metal-orm 1.0.81 → 1.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +58 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/codegen/typescript.ts +40 -29
- package/src/core/ast/expression-nodes.ts +32 -21
- package/src/core/ast/expression-visitor.ts +6 -1
- package/src/core/ast/expression.ts +1 -0
- package/src/core/ast/param-proxy.ts +50 -0
- package/src/core/dialect/abstract.ts +12 -10
- package/src/openapi/query-parameters.ts +1 -0
- package/src/query-builder/relation-filter-utils.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -123,6 +123,7 @@ __export(index_exports, {
|
|
|
123
123
|
createExecutorFromQueryRunner: () => createExecutorFromQueryRunner,
|
|
124
124
|
createMssqlExecutor: () => createMssqlExecutor,
|
|
125
125
|
createMysqlExecutor: () => createMysqlExecutor,
|
|
126
|
+
createParamProxy: () => createParamProxy,
|
|
126
127
|
createPooledExecutorFactory: () => createPooledExecutorFactory,
|
|
127
128
|
createPostgresExecutor: () => createPostgresExecutor,
|
|
128
129
|
createQueryLoggingExecutor: () => createQueryLoggingExecutor,
|
|
@@ -643,6 +644,7 @@ var operandTypes = /* @__PURE__ */ new Set([
|
|
|
643
644
|
"AliasRef",
|
|
644
645
|
"Column",
|
|
645
646
|
"Literal",
|
|
647
|
+
"Param",
|
|
646
648
|
"Function",
|
|
647
649
|
"JsonPath",
|
|
648
650
|
"ScalarSubquery",
|
|
@@ -1082,6 +1084,9 @@ var visitOperand = (node, visitor) => {
|
|
|
1082
1084
|
case "Literal":
|
|
1083
1085
|
if (visitor.visitLiteral) return visitor.visitLiteral(node);
|
|
1084
1086
|
break;
|
|
1087
|
+
case "Param":
|
|
1088
|
+
if (visitor.visitParam) return visitor.visitParam(node);
|
|
1089
|
+
break;
|
|
1085
1090
|
case "Function":
|
|
1086
1091
|
if (visitor.visitFunction) return visitor.visitFunction(node);
|
|
1087
1092
|
break;
|
|
@@ -1113,6 +1118,47 @@ var visitOperand = (node, visitor) => {
|
|
|
1113
1118
|
return unsupportedOperand(node);
|
|
1114
1119
|
};
|
|
1115
1120
|
|
|
1121
|
+
// src/core/ast/param-proxy.ts
|
|
1122
|
+
var buildParamProxy = (name) => {
|
|
1123
|
+
const target = { type: "Param", name };
|
|
1124
|
+
return new Proxy(target, {
|
|
1125
|
+
get(t, prop, receiver) {
|
|
1126
|
+
if (prop === "then") return void 0;
|
|
1127
|
+
if (typeof prop === "symbol") {
|
|
1128
|
+
return Reflect.get(t, prop, receiver);
|
|
1129
|
+
}
|
|
1130
|
+
if (typeof prop === "string" && prop.startsWith("$")) {
|
|
1131
|
+
const trimmed = prop.slice(1);
|
|
1132
|
+
const nextName2 = name ? `${name}.${trimmed}` : trimmed;
|
|
1133
|
+
return buildParamProxy(nextName2);
|
|
1134
|
+
}
|
|
1135
|
+
if (prop in t) {
|
|
1136
|
+
return t[prop];
|
|
1137
|
+
}
|
|
1138
|
+
const nextName = name ? `${name}.${prop}` : prop;
|
|
1139
|
+
return buildParamProxy(nextName);
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
};
|
|
1143
|
+
var createParamProxy = () => {
|
|
1144
|
+
const target = {};
|
|
1145
|
+
return new Proxy(target, {
|
|
1146
|
+
get(t, prop, receiver) {
|
|
1147
|
+
if (prop === "then") return void 0;
|
|
1148
|
+
if (typeof prop === "symbol") {
|
|
1149
|
+
return Reflect.get(t, prop, receiver);
|
|
1150
|
+
}
|
|
1151
|
+
if (typeof prop === "string" && prop.startsWith("$")) {
|
|
1152
|
+
return buildParamProxy(prop.slice(1));
|
|
1153
|
+
}
|
|
1154
|
+
if (prop in t) {
|
|
1155
|
+
return t[prop];
|
|
1156
|
+
}
|
|
1157
|
+
return buildParamProxy(String(prop));
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1116
1162
|
// src/core/ast/adapters.ts
|
|
1117
1163
|
var hasAlias = (obj) => typeof obj === "object" && obj !== null && "alias" in obj;
|
|
1118
1164
|
var toColumnRef = (col2) => ({
|
|
@@ -1822,6 +1868,7 @@ var Dialect = class _Dialect {
|
|
|
1822
1868
|
}
|
|
1823
1869
|
registerDefaultOperandCompilers() {
|
|
1824
1870
|
this.registerOperandCompiler("Literal", (literal, ctx) => ctx.addParameter(literal.value));
|
|
1871
|
+
this.registerOperandCompiler("Param", (_param, ctx) => ctx.addParameter(null));
|
|
1825
1872
|
this.registerOperandCompiler("AliasRef", (alias, _ctx) => {
|
|
1826
1873
|
void _ctx;
|
|
1827
1874
|
return this.quoteIdentifier(alias.name);
|
|
@@ -4345,6 +4392,7 @@ var collectFromOperand = (node, collector) => {
|
|
|
4345
4392
|
break;
|
|
4346
4393
|
case "Literal":
|
|
4347
4394
|
case "AliasRef":
|
|
4395
|
+
case "Param":
|
|
4348
4396
|
break;
|
|
4349
4397
|
default:
|
|
4350
4398
|
break;
|
|
@@ -7611,6 +7659,7 @@ var collectFilterColumns = (expr, table, rootTables) => {
|
|
|
7611
7659
|
}
|
|
7612
7660
|
case "AliasRef":
|
|
7613
7661
|
case "Literal":
|
|
7662
|
+
case "Param":
|
|
7614
7663
|
return;
|
|
7615
7664
|
default:
|
|
7616
7665
|
return;
|
|
@@ -11650,6 +11699,7 @@ var TypeScriptGenerator = class {
|
|
|
11650
11699
|
case "WindowFunction":
|
|
11651
11700
|
case "Cast":
|
|
11652
11701
|
case "Collate":
|
|
11702
|
+
case "Param":
|
|
11653
11703
|
return this.printOperand(term);
|
|
11654
11704
|
default:
|
|
11655
11705
|
return this.printExpression(term);
|
|
@@ -11694,6 +11744,9 @@ var TypeScriptGenerator = class {
|
|
|
11694
11744
|
visitLiteral(node) {
|
|
11695
11745
|
return this.printLiteralOperand(node);
|
|
11696
11746
|
}
|
|
11747
|
+
visitParam(node) {
|
|
11748
|
+
return this.printParamOperand(node);
|
|
11749
|
+
}
|
|
11697
11750
|
visitFunction(node) {
|
|
11698
11751
|
return this.printFunctionOperand(node);
|
|
11699
11752
|
}
|
|
@@ -11815,6 +11868,10 @@ var TypeScriptGenerator = class {
|
|
|
11815
11868
|
if (literal.value === null) return "null";
|
|
11816
11869
|
return typeof literal.value === "string" ? `'${literal.value}'` : String(literal.value);
|
|
11817
11870
|
}
|
|
11871
|
+
printParamOperand(param) {
|
|
11872
|
+
const name = param.name.replace(/'/g, "\\'");
|
|
11873
|
+
return `{ type: 'Param', name: '${name}' }`;
|
|
11874
|
+
}
|
|
11818
11875
|
/**
|
|
11819
11876
|
* Prints a function operand to TypeScript code
|
|
11820
11877
|
* @param fn - Function node
|
|
@@ -14123,6 +14180,7 @@ function createPooledExecutorFactory(opts) {
|
|
|
14123
14180
|
createExecutorFromQueryRunner,
|
|
14124
14181
|
createMssqlExecutor,
|
|
14125
14182
|
createMysqlExecutor,
|
|
14183
|
+
createParamProxy,
|
|
14126
14184
|
createPooledExecutorFactory,
|
|
14127
14185
|
createPostgresExecutor,
|
|
14128
14186
|
createQueryLoggingExecutor,
|