@prisma/orm-family-sql 8.0.0-rc.11-dev.33 → 8.0.0-rc.11-dev.35
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/contract-prisma7__provider.mjs +58 -44
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.d.mts +5 -5
- package/dist/contract-psl.d.mts.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +2 -2
- 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 +11 -20
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/{control-BICEwXxs.mjs → control-liGaqQ0q.mjs} +26 -27
- package/dist/control-liGaqQ0q.mjs.map +1 -0
- package/dist/diff-B16bL_IR.mjs.map +1 -1
- package/dist/family.mjs +5 -5
- package/dist/family__control.mjs +2 -2
- package/dist/family__diff.mjs +1 -1
- package/dist/family__ir.mjs +1 -1
- package/dist/family__pack.mjs +1 -1
- package/dist/family__psl-infer.mjs +1 -1
- package/dist/family__verify.mjs +1 -1
- package/dist/{interpreter-9Ru2E-MH-CQdWmnh8.mjs → interpreter-C8N5eRW1-LGv-WI9y.mjs} +280 -336
- package/dist/interpreter-C8N5eRW1-LGv-WI9y.mjs.map +1 -0
- package/dist/ir-I-xciGUH.mjs.map +1 -1
- package/dist/{psl-infer-DyRJ8dw6.mjs → psl-infer-CsCbcmXS.mjs} +4 -2
- package/dist/psl-infer-CsCbcmXS.mjs.map +1 -0
- package/dist/{schema-verify-C_PEdlAr-CmXrFuW1.mjs → schema-verify-CrvQZ5V8-BfrNHJbX.mjs} +3 -3
- package/dist/schema-verify-CrvQZ5V8-BfrNHJbX.mjs.map +1 -0
- package/dist/{sql-attribute-specs-CHSP1wKs-D5T2TZQ8.mjs → sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs} +11 -16
- package/dist/sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs.map +1 -0
- package/dist/{sql-contract-serializer-Bxu4a5oQ-CNy5ONMn.mjs → sql-contract-serializer-C4HbCKFe-BD1Fx4JX.mjs} +6 -6
- package/dist/sql-contract-serializer-C4HbCKFe-BD1Fx4JX.mjs.map +1 -0
- package/dist/{verify-ChiDeTk8-HEewdjrM.mjs → verify-BVk5bjdH-BXgGLM2U.mjs} +6 -5
- package/dist/verify-BVk5bjdH-BXgGLM2U.mjs.map +1 -0
- package/package.json +18 -18
- package/dist/control-BICEwXxs.mjs.map +0 -1
- package/dist/interpreter-9Ru2E-MH-CQdWmnh8.mjs.map +0 -1
- package/dist/psl-infer-DyRJ8dw6.mjs.map +0 -1
- package/dist/schema-verify-C_PEdlAr-CmXrFuW1.mjs.map +0 -1
- package/dist/sql-attribute-specs-CHSP1wKs-D5T2TZQ8.mjs.map +0 -1
- package/dist/sql-contract-serializer-Bxu4a5oQ-CNy5ONMn.mjs.map +0 -1
- package/dist/verify-ChiDeTk8-HEewdjrM.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { d as validateSqlStorageConsistency, l as validateModelStorageReferences } from "./validators-y6eLjhcb.mjs";
|
|
2
2
|
import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
|
|
3
3
|
import { n as buildSqlContractFromDefinition, t as applySqlSpecifierControlPolicy } from "./derived-checks-DGjY5t7S-DofD5V_2.mjs";
|
|
4
|
-
import { a as normalizeReferentialAction, n as buildEntityTypesByDiscriminator, o as numberLiteralDefault, r as indexFkRelations, s as resolveFieldTypeDescriptor, t as applyBackrelationCandidates } from "./interpreter-
|
|
4
|
+
import { a as normalizeReferentialAction, n as buildEntityTypesByDiscriminator, o as numberLiteralDefault, r as indexFkRelations, s as resolveFieldTypeDescriptor, t as applyBackrelationCandidates } from "./interpreter-C8N5eRW1-LGv-WI9y.mjs";
|
|
5
5
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
6
6
|
import { collectScalarTypeConstructors, instantiateAuthoringEntityType } from "@prisma/orm-framework/components/authoring";
|
|
7
7
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
@@ -9,10 +9,10 @@ import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
|
9
9
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
10
10
|
import { validateContractDomain } from "@prisma/orm-framework/contract/validate-domain";
|
|
11
11
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
12
|
-
import { buildSymbolTable, keywordPslSpan, nodePslSpan, rangeToPslSpan, readResolvedAttribute, readResolvedAttributes } from "@prisma/orm-framework/psl-parser";
|
|
13
12
|
import { ArrayLiteralAst, BooleanLiteralExprAst, FunctionCallAst, IdentifierAst, NumberLiteralExprAst, StringLiteralExprAst, parse, printSyntax } from "@prisma/orm-framework/psl-parser/syntax";
|
|
14
13
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
15
14
|
import { basename, dirname, extname, join, normalize } from "pathe";
|
|
15
|
+
import { buildSymbolTable, createPslDiagnosticCollector, keywordPslSpan, nodePslSpan, readResolvedAttribute, readResolvedAttributes } from "@prisma/orm-framework/psl-parser";
|
|
16
16
|
import { fkRelationPairKey } from "@prisma/orm-framework/psl-parser/interpret";
|
|
17
17
|
//#region ../../../2-sql/2-authoring/contract-prisma7/dist/provider.mjs
|
|
18
18
|
function prisma7Diagnostic(code, message, sourceId, span) {
|
|
@@ -706,29 +706,35 @@ function lowerRelations(models, naming, diagnostics) {
|
|
|
706
706
|
modelIdColumns.set(key, ["A", "B"]);
|
|
707
707
|
modelUniqueColumnSets.set(key, [["A", "B"]]);
|
|
708
708
|
}
|
|
709
|
-
const pairingDiagnostics = [];
|
|
710
709
|
const candidatesBySourceId = /* @__PURE__ */ new Map();
|
|
711
710
|
for (const candidate of candidates) {
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
candidatesBySourceId.
|
|
715
|
-
|
|
711
|
+
const model = models.get(candidate.modelName);
|
|
712
|
+
if (model === void 0) continue;
|
|
713
|
+
const group = candidatesBySourceId.get(model.sourceId) ?? {
|
|
714
|
+
sources: model.sources,
|
|
715
|
+
candidates: []
|
|
716
|
+
};
|
|
717
|
+
candidatesBySourceId.set(model.sourceId, group);
|
|
718
|
+
group.candidates.push(candidate);
|
|
719
|
+
}
|
|
720
|
+
for (const { sources, candidates: backrelationCandidates } of candidatesBySourceId.values()) {
|
|
721
|
+
const pairingDiagnostics = createPslDiagnosticCollector(sources);
|
|
722
|
+
applyBackrelationCandidates({
|
|
723
|
+
backrelationCandidates,
|
|
724
|
+
fkRelationsByPair,
|
|
725
|
+
invalidFkPairings,
|
|
726
|
+
fkRelationsByDeclaringModel,
|
|
727
|
+
modelIdColumns,
|
|
728
|
+
modelUniqueColumnSets,
|
|
729
|
+
modelRelations,
|
|
730
|
+
diagnostics: pairingDiagnostics,
|
|
731
|
+
sources
|
|
732
|
+
});
|
|
733
|
+
for (const diagnostic of pairingDiagnostics.toExternal()) diagnostics.push(RELATION_PAIRING_CODES.has(diagnostic.code) ? {
|
|
734
|
+
...diagnostic,
|
|
735
|
+
code: "PSL.PRISMA7_RELATION_UNRESOLVED"
|
|
736
|
+
} : diagnostic);
|
|
716
737
|
}
|
|
717
|
-
for (const [sourceId, backrelationCandidates] of candidatesBySourceId) applyBackrelationCandidates({
|
|
718
|
-
backrelationCandidates,
|
|
719
|
-
fkRelationsByPair,
|
|
720
|
-
invalidFkPairings,
|
|
721
|
-
fkRelationsByDeclaringModel,
|
|
722
|
-
modelIdColumns,
|
|
723
|
-
modelUniqueColumnSets,
|
|
724
|
-
modelRelations,
|
|
725
|
-
diagnostics: pairingDiagnostics,
|
|
726
|
-
sourceId
|
|
727
|
-
});
|
|
728
|
-
for (const diagnostic of pairingDiagnostics) diagnostics.push(RELATION_PAIRING_CODES.has(diagnostic.code) ? {
|
|
729
|
-
...diagnostic,
|
|
730
|
-
code: "PSL.PRISMA7_RELATION_UNRESOLVED"
|
|
731
|
-
} : diagnostic);
|
|
732
738
|
const relations = /* @__PURE__ */ new Map();
|
|
733
739
|
for (const [modelName, nodes] of modelRelations) relations.set(modelName, [...nodes].sort((left, right) => left.fieldName.localeCompare(right.fieldName)));
|
|
734
740
|
return {
|
|
@@ -880,17 +886,17 @@ function interpretPrisma7Documents(input) {
|
|
|
880
886
|
});
|
|
881
887
|
return false;
|
|
882
888
|
};
|
|
883
|
-
for (const { document, sourceFile, sourceId } of input.documents) {
|
|
884
|
-
const {
|
|
885
|
-
document,
|
|
886
|
-
|
|
889
|
+
for (const { document, sources, sourceFile, sourceId } of input.documents) {
|
|
890
|
+
const { symbolTable, diagnostics: tableDiagnostics } = buildSymbolTable({
|
|
891
|
+
documents: [document],
|
|
892
|
+
sources,
|
|
887
893
|
pslBlockDescriptors: {}
|
|
888
894
|
});
|
|
889
895
|
for (const diagnostic of tableDiagnostics) diagnostics.push({
|
|
890
896
|
code: diagnostic.code,
|
|
891
897
|
message: diagnostic.message,
|
|
892
898
|
sourceId,
|
|
893
|
-
span: rangeToPslSpan(diagnostic.range
|
|
899
|
+
span: sourceFile.rangeToPslSpan(diagnostic.range)
|
|
894
900
|
});
|
|
895
901
|
const unsupported = (keyword, span) => {
|
|
896
902
|
diagnostics.push({
|
|
@@ -900,11 +906,12 @@ function interpretPrisma7Documents(input) {
|
|
|
900
906
|
span
|
|
901
907
|
});
|
|
902
908
|
};
|
|
903
|
-
for (const block of Object.values(
|
|
909
|
+
for (const block of Object.values(symbolTable.topLevel.blocks)) switch (block.keyword) {
|
|
904
910
|
case "datasource":
|
|
905
911
|
datasources.push({
|
|
906
912
|
block,
|
|
907
913
|
sourceId,
|
|
914
|
+
sources,
|
|
908
915
|
sourceFile
|
|
909
916
|
});
|
|
910
917
|
break;
|
|
@@ -913,20 +920,21 @@ function interpretPrisma7Documents(input) {
|
|
|
913
920
|
if (claimName("enum", block.name, sourceId, block.span)) enumBlocks.push({
|
|
914
921
|
block,
|
|
915
922
|
sourceId,
|
|
923
|
+
sources,
|
|
916
924
|
sourceFile
|
|
917
925
|
});
|
|
918
926
|
break;
|
|
919
927
|
case "view":
|
|
920
|
-
diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_VIEW_UNSUPPORTED", `View "${block.name}" is not supported; Prisma 8 has no views. Remove the view or replace it with a model over the underlying table.`, sourceId, keywordPslSpan(block.node.syntax, block.keyword,
|
|
928
|
+
diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_VIEW_UNSUPPORTED", `View "${block.name}" is not supported; Prisma 8 has no views. Remove the view or replace it with a model over the underlying table.`, sourceId, keywordPslSpan(block.node.syntax, block.keyword, sources)));
|
|
921
929
|
break;
|
|
922
|
-
default: unsupported(block.keyword, keywordPslSpan(block.node.syntax, block.keyword,
|
|
930
|
+
default: unsupported(block.keyword, keywordPslSpan(block.node.syntax, block.keyword, sources));
|
|
923
931
|
}
|
|
924
|
-
for (const namespace of Object.values(
|
|
925
|
-
for (const compositeType of Object.values(
|
|
926
|
-
for (const namedType of Object.values(
|
|
927
|
-
for (const symbol of Object.values(
|
|
932
|
+
for (const namespace of Object.values(symbolTable.topLevel.namespaces)) for (const { span } of namespace.declarations) unsupported("namespace", span);
|
|
933
|
+
for (const compositeType of Object.values(symbolTable.topLevel.compositeTypes)) unsupported("type", compositeType.span);
|
|
934
|
+
for (const namedType of Object.values(symbolTable.topLevel.namedTypes)) unsupported("types", namedType.span);
|
|
935
|
+
for (const symbol of Object.values(symbolTable.topLevel.models)) {
|
|
928
936
|
if (!claimName("model", symbol.name, sourceId, symbol.span)) continue;
|
|
929
|
-
const declaration = readModelDeclaration(symbol, sourceId, defaultNamespaceId, binding.indexTypes, diagnostics);
|
|
937
|
+
const declaration = readModelDeclaration(symbol, sourceId, sources, defaultNamespaceId, binding.indexTypes, diagnostics);
|
|
930
938
|
if (declaration === void 0) ignoredModels.add(symbol.name);
|
|
931
939
|
else models.push(declaration);
|
|
932
940
|
}
|
|
@@ -979,6 +987,7 @@ function interpretPrisma7Documents(input) {
|
|
|
979
987
|
tableSpan: build.declaration.symbol.attributes.find((attribute) => attribute.name === "map")?.span ?? build.declaration.symbol.span,
|
|
980
988
|
namespaceId: build.declaration.namespaceId,
|
|
981
989
|
sourceId: build.declaration.sourceId,
|
|
990
|
+
sources: build.declaration.sources,
|
|
982
991
|
columns: build.columns,
|
|
983
992
|
ignoredFields: build.ignoredFields,
|
|
984
993
|
ignoredRelationFields: build.ignoredRelationFields,
|
|
@@ -1123,7 +1132,7 @@ function keyColumns(model, fieldNames) {
|
|
|
1123
1132
|
}
|
|
1124
1133
|
return columns;
|
|
1125
1134
|
}
|
|
1126
|
-
function readModelDeclaration(symbol, sourceId, defaultNamespaceId, indexTypes, diagnostics) {
|
|
1135
|
+
function readModelDeclaration(symbol, sourceId, sources, defaultNamespaceId, indexTypes, diagnostics) {
|
|
1127
1136
|
if (symbol.attributes.some((attribute) => attribute.name === "ignore")) return void 0;
|
|
1128
1137
|
let tableName = symbol.name;
|
|
1129
1138
|
let namespaceId = defaultNamespaceId;
|
|
@@ -1157,6 +1166,7 @@ function readModelDeclaration(symbol, sourceId, defaultNamespaceId, indexTypes,
|
|
|
1157
1166
|
return {
|
|
1158
1167
|
symbol,
|
|
1159
1168
|
sourceId,
|
|
1169
|
+
sources,
|
|
1160
1170
|
namespaceId,
|
|
1161
1171
|
tableName,
|
|
1162
1172
|
id,
|
|
@@ -1175,10 +1185,10 @@ function requireStringArgument(attribute, owner, sourceId, diagnostics) {
|
|
|
1175
1185
|
return value;
|
|
1176
1186
|
}
|
|
1177
1187
|
function readEnumDeclaration(source, defaultNamespaceId, diagnostics) {
|
|
1178
|
-
const { block, sourceId,
|
|
1188
|
+
const { block, sourceId, sources } = source;
|
|
1179
1189
|
let typeName = block.name;
|
|
1180
1190
|
let namespaceId = defaultNamespaceId;
|
|
1181
|
-
for (const attribute of readResolvedAttributes(block.node.attributes(),
|
|
1191
|
+
for (const attribute of readResolvedAttributes(block.node.attributes(), sources)) switch (attribute.name) {
|
|
1182
1192
|
case "map":
|
|
1183
1193
|
typeName = requireStringArgument(attribute, block.name, sourceId, diagnostics) ?? typeName;
|
|
1184
1194
|
break;
|
|
@@ -1192,9 +1202,9 @@ function readEnumDeclaration(source, defaultNamespaceId, diagnostics) {
|
|
|
1192
1202
|
const name = entry.key()?.name();
|
|
1193
1203
|
if (name === void 0) continue;
|
|
1194
1204
|
let value = name;
|
|
1195
|
-
const span = nodePslSpan(entry.syntax,
|
|
1205
|
+
const span = nodePslSpan(entry.syntax, sources);
|
|
1196
1206
|
for (const attributeNode of entry.attributes()) {
|
|
1197
|
-
const attribute = readResolvedAttribute(attributeNode,
|
|
1207
|
+
const attribute = readResolvedAttribute(attributeNode, sources);
|
|
1198
1208
|
if (attribute.name === "map") value = requireStringArgument(attribute, `${block.name}.${name}`, sourceId, diagnostics) ?? value;
|
|
1199
1209
|
else diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_UNKNOWN_ATTRIBUTE", `Enum member "${block.name}.${name}": attribute "@${attribute.name}" is not supported by the Prisma 7 contract source.`, sourceId, attribute.span));
|
|
1200
1210
|
}
|
|
@@ -1434,6 +1444,7 @@ function readField(args) {
|
|
|
1434
1444
|
};
|
|
1435
1445
|
}
|
|
1436
1446
|
const namespaceExtensionEntities = args.namespaceEntities.get(model.namespaceId);
|
|
1447
|
+
const typeDiagnostics = createPslDiagnosticCollector(model.sources);
|
|
1437
1448
|
const resolved = resolveFieldTypeDescriptor({
|
|
1438
1449
|
field: {
|
|
1439
1450
|
...field,
|
|
@@ -1446,13 +1457,14 @@ function readField(args) {
|
|
|
1446
1457
|
composedExtensions: args.composedExtensions,
|
|
1447
1458
|
familyId: binding.target.familyId,
|
|
1448
1459
|
targetId: binding.target.targetId,
|
|
1449
|
-
diagnostics,
|
|
1450
|
-
|
|
1460
|
+
diagnostics: typeDiagnostics,
|
|
1461
|
+
sources: model.sources,
|
|
1451
1462
|
entityLabel: label,
|
|
1452
1463
|
namespaceId: model.namespaceId,
|
|
1453
1464
|
...ifDefined("namespaceExtensionEntities", namespaceExtensionEntities),
|
|
1454
1465
|
codecLookup: input.codecLookup
|
|
1455
1466
|
});
|
|
1467
|
+
diagnostics.push(...typeDiagnostics.toExternal());
|
|
1456
1468
|
if (!resolved.ok) {
|
|
1457
1469
|
if (!resolved.alreadyReported) diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_UNSUPPORTED_TYPE", `${label} type "${field.typeName}" could not be resolved against target "${binding.target.targetId}".`, sourceId, field.span));
|
|
1458
1470
|
return;
|
|
@@ -1517,7 +1529,7 @@ function mapParseDiagnostics(diagnostics, sourceFile, sourceId) {
|
|
|
1517
1529
|
code: diagnostic.code,
|
|
1518
1530
|
message: diagnostic.message,
|
|
1519
1531
|
sourceId,
|
|
1520
|
-
span: rangeToPslSpan(diagnostic.range
|
|
1532
|
+
span: sourceFile.rangeToPslSpan(diagnostic.range)
|
|
1521
1533
|
}));
|
|
1522
1534
|
}
|
|
1523
1535
|
/**
|
|
@@ -1603,10 +1615,12 @@ function prisma7Contract(schemaPath, options) {
|
|
|
1603
1615
|
}
|
|
1604
1616
|
});
|
|
1605
1617
|
}
|
|
1606
|
-
const { document,
|
|
1618
|
+
const { document, sources, diagnostics } = parse(schema, file.sourceId, { grammar: "prisma7" });
|
|
1619
|
+
const sourceFile = sources.sourceFileFor(document.syntax);
|
|
1607
1620
|
seedDiagnostics.push(...mapParseDiagnostics(diagnostics, sourceFile, file.sourceId));
|
|
1608
1621
|
documents.push({
|
|
1609
1622
|
document,
|
|
1623
|
+
sources,
|
|
1610
1624
|
sourceFile,
|
|
1611
1625
|
sourceId: file.sourceId
|
|
1612
1626
|
});
|