@powerhousedao/clint 6.3.0-dev.8 → 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 +0,0 @@
1
- {"version":3,"file":"dist-CUltriBW.mjs","names":[],"sources":["../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/raw-builder/raw-builder.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/raw-builder/sql.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/operation-node/operation-node-visitor.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/query-compiler/default-query-compiler.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/query-compiler/compiled-query.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/dialect-adapter-base.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/migration/migrator.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/postgres/postgres-query-compiler.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/postgres/postgres-introspector.js","../../../node_modules/.pnpm/kysely@0.28.16/node_modules/kysely/dist/esm/dialect/postgres/postgres-adapter.js","../../../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"],"sourcesContent":["/// <reference types=\"./raw-builder.d.ts\" />\nimport { AliasNode } from '../operation-node/alias-node.js';\nimport { freeze } from '../util/object-utils.js';\nimport { NOOP_QUERY_EXECUTOR } from '../query-executor/noop-query-executor.js';\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nclass RawBuilderImpl {\n #props;\n constructor(props) {\n this.#props = freeze(props);\n }\n get expressionType() {\n return undefined;\n }\n get isRawBuilder() {\n return true;\n }\n as(alias) {\n return new AliasedRawBuilderImpl(this, alias);\n }\n $castTo() {\n return new RawBuilderImpl({ ...this.#props });\n }\n $notNull() {\n return new RawBuilderImpl(this.#props);\n }\n withPlugin(plugin) {\n return new RawBuilderImpl({\n ...this.#props,\n plugins: this.#props.plugins !== undefined\n ? freeze([...this.#props.plugins, plugin])\n : freeze([plugin]),\n });\n }\n toOperationNode() {\n return this.#toOperationNode(this.#getExecutor());\n }\n compile(executorProvider) {\n return this.#compile(this.#getExecutor(executorProvider));\n }\n async execute(executorProvider) {\n const executor = this.#getExecutor(executorProvider);\n return executor.executeQuery(this.#compile(executor));\n }\n #getExecutor(executorProvider) {\n const executor = executorProvider !== undefined\n ? executorProvider.getExecutor()\n : NOOP_QUERY_EXECUTOR;\n return this.#props.plugins !== undefined\n ? executor.withPlugins(this.#props.plugins)\n : executor;\n }\n #toOperationNode(executor) {\n return executor.transformQuery(this.#props.rawNode, this.#props.queryId);\n }\n #compile(executor) {\n return executor.compileQuery(this.#toOperationNode(executor), this.#props.queryId);\n }\n}\nexport function createRawBuilder(props) {\n return new RawBuilderImpl(props);\n}\nclass AliasedRawBuilderImpl {\n #rawBuilder;\n #alias;\n constructor(rawBuilder, alias) {\n this.#rawBuilder = rawBuilder;\n this.#alias = alias;\n }\n get expression() {\n return this.#rawBuilder;\n }\n get alias() {\n return this.#alias;\n }\n get rawBuilder() {\n return this.#rawBuilder;\n }\n toOperationNode() {\n return AliasNode.create(this.#rawBuilder.toOperationNode(), isOperationNodeSource(this.#alias)\n ? this.#alias.toOperationNode()\n : IdentifierNode.create(this.#alias));\n }\n}\n","/// <reference types=\"./sql.d.ts\" />\nimport { IdentifierNode } from '../operation-node/identifier-node.js';\nimport { isOperationNodeSource } from '../operation-node/operation-node-source.js';\nimport { RawNode } from '../operation-node/raw-node.js';\nimport { ValueNode } from '../operation-node/value-node.js';\nimport { parseStringReference } from '../parser/reference-parser.js';\nimport { parseTable } from '../parser/table-parser.js';\nimport { parseValueExpression } from '../parser/value-parser.js';\nimport { createQueryId } from '../util/query-id.js';\nimport { createRawBuilder } from './raw-builder.js';\nexport const sql = Object.assign((sqlFragments, ...parameters) => {\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.create(sqlFragments, parameters?.map(parseParameter) ?? []),\n });\n}, {\n ref(columnReference) {\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.createWithChild(parseStringReference(columnReference)),\n });\n },\n val(value) {\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.createWithChild(parseValueExpression(value)),\n });\n },\n value(value) {\n return this.val(value);\n },\n table(tableReference) {\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.createWithChild(parseTable(tableReference)),\n });\n },\n id(...ids) {\n const fragments = new Array(ids.length + 1).fill('.');\n fragments[0] = '';\n fragments[fragments.length - 1] = '';\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.create(fragments, ids.map(IdentifierNode.create)),\n });\n },\n lit(value) {\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.createWithChild(ValueNode.createImmediate(value)),\n });\n },\n literal(value) {\n return this.lit(value);\n },\n raw(sql) {\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.createWithSql(sql),\n });\n },\n join(array, separator = sql `, `) {\n const nodes = new Array(Math.max(2 * array.length - 1, 0));\n const sep = separator.toOperationNode();\n for (let i = 0; i < array.length; ++i) {\n nodes[2 * i] = parseParameter(array[i]);\n if (i !== array.length - 1) {\n nodes[2 * i + 1] = sep;\n }\n }\n return createRawBuilder({\n queryId: createQueryId(),\n rawNode: RawNode.createWithChildren(nodes),\n });\n },\n});\nfunction parseParameter(param) {\n if (isOperationNodeSource(param)) {\n return param.toOperationNode();\n }\n return parseValueExpression(param);\n}\n","/// <reference types=\"./operation-node-visitor.d.ts\" />\nimport { freeze } from '../util/object-utils.js';\nexport class OperationNodeVisitor {\n nodeStack = [];\n get parentNode() {\n return this.nodeStack[this.nodeStack.length - 2];\n }\n #visitors = freeze({\n AliasNode: this.visitAlias.bind(this),\n ColumnNode: this.visitColumn.bind(this),\n IdentifierNode: this.visitIdentifier.bind(this),\n SchemableIdentifierNode: this.visitSchemableIdentifier.bind(this),\n RawNode: this.visitRaw.bind(this),\n ReferenceNode: this.visitReference.bind(this),\n SelectQueryNode: this.visitSelectQuery.bind(this),\n SelectionNode: this.visitSelection.bind(this),\n TableNode: this.visitTable.bind(this),\n FromNode: this.visitFrom.bind(this),\n SelectAllNode: this.visitSelectAll.bind(this),\n AndNode: this.visitAnd.bind(this),\n OrNode: this.visitOr.bind(this),\n ValueNode: this.visitValue.bind(this),\n ValueListNode: this.visitValueList.bind(this),\n PrimitiveValueListNode: this.visitPrimitiveValueList.bind(this),\n ParensNode: this.visitParens.bind(this),\n JoinNode: this.visitJoin.bind(this),\n OperatorNode: this.visitOperator.bind(this),\n WhereNode: this.visitWhere.bind(this),\n InsertQueryNode: this.visitInsertQuery.bind(this),\n DeleteQueryNode: this.visitDeleteQuery.bind(this),\n ReturningNode: this.visitReturning.bind(this),\n CreateTableNode: this.visitCreateTable.bind(this),\n AddColumnNode: this.visitAddColumn.bind(this),\n ColumnDefinitionNode: this.visitColumnDefinition.bind(this),\n DropTableNode: this.visitDropTable.bind(this),\n DataTypeNode: this.visitDataType.bind(this),\n OrderByNode: this.visitOrderBy.bind(this),\n OrderByItemNode: this.visitOrderByItem.bind(this),\n GroupByNode: this.visitGroupBy.bind(this),\n GroupByItemNode: this.visitGroupByItem.bind(this),\n UpdateQueryNode: this.visitUpdateQuery.bind(this),\n ColumnUpdateNode: this.visitColumnUpdate.bind(this),\n LimitNode: this.visitLimit.bind(this),\n OffsetNode: this.visitOffset.bind(this),\n OnConflictNode: this.visitOnConflict.bind(this),\n OnDuplicateKeyNode: this.visitOnDuplicateKey.bind(this),\n CreateIndexNode: this.visitCreateIndex.bind(this),\n DropIndexNode: this.visitDropIndex.bind(this),\n ListNode: this.visitList.bind(this),\n PrimaryKeyConstraintNode: this.visitPrimaryKeyConstraint.bind(this),\n UniqueConstraintNode: this.visitUniqueConstraint.bind(this),\n ReferencesNode: this.visitReferences.bind(this),\n CheckConstraintNode: this.visitCheckConstraint.bind(this),\n WithNode: this.visitWith.bind(this),\n CommonTableExpressionNode: this.visitCommonTableExpression.bind(this),\n CommonTableExpressionNameNode: this.visitCommonTableExpressionName.bind(this),\n HavingNode: this.visitHaving.bind(this),\n CreateSchemaNode: this.visitCreateSchema.bind(this),\n DropSchemaNode: this.visitDropSchema.bind(this),\n AlterTableNode: this.visitAlterTable.bind(this),\n DropColumnNode: this.visitDropColumn.bind(this),\n RenameColumnNode: this.visitRenameColumn.bind(this),\n AlterColumnNode: this.visitAlterColumn.bind(this),\n ModifyColumnNode: this.visitModifyColumn.bind(this),\n AddConstraintNode: this.visitAddConstraint.bind(this),\n DropConstraintNode: this.visitDropConstraint.bind(this),\n RenameConstraintNode: this.visitRenameConstraint.bind(this),\n ForeignKeyConstraintNode: this.visitForeignKeyConstraint.bind(this),\n CreateViewNode: this.visitCreateView.bind(this),\n RefreshMaterializedViewNode: this.visitRefreshMaterializedView.bind(this),\n DropViewNode: this.visitDropView.bind(this),\n GeneratedNode: this.visitGenerated.bind(this),\n DefaultValueNode: this.visitDefaultValue.bind(this),\n OnNode: this.visitOn.bind(this),\n ValuesNode: this.visitValues.bind(this),\n SelectModifierNode: this.visitSelectModifier.bind(this),\n CreateTypeNode: this.visitCreateType.bind(this),\n DropTypeNode: this.visitDropType.bind(this),\n ExplainNode: this.visitExplain.bind(this),\n DefaultInsertValueNode: this.visitDefaultInsertValue.bind(this),\n AggregateFunctionNode: this.visitAggregateFunction.bind(this),\n OverNode: this.visitOver.bind(this),\n PartitionByNode: this.visitPartitionBy.bind(this),\n PartitionByItemNode: this.visitPartitionByItem.bind(this),\n SetOperationNode: this.visitSetOperation.bind(this),\n BinaryOperationNode: this.visitBinaryOperation.bind(this),\n UnaryOperationNode: this.visitUnaryOperation.bind(this),\n UsingNode: this.visitUsing.bind(this),\n FunctionNode: this.visitFunction.bind(this),\n CaseNode: this.visitCase.bind(this),\n WhenNode: this.visitWhen.bind(this),\n JSONReferenceNode: this.visitJSONReference.bind(this),\n JSONPathNode: this.visitJSONPath.bind(this),\n JSONPathLegNode: this.visitJSONPathLeg.bind(this),\n JSONOperatorChainNode: this.visitJSONOperatorChain.bind(this),\n TupleNode: this.visitTuple.bind(this),\n MergeQueryNode: this.visitMergeQuery.bind(this),\n MatchedNode: this.visitMatched.bind(this),\n AddIndexNode: this.visitAddIndex.bind(this),\n CastNode: this.visitCast.bind(this),\n FetchNode: this.visitFetch.bind(this),\n TopNode: this.visitTop.bind(this),\n OutputNode: this.visitOutput.bind(this),\n OrActionNode: this.visitOrAction.bind(this),\n CollateNode: this.visitCollate.bind(this),\n });\n visitNode = (node) => {\n this.nodeStack.push(node);\n this.#visitors[node.kind](node);\n this.nodeStack.pop();\n };\n}\n","/// <reference types=\"./default-query-compiler.d.ts\" />\nimport { CreateTableNode } from '../operation-node/create-table-node.js';\nimport { InsertQueryNode } from '../operation-node/insert-query-node.js';\nimport { OperationNodeVisitor } from '../operation-node/operation-node-visitor.js';\nimport { OperatorNode } from '../operation-node/operator-node.js';\nimport { ParensNode } from '../operation-node/parens-node.js';\nimport { RawNode } from '../operation-node/raw-node.js';\nimport { freeze, isString, isNumber, isBoolean, isNull, isDate, isBigInt, } from '../util/object-utils.js';\nimport { CreateViewNode } from '../operation-node/create-view-node.js';\nimport { SetOperationNode } from '../operation-node/set-operation-node.js';\nimport { WhenNode } from '../operation-node/when-node.js';\nimport { logOnce } from '../util/log-once.js';\nconst LIT_WRAP_REGEX = /'/g;\nexport class DefaultQueryCompiler extends OperationNodeVisitor {\n #sql = '';\n #parameters = [];\n get numParameters() {\n return this.#parameters.length;\n }\n compileQuery(node, queryId) {\n this.#sql = '';\n this.#parameters = [];\n this.nodeStack.splice(0, this.nodeStack.length);\n this.visitNode(node);\n return freeze({\n query: node,\n queryId,\n sql: this.getSql(),\n parameters: [...this.#parameters],\n });\n }\n getSql() {\n return this.#sql;\n }\n visitSelectQuery(node) {\n const wrapInParens = this.parentNode !== undefined &&\n !ParensNode.is(this.parentNode) &&\n !InsertQueryNode.is(this.parentNode) &&\n !CreateTableNode.is(this.parentNode) &&\n !CreateViewNode.is(this.parentNode) &&\n !SetOperationNode.is(this.parentNode);\n if (this.parentNode === undefined && node.explain) {\n this.visitNode(node.explain);\n this.append(' ');\n }\n if (wrapInParens) {\n this.append('(');\n }\n if (node.with) {\n this.visitNode(node.with);\n this.append(' ');\n }\n this.append('select');\n if (node.distinctOn) {\n this.append(' ');\n this.compileDistinctOn(node.distinctOn);\n }\n if (node.frontModifiers?.length) {\n this.append(' ');\n this.compileList(node.frontModifiers, ' ');\n }\n if (node.top) {\n this.append(' ');\n this.visitNode(node.top);\n }\n if (node.selections) {\n this.append(' ');\n this.compileList(node.selections);\n }\n if (node.from) {\n this.append(' ');\n this.visitNode(node.from);\n }\n if (node.joins) {\n this.append(' ');\n this.compileList(node.joins, ' ');\n }\n if (node.where) {\n this.append(' ');\n this.visitNode(node.where);\n }\n if (node.groupBy) {\n this.append(' ');\n this.visitNode(node.groupBy);\n }\n if (node.having) {\n this.append(' ');\n this.visitNode(node.having);\n }\n if (node.setOperations) {\n this.append(' ');\n this.compileList(node.setOperations, ' ');\n }\n if (node.orderBy) {\n this.append(' ');\n this.visitNode(node.orderBy);\n }\n if (node.limit) {\n this.append(' ');\n this.visitNode(node.limit);\n }\n if (node.offset) {\n this.append(' ');\n this.visitNode(node.offset);\n }\n if (node.fetch) {\n this.append(' ');\n this.visitNode(node.fetch);\n }\n if (node.endModifiers?.length) {\n this.append(' ');\n this.compileList(this.sortSelectModifiers([...node.endModifiers]), ' ');\n }\n if (wrapInParens) {\n this.append(')');\n }\n }\n visitFrom(node) {\n this.append('from ');\n this.compileList(node.froms);\n }\n visitSelection(node) {\n this.visitNode(node.selection);\n }\n visitColumn(node) {\n this.visitNode(node.column);\n }\n compileDistinctOn(expressions) {\n this.append('distinct on (');\n this.compileList(expressions);\n this.append(')');\n }\n compileList(nodes, separator = ', ') {\n const lastIndex = nodes.length - 1;\n for (let i = 0; i <= lastIndex; i++) {\n this.visitNode(nodes[i]);\n if (i < lastIndex) {\n this.append(separator);\n }\n }\n }\n visitWhere(node) {\n this.append('where ');\n this.visitNode(node.where);\n }\n visitHaving(node) {\n this.append('having ');\n this.visitNode(node.having);\n }\n visitInsertQuery(node) {\n const wrapInParens = this.parentNode !== undefined &&\n !ParensNode.is(this.parentNode) &&\n !RawNode.is(this.parentNode) &&\n !WhenNode.is(this.parentNode);\n if (this.parentNode === undefined && node.explain) {\n this.visitNode(node.explain);\n this.append(' ');\n }\n if (wrapInParens) {\n this.append('(');\n }\n if (node.with) {\n this.visitNode(node.with);\n this.append(' ');\n }\n this.append(node.replace ? 'replace' : 'insert');\n // TODO: remove in 0.29.\n if (node.ignore) {\n logOnce('`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead.');\n this.append(' ignore');\n }\n if (node.orAction) {\n this.append(' ');\n this.visitNode(node.orAction);\n }\n if (node.top) {\n this.append(' ');\n this.visitNode(node.top);\n }\n if (node.into) {\n this.append(' into ');\n this.visitNode(node.into);\n }\n if (node.columns) {\n this.append(' (');\n this.compileList(node.columns);\n this.append(')');\n }\n if (node.output) {\n this.append(' ');\n this.visitNode(node.output);\n }\n if (node.values) {\n this.append(' ');\n this.visitNode(node.values);\n }\n if (node.defaultValues) {\n this.append(' ');\n this.append('default values');\n }\n if (node.onConflict) {\n this.append(' ');\n this.visitNode(node.onConflict);\n }\n if (node.onDuplicateKey) {\n this.append(' ');\n this.visitNode(node.onDuplicateKey);\n }\n if (node.returning) {\n this.append(' ');\n this.visitNode(node.returning);\n }\n if (wrapInParens) {\n this.append(')');\n }\n if (node.endModifiers?.length) {\n this.append(' ');\n this.compileList(node.endModifiers, ' ');\n }\n }\n visitValues(node) {\n this.append('values ');\n this.compileList(node.values);\n }\n visitDeleteQuery(node) {\n const wrapInParens = this.parentNode !== undefined &&\n !ParensNode.is(this.parentNode) &&\n !RawNode.is(this.parentNode);\n if (this.parentNode === undefined && node.explain) {\n this.visitNode(node.explain);\n this.append(' ');\n }\n if (wrapInParens) {\n this.append('(');\n }\n if (node.with) {\n this.visitNode(node.with);\n this.append(' ');\n }\n this.append('delete ');\n if (node.top) {\n this.visitNode(node.top);\n this.append(' ');\n }\n this.visitNode(node.from);\n if (node.output) {\n this.append(' ');\n this.visitNode(node.output);\n }\n if (node.using) {\n this.append(' ');\n this.visitNode(node.using);\n }\n if (node.joins) {\n this.append(' ');\n this.compileList(node.joins, ' ');\n }\n if (node.where) {\n this.append(' ');\n this.visitNode(node.where);\n }\n if (node.orderBy) {\n this.append(' ');\n this.visitNode(node.orderBy);\n }\n if (node.limit) {\n this.append(' ');\n this.visitNode(node.limit);\n }\n if (node.returning) {\n this.append(' ');\n this.visitNode(node.returning);\n }\n if (wrapInParens) {\n this.append(')');\n }\n if (node.endModifiers?.length) {\n this.append(' ');\n this.compileList(node.endModifiers, ' ');\n }\n }\n visitReturning(node) {\n this.append('returning ');\n this.compileList(node.selections);\n }\n visitAlias(node) {\n this.visitNode(node.node);\n this.append(' as ');\n this.visitNode(node.alias);\n }\n visitReference(node) {\n if (node.table) {\n this.visitNode(node.table);\n this.append('.');\n }\n this.visitNode(node.column);\n }\n visitSelectAll(_) {\n this.append('*');\n }\n visitIdentifier(node) {\n this.append(this.getLeftIdentifierWrapper());\n this.compileUnwrappedIdentifier(node);\n this.append(this.getRightIdentifierWrapper());\n }\n compileUnwrappedIdentifier(node) {\n if (!isString(node.name)) {\n throw new Error('a non-string identifier was passed to compileUnwrappedIdentifier.');\n }\n this.append(this.sanitizeIdentifier(node.name));\n }\n visitAnd(node) {\n this.visitNode(node.left);\n this.append(' and ');\n this.visitNode(node.right);\n }\n visitOr(node) {\n this.visitNode(node.left);\n this.append(' or ');\n this.visitNode(node.right);\n }\n visitValue(node) {\n if (node.immediate) {\n this.appendImmediateValue(node.value);\n }\n else {\n this.appendValue(node.value);\n }\n }\n visitValueList(node) {\n this.append('(');\n this.compileList(node.values);\n this.append(')');\n }\n visitTuple(node) {\n this.append('(');\n this.compileList(node.values);\n this.append(')');\n }\n visitPrimitiveValueList(node) {\n this.append('(');\n const { values } = node;\n for (let i = 0; i < values.length; ++i) {\n this.appendValue(values[i]);\n if (i !== values.length - 1) {\n this.append(', ');\n }\n }\n this.append(')');\n }\n visitParens(node) {\n this.append('(');\n this.visitNode(node.node);\n this.append(')');\n }\n visitJoin(node) {\n this.append(JOIN_TYPE_SQL[node.joinType]);\n this.append(' ');\n this.visitNode(node.table);\n if (node.on) {\n this.append(' ');\n this.visitNode(node.on);\n }\n }\n visitOn(node) {\n this.append('on ');\n this.visitNode(node.on);\n }\n visitRaw(node) {\n const { sqlFragments, parameters: params } = node;\n for (let i = 0; i < sqlFragments.length; ++i) {\n this.append(sqlFragments[i]);\n if (params.length > i) {\n this.visitNode(params[i]);\n }\n }\n }\n visitOperator(node) {\n this.append(node.operator);\n }\n visitTable(node) {\n this.visitNode(node.table);\n }\n visitSchemableIdentifier(node) {\n if (node.schema) {\n this.visitNode(node.schema);\n this.append('.');\n }\n this.visitNode(node.identifier);\n }\n visitCreateTable(node) {\n this.append('create ');\n if (node.frontModifiers?.length) {\n this.compileList(node.frontModifiers, ' ');\n this.append(' ');\n }\n if (node.temporary) {\n this.append('temporary ');\n }\n this.append('table ');\n if (node.ifNotExists) {\n this.append('if not exists ');\n }\n this.visitNode(node.table);\n if (!node.selectQuery) {\n this.append(' (');\n this.compileList([...node.columns, ...(node.constraints ?? [])]);\n this.append(')');\n }\n if (node.onCommit) {\n this.append(' on commit ');\n this.append(node.onCommit);\n }\n if (node.endModifiers?.length) {\n this.append(' ');\n this.compileList(node.endModifiers, ' ');\n }\n if (node.selectQuery) {\n this.append(' as ');\n this.visitNode(node.selectQuery);\n }\n }\n visitColumnDefinition(node) {\n if (node.ifNotExists) {\n this.append('if not exists ');\n }\n this.visitNode(node.column);\n this.append(' ');\n this.visitNode(node.dataType);\n if (node.unsigned) {\n this.append(' unsigned');\n }\n if (node.frontModifiers && node.frontModifiers.length > 0) {\n this.append(' ');\n this.compileList(node.frontModifiers, ' ');\n }\n if (node.generated) {\n this.append(' ');\n this.visitNode(node.generated);\n }\n if (node.identity) {\n this.append(' identity');\n }\n if (node.defaultTo) {\n this.append(' ');\n this.visitNode(node.defaultTo);\n }\n if (node.notNull) {\n this.append(' not null');\n }\n if (node.unique) {\n this.append(' unique');\n }\n if (node.nullsNotDistinct) {\n this.append(' nulls not distinct');\n }\n if (node.primaryKey) {\n this.append(' primary key');\n }\n if (node.autoIncrement) {\n this.append(' ');\n this.append(this.getAutoIncrement());\n }\n if (node.references) {\n this.append(' ');\n this.visitNode(node.references);\n }\n if (node.check) {\n this.append(' ');\n this.visitNode(node.check);\n }\n if (node.endModifiers && node.endModifiers.length > 0) {\n this.append(' ');\n this.compileList(node.endModifiers, ' ');\n }\n }\n getAutoIncrement() {\n return 'auto_increment';\n }\n visitReferences(node) {\n this.append('references ');\n this.visitNode(node.table);\n this.append(' (');\n this.compileList(node.columns);\n this.append(')');\n if (node.onDelete) {\n this.append(' on delete ');\n this.append(node.onDelete);\n }\n if (node.onUpdate) {\n this.append(' on update ');\n this.append(node.onUpdate);\n }\n }\n visitDropTable(node) {\n this.append('drop table ');\n if (node.ifExists) {\n this.append('if exists ');\n }\n this.visitNode(node.table);\n if (node.cascade) {\n this.append(' cascade');\n }\n }\n visitDataType(node) {\n this.append(node.dataType);\n }\n visitOrderBy(node) {\n this.append('order by ');\n this.compileList(node.items);\n }\n visitOrderByItem(node) {\n this.visitNode(node.orderBy);\n if (node.collation) {\n this.append(' ');\n this.visitNode(node.collation);\n }\n if (node.direction) {\n this.append(' ');\n this.visitNode(node.direction);\n }\n if (node.nulls) {\n this.append(' nulls ');\n this.append(node.nulls);\n }\n }\n visitGroupBy(node) {\n this.append('group by ');\n this.compileList(node.items);\n }\n visitGroupByItem(node) {\n this.visitNode(node.groupBy);\n }\n visitUpdateQuery(node) {\n const wrapInParens = this.parentNode !== undefined &&\n !ParensNode.is(this.parentNode) &&\n !RawNode.is(this.parentNode) &&\n !WhenNode.is(this.parentNode);\n if (this.parentNode === undefined && node.explain) {\n this.visitNode(node.explain);\n this.append(' ');\n }\n if (wrapInParens) {\n this.append('(');\n }\n if (node.with) {\n this.visitNode(node.with);\n this.append(' ');\n }\n this.append('update ');\n if (node.top) {\n this.visitNode(node.top);\n this.append(' ');\n }\n if (node.table) {\n this.visitNode(node.table);\n this.append(' ');\n }\n this.append('set ');\n if (node.updates) {\n this.compileList(node.updates);\n }\n if (node.output) {\n this.append(' ');\n this.visitNode(node.output);\n }\n if (node.from) {\n this.append(' ');\n this.visitNode(node.from);\n }\n if (node.joins) {\n if (!node.from) {\n 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\");\n }\n this.append(' ');\n this.compileList(node.joins, ' ');\n }\n if (node.where) {\n this.append(' ');\n this.visitNode(node.where);\n }\n if (node.returning) {\n this.append(' ');\n this.visitNode(node.returning);\n }\n if (node.orderBy) {\n this.append(' ');\n this.visitNode(node.orderBy);\n }\n if (node.limit) {\n this.append(' ');\n this.visitNode(node.limit);\n }\n if (wrapInParens) {\n this.append(')');\n }\n if (node.endModifiers?.length) {\n this.append(' ');\n this.compileList(node.endModifiers, ' ');\n }\n }\n visitColumnUpdate(node) {\n this.visitNode(node.column);\n this.append(' = ');\n this.visitNode(node.value);\n }\n visitLimit(node) {\n this.append('limit ');\n this.visitNode(node.limit);\n }\n visitOffset(node) {\n this.append('offset ');\n this.visitNode(node.offset);\n }\n visitOnConflict(node) {\n this.append('on conflict');\n if (node.columns) {\n this.append(' (');\n this.compileList(node.columns);\n this.append(')');\n }\n else if (node.constraint) {\n this.append(' on constraint ');\n this.visitNode(node.constraint);\n }\n else if (node.indexExpression) {\n this.append(' (');\n this.visitNode(node.indexExpression);\n this.append(')');\n }\n if (node.indexWhere) {\n this.append(' ');\n this.visitNode(node.indexWhere);\n }\n if (node.doNothing === true) {\n this.append(' do nothing');\n }\n else if (node.updates) {\n this.append(' do update set ');\n this.compileList(node.updates);\n if (node.updateWhere) {\n this.append(' ');\n this.visitNode(node.updateWhere);\n }\n }\n }\n visitOnDuplicateKey(node) {\n this.append('on duplicate key update ');\n this.compileList(node.updates);\n }\n visitCreateIndex(node) {\n this.append('create ');\n if (node.unique) {\n this.append('unique ');\n }\n this.append('index ');\n if (node.ifNotExists) {\n this.append('if not exists ');\n }\n this.visitNode(node.name);\n if (node.table) {\n this.append(' on ');\n this.visitNode(node.table);\n }\n if (node.using) {\n this.append(' using ');\n this.visitNode(node.using);\n }\n if (node.columns) {\n this.append(' (');\n this.compileList(node.columns);\n this.append(')');\n }\n if (node.nullsNotDistinct) {\n this.append(' nulls not distinct');\n }\n if (node.where) {\n this.append(' ');\n this.visitNode(node.where);\n }\n }\n visitDropIndex(node) {\n this.append('drop index ');\n if (node.ifExists) {\n this.append('if exists ');\n }\n this.visitNode(node.name);\n if (node.table) {\n this.append(' on ');\n this.visitNode(node.table);\n }\n if (node.cascade) {\n this.append(' cascade');\n }\n }\n visitCreateSchema(node) {\n this.append('create schema ');\n if (node.ifNotExists) {\n this.append('if not exists ');\n }\n this.visitNode(node.schema);\n }\n visitDropSchema(node) {\n this.append('drop schema ');\n if (node.ifExists) {\n this.append('if exists ');\n }\n this.visitNode(node.schema);\n if (node.cascade) {\n this.append(' cascade');\n }\n }\n visitPrimaryKeyConstraint(node) {\n if (node.name) {\n this.append('constraint ');\n this.visitNode(node.name);\n this.append(' ');\n }\n this.append('primary key (');\n this.compileList(node.columns);\n this.append(')');\n this.buildDeferrable(node);\n }\n buildDeferrable(node) {\n if (node.deferrable !== undefined) {\n if (node.deferrable) {\n this.append(' deferrable');\n }\n else {\n this.append(' not deferrable');\n }\n }\n if (node.initiallyDeferred !== undefined) {\n if (node.initiallyDeferred) {\n this.append(' initially deferred');\n }\n else {\n this.append(' initially immediate');\n }\n }\n }\n visitUniqueConstraint(node) {\n if (node.name) {\n this.append('constraint ');\n this.visitNode(node.name);\n this.append(' ');\n }\n this.append('unique');\n if (node.nullsNotDistinct) {\n this.append(' nulls not distinct');\n }\n this.append(' (');\n this.compileList(node.columns);\n this.append(')');\n this.buildDeferrable(node);\n }\n visitCheckConstraint(node) {\n if (node.name) {\n this.append('constraint ');\n this.visitNode(node.name);\n this.append(' ');\n }\n this.append('check (');\n this.visitNode(node.expression);\n this.append(')');\n }\n visitForeignKeyConstraint(node) {\n if (node.name) {\n this.append('constraint ');\n this.visitNode(node.name);\n this.append(' ');\n }\n this.append('foreign key (');\n this.compileList(node.columns);\n this.append(') ');\n this.visitNode(node.references);\n if (node.onDelete) {\n this.append(' on delete ');\n this.append(node.onDelete);\n }\n if (node.onUpdate) {\n this.append(' on update ');\n this.append(node.onUpdate);\n }\n this.buildDeferrable(node);\n }\n visitList(node) {\n this.compileList(node.items);\n }\n visitWith(node) {\n this.append('with ');\n if (node.recursive) {\n this.append('recursive ');\n }\n this.compileList(node.expressions);\n }\n visitCommonTableExpression(node) {\n this.visitNode(node.name);\n this.append(' as ');\n if (isBoolean(node.materialized)) {\n if (!node.materialized) {\n this.append('not ');\n }\n this.append('materialized ');\n }\n this.visitNode(node.expression);\n }\n visitCommonTableExpressionName(node) {\n this.visitNode(node.table);\n if (node.columns) {\n this.append('(');\n this.compileList(node.columns);\n this.append(')');\n }\n }\n visitAlterTable(node) {\n this.append('alter table ');\n this.visitNode(node.table);\n this.append(' ');\n if (node.renameTo) {\n this.append('rename to ');\n this.visitNode(node.renameTo);\n }\n if (node.setSchema) {\n this.append('set schema ');\n this.visitNode(node.setSchema);\n }\n if (node.addConstraint) {\n this.visitNode(node.addConstraint);\n }\n if (node.dropConstraint) {\n this.visitNode(node.dropConstraint);\n }\n if (node.renameConstraint) {\n this.visitNode(node.renameConstraint);\n }\n if (node.columnAlterations) {\n this.compileColumnAlterations(node.columnAlterations);\n }\n if (node.addIndex) {\n this.visitNode(node.addIndex);\n }\n if (node.dropIndex) {\n this.visitNode(node.dropIndex);\n }\n }\n visitAddColumn(node) {\n this.append('add column ');\n this.visitNode(node.column);\n }\n visitRenameColumn(node) {\n this.append('rename column ');\n this.visitNode(node.column);\n this.append(' to ');\n this.visitNode(node.renameTo);\n }\n visitDropColumn(node) {\n this.append('drop column ');\n this.visitNode(node.column);\n }\n visitAlterColumn(node) {\n this.append('alter column ');\n this.visitNode(node.column);\n this.append(' ');\n if (node.dataType) {\n if (this.announcesNewColumnDataType()) {\n this.append('type ');\n }\n this.visitNode(node.dataType);\n if (node.dataTypeExpression) {\n this.append('using ');\n this.visitNode(node.dataTypeExpression);\n }\n }\n if (node.setDefault) {\n this.append('set default ');\n this.visitNode(node.setDefault);\n }\n if (node.dropDefault) {\n this.append('drop default');\n }\n if (node.setNotNull) {\n this.append('set not null');\n }\n if (node.dropNotNull) {\n this.append('drop not null');\n }\n }\n visitModifyColumn(node) {\n this.append('modify column ');\n this.visitNode(node.column);\n }\n visitAddConstraint(node) {\n this.append('add ');\n this.visitNode(node.constraint);\n }\n visitDropConstraint(node) {\n this.append('drop constraint ');\n if (node.ifExists) {\n this.append('if exists ');\n }\n this.visitNode(node.constraintName);\n if (node.modifier === 'cascade') {\n this.append(' cascade');\n }\n else if (node.modifier === 'restrict') {\n this.append(' restrict');\n }\n }\n visitRenameConstraint(node) {\n this.append('rename constraint ');\n this.visitNode(node.oldName);\n this.append(' to ');\n this.visitNode(node.newName);\n }\n visitSetOperation(node) {\n this.append(node.operator);\n this.append(' ');\n if (node.all) {\n this.append('all ');\n }\n this.visitNode(node.expression);\n }\n visitCreateView(node) {\n this.append('create ');\n if (node.orReplace) {\n this.append('or replace ');\n }\n if (node.materialized) {\n this.append('materialized ');\n }\n if (node.temporary) {\n this.append('temporary ');\n }\n this.append('view ');\n if (node.ifNotExists) {\n this.append('if not exists ');\n }\n this.visitNode(node.name);\n this.append(' ');\n if (node.columns) {\n this.append('(');\n this.compileList(node.columns);\n this.append(') ');\n }\n if (node.as) {\n this.append('as ');\n this.visitNode(node.as);\n }\n }\n visitRefreshMaterializedView(node) {\n this.append('refresh materialized view ');\n if (node.concurrently) {\n this.append('concurrently ');\n }\n this.visitNode(node.name);\n if (node.withNoData) {\n this.append(' with no data');\n }\n else {\n this.append(' with data');\n }\n }\n visitDropView(node) {\n this.append('drop ');\n if (node.materialized) {\n this.append('materialized ');\n }\n this.append('view ');\n if (node.ifExists) {\n this.append('if exists ');\n }\n this.visitNode(node.name);\n if (node.cascade) {\n this.append(' cascade');\n }\n }\n visitGenerated(node) {\n this.append('generated ');\n if (node.always) {\n this.append('always ');\n }\n if (node.byDefault) {\n this.append('by default ');\n }\n this.append('as ');\n if (node.identity) {\n this.append('identity');\n }\n if (node.expression) {\n this.append('(');\n this.visitNode(node.expression);\n this.append(')');\n }\n if (node.stored) {\n this.append(' stored');\n }\n }\n visitDefaultValue(node) {\n this.append('default ');\n this.visitNode(node.defaultValue);\n }\n visitSelectModifier(node) {\n if (node.rawModifier) {\n this.visitNode(node.rawModifier);\n }\n else {\n this.append(SELECT_MODIFIER_SQL[node.modifier]);\n }\n if (node.of) {\n this.append(' of ');\n this.compileList(node.of, ', ');\n }\n }\n visitCreateType(node) {\n this.append('create type ');\n this.visitNode(node.name);\n if (node.enum) {\n this.append(' as enum ');\n this.visitNode(node.enum);\n }\n }\n visitDropType(node) {\n this.append('drop type ');\n if (node.ifExists) {\n this.append('if exists ');\n }\n this.visitNode(node.name);\n }\n visitExplain(node) {\n this.append('explain');\n if (node.options || node.format) {\n this.append(' ');\n this.append(this.getLeftExplainOptionsWrapper());\n if (node.options) {\n this.visitNode(node.options);\n if (node.format) {\n this.append(this.getExplainOptionsDelimiter());\n }\n }\n if (node.format) {\n this.append('format');\n this.append(this.getExplainOptionAssignment());\n this.append(node.format);\n }\n this.append(this.getRightExplainOptionsWrapper());\n }\n }\n visitDefaultInsertValue(_) {\n this.append('default');\n }\n visitAggregateFunction(node) {\n this.append(node.func);\n this.append('(');\n if (node.distinct) {\n this.append('distinct ');\n }\n this.compileList(node.aggregated);\n if (node.orderBy) {\n this.append(' ');\n this.visitNode(node.orderBy);\n }\n this.append(')');\n if (node.withinGroup) {\n this.append(' within group (');\n this.visitNode(node.withinGroup);\n this.append(')');\n }\n if (node.filter) {\n this.append(' filter(');\n this.visitNode(node.filter);\n this.append(')');\n }\n if (node.over) {\n this.append(' ');\n this.visitNode(node.over);\n }\n }\n visitOver(node) {\n this.append('over(');\n if (node.partitionBy) {\n this.visitNode(node.partitionBy);\n if (node.orderBy) {\n this.append(' ');\n }\n }\n if (node.orderBy) {\n this.visitNode(node.orderBy);\n }\n this.append(')');\n }\n visitPartitionBy(node) {\n this.append('partition by ');\n this.compileList(node.items);\n }\n visitPartitionByItem(node) {\n this.visitNode(node.partitionBy);\n }\n visitBinaryOperation(node) {\n this.visitNode(node.leftOperand);\n this.append(' ');\n this.visitNode(node.operator);\n this.append(' ');\n this.visitNode(node.rightOperand);\n }\n visitUnaryOperation(node) {\n this.visitNode(node.operator);\n if (!this.isMinusOperator(node.operator)) {\n this.append(' ');\n }\n this.visitNode(node.operand);\n }\n isMinusOperator(node) {\n return OperatorNode.is(node) && node.operator === '-';\n }\n visitUsing(node) {\n this.append('using ');\n this.compileList(node.tables);\n }\n visitFunction(node) {\n this.append(node.func);\n this.append('(');\n this.compileList(node.arguments);\n this.append(')');\n }\n visitCase(node) {\n this.append('case');\n if (node.value) {\n this.append(' ');\n this.visitNode(node.value);\n }\n if (node.when) {\n this.append(' ');\n this.compileList(node.when, ' ');\n }\n if (node.else) {\n this.append(' else ');\n this.visitNode(node.else);\n }\n this.append(' end');\n if (node.isStatement) {\n this.append(' case');\n }\n }\n visitWhen(node) {\n this.append('when ');\n this.visitNode(node.condition);\n if (node.result) {\n this.append(' then ');\n this.visitNode(node.result);\n }\n }\n visitJSONReference(node) {\n this.visitNode(node.reference);\n this.visitNode(node.traversal);\n }\n visitJSONPath(node) {\n if (node.inOperator) {\n this.visitNode(node.inOperator);\n }\n this.append(\"'$\");\n for (const pathLeg of node.pathLegs) {\n this.visitNode(pathLeg);\n }\n this.append(\"'\");\n }\n visitJSONPathLeg(node) {\n const isArrayLocation = node.type === 'ArrayLocation';\n this.append(isArrayLocation ? '[' : '.');\n this.append(typeof node.value === 'string'\n ? this.sanitizeStringLiteral(node.value)\n : String(node.value));\n if (isArrayLocation) {\n this.append(']');\n }\n }\n visitJSONOperatorChain(node) {\n for (let i = 0, len = node.values.length; i < len; i++) {\n if (i === len - 1) {\n this.visitNode(node.operator);\n }\n else {\n this.append('->');\n }\n this.visitNode(node.values[i]);\n }\n }\n visitMergeQuery(node) {\n if (node.with) {\n this.visitNode(node.with);\n this.append(' ');\n }\n this.append('merge ');\n if (node.top) {\n this.visitNode(node.top);\n this.append(' ');\n }\n this.append('into ');\n this.visitNode(node.into);\n if (node.using) {\n this.append(' ');\n this.visitNode(node.using);\n }\n if (node.whens) {\n this.append(' ');\n this.compileList(node.whens, ' ');\n }\n if (node.returning) {\n this.append(' ');\n this.visitNode(node.returning);\n }\n if (node.output) {\n this.append(' ');\n this.visitNode(node.output);\n }\n if (node.endModifiers?.length) {\n this.append(' ');\n this.compileList(node.endModifiers, ' ');\n }\n }\n visitMatched(node) {\n if (node.not) {\n this.append('not ');\n }\n this.append('matched');\n if (node.bySource) {\n this.append(' by source');\n }\n }\n visitAddIndex(node) {\n this.append('add ');\n if (node.unique) {\n this.append('unique ');\n }\n this.append('index ');\n this.visitNode(node.name);\n if (node.columns) {\n this.append(' (');\n this.compileList(node.columns);\n this.append(')');\n }\n if (node.using) {\n this.append(' using ');\n this.visitNode(node.using);\n }\n }\n visitCast(node) {\n this.append('cast(');\n this.visitNode(node.expression);\n this.append(' as ');\n this.visitNode(node.dataType);\n this.append(')');\n }\n visitFetch(node) {\n this.append('fetch next ');\n this.visitNode(node.rowCount);\n this.append(` rows ${node.modifier}`);\n }\n visitOutput(node) {\n this.append('output ');\n this.compileList(node.selections);\n }\n visitTop(node) {\n this.append(`top(${node.expression})`);\n if (node.modifiers) {\n this.append(` ${node.modifiers}`);\n }\n }\n visitOrAction(node) {\n this.append(node.action);\n }\n visitCollate(node) {\n this.append('collate ');\n this.visitNode(node.collation);\n }\n append(str) {\n this.#sql += str;\n }\n appendValue(parameter) {\n this.addParameter(parameter);\n this.append(this.getCurrentParameterPlaceholder());\n }\n getLeftIdentifierWrapper() {\n return '\"';\n }\n getRightIdentifierWrapper() {\n return '\"';\n }\n getCurrentParameterPlaceholder() {\n return '$' + this.numParameters;\n }\n getLeftExplainOptionsWrapper() {\n return '(';\n }\n getExplainOptionAssignment() {\n return ' ';\n }\n getExplainOptionsDelimiter() {\n return ', ';\n }\n getRightExplainOptionsWrapper() {\n return ')';\n }\n sanitizeIdentifier(identifier) {\n const leftWrap = this.getLeftIdentifierWrapper();\n const rightWrap = this.getRightIdentifierWrapper();\n let sanitized = '';\n for (const c of identifier) {\n sanitized += c;\n if (c === leftWrap) {\n sanitized += leftWrap;\n }\n else if (c === rightWrap) {\n sanitized += rightWrap;\n }\n }\n return sanitized;\n }\n sanitizeStringLiteral(value) {\n return value.replace(LIT_WRAP_REGEX, \"''\");\n }\n addParameter(parameter) {\n this.#parameters.push(parameter);\n }\n appendImmediateValue(value) {\n if (isString(value)) {\n this.appendStringLiteral(value);\n }\n else if (isNumber(value) || isBoolean(value) || isBigInt(value)) {\n this.append(value.toString());\n }\n else if (isNull(value)) {\n this.append('null');\n }\n else if (isDate(value)) {\n this.appendImmediateValue(value.toISOString());\n }\n else {\n throw new Error(`invalid immediate value ${value}`);\n }\n }\n appendStringLiteral(value) {\n this.append(\"'\");\n this.append(this.sanitizeStringLiteral(value));\n this.append(\"'\");\n }\n sortSelectModifiers(arr) {\n arr.sort((left, right) => left.modifier && right.modifier\n ? SELECT_MODIFIER_PRIORITY[left.modifier] -\n SELECT_MODIFIER_PRIORITY[right.modifier]\n : 1);\n return freeze(arr);\n }\n compileColumnAlterations(columnAlterations) {\n this.compileList(columnAlterations);\n }\n /**\n * controls whether the dialect adds a \"type\" keyword before a column's new data\n * type in an ALTER TABLE statement.\n */\n announcesNewColumnDataType() {\n return true;\n }\n}\nconst SELECT_MODIFIER_SQL = freeze({\n ForKeyShare: 'for key share',\n ForNoKeyUpdate: 'for no key update',\n ForUpdate: 'for update',\n ForShare: 'for share',\n NoWait: 'nowait',\n SkipLocked: 'skip locked',\n Distinct: 'distinct',\n});\nconst SELECT_MODIFIER_PRIORITY = freeze({\n ForKeyShare: 1,\n ForNoKeyUpdate: 1,\n ForUpdate: 1,\n ForShare: 1,\n NoWait: 2,\n SkipLocked: 2,\n Distinct: 0,\n});\nconst JOIN_TYPE_SQL = freeze({\n InnerJoin: 'inner join',\n LeftJoin: 'left join',\n RightJoin: 'right join',\n FullJoin: 'full join',\n CrossJoin: 'cross join',\n LateralInnerJoin: 'inner join lateral',\n LateralLeftJoin: 'left join lateral',\n LateralCrossJoin: 'cross join lateral',\n OuterApply: 'outer apply',\n CrossApply: 'cross apply',\n Using: 'using',\n});\n","/// <reference types=\"./compiled-query.d.ts\" />\nimport { RawNode } from '../operation-node/raw-node.js';\nimport { freeze } from '../util/object-utils.js';\nimport { createQueryId } from '../util/query-id.js';\nexport const CompiledQuery = freeze({\n raw(sql, parameters = []) {\n return freeze({\n sql,\n query: RawNode.createWithSql(sql),\n parameters: freeze(parameters),\n queryId: createQueryId(),\n });\n },\n});\n","/// <reference types=\"./dialect-adapter-base.d.ts\" />\n/**\n * A basic implementation of `DialectAdapter` with sensible default values.\n * Third-party dialects can extend this instead of implementing the `DialectAdapter`\n * interface from scratch. That way all new settings will get default values when\n * they are added and there will be less breaking changes.\n */\nexport class DialectAdapterBase {\n get supportsCreateIfNotExists() {\n return true;\n }\n get supportsTransactionalDdl() {\n return false;\n }\n get supportsReturning() {\n return false;\n }\n get supportsOutput() {\n return false;\n }\n}\n","/// <reference types=\"./migrator.d.ts\" />\nimport { NoopPlugin } from '../plugin/noop-plugin.js';\nimport { WithSchemaPlugin } from '../plugin/with-schema/with-schema-plugin.js';\nimport { freeze, getLast, isObject } from '../util/object-utils.js';\nexport const DEFAULT_MIGRATION_TABLE = 'kysely_migration';\nexport const DEFAULT_MIGRATION_LOCK_TABLE = 'kysely_migration_lock';\nexport const DEFAULT_ALLOW_UNORDERED_MIGRATIONS = false;\nexport const MIGRATION_LOCK_ID = 'migration_lock';\nexport const NO_MIGRATIONS = freeze({ __noMigrations__: true });\n/**\n * A class for running migrations.\n *\n * ### Example\n *\n * This example uses the {@link FileMigrationProvider} that reads migrations\n * files from a single folder. You can easily implement your own\n * {@link MigrationProvider} if you want to provide migrations some\n * other way.\n *\n * ```ts\n * import { promises as fs } from 'node:fs'\n * import path from 'node:path'\n * import * as Sqlite from 'better-sqlite3'\n * import {\n * FileMigrationProvider,\n * Kysely,\n * Migrator,\n * SqliteDialect\n * } from 'kysely'\n *\n * const db = new Kysely<any>({\n * dialect: new SqliteDialect({\n * database: Sqlite(':memory:')\n * })\n * })\n *\n * const migrator = new Migrator({\n * db,\n * provider: new FileMigrationProvider({\n * fs,\n * // Path to the folder that contains all your migrations.\n * migrationFolder: 'some/path/to/migrations',\n * path,\n * })\n * })\n * ```\n */\nexport class Migrator {\n #props;\n constructor(props) {\n this.#props = freeze(props);\n }\n /**\n * Returns a {@link MigrationInfo} object for each migration.\n *\n * The returned array is sorted by migration name.\n */\n async getMigrations() {\n const tableExists = await this.#doesTableExist(this.#migrationTable);\n const executedMigrations = tableExists\n ? await this.#props.db\n .withPlugin(this.#schemaPlugin)\n .selectFrom(this.#migrationTable)\n .select(['name', 'timestamp'])\n .$narrowType()\n .execute()\n : [];\n const migrations = await this.#resolveMigrations();\n return migrations.map(({ name, ...migration }) => {\n const executed = executedMigrations.find((it) => it.name === name);\n return {\n name,\n migration,\n executedAt: executed ? new Date(executed.timestamp) : undefined,\n };\n });\n }\n /**\n * Runs all migrations that have not yet been run.\n *\n * This method returns a {@link MigrationResultSet} instance and _never_ throws.\n * {@link MigrationResultSet.error} holds the error if something went wrong.\n * {@link MigrationResultSet.results} contains information about which migrations\n * were executed and which failed. See the examples below.\n *\n * This method goes through all possible migrations provided by the provider and runs the\n * ones whose names come alphabetically after the last migration that has been run. If the\n * list of executed migrations doesn't match the beginning of the list of possible migrations\n * an error is returned.\n *\n * ### Examples\n *\n * ```ts\n * import { promises as fs } from 'node:fs'\n * import path from 'node:path'\n * import * as Sqlite from 'better-sqlite3'\n * import { FileMigrationProvider, Migrator } from 'kysely'\n *\n * const migrator = new Migrator({\n * db,\n * provider: new FileMigrationProvider({\n * fs,\n * migrationFolder: 'some/path/to/migrations',\n * path,\n * })\n * })\n *\n * const { error, results } = await migrator.migrateToLatest()\n *\n * results?.forEach((it) => {\n * if (it.status === 'Success') {\n * console.log(`migration \"${it.migrationName}\" was executed successfully`)\n * } else if (it.status === 'Error') {\n * console.error(`failed to execute migration \"${it.migrationName}\"`)\n * }\n * })\n *\n * if (error) {\n * console.error('failed to run `migrateToLatest`')\n * console.error(error)\n * }\n * ```\n */\n async migrateToLatest() {\n return this.#migrate(() => ({ direction: 'Up', step: Infinity }));\n }\n /**\n * Migrate up/down to a specific migration.\n *\n * This method returns a {@link MigrationResultSet} instance and _never_ throws.\n * {@link MigrationResultSet.error} holds the error if something went wrong.\n * {@link MigrationResultSet.results} contains information about which migrations\n * were executed and which failed.\n *\n * ### Examples\n *\n * ```ts\n * import { promises as fs } from 'node:fs'\n * import path from 'node:path'\n * import { FileMigrationProvider, Migrator } from 'kysely'\n *\n * const migrator = new Migrator({\n * db,\n * provider: new FileMigrationProvider({\n * fs,\n * // Path to the folder that contains all your migrations.\n * migrationFolder: 'some/path/to/migrations',\n * path,\n * })\n * })\n *\n * await migrator.migrateTo('some_migration')\n * ```\n *\n * If you specify the name of the first migration, this method migrates\n * down to the first migration, but doesn't run the `down` method of\n * the first migration. In case you want to migrate all the way down,\n * you can use a special constant `NO_MIGRATIONS`:\n *\n * ```ts\n * import { promises as fs } from 'node:fs'\n * import path from 'node:path'\n * import { FileMigrationProvider, Migrator, NO_MIGRATIONS } from 'kysely'\n *\n * const migrator = new Migrator({\n * db,\n * provider: new FileMigrationProvider({\n * fs,\n * // Path to the folder that contains all your migrations.\n * migrationFolder: 'some/path/to/migrations',\n * path,\n * })\n * })\n *\n * await migrator.migrateTo(NO_MIGRATIONS)\n * ```\n */\n async migrateTo(targetMigrationName) {\n return this.#migrate(({ migrations, executedMigrations, pendingMigrations, }) => {\n if (isObject(targetMigrationName) &&\n targetMigrationName.__noMigrations__ === true) {\n return { direction: 'Down', step: Infinity };\n }\n if (!migrations.find((m) => m.name === targetMigrationName)) {\n throw new Error(`migration \"${targetMigrationName}\" doesn't exist`);\n }\n const executedIndex = executedMigrations.indexOf(targetMigrationName);\n const pendingIndex = pendingMigrations.findIndex((m) => m.name === targetMigrationName);\n if (executedIndex !== -1) {\n return {\n direction: 'Down',\n step: executedMigrations.length - executedIndex - 1,\n };\n }\n else if (pendingIndex !== -1) {\n return { direction: 'Up', step: pendingIndex + 1 };\n }\n else {\n throw new Error(`migration \"${targetMigrationName}\" isn't executed or pending`);\n }\n });\n }\n /**\n * Migrate one step up.\n *\n * This method returns a {@link MigrationResultSet} instance and _never_ throws.\n * {@link MigrationResultSet.error} holds the error if something went wrong.\n * {@link MigrationResultSet.results} contains information about which migrations\n * were executed and which failed.\n *\n * ### Examples\n *\n * ```ts\n * import { promises as fs } from 'node:fs'\n * import path from 'node:path'\n * import { FileMigrationProvider, Migrator } from 'kysely'\n *\n * const migrator = new Migrator({\n * db,\n * provider: new FileMigrationProvider({\n * fs,\n * // Path to the folder that contains all your migrations.\n * migrationFolder: 'some/path/to/migrations',\n * path,\n * })\n * })\n *\n * await migrator.migrateUp()\n * ```\n */\n async migrateUp() {\n return this.#migrate(() => ({ direction: 'Up', step: 1 }));\n }\n /**\n * Migrate one step down.\n *\n * This method returns a {@link MigrationResultSet} instance and _never_ throws.\n * {@link MigrationResultSet.error} holds the error if something went wrong.\n * {@link MigrationResultSet.results} contains information about which migrations\n * were executed and which failed.\n *\n * ### Examples\n *\n * ```ts\n * import { promises as fs } from 'node:fs'\n * import path from 'node:path'\n * import { FileMigrationProvider, Migrator } from 'kysely'\n *\n * const migrator = new Migrator({\n * db,\n * provider: new FileMigrationProvider({\n * fs,\n * // Path to the folder that contains all your migrations.\n * migrationFolder: 'some/path/to/migrations',\n * path,\n * })\n * })\n *\n * await migrator.migrateDown()\n * ```\n */\n async migrateDown() {\n return this.#migrate(() => ({ direction: 'Down', step: 1 }));\n }\n async #migrate(getMigrationDirectionAndStep) {\n try {\n await this.#ensureMigrationTableSchemaExists();\n await this.#ensureMigrationTableExists();\n await this.#ensureMigrationLockTableExists();\n await this.#ensureLockRowExists();\n return await this.#runMigrations(getMigrationDirectionAndStep);\n }\n catch (error) {\n if (error instanceof MigrationResultSetError) {\n return error.resultSet;\n }\n return { error };\n }\n }\n get #migrationTableSchema() {\n return this.#props.migrationTableSchema;\n }\n get #migrationTable() {\n return this.#props.migrationTableName ?? DEFAULT_MIGRATION_TABLE;\n }\n get #migrationLockTable() {\n return this.#props.migrationLockTableName ?? DEFAULT_MIGRATION_LOCK_TABLE;\n }\n get #allowUnorderedMigrations() {\n return (this.#props.allowUnorderedMigrations ?? DEFAULT_ALLOW_UNORDERED_MIGRATIONS);\n }\n get #schemaPlugin() {\n if (this.#migrationTableSchema) {\n return new WithSchemaPlugin(this.#migrationTableSchema);\n }\n return new NoopPlugin();\n }\n async #ensureMigrationTableSchemaExists() {\n if (!this.#migrationTableSchema) {\n // Use default schema. Nothing to do.\n return;\n }\n const schemaExists = await this.#doesSchemaExist();\n if (schemaExists) {\n return;\n }\n try {\n await this.#createIfNotExists(this.#props.db.schema.createSchema(this.#migrationTableSchema));\n }\n catch (error) {\n const schemaExists = await this.#doesSchemaExist();\n // At least on PostgreSQL, `if not exists` doesn't guarantee the `create schema`\n // query doesn't throw if the schema already exits. That's why we check if\n // the schema exist here and ignore the error if it does.\n if (!schemaExists) {\n throw error;\n }\n }\n }\n async #ensureMigrationTableExists() {\n const tableExists = await this.#doesTableExist(this.#migrationTable);\n if (tableExists) {\n return;\n }\n try {\n await this.#createIfNotExists(this.#props.db.schema\n .withPlugin(this.#schemaPlugin)\n .createTable(this.#migrationTable)\n .addColumn('name', 'varchar(255)', (col) => col.notNull().primaryKey())\n // The migration run time as ISO string. This is not a real date type as we\n // can't know which data type is supported by all future dialects.\n .addColumn('timestamp', 'varchar(255)', (col) => col.notNull()));\n }\n catch (error) {\n const tableExists = await this.#doesTableExist(this.#migrationTable);\n // At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`\n // query doesn't throw if the table already exits. That's why we check if\n // the table exist here and ignore the error if it does.\n if (!tableExists) {\n throw error;\n }\n }\n }\n async #ensureMigrationLockTableExists() {\n const tableExists = await this.#doesTableExist(this.#migrationLockTable);\n if (tableExists) {\n return;\n }\n try {\n await this.#createIfNotExists(this.#props.db.schema\n .withPlugin(this.#schemaPlugin)\n .createTable(this.#migrationLockTable)\n .addColumn('id', 'varchar(255)', (col) => col.notNull().primaryKey())\n .addColumn('is_locked', 'integer', (col) => col.notNull().defaultTo(0)));\n }\n catch (error) {\n const tableExists = await this.#doesTableExist(this.#migrationLockTable);\n // At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`\n // query doesn't throw if the table already exits. That's why we check if\n // the table exist here and ignore the error if it does.\n if (!tableExists) {\n throw error;\n }\n }\n }\n async #ensureLockRowExists() {\n const lockRowExists = await this.#doesLockRowExists();\n if (lockRowExists) {\n return;\n }\n try {\n await this.#props.db\n .withPlugin(this.#schemaPlugin)\n .insertInto(this.#migrationLockTable)\n .values({ id: MIGRATION_LOCK_ID, is_locked: 0 })\n .execute();\n }\n catch (error) {\n const lockRowExists = await this.#doesLockRowExists();\n if (!lockRowExists) {\n throw error;\n }\n }\n }\n async #doesSchemaExist() {\n const schemas = await this.#props.db.introspection.getSchemas();\n return schemas.some((it) => it.name === this.#migrationTableSchema);\n }\n async #doesTableExist(tableName) {\n const schema = this.#migrationTableSchema;\n const tables = await this.#props.db.introspection.getTables({\n withInternalKyselyTables: true,\n });\n return tables.some((it) => it.name === tableName && (!schema || it.schema === schema));\n }\n async #doesLockRowExists() {\n const lockRow = await this.#props.db\n .withPlugin(this.#schemaPlugin)\n .selectFrom(this.#migrationLockTable)\n .where('id', '=', MIGRATION_LOCK_ID)\n .select('id')\n .executeTakeFirst();\n return !!lockRow;\n }\n async #runMigrations(getMigrationDirectionAndStep) {\n const adapter = this.#props.db.getExecutor().adapter;\n const lockOptions = freeze({\n lockTable: this.#props.migrationLockTableName ?? DEFAULT_MIGRATION_LOCK_TABLE,\n lockRowId: MIGRATION_LOCK_ID,\n lockTableSchema: this.#props.migrationTableSchema,\n });\n const run = async (db) => {\n try {\n await adapter.acquireMigrationLock(db, lockOptions);\n const state = await this.#getState(db);\n if (state.migrations.length === 0) {\n return { results: [] };\n }\n const { direction, step } = getMigrationDirectionAndStep(state);\n if (step <= 0) {\n return { results: [] };\n }\n if (direction === 'Down') {\n return await this.#migrateDown(db, state, step);\n }\n else if (direction === 'Up') {\n return await this.#migrateUp(db, state, step);\n }\n return { results: [] };\n }\n finally {\n await adapter.releaseMigrationLock(db, lockOptions);\n }\n };\n if (adapter.supportsTransactionalDdl && !this.#props.disableTransactions) {\n return this.#props.db.transaction().execute(run);\n }\n else {\n return this.#props.db.connection().execute(run);\n }\n }\n async #getState(db) {\n const migrations = await this.#resolveMigrations();\n const executedMigrations = await this.#getExecutedMigrations(db);\n this.#ensureNoMissingMigrations(migrations, executedMigrations);\n if (!this.#allowUnorderedMigrations) {\n this.#ensureMigrationsInOrder(migrations, executedMigrations);\n }\n const pendingMigrations = this.#getPendingMigrations(migrations, executedMigrations);\n return freeze({\n migrations,\n executedMigrations,\n lastMigration: getLast(executedMigrations),\n pendingMigrations,\n });\n }\n #getPendingMigrations(migrations, executedMigrations) {\n return migrations.filter((migration) => {\n return !executedMigrations.includes(migration.name);\n });\n }\n async #resolveMigrations() {\n const allMigrations = await this.#props.provider.getMigrations();\n return Object.keys(allMigrations)\n .sort()\n .map((name) => ({\n ...allMigrations[name],\n name,\n }));\n }\n async #getExecutedMigrations(db) {\n const executedMigrations = await db\n .withPlugin(this.#schemaPlugin)\n .selectFrom(this.#migrationTable)\n .select(['name', 'timestamp'])\n .$narrowType()\n .execute();\n const nameComparator = this.#props.nameComparator || ((a, b) => a.localeCompare(b));\n return (executedMigrations\n // https://github.com/kysely-org/kysely/issues/843\n .sort((a, b) => {\n if (a.timestamp === b.timestamp) {\n return nameComparator(a.name, b.name);\n }\n return (new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());\n })\n .map((it) => it.name));\n }\n #ensureNoMissingMigrations(migrations, executedMigrations) {\n // Ensure all executed migrations exist in the `migrations` list.\n for (const executed of executedMigrations) {\n if (!migrations.some((it) => it.name === executed)) {\n throw new Error(`corrupted migrations: previously executed migration ${executed} is missing`);\n }\n }\n }\n #ensureMigrationsInOrder(migrations, executedMigrations) {\n // Ensure the executed migrations are the first ones in the migration list.\n for (let i = 0; i < executedMigrations.length; ++i) {\n if (migrations[i].name !== executedMigrations[i]) {\n throw new Error(`corrupted migrations: expected previously executed migration ${executedMigrations[i]} to be at index ${i} but ${migrations[i].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);\n }\n }\n }\n async #migrateDown(db, state, step) {\n const migrationsToRollback = state.executedMigrations\n .slice()\n .reverse()\n .slice(0, step)\n .map((name) => {\n return state.migrations.find((it) => it.name === name);\n });\n const results = migrationsToRollback.map((migration) => {\n return {\n migrationName: migration.name,\n direction: 'Down',\n status: 'NotExecuted',\n };\n });\n for (let i = 0; i < results.length; ++i) {\n const migration = migrationsToRollback[i];\n try {\n if (migration.down) {\n await migration.down(db);\n await db\n .withPlugin(this.#schemaPlugin)\n .deleteFrom(this.#migrationTable)\n .where('name', '=', migration.name)\n .execute();\n results[i] = {\n migrationName: migration.name,\n direction: 'Down',\n status: 'Success',\n };\n }\n }\n catch (error) {\n results[i] = {\n migrationName: migration.name,\n direction: 'Down',\n status: 'Error',\n };\n throw new MigrationResultSetError({\n error,\n results,\n });\n }\n }\n return { results };\n }\n async #migrateUp(db, state, step) {\n const migrationsToRun = state.pendingMigrations.slice(0, step);\n const results = migrationsToRun.map((migration) => {\n return {\n migrationName: migration.name,\n direction: 'Up',\n status: 'NotExecuted',\n };\n });\n for (let i = 0; i < results.length; i++) {\n const migration = state.pendingMigrations[i];\n try {\n await migration.up(db);\n await db\n .withPlugin(this.#schemaPlugin)\n .insertInto(this.#migrationTable)\n .values({\n name: migration.name,\n timestamp: new Date().toISOString(),\n })\n .execute();\n results[i] = {\n migrationName: migration.name,\n direction: 'Up',\n status: 'Success',\n };\n }\n catch (error) {\n results[i] = {\n migrationName: migration.name,\n direction: 'Up',\n status: 'Error',\n };\n throw new MigrationResultSetError({\n error,\n results,\n });\n }\n }\n return { results };\n }\n async #createIfNotExists(qb) {\n if (this.#props.db.getExecutor().adapter.supportsCreateIfNotExists) {\n qb = qb.ifNotExists();\n }\n await qb.execute();\n }\n}\nclass MigrationResultSetError extends Error {\n #resultSet;\n constructor(result) {\n super();\n this.#resultSet = result;\n }\n get resultSet() {\n return this.#resultSet;\n }\n}\n","/// <reference types=\"./postgres-query-compiler.d.ts\" />\nimport { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';\nconst ID_WRAP_REGEX = /\"/g;\nexport class PostgresQueryCompiler extends DefaultQueryCompiler {\n sanitizeIdentifier(identifier) {\n return identifier.replace(ID_WRAP_REGEX, '\"\"');\n }\n}\n","/// <reference types=\"./postgres-introspector.d.ts\" />\nimport { DEFAULT_MIGRATION_LOCK_TABLE, DEFAULT_MIGRATION_TABLE, } from '../../migration/migrator.js';\nimport { freeze } from '../../util/object-utils.js';\nimport { sql } from '../../raw-builder/sql.js';\nexport class PostgresIntrospector {\n #db;\n constructor(db) {\n this.#db = db;\n }\n async getSchemas() {\n let rawSchemas = await this.#db\n .selectFrom('pg_catalog.pg_namespace')\n .select('nspname')\n .$castTo()\n .execute();\n return rawSchemas.map((it) => ({ name: it.nspname }));\n }\n async getTables(options = { withInternalKyselyTables: false }) {\n let query = this.#db\n // column\n .selectFrom('pg_catalog.pg_attribute as a')\n // table\n .innerJoin('pg_catalog.pg_class as c', 'a.attrelid', 'c.oid')\n // table schema\n .innerJoin('pg_catalog.pg_namespace as ns', 'c.relnamespace', 'ns.oid')\n // column data type\n .innerJoin('pg_catalog.pg_type as typ', 'a.atttypid', 'typ.oid')\n // column data type schema\n .innerJoin('pg_catalog.pg_namespace as dtns', 'typ.typnamespace', 'dtns.oid')\n .select([\n 'a.attname as column',\n 'a.attnotnull as not_null',\n 'a.atthasdef as has_default',\n 'c.relname as table',\n 'c.relkind as table_type',\n 'ns.nspname as schema',\n 'typ.typname as type',\n 'dtns.nspname as type_schema',\n sql `col_description(a.attrelid, a.attnum)`.as('column_description'),\n sql `pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as('auto_incrementing'),\n ])\n .where('c.relkind', 'in', [\n 'r' /*regular table*/,\n 'v' /*view*/,\n 'p' /*partitioned table*/,\n ])\n .where('ns.nspname', '!~', '^pg_')\n .where('ns.nspname', '!=', 'information_schema')\n // Filter out internal cockroachdb schema\n .where('ns.nspname', '!=', 'crdb_internal')\n // Only schemas where we are allowed access\n .where(sql `has_schema_privilege(ns.nspname, 'USAGE')`)\n // No system columns\n .where('a.attnum', '>=', 0)\n .where('a.attisdropped', '!=', true)\n .orderBy('ns.nspname')\n .orderBy('c.relname')\n .orderBy('a.attnum')\n .$castTo();\n if (!options.withInternalKyselyTables) {\n query = query\n .where('c.relname', '!=', DEFAULT_MIGRATION_TABLE)\n .where('c.relname', '!=', DEFAULT_MIGRATION_LOCK_TABLE);\n }\n const rawColumns = await query.execute();\n return this.#parseTableMetadata(rawColumns);\n }\n async getMetadata(options) {\n return {\n tables: await this.getTables(options),\n };\n }\n #parseTableMetadata(columns) {\n const tableDictionary = new Map();\n for (let i = 0, len = columns.length; i < len; i++) {\n const column = columns[i];\n const { schema, table } = column;\n const tableKey = `schema:${schema};table:${table}`;\n if (!tableDictionary.has(tableKey)) {\n tableDictionary.set(tableKey, freeze({\n columns: [],\n isView: column.table_type === 'v',\n name: table,\n schema,\n }));\n }\n tableDictionary.get(tableKey).columns.push(freeze({\n comment: column.column_description ?? undefined,\n dataType: column.type,\n dataTypeSchema: column.type_schema,\n hasDefaultValue: column.has_default,\n isAutoIncrementing: column.auto_incrementing !== null,\n isNullable: !column.not_null,\n name: column.column,\n }));\n }\n return Array.from(tableDictionary.values());\n }\n}\n","/// <reference types=\"./postgres-adapter.d.ts\" />\nimport { sql } from '../../raw-builder/sql.js';\nimport { DialectAdapterBase } from '../dialect-adapter-base.js';\n// Random id for our transaction lock.\nconst LOCK_ID = BigInt('3853314791062309107');\nexport class PostgresAdapter extends DialectAdapterBase {\n get supportsTransactionalDdl() {\n return true;\n }\n get supportsReturning() {\n return true;\n }\n async acquireMigrationLock(db, _opt) {\n // Acquire a transaction level advisory lock.\n await sql `select pg_advisory_xact_lock(${sql.lit(LOCK_ID)})`.execute(db);\n }\n async releaseMigrationLock(_db, _opt) {\n // Nothing to do here. `pg_advisory_xact_lock` is automatically released at the\n // end of the transaction and since `supportsTransactionalDdl` true, we know\n // the `db` instance passed to acquireMigrationLock is actually a transaction.\n }\n}\n","// src/dialect.ts\nimport {\n CompiledQuery,\n PostgresAdapter,\n PostgresIntrospector,\n PostgresQueryCompiler\n} from \"kysely\";\n\n// src/connection.ts\nvar PGliteConnection = class {\n client;\n constructor(client) {\n this.client = client;\n }\n async executeQuery(compiledQuery) {\n const result = await this.client.query(compiledQuery.sql, [\n ...compiledQuery.parameters\n ]);\n if (result.affectedRows) {\n const numAffectedRows = BigInt(result.affectedRows);\n return {\n numAffectedRows,\n rows: result.rows\n };\n }\n return {\n rows: result.rows\n };\n }\n async *streamQuery(compiledQuery, chunkSize) {\n if (!Number.isInteger(chunkSize) || chunkSize <= 0) {\n throw new Error(\"chunkSize must be a positive integer\");\n }\n const result = await this.client.query(compiledQuery.sql, [\n ...compiledQuery.parameters\n ]);\n for (let i = 0; i < result.rows.length; i = i + chunkSize) {\n const chunk = result.rows.slice(i, i + chunkSize);\n yield { rows: chunk };\n }\n }\n};\n\n// src/dialect.ts\nvar PGliteDialect = class {\n constructor(pgLite) {\n this.pgLite = pgLite;\n }\n createAdapter() {\n return new PostgresAdapter();\n }\n createDriver() {\n return new PGliteDriver(this.pgLite);\n }\n createQueryCompiler() {\n return new PostgresQueryCompiler();\n }\n createIntrospector(db) {\n return new PostgresIntrospector(db);\n }\n};\nvar PGliteDriver = class {\n client;\n /**\n * Currently used connection.\n * If another acquireConnection() is called the request is queued till this connection has been released.\n */\n connection;\n queue = [];\n constructor(pgLite) {\n this.client = pgLite;\n }\n async init() {\n }\n // Serialize access to the connection, i.e. promise is only resolved when the last connection was released.\n async acquireConnection() {\n if (this.client === void 0) {\n throw new Error(\"PGLite not initialized\");\n }\n if (this.connection !== void 0) {\n return new Promise((resolve) => {\n this.queue.push(resolve);\n });\n }\n this.connection = new PGliteConnection(this.client);\n return this.connection;\n }\n async releaseConnection(connection) {\n if (connection !== this.connection) {\n throw new Error(\"Invalid connection\");\n }\n const removed = this.queue.splice(0, 1);\n const next = removed[0];\n if (next === void 0) {\n this.connection = void 0;\n return;\n }\n next(this.connection);\n }\n async beginTransaction(conn, settings) {\n if (settings.isolationLevel) {\n await conn.executeQuery(\n CompiledQuery.raw(\n `start transaction isolation level ${settings.isolationLevel}`\n )\n );\n } else {\n await conn.executeQuery(CompiledQuery.raw(\"begin\"));\n }\n }\n async commitTransaction(conn) {\n await conn.executeQuery(CompiledQuery.raw(\"commit\"));\n }\n async rollbackTransaction(conn) {\n await conn.executeQuery(CompiledQuery.raw(\"rollback\"));\n }\n async destroy() {\n this.client = void 0;\n }\n};\nexport {\n PGliteDialect\n};\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10],"mappings":";;AAMA,IAAM,iBAAN,MAAM,eAAe;CACjB;CACA,YAAY,OAAO;EACf,KAAK,SAAS,OAAO,KAAK;CAC9B;CACA,IAAI,iBAAiB,CAErB;CACA,IAAI,eAAe;EACf,OAAO;CACX;CACA,GAAG,OAAO;EACN,OAAO,IAAI,sBAAsB,MAAM,KAAK;CAChD;CACA,UAAU;EACN,OAAO,IAAI,eAAe,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AAe,KAAK,GAC3B,OAAO,IAAI,SAAS,YAAY;GAC9B,KAAK,MAAM,KAAK,OAAO;EACzB,CAAC;EAEH,KAAK,aAAa,IAAI,iBAAiB,KAAK,MAAM;EAClD,OAAO,KAAK;CACd;CACA,MAAM,kBAAkB,YAAY;EAClC,IAAI,eAAe,KAAK,YACtB,MAAM,IAAI,MAAM,oBAAoB;EAGtC,MAAM,OADU,KAAK,MAAM,OAAO,GAAG,CAClB,CAAC,CAAC;EACrB,IAAI,SAAS,KAAK,GAAG;GACnB,KAAK,aAAa,KAAK;GACvB;EACF;EACA,KAAK,KAAK,UAAU;CACtB;CACA,MAAM,iBAAiB,MAAM,UAAU;EACrC,IAAI,SAAS,gBACX,MAAM,KAAK,aACT,cAAc,IACZ,qCAAqC,SAAS,gBAChD,CACF;OAEA,MAAM,KAAK,aAAa,cAAc,IAAI,OAAO,CAAC;CAEtD;CACA,MAAM,kBAAkB,MAAM;EAC5B,MAAM,KAAK,aAAa,cAAc,IAAI,QAAQ,CAAC;CACrD;CACA,MAAM,oBAAoB,MAAM;EAC9B,MAAM,KAAK,aAAa,cAAc,IAAI,UAAU,CAAC;CACvD;CACA,MAAM,UAAU;EACd,KAAK,SAAS,KAAK;CACrB;AACF"}
@@ -1,85 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
- //#region src/integrations/powerhouse/drive.ts
3
- var drive_exports = /* @__PURE__ */ __exportAll({
4
- ensureDrive: () => ensureDrive,
5
- ensureRemoteDrive: () => ensureRemoteDrive
6
- });
7
- const DRIVE_DOCUMENT_TYPE = "powerhouse/document-drive";
8
- /**
9
- * Ensure a drive exists, matching by name. On first run, creates a new drive.
10
- * On subsequent runs, finds the existing one by name.
11
- *
12
- * The Reactor client has no `getDrives()` — drives are documents of type
13
- * `powerhouse/document-drive`. We use `reactor.findByType()` to locate
14
- * existing ones and `client.write.createEmpty()` + `client.write.rename()`
15
- * to create.
16
- *
17
- * @param reactorModule - The full ReactorClientModule (needs .client and .reactor)
18
- * @param driveConfig - Optional drive name/icon configuration
19
- * @returns The drive ID and name
20
- */
21
- async function ensureDrive(reactorModule, driveConfig) {
22
- const { client, reactor } = reactorModule;
23
- const driveName = driveConfig?.name ?? "default";
24
- const wantedId = driveConfig?.id;
25
- const preferredEditor = driveConfig?.preferredEditor;
26
- const existing = await reactor.findByType(DRIVE_DOCUMENT_TYPE);
27
- if (existing?.results?.length) {
28
- if (wantedId) {
29
- if (existing.results.find((r) => r.header.id === wantedId)) return {
30
- id: wantedId,
31
- name: driveName
32
- };
33
- }
34
- for (const result of existing.results) {
35
- const doc = await client.get(result.header.id);
36
- if ((doc.name ?? doc.header?.name ?? doc.state?.global?.name) === driveName) return {
37
- id: result.header.id,
38
- name: driveName
39
- };
40
- }
41
- if (driveName === "default" && existing.results.length === 1) return {
42
- id: existing.results[0].header.id,
43
- name: driveName
44
- };
45
- }
46
- let driveId;
47
- if (wantedId || preferredEditor) {
48
- const doc = await client.newDocument(DRIVE_DOCUMENT_TYPE, wantedId ? {
49
- signaturePolicy: "legacy",
50
- id: wantedId
51
- } : void 0);
52
- if (preferredEditor) doc.header.meta = { preferredEditor };
53
- driveId = (await (await client.write.create(doc)).document()).header.id;
54
- } else driveId = (await (await client.write.createEmpty(DRIVE_DOCUMENT_TYPE)).document()).header.id;
55
- await (await client.write.rename(driveId, driveName)).document();
56
- return {
57
- id: driveId,
58
- name: driveName
59
- };
60
- }
61
- /**
62
- * Ensure a remote drive is connected for watching.
63
- * Uses the reactor client's addRemoteDrive capability.
64
- *
65
- * @param reactorModule - The full ReactorClientModule
66
- * @param url - The Switchboard URL to sync from
67
- * @param name - Display name for the drive
68
- * @returns The drive ID and name
69
- */
70
- async function ensureRemoteDrive(reactorModule, url, name) {
71
- const { client } = reactorModule;
72
- const result = await client.addRemoteDrive(url);
73
- const driveId = result.header?.id ?? result.id;
74
- if (name) try {
75
- await (await client.write.rename(driveId, name)).document();
76
- } catch {}
77
- return {
78
- id: driveId,
79
- name
80
- };
81
- }
82
- //#endregion
83
- export { drive_exports as t };
84
-
85
- //# sourceMappingURL=drive-Bu9zoFrO.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"drive-Bu9zoFrO.mjs","names":[],"sources":["../src/integrations/powerhouse/drive.ts"],"sourcesContent":["/**\n * Drive management — find or create drives on startup.\n */\n\nimport type { DriveConfig, ReactorClientModule } from \"./types.js\";\n\nconst DRIVE_DOCUMENT_TYPE = \"powerhouse/document-drive\" as const;\n\n/**\n * Ensure a drive exists, matching by name. On first run, creates a new drive.\n * On subsequent runs, finds the existing one by name.\n *\n * The Reactor client has no `getDrives()` — drives are documents of type\n * `powerhouse/document-drive`. We use `reactor.findByType()` to locate\n * existing ones and `client.write.createEmpty()` + `client.write.rename()`\n * to create.\n *\n * @param reactorModule - The full ReactorClientModule (needs .client and .reactor)\n * @param driveConfig - Optional drive name/icon configuration\n * @returns The drive ID and name\n */\nexport async function ensureDrive(\n reactorModule: ReactorClientModule,\n driveConfig?: DriveConfig,\n): Promise<{ id: string; name: string }> {\n const { client, reactor } = reactorModule;\n const driveName = driveConfig?.name ?? \"default\";\n const wantedId = driveConfig?.id;\n const preferredEditor = driveConfig?.preferredEditor;\n\n // Find existing document-drive documents\n const existing = await reactor.findByType(DRIVE_DOCUMENT_TYPE);\n if (existing?.results?.length) {\n // If a deterministic ID was requested, check if it already exists\n if (wantedId) {\n const match = existing.results.find((r) => r.header.id === wantedId);\n if (match) return { id: wantedId, name: driveName };\n }\n\n // Match by name — load each to check\n for (const result of existing.results) {\n const doc = (await client.get(result.header.id)) as any;\n const docName = doc.name ?? doc.header?.name ?? doc.state?.global?.name;\n if (docName === driveName) {\n return { id: result.header.id, name: driveName };\n }\n }\n // No name match — if default name and single drive, use it\n if (driveName === \"default\" && existing.results.length === 1) {\n return { id: existing.results[0].header.id, name: driveName };\n }\n }\n\n // Create a new drive document. Goes through the doc-build path when a\n // deterministic id or preferredEditor is set so we can populate the\n // header before persistence; falls back to createEmpty otherwise.\n let driveId: string;\n if (wantedId || preferredEditor) {\n // Only a legacy drive can take a chosen id.\n const doc = await client.newDocument(\n DRIVE_DOCUMENT_TYPE,\n wantedId ? { signaturePolicy: \"legacy\", id: wantedId } : undefined,\n );\n if (preferredEditor) doc.header.meta = { preferredEditor };\n const handle = await client.write.create(doc);\n const created = await handle.document();\n driveId = (created as any).header.id;\n } else {\n const handle = await client.write.createEmpty(DRIVE_DOCUMENT_TYPE);\n const drive = await handle.document();\n driveId = drive.header.id;\n }\n\n await (await client.write.rename(driveId, driveName)).document();\n return { id: driveId, name: driveName };\n}\n\n/**\n * Ensure a remote drive is connected for watching.\n * Uses the reactor client's addRemoteDrive capability.\n *\n * @param reactorModule - The full ReactorClientModule\n * @param url - The Switchboard URL to sync from\n * @param name - Display name for the drive\n * @returns The drive ID and name\n */\nexport async function ensureRemoteDrive(\n reactorModule: ReactorClientModule,\n url: string,\n name: string,\n): Promise<{ id: string; name: string }> {\n const { client } = reactorModule;\n\n // addRemoteDrive is idempotent — calling again for the same URL\n // returns the existing drive\n const result = await (client as any).addRemoteDrive(url);\n const driveId = result.header?.id ?? result.id;\n\n if (name) {\n try {\n await (await client.write.rename(driveId, name)).document();\n } catch {\n // Rename may fail for remote drives — non-fatal\n }\n }\n\n return { id: driveId, name };\n}\n"],"mappings":";;;;;;AAMA,MAAM,sBAAsB;;;;;;;;;;;;;;AAe5B,eAAsB,YACpB,eACA,aACuC;CACvC,MAAM,EAAE,QAAQ,YAAY;CAC5B,MAAM,YAAY,aAAa,QAAQ;CACvC,MAAM,WAAW,aAAa;CAC9B,MAAM,kBAAkB,aAAa;CAGrC,MAAM,WAAW,MAAM,QAAQ,WAAW,mBAAmB;CAC7D,IAAI,UAAU,SAAS,QAAQ;EAE7B,IAAI,UACY;OAAA,SAAS,QAAQ,MAAM,MAAM,EAAE,OAAO,OAAO,QACnD,GAAG,OAAO;IAAE,IAAI;IAAU,MAAM;GAAU;EAAA;EAIpD,KAAK,MAAM,UAAU,SA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