@pikku/cli 0.12.128 → 0.12.133

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 (267) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/console-app/assets/{abnfDiagram-N423BO3Z-BY2LM8wi.js → abnfDiagram-N423BO3Z-BQPUva28.js} +1 -1
  3. package/console-app/assets/architecture-TIHT7OUA-G_ldr-C2.js +1 -0
  4. package/console-app/assets/{architectureDiagram-T3A2C74G-CeqjY3Kw.js → architectureDiagram-T3A2C74G-Cjzy66o9.js} +1 -1
  5. package/console-app/assets/{blockDiagram-VBNYF7ZC-BW5174xj.js → blockDiagram-VBNYF7ZC-DVasSXpX.js} +1 -1
  6. package/console-app/assets/{c4Diagram-5PPSVZJV-B7zXAFL0.js → c4Diagram-5PPSVZJV-FB0YMoOr.js} +1 -1
  7. package/console-app/assets/channel-CuDpOUYn.js +1 -0
  8. package/console-app/assets/{chunk-2GRJ4B5K-BfRYzQ4t.js → chunk-2GRJ4B5K-BLGsmyy4.js} +1 -1
  9. package/console-app/assets/{chunk-4I5QYGJK-DBA7-Nu4.js → chunk-4I5QYGJK-DCgTj78f.js} +1 -1
  10. package/console-app/assets/{chunk-5RXB4S5H-D03lNzwi.js → chunk-5RXB4S5H-CX9hS68x.js} +1 -1
  11. package/console-app/assets/{chunk-6Q2QTUOP-DloGRHJZ.js → chunk-6Q2QTUOP-xrgFRP4Y.js} +1 -1
  12. package/console-app/assets/{chunk-7Z6QIM7H-DH3uHtl2.js → chunk-7Z6QIM7H-CbBMe7ej.js} +1 -1
  13. package/console-app/assets/{chunk-GF5L2VYU-Cu252lza.js → chunk-GF5L2VYU-BXraqZ7w.js} +1 -1
  14. package/console-app/assets/{chunk-I66GZJ75-DH54FcuO.js → chunk-I66GZJ75-CbpQtX8e.js} +1 -1
  15. package/console-app/assets/{chunk-JQJVKLGR-CeFuTL-V.js → chunk-JQJVKLGR-Cp9FHSH6.js} +1 -1
  16. package/console-app/assets/{chunk-KBJHAD2P-B-prFo0-.js → chunk-KBJHAD2P-Brvmen34.js} +1 -1
  17. package/console-app/assets/{chunk-NSK5VX7P-C10iA4GS.js → chunk-NSK5VX7P-Bo-dbDZD.js} +1 -1
  18. package/console-app/assets/{chunk-QR6OTTB3-Cd8apAsA.js → chunk-QR6OTTB3-B5Al5KEo.js} +1 -1
  19. package/console-app/assets/{chunk-RYQCIY6F-rfPUp2Fj.js → chunk-RYQCIY6F-WOZyn5It.js} +1 -1
  20. package/console-app/assets/{chunk-UBXNYLIW-D25wqJBc.js → chunk-UBXNYLIW-D9OoHV5X.js} +1 -1
  21. package/console-app/assets/{chunk-W5SLKNZC-CJvxkxuK.js → chunk-W5SLKNZC-BNTcVpi3.js} +1 -1
  22. package/console-app/assets/{chunk-WRU74C26-B9Wju92P.js → chunk-WRU74C26-DXijYjrx.js} +1 -1
  23. package/console-app/assets/chunk-XXDRQBXY-DRMEt0Gf.js +1 -0
  24. package/console-app/assets/classDiagram-JCYQIIEL-Bjgk6QkN.js +1 -0
  25. package/console-app/assets/classDiagram-v2-OCEON4UE-Bjgk6QkN.js +1 -0
  26. package/console-app/assets/{cose-bilkent-JH36ORCC-CwA1VCP5.js → cose-bilkent-JH36ORCC-CPN5VkQC.js} +1 -1
  27. package/console-app/assets/{cynefin-VYW2F7L2-C_qsD7eR.js → cynefin-VYW2F7L2-CuBPO3Z0.js} +1 -1
  28. package/console-app/assets/{cynefinDiagram-MW4NZA55-CkSLreFW.js → cynefinDiagram-MW4NZA55-BYc2PGXv.js} +1 -1
  29. package/console-app/assets/{dagre-WqgBlKb7.js → dagre-7HV9Jfb_.js} +1 -1
  30. package/console-app/assets/{dagre-VZM6K2ZE-0ssqLoHs.js → dagre-VZM6K2ZE-BpPyuM7i.js} +1 -1
  31. package/console-app/assets/{diagram-7IWD3JNH-DmRL3lmL.js → diagram-7IWD3JNH-DTH9ID9z.js} +1 -1
  32. package/console-app/assets/{diagram-B4RE2ZJO-Bsr9wG4I.js → diagram-B4RE2ZJO-DwZb9gPm.js} +1 -1
  33. package/console-app/assets/{diagram-LBJQPF4R-DdMw1FSY.js → diagram-LBJQPF4R-DfvBayzk.js} +1 -1
  34. package/console-app/assets/{diagram-Q27KOJAE-TPx5TB2B.js → diagram-Q27KOJAE-hksFpSxs.js} +1 -1
  35. package/console-app/assets/{diagram-UB23O5K3-e_1zSlZR.js → diagram-UB23O5K3-5hEVCouO.js} +1 -1
  36. package/console-app/assets/{ebnfDiagram-BXEA7PRR-BACajh2b.js → ebnfDiagram-BXEA7PRR-D0v6RJvf.js} +1 -1
  37. package/console-app/assets/{erDiagram-JOGREHBK-CojomKqL.js → erDiagram-JOGREHBK-DGps-M4l.js} +1 -1
  38. package/console-app/assets/eventmodeling-45OFAUF4-DWRslJcU.js +1 -0
  39. package/console-app/assets/flowDiagram-UKHOOZJN-CE3qN_pH.js +1 -0
  40. package/console-app/assets/{ganttDiagram-PKOTCBZU-yoOX4Xj2.js → ganttDiagram-PKOTCBZU-Dok7ME1t.js} +1 -1
  41. package/console-app/assets/{gitGraph-TEB2WS4Q-BcUY5hIc.js → gitGraph-TEB2WS4Q-8492lYYh.js} +1 -1
  42. package/console-app/assets/{gitGraphDiagram-DS77QQ5N-BtuIPjuB.js → gitGraphDiagram-DS77QQ5N-sPOnBy5f.js} +1 -1
  43. package/console-app/assets/{index-CzWW052c.js → index-DqNqujdF.js} +184 -184
  44. package/console-app/assets/{info-DKCQHKI2-B-iR9PUz.js → info-DKCQHKI2-U4uEmX4H.js} +1 -1
  45. package/console-app/assets/{infoDiagram-6WML65LV-CuXKIFH2.js → infoDiagram-6WML65LV-CNV12_Nx.js} +1 -1
  46. package/console-app/assets/{ishikawaDiagram-WSZJBQD7-CSueMFD6.js → ishikawaDiagram-WSZJBQD7-CcnTBGLj.js} +1 -1
  47. package/console-app/assets/{journeyDiagram-NVQOT4AX-kvnKStZp.js → journeyDiagram-NVQOT4AX-MX-UQBJ7.js} +1 -1
  48. package/console-app/assets/{kanban-definition-27J2QSJJ-CGGDEz30.js → kanban-definition-27J2QSJJ-BXh1Eu4D.js} +1 -1
  49. package/console-app/assets/{line-mtMM5-xO.js → line-2B2dlQbw.js} +1 -1
  50. package/console-app/assets/{linear-CLSje0O_.js → linear-DAVRH-Dp.js} +1 -1
  51. package/console-app/assets/{mermaid-parser.core-Cx6yvn3j.js → mermaid-parser.core-DxPo1qbR.js} +3 -3
  52. package/console-app/assets/{mermaid.core-BebGyklS.js → mermaid.core-DpvXaF3y.js} +4 -4
  53. package/console-app/assets/{mindmap-definition-FAOFIHXS-C2_WUUJ9.js → mindmap-definition-FAOFIHXS-wIEKn4qe.js} +1 -1
  54. package/console-app/assets/{packet-7NZHBO7P-Dh5yNCA8.js → packet-7NZHBO7P-CXySycDQ.js} +1 -1
  55. package/console-app/assets/{pegDiagram-VL7TDLO6-XgUxesi8.js → pegDiagram-VL7TDLO6-CDGkzO6q.js} +1 -1
  56. package/console-app/assets/{pie-RZYD4A2V-D2x2RAXI.js → pie-RZYD4A2V-9woSahH7.js} +1 -1
  57. package/console-app/assets/{pieDiagram-7S7Q4E2Y-Bbor0KbG.js → pieDiagram-7S7Q4E2Y-DLoZWnVF.js} +1 -1
  58. package/console-app/assets/{quadrantDiagram-CIZ2JOQS-DZmnMHpM.js → quadrantDiagram-CIZ2JOQS-NBGRoga7.js} +1 -1
  59. package/console-app/assets/{radar-I7S5WNFK-CPeriDtN.js → radar-I7S5WNFK-BYhW66ZA.js} +1 -1
  60. package/console-app/assets/{railroad-3IZDKUUU-2iKAyaie.js → railroad-3IZDKUUU-BqHXlwF5.js} +1 -1
  61. package/console-app/assets/railroad-abnf-AHOZXSZD-BfGOy69e.js +1 -0
  62. package/console-app/assets/railroad-ebnf-EBAXGLYW-BbGv9WfS.js +1 -0
  63. package/console-app/assets/railroad-peg-LSFZ7HO6-CCiPI8BL.js +1 -0
  64. package/console-app/assets/{railroadDiagram-AXF67PYL-DVEqCXoo.js → railroadDiagram-AXF67PYL-FYQaHJ6A.js} +1 -1
  65. package/console-app/assets/{requirementDiagram-LRYGKXZP-CSgSNL8p.js → requirementDiagram-LRYGKXZP-ihhW1kgC.js} +1 -1
  66. package/console-app/assets/{sankeyDiagram-W5VNT64P-CFk11odN.js → sankeyDiagram-W5VNT64P-Dw2EbW8v.js} +1 -1
  67. package/console-app/assets/{sequenceDiagram-SI44F4Z6-Cb5u6FsJ.js → sequenceDiagram-SI44F4Z6-C6i_U4QX.js} +1 -1
  68. package/console-app/assets/{src-LceHEY_Q.js → src-DF-84qwJ.js} +1 -1
  69. package/console-app/assets/{stateDiagram-OKZ733FA-DM1jWlkU.js → stateDiagram-OKZ733FA-xH4wcMO4.js} +1 -1
  70. package/console-app/assets/stateDiagram-v2-UEYNNEHI-BJln5PLd.js +1 -0
  71. package/console-app/assets/{swimlanes-SLNWSIFB-DD6MchlE.js → swimlanes-SLNWSIFB-CkFlU1Qc.js} +1 -1
  72. package/console-app/assets/swimlanesDiagram-ULZ7WXOC-CSLhmtbh.js +8 -0
  73. package/console-app/assets/{timeline-definition-Z64GVDOM-zu5cNnVv.js → timeline-definition-Z64GVDOM-BQE9-7mm.js} +1 -1
  74. package/console-app/assets/{treeView-QDETBFTQ-D_4IbvCG.js → treeView-QDETBFTQ-C4hse2Wn.js} +1 -1
  75. package/console-app/assets/{treemap-6X3UGDF4-DNc6bjUc.js → treemap-6X3UGDF4-Bi7ORgq6.js} +1 -1
  76. package/console-app/assets/{vennDiagram-T6HMQDX7-DfqoG28f.js → vennDiagram-T6HMQDX7-DbUdNREA.js} +1 -1
  77. package/console-app/assets/{wardley-OPB4EBWU-BqpI2Lx-.js → wardley-OPB4EBWU-BHqXIxRe.js} +1 -1
  78. package/console-app/assets/{wardleyDiagram-T6FBY63Y-CLIZSvNi.js → wardleyDiagram-T6FBY63Y-1VOvM_bb.js} +1 -1
  79. package/console-app/assets/{xychartDiagram-ELKLHX3M-Cni-XXa6.js → xychartDiagram-ELKLHX3M-C3DVfSR9.js} +1 -1
  80. package/console-app/index.html +1 -1
  81. package/dist/.pikku/addon/index.d.ts +1 -1
  82. package/dist/.pikku/addon/index.js +1 -1
  83. package/dist/.pikku/addon/pikku-addon-types.gen.d.ts +1 -1
  84. package/dist/.pikku/addon/pikku-addon-types.gen.js +1 -1
  85. package/dist/.pikku/agent/index.d.ts +1 -1
  86. package/dist/.pikku/agent/index.js +1 -1
  87. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
  88. package/dist/.pikku/agent/pikku-model-aliases.gen.js +1 -1
  89. package/dist/.pikku/auth/index.d.ts +1 -1
  90. package/dist/.pikku/auth/index.js +1 -1
  91. package/dist/.pikku/auth/pikku-auth-types.gen.d.ts +1 -1
  92. package/dist/.pikku/auth/pikku-auth-types.gen.js +1 -1
  93. package/dist/.pikku/channel/index.d.ts +1 -1
  94. package/dist/.pikku/channel/index.js +1 -1
  95. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
  96. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  97. package/dist/.pikku/cli/index.d.ts +1 -1
  98. package/dist/.pikku/cli/index.js +1 -1
  99. package/dist/.pikku/cli/pikku-cli-channel.js +26 -1
  100. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  101. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
  102. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
  103. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
  104. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  105. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  106. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  107. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +85 -0
  108. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  109. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  110. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  111. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  112. package/dist/.pikku/error/index.d.ts +1 -1
  113. package/dist/.pikku/error/index.js +1 -1
  114. package/dist/.pikku/error/pikku-error-types.gen.d.ts +1 -1
  115. package/dist/.pikku/error/pikku-error-types.gen.js +1 -1
  116. package/dist/.pikku/function/index.d.ts +1 -1
  117. package/dist/.pikku/function/index.js +1 -1
  118. package/dist/.pikku/function/pikku-function-types.gen.d.ts +1 -1
  119. package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
  120. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  121. package/dist/.pikku/function/pikku-functions-meta.gen.json +95 -0
  122. package/dist/.pikku/function/pikku-functions.gen.js +1 -1
  123. package/dist/.pikku/gateway/index.d.ts +1 -1
  124. package/dist/.pikku/gateway/index.js +1 -1
  125. package/dist/.pikku/gateway/pikku-gateway-types.gen.d.ts +1 -1
  126. package/dist/.pikku/gateway/pikku-gateway-types.gen.js +1 -1
  127. package/dist/.pikku/http/index.d.ts +1 -1
  128. package/dist/.pikku/http/index.js +1 -1
  129. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  130. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  131. package/dist/.pikku/mcp/index.d.ts +1 -1
  132. package/dist/.pikku/mcp/index.js +1 -1
  133. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  134. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  135. package/dist/.pikku/middleware/index.d.ts +1 -1
  136. package/dist/.pikku/middleware/index.js +1 -1
  137. package/dist/.pikku/middleware/pikku-middleware-types.gen.d.ts +1 -1
  138. package/dist/.pikku/middleware/pikku-middleware-types.gen.js +1 -1
  139. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +1 -1
  140. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +1 -1
  141. package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
  142. package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
  143. package/dist/.pikku/pikku-services.gen.d.ts +1 -1
  144. package/dist/.pikku/queue/index.d.ts +1 -1
  145. package/dist/.pikku/queue/index.js +1 -1
  146. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  147. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  148. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  149. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  150. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  151. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  152. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +5 -0
  153. package/dist/.pikku/scenarios/index.d.ts +1 -1
  154. package/dist/.pikku/scenarios/index.js +1 -1
  155. package/dist/.pikku/scenarios/pikku-personas.gen.js +1 -1
  156. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
  157. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
  158. package/dist/.pikku/scenarios/pikku-scenario-types.gen.d.ts +1 -1
  159. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
  160. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
  161. package/dist/.pikku/scenarios/schemas/register.gen.d.ts +1 -1
  162. package/dist/.pikku/scenarios/schemas/register.gen.js +1 -1
  163. package/dist/.pikku/scheduler/index.d.ts +1 -1
  164. package/dist/.pikku/scheduler/index.js +1 -1
  165. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  166. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  167. package/dist/.pikku/schemas/register.gen.js +21 -1
  168. package/dist/.pikku/schemas/schemas/KnowledgePlanDeferInput.schema.json +1 -0
  169. package/dist/.pikku/schemas/schemas/KnowledgePlanDeferOutput.schema.json +1 -0
  170. package/dist/.pikku/schemas/schemas/KnowledgePlanProgressInput.schema.json +1 -0
  171. package/dist/.pikku/schemas/schemas/KnowledgePlanProgressOutput.schema.json +1 -0
  172. package/dist/.pikku/schemas/schemas/KnowledgePlanSchemaInput.schema.json +1 -0
  173. package/dist/.pikku/schemas/schemas/KnowledgePlanSchemaOutput.schema.json +1 -0
  174. package/dist/.pikku/schemas/schemas/KnowledgePlanSetInput.schema.json +1 -0
  175. package/dist/.pikku/schemas/schemas/KnowledgePlanSetOutput.schema.json +1 -0
  176. package/dist/.pikku/schemas/schemas/KnowledgePlanShowInput.schema.json +1 -0
  177. package/dist/.pikku/schemas/schemas/KnowledgePlanShowOutput.schema.json +1 -0
  178. package/dist/.pikku/scopes/index.d.ts +1 -1
  179. package/dist/.pikku/scopes/index.js +1 -1
  180. package/dist/.pikku/scopes/pikku-personas.gen.js +1 -1
  181. package/dist/.pikku/scopes/pikku-roles.gen.d.ts +1 -1
  182. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
  183. package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
  184. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
  185. package/dist/.pikku/secrets/index.d.ts +1 -1
  186. package/dist/.pikku/secrets/index.js +1 -1
  187. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  188. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  189. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  190. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  191. package/dist/.pikku/services/pikku-meta-service.gen.d.ts +1 -1
  192. package/dist/.pikku/services/pikku-meta-service.gen.js +1 -1
  193. package/dist/.pikku/setup/index.d.ts +1 -1
  194. package/dist/.pikku/setup/index.js +1 -1
  195. package/dist/.pikku/setup/pikku-setup-types.gen.d.ts +1 -1
  196. package/dist/.pikku/setup/pikku-setup-types.gen.js +1 -1
  197. package/dist/.pikku/trigger/index.d.ts +1 -1
  198. package/dist/.pikku/trigger/index.js +1 -1
  199. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  200. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  201. package/dist/.pikku/variables/index.d.ts +1 -1
  202. package/dist/.pikku/variables/index.js +1 -1
  203. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  204. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  205. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  206. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  207. package/dist/.pikku/workflow/index.d.ts +1 -1
  208. package/dist/.pikku/workflow/index.js +1 -1
  209. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
  210. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
  211. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  212. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  213. package/dist/bin/pikku-bin.mjs +2 -2
  214. package/dist/src/cli.wiring.js +47 -0
  215. package/dist/src/deploy/analyzer/analyzer.js +42 -6
  216. package/dist/src/deploy/build-pipeline.js +92 -4
  217. package/dist/src/deploy/codegen/per-unit-codegen.d.ts +10 -0
  218. package/dist/src/deploy/codegen/per-unit-codegen.js +12 -1
  219. package/dist/src/deploy/server-entry.js +14 -1
  220. package/dist/src/functions/commands/knowledge-plan.d.ts +112 -0
  221. package/dist/src/functions/commands/knowledge-plan.js +35 -0
  222. package/dist/src/functions/db/local-db.d.ts +1 -1
  223. package/dist/src/functions/db/local-db.js +5 -5
  224. package/dist/src/functions/db/postgres/postgres-introspector.js +1 -1
  225. package/dist/src/functions/db/sqlite/dev-seed.d.ts +1 -1
  226. package/dist/src/functions/db/sqlite/sqlite-introspector.d.ts +1 -1
  227. package/dist/src/functions/db/sqlite/sqlite-introspector.js +1 -1
  228. package/dist/src/functions/db/sqlite/sqlite-kysely.d.ts +1 -1
  229. package/dist/src/functions/knowledge/render.d.ts +6 -1
  230. package/dist/src/functions/knowledge/render.js +74 -0
  231. package/dist/src/functions/knowledge/schemas.d.ts +45 -0
  232. package/dist/src/functions/knowledge/schemas.js +11 -1
  233. package/dist/src/functions/surface/surface-editorial.js +12 -12
  234. package/dist/src/functions/validate/shared-checks.js +1 -1
  235. package/dist/src/functions/wirings/realtime/serialize-events-scaffold.d.ts +1 -1
  236. package/dist/src/functions/wirings/realtime/serialize-events-scaffold.js +2 -2
  237. package/dist/tsconfig.tsbuildinfo +1 -1
  238. package/package.json +11 -10
  239. package/surface.json +23 -29
  240. package/console-app/assets/architecture-TIHT7OUA-CWwmvxZF.js +0 -1
  241. package/console-app/assets/channel-pOkwZ_Ot.js +0 -1
  242. package/console-app/assets/chunk-XXDRQBXY-BU_UP6f5.js +0 -1
  243. package/console-app/assets/classDiagram-JCYQIIEL-CLBKUuxj.js +0 -1
  244. package/console-app/assets/classDiagram-v2-OCEON4UE-CLBKUuxj.js +0 -1
  245. package/console-app/assets/eventmodeling-45OFAUF4-DkN2KCrT.js +0 -1
  246. package/console-app/assets/flowDiagram-UKHOOZJN-DL0M9lBc.js +0 -1
  247. package/console-app/assets/railroad-abnf-AHOZXSZD-D26xz4MM.js +0 -1
  248. package/console-app/assets/railroad-ebnf-EBAXGLYW-CCAiMPWc.js +0 -1
  249. package/console-app/assets/railroad-peg-LSFZ7HO6-BA1zcisq.js +0 -1
  250. package/console-app/assets/stateDiagram-v2-UEYNNEHI-COVnPYic.js +0 -1
  251. package/console-app/assets/swimlanesDiagram-ULZ7WXOC-B5q8iRCQ.js +0 -8
  252. package/dist/src/functions/db/db-migrator.d.ts +0 -63
  253. package/dist/src/functions/db/db-migrator.js +0 -136
  254. package/dist/src/functions/db/migration-identifiers.d.ts +0 -58
  255. package/dist/src/functions/db/migration-identifiers.js +0 -262
  256. package/dist/src/functions/db/postgres/postgres-migrator.d.ts +0 -15
  257. package/dist/src/functions/db/postgres/postgres-migrator.js +0 -40
  258. package/dist/src/functions/db/schema-sql.d.ts +0 -43
  259. package/dist/src/functions/db/schema-sql.js +0 -135
  260. package/dist/src/functions/db/sqlite/sqlite-migrator.d.ts +0 -11
  261. package/dist/src/functions/db/sqlite/sqlite-migrator.js +0 -41
  262. package/dist/src/functions/db/sqlite/sqlite-runtime-bun.d.ts +0 -2
  263. package/dist/src/functions/db/sqlite/sqlite-runtime-bun.js +0 -62
  264. package/dist/src/functions/db/sqlite/sqlite-runtime-node.d.ts +0 -2
  265. package/dist/src/functions/db/sqlite/sqlite-runtime-node.js +0 -78
  266. package/dist/src/functions/db/sqlite/sqlite-runtime.d.ts +0 -20
  267. package/dist/src/functions/db/sqlite/sqlite-runtime.js +0 -13
@@ -1,63 +0,0 @@
1
- /**
2
- * The migrator's own bookkeeping table, which belongs to no dialect and to no
3
- * project's schema.
4
- *
5
- * Every introspector hides it for that reason. Leaving it visible on one
6
- * dialect and not the other is not cosmetic: a schema source exported from a
7
- * database that has been migrated would publish `sql_migrations` as one of its
8
- * own tables, and the consumer — which also has it — would then read the source
9
- * as partially covered and emit column deltas instead of the source's own SQL,
10
- * silently dropping its primary keys, indexes and constraints.
11
- */
12
- export declare const MIGRATION_TRACKING_TABLE = "sql_migrations";
13
- export declare class MigrationDriftError extends Error {
14
- readonly file: string;
15
- readonly recordedHash: string;
16
- readonly currentHash: string | null;
17
- readonly appliedAt: string;
18
- constructor(file: string, recordedHash: string, currentHash: string | null, appliedAt: string, migrationsDir: string);
19
- }
20
- export interface MigrateResult {
21
- applied: string[];
22
- skipped: string[];
23
- }
24
- export interface AppliedMigration {
25
- name: string;
26
- hash: string;
27
- applied_at: string;
28
- }
29
- /**
30
- * Provider-agnostic migration executor. Implement this for each DB dialect.
31
- * Each method maps to a single DB operation; all file I/O and hashing lives
32
- * in the shared `migrate()` function above.
33
- */
34
- export interface MigrationExecutor {
35
- ensureTrackingTable(): Promise<void>;
36
- getApplied(): Promise<AppliedMigration[]>;
37
- runMigration(sql: string, name: string, hash: string): Promise<void>;
38
- /**
39
- * Record a migration as applied without running its SQL.
40
- *
41
- * For a database that already contains what the migration describes, because
42
- * something created those tables before anyone wrote them down. Only ever
43
- * called once the caller has confirmed that is actually true — recording a
44
- * migration whose tables are absent leaves a database permanently behind with
45
- * no pending migration to reveal it.
46
- */
47
- recordMigration(name: string, hash: string): Promise<void>;
48
- }
49
- export declare function migrate(executor: MigrationExecutor, migrationsDir: string): Promise<MigrateResult>;
50
- /**
51
- * Record every pending migration as applied, without running any of it.
52
- *
53
- * The escape hatch for a database that already has the tables a migration
54
- * creates — the shape you get when a runtime bootstrapped its own schema at
55
- * boot and the migration writing it down was authored afterwards. Running that
56
- * migration would fail on every existing deployment; skipping it forever would
57
- * leave the history lying. Recording it says what is true.
58
- *
59
- * Deliberately unconditional here. Whether the database really does match is a
60
- * question about schemas, not migration files, so the caller answers it first
61
- * and this only runs once it has.
62
- */
63
- export declare function baselineMigrations(executor: MigrationExecutor, migrationsDir: string): Promise<string[]>;
@@ -1,136 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { existsSync, readFileSync, readdirSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { assertSnakeCaseIdentifiers } from './migration-identifiers.js';
5
- /**
6
- * The migrator's own bookkeeping table, which belongs to no dialect and to no
7
- * project's schema.
8
- *
9
- * Every introspector hides it for that reason. Leaving it visible on one
10
- * dialect and not the other is not cosmetic: a schema source exported from a
11
- * database that has been migrated would publish `sql_migrations` as one of its
12
- * own tables, and the consumer — which also has it — would then read the source
13
- * as partially covered and emit column deltas instead of the source's own SQL,
14
- * silently dropping its primary keys, indexes and constraints.
15
- */
16
- export const MIGRATION_TRACKING_TABLE = 'sql_migrations';
17
- export class MigrationDriftError extends Error {
18
- file;
19
- recordedHash;
20
- currentHash;
21
- appliedAt;
22
- constructor(file, recordedHash, currentHash, appliedAt, migrationsDir) {
23
- const onDisk = currentHash === null
24
- ? 'file missing on disk'
25
- : `sha256:${currentHash.slice(0, 8)}…`;
26
- super(`[PKU-DB-DRIFT] ${migrationsDir}/${file}\n\n` +
27
- `Migration content has changed since it was applied.\n` +
28
- ` recorded: sha256:${recordedHash.slice(0, 8)}… applied ${appliedAt}\n` +
29
- ` on disk: ${onDisk}\n\n` +
30
- `If this edit was intentional, write a new forward migration to revert the change.\n` +
31
- `Production migrations are immutable.`);
32
- this.file = file;
33
- this.recordedHash = recordedHash;
34
- this.currentHash = currentHash;
35
- this.appliedAt = appliedAt;
36
- this.name = 'MigrationDriftError';
37
- }
38
- }
39
- function sha256(bytes) {
40
- return createHash('sha256').update(bytes).digest('hex');
41
- }
42
- /**
43
- * Apply pending migrations from `migrationsDir/*.sql` using the supplied
44
- * executor. Hashes raw file bytes on apply; subsequent runs re-hash and bail
45
- * with `MigrationDriftError` if any applied file has changed on disk.
46
- */
47
- /**
48
- * The migrations on disk, or none.
49
- *
50
- * A project that has never generated a migration has no directory to read, and
51
- * that is the ordinary first-run state rather than a failure — it is precisely
52
- * the project `db generate` exists to serve.
53
- */
54
- const migrationFiles = (migrationsDir) => existsSync(migrationsDir)
55
- ? readdirSync(migrationsDir)
56
- .filter((f) => f.endsWith('.sql'))
57
- .sort()
58
- : [];
59
- /**
60
- * Re-hash every applied migration and bail if one has changed on disk.
61
- *
62
- * Applies to baselining as much as to migrating: recording a file as applied
63
- * only means anything if the file is still the one that was applied.
64
- */
65
- function assertNoDrift(applied, migrationsDir) {
66
- for (const row of applied) {
67
- let currentHash = null;
68
- try {
69
- currentHash = sha256(readFileSync(join(migrationsDir, row.name)));
70
- }
71
- catch {
72
- currentHash = null;
73
- }
74
- if (currentHash !== row.hash) {
75
- throw new MigrationDriftError(row.name, row.hash, currentHash, row.applied_at, migrationsDir);
76
- }
77
- }
78
- }
79
- /**
80
- * Every migration on disk, read once.
81
- *
82
- * The identifier check reads all of them and not just the pending ones, so that
83
- * whether a migration is rejected depends on the files alone. A camelCase
84
- * column that had already been applied somewhere would otherwise pass on that
85
- * machine and fail on a fresh checkout, which is the opposite of deterministic.
86
- */
87
- const readMigrations = (migrationsDir) => migrationFiles(migrationsDir).map((name) => ({
88
- name,
89
- sql: readFileSync(join(migrationsDir, name), 'utf8'),
90
- }));
91
- export async function migrate(executor, migrationsDir) {
92
- assertSnakeCaseIdentifiers(readMigrations(migrationsDir));
93
- await executor.ensureTrackingTable();
94
- const applied = await executor.getApplied();
95
- assertNoDrift(applied, migrationsDir);
96
- const appliedNames = new Set(applied.map((r) => r.name));
97
- const result = { applied: [], skipped: [] };
98
- for (const name of migrationFiles(migrationsDir)) {
99
- if (appliedNames.has(name)) {
100
- result.skipped.push(name);
101
- continue;
102
- }
103
- const raw = readFileSync(join(migrationsDir, name));
104
- const hash = sha256(raw);
105
- await executor.runMigration(raw.toString('utf8'), name, hash);
106
- result.applied.push(name);
107
- }
108
- return result;
109
- }
110
- /**
111
- * Record every pending migration as applied, without running any of it.
112
- *
113
- * The escape hatch for a database that already has the tables a migration
114
- * creates — the shape you get when a runtime bootstrapped its own schema at
115
- * boot and the migration writing it down was authored afterwards. Running that
116
- * migration would fail on every existing deployment; skipping it forever would
117
- * leave the history lying. Recording it says what is true.
118
- *
119
- * Deliberately unconditional here. Whether the database really does match is a
120
- * question about schemas, not migration files, so the caller answers it first
121
- * and this only runs once it has.
122
- */
123
- export async function baselineMigrations(executor, migrationsDir) {
124
- await executor.ensureTrackingTable();
125
- const applied = await executor.getApplied();
126
- assertNoDrift(applied, migrationsDir);
127
- const appliedNames = new Set(applied.map((r) => r.name));
128
- const recorded = [];
129
- for (const name of migrationFiles(migrationsDir)) {
130
- if (appliedNames.has(name))
131
- continue;
132
- await executor.recordMigration(name, sha256(readFileSync(join(migrationsDir, name))));
133
- recorded.push(name);
134
- }
135
- return recorded;
136
- }
@@ -1,58 +0,0 @@
1
- /**
2
- * Catching camelCase columns at migrate time, before they can half-work.
3
- *
4
- * Pikku's Kysely runs with `CamelCasePlugin`, so `priceCents` in TypeScript is
5
- * `price_cents` in SQL and nothing else. A migration that declares the column
6
- * *as* `priceCents` is not merely unconventional — it is broken in the one way
7
- * that hides itself: `.selectAll()` compiles to `SELECT *` and never names an
8
- * identifier, so the table reads back perfectly, while the first query that
9
- * names the column (`.select(['animal.priceCents'])`) asks for `price_cents`
10
- * and gets `no such column`. The usual conclusion is that the plugin is broken,
11
- * and the usual response is a raw `sql` template or a retreat to `.selectAll()`
12
- * — both of which keep the real cause alive.
13
- *
14
- * There is no exception to escape. Even the Better Auth schema `db generate`
15
- * writes is snake_case (`email_verified`, `user_id`), because Better Auth is
16
- * handed the app's own Kysely and its camelCase field names compile the same
17
- * way everyone else's do.
18
- */
19
- /** A camelCase identifier a migration declares, and what it should have said. */
20
- export interface CamelCaseIdentifier {
21
- file: string;
22
- table: string;
23
- /** `null` when the table name itself is the offender. */
24
- column: string | null;
25
- suggestion: string;
26
- }
27
- export declare class CamelCaseIdentifierError extends Error {
28
- readonly offenders: CamelCaseIdentifier[];
29
- constructor(offenders: CamelCaseIdentifier[]);
30
- }
31
- /**
32
- * Strip comments so a word in prose can never be read as an identifier.
33
- *
34
- * `splitStatements` already skips over comments when it looks for a boundary,
35
- * but it hands back the statement with them still in it, and `-- the userId
36
- * column` would otherwise be flagged. Quoting rules are honoured for the same
37
- * reason they are there: `'a -- b'` is a string, not a comment.
38
- */
39
- export declare function stripSqlComments(sql: string): string;
40
- /**
41
- * Every camelCase identifier one migration file declares.
42
- *
43
- * Only declarations are read — a `CREATE TABLE` column list and an `ALTER TABLE
44
- * … ADD COLUMN`. Everywhere else an identifier merely refers to something that
45
- * was declared somewhere, and reporting those would name the same mistake once
46
- * per reference while adding nothing to the fix.
47
- */
48
- export declare function findCamelCaseIdentifiers(file: string, sql: string): CamelCaseIdentifier[];
49
- /**
50
- * Bail unless every migration on disk is snake_case throughout.
51
- *
52
- * Reports all of them at once: a camelCase column is rarely alone, and a
53
- * one-at-a-time failure turns a single edit into one migrate run per column.
54
- */
55
- export declare function assertSnakeCaseIdentifiers(migrations: Array<{
56
- name: string;
57
- sql: string;
58
- }>): void;
@@ -1,262 +0,0 @@
1
- /**
2
- * Catching camelCase columns at migrate time, before they can half-work.
3
- *
4
- * Pikku's Kysely runs with `CamelCasePlugin`, so `priceCents` in TypeScript is
5
- * `price_cents` in SQL and nothing else. A migration that declares the column
6
- * *as* `priceCents` is not merely unconventional — it is broken in the one way
7
- * that hides itself: `.selectAll()` compiles to `SELECT *` and never names an
8
- * identifier, so the table reads back perfectly, while the first query that
9
- * names the column (`.select(['animal.priceCents'])`) asks for `price_cents`
10
- * and gets `no such column`. The usual conclusion is that the plugin is broken,
11
- * and the usual response is a raw `sql` template or a retreat to `.selectAll()`
12
- * — both of which keep the real cause alive.
13
- *
14
- * There is no exception to escape. Even the Better Auth schema `db generate`
15
- * writes is snake_case (`email_verified`, `user_id`), because Better Auth is
16
- * handed the app's own Kysely and its camelCase field names compile the same
17
- * way everyone else's do.
18
- */
19
- import { splitStatements } from './schema-sql.js';
20
- export class CamelCaseIdentifierError extends Error {
21
- offenders;
22
- constructor(offenders) {
23
- const lines = offenders.map((o) => ` ${o.file} ${o.column === null ? o.table : `${o.table}.${o.column}`} → ${o.suggestion}`);
24
- super(`[PKU-DB-CAMEL] Migrations declare camelCase identifiers.\n\n` +
25
- `Pikku's Kysely runs with CamelCasePlugin, which maps camelCase in TypeScript\n` +
26
- `to snake_case in SQL. A camelCase column half-works: \`.selectAll()\` emits\n` +
27
- `\`SELECT *\` so the table reads fine, but naming the column compiles it to\n` +
28
- `snake_case and the database answers \`no such column\`.\n\n` +
29
- `${lines.join('\n')}\n\n` +
30
- `Fix the column definition in the migration file itself and replay your dev\n` +
31
- `database from scratch. Do not write a RENAME COLUMN migration — that leaves\n` +
32
- `the banned identifier in a SQL file forever.`);
33
- this.offenders = offenders;
34
- this.name = 'CamelCaseIdentifierError';
35
- }
36
- }
37
- /**
38
- * Strip comments so a word in prose can never be read as an identifier.
39
- *
40
- * `splitStatements` already skips over comments when it looks for a boundary,
41
- * but it hands back the statement with them still in it, and `-- the userId
42
- * column` would otherwise be flagged. Quoting rules are honoured for the same
43
- * reason they are there: `'a -- b'` is a string, not a comment.
44
- */
45
- export function stripSqlComments(sql) {
46
- let out = '';
47
- let i = 0;
48
- while (i < sql.length) {
49
- const ch = sql[i];
50
- if (ch === "'" || ch === '"' || ch === '`') {
51
- const start = i;
52
- i++;
53
- while (i < sql.length) {
54
- if (sql[i] === '\\' && ch === "'") {
55
- i += 2;
56
- continue;
57
- }
58
- if (sql[i] === ch) {
59
- if (sql[i + 1] === ch) {
60
- i += 2;
61
- continue;
62
- }
63
- i++;
64
- break;
65
- }
66
- i++;
67
- }
68
- out += sql.slice(start, i);
69
- continue;
70
- }
71
- if (ch === '-' && sql[i + 1] === '-') {
72
- const end = sql.indexOf('\n', i);
73
- i = end === -1 ? sql.length : end;
74
- continue;
75
- }
76
- if (ch === '/' && sql[i + 1] === '*') {
77
- const end = sql.indexOf('*/', i + 2);
78
- i = end === -1 ? sql.length : end + 2;
79
- // A block comment can span lines, and removing it outright would join two
80
- // statements onto one line. A space keeps the tokens either side apart.
81
- out += ' ';
82
- continue;
83
- }
84
- out += ch;
85
- i++;
86
- }
87
- return out;
88
- }
89
- const IDENTIFIER = String.raw `"[^"]*"|\`[^\`]*\`|\[[^\]]*\]|[A-Za-z_][A-Za-z_0-9$]*`;
90
- const CREATE_TABLE = new RegExp(String.raw `^CREATE\s+(?:TEMP(?:ORARY)?\s+|UNLOGGED\s+)*TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(\S+?)\s*\(`, 'i');
91
- const ALTER_TABLE = new RegExp(String.raw `^ALTER\s+TABLE\s+(?:IF\s+EXISTS\s+)?(?:ONLY\s+)?(\S+)`, 'i');
92
- const ADD_COLUMN = new RegExp(String.raw `^\s*ADD\s+(?:COLUMN\s+)?(?:IF\s+NOT\s+EXISTS\s+)?(${IDENTIFIER})`, 'i');
93
- const COLUMN_NAME = new RegExp(String.raw `^\s*(${IDENTIFIER})`);
94
- /**
95
- * The words that open a table-level constraint rather than a column.
96
- *
97
- * Only consulted for an unquoted first token: `"check"` in quotes is a column
98
- * named check, however unwise, and skipping it would let `"checkedAt"`'s
99
- * neighbours hide behind it.
100
- */
101
- const CONSTRAINT_KEYWORDS = new Set([
102
- 'constraint',
103
- 'primary',
104
- 'foreign',
105
- 'unique',
106
- 'check',
107
- 'exclude',
108
- 'index',
109
- 'key',
110
- 'like',
111
- 'period',
112
- 'fulltext',
113
- 'spatial',
114
- ]);
115
- /** Drop the quoting a dialect happens to use, leaving the identifier itself. */
116
- const unquote = (name) => /^["`[]/.test(name) ? name.slice(1, -1) : name;
117
- const isCamelCase = (name) => /[a-z][A-Z]/.test(name);
118
- const toSnakeCase = (name) => name.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
119
- /**
120
- * Walk `sql` from `from` and return the offsets just inside and just outside
121
- * the parenthesised group that starts there, or `null` if it never closes.
122
- *
123
- * Quote-aware, because a `)` inside `DEFAULT ')'` closes nothing.
124
- */
125
- function parenSpan(sql, from) {
126
- let depth = 0;
127
- let i = from;
128
- while (i < sql.length) {
129
- const ch = sql[i];
130
- if (ch === "'" || ch === '"' || ch === '`') {
131
- i++;
132
- while (i < sql.length && sql[i] !== ch)
133
- i++;
134
- i++;
135
- continue;
136
- }
137
- if (ch === '(') {
138
- depth++;
139
- if (depth === 1)
140
- from = i + 1;
141
- }
142
- else if (ch === ')') {
143
- depth--;
144
- if (depth === 0)
145
- return { start: from, end: i };
146
- }
147
- i++;
148
- }
149
- return null;
150
- }
151
- /**
152
- * Split a definition list on the commas that separate its items.
153
- *
154
- * The commas inside `NUMERIC(10,2)`, a `CHECK (x IN ('a','b'))` or a compound
155
- * `PRIMARY KEY (a, b)` belong to those and not to the list, so only depth zero
156
- * counts.
157
- */
158
- function splitTopLevel(list) {
159
- const items = [];
160
- let depth = 0;
161
- let start = 0;
162
- let i = 0;
163
- while (i < list.length) {
164
- const ch = list[i];
165
- if (ch === "'" || ch === '"' || ch === '`') {
166
- i++;
167
- while (i < list.length && list[i] !== ch)
168
- i++;
169
- i++;
170
- continue;
171
- }
172
- if (ch === '(')
173
- depth++;
174
- else if (ch === ')')
175
- depth--;
176
- else if (ch === ',' && depth === 0) {
177
- items.push(list.slice(start, i));
178
- start = i + 1;
179
- }
180
- i++;
181
- }
182
- items.push(list.slice(start));
183
- return items.filter((item) => item.trim().length > 0);
184
- }
185
- /**
186
- * Every camelCase identifier one migration file declares.
187
- *
188
- * Only declarations are read — a `CREATE TABLE` column list and an `ALTER TABLE
189
- * … ADD COLUMN`. Everywhere else an identifier merely refers to something that
190
- * was declared somewhere, and reporting those would name the same mistake once
191
- * per reference while adding nothing to the fix.
192
- */
193
- export function findCamelCaseIdentifiers(file, sql) {
194
- const offenders = [];
195
- for (const statement of splitStatements(stripSqlComments(sql))) {
196
- const create = CREATE_TABLE.exec(statement);
197
- if (create) {
198
- const table = unquote(create[1].split('.').pop());
199
- if (isCamelCase(table)) {
200
- offenders.push({
201
- file,
202
- table,
203
- column: null,
204
- suggestion: toSnakeCase(table),
205
- });
206
- }
207
- const span = parenSpan(statement, create.index + create[0].length - 1);
208
- if (!span)
209
- continue;
210
- for (const item of splitTopLevel(statement.slice(span.start, span.end))) {
211
- const name = COLUMN_NAME.exec(item)?.[1];
212
- if (!name)
213
- continue;
214
- if (CONSTRAINT_KEYWORDS.has(name.toLowerCase()))
215
- continue;
216
- const column = unquote(name);
217
- if (isCamelCase(column)) {
218
- offenders.push({
219
- file,
220
- table,
221
- column,
222
- suggestion: toSnakeCase(column),
223
- });
224
- }
225
- }
226
- continue;
227
- }
228
- const alter = ALTER_TABLE.exec(statement);
229
- if (!alter)
230
- continue;
231
- const table = unquote(alter[1].split('.').pop());
232
- // Postgres lets one ALTER carry several actions, and only the ADDs declare.
233
- for (const action of splitTopLevel(statement.slice(alter[0].length).replace(/;\s*$/, ''))) {
234
- const name = ADD_COLUMN.exec(action)?.[1];
235
- if (!name)
236
- continue;
237
- if (CONSTRAINT_KEYWORDS.has(name.toLowerCase()))
238
- continue;
239
- const column = unquote(name);
240
- if (isCamelCase(column)) {
241
- offenders.push({
242
- file,
243
- table,
244
- column,
245
- suggestion: toSnakeCase(column),
246
- });
247
- }
248
- }
249
- }
250
- return offenders;
251
- }
252
- /**
253
- * Bail unless every migration on disk is snake_case throughout.
254
- *
255
- * Reports all of them at once: a camelCase column is rarely alone, and a
256
- * one-at-a-time failure turns a single edit into one migrate run per column.
257
- */
258
- export function assertSnakeCaseIdentifiers(migrations) {
259
- const offenders = migrations.flatMap(({ name, sql }) => findCamelCaseIdentifiers(name, sql));
260
- if (offenders.length > 0)
261
- throw new CamelCaseIdentifierError(offenders);
262
- }
@@ -1,15 +0,0 @@
1
- import type { MigrationExecutor, AppliedMigration } from '../db-migrator.js';
2
- export interface PostgresMigrationClient {
3
- query<T = unknown>(sql: string, params?: unknown[]): Promise<{
4
- rows: T[];
5
- }>;
6
- exec?(sql: string): Promise<unknown>;
7
- }
8
- export declare class PostgresMigrationExecutor implements MigrationExecutor {
9
- private readonly client;
10
- constructor(client: PostgresMigrationClient);
11
- ensureTrackingTable(): Promise<void>;
12
- getApplied(): Promise<AppliedMigration[]>;
13
- recordMigration(name: string, hash: string): Promise<void>;
14
- runMigration(sql: string, name: string, hash: string): Promise<void>;
15
- }
@@ -1,40 +0,0 @@
1
- import { MIGRATION_TRACKING_TABLE as TRACKING_TABLE } from '../db-migrator.js';
2
- export class PostgresMigrationExecutor {
3
- client;
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- async ensureTrackingTable() {
8
- await this.client.query(`
9
- CREATE TABLE IF NOT EXISTS ${TRACKING_TABLE} (
10
- name TEXT PRIMARY KEY,
11
- hash TEXT NOT NULL,
12
- applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
13
- )
14
- `);
15
- }
16
- async getApplied() {
17
- const { rows } = await this.client.query(`SELECT name, hash, applied_at FROM ${TRACKING_TABLE} ORDER BY name`);
18
- return rows;
19
- }
20
- async recordMigration(name, hash) {
21
- await this.client.query(`INSERT INTO ${TRACKING_TABLE} (name, hash) VALUES ($1, $2)`, [name, hash]);
22
- }
23
- async runMigration(sql, name, hash) {
24
- await this.client.query('BEGIN');
25
- try {
26
- if (typeof this.client.exec === 'function') {
27
- await this.client.exec(sql);
28
- }
29
- else {
30
- await this.client.query(sql);
31
- }
32
- await this.client.query(`INSERT INTO ${TRACKING_TABLE} (name, hash) VALUES ($1, $2)`, [name, hash]);
33
- await this.client.query('COMMIT');
34
- }
35
- catch (err) {
36
- await this.client.query('ROLLBACK');
37
- throw err;
38
- }
39
- }
40
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Reading a schema source's own SQL back out, one table at a time.
3
- *
4
- * A source hands `db generate` both what must exist (`tables`) and what creates
5
- * it (`sql`). The column map is a comparison surface — it answers "is this
6
- * table there, and does it have these columns" — and it is deliberately lossy:
7
- * primary keys, foreign keys, uniqueness, check constraints and indexes are all
8
- * absent from it. So the moment the generator has to *create* something, the
9
- * only honest source is the SQL, and this is what pulls the relevant part of it
10
- * out.
11
- */
12
- /**
13
- * Split a SQL script into its top-level statements, semicolons included.
14
- *
15
- * A naive `split(';')` is wrong in a way that only shows up later: a semicolon
16
- * inside a string literal, a quoted identifier or a comment is not a statement
17
- * boundary, and cutting there yields two fragments that are each valid-looking
18
- * and neither of which does what the original did.
19
- */
20
- export declare function splitStatements(sql: string): string[];
21
- /**
22
- * Reduce a written table name to the form two sources can be compared on.
23
- *
24
- * The same table is `two_factor` to one writer, `"two_factor"` to Kysely and
25
- * `public.two_factor` to Postgres introspection. Dropping the schema qualifier,
26
- * the quoting and the case is the only shape all three agree on.
27
- */
28
- export declare function bareTableName(name: string): string;
29
- /**
30
- * Every statement in `sql` that builds `table`, in the order the source wrote
31
- * them.
32
- *
33
- * The `CREATE TABLE` and its indexes, plus any `ALTER TABLE` the source uses to
34
- * hang a constraint on it afterwards — which together are what the column list
35
- * cannot express. Source order is preserved because it is load-bearing: an
36
- * index cannot precede its table, and a table cannot precede one it references.
37
- *
38
- * An empty result means the source's SQL does not visibly create the table.
39
- * That is a real answer rather than a failure — a source may create a table
40
- * from something other than a literal `CREATE TABLE` — and the caller is
41
- * expected to fall back rather than emit nothing.
42
- */
43
- export declare function tableCreationSql(sql: string, table: string): string[];