import { AccumulatorTrigger, EscalationWakeCommand } from '../../../../types/hmsh_escalations'; /** * SQL builders for the accumulator store operations. Every builder is a * pure function of parameter positions; the provider owns the connection * and the result mapping. Two rows (container and reciprocal) are locked * in one ordered CTE and written by one UPDATE gated on both being * eligible, so a reciprocal add is both-or-neither by construction. */ /** Collects statement parameters and hands back their `$n` placeholders. */ export declare class SqlParams { readonly values: unknown[]; add(value: unknown): string; } export type AccumulateRowSelector = { kind: 'id'; id: string; } | { kind: 'signalKey'; signalKey: string; } | { kind: 'metadata'; key: string; value: unknown; roles?: string[]; }; export interface AccumulateWake { command: EscalationWakeCommand; /** Pre-serialized `$resolution` object merged into the delivered * collection only, never into the stored `resolver_payload`. */ resolutionJson: string | null; } /** True when the row's envelope carries an accumulator item store. */ export declare function isAccumulatorSql(envelopeExpr: string): string; /** * The delivered collection for an item store expression: `$accumulated` * ordered by each entry's database-clock `at`, plus the `$trigger` that * ended the wait. */ export declare function accumulatedCollectionSql(itemsExpr: string, trigger: AccumulatorTrigger): string; /** * The stored `resolver_payload` for a manual resolve: the collection merged * with the resolver's payload on an accumulator row, the payload alone on * any other row. */ export declare function resolvePayloadSql(rowAlias: string, payloadParam: string): string; /** * The `resolver_payload` written by the timeout path: an accumulator * delivers its collection, a batch row with `partialOnTimeout` delivers the * items filled so far, every other row keeps its column untouched. */ export declare function timeoutPayloadSql(rowAlias: string): string; /** * The wake message for a resolve statement: on an accumulator row the * `{data,data}` slot is rewritten from the committed `resolver_payload` * (plus `$resolution`), so the waiter receives exactly what the row stores. */ export declare function resolveWakeMessageSql(fromCTE: string, messageParam: string, resolutionParam: string): string; export interface AccumulateStatementInput { primary: AccumulateRowSelector; reciprocal: AccumulateRowSelector | null; namespace?: string; itemKey: string; payload: Record | null; reciprocalPayload: Record | null; metadata: Record | null; actor: string | null; assertClaim: string | null; wakes: AccumulateWake[]; appId: string; schemaName: string; } /** * One statement: guarded append of one item on the container (and the * container's id on the reciprocal), facet recompute, resolve-at-max with * the ordered collection as `resolver_payload`, per-side wake enqueue, and * per-side outcome classification. Both writes or neither. */ export declare function buildAccumulateStatement(input: AccumulateStatementInput): { sql: string; values: unknown[]; }; export interface RemoveStatementInput { primary: AccumulateRowSelector; reciprocal: AccumulateRowSelector | null; namespace?: string; itemKey: string; } /** * One statement: guarded removal of one held item from the container (and * of the container's id from the reciprocal), facet recompute, no wake and * no status change. Both writes or neither. */ export declare function buildRemoveStatement(input: RemoveStatementInput): { sql: string; values: unknown[]; };