@prisma-next/sql-relational-core 0.3.0-dev.34 → 0.3.0-dev.36
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 -1
- package/dist/errors-7_V3El9I.mjs +3 -0
- package/dist/errors-DVufq9PT.d.mts +2 -0
- package/dist/exports/ast.d.mts +189 -0
- package/dist/exports/ast.d.mts.map +1 -0
- package/dist/exports/ast.mjs +360 -0
- package/dist/exports/ast.mjs.map +1 -0
- package/dist/exports/errors.d.mts +2 -0
- package/dist/exports/errors.mjs +3 -0
- package/dist/exports/guards.d.mts +5 -0
- package/dist/exports/guards.mjs +3 -0
- package/dist/exports/operations-registry.d.mts +5 -0
- package/dist/exports/operations-registry.mjs +3 -0
- package/dist/exports/param.d.mts +5 -0
- package/dist/exports/param.mjs +3 -0
- package/dist/exports/plan.d.mts +2 -0
- package/dist/exports/plan.mjs +17 -0
- package/dist/exports/plan.mjs.map +1 -0
- package/dist/exports/query-lane-context.d.mts +2 -0
- package/dist/exports/query-lane-context.mjs +1 -0
- package/dist/exports/schema.d.mts +5 -0
- package/dist/exports/schema.mjs +4 -0
- package/dist/exports/types.d.mts +4 -0
- package/dist/exports/types.mjs +3 -0
- package/dist/exports/utils/guards.d.mts +5 -0
- package/dist/exports/utils/guards.mjs +4 -0
- package/dist/guards-0ycyntYX.mjs +132 -0
- package/dist/guards-0ycyntYX.mjs.map +1 -0
- package/dist/{utils/guards.d.ts → guards-l1R3q8pA.d.mts} +24 -19
- package/dist/guards-l1R3q8pA.d.mts.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +12 -0
- package/dist/operations-registry-0GuSkOCC.d.mts +9 -0
- package/dist/operations-registry-0GuSkOCC.d.mts.map +1 -0
- package/dist/operations-registry-DPZ5aElH.mjs +152 -0
- package/dist/operations-registry-DPZ5aElH.mjs.map +1 -0
- package/dist/param-ChBZwVcw.d.mts +8 -0
- package/dist/param-ChBZwVcw.d.mts.map +1 -0
- package/dist/param-DMU3OWfI.mjs +14 -0
- package/dist/param-DMU3OWfI.mjs.map +1 -0
- package/dist/plan-cjDF_yFX.d.mts +182 -0
- package/dist/plan-cjDF_yFX.d.mts.map +1 -0
- package/dist/query-lane-context-CgkPuKaR.d.mts +259 -0
- package/dist/query-lane-context-CgkPuKaR.d.mts.map +1 -0
- package/dist/schema-Bi5p4aAc.mjs +175 -0
- package/dist/schema-Bi5p4aAc.mjs.map +1 -0
- package/dist/schema-CEpzzWNY.d.mts +86 -0
- package/dist/schema-CEpzzWNY.d.mts.map +1 -0
- package/dist/types-Cdi4Whda.mjs +18 -0
- package/dist/types-Cdi4Whda.mjs.map +1 -0
- package/dist/types-DicmXfBm.d.mts +447 -0
- package/dist/types-DicmXfBm.d.mts.map +1 -0
- package/package.json +34 -51
- package/src/ast/codec-types.ts +72 -4
- package/src/ast/driver-types.ts +20 -3
- package/src/ast/predicate.ts +3 -1
- package/src/ast/sql-codecs.ts +67 -0
- package/src/ast/types.ts +28 -3
- package/src/exports/ast.ts +1 -0
- package/src/exports/utils/guards.ts +1 -0
- package/src/query-lane-context.ts +70 -6
- package/src/schema.ts +4 -4
- package/src/types.ts +2 -2
- package/dist/ast/adapter-types.d.ts +0 -28
- package/dist/ast/adapter-types.d.ts.map +0 -1
- package/dist/ast/codec-types.d.ts +0 -141
- package/dist/ast/codec-types.d.ts.map +0 -1
- package/dist/ast/common.d.ts +0 -7
- package/dist/ast/common.d.ts.map +0 -1
- package/dist/ast/delete.d.ts +0 -8
- package/dist/ast/delete.d.ts.map +0 -1
- package/dist/ast/driver-types.d.ts +0 -20
- package/dist/ast/driver-types.d.ts.map +0 -1
- package/dist/ast/insert.d.ts +0 -8
- package/dist/ast/insert.d.ts.map +0 -1
- package/dist/ast/join.d.ts +0 -6
- package/dist/ast/join.d.ts.map +0 -1
- package/dist/ast/order.d.ts +0 -6
- package/dist/ast/order.d.ts.map +0 -1
- package/dist/ast/predicate.d.ts +0 -5
- package/dist/ast/predicate.d.ts.map +0 -1
- package/dist/ast/select.d.ts +0 -18
- package/dist/ast/select.d.ts.map +0 -1
- package/dist/ast/types.d.ts +0 -143
- package/dist/ast/types.d.ts.map +0 -1
- package/dist/ast/update.d.ts +0 -9
- package/dist/ast/update.d.ts.map +0 -1
- package/dist/ast/util.d.ts +0 -2
- package/dist/ast/util.d.ts.map +0 -1
- package/dist/chunk-2F7DSEOU.js +0 -8
- package/dist/chunk-2F7DSEOU.js.map +0 -1
- package/dist/chunk-2MAKNVCP.js +0 -86
- package/dist/chunk-2MAKNVCP.js.map +0 -1
- package/dist/chunk-36WJWNHT.js +0 -1
- package/dist/chunk-36WJWNHT.js.map +0 -1
- package/dist/chunk-3F4RFQIB.js +0 -169
- package/dist/chunk-3F4RFQIB.js.map +0 -1
- package/dist/chunk-4WKZQIDS.js +0 -193
- package/dist/chunk-4WKZQIDS.js.map +0 -1
- package/dist/chunk-7I3EMQID.js +0 -16
- package/dist/chunk-7I3EMQID.js.map +0 -1
- package/dist/chunk-G52ENULI.js +0 -1
- package/dist/chunk-G52ENULI.js.map +0 -1
- package/dist/chunk-HAUHWBE7.js +0 -13
- package/dist/chunk-HAUHWBE7.js.map +0 -1
- package/dist/chunk-KYSP7L5C.js +0 -16
- package/dist/chunk-KYSP7L5C.js.map +0 -1
- package/dist/chunk-RVHFGDZ6.js +0 -328
- package/dist/chunk-RVHFGDZ6.js.map +0 -1
- package/dist/chunk-U7AXAUJA.js +0 -1
- package/dist/chunk-U7AXAUJA.js.map +0 -1
- package/dist/errors.d.ts +0 -2
- package/dist/errors.d.ts.map +0 -1
- package/dist/exports/ast.d.ts +0 -14
- package/dist/exports/ast.d.ts.map +0 -1
- package/dist/exports/ast.js +0 -48
- package/dist/exports/ast.js.map +0 -1
- package/dist/exports/errors.d.ts +0 -2
- package/dist/exports/errors.d.ts.map +0 -1
- package/dist/exports/errors.js +0 -9
- package/dist/exports/errors.js.map +0 -1
- package/dist/exports/guards.d.ts +0 -2
- package/dist/exports/guards.d.ts.map +0 -1
- package/dist/exports/guards.js +0 -31
- package/dist/exports/guards.js.map +0 -1
- package/dist/exports/operations-registry.d.ts +0 -2
- package/dist/exports/operations-registry.d.ts.map +0 -1
- package/dist/exports/operations-registry.js +0 -9
- package/dist/exports/operations-registry.js.map +0 -1
- package/dist/exports/param.d.ts +0 -3
- package/dist/exports/param.d.ts.map +0 -1
- package/dist/exports/param.js +0 -7
- package/dist/exports/param.js.map +0 -1
- package/dist/exports/plan.d.ts +0 -2
- package/dist/exports/plan.d.ts.map +0 -1
- package/dist/exports/plan.js +0 -7
- package/dist/exports/plan.js.map +0 -1
- package/dist/exports/query-lane-context.d.ts +0 -2
- package/dist/exports/query-lane-context.d.ts.map +0 -1
- package/dist/exports/query-lane-context.js +0 -2
- package/dist/exports/query-lane-context.js.map +0 -1
- package/dist/exports/schema.d.ts +0 -3
- package/dist/exports/schema.d.ts.map +0 -1
- package/dist/exports/schema.js +0 -13
- package/dist/exports/schema.js.map +0 -1
- package/dist/exports/types.d.ts +0 -2
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -10
- package/dist/exports/types.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -83
- package/dist/index.js.map +0 -1
- package/dist/operations-registry.d.ts +0 -5
- package/dist/operations-registry.d.ts.map +0 -1
- package/dist/param.d.ts +0 -4
- package/dist/param.d.ts.map +0 -1
- package/dist/plan.d.ts +0 -23
- package/dist/plan.d.ts.map +0 -1
- package/dist/query-lane-context.d.ts +0 -27
- package/dist/query-lane-context.d.ts.map +0 -1
- package/dist/schema.d.ts +0 -93
- package/dist/schema.d.ts.map +0 -1
- package/dist/types.d.ts +0 -459
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/guards.d.ts.map +0 -1
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface SqlExecuteRequest {
|
|
2
|
-
readonly sql: string;
|
|
3
|
-
readonly params?: readonly unknown[];
|
|
4
|
-
}
|
|
5
|
-
export interface SqlQueryResult<Row = Record<string, unknown>> {
|
|
6
|
-
readonly rows: ReadonlyArray<Row>;
|
|
7
|
-
readonly rowCount?: number | null;
|
|
8
|
-
readonly [key: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
export interface SqlExplainResult<Row = Record<string, unknown>> {
|
|
11
|
-
readonly rows: ReadonlyArray<Row>;
|
|
12
|
-
}
|
|
13
|
-
export interface SqlDriver {
|
|
14
|
-
connect(): Promise<void>;
|
|
15
|
-
execute<Row = Record<string, unknown>>(request: SqlExecuteRequest): AsyncIterable<Row>;
|
|
16
|
-
explain?(request: SqlExecuteRequest): Promise<SqlExplainResult>;
|
|
17
|
-
query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<SqlQueryResult<Row>>;
|
|
18
|
-
close(): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=driver-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"driver-types.d.ts","sourceRoot":"","sources":["../../src/ast/driver-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,cAAc,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACvF,OAAO,CAAC,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChE,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAC1B,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
package/dist/ast/insert.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ColumnRef, InsertAst, ParamRef, TableRef } from './types';
|
|
2
|
-
export interface CreateInsertAstOptions {
|
|
3
|
-
readonly table: TableRef;
|
|
4
|
-
readonly values: Record<string, ColumnRef | ParamRef>;
|
|
5
|
-
readonly returning?: ReadonlyArray<ColumnRef>;
|
|
6
|
-
}
|
|
7
|
-
export declare function createInsertAst(options: CreateInsertAstOptions): InsertAst;
|
|
8
|
-
//# sourceMappingURL=insert.d.ts.map
|
package/dist/ast/insert.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/ast/insert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAO1E"}
|
package/dist/ast/join.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { JoinOnBuilder } from '../types';
|
|
2
|
-
import type { ColumnRef, JoinAst, JoinOnExpr, TableRef } from './types';
|
|
3
|
-
export declare function createJoin(joinType: 'inner' | 'left' | 'right' | 'full', table: TableRef, on: JoinOnExpr): JoinAst;
|
|
4
|
-
export declare function createJoinOnExpr(left: ColumnRef, right: ColumnRef): JoinOnExpr;
|
|
5
|
-
export declare function createJoinOnBuilder(): JoinOnBuilder;
|
|
6
|
-
//# sourceMappingURL=join.d.ts.map
|
package/dist/ast/join.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../src/ast/join.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,aAAa,EAAmB,MAAM,UAAU,CAAC;AAEjF,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExE,wBAAgB,UAAU,CACxB,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAC7C,KAAK,EAAE,QAAQ,EACf,EAAE,EAAE,UAAU,GACb,OAAO,CAOT;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,UAAU,CAM9E;AA2BD,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD"}
|
package/dist/ast/order.d.ts
DELETED
package/dist/ast/order.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/ast/order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEnE,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,GAAG,aAAa,EAC/B,GAAG,EAAE,KAAK,GAAG,MAAM,GAClB;IAAE,IAAI,EAAE,SAAS,GAAG,aAAa,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,CAKrD"}
|
package/dist/ast/predicate.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BinaryExpr, BinaryOp, ExistsExpr, Expression, NullCheckExpr, ParamRef, SelectAst } from './types';
|
|
2
|
-
export declare function createBinaryExpr(op: BinaryOp, left: Expression, right: Expression | ParamRef): BinaryExpr;
|
|
3
|
-
export declare function createExistsExpr(not: boolean, subquery: SelectAst): ExistsExpr;
|
|
4
|
-
export declare function createNullCheckExpr(expr: Expression, isNull: boolean): NullCheckExpr;
|
|
5
|
-
//# sourceMappingURL=predicate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../src/ast/predicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EACV,MAAM,SAAS,CAAC;AAEjB,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,UAAU,GAAG,QAAQ,GAC3B,UAAU,CAOZ;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,UAAU,CAM9E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAG,aAAa,CAMpF"}
|
package/dist/ast/select.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ColumnRef, Direction, IncludeAst, IncludeRef, JoinAst, OperationExpr, SelectAst, TableRef, WhereExpr } from './types';
|
|
2
|
-
export interface CreateSelectAstOptions {
|
|
3
|
-
readonly from: TableRef;
|
|
4
|
-
readonly joins?: ReadonlyArray<JoinAst>;
|
|
5
|
-
readonly includes?: ReadonlyArray<IncludeAst>;
|
|
6
|
-
readonly project: ReadonlyArray<{
|
|
7
|
-
alias: string;
|
|
8
|
-
expr: ColumnRef | IncludeRef | OperationExpr;
|
|
9
|
-
}>;
|
|
10
|
-
readonly where?: WhereExpr;
|
|
11
|
-
readonly orderBy?: ReadonlyArray<{
|
|
12
|
-
expr: ColumnRef | OperationExpr;
|
|
13
|
-
dir: Direction;
|
|
14
|
-
}>;
|
|
15
|
-
readonly limit?: number;
|
|
16
|
-
}
|
|
17
|
-
export declare function createSelectAst(options: CreateSelectAstOptions): SelectAst;
|
|
18
|
-
//# sourceMappingURL=select.d.ts.map
|
package/dist/ast/select.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/ast/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,OAAO,EACP,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,SAAS,CAAC;AAGjB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC;KAC9C,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,SAAS,GAAG,aAAa,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACtF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAW1E"}
|
package/dist/ast/types.d.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import type { ReturnSpec } from '@prisma-next/operations';
|
|
2
|
-
import type { SqlLoweringSpec } from '@prisma-next/sql-operations';
|
|
3
|
-
export type Direction = 'asc' | 'desc';
|
|
4
|
-
export interface TableRef {
|
|
5
|
-
readonly kind: 'table';
|
|
6
|
-
readonly name: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ColumnRef {
|
|
9
|
-
readonly kind: 'col';
|
|
10
|
-
readonly table: string;
|
|
11
|
-
readonly column: string;
|
|
12
|
-
}
|
|
13
|
-
export interface ParamRef {
|
|
14
|
-
readonly kind: 'param';
|
|
15
|
-
readonly index: number;
|
|
16
|
-
readonly name?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface LiteralExpr {
|
|
19
|
-
readonly kind: 'literal';
|
|
20
|
-
readonly value: unknown;
|
|
21
|
-
}
|
|
22
|
-
export interface OperationExpr {
|
|
23
|
-
readonly kind: 'operation';
|
|
24
|
-
readonly method: string;
|
|
25
|
-
readonly forTypeId: string;
|
|
26
|
-
readonly self: Expression;
|
|
27
|
-
readonly args: ReadonlyArray<Expression | ParamRef | LiteralExpr>;
|
|
28
|
-
readonly returns: ReturnSpec;
|
|
29
|
-
readonly lowering: SqlLoweringSpec;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Unified expression type - the canonical AST representation for column references
|
|
33
|
-
* and operation expressions. This is what all builders convert to via toExpr().
|
|
34
|
-
*/
|
|
35
|
-
export type Expression = ColumnRef | OperationExpr;
|
|
36
|
-
/**
|
|
37
|
-
* Interface for any builder that can produce an Expression.
|
|
38
|
-
* Implemented by ColumnBuilder and ExpressionBuilder.
|
|
39
|
-
*/
|
|
40
|
-
export interface ExpressionSource {
|
|
41
|
-
toExpr(): Expression;
|
|
42
|
-
}
|
|
43
|
-
export declare function isOperationExpr(expr: Expression): expr is OperationExpr;
|
|
44
|
-
export type BinaryOp = 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte';
|
|
45
|
-
export interface BinaryExpr {
|
|
46
|
-
readonly kind: 'bin';
|
|
47
|
-
readonly op: BinaryOp;
|
|
48
|
-
readonly left: Expression;
|
|
49
|
-
readonly right: Expression | ParamRef;
|
|
50
|
-
}
|
|
51
|
-
export interface ExistsExpr {
|
|
52
|
-
readonly kind: 'exists';
|
|
53
|
-
readonly not: boolean;
|
|
54
|
-
readonly subquery: SelectAst;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Unary expression for IS NULL / IS NOT NULL checks.
|
|
58
|
-
* Used in WHERE clauses to check for null values.
|
|
59
|
-
*/
|
|
60
|
-
export interface NullCheckExpr {
|
|
61
|
-
readonly kind: 'nullCheck';
|
|
62
|
-
readonly expr: Expression;
|
|
63
|
-
readonly isNull: boolean;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Union type for WHERE clause expressions.
|
|
67
|
-
*/
|
|
68
|
-
export type WhereExpr = BinaryExpr | ExistsExpr | NullCheckExpr;
|
|
69
|
-
export type JoinOnExpr = {
|
|
70
|
-
readonly kind: 'eqCol';
|
|
71
|
-
readonly left: ColumnRef;
|
|
72
|
-
readonly right: ColumnRef;
|
|
73
|
-
};
|
|
74
|
-
export interface JoinAst {
|
|
75
|
-
readonly kind: 'join';
|
|
76
|
-
readonly joinType: 'inner' | 'left' | 'right' | 'full';
|
|
77
|
-
readonly table: TableRef;
|
|
78
|
-
readonly on: JoinOnExpr;
|
|
79
|
-
}
|
|
80
|
-
export interface IncludeRef {
|
|
81
|
-
readonly kind: 'includeRef';
|
|
82
|
-
readonly alias: string;
|
|
83
|
-
}
|
|
84
|
-
export interface IncludeAst {
|
|
85
|
-
readonly kind: 'includeMany';
|
|
86
|
-
readonly alias: string;
|
|
87
|
-
readonly child: {
|
|
88
|
-
readonly table: TableRef;
|
|
89
|
-
readonly on: JoinOnExpr;
|
|
90
|
-
readonly where?: WhereExpr;
|
|
91
|
-
readonly orderBy?: ReadonlyArray<{
|
|
92
|
-
expr: Expression;
|
|
93
|
-
dir: Direction;
|
|
94
|
-
}>;
|
|
95
|
-
readonly limit?: number;
|
|
96
|
-
readonly project: ReadonlyArray<{
|
|
97
|
-
alias: string;
|
|
98
|
-
expr: Expression;
|
|
99
|
-
}>;
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
export interface SelectAst {
|
|
103
|
-
readonly kind: 'select';
|
|
104
|
-
readonly from: TableRef;
|
|
105
|
-
readonly joins?: ReadonlyArray<JoinAst>;
|
|
106
|
-
readonly includes?: ReadonlyArray<IncludeAst>;
|
|
107
|
-
readonly project: ReadonlyArray<{
|
|
108
|
-
alias: string;
|
|
109
|
-
expr: Expression | IncludeRef | LiteralExpr;
|
|
110
|
-
}>;
|
|
111
|
-
readonly where?: WhereExpr;
|
|
112
|
-
readonly orderBy?: ReadonlyArray<{
|
|
113
|
-
expr: Expression;
|
|
114
|
-
dir: Direction;
|
|
115
|
-
}>;
|
|
116
|
-
readonly limit?: number;
|
|
117
|
-
}
|
|
118
|
-
export interface InsertAst {
|
|
119
|
-
readonly kind: 'insert';
|
|
120
|
-
readonly table: TableRef;
|
|
121
|
-
readonly values: Record<string, ColumnRef | ParamRef>;
|
|
122
|
-
readonly returning?: ReadonlyArray<ColumnRef>;
|
|
123
|
-
}
|
|
124
|
-
export interface UpdateAst {
|
|
125
|
-
readonly kind: 'update';
|
|
126
|
-
readonly table: TableRef;
|
|
127
|
-
readonly set: Record<string, ColumnRef | ParamRef>;
|
|
128
|
-
readonly where: WhereExpr;
|
|
129
|
-
readonly returning?: ReadonlyArray<ColumnRef>;
|
|
130
|
-
}
|
|
131
|
-
export interface DeleteAst {
|
|
132
|
-
readonly kind: 'delete';
|
|
133
|
-
readonly table: TableRef;
|
|
134
|
-
readonly where: WhereExpr;
|
|
135
|
-
readonly returning?: ReadonlyArray<ColumnRef>;
|
|
136
|
-
}
|
|
137
|
-
export type QueryAst = SelectAst | InsertAst | UpdateAst | DeleteAst;
|
|
138
|
-
export interface LoweredStatement {
|
|
139
|
-
readonly sql: string;
|
|
140
|
-
readonly params: readonly unknown[];
|
|
141
|
-
readonly annotations?: Record<string, unknown>;
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/ast/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAKnE,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvC,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IA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AAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD"}
|
package/dist/ast/update.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ColumnRef, ParamRef, TableRef, UpdateAst, WhereExpr } from './types';
|
|
2
|
-
export interface CreateUpdateAstOptions {
|
|
3
|
-
readonly table: TableRef;
|
|
4
|
-
readonly set: Record<string, ColumnRef | ParamRef>;
|
|
5
|
-
readonly where: WhereExpr;
|
|
6
|
-
readonly returning?: ReadonlyArray<ColumnRef>;
|
|
7
|
-
}
|
|
8
|
-
export declare function createUpdateAst(options: CreateUpdateAstOptions): UpdateAst;
|
|
9
|
-
//# sourceMappingURL=update.d.ts.map
|
package/dist/ast/update.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/ast/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGnF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAQ1E"}
|
package/dist/ast/util.d.ts
DELETED
package/dist/ast/util.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/ast/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAQlE"}
|
package/dist/chunk-2F7DSEOU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["export { planInvalid, planUnsupported } from '@prisma-next/plan';\n"],"mappings":";AAAA,SAAS,aAAa,uBAAuB;","names":[]}
|
package/dist/chunk-2MAKNVCP.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// src/utils/guards.ts
|
|
2
|
-
function getColumnMeta(expr) {
|
|
3
|
-
if ("columnMeta" in expr) {
|
|
4
|
-
return expr.columnMeta;
|
|
5
|
-
}
|
|
6
|
-
return void 0;
|
|
7
|
-
}
|
|
8
|
-
function isParamPlaceholder(value) {
|
|
9
|
-
return typeof value === "object" && value !== null && "kind" in value && value.kind === "param-placeholder" && "name" in value && typeof value.name === "string";
|
|
10
|
-
}
|
|
11
|
-
function extractBaseColumnRef(expr) {
|
|
12
|
-
if (expr.kind === "col") {
|
|
13
|
-
return expr;
|
|
14
|
-
}
|
|
15
|
-
return extractBaseColumnRef(expr.self);
|
|
16
|
-
}
|
|
17
|
-
function collectColumnRefs(expr) {
|
|
18
|
-
if (expr.kind === "col") {
|
|
19
|
-
return [expr];
|
|
20
|
-
}
|
|
21
|
-
if (expr.kind === "operation") {
|
|
22
|
-
const refs = collectColumnRefs(expr.self);
|
|
23
|
-
for (const arg of expr.args) {
|
|
24
|
-
refs.push(...collectColumnRefs(arg));
|
|
25
|
-
}
|
|
26
|
-
return refs;
|
|
27
|
-
}
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
function isOperationExpr(expr) {
|
|
31
|
-
return typeof expr === "object" && expr !== null && "kind" in expr && expr.kind === "operation";
|
|
32
|
-
}
|
|
33
|
-
function getColumnInfo(expr) {
|
|
34
|
-
if (isOperationExpr(expr)) {
|
|
35
|
-
const baseCol = extractBaseColumnRef(expr);
|
|
36
|
-
return { table: baseCol.table, column: baseCol.column };
|
|
37
|
-
}
|
|
38
|
-
if (isExpressionBuilder(expr)) {
|
|
39
|
-
const baseCol = extractBaseColumnRef(expr.expr);
|
|
40
|
-
return { table: baseCol.table, column: baseCol.column };
|
|
41
|
-
}
|
|
42
|
-
const colBuilder = expr;
|
|
43
|
-
return { table: colBuilder.table, column: colBuilder.column };
|
|
44
|
-
}
|
|
45
|
-
function isColumnBuilder(value) {
|
|
46
|
-
return typeof value === "object" && value !== null && "kind" in value && value.kind === "column";
|
|
47
|
-
}
|
|
48
|
-
function isExpressionBuilder(value) {
|
|
49
|
-
return typeof value === "object" && value !== null && "kind" in value && value.kind === "expression";
|
|
50
|
-
}
|
|
51
|
-
function isExpressionSource(value) {
|
|
52
|
-
return typeof value === "object" && value !== null && "toExpr" in value && typeof value.toExpr === "function";
|
|
53
|
-
}
|
|
54
|
-
function toExpression(source) {
|
|
55
|
-
return source.toExpr();
|
|
56
|
-
}
|
|
57
|
-
function expressionFromSource(source) {
|
|
58
|
-
return source.toExpr();
|
|
59
|
-
}
|
|
60
|
-
function isValueSource(value) {
|
|
61
|
-
return isParamPlaceholder(value) || isExpressionSource(value);
|
|
62
|
-
}
|
|
63
|
-
function getOperationExpr(builder) {
|
|
64
|
-
if (isOperationExpr(builder)) {
|
|
65
|
-
return builder;
|
|
66
|
-
}
|
|
67
|
-
const builderWithExpr = builder;
|
|
68
|
-
return builderWithExpr._operationExpr;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export {
|
|
72
|
-
getColumnMeta,
|
|
73
|
-
isParamPlaceholder,
|
|
74
|
-
extractBaseColumnRef,
|
|
75
|
-
collectColumnRefs,
|
|
76
|
-
isOperationExpr,
|
|
77
|
-
getColumnInfo,
|
|
78
|
-
isColumnBuilder,
|
|
79
|
-
isExpressionBuilder,
|
|
80
|
-
isExpressionSource,
|
|
81
|
-
toExpression,
|
|
82
|
-
expressionFromSource,
|
|
83
|
-
isValueSource,
|
|
84
|
-
getOperationExpr
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=chunk-2MAKNVCP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/guards.ts"],"sourcesContent":["import type { StorageColumn } from '@prisma-next/sql-contract/types';\nimport type {\n ColumnRef,\n Expression,\n ExpressionSource,\n LiteralExpr,\n OperationExpr,\n ParamRef,\n} from '../ast/types';\nimport type {\n AnyColumnBuilder,\n AnyExpressionSource,\n ExpressionBuilder,\n ParamPlaceholder,\n ValueSource,\n} from '../types';\n\n/**\n * Helper to extract columnMeta from a ColumnBuilder or ExpressionBuilder.\n * Returns StorageColumn if present, undefined otherwise.\n * Both ColumnBuilder and ExpressionBuilder have columnMeta property.\n */\nexport function getColumnMeta(expr: AnyExpressionSource): StorageColumn | undefined {\n // Both ColumnBuilder and ExpressionBuilder have columnMeta: StorageColumn\n // TypeScript should narrow the type after the 'in' check\n if ('columnMeta' in expr) {\n return expr.columnMeta;\n }\n return undefined;\n}\n\n/**\n * Type predicate to check if a value is a ParamPlaceholder.\n */\nexport function isParamPlaceholder(value: unknown): value is ParamPlaceholder {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'kind' in value &&\n (value as { kind: unknown }).kind === 'param-placeholder' &&\n 'name' in value &&\n typeof (value as { name: unknown }).name === 'string'\n );\n}\n\n/**\n * Recursively extracts the base ColumnRef from an OperationExpr.\n * If the expression is already a ColumnRef, it is returned directly.\n */\nexport function extractBaseColumnRef(expr: ColumnRef | OperationExpr): ColumnRef {\n if (expr.kind === 'col') {\n return expr;\n }\n return extractBaseColumnRef(expr.self);\n}\n\n/**\n * Recursively collects all ColumnRef nodes from an expression tree.\n * Handles nested OperationExpr structures by traversing both self and args.\n */\nexport function collectColumnRefs(\n expr: ColumnRef | ParamRef | LiteralExpr | OperationExpr,\n): ColumnRef[] {\n if (expr.kind === 'col') {\n return [expr];\n }\n if (expr.kind === 'operation') {\n const refs: ColumnRef[] = collectColumnRefs(expr.self);\n for (const arg of expr.args) {\n refs.push(...collectColumnRefs(arg));\n }\n return refs;\n }\n return [];\n}\n\n/**\n * Type predicate to check if an expression is an OperationExpr.\n */\nexport function isOperationExpr(\n expr: AnyExpressionSource | OperationExpr | Expression,\n): expr is OperationExpr {\n return typeof expr === 'object' && expr !== null && 'kind' in expr && expr.kind === 'operation';\n}\n\n/**\n * Helper to extract table and column from a ColumnBuilder, ExpressionBuilder, or OperationExpr.\n * For ExpressionBuilder or OperationExpr, recursively unwraps to find the base ColumnRef.\n */\nexport function getColumnInfo(expr: AnyExpressionSource | OperationExpr): {\n table: string;\n column: string;\n} {\n if (isOperationExpr(expr)) {\n const baseCol = extractBaseColumnRef(expr);\n return { table: baseCol.table, column: baseCol.column };\n }\n if (isExpressionBuilder(expr)) {\n const baseCol = extractBaseColumnRef(expr.expr);\n return { table: baseCol.table, column: baseCol.column };\n }\n // expr is ColumnBuilder - TypeScript can't narrow properly\n const colBuilder = expr as unknown as { table: string; column: string };\n return { table: colBuilder.table, column: colBuilder.column };\n}\n\n/**\n * Type predicate to check if a value is a ColumnBuilder.\n */\nexport function isColumnBuilder(value: unknown): value is AnyColumnBuilder {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'kind' in value &&\n (value as { kind: unknown }).kind === 'column'\n );\n}\n\n/**\n * Type predicate to check if a value is an ExpressionBuilder.\n */\nexport function isExpressionBuilder(value: unknown): value is ExpressionBuilder {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'kind' in value &&\n (value as { kind: unknown }).kind === 'expression'\n );\n}\n\n/**\n * Type predicate to check if a value is an ExpressionSource (has toExpr method).\n */\nexport function isExpressionSource(value: unknown): value is ExpressionSource {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'toExpr' in value &&\n typeof (value as ExpressionSource).toExpr === 'function'\n );\n}\n\n/**\n * Converts any ExpressionSource to an Expression.\n * This is the canonical way to get an AST Expression from a builder.\n *\n * @param source - A ColumnBuilder or ExpressionBuilder\n * @returns The corresponding Expression (ColumnRef or OperationExpr)\n */\nexport function toExpression(source: ExpressionSource): Expression {\n return source.toExpr();\n}\n\n/**\n * Converts an AnyExpressionSource to an Expression.\n * Handles both ColumnBuilder and ExpressionBuilder.\n *\n * @param source - A ColumnBuilder or ExpressionBuilder\n * @returns The corresponding Expression (ColumnRef or OperationExpr)\n */\nexport function expressionFromSource(source: AnyExpressionSource): Expression {\n return source.toExpr();\n}\n\n/**\n * Type predicate to check if a value is a ValueSource.\n * ValueSource is either a ParamPlaceholder or an ExpressionSource.\n */\nexport function isValueSource(value: unknown): value is ValueSource {\n return isParamPlaceholder(value) || isExpressionSource(value);\n}\n\n/**\n * Extracts and returns an OperationExpr from a builder.\n * Returns the OperationExpr if the builder is an OperationExpr or has an _operationExpr property,\n * otherwise returns undefined.\n *\n * @deprecated Use isExpressionBuilder() instead. This function exists for backward compatibility\n * with code that uses the hidden _operationExpr property pattern.\n *\n * @design-note: This function accesses the hidden `_operationExpr` property, which is a code smell.\n * The ExpressionBuilder type (introduced in the operation-expr-refactoring) provides a cleaner\n * approach by explicitly representing operation results as a distinct type.\n */\nexport function getOperationExpr(\n builder: AnyColumnBuilder | OperationExpr,\n): OperationExpr | undefined {\n if (isOperationExpr(builder)) {\n return builder;\n }\n const builderWithExpr = builder as unknown as { _operationExpr?: OperationExpr };\n return builderWithExpr._operationExpr;\n}\n"],"mappings":";AAsBO,SAAS,cAAc,MAAsD;AAGlF,MAAI,gBAAgB,MAAM;AACxB,WAAO,KAAK;AAAA,EACd;AACA,SAAO;AACT;AAKO,SAAS,mBAAmB,OAA2C;AAC5E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS,uBACtC,UAAU,SACV,OAAQ,MAA4B,SAAS;AAEjD;AAMO,SAAS,qBAAqB,MAA4C;AAC/E,MAAI,KAAK,SAAS,OAAO;AACvB,WAAO;AAAA,EACT;AACA,SAAO,qBAAqB,KAAK,IAAI;AACvC;AAMO,SAAS,kBACd,MACa;AACb,MAAI,KAAK,SAAS,OAAO;AACvB,WAAO,CAAC,IAAI;AAAA,EACd;AACA,MAAI,KAAK,SAAS,aAAa;AAC7B,UAAM,OAAoB,kBAAkB,KAAK,IAAI;AACrD,eAAW,OAAO,KAAK,MAAM;AAC3B,WAAK,KAAK,GAAG,kBAAkB,GAAG,CAAC;AAAA,IACrC;AACA,WAAO;AAAA,EACT;AACA,SAAO,CAAC;AACV;AAKO,SAAS,gBACd,MACuB;AACvB,SAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,KAAK,SAAS;AACtF;AAMO,SAAS,cAAc,MAG5B;AACA,MAAI,gBAAgB,IAAI,GAAG;AACzB,UAAM,UAAU,qBAAqB,IAAI;AACzC,WAAO,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO;AAAA,EACxD;AACA,MAAI,oBAAoB,IAAI,GAAG;AAC7B,UAAM,UAAU,qBAAqB,KAAK,IAAI;AAC9C,WAAO,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO;AAAA,EACxD;AAEA,QAAM,aAAa;AACnB,SAAO,EAAE,OAAO,WAAW,OAAO,QAAQ,WAAW,OAAO;AAC9D;AAKO,SAAS,gBAAgB,OAA2C;AACzE,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS;AAE1C;AAKO,SAAS,oBAAoB,OAA4C;AAC9E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS;AAE1C;AAKO,SAAS,mBAAmB,OAA2C;AAC5E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,YAAY,SACZ,OAAQ,MAA2B,WAAW;AAElD;AASO,SAAS,aAAa,QAAsC;AACjE,SAAO,OAAO,OAAO;AACvB;AASO,SAAS,qBAAqB,QAAyC;AAC5E,SAAO,OAAO,OAAO;AACvB;AAMO,SAAS,cAAc,OAAsC;AAClE,SAAO,mBAAmB,KAAK,KAAK,mBAAmB,KAAK;AAC9D;AAcO,SAAS,iBACd,SAC2B;AAC3B,MAAI,gBAAgB,OAAO,GAAG;AAC5B,WAAO;AAAA,EACT;AACA,QAAM,kBAAkB;AACxB,SAAO,gBAAgB;AACzB;","names":[]}
|
package/dist/chunk-36WJWNHT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-36WJWNHT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-3F4RFQIB.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isParamPlaceholder
|
|
3
|
-
} from "./chunk-2MAKNVCP.js";
|
|
4
|
-
|
|
5
|
-
// src/operations-registry.ts
|
|
6
|
-
import { hasAllCapabilities } from "@prisma-next/operations";
|
|
7
|
-
import { planInvalid } from "@prisma-next/plan";
|
|
8
|
-
function isExpressionSource(value) {
|
|
9
|
-
return typeof value === "object" && value !== null && "toExpr" in value && typeof value.toExpr === "function";
|
|
10
|
-
}
|
|
11
|
-
function executeOperation(signature, selfBuilder, args, columnMeta, operationRegistry, contractCapabilities) {
|
|
12
|
-
if (args.length !== signature.args.length) {
|
|
13
|
-
throw planInvalid(
|
|
14
|
-
`Operation ${signature.method} expects ${signature.args.length} arguments, got ${args.length}`
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
const selfExpr = selfBuilder.toExpr();
|
|
18
|
-
const operationArgs = [];
|
|
19
|
-
for (let i = 0; i < args.length; i++) {
|
|
20
|
-
const arg = args[i];
|
|
21
|
-
const argSpec = signature.args[i];
|
|
22
|
-
if (!argSpec) {
|
|
23
|
-
throw planInvalid(`Missing argument spec for argument ${i}`);
|
|
24
|
-
}
|
|
25
|
-
if (argSpec.kind === "param") {
|
|
26
|
-
if (!isParamPlaceholder(arg)) {
|
|
27
|
-
throw planInvalid(`Argument ${i} must be a parameter placeholder`);
|
|
28
|
-
}
|
|
29
|
-
operationArgs.push({
|
|
30
|
-
kind: "param",
|
|
31
|
-
index: 0,
|
|
32
|
-
name: arg.name
|
|
33
|
-
});
|
|
34
|
-
} else if (argSpec.kind === "typeId") {
|
|
35
|
-
if (!isExpressionSource(arg)) {
|
|
36
|
-
throw planInvalid(
|
|
37
|
-
`Argument ${i} must be an ExpressionSource (ColumnBuilder or ExpressionBuilder)`
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
operationArgs.push(arg.toExpr());
|
|
41
|
-
} else if (argSpec.kind === "literal") {
|
|
42
|
-
operationArgs.push({
|
|
43
|
-
kind: "literal",
|
|
44
|
-
value: arg
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const operationExpr = {
|
|
49
|
-
kind: "operation",
|
|
50
|
-
method: signature.method,
|
|
51
|
-
forTypeId: signature.forTypeId,
|
|
52
|
-
self: selfExpr,
|
|
53
|
-
args: operationArgs,
|
|
54
|
-
returns: signature.returns,
|
|
55
|
-
lowering: signature.lowering
|
|
56
|
-
};
|
|
57
|
-
const returnTypeId = signature.returns.kind === "typeId" ? signature.returns.type : void 0;
|
|
58
|
-
const returnColumnMeta = returnTypeId ? {
|
|
59
|
-
...columnMeta,
|
|
60
|
-
codecId: returnTypeId
|
|
61
|
-
} : columnMeta;
|
|
62
|
-
const createComparisonMethod = (op) => (value) => Object.freeze({
|
|
63
|
-
kind: "binary",
|
|
64
|
-
op,
|
|
65
|
-
left: operationExpr,
|
|
66
|
-
right: value
|
|
67
|
-
});
|
|
68
|
-
const baseResult = {
|
|
69
|
-
kind: "expression",
|
|
70
|
-
expr: operationExpr,
|
|
71
|
-
get columnMeta() {
|
|
72
|
-
return returnColumnMeta;
|
|
73
|
-
},
|
|
74
|
-
eq: createComparisonMethod("eq"),
|
|
75
|
-
neq: createComparisonMethod("neq"),
|
|
76
|
-
gt: createComparisonMethod("gt"),
|
|
77
|
-
lt: createComparisonMethod("lt"),
|
|
78
|
-
gte: createComparisonMethod("gte"),
|
|
79
|
-
lte: createComparisonMethod("lte"),
|
|
80
|
-
asc() {
|
|
81
|
-
return Object.freeze({
|
|
82
|
-
kind: "order",
|
|
83
|
-
expr: operationExpr,
|
|
84
|
-
dir: "asc"
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
desc() {
|
|
88
|
-
return Object.freeze({
|
|
89
|
-
kind: "order",
|
|
90
|
-
expr: operationExpr,
|
|
91
|
-
dir: "desc"
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
toExpr() {
|
|
95
|
-
return operationExpr;
|
|
96
|
-
},
|
|
97
|
-
get __jsType() {
|
|
98
|
-
return void 0;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
if (returnTypeId && operationRegistry) {
|
|
102
|
-
const resultWithOps = attachOperationsToExpressionBuilder(
|
|
103
|
-
baseResult,
|
|
104
|
-
returnColumnMeta,
|
|
105
|
-
operationRegistry,
|
|
106
|
-
contractCapabilities
|
|
107
|
-
);
|
|
108
|
-
return Object.freeze(resultWithOps);
|
|
109
|
-
}
|
|
110
|
-
return Object.freeze(baseResult);
|
|
111
|
-
}
|
|
112
|
-
function attachOperationsToExpressionBuilder(expressionBuilder, columnMeta, registry, contractCapabilities) {
|
|
113
|
-
const codecId = columnMeta.codecId;
|
|
114
|
-
if (!codecId) {
|
|
115
|
-
return expressionBuilder;
|
|
116
|
-
}
|
|
117
|
-
const operations = registry.byType(codecId);
|
|
118
|
-
if (operations.length === 0) {
|
|
119
|
-
return expressionBuilder;
|
|
120
|
-
}
|
|
121
|
-
const builderWithOps = expressionBuilder;
|
|
122
|
-
for (const operation of operations) {
|
|
123
|
-
if (operation.capabilities && operation.capabilities.length > 0) {
|
|
124
|
-
if (!contractCapabilities) {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (!hasAllCapabilities(operation.capabilities, contractCapabilities)) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
builderWithOps[operation.method] = function(...args) {
|
|
132
|
-
return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
return builderWithOps;
|
|
136
|
-
}
|
|
137
|
-
function attachOperationsToColumnBuilder(columnBuilder, columnMeta, registry, contractCapabilities) {
|
|
138
|
-
if (!registry) {
|
|
139
|
-
return columnBuilder;
|
|
140
|
-
}
|
|
141
|
-
const codecId = columnMeta.codecId;
|
|
142
|
-
if (!codecId) {
|
|
143
|
-
return columnBuilder;
|
|
144
|
-
}
|
|
145
|
-
const operations = registry.byType(codecId);
|
|
146
|
-
if (operations.length === 0) {
|
|
147
|
-
return columnBuilder;
|
|
148
|
-
}
|
|
149
|
-
const builderWithOps = columnBuilder;
|
|
150
|
-
for (const operation of operations) {
|
|
151
|
-
if (operation.capabilities && operation.capabilities.length > 0) {
|
|
152
|
-
if (!contractCapabilities) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (!hasAllCapabilities(operation.capabilities, contractCapabilities)) {
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
builderWithOps[operation.method] = function(...args) {
|
|
160
|
-
return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return builderWithOps;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export {
|
|
167
|
-
attachOperationsToColumnBuilder
|
|
168
|
-
};
|
|
169
|
-
//# sourceMappingURL=chunk-3F4RFQIB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/operations-registry.ts"],"sourcesContent":["import type { OperationRegistry } from '@prisma-next/operations';\nimport { hasAllCapabilities } from '@prisma-next/operations';\nimport { planInvalid } from '@prisma-next/plan';\nimport type { StorageColumn } from '@prisma-next/sql-contract/types';\nimport type { SqlOperationSignature } from '@prisma-next/sql-operations';\nimport type {\n BinaryOp,\n Expression,\n ExpressionSource,\n LiteralExpr,\n OperationExpr,\n ParamRef,\n} from './ast/types';\nimport type {\n AnyBinaryBuilder,\n AnyOrderBuilder,\n ColumnBuilder,\n ExpressionBuilder,\n OperationTypes,\n ParamPlaceholder,\n} from './types';\nimport { isParamPlaceholder } from './utils/guards';\n\n/**\n * Type guard to check if a value is an ExpressionSource (has toExpr method).\n */\nfunction isExpressionSource(value: unknown): value is ExpressionSource {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'toExpr' in value &&\n typeof (value as ExpressionSource).toExpr === 'function'\n );\n}\n\n/**\n * Executes an operation and returns an ExpressionBuilder.\n * This is the canonical entrypoint for operation invocation, enabling\n * future enhancements like telemetry, caching, or tracing.\n *\n * The returned ExpressionBuilder:\n * - Has `kind: 'expression'` to distinguish it from ColumnBuilder\n * - Contains the operation expression in `expr`\n * - Provides `toExpr()` method to get the Expression\n * - Provides comparison and ordering methods for chaining\n *\n * @param signature - The operation signature from the registry\n * @param selfBuilder - The expression source that the operation is called on\n * @param args - The arguments passed to the operation\n * @param columnMeta - The metadata of the column the operation is called on\n * @returns An ExpressionBuilder containing the operation expression\n */\nfunction executeOperation(\n signature: SqlOperationSignature,\n selfBuilder: ExpressionSource,\n args: unknown[],\n columnMeta: StorageColumn,\n operationRegistry?: OperationRegistry,\n contractCapabilities?: Record<string, Record<string, boolean>>,\n): ExpressionBuilder {\n if (args.length !== signature.args.length) {\n throw planInvalid(\n `Operation ${signature.method} expects ${signature.args.length} arguments, got ${args.length}`,\n );\n }\n\n // Get the Expression from the self builder using toExpr()\n const selfExpr: Expression = selfBuilder.toExpr();\n\n const operationArgs: Array<Expression | ParamRef | LiteralExpr> = [];\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n const argSpec = signature.args[i];\n if (!argSpec) {\n throw planInvalid(`Missing argument spec for argument ${i}`);\n }\n\n if (argSpec.kind === 'param') {\n if (!isParamPlaceholder(arg)) {\n throw planInvalid(`Argument ${i} must be a parameter placeholder`);\n }\n operationArgs.push({\n kind: 'param',\n index: 0,\n name: arg.name,\n });\n } else if (argSpec.kind === 'typeId') {\n // Accept ExpressionSource (ColumnBuilder or ExpressionBuilder)\n if (!isExpressionSource(arg)) {\n throw planInvalid(\n `Argument ${i} must be an ExpressionSource (ColumnBuilder or ExpressionBuilder)`,\n );\n }\n // Use toExpr() to get the Expression\n operationArgs.push(arg.toExpr());\n } else if (argSpec.kind === 'literal') {\n operationArgs.push({\n kind: 'literal',\n value: arg,\n });\n }\n }\n\n const operationExpr: OperationExpr = {\n kind: 'operation',\n method: signature.method,\n forTypeId: signature.forTypeId,\n self: selfExpr,\n args: operationArgs,\n returns: signature.returns,\n lowering: signature.lowering,\n };\n\n const returnTypeId = signature.returns.kind === 'typeId' ? signature.returns.type : undefined;\n const returnColumnMeta: StorageColumn = returnTypeId\n ? {\n ...columnMeta,\n codecId: returnTypeId,\n }\n : columnMeta;\n\n const createComparisonMethod =\n (op: BinaryOp) =>\n (value: ParamPlaceholder | ExpressionSource): AnyBinaryBuilder =>\n Object.freeze({\n kind: 'binary' as const,\n op,\n left: operationExpr,\n right: value,\n }) as AnyBinaryBuilder;\n\n const baseResult: ExpressionBuilder = {\n kind: 'expression' as const,\n expr: operationExpr,\n get columnMeta() {\n return returnColumnMeta;\n },\n eq: createComparisonMethod('eq'),\n neq: createComparisonMethod('neq'),\n gt: createComparisonMethod('gt'),\n lt: createComparisonMethod('lt'),\n gte: createComparisonMethod('gte'),\n lte: createComparisonMethod('lte'),\n asc(): AnyOrderBuilder {\n return Object.freeze({\n kind: 'order' as const,\n expr: operationExpr,\n dir: 'asc' as const,\n });\n },\n desc(): AnyOrderBuilder {\n return Object.freeze({\n kind: 'order' as const,\n expr: operationExpr,\n dir: 'desc' as const,\n });\n },\n toExpr(): OperationExpr {\n return operationExpr;\n },\n get __jsType(): unknown {\n return undefined;\n },\n };\n\n // If the return type is a typeId, attach operations for that type\n if (returnTypeId && operationRegistry) {\n const resultWithOps = attachOperationsToExpressionBuilder(\n baseResult,\n returnColumnMeta,\n operationRegistry,\n contractCapabilities,\n );\n return Object.freeze(resultWithOps);\n }\n\n return Object.freeze(baseResult);\n}\n\n/**\n * Attaches operation methods to an ExpressionBuilder for chained operations.\n * When an operation returns a typeId, the result ExpressionBuilder needs\n * operation methods for that type.\n */\nfunction attachOperationsToExpressionBuilder(\n expressionBuilder: ExpressionBuilder,\n columnMeta: StorageColumn,\n registry: OperationRegistry,\n contractCapabilities?: Record<string, Record<string, boolean>>,\n): ExpressionBuilder {\n const codecId = columnMeta.codecId;\n if (!codecId) {\n return expressionBuilder;\n }\n\n const operations = registry.byType(codecId) as SqlOperationSignature[];\n if (operations.length === 0) {\n return expressionBuilder;\n }\n\n const builderWithOps = expressionBuilder as ExpressionBuilder & Record<string, unknown>;\n\n for (const operation of operations) {\n if (operation.capabilities && operation.capabilities.length > 0) {\n if (!contractCapabilities) {\n continue;\n }\n\n if (!hasAllCapabilities(operation.capabilities, contractCapabilities)) {\n continue;\n }\n }\n // Method sugar: attach operation as a method on the expression builder\n builderWithOps[operation.method] = function (this: ExpressionBuilder, ...args: unknown[]) {\n return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);\n };\n }\n\n return builderWithOps;\n}\n\nexport function attachOperationsToColumnBuilder<\n ColumnName extends string,\n ColumnMeta extends StorageColumn,\n JsType = unknown,\n Operations extends OperationTypes = Record<string, never>,\n>(\n columnBuilder: ColumnBuilder<ColumnName, ColumnMeta, JsType, Record<string, never>>,\n columnMeta: ColumnMeta,\n registry: OperationRegistry | undefined,\n contractCapabilities?: Record<string, Record<string, boolean>>,\n): ColumnBuilder<ColumnName, ColumnMeta, JsType, Operations> {\n if (!registry) {\n return columnBuilder as ColumnBuilder<ColumnName, ColumnMeta, JsType, Operations>;\n }\n\n // Use codecId to look up operations registered for this column's type\n const codecId = columnMeta.codecId;\n if (!codecId) {\n return columnBuilder as ColumnBuilder<ColumnName, ColumnMeta, JsType, Operations>;\n }\n\n const operations = registry.byType(codecId) as SqlOperationSignature[];\n if (operations.length === 0) {\n return columnBuilder as ColumnBuilder<ColumnName, ColumnMeta, JsType, Operations>;\n }\n\n const builderWithOps = columnBuilder as unknown as ColumnBuilder<\n ColumnName,\n ColumnMeta,\n JsType,\n Operations\n >;\n\n for (const operation of operations) {\n if (operation.capabilities && operation.capabilities.length > 0) {\n if (!contractCapabilities) {\n continue;\n }\n\n if (!hasAllCapabilities(operation.capabilities, contractCapabilities)) {\n continue;\n }\n }\n // Method sugar: attach operation as a method on the column builder\n // Operations return ExpressionBuilder, not ColumnBuilder\n (builderWithOps as Record<string, unknown>)[operation.method] = function (\n this: ColumnBuilder<ColumnName, ColumnMeta, JsType, Record<string, never>>,\n ...args: unknown[]\n ) {\n return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);\n };\n }\n\n return builderWithOps;\n}\n"],"mappings":";;;;;AACA,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAwB5B,SAAS,mBAAmB,OAA2C;AACrE,SACE,OAAO,UAAU,YACjB,UAAU,QACV,YAAY,SACZ,OAAQ,MAA2B,WAAW;AAElD;AAmBA,SAAS,iBACP,WACA,aACA,MACA,YACA,mBACA,s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