@prisma/orm-toolchain 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.1

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.
Files changed (196) hide show
  1. package/README.md +1 -5
  2. package/dist/{aggregate-DLUJLq5Y.d.mts → aggregate-BpcQdygS.d.mts} +83 -36
  3. package/dist/aggregate-BpcQdygS.d.mts.map +1 -0
  4. package/dist/{aggregate-CPZB020V.mjs → aggregate-T_HG6gq6.mjs} +118 -57
  5. package/dist/aggregate-T_HG6gq6.mjs.map +1 -0
  6. package/dist/caught-errors-Bmbi1dBu-DKO5X2tN.mjs +1026 -0
  7. package/dist/caught-errors-Bmbi1dBu-DKO5X2tN.mjs.map +1 -0
  8. package/dist/cli-telemetry.d.mts +9 -8
  9. package/dist/cli-telemetry.d.mts.map +1 -1
  10. package/dist/cli-telemetry.mjs +30 -27
  11. package/dist/cli-telemetry.mjs.map +1 -1
  12. package/dist/cli.d.mts +7 -14
  13. package/dist/cli.d.mts.map +1 -1
  14. package/dist/cli.mjs +3769 -1506
  15. package/dist/cli.mjs.map +1 -1
  16. package/dist/cli__control-api.d.mts +233 -93
  17. package/dist/cli__control-api.d.mts.map +1 -1
  18. package/dist/cli__control-api.mjs +3 -2
  19. package/dist/cli__control-api__testing.d.mts +5 -4
  20. package/dist/cli__control-api__testing.d.mts.map +1 -1
  21. package/dist/cli__control-api__testing.mjs +21 -16
  22. package/dist/cli__control-api__testing.mjs.map +1 -1
  23. package/dist/cli__init-output.d.mts +11 -1
  24. package/dist/cli__init-output.d.mts.map +1 -1
  25. package/dist/cli__init-output.mjs +1 -1
  26. package/dist/cli__migration-cli.d.mts +1 -1
  27. package/dist/cli__migration-cli.mjs +65 -19
  28. package/dist/cli__migration-cli.mjs.map +1 -1
  29. package/dist/config-loader.d.mts +2 -2
  30. package/dist/config-loader.mjs +2 -2
  31. package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs → contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs} +44 -16
  32. package/dist/contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs.map +1 -0
  33. package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts +59 -0
  34. package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts.map +1 -0
  35. package/dist/contract-snapshot-store-DrIwu5pn.d.mts +2 -0
  36. package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts → db-sign-gvrl0kFE-D-nTGx88.d.mts} +330 -230
  37. package/dist/db-sign-gvrl0kFE-D-nTGx88.d.mts.map +1 -0
  38. package/dist/{domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs → domain-type-generation-B4m774CV-WAjyhZHw.mjs} +144 -154
  39. package/dist/domain-type-generation-B4m774CV-WAjyhZHw.mjs.map +1 -0
  40. package/dist/domain-type-generation-DZjtzrbE-BpOOD3YV.d.mts +78 -0
  41. package/dist/domain-type-generation-DZjtzrbE-BpOOD3YV.d.mts.map +1 -0
  42. package/dist/emitter.d.mts +3 -3
  43. package/dist/emitter.mjs +3 -3
  44. package/dist/emitter__domain-type-generation.d.mts +2 -2
  45. package/dist/emitter__domain-type-generation.mjs +2 -2
  46. package/dist/{errors-D59OCpoI.d.mts → errors-CLwhWJiz.d.mts} +14 -3
  47. package/dist/errors-CLwhWJiz.d.mts.map +1 -0
  48. package/dist/{errors-CXbGUWGu-CstQHPh6.mjs → errors-DXha_4l--relAaiI4.mjs} +37 -42
  49. package/dist/errors-DXha_4l--relAaiI4.mjs.map +1 -0
  50. package/dist/exports-BCIlMjIW-DkUBVDzl.mjs +421 -0
  51. package/dist/exports-BCIlMjIW-DkUBVDzl.mjs.map +1 -0
  52. package/dist/exports-BlYTE3-J.mjs +539 -0
  53. package/dist/exports-BlYTE3-J.mjs.map +1 -0
  54. package/dist/exports-CKgwcXbp.mjs +3973 -0
  55. package/dist/exports-CKgwcXbp.mjs.map +1 -0
  56. package/dist/graph-membership-DxpNgxfZ-BfqA-H7V.mjs +19 -0
  57. package/dist/graph-membership-DxpNgxfZ-BfqA-H7V.mjs.map +1 -0
  58. package/dist/{hash-DH8hl5Rq-BpM2t3Nu.mjs → hash-BAZVWU4a-BQovI7hF.mjs} +24 -3
  59. package/dist/hash-BAZVWU4a-BQovI7hF.mjs.map +1 -0
  60. package/dist/hash-CwWGlFWV.d.mts +1 -0
  61. package/dist/{hash-XZYYKJ-i.d.mts → hash-DclMqd7S-WBvXJ_4C.d.mts} +17 -4
  62. package/dist/hash-DclMqd7S-WBvXJ_4C.d.mts.map +1 -0
  63. package/dist/{import-roots-CfoYgejL.d.mts → import-roots-ARK1wjzc.d.mts} +3 -3
  64. package/dist/{import-roots-CfoYgejL.d.mts.map → import-roots-ARK1wjzc.d.mts.map} +1 -1
  65. package/dist/{import-roots-CNFBPAT1.mjs → import-roots-BPn2s_fq.mjs} +6 -6
  66. package/dist/import-roots-BPn2s_fq.mjs.map +1 -0
  67. package/dist/index-CWPFeYyi.d.mts +204 -0
  68. package/dist/index-CWPFeYyi.d.mts.map +1 -0
  69. package/dist/{index-Dgwl8Tzs.d.mts → index-tAySVPvZ.d.mts} +16 -4
  70. package/dist/index-tAySVPvZ.d.mts.map +1 -0
  71. package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs → invariants-DrF9p5Gd-BF70vGl1.mjs} +3 -3
  72. package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs.map → invariants-DrF9p5Gd-BF70vGl1.mjs.map} +1 -1
  73. package/dist/{io-635GlNx1-D3zrw2qu.mjs → io-BNxFm3eg-DYD82QeZ.mjs} +8 -8
  74. package/dist/io-BNxFm3eg-DYD82QeZ.mjs.map +1 -0
  75. package/dist/io-D8Epu7iY.d.mts +1 -0
  76. package/dist/{io-sr4CO9_t-C3eV_kn-.d.mts → io-DZfMV51z-BKlH5Dhb.d.mts} +9 -2
  77. package/dist/io-DZfMV51z-BKlH5Dhb.d.mts.map +1 -0
  78. package/dist/{migration-B2ljMJim.d.mts → migration-Bjz05034.d.mts} +12 -5
  79. package/dist/migration-Bjz05034.d.mts.map +1 -0
  80. package/dist/{migration-hspPIEeV.mjs → migration-CWyjX9vz.mjs} +18 -6
  81. package/dist/migration-CWyjX9vz.mjs.map +1 -0
  82. package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs → migration-graph-BoiiZAaU-DLht12k7.mjs} +6 -89
  83. package/dist/migration-graph-BoiiZAaU-DLht12k7.mjs.map +1 -0
  84. package/dist/{migration-graph-tarTxJ99-BrGBANeE.d.mts → migration-graph-D8IuOkZb-pSI7-k4_.d.mts} +7 -29
  85. package/dist/migration-graph-D8IuOkZb-pSI7-k4_.d.mts.map +1 -0
  86. package/dist/migration-graph-Dra4CcyN.d.mts +14 -0
  87. package/dist/migration-graph-Dra4CcyN.d.mts.map +1 -0
  88. package/dist/migration-tools.d.mts +17 -15
  89. package/dist/migration-tools.mjs +15 -15
  90. package/dist/migration-tools__aggregate.d.mts +2 -2
  91. package/dist/migration-tools__aggregate.mjs +2 -2
  92. package/dist/migration-tools__contract-snapshot-store.d.mts +4 -2
  93. package/dist/migration-tools__contract-snapshot-store.mjs +2 -2
  94. package/dist/migration-tools__errors.d.mts +2 -2
  95. package/dist/migration-tools__errors.mjs +1 -1
  96. package/dist/migration-tools__hash.d.mts +2 -1
  97. package/dist/migration-tools__hash.mjs +1 -1
  98. package/dist/migration-tools__invariants.mjs +1 -1
  99. package/dist/migration-tools__io.d.mts +2 -2
  100. package/dist/migration-tools__io.mjs +1 -1
  101. package/dist/migration-tools__migration-graph.d.mts +3 -3
  102. package/dist/migration-tools__migration-graph.mjs +3 -3
  103. package/dist/migration-tools__migration-ts.d.mts +2 -2
  104. package/dist/migration-tools__migration-ts.mjs +2 -2
  105. package/dist/migration-tools__migration.d.mts +1 -1
  106. package/dist/migration-tools__migration.mjs +1 -1
  107. package/dist/migration-tools__ref-resolution.d.mts +2 -2
  108. package/dist/migration-tools__ref-resolution.mjs +2 -2
  109. package/dist/migration-tools__refs.mjs +1 -1
  110. package/dist/migration-tools__spaces.d.mts +1 -1
  111. package/dist/migration-tools__spaces.mjs +2 -2
  112. package/dist/{migration-ts-DdVm0rws.mjs → migration-ts-DDgjsR1O.mjs} +6 -5
  113. package/dist/migration-ts-DDgjsR1O.mjs.map +1 -0
  114. package/dist/{migration-ts-CNaAtK8C.d.mts → migration-ts-SGer0PXq.d.mts} +4 -2
  115. package/dist/migration-ts-SGer0PXq.d.mts.map +1 -0
  116. package/dist/op-schema-3tXg0LTS-DqpOKDEa.mjs +23 -0
  117. package/dist/op-schema-3tXg0LTS-DqpOKDEa.mjs.map +1 -0
  118. package/dist/output-BcC8eB0h-C5bRd-aC.mjs +129 -0
  119. package/dist/output-BcC8eB0h-C5bRd-aC.mjs.map +1 -0
  120. package/dist/publish-surface.d.mts +1 -1
  121. package/dist/publish-surface.mjs +2 -2
  122. package/dist/publish-surface__import-roots.d.mts +1 -1
  123. package/dist/publish-surface__import-roots.mjs +1 -1
  124. package/dist/publish-surface__shells.mjs +1 -1
  125. package/dist/quick-reference-mongo.md +12 -12
  126. package/dist/quick-reference-postgres.md +10 -10
  127. package/dist/quick-reference-prisma7.md +80 -0
  128. package/dist/readme-mongo.md +6 -6
  129. package/dist/readme-postgres.md +6 -6
  130. package/dist/ref-DEiY2Cbd-1ZImpUEN.mjs +6663 -0
  131. package/dist/ref-DEiY2Cbd-1ZImpUEN.mjs.map +1 -0
  132. package/dist/{ref-resolution-COGOSL57.d.mts → ref-resolution-BPhR-kta.d.mts} +29 -11
  133. package/dist/ref-resolution-BPhR-kta.d.mts.map +1 -0
  134. package/dist/{ref-resolution-HeNBXW53.mjs → ref-resolution-Eo0QHp4f.mjs} +30 -6
  135. package/dist/ref-resolution-Eo0QHp4f.mjs.map +1 -0
  136. package/dist/{refs-WK86uYYp-gM8tvWQP.mjs → refs-DM3q3IZC-BC6H6P0X.mjs} +9 -9
  137. package/dist/refs-DM3q3IZC-BC6H6P0X.mjs.map +1 -0
  138. package/dist/{shells-C4HbRAr5.mjs → shells-w_yEDhe8.mjs} +98 -31
  139. package/dist/shells-w_yEDhe8.mjs.map +1 -0
  140. package/dist/{spaces-Dj65JrwZ.d.mts → spaces-BWULKO54.d.mts} +3 -3
  141. package/dist/{spaces-Dj65JrwZ.d.mts.map → spaces-BWULKO54.d.mts.map} +1 -1
  142. package/dist/{spaces-4qMOAYE9.mjs → spaces-c9xdiXW8.mjs} +14 -13
  143. package/dist/spaces-c9xdiXW8.mjs.map +1 -0
  144. package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs → verify-contract-spaces-YzEHF9zj-DGZgox_3.mjs} +7 -7
  145. package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map → verify-contract-spaces-YzEHF9zj-DGZgox_3.mjs.map} +1 -1
  146. package/dist/vite-plugin-contract-emit.d.mts +1 -1
  147. package/dist/vite-plugin-contract-emit.mjs +10 -10
  148. package/dist/vite-plugin-contract-emit.mjs.map +1 -1
  149. package/package.json +16 -15
  150. package/dist/aggregate-CPZB020V.mjs.map +0 -1
  151. package/dist/aggregate-DLUJLq5Y.d.mts.map +0 -1
  152. package/dist/contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map +0 -1
  153. package/dist/contract-snapshot-store-CbqynbtE.d.mts +0 -28
  154. package/dist/contract-snapshot-store-CbqynbtE.d.mts.map +0 -1
  155. package/dist/db-verify-BwgNK50T-DGvKgFCK.d.mts.map +0 -1
  156. package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts +0 -63
  157. package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts.map +0 -1
  158. package/dist/domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs.map +0 -1
  159. package/dist/errors-CXbGUWGu-CstQHPh6.mjs.map +0 -1
  160. package/dist/errors-D59OCpoI.d.mts.map +0 -1
  161. package/dist/exports-8ZUN43ve.mjs +0 -1734
  162. package/dist/exports-8ZUN43ve.mjs.map +0 -1
  163. package/dist/exports-BCLg4CiV-05kuwcb0.mjs +0 -160
  164. package/dist/exports-BCLg4CiV-05kuwcb0.mjs.map +0 -1
  165. package/dist/exports-BZaG8_w_.mjs +0 -243
  166. package/dist/exports-BZaG8_w_.mjs.map +0 -1
  167. package/dist/graph-membership-BViWUMpP-C4lYYJdU.mjs +0 -14
  168. package/dist/graph-membership-BViWUMpP-C4lYYJdU.mjs.map +0 -1
  169. package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs.map +0 -1
  170. package/dist/hash-XZYYKJ-i.d.mts.map +0 -1
  171. package/dist/import-roots-CNFBPAT1.mjs.map +0 -1
  172. package/dist/index-DRs7L6N0.d.mts +0 -57
  173. package/dist/index-DRs7L6N0.d.mts.map +0 -1
  174. package/dist/index-Dgwl8Tzs.d.mts.map +0 -1
  175. package/dist/io-635GlNx1-D3zrw2qu.mjs.map +0 -1
  176. package/dist/io-DYfeLJxR.d.mts +0 -1
  177. package/dist/io-sr4CO9_t-C3eV_kn-.d.mts.map +0 -1
  178. package/dist/migration-B2ljMJim.d.mts.map +0 -1
  179. package/dist/migration-graph-Dqndu0i5.d.mts +0 -9
  180. package/dist/migration-graph-Dqndu0i5.d.mts.map +0 -1
  181. package/dist/migration-graph-_SJImD5V-BURyY1KM.mjs.map +0 -1
  182. package/dist/migration-graph-tarTxJ99-BrGBANeE.d.mts.map +0 -1
  183. package/dist/migration-hspPIEeV.mjs.map +0 -1
  184. package/dist/migration-ts-CNaAtK8C.d.mts.map +0 -1
  185. package/dist/migration-ts-DdVm0rws.mjs.map +0 -1
  186. package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs +0 -13
  187. package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs.map +0 -1
  188. package/dist/output-CovTDY14-CUoAqLML.mjs +0 -77
  189. package/dist/output-CovTDY14-CUoAqLML.mjs.map +0 -1
  190. package/dist/ref-h6InR6dO-rGfl18Jv.mjs +0 -4686
  191. package/dist/ref-h6InR6dO-rGfl18Jv.mjs.map +0 -1
  192. package/dist/ref-resolution-COGOSL57.d.mts.map +0 -1
  193. package/dist/ref-resolution-HeNBXW53.mjs.map +0 -1
  194. package/dist/refs-WK86uYYp-gM8tvWQP.mjs.map +0 -1
  195. package/dist/shells-C4HbRAr5.mjs.map +0 -1
  196. package/dist/spaces-4qMOAYE9.mjs.map +0 -1
@@ -0,0 +1,421 @@
1
+ import { E as serializeExecutionType, O as serializeObjectKey, _ as parameterizedOutputTypeFunctionsAlias, a as generateCodecTypeIntersection, c as generateHashTypeAliases, g as generateValueObjectsDescriptorType, h as generateValueObjectTypeAliases, i as fieldTypesMapExpression, k as serializeValue, l as generateImportLines, m as generateRootsType, n as deduplicateImports, p as generateModelsType, r as emitterError, s as generateFieldTypeOverridesMap, x as renderValueLiteralType } from "./domain-type-generation-B4m774CV-WAjyhZHw.mjs";
2
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
+ import { InternalError } from "@prisma/orm-framework/utils/internal-error";
4
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
5
+ import { canonicalizeContractToObject } from "@prisma/orm-framework/contract/hashing";
6
+ import { keepInternalSpecifiers } from "@prisma/orm-framework/components/emission";
7
+ import { format } from "prettier";
8
+ import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
9
+ import { UNBOUND_PSL_NAMESPACE_NAME } from "@prisma/orm-framework/components/psl-ast";
10
+ //#region ../../../1-framework/3-tooling/emitter/dist/exports-BCIlMjIW.mjs
11
+ const JSON_EXTENSION = ".json";
12
+ function getEmittedArtifactPaths(outputJsonPath) {
13
+ if (!outputJsonPath.endsWith(JSON_EXTENSION)) throw emitterError("CONFIG.VALIDATION_FAILED", "Contract output path must end with .json", { meta: {
14
+ field: "contract.output",
15
+ outputJsonPath
16
+ } });
17
+ return {
18
+ jsonPath: outputJsonPath,
19
+ dtsPath: `${outputJsonPath.slice(0, -5)}.d.ts`
20
+ };
21
+ }
22
+ const TYPESCRIPT_IDENTIFIER = /^[$A-Z_a-z][$\w]*$/;
23
+ function namespacedMemberName(namespaceId, modelName) {
24
+ return `${namespaceId === UNBOUND_NAMESPACE_ID ? UNBOUND_PSL_NAMESPACE_NAME : namespaceId}_${modelName}`;
25
+ }
26
+ function bareMemberName(_namespaceId, modelName) {
27
+ return modelName;
28
+ }
29
+ function claimMemberName(claims, memberName, source) {
30
+ if (!TYPESCRIPT_IDENTIFIER.test(memberName)) throw emitterError("CONTRACT.MODEL_TYPE_NAME_INVALID", `Emitted model type name "${memberName}" (from ${source}) is not a TypeScript identifier`, {
31
+ why: "Every entry in the emitted Models namespace is declared as `export type <name>`, so the name must be a TypeScript identifier.",
32
+ fix: "Rename the namespace or model so that <namespace>_<Model> contains only letters, digits, `$`, and `_`, and does not start with a digit.",
33
+ meta: {
34
+ memberName,
35
+ source
36
+ }
37
+ });
38
+ const existing = claims.get(memberName);
39
+ if (existing !== void 0) throw emitterError("CONTRACT.MODEL_TYPE_NAME_COLLISION", `Emitted model type name "${memberName}" is produced by both ${existing} and ${source}`, {
40
+ why: "Every entry in the emitted Models namespace needs a distinct name, formed as <namespace>_<Model>.",
41
+ fix: "Rename one of the models or namespaces so the two names differ.",
42
+ meta: {
43
+ memberName,
44
+ sources: [existing, source]
45
+ }
46
+ });
47
+ claims.set(memberName, source);
48
+ }
49
+ function isPolymorphicBase(model) {
50
+ return model.discriminator !== void 0 && model.variants !== void 0;
51
+ }
52
+ function findModel(namespaces, ref) {
53
+ return namespaces.find((ns) => ns.namespaceId === ref.namespace)?.models.find((m) => m.modelName === ref.model);
54
+ }
55
+ function requireRelationTarget(namespaces, owner, relationName, ref) {
56
+ const target = findModel(namespaces, ref);
57
+ if (target !== void 0) return target;
58
+ const ownerSource = `${owner.namespaceId}.${owner.modelName}`;
59
+ throw emitterError("CONTRACT.MODEL_RELATION_TARGET_MISSING", `Relation "${relationName}" on ${ownerSource} targets ${ref.namespace}.${ref.model}, which is not in the contract`, {
60
+ why: "A same-space relation must point at a model the contract declares; only cross-space relations may reference models outside it.",
61
+ fix: "Declare the target model in the contract, or mark the relation as cross-space by giving its target a `space`.",
62
+ meta: {
63
+ owner: ownerSource,
64
+ relationName,
65
+ target: {
66
+ namespaceId: ref.namespace,
67
+ modelName: ref.model
68
+ }
69
+ }
70
+ });
71
+ }
72
+ function requireBase(namespaces, variant, base) {
73
+ const found = findModel(namespaces, base);
74
+ if (found !== void 0) return found;
75
+ const variantSource = `${variant.namespaceId}.${variant.modelName}`;
76
+ const baseSource = `${base.namespace}.${base.model}`;
77
+ throw emitterError("CONTRACT.MODEL_BASE_MISSING", `Model ${variantSource} names base ${baseSource}, which is not in the contract`, {
78
+ why: "A variant's type is its base's fields plus its own, so the base must be a model the contract declares.",
79
+ fix: "Declare the base model in the contract, or remove `base` from the variant.",
80
+ meta: {
81
+ variant: variantSource,
82
+ base: baseSource
83
+ }
84
+ });
85
+ }
86
+ function requireVariant(namespaces, base, variantRef) {
87
+ const variant = findModel(namespaces, variantRef);
88
+ if (variant !== void 0) return variant;
89
+ const baseSource = `${base.namespaceId}.${base.modelName}`;
90
+ const variantSource = `${variantRef.namespace}.${variantRef.model}`;
91
+ throw emitterError("CONTRACT.MODEL_VARIANT_MISSING", `Polymorphic base ${baseSource} names variant ${variantSource}, which is not in the contract`, {
92
+ 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 contract.",
93
+ fix: "Declare the variant model, or remove it from the base's variants.",
94
+ meta: {
95
+ base: baseSource,
96
+ variant: variantSource
97
+ }
98
+ });
99
+ }
100
+ function collectFieldLines(ref, discriminatorType) {
101
+ const lines = /* @__PURE__ */ new Map();
102
+ for (const fieldName of Object.keys(ref.model.fields)) {
103
+ const type = discriminatorType !== void 0 && fieldName === discriminatorType.field ? discriminatorType.type : `FieldOutputTypes[${serializeValue(ref.namespaceId)}][${serializeValue(ref.modelName)}][${serializeValue(fieldName)}]`;
104
+ lines.set(fieldName, `${serializeObjectKey(fieldName)}: ${type};`);
105
+ }
106
+ return lines;
107
+ }
108
+ function hasJoin(relation) {
109
+ return "on" in relation && relation.on !== void 0;
110
+ }
111
+ function relationLine(owner, relationName, relation, index) {
112
+ if (relation.to.space !== void 0) return void 0;
113
+ const target = requireRelationTarget(index.namespaces, owner, relationName, relation.to);
114
+ const targetMember = index.memberNameOf(target.namespaceId, isPolymorphicBase(target.model) ? `Any${target.modelName}` : target.modelName);
115
+ const key = serializeObjectKey(relationName);
116
+ if (!hasJoin(relation)) return {
117
+ line: `${key}: ${relation.cardinality === "1:N" ? `${targetMember}[]` : targetMember};`,
118
+ hasJoin: false
119
+ };
120
+ if (relation.cardinality === "1:N" || relation.cardinality === "N:M") return {
121
+ line: `${key}: ${targetMember}[];`,
122
+ hasJoin: true
123
+ };
124
+ return {
125
+ line: `${key}: ${relation.nullable ? `${targetMember} | null` : targetMember};`,
126
+ hasJoin: true
127
+ };
128
+ }
129
+ function collectRelationLines(ref, index) {
130
+ const lines = /* @__PURE__ */ new Map();
131
+ for (const [relationName, relation] of Object.entries(ref.model.relations)) {
132
+ const rendered = relationLine(ref, relationName, relation, index);
133
+ if (rendered !== void 0) lines.set(relationName, rendered);
134
+ }
135
+ return lines;
136
+ }
137
+ function discriminatorUnion(base) {
138
+ const values = Object.keys(base.variants ?? {}).map((value) => serializeValue(value));
139
+ return values.length > 0 ? values.join(" | ") : "never";
140
+ }
141
+ function memberLines(ref, index) {
142
+ const base = ref.model.base !== void 0 ? requireBase(index.namespaces, ref, ref.model.base) : void 0;
143
+ if (base !== void 0 && isPolymorphicBase(base.model)) {
144
+ const discriminatorField = base.model.discriminator?.field ?? "";
145
+ const variantValue = Object.entries(base.model.variants ?? {}).find(([, variant]) => variant.namespace === ref.namespaceId && variant.model === ref.modelName)?.[0];
146
+ const discriminatorType = {
147
+ field: discriminatorField,
148
+ type: variantValue !== void 0 ? serializeValue(variantValue) : discriminatorUnion(base.model)
149
+ };
150
+ return {
151
+ fieldsByName: new Map([...collectFieldLines(base, discriminatorType), ...collectFieldLines(ref, void 0)]),
152
+ relationsByName: new Map([...collectRelationLines(base, index), ...collectRelationLines(ref, index)])
153
+ };
154
+ }
155
+ return {
156
+ fieldsByName: collectFieldLines(ref, isPolymorphicBase(ref.model) ? {
157
+ field: ref.model.discriminator?.field ?? "",
158
+ type: discriminatorUnion(ref.model)
159
+ } : void 0),
160
+ relationsByName: collectRelationLines(ref, index)
161
+ };
162
+ }
163
+ function renderMember(memberName, lines, hasOwner) {
164
+ const entries = [...lines.relationsByName];
165
+ const joinlessLines = entries.filter(([, r]) => !r.hasJoin).map(([, r]) => r.line);
166
+ const joinedLines = entries.filter(([, r]) => r.hasJoin).map(([, r]) => r.line);
167
+ const relationNames = entries.filter(([, r]) => r.hasJoin).map(([name]) => name);
168
+ const phantom = relationNames.length > 0 ? relationNames.map((name) => serializeValue(name)).join(" | ") : "never";
169
+ return ` export type ${memberName} = {\n${[
170
+ ...lines.fieldsByName.values(),
171
+ ...joinlessLines,
172
+ ...joinedLines,
173
+ ...hasOwner ? [] : [`readonly [RelationKeys]?: ${phantom};`]
174
+ ].map((line) => ` ${line}`).join("\n")}\n };`;
175
+ }
176
+ function namespaceModelsOf(contract) {
177
+ return Object.entries(contract.domain.namespaces).map(([namespaceId, ns]) => ({
178
+ namespaceId,
179
+ models: Object.entries(ns.models).map(([modelName, model]) => ({
180
+ namespaceId,
181
+ modelName,
182
+ model
183
+ }))
184
+ }));
185
+ }
186
+ function generateModelTypesBlock(contract, supportsNamespaces) {
187
+ const memberNameOf = supportsNamespaces ? namespacedMemberName : bareMemberName;
188
+ const namespaces = namespaceModelsOf(contract);
189
+ const index = {
190
+ namespaces,
191
+ memberNameOf
192
+ };
193
+ const claims = /* @__PURE__ */ new Map();
194
+ for (const ns of namespaces) for (const ref of ns.models) claimMemberName(claims, memberNameOf(ns.namespaceId, ref.modelName), `${ns.namespaceId}.${ref.modelName}`);
195
+ for (const ns of namespaces) for (const ref of ns.models) {
196
+ if (!isPolymorphicBase(ref.model)) continue;
197
+ claimMemberName(claims, memberNameOf(ns.namespaceId, `Any${ref.modelName}`), `${ns.namespaceId}.Any<${ref.modelName}>`);
198
+ }
199
+ const members = [];
200
+ const constantEntries = [];
201
+ for (const ns of namespaces) {
202
+ const keys = [];
203
+ for (const ref of ns.models) {
204
+ const memberName = memberNameOf(ns.namespaceId, ref.modelName);
205
+ members.push(renderMember(memberName, memberLines(ref, index), ref.model.owner !== void 0));
206
+ keys.push(`${serializeObjectKey(ref.modelName)}: Models.${memberName};`);
207
+ }
208
+ for (const ref of ns.models) {
209
+ if (!isPolymorphicBase(ref.model)) continue;
210
+ const unionName = memberNameOf(ns.namespaceId, `Any${ref.modelName}`);
211
+ const variantMembers = Object.values(ref.model.variants ?? {}).map((variantRef) => {
212
+ const variant = requireVariant(namespaces, ref, variantRef);
213
+ return memberNameOf(variant.namespaceId, variant.modelName);
214
+ });
215
+ members.push(` export type ${unionName} = ${variantMembers.length > 0 ? variantMembers.join(" | ") : "never"};`);
216
+ keys.push(`${serializeObjectKey(`Any${ref.modelName}`)}: Models.${unionName};`);
217
+ }
218
+ if (!supportsNamespaces) {
219
+ constantEntries.push(...keys.map((key) => ` ${key}`));
220
+ continue;
221
+ }
222
+ const nsKey = serializeObjectKey(ns.namespaceId);
223
+ const nested = keys.map((key) => ` ${key}`).join("\n");
224
+ constantEntries.push(keys.length > 0 ? ` ${nsKey}: {\n${nested}\n };` : ` ${nsKey}: {};`);
225
+ }
226
+ 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};`}`;
227
+ }
228
+ function generateEnumBlockType(enums) {
229
+ return `{ ${Object.entries(enums).map(([name, entry]) => {
230
+ const membersType = `readonly [${entry.members.map((m) => `{ readonly name: ${serializeValue(m.name)}; readonly value: ${serializeValue(m.value)} }`).join(", ")}]`;
231
+ return `readonly ${serializeObjectKey(name)}: { readonly codecId: ${serializeValue(entry.codecId)}; readonly members: ${membersType} }`;
232
+ }).join("; ")} }`;
233
+ }
234
+ /**
235
+ * Types each enum member as the value a query returns for it: the literal its codec renders for the stored form, or the codec's output type when the codec renders none.
236
+ */
237
+ function generateEnumMemberTypesBlock(enums, codecLookup) {
238
+ return `{ ${Object.entries(enums).map(([name, entry]) => {
239
+ const memberTupleItems = entry.members.map((m) => {
240
+ const valueType = renderValueLiteralType(m.value, entry.codecId, "output", codecLookup) ?? `CodecTypes[${serializeValue(entry.codecId)}]["output"]`;
241
+ return `{ readonly name: ${serializeValue(m.name)}; readonly value: ${valueType} }`;
242
+ });
243
+ return `readonly ${serializeObjectKey(name)}: readonly [${memberTupleItems.join(", ")}]`;
244
+ }).join("; ")} }`;
245
+ }
246
+ function generateContractDts(contract, emitter, codecTypeImports, hashes, options, codecLookup, resolveImportSpecifier = keepInternalSpecifiers) {
247
+ const allImports = [...codecTypeImports];
248
+ if (options?.queryOperationTypeImports) allImports.push(...options.queryOperationTypeImports);
249
+ if (options?.parameterizedOutputTypeImports) allImports.push(...options.parameterizedOutputTypeImports);
250
+ const uniqueImports = deduplicateImports(allImports);
251
+ const familyImportLines = emitter.getFamilyImports(resolveImportSpecifier);
252
+ const hashAliases = generateHashTypeAliases(hashes);
253
+ const codecTypes = generateCodecTypeIntersection(codecTypeImports, "CodecTypes");
254
+ const familyTypeAliases = emitter.getFamilyTypeAliases(options);
255
+ const typeMapsExpr = emitter.getTypeMapsExpression();
256
+ const storageType = emitter.generateStorageType(contract, "StorageHash");
257
+ const namespaceEntries = Object.entries(contract.domain.namespaces);
258
+ if (namespaceEntries.length === 0) throw emitterError("CONTRACT.NAMESPACE_INVALID", "domain has no namespaces", { meta: { reason: "no-domain-namespaces" } });
259
+ for (const [nsId, ns] of namespaceEntries) if (ns === void 0) throw new InternalError(`domain namespace "${nsId}" is not present on the contract`);
260
+ const rootsType = generateRootsType(contract.roots);
261
+ const flatValueObjects = {};
262
+ const valueObjectNamespaces = [];
263
+ for (const [nsId, ns] of namespaceEntries) for (const [voName, vo] of Object.entries(blindCast(ns.valueObjects ?? {}))) if (!(voName in flatValueObjects)) {
264
+ flatValueObjects[voName] = vo;
265
+ valueObjectNamespaces.push([voName, nsId]);
266
+ }
267
+ const valueObjects = Object.keys(flatValueObjects).length > 0 ? flatValueObjects : void 0;
268
+ const valueObjectTypeAliases = generateValueObjectTypeAliases(valueObjectNamespaces);
269
+ const valueObjectsDescriptor = generateValueObjectsDescriptorType(valueObjects);
270
+ const domainNamespacesType = namespaceEntries.map(([nsId, ns]) => {
271
+ const nsModels = ns.models;
272
+ const nsModelsType = generateModelsType(nsModels, (name, model) => emitter.generateModelStorageType(name, model));
273
+ const nsValueObjects = blindCast(ns.valueObjects);
274
+ const nsValueObjectsDescriptor = nsValueObjects !== void 0 && Object.keys(nsValueObjects).length > 0 ? generateValueObjectsDescriptorType(nsValueObjects) : void 0;
275
+ const nsEnums = blindCast(ns.enum);
276
+ const hasEnums = nsEnums !== void 0 && Object.keys(nsEnums).length > 0;
277
+ return [
278
+ nsId,
279
+ nsModelsType,
280
+ nsValueObjectsDescriptor,
281
+ hasEnums ? generateEnumBlockType(nsEnums) : void 0,
282
+ hasEnums ? generateEnumMemberTypesBlock(nsEnums, codecLookup) : void 0
283
+ ];
284
+ }).map(([nsId, nsModelsType, nsValueObjectsDescriptor, nsEnumBlock, nsEnumMemberTypesBlock]) => {
285
+ const voLine = nsValueObjectsDescriptor !== void 0 ? `\n readonly valueObjects: ${nsValueObjectsDescriptor};` : "";
286
+ const enumLine = nsEnumBlock !== void 0 ? `\n readonly enum: ${nsEnumBlock};` : "";
287
+ const enumMemberTypesLine = nsEnumMemberTypesBlock !== void 0 ? `\n readonly enumMemberTypes?: ${nsEnumMemberTypesBlock};` : "";
288
+ return ` readonly ${serializeObjectKey(nsId)}: {\n readonly models: ${nsModelsType};${voLine}${enumLine}${enumMemberTypesLine}\n }`;
289
+ }).join(";\n");
290
+ const executionClause = contract.execution !== void 0 ? `\n readonly execution: ${serializeExecutionType(contract.execution)};` : "";
291
+ const fieldTypeOverrides = generateFieldTypeOverridesMap(contract, codecLookup, emitter.resolveStorageValueSet ? (modelName, fieldName, model) => emitter.resolveStorageValueSet?.(modelName, fieldName, model, contract) : void 0);
292
+ const extraTypeExports = emitter.getStorageTypeExports?.(contract, codecLookup);
293
+ const contractWrapper = emitter.getContractWrapper("ContractBase", "TypeMaps");
294
+ const modelTypesBlock = generateModelTypesBlock(contract, options?.supportsNamespaces ?? true);
295
+ const body = `${hashAliases}
296
+
297
+ export type CodecTypes = ${codecTypes};
298
+ ${familyTypeAliases}
299
+ ${parameterizedOutputTypeFunctionsAlias(options?.parameterizedOutputTypeImports ?? [])}
300
+ ${valueObjectTypeAliases}
301
+ type FieldTypeOverrides = ${fieldTypeOverrides};
302
+ export type FieldOutputTypes = ${fieldTypesMapExpression("output")};
303
+ export type FieldInputTypes = ${fieldTypesMapExpression("input")};
304
+ ${extraTypeExports ? `${extraTypeExports}\n` : ""}
305
+ ${modelTypesBlock}
306
+
307
+ export type TypeMaps = ${typeMapsExpr};
308
+
309
+ type ContractBase = Omit<
310
+ ContractType<${storageType}>,
311
+ 'roots' | 'domain'
312
+ > & {
313
+ readonly target: ${serializeValue(contract.target)};
314
+ readonly targetFamily: ${serializeValue(contract.targetFamily)};
315
+ readonly roots: ${rootsType};
316
+ readonly domain: {
317
+ readonly namespaces: {
318
+ ${domainNamespacesType};
319
+ };
320
+ };
321
+ readonly capabilities: ${serializeValue(contract.capabilities)};
322
+ readonly extensions: ${serializeValue(contract.extensions)};${executionClause}
323
+ readonly meta: ${serializeValue(contract.meta)};
324
+ ${valueObjects ? `readonly valueObjects: ${valueObjectsDescriptor};` : ""}
325
+ readonly profileHash: ProfileHash;
326
+ };
327
+
328
+ ${contractWrapper}
329
+ `;
330
+ return `// ⚠️ GENERATED FILE - DO NOT EDIT
331
+ // This file is automatically generated by 'prisma contract emit'.
332
+ // To regenerate, run: prisma contract emit
333
+ ${generateImportLines(uniqueImports.filter((spec) => mentions(body, spec.alias)), resolveImportSpecifier).join("\n")}
334
+
335
+ ${familyImportLines.join("\n")}
336
+ import type {
337
+ Contract as ContractType,
338
+ ExecutionHashBase,
339
+ FieldTypesFromDomain,
340
+ NamespaceId,
341
+ ProfileHashBase,
342
+ StorageHashBase,${valueObjects ? "\n ValueObjectTypesFromDomain," : ""}
343
+ } from '${resolveImportSpecifier("@internal/contract/types")}';
344
+
345
+ ${body}`;
346
+ }
347
+ /** Whether `text` uses `identifier` as a whole identifier, not as part of a longer one. */
348
+ function mentions(text, identifier) {
349
+ const escaped = identifier.replace(/[$]/g, "\\$");
350
+ return new RegExp(`(?<![\\w$])${escaped}(?![\\w$])`).test(text);
351
+ }
352
+ /**
353
+ * The emitter only ever consumes a freshly authored contract, so every same-space to-one relation
354
+ * must already state whether it is nullable. Hydration of an on-disk contract derives a missing
355
+ * flag instead; that path never reaches here.
356
+ */
357
+ function requireToOneRelationNullability(contract) {
358
+ 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 ?? {})) {
359
+ if (!("on" in relation && (relation.cardinality === "1:1" || relation.cardinality === "N:1") && relation.to.space === void 0) || typeof relation.nullable === "boolean") continue;
360
+ throw emitterError("CONTRACT.RELATION_INVALID", `Relation "${relationName}" on model "${namespaceId}:${modelName}" is a ${relation.cardinality} relation and must carry a boolean "nullable"`, {
361
+ why: "contract.d.ts types a to-one relation as nullable or required from this flag, and the authoring surfaces always set it.",
362
+ fix: "Author the contract through PSL or the contract builder, which derive the flag from the local fields the relation joins on.",
363
+ meta: {
364
+ modelName,
365
+ relationName,
366
+ reason: "to-one-nullability-missing"
367
+ }
368
+ });
369
+ }
370
+ }
371
+ const SCHEMA_VERSION = "1";
372
+ async function emit(contract, stack, targetFamily, options) {
373
+ if (options.outputJsonPath !== void 0) getEmittedArtifactPaths(options.outputJsonPath);
374
+ requireToOneRelationNullability(contract);
375
+ const { codecTypeImports, queryOperationTypeImports, parameterizedOutputTypeImports, aggregateDescriptors, codecDescriptors } = stack;
376
+ const { storageHash } = contract.storage;
377
+ const executionHash = contract.execution?.executionHash;
378
+ const { profileHash } = contract;
379
+ const canonicalized = canonicalizeContractToObject(contract, {
380
+ schemaVersion: SCHEMA_VERSION,
381
+ serializeContract: options.serializeContract,
382
+ ...ifDefined("shouldPreserveEmpty", options.shouldPreserveEmpty),
383
+ ...ifDefined("sortStorage", options.sortStorage)
384
+ });
385
+ const contractJsonString = JSON.stringify({
386
+ ...canonicalized,
387
+ _generated: {
388
+ warning: "⚠️ GENERATED FILE - DO NOT EDIT",
389
+ message: "This file is automatically generated by \"prisma contract emit\".",
390
+ regenerate: "To regenerate, run: prisma contract emit"
391
+ }
392
+ }, null, 2);
393
+ const generateOptions = {
394
+ ...ifDefined("queryOperationTypeImports", queryOperationTypeImports),
395
+ ...ifDefined("parameterizedOutputTypeImports", parameterizedOutputTypeImports),
396
+ ...ifDefined("aggregateDescriptors", aggregateDescriptors),
397
+ ...ifDefined("codecDescriptors", codecDescriptors),
398
+ ...ifDefined("supportsNamespaces", options.supportsNamespaces)
399
+ };
400
+ const contractTypeHashes = {
401
+ storageHash,
402
+ ...ifDefined("executionHash", executionHash),
403
+ profileHash
404
+ };
405
+ return {
406
+ contractJson: contractJsonString,
407
+ contractDts: await format(generateContractDts(options.deserializeContract(canonicalized), targetFamily, codecTypeImports ?? [], contractTypeHashes, generateOptions, stack.codecLookup, options.resolveImportSpecifier ?? keepInternalSpecifiers), {
408
+ parser: "typescript",
409
+ singleQuote: true,
410
+ semi: true,
411
+ printWidth: 100
412
+ }),
413
+ storageHash,
414
+ ...ifDefined("executionHash", executionHash),
415
+ profileHash
416
+ };
417
+ }
418
+ //#endregion
419
+ export { generateContractDts as n, getEmittedArtifactPaths as r, emit as t };
420
+
421
+ //# sourceMappingURL=exports-BCIlMjIW-DkUBVDzl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-BCIlMjIW-DkUBVDzl.mjs","names":[],"sources":["../../../../1-framework/3-tooling/emitter/dist/exports-BCIlMjIW.mjs"],"sourcesContent":["import { D as serializeObjectKey, O as serializeValue, T as serializeExecutionType, b as renderValueLiteralType, c as generateImportLines, f as generateModelsType, g as parameterizedOutputTypeFunctionsAlias, h as generateValueObjectsDescriptorType, i as generateCodecTypeIntersection, k as emitterError, m as generateValueObjectTypeAliases, n as deduplicateImports, o as generateFieldTypeOverridesMap, p as generateRootsType, r as fieldTypesMapExpression, s as generateHashTypeAliases } from \"./domain-type-generation-B4m774CV.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\";\nimport { UNBOUND_PSL_NAMESPACE_NAME } from \"@internal/framework-components/psl-ast\";\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_PSL_NAMESPACE_NAME : 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 findModel(namespaces, ref) {\n\treturn namespaces.find((ns) => ns.namespaceId === ref.namespace)?.models.find((m) => m.modelName === 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, variantRef) {\n\tconst variant = findModel(namespaces, variantRef);\n\tif (variant !== void 0) return variant;\n\tconst baseSource = `${base.namespaceId}.${base.modelName}`;\n\tconst variantSource = `${variantRef.namespace}.${variantRef.model}`;\n\tthrow emitterError(\"CONTRACT.MODEL_VARIANT_MISSING\", `Polymorphic base ${baseSource} names variant ${variantSource}, 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 contract.\",\n\t\tfix: \"Declare the variant model, or remove it from the base's variants.\",\n\t\tmeta: {\n\t\t\tbase: baseSource,\n\t\t\tvariant: variantSource\n\t\t}\n\t});\n}\nfunction collectFieldLines(ref, discriminatorType) {\n\tconst lines = /* @__PURE__ */ new Map();\n\tfor (const fieldName of Object.keys(ref.model.fields)) {\n\t\tconst type = discriminatorType !== void 0 && fieldName === discriminatorType.field ? discriminatorType.type : `FieldOutputTypes[${serializeValue(ref.namespaceId)}][${serializeValue(ref.modelName)}][${serializeValue(fieldName)}]`;\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.keys(base.variants ?? {}).map((value) => serializeValue(value));\n\treturn values.length > 0 ? values.join(\" | \") : \"never\";\n}\nfunction memberLines(ref, index) {\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 = Object.entries(base.model.variants ?? {}).find(([, variant]) => variant.namespace === ref.namespaceId && variant.model === ref.modelName)?.[0];\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, discriminatorType), ...collectFieldLines(ref, 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, 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, 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), 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.values(ref.model.variants ?? {}).map((variantRef) => {\n\t\t\t\tconst variant = requireVariant(namespaces, ref, variantRef);\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}\n/**\n* Types each enum member as the value a query returns for it: the literal its codec renders for the stored form, or the codec's output type when the codec renders none.\n*/\nfunction generateEnumMemberTypesBlock(enums, codecLookup) {\n\treturn `{ ${Object.entries(enums).map(([name, entry]) => {\n\t\tconst memberTupleItems = entry.members.map((m) => {\n\t\t\tconst valueType = renderValueLiteralType(m.value, entry.codecId, \"output\", codecLookup) ?? `CodecTypes[${serializeValue(entry.codecId)}][\"output\"]`;\n\t\t\treturn `{ readonly name: ${serializeValue(m.name)}; readonly value: ${valueType} }`;\n\t\t});\n\t\treturn `readonly ${serializeObjectKey(name)}: readonly [${memberTupleItems.join(\", \")}]`;\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\tif (options?.parameterizedOutputTypeImports) allImports.push(...options.parameterizedOutputTypeImports);\n\tconst uniqueImports = deduplicateImports(allImports);\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\tconst valueObjectNamespaces = [];\n\tfor (const [nsId, ns] of namespaceEntries) for (const [voName, vo] of Object.entries(blindCast(ns.valueObjects ?? {}))) if (!(voName in flatValueObjects)) {\n\t\tflatValueObjects[voName] = vo;\n\t\tvalueObjectNamespaces.push([voName, nsId]);\n\t}\n\tconst valueObjects = Object.keys(flatValueObjects).length > 0 ? flatValueObjects : void 0;\n\tconst valueObjectTypeAliases = generateValueObjectTypeAliases(valueObjectNamespaces);\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\tconst hasEnums = nsEnums !== void 0 && Object.keys(nsEnums).length > 0;\n\t\treturn [\n\t\t\tnsId,\n\t\t\tnsModelsType,\n\t\t\tnsValueObjectsDescriptor,\n\t\t\thasEnums ? generateEnumBlockType(nsEnums) : void 0,\n\t\t\thasEnums ? generateEnumMemberTypesBlock(nsEnums, codecLookup) : void 0\n\t\t];\n\t}).map(([nsId, nsModelsType, nsValueObjectsDescriptor, nsEnumBlock, nsEnumMemberTypesBlock]) => {\n\t\tconst voLine = nsValueObjectsDescriptor !== void 0 ? `\\n readonly valueObjects: ${nsValueObjectsDescriptor};` : \"\";\n\t\tconst enumLine = nsEnumBlock !== void 0 ? `\\n readonly enum: ${nsEnumBlock};` : \"\";\n\t\tconst enumMemberTypesLine = nsEnumMemberTypesBlock !== void 0 ? `\\n readonly enumMemberTypes?: ${nsEnumMemberTypesBlock};` : \"\";\n\t\treturn ` readonly ${serializeObjectKey(nsId)}: {\\n readonly models: ${nsModelsType};${voLine}${enumLine}${enumMemberTypesLine}\\n }`;\n\t}).join(\";\\n\");\n\tconst executionClause = contract.execution !== void 0 ? `\\n readonly execution: ${serializeExecutionType(contract.execution)};` : \"\";\n\tconst fieldTypeOverrides = generateFieldTypeOverridesMap(contract, codecLookup, emitter.resolveStorageValueSet ? (modelName, fieldName, model) => emitter.resolveStorageValueSet?.(modelName, fieldName, model, contract) : void 0);\n\tconst extraTypeExports = emitter.getStorageTypeExports?.(contract, codecLookup);\n\tconst contractWrapper = emitter.getContractWrapper(\"ContractBase\", \"TypeMaps\");\n\tconst modelTypesBlock = generateModelTypesBlock(contract, options?.supportsNamespaces ?? true);\n\tconst body = `${hashAliases}\n\nexport type CodecTypes = ${codecTypes};\n${familyTypeAliases}\n${parameterizedOutputTypeFunctionsAlias(options?.parameterizedOutputTypeImports ?? [])}\n${valueObjectTypeAliases}\ntype FieldTypeOverrides = ${fieldTypeOverrides};\nexport type FieldOutputTypes = ${fieldTypesMapExpression(\"output\")};\nexport type FieldInputTypes = ${fieldTypesMapExpression(\"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\treturn `// ⚠️ GENERATED FILE - DO NOT EDIT\n// This file is automatically generated by 'prisma contract emit'.\n// To regenerate, run: prisma contract emit\n${generateImportLines(uniqueImports.filter((spec) => mentions(body, spec.alias)), resolveImportSpecifier).join(\"\\n\")}\n\n${familyImportLines.join(\"\\n\")}\nimport type {\n Contract as ContractType,\n ExecutionHashBase,\n FieldTypesFromDomain,\n NamespaceId,\n ProfileHashBase,\n StorageHashBase,${valueObjects ? \"\\n ValueObjectTypesFromDomain,\" : \"\"}\n} from '${resolveImportSpecifier(\"@internal/contract/types\")}';\n\n${body}`;\n}\n/** Whether `text` uses `identifier` as a whole identifier, not as part of a longer one. */\nfunction mentions(text, identifier) {\n\tconst escaped = identifier.replace(/[$]/g, \"\\\\$\");\n\treturn new RegExp(`(?<![\\\\w$])${escaped}(?![\\\\w$])`).test(text);\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, parameterizedOutputTypeImports, 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(\"parameterizedOutputTypeImports\", parameterizedOutputTypeImports),\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(options.deserializeContract(canonicalized), 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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