@vibeorm/sql 5.8.0 → 5.10.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.
Files changed (51) hide show
  1. package/README.md +1 -0
  2. package/dist/ast.d.ts +293 -9
  3. package/dist/codecs.d.ts +106 -12
  4. package/dist/composable.d.ts +44 -4
  5. package/dist/dialect.d.ts +30 -2
  6. package/dist/dialects/diagnostics.d.ts +1 -1
  7. package/dist/dialects/migration-inventory.d.ts +0 -11
  8. package/dist/dialects/migration-shadow-marker.d.ts +65 -0
  9. package/dist/dialects/mysql-generated-columns.d.ts +1 -5
  10. package/dist/dialects/mysql-index-expressions.d.ts +1 -19
  11. package/dist/dialects/mysql-row-rules.d.ts +1 -7
  12. package/dist/dialects/postgres-generated-columns.d.ts +0 -5
  13. package/dist/dialects/postgres-index-expressions.d.ts +1 -9
  14. package/dist/dialects/postgres-rls-readiness.d.ts +0 -2
  15. package/dist/dialects/postgres-rls.d.ts +7 -1
  16. package/dist/dialects/postgres-row-rules.d.ts +1 -24
  17. package/dist/dialects/sqlite-fts.d.ts +2 -2
  18. package/dist/dialects/sqlite-generated-columns.d.ts +1 -12
  19. package/dist/dialects/sqlite-index-expressions.d.ts +1 -22
  20. package/dist/dialects/sqlite-json-equality.d.ts +1 -14
  21. package/dist/dialects/sqlite-row-rules.d.ts +1 -7
  22. package/dist/dialects/sqlite-table-definition.d.ts +0 -19
  23. package/dist/dialects/test-databases.d.ts +96 -0
  24. package/dist/expr-fragment.d.ts +13 -0
  25. package/dist/identifiers.d.ts +1 -4
  26. package/dist/index-expressions.d.ts +8 -2
  27. package/dist/index.d.ts +16 -7
  28. package/dist/index.js +4148 -2762
  29. package/dist/index.js.map +49 -42
  30. package/dist/json-patch.d.ts +82 -0
  31. package/dist/json-path.d.ts +2 -0
  32. package/dist/key-list.d.ts +0 -21
  33. package/dist/native-types.d.ts +72 -0
  34. package/dist/params.d.ts +0 -2
  35. package/dist/query/expressions.d.ts +1 -33
  36. package/dist/query/index.js.map +7 -7
  37. package/dist/query/mutations.d.ts +1 -14
  38. package/dist/query/reusable.d.ts +1 -16
  39. package/dist/query/select.d.ts +1 -10
  40. package/dist/query/sources.d.ts +1 -36
  41. package/dist/query/state.d.ts +1 -77
  42. package/dist/query-plan.d.ts +2 -2
  43. package/dist/render.d.ts +9 -0
  44. package/dist/result-decoder.d.ts +21 -1
  45. package/dist/row-rules.d.ts +1 -19
  46. package/dist/sql-bindings.d.ts +7 -43
  47. package/dist/sql-handles.d.ts +1 -3
  48. package/dist/sql-input.d.ts +8 -24
  49. package/dist/timestamp-identity.d.ts +6 -12
  50. package/dist/timestamp-text.d.ts +36 -0
  51. package/package.json +2 -2
@@ -21,10 +21,22 @@ export type SqlTag = {
21
21
  value: NoInfer<T>;
22
22
  decoder?: ResultDecoder<T>;
23
23
  }) => SqlFragment;
24
- readonly join: (params: {
25
- items: readonly unknown[];
26
- separator?: SqlFragment;
27
- }) => SqlFragment;
24
+ /**
25
+ * A list: fragments spliced, anything else bound as one value each, joined
26
+ * by `separator` (default `, `). `sql.join(items, separator)` and
27
+ * `sql.join({ items, separator })` are the same call.
28
+ */
29
+ readonly join: {
30
+ (items: readonly unknown[], separator?: SqlFragment): SqlFragment;
31
+ (params: {
32
+ items: readonly unknown[];
33
+ separator?: SqlFragment;
34
+ }): SqlFragment;
35
+ };
36
+ /** Every condition must hold: `(a) AND (b)`, each part in parentheses; `undefined` parts are skipped, and none left is `TRUE`. */
37
+ readonly and: (parts: readonly (SqlFragment | undefined)[]) => SqlFragment;
38
+ /** Any condition may hold: `(a) OR (b)`, each part in parentheses; `undefined` parts are skipped, and none left is `FALSE`. */
39
+ readonly or: (parts: readonly (SqlFragment | undefined)[]) => SqlFragment;
28
40
  readonly existing: (params: {
29
41
  column: string;
30
42
  }) => SqlFragment;
@@ -62,6 +74,34 @@ export declare function compileSql(params: {
62
74
  text: string;
63
75
  values: unknown[];
64
76
  };
77
+ /**
78
+ * A tagged template whose every interpolated value binds as one plain
79
+ * parameter (no fragment, no typed array or JSON-list parameter), captured
80
+ * without building a fragment. Its values are snapshotted when captured, as
81
+ * `sql` snapshots them; `compileSqlTemplate` renders it.
82
+ */
83
+ export declare class PlainSqlTemplate {
84
+ readonly strings: TemplateStringsArray;
85
+ readonly values: readonly unknown[];
86
+ constructor(strings: TemplateStringsArray, values: readonly unknown[]);
87
+ }
88
+ /**
89
+ * What `sql` builds for a template, except that a template whose
90
+ * values all bind as plain parameters comes back as a `PlainSqlTemplate`:
91
+ * the same text and values once compiled, without a fragment per call.
92
+ */
93
+ export declare function captureSqlTemplate(params: {
94
+ strings: TemplateStringsArray;
95
+ values: readonly unknown[];
96
+ }): SqlFragment | PlainSqlTemplate;
97
+ /** `compileSql` over what `captureSqlTemplate` returned. */
98
+ export declare function compileSqlTemplate(params: {
99
+ dialect: SqlDialect;
100
+ query: SqlFragment | PlainSqlTemplate;
101
+ }): {
102
+ text: string;
103
+ values: unknown[];
104
+ };
65
105
  /** Whether a nested SQL fragment reads the incoming row (MySQL alias declaration). */
66
106
  export declare function sqlUsesIncoming(params: {
67
107
  fragment: SqlFragment;
package/dist/dialect.d.ts CHANGED
@@ -20,6 +20,13 @@ import type { ParamCollector } from "./params.ts";
20
20
  export type RowLockSyntax = {
21
21
  readonly strengths: Readonly<Partial<Record<RowLockStrength, string>>>;
22
22
  readonly wait: Readonly<Partial<Record<RowLockWaitPolicy, string>>>;
23
+ /**
24
+ * The spelling of a strength when the lock names no `OF` table and no wait
25
+ * policy, where it differs from `strengths`: a form more servers of the
26
+ * family parse (MySQL's `LOCK IN SHARE MODE`, which MariaDB and MySQL before
27
+ * 8.0.1 accept while `FOR SHARE` is a syntax error there).
28
+ */
29
+ readonly plain?: Readonly<Partial<Record<RowLockStrength, string>>>;
23
30
  };
24
31
  /** The blocking and try function names for one advisory-lock mode. */
25
32
  export type AdvisoryLockModeFunctions = {
@@ -218,8 +225,14 @@ export type SqlDialect = {
218
225
  * PostgreSQL and MySQL turn it into a semi-join. `inSelect`: an uncorrelated
219
226
  * `key IN (SELECT key …)` — SQLite runs a correlated `EXISTS` once per outer
220
227
  * row (`post where author.email = x`: 134 → 0.15 ms, Post 500 000).
228
+ * `eqSelect`: a to-one through ONE foreign-key column pinned this way renders
229
+ * `fk = (SELECT key …)`, every other shape the correlated `EXISTS` —
230
+ * PostgreSQL plans the semi-join as a loop into all of the parent's children
231
+ * and sorts them for a page, but reads a page of `fk = (SELECT …)` in index
232
+ * order (newest 20 of 4 000 orders of one person: 889 → 11 buffers,
233
+ * 1.16 → 0.01 ms; an `IN (SELECT …)` keeps the semi-join plan).
221
234
  */
222
- readonly relationFilterStrategy: "exists" | "inSelect";
235
+ readonly relationFilterStrategy: "exists" | "inSelect" | "eqSelect";
223
236
  /**
224
237
  * DB-02: when a find with a TOTAL order (it ends with the full primary key)
225
238
  * pages with `skip` ≥ `minSkip`, the runtime cuts the page as primary keys
@@ -450,11 +463,16 @@ export type SqlDialect = {
450
463
  renderEnumOrdinal(params: {
451
464
  column: string;
452
465
  }): string;
453
- /** Render native enum MIN/MAX in database declaration order, returning its label or an order key. */
466
+ /**
467
+ * Render native enum MIN/MAX in database declaration order, returning its
468
+ * label or an order key. `when` (a rendered predicate) is a filtered
469
+ * aggregate on a `caseWhen` dialect: only the rows it admits are aggregated.
470
+ */
454
471
  renderEnumMinMax(params: {
455
472
  fn: "min" | "max";
456
473
  column: string;
457
474
  result: "value" | "ordinal";
475
+ when?: string;
458
476
  }): string;
459
477
  /** Positional placeholder for the 1-based parameter index ($n or ?). */
460
478
  placeholder(params: {
@@ -479,5 +497,15 @@ export type SqlDialect = {
479
497
  offsetSeconds: number;
480
498
  collector: ParamCollector;
481
499
  }): string;
500
+ /**
501
+ * True when any pair of the two equally long lists of rendered expressions
502
+ * differs, NULL counting as a value: `IS DISTINCT FROM` on postgres, `IS
503
+ * NOT` on sqlite, `NOT (… <=> …)` on mysql. One pair compares the two
504
+ * expressions; several compare row constructors.
505
+ */
506
+ renderRowsDiffer(params: {
507
+ left: readonly string[];
508
+ right: readonly string[];
509
+ }): string;
482
510
  };
483
511
  //# sourceMappingURL=dialect.d.ts.map
@@ -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;
@@ -1,16 +1,5 @@
1
1
  import type { SqlDialect } from "../dialect.ts";
2
2
  import type { RenderedQuery } from "../render.ts";
3
- /**
4
- * Ends a MySQL catalog listing whose row count has no small bound (the
5
- * migration inventory, the visibility proof). `sql_select_limit` (session or
6
- * global, e.g. 1 000 under `mysql --safe-updates`) silently cuts the rows of a
7
- * SELECT without its own LIMIT, and a cut listing reads its last objects (or
8
- * grants) as missing; an explicit LIMIT takes precedence over it. After the
9
- * last `UNION` branch (and its ORDER BY) the LIMIT applies to the whole union.
10
- * The value is MySQL's largest row count, so nothing is ever cut. The batched
11
- * object readers end the same way (`migration-objects.ts`, LEFTOVERS-01).
12
- */
13
- export declare const MYSQL_NO_ROW_LIMIT: string;
14
3
  /** SQLite column metadata includes generated columns omitted by table_info. */
15
4
  export declare function renderSqliteColumnInventory(params: {
16
5
  dialect: SqlDialect;
@@ -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,11 +1,7 @@
1
1
  import type { QualifiedSqlName } from "@vibeorm/schema";
2
2
  import type { SqlDialect } from "../dialect.ts";
3
- import type { ExtractedGeneratedColumn, GeneratedColumnDeclaration } from "../generated-columns.ts";
3
+ import type { ExtractedGeneratedColumn } from "../generated-columns.ts";
4
4
  import type { RenderedQuery } from "../render.ts";
5
- /** MySQL stored syntax, placed after complete type/charset/collation information. */
6
- export declare function renderMysqlGeneratedColumnClause({ generated }: {
7
- readonly generated: GeneratedColumnDeclaration;
8
- }): string;
9
5
  /** Temporary CREATE/DROP operations avoid ALTER's implicit-commit boundary. */
10
6
  export type MysqlGeneratedColumnProbe = {
11
7
  readonly operation: "context";
@@ -1,20 +1,2 @@
1
- import type { IndexKeyTermIR } from "@vibeorm/schema";
2
- import type { SqlDialect } from "../dialect.ts";
3
- import type { IndexExpressionProbeParams, IndexKeyOperand } from "../index-expressions.ts";
4
- import type { PredicateModel } from "../predicate.ts";
5
- import type { RenderedQuery } from "../render.ts";
6
- /** Qualify only expression-bearing keys through schema's shared width rule; never impose new bounds on ordinary indexes. */
7
- export declare function assertMysqlIndexKeyStorage({ model, terms }: {
8
- readonly dialect: SqlDialect;
9
- readonly model: PredicateModel;
10
- readonly terms: readonly IndexKeyTermIR[];
11
- }): void;
12
- /** Recover SHOW CREATE key interiors, including exact CAST/charset/collation bytes. */
13
- export declare function extractMysqlIndexKeys({ definition, index, backslashEscapes }: {
14
- readonly definition: string;
15
- readonly index: string;
16
- readonly backslashEscapes: boolean;
17
- }): readonly IndexKeyOperand[] | undefined;
18
- /** Reuse E's temporary-clone/read/drop operations, extending only CREATE's key replacement seam. */
19
- export declare function renderMysqlIndexExpressionProbe({ ...params }: IndexExpressionProbeParams): readonly RenderedQuery[];
1
+ export {};
20
2
  //# sourceMappingURL=mysql-index-expressions.d.ts.map
@@ -1,8 +1,2 @@
1
- import type { SqlDialect } from "../dialect.ts";
2
- import type { EventRowRuleContext, RenderedRowRule } from "../row-rules.ts";
3
- /** Emit mode-safe SIGNAL diagnostics and one unfiltered BEFORE trigger per event. */
4
- export declare function renderMysqlRowRule({ dialect, context }: {
5
- readonly dialect: SqlDialect;
6
- readonly context: EventRowRuleContext;
7
- }): RenderedRowRule;
1
+ export {};
8
2
  //# sourceMappingURL=mysql-row-rules.d.ts.map
@@ -1,11 +1,6 @@
1
1
  import type { QualifiedSqlName } from "@vibeorm/schema";
2
2
  import type { SqlDialect } from "../dialect.ts";
3
- import type { GeneratedColumnDeclaration } from "../generated-columns.ts";
4
3
  import type { RenderedQuery } from "../render.ts";
5
- /** PostgreSQL stored syntax; the public dispatcher performs declaration admission. */
6
- export declare function renderPostgresGeneratedColumnClause({ generated }: {
7
- readonly generated: GeneratedColumnDeclaration;
8
- }): string;
9
4
  /** The migration owner creates the desired base context inside the private savepoint. */
10
5
  export type PostgresGeneratedColumnProbe = {
11
6
  readonly operation: "savepoint" | "rollback" | "release";
@@ -1,10 +1,2 @@
1
- import type { IndexExpressionProbeParams, IndexKeyOperand } from "../index-expressions.ts";
2
- import type { RenderedQuery } from "../render.ts";
3
- /** CREATE INDEX extraction is conservative; structured catalog rows remain authoritative. */
4
- export declare function extractPostgresIndexKeys({ definition, index }: {
5
- readonly definition: string;
6
- readonly index: string;
7
- }): readonly IndexKeyOperand[] | undefined;
8
- /** Caller owns a fixed search_path and rollback savepoint; no populated user table is indexed. */
9
- export declare function renderPostgresIndexExpressionProbe({ ...params }: IndexExpressionProbeParams): readonly RenderedQuery[];
1
+ export {};
10
2
  //# sourceMappingURL=postgres-index-expressions.d.ts.map
@@ -2,8 +2,6 @@ import type { SqlDialect } from "../dialect.ts";
2
2
  import type { RenderedQuery } from "../render.ts";
3
3
  /** Throwaway policy identity; never installed on a live table by readiness. */
4
4
  export declare const NATIVE_RLS_PROBE_POLICY: "vibeorm_probe";
5
- /** The reads `catalog` folds, in the order their JSON columns appear. */
6
- export declare const RLS_READINESS_CATALOG_KEYS: readonly ("identity" | "elevatedRoles" | "schemaControl" | "tables" | "policies" | "views" | "routines" | "triggers")[];
7
5
  /** Read-only catalog SQL; exported for exact statement routing in adapter tests. */
8
6
  export declare const RLS_READINESS_SQL: {
9
7
  readonly identity: string;
@@ -43,11 +43,17 @@ export declare function renderRlsColumnType(params: {
43
43
  dialect: SqlDialect;
44
44
  field: FieldIR;
45
45
  }): string;
46
- /** Desired predicate only, for drift probes; it is NOT server-canonical deparse. */
46
+ /**
47
+ * Desired predicate only, for drift probes; it is NOT server-canonical deparse.
48
+ * `qualify` names the table a `where` rule's columns are read from, for a
49
+ * statement with another relation in scope (`excluded` in `ON CONFLICT … DO
50
+ * UPDATE`); the policy itself and the drift probes render them bare.
51
+ */
47
52
  export declare function renderRlsPredicate(params: {
48
53
  dialect: SqlDialect;
49
54
  schema: SchemaIR;
50
55
  model: string;
56
+ qualify?: string;
51
57
  }): string;
52
58
  /** One PERMISSIVE ALL/PUBLIC policy with equal existing/proposed-row checks. */
53
59
  export declare function renderRlsPolicy(params: {
@@ -1,25 +1,2 @@
1
- import type { FieldIR, QualifiedSqlName, RowRuleIR, SqlObjectIdentity } from "@vibeorm/schema";
2
- import type { SqlDialect } from "../dialect.ts";
3
- import type { RenderedRowRule } from "../row-rules.ts";
4
- /** A finalized PostgreSQL comparison context, supplied by the canonical schema collector. */
5
- export type PostgresRowRuleContext = {
6
- readonly model: string;
7
- readonly table: QualifiedSqlName;
8
- readonly rule: RowRuleIR;
9
- readonly functionIdentity: Extract<SqlObjectIdentity, {
10
- readonly kind: "function";
11
- }>;
12
- readonly triggerIdentity: {
13
- readonly kind: "trigger";
14
- readonly table: QualifiedSqlName;
15
- readonly name: string;
16
- };
17
- readonly protectedFields: readonly FieldIR[];
18
- readonly gateField?: FieldIR;
19
- };
20
- /** Emit one ordinary invoker function and an unfiltered BEFORE row trigger; no live objects are taken over. */
21
- export declare function renderPostgresRowRule({ dialect, context }: {
22
- readonly dialect: SqlDialect;
23
- readonly context: PostgresRowRuleContext;
24
- }): RenderedRowRule;
1
+ export {};
25
2
  //# sourceMappingURL=postgres-row-rules.d.ts.map
@@ -1,4 +1,4 @@
1
- /** @internal SQLite FTS synchronization SQL and its independently verifiable catalog spelling. */
1
+ /** SQLite FTS synchronization SQL and its independently verifiable catalog spelling. */
2
2
  export declare function renderSqliteFtsUpdateTrigger(params: {
3
3
  table: string;
4
4
  ftsTable: string;
@@ -7,7 +7,7 @@ export declare function renderSqliteFtsUpdateTrigger(params: {
7
7
  readonly create: string;
8
8
  readonly definition: string;
9
9
  };
10
- /** @internal Recognize only complete generated legacy/current triggers and their external-content FTS5 table. */
10
+ /** Recognize only complete generated legacy/current triggers and their external-content FTS5 table. */
11
11
  export declare function sqliteFtsUpdateUpgrade(params: {
12
12
  create: string;
13
13
  installed: string;
@@ -1,15 +1,4 @@
1
- import type { ExtractedGeneratedColumn, GeneratedColumnDeclaration } from "../generated-columns.ts";
2
- /** SQLite stored syntax; adding a stored column still requires the migrate rebuild path. */
3
- export declare function renderSqliteGeneratedColumnClause({ generated }: {
4
- readonly generated: GeneratedColumnDeclaration;
5
- }): string;
6
- /** Shared source-slice extraction for SQLite source and MySQL SHOW CREATE, not SQL equivalence. */
7
- export declare function extractGenerationFromDefinition({ definition, column, backslashEscapes, mysql }: {
8
- readonly definition: string;
9
- readonly column: string;
10
- readonly backslashEscapes?: boolean;
11
- readonly mysql?: boolean;
12
- }): ExtractedGeneratedColumn | undefined;
1
+ import type { ExtractedGeneratedColumn } from "../generated-columns.ts";
13
2
  /** Recover the exact AS interior; omitted storage means virtual, never inferred stored. */
14
3
  export declare function extractSqliteGeneratedColumn({ definition, column }: {
15
4
  readonly definition: string;
@@ -1,23 +1,2 @@
1
- import type { IndexKeyOperand } from "../index-expressions.ts";
2
- import type { TableDefinitionToken } from "./sqlite-table-definition.ts";
3
- /** Exact outer-key slices shared by CREATE INDEX and MySQL table-key clauses. */
4
- export declare function extractIndexKeyList({ sql, open, close, tokens, wrapped, removeWrapper }: {
5
- readonly sql: string;
6
- readonly open: TableDefinitionToken;
7
- readonly close: TableDefinitionToken;
8
- readonly tokens: readonly TableDefinitionToken[];
9
- readonly wrapped?: boolean;
10
- readonly removeWrapper?: boolean;
11
- }): readonly IndexKeyOperand[] | undefined;
12
- /** Parse the CREATE INDEX header without interpreting any scalar expression. */
13
- export declare function extractStandaloneIndexKeys({ definition, index, postgres }: {
14
- readonly definition: string;
15
- readonly index: string;
16
- readonly postgres?: boolean;
17
- }): readonly IndexKeyOperand[] | undefined;
18
- /** SQLite source spelling is the evidence; CAST alone never proves a plain Decimal key. */
19
- export declare function extractSqliteIndexKeys({ definition, index }: {
20
- readonly definition: string;
21
- readonly index: string;
22
- }): readonly IndexKeyOperand[] | undefined;
1
+ export {};
23
2
  //# sourceMappingURL=sqlite-index-expressions.d.ts.map
@@ -1,15 +1,2 @@
1
- import type { SqlDialect } from "../dialect.ts";
2
- /**
3
- * Compare both JSON trees by decoded key/index paths, node type and atomic value.
4
- * Object order and JSON escape spelling do not matter; array positions do.
5
- * Container nodes retain empty-object/array distinctions, and multiplicity stops
6
- * duplicate object members from disappearing as they would in a set difference.
7
- * SQL NULL remains unknown. The tree input is guarded against non-JSON scalar
8
- * text even when SQLite evaluates this expression before the outer type guard.
9
- */
10
- export declare function renderSqliteJsonEquality(params: {
11
- dialect: SqlDialect;
12
- left: string;
13
- right: string;
14
- }): string;
1
+ export {};
15
2
  //# sourceMappingURL=sqlite-json-equality.d.ts.map
@@ -1,8 +1,2 @@
1
- import type { SqlDialect } from "../dialect.ts";
2
- import type { EventRowRuleContext, RenderedRowRule } from "../row-rules.ts";
3
- /** Emit literal-only ABORT diagnostics and one unfiltered BEFORE trigger per event. */
4
- export declare function renderSqliteRowRule({ dialect, context }: {
5
- readonly dialect: SqlDialect;
6
- readonly context: EventRowRuleContext;
7
- }): RenderedRowRule;
1
+ export {};
8
2
  //# sourceMappingURL=sqlite-row-rules.d.ts.map
@@ -8,30 +8,11 @@ export type TableDefinitionParts = {
8
8
  readonly clauses: readonly string[];
9
9
  readonly suffix: string;
10
10
  };
11
- /** A source token with balanced-parenthesis depth and original byte boundaries. */
12
- export type TableDefinitionToken = {
13
- readonly value: string;
14
- readonly kind: "word" | "quoted" | "literal" | "symbol";
15
- readonly start: number;
16
- readonly end: number;
17
- readonly depth: number;
18
- };
19
- /** Scan SQL delimiters without looking inside quoted strings, identifiers or comments. */
20
- export declare function tableDefinitionTokens({ sql, backslashEscapes }: {
21
- readonly sql: string;
22
- readonly backslashEscapes?: boolean;
23
- }): readonly TableDefinitionToken[];
24
11
  /** Extract a CREATE TABLE list with a quote/comment-aware delimiter walk. */
25
12
  export declare function tableDefinitionParts({ sql, backslashEscapes }: {
26
13
  readonly sql: string;
27
14
  readonly backslashEscapes?: boolean;
28
15
  }): TableDefinitionParts;
29
- /** Read column names for SQLite source and MySQL SHOW CREATE using the same lexer. */
30
- export declare function tableColumnClauses({ sql, backslashEscapes, mysql }: {
31
- readonly sql: string;
32
- readonly backslashEscapes?: boolean;
33
- readonly mysql?: boolean;
34
- }): readonly SqliteColumnClause[];
35
16
  /** Return column clauses without rewriting any SQL inside them. */
36
17
  export declare function sqliteColumnClauses({ sql }: {
37
18
  readonly sql: string;
@@ -0,0 +1,96 @@
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 copy a migrated database on the server. PostgreSQL clones
6
+ * a template database (`CREATE DATABASE … TEMPLATE`). MySQL has no template
7
+ * databases, and its only server-side copy (`CREATE TABLE … LIKE`) leaves the
8
+ * foreign keys behind; SQLite copies files and sends no SQL for it.
9
+ */
10
+ export declare const TEST_DATABASE_CAPABILITIES: Readonly<Record<Dialect, Readonly<{
11
+ templateDatabases: boolean;
12
+ }>>>;
13
+ /**
14
+ * A caller's test-database prefix: lower-case, a plain identifier start, and
15
+ * the word `test` in it, so a prefix cannot name an application's databases.
16
+ */
17
+ export declare const TEST_DATABASE_PREFIX_PATTERN: RegExp;
18
+ /** What a test-database name is, by its shape under one prefix. */
19
+ export type TestDatabaseKind = "template" | "clone";
20
+ /** `undefined` for a valid prefix, else why it is refused. */
21
+ export declare function testDatabasePrefixIssue(params: {
22
+ prefix: unknown;
23
+ }): string | undefined;
24
+ /** The kind of a database name under `prefix`, or `undefined` for every other name. */
25
+ export declare function testDatabaseKind(params: {
26
+ prefix: string;
27
+ name: string;
28
+ }): TestDatabaseKind | undefined;
29
+ /** When a clone was created (ms since the epoch, the creating process's clock), read from its name. */
30
+ export declare function testCloneCreatedAt(params: {
31
+ prefix: string;
32
+ name: string;
33
+ }): number | undefined;
34
+ /** The template marker's creation time (server milliseconds), or `undefined` for any other comment. */
35
+ export declare function parseTestTemplateMarker(params: {
36
+ text: unknown;
37
+ }): number | undefined;
38
+ /** Test-database statements on the administration connection. */
39
+ export type TestDatabaseOperation =
40
+ /**
41
+ * One row whether or not the database exists: its template flag (null when
42
+ * absent), its comment, the sessions connected to it other than this one, and
43
+ * the server clock in milliseconds.
44
+ */
45
+ {
46
+ readonly kind: "state";
47
+ readonly prefix: string;
48
+ readonly name: string;
49
+ }
50
+ /** An empty database to build a template in. */
51
+ | {
52
+ readonly kind: "createTemplate";
53
+ readonly prefix: string;
54
+ readonly name: string;
55
+ }
56
+ /** The template's creation time (server milliseconds), as its database comment. */
57
+ | {
58
+ readonly kind: "markTemplate";
59
+ readonly prefix: string;
60
+ readonly name: string;
61
+ readonly created: number;
62
+ }
63
+ /**
64
+ * Set: the build's last step and the ready signal — a template that refuses
65
+ * connections, because one connection to it blocks every clone. Cleared before
66
+ * a template is dropped.
67
+ */
68
+ | {
69
+ readonly kind: "flagTemplate";
70
+ readonly prefix: string;
71
+ readonly name: string;
72
+ readonly template: boolean;
73
+ } | {
74
+ readonly kind: "clone";
75
+ readonly prefix: string;
76
+ readonly name: string;
77
+ readonly template: string;
78
+ }
79
+ /** `force` (PostgreSQL 13+) ends the sessions still connected; only a clone may be forced. */
80
+ | {
81
+ readonly kind: "drop";
82
+ readonly prefix: string;
83
+ readonly name: string;
84
+ readonly force?: boolean;
85
+ }
86
+ /** Every database whose name starts with the prefix, its template flag, comment and other sessions, and the server clock. */
87
+ | {
88
+ readonly kind: "list";
89
+ readonly prefix: string;
90
+ };
91
+ /** Render one test-database statement; dialects without template databases refuse. */
92
+ export declare function renderTestDatabaseOperation(params: {
93
+ dialect: SqlDialect;
94
+ operation: TestDatabaseOperation;
95
+ }): RenderedQuery;
96
+ //# sourceMappingURL=test-databases.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { SqlExpr } from "./ast.ts";
2
+ import type { SqlFragment } from "./composable.ts";
3
+ import type { SqlDialect } from "./dialect.ts";
4
+ /**
5
+ * A compiled boolean expression as an opaque fragment for the caller's own
6
+ * statement: the text the dialect renders, every bound value a fragment
7
+ * value, so the enclosing statement numbers the placeholders.
8
+ */
9
+ export declare function exprToFragment(params: {
10
+ dialect: SqlDialect;
11
+ expr: SqlExpr;
12
+ }): SqlFragment;
13
+ //# sourceMappingURL=expr-fragment.d.ts.map
@@ -7,8 +7,5 @@
7
7
  * containing one is not an identifier at all. Refused at render time, the
8
8
  * earliest point every path (IR, raw `sql.ident`, extension DDL) shares.
9
9
  */
10
- /** Return `name` unchanged, or throw `VIBE_VALIDATION` when it contains a NUL. */
11
- export declare function assertNoNul(params: {
12
- name: string;
13
- }): string;
10
+ export {};
14
11
  //# sourceMappingURL=identifiers.d.ts.map
@@ -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[];