@prisma-next/sql-relational-core 0.3.0-dev.6 → 0.3.0-dev.63
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/LICENSE +201 -0
- package/README.md +18 -2
- package/dist/errors-7_V3El9I.mjs +3 -0
- package/dist/errors-DVufq9PT.d.mts +2 -0
- package/dist/exports/ast.d.mts +192 -0
- package/dist/exports/ast.d.mts.map +1 -0
- package/dist/exports/ast.mjs +361 -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/guards-DCCpAlOL.d.mts +87 -0
- package/dist/guards-DCCpAlOL.d.mts.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +12 -0
- package/dist/operations-registry-DPZ5aElH.mjs +152 -0
- package/dist/operations-registry-DPZ5aElH.mjs.map +1 -0
- package/dist/operations-registry-wVEaiLyt.d.mts +9 -0
- package/dist/operations-registry-wVEaiLyt.d.mts.map +1 -0
- package/dist/param-C4n0OW59.d.mts +8 -0
- package/dist/param-C4n0OW59.d.mts.map +1 -0
- package/dist/param-DMU3OWfI.mjs +14 -0
- package/dist/param-DMU3OWfI.mjs.map +1 -0
- package/dist/plan-BhSWuTfw.d.mts +194 -0
- package/dist/plan-BhSWuTfw.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-CgrEMqEd.d.mts +86 -0
- package/dist/schema-CgrEMqEd.d.mts.map +1 -0
- package/dist/types-CEUzDuDC.d.mts +447 -0
- package/dist/types-CEUzDuDC.d.mts.map +1 -0
- package/dist/types-Cdi4Whda.mjs +18 -0
- package/dist/types-Cdi4Whda.mjs.map +1 -0
- package/package.json +38 -55
- package/src/ast/codec-types.ts +77 -8
- package/src/ast/delete.ts +2 -2
- package/src/ast/driver-types.ts +20 -3
- package/src/ast/predicate.ts +14 -4
- package/src/ast/select.ts +4 -3
- package/src/ast/sql-codecs.ts +67 -0
- package/src/ast/types.ts +89 -19
- package/src/ast/update.ts +2 -2
- package/src/exports/ast.ts +1 -0
- package/src/exports/guards.ts +5 -0
- package/src/exports/utils/guards.ts +1 -0
- package/src/operations-registry.ts +112 -73
- package/src/query-lane-context.ts +77 -1
- package/src/schema.ts +91 -33
- package/src/types.ts +327 -75
- package/src/utils/guards.ts +88 -18
- 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 -4
- 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 -118
- 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-36WJWNHT.js +0 -1
- package/dist/chunk-36WJWNHT.js.map +0 -1
- package/dist/chunk-5N34PNVZ.js +0 -62
- package/dist/chunk-5N34PNVZ.js.map +0 -1
- package/dist/chunk-7I3EMQID.js +0 -16
- package/dist/chunk-7I3EMQID.js.map +0 -1
- package/dist/chunk-CBTYMOX2.js +0 -152
- package/dist/chunk-CBTYMOX2.js.map +0 -1
- package/dist/chunk-G52ENULI.js +0 -1
- package/dist/chunk-G52ENULI.js.map +0 -1
- package/dist/chunk-KYSP7L5C.js +0 -16
- package/dist/chunk-KYSP7L5C.js.map +0 -1
- package/dist/chunk-M23L3JHG.js +0 -159
- package/dist/chunk-M23L3JHG.js.map +0 -1
- package/dist/chunk-MM74SVJ4.js +0 -13
- package/dist/chunk-MM74SVJ4.js.map +0 -1
- package/dist/chunk-U7AXAUJA.js +0 -1
- package/dist/chunk-U7AXAUJA.js.map +0 -1
- package/dist/chunk-WZBPVEZI.js +0 -320
- package/dist/chunk-WZBPVEZI.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 -46
- 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 -21
- 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 -14
- 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 -81
- 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 -16
- package/dist/query-lane-context.d.ts.map +0 -1
- package/dist/schema.d.ts +0 -63
- package/dist/schema.d.ts.map +0 -1
- package/dist/types.d.ts +0 -332
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/guards.d.ts +0 -55
- package/dist/utils/guards.d.ts.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
//#region src/utils/guards.ts
|
|
2
|
+
/**
|
|
3
|
+
* Helper to extract columnMeta from a ColumnBuilder or ExpressionBuilder.
|
|
4
|
+
* Returns StorageColumn if present, undefined otherwise.
|
|
5
|
+
* Both ColumnBuilder and ExpressionBuilder have columnMeta property.
|
|
6
|
+
*/
|
|
7
|
+
function getColumnMeta(expr) {
|
|
8
|
+
if ("columnMeta" in expr) return expr.columnMeta;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Type predicate to check if a value is a ParamPlaceholder.
|
|
12
|
+
*/
|
|
13
|
+
function isParamPlaceholder(value) {
|
|
14
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "param-placeholder" && "name" in value && typeof value.name === "string";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Recursively extracts the base ColumnRef from an OperationExpr.
|
|
18
|
+
* If the expression is already a ColumnRef, it is returned directly.
|
|
19
|
+
*/
|
|
20
|
+
function extractBaseColumnRef(expr) {
|
|
21
|
+
if (expr.kind === "col") return expr;
|
|
22
|
+
return extractBaseColumnRef(expr.self);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Recursively collects all ColumnRef nodes from an expression tree.
|
|
26
|
+
* Handles nested OperationExpr structures by traversing both self and args.
|
|
27
|
+
*/
|
|
28
|
+
function collectColumnRefs(expr) {
|
|
29
|
+
if (expr.kind === "col") return [expr];
|
|
30
|
+
if (expr.kind === "operation") {
|
|
31
|
+
const refs = collectColumnRefs(expr.self);
|
|
32
|
+
for (const arg of expr.args) refs.push(...collectColumnRefs(arg));
|
|
33
|
+
return refs;
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Type predicate to check if an expression is an OperationExpr.
|
|
39
|
+
*/
|
|
40
|
+
function isOperationExpr(expr) {
|
|
41
|
+
return typeof expr === "object" && expr !== null && "kind" in expr && expr.kind === "operation";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Helper to extract table and column from a ColumnBuilder, ExpressionBuilder, or OperationExpr.
|
|
45
|
+
* For ExpressionBuilder or OperationExpr, recursively unwraps to find the base ColumnRef.
|
|
46
|
+
*/
|
|
47
|
+
function getColumnInfo(expr) {
|
|
48
|
+
if (isOperationExpr(expr)) {
|
|
49
|
+
const baseCol = extractBaseColumnRef(expr);
|
|
50
|
+
return {
|
|
51
|
+
table: baseCol.table,
|
|
52
|
+
column: baseCol.column
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (isExpressionBuilder(expr)) {
|
|
56
|
+
const baseCol = extractBaseColumnRef(expr.expr);
|
|
57
|
+
return {
|
|
58
|
+
table: baseCol.table,
|
|
59
|
+
column: baseCol.column
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const colBuilder = expr;
|
|
63
|
+
return {
|
|
64
|
+
table: colBuilder.table,
|
|
65
|
+
column: colBuilder.column
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Type predicate to check if a value is a ColumnBuilder.
|
|
70
|
+
*/
|
|
71
|
+
function isColumnBuilder(value) {
|
|
72
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "column";
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Type predicate to check if a value is an ExpressionBuilder.
|
|
76
|
+
*/
|
|
77
|
+
function isExpressionBuilder(value) {
|
|
78
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "expression";
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Type predicate to check if a value is an ExpressionSource (has toExpr method).
|
|
82
|
+
*/
|
|
83
|
+
function isExpressionSource(value) {
|
|
84
|
+
return typeof value === "object" && value !== null && "toExpr" in value && typeof value.toExpr === "function";
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Converts any ExpressionSource to an Expression.
|
|
88
|
+
* This is the canonical way to get an AST Expression from a builder.
|
|
89
|
+
*
|
|
90
|
+
* @param source - A ColumnBuilder or ExpressionBuilder
|
|
91
|
+
* @returns The corresponding Expression (ColumnRef or OperationExpr)
|
|
92
|
+
*/
|
|
93
|
+
function toExpression(source) {
|
|
94
|
+
return source.toExpr();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Converts an AnyExpressionSource to an Expression.
|
|
98
|
+
* Handles both ColumnBuilder and ExpressionBuilder.
|
|
99
|
+
*
|
|
100
|
+
* @param source - A ColumnBuilder or ExpressionBuilder
|
|
101
|
+
* @returns The corresponding Expression (ColumnRef or OperationExpr)
|
|
102
|
+
*/
|
|
103
|
+
function expressionFromSource(source) {
|
|
104
|
+
return source.toExpr();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Type predicate to check if a value is a ValueSource.
|
|
108
|
+
* ValueSource is either a ParamPlaceholder or an ExpressionSource.
|
|
109
|
+
*/
|
|
110
|
+
function isValueSource(value) {
|
|
111
|
+
return isParamPlaceholder(value) || isExpressionSource(value);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Extracts and returns an OperationExpr from a builder.
|
|
115
|
+
* Returns the OperationExpr if the builder is an OperationExpr or has an _operationExpr property,
|
|
116
|
+
* otherwise returns undefined.
|
|
117
|
+
*
|
|
118
|
+
* @deprecated Use isExpressionBuilder() instead. This function exists for backward compatibility
|
|
119
|
+
* with code that uses the hidden _operationExpr property pattern.
|
|
120
|
+
*
|
|
121
|
+
* @design-note: This function accesses the hidden `_operationExpr` property, which is a code smell.
|
|
122
|
+
* The ExpressionBuilder type (introduced in the operation-expr-refactoring) provides a cleaner
|
|
123
|
+
* approach by explicitly representing operation results as a distinct type.
|
|
124
|
+
*/
|
|
125
|
+
function getOperationExpr(builder) {
|
|
126
|
+
if (isOperationExpr(builder)) return builder;
|
|
127
|
+
return builder._operationExpr;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { getColumnMeta as a, isExpressionBuilder as c, isParamPlaceholder as d, isValueSource as f, getColumnInfo as i, isExpressionSource as l, expressionFromSource as n, getOperationExpr as o, toExpression as p, extractBaseColumnRef as r, isColumnBuilder as s, collectColumnRefs as t, isOperationExpr as u };
|
|
132
|
+
//# sourceMappingURL=guards-0ycyntYX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards-0ycyntYX.mjs","names":["refs: ColumnRef[]"],"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":";;;;;;AAsBA,SAAgB,cAAc,MAAsD;AAGlF,KAAI,gBAAgB,KAClB,QAAO,KAAK;;;;;AAQhB,SAAgB,mBAAmB,OAA2C;AAC5E,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS,uBACtC,UAAU,SACV,OAAQ,MAA4B,SAAS;;;;;;AAQjD,SAAgB,qBAAqB,MAA4C;AAC/E,KAAI,KAAK,SAAS,MAChB,QAAO;AAET,QAAO,qBAAqB,KAAK,KAAK;;;;;;AAOxC,SAAgB,kBACd,MACa;AACb,KAAI,KAAK,SAAS,MAChB,QAAO,CAAC,KAAK;AAEf,KAAI,KAAK,SAAS,aAAa;EAC7B,MAAMA,OAAoB,kBAAkB,KAAK,KAAK;AACtD,OAAK,MAAM,OAAO,KAAK,KACrB,MAAK,KAAK,GAAG,kBAAkB,IAAI,CAAC;AAEtC,SAAO;;AAET,QAAO,EAAE;;;;;AAMX,SAAgB,gBACd,MACuB;AACvB,QAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,KAAK,SAAS;;;;;;AAOtF,SAAgB,cAAc,MAG5B;AACA,KAAI,gBAAgB,KAAK,EAAE;EACzB,MAAM,UAAU,qBAAqB,KAAK;AAC1C,SAAO;GAAE,OAAO,QAAQ;GAAO,QAAQ,QAAQ;GAAQ;;AAEzD,KAAI,oBAAoB,KAAK,EAAE;EAC7B,MAAM,UAAU,qBAAqB,KAAK,KAAK;AAC/C,SAAO;GAAE,OAAO,QAAQ;GAAO,QAAQ,QAAQ;GAAQ;;CAGzD,MAAM,aAAa;AACnB,QAAO;EAAE,OAAO,WAAW;EAAO,QAAQ,WAAW;EAAQ;;;;;AAM/D,SAAgB,gBAAgB,OAA2C;AACzE,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS;;;;;AAO1C,SAAgB,oBAAoB,OAA4C;AAC9E,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS;;;;;AAO1C,SAAgB,mBAAmB,OAA2C;AAC5E,QACE,OAAO,UAAU,YACjB,UAAU,QACV,YAAY,SACZ,OAAQ,MAA2B,WAAW;;;;;;;;;AAWlD,SAAgB,aAAa,QAAsC;AACjE,QAAO,OAAO,QAAQ;;;;;;;;;AAUxB,SAAgB,qBAAqB,QAAyC;AAC5E,QAAO,OAAO,QAAQ;;;;;;AAOxB,SAAgB,cAAc,OAAsC;AAClE,QAAO,mBAAmB,MAAM,IAAI,mBAAmB,MAAM;;;;;;;;;;;;;;AAe/D,SAAgB,iBACd,SAC2B;AAC3B,KAAI,gBAAgB,QAAQ,CAC1B,QAAO;AAGT,QADwB,QACD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { S as OperationExpr, d as Expression, f as ExpressionSource, s as ColumnRef, w as ParamRef, y as LiteralExpr } from "./plan-BhSWuTfw.mjs";
|
|
2
|
+
import { N as ParamPlaceholder, h as ExpressionBuilder, i as AnyExpressionSource, n as AnyColumnBuilder, q as ValueSource } from "./types-CEUzDuDC.mjs";
|
|
3
|
+
import { StorageColumn } from "@prisma-next/sql-contract/types";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/guards.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Helper to extract columnMeta from a ColumnBuilder or ExpressionBuilder.
|
|
9
|
+
* Returns StorageColumn if present, undefined otherwise.
|
|
10
|
+
* Both ColumnBuilder and ExpressionBuilder have columnMeta property.
|
|
11
|
+
*/
|
|
12
|
+
declare function getColumnMeta(expr: AnyExpressionSource): StorageColumn | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Type predicate to check if a value is a ParamPlaceholder.
|
|
15
|
+
*/
|
|
16
|
+
declare function isParamPlaceholder(value: unknown): value is ParamPlaceholder;
|
|
17
|
+
/**
|
|
18
|
+
* Recursively extracts the base ColumnRef from an OperationExpr.
|
|
19
|
+
* If the expression is already a ColumnRef, it is returned directly.
|
|
20
|
+
*/
|
|
21
|
+
declare function extractBaseColumnRef(expr: ColumnRef | OperationExpr): ColumnRef;
|
|
22
|
+
/**
|
|
23
|
+
* Recursively collects all ColumnRef nodes from an expression tree.
|
|
24
|
+
* Handles nested OperationExpr structures by traversing both self and args.
|
|
25
|
+
*/
|
|
26
|
+
declare function collectColumnRefs(expr: ColumnRef | ParamRef | LiteralExpr | OperationExpr): ColumnRef[];
|
|
27
|
+
/**
|
|
28
|
+
* Type predicate to check if an expression is an OperationExpr.
|
|
29
|
+
*/
|
|
30
|
+
declare function isOperationExpr(expr: AnyExpressionSource | OperationExpr | Expression): expr is OperationExpr;
|
|
31
|
+
/**
|
|
32
|
+
* Helper to extract table and column from a ColumnBuilder, ExpressionBuilder, or OperationExpr.
|
|
33
|
+
* For ExpressionBuilder or OperationExpr, recursively unwraps to find the base ColumnRef.
|
|
34
|
+
*/
|
|
35
|
+
declare function getColumnInfo(expr: AnyExpressionSource | OperationExpr): {
|
|
36
|
+
table: string;
|
|
37
|
+
column: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Type predicate to check if a value is a ColumnBuilder.
|
|
41
|
+
*/
|
|
42
|
+
declare function isColumnBuilder(value: unknown): value is AnyColumnBuilder;
|
|
43
|
+
/**
|
|
44
|
+
* Type predicate to check if a value is an ExpressionBuilder.
|
|
45
|
+
*/
|
|
46
|
+
declare function isExpressionBuilder(value: unknown): value is ExpressionBuilder;
|
|
47
|
+
/**
|
|
48
|
+
* Type predicate to check if a value is an ExpressionSource (has toExpr method).
|
|
49
|
+
*/
|
|
50
|
+
declare function isExpressionSource(value: unknown): value is ExpressionSource;
|
|
51
|
+
/**
|
|
52
|
+
* Converts any ExpressionSource to an Expression.
|
|
53
|
+
* This is the canonical way to get an AST Expression from a builder.
|
|
54
|
+
*
|
|
55
|
+
* @param source - A ColumnBuilder or ExpressionBuilder
|
|
56
|
+
* @returns The corresponding Expression (ColumnRef or OperationExpr)
|
|
57
|
+
*/
|
|
58
|
+
declare function toExpression(source: ExpressionSource): Expression;
|
|
59
|
+
/**
|
|
60
|
+
* Converts an AnyExpressionSource to an Expression.
|
|
61
|
+
* Handles both ColumnBuilder and ExpressionBuilder.
|
|
62
|
+
*
|
|
63
|
+
* @param source - A ColumnBuilder or ExpressionBuilder
|
|
64
|
+
* @returns The corresponding Expression (ColumnRef or OperationExpr)
|
|
65
|
+
*/
|
|
66
|
+
declare function expressionFromSource(source: AnyExpressionSource): Expression;
|
|
67
|
+
/**
|
|
68
|
+
* Type predicate to check if a value is a ValueSource.
|
|
69
|
+
* ValueSource is either a ParamPlaceholder or an ExpressionSource.
|
|
70
|
+
*/
|
|
71
|
+
declare function isValueSource(value: unknown): value is ValueSource;
|
|
72
|
+
/**
|
|
73
|
+
* Extracts and returns an OperationExpr from a builder.
|
|
74
|
+
* Returns the OperationExpr if the builder is an OperationExpr or has an _operationExpr property,
|
|
75
|
+
* otherwise returns undefined.
|
|
76
|
+
*
|
|
77
|
+
* @deprecated Use isExpressionBuilder() instead. This function exists for backward compatibility
|
|
78
|
+
* with code that uses the hidden _operationExpr property pattern.
|
|
79
|
+
*
|
|
80
|
+
* @design-note: This function accesses the hidden `_operationExpr` property, which is a code smell.
|
|
81
|
+
* The ExpressionBuilder type (introduced in the operation-expr-refactoring) provides a cleaner
|
|
82
|
+
* approach by explicitly representing operation results as a distinct type.
|
|
83
|
+
*/
|
|
84
|
+
declare function getOperationExpr(builder: AnyColumnBuilder | OperationExpr): OperationExpr | undefined;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { getColumnMeta as a, isExpressionBuilder as c, isParamPlaceholder as d, isValueSource as f, getColumnInfo as i, isExpressionSource as l, expressionFromSource as n, getOperationExpr as o, toExpression as p, extractBaseColumnRef as r, isColumnBuilder as s, collectColumnRefs as t, isOperationExpr as u };
|
|
87
|
+
//# sourceMappingURL=guards-DCCpAlOL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards-DCCpAlOL.d.mts","names":[],"sources":["../src/utils/guards.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAsBA;AAYA;AAeA;AAA2C,iBA3B3B,aAAA,CA2B2B,IAAA,EA3BP,mBA2BO,CAAA,EA3Be,aA2Bf,GAAA,SAAA;;;;AAW3B,iBA1BA,kBAAA,CA0BiB,KAAA,EAAA,OAAA,CAAA,EAAA,KAAA,IA1B4B,gBA0B5B;;;;;AAE9B,iBAba,oBAAA,CAab,IAAA,EAbwC,SAaxC,GAboD,aAapD,CAAA,EAboE,SAapE;;AAiBH;;;AAC8C,iBApB9B,iBAAA,CAoB8B,IAAA,EAnBtC,SAmBsC,GAnB1B,QAmB0B,GAnBf,WAmBe,GAnBD,aAmBC,CAAA,EAlB3C,SAkB2C,EAAA;;;AAS9C;AAoBgB,iBA9BA,eAAA,CA8B0C,IAAA,EA7BlD,mBA6BkE,GA7B5C,aA6B4C,GA7B5B,UA6B4B,CAAA,EAAA,IAAA,IA5B/D,aA4B+D;AAY1E;AAYA;AAgBA;AAWA;AAQgB,iBA/EA,aAAA,CA+EwC,IAAA,EA/EpB,mBA+E+B,GA/ET,aA+ES,CAAA,EAAA;EAgBnD,KAAA,EAAA,MAAA;EACL,MAAA,EAAA,MAAA;CAAmB;;;;iBA5Ed,eAAA,2BAA0C;;;;iBAY1C,mBAAA,2BAA8C;;;;iBAY9C,kBAAA,2BAA6C;;;;;;;;iBAgB7C,YAAA,SAAqB,mBAAmB;;;;;;;;iBAWxC,oBAAA,SAA6B,sBAAsB;;;;;iBAQnD,aAAA,2BAAwC;;;;;;;;;;;;;iBAgBxC,gBAAA,UACL,mBAAmB,gBAC3B"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { S as defineCodecs, _ as CodecRegistry, a as JsonSchemaValidationResult, b as codec, c as MutationDefaultsOptions, d as CodecDefBuilder, f as CodecId, g as CodecParamsDescriptor, h as CodecOutput, i as JsonSchemaValidationError, l as TypeHelperRegistry, m as CodecMeta, n as ExecutionContext, o as JsonSchemaValidatorRegistry, p as CodecInput, r as JsonSchemaValidateFn, s as MutationDefaultsOp, t as AppliedMutationDefault, u as Codec, v as ExtractCodecTypes, x as createCodecRegistry, y as ExtractDataTypes } from "./query-lane-context-CgkPuKaR.mjs";
|
|
2
|
+
import { A as WhereArg, C as OrExpr, D as TableRef, E as SelectAst, M as isOperationExpr, O as ToWhereExpr, S as OperationExpr, T as QueryAst, _ as JoinOnExpr, a as BinaryOp, b as LoweredStatement, c as DeleteAst, d as Expression, f as ExpressionSource, g as JoinAst, h as InsertAst, i as BinaryExpr, j as WhereExpr, k as UpdateAst, l as Direction, m as IncludeRef, n as augmentDescriptorWithColumnMeta, o as BoundWhereExpr, p as IncludeAst, r as AndExpr, s as ColumnRef, t as SqlQueryPlan, u as ExistsExpr, v as ListLiteralExpr, w as ParamRef, x as NullCheckExpr, y as LiteralExpr } from "./plan-BhSWuTfw.mjs";
|
|
3
|
+
import { A as OperationTypes, B as SqlBuilderOptions, C as Meta, D as NullCheckBuilder, E as NestedProjection, F as RawFunctionOptions, G as TablesOf, H as TableDef, I as RawTemplateFactory, J as createOrderBuilder, K as UnaryBuilder, L as RawTemplateOptions, M as OrderBuilder, N as ParamPlaceholder, O as NullableMethods, P as RawFactory, R as ResultType, S as META, T as ModelMetadata, U as TableKey, V as SqlPlan, W as TableMetadata, Y as isColumnBuilder, _ as InferNestedProjectionRow, a as AnyOrderBuilder, b as JoinOnBuilder, c as BuildOptions, d as ColumnBuilder, f as ColumnsOf, g as HasIncludeManyCapabilities, h as ExpressionBuilder, i as AnyExpressionSource, j as OperationsForTypeId, k as OperationTypeSignature, l as BuildParamsMap, m as Expr, n as AnyColumnBuilder, o as AnyUnaryBuilder, p as ComputeColumnJsType, q as ValueSource, r as AnyColumnBuilderBase, s as BinaryBuilder, t as AnyBinaryBuilder, u as CodecTypes, v as InferProjectionRow, w as ModelDef, x as JoinOnPredicate, y as InferReturningRow, z as RuntimeError } from "./types-CEUzDuDC.mjs";
|
|
4
|
+
import { Adapter, AdapterProfile, AdapterTarget, CreateDeleteAstOptions, CreateInsertAstOptions, CreateSelectAstOptions, CreateUpdateAstOptions, LoweredPayload, Lowerer, LowererContext, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, SqlCodecTypes, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlQueryResult, SqlQueryable, SqlTransaction, compact, createBinaryExpr, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, sqlCodecDefinitions, sqlDataTypes } from "./exports/ast.mjs";
|
|
5
|
+
import { n as planUnsupported, t as planInvalid } from "./errors-DVufq9PT.mjs";
|
|
6
|
+
import { t as attachOperationsToColumnBuilder } from "./operations-registry-wVEaiLyt.mjs";
|
|
7
|
+
import { n as param, t as Parameter } from "./param-C4n0OW59.mjs";
|
|
8
|
+
import "./exports/plan.mjs";
|
|
9
|
+
import "./exports/query-lane-context.mjs";
|
|
10
|
+
import { i as schema, n as SchemaHandle, r as TableBuilderImpl, t as ColumnBuilderImpl } from "./schema-CgrEMqEd.mjs";
|
|
11
|
+
import "./exports/types.mjs";
|
|
12
|
+
export { Adapter, AdapterProfile, AdapterTarget, AndExpr, AnyBinaryBuilder, AnyColumnBuilder, AnyColumnBuilderBase, AnyExpressionSource, AnyOrderBuilder, AnyUnaryBuilder, AppliedMutationDefault, BinaryBuilder, BinaryExpr, BinaryOp, BoundWhereExpr, BuildOptions, BuildParamsMap, Codec, CodecDefBuilder, CodecId, CodecInput, CodecMeta, CodecOutput, CodecParamsDescriptor, CodecRegistry, CodecTypes, ColumnBuilderImpl as Column, ColumnBuilderImpl, ColumnBuilder, ColumnRef, ColumnsOf, ComputeColumnJsType, CreateDeleteAstOptions, CreateInsertAstOptions, CreateSelectAstOptions, CreateUpdateAstOptions, DeleteAst, Direction, ExecutionContext, ExistsExpr, Expr, Expression, ExpressionBuilder, ExpressionSource, ExtractCodecTypes, ExtractDataTypes, HasIncludeManyCapabilities, IncludeAst, IncludeRef, InferNestedProjectionRow, InferProjectionRow, InferReturningRow, InsertAst, JoinAst, JoinOnBuilder, JoinOnExpr, JoinOnPredicate, JsonSchemaValidateFn, JsonSchemaValidationError, JsonSchemaValidationResult, JsonSchemaValidatorRegistry, ListLiteralExpr, LiteralExpr, LoweredPayload, LoweredStatement, Lowerer, LowererContext, META, Meta, ModelDef, ModelMetadata, MutationDefaultsOp, MutationDefaultsOptions, NestedProjection, NullCheckBuilder, NullCheckExpr, NullableMethods, OperationExpr, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrExpr, OrderBuilder, ParamPlaceholder, ParamRef, Parameter, QueryAst, RawFactory, RawFunctionOptions, RawTemplateFactory, RawTemplateOptions, ResultType, RuntimeError, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, SchemaHandle, SelectAst, SqlBuilderOptions, SqlCodecTypes, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlPlan, SqlQueryPlan, SqlQueryResult, SqlQueryable, SqlTransaction, TableBuilderImpl as Table, TableBuilderImpl, TableDef, TableKey, TableMetadata, TableRef, TablesOf, ToWhereExpr, TypeHelperRegistry, UnaryBuilder, UpdateAst, ValueSource, WhereArg, WhereExpr, attachOperationsToColumnBuilder, augmentDescriptorWithColumnMeta, codec, compact, createBinaryExpr, createCodecRegistry, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderBuilder, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, defineCodecs, isColumnBuilder, isOperationExpr, param, planInvalid, planUnsupported, schema, sqlCodecDefinitions, sqlDataTypes };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { n as isColumnBuilder, t as createOrderBuilder } from "./types-Cdi4Whda.mjs";
|
|
2
|
+
import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, codec, compact, createBinaryExpr, createCodecRegistry, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, defineCodecs, isOperationExpr, sqlCodecDefinitions, sqlDataTypes } from "./exports/ast.mjs";
|
|
3
|
+
import { n as planUnsupported, t as planInvalid } from "./errors-7_V3El9I.mjs";
|
|
4
|
+
import { t as attachOperationsToColumnBuilder } from "./operations-registry-DPZ5aElH.mjs";
|
|
5
|
+
import "./exports/operations-registry.mjs";
|
|
6
|
+
import { t as param } from "./param-DMU3OWfI.mjs";
|
|
7
|
+
import { augmentDescriptorWithColumnMeta } from "./exports/plan.mjs";
|
|
8
|
+
import "./exports/query-lane-context.mjs";
|
|
9
|
+
import { n as TableBuilderImpl, r as schema, t as ColumnBuilderImpl } from "./schema-Bi5p4aAc.mjs";
|
|
10
|
+
import "./exports/types.mjs";
|
|
11
|
+
|
|
12
|
+
export { ColumnBuilderImpl, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, TableBuilderImpl, attachOperationsToColumnBuilder, augmentDescriptorWithColumnMeta, codec, compact, createBinaryExpr, createCodecRegistry, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderBuilder, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, defineCodecs, isColumnBuilder, isOperationExpr, param, planInvalid, planUnsupported, schema, sqlCodecDefinitions, sqlDataTypes };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { d as isParamPlaceholder } from "./guards-0ycyntYX.mjs";
|
|
2
|
+
import { planInvalid } from "@prisma-next/plan";
|
|
3
|
+
import { hasAllCapabilities } from "@prisma-next/operations";
|
|
4
|
+
|
|
5
|
+
//#region src/operations-registry.ts
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if a value is an ExpressionSource (has toExpr method).
|
|
8
|
+
*/
|
|
9
|
+
function isExpressionSource(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && "toExpr" in value && typeof value.toExpr === "function";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Executes an operation and returns an ExpressionBuilder.
|
|
14
|
+
* This is the canonical entrypoint for operation invocation, enabling
|
|
15
|
+
* future enhancements like telemetry, caching, or tracing.
|
|
16
|
+
*
|
|
17
|
+
* The returned ExpressionBuilder:
|
|
18
|
+
* - Has `kind: 'expression'` to distinguish it from ColumnBuilder
|
|
19
|
+
* - Contains the operation expression in `expr`
|
|
20
|
+
* - Provides `toExpr()` method to get the Expression
|
|
21
|
+
* - Provides comparison and ordering methods for chaining
|
|
22
|
+
*
|
|
23
|
+
* @param signature - The operation signature from the registry
|
|
24
|
+
* @param selfBuilder - The expression source that the operation is called on
|
|
25
|
+
* @param args - The arguments passed to the operation
|
|
26
|
+
* @param columnMeta - The metadata of the column the operation is called on
|
|
27
|
+
* @returns An ExpressionBuilder containing the operation expression
|
|
28
|
+
*/
|
|
29
|
+
function executeOperation(signature, selfBuilder, args, columnMeta, operationRegistry, contractCapabilities) {
|
|
30
|
+
if (args.length !== signature.args.length) throw planInvalid(`Operation ${signature.method} expects ${signature.args.length} arguments, got ${args.length}`);
|
|
31
|
+
const selfExpr = selfBuilder.toExpr();
|
|
32
|
+
const operationArgs = [];
|
|
33
|
+
for (let i = 0; i < args.length; i++) {
|
|
34
|
+
const arg = args[i];
|
|
35
|
+
const argSpec = signature.args[i];
|
|
36
|
+
if (!argSpec) throw planInvalid(`Missing argument spec for argument ${i}`);
|
|
37
|
+
if (argSpec.kind === "param") {
|
|
38
|
+
if (!isParamPlaceholder(arg)) throw planInvalid(`Argument ${i} must be a parameter placeholder`);
|
|
39
|
+
operationArgs.push({
|
|
40
|
+
kind: "param",
|
|
41
|
+
index: 0,
|
|
42
|
+
name: arg.name
|
|
43
|
+
});
|
|
44
|
+
} else if (argSpec.kind === "typeId") {
|
|
45
|
+
if (!isExpressionSource(arg)) throw planInvalid(`Argument ${i} must be an ExpressionSource (ColumnBuilder or ExpressionBuilder)`);
|
|
46
|
+
operationArgs.push(arg.toExpr());
|
|
47
|
+
} else if (argSpec.kind === "literal") operationArgs.push({
|
|
48
|
+
kind: "literal",
|
|
49
|
+
value: arg
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const operationExpr = {
|
|
53
|
+
kind: "operation",
|
|
54
|
+
method: signature.method,
|
|
55
|
+
forTypeId: signature.forTypeId,
|
|
56
|
+
self: selfExpr,
|
|
57
|
+
args: operationArgs,
|
|
58
|
+
returns: signature.returns,
|
|
59
|
+
lowering: signature.lowering
|
|
60
|
+
};
|
|
61
|
+
const returnTypeId = signature.returns.kind === "typeId" ? signature.returns.type : void 0;
|
|
62
|
+
const returnColumnMeta = returnTypeId ? {
|
|
63
|
+
...columnMeta,
|
|
64
|
+
codecId: returnTypeId
|
|
65
|
+
} : columnMeta;
|
|
66
|
+
const createComparisonMethod = (op) => (value) => Object.freeze({
|
|
67
|
+
kind: "binary",
|
|
68
|
+
op,
|
|
69
|
+
left: operationExpr,
|
|
70
|
+
right: value
|
|
71
|
+
});
|
|
72
|
+
const baseResult = {
|
|
73
|
+
kind: "expression",
|
|
74
|
+
expr: operationExpr,
|
|
75
|
+
get columnMeta() {
|
|
76
|
+
return returnColumnMeta;
|
|
77
|
+
},
|
|
78
|
+
eq: createComparisonMethod("eq"),
|
|
79
|
+
neq: createComparisonMethod("neq"),
|
|
80
|
+
gt: createComparisonMethod("gt"),
|
|
81
|
+
lt: createComparisonMethod("lt"),
|
|
82
|
+
gte: createComparisonMethod("gte"),
|
|
83
|
+
lte: createComparisonMethod("lte"),
|
|
84
|
+
asc() {
|
|
85
|
+
return Object.freeze({
|
|
86
|
+
kind: "order",
|
|
87
|
+
expr: operationExpr,
|
|
88
|
+
dir: "asc"
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
desc() {
|
|
92
|
+
return Object.freeze({
|
|
93
|
+
kind: "order",
|
|
94
|
+
expr: operationExpr,
|
|
95
|
+
dir: "desc"
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
toExpr() {
|
|
99
|
+
return operationExpr;
|
|
100
|
+
},
|
|
101
|
+
get __jsType() {}
|
|
102
|
+
};
|
|
103
|
+
if (returnTypeId && operationRegistry) {
|
|
104
|
+
const resultWithOps = attachOperationsToExpressionBuilder(baseResult, returnColumnMeta, operationRegistry, contractCapabilities);
|
|
105
|
+
return Object.freeze(resultWithOps);
|
|
106
|
+
}
|
|
107
|
+
return Object.freeze(baseResult);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Attaches operation methods to an ExpressionBuilder for chained operations.
|
|
111
|
+
* When an operation returns a typeId, the result ExpressionBuilder needs
|
|
112
|
+
* operation methods for that type.
|
|
113
|
+
*/
|
|
114
|
+
function attachOperationsToExpressionBuilder(expressionBuilder, columnMeta, registry, contractCapabilities) {
|
|
115
|
+
const codecId = columnMeta.codecId;
|
|
116
|
+
if (!codecId) return expressionBuilder;
|
|
117
|
+
const operations = registry.byType(codecId);
|
|
118
|
+
if (operations.length === 0) return expressionBuilder;
|
|
119
|
+
const builderWithOps = expressionBuilder;
|
|
120
|
+
for (const operation of operations) {
|
|
121
|
+
if (operation.capabilities && operation.capabilities.length > 0) {
|
|
122
|
+
if (!contractCapabilities) continue;
|
|
123
|
+
if (!hasAllCapabilities(operation.capabilities, contractCapabilities)) continue;
|
|
124
|
+
}
|
|
125
|
+
builderWithOps[operation.method] = function(...args) {
|
|
126
|
+
return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return builderWithOps;
|
|
130
|
+
}
|
|
131
|
+
function attachOperationsToColumnBuilder(columnBuilder, columnMeta, registry, contractCapabilities) {
|
|
132
|
+
if (!registry) return columnBuilder;
|
|
133
|
+
const codecId = columnMeta.codecId;
|
|
134
|
+
if (!codecId) return columnBuilder;
|
|
135
|
+
const operations = registry.byType(codecId);
|
|
136
|
+
if (operations.length === 0) return columnBuilder;
|
|
137
|
+
const builderWithOps = columnBuilder;
|
|
138
|
+
for (const operation of operations) {
|
|
139
|
+
if (operation.capabilities && operation.capabilities.length > 0) {
|
|
140
|
+
if (!contractCapabilities) continue;
|
|
141
|
+
if (!hasAllCapabilities(operation.capabilities, contractCapabilities)) continue;
|
|
142
|
+
}
|
|
143
|
+
builderWithOps[operation.method] = function(...args) {
|
|
144
|
+
return executeOperation(operation, this, args, columnMeta, registry, contractCapabilities);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return builderWithOps;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
export { attachOperationsToColumnBuilder as t };
|
|
152
|
+
//# sourceMappingURL=operations-registry-DPZ5aElH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations-registry-DPZ5aElH.mjs","names":["selfExpr: Expression","operationArgs: Array<Expression | ParamRef | LiteralExpr>","operationExpr: OperationExpr","returnColumnMeta: StorageColumn","baseResult: ExpressionBuilder"],"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":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { A as OperationTypes, d as ColumnBuilder } from "./types-CEUzDuDC.mjs";
|
|
2
|
+
import { OperationRegistry } from "@prisma-next/operations";
|
|
3
|
+
import { StorageColumn } from "@prisma-next/sql-contract/types";
|
|
4
|
+
|
|
5
|
+
//#region src/operations-registry.d.ts
|
|
6
|
+
declare function attachOperationsToColumnBuilder<ColumnName extends string, ColumnMeta extends StorageColumn, JsType = unknown, Operations extends OperationTypes = Record<string, never>>(columnBuilder: ColumnBuilder<ColumnName, ColumnMeta, JsType, Record<string, never>>, columnMeta: ColumnMeta, registry: OperationRegistry | undefined, contractCapabilities?: Record<string, Record<string, boolean>>): ColumnBuilder<ColumnName, ColumnMeta, JsType, Operations>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { attachOperationsToColumnBuilder as t };
|
|
9
|
+
//# sourceMappingURL=operations-registry-wVEaiLyt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations-registry-wVEaiLyt.d.mts","names":[],"sources":["../src/operations-registry.ts"],"sourcesContent":[],"mappings":";;;;;iBA6NgB,8EAEK,oDAEA,iBAAiB,sCAErB,cAAc,YAAY,YAAY,QAAQ,oCACjD,sBACF,sDACa,eAAe,2BACrC,cAAc,YAAY,YAAY,QAAQ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { N as ParamPlaceholder } from "./types-CEUzDuDC.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/param.d.ts
|
|
4
|
+
type Parameter = ParamPlaceholder;
|
|
5
|
+
declare function param(name: string): Parameter;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { param as n, Parameter as t };
|
|
8
|
+
//# sourceMappingURL=param-C4n0OW59.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"param-C4n0OW59.d.mts","names":[],"sources":["../src/param.ts"],"sourcesContent":[],"mappings":";;;KAGY,SAAA,GAAY;iBAER,KAAA,gBAAqB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { planInvalid } from "@prisma-next/plan";
|
|
2
|
+
|
|
3
|
+
//#region src/param.ts
|
|
4
|
+
function param(name) {
|
|
5
|
+
if (typeof name !== "string" || name.length === 0) throw planInvalid("Parameter name must be a non-empty string");
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
kind: "param-placeholder",
|
|
8
|
+
name
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { param as t };
|
|
14
|
+
//# sourceMappingURL=param-DMU3OWfI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"param-DMU3OWfI.mjs","names":[],"sources":["../src/param.ts"],"sourcesContent":["import { planInvalid } from '@prisma-next/plan';\nimport type { ParamPlaceholder } from './types';\n\nexport type Parameter = ParamPlaceholder;\n\nexport function param(name: string): Parameter {\n if (typeof name !== 'string' || name.length === 0) {\n throw planInvalid('Parameter name must be a non-empty string');\n }\n\n return Object.freeze({\n kind: 'param-placeholder' as const,\n name,\n }) satisfies Parameter;\n}\n"],"mappings":";;;AAKA,SAAgB,MAAM,MAAyB;AAC7C,KAAI,OAAO,SAAS,YAAY,KAAK,WAAW,EAC9C,OAAM,YAAY,4CAA4C;AAGhE,QAAO,OAAO,OAAO;EACnB,MAAM;EACN;EACD,CAAC"}
|