@intentius/sql-yodeler 0.0.0-stage → 0.1.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 (264) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +110 -2
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +14 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/chant/apply.d.ts +51 -0
  7. package/dist/chant/apply.js +104 -0
  8. package/dist/chant/apply.js.map +1 -0
  9. package/dist/chant/build.d.ts +34 -0
  10. package/dist/chant/build.js +48 -0
  11. package/dist/chant/build.js.map +1 -0
  12. package/dist/chant/drift.d.ts +44 -0
  13. package/dist/chant/drift.js +91 -0
  14. package/dist/chant/drift.js.map +1 -0
  15. package/dist/chant/plan.d.ts +45 -0
  16. package/dist/chant/plan.js +61 -0
  17. package/dist/chant/plan.js.map +1 -0
  18. package/dist/chant/process.d.ts +41 -0
  19. package/dist/chant/process.js +87 -0
  20. package/dist/chant/process.js.map +1 -0
  21. package/dist/cli.d.ts +4 -0
  22. package/dist/cli.js +59 -0
  23. package/dist/cli.js.map +1 -0
  24. package/dist/command.d.ts +17 -0
  25. package/dist/command.js +13 -0
  26. package/dist/command.js.map +1 -0
  27. package/dist/commands/apply.d.ts +3 -0
  28. package/dist/commands/apply.js +306 -0
  29. package/dist/commands/apply.js.map +1 -0
  30. package/dist/commands/drift.d.ts +3 -0
  31. package/dist/commands/drift.js +38 -0
  32. package/dist/commands/drift.js.map +1 -0
  33. package/dist/commands/index.d.ts +3 -0
  34. package/dist/commands/index.js +22 -0
  35. package/dist/commands/index.js.map +1 -0
  36. package/dist/commands/init.d.ts +3 -0
  37. package/dist/commands/init.js +135 -0
  38. package/dist/commands/init.js.map +1 -0
  39. package/dist/commands/lint.d.ts +3 -0
  40. package/dist/commands/lint.js +193 -0
  41. package/dist/commands/lint.js.map +1 -0
  42. package/dist/commands/new.d.ts +3 -0
  43. package/dist/commands/new.js +168 -0
  44. package/dist/commands/new.js.map +1 -0
  45. package/dist/commands/plan.d.ts +3 -0
  46. package/dist/commands/plan.js +171 -0
  47. package/dist/commands/plan.js.map +1 -0
  48. package/dist/commands/rebase.d.ts +3 -0
  49. package/dist/commands/rebase.js +167 -0
  50. package/dist/commands/rebase.js.map +1 -0
  51. package/dist/commands/repair.d.ts +3 -0
  52. package/dist/commands/repair.js +117 -0
  53. package/dist/commands/repair.js.map +1 -0
  54. package/dist/commands/status.d.ts +7 -0
  55. package/dist/commands/status.js +54 -0
  56. package/dist/commands/status.js.map +1 -0
  57. package/dist/config/define.d.ts +50 -0
  58. package/dist/config/define.js +20 -0
  59. package/dist/config/define.js.map +1 -0
  60. package/dist/config/index.d.ts +11 -0
  61. package/dist/config/index.js +12 -0
  62. package/dist/config/index.js.map +1 -0
  63. package/dist/config/load.d.ts +17 -0
  64. package/dist/config/load.js +102 -0
  65. package/dist/config/load.js.map +1 -0
  66. package/dist/config/settings.d.ts +40 -0
  67. package/dist/config/settings.js +88 -0
  68. package/dist/config/settings.js.map +1 -0
  69. package/dist/env-args.d.ts +18 -0
  70. package/dist/env-args.js +62 -0
  71. package/dist/env-args.js.map +1 -0
  72. package/dist/history/client.d.ts +17 -0
  73. package/dist/history/client.js +19 -0
  74. package/dist/history/client.js.map +1 -0
  75. package/dist/history/ddl.d.ts +58 -0
  76. package/dist/history/ddl.js +100 -0
  77. package/dist/history/ddl.js.map +1 -0
  78. package/dist/history/index.d.ts +25 -0
  79. package/dist/history/index.js +26 -0
  80. package/dist/history/index.js.map +1 -0
  81. package/dist/history/lock.d.ts +100 -0
  82. package/dist/history/lock.js +224 -0
  83. package/dist/history/lock.js.map +1 -0
  84. package/dist/history/postgres/ddl.d.ts +22 -0
  85. package/dist/history/postgres/ddl.js +47 -0
  86. package/dist/history/postgres/ddl.js.map +1 -0
  87. package/dist/history/postgres/index.d.ts +12 -0
  88. package/dist/history/postgres/index.js +13 -0
  89. package/dist/history/postgres/index.js.map +1 -0
  90. package/dist/history/postgres/lock.d.ts +48 -0
  91. package/dist/history/postgres/lock.js +95 -0
  92. package/dist/history/postgres/lock.js.map +1 -0
  93. package/dist/history/postgres/store.d.ts +39 -0
  94. package/dist/history/postgres/store.js +68 -0
  95. package/dist/history/postgres/store.js.map +1 -0
  96. package/dist/history/rows.d.ts +96 -0
  97. package/dist/history/rows.js +73 -0
  98. package/dist/history/rows.js.map +1 -0
  99. package/dist/history/store.d.ts +72 -0
  100. package/dist/history/store.js +134 -0
  101. package/dist/history/store.js.map +1 -0
  102. package/dist/history/topology.d.ts +41 -0
  103. package/dist/history/topology.js +54 -0
  104. package/dist/history/topology.js.map +1 -0
  105. package/dist/index.d.ts +10 -0
  106. package/dist/index.js +10 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/init/adopt.d.ts +70 -0
  109. package/dist/init/adopt.js +138 -0
  110. package/dist/init/adopt.js.map +1 -0
  111. package/dist/init/baseline.d.ts +61 -0
  112. package/dist/init/baseline.js +88 -0
  113. package/dist/init/baseline.js.map +1 -0
  114. package/dist/init/files.d.ts +23 -0
  115. package/dist/init/files.js +77 -0
  116. package/dist/init/files.js.map +1 -0
  117. package/dist/init/index.d.ts +16 -0
  118. package/dist/init/index.js +17 -0
  119. package/dist/init/index.js.map +1 -0
  120. package/dist/init/live.d.ts +28 -0
  121. package/dist/init/live.js +45 -0
  122. package/dist/init/live.js.map +1 -0
  123. package/dist/lint/check.d.ts +81 -0
  124. package/dist/lint/check.js +208 -0
  125. package/dist/lint/check.js.map +1 -0
  126. package/dist/lint/config.d.ts +21 -0
  127. package/dist/lint/config.js +43 -0
  128. package/dist/lint/config.js.map +1 -0
  129. package/dist/lint/index.d.ts +31 -0
  130. package/dist/lint/index.js +43 -0
  131. package/dist/lint/index.js.map +1 -0
  132. package/dist/lint/project-rules.d.ts +19 -0
  133. package/dist/lint/project-rules.js +32 -0
  134. package/dist/lint/project-rules.js.map +1 -0
  135. package/dist/lint/report.d.ts +7 -0
  136. package/dist/lint/report.js +48 -0
  137. package/dist/lint/report.js.map +1 -0
  138. package/dist/lint/rules.d.ts +53 -0
  139. package/dist/lint/rules.js +42 -0
  140. package/dist/lint/rules.js.map +1 -0
  141. package/dist/lint/silences.d.ts +49 -0
  142. package/dist/lint/silences.js +91 -0
  143. package/dist/lint/silences.js.map +1 -0
  144. package/dist/lint/statements.d.ts +38 -0
  145. package/dist/lint/statements.js +120 -0
  146. package/dist/lint/statements.js.map +1 -0
  147. package/dist/migrations/checksum.d.ts +56 -0
  148. package/dist/migrations/checksum.js +72 -0
  149. package/dist/migrations/checksum.js.map +1 -0
  150. package/dist/migrations/create.d.ts +73 -0
  151. package/dist/migrations/create.js +119 -0
  152. package/dist/migrations/create.js.map +1 -0
  153. package/dist/migrations/directory.d.ts +119 -0
  154. package/dist/migrations/directory.js +225 -0
  155. package/dist/migrations/directory.js.map +1 -0
  156. package/dist/migrations/document.d.ts +83 -0
  157. package/dist/migrations/document.js +82 -0
  158. package/dist/migrations/document.js.map +1 -0
  159. package/dist/migrations/index.d.ts +20 -0
  160. package/dist/migrations/index.js +21 -0
  161. package/dist/migrations/index.js.map +1 -0
  162. package/dist/pr/comment.d.ts +32 -0
  163. package/dist/pr/comment.js +99 -0
  164. package/dist/pr/comment.js.map +1 -0
  165. package/dist/pr/forge.d.ts +50 -0
  166. package/dist/pr/forge.js +105 -0
  167. package/dist/pr/forge.js.map +1 -0
  168. package/dist/pr/model.d.ts +91 -0
  169. package/dist/pr/model.js +113 -0
  170. package/dist/pr/model.js.map +1 -0
  171. package/dist/pr/render.d.ts +27 -0
  172. package/dist/pr/render.js +246 -0
  173. package/dist/pr/render.js.map +1 -0
  174. package/dist/project.d.ts +62 -0
  175. package/dist/project.js +92 -0
  176. package/dist/project.js.map +1 -0
  177. package/dist/rebase/index.d.ts +121 -0
  178. package/dist/rebase/index.js +390 -0
  179. package/dist/rebase/index.js.map +1 -0
  180. package/dist/rebase/repair.d.ts +41 -0
  181. package/dist/rebase/repair.js +68 -0
  182. package/dist/rebase/repair.js.map +1 -0
  183. package/dist/replay/clickhouse.d.ts +33 -0
  184. package/dist/replay/clickhouse.js +106 -0
  185. package/dist/replay/clickhouse.js.map +1 -0
  186. package/dist/replay/index.d.ts +36 -0
  187. package/dist/replay/index.js +54 -0
  188. package/dist/replay/index.js.map +1 -0
  189. package/dist/replay/postgres.d.ts +31 -0
  190. package/dist/replay/postgres.js +140 -0
  191. package/dist/replay/postgres.js.map +1 -0
  192. package/dist/replay/replay.d.ts +114 -0
  193. package/dist/replay/replay.js +98 -0
  194. package/dist/replay/replay.js.map +1 -0
  195. package/dist/replay/report.d.ts +18 -0
  196. package/dist/replay/report.js +72 -0
  197. package/dist/replay/report.js.map +1 -0
  198. package/dist/steps/backfill.d.ts +128 -0
  199. package/dist/steps/backfill.js +307 -0
  200. package/dist/steps/backfill.js.map +1 -0
  201. package/dist/steps/index.d.ts +52 -0
  202. package/dist/steps/index.js +52 -0
  203. package/dist/steps/index.js.map +1 -0
  204. package/dist/steps/kinds.d.ts +101 -0
  205. package/dist/steps/kinds.js +143 -0
  206. package/dist/steps/kinds.js.map +1 -0
  207. package/dist/steps/postgres-migration.d.ts +95 -0
  208. package/dist/steps/postgres-migration.js +149 -0
  209. package/dist/steps/postgres-migration.js.map +1 -0
  210. package/dist/steps/rebuild.d.ts +97 -0
  211. package/dist/steps/rebuild.js +162 -0
  212. package/dist/steps/rebuild.js.map +1 -0
  213. package/dist/steps/run.d.ts +45 -0
  214. package/dist/steps/run.js +72 -0
  215. package/dist/steps/run.js.map +1 -0
  216. package/dist/topology/render.d.ts +17 -0
  217. package/dist/topology/render.js +17 -0
  218. package/dist/topology/render.js.map +1 -0
  219. package/dist/version.d.ts +2 -0
  220. package/dist/version.js +11 -0
  221. package/dist/version.js.map +1 -0
  222. package/dist/versioned/approval.d.ts +35 -0
  223. package/dist/versioned/approval.js +53 -0
  224. package/dist/versioned/approval.js.map +1 -0
  225. package/dist/versioned/clickhouse.d.ts +24 -0
  226. package/dist/versioned/clickhouse.js +34 -0
  227. package/dist/versioned/clickhouse.js.map +1 -0
  228. package/dist/versioned/digest.d.ts +77 -0
  229. package/dist/versioned/digest.js +69 -0
  230. package/dist/versioned/digest.js.map +1 -0
  231. package/dist/versioned/driver.d.ts +41 -0
  232. package/dist/versioned/driver.js +13 -0
  233. package/dist/versioned/driver.js.map +1 -0
  234. package/dist/versioned/engine.d.ts +152 -0
  235. package/dist/versioned/engine.js +277 -0
  236. package/dist/versioned/engine.js.map +1 -0
  237. package/dist/versioned/explain.d.ts +123 -0
  238. package/dist/versioned/explain.js +289 -0
  239. package/dist/versioned/explain.js.map +1 -0
  240. package/dist/versioned/index.d.ts +37 -0
  241. package/dist/versioned/index.js +54 -0
  242. package/dist/versioned/index.js.map +1 -0
  243. package/dist/versioned/op.d.ts +62 -0
  244. package/dist/versioned/op.js +153 -0
  245. package/dist/versioned/op.js.map +1 -0
  246. package/dist/versioned/postgres/catalog.d.ts +33 -0
  247. package/dist/versioned/postgres/catalog.js +34 -0
  248. package/dist/versioned/postgres/catalog.js.map +1 -0
  249. package/dist/versioned/postgres/driver.d.ts +69 -0
  250. package/dist/versioned/postgres/driver.js +113 -0
  251. package/dist/versioned/postgres/driver.js.map +1 -0
  252. package/dist/versioned/postgres/executor.d.ts +104 -0
  253. package/dist/versioned/postgres/executor.js +172 -0
  254. package/dist/versioned/postgres/executor.js.map +1 -0
  255. package/dist/versioned/postgres/index.d.ts +11 -0
  256. package/dist/versioned/postgres/index.js +12 -0
  257. package/dist/versioned/postgres/index.js.map +1 -0
  258. package/dist/versioned/report.d.ts +22 -0
  259. package/dist/versioned/report.js +81 -0
  260. package/dist/versioned/report.js.map +1 -0
  261. package/dist/versioned/state.d.ts +108 -0
  262. package/dist/versioned/state.js +153 -0
  263. package/dist/versioned/state.js.map +1 -0
  264. package/package.json +51 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,111 @@
1
- # Temporary Holding Version
1
+ # SQL Yodeler
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Schema management and migrations for ClickHouse and Postgres, on chant's `sql` lexicon. `design/README.md` is the design, and `research/` holds the reports it is based on.
4
+
5
+ ## Documentation
6
+
7
+ [`docs/`](docs/README.md) covers installing (the package is not on npm; it installs from git, which needs read access to this private repository, or from a clone or a packed tarball), [starting a project](docs/adoption.md) from a template or with `yodel init --from`, [the declarative and versioned workflows](docs/workflows.md), [migrations](docs/migrations.md), [steps](docs/steps.md), [lint](docs/lint.md), [approval](docs/approval.md), [drift](docs/drift.md) and [topology](docs/topology.md).
8
+
9
+ [`examples/clickhouse`](examples/clickhouse/README.md) and [`examples/postgres`](examples/postgres/README.md) are example projects, each with a transcript of a run against chant's emulator.
10
+
11
+ ## Starting a project
12
+
13
+ `templates/clickhouse` and `templates/postgres` are starter projects for `chant init --from`:
14
+
15
+ ```sh
16
+ chant init --from INTENTIUS/sql-yodeler@main#templates/clickhouse --param name=events-schema --param database=events my-schema
17
+ chant init --from INTENTIUS/sql-yodeler@main#templates/postgres --param name=app-schema --param schema=app my-schema
18
+ ```
19
+
20
+ Each gives `chant.config.ts` with a profile per environment (`dev`, `prod`), `yodel.config.ts`, a migrate Op per environment (`yodel apply` behind a gate bound to the plan digest), a `WatchOp` per environment for drift on a schedule, and pipelines for GitHub Actions, GitLab CI and Forgejo Actions: `yodel lint` and the plan comment on pull requests with read-only credentials, `yodel apply` on a push to main with the writer, and the drift watch on its cron with the reader. `scripts/ci.ts` in the project renders the pipelines again after an environment is added (`npm run ci`). The parameters are in each template's `chant.template.json`; the template's README covers the credentials and each forge's setup.
21
+
22
+ ## Development
23
+
24
+ Node 22 (`.nvmrc`).
25
+
26
+ ```sh
27
+ npm ci
28
+ npm run build
29
+ npx yodel --help
30
+ npm run check # typecheck, lint and test
31
+ ```
32
+
33
+ Working rules are in `AGENTS.md`.
34
+
35
+ ## Versioned migrations (ClickHouse)
36
+
37
+ `yodel apply <env>` takes the versioned path when the project has a `migrations/` directory holding at least one migration (`yodel new` writes them); otherwise it is the declarative path, unchanged. `yodel status <env>` lists applied, pending, out-of-order and part-way migrations and checksum mismatches (`--json`; exit 0 up to date, 3 pending, 4 mismatch or out of order, 2 an Op step, 1 error).
38
+
39
+ `yodel init --from <env>` adopts an existing database: it reads it with chant's import (`chant import --from`), writes the declarations to `src/`, checks they plan clean, writes the baseline migration (the first one, creating everything) and records it applied in the history without running it (a succeeded migration row whose `note` starts `baseline:`). It needs a `chant.config.ts` with `sql.profiles.<env>` already, and for ClickHouse the profile's `databases`; `yodel init --help` has the rest. On Postgres it does the same, recording the baseline in `<history schema>.history`.
40
+
41
+ The history is an append-only table, `<db>.history`, one row per migration and per statement event, never updated or deleted.
42
+
43
+ ### yodel.config.ts
44
+
45
+ An optional `yodel.config.ts` next to `chant.config.ts` sets what chant's config does not, per environment (by its `sql.profiles` name):
46
+
47
+ ```ts
48
+ // yodel.config.ts
49
+ import { defineConfig } from "@intentius/sql-yodeler";
50
+
51
+ export default defineConfig({
52
+ environments: {
53
+ dev: { topology: "single" },
54
+ staging: { topology: "replicated" },
55
+ prod: { topology: "cluster:main", history: { database: "yodeler" }, lockTtl: 1800 },
56
+ },
57
+ });
58
+ ```
59
+
60
+ - `topology`: `single` (a single node), `cluster:<name>` (`ON CLUSTER <name>`, `Replicated*MergeTree` with a Keeper path), `replicated` or `replicated:<cluster>` (a `Replicated` database: no `ON CLUSTER`, `Replicated*MergeTree` with no arguments), or `cloud` (no `ON CLUSTER`, plain MergeTree, which Cloud makes `SharedMergeTree`). The object form, `{ kind: "cluster", cluster: "main", replicaPath, replicaName }`, sets the Keeper path and replica name of the tables the migrations create. Order: `yodel.config.ts`, then `sql.profiles.<env>.topology` in chant.config.ts, then `YODEL_TOPOLOGY`, then `single`.
61
+ - `history.database`: the database for the history and the lock. Then `YODEL_HISTORY_DATABASE`, then `yodeler`.
62
+ - `lockTtl`: the apply lock's TTL in seconds. Then `YODEL_LOCK_TTL`, then 900.
63
+
64
+ One migrations directory serves every topology. `yodel new` writes each statement for a single node and records nothing about where it runs; `yodel apply` renders each statement for the environment's topology as it sends it (chant's `renderStatement`). The history records a statement by the hash of the statement as written, so a migration that failed part way resumes the same way on any topology, and the statement row's `note` says the topology it was sent for (`topology=cluster:main`). The plan digest covers the topology, so an approval given for one topology does not apply on another. The history table's own engine follows the topology too: MergeTree on a single node and on Cloud, `ReplicatedMergeTree` `ON CLUSTER` on a cluster (one copy for the whole cluster), `ReplicatedMergeTree` inside a `Replicated` database. `yodel status` and `yodel plan` print the topology and where it came from.
65
+
66
+ The declarative path (no `migrations/`) plans and applies through chant, which reads `sql.profiles.<env>.topology` only, so a topology set in `yodel.config.ts` alone is refused there; set it in chant.config.ts as well. A rebuild step (`ClickHouseRebuildOp`) runs through chant too, but yodel hands its activities the environment's topology, so it renders for the same topology as the statements around it.
67
+
68
+ One apply runs at a time: the lock is a row in a KeeperMap table, `<db>.lock`, which needs Keeper and `keeper_map_path_prefix` on the server. A single node without them gets a lock file on the runner's machine, and the run says cross-runner locking needs Keeper. A lock left by a dead runner expires; to clear it sooner, once you know nothing is applying: `ALTER TABLE <db>.lock DELETE WHERE name = 'apply'` (or remove the lock file the refusal names).
69
+
70
+ The apply runs as a chant Op behind a gate bound to the plan digest (the pending migrations' checksums, the history and the live schema). `yodel apply <env>` prints the declaration to add when there is none:
71
+
72
+ ```ts
73
+ // ops/migrate-prod.op.ts
74
+ import { Op, phase, gate, shell, stepOutput } from "@intentius/chant/op";
75
+
76
+ const plan = shell("yodel apply prod --digest", { id: "plan" });
77
+ const digest = stepOutput(plan, "stdout");
78
+
79
+ export const op = Op({
80
+ name: "migrate-prod",
81
+ overview: "Apply the pending migrations to prod, behind an approval bound to their plan digest",
82
+ phases: [
83
+ phase("Plan", [plan]),
84
+ phase("Approve", [gate("approve-migrate-prod", { plan: digest })]),
85
+ phase("Apply", [shell("yodel apply prod --execute", { env: { YODEL_APPROVED_PLAN: digest }, timeout: "2h" })]),
86
+ ],
87
+ });
88
+ ```
89
+
90
+ `yodel apply prod` stops at the gate and prints `chant approve migrate-prod approve-migrate-prod --plan <digest>`; approve, then run it again. `yodel apply prod --plan` prints the pending migrations and the digest without applying. Running `chant run migrate-prod` directly needs `yodel` on PATH.
91
+
92
+ ## yodel lint
93
+
94
+ `yodel lint` checks the migrations directory offline, with no server, so it runs in CI on every pull request. Every rule is free. Exit 0 when there is no error (warnings and silenced findings do not fail), 3 when there is at least one, 1 when lint cannot run; `--json` prints the findings.
95
+
96
+ - Integrity, always errors: `fork` (two migrations follow the same parent; `yodel rebase`), `directory` (a bad name or file, a missing parent, a cycle, another dialect), `checksum` (a migration's files changed since it was written), `unreadable-object` (an object in a recorded schema, or a step, the sql lexicon cannot read or classify; never skipped).
97
+ - From the classifier's classes: `destructive` (a drop), `pg-rewrite` (a rewrite or full scan under ACCESS EXCLUSIVE), `pg-lock` (writes blocked for a whole index build or scan: no `CONCURRENTLY`, a constraint validated in place), `ch-mutation` (a mutation rewriting parts), `ch-rebuild` (a `ClickHouseRebuildOp` step).
98
+ - `refused-step` (a step `yodel apply` will not run), `migration-sql` (migration.sql does not hold a statement migration.json records), `silence` (a bad or unused `yodel:allow` line).
99
+
100
+ A line above a statement in its `migration.sql` silences one of the classifier rules for that statement:
101
+
102
+ ```sql
103
+ -- yodel:allow destructive the column was never read; checked in prod 2026-10-08
104
+ ALTER TABLE `db`.`events` DROP COLUMN `legacy`;
105
+ ```
106
+
107
+ The reason is required. `yodel apply` records each silence (step, rule, reason) in every history row the migration writes, in the `silences` column. The line changes the migration's checksum, so record the new one with `yodel lint --update-checksum <id>` while it is applied nowhere.
108
+
109
+ `yodel lint --env <env>` also reads the environment's history: an applied migration whose files changed since it ran is a `checksum` error, a pending migration's edit a warning. `yodel.config.ts` sets rule levels: `lint: { rules: { "ch-mutation": "warning", "pg-lock": "off" } }`; the integrity rules cannot be lowered. `yodel lint --rules` lists the rules and their levels.
110
+
111
+ `yodel lint --replay <env>` also replays every migration, in order, into `<env>`'s server (a throwaway emulator, `chant emulator up --lexicon sql`) and compares each with its recorded schema; the first that differs fails the run (rule `replay`, exit 3), named. The databases or schemas the history names must not exist there yet: otherwise it exits 4 and runs nothing, unless `--reset`, which drops them first (never point it at a server whose data matters). `--keep` leaves the replayed database in place to look at.
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ // Published chant and its sql lexicon ship TypeScript source (their exports'
3
+ // "default" condition is ./src/*.ts), and chant evaluates the project's
4
+ // chant.config.ts and *.op.ts in this process. Register tsx's loader before
5
+ // anything imports them, the way chant's own bin runs under tsx.
6
+ import { register } from "tsx/esm/api";
7
+ register();
8
+ const { main } = await import("./cli.js");
9
+ const code = await main(process.argv.slice(2), {
10
+ out: (text) => process.stdout.write(text),
11
+ err: (text) => process.stderr.write(text),
12
+ });
13
+ process.exitCode = code;
14
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,6EAA6E;AAC7E,wEAAwE;AACxE,4EAA4E;AAC5E,iEAAiE;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,QAAQ,EAAE,CAAC;AACX,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;AAE1C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC7C,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IACzC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;CAC1C,CAAC,CAAC;AACH,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Applying through the project's own `ApplyOp`: yodel finds the Op that
3
+ * applies the environment's build (`nativeApply` with `target: "clickhouse"`
4
+ * or `"postgres"` and that `env`), and runs it with `chant run`. The Op's
5
+ * gate is bound to its Plan phase's digest, so an approval given for one
6
+ * change set never applies another; yodel never resolves the gate itself.
7
+ * `chant approve <op> <gate> --plan <digest>` does, and the next run walks
8
+ * through it.
9
+ */
10
+ import type { OpConfig } from "@intentius/chant/op/types";
11
+ import { type Environment, type Project, type SqlDialect } from "../project.js";
12
+ /** The ApplyOp yodel runs for an environment. */
13
+ export interface ApplyOpRef {
14
+ name: string;
15
+ filePath: string;
16
+ target: SqlDialect;
17
+ /** The gate step's name. */
18
+ gate: string;
19
+ }
20
+ /** How to declare the ApplyOp yodel looks for. */
21
+ export declare function applyOpExample(env: string, dialect: SqlDialect): string;
22
+ /**
23
+ * Picks the ApplyOp for `env` from discovered Ops. Pure: takes the Ops as
24
+ * `chant run` would discover them. `name` picks one when several apply the
25
+ * same environment. An Op without a plan-bound gate is refused.
26
+ */
27
+ export declare function selectApplyOp(ops: ReadonlyMap<string, {
28
+ config: OpConfig;
29
+ filePath: string;
30
+ }>, project: Project, env: Environment, name?: string): ApplyOpRef;
31
+ /** Discovers the project's Ops the way `chant run` does and picks the ApplyOp for `env`. */
32
+ export declare function findApplyOp(project: Project, env: Environment, name?: string): Promise<ApplyOpRef>;
33
+ /** `chant run`'s exit code for a run that stopped at its gate. */
34
+ export declare const GATED = 3;
35
+ export type ApplyRunStatus = "applied" | "gated" | "failed";
36
+ export interface ApplyRun {
37
+ status: ApplyRunStatus;
38
+ code: number;
39
+ /** The `chant approve ...` command chant printed for a gated run. */
40
+ approve?: string;
41
+ /** The plan digest the gate is waiting on. */
42
+ planDigest?: string;
43
+ output: string;
44
+ }
45
+ /** What a `chant run` of an ApplyOp says about its outcome. */
46
+ export declare function readApplyRun(code: number, output: string): ApplyRun;
47
+ /** Runs the ApplyOp with `chant run <op>`, its output passed to `onOutput` as it arrives. */
48
+ export declare function runApplyOp(project: Project, op: ApplyOpRef, options?: {
49
+ env?: NodeJS.ProcessEnv;
50
+ onOutput?: (text: string) => void;
51
+ }): Promise<ApplyRun>;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Applying through the project's own `ApplyOp`: yodel finds the Op that
3
+ * applies the environment's build (`nativeApply` with `target: "clickhouse"`
4
+ * or `"postgres"` and that `env`), and runs it with `chant run`. The Op's
5
+ * gate is bound to its Plan phase's digest, so an approval given for one
6
+ * change set never applies another; yodel never resolves the gate itself.
7
+ * `chant approve <op> <gate> --plan <digest>` does, and the next run walks
8
+ * through it.
9
+ */
10
+ import { YodelError } from "../project.js";
11
+ import { runChant } from "./process.js";
12
+ const steps = (config) => config.phases.flatMap((p) => p.steps);
13
+ /** The environment and target a `nativeApply` step applies, when the Op has one. */
14
+ function nativeApplyOf(config) {
15
+ for (const step of steps(config)) {
16
+ if (step.kind === "activity" && step.fn === "nativeApply")
17
+ return step.args;
18
+ }
19
+ return undefined;
20
+ }
21
+ /** The gate the Op stops at, when it is bound to a plan (`plan` set, as ApplyOp sets it). */
22
+ function planBoundGate(config) {
23
+ for (const step of steps(config)) {
24
+ if (step.kind === "gate" && step.plan !== undefined)
25
+ return step.gate;
26
+ }
27
+ return undefined;
28
+ }
29
+ /** How to declare the ApplyOp yodel looks for. */
30
+ export function applyOpExample(env, dialect) {
31
+ return [
32
+ `// ops/apply-${env}.op.ts`,
33
+ `import { ApplyOp } from "@intentius/chant/op";`,
34
+ ``,
35
+ `export const { op } = ApplyOp({ name: "apply-${env}", env: "${env}", target: "${dialect}", gate: {} });`,
36
+ ].join("\n");
37
+ }
38
+ /**
39
+ * Picks the ApplyOp for `env` from discovered Ops. Pure: takes the Ops as
40
+ * `chant run` would discover them. `name` picks one when several apply the
41
+ * same environment. An Op without a plan-bound gate is refused.
42
+ */
43
+ export function selectApplyOp(ops, project, env, name) {
44
+ const candidates = [...ops.values()].filter((o) => {
45
+ const apply = nativeApplyOf(o.config);
46
+ return apply?.env === env.name && (apply.target === "clickhouse" || apply.target === "postgres");
47
+ });
48
+ const chosen = name ? candidates.filter((o) => o.config.name === name) : candidates;
49
+ if (chosen.length === 0) {
50
+ if (name && ops.has(name))
51
+ throw new YodelError(`Op "${name}" is not an ApplyOp for environment ${env.name} with target clickhouse or postgres`);
52
+ throw new YodelError(name
53
+ ? `no Op named "${name}" in ${project.dir}`
54
+ : `no ApplyOp applies environment ${env.name} in ${project.dir}; declare one, for example:\n\n${applyOpExample(env.name, project.dialect)}`);
55
+ }
56
+ if (chosen.length > 1) {
57
+ throw new YodelError(`${String(chosen.length)} Ops apply environment ${env.name} (${chosen.map((o) => o.config.name).join(", ")}); pick one with --op <name>`);
58
+ }
59
+ const [op] = chosen;
60
+ const target = nativeApplyOf(op.config)?.target;
61
+ if (target !== project.dialect) {
62
+ throw new YodelError(`Op "${op.config.name}" applies target ${target}, but the project's dialect is ${project.dialect}`);
63
+ }
64
+ const gate = planBoundGate(op.config);
65
+ if (!gate) {
66
+ throw new YodelError(`Op "${op.config.name}" (${op.filePath}) has no approval gate bound to its plan, and yodel only applies behind one; ` +
67
+ `give the ApplyOp a gate (gate: {}) or delete: "gated"`);
68
+ }
69
+ return { name: op.config.name, filePath: op.filePath, target, gate };
70
+ }
71
+ /** Discovers the project's Ops the way `chant run` does and picks the ApplyOp for `env`. */
72
+ export async function findApplyOp(project, env, name) {
73
+ const { discoverOps } = await import("@intentius/chant/op/discover");
74
+ let found;
75
+ try {
76
+ found = await discoverOps({ cwd: project.dir });
77
+ }
78
+ catch (e) {
79
+ throw new YodelError(`could not discover Ops in ${project.dir}: ${e instanceof Error ? e.message : String(e)}`);
80
+ }
81
+ if (found.errors.length > 0 && found.ops.size === 0) {
82
+ throw new YodelError(`could not discover Ops in ${project.dir}:\n${found.errors.join("\n")}`);
83
+ }
84
+ return selectApplyOp(found.ops, project, env, name);
85
+ }
86
+ /** `chant run`'s exit code for a run that stopped at its gate. */
87
+ export const GATED = 3;
88
+ /** What a `chant run` of an ApplyOp says about its outcome. */
89
+ export function readApplyRun(code, output) {
90
+ const status = code === 0 ? "applied" : code === GATED ? "gated" : "failed";
91
+ const approve = /^\s*approve\s*:\s*(chant approve .+?)\s*$/m.exec(output)?.[1];
92
+ const planDigest = /^\s*plan\s*:\s*(\S+)\s*$/m.exec(output)?.[1];
93
+ return { status, code, ...(approve ? { approve } : {}), ...(planDigest ? { planDigest } : {}), output };
94
+ }
95
+ /** Runs the ApplyOp with `chant run <op>`, its output passed to `onOutput` as it arrives. */
96
+ export async function runApplyOp(project, op, options = {}) {
97
+ const result = await runChant(["run", op.name, "--gated-exit", String(GATED)], {
98
+ cwd: project.dir,
99
+ ...(options.env ? { env: options.env } : {}),
100
+ ...(options.onOutput ? { onStdout: options.onOutput, onStderr: options.onOutput } : {}),
101
+ });
102
+ return readApplyRun(result.code, `${result.stdout}\n${result.stderr}`);
103
+ }
104
+ //# sourceMappingURL=apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/chant/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,UAAU,EAAmD,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAWxC,MAAM,KAAK,GAAG,CAAC,MAAgB,EAAoB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAE5F,oFAAoF;AACpF,SAAS,aAAa,CAAC,MAAgB;IACrC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,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AO,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Building the declared schema: `chant build <sourceDir> --lexicon sql`, the
3
+ * same build the project's ApplyOp runs, written to a file the planner reads.
4
+ */
5
+ import { type Project, type SqlDialect } from "../project.js";
6
+ /** One declared object as the sql lexicon's build output holds it. */
7
+ export interface BuiltObject {
8
+ export: string;
9
+ type?: string;
10
+ ddl: string;
11
+ dependsOn?: string[];
12
+ }
13
+ /** The sql lexicon's build output (`dist/schema.json`). */
14
+ export interface BuildOutput {
15
+ dialect: SqlDialect;
16
+ objects: BuiltObject[];
17
+ [key: string]: unknown;
18
+ }
19
+ export interface Build {
20
+ /** The build output file. */
21
+ path: string;
22
+ output: BuildOutput;
23
+ /** Removes the file and its directory, when yodel made them. */
24
+ dispose: () => void;
25
+ }
26
+ /**
27
+ * Builds the project's declared schema. Writes to `out` when given, else to
28
+ * a temporary directory that {@link Build.dispose} removes. A build that
29
+ * fails, or that holds another dialect than the project's, is an error.
30
+ */
31
+ export declare function buildSchema(project: Project, options?: {
32
+ out?: string;
33
+ env?: NodeJS.ProcessEnv;
34
+ }): Promise<Build>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Building the declared schema: `chant build <sourceDir> --lexicon sql`, the
3
+ * same build the project's ApplyOp runs, written to a file the planner reads.
4
+ */
5
+ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
6
+ import { tmpdir } from "node:os";
7
+ import { join } from "node:path";
8
+ import { YodelError } from "../project.js";
9
+ import { runChant } from "./process.js";
10
+ /**
11
+ * Builds the project's declared schema. Writes to `out` when given, else to
12
+ * a temporary directory that {@link Build.dispose} removes. A build that
13
+ * fails, or that holds another dialect than the project's, is an error.
14
+ */
15
+ export async function buildSchema(project, options = {}) {
16
+ const tmp = options.out ? undefined : mkdtempSync(join(tmpdir(), "yodel-build-"));
17
+ const path = options.out ?? join(tmp ?? ".", "schema.json");
18
+ const dispose = () => {
19
+ if (tmp)
20
+ rmSync(tmp, { recursive: true, force: true });
21
+ };
22
+ try {
23
+ const result = await runChant(["build", project.sourceDir, "--lexicon", "sql", "-o", path], {
24
+ cwd: project.dir,
25
+ ...(options.env ? { env: options.env } : {}),
26
+ });
27
+ if (result.code !== 0) {
28
+ const detail = (result.stderr || result.stdout).trim();
29
+ throw new YodelError(`chant build failed in ${project.dir}${detail ? `:\n${detail}` : ""}`);
30
+ }
31
+ let output;
32
+ try {
33
+ output = JSON.parse(readFileSync(path, "utf8"));
34
+ }
35
+ catch (e) {
36
+ throw new YodelError(`chant build wrote no readable output at ${path}: ${e instanceof Error ? e.message : String(e)}`);
37
+ }
38
+ if (output.dialect !== project.dialect) {
39
+ throw new YodelError(`the build holds ${output.dialect} objects, but the project's dialect is ${project.dialect}`);
40
+ }
41
+ return { path, output, dispose };
42
+ }
43
+ catch (e) {
44
+ dispose();
45
+ throw e;
46
+ }
47
+ }
48
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/chant/build.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAiC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAyBxC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAgB,EAAE,UAAqD,EAAE;IACzG,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,MAA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AC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzH,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;YACvC,MAAM,IAAI,UAAU,CAAC,mBAAmB,MAAM,CAAC,OAAO,0CAA0C,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACrH,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACnC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;QACV,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Drift: the declared objects whose live definition changed out of band, or
3
+ * that are gone from the server. Read from `chant lifecycle diff <env> --live
4
+ * --json`, the sql lexicon's section of it:
5
+ *
6
+ * - `deep.drifted[].changes[]`: a declared object whose live definition
7
+ * differs, property by property, declared against live;
8
+ * - `resources.missing`: a declared object the server does not have;
9
+ * - `resources.unobserved` and `deep.unobserved`: a declared object chant
10
+ * could not read (no credentials, a kind it cannot observe). Not drift, and
11
+ * not clean either: that part of the environment is unknown.
12
+ *
13
+ * An object the project does not declare is never reported: chant only reads
14
+ * what the project declares, and only touches what carries its marker.
15
+ */
16
+ import type { LiveDiffResult, UnobservedResource } from "@intentius/chant/lifecycle/live-diff";
17
+ import type { DeepDiffResult, DeepEntityDrift } from "@intentius/chant/lifecycle/deep-diff";
18
+ import { type Environment, type Project } from "../project.js";
19
+ /** The `lexicons.sql` section of `chant lifecycle diff --live --json`. */
20
+ export interface SqlLiveDiff {
21
+ resources?: LiveDiffResult;
22
+ deep?: DeepDiffResult;
23
+ }
24
+ export interface Drift {
25
+ environment: string;
26
+ /** Declared objects whose live definition differs from the declaration. */
27
+ changed: DeepEntityDrift[];
28
+ /** Declared objects the server does not have. */
29
+ missing: string[];
30
+ /** Declared objects chant could not read. */
31
+ unobserved: UnobservedResource[];
32
+ }
33
+ /** Exit code: an owned object changed or is gone. */
34
+ export declare const DRIFTED = 2;
35
+ /** `2` on drift; `1` when there is none but part of the environment could not be read; `0` when clean. */
36
+ export declare function driftExitCode(drift: Drift): number;
37
+ /** The drift in a parsed `chant lifecycle diff --live --json` document. */
38
+ export declare function driftFromLifecycle(environment: string, doc: unknown): Drift;
39
+ /** Runs `chant lifecycle diff <env> --live --json` in the project and reads the drift from it. */
40
+ export declare function readDrift(project: Project, env: Environment, options?: {
41
+ env?: NodeJS.ProcessEnv;
42
+ }): Promise<Drift>;
43
+ /** The drift as text. */
44
+ export declare function renderDrift(drift: Drift): string;