@prisma-next/sql-contract-psl 0.11.0-dev.7 → 0.11.0-dev.70
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/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{interpreter-fVwMptxi.mjs → interpreter-DTnnPYbb.mjs} +18 -8
- package/dist/interpreter-DTnnPYbb.mjs.map +1 -0
- package/dist/provider.d.mts.map +1 -1
- package/dist/provider.mjs +1 -1
- package/dist/provider.mjs.map +1 -1
- package/package.json +12 -12
- package/src/interpreter.ts +44 -8
- package/dist/interpreter-fVwMptxi.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-contract-psl",
|
|
3
|
-
"version": "0.11.0-dev.
|
|
3
|
+
"version": "0.11.0-dev.70",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "PSL-to-SQL ContractIR interpreter for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/config": "0.11.0-dev.
|
|
10
|
-
"@prisma-next/contract": "0.11.0-dev.
|
|
11
|
-
"@prisma-next/framework-components": "0.11.0-dev.
|
|
12
|
-
"@prisma-next/psl-parser": "0.11.0-dev.
|
|
13
|
-
"@prisma-next/sql-contract": "0.11.0-dev.
|
|
14
|
-
"@prisma-next/sql-contract-ts": "0.11.0-dev.
|
|
15
|
-
"@prisma-next/utils": "0.11.0-dev.
|
|
9
|
+
"@prisma-next/config": "0.11.0-dev.70",
|
|
10
|
+
"@prisma-next/contract": "0.11.0-dev.70",
|
|
11
|
+
"@prisma-next/framework-components": "0.11.0-dev.70",
|
|
12
|
+
"@prisma-next/psl-parser": "0.11.0-dev.70",
|
|
13
|
+
"@prisma-next/sql-contract": "0.11.0-dev.70",
|
|
14
|
+
"@prisma-next/sql-contract-ts": "0.11.0-dev.70",
|
|
15
|
+
"@prisma-next/utils": "0.11.0-dev.70",
|
|
16
16
|
"pathe": "^2.0.3"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@prisma-next/contract-authoring": "0.11.0-dev.
|
|
20
|
-
"@prisma-next/test-utils": "0.11.0-dev.
|
|
21
|
-
"@prisma-next/tsconfig": "0.11.0-dev.
|
|
22
|
-
"@prisma-next/tsdown": "0.11.0-dev.
|
|
19
|
+
"@prisma-next/contract-authoring": "0.11.0-dev.70",
|
|
20
|
+
"@prisma-next/test-utils": "0.11.0-dev.70",
|
|
21
|
+
"@prisma-next/tsconfig": "0.11.0-dev.70",
|
|
22
|
+
"@prisma-next/tsdown": "0.11.0-dev.70",
|
|
23
23
|
"arktype": "^2.2.0",
|
|
24
24
|
"tsdown": "0.22.0",
|
|
25
25
|
"typescript": "5.9.3",
|
package/src/interpreter.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
ContractModel,
|
|
10
10
|
ContractValueObject,
|
|
11
11
|
} from '@prisma-next/contract/types';
|
|
12
|
+
import { crossRef } from '@prisma-next/contract/types';
|
|
12
13
|
import type {
|
|
13
14
|
AuthoringContributions,
|
|
14
15
|
AuthoringEntityContext,
|
|
@@ -22,6 +23,7 @@ import type {
|
|
|
22
23
|
MutationDefaultGeneratorDescriptor,
|
|
23
24
|
} from '@prisma-next/framework-components/control';
|
|
24
25
|
import type { Namespace } from '@prisma-next/framework-components/ir';
|
|
26
|
+
import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
|
|
25
27
|
import type {
|
|
26
28
|
ParsePslDocumentResult,
|
|
27
29
|
PslAttribute,
|
|
@@ -1303,6 +1305,7 @@ function resolvePolymorphism(
|
|
|
1303
1305
|
baseDeclarations: Map<string, BaseDeclaration>,
|
|
1304
1306
|
modelNames: Set<string>,
|
|
1305
1307
|
modelMappings: ReadonlyMap<string, ModelNameMapping>,
|
|
1308
|
+
modelNamespaceIds: ReadonlyMap<string, string>,
|
|
1306
1309
|
sourceId: string,
|
|
1307
1310
|
diagnostics: ContractSourceDiagnostic[],
|
|
1308
1311
|
): Record<string, ContractModel> {
|
|
@@ -1406,7 +1409,10 @@ function resolvePolymorphism(
|
|
|
1406
1409
|
...patched,
|
|
1407
1410
|
[variantName]: {
|
|
1408
1411
|
...variantModel,
|
|
1409
|
-
base:
|
|
1412
|
+
base: crossRef(
|
|
1413
|
+
baseDecl.baseName,
|
|
1414
|
+
modelNamespaceIds.get(baseDecl.baseName) ?? UNBOUND_NAMESPACE_ID,
|
|
1415
|
+
),
|
|
1410
1416
|
...(resolvedTable ? { storage: { ...variantModel.storage, table: resolvedTable } } : {}),
|
|
1411
1417
|
},
|
|
1412
1418
|
};
|
|
@@ -1668,10 +1674,18 @@ export function interpretPslDocumentToSqlContract(
|
|
|
1668
1674
|
})),
|
|
1669
1675
|
});
|
|
1670
1676
|
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1677
|
+
const modelsForPatch: Record<string, ContractModel> = {};
|
|
1678
|
+
for (const namespaceSlice of Object.values(contract.domain.namespaces)) {
|
|
1679
|
+
for (const [modelName, model] of Object.entries(namespaceSlice.models)) {
|
|
1680
|
+
if (Object.hasOwn(modelsForPatch, modelName)) {
|
|
1681
|
+
throw new Error(
|
|
1682
|
+
`duplicate model name "${modelName}" across domain namespaces during PSL interpretation`,
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
modelsForPatch[modelName] = model as ContractModel;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
let patchedModels = patchModelDomainFields(modelsForPatch, modelResolvedFields);
|
|
1675
1689
|
|
|
1676
1690
|
const polyDiagnostics: ContractSourceDiagnostic[] = [];
|
|
1677
1691
|
patchedModels = resolvePolymorphism(
|
|
@@ -1680,6 +1694,7 @@ export function interpretPslDocumentToSqlContract(
|
|
|
1680
1694
|
baseDeclarations,
|
|
1681
1695
|
modelNames,
|
|
1682
1696
|
modelMappings,
|
|
1697
|
+
modelNamespaceIds,
|
|
1683
1698
|
sourceId,
|
|
1684
1699
|
polyDiagnostics,
|
|
1685
1700
|
);
|
|
@@ -1693,14 +1708,35 @@ export function interpretPslDocumentToSqlContract(
|
|
|
1693
1708
|
|
|
1694
1709
|
const variantModelNames = new Set(baseDeclarations.keys());
|
|
1695
1710
|
const filteredRoots = Object.fromEntries(
|
|
1696
|
-
Object.entries(contract.roots).filter(
|
|
1711
|
+
Object.entries(contract.roots).filter(
|
|
1712
|
+
([, crossReference]) => !variantModelNames.has(crossReference.model),
|
|
1713
|
+
),
|
|
1697
1714
|
);
|
|
1698
1715
|
|
|
1699
1716
|
const patchedContract: Contract = {
|
|
1700
1717
|
...contract,
|
|
1701
1718
|
roots: filteredRoots,
|
|
1702
|
-
|
|
1703
|
-
|
|
1719
|
+
domain: {
|
|
1720
|
+
namespaces: Object.fromEntries(
|
|
1721
|
+
Object.entries(contract.domain.namespaces).map(([namespaceId, namespaceSlice]) => [
|
|
1722
|
+
namespaceId,
|
|
1723
|
+
{
|
|
1724
|
+
models: Object.fromEntries(
|
|
1725
|
+
Object.entries(namespaceSlice.models).map(([modelName, model]) => [
|
|
1726
|
+
modelName,
|
|
1727
|
+
patchedModels[modelName] ?? model,
|
|
1728
|
+
]),
|
|
1729
|
+
),
|
|
1730
|
+
...(namespaceSlice.valueObjects !== undefined
|
|
1731
|
+
? { valueObjects: namespaceSlice.valueObjects }
|
|
1732
|
+
: {}),
|
|
1733
|
+
...(namespaceId === UNBOUND_NAMESPACE_ID && Object.keys(valueObjects).length > 0
|
|
1734
|
+
? { valueObjects }
|
|
1735
|
+
: {}),
|
|
1736
|
+
},
|
|
1737
|
+
]),
|
|
1738
|
+
),
|
|
1739
|
+
},
|
|
1704
1740
|
};
|
|
1705
1741
|
|
|
1706
1742
|
return ok(patchedContract);
|