@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,532 @@
1
+ import { n as newMongoCodecRegistry } from "./dist-Czwqx_i3.mjs";
2
+ import { t as MongoParamRef } from "./dist-C7Ykq48Q.mjs";
3
+ import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
4
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
5
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
6
+ import { canonicalStringify } from "@prisma/orm-framework/utils/canonical-stringify";
7
+ import { AsyncIterableResult, RuntimeCore, checkAborted, checkMiddlewareCompatibility, runBeforeExecuteChain, runWithMiddleware, runtimeError } from "@prisma/orm-framework/components/runtime";
8
+ import { createExecutionStack } from "@prisma/orm-framework/components/execution";
9
+ import { hashContent } from "@prisma/orm-framework/utils/hash-content";
10
+ import { isPlainRecord } from "@prisma/orm-framework/contract/is-plain-record";
11
+ //#region ../../../2-mongo-family/7-runtime/dist/index.mjs
12
+ function createMongoExecutionStack(options) {
13
+ return createExecutionStack({
14
+ target: options.target,
15
+ adapter: options.adapter,
16
+ driver: options.driver,
17
+ extensions: options.extensions
18
+ });
19
+ }
20
+ function createMongoExecutionContext(options) {
21
+ const registry = newMongoCodecRegistry();
22
+ const owners = /* @__PURE__ */ new Map();
23
+ const contributors = [
24
+ options.stack.target,
25
+ options.stack.adapter,
26
+ ...options.stack.extensions
27
+ ];
28
+ for (const contributor of contributors) {
29
+ const contributed = contributor.codecs();
30
+ for (const codec of iterateCodecs(contributed)) {
31
+ const existingOwner = owners.get(codec.id);
32
+ if (existingOwner !== void 0) throw runtimeError("RUNTIME.DUPLICATE_CODEC", `Duplicate Mongo codec id '${codec.id}' contributed by '${contributor.id}' (already registered by '${existingOwner}').`, {
33
+ codecId: codec.id,
34
+ existingOwner,
35
+ incomingOwner: contributor.id
36
+ });
37
+ registry.register(codec);
38
+ owners.set(codec.id, contributor.id);
39
+ }
40
+ }
41
+ return Object.freeze({
42
+ contract: options.contract,
43
+ codecs: registry,
44
+ stack: options.stack
45
+ });
46
+ }
47
+ function* iterateCodecs(registry) {
48
+ yield* registry.values();
49
+ }
50
+ const WIRE_PREVIEW_LIMIT = 100;
51
+ function previewWireValue(wireValue) {
52
+ if (typeof wireValue === "string") return wireValue.length > WIRE_PREVIEW_LIMIT ? `${wireValue.substring(0, WIRE_PREVIEW_LIMIT)}...` : wireValue;
53
+ return String(wireValue).substring(0, WIRE_PREVIEW_LIMIT);
54
+ }
55
+ /**
56
+ * Structured envelopes (any error with a dotted `code`, per `isStructuredError`)
57
+ * thrown by a codec body pass through unchanged; everything else is wrapped in
58
+ * a `RUNTIME.DECODE_FAILED` envelope with the original error on `cause`.
59
+ */
60
+ function wrapDecodeFailure(error, collection, path, codecId, wireValue) {
61
+ if (isStructuredError(error)) throw error;
62
+ const wrapped = runtimeError("RUNTIME.DECODE_FAILED", `Failed to decode field ${path} in collection '${collection}' with codec '${codecId}': ${error instanceof Error ? error.message : String(error)}`, {
63
+ collection,
64
+ path,
65
+ codec: codecId,
66
+ wirePreview: previewWireValue(wireValue)
67
+ });
68
+ wrapped.cause = error;
69
+ throw wrapped;
70
+ }
71
+ async function decodeMongoRow(row, shape, registry, collection, ctx = {}) {
72
+ if (shape.kind === "unknown") return row;
73
+ if (typeof row !== "object" || row === null) return row;
74
+ const rowObj = row;
75
+ const out = {};
76
+ const tasks = [];
77
+ function scheduleLeaf(path, codecId, wire, assign) {
78
+ const codec = registry.get(codecId);
79
+ if (!codec) {
80
+ assign(wire);
81
+ return;
82
+ }
83
+ tasks.push((async () => {
84
+ try {
85
+ assign(await codec.decode(wire, ctx));
86
+ } catch (error) {
87
+ wrapDecodeFailure(error, collection, path, codecId, wire);
88
+ }
89
+ })());
90
+ }
91
+ function walkField(value, fieldShape, path, assign) {
92
+ switch (fieldShape.kind) {
93
+ case "unknown":
94
+ assign(value);
95
+ return;
96
+ case "leaf":
97
+ if (value === null || value === void 0) {
98
+ assign(value);
99
+ return;
100
+ }
101
+ scheduleLeaf(path, fieldShape.codecId, value, assign);
102
+ return;
103
+ case "document": {
104
+ if (value === null || value === void 0) {
105
+ assign(value);
106
+ return;
107
+ }
108
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
109
+ assign(value);
110
+ return;
111
+ }
112
+ const vObj = value;
113
+ const nested = { ...vObj };
114
+ assign(nested);
115
+ for (const [fk, fShape] of Object.entries(fieldShape.fields)) walkField(vObj[fk], fShape, `${path}.${fk}`, (v) => {
116
+ nested[fk] = v;
117
+ });
118
+ return;
119
+ }
120
+ case "array": {
121
+ if (value === null || value === void 0) {
122
+ assign(value);
123
+ return;
124
+ }
125
+ if (!Array.isArray(value)) {
126
+ assign(value);
127
+ return;
128
+ }
129
+ const arr = [];
130
+ assign(arr);
131
+ for (let i = 0; i < value.length; i++) {
132
+ const el = value[i];
133
+ walkField(el, fieldShape.element, `${path}.${i}`, (v) => {
134
+ arr[i] = v;
135
+ });
136
+ }
137
+ return;
138
+ }
139
+ }
140
+ /* v8 ignore stop */
141
+ }
142
+ for (const [k, fShape] of Object.entries(shape.fields)) walkField(rowObj[k], fShape, k, (v) => {
143
+ out[k] = v;
144
+ });
145
+ for (const k of Object.keys(rowObj)) if (!Object.hasOwn(shape.fields, k)) out[k] = rowObj[k];
146
+ await Promise.all(tasks);
147
+ return out;
148
+ }
149
+ /** @internal */
150
+ const RUNTIME_CONTENT_HASH_REQUIRES_RESOLVED_COMMAND = "RUNTIME.CONTENT_HASH_REQUIRES_RESOLVED_COMMAND";
151
+ /**
152
+ * Resolved wire commands are frozen class instances (`InsertOneWireCommand`, …);
153
+ * pre-resolve `beforeExecute` plans hold a plain-object `MongoLoweredDraft` in the
154
+ * command slot. O(1) prototype check — no tree walk on the hot path.
155
+ */
156
+ function isResolvedMongoWireCommand(command) {
157
+ if (command === null || typeof command !== "object") return false;
158
+ const proto = Object.getPrototypeOf(command);
159
+ return proto !== null && proto !== Object.prototype;
160
+ }
161
+ function assertContentHashOnResolvedCommand(command) {
162
+ if (isResolvedMongoWireCommand(command)) return;
163
+ throw runtimeError(RUNTIME_CONTENT_HASH_REQUIRES_RESOLVED_COMMAND, "contentHash and computeMongoContentHash are only valid on a resolved wire command (after param resolution, e.g. from afterExecute). During beforeExecute, plan.command holds an unresolved MongoLoweredDraft — use params.entries() and the param mutator instead of contentHash or structural reads of plan.command.", { phase: "beforeExecute" });
164
+ }
165
+ /**
166
+ * Computes a stable content hash for a lowered Mongo execution plan.
167
+ *
168
+ * Internally builds an unambiguous canonical-stringified preimage from
169
+ * two components:
170
+ *
171
+ * 1. `meta.storageHash` — discriminates by schema. A migration changes the
172
+ * storage hash, which invalidates cached entries automatically (no
173
+ * per-app invalidation logic needed for schema changes).
174
+ * 2. `exec.command` — the wire command. `canonicalStringify` produces a
175
+ * deterministic serialization that is stable across object key
176
+ * insertion order and that distinguishes types JSON would otherwise
177
+ * conflate (e.g. `BigInt(1)` vs `1`, `Date` vs ISO string, `Buffer`
178
+ * vs number array). The spread converts the frozen wire-command
179
+ * class instance (`InsertOneWireCommand`, `AggregateWireCommand`, …)
180
+ * into a plain object exposing its own enumerable properties
181
+ * (`kind`, `collection`, plus the payload-specific fields like
182
+ * `document`/`filter`/`update`/`pipeline`/…), which is what
183
+ * `canonicalStringify` accepts; class instances are rejected
184
+ * outright to prevent silent collisions.
185
+ *
186
+ * Unlike SQL, there is no separate "rendered statement" component because
187
+ * a Mongo `MongoExecutionPlan.command` is the wire command itself —
188
+ * canonicalizing it captures both structure and parameters in one pass.
189
+ *
190
+ * The components are wrapped in an object and canonicalized as a single
191
+ * unit (rather than concatenated with a delimiter) so component
192
+ * boundaries are unambiguous and cannot collide with a different split
193
+ * of the same characters.
194
+ *
195
+ * The canonical string is then piped through `hashContent` to produce a
196
+ * bounded, opaque digest. See `@internal/utils/hash-content` for the
197
+ * rationale.
198
+ *
199
+ * @throws {RuntimeErrorEnvelope} {@link RUNTIME_CONTENT_HASH_REQUIRES_RESOLVED_COMMAND}
200
+ * when `exec.command` is still a pre-resolve draft (plain object), e.g. when
201
+ * `contentHash` is called from `beforeExecute`.
202
+ *
203
+ * @internal
204
+ */
205
+ function computeMongoContentHash(exec) {
206
+ assertContentHashOnResolvedCommand(exec.command);
207
+ return hashContent(canonicalStringify({
208
+ storageHash: exec.meta.storageHash,
209
+ command: { ...exec.command }
210
+ }));
211
+ }
212
+ function* flattenDraftSlot(value) {
213
+ if (value instanceof MongoParamRef) {
214
+ yield value;
215
+ return;
216
+ }
217
+ if (Array.isArray(value)) {
218
+ for (const item of value) yield* flattenDraftSlot(item);
219
+ return;
220
+ }
221
+ if (isPlainRecord(value)) for (const v of Object.values(value)) yield* flattenDraftSlot(v);
222
+ }
223
+ /**
224
+ * Flat walk over a `MongoLoweredDraft` yielding every `MongoParamRef` leaf
225
+ * regardless of nesting — object values, array elements, filter predicate
226
+ * values, update operator values, and pipeline stage values. Raw command
227
+ * variants carry no `MongoParamRef` nodes so they yield zero entries.
228
+ *
229
+ * **Walk parity:** slot traversal matches `resolveDraftSlot` / `resolveParams`
230
+ * — refs appear only in plain-object and array containers; `Date` and other
231
+ * non-plain objects are leaves (not descended into), so middleware sees every
232
+ * ref the resolve pass will encode.
233
+ */
234
+ function* flattenMongoParamRefs(draft) {
235
+ switch (draft.kind) {
236
+ case "insertOne":
237
+ case "rawInsertOne":
238
+ yield* flattenDraftSlot(draft.document);
239
+ break;
240
+ case "insertMany":
241
+ case "rawInsertMany":
242
+ for (const doc of draft.documents) yield* flattenDraftSlot(doc);
243
+ break;
244
+ case "updateOne":
245
+ case "updateMany":
246
+ case "rawUpdateOne":
247
+ case "rawUpdateMany":
248
+ yield* flattenDraftSlot(draft.filter);
249
+ yield* flattenDraftSlot(draft.update);
250
+ break;
251
+ case "findOneAndUpdate":
252
+ case "rawFindOneAndUpdate":
253
+ yield* flattenDraftSlot(draft.filter);
254
+ yield* flattenDraftSlot(draft.update);
255
+ break;
256
+ case "deleteOne":
257
+ case "deleteMany":
258
+ case "rawDeleteOne":
259
+ case "rawDeleteMany":
260
+ yield* flattenDraftSlot(draft.filter);
261
+ break;
262
+ case "findOneAndDelete":
263
+ case "rawFindOneAndDelete":
264
+ yield* flattenDraftSlot(draft.filter);
265
+ break;
266
+ case "aggregate":
267
+ case "rawAggregate":
268
+ for (const stage of draft.pipeline) yield* flattenDraftSlot(stage);
269
+ break;
270
+ }
271
+ }
272
+ function substituteSlot(value, overrides) {
273
+ if (value instanceof MongoParamRef) {
274
+ if (overrides.has(value)) {
275
+ const opts = {};
276
+ if (value.name !== void 0) opts.name = value.name;
277
+ if (value.codecId !== void 0) opts.codecId = value.codecId;
278
+ return new MongoParamRef(overrides.get(value), opts);
279
+ }
280
+ return value;
281
+ }
282
+ if (Array.isArray(value)) return value.map((item) => substituteSlot(item, overrides));
283
+ if (isPlainRecord(value)) {
284
+ const out = {};
285
+ for (const [k, v] of Object.entries(value)) out[k] = substituteSlot(v, overrides);
286
+ return out;
287
+ }
288
+ return value;
289
+ }
290
+ function substituteDoc(doc, overrides) {
291
+ return blindCast(substituteSlot(doc, overrides));
292
+ }
293
+ function isUpdatePipeline(update) {
294
+ return Array.isArray(update);
295
+ }
296
+ function substituteUpdate(update, overrides) {
297
+ if (isUpdatePipeline(update)) return update.map((stage) => substituteDoc(stage, overrides));
298
+ return substituteDoc(update, overrides);
299
+ }
300
+ function buildMutatedDraft(draft, overrides) {
301
+ switch (draft.kind) {
302
+ case "insertOne": return {
303
+ kind: "insertOne",
304
+ collection: draft.collection,
305
+ document: substituteDoc(draft.document, overrides)
306
+ };
307
+ case "rawInsertOne": return {
308
+ kind: "rawInsertOne",
309
+ collection: draft.collection,
310
+ document: substituteDoc(draft.document, overrides)
311
+ };
312
+ case "insertMany": return {
313
+ kind: "insertMany",
314
+ collection: draft.collection,
315
+ documents: draft.documents.map((d) => substituteDoc(d, overrides))
316
+ };
317
+ case "rawInsertMany": return {
318
+ kind: "rawInsertMany",
319
+ collection: draft.collection,
320
+ documents: draft.documents.map((d) => substituteDoc(d, overrides))
321
+ };
322
+ case "updateOne": return {
323
+ kind: "updateOne",
324
+ collection: draft.collection,
325
+ filter: substituteDoc(draft.filter, overrides),
326
+ update: substituteUpdate(draft.update, overrides),
327
+ upsert: draft.upsert
328
+ };
329
+ case "updateMany": return {
330
+ kind: "updateMany",
331
+ collection: draft.collection,
332
+ filter: substituteDoc(draft.filter, overrides),
333
+ update: substituteUpdate(draft.update, overrides),
334
+ upsert: draft.upsert
335
+ };
336
+ case "rawUpdateOne": return {
337
+ kind: "rawUpdateOne",
338
+ collection: draft.collection,
339
+ filter: substituteDoc(draft.filter, overrides),
340
+ update: substituteUpdate(draft.update, overrides)
341
+ };
342
+ case "rawUpdateMany": return {
343
+ kind: "rawUpdateMany",
344
+ collection: draft.collection,
345
+ filter: substituteDoc(draft.filter, overrides),
346
+ update: substituteUpdate(draft.update, overrides)
347
+ };
348
+ case "deleteOne": return {
349
+ kind: "deleteOne",
350
+ collection: draft.collection,
351
+ filter: substituteDoc(draft.filter, overrides)
352
+ };
353
+ case "deleteMany": return {
354
+ kind: "deleteMany",
355
+ collection: draft.collection,
356
+ filter: substituteDoc(draft.filter, overrides)
357
+ };
358
+ case "rawDeleteOne": return {
359
+ kind: "rawDeleteOne",
360
+ collection: draft.collection,
361
+ filter: substituteDoc(draft.filter, overrides)
362
+ };
363
+ case "rawDeleteMany": return {
364
+ kind: "rawDeleteMany",
365
+ collection: draft.collection,
366
+ filter: substituteDoc(draft.filter, overrides)
367
+ };
368
+ case "findOneAndUpdate": return {
369
+ kind: "findOneAndUpdate",
370
+ collection: draft.collection,
371
+ filter: substituteDoc(draft.filter, overrides),
372
+ update: substituteUpdate(draft.update, overrides),
373
+ upsert: draft.upsert,
374
+ sort: draft.sort,
375
+ returnDocument: draft.returnDocument
376
+ };
377
+ case "rawFindOneAndUpdate": return {
378
+ kind: "rawFindOneAndUpdate",
379
+ collection: draft.collection,
380
+ filter: substituteDoc(draft.filter, overrides),
381
+ update: substituteUpdate(draft.update, overrides),
382
+ upsert: draft.upsert,
383
+ sort: draft.sort,
384
+ returnDocument: draft.returnDocument
385
+ };
386
+ case "findOneAndDelete": return {
387
+ kind: "findOneAndDelete",
388
+ collection: draft.collection,
389
+ filter: substituteDoc(draft.filter, overrides),
390
+ sort: draft.sort
391
+ };
392
+ case "rawFindOneAndDelete": return {
393
+ kind: "rawFindOneAndDelete",
394
+ collection: draft.collection,
395
+ filter: substituteDoc(draft.filter, overrides),
396
+ sort: draft.sort
397
+ };
398
+ case "aggregate": return {
399
+ kind: "aggregate",
400
+ collection: draft.collection,
401
+ pipeline: draft.pipeline.map((s) => substituteDoc(s, overrides))
402
+ };
403
+ case "rawAggregate": return {
404
+ kind: "rawAggregate",
405
+ collection: draft.collection,
406
+ pipeline: draft.pipeline.map((s) => substituteDoc(s, overrides))
407
+ };
408
+ }
409
+ }
410
+ /**
411
+ * Build a {@link MongoParamRefMutatorInternal} for the given lowered draft.
412
+ *
413
+ * The mutator captures the draft by reference and uses `flattenMongoParamRefs`
414
+ * on demand to produce `entries()`. Replacements are stored in a lazily-
415
+ * allocated `Map`; the fast path (no replacements) preserves bit-for-bit
416
+ * reference identity to the original draft in `currentDraft()`.
417
+ */
418
+ function createMongoParamRefMutator(draft) {
419
+ const originalDraft = draft;
420
+ let overrides;
421
+ const ensureOverrides = () => {
422
+ if (!overrides) overrides = /* @__PURE__ */ new Map();
423
+ return overrides;
424
+ };
425
+ function* entries() {
426
+ for (const ref of flattenMongoParamRefs(originalDraft)) yield blindCast({
427
+ ref: blindCast(ref),
428
+ value: overrides?.has(ref) ? overrides.get(ref) : ref.value,
429
+ codecId: ref.codecId
430
+ });
431
+ }
432
+ function replaceValue(handle, newValue) {
433
+ ensureOverrides().set(blindCast(handle), newValue);
434
+ }
435
+ function replaceValues(updates) {
436
+ const map = ensureOverrides();
437
+ for (const { ref, newValue } of updates) map.set(blindCast(ref), newValue);
438
+ }
439
+ return {
440
+ entries,
441
+ replaceValue: blindCast(replaceValue),
442
+ replaceValues,
443
+ currentDraft() {
444
+ if (!overrides || overrides.size === 0) return originalDraft;
445
+ return buildMutatedDraft(originalDraft, overrides);
446
+ }
447
+ };
448
+ }
449
+ function noop() {}
450
+ var MongoRuntimeImpl = class extends RuntimeCore {
451
+ #adapter;
452
+ #driver;
453
+ #codecs;
454
+ constructor(options) {
455
+ const middleware = options.middleware ? [...options.middleware] : [];
456
+ const targetId = options.context.stack.target.targetId;
457
+ for (const mw of middleware) checkMiddlewareCompatibility(mw, "mongo", targetId);
458
+ const ctx = {
459
+ contract: options.context.contract,
460
+ mode: options.mode ?? "strict",
461
+ now: () => Date.now(),
462
+ log: {
463
+ info: noop,
464
+ warn: noop,
465
+ error: noop
466
+ },
467
+ contentHash: (exec) => computeMongoContentHash(blindCast(exec)),
468
+ scope: "runtime",
469
+ planExecutionId: ""
470
+ };
471
+ super({
472
+ middleware,
473
+ ctx
474
+ });
475
+ const adapterInstance = options.context.stack.adapter.create(options.context.stack);
476
+ this.#adapter = adapterInstance;
477
+ this.#driver = options.driver;
478
+ this.#codecs = options.context.codecs;
479
+ }
480
+ /* v8 ignore start -- one-phase lower satisfies RuntimeCore; execute uses structuralLower + resolveParams */
481
+ async lower(plan, ctx) {
482
+ return {
483
+ command: await this.#adapter.lower(plan, ctx),
484
+ meta: plan.meta,
485
+ ...ifDefined("resultShape", plan.resultShape)
486
+ };
487
+ }
488
+ /* v8 ignore stop */
489
+ runDriver(exec) {
490
+ return this.#driver.execute(exec.command);
491
+ }
492
+ execute(plan, options) {
493
+ const self = this;
494
+ const signal = options?.signal;
495
+ const codecCtx = signal === void 0 ? {} : { signal };
496
+ const execCtx = {
497
+ ...self.ctx,
498
+ planExecutionId: crypto.randomUUID()
499
+ };
500
+ const generator = async function* () {
501
+ checkAborted(codecCtx, "stream");
502
+ const compiled = await self.runBeforeCompile(plan);
503
+ const draft = self.#adapter.structuralLower(compiled);
504
+ const mutator = createMongoParamRefMutator(draft);
505
+ await runBeforeExecuteChain({
506
+ meta: compiled.meta,
507
+ ...ifDefined("resultShape", compiled.resultShape),
508
+ command: blindCast(draft)
509
+ }, self.middleware, execCtx, mutator);
510
+ const resolvedCommand = await self.#adapter.resolveParams(mutator.currentDraft(), codecCtx);
511
+ const exec = {
512
+ meta: compiled.meta,
513
+ ...ifDefined("resultShape", compiled.resultShape),
514
+ command: resolvedCommand
515
+ };
516
+ const stream = runWithMiddleware(exec, self.middleware, execCtx, () => self.runDriver(exec));
517
+ for await (const rawRow of stream) if (exec.resultShape === void 0) yield blindCast(rawRow);
518
+ else yield blindCast(await decodeMongoRow(rawRow, exec.resultShape, self.#codecs, exec.command.collection, codecCtx));
519
+ };
520
+ return new AsyncIterableResult(generator());
521
+ }
522
+ async close() {
523
+ await this.#driver.close();
524
+ }
525
+ };
526
+ function createMongoRuntime(options) {
527
+ return new MongoRuntimeImpl(options);
528
+ }
529
+ //#endregion
530
+ export { createMongoExecutionContext, createMongoExecutionStack, createMongoParamRefMutator, createMongoRuntime, flattenMongoParamRefs };
531
+
532
+ //# sourceMappingURL=runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.mjs","names":["#adapter","#driver","#codecs"],"sources":["../../../../2-mongo-family/7-runtime/dist/index.mjs"],"sourcesContent":["import { createExecutionStack } from \"@internal/framework-components/execution\";\nimport { AsyncIterableResult, RuntimeCore, checkAborted, checkMiddlewareCompatibility, runBeforeExecuteChain, runWithMiddleware, runtimeError } from \"@internal/framework-components/runtime\";\nimport { newMongoCodecRegistry } from \"@internal/mongo-codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\nimport { canonicalStringify } from \"@internal/utils/canonical-stringify\";\nimport { hashContent } from \"@internal/utils/hash-content\";\nimport { isPlainRecord } from \"@internal/contract/is-plain-record\";\nimport { MongoParamRef } from \"@internal/mongo-value\";\n//#region src/mongo-execution-stack.ts\nfunction createMongoExecutionStack(options) {\n\treturn createExecutionStack({\n\t\ttarget: options.target,\n\t\tadapter: options.adapter,\n\t\tdriver: options.driver,\n\t\textensions: options.extensions\n\t});\n}\nfunction createMongoExecutionContext(options) {\n\tconst registry = newMongoCodecRegistry();\n\tconst owners = /* @__PURE__ */ new Map();\n\tconst contributors = [\n\t\toptions.stack.target,\n\t\toptions.stack.adapter,\n\t\t...options.stack.extensions\n\t];\n\tfor (const contributor of contributors) {\n\t\tconst contributed = contributor.codecs();\n\t\tfor (const codec of iterateCodecs(contributed)) {\n\t\t\tconst existingOwner = owners.get(codec.id);\n\t\t\tif (existingOwner !== void 0) throw runtimeError(\"RUNTIME.DUPLICATE_CODEC\", `Duplicate Mongo codec id '${codec.id}' contributed by '${contributor.id}' (already registered by '${existingOwner}').`, {\n\t\t\t\tcodecId: codec.id,\n\t\t\t\texistingOwner,\n\t\t\t\tincomingOwner: contributor.id\n\t\t\t});\n\t\t\tregistry.register(codec);\n\t\t\towners.set(codec.id, contributor.id);\n\t\t}\n\t}\n\treturn Object.freeze({\n\t\tcontract: options.contract,\n\t\tcodecs: registry,\n\t\tstack: options.stack\n\t});\n}\nfunction* iterateCodecs(registry) {\n\tyield* registry.values();\n}\n//#endregion\n//#region src/codecs/decoding.ts\nconst WIRE_PREVIEW_LIMIT = 100;\nfunction previewWireValue(wireValue) {\n\tif (typeof wireValue === \"string\") return wireValue.length > WIRE_PREVIEW_LIMIT ? `${wireValue.substring(0, WIRE_PREVIEW_LIMIT)}...` : wireValue;\n\treturn String(wireValue).substring(0, WIRE_PREVIEW_LIMIT);\n}\n/**\n* Structured envelopes (any error with a dotted `code`, per `isStructuredError`)\n* thrown by a codec body pass through unchanged; everything else is wrapped in\n* a `RUNTIME.DECODE_FAILED` envelope with the original error on `cause`.\n*/\nfunction wrapDecodeFailure(error, collection, path, codecId, wireValue) {\n\tif (isStructuredError(error)) throw error;\n\tconst wrapped = runtimeError(\"RUNTIME.DECODE_FAILED\", `Failed to decode field ${path} in collection '${collection}' with codec '${codecId}': ${error instanceof Error ? error.message : String(error)}`, {\n\t\tcollection,\n\t\tpath,\n\t\tcodec: codecId,\n\t\twirePreview: previewWireValue(wireValue)\n\t});\n\twrapped.cause = error;\n\tthrow wrapped;\n}\nasync function decodeMongoRow(row, shape, registry, collection, ctx = {}) {\n\tif (shape.kind === \"unknown\") return row;\n\tif (typeof row !== \"object\" || row === null) return row;\n\tconst rowObj = row;\n\tconst out = {};\n\tconst tasks = [];\n\tfunction scheduleLeaf(path, codecId, wire, assign) {\n\t\tconst codec = registry.get(codecId);\n\t\tif (!codec) {\n\t\t\tassign(wire);\n\t\t\treturn;\n\t\t}\n\t\ttasks.push((async () => {\n\t\t\ttry {\n\t\t\t\tassign(await codec.decode(wire, ctx));\n\t\t\t} catch (error) {\n\t\t\t\twrapDecodeFailure(error, collection, path, codecId, wire);\n\t\t\t}\n\t\t})());\n\t}\n\tfunction walkField(value, fieldShape, path, assign) {\n\t\tswitch (fieldShape.kind) {\n\t\t\tcase \"unknown\":\n\t\t\t\tassign(value);\n\t\t\t\treturn;\n\t\t\tcase \"leaf\":\n\t\t\t\tif (value === null || value === void 0) {\n\t\t\t\t\tassign(value);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tscheduleLeaf(path, fieldShape.codecId, value, assign);\n\t\t\t\treturn;\n\t\t\tcase \"document\": {\n\t\t\t\tif (value === null || value === void 0) {\n\t\t\t\t\tassign(value);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\t\t\t\tassign(value);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst vObj = value;\n\t\t\t\tconst nested = { ...vObj };\n\t\t\t\tassign(nested);\n\t\t\t\tfor (const [fk, fShape] of Object.entries(fieldShape.fields)) walkField(vObj[fk], fShape, `${path}.${fk}`, (v) => {\n\t\t\t\t\tnested[fk] = v;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"array\": {\n\t\t\t\tif (value === null || value === void 0) {\n\t\t\t\t\tassign(value);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\tassign(value);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst arr = [];\n\t\t\t\tassign(arr);\n\t\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\t\tconst el = value[i];\n\t\t\t\t\twalkField(el, fieldShape.element, `${path}.${i}`, (v) => {\n\t\t\t\t\t\tarr[i] = v;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t/* v8 ignore stop */\n\t}\n\tfor (const [k, fShape] of Object.entries(shape.fields)) walkField(rowObj[k], fShape, k, (v) => {\n\t\tout[k] = v;\n\t});\n\tfor (const k of Object.keys(rowObj)) if (!Object.hasOwn(shape.fields, k)) out[k] = rowObj[k];\n\tawait Promise.all(tasks);\n\treturn out;\n}\n//#endregion\n//#region src/content-hash.ts\n/** @internal */\nconst RUNTIME_CONTENT_HASH_REQUIRES_RESOLVED_COMMAND = \"RUNTIME.CONTENT_HASH_REQUIRES_RESOLVED_COMMAND\";\n/**\n* Resolved wire commands are frozen class instances (`InsertOneWireCommand`, …);\n* pre-resolve `beforeExecute` plans hold a plain-object `MongoLoweredDraft` in the\n* command slot. O(1) prototype check — no tree walk on the hot path.\n*/\nfunction isResolvedMongoWireCommand(command) {\n\tif (command === null || typeof command !== \"object\") return false;\n\tconst proto = Object.getPrototypeOf(command);\n\treturn proto !== null && proto !== Object.prototype;\n}\nfunction assertContentHashOnResolvedCommand(command) {\n\tif (isResolvedMongoWireCommand(command)) return;\n\tthrow runtimeError(RUNTIME_CONTENT_HASH_REQUIRES_RESOLVED_COMMAND, \"contentHash and computeMongoContentHash are only valid on a resolved wire command (after param resolution, e.g. from afterExecute). During beforeExecute, plan.command holds an unresolved MongoLoweredDraft — use params.entries() and the param mutator instead of contentHash or structural reads of plan.command.\", { phase: \"beforeExecute\" });\n}\n/**\n* Computes a stable content hash for a lowered Mongo execution plan.\n*\n* Internally builds an unambiguous canonical-stringified preimage from\n* two components:\n*\n* 1. `meta.storageHash` — discriminates by schema. A migration changes the\n* storage hash, which invalidates cached entries automatically (no\n* per-app invalidation logic needed for schema changes).\n* 2. `exec.command` — the wire command. `canonicalStringify` produces a\n* deterministic serialization that is stable across object key\n* insertion order and that distinguishes types JSON would otherwise\n* conflate (e.g. `BigInt(1)` vs `1`, `Date` vs ISO string, `Buffer`\n* vs number array). The spread converts the frozen wire-command\n* class instance (`InsertOneWireCommand`, `AggregateWireCommand`, …)\n* into a plain object exposing its own enumerable properties\n* (`kind`, `collection`, plus the payload-specific fields like\n* `document`/`filter`/`update`/`pipeline`/…), which is what\n* `canonicalStringify` accepts; class instances are rejected\n* outright to prevent silent collisions.\n*\n* Unlike SQL, there is no separate \"rendered statement\" component because\n* a Mongo `MongoExecutionPlan.command` is the wire command itself —\n* canonicalizing it captures both structure and parameters in one pass.\n*\n* The components are wrapped in an object and canonicalized as a single\n* unit (rather than concatenated with a delimiter) so component\n* boundaries are unambiguous and cannot collide with a different split\n* of the same characters.\n*\n* The canonical string is then piped through `hashContent` to produce a\n* bounded, opaque digest. See `@internal/utils/hash-content` for the\n* rationale.\n*\n* @throws {RuntimeErrorEnvelope} {@link RUNTIME_CONTENT_HASH_REQUIRES_RESOLVED_COMMAND}\n* when `exec.command` is still a pre-resolve draft (plain object), e.g. when\n* `contentHash` is called from `beforeExecute`.\n*\n* @internal\n*/\nfunction computeMongoContentHash(exec) {\n\tassertContentHashOnResolvedCommand(exec.command);\n\treturn hashContent(canonicalStringify({\n\t\tstorageHash: exec.meta.storageHash,\n\t\tcommand: { ...exec.command }\n\t}));\n}\n//#endregion\n//#region src/param-ref-mutator.ts\nfunction* flattenDraftSlot(value) {\n\tif (value instanceof MongoParamRef) {\n\t\tyield value;\n\t\treturn;\n\t}\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) yield* flattenDraftSlot(item);\n\t\treturn;\n\t}\n\tif (isPlainRecord(value)) for (const v of Object.values(value)) yield* flattenDraftSlot(v);\n}\n/**\n* Flat walk over a `MongoLoweredDraft` yielding every `MongoParamRef` leaf\n* regardless of nesting — object values, array elements, filter predicate\n* values, update operator values, and pipeline stage values. Raw command\n* variants carry no `MongoParamRef` nodes so they yield zero entries.\n*\n* **Walk parity:** slot traversal matches `resolveDraftSlot` / `resolveParams`\n* — refs appear only in plain-object and array containers; `Date` and other\n* non-plain objects are leaves (not descended into), so middleware sees every\n* ref the resolve pass will encode.\n*/\nfunction* flattenMongoParamRefs(draft) {\n\tswitch (draft.kind) {\n\t\tcase \"insertOne\":\n\t\tcase \"rawInsertOne\":\n\t\t\tyield* flattenDraftSlot(draft.document);\n\t\t\tbreak;\n\t\tcase \"insertMany\":\n\t\tcase \"rawInsertMany\":\n\t\t\tfor (const doc of draft.documents) yield* flattenDraftSlot(doc);\n\t\t\tbreak;\n\t\tcase \"updateOne\":\n\t\tcase \"updateMany\":\n\t\tcase \"rawUpdateOne\":\n\t\tcase \"rawUpdateMany\":\n\t\t\tyield* flattenDraftSlot(draft.filter);\n\t\t\tyield* flattenDraftSlot(draft.update);\n\t\t\tbreak;\n\t\tcase \"findOneAndUpdate\":\n\t\tcase \"rawFindOneAndUpdate\":\n\t\t\tyield* flattenDraftSlot(draft.filter);\n\t\t\tyield* flattenDraftSlot(draft.update);\n\t\t\tbreak;\n\t\tcase \"deleteOne\":\n\t\tcase \"deleteMany\":\n\t\tcase \"rawDeleteOne\":\n\t\tcase \"rawDeleteMany\":\n\t\t\tyield* flattenDraftSlot(draft.filter);\n\t\t\tbreak;\n\t\tcase \"findOneAndDelete\":\n\t\tcase \"rawFindOneAndDelete\":\n\t\t\tyield* flattenDraftSlot(draft.filter);\n\t\t\tbreak;\n\t\tcase \"aggregate\":\n\t\tcase \"rawAggregate\":\n\t\t\tfor (const stage of draft.pipeline) yield* flattenDraftSlot(stage);\n\t\t\tbreak;\n\t}\n}\nfunction substituteSlot(value, overrides) {\n\tif (value instanceof MongoParamRef) {\n\t\tif (overrides.has(value)) {\n\t\t\tconst opts = {};\n\t\t\tif (value.name !== void 0) opts.name = value.name;\n\t\t\tif (value.codecId !== void 0) opts.codecId = value.codecId;\n\t\t\treturn new MongoParamRef(overrides.get(value), opts);\n\t\t}\n\t\treturn value;\n\t}\n\tif (Array.isArray(value)) return value.map((item) => substituteSlot(item, overrides));\n\tif (isPlainRecord(value)) {\n\t\tconst out = {};\n\t\tfor (const [k, v] of Object.entries(value)) out[k] = substituteSlot(v, overrides);\n\t\treturn out;\n\t}\n\treturn value;\n}\nfunction substituteDoc(doc, overrides) {\n\treturn blindCast(substituteSlot(doc, overrides));\n}\nfunction isUpdatePipeline(update) {\n\treturn Array.isArray(update);\n}\nfunction substituteUpdate(update, overrides) {\n\tif (isUpdatePipeline(update)) return update.map((stage) => substituteDoc(stage, overrides));\n\treturn substituteDoc(update, overrides);\n}\nfunction buildMutatedDraft(draft, overrides) {\n\tswitch (draft.kind) {\n\t\tcase \"insertOne\": return {\n\t\t\tkind: \"insertOne\",\n\t\t\tcollection: draft.collection,\n\t\t\tdocument: substituteDoc(draft.document, overrides)\n\t\t};\n\t\tcase \"rawInsertOne\": return {\n\t\t\tkind: \"rawInsertOne\",\n\t\t\tcollection: draft.collection,\n\t\t\tdocument: substituteDoc(draft.document, overrides)\n\t\t};\n\t\tcase \"insertMany\": return {\n\t\t\tkind: \"insertMany\",\n\t\t\tcollection: draft.collection,\n\t\t\tdocuments: draft.documents.map((d) => substituteDoc(d, overrides))\n\t\t};\n\t\tcase \"rawInsertMany\": return {\n\t\t\tkind: \"rawInsertMany\",\n\t\t\tcollection: draft.collection,\n\t\t\tdocuments: draft.documents.map((d) => substituteDoc(d, overrides))\n\t\t};\n\t\tcase \"updateOne\": return {\n\t\t\tkind: \"updateOne\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tupdate: substituteUpdate(draft.update, overrides),\n\t\t\tupsert: draft.upsert\n\t\t};\n\t\tcase \"updateMany\": return {\n\t\t\tkind: \"updateMany\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tupdate: substituteUpdate(draft.update, overrides),\n\t\t\tupsert: draft.upsert\n\t\t};\n\t\tcase \"rawUpdateOne\": return {\n\t\t\tkind: \"rawUpdateOne\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tupdate: substituteUpdate(draft.update, overrides)\n\t\t};\n\t\tcase \"rawUpdateMany\": return {\n\t\t\tkind: \"rawUpdateMany\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tupdate: substituteUpdate(draft.update, overrides)\n\t\t};\n\t\tcase \"deleteOne\": return {\n\t\t\tkind: \"deleteOne\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides)\n\t\t};\n\t\tcase \"deleteMany\": return {\n\t\t\tkind: \"deleteMany\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides)\n\t\t};\n\t\tcase \"rawDeleteOne\": return {\n\t\t\tkind: \"rawDeleteOne\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides)\n\t\t};\n\t\tcase \"rawDeleteMany\": return {\n\t\t\tkind: \"rawDeleteMany\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides)\n\t\t};\n\t\tcase \"findOneAndUpdate\": return {\n\t\t\tkind: \"findOneAndUpdate\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tupdate: substituteUpdate(draft.update, overrides),\n\t\t\tupsert: draft.upsert,\n\t\t\tsort: draft.sort,\n\t\t\treturnDocument: draft.returnDocument\n\t\t};\n\t\tcase \"rawFindOneAndUpdate\": return {\n\t\t\tkind: \"rawFindOneAndUpdate\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tupdate: substituteUpdate(draft.update, overrides),\n\t\t\tupsert: draft.upsert,\n\t\t\tsort: draft.sort,\n\t\t\treturnDocument: draft.returnDocument\n\t\t};\n\t\tcase \"findOneAndDelete\": return {\n\t\t\tkind: \"findOneAndDelete\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tsort: draft.sort\n\t\t};\n\t\tcase \"rawFindOneAndDelete\": return {\n\t\t\tkind: \"rawFindOneAndDelete\",\n\t\t\tcollection: draft.collection,\n\t\t\tfilter: substituteDoc(draft.filter, overrides),\n\t\t\tsort: draft.sort\n\t\t};\n\t\tcase \"aggregate\": return {\n\t\t\tkind: \"aggregate\",\n\t\t\tcollection: draft.collection,\n\t\t\tpipeline: draft.pipeline.map((s) => substituteDoc(s, overrides))\n\t\t};\n\t\tcase \"rawAggregate\": return {\n\t\t\tkind: \"rawAggregate\",\n\t\t\tcollection: draft.collection,\n\t\t\tpipeline: draft.pipeline.map((s) => substituteDoc(s, overrides))\n\t\t};\n\t}\n}\n/**\n* Build a {@link MongoParamRefMutatorInternal} for the given lowered draft.\n*\n* The mutator captures the draft by reference and uses `flattenMongoParamRefs`\n* on demand to produce `entries()`. Replacements are stored in a lazily-\n* allocated `Map`; the fast path (no replacements) preserves bit-for-bit\n* reference identity to the original draft in `currentDraft()`.\n*/\nfunction createMongoParamRefMutator(draft) {\n\tconst originalDraft = draft;\n\tlet overrides;\n\tconst ensureOverrides = () => {\n\t\tif (!overrides) overrides = /* @__PURE__ */ new Map();\n\t\treturn overrides;\n\t};\n\tfunction* entries() {\n\t\tfor (const ref of flattenMongoParamRefs(originalDraft)) yield blindCast({\n\t\t\tref: blindCast(ref),\n\t\t\tvalue: overrides?.has(ref) ? overrides.get(ref) : ref.value,\n\t\t\tcodecId: ref.codecId\n\t\t});\n\t}\n\tfunction replaceValue(handle, newValue) {\n\t\tensureOverrides().set(blindCast(handle), newValue);\n\t}\n\tfunction replaceValues(updates) {\n\t\tconst map = ensureOverrides();\n\t\tfor (const { ref, newValue } of updates) map.set(blindCast(ref), newValue);\n\t}\n\treturn {\n\t\tentries,\n\t\treplaceValue: blindCast(replaceValue),\n\t\treplaceValues,\n\t\tcurrentDraft() {\n\t\t\tif (!overrides || overrides.size === 0) return originalDraft;\n\t\t\treturn buildMutatedDraft(originalDraft, overrides);\n\t\t}\n\t};\n}\n//#endregion\n//#region src/mongo-runtime.ts\nfunction noop() {}\nvar MongoRuntimeImpl = class extends RuntimeCore {\n\t#adapter;\n\t#driver;\n\t#codecs;\n\tconstructor(options) {\n\t\tconst middleware = options.middleware ? [...options.middleware] : [];\n\t\tconst targetId = options.context.stack.target.targetId;\n\t\tfor (const mw of middleware) checkMiddlewareCompatibility(mw, \"mongo\", targetId);\n\t\tconst ctx = {\n\t\t\tcontract: options.context.contract,\n\t\t\tmode: options.mode ?? \"strict\",\n\t\t\tnow: () => Date.now(),\n\t\t\tlog: {\n\t\t\t\tinfo: noop,\n\t\t\t\twarn: noop,\n\t\t\t\terror: noop\n\t\t\t},\n\t\t\tcontentHash: (exec) => computeMongoContentHash(blindCast(exec)),\n\t\t\tscope: \"runtime\",\n\t\t\tplanExecutionId: \"\"\n\t\t};\n\t\tsuper({\n\t\t\tmiddleware,\n\t\t\tctx\n\t\t});\n\t\tconst adapterInstance = options.context.stack.adapter.create(options.context.stack);\n\t\tthis.#adapter = adapterInstance;\n\t\tthis.#driver = options.driver;\n\t\tthis.#codecs = options.context.codecs;\n\t}\n\t/* v8 ignore start -- one-phase lower satisfies RuntimeCore; execute uses structuralLower + resolveParams */\n\tasync lower(plan, ctx) {\n\t\treturn {\n\t\t\tcommand: await this.#adapter.lower(plan, ctx),\n\t\t\tmeta: plan.meta,\n\t\t\t...ifDefined(\"resultShape\", plan.resultShape)\n\t\t};\n\t}\n\t/* v8 ignore stop */\n\trunDriver(exec) {\n\t\treturn this.#driver.execute(exec.command);\n\t}\n\texecute(plan, options) {\n\t\tconst self = this;\n\t\tconst signal = options?.signal;\n\t\tconst codecCtx = signal === void 0 ? {} : { signal };\n\t\tconst execCtx = {\n\t\t\t...self.ctx,\n\t\t\tplanExecutionId: crypto.randomUUID()\n\t\t};\n\t\tconst generator = async function* () {\n\t\t\tcheckAborted(codecCtx, \"stream\");\n\t\t\tconst compiled = await self.runBeforeCompile(plan);\n\t\t\tconst draft = self.#adapter.structuralLower(compiled);\n\t\t\tconst mutator = createMongoParamRefMutator(draft);\n\t\t\tawait runBeforeExecuteChain({\n\t\t\t\tmeta: compiled.meta,\n\t\t\t\t...ifDefined(\"resultShape\", compiled.resultShape),\n\t\t\t\tcommand: blindCast(draft)\n\t\t\t}, self.middleware, execCtx, mutator);\n\t\t\tconst resolvedCommand = await self.#adapter.resolveParams(mutator.currentDraft(), codecCtx);\n\t\t\tconst exec = {\n\t\t\t\tmeta: compiled.meta,\n\t\t\t\t...ifDefined(\"resultShape\", compiled.resultShape),\n\t\t\t\tcommand: resolvedCommand\n\t\t\t};\n\t\t\tconst stream = runWithMiddleware(exec, self.middleware, execCtx, () => self.runDriver(exec));\n\t\t\tfor await (const rawRow of stream) if (exec.resultShape === void 0) yield blindCast(rawRow);\n\t\t\telse yield blindCast(await decodeMongoRow(rawRow, exec.resultShape, self.#codecs, exec.command.collection, codecCtx));\n\t\t};\n\t\treturn new AsyncIterableResult(generator());\n\t}\n\tasync close() {\n\t\tawait this.#driver.close();\n\t}\n};\nfunction createMongoRuntime(options) {\n\treturn new MongoRuntimeImpl(options);\n}\n//#endregion\nexport { createMongoExecutionContext, createMongoExecutionStack, createMongoParamRefMutator, createMongoRuntime, flattenMongoParamRefs };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,0BAA0B,SAAS;CAC3C,OAAO,qBAAqB;EAC3B,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB,QAAQ,QAAQ;EAChB,YAAY,QAAQ;CACrB,CAAC;AACF;AACA,SAAS,4BAA4B,SAAS;CAC7C,MAAM,WAAW,sBAAsB;CACvC,MAAM,yBAAyB,IAAI,IAAI;CACvC,MAAM,eAAe;EACpB,QAAQ,MAAM;EACd,QAAQ,MAAM;EACd,GAAG,QAAQ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ACf,GAAG,UAAU,eAAe,SAAS,WAAW;IAChD,SAAS;GACV;GACA,MAAM,SAAS,kBAAkB,MAAM,KAAK,YAAY,eAAe,KAAK,UAAU,IAAI,CAAC;GAC3F,WAAW,MAAM,UAAU,QAAQ,IAAI,KAAK,gBAAgB,KAAK,GAAG,MAAM,UAAU,MAAM;QACrF,MAAM,UAAU,MAAM,eAAe,QAAQ,KAAK,aAAa,KAAKE,SAAS,KAAK,QAAQ,YAAY,QAAQ,CAAC;EACrH;EACA,OAAO,IAAI,oBAAoB,UAAU,CAAC;CAC3C;CACA,MAAM,QAAQ;EACb,MAAM,KAAKD,QAAQ,MAAM;CAC1B;AACD;AACA,SAAS,mBAAmB,SAAS;CACpC,OAAO,IAAI,iBAAiB,OAAO;AACpC"}
@@ -0,0 +1,2 @@
1
+ import { a as MongoSchemaCollectionOptionsInput, c as MongoSchemaIndex, d as MongoSchemaValidatorOptions, f as MongoSchemaVisitor, h as indexesEquivalent, i as MongoSchemaCollectionOptions, l as MongoSchemaIndexOptions, m as deepEqual, n as MongoSchemaCollection, o as MongoSchemaIR, p as canonicalize, r as MongoSchemaCollectionCtorOptions, s as MongoSchemaIRNode, t as AnyMongoSchemaNode, u as MongoSchemaValidator } from "./index-DxoO-ywI.mjs";
2
+ export { type AnyMongoSchemaNode, MongoSchemaCollection, type MongoSchemaCollectionCtorOptions, MongoSchemaCollectionOptions, type MongoSchemaCollectionOptionsInput, MongoSchemaIR, MongoSchemaIRNode, MongoSchemaIndex, type MongoSchemaIndexOptions, MongoSchemaValidator, type MongoSchemaValidatorOptions, type MongoSchemaVisitor, canonicalize, deepEqual, indexesEquivalent };
@@ -0,0 +1,2 @@
1
+ import { a as MongoSchemaIndex, c as deepEqual, i as MongoSchemaIRNode, l as indexesEquivalent, n as MongoSchemaCollectionOptions, o as MongoSchemaValidator, r as MongoSchemaIR, s as canonicalize, t as MongoSchemaCollection } from "./exports-Bx-hlnZ3.mjs";
2
+ export { MongoSchemaCollection, MongoSchemaCollectionOptions, MongoSchemaIR, MongoSchemaIRNode, MongoSchemaIndex, MongoSchemaValidator, canonicalize, deepEqual, indexesEquivalent };
@@ -0,0 +1,23 @@
1
+ import { C as MongoContract } from "./mongo-value-set-tNn9-pun-dJYx_rVD.mjs";
2
+ import "./index-Cd2zLiU6.mjs";
3
+ import { o as MongoSchemaIR } from "./index-DxoO-ywI.mjs";
4
+ import { OperationContext, VerifyDatabaseSchemaResult } from "@prisma/orm-framework/components/control";
5
+ import { TargetBoundComponentDescriptor } from "@prisma/orm-framework/components/components";
6
+ //#region ../../../2-mongo-family/9-family/dist/schema-verify.d.mts
7
+ //#region src/core/schema-verify/verify-mongo-schema.d.ts
8
+ interface VerifyMongoSchemaOptions {
9
+ readonly contract: MongoContract;
10
+ readonly schema: MongoSchemaIR;
11
+ readonly strict: boolean;
12
+ readonly context?: OperationContext;
13
+ /**
14
+ * Active framework components participating in this composition. Mongo
15
+ * verification does not currently consult them, but the parameter exists
16
+ * for parity with the SQL family verify so callers can pass the same envelope.
17
+ */
18
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'mongo', string>>;
19
+ }
20
+ declare function verifyMongoSchema(options: VerifyMongoSchemaOptions): VerifyDatabaseSchemaResult;
21
+ //#endregion
22
+ export { verifyMongoSchema as n, VerifyMongoSchemaOptions as t };
23
+ //# sourceMappingURL=schema-verify-DJGr28XW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-verify-DJGr28XW.d.mts","names":[],"sources":["../../../../2-mongo-family/9-family/dist/schema-verify.d.mts"],"mappings":";;;;;;;UAKU;WACC,UAAU;WACV,QAAQ;WACR;WACA,UAAU;;;;;;WAMV,qBAAqB,cAAc;;iBAE7B,kBAAkB,SAAS,2BAA2B"}
@@ -0,0 +1,2 @@
1
+ import { a as MongoExpr, c as MongoValue, i as MongoDocument, l as RawPipeline, n as LiteralValue, o as MongoParamRef, r as MongoArray, s as MongoUpdateDocument, t as Document } from "./index-wKMm41HC.mjs";
2
+ export { type Document, type LiteralValue, type MongoArray, type MongoDocument, type MongoExpr, MongoParamRef, type MongoUpdateDocument, type MongoValue, type RawPipeline };
package/dist/value.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { t as MongoParamRef } from "./dist-C7Ykq48Q.mjs";
2
+ export { MongoParamRef };
@@ -0,0 +1,2 @@
1
+ import { i as IndexSpecification, n as CreateCollectionOptions, r as CreateIndexesOptions, t as CollationOptions } from "./mongodb-types-B4HmhF1S.mjs";
2
+ export type { CollationOptions, CreateCollectionOptions, CreateIndexesOptions, IndexSpecification };
@@ -0,0 +1 @@
1
+ export {};