-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rename blob and index client capabilities
- Loading branch information
1 parent
604d300
commit addfb05
Showing
22 changed files
with
513 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,16 @@ | ||
import { Space } from '@web3-storage/capabilities' | ||
import { DID } from '@ucanto/validator' | ||
import * as Provider from '@ucanto/server' | ||
import * as API from './types.js' | ||
|
||
/** | ||
* @param {API.Input<Space.info>} input | ||
* @param {API.SpaceServiceContext} ctx | ||
* @returns {Promise<API.Result<API.SpaceInfoSuccess, API.SpaceInfoFailure>>} | ||
*/ | ||
export const info = async ({ capability }, ctx) => { | ||
const { provisionsStorage: provisions } = ctx | ||
|
||
const spaceDid = capability.with | ||
if (!DID.match({ method: 'key' }).is(spaceDid)) { | ||
/** @type {API.SpaceUnknown} */ | ||
const unexpectedSpaceDidFailure = { | ||
name: 'SpaceUnknown', | ||
message: `can only get info for did:key spaces`, | ||
} | ||
return { | ||
error: unexpectedSpaceDidFailure, | ||
} | ||
} | ||
|
||
const result = await provisions.getStorageProviders(spaceDid) | ||
const providers = result.ok | ||
if (providers && providers.length > 0) { | ||
return { | ||
ok: { | ||
did: spaceDid, | ||
providers, | ||
}, | ||
} | ||
} | ||
|
||
/** @type {import('@web3-storage/access/types').SpaceUnknown} */ | ||
const spaceUnknownFailure = { | ||
name: 'SpaceUnknown', | ||
message: `Space not found.`, | ||
} | ||
return { | ||
error: spaceUnknownFailure, | ||
} | ||
} | ||
import { info } from './space/info.js' | ||
import { createService as createBlobService } from './blob.js' | ||
import { createService as createIndexService } from './index.js' | ||
|
||
/** | ||
* @param {API.SpaceServiceContext} ctx | ||
* @param {API.SpaceServiceContext & API.BlobServiceContext & API.IndexServiceContext} ctx | ||
*/ | ||
export const createService = (ctx) => ({ | ||
info: Provider.provide(Space.info, (input) => info(input, ctx)), | ||
blob: createBlobService(ctx), | ||
index: createIndexService(ctx), | ||
}) |
Oops, something went wrong.