@reyemtech/nimbus 2.12.5 → 3.0.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 (276) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/backup/index.d.ts.map +1 -1
  3. package/dist/cjs/backup/index.js +6 -1
  4. package/dist/cjs/backup/index.js.map +1 -1
  5. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts +43 -0
  6. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  7. package/dist/cjs/cli/migrate-cnpg-ownership.js +67 -0
  8. package/dist/cjs/cli/migrate-cnpg-ownership.js.map +1 -0
  9. package/dist/cjs/cli/migrate-cnpg-roles.d.ts +92 -0
  10. package/dist/cjs/cli/migrate-cnpg-roles.d.ts.map +1 -0
  11. package/dist/cjs/cli/migrate-cnpg-roles.js +337 -0
  12. package/dist/cjs/cli/migrate-cnpg-roles.js.map +1 -0
  13. package/dist/cjs/cli/migrate-cnpg.d.ts +38 -0
  14. package/dist/cjs/cli/migrate-cnpg.d.ts.map +1 -0
  15. package/dist/cjs/cli/migrate-cnpg.js +258 -0
  16. package/dist/cjs/cli/migrate-cnpg.js.map +1 -0
  17. package/dist/cjs/cli/migrate-exec.d.ts +45 -0
  18. package/dist/cjs/cli/migrate-exec.d.ts.map +1 -0
  19. package/dist/cjs/cli/migrate-exec.js +104 -0
  20. package/dist/cjs/cli/migrate-exec.js.map +1 -0
  21. package/dist/cjs/cli/migrate-psql.d.ts +125 -0
  22. package/dist/cjs/cli/migrate-psql.d.ts.map +1 -0
  23. package/dist/cjs/cli/migrate-psql.js +213 -0
  24. package/dist/cjs/cli/migrate-psql.js.map +1 -0
  25. package/dist/cjs/cli/migrate-report.d.ts +27 -0
  26. package/dist/cjs/cli/migrate-report.d.ts.map +1 -0
  27. package/dist/cjs/cli/migrate-report.js +29 -0
  28. package/dist/cjs/cli/migrate-report.js.map +1 -0
  29. package/dist/cjs/cli/migrate-superuser.d.ts +22 -0
  30. package/dist/cjs/cli/migrate-superuser.d.ts.map +1 -0
  31. package/dist/cjs/cli/migrate-superuser.js +73 -0
  32. package/dist/cjs/cli/migrate-superuser.js.map +1 -0
  33. package/dist/cjs/cli/migrate.d.ts +37 -0
  34. package/dist/cjs/cli/migrate.d.ts.map +1 -0
  35. package/dist/cjs/cli/migrate.js +67 -0
  36. package/dist/cjs/cli/migrate.js.map +1 -0
  37. package/dist/cjs/cli.d.ts +1 -0
  38. package/dist/cjs/cli.d.ts.map +1 -1
  39. package/dist/cjs/cli.js +6 -0
  40. package/dist/cjs/cli.js.map +1 -1
  41. package/dist/cjs/index.d.ts +1 -1
  42. package/dist/cjs/index.d.ts.map +1 -1
  43. package/dist/cjs/index.js.map +1 -1
  44. package/dist/cjs/operator/cnpg-common.d.ts +56 -0
  45. package/dist/cjs/operator/cnpg-common.d.ts.map +1 -0
  46. package/dist/cjs/operator/cnpg-common.js +82 -0
  47. package/dist/cjs/operator/cnpg-common.js.map +1 -0
  48. package/dist/cjs/operator/cnpg-database.d.ts +66 -0
  49. package/dist/cjs/operator/cnpg-database.d.ts.map +1 -0
  50. package/dist/cjs/operator/cnpg-database.js +296 -0
  51. package/dist/cjs/operator/cnpg-database.js.map +1 -0
  52. package/dist/cjs/operator/cnpg-roles.d.ts +173 -0
  53. package/dist/cjs/operator/cnpg-roles.d.ts.map +1 -0
  54. package/dist/cjs/operator/cnpg-roles.js +225 -0
  55. package/dist/cjs/operator/cnpg-roles.js.map +1 -0
  56. package/dist/cjs/operator/cnpg.d.ts.map +1 -1
  57. package/dist/cjs/operator/cnpg.js +50 -162
  58. package/dist/cjs/operator/cnpg.js.map +1 -1
  59. package/dist/cjs/operator/connection-uri.d.ts +44 -0
  60. package/dist/cjs/operator/connection-uri.d.ts.map +1 -0
  61. package/dist/cjs/operator/connection-uri.js +49 -0
  62. package/dist/cjs/operator/connection-uri.js.map +1 -0
  63. package/dist/cjs/operator/credentials.d.ts +76 -0
  64. package/dist/cjs/operator/credentials.d.ts.map +1 -0
  65. package/dist/cjs/operator/credentials.js +106 -0
  66. package/dist/cjs/operator/credentials.js.map +1 -0
  67. package/dist/cjs/operator/database-options.d.ts +121 -0
  68. package/dist/cjs/operator/database-options.d.ts.map +1 -0
  69. package/dist/cjs/operator/database-options.js +131 -0
  70. package/dist/cjs/operator/database-options.js.map +1 -0
  71. package/dist/cjs/operator/grants/postgres-job.d.ts +109 -0
  72. package/dist/cjs/operator/grants/postgres-job.d.ts.map +1 -0
  73. package/dist/cjs/operator/grants/postgres-job.js +232 -0
  74. package/dist/cjs/operator/grants/postgres-job.js.map +1 -0
  75. package/dist/cjs/operator/grants/postgres-sql.d.ts +130 -0
  76. package/dist/cjs/operator/grants/postgres-sql.d.ts.map +1 -0
  77. package/dist/cjs/operator/grants/postgres-sql.js +305 -0
  78. package/dist/cjs/operator/grants/postgres-sql.js.map +1 -0
  79. package/dist/cjs/operator/grants/privileges.d.ts +24 -0
  80. package/dist/cjs/operator/grants/privileges.d.ts.map +1 -0
  81. package/dist/cjs/operator/grants/privileges.js +35 -0
  82. package/dist/cjs/operator/grants/privileges.js.map +1 -0
  83. package/dist/cjs/operator/grants/role-config.d.ts +80 -0
  84. package/dist/cjs/operator/grants/role-config.d.ts.map +1 -0
  85. package/dist/cjs/operator/grants/role-config.js +134 -0
  86. package/dist/cjs/operator/grants/role-config.js.map +1 -0
  87. package/dist/cjs/operator/index.d.ts +1 -1
  88. package/dist/cjs/operator/index.d.ts.map +1 -1
  89. package/dist/cjs/operator/index.js.map +1 -1
  90. package/dist/cjs/operator/interfaces.d.ts +223 -1
  91. package/dist/cjs/operator/interfaces.d.ts.map +1 -1
  92. package/dist/cjs/operator/interfaces.js.map +1 -1
  93. package/dist/cjs/operator/mariadb-common.d.ts +99 -0
  94. package/dist/cjs/operator/mariadb-common.d.ts.map +1 -0
  95. package/dist/cjs/operator/mariadb-common.js +141 -0
  96. package/dist/cjs/operator/mariadb-common.js.map +1 -0
  97. package/dist/cjs/operator/mariadb-database.d.ts +65 -0
  98. package/dist/cjs/operator/mariadb-database.d.ts.map +1 -0
  99. package/dist/cjs/operator/mariadb-database.js +285 -0
  100. package/dist/cjs/operator/mariadb-database.js.map +1 -0
  101. package/dist/cjs/operator/mariadb-roles.d.ts +264 -0
  102. package/dist/cjs/operator/mariadb-roles.d.ts.map +1 -0
  103. package/dist/cjs/operator/mariadb-roles.js +366 -0
  104. package/dist/cjs/operator/mariadb-roles.js.map +1 -0
  105. package/dist/cjs/operator/mariadb.d.ts.map +1 -1
  106. package/dist/cjs/operator/mariadb.js +35 -147
  107. package/dist/cjs/operator/mariadb.js.map +1 -1
  108. package/dist/cjs/operator/neo4j-common.d.ts +62 -0
  109. package/dist/cjs/operator/neo4j-common.d.ts.map +1 -0
  110. package/dist/cjs/operator/neo4j-common.js +89 -0
  111. package/dist/cjs/operator/neo4j-common.js.map +1 -0
  112. package/dist/cjs/operator/neo4j-database.d.ts +88 -0
  113. package/dist/cjs/operator/neo4j-database.d.ts.map +1 -0
  114. package/dist/cjs/operator/neo4j-database.js +274 -0
  115. package/dist/cjs/operator/neo4j-database.js.map +1 -0
  116. package/dist/cjs/operator/neo4j-roles.d.ts +203 -0
  117. package/dist/cjs/operator/neo4j-roles.d.ts.map +1 -0
  118. package/dist/cjs/operator/neo4j-roles.js +298 -0
  119. package/dist/cjs/operator/neo4j-roles.js.map +1 -0
  120. package/dist/cjs/operator/neo4j.d.ts.map +1 -1
  121. package/dist/cjs/operator/neo4j.js +32 -132
  122. package/dist/cjs/operator/neo4j.js.map +1 -1
  123. package/dist/cjs/operator/resource-identity.d.ts +170 -0
  124. package/dist/cjs/operator/resource-identity.d.ts.map +1 -0
  125. package/dist/cjs/operator/resource-identity.js +231 -0
  126. package/dist/cjs/operator/resource-identity.js.map +1 -0
  127. package/dist/cjs/operator/role-registry.d.ts +85 -0
  128. package/dist/cjs/operator/role-registry.d.ts.map +1 -0
  129. package/dist/cjs/operator/role-registry.js +72 -0
  130. package/dist/cjs/operator/role-registry.js.map +1 -0
  131. package/dist/cjs/platform/components/image-pruner.d.ts +3 -1
  132. package/dist/cjs/platform/components/image-pruner.d.ts.map +1 -1
  133. package/dist/cjs/platform/components/image-pruner.js +38 -19
  134. package/dist/cjs/platform/components/image-pruner.js.map +1 -1
  135. package/dist/cjs/types/errors.d.ts +3 -0
  136. package/dist/cjs/types/errors.d.ts.map +1 -1
  137. package/dist/cjs/types/errors.js +3 -0
  138. package/dist/cjs/types/errors.js.map +1 -1
  139. package/dist/esm/backup/index.d.ts.map +1 -1
  140. package/dist/esm/backup/index.js +6 -1
  141. package/dist/esm/backup/index.js.map +1 -1
  142. package/dist/esm/cli/migrate-cnpg-ownership.d.ts +43 -0
  143. package/dist/esm/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  144. package/dist/esm/cli/migrate-cnpg-ownership.js +67 -0
  145. package/dist/esm/cli/migrate-cnpg-ownership.js.map +1 -0
  146. package/dist/esm/cli/migrate-cnpg-roles.d.ts +92 -0
  147. package/dist/esm/cli/migrate-cnpg-roles.d.ts.map +1 -0
  148. package/dist/esm/cli/migrate-cnpg-roles.js +337 -0
  149. package/dist/esm/cli/migrate-cnpg-roles.js.map +1 -0
  150. package/dist/esm/cli/migrate-cnpg.d.ts +38 -0
  151. package/dist/esm/cli/migrate-cnpg.d.ts.map +1 -0
  152. package/dist/esm/cli/migrate-cnpg.js +258 -0
  153. package/dist/esm/cli/migrate-cnpg.js.map +1 -0
  154. package/dist/esm/cli/migrate-exec.d.ts +45 -0
  155. package/dist/esm/cli/migrate-exec.d.ts.map +1 -0
  156. package/dist/esm/cli/migrate-exec.js +104 -0
  157. package/dist/esm/cli/migrate-exec.js.map +1 -0
  158. package/dist/esm/cli/migrate-psql.d.ts +125 -0
  159. package/dist/esm/cli/migrate-psql.d.ts.map +1 -0
  160. package/dist/esm/cli/migrate-psql.js +213 -0
  161. package/dist/esm/cli/migrate-psql.js.map +1 -0
  162. package/dist/esm/cli/migrate-report.d.ts +27 -0
  163. package/dist/esm/cli/migrate-report.d.ts.map +1 -0
  164. package/dist/esm/cli/migrate-report.js +29 -0
  165. package/dist/esm/cli/migrate-report.js.map +1 -0
  166. package/dist/esm/cli/migrate-superuser.d.ts +22 -0
  167. package/dist/esm/cli/migrate-superuser.d.ts.map +1 -0
  168. package/dist/esm/cli/migrate-superuser.js +73 -0
  169. package/dist/esm/cli/migrate-superuser.js.map +1 -0
  170. package/dist/esm/cli/migrate.d.ts +37 -0
  171. package/dist/esm/cli/migrate.d.ts.map +1 -0
  172. package/dist/esm/cli/migrate.js +67 -0
  173. package/dist/esm/cli/migrate.js.map +1 -0
  174. package/dist/esm/cli.d.ts +1 -0
  175. package/dist/esm/cli.d.ts.map +1 -1
  176. package/dist/esm/cli.js +6 -0
  177. package/dist/esm/cli.js.map +1 -1
  178. package/dist/esm/index.d.ts +1 -1
  179. package/dist/esm/index.d.ts.map +1 -1
  180. package/dist/esm/index.js.map +1 -1
  181. package/dist/esm/operator/cnpg-common.d.ts +56 -0
  182. package/dist/esm/operator/cnpg-common.d.ts.map +1 -0
  183. package/dist/esm/operator/cnpg-common.js +82 -0
  184. package/dist/esm/operator/cnpg-common.js.map +1 -0
  185. package/dist/esm/operator/cnpg-database.d.ts +66 -0
  186. package/dist/esm/operator/cnpg-database.d.ts.map +1 -0
  187. package/dist/esm/operator/cnpg-database.js +296 -0
  188. package/dist/esm/operator/cnpg-database.js.map +1 -0
  189. package/dist/esm/operator/cnpg-roles.d.ts +173 -0
  190. package/dist/esm/operator/cnpg-roles.d.ts.map +1 -0
  191. package/dist/esm/operator/cnpg-roles.js +225 -0
  192. package/dist/esm/operator/cnpg-roles.js.map +1 -0
  193. package/dist/esm/operator/cnpg.d.ts.map +1 -1
  194. package/dist/esm/operator/cnpg.js +50 -162
  195. package/dist/esm/operator/cnpg.js.map +1 -1
  196. package/dist/esm/operator/connection-uri.d.ts +44 -0
  197. package/dist/esm/operator/connection-uri.d.ts.map +1 -0
  198. package/dist/esm/operator/connection-uri.js +49 -0
  199. package/dist/esm/operator/connection-uri.js.map +1 -0
  200. package/dist/esm/operator/credentials.d.ts +76 -0
  201. package/dist/esm/operator/credentials.d.ts.map +1 -0
  202. package/dist/esm/operator/credentials.js +106 -0
  203. package/dist/esm/operator/credentials.js.map +1 -0
  204. package/dist/esm/operator/database-options.d.ts +121 -0
  205. package/dist/esm/operator/database-options.d.ts.map +1 -0
  206. package/dist/esm/operator/database-options.js +131 -0
  207. package/dist/esm/operator/database-options.js.map +1 -0
  208. package/dist/esm/operator/grants/postgres-job.d.ts +109 -0
  209. package/dist/esm/operator/grants/postgres-job.d.ts.map +1 -0
  210. package/dist/esm/operator/grants/postgres-job.js +232 -0
  211. package/dist/esm/operator/grants/postgres-job.js.map +1 -0
  212. package/dist/esm/operator/grants/postgres-sql.d.ts +130 -0
  213. package/dist/esm/operator/grants/postgres-sql.d.ts.map +1 -0
  214. package/dist/esm/operator/grants/postgres-sql.js +305 -0
  215. package/dist/esm/operator/grants/postgres-sql.js.map +1 -0
  216. package/dist/esm/operator/grants/privileges.d.ts +24 -0
  217. package/dist/esm/operator/grants/privileges.d.ts.map +1 -0
  218. package/dist/esm/operator/grants/privileges.js +35 -0
  219. package/dist/esm/operator/grants/privileges.js.map +1 -0
  220. package/dist/esm/operator/grants/role-config.d.ts +80 -0
  221. package/dist/esm/operator/grants/role-config.d.ts.map +1 -0
  222. package/dist/esm/operator/grants/role-config.js +134 -0
  223. package/dist/esm/operator/grants/role-config.js.map +1 -0
  224. package/dist/esm/operator/index.d.ts +1 -1
  225. package/dist/esm/operator/index.d.ts.map +1 -1
  226. package/dist/esm/operator/index.js.map +1 -1
  227. package/dist/esm/operator/interfaces.d.ts +223 -1
  228. package/dist/esm/operator/interfaces.d.ts.map +1 -1
  229. package/dist/esm/operator/interfaces.js.map +1 -1
  230. package/dist/esm/operator/mariadb-common.d.ts +99 -0
  231. package/dist/esm/operator/mariadb-common.d.ts.map +1 -0
  232. package/dist/esm/operator/mariadb-common.js +141 -0
  233. package/dist/esm/operator/mariadb-common.js.map +1 -0
  234. package/dist/esm/operator/mariadb-database.d.ts +65 -0
  235. package/dist/esm/operator/mariadb-database.d.ts.map +1 -0
  236. package/dist/esm/operator/mariadb-database.js +285 -0
  237. package/dist/esm/operator/mariadb-database.js.map +1 -0
  238. package/dist/esm/operator/mariadb-roles.d.ts +264 -0
  239. package/dist/esm/operator/mariadb-roles.d.ts.map +1 -0
  240. package/dist/esm/operator/mariadb-roles.js +366 -0
  241. package/dist/esm/operator/mariadb-roles.js.map +1 -0
  242. package/dist/esm/operator/mariadb.d.ts.map +1 -1
  243. package/dist/esm/operator/mariadb.js +35 -147
  244. package/dist/esm/operator/mariadb.js.map +1 -1
  245. package/dist/esm/operator/neo4j-common.d.ts +62 -0
  246. package/dist/esm/operator/neo4j-common.d.ts.map +1 -0
  247. package/dist/esm/operator/neo4j-common.js +89 -0
  248. package/dist/esm/operator/neo4j-common.js.map +1 -0
  249. package/dist/esm/operator/neo4j-database.d.ts +88 -0
  250. package/dist/esm/operator/neo4j-database.d.ts.map +1 -0
  251. package/dist/esm/operator/neo4j-database.js +274 -0
  252. package/dist/esm/operator/neo4j-database.js.map +1 -0
  253. package/dist/esm/operator/neo4j-roles.d.ts +203 -0
  254. package/dist/esm/operator/neo4j-roles.d.ts.map +1 -0
  255. package/dist/esm/operator/neo4j-roles.js +298 -0
  256. package/dist/esm/operator/neo4j-roles.js.map +1 -0
  257. package/dist/esm/operator/neo4j.d.ts.map +1 -1
  258. package/dist/esm/operator/neo4j.js +32 -132
  259. package/dist/esm/operator/neo4j.js.map +1 -1
  260. package/dist/esm/operator/resource-identity.d.ts +170 -0
  261. package/dist/esm/operator/resource-identity.d.ts.map +1 -0
  262. package/dist/esm/operator/resource-identity.js +231 -0
  263. package/dist/esm/operator/resource-identity.js.map +1 -0
  264. package/dist/esm/operator/role-registry.d.ts +85 -0
  265. package/dist/esm/operator/role-registry.d.ts.map +1 -0
  266. package/dist/esm/operator/role-registry.js +72 -0
  267. package/dist/esm/operator/role-registry.js.map +1 -0
  268. package/dist/esm/platform/components/image-pruner.d.ts +3 -1
  269. package/dist/esm/platform/components/image-pruner.d.ts.map +1 -1
  270. package/dist/esm/platform/components/image-pruner.js +38 -19
  271. package/dist/esm/platform/components/image-pruner.js.map +1 -1
  272. package/dist/esm/types/errors.d.ts +3 -0
  273. package/dist/esm/types/errors.d.ts.map +1 -1
  274. package/dist/esm/types/errors.js +3 -0
  275. package/dist/esm/types/errors.js.map +1 -1
  276. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Command execution primitives for `nimbus migrate`.
3
+ *
4
+ * Every external call the migrate command makes goes through {@link runCommand},
5
+ * which always uses `execFileSync` with an argument array — never a
6
+ * shell-interpolated string — and never throws. Callers get back a discriminated
7
+ * result instead, so a missing tool, an unreachable cluster, or a non-zero exit
8
+ * code can be turned into a clear WARN/FAIL instead of an unhandled exception.
9
+ *
10
+ * @module cli/migrate-exec
11
+ */
12
+ /** Successful command execution. */
13
+ export interface ICommandSuccess {
14
+ readonly ok: true;
15
+ readonly stdout: string;
16
+ }
17
+ /** Failed command execution, with enough detail to explain why to the operator. */
18
+ export interface ICommandFailure {
19
+ readonly ok: false;
20
+ readonly reason: "not-found" | "error";
21
+ readonly message: string;
22
+ readonly exitCode?: number;
23
+ }
24
+ /** Outcome of {@link runCommand}: either captured stdout, or a structured failure. */
25
+ export type CommandResult = ICommandSuccess | ICommandFailure;
26
+ /**
27
+ * Run a command and capture its outcome without ever throwing.
28
+ *
29
+ * Uses `execFileSync` with an argument array (never a shell-interpolated
30
+ * string) so nothing in cluster or filesystem output can be interpreted as a
31
+ * shell command.
32
+ *
33
+ * @param cmd - Executable to run
34
+ * @param args - Arguments, passed verbatim (no shell involved)
35
+ * @returns The command's stdout on success, or a structured failure reason
36
+ */
37
+ export declare function runCommand(cmd: string, args: readonly string[]): CommandResult;
38
+ /**
39
+ * Split raw command stdout into trimmed, non-empty lines.
40
+ *
41
+ * @param stdout - Raw command output
42
+ * @returns Trimmed, non-empty lines
43
+ */
44
+ export declare function splitNonEmptyLines(stdout: string): string[];
45
+ //# sourceMappingURL=migrate-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-exec.d.ts","sourceRoot":"","sources":["../../../src/cli/migrate-exec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,sFAAsF;AACtF,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,eAAe,CAAC;AAiD9D;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAkB9E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAK3D"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ /**
3
+ * Command execution primitives for `nimbus migrate`.
4
+ *
5
+ * Every external call the migrate command makes goes through {@link runCommand},
6
+ * which always uses `execFileSync` with an argument array — never a
7
+ * shell-interpolated string — and never throws. Callers get back a discriminated
8
+ * result instead, so a missing tool, an unreachable cluster, or a non-zero exit
9
+ * code can be turned into a clear WARN/FAIL instead of an unhandled exception.
10
+ *
11
+ * @module cli/migrate-exec
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.runCommand = runCommand;
15
+ exports.splitNonEmptyLines = splitNonEmptyLines;
16
+ const child_process_1 = require("child_process");
17
+ /**
18
+ * Narrow an unknown thrown value to a Node.js errno exception.
19
+ *
20
+ * @param error - Value caught from a try/catch block
21
+ * @returns True when the value looks like a Node.js system error
22
+ */
23
+ function isErrnoException(error) {
24
+ return error instanceof Error;
25
+ }
26
+ /**
27
+ * Extract the numeric exit code from an `execFileSync` failure, if present.
28
+ *
29
+ * @param error - Value caught from a try/catch block
30
+ * @returns The process exit code, or undefined when unavailable
31
+ */
32
+ function extractExitCode(error) {
33
+ if (error && typeof error === "object" && "status" in error) {
34
+ const status = error.status;
35
+ return typeof status === "number" ? status : undefined;
36
+ }
37
+ return undefined;
38
+ }
39
+ /**
40
+ * Extract a human-readable message from an `execFileSync` failure, preferring
41
+ * captured stderr over the generic Error message.
42
+ *
43
+ * @param error - Value caught from a try/catch block
44
+ * @returns A trimmed, human-readable error message
45
+ */
46
+ function extractErrorMessage(error) {
47
+ if (error && typeof error === "object") {
48
+ const withStreams = error;
49
+ if (typeof withStreams.stderr === "string" && withStreams.stderr.trim().length > 0) {
50
+ return withStreams.stderr.trim();
51
+ }
52
+ if (Buffer.isBuffer(withStreams.stderr) && withStreams.stderr.length > 0) {
53
+ return withStreams.stderr.toString("utf8").trim();
54
+ }
55
+ if (typeof withStreams.message === "string") {
56
+ return withStreams.message;
57
+ }
58
+ }
59
+ return String(error);
60
+ }
61
+ /**
62
+ * Run a command and capture its outcome without ever throwing.
63
+ *
64
+ * Uses `execFileSync` with an argument array (never a shell-interpolated
65
+ * string) so nothing in cluster or filesystem output can be interpreted as a
66
+ * shell command.
67
+ *
68
+ * @param cmd - Executable to run
69
+ * @param args - Arguments, passed verbatim (no shell involved)
70
+ * @returns The command's stdout on success, or a structured failure reason
71
+ */
72
+ function runCommand(cmd, args) {
73
+ try {
74
+ const stdout = (0, child_process_1.execFileSync)(cmd, [...args], {
75
+ encoding: "utf8",
76
+ stdio: ["ignore", "pipe", "pipe"],
77
+ });
78
+ return { ok: true, stdout };
79
+ }
80
+ catch (error) {
81
+ if (isErrnoException(error) && error.code === "ENOENT") {
82
+ return { ok: false, reason: "not-found", message: `"${cmd}" was not found on PATH.` };
83
+ }
84
+ return {
85
+ ok: false,
86
+ reason: "error",
87
+ message: extractErrorMessage(error),
88
+ exitCode: extractExitCode(error),
89
+ };
90
+ }
91
+ }
92
+ /**
93
+ * Split raw command stdout into trimmed, non-empty lines.
94
+ *
95
+ * @param stdout - Raw command output
96
+ * @returns Trimmed, non-empty lines
97
+ */
98
+ function splitNonEmptyLines(stdout) {
99
+ return stdout
100
+ .split("\n")
101
+ .map((line) => line.trim())
102
+ .filter((line) => line.length > 0);
103
+ }
104
+ //# sourceMappingURL=migrate-exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-exec.js","sourceRoot":"","sources":["../../../src/cli/migrate-exec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA+EH,gCAkBC;AAQD,gDAKC;AA5GD,iDAA6C;AAmB7C;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,KAAK,YAAY,KAAK,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAI,KAA6B,CAAC,MAAM,CAAC;QACrD,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACzD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,WAAW,GAAG,KAAgD,CAAC;QACrE,IAAI,OAAO,WAAW,CAAC,MAAM,KAAK,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ACnC,QAAQ,EAAE,eAAe,CAAC,KAAK,CAAC;SACjC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,OAAO,MAAM;SACV,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Machine-readable `psql` output for the `nimbus migrate` checks.
3
+ *
4
+ * `psql -tAc` prints columns separated by `|` and escapes nothing, so a value
5
+ * containing that character is indistinguishable from a column boundary. A role
6
+ * called `read|er` — legal in PostgreSQL, which quotes identifiers — produced a
7
+ * line with ten fields where the parser expected nine, and the row was dropped.
8
+ * The check could then report that every role matches the adoption baseline
9
+ * while having skipped precisely the role whose attributes `DatabaseRole`
10
+ * adoption would reset: a false all-clear from the tool whose entire purpose is
11
+ * catching that.
12
+ *
13
+ * {@link toJsonRowsQuery} wraps a row-returning query so PostgreSQL renders the
14
+ * whole result as one JSON document, which escapes delimiters, quotes and
15
+ * newlines for us. The documented query itself is kept verbatim as the wrapped
16
+ * subquery, so this check and the manual procedure in
17
+ * `docs/cnpg-declarative-databases.md` still cannot drift apart.
18
+ *
19
+ * Nothing here drops a row it cannot read. {@link parseJsonRows} returns the
20
+ * rows it understood **and** a warning for everything else, which the caller
21
+ * surfaces as a WARN naming the row rather than silently omitting it.
22
+ *
23
+ * @module cli/migrate-psql
24
+ */
25
+ /**
26
+ * Wrap a row-returning query so `psql -tAc` emits a single JSON array.
27
+ *
28
+ * `json_agg` over `row_to_json` renders every column with its own name and
29
+ * escapes anything a value might contain, so no `|`, newline or quote in a role
30
+ * or database name can shift a field boundary. `coalesce` keeps the output a
31
+ * valid document (`[]`) when the query matches nothing, rather than the empty
32
+ * string `json_agg` returns for no rows.
33
+ *
34
+ * The query is embedded verbatim, so the constant a check runs stays byte-equal
35
+ * to the one the migration guide tells an operator to run by hand.
36
+ *
37
+ * @param query - A row-returning `SELECT`, without a trailing semicolon
38
+ * @returns A query returning one row with one JSON-array column
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * toJsonRowsQuery("SELECT datname FROM pg_database");
43
+ * // SELECT coalesce(json_agg(row_to_json(nimbus_row)), '[]'::json)
44
+ * // FROM (SELECT datname FROM pg_database) AS nimbus_row
45
+ * ```
46
+ */
47
+ export declare function toJsonRowsQuery(query: string): string;
48
+ /** Rows parsed out of one JSON document, plus what could not be parsed. */
49
+ export interface IJsonRowsResult {
50
+ /** Every element that was a JSON object, in the order returned. */
51
+ readonly rows: ReadonlyArray<Record<string, unknown>>;
52
+ /** One line per unreadable element, or per wholly unusable output. */
53
+ readonly warnings: ReadonlyArray<string>;
54
+ }
55
+ /**
56
+ * Parse the output of a {@link toJsonRowsQuery} query into row objects.
57
+ *
58
+ * A row that cannot be used is reported, never dropped: the caller turns each
59
+ * warning into a WARN line, so an unreadable row downgrades the check instead of
60
+ * quietly shrinking the set it claims to have inspected.
61
+ *
62
+ * @param stdout - Raw `psql -tAc` output
63
+ * @param subject - What the query was reading, named in warnings (e.g. "pg_roles")
64
+ * @returns The object rows, and a warning for anything unusable
65
+ */
66
+ export declare function parseJsonRows(stdout: string, subject: string): IJsonRowsResult;
67
+ /**
68
+ * Read a column that must hold a non-empty string.
69
+ *
70
+ * @param row - Parsed row
71
+ * @param column - Column name
72
+ * @returns The value, or undefined when absent, empty, or another type
73
+ */
74
+ export declare function readString(row: Record<string, unknown>, column: string): string | undefined;
75
+ /**
76
+ * Read a column that may legitimately hold SQL `NULL`.
77
+ *
78
+ * A nullable column has three states this parser must keep apart: a value, an
79
+ * explicit `NULL` — which is data, not a failure (`rolvaliduntil` NULL is how
80
+ * PostgreSQL spells "this password never expires") — and a column that is absent
81
+ * or of the wrong type, which is unreadable. Only the last may warn, so `null`
82
+ * is returned as itself rather than collapsed into the `undefined` that
83
+ * {@link readString} uses for "could not read this".
84
+ *
85
+ * An empty string is a value here, unlike in {@link readString}: `COMMENT ON
86
+ * ROLE … IS ''` is a real, if pointless, state and must not read as unreadable.
87
+ *
88
+ * @param row - Parsed row
89
+ * @param column - Column name
90
+ * @returns The value, `null` for a SQL `NULL`, or undefined when the column is
91
+ * absent or of another type
92
+ */
93
+ export declare function readNullableString(row: Record<string, unknown>, column: string): string | null | undefined;
94
+ /**
95
+ * Read a column that must hold a JSON boolean.
96
+ *
97
+ * PostgreSQL's `boolean` renders as a JSON boolean, not as psql's `t`/`f`, so a
98
+ * `"t"` here means the query was not the wrapped JSON one.
99
+ *
100
+ * @param row - Parsed row
101
+ * @param column - Column name
102
+ * @returns The value, or undefined when absent or another type
103
+ */
104
+ export declare function readBoolean(row: Record<string, unknown>, column: string): boolean | undefined;
105
+ /**
106
+ * Read a column that must hold a finite JSON number.
107
+ *
108
+ * @param row - Parsed row
109
+ * @param column - Column name
110
+ * @returns The value, or undefined when absent, not finite, or another type
111
+ */
112
+ export declare function readNumber(row: Record<string, unknown>, column: string): number | undefined;
113
+ /**
114
+ * Read a column that must hold an array of strings.
115
+ *
116
+ * A PostgreSQL `text[]` renders as a JSON array, so role memberships arrive
117
+ * already separated — a membership containing a comma or a `|` can no longer
118
+ * blur into its neighbour the way it could in psql's `{a,b}` array text.
119
+ *
120
+ * @param row - Parsed row
121
+ * @param column - Column name
122
+ * @returns The values, or undefined when absent or not an array of strings
123
+ */
124
+ export declare function readStringArray(row: Record<string, unknown>, column: string): ReadonlyArray<string> | undefined;
125
+ //# sourceMappingURL=migrate-psql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-psql.d.ts","sourceRoot":"","sources":["../../../src/cli/migrate-psql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH;;;;;;;;;;;;;;;;;;;;;GAqBG;A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 * Machine-readable `psql` output for the `nimbus migrate` checks.
4
+ *
5
+ * `psql -tAc` prints columns separated by `|` and escapes nothing, so a value
6
+ * containing that character is indistinguishable from a column boundary. A role
7
+ * called `read|er` — legal in PostgreSQL, which quotes identifiers — produced a
8
+ * line with ten fields where the parser expected nine, and the row was dropped.
9
+ * The check could then report that every role matches the adoption baseline
10
+ * while having skipped precisely the role whose attributes `DatabaseRole`
11
+ * adoption would reset: a false all-clear from the tool whose entire purpose is
12
+ * catching that.
13
+ *
14
+ * {@link toJsonRowsQuery} wraps a row-returning query so PostgreSQL renders the
15
+ * whole result as one JSON document, which escapes delimiters, quotes and
16
+ * newlines for us. The documented query itself is kept verbatim as the wrapped
17
+ * subquery, so this check and the manual procedure in
18
+ * `docs/cnpg-declarative-databases.md` still cannot drift apart.
19
+ *
20
+ * Nothing here drops a row it cannot read. {@link parseJsonRows} returns the
21
+ * rows it understood **and** a warning for everything else, which the caller
22
+ * surfaces as a WARN naming the row rather than silently omitting it.
23
+ *
24
+ * @module cli/migrate-psql
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.toJsonRowsQuery = toJsonRowsQuery;
28
+ exports.parseJsonRows = parseJsonRows;
29
+ exports.readString = readString;
30
+ exports.readNullableString = readNullableString;
31
+ exports.readBoolean = readBoolean;
32
+ exports.readNumber = readNumber;
33
+ exports.readStringArray = readStringArray;
34
+ /** Alias the wrapped query's rows are aggregated under. */
35
+ const ROWS_ALIAS = "nimbus_row";
36
+ /** Longest fragment of unparseable output echoed back in a warning. */
37
+ const MAX_REPORTED_LENGTH = 200;
38
+ /**
39
+ * Wrap a row-returning query so `psql -tAc` emits a single JSON array.
40
+ *
41
+ * `json_agg` over `row_to_json` renders every column with its own name and
42
+ * escapes anything a value might contain, so no `|`, newline or quote in a role
43
+ * or database name can shift a field boundary. `coalesce` keeps the output a
44
+ * valid document (`[]`) when the query matches nothing, rather than the empty
45
+ * string `json_agg` returns for no rows.
46
+ *
47
+ * The query is embedded verbatim, so the constant a check runs stays byte-equal
48
+ * to the one the migration guide tells an operator to run by hand.
49
+ *
50
+ * @param query - A row-returning `SELECT`, without a trailing semicolon
51
+ * @returns A query returning one row with one JSON-array column
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * toJsonRowsQuery("SELECT datname FROM pg_database");
56
+ * // SELECT coalesce(json_agg(row_to_json(nimbus_row)), '[]'::json)
57
+ * // FROM (SELECT datname FROM pg_database) AS nimbus_row
58
+ * ```
59
+ */
60
+ function toJsonRowsQuery(query) {
61
+ return (`SELECT coalesce(json_agg(row_to_json(${ROWS_ALIAS})), '[]'::json) ` +
62
+ `FROM (${query}) AS ${ROWS_ALIAS}`);
63
+ }
64
+ /**
65
+ * Render a value into a warning without pasting an entire query result into the
66
+ * report.
67
+ *
68
+ * @param value - Value to describe
69
+ * @returns A short, single-line rendering, truncated with an ellipsis
70
+ */
71
+ function describeValue(value) {
72
+ const rendered = typeof value === "string" ? value : JSON.stringify(value);
73
+ const oneLine = (rendered ?? String(value)).replace(/\s+/g, " ").trim();
74
+ return oneLine.length > MAX_REPORTED_LENGTH
75
+ ? `${oneLine.slice(0, MAX_REPORTED_LENGTH)}…`
76
+ : oneLine;
77
+ }
78
+ /**
79
+ * Parse the output of a {@link toJsonRowsQuery} query into row objects.
80
+ *
81
+ * A row that cannot be used is reported, never dropped: the caller turns each
82
+ * warning into a WARN line, so an unreadable row downgrades the check instead of
83
+ * quietly shrinking the set it claims to have inspected.
84
+ *
85
+ * @param stdout - Raw `psql -tAc` output
86
+ * @param subject - What the query was reading, named in warnings (e.g. "pg_roles")
87
+ * @returns The object rows, and a warning for anything unusable
88
+ */
89
+ function parseJsonRows(stdout, subject) {
90
+ const text = stdout.trim();
91
+ if (text === "") {
92
+ return {
93
+ rows: [],
94
+ warnings: [`the ${subject} query returned no output; nothing was checked.`],
95
+ };
96
+ }
97
+ let parsed;
98
+ try {
99
+ parsed = JSON.parse(text);
100
+ }
101
+ catch (error) {
102
+ const reason = error instanceof Error ? error.message : String(error);
103
+ return {
104
+ rows: [],
105
+ warnings: [
106
+ `could not parse the ${subject} query output as JSON (${reason}): ${describeValue(text)}`,
107
+ ],
108
+ };
109
+ }
110
+ if (!Array.isArray(parsed)) {
111
+ return {
112
+ rows: [],
113
+ warnings: [
114
+ `the ${subject} query returned ${describeValue(parsed)}, which is not a list of rows.`,
115
+ ],
116
+ };
117
+ }
118
+ const rows = [];
119
+ const warnings = [];
120
+ parsed.forEach((element, index) => {
121
+ if (typeof element === "object" && element !== null && !Array.isArray(element)) {
122
+ rows.push(element);
123
+ return;
124
+ }
125
+ warnings.push(`${subject} row ${index + 1} is not an object and was not checked: ${describeValue(element)}`);
126
+ });
127
+ return { rows, warnings };
128
+ }
129
+ /**
130
+ * Read a column that must hold a non-empty string.
131
+ *
132
+ * @param row - Parsed row
133
+ * @param column - Column name
134
+ * @returns The value, or undefined when absent, empty, or another type
135
+ */
136
+ function readString(row, column) {
137
+ const value = row[column];
138
+ return typeof value === "string" && value.length > 0 ? value : undefined;
139
+ }
140
+ /**
141
+ * Read a column that may legitimately hold SQL `NULL`.
142
+ *
143
+ * A nullable column has three states this parser must keep apart: a value, an
144
+ * explicit `NULL` — which is data, not a failure (`rolvaliduntil` NULL is how
145
+ * PostgreSQL spells "this password never expires") — and a column that is absent
146
+ * or of the wrong type, which is unreadable. Only the last may warn, so `null`
147
+ * is returned as itself rather than collapsed into the `undefined` that
148
+ * {@link readString} uses for "could not read this".
149
+ *
150
+ * An empty string is a value here, unlike in {@link readString}: `COMMENT ON
151
+ * ROLE … IS ''` is a real, if pointless, state and must not read as unreadable.
152
+ *
153
+ * @param row - Parsed row
154
+ * @param column - Column name
155
+ * @returns The value, `null` for a SQL `NULL`, or undefined when the column is
156
+ * absent or of another type
157
+ */
158
+ function readNullableString(row, column) {
159
+ if (!(column in row)) {
160
+ return undefined;
161
+ }
162
+ const value = row[column];
163
+ if (value === null) {
164
+ return null;
165
+ }
166
+ return typeof value === "string" ? value : undefined;
167
+ }
168
+ /**
169
+ * Read a column that must hold a JSON boolean.
170
+ *
171
+ * PostgreSQL's `boolean` renders as a JSON boolean, not as psql's `t`/`f`, so a
172
+ * `"t"` here means the query was not the wrapped JSON one.
173
+ *
174
+ * @param row - Parsed row
175
+ * @param column - Column name
176
+ * @returns The value, or undefined when absent or another type
177
+ */
178
+ function readBoolean(row, column) {
179
+ const value = row[column];
180
+ return typeof value === "boolean" ? value : undefined;
181
+ }
182
+ /**
183
+ * Read a column that must hold a finite JSON number.
184
+ *
185
+ * @param row - Parsed row
186
+ * @param column - Column name
187
+ * @returns The value, or undefined when absent, not finite, or another type
188
+ */
189
+ function readNumber(row, column) {
190
+ const value = row[column];
191
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
192
+ }
193
+ /**
194
+ * Read a column that must hold an array of strings.
195
+ *
196
+ * A PostgreSQL `text[]` renders as a JSON array, so role memberships arrive
197
+ * already separated — a membership containing a comma or a `|` can no longer
198
+ * blur into its neighbour the way it could in psql's `{a,b}` array text.
199
+ *
200
+ * @param row - Parsed row
201
+ * @param column - Column name
202
+ * @returns The values, or undefined when absent or not an array of strings
203
+ */
204
+ function readStringArray(row, column) {
205
+ const value = row[column];
206
+ if (!Array.isArray(value)) {
207
+ return undefined;
208
+ }
209
+ return value.every((element) => typeof element === "string")
210
+ ? value
211
+ : undefined;
212
+ }
213
+ //# sourceMappingURL=migrate-psql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-psql.js","sourceRoot":"","sources":["../../../src/cli/migrate-psql.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AA8BH,0CAKC;AAoCD,sCA4CC;AASD,gCAGC;AAoBD,gDAYC;AAYD,kCAGC;AASD,gCAGC;AAaD,0CAWC;AAhND,2DAA2D;AAC3D,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC;;;;;;;;;;;;;;;;;;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3
+ * every check section reports in, and the printer that renders one.
4
+ *
5
+ * @module cli/migrate-report
6
+ */
7
+ /** Section verdicts printed by `nimbus migrate`. */
8
+ export declare const CHECK_STATUS: {
9
+ readonly PASS: "PASS";
10
+ readonly WARN: "WARN";
11
+ readonly FAIL: "FAIL";
12
+ };
13
+ /** A section verdict: "PASS", "WARN", or "FAIL". */
14
+ export type CheckStatus = (typeof CHECK_STATUS)[keyof typeof CHECK_STATUS];
15
+ /** Result of one pre-flight check section. */
16
+ export interface ISectionResult {
17
+ readonly status: CheckStatus;
18
+ readonly lines: readonly string[];
19
+ }
20
+ /**
21
+ * Print one report section in `[STATUS] title` form, indenting its detail lines.
22
+ *
23
+ * @param title - Section heading
24
+ * @param section - Section result to print
25
+ */
26
+ export declare function printSection(title: string, section: ISectionResult): void;
27
+ //# sourceMappingURL=migrate-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-report.d.ts","sourceRoot":"","sources":["../../../src/cli/migrate-report.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oDAAoD;AACpD,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,oDAAoD;AACpD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE3E,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAKzE"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * Shared report types for `nimbus migrate` — the PASS/WARN/FAIL vocabulary
4
+ * every check section reports in, and the printer that renders one.
5
+ *
6
+ * @module cli/migrate-report
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CHECK_STATUS = void 0;
10
+ exports.printSection = printSection;
11
+ /** Section verdicts printed by `nimbus migrate`. */
12
+ exports.CHECK_STATUS = {
13
+ PASS: "PASS",
14
+ WARN: "WARN",
15
+ FAIL: "FAIL",
16
+ };
17
+ /**
18
+ * Print one report section in `[STATUS] title` form, indenting its detail lines.
19
+ *
20
+ * @param title - Section heading
21
+ * @param section - Section result to print
22
+ */
23
+ function printSection(title, section) {
24
+ console.log(`\n[${section.status}] ${title}`);
25
+ for (const line of section.lines) {
26
+ console.log(` ${line}`);
27
+ }
28
+ }
29
+ //# sourceMappingURL=migrate-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-report.js","sourceRoot":"","sources":["../../../src/cli/migrate-report.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAwBH,oCAKC;AA3BD,oDAAoD;AACvC,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACJ,CAAC;AAWX;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAa,EAAE,OAAuB;IACjE,OAAO,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `{cluster}-superuser` Secret consumer check for `nimbus migrate`.
3
+ *
4
+ * `superuserAccess` now defaults to `false`. On an existing cluster this makes
5
+ * CNPG set the `postgres` password to NULL and delete the `{cluster}-superuser`
6
+ * Secret — the one change in this release that mutates live cluster state and
7
+ * that no Pulumi alias can shim. Any out-of-band consumer of that Secret needs
8
+ * a human decision, not an automated fix, so this only ever greps for it.
9
+ *
10
+ * @module cli/migrate-superuser
11
+ */
12
+ import type { ISectionResult } from "./migrate-report.js";
13
+ /** Secret name suffix that disappears when `superuserAccess` is `false`. */
14
+ export declare const SUPERUSER_SECRET_SUFFIX = "-superuser";
15
+ /**
16
+ * Grep the working directory for references to the `{cluster}-superuser` Secret.
17
+ *
18
+ * @returns PASS when nothing references the Secret, WARN otherwise (or when
19
+ * the scan itself could not run)
20
+ */
21
+ export declare function checkSuperuserConsumers(): ISectionResult;
22
+ //# sourceMappingURL=migrate-superuser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-superuser.d.ts","sourceRoot":"","sources":["../../../src/cli/migrate-superuser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,eAAe,CAAC;AAKpD;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,cAAc,CAgDxD"}