@prisma-next/adapter-mongo 0.5.0-dev.6 → 0.5.0-dev.61

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.
@@ -1,7 +1,9 @@
1
1
  import { isExprArray, isRecordArgs } from "@prisma-next/mongo-query-ast/execution";
2
+ import { checkAborted, raceAgainstAbort, runtimeError } from "@prisma-next/framework-components/runtime";
2
3
  import { MongoParamRef } from "@prisma-next/mongo-value";
3
- import { createMongoCodecRegistry, mongoCodec } from "@prisma-next/mongo-codec";
4
4
  import { AggregateWireCommand, DeleteManyWireCommand, DeleteOneWireCommand, FindOneAndDeleteWireCommand, FindOneAndUpdateWireCommand, InsertManyWireCommand, InsertOneWireCommand, UpdateManyWireCommand, UpdateOneWireCommand } from "@prisma-next/mongo-wire";
5
+ import { voidParamsSchema } from "@prisma-next/framework-components/codec";
6
+ import { mongoCodec, newMongoCodecRegistry } from "@prisma-next/mongo-codec";
5
7
  import { ObjectId } from "mongodb";
6
8
 
7
9
  //#region src/core/codec-ids.ts
@@ -15,21 +17,80 @@ const MONGO_VECTOR_CODEC_ID = "mongo/vector@1";
15
17
 
16
18
  //#endregion
17
19
  //#region src/resolve-value.ts
18
- function resolveValue(value, codecs) {
20
+ /**
21
+ * Resolves a `MongoValue` (which may contain `MongoParamRef` leaves) into the
22
+ * driver-ready wire shape. When a leaf has a `codecId` and the registry has a
23
+ * codec for it, the codec's async `encode` is awaited so codecs may perform
24
+ * asynchronous work (e.g. lookups, key derivations).
25
+ *
26
+ * Object/array nodes dispatch their child resolutions concurrently via
27
+ * `Promise.all` so independent leaves encode in parallel.
28
+ *
29
+ * Codec encode failures are wrapped in a `RUNTIME.ENCODE_FAILED` envelope
30
+ * (mirroring SQL's `wrapEncodeFailure` shape) with `{ label, codec }` details
31
+ * and the original error attached on `cause`. An already-wrapped envelope is
32
+ * re-thrown verbatim so nested resolvers don't double-wrap.
33
+ *
34
+ * `ctx: CodecCallContext` is forwarded verbatim to every
35
+ * `codec.encode(value, ctx)` call. The same `ctx` reference is also passed
36
+ * to nested `resolveValue` invocations so codec authors observe **signal
37
+ * identity** across the entire recursive walk for one `runtime.execute()`.
38
+ *
39
+ * Abort observation (only when `ctx.signal` is provided):
40
+ *
41
+ * - **Already-aborted at entry** — every recursive call pre-checks
42
+ * `ctx.signal.aborted` and short-circuits with
43
+ * `RUNTIME.ABORTED { phase: 'encode' }` before any codec is invoked.
44
+ * - **Mid-flight abort** — each per-level `Promise.all` races against the
45
+ * signal via `raceAgainstAbort`. The runtime returns
46
+ * `RUNTIME.ABORTED { phase: 'encode' }` promptly even if codec bodies
47
+ * ignore the signal; in-flight bodies run to completion in the background
48
+ * (cooperative cancellation, see ADR 204).
49
+ * - `RUNTIME.ENCODE_FAILED` envelopes thrown by a codec body before the
50
+ * runtime sees the abort pass through unchanged (AC-ERR4).
51
+ */
52
+ async function resolveValue(value, codecs, ctx) {
53
+ checkAborted(ctx, "encode");
54
+ const signal = ctx.signal;
19
55
  if (value instanceof MongoParamRef) {
20
- if (value.codecId && codecs) {
56
+ if (value.codecId) {
21
57
  const codec = codecs.get(value.codecId);
22
- if (codec?.encode) return codec.encode(value.value);
58
+ if (codec?.encode) try {
59
+ return await raceAgainstAbort(codec.encode(value.value, ctx), signal, "encode");
60
+ } catch (error) {
61
+ wrapEncodeFailure(error, value, codec.id);
62
+ }
23
63
  }
24
64
  return value.value;
25
65
  }
26
66
  if (value === null || typeof value !== "object") return value;
27
67
  if (value instanceof Date) return value;
28
- if (Array.isArray(value)) return value.map((v) => resolveValue(v, codecs));
68
+ if (Array.isArray(value)) return raceAgainstAbort(Promise.all(value.map((v) => resolveValue(v, codecs, ctx))), signal, "encode");
69
+ const entries = Object.entries(value);
70
+ const resolved = await raceAgainstAbort(Promise.all(entries.map(([, val]) => resolveValue(val, codecs, ctx))), signal, "encode");
29
71
  const result = {};
30
- for (const [key, val] of Object.entries(value)) result[key] = resolveValue(val, codecs);
72
+ for (let i = 0; i < entries.length; i++) {
73
+ const entry = entries[i];
74
+ if (entry) result[entry[0]] = resolved[i];
75
+ }
31
76
  return result;
32
77
  }
78
+ function paramRefLabel(ref, codecId) {
79
+ return ref.name ?? codecId;
80
+ }
81
+ function isAlreadyEncodeFailure(error) {
82
+ return error instanceof Error && "code" in error && error.code === "RUNTIME.ENCODE_FAILED";
83
+ }
84
+ function wrapEncodeFailure(error, ref, codecId) {
85
+ if (isAlreadyEncodeFailure(error)) throw error;
86
+ const label = paramRefLabel(ref, codecId);
87
+ const wrapped = runtimeError("RUNTIME.ENCODE_FAILED", `Failed to encode parameter ${label} with codec '${codecId}': ${error instanceof Error ? error.message : String(error)}`, {
88
+ label,
89
+ codec: codecId
90
+ });
91
+ wrapped.cause = error;
92
+ throw wrapped;
93
+ }
33
94
 
34
95
  //#endregion
35
96
  //#region src/lowering.ts
@@ -110,12 +171,12 @@ function needsLiteralWrap(value) {
110
171
  function lowerAggExpr(expr) {
111
172
  return expr.accept(aggExprLoweringVisitor);
112
173
  }
113
- function lowerFilter(filter) {
174
+ async function lowerFilter(filter, codecs, ctx) {
114
175
  switch (filter.kind) {
115
- case "field": return { [filter.field]: { [filter.op]: resolveValue(filter.value) } };
116
- case "and": return { $and: filter.exprs.map((e) => lowerFilter(e)) };
117
- case "or": return { $or: filter.exprs.map((e) => lowerFilter(e)) };
118
- case "not": return { $nor: [lowerFilter(filter.expr)] };
176
+ case "field": return { [filter.field]: { [filter.op]: await resolveValue(filter.value, codecs, ctx) } };
177
+ case "and": return { $and: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs, ctx))) };
178
+ case "or": return { $or: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs, ctx))) };
179
+ case "not": return { $nor: [await lowerFilter(filter.expr, codecs, ctx)] };
119
180
  case "exists": return { [filter.field]: { $exists: filter.exists } };
120
181
  case "expr": return { $expr: lowerAggExpr(filter.aggExpr) };
121
182
  default: {
@@ -149,9 +210,9 @@ function lowerWindowField(wf) {
149
210
  if (wf.window) result["window"] = { ...wf.window };
150
211
  return result;
151
212
  }
152
- function lowerStage(stage) {
213
+ async function lowerStage(stage, codecs, ctx) {
153
214
  switch (stage.kind) {
154
- case "match": return { $match: lowerFilter(stage.filter) };
215
+ case "match": return { $match: await lowerFilter(stage.filter, codecs, ctx) };
155
216
  case "project": {
156
217
  const projection = {};
157
218
  for (const [key, val] of Object.entries(stage.projection)) projection[key] = lowerProjectionValue(val);
@@ -167,7 +228,7 @@ function lowerStage(stage) {
167
228
  };
168
229
  if (stage.localField !== void 0) lookup["localField"] = stage.localField;
169
230
  if (stage.foreignField !== void 0) lookup["foreignField"] = stage.foreignField;
170
- if (stage.pipeline) lookup["pipeline"] = stage.pipeline.map((s) => lowerStage(s));
231
+ if (stage.pipeline) lookup["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs, ctx)));
171
232
  if (stage.let_) lookup["let"] = lowerExprRecord(stage.let_);
172
233
  return { $lookup: lookup };
173
234
  }
@@ -196,7 +257,7 @@ function lowerStage(stage) {
196
257
  } : stage.collection };
197
258
  case "unionWith": {
198
259
  const unionWith = { coll: stage.collection };
199
- if (stage.pipeline) unionWith["pipeline"] = stage.pipeline.map((s) => lowerStage(s));
260
+ if (stage.pipeline) unionWith["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs, ctx)));
200
261
  return { $unionWith: unionWith };
201
262
  }
202
263
  case "bucket": {
@@ -225,15 +286,20 @@ function lowerStage(stage) {
225
286
  if (stage.spherical !== void 0) geoNear["spherical"] = stage.spherical;
226
287
  if (stage.maxDistance !== void 0) geoNear["maxDistance"] = stage.maxDistance;
227
288
  if (stage.minDistance !== void 0) geoNear["minDistance"] = stage.minDistance;
228
- if (stage.query) geoNear["query"] = lowerFilter(stage.query);
289
+ if (stage.query) geoNear["query"] = await lowerFilter(stage.query, codecs, ctx);
229
290
  if (stage.key !== void 0) geoNear["key"] = stage.key;
230
291
  if (stage.distanceMultiplier !== void 0) geoNear["distanceMultiplier"] = stage.distanceMultiplier;
231
292
  if (stage.includeLocs !== void 0) geoNear["includeLocs"] = stage.includeLocs;
232
293
  return { $geoNear: geoNear };
233
294
  }
234
295
  case "facet": {
296
+ const facetEntries = Object.entries(stage.facets);
297
+ const facetPipelines = await Promise.all(facetEntries.map(([, pipeline]) => Promise.all(pipeline.map((s) => lowerStage(s, codecs, ctx)))));
235
298
  const facet = {};
236
- for (const [key, pipeline] of Object.entries(stage.facets)) facet[key] = pipeline.map((s) => lowerStage(s));
299
+ for (let i = 0; i < facetEntries.length; i++) {
300
+ const entry = facetEntries[i];
301
+ if (entry) facet[entry[0]] = facetPipelines[i];
302
+ }
237
303
  return { $facet: facet };
238
304
  }
239
305
  case "graphLookup": {
@@ -246,13 +312,13 @@ function lowerStage(stage) {
246
312
  };
247
313
  if (stage.maxDepth !== void 0) graphLookup["maxDepth"] = stage.maxDepth;
248
314
  if (stage.depthField !== void 0) graphLookup["depthField"] = stage.depthField;
249
- if (stage.restrictSearchWithMatch) graphLookup["restrictSearchWithMatch"] = lowerFilter(stage.restrictSearchWithMatch);
315
+ if (stage.restrictSearchWithMatch) graphLookup["restrictSearchWithMatch"] = await lowerFilter(stage.restrictSearchWithMatch, codecs, ctx);
250
316
  return { $graphLookup: graphLookup };
251
317
  }
252
318
  case "merge": {
253
319
  const merge = { into: stage.into };
254
320
  if (stage.on !== void 0) merge["on"] = stage.on;
255
- if (stage.whenMatched !== void 0) merge["whenMatched"] = Array.isArray(stage.whenMatched) ? stage.whenMatched.map((s) => lowerStage(s)) : stage.whenMatched;
321
+ if (stage.whenMatched !== void 0) merge["whenMatched"] = Array.isArray(stage.whenMatched) ? await Promise.all(stage.whenMatched.map((s) => lowerStage(s, codecs, ctx))) : stage.whenMatched;
256
322
  if (stage.whenNotMatched !== void 0) merge["whenNotMatched"] = stage.whenNotMatched;
257
323
  return { $merge: merge };
258
324
  }
@@ -315,79 +381,145 @@ function lowerStage(stage) {
315
381
  }
316
382
  }
317
383
  }
318
- function lowerPipeline(stages) {
319
- return stages.map(lowerStage);
384
+ async function lowerPipeline(stages, codecs, ctx) {
385
+ return Promise.all(stages.map((s) => lowerStage(s, codecs, ctx)));
320
386
  }
321
387
 
322
388
  //#endregion
323
389
  //#region src/core/codecs.ts
324
390
  const mongoObjectIdCodec = mongoCodec({
325
391
  typeId: MONGO_OBJECTID_CODEC_ID,
326
- targetTypes: ["objectId"],
327
- traits: ["equality"],
328
392
  decode: (wire) => wire.toHexString(),
329
393
  encode: (value) => new ObjectId(value)
330
394
  });
331
395
  const mongoStringCodec = mongoCodec({
332
396
  typeId: MONGO_STRING_CODEC_ID,
333
- targetTypes: ["string"],
334
- traits: [
335
- "equality",
336
- "order",
337
- "textual"
338
- ],
339
397
  decode: (wire) => wire,
340
398
  encode: (value) => value
341
399
  });
342
400
  const mongoDoubleCodec = mongoCodec({
343
401
  typeId: MONGO_DOUBLE_CODEC_ID,
344
- targetTypes: ["double"],
345
- traits: [
346
- "equality",
347
- "order",
348
- "numeric"
349
- ],
350
402
  decode: (wire) => wire,
351
403
  encode: (value) => value
352
404
  });
353
405
  const mongoInt32Codec = mongoCodec({
354
406
  typeId: MONGO_INT32_CODEC_ID,
355
- targetTypes: ["int"],
356
- traits: [
357
- "equality",
358
- "order",
359
- "numeric"
360
- ],
361
407
  decode: (wire) => wire,
362
408
  encode: (value) => value
363
409
  });
364
410
  const mongoBooleanCodec = mongoCodec({
365
411
  typeId: MONGO_BOOLEAN_CODEC_ID,
366
- targetTypes: ["bool"],
367
- traits: ["equality", "boolean"],
368
412
  decode: (wire) => wire,
369
413
  encode: (value) => value
370
414
  });
371
415
  const mongoDateCodec = mongoCodec({
372
416
  typeId: MONGO_DATE_CODEC_ID,
373
- targetTypes: ["date"],
374
- traits: ["equality", "order"],
375
417
  decode: (wire) => wire,
376
- encode: (value) => value
418
+ encode: (value) => value,
419
+ encodeJson: (value) => value.toISOString(),
420
+ decodeJson: (json) => {
421
+ if (typeof json !== "string") throw new Error("expected ISO date string");
422
+ return new Date(json);
423
+ }
377
424
  });
378
425
  const mongoVectorCodec = mongoCodec({
379
426
  typeId: MONGO_VECTOR_CODEC_ID,
380
- targetTypes: ["vector"],
381
- traits: ["equality"],
382
427
  decode: (wire) => wire,
383
- encode: (value) => value,
384
- renderOutputType: (typeParams) => {
385
- const length = typeParams["length"];
386
- if (length === void 0) return void 0;
387
- if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw new Error("renderOutputType: expected positive integer \"length\" for Vector");
388
- return `Vector<${length}>`;
389
- }
428
+ encode: (value) => value
390
429
  });
430
+ /**
431
+ * The canonical set of Mongo wire-type codecs.
432
+ *
433
+ * Single source of truth for both control- and runtime-plane adapter descriptors. Don't duplicate this list — import it.
434
+ */
435
+ const mongoStandardCodecs = [
436
+ mongoObjectIdCodec,
437
+ mongoStringCodec,
438
+ mongoDoubleCodec,
439
+ mongoInt32Codec,
440
+ mongoBooleanCodec,
441
+ mongoDateCodec,
442
+ mongoVectorCodec
443
+ ];
444
+ /**
445
+ * Build a {@link CodecDescriptor} for a Mongo wire-type codec.
446
+ *
447
+ * Wraps an existing {@link MongoCodec} instance into a descriptor whose factory hands out the same shared codec. Mongo's full migration to descriptor-first authoring is tracked under TML-2324; for now the descriptor view is composed from the existing `mongoCodec()` outputs.
448
+ */
449
+ function descriptorFor(codec, metadata) {
450
+ const renderOutputType = metadata.renderOutputType;
451
+ return {
452
+ codecId: codec.id,
453
+ traits: metadata.traits,
454
+ targetTypes: metadata.targetTypes,
455
+ paramsSchema: voidParamsSchema,
456
+ isParameterized: false,
457
+ factory: (() => () => codec),
458
+ ...renderOutputType !== void 0 ? { renderOutputType } : {}
459
+ };
460
+ }
461
+ const renderVectorOutputType = (typeParams) => {
462
+ const length = typeParams["length"];
463
+ if (length === void 0) return void 0;
464
+ if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length) || length <= 0) throw new Error("renderOutputType: expected positive integer \"length\" for Vector");
465
+ return `Vector<${length}>`;
466
+ };
467
+ /**
468
+ * Mongo wire-type codec descriptors. Static metadata for `traits`, `targetTypes`, and `renderOutputType` lives here (the descriptor shape) — `MongoCodec` itself is narrow and only carries the four conversion methods (TML-2357).
469
+ */
470
+ const mongoCodecDescriptors = [
471
+ descriptorFor(mongoObjectIdCodec, {
472
+ traits: ["equality"],
473
+ targetTypes: ["objectId"]
474
+ }),
475
+ descriptorFor(mongoStringCodec, {
476
+ traits: [
477
+ "equality",
478
+ "order",
479
+ "textual"
480
+ ],
481
+ targetTypes: ["string"]
482
+ }),
483
+ descriptorFor(mongoDoubleCodec, {
484
+ traits: [
485
+ "equality",
486
+ "order",
487
+ "numeric"
488
+ ],
489
+ targetTypes: ["double"]
490
+ }),
491
+ descriptorFor(mongoInt32Codec, {
492
+ traits: [
493
+ "equality",
494
+ "order",
495
+ "numeric"
496
+ ],
497
+ targetTypes: ["int"]
498
+ }),
499
+ descriptorFor(mongoBooleanCodec, {
500
+ traits: ["equality", "boolean"],
501
+ targetTypes: ["bool"]
502
+ }),
503
+ descriptorFor(mongoDateCodec, {
504
+ traits: ["equality", "order"],
505
+ targetTypes: ["date"]
506
+ }),
507
+ descriptorFor(mongoVectorCodec, {
508
+ traits: ["equality"],
509
+ targetTypes: ["vector"],
510
+ renderOutputType: renderVectorOutputType
511
+ })
512
+ ];
513
+ /**
514
+ * Build a {@link MongoCodecRegistry} preloaded with the standard Mongo wire-type codecs.
515
+ *
516
+ * Single point of truth for adapter-side codec construction: used by the legacy synchronous `createMongoAdapter()` factory and by the runtime adapter descriptor's `codecs()` getter. Userland code obtains a registry via the framework's execution-stack composition (see `createMongoExecutionContext`) instead of calling this directly.
517
+ */
518
+ function buildStandardCodecRegistry() {
519
+ const registry = newMongoCodecRegistry();
520
+ for (const codec of mongoStandardCodecs) registry.register(codec);
521
+ return registry;
522
+ }
391
523
 
392
524
  //#endregion
393
525
  //#region src/mongo-adapter.ts
@@ -399,27 +531,41 @@ var MongoAdapterImpl = class {
399
531
  constructor(codecs) {
400
532
  this.#codecs = codecs;
401
533
  }
402
- #resolveDocument(expr) {
534
+ async #resolveDocument(expr, ctx) {
535
+ const entries = Object.entries(expr);
536
+ const resolved = await Promise.all(entries.map(([, val]) => resolveValue(val, this.#codecs, ctx)));
403
537
  const result = {};
404
- for (const [key, val] of Object.entries(expr)) result[key] = resolveValue(val, this.#codecs);
538
+ for (let i = 0; i < entries.length; i++) {
539
+ const entry = entries[i];
540
+ if (entry) result[entry[0]] = resolved[i];
541
+ }
405
542
  return result;
406
543
  }
407
- #lowerUpdate(update) {
408
- if (isUpdatePipeline(update)) return update.map((stage) => lowerStage(stage));
409
- return this.#resolveDocument(update);
544
+ async #lowerUpdate(update, ctx) {
545
+ if (isUpdatePipeline(update)) return Promise.all(update.map((stage) => lowerStage(stage, this.#codecs, ctx)));
546
+ return this.#resolveDocument(update, ctx);
410
547
  }
411
- lower(plan) {
548
+ async lower(plan, ctx) {
412
549
  const { command } = plan;
413
550
  switch (command.kind) {
414
- case "insertOne": return new InsertOneWireCommand(command.collection, this.#resolveDocument(command.document));
415
- case "updateOne": return new UpdateOneWireCommand(command.collection, lowerFilter(command.filter), this.#lowerUpdate(command.update), command.upsert);
416
- case "insertMany": return new InsertManyWireCommand(command.collection, command.documents.map((doc) => this.#resolveDocument(doc)));
417
- case "updateMany": return new UpdateManyWireCommand(command.collection, lowerFilter(command.filter), this.#lowerUpdate(command.update), command.upsert);
418
- case "deleteOne": return new DeleteOneWireCommand(command.collection, lowerFilter(command.filter));
419
- case "deleteMany": return new DeleteManyWireCommand(command.collection, lowerFilter(command.filter));
420
- case "findOneAndUpdate": return new FindOneAndUpdateWireCommand(command.collection, lowerFilter(command.filter), this.#lowerUpdate(command.update), command.upsert, command.sort, command.returnDocument);
421
- case "findOneAndDelete": return new FindOneAndDeleteWireCommand(command.collection, lowerFilter(command.filter), command.sort);
422
- case "aggregate": return new AggregateWireCommand(command.collection, lowerPipeline(command.pipeline));
551
+ case "insertOne": return new InsertOneWireCommand(command.collection, await this.#resolveDocument(command.document, ctx));
552
+ case "updateOne": {
553
+ const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
554
+ return new UpdateOneWireCommand(command.collection, filter, update, command.upsert);
555
+ }
556
+ case "insertMany": return new InsertManyWireCommand(command.collection, await Promise.all(command.documents.map((doc) => this.#resolveDocument(doc, ctx))));
557
+ case "updateMany": {
558
+ const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
559
+ return new UpdateManyWireCommand(command.collection, filter, update, command.upsert);
560
+ }
561
+ case "deleteOne": return new DeleteOneWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs, ctx));
562
+ case "deleteMany": return new DeleteManyWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs, ctx));
563
+ case "findOneAndUpdate": {
564
+ const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
565
+ return new FindOneAndUpdateWireCommand(command.collection, filter, update, command.upsert, command.sort, command.returnDocument);
566
+ }
567
+ case "findOneAndDelete": return new FindOneAndDeleteWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs, ctx), command.sort);
568
+ case "aggregate": return new AggregateWireCommand(command.collection, await lowerPipeline(command.pipeline, this.#codecs, ctx));
423
569
  case "rawAggregate": return new AggregateWireCommand(command.collection, command.pipeline);
424
570
  case "rawInsertOne": return new InsertOneWireCommand(command.collection, command.document);
425
571
  case "rawInsertMany": return new InsertManyWireCommand(command.collection, command.documents);
@@ -436,23 +582,19 @@ var MongoAdapterImpl = class {
436
582
  }
437
583
  }
438
584
  };
439
- function defaultCodecRegistry() {
440
- const registry = createMongoCodecRegistry();
441
- for (const codec of [
442
- mongoObjectIdCodec,
443
- mongoStringCodec,
444
- mongoDoubleCodec,
445
- mongoInt32Codec,
446
- mongoBooleanCodec,
447
- mongoDateCodec,
448
- mongoVectorCodec
449
- ]) registry.register(codec);
450
- return registry;
451
- }
452
- function createMongoAdapter(codecs) {
453
- return new MongoAdapterImpl(codecs ?? defaultCodecRegistry());
585
+ /**
586
+ * Construct a Mongo adapter with the standard wire-type codecs registered
587
+ * for encode-side dispatch (`MongoParamRef.codecId` lookups).
588
+ *
589
+ * The runtime-side codec registry the runtime decodes against is composed
590
+ * separately by `createMongoExecutionContext`. This factory exists for
591
+ * direct adapter use (the runtime descriptor's `create(stack)` calls
592
+ * through it). User code should compose a stack/context instead.
593
+ */
594
+ function createMongoAdapter() {
595
+ return new MongoAdapterImpl(buildStandardCodecRegistry());
454
596
  }
455
597
 
456
598
  //#endregion
457
- export { mongoInt32Codec as a, mongoVectorCodec as c, lowerPipeline as d, lowerStage as f, mongoDoubleCodec as i, lowerAggExpr as l, MONGO_VECTOR_CODEC_ID as m, mongoBooleanCodec as n, mongoObjectIdCodec as o, MONGO_INT32_CODEC_ID as p, mongoDateCodec as r, mongoStringCodec as s, createMongoAdapter as t, lowerFilter as u };
458
- //# sourceMappingURL=mongo-adapter-aVo8aZrf.mjs.map
599
+ export { lowerFilter as a, MONGO_VECTOR_CODEC_ID as c, lowerAggExpr as i, buildStandardCodecRegistry as n, lowerPipeline as o, mongoCodecDescriptors as r, lowerStage as s, createMongoAdapter as t };
600
+ //# sourceMappingURL=mongo-adapter-MY7jRJ9i.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo-adapter-MY7jRJ9i.mjs","names":["result: Record<string, unknown>","entries: Array<[string, unknown]>","aggExprLoweringVisitor: MongoAggExprVisitor<unknown>","loweredArgs: unknown","vars: Record<string, unknown>","_exhaustive: never","result: Record<string, unknown>","projection: Record<string, unknown>","lookup: Record<string, unknown>","unwind: Record<string, unknown>","group: Record<string, unknown>","unionWith: Record<string, unknown>","bucket: Record<string, unknown>","bucketAuto: Record<string, unknown>","geoNear: Record<string, unknown>","facet: Record<string, unknown>","graphLookup: Record<string, unknown>","merge: Record<string, unknown>","swf: Record<string, unknown>","output: Record<string, unknown>","densify: Record<string, unknown>","fill: Record<string, unknown>","entry: Record<string, unknown>","search: Record<string, unknown>","searchMeta: Record<string, unknown>","vs: Record<string, unknown>","mongoCodecDescriptors: ReadonlyArray<CodecDescriptor>","#codecs","#resolveDocument","result: Record<string, unknown>","#lowerUpdate","_exhaustive: never"],"sources":["../src/core/codec-ids.ts","../src/resolve-value.ts","../src/lowering.ts","../src/core/codecs.ts","../src/mongo-adapter.ts"],"sourcesContent":["export const MONGO_OBJECTID_CODEC_ID = 'mongo/objectId@1' as const;\nexport const MONGO_STRING_CODEC_ID = 'mongo/string@1' as const;\nexport const MONGO_DOUBLE_CODEC_ID = 'mongo/double@1' as const;\nexport const MONGO_INT32_CODEC_ID = 'mongo/int32@1' as const;\nexport const MONGO_BOOLEAN_CODEC_ID = 'mongo/bool@1' as const;\nexport const MONGO_DATE_CODEC_ID = 'mongo/date@1' as const;\nexport const MONGO_VECTOR_CODEC_ID = 'mongo/vector@1' as const;\n","import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport {\n checkAborted,\n raceAgainstAbort,\n runtimeError,\n} from '@prisma-next/framework-components/runtime';\nimport type { MongoCodecRegistry } from '@prisma-next/mongo-codec';\nimport type { MongoValue } from '@prisma-next/mongo-value';\nimport { MongoParamRef } from '@prisma-next/mongo-value';\n\n/**\n * Resolves a `MongoValue` (which may contain `MongoParamRef` leaves) into the\n * driver-ready wire shape. When a leaf has a `codecId` and the registry has a\n * codec for it, the codec's async `encode` is awaited so codecs may perform\n * asynchronous work (e.g. lookups, key derivations).\n *\n * Object/array nodes dispatch their child resolutions concurrently via\n * `Promise.all` so independent leaves encode in parallel.\n *\n * Codec encode failures are wrapped in a `RUNTIME.ENCODE_FAILED` envelope\n * (mirroring SQL's `wrapEncodeFailure` shape) with `{ label, codec }` details\n * and the original error attached on `cause`. An already-wrapped envelope is\n * re-thrown verbatim so nested resolvers don't double-wrap.\n *\n * `ctx: CodecCallContext` is forwarded verbatim to every\n * `codec.encode(value, ctx)` call. The same `ctx` reference is also passed\n * to nested `resolveValue` invocations so codec authors observe **signal\n * identity** across the entire recursive walk for one `runtime.execute()`.\n *\n * Abort observation (only when `ctx.signal` is provided):\n *\n * - **Already-aborted at entry** — every recursive call pre-checks\n * `ctx.signal.aborted` and short-circuits with\n * `RUNTIME.ABORTED { phase: 'encode' }` before any codec is invoked.\n * - **Mid-flight abort** — each per-level `Promise.all` races against the\n * signal via `raceAgainstAbort`. The runtime returns\n * `RUNTIME.ABORTED { phase: 'encode' }` promptly even if codec bodies\n * ignore the signal; in-flight bodies run to completion in the background\n * (cooperative cancellation, see ADR 204).\n * - `RUNTIME.ENCODE_FAILED` envelopes thrown by a codec body before the\n * runtime sees the abort pass through unchanged (AC-ERR4).\n */\nexport async function resolveValue(\n value: MongoValue,\n codecs: MongoCodecRegistry,\n ctx: CodecCallContext,\n): Promise<unknown> {\n checkAborted(ctx, 'encode');\n const signal = ctx.signal;\n\n if (value instanceof MongoParamRef) {\n if (value.codecId) {\n const codec = codecs.get(value.codecId);\n if (codec?.encode) {\n try {\n // Race even leaf scalar encodes against the signal so a leaf\n // `MongoParamRef` (e.g. a simple field filter, or any leaf reached\n // from `MongoAdapterImpl.#resolveDocument()` outside an enclosing\n // `Promise.all`) surfaces `RUNTIME.ABORTED` promptly instead of\n // blocking on a slow codec body.\n const encoded = codec.encode(value.value, ctx);\n return await raceAgainstAbort(encoded, signal, 'encode');\n } catch (error) {\n wrapEncodeFailure(error, value, codec.id);\n }\n }\n }\n return value.value;\n }\n if (value === null || typeof value !== 'object') {\n return value;\n }\n if (value instanceof Date) {\n return value;\n }\n if (Array.isArray(value)) {\n const tasks = Promise.all(value.map((v) => resolveValue(v, codecs, ctx)));\n return raceAgainstAbort(tasks, signal, 'encode');\n }\n const entries = Object.entries(value);\n const all = Promise.all(entries.map(([, val]) => resolveValue(val, codecs, ctx)));\n const resolved = await raceAgainstAbort(all, signal, 'encode');\n const result: Record<string, unknown> = {};\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n if (entry) {\n result[entry[0]] = resolved[i];\n }\n }\n return result;\n}\n\nfunction paramRefLabel(ref: MongoParamRef, codecId: string): string {\n return ref.name ?? codecId;\n}\n\nfunction isAlreadyEncodeFailure(error: unknown): boolean {\n return (\n error instanceof Error &&\n 'code' in error &&\n (error as Error & { code?: unknown }).code === 'RUNTIME.ENCODE_FAILED'\n );\n}\n\nfunction wrapEncodeFailure(error: unknown, ref: MongoParamRef, codecId: string): never {\n if (isAlreadyEncodeFailure(error)) {\n throw error;\n }\n const label = paramRefLabel(ref, codecId);\n const message = error instanceof Error ? error.message : String(error);\n const wrapped = runtimeError(\n 'RUNTIME.ENCODE_FAILED',\n `Failed to encode parameter ${label} with codec '${codecId}': ${message}`,\n { label, codec: codecId },\n );\n wrapped.cause = error;\n throw wrapped;\n}\n","import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport type { MongoCodecRegistry } from '@prisma-next/mongo-codec';\nimport type {\n MongoAggExpr,\n MongoAggExprVisitor,\n MongoFilterExpr,\n MongoGroupId,\n MongoPipelineStage,\n MongoProjectionValue,\n MongoWindowField,\n} from '@prisma-next/mongo-query-ast/execution';\nimport { isExprArray, isRecordArgs } from '@prisma-next/mongo-query-ast/execution';\nimport type { Document } from '@prisma-next/mongo-value';\nimport { resolveValue } from './resolve-value';\n\n// Biome flags `{ then: ... }` as a thenable object (noThenProperty). Build via Object.fromEntries to avoid.\nconst THEN_KEY = 'then';\n\nfunction condBranch(\n caseOrIf: MongoAggExpr,\n thenExpr: MongoAggExpr,\n elseExpr?: MongoAggExpr,\n): Record<string, unknown> {\n const entries: Array<[string, unknown]> = [\n [elseExpr ? 'if' : 'case', lowerAggExpr(caseOrIf)],\n [THEN_KEY, lowerAggExpr(thenExpr)],\n ];\n if (elseExpr) {\n entries.push(['else', lowerAggExpr(elseExpr)]);\n }\n return Object.fromEntries(entries);\n}\n\nconst aggExprLoweringVisitor: MongoAggExprVisitor<unknown> = {\n fieldRef(expr) {\n return `$${expr.path}`;\n },\n\n literal(expr) {\n return needsLiteralWrap(expr.value) ? { $literal: expr.value } : expr.value;\n },\n\n operator(expr) {\n const { args } = expr;\n let loweredArgs: unknown;\n if (isExprArray(args)) {\n loweredArgs = args.map((a) => lowerAggExpr(a));\n } else if (isRecordArgs(args)) {\n loweredArgs = lowerExprRecord(args);\n } else {\n loweredArgs = lowerAggExpr(args);\n }\n return { [expr.op]: loweredArgs };\n },\n\n accumulator(expr) {\n if (expr.arg === null) {\n return { [expr.op]: {} };\n }\n if (isRecordArgs(expr.arg)) {\n return { [expr.op]: lowerExprRecord(expr.arg) };\n }\n return { [expr.op]: lowerAggExpr(expr.arg) };\n },\n\n cond(expr) {\n return { $cond: condBranch(expr.condition, expr.then_, expr.else_) };\n },\n\n switch_(expr) {\n return {\n $switch: {\n branches: expr.branches.map((b) => condBranch(b.case_, b.then_)),\n default: lowerAggExpr(expr.default_),\n },\n };\n },\n\n filter(expr) {\n return {\n $filter: {\n input: lowerAggExpr(expr.input),\n cond: lowerAggExpr(expr.cond),\n as: expr.as,\n },\n };\n },\n\n map(expr) {\n return {\n $map: {\n input: lowerAggExpr(expr.input),\n in: lowerAggExpr(expr.in_),\n as: expr.as,\n },\n };\n },\n\n reduce(expr) {\n return {\n $reduce: {\n input: lowerAggExpr(expr.input),\n initialValue: lowerAggExpr(expr.initialValue),\n in: lowerAggExpr(expr.in_),\n },\n };\n },\n\n let_(expr) {\n const vars: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(expr.vars)) {\n vars[key] = lowerAggExpr(val);\n }\n return { $let: { vars, in: lowerAggExpr(expr.in_) } };\n },\n\n mergeObjects(expr) {\n return { $mergeObjects: expr.exprs.map((e) => lowerAggExpr(e)) };\n },\n};\n\nfunction needsLiteralWrap(value: unknown): boolean {\n if (typeof value === 'string' && value.startsWith('$')) {\n return true;\n }\n if (Array.isArray(value)) {\n return value.some((v) => needsLiteralWrap(v));\n }\n if (value !== null && typeof value === 'object') {\n return Object.entries(value as Record<string, unknown>).some(\n ([k, v]) => k.startsWith('$') || needsLiteralWrap(v),\n );\n }\n return false;\n}\n\nexport function lowerAggExpr(expr: MongoAggExpr): unknown {\n return expr.accept(aggExprLoweringVisitor);\n}\n\nexport async function lowerFilter(\n filter: MongoFilterExpr,\n codecs: MongoCodecRegistry,\n ctx: CodecCallContext,\n): Promise<Document> {\n switch (filter.kind) {\n case 'field':\n return { [filter.field]: { [filter.op]: await resolveValue(filter.value, codecs, ctx) } };\n case 'and':\n return { $and: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs, ctx))) };\n case 'or':\n return { $or: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs, ctx))) };\n case 'not':\n return { $nor: [await lowerFilter(filter.expr, codecs, ctx)] };\n case 'exists':\n return { [filter.field]: { $exists: filter.exists } };\n case 'expr':\n return { $expr: lowerAggExpr(filter.aggExpr) };\n default: {\n const _exhaustive: never = filter;\n throw new Error(`Unhandled filter kind: ${(_exhaustive as MongoFilterExpr).kind}`);\n }\n }\n}\n\nfunction isAggExprNode(value: object): value is MongoAggExpr {\n return 'accept' in value && typeof value.accept === 'function';\n}\n\nfunction lowerGroupId(groupId: MongoGroupId): unknown {\n if (groupId === null) return null;\n if (isAggExprNode(groupId)) return lowerAggExpr(groupId);\n return lowerExprRecord(groupId);\n}\n\nfunction lowerExprRecord(\n fields: Readonly<Record<string, MongoAggExpr | ReadonlyArray<MongoAggExpr>>>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(fields)) {\n if (Array.isArray(val)) {\n result[key] = val.map((v: MongoAggExpr) => lowerAggExpr(v));\n } else {\n result[key] = lowerAggExpr(val as MongoAggExpr);\n }\n }\n return result;\n}\n\nfunction lowerProjectionValue(value: MongoProjectionValue): unknown {\n if (typeof value === 'number') return value;\n return lowerAggExpr(value);\n}\n\nfunction lowerWindowField(wf: MongoWindowField): Record<string, unknown> {\n const lowered = lowerAggExpr(wf.operator);\n if (typeof lowered !== 'object' || lowered === null) {\n throw new Error('Window field operator must lower to an object');\n }\n const result: Record<string, unknown> = { ...lowered };\n if (wf.window) {\n result['window'] = { ...wf.window };\n }\n return result;\n}\n\nexport async function lowerStage(\n stage: MongoPipelineStage,\n codecs: MongoCodecRegistry,\n ctx: CodecCallContext,\n): Promise<Record<string, unknown>> {\n switch (stage.kind) {\n case 'match':\n return { $match: await lowerFilter(stage.filter, codecs, ctx) };\n case 'project': {\n const projection: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(stage.projection)) {\n projection[key] = lowerProjectionValue(val);\n }\n return { $project: projection };\n }\n case 'sort':\n return { $sort: { ...stage.sort } };\n case 'limit':\n return { $limit: stage.limit };\n case 'skip':\n return { $skip: stage.skip };\n case 'lookup': {\n const lookup: Record<string, unknown> = {\n from: stage.from,\n as: stage.as,\n };\n if (stage.localField !== undefined) lookup['localField'] = stage.localField;\n if (stage.foreignField !== undefined) lookup['foreignField'] = stage.foreignField;\n if (stage.pipeline) {\n lookup['pipeline'] = await Promise.all(\n stage.pipeline.map((s) => lowerStage(s, codecs, ctx)),\n );\n }\n if (stage.let_) {\n lookup['let'] = lowerExprRecord(stage.let_);\n }\n return { $lookup: lookup };\n }\n case 'unwind': {\n const unwind: Record<string, unknown> = {\n path: stage.path,\n preserveNullAndEmptyArrays: stage.preserveNullAndEmptyArrays,\n };\n if (stage.includeArrayIndex !== undefined) {\n unwind['includeArrayIndex'] = stage.includeArrayIndex;\n }\n return { $unwind: unwind };\n }\n case 'group': {\n const group: Record<string, unknown> = { _id: lowerGroupId(stage.groupId) };\n for (const [key, acc] of Object.entries(stage.accumulators)) {\n group[key] = lowerAggExpr(acc);\n }\n return { $group: group };\n }\n case 'addFields':\n return { $addFields: lowerExprRecord(stage.fields) };\n case 'replaceRoot':\n return { $replaceRoot: { newRoot: lowerAggExpr(stage.newRoot) } };\n case 'count':\n return { $count: stage.field };\n case 'sortByCount':\n return { $sortByCount: lowerAggExpr(stage.expr) };\n case 'sample':\n return { $sample: { size: stage.size } };\n case 'redact':\n return { $redact: lowerAggExpr(stage.expr) };\n case 'out':\n return { $out: stage.db ? { db: stage.db, coll: stage.collection } : stage.collection };\n case 'unionWith': {\n const unionWith: Record<string, unknown> = { coll: stage.collection };\n if (stage.pipeline) {\n unionWith['pipeline'] = await Promise.all(\n stage.pipeline.map((s) => lowerStage(s, codecs, ctx)),\n );\n }\n return { $unionWith: unionWith };\n }\n case 'bucket': {\n const bucket: Record<string, unknown> = {\n groupBy: lowerAggExpr(stage.groupBy),\n boundaries: [...stage.boundaries],\n };\n if (stage.default_ !== undefined) bucket['default'] = stage.default_;\n if (stage.output) bucket['output'] = lowerExprRecord(stage.output);\n return { $bucket: bucket };\n }\n case 'bucketAuto': {\n const bucketAuto: Record<string, unknown> = {\n groupBy: lowerAggExpr(stage.groupBy),\n buckets: stage.buckets,\n };\n if (stage.output) bucketAuto['output'] = lowerExprRecord(stage.output);\n if (stage.granularity !== undefined) bucketAuto['granularity'] = stage.granularity;\n return { $bucketAuto: bucketAuto };\n }\n case 'geoNear': {\n const geoNear: Record<string, unknown> = {\n near: stage.near,\n distanceField: stage.distanceField,\n };\n if (stage.spherical !== undefined) geoNear['spherical'] = stage.spherical;\n if (stage.maxDistance !== undefined) geoNear['maxDistance'] = stage.maxDistance;\n if (stage.minDistance !== undefined) geoNear['minDistance'] = stage.minDistance;\n if (stage.query) geoNear['query'] = await lowerFilter(stage.query, codecs, ctx);\n if (stage.key !== undefined) geoNear['key'] = stage.key;\n if (stage.distanceMultiplier !== undefined)\n geoNear['distanceMultiplier'] = stage.distanceMultiplier;\n if (stage.includeLocs !== undefined) geoNear['includeLocs'] = stage.includeLocs;\n return { $geoNear: geoNear };\n }\n case 'facet': {\n const facetEntries = Object.entries(stage.facets);\n const facetPipelines = await Promise.all(\n facetEntries.map(([, pipeline]) =>\n Promise.all(pipeline.map((s) => lowerStage(s, codecs, ctx))),\n ),\n );\n const facet: Record<string, unknown> = {};\n for (let i = 0; i < facetEntries.length; i++) {\n const entry = facetEntries[i];\n if (entry) {\n facet[entry[0]] = facetPipelines[i];\n }\n }\n return { $facet: facet };\n }\n case 'graphLookup': {\n const graphLookup: Record<string, unknown> = {\n from: stage.from,\n startWith: lowerAggExpr(stage.startWith),\n connectFromField: stage.connectFromField,\n connectToField: stage.connectToField,\n as: stage.as,\n };\n if (stage.maxDepth !== undefined) graphLookup['maxDepth'] = stage.maxDepth;\n if (stage.depthField !== undefined) graphLookup['depthField'] = stage.depthField;\n if (stage.restrictSearchWithMatch)\n graphLookup['restrictSearchWithMatch'] = await lowerFilter(\n stage.restrictSearchWithMatch,\n codecs,\n ctx,\n );\n return { $graphLookup: graphLookup };\n }\n case 'merge': {\n const merge: Record<string, unknown> = { into: stage.into };\n if (stage.on !== undefined) merge['on'] = stage.on;\n if (stage.whenMatched !== undefined) {\n merge['whenMatched'] = Array.isArray(stage.whenMatched)\n ? await Promise.all(stage.whenMatched.map((s) => lowerStage(s, codecs, ctx)))\n : stage.whenMatched;\n }\n if (stage.whenNotMatched !== undefined) merge['whenNotMatched'] = stage.whenNotMatched;\n return { $merge: merge };\n }\n case 'setWindowFields': {\n const swf: Record<string, unknown> = {};\n if (stage.partitionBy) swf['partitionBy'] = lowerAggExpr(stage.partitionBy);\n if (stage.sortBy) swf['sortBy'] = { ...stage.sortBy };\n const output: Record<string, unknown> = {};\n for (const [key, wf] of Object.entries(stage.output)) {\n output[key] = lowerWindowField(wf);\n }\n swf['output'] = output;\n return { $setWindowFields: swf };\n }\n case 'densify': {\n const densify: Record<string, unknown> = {\n field: stage.field,\n range: { ...stage.range },\n };\n if (stage.partitionByFields) densify['partitionByFields'] = [...stage.partitionByFields];\n return { $densify: densify };\n }\n case 'fill': {\n const fill: Record<string, unknown> = {};\n if (stage.partitionBy) fill['partitionBy'] = lowerAggExpr(stage.partitionBy);\n if (stage.partitionByFields) fill['partitionByFields'] = [...stage.partitionByFields];\n if (stage.sortBy) fill['sortBy'] = { ...stage.sortBy };\n const output: Record<string, unknown> = {};\n for (const [key, fo] of Object.entries(stage.output)) {\n const entry: Record<string, unknown> = {};\n if (fo.method !== undefined) entry['method'] = fo.method;\n if (fo.value !== undefined) entry['value'] = lowerAggExpr(fo.value);\n output[key] = entry;\n }\n fill['output'] = output;\n return { $fill: fill };\n }\n case 'search': {\n const search: Record<string, unknown> = { ...stage.config };\n if (stage.index !== undefined) search['index'] = stage.index;\n return { $search: search };\n }\n case 'searchMeta': {\n const searchMeta: Record<string, unknown> = { ...stage.config };\n if (stage.index !== undefined) searchMeta['index'] = stage.index;\n return { $searchMeta: searchMeta };\n }\n case 'vectorSearch': {\n const vs: Record<string, unknown> = {\n index: stage.index,\n path: stage.path,\n queryVector: [...stage.queryVector],\n numCandidates: stage.numCandidates,\n limit: stage.limit,\n };\n if (stage.filter) vs['filter'] = { ...stage.filter };\n return { $vectorSearch: vs };\n }\n default: {\n const _exhaustive: never = stage;\n throw new Error(`Unhandled stage kind: ${(_exhaustive as MongoPipelineStage).kind}`);\n }\n }\n}\n\nexport async function lowerPipeline(\n stages: ReadonlyArray<MongoPipelineStage>,\n codecs: MongoCodecRegistry,\n ctx: CodecCallContext,\n): Promise<Array<Record<string, unknown>>> {\n return Promise.all(stages.map((s) => lowerStage(s, codecs, ctx)));\n}\n","import type { CodecDescriptor, CodecTrait } from '@prisma-next/framework-components/codec';\nimport { voidParamsSchema } from '@prisma-next/framework-components/codec';\nimport {\n type MongoCodec,\n type MongoCodecRegistry,\n mongoCodec,\n newMongoCodecRegistry,\n} from '@prisma-next/mongo-codec';\nimport { ObjectId } from 'mongodb';\nimport {\n MONGO_BOOLEAN_CODEC_ID,\n MONGO_DATE_CODEC_ID,\n MONGO_DOUBLE_CODEC_ID,\n MONGO_INT32_CODEC_ID,\n MONGO_OBJECTID_CODEC_ID,\n MONGO_STRING_CODEC_ID,\n MONGO_VECTOR_CODEC_ID,\n} from './codec-ids';\n\nexport const mongoObjectIdCodec = mongoCodec({\n typeId: MONGO_OBJECTID_CODEC_ID,\n decode: (wire: ObjectId) => wire.toHexString(),\n encode: (value: string) => new ObjectId(value),\n});\n\nexport const mongoStringCodec = mongoCodec({\n typeId: MONGO_STRING_CODEC_ID,\n decode: (wire: string) => wire,\n encode: (value: string) => value,\n});\n\nexport const mongoDoubleCodec = mongoCodec({\n typeId: MONGO_DOUBLE_CODEC_ID,\n decode: (wire: number) => wire,\n encode: (value: number) => value,\n});\n\nexport const mongoInt32Codec = mongoCodec({\n typeId: MONGO_INT32_CODEC_ID,\n decode: (wire: number) => wire,\n encode: (value: number) => value,\n});\n\nexport const mongoBooleanCodec = mongoCodec({\n typeId: MONGO_BOOLEAN_CODEC_ID,\n decode: (wire: boolean) => wire,\n encode: (value: boolean) => value,\n});\n\nexport const mongoDateCodec = mongoCodec({\n typeId: MONGO_DATE_CODEC_ID,\n decode: (wire: Date) => wire,\n encode: (value: Date) => value,\n encodeJson: (value: Date) => value.toISOString(),\n decodeJson: (json) => {\n if (typeof json !== 'string') throw new Error('expected ISO date string');\n return new Date(json);\n },\n});\n\nexport const mongoVectorCodec = mongoCodec({\n typeId: MONGO_VECTOR_CODEC_ID,\n decode: (wire: readonly number[]) => wire,\n encode: (value: readonly number[]) => value,\n});\n\n/**\n * The canonical set of Mongo wire-type codecs.\n *\n * Single source of truth for both control- and runtime-plane adapter descriptors. Don't duplicate this list — import it.\n */\nexport const mongoStandardCodecs = [\n mongoObjectIdCodec,\n mongoStringCodec,\n mongoDoubleCodec,\n mongoInt32Codec,\n mongoBooleanCodec,\n mongoDateCodec,\n mongoVectorCodec,\n] as const;\n\n/**\n * Build a {@link CodecDescriptor} for a Mongo wire-type codec.\n *\n * Wraps an existing {@link MongoCodec} instance into a descriptor whose factory hands out the same shared codec. Mongo's full migration to descriptor-first authoring is tracked under TML-2324; for now the descriptor view is composed from the existing `mongoCodec()` outputs.\n */\nfunction descriptorFor<Id extends string>(\n codec: MongoCodec<Id, readonly CodecTrait[]>,\n metadata: {\n readonly traits: readonly CodecTrait[];\n readonly targetTypes: readonly string[];\n readonly renderOutputType?: (typeParams: Record<string, unknown>) => string | undefined;\n },\n): CodecDescriptor {\n // The descriptor's `P` is structurally `Record<string, unknown>` for codecs that take params (Mongo `vector`); non-parameterized codecs ignore the slot. Cast through `unknown` to fit the `CodecDescriptor` slot's `(params: P) => …` typing without leaking a per-codec `P` into the heterogeneous descriptor list.\n const renderOutputType = metadata.renderOutputType as\n | CodecDescriptor['renderOutputType']\n | undefined;\n return {\n codecId: codec.id,\n traits: metadata.traits,\n targetTypes: metadata.targetTypes,\n paramsSchema: voidParamsSchema as CodecDescriptor['paramsSchema'],\n isParameterized: false,\n factory: (() => () => codec) as CodecDescriptor['factory'],\n ...(renderOutputType !== undefined ? { renderOutputType } : {}),\n };\n}\n\nconst renderVectorOutputType = (typeParams: Record<string, unknown>): string | undefined => {\n const length = typeParams['length'];\n if (length === undefined) return undefined;\n if (\n typeof length !== 'number' ||\n !Number.isFinite(length) ||\n !Number.isInteger(length) ||\n length <= 0\n ) {\n throw new Error('renderOutputType: expected positive integer \"length\" for Vector');\n }\n return `Vector<${length}>`;\n};\n\n/**\n * Mongo wire-type codec descriptors. Static metadata for `traits`, `targetTypes`, and `renderOutputType` lives here (the descriptor shape) — `MongoCodec` itself is narrow and only carries the four conversion methods (TML-2357).\n */\nexport const mongoCodecDescriptors: ReadonlyArray<CodecDescriptor> = [\n descriptorFor(mongoObjectIdCodec, { traits: ['equality'], targetTypes: ['objectId'] }),\n descriptorFor(mongoStringCodec, {\n traits: ['equality', 'order', 'textual'],\n targetTypes: ['string'],\n }),\n descriptorFor(mongoDoubleCodec, {\n traits: ['equality', 'order', 'numeric'],\n targetTypes: ['double'],\n }),\n descriptorFor(mongoInt32Codec, {\n traits: ['equality', 'order', 'numeric'],\n targetTypes: ['int'],\n }),\n descriptorFor(mongoBooleanCodec, { traits: ['equality', 'boolean'], targetTypes: ['bool'] }),\n descriptorFor(mongoDateCodec, { traits: ['equality', 'order'], targetTypes: ['date'] }),\n descriptorFor(mongoVectorCodec, {\n traits: ['equality'],\n targetTypes: ['vector'],\n renderOutputType: renderVectorOutputType,\n }),\n];\n\n/**\n * Lookup descriptor metadata by codec id — used by tests and for descriptor-side reads of static metadata.\n */\nexport function mongoDescriptorById(codecId: string): CodecDescriptor | undefined {\n return mongoCodecDescriptors.find((d) => d.codecId === codecId);\n}\n\n/**\n * Build a {@link MongoCodecRegistry} preloaded with the standard Mongo wire-type codecs.\n *\n * Single point of truth for adapter-side codec construction: used by the legacy synchronous `createMongoAdapter()` factory and by the runtime adapter descriptor's `codecs()` getter. Userland code obtains a registry via the framework's execution-stack composition (see `createMongoExecutionContext`) instead of calling this directly.\n */\nexport function buildStandardCodecRegistry(): MongoCodecRegistry {\n const registry = newMongoCodecRegistry();\n for (const codec of mongoStandardCodecs) {\n registry.register(codec);\n }\n return registry;\n}\n","import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport type { MongoCodecRegistry } from '@prisma-next/mongo-codec';\nimport type { MongoAdapter } from '@prisma-next/mongo-lowering';\nimport type {\n MongoQueryPlan,\n MongoUpdatePipelineStage,\n MongoUpdateSpec,\n} from '@prisma-next/mongo-query-ast/execution';\nimport type { Document, MongoExpr } from '@prisma-next/mongo-value';\nimport type { AnyMongoWireCommand } from '@prisma-next/mongo-wire';\nimport {\n AggregateWireCommand,\n DeleteManyWireCommand,\n DeleteOneWireCommand,\n FindOneAndDeleteWireCommand,\n FindOneAndUpdateWireCommand,\n InsertManyWireCommand,\n InsertOneWireCommand,\n UpdateManyWireCommand,\n UpdateOneWireCommand,\n} from '@prisma-next/mongo-wire';\nimport { buildStandardCodecRegistry } from './core/codecs';\nimport { lowerFilter, lowerPipeline, lowerStage } from './lowering';\nimport { resolveValue } from './resolve-value';\n\nfunction isUpdatePipeline(\n update: MongoUpdateSpec,\n): update is ReadonlyArray<MongoUpdatePipelineStage> {\n return Array.isArray(update);\n}\n\nclass MongoAdapterImpl implements MongoAdapter {\n readonly #codecs: MongoCodecRegistry;\n\n constructor(codecs: MongoCodecRegistry) {\n this.#codecs = codecs;\n }\n\n async #resolveDocument(expr: MongoExpr, ctx: CodecCallContext): Promise<Document> {\n const entries = Object.entries(expr);\n const resolved = await Promise.all(\n entries.map(([, val]) => resolveValue(val, this.#codecs, ctx)),\n );\n const result: Record<string, unknown> = {};\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n if (entry) {\n result[entry[0]] = resolved[i];\n }\n }\n return result;\n }\n\n async #lowerUpdate(\n update: MongoUpdateSpec,\n ctx: CodecCallContext,\n ): Promise<Document | ReadonlyArray<Document>> {\n if (isUpdatePipeline(update)) {\n return Promise.all(update.map((stage) => lowerStage(stage, this.#codecs, ctx)));\n }\n return this.#resolveDocument(update, ctx);\n }\n\n async lower(plan: MongoQueryPlan, ctx: CodecCallContext): Promise<AnyMongoWireCommand> {\n const { command } = plan;\n switch (command.kind) {\n case 'insertOne':\n return new InsertOneWireCommand(\n command.collection,\n await this.#resolveDocument(command.document, ctx),\n );\n case 'updateOne': {\n const [filter, update] = await Promise.all([\n lowerFilter(command.filter, this.#codecs, ctx),\n this.#lowerUpdate(command.update, ctx),\n ]);\n return new UpdateOneWireCommand(command.collection, filter, update, command.upsert);\n }\n case 'insertMany':\n return new InsertManyWireCommand(\n command.collection,\n await Promise.all(command.documents.map((doc) => this.#resolveDocument(doc, ctx))),\n );\n case 'updateMany': {\n const [filter, update] = await Promise.all([\n lowerFilter(command.filter, this.#codecs, ctx),\n this.#lowerUpdate(command.update, ctx),\n ]);\n return new UpdateManyWireCommand(command.collection, filter, update, command.upsert);\n }\n case 'deleteOne':\n return new DeleteOneWireCommand(\n command.collection,\n await lowerFilter(command.filter, this.#codecs, ctx),\n );\n case 'deleteMany':\n return new DeleteManyWireCommand(\n command.collection,\n await lowerFilter(command.filter, this.#codecs, ctx),\n );\n case 'findOneAndUpdate': {\n const [filter, update] = await Promise.all([\n lowerFilter(command.filter, this.#codecs, ctx),\n this.#lowerUpdate(command.update, ctx),\n ]);\n return new FindOneAndUpdateWireCommand(\n command.collection,\n filter,\n update,\n command.upsert,\n command.sort,\n command.returnDocument,\n );\n }\n case 'findOneAndDelete':\n return new FindOneAndDeleteWireCommand(\n command.collection,\n await lowerFilter(command.filter, this.#codecs, ctx),\n command.sort,\n );\n case 'aggregate':\n return new AggregateWireCommand(\n command.collection,\n await lowerPipeline(command.pipeline, this.#codecs, ctx),\n );\n case 'rawAggregate':\n return new AggregateWireCommand(command.collection, command.pipeline);\n case 'rawInsertOne':\n return new InsertOneWireCommand(command.collection, command.document);\n case 'rawInsertMany':\n return new InsertManyWireCommand(command.collection, command.documents);\n case 'rawUpdateOne':\n return new UpdateOneWireCommand(command.collection, command.filter, command.update);\n case 'rawUpdateMany':\n return new UpdateManyWireCommand(command.collection, command.filter, command.update);\n case 'rawDeleteOne':\n return new DeleteOneWireCommand(command.collection, command.filter);\n case 'rawDeleteMany':\n return new DeleteManyWireCommand(command.collection, command.filter);\n case 'rawFindOneAndUpdate':\n return new FindOneAndUpdateWireCommand(\n command.collection,\n command.filter,\n command.update,\n command.upsert,\n command.sort,\n command.returnDocument,\n );\n case 'rawFindOneAndDelete':\n return new FindOneAndDeleteWireCommand(command.collection, command.filter, command.sort);\n // v8 ignore next 4\n default: {\n const _exhaustive: never = command;\n throw new Error(`Unknown command kind: ${(_exhaustive as { kind: string }).kind}`);\n }\n }\n }\n}\n\n/**\n * Construct a Mongo adapter with the standard wire-type codecs registered\n * for encode-side dispatch (`MongoParamRef.codecId` lookups).\n *\n * The runtime-side codec registry the runtime decodes against is composed\n * separately by `createMongoExecutionContext`. This factory exists for\n * direct adapter use (the runtime descriptor's `create(stack)` calls\n * through it). User code should compose a stack/context instead.\n */\nexport function createMongoAdapter(): MongoAdapter {\n return new MongoAdapterImpl(buildStandardCodecRegistry());\n}\n\n/**\n * Internal escape hatch — direct adapter construction with a caller-supplied\n * codec registry, used only by adapter unit tests that exercise the\n * encode-side codec-dispatch path with synthetic codecs. Not re-exported\n * from the package's public surface and not for production use; production\n * callers compose a `MongoExecutionStack` and `MongoExecution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QAAQ,QACR,QAAQ,QACR,QAAQ,QACR,QAAQ,MACR,QAAQ,eACT;GACH,KAAK,sBACH,QAAO,IAAI,4BAA4B,QAAQ,YAAY,QAAQ,QAAQ,QAAQ,KAAK;GAE1F,SAAS;IACP,MAAMI,cAAqB;AAC3B,UAAM,IAAI,MAAM,yBAA0B,YAAiC,OAAO;;;;;;;;;;;;;;AAe1F,SAAgB,qBAAmC;AACjD,QAAO,IAAI,iBAAiB,4BAA4B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { MongoCodecRegistry } from "@prisma-next/mongo-codec";
2
+ import { MongoAdapter } from "@prisma-next/mongo-lowering";
3
+ import { RuntimeAdapterDescriptor, RuntimeAdapterInstance } from "@prisma-next/framework-components/execution";
4
+
5
+ //#region src/exports/runtime.d.ts
6
+
7
+ /**
8
+ * adapter-mongo deliberately does NOT import the `MongoRuntimeAdapterDescriptor` type alias from `@prisma-next/mongo-runtime`. The adapter package is downstream of the Mongo runtime package only conceptually; introducing a hard import would create a workspace dependency cycle (`mongo-runtime` consumes the runtime descriptor's `create(stack)` factory; `adapter-mongo` would then need `mongo-runtime` to type the
9
+ * descriptor). The descriptor is shaped to satisfy the framework's `RuntimeAdapterDescriptor` plus the structural `MongoStaticContributions` (`codecs()`) that `@prisma-next/mongo-runtime` narrows to at composition time. This mirrors the `target-postgres` ↔ `sql-runtime` decoupling pattern.
10
+ */
11
+ interface MongoRuntimeAdapterInstance extends RuntimeAdapterInstance<'mongo', 'mongo'>, MongoAdapter {}
12
+ declare const mongoRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<'mongo', 'mongo', MongoRuntimeAdapterInstance> & {
13
+ readonly codecs: () => MongoCodecRegistry;
14
+ };
15
+ //#endregion
16
+ export { mongoRuntimeAdapterDescriptor as default };
17
+ //# sourceMappingURL=runtime.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAMgE;AAWhD;UAFN,2BAAA,SACA,sBAMR,CAAA,OAAA,EAAA,OAAA,CAAA,EALE,YAKF,CAAA;cAHI,6BAKmB,EALY,wBAKZ,CAAA,OAAA,EAAA,OAAA,EAFvB,2BAEuB,CAAA,GAAA;EAAkB,SAAA,MAAA,EAAA,GAAA,GAAlB,kBAAkB"}
@@ -0,0 +1,25 @@
1
+ import { n as buildStandardCodecRegistry, r as mongoCodecDescriptors, t as createMongoAdapter } from "./mongo-adapter-MY7jRJ9i.mjs";
2
+
3
+ //#region src/exports/runtime.ts
4
+ const mongoRuntimeAdapterDescriptor = {
5
+ kind: "adapter",
6
+ id: "mongo",
7
+ familyId: "mongo",
8
+ targetId: "mongo",
9
+ version: "0.0.1",
10
+ types: { codecTypes: { codecDescriptors: mongoCodecDescriptors } },
11
+ codecs: buildStandardCodecRegistry,
12
+ create(_stack) {
13
+ const adapter = createMongoAdapter();
14
+ return {
15
+ familyId: "mongo",
16
+ targetId: "mongo",
17
+ lower: adapter.lower.bind(adapter)
18
+ };
19
+ }
20
+ };
21
+ var runtime_default = mongoRuntimeAdapterDescriptor;
22
+
23
+ //#endregion
24
+ export { runtime_default as default };
25
+ //# sourceMappingURL=runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.mjs","names":["mongoRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<\n 'mongo',\n 'mongo',\n MongoRuntimeAdapterInstance\n> & {\n readonly codecs: () => MongoCodecRegistry;\n}"],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type {\n ExecutionStack,\n RuntimeAdapterDescriptor,\n RuntimeAdapterInstance,\n} from '@prisma-next/framework-components/execution';\nimport type { MongoCodecRegistry } from '@prisma-next/mongo-codec';\nimport type { MongoAdapter } from '@prisma-next/mongo-lowering';\nimport { buildStandardCodecRegistry, mongoCodecDescriptors } from '../core/codecs';\nimport { createMongoAdapter } from '../mongo-adapter';\n\n/**\n * adapter-mongo deliberately does NOT import the `MongoRuntimeAdapterDescriptor` type alias from `@prisma-next/mongo-runtime`. The adapter package is downstream of the Mongo runtime package only conceptually; introducing a hard import would create a workspace dependency cycle (`mongo-runtime` consumes the runtime descriptor's `create(stack)` factory; `adapter-mongo` would then need `mongo-runtime` to type the\n * descriptor). The descriptor is shaped to satisfy the framework's `RuntimeAdapterDescriptor` plus the structural `MongoStaticContributions` (`codecs()`) that `@prisma-next/mongo-runtime` narrows to at composition time. This mirrors the `target-postgres` ↔ `sql-runtime` decoupling pattern.\n */\n\ninterface MongoRuntimeAdapterInstance\n extends RuntimeAdapterInstance<'mongo', 'mongo'>,\n MongoAdapter {}\n\nconst mongoRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<\n 'mongo',\n 'mongo',\n MongoRuntimeAdapterInstance\n> & {\n readonly codecs: () => MongoCodecRegistry;\n} = {\n kind: 'adapter',\n id: 'mongo',\n familyId: 'mongo',\n targetId: 'mongo',\n version: '0.0.1',\n types: {\n codecTypes: {\n codecDescriptors: mongoCodecDescriptors,\n },\n },\n codecs: buildStandardCodecRegistry,\n create(_stack: ExecutionStack<'mongo', 'mongo'>): MongoRuntimeAdapterInstance {\n const adapter = createMongoAdapter();\n return {\n familyId: 'mongo' as const,\n targetId: 'mongo' as const,\n lower: adapter.lower.bind(adapter),\n };\n },\n};\n\nexport default mongoRuntimeAdapterDescriptor;\n"],"mappings":";;;AAmBA,MAAMA,gCAMF;CACF,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO,EACL,YAAY,EACV,kBAAkB,uBACnB,EACF;CACD,QAAQ;CACR,OAAO,QAAuE;EAC5E,MAAM,UAAU,oBAAoB;AACpC,SAAO;GACL,UAAU;GACV,UAAU;GACV,OAAO,QAAQ,MAAM,KAAK,QAAQ;GACnC;;CAEJ;AAED,sBAAe"}