@storecraft/database-sql-base 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -12
- package/index.js +172 -1
- package/{tsconfig.json → jsconfig.json} +1 -5
- package/migrate.js +25 -19
- package/migrations.mysql/00000_init_tables.js +6 -5
- package/migrations.postgres/00000_init_tables.js +15 -14
- package/migrations.shared/00001_seed_email_templates copy.js +262 -0
- package/migrations.shared/00001_seed_email_templates.js +5 -238
- package/migrations.sqlite/00000_init_tables.js +12 -12
- package/package.json +2 -4
- package/src/con.auth_users.js +5 -2
- package/src/con.collections.js +2 -2
- package/src/con.customers.js +2 -2
- package/src/con.discounts.js +3 -3
- package/src/con.discounts.utils.js +11 -11
- package/src/con.helpers.json.js +3 -3
- package/src/con.images.js +5 -5
- package/src/con.notifications.js +2 -2
- package/src/con.orders.js +19 -4
- package/src/con.posts.js +2 -2
- package/src/con.products.js +5 -5
- package/src/con.search.js +7 -7
- package/src/con.shared.experiment.js +723 -0
- package/src/con.shared.js +55 -21
- package/src/con.shipping.js +2 -2
- package/src/con.storefronts.js +2 -2
- package/src/con.tags.js +2 -2
- package/src/con.templates.js +22 -7
- package/src/utils.query.js +6 -6
- package/tests/runner.mssql-local.test.js +10 -6
- package/tests/runner.mysql-local.test.js +16 -63
- package/tests/runner.postgres-local.test.js +17 -62
- package/tests/runner.sqlite-local.test.js +15 -64
- package/tests/sandbox.test.js +15 -13
- package/types.public.d.ts +12 -4
- package/types.sql.tables.d.ts +4 -2
- package/driver.js +0 -190
- package/tests/query.cursor.test.js +0 -389
- package/tests/query.vql.test.js +0 -71
@@ -1,389 +0,0 @@
|
|
1
|
-
// import { test } from 'uvu';
|
2
|
-
// import * as assert from 'uvu/assert';
|
3
|
-
// import { query_cursor_to_mongo } from '../src/utils.query.js'
|
4
|
-
|
5
|
-
// test('(a1, a2, a3)', async () => {
|
6
|
-
// const t_1 = {
|
7
|
-
// "$or": [
|
8
|
-
// {
|
9
|
-
// "$and": [
|
10
|
-
// {
|
11
|
-
// "a1": {
|
12
|
-
// "$gt": "b1"
|
13
|
-
// }
|
14
|
-
// }
|
15
|
-
// ]
|
16
|
-
// },
|
17
|
-
// {
|
18
|
-
// "$and": [
|
19
|
-
// {
|
20
|
-
// "a1": "b1"
|
21
|
-
// },
|
22
|
-
// {
|
23
|
-
// "a2": {
|
24
|
-
// "$gt": "b2"
|
25
|
-
// }
|
26
|
-
// }
|
27
|
-
// ]
|
28
|
-
// },
|
29
|
-
// {
|
30
|
-
// "$and": [
|
31
|
-
// {
|
32
|
-
// "a1": "b1"
|
33
|
-
// },
|
34
|
-
// {
|
35
|
-
// "a2": "b2"
|
36
|
-
// },
|
37
|
-
// {
|
38
|
-
// "a3": {
|
39
|
-
// "$gte": "b3"
|
40
|
-
// }
|
41
|
-
// }
|
42
|
-
// ]
|
43
|
-
// }
|
44
|
-
// ]
|
45
|
-
// };
|
46
|
-
|
47
|
-
// const t_2 = {
|
48
|
-
// "$or": [
|
49
|
-
// {
|
50
|
-
// "$and": [
|
51
|
-
// {
|
52
|
-
// "a1": {
|
53
|
-
// "$gt": "b1"
|
54
|
-
// }
|
55
|
-
// }
|
56
|
-
// ]
|
57
|
-
// },
|
58
|
-
// {
|
59
|
-
// "$and": [
|
60
|
-
// {
|
61
|
-
// "a1": "b1"
|
62
|
-
// },
|
63
|
-
// {
|
64
|
-
// "a2": {
|
65
|
-
// "$gt": "b2"
|
66
|
-
// }
|
67
|
-
// }
|
68
|
-
// ]
|
69
|
-
// },
|
70
|
-
// {
|
71
|
-
// "$and": [
|
72
|
-
// {
|
73
|
-
// "a1": "b1"
|
74
|
-
// },
|
75
|
-
// {
|
76
|
-
// "a2": "b2"
|
77
|
-
// },
|
78
|
-
// {
|
79
|
-
// "a3": {
|
80
|
-
// "$gt": "b3"
|
81
|
-
// }
|
82
|
-
// }
|
83
|
-
// ]
|
84
|
-
// }
|
85
|
-
// ]
|
86
|
-
// };
|
87
|
-
|
88
|
-
// const t_3 = {
|
89
|
-
// "$or": [
|
90
|
-
// {
|
91
|
-
// "$and": [
|
92
|
-
// {
|
93
|
-
// "a1": {
|
94
|
-
// "$lt": "b1"
|
95
|
-
// }
|
96
|
-
// }
|
97
|
-
// ]
|
98
|
-
// },
|
99
|
-
// {
|
100
|
-
// "$and": [
|
101
|
-
// {
|
102
|
-
// "a1": "b1"
|
103
|
-
// },
|
104
|
-
// {
|
105
|
-
// "a2": {
|
106
|
-
// "$lt": "b2"
|
107
|
-
// }
|
108
|
-
// }
|
109
|
-
// ]
|
110
|
-
// },
|
111
|
-
// {
|
112
|
-
// "$and": [
|
113
|
-
// {
|
114
|
-
// "a1": "b1"
|
115
|
-
// },
|
116
|
-
// {
|
117
|
-
// "a2": "b2"
|
118
|
-
// },
|
119
|
-
// {
|
120
|
-
// "a3": {
|
121
|
-
// "$lte": "b3"
|
122
|
-
// }
|
123
|
-
// }
|
124
|
-
// ]
|
125
|
-
// }
|
126
|
-
// ]
|
127
|
-
// };
|
128
|
-
|
129
|
-
// const t_4 = {
|
130
|
-
// "$or": [
|
131
|
-
// {
|
132
|
-
// "$and": [
|
133
|
-
// {
|
134
|
-
// "a1": {
|
135
|
-
// "$lt": "b1"
|
136
|
-
// }
|
137
|
-
// }
|
138
|
-
// ]
|
139
|
-
// },
|
140
|
-
// {
|
141
|
-
// "$and": [
|
142
|
-
// {
|
143
|
-
// "a1": "b1"
|
144
|
-
// },
|
145
|
-
// {
|
146
|
-
// "a2": {
|
147
|
-
// "$lt": "b2"
|
148
|
-
// }
|
149
|
-
// }
|
150
|
-
// ]
|
151
|
-
// },
|
152
|
-
// {
|
153
|
-
// "$and": [
|
154
|
-
// {
|
155
|
-
// "a1": "b1"
|
156
|
-
// },
|
157
|
-
// {
|
158
|
-
// "a2": "b2"
|
159
|
-
// },
|
160
|
-
// {
|
161
|
-
// "a3": {
|
162
|
-
// "$lt": "b3"
|
163
|
-
// }
|
164
|
-
// }
|
165
|
-
// ]
|
166
|
-
// }
|
167
|
-
// ]
|
168
|
-
// };
|
169
|
-
|
170
|
-
// /** @type {import('@storecraft/core').Cursor[]} */
|
171
|
-
// const cursor = [
|
172
|
-
// ['a1', 'b1'],
|
173
|
-
// ['a2', 'b2'],
|
174
|
-
// ['a3', 'b3'],
|
175
|
-
// ];
|
176
|
-
|
177
|
-
// const rel_1 = query_cursor_to_mongo(cursor, '>=');
|
178
|
-
// const rel_2 = query_cursor_to_mongo(cursor, '>');
|
179
|
-
// const rel_3 = query_cursor_to_mongo(cursor, '<=');
|
180
|
-
// const rel_4 = query_cursor_to_mongo(cursor, '<');
|
181
|
-
|
182
|
-
// assert.equal(rel_1, t_1);
|
183
|
-
// assert.equal(rel_2, t_2);
|
184
|
-
// assert.equal(rel_3, t_3);
|
185
|
-
// assert.equal(rel_4, t_4);
|
186
|
-
|
187
|
-
// });
|
188
|
-
|
189
|
-
|
190
|
-
// test('(a1, a2)', async () => {
|
191
|
-
// const t_1 = {
|
192
|
-
// "$or": [
|
193
|
-
// {
|
194
|
-
// "$and": [
|
195
|
-
// {
|
196
|
-
// "a1": {
|
197
|
-
// "$gt": "b1"
|
198
|
-
// }
|
199
|
-
// }
|
200
|
-
// ]
|
201
|
-
// },
|
202
|
-
// {
|
203
|
-
// "$and": [
|
204
|
-
// {
|
205
|
-
// "a1": "b1"
|
206
|
-
// },
|
207
|
-
// {
|
208
|
-
// "a2": {
|
209
|
-
// "$gte": "b2"
|
210
|
-
// }
|
211
|
-
// }
|
212
|
-
// ]
|
213
|
-
// },
|
214
|
-
// ]
|
215
|
-
// };
|
216
|
-
|
217
|
-
// const t_2 = {
|
218
|
-
// "$or": [
|
219
|
-
// {
|
220
|
-
// "$and": [
|
221
|
-
// {
|
222
|
-
// "a1": {
|
223
|
-
// "$gt": "b1"
|
224
|
-
// }
|
225
|
-
// }
|
226
|
-
// ]
|
227
|
-
// },
|
228
|
-
// {
|
229
|
-
// "$and": [
|
230
|
-
// {
|
231
|
-
// "a1": "b1"
|
232
|
-
// },
|
233
|
-
// {
|
234
|
-
// "a2": {
|
235
|
-
// "$gt": "b2"
|
236
|
-
// }
|
237
|
-
// }
|
238
|
-
// ]
|
239
|
-
// },
|
240
|
-
// ]
|
241
|
-
// };
|
242
|
-
|
243
|
-
// const t_3 = {
|
244
|
-
// "$or": [
|
245
|
-
// {
|
246
|
-
// "$and": [
|
247
|
-
// {
|
248
|
-
// "a1": {
|
249
|
-
// "$lt": "b1"
|
250
|
-
// }
|
251
|
-
// }
|
252
|
-
// ]
|
253
|
-
// },
|
254
|
-
// {
|
255
|
-
// "$and": [
|
256
|
-
// {
|
257
|
-
// "a1": "b1"
|
258
|
-
// },
|
259
|
-
// {
|
260
|
-
// "a2": {
|
261
|
-
// "$lte": "b2"
|
262
|
-
// }
|
263
|
-
// }
|
264
|
-
// ]
|
265
|
-
// },
|
266
|
-
// ]
|
267
|
-
// };
|
268
|
-
|
269
|
-
// const t_4 = {
|
270
|
-
// "$or": [
|
271
|
-
// {
|
272
|
-
// "$and": [
|
273
|
-
// {
|
274
|
-
// "a1": {
|
275
|
-
// "$lt": "b1"
|
276
|
-
// }
|
277
|
-
// }
|
278
|
-
// ]
|
279
|
-
// },
|
280
|
-
// {
|
281
|
-
// "$and": [
|
282
|
-
// {
|
283
|
-
// "a1": "b1"
|
284
|
-
// },
|
285
|
-
// {
|
286
|
-
// "a2": {
|
287
|
-
// "$lt": "b2"
|
288
|
-
// }
|
289
|
-
// }
|
290
|
-
// ]
|
291
|
-
// },
|
292
|
-
// ]
|
293
|
-
// };
|
294
|
-
|
295
|
-
// /** @type {import('@storecraft/core').Cursor[]} */
|
296
|
-
// const cursor = [
|
297
|
-
// ['a1', 'b1'],
|
298
|
-
// ['a2', 'b2'],
|
299
|
-
// ];
|
300
|
-
|
301
|
-
// const rel_1 = query_cursor_to_mongo(cursor, '>=');
|
302
|
-
// const rel_2 = query_cursor_to_mongo(cursor, '>');
|
303
|
-
// const rel_3 = query_cursor_to_mongo(cursor, '<=');
|
304
|
-
// const rel_4 = query_cursor_to_mongo(cursor, '<');
|
305
|
-
|
306
|
-
// assert.equal(rel_1, t_1);
|
307
|
-
// assert.equal(rel_2, t_2);
|
308
|
-
// assert.equal(rel_3, t_3);
|
309
|
-
// assert.equal(rel_4, t_4);
|
310
|
-
// });
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
// test('(a1)', async () => {
|
315
|
-
// const t_1 = {
|
316
|
-
// "$or": [
|
317
|
-
// {
|
318
|
-
// "$and": [
|
319
|
-
// {
|
320
|
-
// "a1": {
|
321
|
-
// "$gte": "b1"
|
322
|
-
// }
|
323
|
-
// }
|
324
|
-
// ]
|
325
|
-
// },
|
326
|
-
// ]
|
327
|
-
// };
|
328
|
-
|
329
|
-
// const t_2 = {
|
330
|
-
// "$or": [
|
331
|
-
// {
|
332
|
-
// "$and": [
|
333
|
-
// {
|
334
|
-
// "a1": {
|
335
|
-
// "$gt": "b1"
|
336
|
-
// }
|
337
|
-
// }
|
338
|
-
// ]
|
339
|
-
// },
|
340
|
-
// ]
|
341
|
-
// };
|
342
|
-
|
343
|
-
// const t_3 = {
|
344
|
-
// "$or": [
|
345
|
-
// {
|
346
|
-
// "$and": [
|
347
|
-
// {
|
348
|
-
// "a1": {
|
349
|
-
// "$lte": "b1"
|
350
|
-
// }
|
351
|
-
// }
|
352
|
-
// ]
|
353
|
-
// },
|
354
|
-
// ]
|
355
|
-
// };
|
356
|
-
|
357
|
-
// const t_4 = {
|
358
|
-
// "$or": [
|
359
|
-
// {
|
360
|
-
// "$and": [
|
361
|
-
// {
|
362
|
-
// "a1": {
|
363
|
-
// "$lt": "b1"
|
364
|
-
// }
|
365
|
-
// }
|
366
|
-
// ]
|
367
|
-
// },
|
368
|
-
// ]
|
369
|
-
// };
|
370
|
-
|
371
|
-
// /** @type {import('@storecraft/core').Cursor[]} */
|
372
|
-
// const cursor = [
|
373
|
-
// ['a1', 'b1'],
|
374
|
-
// ];
|
375
|
-
|
376
|
-
// const rel_1 = query_cursor_to_mongo(cursor, '>=');
|
377
|
-
// const rel_2 = query_cursor_to_mongo(cursor, '>');
|
378
|
-
// const rel_3 = query_cursor_to_mongo(cursor, '<=');
|
379
|
-
// const rel_4 = query_cursor_to_mongo(cursor, '<');
|
380
|
-
|
381
|
-
// assert.equal(rel_1, t_1);
|
382
|
-
// assert.equal(rel_2, t_2);
|
383
|
-
// assert.equal(rel_3, t_3);
|
384
|
-
// assert.equal(rel_4, t_4);
|
385
|
-
// });
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
// test.run();
|
package/tests/query.vql.test.js
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
// import { test } from 'uvu';
|
2
|
-
// import * as assert from 'uvu/assert';
|
3
|
-
// import { query_vql_to_mongo } from '../src/utils.query.js'
|
4
|
-
|
5
|
-
// test('VQL', async () => {
|
6
|
-
// const vql_ast = {
|
7
|
-
// op: '&',
|
8
|
-
// args: [
|
9
|
-
// {
|
10
|
-
// op: 'LEAF',
|
11
|
-
// value: 'name:tomer'
|
12
|
-
// },
|
13
|
-
// {
|
14
|
-
// op: '&',
|
15
|
-
// args: [
|
16
|
-
// {
|
17
|
-
// op: 'LEAF',
|
18
|
-
// value: 'tag:genre_a'
|
19
|
-
// },
|
20
|
-
// {
|
21
|
-
// op: '!',
|
22
|
-
// args: [
|
23
|
-
// {
|
24
|
-
// op: 'LEAF',
|
25
|
-
// value: 'tag:genre_b'
|
26
|
-
// }
|
27
|
-
// ]
|
28
|
-
// }
|
29
|
-
// ],
|
30
|
-
// group: true
|
31
|
-
// }
|
32
|
-
// ],
|
33
|
-
// group: true
|
34
|
-
// };
|
35
|
-
|
36
|
-
// const mongo = {
|
37
|
-
// "$and": [
|
38
|
-
// {
|
39
|
-
// "search": {
|
40
|
-
// "$regex": "^name:tomer$"
|
41
|
-
// }
|
42
|
-
// },
|
43
|
-
// {
|
44
|
-
// "$and": [
|
45
|
-
// {
|
46
|
-
// "search": {
|
47
|
-
// "$regex": "^tag:genre_a$"
|
48
|
-
// }
|
49
|
-
// },
|
50
|
-
// {
|
51
|
-
// "$nor": [
|
52
|
-
// {
|
53
|
-
// "search": {
|
54
|
-
// "$regex": "^tag:genre_b$"
|
55
|
-
// }
|
56
|
-
// }
|
57
|
-
// ]
|
58
|
-
// }
|
59
|
-
// ]
|
60
|
-
// }
|
61
|
-
// ]
|
62
|
-
// };
|
63
|
-
|
64
|
-
// const m1 = query_vql_to_mongo(vql_ast);
|
65
|
-
|
66
|
-
// // console.log(JSON.stringify(m1, null, 2))
|
67
|
-
|
68
|
-
// assert.equal(m1, mongo);
|
69
|
-
// });
|
70
|
-
|
71
|
-
// test.run();
|