Skip to content

Commit

Permalink
feat: upload/remove returns removed item (#289)
Browse files Browse the repository at this point in the history
needed by storacha/w3cli#20 to find which
shards to also remove when removing an upload

License: MIT
Signed-off-by: Oli Evans <[email protected]>
  • Loading branch information
olizilla authored Dec 13, 2022
1 parent 66be860 commit 5e6681f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/upload-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface Service {
upload: {
add: ServiceMethod<UploadAdd, UploadAddResponse, never>
list: ServiceMethod<UploadList, ListResponse<UploadListResult>, never>
remove: ServiceMethod<UploadRemove, null, never>
remove: ServiceMethod<UploadRemove, UploadRemoveResponse | undefined, never>
}
}

Expand All @@ -51,6 +51,8 @@ export interface UploadAddResponse {
shards?: CARLink[]
}

export interface UploadRemoveResponse extends UploadAddResponse {}

export interface ListResponse<R> {
cursor?: string
size: number
Expand Down
2 changes: 2 additions & 0 deletions packages/upload-client/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,6 @@ export async function remove(
cause: result,
})
}

return result
}
2 changes: 1 addition & 1 deletion packages/upload-client/test/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ describe('Upload.remove', () => {
assert.equal(invCap.can, UploadCapabilities.remove.can)
assert.equal(invCap.with, space.did())
assert.equal(String(invCap.nb?.root), car.roots[0].toString())
return null
return { root: car.roots[0] }
}),
},
})
Expand Down

0 comments on commit 5e6681f

Please sign in to comment.