diff --git a/packages/access-client/src/capabilities/store.js b/packages/access-client/src/capabilities/store.js index 2c7153cdf..78ee6c225 100644 --- a/packages/access-client/src/capabilities/store.js +++ b/packages/access-client/src/capabilities/store.js @@ -130,6 +130,18 @@ export const list = base.derive({ * be stored. */ with: URI.match({ protocol: 'did:' }), + nb: { + /** + * CID of the item where a previous list operation stopped, inclusive of + * the previous result set. Use this value to start a new operation, in + * order to paginate list. + */ + cursor: Link.optional(), + /** + * Size of the page being requested to list. + */ + size: Schema.integer().optional(), + }, derives: (claimed, delegated) => { if (claimed.with !== delegated.with) { return new Failure( diff --git a/packages/access-client/src/capabilities/upload.js b/packages/access-client/src/capabilities/upload.js index 5f589bb9c..eaf2a3de5 100644 --- a/packages/access-client/src/capabilities/upload.js +++ b/packages/access-client/src/capabilities/upload.js @@ -1,4 +1,4 @@ -import { capability, Link, URI } from '@ucanto/validator' +import { capability, Link, URI, Schema } from '@ucanto/validator' import { codec as CAR } from '@ucanto/transport/car' import { equalWith, fail, equal } from './utils.js' import { any } from './any.js' @@ -130,6 +130,18 @@ export const list = base.derive({ to: capability({ can: 'upload/list', with: URI.match({ protocol: 'did:' }), + nb: { + /** + * CID of the item where a previous list operation stopped, inclusive of + * the previous result set. Use this value to start a new operation, in + * order to paginate list. + */ + cursor: Link.optional(), + /** + * Size of the page being requested to list. + */ + size: Schema.integer().optional(), + }, }), /** * `upload/list` can be derived from the `upload/*` & `*` capability @@ -140,4 +152,4 @@ export const list = base.derive({ // ⚠️ We export imports here so they are not omited in generated typedefs // @see https://github.com/microsoft/TypeScript/issues/51548 -export { Link } +export { Link, Schema } diff --git a/packages/access-client/test/capabilities/upload.test.js b/packages/access-client/test/capabilities/upload.test.js index 31422a8a1..0fb3fdc1d 100644 --- a/packages/access-client/test/capabilities/upload.test.js +++ b/packages/access-client/test/capabilities/upload.test.js @@ -328,6 +328,7 @@ describe('upload capabilities', function () { audience: w3, with: account.did(), proofs: [await any], + nb: {}, }) const result = await access(await list.delegate(), { @@ -357,6 +358,7 @@ describe('upload capabilities', function () { issuer: bob, with: account.did(), proofs: [await upload.delegate()], + nb: {}, }) const result = await access(await list.delegate(), { @@ -379,6 +381,7 @@ describe('upload capabilities', function () { audience: bob, with: account.did(), proofs: [await any], + nb: {}, }) const list = Upload.list.invoke({ @@ -386,6 +389,7 @@ describe('upload capabilities', function () { issuer: bob, with: account.did(), proofs: [await delegation.delegate()], + nb: {}, }) const result = await access(await list.delegate(), {