Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-export all blob types #30

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading