import { ContractInput, ContractOutput, ContractSchema } from "./contract.mjs"; import { DecodedFailure, ErrorContract, ErrorDefinitions, UnknownFailure } from "./errors.mjs"; //#region src/modules/contracts/exposure.d.ts declare const selectedTypes: unique symbol; declare const executorTypes: unique symbol; type Definition = { input: ContractSchema; result: ContractSchema; wire?: { schema: ContractSchema; }; }; export type OperationPublicResult = D extends { wire: { schema: infer Schema extends ContractSchema; }; } ? ContractInput : ContractOutput; /** Only the selected input/public contracts are exposed, never handlers or other operations. */ export type SelectedOperation = Readonly<{ owner: Owner; key: Key; kind: 'mutation' | 'query'; input: Input; result: ContractSchema; readonly [selectedTypes]: { readonly input: ContractInput; readonly public: Public; }; }>; type Selection = Readonly<{ owner: symbol; key: string; kind: 'mutation' | 'query'; input: ContractSchema; result: ContractSchema; readonly [selectedTypes]: { readonly input: unknown; readonly public: unknown; }; }>; type InputOf = S[typeof selectedTypes]['input']; type PublicOf = S[typeof selectedTypes]['public']; /** Registry integrators must check membership before selecting their own definition. */ export declare function selectOperation(owner: Owner, kind: 'mutation' | 'query', key: Key, definition: D): SelectedOperation>; export type OperationExecutor = Readonly<{ owner: S['owner']; key: S['key']; readonly [executorTypes]: S; }>; /** The host captures authority in an already authorized native Promise call. */ export declare function bindOperationExecutor(selected: S, configuration: { owner: NoInfer; key: NoInfer; execute: (raw: NoInfer>) => Promise>>; }): OperationExecutor; export declare const operationToolDialect: 'https://json-schema.org/draft/2020-12/schema'; type Json = null | boolean | number | string | readonly Json[] | { readonly [key: string]: Json; }; export type OperationToolJsonSchema = Readonly<{ [keyword: string]: Json; }>; export type OperationToolConverter = Readonly<{ dialect: typeof operationToolDialect; /** Represent raw transport input. Unsupported IDs/transforms must throw, never be approximated. */ convert: (input: Input) => OperationToolJsonSchema; }>; export type OperationToolDefinition = Readonly<{ operation: S; executor: OperationExecutor; description: string; converter: OperationToolConverter; errors?: Pick, 'decode'>; }>; type ToolConstraint = Readonly<{ operation: Selection; executor: OperationExecutor; description: string; converter: { dialect: typeof operationToolDialect; convert: (input: never) => OperationToolJsonSchema; }; errors?: Pick, 'decode'>; }>; type Checked = T & OperationToolDefinition; type FailureOf = T extends { errors: Pick, 'decode'>; } ? DecodedFailure : UnknownFailure; export type OperationToolOutcome = Readonly<{ _tag: 'Success'; value: Public; }> | Failure; export type OperationTool = Readonly<{ name: string; description: string; args: OperationToolJsonSchema; invoke: (raw: InputOf) => Promise, FailureOf>>; }>; export declare function createOperationTools>>(definitions: T & { [K in keyof T]: Checked; }): Readonly<{ [K in keyof T]: OperationTool; }>; export declare function createOperationTools(definitions: T & { [K in keyof T]: Checked; }): Readonly<{ [D in T[number] as D['name']]: OperationTool; }>; //#endregion //# sourceMappingURL=exposure.d.mts.map