@prisma/orm-family-sql 8.0.0-rc.11-dev.43 → 8.0.0-rc.11-dev.45
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/{ast-d2-iNoEs.d.mts → ast-CENQ0LJn.d.mts} +3 -3
- package/dist/{ast-d2-iNoEs.d.mts.map → ast-CENQ0LJn.d.mts.map} +1 -1
- package/dist/builder.d.mts +2 -2
- package/dist/builder__runtime.d.mts +7 -7
- package/dist/builder__types.d.mts +2 -2
- package/dist/{contract-builder-BHCjHphC.d.mts → contract-builder-OJNugboM.d.mts} +7 -7
- package/dist/{contract-builder-BHCjHphC.d.mts.map → contract-builder-OJNugboM.d.mts.map} +1 -1
- package/dist/contract-prisma7__provider.mjs +1 -1
- package/dist/contract-psl.d.mts +2 -2
- package/dist/contract-psl.d.mts.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +7 -6
- package/dist/contract-psl__attribute-specs.d.mts.map +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.mjs +1 -1
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +1 -1
- package/dist/contract-ts__contract-builder.d.mts +1 -1
- package/dist/{control-CkJbZTUB.d.mts → control-DZ6oxNo3.d.mts} +8 -8
- package/dist/control-DZ6oxNo3.d.mts.map +1 -0
- package/dist/{control-Ber3kz3q.mjs → control-FOipY3kl.mjs} +2 -2
- package/dist/{control-Ber3kz3q.mjs.map → control-FOipY3kl.mjs.map} +1 -1
- package/dist/control-adapter-BNrVtMcn.d.mts +1 -0
- package/dist/{control-adapter-C99J7aEF-DwFChl8n.d.mts → control-adapter-C99J7aEF-CZ1WvESn.d.mts} +4 -4
- package/dist/{control-adapter-C99J7aEF-DwFChl8n.d.mts.map → control-adapter-C99J7aEF-CZ1WvESn.d.mts.map} +1 -1
- package/dist/{db-BhQdL6Za-BBgu_awF.d.mts → db-BhQdL6Za-CoAgyIk9.d.mts} +6 -6
- package/dist/{db-BhQdL6Za-BBgu_awF.d.mts.map → db-BhQdL6Za-CoAgyIk9.d.mts.map} +1 -1
- package/dist/{ddl-types-DrK8E0jL-ClX_UkVh.d.mts → ddl-types-DrK8E0jL-Cz06w-Hd.d.mts} +2 -2
- package/dist/{ddl-types-DrK8E0jL-ClX_UkVh.d.mts.map → ddl-types-DrK8E0jL-Cz06w-Hd.d.mts.map} +1 -1
- package/dist/{diff-C9tzE_nE.d.mts → diff-C2qxgHIR.d.mts} +3 -3
- package/dist/{diff-C9tzE_nE.d.mts.map → diff-C2qxgHIR.d.mts.map} +1 -1
- package/dist/{expression-CAJjmssr.d.mts → expression-DV56tQtp.d.mts} +4 -4
- package/dist/{expression-CAJjmssr.d.mts.map → expression-DV56tQtp.d.mts.map} +1 -1
- package/dist/family.d.mts +7 -7
- package/dist/family.mjs +1 -1
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +2 -2
- package/dist/family__control.mjs +1 -1
- package/dist/family__diff.d.mts +2 -2
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.d.mts.map +1 -1
- package/dist/family__pack.mjs +1 -1
- package/dist/family__runtime.d.mts +1 -1
- package/dist/{index-DI6YpxCw.d.mts → index-Cdu63YGJ.d.mts} +9 -9
- package/dist/{index-DI6YpxCw.d.mts.map → index-Cdu63YGJ.d.mts.map} +1 -1
- package/dist/{index-CLAshwKN.d.mts → index-Cef8iy1o.d.mts} +1 -2
- package/dist/index-Cef8iy1o.d.mts.map +1 -0
- package/dist/{interpreter-DvKii7Bl-D8Ipte3f.mjs → interpreter-BIBwrA2w-DAiNN30m.mjs} +109 -81
- package/dist/interpreter-BIBwrA2w-DAiNN30m.mjs.map +1 -0
- package/dist/{middleware-CHg6zJkn-DJAKnDpd.d.mts → middleware-CHg6zJkn-BXbPG5gs.d.mts} +2 -2
- package/dist/{middleware-CHg6zJkn-DJAKnDpd.d.mts.map → middleware-CHg6zJkn-BXbPG5gs.d.mts.map} +1 -1
- package/dist/middleware-nbYXEk2K.d.mts +1 -0
- package/dist/{migration-BQWwBE8Q.d.mts → migration-1d1vOKc_.d.mts} +2 -2
- package/dist/{migration-BQWwBE8Q.d.mts.map → migration-1d1vOKc_.d.mts.map} +1 -1
- package/dist/operations.d.mts +1 -1
- package/dist/orm-client.d.mts +11 -11
- package/dist/{plan-DVkrl9Pq-DOf_eQ84.d.mts → plan-DVkrl9Pq-CUhH48Gt.d.mts} +2 -2
- package/dist/{plan-DVkrl9Pq-DOf_eQ84.d.mts.map → plan-DVkrl9Pq-CUhH48Gt.d.mts.map} +1 -1
- package/dist/plan-Dh-FnySu.d.mts +2 -0
- package/dist/{prepared-statement-DZtymlzd-DmbP44p0.d.mts → prepared-statement-DZtymlzd-BhL0Elnw.d.mts} +14 -14
- package/dist/{prepared-statement-DZtymlzd-DmbP44p0.d.mts.map → prepared-statement-DZtymlzd-BhL0Elnw.d.mts.map} +1 -1
- package/dist/{query-lane-context-BUNC86DS-C_hIrqaW.d.mts → query-lane-context-BUNC86DS-554MXNHX.d.mts} +3 -3
- package/dist/{query-lane-context-BUNC86DS-C_hIrqaW.d.mts.map → query-lane-context-BUNC86DS-554MXNHX.d.mts.map} +1 -1
- package/dist/query-lane-context-Cj8AWGMg.d.mts +1 -0
- package/dist/relational-core.d.mts +11 -11
- package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
- package/dist/relational-core__ast.d.mts +3 -3
- package/dist/relational-core__codec-descriptor-registry.d.mts +2 -2
- package/dist/relational-core__contract-free.d.mts +2 -2
- package/dist/relational-core__contract-free.mjs +0 -1
- package/dist/relational-core__contract-free.mjs.map +1 -1
- package/dist/relational-core__expression.d.mts +1 -1
- package/dist/relational-core__middleware.d.mts +2 -2
- package/dist/relational-core__plan.d.mts +3 -3
- package/dist/relational-core__query-lane-context.d.mts +2 -2
- package/dist/relational-core__types.d.mts +2 -2
- package/dist/{runtime-BqAUXvAl.d.mts → runtime-CeQsEM5X.d.mts} +3 -3
- package/dist/{runtime-BqAUXvAl.d.mts.map → runtime-CeQsEM5X.d.mts.map} +1 -1
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime__internal__prepared-query.d.mts +1 -1
- package/dist/{sql-attribute-specs-CQoOV2MU-DLD9uxC6.mjs → sql-attribute-specs-BH0U6i1B-Ces5ZCvv.mjs} +23 -17
- package/dist/sql-attribute-specs-BH0U6i1B-Ces5ZCvv.mjs.map +1 -0
- package/dist/{sql-execution-plan-DBvAsaOB-LUMcfRpN.d.mts → sql-execution-plan-DBvAsaOB-CJwz206K.d.mts} +2 -2
- package/dist/{sql-execution-plan-DBvAsaOB-LUMcfRpN.d.mts.map → sql-execution-plan-DBvAsaOB-CJwz206K.d.mts.map} +1 -1
- package/dist/{types-BFPRCYGW-CBv60DKI.d.mts → types-BFPRCYGW-M_-7qGEJ.d.mts} +3 -3
- package/dist/{types-BFPRCYGW-CBv60DKI.d.mts.map → types-BFPRCYGW-M_-7qGEJ.d.mts.map} +1 -1
- package/dist/types-BvpZI6y1.d.mts +1 -0
- package/dist/{types-YGX78yVc-BBy1pp_1.d.mts → types-YGX78yVc-LY1JQLED.d.mts} +2 -2
- package/dist/{types-YGX78yVc-BBy1pp_1.d.mts.map → types-YGX78yVc-LY1JQLED.d.mts.map} +1 -1
- package/dist/{types-BLVS175T-DmpY58Nx.d.mts → types-_3eY-tTq-DY2fDu2J.d.mts} +8 -8
- package/dist/{types-BLVS175T-DmpY58Nx.d.mts.map → types-_3eY-tTq-DY2fDu2J.d.mts.map} +1 -1
- package/package.json +18 -18
- package/dist/control-CkJbZTUB.d.mts.map +0 -1
- package/dist/control-adapter-DPWKLNdH.d.mts +0 -1
- package/dist/index-CLAshwKN.d.mts.map +0 -1
- package/dist/interpreter-DvKii7Bl-D8Ipte3f.mjs.map +0 -1
- package/dist/middleware-wyJe8dVq.d.mts +0 -1
- package/dist/plan-Dzq6Nwb4.d.mts +0 -2
- package/dist/query-lane-context-CeOxBL6I.d.mts +0 -1
- package/dist/sql-attribute-specs-CQoOV2MU-DLD9uxC6.mjs.map +0 -1
- package/dist/types-CQ8FfvRk.d.mts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as isAuthoredIndexInput } from "./index-naming-Cj1Anq-T-w1JL7-EM.mjs";
|
|
2
2
|
import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
|
|
3
3
|
import { n as buildSqlContractFromDefinition } from "./derived-checks-6WZKIUxH-B3Pd6QA5.mjs";
|
|
4
|
-
import { a as interpretFieldAttribute, i as findModelAttributeNode, n as fieldSpecContext, o as interpretModelAttribute, r as findFieldAttributeNode, s as sqlAttributeSpecs, t as PSL_CHECK_ON_STI_VARIANT } from "./sql-attribute-specs-
|
|
4
|
+
import { a as interpretFieldAttribute, i as findModelAttributeNode, n as fieldSpecContext, o as interpretModelAttribute, r as findFieldAttributeNode, s as sqlAttributeSpecs, t as PSL_CHECK_ON_STI_VARIANT } from "./sql-attribute-specs-BH0U6i1B-Ces5ZCvv.mjs";
|
|
5
5
|
import { t as defaultTableName } from "./default-table-name-BfFY8qYR-lHNcVmY5.mjs";
|
|
6
6
|
import { isStructuredError, structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
7
7
|
import { hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, isDataTypeLoweringEntry, loweringEntryKey, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
|
|
@@ -17,7 +17,7 @@ import { describeTaggedLiteralFailure } from "@prisma/orm-framework/components/c
|
|
|
17
17
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
18
18
|
import { createPslDiagnosticCollector, diagnosticSource, findBlockDescriptor, keywordPslSpan, nodePslSpan } from "@prisma/orm-framework/psl-parser";
|
|
19
19
|
import { consumeInvalidFkPairing, fkRelationPairKey, requiredOneToOneBackrelationDiagnostic } from "@prisma/orm-framework/psl-parser/interpret";
|
|
20
|
-
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-
|
|
20
|
+
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-BIBwrA2w.mjs
|
|
21
21
|
function contractError(code, message, options) {
|
|
22
22
|
return structuredError(code, message, options);
|
|
23
23
|
}
|
|
@@ -1109,17 +1109,19 @@ function lowerDefaultForField(input) {
|
|
|
1109
1109
|
const node = findFieldAttributeNode(input.field, "default");
|
|
1110
1110
|
if (node === void 0) return {};
|
|
1111
1111
|
const source = diagnosticSource(input.sources, node.syntax);
|
|
1112
|
+
const spec = sqlAttributeSpecs.field.default(fieldSpecContext({
|
|
1113
|
+
symbols: input.symbolTable,
|
|
1114
|
+
model: input.model,
|
|
1115
|
+
field: input.field,
|
|
1116
|
+
controlMutationDefaults: {
|
|
1117
|
+
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
1118
|
+
dataTypeEntries: input.dataTypeSupport.entries
|
|
1119
|
+
}
|
|
1120
|
+
}));
|
|
1112
1121
|
const interpreted = interpretFieldAttribute({
|
|
1122
|
+
symbols: input.symbolTable,
|
|
1113
1123
|
node,
|
|
1114
|
-
spec
|
|
1115
|
-
symbols: input.symbolTable,
|
|
1116
|
-
model: input.model,
|
|
1117
|
-
field: input.field,
|
|
1118
|
-
controlMutationDefaults: {
|
|
1119
|
-
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
1120
|
-
dataTypeEntries: input.dataTypeSupport.entries
|
|
1121
|
-
}
|
|
1122
|
-
})),
|
|
1124
|
+
spec,
|
|
1123
1125
|
model: input.model,
|
|
1124
1126
|
field: input.field,
|
|
1125
1127
|
sources: input.sources,
|
|
@@ -1283,6 +1285,7 @@ function lowerEnumDefaultForField(input) {
|
|
|
1283
1285
|
dataTypeEntries: input.dataTypeSupport.entries
|
|
1284
1286
|
}
|
|
1285
1287
|
})),
|
|
1288
|
+
symbols: input.symbolTable,
|
|
1286
1289
|
model,
|
|
1287
1290
|
field,
|
|
1288
1291
|
sources: input.sources,
|
|
@@ -1352,6 +1355,7 @@ function extractFieldConstraintNames(input) {
|
|
|
1352
1355
|
const idNode = findFieldAttributeNode(input.field, "id");
|
|
1353
1356
|
const idName = idNode === void 0 ? void 0 : interpretFieldAttribute({
|
|
1354
1357
|
node: idNode,
|
|
1358
|
+
symbols: input.symbolTable,
|
|
1355
1359
|
spec: sqlAttributeSpecs.field.id(),
|
|
1356
1360
|
model: input.model,
|
|
1357
1361
|
field: input.field,
|
|
@@ -1365,6 +1369,7 @@ function extractFieldConstraintNames(input) {
|
|
|
1365
1369
|
idName,
|
|
1366
1370
|
uniqueName: uniqueNode === void 0 ? void 0 : interpretFieldAttribute({
|
|
1367
1371
|
node: uniqueNode,
|
|
1372
|
+
symbols: input.symbolTable,
|
|
1368
1373
|
spec: sqlAttributeSpecs.field.unique(),
|
|
1369
1374
|
model: input.model,
|
|
1370
1375
|
field: input.field,
|
|
@@ -1386,6 +1391,7 @@ function lowerNoCheckForField(input) {
|
|
|
1386
1391
|
const interpreted = interpretFieldAttribute({
|
|
1387
1392
|
node,
|
|
1388
1393
|
spec: sqlAttributeSpecs.field.noCheck(),
|
|
1394
|
+
symbols: input.symbolTable,
|
|
1389
1395
|
model: input.model,
|
|
1390
1396
|
field: input.field,
|
|
1391
1397
|
sources: input.sources,
|
|
@@ -1580,6 +1586,7 @@ function collectResolvedFields(input) {
|
|
|
1580
1586
|
}
|
|
1581
1587
|
const mappedColumnName = mapping.fieldColumns.get(field.name) ?? field.name;
|
|
1582
1588
|
const { idAttribute, uniqueAttribute, idName, uniqueName } = extractFieldConstraintNames({
|
|
1589
|
+
symbolTable: input.symbolTable,
|
|
1583
1590
|
model,
|
|
1584
1591
|
field,
|
|
1585
1592
|
sources: input.sources,
|
|
@@ -1613,6 +1620,7 @@ function collectResolvedFields(input) {
|
|
|
1613
1620
|
const fieldExecutionDefaults = presetContributions?.executionDefaults ?? loweredDefault.executionDefaults;
|
|
1614
1621
|
const fieldDefaultValue = presetContributions?.default ?? loweredDefault.defaultValue;
|
|
1615
1622
|
const noCheckKinds = modelDerivesChecks ? lowerNoCheckForField({
|
|
1623
|
+
symbolTable: input.symbolTable,
|
|
1616
1624
|
model,
|
|
1617
1625
|
field,
|
|
1618
1626
|
sources: input.sources,
|
|
@@ -1639,12 +1647,13 @@ function collectResolvedFields(input) {
|
|
|
1639
1647
|
}
|
|
1640
1648
|
return resolvedFields;
|
|
1641
1649
|
}
|
|
1642
|
-
function buildModelMappings(modelEntries, defaultNamespaceId, diagnostics, sources) {
|
|
1650
|
+
function buildModelMappings(symbols, modelEntries, defaultNamespaceId, diagnostics, sources) {
|
|
1643
1651
|
const result = /* @__PURE__ */ new Map();
|
|
1644
1652
|
for (const { model, namespaceId } of modelEntries) {
|
|
1645
1653
|
const mapNode = findModelAttributeNode(model, "map");
|
|
1646
1654
|
const tableName = mapNode === void 0 ? defaultTableName(model.name) : interpretModelAttribute({
|
|
1647
1655
|
node: mapNode,
|
|
1656
|
+
symbols,
|
|
1648
1657
|
spec: sqlAttributeSpecs.model.map(),
|
|
1649
1658
|
model,
|
|
1650
1659
|
sources,
|
|
@@ -1655,6 +1664,7 @@ function buildModelMappings(modelEntries, defaultNamespaceId, diagnostics, sourc
|
|
|
1655
1664
|
const fieldMapNode = findFieldAttributeNode(field, "map");
|
|
1656
1665
|
const columnName = fieldMapNode === void 0 ? field.name : interpretFieldAttribute({
|
|
1657
1666
|
node: fieldMapNode,
|
|
1667
|
+
symbols,
|
|
1658
1668
|
spec: sqlAttributeSpecs.field.map(),
|
|
1659
1669
|
model,
|
|
1660
1670
|
field,
|
|
@@ -1830,6 +1840,7 @@ function interpretRelationAttribute(input) {
|
|
|
1830
1840
|
const node = findFieldAttributeNode(input.field, "relation");
|
|
1831
1841
|
if (node === void 0) return void 0;
|
|
1832
1842
|
return interpretFieldAttribute({
|
|
1843
|
+
symbols: input.symbols,
|
|
1833
1844
|
node,
|
|
1834
1845
|
spec: sqlAttributeSpecs.field.relation(),
|
|
1835
1846
|
model: input.selfModel,
|
|
@@ -2642,6 +2653,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2642
2653
|
node,
|
|
2643
2654
|
spec: sqlAttributeSpecs.model.control(),
|
|
2644
2655
|
model,
|
|
2656
|
+
symbols: input.symbolTable,
|
|
2645
2657
|
sources: input.sources,
|
|
2646
2658
|
diagnostics
|
|
2647
2659
|
});
|
|
@@ -2673,6 +2685,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2673
2685
|
node,
|
|
2674
2686
|
spec: sqlAttributeSpecs.model.id(),
|
|
2675
2687
|
model,
|
|
2688
|
+
symbols: input.symbolTable,
|
|
2676
2689
|
sources: input.sources,
|
|
2677
2690
|
diagnostics
|
|
2678
2691
|
});
|
|
@@ -2711,6 +2724,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2711
2724
|
node,
|
|
2712
2725
|
spec: sqlAttributeSpecs.model.unique(),
|
|
2713
2726
|
model,
|
|
2727
|
+
symbols: input.symbolTable,
|
|
2714
2728
|
sources: input.sources,
|
|
2715
2729
|
diagnostics
|
|
2716
2730
|
});
|
|
@@ -2738,6 +2752,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2738
2752
|
node,
|
|
2739
2753
|
spec: sqlAttributeSpecs.model.index(),
|
|
2740
2754
|
model,
|
|
2755
|
+
symbols: input.symbolTable,
|
|
2741
2756
|
sources: input.sources,
|
|
2742
2757
|
diagnostics
|
|
2743
2758
|
});
|
|
@@ -2783,6 +2798,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2783
2798
|
node,
|
|
2784
2799
|
spec: sqlAttributeSpecs.model.check(),
|
|
2785
2800
|
model,
|
|
2801
|
+
symbols: input.symbolTable,
|
|
2786
2802
|
sources: input.sources,
|
|
2787
2803
|
diagnostics
|
|
2788
2804
|
});
|
|
@@ -2819,6 +2835,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2819
2835
|
}
|
|
2820
2836
|
}),
|
|
2821
2837
|
model,
|
|
2838
|
+
symbols: input.symbolTable,
|
|
2822
2839
|
sources: input.sources,
|
|
2823
2840
|
diagnostics
|
|
2824
2841
|
});
|
|
@@ -3208,15 +3225,16 @@ function patchModelDomainFields(models, modelResolvedFields) {
|
|
|
3208
3225
|
}
|
|
3209
3226
|
return patched;
|
|
3210
3227
|
}
|
|
3211
|
-
function collectPolymorphismDeclarations(
|
|
3228
|
+
function collectPolymorphismDeclarations(identities, symbols, sources, diagnostics) {
|
|
3212
3229
|
const discriminatorDeclarations = /* @__PURE__ */ new Map();
|
|
3213
3230
|
const baseDeclarations = /* @__PURE__ */ new Map();
|
|
3214
|
-
for (const model of
|
|
3231
|
+
for (const { model, key } of identities.values()) {
|
|
3215
3232
|
const source = diagnosticSource(sources, model.node.syntax);
|
|
3216
3233
|
const discriminatorNode = findModelAttributeNode(model, "discriminator");
|
|
3217
3234
|
if (discriminatorNode !== void 0) {
|
|
3218
3235
|
const parsed = interpretModelAttribute({
|
|
3219
3236
|
node: discriminatorNode,
|
|
3237
|
+
symbols,
|
|
3220
3238
|
spec: sqlAttributeSpecs.model.discriminator(),
|
|
3221
3239
|
model,
|
|
3222
3240
|
sources,
|
|
@@ -3230,7 +3248,7 @@ function collectPolymorphismDeclarations(models, sources, diagnostics) {
|
|
|
3230
3248
|
message: `Discriminator field "${parsed.field}" on model "${model.name}" must be of type String, but is "${discField.typeName}"`,
|
|
3231
3249
|
...source.at(span)
|
|
3232
3250
|
});
|
|
3233
|
-
else discriminatorDeclarations.set(
|
|
3251
|
+
else discriminatorDeclarations.set(key, {
|
|
3234
3252
|
fieldName: parsed.field,
|
|
3235
3253
|
span,
|
|
3236
3254
|
source
|
|
@@ -3241,17 +3259,22 @@ function collectPolymorphismDeclarations(models, sources, diagnostics) {
|
|
|
3241
3259
|
if (baseNode !== void 0) {
|
|
3242
3260
|
const parsed = interpretModelAttribute({
|
|
3243
3261
|
node: baseNode,
|
|
3262
|
+
symbols,
|
|
3244
3263
|
spec: sqlAttributeSpecs.model.base(),
|
|
3245
3264
|
model,
|
|
3246
3265
|
sources,
|
|
3247
3266
|
diagnostics
|
|
3248
3267
|
});
|
|
3249
|
-
if (parsed !== void 0)
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3268
|
+
if (parsed !== void 0) {
|
|
3269
|
+
const base = identities.get(parsed.base.declaration);
|
|
3270
|
+
invariant(base !== void 0, `Resolved base model "${parsed.base.declaration.name}" is missing from the collected model identities`);
|
|
3271
|
+
baseDeclarations.set(key, {
|
|
3272
|
+
source,
|
|
3273
|
+
base,
|
|
3274
|
+
value: parsed.value,
|
|
3275
|
+
span: nodePslSpan(baseNode.syntax, sources)
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3255
3278
|
}
|
|
3256
3279
|
}
|
|
3257
3280
|
return {
|
|
@@ -3259,11 +3282,9 @@ function collectPolymorphismDeclarations(models, sources, diagnostics) {
|
|
|
3259
3282
|
baseDeclarations
|
|
3260
3283
|
};
|
|
3261
3284
|
}
|
|
3262
|
-
function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations,
|
|
3285
|
+
function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations, modelMappings, syntheticPkFieldsByVariant, stiBaseFieldsByBase, diagnostics) {
|
|
3263
3286
|
let patched = models;
|
|
3264
|
-
const
|
|
3265
|
-
for (const [baseName, fieldNames] of stiBaseFieldsByBase) {
|
|
3266
|
-
const baseKey = coordinateFor(baseName);
|
|
3287
|
+
for (const [baseKey, fieldNames] of stiBaseFieldsByBase) {
|
|
3267
3288
|
const baseModel = patched[baseKey];
|
|
3268
3289
|
if (!baseModel || fieldNames.length === 0) continue;
|
|
3269
3290
|
patched = {
|
|
@@ -3271,8 +3292,9 @@ function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations
|
|
|
3271
3292
|
[baseKey]: stripStorageOnlyDomainFields(baseModel, fieldNames)
|
|
3272
3293
|
};
|
|
3273
3294
|
}
|
|
3274
|
-
for (const [
|
|
3275
|
-
|
|
3295
|
+
for (const [modelKey, decl] of discriminatorDeclarations) {
|
|
3296
|
+
const modelName = modelMappings.get(modelKey)?.model.name;
|
|
3297
|
+
if (baseDeclarations.has(modelKey)) {
|
|
3276
3298
|
diagnostics.push({
|
|
3277
3299
|
code: "PSL_DISCRIMINATOR_AND_BASE",
|
|
3278
3300
|
message: `Model "${modelName}" cannot have both @@discriminator and @@base`,
|
|
@@ -3280,12 +3302,14 @@ function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations
|
|
|
3280
3302
|
});
|
|
3281
3303
|
continue;
|
|
3282
3304
|
}
|
|
3283
|
-
const model = patched[
|
|
3305
|
+
const model = patched[modelKey];
|
|
3284
3306
|
if (!model) continue;
|
|
3285
3307
|
const variants = {};
|
|
3286
3308
|
const seenValues = /* @__PURE__ */ new Map();
|
|
3287
|
-
for (const [
|
|
3288
|
-
if (baseDecl.
|
|
3309
|
+
for (const [variantKey, baseDecl] of baseDeclarations) {
|
|
3310
|
+
if (baseDecl.base.key !== modelKey) continue;
|
|
3311
|
+
const variantName = modelMappings.get(variantKey)?.model.name;
|
|
3312
|
+
invariant(variantName !== void 0, `Variant "${variantKey}" is missing from the model mappings`);
|
|
3289
3313
|
const existingVariant = seenValues.get(baseDecl.value);
|
|
3290
3314
|
if (existingVariant) {
|
|
3291
3315
|
diagnostics.push({
|
|
@@ -3308,39 +3332,33 @@ function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations
|
|
|
3308
3332
|
}
|
|
3309
3333
|
patched = {
|
|
3310
3334
|
...patched,
|
|
3311
|
-
[
|
|
3335
|
+
[modelKey]: {
|
|
3312
3336
|
...model,
|
|
3313
3337
|
discriminator: { field: decl.fieldName },
|
|
3314
3338
|
variants
|
|
3315
3339
|
}
|
|
3316
3340
|
};
|
|
3317
3341
|
}
|
|
3318
|
-
for (const [
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
...baseDecl.source.at(baseDecl.span)
|
|
3324
|
-
});
|
|
3325
|
-
continue;
|
|
3326
|
-
}
|
|
3327
|
-
if (!discriminatorDeclarations.has(baseDecl.baseName)) {
|
|
3342
|
+
for (const [variantKey, baseDecl] of baseDeclarations) {
|
|
3343
|
+
const variantMapping = modelMappings.get(variantKey);
|
|
3344
|
+
const variantName = variantMapping?.model.name;
|
|
3345
|
+
const baseName = baseDecl.base.model.name;
|
|
3346
|
+
if (!discriminatorDeclarations.has(baseDecl.base.key)) {
|
|
3328
3347
|
diagnostics.push({
|
|
3329
3348
|
code: "PSL_ORPHANED_BASE",
|
|
3330
|
-
message: `Model "${variantName}" declares @@base(${
|
|
3349
|
+
message: `Model "${variantName}" declares @@base(${baseName}, ...) but "${baseName}" has no @@discriminator`,
|
|
3331
3350
|
...baseDecl.source.at(baseDecl.span)
|
|
3332
3351
|
});
|
|
3333
3352
|
continue;
|
|
3334
3353
|
}
|
|
3335
|
-
if (discriminatorDeclarations.has(
|
|
3336
|
-
const variantModel = patched[
|
|
3354
|
+
if (discriminatorDeclarations.has(variantKey)) continue;
|
|
3355
|
+
const variantModel = patched[variantKey];
|
|
3337
3356
|
if (!variantModel) continue;
|
|
3338
|
-
const baseMapping = modelMappings.get(baseDecl.
|
|
3339
|
-
const variantMapping = modelMappings.get(variantName);
|
|
3357
|
+
const baseMapping = modelMappings.get(baseDecl.base.key);
|
|
3340
3358
|
const resolvedTable = variantMapping?.model.attributes.some((attr) => attr.name === "map") ?? false ? variantMapping?.tableName : baseMapping?.tableName;
|
|
3341
3359
|
const patchedVariant = {
|
|
3342
3360
|
...variantModel,
|
|
3343
|
-
base: crossRef(
|
|
3361
|
+
base: crossRef(baseName, baseDecl.base.namespaceId),
|
|
3344
3362
|
...resolvedTable ? { storage: {
|
|
3345
3363
|
...variantModel.storage,
|
|
3346
3364
|
table: resolvedTable
|
|
@@ -3348,7 +3366,7 @@ function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations
|
|
|
3348
3366
|
};
|
|
3349
3367
|
patched = {
|
|
3350
3368
|
...patched,
|
|
3351
|
-
[
|
|
3369
|
+
[variantKey]: stripStorageOnlyDomainFields(patchedVariant, syntheticPkFieldsByVariant.get(variantKey) ?? [])
|
|
3352
3370
|
};
|
|
3353
3371
|
}
|
|
3354
3372
|
return patched;
|
|
@@ -3367,16 +3385,18 @@ function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations
|
|
|
3367
3385
|
* storage table stays joinable. Single-table-inheritance variants (no own
|
|
3368
3386
|
* table) are left untouched.
|
|
3369
3387
|
*/
|
|
3370
|
-
function materializeMtiVariantStorageLinks(modelNodes, baseDeclarations,
|
|
3371
|
-
const
|
|
3388
|
+
function materializeMtiVariantStorageLinks(modelNodes, baseDeclarations, stiVariantKeys, defaultNamespaceId) {
|
|
3389
|
+
const keyOf = (node) => modelCoordinateKey(node.namespaceId ?? defaultNamespaceId, node.modelName);
|
|
3390
|
+
const nodeByModel = new Map(modelNodes.map((node) => [keyOf(node), node]));
|
|
3372
3391
|
const syntheticPkFieldsByVariant = /* @__PURE__ */ new Map();
|
|
3373
3392
|
return {
|
|
3374
3393
|
modelNodes: modelNodes.map((node) => {
|
|
3375
|
-
const
|
|
3394
|
+
const variantKey = keyOf(node);
|
|
3395
|
+
const baseDecl = baseDeclarations.get(variantKey);
|
|
3376
3396
|
if (!baseDecl) return node;
|
|
3377
|
-
const baseNode = nodeByModel.get(baseDecl.
|
|
3397
|
+
const baseNode = nodeByModel.get(baseDecl.base.key);
|
|
3378
3398
|
if (!baseNode) return node;
|
|
3379
|
-
if (
|
|
3399
|
+
if (stiVariantKeys.has(variantKey)) return node;
|
|
3380
3400
|
const basePrimaryKey = baseNode.id;
|
|
3381
3401
|
if (!basePrimaryKey || basePrimaryKey.columns.length === 0) return node;
|
|
3382
3402
|
const existingColumns = new Set(node.fields.map((field) => field.columnName));
|
|
@@ -3393,7 +3413,7 @@ function materializeMtiVariantStorageLinks(modelNodes, baseDeclarations, stiVari
|
|
|
3393
3413
|
});
|
|
3394
3414
|
}
|
|
3395
3415
|
if (linkFields.length === 0) return node;
|
|
3396
|
-
syntheticPkFieldsByVariant.set(
|
|
3416
|
+
syntheticPkFieldsByVariant.set(variantKey, linkFields.map((field) => field.fieldName));
|
|
3397
3417
|
const foreignKey = {
|
|
3398
3418
|
columns: basePrimaryKey.columns,
|
|
3399
3419
|
references: {
|
|
@@ -3435,21 +3455,22 @@ function materializeMtiVariantStorageLinks(modelNodes, baseDeclarations, stiVari
|
|
|
3435
3455
|
* MTI link guard; surfacing them as diagnostics is tracked separately
|
|
3436
3456
|
* (TML-2827).
|
|
3437
3457
|
*/
|
|
3438
|
-
function materializeStiVariantStorageColumns(modelNodes, baseDeclarations,
|
|
3439
|
-
if (
|
|
3458
|
+
function materializeStiVariantStorageColumns(modelNodes, baseDeclarations, stiVariantKeys, defaultNamespaceId) {
|
|
3459
|
+
if (stiVariantKeys.size === 0) return {
|
|
3440
3460
|
modelNodes: [...modelNodes],
|
|
3441
3461
|
stiBaseFieldsByBase: /* @__PURE__ */ new Map()
|
|
3442
3462
|
};
|
|
3443
|
-
const
|
|
3463
|
+
const keyOf = (node) => modelCoordinateKey(node.namespaceId ?? defaultNamespaceId, node.modelName);
|
|
3464
|
+
const nodeByModel = new Map(modelNodes.map((node) => [keyOf(node), node]));
|
|
3444
3465
|
const stiColumnsByBase = /* @__PURE__ */ new Map();
|
|
3445
|
-
for (const
|
|
3446
|
-
const variantNode = nodeByModel.get(
|
|
3447
|
-
const baseDecl = baseDeclarations.get(
|
|
3466
|
+
for (const variantKey of stiVariantKeys) {
|
|
3467
|
+
const variantNode = nodeByModel.get(variantKey);
|
|
3468
|
+
const baseDecl = baseDeclarations.get(variantKey);
|
|
3448
3469
|
if (!variantNode || !baseDecl) continue;
|
|
3449
|
-
const baseNode = nodeByModel.get(baseDecl.
|
|
3470
|
+
const baseNode = nodeByModel.get(baseDecl.base.key);
|
|
3450
3471
|
if (!baseNode) continue;
|
|
3451
3472
|
const baseColumns = new Set(baseNode.fields.map((field) => field.columnName));
|
|
3452
|
-
const claimed = stiColumnsByBase.get(baseDecl.
|
|
3473
|
+
const claimed = stiColumnsByBase.get(baseDecl.base.key) ?? [];
|
|
3453
3474
|
const claimedColumns = new Set(claimed.map((field) => field.columnName));
|
|
3454
3475
|
for (const field of variantNode.fields) {
|
|
3455
3476
|
if (baseColumns.has(field.columnName) || claimedColumns.has(field.columnName)) continue;
|
|
@@ -3459,17 +3480,17 @@ function materializeStiVariantStorageColumns(modelNodes, baseDeclarations, stiVa
|
|
|
3459
3480
|
nullable: true
|
|
3460
3481
|
});
|
|
3461
3482
|
}
|
|
3462
|
-
stiColumnsByBase.set(baseDecl.
|
|
3483
|
+
stiColumnsByBase.set(baseDecl.base.key, claimed);
|
|
3463
3484
|
}
|
|
3464
3485
|
const stiBaseFieldsByBase = /* @__PURE__ */ new Map();
|
|
3465
3486
|
for (const [baseName, columns] of stiColumnsByBase) stiBaseFieldsByBase.set(baseName, columns.map((field) => field.fieldName));
|
|
3466
3487
|
return {
|
|
3467
3488
|
modelNodes: modelNodes.map((node) => {
|
|
3468
|
-
if (
|
|
3489
|
+
if (stiVariantKeys.has(keyOf(node))) return {
|
|
3469
3490
|
...node,
|
|
3470
3491
|
sharesBaseTable: true
|
|
3471
3492
|
};
|
|
3472
|
-
const stiColumns = stiColumnsByBase.get(node
|
|
3493
|
+
const stiColumns = stiColumnsByBase.get(keyOf(node));
|
|
3473
3494
|
if (!stiColumns || stiColumns.length === 0) return node;
|
|
3474
3495
|
return {
|
|
3475
3496
|
...node,
|
|
@@ -3637,7 +3658,7 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3637
3658
|
} },
|
|
3638
3659
|
warnings: authoringWarnings
|
|
3639
3660
|
};
|
|
3640
|
-
const earlyModelMappingsByCoordinate = buildModelMappings(modelEntries, defaultNamespaceId, createPslDiagnosticCollector(input.sources), input.sources);
|
|
3661
|
+
const earlyModelMappingsByCoordinate = buildModelMappings(input.symbolTable, modelEntries, defaultNamespaceId, createPslDiagnosticCollector(input.sources), input.sources);
|
|
3641
3662
|
const composedPslBlockDescriptors = input.authoringContributions?.pslBlockDescriptors ?? {};
|
|
3642
3663
|
const namespaceExtensionEntities = /* @__PURE__ */ new Map();
|
|
3643
3664
|
const mergeNamespaceExtensionEntities = (nsId, entities, blocks) => {
|
|
@@ -3710,7 +3731,7 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3710
3731
|
diagnostics
|
|
3711
3732
|
});
|
|
3712
3733
|
const storageTypes = { ...namedTypeResult.storageTypes };
|
|
3713
|
-
const modelMappingsByCoordinate = buildModelMappings(modelEntries, defaultNamespaceId, diagnostics, input.sources);
|
|
3734
|
+
const modelMappingsByCoordinate = buildModelMappings(input.symbolTable, modelEntries, defaultNamespaceId, diagnostics, input.sources);
|
|
3714
3735
|
const modelMappings = /* @__PURE__ */ new Map();
|
|
3715
3736
|
for (const mapping of modelMappingsByCoordinate.values()) modelMappings.set(mapping.model.name, mapping);
|
|
3716
3737
|
const modelNodes = [];
|
|
@@ -3801,25 +3822,33 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3801
3822
|
if (existing) existing.push(...relations);
|
|
3802
3823
|
else modelRelations.set(modelName, [...relations]);
|
|
3803
3824
|
}
|
|
3804
|
-
const { discriminatorDeclarations, baseDeclarations } = collectPolymorphismDeclarations(
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3825
|
+
const { discriminatorDeclarations, baseDeclarations } = collectPolymorphismDeclarations(new Map(modelEntries.map(({ model, namespaceId }) => {
|
|
3826
|
+
const resolvedNamespaceId = namespaceId ?? defaultNamespaceId;
|
|
3827
|
+
return [model, {
|
|
3828
|
+
model,
|
|
3829
|
+
namespaceId: resolvedNamespaceId,
|
|
3830
|
+
key: modelCoordinateKey(resolvedNamespaceId, model.name)
|
|
3831
|
+
}];
|
|
3832
|
+
})), input.symbolTable, input.sources, diagnostics);
|
|
3833
|
+
const stiVariantKeys = /* @__PURE__ */ new Set();
|
|
3834
|
+
for (const variantKey of baseDeclarations.keys()) if (!(modelMappingsByCoordinate.get(variantKey)?.model.attributes.some((attr) => attr.name === "map") ?? false)) stiVariantKeys.add(variantKey);
|
|
3835
|
+
for (const variantKey of stiVariantKeys) {
|
|
3836
|
+
const variantMapping = modelMappingsByCoordinate.get(variantKey);
|
|
3809
3837
|
if (variantMapping === void 0) continue;
|
|
3810
|
-
const
|
|
3811
|
-
|
|
3838
|
+
const variantName = variantMapping.model.name;
|
|
3839
|
+
const baseDecl = baseDeclarations.get(variantKey);
|
|
3840
|
+
invariant(baseDecl !== void 0, `stiVariantKeys is derived from baseDeclarations.keys(), so "${variantName}" must have a base declaration`);
|
|
3812
3841
|
for (const attribute of variantMapping.model.node.attributes()) {
|
|
3813
3842
|
if (attribute.name()?.isSimpleName("check") !== true) continue;
|
|
3814
3843
|
diagnostics.push({
|
|
3815
3844
|
code: PSL_CHECK_ON_STI_VARIANT,
|
|
3816
|
-
message: `Model "${variantName}" declares "@@check", but it shares its base model "${baseDecl.
|
|
3845
|
+
message: `Model "${variantName}" declares "@@check", but it shares its base model "${baseDecl.base.model.name}"'s storage table (single-table inheritance via @@base) and has no table of its own to declare a check constraint on. Declare the check on "${baseDecl.base.model.name}" instead.`,
|
|
3817
3846
|
...diagnosticSource(input.sources, attribute.syntax).at(nodePslSpan(attribute.syntax, input.sources))
|
|
3818
3847
|
});
|
|
3819
3848
|
}
|
|
3820
3849
|
}
|
|
3821
|
-
const { modelNodes: mtiLinkedModelNodes, syntheticPkFieldsByVariant } = materializeMtiVariantStorageLinks(modelNodes, baseDeclarations,
|
|
3822
|
-
const { modelNodes: stiColumnModelNodes, stiBaseFieldsByBase } = materializeStiVariantStorageColumns(mtiLinkedModelNodes, baseDeclarations,
|
|
3850
|
+
const { modelNodes: mtiLinkedModelNodes, syntheticPkFieldsByVariant } = materializeMtiVariantStorageLinks(modelNodes, baseDeclarations, stiVariantKeys, defaultNamespaceId);
|
|
3851
|
+
const { modelNodes: stiColumnModelNodes, stiBaseFieldsByBase } = materializeStiVariantStorageColumns(mtiLinkedModelNodes, baseDeclarations, stiVariantKeys, defaultNamespaceId);
|
|
3823
3852
|
const valueObjects = buildValueObjects({
|
|
3824
3853
|
compositeTypes,
|
|
3825
3854
|
enumTypeDescriptors: allEnumTypeDescriptors,
|
|
@@ -3883,13 +3912,12 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3883
3912
|
}
|
|
3884
3913
|
let patchedModels = patchModelDomainFields(modelsForPatch, modelResolvedFields);
|
|
3885
3914
|
const polyDiagnostics = createPslDiagnosticCollector(input.sources);
|
|
3886
|
-
patchedModels = resolvePolymorphism(patchedModels, discriminatorDeclarations, baseDeclarations,
|
|
3915
|
+
patchedModels = resolvePolymorphism(patchedModels, discriminatorDeclarations, baseDeclarations, modelMappingsByCoordinate, syntheticPkFieldsByVariant, stiBaseFieldsByBase, polyDiagnostics);
|
|
3887
3916
|
if (polyDiagnostics.length > 0) return notOk({
|
|
3888
3917
|
summary: "PSL to SQL contract interpretation failed",
|
|
3889
3918
|
diagnostics: polyDiagnostics.toExternal()
|
|
3890
3919
|
});
|
|
3891
|
-
const
|
|
3892
|
-
const filteredRoots = Object.fromEntries(Object.entries(contract.roots).filter(([, crossReference]) => !variantModelNames.has(crossReference.model)));
|
|
3920
|
+
const filteredRoots = Object.fromEntries(Object.entries(contract.roots).filter(([, crossReference]) => !baseDeclarations.has(modelCoordinateKey(crossReference.namespace, crossReference.model))));
|
|
3893
3921
|
return ok({
|
|
3894
3922
|
...contract,
|
|
3895
3923
|
roots: filteredRoots,
|
|
@@ -3904,4 +3932,4 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3904
3932
|
//#endregion
|
|
3905
3933
|
export { interpretPslDocumentToSqlContract as a, resolveFieldTypeDescriptor as c, indexFkRelations as i, buildEntityTypesByDiscriminator as n, normalizeReferentialAction as o, entryForTag as r, readDataTypeDefault as s, applyBackrelationCandidates as t };
|
|
3906
3934
|
|
|
3907
|
-
//# sourceMappingURL=interpreter-
|
|
3935
|
+
//# sourceMappingURL=interpreter-BIBwrA2w-DAiNN30m.mjs.map
|