@antelopejs/dms 0.15.1 → 0.16.1

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 (295) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +36 -26
  3. package/bin/control/base.mjs +9 -4
  4. package/bin/control/browser-client.mjs +24 -5
  5. package/bin/control/browser-wire.mjs +41 -0
  6. package/bin/control/browser-wire.test.mjs +96 -0
  7. package/bin/control/browser.mjs +78 -27
  8. package/bin/control/commands-stack.mjs +58 -8
  9. package/bin/control/commands-verify.mjs +47 -1
  10. package/bin/control/doctor.mjs +49 -4
  11. package/bin/control/failure.mjs +9 -0
  12. package/bin/control/journey.mjs +158 -30
  13. package/bin/control/journey.test.mjs +61 -0
  14. package/bin/control/json.mjs +229 -0
  15. package/bin/control/json.test.mjs +130 -0
  16. package/bin/control/mail.mjs +57 -7
  17. package/bin/control/mail.test.mjs +55 -0
  18. package/bin/control/mongo.mjs +205 -27
  19. package/bin/control/mongo.test.mjs +298 -0
  20. package/bin/control/options.mjs +33 -0
  21. package/bin/control/processes.mjs +24 -2
  22. package/bin/control/renderer.mjs +39 -0
  23. package/bin/control/renderer.test.mjs +324 -0
  24. package/bin/control/run-state.mjs +119 -6
  25. package/bin/control/run-state.test.mjs +171 -0
  26. package/bin/control/session.mjs +30 -14
  27. package/bin/control/stack.mjs +95 -24
  28. package/bin/control/tab.mjs +117 -18
  29. package/bin/control/verify/behaviour.mjs +44 -6
  30. package/bin/control/verify/behaviour.test.mjs +130 -22
  31. package/bin/control/verify/decode.mjs +220 -0
  32. package/bin/control/verify/decode.test.mjs +245 -0
  33. package/bin/control/verify/doors.mjs +1 -1
  34. package/bin/control/verify/doors.test.mjs +40 -0
  35. package/bin/control/verify/emit.mjs +135 -9
  36. package/bin/control/verify/formal.mjs +61 -10
  37. package/bin/control/verify/formal.test.mjs +19 -3
  38. package/bin/control/verify/judgement.mjs +22 -3
  39. package/bin/control/verify/map.mjs +25 -5
  40. package/bin/control/verify/publish.mjs +20 -14
  41. package/bin/control/verify/seeded.mjs +65 -16
  42. package/bin/control/verify/skill.mjs +27 -6
  43. package/bin/control/verify/types.mjs +29 -0
  44. package/bin/control/verify/verdict.mjs +72 -7
  45. package/bin/dms-control.mjs +8 -28
  46. package/checks/api-error-presentation.d.mts +61 -0
  47. package/dist/attachments/access.js +1 -1
  48. package/dist/attachments/access.js.map +1 -1
  49. package/dist/attachments/fields.d.ts +2 -2
  50. package/dist/attachments/fields.js +26 -13
  51. package/dist/attachments/fields.js.map +1 -1
  52. package/dist/attachments/index.d.ts +1 -0
  53. package/dist/attachments/index.js +1 -0
  54. package/dist/attachments/index.js.map +1 -1
  55. package/dist/attachments/read.js.map +1 -1
  56. package/dist/attachments/save.d.ts +1 -1
  57. package/dist/attachments/save.js +49 -17
  58. package/dist/attachments/save.js.map +1 -1
  59. package/dist/attachments/table-view.d.ts +1 -2
  60. package/dist/attachments/table-view.js +23 -13
  61. package/dist/attachments/table-view.js.map +1 -1
  62. package/dist/automation/events.d.ts +10 -10
  63. package/dist/automation/index.js +3 -4
  64. package/dist/automation/index.js.map +1 -1
  65. package/dist/automation/send-notification.d.ts +2 -2
  66. package/dist/automation/send-notification.js +4 -6
  67. package/dist/automation/send-notification.js.map +1 -1
  68. package/dist/crons/cleanup-user-invites.js.map +1 -1
  69. package/dist/crons/sweep-expired-sessions.js.map +1 -1
  70. package/dist/crons/sweep-stale-exports.js.map +1 -1
  71. package/dist/db/guard-row.d.ts +2 -3
  72. package/dist/db/guard-row.js +1 -2
  73. package/dist/db/guard-row.js.map +1 -1
  74. package/dist/db/models/attachments.model.d.ts +7 -5
  75. package/dist/db/models/setupToken.model.d.ts +7 -5
  76. package/dist/db/models/signInAttempts.model.d.ts +7 -5
  77. package/dist/db/models/systemState.model.d.ts +7 -5
  78. package/dist/db/models/userEmailChanges.model.d.ts +7 -5
  79. package/dist/db/models/userKnownDevices.model.d.ts +7 -5
  80. package/dist/db/models/userNotificationPreferences.model.d.ts +7 -5
  81. package/dist/db/models/userNotifications.model.d.ts +9 -6
  82. package/dist/db/models/userNotifications.model.js.map +1 -1
  83. package/dist/dev/module-update-notifications.js.map +1 -1
  84. package/dist/hooks/internal/sign-in-monitor.js +6 -6
  85. package/dist/hooks/internal/sign-in-monitor.js.map +1 -1
  86. package/dist/implementations/dms/page/controller.d.ts +2 -2
  87. package/dist/implementations/dms/page/controller.js +3 -1
  88. package/dist/implementations/dms/page/controller.js.map +1 -1
  89. package/dist/implementations/dms/page/dynamic-menu.js +3 -2
  90. package/dist/implementations/dms/page/dynamic-menu.js.map +1 -1
  91. package/dist/implementations/dms/page/notifications.d.ts +6 -2
  92. package/dist/implementations/dms/page/notifications.js +1 -0
  93. package/dist/implementations/dms/page/notifications.js.map +1 -1
  94. package/dist/implementations/dms/page/preview-pages.js +6 -3
  95. package/dist/implementations/dms/page/preview-pages.js.map +1 -1
  96. package/dist/implementations/dms/page/registry.js +10 -4
  97. package/dist/implementations/dms/page/registry.js.map +1 -1
  98. package/dist/implementations/dms/permissions.js +12 -12
  99. package/dist/implementations/dms/permissions.js.map +1 -1
  100. package/dist/implementations/dms-base/bulk-selection.d.ts +3 -4
  101. package/dist/implementations/dms-base/bulk-selection.js +18 -6
  102. package/dist/implementations/dms-base/bulk-selection.js.map +1 -1
  103. package/dist/implementations/dms-base/filter-tokens.js.map +1 -1
  104. package/dist/implementations/dms-base/footer-summary.js +44 -27
  105. package/dist/implementations/dms-base/footer-summary.js.map +1 -1
  106. package/dist/implementations/dms-base/row-rule-operand.d.ts +6 -0
  107. package/dist/implementations/dms-base/row-rule-operand.js +41 -0
  108. package/dist/implementations/dms-base/row-rule-operand.js.map +1 -0
  109. package/dist/implementations/dms-base/search-route.d.ts +9 -13
  110. package/dist/implementations/dms-base/search-route.js +7 -6
  111. package/dist/implementations/dms-base/search-route.js.map +1 -1
  112. package/dist/implementations/dms-base/services.d.ts +1 -0
  113. package/dist/implementations/dms-base/services.js +1 -0
  114. package/dist/implementations/dms-base/services.js.map +1 -1
  115. package/dist/implementations/dms-base/table-view.d.ts +5 -6
  116. package/dist/implementations/dms-base/table-view.js +17 -6
  117. package/dist/implementations/dms-base/table-view.js.map +1 -1
  118. package/dist/implementations/dms-html-render/index.js +16 -6
  119. package/dist/implementations/dms-html-render/index.js.map +1 -1
  120. package/dist/implementations/dms-notifications/delivery-guard.d.ts +3 -2
  121. package/dist/implementations/dms-notifications/delivery-guard.js.map +1 -1
  122. package/dist/implementations/dms-notifications/index.js.map +1 -1
  123. package/dist/index.js.map +1 -1
  124. package/dist/pages/public/preview/block-types.d.ts +1 -2
  125. package/dist/pages/public/preview/block-types.js.map +1 -1
  126. package/dist/pages/settings/overview/account-summary.js +4 -1
  127. package/dist/pages/settings/overview/account-summary.js.map +1 -1
  128. package/dist/pages/settings/users/account-activity-feed.js +3 -2
  129. package/dist/pages/settings/users/account-activity-feed.js.map +1 -1
  130. package/dist/pages/settings/users/account-credentials.d.ts +1 -1
  131. package/dist/pages/settings/users/account-credentials.js +1 -2
  132. package/dist/pages/settings/users/account-credentials.js.map +1 -1
  133. package/dist/pages/settings/users/account-data-store.d.ts +1 -1
  134. package/dist/pages/settings/users/account-data-store.js +1 -3
  135. package/dist/pages/settings/users/account-data-store.js.map +1 -1
  136. package/dist/pages/settings/users/email-change.d.ts +2 -2
  137. package/dist/pages/settings/users/email-change.js +2 -3
  138. package/dist/pages/settings/users/email-change.js.map +1 -1
  139. package/dist/pages/settings/users/invite-extension-routes.d.ts +2 -2
  140. package/dist/pages/settings/users/invite-extension-routes.js +11 -4
  141. package/dist/pages/settings/users/invite-extension-routes.js.map +1 -1
  142. package/dist/pages/settings/users/invites.d.ts +2 -2
  143. package/dist/pages/settings/users/member-invite-batch.d.ts +2 -2
  144. package/dist/pages/settings/users/member-invite-batch.js +7 -3
  145. package/dist/pages/settings/users/member-invite-batch.js.map +1 -1
  146. package/dist/pages/settings/users/member-roles-field.js +1 -4
  147. package/dist/pages/settings/users/member-roles-field.js.map +1 -1
  148. package/dist/pages/settings/users/members.d.ts +2 -3
  149. package/dist/pages/settings/users/members.js.map +1 -1
  150. package/dist/pages/settings/users/notifications.d.ts +2 -3
  151. package/dist/pages/settings/users/notifications.js +2 -1
  152. package/dist/pages/settings/users/notifications.js.map +1 -1
  153. package/dist/pages/settings/users/profile-helpers.d.ts +0 -1
  154. package/dist/pages/settings/users/profile-helpers.js +0 -17
  155. package/dist/pages/settings/users/profile-helpers.js.map +1 -1
  156. package/dist/pages/settings/users/profile.d.ts +3 -4
  157. package/dist/pages/settings/users/profile.js +12 -12
  158. package/dist/pages/settings/users/profile.js.map +1 -1
  159. package/dist/pages/settings/users/region.d.ts +3 -4
  160. package/dist/pages/settings/users/region.js.map +1 -1
  161. package/dist/pages/settings/users/regional-preferences.d.ts +8 -1
  162. package/dist/pages/settings/users/regional-preferences.js +10 -6
  163. package/dist/pages/settings/users/regional-preferences.js.map +1 -1
  164. package/dist/pages/settings/users/role-preview.js +3 -2
  165. package/dist/pages/settings/users/role-preview.js.map +1 -1
  166. package/dist/pages/settings/users/roles.d.ts +4 -5
  167. package/dist/pages/settings/users/roles.js.map +1 -1
  168. package/dist/pages/settings/users/security.d.ts +9 -12
  169. package/dist/pages/settings/users/security.js +11 -9
  170. package/dist/pages/settings/users/security.js.map +1 -1
  171. package/dist/pages/settings/users/two-factor-operations.d.ts +7 -7
  172. package/dist/pages/settings/users/two-factor-operations.js +5 -7
  173. package/dist/pages/settings/users/two-factor-operations.js.map +1 -1
  174. package/dist/realtime/broker.js.map +1 -1
  175. package/dist/realtime/heartbeat.js.map +1 -1
  176. package/dist/realtime/redis-broker.js.map +1 -1
  177. package/dist/realtime/sessions.js.map +1 -1
  178. package/dist/realtime/sse.js +1 -2
  179. package/dist/realtime/sse.js.map +1 -1
  180. package/dist/routes/auth/forgot-password.d.ts +1 -1
  181. package/dist/routes/auth/forgot-password.js +1 -3
  182. package/dist/routes/auth/forgot-password.js.map +1 -1
  183. package/dist/routes/auth/login.d.ts +1 -1
  184. package/dist/routes/auth/login.js +1 -2
  185. package/dist/routes/auth/login.js.map +1 -1
  186. package/dist/routes/auth/logout.d.ts +1 -1
  187. package/dist/routes/auth/logout.js +1 -2
  188. package/dist/routes/auth/logout.js.map +1 -1
  189. package/dist/routes/auth/oauth/providers.js +30 -6
  190. package/dist/routes/auth/oauth/providers.js.map +1 -1
  191. package/dist/routes/auth/oauth/state.js +8 -5
  192. package/dist/routes/auth/oauth/state.js.map +1 -1
  193. package/dist/routes/auth/oauth/token-exchange.js +8 -1
  194. package/dist/routes/auth/oauth/token-exchange.js.map +1 -1
  195. package/dist/routes/auth/refresh.d.ts +1 -1
  196. package/dist/routes/auth/refresh.js +1 -2
  197. package/dist/routes/auth/refresh.js.map +1 -1
  198. package/dist/routes/auth/request-2fa-email.d.ts +1 -1
  199. package/dist/routes/auth/request-2fa-email.js +1 -2
  200. package/dist/routes/auth/request-2fa-email.js.map +1 -1
  201. package/dist/routes/auth/reset-password.d.ts +1 -1
  202. package/dist/routes/auth/reset-password.js +1 -3
  203. package/dist/routes/auth/reset-password.js.map +1 -1
  204. package/dist/routes/auth/session-handoff.d.ts +1 -1
  205. package/dist/routes/auth/session-handoff.js +1 -2
  206. package/dist/routes/auth/session-handoff.js.map +1 -1
  207. package/dist/routes/auth/signup.d.ts +1 -1
  208. package/dist/routes/auth/signup.js +1 -2
  209. package/dist/routes/auth/signup.js.map +1 -1
  210. package/dist/routes/auth/switch-tenant.d.ts +2 -3
  211. package/dist/routes/auth/switch-tenant.js +3 -2
  212. package/dist/routes/auth/switch-tenant.js.map +1 -1
  213. package/dist/routes/auth/validate-forgot-password-token.d.ts +1 -1
  214. package/dist/routes/auth/validate-forgot-password-token.js +1 -3
  215. package/dist/routes/auth/validate-forgot-password-token.js.map +1 -1
  216. package/dist/routes/auth/validate-invite-token.d.ts +1 -1
  217. package/dist/routes/auth/validate-invite-token.js +1 -3
  218. package/dist/routes/auth/validate-invite-token.js.map +1 -1
  219. package/dist/routes/auth/verify-2fa.d.ts +1 -1
  220. package/dist/routes/auth/verify-2fa.js +1 -2
  221. package/dist/routes/auth/verify-2fa.js.map +1 -1
  222. package/dist/routes/auth/verify-email.d.ts +1 -1
  223. package/dist/routes/auth/verify-email.js +1 -2
  224. package/dist/routes/auth/verify-email.js.map +1 -1
  225. package/dist/routes/auth.d.ts +14 -15
  226. package/dist/routes/auth.js +15 -13
  227. package/dist/routes/auth.js.map +1 -1
  228. package/dist/routes/files.d.ts +1 -2
  229. package/dist/routes/files.js.map +1 -1
  230. package/dist/routes/onboarding.d.ts +1 -2
  231. package/dist/routes/onboarding.js.map +1 -1
  232. package/dist/routes/realtime.js +5 -6
  233. package/dist/routes/realtime.js.map +1 -1
  234. package/dist/routes/store.d.ts +6 -7
  235. package/dist/routes/store.js +19 -13
  236. package/dist/routes/store.js.map +1 -1
  237. package/dist/store/catalog.d.ts +13 -5
  238. package/dist/store/catalog.js +19 -9
  239. package/dist/store/catalog.js.map +1 -1
  240. package/dist/store/compatibility.d.ts +1 -0
  241. package/dist/store/compatibility.js +24 -8
  242. package/dist/store/compatibility.js.map +1 -1
  243. package/dist/store/frontend-compatibility.js +15 -3
  244. package/dist/store/frontend-compatibility.js.map +1 -1
  245. package/dist/store/interfaces.js +35 -13
  246. package/dist/store/interfaces.js.map +1 -1
  247. package/dist/store/internal/frontend/frontend-modules.js +7 -3
  248. package/dist/store/internal/frontend/frontend-modules.js.map +1 -1
  249. package/dist/store/internal/frontend/frontend-ready.d.ts +2 -1
  250. package/dist/store/internal/frontend/frontend-ready.js +6 -4
  251. package/dist/store/internal/frontend/frontend-ready.js.map +1 -1
  252. package/dist/store/internal/frontend/manifest.js +6 -7
  253. package/dist/store/internal/frontend/manifest.js.map +1 -1
  254. package/dist/store/operations.js.map +1 -1
  255. package/dist/store/registry.js.map +1 -1
  256. package/dist/store/runtime.d.ts +13 -0
  257. package/dist/store/runtime.js +9 -1
  258. package/dist/store/runtime.js.map +1 -1
  259. package/dist/utils/admin-invite-email.js +3 -1
  260. package/dist/utils/admin-invite-email.js.map +1 -1
  261. package/dist/utils/email-subjects.js +3 -1
  262. package/dist/utils/email-subjects.js.map +1 -1
  263. package/dist/utils/export-jobs-run.js.map +1 -1
  264. package/dist/utils/export-jobs.js +3 -9
  265. package/dist/utils/export-jobs.js.map +1 -1
  266. package/dist/utils/index.d.ts +1 -0
  267. package/dist/utils/index.js +1 -0
  268. package/dist/utils/index.js.map +1 -1
  269. package/dist/utils/own-value.d.ts +1 -0
  270. package/dist/utils/own-value.js +7 -0
  271. package/dist/utils/own-value.js.map +1 -0
  272. package/dist/utils/row-action-rule-evaluator.js +31 -35
  273. package/dist/utils/row-action-rule-evaluator.js.map +1 -1
  274. package/dist/utils/sign-in-country.js +4 -2
  275. package/dist/utils/sign-in-country.js.map +1 -1
  276. package/dist/utils/tenant-export-archive.js +9 -14
  277. package/dist/utils/tenant-export-archive.js.map +1 -1
  278. package/dist/utils/user-agent.js +2 -1
  279. package/dist/utils/user-agent.js.map +1 -1
  280. package/dist/validation/auth.schema.d.ts +10 -10
  281. package/dist/validation/regional-preferences.schema.d.ts +2 -2
  282. package/dist/validation/role-editor.schema.d.ts +1 -1
  283. package/frontend-vue/build/backend-boundary.ts +49 -18
  284. package/frontend-vue/dms.frontend.ts +8 -12
  285. package/frontend-vue/layers/dms-auth/server/accounts.ts +44 -3
  286. package/frontend-vue/layers/dms-auth/server/actions.ts +17 -4
  287. package/frontend-vue/layers/dms-auth/server/oauth.ts +42 -4
  288. package/frontend-vue/layers/dms-core/app/types/watch.ts +1 -2
  289. package/frontend-vue/layers/dms-ui/app/build/composables/form/fieldValueRule.ts +57 -6
  290. package/frontend-vue/layers/dms-ui/app/build/composables/form/registerFormFunctions.ts +7 -9
  291. package/frontend-vue/layers/dms-ui/app/entries/composables/form/registerFormFunctions.ts +1 -0
  292. package/frontend-vue/lazy-plugin.ts +18 -0
  293. package/frontend-vue/package.json +2 -2
  294. package/package.json +19 -13
  295. package/skills/dms-project/SKILL.md +4 -3
@@ -9,6 +9,8 @@ import { apiRequest, isOk, onboard } from "./session.mjs";
9
9
  import { down, freshDatabase, resolutionFolders, up } from "./stack.mjs";
10
10
  import { loadSkill, runPrepare } from "./verify/skill.mjs";
11
11
 
12
+ /** @typedef {import("./options.mjs").Values} Values */
13
+
12
14
  const BROWSER_ACTIONS = [...ACTION_NAMES, "login"];
13
15
 
14
16
  /**
@@ -20,13 +22,32 @@ export function print(text) {
20
22
  process.stdout.write(text.endsWith("\n") ? text : `${text}\n`);
21
23
  }
22
24
 
23
- async function defaultPlayground(values) {
24
- if (values.playground) return values.playground;
25
- const skill = await loadSkill(values.skill, process.cwd()).catch(() => null);
26
- if (skill) return join(skill.repo, skill.config.playground);
27
- return "playground";
25
+ /**
26
+ * The playground and the renderer checkout `up` starts: the options, then
27
+ * the skill's `verify.config.ts`.
28
+ *
29
+ * @param {Pick<Values, "playground" | "renderer" | "skill">} values
30
+ * @param {string} cwd Where the command runs, which finds the skill
31
+ * @returns {Promise<{ playground: string, renderer: string | undefined }>}
32
+ */
33
+ export async function targetOf(values, cwd) {
34
+ const skill =
35
+ values.playground && values.renderer
36
+ ? null
37
+ : await loadSkill(values.skill, cwd).catch(() => null);
38
+ const fromSkill = (/** @type {string | undefined} */ folder) =>
39
+ skill && folder ? resolve(skill.repo, folder) : undefined;
40
+ return {
41
+ playground:
42
+ values.playground ?? fromSkill(skill?.config.playground) ?? "playground",
43
+ renderer: values.renderer ?? fromSkill(skill?.config.renderer),
44
+ };
28
45
  }
29
46
 
47
+ /**
48
+ * @param {Values} values
49
+ * @returns {Promise<number>}
50
+ */
30
51
  async function commandUp(values) {
31
52
  const skill = values.skill ? resolve(values.skill) : undefined;
32
53
  if (values.prepare) {
@@ -34,7 +55,7 @@ async function commandUp(values) {
34
55
  runPrepare(loaded, loaded.repo);
35
56
  }
36
57
  const state = await up({
37
- playground: await defaultPlayground(values),
58
+ ...(await targetOf(values, process.cwd())),
38
59
  runs: values.runs,
39
60
  mongoUrl: values["mongo-url"],
40
61
  env: values.env,
@@ -45,6 +66,11 @@ async function commandUp(values) {
45
66
  return 0;
46
67
  }
47
68
 
69
+ /**
70
+ * @param {string} dir
71
+ * @param {Values} values
72
+ * @returns {Promise<number>}
73
+ */
48
74
  async function commandDoctor(dir, values) {
49
75
  const state = loadRun(dir);
50
76
  const lines = await doctor(state);
@@ -58,6 +84,11 @@ async function commandDoctor(dir, values) {
58
84
  return lines.every((line) => line.ok) ? 0 : 1;
59
85
  }
60
86
 
87
+ /**
88
+ * @param {string} dir
89
+ * @param {Values} values
90
+ * @returns {Promise<number>}
91
+ */
61
92
  async function commandOnboard(dir, values) {
62
93
  const state = loadRun(dir);
63
94
  const answer = await onboard(state, {
@@ -73,6 +104,7 @@ async function commandOnboard(dir, values) {
73
104
  return 0;
74
105
  }
75
106
 
107
+ /** @param {Values} values */
76
108
  function browserTarget(values) {
77
109
  if (!values.role) return undefined;
78
110
  const within = values["within-role"]
@@ -87,6 +119,12 @@ function browserTarget(values) {
87
119
  };
88
120
  }
89
121
 
122
+ /**
123
+ * @param {string} dir
124
+ * @param {string} action
125
+ * @param {Values} values
126
+ * @returns {Promise<number>}
127
+ */
90
128
  async function commandBrowser(dir, action, values) {
91
129
  if (!BROWSER_ACTIONS.includes(action)) {
92
130
  print(
@@ -118,8 +156,16 @@ async function commandBrowser(dir, action, values) {
118
156
  return 0;
119
157
  }
120
158
 
159
+ /**
160
+ * @param {string} dir
161
+ * @param {string} method
162
+ * @param {string} path
163
+ * @param {Values} values
164
+ * @returns {Promise<number>}
165
+ */
121
166
  async function commandApi(dir, method, path, values) {
122
167
  const state = loadRun(dir);
168
+ /** @type {unknown} */
123
169
  const body = values.body === undefined ? undefined : JSON.parse(values.body);
124
170
  const answer = await apiRequest(state, {
125
171
  method: method.toUpperCase(),
@@ -132,6 +178,10 @@ async function commandApi(dir, method, path, values) {
132
178
  return isOk(answer) ? 0 : 1;
133
179
  }
134
180
 
181
+ /**
182
+ * @param {string} dir
183
+ * @returns {Promise<number>}
184
+ */
135
185
  async function commandDown(dir) {
136
186
  const state = loadRun(dir);
137
187
  const lines = await down(state);
@@ -145,9 +195,9 @@ async function commandDown(dir) {
145
195
  * Runs a command that drives the product: `up`, `doctor`, `onboard`,
146
196
  * `browser`, `api`, `mail`, `down`, and the two services `up` starts.
147
197
  *
148
- * @param {string} command The command
198
+ * @param {string | undefined} command The command
149
199
  * @param {string[]} rest Its positional arguments
150
- * @param {Record<string, any>} values Its options
200
+ * @param {Values} values Its options
151
201
  * @returns {Promise<number | undefined>} The exit code, or undefined for a command it does not own; the two services keep the process alive
152
202
  */
153
203
  export async function runStackCommand(command, rest, values) {
@@ -20,6 +20,16 @@ import { runSeededBreaks } from "./verify/seeded.mjs";
20
20
  import { journeysFile, loadSkill } from "./verify/skill.mjs";
21
21
  import { renderVerdict } from "./verify/verdict.mjs";
22
22
 
23
+ /**
24
+ * @typedef {import("./options.mjs").Values} Values
25
+ * @typedef {import("./run-state.mjs").RunState} RunState
26
+ */
27
+
28
+ /**
29
+ * @param {Values} values The options of the command line
30
+ * @param {RunState} [state] The run, whose skill and checkout are the defaults
31
+ * @returns {ReturnType<typeof loadSkill>} The skill
32
+ */
23
33
  function skillOf(values, state) {
24
34
  return loadSkill(
25
35
  values.skill ?? state?.skill ?? undefined,
@@ -27,18 +37,33 @@ function skillOf(values, state) {
27
37
  );
28
38
  }
29
39
 
40
+ /**
41
+ * @param {Values} values The options of the command line
42
+ * @returns {Promise<number>} The exit code
43
+ */
30
44
  async function commandMap(values) {
31
45
  const problems = await checkMap(await skillOf(values));
32
46
  for (const problem of problems) print(problem);
33
47
  return problems.length === 0 ? 0 : 1;
34
48
  }
35
49
 
50
+ /**
51
+ * @param {Values} values The options of the command line
52
+ * @returns {Promise<number>} The exit code
53
+ */
36
54
  async function commandPlan(values) {
37
55
  const plan = planFor(await skillOf(values), values.base);
38
56
  print(JSON.stringify(plan, null, 2));
39
57
  return plan.unmapped.length === 0 ? 0 : 1;
40
58
  }
41
59
 
60
+ /**
61
+ * @param {string} dir The run root
62
+ * @param {string} feature The feature whose journeys run
63
+ * @param {string[]} ids The journeys to run, or none for all
64
+ * @param {Values} values The options of the command line
65
+ * @returns {Promise<number>} The exit code
66
+ */
42
67
  async function commandJourney(dir, feature, ids, values) {
43
68
  const state = loadRun(dir);
44
69
  const skill = await skillOf(values, state);
@@ -61,6 +86,11 @@ async function commandJourney(dir, feature, ids, values) {
61
86
  return results.every((result) => result.status === "PASS") ? 0 : 1;
62
87
  }
63
88
 
89
+ /**
90
+ * @param {string[]} features The features whose seeded breaks run
91
+ * @param {Values} values The options of the command line
92
+ * @returns {Promise<number>} The exit code
93
+ */
64
94
  async function commandSeeded(features, values) {
65
95
  const skill = await skillOf(values);
66
96
  const outcomes = runSeededBreaks(skill, features);
@@ -81,6 +111,11 @@ async function commandSeeded(features, values) {
81
111
  return outcomes.every((outcome) => outcome.caught) ? 0 : 1;
82
112
  }
83
113
 
114
+ /**
115
+ * @param {string | undefined} patch A patch file, or none for the diff
116
+ * @param {Values} values The options of the command line
117
+ * @returns {Promise<number>} The exit code
118
+ */
84
119
  async function commandDoors(patch, values) {
85
120
  const skill = await skillOf(values);
86
121
  const doors = flaggedDoors(
@@ -93,6 +128,11 @@ async function commandDoors(patch, values) {
93
128
  return 0;
94
129
  }
95
130
 
131
+ /**
132
+ * @param {string} dir The run root
133
+ * @param {Values} values The options of the command line
134
+ * @returns {Promise<number>} The exit code
135
+ */
96
136
  async function commandFormal(dir, values) {
97
137
  const state = loadRun(dir);
98
138
  const skill = await skillOf(values, state);
@@ -125,6 +165,12 @@ async function commandFormal(dir, values) {
125
165
  return 0;
126
166
  }
127
167
 
168
+ /**
169
+ * @param {string} command `verdict` or `publish`
170
+ * @param {string} dir The run root
171
+ * @param {Values} values The options of the command line
172
+ * @returns {Promise<number>} The exit code
173
+ */
128
174
  async function commandJudge(command, dir, values) {
129
175
  const pr = Number(values.pr);
130
176
  if (!Number.isInteger(pr) || pr <= 0) {
@@ -159,7 +205,7 @@ async function commandJudge(command, dir, values) {
159
205
  *
160
206
  * @param {string} command The command
161
207
  * @param {string[]} rest Its positional arguments
162
- * @param {Record<string, any>} values Its options
208
+ * @param {Values} values Its options
163
209
  * @returns {Promise<number | undefined>} The exit code, or undefined for a command it does not own
164
210
  */
165
211
  export function runVerifyCommand(command, rest, values) {
@@ -3,9 +3,12 @@ import { createRequire } from "node:module";
3
3
  import { dirname, join } from "node:path";
4
4
  import { descendantsOf, isAlive, listenersOf, probe } from "./processes.mjs";
5
5
  import { checkoutOf } from "./git.mjs";
6
+ import { stringField } from "./json.mjs";
6
7
  import { apiRequest } from "./session.mjs";
7
8
  import { packageVersion } from "./stack.mjs";
8
9
 
10
+ /** @typedef {import("./run-state.mjs").RunState} RunState */
11
+
9
12
  const SKIPPED = new Set([
10
13
  "node_modules",
11
14
  ".antelope",
@@ -16,6 +19,10 @@ const SKIPPED = new Set([
16
19
  ".output",
17
20
  ]);
18
21
 
22
+ /**
23
+ * @param {string} folder
24
+ * @returns {number}
25
+ */
19
26
  function newestMtime(folder) {
20
27
  if (!existsSync(folder)) return 0;
21
28
  let newest = 0;
@@ -30,14 +37,25 @@ function newestMtime(folder) {
30
37
  return newest;
31
38
  }
32
39
 
40
+ /**
41
+ * @param {string} file
42
+ * @returns {number}
43
+ */
33
44
  function mtime(file) {
34
45
  return existsSync(file) ? statSync(file).mtimeMs : 0;
35
46
  }
36
47
 
48
+ /**
49
+ * @param {string} check
50
+ * @param {boolean} ok
51
+ * @param {string} detail
52
+ * @returns {{ check: string, ok: boolean, detail: string }}
53
+ */
37
54
  function line(check, ok, detail) {
38
55
  return { check, ok, detail };
39
56
  }
40
57
 
58
+ /** @param {RunState} state */
41
59
  function processLines(state) {
42
60
  const family = new Set([
43
61
  ...state.processes.map((record) => record.pid),
@@ -71,6 +89,10 @@ function processLines(state) {
71
89
  });
72
90
  }
73
91
 
92
+ /**
93
+ * @param {RunState} state
94
+ * @returns {string}
95
+ */
74
96
  function frontendBackendUrl(state) {
75
97
  const frontend = state.processes.find((record) => record.name === "frontend");
76
98
  if (!frontend) return "no frontend recorded";
@@ -88,8 +110,13 @@ function frontendBackendUrl(state) {
88
110
  return args[args.indexOf("-b") + 1] ?? "no -b";
89
111
  }
90
112
 
113
+ /** @param {RunState} state */
91
114
  function versions(state) {
92
115
  const require = createRequire(join(state.playground, "package.json"));
116
+ /**
117
+ * @param {string} name
118
+ * @returns {string}
119
+ */
93
120
  const version = (name) => {
94
121
  try {
95
122
  return packageVersion(require.resolve(`${name}/package.json`));
@@ -100,10 +127,13 @@ function versions(state) {
100
127
  return {
101
128
  module: `${packageVersion(join(state.moduleRoot, "package.json"))} (${state.moduleRoot})`,
102
129
  core: version("@antelopejs/core"),
103
- dmsFrontend: version("@antelopejs/dms-frontend"),
130
+ dmsFrontend: state.renderer
131
+ ? packageVersion(join(state.renderer, "package.json"))
132
+ : version("@antelopejs/dms-frontend"),
104
133
  };
105
134
  }
106
135
 
136
+ /** @param {RunState} state */
107
137
  function freshnessLines(state) {
108
138
  const moduleDist = join(state.moduleRoot, "dist");
109
139
  const playgroundDist = join(state.playground, "dist");
@@ -116,7 +146,18 @@ function freshnessLines(state) {
116
146
  newestMtime(join(state.moduleRoot, "frontend-vue")),
117
147
  newestMtime(join(state.playground, "frontend-vue")),
118
148
  );
149
+ const renderer = state.renderer
150
+ ? [
151
+ line(
152
+ "renderer build newer than src",
153
+ newestMtime(join(state.renderer, "dist")) >=
154
+ newestMtime(join(state.renderer, "src")),
155
+ state.renderer,
156
+ ),
157
+ ]
158
+ : [];
119
159
  return [
160
+ ...renderer,
120
161
  line(
121
162
  "module dist newer than src",
122
163
  !existsSync(join(state.moduleRoot, "src")) ||
@@ -138,8 +179,10 @@ function freshnessLines(state) {
138
179
  ];
139
180
  }
140
181
 
182
+ /** @param {RunState} state */
141
183
  function headLine(state) {
142
- const now = state.repo ? checkoutOf(state.repo).head : null;
184
+ const verified = state.renderer ?? state.repo;
185
+ const now = verified ? checkoutOf(verified).head : null;
143
186
  return line(
144
187
  "checkout HEAD unchanged since up",
145
188
  now === state.headSha,
@@ -147,6 +190,7 @@ function headLine(state) {
147
190
  );
148
191
  }
149
192
 
193
+ /** @param {RunState} state */
150
194
  async function sessionLine(state) {
151
195
  if (!state.accounts?.admin)
152
196
  return line("admin session", true, "not onboarded yet");
@@ -158,7 +202,8 @@ async function sessionLine(state) {
158
202
  });
159
203
  return line(
160
204
  "admin session valid",
161
- me.status === 200 && me.body?.email === state.accounts.admin.email,
205
+ me.status === 200 &&
206
+ stringField(me.body, "email") === state.accounts.admin.email,
162
207
  `GET /api/auth/me ${me.status}`,
163
208
  );
164
209
  }
@@ -169,7 +214,7 @@ async function sessionLine(state) {
169
214
  * backend, the builds are newer than their sources, the database is the
170
215
  * run's own, and the admin session (once onboarded) is valid.
171
216
  *
172
- * @param {Record<string, any>} state The run
217
+ * @param {import("./run-state.mjs").RunState} state The run
173
218
  * @returns {Promise<{ check: string, ok: boolean, detail: string }[]>} One line per check
174
219
  */
175
220
  export async function doctor(state) {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * What a caught value says: the message of an `Error`, else the value as text.
3
+ *
4
+ * @param {unknown} failure What was thrown or rejected
5
+ * @returns {string} The text
6
+ */
7
+ export function describeFailure(failure) {
8
+ return failure instanceof Error ? failure.message : String(failure);
9
+ }