@prisma-next/adapter-mongo 0.5.0-dev.7 → 0.5.0-dev.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/codec-types.d.mts.map +1 -1
- package/dist/codec-types.mjs +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +11 -18
- package/dist/control.mjs.map +1 -1
- package/dist/index.d.mts +16 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{mongo-adapter-aVo8aZrf.mjs → mongo-adapter-DfCmEYHR.mjs} +234 -105
- package/dist/mongo-adapter-DfCmEYHR.mjs.map +1 -0
- package/dist/runtime.d.mts +16 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +23 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +21 -17
- package/src/core/codecs.ts +116 -23
- package/src/core/introspect-schema.ts +6 -1
- package/src/core/operations.ts +3 -3
- package/src/exports/control.ts +2 -18
- package/src/exports/runtime.ts +48 -0
- package/src/lowering.ts +46 -17
- package/src/mongo-adapter.ts +78 -58
- package/src/resolve-value.ts +97 -6
- package/dist/mongo-adapter-aVo8aZrf.mjs.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
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
|
-
|
|
7
8
|
//#region src/core/codec-ids.ts
|
|
8
9
|
const MONGO_OBJECTID_CODEC_ID = "mongo/objectId@1";
|
|
9
10
|
const MONGO_STRING_CODEC_ID = "mongo/string@1";
|
|
@@ -12,25 +13,82 @@ const MONGO_INT32_CODEC_ID = "mongo/int32@1";
|
|
|
12
13
|
const MONGO_BOOLEAN_CODEC_ID = "mongo/bool@1";
|
|
13
14
|
const MONGO_DATE_CODEC_ID = "mongo/date@1";
|
|
14
15
|
const MONGO_VECTOR_CODEC_ID = "mongo/vector@1";
|
|
15
|
-
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/resolve-value.ts
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a `MongoValue` (which may contain `MongoParamRef` leaves) into the
|
|
20
|
+
* driver-ready wire shape. When a leaf has a `codecId` and the registry has a
|
|
21
|
+
* codec for it, the codec's async `encode` is awaited so codecs may perform
|
|
22
|
+
* asynchronous work (e.g. lookups, key derivations).
|
|
23
|
+
*
|
|
24
|
+
* Object/array nodes dispatch their child resolutions concurrently via
|
|
25
|
+
* `Promise.all` so independent leaves encode in parallel.
|
|
26
|
+
*
|
|
27
|
+
* Codec encode failures are wrapped in a `RUNTIME.ENCODE_FAILED` envelope
|
|
28
|
+
* (mirroring SQL's `wrapEncodeFailure` shape) with `{ label, codec }` details
|
|
29
|
+
* and the original error attached on `cause`. An already-wrapped envelope is
|
|
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).
|
|
49
|
+
*/
|
|
50
|
+
async function resolveValue(value, codecs, ctx) {
|
|
51
|
+
checkAborted(ctx, "encode");
|
|
52
|
+
const signal = ctx.signal;
|
|
19
53
|
if (value instanceof MongoParamRef) {
|
|
20
|
-
if (value.codecId
|
|
54
|
+
if (value.codecId) {
|
|
21
55
|
const codec = codecs.get(value.codecId);
|
|
22
|
-
if (codec?.encode)
|
|
56
|
+
if (codec?.encode) try {
|
|
57
|
+
return await raceAgainstAbort(codec.encode(value.value, ctx), signal, "encode");
|
|
58
|
+
} catch (error) {
|
|
59
|
+
wrapEncodeFailure(error, value, codec.id);
|
|
60
|
+
}
|
|
23
61
|
}
|
|
24
62
|
return value.value;
|
|
25
63
|
}
|
|
26
64
|
if (value === null || typeof value !== "object") return value;
|
|
27
65
|
if (value instanceof Date) return value;
|
|
28
|
-
if (Array.isArray(value)) return value.map((v) => resolveValue(v, codecs));
|
|
66
|
+
if (Array.isArray(value)) return raceAgainstAbort(Promise.all(value.map((v) => resolveValue(v, codecs, ctx))), signal, "encode");
|
|
67
|
+
const entries = Object.entries(value);
|
|
68
|
+
const resolved = await raceAgainstAbort(Promise.all(entries.map(([, val]) => resolveValue(val, codecs, ctx))), signal, "encode");
|
|
29
69
|
const result = {};
|
|
30
|
-
for (
|
|
70
|
+
for (let i = 0; i < entries.length; i++) {
|
|
71
|
+
const entry = entries[i];
|
|
72
|
+
if (entry) result[entry[0]] = resolved[i];
|
|
73
|
+
}
|
|
31
74
|
return result;
|
|
32
75
|
}
|
|
33
|
-
|
|
76
|
+
function paramRefLabel(ref, codecId) {
|
|
77
|
+
return ref.name ?? codecId;
|
|
78
|
+
}
|
|
79
|
+
function isAlreadyEncodeFailure(error) {
|
|
80
|
+
return error instanceof Error && "code" in error && error.code === "RUNTIME.ENCODE_FAILED";
|
|
81
|
+
}
|
|
82
|
+
function wrapEncodeFailure(error, ref, codecId) {
|
|
83
|
+
if (isAlreadyEncodeFailure(error)) throw error;
|
|
84
|
+
const label = paramRefLabel(ref, codecId);
|
|
85
|
+
const wrapped = runtimeError("RUNTIME.ENCODE_FAILED", `Failed to encode parameter ${label} with codec '${codecId}': ${error instanceof Error ? error.message : String(error)}`, {
|
|
86
|
+
label,
|
|
87
|
+
codec: codecId
|
|
88
|
+
});
|
|
89
|
+
wrapped.cause = error;
|
|
90
|
+
throw wrapped;
|
|
91
|
+
}
|
|
34
92
|
//#endregion
|
|
35
93
|
//#region src/lowering.ts
|
|
36
94
|
const THEN_KEY = "then";
|
|
@@ -110,18 +168,15 @@ function needsLiteralWrap(value) {
|
|
|
110
168
|
function lowerAggExpr(expr) {
|
|
111
169
|
return expr.accept(aggExprLoweringVisitor);
|
|
112
170
|
}
|
|
113
|
-
function lowerFilter(filter) {
|
|
171
|
+
async function lowerFilter(filter, codecs, ctx) {
|
|
114
172
|
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)] };
|
|
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)] };
|
|
119
177
|
case "exists": return { [filter.field]: { $exists: filter.exists } };
|
|
120
178
|
case "expr": return { $expr: lowerAggExpr(filter.aggExpr) };
|
|
121
|
-
default: {
|
|
122
|
-
const _exhaustive = filter;
|
|
123
|
-
throw new Error(`Unhandled filter kind: ${_exhaustive.kind}`);
|
|
124
|
-
}
|
|
179
|
+
default: throw new Error(`Unhandled filter kind: ${filter.kind}`);
|
|
125
180
|
}
|
|
126
181
|
}
|
|
127
182
|
function isAggExprNode(value) {
|
|
@@ -149,9 +204,9 @@ function lowerWindowField(wf) {
|
|
|
149
204
|
if (wf.window) result["window"] = { ...wf.window };
|
|
150
205
|
return result;
|
|
151
206
|
}
|
|
152
|
-
function lowerStage(stage) {
|
|
207
|
+
async function lowerStage(stage, codecs, ctx) {
|
|
153
208
|
switch (stage.kind) {
|
|
154
|
-
case "match": return { $match: lowerFilter(stage.filter) };
|
|
209
|
+
case "match": return { $match: await lowerFilter(stage.filter, codecs, ctx) };
|
|
155
210
|
case "project": {
|
|
156
211
|
const projection = {};
|
|
157
212
|
for (const [key, val] of Object.entries(stage.projection)) projection[key] = lowerProjectionValue(val);
|
|
@@ -167,7 +222,7 @@ function lowerStage(stage) {
|
|
|
167
222
|
};
|
|
168
223
|
if (stage.localField !== void 0) lookup["localField"] = stage.localField;
|
|
169
224
|
if (stage.foreignField !== void 0) lookup["foreignField"] = stage.foreignField;
|
|
170
|
-
if (stage.pipeline) lookup["pipeline"] = stage.pipeline.map((s) => lowerStage(s));
|
|
225
|
+
if (stage.pipeline) lookup["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs, ctx)));
|
|
171
226
|
if (stage.let_) lookup["let"] = lowerExprRecord(stage.let_);
|
|
172
227
|
return { $lookup: lookup };
|
|
173
228
|
}
|
|
@@ -196,7 +251,7 @@ function lowerStage(stage) {
|
|
|
196
251
|
} : stage.collection };
|
|
197
252
|
case "unionWith": {
|
|
198
253
|
const unionWith = { coll: stage.collection };
|
|
199
|
-
if (stage.pipeline) unionWith["pipeline"] = stage.pipeline.map((s) => lowerStage(s));
|
|
254
|
+
if (stage.pipeline) unionWith["pipeline"] = await Promise.all(stage.pipeline.map((s) => lowerStage(s, codecs, ctx)));
|
|
200
255
|
return { $unionWith: unionWith };
|
|
201
256
|
}
|
|
202
257
|
case "bucket": {
|
|
@@ -225,15 +280,20 @@ function lowerStage(stage) {
|
|
|
225
280
|
if (stage.spherical !== void 0) geoNear["spherical"] = stage.spherical;
|
|
226
281
|
if (stage.maxDistance !== void 0) geoNear["maxDistance"] = stage.maxDistance;
|
|
227
282
|
if (stage.minDistance !== void 0) geoNear["minDistance"] = stage.minDistance;
|
|
228
|
-
if (stage.query) geoNear["query"] = lowerFilter(stage.query);
|
|
283
|
+
if (stage.query) geoNear["query"] = await lowerFilter(stage.query, codecs, ctx);
|
|
229
284
|
if (stage.key !== void 0) geoNear["key"] = stage.key;
|
|
230
285
|
if (stage.distanceMultiplier !== void 0) geoNear["distanceMultiplier"] = stage.distanceMultiplier;
|
|
231
286
|
if (stage.includeLocs !== void 0) geoNear["includeLocs"] = stage.includeLocs;
|
|
232
287
|
return { $geoNear: geoNear };
|
|
233
288
|
}
|
|
234
289
|
case "facet": {
|
|
290
|
+
const facetEntries = Object.entries(stage.facets);
|
|
291
|
+
const facetPipelines = await Promise.all(facetEntries.map(([, pipeline]) => Promise.all(pipeline.map((s) => lowerStage(s, codecs, ctx)))));
|
|
235
292
|
const facet = {};
|
|
236
|
-
for (
|
|
293
|
+
for (let i = 0; i < facetEntries.length; i++) {
|
|
294
|
+
const entry = facetEntries[i];
|
|
295
|
+
if (entry) facet[entry[0]] = facetPipelines[i];
|
|
296
|
+
}
|
|
237
297
|
return { $facet: facet };
|
|
238
298
|
}
|
|
239
299
|
case "graphLookup": {
|
|
@@ -246,13 +306,13 @@ function lowerStage(stage) {
|
|
|
246
306
|
};
|
|
247
307
|
if (stage.maxDepth !== void 0) graphLookup["maxDepth"] = stage.maxDepth;
|
|
248
308
|
if (stage.depthField !== void 0) graphLookup["depthField"] = stage.depthField;
|
|
249
|
-
if (stage.restrictSearchWithMatch) graphLookup["restrictSearchWithMatch"] = lowerFilter(stage.restrictSearchWithMatch);
|
|
309
|
+
if (stage.restrictSearchWithMatch) graphLookup["restrictSearchWithMatch"] = await lowerFilter(stage.restrictSearchWithMatch, codecs, ctx);
|
|
250
310
|
return { $graphLookup: graphLookup };
|
|
251
311
|
}
|
|
252
312
|
case "merge": {
|
|
253
313
|
const merge = { into: stage.into };
|
|
254
314
|
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;
|
|
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;
|
|
256
316
|
if (stage.whenNotMatched !== void 0) merge["whenNotMatched"] = stage.whenNotMatched;
|
|
257
317
|
return { $merge: merge };
|
|
258
318
|
}
|
|
@@ -309,86 +369,147 @@ function lowerStage(stage) {
|
|
|
309
369
|
if (stage.filter) vs["filter"] = { ...stage.filter };
|
|
310
370
|
return { $vectorSearch: vs };
|
|
311
371
|
}
|
|
312
|
-
default: {
|
|
313
|
-
const _exhaustive = stage;
|
|
314
|
-
throw new Error(`Unhandled stage kind: ${_exhaustive.kind}`);
|
|
315
|
-
}
|
|
372
|
+
default: throw new Error(`Unhandled stage kind: ${stage.kind}`);
|
|
316
373
|
}
|
|
317
374
|
}
|
|
318
|
-
function lowerPipeline(stages) {
|
|
319
|
-
return stages.map(lowerStage);
|
|
375
|
+
async function lowerPipeline(stages, codecs, ctx) {
|
|
376
|
+
return Promise.all(stages.map((s) => lowerStage(s, codecs, ctx)));
|
|
320
377
|
}
|
|
321
|
-
|
|
322
378
|
//#endregion
|
|
323
379
|
//#region src/core/codecs.ts
|
|
324
380
|
const mongoObjectIdCodec = mongoCodec({
|
|
325
381
|
typeId: MONGO_OBJECTID_CODEC_ID,
|
|
326
|
-
targetTypes: ["objectId"],
|
|
327
|
-
traits: ["equality"],
|
|
328
382
|
decode: (wire) => wire.toHexString(),
|
|
329
383
|
encode: (value) => new ObjectId(value)
|
|
330
384
|
});
|
|
331
385
|
const mongoStringCodec = mongoCodec({
|
|
332
386
|
typeId: MONGO_STRING_CODEC_ID,
|
|
333
|
-
targetTypes: ["string"],
|
|
334
|
-
traits: [
|
|
335
|
-
"equality",
|
|
336
|
-
"order",
|
|
337
|
-
"textual"
|
|
338
|
-
],
|
|
339
387
|
decode: (wire) => wire,
|
|
340
388
|
encode: (value) => value
|
|
341
389
|
});
|
|
342
390
|
const mongoDoubleCodec = mongoCodec({
|
|
343
391
|
typeId: MONGO_DOUBLE_CODEC_ID,
|
|
344
|
-
targetTypes: ["double"],
|
|
345
|
-
traits: [
|
|
346
|
-
"equality",
|
|
347
|
-
"order",
|
|
348
|
-
"numeric"
|
|
349
|
-
],
|
|
350
392
|
decode: (wire) => wire,
|
|
351
393
|
encode: (value) => value
|
|
352
394
|
});
|
|
353
395
|
const mongoInt32Codec = mongoCodec({
|
|
354
396
|
typeId: MONGO_INT32_CODEC_ID,
|
|
355
|
-
targetTypes: ["int"],
|
|
356
|
-
traits: [
|
|
357
|
-
"equality",
|
|
358
|
-
"order",
|
|
359
|
-
"numeric"
|
|
360
|
-
],
|
|
361
397
|
decode: (wire) => wire,
|
|
362
398
|
encode: (value) => value
|
|
363
399
|
});
|
|
364
400
|
const mongoBooleanCodec = mongoCodec({
|
|
365
401
|
typeId: MONGO_BOOLEAN_CODEC_ID,
|
|
366
|
-
targetTypes: ["bool"],
|
|
367
|
-
traits: ["equality", "boolean"],
|
|
368
402
|
decode: (wire) => wire,
|
|
369
403
|
encode: (value) => value
|
|
370
404
|
});
|
|
371
405
|
const mongoDateCodec = mongoCodec({
|
|
372
406
|
typeId: MONGO_DATE_CODEC_ID,
|
|
373
|
-
targetTypes: ["date"],
|
|
374
|
-
traits: ["equality", "order"],
|
|
375
407
|
decode: (wire) => wire,
|
|
376
|
-
encode: (value) => value
|
|
408
|
+
encode: (value) => value,
|
|
409
|
+
encodeJson: (value) => value.toISOString(),
|
|
410
|
+
decodeJson: (json) => {
|
|
411
|
+
if (typeof json !== "string") throw new Error("expected ISO date string");
|
|
412
|
+
return new Date(json);
|
|
413
|
+
}
|
|
377
414
|
});
|
|
378
415
|
const mongoVectorCodec = mongoCodec({
|
|
379
416
|
typeId: MONGO_VECTOR_CODEC_ID,
|
|
380
|
-
targetTypes: ["vector"],
|
|
381
|
-
traits: ["equality"],
|
|
382
417
|
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
|
-
}
|
|
418
|
+
encode: (value) => value
|
|
390
419
|
});
|
|
391
|
-
|
|
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
|
+
}
|
|
392
513
|
//#endregion
|
|
393
514
|
//#region src/mongo-adapter.ts
|
|
394
515
|
function isUpdatePipeline(update) {
|
|
@@ -399,27 +520,41 @@ var MongoAdapterImpl = class {
|
|
|
399
520
|
constructor(codecs) {
|
|
400
521
|
this.#codecs = codecs;
|
|
401
522
|
}
|
|
402
|
-
#resolveDocument(expr) {
|
|
523
|
+
async #resolveDocument(expr, ctx) {
|
|
524
|
+
const entries = Object.entries(expr);
|
|
525
|
+
const resolved = await Promise.all(entries.map(([, val]) => resolveValue(val, this.#codecs, ctx)));
|
|
403
526
|
const result = {};
|
|
404
|
-
for (
|
|
527
|
+
for (let i = 0; i < entries.length; i++) {
|
|
528
|
+
const entry = entries[i];
|
|
529
|
+
if (entry) result[entry[0]] = resolved[i];
|
|
530
|
+
}
|
|
405
531
|
return result;
|
|
406
532
|
}
|
|
407
|
-
#lowerUpdate(update) {
|
|
408
|
-
if (isUpdatePipeline(update)) return update.map((stage) => lowerStage(stage));
|
|
409
|
-
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);
|
|
410
536
|
}
|
|
411
|
-
lower(plan) {
|
|
537
|
+
async lower(plan, ctx) {
|
|
412
538
|
const { command } = plan;
|
|
413
539
|
switch (command.kind) {
|
|
414
|
-
case "insertOne": return new InsertOneWireCommand(command.collection, this.#resolveDocument(command.document));
|
|
415
|
-
case "updateOne":
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
case "
|
|
420
|
-
case "
|
|
421
|
-
|
|
422
|
-
|
|
540
|
+
case "insertOne": return new InsertOneWireCommand(command.collection, await this.#resolveDocument(command.document, ctx));
|
|
541
|
+
case "updateOne": {
|
|
542
|
+
const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
|
|
543
|
+
return new UpdateOneWireCommand(command.collection, filter, update, command.upsert);
|
|
544
|
+
}
|
|
545
|
+
case "insertMany": return new InsertManyWireCommand(command.collection, await Promise.all(command.documents.map((doc) => this.#resolveDocument(doc, ctx))));
|
|
546
|
+
case "updateMany": {
|
|
547
|
+
const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
|
|
548
|
+
return new UpdateManyWireCommand(command.collection, filter, update, command.upsert);
|
|
549
|
+
}
|
|
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));
|
|
552
|
+
case "findOneAndUpdate": {
|
|
553
|
+
const [filter, update] = await Promise.all([lowerFilter(command.filter, this.#codecs, ctx), this.#lowerUpdate(command.update, ctx)]);
|
|
554
|
+
return new FindOneAndUpdateWireCommand(command.collection, filter, update, command.upsert, command.sort, command.returnDocument);
|
|
555
|
+
}
|
|
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));
|
|
423
558
|
case "rawAggregate": return new AggregateWireCommand(command.collection, command.pipeline);
|
|
424
559
|
case "rawInsertOne": return new InsertOneWireCommand(command.collection, command.document);
|
|
425
560
|
case "rawInsertMany": return new InsertManyWireCommand(command.collection, command.documents);
|
|
@@ -429,30 +564,24 @@ var MongoAdapterImpl = class {
|
|
|
429
564
|
case "rawDeleteMany": return new DeleteManyWireCommand(command.collection, command.filter);
|
|
430
565
|
case "rawFindOneAndUpdate": return new FindOneAndUpdateWireCommand(command.collection, command.filter, command.update, command.upsert, command.sort, command.returnDocument);
|
|
431
566
|
case "rawFindOneAndDelete": return new FindOneAndDeleteWireCommand(command.collection, command.filter, command.sort);
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
throw new Error(`Unknown command kind: ${_exhaustive.kind}`);
|
|
435
|
-
}
|
|
567
|
+
// v8 ignore next 4
|
|
568
|
+
default: throw new Error(`Unknown command kind: ${command.kind}`);
|
|
436
569
|
}
|
|
437
570
|
}
|
|
438
571
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
return registry;
|
|
451
|
-
}
|
|
452
|
-
function createMongoAdapter(codecs) {
|
|
453
|
-
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());
|
|
454
583
|
}
|
|
455
|
-
|
|
456
584
|
//#endregion
|
|
457
|
-
export {
|
|
458
|
-
|
|
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 _unstable_createMongoAdapterWithCodecs(codecs: MongoCodecRegistry): MongoAdapter {\n return new MongoAdapterImpl(codecs);\n}\n"],"mappings":";;;;;;;;AAAA,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,uBAAuB;AACpC,MAAa,yBAAyB;A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M,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"}
|
package/dist/runtime.mjs
ADDED
|
@@ -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
|