@prisma-next/sql-runtime 0.15.0 → 0.16.0-dev.10
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/{exports-D5-Py3YP.mjs → exports-Cm5jehIz.mjs} +2 -2
- package/dist/{exports-D5-Py3YP.mjs.map → exports-Cm5jehIz.mjs.map} +1 -1
- package/dist/index.d.mts +1 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{prepared-statement-BiwAFEou.d.mts → prepared-statement-BuDdY11z.d.mts} +3 -4
- package/dist/prepared-statement-BuDdY11z.d.mts.map +1 -0
- package/dist/test/utils.d.mts +11 -8
- package/dist/test/utils.d.mts.map +1 -1
- package/dist/test/utils.mjs +20 -11
- package/dist/test/utils.mjs.map +1 -1
- package/package.json +13 -13
- package/src/sql-context.ts +1 -1
- package/dist/prepared-statement-BiwAFEou.d.mts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { A as RuntimeTelemetryEvent, B as PreparedStatement, C as SqlRuntimeTargetDescriptor, D as createSqlExecutionStack, E as createExecutionContext, F as DeclaredCodecId, G as deriveParamMetadata, I as DeclaredNullable, K as encodeParamsWithMetadata, L as ParamSpec, M as VerifyMarkerOption, N as BindSiteParams, O as MarkerReader, P as Declaration, R as ParamsFromDeclaration, S as SqlRuntimeExtensionInstance, T as TypeHelperRegistry, U as SqlMiddleware, W as SqlMiddlewareContext, _ as SqlExecutionStackWithDriver, a as RuntimeConnection, b as SqlRuntimeDriverInstance, c as RuntimeTransaction, d as withTransaction, f as ExecutionContext, g as SqlExecutionStack, h as RuntimeParameterizedCodecDescriptor, i as Runtime, j as TelemetryOutcome, k as RuntimeFamilyAdapter, l as SqlRuntimeBase, m as RuntimeMutationDefaultGenerator, n as PreparedStatementInternals, p as GeneratorStability, r as ConnectionProvider, s as RuntimeQueryable, t as PreparedStatementImpl, u as TransactionContext, v as SqlRuntimeAdapterDescriptor, w as SqlStaticContributions, x as SqlRuntimeExtensionDescriptor, y as SqlRuntimeAdapterInstance, z as PrepareCallback } from "./prepared-statement-
|
|
1
|
+
import { A as RuntimeTelemetryEvent, B as PreparedStatement, C as SqlRuntimeTargetDescriptor, D as createSqlExecutionStack, E as createExecutionContext, F as DeclaredCodecId, G as deriveParamMetadata, I as DeclaredNullable, K as encodeParamsWithMetadata, L as ParamSpec, M as VerifyMarkerOption, N as BindSiteParams, O as MarkerReader, P as Declaration, R as ParamsFromDeclaration, S as SqlRuntimeExtensionInstance, T as TypeHelperRegistry, U as SqlMiddleware, W as SqlMiddlewareContext, _ as SqlExecutionStackWithDriver, a as RuntimeConnection, b as SqlRuntimeDriverInstance, c as RuntimeTransaction, d as withTransaction, f as ExecutionContext, g as SqlExecutionStack, h as RuntimeParameterizedCodecDescriptor, i as Runtime, j as TelemetryOutcome, k as RuntimeFamilyAdapter, l as SqlRuntimeBase, m as RuntimeMutationDefaultGenerator, n as PreparedStatementInternals, p as GeneratorStability, r as ConnectionProvider, s as RuntimeQueryable, t as PreparedStatementImpl, u as TransactionContext, v as SqlRuntimeAdapterDescriptor, w as SqlStaticContributions, x as SqlRuntimeExtensionDescriptor, y as SqlRuntimeAdapterInstance, z as PrepareCallback } from "./prepared-statement-BuDdY11z.mjs";
|
|
2
2
|
import { AfterExecuteResult, RuntimeLog as Log } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
import { Adapter, AnyQueryAst, ContractCodecRegistry, LoweredStatement, MarkerReadResult } from "@prisma-next/sql-relational-core/ast";
|
|
4
4
|
import { Contract } from "@prisma-next/contract/types";
|
|
5
5
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
6
6
|
import { CodecDescriptorRegistry } from "@prisma-next/sql-relational-core/query-lane-context";
|
|
7
7
|
import { SqlExecutionPlan, SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
|
|
8
|
-
|
|
9
8
|
//#region src/codecs/ast-codec-registry.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* Build a contract-free {@link ContractCodecRegistry} that resolves codecs
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/codecs/ast-codec-registry.ts","../src/codecs/validation.ts","../src/lower-sql-plan.ts","../src/middleware/budgets.ts","../src/middleware/lints.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/codecs/ast-codec-registry.ts","../src/codecs/validation.ts","../src/lower-sql-plan.ts","../src/middleware/budgets.ts","../src/middleware/lints.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAagB,uBACd,aAAa,0BACZ;;;iBCVa,gBAAgB,UAAU,SAAS,cAAc;iBAoCjD,8BACd,UAAU,yBACV,UAAU,SAAS;iBAoBL,kCACd,UAAU,yBACV,UAAU,SAAS;;;;;;;;;;;;iBClDL,aAAa,KAC3B,SAAS,QAAQ,aAAa,SAAS,aAAa,mBACpD,UAAU,SAAS,aACnB,WAAW,aAAa,OACvB,iBAAiB;;;UCVH;WACN;WACA;WACA,YAAY;WACZ;WACA;aACE;aACA;;;iBAmEG,QAAQ,UAAU,iBAAiB;;;UCxElC;WACN;aACE;aACA;aACA;aACA;aACA;;WAEF;;;;;;;;;;;;;;;;iBA8HK,MAAM,UAAU,eAAe"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createExecutionContext, c as lints, d as extractCodecIds, f as validateCodecRegistryCompleteness, g as createAstCodecRegistry, h as encodeParamsWithMetadata, l as budgets, m as deriveParamMetadata, n as withTransaction, o as createSqlExecutionStack, p as validateContractCodecMappings, s as PreparedStatementImpl, t as SqlRuntimeBase, u as lowerSqlPlan } from "./exports-
|
|
1
|
+
import { a as createExecutionContext, c as lints, d as extractCodecIds, f as validateCodecRegistryCompleteness, g as createAstCodecRegistry, h as encodeParamsWithMetadata, l as budgets, m as deriveParamMetadata, n as withTransaction, o as createSqlExecutionStack, p as validateContractCodecMappings, s as PreparedStatementImpl, t as SqlRuntimeBase, u as lowerSqlPlan } from "./exports-Cm5jehIz.mjs";
|
|
2
2
|
export { PreparedStatementImpl, SqlRuntimeBase, budgets, createAstCodecRegistry, createExecutionContext, createSqlExecutionStack, deriveParamMetadata, encodeParamsWithMetadata, extractCodecIds, lints, lowerSqlPlan, validateCodecRegistryCompleteness, validateContractCodecMappings, withTransaction };
|
|
@@ -10,7 +10,6 @@ import { ExecutionContext, TypeHelperRegistry } from "@prisma-next/sql-relationa
|
|
|
10
10
|
import { SqlExecutionPlan, SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
|
|
11
11
|
import { CodecTypesBase, CodecValue, Expression, RawCodecInferer } from "@prisma-next/sql-relational-core/expression";
|
|
12
12
|
import { RuntimeScope } from "@prisma-next/sql-relational-core/types";
|
|
13
|
-
|
|
14
13
|
//#region src/codecs/encoding.d.ts
|
|
15
14
|
interface ParamMetadata {
|
|
16
15
|
readonly codec: CodecRef | undefined;
|
|
@@ -122,8 +121,8 @@ type DeclaredNullable<S> = S extends {
|
|
|
122
121
|
type BindSiteParams<D> = { readonly [K in keyof D]: Expression<{
|
|
123
122
|
codecId: DeclaredCodecId<D[K]>;
|
|
124
123
|
nullable: DeclaredNullable<D[K]>;
|
|
125
|
-
}
|
|
126
|
-
type ParamsFromDeclaration<D, CT extends CodecTypesBase> = { readonly [K in keyof D]: CodecValue<DeclaredCodecId<D[K]>, DeclaredNullable<D[K]>, CT
|
|
124
|
+
}>; };
|
|
125
|
+
type ParamsFromDeclaration<D, CT extends CodecTypesBase> = { readonly [K in keyof D]: CodecValue<DeclaredCodecId<D[K]>, DeclaredNullable<D[K]>, CT>; };
|
|
127
126
|
type PrepareCallback<D, Row> = (params: BindSiteParams<D>) => SqlQueryPlan<Row>;
|
|
128
127
|
interface PreparedStatement<Params, Row> {
|
|
129
128
|
readonly sql: string;
|
|
@@ -441,4 +440,4 @@ declare class PreparedStatementImpl<Params, Row> implements PreparedStatement<Pa
|
|
|
441
440
|
}
|
|
442
441
|
//#endregion
|
|
443
442
|
export { RuntimeTelemetryEvent as A, PreparedStatement as B, SqlRuntimeTargetDescriptor as C, createSqlExecutionStack as D, createExecutionContext as E, DeclaredCodecId as F, deriveParamMetadata as G, decodeRow as H, DeclaredNullable as I, encodeParamsWithMetadata as K, ParamSpec as L, VerifyMarkerOption as M, BindSiteParams as N, MarkerReader as O, Declaration as P, ParamsFromDeclaration as R, SqlRuntimeExtensionInstance as S, TypeHelperRegistry as T, SqlMiddleware as U, buildDecodeContext as V, SqlMiddlewareContext as W, SqlExecutionStackWithDriver as _, RuntimeConnection as a, SqlRuntimeDriverInstance as b, RuntimeTransaction as c, withTransaction as d, ExecutionContext as f, SqlExecutionStack as g, RuntimeParameterizedCodecDescriptor as h, Runtime as i, TelemetryOutcome as j, RuntimeFamilyAdapter as k, SqlRuntimeBase as l, RuntimeMutationDefaultGenerator as m, PreparedStatementInternals as n, RuntimeOptions as o, GeneratorStability as p, ConnectionProvider as r, RuntimeQueryable as s, PreparedStatementImpl as t, TransactionContext as u, SqlRuntimeAdapterDescriptor as v, SqlStaticContributions as w, SqlRuntimeExtensionDescriptor as x, SqlRuntimeAdapterInstance as y, PrepareCallback as z };
|
|
444
|
-
//# sourceMappingURL=prepared-statement-
|
|
443
|
+
//# sourceMappingURL=prepared-statement-BuDdY11z.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepared-statement-BuDdY11z.d.mts","names":[],"sources":["../src/codecs/encoding.ts","../src/middleware/sql-middleware.ts","../src/codecs/decoding.ts","../src/prepared/types.ts","../src/runtime-spi.ts","../src/sql-context.ts","../src/sql-runtime.ts","../src/prepared/prepared-statement.ts"],"mappings":";;;;;;;;;;;;;UAgBiB;WACN,OAAO;WACP;;iBAeK,oBAAoB,KAAK,uBAAuB;iBAuI1C,yBACpB,4BACA,mBAAmB,iBACnB,KAAK,qBACL,iBAAiB,wBAChB;;;UCl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AM,4BAA4B,uBAClC,WAAW,cACX,UAAU,wBACT,oBAAoB;EA2FjB,QAAQ,UAAU,YAAY,KAAK,KAAK,WAAW,iBAAiB,gBACxE,aAAa,GACb,UAAU,gBAAgB,GAAG,OAC5B,QAAQ,kBAAkB,sBAAsB,GAAG,KAAK;;;;;YA+CjD,gCAAgC,GAAG,KAC3C,IAAI,sBAAsB,GAAG,MAC7B,YAAY,yBACZ,WAAW,cACX,UAAU,wBACT,oBAAoB;EA2EjB,cAAc,QAAQ;UAyCpB;EAiCR,aAAa;EAIP,SAAS;UAIP;UAOM;UAkCN;;;UAyBO;EACf,cAAc,QAAQ;;iBAGF,gBAAgB,GACpC,SAAS,oBACT,KAAK,IAAI,uBAAuB,YAAY,KAC3C,QAAQ;;;UClvBM;WACN;WACA,KAAK;WACL,MAAM;WACN,gBAAgB;WAChB,eAAe;WACf,wBAAwB;;cAGtB,sBAAsB,QAAQ,gBAC9B,kBAAkB,QAAQ,MAAM;WAElC;WACA,KAAK;WACL,MAAM;WACN,gBAAgB;WAChB,eAAe;WACf,wBAAwB;cAErB,WAAW;EAUvB,QACE,QAAQ,kBACR,QAAQ,QACR,UAAU,wBACT,oBAAoB"}
|
package/dist/test/utils.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as SqlRuntimeTargetDescriptor, H as decodeRow, S as SqlRuntimeExtensionInstance, V as buildDecodeContext, b as SqlRuntimeDriverInstance, f as ExecutionContext, i as Runtime, o as RuntimeOptions, v as SqlRuntimeAdapterDescriptor, x as SqlRuntimeExtensionDescriptor, y as SqlRuntimeAdapterInstance } from "../prepared-statement-
|
|
1
|
+
import { C as SqlRuntimeTargetDescriptor, H as decodeRow, S as SqlRuntimeExtensionInstance, V as buildDecodeContext, b as SqlRuntimeDriverInstance, f as ExecutionContext, i as Runtime, o as RuntimeOptions, v as SqlRuntimeAdapterDescriptor, x as SqlRuntimeExtensionDescriptor, y as SqlRuntimeAdapterInstance } from "../prepared-statement-BuDdY11z.mjs";
|
|
2
2
|
import { CodecDescriptor } from "@prisma-next/framework-components/codec";
|
|
3
3
|
import { ResultType } from "@prisma-next/framework-components/runtime";
|
|
4
4
|
import { Adapter, AnyQueryAst, Codec, ContractCodecRegistry, LoweredStatement, SelectAst } from "@prisma-next/sql-relational-core/ast";
|
|
@@ -9,6 +9,7 @@ import { SqlStorage, SqlStorageInput, StorageTableInput } from "@prisma-next/sql
|
|
|
9
9
|
import { DevDatabase, collectAsync, createDevDatabase, teardownTestDatabase, withClient } from "@prisma-next/test-utils";
|
|
10
10
|
import { SqlExecutionPlan, SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
|
|
11
11
|
import { Client } from "pg";
|
|
12
|
+
import "@prisma-next/framework-components/authoring";
|
|
12
13
|
//#region ../1-core/contract/src/ir/sql-node.d.ts
|
|
13
14
|
/**
|
|
14
15
|
* SQL family IR node base. Carries the family-level `kind` discriminator
|
|
@@ -129,13 +130,17 @@ interface ForeignKeyInput {
|
|
|
129
130
|
readonly name?: string;
|
|
130
131
|
readonly onDelete?: ReferentialAction;
|
|
131
132
|
readonly onUpdate?: ReferentialAction;
|
|
132
|
-
/** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */
|
|
133
|
-
readonly constraint: boolean;
|
|
134
|
-
/** Whether to emit a backing index for the FK columns. */
|
|
135
|
-
readonly index: boolean;
|
|
136
133
|
}
|
|
137
134
|
/**
|
|
138
|
-
* SQL Contract IR node for a table-level foreign-key declaration
|
|
135
|
+
* SQL Contract IR node for a table-level foreign-key declaration — the
|
|
136
|
+
* referential constraint only (source, target, `onDelete`/`onUpdate`).
|
|
137
|
+
*
|
|
138
|
+
* A persisted `foreignKeys[]` entry always denotes a real constraint: whether
|
|
139
|
+
* to emit the constraint at all, and whether to back it with an index, are
|
|
140
|
+
* authoring-time decisions (PSL `@relation(index:)`, TS `fk({ constraint,
|
|
141
|
+
* index })`) resolved once at `contract emit` — a `constraint: false` FK
|
|
142
|
+
* simply has no entry here, and a backing index (if any) is its own discrete,
|
|
143
|
+
* named entry in the table's `indexes[]`.
|
|
139
144
|
*
|
|
140
145
|
* Each FK carries explicit `source` and `target` {@link ForeignKeyReference}
|
|
141
146
|
* coordinates (namespace, table, columns). For single-namespace contracts the
|
|
@@ -149,8 +154,6 @@ interface ForeignKeyInput {
|
|
|
149
154
|
declare class ForeignKey extends SqlNode {
|
|
150
155
|
readonly source: ForeignKeyReference;
|
|
151
156
|
readonly target: ForeignKeyReference;
|
|
152
|
-
readonly constraint: boolean;
|
|
153
|
-
readonly index: boolean;
|
|
154
157
|
readonly name?: string;
|
|
155
158
|
readonly onDelete?: ReferentialAction;
|
|
156
159
|
readonly onUpdate?: ReferentialAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../../1-core/contract/src/ir/sql-node.ts","../../../1-core/contract/src/ir/check-constraint.ts","../../../1-core/contract/src/ir/foreign-key-reference.ts","../../../1-core/contract/src/ir/foreign-key.ts","../../../1-core/contract/src/ir/primary-key.ts","../../../1-core/contract/src/ir/sql-index.ts","../../../1-core/contract/src/ir/storage-column.ts","../../../1-core/contract/src/ir/unique-constraint.ts","../../../1-core/contract/src/ir/storage-table.ts","../../../1-core/contract/src/ir/storage-value-set.ts","../../../1-core/contract/src/ir/sql-storage.ts","../../../1-core/contract/test/test-support.ts","../../test/utils.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../../1-core/contract/src/ir/sql-node.ts","../../../1-core/contract/src/ir/check-constraint.ts","../../../1-core/contract/src/ir/foreign-key-reference.ts","../../../1-core/contract/src/ir/foreign-key.ts","../../../1-core/contract/src/ir/primary-key.ts","../../../1-core/contract/src/ir/sql-index.ts","../../../1-core/contract/src/ir/storage-column.ts","../../../1-core/contract/src/ir/unique-constraint.ts","../../../1-core/contract/src/ir/storage-table.ts","../../../1-core/contract/src/ir/storage-value-set.ts","../../../1-core/contract/src/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pB,QAAQ,QACR,UAAU,SAAS,cAClB;;;;;;;iBAea,wBACd,QAAQ,cAAc,iBACrB;;;;;iBAqCa,sBACd,QAAQ,cAAc,iBACrB,cAAc;iBAuCD,4BACd,SAAS,cACR;;;;iBAoBa,8BAA8B;;;;;;iBAmB9B,kBAAkB,kBAAkB,SAAS,aAC3D,UAAU,WACV,SAAS,aACT;EACE,iBAAiB,cAAc;IAEhC,iBAAiB;iBAWJ,wBAAwB;EACtC,iBAAiB,cAAc;EAC/B,SAAS,oDAIP;0DAEH,0CAAA,uCAAA,sCAAA;;;;KAcW,cAAc,QAAQ,WAAW,SAAS,aAAa;WACxD,UAAU,cAAc;;;;;;;iBAQnB,qBAAqB;iBA0FrB,2BACd,QAAQ,eAAe,qBACtB,kBAAkB;iBAIL,4DAAkB;iBAIlB,mBACd,UAAU,QAAQ,KAAK,SAAS;EAC9B;EACA;EACA,SAAS,eAAe;EACxB,SAAS,SAAS;EAClB,UAAU,QAAQ,KAAK;IAExB,SAAS;iBA+BI,WAAW"}
|
package/dist/test/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createExecutionContext, i as decodeRow, o as createSqlExecutionStack, r as buildDecodeContext, t as SqlRuntimeBase } from "../exports-
|
|
1
|
+
import { a as createExecutionContext, i as decodeRow, o as createSqlExecutionStack, r as buildDecodeContext, t as SqlRuntimeBase } from "../exports-Cm5jehIz.mjs";
|
|
2
2
|
import { canonicalizeJson } from "@prisma-next/framework-components/utils";
|
|
3
3
|
import { runtimeError } from "@prisma-next/framework-components/runtime";
|
|
4
4
|
import { SelectAst, TableSource } from "@prisma-next/sql-relational-core/ast";
|
|
@@ -12,7 +12,14 @@ import { builtinGeneratorIds } from "@prisma-next/ids";
|
|
|
12
12
|
import { generateId } from "@prisma-next/ids/runtime";
|
|
13
13
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
14
14
|
import { applicationDomainOf, collectAsync, collectAsync as collectAsync$1, createDevDatabase, drainAsyncIterable, teardownTestDatabase, withClient } from "@prisma-next/test-utils";
|
|
15
|
+
import { structuredError } from "@prisma-next/utils/structured-error";
|
|
15
16
|
import { type } from "arktype";
|
|
17
|
+
import { InternalError } from "@prisma-next/utils/internal-error";
|
|
18
|
+
//#region ../1-core/contract/src/contract-errors.ts
|
|
19
|
+
function contractError(code, message, options) {
|
|
20
|
+
return structuredError(code, message, options);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
16
23
|
//#region ../1-core/contract/src/ir/storage-entry-schemas.ts
|
|
17
24
|
const literalKindSchema = type("'literal'");
|
|
18
25
|
const functionKindSchema = type("'function'");
|
|
@@ -90,9 +97,7 @@ const ForeignKeySchema = type.declare().type({
|
|
|
90
97
|
target: ForeignKeyReferenceSchema,
|
|
91
98
|
"name?": "string",
|
|
92
99
|
"onDelete?": ReferentialActionSchema,
|
|
93
|
-
"onUpdate?": ReferentialActionSchema
|
|
94
|
-
constraint: "boolean",
|
|
95
|
-
index: "boolean"
|
|
100
|
+
"onUpdate?": ReferentialActionSchema
|
|
96
101
|
});
|
|
97
102
|
const CheckConstraintSchema = type({
|
|
98
103
|
"+": "reject",
|
|
@@ -218,7 +223,15 @@ var ForeignKeyReference = class extends SqlNode {
|
|
|
218
223
|
//#endregion
|
|
219
224
|
//#region ../1-core/contract/src/ir/foreign-key.ts
|
|
220
225
|
/**
|
|
221
|
-
* SQL Contract IR node for a table-level foreign-key declaration
|
|
226
|
+
* SQL Contract IR node for a table-level foreign-key declaration — the
|
|
227
|
+
* referential constraint only (source, target, `onDelete`/`onUpdate`).
|
|
228
|
+
*
|
|
229
|
+
* A persisted `foreignKeys[]` entry always denotes a real constraint: whether
|
|
230
|
+
* to emit the constraint at all, and whether to back it with an index, are
|
|
231
|
+
* authoring-time decisions (PSL `@relation(index:)`, TS `fk({ constraint,
|
|
232
|
+
* index })`) resolved once at `contract emit` — a `constraint: false` FK
|
|
233
|
+
* simply has no entry here, and a backing index (if any) is its own discrete,
|
|
234
|
+
* named entry in the table's `indexes[]`.
|
|
222
235
|
*
|
|
223
236
|
* Each FK carries explicit `source` and `target` {@link ForeignKeyReference}
|
|
224
237
|
* coordinates (namespace, table, columns). For single-namespace contracts the
|
|
@@ -232,14 +245,10 @@ var ForeignKeyReference = class extends SqlNode {
|
|
|
232
245
|
var ForeignKey = class extends SqlNode {
|
|
233
246
|
source;
|
|
234
247
|
target;
|
|
235
|
-
constraint;
|
|
236
|
-
index;
|
|
237
248
|
constructor(input) {
|
|
238
249
|
super();
|
|
239
250
|
this.source = input.source instanceof ForeignKeyReference ? input.source : new ForeignKeyReference(input.source);
|
|
240
251
|
this.target = input.target instanceof ForeignKeyReference ? input.target : new ForeignKeyReference(input.target);
|
|
241
|
-
this.constraint = input.constraint;
|
|
242
|
-
this.index = input.index;
|
|
243
252
|
if (input.name !== void 0) this.name = input.name;
|
|
244
253
|
if (input.onDelete !== void 0) this.onDelete = input.onDelete;
|
|
245
254
|
if (input.onUpdate !== void 0) this.onUpdate = input.onUpdate;
|
|
@@ -370,7 +379,7 @@ var StorageTable = class StorageTable extends SqlNode {
|
|
|
370
379
|
return "columns" in value && "uniques" in value && "indexes" in value && "foreignKeys" in value;
|
|
371
380
|
}
|
|
372
381
|
static assert(value, coordinate) {
|
|
373
|
-
if (!StorageTable.is(value)) throw new
|
|
382
|
+
if (!StorageTable.is(value)) throw new InternalError(`Expected a StorageTable at ${coordinate}`);
|
|
374
383
|
}
|
|
375
384
|
};
|
|
376
385
|
//#endregion
|
|
@@ -425,7 +434,7 @@ const valueSetEntityKind = {
|
|
|
425
434
|
function composeSqlEntityKinds(packKinds = []) {
|
|
426
435
|
const kinds = /* @__PURE__ */ new Map([["table", tableEntityKind], ["valueSet", valueSetEntityKind]]);
|
|
427
436
|
for (const descriptor of packKinds) {
|
|
428
|
-
if (kinds.has(descriptor.kind)) throw
|
|
437
|
+
if (kinds.has(descriptor.kind)) throw contractError("CONTRACT.PACK_CONTRIBUTION_INVALID", `composeSqlEntityKinds: duplicate entity kind "${descriptor.kind}" — each kind may be registered only once`, { meta: { entityKind: descriptor.kind } });
|
|
429
438
|
kinds.set(descriptor.kind, descriptor);
|
|
430
439
|
}
|
|
431
440
|
return kinds;
|