import type { SQL } from '../../db/types.js'; import type { ActiveAuditStep } from '../../../trace/runtime/step-buffer.js'; /** * Information about the active flow_step plus the actor/tenant the row is * attributed to. The CTE compiler resolves these from the active `Flow` and * passes them in — keeps the SQL composer free of context-store coupling. */ export interface AuditSelectContext { readonly step: ActiveAuditStep; /** `auth?.userId`, or null when the trace ran without an authenticated principal. */ readonly actorId: string | null; /** `flow.tenant`, or null when the entry was not tenant-scoped. */ readonly tenantId: string | null; } /** * Composes the `audit_inserts` CTE body: one `SELECT` per `@touches` target, * joined by `UNION ALL`, projecting onto the `audit_record` column order. * * The shape is positional — matches `AUDIT_COLUMNS_SQL` exactly: * id, trace_day, trace_id, trace_step_id, tenant_id, actor_id, * entity, verb, before, after, captured_inputs, occurred_at * * `from` is the verb's contributing FROM clause (e.g. `FROM updated u LEFT * JOIN before b ON ...`), `before` / `after` are the per-row jsonb * expressions to project (or `NULL::jsonb` when the half doesn't apply). */ export declare function buildAuditInserts(ctx: AuditSelectContext, from: SQL, before: SQL, after: SQL): SQL; //# sourceMappingURL=audit-select.d.ts.map