Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Nov 11, 2024
1 parent 746b6f0 commit df8b7c1
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 22 deletions.
9 changes: 1 addition & 8 deletions packages/capabilities/src/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
*/
import { capability, Schema, Link, ok } from '@ucanto/validator'
import { content } from './space/blob.js'
import {
equalBlob,
equalWith,
and,
equal,
checkLink,
Await,
} from './utils.js'
import { equalBlob, equalWith, and, equal, checkLink, Await } from './utils.js'

/**
* Capability can only be delegated (but not invoked) allowing audience to
Expand Down
4 changes: 2 additions & 2 deletions packages/upload-api/src/blob/accept.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export const poll = async (context, receipt) => {
cause: allocate.nb.cause,
blob: {
digest: Digest.decode(allocate.nb.blob.digest),
size: allocate.nb.blob.size
}
size: allocate.nb.blob.size,
},
})
if (register.error) {
// it's ok if there's already a registration of this blob in this space
Expand Down
4 changes: 2 additions & 2 deletions packages/upload-api/src/blob/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export function blobGetProvider(context) {
return Server.ok({
blob: {
digest: res.ok.blob.digest.bytes,
size: res.ok.blob.size
size: res.ok.blob.size,
},
cause: res.ok.cause,
insertedAt: res.ok.insertedAt.toISOString()
insertedAt: res.ok.insertedAt.toISOString(),
})
})
}
8 changes: 4 additions & 4 deletions packages/upload-api/src/blob/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export function blobListProvider(context) {
}
return Server.ok({
...result.ok,
results: result.ok.results.map(r => ({
results: result.ok.results.map((r) => ({
blob: {
digest: r.blob.digest.bytes,
size: r.blob.size
size: r.blob.size,
},
cause: r.cause,
insertedAt: r.insertedAt.toISOString()
}))
insertedAt: r.insertedAt.toISOString(),
})),
})
})
}
6 changes: 5 additions & 1 deletion packages/upload-api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ import { RevocationsStorage } from './types/revocations.js'
export * from '@storacha/capabilities/types'
export * from '@ucanto/interface'

export type { ProvisionsStorage, Provision, Subscription } from './types/provisions.js'
export type {
ProvisionsStorage,
Provision,
Subscription,
} from './types/provisions.js'
export type {
DelegationsStorage,
Query as DelegationsStorageQuery,
Expand Down
8 changes: 7 additions & 1 deletion packages/upload-api/test/external-service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { BrowserStorageNode, StorageNode } from './storage-node.js'
import * as BlobRetriever from './blob-retriever.js'
import * as RoutingService from './router.js'

export { ClaimsService, BrowserStorageNode, StorageNode, BlobRetriever, RoutingService }
export {
ClaimsService,
BrowserStorageNode,
StorageNode,
BlobRetriever,
RoutingService,
}

/**
* @param {object} config
Expand Down
12 changes: 10 additions & 2 deletions packages/upload-api/test/external-service/storage-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { ed25519 } from '@ucanto/principal'
import { CAR, HTTP } from '@ucanto/transport'
import * as Server from '@ucanto/server'
import { connect } from '@ucanto/client'
import { AllocatedMemoryNotWrittenError, BlobSizeLimitExceededError } from '../../src/blob.js'
import {
AllocatedMemoryNotWrittenError,
BlobSizeLimitExceededError,
} from '../../src/blob.js'

/**
* @typedef {{
Expand Down Expand Up @@ -61,7 +64,12 @@ const createService = ({
const digest = Digest.decode(capability.nb.blob.digest)
const checksum = base64pad.baseEncode(digest.digest)
if (capability.nb.blob.size > MaxUploadSize) {
return error(new BlobSizeLimitExceededError(capability.nb.blob.size, MaxUploadSize))
return error(
new BlobSizeLimitExceededError(
capability.nb.blob.size,
MaxUploadSize
)
)
}
if (await contentStore.has(digest)) {
return ok({ size: 0 })
Expand Down
2 changes: 1 addition & 1 deletion packages/upload-api/test/handlers/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const test = {
proofs: [proof],
// Note: we have to set an expiration, or the default expiration value
// will be set when the invocation is executed and the UCAN issued.
expiration: (Math.floor(Date.now() / 1000)) + 10
expiration: Math.floor(Date.now() / 1000) + 10,
})
// Invoke `blob/add` for the first time
const firstBlobAdd = await invocation.execute(connection)
Expand Down
4 changes: 3 additions & 1 deletion packages/upload-api/test/storage/blob-registry-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export const test = {
assert.ok(find1.ok)
assert.ok(find1.ok?.blob)
assert.equal(find1.ok?.blob.size, data.length)
assert.ok(equals(digest.bytes, find1.ok?.blob.digest.bytes || new Uint8Array()))
assert.ok(
equals(digest.bytes, find1.ok?.blob.digest.bytes || new Uint8Array())
)
assert.equal(find1.ok?.cause.toString(), cause.toString())
},
'should list all blobs in a space': async (assert, context) => {
Expand Down

0 comments on commit df8b7c1

Please sign in to comment.