@prisma-next/sql-contract-psl 0.12.0-dev.17 → 0.12.0-dev.3
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 +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{interpreter-o0m3OC4P.mjs → interpreter-QE6eZZof.mjs} +9 -5
- package/dist/interpreter-QE6eZZof.mjs.map +1 -0
- package/dist/provider.mjs +1 -1
- package/package.json +12 -12
- package/src/interpreter.ts +9 -4
- package/dist/interpreter-o0m3OC4P.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Contract } from "@prisma-next/contract/types";
|
|
2
2
|
import { AuthoringContributions } from "@prisma-next/framework-components/authoring";
|
|
3
|
+
import { Namespace } from "@prisma-next/framework-components/ir";
|
|
3
4
|
import { SqlNamespaceTablesInput } from "@prisma-next/sql-contract/types";
|
|
4
5
|
import { Result } from "@prisma-next/utils/result";
|
|
5
6
|
import { ParsePslDocumentResult } from "@prisma-next/psl-parser";
|
|
6
7
|
import { ControlMutationDefaults, ControlMutationDefaults as ControlMutationDefaults$1, DefaultFunctionLoweringContext, DefaultFunctionLoweringHandler, DefaultFunctionRegistry, DefaultFunctionRegistryEntry, MutationDefaultGeneratorDescriptor } from "@prisma-next/framework-components/control";
|
|
7
8
|
import { ContractSourceDiagnostics } from "@prisma-next/config/config-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,MAAM;AAAA;;;
|
|
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,iBAwyCjD,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-QE6eZZof.mjs";
|
|
2
2
|
export { interpretPslDocumentToSqlContract };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { crossRef } from "@prisma-next/contract/types";
|
|
2
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";
|
|
3
4
|
import { isPostgresEnumStorageEntry } from "@prisma-next/sql-contract/types";
|
|
4
5
|
import { buildSqlContractFromDefinition } from "@prisma-next/sql-contract-ts/contract-builder";
|
|
5
6
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -1851,6 +1852,9 @@ const UNSPECIFIED_PSL_NAMESPACE_NAME = "__unspecified__";
|
|
|
1851
1852
|
* slot empty (which means the late-bound default at the `StorageTable`
|
|
1852
1853
|
* layer; emitted JSON omits the field).
|
|
1853
1854
|
*/
|
|
1855
|
+
function defaultSqlNamespaceIdForTarget(targetId) {
|
|
1856
|
+
return targetId === "postgres" ? "public" : UNBOUND_NAMESPACE_ID;
|
|
1857
|
+
}
|
|
1854
1858
|
function resolveNamespaceIdForSqlTarget(input) {
|
|
1855
1859
|
if (input.targetId !== "postgres") return;
|
|
1856
1860
|
if (input.bucketName === UNSPECIFIED_PSL_NAMESPACE_NAME) return "public";
|
|
@@ -2684,7 +2688,7 @@ function collectPolymorphismDeclarations(models, sourceId, diagnostics) {
|
|
|
2684
2688
|
baseDeclarations
|
|
2685
2689
|
};
|
|
2686
2690
|
}
|
|
2687
|
-
function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, modelNamespaceIds,
|
|
2691
|
+
function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, modelNamespaceIds, targetId, sourceId, diagnostics) {
|
|
2688
2692
|
let patched = models;
|
|
2689
2693
|
for (const [modelName, decl] of discriminatorDeclarations) {
|
|
2690
2694
|
if (baseDeclarations.has(modelName)) {
|
|
@@ -2771,7 +2775,7 @@ function resolvePolymorphism(models, discriminatorDeclarations, baseDeclarations
|
|
|
2771
2775
|
...patched,
|
|
2772
2776
|
[variantName]: {
|
|
2773
2777
|
...variantModel,
|
|
2774
|
-
base: crossRef(baseDecl.baseName, modelNamespaceIds.get(baseDecl.baseName) ??
|
|
2778
|
+
base: crossRef(baseDecl.baseName, modelNamespaceIds.get(baseDecl.baseName) ?? defaultSqlNamespaceIdForTarget(targetId)),
|
|
2775
2779
|
...resolvedTable ? { storage: {
|
|
2776
2780
|
...variantModel.storage,
|
|
2777
2781
|
table: resolvedTable
|
|
@@ -2959,7 +2963,7 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
2959
2963
|
}
|
|
2960
2964
|
let patchedModels = patchModelDomainFields(modelsForPatch, modelResolvedFields);
|
|
2961
2965
|
const polyDiagnostics = [];
|
|
2962
|
-
patchedModels = resolvePolymorphism(patchedModels, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, modelNamespaceIds, input.target.
|
|
2966
|
+
patchedModels = resolvePolymorphism(patchedModels, discriminatorDeclarations, baseDeclarations, modelNames, modelMappings, modelNamespaceIds, input.target.targetId, sourceId, polyDiagnostics);
|
|
2963
2967
|
if (polyDiagnostics.length > 0) return notOk({
|
|
2964
2968
|
summary: "PSL to SQL contract interpretation failed",
|
|
2965
2969
|
diagnostics: polyDiagnostics
|
|
@@ -2972,11 +2976,11 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
2972
2976
|
domain: { namespaces: Object.fromEntries(Object.entries(contract.domain.namespaces).map(([namespaceId, namespaceSlice]) => [namespaceId, {
|
|
2973
2977
|
models: Object.fromEntries(Object.entries(namespaceSlice.models).map(([modelName, model]) => [modelName, patchedModels[modelName] ?? model])),
|
|
2974
2978
|
...namespaceSlice.valueObjects !== void 0 ? { valueObjects: namespaceSlice.valueObjects } : {},
|
|
2975
|
-
...namespaceId === input.target.
|
|
2979
|
+
...namespaceId === defaultSqlNamespaceIdForTarget(input.target.targetId) && Object.keys(valueObjects).length > 0 ? { valueObjects } : {}
|
|
2976
2980
|
}])) }
|
|
2977
2981
|
});
|
|
2978
2982
|
}
|
|
2979
2983
|
//#endregion
|
|
2980
2984
|
export { interpretPslDocumentToSqlContract as t };
|
|
2981
2985
|
|
|
2982
|
-
//# sourceMappingURL=interpreter-
|
|
2986
|
+
//# sourceMappingURL=interpreter-QE6eZZof.mjs.map
|