@prisma-next/mongo-runtime 0.5.0-dev.60 → 0.5.0-dev.62

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.
package/README.md CHANGED
@@ -42,7 +42,7 @@ const runtime = createMongoRuntime({
42
42
  });
43
43
  ```
44
44
 
45
- Custom or third-party codecs (encryption, vendor scalars) are contributed via an extension-pack descriptor whose `codecInstances` list includes them; `createMongoExecutionContext` folds them into the same registry. Duplicate codec ids across contributors throw `RUNTIME.DUPLICATE_CODEC` at composition time.
45
+ Custom or third-party codecs (encryption, vendor scalars) are contributed via an extension-pack descriptor whose `codecs` slot returns the codec descriptors; `createMongoExecutionContext` folds them into the same registry. Duplicate codec ids across contributors throw `RUNTIME.DUPLICATE_CODEC` at composition time.
46
46
 
47
47
  ## Responsibilities
48
48
 
package/dist/index.d.mts CHANGED
@@ -36,10 +36,7 @@ interface MongoExecutionPlan<Row = unknown> extends ExecutionPlan<Row> {
36
36
  /**
37
37
  * Mongo-specific static contributions a runtime descriptor declares.
38
38
  *
39
- * Mirrors `SqlStaticContributions` in shape: a `codecs()` getter that yields
40
- * a `MongoCodecRegistry` populated with this contributor's codecs. The
41
- * registry is then walked by `createMongoExecutionContext` and folded into
42
- * the single per-execution registry the runtime reads from at decode time.
39
+ * Mirrors `SqlStaticContributions` in shape: a `codecs()` getter that yields a `MongoCodecRegistry` populated with this contributor's codecs. The registry is then walked by `createMongoExecutionContext` and folded into the single per-execution registry the runtime reads from at decode time.
43
40
  */
44
41
  interface MongoStaticContributions {
45
42
  readonly codecs: () => MongoCodecRegistry;
@@ -52,9 +49,7 @@ interface MongoRuntimeExtensionDescriptor<TTargetId extends string = 'mongo'> ex
52
49
  create(): MongoRuntimeExtensionInstance<TTargetId>;
53
50
  }
54
51
  /**
55
- * The Mongo execution stack: target + adapter + optional driver + extension
56
- * packs. Mirrors `SqlExecutionStack`. Constructed via
57
- * `createMongoExecutionStack`.
52
+ * The Mongo execution stack: target + adapter + optional driver + extension packs. Mirrors `SqlExecutionStack`. Constructed via `createMongoExecutionStack`.
58
53
  */
59
54
  interface MongoExecutionStack<TTargetId extends string = 'mongo'> {
60
55
  readonly target: MongoRuntimeTargetDescriptor<TTargetId>;
@@ -71,10 +66,7 @@ declare function createMongoExecutionStack<TTargetId extends string = 'mongo'>(o
71
66
  /**
72
67
  * Read-only view of the codec registry exposed on `MongoExecutionContext`.
73
68
  *
74
- * Hides `register()` and the iterator from public surface — users do not
75
- * mutate the per-execution codec registry. Internal aggregation in
76
- * `createMongoExecutionContext` keeps using the full `MongoCodecRegistry`
77
- * (it needs `register()`).
69
+ * Hides `register()` and the iterator from public surface — users do not mutate the per-execution codec registry. Internal aggregation in `createMongoExecutionContext` keeps using the full `MongoCodecRegistry` (it needs `register()`).
78
70
  */
79
71
  interface MongoCodecLookup {
80
72
  get(id: string): MongoCodec<string> | undefined;
@@ -83,14 +75,9 @@ interface MongoCodecLookup {
83
75
  /**
84
76
  * Per-execution context aggregated from a `MongoExecutionStack`.
85
77
  *
86
- * Carries the user's contract, a read-only lookup over the codec registry
87
- * composed from every stack contributor, and a back-reference to the stack
88
- * itself so the runtime can reach the adapter without users threading it
89
- * explicitly.
78
+ * Carries the user's contract, a read-only lookup over the codec registry composed from every stack contributor, and a back-reference to the stack itself so the runtime can reach the adapter without users threading it explicitly.
90
79
  *
91
- * Mirrors SQL's `ExecutionContext` in role; Mongo's flavour is leaner
92
- * because there are no parameterised codecs, JSON-schema validators, or
93
- * mutation-default generators in scope yet.
80
+ * Mirrors SQL's `ExecutionContext` in role; Mongo's flavour is leaner because there are no parameterised codecs, JSON-schema validators, or mutation-default generators in scope yet.
94
81
  */
95
82
  interface MongoExecutionContext<TTargetId extends string = 'mongo'> {
96
83
  readonly contract: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/mongo-execution-plan.ts","../src/mongo-execution-stack.ts","../src/mongo-middleware.ts","../src/mongo-runtime.ts"],"sources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ted, checkMiddlewareCompatibility, runWithMiddleware, runtimeError } from "@prisma-next/framework-components/runtime";
3
- import { createMongoCodecRegistry } from "@prisma-next/mongo-codec";
3
+ import { newMongoCodecRegistry } from "@prisma-next/mongo-codec";
4
4
  import { ifDefined } from "@prisma-next/utils/defined";
5
5
  import { canonicalStringify } from "@prisma-next/utils/canonical-stringify";
6
6
  import { hashContent } from "@prisma-next/utils/hash-content";
@@ -15,7 +15,7 @@ function createMongoExecutionStack(options) {
15
15
  });
16
16
  }
17
17
  function createMongoExecutionContext(options) {
18
- const registry = createMongoCodecRegistry();
18
+ const registry = newMongoCodecRegistry();
19
19
  const owners = /* @__PURE__ */ new Map();
20
20
  const contributors = [
21
21
  options.stack.target,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["contributors: ReadonlyArray<MongoStaticContributions & { readonly id: string }>","out: Record<string, unknown>","tasks: Array<Promise<void>>","nested: Record<string, unknown>","arr: unknown[]","#adapter","#driver","#codecs","ctx: MongoMiddlewareContext","codecCtx: CodecCallContext"],"sources":["../src/mongo-execution-stack.ts","../src/codecs/decoding.ts","../src/content-hash.ts","../src/mongo-runtime.ts"],"sourcesContent":["import {\n createExecutionStack,\n type ExecutionStack,\n type RuntimeAdapterDescriptor,\n type RuntimeAdapterInstance,\n type RuntimeDriverDescriptor,\n type RuntimeDriverInstance,\n type RuntimeExtensionDescriptor,\n type RuntimeExtensionInstance,\n type RuntimeTargetDescriptor,\n type RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { runtimeError } from '@prisma-next/framework-components/runtime';\nimport type { MongoCodec } from '@prisma-next/mongo-codec';\nimport { createMongoCodecRegistry, type MongoCodecRegistry } from '@prisma-next/mongo-codec';\nimport type { MongoAdapter } from '@prisma-next/mongo-lowering';\n\n/**\n * Mongo-specific static contributions a runtime descriptor declares.\n *\n * Mirrors `SqlStaticContributions` in shape: a `codecs()` getter that yields\n * a `MongoCodecRegistry` populated with this contributor's codecs. The\n * registry is then walked by `createMongoExecutionContext` and folded into\n * the single per-execution registry the runtime reads from at decode time.\n */\nexport interface MongoStaticContributions {\n readonly codecs: () => MongoCodecRegistry;\n}\n\nexport interface MongoRuntimeTargetDescriptor<\n TTargetId extends string = 'mongo',\n TTargetInstance extends RuntimeTargetInstance<'mongo', TTargetId> = RuntimeTargetInstance<\n 'mongo',\n TTargetId\n >,\n> extends RuntimeTargetDescriptor<'mongo', TTargetId, TTargetInstance>,\n MongoStaticContributions {}\n\nexport interface MongoRuntimeAdapterInstance<TTargetId extends string = 'mongo'>\n extends RuntimeAdapterInstance<'mongo', TTargetId>,\n MongoAdapter {}\n\nexport interface MongoRuntimeAdapterDescriptor<\n TTargetId extends string = 'mongo',\n TAdapterInstance extends RuntimeAdapterInstance<\n 'mongo',\n TTargetId\n > = MongoRuntimeAdapterInstance<TTargetId>,\n> extends RuntimeAdapterDescriptor<'mongo', TTargetId, TAdapterInstance>,\n MongoStaticContributions {}\n\nexport interface MongoRuntimeExtensionInstance<TTargetId extends string = 'mongo'>\n extends RuntimeExtensionInstance<'mongo', TTargetId> {}\n\nexport interface MongoRuntimeExtensionDescriptor<TTargetId extends string = 'mongo'>\n extends RuntimeExtensionDescriptor<'mongo', TTargetId, MongoRuntimeExtensionInstance<TTargetId>>,\n MongoStaticContributions {\n create(): MongoRuntimeExtensionInstance<TTargetId>;\n}\n\n/**\n * The Mongo execution stack: target + adapter + optional driver + extension\n * packs. Mirrors `SqlExecutionStack`. Constructed via\n * `createMongoExecutionStack`.\n */\nexport interface MongoExecutionStack<TTargetId extends string = 'mongo'> {\n readonly target: MongoRuntimeTargetDescriptor<TTargetId>;\n readonly adapter: MongoRuntimeAdapterDescriptor<TTargetId>;\n readonly driver:\n | RuntimeDriverDescriptor<\n 'mongo',\n TTargetId,\n unknown,\n RuntimeDriverInstance<'mongo', TTargetId>\n >\n | undefined;\n readonly extensionPacks: readonly MongoRuntimeExtensionDescriptor<TTargetId>[];\n}\n\nexport function createMongoExecutionStack<TTargetId extends string = 'mongo'>(options: {\n readonly target: MongoRuntimeTargetDescriptor<TTargetId>;\n readonly adapter: MongoRuntimeAdapterDescriptor<TTargetId>;\n readonly driver?:\n | RuntimeDriverDescriptor<\n 'mongo',\n TTargetId,\n unknown,\n RuntimeDriverInstance<'mongo', TTargetId>\n >\n | undefined;\n readonly extensionPacks?: readonly MongoRuntimeExtensionDescriptor<TTargetId>[] | undefined;\n}): MongoExecutionStack<TTargetId> {\n const stack = createExecutionStack({\n target: options.target,\n adapter: options.adapter,\n driver: options.driver,\n extensionPacks: options.extensionPacks,\n });\n return stack as ExecutionStack<'mongo', TTargetId> as MongoExecutionStack<TTargetId>;\n}\n\n/**\n * Read-only view of the codec registry exposed on `MongoExecutionContext`.\n *\n * Hides `register()` and the iterator from public surface — users do not\n * mutate the per-execution codec registry. Internal aggregation in\n * `createMongoExecutionContext` keeps using the full `MongoCodecRegistry`\n * (it needs `register()`).\n */\nexport interface MongoCodecLookup {\n get(id: string): MongoCodec<string> | undefined;\n has(id: string): boolean;\n}\n\n/**\n * Per-execution context aggregated from a `MongoExecutionStack`.\n *\n * Carries the user's contract, a read-only lookup over the codec registry\n * composed from every stack contributor, and a back-reference to the stack\n * itself so the runtime can reach the adapter without users threading it\n * explicitly.\n *\n * Mirrors SQL's `ExecutionContext` in role; Mongo's flavour is leaner\n * because there are no parameterised codecs, JSON-schema validators, or\n * mutation-default generators in scope yet.\n */\nexport interface MongoExecutionContext<TTargetId extends string = 'mongo'> {\n readonly contract: unknown;\n readonly codecs: MongoCodecLookup;\n readonly stack: MongoExecutionStack<TTargetId>;\n}\n\nexport function createMongoExecutionContext<TTargetId extends string = 'mongo'>(options: {\n readonly contract: unknown;\n readonly stack: MongoExecutionStack<TTargetId>;\n}): MongoExecutionContext<TTargetId> {\n const registry = createMongoCodecRegistry();\n const owners = new Map<string, string>();\n\n const contributors: ReadonlyArray<MongoStaticContributions & { readonly id: string }> = [\n options.stack.target,\n options.stack.adapter,\n ...options.stack.extensionPacks,\n ];\n\n for (const contributor of contributors) {\n const contributed = contributor.codecs();\n for (const codec of iterateCodecs(contributed)) {\n const existingOwner = owners.get(codec.id);\n if (existingOwner !== undefined) {\n throw runtimeError(\n 'RUNTIME.DUPLICATE_CODEC',\n `Duplicate Mongo codec id '${codec.id}' contributed by '${contributor.id}' (already registered by '${existingOwner}').`,\n { codecId: codec.id, existingOwner, incomingOwner: contributor.id },\n );\n }\n registry.register(codec);\n owners.set(codec.id, contributor.id);\n }\n }\n\n return Object.freeze({\n contract: options.contract,\n codecs: registry,\n stack: options.stack,\n });\n}\n\nfunction* iterateCodecs(registry: MongoCodecRegistry): Iterable<MongoCodec<string>> {\n yield* registry.values();\n}\n","import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport { runtimeError } from '@prisma-next/framework-components/runtime';\nimport type { MongoFieldShape, MongoResultShape } from '@prisma-next/mongo-query-ast/execution';\nimport type { MongoCodecLookup } from '../mongo-execution-stack';\n\nconst WIRE_PREVIEW_LIMIT = 100;\n\nfunction previewWireValue(wireValue: unknown): string {\n if (typeof wireValue === 'string') {\n return wireValue.length > WIRE_PREVIEW_LIMIT\n ? `${wireValue.substring(0, WIRE_PREVIEW_LIMIT)}...`\n : wireValue;\n }\n return String(wireValue).substring(0, WIRE_PREVIEW_LIMIT);\n}\n\nfunction wrapDecodeFailure(\n error: unknown,\n collection: string,\n path: string,\n codecId: string,\n wireValue: unknown,\n): never {\n const message = error instanceof Error ? error.message : String(error);\n const wrapped = runtimeError(\n 'RUNTIME.DECODE_FAILED',\n `Failed to decode field ${path} in collection '${collection}' with codec '${codecId}': ${message}`,\n {\n collection,\n path,\n codec: codecId,\n wirePreview: previewWireValue(wireValue),\n },\n );\n wrapped.cause = error;\n throw wrapped;\n}\n\nexport async function decodeMongoRow(\n row: unknown,\n shape: MongoResultShape,\n registry: MongoCodecLookup,\n collection: string,\n ctx: CodecCallContext = {},\n): Promise<unknown> {\n if (shape.kind === 'unknown') {\n return row;\n }\n if (typeof row !== 'object' || row === null) {\n return row;\n }\n const rowObj = row as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n const tasks: Array<Promise<void>> = [];\n\n function scheduleLeaf(\n path: string,\n codecId: string,\n wire: unknown,\n assign: (v: unknown) => void,\n ): void {\n const codec = registry.get(codecId);\n if (!codec) {\n assign(wire);\n return;\n }\n tasks.push(\n (async () => {\n try {\n assign(await codec.decode(wire, ctx));\n } catch (error) {\n wrapDecodeFailure(error, collection, path, codecId, wire);\n }\n })(),\n );\n }\n\n function walkField(\n value: unknown,\n fieldShape: MongoFieldShape,\n path: string,\n assign: (v: unknown) => void,\n ): void {\n // Exhaustive over `MongoFieldShape['kind']` by construction:\n // adding a new variant must add a corresponding arm or the\n // `satisfies never` below would error at type-check time.\n switch (fieldShape.kind) {\n case 'unknown':\n assign(value);\n return;\n case 'leaf':\n if (value === null || value === undefined) {\n assign(value);\n return;\n }\n scheduleLeaf(path, fieldShape.codecId, value, assign);\n return;\n case 'document': {\n if (value === null || value === undefined) {\n assign(value);\n return;\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n assign(value);\n return;\n }\n const vObj = value as Record<string, unknown>;\n // Pre-seed with a shallow copy so unshaped subdocument keys\n // round-trip verbatim. Subsequent walkField assignments overwrite\n // shaped keys with their decoded values. Mirrors the top-level\n // pass-through invariant — the decode path is structurally\n // additive at every nesting depth, not just the root.\n const nested: Record<string, unknown> = { ...vObj };\n assign(nested);\n for (const [fk, fShape] of Object.entries(fieldShape.fields)) {\n walkField(vObj[fk], fShape, `${path}.${fk}`, (v) => {\n nested[fk] = v;\n });\n }\n return;\n }\n case 'array': {\n if (value === null || value === undefined) {\n assign(value);\n return;\n }\n if (!Array.isArray(value)) {\n assign(value);\n return;\n }\n const arr: unknown[] = [];\n assign(arr);\n for (let i = 0; i < value.length; i++) {\n const el = value[i];\n walkField(el, fieldShape.element, `${path}.${i}`, (v) => {\n arr[i] = v;\n });\n }\n return;\n }\n }\n // The switch above is exhaustive over `MongoFieldShape['kind']`. The\n // `satisfies never` below is a compile-time guard that fails if a new\n // variant is added without a corresponding arm.\n /* v8 ignore start */\n fieldShape satisfies never;\n /* v8 ignore stop */\n }\n\n for (const [k, fShape] of Object.entries(shape.fields)) {\n walkField(rowObj[k], fShape, k, (v) => {\n out[k] = v;\n });\n }\n\n // Pass through any row fields the shape does not describe. The shape is a\n // partial, lane-vouched description of what the runtime knows how to decode;\n // fields outside that description (e.g. polymorphic variant fields the base\n // model's shape doesn't enumerate, sidecar fields a future schema migration\n // adds) round-trip verbatim. Drop semantics belongs to explicit projection\n // (`select` / `$project`), not to the structural decode path.\n for (const k of Object.keys(rowObj)) {\n if (!Object.hasOwn(shape.fields, k)) {\n out[k] = rowObj[k];\n }\n }\n\n await Promise.all(tasks);\n return out;\n}\n","import { canonicalStringify } from '@prisma-next/utils/canonical-stringify';\nimport { hashContent } from '@prisma-next/utils/hash-content';\nimport type { MongoExecutionPlan } from './mongo-execution-plan';\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 `@prisma-next/utils/hash-content` for the\n * rationale.\n *\n * @internal\n */\nexport function computeMongoContentHash(exec: MongoExecutionPlan): Promise<string> {\n // Spread `exec.command` to a plain object: `canonicalStringify`\n // rejects class instances by design (so `Map`/`Set`/class instances\n // cannot collapse to `{}` and silently collide). All wire-command\n // data lives on own enumerable properties, so this preserves the\n // same canonical form and therefore the same hash.\n return hashContent(\n canonicalStringify({\n storageHash: exec.meta.storageHash,\n command: { ...exec.command },\n }),\n );\n}\n","import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport {\n AsyncIterableResult,\n checkAborted,\n checkMiddlewareCompatibility,\n RuntimeCore,\n type RuntimeExecuteOptions,\n runWithMiddleware,\n} from '@prisma-next/framework-components/runtime';\nimport type { MongoAdapter, MongoDriver } from '@prisma-next/mongo-lowering';\nimport type { MongoQueryPlan } from '@prisma-next/mongo-query-ast/execution';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { decodeMongoRow } from './codecs/decoding';\nimport { computeMongoContentHash } from './content-hash';\nimport type { MongoExecutionPlan } from './mongo-execution-plan';\nimport type { MongoCodecLookup, MongoExecutionContext } from './mongo-execution-stack';\nimport type { MongoMiddleware, MongoMiddlewareContext } from './mongo-middleware';\n\nfunction noop() {}\n\n/**\n * Mongo runtime options.\n *\n * The runtime takes a {@link MongoExecutionContext} (built via\n * `createMongoExecutionContext`) and a driver. Codec resolution flows from\n * the context — there is no `codecs` field on this options bag. The adapter\n * is reached via `context.stack.adapter` (instantiated lazily through the\n * stack's `create(stack)` factory). See ADR — Mongo result-shape as a\n * structural plan field, § Codec registry: stack aggregation, not user\n * threading.\n */\nexport interface MongoRuntimeOptions {\n readonly context: MongoExecutionContext;\n readonly driver: MongoDriver;\n readonly middleware?: readonly MongoMiddleware[];\n readonly mode?: 'strict' | 'permissive';\n}\n\nexport interface MongoRuntime {\n /**\n * Execute a `MongoQueryPlan` and return an async iterable of rows.\n *\n * The optional `options.signal` is threaded through\n * `lower → adapter.lower → resolveValue → codec.encode` so codec authors\n * who forward the signal to their underlying SDK get true cancellation\n * of in-flight network calls. The runtime additionally observes the\n * signal at two boundaries:\n *\n * - **Already-aborted at entry** — first `next()` throws\n * `RUNTIME.ABORTED { phase: 'stream' }` before any work is done.\n * (Inherited from `RuntimeCore.execute`.)\n * - **Mid-encode abort** — surfaces as\n * `RUNTIME.ABORTED { phase: 'encode' }` from inside `resolveValue`'s\n * per-level `Promise.all` race.\n *\n * Mongo's read path decodes rows via `resultShape` (per ADR 209). The\n * same `CodecCallContext` is forwarded into each `codec.decode(wire, ctx)`\n * call, so async decoders that respect the signal get cancellation; the\n * runtime itself does not currently emit a `phase: 'decode'` envelope.\n */\n execute<Row>(\n plan: MongoQueryPlan<Row>,\n options?: RuntimeExecuteOptions,\n ): AsyncIterableResult<Row>;\n close(): Promise<void>;\n}\n\nclass MongoRuntimeImpl\n extends RuntimeCore<MongoQueryPlan, MongoExecutionPlan, MongoMiddleware>\n implements MongoRuntime\n{\n readonly #adapter: MongoAdapter;\n readonly #driver: MongoDriver;\n readonly #codecs: MongoCodecLookup;\n\n constructor(options: MongoRuntimeOptions) {\n const middleware = options.middleware ? [...options.middleware] : [];\n const targetId = options.context.stack.target.targetId;\n for (const mw of middleware) {\n checkMiddlewareCompatibility(mw, 'mongo', targetId);\n }\n\n const ctx: MongoMiddlewareContext = {\n contract: options.context.contract,\n mode: options.mode ?? 'strict',\n now: () => Date.now(),\n log: { info: noop, warn: noop, error: noop },\n // ctx is only invoked by runWithMiddleware with execs this runtime lowered;\n // the framework parameter type is the cross-family base.\n contentHash: (exec) => computeMongoContentHash(exec as MongoExecutionPlan),\n };\n\n super({ middleware, ctx });\n\n const adapterDescriptor = options.context.stack.adapter;\n const adapterInstance = adapterDescriptor.create(options.context.stack);\n this.#adapter = adapterInstance;\n this.#driver = options.driver;\n this.#codecs = options.context.codecs;\n }\n\n protected override async lower(\n plan: MongoQueryPlan,\n ctx: CodecCallContext,\n ): Promise<MongoExecutionPlan> {\n return {\n command: await this.#adapter.lower(plan, ctx),\n meta: plan.meta,\n ...ifDefined('resultShape', plan.resultShape),\n };\n }\n\n protected override runDriver(exec: MongoExecutionPlan): AsyncIterable<Record<string, unknown>> {\n return this.#driver.execute<Record<string, unknown>>(exec.command);\n }\n\n override execute<Row>(\n plan: MongoQueryPlan & { readonly _row?: Row },\n options?: RuntimeExecuteOptions,\n ): AsyncIterableResult<Row> {\n const self = this;\n const signal = options?.signal;\n const codecCtx: CodecCallContext = signal === undefined ? {} : { signal };\n const generator = async function* (): AsyncGenerator<Row, void, unknown> {\n checkAborted(codecCtx, 'stream');\n const compiled = await self.runBeforeCompile(plan);\n const exec = await self.lower(compiled, codecCtx);\n const stream = runWithMiddleware<MongoExecutionPlan, Record<string, unknown>>(\n exec,\n self.middleware,\n self.ctx,\n () => self.runDriver(exec),\n );\n for await (const rawRow of stream) {\n if (exec.resultShape === undefined) {\n yield rawRow as Row;\n } else {\n // Source the collection from the lowered exec rather than the\n // pre-lowering plan: a `runBeforeCompile` middleware is allowed to\n // rewrite collection names during compilation, and the wire\n // command carried by `exec` is always authoritative for what just\n // ran.\n const decoded = await decodeMongoRow(\n rawRow,\n exec.resultShape,\n self.#codecs,\n exec.command.collection,\n codecCtx,\n );\n yield decoded as Row;\n }\n }\n };\n return new AsyncIterableResult(generator());\n }\n\n override async close(): Promise<void> {\n await this.#driver.close();\n }\n}\n\nexport function createMongoRuntime(options: MongoRuntimeOptions): MongoRuntime {\n return new MongoRuntimeImpl(options);\n}\n"],"mappings":";;;;;;;;AA+EA,SAAgB,0BAA8D,SAY3C;AAOjC,QANc,qBAAqB;EACjC,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB,QAAQ,QAAQ;EAChB,gBAAgB,QAAQ;EACzB,CAAC;;AAmCJ,SAAgB,4BAAgE,SAG3C;CACnC,MAAM,WAAW,0BAA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,MAAyB,MACvB,MACA,KAC6B;AAC7B,SAAO;GACL,SAAS,MAAM,MAAKF,QAAS,MAAM,MAAM,IAAI;GAC7C,MAAM,KAAK;GACX,GAAG,UAAU,eAAe,KAAK,YAAY;GAC9C;;CAGH,AAAmB,UAAU,MAAkE;AAC7F,SAAO,MAAKC,OAAQ,QAAiC,KAAK,QAAQ;;CAGpE,AAAS,QACP,MACA,SAC0B;EAC1B,MAAM,OAAO;EACb,MAAM,SAAS,SAAS;EACxB,MAAMG,WAA6B,WAAW,SAAY,EAAE,GAAG,EAAE,QAAQ;EACzE,MAAM,YAAY,mBAAuD;AACvE,gBAAa,UAAU,SAAS;GAChC,MAAM,WAAW,MAAM,KAAK,iBAAiB,KAAK;GAClD,MAAM,OAAO,MAAM,KAAK,MAAM,UAAU,SAAS;GACjD,MAAM,SAAS,kBACb,MACA,KAAK,YACL,KAAK,WACC,KAAK,UAAU,KAAK,CAC3B;AACD,cAAW,MAAM,UAAU,OACzB,KAAI,KAAK,gBAAgB,OACvB,OAAM;OAcN,OAPgB,MAAM,eACpB,QACA,KAAK,aACL,MAAKF,QACL,KAAK,QAAQ,YACb,SACD;;AAKP,SAAO,IAAI,oBAAoB,WAAW,CAAC;;CAG7C,MAAe,QAAuB;AACpC,QAAM,MAAKD,OAAQ,OAAO;;;AAI9B,SAAgB,mBAAmB,SAA4C;AAC7E,QAAO,IAAI,iBAAiB,QAAQ"}
1
+ {"version":3,"file":"index.mjs","names":["contributors: ReadonlyArray<MongoStaticContributions & { readonly id: string }>","out: Record<string, unknown>","tasks: Array<Promise<void>>","nested: Record<string, unknown>","arr: unknown[]","#adapter","#driver","#codecs","ctx: MongoMiddlewareContext","codecCtx: CodecCallContext"],"sources":["../src/mongo-execution-stack.ts","../src/codecs/decoding.ts","../src/content-hash.ts","../src/mongo-runtime.ts"],"sourcesContent":["import {\n createExecutionStack,\n type ExecutionStack,\n type RuntimeAdapterDescriptor,\n type RuntimeAdapterInstance,\n type RuntimeDriverDescriptor,\n type RuntimeDriverInstance,\n type RuntimeExtensionDescriptor,\n type RuntimeExtensionInstance,\n type RuntimeTargetDescriptor,\n type RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { runtimeError } from '@prisma-next/framework-components/runtime';\nimport type { MongoCodec } from '@prisma-next/mongo-codec';\nimport { type MongoCodecRegistry, newMongoCodecRegistry } from '@prisma-next/mongo-codec';\nimport type { MongoAdapter } from '@prisma-next/mongo-lowering';\n\n/**\n * Mongo-specific static contributions a runtime descriptor declares.\n *\n * Mirrors `SqlStaticContributions` in shape: a `codecs()` getter that yields a `MongoCodecRegistry` populated with this contributor's codecs. The registry is then walked by `createMongoExecutionContext` and folded into the single per-execution registry the runtime reads from at decode time.\n */\nexport interface MongoStaticContributions {\n readonly codecs: () => MongoCodecRegistry;\n}\n\nexport interface MongoRuntimeTargetDescriptor<\n TTargetId extends string = 'mongo',\n TTargetInstance extends RuntimeTargetInstance<'mongo', TTargetId> = RuntimeTargetInstance<\n 'mongo',\n TTargetId\n >,\n> extends RuntimeTargetDescriptor<'mongo', TTargetId, TTargetInstance>,\n MongoStaticContributions {}\n\nexport interface MongoRuntimeAdapterInstance<TTargetId extends string = 'mongo'>\n extends RuntimeAdapterInstance<'mongo', TTargetId>,\n MongoAdapter {}\n\nexport interface MongoRuntimeAdapterDescriptor<\n TTargetId extends string = 'mongo',\n TAdapterInstance extends RuntimeAdapterInstance<\n 'mongo',\n TTargetId\n > = MongoRuntimeAdapterInstance<TTargetId>,\n> extends RuntimeAdapterDescriptor<'mongo', TTargetId, TAdapterInstance>,\n MongoStaticContributions {}\n\nexport interface MongoRuntimeExtensionInstance<TTargetId extends string = 'mongo'>\n extends RuntimeExtensionInstance<'mongo', TTargetId> {}\n\nexport interface MongoRuntimeExtensionDescriptor<TTargetId extends string = 'mongo'>\n extends RuntimeExtensionDescriptor<'mongo', TTargetId, MongoRuntimeExtensionInstance<TTargetId>>,\n MongoStaticContributions {\n create(): MongoRuntimeExtensionInstance<TTargetId>;\n}\n\n/**\n * The Mongo execution stack: target + adapter + optional driver + extension packs. Mirrors `SqlExecutionStack`. Constructed via `createMongoExecutionStack`.\n */\nexport interface MongoExecutionStack<TTargetId extends string = 'mongo'> {\n readonly target: MongoRuntimeTargetDescriptor<TTargetId>;\n readonly adapter: MongoRuntimeAdapterDescriptor<TTargetId>;\n readonly driver:\n | RuntimeDriverDescriptor<\n 'mongo',\n TTargetId,\n unknown,\n RuntimeDriverInstance<'mongo', TTargetId>\n >\n | undefined;\n readonly extensionPacks: readonly MongoRuntimeExtensionDescriptor<TTargetId>[];\n}\n\nexport function createMongoExecutionStack<TTargetId extends string = 'mongo'>(options: {\n readonly target: MongoRuntimeTargetDescriptor<TTargetId>;\n readonly adapter: MongoRuntimeAdapterDescriptor<TTargetId>;\n readonly driver?:\n | RuntimeDriverDescriptor<\n 'mongo',\n TTargetId,\n unknown,\n RuntimeDriverInstance<'mongo', TTargetId>\n >\n | undefined;\n readonly extensionPacks?: readonly MongoRuntimeExtensionDescriptor<TTargetId>[] | undefined;\n}): MongoExecutionStack<TTargetId> {\n const stack = createExecutionStack({\n target: options.target,\n adapter: options.adapter,\n driver: options.driver,\n extensionPacks: options.extensionPacks,\n });\n return stack as ExecutionStack<'mongo', TTargetId> as MongoExecutionStack<TTargetId>;\n}\n\n/**\n * Read-only view of the codec registry exposed on `MongoExecutionContext`.\n *\n * Hides `register()` and the iterator from public surface — users do not mutate the per-execution codec registry. Internal aggregation in `createMongoExecutionContext` keeps using the full `MongoCodecRegistry` (it needs `register()`).\n */\nexport interface MongoCodecLookup {\n get(id: string): MongoCodec<string> | undefined;\n has(id: string): boolean;\n}\n\n/**\n * Per-execution context aggregated from a `MongoExecutionStack`.\n *\n * Carries the user's contract, a read-only lookup over the codec registry composed from every stack contributor, and a back-reference to the stack itself so the runtime can reach the adapter without users threading it explicitly.\n *\n * Mirrors SQL's `ExecutionContext` in role; Mongo's flavour is leaner because there are no parameterised codecs, JSON-schema validators, or mutation-default generators in scope yet.\n */\nexport interface MongoExecutionContext<TTargetId extends string = 'mongo'> {\n readonly contract: unknown;\n readonly codecs: MongoCodecLookup;\n readonly stack: MongoExecutionStack<TTargetId>;\n}\n\nexport function createMongoExecutionContext<TTargetId extends string = 'mongo'>(options: {\n readonly contract: unknown;\n readonly stack: MongoExecutionStack<TTargetId>;\n}): MongoExecutionContext<TTargetId> {\n const registry = newMongoCodecRegistry();\n const owners = new Map<string, string>();\n\n const contributors: ReadonlyArray<MongoStaticContributions & { readonly id: string }> = [\n options.stack.target,\n options.stack.adapter,\n ...options.stack.extensionPacks,\n ];\n\n for (const contributor of contributors) {\n const contributed = contributor.codecs();\n for (const codec of iterateCodecs(contributed)) {\n const existingOwner = owners.get(codec.id);\n if (existingOwner !== undefined) {\n throw runtimeError(\n 'RUNTIME.DUPLICATE_CODEC',\n `Duplicate Mongo codec id '${codec.id}' contributed by '${contributor.id}' (already registered by '${existingOwner}').`,\n { codecId: codec.id, existingOwner, incomingOwner: contributor.id },\n );\n }\n registry.register(codec);\n owners.set(codec.id, contributor.id);\n }\n }\n\n return Object.freeze({\n contract: options.contract,\n codecs: registry,\n stack: options.stack,\n });\n}\n\nfunction* iterateCodecs(registry: MongoCodecRegistry): Iterable<MongoCodec<string>> {\n yield* registry.values();\n}\n","import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport { runtimeError } from '@prisma-next/framework-components/runtime';\nimport type { MongoFieldShape, MongoResultShape } from '@prisma-next/mongo-query-ast/execution';\nimport type { MongoCodecLookup } from '../mongo-execution-stack';\n\nconst WIRE_PREVIEW_LIMIT = 100;\n\nfunction previewWireValue(wireValue: unknown): string {\n if (typeof wireValue === 'string') {\n return wireValue.length > WIRE_PREVIEW_LIMIT\n ? `${wireValue.substring(0, WIRE_PREVIEW_LIMIT)}...`\n : wireValue;\n }\n return String(wireValue).substring(0, WIRE_PREVIEW_LIMIT);\n}\n\nfunction wrapDecodeFailure(\n error: unknown,\n collection: string,\n path: string,\n codecId: string,\n wireValue: unknown,\n): never {\n const message = error instanceof Error ? error.message : String(error);\n const wrapped = runtimeError(\n 'RUNTIME.DECODE_FAILED',\n `Failed to decode field ${path} in collection '${collection}' with codec '${codecId}': ${message}`,\n {\n collection,\n path,\n codec: codecId,\n wirePreview: previewWireValue(wireValue),\n },\n );\n wrapped.cause = error;\n throw wrapped;\n}\n\nexport async function decodeMongoRow(\n row: unknown,\n shape: MongoResultShape,\n registry: MongoCodecLookup,\n collection: string,\n ctx: CodecCallContext = {},\n): Promise<unknown> {\n if (shape.kind === 'unknown') {\n return row;\n }\n if (typeof row !== 'object' || row === null) {\n return row;\n }\n const rowObj = row as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n const tasks: Array<Promise<void>> = [];\n\n function scheduleLeaf(\n path: string,\n codecId: string,\n wire: unknown,\n assign: (v: unknown) => void,\n ): void {\n const codec = registry.get(codecId);\n if (!codec) {\n assign(wire);\n return;\n }\n tasks.push(\n (async () => {\n try {\n assign(await codec.decode(wire, ctx));\n } catch (error) {\n wrapDecodeFailure(error, collection, path, codecId, wire);\n }\n })(),\n );\n }\n\n function walkField(\n value: unknown,\n fieldShape: MongoFieldShape,\n path: string,\n assign: (v: unknown) => void,\n ): void {\n // Exhaustive over `MongoFieldShape['kind']` by construction:\n // adding a new variant must add a corresponding arm or the\n // `satisfies never` below would error at type-check time.\n switch (fieldShape.kind) {\n case 'unknown':\n assign(value);\n return;\n case 'leaf':\n if (value === null || value === undefined) {\n assign(value);\n return;\n }\n scheduleLeaf(path, fieldShape.codecId, value, assign);\n return;\n case 'document': {\n if (value === null || value === undefined) {\n assign(value);\n return;\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n assign(value);\n return;\n }\n const vObj = value as Record<string, unknown>;\n // Pre-seed with a shallow copy so unshaped subdocument keys\n // round-trip verbatim. Subsequent walkField assignments overwrite\n // shaped keys with their decoded values. Mirrors the top-level\n // pass-through invariant — the decode path is structurally\n // additive at every nesting depth, not just the root.\n const nested: Record<string, unknown> = { ...vObj };\n assign(nested);\n for (const [fk, fShape] of Object.entries(fieldShape.fields)) {\n walkField(vObj[fk], fShape, `${path}.${fk}`, (v) => {\n nested[fk] = v;\n });\n }\n return;\n }\n case 'array': {\n if (value === null || value === undefined) {\n assign(value);\n return;\n }\n if (!Array.isArray(value)) {\n assign(value);\n return;\n }\n const arr: unknown[] = [];\n assign(arr);\n for (let i = 0; i < value.length; i++) {\n const el = value[i];\n walkField(el, fieldShape.element, `${path}.${i}`, (v) => {\n arr[i] = v;\n });\n }\n return;\n }\n }\n // The switch above is exhaustive over `MongoFieldShape['kind']`. The\n // `satisfies never` below is a compile-time guard that fails if a new\n // variant is added without a corresponding arm.\n /* v8 ignore start */\n fieldShape satisfies never;\n /* v8 ignore stop */\n }\n\n for (const [k, fShape] of Object.entries(shape.fields)) {\n walkField(rowObj[k], fShape, k, (v) => {\n out[k] = v;\n });\n }\n\n // Pass through any row fields the shape does not describe. The shape is a\n // partial, lane-vouched description of what the runtime knows how to decode;\n // fields outside that description (e.g. polymorphic variant fields the base\n // model's shape doesn't enumerate, sidecar fields a future schema migration\n // adds) round-trip verbatim. Drop semantics belongs to explicit projection\n // (`select` / `$project`), not to the structural decode path.\n for (const k of Object.keys(rowObj)) {\n if (!Object.hasOwn(shape.fields, k)) {\n out[k] = rowObj[k];\n }\n }\n\n await Promise.all(tasks);\n return out;\n}\n","import { canonicalStringify } from '@prisma-next/utils/canonical-stringify';\nimport { hashContent } from '@prisma-next/utils/hash-content';\nimport type { MongoExecutionPlan } from './mongo-execution-plan';\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 `@prisma-next/utils/hash-content` for the\n * rationale.\n *\n * @internal\n */\nexport function computeMongoContentHash(exec: MongoExecutionPlan): Promise<string> {\n // Spread `exec.command` to a plain object: `canonicalStringify`\n // rejects class instances by design (so `Map`/`Set`/class instances\n // cannot collapse to `{}` and silently collide). All wire-command\n // data lives on own enumerable properties, so this preserves the\n // same canonical form and therefore the same hash.\n return hashContent(\n canonicalStringify({\n storageHash: exec.meta.storageHash,\n command: { ...exec.command },\n }),\n );\n}\n","import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport {\n AsyncIterableResult,\n checkAborted,\n checkMiddlewareCompatibility,\n RuntimeCore,\n type RuntimeExecuteOptions,\n runWithMiddleware,\n} from '@prisma-next/framework-components/runtime';\nimport type { MongoAdapter, MongoDriver } from '@prisma-next/mongo-lowering';\nimport type { MongoQueryPlan } from '@prisma-next/mongo-query-ast/execution';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { decodeMongoRow } from './codecs/decoding';\nimport { computeMongoContentHash } from './content-hash';\nimport type { MongoExecutionPlan } from './mongo-execution-plan';\nimport type { MongoCodecLookup, MongoExecutionContext } from './mongo-execution-stack';\nimport type { MongoMiddleware, MongoMiddlewareContext } from './mongo-middleware';\n\nfunction noop() {}\n\n/**\n * Mongo runtime options.\n *\n * The runtime takes a {@link MongoExecutionContext} (built via\n * `createMongoExecutionContext`) and a driver. Codec resolution flows from\n * the context — there is no `codecs` field on this options bag. The adapter\n * is reached via `context.stack.adapter` (instantiated lazily through the\n * stack's `create(stack)` factory). See ADR — Mongo result-shape as a\n * structural plan field, § Codec registry: stack aggregation, not user\n * threading.\n */\nexport interface MongoRuntimeOptions {\n readonly context: MongoExecutionContext;\n readonly driver: MongoDriver;\n readonly middleware?: readonly MongoMiddleware[];\n readonly mode?: 'strict' | 'permissive';\n}\n\nexport interface MongoRuntime {\n /**\n * Execute a `MongoQueryPlan` and return an async iterable of rows.\n *\n * The optional `options.signal` is threaded through\n * `lower → adapter.lower → resolveValue → codec.encode` so codec authors\n * who forward the signal to their underlying SDK get true cancellation\n * of in-flight network calls. The runtime additionally observes the\n * signal at two boundaries:\n *\n * - **Already-aborted at entry** — first `next()` throws\n * `RUNTIME.ABORTED { phase: 'stream' }` before any work is done.\n * (Inherited from `RuntimeCore.execute`.)\n * - **Mid-encode abort** — surfaces as\n * `RUNTIME.ABORTED { phase: 'encode' }` from inside `resolveValue`'s\n * per-level `Promise.all` race.\n *\n * Mongo's read path decodes rows via `resultShape` (per ADR 209). The\n * same `CodecCallContext` is forwarded into each `codec.decode(wire, ctx)`\n * call, so async decoders that respect the signal get cancellation; the\n * runtime itself does not currently emit a `phase: 'decode'` envelope.\n */\n execute<Row>(\n plan: MongoQueryPlan<Row>,\n options?: RuntimeExecuteOptions,\n ): AsyncIterableResult<Row>;\n close(): Promise<void>;\n}\n\nclass MongoRuntimeImpl\n extends RuntimeCore<MongoQueryPlan, MongoExecutionPlan, MongoMiddleware>\n implements MongoRuntime\n{\n readonly #adapter: MongoAdapter;\n readonly #driver: MongoDriver;\n readonly #codecs: MongoCodecLookup;\n\n constructor(options: MongoRuntimeOptions) {\n const middleware = options.middleware ? [...options.middleware] : [];\n const targetId = options.context.stack.target.targetId;\n for (const mw of middleware) {\n checkMiddlewareCompatibility(mw, 'mongo', targetId);\n }\n\n const ctx: MongoMiddlewareContext = {\n contract: options.context.contract,\n mode: options.mode ?? 'strict',\n now: () => Date.now(),\n log: { info: noop, warn: noop, error: noop },\n // ctx is only invoked by runWithMiddleware with execs this runtime lowered;\n // the framework parameter type is the cross-family base.\n contentHash: (exec) => computeMongoContentHash(exec as MongoExecutionPlan),\n };\n\n super({ middleware, ctx });\n\n const adapterDescriptor = options.context.stack.adapter;\n const adapterInstance = adapterDescriptor.create(options.context.stack);\n this.#adapter = adapterInstance;\n this.#driver = options.driver;\n this.#codecs = options.context.codecs;\n }\n\n protected override async lower(\n plan: MongoQueryPlan,\n ctx: CodecCallContext,\n ): Promise<MongoExecutionPlan> {\n return {\n command: await this.#adapter.lower(plan, ctx),\n meta: plan.meta,\n ...ifDefined('resultShape', plan.resultShape),\n };\n }\n\n protected override runDriver(exec: MongoExecutionPlan): AsyncIterable<Record<string, unknown>> {\n return this.#driver.execute<Record<string, unknown>>(exec.command);\n }\n\n override execute<Row>(\n plan: MongoQueryPlan & { readonly _row?: Row },\n options?: RuntimeExecuteOptions,\n ): AsyncIterableResult<Row> {\n const self = this;\n const signal = options?.signal;\n const codecCtx: CodecCallContext = signal === undefined ? {} : { signal };\n const generator = async function* (): AsyncGenerator<Row, void, unknown> {\n checkAborted(codecCtx, 'stream');\n const compiled = await self.runBeforeCompile(plan);\n const exec = await self.lower(compiled, codecCtx);\n const stream = runWithMiddleware<MongoExecutionPlan, Record<string, unknown>>(\n exec,\n self.middleware,\n self.ctx,\n () => self.runDriver(exec),\n );\n for await (const rawRow of stream) {\n if (exec.resultShape === undefined) {\n yield rawRow as Row;\n } else {\n // Source the collection from the lowered exec rather than the\n // pre-lowering plan: a `runBeforeCompile` middleware is allowed to\n // rewrite collection names during compilation, and the wire\n // command carried by `exec` is always authoritative for what just\n // ran.\n const decoded = await decodeMongoRow(\n rawRow,\n exec.resultShape,\n self.#codecs,\n exec.command.collection,\n codecCtx,\n );\n yield decoded as Row;\n }\n }\n };\n return new AsyncIterableResult(generator());\n }\n\n override async close(): Promise<void> {\n await this.#driver.close();\n }\n}\n\nexport function createMongoRuntime(options: MongoRuntimeOptions): MongoRuntime {\n return new MongoRuntimeImpl(options);\n}\n"],"mappings":";;;;;;;;AA0EA,SAAgB,0BAA8D,SAY3C;AAOjC,QANc,qBAAqB;EACjC,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB,QAAQ,QAAQ;EAChB,gBAAgB,QAAQ;EACzB,CAAC;;AA2BJ,SAAgB,4BAAgE,SAG3C;CACnC,MAAM,WAAW,uBAAuB;CACxC,MAAM,yBAAS,IAAI,KAAqB;CAExC,MAAMA,eAAkF;EACtF,QAAQ,MAAM;EACd,QAAQ,MAAM;EACd,GAAG,QAAQ,MAAM;EAClB;AAED,MAAK,MAAM,eAAe,cAAc;EACtC,MAAM,cAAc,YAAY,QAAQ;AACxC,OAAK,MAAM,SAAS,cAAc,YAAY,EAAE;GAC9C,MAAM,gBAAgB,OAAO,IAAI,MAAM,GAAG;AAC1C,OAAI,kBAAkB,OACpB,OAAM,aACJ,2BACA,6BAA6B,MAAM,GAAG,oBAAoB,YAAY,GAAG,4BAA4B,cAAc,MACnH;IAAE,SAAS,MAAM;IAAI;IAAe,eAAe,YAAY;IAAI,CACpE;AAEH,YAAS,SAAS,MAAM;AACxB,UAAO,IAAI,MAAM,IAAI,YAAY,GAAG;;;AAIxC,QAAO,OAAO,OAAO;EACnB,UAAU,QAAQ;EAClB,QAAQ;EACR,OAAO,QAAQ;EAChB,CAAC;;AAGJ,UAAU,cAAc,UAA4D;AAClF,QAAO,SAAS,QAAQ;;;;;ACvJ1B,MAAM,qBAAqB;AAE3B,SAAS,iBAAiB,WAA4B;AACpD,KAAI,OAAO,cAAc,SACvB,QAAO,UAAU,SAAS,qBACtB,GAAG,UAAU,UAAU,GAAG,mBAAmB,CAAC,OAC9C;AAEN,QAAO,OAAO,UAAU,CAAC,UAAU,GAAG,mBAAmB;;AAG3D,SA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AiB,QAAQ"}
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@prisma-next/mongo-runtime",
3
- "version": "0.5.0-dev.60",
3
+ "version": "0.5.0-dev.62",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "MongoDB runtime implementation for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/framework-components": "0.5.0-dev.60",
10
- "@prisma-next/contract": "0.5.0-dev.60",
11
- "@prisma-next/mongo-codec": "0.5.0-dev.60",
12
- "@prisma-next/mongo-query-ast": "0.5.0-dev.60",
13
- "@prisma-next/mongo-wire": "0.5.0-dev.60",
14
- "@prisma-next/mongo-lowering": "0.5.0-dev.60",
15
- "@prisma-next/utils": "0.5.0-dev.60"
9
+ "@prisma-next/contract": "0.5.0-dev.62",
10
+ "@prisma-next/framework-components": "0.5.0-dev.62",
11
+ "@prisma-next/mongo-codec": "0.5.0-dev.62",
12
+ "@prisma-next/mongo-lowering": "0.5.0-dev.62",
13
+ "@prisma-next/mongo-query-ast": "0.5.0-dev.62",
14
+ "@prisma-next/mongo-wire": "0.5.0-dev.62",
15
+ "@prisma-next/utils": "0.5.0-dev.62"
16
16
  },
17
17
  "devDependencies": {
18
18
  "mongodb": "^6.16.0",
@@ -20,18 +20,18 @@
20
20
  "tsdown": "0.18.4",
21
21
  "typescript": "5.9.3",
22
22
  "vitest": "4.0.17",
23
- "@prisma-next/middleware-telemetry": "0.5.0-dev.60",
24
- "@prisma-next/adapter-mongo": "0.5.0-dev.60",
25
- "@prisma-next/mongo-contract-ts": "0.5.0-dev.60",
26
- "@prisma-next/family-mongo": "0.5.0-dev.60",
27
- "@prisma-next/mongo-query-builder": "0.5.0-dev.60",
28
- "@prisma-next/mongo-value": "0.5.0-dev.60",
29
- "@prisma-next/mongo-contract": "0.5.0-dev.60",
30
- "@prisma-next/target-mongo": "0.5.0-dev.60",
23
+ "@prisma-next/adapter-mongo": "0.5.0-dev.62",
24
+ "@prisma-next/mongo-contract-ts": "0.5.0-dev.62",
25
+ "@prisma-next/family-mongo": "0.5.0-dev.62",
26
+ "@prisma-next/middleware-telemetry": "0.5.0-dev.62",
27
+ "@prisma-next/mongo-query-builder": "0.5.0-dev.62",
28
+ "@prisma-next/mongo-value": "0.5.0-dev.62",
29
+ "@prisma-next/driver-mongo": "0.5.0-dev.62",
30
+ "@prisma-next/mongo-contract": "0.5.0-dev.62",
31
+ "@prisma-next/target-mongo": "0.5.0-dev.62",
31
32
  "@prisma-next/test-utils": "0.0.1",
32
- "@prisma-next/driver-mongo": "0.5.0-dev.60",
33
- "@prisma-next/tsconfig": "0.0.0",
34
- "@prisma-next/tsdown": "0.0.0"
33
+ "@prisma-next/tsdown": "0.0.0",
34
+ "@prisma-next/tsconfig": "0.0.0"
35
35
  },
36
36
  "files": [
37
37
  "dist",
@@ -12,16 +12,13 @@ import {
12
12
  } from '@prisma-next/framework-components/execution';
13
13
  import { runtimeError } from '@prisma-next/framework-components/runtime';
14
14
  import type { MongoCodec } from '@prisma-next/mongo-codec';
15
- import { createMongoCodecRegistry, type MongoCodecRegistry } from '@prisma-next/mongo-codec';
15
+ import { type MongoCodecRegistry, newMongoCodecRegistry } from '@prisma-next/mongo-codec';
16
16
  import type { MongoAdapter } from '@prisma-next/mongo-lowering';
17
17
 
18
18
  /**
19
19
  * Mongo-specific static contributions a runtime descriptor declares.
20
20
  *
21
- * Mirrors `SqlStaticContributions` in shape: a `codecs()` getter that yields
22
- * a `MongoCodecRegistry` populated with this contributor's codecs. The
23
- * registry is then walked by `createMongoExecutionContext` and folded into
24
- * the single per-execution registry the runtime reads from at decode time.
21
+ * Mirrors `SqlStaticContributions` in shape: a `codecs()` getter that yields a `MongoCodecRegistry` populated with this contributor's codecs. The registry is then walked by `createMongoExecutionContext` and folded into the single per-execution registry the runtime reads from at decode time.
25
22
  */
26
23
  export interface MongoStaticContributions {
27
24
  readonly codecs: () => MongoCodecRegistry;
@@ -59,9 +56,7 @@ export interface MongoRuntimeExtensionDescriptor<TTargetId extends string = 'mon
59
56
  }
60
57
 
61
58
  /**
62
- * The Mongo execution stack: target + adapter + optional driver + extension
63
- * packs. Mirrors `SqlExecutionStack`. Constructed via
64
- * `createMongoExecutionStack`.
59
+ * The Mongo execution stack: target + adapter + optional driver + extension packs. Mirrors `SqlExecutionStack`. Constructed via `createMongoExecutionStack`.
65
60
  */
66
61
  export interface MongoExecutionStack<TTargetId extends string = 'mongo'> {
67
62
  readonly target: MongoRuntimeTargetDescriptor<TTargetId>;
@@ -102,10 +97,7 @@ export function createMongoExecutionStack<TTargetId extends string = 'mongo'>(op
102
97
  /**
103
98
  * Read-only view of the codec registry exposed on `MongoExecutionContext`.
104
99
  *
105
- * Hides `register()` and the iterator from public surface — users do not
106
- * mutate the per-execution codec registry. Internal aggregation in
107
- * `createMongoExecutionContext` keeps using the full `MongoCodecRegistry`
108
- * (it needs `register()`).
100
+ * Hides `register()` and the iterator from public surface — users do not mutate the per-execution codec registry. Internal aggregation in `createMongoExecutionContext` keeps using the full `MongoCodecRegistry` (it needs `register()`).
109
101
  */
110
102
  export interface MongoCodecLookup {
111
103
  get(id: string): MongoCodec<string> | undefined;
@@ -115,14 +107,9 @@ export interface MongoCodecLookup {
115
107
  /**
116
108
  * Per-execution context aggregated from a `MongoExecutionStack`.
117
109
  *
118
- * Carries the user's contract, a read-only lookup over the codec registry
119
- * composed from every stack contributor, and a back-reference to the stack
120
- * itself so the runtime can reach the adapter without users threading it
121
- * explicitly.
110
+ * Carries the user's contract, a read-only lookup over the codec registry composed from every stack contributor, and a back-reference to the stack itself so the runtime can reach the adapter without users threading it explicitly.
122
111
  *
123
- * Mirrors SQL's `ExecutionContext` in role; Mongo's flavour is leaner
124
- * because there are no parameterised codecs, JSON-schema validators, or
125
- * mutation-default generators in scope yet.
112
+ * Mirrors SQL's `ExecutionContext` in role; Mongo's flavour is leaner because there are no parameterised codecs, JSON-schema validators, or mutation-default generators in scope yet.
126
113
  */
127
114
  export interface MongoExecutionContext<TTargetId extends string = 'mongo'> {
128
115
  readonly contract: unknown;
@@ -134,7 +121,7 @@ export function createMongoExecutionContext<TTargetId extends string = 'mongo'>(
134
121
  readonly contract: unknown;
135
122
  readonly stack: MongoExecutionStack<TTargetId>;
136
123
  }): MongoExecutionContext<TTargetId> {
137
- const registry = createMongoCodecRegistry();
124
+ const registry = newMongoCodecRegistry();
138
125
  const owners = new Map<string, string>();
139
126
 
140
127
  const contributors: ReadonlyArray<MongoStaticContributions & { readonly id: string }> = [