@prisma/orm-family-mongo 8.0.0-rc.9-dev.1 → 8.0.0-rc.9-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/{authoring-entity-types-Do4eLmih-DIruXcuT.mjs → authoring-entity-types-B7H9J2_9-DCHLPzmA.mjs} +10 -53
  2. package/dist/authoring-entity-types-B7H9J2_9-DCHLPzmA.mjs.map +1 -0
  3. package/dist/{contract-builder-DB8nguDE.d.mts → contract-builder-B171gPnd.d.mts} +34 -13
  4. package/dist/contract-builder-B171gPnd.d.mts.map +1 -0
  5. package/dist/{contract-builder-BFq0gOMV.mjs → contract-builder-DeB13CGv.mjs} +57 -21
  6. package/dist/contract-builder-DeB13CGv.mjs.map +1 -0
  7. package/dist/contract-psl.d.mts +1 -1
  8. package/dist/contract-psl.mjs +1 -1
  9. package/dist/contract-psl__provider.mjs +2 -2
  10. package/dist/contract-psl__provider.mjs.map +1 -1
  11. package/dist/contract-ts.d.mts +1 -1
  12. package/dist/contract-ts.mjs +1 -1
  13. package/dist/contract-ts__contract-builder.d.mts +1 -1
  14. package/dist/contract-ts__contract-builder.mjs +1 -1
  15. package/dist/contract.d.mts +2 -2
  16. package/dist/contract.mjs +3 -3
  17. package/dist/contract__entity-kinds.mjs +1 -1
  18. package/dist/{control-Cj81sPbj.d.mts → control-BOVl4EL2.d.mts} +3 -3
  19. package/dist/{control-Cj81sPbj.d.mts.map → control-BOVl4EL2.d.mts.map} +1 -1
  20. package/dist/{control-C7-kthr1.d.mts → control-CpITYpd_.d.mts} +2 -2
  21. package/dist/{control-C7-kthr1.d.mts.map → control-CpITYpd_.d.mts.map} +1 -1
  22. package/dist/{control-BNRwpUCl.mjs → control-D5x9n_lZ.mjs} +6 -6
  23. package/dist/{control-BNRwpUCl.mjs.map → control-D5x9n_lZ.mjs.map} +1 -1
  24. package/dist/{control-adapter-Db5pT77b.d.mts → control-adapter-DLwhgMWv.d.mts} +2 -2
  25. package/dist/{control-adapter-Db5pT77b.d.mts.map → control-adapter-DLwhgMWv.d.mts.map} +1 -1
  26. package/dist/{dist-DHrEJnhK.mjs → dist-CihRxcZp.mjs} +36 -3
  27. package/dist/dist-CihRxcZp.mjs.map +1 -0
  28. package/dist/emitter.mjs +1 -1
  29. package/dist/{entity-kinds-B4KNTF8z-DPIuUuuB.mjs → entity-kinds-ECKhAFXy-C28WoR6A.mjs} +23 -9
  30. package/dist/entity-kinds-ECKhAFXy-C28WoR6A.mjs.map +1 -0
  31. package/dist/{exports-C4RGBGzZ.mjs → exports-BSUZo1ZX.mjs} +2 -1
  32. package/dist/{exports-C4RGBGzZ.mjs.map → exports-BSUZo1ZX.mjs.map} +1 -1
  33. package/dist/family.d.mts +9 -9
  34. package/dist/family.mjs +7 -7
  35. package/dist/family__control-adapter.d.mts +1 -1
  36. package/dist/family__control.d.mts +1 -1
  37. package/dist/family__control.mjs +2 -2
  38. package/dist/family__ir.d.mts +2 -2
  39. package/dist/family__ir.mjs +2 -2
  40. package/dist/family__migration.d.mts +1 -1
  41. package/dist/family__migration.mjs +1 -1
  42. package/dist/family__pack.d.mts +1 -1
  43. package/dist/family__pack.mjs +2 -2
  44. package/dist/family__pack.mjs.map +1 -1
  45. package/dist/family__runtime.d.mts +2 -2
  46. package/dist/family__runtime.mjs +1 -1
  47. package/dist/family__schema-verify.d.mts +1 -1
  48. package/dist/family__schema-verify.mjs +1 -1
  49. package/dist/{field-accessor-DHsAPiW3-BdYCspQC.d.mts → field-accessor-DHsAPiW3-Eb0sq6UQ.d.mts} +2 -2
  50. package/dist/{field-accessor-DHsAPiW3-BdYCspQC.d.mts.map → field-accessor-DHsAPiW3-Eb0sq6UQ.d.mts.map} +1 -1
  51. package/dist/{index-DAOkcTCK.d.mts → index-BKUKT3Mr.d.mts} +3 -3
  52. package/dist/{index-DAOkcTCK.d.mts.map → index-BKUKT3Mr.d.mts.map} +1 -1
  53. package/dist/{index-DxoO-ywI.d.mts → index-BXl8FzP8.d.mts} +2 -2
  54. package/dist/{index-DxoO-ywI.d.mts.map → index-BXl8FzP8.d.mts.map} +1 -1
  55. package/dist/{index-BR0ue13b.d.mts → index-D4qRM5-9.d.mts} +2 -2
  56. package/dist/{index-BR0ue13b.d.mts.map → index-D4qRM5-9.d.mts.map} +1 -1
  57. package/dist/{index-Cd2zLiU6.d.mts → index-b88CnctD.d.mts} +20 -3
  58. package/dist/index-b88CnctD.d.mts.map +1 -0
  59. package/dist/{interpreter-BAcUM6H7-DNUcUApV.mjs → interpreter-BCt8cG3P-DJ8yDc_N.mjs} +40 -7
  60. package/dist/interpreter-BCt8cG3P-DJ8yDc_N.mjs.map +1 -0
  61. package/dist/{ir-CQrenTYt.d.mts → ir-BDrbEWTc.d.mts} +3 -24
  62. package/dist/ir-BDrbEWTc.d.mts.map +1 -0
  63. package/dist/ir-Ch2aPr7a.mjs.map +1 -1
  64. package/dist/lowering.d.mts +1 -1
  65. package/dist/{migration-CNDQv5yB.d.mts → migration-DwClgQcT.d.mts} +4 -4
  66. package/dist/{migration-CNDQv5yB.d.mts.map → migration-DwClgQcT.d.mts.map} +1 -1
  67. package/dist/{migration-dcM7u4HG.mjs → migration-c8VhrzyG.mjs} +2 -2
  68. package/dist/{migration-dcM7u4HG.mjs.map → migration-c8VhrzyG.mjs.map} +1 -1
  69. package/dist/{mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs → mongo-contract-serializer-DC_DM9_Y-D13m_FBX.mjs} +24 -5
  70. package/dist/mongo-contract-serializer-DC_DM9_Y-D13m_FBX.mjs.map +1 -0
  71. package/dist/{mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts → mongo-contract-view-AnejqfrQ-DSOAJRaT.d.mts} +2 -2
  72. package/dist/{mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts.map → mongo-contract-view-AnejqfrQ-DSOAJRaT.d.mts.map} +1 -1
  73. package/dist/{mongo-contract-view-rcWzby6f-wRBCUnBt.mjs → mongo-contract-view-JZOa0Ry--BZsUrVN_.mjs} +4 -4
  74. package/dist/{mongo-contract-view-rcWzby6f-wRBCUnBt.mjs.map → mongo-contract-view-JZOa0Ry--BZsUrVN_.mjs.map} +1 -1
  75. package/dist/orm.d.mts +6 -3
  76. package/dist/orm.d.mts.map +1 -1
  77. package/dist/orm.mjs +1 -1
  78. package/dist/{pack-ByR2mQ_8.d.mts → pack-B_cZ_TeB.d.mts} +2 -2
  79. package/dist/{pack-ByR2mQ_8.d.mts.map → pack-B_cZ_TeB.d.mts.map} +1 -1
  80. package/dist/query-ast.d.mts +1 -1
  81. package/dist/query-ast__control.d.mts +1 -1
  82. package/dist/query-builder.d.mts +2 -2
  83. package/dist/query-builder__contract-free.d.mts +2 -2
  84. package/dist/runtime-DdpOBdsJ.d.mts +1 -0
  85. package/dist/runtime.d.mts +2 -2
  86. package/dist/runtime.mjs +1 -1
  87. package/dist/schema-ir.d.mts +1 -1
  88. package/dist/{schema-verify-DJGr28XW.d.mts → schema-verify-DLoKsxIe.d.mts} +3 -3
  89. package/dist/{schema-verify-DJGr28XW.d.mts.map → schema-verify-DLoKsxIe.d.mts.map} +1 -1
  90. package/dist/{verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs → verify-mongo-schema-B0bMHQW0-DSZhsvrk.mjs} +2 -2
  91. package/dist/{verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs.map → verify-mongo-schema-B0bMHQW0-DSZhsvrk.mjs.map} +1 -1
  92. package/dist/wire.d.mts +1 -1
  93. package/package.json +19 -19
  94. package/dist/authoring-entity-types-Do4eLmih-DIruXcuT.mjs.map +0 -1
  95. package/dist/contract-builder-BFq0gOMV.mjs.map +0 -1
  96. package/dist/contract-builder-DB8nguDE.d.mts.map +0 -1
  97. package/dist/dist-DHrEJnhK.mjs.map +0 -1
  98. package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs.map +0 -1
  99. package/dist/index-Cd2zLiU6.d.mts.map +0 -1
  100. package/dist/interpreter-BAcUM6H7-DNUcUApV.mjs.map +0 -1
  101. package/dist/ir-CQrenTYt.d.mts.map +0 -1
  102. package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs.map +0 -1
  103. package/dist/runtime-DPkRW4iu.d.mts +0 -1
@@ -1,58 +1,15 @@
1
- import { structuredError } from "@prisma/orm-framework/utils/structured-error";
1
+ import "@prisma/orm-framework/contract/types";
2
+ import "@prisma/orm-framework/components/ir";
2
3
  import { blindCast } from "@prisma/orm-framework/utils/casts";
4
+ import "@prisma/orm-framework/contract/hashing";
5
+ import { enumType } from "@prisma/orm-framework/contract-authoring";
6
+ import "@prisma/orm-framework/errors/control";
3
7
  import { resolveEnumCodecId } from "@prisma/orm-framework/components/authoring";
4
8
  import { blockAttribute, str } from "@prisma/orm-framework/psl-parser";
5
- //#region ../../../2-mongo-family/9-family/dist/authoring-entity-types-Do4eLmih.mjs
6
- function contractError(code, message, options) {
7
- return structuredError(code, message, options);
8
- }
9
- const ENUM_TYPE_HANDLE_BRAND = "__prismaNextEnumTypeHandle__";
10
- function enumType(name, codec, ...members) {
11
- if (members.length === 0) throw contractError("CONTRACT.ENUM_INVALID", `enumType("${name}"): must have at least one member.`, { meta: {
12
- enumName: name,
13
- reason: "no-members"
14
- } });
15
- const seenNames = /* @__PURE__ */ new Set();
16
- const seenValues = /* @__PURE__ */ new Set();
17
- for (const m of members) {
18
- if (seenNames.has(m.name)) throw contractError("CONTRACT.ENUM_INVALID", `enumType("${name}"): duplicate member name "${m.name}". Member names must be unique.`, { meta: {
19
- enumName: name,
20
- member: m.name,
21
- reason: "duplicate-member-name"
22
- } });
23
- seenNames.add(m.name);
24
- const loweredValue = String(m.value);
25
- if (seenValues.has(loweredValue)) throw contractError("CONTRACT.ENUM_INVALID", `enumType("${name}"): duplicate member value "${loweredValue}". Member values must be unique.`, { meta: {
26
- enumName: name,
27
- member: loweredValue,
28
- reason: "duplicate-member-value"
29
- } });
30
- seenValues.add(loweredValue);
31
- }
32
- const values = Object.freeze(members.map((m) => m.value));
33
- const names = Object.freeze(members.map((m) => m.name));
34
- const enumMembers = Object.freeze(members.map((m) => ({
35
- name: m.name,
36
- value: m.value
37
- })));
38
- const membersAccessor = Object.freeze(Object.fromEntries(members.map((m) => [m.name, m.value])));
39
- const valueSet = new Set(values);
40
- const valueToName = new Map(members.map((m) => [m.value, m.name]));
41
- const valueToOrdinal = new Map(values.map((v, i) => [v, i]));
42
- return {
43
- [ENUM_TYPE_HANDLE_BRAND]: true,
44
- enumName: name,
45
- codecId: codec.codecId,
46
- nativeType: codec.nativeType,
47
- enumMembers,
48
- values,
49
- names,
50
- members: membersAccessor,
51
- has: (v) => valueSet.has(v),
52
- nameOf: (v) => valueToName.get(v),
53
- ordinalOf: (v) => valueToOrdinal.get(v) ?? -1
54
- };
55
- }
9
+ import "@prisma/orm-framework/utils/defined";
10
+ import "@prisma/orm-framework/components/control";
11
+ import "@prisma/orm-framework/utils/canonical-stringify";
12
+ //#region ../../../2-mongo-family/9-family/dist/authoring-entity-types-B7H9J2_9.mjs
56
13
  const mongoFamilyEntityTypes = { enum: {
57
14
  kind: "entity",
58
15
  discriminator: "enum",
@@ -179,4 +136,4 @@ const mongoFamilyPslBlockDescriptors = { enum: {
179
136
  //#endregion
180
137
  export { mongoFamilyPslBlockDescriptors as n, mongoFamilyEntityTypes as t };
181
138
 
182
- //# sourceMappingURL=authoring-entity-types-Do4eLmih-DIruXcuT.mjs.map
139
+ //# sourceMappingURL=authoring-entity-types-B7H9J2_9-DCHLPzmA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-entity-types-B7H9J2_9-DCHLPzmA.mjs","names":[],"sources":["../../../../2-mongo-family/9-family/dist/authoring-entity-types-B7H9J2_9.mjs"],"sourcesContent":["import \"@internal/utils/defined\";\nimport { resolveEnumCodecId } from \"@internal/framework-components/authoring\";\nimport \"@internal/contract/hashing\";\nimport \"@internal/contract/types\";\nimport { enumType } from \"@internal/contract-authoring\";\nimport \"@internal/errors/control\";\nimport \"@internal/framework-components/control\";\nimport \"@internal/framework-components/ir\";\nimport \"@internal/mongo-contract\";\nimport \"@internal/mongo-contract/canonicalization-hooks\";\nimport \"@internal/utils/canonical-stringify\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { blockAttribute, str } from \"@internal/psl-parser\";\nconst mongoFamilyEntityTypes = { enum: {\n\tkind: \"entity\",\n\tdiscriminator: \"enum\",\n\toutput: { factory: (block, ctx) => {\n\t\tconst sourceId = ctx.sourceId ?? \"unknown\";\n\t\tconst diagnostics = ctx.diagnostics;\n\t\tconst resolved = resolveEnumCodecId(block, ctx);\n\t\tif (resolved === void 0) return;\n\t\tconst { codecId, codecSpan } = resolved;\n\t\tconst nativeType = ctx.codecLookup?.targetTypesFor(codecId)?.[0];\n\t\tif (nativeType === void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type references unknown codec \"${codecId}\"`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst codec = ctx.codecLookup?.get(codecId);\n\t\tif (codec === void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type codec \"${codecId}\" resolves in targetTypesFor but is absent from codecLookup.get`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst seenValues = /* @__PURE__ */ new Set();\n\t\tconst members = [];\n\t\tlet memberError = false;\n\t\tfor (const [memberName, paramValue] of Object.entries(block.parameters)) {\n\t\t\tlet value;\n\t\t\tif (paramValue.kind === \"bare\") try {\n\t\t\t\tvalue = codec.decodeJson(memberName);\n\t\t\t} catch {\n\t\t\t\tdiagnostics?.push({\n\t\t\t\t\tcode: \"PSL_ENUM_BARE_MEMBER_NON_STRING_CODEC\",\n\t\t\t\t\tmessage: `enum \"${block.name}\" member \"${memberName}\" has no value and codec \"${codecId}\" does not accept a bare name as input`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: paramValue.span\n\t\t\t\t});\n\t\t\t\tmemberError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (paramValue.kind === \"value\") {\n\t\t\t\tlet jsonValue;\n\t\t\t\ttry {\n\t\t\t\t\tjsonValue = JSON.parse(paramValue.raw);\n\t\t\t\t} catch {\n\t\t\t\t\tdiagnostics?.push({\n\t\t\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\t\t\tmessage: `enum \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n\t\t\t\t\t\tsourceId,\n\t\t\t\t\t\tspan: paramValue.span\n\t\t\t\t\t});\n\t\t\t\t\tmemberError = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tvalue = codec.decodeJson(blindCast(jsonValue));\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconst reason = err instanceof Error ? err.message : String(err);\n\t\t\t\t\tdiagnostics?.push({\n\t\t\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\t\t\tmessage: `enum \"${block.name}\" member \"${memberName}\" was rejected by codec \"${codecId}\": ${reason}`,\n\t\t\t\t\t\tsourceId,\n\t\t\t\t\t\tspan: paramValue.span\n\t\t\t\t\t});\n\t\t\t\t\tmemberError = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else continue;\n\t\t\tconst valueKey = String(value);\n\t\t\tif (seenValues.has(valueKey)) {\n\t\t\t\tdiagnostics?.push({\n\t\t\t\t\tcode: \"PSL_ENUM_DUPLICATE_MEMBER_VALUE\",\n\t\t\t\t\tmessage: `enum \"${block.name}\": duplicate member value \"${valueKey}\"`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: paramValue.span\n\t\t\t\t});\n\t\t\t\tmemberError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseenValues.add(valueKey);\n\t\t\tmembers.push({\n\t\t\t\tname: memberName,\n\t\t\t\tvalue\n\t\t\t});\n\t\t}\n\t\tif (memberError) return void 0;\n\t\tif (members.length === 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_ENUM_MISSING_TYPE\",\n\t\t\t\tmessage: `enum \"${block.name}\" must have at least one member`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: block.span\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\treturn enumType(block.name, {\n\t\t\tcodecId,\n\t\t\tnativeType\n\t\t}, ...members.map((m) => ({\n\t\t\tname: m.name,\n\t\t\tvalue: m.value\n\t\t})));\n\t} }\n} };\nconst enumTypeBlockAttribute = blockAttribute(\"type\", { positional: [{\n\tkey: \"codecId\",\n\ttype: str()\n}] });\nconst mongoFamilyPslBlockDescriptors = { enum: {\n\tkind: \"pslBlock\",\n\tkeyword: \"enum\",\n\tdiscriminator: \"enum\",\n\tname: { required: true },\n\tparameters: {},\n\tvariadicParameters: true,\n\tattributes: { type: () => enumTypeBlockAttribute }\n} };\n//#endregion\nexport { mongoFamilyPslBlockDescriptors as n, mongoFamilyEntityTypes as t };\n\n//# sourceMappingURL=authoring-entity-types-B7H9J2_9.mjs.map"],"mappings":";;;;;;;;;;;;AAaA,MAAM,yBAAyB,EAAE,MAAM;CACtC,MAAM;CACN,eAAe;CACf,QAAQ,EAAE,UAAU,OAAO,QAAQ;EAClC,MAAM,WAAW,IAAI,YAAY;EACjC,MAAM,cAAc,IAAI;EACxB,MAAM,WAAW,mBAAmB,OAAO,GAAG;EAC9C,IAAI,aAAa,KAAK,GAAG;EACzB,MAAM,EAAE,SAAS,cAAc;EAC/B,MAAM,aAAa,IAAI,aAAa,eAAe,OAAO,CAAC,GAAG;EAC9D,IAAI,eAAe,KAAK,GAAG;GAC1B,aAA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B,IAAI,WAAW,IAAI,QAAQ,GAAG;IAC7B,aAAa,KAAK;KACjB,MAAM;KACN,SAAS,SAAS,MAAM,KAAK,6BAA6B,SAAS;KACnE;KACA,MAAM,WAAW;IAClB,CAAC;IACD,cAAc;IACd;GACD;GACA,WAAW,IAAI,QAAQ;GACvB,QAAQ,KAAK;IACZ,MAAM;IACN;GACD,CAAC;EACF;EACA,IAAI,aAAa,OAAO,KAAK;EAC7B,IAAI,QAAQ,WAAW,GAAG;GACzB,aAAa,KAAK;IACjB,MAAM;IACN,SAAS,SAAS,MAAM,KAAK;IAC7B;IACA,MAAM,MAAM;GACb,CAAC;GACD;EACD;EACA,OAAO,SAAS,MAAM,MAAM;GAC3B;GACA;EACD,GAAG,GAAG,QAAQ,KAAK,OAAO;GACzB,MAAM,EAAE;GACR,OAAO,EAAE;EACV,EAAE,CAAC;CACJ,EAAE;AACH,EAAE;AACF,MAAM,yBAAyB,eAAe,QAAQ,EAAE,YAAY,CAAC;CACpE,KAAK;CACL,MAAM,IAAI;AACX,CAAC,EAAE,CAAC;AACJ,MAAM,iCAAiC,EAAE,MAAM;CAC9C,MAAM;CACN,SAAS;CACT,eAAe;CACf,MAAM,EAAE,UAAU,KAAK;CACvB,YAAY,CAAC;CACb,oBAAoB;CACpB,YAAY,EAAE,YAAY,uBAAuB;AAClD,EAAE"}
@@ -1,8 +1,8 @@
1
1
  import { E as MongoIndexAuthoringInput, F as MongoIndexOptionsInput, J as MongoTypeMaps, O as MongoIndexFields, W as MongoStorageShape, v as MongoCollection, w as MongoContractWithTypeMaps, x as MongoCollectionOptionsAuthoringInput } from "./mongo-value-set-tNn9-pun-dJYx_rVD.mjs";
2
- import "./index-Cd2zLiU6.mjs";
2
+ import "./index-b88CnctD.mjs";
3
3
  import { ContractFieldType, ControlPolicy, CrossReference, ProfileHashBase, StorageHashBase } from "@prisma/orm-framework/contract/types";
4
4
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
5
- import { BoundEnumType, CodecTypeMap, EntityHelpersFromNamespace, EnumMember, EnumTypeHandle, ExtractAuthoringNamespaceFromPack, MergeExtensionAuthoringNamespaces, bindEnumType, enumType, isEnumTypeHandle, member } from "@prisma/orm-framework/contract-authoring";
5
+ import { BoundEnumType, CodecTypeMap, EntityHelpersFromNamespace, EnumMember, EnumTypeHandle, ExtractAuthoringNamespaceFromPack, MergeExtensionAuthoringNamespaces, bindEnumType, enumType as enumType$1, isEnumTypeHandle, member } from "@prisma/orm-framework/contract-authoring";
6
6
  import { ExtensionPackRef, FamilyPackRef, TargetPackRef } from "@prisma/orm-framework/components/components";
7
7
  //#region ../../../2-mongo-family/2-authoring/contract-ts/dist/contract-builder.d.mts
8
8
  //#region src/contract-builder.d.ts
@@ -78,11 +78,17 @@ interface RelationOn<LocalFields extends readonly string[] = readonly string[],
78
78
  readonly localFields: LocalFields;
79
79
  readonly targetFields: TargetFields;
80
80
  }
81
- interface RelationBuilder<To extends string = string, Cardinality extends '1:1' | '1:N' | 'N:1' = '1:1' | '1:N' | 'N:1', On extends RelationOn | undefined = RelationOn | undefined> {
81
+ interface RelationBuilder<To extends string = string, Cardinality extends '1:1' | '1:N' | 'N:1' = '1:1' | '1:N' | 'N:1', On extends RelationOn | undefined = RelationOn | undefined, Nullable extends boolean | undefined = boolean | undefined> {
82
82
  readonly __kind: 'relation';
83
83
  readonly __to: To;
84
84
  readonly __cardinality: Cardinality;
85
85
  readonly __on: On;
86
+ /**
87
+ * The authored `optional` flag of a `belongsTo`; `undefined` when the author
88
+ * gave none. Always `true` for a `hasOne` reference: the side without the
89
+ * foreign key has nothing guaranteeing the related document exists.
90
+ */
91
+ readonly __nullable: Nullable;
86
92
  }
87
93
  interface ModelBuilder<Name extends string = string, Fields extends Record<string, FieldBuilder> = Record<string, FieldBuilder>, Relations extends Record<string, RelationBuilder> = Record<string, RelationBuilder>, Collection extends string | undefined = string | undefined, Owner extends string | undefined = string | undefined, Base extends string | undefined = string | undefined, StorageRelations extends Record<string, StorageRelationSpec> | undefined = Record<string, StorageRelationSpec> | undefined, Discriminator extends {
88
94
  readonly field: string;
@@ -152,7 +158,14 @@ type ContractValueObjectFromBuilder<TBuilder> = TBuilder extends ValueObjectBuil
152
158
  readonly fields: ContractFieldsFromRecord<Fields>;
153
159
  }> : never;
154
160
  type ContractValueObjectsFromRecord<ValueObjects extends Record<string, AnyValueObjectBuilder>> = Simplify<{ readonly [K in keyof ValueObjects as ExtractValueObjectName<ValueObjects[K]>]: ContractValueObjectFromBuilder<ValueObjects[K]>; }>;
155
- type ContractRelationFromBuilder<TBuilder> = TBuilder extends RelationBuilder<infer To extends string, infer Cardinality extends '1:1' | '1:N' | 'N:1', infer On extends RelationOn | undefined> ? On extends RelationOn ? {
161
+ type AnyFieldNullable<Fields extends Record<string, AnyFieldBuilder>, FieldNames extends readonly string[]> = FieldNames[number] extends (infer Name) ? Name extends keyof Fields ? Fields[Name] extends FieldBuilder<ContractFieldType, true, boolean> ? true : never : never : never;
162
+ type ToOneRelationNullable<Fields extends Record<string, AnyFieldBuilder>, Cardinality extends '1:1' | 'N:1', On extends RelationOn, Nullable extends boolean | undefined> = Nullable extends boolean ? Nullable : Cardinality extends '1:1' ? true : [AnyFieldNullable<Fields, On['localFields']>] extends [never] ? false : true;
163
+ type ContractRelationFromBuilder<TBuilder, Fields extends Record<string, AnyFieldBuilder>> = TBuilder extends RelationBuilder<infer To extends string, infer Cardinality extends '1:1' | '1:N' | 'N:1', infer On extends RelationOn | undefined, infer Nullable extends boolean | undefined> ? On extends RelationOn ? Cardinality extends '1:1' | 'N:1' ? {
164
+ readonly to: CrossRefFor<To>;
165
+ readonly cardinality: Cardinality;
166
+ readonly nullable: ToOneRelationNullable<Fields, Cardinality, On, Nullable>;
167
+ readonly on: On;
168
+ } : {
156
169
  readonly to: CrossRefFor<To>;
157
170
  readonly cardinality: Cardinality;
158
171
  readonly on: On;
@@ -160,7 +173,7 @@ type ContractRelationFromBuilder<TBuilder> = TBuilder extends RelationBuilder<in
160
173
  readonly to: CrossRefFor<To>;
161
174
  readonly cardinality: Cardinality;
162
175
  } : never;
163
- type ContractRelationsFromRecord<Relations extends Record<string, AnyRelationBuilder>> = keyof Relations extends never ? Record<string, never> : Simplify<{ readonly [K in keyof Relations]: ContractRelationFromBuilder<Relations[K]>; }>;
176
+ type ContractRelationsFromRecord<Relations extends Record<string, AnyRelationBuilder>, Fields extends Record<string, AnyFieldBuilder>> = keyof Relations extends never ? Record<string, never> : Simplify<{ readonly [K in keyof Relations]: ContractRelationFromBuilder<Relations[K], Fields>; }>;
164
177
  type ContractModelStorageFromBuilder<TBuilder> = ModelStorageSection<TBuilder> & ModelStorageRelationsSection<TBuilder>;
165
178
  type MaybeOwner<Owner> = [Owner] extends [undefined] ? EmptyObject : {
166
179
  readonly owner: Owner & string;
@@ -178,7 +191,7 @@ type MaybeVariants<Variants> = [Variants] extends [undefined] ? EmptyObject : {
178
191
  };
179
192
  type ContractModelFromBuilder<TBuilder> = TBuilder extends NamedModelBuilder<string, infer Fields extends Record<string, AnyFieldBuilder>, infer Relations extends Record<string, AnyRelationBuilder>, string | undefined, infer Owner, infer Base, Record<string, StorageRelationSpec> | undefined, infer Discriminator, infer Variants> ? Simplify<{
180
193
  readonly fields: ContractFieldsFromRecord<Fields>;
181
- readonly relations: ContractRelationsFromRecord<Relations>;
194
+ readonly relations: ContractRelationsFromRecord<Relations, Fields>;
182
195
  readonly storage: ContractModelStorageFromBuilder<TBuilder>;
183
196
  } & MaybeOwner<Owner> & MaybeBase<Base> & MaybeDiscriminator<Discriminator> & MaybeVariants<Variants>> : never;
184
197
  type ContractModelsFromRecord<Models extends Record<string, AnyModelBuilder>> = Simplify<{ readonly [K in keyof Models as ExtractModelName<Models[K]>]: ContractModelFromBuilder<Models[K]>; }>;
@@ -364,15 +377,23 @@ type ReferenceOptions<Target extends ModelNameInput, From extends StringListInpu
364
377
  readonly from: From;
365
378
  readonly to: To;
366
379
  };
380
+ type BelongsToOptions<Target extends ModelNameInput, From extends StringListInput, To extends RelationTargetFieldsInput<NormalizeModelName<Target>>, Nullable extends boolean> = ReferenceOptions<Target, From, To> & {
381
+ /**
382
+ * Whether the related document may be absent. Defaults to whether any `from`
383
+ * field is optional; an explicit value that contradicts them is rejected.
384
+ */
385
+ readonly optional: Nullable;
386
+ };
367
387
  type RelationOnFromOptions<From extends StringListInput, To extends RelationTargetFieldsInput<string>> = {
368
388
  readonly localFields: NormalizeStringList<From>;
369
389
  readonly targetFields: NormalizeTargetFieldList<To>;
370
390
  };
371
- declare function hasOne<const Target extends ModelNameInput>(target: Target): RelationBuilder<NormalizeModelName<Target>, '1:1', undefined>;
372
- declare function hasOne<const Target extends ModelNameInput, const From extends StringListInput, const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To>): RelationBuilder<NormalizeModelName<Target>, '1:1', RelationOnFromOptions<From, To>>;
373
- declare function hasMany<const Target extends ModelNameInput>(target: Target): RelationBuilder<NormalizeModelName<Target>, '1:N', undefined>;
374
- declare function hasMany<const Target extends ModelNameInput, const From extends StringListInput, const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To>): RelationBuilder<NormalizeModelName<Target>, '1:N', RelationOnFromOptions<From, To>>;
375
- declare function belongsTo<const Target extends ModelNameInput, const From extends StringListInput, const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To>): RelationBuilder<NormalizeModelName<Target>, 'N:1', RelationOnFromOptions<From, To>>;
391
+ declare function hasOne<const Target extends ModelNameInput>(target: Target): RelationBuilder<NormalizeModelName<Target>, '1:1', undefined, undefined>;
392
+ declare function hasOne<const Target extends ModelNameInput, const From extends StringListInput, const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To>): RelationBuilder<NormalizeModelName<Target>, '1:1', RelationOnFromOptions<From, To>, true>;
393
+ declare function hasMany<const Target extends ModelNameInput>(target: Target): RelationBuilder<NormalizeModelName<Target>, '1:N', undefined, undefined>;
394
+ declare function hasMany<const Target extends ModelNameInput, const From extends StringListInput, const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To>): RelationBuilder<NormalizeModelName<Target>, '1:N', RelationOnFromOptions<From, To>, undefined>;
395
+ declare function belongsTo<const Target extends ModelNameInput, const From extends StringListInput, const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>, const Nullable extends boolean>(target: Target, options: BelongsToOptions<Target, From, To, Nullable>): RelationBuilder<NormalizeModelName<Target>, 'N:1', RelationOnFromOptions<From, To>, Nullable>;
396
+ declare function belongsTo<const Target extends ModelNameInput, const From extends StringListInput, const To extends RelationTargetFieldsInput<NormalizeModelName<Target>>>(target: Target, options: ReferenceOptions<Target, From, To>): RelationBuilder<NormalizeModelName<Target>, 'N:1', RelationOnFromOptions<From, To>, undefined>;
376
397
  declare const rel: {
377
398
  readonly belongsTo: typeof belongsTo;
378
399
  readonly hasMany: typeof hasMany;
@@ -441,5 +462,5 @@ declare function defineContract<const Definition extends ContractScaffold<Family
441
462
  readonly roots?: Record<string, ModelNameInput> | undefined;
442
463
  }, const Family extends FamilyPackRef<string> = FamilyPackRef<string>, const Target extends TargetPackRef<string, string> = TargetPackRef<string, string>, const Extensions extends Record<string, ExtensionPackRef<string, string>> | undefined = undefined>(definition: Definition, factory: (helpers: ContractAuthoringHelpers<Family, Target, Extensions>) => Built): MongoContractResult<Definition & Built>;
443
464
  //#endregion
444
- export { model as C, member as S, valueObject as T, defineContract as _, ContractScaffold as a, index as b, ExtractCodecTypesFromPack as c, ModelBuilder as d, MongoContractResult as f, buildBoundContract as g, bindEnumType as h, ContractFactory as i, FieldBuilder as l, ValueObjectBuilder as m, CodecTypeMap as n, EnumMember as o, RelationBuilder as p, ContractDefinition as r, EnumTypeHandle as s, BoundEnumType as t, FieldReference as u, enumType as v, rel as w, isEnumTypeHandle as x, field as y };
445
- //# sourceMappingURL=contract-builder-DB8nguDE.d.mts.map
465
+ export { model as C, member as S, valueObject as T, defineContract as _, ContractScaffold as a, index as b, ExtractCodecTypesFromPack as c, ModelBuilder as d, MongoContractResult as f, buildBoundContract as g, bindEnumType as h, ContractFactory as i, FieldBuilder as l, ValueObjectBuilder as m, CodecTypeMap as n, EnumMember as o, RelationBuilder as p, ContractDefinition as r, EnumTypeHandle as s, BoundEnumType as t, FieldReference as u, enumType$1 as v, rel as w, isEnumTypeHandle as x, field as y };
466
+ //# sourceMappingURL=contract-builder-B171gPnd.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-builder-B171gPnd.d.mts","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-ts/dist/contract-builder.d.mts"],"mappings":";;;;;;;;KAMK;WACM;;KAEN;WACM;;KAEN;KACA,QAAQ,KAAK,QAAQ;KACrB,cAAc;KACd,SAAS,QAAQ,WAAW,IAAI,EAAE,QAAQ;KAC1C,YAAY,QAAQ,SAAS,SAAS,QAAQ,OAAO,cAAc,cAAc;KACjF,oBAAoB,UAAU,yBAAyB,OAAO,kCAAkC,aAAa,yBAAyB;KACtI,0BAA0B,KAAK;EAClC,qBAAqB;IACnB,mBAAmB;EACrB;KACG,aAAa,wBAAwB;KACrC;WACM;aACE;aACA;;WAEF;aACE;aACA;;WAEF;aACE;aACA;;WAEF;aACE;aACA;;WAEF;aACE;aACA;;WAEF;aACE,OAAO;aACP,QAAQ;;WAEV;aACE;aACA;;;KAGR,yBAAyB,cAAc,2BAA2B,uBAAuB,WAAW,QAAQ,0BAA0B,MAAM,aAAa;KACzJ,6BAA6B,SAAS,cAAc,gCAAgC,sBAAsB,wBAAwB,yBAAyB,SAAS;UAC/J,aAAa,aAAa,oBAAoB,mBAAmB,oCAAoC,gCAAgC,eAAe,6BAA6B;WAChL;WACA,QAAQ;WACR,YAAY;WACZ,QAAQ;WACR,cAAc;EACvB,YAAY,aAAa,YAAY,MAAM;EAC3C,QAAQ,aAAa,MAAM,gBAAg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wB,eAAe,+CAA+C,eAAe,8BAA8B,YAAY,aAAa,oBAAoB;iBACjV,qBAAqB,mBAAmB,iBAAiB,QAAQ,QAAQ,YAAY,eAAe,oCAAoC;WAC9I,SAAS,eAAe;WACxB,eAAe,eAAe;WAC9B,QAAQ,eAAe;SACzB,eAAe,wBAAwB,6BAA6B,eAAe,gCAAgC,qCAAqC,mBAAmB,eAAe,2DAA2D,YAAY,YAAY,UAAU,SAAS,yBAAyB,QAAQ,QAAQ,gBAAgB,QAAQ,oBAAoB,aAAa"}
@@ -1,15 +1,15 @@
1
- import { i as MongoCollectionOptions, o as MongoIndex } from "./entity-kinds-B4KNTF8z-DPIuUuuB.mjs";
2
- import { a as applyPolymorphicScopeToMongoIndex, r as MongoStorage, s as buildMongoNamespace } from "./dist-DHrEJnhK.mjs";
1
+ import { i as MongoCollectionOptions, o as MongoIndex } from "./entity-kinds-ECKhAFXy-C28WoR6A.mjs";
2
+ import { c as buildMongoNamespace, o as applyPolymorphicScopeToMongoIndex, r as MongoStorage } from "./dist-CihRxcZp.mjs";
3
3
  import { t as mongoContractCanonicalizationHooks } from "./canonicalization-hooks-DF3Z6sjO.mjs";
4
4
  import { t as contractError } from "./contract-errors-BCN6RVI5-kMurtAbI.mjs";
5
5
  import { crossRef } from "@prisma/orm-framework/contract/types";
6
6
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
7
7
  import { blindCast } from "@prisma/orm-framework/utils/casts";
8
8
  import { computeProfileHash, computeStorageHash } from "@prisma/orm-framework/contract/hashing";
9
+ import { bindEnumType, createEntityHelpersFromNamespace, enumType as enumType$1, isEnumTypeHandle, member, resolveToOneRelationNullable } from "@prisma/orm-framework/contract-authoring";
9
10
  import { errorEnumCodecNotInPackStack } from "@prisma/orm-framework/errors/control";
10
11
  import { assertNoCrossRegistryCollisions, mergeAuthoringNamespaces } from "@prisma/orm-framework/components/authoring";
11
12
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
12
- import { bindEnumType, createEntityHelpersFromNamespace, enumType, isEnumTypeHandle, member } from "@prisma/orm-framework/contract-authoring";
13
13
  import { extractCodecLookup } from "@prisma/orm-framework/components/control";
14
14
  import { canonicalStringify } from "@prisma/orm-framework/utils/canonical-stringify";
15
15
  //#region ../../../2-mongo-family/2-authoring/contract-ts/dist/contract-builder.mjs
@@ -190,10 +190,11 @@ function createRelationBuilder(spec) {
190
190
  __kind: "relation",
191
191
  __to: spec.to,
192
192
  __cardinality: spec.cardinality,
193
- __on: spec.on
193
+ __on: spec.on,
194
+ __nullable: spec.nullable
194
195
  };
195
196
  }
196
- function createReferenceRelationBuilder(target, cardinality, options) {
197
+ function createReferenceRelationBuilder(target, cardinality, options, nullable) {
197
198
  const targetModelName = resolveModelName(target);
198
199
  return createRelationBuilder({
199
200
  to: targetModelName,
@@ -201,26 +202,28 @@ function createReferenceRelationBuilder(target, cardinality, options) {
201
202
  on: {
202
203
  localFields: normalizeStringList(options.from),
203
204
  targetFields: normalizeTargetFields(targetModelName, options.to)
204
- }
205
+ },
206
+ nullable
205
207
  });
206
208
  }
207
209
  function createEmbedRelationBuilder(target, cardinality) {
208
210
  return createRelationBuilder({
209
211
  to: resolveModelName(target),
210
212
  cardinality,
211
- on: void 0
213
+ on: void 0,
214
+ nullable: void 0
212
215
  });
213
216
  }
214
217
  function hasOne(target, options) {
215
218
  if (!options) return createEmbedRelationBuilder(target, "1:1");
216
- return createReferenceRelationBuilder(target, "1:1", options);
219
+ return createReferenceRelationBuilder(target, "1:1", options, true);
217
220
  }
218
221
  function hasMany(target, options) {
219
222
  if (!options) return createEmbedRelationBuilder(target, "1:N");
220
- return createReferenceRelationBuilder(target, "1:N", options);
223
+ return createReferenceRelationBuilder(target, "1:N", options, void 0);
221
224
  }
222
225
  function belongsTo(target, options) {
223
- return createReferenceRelationBuilder(target, "N:1", options);
226
+ return createReferenceRelationBuilder(target, "N:1", options, options.optional);
224
227
  }
225
228
  const rel = {
226
229
  belongsTo,
@@ -312,20 +315,53 @@ function buildFields(fields) {
312
315
  for (const [fieldName, fieldBuilder] of Object.entries(fields)) builtFields[fieldName] = buildContractField(fieldBuilder);
313
316
  return builtFields;
314
317
  }
315
- function buildRelation(relationBuilder) {
318
+ function toOneRelationNullable(modelName, relationName, relationBuilder, on, fields) {
319
+ const location = `Relation "${modelName}.${relationName}"`;
320
+ const ownsForeignKey = relationBuilder.__cardinality !== "1:1";
321
+ const localFields = ownsForeignKey ? on.localFields.map((fieldName) => {
322
+ const localField = fields[fieldName];
323
+ if (localField === void 0) throw contractError("CONTRACT.RELATION_INVALID", `${location} joins on local field "${fieldName}", which model "${modelName}" does not declare`, { meta: {
324
+ modelName,
325
+ relationName,
326
+ fieldName,
327
+ reason: "local-field-unknown"
328
+ } });
329
+ return localField;
330
+ }) : [];
331
+ const { nullable, contradiction } = resolveToOneRelationNullable({
332
+ declaredNullable: relationBuilder.__nullable,
333
+ localFieldNullability: localFields.map((localField) => localField.__nullable === true),
334
+ ownsReference: ownsForeignKey
335
+ });
336
+ if (contradiction !== void 0) throw contractError("CONTRACT.RELATION_INVALID", !ownsForeignKey ? `${location} is required but does not own the foreign key, so nothing in storage guarantees the related document exists` : contradiction === "declared-optional" ? `${location} is optional but every local field it joins on is required` : `${location} is required but a local field it joins on is nullable`, { meta: {
337
+ modelName,
338
+ relationName,
339
+ reason: "to-one-nullability-mismatch"
340
+ } });
341
+ return nullable;
342
+ }
343
+ function buildRelation(modelName, relationName, relationBuilder, fields) {
316
344
  const to = crossRef(relationBuilder.__to, UNBOUND_NAMESPACE_ID);
317
- return relationBuilder.__on ? {
318
- to,
319
- cardinality: relationBuilder.__cardinality,
320
- on: relationBuilder.__on
321
- } : {
345
+ const on = relationBuilder.__on;
346
+ if (on === void 0) return {
322
347
  to,
323
348
  cardinality: relationBuilder.__cardinality
324
349
  };
350
+ if (relationBuilder.__cardinality === "1:N") return {
351
+ to,
352
+ cardinality: "1:N",
353
+ on
354
+ };
355
+ return {
356
+ to,
357
+ cardinality: relationBuilder.__cardinality,
358
+ nullable: toOneRelationNullable(modelName, relationName, relationBuilder, on, fields),
359
+ on
360
+ };
325
361
  }
326
- function buildRelations(relations) {
362
+ function buildRelations(modelName, relations, fields) {
327
363
  const builtRelations = {};
328
- for (const [relationName, relationBuilder] of Object.entries(relations)) builtRelations[relationName] = buildRelation(relationBuilder);
364
+ for (const [relationName, relationBuilder] of Object.entries(relations)) builtRelations[relationName] = buildRelation(modelName, relationName, relationBuilder, fields);
329
365
  return builtRelations;
330
366
  }
331
367
  function buildValueObjects(valueObjects) {
@@ -352,7 +388,7 @@ function buildModels(models) {
352
388
  };
353
389
  builtModels[modelBuilder.__name] = {
354
390
  fields: buildFields(modelBuilder.__fields),
355
- relations: buildRelations(modelBuilder.__relations),
391
+ relations: buildRelations(modelBuilder.__name, modelBuilder.__relations, modelBuilder.__fields),
356
392
  storage,
357
393
  ...modelBuilder.__owner ? { owner: modelBuilder.__owner } : {},
358
394
  ...modelBuilder.__base ? { base: crossRef(modelBuilder.__base, UNBOUND_NAMESPACE_ID) } : {},
@@ -629,6 +665,6 @@ function defineContract(definition, factory) {
629
665
  return buildBoundContract(definition.family, definition.target, definition);
630
666
  }
631
667
  //#endregion
632
- export { field as a, member as c, valueObject as d, enumType as i, model as l, buildBoundContract as n, index as o, defineContract as r, isEnumTypeHandle as s, bindEnumType as t, rel as u };
668
+ export { field as a, member as c, valueObject as d, enumType$1 as i, model as l, buildBoundContract as n, index as o, defineContract as r, isEnumTypeHandle as s, bindEnumType as t, rel as u };
633
669
 
634
- //# sourceMappingURL=contract-builder-BFq0gOMV.mjs.map
670
+ //# sourceMappingURL=contract-builder-DeB13CGv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-builder-DeB13CGv.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-ts/dist/contract-builder.mjs"],"sourcesContent":["import { t as contractError } from \"./contract-errors-BCN6RVI5.mjs\";\nimport { computeProfileHash, computeStorageHash } from \"@internal/contract/hashing\";\nimport { crossRef } from \"@internal/contract/types\";\nimport { bindEnumType, createEntityHelpersFromNamespace, enumType, isEnumTypeHandle, member, resolveToOneRelationNullable } from \"@internal/contract-authoring\";\nimport { errorEnumCodecNotInPackStack } from \"@internal/errors/control\";\nimport { assertNoCrossRegistryCollisions, mergeAuthoringNamespaces } from \"@internal/framework-components/authoring\";\nimport { extractCodecLookup } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { MongoCollectionOptions, MongoIndex, MongoStorage, applyPolymorphicScopeToMongoIndex, buildMongoNamespace } from \"@internal/mongo-contract\";\nimport { mongoContractCanonicalizationHooks } from \"@internal/mongo-contract/canonicalization-hooks\";\nimport { canonicalStringify } from \"@internal/utils/canonical-stringify\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/contract-builder.ts\n/**\n* Encode an authored enum value to its codec-encoded JSON form, mirroring SQL's `build-contract`.\n*\n* The codec is resolved by id from the lookup built from the contract's target pack, so a\n* non-identity `encodeJson` (permitted by the `mongoCodec` factory) is respected. A codecId the\n* lookup cannot resolve is a hard error: the enum uses a codec that is not part of the contract's\n* pack stack.\n*/\nfunction encodeEnumValue(value, codecId, codecLookup) {\n\tconst codec = codecLookup.get(codecId);\n\tif (!codec) throw errorEnumCodecNotInPackStack({ codecId });\n\treturn codec.encodeJson(value);\n}\nfunction stableStringify(value) {\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\tif (value && typeof value === \"object\") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(\",\")}}`;\n\treturn JSON.stringify(value);\n}\nfunction extractEntitiesNamespace(component) {\n\treturn component.authoring?.entityTypes ?? {};\n}\nconst MONGO_RESERVED_HELPER_KEYS = [\n\t\"field\",\n\t\"index\",\n\t\"model\",\n\t\"rel\",\n\t\"valueObject\"\n];\nfunction composeMongoEntityHelpers(family, target, extensions) {\n\tconst components = [\n\t\tfamily,\n\t\ttarget,\n\t\t...Object.values(extensions ?? {})\n\t];\n\tconst merged = {};\n\tfor (const component of components) {\n\t\tconst ns = extractEntitiesNamespace(component);\n\t\tif (Object.keys(ns).length > 0) mergeAuthoringNamespaces(merged, ns, [], \"entity\", \"entity\");\n\t}\n\tassertNoCrossRegistryCollisions({}, {}, merged);\n\tconst collisions = Object.keys(merged).filter((name) => MONGO_RESERVED_HELPER_KEYS.includes(name));\n\tif (collisions.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Pack-contributed entity type(s) ${collisions.map((c) => `\"${c}\"`).join(\", \")} collide with the reserved built-in helper key(s) on the Mongo composed helpers surface. Reserved keys: ${MONGO_RESERVED_HELPER_KEYS.map((k) => `\"${k}\"`).join(\", \")}.`, { meta: {\n\t\treason: \"reserved-helper-key-collision\",\n\t\tcontribution: collisions\n\t} });\n\treturn createEntityHelpersFromNamespace(merged, { ctx: {\n\t\tfamily: family.familyId,\n\t\ttarget: target.targetId\n\t} });\n}\nfunction createFieldBuilder(spec, enumHandle) {\n\treturn {\n\t\t__kind: \"field\",\n\t\t__type: spec.type,\n\t\t__nullable: spec.nullable,\n\t\t__many: spec.many,\n\t\t__enumHandle: blindCast(enumHandle),\n\t\toptional() {\n\t\t\treturn createFieldBuilder({\n\t\t\t\ttype: spec.type,\n\t\t\t\tnullable: true,\n\t\t\t\tmany: spec.many\n\t\t\t}, enumHandle);\n\t\t},\n\t\tmany() {\n\t\t\treturn createFieldBuilder({\n\t\t\t\ttype: spec.type,\n\t\t\t\tnullable: spec.nullable,\n\t\t\t\tmany: true\n\t\t\t}, enumHandle);\n\t\t}\n\t};\n}\nfunction normalizeOptionalTypeParams(typeParams) {\n\tif (!typeParams) return {};\n\treturn { typeParams };\n}\nfunction createScalarFieldBuilder(codecId, options) {\n\treturn createFieldBuilder({\n\t\ttype: {\n\t\t\tkind: \"scalar\",\n\t\t\tcodecId,\n\t\t\t...normalizeOptionalTypeParams(options?.typeParams)\n\t\t},\n\t\tnullable: false,\n\t\tmany: false\n\t});\n}\nconst field = {\n\tscalar: createScalarFieldBuilder,\n\tobjectId() {\n\t\treturn createScalarFieldBuilder(\"mongo/objectId@1\");\n\t},\n\tstring() {\n\t\treturn createScalarFieldBuilder(\"mongo/string@1\");\n\t},\n\tdouble() {\n\t\treturn createScalarFieldBuilder(\"mongo/double@1\");\n\t},\n\tint32() {\n\t\treturn createScalarFieldBuilder(\"mongo/int32@1\");\n\t},\n\tbool() {\n\t\treturn createScalarFieldBuilder(\"mongo/bool@1\");\n\t},\n\tdate() {\n\t\treturn createScalarFieldBuilder(\"mongo/date@1\");\n\t},\n\tvector(options) {\n\t\treturn createScalarFieldBuilder(\"mongo/vector@1\", options);\n\t},\n\tvalueObject(valueObjectName) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: {\n\t\t\t\tkind: \"valueObject\",\n\t\t\t\tname: resolveValueObjectName(valueObjectName)\n\t\t\t},\n\t\t\tnullable: false,\n\t\t\tmany: false\n\t\t});\n\t},\n\tnamedType(handle) {\n\t\treturn createFieldBuilder({\n\t\t\ttype: blindCast({\n\t\t\t\tkind: \"scalar\",\n\t\t\t\tcodecId: handle.codecId\n\t\t\t}),\n\t\t\tnullable: false,\n\t\t\tmany: false\n\t\t}, handle);\n\t}\n};\nfunction index(fields, options) {\n\treturn {\n\t\tfields,\n\t\t...options ? { options } : {}\n\t};\n}\nfunction createFieldReference(modelName, fieldName) {\n\treturn {\n\t\t__kind: \"fieldRef\",\n\t\tmodelName,\n\t\tfieldName\n\t};\n}\nfunction isFieldReference(value) {\n\treturn typeof value === \"object\" && value !== null && \"__kind\" in value && value.__kind === \"fieldRef\";\n}\nfunction resolveModelName(value) {\n\treturn typeof value === \"string\" ? value : value.__name;\n}\nfunction resolveValueObjectName(value) {\n\treturn typeof value === \"string\" ? value : value.__name;\n}\nfunction normalizeStringList(value) {\n\treturn typeof value === \"string\" ? [value] : [...value];\n}\nfunction normalizeTargetField(targetModelName, value) {\n\tif (!isFieldReference(value)) return value;\n\tif (value.modelName !== targetModelName) throw contractError(\"CONTRACT.RELATION_INVALID\", `Relation target \"${targetModelName}\" cannot reference field \"${value.modelName}.${value.fieldName}\".`, { meta: {\n\t\tmodelName: targetModelName,\n\t\treason: \"cross-model-field-reference\",\n\t\treferencedModel: value.modelName,\n\t\treferencedField: value.fieldName\n\t} });\n\treturn value.fieldName;\n}\nfunction normalizeTargetFields(targetModelName, value) {\n\tif (typeof value === \"string\") return [value];\n\tif (isFieldReference(value)) return [normalizeTargetField(targetModelName, value)];\n\treturn value.map((entry) => normalizeTargetField(targetModelName, entry));\n}\nfunction createRelationBuilder(spec) {\n\treturn {\n\t\t__kind: \"relation\",\n\t\t__to: spec.to,\n\t\t__cardinality: spec.cardinality,\n\t\t__on: spec.on,\n\t\t__nullable: spec.nullable\n\t};\n}\nfunction createReferenceRelationBuilder(target, cardinality, options, nullable) {\n\tconst targetModelName = resolveModelName(target);\n\treturn createRelationBuilder({\n\t\tto: targetModelName,\n\t\tcardinality,\n\t\ton: {\n\t\t\tlocalFields: normalizeStringList(options.from),\n\t\t\ttargetFields: normalizeTargetFields(targetModelName, options.to)\n\t\t},\n\t\tnullable\n\t});\n}\nfunction createEmbedRelationBuilder(target, cardinality) {\n\treturn createRelationBuilder({\n\t\tto: resolveModelName(target),\n\t\tcardinality,\n\t\ton: void 0,\n\t\tnullable: void 0\n\t});\n}\nfunction hasOne(target, options) {\n\tif (!options) return createEmbedRelationBuilder(target, \"1:1\");\n\treturn createReferenceRelationBuilder(target, \"1:1\", options, true);\n}\nfunction hasMany(target, options) {\n\tif (!options) return createEmbedRelationBuilder(target, \"1:N\");\n\treturn createReferenceRelationBuilder(target, \"1:N\", options, void 0);\n}\nfunction belongsTo(target, options) {\n\treturn createReferenceRelationBuilder(target, \"N:1\", options, options.optional);\n}\nconst rel = {\n\tbelongsTo,\n\thasMany,\n\thasOne\n};\nfunction valueObject(name, input) {\n\treturn {\n\t\t__kind: \"valueObject\",\n\t\t__name: name,\n\t\t__fields: input.fields\n\t};\n}\nfunction model(name, input) {\n\treturn {\n\t\t__kind: \"model\",\n\t\t__name: name,\n\t\t__fields: input.fields,\n\t\t__relations: input.relations ?? {},\n\t\t__indexes: input.indexes,\n\t\t__collectionOptions: input.collectionOptions,\n\t\t__controlPolicy: input.controlPolicy,\n\t\t__collection: input.collection,\n\t\t__owner: input.owner ? resolveModelName(input.owner) : void 0,\n\t\t__base: input.base ? resolveModelName(input.base) : void 0,\n\t\t__storageRelations: input.storageRelations,\n\t\t__discriminator: input.discriminator ? { field: input.discriminator.field } : void 0,\n\t\t__variants: input.discriminator?.variants,\n\t\tref(fieldName) {\n\t\t\treturn createFieldReference(name, fieldName);\n\t\t}\n\t};\n}\nfunction validateTargetPackRef(family, target) {\n\tif (family.familyId !== \"mongo\") throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `defineContract only accepts Mongo family packs. Received family \"${family.familyId}\".`, { meta: {\n\t\tpackId: family.id,\n\t\tpackFamilyId: family.familyId,\n\t\tcontractFamilyId: \"mongo\"\n\t} });\n\tif (target.familyId !== family.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `target pack \"${target.id}\" targets family \"${target.familyId}\" but contract family is \"${family.familyId}\".`, { meta: {\n\t\tpackId: target.id,\n\t\tpackFamilyId: target.familyId,\n\t\tcontractFamilyId: family.familyId\n\t} });\n}\nfunction validateExtensionPackRefs(target, extensions) {\n\tif (!extensions) return;\n\tfor (const packRef of Object.values(extensions)) {\n\t\tif (packRef.kind !== \"extension\") throw contractError(\"CONTRACT.PACK_REF_INVALID\", `defineContract only accepts extension pack refs in extensions. Received kind \"${packRef.kind}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tkind: packRef.kind\n\t\t} });\n\t\tif (packRef.familyId !== target.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `extension pack \"${packRef.id}\" targets family \"${packRef.familyId}\" but contract target family is \"${target.familyId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackFamilyId: packRef.familyId,\n\t\t\tcontractFamilyId: target.familyId\n\t\t} });\n\t\tif (packRef.targetId && packRef.targetId !== target.targetId) throw contractError(\"CONTRACT.PACK_TARGET_MISMATCH\", `extension pack \"${packRef.id}\" targets \"${packRef.targetId}\" but contract target is \"${target.targetId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackTargetId: packRef.targetId,\n\t\t\tcontractTargetId: target.targetId\n\t\t} });\n\t}\n}\nfunction isContractScaffold(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\treturn \"family\" in value && \"target\" in value;\n}\nfunction buildContractField(builder) {\n\tconst valueSet = builder.__enumHandle ? {\n\t\tplane: \"domain\",\n\t\tentityKind: \"enum\",\n\t\tnamespaceId: UNBOUND_NAMESPACE_ID,\n\t\tentityName: builder.__enumHandle.enumName\n\t} : void 0;\n\treturn builder.__many ? {\n\t\ttype: builder.__type,\n\t\tnullable: builder.__nullable,\n\t\tmany: true,\n\t\t...ifDefined(\"valueSet\", valueSet)\n\t} : {\n\t\ttype: builder.__type,\n\t\tnullable: builder.__nullable,\n\t\t...ifDefined(\"valueSet\", valueSet)\n\t};\n}\nfunction buildFields(fields) {\n\tconst builtFields = {};\n\tfor (const [fieldName, fieldBuilder] of Object.entries(fields)) builtFields[fieldName] = buildContractField(fieldBuilder);\n\treturn builtFields;\n}\nfunction toOneRelationNullable(modelName, relationName, relationBuilder, on, fields) {\n\tconst location = `Relation \"${modelName}.${relationName}\"`;\n\tconst ownsForeignKey = relationBuilder.__cardinality !== \"1:1\";\n\tconst localFields = ownsForeignKey ? on.localFields.map((fieldName) => {\n\t\tconst localField = fields[fieldName];\n\t\tif (localField === void 0) throw contractError(\"CONTRACT.RELATION_INVALID\", `${location} joins on local field \"${fieldName}\", which model \"${modelName}\" does not declare`, { meta: {\n\t\t\tmodelName,\n\t\t\trelationName,\n\t\t\tfieldName,\n\t\t\treason: \"local-field-unknown\"\n\t\t} });\n\t\treturn localField;\n\t}) : [];\n\tconst { nullable, contradiction } = resolveToOneRelationNullable({\n\t\tdeclaredNullable: relationBuilder.__nullable,\n\t\tlocalFieldNullability: localFields.map((localField) => localField.__nullable === true),\n\t\townsReference: ownsForeignKey\n\t});\n\tif (contradiction !== void 0) throw contractError(\"CONTRACT.RELATION_INVALID\", !ownsForeignKey ? `${location} is required but does not own the foreign key, so nothing in storage guarantees the related document exists` : contradiction === \"declared-optional\" ? `${location} is optional but every local field it joins on is required` : `${location} is required but a local field it joins on is nullable`, { meta: {\n\t\tmodelName,\n\t\trelationName,\n\t\treason: \"to-one-nullability-mismatch\"\n\t} });\n\treturn nullable;\n}\nfunction buildRelation(modelName, relationName, relationBuilder, fields) {\n\tconst to = crossRef(relationBuilder.__to, UNBOUND_NAMESPACE_ID);\n\tconst on = relationBuilder.__on;\n\tif (on === void 0) return {\n\t\tto,\n\t\tcardinality: relationBuilder.__cardinality\n\t};\n\tif (relationBuilder.__cardinality === \"1:N\") return {\n\t\tto,\n\t\tcardinality: \"1:N\",\n\t\ton\n\t};\n\treturn {\n\t\tto,\n\t\tcardinality: relationBuilder.__cardinality,\n\t\tnullable: toOneRelationNullable(modelName, relationName, relationBuilder, on, fields),\n\t\ton\n\t};\n}\nfunction buildRelations(modelName, relations, fields) {\n\tconst builtRelations = {};\n\tfor (const [relationName, relationBuilder] of Object.entries(relations)) builtRelations[relationName] = buildRelation(modelName, relationName, relationBuilder, fields);\n\treturn builtRelations;\n}\nfunction buildValueObjects(valueObjects) {\n\tconst builtValueObjects = {};\n\tfor (const valueObjectBuilder of Object.values(valueObjects ?? {})) {\n\t\tif (valueObjectBuilder.__name in builtValueObjects) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate value object name \"${valueObjectBuilder.__name}\" in defineContract().`, { meta: {\n\t\t\tkind: \"valueObject\",\n\t\t\tname: valueObjectBuilder.__name\n\t\t} });\n\t\tbuiltValueObjects[valueObjectBuilder.__name] = { fields: buildFields(valueObjectBuilder.__fields) };\n\t}\n\treturn builtValueObjects;\n}\nfunction buildModels(models) {\n\tconst builtModels = {};\n\tfor (const modelBuilder of Object.values(models ?? {})) {\n\t\tif (modelBuilder.__name in builtModels) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Duplicate model name \"${modelBuilder.__name}\" in defineContract().`, { meta: {\n\t\t\tkind: \"model\",\n\t\t\tname: modelBuilder.__name\n\t\t} });\n\t\tconst storage = {\n\t\t\t...modelBuilder.__collection ? { collection: modelBuilder.__collection } : {},\n\t\t\t...modelBuilder.__storageRelations ? { relations: modelBuilder.__storageRelations } : {}\n\t\t};\n\t\tbuiltModels[modelBuilder.__name] = {\n\t\t\tfields: buildFields(modelBuilder.__fields),\n\t\t\trelations: buildRelations(modelBuilder.__name, modelBuilder.__relations, modelBuilder.__fields),\n\t\t\tstorage,\n\t\t\t...modelBuilder.__owner ? { owner: modelBuilder.__owner } : {},\n\t\t\t...modelBuilder.__base ? { base: crossRef(modelBuilder.__base, UNBOUND_NAMESPACE_ID) } : {},\n\t\t\t...modelBuilder.__discriminator ? { discriminator: modelBuilder.__discriminator } : {},\n\t\t\t...modelBuilder.__variants ? { variants: modelBuilder.__variants } : {}\n\t\t};\n\t}\n\treturn builtModels;\n}\nfunction deriveRoots(models) {\n\tconst roots = {};\n\tfor (const modelBuilder of Object.values(models ?? {})) {\n\t\tif (!modelBuilder.__collection || modelBuilder.__owner || modelBuilder.__base) continue;\n\t\troots[modelBuilder.__collection] = crossRef(modelBuilder.__name, UNBOUND_NAMESPACE_ID);\n\t}\n\treturn roots;\n}\nfunction normalizeRoots(roots) {\n\tconst normalizedRoots = {};\n\tfor (const [rootName, rootValue] of Object.entries(roots ?? {})) normalizedRoots[rootName] = crossRef(resolveModelName(rootValue), UNBOUND_NAMESPACE_ID);\n\treturn normalizedRoots;\n}\nfunction toStorageIndex(index) {\n\tconst input = { keys: Object.entries(index.fields).map(([field, direction]) => ({\n\t\tfield,\n\t\tdirection\n\t})) };\n\tif (index.options) {\n\t\tfor (const [key, value] of Object.entries(index.options)) if (value !== void 0) input[key] = value;\n\t}\n\treturn new MongoIndex(input);\n}\nfunction toStorageCollectionOptions(opts) {\n\treturn new MongoCollectionOptions({\n\t\t...opts.capped ? { capped: {\n\t\t\tsize: opts.size ?? 0,\n\t\t\t...opts.max != null && { max: opts.max }\n\t\t} } : {},\n\t\t...ifDefined(\"storageEngine\", opts.storageEngine),\n\t\t...ifDefined(\"indexOptionDefaults\", opts.indexOptionDefaults),\n\t\t...ifDefined(\"collation\", opts.collation),\n\t\t...ifDefined(\"timeseries\", opts.timeseries),\n\t\t...opts.clusteredIndex !== void 0 && { clusteredIndex: opts.clusteredIndex.name !== void 0 ? { name: opts.clusteredIndex.name } : {} },\n\t\t...ifDefined(\"expireAfterSeconds\", opts.expireAfterSeconds),\n\t\t...ifDefined(\"changeStreamPreAndPostImages\", opts.changeStreamPreAndPostImages)\n\t});\n}\nfunction findMissingIndexField(index, modelFields) {\n\tfor (const fieldName of Object.keys(index.fields)) {\n\t\tconst wildcardMatch = fieldName.match(/^(.+)\\.\\$\\*\\*$/);\n\t\tconst lookupName = wildcardMatch ? wildcardMatch[1] : fieldName;\n\t\tif (lookupName === void 0 || lookupName.length === 0) continue;\n\t\tif (lookupName === \"$**\") continue;\n\t\tif (!Object.hasOwn(modelFields, lookupName)) return lookupName;\n\t}\n}\nfunction resolveVariantScope(modelBuilder, modelsByName) {\n\tif (!modelBuilder.__base) return void 0;\n\tconst baseBuilder = modelsByName[modelBuilder.__base];\n\tif (!baseBuilder) return void 0;\n\tconst discriminatorField = baseBuilder.__discriminator?.field;\n\tconst variantValue = baseBuilder.__variants?.[modelBuilder.__name]?.value;\n\tif (!discriminatorField || variantValue === void 0) return void 0;\n\treturn {\n\t\tdiscriminatorField,\n\t\tdiscriminatorValue: variantValue\n\t};\n}\nfunction scopeVariantIndex(storageIndex, scope, variantName, authoredIndex) {\n\tconst result = applyPolymorphicScopeToMongoIndex(storageIndex, scope);\n\tif (result.kind === \"conflict\") {\n\t\tconst indexLabel = authoredIndex ? canonicalStringify(authoredIndex) : \"<unknown>\";\n\t\tthrow contractError(\"CONTRACT.INDEX_INVALID\", `Variant model \"${variantName}\" index ${indexLabel} conflicts with discriminator scope: ${result.reason}`, { meta: {\n\t\t\tvariantName,\n\t\t\tindexLabel,\n\t\t\treason: result.reason\n\t\t} });\n\t}\n\treturn result.index;\n}\nfunction buildCollections(models) {\n\tconst intermediate = {};\n\tconst declaredIndexOwners = /* @__PURE__ */ new Map();\n\tconst modelMap = models ?? {};\n\tconst modelsByName = {};\n\tfor (const builder of Object.values(modelMap)) modelsByName[builder.__name] = builder;\n\tfor (const modelBuilder of Object.values(modelMap)) {\n\t\tif (!modelBuilder.__collection) {\n\t\t\tif (modelBuilder.__indexes && modelBuilder.__indexes.length > 0) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines indexes but has no collection to attach them to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"indexes-without-collection\"\n\t\t\t} });\n\t\t\tif (modelBuilder.__collectionOptions) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines collectionOptions but has no collection to attach them to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"collectionOptions-without-collection\"\n\t\t\t} });\n\t\t\tif (modelBuilder.__controlPolicy) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Model \"${modelBuilder.__name}\" defines controlPolicy but has no collection to attach it to.`, { meta: {\n\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\treason: \"controlPolicy-without-collection\"\n\t\t\t} });\n\t\t\tcontinue;\n\t\t}\n\t\tconst existingCollection = intermediate[modelBuilder.__collection] ?? {};\n\t\tconst existingIndexes = existingCollection.indexes ?? [];\n\t\tif (existingCollection.options && modelBuilder.__collectionOptions) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Collection \"${modelBuilder.__collection}\" has collectionOptions declared by multiple models. Author collectionOptions on a single model per collection.`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tcollection: modelBuilder.__collection,\n\t\t\treason: \"collectionOptions-declared-by-multiple-models\"\n\t\t} });\n\t\tif (existingCollection.control !== void 0 && modelBuilder.__controlPolicy) throw contractError(\"CONTRACT.COLLECTION_INVALID\", `Collection \"${modelBuilder.__collection}\" has controlPolicy declared by multiple models. Author controlPolicy on a single model per collection.`, { meta: {\n\t\t\tmodelName: modelBuilder.__name,\n\t\t\tcollection: modelBuilder.__collection,\n\t\t\treason: \"controlPolicy-declared-by-multiple-models\"\n\t\t} });\n\t\tfor (const collectionIndex of modelBuilder.__indexes ?? []) {\n\t\t\tconst missingField = findMissingIndexField(collectionIndex, modelBuilder.__fields);\n\t\t\tif (missingField !== void 0) {\n\t\t\t\tconst indexSignature = canonicalStringify(collectionIndex);\n\t\t\t\tthrow contractError(\"CONTRACT.FIELD_UNKNOWN\", `Model \"${modelBuilder.__name}\" index ${indexSignature} references unknown field \"${missingField}\".`, { meta: {\n\t\t\t\t\tmodelName: modelBuilder.__name,\n\t\t\t\t\tfieldName: missingField,\n\t\t\t\t\tindexSignature\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tconst polymorphicScope = resolveVariantScope(modelBuilder, modelsByName);\n\t\tconst rawStorageIndexes = (modelBuilder.__indexes ?? []).map(toStorageIndex);\n\t\tconst storageIndexes = polymorphicScope ? rawStorageIndexes.map((idx, i) => scopeVariantIndex(idx, polymorphicScope, modelBuilder.__name, modelBuilder.__indexes?.[i])) : rawStorageIndexes;\n\t\tfor (let i = 0; i < storageIndexes.length; i++) {\n\t\t\tconst storageIndex = storageIndexes[i];\n\t\t\tif (storageIndex === void 0) continue;\n\t\t\tconst indexSignature = stableStringify(storageIndex);\n\t\t\tconst collectionIndexKey = `${modelBuilder.__collection}:${indexSignature}`;\n\t\t\tconst firstOwner = declaredIndexOwners.get(collectionIndexKey);\n\t\t\tif (firstOwner) {\n\t\t\t\tconst authoredIndex = modelBuilder.__indexes?.[i];\n\t\t\t\tconst reportedSignature = authoredIndex ? canonicalStringify(authoredIndex) : indexSignature;\n\t\t\t\tthrow contractError(\"CONTRACT.NAME_DUPLICATE\", `Collection \"${modelBuilder.__collection}\" defines duplicate index ${reportedSignature}. First declared on model \"${firstOwner}\" and duplicated on model \"${modelBuilder.__name}\".`, { meta: {\n\t\t\t\t\tkind: \"index\",\n\t\t\t\t\tname: reportedSignature,\n\t\t\t\t\tcollection: modelBuilder.__collection,\n\t\t\t\t\tfirst: firstOwner,\n\t\t\t\t\tsecond: modelBuilder.__name\n\t\t\t\t} });\n\t\t\t}\n\t\t\tdeclaredIndexOwners.set(collectionIndexKey, modelBuilder.__name);\n\t\t}\n\t\tconst storageOptions = modelBuilder.__collectionOptions ? toStorageCollectionOptions(modelBuilder.__collectionOptions) : void 0;\n\t\tconst controlPatch = modelBuilder.__controlPolicy !== void 0 ? { control: modelBuilder.__controlPolicy } : {};\n\t\tintermediate[modelBuilder.__collection] = storageIndexes.length > 0 ? {\n\t\t\t...existingCollection,\n\t\t\tindexes: [...existingIndexes, ...storageIndexes],\n\t\t\t...storageOptions ? { options: storageOptions } : {},\n\t\t\t...controlPatch\n\t\t} : storageOptions ? {\n\t\t\t...existingCollection,\n\t\t\toptions: storageOptions,\n\t\t\t...controlPatch\n\t\t} : Object.keys(controlPatch).length > 0 ? {\n\t\t\t...existingCollection,\n\t\t\t...controlPatch\n\t\t} : existingCollection;\n\t}\n\treturn intermediate;\n}\nfunction buildContractFromDefinition(definition) {\n\tvalidateTargetPackRef(definition.family, definition.target);\n\tvalidateExtensionPackRefs(definition.target, definition.extensions);\n\tconst builtModels = buildModels(definition.models);\n\tconst builtValueObjects = buildValueObjects(definition.valueObjects);\n\tconst roots = definition.roots ? normalizeRoots(definition.roots) : deriveRoots(definition.models);\n\tconst capabilities = {};\n\tconst collections = buildCollections(definition.models);\n\tconst codecLookup = extractCodecLookup([definition.target]);\n\tconst storageValueSets = {};\n\tfor (const [enumName, handle] of Object.entries(definition.enums ?? {})) storageValueSets[enumName] = {\n\t\tkind: \"valueSet\",\n\t\tvalues: handle.values.map((v) => encodeEnumValue(v, handle.codecId, codecLookup))\n\t};\n\tconst unboundNamespace = buildMongoNamespace({\n\t\tid: UNBOUND_NAMESPACE_ID,\n\t\tentries: {\n\t\t\tcollection: collections,\n\t\t\t...ifDefined(\"valueSet\", Object.keys(storageValueSets).length > 0 ? storageValueSets : void 0)\n\t\t}\n\t});\n\tconst storageBody = { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\tid: UNBOUND_NAMESPACE_ID,\n\t\tcollections: unboundNamespace.entries.collection,\n\t\t...ifDefined(\"valueSet\", unboundNamespace.entries.valueSet)\n\t} } };\n\tconst storage = new MongoStorage({\n\t\tstorageHash: computeStorageHash({\n\t\t\ttarget: definition.target.targetId,\n\t\t\ttargetFamily: definition.family.familyId,\n\t\t\tstorage: storageBody,\n\t\t\t...mongoContractCanonicalizationHooks\n\t\t}),\n\t\tnamespaces: { [UNBOUND_NAMESPACE_ID]: unboundNamespace }\n\t});\n\tconst builtEnums = {};\n\tfor (const [enumName, handle] of Object.entries(definition.enums ?? {})) {\n\t\tif (enumName !== handle.enumName) throw contractError(\"CONTRACT.ENUM_INVALID\", `enum declaration key \"${enumName}\" must match enumType name \"${handle.enumName}\". Aliases are not supported.`, { meta: {\n\t\t\tenumName: handle.enumName,\n\t\t\tdeclaredKey: enumName,\n\t\t\treason: \"declaration-key-mismatch\"\n\t\t} });\n\t\tbuiltEnums[enumName] = {\n\t\t\tcodecId: handle.codecId,\n\t\t\tmembers: handle.enumMembers.map((m) => ({\n\t\t\t\tname: m.name,\n\t\t\t\tvalue: encodeEnumValue(m.value, handle.codecId, codecLookup)\n\t\t\t}))\n\t\t};\n\t}\n\tconst hasEnums = Object.keys(builtEnums).length > 0;\n\tfor (const [modelName, modelBuilder] of Object.entries(definition.models ?? {})) for (const [fieldName, fieldBuilder] of Object.entries(modelBuilder.__fields)) {\n\t\tconst handle = fieldBuilder.__enumHandle;\n\t\tif (handle && !(handle.enumName in builtEnums)) throw contractError(\"CONTRACT.ENUM_UNKNOWN\", `Model \"${modelName}\" field \"${fieldName}\" references enum \"${handle.enumName}\" which is not declared in defineContract({ enums: { ... } }).`, { meta: {\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\tenumName: handle.enumName\n\t\t} });\n\t}\n\treturn blindCast({\n\t\ttarget: definition.target.targetId,\n\t\ttargetFamily: definition.family.familyId,\n\t\t...ifDefined(\"defaultControlPolicy\", definition.defaultControlPolicy),\n\t\troots,\n\t\tdomain: { namespaces: { [UNBOUND_NAMESPACE_ID]: {\n\t\t\tmodels: builtModels,\n\t\t\t...Object.keys(builtValueObjects).length > 0 ? { valueObjects: builtValueObjects } : {},\n\t\t\t...hasEnums ? { enum: builtEnums } : {}\n\t\t} } },\n\t\tstorage,\n\t\tcapabilities,\n\t\textensions: definition.extensions ?? {},\n\t\tprofileHash: computeProfileHash({\n\t\t\ttarget: definition.target.targetId,\n\t\t\ttargetFamily: definition.family.familyId,\n\t\t\tcapabilities\n\t\t}),\n\t\tmeta: {}\n\t});\n}\n/** Implementation. */\nfunction buildBoundContract(family, target, definition, factory) {\n\tconst full = {\n\t\t...definition,\n\t\tfamily,\n\t\ttarget\n\t};\n\tif (factory !== void 0) {\n\t\tconst built = factory({\n\t\t\t...composeMongoEntityHelpers(family, target, definition.extensions),\n\t\t\tfield,\n\t\t\tindex,\n\t\t\tmodel,\n\t\t\trel,\n\t\t\tvalueObject\n\t\t});\n\t\treturn buildContractFromDefinition({\n\t\t\t...full,\n\t\t\t...ifDefined(\"models\", built.models),\n\t\t\t...ifDefined(\"valueObjects\", built.valueObjects),\n\t\t\t...ifDefined(\"roots\", built.roots)\n\t\t});\n\t}\n\treturn buildContractFromDefinition(full);\n}\nfunction defineContract(definition, factory) {\n\tif (!isContractScaffold(definition)) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", \"defineContract expects a contract definition object. Define your contract with defineContract({ family, target, models, ... }).\");\n\tif (factory !== void 0) return buildBoundContract(definition.family, definition.target, definition, factory);\n\treturn buildBoundContract(definition.family, definition.target, definition);\n}\n//#endregion\nexport { bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, valueObject };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,OAAO,SAAS,aAAa;CACrD,MAAM,QAAQ,YAAY,IAAI,OAAO;CACrC,IAAI,CAAC,OAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC;CAC1D,OAAO,MAAM,WAAW,KAAK;AAC9B;AACA,SAAS,gBAAgB,OAAO;CAC/B,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,IAAI,MAAM,IAAI,eAAe,CAAC,CAAC,KAAK,GAAG,EAAE;CAC1E,IAAI,SAAS,OAAO,UAAU,UAAU,OAAO,IAAI,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,cAAc,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,GAAG,KAAK,UAAU,GAAG,EAAE,GAAG,gBAAgB,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;CAClN,OAAO,KAAK,UAAU,KAAK;AAC5B;AACA,SAAS,yBAAyB,WAAW;CAC5C,OAAO,UAAU,WAAW,eAAe,CAAC;AAC7C;AACA,MAAM,6BAA6B;CAClC;CACA;CACA;CACA;CACA;AACD;AACA,SAAS,0BAA0B,QAAQ,QAAQ,YAAY;CAC9D,MAAM,aAAa;EAClB;EACA;EACA,GAAG,OAAO,OAAO,cAAc,CAAC,CAAC;CAClC;CACA,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,aAAa,YAAY;EACnC,MAAM,KAAK,yBAAy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AAEA,SAAS,mBAAmB,QAAQ,QAAQ,YAAY,SAAS;CAChE,MAAM,OAAO;EACZ,GAAG;EACH;EACA;CACD;CACA,IAAI,YAAY,KAAK,GAAG;EACvB,MAAM,QAAQ,QAAQ;GACrB,GAAG,0BAA0B,QAAQ,QAAQ,WAAW,UAAU;GAClE;GACA;GACA;GACA;GACA;EACD,CAAC;EACD,OAAO,4BAA4B;GAClC,GAAG;GACH,GAAG,UAAU,UAAU,MAAM,MAAM;GACnC,GAAG,UAAU,gBAAgB,MAAM,YAAY;GAC/C,GAAG,UAAU,SAAS,MAAM,KAAK;EAClC,CAAC;CACF;CACA,OAAO,4BAA4B,IAAI;AACxC;AACA,SAAS,eAAe,YAAY,SAAS;CAC5C,IAAI,CAAC,mBAAmB,UAAU,GAAG,MAAM,cAAc,6BAA6B,iIAAiI;CACvN,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,YAAY,OAAO;CAC3G,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,UAAU;AAC3E"}
@@ -1,5 +1,5 @@
1
1
  import { Q as MongoValidator } from "./mongo-value-set-tNn9-pun-dJYx_rVD.mjs";
2
- import "./index-Cd2zLiU6.mjs";
2
+ import "./index-b88CnctD.mjs";
3
3
  import { Contract, ContractField, ContractValueObject, JsonValue } from "@prisma/orm-framework/contract/types";
4
4
  import { AuthoringContributions } from "@prisma/orm-framework/components/authoring";
5
5
  import { AttributeSpec, AttributeSpecContext, FieldAttributeCtx, FieldAttributeSpecContext, ModelAttributeCtx, SymbolTable, TypedFuncCall } from "@prisma/orm-framework/psl-parser";
@@ -1,2 +1,2 @@
1
- import { i as mongoAttributeSpecs, n as derivePolymorphicJsonSchema, r as interpretPslDocumentToMongoContract, t as deriveJsonSchema } from "./interpreter-BAcUM6H7-DNUcUApV.mjs";
1
+ import { i as mongoAttributeSpecs, n as derivePolymorphicJsonSchema, r as interpretPslDocumentToMongoContract, t as deriveJsonSchema } from "./interpreter-BCt8cG3P-DJ8yDc_N.mjs";
2
2
  export { deriveJsonSchema, derivePolymorphicJsonSchema, interpretPslDocumentToMongoContract, mongoAttributeSpecs };
@@ -1,10 +1,10 @@
1
- import { r as interpretPslDocumentToMongoContract } from "./interpreter-BAcUM6H7-DNUcUApV.mjs";
1
+ import { r as interpretPslDocumentToMongoContract } from "./interpreter-BCt8cG3P-DJ8yDc_N.mjs";
2
2
  import { collectScalarTypeConstructors } from "@prisma/orm-framework/components/authoring";
3
3
  import { buildSymbolTable, rangeToPslSpan } from "@prisma/orm-framework/psl-parser";
4
+ import { withSeedDiagnostics } from "@prisma/orm-framework/psl-parser/interpret";
4
5
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
5
6
  import { notOk } from "@prisma/orm-framework/utils/result";
6
7
  import { readFile } from "node:fs/promises";
7
- import { withSeedDiagnostics } from "@prisma/orm-framework/psl-parser/interpret";
8
8
  import { parse } from "@prisma/orm-framework/psl-parser/syntax";
9
9
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
10
10
  //#region ../../../2-mongo-family/2-authoring/contract-psl/dist/exports/provider.mjs
@@ -1 +1 @@
1
- {"version":3,"file":"contract-psl__provider.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-psl/dist/exports/provider.mjs"],"sourcesContent":["import { t as interpretPslDocumentToMongoContract } from \"../interpreter-BAcUM6H7.mjs\";\nimport { collectScalarTypeConstructors } from \"@internal/framework-components/authoring\";\nimport { buildSymbolTable, rangeToPslSpan } from \"@internal/psl-parser\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { withSeedDiagnostics } from \"@internal/psl-parser/interpret\";\nimport { parse } from \"@internal/psl-parser/syntax\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/provider.ts\nfunction collectScalarTypeCodecIds(namespace) {\n\treturn new Map([...collectScalarTypeConstructors(namespace)].map(([name, output]) => [name, output.codecId]));\n}\nfunction mapParseDiagnostics(diagnostics, sourceFile, sourceId) {\n\treturn diagnostics.map((diagnostic) => ({\n\t\tcode: diagnostic.code,\n\t\tmessage: diagnostic.message,\n\t\tsourceId,\n\t\tspan: rangeToPslSpan(diagnostic.range, sourceFile)\n\t}));\n}\nfunction mongoContract(schemaPath, options) {\n\treturn {\n\t\tsource: {\n\t\t\tformat: \"psl\",\n\t\t\tinputs: [schemaPath],\n\t\t\tinterpret(input, context) {\n\t\t\t\treturn interpretPslDocumentToMongoContract({\n\t\t\t\t\tsymbolTable: input.symbolTable,\n\t\t\t\t\tsourceFile: input.sourceFile,\n\t\t\t\t\tsourceId: input.sourceId,\n\t\t\t\t\tseedDiagnostics: [],\n\t\t\t\t\tscalarTypeCodecIds: collectScalarTypeCodecIds(context.authoringContributions.type),\n\t\t\t\t\tcontrolMutationDefaults: context.controlMutationDefaults.defaultFunctionRegistry,\n\t\t\t\t\tcodecLookup: context.codecLookup,\n\t\t\t\t\tauthoringContributions: context.authoringContributions,\n\t\t\t\t\t...ifDefined(\"enumInferenceCodecs\", options?.enumInferenceCodecs)\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync load(context) {\n\t\t\t\tconst [absoluteSchemaPath] = context.resolvedInputs;\n\t\t\t\tif (absoluteSchemaPath === void 0) throw new InternalError(\"mongoContract: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.\");\n\t\t\t\tlet schema;\n\t\t\t\ttry {\n\t\t\t\t\tschema = await readFile(absoluteSchemaPath, \"utf-8\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = String(error);\n\t\t\t\t\treturn notOk({\n\t\t\t\t\t\tsummary: `Failed to read Prisma schema at \"${schemaPath}\"`,\n\t\t\t\t\t\tdiagnostics: [{\n\t\t\t\t\t\t\tcode: \"PSL_SCHEMA_READ_FAILED\",\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t\t\t}],\n\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\tschemaPath,\n\t\t\t\t\t\t\tabsoluteSchemaPath,\n\t\t\t\t\t\t\tcause: message\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst { document, sourceFile, diagnostics: parseDiagnostics } = parse(schema);\n\t\t\t\tconst { table: symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({\n\t\t\t\t\tdocument,\n\t\t\t\t\tsourceFile,\n\t\t\t\t\tpslBlockDescriptors: context.authoringContributions.pslBlockDescriptors\n\t\t\t\t});\n\t\t\t\tconst seedDiagnostics = [...mapParseDiagnostics(parseDiagnostics, sourceFile, schemaPath), ...mapParseDiagnostics(symbolTableDiagnostics, sourceFile, schemaPath)];\n\t\t\t\treturn withSeedDiagnostics(this.interpret({\n\t\t\t\t\tdocument,\n\t\t\t\t\tsourceFile,\n\t\t\t\t\tsymbolTable,\n\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t}, context), seedDiagnostics);\n\t\t\t}\n\t\t},\n\t\t...ifDefined(\"output\", options?.output)\n\t};\n}\n//#endregion\nexport { mongoContract };\n\n//# sourceMappingURL=provider.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,0BAA0B,WAAW;CAC7C,OAAO,IAAI,IAAI,CAAC,GAAG,8BAA8B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAC7G;AACA,SAAS,oBAAoB,aAAa,YAAY,UAAU;CAC/D,OAAO,YAAY,KAAK,gBAAgB;EACvC,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB;EACA,MAAM,eAAe,WAAW,OAAO,UAAU;CAClD,EAAE;AACH;AACA,SAAS,cAAc,YAAY,SAAS;CAC3C,OAAO;EACN,QAAQ;GACP,QAAQ;GACR,QAAQ,CAAC,UAAU;GACnB,UAAU,OAAO,SAAS;IACzB,OAAO,oCAAoC;KAC1C,aAAa,MAAM;KACnB,YAAY,MAAM;KAClB,UAAU,MAAM;KAChB,iBAAiB,CAAC;KAClB,oBAAoB,0BAA0B,QAAQ,uBAAuB,IAAI;KACjF,yBAAyB,QAAQ,wBAAwB;KACzD,aAAa,QAAQ;KACrB,wBAAwB,QAAQ;KAChC,GAAG,UAAU,uBAAuB,SAAS,mBAAmB;IACjE,CAAC;GACF;GACA,MAAM,KAAK,SAAS;IACnB,MAAM,CAAC,sBAAsB,QAAQ;IACrC,IAAI,uBAAuB,KAAK,GAAG,MAAM,IAAI,cAAc,iIAAiI;IAC5L,IAAI;IACJ,IAAI;KACH,SAAS,MAAM,SAAS,oBAAoB,OAAO;IACpD,SAAS,OAAO;KACf,MAAM,UAAU,OAAO,KAAK;KAC5B,OAAO,MAAM;MACZ,SAAS,oCAAoC,WAAW;MACxD,aAAa,CAAC;OACb,MAAM;OACN;OACA,UAAU;MACX,CAAC;MACD,MAAM;OACL;OACA;OACA,OAAO;MACR;KACD,CAAC;IACF;IACA,MAAM,EAAE,UAAU,YAAY,aAAa,qBAAqB,MAAM,MAAM;IAC5E,MAAM,EAAE,OAAO,aAAa,aAAa,2BAA2B,iBAAiB;KACpF;KACA;KACA,qBAAqB,QAAQ,uBAAuB;IACrD,CAAC;IACD,MAAM,kBAAkB,CAAC,GAAG,oBAAoB,kBAAkB,YAAY,UAAU,GAAG,GAAG,oBAAoB,wBAAwB,YAAY,UAAU,CAAC;IACjK,OAAO,oBAAoB,KAAK,UAAU;KACzC;KACA;KACA;KACA,UAAU;IACX,GAAG,OAAO,GAAG,eAAe;GAC7B;EACD;EACA,GAAG,UAAU,UAAU,SAAS,MAAM;CACvC;AACD"}
1
+ {"version":3,"file":"contract-psl__provider.mjs","names":[],"sources":["../../../../2-mongo-family/2-authoring/contract-psl/dist/exports/provider.mjs"],"sourcesContent":["import { t as interpretPslDocumentToMongoContract } from \"../interpreter-BCt8cG3P.mjs\";\nimport { collectScalarTypeConstructors } from \"@internal/framework-components/authoring\";\nimport { buildSymbolTable, rangeToPslSpan } from \"@internal/psl-parser\";\nimport { withSeedDiagnostics } from \"@internal/psl-parser/interpret\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk } from \"@internal/utils/result\";\nimport { readFile } from \"node:fs/promises\";\nimport { parse } from \"@internal/psl-parser/syntax\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/provider.ts\nfunction collectScalarTypeCodecIds(namespace) {\n\treturn new Map([...collectScalarTypeConstructors(namespace)].map(([name, output]) => [name, output.codecId]));\n}\nfunction mapParseDiagnostics(diagnostics, sourceFile, sourceId) {\n\treturn diagnostics.map((diagnostic) => ({\n\t\tcode: diagnostic.code,\n\t\tmessage: diagnostic.message,\n\t\tsourceId,\n\t\tspan: rangeToPslSpan(diagnostic.range, sourceFile)\n\t}));\n}\nfunction mongoContract(schemaPath, options) {\n\treturn {\n\t\tsource: {\n\t\t\tformat: \"psl\",\n\t\t\tinputs: [schemaPath],\n\t\t\tinterpret(input, context) {\n\t\t\t\treturn interpretPslDocumentToMongoContract({\n\t\t\t\t\tsymbolTable: input.symbolTable,\n\t\t\t\t\tsourceFile: input.sourceFile,\n\t\t\t\t\tsourceId: input.sourceId,\n\t\t\t\t\tseedDiagnostics: [],\n\t\t\t\t\tscalarTypeCodecIds: collectScalarTypeCodecIds(context.authoringContributions.type),\n\t\t\t\t\tcontrolMutationDefaults: context.controlMutationDefaults.defaultFunctionRegistry,\n\t\t\t\t\tcodecLookup: context.codecLookup,\n\t\t\t\t\tauthoringContributions: context.authoringContributions,\n\t\t\t\t\t...ifDefined(\"enumInferenceCodecs\", options?.enumInferenceCodecs)\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync load(context) {\n\t\t\t\tconst [absoluteSchemaPath] = context.resolvedInputs;\n\t\t\t\tif (absoluteSchemaPath === void 0) throw new InternalError(\"mongoContract: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.\");\n\t\t\t\tlet schema;\n\t\t\t\ttry {\n\t\t\t\t\tschema = await readFile(absoluteSchemaPath, \"utf-8\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = String(error);\n\t\t\t\t\treturn notOk({\n\t\t\t\t\t\tsummary: `Failed to read Prisma schema at \"${schemaPath}\"`,\n\t\t\t\t\t\tdiagnostics: [{\n\t\t\t\t\t\t\tcode: \"PSL_SCHEMA_READ_FAILED\",\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t\t\t}],\n\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\tschemaPath,\n\t\t\t\t\t\t\tabsoluteSchemaPath,\n\t\t\t\t\t\t\tcause: message\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst { document, sourceFile, diagnostics: parseDiagnostics } = parse(schema);\n\t\t\t\tconst { table: symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({\n\t\t\t\t\tdocument,\n\t\t\t\t\tsourceFile,\n\t\t\t\t\tpslBlockDescriptors: context.authoringContributions.pslBlockDescriptors\n\t\t\t\t});\n\t\t\t\tconst seedDiagnostics = [...mapParseDiagnostics(parseDiagnostics, sourceFile, schemaPath), ...mapParseDiagnostics(symbolTableDiagnostics, sourceFile, schemaPath)];\n\t\t\t\treturn withSeedDiagnostics(this.interpret({\n\t\t\t\t\tdocument,\n\t\t\t\t\tsourceFile,\n\t\t\t\t\tsymbolTable,\n\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t}, context), seedDiagnostics);\n\t\t\t}\n\t\t},\n\t\t...ifDefined(\"output\", options?.output)\n\t};\n}\n//#endregion\nexport { mongoContract };\n\n//# sourceMappingURL=provider.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,0BAA0B,WAAW;CAC7C,OAAO,IAAI,IAAI,CAAC,GAAG,8BAA8B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAC7G;AACA,SA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ACA;KACA,UAAU;IACX,GAAG,OAAO,GAAG,eAAe;GAC7B;EACD;EACA,GAAG,UAAU,UAAU,SAAS,MAAM;CACvC;AACD"}
@@ -1,3 +1,3 @@
1
1
  import { n as typescriptContract, r as typescriptContractFromPath, t as ContractConfig } from "./config-types-CQOf5N7R.mjs";
2
- import { C as model, S as member, T as valueObject, _ as defineContract, a as ContractScaffold, b as index, c as ExtractCodecTypesFromPack, d as ModelBuilder, f as MongoContractResult, g as buildBoundContract, h as bindEnumType, i as ContractFactory, l as FieldBuilder, m as ValueObjectBuilder, n as CodecTypeMap, o as EnumMember, p as RelationBuilder, r as ContractDefinition, s as EnumTypeHandle, t as BoundEnumType, u as FieldReference, v as enumType, w as rel, x as isEnumTypeHandle, y as field } from "./contract-builder-DB8nguDE.mjs";
2
+ import { C as model, S as member, T as valueObject, _ as defineContract, a as ContractScaffold, b as index, c as ExtractCodecTypesFromPack, d as ModelBuilder, f as MongoContractResult, g as buildBoundContract, h as bindEnumType, i as ContractFactory, l as FieldBuilder, m as ValueObjectBuilder, n as CodecTypeMap, o as EnumMember, p as RelationBuilder, r as ContractDefinition, s as EnumTypeHandle, t as BoundEnumType, u as FieldReference, v as enumType, w as rel, x as isEnumTypeHandle, y as field } from "./contract-builder-B171gPnd.mjs";
3
3
  export { type BoundEnumType, type CodecTypeMap, type ContractConfig, type ContractDefinition, type ContractFactory, type ContractScaffold, type EnumMember, type EnumTypeHandle, type ExtractCodecTypesFromPack, type FieldBuilder, type FieldReference, type ModelBuilder, type MongoContractResult, type RelationBuilder, type ValueObjectBuilder, bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, typescriptContract, typescriptContractFromPath, valueObject };
@@ -1,3 +1,3 @@
1
1
  import { n as typescriptContractFromPath, t as typescriptContract } from "./config-types-CFDf9ivE.mjs";
2
- import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-BFq0gOMV.mjs";
2
+ import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-DeB13CGv.mjs";
3
3
  export { bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, typescriptContract, typescriptContractFromPath, valueObject };
@@ -1,2 +1,2 @@
1
- import { C as model, S as member, T as valueObject, _ as defineContract, a as ContractScaffold, b as index, c as ExtractCodecTypesFromPack, d as ModelBuilder, f as MongoContractResult, g as buildBoundContract, h as bindEnumType, i as ContractFactory, l as FieldBuilder, m as ValueObjectBuilder, n as CodecTypeMap, o as EnumMember, p as RelationBuilder, r as ContractDefinition, s as EnumTypeHandle, t as BoundEnumType, u as FieldReference, v as enumType, w as rel, x as isEnumTypeHandle, y as field } from "./contract-builder-DB8nguDE.mjs";
1
+ import { C as model, S as member, T as valueObject, _ as defineContract, a as ContractScaffold, b as index, c as ExtractCodecTypesFromPack, d as ModelBuilder, f as MongoContractResult, g as buildBoundContract, h as bindEnumType, i as ContractFactory, l as FieldBuilder, m as ValueObjectBuilder, n as CodecTypeMap, o as EnumMember, p as RelationBuilder, r as ContractDefinition, s as EnumTypeHandle, t as BoundEnumType, u as FieldReference, v as enumType, w as rel, x as isEnumTypeHandle, y as field } from "./contract-builder-B171gPnd.mjs";
2
2
  export { type BoundEnumType, type CodecTypeMap, type ContractDefinition, type ContractFactory, type ContractScaffold, type EnumMember, type EnumTypeHandle, type ExtractCodecTypesFromPack, type FieldBuilder, type FieldReference, type ModelBuilder, type MongoContractResult, type RelationBuilder, type ValueObjectBuilder, bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, valueObject };
@@ -1,2 +1,2 @@
1
- import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-BFq0gOMV.mjs";
1
+ import { a as field, c as member, d as valueObject, i as enumType, l as model, n as buildBoundContract, o as index, r as defineContract, s as isEnumTypeHandle, t as bindEnumType, u as rel } from "./contract-builder-DeB13CGv.mjs";
2
2
  export { bindEnumType, buildBoundContract, defineContract, enumType, field, index, isEnumTypeHandle, member, model, rel, valueObject };
@@ -1,3 +1,3 @@
1
1
  import { $ as MongoValidatorInput, A as MongoIndexKey, B as MongoModelStorage, C as MongoContract, D as MongoIndexFieldValue, E as MongoIndexAuthoringInput, F as MongoIndexOptionsInput, G as MongoTimeSeriesCollectionOptions, H as MongoStorageCappedShape, I as MongoJsonObject, J as MongoTypeMaps, K as MongoTimeSeriesCollectionOptionsInput, L as MongoJsonPrimitive, M as MongoIndexOptionDefaults, N as MongoIndexOptionDefaultsInput, O as MongoIndexFields, P as MongoIndexOptions, Q as MongoValidator, R as MongoJsonValue, S as MongoCollectionOptionsInput, T as MongoIndex, U as MongoStorageClusteredIndexShape, V as MongoModelsMap, W as MongoStorageShape, X as MongoUnboundFieldInputTypes, Y as MongoTypeMapsPhantomKey, Z as MongoUnboundFieldOutputTypes, _ as MongoCollationStrength, a as ExtractMongoTypeMaps, at as RootModelName, b as MongoCollectionOptions, c as MongoChangeStreamPreAndPostImagesOptionsInput, d as MongoClusteredCollectionOptionsInput, et as MongoValidatorValidationAction, f as MongoCollationAlternate, g as MongoCollationOptionsInput, h as MongoCollationOptions, i as ExtractMongoFieldOutputTypes, it as MongoWildcardProjection, j as MongoIndexKeyDirection, k as MongoIndexInput, l as MongoClusteredCollectionKey, m as MongoCollationMaxVariable, n as ExtractMongoCodecTypes, nt as MongoValueSet, o as InferModelRow, p as MongoCollationCaseFirst, q as MongoTimeSeriesGranularity, r as ExtractMongoFieldInputTypes, rt as MongoValueSetInput, s as MongoChangeStreamPreAndPostImagesOptions, t as AnyMongoTypeMaps, tt as MongoValidatorValidationLevel, u as MongoClusteredCollectionOptions, v as MongoCollection, w as MongoContractWithTypeMaps, x as MongoCollectionOptionsAuthoringInput, y as MongoCollectionInput, z as MongoModelDefinition } from "./mongo-value-set-tNn9-pun-dJYx_rVD.mjs";
2
- import { _ as defaultMongoDomainNamespaceId, a as MongoNamespace, c as MongoStorageInput, d as StorageValueSetSchema, f as applyPolymorphicScopeToMongoIndex, g as createMongoNamespaceEnvelopeSchema, h as createMongoContractSchema, i as MongoContractView, l as MongoUnboundNamespace, m as buildMongoNamespace, n as MongoContractAccessors, o as MongoNamespaceEntries, p as buildMongoContractView, r as MongoContractSchema, s as MongoStorage, t as ApplyScopeResult, u as PolymorphicIndexScope, v as defaultMongoStorageNamespaceId, y as validateMongoStorage } from "./index-Cd2zLiU6.mjs";
3
- export { type AnyMongoTypeMaps, type ApplyScopeResult, type ExtractMongoCodecTypes, type ExtractMongoFieldInputTypes, type ExtractMongoFieldOutputTypes, type ExtractMongoTypeMaps, type InferModelRow, MongoChangeStreamPreAndPostImagesOptions, type MongoChangeStreamPreAndPostImagesOptionsInput, type MongoClusteredCollectionKey, MongoClusteredCollectionOptions, type MongoClusteredCollectionOptionsInput, type MongoCollationAlternate, type MongoCollationCaseFirst, type MongoCollationMaxVariable, MongoCollationOptions, type MongoCollationOptionsInput, type MongoCollationStrength, MongoCollection, type MongoCollectionInput, MongoCollectionOptions, type MongoCollectionOptionsAuthoringInput, type MongoCollectionOptionsInput, type MongoContract, type MongoContractAccessors, MongoContractSchema, type MongoContractView, type MongoContractWithTypeMaps, MongoIndex, type MongoIndexAuthoringInput, type MongoIndexFieldValue, type MongoIndexFields, type MongoIndexInput, type MongoIndexKey, type MongoIndexKeyDirection, MongoIndexOptionDefaults, type MongoIndexOptionDefaultsInput, MongoIndexOptions, type MongoIndexOptionsInput, type MongoJsonObject, type MongoJsonPrimitive, type MongoJsonValue, type MongoModelDefinition, type MongoModelStorage, type MongoModelsMap, type MongoNamespace, type MongoNamespaceEntries, MongoStorage, type MongoStorageCappedShape, type MongoStorageClusteredIndexShape, type MongoStorageInput, type MongoStorageShape, MongoTimeSeriesCollectionOptions, type MongoTimeSeriesCollectionOptionsInput, type MongoTimeSeriesGranularity, type MongoTypeMaps, type MongoTypeMapsPhantomKey, type MongoUnboundFieldInputTypes, type MongoUnboundFieldOutputTypes, MongoUnboundNamespace, MongoValidator, type MongoValidatorInput, type MongoValidatorValidationAction, type MongoValidatorValidationLevel, MongoValueSet, type MongoValueSetInput, type MongoWildcardProjection, type PolymorphicIndexScope, type RootModelName, StorageValueSetSchema, applyPolymorphicScopeToMongoIndex, buildMongoContractView, buildMongoNamespace, createMongoContractSchema, createMongoNamespaceEnvelopeSchema, defaultMongoDomainNamespaceId, defaultMongoStorageNamespaceId, validateMongoStorage };
2
+ import { C as defaultMongoDomainNamespaceId, E as validateMongoStorage, S as createMongoNamespaceEnvelopeSchema, T as resolveMongoToOneRelationFields, _ as StorageValueSetSchema, a as MongoNamespace, b as buildMongoNamespace, c as MongoStorageInput, d as PolymorphicIndexScope, f as RelationKeys, g as ShapeSpec, h as Shape, i as MongoContractView, l as MongoToOneRelationFields, m as Scalars, n as MongoContractAccessors, o as MongoNamespaceEntries, p as RelationNamesOf, r as MongoContractSchema, s as MongoStorage, t as ApplyScopeResult, u as MongoUnboundNamespace, v as applyPolymorphicScopeToMongoIndex, w as defaultMongoStorageNamespaceId, x as createMongoContractSchema, y as buildMongoContractView } from "./index-b88CnctD.mjs";
3
+ export { type AnyMongoTypeMaps, type ApplyScopeResult, type ExtractMongoCodecTypes, type ExtractMongoFieldInputTypes, type ExtractMongoFieldOutputTypes, type ExtractMongoTypeMaps, type InferModelRow, MongoChangeStreamPreAndPostImagesOptions, type MongoChangeStreamPreAndPostImagesOptionsInput, type MongoClusteredCollectionKey, MongoClusteredCollectionOptions, type MongoClusteredCollectionOptionsInput, type MongoCollationAlternate, type MongoCollationCaseFirst, type MongoCollationMaxVariable, MongoCollationOptions, type MongoCollationOptionsInput, type MongoCollationStrength, MongoCollection, type MongoCollectionInput, MongoCollectionOptions, type MongoCollectionOptionsAuthoringInput, type MongoCollectionOptionsInput, type MongoContract, type MongoContractAccessors, MongoContractSchema, type MongoContractView, type MongoContractWithTypeMaps, MongoIndex, type MongoIndexAuthoringInput, type MongoIndexFieldValue, type MongoIndexFields, type MongoIndexInput, type MongoIndexKey, type MongoIndexKeyDirection, MongoIndexOptionDefaults, type MongoIndexOptionDefaultsInput, MongoIndexOptions, type MongoIndexOptionsInput, type MongoJsonObject, type MongoJsonPrimitive, type MongoJsonValue, type MongoModelDefinition, type MongoModelStorage, type MongoModelsMap, type MongoNamespace, type MongoNamespaceEntries, MongoStorage, type MongoStorageCappedShape, type MongoStorageClusteredIndexShape, type MongoStorageInput, type MongoStorageShape, MongoTimeSeriesCollectionOptions, type MongoTimeSeriesCollectionOptionsInput, type MongoTimeSeriesGranularity, type MongoToOneRelationFields, type MongoTypeMaps, type MongoTypeMapsPhantomKey, type MongoUnboundFieldInputTypes, type MongoUnboundFieldOutputTypes, MongoUnboundNamespace, MongoValidator, type MongoValidatorInput, type MongoValidatorValidationAction, type MongoValidatorValidationLevel, MongoValueSet, type MongoValueSetInput, type MongoWildcardProjection, type PolymorphicIndexScope, RelationKeys, type RelationNamesOf, type RootModelName, type Scalars, type Shape, type ShapeSpec, StorageValueSetSchema, applyPolymorphicScopeToMongoIndex, buildMongoContractView, buildMongoNamespace, createMongoContractSchema, createMongoNamespaceEnvelopeSchema, defaultMongoDomainNamespaceId, defaultMongoStorageNamespaceId, resolveMongoToOneRelationFields, validateMongoStorage };