import type { HandlerExecutionError, Signer, InboundCodec, CapabilityParser, ParsedCapability, InferInvokedCapability, RevocationChecker, Match, Unit, Result, ConnectionView, } from '@ucanto/interface' import type { ProviderInput } from '@ucanto/server' import { InvocationConfig } from '@web3-storage/filecoin-client/types' export * as UcantoInterface from '@ucanto/interface' export type { Result, Variant } from '@ucanto/interface' export * from '@web3-storage/filecoin-client/types' export * from '@web3-storage/capabilities/types' // Resources export interface Queue { add: ( message: Message, options?: QueueMessageOptions ) => Promise> } export interface Store { /** * Puts a record in the store. */ put: (record: Rec) => Promise> /** * Gets a record from the store. */ get: (key: RecKey) => Promise> /** * Determine if a record already exists in the store for the given key. */ has: (key: RecKey) => Promise> } export interface UpdatableStore { /** * Updates a record from the store. */ update: ( key: RecKey, record: Partial ) => Promise> } export interface ReadableStreamStore { /** * Puts a record in the store. */ put: (record: Rec) => Promise> /** * Gets a record from the store. */ stream: (key: RecKey) => Promise, StoreGetError>> } export interface ListSuccess { /** * Opaque string specifying where to start retrival of the next page of * results. */ cursor?: string results: R[] } export interface Pageable { /** * Opaque string specifying where to start retrival of the next page of * results. */ cursor?: string /** * Maximum number of items to return. */ size?: number } export interface QueryableStore { /** * Queries for record matching a given criteria. */ query: ( search: Query, options?: Pageable ) => Promise, StoreGetError>> } export interface QueueMessageOptions { messageGroupId?: string } // eslint-disable-next-line @typescript-eslint/no-explicit-any export interface ServiceConfig> { connection: ConnectionView invocationConfig: InvocationConfig } // Errors export type StorePutError = StoreOperationError | EncodeRecordFailed export type StoreGetError = | StoreOperationError | EncodeRecordFailed | RecordNotFound export type QueueAddError = QueueOperationError | EncodeRecordFailed export interface QueueOperationError extends Error { name: 'QueueOperationFailed' } export interface StoreOperationError extends Error { name: 'StoreOperationFailed' } export interface RecordNotFound extends Error { name: 'RecordNotFound' } export interface EncodeRecordFailed extends Error { name: 'EncodeRecordFailed' } // Service utils export interface UcantoServerContext extends RevocationChecker { id: Signer codec?: InboundCodec errorReporter: ErrorReporter } export interface ErrorReporter { catch: (error: HandlerExecutionError) => void } // test export interface UcantoServerContextTest extends UcantoServerContext { queuedMessages: Map } export type Test = ( assert: Assert, context: UcantoServerContextTest & S ) => unknown export type Tests = Record> export type Input>> = ProviderInput & ParsedCapability> export interface Assert { equal: ( actual: Actual, expected: Expected, message?: string ) => unknown deepEqual: ( actual: Actual, expected: Expected, message?: string ) => unknown ok: (actual: Actual, message?: string) => unknown }