import type { TupleToUnion } from 'type-fest'; import * as Ucanto from '@ucanto/interface'; import type { Schema } from '@ucanto/core'; import { InferInvokedCapability, Unit, DID, DIDKey, ToString, Link, Failure, UnknownLink } from '@ucanto/interface'; import { CAR } from '@ucanto/transport'; import { Phantom, PieceLink, ProofData, uint64 } from '@web3-storage/data-segment'; import * as SpaceCaps from './space.js'; import * as provider from './provider.js'; import { top } from './top.js'; import * as BlobCaps from './blob.js'; import * as W3sBlobCaps from './web3.storage/blob.js'; import * as HTTPCaps from './http.js'; import * as StoreCaps from './store.js'; import * as UploadCaps from './upload.js'; import * as AccessCaps from './access.js'; import * as CustomerCaps from './customer.js'; import * as ConsumerCaps from './consumer.js'; import * as SubscriptionCaps from './subscription.js'; import * as RateLimitCaps from './rate-limit.js'; import * as StorefrontCaps from './filecoin/storefront.js'; import * as AggregatorCaps from './filecoin/aggregator.js'; import * as DealTrackerCaps from './filecoin/deal-tracker.js'; import * as DealerCaps from './filecoin/dealer.js'; import * as IndexCaps from './index/index.js'; import * as AdminCaps from './admin.js'; import * as UCANCaps from './ucan.js'; import * as PlanCaps from './plan.js'; import * as UsageCaps from './usage.js'; export type ISO8601Date = string; export type { Unit, PieceLink }; export interface UCANAwait { 'ucan/await': [Selector, Link]; } /** * An IPLD Link that has the CAR codec code. */ export type CARLink = Link; export type Multihash = Uint8Array; export type AccountDID = DID<'mailto'>; export type SpaceDID = DID<'key'>; /** * Error for cases where an interface implementation needs to return an * error that isn't defined explicitly in the interface. */ export interface UnexpectedError extends Ucanto.Failure { name: 'UnexpectedError'; cause: unknown; } /** * failure due to a resource not having enough storage capacity. */ export interface InsufficientStorage { name: 'InsufficientStorage'; message: string; } export interface UnknownProvider extends Failure { name: 'UnknownProvider'; did: DID; } /** * @see https://github.com/filecoin-project/FIPs/pull/758/files */ export type PieceLinkSchema = Schema.Schema; export type Access = InferInvokedCapability; export type AccessAuthorize = InferInvokedCapability; export interface AccessAuthorizeSuccess { request: Link; expiration: number; } export interface AccessAuthorizeFailure extends Ucanto.Failure { } export type AccessClaim = InferInvokedCapability; export interface AccessClaimSuccess { delegations: Record>; } export interface AccessClaimFailure extends Ucanto.Failure { name: 'AccessClaimFailure'; message: string; } export interface AccessConfirmSuccess { delegations: Record>; } export interface AccessConfirmFailure extends Ucanto.Failure { } export type AccessDelegate = InferInvokedCapability; export type AccessDelegateSuccess = Unit; export type AccessDelegateFailure = InsufficientStorage | DelegationNotFound; export interface DelegationNotFound extends Ucanto.Failure { name: 'DelegationNotFound'; } export type AccessConfirm = InferInvokedCapability; export type Usage = InferInvokedCapability; export type UsageReport = InferInvokedCapability; export type UsageReportSuccess = Record; export type UsageReportFailure = Ucanto.Failure; export interface UsageData { /** Provider the report concerns, e.g. `did:web:web3.storage` */ provider: ProviderDID; /** Space the report concerns. */ space: SpaceDID; /** Period the report applies to. */ period: { /** ISO datetime the report begins from (inclusive). */ from: ISO8601Date; /** ISO datetime the report ends at (inclusive). */ to: ISO8601Date; }; /** Observed space size for the period. */ size: { /** Size at the beginning of the report period. */ initial: number; /** Size at the end of the report period. */ final: number; }; /** Events that caused the size to change during the period. */ events: Array<{ /** CID of the invoked task that caused the size to change. */ cause: Link; /** Number of bytes that were added or removed. */ delta: number; /** ISO datetime that the receipt was issued for the change. */ receiptAt: ISO8601Date; }>; } export interface EgressData { /** The space which contains the resource that was served. */ space: SpaceDID; /** The customer that is being billed for the egress traffic. */ customer: AccountDID; /** CID of the resource that was served it's the CID of some gateway accessible content. It is not the CID of a blob/shard.*/ resource: UnknownLink; /** Amount of bytes served. */ bytes: number; /** ISO datetime that the bytes were served at. */ servedAt: ISO8601Date; /** Identifier of the invocation that caused the egress traffic. */ cause: UnknownLink; } export type ProviderAdd = InferInvokedCapability; export interface ProviderAddSuccess { } export type ProviderAddFailure = InvalidProvider | Ucanto.Failure; export type ProviderDID = DID<'web'>; export interface InvalidProvider extends Ucanto.Failure { name: 'InvalidProvider'; } export type CustomerGet = InferInvokedCapability; export interface CustomerGetSuccess { did: AccountDID; subscriptions: string[]; } export interface CustomerNotFound extends Ucanto.Failure { name: 'CustomerNotFound'; } export type CustomerGetFailure = CustomerNotFound | Ucanto.Failure; export type ConsumerHas = InferInvokedCapability; export type ConsumerHasSuccess = boolean; export type ConsumerHasFailure = Ucanto.Failure; export type ConsumerGet = InferInvokedCapability; export interface ConsumerGetSuccess { did: DIDKey; allocated: number; limit: number; subscription: string; customer: AccountDID; } export interface ConsumerNotFound extends Ucanto.Failure { name: 'ConsumerNotFound'; } export type ConsumerGetFailure = ConsumerNotFound | Ucanto.Failure; export type SubscriptionGet = InferInvokedCapability; export interface SubscriptionGetSuccess { customer: AccountDID; consumer?: DIDKey; } export interface SubscriptionNotFound extends Ucanto.Failure { name: 'SubscriptionNotFound'; } export type SubscriptionGetFailure = SubscriptionNotFound | UnknownProvider | Ucanto.Failure; export type SubscriptionList = InferInvokedCapability; export interface SubscriptionListSuccess { results: Array; } export interface SubscriptionListItem { subscription: string; provider: ProviderDID; consumers: SpaceDID[]; } export type SubscriptionListFailure = Ucanto.Failure; export type RateLimitAdd = InferInvokedCapability; export interface RateLimitAddSuccess { id: string; } export type RateLimitAddFailure = Ucanto.Failure; export type RateLimitRemove = InferInvokedCapability; export type RateLimitRemoveSuccess = Unit; export interface RateLimitsNotFound extends Ucanto.Failure { name: 'RateLimitsNotFound'; } export type RateLimitRemoveFailure = RateLimitsNotFound | Ucanto.Failure; export type RateLimitList = InferInvokedCapability; export interface RateLimitSubject { id: string; rate: number; } export interface RateLimitListSuccess { limits: RateLimitSubject[]; } export type RateLimitListFailure = Ucanto.Failure; export type Space = InferInvokedCapability; export type SpaceInfo = InferInvokedCapability; export type SpaceContentServe = InferInvokedCapability; export type EgressRecord = InferInvokedCapability; export type EgressRecordSuccess = { space: SpaceDID; resource: UnknownLink; bytes: number; servedAt: ISO8601Date; cause: UnknownLink; }; export type EgressRecordFailure = ConsumerNotFound | Ucanto.Failure; export interface DealMetadata { dataType: uint64; dataSource: SingletonMarketSource; } /** @see https://github.com/filecoin-project/go-data-segment/blob/e3257b64fa2c84e0df95df35de409cfed7a38438/datasegment/verifier.go#L8-L14 */ export interface DataAggregationProof { /** * Proof the piece is included in the aggregate. */ inclusion: InclusionProof; /** * Filecoin deal metadata. */ aux: DealMetadata; } /** @see https://github.com/filecoin-project/go-data-segment/blob/e3257b64fa2c84e0df95df35de409cfed7a38438/datasegment/inclusion.go#L30-L39 */ export interface InclusionProof { /** * Proof of inclusion of the client's data segment in the data aggregator's * Merkle tree (includes position information). i.e. a proof that the root * node of the subtree containing all the nodes (leafs) of a data segment is * contained in CommDA. */ subtree: ProofData; /** * Proof that an entry for the user's data is contained in the index of the * aggregator's deal. i.e. a proof that the data segment index constructed * from the root of the user's data segment subtree is contained in the index * of the deal tree. */ index: ProofData; } export interface SingletonMarketSource { dealID: uint64; } export interface FilecoinOfferSuccess { /** * Commitment proof for piece. */ piece: PieceLink; } export type FilecoinOfferFailure = ContentNotFound | Ucanto.Failure; export interface ContentNotFound extends Ucanto.Failure { name: 'ContentNotFound'; content: Link; } export interface FilecoinSubmitSuccess { /** * Commitment proof for piece. */ piece: PieceLink; } export type FilecoinSubmitFailure = InvalidPieceCID | Ucanto.Failure; export interface FilecoinAcceptSuccess extends DataAggregationProof { aggregate: PieceLink; piece: PieceLink; } export type FilecoinAcceptFailure = InvalidContentPiece | ProofNotFound | Ucanto.Failure; export interface InvalidContentPiece extends Ucanto.Failure { name: 'InvalidContentPiece'; content: PieceLink; } export interface ProofNotFound extends Ucanto.Failure { name: 'ProofNotFound'; } export interface FilecoinInfoSuccess { piece: PieceLink; aggregates: FilecoinInfoAcceptedAggregate[]; deals: FilecoinInfoAcceptedDeal[]; } export interface FilecoinInfoAcceptedAggregate { /** * Aggregate piece CID. */ aggregate: PieceLink; /** * Proof the piece is included in the aggregate. */ inclusion: InclusionProof; } export interface FilecoinInfoAcceptedDeal extends Omit, DealDetails { aggregate: PieceLink; } export type FilecoinInfoFailure = ContentNotFound | InvalidContentPiece | Ucanto.Failure; export interface PieceOfferSuccess { /** * Commitment proof for piece. */ piece: PieceLink; } export type PieceOfferFailure = Ucanto.Failure; export interface PieceAcceptSuccess { /** * Commitment proof for piece. */ piece: PieceLink; /** * Commitment proof for aggregate. */ aggregate: PieceLink; /** * Proof the piece is included in the aggregate. */ inclusion: InclusionProof; } export type PieceAcceptFailure = Ucanto.Failure; export interface AggregateOfferSuccess { /** * Commitment proof for aggregate. */ aggregate: PieceLink; } export type AggregateOfferFailure = Ucanto.Failure; export interface AggregateAcceptSuccess extends DealMetadata { aggregate: PieceLink; } export type AggregateAcceptFailure = InvalidPiece | Ucanto.Failure; export interface InvalidPiece extends Ucanto.Failure { name: 'InvalidPiece'; /** * Commitment proof for aggregate. */ aggregate: PieceLink; cause: InvalidPieceCID[]; } export interface InvalidPieceCID extends Ucanto.Failure { name: 'InvalidPieceCID'; piece: PieceLink; } export interface DealInfoSuccess { deals: Record, DealDetails>; } export interface DealDetails { provider: FilecoinAddress; } export type FilecoinAddress = string; export type DealInfoFailure = DealNotFound | Ucanto.Failure; export interface DealNotFound extends Ucanto.Failure { name: 'DealNotFound'; } export type Upload = InferInvokedCapability; export type UploadAdd = InferInvokedCapability; export type UploadGet = InferInvokedCapability; export type UploadRemove = InferInvokedCapability; export type UploadList = InferInvokedCapability; export interface UploadNotFound extends Ucanto.Failure { name: 'UploadNotFound'; } export type UploadGetFailure = UploadNotFound | Ucanto.Failure; export type HTTPPut = InferInvokedCapability; export type Index = InferInvokedCapability; export type IndexAdd = InferInvokedCapability; export type IndexAddSuccess = Unit; export type IndexAddFailure = IndexNotFound | DecodeFailure | UnknownFormat | ShardNotFound | SliceNotFound | Failure; /** An error occurred when decoding the data. */ export interface DecodeFailure extends Failure { name: 'DecodeFailure'; } /** The data is not in a format understood by the service. */ export interface UnknownFormat extends Failure { name: 'UnknownFormat'; } /** The index is not stored in the referenced space. */ export interface IndexNotFound extends Failure { name: 'IndexNotFound'; /** Multihash digest of the index that could not be found. */ digest: Multihash; } /** A shard referenced by the index is not stored in the referenced space. */ export interface ShardNotFound extends Failure { name: 'ShardNotFound'; /** Multihash digest of the shard that could not be found. */ digest: Multihash; } /** A slice referenced by the index was not found in the specified shard. */ export interface SliceNotFound extends Failure { name: 'SliceNotFound'; /** Multihash digest of the slice that could not be found. */ digest: Multihash; } export type Blob = InferInvokedCapability; export type BlobAdd = InferInvokedCapability; export type BlobRemove = InferInvokedCapability; export type BlobList = InferInvokedCapability; export type BlobGet = InferInvokedCapability; export type ServiceBlob = InferInvokedCapability; export type BlobAllocate = InferInvokedCapability; export type BlobAccept = InferInvokedCapability; export interface BlobModel { digest: Multihash; size: number; } export interface BlobAddSuccess { site: UCANAwait<'.out.ok.site'>; } export interface BlobSizeOutsideOfSupportedRange extends Ucanto.Failure { name: 'BlobSizeOutsideOfSupportedRange'; } export interface AwaitError extends Ucanto.Failure { name: 'AwaitError'; } export type BlobAddFailure = BlobSizeOutsideOfSupportedRange | AwaitError | StorageGetError | Ucanto.Failure; export interface BlobListItem { blob: BlobModel; insertedAt: ISO8601Date; } export interface BlobRemoveSuccess { size: number; } export type BlobRemoveFailure = Ucanto.Failure; export interface BlobListSuccess extends ListResponse { } export type BlobListFailure = Ucanto.Failure; export interface BlobGetSuccess { blob: { digest: Uint8Array; size: number; }; cause: UnknownLink; } export type BlobGetFailure = Ucanto.Failure; export interface BlobAllocateSuccess { size: number; address?: BlobAddress; } export interface BlobAddress { url: ToString; headers: Record; expiresAt: ISO8601Date; } export interface NotEnoughStorageCapacity extends Ucanto.Failure { name: 'NotEnoughStorageCapacity'; } export type BlobAllocateFailure = NotEnoughStorageCapacity | Ucanto.Failure; export interface BlobAcceptSuccess { site: Link; } export interface AllocatedMemoryHadNotBeenWrittenTo extends Ucanto.Failure { name: 'AllocatedMemoryHadNotBeenWrittenTo'; } export type BlobAcceptFailure = AllocatedMemoryHadNotBeenWrittenTo | Ucanto.Failure; export type StoragePutError = StorageOperationError; export type StorageGetError = StorageOperationError | RecordNotFound; export interface StorageOperationError extends Error { name: 'StorageOperationFailed'; } export interface RecordNotFound extends Error { name: 'RecordNotFound'; } export type Store = InferInvokedCapability; export type StoreAdd = InferInvokedCapability; export type StoreGet = InferInvokedCapability; export type StoreRemove = InferInvokedCapability; export type StoreList = InferInvokedCapability; export type StoreAddSuccess = StoreAddSuccessDone | StoreAddSuccessUpload; export type StoreAddSuccessStatusUpload = 'upload'; export type StoreAddSuccessStatusDone = 'done'; export interface StoreAddSuccessResult { /** * Status of the item to store. A "done" status indicates that it is not * necessary to upload the item. An "upload" status indicates that the item * should be uploaded to the provided URL. */ status: StoreAddSuccessStatusUpload | StoreAddSuccessStatusDone; /** * Total bytes allocated in the space to accommodate this stored item. * May be zero if the item is _already_ stored in _this_ space. */ allocated: number; /** DID of the space this item will be stored in. */ with: DID; /** CID of the item. */ link: CARLink; } export interface StoreAddSuccessDone extends StoreAddSuccessResult { status: StoreAddSuccessStatusDone; } export interface StoreAddSuccessUpload extends StoreAddSuccessResult { status: StoreAddSuccessStatusUpload; url: ToString; headers: Record; } export interface StoreRemoveSuccess { size: number; } export interface StoreItemNotFound extends Ucanto.Failure { name: 'StoreItemNotFound'; } export type StoreRemoveFailure = StoreItemNotFound | Ucanto.Failure; export type StoreGetSuccess = StoreListItem; export type StoreGetFailure = StoreItemNotFound | Ucanto.Failure; export interface StoreListSuccess extends ListResponse { } export interface ListResponse { cursor?: string; before?: string; after?: string; size: number; results: R[]; } export interface StoreListItem { link: CARLink; size: number; origin?: UnknownLink; insertedAt: ISO8601Date; } export interface UploadListItem { root: UnknownLink; shards?: CARLink[]; insertedAt: ISO8601Date; updatedAt: ISO8601Date; } export type UploadAddSuccess = Omit; export type UploadGetSuccess = UploadListItem; export type UploadRemoveSuccess = UploadAddSuccess; export interface UploadListSuccess extends ListResponse { } export type UCANRevoke = InferInvokedCapability; export type UCANAttest = InferInvokedCapability; export type UCANConclude = InferInvokedCapability; export interface Timestamp { /** * Unix timestamp in seconds. */ time: number; } export type UCANRevokeSuccess = Timestamp; export type UCANConcludeSuccess = Timestamp; /** * Error is raised when `UCAN` being revoked is not supplied or it's proof chain * leading to supplied `scope` is not supplied. */ export interface UCANNotFound extends Ucanto.Failure { name: 'UCANNotFound'; } /** * Error is raised when `UCAN` being revoked does not have provided `scope` in * the proof chain. */ export interface InvalidRevocationScope extends Ucanto.Failure { name: 'InvalidRevocationScope'; } /** * Error is raised when `UCAN` revocation is issued by unauthorized principal, * that is `with` field is not an `iss` of the `scope`. */ export interface UnauthorizedRevocation extends Ucanto.Failure { name: 'UnauthorizedRevocation'; } /** * Error is raised when `UCAN` revocation cannot be stored. This * is usually not a client error. */ export interface RevocationsStoreFailure extends Ucanto.Failure { name: 'RevocationsStoreFailure'; } export type UCANRevokeFailure = UCANNotFound | InvalidRevocationScope | UnauthorizedRevocation | RevocationsStoreFailure; /** * Error is raised when receipt is received for unknown invocation */ export interface ReferencedInvocationNotFound extends Ucanto.Failure { name: 'ReferencedInvocationNotFound'; } export type UCANConcludeFailure = ReferencedInvocationNotFound | Ucanto.Failure; export type Admin = InferInvokedCapability; export type AdminUploadInspect = InferInvokedCapability; export type AdminStoreInspect = InferInvokedCapability; export interface SpaceAdmin { did: DID; insertedAt: string; } export interface AdminUploadInspectSuccess { spaces: SpaceAdmin[]; } export type AdminUploadInspectFailure = Ucanto.Failure; export interface AdminStoreInspectSuccess { spaces: SpaceAdmin[]; } export type AdminStoreInspectFailure = Ucanto.Failure; export type Filecoin = InferInvokedCapability; export type FilecoinOffer = InferInvokedCapability; export type FilecoinSubmit = InferInvokedCapability; export type FilecoinAccept = InferInvokedCapability; export type FilecoinInfo = InferInvokedCapability; export type PieceOffer = InferInvokedCapability; export type PieceAccept = InferInvokedCapability; export type AggregateOffer = InferInvokedCapability; export type AggregateAccept = InferInvokedCapability; export type DealInfo = InferInvokedCapability; export type PlanGet = InferInvokedCapability; export interface PlanGetSuccess { updatedAt: ISO8601Date; product: DID; } export interface PlanNotFound extends Ucanto.Failure { name: 'PlanNotFound'; } export type PlanGetFailure = PlanNotFound | UnexpectedError; export type PlanSet = InferInvokedCapability; export type PlanSetSuccess = Unit; /** * @deprecate currently unused - used to be part of PlanSetFailure but we switched to CustomerNotFound */ export interface AccountNotFound extends Ucanto.Failure { name: 'AccountNotFound'; } export interface InvalidPlanName extends Ucanto.Failure { name: 'InvalidPlanName'; } export interface PlanUpdateError extends Ucanto.Failure { name: 'PlanUpdateError'; } export type PlanSetFailure = CustomerNotFound | PlanUpdateError | UnexpectedError; export type PlanCreateAdminSession = InferInvokedCapability; export interface PlanCreateAdminSessionSuccess { url: string; } export interface AdminSessionNotSupported extends Ucanto.Failure { name: 'AdminSessionNotSupported'; } export type PlanCreateAdminSessionFailure = AdminSessionNotSupported | CustomerNotFound | UnexpectedError; export type Top = InferInvokedCapability; export type ServiceAbility = TupleToUnion; export type ServiceAbilityArray = [ Top['can'], ProviderAdd['can'], Space['can'], SpaceInfo['can'], SpaceContentServe['can'], EgressRecord['can'], Upload['can'], UploadAdd['can'], UploadGet['can'], UploadRemove['can'], UploadList['can'], Store['can'], StoreAdd['can'], StoreGet['can'], StoreRemove['can'], StoreList['can'], Access['can'], AccessAuthorize['can'], UCANAttest['can'], UCANConclude['can'], CustomerGet['can'], ConsumerHas['can'], ConsumerGet['can'], SubscriptionGet['can'], SubscriptionList['can'], RateLimitAdd['can'], RateLimitRemove['can'], RateLimitList['can'], Filecoin['can'], FilecoinOffer['can'], FilecoinSubmit['can'], FilecoinAccept['can'], FilecoinInfo['can'], PieceOffer['can'], PieceAccept['can'], AggregateOffer['can'], AggregateAccept['can'], DealInfo['can'], Admin['can'], AdminUploadInspect['can'], AdminStoreInspect['can'], PlanGet['can'], PlanSet['can'], PlanCreateAdminSession['can'], Usage['can'], UsageReport['can'], Blob['can'], BlobAdd['can'], BlobRemove['can'], BlobList['can'], BlobGet['can'], ServiceBlob['can'], BlobAllocate['can'], BlobAccept['can'], HTTPPut['can'], Index['can'], IndexAdd['can'] ]; /** * @deprecated use ServiceAbility */ export type Abilities = ServiceAbility; /** * @deprecated use ServiceAbilityArray */ export type AbilitiesArray = ServiceAbilityArray; //# sourceMappingURL=types.d.ts.map