@antelopejs/dms-automation 0.2.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +106 -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 +105 -44
  251. package/frontend-vue/app/components/Editor/GraphCanvas.vue +822 -207
  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 +382 -104
  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 -5
  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 -166
  300. package/frontend-vue/app/components/Catalog/TypeList.vue +0 -198
  301. package/frontend-vue/app/components/DataNodes.vue +0 -272
  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,81 @@
1
+ <script lang="ts">
2
+ interface WebhookBase {
3
+ url: string
4
+ configured: boolean
5
+ }
6
+
7
+ // Every endpoint shown is on the same origin: it is asked for once.
8
+ let baseRequest: Promise<WebhookBase | null> | undefined
9
+ </script>
10
+
11
+ <script setup lang="ts">
12
+ import { computed, onMounted, ref } from 'vue'
13
+
14
+ // The full URL a webhook trigger is called on — the API server's public
15
+ // origin and the trigger's path — with a copy button, and a curl example.
16
+ // `compact` keeps the URL and its copy button only, for a line in a list.
17
+ // Until the origin is known, or if it can't be, no URL is offered to copy:
18
+ // the path alone would be a wrong address to hand to another service.
19
+
20
+ const props = withDefaults(
21
+ defineProps<{
22
+ path: string
23
+ method?: string
24
+ apiUrl?: string
25
+ compact?: boolean
26
+ }>(),
27
+ { method: 'POST', apiUrl: '/api/automation', compact: false },
28
+ )
29
+
30
+ const { $authFetch } = useAuthFetch()
31
+
32
+ const base = ref<WebhookBase | null>(null)
33
+ const status = ref<'loading' | 'ready' | 'error'>('loading')
34
+
35
+ onMounted(async () => {
36
+ baseRequest ??= $authFetch<WebhookBase>(`${props.apiUrl}/library/webhook-base`).catch(() => {
37
+ baseRequest = undefined
38
+ return null
39
+ })
40
+ base.value = await baseRequest
41
+ status.value = base.value ? 'ready' : 'error'
42
+ })
43
+
44
+ const url = computed(() => `${base.value?.url ?? ''}${props.path}`)
45
+ const method = computed(() => (props.method || 'POST').toUpperCase())
46
+
47
+ const curl = computed(() => {
48
+ if (method.value === 'GET') return `curl '${url.value}'`
49
+ if (method.value === 'DELETE') return `curl -X DELETE '${url.value}'`
50
+ return [`curl -X ${method.value} '${url.value}'`, ` -H 'content-type: application/json'`, ` -d '{}'`].join(' \\\n')
51
+ })
52
+ </script>
53
+
54
+ <template>
55
+ <span v-if="compact" class="flex min-w-0 items-center gap-1">
56
+ <span class="min-w-0 truncate font-mono text-xs text-muted" :title="status === 'ready' ? url : undefined">
57
+ {{ method }} {{ status === 'ready' ? url : path }}
58
+ </span>
59
+ <DmsCopyButton v-if="status === 'ready'" :value="url" />
60
+ <UIcon v-else-if="status === 'loading'" name="i-ph-circle-notch" class="size-3.5 shrink-0 animate-spin text-dimmed" :aria-label="$t('dms_automation.library.webhookLoading')" />
61
+ <UTooltip v-else :text="$t('dms_automation.library.webhookBaseError')">
62
+ <UIcon name="i-ph-warning" class="size-3.5 shrink-0 text-warning" :aria-label="$t('dms_automation.library.webhookBaseError')" />
63
+ </UTooltip>
64
+ </span>
65
+ <div v-else class="flex flex-col gap-2">
66
+ <p class="text-xs text-muted">{{ $t('dms_automation.library.webhook.hint') }}</p>
67
+ <template v-if="status === 'ready'">
68
+ <div class="flex min-w-0 items-center gap-2 rounded-md border border-default bg-elevated/40 py-1 ps-2.5 pe-1">
69
+ <UBadge size="sm" color="neutral" variant="subtle" class="font-mono">{{ method }}</UBadge>
70
+ <span class="min-w-0 flex-1 truncate font-mono text-xs text-highlighted" :title="url">{{ url }}</span>
71
+ <DmsCopyButton :value="url" />
72
+ </div>
73
+ <DmsCodeSnippet :code="curl" language="shell" :title="$t('dms_automation.library.webhook.example')" wrap />
74
+ <p v-if="!base?.configured" class="text-[11px] text-dimmed">
75
+ {{ $t('dms_automation.library.webhook.unconfigured') }}
76
+ </p>
77
+ </template>
78
+ <USkeleton v-else-if="status === 'loading'" class="h-9 w-full" :aria-label="$t('dms_automation.library.webhookLoading')" />
79
+ <p v-else class="text-xs text-warning">{{ $t('dms_automation.library.webhookBaseError') }}</p>
80
+ </div>
81
+ </template>
@@ -1,5 +1,4 @@
1
- import type { JsonSchema } from "./useGraphConnect";
2
- import { type ListEnvelope, unwrapList } from "../utils/automation";
1
+ import type { GroupPort, JsonSchema } from "./useGraphConnect";
3
2
 
4
3
  export interface PortRef {
5
4
  name: string;
@@ -35,14 +34,32 @@ export interface NodeKindEntry {
35
34
  };
36
35
  }
37
36
 
37
+ /** Data type of a block dragged from the builder palette onto the canvas. */
38
+ export const PALETTE_DRAG_TYPE = "application/x-dms-automation-block";
39
+
40
+ /**
41
+ * A workspace template as the palette offers it: the fields placing it
42
+ * needs (the list endpoint serves more).
43
+ */
44
+ export interface TemplateSummary {
45
+ _id: string;
46
+ name: string;
47
+ icon?: string;
48
+ ports: GroupPort[];
49
+ }
50
+
51
+ /** The block being dragged: a node kind (and type), or a workspace template. */
52
+ export interface PaletteBlock {
53
+ kind?: string;
54
+ typeId?: string;
55
+ template?: TemplateSummary;
56
+ }
57
+
38
58
  export function useAutomationNodeKinds() {
39
59
  const { $authFetch } = useAuthFetch();
40
60
  return {
41
61
  async list(): Promise<NodeKindEntry[]> {
42
- const data = await $authFetch<
43
- NodeKindEntry[] | ListEnvelope<NodeKindEntry>
44
- >("/api/automation/node-kinds");
45
- return unwrapList(data);
62
+ return await $authFetch<NodeKindEntry[]>("/api/automation/node-kinds");
46
63
  },
47
64
  };
48
65
  }
@@ -1,4 +1,4 @@
1
- import { type ListEnvelope, unwrapList } from "../utils/automation";
1
+ import type { StepName, TriggerSummary } from "../utils/describe";
2
2
 
3
3
  export type LogLevel = "info" | "warn" | "error";
4
4
 
@@ -8,10 +8,6 @@ export interface FireNode {
8
8
  sourceNodeId: string;
9
9
  port: string | null;
10
10
  ts: number;
11
- /**
12
- * Monotonic per-run sequence number, shared with LogEntry.seq.
13
- * Tiebreaker when several events share the same millisecond ts.
14
- */
15
11
  seq: number;
16
12
  iteration?: number;
17
13
  closedAt?: number;
@@ -32,44 +28,183 @@ export interface LogEntry {
32
28
  export interface RunLog {
33
29
  fires: FireNode[];
34
30
  entries: LogEntry[];
31
+ truncated?: number;
35
32
  }
36
33
 
37
- export interface RunSummary {
34
+ /** One execution of a step, read from the run's log by the backend. */
35
+ export interface TraceStep {
36
+ nodeId: string;
37
+ name: StepName;
38
+ fireId: string;
39
+ startMs: number;
40
+ durationMs: number | null;
41
+ /** `truncated`: its end was cut from the log to keep the run small. */
42
+ status: "ok" | "failed" | "running" | "truncated";
43
+ error?: string;
44
+ inputs?: unknown;
45
+ output?: unknown;
46
+ /** 0 in the run's own flow, one more inside each loop, try or branch. */
47
+ depth: number;
48
+ /** Index in the trace's steps of the loop, retry, try or parallel step it ran under. */
49
+ parent?: number;
50
+ /** That step's port: `body`, `try`, `catch`, a parallel branch. */
51
+ port?: string;
52
+ /** The iteration or attempt of that step, from 0. */
53
+ iteration?: number;
54
+ /** The branch the step chose: `then`, a switch case, `exhausted`. */
55
+ branch?: string;
56
+ /** A failure a Try/Catch or a Retry around the step caught. */
57
+ handled?: boolean;
58
+ }
59
+
60
+ /** A step of the graph the run did not reach, and why. */
61
+ export interface SkippedStep {
62
+ nodeId: string;
63
+ name: StepName;
64
+ reason: "branch" | "stopped";
65
+ }
66
+
67
+ export interface RunRef {
68
+ runId: string;
69
+ startedAt: string;
70
+ durationMs: number | null;
71
+ stepDurations: Record<string, number | null>;
72
+ }
73
+
74
+ interface GraphNodeLite {
75
+ id: string;
76
+ kind: string;
77
+ typeId?: string;
78
+ label?: string;
79
+ config?: Record<string, unknown>;
80
+ position: { x: number; y: number };
81
+ }
82
+
83
+ interface GraphLite {
84
+ nodes: GraphNodeLite[];
85
+ triggerEdges: Array<{
86
+ id: string;
87
+ from: { node: string; branch?: string };
88
+ to: { node: string; branch?: string };
89
+ }>;
90
+ dataEdges: Array<{
91
+ id: string;
92
+ from: { node: string; port: string };
93
+ to: { node: string; field: string };
94
+ }>;
95
+ }
96
+
97
+ /** A run next to another in its procedure's history. */
98
+ export interface RunNeighbour {
99
+ runId: string;
100
+ startedAt: string;
101
+ status: string;
102
+ errorMessage: string;
103
+ }
104
+
105
+ /** A run as `GET /runs/:id` answers it, with its trace. */
106
+ export interface RunDetail {
38
107
  _id: string;
39
108
  procedureId: string;
40
109
  startedAt: string;
41
110
  endedAt?: string | null;
42
- status: string;
111
+ status: "ok" | "failed";
43
112
  errorMessage?: string | null;
44
- triggerNodeId?: string;
113
+ triggerNodeId: string;
45
114
  triggerPayload?: string;
115
+ payloadKept: boolean;
116
+ kind: "run" | "rerun" | "test";
117
+ rerunOf?: string;
118
+ failedNodeId?: string;
119
+ instanceId?: string;
120
+ /** The version that ran; `null` for a test run of the builder's draft. */
121
+ procedureVersion?: number | null;
122
+ procedureName: string;
123
+ durationMs: number;
124
+ /** The log, when the run carries it; else read with `getLogs`. */
125
+ logs?: RunLog;
126
+ logCount?: number;
127
+ logTruncated?: number;
128
+ procedure: {
129
+ _id: string;
130
+ name: string;
131
+ enabled: boolean;
132
+ version: number;
133
+ } | null;
134
+ /** The graph drawn: the one that ran, else (`graphOutdated`) the current one. */
135
+ graph: GraphLite | null;
136
+ graphOutdated?: boolean;
137
+ trigger: TriggerSummary | null;
138
+ /** What started the run, worded by the server. */
139
+ triggerText: BlockText;
140
+ failedStep: StepName | null;
141
+ trace: {
142
+ steps: TraceStep[];
143
+ skipped: SkippedStep[];
144
+ edgesTaken?: string[];
145
+ truncated?: number;
146
+ };
147
+ usualDurationMs: number | null;
148
+ lastSuccess: RunRef | null;
149
+ /** The runs of the same procedure and kind just before and after this one. */
150
+ previous: RunNeighbour | null;
151
+ next?: RunNeighbour | null;
152
+ failuresInRow: number;
46
153
  }
47
154
 
48
- export interface RunDetail extends RunSummary {
49
- logs?: RunLog;
155
+ /** What `POST /runs/:id/rerun` answers: the new run and how it ended. */
156
+ export interface RerunResult {
157
+ runId: string;
158
+ status?: "ok" | "failed";
159
+ /** An i18n key (with `$`) to show when the new run failed. */
160
+ warning?: string;
50
161
  }
51
162
 
52
- export interface ProcedureRef {
53
- _id: string;
54
- name: string;
163
+ /**
164
+ * The builder open on a run: its procedure, with this run's trace and, given
165
+ * one, a step selected (its top-level node: a step inside a group selects the
166
+ * group). The trace, the drawer and the path taken all link through it.
167
+ */
168
+ export function builderRunUrl(
169
+ builderUrl: string,
170
+ run: RunDetail,
171
+ nodeId?: string,
172
+ ): string {
173
+ const query = new URLSearchParams({
174
+ selected: run.procedureId,
175
+ run: run._id,
176
+ });
177
+ if (nodeId) query.set("node", nodeId.split("__")[0] ?? nodeId);
178
+ return `${builderUrl}?${query}`;
179
+ }
180
+
181
+ /**
182
+ * Whether the builder can show a run: not for a deleted procedure, and not
183
+ * for a test, which ran a draft the builder does not have.
184
+ */
185
+ export function opensInBuilder(run: RunDetail): boolean {
186
+ return !!run.procedure && run.kind !== "test";
55
187
  }
56
188
 
57
- export function useAutomationRuns() {
189
+ /** The run endpoints the drawer, the trace and the builder share. */
190
+ export function useAutomationRuns(apiUrl = "/api/automation") {
58
191
  const { $authFetch } = useAuthFetch();
192
+ // A run id from the URL goes into a path: encoded, "../procedures" stays
193
+ // a run id that does not exist instead of reaching another route.
194
+ const runUrl = (id: string) => `${apiUrl}/runs/${encodeURIComponent(id)}`;
59
195
 
60
196
  return {
61
- async getRun(id: string): Promise<RunDetail> {
62
- return await $authFetch<RunDetail>(`/api/automation/runs/${id}`);
197
+ getRun(id: string): Promise<RunDetail> {
198
+ return $authFetch<RunDetail>(runUrl(id));
63
199
  },
64
-
65
- async listProcedures(): Promise<ProcedureRef[]> {
66
- const data = await $authFetch<
67
- ProcedureRef[] | ListEnvelope<ProcedureRef>
68
- >("/api/automation/procedures");
69
- return unwrapList<ProcedureRef>(data).map((p) => ({
70
- _id: p._id,
71
- name: p.name,
72
- }));
200
+ getLogs(id: string): Promise<RunLog> {
201
+ return $authFetch<RunLog>(`${runUrl(id)}/logs`);
202
+ },
203
+ rerun(id: string): Promise<RerunResult> {
204
+ return $authFetch<RerunResult>(`${runUrl(id)}/rerun`, {
205
+ method: "POST",
206
+ body: {},
207
+ });
73
208
  },
74
209
  };
75
210
  }
@@ -1,4 +1,4 @@
1
- import type { NodeKindEntry } from "./useAutomationNodeKinds";
1
+ import type { NodeKindEntry, PortRef } from "./useAutomationNodeKinds";
2
2
 
3
3
  /**
4
4
  * Node kind is a free-form string keyed off the runtime kind registry
@@ -12,8 +12,14 @@ export interface GraphNode {
12
12
  id: string;
13
13
  kind: NodeKind;
14
14
  typeId?: string;
15
+ // The step's name, set in the inspector (a group's falls back to config.name).
16
+ label?: string;
15
17
  config: Record<string, unknown>;
16
18
  position: { x: number; y: number };
19
+ // Group-only extras — present iff kind === 'group'.
20
+ ports?: GroupPort[];
21
+ templateId?: string;
22
+ subgraph?: ProcedureGraph;
17
23
  }
18
24
 
19
25
  export interface TriggerEdge {
@@ -63,6 +69,8 @@ export interface TriggerType {
63
69
  description?: string;
64
70
  icon?: string;
65
71
  module?: string;
72
+ /** False when the type is switched off in the Library. */
73
+ enabled?: boolean;
66
74
  configSchema?: JsonSchema;
67
75
  outputSchema?: JsonSchema;
68
76
  }
@@ -73,6 +81,8 @@ export interface ActionType {
73
81
  description?: string;
74
82
  icon?: string;
75
83
  module?: string;
84
+ /** False when the type is switched off in the Library. */
85
+ enabled?: boolean;
76
86
  inputSchema?: JsonSchema;
77
87
  outputSchema?: JsonSchema;
78
88
  }
@@ -104,8 +114,8 @@ export interface GroupPort {
104
114
  /**
105
115
  * A group node carries the ports its subgraph exposes, as a sibling field of
106
116
  * `config`/`position` — mirrors `GroupNode` on the backend. `ports` is optional
107
- * here because the value crosses the API: a group saved before it had any port,
108
- * or a hand-written graph, simply omits it.
117
+ * here because the value crosses the API: a hand-written (imported) graph may
118
+ * omit it.
109
119
  */
110
120
  export interface GroupNode extends GraphNode {
111
121
  kind: "group";
@@ -116,9 +126,9 @@ export function isGroupNode(node: GraphNode): node is GroupNode {
116
126
  return node.kind === "group";
117
127
  }
118
128
 
119
- export type ConnectKind = "trigger" | "data";
129
+ type ConnectKind = "trigger" | "data";
120
130
 
121
- export interface ConnectionLike {
131
+ interface ConnectionLike {
122
132
  id?: string;
123
133
  source: string;
124
134
  target: string;
@@ -126,14 +136,27 @@ export interface ConnectionLike {
126
136
  targetHandle?: string | null;
127
137
  }
128
138
 
129
- export type ConnectResult = { ok: true } | { ok: false; reason: string };
139
+ /**
140
+ * Why a connection is refused. The canvas turns the code into a sentence
141
+ * (`dms_automation.editor.canvas.connect.<code>`), with `params` filled in.
142
+ */
143
+ type ConnectRefusal =
144
+ | "invalidPorts"
145
+ | "kindMismatch"
146
+ | "selfLoop"
147
+ | "cycle"
148
+ | "typeMismatch";
149
+
150
+ export type ConnectResult =
151
+ | { ok: true }
152
+ | { ok: false; code: ConnectRefusal; params?: Record<string, string> };
130
153
 
131
154
  // Optional context for canConnect / schema lookups. `parentGroupPorts` is the
132
155
  // declared port list of the outer group when the canvas is editing that
133
156
  // group's inner subgraph — the sentinel nodes (`groupInput` / `groupOutput`)
134
157
  // don't carry ports themselves, so their schemas must be looked up against
135
158
  // the parent group. Undefined at the procedure-graph root.
136
- export interface ConnectContext {
159
+ interface ConnectContext {
137
160
  parentGroupPorts?: GroupPort[];
138
161
  }
139
162
 
@@ -296,11 +319,6 @@ function portsToSyntheticSchema(ports: PortRef[]): JsonSchema {
296
319
  return { properties };
297
320
  }
298
321
 
299
- interface PortRef {
300
- name: string;
301
- type?: string;
302
- }
303
-
304
322
  // Type-registry schemas have a small set of source schemas
305
323
  // (`inputSchema`, `outputSchema`, `configSchema`); the per-kind UI
306
324
  // metadata picks one via the `dataInsFromTypeSchema`/`dataOutsFromTypeSchema`
@@ -436,6 +454,25 @@ function isTriggerTargetHandle(handle: string | null | undefined): boolean {
436
454
  return TRIGGER_IN_PREFIXES.some((p) => handle.startsWith(p));
437
455
  }
438
456
 
457
+ // True when `to` can be reached from `from` by following `next`: linking
458
+ // `to` back to `from` would then close a loop.
459
+ function reaches(
460
+ from: string,
461
+ to: string,
462
+ next: (node: string) => string[],
463
+ ): boolean {
464
+ const seen = new Set<string>();
465
+ const stack = [from];
466
+ while (stack.length > 0) {
467
+ const node = stack.pop()!;
468
+ if (node === to) return true;
469
+ if (seen.has(node)) continue;
470
+ seen.add(node);
471
+ stack.push(...next(node));
472
+ }
473
+ return false;
474
+ }
475
+
439
476
  export function canConnect(
440
477
  graph: ProcedureGraph,
441
478
  nodeKinds: NodeKindEntry[],
@@ -452,21 +489,6 @@ export function canConnect(
452
489
  // `ok` so the existing edge keeps rendering. The real connect path
453
490
  // always supplies both endpoints.
454
491
  if (!source || !target) return { ok: true };
455
- if (source === target) return { ok: true };
456
-
457
- const fromKind = connectionKind(sourceHandle);
458
- const toKind = connectionKind(targetHandle);
459
- if (!fromKind || !toKind) return { ok: false, reason: "Unrecognized handle" };
460
- if (fromKind !== toKind)
461
- return {
462
- ok: false,
463
- reason: "Cannot connect trigger handle to data handle",
464
- };
465
-
466
- const sourceNode = findNode(graph, source);
467
- const targetNode = findNode(graph, target);
468
- if (!sourceNode || !targetNode)
469
- return { ok: false, reason: "Unknown node id" };
470
492
 
471
493
  const selfId = connection.id;
472
494
  // If the edge being validated is already in the graph (Vue Flow calls
@@ -476,38 +498,65 @@ export function canConnect(
476
498
  !!selfId &&
477
499
  (graph.triggerEdges.some((e) => e.id === selfId) ||
478
500
  graph.dataEdges.some((e) => e.id === selfId));
501
+ if (isReValidation) return { ok: true };
502
+
503
+ const fromKind = connectionKind(sourceHandle);
504
+ const toKind = connectionKind(targetHandle);
505
+ if (!fromKind || !toKind) return { ok: false, code: "invalidPorts" };
506
+ if (fromKind !== toKind) return { ok: false, code: "kindMismatch" };
507
+ // A step wired to itself either never ends (trigger) or reads an output it
508
+ // has not produced yet (data).
509
+ if (source === target) return { ok: false, code: "selfLoop" };
510
+
511
+ const sourceNode = findNode(graph, source);
512
+ const targetNode = findNode(graph, target);
513
+ if (!sourceNode || !targetNode) return { ok: false, code: "invalidPorts" };
479
514
 
480
515
  if (fromKind === "trigger") {
481
516
  // Source must be one of the trigger-out flavors; target one of the
482
517
  // trigger-in flavors. (No literal-handle check — the new prefixes
483
518
  // `group-trigger-in-<port>` / `groupOutput-trigger-in-<port>` are
484
519
  // valid in addition to the fixed `trigger-in`.)
485
- if (!isTriggerSourceHandle(sourceHandle))
486
- return { ok: false, reason: "Trigger source must be an out handle" };
487
- if (!isTriggerTargetHandle(targetHandle))
488
- return {
489
- ok: false,
490
- reason: "Trigger target must be a trigger-in handle",
491
- };
492
- // Stateful rules (divergence, duplicate) only apply to NEW connections.
493
- // During re-validation of stored edges, trust the persisted state.
520
+ if (
521
+ !isTriggerSourceHandle(sourceHandle) ||
522
+ !isTriggerTargetHandle(targetHandle)
523
+ )
524
+ return { ok: false, code: "invalidPorts" };
525
+ // The server refuses a trigger cycle: refuse it while drawing. The edge
526
+ // this one may replace leaves `source`, so it can't be on a path that
527
+ // ends there.
528
+ if (
529
+ reaches(target, source, (n) =>
530
+ graph.triggerEdges
531
+ .filter((e) => e.from.node === n)
532
+ .map((e) => e.to.node),
533
+ )
534
+ )
535
+ return { ok: false, code: "cycle" };
494
536
  // Replacement of an existing outgoing edge is handled by the connect
495
- // handler, not by rejection here.
496
- //
497
- // Note: divergence is enforced server-side by `validate.ts` via
498
- // `nodeKinds.mayDiverge(kind)`. The frontend connect path replaces
499
- // existing outgoing edges per source/branch in GraphCanvas.vue so
500
- // divergence never actually occurs from non-whitelisted sources at
501
- // the editor level.
537
+ // handler, not by rejection here. Divergence is enforced server-side by
538
+ // `validate.ts` via `nodeKinds.mayDiverge(kind)`.
502
539
  return { ok: true };
503
540
  }
504
541
 
505
542
  // data edge — overwrite is allowed; replacement is handled by the caller.
506
543
  const port = parseDataPort(sourceHandle);
507
544
  const field = parseDataField(targetHandle);
508
- if (!port || !field) return { ok: false, reason: "Invalid data handle id" };
509
-
510
- if (isReValidation) return { ok: true };
545
+ if (!port || !field) return { ok: false, code: "invalidPorts" };
546
+
547
+ // A loop of data nodes fails at run time ("data node cycle detected"). A
548
+ // loop through a step only reads that step's last output, so it stays.
549
+ const isData = (id: string) => findNode(graph, id)?.kind === "data";
550
+ if (
551
+ isData(source) &&
552
+ isData(target) &&
553
+ reaches(target, source, (n) =>
554
+ graph.dataEdges
555
+ .filter((e) => e.from.node === n && isData(e.to.node))
556
+ .map((e) => e.to.node),
557
+ )
558
+ )
559
+ return { ok: false, code: "cycle" };
511
560
 
512
561
  const outSchema = getOutputSchema(
513
562
  sourceNode,
@@ -527,16 +576,19 @@ export function canConnect(
527
576
  );
528
577
  const outProp = outSchema?.properties?.[port];
529
578
  const inProp = inSchema?.properties?.[field];
530
- if (outSchema && !outProp)
531
- return { ok: false, reason: `Unknown source port "${port}"` };
532
- if (inSchema && !inProp)
533
- return { ok: false, reason: `Unknown target field "${field}"` };
579
+ if ((outSchema && !outProp) || (inSchema && !inProp))
580
+ return { ok: false, code: "invalidPorts" };
534
581
 
535
582
  if (!typesCompatible(outProp?.type, inProp?.type))
536
583
  return {
537
584
  ok: false,
538
- reason: `Type mismatch: ${outProp?.type} → ${inProp?.type}`,
585
+ code: "typeMismatch",
586
+ params: { from: typeText(outProp?.type), to: typeText(inProp?.type) },
539
587
  };
540
588
 
541
589
  return { ok: true };
542
590
  }
591
+
592
+ function typeText(type: string | string[] | undefined): string {
593
+ return Array.isArray(type) ? type.join(" / ") : (type ?? "");
594
+ }
@@ -0,0 +1,60 @@
1
+ import { ref } from "vue";
2
+ import { type RerunResult, useAutomationRuns } from "./useAutomationRuns";
3
+
4
+ /**
5
+ * "Re-run with this payload", shared by the run drawer, the trace and the
6
+ * builder: it asks first, in the server's words (side effects are real, the
7
+ * procedure may be paused, some headers are replayed redacted, or the run
8
+ * cannot be re-run at all), runs, says how the new run ended and opens its
9
+ * trace.
10
+ */
11
+ export function useRunActions(options: { apiUrl: string; traceUrl: string }) {
12
+ const { t } = useI18n();
13
+ const { processI18n } = useTranslation();
14
+ const { confirmFrom } = useConfirmFrom();
15
+ const toast = useToast();
16
+ const router = useDmsRouter();
17
+ const runs = useAutomationRuns(options.apiUrl);
18
+ const rerunning = ref(false);
19
+ let asking = false;
20
+
21
+ async function rerun(runId: string, procedureName: string): Promise<void> {
22
+ // A second click while the first is under way does nothing: the button
23
+ // shows it loading. The server also refuses a re-run asked twice in a
24
+ // row, and the dialog shows its message.
25
+ if (asking || rerunning.value) return;
26
+ asking = true;
27
+ let result: RerunResult | undefined;
28
+ try {
29
+ await confirmFrom(`${options.apiUrl}/runs/{id}/rerun-confirm`, {
30
+ params: { id: runId, name: procedureName },
31
+ fallback: { color: "warning", icon: "i-ph-arrow-clockwise" },
32
+ onConfirm: async () => {
33
+ rerunning.value = true;
34
+ try {
35
+ result = await runs.rerun(runId);
36
+ } finally {
37
+ rerunning.value = false;
38
+ }
39
+ },
40
+ });
41
+ } finally {
42
+ asking = false;
43
+ }
44
+ if (!result) return;
45
+ const failed = result.status === "failed";
46
+ toast.add({
47
+ title: failed
48
+ ? t("dms_automation.trace.rerunFailed", { name: procedureName })
49
+ : t("dms_automation.runs.rerunDone", { name: procedureName }),
50
+ description: result.warning ? processI18n(result.warning) : undefined,
51
+ color: failed ? "error" : "success",
52
+ icon: failed ? "i-ph-x-circle" : "i-ph-check-circle",
53
+ });
54
+ await router.push(
55
+ `${options.traceUrl}?run=${encodeURIComponent(result.runId)}`,
56
+ );
57
+ }
58
+
59
+ return { rerun, rerunning };
60
+ }