@vibeorm/sql 5.8.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,7 @@ Most users never install this directly — it ships as a dependency of [`vibeorm
18
18
  - **Dialects**: `postgresDialect`, `sqliteDialect`, `mysqlDialect`, the `SqlDialect` type, and the registry `SQL_DIALECTS` / `getSqlDialect`. A dialect carries `quoteIdent` plus the strategy switches: `= ANY` versus `IN` expansion, `ILIKE` versus `LOWER(...) LIKE LOWER(...)`, the upsert form, `ESCAPE` clause presence, `RETURNING` availability.
19
19
  - **Capability tables**: `DIALECT_CAPABILITIES`, `POSTGRES_CAPABILITIES`, `SQLITE_CAPABILITIES`, `MYSQL_CAPABILITIES` — frozen objects consumed by the runtime, migrate, the generator and the E2E harness. A feature a dialect cannot express throws `VIBE_UNSUPPORTED_CAPABILITY` rather than degrading.
20
20
  - **Codec tables**: `DIALECT_CODECS`, `POSTGRES_CODECS`, `SQLITE_CODECS`, `MYSQL_CODECS`, `decodeIsNoop`, and the `CodecTable` / `ScalarCodec` / `WireFidelity` types. All per-dialect value encode and decode lives here, in one place, instead of scattered through query builders.
21
+ - **Column types**: `canonicalColumnType({ dialect, scalar, nativeType })` names the column type migrate creates for a field, in the one spelling migrate compares column types by (`"integer"` for `Int`, `@db.Int4` and `@db.Integer` on PostgreSQL); `normalizePostgresNativeType` / `normalizeMysqlNativeType`, the tables `POSTGRES_SCALAR_COLUMN_TYPES`, `MYSQL_SCALAR_COLUMN_TYPES`, `SQLITE_SCALAR_STORAGE_CLASSES` and `POSTGRES_EXACT_EQUIVALENTS` are the pieces. `describeSchema` (`@vibeorm/runtime`) reports each field's `nativeType` with it.
21
22
  - **Rendering**: `renderStatement({ dialect, statement })` returns `RenderedQuery` (`{ text, values, returning }`); `renderExpr` and `renderFragment` render sub-parts against a shared `ParamCollector`. Placeholders always come from `ParamCollector`, never from hand-written `$1` or `?`.
22
23
  - **LIKE helpers**: `escapeLikePattern`, `escapeGlobPattern`, `containsPattern`, `startsWithPattern`, `endsWithPattern`, `strictMatchPattern`.
23
24
 
package/dist/ast.d.ts CHANGED
@@ -66,6 +66,25 @@ export type ColRef = {
66
66
  * without the `dateTruncation` capability refuse it when rendering.
67
67
  */
68
68
  readonly truncate?: DateTruncation;
69
+ /**
70
+ * A `groupBy` expression key read from the column ({@link GroupKeyExpression}):
71
+ * the text at a JSON path, or a string's leading characters. Like
72
+ * {@link ColRef.truncate} it is set on the projection (with `alias`, the
73
+ * key's result name), GROUP BY and ORDER BY refs of one key, which repeat
74
+ * the identical text: every operand is a validated literal, never a bound
75
+ * parameter, so PostgreSQL and MySQL match the GROUP BY expression.
76
+ */
77
+ readonly groupKey?: GroupKeyExpression;
78
+ /**
79
+ * The first non-NULL of these references — `COALESCE("a", "b")` — instead
80
+ * of the column `name`: the value of an `orderBy: { _coalesce: … }` term.
81
+ * Each member renders as its own reference, casts included (a sqlite
82
+ * Decimal member as `CAST(… AS REAL)`, a mysql native enum as its member
83
+ * index). Set on ORDER BY and comparison refs only. `name` is then
84
+ * {@link COALESCE_REF_NAME}, never a column of a table, so a reader that
85
+ * looks a column up by name finds none.
86
+ */
87
+ readonly coalesce?: readonly ColRef[];
69
88
  /**
70
89
  * Projection alias: renders `ref AS "alias"`. PROJECTION-ONLY — filter,
71
90
  * order and correlation refs never set it (the renderer ignores it outside
@@ -74,6 +93,15 @@ export type ColRef = {
74
93
  */
75
94
  readonly alias?: string;
76
95
  };
96
+ /**
97
+ * The `name` of a {@link ColRef.coalesce} reference. The `__vibe_` column
98
+ * prefix is reserved by schema validation, so no model column carries it.
99
+ */
100
+ export declare const COALESCE_REF_NAME: string;
101
+ /** A {@link ColRef.coalesce} reference over `members`. */
102
+ export declare function coalesceRef(params: {
103
+ members: readonly ColRef[];
104
+ }): ColRef;
77
105
  /** A {@link ColRef.truncate} request: the calendar unit, the zone that defines the calendar, and the column's storage form. */
78
106
  export type DateTruncation = {
79
107
  readonly unit: DateTruncationUnit;
@@ -81,6 +109,24 @@ export type DateTruncation = {
81
109
  readonly timeZone: string;
82
110
  readonly storage: DateTruncationStorage;
83
111
  };
112
+ /**
113
+ * A {@link ColRef.groupKey} expression.
114
+ *
115
+ * - `jsonPathText`: the text at an object-key path of a JSON column — a JSON
116
+ * string unquoted, a number or boolean in its JSON spelling, JSON `null` and
117
+ * a missing path SQL NULL, an object or array its JSON text. Each step reads
118
+ * an object member only. `storage: "json"` marks a postgres `json` column,
119
+ * read through jsonb like the JSON filters.
120
+ * - `prefix`: the first `length` characters of a string column.
121
+ */
122
+ export type GroupKeyExpression = {
123
+ readonly kind: "jsonPathText";
124
+ readonly path: readonly string[];
125
+ readonly storage?: "json";
126
+ } | {
127
+ readonly kind: "prefix";
128
+ readonly length: number;
129
+ };
84
130
  export type TableRef = {
85
131
  readonly name: string;
86
132
  /** Explicit fixed PostgreSQL placement; absence preserves existing SQL. */
@@ -92,11 +138,19 @@ export type AggFn = "count" | "avg" | "sum" | "min" | "max";
92
138
  /** Reference to an aggregate expression: `COUNT(*)` or `FN("col")`. */
93
139
  export type AggRef = {
94
140
  readonly fn: "countAll";
141
+ readonly filter?: SqlExpr;
95
142
  } | {
96
143
  readonly fn: AggFn;
97
144
  readonly column: ColRef;
98
145
  /** Native enum MIN/MAX: projections and HAVING return the database label; order keys keep its ordinal. */
99
146
  readonly enumOrder?: "value" | "ordinal";
147
+ /**
148
+ * Aggregate only the rows the predicate admits: `AGG(x) FILTER (WHERE …)`
149
+ * or `AGG(CASE WHEN … THEN x END)` per the dialect's
150
+ * `filteredAggregates` capability. Its parameters bind each time the
151
+ * aggregate renders (projection, HAVING, ORDER BY), in text order.
152
+ */
153
+ readonly filter?: SqlExpr;
100
154
  };
101
155
  /**
102
156
  * One aggregate projection: `FN("col") AS "alias"`. The alias is part of the
@@ -111,10 +165,13 @@ export type AggSelect = {
111
165
  };
112
166
  /**
113
167
  * JSON path predicates (Prisma's Json filter surface). `not` is `equals` with
114
- * `negate` — there is no separate op. Which ops a dialect can express is
168
+ * `negate` — there is no separate op. `exists` takes a boolean `value`: the
169
+ * member at the path (object keys only) is present (its value may be JSON
170
+ * `null`) or, for `false`, the document is present and the member is not; a
171
+ * SQL NULL column is unknown for both. Which ops a dialect can express is
115
172
  * declared on `SqlDialect.supportedJsonOps` and enforced at render time too.
116
173
  */
117
- export type JsonFilterOp = "equals" | "string_contains" | "string_starts_with" | "string_ends_with" | "array_contains" | "array_starts_with" | "array_ends_with";
174
+ export type JsonFilterOp = "equals" | "exists" | "string_contains" | "string_starts_with" | "string_ends_with" | "array_contains" | "array_starts_with" | "array_ends_with";
118
175
  export type ComparisonOp = "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
119
176
  /**
120
177
  * The column facts one member of a {@link SqlExpr} `keyList` tuple needs to
@@ -771,6 +828,20 @@ export type KeyRows = {
771
828
  /** Encoded tuples; never empty, each exactly `columns.length` long. */
772
829
  readonly rows: readonly (readonly unknown[])[];
773
830
  };
831
+ /**
832
+ * `GROUP BY GROUPING SETS (…)` over a select's `groupBy` columns. Each set
833
+ * lists indexes into `groupBy`; `()` is the grand total. The projection gains
834
+ * `CASE GROUPING(<every groupBy column>) WHEN <mask> THEN <set index> … END AS
835
+ * "<indexAlias>"` after the aggregates, so a row names the set that produced
836
+ * it, and an ORDER BY term may name `indexAlias` as a bare column (an output
837
+ * column). Dialect `groupingSets` capability: `"groupingSets"` renders any
838
+ * list, `"rollup"` only the rollup chain of `groupBy` in order (`GROUP BY a,
839
+ * b WITH ROLLUP`), `"none"` refuses.
840
+ */
841
+ export type GroupingSets = {
842
+ readonly sets: readonly (readonly number[])[];
843
+ readonly indexAlias: string;
844
+ };
774
845
  export type SelectStatement = {
775
846
  readonly kind: "select";
776
847
  readonly table: TableRef;
@@ -850,6 +921,8 @@ export type SelectStatement = {
850
921
  readonly fromKeys?: KeyRows;
851
922
  readonly where?: SqlExpr;
852
923
  readonly groupBy?: readonly ColRef[];
924
+ /** Grouping sets over `groupBy` — see {@link GroupingSets}. */
925
+ readonly groupingSets?: GroupingSets;
853
926
  /** HAVING predicate — grouped selects; may contain `aggCmp` expressions. */
854
927
  readonly having?: SqlExpr;
855
928
  readonly orderBy?: readonly OrderTerm[];
@@ -971,7 +1044,26 @@ export type ReturningColumn = string | {
971
1044
  } | {
972
1045
  readonly name: string;
973
1046
  readonly transform: "jsonText";
974
- } | CaptureReturningColumn;
1047
+ } | CaptureReturningColumn | OtherRowReturningColumn;
1048
+ /**
1049
+ * A RETURNING column read from a row OTHER than the one the statement wrote,
1050
+ * exposed as `alias` and projected like the written row's own column
1051
+ * (`projection`), so one codec decodes both:
1052
+ *
1053
+ * - `from: "old"` — the row as it was before the statement (capability
1054
+ * `rowCapture`, PostgreSQL 18): `old."col" AS "alias"`, NULL in every column
1055
+ * for a row the statement inserted;
1056
+ * - `from: { source }` — the joined source of an `UPDATE … FROM` by its alias
1057
+ * (capability `returningReadsJoinedSource`): `"source"."col" AS "alias"`.
1058
+ */
1059
+ export type OtherRowReturningColumn = {
1060
+ readonly from: "old" | {
1061
+ readonly source: string;
1062
+ };
1063
+ readonly name: string;
1064
+ readonly alias: string;
1065
+ readonly projection?: "castText" | "jsonText";
1066
+ };
975
1067
  /**
976
1068
  * A row-capture RETURNING column (`$transaction(…, { capture })`, dialects with
977
1069
  * the `rowCapture` capability: PostgreSQL 18, where RETURNING names the row
@@ -982,15 +1074,71 @@ export type ReturningColumn = string | {
982
1074
  * inserted row, `new` for a deleted one);
983
1075
  * - `"inserted"`: `(old."col" IS NULL) AS "alias"` — the arm of an `INSERT …
984
1076
  * ON CONFLICT DO UPDATE` row, true when it was inserted (`col` must be a
985
- * column no stored row holds NULL in: a primary-key column).
1077
+ * column no stored row holds NULL in: a primary-key column);
1078
+ * - `"old"` / `"new"` with `hop`: the related row's column, read in the same
1079
+ * statement — `(SELECT "__vibe_h"."col"::text FROM "Related" AS "__vibe_h"
1080
+ * WHERE "__vibe_h"."id" = new."relatedId") AS "alias"` (see {@link CaptureHop});
1081
+ * - `"key"`: `old."col" AS "alias"` in the column's own type, for a chain's
1082
+ * {@link CaptureCascade} to match child rows on;
1083
+ * - `"cascade"` ({@link CaptureCascadeReturningColumn}): the images of the
1084
+ * child rows a referential action of this row changes.
986
1085
  */
987
1086
  export type CaptureReturningColumn = {
988
- readonly capture: "old" | "new" | "inserted";
1087
+ readonly capture: "old" | "new" | "inserted" | "key";
1088
+ readonly name: string;
1089
+ readonly alias: string;
1090
+ /** With `"old"` / `"new"`: read `name` from the related row instead of this one. */
1091
+ readonly hop?: CaptureHop;
1092
+ } | CaptureCascadeReturningColumn;
1093
+ /**
1094
+ * A to-one hop of a capture cell: the row of `table` whose `on[i].target`
1095
+ * columns equal the reading row's `on[i].source` columns. The target columns
1096
+ * must be a unique key (a scalar subquery that found two rows would fail the
1097
+ * statement); no row, or a NULL source column, reads NULL.
1098
+ */
1099
+ export type CaptureHop = {
1100
+ readonly table: TableRef;
1101
+ readonly on: readonly {
1102
+ readonly target: string;
1103
+ readonly source: string;
1104
+ }[];
1105
+ };
1106
+ /** One cell of a {@link CaptureCascade} image: a child column, or a column of its related row. */
1107
+ export type CaptureCell = {
989
1108
  readonly name: string;
1109
+ readonly hop?: CaptureHop;
1110
+ };
1111
+ /**
1112
+ * The distinct images of the child rows of `table` whose `on[i].child` columns
1113
+ * equal a written parent row's `on[i].parent` columns: `(SELECT
1114
+ * array_agg("__vibe_i")::text FROM (SELECT DISTINCT ARRAY[<cells>] AS "__vibe_i"
1115
+ * FROM "Child" AS "__vibe_c" WHERE <match> LIMIT $n) AS "__vibe_d")`, NULL when
1116
+ * no child matched. Read inside the parent's statement, whose snapshot still
1117
+ * holds the rows its foreign keys' referential actions remove or rewrite at
1118
+ * the statement's end. `limit` is bound as a parameter.
1119
+ */
1120
+ export type CaptureCascade = {
1121
+ readonly table: TableRef;
1122
+ readonly on: readonly {
1123
+ readonly child: string;
1124
+ readonly parent: string;
1125
+ }[];
1126
+ readonly cells: readonly CaptureCell[];
1127
+ readonly limit: number;
1128
+ };
1129
+ /**
1130
+ * A per-row {@link CaptureCascade} in RETURNING: `parent` columns are read from
1131
+ * `old.` (`"__vibe_c"."child" = old."parent"`).
1132
+ */
1133
+ export type CaptureCascadeReturningColumn = {
1134
+ readonly capture: "cascade";
990
1135
  readonly alias: string;
1136
+ readonly cascade: CaptureCascade;
991
1137
  };
992
1138
  /** The column name a {@link ReturningColumn} exposes in the result row. */
993
1139
  export declare function returningColumnName(column: ReturningColumn): string;
1140
+ /** Is this RETURNING column read from another row ({@link OtherRowReturningColumn})? */
1141
+ export declare function isOtherRowReturningColumn(column: ReturningColumn): column is OtherRowReturningColumn;
994
1142
  /** Is this RETURNING column a row-capture column ({@link CaptureReturningColumn})? */
995
1143
  export declare function isCaptureReturningColumn(column: ReturningColumn): column is CaptureReturningColumn;
996
1144
  export type InsertStatement = {
@@ -1236,11 +1384,24 @@ export declare function stepColumnRef(params: {
1236
1384
  column: string;
1237
1385
  }): StepColumnRef;
1238
1386
  /** The joined relation of an {@link UpdateStatement}: its table, alias and join condition. */
1239
- export type UpdateSource = {
1387
+ export type UpdateSource = UpdateTableSource | UpdateSelectSource;
1388
+ /** A joined table: `FROM "table" AS alias` (`updateMany({ from })`). */
1389
+ export type UpdateTableSource = {
1240
1390
  readonly table: TableRef;
1241
1391
  readonly alias: string;
1242
1392
  readonly on: SqlExpr;
1243
1393
  };
1394
+ /**
1395
+ * A joined subquery: `FROM (SELECT …) AS alias`, PostgreSQL only. With a
1396
+ * locking read of the target table it is the row as it was before the write,
1397
+ * and an {@link OtherRowReturningColumn} `from: { source: alias }` returns its
1398
+ * values (`update({ previous })`, capability `returningReadsJoinedSource`).
1399
+ */
1400
+ export type UpdateSelectSource = {
1401
+ readonly select: SelectStatement;
1402
+ readonly alias: string;
1403
+ readonly on: SqlExpr;
1404
+ };
1244
1405
  /** An UPDATE set value read from the joined source's `column` (`UPDATE … FROM`). */
1245
1406
  export type SourceColumnRef = {
1246
1407
  readonly __sourceColumn: true;
@@ -1412,6 +1573,13 @@ export type ChainCapture = {
1412
1573
  readonly after?: readonly string[];
1413
1574
  /** The most distinct images one image column returns: a positive safe integer, bound as a parameter. */
1414
1575
  readonly limit: number;
1576
+ /**
1577
+ * Child images of the step's rows, one result column `<alias>_c<j>` each: a
1578
+ * {@link CaptureCascade} whose `parent` columns name columns the step
1579
+ * RETURNS, matched by `EXISTS (SELECT 1 FROM "step" AS "__vibe_k" WHERE
1580
+ * "__vibe_k"."parent" = "__vibe_c"."child")`.
1581
+ */
1582
+ readonly cascades?: readonly CaptureCascade[];
1415
1583
  };
1416
1584
  /**
1417
1585
  * Fail the statement when `step` returned no row; `token` names the veto in the
package/dist/dialect.d.ts CHANGED
@@ -450,11 +450,16 @@ export type SqlDialect = {
450
450
  renderEnumOrdinal(params: {
451
451
  column: string;
452
452
  }): string;
453
- /** Render native enum MIN/MAX in database declaration order, returning its label or an order key. */
453
+ /**
454
+ * Render native enum MIN/MAX in database declaration order, returning its
455
+ * label or an order key. `when` (a rendered predicate) is a filtered
456
+ * aggregate on a `caseWhen` dialect: only the rows it admits are aggregated.
457
+ */
454
458
  renderEnumMinMax(params: {
455
459
  fn: "min" | "max";
456
460
  column: string;
457
461
  result: "value" | "ordinal";
462
+ when?: string;
458
463
  }): string;
459
464
  /** Positional placeholder for the 1-based parameter index ($n or ?). */
460
465
  placeholder(params: {
@@ -3,7 +3,7 @@ import type { RenderedQuery } from "../render.ts";
3
3
  import type { SqlStatement, TableRef } from "../ast.ts";
4
4
  import type { PostgresExplainOptions, PostgresWorkloadQuery } from "./postgres-diagnostics.ts";
5
5
  /** Fixed, parameterless diagnostics whose text never varies. */
6
- export type FixedDiagnosticQuery = "postgresJsonWire" | "sqliteTriggers";
6
+ export type FixedDiagnosticQuery = "postgresJsonWire" | "postgresServerVersion" | "sqliteTriggers";
7
7
  /** One table of row capture's readiness read: the table as write statements name it, and the columns capture returns. */
8
8
  export type CaptureReadinessTable = {
9
9
  readonly table: TableRef;
@@ -0,0 +1,65 @@
1
+ import type { Dialect } from "@vibeorm/schema";
2
+ import type { SqlDialect } from "../dialect.ts";
3
+ import type { RenderedQuery } from "../render.ts";
4
+ /**
5
+ * Which dialects can label an automatic shadow database with its creator, so
6
+ * a later run can tell a leaked shadow from one still in use. PostgreSQL
7
+ * stores the label as the database comment; MySQL has no database comment,
8
+ * and SQLite and PGlite shadows never outlive their process.
9
+ */
10
+ export declare const SHADOW_MARKER_CAPABILITIES: Readonly<Record<Dialect, Readonly<{
11
+ databaseMarker: boolean;
12
+ }>>>;
13
+ /** Exactly the names automatic shadow provisioning generates. */
14
+ export declare const AUTOMATIC_SHADOW_NAME_PATTERN: string;
15
+ /**
16
+ * The creator of one automatic shadow. `adminPid` and `adminStarted` identify
17
+ * the administration session that created it and holds it for the run's whole
18
+ * life (a backend pid with its start time never repeats); `adminStarted` is
19
+ * null when the server did not show the session's start. Times are server
20
+ * microseconds since the epoch, as decimal text; `host` and `pid` name the
21
+ * creating process for people reading a prune report.
22
+ */
23
+ export type AutomaticShadowMarker = {
24
+ readonly database: string;
25
+ readonly adminPid: number;
26
+ readonly adminStarted: string | null;
27
+ readonly created: string;
28
+ readonly host: string;
29
+ readonly pid: number;
30
+ };
31
+ /** Automatic shadow bookkeeping on the administration connection. */
32
+ export type AutomaticShadowOperation =
33
+ /** The administration session's pid, its start and the server's clock, before a marker is written. */
34
+ {
35
+ readonly kind: "session";
36
+ } | {
37
+ readonly kind: "mark";
38
+ readonly marker: AutomaticShadowMarker;
39
+ }
40
+ /** Every database with an automatic shadow name: its comment, its connected sessions and the server's clock. */
41
+ | {
42
+ readonly kind: "list";
43
+ }
44
+ /** Every server session's pid and start. */
45
+ | {
46
+ readonly kind: "backends";
47
+ };
48
+ /**
49
+ * The marker text. Every field is validated against a closed character set, so
50
+ * the text is safe inside a string literal whatever `standard_conforming_strings`
51
+ * says (COMMENT accepts no bound parameter).
52
+ */
53
+ export declare function automaticShadowMarkerText(params: {
54
+ marker: AutomaticShadowMarker;
55
+ }): string;
56
+ /** Read a database comment back as a marker; anything but the exact format is no marker. */
57
+ export declare function parseAutomaticShadowMarker(params: {
58
+ text: unknown;
59
+ }): AutomaticShadowMarker | undefined;
60
+ /** Render marker writes and prune reads; dialects without a database marker refuse. */
61
+ export declare function renderAutomaticShadowOperation(params: {
62
+ dialect: SqlDialect;
63
+ operation: AutomaticShadowOperation;
64
+ }): RenderedQuery;
65
+ //# sourceMappingURL=migration-shadow-marker.d.ts.map
@@ -1,9 +1,11 @@
1
1
  import type { IndexExpressionProbeParams, IndexKeyOperand } from "../index-expressions.ts";
2
2
  import type { RenderedQuery } from "../render.ts";
3
3
  /** CREATE INDEX extraction is conservative; structured catalog rows remain authoritative. */
4
- export declare function extractPostgresIndexKeys({ definition, index }: {
4
+ export declare function extractPostgresIndexKeys({ definition, index, included }: {
5
5
  readonly definition: string;
6
6
  readonly index: string;
7
+ /** INCLUDE columns the caller read from the catalog; an INCLUDE clause of another length is refused. */
8
+ readonly included?: number;
7
9
  }): readonly IndexKeyOperand[] | undefined;
8
10
  /** Caller owns a fixed search_path and rollback savepoint; no populated user table is indexed. */
9
11
  export declare function renderPostgresIndexExpressionProbe({ ...params }: IndexExpressionProbeParams): readonly RenderedQuery[];
@@ -10,10 +10,12 @@ export declare function extractIndexKeyList({ sql, open, close, tokens, wrapped,
10
10
  readonly removeWrapper?: boolean;
11
11
  }): readonly IndexKeyOperand[] | undefined;
12
12
  /** Parse the CREATE INDEX header without interpreting any scalar expression. */
13
- export declare function extractStandaloneIndexKeys({ definition, index, postgres }: {
13
+ export declare function extractStandaloneIndexKeys({ definition, index, postgres, included }: {
14
14
  readonly definition: string;
15
15
  readonly index: string;
16
16
  readonly postgres?: boolean;
17
+ /** PostgreSQL INCLUDE columns the caller read from the catalog (default none). */
18
+ readonly included?: number;
17
19
  }): readonly IndexKeyOperand[] | undefined;
18
20
  /** SQLite source spelling is the evidence; CAST alone never proves a plain Decimal key. */
19
21
  export declare function extractSqliteIndexKeys({ definition, index }: {
@@ -44,12 +44,18 @@ export declare function renderIndexKeys({ dialect, keys, unique }: {
44
44
  readonly keys: readonly IndexKeyOperand[];
45
45
  readonly unique: boolean;
46
46
  }): readonly string[];
47
- /** Recover raw physical terms without inventing typed logical expressions or Decimal origin. */
48
- export declare function extractIndexKeys({ dialect, definition, index, backslashEscapes }: {
47
+ /**
48
+ * Recover raw physical terms without inventing typed logical expressions or Decimal origin.
49
+ * A PostgreSQL `INCLUDE (…)` clause makes the result undefined unless the caller read
50
+ * that many included columns from the catalog itself (`included`), so a covering list
51
+ * can never disappear behind recovered keys.
52
+ */
53
+ export declare function extractIndexKeys({ dialect, definition, index, backslashEscapes, included }: {
49
54
  readonly dialect: Dialect;
50
55
  readonly definition: string;
51
56
  readonly index: string;
52
57
  readonly backslashEscapes?: boolean;
58
+ readonly included?: number;
53
59
  }): readonly IndexKeyOperand[] | undefined;
54
60
  /** Render a real expression-index normalization host, never a scalar CHECK surrogate. */
55
61
  export declare function renderIndexExpressionProbe({ ...params }: IndexExpressionProbeParams): readonly RenderedQuery[];
package/dist/index.d.ts CHANGED
@@ -3,6 +3,8 @@ export { nativeEnumArrayParameter, isNativeEnumArrayParameter } from "./native-e
3
3
  export type { NativeEnumArrayParameter } from "./native-enum-parameter.ts";
4
4
  export { isJsonListParameter, jsonListParameter } from "./json-list-parameter.ts";
5
5
  export type { JsonListParameter, JsonListStorage } from "./json-list-parameter.ts";
6
+ export { isJsonPatchOperation, jsonPatchVetoOf, planJsonPatch } from "./json-patch.ts";
7
+ export type { JsonPatchCheck, JsonPatchConflict, JsonPatchFoundType, JsonPatchOperation, JsonPatchPlan, JsonPatchStep, JsonPatchVeto } from "./json-patch.ts";
6
8
  export { renderExternalOwnershipCatalog } from "./dialects/external-ownership.ts";
7
9
  export { renderExternalDependents } from "./dialects/external-dependents.ts";
8
10
  export type { ExternalDependentTarget } from "./dialects/external-dependents.ts";
@@ -17,6 +19,8 @@ export { renderModuleDependencyQuery } from "./dialects/module-dependency.ts";
17
19
  export type { ModuleDependencyOperation } from "./dialects/module-dependency.ts";
18
20
  export { renderReplayCoverageGaps } from "./dialects/migration-replay-coverage.ts";
19
21
  export { SHADOW_DATABASE, SHADOW_CAPABILITIES, renderShadowOperation } from "./dialects/migration-shadow.ts";
22
+ export { AUTOMATIC_SHADOW_NAME_PATTERN, SHADOW_MARKER_CAPABILITIES, automaticShadowMarkerText, parseAutomaticShadowMarker, renderAutomaticShadowOperation } from "./dialects/migration-shadow-marker.ts";
23
+ export type { AutomaticShadowMarker, AutomaticShadowOperation } from "./dialects/migration-shadow-marker.ts";
20
24
  export type { ShadowOperation } from "./dialects/migration-shadow.ts";
21
25
  export { MODULE_JOURNAL_COLUMN, renderModuleJournal } from "./module-journal.ts";
22
26
  export { renderSqliteFtsUpdateTrigger, sqliteFtsUpdateUpgrade } from "./dialects/sqlite-fts.ts";
@@ -40,8 +44,8 @@ export type { ResultDecoder, ResultReadDecoder, ResultParameterEncoder, ResultSc
40
44
  * lives in this package; see the root sql-catalog.md for the reviewable surface.
41
45
  */
42
46
  export { compileExclusion, renderExclusionSetup, renderExclusionDdl, renderExclusionCatalog, renderExclusionProbe } from "./exclusion.ts";
43
- export type { AdvisoryLockKey, AdvisoryLockStatement, AdvisoryLocksStatement, AggFn, AggRef, AggSelect, ChainResult, ChainRowSource, ChainCapture, CaptureReturningColumn, ChainStatement, ChainStep, ChainStepStatement, ChainTally, ChainVeto, ColRef, ComparisonOp, DateTruncation, CountSubquery, ScalarSubquery, DeleteStatement, ExcludedRef, InnerJoin, KeyListMember, KeyPage, KeyRows, KeyTableJoin, KeyTableMember, InsertSelectStatement, InsertStatement, ReturningColumn, JsonFilterOp, LateralJoin, LeftJoin, ListSetOperation, OnConflictClause, OnConflictDoNothing, OnConflictUpdate, OrderByAggregate, OrderByColumn, OrderBySubquery, OrderTerm, RowLock, RowNumberProjection, DbNowMarker, JsonParamCell, SelectExpr, SelectStatement, SetOperation, SetOperator, SqlExpr, SqlStatement, StepColumnRef, SourceColumnRef, UpdateSource, TableRef, UpdateStatement, } from "./ast.ts";
44
- export { ADVISORY_LOCK_RESULT_COLUMN, CHAIN_VETO_PREFIX, CHAIN_VETO_TOKEN_PATTERN, SQL_DEFAULT_CELL, SQL_KEEP_CELL, chainVetoToken, dbNowMarker, excludedRef, isDbNowMarker, isExcludedRef, isJsonParamCell, isListSetOperation, isSetOperation, isSqlDefaultCell, isSqlKeepCell, isStepColumnRef, isSourceColumnRef, sourceColumnRef, isCaptureReturningColumn, jsonParamCell, returningColumnName, stepColumnRef, } from "./ast.ts";
47
+ export type { AdvisoryLockKey, AdvisoryLockStatement, AdvisoryLocksStatement, AggFn, AggRef, AggSelect, ChainResult, ChainRowSource, ChainCapture, CaptureReturningColumn, CaptureCascade, CaptureCascadeReturningColumn, CaptureCell, CaptureHop, OtherRowReturningColumn, ChainStatement, ChainStep, ChainStepStatement, ChainTally, ChainVeto, ColRef, ComparisonOp, DateTruncation, GroupKeyExpression, GroupingSets, CountSubquery, ScalarSubquery, DeleteStatement, ExcludedRef, InnerJoin, KeyListMember, KeyPage, KeyRows, KeyTableJoin, KeyTableMember, InsertSelectStatement, InsertStatement, ReturningColumn, JsonFilterOp, LateralJoin, LeftJoin, ListSetOperation, OnConflictClause, OnConflictDoNothing, OnConflictUpdate, OrderByAggregate, OrderByColumn, OrderBySubquery, OrderTerm, RowLock, RowNumberProjection, DbNowMarker, JsonParamCell, SelectExpr, SelectStatement, SetOperation, SetOperator, SqlExpr, SqlStatement, StepColumnRef, SourceColumnRef, UpdateSource, UpdateTableSource, UpdateSelectSource, TableRef, UpdateStatement, } from "./ast.ts";
48
+ export { ADVISORY_LOCK_RESULT_COLUMN, CHAIN_VETO_PREFIX, CHAIN_VETO_TOKEN_PATTERN, COALESCE_REF_NAME, SQL_DEFAULT_CELL, SQL_KEEP_CELL, chainVetoToken, coalesceRef, dbNowMarker, excludedRef, isDbNowMarker, isExcludedRef, isJsonParamCell, isListSetOperation, isSetOperation, isSqlDefaultCell, isSqlKeepCell, isStepColumnRef, isSourceColumnRef, sourceColumnRef, isCaptureReturningColumn, isOtherRowReturningColumn, jsonParamCell, returningColumnName, stepColumnRef, } from "./ast.ts";
45
49
  export type { AdvisoryLockFunctions, AdvisoryLockModeFunctions, RowLockSyntax, EmptyInsertSyntax, SqlDialect, } from "./dialect.ts";
46
50
  export { ADVISORY_KEY_BOUNDS, describeRowLock, renderAdvisoryLock, renderAdvisoryLocks, renderRowLockClause } from "./locks.ts";
47
51
  export { JSON_TRANSPORT, projectionOutputName } from "./json-transport.ts";
@@ -54,6 +58,7 @@ export { keyListBindsUntypedRows, postgresBulkInsertArrayCastOf, postgresKeyList
54
58
  export { renderPredicate, renderSchemaExpression } from "./predicate.ts";
55
59
  export { renderLocalDateCheck } from "./local-date.ts";
56
60
  export { isTimeZoneName, renderDateTruncation } from "./date-truncation.ts";
61
+ export { MYSQL_SCALAR_COLUMN_TYPES, POSTGRES_EXACT_EQUIVALENTS, POSTGRES_NATIVE_ALIASES, POSTGRES_SCALAR_COLUMN_TYPES, SQLITE_SCALAR_STORAGE_CLASSES, canonicalColumnType, normalizeMysqlNativeType, normalizePostgresNativeType, } from "./native-types.ts";
57
62
  export { renderGeneratedColumnClause } from "./generated-columns.ts";
58
63
  export type { GeneratedColumnDeclaration, ExtractedGeneratedColumn } from "./generated-columns.ts";
59
64
  export { renderPostgresGeneratedColumnProbe, renderPostgresDropGeneratedExpression } from "./dialects/postgres-generated-columns.ts";
@@ -67,7 +72,7 @@ export type { PredicateModel, PredicateUsage } from "./predicate.ts";
67
72
  export { DIALECT_CAPABILITIES, MYSQL_CAPABILITIES, POSTGRES_CAPABILITIES, SQLITE_CAPABILITIES, } from "./capabilities.ts";
68
73
  export { DIALECT_CODECS, MYSQL_CODECS, POSTGRES_CODECS, SQLITE_CODECS, decodeIsNoop, decodedDateTimeRefusal, enumMembershipCodec, float32Codec, localDateCodec, parseDateTimeText, parseExtendedDateTimeText, parseJsonText, postgresArrayElementFromText, shortestFloat32, timeOfDayCodec, } from "./codecs.ts";
69
74
  export type { CodecTable, ScalarCodec, WireFidelity } from "./codecs.ts";
70
- export { renderExpr, renderFragment, renderProjection, renderStatement } from "./render.ts";
75
+ export { isRollupChain, renderExpr, renderFragment, renderProjection, renderStatement } from "./render.ts";
71
76
  export type { RenderedQuery } from "./render.ts";
72
77
  export { snapshotSqlValue } from "./parameter-snapshot.ts";
73
78
  export { ParamCollector } from "./params.ts";