vinojs 0.1.0 → 0.1.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.
Files changed (115) hide show
  1. package/dist/client.mjs +1 -1
  2. package/dist/{compile-Lxl_tdxL.mjs → compile-glNMkyyx.mjs} +3 -47
  3. package/dist/compile-glNMkyyx.mjs.map +1 -0
  4. package/dist/{definePage-Ba4r-TFh.mjs → definePage--9Pz7rHs.mjs} +29 -7
  5. package/dist/definePage--9Pz7rHs.mjs.map +1 -0
  6. package/dist/defineServerFn-H-bz7xBX.mjs +47 -0
  7. package/dist/defineServerFn-H-bz7xBX.mjs.map +1 -0
  8. package/dist/factory-CVT0-OZw.d.mts +187 -0
  9. package/dist/factory-CVT0-OZw.d.mts.map +1 -0
  10. package/dist/factory.d.mts +2 -0
  11. package/dist/factory.mjs +153 -0
  12. package/dist/factory.mjs.map +1 -0
  13. package/dist/vino.d.mts +4 -103
  14. package/dist/vino.d.mts.map +1 -1
  15. package/dist/vino.mjs +8 -3
  16. package/dist/vino.mjs.map +1 -1
  17. package/dist/vite.mjs +3 -2
  18. package/dist/vite.mjs.map +1 -1
  19. package/package.json +5 -1
  20. package/dist/compile-Lxl_tdxL.mjs.map +0 -1
  21. package/dist/definePage-Ba4r-TFh.mjs.map +0 -1
  22. package/examples/basic/dist/client/.assetsignore +0 -2
  23. package/examples/basic/dist/client/about.html +0 -1
  24. package/examples/basic/dist/client/admin.html +0 -1
  25. package/examples/basic/dist/client/assets/Counter-BvqMZKON.js +0 -1
  26. package/examples/basic/dist/client/assets/_slug_-CYpOSbrn.js +0 -1
  27. package/examples/basic/dist/client/assets/about-BZXRzUyv.js +0 -1
  28. package/examples/basic/dist/client/assets/admin-DRE7uh2s.js +0 -1
  29. package/examples/basic/dist/client/assets/client-B6nFkut5.js +0 -1
  30. package/examples/basic/dist/client/assets/client-pages-Bc6cNZAm.js +0 -2
  31. package/examples/basic/dist/client/assets/components-DX9r6vHn.js +0 -1
  32. package/examples/basic/dist/client/assets/components-DsWJ6F73.js +0 -2
  33. package/examples/basic/dist/client/assets/counter-DBpvln_F.js +0 -1
  34. package/examples/basic/dist/client/assets/dom-B5sHIJ1E.js +0 -1
  35. package/examples/basic/dist/client/assets/honoto-9UtdLp4J.js +0 -33
  36. package/examples/basic/dist/client/assets/honoto-client-DEh86_WZ.css +0 -1
  37. package/examples/basic/dist/client/assets/honoto-client.js +0 -2
  38. package/examples/basic/dist/client/assets/hooks-Cz6AT21d.js +0 -1
  39. package/examples/basic/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
  40. package/examples/basic/dist/client/counter.html +0 -1
  41. package/examples/basic/dist/client/index.html +0 -1
  42. package/examples/basic/dist/client/jobs.html +0 -1
  43. package/examples/basic/dist/ssr/.vite/manifest.json +0 -140
  44. package/examples/basic/dist/ssr/assets/_slug_-CY3-kffX.js +0 -46
  45. package/examples/basic/dist/ssr/assets/about-CTDjNhkO.js +0 -15
  46. package/examples/basic/dist/ssr/assets/admin-DvS-UGJx.js +0 -26
  47. package/examples/basic/dist/ssr/assets/constants-UoriGYcX-CUecBFMT.js +0 -6
  48. package/examples/basic/dist/ssr/assets/counter-DfIbc9Sp.js +0 -30
  49. package/examples/basic/dist/ssr/assets/honoto-CA313cVy.js +0 -2129
  50. package/examples/basic/dist/ssr/assets/jobs-D9hh-UO9.js +0 -42
  51. package/examples/basic/dist/ssr/assets/jsx-CgYLQazd.js +0 -1080
  52. package/examples/basic/dist/ssr/assets/jsx-dev-runtime-BlUda7H8.js +0 -742
  53. package/examples/basic/dist/ssr/assets/jsx-renderer-CzZcZPnS.js +0 -65
  54. package/examples/basic/dist/ssr/assets/layout-DYvLwr2u.js +0 -53
  55. package/examples/basic/dist/ssr/assets/pages-DB6jeyrt.js +0 -53
  56. package/examples/basic/dist/ssr/assets/rolldown-runtime-D7D4PA-g.js +0 -13
  57. package/examples/basic/dist/ssr/assets/ssr-hooks-CBQr0cdH.js +0 -7
  58. package/examples/basic/dist/ssr/index.js +0 -22
  59. package/examples/basic/dist/ssr/wrangler.json +0 -1
  60. package/examples/full/dist/client/.assetsignore +0 -2
  61. package/examples/full/dist/client/assets/BookmarkButton-py0xGxgl.js +0 -1
  62. package/examples/full/dist/client/assets/_slug_-DZUFsE9O.js +0 -1
  63. package/examples/full/dist/client/assets/auth-client-D2Wtuobe.js +0 -1
  64. package/examples/full/dist/client/assets/bun-sqlite-dialect-C7ftEUSI-CsHdUKBY.js +0 -1
  65. package/examples/full/dist/client/assets/client-B6nFkut5.js +0 -1
  66. package/examples/full/dist/client/assets/client-pages-fshKs747.js +0 -2
  67. package/examples/full/dist/client/assets/components-DX9r6vHn.js +0 -1
  68. package/examples/full/dist/client/assets/components-S_-rWrKi.js +0 -2
  69. package/examples/full/dist/client/assets/d1-sqlite-dialect-BZmaVTp8-FPCaMZqX.js +0 -1
  70. package/examples/full/dist/client/assets/default-query-compiler-CUdqIu1h.js +0 -1
  71. package/examples/full/dist/client/assets/dist-BoGTNvkC.js +0 -1
  72. package/examples/full/dist/client/assets/dom-DCd3wYW7.js +0 -1
  73. package/examples/full/dist/client/assets/factory-Bgf4EtLx.js +0 -8
  74. package/examples/full/dist/client/assets/honoto-client-BSvNAnxN.css +0 -1
  75. package/examples/full/dist/client/assets/honoto-client.js +0 -2
  76. package/examples/full/dist/client/assets/hooks-Cz6AT21d.js +0 -1
  77. package/examples/full/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
  78. package/examples/full/dist/client/assets/kysely-adapter-BHhasAnc.js +0 -1
  79. package/examples/full/dist/client/assets/kysely-migration-tables-DFfmKhq--U5ujlMwE.js +0 -1
  80. package/examples/full/dist/client/assets/node-sqlite-dialect-DJDXH5Ot.js +0 -1
  81. package/examples/full/dist/client/assets/pages-CUQx6Eus.js +0 -1
  82. package/examples/full/dist/client/assets/saved-jIi74ncJ.js +0 -1
  83. package/examples/full/dist/client/assets/session-B-accyM3.js +0 -611
  84. package/examples/full/dist/client/assets/sign-in-BelI3gSs.js +0 -1
  85. package/examples/full/dist/client/assets/sign-up-pR94lfdu.js +0 -1
  86. package/examples/full/dist/client/index.html +0 -1
  87. package/examples/full/dist/client/saved.html +0 -1
  88. package/examples/full/dist/client/sign-in.html +0 -1
  89. package/examples/full/dist/client/sign-up.html +0 -1
  90. package/examples/full/dist/ssr/.dev.vars +0 -1
  91. package/examples/full/dist/ssr/.vite/manifest.json +0 -219
  92. package/examples/full/dist/ssr/assets/BookmarkButton-KS7z5_vi.js +0 -298
  93. package/examples/full/dist/ssr/assets/_slug_-rRStRaAN.js +0 -89
  94. package/examples/full/dist/ssr/assets/auth-DSFZ4iak.js +0 -31434
  95. package/examples/full/dist/ssr/assets/auth-client-BFSBVoML.js +0 -894
  96. package/examples/full/dist/ssr/assets/bun-sqlite-dialect-C7ftEUSI-BeXpIqKl.js +0 -162
  97. package/examples/full/dist/ssr/assets/compiled-query-DmoyCh28.js +0 -8410
  98. package/examples/full/dist/ssr/assets/d1-sqlite-dialect-BZmaVTp8-CjJdvL94.js +0 -114
  99. package/examples/full/dist/ssr/assets/default-query-compiler-D7xOzCCJ.js +0 -1727
  100. package/examples/full/dist/ssr/assets/dist-LmmDoNdk.js +0 -6832
  101. package/examples/full/dist/ssr/assets/dist-kFDN1l4Z.js +0 -342
  102. package/examples/full/dist/ssr/assets/factory-AD6s9SIW.js +0 -2079
  103. package/examples/full/dist/ssr/assets/jsx-renderer-mMLf5XLN.js +0 -1926
  104. package/examples/full/dist/ssr/assets/kysely-adapter-BCLenpM8.js +0 -2
  105. package/examples/full/dist/ssr/assets/kysely-migration-tables-DFfmKhq--BtVr6hRe.js +0 -17
  106. package/examples/full/dist/ssr/assets/layout-mVA7qP4j.js +0 -44
  107. package/examples/full/dist/ssr/assets/node-sqlite-dialect-D-wtYAD7.js +0 -162
  108. package/examples/full/dist/ssr/assets/pages-Do5kR_Ia.js +0 -147
  109. package/examples/full/dist/ssr/assets/saved-Dr4pP6B5.js +0 -111
  110. package/examples/full/dist/ssr/assets/session-BvIpX7tr.js +0 -13
  111. package/examples/full/dist/ssr/assets/sign-in-22pzTnJE.js +0 -115
  112. package/examples/full/dist/ssr/assets/sign-up-CN4j8Qg1.js +0 -117
  113. package/examples/full/dist/ssr/assets/sqlite-adapter-DVlms5wO.js +0 -79
  114. package/examples/full/dist/ssr/index.js +0 -97
  115. package/examples/full/dist/ssr/wrangler.json +0 -1
@@ -1,1727 +0,0 @@
1
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/util/object-utils.js
2
- function isUndefined(obj) {
3
- return typeof obj === "undefined" || obj === void 0;
4
- }
5
- function isString(obj) {
6
- return typeof obj === "string";
7
- }
8
- function isNumber(obj) {
9
- return typeof obj === "number";
10
- }
11
- function isBoolean(obj) {
12
- return typeof obj === "boolean";
13
- }
14
- function isNull(obj) {
15
- return obj === null;
16
- }
17
- function isDate(obj) {
18
- return obj instanceof Date;
19
- }
20
- function isBigInt(obj) {
21
- return typeof obj === "bigint";
22
- }
23
- function isBuffer(obj) {
24
- return typeof Buffer !== "undefined" && Buffer.isBuffer(obj);
25
- }
26
- function isFunction(obj) {
27
- return typeof obj === "function";
28
- }
29
- function isObject(obj) {
30
- return typeof obj === "object" && obj !== null;
31
- }
32
- function freeze(obj) {
33
- return Object.freeze(obj);
34
- }
35
- function asArray(arg) {
36
- if (isReadonlyArray(arg)) return arg;
37
- else return [arg];
38
- }
39
- function isReadonlyArray(arg) {
40
- return Array.isArray(arg);
41
- }
42
- function noop(obj) {
43
- return obj;
44
- }
45
- function getMessage(error) {
46
- return error instanceof Error ? error.message : String(error);
47
- }
48
- //#endregion
49
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/identifier-node.js
50
- /**
51
- * @internal
52
- */
53
- var IdentifierNode = freeze({
54
- is(node) {
55
- return node.kind === "IdentifierNode";
56
- },
57
- create(name) {
58
- return freeze({
59
- kind: "IdentifierNode",
60
- name
61
- });
62
- }
63
- });
64
- //#endregion
65
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/create-table-node.js
66
- var ON_COMMIT_ACTIONS = [
67
- "preserve rows",
68
- "delete rows",
69
- "drop"
70
- ];
71
- /**
72
- * @internal
73
- */
74
- var CreateTableNode = freeze({
75
- is(node) {
76
- return node.kind === "CreateTableNode";
77
- },
78
- create(table) {
79
- return freeze({
80
- kind: "CreateTableNode",
81
- table,
82
- columns: freeze([])
83
- });
84
- },
85
- cloneWithColumn(node, column) {
86
- return freeze({
87
- ...node,
88
- columns: freeze([...node.columns, column])
89
- });
90
- },
91
- cloneWithConstraint(node, constraint) {
92
- return freeze({
93
- ...node,
94
- constraints: node.constraints ? freeze([...node.constraints, constraint]) : freeze([constraint])
95
- });
96
- },
97
- cloneWithIndex(node, index) {
98
- return freeze({
99
- ...node,
100
- indexes: node.indexes ? freeze([...node.indexes, index]) : freeze([index])
101
- });
102
- },
103
- cloneWithFrontModifier(node, modifier) {
104
- return freeze({
105
- ...node,
106
- frontModifiers: node.frontModifiers ? freeze([...node.frontModifiers, modifier]) : freeze([modifier])
107
- });
108
- },
109
- cloneWithEndModifier(node, modifier) {
110
- return freeze({
111
- ...node,
112
- endModifiers: node.endModifiers ? freeze([...node.endModifiers, modifier]) : freeze([modifier])
113
- });
114
- },
115
- cloneWith(node, params) {
116
- return freeze({
117
- ...node,
118
- ...params
119
- });
120
- }
121
- });
122
- //#endregion
123
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/schemable-identifier-node.js
124
- /**
125
- * @internal
126
- */
127
- var SchemableIdentifierNode = freeze({
128
- is(node) {
129
- return node.kind === "SchemableIdentifierNode";
130
- },
131
- create(identifier) {
132
- return freeze({
133
- kind: "SchemableIdentifierNode",
134
- identifier: IdentifierNode.create(identifier)
135
- });
136
- },
137
- createWithSchema(schema, identifier) {
138
- return freeze({
139
- kind: "SchemableIdentifierNode",
140
- schema: IdentifierNode.create(schema),
141
- identifier: IdentifierNode.create(identifier)
142
- });
143
- }
144
- });
145
- //#endregion
146
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/operator-node.js
147
- var COMPARISON_OPERATORS_DICTIONARY = freeze({
148
- "=": true,
149
- "==": true,
150
- "!=": true,
151
- "<>": true,
152
- ">": true,
153
- ">=": true,
154
- "<": true,
155
- "<=": true,
156
- in: true,
157
- "not in": true,
158
- is: true,
159
- "is not": true,
160
- like: true,
161
- "not like": true,
162
- match: true,
163
- ilike: true,
164
- "not ilike": true,
165
- "@>": true,
166
- "<@": true,
167
- "^@": true,
168
- "&&": true,
169
- "?": true,
170
- "?&": true,
171
- "?|": true,
172
- "!<": true,
173
- "!>": true,
174
- "<=>": true,
175
- "!~": true,
176
- "~": true,
177
- "~*": true,
178
- "!~*": true,
179
- "@@": true,
180
- "@@@": true,
181
- "!!": true,
182
- "<->": true,
183
- regexp: true,
184
- "is distinct from": true,
185
- "is not distinct from": true
186
- });
187
- Object.keys(COMPARISON_OPERATORS_DICTIONARY);
188
- var ARITHMETIC_OPERATORS_DICTIONARY = freeze({
189
- "+": true,
190
- "-": true,
191
- "*": true,
192
- "/": true,
193
- "%": true,
194
- "^": true,
195
- "&": true,
196
- "|": true,
197
- "#": true,
198
- "<<": true,
199
- ">>": true
200
- });
201
- Object.keys(ARITHMETIC_OPERATORS_DICTIONARY);
202
- var JSON_OPERATORS_DICTIONARY = freeze({
203
- "->": true,
204
- "->>": true
205
- });
206
- /**
207
- * @deprecated will be removed in version 0.30.x
208
- */
209
- var JSON_OPERATORS = Object.keys(JSON_OPERATORS_DICTIONARY);
210
- var BINARY_OPERATORS_DICTIONARY = freeze({
211
- ...COMPARISON_OPERATORS_DICTIONARY,
212
- ...ARITHMETIC_OPERATORS_DICTIONARY,
213
- "||": true
214
- });
215
- /**
216
- * @deprecated will be removed in version 0.30.x
217
- */
218
- var BINARY_OPERATORS = Object.keys(BINARY_OPERATORS_DICTIONARY);
219
- var UNARY_FILTER_OPERATORS_DICTIONARY = freeze({
220
- exists: true,
221
- "not exists": true
222
- });
223
- Object.keys(UNARY_FILTER_OPERATORS_DICTIONARY);
224
- var UNARY_OPERATORS_DICTIONARY = freeze({
225
- ...UNARY_FILTER_OPERATORS_DICTIONARY,
226
- "-": true,
227
- not: true
228
- });
229
- /**
230
- * @deprecated will be removed in version 0.30.x
231
- */
232
- var UNARY_OPERATORS = Object.keys(UNARY_OPERATORS_DICTIONARY);
233
- [
234
- ...BINARY_OPERATORS,
235
- ...JSON_OPERATORS,
236
- ...UNARY_OPERATORS
237
- ];
238
- /**
239
- * @internal
240
- */
241
- var OperatorNode = freeze({
242
- is(node) {
243
- return node.kind === "OperatorNode";
244
- },
245
- create(operator) {
246
- return freeze({
247
- kind: "OperatorNode",
248
- operator
249
- });
250
- }
251
- });
252
- function isBinaryOperator(op) {
253
- return isString(op) && BINARY_OPERATORS_DICTIONARY[op];
254
- }
255
- function isJSONOperator(op) {
256
- return isString(op) && JSON_OPERATORS_DICTIONARY[op];
257
- }
258
- function isUnaryOperator(op) {
259
- return isString(op) && UNARY_OPERATORS_DICTIONARY[op];
260
- }
261
- //#endregion
262
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/raw-node.js
263
- /**
264
- * @internal
265
- */
266
- var RawNode = freeze({
267
- is(node) {
268
- return node.kind === "RawNode";
269
- },
270
- create(sqlFragments, parameters) {
271
- return freeze({
272
- kind: "RawNode",
273
- sqlFragments: freeze(sqlFragments),
274
- parameters: freeze(parameters)
275
- });
276
- },
277
- createWithSql(sql) {
278
- return RawNode.create([sql], []);
279
- },
280
- createWithChild(child) {
281
- return RawNode.create(["", ""], [child]);
282
- },
283
- createWithChildren(children) {
284
- return RawNode.create(new Array(children.length + 1).fill(""), children);
285
- }
286
- });
287
- //#endregion
288
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/parens-node.js
289
- /**
290
- * @internal
291
- */
292
- var ParensNode = freeze({
293
- is(node) {
294
- return node.kind === "ParensNode";
295
- },
296
- create(node) {
297
- return freeze({
298
- kind: "ParensNode",
299
- node
300
- });
301
- }
302
- });
303
- //#endregion
304
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/insert-query-node.js
305
- /**
306
- * @internal
307
- */
308
- var InsertQueryNode = freeze({
309
- is(node) {
310
- return node.kind === "InsertQueryNode";
311
- },
312
- create(into, withNode, replace) {
313
- return freeze({
314
- kind: "InsertQueryNode",
315
- into,
316
- ...withNode && { with: withNode },
317
- replace
318
- });
319
- },
320
- createWithoutInto() {
321
- return freeze({ kind: "InsertQueryNode" });
322
- },
323
- cloneWith(insertQuery, props) {
324
- return freeze({
325
- ...insertQuery,
326
- ...props
327
- });
328
- }
329
- });
330
- //#endregion
331
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/when-node.js
332
- /**
333
- * @internal
334
- */
335
- var WhenNode = freeze({
336
- is(node) {
337
- return node.kind === "WhenNode";
338
- },
339
- create(condition) {
340
- return freeze({
341
- kind: "WhenNode",
342
- condition
343
- });
344
- },
345
- cloneWithResult(whenNode, result) {
346
- return freeze({
347
- ...whenNode,
348
- result
349
- });
350
- }
351
- });
352
- //#endregion
353
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/set-operation-node.js
354
- /**
355
- * @internal
356
- */
357
- var SetOperationNode = freeze({
358
- is(node) {
359
- return node.kind === "SetOperationNode";
360
- },
361
- create(operator, expression, all) {
362
- return freeze({
363
- kind: "SetOperationNode",
364
- operator,
365
- expression,
366
- all
367
- });
368
- }
369
- });
370
- //#endregion
371
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/create-view-node.js
372
- /**
373
- * @internal
374
- */
375
- var CreateViewNode = freeze({
376
- is(node) {
377
- return node.kind === "CreateViewNode";
378
- },
379
- create(name) {
380
- return freeze({
381
- kind: "CreateViewNode",
382
- name: SchemableIdentifierNode.create(name)
383
- });
384
- },
385
- cloneWith(createView, params) {
386
- return freeze({
387
- ...createView,
388
- ...params
389
- });
390
- }
391
- });
392
- //#endregion
393
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/operation-node/operation-node-visitor.js
394
- var OperationNodeVisitor = class {
395
- nodeStack = [];
396
- get parentNode() {
397
- return this.nodeStack[this.nodeStack.length - 2];
398
- }
399
- #visitors = freeze({
400
- AliasNode: this.visitAlias.bind(this),
401
- ColumnNode: this.visitColumn.bind(this),
402
- IdentifierNode: this.visitIdentifier.bind(this),
403
- SchemableIdentifierNode: this.visitSchemableIdentifier.bind(this),
404
- RawNode: this.visitRaw.bind(this),
405
- ReferenceNode: this.visitReference.bind(this),
406
- SelectQueryNode: this.visitSelectQuery.bind(this),
407
- SelectionNode: this.visitSelection.bind(this),
408
- TableNode: this.visitTable.bind(this),
409
- FromNode: this.visitFrom.bind(this),
410
- SelectAllNode: this.visitSelectAll.bind(this),
411
- AndNode: this.visitAnd.bind(this),
412
- OrNode: this.visitOr.bind(this),
413
- ValueNode: this.visitValue.bind(this),
414
- ValueListNode: this.visitValueList.bind(this),
415
- PrimitiveValueListNode: this.visitPrimitiveValueList.bind(this),
416
- ParensNode: this.visitParens.bind(this),
417
- JoinNode: this.visitJoin.bind(this),
418
- OperatorNode: this.visitOperator.bind(this),
419
- WhereNode: this.visitWhere.bind(this),
420
- InsertQueryNode: this.visitInsertQuery.bind(this),
421
- DeleteQueryNode: this.visitDeleteQuery.bind(this),
422
- ReturningNode: this.visitReturning.bind(this),
423
- CreateTableNode: this.visitCreateTable.bind(this),
424
- AddColumnNode: this.visitAddColumn.bind(this),
425
- ColumnDefinitionNode: this.visitColumnDefinition.bind(this),
426
- DropTableNode: this.visitDropTable.bind(this),
427
- DataTypeNode: this.visitDataType.bind(this),
428
- OrderByNode: this.visitOrderBy.bind(this),
429
- OrderByItemNode: this.visitOrderByItem.bind(this),
430
- GroupByNode: this.visitGroupBy.bind(this),
431
- GroupByItemNode: this.visitGroupByItem.bind(this),
432
- UpdateQueryNode: this.visitUpdateQuery.bind(this),
433
- ColumnUpdateNode: this.visitColumnUpdate.bind(this),
434
- LimitNode: this.visitLimit.bind(this),
435
- OffsetNode: this.visitOffset.bind(this),
436
- OnConflictNode: this.visitOnConflict.bind(this),
437
- OnDuplicateKeyNode: this.visitOnDuplicateKey.bind(this),
438
- CreateIndexNode: this.visitCreateIndex.bind(this),
439
- DropIndexNode: this.visitDropIndex.bind(this),
440
- ListNode: this.visitList.bind(this),
441
- PrimaryKeyConstraintNode: this.visitPrimaryKeyConstraint.bind(this),
442
- UniqueConstraintNode: this.visitUniqueConstraint.bind(this),
443
- ReferencesNode: this.visitReferences.bind(this),
444
- CheckConstraintNode: this.visitCheckConstraint.bind(this),
445
- WithNode: this.visitWith.bind(this),
446
- CommonTableExpressionNode: this.visitCommonTableExpression.bind(this),
447
- CommonTableExpressionNameNode: this.visitCommonTableExpressionName.bind(this),
448
- HavingNode: this.visitHaving.bind(this),
449
- CreateSchemaNode: this.visitCreateSchema.bind(this),
450
- DropSchemaNode: this.visitDropSchema.bind(this),
451
- AlterTableNode: this.visitAlterTable.bind(this),
452
- DropColumnNode: this.visitDropColumn.bind(this),
453
- RenameColumnNode: this.visitRenameColumn.bind(this),
454
- AlterColumnNode: this.visitAlterColumn.bind(this),
455
- ModifyColumnNode: this.visitModifyColumn.bind(this),
456
- AddConstraintNode: this.visitAddConstraint.bind(this),
457
- DropConstraintNode: this.visitDropConstraint.bind(this),
458
- RenameConstraintNode: this.visitRenameConstraint.bind(this),
459
- ForeignKeyConstraintNode: this.visitForeignKeyConstraint.bind(this),
460
- CreateViewNode: this.visitCreateView.bind(this),
461
- RefreshMaterializedViewNode: this.visitRefreshMaterializedView.bind(this),
462
- DropViewNode: this.visitDropView.bind(this),
463
- GeneratedNode: this.visitGenerated.bind(this),
464
- DefaultValueNode: this.visitDefaultValue.bind(this),
465
- OnNode: this.visitOn.bind(this),
466
- ValuesNode: this.visitValues.bind(this),
467
- SelectModifierNode: this.visitSelectModifier.bind(this),
468
- CreateTypeNode: this.visitCreateType.bind(this),
469
- DropTypeNode: this.visitDropType.bind(this),
470
- ExplainNode: this.visitExplain.bind(this),
471
- DefaultInsertValueNode: this.visitDefaultInsertValue.bind(this),
472
- AggregateFunctionNode: this.visitAggregateFunction.bind(this),
473
- OverNode: this.visitOver.bind(this),
474
- PartitionByNode: this.visitPartitionBy.bind(this),
475
- PartitionByItemNode: this.visitPartitionByItem.bind(this),
476
- SetOperationNode: this.visitSetOperation.bind(this),
477
- BinaryOperationNode: this.visitBinaryOperation.bind(this),
478
- UnaryOperationNode: this.visitUnaryOperation.bind(this),
479
- UsingNode: this.visitUsing.bind(this),
480
- FunctionNode: this.visitFunction.bind(this),
481
- CaseNode: this.visitCase.bind(this),
482
- WhenNode: this.visitWhen.bind(this),
483
- JSONReferenceNode: this.visitJSONReference.bind(this),
484
- JSONPathNode: this.visitJSONPath.bind(this),
485
- JSONPathLegNode: this.visitJSONPathLeg.bind(this),
486
- JSONOperatorChainNode: this.visitJSONOperatorChain.bind(this),
487
- TupleNode: this.visitTuple.bind(this),
488
- MergeQueryNode: this.visitMergeQuery.bind(this),
489
- MatchedNode: this.visitMatched.bind(this),
490
- AddIndexNode: this.visitAddIndex.bind(this),
491
- CastNode: this.visitCast.bind(this),
492
- FetchNode: this.visitFetch.bind(this),
493
- TopNode: this.visitTop.bind(this),
494
- OutputNode: this.visitOutput.bind(this),
495
- OrActionNode: this.visitOrAction.bind(this),
496
- CollateNode: this.visitCollate.bind(this),
497
- AlterTypeNode: this.visitAlterType.bind(this),
498
- AddValueNode: this.visitAddValue.bind(this),
499
- RenameValueNode: this.visitRenameValue.bind(this)
500
- });
501
- visitNode = (node) => {
502
- this.nodeStack.push(node);
503
- this.#visitors[node.kind](node);
504
- this.nodeStack.pop();
505
- };
506
- };
507
- //#endregion
508
- //#region ../../node_modules/.pnpm/kysely@0.29.5/node_modules/kysely/dist/query-compiler/default-query-compiler.js
509
- var LIT_WRAP_REGEX = /'/g;
510
- var JSON_PATH_MEMBER_WRAP_REGEX = /['"]/g;
511
- var DefaultQueryCompiler = class extends OperationNodeVisitor {
512
- #sql = "";
513
- #parameters = [];
514
- get numParameters() {
515
- return this.#parameters.length;
516
- }
517
- compileQuery(node, queryId) {
518
- this.#sql = "";
519
- this.#parameters = [];
520
- this.nodeStack.splice(0, this.nodeStack.length);
521
- this.visitNode(node);
522
- return freeze({
523
- query: node,
524
- queryId,
525
- sql: this.getSql(),
526
- parameters: [...this.#parameters]
527
- });
528
- }
529
- getSql() {
530
- return this.#sql;
531
- }
532
- visitSelectQuery(node) {
533
- const wrapInParens = this.parentNode !== void 0 && !ParensNode.is(this.parentNode) && !InsertQueryNode.is(this.parentNode) && !CreateTableNode.is(this.parentNode) && !CreateViewNode.is(this.parentNode) && !SetOperationNode.is(this.parentNode);
534
- if (this.parentNode === void 0 && node.explain) {
535
- this.visitNode(node.explain);
536
- this.append(" ");
537
- }
538
- if (wrapInParens) this.append("(");
539
- if (node.with) {
540
- this.visitNode(node.with);
541
- this.append(" ");
542
- }
543
- this.append("select");
544
- if (node.distinctOn) {
545
- this.append(" ");
546
- this.compileDistinctOn(node.distinctOn);
547
- }
548
- if (node.frontModifiers?.length) {
549
- this.append(" ");
550
- this.compileList(node.frontModifiers, " ");
551
- }
552
- if (node.top) {
553
- this.append(" ");
554
- this.visitNode(node.top);
555
- }
556
- if (node.selections) {
557
- this.append(" ");
558
- this.compileList(node.selections);
559
- }
560
- if (node.from) {
561
- this.append(" ");
562
- this.visitNode(node.from);
563
- }
564
- if (node.joins) {
565
- this.append(" ");
566
- this.compileList(node.joins, " ");
567
- }
568
- if (node.where) {
569
- this.append(" ");
570
- this.visitNode(node.where);
571
- }
572
- if (node.groupBy) {
573
- this.append(" ");
574
- this.visitNode(node.groupBy);
575
- }
576
- if (node.having) {
577
- this.append(" ");
578
- this.visitNode(node.having);
579
- }
580
- if (node.setOperations) {
581
- this.append(" ");
582
- this.compileList(node.setOperations, " ");
583
- }
584
- if (node.orderBy) {
585
- this.append(" ");
586
- this.visitNode(node.orderBy);
587
- }
588
- if (node.limit) {
589
- this.append(" ");
590
- this.visitNode(node.limit);
591
- }
592
- if (node.offset) {
593
- this.append(" ");
594
- this.visitNode(node.offset);
595
- }
596
- if (node.fetch) {
597
- this.append(" ");
598
- this.visitNode(node.fetch);
599
- }
600
- if (node.endModifiers?.length) {
601
- this.append(" ");
602
- this.compileList(this.sortSelectModifiers(node.endModifiers), " ");
603
- }
604
- if (wrapInParens) this.append(")");
605
- }
606
- visitFrom(node) {
607
- this.append("from ");
608
- this.compileList(node.froms);
609
- }
610
- visitSelection(node) {
611
- this.visitNode(node.selection);
612
- }
613
- visitColumn(node) {
614
- this.visitNode(node.column);
615
- }
616
- compileDistinctOn(expressions) {
617
- this.append("distinct on (");
618
- this.compileList(expressions);
619
- this.append(")");
620
- }
621
- compileList(nodes, separator = ", ") {
622
- const lastIndex = nodes.length - 1;
623
- for (let i = 0; i <= lastIndex; i++) {
624
- this.visitNode(nodes[i]);
625
- if (i < lastIndex) this.append(separator);
626
- }
627
- }
628
- visitWhere(node) {
629
- this.append("where ");
630
- this.visitNode(node.where);
631
- }
632
- visitHaving(node) {
633
- this.append("having ");
634
- this.visitNode(node.having);
635
- }
636
- visitInsertQuery(node) {
637
- const wrapInParens = this.parentNode !== void 0 && !ParensNode.is(this.parentNode) && !RawNode.is(this.parentNode) && !WhenNode.is(this.parentNode);
638
- if (this.parentNode === void 0 && node.explain) {
639
- this.visitNode(node.explain);
640
- this.append(" ");
641
- }
642
- if (wrapInParens) this.append("(");
643
- if (node.with) {
644
- this.visitNode(node.with);
645
- this.append(" ");
646
- }
647
- this.append(node.replace ? "replace" : "insert");
648
- if (node.orAction) {
649
- this.append(" ");
650
- this.visitNode(node.orAction);
651
- }
652
- if (node.top) {
653
- this.append(" ");
654
- this.visitNode(node.top);
655
- }
656
- if (node.into) {
657
- this.append(" into ");
658
- this.visitNode(node.into);
659
- }
660
- if (node.columns) {
661
- this.append(" (");
662
- this.compileList(node.columns);
663
- this.append(")");
664
- }
665
- if (node.output) {
666
- this.append(" ");
667
- this.visitNode(node.output);
668
- }
669
- if (node.values) {
670
- this.append(" ");
671
- this.visitNode(node.values);
672
- }
673
- if (node.defaultValues) {
674
- this.append(" ");
675
- this.append("default values");
676
- }
677
- if (node.onConflict) {
678
- this.append(" ");
679
- this.visitNode(node.onConflict);
680
- }
681
- if (node.onDuplicateKey) {
682
- this.append(" ");
683
- this.visitNode(node.onDuplicateKey);
684
- }
685
- if (node.returning) {
686
- this.append(" ");
687
- this.visitNode(node.returning);
688
- }
689
- if (wrapInParens) this.append(")");
690
- if (node.endModifiers?.length) {
691
- this.append(" ");
692
- this.compileList(node.endModifiers, " ");
693
- }
694
- }
695
- visitValues(node) {
696
- this.append("values ");
697
- this.compileList(node.values);
698
- }
699
- visitDeleteQuery(node) {
700
- const wrapInParens = this.parentNode !== void 0 && !ParensNode.is(this.parentNode) && !RawNode.is(this.parentNode);
701
- if (this.parentNode === void 0 && node.explain) {
702
- this.visitNode(node.explain);
703
- this.append(" ");
704
- }
705
- if (wrapInParens) this.append("(");
706
- if (node.with) {
707
- this.visitNode(node.with);
708
- this.append(" ");
709
- }
710
- this.append("delete ");
711
- if (node.top) {
712
- this.visitNode(node.top);
713
- this.append(" ");
714
- }
715
- this.visitNode(node.from);
716
- if (node.output) {
717
- this.append(" ");
718
- this.visitNode(node.output);
719
- }
720
- if (node.using) {
721
- this.append(" ");
722
- this.visitNode(node.using);
723
- }
724
- if (node.joins) {
725
- this.append(" ");
726
- this.compileList(node.joins, " ");
727
- }
728
- if (node.where) {
729
- this.append(" ");
730
- this.visitNode(node.where);
731
- }
732
- if (node.returning) {
733
- this.append(" ");
734
- this.visitNode(node.returning);
735
- }
736
- if (node.orderBy) {
737
- this.append(" ");
738
- this.visitNode(node.orderBy);
739
- }
740
- if (node.limit) {
741
- this.append(" ");
742
- this.visitNode(node.limit);
743
- }
744
- if (wrapInParens) this.append(")");
745
- if (node.endModifiers?.length) {
746
- this.append(" ");
747
- this.compileList(node.endModifiers, " ");
748
- }
749
- }
750
- visitReturning(node) {
751
- this.append("returning ");
752
- this.compileList(node.selections);
753
- }
754
- visitAlias(node) {
755
- this.visitNode(node.node);
756
- this.append(" as ");
757
- this.visitNode(node.alias);
758
- }
759
- visitReference(node) {
760
- if (node.table) {
761
- this.visitNode(node.table);
762
- this.append(".");
763
- }
764
- this.visitNode(node.column);
765
- }
766
- visitSelectAll(_) {
767
- this.append("*");
768
- }
769
- visitIdentifier(node) {
770
- this.append(this.getLeftIdentifierWrapper());
771
- this.compileUnwrappedIdentifier(node);
772
- this.append(this.getRightIdentifierWrapper());
773
- }
774
- compileUnwrappedIdentifier(node) {
775
- if (!isString(node.name)) throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");
776
- this.append(this.sanitizeIdentifier(node.name));
777
- }
778
- visitAnd(node) {
779
- this.visitNode(node.left);
780
- this.append(" and ");
781
- this.visitNode(node.right);
782
- }
783
- visitOr(node) {
784
- this.visitNode(node.left);
785
- this.append(" or ");
786
- this.visitNode(node.right);
787
- }
788
- visitValue(node) {
789
- if (node.immediate) this.appendImmediateValue(node.value);
790
- else this.appendValue(node.value);
791
- }
792
- visitValueList(node) {
793
- this.append("(");
794
- this.compileList(node.values);
795
- this.append(")");
796
- }
797
- visitTuple(node) {
798
- this.append("(");
799
- this.compileList(node.values);
800
- this.append(")");
801
- }
802
- visitPrimitiveValueList(node) {
803
- this.append("(");
804
- const { values } = node;
805
- for (let i = 0; i < values.length; ++i) {
806
- this.appendValue(values[i]);
807
- if (i !== values.length - 1) this.append(", ");
808
- }
809
- this.append(")");
810
- }
811
- visitParens(node) {
812
- this.append("(");
813
- this.visitNode(node.node);
814
- this.append(")");
815
- }
816
- visitJoin(node) {
817
- this.append(JOIN_TYPE_SQL[node.joinType]);
818
- this.append(" ");
819
- this.visitNode(node.table);
820
- if (node.on) {
821
- this.append(" ");
822
- this.visitNode(node.on);
823
- }
824
- }
825
- visitOn(node) {
826
- this.append("on ");
827
- this.visitNode(node.on);
828
- }
829
- visitRaw(node) {
830
- const { sqlFragments, parameters: params } = node;
831
- for (let i = 0; i < sqlFragments.length; ++i) {
832
- this.append(sqlFragments[i]);
833
- if (params.length > i) this.visitNode(params[i]);
834
- }
835
- }
836
- visitOperator(node) {
837
- this.append(node.operator);
838
- }
839
- visitTable(node) {
840
- this.visitNode(node.table);
841
- }
842
- visitSchemableIdentifier(node) {
843
- if (node.schema) {
844
- this.visitNode(node.schema);
845
- this.append(".");
846
- }
847
- this.visitNode(node.identifier);
848
- }
849
- visitCreateTable(node) {
850
- this.append("create ");
851
- if (node.frontModifiers?.length) {
852
- this.compileList(node.frontModifiers, " ");
853
- this.append(" ");
854
- }
855
- if (node.temporary) this.append("temporary ");
856
- this.append("table ");
857
- if (node.ifNotExists) this.append("if not exists ");
858
- this.visitNode(node.table);
859
- if (!node.selectQuery) {
860
- this.append(" (");
861
- this.compileList([
862
- ...node.columns,
863
- ...node.constraints ?? [],
864
- ...node.indexes ?? []
865
- ]);
866
- this.append(")");
867
- }
868
- if (node.onCommit) {
869
- this.append(" on commit ");
870
- this.append(node.onCommit);
871
- }
872
- if (node.endModifiers?.length) {
873
- this.append(" ");
874
- this.compileList(node.endModifiers, " ");
875
- }
876
- if (node.selectQuery) {
877
- this.append(" as ");
878
- this.visitNode(node.selectQuery);
879
- }
880
- }
881
- visitColumnDefinition(node) {
882
- if (node.ifNotExists) this.append("if not exists ");
883
- this.visitNode(node.column);
884
- this.append(" ");
885
- this.visitNode(node.dataType);
886
- if (node.unsigned) this.append(" unsigned");
887
- if (node.frontModifiers && node.frontModifiers.length > 0) {
888
- this.append(" ");
889
- this.compileList(node.frontModifiers, " ");
890
- }
891
- if (node.generated) {
892
- this.append(" ");
893
- this.visitNode(node.generated);
894
- }
895
- if (node.identity) this.append(" identity");
896
- if (node.defaultTo) {
897
- this.append(" ");
898
- this.visitNode(node.defaultTo);
899
- }
900
- if (node.notNull) this.append(" not null");
901
- if (node.unique) this.append(" unique");
902
- if (node.nullsNotDistinct) this.append(" nulls not distinct");
903
- if (node.primaryKey) this.append(" primary key");
904
- if (node.autoIncrement) {
905
- this.append(" ");
906
- this.append(this.getAutoIncrement());
907
- }
908
- if (node.references) {
909
- this.append(" ");
910
- this.visitNode(node.references);
911
- }
912
- if (node.check) {
913
- this.append(" ");
914
- this.visitNode(node.check);
915
- }
916
- if (node.endModifiers && node.endModifiers.length > 0) {
917
- this.append(" ");
918
- this.compileList(node.endModifiers, " ");
919
- }
920
- }
921
- getAutoIncrement() {
922
- return "auto_increment";
923
- }
924
- visitReferences(node) {
925
- this.append("references ");
926
- this.visitNode(node.table);
927
- this.append(" (");
928
- this.compileList(node.columns);
929
- this.append(")");
930
- if (node.onDelete) {
931
- this.append(" on delete ");
932
- this.append(node.onDelete);
933
- }
934
- if (node.onUpdate) {
935
- this.append(" on update ");
936
- this.append(node.onUpdate);
937
- }
938
- }
939
- visitDropTable(node) {
940
- this.append("drop ");
941
- if (node.temporary) this.append("temporary ");
942
- this.append("table ");
943
- if (node.ifExists) this.append("if exists ");
944
- this.visitNode(node.table);
945
- if (node.cascade) this.append(" cascade");
946
- }
947
- visitDataType(node) {
948
- this.append(node.dataType);
949
- }
950
- visitOrderBy(node) {
951
- this.append("order by ");
952
- this.compileList(node.items);
953
- }
954
- visitOrderByItem(node) {
955
- this.visitNode(node.orderBy);
956
- if (node.collation) {
957
- this.append(" ");
958
- this.visitNode(node.collation);
959
- }
960
- if (node.direction) {
961
- this.append(" ");
962
- this.visitNode(node.direction);
963
- }
964
- if (node.nulls) {
965
- this.append(" nulls ");
966
- this.append(node.nulls);
967
- }
968
- }
969
- visitGroupBy(node) {
970
- this.append("group by ");
971
- this.compileList(node.items);
972
- }
973
- visitGroupByItem(node) {
974
- this.visitNode(node.groupBy);
975
- }
976
- visitUpdateQuery(node) {
977
- const wrapInParens = this.parentNode !== void 0 && !ParensNode.is(this.parentNode) && !RawNode.is(this.parentNode) && !WhenNode.is(this.parentNode);
978
- if (this.parentNode === void 0 && node.explain) {
979
- this.visitNode(node.explain);
980
- this.append(" ");
981
- }
982
- if (wrapInParens) this.append("(");
983
- if (node.with) {
984
- this.visitNode(node.with);
985
- this.append(" ");
986
- }
987
- this.append("update ");
988
- if (node.top) {
989
- this.visitNode(node.top);
990
- this.append(" ");
991
- }
992
- if (node.table) {
993
- this.visitNode(node.table);
994
- this.append(" ");
995
- }
996
- this.append("set ");
997
- if (node.updates) this.compileList(node.updates);
998
- if (node.output) {
999
- this.append(" ");
1000
- this.visitNode(node.output);
1001
- }
1002
- if (node.from) {
1003
- this.append(" ");
1004
- this.visitNode(node.from);
1005
- }
1006
- if (node.joins) {
1007
- if (!node.from) throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");
1008
- this.append(" ");
1009
- this.compileList(node.joins, " ");
1010
- }
1011
- if (node.where) {
1012
- this.append(" ");
1013
- this.visitNode(node.where);
1014
- }
1015
- if (node.returning) {
1016
- this.append(" ");
1017
- this.visitNode(node.returning);
1018
- }
1019
- if (node.orderBy) {
1020
- this.append(" ");
1021
- this.visitNode(node.orderBy);
1022
- }
1023
- if (node.limit) {
1024
- this.append(" ");
1025
- this.visitNode(node.limit);
1026
- }
1027
- if (wrapInParens) this.append(")");
1028
- if (node.endModifiers?.length) {
1029
- this.append(" ");
1030
- this.compileList(node.endModifiers, " ");
1031
- }
1032
- }
1033
- visitColumnUpdate(node) {
1034
- this.visitNode(node.column);
1035
- this.append(" = ");
1036
- this.visitNode(node.value);
1037
- }
1038
- visitLimit(node) {
1039
- this.append("limit ");
1040
- this.visitNode(node.limit);
1041
- }
1042
- visitOffset(node) {
1043
- this.append("offset ");
1044
- this.visitNode(node.offset);
1045
- }
1046
- visitOnConflict(node) {
1047
- this.append("on conflict");
1048
- if (node.columns) {
1049
- this.append(" (");
1050
- this.compileList(node.columns);
1051
- this.append(")");
1052
- } else if (node.constraint) {
1053
- this.append(" on constraint ");
1054
- this.visitNode(node.constraint);
1055
- } else if (node.indexExpression) {
1056
- this.append(" (");
1057
- this.visitNode(node.indexExpression);
1058
- this.append(")");
1059
- }
1060
- if (node.indexWhere) {
1061
- this.append(" ");
1062
- this.visitNode(node.indexWhere);
1063
- }
1064
- if (node.doNothing === true) this.append(" do nothing");
1065
- else if (node.updates) {
1066
- this.append(" do update set ");
1067
- this.compileList(node.updates);
1068
- if (node.updateWhere) {
1069
- this.append(" ");
1070
- this.visitNode(node.updateWhere);
1071
- }
1072
- }
1073
- }
1074
- visitOnDuplicateKey(node) {
1075
- this.append("on duplicate key update ");
1076
- this.compileList(node.updates);
1077
- }
1078
- visitCreateIndex(node) {
1079
- this.append("create ");
1080
- if (node.unique) this.append("unique ");
1081
- this.append("index ");
1082
- if (node.ifNotExists) this.append("if not exists ");
1083
- this.visitNode(node.name);
1084
- if (node.table) {
1085
- this.append(" on ");
1086
- this.visitNode(node.table);
1087
- }
1088
- if (node.using) {
1089
- this.append(" using ");
1090
- this.visitNode(node.using);
1091
- }
1092
- if (node.columns) {
1093
- this.append(" (");
1094
- this.compileList(node.columns);
1095
- this.append(")");
1096
- }
1097
- if (node.nullsNotDistinct) this.append(" nulls not distinct");
1098
- if (node.where) {
1099
- this.append(" ");
1100
- this.visitNode(node.where);
1101
- }
1102
- }
1103
- visitDropIndex(node) {
1104
- this.append("drop index ");
1105
- if (node.ifExists) this.append("if exists ");
1106
- this.visitNode(node.name);
1107
- if (node.table) {
1108
- this.append(" on ");
1109
- this.visitNode(node.table);
1110
- }
1111
- if (node.cascade) this.append(" cascade");
1112
- }
1113
- visitCreateSchema(node) {
1114
- this.append("create schema ");
1115
- if (node.ifNotExists) this.append("if not exists ");
1116
- this.visitNode(node.schema);
1117
- }
1118
- visitDropSchema(node) {
1119
- this.append("drop schema ");
1120
- if (node.ifExists) this.append("if exists ");
1121
- this.visitNode(node.schema);
1122
- if (node.cascade) this.append(" cascade");
1123
- }
1124
- visitPrimaryKeyConstraint(node) {
1125
- if (node.name) {
1126
- this.append("constraint ");
1127
- this.visitNode(node.name);
1128
- this.append(" ");
1129
- }
1130
- this.append("primary key (");
1131
- this.compileList(node.columns);
1132
- this.append(")");
1133
- this.buildDeferrable(node);
1134
- }
1135
- buildDeferrable(node) {
1136
- if (node.deferrable !== void 0) {
1137
- if (node.deferrable) this.append(" deferrable");
1138
- else this.append(" not deferrable");
1139
- }
1140
- if (node.initiallyDeferred !== void 0) {
1141
- if (node.initiallyDeferred) this.append(" initially deferred");
1142
- else this.append(" initially immediate");
1143
- }
1144
- }
1145
- visitUniqueConstraint(node) {
1146
- if (node.name) {
1147
- this.append("constraint ");
1148
- this.visitNode(node.name);
1149
- this.append(" ");
1150
- }
1151
- this.append("unique");
1152
- if (node.nullsNotDistinct) this.append(" nulls not distinct");
1153
- this.append(" (");
1154
- this.compileList(node.columns);
1155
- this.append(")");
1156
- this.buildDeferrable(node);
1157
- }
1158
- visitCheckConstraint(node) {
1159
- if (node.name) {
1160
- this.append("constraint ");
1161
- this.visitNode(node.name);
1162
- this.append(" ");
1163
- }
1164
- this.append("check (");
1165
- this.visitNode(node.expression);
1166
- this.append(")");
1167
- }
1168
- visitForeignKeyConstraint(node) {
1169
- if (node.name) {
1170
- this.append("constraint ");
1171
- this.visitNode(node.name);
1172
- this.append(" ");
1173
- }
1174
- this.append("foreign key (");
1175
- this.compileList(node.columns);
1176
- this.append(") ");
1177
- this.visitNode(node.references);
1178
- if (node.onDelete) {
1179
- this.append(" on delete ");
1180
- this.append(node.onDelete);
1181
- }
1182
- if (node.onUpdate) {
1183
- this.append(" on update ");
1184
- this.append(node.onUpdate);
1185
- }
1186
- this.buildDeferrable(node);
1187
- }
1188
- visitList(node) {
1189
- this.compileList(node.items);
1190
- }
1191
- visitWith(node) {
1192
- this.append("with ");
1193
- if (node.recursive) this.append("recursive ");
1194
- this.compileList(node.expressions);
1195
- }
1196
- visitCommonTableExpression(node) {
1197
- this.visitNode(node.name);
1198
- this.append(" as ");
1199
- if (isBoolean(node.materialized)) {
1200
- if (!node.materialized) this.append("not ");
1201
- this.append("materialized ");
1202
- }
1203
- this.visitNode(node.expression);
1204
- }
1205
- visitCommonTableExpressionName(node) {
1206
- this.visitNode(node.table);
1207
- if (node.columns) {
1208
- this.append("(");
1209
- this.compileList(node.columns);
1210
- this.append(")");
1211
- }
1212
- }
1213
- visitAlterTable(node) {
1214
- this.append("alter table ");
1215
- this.visitNode(node.table);
1216
- this.append(" ");
1217
- if (node.renameTo) {
1218
- this.append("rename to ");
1219
- this.visitNode(node.renameTo);
1220
- }
1221
- if (node.setSchema) {
1222
- this.append("set schema ");
1223
- this.visitNode(node.setSchema);
1224
- }
1225
- if (node.addConstraint) this.visitNode(node.addConstraint);
1226
- if (node.dropConstraint) this.visitNode(node.dropConstraint);
1227
- if (node.renameConstraint) this.visitNode(node.renameConstraint);
1228
- if (node.columnAlterations) this.compileColumnAlterations(node.columnAlterations);
1229
- if (node.addIndex) this.visitNode(node.addIndex);
1230
- if (node.dropIndex) this.visitNode(node.dropIndex);
1231
- }
1232
- visitAddColumn(node) {
1233
- this.append("add column ");
1234
- this.visitNode(node.column);
1235
- }
1236
- visitRenameColumn(node) {
1237
- this.append("rename column ");
1238
- this.visitNode(node.column);
1239
- this.append(" to ");
1240
- this.visitNode(node.renameTo);
1241
- }
1242
- visitDropColumn(node) {
1243
- this.append("drop column ");
1244
- if (node.ifExists) this.append("if exists ");
1245
- this.visitNode(node.column);
1246
- }
1247
- visitAlterColumn(node) {
1248
- this.append("alter column ");
1249
- this.visitNode(node.column);
1250
- this.append(" ");
1251
- if (node.dataType) {
1252
- if (this.announcesNewColumnDataType()) this.append("type ");
1253
- this.visitNode(node.dataType);
1254
- if (node.dataTypeExpression) {
1255
- this.append("using ");
1256
- this.visitNode(node.dataTypeExpression);
1257
- }
1258
- }
1259
- if (node.setDefault) {
1260
- this.append("set default ");
1261
- this.visitNode(node.setDefault);
1262
- }
1263
- if (node.dropDefault) this.append("drop default");
1264
- if (node.setNotNull) this.append("set not null");
1265
- if (node.dropNotNull) this.append("drop not null");
1266
- }
1267
- visitModifyColumn(node) {
1268
- this.append("modify column ");
1269
- this.visitNode(node.column);
1270
- }
1271
- visitAddConstraint(node) {
1272
- this.append("add ");
1273
- this.visitNode(node.constraint);
1274
- }
1275
- visitDropConstraint(node) {
1276
- this.append("drop constraint ");
1277
- if (node.ifExists) this.append("if exists ");
1278
- this.visitNode(node.constraintName);
1279
- if (node.modifier === "cascade") this.append(" cascade");
1280
- else if (node.modifier === "restrict") this.append(" restrict");
1281
- }
1282
- visitRenameConstraint(node) {
1283
- this.append("rename constraint ");
1284
- this.visitNode(node.oldName);
1285
- this.append(" to ");
1286
- this.visitNode(node.newName);
1287
- }
1288
- visitSetOperation(node) {
1289
- this.append(node.operator);
1290
- this.append(" ");
1291
- if (node.all) this.append("all ");
1292
- this.visitNode(node.expression);
1293
- }
1294
- visitCreateView(node) {
1295
- this.append("create ");
1296
- if (node.orReplace) this.append("or replace ");
1297
- if (node.materialized) this.append("materialized ");
1298
- if (node.temporary) this.append("temporary ");
1299
- this.append("view ");
1300
- if (node.ifNotExists) this.append("if not exists ");
1301
- this.visitNode(node.name);
1302
- this.append(" ");
1303
- if (node.columns) {
1304
- this.append("(");
1305
- this.compileList(node.columns);
1306
- this.append(") ");
1307
- }
1308
- if (node.as) {
1309
- this.append("as ");
1310
- this.visitNode(node.as);
1311
- }
1312
- }
1313
- visitRefreshMaterializedView(node) {
1314
- this.append("refresh materialized view ");
1315
- if (node.concurrently) this.append("concurrently ");
1316
- this.visitNode(node.name);
1317
- if (node.withNoData) this.append(" with no data");
1318
- else this.append(" with data");
1319
- }
1320
- visitDropView(node) {
1321
- this.append("drop ");
1322
- if (node.materialized) this.append("materialized ");
1323
- this.append("view ");
1324
- if (node.ifExists) this.append("if exists ");
1325
- this.visitNode(node.name);
1326
- if (node.cascade) this.append(" cascade");
1327
- }
1328
- visitGenerated(node) {
1329
- this.append("generated ");
1330
- if (node.always) this.append("always ");
1331
- if (node.byDefault) this.append("by default ");
1332
- this.append("as ");
1333
- if (node.identity) this.append("identity");
1334
- if (node.expression) {
1335
- this.append("(");
1336
- this.visitNode(node.expression);
1337
- this.append(")");
1338
- }
1339
- if (node.stored) this.append(" stored");
1340
- }
1341
- visitDefaultValue(node) {
1342
- this.append("default ");
1343
- this.visitNode(node.defaultValue);
1344
- }
1345
- visitSelectModifier(node) {
1346
- if (node.rawModifier) this.visitNode(node.rawModifier);
1347
- else this.append(SELECT_MODIFIER_SQL[node.modifier]);
1348
- if (node.of) {
1349
- this.append(" of ");
1350
- this.compileList(node.of, ", ");
1351
- }
1352
- }
1353
- visitCreateType(node) {
1354
- this.append("create type ");
1355
- this.visitNode(node.name);
1356
- if (node.enum) {
1357
- this.append(" as enum ");
1358
- this.visitNode(node.enum);
1359
- }
1360
- }
1361
- visitDropType(node) {
1362
- this.append("drop type ");
1363
- if (node.ifExists) this.append("if exists ");
1364
- this.visitNode(node.name);
1365
- if (node.additionalNames?.length) {
1366
- this.append(", ");
1367
- this.compileList(node.additionalNames);
1368
- }
1369
- if (node.cascade) this.append(" cascade");
1370
- }
1371
- visitAlterType(node) {
1372
- this.append("alter type ");
1373
- this.visitNode(node.name);
1374
- this.append(" ");
1375
- if (node.addValue) this.visitNode(node.addValue);
1376
- else if (node.renameTo) {
1377
- this.append("rename to ");
1378
- this.visitNode(node.renameTo);
1379
- } else if (node.renameValue) this.visitNode(node.renameValue);
1380
- else if (node.setSchema) {
1381
- this.append("set schema ");
1382
- this.visitNode(node.setSchema);
1383
- }
1384
- }
1385
- visitAddValue(node) {
1386
- this.append("add value ");
1387
- if (node.ifNotExists) this.append("if not exists ");
1388
- this.visitNode(node.value);
1389
- if (node.neighborValue) {
1390
- this.append(node.isBefore ? " before " : " after ");
1391
- this.visitNode(node.neighborValue);
1392
- }
1393
- }
1394
- visitRenameValue(node) {
1395
- this.append("rename value ");
1396
- this.visitNode(node.oldValue);
1397
- this.append(" to ");
1398
- this.visitNode(node.newValue);
1399
- }
1400
- visitExplain(node) {
1401
- this.append("explain");
1402
- if (node.options || node.format) {
1403
- this.append(" ");
1404
- this.append(this.getLeftExplainOptionsWrapper());
1405
- if (node.options) {
1406
- this.visitNode(node.options);
1407
- if (node.format) this.append(this.getExplainOptionsDelimiter());
1408
- }
1409
- if (node.format) {
1410
- this.append("format");
1411
- this.append(this.getExplainOptionAssignment());
1412
- this.append(node.format);
1413
- }
1414
- this.append(this.getRightExplainOptionsWrapper());
1415
- }
1416
- }
1417
- visitDefaultInsertValue(_) {
1418
- this.append("default");
1419
- }
1420
- visitAggregateFunction(node) {
1421
- this.append(node.func);
1422
- this.append("(");
1423
- if (node.distinct) this.append("distinct ");
1424
- this.compileList(node.aggregated);
1425
- if (node.orderBy) {
1426
- this.append(" ");
1427
- this.visitNode(node.orderBy);
1428
- }
1429
- this.append(")");
1430
- if (node.withinGroup) {
1431
- this.append(" within group (");
1432
- this.visitNode(node.withinGroup);
1433
- this.append(")");
1434
- }
1435
- if (node.filter) {
1436
- this.append(" filter(");
1437
- this.visitNode(node.filter);
1438
- this.append(")");
1439
- }
1440
- if (node.over) {
1441
- this.append(" ");
1442
- this.visitNode(node.over);
1443
- }
1444
- }
1445
- visitOver(node) {
1446
- this.append("over(");
1447
- if (node.partitionBy) {
1448
- this.visitNode(node.partitionBy);
1449
- if (node.orderBy) this.append(" ");
1450
- }
1451
- if (node.orderBy) this.visitNode(node.orderBy);
1452
- this.append(")");
1453
- }
1454
- visitPartitionBy(node) {
1455
- this.append("partition by ");
1456
- this.compileList(node.items);
1457
- }
1458
- visitPartitionByItem(node) {
1459
- this.visitNode(node.partitionBy);
1460
- }
1461
- visitBinaryOperation(node) {
1462
- this.visitNode(node.leftOperand);
1463
- this.append(" ");
1464
- this.visitNode(node.operator);
1465
- this.append(" ");
1466
- this.visitNode(node.rightOperand);
1467
- }
1468
- visitUnaryOperation(node) {
1469
- this.visitNode(node.operator);
1470
- if (!this.isMinusOperator(node.operator)) this.append(" ");
1471
- this.visitNode(node.operand);
1472
- }
1473
- isMinusOperator(node) {
1474
- return OperatorNode.is(node) && node.operator === "-";
1475
- }
1476
- visitUsing(node) {
1477
- this.append("using ");
1478
- this.compileList(node.tables);
1479
- }
1480
- visitFunction(node) {
1481
- this.append(node.func);
1482
- this.append("(");
1483
- this.compileList(node.arguments);
1484
- this.append(")");
1485
- }
1486
- visitCase(node) {
1487
- this.append("case");
1488
- if (node.value) {
1489
- this.append(" ");
1490
- this.visitNode(node.value);
1491
- }
1492
- if (node.when) {
1493
- this.append(" ");
1494
- this.compileList(node.when, " ");
1495
- }
1496
- if (node.else) {
1497
- this.append(" else ");
1498
- this.visitNode(node.else);
1499
- }
1500
- this.append(" end");
1501
- if (node.isStatement) this.append(" case");
1502
- }
1503
- visitWhen(node) {
1504
- this.append("when ");
1505
- this.visitNode(node.condition);
1506
- if (node.result) {
1507
- this.append(" then ");
1508
- this.visitNode(node.result);
1509
- }
1510
- }
1511
- visitJSONReference(node) {
1512
- this.visitNode(node.reference);
1513
- this.visitNode(node.traversal);
1514
- }
1515
- visitJSONPath(node) {
1516
- if (node.inOperator) this.visitNode(node.inOperator);
1517
- this.append("'$");
1518
- for (const pathLeg of node.pathLegs) this.visitNode(pathLeg);
1519
- this.append("'");
1520
- }
1521
- visitJSONPathLeg(node) {
1522
- const isArrayLocation = node.type === "ArrayLocation";
1523
- const value = String(node.value);
1524
- if (isArrayLocation) {
1525
- this.append("[");
1526
- this.append(this.sanitizeStringLiteral(value));
1527
- this.append("]");
1528
- } else {
1529
- this.append(".\"");
1530
- this.append(this.sanitizeJSONPathMemberValue(value));
1531
- this.append("\"");
1532
- }
1533
- }
1534
- visitJSONOperatorChain(node) {
1535
- for (let i = 0, len = node.values.length; i < len; i++) {
1536
- if (i === len - 1) this.visitNode(node.operator);
1537
- else this.append("->");
1538
- this.visitNode(node.values[i]);
1539
- }
1540
- }
1541
- visitMergeQuery(node) {
1542
- if (node.with) {
1543
- this.visitNode(node.with);
1544
- this.append(" ");
1545
- }
1546
- this.append("merge ");
1547
- if (node.top) {
1548
- this.visitNode(node.top);
1549
- this.append(" ");
1550
- }
1551
- this.append("into ");
1552
- this.visitNode(node.into);
1553
- if (node.using) {
1554
- this.append(" ");
1555
- this.visitNode(node.using);
1556
- }
1557
- if (node.whens) {
1558
- this.append(" ");
1559
- this.compileList(node.whens, " ");
1560
- }
1561
- if (node.returning) {
1562
- this.append(" ");
1563
- this.visitNode(node.returning);
1564
- }
1565
- if (node.output) {
1566
- this.append(" ");
1567
- this.visitNode(node.output);
1568
- }
1569
- if (node.endModifiers?.length) {
1570
- this.append(" ");
1571
- this.compileList(node.endModifiers, " ");
1572
- }
1573
- }
1574
- visitMatched(node) {
1575
- if (node.not) this.append("not ");
1576
- this.append("matched");
1577
- if (node.bySource) this.append(" by source");
1578
- }
1579
- visitAddIndex(node) {
1580
- if (!this.parentNode || !CreateTableNode.is(this.parentNode)) this.append("add ");
1581
- if (node.unique) this.append("unique ");
1582
- this.append("index ");
1583
- this.visitNode(node.name);
1584
- if (node.columns) {
1585
- this.append(" (");
1586
- this.compileList(node.columns);
1587
- this.append(")");
1588
- }
1589
- if (node.using) {
1590
- this.append(" using ");
1591
- this.visitNode(node.using);
1592
- }
1593
- }
1594
- visitCast(node) {
1595
- this.append("cast(");
1596
- this.visitNode(node.expression);
1597
- this.append(" as ");
1598
- this.visitNode(node.dataType);
1599
- this.append(")");
1600
- }
1601
- visitFetch(node) {
1602
- this.append("fetch next ");
1603
- this.visitNode(node.rowCount);
1604
- this.append(` rows ${node.modifier}`);
1605
- }
1606
- visitOutput(node) {
1607
- this.append("output ");
1608
- this.compileList(node.selections);
1609
- }
1610
- visitTop(node) {
1611
- this.append(`top(${node.expression})`);
1612
- if (node.modifiers) this.append(` ${node.modifiers}`);
1613
- }
1614
- visitOrAction(node) {
1615
- this.append(node.action);
1616
- }
1617
- visitCollate(node) {
1618
- this.append("collate ");
1619
- this.visitNode(node.collation);
1620
- }
1621
- append(str) {
1622
- this.#sql += str;
1623
- }
1624
- appendValue(parameter) {
1625
- this.addParameter(parameter);
1626
- this.append(this.getCurrentParameterPlaceholder());
1627
- }
1628
- getLeftIdentifierWrapper() {
1629
- return "\"";
1630
- }
1631
- getRightIdentifierWrapper() {
1632
- return "\"";
1633
- }
1634
- getCurrentParameterPlaceholder() {
1635
- return "$" + this.numParameters;
1636
- }
1637
- getLeftExplainOptionsWrapper() {
1638
- return "(";
1639
- }
1640
- getExplainOptionAssignment() {
1641
- return " ";
1642
- }
1643
- getExplainOptionsDelimiter() {
1644
- return ", ";
1645
- }
1646
- getRightExplainOptionsWrapper() {
1647
- return ")";
1648
- }
1649
- sanitizeIdentifier(identifier) {
1650
- const leftWrap = this.getLeftIdentifierWrapper();
1651
- const rightWrap = this.getRightIdentifierWrapper();
1652
- let sanitized = "";
1653
- for (const c of identifier) {
1654
- sanitized += c;
1655
- if (c === leftWrap) sanitized += leftWrap;
1656
- else if (c === rightWrap) sanitized += rightWrap;
1657
- }
1658
- return sanitized;
1659
- }
1660
- sanitizeStringLiteral(value) {
1661
- return value.replace(LIT_WRAP_REGEX, "''");
1662
- }
1663
- sanitizeJSONPathMemberValue(value) {
1664
- return value.replace(JSON_PATH_MEMBER_WRAP_REGEX, (char) => char === "'" ? "''" : "\\\"");
1665
- }
1666
- addParameter(parameter) {
1667
- this.#parameters.push(parameter);
1668
- }
1669
- appendImmediateValue(value) {
1670
- if (isString(value)) this.appendStringLiteral(value);
1671
- else if (isNumber(value) || isBoolean(value) || isBigInt(value)) this.append(value.toString());
1672
- else if (isNull(value)) this.append("null");
1673
- else if (isDate(value)) this.appendImmediateValue(value.toISOString());
1674
- else throw new Error(`invalid immediate value ${value}`);
1675
- }
1676
- appendStringLiteral(value) {
1677
- this.append("'");
1678
- this.append(this.sanitizeStringLiteral(value));
1679
- this.append("'");
1680
- }
1681
- sortSelectModifiers(arr) {
1682
- return freeze(arr.toSorted((left, right) => left.modifier && right.modifier ? SELECT_MODIFIER_PRIORITY[left.modifier] - SELECT_MODIFIER_PRIORITY[right.modifier] : 1));
1683
- }
1684
- compileColumnAlterations(columnAlterations) {
1685
- this.compileList(columnAlterations);
1686
- }
1687
- /**
1688
- * controls whether the dialect adds a "type" keyword before a column's new data
1689
- * type in an ALTER TABLE statement.
1690
- */
1691
- announcesNewColumnDataType() {
1692
- return true;
1693
- }
1694
- };
1695
- var SELECT_MODIFIER_SQL = freeze({
1696
- ForKeyShare: "for key share",
1697
- ForNoKeyUpdate: "for no key update",
1698
- ForUpdate: "for update",
1699
- ForShare: "for share",
1700
- NoWait: "nowait",
1701
- SkipLocked: "skip locked",
1702
- Distinct: "distinct"
1703
- });
1704
- var SELECT_MODIFIER_PRIORITY = freeze({
1705
- ForKeyShare: 1,
1706
- ForNoKeyUpdate: 1,
1707
- ForUpdate: 1,
1708
- ForShare: 1,
1709
- NoWait: 2,
1710
- SkipLocked: 2,
1711
- Distinct: 0
1712
- });
1713
- var JOIN_TYPE_SQL = freeze({
1714
- InnerJoin: "inner join",
1715
- LeftJoin: "left join",
1716
- RightJoin: "right join",
1717
- FullJoin: "full join",
1718
- CrossJoin: "cross join",
1719
- LateralInnerJoin: "inner join lateral",
1720
- LateralLeftJoin: "left join lateral",
1721
- LateralCrossJoin: "cross join lateral",
1722
- OuterApply: "outer apply",
1723
- CrossApply: "cross apply",
1724
- Using: "using"
1725
- });
1726
- //#endregion
1727
- export { noop as A, isFunction as C, isReadonlyArray as D, isObject as E, isString as O, isDate as S, isNumber as T, freeze as _, InsertQueryNode as a, isBoolean as b, OperatorNode as c, isUnaryOperator as d, SchemableIdentifierNode as f, asArray as g, IdentifierNode as h, WhenNode as i, isUndefined as k, isBinaryOperator as l, ON_COMMIT_ACTIONS as m, CreateViewNode as n, ParensNode as o, CreateTableNode as p, SetOperationNode as r, RawNode as s, DefaultQueryCompiler as t, isJSONOperator as u, getMessage as v, isNull as w, isBuffer as x, isBigInt as y };