-
Notifications
You must be signed in to change notification settings - Fork 7
Consume upload-client
and access-client
#56
Comments
Will |
This looks good to me, the wrapping of stuff is similar to what we had hoped to do before so I think this is a great api. My only concern is the "overlap" of uploadFile, and upload.* namespaces (I think that internally uploadFile will call the other and handle it, but that is exposed as a lower level api? If so, I think that's fine but we should clarify in docs or etc). |
If the file is smaller then the minimum shard size then it won't be sharded. It can definitely auto inline but that's not something that we support yet!
Yes, root API |
Totally valid, my current thinking is to put these under |
This PR updates `w3up-client` to consume the [access-client](https://www.npmjs.com/package/@web3-storage/access) and [upload-client](https://www.npmjs.com/package/@web3-storage/upload-client) modules. It brings: * Convenience methods for storing files/directories and registering uploads * Automatic CAR sharding * Support for store/upload list pagination * Automatic data store selection (IndexedDB in browser, Conf in Node.js) * Automatic key selection (RSA in browser, Ed25519 in Node.js) * 100% test coverage It exports the following API: ```ts export class Client { /* passthroughs to `upload-client` */ uploadFile(file: Blob, options: UploadOptions): Promise<CID> uploadDirectory(dir: File[], options: UploadOptions): Promise<CID> /* passthroughs to `access-client` */ agent(): Signer // space management currentSpace(): Space|undefined setCurrentSpace(did: DID): Promise<void> spaces(): Space[] createSpace(name?: string): Promise<DID> registerSpace(email: string): Promise<void> addSpace(proof: Delegation): Promise<void> // capability management proofs(): Delegation[] addProof(proof: Delegation): Promise<void> delegations(): Delegation[] createDelegation(audience: Principal, abilities: Abilities[], options: DelegationOptions): Delegation /* Advanced API - grouped by capability namespace: *************************/ capability: { /* passthroughs to `upload-client` */ store: { add(carBytes: Blob, options: RequestOptions): Promise<CID> remove(carCID: CID, options: RequestOptions): Promise<void> list(options: ListRequestOptions): Promise<ListResponse<StoreListResult>> } /* passthroughs to `upload-client` */ upload: { add(root: CID, shards: CID[], options: RequestOptions): Promise<void> remove(root: CID, options: RequestOptions): Promise<void> list(options: ListRequestOptions): Promise<ListResponse<UploadListResult>> } /* passthroughs to `access-client` */ space { info(space: DID): Promise<SpaceInfo> recover(space: DID, email: string): Promise<void> } } } export function create(options?: ClientFactoryOptions): Promise<Client> ``` resolves #56 BREAKING CHANGE: The client has been re-written as a wrapper around [access-client](https://www.npmjs.com/package/@web3-storage/access) and [upload-client](https://www.npmjs.com/package/@web3-storage/upload-client) and the API has changed. Migration notes: * `client.account()` has been removed, use `client.currentSpace()` * `client.exportDelegation()` has been removed, use `client.createDelegation()` and then call `export()` on the returned value and encode the returned blocks as a CAR file using the [`@ipld/car`](https://www.npmjs.com/package/@ipld/car) library. * `client.identity()` has been removed, use `client.agent()` + `client.currentSpace()` + `client.delegations()` * `client.importDelegation()` has been removed, use `client.addProof()` (for general delegations to your agent) or `client.addSpace()` (to add a proof and _also_ add the space to your list of spaces). * `client.insights()` has been removed - this was never working * `client.invoke()` has been removed * `client.list()` has been removed, use `client.capability.upload.list()` * `client.makeDelegation()` has been renamed and signature has changed, use `client.createDelegation()` * `client.register()` has been removed, use `client.registerSpace()` * `client.remove()` has been removed, use `client.capability.store.remove()` * `client.removeUpload()` has been removed, use `client.capability.upload.remove()` * `client.stat()` has been removed, use `client.capability.store.list()` * `client.upload()` has been removed, use `client.capability.store.add()` * `client.uploadAdd()` has been removed, use `client.capability.upload.add()` * `client.whoami()` has been removed, use `client.capability.space.info()`
This module will become a thin wrapper around
access-client
andupload-client
, with the following proposed API:The text was updated successfully, but these errors were encountered: