@prisma-next/mongo-runtime 0.5.0-dev.28 → 0.5.0-dev.29
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/dist/index.d.mts +21 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
- package/src/mongo-runtime.ts +33 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AfterExecuteResult, AsyncIterableResult, ExecutionPlan, RuntimeMiddleware, RuntimeMiddlewareContext } from "@prisma-next/framework-components/runtime";
|
|
1
|
+
import { AfterExecuteResult, AsyncIterableResult, ExecutionPlan, RuntimeExecuteOptions, RuntimeMiddleware, RuntimeMiddlewareContext } from "@prisma-next/framework-components/runtime";
|
|
2
2
|
import { AnyMongoWireCommand } from "@prisma-next/mongo-wire";
|
|
3
3
|
import { MongoAdapter, MongoDriver } from "@prisma-next/mongo-lowering";
|
|
4
4
|
import { MongoQueryPlan } from "@prisma-next/mongo-query-ast/execution";
|
|
@@ -60,7 +60,26 @@ interface MongoRuntimeOptions {
|
|
|
60
60
|
readonly mode?: 'strict' | 'permissive';
|
|
61
61
|
}
|
|
62
62
|
interface MongoRuntime {
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Execute a `MongoQueryPlan` and return an async iterable of rows.
|
|
65
|
+
*
|
|
66
|
+
* The optional `options.signal` is threaded through
|
|
67
|
+
* `lower → adapter.lower → resolveValue → codec.encode` so codec authors
|
|
68
|
+
* who forward the signal to their underlying SDK get true cancellation
|
|
69
|
+
* of in-flight network calls. The runtime additionally observes the
|
|
70
|
+
* signal at two boundaries:
|
|
71
|
+
*
|
|
72
|
+
* - **Already-aborted at entry** — first `next()` throws
|
|
73
|
+
* `RUNTIME.ABORTED { phase: 'stream' }` before any work is done.
|
|
74
|
+
* (Inherited from `RuntimeCore.execute`.)
|
|
75
|
+
* - **Mid-encode abort** — surfaces as
|
|
76
|
+
* `RUNTIME.ABORTED { phase: 'encode' }` from inside `resolveValue`'s
|
|
77
|
+
* per-level `Promise.all` race.
|
|
78
|
+
*
|
|
79
|
+
* Mongo's read path does not go through codecs (per ADR 204), so there
|
|
80
|
+
* is no `phase: 'decode'` boundary on the Mongo side.
|
|
81
|
+
*/
|
|
82
|
+
execute<Row>(plan: MongoQueryPlan<Row>, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
|
|
64
83
|
close(): Promise<void>;
|
|
65
84
|
}
|
|
66
85
|
declare function createMongoRuntime(options: MongoRuntimeOptions): MongoRuntime;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/mongo-execution-plan.ts","../src/mongo-middleware.ts","../src/mongo-runtime.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAwBA;;;;;;;;ACjBA;AAaA;;;;;;;;AAOK,UDHY,kBCGZ,CAAA,MAAA,OAAA,CAAA,SDHsD,aCGtD,CDHoE,GCGpE,CAAA,CAAA;EAEK,SAAA,OAAA,EDJU,mBCIV;;;;UAtBO,sBAAA,SAA+B;;;ADiBhD;;;;;;;;ACjBA;AAaiB,UAAA,eAAA,SAAwB,iBAAR,CAA0B,kBAA1B,CAAA,CAAA;EAA0B,SAAA,QAAA,CAAA,EAAA,OAAA;EAEpC,aAAA,EAAA,IAAA,EAAA,kBAAA,EAAA,GAAA,EAAyB,sBAAzB,CAAA,EAAkD,OAAlD,CAAA,IAAA,CAAA;EAAyB,KAAA,EAAA,GAAA,EAEvC,MAFuC,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,IAAA,EAGtC,kBAHsC,EAAA,GAAA,EAIvC,sBAJuC,CAAA,EAK3C,OAL2C,CAAA,IAAA,CAAA;EAAyB,YAAA,EAAA,IAAA,EAO/D,kBAP+D,EAAA,MAAA,EAQ7D,kBAR6D,EAAA,GAAA,EAShE,sBATgE,C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jB,iBA+EH,kBAAA,CA/EG,OAAA,EA+EyB,mBA/EzB,CAAA,EA+E+C,YA/E/C"}
|
package/dist/index.mjs
CHANGED
|
@@ -25,9 +25,9 @@ var MongoRuntimeImpl = class extends RuntimeCore {
|
|
|
25
25
|
this.#adapter = options.adapter;
|
|
26
26
|
this.#driver = options.driver;
|
|
27
27
|
}
|
|
28
|
-
async lower(plan) {
|
|
28
|
+
async lower(plan, ctx) {
|
|
29
29
|
return {
|
|
30
|
-
command: await this.#adapter.lower(plan),
|
|
30
|
+
command: await this.#adapter.lower(plan, ctx),
|
|
31
31
|
meta: plan.meta
|
|
32
32
|
};
|
|
33
33
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["#adapter","#driver","ctx: MongoMiddlewareContext"],"sources":["../src/mongo-runtime.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#adapter","#driver","ctx: MongoMiddlewareContext"],"sources":["../src/mongo-runtime.ts"],"sourcesContent":["import type { CodecCallContext } from '@prisma-next/framework-components/codec';\nimport type {\n AsyncIterableResult,\n RuntimeExecuteOptions,\n} from '@prisma-next/framework-components/runtime';\nimport {\n checkMiddlewareCompatibility,\n RuntimeCore,\n} from '@prisma-next/framework-components/runtime';\nimport type { MongoAdapter, MongoDriver } from '@prisma-next/mongo-lowering';\nimport type { MongoQueryPlan } from '@prisma-next/mongo-query-ast/execution';\nimport type { MongoExecutionPlan } from './mongo-execution-plan';\nimport type { MongoMiddleware, MongoMiddlewareContext } from './mongo-middleware';\n\nfunction noop() {}\n\nexport interface MongoRuntimeOptions {\n readonly adapter: MongoAdapter;\n readonly driver: MongoDriver;\n readonly contract: unknown;\n readonly targetId: string;\n readonly middleware?: readonly MongoMiddleware[];\n readonly mode?: 'strict' | 'permissive';\n}\n\nexport interface MongoRuntime {\n /**\n * Execute a `MongoQueryPlan` and return an async iterable of rows.\n *\n * The optional `options.signal` is threaded through\n * `lower → adapter.lower → resolveValue → codec.encode` so codec authors\n * who forward the signal to their underlying SDK get true cancellation\n * of in-flight network calls. The runtime additionally observes the\n * signal at two boundaries:\n *\n * - **Already-aborted at entry** — first `next()` throws\n * `RUNTIME.ABORTED { phase: 'stream' }` before any work is done.\n * (Inherited from `RuntimeCore.execute`.)\n * - **Mid-encode abort** — surfaces as\n * `RUNTIME.ABORTED { phase: 'encode' }` from inside `resolveValue`'s\n * per-level `Promise.all` race.\n *\n * Mongo's read path does not go through codecs (per ADR 204), so there\n * is no `phase: 'decode'` boundary on the Mongo side.\n */\n execute<Row>(\n plan: MongoQueryPlan<Row>,\n options?: RuntimeExecuteOptions,\n ): AsyncIterableResult<Row>;\n close(): Promise<void>;\n}\n\nclass MongoRuntimeImpl\n extends RuntimeCore<MongoQueryPlan, MongoExecutionPlan, MongoMiddleware>\n implements MongoRuntime\n{\n readonly #adapter: MongoAdapter;\n readonly #driver: MongoDriver;\n\n constructor(options: MongoRuntimeOptions) {\n const middleware = options.middleware ? [...options.middleware] : [];\n for (const mw of middleware) {\n checkMiddlewareCompatibility(mw, 'mongo', options.targetId);\n }\n\n const ctx: MongoMiddlewareContext = {\n contract: options.contract,\n mode: options.mode ?? 'strict',\n now: () => Date.now(),\n log: { info: noop, warn: noop, error: noop },\n };\n\n super({ middleware, ctx });\n\n this.#adapter = options.adapter;\n this.#driver = options.driver;\n }\n\n protected override async lower(\n plan: MongoQueryPlan,\n ctx: CodecCallContext,\n ): Promise<MongoExecutionPlan> {\n return {\n command: await this.#adapter.lower(plan, ctx),\n meta: plan.meta,\n };\n }\n\n protected override runDriver(exec: MongoExecutionPlan): AsyncIterable<Record<string, unknown>> {\n return this.#driver.execute<Record<string, unknown>>(exec.command);\n }\n\n override async close(): Promise<void> {\n await this.#driver.close();\n }\n}\n\nexport function createMongoRuntime(options: MongoRuntimeOptions): MongoRuntime {\n return new MongoRuntimeImpl(options);\n}\n"],"mappings":";;;AAcA,SAAS,OAAO;AAsChB,IAAM,mBAAN,cACU,YAEV;CACE,CAASA;CACT,CAASC;CAET,YAAY,SAA8B;EACxC,MAAM,aAAa,QAAQ,aAAa,CAAC,GAAG,QAAQ,WAAW,GAAG,EAAE;AACpE,OAAK,MAAM,MAAM,WACf,8BAA6B,IAAI,SAAS,QAAQ,SAAS;EAG7D,MAAMC,MAA8B;GAClC,UAAU,QAAQ;GAClB,MAAM,QAAQ,QAAQ;GACtB,WAAW,KAAK,KAAK;GACrB,KAAK;IAAE,MAAM;IAAM,MAAM;IAAM,OAAO;IAAM;GAC7C;AAED,QAAM;GAAE;GAAY;GAAK,CAAC;AAE1B,QAAKF,UAAW,QAAQ;AACxB,QAAKC,SAAU,QAAQ;;CAGzB,MAAyB,MACvB,MACA,KAC6B;AAC7B,SAAO;GACL,SAAS,MAAM,MAAKD,QAAS,MAAM,MAAM,IAAI;GAC7C,MAAM,KAAK;GACZ;;CAGH,AAAmB,UAAU,MAAkE;AAC7F,SAAO,MAAKC,OAAQ,QAAiC,KAAK,QAAQ;;CAGpE,MAAe,QAAuB;AACpC,QAAM,MAAKA,OAAQ,OAAO;;;AAI9B,SAAgB,mBAAmB,SAA4C;AAC7E,QAAO,IAAI,iBAAiB,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo-runtime",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "MongoDB runtime implementation for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/contract": "0.5.0-dev.
|
|
9
|
-
"@prisma-next/mongo-
|
|
10
|
-
"@prisma-next/mongo-
|
|
11
|
-
"@prisma-next/framework-components": "0.5.0-dev.
|
|
12
|
-
"@prisma-next/mongo-wire": "0.5.0-dev.
|
|
8
|
+
"@prisma-next/contract": "0.5.0-dev.29",
|
|
9
|
+
"@prisma-next/mongo-query-ast": "0.5.0-dev.29",
|
|
10
|
+
"@prisma-next/mongo-lowering": "0.5.0-dev.29",
|
|
11
|
+
"@prisma-next/framework-components": "0.5.0-dev.29",
|
|
12
|
+
"@prisma-next/mongo-wire": "0.5.0-dev.29"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"mongodb": "^6.16.0",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"tsdown": "0.18.4",
|
|
18
18
|
"typescript": "5.9.3",
|
|
19
19
|
"vitest": "4.0.17",
|
|
20
|
-
"@prisma-next/adapter-mongo": "0.5.0-dev.
|
|
21
|
-
"@prisma-next/middleware-telemetry": "0.5.0-dev.
|
|
22
|
-
"@prisma-next/
|
|
23
|
-
"@prisma-next/mongo
|
|
24
|
-
"@prisma-next/mongo-
|
|
25
|
-
"@prisma-next/mongo-value": "0.5.0-dev.
|
|
26
|
-
"@prisma-next/
|
|
27
|
-
"@prisma-next/
|
|
28
|
-
"@prisma-next/driver-mongo": "0.5.0-dev.28",
|
|
20
|
+
"@prisma-next/adapter-mongo": "0.5.0-dev.29",
|
|
21
|
+
"@prisma-next/middleware-telemetry": "0.5.0-dev.29",
|
|
22
|
+
"@prisma-next/mongo-contract-ts": "0.5.0-dev.29",
|
|
23
|
+
"@prisma-next/family-mongo": "0.5.0-dev.29",
|
|
24
|
+
"@prisma-next/mongo-query-builder": "0.5.0-dev.29",
|
|
25
|
+
"@prisma-next/mongo-value": "0.5.0-dev.29",
|
|
26
|
+
"@prisma-next/driver-mongo": "0.5.0-dev.29",
|
|
27
|
+
"@prisma-next/mongo-contract": "0.5.0-dev.29",
|
|
29
28
|
"@prisma-next/test-utils": "0.0.1",
|
|
30
|
-
"@prisma-next/mongo
|
|
31
|
-
"@prisma-next/
|
|
29
|
+
"@prisma-next/target-mongo": "0.5.0-dev.29",
|
|
30
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
31
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"dist",
|
package/src/mongo-runtime.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CodecCallContext } from '@prisma-next/framework-components/codec';
|
|
2
|
+
import type {
|
|
3
|
+
AsyncIterableResult,
|
|
4
|
+
RuntimeExecuteOptions,
|
|
5
|
+
} from '@prisma-next/framework-components/runtime';
|
|
2
6
|
import {
|
|
3
7
|
checkMiddlewareCompatibility,
|
|
4
8
|
RuntimeCore,
|
|
@@ -20,7 +24,29 @@ export interface MongoRuntimeOptions {
|
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export interface MongoRuntime {
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Execute a `MongoQueryPlan` and return an async iterable of rows.
|
|
29
|
+
*
|
|
30
|
+
* The optional `options.signal` is threaded through
|
|
31
|
+
* `lower → adapter.lower → resolveValue → codec.encode` so codec authors
|
|
32
|
+
* who forward the signal to their underlying SDK get true cancellation
|
|
33
|
+
* of in-flight network calls. The runtime additionally observes the
|
|
34
|
+
* signal at two boundaries:
|
|
35
|
+
*
|
|
36
|
+
* - **Already-aborted at entry** — first `next()` throws
|
|
37
|
+
* `RUNTIME.ABORTED { phase: 'stream' }` before any work is done.
|
|
38
|
+
* (Inherited from `RuntimeCore.execute`.)
|
|
39
|
+
* - **Mid-encode abort** — surfaces as
|
|
40
|
+
* `RUNTIME.ABORTED { phase: 'encode' }` from inside `resolveValue`'s
|
|
41
|
+
* per-level `Promise.all` race.
|
|
42
|
+
*
|
|
43
|
+
* Mongo's read path does not go through codecs (per ADR 204), so there
|
|
44
|
+
* is no `phase: 'decode'` boundary on the Mongo side.
|
|
45
|
+
*/
|
|
46
|
+
execute<Row>(
|
|
47
|
+
plan: MongoQueryPlan<Row>,
|
|
48
|
+
options?: RuntimeExecuteOptions,
|
|
49
|
+
): AsyncIterableResult<Row>;
|
|
24
50
|
close(): Promise<void>;
|
|
25
51
|
}
|
|
26
52
|
|
|
@@ -50,9 +76,12 @@ class MongoRuntimeImpl
|
|
|
50
76
|
this.#driver = options.driver;
|
|
51
77
|
}
|
|
52
78
|
|
|
53
|
-
protected override async lower(
|
|
79
|
+
protected override async lower(
|
|
80
|
+
plan: MongoQueryPlan,
|
|
81
|
+
ctx: CodecCallContext,
|
|
82
|
+
): Promise<MongoExecutionPlan> {
|
|
54
83
|
return {
|
|
55
|
-
command: await this.#adapter.lower(plan),
|
|
84
|
+
command: await this.#adapter.lower(plan, ctx),
|
|
56
85
|
meta: plan.meta,
|
|
57
86
|
};
|
|
58
87
|
}
|