@prisma/orm-toolchain 8.0.0-rc.1-dev.46 → 8.0.0-rc.10
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/README.md +1 -5
- package/dist/{aggregate-CPZB020V.mjs → aggregate-B4HKshLQ.mjs} +10 -10
- package/dist/aggregate-B4HKshLQ.mjs.map +1 -0
- package/dist/{aggregate-DLUJLq5Y.d.mts → aggregate-D_eX4zoo.d.mts} +3 -3
- package/dist/{aggregate-DLUJLq5Y.d.mts.map → aggregate-D_eX4zoo.d.mts.map} +1 -1
- package/dist/cli-telemetry.d.mts +8 -7
- package/dist/cli-telemetry.d.mts.map +1 -1
- package/dist/cli-telemetry.mjs +22 -24
- package/dist/cli-telemetry.mjs.map +1 -1
- package/dist/cli.d.mts +2 -6
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +447 -430
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +20 -11
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__init-output.mjs +1 -1
- package/dist/cli__migration-cli.mjs +6 -6
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs → contract-snapshot-store-qGrwlGmt-Cf2NFzRL.mjs} +3 -3
- package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map → contract-snapshot-store-qGrwlGmt-Cf2NFzRL.mjs.map} +1 -1
- package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts → db-verify-Yih5kWtB-B1kv76ec.d.mts} +5 -5
- package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts.map → db-verify-Yih5kWtB-B1kv76ec.d.mts.map} +1 -1
- package/dist/{domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs → domain-type-generation-CR9ECUau-DOlKbcaE.mjs} +20 -6
- package/dist/domain-type-generation-CR9ECUau-DOlKbcaE.mjs.map +1 -0
- package/dist/{domain-type-generation-PkAb39ob-Ct8AGqow.d.mts → domain-type-generation-X6-AaL1U-DHEoRf_y.d.mts} +14 -3
- package/dist/domain-type-generation-X6-AaL1U-DHEoRf_y.d.mts.map +1 -0
- package/dist/emitter.d.mts +2 -2
- package/dist/emitter.mjs +2 -2
- package/dist/emitter__domain-type-generation.d.mts +2 -2
- package/dist/emitter__domain-type-generation.mjs +2 -2
- package/dist/{errors-CXbGUWGu-CstQHPh6.mjs → errors-SoLLYLtw-DMxVbVs9.mjs} +9 -9
- package/dist/errors-SoLLYLtw-DMxVbVs9.mjs.map +1 -0
- package/dist/{exports-BZaG8_w_.mjs → exports-BXXeNWlj.mjs} +25 -47
- package/dist/exports-BXXeNWlj.mjs.map +1 -0
- package/dist/exports-CE6OD63o-4Qpqr2W7.mjs +398 -0
- package/dist/exports-CE6OD63o-4Qpqr2W7.mjs.map +1 -0
- package/dist/{exports-8ZUN43ve.mjs → exports-CYa2di3d.mjs} +382 -22
- package/dist/exports-CYa2di3d.mjs.map +1 -0
- package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs → graph-membership-DY1Onbc3-CwBd6wuB.mjs} +3 -3
- package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs.map → graph-membership-DY1Onbc3-CwBd6wuB.mjs.map} +1 -1
- package/dist/{import-roots-CfoYgejL.d.mts → import-roots-ARK1wjzc.d.mts} +3 -3
- package/dist/{import-roots-CfoYgejL.d.mts.map → import-roots-ARK1wjzc.d.mts.map} +1 -1
- package/dist/{import-roots-CNFBPAT1.mjs → import-roots-BHOrDJbI.mjs} +5 -5
- package/dist/import-roots-BHOrDJbI.mjs.map +1 -0
- package/dist/{index-Dgwl8Tzs.d.mts → index-D217lbiW.d.mts} +7 -3
- package/dist/index-D217lbiW.d.mts.map +1 -0
- package/dist/{index-DRs7L6N0.d.mts → index-u5RdrumF.d.mts} +2 -19
- package/dist/index-u5RdrumF.d.mts.map +1 -0
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs → invariants-Cww4bv0v-BEiFxmbX.mjs} +3 -3
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs.map → invariants-Cww4bv0v-BEiFxmbX.mjs.map} +1 -1
- package/dist/{io-635GlNx1-D3zrw2qu.mjs → io-BmWQNxRP-DQqbcPsS.mjs} +5 -5
- package/dist/{io-635GlNx1-D3zrw2qu.mjs.map → io-BmWQNxRP-DQqbcPsS.mjs.map} +1 -1
- package/dist/{migration-hspPIEeV.mjs → migration-B9w-7dKe.mjs} +4 -4
- package/dist/{migration-hspPIEeV.mjs.map → migration-B9w-7dKe.mjs.map} +1 -1
- package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs → migration-graph-CW4bMmTz-B5xFtFVB.mjs} +3 -3
- package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs.map → migration-graph-CW4bMmTz-B5xFtFVB.mjs.map} +1 -1
- package/dist/migration-tools.d.mts +3 -3
- package/dist/migration-tools.mjs +12 -12
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.d.mts +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.d.mts +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{output-CovTDY14-CUoAqLML.mjs → output-D83nTTpC-XlvN30yS.mjs} +4 -4
- package/dist/{output-CovTDY14-CUoAqLML.mjs.map → output-D83nTTpC-XlvN30yS.mjs.map} +1 -1
- package/dist/publish-surface.d.mts +1 -1
- package/dist/publish-surface.mjs +2 -2
- package/dist/publish-surface__import-roots.d.mts +1 -1
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/publish-surface__shells.mjs +1 -1
- package/dist/quick-reference-mongo.md +11 -11
- package/dist/quick-reference-postgres.md +10 -10
- package/dist/readme-mongo.md +6 -6
- package/dist/readme-postgres.md +6 -6
- package/dist/{ref-h6InR6dO-rGfl18Jv.mjs → ref-DcqFmceq-QaUjgZeM.mjs} +190 -87
- package/dist/ref-DcqFmceq-QaUjgZeM.mjs.map +1 -0
- package/dist/{ref-resolution-HeNBXW53.mjs → ref-resolution-BWpwb8_b.mjs} +9 -2
- package/dist/ref-resolution-BWpwb8_b.mjs.map +1 -0
- package/dist/{ref-resolution-COGOSL57.d.mts → ref-resolution-CaHQJXE0.d.mts} +11 -1
- package/dist/ref-resolution-CaHQJXE0.d.mts.map +1 -0
- package/dist/{refs-WK86uYYp-gM8tvWQP.mjs → refs-BpSpzdYB-BcDelHGt.mjs} +9 -9
- package/dist/refs-BpSpzdYB-BcDelHGt.mjs.map +1 -0
- package/dist/{shells-C4HbRAr5.mjs → shells-BIdFZwUY.mjs} +1 -6
- package/dist/shells-BIdFZwUY.mjs.map +1 -0
- package/dist/{spaces-Dj65JrwZ.d.mts → spaces-B20bgxF9.d.mts} +2 -2
- package/dist/{spaces-Dj65JrwZ.d.mts.map → spaces-B20bgxF9.d.mts.map} +1 -1
- package/dist/{spaces-4qMOAYE9.mjs → spaces-BCZiAZQn.mjs} +7 -7
- package/dist/spaces-BCZiAZQn.mjs.map +1 -0
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs → verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs} +7 -7
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map → verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.d.mts +1 -1
- package/dist/vite-plugin-contract-emit.mjs +7 -7
- package/dist/vite-plugin-contract-emit.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/aggregate-CPZB020V.mjs.map +0 -1
- package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts.map +0 -1
- package/dist/domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs.map +0 -1
- package/dist/errors-CXbGUWGu-CstQHPh6.mjs.map +0 -1
- package/dist/exports-8ZUN43ve.mjs.map +0 -1
- package/dist/exports-BCLg4CiV-05kuwcb0.mjs +0 -160
- package/dist/exports-BCLg4CiV-05kuwcb0.mjs.map +0 -1
- package/dist/exports-BZaG8_w_.mjs.map +0 -1
- package/dist/import-roots-CNFBPAT1.mjs.map +0 -1
- package/dist/index-DRs7L6N0.d.mts.map +0 -1
- package/dist/index-Dgwl8Tzs.d.mts.map +0 -1
- package/dist/ref-h6InR6dO-rGfl18Jv.mjs.map +0 -1
- package/dist/ref-resolution-COGOSL57.d.mts.map +0 -1
- package/dist/ref-resolution-HeNBXW53.mjs.map +0 -1
- package/dist/refs-WK86uYYp-gM8tvWQP.mjs.map +0 -1
- package/dist/shells-C4HbRAr5.mjs.map +0 -1
- package/dist/spaces-4qMOAYE9.mjs.map +0 -1
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { D as serializeObjectKey, O as serializeValue, S as resolveModelFieldType, T as serializeExecutionType, d as generateImportLines, g as generateRootsType, h as generateModelsType, i as generateCodecTypeIntersection, l as generateFieldTypesMapsByNamespace, n as emitterError, t as deduplicateImports, u as generateHashTypeAliases, v as generateValueObjectTypeAliases, y as generateValueObjectsDescriptorType } from "./domain-type-generation-CR9ECUau-DOlKbcaE.mjs";
|
|
2
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
3
|
+
import { keepInternalSpecifiers } from "@prisma/orm-framework/components/emission";
|
|
4
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
5
|
+
import { canonicalizeContractToObject } from "@prisma/orm-framework/contract/hashing";
|
|
6
|
+
import { format } from "prettier";
|
|
7
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
8
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
9
|
+
//#region ../../../1-framework/3-tooling/emitter/dist/exports-CE6OD63o.mjs
|
|
10
|
+
const JSON_EXTENSION = ".json";
|
|
11
|
+
function getEmittedArtifactPaths(outputJsonPath) {
|
|
12
|
+
if (!outputJsonPath.endsWith(JSON_EXTENSION)) throw emitterError("CONFIG.VALIDATION_FAILED", "Contract output path must end with .json", { meta: {
|
|
13
|
+
field: "contract.output",
|
|
14
|
+
outputJsonPath
|
|
15
|
+
} });
|
|
16
|
+
return {
|
|
17
|
+
jsonPath: outputJsonPath,
|
|
18
|
+
dtsPath: `${outputJsonPath.slice(0, -5)}.d.ts`
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const TYPESCRIPT_IDENTIFIER = /^[$A-Z_a-z][$\w]*$/;
|
|
22
|
+
function namespacedMemberName(namespaceId, modelName) {
|
|
23
|
+
return `${namespaceId === UNBOUND_NAMESPACE_ID ? "unbound" : namespaceId}_${modelName}`;
|
|
24
|
+
}
|
|
25
|
+
function bareMemberName(_namespaceId, modelName) {
|
|
26
|
+
return modelName;
|
|
27
|
+
}
|
|
28
|
+
function claimMemberName(claims, memberName, source) {
|
|
29
|
+
if (!TYPESCRIPT_IDENTIFIER.test(memberName)) throw emitterError("CONTRACT.MODEL_TYPE_NAME_INVALID", `Emitted model type name "${memberName}" (from ${source}) is not a TypeScript identifier`, {
|
|
30
|
+
why: "Every entry in the emitted Models namespace is declared as `export type <name>`, so the name must be a TypeScript identifier.",
|
|
31
|
+
fix: "Rename the namespace or model so that <namespace>_<Model> contains only letters, digits, `$`, and `_`, and does not start with a digit.",
|
|
32
|
+
meta: {
|
|
33
|
+
memberName,
|
|
34
|
+
source
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const existing = claims.get(memberName);
|
|
38
|
+
if (existing !== void 0) throw emitterError("CONTRACT.MODEL_TYPE_NAME_COLLISION", `Emitted model type name "${memberName}" is produced by both ${existing} and ${source}`, {
|
|
39
|
+
why: "Every entry in the emitted Models namespace needs a distinct name, formed as <namespace>_<Model>.",
|
|
40
|
+
fix: "Rename one of the models or namespaces so the two names differ.",
|
|
41
|
+
meta: {
|
|
42
|
+
memberName,
|
|
43
|
+
sources: [existing, source]
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
claims.set(memberName, source);
|
|
47
|
+
}
|
|
48
|
+
function isPolymorphicBase(model) {
|
|
49
|
+
return model.discriminator !== void 0 && model.variants !== void 0;
|
|
50
|
+
}
|
|
51
|
+
function findModelByName(namespaces, namespaceId, modelName) {
|
|
52
|
+
return namespaces.find((ns) => ns.namespaceId === namespaceId)?.models.find((m) => m.modelName === modelName);
|
|
53
|
+
}
|
|
54
|
+
function findModel(namespaces, ref) {
|
|
55
|
+
return findModelByName(namespaces, ref.namespace, ref.model);
|
|
56
|
+
}
|
|
57
|
+
function requireRelationTarget(namespaces, owner, relationName, ref) {
|
|
58
|
+
const target = findModel(namespaces, ref);
|
|
59
|
+
if (target !== void 0) return target;
|
|
60
|
+
const ownerSource = `${owner.namespaceId}.${owner.modelName}`;
|
|
61
|
+
throw emitterError("CONTRACT.MODEL_RELATION_TARGET_MISSING", `Relation "${relationName}" on ${ownerSource} targets ${ref.namespace}.${ref.model}, which is not in the contract`, {
|
|
62
|
+
why: "A same-space relation must point at a model the contract declares; only cross-space relations may reference models outside it.",
|
|
63
|
+
fix: "Declare the target model in the contract, or mark the relation as cross-space by giving its target a `space`.",
|
|
64
|
+
meta: {
|
|
65
|
+
owner: ownerSource,
|
|
66
|
+
relationName,
|
|
67
|
+
target: {
|
|
68
|
+
namespaceId: ref.namespace,
|
|
69
|
+
modelName: ref.model
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function requireBase(namespaces, variant, base) {
|
|
75
|
+
const found = findModel(namespaces, base);
|
|
76
|
+
if (found !== void 0) return found;
|
|
77
|
+
const variantSource = `${variant.namespaceId}.${variant.modelName}`;
|
|
78
|
+
const baseSource = `${base.namespace}.${base.model}`;
|
|
79
|
+
throw emitterError("CONTRACT.MODEL_BASE_MISSING", `Model ${variantSource} names base ${baseSource}, which is not in the contract`, {
|
|
80
|
+
why: "A variant's type is its base's fields plus its own, so the base must be a model the contract declares.",
|
|
81
|
+
fix: "Declare the base model in the contract, or remove `base` from the variant.",
|
|
82
|
+
meta: {
|
|
83
|
+
variant: variantSource,
|
|
84
|
+
base: baseSource
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function requireVariant(namespaces, base, variantName) {
|
|
89
|
+
const variant = findModelByName(namespaces, base.namespaceId, variantName);
|
|
90
|
+
if (variant !== void 0) return variant;
|
|
91
|
+
const baseSource = `${base.namespaceId}.${base.modelName}`;
|
|
92
|
+
throw emitterError("CONTRACT.MODEL_VARIANT_MISSING", `Polymorphic base ${baseSource} names variant "${variantName}", which is not in the contract`, {
|
|
93
|
+
why: "The Any<Base> union is the union of the variant model types, so every variant a base declares must be a model in the same namespace.",
|
|
94
|
+
fix: "Declare the variant model in the same namespace as the base, or remove it from the base's variants.",
|
|
95
|
+
meta: {
|
|
96
|
+
base: baseSource,
|
|
97
|
+
variantName
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function collectFieldLines(ref, resolvers, discriminatorType) {
|
|
102
|
+
const lines = /* @__PURE__ */ new Map();
|
|
103
|
+
for (const [fieldName, field] of Object.entries(ref.model.fields)) {
|
|
104
|
+
const type = discriminatorType !== void 0 && fieldName === discriminatorType.field ? discriminatorType.type : resolveModelFieldType(ref.modelName, fieldName, field, ref.model, resolvers).output;
|
|
105
|
+
lines.set(fieldName, `${serializeObjectKey(fieldName)}: ${type};`);
|
|
106
|
+
}
|
|
107
|
+
return lines;
|
|
108
|
+
}
|
|
109
|
+
function hasJoin(relation) {
|
|
110
|
+
return "on" in relation && relation.on !== void 0;
|
|
111
|
+
}
|
|
112
|
+
function relationLine(owner, relationName, relation, index) {
|
|
113
|
+
if (relation.to.space !== void 0) return void 0;
|
|
114
|
+
const target = requireRelationTarget(index.namespaces, owner, relationName, relation.to);
|
|
115
|
+
const targetMember = index.memberNameOf(target.namespaceId, isPolymorphicBase(target.model) ? `Any${target.modelName}` : target.modelName);
|
|
116
|
+
const key = serializeObjectKey(relationName);
|
|
117
|
+
if (!hasJoin(relation)) return {
|
|
118
|
+
line: `${key}: ${relation.cardinality === "1:N" ? `${targetMember}[]` : targetMember};`,
|
|
119
|
+
hasJoin: false
|
|
120
|
+
};
|
|
121
|
+
if (relation.cardinality === "1:N" || relation.cardinality === "N:M") return {
|
|
122
|
+
line: `${key}: ${targetMember}[];`,
|
|
123
|
+
hasJoin: true
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
line: `${key}: ${relation.nullable ? `${targetMember} | null` : targetMember};`,
|
|
127
|
+
hasJoin: true
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function collectRelationLines(ref, index) {
|
|
131
|
+
const lines = /* @__PURE__ */ new Map();
|
|
132
|
+
for (const [relationName, relation] of Object.entries(ref.model.relations)) {
|
|
133
|
+
const rendered = relationLine(ref, relationName, relation, index);
|
|
134
|
+
if (rendered !== void 0) lines.set(relationName, rendered);
|
|
135
|
+
}
|
|
136
|
+
return lines;
|
|
137
|
+
}
|
|
138
|
+
function discriminatorUnion(base) {
|
|
139
|
+
const values = Object.values(base.variants ?? {}).map((v) => serializeValue(v.value));
|
|
140
|
+
return values.length > 0 ? values.join(" | ") : "never";
|
|
141
|
+
}
|
|
142
|
+
function memberLines(ref, index, resolvers) {
|
|
143
|
+
const base = ref.model.base !== void 0 ? requireBase(index.namespaces, ref, ref.model.base) : void 0;
|
|
144
|
+
if (base !== void 0 && isPolymorphicBase(base.model)) {
|
|
145
|
+
const discriminatorField = base.model.discriminator?.field ?? "";
|
|
146
|
+
const variantValue = base.model.variants?.[ref.modelName]?.value;
|
|
147
|
+
const discriminatorType = {
|
|
148
|
+
field: discriminatorField,
|
|
149
|
+
type: variantValue !== void 0 ? serializeValue(variantValue) : discriminatorUnion(base.model)
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
fieldsByName: new Map([...collectFieldLines(base, resolvers, discriminatorType), ...collectFieldLines(ref, resolvers, void 0)]),
|
|
153
|
+
relationsByName: new Map([...collectRelationLines(base, index), ...collectRelationLines(ref, index)])
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
fieldsByName: collectFieldLines(ref, resolvers, isPolymorphicBase(ref.model) ? {
|
|
158
|
+
field: ref.model.discriminator?.field ?? "",
|
|
159
|
+
type: discriminatorUnion(ref.model)
|
|
160
|
+
} : void 0),
|
|
161
|
+
relationsByName: collectRelationLines(ref, index)
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function renderMember(memberName, lines, hasOwner) {
|
|
165
|
+
const entries = [...lines.relationsByName];
|
|
166
|
+
const joinlessLines = entries.filter(([, r]) => !r.hasJoin).map(([, r]) => r.line);
|
|
167
|
+
const joinedLines = entries.filter(([, r]) => r.hasJoin).map(([, r]) => r.line);
|
|
168
|
+
const relationNames = entries.filter(([, r]) => r.hasJoin).map(([name]) => name);
|
|
169
|
+
const phantom = relationNames.length > 0 ? relationNames.map((name) => serializeValue(name)).join(" | ") : "never";
|
|
170
|
+
return ` export type ${memberName} = {\n${[
|
|
171
|
+
...lines.fieldsByName.values(),
|
|
172
|
+
...joinlessLines,
|
|
173
|
+
...joinedLines,
|
|
174
|
+
...hasOwner ? [] : [`readonly [RelationKeys]?: ${phantom};`]
|
|
175
|
+
].map((line) => ` ${line}`).join("\n")}\n };`;
|
|
176
|
+
}
|
|
177
|
+
function namespaceModelsOf(contract) {
|
|
178
|
+
return Object.entries(contract.domain.namespaces).map(([namespaceId, ns]) => ({
|
|
179
|
+
namespaceId,
|
|
180
|
+
models: Object.entries(ns.models).map(([modelName, model]) => ({
|
|
181
|
+
namespaceId,
|
|
182
|
+
modelName,
|
|
183
|
+
model
|
|
184
|
+
}))
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
function generateModelTypesBlock(contract, resolvers, supportsNamespaces) {
|
|
188
|
+
const memberNameOf = supportsNamespaces ? namespacedMemberName : bareMemberName;
|
|
189
|
+
const namespaces = namespaceModelsOf(contract);
|
|
190
|
+
const index = {
|
|
191
|
+
namespaces,
|
|
192
|
+
memberNameOf
|
|
193
|
+
};
|
|
194
|
+
const claims = /* @__PURE__ */ new Map();
|
|
195
|
+
for (const ns of namespaces) for (const ref of ns.models) claimMemberName(claims, memberNameOf(ns.namespaceId, ref.modelName), `${ns.namespaceId}.${ref.modelName}`);
|
|
196
|
+
for (const ns of namespaces) for (const ref of ns.models) {
|
|
197
|
+
if (!isPolymorphicBase(ref.model)) continue;
|
|
198
|
+
claimMemberName(claims, memberNameOf(ns.namespaceId, `Any${ref.modelName}`), `${ns.namespaceId}.Any<${ref.modelName}>`);
|
|
199
|
+
}
|
|
200
|
+
const members = [];
|
|
201
|
+
const constantEntries = [];
|
|
202
|
+
for (const ns of namespaces) {
|
|
203
|
+
const keys = [];
|
|
204
|
+
for (const ref of ns.models) {
|
|
205
|
+
const memberName = memberNameOf(ns.namespaceId, ref.modelName);
|
|
206
|
+
members.push(renderMember(memberName, memberLines(ref, index, resolvers), ref.model.owner !== void 0));
|
|
207
|
+
keys.push(`${serializeObjectKey(ref.modelName)}: Models.${memberName};`);
|
|
208
|
+
}
|
|
209
|
+
for (const ref of ns.models) {
|
|
210
|
+
if (!isPolymorphicBase(ref.model)) continue;
|
|
211
|
+
const unionName = memberNameOf(ns.namespaceId, `Any${ref.modelName}`);
|
|
212
|
+
const variantMembers = Object.keys(ref.model.variants ?? {}).map((variantName) => {
|
|
213
|
+
const variant = requireVariant(namespaces, ref, variantName);
|
|
214
|
+
return memberNameOf(variant.namespaceId, variant.modelName);
|
|
215
|
+
});
|
|
216
|
+
members.push(` export type ${unionName} = ${variantMembers.length > 0 ? variantMembers.join(" | ") : "never"};`);
|
|
217
|
+
keys.push(`${serializeObjectKey(`Any${ref.modelName}`)}: Models.${unionName};`);
|
|
218
|
+
}
|
|
219
|
+
if (!supportsNamespaces) {
|
|
220
|
+
constantEntries.push(...keys.map((key) => ` ${key}`));
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const nsKey = serializeObjectKey(ns.namespaceId);
|
|
224
|
+
const nested = keys.map((key) => ` ${key}`).join("\n");
|
|
225
|
+
constantEntries.push(keys.length > 0 ? ` ${nsKey}: {\n${nested}\n };` : ` ${nsKey}: {};`);
|
|
226
|
+
}
|
|
227
|
+
return `${members.length > 0 ? `export namespace Models {\n${members.join("\n")}\n}` : "export namespace Models {}"}\n\n${`export declare const models: {\n${constantEntries.join("\n")}\n};`}`;
|
|
228
|
+
}
|
|
229
|
+
function generateEnumBlockType(enums) {
|
|
230
|
+
return `{ ${Object.entries(enums).map(([name, entry]) => {
|
|
231
|
+
const membersType = `readonly [${entry.members.map((m) => `{ readonly name: ${serializeValue(m.name)}; readonly value: ${serializeValue(m.value)} }`).join(", ")}]`;
|
|
232
|
+
return `readonly ${serializeObjectKey(name)}: { readonly codecId: ${serializeValue(entry.codecId)}; readonly members: ${membersType} }`;
|
|
233
|
+
}).join("; ")} }`;
|
|
234
|
+
}
|
|
235
|
+
function generateContractDts(contract, emitter, codecTypeImports, hashes, options, codecLookup, resolveImportSpecifier = keepInternalSpecifiers) {
|
|
236
|
+
const allImports = [...codecTypeImports];
|
|
237
|
+
if (options?.queryOperationTypeImports) allImports.push(...options.queryOperationTypeImports);
|
|
238
|
+
const importLines = generateImportLines(deduplicateImports(allImports), resolveImportSpecifier);
|
|
239
|
+
const familyImportLines = emitter.getFamilyImports(resolveImportSpecifier);
|
|
240
|
+
const hashAliases = generateHashTypeAliases(hashes);
|
|
241
|
+
const codecTypes = generateCodecTypeIntersection(codecTypeImports, "CodecTypes");
|
|
242
|
+
const familyTypeAliases = emitter.getFamilyTypeAliases(options);
|
|
243
|
+
const typeMapsExpr = emitter.getTypeMapsExpression();
|
|
244
|
+
const storageType = emitter.generateStorageType(contract, "StorageHash");
|
|
245
|
+
const namespaceEntries = Object.entries(contract.domain.namespaces);
|
|
246
|
+
if (namespaceEntries.length === 0) throw emitterError("CONTRACT.NAMESPACE_INVALID", "domain has no namespaces", { meta: { reason: "no-domain-namespaces" } });
|
|
247
|
+
for (const [nsId, ns] of namespaceEntries) if (ns === void 0) throw new InternalError(`domain namespace "${nsId}" is not present on the contract`);
|
|
248
|
+
const rootsType = generateRootsType(contract.roots);
|
|
249
|
+
const flatValueObjects = {};
|
|
250
|
+
for (const [, ns] of namespaceEntries) for (const [voName, vo] of Object.entries(blindCast(ns.valueObjects ?? {}))) if (!(voName in flatValueObjects)) flatValueObjects[voName] = vo;
|
|
251
|
+
const valueObjects = Object.keys(flatValueObjects).length > 0 ? flatValueObjects : void 0;
|
|
252
|
+
const valueObjectTypeAliases = generateValueObjectTypeAliases(valueObjects, codecLookup);
|
|
253
|
+
const valueObjectsDescriptor = generateValueObjectsDescriptorType(valueObjects);
|
|
254
|
+
const domainNamespacesType = namespaceEntries.map(([nsId, ns]) => {
|
|
255
|
+
const nsModels = ns.models;
|
|
256
|
+
const nsModelsType = generateModelsType(nsModels, (name, model) => emitter.generateModelStorageType(name, model));
|
|
257
|
+
const nsValueObjects = blindCast(ns.valueObjects);
|
|
258
|
+
const nsValueObjectsDescriptor = nsValueObjects !== void 0 && Object.keys(nsValueObjects).length > 0 ? generateValueObjectsDescriptorType(nsValueObjects) : void 0;
|
|
259
|
+
const nsEnums = blindCast(ns.enum);
|
|
260
|
+
return [
|
|
261
|
+
nsId,
|
|
262
|
+
nsModelsType,
|
|
263
|
+
nsValueObjectsDescriptor,
|
|
264
|
+
nsEnums !== void 0 && Object.keys(nsEnums).length > 0 ? generateEnumBlockType(nsEnums) : void 0
|
|
265
|
+
];
|
|
266
|
+
}).map(([nsId, nsModelsType, nsValueObjectsDescriptor, nsEnumBlock]) => {
|
|
267
|
+
const voLine = nsValueObjectsDescriptor !== void 0 ? `\n readonly valueObjects: ${nsValueObjectsDescriptor};` : "";
|
|
268
|
+
const enumLine = nsEnumBlock !== void 0 ? `\n readonly enum: ${nsEnumBlock};` : "";
|
|
269
|
+
return ` readonly ${serializeObjectKey(nsId)}: {\n readonly models: ${nsModelsType};${voLine}${enumLine}\n }`;
|
|
270
|
+
}).join(";\n");
|
|
271
|
+
const executionClause = contract.execution !== void 0 ? `\n readonly execution: ${serializeExecutionType(contract.execution)};` : "";
|
|
272
|
+
const resolveFieldTypeParams = emitter.resolveFieldTypeParams ? (modelName, fieldName, model) => emitter.resolveFieldTypeParams?.(modelName, fieldName, model, contract) : void 0;
|
|
273
|
+
const resolveFieldValueSet = emitter.resolveFieldValueSet ? (modelName, fieldName, model) => emitter.resolveFieldValueSet?.(modelName, fieldName, model, contract) : void 0;
|
|
274
|
+
const fieldTypesMaps = generateFieldTypesMapsByNamespace(namespaceEntries.map(([nsId, ns]) => [nsId, ns.models]), codecLookup, resolveFieldTypeParams, resolveFieldValueSet);
|
|
275
|
+
const extraTypeExports = emitter.getStorageTypeExports?.(contract, codecLookup);
|
|
276
|
+
const contractWrapper = emitter.getContractWrapper("ContractBase", "TypeMaps");
|
|
277
|
+
const modelTypesBlock = generateModelTypesBlock(contract, {
|
|
278
|
+
codecLookup,
|
|
279
|
+
resolveFieldTypeParams,
|
|
280
|
+
resolveFieldValueSet
|
|
281
|
+
}, options?.supportsNamespaces ?? true);
|
|
282
|
+
return `// ⚠️ GENERATED FILE - DO NOT EDIT
|
|
283
|
+
// This file is automatically generated by 'prisma contract emit'.
|
|
284
|
+
// To regenerate, run: prisma contract emit
|
|
285
|
+
${importLines.join("\n")}
|
|
286
|
+
|
|
287
|
+
${familyImportLines.join("\n")}
|
|
288
|
+
import type {
|
|
289
|
+
Contract as ContractType,
|
|
290
|
+
ExecutionHashBase,
|
|
291
|
+
NamespaceId,
|
|
292
|
+
ProfileHashBase,
|
|
293
|
+
StorageHashBase,
|
|
294
|
+
} from '${resolveImportSpecifier("@internal/contract/types")}';
|
|
295
|
+
|
|
296
|
+
${hashAliases}
|
|
297
|
+
|
|
298
|
+
export type CodecTypes = ${codecTypes};
|
|
299
|
+
${familyTypeAliases}
|
|
300
|
+
${valueObjectTypeAliases}
|
|
301
|
+
export type FieldOutputTypes = ${fieldTypesMaps.output};
|
|
302
|
+
export type FieldInputTypes = ${fieldTypesMaps.input};
|
|
303
|
+
${extraTypeExports ? `${extraTypeExports}\n` : ""}
|
|
304
|
+
${modelTypesBlock}
|
|
305
|
+
|
|
306
|
+
export type TypeMaps = ${typeMapsExpr};
|
|
307
|
+
|
|
308
|
+
type ContractBase = Omit<
|
|
309
|
+
ContractType<${storageType}>,
|
|
310
|
+
'roots' | 'domain'
|
|
311
|
+
> & {
|
|
312
|
+
readonly target: ${serializeValue(contract.target)};
|
|
313
|
+
readonly targetFamily: ${serializeValue(contract.targetFamily)};
|
|
314
|
+
readonly roots: ${rootsType};
|
|
315
|
+
readonly domain: {
|
|
316
|
+
readonly namespaces: {
|
|
317
|
+
${domainNamespacesType};
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
readonly capabilities: ${serializeValue(contract.capabilities)};
|
|
321
|
+
readonly extensions: ${serializeValue(contract.extensions)};${executionClause}
|
|
322
|
+
readonly meta: ${serializeValue(contract.meta)};
|
|
323
|
+
${valueObjects ? `readonly valueObjects: ${valueObjectsDescriptor};` : ""}
|
|
324
|
+
readonly profileHash: ProfileHash;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
${contractWrapper}
|
|
328
|
+
`;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The emitter only ever consumes a freshly authored contract, so every same-space to-one relation
|
|
332
|
+
* must already state whether it is nullable. Hydration of an on-disk contract derives a missing
|
|
333
|
+
* flag instead; that path never reaches here.
|
|
334
|
+
*/
|
|
335
|
+
function requireToOneRelationNullability(contract) {
|
|
336
|
+
for (const [namespaceId, namespace] of Object.entries(contract.domain.namespaces)) for (const [modelName, model] of Object.entries(namespace.models)) for (const [relationName, relation] of Object.entries(model.relations ?? {})) {
|
|
337
|
+
if (!("on" in relation && (relation.cardinality === "1:1" || relation.cardinality === "N:1") && relation.to.space === void 0) || typeof relation.nullable === "boolean") continue;
|
|
338
|
+
throw emitterError("CONTRACT.RELATION_INVALID", `Relation "${relationName}" on model "${namespaceId}:${modelName}" is a ${relation.cardinality} relation and must carry a boolean "nullable"`, {
|
|
339
|
+
why: "contract.d.ts types a to-one relation as nullable or required from this flag, and the authoring surfaces always set it.",
|
|
340
|
+
fix: "Author the contract through PSL or the contract builder, which derive the flag from the local fields the relation joins on.",
|
|
341
|
+
meta: {
|
|
342
|
+
modelName,
|
|
343
|
+
relationName,
|
|
344
|
+
reason: "to-one-nullability-missing"
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
const SCHEMA_VERSION = "1";
|
|
350
|
+
async function emit(contract, stack, targetFamily, options) {
|
|
351
|
+
if (options.outputJsonPath !== void 0) getEmittedArtifactPaths(options.outputJsonPath);
|
|
352
|
+
requireToOneRelationNullability(contract);
|
|
353
|
+
const { codecTypeImports, queryOperationTypeImports, aggregateDescriptors, codecDescriptors } = stack;
|
|
354
|
+
const { storageHash } = contract.storage;
|
|
355
|
+
const executionHash = contract.execution?.executionHash;
|
|
356
|
+
const { profileHash } = contract;
|
|
357
|
+
const canonicalized = canonicalizeContractToObject(contract, {
|
|
358
|
+
schemaVersion: SCHEMA_VERSION,
|
|
359
|
+
serializeContract: options.serializeContract,
|
|
360
|
+
...ifDefined("shouldPreserveEmpty", options.shouldPreserveEmpty),
|
|
361
|
+
...ifDefined("sortStorage", options.sortStorage)
|
|
362
|
+
});
|
|
363
|
+
const contractJsonString = JSON.stringify({
|
|
364
|
+
...canonicalized,
|
|
365
|
+
_generated: {
|
|
366
|
+
warning: "⚠️ GENERATED FILE - DO NOT EDIT",
|
|
367
|
+
message: "This file is automatically generated by \"prisma contract emit\".",
|
|
368
|
+
regenerate: "To regenerate, run: prisma contract emit"
|
|
369
|
+
}
|
|
370
|
+
}, null, 2);
|
|
371
|
+
const generateOptions = {
|
|
372
|
+
...ifDefined("queryOperationTypeImports", queryOperationTypeImports),
|
|
373
|
+
...ifDefined("aggregateDescriptors", aggregateDescriptors),
|
|
374
|
+
...ifDefined("codecDescriptors", codecDescriptors),
|
|
375
|
+
...ifDefined("supportsNamespaces", options.supportsNamespaces)
|
|
376
|
+
};
|
|
377
|
+
const contractTypeHashes = {
|
|
378
|
+
storageHash,
|
|
379
|
+
...ifDefined("executionHash", executionHash),
|
|
380
|
+
profileHash
|
|
381
|
+
};
|
|
382
|
+
return {
|
|
383
|
+
contractJson: contractJsonString,
|
|
384
|
+
contractDts: await format(generateContractDts(contract, targetFamily, codecTypeImports ?? [], contractTypeHashes, generateOptions, stack.codecLookup, options.resolveImportSpecifier ?? keepInternalSpecifiers), {
|
|
385
|
+
parser: "typescript",
|
|
386
|
+
singleQuote: true,
|
|
387
|
+
semi: true,
|
|
388
|
+
printWidth: 100
|
|
389
|
+
}),
|
|
390
|
+
storageHash,
|
|
391
|
+
...ifDefined("executionHash", executionHash),
|
|
392
|
+
profileHash
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
396
|
+
export { generateContractDts as n, getEmittedArtifactPaths as r, emit as t };
|
|
397
|
+
|
|
398
|
+
//# sourceMappingURL=exports-CE6OD63o-4Qpqr2W7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports-CE6OD63o-4Qpqr2W7.mjs","names":[],"sources":["../../../../1-framework/3-tooling/emitter/dist/exports-CE6OD63o.mjs"],"sourcesContent":["import { D as serializeValue, E as serializeObjectKey, O as emitterError, _ as generateValueObjectTypeAliases, c as generateFieldTypesMapsByNamespace, h as generateRootsType, l as generateHashTypeAliases, m as generateModelsType, r as generateCodecTypeIntersection, t as deduplicateImports, u as generateImportLines, v as generateValueObjectsDescriptorType, w as serializeExecutionType, x as resolveModelFieldType } from \"./domain-type-generation-CR9ECUau.mjs\";\nimport { keepInternalSpecifiers } from \"@internal/framework-components/emission\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { canonicalizeContractToObject } from \"@internal/contract/hashing\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { format } from \"prettier\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\n//#region src/artifact-paths.ts\nconst JSON_EXTENSION = \".json\";\nfunction getEmittedArtifactPaths(outputJsonPath) {\n\tif (!outputJsonPath.endsWith(JSON_EXTENSION)) throw emitterError(\"CONFIG.VALIDATION_FAILED\", \"Contract output path must end with .json\", { meta: {\n\t\tfield: \"contract.output\",\n\t\toutputJsonPath\n\t} });\n\treturn {\n\t\tjsonPath: outputJsonPath,\n\t\tdtsPath: `${outputJsonPath.slice(0, -5)}.d.ts`\n\t};\n}\n//#endregion\n//#region src/model-types-emission.ts\nconst TYPESCRIPT_IDENTIFIER = /^[$A-Z_a-z][$\\w]*$/;\nfunction namespacedMemberName(namespaceId, modelName) {\n\treturn `${namespaceId === UNBOUND_NAMESPACE_ID ? \"unbound\" : namespaceId}_${modelName}`;\n}\nfunction bareMemberName(_namespaceId, modelName) {\n\treturn modelName;\n}\nfunction claimMemberName(claims, memberName, source) {\n\tif (!TYPESCRIPT_IDENTIFIER.test(memberName)) throw emitterError(\"CONTRACT.MODEL_TYPE_NAME_INVALID\", `Emitted model type name \"${memberName}\" (from ${source}) is not a TypeScript identifier`, {\n\t\twhy: \"Every entry in the emitted Models namespace is declared as `export type <name>`, so the name must be a TypeScript identifier.\",\n\t\tfix: \"Rename the namespace or model so that <namespace>_<Model> contains only letters, digits, `$`, and `_`, and does not start with a digit.\",\n\t\tmeta: {\n\t\t\tmemberName,\n\t\t\tsource\n\t\t}\n\t});\n\tconst existing = claims.get(memberName);\n\tif (existing !== void 0) throw emitterError(\"CONTRACT.MODEL_TYPE_NAME_COLLISION\", `Emitted model type name \"${memberName}\" is produced by both ${existing} and ${source}`, {\n\t\twhy: \"Every entry in the emitted Models namespace needs a distinct name, formed as <namespace>_<Model>.\",\n\t\tfix: \"Rename one of the models or namespaces so the two names differ.\",\n\t\tmeta: {\n\t\t\tmemberName,\n\t\t\tsources: [existing, source]\n\t\t}\n\t});\n\tclaims.set(memberName, source);\n}\nfunction isPolymorphicBase(model) {\n\treturn model.discriminator !== void 0 && model.variants !== void 0;\n}\nfunction findModelByName(namespaces, namespaceId, modelName) {\n\treturn namespaces.find((ns) => ns.namespaceId === namespaceId)?.models.find((m) => m.modelName === modelName);\n}\nfunction findModel(namespaces, ref) {\n\treturn findModelByName(namespaces, ref.namespace, ref.model);\n}\nfunction requireRelationTarget(namespaces, owner, relationName, ref) {\n\tconst target = findModel(namespaces, ref);\n\tif (target !== void 0) return target;\n\tconst ownerSource = `${owner.namespaceId}.${owner.modelName}`;\n\tthrow emitterError(\"CONTRACT.MODEL_RELATION_TARGET_MISSING\", `Relation \"${relationName}\" on ${ownerSource} targets ${ref.namespace}.${ref.model}, which is not in the contract`, {\n\t\twhy: \"A same-space relation must point at a model the contract declares; only cross-space relations may reference models outside it.\",\n\t\tfix: \"Declare the target model in the contract, or mark the relation as cross-space by giving its target a `space`.\",\n\t\tmeta: {\n\t\t\towner: ownerSource,\n\t\t\trelationName,\n\t\t\ttarget: {\n\t\t\t\tnamespaceId: ref.namespace,\n\t\t\t\tmodelName: ref.model\n\t\t\t}\n\t\t}\n\t});\n}\nfunction requireBase(namespaces, variant, base) {\n\tconst found = findModel(namespaces, base);\n\tif (found !== void 0) return found;\n\tconst variantSource = `${variant.namespaceId}.${variant.modelName}`;\n\tconst baseSource = `${base.namespace}.${base.model}`;\n\tthrow emitterError(\"CONTRACT.MODEL_BASE_MISSING\", `Model ${variantSource} names base ${baseSource}, which is not in the contract`, {\n\t\twhy: \"A variant's type is its base's fields plus its own, so the base must be a model the contract declares.\",\n\t\tfix: \"Declare the base model in the contract, or remove `base` from the variant.\",\n\t\tmeta: {\n\t\t\tvariant: variantSource,\n\t\t\tbase: baseSource\n\t\t}\n\t});\n}\nfunction requireVariant(namespaces, base, variantName) {\n\tconst variant = findModelByName(namespaces, base.namespaceId, variantName);\n\tif (variant !== void 0) return variant;\n\tconst baseSource = `${base.namespaceId}.${base.modelName}`;\n\tthrow emitterError(\"CONTRACT.MODEL_VARIANT_MISSING\", `Polymorphic base ${baseSource} names variant \"${variantName}\", which is not in the contract`, {\n\t\twhy: \"The Any<Base> union is the union of the variant model types, so every variant a base declares must be a model in the same namespace.\",\n\t\tfix: \"Declare the variant model in the same namespace as the base, or remove it from the base's variants.\",\n\t\tmeta: {\n\t\t\tbase: baseSource,\n\t\t\tvariantName\n\t\t}\n\t});\n}\nfunction collectFieldLines(ref, resolvers, discriminatorType) {\n\tconst lines = /* @__PURE__ */ new Map();\n\tfor (const [fieldName, field] of Object.entries(ref.model.fields)) {\n\t\tconst type = discriminatorType !== void 0 && fieldName === discriminatorType.field ? discriminatorType.type : resolveModelFieldType(ref.modelName, fieldName, field, ref.model, resolvers).output;\n\t\tlines.set(fieldName, `${serializeObjectKey(fieldName)}: ${type};`);\n\t}\n\treturn lines;\n}\nfunction hasJoin(relation) {\n\treturn \"on\" in relation && relation.on !== void 0;\n}\nfunction relationLine(owner, relationName, relation, index) {\n\tif (relation.to.space !== void 0) return void 0;\n\tconst target = requireRelationTarget(index.namespaces, owner, relationName, relation.to);\n\tconst targetMember = index.memberNameOf(target.namespaceId, isPolymorphicBase(target.model) ? `Any${target.modelName}` : target.modelName);\n\tconst key = serializeObjectKey(relationName);\n\tif (!hasJoin(relation)) return {\n\t\tline: `${key}: ${relation.cardinality === \"1:N\" ? `${targetMember}[]` : targetMember};`,\n\t\thasJoin: false\n\t};\n\tif (relation.cardinality === \"1:N\" || relation.cardinality === \"N:M\") return {\n\t\tline: `${key}: ${targetMember}[];`,\n\t\thasJoin: true\n\t};\n\treturn {\n\t\tline: `${key}: ${relation.nullable ? `${targetMember} | null` : targetMember};`,\n\t\thasJoin: true\n\t};\n}\nfunction collectRelationLines(ref, index) {\n\tconst lines = /* @__PURE__ */ new Map();\n\tfor (const [relationName, relation] of Object.entries(ref.model.relations)) {\n\t\tconst rendered = relationLine(ref, relationName, relation, index);\n\t\tif (rendered !== void 0) lines.set(relationName, rendered);\n\t}\n\treturn lines;\n}\nfunction discriminatorUnion(base) {\n\tconst values = Object.values(base.variants ?? {}).map((v) => serializeValue(v.value));\n\treturn values.length > 0 ? values.join(\" | \") : \"never\";\n}\nfunction memberLines(ref, index, resolvers) {\n\tconst base = ref.model.base !== void 0 ? requireBase(index.namespaces, ref, ref.model.base) : void 0;\n\tif (base !== void 0 && isPolymorphicBase(base.model)) {\n\t\tconst discriminatorField = base.model.discriminator?.field ?? \"\";\n\t\tconst variantValue = base.model.variants?.[ref.modelName]?.value;\n\t\tconst discriminatorType = {\n\t\t\tfield: discriminatorField,\n\t\t\ttype: variantValue !== void 0 ? serializeValue(variantValue) : discriminatorUnion(base.model)\n\t\t};\n\t\treturn {\n\t\t\tfieldsByName: new Map([...collectFieldLines(base, resolvers, discriminatorType), ...collectFieldLines(ref, resolvers, void 0)]),\n\t\t\trelationsByName: new Map([...collectRelationLines(base, index), ...collectRelationLines(ref, index)])\n\t\t};\n\t}\n\treturn {\n\t\tfieldsByName: collectFieldLines(ref, resolvers, isPolymorphicBase(ref.model) ? {\n\t\t\tfield: ref.model.discriminator?.field ?? \"\",\n\t\t\ttype: discriminatorUnion(ref.model)\n\t\t} : void 0),\n\t\trelationsByName: collectRelationLines(ref, index)\n\t};\n}\nfunction renderMember(memberName, lines, hasOwner) {\n\tconst entries = [...lines.relationsByName];\n\tconst joinlessLines = entries.filter(([, r]) => !r.hasJoin).map(([, r]) => r.line);\n\tconst joinedLines = entries.filter(([, r]) => r.hasJoin).map(([, r]) => r.line);\n\tconst relationNames = entries.filter(([, r]) => r.hasJoin).map(([name]) => name);\n\tconst phantom = relationNames.length > 0 ? relationNames.map((name) => serializeValue(name)).join(\" | \") : \"never\";\n\treturn ` export type ${memberName} = {\\n${[\n\t\t...lines.fieldsByName.values(),\n\t\t...joinlessLines,\n\t\t...joinedLines,\n\t\t...hasOwner ? [] : [`readonly [RelationKeys]?: ${phantom};`]\n\t].map((line) => ` ${line}`).join(\"\\n\")}\\n };`;\n}\nfunction namespaceModelsOf(contract) {\n\treturn Object.entries(contract.domain.namespaces).map(([namespaceId, ns]) => ({\n\t\tnamespaceId,\n\t\tmodels: Object.entries(ns.models).map(([modelName, model]) => ({\n\t\t\tnamespaceId,\n\t\t\tmodelName,\n\t\t\tmodel\n\t\t}))\n\t}));\n}\nfunction generateModelTypesBlock(contract, resolvers, supportsNamespaces) {\n\tconst memberNameOf = supportsNamespaces ? namespacedMemberName : bareMemberName;\n\tconst namespaces = namespaceModelsOf(contract);\n\tconst index = {\n\t\tnamespaces,\n\t\tmemberNameOf\n\t};\n\tconst claims = /* @__PURE__ */ new Map();\n\tfor (const ns of namespaces) for (const ref of ns.models) claimMemberName(claims, memberNameOf(ns.namespaceId, ref.modelName), `${ns.namespaceId}.${ref.modelName}`);\n\tfor (const ns of namespaces) for (const ref of ns.models) {\n\t\tif (!isPolymorphicBase(ref.model)) continue;\n\t\tclaimMemberName(claims, memberNameOf(ns.namespaceId, `Any${ref.modelName}`), `${ns.namespaceId}.Any<${ref.modelName}>`);\n\t}\n\tconst members = [];\n\tconst constantEntries = [];\n\tfor (const ns of namespaces) {\n\t\tconst keys = [];\n\t\tfor (const ref of ns.models) {\n\t\t\tconst memberName = memberNameOf(ns.namespaceId, ref.modelName);\n\t\t\tmembers.push(renderMember(memberName, memberLines(ref, index, resolvers), ref.model.owner !== void 0));\n\t\t\tkeys.push(`${serializeObjectKey(ref.modelName)}: Models.${memberName};`);\n\t\t}\n\t\tfor (const ref of ns.models) {\n\t\t\tif (!isPolymorphicBase(ref.model)) continue;\n\t\t\tconst unionName = memberNameOf(ns.namespaceId, `Any${ref.modelName}`);\n\t\t\tconst variantMembers = Object.keys(ref.model.variants ?? {}).map((variantName) => {\n\t\t\t\tconst variant = requireVariant(namespaces, ref, variantName);\n\t\t\t\treturn memberNameOf(variant.namespaceId, variant.modelName);\n\t\t\t});\n\t\t\tmembers.push(` export type ${unionName} = ${variantMembers.length > 0 ? variantMembers.join(\" | \") : \"never\"};`);\n\t\t\tkeys.push(`${serializeObjectKey(`Any${ref.modelName}`)}: Models.${unionName};`);\n\t\t}\n\t\tif (!supportsNamespaces) {\n\t\t\tconstantEntries.push(...keys.map((key) => ` ${key}`));\n\t\t\tcontinue;\n\t\t}\n\t\tconst nsKey = serializeObjectKey(ns.namespaceId);\n\t\tconst nested = keys.map((key) => ` ${key}`).join(\"\\n\");\n\t\tconstantEntries.push(keys.length > 0 ? ` ${nsKey}: {\\n${nested}\\n };` : ` ${nsKey}: {};`);\n\t}\n\treturn `${members.length > 0 ? `export namespace Models {\\n${members.join(\"\\n\")}\\n}` : \"export namespace Models {}\"}\\n\\n${`export declare const models: {\\n${constantEntries.join(\"\\n\")}\\n};`}`;\n}\n//#endregion\n//#region src/generate-contract-dts.ts\nfunction generateEnumBlockType(enums) {\n\treturn `{ ${Object.entries(enums).map(([name, entry]) => {\n\t\tconst membersType = `readonly [${entry.members.map((m) => `{ readonly name: ${serializeValue(m.name)}; readonly value: ${serializeValue(m.value)} }`).join(\", \")}]`;\n\t\treturn `readonly ${serializeObjectKey(name)}: { readonly codecId: ${serializeValue(entry.codecId)}; readonly members: ${membersType} }`;\n\t}).join(\"; \")} }`;\n}\nfunction generateContractDts(contract, emitter, codecTypeImports, hashes, options, codecLookup, resolveImportSpecifier = keepInternalSpecifiers) {\n\tconst allImports = [...codecTypeImports];\n\tif (options?.queryOperationTypeImports) allImports.push(...options.queryOperationTypeImports);\n\tconst importLines = generateImportLines(deduplicateImports(allImports), resolveImportSpecifier);\n\tconst familyImportLines = emitter.getFamilyImports(resolveImportSpecifier);\n\tconst hashAliases = generateHashTypeAliases(hashes);\n\tconst codecTypes = generateCodecTypeIntersection(codecTypeImports, \"CodecTypes\");\n\tconst familyTypeAliases = emitter.getFamilyTypeAliases(options);\n\tconst typeMapsExpr = emitter.getTypeMapsExpression();\n\tconst storageType = emitter.generateStorageType(contract, \"StorageHash\");\n\tconst namespaceEntries = Object.entries(contract.domain.namespaces);\n\tif (namespaceEntries.length === 0) throw emitterError(\"CONTRACT.NAMESPACE_INVALID\", \"domain has no namespaces\", { meta: { reason: \"no-domain-namespaces\" } });\n\tfor (const [nsId, ns] of namespaceEntries) if (ns === void 0) throw new InternalError(`domain namespace \"${nsId}\" is not present on the contract`);\n\tconst rootsType = generateRootsType(contract.roots);\n\tconst flatValueObjects = {};\n\tfor (const [, ns] of namespaceEntries) for (const [voName, vo] of Object.entries(blindCast(ns.valueObjects ?? {}))) if (!(voName in flatValueObjects)) flatValueObjects[voName] = vo;\n\tconst valueObjects = Object.keys(flatValueObjects).length > 0 ? flatValueObjects : void 0;\n\tconst valueObjectTypeAliases = generateValueObjectTypeAliases(valueObjects, codecLookup);\n\tconst valueObjectsDescriptor = generateValueObjectsDescriptorType(valueObjects);\n\tconst domainNamespacesType = namespaceEntries.map(([nsId, ns]) => {\n\t\tconst nsModels = ns.models;\n\t\tconst nsModelsType = generateModelsType(nsModels, (name, model) => emitter.generateModelStorageType(name, model));\n\t\tconst nsValueObjects = blindCast(ns.valueObjects);\n\t\tconst nsValueObjectsDescriptor = nsValueObjects !== void 0 && Object.keys(nsValueObjects).length > 0 ? generateValueObjectsDescriptorType(nsValueObjects) : void 0;\n\t\tconst nsEnums = blindCast(ns.enum);\n\t\treturn [\n\t\t\tnsId,\n\t\t\tnsModelsType,\n\t\t\tnsValueObjectsDescriptor,\n\t\t\tnsEnums !== void 0 && Object.keys(nsEnums).length > 0 ? generateEnumBlockType(nsEnums) : void 0\n\t\t];\n\t}).map(([nsId, nsModelsType, nsValueObjectsDescriptor, nsEnumBlock]) => {\n\t\tconst voLine = nsValueObjectsDescriptor !== void 0 ? `\\n readonly valueObjects: ${nsValueObjectsDescriptor};` : \"\";\n\t\tconst enumLine = nsEnumBlock !== void 0 ? `\\n readonly enum: ${nsEnumBlock};` : \"\";\n\t\treturn ` readonly ${serializeObjectKey(nsId)}: {\\n readonly models: ${nsModelsType};${voLine}${enumLine}\\n }`;\n\t}).join(\";\\n\");\n\tconst executionClause = contract.execution !== void 0 ? `\\n readonly execution: ${serializeExecutionType(contract.execution)};` : \"\";\n\tconst resolveFieldTypeParams = emitter.resolveFieldTypeParams ? (modelName, fieldName, model) => emitter.resolveFieldTypeParams?.(modelName, fieldName, model, contract) : void 0;\n\tconst resolveFieldValueSet = emitter.resolveFieldValueSet ? (modelName, fieldName, model) => emitter.resolveFieldValueSet?.(modelName, fieldName, model, contract) : void 0;\n\tconst fieldTypesMaps = generateFieldTypesMapsByNamespace(namespaceEntries.map(([nsId, ns]) => [nsId, ns.models]), codecLookup, resolveFieldTypeParams, resolveFieldValueSet);\n\tconst extraTypeExports = emitter.getStorageTypeExports?.(contract, codecLookup);\n\tconst contractWrapper = emitter.getContractWrapper(\"ContractBase\", \"TypeMaps\");\n\tconst modelTypesBlock = generateModelTypesBlock(contract, {\n\t\tcodecLookup,\n\t\tresolveFieldTypeParams,\n\t\tresolveFieldValueSet\n\t}, options?.supportsNamespaces ?? true);\n\treturn `// ⚠️ GENERATED FILE - DO NOT EDIT\n// This file is automatically generated by 'prisma contract emit'.\n// To regenerate, run: prisma contract emit\n${importLines.join(\"\\n\")}\n\n${familyImportLines.join(\"\\n\")}\nimport type {\n Contract as ContractType,\n ExecutionHashBase,\n NamespaceId,\n ProfileHashBase,\n StorageHashBase,\n} from '${resolveImportSpecifier(\"@internal/contract/types\")}';\n\n${hashAliases}\n\nexport type CodecTypes = ${codecTypes};\n${familyTypeAliases}\n${valueObjectTypeAliases}\nexport type FieldOutputTypes = ${fieldTypesMaps.output};\nexport type FieldInputTypes = ${fieldTypesMaps.input};\n${extraTypeExports ? `${extraTypeExports}\\n` : \"\"}\n${modelTypesBlock}\n\nexport type TypeMaps = ${typeMapsExpr};\n\ntype ContractBase = Omit<\n ContractType<${storageType}>,\n 'roots' | 'domain'\n> & {\n readonly target: ${serializeValue(contract.target)};\n readonly targetFamily: ${serializeValue(contract.targetFamily)};\n readonly roots: ${rootsType};\n readonly domain: {\n readonly namespaces: {\n${domainNamespacesType};\n };\n };\n readonly capabilities: ${serializeValue(contract.capabilities)};\n readonly extensions: ${serializeValue(contract.extensions)};${executionClause}\n readonly meta: ${serializeValue(contract.meta)};\n ${valueObjects ? `readonly valueObjects: ${valueObjectsDescriptor};` : \"\"}\n readonly profileHash: ProfileHash;\n};\n\n${contractWrapper}\n`;\n}\n//#endregion\n//#region src/require-relation-nullability.ts\n/**\n* The emitter only ever consumes a freshly authored contract, so every same-space to-one relation\n* must already state whether it is nullable. Hydration of an on-disk contract derives a missing\n* flag instead; that path never reaches here.\n*/\nfunction requireToOneRelationNullability(contract) {\n\tfor (const [namespaceId, namespace] of Object.entries(contract.domain.namespaces)) for (const [modelName, model] of Object.entries(namespace.models)) for (const [relationName, relation] of Object.entries(model.relations ?? {})) {\n\t\tif (!(\"on\" in relation && (relation.cardinality === \"1:1\" || relation.cardinality === \"N:1\") && relation.to.space === void 0) || typeof relation.nullable === \"boolean\") continue;\n\t\tthrow emitterError(\"CONTRACT.RELATION_INVALID\", `Relation \"${relationName}\" on model \"${namespaceId}:${modelName}\" is a ${relation.cardinality} relation and must carry a boolean \"nullable\"`, {\n\t\t\twhy: \"contract.d.ts types a to-one relation as nullable or required from this flag, and the authoring surfaces always set it.\",\n\t\t\tfix: \"Author the contract through PSL or the contract builder, which derive the flag from the local fields the relation joins on.\",\n\t\t\tmeta: {\n\t\t\t\tmodelName,\n\t\t\t\trelationName,\n\t\t\t\treason: \"to-one-nullability-missing\"\n\t\t\t}\n\t\t});\n\t}\n}\n//#endregion\n//#region src/emit.ts\nconst SCHEMA_VERSION = \"1\";\nasync function emit(contract, stack, targetFamily, options) {\n\tif (options.outputJsonPath !== void 0) getEmittedArtifactPaths(options.outputJsonPath);\n\trequireToOneRelationNullability(contract);\n\tconst { codecTypeImports, queryOperationTypeImports, aggregateDescriptors, codecDescriptors } = stack;\n\tconst { storageHash } = contract.storage;\n\tconst executionHash = contract.execution?.executionHash;\n\tconst { profileHash } = contract;\n\tconst canonicalized = canonicalizeContractToObject(contract, {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tserializeContract: options.serializeContract,\n\t\t...ifDefined(\"shouldPreserveEmpty\", options.shouldPreserveEmpty),\n\t\t...ifDefined(\"sortStorage\", options.sortStorage)\n\t});\n\tconst contractJsonString = JSON.stringify({\n\t\t...canonicalized,\n\t\t_generated: {\n\t\t\twarning: \"⚠️ GENERATED FILE - DO NOT EDIT\",\n\t\t\tmessage: \"This file is automatically generated by \\\"prisma contract emit\\\".\",\n\t\t\tregenerate: \"To regenerate, run: prisma contract emit\"\n\t\t}\n\t}, null, 2);\n\tconst generateOptions = {\n\t\t...ifDefined(\"queryOperationTypeImports\", queryOperationTypeImports),\n\t\t...ifDefined(\"aggregateDescriptors\", aggregateDescriptors),\n\t\t...ifDefined(\"codecDescriptors\", codecDescriptors),\n\t\t...ifDefined(\"supportsNamespaces\", options.supportsNamespaces)\n\t};\n\tconst contractTypeHashes = {\n\t\tstorageHash,\n\t\t...ifDefined(\"executionHash\", executionHash),\n\t\tprofileHash\n\t};\n\treturn {\n\t\tcontractJson: contractJsonString,\n\t\tcontractDts: await format(generateContractDts(contract, targetFamily, codecTypeImports ?? [], contractTypeHashes, generateOptions, stack.codecLookup, options.resolveImportSpecifier ?? keepInternalSpecifiers), {\n\t\t\tparser: \"typescript\",\n\t\t\tsingleQuote: true,\n\t\t\tsemi: true,\n\t\t\tprintWidth: 100\n\t\t}),\n\t\tstorageHash,\n\t\t...ifDefined(\"executionHash\", executionHash),\n\t\tprofileHash\n\t};\n}\n//#endregion\nexport { generateContractDts as n, getEmittedArtifactPaths as r, emit as t };\n\n//# sourceMappingURL=exports-CE6OD63o.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,iBAAiB;AACvB,SAAS,wBAAwB,gBAAgB;CAChD,IAAI,CAAC,eAAe,SAAS,cAAc,GAAG,MAAM,aAAa,4BAA4B,4CAA4C,EAAE,MAAM;EAChJ,OAAO;EACP;CACD,EAAE,CAAC;CACH,OAAO;EACN,UAAU;EACV,SAAS,GAAG,eAAe,MAAM,GAAG,EAAE,EAAE;CACzC;AACD;AAGA,MAAM,wBAAwB;AAC9B,SAAS,qBAAqB,aAAa,WAAW;CACrD,OAAO,GAAG,gBAAgB,uBAAuB,YAAY,YAAY,GAAG;AAC7E;AACA,SAAS,eAAe,cAAc,WAAW;CAChD,OAAO;AACR;AACA,SAAS,gBAAgB,QAAQ,YAAY,QAAQ;CACpD,IAAI,CAAC,sBAAsB,KAAK,UAAU,GAAG,MAAM,aAAa,oCAAoC,4BAA4B,WAAW,UAAU,OAAO,mCAAmC;EAC9L,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA;EACD;CACD,CAAC;CACD,MAAM,WAAW,OAAO,IAAI,UAAU;CACtC,IAAI,aAAa,KAAK,GAAG,MAAM,aAAa,sCAAsC,4BAA4B,WAAW,wBAAwB,SAAS,OAAO,UAAU;EAC1K,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA,SAAS,CAAC,UAAU,MAAM;EAC3B;CACD,CAAC;CACD,OAAO,IAAI,YAAY,MAAM;AAC9B;AACA,SAAS,kBAAkB,OAAO;CACjC,OAAO,MAAM,kBAAkB,KAAK,KAAK,MAAM,aAAa,KAAK;AAClE;AACA,SAAS,gBAAgB,YAAY,aAAa,WAAW;CAC5D,OAAO,WAAW,MAAM,OAAO,GAAG,gBAAgB,WAAW,CAAC,EAAE,OAAO,MAAM,MAAM,EAAE,cAAc,SAAS;AAC7G;AAC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