Skip to content

Commit

Permalink
fix: re-export all blob types (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw authored Nov 5, 2024
1 parent 4c094ed commit b10046b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
7 changes: 0 additions & 7 deletions packages/upload-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
"space": [
"dist/src/space.d.ts"
],
"store": [
"dist/src/store.d.ts"
],
"subscription": [
"dist/src/subscription.d.ts"
],
Expand Down Expand Up @@ -146,10 +143,6 @@
"types": "./dist/src/space.d.ts",
"import": "./src/space.js"
},
"./store": {
"types": "./dist/src/store.d.ts",
"import": "./src/store.js"
},
"./subscription": {
"types": "./dist/src/subscription.d.ts",
"import": "./src/subscription.js"
Expand Down
8 changes: 2 additions & 6 deletions packages/upload-api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,8 @@ export type { SubscriptionsStorage }
import { UsageStorage } from './types/usage.js'
export type { UsageStorage }
import { StorageGetError } from './types/storage.js'
import {
Registry as BlobRegistry,
Entry as BlobEntry,
RoutingService,
} from './types/blob.js'
export type { BlobRegistry, BlobEntry, RoutingService }
import { Registry as BlobRegistry, RoutingService } from './types/blob.js'
export type * as BlobAPI from './types/blob.js'
import { IndexServiceContext } from './types/index.js'
import { ClaimsClientConfig } from './types/content-claims.js'
import { Claim } from '@web3-storage/content-claims/client/api'
Expand Down
12 changes: 6 additions & 6 deletions packages/upload-api/test/storage/blob-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as API from '../../src/types.js'
import { ok, error, Failure } from '@ucanto/core'
import { equals } from 'multiformats/bytes'

/** @implements {API.BlobRegistry} */
/** @implements {API.BlobAPI.Registry} */
export class Registry {
constructor() {
/** @type {Map<import('@storacha/access').SpaceDID, API.BlobEntry[]>} */
/** @type {Map<import('@storacha/access').SpaceDID, API.BlobAPI.Entry[]>} */
this.data = new Map()
}

/** @type {API.BlobRegistry['register']} */
/** @type {API.BlobAPI.Registry['register']} */
async register({ space, cause, blob }) {
const entries = this.data.get(space) ?? []
if (entries.some((e) => equals(e.blob.digest, blob.digest))) {
Expand All @@ -20,15 +20,15 @@ export class Registry {
return ok({})
}

/** @type {API.BlobRegistry['find']} */
/** @type {API.BlobAPI.Registry['find']} */
async find(space, digest) {
const entries = this.data.get(space) ?? []
const entry = entries.find((e) => equals(e.blob.digest, digest.bytes))
if (!entry) return error(new EntryNotFound())
return ok(entry)
}

/** @type {API.BlobRegistry['deregister']} */
/** @type {API.BlobAPI.Registry['deregister']} */
async deregister(space, digest) {
const entries = this.data.get(space) ?? []
const entry = entries.find((e) => equals(e.blob.digest, digest.bytes))
Expand All @@ -40,7 +40,7 @@ export class Registry {
return ok({})
}

/** @type {API.BlobRegistry['entries']} */
/** @type {API.BlobAPI.Registry['entries']} */
async entries(space, options) {
const entries = this.data.get(space) ?? []
const { cursor = '0', size = entries.length } = options ?? {}
Expand Down

0 comments on commit b10046b

Please sign in to comment.