import { CommandHandlerResult, CommandInput, CommandSchema, SchemaInput, SchemaOutput } from "./modules/command/command.mjs"; import { AnyCommandMiddleware, AuditEntryInput, AuditedOperation, AuditedRegistry } from "./client.mjs"; //#region src/components/foundation/operation.d.ts type MaybePromise = T | Promise; export type CommandPreparation = { kind: 'replay'; result: unknown; } | { kind: 'execute'; complete?: (result: Result) => MaybePromise; }; type Parsed = SchemaOutput; declare const extension: unique symbol; declare const hostContext: unique symbol; export type OperationHostContext = { readonly [hostContext]?: (context: Context) => void; }; export type OperationExtension = Definition extends { readonly [extension]?: infer Extension; } ? Extension : unknown; type MiddlewareInput = { operation: string; context: Context; command: Input; next: keyof Extension extends never ? (options?: { context?: Extension; }) => Promise : (options: { context: Extension; }) => Promise; }; type LocalMiddleware = (input: MiddlewareInput) => Promise; type AuditFor = Omit & { aggregate: { type: Aggregate; id: string; }; }; export type TypedOperation = OperationHostContext & { readonly command: Input; readonly result: Output; readonly classification: string; readonly permission?: string; /** Called after permission, inside observation; returns invocation-local hooks. */ readonly prepare?: (context: Context, command: Parsed) => MaybePromise>>; /** Validates stored outputs when result transforms accept a different input shape. */ readonly replayResult?: CommandSchema>; readonly aggregates?: Aggregates; readonly guard?: (context: Context & Extension, command: Parsed) => MaybePromise; readonly audit: (resolution: { command: Parsed; result: Parsed; }, context: Context) => MaybePromise | null>; readonly [extension]?: Extension; } & (keyof Extension extends never ? { readonly middleware?: readonly LocalMiddleware, SchemaInput, Extension>[]; } : { readonly middleware: readonly [LocalMiddleware, SchemaInput, Extension>, ...LocalMiddleware, SchemaInput, Record>[]]; }); type RegistryInput = { [Key in Extract]: { operation: Key; definition: Operations[Key]; context: Context; command: CommandInput; next: () => Promise>; }; }[Extract]; type StoredOperation = Omit, 'middleware'> & Pick; /** Binds host context once; each operation infers its own parsed schemas. */ export declare function operationFactory = Record>(): { operation(definition: TypedOperation): StoredOperation; registryMiddleware(operations: Operations & { readonly [Key in keyof Operations]: OperationHostContext; }, middleware: (input: RegistryInput) => Promise>>): AnyCommandMiddleware; }; //#endregion //# sourceMappingURL=operation.d.mts.map