import { ContractInput, ContractOutput, NeutralSchema } from "../contracts/contract.mjs"; import { AuditEntryInput } from "../../components/foundation/client.mjs"; import { DomainOperationContract, ExactOperationKeys } from "../contracts/domain.mjs"; import { DeclaredSchemas } from "../contracts/binding.mjs"; //#region src/modules/foundation/operation.d.ts type Supported = A | PromiseLike; export type Audit = Omit | null; export type NormalEntry = DomainOperationContract & { input: NeutralSchema; result: NeutralSchema; replayResult?: NeutralSchema; wire?: { schema: NeutralSchema; project: Function; }; }; declare const checkedOperation: unique symbol; export type CheckedDefinition = NoInfer & { readonly [checkedOperation]: { context: (context: Context) => void; definition: Definition; key: Key; }; }; export type CheckedOperation = { readonly [checkedOperation]: { context: (context: Context) => void; definition: unknown; key: unknown; }; }; export type ValidatedOperations = { [Key in keyof Operations]: Operations[Key] extends { readonly [checkedOperation]: { definition: infer Definition; }; } ? Operations[Key] extends Definition ? Operations[Key] : never : never; }; export type ExactOperations = ExactOperationKeys & { [Key in keyof Operations]: Operations[Key] extends { readonly [checkedOperation]: { key: Key; }; } ? Operations[Key] : never; }; type Definition = { handler: (input: ContractOutput, context: Context) => Supported>; permission?: string; metadata?: object; aggregates?: readonly string[]; guard?: (context: Context, input: ContractOutput) => Supported; prepare?: (context: Context, input: ContractOutput) => Supported<{ kind: 'replay'; result: unknown; } | { kind: 'execute'; complete?: (result: ContractOutput) => Supported; }>; audit?: (resolution: { command: ContractOutput; result: ContractOutput; }, context: Context) => Supported; middleware?: (input: { operation: string; input: ContractOutput; command: ContractOutput; context: Context; metadata: object; next: (options?: { context?: object; }) => Promise>; }) => Supported>; }; type CommandRules = Command extends false ? { audit?: never; prepare?: never; aggregates?: never; replayResult?: never; } : Required extends true ? { audit: NonNullable['audit']>; } : {}; type Forbidden = { input?: never; result?: never; classification?: never; replayResult?: never; wire?: never; }; type HandlerOptions = Omit, 'handler'> & Forbidden & { handler?: never; } & CommandRules; type HandlerArguments = Required extends true ? [options: Options] : [options?: Options]; export type DomainFactory>, Command extends boolean, Required extends boolean> = { [Kind in Command extends true ? 'command' : 'query']: { [Key in keyof Entries]: (implementation: Implementation & Definition & Forbidden & CommandRules) => DeclaredSchemas> & CheckedDefinition; } & { handler: >, const Implementation extends object = Record>(handler: (input: ContractOutput, context: Context) => Handler, ...options: HandlerArguments, Command extends true ? Required : false>) => DeclaredSchemas<{ input: Input; result: Result; }> & CheckedDefinition & { handler: (input: ContractOutput, context: Context) => Handler; }, Key>; }; }; export type DomainImplementations>, Command extends boolean, Required extends boolean> = { [Key in keyof Entries]: DeclaredSchemas> & CheckedDefinition & CommandRules, Key>; }; export declare function domainFactory>, Command extends boolean, Required extends boolean>(entries: Entries, command: Command): DomainFactory; export declare function operationFactory(): { command: (implementation: Implementation & { input: Input; result: Result; classification: string; replayResult?: Replay & (ContractOutput extends ContractOutput ? unknown : never); wire?: { schema: Wire; project: (result: ContractOutput) => ContractInput; }; } & Definition & CommandRules) => CheckedDefinition; query: (implementation: Implementation & { input: Input; result: Result; classification?: string; wire?: { schema: Wire; project: (result: ContractOutput) => ContractInput; }; } & Definition & CommandRules) => CheckedDefinition; }; export type InlineFactory = ReturnType>; //#endregion //# sourceMappingURL=operation.d.mts.map