/** * SQL helpers for the v-next Postgres observability domain. * * Provides a multi-row INSERT builder with a configurable conflict clause * (`ON CONFLICT DO NOTHING` by default, for retry idempotency), and explicit * jsonb / text[] casts so the pg driver doesn't have to guess column types. */ /** * Build a multi-row INSERT with explicit column types and ON CONFLICT DO NOTHING. * * @param schema Schema name. * @param table Table name. * @param records Array of records (each is a column-name → value object). * All records must have identical key sets. * @returns { text, values } ready to pass to `client.query`. */ export declare function buildInsert(schema: string, table: string, records: Record[], onConflict?: string): { text: string; values: unknown[]; } | null; /** * Conflict clause for span writes. * * A span is written twice under the event-sourced strategy: once when it starts * (`isPending = true`, `endedAt` synthesized from `startedAt`) and once when it * ends. Those two rows normally differ in `endedAt` and so coexist under the * primary key. A zero-duration span is the exception — its real `endedAt` * equals its `startedAt`, so the end row collides with the pending row. Letting * `DO NOTHING` win there would strand the span as permanently running, so the * end row overwrites the pending one instead. * * The `WHERE` guard keeps the clause a no-op for every other conflict, which * preserves insert-only retry idempotency: a replayed end row cannot clobber * the row it duplicates, and a late-arriving start row cannot revert an ended * span to pending. */ export declare function spanConflictClause(columns: readonly string[]): string; /** * Ordering that picks the winning row for a span under the event-sourced write * model. An ended row always beats a pending row for the same span; among rows * of the same kind the latest write wins, with `cursorId` breaking ties between * rows that share a timestamp. Combine with `DISTINCT ON` (or `LIMIT 1`) after * the grouping key to collapse a span's rows down to one. */ export declare const SPAN_COLLAPSE_ORDER = "\"isPending\" ASC, \"endedAt\" DESC, \"cursorId\" DESC"; /** * Standard SELECT column list for tracing tables. The select projects every * column the row→record converters expect. */ export declare const SPAN_SELECT_COLUMNS: string; export declare const SPAN_LIGHT_SELECT_COLUMNS: string; export declare const METRIC_SELECT_COLUMNS: string; export declare const LOG_SELECT_COLUMNS: string; export declare const SCORE_SELECT_COLUMNS: string; export declare const FEEDBACK_SELECT_COLUMNS: string; //# sourceMappingURL=sql.d.ts.map