@prisma-next/sql-runtime 0.16.0-dev.3 → 0.16.0-dev.31
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-Cm5jehIz.mjs → exports-zQ8h9W9h.mjs} +19 -17
- package/dist/exports-zQ8h9W9h.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{prepared-statement-BuDdY11z.d.mts → prepared-statement-C0hx9fQD.d.mts} +7 -7
- package/dist/{prepared-statement-BuDdY11z.d.mts.map → prepared-statement-C0hx9fQD.d.mts.map} +1 -1
- package/dist/test/utils.d.mts +64 -11
- package/dist/test/utils.d.mts.map +1 -1
- package/dist/test/utils.mjs +77 -14
- package/dist/test/utils.mjs.map +1 -1
- package/package.json +12 -12
- package/src/codecs/decoding.ts +11 -5
- package/src/codecs/encoding.ts +12 -10
- package/src/fingerprint.ts +1 -2
- package/src/middleware/budgets.ts +3 -1
- package/src/middleware/lints.ts +4 -2
- package/src/sql-context.ts +10 -11
- package/dist/exports-Cm5jehIz.mjs.map +0 -1
package/dist/{prepared-statement-BuDdY11z.d.mts.map → prepared-statement-C0hx9fQD.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepared-statement-
|
|
1
|
+
{"version":3,"file":"prepared-statement-C0hx9fQD.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;iBAyI1C,yBACpB,4BACA,mBAAmB,iBACnB,KAAK,qBACL,iBAAiB,wBAChB;;;UCpKc,6BAA6B;WACnC,UAAU,SAAS;;;;;;UAOb;WACN,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B;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-C0hx9fQD.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";
|
|
@@ -175,14 +175,62 @@ declare class PrimaryKey extends SqlNode {
|
|
|
175
175
|
}
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region ../1-core/contract/src/ir/sql-index.d.ts
|
|
178
|
-
|
|
178
|
+
/**
|
|
179
|
+
* An index's element structure — exactly one of a column tuple or an opaque
|
|
180
|
+
* expression, made unrepresentable-otherwise at the type level. No
|
|
181
|
+
* discriminant is stored: the JSON shape stays flat (`columns` or
|
|
182
|
+
* `expression`, never both), and the runtime xor guard in the constructor
|
|
183
|
+
* remains as the backstop for JSON loads that bypass this input type.
|
|
184
|
+
*/
|
|
185
|
+
type IndexElements = {
|
|
186
|
+
/** Column-tuple elements. */
|
|
179
187
|
readonly columns: readonly string[];
|
|
180
|
-
readonly
|
|
181
|
-
|
|
182
|
-
readonly
|
|
183
|
-
|
|
188
|
+
readonly expression?: never;
|
|
189
|
+
} | {
|
|
190
|
+
readonly columns?: never;
|
|
191
|
+
/**
|
|
192
|
+
* Opaque SQL: the entire element list between the parens of CREATE
|
|
193
|
+
* INDEX — one string, never parsed.
|
|
194
|
+
*/
|
|
195
|
+
readonly expression: string;
|
|
196
|
+
};
|
|
184
197
|
/**
|
|
185
|
-
*
|
|
198
|
+
* Construction input for {@link Index}. Internal seam (built by lowering and
|
|
199
|
+
* FK materialization, not by end users), so every non-element key is
|
|
200
|
+
* required and absence is stated explicitly as `undefined` — matching the
|
|
201
|
+
* `SqlIndexIRInput` convention.
|
|
202
|
+
*/
|
|
203
|
+
type IndexInput = IndexElements & {
|
|
204
|
+
/** Full wire name (managed) or verbatim physical name (exact). Always present. */
|
|
205
|
+
readonly name: string;
|
|
206
|
+
/**
|
|
207
|
+
* The managed-mode name prefix — its PRESENCE is the naming-mode
|
|
208
|
+
* discriminator (there is no stored enum). Present ⇔ managed: the
|
|
209
|
+
* toolchain owns the physical name and `name === formatWireName(prefix,
|
|
210
|
+
* <8hex content hash>)`, so the author chooses the prefix but never the
|
|
211
|
+
* whole name. Absent ⇔ exact: `name` is an adopted verbatim physical name
|
|
212
|
+
* (PSL `map:`) whose identity the author owns entirely.
|
|
213
|
+
*/
|
|
214
|
+
readonly prefix: string | undefined;
|
|
215
|
+
/** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */
|
|
216
|
+
readonly where: string | undefined;
|
|
217
|
+
/** Rendered as CREATE UNIQUE INDEX. */
|
|
218
|
+
readonly unique: boolean;
|
|
219
|
+
readonly type: string | undefined;
|
|
220
|
+
readonly options: Record<string, unknown> | undefined;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* SQL Contract IR node for a table-level secondary index, name-identified:
|
|
224
|
+
* `name` is the full physical name; a present `prefix` marks the index as
|
|
225
|
+
* managed (`name` is `formatWireName(prefix, <8hex>)`), an absent `prefix`
|
|
226
|
+
* marks it exact (the name is adopted verbatim).
|
|
227
|
+
*
|
|
228
|
+
* `expression`, `where`, and `unique` are genuine SQL-family attributes —
|
|
229
|
+
* functional and partial indexes are standard SQL supported natively by
|
|
230
|
+
* Postgres and SQLite alike, and the family IR must be able to represent
|
|
231
|
+
* anything any SQL target can introspect. A target declining to AUTHOR them
|
|
232
|
+
* (SQLite's rejection at namespace construction) is a capability decision,
|
|
233
|
+
* not evidence of target-specificity.
|
|
186
234
|
*
|
|
187
235
|
* Note that this class shadows the global TypeScript `Index` lib type
|
|
188
236
|
* at the family-shared name; consumer files that need both should
|
|
@@ -190,8 +238,13 @@ interface IndexInput {
|
|
|
190
238
|
* `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).
|
|
191
239
|
*/
|
|
192
240
|
declare class Index extends SqlNode {
|
|
193
|
-
readonly
|
|
194
|
-
readonly
|
|
241
|
+
readonly name: string;
|
|
242
|
+
readonly unique: boolean;
|
|
243
|
+
/** See {@link IndexInput.prefix} — presence is the naming-mode discriminator. */
|
|
244
|
+
readonly prefix?: string;
|
|
245
|
+
readonly columns?: readonly string[];
|
|
246
|
+
readonly expression?: string;
|
|
247
|
+
readonly where?: string;
|
|
195
248
|
readonly type?: string;
|
|
196
249
|
readonly options?: Record<string, unknown>;
|
|
197
250
|
constructor(input: IndexInput);
|
|
@@ -491,10 +544,10 @@ declare function createTestTargetDescriptor(): SqlRuntimeTargetDescriptor<'postg
|
|
|
491
544
|
* Accepts a raw adapter and optional extension descriptors, wrapping the adapter in a descriptor internally for descriptor-first context creation.
|
|
492
545
|
*/
|
|
493
546
|
declare function createTestContext<TContract extends Contract<SqlStorage>>(contract: TContract, adapter: StubAdapter, options?: {
|
|
494
|
-
|
|
547
|
+
extensions?: ReadonlyArray<SqlRuntimeExtensionDescriptor<'postgres'>>;
|
|
495
548
|
}): ExecutionContext<TContract>;
|
|
496
549
|
declare function createTestStackInstance(options?: {
|
|
497
|
-
|
|
550
|
+
extensions?: ReadonlyArray<SqlRuntimeExtensionDescriptor<'postgres'>>;
|
|
498
551
|
driver?: RuntimeDriverDescriptor<'sql', 'postgres', unknown, SqlRuntimeDriverInstance<'postgres'>>;
|
|
499
552
|
}): import("@prisma-next/framework-components/execution").ExecutionStackInstance<"sql", "postgres", SqlRuntimeAdapterInstance<"postgres">, SqlRuntimeDriverInstance<"postgres">, SqlRuntimeExtensionInstance<"postgres">>;
|
|
500
553
|
/**
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAkCsB,gBAAgB;WAC3B;;;;;;;;;;UC1BM;WACN;WACA;WACA,UAAU;;;;;;;;;;;;;;;;cAiBR,wBAAwB;WAC1B;WACA;WACA,UAAU;cAEP,OAAO;;;;;;;;;;;;;;;UCnBJ;WACN;WACA;WACA;WACA;;;;;;;;;;;;;;;;;;cAmBE,4BAA4B;WAC9B,aAAa;WACb;WACA;WACQ;cAEL,OAAO;;;;KCxCT;UAEK;WACN,QAAQ,sBAAsB;WAC9B,QAAQ,sBAAsB;WAC9B;WACA,WAAW;WACX,WAAW;;;;;;;;;;;;;;;;;;;;;;cAuBT,mBAAmB;WACrB,QAAQ;WACR,QAAQ;WACA;WACA,WAAW;WACX,WAAW;cAEhB,OAAO;;;;UCtCJ;WACN;WACA;;;;;cAME,mBAAmB;WACrB;WACQ;cAEL,OAAO
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAkCsB,gBAAgB;WAC3B;;;;;;;;;;UC1BM;WACN;WACA;WACA,UAAU;;;;;;;;;;;;;;;;cAiBR,wBAAwB;WAC1B;WACA;WACA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c,iBACrB,cAAc;iBAuCD,4BACd,SAAS,cACR;;;;iBAoBa,8BAA8B;;;;;;iBAmB9B,kBAAkB,kBAAkB,SAAS,aAC3D,UAAU,WACV,SAAS,aACT;EACE,aAAa,cAAc;IAE5B,iBAAiB;iBAWJ,wBAAwB;EACtC,aAAa,cAAc;EAC3B,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,10 +1,13 @@
|
|
|
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-zQ8h9W9h.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";
|
|
5
|
+
import { structuredError } from "@prisma-next/utils/structured-error";
|
|
6
|
+
import { InternalError } from "@prisma-next/utils/internal-error";
|
|
5
7
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
6
8
|
import { instantiateExecutionStack } from "@prisma-next/framework-components/execution";
|
|
7
9
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
10
|
+
import "node:crypto";
|
|
8
11
|
import { asNamespaceId, coreHash, profileHash } from "@prisma-next/contract/types";
|
|
9
12
|
import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
|
|
10
13
|
import { IRNodeBase, NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma-next/framework-components/ir";
|
|
@@ -13,6 +16,12 @@ import { generateId } from "@prisma-next/ids/runtime";
|
|
|
13
16
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
14
17
|
import { applicationDomainOf, collectAsync, collectAsync as collectAsync$1, createDevDatabase, drainAsyncIterable, teardownTestDatabase, withClient } from "@prisma-next/test-utils";
|
|
15
18
|
import { type } from "arktype";
|
|
19
|
+
import { ContractValidationError } from "@prisma-next/contract/contract-validation-error";
|
|
20
|
+
//#region ../1-core/contract/src/contract-errors.ts
|
|
21
|
+
function contractError(code, message, options) {
|
|
22
|
+
return structuredError(code, message, options);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
16
25
|
//#region ../1-core/contract/src/ir/storage-entry-schemas.ts
|
|
17
26
|
const literalKindSchema = type("'literal'");
|
|
18
27
|
const functionKindSchema = type("'function'");
|
|
@@ -66,8 +75,12 @@ const UniqueConstraintSchema = type.declare().type({
|
|
|
66
75
|
"name?": "string"
|
|
67
76
|
});
|
|
68
77
|
const IndexSchema = type({
|
|
69
|
-
|
|
70
|
-
"
|
|
78
|
+
name: "string",
|
|
79
|
+
"prefix?": "string",
|
|
80
|
+
"columns?": type.string.array().readonly(),
|
|
81
|
+
"expression?": "string",
|
|
82
|
+
"where?": "string",
|
|
83
|
+
unique: "boolean",
|
|
71
84
|
"type?": "string",
|
|
72
85
|
"options?": "Record<string, unknown>"
|
|
73
86
|
});
|
|
@@ -263,9 +276,48 @@ var PrimaryKey = class extends SqlNode {
|
|
|
263
276
|
}
|
|
264
277
|
};
|
|
265
278
|
//#endregion
|
|
279
|
+
//#region ../1-core/schema-ir/dist/naming-BD7Y-Fq1.mjs
|
|
280
|
+
const WIRE_NAME_PATTERN = /^(.+)_([0-9a-f]{8})$/;
|
|
281
|
+
/**
|
|
282
|
+
* Assembles a wire name from its user-supplied prefix and its 8-hex
|
|
283
|
+
* content-hash suffix. This module owns the `<prefix>_<hash>` format on both
|
|
284
|
+
* sides — construction here and parsing in {@link parseWireName} — so the two
|
|
285
|
+
* never drift.
|
|
286
|
+
*/
|
|
287
|
+
function formatWireName(prefix, hash) {
|
|
288
|
+
return `${prefix}_${hash}`;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Splits a wire name (`<prefix>_<8hex>`) into its prefix and content-hash
|
|
292
|
+
* suffix. Returns `undefined` when the name does not follow the wire-name
|
|
293
|
+
* shape (e.g. an object created outside the toolchain) — callers treat such
|
|
294
|
+
* names as all-prefix. Consumed by introspection (prefix extraction) and by
|
|
295
|
+
* rename pairing (same hash, different prefix).
|
|
296
|
+
*/
|
|
297
|
+
function parseWireName(name) {
|
|
298
|
+
const match = WIRE_NAME_PATTERN.exec(name);
|
|
299
|
+
const prefix = match?.[1];
|
|
300
|
+
const hash = match?.[2];
|
|
301
|
+
if (prefix === void 0 || hash === void 0) return void 0;
|
|
302
|
+
return {
|
|
303
|
+
prefix,
|
|
304
|
+
hash
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
266
308
|
//#region ../1-core/contract/src/ir/sql-index.ts
|
|
267
309
|
/**
|
|
268
|
-
* SQL Contract IR node for a table-level secondary index
|
|
310
|
+
* SQL Contract IR node for a table-level secondary index, name-identified:
|
|
311
|
+
* `name` is the full physical name; a present `prefix` marks the index as
|
|
312
|
+
* managed (`name` is `formatWireName(prefix, <8hex>)`), an absent `prefix`
|
|
313
|
+
* marks it exact (the name is adopted verbatim).
|
|
314
|
+
*
|
|
315
|
+
* `expression`, `where`, and `unique` are genuine SQL-family attributes —
|
|
316
|
+
* functional and partial indexes are standard SQL supported natively by
|
|
317
|
+
* Postgres and SQLite alike, and the family IR must be able to represent
|
|
318
|
+
* anything any SQL target can introspect. A target declining to AUTHOR them
|
|
319
|
+
* (SQLite's rejection at namespace construction) is a capability decision,
|
|
320
|
+
* not evidence of target-specificity.
|
|
269
321
|
*
|
|
270
322
|
* Note that this class shadows the global TypeScript `Index` lib type
|
|
271
323
|
* at the family-shared name; consumer files that need both should
|
|
@@ -273,11 +325,22 @@ var PrimaryKey = class extends SqlNode {
|
|
|
273
325
|
* `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).
|
|
274
326
|
*/
|
|
275
327
|
var Index = class extends SqlNode {
|
|
276
|
-
|
|
328
|
+
name;
|
|
329
|
+
unique;
|
|
277
330
|
constructor(input) {
|
|
278
331
|
super();
|
|
279
|
-
|
|
280
|
-
if (input.
|
|
332
|
+
if (input.name === void 0 || input.name.length === 0) throw new ContractValidationError("Index: every index carries a full physical name; an expression index must be explicitly named (a default name cannot be derived from an expression).", "storage");
|
|
333
|
+
if (input.columns === void 0 === (input.expression === void 0)) throw new ContractValidationError(`Index "${input.name}": exactly one of columns or expression must be set.`, "storage");
|
|
334
|
+
if (input.prefix !== void 0) {
|
|
335
|
+
const parsed = parseWireName(input.name);
|
|
336
|
+
if (parsed === void 0 || parsed.prefix !== input.prefix) throw new ContractValidationError(`Index "${input.name}": prefix "${input.prefix}" does not match the wire name (expected "${formatWireName(input.prefix, "<8hex>")}").`, "storage");
|
|
337
|
+
}
|
|
338
|
+
this.name = input.name;
|
|
339
|
+
this.unique = input.unique;
|
|
340
|
+
if (input.prefix !== void 0) this.prefix = input.prefix;
|
|
341
|
+
if (input.columns !== void 0) this.columns = input.columns;
|
|
342
|
+
if (input.expression !== void 0) this.expression = input.expression;
|
|
343
|
+
if (input.where !== void 0) this.where = input.where;
|
|
281
344
|
if (input.type !== void 0) this.type = input.type;
|
|
282
345
|
if (input.options !== void 0) this.options = input.options;
|
|
283
346
|
freezeNode(this);
|
|
@@ -372,7 +435,7 @@ var StorageTable = class StorageTable extends SqlNode {
|
|
|
372
435
|
return "columns" in value && "uniques" in value && "indexes" in value && "foreignKeys" in value;
|
|
373
436
|
}
|
|
374
437
|
static assert(value, coordinate) {
|
|
375
|
-
if (!StorageTable.is(value)) throw new
|
|
438
|
+
if (!StorageTable.is(value)) throw new InternalError(`Expected a StorageTable at ${coordinate}`);
|
|
376
439
|
}
|
|
377
440
|
};
|
|
378
441
|
//#endregion
|
|
@@ -427,7 +490,7 @@ const valueSetEntityKind = {
|
|
|
427
490
|
function composeSqlEntityKinds(packKinds = []) {
|
|
428
491
|
const kinds = /* @__PURE__ */ new Map([["table", tableEntityKind], ["valueSet", valueSetEntityKind]]);
|
|
429
492
|
for (const descriptor of packKinds) {
|
|
430
|
-
if (kinds.has(descriptor.kind)) throw
|
|
493
|
+
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 } });
|
|
431
494
|
kinds.set(descriptor.kind, descriptor);
|
|
432
495
|
}
|
|
433
496
|
return kinds;
|
|
@@ -696,7 +759,7 @@ function createTestContext(contract, adapter, options) {
|
|
|
696
759
|
stack: {
|
|
697
760
|
target: createTestTargetDescriptor(),
|
|
698
761
|
adapter: createTestAdapterDescriptor(adapter),
|
|
699
|
-
|
|
762
|
+
extensions: options?.extensions ?? []
|
|
700
763
|
}
|
|
701
764
|
});
|
|
702
765
|
}
|
|
@@ -705,7 +768,7 @@ function createTestStackInstance(options) {
|
|
|
705
768
|
target: createTestTargetDescriptor(),
|
|
706
769
|
adapter: createTestAdapterDescriptor(createStubAdapter()),
|
|
707
770
|
driver: options?.driver,
|
|
708
|
-
|
|
771
|
+
extensions: options?.extensions ?? []
|
|
709
772
|
}));
|
|
710
773
|
}
|
|
711
774
|
/**
|
|
@@ -807,7 +870,7 @@ function emptySqlTestDomain() {
|
|
|
807
870
|
}
|
|
808
871
|
function createTestContract(contract) {
|
|
809
872
|
const { execution, ...rest } = contract;
|
|
810
|
-
const storageHashValue = coreHash(rest["storageHash"] ?? "
|
|
873
|
+
const storageHashValue = coreHash(rest["storageHash"] ?? "testcore");
|
|
811
874
|
return {
|
|
812
875
|
target: rest["target"] ?? "postgres",
|
|
813
876
|
targetFamily: rest["targetFamily"] ?? "sql",
|
|
@@ -828,10 +891,10 @@ function createTestContract(contract) {
|
|
|
828
891
|
domain: rest["domain"] ?? applicationDomainOf({ models: rest["models"] ?? {} }),
|
|
829
892
|
roots: rest["roots"] ?? {},
|
|
830
893
|
capabilities: rest["capabilities"] ?? {},
|
|
831
|
-
|
|
894
|
+
extensions: rest["extensions"] ?? {},
|
|
832
895
|
meta: rest["meta"] ?? {},
|
|
833
896
|
...execution ? { execution } : {},
|
|
834
|
-
profileHash: profileHash(rest["profileHash"] ?? "
|
|
897
|
+
profileHash: profileHash(rest["profileHash"] ?? "testprofile")
|
|
835
898
|
};
|
|
836
899
|
}
|
|
837
900
|
function stubAst() {
|