@dbsp/types 3.4.0 → 5.0.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/dist/{adapter-CjwnHeg4.d.ts → adapter-DXjfHEAf.d.ts} +110 -34
- package/dist/adapter-sdk.d.ts +1 -1
- package/dist/{chunk-SEWKTHUK.js → chunk-X5OQYLAK.js} +260 -2
- package/dist/chunk-X5OQYLAK.js.map +1 -0
- package/dist/index.d.ts +811 -26
- package/dist/index.js +23 -1
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +23 -1
- package/dist/internal.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-SEWKTHUK.js.map +0 -1
|
@@ -202,6 +202,10 @@ interface ColumnIR {
|
|
|
202
202
|
* Foreign key constraint
|
|
203
203
|
*/
|
|
204
204
|
interface ForeignKeyIR {
|
|
205
|
+
/** Physical PostgreSQL constraint name when the model has been physicalized. */
|
|
206
|
+
readonly name?: string;
|
|
207
|
+
/** Physical PostgreSQL name of the automatic single-column FK index. */
|
|
208
|
+
readonly autoIndexName?: string;
|
|
205
209
|
/** Local columns that form the FK */
|
|
206
210
|
readonly columns: readonly string[];
|
|
207
211
|
/** Referenced table and columns; schema is the referenced table's schema and defaults to the FK's own/migration schema when absent */
|
|
@@ -231,21 +235,29 @@ interface ForeignKeyIR {
|
|
|
231
235
|
interface SequenceIR {
|
|
232
236
|
/** Sequence name */
|
|
233
237
|
readonly name: string;
|
|
238
|
+
/** Explicitly bring this existing standalone sequence under managed state. Adoption is never inferred. */
|
|
239
|
+
readonly adopt?: true;
|
|
234
240
|
/** Start value */
|
|
235
|
-
readonly startWith?: number;
|
|
241
|
+
readonly startWith?: number | string;
|
|
236
242
|
/** Increment step */
|
|
237
|
-
readonly incrementBy?: number;
|
|
243
|
+
readonly incrementBy?: number | string;
|
|
238
244
|
/** Minimum value */
|
|
239
|
-
readonly minValue?: number;
|
|
245
|
+
readonly minValue?: number | string;
|
|
240
246
|
/** Maximum value */
|
|
241
|
-
readonly maxValue?: number;
|
|
247
|
+
readonly maxValue?: number | string;
|
|
242
248
|
/** Whether to cycle */
|
|
243
249
|
readonly cycle?: boolean;
|
|
244
250
|
/** Schema name (if not default) */
|
|
245
251
|
readonly schema?: string;
|
|
246
252
|
}
|
|
247
253
|
interface EnumIR {
|
|
248
|
-
/**
|
|
254
|
+
/**
|
|
255
|
+
* Raw PostgreSQL catalog type name (`pg_type.typname`): no identifier
|
|
256
|
+
* quotes, schema, modifiers or array suffix. It is physical: `dbCasing`
|
|
257
|
+
* never maps it. A column refers to it through the rendered spelling in
|
|
258
|
+
* `originalDbType` (`status`, `"Status"`, `status[]`), with the schema in
|
|
259
|
+
* `originalDbTypeSchema`. Its `ModelIR.enums` key must be this same string.
|
|
260
|
+
*/
|
|
249
261
|
readonly name: string;
|
|
250
262
|
/** Ordered list of enum values */
|
|
251
263
|
readonly values: readonly string[];
|
|
@@ -254,6 +266,7 @@ interface EnumIR {
|
|
|
254
266
|
}
|
|
255
267
|
interface RequiredEnumLabelIR {
|
|
256
268
|
readonly schema?: string;
|
|
269
|
+
/** Physical enum type name, as in `EnumIR.name`; `dbCasing` never maps it. */
|
|
257
270
|
readonly type: string;
|
|
258
271
|
readonly label: string;
|
|
259
272
|
}
|
|
@@ -327,7 +340,12 @@ interface IndexIR {
|
|
|
327
340
|
readonly nullsNotDistinct?: boolean;
|
|
328
341
|
/** Index access method (default: btree) */
|
|
329
342
|
readonly method?: string;
|
|
330
|
-
/**
|
|
343
|
+
/**
|
|
344
|
+
* Partial index predicate (WHERE clause). The model representation has one
|
|
345
|
+
* absence value: `undefined`. Every present string, including an empty or
|
|
346
|
+
* whitespace-only string, is an authored `WHERE` clause and must reach
|
|
347
|
+
* PostgreSQL.
|
|
348
|
+
*/
|
|
331
349
|
readonly where?: string;
|
|
332
350
|
/** Expression-based index entries (used instead of/alongside columns) */
|
|
333
351
|
readonly expressions?: readonly string[];
|
|
@@ -344,12 +362,27 @@ interface IndexIR {
|
|
|
344
362
|
interface TableIR {
|
|
345
363
|
/** Table name in database */
|
|
346
364
|
readonly name: string;
|
|
365
|
+
/**
|
|
366
|
+
* An explicit address change for this table. The desired table remains
|
|
367
|
+
* identified by `name`; `from` and `to` make the otherwise ambiguous
|
|
368
|
+
* rename/schema move an authored transition rather than inferred drift.
|
|
369
|
+
*/
|
|
370
|
+
readonly readdress?: TableReaddressDeclaration;
|
|
371
|
+
/**
|
|
372
|
+
* Declare that this named, pre-existing table is to enter managed state.
|
|
373
|
+
* Existing objects are otherwise drift; adoption is never inferred.
|
|
374
|
+
*/
|
|
375
|
+
readonly adopt?: true;
|
|
376
|
+
/** Request a reviewed retire-and-create replacement of this unchanged table. */
|
|
377
|
+
readonly replace?: true;
|
|
347
378
|
/** Stable logical identity, when attached by an engine-neutral carrier. */
|
|
348
379
|
readonly logicalIdentity?: LogicalIdentity;
|
|
349
380
|
/** Column definitions */
|
|
350
381
|
readonly columns: readonly ColumnIR[];
|
|
351
382
|
/** Primary key (single column or composite); omitted for junction tables without explicit PK */
|
|
352
383
|
readonly primaryKey?: string | readonly string[];
|
|
384
|
+
/** Physical PostgreSQL primary-key constraint name when known. */
|
|
385
|
+
readonly primaryKeyName?: string;
|
|
353
386
|
/** Foreign key constraints */
|
|
354
387
|
readonly foreignKeys: readonly ForeignKeyIR[];
|
|
355
388
|
/** Index definitions */
|
|
@@ -371,6 +404,20 @@ interface TableIR {
|
|
|
371
404
|
/** Row-Level Security policies */
|
|
372
405
|
readonly policies?: readonly PolicyIR[];
|
|
373
406
|
}
|
|
407
|
+
/** One endpoint of an authored table re-addressing declaration. */
|
|
408
|
+
interface TableReaddressAddress {
|
|
409
|
+
readonly name: string;
|
|
410
|
+
readonly schema?: string;
|
|
411
|
+
/** Deliberately carried through so the command can refuse the named kind. */
|
|
412
|
+
readonly kind?: string;
|
|
413
|
+
/** Deliberately carried through so the command can refuse cross-database moves. */
|
|
414
|
+
readonly database?: string;
|
|
415
|
+
}
|
|
416
|
+
/** A declared rename or schema move; execution currently supports tables only. */
|
|
417
|
+
interface TableReaddressDeclaration {
|
|
418
|
+
readonly from: TableReaddressAddress;
|
|
419
|
+
readonly to: TableReaddressAddress;
|
|
420
|
+
}
|
|
374
421
|
/**
|
|
375
422
|
* Relation definition with planning metadata
|
|
376
423
|
*/
|
|
@@ -449,7 +496,10 @@ interface ModelIR {
|
|
|
449
496
|
readonly externalTables?: ReadonlySet<string>;
|
|
450
497
|
/** Relation definitions indexed by "source.name" */
|
|
451
498
|
readonly relations: ReadonlyMap<string, RelationIR>;
|
|
452
|
-
/**
|
|
499
|
+
/**
|
|
500
|
+
* ENUM type definitions keyed by `EnumIR.name`, the physical type name. A key
|
|
501
|
+
* that differs from its value's `name` is refused wherever enums are handled.
|
|
502
|
+
*/
|
|
453
503
|
readonly enums?: ReadonlyMap<string, EnumIR>;
|
|
454
504
|
/** Extension names to ensure (CREATE EXTENSION IF NOT EXISTS) */
|
|
455
505
|
readonly extensions?: readonly string[];
|
|
@@ -1077,13 +1127,19 @@ interface WhereJsonExistsIntent {
|
|
|
1077
1127
|
readonly field: string;
|
|
1078
1128
|
readonly key: string | ParamIntent;
|
|
1079
1129
|
}
|
|
1080
|
-
/** WHERE clause using a custom expression
|
|
1081
|
-
|
|
1130
|
+
/** WHERE clause using a custom expression, optionally compared to a value. */
|
|
1131
|
+
type WhereExpressionIntent = {
|
|
1082
1132
|
readonly kind: 'expression';
|
|
1083
1133
|
readonly expr: ExpressionIntent;
|
|
1084
1134
|
readonly operator: ComparisonOperator;
|
|
1085
1135
|
readonly value: unknown;
|
|
1086
|
-
}
|
|
1136
|
+
} | {
|
|
1137
|
+
readonly kind: 'expression';
|
|
1138
|
+
readonly expr: StandaloneWhereExpressionIntent;
|
|
1139
|
+
/** A standalone expression that is already a SQL predicate. */
|
|
1140
|
+
readonly operator?: never;
|
|
1141
|
+
readonly value?: never;
|
|
1142
|
+
};
|
|
1087
1143
|
/**
|
|
1088
1144
|
* Where intent - filter conditions union type
|
|
1089
1145
|
* Discriminated union using 'kind' field
|
|
@@ -1233,11 +1289,20 @@ interface ColumnAliasIntent {
|
|
|
1233
1289
|
}
|
|
1234
1290
|
/**
|
|
1235
1291
|
* Relation column expression: select a column from a related table
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1292
|
+
* The query must already emit the named relation's JOIN, through `.join()` or
|
|
1293
|
+
* an include with an explicit outer join. Without one, compilation reports
|
|
1294
|
+
* `relation column "<relation>"."<column>" has no emitted alias in this query`.
|
|
1295
|
+
* A bare include aggregates the relation instead, and the column lands inside
|
|
1296
|
+
* `<relation>_json` rather than under its own alias (#793).
|
|
1297
|
+
* @example orm.select('products').join('category').columns([
|
|
1298
|
+
* relationColumn('category', 'name', 'categoryName'),
|
|
1299
|
+
* ])
|
|
1300
|
+
* @example orm.select('products').include('category', { join: 'left' }).columns([
|
|
1301
|
+
* relationColumn('category', 'name', 'categoryName'),
|
|
1302
|
+
* ])
|
|
1303
|
+
*
|
|
1304
|
+
* Deriving a join would choose join type, null behavior, and row multiplication
|
|
1305
|
+
* on the caller's behalf; that is a separate feature.
|
|
1241
1306
|
*/
|
|
1242
1307
|
interface RelationColumnIntent {
|
|
1243
1308
|
readonly kind: 'relationColumn';
|
|
@@ -1427,6 +1492,14 @@ interface JsonPathExtractIntent {
|
|
|
1427
1492
|
readonly mode: 'json' | 'text';
|
|
1428
1493
|
readonly as?: string | undefined;
|
|
1429
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Operators whose result is a SQL predicate.
|
|
1497
|
+
*
|
|
1498
|
+
* This is deliberately closed: `op()` only brands these literal operators as
|
|
1499
|
+
* predicates. Arbitrary operator strings remain ordinary expressions unless a
|
|
1500
|
+
* caller explicitly opts into `unsafeAsPredicate()`.
|
|
1501
|
+
*/
|
|
1502
|
+
type PredicateOperator = '=' | '!=' | '<>' | '<' | '<=' | '>' | '>=' | 'AND' | 'OR' | 'NOT' | '@@' | '@@@' | '&&' | '<@' | '@>';
|
|
1430
1503
|
/** Custom binary operator expression (e.g., <=> for pgvector) */
|
|
1431
1504
|
interface CustomOpExpressionIntent {
|
|
1432
1505
|
readonly kind: 'customOp';
|
|
@@ -1514,6 +1587,14 @@ interface UnaryExpressionIntent {
|
|
|
1514
1587
|
* Extensible for future expression types
|
|
1515
1588
|
*/
|
|
1516
1589
|
type ExpressionIntent = ColumnExpressionIntent | CoalesceExpressionIntent | RawExpressionIntent | ColumnAliasIntent | RelationColumnIntent | WindowIntent | AggregateExpressionIntent | PseudoColumnExpressionIntent | FunctionExpressionIntent | SubqueryExpressionIntent | ArithmeticExpressionIntent | LiteralExpressionIntent | ComparisonExpressionIntent | CaseExpressionIntent | JsonExtractIntent | JsonContainsIntent | JsonExistsIntent | JsonPathExtractIntent | CustomOpExpressionIntent | CustomFnExpressionIntent | RefExpressionIntent | ParamExpressionIntent | CastExpressionIntent | UnaryExpressionIntent | NamedArgExpressionIntent | StarExpressionIntent | ArrayExpressionIntent;
|
|
1590
|
+
/**
|
|
1591
|
+
* Expression intents that the standalone `WHERE` expression compiler accepts.
|
|
1592
|
+
*
|
|
1593
|
+
* This deliberately excludes SELECT-only and planner-only expression kinds.
|
|
1594
|
+
* A standalone expression is used only when a local predicate wrapper derives
|
|
1595
|
+
* `{ kind: 'expression', expr }` for `WHERE`.
|
|
1596
|
+
*/
|
|
1597
|
+
type StandaloneWhereExpressionIntent = CustomOpExpressionIntent | CustomFnExpressionIntent | RefExpressionIntent | ParamExpressionIntent | CastExpressionIntent | LiteralExpressionIntent | UnaryExpressionIntent | NamedArgExpressionIntent | StarExpressionIntent | ArrayExpressionIntent | SubqueryExpressionIntent | RelationColumnIntent | CaseExpressionIntent;
|
|
1517
1598
|
/**
|
|
1518
1599
|
* Window function types for OVER clause analytics.
|
|
1519
1600
|
* - Ranking: row_number, rank, dense_rank (no field required)
|
|
@@ -2550,6 +2631,8 @@ type OutputReadHandling = {
|
|
|
2550
2631
|
readonly table: string;
|
|
2551
2632
|
readonly column: string;
|
|
2552
2633
|
readonly js: ColumnJsReadType;
|
|
2634
|
+
/** Emitted nested JSON key; absent metadata keeps legacy column lookup. */
|
|
2635
|
+
readonly outputKey?: string;
|
|
2553
2636
|
} | {
|
|
2554
2637
|
readonly kind: 'none';
|
|
2555
2638
|
};
|
|
@@ -3124,6 +3207,12 @@ interface BaseAdapter {
|
|
|
3124
3207
|
* their actionable refusal before any capability preflight.
|
|
3125
3208
|
*/
|
|
3126
3209
|
readonly connectionAvailability?: ConnectionAvailability;
|
|
3210
|
+
/**
|
|
3211
|
+
* Optional side-effect-free execution availability check.
|
|
3212
|
+
*
|
|
3213
|
+
* When present, core uses this instead of probing a raw connection handle.
|
|
3214
|
+
*/
|
|
3215
|
+
executionAvailable?(): boolean;
|
|
3127
3216
|
/**
|
|
3128
3217
|
* Whether this adapter instance is scoped inside a transaction.
|
|
3129
3218
|
* Compile-only adapters and adapters without an active transaction report false.
|
|
@@ -3183,8 +3272,8 @@ interface ExecutingAdapter extends BaseAdapter {
|
|
|
3183
3272
|
/** Execute a query and return all results. */
|
|
3184
3273
|
execute<T>(query: CompiledQuery<T>): Promise<T[]>;
|
|
3185
3274
|
/** Execute a compiled query and return the rows plus result metadata, when the adapter supports it. */
|
|
3186
|
-
executeWithMeta
|
|
3187
|
-
readonly rows:
|
|
3275
|
+
executeWithMeta?(query: CompiledQuery): Promise<{
|
|
3276
|
+
readonly rows: readonly unknown[];
|
|
3188
3277
|
readonly rowCount: number;
|
|
3189
3278
|
readonly command?: string;
|
|
3190
3279
|
}>;
|
|
@@ -3308,7 +3397,7 @@ interface RawSqlAdapter extends BaseAdapter {
|
|
|
3308
3397
|
/**
|
|
3309
3398
|
* PostgreSQL index access method.
|
|
3310
3399
|
*/
|
|
3311
|
-
type IndexMethod = 'btree' | 'hash' | 'gist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat' | 'bm25';
|
|
3400
|
+
type IndexMethod = 'btree' | 'hash' | 'gist' | 'gin' | 'brin' | 'spgist' | 'bloom' | 'hnsw' | 'ivfflat' | 'bm25';
|
|
3312
3401
|
/** A column reference in an index: either a column name or an expression. */
|
|
3313
3402
|
type IndexColumnDef = string | {
|
|
3314
3403
|
expression: string;
|
|
@@ -3402,25 +3491,12 @@ interface TableDDLGeneratorAdapter {
|
|
|
3402
3491
|
*/
|
|
3403
3492
|
storageSize?(table: string, schema?: string): Promise<number>;
|
|
3404
3493
|
}
|
|
3405
|
-
/**
|
|
3406
|
-
* DDL-generating adapter - can generate DDL (CREATE TABLE statements) from a schema.
|
|
3407
|
-
*/
|
|
3408
|
-
interface DDLGeneratingAdapter extends BaseAdapter {
|
|
3409
|
-
/**
|
|
3410
|
-
* Generate DDL statements from a schema.
|
|
3411
|
-
*
|
|
3412
|
-
* @param schema - The ModelIR schema to generate DDL from
|
|
3413
|
-
* @param options - Optional adapter-specific options (e.g., includeDropStatements)
|
|
3414
|
-
* @returns Array of DDL statements (CREATE TABLE, CREATE INDEX, etc.)
|
|
3415
|
-
*/
|
|
3416
|
-
generateDDL(schema: ModelIR, options?: Record<string, unknown>): string[];
|
|
3417
|
-
}
|
|
3418
3494
|
/**
|
|
3419
3495
|
* Database adapter interface - full adapter with all capabilities.
|
|
3420
3496
|
*
|
|
3421
3497
|
* @typeParam DB - Database schema type for type inference
|
|
3422
3498
|
*/
|
|
3423
|
-
interface Adapter<DB = unknown> extends CompilingAdapter, ExecutingAdapter, StreamingAdapter, IntrospectingAdapter, TransactionalAdapter<DB>, RawSqlAdapter,
|
|
3499
|
+
interface Adapter<DB = unknown> extends CompilingAdapter, ExecutingAdapter, StreamingAdapter, IntrospectingAdapter, TransactionalAdapter<DB>, RawSqlAdapter, TableDDLGeneratorAdapter {
|
|
3424
3500
|
/**
|
|
3425
3501
|
* Naming convention used by this adapter.
|
|
3426
3502
|
*
|
|
@@ -3439,7 +3515,7 @@ interface Adapter<DB = unknown> extends CompilingAdapter, ExecutingAdapter, Stre
|
|
|
3439
3515
|
* @deprecated Existing `CompileOnlyAdapter` annotations remain valid. Use
|
|
3440
3516
|
* `Adapter` when direct execution calls are needed.
|
|
3441
3517
|
*/
|
|
3442
|
-
type CompileOnlyAdapter<DB = unknown> = CompilingAdapter &
|
|
3518
|
+
type CompileOnlyAdapter<DB = unknown> = CompilingAdapter & TableDDLGeneratorAdapter & {
|
|
3443
3519
|
/** Naming convention used by this adapter. */
|
|
3444
3520
|
readonly dbCasing: DbCasing;
|
|
3445
3521
|
/** Create a schema-scoped compile-only adapter. */
|
|
@@ -3521,4 +3597,4 @@ interface TranslationContext {
|
|
|
3521
3597
|
readonly dialectCapabilities: DialectCapabilities;
|
|
3522
3598
|
}
|
|
3523
3599
|
|
|
3524
|
-
export { type CustomOpExpressionIntent as $, type Adapter as A, type BaseAdapter as B, type CompiledQuery as C, type CastExpressionIntent as D, type CheckConstraintIR as E, type CoalesceExpressionIntent as F, type ColumnAliasIntent as G, type ColumnExpressionIntent as H, type ColumnIR as I, type ColumnJsReadType as J, type ColumnListInput as K, type ColumnType as L, type CommonColumnType as M, type NqlBindingRelationType as N, type ComparisonExpressionIntent as O, type PlanReport as P, type ComparisonOperator as Q, type CompileOnlyAdapter as R, type CompileOptions as S, type CompileOptionsBase as T, type CompileResultWithIncludes as U, type CompiledNqlQuery as V, type CompilingAdapter as W, type ConnectionAvailability as X, type CreateIndexOptions as Y, type CteQueryIntent as Z, type CustomFnExpressionIntent as _, type CompiledColumnMetadata as a, type
|
|
3600
|
+
export { type CustomOpExpressionIntent as $, type Adapter as A, type BaseAdapter as B, type CompiledQuery as C, type CastExpressionIntent as D, type CheckConstraintIR as E, type CoalesceExpressionIntent as F, type ColumnAliasIntent as G, type ColumnExpressionIntent as H, type ColumnIR as I, type ColumnJsReadType as J, type ColumnListInput as K, type ColumnType as L, type CommonColumnType as M, type NqlBindingRelationType as N, type ComparisonExpressionIntent as O, type PlanReport as P, type ComparisonOperator as Q, type CompileOnlyAdapter as R, type CompileOptions as S, type CompileOptionsBase as T, type CompileResultWithIncludes as U, type CompiledNqlQuery as V, type CompilingAdapter as W, type ConnectionAvailability as X, type CreateIndexOptions as Y, type CteQueryIntent as Z, type CustomFnExpressionIntent as _, type CompiledColumnMetadata as a, type NqlBindingColumnTypeInfo as a$, type CustomTraversal as a0, type DDLFeature as a1, type DDLFeatureElementMap as a2, type DDLFeatureVersionRange as a3, type DbCasing as a4, type DecisionType as a5, type DeleteIntent as a6, type DialectCapabilities as a7, type DialectName as a8, type DiffSummary as a9, type InsertIntent as aA, type IntrospectingAdapter as aB, type IntrospectionOptions as aC, type IntrospectionResult as aD, type IsTypeSupported as aE, type JoinDefault as aF, type JoinIntent as aG, type JsonAggOrderByEntry as aH, type JsonContainsIntent as aI, type JsonExistsIntent as aJ, type JsonExtractIntent as aK, type JsonPathExtractIntent as aL, type LiteralExpressionIntent as aM, type LockIntent as aN, type LockStrength as aO, type LockWaitPolicy as aP, type LogicalIdentity as aQ, type LogicalIdentityCarrier as aR, type LogicalOperator as aS, type MSSQLColumnType as aT, type ModelIR as aU, type MutationIntent as aV, type MutationReturningItem as aW, type MySQLColumnType as aX, type NamedArgExpressionIntent as aY, type NestedOutputReadHandling as aZ, type NqlBindingColumnLineage as a_, type DropIndexOptions as aa, type DuckDBColumnType as ab, type Dump as ac, type DumpMeta as ad, type DumpSequenceStep as ae, type EdgeTableTraversal as af, type EmitJoinClause as ag, type EnumIR as ah, type ExecutingAdapter as ai, type ExpressionIntent as aj, type FeatureBehaviorConfig as ak, type FeatureTranslator as al, type FeatureWarning as am, type FieldRef as an, type FilterStrategy as ao, type ForeignKeyIR as ap, type FunctionExpressionIntent as aq, type HierarchyIR as ar, type IncludeIntent as as, type IncludeRecursiveOptions as at, type IncludeStrategy as au, type IndexColumnDef as av, type IndexIR as aw, type IndexInfo as ax, type IndexMethod as ay, type InsertFromIntent as az, type AdapterCapabilities as b, type RelationType as b$, type NqlBindingColumnUntypeableReason as b0, type NqlBindingOutputSchema as b1, type NqlBindingRelationFilterMetadata as b2, type NqlBindingVirtualRelation as b3, type NqlBindingVirtualRelationHop as b4, type NqlBindingVirtualRelationRecursive as b5, type NqlProgramSequenceStep as b6, type NqlRuntimeBinding as b7, type NullOperator as b8, type NullsPosition as b9, type PseudoColumnTraversal as bA, type QueryIntent as bB, type RangeOperand as bC, type RangeOperator as bD, type RangeValue as bE, type RankingWindowFunction as bF, type RankingWindowIntent as bG, type RawCteIntent as bH, type RawExpressionIntent as bI, type RawSqlAdapter as bJ, type RecursiveAdvancedOptions as bK, type RecursiveDedupe as bL, type RecursiveDirection as bM, type RecursiveEmitOptions as bN, type RecursiveExistsOptions as bO, type RecursiveIntent as bP, type RecursiveMetadata as bQ, type RecursiveNodeIdExpr as bR, type RecursivePlanOptions as bS, type RecursivePlanReport as bT, type RecursiveTrackOptions as bU, type RecursiveTraversal as bV, type RefExpressionIntent as bW, type RelationColumnIntent as bX, type RelationIR as bY, type RelationKind as bZ, type RelationOperator as b_, type OffsetWindowFunction as ba, type OffsetWindowIntent as bb, type OnDeleteAction as bc, type OperationKindRef as bd, type Optionality as be, type OrderByExpressionIntent as bf, type OrderByFieldIntent as bg, type OrderByIntent as bh, type OutputDescriptor as bi, type OutputReadHandling as bj, type OutputSource as bk, type OutputValueShape as bl, type ParamExpressionIntent as bm, type ParamIntent as bn, type PartitionIR as bo, type PinnedConnectionOptions as bp, type PlanDecision as bq, type PlanOptions as br, type PlanWarning as bs, type PlanWarningCode as bt, type PolicyIR as bu, type PostgresColumnType as bv, type PostgresOnlyColumnType as bw, type PredicateOperator as bx, type PseudoColumnExpressionIntent as by, type PseudoColumnMetadata as bz, type AdapterLogger as c, type WhereRelationFilterIntent as c$, type RequiredEnumLabelIR as c0, type ResolvedIncludeStrategy as c1, type SQLiteColumnType as c2, type SchemaChange as c3, type SchemaDiff as c4, type SelectAggregateIntent as c5, type SelectAllIntent as c6, type SelectFieldsIntent as c7, type SelectIntent as c8, type SelectWithExpressionsIntent as c9, type UnnestCteIntent as cA, type UnsupportedFeatureBehavior as cB, type UpdateIntent as cC, type UpsertConflictAction as cD, type UpsertConflictTarget as cE, type UpsertFromIntent as cF, type UpsertIntent as cG, type VacuumOptions as cH, type WhereAndIntent as cI, type WhereAnyIntent as cJ, type WhereComparisonIntent as cK, type WhereExistsIntent as cL, type WhereExpressionIntent as cM, type WhereInIntent as cN, type WhereInSubqueryIntent as cO, type WhereInValueIntent as cP, type WhereIntent as cQ, type WhereJsonContainsIntent as cR, type WhereJsonExistsIntent as cS, type WhereLikeIntent as cT, type WhereNotExistsIntent as cU, type WhereNotIntent as cV, type WhereNullIntent as cW, type WhereOrIntent as cX, type WhereRangeIntent as cY, type WhereRawExistsIntent as cZ, type WhereRawNotExistsIntent as c_, type SemanticArtifactId as ca, type SemanticArtifactRef as cb, type SequenceIR as cc, type SetOperationIntent as cd, type SetOperationType as ce, type SimpleCteIntent as cf, type SortDirection as cg, type StandaloneWhereExpressionIntent as ch, type StarExpressionIntent as ci, type StreamingAdapter as cj, type StringOperator as ck, type SubqueryExpressionIntent as cl, type SubqueryIncludeInfo as cm, type SubqueryRefIntent as cn, type SupportedColumnTypes as co, type TableDDLGeneratorAdapter as cp, type TableIR as cq, type TableReaddressAddress as cr, type TableReaddressDeclaration as cs, type TransactionBeginOptions as ct, type TransactionOptions as cu, type TransactionalAdapter as cv, type TranslationContext as cw, type TruncateOptions as cx, type TrustRoot as cy, type UnaryExpressionIntent as cz, type AdapterStreamOptions as d, type WhereSubqueryIntent as d0, type WindowFunction as d1, type WindowIntent as d2, type WindowOrderBy as d3, getNodeIdAlias as d4, isFieldRef as d5, isParamIntent as d6, resolveOutputReadHandling as d7, toColumnList as d8, type AdjacencyTraversal as e, type AggOrderByArg as f, type AggregateCountIntent as g, type AggregateExpressionIntent as h, type AggregateFieldIntent as i, type AggregateFunction as j, type AggregateIntent as k, type AggregateWindowFunction as l, type AggregateWindowIntent as m, type AliasIncludedColumnsMode as n, type AlterColumnOptions as o, type AmbiguityCheckResult as p, type ArithmeticExpressionIntent as q, type ArrayExpressionIntent as r, type ArrayOperator as s, type AuthorAttestedNativeDefault as t, type AuthorAttester as u, type BatchUpdateIntent as v, type BatchValuesJoinPayload as w, type CTEDefinition as x, type Cardinality as y, type CaseExpressionIntent as z };
|
package/dist/adapter-sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CompiledQuery, a as CompiledColumnMetadata, P as PlanReport } from './adapter-
|
|
1
|
+
import { C as CompiledQuery, a as CompiledColumnMetadata, P as PlanReport } from './adapter-DXjfHEAf.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Stable SPI for implementing the `Adapter` port. Only stable helpers required to construct/validate a
|
|
@@ -334,6 +334,108 @@ function resolveOutputReadHandling(descriptor) {
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
// src/physical-name-inventory.ts
|
|
338
|
+
var PhysicalNameInventoryDuplicateError = class extends Error {
|
|
339
|
+
constructor(scope, first, second) {
|
|
340
|
+
super(
|
|
341
|
+
`Duplicate physical-name inventory ${scope}: "${first.physical}" is claimed by ${addressText(first.logical)} and ${addressText(second.logical)}.`
|
|
342
|
+
);
|
|
343
|
+
this.scope = scope;
|
|
344
|
+
this.first = first;
|
|
345
|
+
this.second = second;
|
|
346
|
+
this.name = "PhysicalNameInventoryDuplicateError";
|
|
347
|
+
}
|
|
348
|
+
scope;
|
|
349
|
+
first;
|
|
350
|
+
second;
|
|
351
|
+
};
|
|
352
|
+
function createPhysicalNameInventory(entries) {
|
|
353
|
+
const byAddress = /* @__PURE__ */ new Map();
|
|
354
|
+
const tables = /* @__PURE__ */ new Map();
|
|
355
|
+
const columns = /* @__PURE__ */ new Map();
|
|
356
|
+
const copied = entries.map(
|
|
357
|
+
(entry) => Object.freeze({
|
|
358
|
+
logical: Object.freeze({ ...entry.logical }),
|
|
359
|
+
physical: entry.physical,
|
|
360
|
+
...entry.sequenceProvenance === void 0 ? {} : { sequenceProvenance: entry.sequenceProvenance }
|
|
361
|
+
})
|
|
362
|
+
);
|
|
363
|
+
const physicalTables = /* @__PURE__ */ new Map();
|
|
364
|
+
for (const entry of copied) {
|
|
365
|
+
if (entry.logical.kind === "table")
|
|
366
|
+
physicalTables.set(
|
|
367
|
+
`${entry.logical.schema}\0${entry.logical.name}`,
|
|
368
|
+
entry.physical
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
for (const entry of copied) {
|
|
372
|
+
const key = addressKey(entry.logical);
|
|
373
|
+
const firstAddress = byAddress.get(key);
|
|
374
|
+
if (firstAddress)
|
|
375
|
+
throw new PhysicalNameInventoryDuplicateError(
|
|
376
|
+
"logical-address",
|
|
377
|
+
firstAddress,
|
|
378
|
+
entry
|
|
379
|
+
);
|
|
380
|
+
byAddress.set(key, entry);
|
|
381
|
+
if (entry.logical.kind === "table") {
|
|
382
|
+
const tableKey = `${entry.logical.schema}\0${entry.physical}`;
|
|
383
|
+
const firstTable = tables.get(tableKey);
|
|
384
|
+
if (firstTable)
|
|
385
|
+
throw new PhysicalNameInventoryDuplicateError(
|
|
386
|
+
"table",
|
|
387
|
+
firstTable,
|
|
388
|
+
entry
|
|
389
|
+
);
|
|
390
|
+
tables.set(tableKey, entry);
|
|
391
|
+
}
|
|
392
|
+
if (entry.logical.kind === "column") {
|
|
393
|
+
const physicalTable = physicalTables.get(
|
|
394
|
+
`${entry.logical.schema}\0${entry.logical.table}`
|
|
395
|
+
) ?? entry.logical.table;
|
|
396
|
+
const columnKey = `${entry.logical.schema}\0${physicalTable}\0${entry.physical}`;
|
|
397
|
+
const firstColumn = columns.get(columnKey);
|
|
398
|
+
if (firstColumn)
|
|
399
|
+
throw new PhysicalNameInventoryDuplicateError(
|
|
400
|
+
"column",
|
|
401
|
+
firstColumn,
|
|
402
|
+
entry
|
|
403
|
+
);
|
|
404
|
+
columns.set(columnKey, entry);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const sorted = Object.freeze(
|
|
408
|
+
[...copied].sort(
|
|
409
|
+
(left, right) => addressKey(left.logical) < addressKey(right.logical) ? -1 : addressKey(left.logical) > addressKey(right.logical) ? 1 : 0
|
|
410
|
+
)
|
|
411
|
+
);
|
|
412
|
+
return Object.freeze({
|
|
413
|
+
entries: sorted,
|
|
414
|
+
has(address) {
|
|
415
|
+
return byAddress.has(addressKey(address));
|
|
416
|
+
},
|
|
417
|
+
get(address) {
|
|
418
|
+
const entry = byAddress.get(addressKey(address));
|
|
419
|
+
if (!entry) throw new PhysicalNameInventoryMissingError(address);
|
|
420
|
+
return entry.physical;
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
var PhysicalNameInventoryMissingError = class extends Error {
|
|
425
|
+
constructor(address) {
|
|
426
|
+
super(`Physical name inventory has no entry for ${addressText(address)}.`);
|
|
427
|
+
this.address = address;
|
|
428
|
+
this.name = "PhysicalNameInventoryMissingError";
|
|
429
|
+
}
|
|
430
|
+
address;
|
|
431
|
+
};
|
|
432
|
+
function addressKey(address) {
|
|
433
|
+
return "table" in address ? `${address.kind}\0${address.schema}\0${address.table}\0${address.name}` : `${address.kind}\0${address.schema}\0${address.name}`;
|
|
434
|
+
}
|
|
435
|
+
function addressText(address) {
|
|
436
|
+
return "table" in address ? `${address.kind} ${address.schema}.${address.table}.${address.name}` : `${address.kind} ${address.schema}.${address.name}`;
|
|
437
|
+
}
|
|
438
|
+
|
|
337
439
|
// src/relation-key-fields.ts
|
|
338
440
|
var DEFAULT_REFERENCED_COLUMN = "id";
|
|
339
441
|
function columnListValue(columns, shape) {
|
|
@@ -370,6 +472,151 @@ function buildRelationKeyFields(fk, direction, options = {}) {
|
|
|
370
472
|
// src/transition/execution-contract.ts
|
|
371
473
|
var EXECUTION_CONTRACT_VERSION = 1;
|
|
372
474
|
|
|
475
|
+
// src/transition/ledger.ts
|
|
476
|
+
var LEDGER_EVENT_KINDS = [
|
|
477
|
+
"adopt-intent",
|
|
478
|
+
"adopt",
|
|
479
|
+
"intent",
|
|
480
|
+
"retire-intent",
|
|
481
|
+
"readdress-intent",
|
|
482
|
+
"refused",
|
|
483
|
+
"executing",
|
|
484
|
+
"observed",
|
|
485
|
+
"absent",
|
|
486
|
+
"indeterminate",
|
|
487
|
+
"resolved",
|
|
488
|
+
"readdressed-to",
|
|
489
|
+
"readdressed-from",
|
|
490
|
+
"released"
|
|
491
|
+
];
|
|
492
|
+
function canonicalResourceParent(address) {
|
|
493
|
+
return {
|
|
494
|
+
engine: address.engine,
|
|
495
|
+
database: address.database,
|
|
496
|
+
...address.schema === void 0 ? {} : { schema: address.schema },
|
|
497
|
+
...address.parent === void 0 || address.parent === null ? {} : { parent: canonicalResourceParent(address.parent) },
|
|
498
|
+
kind: address.kind,
|
|
499
|
+
name: address.name
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function canonicalJson(value) {
|
|
503
|
+
if (value === null) return "null";
|
|
504
|
+
if (value === void 0) return "null";
|
|
505
|
+
if (Array.isArray(value)) {
|
|
506
|
+
const entries = [];
|
|
507
|
+
for (let index = 0; index < value.length; index += 1)
|
|
508
|
+
entries.push(
|
|
509
|
+
Object.hasOwn(value, index) ? canonicalJson(value[index]) : "null"
|
|
510
|
+
);
|
|
511
|
+
return `[${entries.join(",")}]`;
|
|
512
|
+
}
|
|
513
|
+
if (typeof value === "object") {
|
|
514
|
+
const entries = Object.entries(value).filter(([, item]) => item !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonicalJson(item)}`);
|
|
515
|
+
return `{${entries.join(",")}}`;
|
|
516
|
+
}
|
|
517
|
+
return JSON.stringify(value);
|
|
518
|
+
}
|
|
519
|
+
function normalizedParent(parent) {
|
|
520
|
+
if (parent === null || parent === void 0) return null;
|
|
521
|
+
const canonical = canonicalResourceParent(parent);
|
|
522
|
+
return {
|
|
523
|
+
engine: canonical.engine,
|
|
524
|
+
database: canonical.database,
|
|
525
|
+
...canonical.schema === void 0 ? {} : { schema: canonical.schema },
|
|
526
|
+
parent: normalizedParent(canonical.parent),
|
|
527
|
+
kind: canonical.kind,
|
|
528
|
+
name: canonical.name
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function canonicalLedgerAddress(address) {
|
|
532
|
+
return {
|
|
533
|
+
scope: address.scope,
|
|
534
|
+
engine: address.engine,
|
|
535
|
+
database: address.database,
|
|
536
|
+
...address.schema === void 0 ? {} : { schema: address.schema },
|
|
537
|
+
parent: normalizedParent(address.parent),
|
|
538
|
+
kind: address.kind,
|
|
539
|
+
name: address.name
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function sameLedgerAddress(left, right) {
|
|
543
|
+
return ledgerAddressKey(left) === ledgerAddressKey(right);
|
|
544
|
+
}
|
|
545
|
+
function ledgerAddressKey(address) {
|
|
546
|
+
return canonicalJson(canonicalLedgerAddress(address));
|
|
547
|
+
}
|
|
548
|
+
function ledgerAddressParentJson(address) {
|
|
549
|
+
return canonicalJson(normalizedParent(address.parent));
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/transition/refusal.ts
|
|
553
|
+
var REFUSAL_VOCABULARY = {
|
|
554
|
+
"ERR-01": {
|
|
555
|
+
cause: "unaccepted non-transactional segment",
|
|
556
|
+
withheldAuthority: "non-transactional execution authority",
|
|
557
|
+
resolvingCommand: "dbsp apply"
|
|
558
|
+
},
|
|
559
|
+
"ERR-02": {
|
|
560
|
+
cause: "pre-existing object has no admitted adoption",
|
|
561
|
+
withheldAuthority: "creation authority over an occupied address",
|
|
562
|
+
resolvingCommand: "dbsp apply"
|
|
563
|
+
},
|
|
564
|
+
"ERR-03": {
|
|
565
|
+
cause: "managed-ledger preflight is not current",
|
|
566
|
+
withheldAuthority: "managed-ledger mutation authority",
|
|
567
|
+
resolvingCommand: "dbsp preflight --reinitialize"
|
|
568
|
+
},
|
|
569
|
+
"ERR-04": {
|
|
570
|
+
cause: "removal containment cannot be proven",
|
|
571
|
+
withheldAuthority: "destructive removal authority",
|
|
572
|
+
resolvingCommand: "dbsp apply"
|
|
573
|
+
},
|
|
574
|
+
"ERR-05": {
|
|
575
|
+
cause: "recorded identity differs from the live object",
|
|
576
|
+
withheldAuthority: "managed mutation authority",
|
|
577
|
+
resolvingCommand: "dbsp apply"
|
|
578
|
+
},
|
|
579
|
+
"ERR-06": {
|
|
580
|
+
cause: "managed-ledger lineage does not match this target",
|
|
581
|
+
withheldAuthority: "managed-ledger mutation authority",
|
|
582
|
+
resolvingCommand: "dbsp preflight --reinitialize"
|
|
583
|
+
},
|
|
584
|
+
"ERR-07": {
|
|
585
|
+
cause: "target database is read-only",
|
|
586
|
+
withheldAuthority: "database write authority",
|
|
587
|
+
resolvingCommand: "dbsp apply"
|
|
588
|
+
},
|
|
589
|
+
"ERR-08": {
|
|
590
|
+
cause: "ledger chain is malformed",
|
|
591
|
+
withheldAuthority: "managed mutation authority",
|
|
592
|
+
resolvingCommand: "dbsp inspect"
|
|
593
|
+
},
|
|
594
|
+
"ERR-09": {
|
|
595
|
+
cause: "catalogue read is unavailable",
|
|
596
|
+
withheldAuthority: "outcome classification authority",
|
|
597
|
+
resolvingCommand: "dbsp reconcile"
|
|
598
|
+
},
|
|
599
|
+
"ERR-10": {
|
|
600
|
+
cause: "recorded-plan path cannot execute a removal",
|
|
601
|
+
withheldAuthority: "recorded-plan removal execution",
|
|
602
|
+
resolvingCommand: "dbsp apply"
|
|
603
|
+
},
|
|
604
|
+
"ERR-11": {
|
|
605
|
+
cause: "recovery proved the interrupted operation had no effect",
|
|
606
|
+
withheldAuthority: "recovery execution authority",
|
|
607
|
+
resolvingCommand: "dbsp reconcile"
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
function refusalFor(code, input) {
|
|
611
|
+
void input.address;
|
|
612
|
+
return { code, ...REFUSAL_VOCABULARY[code], state: input.state };
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// src/transition/resource.ts
|
|
616
|
+
function sameControllerIdentity(recorded, current) {
|
|
617
|
+
return recorded.name === current.name && recorded.oid === current.oid;
|
|
618
|
+
}
|
|
619
|
+
|
|
373
620
|
export {
|
|
374
621
|
convertBigintJsReadValue,
|
|
375
622
|
toColumnList,
|
|
@@ -427,7 +674,18 @@ export {
|
|
|
427
674
|
resolveJsonAggOrderKey,
|
|
428
675
|
isValidSchema,
|
|
429
676
|
resolveOutputReadHandling,
|
|
677
|
+
PhysicalNameInventoryDuplicateError,
|
|
678
|
+
createPhysicalNameInventory,
|
|
679
|
+
PhysicalNameInventoryMissingError,
|
|
430
680
|
buildRelationKeyFields,
|
|
431
|
-
EXECUTION_CONTRACT_VERSION
|
|
681
|
+
EXECUTION_CONTRACT_VERSION,
|
|
682
|
+
LEDGER_EVENT_KINDS,
|
|
683
|
+
canonicalResourceParent,
|
|
684
|
+
sameLedgerAddress,
|
|
685
|
+
ledgerAddressKey,
|
|
686
|
+
ledgerAddressParentJson,
|
|
687
|
+
REFUSAL_VOCABULARY,
|
|
688
|
+
refusalFor,
|
|
689
|
+
sameControllerIdentity
|
|
432
690
|
};
|
|
433
|
-
//# sourceMappingURL=chunk-
|
|
691
|
+
//# sourceMappingURL=chunk-X5OQYLAK.js.map
|