@memberjunction/cli 6.3.0-edge.0 → 6.3.0-edge.2

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 (251) hide show
  1. package/README.md +1047 -359
  2. package/dist/baseline/connection.d.ts.map +1 -1
  3. package/dist/baseline/connection.js +12 -1
  4. package/dist/baseline/connection.js.map +1 -1
  5. package/dist/commands/agent/usage.d.ts +7 -0
  6. package/dist/commands/agent/usage.d.ts.map +1 -0
  7. package/dist/commands/agent/usage.js +10 -0
  8. package/dist/commands/agent/usage.js.map +1 -0
  9. package/dist/commands/app/check-updates.d.ts +2 -2
  10. package/dist/commands/app/check-updates.d.ts.map +1 -1
  11. package/dist/commands/app/check-updates.js +8 -7
  12. package/dist/commands/app/check-updates.js.map +1 -1
  13. package/dist/commands/app/install.d.ts +2 -2
  14. package/dist/commands/app/install.d.ts.map +1 -1
  15. package/dist/commands/app/install.js +29 -18
  16. package/dist/commands/app/install.js.map +1 -1
  17. package/dist/commands/app/remove.d.ts.map +1 -1
  18. package/dist/commands/app/remove.js +3 -1
  19. package/dist/commands/app/remove.js.map +1 -1
  20. package/dist/commands/app/upgrade.d.ts +1 -0
  21. package/dist/commands/app/upgrade.d.ts.map +1 -1
  22. package/dist/commands/app/upgrade.js +6 -0
  23. package/dist/commands/app/upgrade.js.map +1 -1
  24. package/dist/commands/codegen/index.d.ts +1 -0
  25. package/dist/commands/codegen/index.d.ts.map +1 -1
  26. package/dist/commands/codegen/manifest.d.ts +40 -0
  27. package/dist/commands/codegen/manifest.d.ts.map +1 -1
  28. package/dist/commands/codegen/manifest.js +124 -3
  29. package/dist/commands/codegen/manifest.js.map +1 -1
  30. package/dist/commands/diag/usage.d.ts +7 -0
  31. package/dist/commands/diag/usage.d.ts.map +1 -0
  32. package/dist/commands/diag/usage.js +10 -0
  33. package/dist/commands/diag/usage.js.map +1 -0
  34. package/dist/commands/doctor/index.d.ts +6 -0
  35. package/dist/commands/doctor/index.d.ts.map +1 -1
  36. package/dist/commands/doctor/index.js +42 -0
  37. package/dist/commands/doctor/index.js.map +1 -1
  38. package/dist/commands/explorer/postbuild.d.ts +14 -0
  39. package/dist/commands/explorer/postbuild.d.ts.map +1 -0
  40. package/dist/commands/explorer/postbuild.js +49 -0
  41. package/dist/commands/explorer/postbuild.js.map +1 -0
  42. package/dist/commands/explorer/usage.d.ts +7 -0
  43. package/dist/commands/explorer/usage.d.ts.map +1 -0
  44. package/dist/commands/explorer/usage.js +10 -0
  45. package/dist/commands/explorer/usage.js.map +1 -0
  46. package/dist/commands/harness/account/add.d.ts +22 -0
  47. package/dist/commands/harness/account/add.d.ts.map +1 -0
  48. package/dist/commands/harness/account/add.js +100 -0
  49. package/dist/commands/harness/account/add.js.map +1 -0
  50. package/dist/commands/harness/account/clear-cooldown.d.ts +13 -0
  51. package/dist/commands/harness/account/clear-cooldown.d.ts.map +1 -0
  52. package/dist/commands/harness/account/clear-cooldown.js +32 -0
  53. package/dist/commands/harness/account/clear-cooldown.js.map +1 -0
  54. package/dist/commands/harness/account/disable.d.ts +13 -0
  55. package/dist/commands/harness/account/disable.d.ts.map +1 -0
  56. package/dist/commands/harness/account/disable.js +34 -0
  57. package/dist/commands/harness/account/disable.js.map +1 -0
  58. package/dist/commands/harness/account/enable.d.ts +13 -0
  59. package/dist/commands/harness/account/enable.d.ts.map +1 -0
  60. package/dist/commands/harness/account/enable.js +34 -0
  61. package/dist/commands/harness/account/enable.js.map +1 -0
  62. package/dist/commands/harness/account/index.d.ts +7 -0
  63. package/dist/commands/harness/account/index.d.ts.map +1 -0
  64. package/dist/commands/harness/account/index.js +23 -0
  65. package/dist/commands/harness/account/index.js.map +1 -0
  66. package/dist/commands/harness/account/list.d.ts +15 -0
  67. package/dist/commands/harness/account/list.d.ts.map +1 -0
  68. package/dist/commands/harness/account/list.js +58 -0
  69. package/dist/commands/harness/account/list.js.map +1 -0
  70. package/dist/commands/harness/account/login.d.ts +16 -0
  71. package/dist/commands/harness/account/login.d.ts.map +1 -0
  72. package/dist/commands/harness/account/login.js +50 -0
  73. package/dist/commands/harness/account/login.js.map +1 -0
  74. package/dist/commands/harness/account/remove.d.ts +14 -0
  75. package/dist/commands/harness/account/remove.d.ts.map +1 -0
  76. package/dist/commands/harness/account/remove.js +43 -0
  77. package/dist/commands/harness/account/remove.js.map +1 -0
  78. package/dist/commands/harness/account/set-strategy.d.ts +13 -0
  79. package/dist/commands/harness/account/set-strategy.d.ts.map +1 -0
  80. package/dist/commands/harness/account/set-strategy.js +38 -0
  81. package/dist/commands/harness/account/set-strategy.js.map +1 -0
  82. package/dist/commands/harness/index.d.ts +7 -0
  83. package/dist/commands/harness/index.d.ts.map +1 -0
  84. package/dist/commands/harness/index.js +22 -0
  85. package/dist/commands/harness/index.js.map +1 -0
  86. package/dist/commands/harness/usage.d.ts +7 -0
  87. package/dist/commands/harness/usage.d.ts.map +1 -0
  88. package/dist/commands/harness/usage.js +10 -0
  89. package/dist/commands/harness/usage.js.map +1 -0
  90. package/dist/commands/migrate/convert.d.ts +25 -1
  91. package/dist/commands/migrate/convert.d.ts.map +1 -1
  92. package/dist/commands/migrate/convert.js +160 -46
  93. package/dist/commands/migrate/convert.js.map +1 -1
  94. package/dist/commands/migrate/index.d.ts +8 -0
  95. package/dist/commands/migrate/index.d.ts.map +1 -1
  96. package/dist/commands/migrate/index.js +41 -2
  97. package/dist/commands/migrate/index.js.map +1 -1
  98. package/dist/commands/migrate/rebake.d.ts +13 -0
  99. package/dist/commands/migrate/rebake.d.ts.map +1 -1
  100. package/dist/commands/migrate/rebake.js +48 -14
  101. package/dist/commands/migrate/rebake.js.map +1 -1
  102. package/dist/commands/queue/export-topology.d.ts +2 -0
  103. package/dist/commands/queue/export-topology.d.ts.map +1 -1
  104. package/dist/commands/queue/export-topology.js +3 -1
  105. package/dist/commands/queue/export-topology.js.map +1 -1
  106. package/dist/commands/queue/import-bindings.d.ts +2 -0
  107. package/dist/commands/queue/import-bindings.d.ts.map +1 -1
  108. package/dist/commands/queue/import-bindings.js +3 -1
  109. package/dist/commands/queue/import-bindings.js.map +1 -1
  110. package/dist/commands/queue/index.d.ts.map +1 -1
  111. package/dist/commands/queue/index.js +1 -0
  112. package/dist/commands/queue/index.js.map +1 -1
  113. package/dist/commands/queue/sweep.d.ts +11 -0
  114. package/dist/commands/queue/sweep.d.ts.map +1 -0
  115. package/dist/commands/queue/sweep.js +36 -0
  116. package/dist/commands/queue/sweep.js.map +1 -0
  117. package/dist/commands/queue/validate-bindings.d.ts +2 -0
  118. package/dist/commands/queue/validate-bindings.d.ts.map +1 -1
  119. package/dist/commands/queue/validate-bindings.js +3 -1
  120. package/dist/commands/queue/validate-bindings.js.map +1 -1
  121. package/dist/commands/queue/work.d.ts +4 -0
  122. package/dist/commands/queue/work.d.ts.map +1 -1
  123. package/dist/commands/queue/work.js +9 -9
  124. package/dist/commands/queue/work.js.map +1 -1
  125. package/dist/commands/rubric/usage.d.ts +7 -0
  126. package/dist/commands/rubric/usage.d.ts.map +1 -0
  127. package/dist/commands/rubric/usage.js +10 -0
  128. package/dist/commands/rubric/usage.js.map +1 -0
  129. package/dist/commands/test/regression/index.d.ts.map +1 -1
  130. package/dist/commands/test/regression/index.js +2 -0
  131. package/dist/commands/test/regression/index.js.map +1 -1
  132. package/dist/commands/test/regression/new.d.ts +21 -0
  133. package/dist/commands/test/regression/new.d.ts.map +1 -0
  134. package/dist/commands/test/regression/new.js +82 -0
  135. package/dist/commands/test/regression/new.js.map +1 -0
  136. package/dist/commands/test/regression/up.d.ts +1 -0
  137. package/dist/commands/test/regression/up.d.ts.map +1 -1
  138. package/dist/commands/test/regression/up.js +17 -0
  139. package/dist/commands/test/regression/up.js.map +1 -1
  140. package/dist/commands/test/scripts.d.ts +6 -4
  141. package/dist/commands/test/scripts.d.ts.map +1 -1
  142. package/dist/commands/test/scripts.js +14 -0
  143. package/dist/commands/test/scripts.js.map +1 -1
  144. package/dist/commands/test/suite.d.ts +1 -0
  145. package/dist/commands/test/suite.d.ts.map +1 -1
  146. package/dist/commands/test/suite.js +6 -0
  147. package/dist/commands/test/suite.js.map +1 -1
  148. package/dist/commands/usage.js +2 -1
  149. package/dist/commands/usage.js.map +1 -1
  150. package/dist/commands/user/usage.d.ts +7 -0
  151. package/dist/commands/user/usage.d.ts.map +1 -0
  152. package/dist/commands/user/usage.js +10 -0
  153. package/dist/commands/user/usage.js.map +1 -0
  154. package/dist/config.d.ts +119 -0
  155. package/dist/config.d.ts.map +1 -1
  156. package/dist/config.js +43 -1
  157. package/dist/config.js.map +1 -1
  158. package/dist/init-templates/citizen-builder/.env.example +5 -0
  159. package/dist/init-templates/citizen-builder/docker-compose.yml +9 -0
  160. package/dist/init-templates/citizen-builder/scripts/docker-entrypoint.sh +18 -1
  161. package/dist/lib/db-preflight.d.ts.map +1 -1
  162. package/dist/lib/db-preflight.js +22 -0
  163. package/dist/lib/db-preflight.js.map +1 -1
  164. package/dist/lib/derived-usage.d.ts +8 -0
  165. package/dist/lib/derived-usage.d.ts.map +1 -1
  166. package/dist/lib/derived-usage.js +30 -20
  167. package/dist/lib/derived-usage.js.map +1 -1
  168. package/dist/lib/dev-workspace/prebundle.d.ts +3 -1
  169. package/dist/lib/dev-workspace/prebundle.d.ts.map +1 -1
  170. package/dist/lib/dev-workspace/prebundle.js +4 -3
  171. package/dist/lib/dev-workspace/prebundle.js.map +1 -1
  172. package/dist/lib/domain-profiles.d.ts.map +1 -1
  173. package/dist/lib/domain-profiles.js +24 -0
  174. package/dist/lib/domain-profiles.js.map +1 -1
  175. package/dist/lib/domain-usage-command.js +2 -1
  176. package/dist/lib/domain-usage-command.js.map +1 -1
  177. package/dist/lib/explorer-postbuild/public-page-html.d.ts +48 -0
  178. package/dist/lib/explorer-postbuild/public-page-html.d.ts.map +1 -0
  179. package/dist/lib/explorer-postbuild/public-page-html.js +284 -0
  180. package/dist/lib/explorer-postbuild/public-page-html.js.map +1 -0
  181. package/dist/lib/explorer-postbuild/service-worker-check.d.ts +13 -0
  182. package/dist/lib/explorer-postbuild/service-worker-check.d.ts.map +1 -0
  183. package/dist/lib/explorer-postbuild/service-worker-check.js +41 -0
  184. package/dist/lib/explorer-postbuild/service-worker-check.js.map +1 -0
  185. package/dist/lib/harness-account.d.ts +34 -0
  186. package/dist/lib/harness-account.d.ts.map +1 -0
  187. package/dist/lib/harness-account.js +105 -0
  188. package/dist/lib/harness-account.js.map +1 -0
  189. package/dist/lib/pg-preflight/checks.d.ts +28 -0
  190. package/dist/lib/pg-preflight/checks.d.ts.map +1 -0
  191. package/dist/lib/pg-preflight/checks.js +94 -0
  192. package/dist/lib/pg-preflight/checks.js.map +1 -0
  193. package/dist/lib/pg-preflight/extension-check.d.ts +28 -0
  194. package/dist/lib/pg-preflight/extension-check.d.ts.map +1 -0
  195. package/dist/lib/pg-preflight/extension-check.js +86 -0
  196. package/dist/lib/pg-preflight/extension-check.js.map +1 -0
  197. package/dist/lib/pg-preflight/extension-scan.d.ts +24 -0
  198. package/dist/lib/pg-preflight/extension-scan.d.ts.map +1 -0
  199. package/dist/lib/pg-preflight/extension-scan.js +58 -0
  200. package/dist/lib/pg-preflight/extension-scan.js.map +1 -0
  201. package/dist/lib/pg-preflight/pending-migrations.d.ts +28 -0
  202. package/dist/lib/pg-preflight/pending-migrations.d.ts.map +1 -0
  203. package/dist/lib/pg-preflight/pending-migrations.js +48 -0
  204. package/dist/lib/pg-preflight/pending-migrations.js.map +1 -0
  205. package/dist/lib/pg-preflight/preflight.d.ts +18 -0
  206. package/dist/lib/pg-preflight/preflight.d.ts.map +1 -0
  207. package/dist/lib/pg-preflight/preflight.js +43 -0
  208. package/dist/lib/pg-preflight/preflight.js.map +1 -0
  209. package/dist/lib/pg-preflight/remediation.d.ts +27 -0
  210. package/dist/lib/pg-preflight/remediation.d.ts.map +1 -0
  211. package/dist/lib/pg-preflight/remediation.js +82 -0
  212. package/dist/lib/pg-preflight/remediation.js.map +1 -0
  213. package/dist/lib/pg-preflight/render.d.ts +15 -0
  214. package/dist/lib/pg-preflight/render.d.ts.map +1 -0
  215. package/dist/lib/pg-preflight/render.js +48 -0
  216. package/dist/lib/pg-preflight/render.js.map +1 -0
  217. package/dist/lib/pg-preflight/run-for-config.d.ts +23 -0
  218. package/dist/lib/pg-preflight/run-for-config.d.ts.map +1 -0
  219. package/dist/lib/pg-preflight/run-for-config.js +45 -0
  220. package/dist/lib/pg-preflight/run-for-config.js.map +1 -0
  221. package/dist/lib/pg-preflight/types.d.ts +67 -0
  222. package/dist/lib/pg-preflight/types.d.ts.map +1 -0
  223. package/dist/lib/pg-preflight/types.js +8 -0
  224. package/dist/lib/pg-preflight/types.js.map +1 -0
  225. package/dist/lib/regression/test-scaffold.d.ts +52 -0
  226. package/dist/lib/regression/test-scaffold.d.ts.map +1 -0
  227. package/dist/lib/regression/test-scaffold.js +237 -0
  228. package/dist/lib/regression/test-scaffold.js.map +1 -0
  229. package/dist/lib/work-queue/queue-format.d.ts +4 -0
  230. package/dist/lib/work-queue/queue-format.d.ts.map +1 -1
  231. package/dist/lib/work-queue/queue-format.js +15 -0
  232. package/dist/lib/work-queue/queue-format.js.map +1 -1
  233. package/dist/lib/work-queue/queue-worker.d.ts +16 -1
  234. package/dist/lib/work-queue/queue-worker.d.ts.map +1 -1
  235. package/dist/lib/work-queue/queue-worker.js +18 -0
  236. package/dist/lib/work-queue/queue-worker.js.map +1 -1
  237. package/dist/light-commands.d.ts.map +1 -1
  238. package/dist/light-commands.js +34 -0
  239. package/dist/light-commands.js.map +1 -1
  240. package/dist/tsconfig.tsbuildinfo +1 -0
  241. package/dist/utils/app-source-lookups.d.ts +19 -0
  242. package/dist/utils/app-source-lookups.d.ts.map +1 -0
  243. package/dist/utils/app-source-lookups.js +19 -0
  244. package/dist/utils/app-source-lookups.js.map +1 -0
  245. package/dist/utils/open-app-context.d.ts +1 -0
  246. package/dist/utils/open-app-context.d.ts.map +1 -1
  247. package/dist/utils/open-app-context.js +13 -17
  248. package/dist/utils/open-app-context.js.map +1 -1
  249. package/oclif.manifest.json +974 -31
  250. package/package.json +31 -28
  251. package/regression-compose/docker-compose.bacpac-standalone.yml +4 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The SQL an administrator runs to fix a failed preflight check.
3
+ *
4
+ * Every statement is taken from the installer's own step builder
5
+ * (`BuildPostgresSetupSteps` in `@memberjunction/installer`) when the installer has
6
+ * one for it, so `mj migrate` and `mj install` can never tell an administrator two
7
+ * different things. A statement is built here only when the installer has no step for
8
+ * it (an Open App schema, an extension outside `POSTGRES_MJ_EXTENSIONS`), and then
9
+ * with the installer's own quoting helper.
10
+ *
11
+ * @module lib/pg-preflight/remediation
12
+ */
13
+ import { BuildPostgresSetupSteps, QuotePgIdentifier } from '@memberjunction/installer';
14
+ /** The installer's steps for this database and login. Passwords are never printed. */
15
+ function installerSteps(session) {
16
+ return BuildPostgresSetupSteps({ DatabaseName: session.Database, CodeGenUser: session.Login });
17
+ }
18
+ /** The installer step matching `predicate`, or `fallback` when it has none. */
19
+ function pickStep(steps, predicate, fallback) {
20
+ const step = steps.find(predicate);
21
+ return step ? { Description: step.Description, Sql: step.Sql } : fallback;
22
+ }
23
+ /** `CREATE ROLE ... NOLOGIN` for each missing group role. */
24
+ export function RoleRemediation(session, missingRoles) {
25
+ const steps = installerSteps(session);
26
+ return missingRoles.map((role) => pickStep(steps, (s) => s.SkipIf?.Param === role && s.Sql.startsWith('CREATE ROLE') && s.Sql.endsWith(' NOLOGIN'), {
27
+ Description: `Create group role ${role}`,
28
+ Sql: `CREATE ROLE ${QuotePgIdentifier(role)} NOLOGIN`,
29
+ }));
30
+ }
31
+ /** `CREATE EXTENSION IF NOT EXISTS` for each extension. */
32
+ export function ExtensionRemediation(session, extensions) {
33
+ const steps = installerSteps(session);
34
+ return extensions.map((ext) => {
35
+ const sql = `CREATE EXTENSION IF NOT EXISTS ${QuotePgIdentifier(ext)}`;
36
+ return pickStep(steps, (s) => s.Sql === sql, { Description: `Create extension ${ext}`, Sql: sql });
37
+ });
38
+ }
39
+ /** `GRANT CONNECT, CREATE, TEMPORARY ON DATABASE` to the migrate login. */
40
+ export function DatabaseCreateRemediation(session) {
41
+ const steps = installerSteps(session);
42
+ const database = QuotePgIdentifier(session.Database);
43
+ const login = QuotePgIdentifier(session.Login);
44
+ return [
45
+ pickStep(steps, (s) => s.Sql.startsWith('GRANT CONNECT, CREATE, TEMPORARY ON DATABASE'), {
46
+ Description: `Let ${session.Login} connect and create schemas`,
47
+ Sql: `GRANT CONNECT, CREATE, TEMPORARY ON DATABASE ${database} TO ${login}`,
48
+ }),
49
+ ];
50
+ }
51
+ /** `ALTER SCHEMA ... OWNER TO` the migrate login. */
52
+ export function SchemaOwnerRemediation(session, schema) {
53
+ const sql = `ALTER SCHEMA ${QuotePgIdentifier(schema)} OWNER TO ${QuotePgIdentifier(session.Login)}`;
54
+ return [pickStep(installerSteps(session), (s) => s.Sql === sql, { Description: `Make ${session.Login} the owner of schema ${schema}`, Sql: sql })];
55
+ }
56
+ /**
57
+ * Renders every failed check's remediation as one script an administrator can paste
58
+ * into psql or any SQL client. Returns an empty string when nothing needs fixing.
59
+ */
60
+ export function RenderRemediationScript(report) {
61
+ const steps = uniqueSteps(report.Checks.filter((c) => c.Status === 'fail').flatMap((c) => c.Remediation));
62
+ if (steps.length === 0)
63
+ return '';
64
+ const lines = [
65
+ '-- Run as a PostgreSQL administrator (a superuser, rds_superuser on AWS RDS, or',
66
+ `-- azure_pg_admin on Azure), connected to database ${QuotePgIdentifier(report.Session.Database)}.`,
67
+ '-- Then run `mj migrate` again.',
68
+ ];
69
+ steps.forEach((step, index) => lines.push('', `-- ${index + 1}. ${step.Description}`, `${step.Sql};`));
70
+ return lines.join('\n');
71
+ }
72
+ /** Drops repeated statements, keeping the first. */
73
+ function uniqueSteps(steps) {
74
+ const seen = new Set();
75
+ return steps.filter((step) => {
76
+ if (seen.has(step.Sql))
77
+ return false;
78
+ seen.add(step.Sql);
79
+ return true;
80
+ });
81
+ }
82
+ //# sourceMappingURL=remediation.js.map
@@ -0,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AAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Text output for the managed-PostgreSQL preflight, shared by `mj doctor --db` and
3
+ * `mj migrate` so both print the same thing.
4
+ *
5
+ * @module lib/pg-preflight/render
6
+ */
7
+ import type { PgPreflightReport } from './types.js';
8
+ /**
9
+ * The report as printable lines: one per check, then (when anything failed) the
10
+ * non-SQL notes and the remediation script.
11
+ */
12
+ export declare function FormatPgPreflightReport(report: PgPreflightReport): string[];
13
+ /** One-line summary: counts of each status. */
14
+ export declare function SummarizePgPreflightReport(report: PgPreflightReport): string;
15
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/lib/pg-preflight/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,SAAS,CAAC;AAgBpE;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAgB3E;AAED,+CAA+C;AAC/C,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAG5E"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Text output for the managed-PostgreSQL preflight, shared by `mj doctor --db` and
3
+ * `mj migrate` so both print the same thing.
4
+ *
5
+ * @module lib/pg-preflight/render
6
+ */
7
+ import chalk from 'chalk';
8
+ import { RenderRemediationScript } from './remediation.js';
9
+ /** `[PASS]`-style tag for a status. */
10
+ function statusTag(status) {
11
+ switch (status) {
12
+ case 'pass':
13
+ return chalk.green('[PASS]');
14
+ case 'fail':
15
+ return chalk.red('[FAIL]');
16
+ case 'warn':
17
+ return chalk.yellow('[WARN]');
18
+ default:
19
+ return chalk.blue('[INFO]');
20
+ }
21
+ }
22
+ /**
23
+ * The report as printable lines: one per check, then (when anything failed) the
24
+ * non-SQL notes and the remediation script.
25
+ */
26
+ export function FormatPgPreflightReport(report) {
27
+ const { Session } = report;
28
+ const lines = [chalk.bold(`PostgreSQL readiness — database ${Session.Database}, login ${Session.Login}, schema ${report.TargetSchema}`)];
29
+ for (const check of report.Checks) {
30
+ lines.push(`${statusTag(check.Status)} ${check.Message}`);
31
+ }
32
+ const failed = report.Checks.filter((c) => c.Status === 'fail');
33
+ const notes = failed.flatMap((c) => c.Notes);
34
+ if (notes.length > 0) {
35
+ lines.push('', chalk.yellow('Also required:'), ...notes.map((n) => ` - ${n}`));
36
+ }
37
+ const script = RenderRemediationScript(report);
38
+ if (script) {
39
+ lines.push('', chalk.yellow('An administrator must run this SQL first:'), '', script);
40
+ }
41
+ return lines;
42
+ }
43
+ /** One-line summary: counts of each status. */
44
+ export function SummarizePgPreflightReport(report) {
45
+ const count = (s) => report.Checks.filter((c) => c.Status === s).length;
46
+ return `${count('fail')} failed, ${count('warn')} warning(s), ${count('pass')} passed`;
47
+ }
48
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/lib/pg-preflight/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,uCAAuC;AACvC,SAAS,SAAS,CAAC,MAAyB;IAC1C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC/B,KAAK,MAAM;YACT,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,KAAK,MAAM;YACT,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChC;YACE,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CA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EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3F,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,KAAK,CAAC,MAAM,CAAC,gBAAgB,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;AACzF,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Runs the managed-PostgreSQL preflight for an MJ config: reads the pending migrations,
3
+ * connects as the migrate login, runs the checks, and closes the connection.
4
+ *
5
+ * @module lib/pg-preflight/run-for-config
6
+ */
7
+ import type { SkywayConfig } from '@memberjunction/skyway-core';
8
+ import { type QueryRunner } from '../../baseline/connection.js';
9
+ import type { MJConfig } from '../../config.js';
10
+ import type { PgPreflightQueryRunner, PgPreflightReport } from './types.js';
11
+ /** The config fields the preflight connection needs. */
12
+ export type PgPreflightConnectionConfig = Pick<MJConfig, 'dbHost' | 'dbPort' | 'dbDatabase' | 'codeGenLogin' | 'codeGenPassword'>;
13
+ /**
14
+ * Runs the preflight.
15
+ *
16
+ * @param config - The MJ config `mj migrate` runs with (its CodeGen login is the migrate login).
17
+ * @param skywayProbe - A Skyway config for the same schema and migration location, used only
18
+ * to read pending migrations; its provider is connected and disconnected here.
19
+ */
20
+ export declare function RunPgPreflightForConfig(config: PgPreflightConnectionConfig, skywayProbe: SkywayConfig): Promise<PgPreflightReport>;
21
+ /** Wraps the baseline connection helper in the preflight's query interface. */
22
+ export declare function AdaptQueryRunner(connection: Pick<QueryRunner, 'query'>): PgPreflightQueryRunner;
23
+ //# sourceMappingURL=run-for-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-for-config.d.ts","sourceRoot":"","sources":["../../../src/lib/pg-preflight/run-for-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEzE,wDAAwD;AACxD,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,cAAc,GAAG,iBAAiB,CAAC,CAAC;AAElI;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,2BAA2B,EAAE,WAAW,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoBxI;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAI/F"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Runs the managed-PostgreSQL preflight for an MJ config: reads the pending migrations,
3
+ * connects as the migrate login, runs the checks, and closes the connection.
4
+ *
5
+ * @module lib/pg-preflight/run-for-config
6
+ */
7
+ import { OpenConnection } from '../../baseline/connection.js';
8
+ import { ReadPendingRequirements } from './pending-migrations.js';
9
+ import { RunPgManagedPreflight } from './preflight.js';
10
+ /**
11
+ * Runs the preflight.
12
+ *
13
+ * @param config - The MJ config `mj migrate` runs with (its CodeGen login is the migrate login).
14
+ * @param skywayProbe - A Skyway config for the same schema and migration location, used only
15
+ * to read pending migrations; its provider is connected and disconnected here.
16
+ */
17
+ export async function RunPgPreflightForConfig(config, skywayProbe) {
18
+ const pending = await ReadPendingRequirements(skywayProbe);
19
+ const connection = await OpenConnection({
20
+ Dialect: 'postgres',
21
+ Host: config.dbHost,
22
+ port: config.dbPort,
23
+ User: config.codeGenLogin,
24
+ Password: config.codeGenPassword,
25
+ Database: config.dbDatabase,
26
+ });
27
+ try {
28
+ return await RunPgManagedPreflight(AdaptQueryRunner(connection), {
29
+ TargetSchema: skywayProbe.Migrations.DefaultSchema ?? '__mj',
30
+ RequiredExtensions: pending.Extensions,
31
+ RequiredRoles: pending.Roles,
32
+ Host: config.dbHost,
33
+ });
34
+ }
35
+ finally {
36
+ await connection.close();
37
+ }
38
+ }
39
+ /** Wraps the baseline connection helper in the preflight's query interface. */
40
+ export function AdaptQueryRunner(connection) {
41
+ return {
42
+ Query: (sql, params) => connection.query(sql, params),
43
+ };
44
+ }
45
+ //# sourceMappingURL=run-for-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-for-config.js","sourceRoot":"","sources":["../../../src/lib/pg-preflight/run-for-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAoB,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAMpD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,MAAmC,EAAE,WAAyB;IAC1G,MAAM,OAAO,GAAG,MAAM,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC;QACtC,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,IAAI,EAAE,MAAM,CAAC,YAAY;QACzB,QAAQ,EAAE,MAAM,CAAC,eAAe;QAChC,QAAQ,EAAE,MAAM,CAAC,UAAU;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,MAAM,qBAAqB,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;YAC/D,YAAY,EAAE,WAAW,CAAC,UAAU,CAAC,aAAa,IAAI,MAAM;YAC5D,kBAAkB,EAAE,OAAO,CAAC,UAAU;YACtC,aAAa,EAAE,OAAO,CAAC,KAAK;YAC5B,IAAI,EAAE,MAAM,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAAC,UAAsC;IACrE,OAAO;QACL,KAAK,EAAE,CAAI,GAAW,EAAE,MAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAI,GAAG,EAAE,MAAM,CAAC;KAChF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Types for the managed-PostgreSQL preflight (`mj doctor --db`, and the check `mj migrate`
3
+ * runs before it applies anything on PostgreSQL).
4
+ *
5
+ * @module lib/pg-preflight/types
6
+ */
7
+ /**
8
+ * The one database call the checks make. An interface rather than a `pg.Client` so the
9
+ * checks can be unit-tested against a fake.
10
+ */
11
+ export interface PgPreflightQueryRunner {
12
+ /** Run one statement with optional `$n` parameters and return its rows. */
13
+ Query<T>(sql: string, params?: unknown[]): Promise<T[]>;
14
+ }
15
+ /** Outcome of one check. Only `fail` blocks `mj migrate`. */
16
+ export type PgPreflightStatus = 'pass' | 'fail' | 'warn' | 'info';
17
+ /** The checks, in the order they run and print. */
18
+ export type PgPreflightCheckId = 'server-version' | 'group-roles' | 'database-create' | 'target-schema' | 'extensions' | 'tls' | 'connections';
19
+ /** One statement an administrator runs to fix a failed check. */
20
+ export interface PgRemediationStep {
21
+ /** What the statement does, printed as a comment above it. */
22
+ Description: string;
23
+ /** The statement, without a trailing semicolon. */
24
+ Sql: string;
25
+ }
26
+ /** The result of one check. */
27
+ export interface PgPreflightCheck {
28
+ Id: PgPreflightCheckId;
29
+ Status: PgPreflightStatus;
30
+ /** One line describing what was found. */
31
+ Message: string;
32
+ /** SQL that fixes a `fail` (empty otherwise, or when the fix is not SQL). */
33
+ Remediation: PgRemediationStep[];
34
+ /** Fixes that are not SQL, such as a server parameter on a managed host. */
35
+ Notes: string[];
36
+ }
37
+ /** What the session reports about itself; read once and shared by the checks. */
38
+ export interface PgSessionContext {
39
+ Login: string;
40
+ Database: string;
41
+ ServerVersion: string;
42
+ ServerVersionNum: number;
43
+ CanCreateInDatabase: boolean;
44
+ IsSuperuser: boolean;
45
+ }
46
+ /** Inputs to `RunPgManagedPreflight`. */
47
+ export interface PgPreflightOptions {
48
+ /** Schema the migrations target (`__mj`, or an Open App schema). */
49
+ TargetSchema: string;
50
+ /** Extensions the pending migrations `CREATE`. */
51
+ RequiredExtensions: readonly string[];
52
+ /** Group roles the migrations grant to. Defaults to the installer's `POSTGRES_MJ_GROUP_ROLES`. */
53
+ RequiredRoles?: readonly string[];
54
+ /** Host the session connected to; a loopback host downgrades the TLS warning to info. */
55
+ Host?: string;
56
+ /** Lowest supported `server_version_num`. Defaults to 140000 (PostgreSQL 14). */
57
+ MinimumServerVersionNum?: number;
58
+ }
59
+ /** The full preflight outcome. */
60
+ export interface PgPreflightReport {
61
+ Session: PgSessionContext;
62
+ TargetSchema: string;
63
+ Checks: PgPreflightCheck[];
64
+ /** False when any check failed. */
65
+ Passed: boolean;
66
+ }
67
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/pg-preflight/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,2EAA2E;IAC3E,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CACzD;AAED,6DAA6D;AAC7D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAElE,mDAAmD;AACnD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,aAAa,GACb,iBAAiB,GAC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the managed-PostgreSQL preflight (`mj doctor --db`, and the check `mj migrate`
3
+ * runs before it applies anything on PostgreSQL).
4
+ *
5
+ * @module lib/pg-preflight/types
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/pg-preflight/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,52 @@
1
+ export declare const REGRESSION_TESTS_DIR = "metadata-optional/regression-test/tests/regression";
2
+ export declare const REGRESSION_SUITE_FILE = "metadata-optional/regression-test/test-suites/.regression-suite.json";
3
+ export declare const REGRESSION_PARITY_SCRIPT = ".github/scripts/check-regression-suite.mjs";
4
+ declare const PRIORITIES: readonly ["P0", "P1", "P2", "P3"];
5
+ export type JsonPrimitive = string | number | boolean | null;
6
+ export type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
7
+ export type JsonObject = {
8
+ [key: string]: JsonValue;
9
+ };
10
+ export type RegressionPriority = (typeof PRIORITIES)[number];
11
+ export interface ScaffoldOptions {
12
+ /** Title without the `T### - ` prefix. */
13
+ Title: string;
14
+ /** What the controller LLM must achieve, stated as the success state. */
15
+ Goal: string;
16
+ /** Judge criteria, checked against the final screenshot. */
17
+ Criteria: string[];
18
+ Priority: RegressionPriority;
19
+ /** Area tags. The priority and `regression` are always added. */
20
+ Tags: string[];
21
+ /** Path after the base URL, e.g. `/app/form-builder`. Empty for the app root. */
22
+ StartPath: string;
23
+ MaxSteps: number;
24
+ /** Defaults to the goal. */
25
+ Description?: string;
26
+ /** Copy `Configuration` from this existing test number. */
27
+ FromNumber?: number;
28
+ }
29
+ export interface ScaffoldResult {
30
+ Number: number;
31
+ Name: string;
32
+ Sequence: number;
33
+ /** Repo-relative path of the new test file. */
34
+ TestFilePath: string;
35
+ TestFileContent: string;
36
+ SuiteFileContent: string;
37
+ }
38
+ export declare function IsRegressionPriority(value: string): value is RegressionPriority;
39
+ /** Formats a test number as `T###`. */
40
+ export declare function FormatTestNumber(n: number): string;
41
+ /** Parses `T149` or `149` into `149`. */
42
+ export declare function ParseTestNumber(text: string): number;
43
+ /** Turns a title into the kebab-case part of a test file name. */
44
+ export declare function SlugifyTitle(title: string): string;
45
+ /** Returns the highest `.T###-*.json` number plus one. */
46
+ export declare function NextTestNumber(fileNames: string[]): number;
47
+ /** Builds the new test record and the updated suite file. Writes nothing. */
48
+ export declare function BuildScaffold(repoRoot: string, options: ScaffoldOptions): ScaffoldResult;
49
+ /** Writes the test file and the updated suite file. Refuses to overwrite a test file. */
50
+ export declare function WriteScaffold(repoRoot: string, result: ScaffoldResult): void;
51
+ export {};
52
+ //# sourceMappingURL=test-scaffold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-scaffold.d.ts","sourceRoot":"","sources":["../../../src/lib/regression/test-scaffold.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,oBAAoB,uDAAuD,CAAC;AACzF,eAAO,MAAM,qBAAqB,yEAAyE,CAAC;AAC5G,eAAO,MAAM,wBAAwB,+CAA+C,CAAC;AAUrF,QAAA,MAAM,UAAU,mCAAoC,CAAC;AAErD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG,UAAU,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AA6C7D,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,iEAAiE;IACjE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,kBAAkB,CAE/E;AAED,uCAAuC;AACvC,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,yCAAyC;AACzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOlD;AAED,0DAA0D;AAC1D,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAO1D;AA2HD,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,cAAc,CAuCxF;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAS5E"}
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Builds new MJ Explorer regression tests: the `.T###-<slug>.json` test record and its member row
3
+ * in `.regression-suite.json`. Building and writing are separate so callers can preview the result.
4
+ */
5
+ import { randomUUID } from 'node:crypto';
6
+ import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ export const REGRESSION_TESTS_DIR = 'metadata-optional/regression-test/tests/regression';
9
+ export const REGRESSION_SUITE_FILE = 'metadata-optional/regression-test/test-suites/.regression-suite.json';
10
+ export const REGRESSION_PARITY_SCRIPT = '.github/scripts/check-regression-suite.mjs';
11
+ const COMPUTER_USE_TYPE = '@lookup:MJ: Test Types.Name=Computer Use';
12
+ const MEMBER_ENTITY = 'MJ: Test Suite Tests';
13
+ const BASE_URL = 'http://localhost:4200';
14
+ const ALLOWED_DOMAINS = ['localhost', '*.auth0.com'];
15
+ const NOT_LOGIN_PAGE = '(?!/login|/callback)';
16
+ const MS_PER_STEP = 12000;
17
+ const MIN_EXECUTION_MS = 300000;
18
+ const TEST_FILE_RE = /^\.T(\d{3,})-.+\.json$/;
19
+ const PRIORITIES = ['P0', 'P1', 'P2', 'P3'];
20
+ /** The values `mj sync pull` writes for the `MJ: Tests` fields the scaffold does not author. */
21
+ const PULLED_FIELD_DEFAULTS = {
22
+ Priority: 0,
23
+ EstimatedDurationSeconds: null,
24
+ EstimatedCostUSD: null,
25
+ RepeatCount: null,
26
+ MaxExecutionTimeMS: null,
27
+ Variables: null,
28
+ SkipEmbeddings: false,
29
+ RubricID: null,
30
+ };
31
+ export function IsRegressionPriority(value) {
32
+ return PRIORITIES.includes(value);
33
+ }
34
+ /** Formats a test number as `T###`. */
35
+ export function FormatTestNumber(n) {
36
+ return `T${String(n).padStart(3, '0')}`;
37
+ }
38
+ /** Parses `T149` or `149` into `149`. */
39
+ export function ParseTestNumber(text) {
40
+ const match = /^T?(\d+)$/i.exec(text.trim());
41
+ if (!match)
42
+ throw new Error(`"${text}" is not a test number (use T149 or 149).`);
43
+ return Number(match[1]);
44
+ }
45
+ /** Turns a title into the kebab-case part of a test file name. */
46
+ export function SlugifyTitle(title) {
47
+ return title
48
+ .toLowerCase()
49
+ .replace(/[^a-z0-9]+/g, '-')
50
+ .replace(/^-+|-+$/g, '')
51
+ .slice(0, 60)
52
+ .replace(/-+$/, '');
53
+ }
54
+ /** Returns the highest `.T###-*.json` number plus one. */
55
+ export function NextTestNumber(fileNames) {
56
+ let max = 0;
57
+ for (const name of fileNames) {
58
+ const match = TEST_FILE_RE.exec(name);
59
+ if (match)
60
+ max = Math.max(max, Number(match[1]));
61
+ }
62
+ return max + 1;
63
+ }
64
+ function newRecordId() {
65
+ return randomUUID().toUpperCase();
66
+ }
67
+ function isJsonObject(value) {
68
+ return value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
69
+ }
70
+ function escapeRegExp(text) {
71
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
72
+ }
73
+ function normalizeStartPath(startPath) {
74
+ const trimmed = startPath.trim();
75
+ if (trimmed === '' || trimmed === '/')
76
+ return '';
77
+ return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
78
+ }
79
+ function buildTags(priority, tags) {
80
+ const extra = tags
81
+ .map((t) => t.trim().toLowerCase())
82
+ .filter((t) => t !== '' && t !== 'regression' && !/^p[0-3]$/.test(t));
83
+ return [priority, 'regression', ...new Set(extra)].join(',');
84
+ }
85
+ /** Validates the options and returns the trimmed, non-empty criteria. */
86
+ function validateOptions(options) {
87
+ if (options.Title.trim() === '')
88
+ throw new Error('A test title is required.');
89
+ if (options.Title.includes('&'))
90
+ throw new Error('The title must not contain "&" (it breaks the @lookup parser). Use "and".');
91
+ if (options.Goal.trim() === '')
92
+ throw new Error('A goal is required.');
93
+ const criteria = options.Criteria.map((c) => c.trim()).filter((c) => c !== '');
94
+ if (criteria.length === 0)
95
+ throw new Error('At least one --criteria is required.');
96
+ if (!Number.isInteger(options.MaxSteps) || options.MaxSteps < 1)
97
+ throw new Error('--max-steps must be a positive integer.');
98
+ return criteria;
99
+ }
100
+ function defaultConfiguration() {
101
+ return {
102
+ headless: true,
103
+ maxSteps: 0,
104
+ maxExecutionTime: 0,
105
+ screenshotHistoryDepth: 3,
106
+ viewportWidth: 1280,
107
+ viewportHeight: 720,
108
+ controllerPromptName: 'Computer Use - Controller',
109
+ judgePromptName: 'Computer Use - Judge',
110
+ judgeFrequency: 'EveryNSteps:3',
111
+ oracles: [
112
+ { type: 'goal-completion', weight: 0.5, config: { minConfidence: 0.7 } },
113
+ { type: 'url-match', weight: 0.3, config: { pattern: '' } },
114
+ { type: 'step-count', weight: 0.2, config: { maxSteps: 0 } },
115
+ ],
116
+ scoringWeights: { 'goal-completion': 0.5, 'url-match': 0.3, 'step-count': 0.2 },
117
+ };
118
+ }
119
+ /** Builds Configuration from a source test (minus its replay scripts) or from the default template. */
120
+ function buildConfiguration(maxSteps, finalUrlPattern, source) {
121
+ const configuration = source ? structuredClone(source) : defaultConfiguration();
122
+ delete configuration.ReplayScript;
123
+ delete configuration.PendingReplayScript;
124
+ configuration.maxSteps = maxSteps;
125
+ configuration.maxExecutionTime = Math.max(MIN_EXECUTION_MS, maxSteps * MS_PER_STEP);
126
+ const oracles = configuration.oracles;
127
+ if (Array.isArray(oracles)) {
128
+ for (const oracle of oracles) {
129
+ if (!isJsonObject(oracle) || !isJsonObject(oracle.config))
130
+ continue;
131
+ if (oracle.type === 'url-match')
132
+ oracle.config.pattern = finalUrlPattern;
133
+ if (oracle.type === 'step-count')
134
+ oracle.config.maxSteps = maxSteps;
135
+ }
136
+ }
137
+ return configuration;
138
+ }
139
+ function readSourceConfiguration(testsDir, fileNames, fromNumber) {
140
+ const prefix = `.${FormatTestNumber(fromNumber)}-`;
141
+ const file = fileNames.find((n) => n.startsWith(prefix) && n.endsWith('.json'));
142
+ if (!file)
143
+ throw new Error(`No test file starts with ${prefix} in ${REGRESSION_TESTS_DIR}.`);
144
+ const source = JSON.parse(readFileSync(path.join(testsDir, file), 'utf8'));
145
+ return source.fields.Configuration;
146
+ }
147
+ function suiteMembers(suite) {
148
+ const list = suite.relatedEntities?.[MEMBER_ENTITY];
149
+ if (!Array.isArray(list))
150
+ throw new Error(`${REGRESSION_SUITE_FILE} has no relatedEntities["${MEMBER_ENTITY}"].`);
151
+ return list;
152
+ }
153
+ function buildInputDefinition(goal, startUrl) {
154
+ const input = {
155
+ goal,
156
+ startUrl,
157
+ allowedDomains: ALLOWED_DOMAINS,
158
+ auth: {
159
+ bindings: [
160
+ {
161
+ domains: ALLOWED_DOMAINS,
162
+ method: { Type: 'Basic', Username: '{{authUsername}}', Password: '{{authPassword}}', Strategy: 'FormLogin' },
163
+ },
164
+ ],
165
+ },
166
+ };
167
+ return JSON.stringify(input, null, 2);
168
+ }
169
+ function buildExpectedOutcomes(finalUrlPattern, maxSteps, criteria) {
170
+ const expected = { goalCompleted: true, finalUrlPattern, minConfidence: 0.7, maxSteps, judgeValidationCriteria: criteria };
171
+ return JSON.stringify(expected, null, 2);
172
+ }
173
+ /** Appends a member for `name` to the suite and returns its Sequence. */
174
+ function appendSuiteMember(suite, name) {
175
+ const members = suiteMembers(suite);
176
+ const sequence = members.reduce((max, m) => Math.max(max, m.fields.Sequence), 0) + 1;
177
+ members.push({
178
+ fields: { SuiteID: '@parent:ID', TestID: `@lookup:MJ: Tests.Name=${name}`, Sequence: sequence, Status: 'Active' },
179
+ primaryKey: { ID: newRecordId() },
180
+ });
181
+ return sequence;
182
+ }
183
+ /** Builds the new test record and the updated suite file. Writes nothing. */
184
+ export function BuildScaffold(repoRoot, options) {
185
+ const criteria = validateOptions(options);
186
+ const testsDir = path.join(repoRoot, REGRESSION_TESTS_DIR);
187
+ const fileNames = readdirSync(testsDir);
188
+ const number = NextTestNumber(fileNames);
189
+ const title = options.Title.trim();
190
+ const name = `${FormatTestNumber(number)} - ${title}`;
191
+ const startPath = normalizeStartPath(options.StartPath);
192
+ const startUrl = `${BASE_URL}${startPath}`;
193
+ const finalUrlPattern = `^${escapeRegExp(startUrl)}${startPath === '' ? NOT_LOGIN_PAGE : ''}`;
194
+ const source = options.FromNumber === undefined ? undefined : readSourceConfiguration(testsDir, fileNames, options.FromNumber);
195
+ const record = {
196
+ fields: {
197
+ TypeID: COMPUTER_USE_TYPE,
198
+ Name: name,
199
+ Description: (options.Description ?? options.Goal).trim(),
200
+ InputDefinition: buildInputDefinition(options.Goal.trim(), startUrl),
201
+ ExpectedOutcomes: buildExpectedOutcomes(finalUrlPattern, options.MaxSteps, criteria),
202
+ Configuration: buildConfiguration(options.MaxSteps, finalUrlPattern, source),
203
+ Status: 'Active',
204
+ Tags: buildTags(options.Priority, options.Tags),
205
+ ...PULLED_FIELD_DEFAULTS,
206
+ },
207
+ primaryKey: { ID: newRecordId() },
208
+ };
209
+ const suiteText = readFileSync(path.join(repoRoot, REGRESSION_SUITE_FILE), 'utf8');
210
+ const suite = JSON.parse(suiteText);
211
+ const sequence = appendSuiteMember(suite, name);
212
+ return {
213
+ Number: number,
214
+ Name: name,
215
+ Sequence: sequence,
216
+ TestFilePath: `${REGRESSION_TESTS_DIR}/.${FormatTestNumber(number)}-${SlugifyTitle(title)}.json`,
217
+ TestFileContent: `${JSON.stringify(record, null, 2)}\n`,
218
+ SuiteFileContent: JSON.stringify(suite, null, 2) + (suiteText.endsWith('\n') ? '\n' : ''),
219
+ };
220
+ }
221
+ /** Writes the test file and the updated suite file. Refuses to overwrite a test file. */
222
+ export function WriteScaffold(repoRoot, result) {
223
+ const testPath = path.join(repoRoot, result.TestFilePath);
224
+ try {
225
+ writeFileSync(testPath, result.TestFileContent, { flag: 'wx' });
226
+ }
227
+ catch (error) {
228
+ if (isAlreadyExistsError(error))
229
+ throw new Error(`${result.TestFilePath} already exists.`);
230
+ throw error;
231
+ }
232
+ writeFileSync(path.join(repoRoot, REGRESSION_SUITE_FILE), result.SuiteFileContent);
233
+ }
234
+ function isAlreadyExistsError(error) {
235
+ return error instanceof Error && 'code' in error && error.code === 'EEXIST';
236
+ }
237
+ //# sourceMappingURL=test-scaffold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-scaffold.js","sourceRoot":"","sources":["../../../src/lib/regression/test-scaffold.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,E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