@prisma/orm-family-mongo 0.16.0-dev.36

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 (166) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +27 -0
  3. package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs +176 -0
  4. package/dist/authoring-entity-types-BGtkMyoN-D32kzx28.mjs.map +1 -0
  5. package/dist/canonicalization-hooks-DF3Z6sjO.mjs +22 -0
  6. package/dist/canonicalization-hooks-DF3Z6sjO.mjs.map +1 -0
  7. package/dist/codec.d.mts +2 -0
  8. package/dist/codec.mjs +2 -0
  9. package/dist/config-types-CFDf9ivE.mjs +37 -0
  10. package/dist/config-types-CFDf9ivE.mjs.map +1 -0
  11. package/dist/config-types-CQOf5N7R.d.mts +12 -0
  12. package/dist/config-types-CQOf5N7R.d.mts.map +1 -0
  13. package/dist/contract-builder-BFq0gOMV.mjs +634 -0
  14. package/dist/contract-builder-BFq0gOMV.mjs.map +1 -0
  15. package/dist/contract-builder-DB8nguDE.d.mts +445 -0
  16. package/dist/contract-builder-DB8nguDE.d.mts.map +1 -0
  17. package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs +9 -0
  18. package/dist/contract-errors-BCN6RVI5-kMurtAbI.mjs.map +1 -0
  19. package/dist/contract-psl.d.mts +45 -0
  20. package/dist/contract-psl.d.mts.map +1 -0
  21. package/dist/contract-psl.mjs +2 -0
  22. package/dist/contract-psl__provider.d.mts +15 -0
  23. package/dist/contract-psl__provider.d.mts.map +1 -0
  24. package/dist/contract-psl__provider.mjs +82 -0
  25. package/dist/contract-psl__provider.mjs.map +1 -0
  26. package/dist/contract-ts.d.mts +3 -0
  27. package/dist/contract-ts.mjs +3 -0
  28. package/dist/contract-ts__config-types.d.mts +2 -0
  29. package/dist/contract-ts__config-types.mjs +2 -0
  30. package/dist/contract-ts__contract-builder.d.mts +2 -0
  31. package/dist/contract-ts__contract-builder.mjs +2 -0
  32. package/dist/contract.d.mts +3 -0
  33. package/dist/contract.mjs +3 -0
  34. package/dist/contract__canonicalization-hooks.d.mts +9 -0
  35. package/dist/contract__canonicalization-hooks.d.mts.map +1 -0
  36. package/dist/contract__canonicalization-hooks.mjs +2 -0
  37. package/dist/contract__entity-kinds.d.mts +17 -0
  38. package/dist/contract__entity-kinds.d.mts.map +1 -0
  39. package/dist/contract__entity-kinds.mjs +2 -0
  40. package/dist/control-C7-kthr1.d.mts +193 -0
  41. package/dist/control-C7-kthr1.d.mts.map +1 -0
  42. package/dist/control-CClR5JMr.mjs +127 -0
  43. package/dist/control-CClR5JMr.mjs.map +1 -0
  44. package/dist/control-CFr3tYsg.mjs +398 -0
  45. package/dist/control-CFr3tYsg.mjs.map +1 -0
  46. package/dist/control-Cj81sPbj.d.mts +101 -0
  47. package/dist/control-Cj81sPbj.d.mts.map +1 -0
  48. package/dist/control-adapter-Db5pT77b.d.mts +83 -0
  49. package/dist/control-adapter-Db5pT77b.d.mts.map +1 -0
  50. package/dist/dist-C7Ykq48Q.mjs +19 -0
  51. package/dist/dist-C7Ykq48Q.mjs.map +1 -0
  52. package/dist/dist-Czwqx_i3.mjs +58 -0
  53. package/dist/dist-Czwqx_i3.mjs.map +1 -0
  54. package/dist/dist-DHrEJnhK.mjs +236 -0
  55. package/dist/dist-DHrEJnhK.mjs.map +1 -0
  56. package/dist/dist-Dyp05u64.mjs +1546 -0
  57. package/dist/dist-Dyp05u64.mjs.map +1 -0
  58. package/dist/emitter.d.mts +22 -0
  59. package/dist/emitter.d.mts.map +1 -0
  60. package/dist/emitter.mjs +2 -0
  61. package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs +603 -0
  62. package/dist/entity-kinds-B4KNTF8z-DPIuUuuB.mjs.map +1 -0
  63. package/dist/execution-CKnUiOfm.d.mts +48 -0
  64. package/dist/execution-CKnUiOfm.d.mts.map +1 -0
  65. package/dist/execution-D5XyZ5XS.mjs +1269 -0
  66. package/dist/execution-D5XyZ5XS.mjs.map +1 -0
  67. package/dist/exports-Bx-hlnZ3.mjs +209 -0
  68. package/dist/exports-Bx-hlnZ3.mjs.map +1 -0
  69. package/dist/exports-CJMh0VTU.mjs +156 -0
  70. package/dist/exports-CJMh0VTU.mjs.map +1 -0
  71. package/dist/family.d.mts +10 -0
  72. package/dist/family.mjs +9 -0
  73. package/dist/family__control-adapter.d.mts +2 -0
  74. package/dist/family__control-adapter.mjs +1 -0
  75. package/dist/family__control.d.mts +2 -0
  76. package/dist/family__control.mjs +3 -0
  77. package/dist/family__ir.d.mts +3 -0
  78. package/dist/family__ir.mjs +4 -0
  79. package/dist/family__migration.d.mts +2 -0
  80. package/dist/family__migration.mjs +2 -0
  81. package/dist/family__pack.d.mts +2 -0
  82. package/dist/family__pack.mjs +16 -0
  83. package/dist/family__pack.mjs.map +1 -0
  84. package/dist/family__runtime.d.mts +3 -0
  85. package/dist/family__runtime.mjs +2 -0
  86. package/dist/family__schema-verify.d.mts +2 -0
  87. package/dist/family__schema-verify.mjs +2 -0
  88. package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs +234 -0
  89. package/dist/field-accessor-0oUt6RZC-B_Z30uAA.mjs.map +1 -0
  90. package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts +588 -0
  91. package/dist/field-accessor-DHsAPiW3-BdYCspQC.d.mts.map +1 -0
  92. package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs +181 -0
  93. package/dist/filter-expressions-Uo8ZdzwB-53qnqceS.mjs.map +1 -0
  94. package/dist/index-BR0ue13b.d.mts +136 -0
  95. package/dist/index-BR0ue13b.d.mts.map +1 -0
  96. package/dist/index-Cd2zLiU6.d.mts +128 -0
  97. package/dist/index-Cd2zLiU6.d.mts.map +1 -0
  98. package/dist/index-DAOkcTCK.d.mts +151 -0
  99. package/dist/index-DAOkcTCK.d.mts.map +1 -0
  100. package/dist/index-Dv2PNMiG.d.mts +53 -0
  101. package/dist/index-Dv2PNMiG.d.mts.map +1 -0
  102. package/dist/index-DxoO-ywI.d.mts +178 -0
  103. package/dist/index-DxoO-ywI.d.mts.map +1 -0
  104. package/dist/index-wKMm41HC.d.mts +30 -0
  105. package/dist/index-wKMm41HC.d.mts.map +1 -0
  106. package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs +1091 -0
  107. package/dist/interpreter-BxbUTQ3k-ClR98Ned.mjs.map +1 -0
  108. package/dist/ir-CQrenTYt.d.mts +147 -0
  109. package/dist/ir-CQrenTYt.d.mts.map +1 -0
  110. package/dist/ir-Ch2aPr7a.mjs +62 -0
  111. package/dist/ir-Ch2aPr7a.mjs.map +1 -0
  112. package/dist/lowering.d.mts +2 -0
  113. package/dist/lowering.mjs +1 -0
  114. package/dist/migration-CNDQv5yB.d.mts +50 -0
  115. package/dist/migration-CNDQv5yB.d.mts.map +1 -0
  116. package/dist/migration-dcM7u4HG.mjs +52 -0
  117. package/dist/migration-dcM7u4HG.mjs.map +1 -0
  118. package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs +119 -0
  119. package/dist/mongo-contract-serializer-Cx7Fae8e-C8ZYPXpc.mjs.map +1 -0
  120. package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts +27 -0
  121. package/dist/mongo-contract-view-AnejqfrQ-BaCFT0xm.d.mts.map +1 -0
  122. package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs +17 -0
  123. package/dist/mongo-contract-view-rcWzby6f-wRBCUnBt.mjs.map +1 -0
  124. package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts +536 -0
  125. package/dist/mongo-value-set-tNn9-pun-dJYx_rVD.d.mts.map +1 -0
  126. package/dist/mongodb-types-B4HmhF1S.d.mts +2 -0
  127. package/dist/orm.d.mts +311 -0
  128. package/dist/orm.d.mts.map +1 -0
  129. package/dist/orm.mjs +664 -0
  130. package/dist/orm.mjs.map +1 -0
  131. package/dist/pack-D9aLY50F.d.mts +44 -0
  132. package/dist/pack-D9aLY50F.d.mts.map +1 -0
  133. package/dist/query-ast.d.mts +5 -0
  134. package/dist/query-ast.mjs +4 -0
  135. package/dist/query-ast__control.d.mts +4 -0
  136. package/dist/query-ast__control.mjs +3 -0
  137. package/dist/query-ast__execution.d.mts +3 -0
  138. package/dist/query-ast__execution.mjs +3 -0
  139. package/dist/query-builder.d.mts +836 -0
  140. package/dist/query-builder.d.mts.map +1 -0
  141. package/dist/query-builder.mjs +3 -0
  142. package/dist/query-builder__contract-free.d.mts +83 -0
  143. package/dist/query-builder__contract-free.d.mts.map +1 -0
  144. package/dist/query-builder__contract-free.mjs +107 -0
  145. package/dist/query-builder__contract-free.mjs.map +1 -0
  146. package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts +822 -0
  147. package/dist/query-plan-C0-Yu8hf-DdilEdW6.d.mts.map +1 -0
  148. package/dist/runtime-DPkRW4iu.d.mts +1 -0
  149. package/dist/runtime.d.mts +286 -0
  150. package/dist/runtime.d.mts.map +1 -0
  151. package/dist/runtime.mjs +532 -0
  152. package/dist/runtime.mjs.map +1 -0
  153. package/dist/schema-ir.d.mts +2 -0
  154. package/dist/schema-ir.mjs +2 -0
  155. package/dist/schema-verify-DJGr28XW.d.mts +23 -0
  156. package/dist/schema-verify-DJGr28XW.d.mts.map +1 -0
  157. package/dist/value.d.mts +2 -0
  158. package/dist/value.mjs +2 -0
  159. package/dist/value__mongodb-types.d.mts +2 -0
  160. package/dist/value__mongodb-types.mjs +1 -0
  161. package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs +447 -0
  162. package/dist/verify-mongo-schema-De0FG2Rm-CCzwnNPY.mjs.map +1 -0
  163. package/dist/wire.d.mts +3 -0
  164. package/dist/wire.mjs +190 -0
  165. package/dist/wire.mjs.map +1 -0
  166. package/package.json +89 -0
@@ -0,0 +1,603 @@
1
+ import { structuredError } from "@prisma/orm-framework/utils/structured-error";
2
+ import { CrossReferenceSchema } from "@prisma/orm-framework/contract/types";
3
+ import { type } from "arktype";
4
+ import { IRNodeBase, freezeNode } from "@prisma/orm-framework/components/ir";
5
+ //#region ../../../2-mongo-family/1-foundation/mongo-contract/dist/entity-kinds-B4KNTF8z.mjs
6
+ const ControlPolicySchema = type("'managed' | 'tolerated' | 'external' | 'observed'");
7
+ const ScalarFieldTypeSchema = type({
8
+ "+": "reject",
9
+ kind: "'scalar'",
10
+ codecId: "string",
11
+ "typeParams?": "Record<string, unknown>"
12
+ });
13
+ const ValueObjectFieldTypeSchema = type({
14
+ "+": "reject",
15
+ kind: "'valueObject'",
16
+ name: "string"
17
+ });
18
+ const UnionFieldTypeSchema = type({
19
+ "+": "reject",
20
+ kind: "'union'",
21
+ members: ScalarFieldTypeSchema.or(ValueObjectFieldTypeSchema).array()
22
+ });
23
+ const FieldTypeSchema = ScalarFieldTypeSchema.or(ValueObjectFieldTypeSchema).or(UnionFieldTypeSchema);
24
+ const DomainEnumRefSchema = type({
25
+ plane: "'domain'",
26
+ namespaceId: "string",
27
+ entityKind: "'enum'",
28
+ entityName: "string",
29
+ "spaceId?": "string"
30
+ });
31
+ const ContractEnumSchema = type({
32
+ "+": "reject",
33
+ codecId: "string",
34
+ members: type({
35
+ name: "string",
36
+ value: "string | number | boolean | null | unknown[] | Record<string, unknown>"
37
+ }).array().atLeastLength(1).readonly()
38
+ });
39
+ const FieldSchema = type({
40
+ "+": "reject",
41
+ type: FieldTypeSchema,
42
+ "nullable?": "boolean",
43
+ "many?": "boolean",
44
+ "dict?": "boolean",
45
+ "valueSet?": DomainEnumRefSchema
46
+ }).pipe((field) => ({
47
+ ...field,
48
+ nullable: field.nullable ?? false
49
+ }));
50
+ const RelationSchema = type({
51
+ "+": "reject",
52
+ to: CrossReferenceSchema,
53
+ cardinality: "'1:1' | '1:N' | 'N:1'",
54
+ "on?": type({
55
+ "+": "reject",
56
+ localFields: "string[]",
57
+ targetFields: "string[]"
58
+ })
59
+ });
60
+ const StorageRelationEntrySchema = type({
61
+ "+": "reject",
62
+ field: "string"
63
+ });
64
+ const MongoJsonPrimitiveSchema = type.declare().type("string | number | boolean | null");
65
+ function isMongoJsonRecord(value) {
66
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
67
+ const prototype = Object.getPrototypeOf(value);
68
+ return prototype === Object.prototype || prototype === null;
69
+ }
70
+ function withUnseenReference(value, seen, visit) {
71
+ if (seen.has(value)) return false;
72
+ seen.add(value);
73
+ const result = visit();
74
+ seen.delete(value);
75
+ return result;
76
+ }
77
+ function isMongoJsonObject(value, seen) {
78
+ return isMongoJsonRecord(value) && withUnseenReference(value, seen, () => Object.values(value).every((entry) => isMongoJsonValue(entry, seen)));
79
+ }
80
+ function isMongoJsonValue(value, seen = /* @__PURE__ */ new WeakSet()) {
81
+ if (MongoJsonPrimitiveSchema.allows(value)) return true;
82
+ if (Array.isArray(value)) return withUnseenReference(value, seen, () => value.every((entry) => isMongoJsonValue(entry, seen)));
83
+ return isMongoJsonObject(value, seen);
84
+ }
85
+ const MongoJsonValueSchema = type("unknown").narrow((value, ctx) => isMongoJsonValue(value) ? true : ctx.mustBe("a JSON-serializable MongoJsonValue"));
86
+ const MongoJsonObjectSchema = type({ "[string]": "unknown" }).narrow((value, ctx) => isMongoJsonRecord(value) && Object.values(value).every((entry) => MongoJsonValueSchema.allows(entry)) ? true : ctx.mustBe("a JSON object with MongoJsonValue entries"));
87
+ const NumberRecordSchema = type({ "[string]": "number" });
88
+ const IndexFieldsSchema = type({
89
+ "+": "reject",
90
+ "[string]": "1 | -1 | \"text\" | \"2dsphere\" | \"2d\" | \"hashed\""
91
+ }).narrow((fields, ctx) => Object.keys(fields).length > 0 ? true : ctx.mustBe("an index field map with at least one entry"));
92
+ const CollationSchema = type({
93
+ "+": "reject",
94
+ "kind?": "'mongo-collation-options'",
95
+ locale: "string",
96
+ "caseLevel?": "boolean",
97
+ "caseFirst?": "\"off\" | \"upper\" | \"lower\"",
98
+ "strength?": "1 | 2 | 3 | 4 | 5",
99
+ "numericOrdering?": "boolean",
100
+ "alternate?": "\"non-ignorable\" | \"shifted\"",
101
+ "maxVariable?": "\"punct\" | \"space\"",
102
+ "backwards?": "boolean",
103
+ "normalization?": "boolean"
104
+ });
105
+ const IndexOptionDefaultsSchema = type({
106
+ "+": "reject",
107
+ "kind?": "'mongo-index-option-defaults'",
108
+ "storageEngine?": MongoJsonObjectSchema
109
+ });
110
+ const TimeSeriesCollectionOptionsSchema = type({
111
+ "+": "reject",
112
+ "kind?": "'mongo-time-series-collection-options'",
113
+ timeField: "string",
114
+ "metaField?": "string",
115
+ "granularity?": "\"seconds\" | \"minutes\" | \"hours\"",
116
+ "bucketMaxSpanSeconds?": "number",
117
+ "bucketRoundingSeconds?": "number"
118
+ });
119
+ const ClusteredCollectionOptionsSchema = type({
120
+ "+": "reject",
121
+ "kind?": "'mongo-clustered-collection-options'",
122
+ "name?": "string",
123
+ key: type({
124
+ "+": "reject",
125
+ "[string]": "1"
126
+ }).narrow((key, ctx) => Object.keys(key).length > 0 ? true : ctx.mustBe("a clustered index key map with at least one entry")),
127
+ unique: "boolean"
128
+ });
129
+ const ChangeStreamPreAndPostImagesSchema = type({
130
+ "+": "reject",
131
+ "kind?": "'mongo-change-stream-pre-and-post-images-options'",
132
+ enabled: "boolean"
133
+ });
134
+ type({
135
+ "+": "reject",
136
+ "capped?": "boolean",
137
+ "size?": "number",
138
+ "max?": "number",
139
+ "storageEngine?": MongoJsonObjectSchema,
140
+ "indexOptionDefaults?": IndexOptionDefaultsSchema,
141
+ "collation?": CollationSchema,
142
+ "timeseries?": TimeSeriesCollectionOptionsSchema,
143
+ "clusteredIndex?": ClusteredCollectionOptionsSchema,
144
+ "expireAfterSeconds?": "number",
145
+ "changeStreamPreAndPostImages?": ChangeStreamPreAndPostImagesSchema
146
+ });
147
+ const ModelStorageSchema = type({
148
+ "+": "reject",
149
+ "collection?": "string",
150
+ "relations?": type({ "[string]": StorageRelationEntrySchema })
151
+ });
152
+ const DiscriminatorSchema = type({
153
+ "+": "reject",
154
+ field: "string"
155
+ });
156
+ const VariantEntrySchema = type({
157
+ "+": "reject",
158
+ value: "string"
159
+ });
160
+ const ModelDefinitionSchema = type({
161
+ "+": "reject",
162
+ fields: type({ "[string]": FieldSchema }),
163
+ storage: ModelStorageSchema,
164
+ "relations?": type({ "[string]": RelationSchema }),
165
+ "discriminator?": DiscriminatorSchema,
166
+ "variants?": type({ "[string]": VariantEntrySchema }),
167
+ "base?": CrossReferenceSchema,
168
+ "owner?": "string"
169
+ });
170
+ type({
171
+ "+": "reject",
172
+ fields: IndexFieldsSchema,
173
+ "options?": type({
174
+ "+": "reject",
175
+ "kind?": "'mongo-index-options'",
176
+ "unique?": "boolean",
177
+ "name?": "string",
178
+ "partialFilterExpression?": MongoJsonObjectSchema,
179
+ "sparse?": "boolean",
180
+ "expireAfterSeconds?": "number",
181
+ "weights?": NumberRecordSchema,
182
+ "default_language?": "string",
183
+ "language_override?": "string",
184
+ "textIndexVersion?": "number",
185
+ "2dsphereIndexVersion?": "number",
186
+ "bits?": "number",
187
+ "min?": "number",
188
+ "max?": "number",
189
+ "bucketSize?": "number",
190
+ "hidden?": "boolean",
191
+ "collation?": CollationSchema,
192
+ "wildcardProjection?": type({
193
+ "+": "reject",
194
+ "[string]": "0 | 1"
195
+ })
196
+ })
197
+ });
198
+ const MongoStorageIndexSchema = type({
199
+ "+": "reject",
200
+ "kind?": "'mongo-index'",
201
+ keys: type({
202
+ "+": "reject",
203
+ field: "string",
204
+ direction: "1 | -1 | \"text\" | \"2dsphere\" | \"2d\" | \"hashed\""
205
+ }).array().atLeastLength(1),
206
+ "unique?": "boolean",
207
+ "sparse?": "boolean",
208
+ "expireAfterSeconds?": "number",
209
+ "partialFilterExpression?": "Record<string, unknown>",
210
+ "wildcardProjection?": "Record<string, 0 | 1>",
211
+ "collation?": "Record<string, unknown>",
212
+ "weights?": "Record<string, number>",
213
+ "default_language?": "string",
214
+ "language_override?": "string"
215
+ });
216
+ const MongoStorageValidatorSchema = type({
217
+ "+": "reject",
218
+ "kind?": "'mongo-validator'",
219
+ jsonSchema: "Record<string, unknown>",
220
+ validationLevel: "'strict' | 'moderate'",
221
+ validationAction: "'error' | 'warn'"
222
+ });
223
+ const MongoCollectionOptionsSchema = type({
224
+ "+": "reject",
225
+ "kind?": "'mongo-collection-options'",
226
+ "capped?": type({
227
+ "+": "reject",
228
+ size: "number",
229
+ "max?": "number"
230
+ }),
231
+ "storageEngine?": MongoJsonObjectSchema,
232
+ "indexOptionDefaults?": IndexOptionDefaultsSchema,
233
+ "timeseries?": type({
234
+ "+": "reject",
235
+ "kind?": "'mongo-time-series-collection-options'",
236
+ timeField: "string",
237
+ "metaField?": "string",
238
+ "granularity?": "'seconds' | 'minutes' | 'hours'",
239
+ "bucketMaxSpanSeconds?": "number",
240
+ "bucketRoundingSeconds?": "number"
241
+ }),
242
+ "collation?": "Record<string, unknown>",
243
+ "expireAfterSeconds?": "number",
244
+ "changeStreamPreAndPostImages?": ChangeStreamPreAndPostImagesSchema,
245
+ "clusteredIndex?": type({
246
+ "+": "reject",
247
+ "name?": "string"
248
+ })
249
+ });
250
+ const StorageCollectionSchema = type({
251
+ "+": "reject",
252
+ "kind?": "'mongo-collection'",
253
+ "indexes?": MongoStorageIndexSchema.array(),
254
+ "validator?": MongoStorageValidatorSchema,
255
+ "options?": MongoCollectionOptionsSchema,
256
+ "control?": ControlPolicySchema
257
+ });
258
+ const StorageValueSetSchema = type({
259
+ "+": "reject",
260
+ kind: "'valueSet'",
261
+ values: type("string | number | boolean | null | unknown[] | Record<string, unknown>").array().readonly()
262
+ });
263
+ function collectionEntrySchema(fragments) {
264
+ if (fragments === void 0 || fragments.size === 0) return StorageCollectionSchema;
265
+ return type("unknown").narrow((entry, ctx) => {
266
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return ctx.mustBe("an object");
267
+ const kind = entry.kind;
268
+ if (typeof kind === "string") {
269
+ const fragment = fragments.get(kind);
270
+ if (fragment !== void 0) {
271
+ const parsed = fragment(entry);
272
+ if (parsed instanceof type.errors) return ctx.reject({ expected: parsed.summary });
273
+ return true;
274
+ }
275
+ }
276
+ const parsed = StorageCollectionSchema(entry);
277
+ if (parsed instanceof type.errors) return ctx.reject({ expected: parsed.summary });
278
+ return true;
279
+ });
280
+ }
281
+ /**
282
+ * Builds the per-namespace envelope schema for Mongo storage. Pack
283
+ * contributions are keyed by the descriptor's `discriminator` and
284
+ * validate each entry by matching the entry's `kind` field. Mongo today
285
+ * has no pack contributions; the composition surface exists for symmetry
286
+ * with SQL and as the substrate for future entity kinds.
287
+ *
288
+ * `'kind?': 'string'` because `kind` is non-enumerable on built
289
+ * Mongo namespace IR classes and therefore absent from the wire shape; the
290
+ * type-side narrowing is enforced by the IR class, not by this validator.
291
+ */
292
+ function createMongoNamespaceEnvelopeSchema(fragments) {
293
+ return type({
294
+ "+": "reject",
295
+ id: "string",
296
+ "kind?": "string",
297
+ entries: type({
298
+ "collection?": type({ "[string]": collectionEntrySchema(fragments) }),
299
+ "valueSet?": type({ "[string]": StorageValueSetSchema })
300
+ })
301
+ }).narrow((ns, ctx) => {
302
+ if (typeof ns !== "object" || ns === null || Array.isArray(ns)) return ctx.mustBe("an object");
303
+ if (Object.hasOwn(ns, "collections") || Object.hasOwn(ns, "tables")) return ctx.reject({ expected: "namespace must use `entries: { collection? }`; flat `collections` / `tables` keys are no longer accepted" });
304
+ return true;
305
+ });
306
+ }
307
+ /**
308
+ * Builds the full Mongo contract schema. The per-namespace entry
309
+ * threading happens through {@link createMongoNamespaceEnvelopeSchema};
310
+ * the rest of the envelope is family-shared.
311
+ */
312
+ function createMongoContractSchema(fragments) {
313
+ const namespaceEnvelope = createMongoNamespaceEnvelopeSchema(fragments);
314
+ return type({
315
+ "+": "reject",
316
+ targetFamily: "'mongo'",
317
+ "schemaVersion?": "string",
318
+ "target?": "string",
319
+ "storageHash?": "string",
320
+ "profileHash?": "string",
321
+ roots: type({ "[string]": CrossReferenceSchema }),
322
+ "capabilities?": "Record<string, unknown>",
323
+ "extensions?": "Record<string, unknown>",
324
+ "meta?": "Record<string, unknown>",
325
+ "defaultControlPolicy?": ControlPolicySchema,
326
+ "sources?": "Record<string, unknown>",
327
+ "_generated?": "Record<string, unknown>",
328
+ domain: type({ namespaces: type({ "[string]": type({
329
+ models: type({ "[string]": ModelDefinitionSchema }),
330
+ "valueObjects?": type({ "[string]": type({
331
+ "+": "reject",
332
+ fields: type({ "[string]": FieldSchema })
333
+ }) }),
334
+ "enum?": type({ "[string]": ContractEnumSchema })
335
+ }) }) }),
336
+ storage: type({
337
+ "+": "reject",
338
+ namespaces: type({ "[string]": namespaceEnvelope }),
339
+ "storageHash?": "string"
340
+ })
341
+ });
342
+ }
343
+ const MongoContractSchema = createMongoContractSchema();
344
+ /**
345
+ * Change-stream pre-and-post-images collection option. Lifted from a
346
+ * `type =` data shape to an AST class extending `IRNodeBase` per
347
+ * FR18. Single-field shape; the class exists for AST-pattern
348
+ * consistency (every nested data shape inside `MongoCollectionOptions`
349
+ * is an AST node so the verifier can walk uniformly).
350
+ */
351
+ var MongoChangeStreamPreAndPostImagesOptions = class extends IRNodeBase {
352
+ kind = "mongo-change-stream-pre-and-post-images-options";
353
+ enabled;
354
+ constructor(options) {
355
+ super();
356
+ this.enabled = options.enabled;
357
+ freezeNode(this);
358
+ }
359
+ };
360
+ /**
361
+ * Mongo Contract IR leaf for collection / index collation options.
362
+ *
363
+ * Lifted from a `type =` data shape to an AST class extending
364
+ * `IRNodeBase` per FR18 ("Mongo's Contract IR is fully unified under
365
+ * the AST-class pattern, layered family / target"). Single concrete class
366
+ * (no target subclass): collation options carry no target-specific
367
+ * variation at this layer — both Atlas and self-hosted Mongo consume the
368
+ * same option vocabulary.
369
+ *
370
+ * Undefined optional fields are not assigned, so `JSON.stringify` omits
371
+ * them from the canonical JSON output (matches the pre-lift data shape's
372
+ * round-trip behaviour, modulo the new `kind` discriminator).
373
+ */
374
+ var MongoCollationOptions = class extends IRNodeBase {
375
+ kind = "mongo-collation-options";
376
+ locale;
377
+ constructor(options) {
378
+ super();
379
+ this.locale = options.locale;
380
+ if (options.caseLevel !== void 0) this.caseLevel = options.caseLevel;
381
+ if (options.caseFirst !== void 0) this.caseFirst = options.caseFirst;
382
+ if (options.strength !== void 0) this.strength = options.strength;
383
+ if (options.numericOrdering !== void 0) this.numericOrdering = options.numericOrdering;
384
+ if (options.alternate !== void 0) this.alternate = options.alternate;
385
+ if (options.maxVariable !== void 0) this.maxVariable = options.maxVariable;
386
+ if (options.backwards !== void 0) this.backwards = options.backwards;
387
+ if (options.normalization !== void 0) this.normalization = options.normalization;
388
+ freezeNode(this);
389
+ }
390
+ };
391
+ /**
392
+ * Collection-level default index options (the `indexOptionDefaults`
393
+ * collection-creation field on Mongo's `createCollection`). Lifted from
394
+ * a `type =` data shape to an AST class extending `IRNodeBase` per
395
+ * FR18 (Mongo Contract IR fully unified under the AST-class pattern).
396
+ *
397
+ * Carries `storageEngine` only — the underlying MongoDB option set is
398
+ * intentionally narrow at this layer; per-engine richer option vocabularies
399
+ * are out of scope for this project.
400
+ */
401
+ var MongoIndexOptionDefaults = class extends IRNodeBase {
402
+ kind = "mongo-index-option-defaults";
403
+ constructor(options = {}) {
404
+ super();
405
+ if (options.storageEngine !== void 0) this.storageEngine = options.storageEngine;
406
+ freezeNode(this);
407
+ }
408
+ };
409
+ /**
410
+ * Time-series collection options. Lifted from a `type =` data shape to
411
+ * an AST class extending `IRNodeBase` per FR18.
412
+ *
413
+ * MongoDB requires `timeField` for any time-series collection; the
414
+ * constructor enforces presence by type signature (`timeField: string`
415
+ * is required on the input).
416
+ */
417
+ var MongoTimeSeriesCollectionOptions = class extends IRNodeBase {
418
+ kind = "mongo-time-series-collection-options";
419
+ timeField;
420
+ constructor(options) {
421
+ super();
422
+ this.timeField = options.timeField;
423
+ if (options.metaField !== void 0) this.metaField = options.metaField;
424
+ if (options.granularity !== void 0) this.granularity = options.granularity;
425
+ if (options.bucketMaxSpanSeconds !== void 0) this.bucketMaxSpanSeconds = options.bucketMaxSpanSeconds;
426
+ if (options.bucketRoundingSeconds !== void 0) this.bucketRoundingSeconds = options.bucketRoundingSeconds;
427
+ freezeNode(this);
428
+ }
429
+ };
430
+ /**
431
+ * Mongo Contract IR node for collection-level creation options (the
432
+ * second argument to `db.createCollection(name, options)`). Lifted from
433
+ * the pre-M2R2 `MongoStorageCollectionOptions` storage interface to a
434
+ * class extending `IRNodeBase` per FR18.
435
+ *
436
+ * Single concrete family-layer class (no target subclass). The
437
+ * constructor accepts the storage JSON envelope shape ({@link
438
+ * MongoCollectionOptionsInput}) so the family-base hydration walker
439
+ * can pass arktype-validated objects directly to `new`. Authoring
440
+ * vocabulary is translated to this shape upstream in the contract-ts
441
+ * builder.
442
+ *
443
+ * Nested IR sub-shapes (collation, timeseries, …) are normalised to
444
+ * their respective IR class instances inside the constructor so
445
+ * downstream walks see a uniform AST regardless of whether the input
446
+ * was a JSON literal or an already-constructed class.
447
+ */
448
+ var MongoCollectionOptions = class extends IRNodeBase {
449
+ kind = "mongo-collection-options";
450
+ constructor(input = {}) {
451
+ super();
452
+ if (input.capped !== void 0) this.capped = {
453
+ size: input.capped.size,
454
+ ...input.capped.max != null && { max: input.capped.max }
455
+ };
456
+ if (input.storageEngine !== void 0) this.storageEngine = input.storageEngine;
457
+ if (input.indexOptionDefaults !== void 0) this.indexOptionDefaults = input.indexOptionDefaults instanceof MongoIndexOptionDefaults ? input.indexOptionDefaults : new MongoIndexOptionDefaults(input.indexOptionDefaults);
458
+ if (input.collation !== void 0) this.collation = input.collation instanceof MongoCollationOptions ? input.collation : new MongoCollationOptions(input.collation);
459
+ if (input.timeseries !== void 0) this.timeseries = input.timeseries instanceof MongoTimeSeriesCollectionOptions ? input.timeseries : new MongoTimeSeriesCollectionOptions(input.timeseries);
460
+ if (input.clusteredIndex !== void 0) this.clusteredIndex = input.clusteredIndex.name !== void 0 ? { name: input.clusteredIndex.name } : {};
461
+ if (input.expireAfterSeconds !== void 0) this.expireAfterSeconds = input.expireAfterSeconds;
462
+ if (input.changeStreamPreAndPostImages !== void 0) this.changeStreamPreAndPostImages = input.changeStreamPreAndPostImages instanceof MongoChangeStreamPreAndPostImagesOptions ? input.changeStreamPreAndPostImages : new MongoChangeStreamPreAndPostImagesOptions(input.changeStreamPreAndPostImages);
463
+ freezeNode(this);
464
+ }
465
+ };
466
+ /**
467
+ * Mongo Contract IR node for a single collection index entry (one
468
+ * element of `MongoCollection.indexes`). Lifted from the
469
+ * pre-M2R2 `MongoStorageIndex` storage interface to a class extending
470
+ * `IRNodeBase` per FR18.
471
+ *
472
+ * Single concrete family-layer class (no target subclass). The spec's
473
+ * `MongoTargetIndex extends MongoIndex` pattern remains additive — a
474
+ * future Mongo target with target-specific index extensions is free to
475
+ * subclass; for the single Mongo target shipped today a concrete
476
+ * family-layer class is enough and avoids a target-import layering
477
+ * violation from the contract-ts builder.
478
+ */
479
+ var MongoIndex = class extends IRNodeBase {
480
+ kind = "mongo-index";
481
+ keys;
482
+ constructor(input) {
483
+ super();
484
+ this.keys = input.keys;
485
+ if (input.unique !== void 0) this.unique = input.unique;
486
+ if (input.sparse !== void 0) this.sparse = input.sparse;
487
+ if (input.expireAfterSeconds !== void 0) this.expireAfterSeconds = input.expireAfterSeconds;
488
+ if (input.partialFilterExpression !== void 0) this.partialFilterExpression = input.partialFilterExpression;
489
+ if (input.wildcardProjection !== void 0) this.wildcardProjection = input.wildcardProjection;
490
+ if (input.collation !== void 0) this.collation = input.collation;
491
+ if (input.weights !== void 0) this.weights = input.weights;
492
+ if (input.default_language !== void 0) this.default_language = input.default_language;
493
+ if (input.language_override !== void 0) this.language_override = input.language_override;
494
+ freezeNode(this);
495
+ }
496
+ };
497
+ /**
498
+ * Mongo Contract IR node for collection-level document validators (the
499
+ * `validator` field on Mongo's `createCollection`). Lifted from the
500
+ * pre-M2R2 `MongoStorageValidator` storage interface to a class extending
501
+ * `IRNodeBase` per FR18.
502
+ *
503
+ * Concrete at the family layer (no target subclass). The spec's
504
+ * abstract-family + target-concrete pattern (`MongoTargetValidator
505
+ * extends MongoValidator`) becomes meaningful when a second Mongo target
506
+ * introduces target-specific validator extensions (Atlas search rules,
507
+ * DocumentDB-specific levels, …); for the single Mongo target shipped
508
+ * today, a concrete family-layer class lets the PSL JSON-Schema deriver
509
+ * and the contract-ts builder construct instances directly without a
510
+ * target-import layering violation. Target subclassing remains additive
511
+ * — a future `MongoTargetValidator extends MongoValidator` is an
512
+ * additive change, not a breaking one.
513
+ */
514
+ var MongoValidator = class extends IRNodeBase {
515
+ kind = "mongo-validator";
516
+ jsonSchema;
517
+ validationLevel;
518
+ validationAction;
519
+ constructor(input) {
520
+ super();
521
+ this.jsonSchema = input.jsonSchema;
522
+ this.validationLevel = input.validationLevel;
523
+ this.validationAction = input.validationAction;
524
+ freezeNode(this);
525
+ }
526
+ };
527
+ /**
528
+ * Mongo Contract IR node for a single collection entry in a namespace's
529
+ * `collections` map. Lifted from the pre-M2R2
530
+ * `MongoStorageCollection` storage interface to a class extending
531
+ * `IRNodeBase` per FR18.
532
+ *
533
+ * Concrete at the family layer (no target subclass). The spec's
534
+ * `MongoTargetCollection extends MongoCollection` pattern remains
535
+ * additive: a future Mongo target with target-specific extensions is
536
+ * free to subclass without breaking the family-layer construction
537
+ * sites.
538
+ *
539
+ * The unprefixed name `MongoCollection` is now the contract IR class.
540
+ * Note that `@internal/mongo-orm` also exports a (different)
541
+ * `MongoCollection<TContract, ModelName>` generic for the user-facing
542
+ * ORM query builder; the two live in separate packages and are
543
+ * resolved by import path. A source file that needs both should alias
544
+ * one (e.g. `import { MongoCollection as MongoContractCollection }
545
+ * from '@internal/mongo-contract'`).
546
+ */
547
+ var MongoCollection = class extends IRNodeBase {
548
+ kind = "mongo-collection";
549
+ constructor(input = {}) {
550
+ super();
551
+ if (input.indexes !== void 0) this.indexes = input.indexes.map((idx) => idx instanceof MongoIndex ? idx : new MongoIndex(idx));
552
+ if (input.validator !== void 0) this.validator = input.validator instanceof MongoValidator ? input.validator : new MongoValidator(input.validator);
553
+ if (input.options !== void 0) this.options = input.options instanceof MongoCollectionOptions ? input.options : new MongoCollectionOptions(input.options);
554
+ if (input.control !== void 0) this.control = input.control;
555
+ freezeNode(this);
556
+ }
557
+ };
558
+ /**
559
+ * Mongo Contract IR node for a value-set entry in a namespace's `valueSet` map
560
+ * (`entries.valueSet`). Same shape as SQL's `StorageValueSet`: the ordered set of permitted
561
+ * codec-encoded values for a field restriction, with no `codecId` (the field that references it
562
+ * holds the codec). The `kind` is enumerable so the JSON envelope carries the discriminator and the
563
+ * hydration walker can dispatch on it. Value-sets are keyed by name in the parent namespace's
564
+ * `valueSet: Record<string, MongoValueSet>` map, so the entry name is not on the class.
565
+ */
566
+ var MongoValueSet = class extends IRNodeBase {
567
+ kind = "valueSet";
568
+ values;
569
+ constructor(input) {
570
+ super();
571
+ this.values = Object.freeze([...input.values]);
572
+ freezeNode(this);
573
+ }
574
+ };
575
+ const collectionEntityKind = {
576
+ kind: "collection",
577
+ schema: StorageCollectionSchema,
578
+ construct: (input) => new MongoCollection(input)
579
+ };
580
+ const valueSetEntityKind = {
581
+ kind: "valueSet",
582
+ schema: StorageValueSetSchema,
583
+ construct: (input) => new MongoValueSet(input)
584
+ };
585
+ /**
586
+ * Assembles the `kind → descriptor` registry for Mongo namespaces: the built-in
587
+ * `collection` kind plus any target `packKinds`. This builds the lookup table —
588
+ * it does not touch contract data. `hydrateNamespaceEntities` later consumes
589
+ * this registry to turn a namespace's raw entries into IR instances. Throws on
590
+ * a duplicate kind.
591
+ */
592
+ function composeMongoEntityKinds(packKinds = []) {
593
+ const kinds = /* @__PURE__ */ new Map([["collection", collectionEntityKind], ["valueSet", valueSetEntityKind]]);
594
+ for (const descriptor of packKinds) {
595
+ if (kinds.has(descriptor.kind)) throw structuredError("CONTRACT.PACK_CONTRIBUTION_INVALID", `composeMongoEntityKinds: duplicate entity kind "${descriptor.kind}" — each kind may be registered only once`);
596
+ kinds.set(descriptor.kind, descriptor);
597
+ }
598
+ return kinds;
599
+ }
600
+ //#endregion
601
+ export { MongoContractSchema as a, MongoTimeSeriesCollectionOptions as c, StorageValueSetSchema as d, collectionEntityKind as f, valueSetEntityKind as g, createMongoNamespaceEnvelopeSchema as h, MongoCollectionOptions as i, MongoValidator as l, createMongoContractSchema as m, MongoCollationOptions as n, MongoIndex as o, composeMongoEntityKinds as p, MongoCollection as r, MongoIndexOptionDefaults as s, MongoChangeStreamPreAndPostImagesOptions as t, MongoValueSet as u };
602
+
603
+ //# sourceMappingURL=entity-kinds-B4KNTF8z-DPIuUuuB.mjs.map