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

TheCapabilityParser Interface should infer nb is optional if all its properties are optional #140

Open
vasco-santos opened this issue Nov 18, 2022 · 0 comments

Comments

@vasco-santos
Copy link
Contributor

While working on storacha/w3up#184 to add nb properties to store/list and upload/list to support pagination, got to this problem.

When we have nb with all optional properties like:

 nb: {
      /**
       * Item where a previous list operation stopped, inclusive of the previous
       * result set. Use this value to start a new operation, inorder to paginate
       * list.
       */
      cursor: Schema.string().optional(),
      /**
       * Size of the page being requested to list.
       */
      size: Schema.integer().optional(),
    }

and we want to invoke like:

const delegation = Upload.list.invoke({
      issuer: alice,
      audience: bob,
      with: account.did(),
      proofs: [await any],
 })

the interface types fail with Property 'nb' is missing in type. If we just add an empty object for nb there types get happy.

I looked through the types in https://github.com/web3-storage/ucanto/blob/5d04d169d09bd691261ddc86449488c05b093683/packages/interface/src/capability.ts#L178 but could not get to a solution to create PR. Main motivation here is to not require a breaking change to add new optional nb. However, it also makes sense in general to not need to provide empty object if everything is optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant