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

feat: add pre caveat to store/list and upload/list #423

Merged
merged 6 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions packages/capabilities/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export const list = base.derive({
* Maximum number of items per page.
*/
size: Schema.integer().optional(),
/**
* If true, return page of results preceding cursor. Defaults to false.
*/
prev: Schema.boolean().optional(),
},
derives: (claimed, delegated) => {
if (claimed.with !== delegated.with) {
Expand Down
4 changes: 4 additions & 0 deletions packages/capabilities/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export const list = base.derive({
* Maximum number of items per page.
*/
size: Schema.integer().optional(),
/**
* If true, return page of results preceding cursor. Defaults to false.
*/
prev: Schema.boolean().optional(),
},
}),
/**
Expand Down
1 change: 1 addition & 0 deletions packages/upload-client/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export async function list(
nb: {
cursor: options.cursor,
size: options.size,
prev: options.prev,
},
})
.execute(conn)
Expand Down
4 changes: 4 additions & 0 deletions packages/upload-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ export interface Pageable {
* Maximum number of items to return.
*/
size?: number
/**
* If true, return page of results preceding cursor. Defaults to false.
*/
prev?: boolean
}

export interface RequestOptions extends Retryable, Abortable, Connectable {}
Expand Down
1 change: 1 addition & 0 deletions packages/upload-client/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export async function list(
nb: {
cursor: options.cursor,
size: options.size,
prev: options.prev,
},
})
.execute(conn)
Expand Down
8 changes: 8 additions & 0 deletions spec/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ The `with` field of the invocation must be set to the DID of the memory space to

`cursor` can be set to start listing from an item in the middle of the list. Its value should be a `cursor` returned by a previous invocation of `store/list`
`size` can be set to change the number of items returned by an `store/list` invocation
`prev` can be set to `true` to return the page of results preceding `cursor` rather than the results after `cursor`. Defaults to `false`.

| field | value | required? | context |
| ----------- | ------------------------ | --------- | --------------------------------------------------------------- |
| `nb.cursor` | string | ❌ | A cursor returned by a previous invocation |
| `nb.size` | integer | ❌ | The maximum number of results to return |
| `nb.prev` | boolean | ❌ | If true, return previous page of results |

## `upload/` namespace

Expand Down Expand Up @@ -286,12 +288,18 @@ The `with` field of the invocation must be set to the DID of the memory space to

`cursor` can be set to start listing from an item in the middle of the list. Its value should be a `cursor` returned by a previous invocation of `upload/list`
`size` can be set to change the number of items returned by an `upload/list` invocation
`prev` can be set to `true` to return the page of results preceding `cursor` rather than the results after `cursor`. Defaults to `false`.

| field | value | required? | context |
| ----------- | ------------------------ | --------- | --------------------------------------------------------------- |
| `nb.cursor` | string | ❌ | A cursor returned by a previous invocation |
| `nb.size` | integer | ❌ | The maximum number of results to return |

| field | value | required? | context |
| ----------- | ------------------------ | --------- | --------------------------------------------------------------- |
| `nb.cursor` | string | ❌ | A cursor returned by a previous invocation |
| `nb.size` | integer | ❌ | The maximum number of results to return |
| `nb.prev` | boolean | ❌ | If true, return previous page of results |
## `voucher/` namespace

TODO: more voucher docs when implementation details settle down a bit.
Expand Down