@technicity/data-service-generator 0.13.26 → 0.14.1
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/generation/generate.d.ts +0 -1
- package/dist/generation/generate.js +269 -787
- package/dist/ksql.js +1 -24
- package/dist/runtime/Cache.js +3 -6
- package/dist/runtime/IRuntime.d.ts +4 -33
- package/dist/runtime/RuntimeKSQL.d.ts +0 -7
- package/dist/runtime/RuntimeKSQL.js +17 -47
- package/dist/runtime/RuntimeMSSQL.d.ts +1 -7
- package/dist/runtime/RuntimeMSSQL.js +4 -4
- package/dist/runtime/RuntimeMySQL.d.ts +1 -3
- package/dist/runtime/RuntimeMySQL.js +7 -33
- package/dist/runtime/lib/MSSQL.d.ts +1 -2
- package/dist/runtime/lib/MSSQL.js +8 -36
- package/dist/runtime/lib/MySQL.d.ts +1 -1
- package/dist/runtime/lib/MySQL.js +2 -15
- package/dist/runtime/lib/getSqlAst.js +21 -46
- package/dist/runtime/lib/shared.js +44 -156
- package/dist/runtime/lib/stringifyWhere.js +12 -39
- package/dist/runtime/lib/typeCastMSSQL.js +1 -24
- package/package.json +4 -1
- package/dist/runtime/RuntimeSQLite.d.ts +0 -38
- package/dist/runtime/RuntimeSQLite.js +0 -135
- package/dist/runtime/lib/addNullFallbacks.test.d.ts +0 -1
- package/dist/runtime/lib/addNullFallbacks.test.js +0 -206
- package/dist/runtime/lib/runTransforms.test.d.ts +0 -1
- package/dist/runtime/lib/runTransforms.test.js +0 -112
- package/dist/runtime/lib/stringifyWhere.test.d.ts +0 -1
- package/dist/runtime/lib/stringifyWhere.test.js +0 -236
- package/dist/traverseFieldArgs.test.d.ts +0 -1
- package/dist/traverseFieldArgs.test.js +0 -72
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const globals_1 = require("@jest/globals");
|
|
7
|
-
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
8
|
-
const stringifyWhere_1 = require("./stringifyWhere");
|
|
9
|
-
(0, globals_1.describe)("stringifyWhere", () => {
|
|
10
|
-
const table = "Usr";
|
|
11
|
-
const dialect = "mysql";
|
|
12
|
-
const args = {};
|
|
13
|
-
(0, globals_1.test)("should work", () => {
|
|
14
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
15
|
-
where: { userId: 2, text: "foo" },
|
|
16
|
-
table,
|
|
17
|
-
dialect,
|
|
18
|
-
args
|
|
19
|
-
});
|
|
20
|
-
strict_1.default.deepEqual(result, "Usr.`userId` = 2 AND Usr.`text` = 'foo'");
|
|
21
|
-
});
|
|
22
|
-
(0, globals_1.test)("should handle empty object", () => {
|
|
23
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({ where: {}, table, dialect, args });
|
|
24
|
-
strict_1.default.deepEqual(result, "");
|
|
25
|
-
});
|
|
26
|
-
(0, globals_1.test)("should handle $and", () => {
|
|
27
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
28
|
-
where: { $and: [{ valid: true }, { text: "foo" }] },
|
|
29
|
-
table,
|
|
30
|
-
dialect,
|
|
31
|
-
args
|
|
32
|
-
});
|
|
33
|
-
strict_1.default.deepEqual(result, "(Usr.`valid` = 1 AND Usr.`text` = 'foo')");
|
|
34
|
-
});
|
|
35
|
-
(0, globals_1.test)("should handle $or", () => {
|
|
36
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
37
|
-
where: { $or: [{ valid: true }, { text: "foo" }] },
|
|
38
|
-
table,
|
|
39
|
-
dialect,
|
|
40
|
-
args
|
|
41
|
-
});
|
|
42
|
-
strict_1.default.deepEqual(result, "(Usr.`valid` = 1 OR Usr.`text` = 'foo')");
|
|
43
|
-
});
|
|
44
|
-
(0, globals_1.test)("should handle null", () => {
|
|
45
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
46
|
-
where: { userId: null },
|
|
47
|
-
table,
|
|
48
|
-
dialect,
|
|
49
|
-
args
|
|
50
|
-
});
|
|
51
|
-
strict_1.default.deepEqual(result, "Usr.`userId` IS NULL");
|
|
52
|
-
});
|
|
53
|
-
(0, globals_1.test)("should handle $neq", () => {
|
|
54
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
55
|
-
where: { userId: { $neq: 2 }, text: "foo" },
|
|
56
|
-
table,
|
|
57
|
-
dialect,
|
|
58
|
-
args
|
|
59
|
-
});
|
|
60
|
-
strict_1.default.deepEqual(result, "Usr.`userId` != 2 AND Usr.`text` = 'foo'");
|
|
61
|
-
});
|
|
62
|
-
(0, globals_1.test)("should handle $gt", () => {
|
|
63
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
64
|
-
where: { userId: { $gt: 2 }, text: "foo" },
|
|
65
|
-
table,
|
|
66
|
-
dialect,
|
|
67
|
-
args
|
|
68
|
-
});
|
|
69
|
-
strict_1.default.deepEqual(result, "Usr.`userId` > 2 AND Usr.`text` = 'foo'");
|
|
70
|
-
});
|
|
71
|
-
(0, globals_1.test)("should handle $gte", () => {
|
|
72
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
73
|
-
where: { userId: { $gte: 2 }, text: "foo" },
|
|
74
|
-
table,
|
|
75
|
-
dialect,
|
|
76
|
-
args
|
|
77
|
-
});
|
|
78
|
-
strict_1.default.deepEqual(result, "Usr.`userId` >= 2 AND Usr.`text` = 'foo'");
|
|
79
|
-
});
|
|
80
|
-
(0, globals_1.test)("should handle $lt", () => {
|
|
81
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
82
|
-
where: { userId: { $lt: 2 }, text: "foo" },
|
|
83
|
-
table,
|
|
84
|
-
dialect,
|
|
85
|
-
args
|
|
86
|
-
});
|
|
87
|
-
strict_1.default.deepEqual(result, "Usr.`userId` < 2 AND Usr.`text` = 'foo'");
|
|
88
|
-
});
|
|
89
|
-
(0, globals_1.test)("should handle $lte", () => {
|
|
90
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
91
|
-
where: { userId: { $lte: 2 }, text: "foo" },
|
|
92
|
-
table,
|
|
93
|
-
dialect,
|
|
94
|
-
args
|
|
95
|
-
});
|
|
96
|
-
strict_1.default.deepEqual(result, "Usr.`userId` <= 2 AND Usr.`text` = 'foo'");
|
|
97
|
-
});
|
|
98
|
-
(0, globals_1.test)("should handle $like", () => {
|
|
99
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
100
|
-
where: { text: { $like: "%foo%" } },
|
|
101
|
-
table,
|
|
102
|
-
dialect,
|
|
103
|
-
args
|
|
104
|
-
});
|
|
105
|
-
strict_1.default.deepEqual(result, "Usr.`text` LIKE '%foo%'");
|
|
106
|
-
});
|
|
107
|
-
(0, globals_1.test)("should handle $nlike", () => {
|
|
108
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
109
|
-
where: { text: { $nlike: "%foo%" } },
|
|
110
|
-
table,
|
|
111
|
-
dialect,
|
|
112
|
-
args
|
|
113
|
-
});
|
|
114
|
-
strict_1.default.deepEqual(result, "Usr.`text` NOT LIKE '%foo%'");
|
|
115
|
-
});
|
|
116
|
-
(0, globals_1.test)("should handle $in", () => {
|
|
117
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
118
|
-
where: { userId: { $in: [1, 2] }, text: "foo" },
|
|
119
|
-
table,
|
|
120
|
-
dialect,
|
|
121
|
-
args
|
|
122
|
-
});
|
|
123
|
-
strict_1.default.deepEqual(result, "Usr.`userId` IN (1,2) AND Usr.`text` = 'foo'");
|
|
124
|
-
});
|
|
125
|
-
(0, globals_1.test)("should handle empty $in", () => {
|
|
126
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
127
|
-
where: { userId: { $in: [] }, text: "foo" },
|
|
128
|
-
table,
|
|
129
|
-
dialect,
|
|
130
|
-
args
|
|
131
|
-
});
|
|
132
|
-
strict_1.default.deepEqual(result, "(1=0) AND Usr.`text` = 'foo'");
|
|
133
|
-
});
|
|
134
|
-
(0, globals_1.test)("should handle $nin", () => {
|
|
135
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
136
|
-
where: { userId: { $nin: [1, 2] }, text: "foo" },
|
|
137
|
-
table,
|
|
138
|
-
dialect,
|
|
139
|
-
args
|
|
140
|
-
});
|
|
141
|
-
strict_1.default.deepEqual(result, "Usr.`userId` NOT IN (1,2) AND Usr.`text` = 'foo'");
|
|
142
|
-
});
|
|
143
|
-
(0, globals_1.test)("should handle empty $nin", () => {
|
|
144
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
145
|
-
where: { userId: { $nin: [] }, text: "foo" },
|
|
146
|
-
table,
|
|
147
|
-
dialect,
|
|
148
|
-
args
|
|
149
|
-
});
|
|
150
|
-
strict_1.default.deepEqual(result, "(1=1) AND Usr.`text` = 'foo'");
|
|
151
|
-
});
|
|
152
|
-
(0, globals_1.test)("should handle $btwn", () => {
|
|
153
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
154
|
-
where: { userId: { $btwn: [1, 20] }, text: "foo" },
|
|
155
|
-
table,
|
|
156
|
-
dialect,
|
|
157
|
-
args
|
|
158
|
-
});
|
|
159
|
-
strict_1.default.deepEqual(result, "Usr.`userId` BETWEEN 1 AND 20 AND Usr.`text` = 'foo'");
|
|
160
|
-
});
|
|
161
|
-
(0, globals_1.test)("should handle $nbtwn", () => {
|
|
162
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
163
|
-
where: { userId: { $nbtwn: [1, 20] }, text: "foo" },
|
|
164
|
-
table,
|
|
165
|
-
dialect,
|
|
166
|
-
args
|
|
167
|
-
});
|
|
168
|
-
strict_1.default.deepEqual(result, "Usr.`userId` NOT BETWEEN 1 AND 20 AND Usr.`text` = 'foo'");
|
|
169
|
-
});
|
|
170
|
-
(0, globals_1.test)("should handle nested $and and $or", () => {
|
|
171
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
172
|
-
where: {
|
|
173
|
-
$and: [
|
|
174
|
-
{ userId: { $gt: 2 } },
|
|
175
|
-
{ $or: [{ text: { $like: "foo" } }, { text: { $like: "bar" } }] },
|
|
176
|
-
{ $and: [{ lala: "lala" }, { oioi: "oioi" }] }
|
|
177
|
-
]
|
|
178
|
-
},
|
|
179
|
-
table,
|
|
180
|
-
dialect,
|
|
181
|
-
args
|
|
182
|
-
});
|
|
183
|
-
strict_1.default.deepEqual(result, "(Usr.`userId` > 2 AND (Usr.`text` LIKE 'foo' OR Usr.`text` LIKE 'bar') AND (Usr.`lala` = 'lala' AND Usr.`oioi` = 'oioi'))");
|
|
184
|
-
});
|
|
185
|
-
(0, globals_1.test)("should throw on invalid operator", () => {
|
|
186
|
-
strict_1.default.throws(() => (0, stringifyWhere_1.stringifyWhere)({
|
|
187
|
-
where: { foo: { $foo: 3 } },
|
|
188
|
-
table,
|
|
189
|
-
dialect,
|
|
190
|
-
args
|
|
191
|
-
}), (error) => {
|
|
192
|
-
(0, strict_1.default)(error instanceof Error);
|
|
193
|
-
(0, strict_1.default)(error.message.startsWith("Invalid operator:"));
|
|
194
|
-
return true;
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
(0, globals_1.test)("should throw on more than 1 key for $and", () => {
|
|
198
|
-
strict_1.default.throws(() => (0, stringifyWhere_1.stringifyWhere)({
|
|
199
|
-
where: { $and: [{ foo: "bar" }, { bar: "baz" }], foo: "bar" },
|
|
200
|
-
table,
|
|
201
|
-
dialect,
|
|
202
|
-
args
|
|
203
|
-
}), (error) => {
|
|
204
|
-
(0, strict_1.default)(error instanceof Error);
|
|
205
|
-
(0, strict_1.default)(error.message.startsWith("Must have 1 key:"));
|
|
206
|
-
return true;
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
(0, globals_1.test)("ignores undefined values", () => {
|
|
210
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
211
|
-
where: { $or: [{ foo: "bar" }, { bar: null }, { baz: undefined }] },
|
|
212
|
-
table,
|
|
213
|
-
dialect,
|
|
214
|
-
args
|
|
215
|
-
});
|
|
216
|
-
strict_1.default.deepEqual(result, "(Usr.`foo` = 'bar' OR Usr.`bar` IS NULL)");
|
|
217
|
-
});
|
|
218
|
-
(0, globals_1.test)("handles empty $and", () => {
|
|
219
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
220
|
-
where: { $and: [] },
|
|
221
|
-
table,
|
|
222
|
-
dialect,
|
|
223
|
-
args
|
|
224
|
-
});
|
|
225
|
-
strict_1.default.deepEqual(result, "");
|
|
226
|
-
});
|
|
227
|
-
(0, globals_1.test)("handles empty $or", () => {
|
|
228
|
-
const result = (0, stringifyWhere_1.stringifyWhere)({
|
|
229
|
-
where: { $or: [] },
|
|
230
|
-
table,
|
|
231
|
-
dialect,
|
|
232
|
-
args
|
|
233
|
-
});
|
|
234
|
-
strict_1.default.deepEqual(result, "");
|
|
235
|
-
});
|
|
236
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const globals_1 = require("@jest/globals");
|
|
7
|
-
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
8
|
-
const _1 = require(".");
|
|
9
|
-
const addWhereValidTrue_1 = require("../test/addWhereValidTrue");
|
|
10
|
-
(0, globals_1.describe)("traverseFieldArgs", () => {
|
|
11
|
-
(0, globals_1.test)("should work", () => {
|
|
12
|
-
const fields = [
|
|
13
|
-
"id",
|
|
14
|
-
"uuid",
|
|
15
|
-
{
|
|
16
|
-
name: "business",
|
|
17
|
-
fields: ["id", "uuid", "name"]
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "sessionList",
|
|
21
|
-
fields: ["id", "archived", { name: "fooList", fields: ["id", "uuid"] }],
|
|
22
|
-
args: {
|
|
23
|
-
$where: { archived: false },
|
|
24
|
-
$orderBy: { id: "desc" }
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "usrList",
|
|
29
|
-
fields: ["firstName", "lastName", "password"],
|
|
30
|
-
args: {
|
|
31
|
-
$where: { valid: false, archived: false },
|
|
32
|
-
$orderBy: { id: "desc" }
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
(0, _1.traverseFieldArgs)(fields, addWhereValidTrue_1.addWhereValidTrue);
|
|
37
|
-
strict_1.default.deepEqual(fields, [
|
|
38
|
-
"id",
|
|
39
|
-
"uuid",
|
|
40
|
-
{
|
|
41
|
-
name: "business",
|
|
42
|
-
fields: ["id", "uuid", "name"],
|
|
43
|
-
args: { $where: { valid: true } }
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "sessionList",
|
|
47
|
-
fields: [
|
|
48
|
-
"id",
|
|
49
|
-
"archived",
|
|
50
|
-
{
|
|
51
|
-
name: "fooList",
|
|
52
|
-
fields: ["id", "uuid"],
|
|
53
|
-
args: { $where: { valid: true } }
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
args: {
|
|
57
|
-
$where: { valid: true, archived: false },
|
|
58
|
-
$orderBy: { id: "desc" }
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: "usrList",
|
|
63
|
-
fields: ["firstName", "lastName", "password"],
|
|
64
|
-
args: {
|
|
65
|
-
// Should not be overwritten
|
|
66
|
-
$where: { valid: false, archived: false },
|
|
67
|
-
$orderBy: { id: "desc" }
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
]);
|
|
71
|
-
});
|
|
72
|
-
});
|