@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 @@
1
+ {"version":3,"file":"dist-Dyp05u64.mjs","names":["#contract","#state","#withStage","#writeTerminal","#writeMeta","#ctx","#modelName","#filters","#foldedFilter"],"sources":["../../../../2-mongo-family/5-query-builders/query-builder/dist/index.mjs"],"sourcesContent":["import { i as ormError, n as expr, r as resolveUpdaterResult, t as createFieldAccessor } from \"./field-accessor-0oUt6RZC.mjs\";\nimport { AggregateCommand, DeleteManyCommand, DeleteOneCommand, FindOneAndDeleteCommand, FindOneAndUpdateCommand, InsertManyCommand, InsertOneCommand, MongoAddFieldsStage, MongoAggAccumulator, MongoAggCond, MongoAggFieldRef, MongoAggLiteral, MongoAggOperator, MongoAndExpr, MongoBucketAutoStage, MongoBucketStage, MongoCountStage, MongoDensifyStage, MongoExistsExpr, MongoFacetStage, MongoFillStage, MongoGeoNearStage, MongoGraphLookupStage, MongoGroupStage, MongoLimitStage, MongoLookupStage, MongoMatchStage, MongoMergeStage, MongoOutStage, MongoProjectStage, MongoRedactStage, MongoReplaceRootStage, MongoSampleStage, MongoSearchMetaStage, MongoSearchStage, MongoSetWindowFieldsStage, MongoSkipStage, MongoSortByCountStage, MongoSortStage, MongoUnionWithStage, MongoUnwindStage, MongoVectorSearchStage, UpdateManyCommand, UpdateOneCommand, freezeMongoFieldShape, freezeMongoResultShape } from \"@internal/mongo-query-ast/execution\";\nimport { domainModelsAtDefaultNamespace } from \"@internal/contract/types\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/accumulator-helpers.ts\nfunction namedAccumulatorArgs(args) {\n\tconst result = {};\n\tfor (const [key, val] of Object.entries(args)) if (val !== void 0) result[key] = val.node;\n\treturn result;\n}\nconst acc = {\n\tsum(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.sum(expr.node)\n\t\t};\n\t},\n\tavg(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.avg(expr.node)\n\t\t};\n\t},\n\tmin(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.min(expr.node)\n\t\t};\n\t},\n\tmax(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.max(expr.node)\n\t\t};\n\t},\n\tfirst(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.first(expr.node)\n\t\t};\n\t},\n\tlast(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.last(expr.node)\n\t\t};\n\t},\n\tpush(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.push(expr.node)\n\t\t};\n\t},\n\taddToSet(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.addToSet(expr.node)\n\t\t};\n\t},\n\tcount() {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.count()\n\t\t};\n\t},\n\tstdDevPop(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.stdDevPop(expr.node)\n\t\t};\n\t},\n\tstdDevSamp(expr) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.stdDevSamp(expr.node)\n\t\t};\n\t},\n\tfirstN(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$firstN\", namedAccumulatorArgs(args))\n\t\t};\n\t},\n\tlastN(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$lastN\", namedAccumulatorArgs(args))\n\t\t};\n\t},\n\tmaxN(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$maxN\", namedAccumulatorArgs(args))\n\t\t};\n\t},\n\tminN(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$minN\", namedAccumulatorArgs(args))\n\t\t};\n\t},\n\ttop(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$top\", {\n\t\t\t\toutput: args.output.node,\n\t\t\t\tsortBy: MongoAggLiteral.of(args.sortBy)\n\t\t\t})\n\t\t};\n\t},\n\tbottom(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$bottom\", {\n\t\t\t\toutput: args.output.node,\n\t\t\t\tsortBy: MongoAggLiteral.of(args.sortBy)\n\t\t\t})\n\t\t};\n\t},\n\ttopN(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$topN\", {\n\t\t\t\toutput: args.output.node,\n\t\t\t\tsortBy: MongoAggLiteral.of(args.sortBy),\n\t\t\t\tn: args.n.node\n\t\t\t})\n\t\t};\n\t},\n\tbottomN(args) {\n\t\treturn {\n\t\t\t_field: void 0,\n\t\t\tnode: MongoAggAccumulator.of(\"$bottomN\", {\n\t\t\t\toutput: args.output.node,\n\t\t\t\tsortBy: MongoAggLiteral.of(args.sortBy),\n\t\t\t\tn: args.n.node\n\t\t\t})\n\t\t};\n\t}\n};\n//#endregion\n//#region src/lookup-builder.ts\n/**\n* Construct the `from` callable for `PipelineChain.lookup`. The contract\n* is captured so `from(name)` can resolve `roots[name]` to the foreign\n* model name at runtime, look up the foreign collection name from\n* `models[modelName].storage.collection`, and assemble a `LookupResult`\n* for the outer `lookup` to consume.\n*\n* The `Shape`/`Nested` generics are erased at runtime — they exist only\n* to type the local accessor inside the user's `on(...)` callback. The\n* contract value at runtime carries the real model lookup table.\n*/\nfunction createLookupFrom(contract) {\n\tconst callable = ((rootName) => {\n\t\tconst modelName = contract.roots[rootName]?.model;\n\t\tif (!modelName) throw ormError(\"ORM.MODEL_UNKNOWN\", `lookup() unknown root: \"${rootName}\". Valid roots: ${Object.keys(contract.roots).join(\", \")}`);\n\t\treturn createLookupBuilder({\n\t\t\trootName,\n\t\t\tmodelName,\n\t\t\tforeignCollection: domainModelsAtDefaultNamespace(contract.domain)[modelName]?.storage?.collection ?? rootName\n\t\t});\n\t});\n\treturn callable;\n}\nfunction createLookupBuilder(state) {\n\treturn { on(cb) {\n\t\tconst result = cb(createFieldAccessor(), createFieldAccessor());\n\t\tassertLeafExpression(result.local, \"local\");\n\t\tassertLeafExpression(result.foreign, \"foreign\");\n\t\treturn createLookupBuilderWithKey({\n\t\t\t...state,\n\t\t\tlocalField: result.local._path,\n\t\t\tforeignField: result.foreign._path\n\t\t});\n\t} };\n}\nfunction createLookupBuilderWithKey(state) {\n\treturn { as(name) {\n\t\treturn {\n\t\t\t_brand: \"mongo-query-builder/lookup-result@1\",\n\t\t\t_root: state.rootName,\n\t\t\t_model: state.modelName,\n\t\t\t_localField: state.localField,\n\t\t\t_foreignField: state.foreignField,\n\t\t\t_as: name\n\t\t};\n\t} };\n}\n/**\n* Defensive runtime guard catching the case where a user returns a\n* non-`LeafExpression` from the `on(...)` callback (e.g. by casting\n* around the type system, or threading a value in from outside the\n* callback). Compile-time gating via `LookupOnResult`'s `LeafExpression`\n* type already rejects `fn.<op>(…)` returns at the type level — this\n* guard is the runtime backstop matching the defensive style of\n* `deconstructFindAndModifyChain` in builder.ts.\n*/\nfunction assertLeafExpression(value, side) {\n\tif (!value || typeof value._path !== \"string\" || value._path.length === 0) throw ormError(\"ORM.ARGUMENT_INVALID\", `lookup().on() ${side} side must return a leaf field reference (e.g. \\`${side}.<field>\\`). Aggregation expressions and computed values are not supported.`);\n}\n/**\n* Extract the runtime metadata from a `LookupResult` for `PipelineChain\n* .lookup` to construct the `MongoLookupStage`. The internal fields are\n* intentionally underscore-prefixed and brand-checked here so user code\n* cannot synthesise a fake spec; this is the single ingress point.\n*/\nfunction extractLookupResult(result, contract) {\n\tif (result?._brand !== \"mongo-query-builder/lookup-result@1\") throw ormError(\"ORM.ARGUMENT_INVALID\", \"lookup() callback must return the result of `from(name).on(cb).as(name)`. Returning a hand-rolled options object is not supported.\");\n\treturn {\n\t\tforeignCollection: domainModelsAtDefaultNamespace(contract.domain)[result._model]?.storage?.collection ?? result._root,\n\t\tlocalField: result._localField,\n\t\tforeignField: result._foreignField,\n\t\tas: result._as,\n\t\tmodelName: result._model\n\t};\n}\n//#endregion\n//#region src/pipeline-result-shape.ts\nconst identityStageKinds = /* @__PURE__ */ new Set([\n\t\"match\",\n\t\"sort\",\n\t\"limit\",\n\t\"skip\",\n\t\"sample\",\n\t\"vectorSearch\"\n]);\nconst unknownShape = { kind: \"unknown\" };\nfunction fieldShapeAtPath(shape, path) {\n\tif (shape.kind !== \"document\" || path.includes(\".\")) return unknownShape;\n\treturn shape.fields[path] ?? unknownShape;\n}\nfunction shapeForExpr(currentShape, expr) {\n\tif (expr instanceof MongoAggFieldRef) return fieldShapeAtPath(currentShape, expr.path);\n\treturn unknownShape;\n}\nfunction resultShapeAfterProject(currentShape, stage) {\n\tif (currentShape.kind !== \"document\") return { kind: \"unknown\" };\n\tconst fields = {};\n\tfor (const [key, value] of Object.entries(stage.projection)) {\n\t\tif (value === 0) continue;\n\t\tif (value === 1) {\n\t\t\tfields[key] = currentShape.fields[key] ?? unknownShape;\n\t\t\tcontinue;\n\t\t}\n\t\tfields[key] = shapeForExpr(currentShape, value);\n\t}\n\tif (!Object.hasOwn(stage.projection, \"_id\") && currentShape.fields[\"_id\"]) fields[\"_id\"] = currentShape.fields[\"_id\"];\n\treturn freezeMongoResultShape({\n\t\tkind: \"document\",\n\t\tfields\n\t});\n}\nfunction resultShapeAfterAddFields(currentShape, stage) {\n\tif (currentShape.kind !== \"document\") return { kind: \"unknown\" };\n\tconst fields = { ...currentShape.fields };\n\tfor (const [key, expr] of Object.entries(stage.fields)) fields[key] = shapeForExpr(currentShape, expr);\n\treturn freezeMongoResultShape({\n\t\tkind: \"document\",\n\t\tfields\n\t});\n}\nfunction computePipelineResultShape(stages, startShape) {\n\tlet shape = startShape;\n\tfor (const stage of stages) {\n\t\tif (shape.kind === \"unknown\") return { kind: \"unknown\" };\n\t\tif (identityStageKinds.has(stage.kind)) continue;\n\t\tif (stage instanceof MongoProjectStage) {\n\t\t\tshape = resultShapeAfterProject(shape, stage);\n\t\t\tcontinue;\n\t\t}\n\t\tif (stage instanceof MongoAddFieldsStage) {\n\t\t\tshape = resultShapeAfterAddFields(shape, stage);\n\t\t\tcontinue;\n\t\t}\n\t\treturn { kind: \"unknown\" };\n\t}\n\treturn shape;\n}\n//#endregion\n//#region src/result-shape.ts\nfunction contractFieldToMongoFieldShape(field) {\n\tconst { type, nullable, many } = field;\n\tif (type.kind === \"valueObject\" || type.kind === \"union\") return Object.freeze({ kind: \"unknown\" });\n\tif (type.kind !== \"scalar\") return Object.freeze({ kind: \"unknown\" });\n\tif (field.dict === true) return Object.freeze({ kind: \"unknown\" });\n\tif (many === true) return freezeMongoFieldShape({\n\t\tkind: \"array\",\n\t\tnullable,\n\t\telement: {\n\t\t\tkind: \"leaf\",\n\t\t\tcodecId: type.codecId,\n\t\t\tnullable: false\n\t\t}\n\t});\n\treturn freezeMongoFieldShape({\n\t\tkind: \"leaf\",\n\t\tcodecId: type.codecId,\n\t\tnullable\n\t});\n}\nfunction contractModelToMongoResultShape(model, options) {\n\tconst fields = {};\n\tfor (const rel of options?.includeRelationNames ?? []) fields[rel] = Object.freeze({ kind: \"unknown\" });\n\tconst modelFields = model.fields;\n\tconst keys = options?.selection !== void 0 ? options.selection : Object.keys(modelFields);\n\tfor (const key of keys) {\n\t\tif (Object.hasOwn(fields, key)) continue;\n\t\tconst cf = modelFields[key];\n\t\tif (!cf) {\n\t\t\tfields[key] = Object.freeze({ kind: \"unknown\" });\n\t\t\tcontinue;\n\t\t}\n\t\tfields[key] = contractFieldToMongoFieldShape(cf);\n\t}\n\treturn freezeMongoResultShape({\n\t\tkind: \"document\",\n\t\tfields\n\t});\n}\n//#endregion\n//#region src/builder.ts\n/**\n* The pipeline state in the query-builder state machine.\n*\n* Reached from `CollectionHandle` or `FilteredCollection` after the first\n* pipeline-stage method call (or directly via `aggregate()` shortcuts). Holds\n* the accumulated `MongoPipelineStage[]` and exposes pipeline-stage methods,\n* the `merge`/`out` write terminals, and the `build`/`aggregate` read\n* terminals.\n*\n* Two phantom type parameters gate the conditional terminals:\n*\n* - `U extends UpdateEnabled` — when `'update-ok'`, the no-arg `updateMany()` /\n* `updateOne()` form is available (consume the chain as an\n* update-with-pipeline spec). Cleared by stages that produce content the\n* `update` AST cannot represent (e.g. `$group`, `$lookup`, `$limit`).\n* - `F extends FindAndModifyEnabled` — when `'fam-ok'`, the\n* `findOneAndUpdate(...)` / `findOneAndDelete(...)` terminals are\n* available. Cleared by stages incompatible with their wire-command slots\n* (`$limit`, `$group`, mutating stages, …).\n*\n* The marker semantics are encoded in the per-method return types — see the\n* marker table (and rationale per row) in\n* `docs/architecture docs/adrs/ADR 201 - State-machine pattern for typed DSL builders.md`.\n*/\nvar PipelineChain = class PipelineChain {\n\t#contract;\n\t#state;\n\tconstructor(contract, state) {\n\t\tthis.#contract = contract;\n\t\tthis.#state = state;\n\t}\n\t/**\n\t* Internal helper that appends a pipeline stage and branches into a new\n\t* state-type. The fifth type parameter `NewN` carries the nested-path\n\t* shape forward. It defaults to `Record<string, never>` so stages that\n\t* fundamentally rewrite the document (`$group`, `$project`,\n\t* `$replaceRoot`, …) automatically disable the callable form of\n\t* `FieldAccessor` downstream. Additive stages (`match`, `addFields`,\n\t* `sort`, `lookup`, …) explicitly re-thread the current `N`.\n\t*/\n\t#withStage(stage) {\n\t\treturn new PipelineChain(this.#contract, {\n\t\t\t...this.#state,\n\t\t\tstages: [...this.#state.stages, stage]\n\t\t});\n\t}\n\t#writeMeta() {\n\t\treturn {\n\t\t\ttarget: \"mongo\",\n\t\t\tstorageHash: this.#state.storageHash,\n\t\t\tlane: \"mongo-query\"\n\t\t};\n\t}\n\tmatch(filterOrFn) {\n\t\tconst filter = typeof filterOrFn === \"function\" ? filterOrFn(createFieldAccessor()) : filterOrFn;\n\t\treturn this.#withStage(new MongoMatchStage(filter));\n\t}\n\t/**\n\t* `$sort`. Clears `UpdateEnabled` (`update` has no per-document sort) but\n\t* preserves `FindAndModifyEnabled` (`findAndModify` has a `sort` slot).\n\t*/\n\tsort(spec) {\n\t\treturn this.#withStage(new MongoSortStage(spec));\n\t}\n\t/**\n\t* `$limit`. Clears both markers — `limit` is incompatible with the `update`\n\t* wire command, and `findAndModify` already implies single-document\n\t* semantics (so `.limit(...)` adds no meaning, only ambiguity).\n\t*/\n\tlimit(n) {\n\t\treturn this.#withStage(new MongoLimitStage(n));\n\t}\n\t/**\n\t* `$skip`. Clears both markers — MongoDB's `findAndModify` wire command\n\t* has no `skip` slot, so `deconstructFindAndModifyChain` rejects any\n\t* `$skip` at runtime; keeping the marker `fam-cleared` makes the type\n\t* system reflect the same constraint (see ADR 201 marker table).\n\t*/\n\tskip(n) {\n\t\treturn this.#withStage(new MongoSkipStage(n));\n\t}\n\tsample(n) {\n\t\treturn this.#withStage(new MongoSampleStage(n));\n\t}\n\t/**\n\t* `$addFields`. Preserves `UpdateEnabled` (representable as\n\t* update-with-pipeline `$set`); clears `FindAndModifyEnabled` (no analogue\n\t* in the find-and-modify wire commands). The nested-path shape `N` is\n\t* preserved — newly added flat fields are reachable via property access\n\t* (`f.newField`) but do not themselves carry nested structure.\n\t*/\n\taddFields(fn) {\n\t\tconst newFields = fn(createFieldAccessor());\n\t\tconst exprRecord = {};\n\t\tfor (const [key, typed] of Object.entries(newFields)) exprRecord[key] = typed.node;\n\t\treturn this.#withStage(new MongoAddFieldsStage(exprRecord));\n\t}\n\t/**\n\t* `$lookup`. Clears both markers — joins are not representable in either\n\t* the `update` or `findAndModify` wire commands. The original document's\n\t* nested-path shape `N` is preserved (the lookup adds a sidecar array\n\t* field; existing keys are untouched).\n\t*\n\t* The single callback receives a `from` callable that grounds the\n\t* foreign-root literal sequentially before the inner `on(...)`\n\t* callback is type-checked — see `lookup-builder.ts`. The resulting\n\t* `Shape` gains the `As` key as a `ModelArrayField<ModelName>` so\n\t* `ResolveRow` produces `Array<ForeignRow>` (with concrete leaf\n\t* types) instead of the legacy `unknown[]`.\n\t*/\n\tlookup(fn) {\n\t\tconst extracted = extractLookupResult(fn(createLookupFrom(this.#contract)), this.#contract);\n\t\treturn this.#withStage(new MongoLookupStage({\n\t\t\tfrom: extracted.foreignCollection,\n\t\t\tlocalField: extracted.localField,\n\t\t\tforeignField: extracted.foreignField,\n\t\t\tas: extracted.as\n\t\t}));\n\t}\n\tproject(...args) {\n\t\tif (args.length === 1 && typeof args[0] === \"function\") {\n\t\t\tconst fn = args[0];\n\t\t\tconst spec = fn(createFieldAccessor());\n\t\t\tconst projection = {};\n\t\t\tfor (const [key, val] of Object.entries(spec)) projection[key] = val === 1 ? 1 : val.node;\n\t\t\treturn this.#withStage(new MongoProjectStage(projection));\n\t\t}\n\t\tconst keys = args;\n\t\tconst projection = {};\n\t\tfor (const key of keys) projection[key] = 1;\n\t\treturn this.#withStage(new MongoProjectStage(projection));\n\t}\n\t/**\n\t* `$unwind`. Clears both markers — array unrolling produces multiple output\n\t* documents per input, incompatible with both single-document update and\n\t* find-and-modify wire commands. The original `N` is preserved: unwind\n\t* replaces the unwound array slot with its element but leaves the rest\n\t* of the document structurally intact.\n\t*/\n\tunwind(field, options) {\n\t\treturn this.#withStage(new MongoUnwindStage(`$${field}`, options?.preserveNullAndEmptyArrays ?? false));\n\t}\n\t/**\n\t* `$group`. Clears both markers — group output bears no relation to source\n\t* documents; neither `update` nor `findAndModify` can consume it. Nested\n\t* path shape is reset (the source document's path tree is gone).\n\t*/\n\tgroup(fn) {\n\t\tconst { _id: groupIdExpr, ...rest } = fn(createFieldAccessor());\n\t\tconst groupId = groupIdExpr === null ? null : groupIdExpr.node;\n\t\tconst accumulators = {};\n\t\tfor (const [key, typed] of Object.entries(rest)) {\n\t\t\tif (typed === null) throw ormError(\"ORM.ARGUMENT_INVALID\", `group() field \"${key}\" must not be null. Only _id can be null.`);\n\t\t\tif (typed.node.kind !== \"accumulator\") throw ormError(\"ORM.ARGUMENT_INVALID\", `group() field \"${key}\" must use an accumulator (e.g. acc.sum(), acc.count()). Got \"${typed.node.kind}\" expression.`);\n\t\t\taccumulators[key] = typed.node;\n\t\t}\n\t\treturn this.#withStage(new MongoGroupStage(groupId, accumulators));\n\t}\n\t/**\n\t* `$replaceRoot`. Preserves `UpdateEnabled` (representable as\n\t* update-with-pipeline `$replaceRoot`); clears `FindAndModifyEnabled`.\n\t* Nested path shape is reset — the replaced root has no relation to\n\t* the original document structure.\n\t*/\n\treplaceRoot(fn) {\n\t\tconst expr = fn(createFieldAccessor());\n\t\treturn this.#withStage(new MongoReplaceRootStage(expr.node));\n\t}\n\tcount(field) {\n\t\treturn this.#withStage(new MongoCountStage(field));\n\t}\n\tsortByCount(fn) {\n\t\tconst expr = fn(createFieldAccessor());\n\t\treturn this.#withStage(new MongoSortByCountStage(expr.node));\n\t}\n\t/**\n\t* `$redact`. Preserves `UpdateEnabled`; clears `FindAndModifyEnabled`.\n\t* Shape- and nested-path-preserving (the document tree is unchanged).\n\t*/\n\tredact(fn) {\n\t\tconst expr = fn(createFieldAccessor());\n\t\treturn this.#withStage(new MongoRedactStage(expr.node));\n\t}\n\t/**\n\t* `$out` write terminal. Materialises the pipeline output into\n\t* `collection` (optionally in `db`), replacing any prior contents. Unlike\n\t* the other pipeline-stage methods, this **terminates** the chain — it\n\t* returns a `MongoQueryPlan` rather than another `PipelineChain`, since\n\t* `$out` must be the final stage and there is nothing further to chain.\n\t*\n\t* Lane is `mongo-query` (matching all other terminals in this package) so\n\t* middleware can dispatch on intent without inspecting the command.\n\t*\n\t* The result row stream is empty (`unknown` row type) — the data lives\n\t* in the destination collection, not the response.\n\t*/\n\tout(collection, db) {\n\t\treturn this.#writeTerminal(new MongoOutStage(collection, db));\n\t}\n\t/**\n\t* `$merge` write terminal. Streams the pipeline output into the target\n\t* collection per the supplied merge semantics (`whenMatched` /\n\t* `whenNotMatched`). Like `out()`, terminates the chain — `$merge` must\n\t* be the final stage.\n\t*/\n\tmerge(options) {\n\t\treturn this.#writeTerminal(new MongoMergeStage(options));\n\t}\n\t#writeTerminal(stage) {\n\t\tconst pipeline = [...this.#state.stages, stage];\n\t\tconst command = new AggregateCommand(this.#state.collection, pipeline);\n\t\tconst meta = {\n\t\t\ttarget: \"mongo\",\n\t\t\tstorageHash: this.#state.storageHash,\n\t\t\tlane: \"mongo-query\"\n\t\t};\n\t\treturn {\n\t\t\tcollection: this.#state.collection,\n\t\t\tcommand,\n\t\t\tmeta\n\t\t};\n\t}\n\tunionWith(collection, pipeline) {\n\t\treturn this.#withStage(new MongoUnionWithStage(collection, pipeline));\n\t}\n\tbucket(options) {\n\t\treturn this.#withStage(new MongoBucketStage(options));\n\t}\n\tbucketAuto(options) {\n\t\treturn this.#withStage(new MongoBucketAutoStage(options));\n\t}\n\tgeoNear(options) {\n\t\treturn this.#withStage(new MongoGeoNearStage(options));\n\t}\n\tfacet(facets) {\n\t\treturn this.#withStage(new MongoFacetStage(facets));\n\t}\n\tgraphLookup(options) {\n\t\treturn this.#withStage(new MongoGraphLookupStage(options));\n\t}\n\tsetWindowFields(options) {\n\t\treturn this.#withStage(new MongoSetWindowFieldsStage(options));\n\t}\n\tdensify(options) {\n\t\treturn this.#withStage(new MongoDensifyStage(options));\n\t}\n\tfill(options) {\n\t\treturn this.#withStage(new MongoFillStage(options));\n\t}\n\tsearch(config, index) {\n\t\treturn this.#withStage(new MongoSearchStage(config, index));\n\t}\n\tsearchMeta(config, index) {\n\t\treturn this.#withStage(new MongoSearchMetaStage(config, index));\n\t}\n\tvectorSearch(options) {\n\t\treturn this.#withStage(new MongoVectorSearchStage(options));\n\t}\n\tpipe(stage) {\n\t\treturn this.#withStage(stage);\n\t}\n\t/**\n\t* No-arg `updateMany()`: deconstruct the chain into leading `$match`\n\t* stages (folded into the filter) and remaining stages (which must all\n\t* be valid pipeline-update stages). Available only when `U = 'update-ok'`.\n\t*\n\t* The optional callback parameter exists for subclass-override\n\t* compatibility with `FilteredCollection.updateMany(updaterFn)` — TS's\n\t* strict override check requires the parent's parameter to accept at\n\t* least what the child's signature does. A runtime guard throws if a\n\t* callback is actually passed on a bare `PipelineChain`. Note that\n\t* because nothing in the public surface transitions `U` from\n\t* `'update-cleared'` (the initial state on `CollectionHandle` /\n\t* `FilteredCollection`) back to `'update-ok'`, the no-arg form is\n\t* reachable only via explicit type casts in internal tests — the\n\t* callback-form \"type hole\" is therefore not reachable from user\n\t* code. See `docs/architecture docs/adrs/ADR 201 - State-machine\n\t* pattern for typed DSL builders.md` for the marker-transition table.\n\t*/\n\tupdateMany(updaterFn) {\n\t\tif (updaterFn !== void 0) throw ormError(\"ORM.ARGUMENT_INVALID\", \"updateMany() on a PipelineChain expects no arguments — the chain itself is the update pipeline. To update with an operator callback, call .updateMany(fn) on a FilteredCollection (i.e. after .match()).\");\n\t\tconst { filter, updatePipeline } = deconstructUpdateChain(this.#state.stages);\n\t\tconst command = new UpdateManyCommand(this.#state.collection, filter, updatePipeline);\n\t\treturn {\n\t\t\tcollection: this.#state.collection,\n\t\t\tcommand,\n\t\t\tmeta: this.#writeMeta()\n\t\t};\n\t}\n\t/**\n\t* No-arg `updateOne()`: same as `updateMany()` but maps to a single-doc\n\t* update. Carries the same optional-callback/subclass-compat caveat\n\t* documented above — the callback form is reachable only via forced\n\t* casts in internal tests.\n\t*/\n\tupdateOne(updaterFn) {\n\t\tif (updaterFn !== void 0) throw ormError(\"ORM.ARGUMENT_INVALID\", \"updateOne() on a PipelineChain expects no arguments — the chain itself is the update pipeline. To update with an operator callback, call .updateOne(fn) on a FilteredCollection (i.e. after .match()).\");\n\t\tconst { filter, updatePipeline } = deconstructUpdateChain(this.#state.stages);\n\t\tconst command = new UpdateOneCommand(this.#state.collection, filter, updatePipeline);\n\t\treturn {\n\t\t\tcollection: this.#state.collection,\n\t\t\tcommand,\n\t\t\tmeta: this.#writeMeta()\n\t\t};\n\t}\n\t/**\n\t* Find a single document matching the accumulated pipeline (which must\n\t* consist solely of leading `$match` stages followed by at most one\n\t* `$sort`) and apply `updaterFn`. Available only when\n\t* `FindAndModifyEnabled` is `'fam-ok'` — stages that clear the marker\n\t* (including `$skip`, which MongoDB's `findAndModify` has no slot for)\n\t* make this method invisible at the type level.\n\t*\n\t* The pipeline stages are deconstructed into the wire command's `filter`\n\t* and `sort` slots. If any non-deconstructable stage is present, a\n\t* runtime error is thrown as a defensive check (the type system should\n\t* prevent this).\n\t*/\n\tfindOneAndUpdate(updaterFn, opts = {}) {\n\t\tconst { filter, sort } = deconstructFindAndModifyChain(this.#state.stages);\n\t\tconst update = resolveUpdaterResult(updaterFn(createFieldAccessor()));\n\t\tconst command = new FindOneAndUpdateCommand(this.#state.collection, filter, update, opts.upsert ?? false, sort, opts.returnDocument ?? \"after\");\n\t\tconst meta = {\n\t\t\ttarget: \"mongo\",\n\t\t\tstorageHash: this.#state.storageHash,\n\t\t\tlane: \"mongo-query\"\n\t\t};\n\t\treturn {\n\t\t\tcollection: this.#state.collection,\n\t\t\tcommand,\n\t\t\tmeta\n\t\t};\n\t}\n\t/**\n\t* Find a single document matching the accumulated pipeline and delete it.\n\t* Same marker gating and deconstruction as `findOneAndUpdate`.\n\t*/\n\tfindOneAndDelete() {\n\t\tconst { filter, sort } = deconstructFindAndModifyChain(this.#state.stages);\n\t\tconst command = new FindOneAndDeleteCommand(this.#state.collection, filter, sort);\n\t\tconst meta = {\n\t\t\ttarget: \"mongo\",\n\t\t\tstorageHash: this.#state.storageHash,\n\t\t\tlane: \"mongo-query\"\n\t\t};\n\t\treturn {\n\t\t\tcollection: this.#state.collection,\n\t\t\tcommand,\n\t\t\tmeta\n\t\t};\n\t}\n\t/**\n\t* Materialise the chain as a `MongoQueryPlan` wrapping an `AggregateCommand`.\n\t*/\n\tbuild() {\n\t\tconst command = new AggregateCommand(this.#state.collection, this.#state.stages);\n\t\tconst meta = {\n\t\t\ttarget: \"mongo\",\n\t\t\tstorageHash: this.#state.storageHash,\n\t\t\tlane: \"mongo-query\"\n\t\t};\n\t\tconst modelName = this.#state.modelName;\n\t\tconst contractNarrow = this.#contract;\n\t\tlet resultShape;\n\t\tif (modelName !== void 0) {\n\t\t\tconst model = castAs(domainModelsAtDefaultNamespace(contractNarrow.domain)[modelName]);\n\t\t\tresultShape = model ? computePipelineResultShape(this.#state.stages, contractModelToMongoResultShape(model)) : { kind: \"unknown\" };\n\t\t}\n\t\treturn {\n\t\t\tcollection: this.#state.collection,\n\t\t\tcommand,\n\t\t\tmeta,\n\t\t\t...ifDefined(\"resultShape\", resultShape)\n\t\t};\n\t}\n\t/**\n\t* Alias for `build()` — surfaces the read intent at the call site.\n\t*/\n\taggregate() {\n\t\treturn this.build();\n\t}\n};\n/**\n* Walk the accumulated pipeline stages and extract the `filter` and `sort`\n* slots for a `findOneAndUpdate` / `findOneAndDelete` wire command.\n*\n* The helper accepts exactly the canonical shape `match+ -> sort?` and\n* nothing else:\n*\n* - one or more `$match` stages (AND-folded into a single filter),\n* - optionally followed by a single `$sort` stage.\n*\n* Anything else — a `$sort` before `$match`, multiple `$sort` stages, a\n* `$skip` stage, or any non-`$match`/`$sort` stage — is rejected with a\n* clear error. The type system already prevents most of these at compile\n* time via the `FindAndModifyEnabled` marker, but the runtime check\n* guards the escape hatches (e.g. `.pipe(...)`) and future marker gaps.\n*\n* `$skip` is rejected outright because MongoDB's `findAndModify` command\n* has no skip slot; a silently-dropped skip is a latent correctness bug\n* waiting to happen. (A02 removed skip from the typed AST for the same\n* reason.)\n*/\nfunction deconstructFindAndModifyChain(stages) {\n\tconst matchFilters = [];\n\tlet sort;\n\tlet seenNonMatch = false;\n\tfor (const stage of stages) if (stage instanceof MongoMatchStage) {\n\t\tif (seenNonMatch) throw ormError(\"ORM.ARGUMENT_INVALID\", \"findOneAndUpdate/findOneAndDelete requires the canonical $match+ -> $sort? shape, but a $match stage was found after a $sort. Re-order the chain so every .match() call precedes the .sort() call.\");\n\t\tmatchFilters.push(stage.filter);\n\t} else if (stage instanceof MongoSortStage) {\n\t\tif (sort !== void 0) throw ormError(\"ORM.ARGUMENT_INVALID\", \"findOneAndUpdate/findOneAndDelete accepts at most one $sort stage; drop the extra .sort() call or combine the keys into a single sort spec.\");\n\t\tsort = { ...stage.sort };\n\t\tseenNonMatch = true;\n\t} else if (stage instanceof MongoSkipStage) throw ormError(\"ORM.OPERATION_UNSUPPORTED\", \"findOneAndUpdate/findOneAndDelete does not support .skip() — MongoDB findAndModify has no skip slot. Remove the .skip() call, or use .aggregate()/.build() if the chain needs skip semantics.\");\n\telse throw ormError(\"ORM.ARGUMENT_INVALID\", `findOneAndUpdate/findOneAndDelete requires the canonical \\$match+ -> \\$sort? shape, but encountered a '${stage.constructor.name}' stage. This is likely a bug — the type system should have prevented this chain.`);\n\tif (matchFilters.length === 0) throw ormError(\"ORM.ARGUMENT_INVALID\", \"findOneAndUpdate/findOneAndDelete requires at least one .match() call.\");\n\tconst first = matchFilters[0];\n\tif (first === void 0) throw new InternalError(\"Unreachable: matchFilters.length > 0 but first is undefined\");\n\treturn {\n\t\tfilter: matchFilters.length === 1 ? first : MongoAndExpr.of(matchFilters),\n\t\tsort\n\t};\n}\n/**\n* Walk the accumulated pipeline stages: leading `$match` stages become the\n* filter, remaining stages must all be valid `MongoUpdatePipelineStage`\n* members (currently `$addFields`, `$project`, `$replaceRoot`).\n*/\nfunction deconstructUpdateChain(stages) {\n\tconst matchFilters = [];\n\tlet boundary = 0;\n\tfor (const stage of stages) {\n\t\tif (!(stage instanceof MongoMatchStage)) break;\n\t\tmatchFilters.push(stage.filter);\n\t\tboundary++;\n\t}\n\tif (matchFilters.length === 0) throw ormError(\"ORM.ARGUMENT_INVALID\", \"No-arg updateMany/updateOne requires at least one .match() call.\");\n\tconst remaining = stages.slice(boundary);\n\tif (remaining.length === 0) throw ormError(\"ORM.ARGUMENT_INVALID\", \"No-arg updateMany/updateOne requires at least one pipeline-update stage (e.g. .addFields(), .project(), .replaceRoot()) after the .match() stages.\");\n\tconst updatePipeline = [];\n\tfor (const stage of remaining) if (stage instanceof MongoAddFieldsStage || stage instanceof MongoProjectStage || stage instanceof MongoReplaceRootStage) updatePipeline.push(stage);\n\telse throw ormError(\"ORM.ARGUMENT_INVALID\", `No-arg updateMany/updateOne: encountered non-update stage '${stage.constructor.name}' after the leading \\$match stages. Only \\$addFields/\\$set, \\$project/\\$unset, and \\$replaceRoot/\\$replaceWith stages are valid in an update pipeline.`);\n\tconst first = matchFilters[0];\n\tif (first === void 0) throw new InternalError(\"Unreachable: matchFilters.length > 0 but first is undefined\");\n\treturn {\n\t\tfilter: matchFilters.length === 1 ? first : MongoAndExpr.of(matchFilters),\n\t\tupdatePipeline\n\t};\n}\n//#endregion\n//#region src/expression-helpers.ts\nfunction numericExpr(op, args) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/double@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, args.map((a) => a.node))\n\t};\n}\nfunction numericUnaryExpr(op, arg) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/double@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, arg.node)\n\t};\n}\nfunction stringExpr(op, args) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/string@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, args.map((a) => a.node))\n\t};\n}\nfunction stringUnaryExpr(op, arg) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/string@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, arg.node)\n\t};\n}\nfunction booleanExpr(op, args) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/bool@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, args.map((a) => a.node))\n\t};\n}\nfunction booleanUnaryExpr(op, arg) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/bool@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, arg.node)\n\t};\n}\nfunction dateUnaryExpr(op, arg) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/date@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, arg.node)\n\t};\n}\nfunction arrayExpr(op, args) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/array@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, args.map((a) => a.node))\n\t};\n}\nfunction arrayUnaryExpr(op, arg) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: \"mongo/array@1\",\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, arg.node)\n\t};\n}\nfunction docUnaryExpr(op, arg) {\n\treturn {\n\t\t_field: {\n\t\t\tcodecId: arg._field.codecId,\n\t\t\tnullable: false\n\t\t},\n\t\tnode: MongoAggOperator.of(op, arg.node)\n\t};\n}\nfunction namedArgsExpr(op, args, _field) {\n\tconst nodeArgs = {};\n\tfor (const [key, val] of Object.entries(args)) if (val !== void 0) nodeArgs[key] = val.node;\n\treturn {\n\t\t_field,\n\t\tnode: MongoAggOperator.of(op, nodeArgs)\n\t};\n}\nconst NUMERIC = {\n\tcodecId: \"mongo/double@1\",\n\tnullable: false\n};\nconst STRING = {\n\tcodecId: \"mongo/string@1\",\n\tnullable: false\n};\nconst BOOLEAN = {\n\tcodecId: \"mongo/bool@1\",\n\tnullable: false\n};\nconst DATE = {\n\tcodecId: \"mongo/date@1\",\n\tnullable: false\n};\nconst ARRAY = {\n\tcodecId: \"mongo/array@1\",\n\tnullable: false\n};\nconst DOC = {\n\tcodecId: \"mongo/document@1\",\n\tnullable: false\n};\nfunction literal(value) {\n\treturn {\n\t\t_field: void 0,\n\t\tnode: MongoAggLiteral.of(value)\n\t};\n}\nconst fn = {\n\tadd(...args) {\n\t\treturn numericExpr(\"$add\", args);\n\t},\n\tsubtract(a, b) {\n\t\treturn numericExpr(\"$subtract\", [a, b]);\n\t},\n\tmultiply(...args) {\n\t\treturn numericExpr(\"$multiply\", args);\n\t},\n\tdivide(a, b) {\n\t\treturn numericExpr(\"$divide\", [a, b]);\n\t},\n\tconcat(...args) {\n\t\treturn stringExpr(\"$concat\", args);\n\t},\n\ttoLower(a) {\n\t\treturn stringUnaryExpr(\"$toLower\", a);\n\t},\n\ttoUpper(a) {\n\t\treturn stringUnaryExpr(\"$toUpper\", a);\n\t},\n\tsize(a) {\n\t\treturn numericUnaryExpr(\"$size\", a);\n\t},\n\tcond(condition, thenExpr, elseExpr) {\n\t\treturn {\n\t\t\t_field: thenExpr._field,\n\t\t\tnode: new MongoAggCond(condition, thenExpr.node, elseExpr.node)\n\t\t};\n\t},\n\tliteral,\n\tyear(a) {\n\t\treturn numericUnaryExpr(\"$year\", a);\n\t},\n\tmonth(a) {\n\t\treturn numericUnaryExpr(\"$month\", a);\n\t},\n\tdayOfMonth(a) {\n\t\treturn numericUnaryExpr(\"$dayOfMonth\", a);\n\t},\n\thour(a) {\n\t\treturn numericUnaryExpr(\"$hour\", a);\n\t},\n\tminute(a) {\n\t\treturn numericUnaryExpr(\"$minute\", a);\n\t},\n\tsecond(a) {\n\t\treturn numericUnaryExpr(\"$second\", a);\n\t},\n\tmillisecond(a) {\n\t\treturn numericUnaryExpr(\"$millisecond\", a);\n\t},\n\tdateToString(args) {\n\t\treturn namedArgsExpr(\"$dateToString\", args, STRING);\n\t},\n\tdateFromString(args) {\n\t\treturn namedArgsExpr(\"$dateFromString\", args, DATE);\n\t},\n\tdateDiff(args) {\n\t\treturn namedArgsExpr(\"$dateDiff\", args, NUMERIC);\n\t},\n\tdateAdd(args) {\n\t\treturn namedArgsExpr(\"$dateAdd\", args, DATE);\n\t},\n\tdateSubtract(args) {\n\t\treturn namedArgsExpr(\"$dateSubtract\", args, DATE);\n\t},\n\tdateTrunc(args) {\n\t\treturn namedArgsExpr(\"$dateTrunc\", args, DATE);\n\t},\n\tsubstr(str, start, length) {\n\t\treturn stringExpr(\"$substr\", [\n\t\t\tstr,\n\t\t\tstart,\n\t\t\tlength\n\t\t]);\n\t},\n\tsubstrBytes(str, start, count) {\n\t\treturn stringExpr(\"$substrBytes\", [\n\t\t\tstr,\n\t\t\tstart,\n\t\t\tcount\n\t\t]);\n\t},\n\ttrim(args) {\n\t\treturn namedArgsExpr(\"$trim\", args, STRING);\n\t},\n\tltrim(args) {\n\t\treturn namedArgsExpr(\"$ltrim\", args, STRING);\n\t},\n\trtrim(args) {\n\t\treturn namedArgsExpr(\"$rtrim\", args, STRING);\n\t},\n\tsplit(str, delimiter) {\n\t\treturn arrayExpr(\"$split\", [str, delimiter]);\n\t},\n\tstrLenCP(a) {\n\t\treturn numericUnaryExpr(\"$strLenCP\", a);\n\t},\n\tstrLenBytes(a) {\n\t\treturn numericUnaryExpr(\"$strLenBytes\", a);\n\t},\n\tregexMatch(args) {\n\t\treturn namedArgsExpr(\"$regexMatch\", args, BOOLEAN);\n\t},\n\tregexFind(args) {\n\t\treturn namedArgsExpr(\"$regexFind\", args, DOC);\n\t},\n\tregexFindAll(args) {\n\t\treturn namedArgsExpr(\"$regexFindAll\", args, ARRAY);\n\t},\n\treplaceOne(args) {\n\t\treturn namedArgsExpr(\"$replaceOne\", args, STRING);\n\t},\n\treplaceAll(args) {\n\t\treturn namedArgsExpr(\"$replaceAll\", args, STRING);\n\t},\n\tcmp(a, b) {\n\t\treturn numericExpr(\"$cmp\", [a, b]);\n\t},\n\teq(a, b) {\n\t\treturn booleanExpr(\"$eq\", [a, b]);\n\t},\n\tne(a, b) {\n\t\treturn booleanExpr(\"$ne\", [a, b]);\n\t},\n\tgt(a, b) {\n\t\treturn booleanExpr(\"$gt\", [a, b]);\n\t},\n\tgte(a, b) {\n\t\treturn booleanExpr(\"$gte\", [a, b]);\n\t},\n\tlt(a, b) {\n\t\treturn booleanExpr(\"$lt\", [a, b]);\n\t},\n\tlte(a, b) {\n\t\treturn booleanExpr(\"$lte\", [a, b]);\n\t},\n\tarrayElemAt(arr, idx) {\n\t\treturn {\n\t\t\t_field: {\n\t\t\t\tcodecId: DOC.codecId,\n\t\t\t\tnullable: true\n\t\t\t},\n\t\t\tnode: MongoAggOperator.of(\"$arrayElemAt\", [arr.node, idx.node])\n\t\t};\n\t},\n\tconcatArrays(...args) {\n\t\treturn arrayExpr(\"$concatArrays\", args);\n\t},\n\tfirstElem(a) {\n\t\treturn {\n\t\t\t_field: {\n\t\t\t\tcodecId: DOC.codecId,\n\t\t\t\tnullable: true\n\t\t\t},\n\t\t\tnode: MongoAggOperator.of(\"$first\", a.node)\n\t\t};\n\t},\n\tlastElem(a) {\n\t\treturn {\n\t\t\t_field: {\n\t\t\t\tcodecId: DOC.codecId,\n\t\t\t\tnullable: true\n\t\t\t},\n\t\t\tnode: MongoAggOperator.of(\"$last\", a.node)\n\t\t};\n\t},\n\tisIn(elem, arr) {\n\t\treturn booleanExpr(\"$in\", [elem, arr]);\n\t},\n\tindexOfArray(arr, value, ...rest) {\n\t\treturn numericExpr(\"$indexOfArray\", [\n\t\t\tarr,\n\t\t\tvalue,\n\t\t\t...rest\n\t\t]);\n\t},\n\tisArray(a) {\n\t\treturn booleanUnaryExpr(\"$isArray\", a);\n\t},\n\treverseArray(a) {\n\t\treturn arrayUnaryExpr(\"$reverseArray\", a);\n\t},\n\tslice(arr, ...rest) {\n\t\treturn arrayExpr(\"$slice\", [arr, ...rest]);\n\t},\n\tzip(args) {\n\t\tconst nodeArgs = { inputs: args.inputs.map((a) => a.node) };\n\t\tif (args.useLongestLength) nodeArgs[\"useLongestLength\"] = args.useLongestLength.node;\n\t\tif (args.defaults) nodeArgs[\"defaults\"] = args.defaults.node;\n\t\treturn {\n\t\t\t_field: ARRAY,\n\t\t\tnode: MongoAggOperator.of(\"$zip\", nodeArgs)\n\t\t};\n\t},\n\trange(start, end, step) {\n\t\treturn arrayExpr(\"$range\", [\n\t\t\tstart,\n\t\t\tend,\n\t\t\tstep\n\t\t]);\n\t},\n\tsetUnion(...args) {\n\t\treturn arrayExpr(\"$setUnion\", args);\n\t},\n\tsetIntersection(...args) {\n\t\treturn arrayExpr(\"$setIntersection\", args);\n\t},\n\tsetDifference(a, b) {\n\t\treturn arrayExpr(\"$setDifference\", [a, b]);\n\t},\n\tsetEquals(...args) {\n\t\treturn booleanExpr(\"$setEquals\", args);\n\t},\n\tsetIsSubset(a, b) {\n\t\treturn booleanExpr(\"$setIsSubset\", [a, b]);\n\t},\n\tanyElementTrue(a) {\n\t\treturn booleanUnaryExpr(\"$anyElementTrue\", a);\n\t},\n\tallElementsTrue(a) {\n\t\treturn booleanUnaryExpr(\"$allElementsTrue\", a);\n\t},\n\ttypeOf(a) {\n\t\treturn stringUnaryExpr(\"$type\", a);\n\t},\n\tconvert(args) {\n\t\treturn namedArgsExpr(\"$convert\", args, DOC);\n\t},\n\ttoInt(a) {\n\t\treturn numericUnaryExpr(\"$toInt\", a);\n\t},\n\ttoLong(a) {\n\t\treturn numericUnaryExpr(\"$toLong\", a);\n\t},\n\ttoDouble(a) {\n\t\treturn numericUnaryExpr(\"$toDouble\", a);\n\t},\n\ttoDecimal(a) {\n\t\treturn numericUnaryExpr(\"$toDecimal\", a);\n\t},\n\ttoString_(a) {\n\t\treturn stringUnaryExpr(\"$toString\", a);\n\t},\n\ttoObjectId(a) {\n\t\treturn docUnaryExpr(\"$toObjectId\", a);\n\t},\n\ttoBool(a) {\n\t\treturn booleanUnaryExpr(\"$toBool\", a);\n\t},\n\ttoDate(a) {\n\t\treturn dateUnaryExpr(\"$toDate\", a);\n\t},\n\tobjectToArray(a) {\n\t\treturn arrayUnaryExpr(\"$objectToArray\", a);\n\t},\n\tarrayToObject(a) {\n\t\treturn {\n\t\t\t_field: DOC,\n\t\t\tnode: MongoAggOperator.of(\"$arrayToObject\", a.node)\n\t\t};\n\t},\n\tgetField(args) {\n\t\treturn namedArgsExpr(\"$getField\", args, DOC);\n\t},\n\tsetField(args) {\n\t\treturn namedArgsExpr(\"$setField\", args, DOC);\n\t}\n};\n//#endregion\n//#region src/contract-errors.ts\nfunction contractError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/state-classes.ts\n/**\n* \"Match-all\" filter used by the unqualified-write terminals\n* (`updateAll`/`deleteAll`). The canonical representation is still\n* undecided — `MongoAndExpr` with an empty conjunction and a dedicated\n* `MongoMatchAllExpr` node are both candidates. For now we use\n* `_id $exists: true`, which is trivially true on every document and\n* avoids introducing a new AST node before the wider question is\n* resolved. Centralised so the eventual switch is a one-line change.\n*/\nfunction matchAllFilter() {\n\treturn MongoExistsExpr.exists(\"_id\");\n}\n/**\n* Resolve an updater callback into a `MongoUpdateSpec` (either the folded\n* operator object or a pipeline-stage array). Centralised so all write\n* terminals share the same fold / dispatch semantics.\n*/\nfunction resolveUpdaterCallback(updaterFn) {\n\treturn resolveUpdaterResult(updaterFn(createFieldAccessor()));\n}\n/**\n* Build the `PlanMeta` envelope shared by every write terminal in this\n* package. Lane is `mongo-query` (single lane for all query-builder terminals)\n* so middleware can dispatch on intent without inspecting the command.\n*/\nfunction writeMeta(storageHash) {\n\treturn {\n\t\ttarget: \"mongo\",\n\t\tstorageHash,\n\t\tlane: \"mongo-query\"\n\t};\n}\n/**\n* Root state of the query-builder state machine. Returned from\n* `mongoQuery(...).from(name)` and bound to a single collection.\n*\n* Inherits the entire pipeline-stage surface from `PipelineChain` (since an\n* empty `CollectionHandle` is observably an empty pipeline). Adds:\n*\n* - `match(...)` — overridden to transition to `FilteredCollection`, which\n* accumulates filters for eventual splatting into write/find-and-modify\n* wire commands.\n* - **Insert / unqualified-write methods** (M2): `insertOne`, `insertMany`,\n* `updateAll`, `deleteAll`. These live *only* here — the corresponding\n* methods are absent from `FilteredCollection`, so a caller cannot\n* accidentally produce an unqualified write by forgetting to `.match(...)`\n* later in the chain. Bodies land in M2.\n*/\nvar CollectionHandle = class extends PipelineChain {\n\t#ctx;\n\t#modelName;\n\tconstructor(ctx, modelName) {\n\t\tsuper(ctx.contract, {\n\t\t\tcollection: ctx.collection,\n\t\t\tstages: [],\n\t\t\tstorageHash: ctx.storageHash,\n\t\t\tmodelName\n\t\t});\n\t\tthis.#ctx = ctx;\n\t\tthis.#modelName = modelName;\n\t}\n\t/**\n\t* Bound model name. Exposed so type tests can assert the binding without\n\t* flipping into a pipeline. Not part of the public-API contract.\n\t*/\n\tget _modelName() {\n\t\treturn this.#modelName;\n\t}\n\tmatch(filterOrFn) {\n\t\tconst resolved = typeof filterOrFn === \"function\" ? filterOrFn(createFieldAccessor()) : filterOrFn;\n\t\treturn new FilteredCollection(this.#ctx, this.#modelName, [resolved]);\n\t}\n\t/**\n\t* Insert a single document. Document fields are passed straight through to\n\t* the wire `InsertOneCommand` — codec normalisation happens at the\n\t* adapter/driver boundary, identically to the SQL builder (see Open Item\n\t* #14 confirmation in the design conversation).\n\t*\n\t* Returns a `MongoQueryPlan<InsertOneResult>` whose row stream yields a\n\t* single result document with the server-assigned `insertedId`.\n\t*/\n\tinsertOne(document) {\n\t\tconst command = new InsertOneCommand(this.#ctx.collection, document);\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Insert a batch of documents. Order is preserved in the returned\n\t* `insertedIds` array.\n\t*/\n\tinsertMany(documents) {\n\t\tif (documents.length === 0) throw ormError(\"ORM.MUTATION_DATA_MISSING\", \"insertMany() requires at least one document.\");\n\t\tconst command = new InsertManyCommand(this.#ctx.collection, documents);\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Update *every* document in the collection. Lives only on\n\t* `CollectionHandle` — the corresponding method is intentionally absent\n\t* from `FilteredCollection` so a caller cannot accidentally produce an\n\t* unqualified write by forgetting to `.match(...)` first. Pair with\n\t* `.match(...).updateMany(...)` for the filtered case.\n\t*/\n\tupdateAll(updaterFn) {\n\t\tconst update = resolveUpdaterCallback(updaterFn);\n\t\tconst command = new UpdateManyCommand(this.#ctx.collection, matchAllFilter(), update);\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Delete *every* document in the collection. See `updateAll` for the\n\t* rationale around the unqualified-write surface being limited to this\n\t* state class.\n\t*/\n\tdeleteAll() {\n\t\tconst command = new DeleteManyCommand(this.#ctx.collection, matchAllFilter());\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Insert-or-update the document matching `filterFn`. The filter is\n\t* mandatory (vs. `updateAll`'s tautological match) because an upsert\n\t* without a discriminating predicate would either match every existing\n\t* document or insert an indistinguishable new one.\n\t*\n\t* Maps to `UpdateOneCommand` with `upsert: true`. The driver inserts a\n\t* new document derived from the filter equality fields plus the update\n\t* spec when no match is found; otherwise updates the matched document.\n\t*/\n\tupsertOne(filterFn, updaterFn) {\n\t\tconst filter = filterFn(createFieldAccessor());\n\t\tconst update = resolveUpdaterCallback(updaterFn);\n\t\tconst command = new UpdateOneCommand(this.#ctx.collection, filter, update, true);\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n};\n/**\n* State reached after one or more `.match(...)` calls on `CollectionHandle`.\n*\n* Inherits the pipeline-stage surface from `PipelineChain`, with the\n* accumulated filters baked in as a leading `$match` stage on the underlying\n* pipeline state. This means read-terminal output (`.aggregate()` /\n* `.build()`) and any subsequent pipeline-stage chain see the filtered\n* collection as input — the read story works through pure inheritance.\n*\n* Adds:\n*\n* - `match(...)` — pushes another `$match` stage *and* records the filter in\n* the accumulator, so the eventual write/find-and-modify terminal can\n* splat the AND-folded filter into the wire command's `filter` slot.\n* - **Filtered writes** (M2): `updateMany`, `updateOne`, `deleteMany`,\n* `deleteOne`, `upsertOne`. Stubbed in M1. (Upsert-many is an open\n* question in the spec — see TML-2267 — and is intentionally absent.)\n* - **Find-and-modify** (M3): `findOneAndUpdate`, `findOneAndDelete`.\n* Stubbed in M1.\n*\n* Notably *does not* expose `insertOne`/`insertMany`/`updateAll`/`deleteAll`\n* — those are insert or unqualified-write operations that are nonsense\n* after a filter has been applied.\n*/\nvar FilteredCollection = class FilteredCollection extends PipelineChain {\n\t#ctx;\n\t#modelName;\n\t#filters;\n\tconstructor(ctx, modelName, filters) {\n\t\tif (filters.length === 0) throw new InternalError(\"FilteredCollection requires at least one accumulated filter\");\n\t\tconst first = filters[0];\n\t\tif (first === void 0) throw new InternalError(\"FilteredCollection: unreachable empty-filters branch\");\n\t\tconst leading = filters.length === 1 ? first : foldAnd(filters);\n\t\tsuper(ctx.contract, {\n\t\t\tcollection: ctx.collection,\n\t\t\tstages: [new MongoMatchStage(leading)],\n\t\t\tstorageHash: ctx.storageHash,\n\t\t\tmodelName\n\t\t});\n\t\tthis.#ctx = ctx;\n\t\tthis.#modelName = modelName;\n\t\tthis.#filters = filters;\n\t}\n\tget _modelName() {\n\t\treturn this.#modelName;\n\t}\n\t/**\n\t* Accumulated filter list. Exposed for the M2/M3 write/find-and-modify\n\t* terminals to splat into wire-command `filter` slots; not part of the\n\t* public-API contract.\n\t*/\n\tget _filters() {\n\t\treturn this.#filters;\n\t}\n\tmatch(filterOrFn) {\n\t\tconst resolved = typeof filterOrFn === \"function\" ? filterOrFn(createFieldAccessor()) : filterOrFn;\n\t\treturn new FilteredCollection(this.#ctx, this.#modelName, [...this.#filters, resolved]);\n\t}\n\t/**\n\t* AND-fold the accumulated filters into a single `MongoFilterExpr` for\n\t* splatting into a write/find-and-modify wire command's `filter` slot.\n\t* Length-1 short-circuits to avoid a redundant `$and` wrapper.\n\t*/\n\t#foldedFilter() {\n\t\tconst first = this.#filters[0];\n\t\tif (first === void 0) throw new InternalError(\"FilteredCollection: invariant violated — empty filter accumulator\");\n\t\treturn this.#filters.length === 1 ? first : foldAnd(this.#filters);\n\t}\n\t/**\n\t* Update every matching document. `updaterFn` receives a `FieldAccessor`\n\t* and returns an array of `TypedUpdateOp` (e.g. `[f.amount.inc(1),\n\t* f.status.set('done')]`). Operators are folded into the wire-format\n\t* update spec by `foldUpdateOps`, which throws on operator+path\n\t* collisions.\n\t*/\n\tupdateMany(updaterFn) {\n\t\tconst update = resolveUpdaterCallback(updaterFn);\n\t\tconst command = new UpdateManyCommand(this.#ctx.collection, this.#foldedFilter(), update);\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Update at most one matching document. The driver picks the document\n\t* (typically the first one matched by the underlying scan); no ordering\n\t* guarantee is implied — chain `.sort(...)` and use the M3\n\t* `.findOneAndUpdate(...)` terminal when ordering matters.\n\t*/\n\tupdateOne(updaterFn) {\n\t\tconst update = resolveUpdaterCallback(updaterFn);\n\t\tconst command = new UpdateOneCommand(this.#ctx.collection, this.#foldedFilter(), update);\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Delete every matching document.\n\t*/\n\tdeleteMany() {\n\t\tconst command = new DeleteManyCommand(this.#ctx.collection, this.#foldedFilter());\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Delete at most one matching document. See the `updateOne` note about\n\t* driver-chosen victim selection.\n\t*/\n\tdeleteOne() {\n\t\tconst command = new DeleteOneCommand(this.#ctx.collection, this.#foldedFilter());\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Insert-or-update against the accumulated filter. Maps to\n\t* `UpdateOneCommand` with `upsert: true`. Equivalent to\n\t* `CollectionHandle.upsertOne(f => filter, updaterFn)` but reuses the\n\t* already-accumulated `.match(...)` filter chain.\n\t*/\n\tupsertOne(updaterFn) {\n\t\tconst update = resolveUpdaterCallback(updaterFn);\n\t\tconst command = new UpdateOneCommand(this.#ctx.collection, this.#foldedFilter(), update, true);\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Find a single matching document and apply `updaterFn` to it.\n\t*\n\t* `opts.upsert` (default `false`) toggles insert-on-miss behaviour.\n\t* `opts.returnDocument` (default `'after'`) controls whether the row\n\t* stream yields the document as it was before or after the update.\n\t*/\n\tfindOneAndUpdate(updaterFn, opts = {}) {\n\t\tconst update = resolveUpdaterCallback(updaterFn);\n\t\tconst command = new FindOneAndUpdateCommand(this.#ctx.collection, this.#foldedFilter(), update, opts.upsert ?? false, void 0, opts.returnDocument ?? \"after\");\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n\t/**\n\t* Find a single matching document and delete it. Returns the deleted\n\t* document via the row stream.\n\t*/\n\tfindOneAndDelete() {\n\t\tconst command = new FindOneAndDeleteCommand(this.#ctx.collection, this.#foldedFilter());\n\t\treturn {\n\t\t\tcollection: this.#ctx.collection,\n\t\t\tcommand,\n\t\t\tmeta: writeMeta(this.#ctx.storageHash)\n\t\t};\n\t}\n};\nfunction foldAnd(filters) {\n\treturn MongoAndExpr.of(filters);\n}\n/**\n* Narrow a `MongoContractWithTypeMaps`-shaped value down to its underlying\n* `MongoContract` view. `MongoContractWithTypeMaps<C, ...>` is defined as\n* `C & { readonly [phantom]?: TTypeMaps }`, so every contract we accept is\n* structurally a `MongoContract` — the phantom is type-only. This helper\n* centralises that narrowing so callers don't reach for `as unknown as\n* MongoContract` double-casts.\n*/\nfunction asMongoContract(contract) {\n\treturn contract;\n}\n/**\n* Construct a `CollectionHandle` from a validated contract + root name.\n* Used by `mongoQuery(...).from(name)` to enter the state machine.\n*/\nfunction createCollectionHandle(contract, rootName) {\n\tconst c = asMongoContract(contract);\n\tconst modelName = c.roots[rootName]?.model;\n\tif (!modelName) throw ormError(\"ORM.MODEL_UNKNOWN\", `Unknown root: \"${rootName}\". Valid roots: ${Object.keys(c.roots).join(\", \")}`);\n\tconst model = domainModelsAtDefaultNamespace(c.domain)[modelName];\n\tif (!model) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Unknown model: \"${modelName}\" referenced by root \"${rootName}\".`);\n\tconst collectionName = model.storage.collection ?? rootName;\n\tif (!c.storage?.storageHash) throw contractError(\"CONTRACT.VALIDATION_FAILED\", \"Contract is missing storage.storageHash. Pass a validated contract to mongoQuery().\");\n\treturn new CollectionHandle({\n\t\tcontract,\n\t\tcollection: collectionName,\n\t\tstorageHash: String(c.storage.storageHash)\n\t}, modelName);\n}\n//#endregion\n//#region src/query.ts\nfunction mongoQuery(options) {\n\tconst contract = blindCast(options.contractJson);\n\treturn {\n\t\tfrom(rootName) {\n\t\t\treturn createCollectionHandle(contract, rootName);\n\t\t},\n\t\trawCommand(command) {\n\t\t\tconst storageHash = asMongoContract(contract).storage?.storageHash;\n\t\t\tif (!storageHash) throw contractError(\"CONTRACT.VALIDATION_FAILED\", \"Contract is missing storage.storageHash. Pass a validated contract to mongoQuery().\");\n\t\t\tconst meta = {\n\t\t\t\ttarget: \"mongo\",\n\t\t\t\tstorageHash: String(storageHash),\n\t\t\t\tlane: \"mongo-query\"\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tcollection: command.collection,\n\t\t\t\tcommand,\n\t\t\t\tmeta\n\t\t\t};\n\t\t}\n\t};\n}\n//#endregion\nexport { CollectionHandle, FilteredCollection, PipelineChain, acc, contractFieldToMongoFieldShape, contractModelToMongoResultShape, createFieldAccessor, expr, fn, mongoQuery };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;AAQA,SAAS,qBAAqB,MAAM;CACnC,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,IAAI,GAAG,IAAI,QAAQ,KAAK,GAAG,OAAO,OAAO,IAAI;CACrF,OAAO;AACR;AACA,MAAM,MAAM;CACX,IAAI,MAAM;EACT,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,IAAI,KAAK,IAAI;EACxC;CACD;CACA,IAAI,MAAM;EACT,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,IAAI,KAAK,IAAI;EACxC;CACD;CACA,IAAI,MAAM;EACT,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,IAAI,KAAK,IAAI;EACxC;CACD;CACA,IAAI,MAAM;EACT,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,IAAI,KAAK,IAAI;EACxC;CACD;CACA,MAAM,MAAM;EACX,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,MAAM,KAAK,IAAI;EAC1C;CACD;CACA,KAAK,MAAM;EACV,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,KAAK,KAAK,IAAI;EACzC;CACD;CACA,KAAK,MAAM;EACV,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,KAAK,KAAK,IAAI;EACzC;CACD;CACA,SAAS,MAAM;EACd,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,SAAS,KAAK,IAAI;EAC7C;CACD;CACA,QAAQ;EACP,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,MAAM;EACjC;CACD;CACA,UAAU,MAAM;EACf,OAAO;GACN,QAAQ,KAAK;GACb,MAAM,oBAAoB,UAAU,KAAK,IAAI;EAC9C;CACD;CACA,WA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C3H,MAAM,iBAAiB,MAAM,QAAQ,cAAc;CACnD,IAAI,CAAC,EAAE,SAAS,aAAa,MAAM,cAAc,8BAA8B,qFAAqF;CACpK,OAAO,IAAI,iBAAiB;EAC3B;EACA,YAAY;EACZ,aAAa,OAAO,EAAE,QAAQ,WAAW;CAC1C,GAAG,SAAS;AACb;AAGA,SAAS,WAAW,SAAS;CAC5B,MAAM,WAAW,UAAU,QAAQ,YAAY;CAC/C,OAAO;EACN,KAAK,UAAU;GACd,OAAO,uBAAuB,UAAU,QAAQ;EACjD;EACA,WAAW,SAAS;GACnB,MAAM,cAAc,gBAAgB,QAAQ,CAAC,CAAC,SAAS;GACvD,IAAI,CAAC,aAAa,MAAM,cAAc,8BAA8B,qFAAqF;GACzJ,MAAM,OAAO;IACZ,QAAQ;IACR,aAAa,OAAO,WAAW;IAC/B,MAAM;GACP;GACA,OAAO;IACN,YAAY,QAAQ;IACpB;IACA;GACD;EACD;CACD;AACD"}
@@ -0,0 +1,22 @@
1
+ import { Contract, ContractModelBase, JsonValue } from "@prisma/orm-framework/contract/types";
2
+ import { ImportSpecifierResolver, ValidationContext } from "@prisma/orm-framework/components/emission";
3
+ //#region ../../../2-mongo-family/3-tooling/emitter/dist/exports/index.d.mts
4
+ //#region src/index.d.ts
5
+ declare const mongoEmission: {
6
+ id: string;
7
+ validateTypes(contract: Contract, _ctx: ValidationContext): void;
8
+ validateStructure(contract: Contract): void;
9
+ generateStorageType(contract: Contract, storageHashTypeName: string): string;
10
+ generateModelStorageType(_modelName: string, model: ContractModelBase): string;
11
+ resolveFieldValueSet(_modelName: string, fieldName: string, model: ContractModelBase, contract: Contract): {
12
+ readonly encodedValues: readonly JsonValue[];
13
+ readonly codecId: string;
14
+ } | undefined;
15
+ getFamilyImports(resolveImportSpecifier: ImportSpecifierResolver): string[];
16
+ getFamilyTypeAliases(): string;
17
+ getTypeMapsExpression(): string;
18
+ getContractWrapper(contractBaseName: string, typeMapsName: string): string;
19
+ };
20
+ //#endregion
21
+ export { mongoEmission };
22
+ //# sourceMappingURL=emitter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.d.mts","names":[],"sources":["../../../../2-mongo-family/3-tooling/emitter/dist/exports/index.d.mts"],"mappings":";;;;cAGc;EACZ;EACA,cAAc,UAAU,UAAU,MAAM;EACxC,kBAAkB,UAAU;EAC5B,oBAAoB,UAAU,UAAU;EACxC,yBAAyB,oBAAoB,OAAO;EACpD,qBAAqB,oBAAoB,mBAAmB,OAAO,mBAAmB,UAAU;aACrF,wBAAwB;aACxB;;EAEX,iBAAiB,wBAAwB;EACzC;EACA;EACA,mBAAmB,0BAA0B"}
@@ -0,0 +1,2 @@
1
+ import { t as mongoEmission } from "./exports-CJMh0VTU.mjs";
2
+ export { mongoEmission };