@powerhousedao/clint 6.3.0-dev.9 → 6.4.0-next.0

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 (93) hide show
  1. package/dist/build-DZIv63eB.mjs +77 -0
  2. package/dist/build-DZIv63eB.mjs.map +1 -0
  3. package/dist/{build-skills-BnqGyuCH.mjs → build-skills-BNEOn-cl.mjs} +15 -6
  4. package/dist/build-skills-BNEOn-cl.mjs.map +1 -0
  5. package/dist/dist--xzirmg-.mjs +655 -0
  6. package/dist/dist--xzirmg-.mjs.map +1 -0
  7. package/dist/glob-CGjvhxgW.mjs +48 -0
  8. package/dist/glob-CGjvhxgW.mjs.map +1 -0
  9. package/dist/index-C3-HSfKb.d.mts +389 -0
  10. package/dist/index-C3-HSfKb.d.mts.map +1 -0
  11. package/dist/index.d.mts +55 -303
  12. package/dist/index.d.mts.map +1 -1
  13. package/dist/index.mjs +7 -8
  14. package/dist/integrations/mastra/index.d.mts +248 -0
  15. package/dist/integrations/mastra/index.d.mts.map +1 -0
  16. package/dist/integrations/mastra/index.mjs +509 -0
  17. package/dist/integrations/mastra/index.mjs.map +1 -0
  18. package/dist/integrations/powerhouse/index.d.mts +4 -0
  19. package/dist/integrations/powerhouse/index.mjs +3 -0
  20. package/dist/markdown-BUeGwhbR.mjs +1588 -0
  21. package/dist/markdown-BUeGwhbR.mjs.map +1 -0
  22. package/dist/powerhouse-BDnj7kqd.mjs +1922 -0
  23. package/dist/powerhouse-BDnj7kqd.mjs.map +1 -0
  24. package/dist/{proxy-BFR8GScT.mjs → proxy-ji3EHzLn.mjs} +128 -28
  25. package/dist/proxy-ji3EHzLn.mjs.map +1 -0
  26. package/dist/remote-reactor-BQzq4yfO.mjs +69 -0
  27. package/dist/remote-reactor-BQzq4yfO.mjs.map +1 -0
  28. package/dist/{start-b7Mn2cxB.mjs → repl-Czb7u0x_.mjs} +6 -29
  29. package/dist/repl-Czb7u0x_.mjs.map +1 -0
  30. package/dist/runners/cli-runner.d.mts +339 -0
  31. package/dist/runners/cli-runner.d.mts.map +1 -0
  32. package/dist/runners/cli-runner.mjs +324 -0
  33. package/dist/runners/cli-runner.mjs.map +1 -0
  34. package/dist/runners/mastra-runner.d.mts +5 -3
  35. package/dist/runners/mastra-runner.d.mts.map +1 -1
  36. package/dist/runners/mastra-runner.mjs +10 -60
  37. package/dist/runners/mastra-runner.mjs.map +1 -1
  38. package/dist/runners/proxy-runner.d.mts +281 -0
  39. package/dist/runners/proxy-runner.d.mts.map +1 -0
  40. package/dist/runners/proxy-runner.mjs +91 -0
  41. package/dist/runners/proxy-runner.mjs.map +1 -0
  42. package/dist/schema-BEKAZGyT.mjs +47 -0
  43. package/dist/schema-BEKAZGyT.mjs.map +1 -0
  44. package/dist/{src-BebNN3xc.mjs → src-BehwgLP6.mjs} +395 -1481
  45. package/dist/src-BehwgLP6.mjs.map +1 -0
  46. package/dist/start-BHn9LIyX.mjs +37 -0
  47. package/dist/start-BHn9LIyX.mjs.map +1 -0
  48. package/dist/store-CxqB-OrX.mjs +101 -0
  49. package/dist/store-CxqB-OrX.mjs.map +1 -0
  50. package/dist/{stream-DVuufwIj.mjs → stream-BguHx7vC.mjs} +4 -2
  51. package/dist/{stream-DVuufwIj.mjs.map → stream-BguHx7vC.mjs.map} +1 -1
  52. package/dist/testing/index.d.mts +81 -0
  53. package/dist/testing/index.d.mts.map +1 -0
  54. package/dist/testing/index.mjs +131 -0
  55. package/dist/testing/index.mjs.map +1 -0
  56. package/dist/{types-CRkoD-Mm.d.mts → types-CF6GuPJd.d.mts} +241 -261
  57. package/dist/types-CF6GuPJd.d.mts.map +1 -0
  58. package/dist/types-CbHJ-ZnH.d.mts +60 -0
  59. package/dist/types-CbHJ-ZnH.d.mts.map +1 -0
  60. package/package.json +44 -25
  61. package/dist/build-skills-BnqGyuCH.mjs.map +0 -1
  62. package/dist/dist-CUltriBW.mjs +0 -1628
  63. package/dist/dist-CUltriBW.mjs.map +0 -1
  64. package/dist/drive-Bu9zoFrO.mjs +0 -85
  65. package/dist/drive-Bu9zoFrO.mjs.map +0 -1
  66. package/dist/esm-C1DOsF1a.mjs +0 -13140
  67. package/dist/esm-C1DOsF1a.mjs.map +0 -1
  68. package/dist/events-BnwGFTjv.mjs +0 -237
  69. package/dist/events-BnwGFTjv.mjs.map +0 -1
  70. package/dist/folders-BYO1Wqqb.mjs +0 -256
  71. package/dist/folders-BYO1Wqqb.mjs.map +0 -1
  72. package/dist/local-signer-EFzJV3bn.mjs +0 -128
  73. package/dist/local-signer-EFzJV3bn.mjs.map +0 -1
  74. package/dist/markdown-D-sP2zw_.mjs +0 -275
  75. package/dist/markdown-D-sP2zw_.mjs.map +0 -1
  76. package/dist/proxy-BFR8GScT.mjs.map +0 -1
  77. package/dist/proxy-routes-DP3ztsnS.mjs +0 -215
  78. package/dist/proxy-routes-DP3ztsnS.mjs.map +0 -1
  79. package/dist/reactor-C9VIUX1H.mjs +0 -51
  80. package/dist/reactor-C9VIUX1H.mjs.map +0 -1
  81. package/dist/runners/clint-runner.d.mts +0 -398
  82. package/dist/runners/clint-runner.d.mts.map +0 -1
  83. package/dist/runners/clint-runner.mjs +0 -519
  84. package/dist/runners/clint-runner.mjs.map +0 -1
  85. package/dist/services-9E-r0nWl.mjs +0 -999
  86. package/dist/services-9E-r0nWl.mjs.map +0 -1
  87. package/dist/src-BebNN3xc.mjs.map +0 -1
  88. package/dist/start-b7Mn2cxB.mjs.map +0 -1
  89. package/dist/subscriptions-CfiflAsI.mjs +0 -38
  90. package/dist/subscriptions-CfiflAsI.mjs.map +0 -1
  91. package/dist/switchboard-CyvOavqL.mjs +0 -57
  92. package/dist/switchboard-CyvOavqL.mjs.map +0 -1
  93. package/dist/types-CRkoD-Mm.d.mts.map +0 -1
@@ -1,1628 +0,0 @@
1
- import { C as isDate, E as isString, S as isBoolean, T as isNumber, _ as AliasNode, a as NOOP_QUERY_EXECUTOR, b as freeze, c as InsertQueryNode, d as ValueNode, f as parseStringReference, g as isOperationNodeSource, h as OperatorNode, i as SetOperationNode, l as ParensNode, m as RawNode, n as CreateViewNode, o as createQueryId, p as logOnce, r as parseTable, s as WhenNode, u as parseValueExpression, v as CreateTableNode, w as isNull, x as isBigInt, y as IdentifierNode } from "./esm-C1DOsF1a.mjs";
2
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/raw-builder/raw-builder.js
3
- var RawBuilderImpl = class RawBuilderImpl {
4
- #props;
5
- constructor(props) {
6
- this.#props = freeze(props);
7
- }
8
- get expressionType() {}
9
- get isRawBuilder() {
10
- return true;
11
- }
12
- as(alias) {
13
- return new AliasedRawBuilderImpl(this, alias);
14
- }
15
- $castTo() {
16
- return new RawBuilderImpl({ ...this.#props });
17
- }
18
- $notNull() {
19
- return new RawBuilderImpl(this.#props);
20
- }
21
- withPlugin(plugin) {
22
- return new RawBuilderImpl({
23
- ...this.#props,
24
- plugins: this.#props.plugins !== void 0 ? freeze([...this.#props.plugins, plugin]) : freeze([plugin])
25
- });
26
- }
27
- toOperationNode() {
28
- return this.#toOperationNode(this.#getExecutor());
29
- }
30
- compile(executorProvider) {
31
- return this.#compile(this.#getExecutor(executorProvider));
32
- }
33
- async execute(executorProvider) {
34
- const executor = this.#getExecutor(executorProvider);
35
- return executor.executeQuery(this.#compile(executor));
36
- }
37
- #getExecutor(executorProvider) {
38
- const executor = executorProvider !== void 0 ? executorProvider.getExecutor() : NOOP_QUERY_EXECUTOR;
39
- return this.#props.plugins !== void 0 ? executor.withPlugins(this.#props.plugins) : executor;
40
- }
41
- #toOperationNode(executor) {
42
- return executor.transformQuery(this.#props.rawNode, this.#props.queryId);
43
- }
44
- #compile(executor) {
45
- return executor.compileQuery(this.#toOperationNode(executor), this.#props.queryId);
46
- }
47
- };
48
- function createRawBuilder(props) {
49
- return new RawBuilderImpl(props);
50
- }
51
- var AliasedRawBuilderImpl = class {
52
- #rawBuilder;
53
- #alias;
54
- constructor(rawBuilder, alias) {
55
- this.#rawBuilder = rawBuilder;
56
- this.#alias = alias;
57
- }
58
- get expression() {
59
- return this.#rawBuilder;
60
- }
61
- get alias() {
62
- return this.#alias;
63
- }
64
- get rawBuilder() {
65
- return this.#rawBuilder;
66
- }
67
- toOperationNode() {
68
- return AliasNode.create(this.#rawBuilder.toOperationNode(), isOperationNodeSource(this.#alias) ? this.#alias.toOperationNode() : IdentifierNode.create(this.#alias));
69
- }
70
- };
71
- //#endregion
72
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/raw-builder/sql.js
73
- const sql = Object.assign((sqlFragments, ...parameters) => {
74
- return createRawBuilder({
75
- queryId: createQueryId(),
76
- rawNode: RawNode.create(sqlFragments, parameters?.map(parseParameter) ?? [])
77
- });
78
- }, {
79
- ref(columnReference) {
80
- return createRawBuilder({
81
- queryId: createQueryId(),
82
- rawNode: RawNode.createWithChild(parseStringReference(columnReference))
83
- });
84
- },
85
- val(value) {
86
- return createRawBuilder({
87
- queryId: createQueryId(),
88
- rawNode: RawNode.createWithChild(parseValueExpression(value))
89
- });
90
- },
91
- value(value) {
92
- return this.val(value);
93
- },
94
- table(tableReference) {
95
- return createRawBuilder({
96
- queryId: createQueryId(),
97
- rawNode: RawNode.createWithChild(parseTable(tableReference))
98
- });
99
- },
100
- id(...ids) {
101
- const fragments = new Array(ids.length + 1).fill(".");
102
- fragments[0] = "";
103
- fragments[fragments.length - 1] = "";
104
- return createRawBuilder({
105
- queryId: createQueryId(),
106
- rawNode: RawNode.create(fragments, ids.map(IdentifierNode.create))
107
- });
108
- },
109
- lit(value) {
110
- return createRawBuilder({
111
- queryId: createQueryId(),
112
- rawNode: RawNode.createWithChild(ValueNode.createImmediate(value))
113
- });
114
- },
115
- literal(value) {
116
- return this.lit(value);
117
- },
118
- raw(sql) {
119
- return createRawBuilder({
120
- queryId: createQueryId(),
121
- rawNode: RawNode.createWithSql(sql)
122
- });
123
- },
124
- join(array, separator = sql`, `) {
125
- const nodes = new Array(Math.max(2 * array.length - 1, 0));
126
- const sep = separator.toOperationNode();
127
- for (let i = 0; i < array.length; ++i) {
128
- nodes[2 * i] = parseParameter(array[i]);
129
- if (i !== array.length - 1) nodes[2 * i + 1] = sep;
130
- }
131
- return createRawBuilder({
132
- queryId: createQueryId(),
133
- rawNode: RawNode.createWithChildren(nodes)
134
- });
135
- }
136
- });
137
- function parseParameter(param) {
138
- if (isOperationNodeSource(param)) return param.toOperationNode();
139
- return parseValueExpression(param);
140
- }
141
- //#endregion
142
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/operation-node/operation-node-visitor.js
143
- var OperationNodeVisitor = class {
144
- nodeStack = [];
145
- get parentNode() {
146
- return this.nodeStack[this.nodeStack.length - 2];
147
- }
148
- #visitors = freeze({
149
- AliasNode: this.visitAlias.bind(this),
150
- ColumnNode: this.visitColumn.bind(this),
151
- IdentifierNode: this.visitIdentifier.bind(this),
152
- SchemableIdentifierNode: this.visitSchemableIdentifier.bind(this),
153
- RawNode: this.visitRaw.bind(this),
154
- ReferenceNode: this.visitReference.bind(this),
155
- SelectQueryNode: this.visitSelectQuery.bind(this),
156
- SelectionNode: this.visitSelection.bind(this),
157
- TableNode: this.visitTable.bind(this),
158
- FromNode: this.visitFrom.bind(this),
159
- SelectAllNode: this.visitSelectAll.bind(this),
160
- AndNode: this.visitAnd.bind(this),
161
- OrNode: this.visitOr.bind(this),
162
- ValueNode: this.visitValue.bind(this),
163
- ValueListNode: this.visitValueList.bind(this),
164
- PrimitiveValueListNode: this.visitPrimitiveValueList.bind(this),
165
- ParensNode: this.visitParens.bind(this),
166
- JoinNode: this.visitJoin.bind(this),
167
- OperatorNode: this.visitOperator.bind(this),
168
- WhereNode: this.visitWhere.bind(this),
169
- InsertQueryNode: this.visitInsertQuery.bind(this),
170
- DeleteQueryNode: this.visitDeleteQuery.bind(this),
171
- ReturningNode: this.visitReturning.bind(this),
172
- CreateTableNode: this.visitCreateTable.bind(this),
173
- AddColumnNode: this.visitAddColumn.bind(this),
174
- ColumnDefinitionNode: this.visitColumnDefinition.bind(this),
175
- DropTableNode: this.visitDropTable.bind(this),
176
- DataTypeNode: this.visitDataType.bind(this),
177
- OrderByNode: this.visitOrderBy.bind(this),
178
- OrderByItemNode: this.visitOrderByItem.bind(this),
179
- GroupByNode: this.visitGroupBy.bind(this),
180
- GroupByItemNode: this.visitGroupByItem.bind(this),
181
- UpdateQueryNode: this.visitUpdateQuery.bind(this),
182
- ColumnUpdateNode: this.visitColumnUpdate.bind(this),
183
- LimitNode: this.visitLimit.bind(this),
184
- OffsetNode: this.visitOffset.bind(this),
185
- OnConflictNode: this.visitOnConflict.bind(this),
186
- OnDuplicateKeyNode: this.visitOnDuplicateKey.bind(this),
187
- CreateIndexNode: this.visitCreateIndex.bind(this),
188
- DropIndexNode: this.visitDropIndex.bind(this),
189
- ListNode: this.visitList.bind(this),
190
- PrimaryKeyConstraintNode: this.visitPrimaryKeyConstraint.bind(this),
191
- UniqueConstraintNode: this.visitUniqueConstraint.bind(this),
192
- ReferencesNode: this.visitReferences.bind(this),
193
- CheckConstraintNode: this.visitCheckConstraint.bind(this),
194
- WithNode: this.visitWith.bind(this),
195
- CommonTableExpressionNode: this.visitCommonTableExpression.bind(this),
196
- CommonTableExpressionNameNode: this.visitCommonTableExpressionName.bind(this),
197
- HavingNode: this.visitHaving.bind(this),
198
- CreateSchemaNode: this.visitCreateSchema.bind(this),
199
- DropSchemaNode: this.visitDropSchema.bind(this),
200
- AlterTableNode: this.visitAlterTable.bind(this),
201
- DropColumnNode: this.visitDropColumn.bind(this),
202
- RenameColumnNode: this.visitRenameColumn.bind(this),
203
- AlterColumnNode: this.visitAlterColumn.bind(this),
204
- ModifyColumnNode: this.visitModifyColumn.bind(this),
205
- AddConstraintNode: this.visitAddConstraint.bind(this),
206
- DropConstraintNode: this.visitDropConstraint.bind(this),
207
- RenameConstraintNode: this.visitRenameConstraint.bind(this),
208
- ForeignKeyConstraintNode: this.visitForeignKeyConstraint.bind(this),
209
- CreateViewNode: this.visitCreateView.bind(this),
210
- RefreshMaterializedViewNode: this.visitRefreshMaterializedView.bind(this),
211
- DropViewNode: this.visitDropView.bind(this),
212
- GeneratedNode: this.visitGenerated.bind(this),
213
- DefaultValueNode: this.visitDefaultValue.bind(this),
214
- OnNode: this.visitOn.bind(this),
215
- ValuesNode: this.visitValues.bind(this),
216
- SelectModifierNode: this.visitSelectModifier.bind(this),
217
- CreateTypeNode: this.visitCreateType.bind(this),
218
- DropTypeNode: this.visitDropType.bind(this),
219
- ExplainNode: this.visitExplain.bind(this),
220
- DefaultInsertValueNode: this.visitDefaultInsertValue.bind(this),
221
- AggregateFunctionNode: this.visitAggregateFunction.bind(this),
222
- OverNode: this.visitOver.bind(this),
223
- PartitionByNode: this.visitPartitionBy.bind(this),
224
- PartitionByItemNode: this.visitPartitionByItem.bind(this),
225
- SetOperationNode: this.visitSetOperation.bind(this),
226
- BinaryOperationNode: this.visitBinaryOperation.bind(this),
227
- UnaryOperationNode: this.visitUnaryOperation.bind(this),
228
- UsingNode: this.visitUsing.bind(this),
229
- FunctionNode: this.visitFunction.bind(this),
230
- CaseNode: this.visitCase.bind(this),
231
- WhenNode: this.visitWhen.bind(this),
232
- JSONReferenceNode: this.visitJSONReference.bind(this),
233
- JSONPathNode: this.visitJSONPath.bind(this),
234
- JSONPathLegNode: this.visitJSONPathLeg.bind(this),
235
- JSONOperatorChainNode: this.visitJSONOperatorChain.bind(this),
236
- TupleNode: this.visitTuple.bind(this),
237
- MergeQueryNode: this.visitMergeQuery.bind(this),
238
- MatchedNode: this.visitMatched.bind(this),
239
- AddIndexNode: this.visitAddIndex.bind(this),
240
- CastNode: this.visitCast.bind(this),
241
- FetchNode: this.visitFetch.bind(this),
242
- TopNode: this.visitTop.bind(this),
243
- OutputNode: this.visitOutput.bind(this),
244
- OrActionNode: this.visitOrAction.bind(this),
245
- CollateNode: this.visitCollate.bind(this)
246
- });
247
- visitNode = (node) => {
248
- this.nodeStack.push(node);
249
- this.#visitors[node.kind](node);
250
- this.nodeStack.pop();
251
- };
252
- };
253
- //#endregion
254
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/query-compiler/default-query-compiler.js
255
- const LIT_WRAP_REGEX = /'/g;
256
- var DefaultQueryCompiler = class extends OperationNodeVisitor {
257
- #sql = "";
258
- #parameters = [];
259
- get numParameters() {
260
- return this.#parameters.length;
261
- }
262
- compileQuery(node, queryId) {
263
- this.#sql = "";
264
- this.#parameters = [];
265
- this.nodeStack.splice(0, this.nodeStack.length);
266
- this.visitNode(node);
267
- return freeze({
268
- query: node,
269
- queryId,
270
- sql: this.getSql(),
271
- parameters: [...this.#parameters]
272
- });
273
- }
274
- getSql() {
275
- return this.#sql;
276
- }
277
- visitSelectQuery(node) {
278
- 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);
279
- if (this.parentNode === void 0 && node.explain) {
280
- this.visitNode(node.explain);
281
- this.append(" ");
282
- }
283
- if (wrapInParens) this.append("(");
284
- if (node.with) {
285
- this.visitNode(node.with);
286
- this.append(" ");
287
- }
288
- this.append("select");
289
- if (node.distinctOn) {
290
- this.append(" ");
291
- this.compileDistinctOn(node.distinctOn);
292
- }
293
- if (node.frontModifiers?.length) {
294
- this.append(" ");
295
- this.compileList(node.frontModifiers, " ");
296
- }
297
- if (node.top) {
298
- this.append(" ");
299
- this.visitNode(node.top);
300
- }
301
- if (node.selections) {
302
- this.append(" ");
303
- this.compileList(node.selections);
304
- }
305
- if (node.from) {
306
- this.append(" ");
307
- this.visitNode(node.from);
308
- }
309
- if (node.joins) {
310
- this.append(" ");
311
- this.compileList(node.joins, " ");
312
- }
313
- if (node.where) {
314
- this.append(" ");
315
- this.visitNode(node.where);
316
- }
317
- if (node.groupBy) {
318
- this.append(" ");
319
- this.visitNode(node.groupBy);
320
- }
321
- if (node.having) {
322
- this.append(" ");
323
- this.visitNode(node.having);
324
- }
325
- if (node.setOperations) {
326
- this.append(" ");
327
- this.compileList(node.setOperations, " ");
328
- }
329
- if (node.orderBy) {
330
- this.append(" ");
331
- this.visitNode(node.orderBy);
332
- }
333
- if (node.limit) {
334
- this.append(" ");
335
- this.visitNode(node.limit);
336
- }
337
- if (node.offset) {
338
- this.append(" ");
339
- this.visitNode(node.offset);
340
- }
341
- if (node.fetch) {
342
- this.append(" ");
343
- this.visitNode(node.fetch);
344
- }
345
- if (node.endModifiers?.length) {
346
- this.append(" ");
347
- this.compileList(this.sortSelectModifiers([...node.endModifiers]), " ");
348
- }
349
- if (wrapInParens) this.append(")");
350
- }
351
- visitFrom(node) {
352
- this.append("from ");
353
- this.compileList(node.froms);
354
- }
355
- visitSelection(node) {
356
- this.visitNode(node.selection);
357
- }
358
- visitColumn(node) {
359
- this.visitNode(node.column);
360
- }
361
- compileDistinctOn(expressions) {
362
- this.append("distinct on (");
363
- this.compileList(expressions);
364
- this.append(")");
365
- }
366
- compileList(nodes, separator = ", ") {
367
- const lastIndex = nodes.length - 1;
368
- for (let i = 0; i <= lastIndex; i++) {
369
- this.visitNode(nodes[i]);
370
- if (i < lastIndex) this.append(separator);
371
- }
372
- }
373
- visitWhere(node) {
374
- this.append("where ");
375
- this.visitNode(node.where);
376
- }
377
- visitHaving(node) {
378
- this.append("having ");
379
- this.visitNode(node.having);
380
- }
381
- visitInsertQuery(node) {
382
- const wrapInParens = this.parentNode !== void 0 && !ParensNode.is(this.parentNode) && !RawNode.is(this.parentNode) && !WhenNode.is(this.parentNode);
383
- if (this.parentNode === void 0 && node.explain) {
384
- this.visitNode(node.explain);
385
- this.append(" ");
386
- }
387
- if (wrapInParens) this.append("(");
388
- if (node.with) {
389
- this.visitNode(node.with);
390
- this.append(" ");
391
- }
392
- this.append(node.replace ? "replace" : "insert");
393
- if (node.ignore) {
394
- logOnce("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead.");
395
- this.append(" ignore");
396
- }
397
- if (node.orAction) {
398
- this.append(" ");
399
- this.visitNode(node.orAction);
400
- }
401
- if (node.top) {
402
- this.append(" ");
403
- this.visitNode(node.top);
404
- }
405
- if (node.into) {
406
- this.append(" into ");
407
- this.visitNode(node.into);
408
- }
409
- if (node.columns) {
410
- this.append(" (");
411
- this.compileList(node.columns);
412
- this.append(")");
413
- }
414
- if (node.output) {
415
- this.append(" ");
416
- this.visitNode(node.output);
417
- }
418
- if (node.values) {
419
- this.append(" ");
420
- this.visitNode(node.values);
421
- }
422
- if (node.defaultValues) {
423
- this.append(" ");
424
- this.append("default values");
425
- }
426
- if (node.onConflict) {
427
- this.append(" ");
428
- this.visitNode(node.onConflict);
429
- }
430
- if (node.onDuplicateKey) {
431
- this.append(" ");
432
- this.visitNode(node.onDuplicateKey);
433
- }
434
- if (node.returning) {
435
- this.append(" ");
436
- this.visitNode(node.returning);
437
- }
438
- if (wrapInParens) this.append(")");
439
- if (node.endModifiers?.length) {
440
- this.append(" ");
441
- this.compileList(node.endModifiers, " ");
442
- }
443
- }
444
- visitValues(node) {
445
- this.append("values ");
446
- this.compileList(node.values);
447
- }
448
- visitDeleteQuery(node) {
449
- const wrapInParens = this.parentNode !== void 0 && !ParensNode.is(this.parentNode) && !RawNode.is(this.parentNode);
450
- if (this.parentNode === void 0 && node.explain) {
451
- this.visitNode(node.explain);
452
- this.append(" ");
453
- }
454
- if (wrapInParens) this.append("(");
455
- if (node.with) {
456
- this.visitNode(node.with);
457
- this.append(" ");
458
- }
459
- this.append("delete ");
460
- if (node.top) {
461
- this.visitNode(node.top);
462
- this.append(" ");
463
- }
464
- this.visitNode(node.from);
465
- if (node.output) {
466
- this.append(" ");
467
- this.visitNode(node.output);
468
- }
469
- if (node.using) {
470
- this.append(" ");
471
- this.visitNode(node.using);
472
- }
473
- if (node.joins) {
474
- this.append(" ");
475
- this.compileList(node.joins, " ");
476
- }
477
- if (node.where) {
478
- this.append(" ");
479
- this.visitNode(node.where);
480
- }
481
- if (node.orderBy) {
482
- this.append(" ");
483
- this.visitNode(node.orderBy);
484
- }
485
- if (node.limit) {
486
- this.append(" ");
487
- this.visitNode(node.limit);
488
- }
489
- if (node.returning) {
490
- this.append(" ");
491
- this.visitNode(node.returning);
492
- }
493
- if (wrapInParens) this.append(")");
494
- if (node.endModifiers?.length) {
495
- this.append(" ");
496
- this.compileList(node.endModifiers, " ");
497
- }
498
- }
499
- visitReturning(node) {
500
- this.append("returning ");
501
- this.compileList(node.selections);
502
- }
503
- visitAlias(node) {
504
- this.visitNode(node.node);
505
- this.append(" as ");
506
- this.visitNode(node.alias);
507
- }
508
- visitReference(node) {
509
- if (node.table) {
510
- this.visitNode(node.table);
511
- this.append(".");
512
- }
513
- this.visitNode(node.column);
514
- }
515
- visitSelectAll(_) {
516
- this.append("*");
517
- }
518
- visitIdentifier(node) {
519
- this.append(this.getLeftIdentifierWrapper());
520
- this.compileUnwrappedIdentifier(node);
521
- this.append(this.getRightIdentifierWrapper());
522
- }
523
- compileUnwrappedIdentifier(node) {
524
- if (!isString(node.name)) throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");
525
- this.append(this.sanitizeIdentifier(node.name));
526
- }
527
- visitAnd(node) {
528
- this.visitNode(node.left);
529
- this.append(" and ");
530
- this.visitNode(node.right);
531
- }
532
- visitOr(node) {
533
- this.visitNode(node.left);
534
- this.append(" or ");
535
- this.visitNode(node.right);
536
- }
537
- visitValue(node) {
538
- if (node.immediate) this.appendImmediateValue(node.value);
539
- else this.appendValue(node.value);
540
- }
541
- visitValueList(node) {
542
- this.append("(");
543
- this.compileList(node.values);
544
- this.append(")");
545
- }
546
- visitTuple(node) {
547
- this.append("(");
548
- this.compileList(node.values);
549
- this.append(")");
550
- }
551
- visitPrimitiveValueList(node) {
552
- this.append("(");
553
- const { values } = node;
554
- for (let i = 0; i < values.length; ++i) {
555
- this.appendValue(values[i]);
556
- if (i !== values.length - 1) this.append(", ");
557
- }
558
- this.append(")");
559
- }
560
- visitParens(node) {
561
- this.append("(");
562
- this.visitNode(node.node);
563
- this.append(")");
564
- }
565
- visitJoin(node) {
566
- this.append(JOIN_TYPE_SQL[node.joinType]);
567
- this.append(" ");
568
- this.visitNode(node.table);
569
- if (node.on) {
570
- this.append(" ");
571
- this.visitNode(node.on);
572
- }
573
- }
574
- visitOn(node) {
575
- this.append("on ");
576
- this.visitNode(node.on);
577
- }
578
- visitRaw(node) {
579
- const { sqlFragments, parameters: params } = node;
580
- for (let i = 0; i < sqlFragments.length; ++i) {
581
- this.append(sqlFragments[i]);
582
- if (params.length > i) this.visitNode(params[i]);
583
- }
584
- }
585
- visitOperator(node) {
586
- this.append(node.operator);
587
- }
588
- visitTable(node) {
589
- this.visitNode(node.table);
590
- }
591
- visitSchemableIdentifier(node) {
592
- if (node.schema) {
593
- this.visitNode(node.schema);
594
- this.append(".");
595
- }
596
- this.visitNode(node.identifier);
597
- }
598
- visitCreateTable(node) {
599
- this.append("create ");
600
- if (node.frontModifiers?.length) {
601
- this.compileList(node.frontModifiers, " ");
602
- this.append(" ");
603
- }
604
- if (node.temporary) this.append("temporary ");
605
- this.append("table ");
606
- if (node.ifNotExists) this.append("if not exists ");
607
- this.visitNode(node.table);
608
- if (!node.selectQuery) {
609
- this.append(" (");
610
- this.compileList([...node.columns, ...node.constraints ?? []]);
611
- this.append(")");
612
- }
613
- if (node.onCommit) {
614
- this.append(" on commit ");
615
- this.append(node.onCommit);
616
- }
617
- if (node.endModifiers?.length) {
618
- this.append(" ");
619
- this.compileList(node.endModifiers, " ");
620
- }
621
- if (node.selectQuery) {
622
- this.append(" as ");
623
- this.visitNode(node.selectQuery);
624
- }
625
- }
626
- visitColumnDefinition(node) {
627
- if (node.ifNotExists) this.append("if not exists ");
628
- this.visitNode(node.column);
629
- this.append(" ");
630
- this.visitNode(node.dataType);
631
- if (node.unsigned) this.append(" unsigned");
632
- if (node.frontModifiers && node.frontModifiers.length > 0) {
633
- this.append(" ");
634
- this.compileList(node.frontModifiers, " ");
635
- }
636
- if (node.generated) {
637
- this.append(" ");
638
- this.visitNode(node.generated);
639
- }
640
- if (node.identity) this.append(" identity");
641
- if (node.defaultTo) {
642
- this.append(" ");
643
- this.visitNode(node.defaultTo);
644
- }
645
- if (node.notNull) this.append(" not null");
646
- if (node.unique) this.append(" unique");
647
- if (node.nullsNotDistinct) this.append(" nulls not distinct");
648
- if (node.primaryKey) this.append(" primary key");
649
- if (node.autoIncrement) {
650
- this.append(" ");
651
- this.append(this.getAutoIncrement());
652
- }
653
- if (node.references) {
654
- this.append(" ");
655
- this.visitNode(node.references);
656
- }
657
- if (node.check) {
658
- this.append(" ");
659
- this.visitNode(node.check);
660
- }
661
- if (node.endModifiers && node.endModifiers.length > 0) {
662
- this.append(" ");
663
- this.compileList(node.endModifiers, " ");
664
- }
665
- }
666
- getAutoIncrement() {
667
- return "auto_increment";
668
- }
669
- visitReferences(node) {
670
- this.append("references ");
671
- this.visitNode(node.table);
672
- this.append(" (");
673
- this.compileList(node.columns);
674
- this.append(")");
675
- if (node.onDelete) {
676
- this.append(" on delete ");
677
- this.append(node.onDelete);
678
- }
679
- if (node.onUpdate) {
680
- this.append(" on update ");
681
- this.append(node.onUpdate);
682
- }
683
- }
684
- visitDropTable(node) {
685
- this.append("drop table ");
686
- if (node.ifExists) this.append("if exists ");
687
- this.visitNode(node.table);
688
- if (node.cascade) this.append(" cascade");
689
- }
690
- visitDataType(node) {
691
- this.append(node.dataType);
692
- }
693
- visitOrderBy(node) {
694
- this.append("order by ");
695
- this.compileList(node.items);
696
- }
697
- visitOrderByItem(node) {
698
- this.visitNode(node.orderBy);
699
- if (node.collation) {
700
- this.append(" ");
701
- this.visitNode(node.collation);
702
- }
703
- if (node.direction) {
704
- this.append(" ");
705
- this.visitNode(node.direction);
706
- }
707
- if (node.nulls) {
708
- this.append(" nulls ");
709
- this.append(node.nulls);
710
- }
711
- }
712
- visitGroupBy(node) {
713
- this.append("group by ");
714
- this.compileList(node.items);
715
- }
716
- visitGroupByItem(node) {
717
- this.visitNode(node.groupBy);
718
- }
719
- visitUpdateQuery(node) {
720
- const wrapInParens = this.parentNode !== void 0 && !ParensNode.is(this.parentNode) && !RawNode.is(this.parentNode) && !WhenNode.is(this.parentNode);
721
- if (this.parentNode === void 0 && node.explain) {
722
- this.visitNode(node.explain);
723
- this.append(" ");
724
- }
725
- if (wrapInParens) this.append("(");
726
- if (node.with) {
727
- this.visitNode(node.with);
728
- this.append(" ");
729
- }
730
- this.append("update ");
731
- if (node.top) {
732
- this.visitNode(node.top);
733
- this.append(" ");
734
- }
735
- if (node.table) {
736
- this.visitNode(node.table);
737
- this.append(" ");
738
- }
739
- this.append("set ");
740
- if (node.updates) this.compileList(node.updates);
741
- if (node.output) {
742
- this.append(" ");
743
- this.visitNode(node.output);
744
- }
745
- if (node.from) {
746
- this.append(" ");
747
- this.visitNode(node.from);
748
- }
749
- if (node.joins) {
750
- 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");
751
- this.append(" ");
752
- this.compileList(node.joins, " ");
753
- }
754
- if (node.where) {
755
- this.append(" ");
756
- this.visitNode(node.where);
757
- }
758
- if (node.returning) {
759
- this.append(" ");
760
- this.visitNode(node.returning);
761
- }
762
- if (node.orderBy) {
763
- this.append(" ");
764
- this.visitNode(node.orderBy);
765
- }
766
- if (node.limit) {
767
- this.append(" ");
768
- this.visitNode(node.limit);
769
- }
770
- if (wrapInParens) this.append(")");
771
- if (node.endModifiers?.length) {
772
- this.append(" ");
773
- this.compileList(node.endModifiers, " ");
774
- }
775
- }
776
- visitColumnUpdate(node) {
777
- this.visitNode(node.column);
778
- this.append(" = ");
779
- this.visitNode(node.value);
780
- }
781
- visitLimit(node) {
782
- this.append("limit ");
783
- this.visitNode(node.limit);
784
- }
785
- visitOffset(node) {
786
- this.append("offset ");
787
- this.visitNode(node.offset);
788
- }
789
- visitOnConflict(node) {
790
- this.append("on conflict");
791
- if (node.columns) {
792
- this.append(" (");
793
- this.compileList(node.columns);
794
- this.append(")");
795
- } else if (node.constraint) {
796
- this.append(" on constraint ");
797
- this.visitNode(node.constraint);
798
- } else if (node.indexExpression) {
799
- this.append(" (");
800
- this.visitNode(node.indexExpression);
801
- this.append(")");
802
- }
803
- if (node.indexWhere) {
804
- this.append(" ");
805
- this.visitNode(node.indexWhere);
806
- }
807
- if (node.doNothing === true) this.append(" do nothing");
808
- else if (node.updates) {
809
- this.append(" do update set ");
810
- this.compileList(node.updates);
811
- if (node.updateWhere) {
812
- this.append(" ");
813
- this.visitNode(node.updateWhere);
814
- }
815
- }
816
- }
817
- visitOnDuplicateKey(node) {
818
- this.append("on duplicate key update ");
819
- this.compileList(node.updates);
820
- }
821
- visitCreateIndex(node) {
822
- this.append("create ");
823
- if (node.unique) this.append("unique ");
824
- this.append("index ");
825
- if (node.ifNotExists) this.append("if not exists ");
826
- this.visitNode(node.name);
827
- if (node.table) {
828
- this.append(" on ");
829
- this.visitNode(node.table);
830
- }
831
- if (node.using) {
832
- this.append(" using ");
833
- this.visitNode(node.using);
834
- }
835
- if (node.columns) {
836
- this.append(" (");
837
- this.compileList(node.columns);
838
- this.append(")");
839
- }
840
- if (node.nullsNotDistinct) this.append(" nulls not distinct");
841
- if (node.where) {
842
- this.append(" ");
843
- this.visitNode(node.where);
844
- }
845
- }
846
- visitDropIndex(node) {
847
- this.append("drop index ");
848
- if (node.ifExists) this.append("if exists ");
849
- this.visitNode(node.name);
850
- if (node.table) {
851
- this.append(" on ");
852
- this.visitNode(node.table);
853
- }
854
- if (node.cascade) this.append(" cascade");
855
- }
856
- visitCreateSchema(node) {
857
- this.append("create schema ");
858
- if (node.ifNotExists) this.append("if not exists ");
859
- this.visitNode(node.schema);
860
- }
861
- visitDropSchema(node) {
862
- this.append("drop schema ");
863
- if (node.ifExists) this.append("if exists ");
864
- this.visitNode(node.schema);
865
- if (node.cascade) this.append(" cascade");
866
- }
867
- visitPrimaryKeyConstraint(node) {
868
- if (node.name) {
869
- this.append("constraint ");
870
- this.visitNode(node.name);
871
- this.append(" ");
872
- }
873
- this.append("primary key (");
874
- this.compileList(node.columns);
875
- this.append(")");
876
- this.buildDeferrable(node);
877
- }
878
- buildDeferrable(node) {
879
- if (node.deferrable !== void 0) {
880
- if (node.deferrable) this.append(" deferrable");
881
- else this.append(" not deferrable");
882
- }
883
- if (node.initiallyDeferred !== void 0) {
884
- if (node.initiallyDeferred) this.append(" initially deferred");
885
- else this.append(" initially immediate");
886
- }
887
- }
888
- visitUniqueConstraint(node) {
889
- if (node.name) {
890
- this.append("constraint ");
891
- this.visitNode(node.name);
892
- this.append(" ");
893
- }
894
- this.append("unique");
895
- if (node.nullsNotDistinct) this.append(" nulls not distinct");
896
- this.append(" (");
897
- this.compileList(node.columns);
898
- this.append(")");
899
- this.buildDeferrable(node);
900
- }
901
- visitCheckConstraint(node) {
902
- if (node.name) {
903
- this.append("constraint ");
904
- this.visitNode(node.name);
905
- this.append(" ");
906
- }
907
- this.append("check (");
908
- this.visitNode(node.expression);
909
- this.append(")");
910
- }
911
- visitForeignKeyConstraint(node) {
912
- if (node.name) {
913
- this.append("constraint ");
914
- this.visitNode(node.name);
915
- this.append(" ");
916
- }
917
- this.append("foreign key (");
918
- this.compileList(node.columns);
919
- this.append(") ");
920
- this.visitNode(node.references);
921
- if (node.onDelete) {
922
- this.append(" on delete ");
923
- this.append(node.onDelete);
924
- }
925
- if (node.onUpdate) {
926
- this.append(" on update ");
927
- this.append(node.onUpdate);
928
- }
929
- this.buildDeferrable(node);
930
- }
931
- visitList(node) {
932
- this.compileList(node.items);
933
- }
934
- visitWith(node) {
935
- this.append("with ");
936
- if (node.recursive) this.append("recursive ");
937
- this.compileList(node.expressions);
938
- }
939
- visitCommonTableExpression(node) {
940
- this.visitNode(node.name);
941
- this.append(" as ");
942
- if (isBoolean(node.materialized)) {
943
- if (!node.materialized) this.append("not ");
944
- this.append("materialized ");
945
- }
946
- this.visitNode(node.expression);
947
- }
948
- visitCommonTableExpressionName(node) {
949
- this.visitNode(node.table);
950
- if (node.columns) {
951
- this.append("(");
952
- this.compileList(node.columns);
953
- this.append(")");
954
- }
955
- }
956
- visitAlterTable(node) {
957
- this.append("alter table ");
958
- this.visitNode(node.table);
959
- this.append(" ");
960
- if (node.renameTo) {
961
- this.append("rename to ");
962
- this.visitNode(node.renameTo);
963
- }
964
- if (node.setSchema) {
965
- this.append("set schema ");
966
- this.visitNode(node.setSchema);
967
- }
968
- if (node.addConstraint) this.visitNode(node.addConstraint);
969
- if (node.dropConstraint) this.visitNode(node.dropConstraint);
970
- if (node.renameConstraint) this.visitNode(node.renameConstraint);
971
- if (node.columnAlterations) this.compileColumnAlterations(node.columnAlterations);
972
- if (node.addIndex) this.visitNode(node.addIndex);
973
- if (node.dropIndex) this.visitNode(node.dropIndex);
974
- }
975
- visitAddColumn(node) {
976
- this.append("add column ");
977
- this.visitNode(node.column);
978
- }
979
- visitRenameColumn(node) {
980
- this.append("rename column ");
981
- this.visitNode(node.column);
982
- this.append(" to ");
983
- this.visitNode(node.renameTo);
984
- }
985
- visitDropColumn(node) {
986
- this.append("drop column ");
987
- this.visitNode(node.column);
988
- }
989
- visitAlterColumn(node) {
990
- this.append("alter column ");
991
- this.visitNode(node.column);
992
- this.append(" ");
993
- if (node.dataType) {
994
- if (this.announcesNewColumnDataType()) this.append("type ");
995
- this.visitNode(node.dataType);
996
- if (node.dataTypeExpression) {
997
- this.append("using ");
998
- this.visitNode(node.dataTypeExpression);
999
- }
1000
- }
1001
- if (node.setDefault) {
1002
- this.append("set default ");
1003
- this.visitNode(node.setDefault);
1004
- }
1005
- if (node.dropDefault) this.append("drop default");
1006
- if (node.setNotNull) this.append("set not null");
1007
- if (node.dropNotNull) this.append("drop not null");
1008
- }
1009
- visitModifyColumn(node) {
1010
- this.append("modify column ");
1011
- this.visitNode(node.column);
1012
- }
1013
- visitAddConstraint(node) {
1014
- this.append("add ");
1015
- this.visitNode(node.constraint);
1016
- }
1017
- visitDropConstraint(node) {
1018
- this.append("drop constraint ");
1019
- if (node.ifExists) this.append("if exists ");
1020
- this.visitNode(node.constraintName);
1021
- if (node.modifier === "cascade") this.append(" cascade");
1022
- else if (node.modifier === "restrict") this.append(" restrict");
1023
- }
1024
- visitRenameConstraint(node) {
1025
- this.append("rename constraint ");
1026
- this.visitNode(node.oldName);
1027
- this.append(" to ");
1028
- this.visitNode(node.newName);
1029
- }
1030
- visitSetOperation(node) {
1031
- this.append(node.operator);
1032
- this.append(" ");
1033
- if (node.all) this.append("all ");
1034
- this.visitNode(node.expression);
1035
- }
1036
- visitCreateView(node) {
1037
- this.append("create ");
1038
- if (node.orReplace) this.append("or replace ");
1039
- if (node.materialized) this.append("materialized ");
1040
- if (node.temporary) this.append("temporary ");
1041
- this.append("view ");
1042
- if (node.ifNotExists) this.append("if not exists ");
1043
- this.visitNode(node.name);
1044
- this.append(" ");
1045
- if (node.columns) {
1046
- this.append("(");
1047
- this.compileList(node.columns);
1048
- this.append(") ");
1049
- }
1050
- if (node.as) {
1051
- this.append("as ");
1052
- this.visitNode(node.as);
1053
- }
1054
- }
1055
- visitRefreshMaterializedView(node) {
1056
- this.append("refresh materialized view ");
1057
- if (node.concurrently) this.append("concurrently ");
1058
- this.visitNode(node.name);
1059
- if (node.withNoData) this.append(" with no data");
1060
- else this.append(" with data");
1061
- }
1062
- visitDropView(node) {
1063
- this.append("drop ");
1064
- if (node.materialized) this.append("materialized ");
1065
- this.append("view ");
1066
- if (node.ifExists) this.append("if exists ");
1067
- this.visitNode(node.name);
1068
- if (node.cascade) this.append(" cascade");
1069
- }
1070
- visitGenerated(node) {
1071
- this.append("generated ");
1072
- if (node.always) this.append("always ");
1073
- if (node.byDefault) this.append("by default ");
1074
- this.append("as ");
1075
- if (node.identity) this.append("identity");
1076
- if (node.expression) {
1077
- this.append("(");
1078
- this.visitNode(node.expression);
1079
- this.append(")");
1080
- }
1081
- if (node.stored) this.append(" stored");
1082
- }
1083
- visitDefaultValue(node) {
1084
- this.append("default ");
1085
- this.visitNode(node.defaultValue);
1086
- }
1087
- visitSelectModifier(node) {
1088
- if (node.rawModifier) this.visitNode(node.rawModifier);
1089
- else this.append(SELECT_MODIFIER_SQL[node.modifier]);
1090
- if (node.of) {
1091
- this.append(" of ");
1092
- this.compileList(node.of, ", ");
1093
- }
1094
- }
1095
- visitCreateType(node) {
1096
- this.append("create type ");
1097
- this.visitNode(node.name);
1098
- if (node.enum) {
1099
- this.append(" as enum ");
1100
- this.visitNode(node.enum);
1101
- }
1102
- }
1103
- visitDropType(node) {
1104
- this.append("drop type ");
1105
- if (node.ifExists) this.append("if exists ");
1106
- this.visitNode(node.name);
1107
- }
1108
- visitExplain(node) {
1109
- this.append("explain");
1110
- if (node.options || node.format) {
1111
- this.append(" ");
1112
- this.append(this.getLeftExplainOptionsWrapper());
1113
- if (node.options) {
1114
- this.visitNode(node.options);
1115
- if (node.format) this.append(this.getExplainOptionsDelimiter());
1116
- }
1117
- if (node.format) {
1118
- this.append("format");
1119
- this.append(this.getExplainOptionAssignment());
1120
- this.append(node.format);
1121
- }
1122
- this.append(this.getRightExplainOptionsWrapper());
1123
- }
1124
- }
1125
- visitDefaultInsertValue(_) {
1126
- this.append("default");
1127
- }
1128
- visitAggregateFunction(node) {
1129
- this.append(node.func);
1130
- this.append("(");
1131
- if (node.distinct) this.append("distinct ");
1132
- this.compileList(node.aggregated);
1133
- if (node.orderBy) {
1134
- this.append(" ");
1135
- this.visitNode(node.orderBy);
1136
- }
1137
- this.append(")");
1138
- if (node.withinGroup) {
1139
- this.append(" within group (");
1140
- this.visitNode(node.withinGroup);
1141
- this.append(")");
1142
- }
1143
- if (node.filter) {
1144
- this.append(" filter(");
1145
- this.visitNode(node.filter);
1146
- this.append(")");
1147
- }
1148
- if (node.over) {
1149
- this.append(" ");
1150
- this.visitNode(node.over);
1151
- }
1152
- }
1153
- visitOver(node) {
1154
- this.append("over(");
1155
- if (node.partitionBy) {
1156
- this.visitNode(node.partitionBy);
1157
- if (node.orderBy) this.append(" ");
1158
- }
1159
- if (node.orderBy) this.visitNode(node.orderBy);
1160
- this.append(")");
1161
- }
1162
- visitPartitionBy(node) {
1163
- this.append("partition by ");
1164
- this.compileList(node.items);
1165
- }
1166
- visitPartitionByItem(node) {
1167
- this.visitNode(node.partitionBy);
1168
- }
1169
- visitBinaryOperation(node) {
1170
- this.visitNode(node.leftOperand);
1171
- this.append(" ");
1172
- this.visitNode(node.operator);
1173
- this.append(" ");
1174
- this.visitNode(node.rightOperand);
1175
- }
1176
- visitUnaryOperation(node) {
1177
- this.visitNode(node.operator);
1178
- if (!this.isMinusOperator(node.operator)) this.append(" ");
1179
- this.visitNode(node.operand);
1180
- }
1181
- isMinusOperator(node) {
1182
- return OperatorNode.is(node) && node.operator === "-";
1183
- }
1184
- visitUsing(node) {
1185
- this.append("using ");
1186
- this.compileList(node.tables);
1187
- }
1188
- visitFunction(node) {
1189
- this.append(node.func);
1190
- this.append("(");
1191
- this.compileList(node.arguments);
1192
- this.append(")");
1193
- }
1194
- visitCase(node) {
1195
- this.append("case");
1196
- if (node.value) {
1197
- this.append(" ");
1198
- this.visitNode(node.value);
1199
- }
1200
- if (node.when) {
1201
- this.append(" ");
1202
- this.compileList(node.when, " ");
1203
- }
1204
- if (node.else) {
1205
- this.append(" else ");
1206
- this.visitNode(node.else);
1207
- }
1208
- this.append(" end");
1209
- if (node.isStatement) this.append(" case");
1210
- }
1211
- visitWhen(node) {
1212
- this.append("when ");
1213
- this.visitNode(node.condition);
1214
- if (node.result) {
1215
- this.append(" then ");
1216
- this.visitNode(node.result);
1217
- }
1218
- }
1219
- visitJSONReference(node) {
1220
- this.visitNode(node.reference);
1221
- this.visitNode(node.traversal);
1222
- }
1223
- visitJSONPath(node) {
1224
- if (node.inOperator) this.visitNode(node.inOperator);
1225
- this.append("'$");
1226
- for (const pathLeg of node.pathLegs) this.visitNode(pathLeg);
1227
- this.append("'");
1228
- }
1229
- visitJSONPathLeg(node) {
1230
- const isArrayLocation = node.type === "ArrayLocation";
1231
- this.append(isArrayLocation ? "[" : ".");
1232
- this.append(typeof node.value === "string" ? this.sanitizeStringLiteral(node.value) : String(node.value));
1233
- if (isArrayLocation) this.append("]");
1234
- }
1235
- visitJSONOperatorChain(node) {
1236
- for (let i = 0, len = node.values.length; i < len; i++) {
1237
- if (i === len - 1) this.visitNode(node.operator);
1238
- else this.append("->");
1239
- this.visitNode(node.values[i]);
1240
- }
1241
- }
1242
- visitMergeQuery(node) {
1243
- if (node.with) {
1244
- this.visitNode(node.with);
1245
- this.append(" ");
1246
- }
1247
- this.append("merge ");
1248
- if (node.top) {
1249
- this.visitNode(node.top);
1250
- this.append(" ");
1251
- }
1252
- this.append("into ");
1253
- this.visitNode(node.into);
1254
- if (node.using) {
1255
- this.append(" ");
1256
- this.visitNode(node.using);
1257
- }
1258
- if (node.whens) {
1259
- this.append(" ");
1260
- this.compileList(node.whens, " ");
1261
- }
1262
- if (node.returning) {
1263
- this.append(" ");
1264
- this.visitNode(node.returning);
1265
- }
1266
- if (node.output) {
1267
- this.append(" ");
1268
- this.visitNode(node.output);
1269
- }
1270
- if (node.endModifiers?.length) {
1271
- this.append(" ");
1272
- this.compileList(node.endModifiers, " ");
1273
- }
1274
- }
1275
- visitMatched(node) {
1276
- if (node.not) this.append("not ");
1277
- this.append("matched");
1278
- if (node.bySource) this.append(" by source");
1279
- }
1280
- visitAddIndex(node) {
1281
- this.append("add ");
1282
- if (node.unique) this.append("unique ");
1283
- this.append("index ");
1284
- this.visitNode(node.name);
1285
- if (node.columns) {
1286
- this.append(" (");
1287
- this.compileList(node.columns);
1288
- this.append(")");
1289
- }
1290
- if (node.using) {
1291
- this.append(" using ");
1292
- this.visitNode(node.using);
1293
- }
1294
- }
1295
- visitCast(node) {
1296
- this.append("cast(");
1297
- this.visitNode(node.expression);
1298
- this.append(" as ");
1299
- this.visitNode(node.dataType);
1300
- this.append(")");
1301
- }
1302
- visitFetch(node) {
1303
- this.append("fetch next ");
1304
- this.visitNode(node.rowCount);
1305
- this.append(` rows ${node.modifier}`);
1306
- }
1307
- visitOutput(node) {
1308
- this.append("output ");
1309
- this.compileList(node.selections);
1310
- }
1311
- visitTop(node) {
1312
- this.append(`top(${node.expression})`);
1313
- if (node.modifiers) this.append(` ${node.modifiers}`);
1314
- }
1315
- visitOrAction(node) {
1316
- this.append(node.action);
1317
- }
1318
- visitCollate(node) {
1319
- this.append("collate ");
1320
- this.visitNode(node.collation);
1321
- }
1322
- append(str) {
1323
- this.#sql += str;
1324
- }
1325
- appendValue(parameter) {
1326
- this.addParameter(parameter);
1327
- this.append(this.getCurrentParameterPlaceholder());
1328
- }
1329
- getLeftIdentifierWrapper() {
1330
- return "\"";
1331
- }
1332
- getRightIdentifierWrapper() {
1333
- return "\"";
1334
- }
1335
- getCurrentParameterPlaceholder() {
1336
- return "$" + this.numParameters;
1337
- }
1338
- getLeftExplainOptionsWrapper() {
1339
- return "(";
1340
- }
1341
- getExplainOptionAssignment() {
1342
- return " ";
1343
- }
1344
- getExplainOptionsDelimiter() {
1345
- return ", ";
1346
- }
1347
- getRightExplainOptionsWrapper() {
1348
- return ")";
1349
- }
1350
- sanitizeIdentifier(identifier) {
1351
- const leftWrap = this.getLeftIdentifierWrapper();
1352
- const rightWrap = this.getRightIdentifierWrapper();
1353
- let sanitized = "";
1354
- for (const c of identifier) {
1355
- sanitized += c;
1356
- if (c === leftWrap) sanitized += leftWrap;
1357
- else if (c === rightWrap) sanitized += rightWrap;
1358
- }
1359
- return sanitized;
1360
- }
1361
- sanitizeStringLiteral(value) {
1362
- return value.replace(LIT_WRAP_REGEX, "''");
1363
- }
1364
- addParameter(parameter) {
1365
- this.#parameters.push(parameter);
1366
- }
1367
- appendImmediateValue(value) {
1368
- if (isString(value)) this.appendStringLiteral(value);
1369
- else if (isNumber(value) || isBoolean(value) || isBigInt(value)) this.append(value.toString());
1370
- else if (isNull(value)) this.append("null");
1371
- else if (isDate(value)) this.appendImmediateValue(value.toISOString());
1372
- else throw new Error(`invalid immediate value ${value}`);
1373
- }
1374
- appendStringLiteral(value) {
1375
- this.append("'");
1376
- this.append(this.sanitizeStringLiteral(value));
1377
- this.append("'");
1378
- }
1379
- sortSelectModifiers(arr) {
1380
- arr.sort((left, right) => left.modifier && right.modifier ? SELECT_MODIFIER_PRIORITY[left.modifier] - SELECT_MODIFIER_PRIORITY[right.modifier] : 1);
1381
- return freeze(arr);
1382
- }
1383
- compileColumnAlterations(columnAlterations) {
1384
- this.compileList(columnAlterations);
1385
- }
1386
- /**
1387
- * controls whether the dialect adds a "type" keyword before a column's new data
1388
- * type in an ALTER TABLE statement.
1389
- */
1390
- announcesNewColumnDataType() {
1391
- return true;
1392
- }
1393
- };
1394
- const SELECT_MODIFIER_SQL = freeze({
1395
- ForKeyShare: "for key share",
1396
- ForNoKeyUpdate: "for no key update",
1397
- ForUpdate: "for update",
1398
- ForShare: "for share",
1399
- NoWait: "nowait",
1400
- SkipLocked: "skip locked",
1401
- Distinct: "distinct"
1402
- });
1403
- const SELECT_MODIFIER_PRIORITY = freeze({
1404
- ForKeyShare: 1,
1405
- ForNoKeyUpdate: 1,
1406
- ForUpdate: 1,
1407
- ForShare: 1,
1408
- NoWait: 2,
1409
- SkipLocked: 2,
1410
- Distinct: 0
1411
- });
1412
- const JOIN_TYPE_SQL = freeze({
1413
- InnerJoin: "inner join",
1414
- LeftJoin: "left join",
1415
- RightJoin: "right join",
1416
- FullJoin: "full join",
1417
- CrossJoin: "cross join",
1418
- LateralInnerJoin: "inner join lateral",
1419
- LateralLeftJoin: "left join lateral",
1420
- LateralCrossJoin: "cross join lateral",
1421
- OuterApply: "outer apply",
1422
- CrossApply: "cross apply",
1423
- Using: "using"
1424
- });
1425
- //#endregion
1426
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/query-compiler/compiled-query.js
1427
- const CompiledQuery = freeze({ raw(sql, parameters = []) {
1428
- return freeze({
1429
- sql,
1430
- query: RawNode.createWithSql(sql),
1431
- parameters: freeze(parameters),
1432
- queryId: createQueryId()
1433
- });
1434
- } });
1435
- //#endregion
1436
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/dialect-adapter-base.js
1437
- /**
1438
- * A basic implementation of `DialectAdapter` with sensible default values.
1439
- * Third-party dialects can extend this instead of implementing the `DialectAdapter`
1440
- * interface from scratch. That way all new settings will get default values when
1441
- * they are added and there will be less breaking changes.
1442
- */
1443
- var DialectAdapterBase = class {
1444
- get supportsCreateIfNotExists() {
1445
- return true;
1446
- }
1447
- get supportsTransactionalDdl() {
1448
- return false;
1449
- }
1450
- get supportsReturning() {
1451
- return false;
1452
- }
1453
- get supportsOutput() {
1454
- return false;
1455
- }
1456
- };
1457
- //#endregion
1458
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/migration/migrator.js
1459
- const DEFAULT_MIGRATION_TABLE = "kysely_migration";
1460
- const DEFAULT_MIGRATION_LOCK_TABLE = "kysely_migration_lock";
1461
- freeze({ __noMigrations__: true });
1462
- //#endregion
1463
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/postgres/postgres-query-compiler.js
1464
- const ID_WRAP_REGEX = /"/g;
1465
- var PostgresQueryCompiler = class extends DefaultQueryCompiler {
1466
- sanitizeIdentifier(identifier) {
1467
- return identifier.replace(ID_WRAP_REGEX, "\"\"");
1468
- }
1469
- };
1470
- //#endregion
1471
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/postgres/postgres-introspector.js
1472
- var PostgresIntrospector = class {
1473
- #db;
1474
- constructor(db) {
1475
- this.#db = db;
1476
- }
1477
- async getSchemas() {
1478
- return (await this.#db.selectFrom("pg_catalog.pg_namespace").select("nspname").$castTo().execute()).map((it) => ({ name: it.nspname }));
1479
- }
1480
- async getTables(options = { withInternalKyselyTables: false }) {
1481
- let query = this.#db.selectFrom("pg_catalog.pg_attribute as a").innerJoin("pg_catalog.pg_class as c", "a.attrelid", "c.oid").innerJoin("pg_catalog.pg_namespace as ns", "c.relnamespace", "ns.oid").innerJoin("pg_catalog.pg_type as typ", "a.atttypid", "typ.oid").innerJoin("pg_catalog.pg_namespace as dtns", "typ.typnamespace", "dtns.oid").select([
1482
- "a.attname as column",
1483
- "a.attnotnull as not_null",
1484
- "a.atthasdef as has_default",
1485
- "c.relname as table",
1486
- "c.relkind as table_type",
1487
- "ns.nspname as schema",
1488
- "typ.typname as type",
1489
- "dtns.nspname as type_schema",
1490
- sql`col_description(a.attrelid, a.attnum)`.as("column_description"),
1491
- sql`pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as("auto_incrementing")
1492
- ]).where("c.relkind", "in", [
1493
- "r",
1494
- "v",
1495
- "p"
1496
- ]).where("ns.nspname", "!~", "^pg_").where("ns.nspname", "!=", "information_schema").where("ns.nspname", "!=", "crdb_internal").where(sql`has_schema_privilege(ns.nspname, 'USAGE')`).where("a.attnum", ">=", 0).where("a.attisdropped", "!=", true).orderBy("ns.nspname").orderBy("c.relname").orderBy("a.attnum").$castTo();
1497
- if (!options.withInternalKyselyTables) query = query.where("c.relname", "!=", DEFAULT_MIGRATION_TABLE).where("c.relname", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
1498
- const rawColumns = await query.execute();
1499
- return this.#parseTableMetadata(rawColumns);
1500
- }
1501
- async getMetadata(options) {
1502
- return { tables: await this.getTables(options) };
1503
- }
1504
- #parseTableMetadata(columns) {
1505
- const tableDictionary = /* @__PURE__ */ new Map();
1506
- for (let i = 0, len = columns.length; i < len; i++) {
1507
- const column = columns[i];
1508
- const { schema, table } = column;
1509
- const tableKey = `schema:${schema};table:${table}`;
1510
- if (!tableDictionary.has(tableKey)) tableDictionary.set(tableKey, freeze({
1511
- columns: [],
1512
- isView: column.table_type === "v",
1513
- name: table,
1514
- schema
1515
- }));
1516
- tableDictionary.get(tableKey).columns.push(freeze({
1517
- comment: column.column_description ?? void 0,
1518
- dataType: column.type,
1519
- dataTypeSchema: column.type_schema,
1520
- hasDefaultValue: column.has_default,
1521
- isAutoIncrementing: column.auto_incrementing !== null,
1522
- isNullable: !column.not_null,
1523
- name: column.column
1524
- }));
1525
- }
1526
- return Array.from(tableDictionary.values());
1527
- }
1528
- };
1529
- //#endregion
1530
- //#region ../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/postgres/postgres-adapter.js
1531
- const LOCK_ID = BigInt("3853314791062309107");
1532
- var PostgresAdapter = class extends DialectAdapterBase {
1533
- get supportsTransactionalDdl() {
1534
- return true;
1535
- }
1536
- get supportsReturning() {
1537
- return true;
1538
- }
1539
- async acquireMigrationLock(db, _opt) {
1540
- await sql`select pg_advisory_xact_lock(${sql.lit(LOCK_ID)})`.execute(db);
1541
- }
1542
- async releaseMigrationLock(_db, _opt) {}
1543
- };
1544
- //#endregion
1545
- //#region ../../node_modules/.pnpm/kysely-pglite-dialect@1.2.0_@electric-sql+pglite@0.3.15_kysely@0.28.16/node_modules/kysely-pglite-dialect/dist/index.mjs
1546
- var PGliteConnection = class {
1547
- client;
1548
- constructor(client) {
1549
- this.client = client;
1550
- }
1551
- async executeQuery(compiledQuery) {
1552
- const result = await this.client.query(compiledQuery.sql, [...compiledQuery.parameters]);
1553
- if (result.affectedRows) return {
1554
- numAffectedRows: BigInt(result.affectedRows),
1555
- rows: result.rows
1556
- };
1557
- return { rows: result.rows };
1558
- }
1559
- async *streamQuery(compiledQuery, chunkSize) {
1560
- if (!Number.isInteger(chunkSize) || chunkSize <= 0) throw new Error("chunkSize must be a positive integer");
1561
- const result = await this.client.query(compiledQuery.sql, [...compiledQuery.parameters]);
1562
- for (let i = 0; i < result.rows.length; i = i + chunkSize) yield { rows: result.rows.slice(i, i + chunkSize) };
1563
- }
1564
- };
1565
- var PGliteDialect = class {
1566
- constructor(pgLite) {
1567
- this.pgLite = pgLite;
1568
- }
1569
- createAdapter() {
1570
- return new PostgresAdapter();
1571
- }
1572
- createDriver() {
1573
- return new PGliteDriver(this.pgLite);
1574
- }
1575
- createQueryCompiler() {
1576
- return new PostgresQueryCompiler();
1577
- }
1578
- createIntrospector(db) {
1579
- return new PostgresIntrospector(db);
1580
- }
1581
- };
1582
- var PGliteDriver = class {
1583
- client;
1584
- /**
1585
- * Currently used connection.
1586
- * If another acquireConnection() is called the request is queued till this connection has been released.
1587
- */
1588
- connection;
1589
- queue = [];
1590
- constructor(pgLite) {
1591
- this.client = pgLite;
1592
- }
1593
- async init() {}
1594
- async acquireConnection() {
1595
- if (this.client === void 0) throw new Error("PGLite not initialized");
1596
- if (this.connection !== void 0) return new Promise((resolve) => {
1597
- this.queue.push(resolve);
1598
- });
1599
- this.connection = new PGliteConnection(this.client);
1600
- return this.connection;
1601
- }
1602
- async releaseConnection(connection) {
1603
- if (connection !== this.connection) throw new Error("Invalid connection");
1604
- const next = this.queue.splice(0, 1)[0];
1605
- if (next === void 0) {
1606
- this.connection = void 0;
1607
- return;
1608
- }
1609
- next(this.connection);
1610
- }
1611
- async beginTransaction(conn, settings) {
1612
- if (settings.isolationLevel) await conn.executeQuery(CompiledQuery.raw(`start transaction isolation level ${settings.isolationLevel}`));
1613
- else await conn.executeQuery(CompiledQuery.raw("begin"));
1614
- }
1615
- async commitTransaction(conn) {
1616
- await conn.executeQuery(CompiledQuery.raw("commit"));
1617
- }
1618
- async rollbackTransaction(conn) {
1619
- await conn.executeQuery(CompiledQuery.raw("rollback"));
1620
- }
1621
- async destroy() {
1622
- this.client = void 0;
1623
- }
1624
- };
1625
- //#endregion
1626
- export { PGliteDialect, DEFAULT_MIGRATION_TABLE as a, DefaultQueryCompiler as c, createRawBuilder as d, DEFAULT_MIGRATION_LOCK_TABLE as i, OperationNodeVisitor as l, PostgresIntrospector as n, DialectAdapterBase as o, PostgresQueryCompiler as r, CompiledQuery as s, PostgresAdapter as t, sql as u };
1627
-
1628
- //# sourceMappingURL=dist-CUltriBW.mjs.map