@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/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
1
2
|
import { AuthoringContributions } from "@prisma-next/framework-components/authoring";
|
|
3
|
+
import { Namespace } from "@prisma-next/framework-components/ir";
|
|
2
4
|
import { SqlNamespaceTablesInput } from "@prisma-next/sql-contract/types";
|
|
3
5
|
import { Result } from "@prisma-next/utils/result";
|
|
4
6
|
import { ParsePslDocumentResult } from "@prisma-next/psl-parser";
|
|
5
7
|
import { ControlMutationDefaults, ControlMutationDefaults as ControlMutationDefaults$1, DefaultFunctionLoweringContext, DefaultFunctionLoweringHandler, DefaultFunctionRegistry, DefaultFunctionRegistryEntry, MutationDefaultGeneratorDescriptor } from "@prisma-next/framework-components/control";
|
|
6
8
|
import { ContractSourceDiagnostics } from "@prisma-next/config/config-types";
|
|
7
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
8
9
|
import { ExtensionPackRef, TargetPackRef } from "@prisma-next/framework-components/components";
|
|
9
|
-
import { Namespace } from "@prisma-next/framework-components/ir";
|
|
10
10
|
|
|
11
11
|
//#region src/psl-column-resolution.d.ts
|
|
12
12
|
type ColumnDescriptor = {
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/psl-column-resolution.ts","../src/interpreter.ts"],"mappings":";;;;;;;;;;;KAyCY,gBAAA;EAAA,SACD,OAAA;EAAA,SACA,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/psl-column-resolution.ts","../src/interpreter.ts"],"mappings":";;;;;;;;;;;KAyCY,gBAAA;EAAA,SACD,OAAA;EAAA,SACA,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;UC8Cb,sCAAA;EAAA,SACN,QAAA,EAAU,sBAAA;EAAA,SACV,MAAA,EAAQ,aAAA;EAAA,SACR,qBAAA,EAAuB,WAAA,SAAoB,gBAAA;EAAA,SAC3C,sBAAA;EAAA,SACA,yBAAA,YAAqC,gBAAA;EAAA,SACrC,uBAAA,GAA0B,yBAAA;EAAA,SAC1B,sBAAA,GAAyB,sBAAA;EDrDzB;;;AAAmB;;;;AC8C9B;;ED9CW,SC+DA,eAAA,IAAmB,KAAA,EAAO,uBAAA,KAA4B,SAAA;AAAA;AAAA,iBAmyCjD,iCAAA,CACd,KAAA,EAAO,sCAAA,GACN,MAAA,CAAO,QAAA,EAAU,yBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as interpretPslDocumentToSqlContract } from "./interpreter-
|
|
1
|
+
import { t as interpretPslDocumentToSqlContract } from "./interpreter-DTnnPYbb.mjs";
|
|
2
2
|
export { interpretPslDocumentToSqlContract };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { crossRef } from "@prisma-next/contract/types";
|
|
1
2
|
import { hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringTypeConstructorDescriptor, validateAuthoringHelperArguments } from "@prisma-next/framework-components/authoring";
|
|
3
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
2
4
|
import { isPostgresEnumStorageEntry } from "@prisma-next/sql-contract/types";
|
|
3
5
|
import { buildSqlContractFromDefinition } from "@prisma-next/sql-contract-ts/contract-builder";
|
|
4
6
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -2683,7 +2685,7 @@ function collectPolymorphismDeclarations(models, sourceId, diagnostics) {
|
|
|
2683
2685
|
baseDeclarations
|
|
2684
2686
|
};
|
|
2685
2687
|
}
|
|
2686
|
-
function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, sourceId, diagnostics) {
|
|
2688
|
+
function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, modelNamespaceIds, sourceId, diagnostics) {
|
|
2687
2689
|
let patched = models;
|
|
2688
2690
|
for (const [modelName, decl] of discriminatorDeclarations) {
|
|
2689
2691
|
if (baseDeclarations.has(modelName)) {
|
|
@@ -2770,7 +2772,7 @@ function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations
|
|
|
2770
2772
|
...patched,
|
|
2771
2773
|
[variantName]: {
|
|
2772
2774
|
...variantModel,
|
|
2773
|
-
base: baseDecl.baseName,
|
|
2775
|
+
base: crossRef(baseDecl.baseName, modelNamespaceIds.get(baseDecl.baseName) ?? UNBOUND_NAMESPACE_ID),
|
|
2774
2776
|
...resolvedTable ? { storage: {
|
|
2775
2777
|
...variantModel.storage,
|
|
2776
2778
|
table: resolvedTable
|
|
@@ -2951,23 +2953,31 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
2951
2953
|
...modelRelations.has(model.modelName) ? { relations: [...modelRelations.get(model.modelName) ?? []].sort((left, right) => compareStrings(left.fieldName, right.fieldName)) } : {}
|
|
2952
2954
|
}))
|
|
2953
2955
|
});
|
|
2954
|
-
|
|
2956
|
+
const modelsForPatch = {};
|
|
2957
|
+
for (const namespaceSlice of Object.values(contract.domain.namespaces)) for (const [modelName, model] of Object.entries(namespaceSlice.models)) {
|
|
2958
|
+
if (Object.hasOwn(modelsForPatch, modelName)) throw new Error(`duplicate model name "${modelName}" across domain namespaces during PSL interpretation`);
|
|
2959
|
+
modelsForPatch[modelName] = model;
|
|
2960
|
+
}
|
|
2961
|
+
let patchedModels = patchModelDomainFields(modelsForPatch, modelResolvedFields);
|
|
2955
2962
|
const polyDiagnostics = [];
|
|
2956
|
-
patchedModels = resolvePolymorphism(patchedModels, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, sourceId, polyDiagnostics);
|
|
2963
|
+
patchedModels = resolvePolymorphism(patchedModels, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, modelNamespaceIds, sourceId, polyDiagnostics);
|
|
2957
2964
|
if (polyDiagnostics.length > 0) return notOk({
|
|
2958
2965
|
summary: "PSL to SQL contract interpretation failed",
|
|
2959
2966
|
diagnostics: polyDiagnostics
|
|
2960
2967
|
});
|
|
2961
2968
|
const variantModelNames = new Set(baseDeclarations.keys());
|
|
2962
|
-
const filteredRoots = Object.fromEntries(Object.entries(contract.roots).filter(([,
|
|
2969
|
+
const filteredRoots = Object.fromEntries(Object.entries(contract.roots).filter(([, crossReference]) => !variantModelNames.has(crossReference.model)));
|
|
2963
2970
|
return ok({
|
|
2964
2971
|
...contract,
|
|
2965
2972
|
roots: filteredRoots,
|
|
2966
|
-
|
|
2967
|
-
|
|
2973
|
+
domain: { namespaces: Object.fromEntries(Object.entries(contract.domain.namespaces).map(([namespaceId, namespaceSlice]) => [namespaceId, {
|
|
2974
|
+
models: Object.fromEntries(Object.entries(namespaceSlice.models).map(([modelName, model]) => [modelName, patchedModels[modelName] ?? model])),
|
|
2975
|
+
...namespaceSlice.valueObjects !== void 0 ? { valueObjects: namespaceSlice.valueObjects } : {},
|
|
2976
|
+
...namespaceId === UNBOUND_NAMESPACE_ID && Object.keys(valueObjects).length > 0 ? { valueObjects } : {}
|
|
2977
|
+
}])) }
|
|
2968
2978
|
});
|
|
2969
2979
|
}
|
|
2970
2980
|
//#endregion
|
|
2971
2981
|
export { interpretPslDocumentToSqlContract as t };
|
|
2972
2982
|
|
|
2973
|
-
//# sourceMappingURL=interpreter-
|
|
2983
|
+
//# sourceMappingURL=interpreter-DTnnPYbb.mjs.map
|