@antelopejs/dms-automation 0.2.7 → 0.3.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 (312) hide show
  1. package/README.md +46 -2
  2. package/dist/data/procedures-table.d.ts +38 -4
  3. package/dist/data/procedures-table.js +264 -82
  4. package/dist/data/procedures-table.js.map +1 -1
  5. package/dist/data/runs-table.d.ts +19 -3
  6. package/dist/data/runs-table.js +254 -19
  7. package/dist/data/runs-table.js.map +1 -1
  8. package/dist/db/index.d.ts +1 -2
  9. package/dist/db/index.js +1 -2
  10. package/dist/db/index.js.map +1 -1
  11. package/dist/db/models/automation_template.model.d.ts +16 -1
  12. package/dist/db/models/automation_template.model.js +31 -11
  13. package/dist/db/models/automation_template.model.js.map +1 -1
  14. package/dist/db/models/index.d.ts +1 -1
  15. package/dist/db/models/index.js +1 -1
  16. package/dist/db/models/procedure.model.d.ts +1 -0
  17. package/dist/db/models/procedure.model.js +7 -0
  18. package/dist/db/models/procedure.model.js.map +1 -1
  19. package/dist/db/models/procedure_run.model.d.ts +16 -9
  20. package/dist/db/models/procedure_run.model.js +96 -17
  21. package/dist/db/models/procedure_run.model.js.map +1 -1
  22. package/dist/db/models/stats.model.d.ts +60 -61
  23. package/dist/db/models/stats.model.js +189 -236
  24. package/dist/db/models/stats.model.js.map +1 -1
  25. package/dist/db/models/type_switch.model.d.ts +25 -0
  26. package/dist/db/models/type_switch.model.js +25 -0
  27. package/dist/db/models/type_switch.model.js.map +1 -0
  28. package/dist/db/tables/index.d.ts +1 -2
  29. package/dist/db/tables/index.js +1 -2
  30. package/dist/db/tables/index.js.map +1 -1
  31. package/dist/db/tables/procedure.table.d.ts +6 -0
  32. package/dist/db/tables/procedure.table.js +24 -0
  33. package/dist/db/tables/procedure.table.js.map +1 -1
  34. package/dist/db/tables/procedure_run.table.d.ts +15 -1
  35. package/dist/db/tables/procedure_run.table.js +54 -0
  36. package/dist/db/tables/procedure_run.table.js.map +1 -1
  37. package/dist/db/tables/type_switch.table.d.ts +8 -0
  38. package/dist/db/tables/{trigger_type_config.table.js → type_switch.table.js} +16 -15
  39. package/dist/db/tables/type_switch.table.js.map +1 -0
  40. package/dist/displays/index.d.ts +14 -0
  41. package/dist/displays/index.js +23 -0
  42. package/dist/displays/index.js.map +1 -0
  43. package/dist/index.d.ts +7 -0
  44. package/dist/index.js +8 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/pages/builder.d.ts +1 -1
  47. package/dist/pages/builder.js +10 -3
  48. package/dist/pages/builder.js.map +1 -1
  49. package/dist/pages/index.d.ts +2 -1
  50. package/dist/pages/index.js +2 -1
  51. package/dist/pages/index.js.map +1 -1
  52. package/dist/pages/library.d.ts +2 -1
  53. package/dist/pages/library.js +54 -4
  54. package/dist/pages/library.js.map +1 -1
  55. package/dist/pages/overview.d.ts +6 -1
  56. package/dist/pages/overview.js +121 -2
  57. package/dist/pages/overview.js.map +1 -1
  58. package/dist/pages/procedures.js +111 -16
  59. package/dist/pages/procedures.js.map +1 -1
  60. package/dist/pages/runs.d.ts +4 -1
  61. package/dist/pages/runs.js +109 -13
  62. package/dist/pages/runs.js.map +1 -1
  63. package/dist/pages/shared.d.ts +18 -0
  64. package/dist/pages/shared.js +238 -0
  65. package/dist/pages/shared.js.map +1 -0
  66. package/dist/pages/trace.d.ts +10 -0
  67. package/dist/pages/trace.js +41 -0
  68. package/dist/pages/trace.js.map +1 -0
  69. package/dist/realtime.d.ts +3 -0
  70. package/dist/realtime.js +14 -0
  71. package/dist/realtime.js.map +1 -0
  72. package/dist/routes/action-types.d.ts +2 -14
  73. package/dist/routes/action-types.js +2 -32
  74. package/dist/routes/action-types.js.map +1 -1
  75. package/dist/routes/deleteConfirm.d.ts +3 -0
  76. package/dist/routes/deleteConfirm.js +64 -0
  77. package/dist/routes/deleteConfirm.js.map +1 -0
  78. package/dist/routes/graphSchema.d.ts +3 -90
  79. package/dist/routes/graphSchema.js +36 -9
  80. package/dist/routes/graphSchema.js.map +1 -1
  81. package/dist/routes/index.d.ts +1 -0
  82. package/dist/routes/index.js +1 -0
  83. package/dist/routes/index.js.map +1 -1
  84. package/dist/routes/library.d.ts +40 -0
  85. package/dist/routes/library.js +147 -0
  86. package/dist/routes/library.js.map +1 -0
  87. package/dist/routes/procedureChecks.d.ts +16 -0
  88. package/dist/routes/procedureChecks.js +72 -0
  89. package/dist/routes/procedureChecks.js.map +1 -0
  90. package/dist/routes/procedureRuns.d.ts +21 -0
  91. package/dist/routes/procedureRuns.js +45 -0
  92. package/dist/routes/procedureRuns.js.map +1 -0
  93. package/dist/routes/procedureSchemas.d.ts +107 -0
  94. package/dist/routes/procedureSchemas.js +61 -0
  95. package/dist/routes/procedureSchemas.js.map +1 -0
  96. package/dist/routes/procedures.d.ts +125 -7
  97. package/dist/routes/procedures.js +363 -67
  98. package/dist/routes/procedures.js.map +1 -1
  99. package/dist/routes/requests.d.ts +15 -0
  100. package/dist/routes/requests.js +35 -0
  101. package/dist/routes/requests.js.map +1 -0
  102. package/dist/routes/runs.d.ts +107 -2
  103. package/dist/routes/runs.js +340 -37
  104. package/dist/routes/runs.js.map +1 -1
  105. package/dist/routes/stats.d.ts +19 -1
  106. package/dist/routes/stats.js +160 -4
  107. package/dist/routes/stats.js.map +1 -1
  108. package/dist/routes/templates.d.ts +6 -2
  109. package/dist/routes/templates.js +106 -36
  110. package/dist/routes/templates.js.map +1 -1
  111. package/dist/routes/trigger-types.d.ts +2 -15
  112. package/dist/routes/trigger-types.js +2 -32
  113. package/dist/routes/trigger-types.js.map +1 -1
  114. package/dist/routes/typeConfigShared.d.ts +7 -11
  115. package/dist/routes/typeConfigShared.js +25 -15
  116. package/dist/routes/typeConfigShared.js.map +1 -1
  117. package/dist/runtime/armErrors.d.ts +16 -0
  118. package/dist/runtime/armErrors.js +69 -0
  119. package/dist/runtime/armErrors.js.map +1 -0
  120. package/dist/runtime/boundRunLog.d.ts +24 -0
  121. package/dist/runtime/boundRunLog.js +202 -10
  122. package/dist/runtime/boundRunLog.js.map +1 -1
  123. package/dist/runtime/builtins/actions/http.d.ts +10 -1
  124. package/dist/runtime/builtins/actions/http.js +306 -19
  125. package/dist/runtime/builtins/actions/http.js.map +1 -1
  126. package/dist/runtime/builtins/actions/log.js +2 -2
  127. package/dist/runtime/builtins/actions/log.js.map +1 -1
  128. package/dist/runtime/builtins/data/boolean.d.ts +1 -0
  129. package/dist/runtime/builtins/data/boolean.js +18 -10
  130. package/dist/runtime/builtins/data/boolean.js.map +1 -1
  131. package/dist/runtime/builtins/data/compare.js +60 -11
  132. package/dist/runtime/builtins/data/compare.js.map +1 -1
  133. package/dist/runtime/builtins/data/constant.js +9 -12
  134. package/dist/runtime/builtins/data/constant.js.map +1 -1
  135. package/dist/runtime/builtins/data/json.js +4 -4
  136. package/dist/runtime/builtins/data/json.js.map +1 -1
  137. package/dist/runtime/builtins/data/math.js +44 -24
  138. package/dist/runtime/builtins/data/math.js.map +1 -1
  139. package/dist/runtime/builtins/data/object.js +10 -10
  140. package/dist/runtime/builtins/data/object.js.map +1 -1
  141. package/dist/runtime/builtins/data/string.js +31 -20
  142. package/dist/runtime/builtins/data/string.js.map +1 -1
  143. package/dist/runtime/builtins/nodes/action.js +4 -0
  144. package/dist/runtime/builtins/nodes/action.js.map +1 -1
  145. package/dist/runtime/builtins/nodes/delay.js +1 -1
  146. package/dist/runtime/builtins/nodes/delay.js.map +1 -1
  147. package/dist/runtime/builtins/nodes/forRange.d.ts +1 -1
  148. package/dist/runtime/builtins/nodes/forRange.js +10 -4
  149. package/dist/runtime/builtins/nodes/forRange.js.map +1 -1
  150. package/dist/runtime/builtins/nodes/if.js +2 -1
  151. package/dist/runtime/builtins/nodes/if.js.map +1 -1
  152. package/dist/runtime/builtins/nodes/parallel.js +9 -2
  153. package/dist/runtime/builtins/nodes/parallel.js.map +1 -1
  154. package/dist/runtime/builtins/nodes/retry.js +1 -1
  155. package/dist/runtime/builtins/nodes/retry.js.map +1 -1
  156. package/dist/runtime/builtins/nodes/setVariable.js +1 -3
  157. package/dist/runtime/builtins/nodes/setVariable.js.map +1 -1
  158. package/dist/runtime/builtins/triggers/cron.d.ts +3 -0
  159. package/dist/runtime/builtins/triggers/cron.js +21 -7
  160. package/dist/runtime/builtins/triggers/cron.js.map +1 -1
  161. package/dist/runtime/builtins/triggers/manual.js +2 -2
  162. package/dist/runtime/builtins/triggers/manual.js.map +1 -1
  163. package/dist/runtime/builtins/triggers/webhook.d.ts +14 -1
  164. package/dist/runtime/builtins/triggers/webhook.js +116 -30
  165. package/dist/runtime/builtins/triggers/webhook.js.map +1 -1
  166. package/dist/runtime/describe.d.ts +23 -0
  167. package/dist/runtime/describe.js +114 -0
  168. package/dist/runtime/describe.js.map +1 -0
  169. package/dist/runtime/executionResult.d.ts +1 -0
  170. package/dist/runtime/executor.js +82 -5
  171. package/dist/runtime/executor.js.map +1 -1
  172. package/dist/runtime/graphIssues.d.ts +20 -0
  173. package/dist/runtime/graphIssues.js +290 -0
  174. package/dist/runtime/graphIssues.js.map +1 -0
  175. package/dist/runtime/graphVersion.d.ts +2 -0
  176. package/dist/runtime/graphVersion.js +43 -0
  177. package/dist/runtime/graphVersion.js.map +1 -0
  178. package/dist/runtime/nodeKinds.d.ts +4 -4
  179. package/dist/runtime/nodeKinds.js +1 -2
  180. package/dist/runtime/nodeKinds.js.map +1 -1
  181. package/dist/runtime/registry.d.ts +2 -1
  182. package/dist/runtime/registry.js +1 -2
  183. package/dist/runtime/registry.js.map +1 -1
  184. package/dist/runtime/resolveInputs.d.ts +3 -1
  185. package/dist/runtime/resolveInputs.js +12 -2
  186. package/dist/runtime/resolveInputs.js.map +1 -1
  187. package/dist/runtime/resolveSubgraph.d.ts +12 -1
  188. package/dist/runtime/resolveSubgraph.js +36 -0
  189. package/dist/runtime/resolveSubgraph.js.map +1 -1
  190. package/dist/runtime/retention.d.ts +6 -0
  191. package/dist/runtime/retention.js +54 -0
  192. package/dist/runtime/retention.js.map +1 -0
  193. package/dist/runtime/runProcedure.d.ts +12 -0
  194. package/dist/runtime/runProcedure.js +130 -0
  195. package/dist/runtime/runProcedure.js.map +1 -0
  196. package/dist/runtime/schedule.d.ts +2 -0
  197. package/dist/runtime/schedule.js +139 -0
  198. package/dist/runtime/schedule.js.map +1 -0
  199. package/dist/runtime/subscriptions.d.ts +11 -1
  200. package/dist/runtime/subscriptions.js +91 -125
  201. package/dist/runtime/subscriptions.js.map +1 -1
  202. package/dist/runtime/subwalk.js +2 -3
  203. package/dist/runtime/subwalk.js.map +1 -1
  204. package/dist/runtime/templateUsages.d.ts +4 -0
  205. package/dist/runtime/templateUsages.js +102 -0
  206. package/dist/runtime/templateUsages.js.map +1 -0
  207. package/dist/runtime/topo.d.ts +1 -0
  208. package/dist/runtime/topo.js +23 -0
  209. package/dist/runtime/topo.js.map +1 -1
  210. package/dist/runtime/trace.d.ts +44 -0
  211. package/dist/runtime/trace.js +240 -0
  212. package/dist/runtime/trace.js.map +1 -0
  213. package/dist/runtime/typeSwitches.d.ts +3 -0
  214. package/dist/runtime/typeSwitches.js +27 -0
  215. package/dist/runtime/typeSwitches.js.map +1 -0
  216. package/dist/runtime/validate.d.ts +11 -0
  217. package/dist/runtime/validate.js +118 -61
  218. package/dist/runtime/validate.js.map +1 -1
  219. package/dist/runtime/webhookRoutes.d.ts +4 -0
  220. package/dist/runtime/webhookRoutes.js +68 -0
  221. package/dist/runtime/webhookRoutes.js.map +1 -0
  222. package/dist/runtime/withTimeout.d.ts +1 -0
  223. package/dist/runtime/withTimeout.js +17 -0
  224. package/dist/runtime/withTimeout.js.map +1 -0
  225. package/dist/runtime/wording.d.ts +10 -0
  226. package/dist/runtime/wording.js +118 -0
  227. package/dist/runtime/wording.js.map +1 -0
  228. package/dist/stats/health-banner.d.ts +13 -0
  229. package/dist/stats/health-banner.js +149 -0
  230. package/dist/stats/health-banner.js.map +1 -0
  231. package/dist/stats/health.d.ts +49 -0
  232. package/dist/stats/health.js +130 -0
  233. package/dist/stats/health.js.map +1 -0
  234. package/dist/stats/kpi.d.ts +21 -0
  235. package/dist/stats/kpi.js +101 -0
  236. package/dist/stats/kpi.js.map +1 -0
  237. package/dist/stats/overview.d.ts +94 -0
  238. package/dist/stats/overview.js +244 -0
  239. package/dist/stats/overview.js.map +1 -0
  240. package/dist/types/constants.d.ts +0 -1
  241. package/dist/types/constants.js +1 -2
  242. package/dist/types/constants.js.map +1 -1
  243. package/dist/types/runLog.d.ts +2 -0
  244. package/dist/types/runLog.js +4 -0
  245. package/dist/types/runLog.js.map +1 -1
  246. package/frontend-vue/app/components/AttentionList.vue +276 -0
  247. package/frontend-vue/app/components/Catalog/SchemaTable.vue +127 -0
  248. package/frontend-vue/app/components/Catalog.vue +457 -0
  249. package/frontend-vue/app/components/Editor/BottomDock.vue +188 -0
  250. package/frontend-vue/app/components/Editor/BuilderPalette.vue +101 -45
  251. package/frontend-vue/app/components/Editor/GraphCanvas.vue +818 -206
  252. package/frontend-vue/app/components/Editor/GroupPortEditor.vue +29 -18
  253. package/frontend-vue/app/components/Editor/JsonField.vue +3 -3
  254. package/frontend-vue/app/components/Editor/NewProcedureDialog.vue +108 -0
  255. package/frontend-vue/app/components/Editor/NodeInspector.vue +373 -101
  256. package/frontend-vue/app/components/Editor/ProcedureSwitcher.vue +147 -0
  257. package/frontend-vue/app/components/Editor/RunNowDialog.vue +145 -0
  258. package/frontend-vue/app/components/Editor/WiredField.vue +3 -3
  259. package/frontend-vue/app/components/Editor/nodes/GenericNode.vue +97 -91
  260. package/frontend-vue/app/components/Editor/nodes/GroupNode.vue +5 -6
  261. package/frontend-vue/app/components/Editor/nodes/GroupSentinel.vue +3 -2
  262. package/frontend-vue/app/components/Editor/nodes/styles.ts +14 -18
  263. package/frontend-vue/app/components/Editor.vue +1894 -705
  264. package/frontend-vue/app/components/IconPicker.vue +122 -0
  265. package/frontend-vue/app/components/LiveTopics.vue +20 -0
  266. package/frontend-vue/app/components/Run/RunCompare.vue +115 -0
  267. package/frontend-vue/app/components/Run/RunFailure.vue +54 -0
  268. package/frontend-vue/app/components/Run/RunLogList.vue +167 -0
  269. package/frontend-vue/app/components/Run/RunPathTaken.vue +139 -0
  270. package/frontend-vue/app/components/Run/RunPayload.vue +85 -0
  271. package/frontend-vue/app/components/Run/RunWaterfall.vue +374 -0
  272. package/frontend-vue/app/components/RunPeek.vue +132 -0
  273. package/frontend-vue/app/components/RunTrace.vue +462 -0
  274. package/frontend-vue/app/components/Templates.vue +382 -537
  275. package/frontend-vue/app/components/WebhookEndpoint.vue +81 -0
  276. package/frontend-vue/app/composables/useAutomationNodeKinds.ts +23 -6
  277. package/frontend-vue/app/composables/useAutomationRuns.ts +160 -25
  278. package/frontend-vue/app/composables/useGraphConnect.ts +103 -51
  279. package/frontend-vue/app/composables/useRunActions.ts +60 -0
  280. package/frontend-vue/app/plugins/cell-displays.ts +169 -0
  281. package/frontend-vue/app/utils/automation.ts +4 -36
  282. package/frontend-vue/app/utils/describe.ts +252 -0
  283. package/frontend-vue/app/utils/redactedHeaders.ts +31 -0
  284. package/frontend-vue/dms.frontend.build.ts +7 -0
  285. package/frontend-vue/dms.frontend.ts +7 -4
  286. package/frontend-vue/i18n/locales/dms-automation-en-GB.json +1149 -309
  287. package/frontend-vue/i18n/locales/dms-automation-fr-FR.json +1154 -314
  288. package/frontend-vue/package.json +1 -1
  289. package/package.json +8 -6
  290. package/dist/db/models/type_config.model.d.ts +0 -47
  291. package/dist/db/models/type_config.model.js +0 -51
  292. package/dist/db/models/type_config.model.js.map +0 -1
  293. package/dist/db/tables/action_type_config.table.d.ts +0 -7
  294. package/dist/db/tables/action_type_config.table.js +0 -35
  295. package/dist/db/tables/action_type_config.table.js.map +0 -1
  296. package/dist/db/tables/trigger_type_config.table.d.ts +0 -7
  297. package/dist/db/tables/trigger_type_config.table.js.map +0 -1
  298. package/frontend-vue/app/components/Actions.vue +0 -151
  299. package/frontend-vue/app/components/Catalog/TypeConfigForm.vue +0 -170
  300. package/frontend-vue/app/components/Catalog/TypeList.vue +0 -203
  301. package/frontend-vue/app/components/DataNodes.vue +0 -275
  302. package/frontend-vue/app/components/Editor/ProcedureList.vue +0 -156
  303. package/frontend-vue/app/components/Editor/RunsDrawer.vue +0 -312
  304. package/frontend-vue/app/components/Library.vue +0 -69
  305. package/frontend-vue/app/components/Overview.vue +0 -503
  306. package/frontend-vue/app/components/RunDetailDrawer.vue +0 -165
  307. package/frontend-vue/app/components/RunFireTree.vue +0 -170
  308. package/frontend-vue/app/components/RunTraceDrawer.vue +0 -59
  309. package/frontend-vue/app/components/RunsStats.vue +0 -126
  310. package/frontend-vue/app/components/RunsTimelineDisplay.vue +0 -287
  311. package/frontend-vue/app/components/Triggers.vue +0 -147
  312. package/frontend-vue/app/plugins/runs-timeline-display.client.ts +0 -16
@@ -0,0 +1,169 @@
1
+ import { h, type VNodeChild } from "vue";
2
+ import { defineDmsPlugin, DmsLink } from "#dms/frontend-module";
3
+
4
+ // The cell displays the procedures table names (src/displays/index.ts):
5
+ // `automation:last-runs`, the strip of last runs over the last run's date, and
6
+ // `automation:procedure-link`, a procedure's identity cell as a link. A
7
+ // universal plugin, so the server render draws the cells. The trigger and
8
+ // failed-step cells are the DMS `two_line` display, over texts the server
9
+ // composes (src/runtime/wording.ts).
10
+
11
+ /**
12
+ * A run of the strip, as the procedures summary lists it. A type alias, not an
13
+ * interface, so it fills the run URL's `{{row.runId}}` as a plain record.
14
+ */
15
+ type RecentRun = {
16
+ runId: string;
17
+ status: string;
18
+ startedAt: string;
19
+ errorMessage: string | null;
20
+ };
21
+
22
+ interface LastRunsOptions {
23
+ limit?: number;
24
+ runsField?: string;
25
+ runUrl?: string;
26
+ emptyLabel?: string;
27
+ }
28
+
29
+ const STATUS_BAR_CLASS: Record<string, string> = {
30
+ ok: "bg-success",
31
+ failed: "bg-error",
32
+ };
33
+ const DEFAULT_RUN_STRIP = 12;
34
+ const BAR_CLASS = "h-4 w-[5px] rounded-[1px]";
35
+
36
+ function isRecentRun(value: unknown): value is RecentRun {
37
+ return typeof value === "object" && value !== null && "runId" in value;
38
+ }
39
+
40
+ /** "Failed · 12 Oct 2026, 13:59 · HTTP 404 Not Found". */
41
+ function runTitle(run: RecentRun): string {
42
+ const { t, te } = useI18n();
43
+ const { formatDateTime } = useRegionalFormat();
44
+ const statusKey = `dms_automation.runs.status.${run.status}`;
45
+ return [
46
+ te(statusKey) ? t(statusKey) : run.status,
47
+ formatDateTime(run.startedAt),
48
+ run.errorMessage,
49
+ ]
50
+ .filter(Boolean)
51
+ .join(" · ");
52
+ }
53
+
54
+ /**
55
+ * One bar of the strip: a link to its run, named by its tooltip. Out of the
56
+ * tab order (twelve stops a row): the keyboard reaches the last run through
57
+ * the row's "Open last run".
58
+ */
59
+ function renderRunBar(run: RecentRun, runUrl: string | undefined) {
60
+ const title = runTitle(run);
61
+ const bar = [BAR_CLASS, STATUS_BAR_CLASS[run.status] ?? "bg-accented"];
62
+ return runUrl
63
+ ? h(DmsLink, {
64
+ to: interpolateUrl(runUrl, run),
65
+ class: [bar, "hover:opacity-70"],
66
+ title,
67
+ "aria-label": title,
68
+ tabindex: -1,
69
+ })
70
+ : h("span", { class: bar, title });
71
+ }
72
+
73
+ /**
74
+ * The strip of the row's last runs, over the column's date written like the
75
+ * DMS `relative_date` cell ("2 hr. ago", the exact moment in its tooltip).
76
+ */
77
+ function renderLastRuns(
78
+ value: unknown,
79
+ locale: string,
80
+ options: unknown,
81
+ row: Record<string, unknown> | undefined,
82
+ ) {
83
+ const { t } = useI18n();
84
+ const {
85
+ limit = DEFAULT_RUN_STRIP,
86
+ runsField = "lastRuns",
87
+ runUrl,
88
+ emptyLabel,
89
+ } = (options ?? {}) as LastRunsOptions;
90
+ const listed = row?.[runsField];
91
+ const runs = Array.isArray(listed)
92
+ ? listed.filter(isRecentRun).slice(-limit)
93
+ : [];
94
+ const count = (status: string) =>
95
+ runs.filter((run) => run.status === status).length;
96
+ const label = runs.length
97
+ ? t("dms_automation.procedures.lastRunsLabel", {
98
+ ok: count("ok"),
99
+ failed: count("failed"),
100
+ })
101
+ : t("dms_automation.procedures.detail.noRunYet");
102
+ const empty = Array.from({ length: limit - runs.length }, () =>
103
+ h("span", { class: "h-1.5 w-[5px] rounded-[1px] bg-elevated" }),
104
+ );
105
+ const strip = h(
106
+ "span",
107
+ {
108
+ class: "inline-flex h-4 items-end gap-[2px]",
109
+ role: "group",
110
+ "aria-label": label,
111
+ },
112
+ [...empty, ...runs.map((run) => renderRunBar(run, runUrl))],
113
+ );
114
+ const relativeDate = useDataTypes().getDataType("relative_date")?.formatter;
115
+ const dateOptions = { emptyLabel, emptyTone: "dimmed" };
116
+ const date = (
117
+ value
118
+ ? relativeDate?.default(value, locale, dateOptions, row)
119
+ : relativeDate?.empty?.(value, locale, dateOptions, row)
120
+ ) as VNodeChild;
121
+ return h("span", { class: "flex min-w-0 flex-col items-start gap-1" }, [
122
+ strip,
123
+ date,
124
+ ]);
125
+ }
126
+
127
+ /**
128
+ * The DMS identity cell (icon, name, description) inside a link to the
129
+ * row's page: a click, a middle-click or Enter opens it.
130
+ */
131
+ function renderProcedureLink(
132
+ value: unknown,
133
+ locale: string,
134
+ options: unknown,
135
+ row: Record<string, unknown> | undefined,
136
+ ) {
137
+ const identity = useDataTypes().getDataType("identity")?.formatter;
138
+ const cell = identity?.default(value, locale, options, row) ?? String(value);
139
+ const url = (options as { url?: string } | undefined)?.url;
140
+ if (!url || !row) return cell;
141
+ return h(
142
+ DmsLink,
143
+ {
144
+ to: interpolateUrl(url, row),
145
+ class:
146
+ "block min-w-0 rounded-sm focus-visible:outline-2 focus-visible:outline-primary [&:hover_.text-highlighted>.truncate]:underline",
147
+ },
148
+ () => cell,
149
+ );
150
+ }
151
+
152
+ export default defineDmsPlugin(() => {
153
+ const { registerDataType } = useDataTypes();
154
+ registerDataType({
155
+ id: "automation:last-runs",
156
+ formatter: {
157
+ default: (value, locale, options, row) =>
158
+ renderLastRuns(value, locale, options, row),
159
+ empty: (value, locale, options, row) =>
160
+ renderLastRuns(value, locale, options, row),
161
+ },
162
+ });
163
+ registerDataType({
164
+ id: "automation:procedure-link",
165
+ formatter: {
166
+ default: renderProcedureLink,
167
+ },
168
+ });
169
+ });
@@ -12,40 +12,8 @@ export function newId(): string {
12
12
  return `id-${Math.random().toString(36).slice(2, 10)}-${Date.now().toString(36)}`;
13
13
  }
14
14
 
15
- /**
16
- * Backend list endpoints return one of:
17
- * - a plain T[]
18
- * - { results: T[] }
19
- * - { items: T[] }
20
- * This shrinks the per-call envelope-unwrap noise.
21
- */
22
- export interface ListEnvelope<T> {
23
- results?: T[];
24
- items?: T[];
25
- }
26
-
27
- export function unwrapList<T>(
28
- data: T[] | ListEnvelope<T> | null | undefined,
29
- ): T[] {
30
- if (Array.isArray(data)) return data;
31
- if (data && Array.isArray((data as ListEnvelope<T>).results))
32
- return (data as ListEnvelope<T>).results ?? [];
33
- if (data && Array.isArray((data as ListEnvelope<T>).items))
34
- return (data as ListEnvelope<T>).items ?? [];
35
- return [];
36
- }
37
-
38
- /**
39
- * Human-readable duration from a millisecond count: `0ms` / `850ms` / `1.2s` /
40
- * `3m 4s`. Shared by the runs KPI header and the runs timeline so the format
41
- * stays in one place.
42
- */
43
- export function formatDuration(ms: number): string {
44
- if (!ms || !Number.isFinite(ms)) return "0ms";
45
- if (ms < 1000) return `${Math.round(ms)}ms`;
46
- const sec = ms / 1000;
47
- if (sec < 60) return `${sec.toFixed(1)}s`;
48
- const m = Math.floor(sec / 60);
49
- const rem = Math.round(sec % 60);
50
- return `${m}m ${rem}s`;
15
+ /** A route query value as one non-empty string: the first of a list. */
16
+ export function queryString(value: unknown): string | null {
17
+ const first: unknown = Array.isArray(value) ? value[0] : value;
18
+ return typeof first === "string" && first.length > 0 ? first : null;
51
19
  }
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Wording of automation objects the backend sends structured: a step, a
3
+ * duration, a date. Every function takes the translator, so cells, cards and
4
+ * the builder say the same thing in the reader's language. Triggers and
5
+ * schedules are worded by the server, which sends their text next to them
6
+ * (`src/runtime/wording.ts`), written with `useComposedText().processText`.
7
+ */
8
+
9
+ /** `processI18n` of the DMS translation composable. */
10
+ export type Translate = (
11
+ key: string,
12
+ params?: Record<string, unknown>,
13
+ ) => string;
14
+
15
+ /** What starts a procedure or a run (see the backend `TriggerSummary`). */
16
+ export interface TriggerSummary {
17
+ nodeId?: string;
18
+ typeId: string;
19
+ typeName: string;
20
+ method?: string;
21
+ path?: string;
22
+ cron?: string;
23
+ /** The time zone the schedule fires in, the server's. */
24
+ timeZone?: string;
25
+ }
26
+
27
+ /** A trigger with the text the server words it as. */
28
+ export interface WordedTrigger extends TriggerSummary {
29
+ text: BlockText;
30
+ }
31
+
32
+ /** A step, named by its label or the name of its type. */
33
+ export interface StepName {
34
+ nodeId: string;
35
+ label?: string;
36
+ typeName?: string;
37
+ kind?: string;
38
+ }
39
+
40
+ /** A step's name: its label, else its type's name, else its id. */
41
+ export function stepTitle(
42
+ step: StepName | null | undefined,
43
+ t: Translate,
44
+ ): string {
45
+ if (!step) return "";
46
+ if (step.label) return step.label;
47
+ if (step.typeName) return t(step.typeName);
48
+ return step.nodeId;
49
+ }
50
+
51
+ const MS_PER_SECOND = 1000;
52
+ const SECONDS_PER_MINUTE = 60;
53
+
54
+ /**
55
+ * The reader's language, as the page declares it, for the formatters called
56
+ * without one: dates and durations then follow the DMS language, not the
57
+ * browser's.
58
+ */
59
+ function pageLocale(locale?: string): string | undefined {
60
+ if (locale) return locale;
61
+ return typeof document === "undefined"
62
+ ? undefined
63
+ : document.documentElement.lang || undefined;
64
+ }
65
+
66
+ /** A duration in its most readable unit: "640 ms", "2.4 s", "3 min 4 s". */
67
+ export function describeDuration(
68
+ ms: number | null | undefined,
69
+ locale?: string,
70
+ ): string {
71
+ if (ms === null || ms === undefined || !Number.isFinite(ms)) return "—";
72
+ if (ms < MS_PER_SECOND) return `${Math.round(ms)} ms`;
73
+ const seconds = ms / MS_PER_SECOND;
74
+ if (seconds < SECONDS_PER_MINUTE) {
75
+ const value = new Intl.NumberFormat(pageLocale(locale), {
76
+ maximumFractionDigits: 1,
77
+ }).format(seconds);
78
+ return `${value} s`;
79
+ }
80
+ const minutes = Math.floor(seconds / SECONDS_PER_MINUTE);
81
+ return `${minutes} min ${Math.round(seconds % SECONDS_PER_MINUTE)} s`;
82
+ }
83
+
84
+ const RELATIVE_UNITS: Array<[Intl.RelativeTimeFormatUnit, number]> = [
85
+ ["day", 86_400_000],
86
+ ["hour", 3_600_000],
87
+ ["minute", 60_000],
88
+ ["second", 1000],
89
+ ];
90
+
91
+ /** "4 min ago", "in 2 days": the distance from now, in the reader's locale. */
92
+ export function describeRelative(
93
+ date: string | Date | null | undefined,
94
+ locale?: string,
95
+ ): string {
96
+ if (!date) return "—";
97
+ const ms = new Date(date).getTime() - Date.now();
98
+ const format = new Intl.RelativeTimeFormat(pageLocale(locale), {
99
+ numeric: "auto",
100
+ style: "short",
101
+ });
102
+ for (const [unit, size] of RELATIVE_UNITS) {
103
+ if (Math.abs(ms) >= size || unit === "second") {
104
+ return format.format(Math.round(ms / size), unit);
105
+ }
106
+ }
107
+ return "";
108
+ }
109
+
110
+ /**
111
+ * Builds the `Intl.DateTimeFormat` a date is written with: the page's
112
+ * `useRegionalFormat().dateTimeFormat`, which adds the user's Language &
113
+ * region settings (time zone, clock, date format) to what is asked for. An
114
+ * explicit `timeZone` wins.
115
+ */
116
+ export type DateTimeFormatOf = (
117
+ options: Intl.DateTimeFormatOptions,
118
+ ) => Intl.DateTimeFormat;
119
+
120
+ /**
121
+ * How the reader writes hours: "09:05" on a 24-hour clock, "9:05 AM" on a
122
+ * 12-hour one (never "09:05 AM").
123
+ */
124
+ function hourStyle(formatOf: DateTimeFormatOf): "2-digit" | "numeric" {
125
+ const { hourCycle } = formatOf({ hour: "numeric" }).resolvedOptions();
126
+ return hourCycle === "h23" || hourCycle === "h24" ? "2-digit" : "numeric";
127
+ }
128
+
129
+ /**
130
+ * A date and time, written the same way on every page: "Oct 12, 1:57 PM",
131
+ * "12 oct., 13:57", with the year when it is not this one. Never all digits,
132
+ * which reads month-first or day-first depending on the reader. In the
133
+ * reader's time zone, or in `timeZone` when the text names it (a schedule's
134
+ * next run, in the server's zone like the schedule itself).
135
+ */
136
+ export function describeDateTime(
137
+ date: string | Date | null | undefined,
138
+ formatOf: DateTimeFormatOf,
139
+ timeZone?: string,
140
+ ): string {
141
+ if (!date) return "—";
142
+ const d = new Date(date);
143
+ if (Number.isNaN(d.getTime())) return "—";
144
+ const yearOf = (value: Date) =>
145
+ formatOf({ year: "numeric", timeZone }).format(value);
146
+ const options: Intl.DateTimeFormatOptions = {
147
+ month: "short",
148
+ day: "numeric",
149
+ hour: hourStyle(formatOf),
150
+ minute: "2-digit",
151
+ timeZone,
152
+ };
153
+ if (yearOf(d) !== yearOf(new Date())) options.year = "numeric";
154
+ return formatOf(options).format(d);
155
+ }
156
+
157
+ /** "14:28" today, else the date and time: "Sep 22, 14:28". */
158
+ export function describeTime(
159
+ date: string | Date | null | undefined,
160
+ formatOf: DateTimeFormatOf,
161
+ ): string {
162
+ if (!date) return "—";
163
+ const d = new Date(date);
164
+ if (Number.isNaN(d.getTime())) return "—";
165
+ const dayOf = (value: Date) =>
166
+ formatOf({ year: "numeric", month: "numeric", day: "numeric" }).format(
167
+ value,
168
+ );
169
+ if (dayOf(d) !== dayOf(new Date())) return describeDateTime(d, formatOf);
170
+ return formatOf({ hour: hourStyle(formatOf), minute: "2-digit" }).format(d);
171
+ }
172
+
173
+ /** Pretty JSON for a payload or an output, `null` shown as such. */
174
+ export function prettyJson(value: unknown): string {
175
+ if (value === undefined) return "";
176
+ try {
177
+ return JSON.stringify(value, null, 2) ?? "";
178
+ } catch {
179
+ return String(value);
180
+ }
181
+ }
182
+
183
+ /** Parse a stored payload string, keeping the text when it is not JSON. */
184
+ export function parsePayload(raw: unknown): unknown {
185
+ if (typeof raw !== "string") return raw;
186
+ try {
187
+ return JSON.parse(raw);
188
+ } catch {
189
+ return raw;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * What a node does, in one line, from its settings (AU-10). A schedule reads
195
+ * as `scheduleText`, its words as the server writes them, else as its cron
196
+ * expression.
197
+ */
198
+ export function summarizeNode(
199
+ kind: string,
200
+ typeId: string | undefined,
201
+ config: Record<string, unknown> | undefined,
202
+ t: Translate,
203
+ scheduleText?: string,
204
+ ): string {
205
+ const c = config ?? {};
206
+ const text = (key: string) =>
207
+ typeof c[key] === "string" ? (c[key] as string) : "";
208
+ if (kind === "trigger") {
209
+ if (text("path")) return `${text("method") || "POST"} ${text("path")}`;
210
+ return text("cron") ? (scheduleText ?? text("cron")) : "";
211
+ }
212
+ if (text("url")) return `${text("method") || "GET"} ${shortUrl(text("url"))}`;
213
+ if (kind === "delay" && c.ms !== undefined)
214
+ return describeDuration(Number(c.ms));
215
+ if (text("message")) return `“${text("message")}”`;
216
+ if (kind === "data" && c.value !== undefined && typeof c.value !== "object")
217
+ return String(c.value);
218
+ if (Array.isArray(c.cases))
219
+ return (c.cases as unknown[]).map(String).join(" · ");
220
+ if (typeof c.maxAttempts === "number")
221
+ return t("$dms_automation.nodes.attempts", { n: c.maxAttempts });
222
+ if (Array.isArray(c.ports))
223
+ return (c.ports as unknown[]).map(String).join(" · ");
224
+ if (kind === "setVariable" && text("name")) return `${text("name")} =`;
225
+ return typeId && kind === "data" ? typeId : "";
226
+ }
227
+
228
+ function shortUrl(url: string): string {
229
+ try {
230
+ const u = new URL(url);
231
+ return `${u.host}${u.pathname === "/" ? "" : u.pathname}`;
232
+ } catch {
233
+ return url;
234
+ }
235
+ }
236
+
237
+ /** The colour role of a node's category: trigger, flow, data, action. */
238
+ export type NodeRole =
239
+ | "trigger"
240
+ | "flow"
241
+ | "data"
242
+ | "action"
243
+ | "helper"
244
+ | "group";
245
+
246
+ export function roleOf(kind: string, category?: string): NodeRole {
247
+ if (kind === "trigger") return "trigger";
248
+ if (kind === "action") return "action";
249
+ if (kind === "data") return "data";
250
+ if (kind === "group") return "group";
251
+ return category === "helper" ? "helper" : "flow";
252
+ }
@@ -0,0 +1,31 @@
1
+ /** How a stored run writes a secret header's value (see the backend's REDACTED). */
2
+ const REDACTED = "[redacted]";
3
+
4
+ /** The names in a group of a payload (headers, query) whose value is hidden. */
5
+ function redactedNames(group: unknown): string[] {
6
+ if (!group || typeof group !== "object") return [];
7
+ return Object.entries(group)
8
+ .filter(([, value]) => value === REDACTED)
9
+ .map(([name]) => name);
10
+ }
11
+
12
+ /**
13
+ * The headers and query parameters of a payload, typed as JSON, whose value
14
+ * was hidden when the run was stored: a payload prefilled from such a run must
15
+ * say so until they are replaced. A query parameter reads `?token`. Empty for a
16
+ * payload that is not JSON or holds neither.
17
+ */
18
+ export function redactedHeadersOf(payloadJson: string): string[] {
19
+ try {
20
+ const payload = JSON.parse(payloadJson || "null") as {
21
+ headers?: unknown;
22
+ query?: unknown;
23
+ } | null;
24
+ return [
25
+ ...redactedNames(payload?.headers),
26
+ ...redactedNames(payload?.query).map((name) => `?${name}`),
27
+ ];
28
+ } catch {
29
+ return [];
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ import { defineDmsFrontendBuild } from "#dms/frontend-build";
2
+
3
+ // The layer's public helpers, auto-imported in its own components: nothing is
4
+ // auto-imported from a module that does not list its folders here.
5
+ export default defineDmsFrontendBuild((build) => {
6
+ build.registerAutoImports(["app/composables", "app/utils"]);
7
+ });
@@ -1,6 +1,6 @@
1
1
  import { defineAsyncComponent, type Component } from "vue";
2
2
  import type { DmsFrontendModule } from "#dms/frontend-module";
3
- import timelinePlugin from "./app/plugins/runs-timeline-display.client";
3
+ import cellDisplaysPlugin from "./app/plugins/cell-displays";
4
4
 
5
5
  interface VueModule {
6
6
  default: Component;
@@ -9,17 +9,20 @@ interface VueModule {
9
9
  const components = import.meta.glob<VueModule>("./app/components/**/*.vue");
10
10
 
11
11
  const frontendModule: DmsFrontendModule = {
12
+ // Put in front of every registered name: Editor.vue registers as
13
+ // DmsAutomationEditor, which the backend names `dms-automation-editor`.
14
+ componentPrefix: "DmsAutomation",
12
15
  setup(sdk) {
13
16
  Object.entries(components)
14
17
  .sort(([left], [right]) => left.localeCompare(right))
15
18
  .forEach(([path, loader]) => {
16
- const name = `DmsAutomation${path
19
+ const name = path
17
20
  .split("/")
18
21
  .at(-1)!
19
- .replace(/\.vue$/, "")}`;
22
+ .replace(/\.vue$/, "");
20
23
  sdk.registerComponent(name, defineAsyncComponent(loader));
21
24
  });
22
- sdk.registerPlugin(timelinePlugin, { clientOnly: true });
25
+ sdk.registerPlugin(cellDisplaysPlugin);
23
26
  },
24
27
  };
25
28