@prisma-next/adapter-mongo 0.5.0-dev.8 → 0.5.0-dev.80

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,10 +1,10 @@
1
1
  import { isExprArray, isRecordArgs } from "@prisma-next/mongo-query-ast/execution";
2
- import { runtimeError } from "@prisma-next/framework-components/runtime";
2
+ import { checkAborted, raceAgainstAbort, runtimeError } from "@prisma-next/framework-components/runtime";
3
3
  import { MongoParamRef } from "@prisma-next/mongo-value";
4
- import { createMongoCodecRegistry, mongoCodec } from "@prisma-next/mongo-codec";
5
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";
6
7
  import { ObjectId } from "mongodb";
7
-
8
8
  //#region src/core/codec-ids.ts
9
9
  const MONGO_OBJECTID_CODEC_ID = "mongo/objectId@1";
10
10
  const MONGO_STRING_CODEC_ID = "mongo/string@1";
@@ -13,7 +13,6 @@ const MONGO_INT32_CODEC_ID = "mongo/int32@1";
13
13
  const MONGO_BOOLEAN_CODEC_ID = "mongo/bool@1";
14
14
  const MONGO_DATE_CODEC_ID = "mongo/date@1";
15
15
  const MONGO_VECTOR_CODEC_ID = "mongo/vector@1";
16
-
17
16
  //#endregion
18
17
  //#region src/resolve-value.ts
19
18
  /**
@@ -29,13 +28,33 @@ const MONGO_VECTOR_CODEC_ID = "mongo/vector@1";
29
28
  * (mirroring SQL's `wrapEncodeFailure` shape) with `{ label, codec }` details
30
29
  * and the original error attached on `cause`. An already-wrapped envelope is
31
30
  * re-thrown verbatim so nested resolvers don't double-wrap.
31
+ *
32
+ * `ctx: CodecCallContext` is forwarded verbatim to every
33
+ * `codec.encode(value, ctx)` call. The same `ctx` reference is also passed
34
+ * to nested `resolveValue` invocations so codec authors observe **signal
35
+ * identity** across the entire recursive walk for one `runtime.execute()`.
36
+ *
37
+ * Abort observation (only when `ctx.signal` is provided):
38
+ *
39
+ * - **Already-aborted at entry** — every recursive call pre-checks
40
+ * `ctx.signal.aborted` and short-circuits with
41
+ * `RUNTIME.ABORTED { phase: 'encode' }` before any codec is invoked.
42
+ * - **Mid-flight abort** — each per-level `Promise.all` races against the
43
+ * signal via `raceAgainstAbort`. The runtime returns
44
+ * `RUNTIME.ABORTED { phase: 'encode' }` promptly even if codec bodies
45
+ * ignore the signal; in-flight bodies run to completion in the background
46
+ * (cooperative cancellation, see ADR 204).
47
+ * - `RUNTIME.ENCODE_FAILED` envelopes thrown by a codec body before the
48
+ * runtime sees the abort pass through unchanged (AC-ERR4).
32
49
  */
33
- async function resolveValue(value, codecs) {
50
+ async function resolveValue(value, codecs, ctx) {
51
+ checkAborted(ctx, "encode");
52
+ const signal = ctx.signal;
34
53
  if (value instanceof MongoParamRef) {
35
- if (value.codecId && codecs) {
54
+ if (value.codecId) {
36
55
  const codec = codecs.get(value.codecId);
37
56
  if (codec?.encode) try {
38
- return await codec.encode(value.value);
57
+ return await raceAgainstAbort(codec.encode(value.value, ctx), signal, "encode");
39
58
  } catch (error) {
40
59
  wrapEncodeFailure(error, value, codec.id);
41
60
  }
@@ -44,9 +63,9 @@ async function resolveValue(value, codecs) {
44
63
  }
45
64
  if (value === null || typeof value !== "object") return value;
46
65
  if (value instanceof Date) return value;
47
- if (Array.isArray(value)) return Promise.all(value.map((v) => resolveValue(v, codecs)));
66
+ if (Array.isArray(value)) return raceAgainstAbort(Promise.all(value.map((v) => resolveValue(v, codecs, ctx))), signal, "encode");
48
67
  const entries = Object.entries(value);
49
- const resolved = await Promise.all(entries.map(([, val]) => resolveValue(val, codecs)));
68
+ const resolved = await raceAgainstAbort(Promise.all(entries.map(([, val]) => resolveValue(val, codecs, ctx))), signal, "encode");
50
69
  const result = {};
51
70
  for (let i = 0; i < entries.length; i++) {
52
71
  const entry = entries[i];
@@ -70,7 +89,6 @@ function wrapEncodeFailure(error, ref, codecId) {
70
89
  wrapped.cause = error;
71
90
  throw wrapped;
72
91
  }
73
-
74
92
  //#endregion
75
93
  //#region src/lowering.ts
76
94
  const THEN_KEY = "then";
@@ -150,18 +168,15 @@ function needsLiteralWrap(value) {
150
168
  function lowerAggExpr(expr) {
151
169
  return expr.accept(aggExprLoweringVisitor);
152
170
  }
153
- async function lowerFilter(filter, codecs) {
171
+ async function lowerFilter(filter, codecs, ctx) {
154
172
  switch (filter.kind) {
155
- case "field": return { [filter.field]: { [filter.op]: await resolveValue(filter.value, codecs) } };
156
- case "and": return { $and: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs))) };
157
- case "or": return { $or: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs))) };
158
- case "not": return { $nor: [await lowerFilter(filter.expr, codecs)] };
173
+ case "field": return { [filter.field]: { [filter.op]: await resolveValue(filter.value, codecs, ctx) } };
174
+ case "and": return { $and: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs, ctx))) };
175
+ case "or": return { $or: await Promise.all(filter.exprs.map((e) => lowerFilter(e, codecs, ctx))) };
176
+ case "not": return { $nor: [await lowerFilter(filter.expr, codecs, ctx)] };
159
177
  case "exists": return { [filter.field]: { $exists: filter.exists } };
160
178
  case "expr": return { $expr: lowerAggExpr(filter.aggExpr) };
161
- default: {
162
- const _exhaustive = filter;
163
- throw new Error(`Unhandled filter kind: ${_exhaustive.kind}`);
164
- }
179
+ default: throw new Error(`Unhandled filter kind: ${filter.kind}`);
165
180
  }
166
181
  }
167
182
  function isAggExprNode(value) {
@@ -189,9 +204,9 @@ function lowerWindowField(wf) {
189
204
  if (wf.window) result["window"] = { ...wf.window };
190
205
  return result;
191
206
  }
192
- async function lowerStage(stage, codecs) {
207
+ async function lowerStage(stage, codecs, ctx) {
193
208
  switch (stage.kind) {
194
- case "match": return { $match: await lowerFilter(stage.filter, codecs) };
209
+ case "match": return { $match: await lowerFilter(stage.filter, codecs, ctx) };
195
210
  case "project": {
196
211
  const projection = {};
197
212
  for (const [key, val] of Object.entries(stage.projection)) projection[key] = lowerProjectionValue(val);
@@ -207,7 +222,7 @@ async function lowerStage(stage, codecs) {
207
222
  };
208
223
  if (stage.localField !== void 0) lookup["localField"] = stage.localField;
209
224
  if (stage.foreignField !== void 0) lookup["foreignField"] = stage.foreignField;
210
- if (stage.pipeline) lookup["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs)));
225
+ if (stage.pipeline) lookup["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs, ctx)));
211
226
  if (stage.let_) lookup["let"] = lowerExprRecord(stage.let_);
212
227
  return { $lookup: lookup };
213
228
  }
@@ -236,7 +251,7 @@ async function lowerStage(stage, codecs) {
236
251
  } : stage.collection };
237
252
  case "unionWith": {
238
253
  const unionWith = { coll: stage.collection };
239
- if (stage.pipeline) unionWith["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs)));
254
+ if (stage.pipeline) unionWith["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs, ctx)));
240
255
  return { $unionWith: unionWith };
241
256
  }
242
257
  case "bucket": {
@@ -265,7 +280,7 @@ async function lowerStage(stage, codecs) {
265
280
  if (stage.spherical !== void 0) geoNear["spherical"] = stage.spherical;
266
281
  if (stage.maxDistance !== void 0) geoNear["maxDistance"] = stage.maxDistance;
267
282
  if (stage.minDistance !== void 0) geoNear["minDistance"] = stage.minDistance;
268
- if (stage.query) geoNear["query"] = await lowerFilter(stage.query, codecs);
283
+ if (stage.query) geoNear["query"] = await lowerFilter(stage.query, codecs, ctx);
269
284
  if (stage.key !== void 0) geoNear["key"] = stage.key;
270
285
  if (stage.distanceMultiplier !== void 0) geoNear["distanceMultiplier"] = stage.distanceMultiplier;
271
286
  if (stage.includeLocs !== void 0) geoNear["includeLocs"] = stage.includeLocs;
@@ -273,7 +288,7 @@ async function lowerStage(stage, codecs) {
273
288
  }
274
289
  case "facet": {
275
290
  const facetEntries = Object.entries(stage.facets);
276
- const facetPipelines = await Promise.all(facetEntries.map(([, pipeline]) => Promise.all(pipeline.map((s) => lowerStage(s, codecs)))));
291
+ const facetPipelines = await Promise.all(facetEntries.map(([, pipeline]) => Promise.all(pipeline.map((s) => lowerStage(s, codecs, ctx)))));
277
292
  const facet = {};
278
293
  for (let i = 0; i < facetEntries.length; i++) {
279
294
  const entry = facetEntries[i];
@@ -291,13 +306,13 @@ async function lowerStage(stage, codecs) {
291
306
  };
292
307
  if (stage.maxDepth !== void 0) graphLookup["maxDepth"] = stage.maxDepth;
293
308
  if (stage.depthField !== void 0) graphLookup["depthField"] = stage.depthField;
294
- if (stage.restrictSearchWithMatch) graphLookup["restrictSearchWithMatch"] = await lowerFilter(stage.restrictSearchWithMatch, codecs);
309
+ if (stage.restrictSearchWithMatch) graphLookup["restrictSearchWithMatch"] = await lowerFilter(stage.restrictSearchWithMatch, codecs, ctx);
295
310
  return { $graphLookup: graphLookup };
296
311
  }
297
312
  case "merge": {
298
313
  const merge = { into: stage.into };
299
314
  if (stage.on !== void 0) merge["on"] = stage.on;
300
- if (stage.whenMatched !== void 0) merge["whenMatched"] = Array.isArray(stage.whenMatched) ? await Promise.all(stage.whenMatched.map((s) => lowerStage(s, codecs))) : stage.whenMatched;
315
+ if (stage.whenMatched !== void 0) merge["whenMatched"] = Array.isArray(stage.whenMatched) ? await Promise.all(stage.whenMatched.map((s) => lowerStage(s, codecs, ctx))) : stage.whenMatched;
301
316
  if (stage.whenNotMatched !== void 0) merge["whenNotMatched"] = stage.whenNotMatched;
302
317
  return { $merge: merge };
303
318
  }
@@ -354,69 +369,41 @@ async function lowerStage(stage, codecs) {
354
369
  if (stage.filter) vs["filter"] = { ...stage.filter };
355
370
  return { $vectorSearch: vs };
356
371
  }
357
- default: {
358
- const _exhaustive = stage;
359
- throw new Error(`Unhandled stage kind: ${_exhaustive.kind}`);
360
- }
372
+ default: throw new Error(`Unhandled stage kind: ${stage.kind}`);
361
373
  }
362
374
  }
363
- async function lowerPipeline(stages, codecs) {
364
- return Promise.all(stages.map((s) => lowerStage(s, codecs)));
375
+ async function lowerPipeline(stages, codecs, ctx) {
376
+ return Promise.all(stages.map((s) => lowerStage(s, codecs, ctx)));
365
377
  }
366
-
367
378
  //#endregion
368
379
  //#region src/core/codecs.ts
369
380
  const mongoObjectIdCodec = mongoCodec({
370
381
  typeId: MONGO_OBJECTID_CODEC_ID,
371
- targetTypes: ["objectId"],
372
- traits: ["equality"],
373
382
  decode: (wire) => wire.toHexString(),
374
383
  encode: (value) => new ObjectId(value)
375
384
  });
376
385
  const mongoStringCodec = mongoCodec({
377
386
  typeId: MONGO_STRING_CODEC_ID,
378
- targetTypes: ["string"],
379
- traits: [
380
- "equality",
381
- "order",
382
- "textual"
383
- ],
384
387
  decode: (wire) => wire,
385
388
  encode: (value) => value
386
389
  });
387
390
  const mongoDoubleCodec = mongoCodec({
388
391
  typeId: MONGO_DOUBLE_CODEC_ID,
389
- targetTypes: ["double"],
390
- traits: [
391
- "equality",
392
- "order",
393
- "numeric"
394
- ],
395
392
  decode: (wire) => wire,
396
393
  encode: (value) => value
397
394
  });
398
395
  const mongoInt32Codec = mongoCodec({
399
396
  typeId: MONGO_INT32_CODEC_ID,
400
- targetTypes: ["int"],
401
- traits: [
402
- "equality",
403
- "order",
404
- "numeric"
405
- ],
406
397
  decode: (wire) => wire,
407
398
  encode: (value) => value
408
399
  });
409
400
  const mongoBooleanCodec = mongoCodec({
410
401
  typeId: MONGO_BOOLEAN_CODEC_ID,
411
- targetTypes: ["bool"],
412
- traits: ["equality", "boolean"],
413
402
  decode: (wire) => wire,
414
403
  encode: (value) => value
415
404
  });
416
405
  const mongoDateCodec = mongoCodec({
417
406
  typeId: MONGO_DATE_CODEC_ID,
418
- targetTypes: ["date"],
419
- traits: ["equality", "order"],
420
407
  decode: (wire) => wire,
421
408
  encode: (value) => value,
422
409
  encodeJson: (value) => value.toISOString(),
@@ -427,18 +414,102 @@ const mongoDateCodec = mongoCodec({
427
414
  });
428
415
  const mongoVectorCodec = mongoCodec({
429
416
  typeId: MONGO_VECTOR_CODEC_ID,
430
- targetTypes: ["vector"],
431
- traits: ["equality"],
432
417
  decode: (wire) => wire,
433
- encode: (value) => value,
434
- renderOutputType: (typeParams) => {
435
- const length = typeParams["length"];
436
- if (length === void 0) return void 0;
437
- if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw new Error("renderOutputType: expected positive integer \"length\" for Vector");
438
- return `Vector<${length}>`;
439
- }
418
+ encode: (value) => value
440
419
  });
441
-
420
+ /**
421
+ * The canonical set of Mongo wire-type codecs.
422
+ *
423
+ * Single source of truth for both control- and runtime-plane adapter descriptors. Don't duplicate this list — import it.
424
+ */
425
+ const mongoStandardCodecs = [
426
+ mongoObjectIdCodec,
427
+ mongoStringCodec,
428
+ mongoDoubleCodec,
429
+ mongoInt32Codec,
430
+ mongoBooleanCodec,
431
+ mongoDateCodec,
432
+ mongoVectorCodec
433
+ ];
434
+ /**
435
+ * Build a {@link CodecDescriptor} for a Mongo wire-type codec.
436
+ *
437
+ * 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.
438
+ */
439
+ function descriptorFor(codec, metadata) {
440
+ const renderOutputType = metadata.renderOutputType;
441
+ return {
442
+ codecId: codec.id,
443
+ traits: metadata.traits,
444
+ targetTypes: metadata.targetTypes,
445
+ paramsSchema: voidParamsSchema,
446
+ isParameterized: false,
447
+ factory: (() => () => codec),
448
+ ...renderOutputType !== void 0 ? { renderOutputType } : {}
449
+ };
450
+ }
451
+ const renderVectorOutputType = (typeParams) => {
452
+ const length = typeParams["length"];
453
+ if (length === void 0) return void 0;
454
+ if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length) || length <= 0) throw new Error("renderOutputType: expected positive integer \"length\" for Vector");
455
+ return `Vector<${length}>`;
456
+ };
457
+ /**
458
+ * 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).
459
+ */
460
+ const mongoCodecDescriptors = [
461
+ descriptorFor(mongoObjectIdCodec, {
462
+ traits: ["equality"],
463
+ targetTypes: ["objectId"]
464
+ }),
465
+ descriptorFor(mongoStringCodec, {
466
+ traits: [
467
+ "equality",
468
+ "order",
469
+ "textual"
470
+ ],
471
+ targetTypes: ["string"]
472
+ }),
473
+ descriptorFor(mongoDoubleCodec, {
474
+ traits: [
475
+ "equality",
476
+ "order",
477
+ "numeric"
478
+ ],
479
+ targetTypes: ["double"]
480
+ }),
481
+ descriptorFor(mongoInt32Codec, {
482
+ traits: [
483
+ "equality",
484
+ "order",
485
+ "numeric"
486
+ ],
487
+ targetTypes: ["int"]
488
+ }),
489
+ descriptorFor(mongoBooleanCodec, {
490
+ traits: ["equality", "boolean"],
491
+ targetTypes: ["bool"]
492
+ }),
493
+ descriptorFor(mongoDateCodec, {
494
+ traits: ["equality", "order"],
495
+ targetTypes: ["date"]
496
+ }),
497
+ descriptorFor(mongoVectorCodec, {
498
+ traits: ["equality"],
499
+ targetTypes: ["vector"],
500
+ renderOutputType: renderVectorOutputType
501
+ })
502
+ ];
503
+ /**
504
+ * Build a {@link MongoCodecRegistry} preloaded with the standard Mongo wire-type codecs.
505
+ *
506
+ * 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.
507
+ */
508
+ function buildStandardCodecRegistry() {
509
+ const registry = newMongoCodecRegistry();
510
+ for (const codec of mongoStandardCodecs) registry.register(codec);
511
+ return registry;
512
+ }
442
513
  //#endregion
443
514
  //#region src/mongo-adapter.ts
444
515
  function isUpdatePipeline(update) {
@@ -449,9 +520,9 @@ var MongoAdapterImpl = class {
449
520
  constructor(codecs) {
450
521
  this.#codecs = codecs;
451
522
  }
452
- async #resolveDocument(expr) {
523
+ async #resolveDocument(expr, ctx) {
453
524
  const entries = Object.entries(expr);
454
- const resolved = await Promise.all(entries.map(([, val]) => resolveValue(val, this.#codecs)));
525
+ const resolved = await Promise.all(entries.map(([, val]) => resolveValue(val, this.#codecs, ctx)));
455
526
  const result = {};
456
527
  for (let i = 0; i < entries.length; i++) {
457
528
  const entry = entries[i];
@@ -459,31 +530,31 @@ var MongoAdapterImpl = class {
459
530
  }
460
531
  return result;
461
532
  }
462
- async #lowerUpdate(update) {
463
- if (isUpdatePipeline(update)) return Promise.all(update.map((stage) => lowerStage(stage, this.#codecs)));
464
- return this.#resolveDocument(update);
533
+ async #lowerUpdate(update, ctx) {
534
+ if (isUpdatePipeline(update)) return Promise.all(update.map((stage) => lowerStage(stage, this.#codecs, ctx)));
535
+ return this.#resolveDocument(update, ctx);
465
536
  }
466
- async lower(plan) {
537
+ async lower(plan, ctx) {
467
538
  const { command } = plan;
468
539
  switch (command.kind) {
469
- case "insertOne": return new InsertOneWireCommand(command.collection, await this.#resolveDocument(command.document));
540
+ case "insertOne": return new InsertOneWireCommand(command.collection, await this.#resolveDocument(command.document, ctx));
470
541
  case "updateOne": {
471
- const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs), this.#lowerUpdate(command.update)]);
542
+ const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
472
543
  return new UpdateOneWireCommand(command.collection, filter, update, command.upsert);
473
544
  }
474
- case "insertMany": return new InsertManyWireCommand(command.collection, await Promise.all(command.documents.map((doc) => this.#resolveDocument(doc))));
545
+ case "insertMany": return new InsertManyWireCommand(command.collection, await Promise.all(command.documents.map((doc) => this.#resolveDocument(doc, ctx))));
475
546
  case "updateMany": {
476
- const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs), this.#lowerUpdate(command.update)]);
547
+ const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
477
548
  return new UpdateManyWireCommand(command.collection, filter, update, command.upsert);
478
549
  }
479
- case "deleteOne": return new DeleteOneWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs));
480
- case "deleteMany": return new DeleteManyWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs));
550
+ case "deleteOne": return new DeleteOneWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs, ctx));
551
+ case "deleteMany": return new DeleteManyWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs, ctx));
481
552
  case "findOneAndUpdate": {
482
- const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs), this.#lowerUpdate(command.update)]);
553
+ const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
483
554
  return new FindOneAndUpdateWireCommand(command.collection, filter, update, command.upsert, command.sort, command.returnDocument);
484
555
  }
485
- case "findOneAndDelete": return new FindOneAndDeleteWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs), command.sort);
486
- case "aggregate": return new AggregateWireCommand(command.collection, await lowerPipeline(command.pipeline, this.#codecs));
556
+ case "findOneAndDelete": return new FindOneAndDeleteWireCommand(command.collection, await lowerFilter(command.filter, this.#codecs, ctx), command.sort);
557
+ case "aggregate": return new AggregateWireCommand(command.collection, await lowerPipeline(command.pipeline, this.#codecs, ctx));
487
558
  case "rawAggregate": return new AggregateWireCommand(command.collection, command.pipeline);
488
559
  case "rawInsertOne": return new InsertOneWireCommand(command.collection, command.document);
489
560
  case "rawInsertMany": return new InsertManyWireCommand(command.collection, command.documents);
@@ -493,30 +564,24 @@ var MongoAdapterImpl = class {
493
564
  case "rawDeleteMany": return new DeleteManyWireCommand(command.collection, command.filter);
494
565
  case "rawFindOneAndUpdate": return new FindOneAndUpdateWireCommand(command.collection, command.filter, command.update, command.upsert, command.sort, command.returnDocument);
495
566
  case "rawFindOneAndDelete": return new FindOneAndDeleteWireCommand(command.collection, command.filter, command.sort);
496
- default: {
497
- const _exhaustive = command;
498
- throw new Error(`Unknown command kind: ${_exhaustive.kind}`);
499
- }
567
+ // v8 ignore next 4
568
+ default: throw new Error(`Unknown command kind: ${command.kind}`);
500
569
  }
501
570
  }
502
571
  };
503
- function defaultCodecRegistry() {
504
- const registry = createMongoCodecRegistry();
505
- for (const codec of [
506
- mongoObjectIdCodec,
507
- mongoStringCodec,
508
- mongoDoubleCodec,
509
- mongoInt32Codec,
510
- mongoBooleanCodec,
511
- mongoDateCodec,
512
- mongoVectorCodec
513
- ]) registry.register(codec);
514
- return registry;
515
- }
516
- function createMongoAdapter(codecs) {
517
- return new MongoAdapterImpl(codecs ?? defaultCodecRegistry());
572
+ /**
573
+ * Construct a Mongo adapter with the standard wire-type codecs registered
574
+ * for encode-side dispatch (`MongoParamRef.codecId` lookups).
575
+ *
576
+ * The runtime-side codec registry the runtime decodes against is composed
577
+ * separately by `createMongoExecutionContext`. This factory exists for
578
+ * direct adapter use (the runtime descriptor's `create(stack)` calls
579
+ * through it). User code should compose a stack/context instead.
580
+ */
581
+ function createMongoAdapter() {
582
+ return new MongoAdapterImpl(buildStandardCodecRegistry());
518
583
  }
519
-
520
584
  //#endregion
521
- 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 };
522
- //# sourceMappingURL=mongo-adapter-B3Mh3rXi.mjs.map
585
+ 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 };
586
+
587
+ //# sourceMappingURL=mongo-adapter-DfCmEYHR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo-adapter-DfCmEYHR.mjs","names":["_exhaustive","#codecs","#resolveDocument","#lowerUpdate","_exhaustive"],"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 `MongoExecutionContext`.\n */\nexport function _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H,OAAO,IAAI,4BACT,QAAQ,YACR,QAAQ,QACR,QAAQ,QACR,QAAQ,QACR,QAAQ,MACR,QAAQ,eACT;GACH,KAAK,uBACH,OAAO,IAAI,4BAA4B,QAAQ,YAAY,QAAQ,QAAQ,QAAQ,KAAK;;GAE1F,SAEE,MAAM,IAAI,MAAM,yBAA0BG,QAAiC,OAAO;;;;;;;;;;;;;AAe1F,SAAgB,qBAAmC;CACjD,OAAO,IAAI,iBAAiB,4BAA4B,CAAC"}
@@ -0,0 +1,16 @@
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
+ * 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
8
+ * 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.
9
+ */
10
+ interface MongoRuntimeAdapterInstance extends RuntimeAdapterInstance<'mongo', 'mongo'>, MongoAdapter {}
11
+ declare const mongoRuntimeAdapterDescriptor: RuntimeAdapterDescriptor<'mongo', 'mongo', MongoRuntimeAdapterInstance> & {
12
+ readonly codecs: () => MongoCodecRegistry;
13
+ };
14
+ //#endregion
15
+ export { mongoRuntimeAdapterDescriptor as default };
16
+ //# sourceMappingURL=runtime.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"mappings":";;;;;;;AAMgE;;UAStD,2BAAA,SACA,sBAAA,oBACN,YAAA;AAAA,cAEE,6BAAA,EAA+B,wBAAA,mBAGnC,2BAAA;EAAA,SAES,MAAA,QAAc,kBAAA;AAAA"}
@@ -0,0 +1,23 @@
1
+ import { n as buildStandardCodecRegistry, r as mongoCodecDescriptors, t as createMongoAdapter } from "./mongo-adapter-DfCmEYHR.mjs";
2
+ //#region src/exports/runtime.ts
3
+ const mongoRuntimeAdapterDescriptor = {
4
+ kind: "adapter",
5
+ id: "mongo",
6
+ familyId: "mongo",
7
+ targetId: "mongo",
8
+ version: "0.0.1",
9
+ types: { codecTypes: { codecDescriptors: mongoCodecDescriptors } },
10
+ codecs: buildStandardCodecRegistry,
11
+ create(_stack) {
12
+ const adapter = createMongoAdapter();
13
+ return {
14
+ familyId: "mongo",
15
+ targetId: "mongo",
16
+ lower: adapter.lower.bind(adapter)
17
+ };
18
+ }
19
+ };
20
+ //#endregion
21
+ export { mongoRuntimeAdapterDescriptor as default };
22
+
23
+ //# sourceMappingURL=runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.mjs","names":[],"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,MAAM,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;EACpC,OAAO;GACL,UAAU;GACV,UAAU;GACV,OAAO,QAAQ,MAAM,KAAK,QAAQ;GACnC;;CAEJ"}