import { type SQL } from 'drizzle-orm'; import { type H3Event } from 'h3'; import { z } from 'zod'; import { type DatabaseType, type SqlExecutionResult, type TransactionOptions, type TransactionRunner } from './db.js'; export declare const processorConfigSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{ processor: z.ZodString; param: z.ZodOptional; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>; export declare const processorsSchema: z.ZodArray; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>, "many">; export declare const processableKeySchema: z.ZodUnion<[z.ZodString, z.ZodObject<{ key: z.ZodString; processors: z.ZodDefault; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>, "many">>>; }, "strict", z.ZodTypeAny, { key: string; processors: (string | { processor: string; param?: unknown; })[]; }, { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; }>]>; export declare const calculateTemplateSchema: z.ZodObject<{ template: z.ZodString; processors: z.ZodDefault; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>, "many">>>; }, "strict", z.ZodTypeAny, { processors: (string | { processor: string; param?: unknown; })[]; template: string; }, { template: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; }>; declare const conditionTypeSchema: z.ZodEnum<["GE", "GT", "LE", "LT", "NEQ", "EQ", "NOTIN", "IN", "LIKE"]>; declare const groupTypeSchema: z.ZodEnum<["AND", "OR"]>; export type CalculateTemplate = z.infer; export type ProcessorConfig = z.infer; export type ProcessableKey = z.infer; export type NextBlockUuid = string | null; type LeafCondition = { group: false; fieldName: string; fieldValue?: unknown; conditionType: z.infer; optional?: boolean; }; type GroupCondition = { group: true; groupType: z.infer; groups: OrchestrationCondition[]; }; export type OrchestrationCondition = LeafCondition | GroupCondition; export declare const conditionSchema: z.ZodType; export type Block = { uuid: string; alias?: string; functionName: string; type?: string; inputs: Record; outputs?: ProcessableKey[] | null; nextBlock: NextBlockUuid; errorNextBlock?: NextBlockUuid; }; export type ExecuteFragmentBlock = Block & { functionName: 'executeFragment'; inputs: { fragmentUuid: string; params: Record; }; outputs: ['result']; }; export type StarterBlock = { uuid: 'starter'; nextBlock: NextBlockUuid; }; export type ControllerNode = { uuid: string; alias?: string; type?: 'DEFAULT'; value?: string | number | boolean; nextBlock: NextBlockUuid; }; export type Controller = { uuid: string; alias?: string; functionName: string; type: 'controller'; inputs: Record; nodes: ControllerNode[]; }; export type OrchestrationBlock = StarterBlock | Block | ExecuteFragmentBlock | Controller; export type ResponseConfig = Record | null; export declare const controllerNodeSchema: z.ZodType; export declare const controllerSchema: z.ZodType; export declare const blockSchema: z.ZodType; declare const endpointApiJsonSchema: z.ZodObject<{ fragment: z.ZodDefault>>; method: z.ZodEffects; request: z.ZodDefault; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>, "many">>>; }, "strict", z.ZodTypeAny, { key: string; processors: (string | { processor: string; param?: unknown; })[]; }, { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; }>]>, "many">>>; query: z.ZodDefault; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>, "many">>>; }, "strict", z.ZodTypeAny, { key: string; processors: (string | { processor: string; param?: unknown; })[]; }, { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; }>]>, "many">>>; body: z.ZodDefault; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>, "many">>>; }, "strict", z.ZodTypeAny, { key: string; processors: (string | { processor: string; param?: unknown; })[]; }, { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; }>]>, "many">>>; }, "strict", z.ZodTypeAny, { header: (string | { key: string; processors: (string | { processor: string; param?: unknown; })[]; })[]; query: (string | { key: string; processors: (string | { processor: string; param?: unknown; })[]; })[]; body: (string | { key: string; processors: (string | { processor: string; param?: unknown; })[]; })[]; }, { header?: (string | { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; })[] | undefined; query?: (string | { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; })[] | undefined; body?: (string | { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; })[] | undefined; }>>>; uuid: z.ZodString; alias: z.ZodOptional; blocks: z.ZodDefault, "many">>; response: z.ZodOptional>; responses: z.ZodOptional>>; }, "strict", z.ZodTypeAny, { uuid: string; fragment: false; method: string; request: { header: (string | { key: string; processors: (string | { processor: string; param?: unknown; })[]; })[]; query: (string | { key: string; processors: (string | { processor: string; param?: unknown; })[]; })[]; body: (string | { key: string; processors: (string | { processor: string; param?: unknown; })[]; })[]; }; blocks: OrchestrationBlock[]; alias?: string | undefined; response?: ResponseConfig | undefined; responses?: Record | undefined; }, { uuid: string; method: string; alias?: string | undefined; fragment?: false | undefined; request?: { header?: (string | { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; })[] | undefined; query?: (string | { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; })[] | undefined; body?: (string | { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; })[] | undefined; } | undefined; blocks?: unknown[] | undefined; response?: unknown; responses?: Record | undefined; }>; declare const fragmentApiJsonSchema: z.ZodObject<{ fragment: z.ZodLiteral; params: z.ZodDefault; }, "strict", z.ZodTypeAny, { processor: string; param?: unknown; }, { processor: string; param?: unknown; }>]>, "many">>>; }, "strict", z.ZodTypeAny, { key: string; processors: (string | { processor: string; param?: unknown; })[]; }, { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; }>]>, "many">>>; response: z.ZodOptional>; responses: z.ZodOptional>>; uuid: z.ZodString; alias: z.ZodOptional; blocks: z.ZodDefault, "many">>; }, "strict", z.ZodTypeAny, { params: (string | { key: string; processors: (string | { processor: string; param?: unknown; })[]; })[]; uuid: string; fragment: true; blocks: OrchestrationBlock[]; alias?: string | undefined; response?: Record | undefined; responses?: Record> | undefined; }, { uuid: string; fragment: true; params?: (string | { key: string; processors?: (string | { processor: string; param?: unknown; })[] | undefined; })[] | undefined; alias?: string | undefined; blocks?: unknown[] | undefined; response?: Record | undefined; responses?: Record> | undefined; }>; export type EndpointApiJson = z.infer; export type FragmentApiJson = z.infer; export type ApiJson = EndpointApiJson | FragmentApiJson; export type RequestContext = { header: Record; query: Record; body: Record; }; type BaseBlockExecutionContext = { now: string; blocks: Record; outputs: Record; }>; }; export type EndpointBlockExecutionContext = BaseBlockExecutionContext & { request: RequestContext; header: Record; query: Record; body: Record; }; export type FragmentBlockExecutionContext = BaseBlockExecutionContext & { params: Record; }; export type BlockExecutionContext = EndpointBlockExecutionContext | FragmentBlockExecutionContext; export type MokelayDebugError = { code: string; message: string; }; export type MokelayDebugBlockStep = { uuid: string; type: 'block'; inputs: Record; outputs: Record; nextBlock: MokelayDebugStep | null; error?: MokelayDebugError; fragment?: MokelayDebugResponse; }; export type MokelayDebugControllerNode = { uuid: string; nextBlock: MokelayDebugStep | null; }; export type MokelayDebugControllerStep = { uuid: string; type: 'controller'; inputs: Record; node?: MokelayDebugControllerNode; error?: MokelayDebugError; }; export type MokelayDebugStep = MokelayDebugBlockStep | MokelayDebugControllerStep; export type MokelayDebugResponse = { uuid: 'starter'; nextBlock: MokelayDebugStep | null; }; export type SqlExecutor = = Record>(query: SQL) => Promise>; export type DatasourceSqlExecutor = = Record>(query: SQL, datasource: string, databaseType: DatabaseType) => Promise>; export type DatasourceTransactionRunner = (datasource: string, callback: (executeSql: SqlExecutor) => Promise, options?: TransactionOptions) => Promise; export type FragmentInvocation = { fragmentUuid: string; params: Record; }; export type FragmentInvoker = (input: FragmentInvocation) => Promise>; export type ProcessValue = (value: unknown, processors: ProcessorConfig[], label: string) => Promise; export type BlockExecutorInput = { event: H3Event; block: Block; inputs: Record; executeSql: SqlExecutor; databaseType?: DatabaseType; /** Available for datasource-backed blocks; all statements use one connection. */ withTransaction?: TransactionRunner; /** Runs a value through the orchestration Processor pipeline in the current template context. */ processValue: ProcessValue; /** Reserved for the built-in executeFragment Block; other Blocks are rejected at runtime. */ invokeFragment: FragmentInvoker; }; export type BlockExecutor = (input: BlockExecutorInput) => Promise>; export type BlockDefinition = { executor: BlockExecutor; allowedOutputs: readonly string[]; requiresDatasource?: boolean; }; export type ApiJsonSource = 'system' | 'user'; export type OrchestrationHandlerOptions = { loadApiJson?: (apiJsonUuid: string) => Promise; /** * Ownership domain for raw DSL passed directly to executeApiJson. The default * handler detects this automatically and custom loaders remain self-contained. */ apiJsonSource?: ApiJsonSource; executeSql?: DatasourceSqlExecutor; executeTransaction?: DatasourceTransactionRunner; blockDefinitions?: Readonly>; }; export type MokelaySuccessResponse = { ok: true; data: unknown; debug?: MokelayDebugResponse; }; export declare function assertApiJsonUuid(value: string | undefined): string; export declare function parseApiJson(apiJsonUuid: string, value: unknown): ApiJson; export declare function isFragmentApiJson(apiJson: ApiJson): apiJson is FragmentApiJson; export {};