@prisma-next/sql-relational-core 0.5.0-dev.7 → 0.5.0-dev.9
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 +30 -0
- package/dist/{codec-types-DcEITed4.d.mts → codec-types-B2Xdq0Wr.d.mts} +43 -20
- package/dist/codec-types-B2Xdq0Wr.d.mts.map +1 -0
- package/dist/{errors-ChY_dHam.d.mts → errors-CDvhnH7P.d.mts} +2 -2
- package/dist/errors-CDvhnH7P.d.mts.map +1 -0
- package/dist/exports/ast.d.mts +2 -2
- package/dist/exports/ast.mjs +31 -6
- package/dist/exports/ast.mjs.map +1 -1
- package/dist/exports/errors.d.mts +4 -4
- package/dist/exports/plan.d.mts +3 -2
- package/dist/exports/plan.mjs.map +1 -1
- package/dist/exports/query-lane-context.d.mts +2 -2
- package/dist/exports/types.d.mts +5 -4
- package/dist/index.d.mts +8 -7
- package/dist/plan-CRPxW2Jj.d.mts +32 -0
- package/dist/plan-CRPxW2Jj.d.mts.map +1 -0
- package/dist/{query-lane-context-UlR8vOkd.d.mts → query-lane-context-DDRW5NBG.d.mts} +2 -2
- package/dist/{query-lane-context-UlR8vOkd.d.mts.map → query-lane-context-DDRW5NBG.d.mts.map} +1 -1
- package/dist/sql-execution-plan-DY0WvJOW.d.mts +33 -0
- package/dist/sql-execution-plan-DY0WvJOW.d.mts.map +1 -0
- package/dist/types-B5XsBeaT.d.mts +24 -0
- package/dist/types-B5XsBeaT.d.mts.map +1 -0
- package/dist/{types-k9pir8XY.d.mts → types-CG3u534i.d.mts} +12 -17
- package/dist/types-CG3u534i.d.mts.map +1 -0
- package/package.json +10 -10
- package/src/ast/codec-types.ts +91 -41
- package/src/exports/plan.ts +1 -0
- package/src/exports/types.ts +1 -0
- package/src/plan.ts +12 -11
- package/src/runtime-scope.ts +20 -0
- package/src/sql-execution-plan.ts +28 -0
- package/src/types.ts +9 -20
- package/dist/codec-types-DcEITed4.d.mts.map +0 -1
- package/dist/errors-ChY_dHam.d.mts.map +0 -1
- package/dist/plan-Cs65hb-E.d.mts +0 -28
- package/dist/plan-Cs65hb-E.d.mts.map +0 -1
- package/dist/types-k9pir8XY.d.mts.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { d as AnyQueryAst } from "./types-C3Hg-CVz.mjs";
|
|
2
|
+
import { ParamDescriptor } from "@prisma-next/contract/types";
|
|
3
|
+
import { StorageColumn } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { QueryPlan } from "@prisma-next/framework-components/runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/plan.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SQL query plan produced by lanes before lowering.
|
|
10
|
+
*
|
|
11
|
+
* Lanes build ASTs and metadata but do not perform SQL lowering. The `sql`
|
|
12
|
+
* field is absent — `RuntimeCore` (the runtime base class in
|
|
13
|
+
* `@prisma-next/framework-components/runtime`) drives lowering via the
|
|
14
|
+
* SQL adapter and produces a `SqlExecutionPlan`.
|
|
15
|
+
*
|
|
16
|
+
* Extends the framework-level `QueryPlan<Row>` marker (`meta + _row`) and
|
|
17
|
+
* adds SQL-specific fields (`ast`, `params`). The phantom `_row` property
|
|
18
|
+
* (inherited from `QueryPlan`) is what `ResultType<P>` inspects to recover
|
|
19
|
+
* the row type.
|
|
20
|
+
*/
|
|
21
|
+
interface SqlQueryPlan<Row = unknown> extends QueryPlan<Row> {
|
|
22
|
+
readonly ast: AnyQueryAst;
|
|
23
|
+
readonly params: readonly unknown[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Augments the last ParamDescriptor in the array with codecId and nativeType from columnMeta.
|
|
27
|
+
* This is used when building WHERE expressions to ensure param descriptors have type information.
|
|
28
|
+
*/
|
|
29
|
+
declare function augmentDescriptorWithColumnMeta(descriptors: ParamDescriptor[], columnMeta: StorageColumn | undefined): void;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { augmentDescriptorWithColumnMeta as n, SqlQueryPlan as t };
|
|
32
|
+
//# sourceMappingURL=plan-CRPxW2Jj.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-CRPxW2Jj.d.mts","names":[],"sources":["../src/plan.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAkBA;;;;;AASA;;;;;;UATiB,oCAAoC,UAAU;gBAC/C;;;;;;;iBAQA,+BAAA,cACD,+BACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as CodecRegistry } from "./codec-types-B2Xdq0Wr.mjs";
|
|
2
2
|
import { Contract } from "@prisma-next/contract/types";
|
|
3
3
|
import { SqlOperationRegistry } from "@prisma-next/sql-operations";
|
|
4
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
@@ -86,4 +86,4 @@ interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<Sql
|
|
|
86
86
|
}
|
|
87
87
|
//#endregion
|
|
88
88
|
export { JsonSchemaValidationResult as a, MutationDefaultsOptions as c, JsonSchemaValidationError as i, TypeHelperRegistry as l, ExecutionContext as n, JsonSchemaValidatorRegistry as o, JsonSchemaValidateFn as r, MutationDefaultsOp as s, AppliedMutationDefault as t };
|
|
89
|
-
//# sourceMappingURL=query-lane-context-
|
|
89
|
+
//# sourceMappingURL=query-lane-context-DDRW5NBG.d.mts.map
|
package/dist/{query-lane-context-UlR8vOkd.d.mts.map → query-lane-context-DDRW5NBG.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-lane-context-
|
|
1
|
+
{"version":3,"file":"query-lane-context-DDRW5NBG.d.mts","names":[],"sources":["../src/query-lane-context.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AASA;AASA;AAQA;AASiB,KAnCL,kBAAA,GAAqB,MAmCW,CAAA,MAExB,EAAA,OAAA,CAAA;AAKpB;AAEA;AAKA;AAaiB,UArDA,yBAAA,CAqDgB;EAA4B,SAAA,IAAA,EAAA,MAAA;EAAT,SAAA,OAAA,EAAA,MAAA;EAAgC,SAAA,OAAA,EAAA,MAAA;;;;;AAQlE,KApDN,0BAAA,GAoDM;EAKgB,SAAA,KAAA,EAAA,IAAA;CAKD,GAAA;EAAwC,SAAA,KAAA,EAAA,KAAA;EAAd,SAAA,MAAA,EA5Db,aA4Da,CA5DC,yBA4DD,CAAA;CAAa;;;;;KAtD5D,oBAAA,uBAA2C;;;;;;;;UAStC,2BAAA;;oBAEG;;;;KAKR,kBAAA;KAEA,sBAAA;;;;KAKA,uBAAA;eACG;;mBAEI;;;;;;;;;UAUF,mCAAmC,SAAS,cAAc,SAAS;qBAC/D;mBACF;4BACS;;;;;kBAKV;;;;;kCAKgB;;;;;iCAKD,0BAA0B,cAAc"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { d as AnyQueryAst } from "./types-C3Hg-CVz.mjs";
|
|
2
|
+
import { ExecutionPlan } from "@prisma-next/framework-components/runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/sql-execution-plan.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SQL-domain execution plan: a query lowered to the wire-level shape that a
|
|
8
|
+
* SQL driver can run.
|
|
9
|
+
*
|
|
10
|
+
* The plan carries:
|
|
11
|
+
* - `sql` — the rendered SQL text
|
|
12
|
+
* - `params` — the bound parameter list
|
|
13
|
+
* - `ast` — optional pre-lowering AST, retained for telemetry / debugging
|
|
14
|
+
* - `meta` — family-agnostic plan metadata (target, lane, hashes, ...)
|
|
15
|
+
* - `_row` — phantom row type, propagated from the originating `SqlQueryPlan`
|
|
16
|
+
*
|
|
17
|
+
* Extends the framework-level `ExecutionPlan<Row>` marker so generic SPIs
|
|
18
|
+
* (`RuntimeExecutor<SqlExecutionPlan>`, `RuntimeMiddleware<SqlExecutionPlan>`)
|
|
19
|
+
* can be parameterized over it.
|
|
20
|
+
*
|
|
21
|
+
* Co-located with `SqlQueryPlan` (its pre-lowering counterpart) in the lanes
|
|
22
|
+
* layer because lane-level utilities (`RawTemplateFactory`, `RawFactory`,
|
|
23
|
+
* `SqlPlan`) compose against the executable shape and the lanes layer cannot
|
|
24
|
+
* depend on the runtime layer.
|
|
25
|
+
*/
|
|
26
|
+
interface SqlExecutionPlan<Row = unknown> extends ExecutionPlan<Row> {
|
|
27
|
+
readonly sql: string;
|
|
28
|
+
readonly params: readonly unknown[];
|
|
29
|
+
readonly ast?: AnyQueryAst;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { SqlExecutionPlan as t };
|
|
33
|
+
//# sourceMappingURL=sql-execution-plan-DY0WvJOW.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-execution-plan-DY0WvJOW.d.mts","names":[],"sources":["../src/sql-execution-plan.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;;;;;;;;;;;;;;;;;;UAAiB,wCAAwC,cAAc;;;iBAGtD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-DY0WvJOW.mjs";
|
|
2
|
+
import { t as SqlQueryPlan } from "./plan-CRPxW2Jj.mjs";
|
|
3
|
+
import { RuntimeExecutor } from "@prisma-next/framework-components/runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime-scope.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The plan shape accepted by the SQL ORM client and SQL runtime: either a
|
|
9
|
+
* pre-lowering `SqlQueryPlan` (AST + meta) or a post-lowering
|
|
10
|
+
* `SqlExecutionPlan` (sql + params + meta).
|
|
11
|
+
*/
|
|
12
|
+
type SqlOrmPlan = SqlExecutionPlan | SqlQueryPlan;
|
|
13
|
+
/**
|
|
14
|
+
* The minimal SQL-runtime surface that the ORM client and SQL runtime both
|
|
15
|
+
* depend on: the `execute` method of `RuntimeExecutor<SqlOrmPlan>`.
|
|
16
|
+
*
|
|
17
|
+
* Owned by `sql-relational-core` (lanes layer) so both
|
|
18
|
+
* `@prisma-next/sql-runtime` and `@prisma-next/sql-orm-client` consume the
|
|
19
|
+
* same source of truth without a layering inversion.
|
|
20
|
+
*/
|
|
21
|
+
type RuntimeScope = Pick<RuntimeExecutor<SqlOrmPlan>, 'execute'>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SqlOrmPlan as n, RuntimeScope as t };
|
|
24
|
+
//# sourceMappingURL=types-B5XsBeaT.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-B5XsBeaT.d.mts","names":[],"sources":["../src/runtime-scope.ts"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AAUA;;AAAgC,KAVpB,UAAA,GAAa,gBAUO,GAVY,YAUZ;;;;;;;;;KAApB,YAAA,GAAe,KAAK,gBAAgB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as ParamRef,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Contract,
|
|
1
|
+
import { G as ParamRef, h as ColumnRef } from "./types-C3Hg-CVz.mjs";
|
|
2
|
+
import { n as ExecutionContext } from "./query-lane-context-DDRW5NBG.mjs";
|
|
3
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-DY0WvJOW.mjs";
|
|
4
|
+
import { Contract, PlanRefs } from "@prisma-next/contract/types";
|
|
5
5
|
import { ParamSpec } from "@prisma-next/operations";
|
|
6
6
|
import { SqlLoweringSpec } from "@prisma-next/sql-operations";
|
|
7
7
|
import { ExtractFieldOutputTypes, SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
@@ -107,10 +107,11 @@ type HasIncludeManyCapabilities<TContract extends Contract<SqlStorage>> = TContr
|
|
|
107
107
|
jsonAgg: true;
|
|
108
108
|
} ? true : false : false : false : false : false;
|
|
109
109
|
/**
|
|
110
|
-
* SQL-
|
|
111
|
-
*
|
|
110
|
+
* Alias for the SQL-domain executable plan, exposed under the legacy
|
|
111
|
+
* `SqlPlan` name for compatibility with SQL builder/utility call sites.
|
|
112
|
+
* The canonical name is `SqlExecutionPlan` (`./sql-execution-plan`).
|
|
112
113
|
*/
|
|
113
|
-
type SqlPlan<Row = unknown> =
|
|
114
|
+
type SqlPlan<Row = unknown> = SqlExecutionPlan<Row>;
|
|
114
115
|
/**
|
|
115
116
|
* Helper types for extracting contract structure.
|
|
116
117
|
*/
|
|
@@ -167,9 +168,9 @@ interface RawTemplateOptions {
|
|
|
167
168
|
interface RawFunctionOptions extends RawTemplateOptions {
|
|
168
169
|
readonly params: ReadonlyArray<unknown>;
|
|
169
170
|
}
|
|
170
|
-
type RawTemplateFactory = (strings: TemplateStringsArray, ...values: readonly unknown[]) =>
|
|
171
|
+
type RawTemplateFactory = (strings: TemplateStringsArray, ...values: readonly unknown[]) => SqlExecutionPlan;
|
|
171
172
|
interface RawFactory extends RawTemplateFactory {
|
|
172
|
-
(text: string, options: RawFunctionOptions):
|
|
173
|
+
(text: string, options: RawFunctionOptions): SqlExecutionPlan;
|
|
173
174
|
with(options: RawTemplateOptions): RawTemplateFactory;
|
|
174
175
|
}
|
|
175
176
|
interface RuntimeError extends Error {
|
|
@@ -189,12 +190,6 @@ interface BuildOptions {
|
|
|
189
190
|
interface SqlBuilderOptions<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
|
|
190
191
|
readonly context: ExecutionContext<TContract>;
|
|
191
192
|
}
|
|
192
|
-
/**
|
|
193
|
-
* SQL-specific ResultType that works with both Plan and SqlQueryPlan.
|
|
194
|
-
* This extends the core ResultType to also handle SqlQueryPlan.
|
|
195
|
-
* Example: `type Row = ResultType<typeof plan>`
|
|
196
|
-
*/
|
|
197
|
-
type ResultType$1<P> = P extends SqlQueryPlan<infer R> ? R : ResultType<P>;
|
|
198
193
|
//#endregion
|
|
199
|
-
export {
|
|
200
|
-
//# sourceMappingURL=types-
|
|
194
|
+
export { TableKey as C, TableDef as S, TablesOf as T, RawTemplateFactory as _, ComputeColumnJsType as a, SqlBuilderOptions as b, META as c, ModelMetadata as d, OperationTypeSignature as f, RawFunctionOptions as g, RawFactory as h, ColumnsOf as i, Meta as l, OperationsForTypeId as m, BuildParamsMap as n, Expr as o, OperationTypes as p, CodecTypes as r, HasIncludeManyCapabilities as s, BuildOptions as t, ModelDef as u, RawTemplateOptions as v, TableMetadata as w, SqlPlan as x, RuntimeError as y };
|
|
195
|
+
//# sourceMappingURL=types-CG3u534i.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CG3u534i.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAYY,IAAA,GAAO,YAAY;;AAA/B;AAAwC;;KAMnC,mBACe,CAAA,kBAAA,QAAA,CAAS,UAAT,CAAA,EAAA,kBAAA,MAAA,CAAA,GAEhB,SAFgB,CAAA,QAAA,CAAA,SAAA,KAAA,gBAEiC,MAFjC,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,QAEhB,MAEc,MAFd,GAAA,MAAA,GAEgC,MAFhC,CAEuC,CAFvC,CAAA,SAAA;EAAiD,SAAA,OAAA,EAAA;IAEnC,SAAA,KAAA,EAC0B,SAD1B;EAAkB,CAAA;AAAO,CAAA,GAGjC,CAHiC,GAAA,KAAA,EACC,CAAA,MAIhC,MAJgC,GAAA,MAAA,CAAA,GAAA,KAAA;;;;AAI1B;KAOb,oBACwB,CAAA,kBAAT,QAAS,CAAA,UAAA,CAAA,EAAA,kBAAA,MAAA,EAAA,mBAAA,MAAA,CAAA,GAGzB,mBAHyB,CAGL,SAHK,EAGM,SAHN,CAAA,SAAA,KAAA,mBAAA,MAAA,GAIzB,SAJyB,CAAA,QAAA,CAAA,SAAA,KAAA,gBAIwB,MAJxB,CAAA,MAAA,EAAA,OAAA,CAAA,GAKvB,SALuB,GAAA,MAKL,MALK,SAAA,KAAA,cAAA,MAAA,GAMrB,MANqB,CAMd,IANc,CAAA,SAAA;EAAT,SAAA,OAAA,EAAA;IAGI,SAAA,MAAA,EA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A;;;;AAEqC,UA9BpB,QA8BoB,CAAA,aAAA,MAAA,CAAA,CAAA;EAFD,UA3BxB,IAAA,CA2BwB,EA3BjB,aA2BiB,CA3BH,IA2BG,CAAA;;AAKnB,KA7BL,SA6BkB,CAAA,SAIT,EAAA,UA/BT,QA2B+B,CA3BtB,SA2BsB,CAAA,CAAA,GA1BvC,CA0BuC,SAAA,MA1BvB,QA0BuB,CA1Bd,SA0Bc,CAAA,GAzBvC,QAyBuC,CAzB9B,SAyB8B,CAAA,CAzBnB,CAyBmB,CAAA,SAAA;EAS1B,OAAA,EAAA,KAAA,EAAA;AAIjB,CAAA,GAAiB,CAAA,GAAA,KAAA,GAAA,KAAY;AAIZ,UArCA,kBAAA,CAqCiB;EAA4B,SAAA,IAAA,CAAA,EApC5C,QAoC4C;EAAT,SAAA,WAAA,CAAA,EAnC5B,MAmC4B,CAAA,MAAA,EAAA,OAAA,CAAA;EAAgC,SAAA,UAAA,CAAA,EAlC7D,aAkC6D,CAAA,MAAA,CAAA;;AAChD,UAhCpB,kBAAA,SAA2B,kBAgCP,CAAA;EAAjB,SAAA,MAAA,EA/BD,aA+BC,CAAA,OAAA,CAAA;;KA5BR,kBAAA,aACD,wDAEN;UAEY,UAAA,SAAmB;0BACV,qBAAqB;gBAC/B,qBAAqB;;UAGpB,YAAA,SAAqB;;;;qBAIjB;;;;UAKJ,cAAA;;;UAIA,YAAA;oBACG;;UAGH,oCAAoC,SAAS,cAAc,SAAS;oBACjE,iBAAiB"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-relational-core",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "AST types, query lane context, and type utilities for Prisma Next SQL lanes",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.1.29",
|
|
9
9
|
"ts-toolbelt": "^9.6.0",
|
|
10
|
-
"@prisma-next/contract": "0.5.0-dev.
|
|
11
|
-
"@prisma-next/framework-components": "0.5.0-dev.
|
|
12
|
-
"@prisma-next/operations": "0.5.0-dev.
|
|
13
|
-
"@prisma-next/sql-contract": "0.5.0-dev.
|
|
14
|
-
"@prisma-next/sql-operations": "0.5.0-dev.
|
|
15
|
-
"@prisma-next/utils": "0.5.0-dev.
|
|
10
|
+
"@prisma-next/contract": "0.5.0-dev.9",
|
|
11
|
+
"@prisma-next/framework-components": "0.5.0-dev.9",
|
|
12
|
+
"@prisma-next/operations": "0.5.0-dev.9",
|
|
13
|
+
"@prisma-next/sql-contract": "0.5.0-dev.9",
|
|
14
|
+
"@prisma-next/sql-operations": "0.5.0-dev.9",
|
|
15
|
+
"@prisma-next/utils": "0.5.0-dev.9"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"tsdown": "0.18.4",
|
|
19
19
|
"typescript": "5.9.3",
|
|
20
20
|
"vitest": "4.0.17",
|
|
21
|
-
"@prisma-next/sql-contract-ts": "0.5.0-dev.7",
|
|
22
21
|
"@prisma-next/test-utils": "0.0.1",
|
|
23
|
-
"@prisma-next/
|
|
24
|
-
"@prisma-next/tsconfig": "0.0.0"
|
|
22
|
+
"@prisma-next/sql-contract-ts": "0.5.0-dev.9",
|
|
23
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
24
|
+
"@prisma-next/tsdown": "0.0.0"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
package/src/ast/codec-types.ts
CHANGED
|
@@ -46,20 +46,22 @@ export interface CodecMeta {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* SQL codec
|
|
49
|
+
* SQL codec — extends the framework codec base with SQL-specific metadata:
|
|
50
|
+
* driver-native type info (`meta.db.sql.<dialect>.nativeType`) and an
|
|
51
|
+
* optional parameterized-codec descriptor (`paramsSchema` + `init`) for
|
|
52
|
+
* codecs that require type-parameter validation (e.g. `pg/vector@1`).
|
|
50
53
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* and between JS values and contract JSON.
|
|
54
|
+
* See `Codec` in `@prisma-next/framework-components/codec` for the codec
|
|
55
|
+
* contract that this interface extends.
|
|
54
56
|
*/
|
|
55
57
|
export interface Codec<
|
|
56
58
|
Id extends string = string,
|
|
57
59
|
TTraits extends readonly CodecTrait[] = readonly CodecTrait[],
|
|
58
60
|
TWire = unknown,
|
|
59
|
-
|
|
61
|
+
TInput = unknown,
|
|
60
62
|
TParams = Record<string, unknown>,
|
|
61
63
|
THelper = unknown,
|
|
62
|
-
> extends BaseCodec<Id, TTraits, TWire,
|
|
64
|
+
> extends BaseCodec<Id, TTraits, TWire, TInput> {
|
|
63
65
|
readonly meta?: CodecMeta;
|
|
64
66
|
readonly paramsSchema?: Type<TParams>;
|
|
65
67
|
readonly init?: (params: TParams) => THelper;
|
|
@@ -180,30 +182,68 @@ class CodecRegistryImpl implements CodecRegistry {
|
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
/**
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
+
* Conditional bundle for `encodeJson`/`decodeJson`: when `TInput` is
|
|
186
|
+
* structurally assignable to `JsonValue` the identity defaults are
|
|
187
|
+
* sound and both fields are optional; otherwise both fields are
|
|
188
|
+
* required so an author cannot silently produce a non-JSON-safe
|
|
189
|
+
* contract artifact.
|
|
190
|
+
*/
|
|
191
|
+
type JsonRoundTripConfig<TInput> = [TInput] extends [JsonValue]
|
|
192
|
+
? {
|
|
193
|
+
encodeJson?: (value: TInput) => JsonValue;
|
|
194
|
+
decodeJson?: (json: JsonValue) => TInput;
|
|
195
|
+
}
|
|
196
|
+
: {
|
|
197
|
+
encodeJson: (value: TInput) => JsonValue;
|
|
198
|
+
decodeJson: (json: JsonValue) => TInput;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Construct a SQL codec from author functions and optional metadata.
|
|
203
|
+
*
|
|
204
|
+
* Author `encode` and `decode` as sync or async functions; the factory
|
|
205
|
+
* produces a {@link Codec} whose query-time methods follow the boundary
|
|
206
|
+
* contract documented on `Codec`.
|
|
207
|
+
*
|
|
208
|
+
* `encode` is optional — when omitted, an identity default is installed
|
|
209
|
+
* (declaring "the input value already is the wire value", so `TInput` and
|
|
210
|
+
* `TWire` are interchangeable for that codec). `decode` is always
|
|
211
|
+
* required. `encodeJson` and `decodeJson` default to identity **only when
|
|
212
|
+
* `TInput` is assignable to `JsonValue`**; otherwise both are required
|
|
213
|
+
* so the contract artifact stays JSON-safe.
|
|
185
214
|
*/
|
|
186
215
|
export function codec<
|
|
187
216
|
Id extends string,
|
|
188
|
-
const TTraits extends readonly CodecTrait[],
|
|
189
|
-
TWire,
|
|
190
|
-
|
|
217
|
+
const TTraits extends readonly CodecTrait[] = readonly [],
|
|
218
|
+
TWire = unknown,
|
|
219
|
+
TInput = unknown,
|
|
191
220
|
TParams = Record<string, unknown>,
|
|
192
221
|
THelper = unknown,
|
|
193
|
-
>(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
222
|
+
>(
|
|
223
|
+
config: {
|
|
224
|
+
typeId: Id;
|
|
225
|
+
targetTypes: readonly string[];
|
|
226
|
+
encode?: (value: TInput) => TWire | Promise<TWire>;
|
|
227
|
+
decode: (wire: TWire) => TInput | Promise<TInput>;
|
|
228
|
+
meta?: CodecMeta;
|
|
229
|
+
paramsSchema?: Type<TParams>;
|
|
230
|
+
init?: (params: TParams) => THelper;
|
|
231
|
+
traits?: TTraits;
|
|
232
|
+
renderOutputType?: (typeParams: Record<string, unknown>) => string | undefined;
|
|
233
|
+
} & JsonRoundTripConfig<TInput>,
|
|
234
|
+
): Codec<Id, TTraits, TWire, TInput, TParams, THelper> {
|
|
206
235
|
const identity = (v: unknown) => v;
|
|
236
|
+
// The synchronous identity default is only safe when the author has
|
|
237
|
+
// declared "the input is already the wire value" (i.e. TInput == TWire);
|
|
238
|
+
// it returns the value directly, never a Promise.
|
|
239
|
+
const userEncode = config.encode ?? ((value: TInput) => value as unknown as TWire);
|
|
240
|
+
const userDecode = config.decode;
|
|
241
|
+
// The conditional JsonRoundTripConfig narrows TInput|JsonValue at the
|
|
242
|
+
// boundary; widen back to the generic shape inside the factory body.
|
|
243
|
+
const widenedConfig = config as {
|
|
244
|
+
encodeJson?: (value: TInput) => JsonValue;
|
|
245
|
+
decodeJson?: (json: JsonValue) => TInput;
|
|
246
|
+
};
|
|
207
247
|
return {
|
|
208
248
|
id: config.typeId,
|
|
209
249
|
targetTypes: config.targetTypes,
|
|
@@ -215,10 +255,22 @@ export function codec<
|
|
|
215
255
|
config.traits ? (Object.freeze([...config.traits]) as TTraits) : undefined,
|
|
216
256
|
),
|
|
217
257
|
...ifDefined('renderOutputType', config.renderOutputType),
|
|
218
|
-
encode:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
258
|
+
encode: (value) => {
|
|
259
|
+
try {
|
|
260
|
+
return Promise.resolve(userEncode(value));
|
|
261
|
+
} catch (error) {
|
|
262
|
+
return Promise.reject(error);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
decode: (wire) => {
|
|
266
|
+
try {
|
|
267
|
+
return Promise.resolve(userDecode(wire));
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return Promise.reject(error);
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
encodeJson: (widenedConfig.encodeJson ?? identity) as (value: TInput) => JsonValue,
|
|
273
|
+
decodeJson: (widenedConfig.decodeJson ?? identity) as (json: JsonValue) => TInput,
|
|
222
274
|
};
|
|
223
275
|
}
|
|
224
276
|
|
|
@@ -228,9 +280,7 @@ export function codec<
|
|
|
228
280
|
export type CodecId<T> =
|
|
229
281
|
T extends Codec<infer Id> ? Id : T extends { readonly id: infer Id } ? Id : never;
|
|
230
282
|
export type CodecInput<T> =
|
|
231
|
-
T extends Codec<string, readonly CodecTrait[], unknown, infer
|
|
232
|
-
export type CodecOutput<T> =
|
|
233
|
-
T extends Codec<string, readonly CodecTrait[], unknown, infer JsT> ? JsT : never;
|
|
283
|
+
T extends Codec<string, readonly CodecTrait[], unknown, infer In> ? In : never;
|
|
234
284
|
export type CodecTraits<T> =
|
|
235
285
|
T extends Codec<string, infer TTraits> ? TTraits[number] & CodecTrait : never;
|
|
236
286
|
|
|
@@ -242,7 +292,7 @@ export type ExtractCodecTypes<
|
|
|
242
292
|
> = {
|
|
243
293
|
readonly [K in keyof ScalarNames as ScalarNames[K] extends Codec<infer Id> ? Id : never]: {
|
|
244
294
|
readonly input: CodecInput<ScalarNames[K]>;
|
|
245
|
-
readonly output:
|
|
295
|
+
readonly output: CodecInput<ScalarNames[K]>;
|
|
246
296
|
readonly traits: CodecTraits<ScalarNames[K]>;
|
|
247
297
|
};
|
|
248
298
|
};
|
|
@@ -283,8 +333,8 @@ export interface CodecDefBuilder<
|
|
|
283
333
|
readonly scalar: K;
|
|
284
334
|
readonly codec: ScalarNames[K];
|
|
285
335
|
readonly input: CodecInput<ScalarNames[K]>;
|
|
286
|
-
readonly output:
|
|
287
|
-
readonly jsType:
|
|
336
|
+
readonly output: CodecInput<ScalarNames[K]>;
|
|
337
|
+
readonly jsType: CodecInput<ScalarNames[K]>;
|
|
288
338
|
};
|
|
289
339
|
};
|
|
290
340
|
|
|
@@ -323,7 +373,7 @@ class CodecDefBuilderImpl<
|
|
|
323
373
|
const codecImplTyped = codecImpl as Codec<string>;
|
|
324
374
|
codecTypes[codecImplTyped.id] = {
|
|
325
375
|
input: undefined as unknown as CodecInput<typeof codecImplTyped>,
|
|
326
|
-
output: undefined as unknown as
|
|
376
|
+
output: undefined as unknown as CodecInput<typeof codecImplTyped>,
|
|
327
377
|
traits: undefined as unknown as CodecTraits<typeof codecImplTyped>,
|
|
328
378
|
};
|
|
329
379
|
}
|
|
@@ -368,8 +418,8 @@ class CodecDefBuilderImpl<
|
|
|
368
418
|
readonly scalar: K;
|
|
369
419
|
readonly codec: ScalarNames[K];
|
|
370
420
|
readonly input: CodecInput<ScalarNames[K]>;
|
|
371
|
-
readonly output:
|
|
372
|
-
readonly jsType:
|
|
421
|
+
readonly output: CodecInput<ScalarNames[K]>;
|
|
422
|
+
readonly jsType: CodecInput<ScalarNames[K]>;
|
|
373
423
|
};
|
|
374
424
|
} {
|
|
375
425
|
const result: Record<
|
|
@@ -391,8 +441,8 @@ class CodecDefBuilderImpl<
|
|
|
391
441
|
scalar: scalarName,
|
|
392
442
|
codec: codec,
|
|
393
443
|
input: undefined as unknown as CodecInput<typeof codec>,
|
|
394
|
-
output: undefined as unknown as
|
|
395
|
-
jsType: undefined as unknown as
|
|
444
|
+
output: undefined as unknown as CodecInput<typeof codec>,
|
|
445
|
+
jsType: undefined as unknown as CodecInput<typeof codec>,
|
|
396
446
|
};
|
|
397
447
|
}
|
|
398
448
|
|
|
@@ -402,8 +452,8 @@ class CodecDefBuilderImpl<
|
|
|
402
452
|
readonly scalar: K;
|
|
403
453
|
readonly codec: ScalarNames[K];
|
|
404
454
|
readonly input: CodecInput<ScalarNames[K]>;
|
|
405
|
-
readonly output:
|
|
406
|
-
readonly jsType:
|
|
455
|
+
readonly output: CodecInput<ScalarNames[K]>;
|
|
456
|
+
readonly jsType: CodecInput<ScalarNames[K]>;
|
|
407
457
|
};
|
|
408
458
|
};
|
|
409
459
|
}
|
package/src/exports/plan.ts
CHANGED
package/src/exports/types.ts
CHANGED
package/src/plan.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ParamDescriptor } from '@prisma-next/contract/types';
|
|
2
|
+
import type { QueryPlan } from '@prisma-next/framework-components/runtime';
|
|
2
3
|
import type { StorageColumn } from '@prisma-next/sql-contract/types';
|
|
3
4
|
import type { AnyQueryAst } from './ast/types';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* SQL query plan produced by lanes before lowering.
|
|
7
8
|
*
|
|
8
|
-
* Lanes build ASTs and metadata but do not perform SQL lowering.
|
|
9
|
-
*
|
|
9
|
+
* Lanes build ASTs and metadata but do not perform SQL lowering. The `sql`
|
|
10
|
+
* field is absent — `RuntimeCore` (the runtime base class in
|
|
11
|
+
* `@prisma-next/framework-components/runtime`) drives lowering via the
|
|
12
|
+
* SQL adapter and produces a `SqlExecutionPlan`.
|
|
10
13
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Extends the framework-level `QueryPlan<Row>` marker (`meta + _row`) and
|
|
15
|
+
* adds SQL-specific fields (`ast`, `params`). The phantom `_row` property
|
|
16
|
+
* (inherited from `QueryPlan`) is what `ResultType<P>` inspects to recover
|
|
17
|
+
* the row type.
|
|
14
18
|
*/
|
|
15
|
-
export interface SqlQueryPlan<
|
|
16
|
-
extends Pick<ExecutionPlan<_Row, AnyQueryAst>, 'params' | 'meta'> {
|
|
19
|
+
export interface SqlQueryPlan<Row = unknown> extends QueryPlan<Row> {
|
|
17
20
|
readonly ast: AnyQueryAst;
|
|
18
|
-
|
|
19
|
-
// This allows ResultType to extract _Row for SqlQueryPlan values.
|
|
20
|
-
readonly _Row?: _Row;
|
|
21
|
+
readonly params: readonly unknown[];
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RuntimeExecutor } from '@prisma-next/framework-components/runtime';
|
|
2
|
+
import type { SqlQueryPlan } from './plan';
|
|
3
|
+
import type { SqlExecutionPlan } from './sql-execution-plan';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The plan shape accepted by the SQL ORM client and SQL runtime: either a
|
|
7
|
+
* pre-lowering `SqlQueryPlan` (AST + meta) or a post-lowering
|
|
8
|
+
* `SqlExecutionPlan` (sql + params + meta).
|
|
9
|
+
*/
|
|
10
|
+
export type SqlOrmPlan = SqlExecutionPlan | SqlQueryPlan;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The minimal SQL-runtime surface that the ORM client and SQL runtime both
|
|
14
|
+
* depend on: the `execute` method of `RuntimeExecutor<SqlOrmPlan>`.
|
|
15
|
+
*
|
|
16
|
+
* Owned by `sql-relational-core` (lanes layer) so both
|
|
17
|
+
* `@prisma-next/sql-runtime` and `@prisma-next/sql-orm-client` consume the
|
|
18
|
+
* same source of truth without a layering inversion.
|
|
19
|
+
*/
|
|
20
|
+
export type RuntimeScope = Pick<RuntimeExecutor<SqlOrmPlan>, 'execute'>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ExecutionPlan } from '@prisma-next/framework-components/runtime';
|
|
2
|
+
import type { AnyQueryAst } from './ast/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SQL-domain execution plan: a query lowered to the wire-level shape that a
|
|
6
|
+
* SQL driver can run.
|
|
7
|
+
*
|
|
8
|
+
* The plan carries:
|
|
9
|
+
* - `sql` — the rendered SQL text
|
|
10
|
+
* - `params` — the bound parameter list
|
|
11
|
+
* - `ast` — optional pre-lowering AST, retained for telemetry / debugging
|
|
12
|
+
* - `meta` — family-agnostic plan metadata (target, lane, hashes, ...)
|
|
13
|
+
* - `_row` — phantom row type, propagated from the originating `SqlQueryPlan`
|
|
14
|
+
*
|
|
15
|
+
* Extends the framework-level `ExecutionPlan<Row>` marker so generic SPIs
|
|
16
|
+
* (`RuntimeExecutor<SqlExecutionPlan>`, `RuntimeMiddleware<SqlExecutionPlan>`)
|
|
17
|
+
* can be parameterized over it.
|
|
18
|
+
*
|
|
19
|
+
* Co-located with `SqlQueryPlan` (its pre-lowering counterpart) in the lanes
|
|
20
|
+
* layer because lane-level utilities (`RawTemplateFactory`, `RawFactory`,
|
|
21
|
+
* `SqlPlan`) compose against the executable shape and the lanes layer cannot
|
|
22
|
+
* depend on the runtime layer.
|
|
23
|
+
*/
|
|
24
|
+
export interface SqlExecutionPlan<Row = unknown> extends ExecutionPlan<Row> {
|
|
25
|
+
readonly sql: string;
|
|
26
|
+
readonly params: readonly unknown[];
|
|
27
|
+
readonly ast?: AnyQueryAst;
|
|
28
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Contract,
|
|
3
|
-
ResultType as CoreResultType,
|
|
4
|
-
ExecutionPlan,
|
|
5
|
-
PlanRefs,
|
|
6
|
-
} from '@prisma-next/contract/types';
|
|
1
|
+
import type { Contract, PlanRefs } from '@prisma-next/contract/types';
|
|
7
2
|
import type { ParamSpec } from '@prisma-next/operations';
|
|
8
3
|
import type {
|
|
9
4
|
ExtractFieldOutputTypes,
|
|
@@ -11,9 +6,9 @@ import type {
|
|
|
11
6
|
StorageColumn,
|
|
12
7
|
} from '@prisma-next/sql-contract/types';
|
|
13
8
|
import type { SqlLoweringSpec } from '@prisma-next/sql-operations';
|
|
14
|
-
import type {
|
|
15
|
-
import type { SqlQueryPlan } from './plan';
|
|
9
|
+
import type { ColumnRef, ParamRef } from './ast/types';
|
|
16
10
|
import type { ExecutionContext } from './query-lane-context';
|
|
11
|
+
import type { SqlExecutionPlan } from './sql-execution-plan';
|
|
17
12
|
|
|
18
13
|
export type Expr = ColumnRef | ParamRef;
|
|
19
14
|
|
|
@@ -179,10 +174,11 @@ export type HasIncludeManyCapabilities<TContract extends Contract<SqlStorage>> =
|
|
|
179
174
|
: false;
|
|
180
175
|
|
|
181
176
|
/**
|
|
182
|
-
* SQL-
|
|
183
|
-
*
|
|
177
|
+
* Alias for the SQL-domain executable plan, exposed under the legacy
|
|
178
|
+
* `SqlPlan` name for compatibility with SQL builder/utility call sites.
|
|
179
|
+
* The canonical name is `SqlExecutionPlan` (`./sql-execution-plan`).
|
|
184
180
|
*/
|
|
185
|
-
export type SqlPlan<Row = unknown> =
|
|
181
|
+
export type SqlPlan<Row = unknown> = SqlExecutionPlan<Row>;
|
|
186
182
|
|
|
187
183
|
/**
|
|
188
184
|
* Helper types for extracting contract structure.
|
|
@@ -260,10 +256,10 @@ export interface RawFunctionOptions extends RawTemplateOptions {
|
|
|
260
256
|
export type RawTemplateFactory = (
|
|
261
257
|
strings: TemplateStringsArray,
|
|
262
258
|
...values: readonly unknown[]
|
|
263
|
-
) =>
|
|
259
|
+
) => SqlExecutionPlan;
|
|
264
260
|
|
|
265
261
|
export interface RawFactory extends RawTemplateFactory {
|
|
266
|
-
(text: string, options: RawFunctionOptions):
|
|
262
|
+
(text: string, options: RawFunctionOptions): SqlExecutionPlan;
|
|
267
263
|
with(options: RawTemplateOptions): RawTemplateFactory;
|
|
268
264
|
}
|
|
269
265
|
|
|
@@ -287,10 +283,3 @@ export interface BuildOptions {
|
|
|
287
283
|
export interface SqlBuilderOptions<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
|
|
288
284
|
readonly context: ExecutionContext<TContract>;
|
|
289
285
|
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* SQL-specific ResultType that works with both Plan and SqlQueryPlan.
|
|
293
|
-
* This extends the core ResultType to also handle SqlQueryPlan.
|
|
294
|
-
* Example: `type Row = ResultType<typeof plan>`
|
|
295
|
-
*/
|
|
296
|
-
export type ResultType<P> = P extends SqlQueryPlan<infer R> ? R : CoreResultType<P>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec-types-DcEITed4.d.mts","names":[],"sources":["../src/ast/codec-types.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAeA;;;;;;AAe8C,UAf7B,qBAe6B,CAAA,UAfG,MAeH,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,UAAA,OAAA,CAAA,CAAA;EAO7B;EAiBA,SAAA,OAAK,EAAA,MAAA;EAEK;;;;EAKH,SAAA,YAAA,EAtCC,IAsCD,CAtCM,OAsCN,CAAA;EAAS;;;;;EAGN,SAAA,IAAA,CAAA,EAAA,CAAA,MA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