@vibeorm/sql 5.9.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 (46) hide show
  1. package/dist/ast.d.ts +120 -4
  2. package/dist/codecs.d.ts +106 -12
  3. package/dist/composable.d.ts +44 -4
  4. package/dist/dialect.d.ts +24 -1
  5. package/dist/dialects/migration-inventory.d.ts +0 -11
  6. package/dist/dialects/mysql-generated-columns.d.ts +1 -5
  7. package/dist/dialects/mysql-index-expressions.d.ts +1 -19
  8. package/dist/dialects/mysql-row-rules.d.ts +1 -7
  9. package/dist/dialects/postgres-generated-columns.d.ts +0 -5
  10. package/dist/dialects/postgres-index-expressions.d.ts +1 -11
  11. package/dist/dialects/postgres-rls-readiness.d.ts +0 -2
  12. package/dist/dialects/postgres-rls.d.ts +7 -1
  13. package/dist/dialects/postgres-row-rules.d.ts +1 -24
  14. package/dist/dialects/sqlite-fts.d.ts +2 -2
  15. package/dist/dialects/sqlite-generated-columns.d.ts +1 -12
  16. package/dist/dialects/sqlite-index-expressions.d.ts +1 -24
  17. package/dist/dialects/sqlite-json-equality.d.ts +1 -14
  18. package/dist/dialects/sqlite-row-rules.d.ts +1 -7
  19. package/dist/dialects/sqlite-table-definition.d.ts +0 -19
  20. package/dist/dialects/test-databases.d.ts +96 -0
  21. package/dist/expr-fragment.d.ts +13 -0
  22. package/dist/identifiers.d.ts +1 -4
  23. package/dist/index.d.ts +9 -5
  24. package/dist/index.js +3754 -3052
  25. package/dist/index.js.map +46 -43
  26. package/dist/json-patch.d.ts +0 -14
  27. package/dist/json-path.d.ts +1 -2
  28. package/dist/key-list.d.ts +0 -21
  29. package/dist/native-types.d.ts +3 -1
  30. package/dist/params.d.ts +0 -2
  31. package/dist/query/expressions.d.ts +1 -33
  32. package/dist/query/index.js.map +7 -7
  33. package/dist/query/mutations.d.ts +1 -14
  34. package/dist/query/reusable.d.ts +1 -16
  35. package/dist/query/select.d.ts +1 -10
  36. package/dist/query/sources.d.ts +1 -36
  37. package/dist/query/state.d.ts +1 -77
  38. package/dist/query-plan.d.ts +2 -2
  39. package/dist/result-decoder.d.ts +21 -1
  40. package/dist/row-rules.d.ts +1 -19
  41. package/dist/sql-bindings.d.ts +7 -43
  42. package/dist/sql-handles.d.ts +1 -3
  43. package/dist/sql-input.d.ts +8 -24
  44. package/dist/timestamp-identity.d.ts +6 -12
  45. package/dist/timestamp-text.d.ts +36 -0
  46. package/package.json +2 -2
@@ -1,25 +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, included }: {
14
- readonly definition: string;
15
- readonly index: string;
16
- readonly postgres?: boolean;
17
- /** PostgreSQL INCLUDE columns the caller read from the catalog (default none). */
18
- readonly included?: number;
19
- }): readonly IndexKeyOperand[] | undefined;
20
- /** SQLite source spelling is the evidence; CAST alone never proves a plain Decimal key. */
21
- export declare function extractSqliteIndexKeys({ definition, index }: {
22
- readonly definition: string;
23
- readonly index: string;
24
- }): readonly IndexKeyOperand[] | undefined;
1
+ export {};
25
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
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { cloneTimestampDate, compareTimestampDates, timestampIdentityKey, timestampIdentityText } from "./timestamp-identity.ts";
2
+ export { parsePlainTimestampText } from "./timestamp-text.ts";
2
3
  export { nativeEnumArrayParameter, isNativeEnumArrayParameter } from "./native-enum-parameter.ts";
3
4
  export type { NativeEnumArrayParameter } from "./native-enum-parameter.ts";
4
5
  export { isJsonListParameter, jsonListParameter } from "./json-list-parameter.ts";
@@ -21,12 +22,15 @@ export { renderReplayCoverageGaps } from "./dialects/migration-replay-coverage.t
21
22
  export { SHADOW_DATABASE, SHADOW_CAPABILITIES, renderShadowOperation } from "./dialects/migration-shadow.ts";
22
23
  export { AUTOMATIC_SHADOW_NAME_PATTERN, SHADOW_MARKER_CAPABILITIES, automaticShadowMarkerText, parseAutomaticShadowMarker, renderAutomaticShadowOperation } from "./dialects/migration-shadow-marker.ts";
23
24
  export type { AutomaticShadowMarker, AutomaticShadowOperation } from "./dialects/migration-shadow-marker.ts";
25
+ export { TEST_DATABASE_CAPABILITIES, TEST_DATABASE_PREFIX_PATTERN, parseTestTemplateMarker, renderTestDatabaseOperation, testCloneCreatedAt, testDatabaseKind, testDatabasePrefixIssue } from "./dialects/test-databases.ts";
26
+ export type { TestDatabaseKind, TestDatabaseOperation } from "./dialects/test-databases.ts";
24
27
  export type { ShadowOperation } from "./dialects/migration-shadow.ts";
25
28
  export { MODULE_JOURNAL_COLUMN, renderModuleJournal } from "./module-journal.ts";
26
29
  export { renderSqliteFtsUpdateTrigger, sqliteFtsUpdateUpgrade } from "./dialects/sqlite-fts.ts";
27
30
  export { SQLITE_SESSION_SQL } from "./dialects/sqlite-session.ts";
28
- export { sql, isSqlFragment, renderSqlFragment, compileSql, sqlUsesIncoming, mapConflictColumns } from "./composable.ts";
31
+ export { sql, isSqlFragment, renderSqlFragment, compileSql, sqlUsesIncoming, mapConflictColumns, captureSqlTemplate, compileSqlTemplate, PlainSqlTemplate } from "./composable.ts";
29
32
  export { registerSqlHandleCheck } from "./sql-handles.ts";
33
+ export { exprToFragment } from "./expr-fragment.ts";
30
34
  export type { SqlFragment, SqlTag } from "./composable.ts";
31
35
  export { createSqlQuery, createSqlCommand, isSqlQuery, isSqlCommand, compileSqlQuery, compileSqlCommand } from "./query-plan.ts";
32
36
  export type { SqlQuery, SqlCommand, SqlPlanRender, CompiledSqlQuery, CompiledSqlCommand, ReusableSqlQuery, ReusableSqlCommand } from "./query-plan.ts";
@@ -35,7 +39,7 @@ export { isSqlParam, createSqlInput, sqlInputContract, createSqlInputScope, seal
35
39
  export type { SqlParam, SqlInput, SqlInputMap, SqlInputValue, SqlInputValues, SqlInputTokens, SqlExecutionParams, SqlInputContract, SqlInputScope } from "./sql-input.ts";
36
40
  export { isSqlBindingCollector, recordSqlBinding, recordSqlBindingCheck } from "./sql-bindings.ts";
37
41
  export type { SqlBindingSource, SqlParameterTransport, SqlBindingEncoder } from "./sql-bindings.ts";
38
- export { decode, encode, resultScalarContract, sameResultDecoder } from "./result-decoder.ts";
42
+ export { decode, decodeResultColumn, encode, resultScalarContract, sameResultDecoder } from "./result-decoder.ts";
39
43
  export type { ResultDecoder, ResultReadDecoder, ResultParameterEncoder, ResultScalarContract, Decoded, ExtendedDateTime } from "./result-decoder.ts";
40
44
  /**
41
45
  * @vibeorm/sql — dialect-aware SQL layer for VibeORM v2.
@@ -44,7 +48,7 @@ export type { ResultDecoder, ResultReadDecoder, ResultParameterEncoder, ResultSc
44
48
  * lives in this package; see the root sql-catalog.md for the reviewable surface.
45
49
  */
46
50
  export { compileExclusion, renderExclusionSetup, renderExclusionDdl, renderExclusionCatalog, renderExclusionProbe } from "./exclusion.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";
51
+ export type { AdvisoryLockKey, AdvisoryLockStatement, AdvisoryLocksStatement, AggFn, AggRef, AggSelect, ChainResult, ChainRowSource, ChainCapture, CaptureReturningColumn, CaptureCascade, CaptureCascadeReturningColumn, CaptureCell, CaptureHop, OtherRowReturningColumn, ServerVersionReturningColumn, 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, UnchangedColumn, UnchangedExactness, 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
52
  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";
49
53
  export type { AdvisoryLockFunctions, AdvisoryLockModeFunctions, RowLockSyntax, EmptyInsertSyntax, SqlDialect, } from "./dialect.ts";
50
54
  export { ADVISORY_KEY_BOUNDS, describeRowLock, renderAdvisoryLock, renderAdvisoryLocks, renderRowLockClause } from "./locks.ts";
@@ -70,8 +74,8 @@ export { renderRowRule } from "./row-rules.ts";
70
74
  export type { RenderedRowRule, RowRuleStatement, RowRuleTriggerPlacement } from "./row-rules.ts";
71
75
  export type { PredicateModel, PredicateUsage } from "./predicate.ts";
72
76
  export { DIALECT_CAPABILITIES, MYSQL_CAPABILITIES, POSTGRES_CAPABILITIES, SQLITE_CAPABILITIES, } from "./capabilities.ts";
73
- export { DIALECT_CODECS, MYSQL_CODECS, POSTGRES_CODECS, SQLITE_CODECS, decodeIsNoop, decodedDateTimeRefusal, enumMembershipCodec, float32Codec, localDateCodec, parseDateTimeText, parseExtendedDateTimeText, parseJsonText, postgresArrayElementFromText, shortestFloat32, timeOfDayCodec, } from "./codecs.ts";
74
- export type { CodecTable, ScalarCodec, WireFidelity } from "./codecs.ts";
77
+ export { DIALECT_CODECS, MYSQL_CODECS, POSTGRES_CODECS, SQLITE_CODECS, dateTimeTextLayoutError, decodeIsNoop, decodedDateTimeRefusal, undecodableDateTimeText, enumMembershipCodec, float32Codec, localDateCodec, parseDateTimeText, parseExtendedDateTimeText, parseJsonText, postgresArrayElementFromText, shortestFloat32, timeOfDayCodec, dateOnlyCodec, dateTimeZoneKey, mysqlBoundTimestampText, parseZoneLessDateTime, zonedCodec, } from "./codecs.ts";
78
+ export type { CodecTable, DateTimeZone, ScalarCodec, WireFidelity } from "./codecs.ts";
75
79
  export { isRollupChain, renderExpr, renderFragment, renderProjection, renderStatement } from "./render.ts";
76
80
  export type { RenderedQuery } from "./render.ts";
77
81
  export { snapshotSqlValue } from "./parameter-snapshot.ts";