@antelopejs/dms-automation 0.0.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 (305) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +95 -0
  3. package/dist/cluster/bus.d.ts +17 -0
  4. package/dist/cluster/bus.js +82 -0
  5. package/dist/cluster/bus.js.map +1 -0
  6. package/dist/cluster/instance.d.ts +1 -0
  7. package/dist/cluster/instance.js +6 -0
  8. package/dist/cluster/instance.js.map +1 -0
  9. package/dist/cluster/leader.d.ts +7 -0
  10. package/dist/cluster/leader.js +123 -0
  11. package/dist/cluster/leader.js.map +1 -0
  12. package/dist/cluster/mode.d.ts +3 -0
  13. package/dist/cluster/mode.js +25 -0
  14. package/dist/cluster/mode.js.map +1 -0
  15. package/dist/data/procedures-table.d.ts +66 -0
  16. package/dist/data/procedures-table.js +271 -0
  17. package/dist/data/procedures-table.js.map +1 -0
  18. package/dist/data/runs-table.d.ts +23 -0
  19. package/dist/data/runs-table.js +125 -0
  20. package/dist/data/runs-table.js.map +1 -0
  21. package/dist/db/index.d.ts +7 -0
  22. package/dist/db/index.js +24 -0
  23. package/dist/db/index.js.map +1 -0
  24. package/dist/db/models/automation_template.model.d.ts +58 -0
  25. package/dist/db/models/automation_template.model.js +134 -0
  26. package/dist/db/models/automation_template.model.js.map +1 -0
  27. package/dist/db/models/index.d.ts +3 -0
  28. package/dist/db/models/index.js +20 -0
  29. package/dist/db/models/index.js.map +1 -0
  30. package/dist/db/models/procedure.model.d.ts +25 -0
  31. package/dist/db/models/procedure.model.js +28 -0
  32. package/dist/db/models/procedure.model.js.map +1 -0
  33. package/dist/db/models/procedure_run.model.d.ts +34 -0
  34. package/dist/db/models/procedure_run.model.js +39 -0
  35. package/dist/db/models/procedure_run.model.js.map +1 -0
  36. package/dist/db/models/stats.model.d.ts +73 -0
  37. package/dist/db/models/stats.model.js +267 -0
  38. package/dist/db/models/stats.model.js.map +1 -0
  39. package/dist/db/models/type_config.model.d.ts +47 -0
  40. package/dist/db/models/type_config.model.js +51 -0
  41. package/dist/db/models/type_config.model.js.map +1 -0
  42. package/dist/db/tables/action_type_config.table.d.ts +7 -0
  43. package/dist/db/tables/action_type_config.table.js +35 -0
  44. package/dist/db/tables/action_type_config.table.js.map +1 -0
  45. package/dist/db/tables/automation_template.table.d.ts +11 -0
  46. package/dist/db/tables/automation_template.table.js +52 -0
  47. package/dist/db/tables/automation_template.table.js.map +1 -0
  48. package/dist/db/tables/index.d.ts +5 -0
  49. package/dist/db/tables/index.js +22 -0
  50. package/dist/db/tables/index.js.map +1 -0
  51. package/dist/db/tables/procedure.table.d.ts +10 -0
  52. package/dist/db/tables/procedure.table.js +48 -0
  53. package/dist/db/tables/procedure.table.js.map +1 -0
  54. package/dist/db/tables/procedure_run.table.d.ts +13 -0
  55. package/dist/db/tables/procedure_run.table.js +57 -0
  56. package/dist/db/tables/procedure_run.table.js.map +1 -0
  57. package/dist/db/tables/trigger_type_config.table.d.ts +7 -0
  58. package/dist/db/tables/trigger_type_config.table.js +35 -0
  59. package/dist/db/tables/trigger_type_config.table.js.map +1 -0
  60. package/dist/implementations/dms-automation/index.d.ts +19 -0
  61. package/dist/implementations/dms-automation/index.js +50 -0
  62. package/dist/implementations/dms-automation/index.js.map +1 -0
  63. package/dist/index.d.ts +14 -0
  64. package/dist/index.js +121 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/pages/builder.d.ts +10 -0
  67. package/dist/pages/builder.js +28 -0
  68. package/dist/pages/builder.js.map +1 -0
  69. package/dist/pages/category.d.ts +1 -0
  70. package/dist/pages/category.js +10 -0
  71. package/dist/pages/category.js.map +1 -0
  72. package/dist/pages/index.d.ts +6 -0
  73. package/dist/pages/index.js +9 -0
  74. package/dist/pages/index.js.map +1 -0
  75. package/dist/pages/library.d.ts +10 -0
  76. package/dist/pages/library.js +28 -0
  77. package/dist/pages/library.js.map +1 -0
  78. package/dist/pages/overview.d.ts +10 -0
  79. package/dist/pages/overview.js +28 -0
  80. package/dist/pages/overview.js.map +1 -0
  81. package/dist/pages/procedures.d.ts +10 -0
  82. package/dist/pages/procedures.js +72 -0
  83. package/dist/pages/procedures.js.map +1 -0
  84. package/dist/pages/runs.d.ts +11 -0
  85. package/dist/pages/runs.js +61 -0
  86. package/dist/pages/runs.js.map +1 -0
  87. package/dist/routes/action-types.d.ts +23 -0
  88. package/dist/routes/action-types.js +80 -0
  89. package/dist/routes/action-types.js.map +1 -0
  90. package/dist/routes/data-node-types.d.ts +6 -0
  91. package/dist/routes/data-node-types.js +36 -0
  92. package/dist/routes/data-node-types.js.map +1 -0
  93. package/dist/routes/graphSchema.d.ts +92 -0
  94. package/dist/routes/graphSchema.js +60 -0
  95. package/dist/routes/graphSchema.js.map +1 -0
  96. package/dist/routes/index.d.ts +8 -0
  97. package/dist/routes/index.js +11 -0
  98. package/dist/routes/index.js.map +1 -0
  99. package/dist/routes/node-kinds.d.ts +9 -0
  100. package/dist/routes/node-kinds.js +35 -0
  101. package/dist/routes/node-kinds.js.map +1 -0
  102. package/dist/routes/procedures.d.ts +23 -0
  103. package/dist/routes/procedures.js +181 -0
  104. package/dist/routes/procedures.js.map +1 -0
  105. package/dist/routes/runs.d.ts +7 -0
  106. package/dist/routes/runs.js +81 -0
  107. package/dist/routes/runs.js.map +1 -0
  108. package/dist/routes/stats.d.ts +6 -0
  109. package/dist/routes/stats.js +35 -0
  110. package/dist/routes/stats.js.map +1 -0
  111. package/dist/routes/templates.d.ts +20 -0
  112. package/dist/routes/templates.js +243 -0
  113. package/dist/routes/templates.js.map +1 -0
  114. package/dist/routes/trigger-types.d.ts +24 -0
  115. package/dist/routes/trigger-types.js +80 -0
  116. package/dist/routes/trigger-types.js.map +1 -0
  117. package/dist/routes/typeConfigShared.d.ts +22 -0
  118. package/dist/routes/typeConfigShared.js +37 -0
  119. package/dist/routes/typeConfigShared.js.map +1 -0
  120. package/dist/runtime/builtins/actions/http.d.ts +13 -0
  121. package/dist/runtime/builtins/actions/http.js +47 -0
  122. package/dist/runtime/builtins/actions/http.js.map +1 -0
  123. package/dist/runtime/builtins/actions/index.d.ts +2 -0
  124. package/dist/runtime/builtins/actions/index.js +7 -0
  125. package/dist/runtime/builtins/actions/index.js.map +1 -0
  126. package/dist/runtime/builtins/actions/log.d.ts +13 -0
  127. package/dist/runtime/builtins/actions/log.js +49 -0
  128. package/dist/runtime/builtins/actions/log.js.map +1 -0
  129. package/dist/runtime/builtins/data/boolean.d.ts +2 -0
  130. package/dist/runtime/builtins/data/boolean.js +39 -0
  131. package/dist/runtime/builtins/data/boolean.js.map +1 -0
  132. package/dist/runtime/builtins/data/compare.d.ts +2 -0
  133. package/dist/runtime/builtins/data/compare.js +29 -0
  134. package/dist/runtime/builtins/data/compare.js.map +1 -0
  135. package/dist/runtime/builtins/data/constant.d.ts +2 -0
  136. package/dist/runtime/builtins/data/constant.js +29 -0
  137. package/dist/runtime/builtins/data/constant.js.map +1 -0
  138. package/dist/runtime/builtins/data/index.d.ts +2 -0
  139. package/dist/runtime/builtins/data/index.js +20 -0
  140. package/dist/runtime/builtins/data/index.js.map +1 -0
  141. package/dist/runtime/builtins/data/json.d.ts +2 -0
  142. package/dist/runtime/builtins/data/json.js +46 -0
  143. package/dist/runtime/builtins/data/json.js.map +1 -0
  144. package/dist/runtime/builtins/data/math.d.ts +2 -0
  145. package/dist/runtime/builtins/data/math.js +53 -0
  146. package/dist/runtime/builtins/data/math.js.map +1 -0
  147. package/dist/runtime/builtins/data/object.d.ts +2 -0
  148. package/dist/runtime/builtins/data/object.js +121 -0
  149. package/dist/runtime/builtins/data/object.js.map +1 -0
  150. package/dist/runtime/builtins/data/string.d.ts +2 -0
  151. package/dist/runtime/builtins/data/string.js +143 -0
  152. package/dist/runtime/builtins/data/string.js.map +1 -0
  153. package/dist/runtime/builtins/index.d.ts +17 -0
  154. package/dist/runtime/builtins/index.js +24 -0
  155. package/dist/runtime/builtins/index.js.map +1 -0
  156. package/dist/runtime/builtins/nodes/action.d.ts +1 -0
  157. package/dist/runtime/builtins/nodes/action.js +36 -0
  158. package/dist/runtime/builtins/nodes/action.js.map +1 -0
  159. package/dist/runtime/builtins/nodes/data.d.ts +1 -0
  160. package/dist/runtime/builtins/nodes/data.js +28 -0
  161. package/dist/runtime/builtins/nodes/data.js.map +1 -0
  162. package/dist/runtime/builtins/nodes/delay.d.ts +1 -0
  163. package/dist/runtime/builtins/nodes/delay.js +41 -0
  164. package/dist/runtime/builtins/nodes/delay.js.map +1 -0
  165. package/dist/runtime/builtins/nodes/forRange.d.ts +1 -0
  166. package/dist/runtime/builtins/nodes/forRange.js +52 -0
  167. package/dist/runtime/builtins/nodes/forRange.js.map +1 -0
  168. package/dist/runtime/builtins/nodes/foreach.d.ts +1 -0
  169. package/dist/runtime/builtins/nodes/foreach.js +31 -0
  170. package/dist/runtime/builtins/nodes/foreach.js.map +1 -0
  171. package/dist/runtime/builtins/nodes/groupInput.d.ts +1 -0
  172. package/dist/runtime/builtins/nodes/groupInput.js +11 -0
  173. package/dist/runtime/builtins/nodes/groupInput.js.map +1 -0
  174. package/dist/runtime/builtins/nodes/groupOutput.d.ts +1 -0
  175. package/dist/runtime/builtins/nodes/groupOutput.js +11 -0
  176. package/dist/runtime/builtins/nodes/groupOutput.js.map +1 -0
  177. package/dist/runtime/builtins/nodes/if.d.ts +1 -0
  178. package/dist/runtime/builtins/nodes/if.js +23 -0
  179. package/dist/runtime/builtins/nodes/if.js.map +1 -0
  180. package/dist/runtime/builtins/nodes/parallel.d.ts +1 -0
  181. package/dist/runtime/builtins/nodes/parallel.js +34 -0
  182. package/dist/runtime/builtins/nodes/parallel.js.map +1 -0
  183. package/dist/runtime/builtins/nodes/retry.d.ts +1 -0
  184. package/dist/runtime/builtins/nodes/retry.js +46 -0
  185. package/dist/runtime/builtins/nodes/retry.js.map +1 -0
  186. package/dist/runtime/builtins/nodes/setVariable.d.ts +1 -0
  187. package/dist/runtime/builtins/nodes/setVariable.js +31 -0
  188. package/dist/runtime/builtins/nodes/setVariable.js.map +1 -0
  189. package/dist/runtime/builtins/nodes/switch.d.ts +1 -0
  190. package/dist/runtime/builtins/nodes/switch.js +33 -0
  191. package/dist/runtime/builtins/nodes/switch.js.map +1 -0
  192. package/dist/runtime/builtins/nodes/trigger.d.ts +1 -0
  193. package/dist/runtime/builtins/nodes/trigger.js +25 -0
  194. package/dist/runtime/builtins/nodes/trigger.js.map +1 -0
  195. package/dist/runtime/builtins/nodes/tryCatch.d.ts +1 -0
  196. package/dist/runtime/builtins/nodes/tryCatch.js +35 -0
  197. package/dist/runtime/builtins/nodes/tryCatch.js.map +1 -0
  198. package/dist/runtime/builtins/triggers/cron.d.ts +9 -0
  199. package/dist/runtime/builtins/triggers/cron.js +52 -0
  200. package/dist/runtime/builtins/triggers/cron.js.map +1 -0
  201. package/dist/runtime/builtins/triggers/index.d.ts +2 -0
  202. package/dist/runtime/builtins/triggers/index.js +12 -0
  203. package/dist/runtime/builtins/triggers/index.js.map +1 -0
  204. package/dist/runtime/builtins/triggers/manual.d.ts +3 -0
  205. package/dist/runtime/builtins/triggers/manual.js +20 -0
  206. package/dist/runtime/builtins/triggers/manual.js.map +1 -0
  207. package/dist/runtime/builtins/triggers/webhook.d.ts +14 -0
  208. package/dist/runtime/builtins/triggers/webhook.js +90 -0
  209. package/dist/runtime/builtins/triggers/webhook.js.map +1 -0
  210. package/dist/runtime/executionResult.d.ts +6 -0
  211. package/dist/runtime/executionResult.js +3 -0
  212. package/dist/runtime/executionResult.js.map +1 -0
  213. package/dist/runtime/executor.d.ts +9 -0
  214. package/dist/runtime/executor.js +300 -0
  215. package/dist/runtime/executor.js.map +1 -0
  216. package/dist/runtime/flatten.d.ts +3 -0
  217. package/dist/runtime/flatten.js +188 -0
  218. package/dist/runtime/flatten.js.map +1 -0
  219. package/dist/runtime/nodeKinds.d.ts +64 -0
  220. package/dist/runtime/nodeKinds.js +43 -0
  221. package/dist/runtime/nodeKinds.js.map +1 -0
  222. package/dist/runtime/reconcileDiff.d.ts +9 -0
  223. package/dist/runtime/reconcileDiff.js +26 -0
  224. package/dist/runtime/reconcileDiff.js.map +1 -0
  225. package/dist/runtime/registry.d.ts +19 -0
  226. package/dist/runtime/registry.js +47 -0
  227. package/dist/runtime/registry.js.map +1 -0
  228. package/dist/runtime/resolveInputs.d.ts +14 -0
  229. package/dist/runtime/resolveInputs.js +64 -0
  230. package/dist/runtime/resolveInputs.js.map +1 -0
  231. package/dist/runtime/resolveSubgraph.d.ts +7 -0
  232. package/dist/runtime/resolveSubgraph.js +15 -0
  233. package/dist/runtime/resolveSubgraph.js.map +1 -0
  234. package/dist/runtime/subscriptions.d.ts +16 -0
  235. package/dist/runtime/subscriptions.js +419 -0
  236. package/dist/runtime/subscriptions.js.map +1 -0
  237. package/dist/runtime/subwalk.d.ts +17 -0
  238. package/dist/runtime/subwalk.js +74 -0
  239. package/dist/runtime/subwalk.js.map +1 -0
  240. package/dist/runtime/topo.d.ts +3 -0
  241. package/dist/runtime/topo.js +75 -0
  242. package/dist/runtime/topo.js.map +1 -0
  243. package/dist/runtime/typeOrigin.d.ts +7 -0
  244. package/dist/runtime/typeOrigin.js +24 -0
  245. package/dist/runtime/typeOrigin.js.map +1 -0
  246. package/dist/runtime/validate.d.ts +10 -0
  247. package/dist/runtime/validate.js +185 -0
  248. package/dist/runtime/validate.js.map +1 -0
  249. package/dist/runtime/validateTemplate.d.ts +3 -0
  250. package/dist/runtime/validateTemplate.js +54 -0
  251. package/dist/runtime/validateTemplate.js.map +1 -0
  252. package/dist/types/constants.d.ts +6 -0
  253. package/dist/types/constants.js +10 -0
  254. package/dist/types/constants.js.map +1 -0
  255. package/dist/types/graph.d.ts +51 -0
  256. package/dist/types/graph.js +23 -0
  257. package/dist/types/graph.js.map +1 -0
  258. package/dist/types/pagination.d.ts +8 -0
  259. package/dist/types/pagination.js +3 -0
  260. package/dist/types/pagination.js.map +1 -0
  261. package/dist/types/runLog.d.ts +26 -0
  262. package/dist/types/runLog.js +3 -0
  263. package/dist/types/runLog.js.map +1 -0
  264. package/frontend-vue/.prettierignore +4 -0
  265. package/frontend-vue/app/components/Actions.vue +141 -0
  266. package/frontend-vue/app/components/Catalog/TypeConfigForm.vue +166 -0
  267. package/frontend-vue/app/components/Catalog/TypeList.vue +198 -0
  268. package/frontend-vue/app/components/DataNodes.vue +259 -0
  269. package/frontend-vue/app/components/Editor/BuilderPalette.vue +234 -0
  270. package/frontend-vue/app/components/Editor/GraphCanvas.vue +994 -0
  271. package/frontend-vue/app/components/Editor/GroupPortEditor.vue +289 -0
  272. package/frontend-vue/app/components/Editor/JsonField.vue +63 -0
  273. package/frontend-vue/app/components/Editor/NodeInspector.vue +356 -0
  274. package/frontend-vue/app/components/Editor/ProcedureList.vue +156 -0
  275. package/frontend-vue/app/components/Editor/RunsDrawer.vue +312 -0
  276. package/frontend-vue/app/components/Editor/WiredField.vue +42 -0
  277. package/frontend-vue/app/components/Editor/nodes/GenericNode.vue +161 -0
  278. package/frontend-vue/app/components/Editor/nodes/GroupInputNode.vue +19 -0
  279. package/frontend-vue/app/components/Editor/nodes/GroupNode.vue +200 -0
  280. package/frontend-vue/app/components/Editor/nodes/GroupOutputNode.vue +19 -0
  281. package/frontend-vue/app/components/Editor/nodes/GroupSentinel.vue +161 -0
  282. package/frontend-vue/app/components/Editor/nodes/styles.ts +53 -0
  283. package/frontend-vue/app/components/Editor.vue +2504 -0
  284. package/frontend-vue/app/components/Library.vue +67 -0
  285. package/frontend-vue/app/components/Overview.vue +503 -0
  286. package/frontend-vue/app/components/RunDetailDrawer.vue +165 -0
  287. package/frontend-vue/app/components/RunFireTree.vue +170 -0
  288. package/frontend-vue/app/components/RunTraceDrawer.vue +59 -0
  289. package/frontend-vue/app/components/RunsStats.vue +126 -0
  290. package/frontend-vue/app/components/RunsTimelineDisplay.vue +287 -0
  291. package/frontend-vue/app/components/Templates.vue +663 -0
  292. package/frontend-vue/app/components/Triggers.vue +137 -0
  293. package/frontend-vue/app/composables/useAutomationNodeKinds.ts +48 -0
  294. package/frontend-vue/app/composables/useAutomationRuns.ts +75 -0
  295. package/frontend-vue/app/composables/useGraphConnect.ts +542 -0
  296. package/frontend-vue/app/plugins/runs-timeline-display.client.ts +16 -0
  297. package/frontend-vue/app/utils/automation.ts +51 -0
  298. package/frontend-vue/dms.frontend.ts +26 -0
  299. package/frontend-vue/eslint.config.mjs +24 -0
  300. package/frontend-vue/i18n/locales/dms-automation-en-GB.json +369 -0
  301. package/frontend-vue/i18n/locales/dms-automation-fr-FR.json +369 -0
  302. package/frontend-vue/package.json +33 -0
  303. package/frontend-vue/pnpm-lock.yaml +6483 -0
  304. package/frontend-vue/pnpm-workspace.yaml +2 -0
  305. package/package.json +81 -0
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutomationTemplateModel = void 0;
4
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
5
+ const constants_1 = require("../../types/constants");
6
+ const graph_1 = require("../../types/graph");
7
+ const automation_template_table_1 = require("../tables/automation_template.table");
8
+ const procedure_model_1 = require("./procedure.model");
9
+ function parseRow(row) {
10
+ let ports = [];
11
+ let subgraph = {
12
+ nodes: [],
13
+ triggerEdges: [],
14
+ dataEdges: [],
15
+ };
16
+ try {
17
+ ports = row.ports ? JSON.parse(row.ports) : [];
18
+ }
19
+ catch {
20
+ ports = [];
21
+ }
22
+ try {
23
+ subgraph = row.subgraph
24
+ ? JSON.parse(row.subgraph)
25
+ : { nodes: [], triggerEdges: [], dataEdges: [] };
26
+ }
27
+ catch {
28
+ subgraph = { nodes: [], triggerEdges: [], dataEdges: [] };
29
+ }
30
+ return {
31
+ _id: row._id,
32
+ name: row.name,
33
+ description: row.description ?? "",
34
+ icon: row.icon ?? "",
35
+ ports,
36
+ subgraph,
37
+ created_at: row.created_at,
38
+ updated_at: row.updated_at,
39
+ };
40
+ }
41
+ class AutomationTemplateModel extends (0, interface_database_decorators_1.BasicDataModel)(automation_template_table_1.AutomationTemplate, automation_template_table_1.automationTemplatesTableName) {
42
+ async list(options) {
43
+ const totalReq = this.table.count();
44
+ const finalReq = this.table
45
+ .orderBy("updated_at", "desc")
46
+ .slice(options.page * options.limit, options.limit);
47
+ const [total, rows] = await Promise.all([totalReq.run(), finalReq.run()]);
48
+ return {
49
+ results: rows.map(parseRow),
50
+ total,
51
+ page: options.page,
52
+ limit: options.limit,
53
+ };
54
+ }
55
+ async getById(id) {
56
+ const row = await this.get(id);
57
+ if (!row)
58
+ return undefined;
59
+ return parseRow(row);
60
+ }
61
+ async create(input) {
62
+ const now = new Date();
63
+ const ids = await this.insert({
64
+ name: input.name,
65
+ description: input.description ?? "",
66
+ icon: input.icon ?? "",
67
+ ports: JSON.stringify(input.ports),
68
+ subgraph: JSON.stringify(input.subgraph),
69
+ created_at: now,
70
+ updated_at: now,
71
+ });
72
+ const id = ids[0];
73
+ if (!id) {
74
+ throw new Error("automation_template insert returned no id");
75
+ }
76
+ const created = await this.get(id);
77
+ if (!created) {
78
+ throw new Error(`automation_template ${id} not found after insert`);
79
+ }
80
+ return parseRow(created);
81
+ }
82
+ async updateById(id, patch) {
83
+ const updateObj = {
84
+ updated_at: new Date(),
85
+ };
86
+ if (patch.name !== undefined)
87
+ updateObj.name = patch.name;
88
+ if (patch.description !== undefined)
89
+ updateObj.description = patch.description;
90
+ if (patch.icon !== undefined)
91
+ updateObj.icon = patch.icon;
92
+ if (patch.ports !== undefined)
93
+ updateObj.ports = JSON.stringify(patch.ports);
94
+ if (patch.subgraph !== undefined)
95
+ updateObj.subgraph = JSON.stringify(patch.subgraph);
96
+ await this.update(id, updateObj);
97
+ const updated = await this.get(id);
98
+ if (!updated) {
99
+ throw new Error(`automation_template ${id} not found after update`);
100
+ }
101
+ return parseRow(updated);
102
+ }
103
+ async deleteById(id) {
104
+ await this.delete(id);
105
+ }
106
+ async findUsages(templateId) {
107
+ const procedureModel = (0, interface_database_decorators_1.GetModel)(procedure_model_1.ProcedureModel, constants_1.DATABASE_NAME);
108
+ const procs = await procedureModel.list({
109
+ page: 0,
110
+ limit: constants_1.FETCH_ALL_LIMIT,
111
+ });
112
+ const out = [];
113
+ for (const p of procs.results) {
114
+ let graph;
115
+ try {
116
+ graph = JSON.parse(p.graph);
117
+ }
118
+ catch {
119
+ continue;
120
+ }
121
+ for (const node of (0, graph_1.walkNodesRecursive)(graph)) {
122
+ if (node.kind !== "group")
123
+ continue;
124
+ const groupNode = node;
125
+ if (groupNode.templateId === templateId) {
126
+ out.push({ procedureId: p._id, nodeId: node.id });
127
+ }
128
+ }
129
+ }
130
+ return out;
131
+ }
132
+ }
133
+ exports.AutomationTemplateModel = AutomationTemplateModel;
134
+ //# sourceMappingURL=automation_template.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation_template.model.js","sourceRoot":"","sources":["../../../src/db/models/automation_template.model.ts"],"names":[],"mappings":";;;AAAA,6FAGmD;AACnD,qDAAuE;AACvE,6CAK2B;AAE3B,mFAG6C;AAC7C,uDAAmD;AAyCnD,SAAS,QAAQ,CAAC,GAAuB;IACvC,IAAI,KAAK,GAAgB,EAAE,CAAC;IAC5B,IAAI,QAAQ,GAAmB;QAC7B,KAAK,EAAE,EAAE;QACT,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,EAAE;KACd,CAAC;IACF,IAAI,CAAC;QACH,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,GAAG,EAAE,CAAC;IACb,CAAC;IACD,IAAI,CAAC;QACH,QAAQ,GAAG,GAAG,CAAC,QAAQ;YACrB,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAoB;YAC9C,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;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AI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAmB,CAAC;YAChD,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;YACD,KAAK,MAAM,IAAI,IAAI,IAAA,0BAAkB,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC7C,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO;oBAAE,SAAS;gBACpC,MAAM,SAAS,GAAG,IAA2C,CAAC;gBAC9D,IAAI,SAAS,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;oBACxC,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAzGD,0DAyGC"}
@@ -0,0 +1,3 @@
1
+ export * from "./procedure.model";
2
+ export * from "./procedure_run.model";
3
+ export * from "./type_config.model";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./procedure.model"), exports);
18
+ __exportStar(require("./procedure_run.model"), exports);
19
+ __exportStar(require("./type_config.model"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,wDAAsC;AACtC,sDAAoC"}
@@ -0,0 +1,25 @@
1
+ import type { PageParams, Paginated } from "../../types/pagination";
2
+ import { Procedure } from "../tables/procedure.table";
3
+ declare const ProcedureModel_base: {
4
+ new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
5
+ readonly table: import("@antelopejs/interface-database").Table<Procedure>;
6
+ readonly database: import("@antelopejs/interface-database").SchemaInstance<any>;
7
+ get(id: string): PromiseLike<Procedure | undefined>;
8
+ getBy(index: keyof Procedure, ...keys: any[]): PromiseLike<Procedure[]>;
9
+ getAll(): PromiseLike<Procedure[]>;
10
+ insert(obj: import("@antelopejs/interface-database-decorators").DeepPartial<Procedure> | import("@antelopejs/interface-database-decorators").DeepPartial<Procedure>[], options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<string[]>;
11
+ update(id: string, obj: import("@antelopejs/interface-database-decorators").DeepPartial<Procedure>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
12
+ update(obj: import("@antelopejs/interface-database-decorators").DeepPartial<Procedure>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
13
+ delete(id: string): Promise<number>;
14
+ };
15
+ readonly schemaName: string;
16
+ fromPlainData(obj: any): Procedure;
17
+ fromDatabase(obj: any): Procedure | undefined;
18
+ toDatabase(obj: any): Record<string, any>;
19
+ validate(obj: unknown, options?: import("@antelopejs/interface-database-decorators").ValidateInputOptions): import("@antelopejs/interface-database-decorators").ValidationResult;
20
+ };
21
+ export declare class ProcedureModel extends ProcedureModel_base {
22
+ listEnabled(): Promise<Procedure[]>;
23
+ list(options: PageParams): Promise<Paginated<Procedure>>;
24
+ }
25
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProcedureModel = void 0;
4
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
5
+ const procedure_table_1 = require("../tables/procedure.table");
6
+ class ProcedureModel extends (0, interface_database_decorators_1.BasicDataModel)(procedure_table_1.Procedure, procedure_table_1.proceduresTableName) {
7
+ async listEnabled() {
8
+ return await this.table.filter((doc) => doc.key("enabled").eq(true)).run();
9
+ }
10
+ async list(options) {
11
+ const totalReq = this.table.count();
12
+ const finalReq = this.table
13
+ .orderBy("updated_at", "desc")
14
+ .slice(options.page * options.limit, options.limit);
15
+ const [total, results] = await Promise.all([
16
+ totalReq.run(),
17
+ finalReq.run(),
18
+ ]);
19
+ return {
20
+ results,
21
+ total,
22
+ page: options.page,
23
+ limit: options.limit,
24
+ };
25
+ }
26
+ }
27
+ exports.ProcedureModel = ProcedureModel;
28
+ //# sourceMappingURL=procedure.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure.model.js","sourceRoot":"","sources":["../../../src/db/models/procedure.model.ts"],"names":[],"mappings":";;;AAAA,6FAA2E;AAE3E,+DAA2E;AAE3E,MAAa,cAAe,SAAQ,IAAA,8CAAc,EAChD,2BAAS,EACT,qCAAmB,CACpB;IACC,KAAK,CAAC,WAAW;QACf,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAmB;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK;aACxB,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;aAC7B,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAEtD,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACzC,QAAQ,CAAC,GAAG,EAAE;YACd,QAAQ,CAAC,GAAG,EAAE;SACf,CAAC,CAAC;QAEH,OAAO;YACL,OAAO;YACP,KAAK;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;IACJ,CAAC;CACF;AA1BD,wCA0BC"}
@@ -0,0 +1,34 @@
1
+ import { ProcedureRun } from "../tables/procedure_run.table";
2
+ export interface RunListQuery {
3
+ page: number;
4
+ limit: number;
5
+ procedureId?: string;
6
+ status?: string;
7
+ since?: Date;
8
+ peek?: boolean;
9
+ }
10
+ export type StatsRun = Pick<ProcedureRun, "_id" | "procedureId" | "startedAt" | "endedAt" | "status" | "errorMessage">;
11
+ declare const ProcedureRunModel_base: {
12
+ new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
13
+ readonly table: import("@antelopejs/interface-database").Table<ProcedureRun>;
14
+ readonly database: import("@antelopejs/interface-database").SchemaInstance<any>;
15
+ get(id: string): PromiseLike<ProcedureRun | undefined>;
16
+ getBy(index: keyof ProcedureRun, ...keys: any[]): PromiseLike<ProcedureRun[]>;
17
+ getAll(): PromiseLike<ProcedureRun[]>;
18
+ insert(obj: import("@antelopejs/interface-database-decorators").DeepPartial<ProcedureRun> | import("@antelopejs/interface-database-decorators").DeepPartial<ProcedureRun>[], options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<string[]>;
19
+ update(id: string, obj: import("@antelopejs/interface-database-decorators").DeepPartial<ProcedureRun>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
20
+ update(obj: import("@antelopejs/interface-database-decorators").DeepPartial<ProcedureRun>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
21
+ delete(id: string): Promise<number>;
22
+ };
23
+ readonly schemaName: string;
24
+ fromPlainData(obj: any): ProcedureRun;
25
+ fromDatabase(obj: any): ProcedureRun | undefined;
26
+ toDatabase(obj: any): Record<string, any>;
27
+ validate(obj: unknown, options?: import("@antelopejs/interface-database-decorators").ValidateInputOptions): import("@antelopejs/interface-database-decorators").ValidationResult;
28
+ };
29
+ export declare class ProcedureRunModel extends ProcedureRunModel_base {
30
+ listForStats(since: Date): Promise<StatsRun[]>;
31
+ listByProcedure(procedureId: string, page: number, limit: number, peek?: boolean): Promise<ProcedureRun[]>;
32
+ listAll({ page, limit, procedureId, status, since, peek, }: RunListQuery): Promise<ProcedureRun[]>;
33
+ }
34
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProcedureRunModel = void 0;
4
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
5
+ const procedure_run_table_1 = require("../tables/procedure_run.table");
6
+ class ProcedureRunModel extends (0, interface_database_decorators_1.BasicDataModel)(procedure_run_table_1.ProcedureRun, procedure_run_table_1.procedureRunsTableName) {
7
+ async listForStats(since) {
8
+ return this.table
9
+ .filter((row) => row.key("startedAt").ge(since))
10
+ .orderBy("startedAt", "desc")
11
+ .pluck("_id", "procedureId", "startedAt", "endedAt", "status", "errorMessage")
12
+ .run();
13
+ }
14
+ async listByProcedure(procedureId, page, limit, peek = false) {
15
+ return await this.table
16
+ .filter((doc) => doc.key("procedureId").eq(procedureId))
17
+ .orderBy("startedAt", "desc")
18
+ .slice(page * limit, peek ? limit + 1 : limit)
19
+ .run();
20
+ }
21
+ async listAll({ page, limit, procedureId, status, since, peek = false, }) {
22
+ let base = this.table;
23
+ if (procedureId) {
24
+ base = base.filter((doc) => doc.key("procedureId").eq(procedureId));
25
+ }
26
+ if (status) {
27
+ base = base.filter((doc) => doc.key("status").eq(status));
28
+ }
29
+ if (since) {
30
+ base = base.filter((doc) => doc.key("startedAt").ge(since));
31
+ }
32
+ return await base
33
+ .orderBy("startedAt", "desc")
34
+ .slice(page * limit, peek ? limit + 1 : limit)
35
+ .run();
36
+ }
37
+ }
38
+ exports.ProcedureRunModel = ProcedureRunModel;
39
+ //# sourceMappingURL=procedure_run.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure_run.model.js","sourceRoot":"","sources":["../../../src/db/models/procedure_run.model.ts"],"names":[],"mappings":";;;AAAA,6FAA2E;AAC3E,uEAGuC;AAsBvC,MAAa,iBAAkB,SAAQ,IAAA,8CAAc,EACnD,kCAAY,EACZ,4CAAsB,CACvB;IAEC,KAAK,CAAC,YAAY,CAAC,KAAW;QAC5B,OAAO,IAAI,CAAC,KAAK;aACd,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;aAC/C,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;aAC5B,KAAK,CACJ,KAAK,EACL,aAAa,EACb,WAAW,EACX,SAAS,EACT,QAAQ,EACR,cAAc,CACf;aACA,GAAG,EAAyB,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,WAAmB,EACnB,IAAY,EACZ,KAAa,EAIb,IAAI,GAAG,KAAK;QAEZ,OAAO,MAAM,IAAI,CAAC,KAAK;aACpB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;aACvD,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;aAC5B,KAAK,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;aAC7C,GAAG,EAAE,CAAC;IACX,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EACZ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,KAAK,EACL,IAAI,GAAG,KAAK,GACC;QACb,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACtB,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,MAAM,IAAI;aACd,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;aAC5B,KAAK,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;aAC7C,GAAG,EAAE,CAAC;IACX,CAAC;CACF;AA3DD,8CA2DC"}
@@ -0,0 +1,73 @@
1
+ interface HealthBucket {
2
+ total: number;
3
+ ok: number;
4
+ failed: number;
5
+ successRate: number;
6
+ avgDurationMs: number;
7
+ p95DurationMs: number;
8
+ }
9
+ export interface StatsSnapshot {
10
+ counts: {
11
+ procedures: {
12
+ total: number;
13
+ enabled: number;
14
+ disabled: number;
15
+ };
16
+ triggerTypes: number;
17
+ actionTypes: number;
18
+ dataNodeTypes: number;
19
+ templates: number;
20
+ };
21
+ health: {
22
+ "24h": HealthBucket;
23
+ "7d": HealthBucket;
24
+ };
25
+ runsPerDay7d: Array<{
26
+ day: string;
27
+ ok: number;
28
+ failed: number;
29
+ }>;
30
+ recentFailures: Array<{
31
+ runId: string;
32
+ procedureId: string;
33
+ procedureName: string;
34
+ startedAt: string;
35
+ errorMessage: string;
36
+ }>;
37
+ topProcedures7d: Array<{
38
+ procedureId: string;
39
+ name: string;
40
+ runs: number;
41
+ ok: number;
42
+ failed: number;
43
+ }>;
44
+ recentRuns: Array<{
45
+ runId: string;
46
+ procedureId: string;
47
+ procedureName: string;
48
+ status: string;
49
+ startedAt: string;
50
+ durationMs: number | null;
51
+ }>;
52
+ needsAttention: Array<{
53
+ procedureId: string;
54
+ name: string;
55
+ kind: "paused" | "failing";
56
+ failed: number;
57
+ lastRunAt: string | null;
58
+ }>;
59
+ }
60
+ export declare function getStatsSnapshot(now?: Date): Promise<StatsSnapshot>;
61
+ export interface ProcedureSummaryRow {
62
+ procedureId: string;
63
+ name: string;
64
+ enabled: boolean;
65
+ trigger: string | null;
66
+ status: "active" | "paused" | "failing";
67
+ lastRunAt: string | null;
68
+ successRate: number;
69
+ avgDurationMs: number;
70
+ runs: number;
71
+ }
72
+ export declare function getProceduresSummary(now?: Date): Promise<ProcedureSummaryRow[]>;
73
+ export {};
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStatsSnapshot = getStatsSnapshot;
4
+ exports.getProceduresSummary = getProceduresSummary;
5
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
6
+ const registry_1 = require("../../runtime/registry");
7
+ const constants_1 = require("../../types/constants");
8
+ const automation_template_model_1 = require("./automation_template.model");
9
+ const procedure_model_1 = require("./procedure.model");
10
+ const procedure_run_model_1 = require("./procedure_run.model");
11
+ const WINDOW_MS = {
12
+ "24h": constants_1.MS_PER_DAY,
13
+ "7d": 7 * constants_1.MS_PER_DAY,
14
+ };
15
+ function startOf(windowStr, now) {
16
+ const d = new Date(now);
17
+ d.setMilliseconds(0);
18
+ d.setTime(d.getTime() - WINDOW_MS[windowStr]);
19
+ return d;
20
+ }
21
+ function computeHealthBucket(runs, fromDate) {
22
+ const inWindow = runs.filter((r) => new Date(r.startedAt) >= fromDate);
23
+ const ok = inWindow.filter((r) => r.status === "ok").length;
24
+ const failed = inWindow.filter((r) => r.status === "failed").length;
25
+ const total = ok + failed;
26
+ const durations = inWindow
27
+ .filter((r) => r.endedAt)
28
+ .map((r) => new Date(r.endedAt).getTime() - new Date(r.startedAt).getTime());
29
+ const avgDurationMs = durations.length
30
+ ? Math.round(durations.reduce((a, b) => a + b, 0) / durations.length)
31
+ : 0;
32
+ let p95DurationMs = 0;
33
+ if (durations.length) {
34
+ const sorted = [...durations].sort((a, b) => a - b);
35
+ const idx = Math.min(sorted.length - 1, Math.ceil(0.95 * sorted.length) - 1);
36
+ p95DurationMs = Math.round(sorted[Math.max(0, idx)]);
37
+ }
38
+ return {
39
+ total,
40
+ ok,
41
+ failed,
42
+ successRate: total ? ok / total : 0,
43
+ avgDurationMs,
44
+ p95DurationMs,
45
+ };
46
+ }
47
+ function buildRunsPerDay(allRuns, now) {
48
+ const out = [];
49
+ for (let i = 6; i >= 0; i--) {
50
+ const dayStart = new Date(now);
51
+ dayStart.setHours(0, 0, 0, 0);
52
+ dayStart.setDate(dayStart.getDate() - i);
53
+ const dayEnd = new Date(dayStart);
54
+ dayEnd.setDate(dayEnd.getDate() + 1);
55
+ const dayRuns = allRuns.filter((r) => {
56
+ const t = new Date(r.startedAt);
57
+ return t >= dayStart && t < dayEnd;
58
+ });
59
+ out.push({
60
+ day: dayStart.toISOString().slice(0, 10),
61
+ ok: dayRuns.filter((r) => r.status === "ok").length,
62
+ failed: dayRuns.filter((r) => r.status === "failed").length,
63
+ });
64
+ }
65
+ return out;
66
+ }
67
+ function buildRecentFailures(allRuns, procById) {
68
+ return allRuns
69
+ .filter((r) => r.status === "failed")
70
+ .sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime())
71
+ .slice(0, 10)
72
+ .map((r) => ({
73
+ runId: r._id,
74
+ procedureId: r.procedureId,
75
+ procedureName: procById.get(r.procedureId)?.name ?? "(deleted)",
76
+ startedAt: new Date(r.startedAt).toISOString(),
77
+ errorMessage: r.errorMessage ?? "",
78
+ }));
79
+ }
80
+ function aggregateByProcedure(allRuns) {
81
+ const perProc = new Map();
82
+ for (const r of allRuns) {
83
+ const cur = perProc.get(r.procedureId) ?? { runs: 0, ok: 0, failed: 0 };
84
+ cur.runs++;
85
+ if (r.status === "ok")
86
+ cur.ok++;
87
+ else if (r.status === "failed")
88
+ cur.failed++;
89
+ perProc.set(r.procedureId, cur);
90
+ }
91
+ return perProc;
92
+ }
93
+ function buildTopProcedures(perProc, procById) {
94
+ return [...perProc.entries()]
95
+ .map(([procedureId, c]) => ({
96
+ procedureId,
97
+ name: procById.get(procedureId)?.name ?? "(deleted)",
98
+ ...c,
99
+ }))
100
+ .sort((a, b) => b.runs - a.runs)
101
+ .slice(0, 10);
102
+ }
103
+ function buildRecentRuns(allRuns, procById) {
104
+ return [...allRuns]
105
+ .sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime())
106
+ .slice(0, 8)
107
+ .map((r) => ({
108
+ runId: r._id,
109
+ procedureId: r.procedureId,
110
+ procedureName: procById.get(r.procedureId)?.name ?? "(deleted)",
111
+ status: r.status,
112
+ startedAt: new Date(r.startedAt).toISOString(),
113
+ durationMs: r.endedAt
114
+ ? new Date(r.endedAt).getTime() - new Date(r.startedAt).getTime()
115
+ : null,
116
+ }));
117
+ }
118
+ function lastRunByProcedure(allRuns) {
119
+ const lastRunByProc = new Map();
120
+ for (const r of allRuns) {
121
+ const iso = new Date(r.startedAt).toISOString();
122
+ const prev = lastRunByProc.get(r.procedureId);
123
+ if (!prev || iso > prev)
124
+ lastRunByProc.set(r.procedureId, iso);
125
+ }
126
+ return lastRunByProc;
127
+ }
128
+ function buildNeedsAttention(procedures, perProc, lastRunByProc, procById) {
129
+ const out = [];
130
+ const pausedIds = new Set();
131
+ for (const p of procedures) {
132
+ if (!p.enabled) {
133
+ out.push({
134
+ procedureId: p._id,
135
+ name: p.name,
136
+ kind: "paused",
137
+ failed: perProc.get(p._id)?.failed ?? 0,
138
+ lastRunAt: lastRunByProc.get(p._id) ?? null,
139
+ });
140
+ pausedIds.add(p._id);
141
+ }
142
+ }
143
+ for (const [procedureId, c] of perProc) {
144
+ if (c.failed > 0 && !pausedIds.has(procedureId)) {
145
+ out.push({
146
+ procedureId,
147
+ name: procById.get(procedureId)?.name ?? "(deleted)",
148
+ kind: "failing",
149
+ failed: c.failed,
150
+ lastRunAt: lastRunByProc.get(procedureId) ?? null,
151
+ });
152
+ }
153
+ }
154
+ out.sort((a, b) => {
155
+ if (a.kind !== b.kind)
156
+ return a.kind === "failing" ? -1 : 1;
157
+ return b.failed - a.failed;
158
+ });
159
+ return out;
160
+ }
161
+ function buildCounts(procedures, templatesCount) {
162
+ return {
163
+ procedures: {
164
+ total: procedures.length,
165
+ enabled: procedures.filter((p) => p.enabled).length,
166
+ disabled: procedures.filter((p) => !p.enabled).length,
167
+ },
168
+ triggerTypes: registry_1.registry.listTriggers().length,
169
+ actionTypes: registry_1.registry.listActions().length,
170
+ dataNodeTypes: registry_1.registry.listDataNodes().length,
171
+ templates: templatesCount,
172
+ };
173
+ }
174
+ async function getStatsSnapshot(now = new Date()) {
175
+ const procedureModel = (0, interface_database_decorators_1.GetModel)(procedure_model_1.ProcedureModel, constants_1.DATABASE_NAME);
176
+ const runModel = (0, interface_database_decorators_1.GetModel)(procedure_run_model_1.ProcedureRunModel, constants_1.DATABASE_NAME);
177
+ const procedures = await procedureModel.table
178
+ .orderBy("updated_at", "desc")
179
+ .run();
180
+ const procById = new Map(procedures.map((p) => [p._id, p]));
181
+ const since7 = startOf("7d", now);
182
+ const allRuns = await runModel.listForStats(since7);
183
+ const perProc = aggregateByProcedure(allRuns);
184
+ const lastRunByProc = lastRunByProcedure(allRuns);
185
+ const tplModel = (0, interface_database_decorators_1.GetModel)(automation_template_model_1.AutomationTemplateModel, constants_1.DATABASE_NAME);
186
+ const templatesCount = await tplModel.table.count().run();
187
+ return {
188
+ counts: buildCounts(procedures, templatesCount),
189
+ health: {
190
+ "24h": computeHealthBucket(allRuns, startOf("24h", now)),
191
+ "7d": computeHealthBucket(allRuns, since7),
192
+ },
193
+ runsPerDay7d: buildRunsPerDay(allRuns, now),
194
+ recentFailures: buildRecentFailures(allRuns, procById),
195
+ topProcedures7d: buildTopProcedures(perProc, procById),
196
+ recentRuns: buildRecentRuns(allRuns, procById),
197
+ needsAttention: buildNeedsAttention(procedures, perProc, lastRunByProc, procById),
198
+ };
199
+ }
200
+ function triggerTypeOf(graphStr) {
201
+ try {
202
+ const g = JSON.parse(graphStr);
203
+ const nodes = Array.isArray(g.nodes) ? g.nodes : [];
204
+ const trigger = nodes.find((n) => n.kind === "trigger");
205
+ return trigger?.typeId ?? null;
206
+ }
207
+ catch {
208
+ return null;
209
+ }
210
+ }
211
+ async function getProceduresSummary(now = new Date()) {
212
+ const procedureModel = (0, interface_database_decorators_1.GetModel)(procedure_model_1.ProcedureModel, constants_1.DATABASE_NAME);
213
+ const runModel = (0, interface_database_decorators_1.GetModel)(procedure_run_model_1.ProcedureRunModel, constants_1.DATABASE_NAME);
214
+ const procedures = await procedureModel.table
215
+ .orderBy("updated_at", "desc")
216
+ .run();
217
+ const since7 = startOf("7d", now);
218
+ const allRuns = await runModel.listForStats(since7);
219
+ const agg = new Map();
220
+ for (const r of allRuns) {
221
+ const a = agg.get(r.procedureId) ?? {
222
+ runs: 0,
223
+ ok: 0,
224
+ failed: 0,
225
+ durSum: 0,
226
+ durN: 0,
227
+ last: null,
228
+ };
229
+ a.runs++;
230
+ if (r.status === "ok")
231
+ a.ok++;
232
+ else if (r.status === "failed")
233
+ a.failed++;
234
+ if (r.endedAt) {
235
+ a.durSum +=
236
+ new Date(r.endedAt).getTime() - new Date(r.startedAt).getTime();
237
+ a.durN++;
238
+ }
239
+ const iso = new Date(r.startedAt).toISOString();
240
+ if (!a.last || iso > a.last)
241
+ a.last = iso;
242
+ agg.set(r.procedureId, a);
243
+ }
244
+ return procedures.map((p) => {
245
+ const a = agg.get(p._id);
246
+ const ok = a?.ok ?? 0;
247
+ const failed = a?.failed ?? 0;
248
+ const total = ok + failed;
249
+ const status = !p.enabled
250
+ ? "paused"
251
+ : failed > 0
252
+ ? "failing"
253
+ : "active";
254
+ return {
255
+ procedureId: p._id,
256
+ name: p.name,
257
+ enabled: p.enabled,
258
+ trigger: triggerTypeOf(p.graph),
259
+ status,
260
+ lastRunAt: a?.last ?? null,
261
+ successRate: total ? ok / total : 0,
262
+ avgDurationMs: a && a.durN ? Math.round(a.durSum / a.durN) : 0,
263
+ runs: a?.runs ?? 0,
264
+ };
265
+ });
266
+ }
267
+ //# sourceMappingURL=stats.model.js.map