@vibeorm/sql 4.1.0 → 4.3.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.
@@ -0,0 +1,8 @@
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;
8
+ //# sourceMappingURL=sqlite-row-rules.d.ts.map
@@ -8,12 +8,32 @@ export type TableDefinitionParts = {
8
8
  readonly clauses: readonly string[];
9
9
  readonly suffix: string;
10
10
  };
11
- /** Extract a CREATE TABLE list with a quote-aware delimiter walk, not an expression parser. */
12
- export declare function tableDefinitionParts(params: {
13
- sql: string;
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
+ /** Extract a CREATE TABLE list with a quote/comment-aware delimiter walk. */
25
+ export declare function tableDefinitionParts({ sql, backslashEscapes }: {
26
+ readonly sql: string;
27
+ readonly backslashEscapes?: boolean;
14
28
  }): 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[];
15
35
  /** Return column clauses without rewriting any SQL inside them. */
16
- export declare function sqliteColumnClauses(params: {
17
- sql: string;
36
+ export declare function sqliteColumnClauses({ sql }: {
37
+ readonly sql: string;
18
38
  }): readonly SqliteColumnClause[];
19
39
  //# sourceMappingURL=sqlite-table-definition.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { GeneratedColumnIR } from "@vibeorm/schema";
2
+ import type { SqlDialect } from "./dialect.ts";
3
+ /** SQL helper name for the canonical stored generation declaration. */
4
+ export type GeneratedColumnDeclaration = GeneratedColumnIR;
5
+ /** Source evidence; virtual storage is reported for the caller's admission check. */
6
+ export type ExtractedGeneratedColumn = {
7
+ readonly expression: string;
8
+ readonly storage: "stored" | "virtual";
9
+ readonly columnSql: string;
10
+ /** Declaration prefix, including any type/charset/collation/nullability qualifiers. */
11
+ readonly typeSql: string;
12
+ };
13
+ /** Render trusted physical SQL without interpreting or rewriting its expression. */
14
+ export declare function renderGeneratedColumnClause({ dialect, generated }: {
15
+ readonly dialect: SqlDialect;
16
+ readonly generated: GeneratedColumnDeclaration;
17
+ }): string;
18
+ //# sourceMappingURL=generated-columns.d.ts.map
@@ -0,0 +1,61 @@
1
+ import type { Dialect, EnumIR, IndexIR, QualifiedSqlName } from "@vibeorm/schema";
2
+ import type { SqlDialect } from "./dialect.ts";
3
+ import type { PredicateModel } from "./predicate.ts";
4
+ import type { RenderedQuery } from "./render.ts";
5
+ /** Complete ordered physical keys; expression text has no key wrapper or direction. */
6
+ export type IndexKeyOperand = {
7
+ readonly kind: "field";
8
+ readonly name: string;
9
+ readonly desc: boolean;
10
+ readonly decimal?: boolean;
11
+ readonly operatorClass?: QualifiedSqlName;
12
+ } | {
13
+ readonly kind: "expression";
14
+ readonly text: string;
15
+ readonly desc: boolean;
16
+ };
17
+ /** Scratch statements only: sessions, normalization context and cleanup belong to migrate. */
18
+ export type IndexExpressionProbeParams = {
19
+ readonly dialect: SqlDialect;
20
+ readonly operation: "context" | "clone" | "createIndex" | "read" | "drop";
21
+ readonly probe: {
22
+ readonly table: string;
23
+ readonly index: string;
24
+ };
25
+ readonly table?: QualifiedSqlName;
26
+ readonly keys?: readonly IndexKeyOperand[];
27
+ readonly unique?: boolean;
28
+ readonly definition?: string;
29
+ readonly backslashEscapes?: boolean;
30
+ readonly where?: string;
31
+ readonly nullsNotDistinct?: boolean;
32
+ };
33
+ /** Resolve logical terms using the shared scalar renderer, then qualify physical key storage. */
34
+ export declare function resolveIndexKeys({ index, model, dialect, enums, site }: {
35
+ readonly index: IndexIR;
36
+ readonly model: PredicateModel;
37
+ readonly dialect: SqlDialect;
38
+ readonly enums?: readonly EnumIR[];
39
+ readonly site: string;
40
+ }): readonly IndexKeyOperand[];
41
+ /** Render complete key fragments; the caller owns the outer CREATE/ALTER list. */
42
+ export declare function renderIndexKeys({ dialect, keys, unique }: {
43
+ readonly dialect: SqlDialect;
44
+ readonly keys: readonly IndexKeyOperand[];
45
+ readonly unique: boolean;
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 }: {
49
+ readonly dialect: Dialect;
50
+ readonly definition: string;
51
+ readonly index: string;
52
+ readonly backslashEscapes?: boolean;
53
+ }): readonly IndexKeyOperand[] | undefined;
54
+ /** Render a real expression-index normalization host, never a scalar CHECK surrogate. */
55
+ export declare function renderIndexExpressionProbe({ ...params }: IndexExpressionProbeParams): readonly RenderedQuery[];
56
+ /** Version admission after a connection reveals its host, before scratch or user index DDL. */
57
+ export declare function assertIndexExpressionVersion({ dialect, version }: {
58
+ readonly dialect: Dialect;
59
+ readonly version: string;
60
+ }): void;
61
+ //# sourceMappingURL=index-expressions.d.ts.map
package/dist/index.d.ts CHANGED
@@ -8,9 +8,11 @@ export { renderExternalDependents } from "./dialects/external-dependents.ts";
8
8
  export type { ExternalDependentTarget } from "./dialects/external-dependents.ts";
9
9
  export { renderPostgresPhysicalCatalog } from "./dialects/postgres-physical-catalog.ts";
10
10
  export type { PostgresPhysicalCatalogQuery } from "./dialects/postgres-physical-catalog.ts";
11
- export { renderPostgresIndexKeys } from "./dialects/postgres-index-keys.ts";
11
+ export { renderPostgresIndexKeys, renderPostgresJitSuspend, renderPostgresJitRestore } from "./dialects/postgres-index-keys.ts";
12
12
  export { renderIndexColumns } from "./index-columns.ts";
13
13
  export type { IndexColumnOperand } from "./index-columns.ts";
14
+ export { resolveIndexKeys, renderIndexKeys, extractIndexKeys, renderIndexExpressionProbe, assertIndexExpressionVersion } from "./index-expressions.ts";
15
+ export type { IndexKeyOperand, IndexExpressionProbeParams } from "./index-expressions.ts";
14
16
  export { renderModuleDependencyQuery } from "./dialects/module-dependency.ts";
15
17
  export type { ModuleDependencyOperation } from "./dialects/module-dependency.ts";
16
18
  export { renderReplayCoverageGaps } from "./dialects/migration-replay-coverage.ts";
@@ -38,9 +40,9 @@ export type { ResultDecoder, ResultReadDecoder, ResultParameterEncoder, ResultSc
38
40
  * lives in this package; see the root sql-catalog.md for the reviewable surface.
39
41
  */
40
42
  export { compileExclusion, renderExclusionSetup, renderExclusionDdl, renderExclusionCatalog, renderExclusionProbe } from "./exclusion.ts";
41
- export type { AdvisoryLockKey, AdvisoryLockStatement, AggFn, AggRef, AggSelect, ChainResult, ChainRowSource, ChainStatement, ChainStep, ChainStepStatement, ChainTally, ChainVeto, ColRef, ComparisonOp, CountSubquery, DeleteStatement, ExcludedRef, InnerJoin, KeyTableJoin, KeyTableMember, InsertSelectStatement, InsertStatement, ReturningColumn, JsonFilterOp, LateralJoin, ListSetOperation, OnConflictClause, OnConflictDoNothing, OnConflictUpdate, OrderByAggregate, OrderByColumn, OrderBySubquery, OrderTerm, RowLock, RowNumberProjection, DbNowMarker, JsonParamCell, SelectExpr, SelectStatement, SetOperation, SetOperator, SqlExpr, SqlStatement, StepColumnRef, TableRef, UpdateStatement, } from "./ast.ts";
43
+ export type { AdvisoryLockKey, AdvisoryLockStatement, AggFn, AggRef, AggSelect, ChainResult, ChainRowSource, ChainStatement, ChainStep, ChainStepStatement, ChainTally, ChainVeto, ColRef, ComparisonOp, CountSubquery, DeleteStatement, ExcludedRef, InnerJoin, KeyListMember, KeyPage, 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, TableRef, UpdateStatement, } from "./ast.ts";
42
44
  export { ADVISORY_LOCK_RESULT_COLUMN, CHAIN_VETO_PREFIX, CHAIN_VETO_TOKEN_PATTERN, SQL_DEFAULT_CELL, chainVetoToken, dbNowMarker, excludedRef, isDbNowMarker, isExcludedRef, isJsonParamCell, isListSetOperation, isSetOperation, isSqlDefaultCell, isStepColumnRef, jsonParamCell, returningColumnName, stepColumnRef, } from "./ast.ts";
43
- export type { AdvisoryLockFunctions, AdvisoryLockModeFunctions, RowLockSyntax, SqlDialect, } from "./dialect.ts";
45
+ export type { AdvisoryLockFunctions, AdvisoryLockModeFunctions, RowLockSyntax, EmptyInsertSyntax, SqlDialect, } from "./dialect.ts";
44
46
  export { ADVISORY_KEY_BOUNDS, describeRowLock, renderAdvisoryLock, renderRowLockClause } from "./locks.ts";
45
47
  export { JSON_TRANSPORT, projectionOutputName } from "./json-transport.ts";
46
48
  export { postgresDialect } from "./dialects/postgres.ts";
@@ -48,10 +50,21 @@ export { sqliteDialect } from "./dialects/sqlite.ts";
48
50
  export { mysqlDialect } from "./dialects/mysql.ts";
49
51
  export { SQL_DIALECTS, getSqlDialect } from "./dialects/registry.ts";
50
52
  export { tableDefinitionParts } from "./dialects/sqlite-table-definition.ts";
51
- export { renderPredicate } from "./predicate.ts";
53
+ export { keyListBindsUntypedRows, postgresBulkInsertArrayCastOf, postgresKeyListElementTypeOf } from "./key-list.ts";
54
+ export { renderPredicate, renderSchemaExpression } from "./predicate.ts";
55
+ export { renderLocalDateCheck } from "./local-date.ts";
56
+ export { renderGeneratedColumnClause } from "./generated-columns.ts";
57
+ export type { GeneratedColumnDeclaration, ExtractedGeneratedColumn } from "./generated-columns.ts";
58
+ export { renderPostgresGeneratedColumnProbe, renderPostgresDropGeneratedExpression } from "./dialects/postgres-generated-columns.ts";
59
+ export type { PostgresGeneratedColumnProbe } from "./dialects/postgres-generated-columns.ts";
60
+ export { renderMysqlGeneratedColumnProbe, extractMysqlGeneratedColumn } from "./dialects/mysql-generated-columns.ts";
61
+ export type { MysqlGeneratedColumnProbe } from "./dialects/mysql-generated-columns.ts";
62
+ export { extractSqliteGeneratedColumn } from "./dialects/sqlite-generated-columns.ts";
63
+ export { renderRowRule } from "./row-rules.ts";
64
+ export type { RenderedRowRule, RowRuleStatement, RowRuleTriggerPlacement } from "./row-rules.ts";
52
65
  export type { PredicateModel, PredicateUsage } from "./predicate.ts";
53
66
  export { DIALECT_CAPABILITIES, MYSQL_CAPABILITIES, POSTGRES_CAPABILITIES, SQLITE_CAPABILITIES, } from "./capabilities.ts";
54
- export { DIALECT_CODECS, MYSQL_CODECS, POSTGRES_CODECS, SQLITE_CODECS, decodeIsNoop, enumMembershipCodec, float32Codec, parseDateTimeText, parseJsonText, postgresArrayElementFromText, shortestFloat32, timeOfDayCodec, } from "./codecs.ts";
67
+ export { DIALECT_CODECS, MYSQL_CODECS, POSTGRES_CODECS, SQLITE_CODECS, decodeIsNoop, enumMembershipCodec, float32Codec, localDateCodec, parseDateTimeText, parseJsonText, postgresArrayElementFromText, shortestFloat32, timeOfDayCodec, } from "./codecs.ts";
55
68
  export type { CodecTable, ScalarCodec, WireFidelity } from "./codecs.ts";
56
69
  export { renderExpr, renderFragment, renderProjection, renderStatement } from "./render.ts";
57
70
  export type { RenderedQuery } from "./render.ts";
@@ -59,7 +72,7 @@ export { snapshotSqlValue } from "./parameter-snapshot.ts";
59
72
  export { ParamCollector } from "./params.ts";
60
73
  export { NATIVE_RLS, renderRlsColumnType, renderRlsContext, renderRlsDisable, renderRlsDropPolicy, renderRlsEnable, renderRlsForce, renderRlsNoForce, renderRlsPolicy, renderRlsPredicate, renderRlsRole } from "./dialects/postgres-rls.ts";
61
74
  export type { RlsContextStatement, RlsDisableStatement, RlsDropPolicyStatement, RlsEnableStatement, RlsForceStatement, RlsNoForceStatement, RlsPolicyStatement, RlsRoleStatement } from "./ast.ts";
62
- export { containsPattern, endsWithPattern, escapeGlobPattern, escapeLikePattern, startsWithPattern, strictMatchPattern } from "./like.ts";
75
+ export { containsPattern, endsWithPattern, escapeGlobPattern, escapeLikePattern, startsWithPattern, strictMatchCollationPrefilter, strictMatchPattern } from "./like.ts";
63
76
  export { RLS_READINESS_SQL, NATIVE_RLS_PROBE_POLICY, renderRlsReadinessQuery, renderRlsProbeTable, renderRlsPolicyPath } from "./dialects/postgres-rls-readiness.ts";
64
77
  export type { RlsReadinessQuery } from "./dialects/postgres-rls-readiness.ts";
65
78
  export { isFixedDiagnostic, renderDiagnostic } from "./dialects/diagnostics.ts";