@antelopejs/dms-automation 0.3.1 → 0.4.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.
- package/README.md +58 -112
- package/dist/db/models/automation_template.model.d.ts +1 -0
- package/dist/db/models/procedure.model.d.ts +1 -0
- package/dist/db/models/procedure_run.model.d.ts +1 -0
- package/dist/db/models/type_switch.model.d.ts +1 -0
- package/dist/runtime/typeOrigin.js +1 -1
- package/dist/runtime/typeOrigin.js.map +1 -1
- package/frontend-vue/app/components/AttentionList.vue +2 -1
- package/frontend-vue/app/components/Catalog.vue +34 -27
- package/frontend-vue/app/components/Editor/RunNowDialog.vue +29 -20
- package/frontend-vue/app/components/Editor.vue +200 -193
- package/frontend-vue/app/components/Run/RunLogList.vue +7 -20
- package/frontend-vue/app/components/RunPeek.vue +7 -19
- package/frontend-vue/app/components/RunTrace.vue +18 -29
- package/frontend-vue/app/components/Templates.vue +46 -71
- package/frontend-vue/app/components/WebhookEndpoint.vue +14 -24
- package/frontend-vue/app/composables/useAutomationNodeKinds.ts +6 -7
- package/frontend-vue/app/composables/useAutomationRuns.ts +29 -4
- package/frontend-vue/package.json +4 -2
- package/frontend-vue/pnpm-lock.yaml +2880 -2717
- package/package.json +31 -15
- package/skills/dms-automation/SKILL.md +30 -0
package/README.md
CHANGED
|
@@ -1,139 +1,85 @@
|
|
|
1
|
-
# @antelopejs/dms-automation
|
|
2
|
-
|
|
3
1
|
<div align="center">
|
|
4
|
-
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-blue?style=for-the-badge&labelColor=000000"></a>
|
|
5
|
-
<a href="https://discord.gg/sjK28QHrA7"><img src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000" alt="Discord"></a>
|
|
6
|
-
<a href="https://antelopejs.com"><img src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" alt="Documentation"></a>
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
AntelopeJS DMS module that provides a visual automation builder under `/modules/automation`. Author procedures as node graphs (triggers, actions, data nodes), wire trigger and data edges, and run them in response to events such as cron schedules and webhooks.
|
|
10
|
-
|
|
11
|
-
It runs on `@antelopejs/dms` 0.7.21 (`@antelopejs/interface-dms` 0.5.13) and `@antelopejs/dms-frontend` 0.5.
|
|
12
|
-
|
|
13
|
-
## Pages
|
|
14
|
-
|
|
15
|
-
| Page | What it shows |
|
|
16
|
-
| --- | --- |
|
|
17
|
-
| Overview | The health of every procedure in one line, KPIs over 24 h / 7 d / 30 d, what needs attention and why, the latest runs |
|
|
18
|
-
| Run history | Every run grouped by day, with KPIs; one click opens a run in the side panel (failure, path taken, payload, log; J / K to step), re-runs with its own payload |
|
|
19
|
-
| Run trace | One run, linkable (`/modules/automation/trace?run=<id>`): its steps on a time line, where and why it failed, compared with the last success |
|
|
20
|
-
| Procedures | Every procedure with its state (failing, degraded, healthy, paused, draft), its last 12 runs, success rate and duration; import and new-procedure dialogs |
|
|
21
|
-
| Builder | The graph editor: test runs of the draft overlaid on the canvas, problems mapped onto nodes, Run now with an editable payload |
|
|
22
|
-
| Library | Triggers, actions, data nodes and templates, each with where it is used |
|
|
23
|
-
|
|
24
|
-
The pages are DMS blocks (KPI and chart cards, period selector, activity feed, table views with the grouped display and module cell displays) around a few module components, each named for the roles screen with `meta()`. Module pages are the platform owner's, like every DMS module, and so is the module's API.
|
|
25
|
-
|
|
26
|
-
A procedure is **failing** when its last run failed, **degraded** when runs failed in the last 7 days but the last one succeeded, **healthy** otherwise; a disabled one is **paused**, and one that has no trigger, or was never enabled nor run, is a **draft**. Test runs from the builder are kept (they have a trace) but never count in these states or in any figure. A procedure whose trigger cannot be armed (an invalid schedule, a webhook path already taken) is **failing**, with the reason under its state.
|
|
27
|
-
|
|
28
|
-
Webhooks are served by the API server, under the path set on the trigger. A path cannot overlap a route the server already serves, nor start with `/api`, `/auth`, `/dms`, `/modules` or `/settings`, and two enabled procedures cannot share the same method and path. A run keeps the request it received, with credentials replaced by `[redacted]` (see `runs.sensitiveNames`): a re-run therefore sends `[redacted]` in their place, and its confirmation says so. The library and the builder show each webhook's full URL on the DMS `apiBaseUrl`.
|
|
29
2
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| Key | Default | |
|
|
33
|
-
| --- | --- | --- |
|
|
34
|
-
| `runs.retentionDays` | `30` | Days a run is kept; older runs are deleted every hour by the leader instance. `0` keeps every run. |
|
|
35
|
-
| `runs.sensitiveNames` | `[]` | More header and query parameter names whose value is a credential, matched case-insensitively as part of the name. They are added to the built-in list (`Authorization`, `Cookie`, `*token*`, `*secret*`, `*signature*`, `*hmac*`, `*-key`…). A run stores, shows and replays these values as `[redacted]`. |
|
|
36
|
-
| `httpRequest.blockPrivateNetwork` | `false` | Refuse HTTP requests to this server's network. See [HTTP request: private network](#http-request-private-network). |
|
|
37
|
-
| `cluster.driver` | `auto` | See [Clustering](#clustering). |
|
|
3
|
+
# @antelopejs/dms-automation
|
|
38
4
|
|
|
39
|
-
|
|
5
|
+
<a href="https://www.npmjs.com/package/@antelopejs/dms-automation"><img alt="npm" src="https://img.shields.io/npm/v/@antelopejs/dms-automation?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
6
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/dms-automation?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
7
|
+
<a href="https://discord.gg/sjK28QHrA7"><img alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000"></a>
|
|
8
|
+
<a href="https://dms.antelopejs.com/docs/modules/automation"><img alt="Documentation" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000"></a>
|
|
40
9
|
|
|
41
|
-
The
|
|
10
|
+
The visual automation builder of the AntelopeJS DMS.
|
|
42
11
|
|
|
43
|
-
|
|
44
|
-
"dms-automation": {
|
|
45
|
-
config: {
|
|
46
|
-
httpRequest: { blockPrivateNetwork: true },
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
```
|
|
12
|
+
</div>
|
|
50
13
|
|
|
51
|
-
The
|
|
14
|
+

|
|
52
15
|
|
|
53
|
-
|
|
16
|
+
## What it does
|
|
54
17
|
|
|
55
|
-
|
|
18
|
+
- Builds procedures as node graphs: triggers start a run, actions do the work, flow and data nodes branch, loop and shape values.
|
|
19
|
+
- Starts procedures from schedules, webhooks, manual runs or DMS events such as a user registering or a record being created.
|
|
20
|
+
- Keeps every run with its trace, shows where and why it failed, and re-runs it with its own payload.
|
|
21
|
+
- Shows the health of every procedure, with KPIs over 24 hours, 7 days or 30 days.
|
|
22
|
+
- Lets any module add its own nodes through [`@antelopejs/interface-dms-automation`](https://github.com/AntelopeJS/dms-automation/tree/main/packages/interface-dms-automation).
|
|
56
23
|
|
|
57
|
-
|
|
24
|
+
## Install
|
|
58
25
|
|
|
59
|
-
|
|
26
|
+
Run the AntelopeJS CLI from the root of a project that already loads `@antelopejs/dms`:
|
|
60
27
|
|
|
61
28
|
```bash
|
|
62
|
-
|
|
63
|
-
pnpm --dir frontend-vue typecheck
|
|
29
|
+
ajs project modules add @antelopejs/dms-automation
|
|
64
30
|
```
|
|
65
31
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
## Interface
|
|
69
|
-
|
|
70
|
-
The public contract lives in a dedicated interface package,
|
|
71
|
-
[`@antelopejs/interface-dms-automation`](https://github.com/AntelopeJS/dms-automation/tree/main/packages/interface-dms-automation),
|
|
72
|
-
which this module `implements`. Any DMS module can declare its own automation nodes
|
|
73
|
-
(triggers, actions, data nodes) by depending on the interface package only — never on
|
|
74
|
-
this implementation module. Add it to `optionalDependencies` and call
|
|
75
|
-
`RegisterTriggerType` / `RegisterActionType` / `RegisterDataNodeType`; when
|
|
76
|
-
dms-automation is absent from the project the registrations are inert no-ops. See the
|
|
77
|
-
interface package README for the full guide and examples.
|
|
78
|
-
|
|
79
|
-
The builder's block palette groups each category by the module that registered its
|
|
80
|
-
entries: the built-ins shipped with dms-automation come first, unlabeled, followed by
|
|
81
|
-
one section per external module, labelled with the module's id as named in the
|
|
82
|
-
project's `antelope.config.ts`.
|
|
83
|
-
|
|
84
|
-
The interface package is released before dms-automation because the latter depends on
|
|
85
|
-
it. Both are published to npmjs from their own manually dispatched GitHub workflow:
|
|
86
|
-
run `Release DMS automation interface` first, then `Release DMS automation module`,
|
|
87
|
-
which refuses to run until the interface version its dependency range is floored at is
|
|
88
|
-
resolvable on npmjs. Inside the workspace that same range resolves to the sibling
|
|
89
|
-
package, through `link-workspace-packages`. Existing consumers of the old standalone interface must
|
|
90
|
-
move to `@antelopejs/interface-dms-automation` and update their `implements` or
|
|
91
|
-
optional-dependency wiring; no compatibility alias is provided.
|
|
32
|
+
## Quick start
|
|
92
33
|
|
|
93
|
-
|
|
34
|
+
The module works without configuration. Restart the backend, then the frontend, and open **Modules → Automation**. The Overview offers three recipes to start from: **Forward a webhook**, **Send a scheduled digest** and **Run it on demand**.
|
|
94
35
|
|
|
95
|
-
|
|
36
|
+
To add a node from your own module, depend on the interface and register it in `start()`:
|
|
96
37
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
38
|
+
```ts
|
|
39
|
+
import { RegisterActionType } from "@antelopejs/interface-dms-automation";
|
|
40
|
+
|
|
41
|
+
RegisterActionType({
|
|
42
|
+
id: "bakery.restock-order",
|
|
43
|
+
name: "Place restock order",
|
|
44
|
+
description: "Order an ingredient restock from a supplier",
|
|
45
|
+
icon: "i-lucide-shopping-cart",
|
|
46
|
+
inputSchema: { type: "object", properties: { ingredient: { type: "string" } } },
|
|
47
|
+
outputSchema: { type: "object", properties: { ordered: { type: "boolean" } } },
|
|
48
|
+
async execute(input, ctx) {
|
|
49
|
+
ctx.log("info", "placing restock order", input);
|
|
50
|
+
return { ordered: true };
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
104
54
|
|
|
105
|
-
|
|
55
|
+
## Compatibility
|
|
106
56
|
|
|
107
|
-
|
|
57
|
+
| Package | Version |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `@antelopejs/dms` | `>=0.9.0 <1.0.0` |
|
|
60
|
+
| `@antelopejs/interface-dms` | `>=0.7.0 <1.0.0` |
|
|
61
|
+
| `@antelopejs/dms-frontend` (renderer) | `>=0.6.0 <0.7.0` |
|
|
62
|
+
| `@antelopejs/interface-dms-automation` | `>=0.2.0 <0.3.0` |
|
|
63
|
+
| API provider | `@antelopejs/api`, for webhooks |
|
|
64
|
+
| Database | an `@antelopejs/interface-database` implementation |
|
|
108
65
|
|
|
109
|
-
|
|
110
|
-
- **`replicated`** (e.g. webhook) — every instance activates it. The load balancer in front of the cluster already routes each incoming event to exactly one instance.
|
|
66
|
+
On DMS 0.8, use `@antelopejs/dms-automation` 0.3. Running several instances needs `@antelopejs/interface-redis`: see [Clustering](https://dms.antelopejs.com/docs/modules/automation/configuration#clustering).
|
|
111
67
|
|
|
112
|
-
|
|
68
|
+
## Documentation
|
|
113
69
|
|
|
114
|
-
|
|
70
|
+
- [Introduction](https://dms.antelopejs.com/docs/modules/automation/introduction)
|
|
71
|
+
- [Installation](https://dms.antelopejs.com/docs/modules/automation/installation)
|
|
72
|
+
- [Configuration](https://dms.antelopejs.com/docs/modules/automation/configuration)
|
|
73
|
+
- [Usage](https://dms.antelopejs.com/docs/modules/automation/usage/overview)
|
|
74
|
+
- [Extending](https://dms.antelopejs.com/docs/modules/automation/extending)
|
|
75
|
+
- [FAQ](https://dms.antelopejs.com/docs/modules/automation/faq)
|
|
115
76
|
|
|
116
|
-
|
|
117
|
-
normal operation but not transactionally exactly-once** across leadership
|
|
118
|
-
changes. If a singleton trigger must never run twice, make its downstream effect
|
|
119
|
-
idempotent.
|
|
77
|
+
The guide's sources live in [`packages/dms-automation/docs`](https://github.com/AntelopeJS/dms-automation/tree/main/packages/dms-automation/docs). The module ships the `dms-automation` Claude Code skill in [`packages/dms-automation/skills`](https://github.com/AntelopeJS/dms-automation/tree/main/packages/dms-automation/skills), declared under `antelopeJs.skills`.
|
|
120
78
|
|
|
121
|
-
|
|
122
|
-
- **Brief double-fire on handover.** When leadership moves, the new leader arms its singletons as soon as it acquires the lock, while the old leader only deactivates its copies on its next tick (≤ one tick interval) — or, for a stall/GC-pause longer than the lock TTL, after it notices it lost the lock. An occurrence landing in that overlap can fire on both. The window is bounded by the tick interval (and by the TTL for stalls), never unbounded.
|
|
123
|
-
- **No timeout on Redis itself.** Leader renewal and pub/sub ride the shared Redis client; a Redis server that accepts connections but stops responding (no command timeout configured) can stall a renew. The leader tolerates transient errors up to the TTL before stepping down, so this degrades to the missed-occurrence case rather than a hang.
|
|
124
|
-
- **Very slow promotion can self-evict.** When an instance wins the lock it activates its singletons before the renewal loop resumes; if that activation took longer than the lock TTL (≤30s) the lock could expire mid-promotion. Built-in trigger activation is sub-millisecond, so this only matters for a custom trigger whose `activate` blocks for tens of seconds — keep trigger `activate`/`deactivate` fast and non-blocking.
|
|
79
|
+
## Contributing
|
|
125
80
|
|
|
126
|
-
|
|
81
|
+
This package lives in the [`AntelopeJS/dms-automation`](https://github.com/AntelopeJS/dms-automation) pnpm workspace, next to `@antelopejs/interface-dms-automation`. Read [CONTRIBUTING.md](https://github.com/AntelopeJS/dms-automation/blob/main/CONTRIBUTING.md) and the [repository README](https://github.com/AntelopeJS/dms-automation#contributing) for the development commands.
|
|
127
82
|
|
|
128
|
-
|
|
129
|
-
product. Every identifier that carried the old name moved with it, and there is
|
|
130
|
-
no compatibility path: a deployment is recreated from scratch, not migrated.
|
|
83
|
+
## License
|
|
131
84
|
|
|
132
|
-
-
|
|
133
|
-
`dms_automation`. Existing collections are invisible to this version.
|
|
134
|
-
- Module config key `cmsAutomation` -> `dmsAutomation` in `antelope.config.ts`.
|
|
135
|
-
- Frontend i18n namespace `cms-automation-<locale>` -> `dms-automation-<locale>`;
|
|
136
|
-
a host overriding those keys has to rename its own entries.
|
|
137
|
-
- The contract lives in `@antelopejs/interface-dms-automation`, which this
|
|
138
|
-
module `implements`. Import it from there, never from the runtime package,
|
|
139
|
-
and note that `TriggerType` requires a `cluster` field.
|
|
85
|
+
[Apache-2.0](./LICENSE)
|
|
@@ -55,6 +55,7 @@ declare const AutomationTemplateModel_base: {
|
|
|
55
55
|
delete(id: string): Promise<number>;
|
|
56
56
|
};
|
|
57
57
|
readonly schemaName: string;
|
|
58
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<AutomationTemplate>;
|
|
58
59
|
fromPlainData(obj: any): AutomationTemplate;
|
|
59
60
|
fromDatabase(obj: any): AutomationTemplate | undefined;
|
|
60
61
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -13,6 +13,7 @@ declare const ProcedureModel_base: {
|
|
|
13
13
|
delete(id: string): Promise<number>;
|
|
14
14
|
};
|
|
15
15
|
readonly schemaName: string;
|
|
16
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<Procedure>;
|
|
16
17
|
fromPlainData(obj: any): Procedure;
|
|
17
18
|
fromDatabase(obj: any): Procedure | undefined;
|
|
18
19
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -21,6 +21,7 @@ declare const ProcedureRunModel_base: {
|
|
|
21
21
|
delete(id: string): Promise<number>;
|
|
22
22
|
};
|
|
23
23
|
readonly schemaName: string;
|
|
24
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<ProcedureRun>;
|
|
24
25
|
fromPlainData(obj: any): ProcedureRun;
|
|
25
26
|
fromDatabase(obj: any): ProcedureRun | undefined;
|
|
26
27
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -12,6 +12,7 @@ declare const TypeSwitchModel_base: {
|
|
|
12
12
|
delete(id: string): Promise<number>;
|
|
13
13
|
};
|
|
14
14
|
readonly schemaName: string;
|
|
15
|
+
readonly tableClass: import("@antelopejs/interface-database-decorators").Constructible<TypeSwitch>;
|
|
15
16
|
fromPlainData(obj: any): TypeSwitch;
|
|
16
17
|
fromDatabase(obj: any): TypeSwitch | undefined;
|
|
17
18
|
toDatabase(obj: any): Record<string, any>;
|
|
@@ -5,7 +5,7 @@ exports.isOriginAttributionWorking = isOriginAttributionWorking;
|
|
|
5
5
|
const interface_core_1 = require("@antelopejs/interface-core");
|
|
6
6
|
const interface_dms_automation_1 = require("@antelopejs/interface-dms-automation");
|
|
7
7
|
function registryEntry(proxy, id) {
|
|
8
|
-
return proxy.
|
|
8
|
+
return proxy.registered?.get(id);
|
|
9
9
|
}
|
|
10
10
|
const SELF_MODULE = (0, interface_core_1.GetResponsibleModule)();
|
|
11
11
|
function originOf(proxy, id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeOrigin.js","sourceRoot":"","sources":["../../src/runtime/typeOrigin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"typeOrigin.js","sourceRoot":"","sources":["../../src/runtime/typeOrigin.ts"],"names":[],"mappings":";;;AAuFA,gEAMC;AA7FD,+DAAkE;AAClE,mFAAgE;AAoChE,SAAS,aAAa,CACpB,KAAgB,EAChB,EAAU;IAMV,OAAQ,KAAkC,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AACjE,CAAC;AASD,MAAM,WAAW,GAAG,IAAA,qCAAoB,GAAE,CAAC;AAW3C,SAAS,QAAQ,CAAC,KAAgB,EAAE,EAAU;IAC5C,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;AAC1E,CAAC;AAEM,MAAM,iBAAiB,GAAG,CAAC,EAAU,EAAc,EAAE,CAC1D,QAAQ,CAAC,mCAAQ,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;AADhC,QAAA,iBAAiB,qBACe;AAEtC,MAAM,gBAAgB,GAAG,CAAC,EAAU,EAAc,EAAE,CACzD,QAAQ,CAAC,mCAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAD/B,QAAA,gBAAgB,oBACe;AAErC,MAAM,kBAAkB,GAAG,CAAC,EAAU,EAAc,EAAE,CAC3D,QAAQ,CAAC,mCAAQ,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AADjC,QAAA,kBAAkB,sBACe;AAS9C,SAAgB,0BAA0B,CAAC,gBAAwB;IACjE,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,CACL,aAAa,CAAC,mCAAQ,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,MAAM;QACrE,WAAW,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -121,7 +121,8 @@ async function act(row: AttentionRow, change: Change, undo: Change, message: str
|
|
|
121
121
|
busy.value = row.procedureId
|
|
122
122
|
try {
|
|
123
123
|
await $authFetch(change.url, { method: change.method, body: change.body })
|
|
124
|
-
|
|
124
|
+
// The row keeps its spinner until the page shows the change.
|
|
125
|
+
await refreshPageBlocks()
|
|
125
126
|
toast.add({
|
|
126
127
|
title: processI18n(message, { name: row.name }),
|
|
127
128
|
color: 'success',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, nextTick,
|
|
2
|
+
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue'
|
|
3
3
|
import type { NodeKindEntry, PortRef } from '../composables/useAutomationNodeKinds'
|
|
4
4
|
import type { JsonSchema } from '../composables/useGraphConnect'
|
|
5
5
|
|
|
@@ -84,11 +84,17 @@ const { confirm } = useConfirm()
|
|
|
84
84
|
const route = useDmsRoute()
|
|
85
85
|
const router = useDmsRouter()
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
87
|
+
// The catalog and where its entries are used, read with the page.
|
|
88
|
+
const listRead = useApiData<CatalogEntry[] | NodeKindEntry[]>(`${props.apiUrl}/${ENDPOINTS[props.kind]}`)
|
|
89
|
+
const usageRead = useApiData<Record<string, TypeUsage[]>>(`${props.apiUrl}/library/usage/${props.kind}`)
|
|
90
|
+
const usage = computed(() => usageRead.data.value ?? {})
|
|
91
|
+
const loading = computed(() => listRead.pending.value || usageRead.pending.value)
|
|
92
|
+
const error = computed(() => {
|
|
93
|
+
const failure = listRead.error.value ?? usageRead.error.value
|
|
94
|
+
return failure ? describeApiError(failure) : null
|
|
95
|
+
})
|
|
96
|
+
// The entry picked in this view, else the URL's (`?item=`).
|
|
97
|
+
const picked = ref<string | null>(null)
|
|
92
98
|
const query = ref('')
|
|
93
99
|
const saving = ref(false)
|
|
94
100
|
const showAllUses = ref(false)
|
|
@@ -126,26 +132,21 @@ function queryItem(): string | null {
|
|
|
126
132
|
return typeof q === 'string' && q ? q : null
|
|
127
133
|
}
|
|
128
134
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
entries.value = props.kind === 'flow' ? flowEntries(listed as NodeKindEntry[]) : (listed as CatalogEntry[])
|
|
137
|
-
usage.value = uses
|
|
138
|
-
error.value = null
|
|
139
|
-
const wanted = selectedId.value ?? queryItem()
|
|
140
|
-
selectedId.value = entries.value.some((e) => e.id === wanted) ? wanted : (groups.value[0]?.[1][0]?.id ?? null)
|
|
141
|
-
} catch (e) {
|
|
142
|
-
error.value = describeApiError(e)
|
|
143
|
-
} finally {
|
|
144
|
-
loading.value = false
|
|
145
|
-
}
|
|
135
|
+
const entries = computed<CatalogEntry[]>(() => {
|
|
136
|
+
const listed = listRead.data.value ?? []
|
|
137
|
+
return props.kind === 'flow' ? flowEntries(listed as NodeKindEntry[]) : (listed as CatalogEntry[])
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
function load() {
|
|
141
|
+
void Promise.all([listRead.refresh(), usageRead.refresh()])
|
|
146
142
|
}
|
|
147
143
|
|
|
148
|
-
|
|
144
|
+
/** Shows a write at once: the catalog's data is replaced, never changed in place. */
|
|
145
|
+
function replaceEntry(id: string, change: Partial<CatalogEntry>) {
|
|
146
|
+
const listed = listRead.data.value
|
|
147
|
+
if (!listed || props.kind === 'flow') return
|
|
148
|
+
listRead.data.value = (listed as CatalogEntry[]).map((entry) => (entry.id === id ? { ...entry, ...change } : entry))
|
|
149
|
+
}
|
|
149
150
|
|
|
150
151
|
/**
|
|
151
152
|
* The heading an entry is listed under: its module (built-in first), and for
|
|
@@ -183,11 +184,17 @@ const groups = computed(() => {
|
|
|
183
184
|
return [...map.entries()].sort(([a], [b]) => rank(a) - rank(b) || a.localeCompare(b))
|
|
184
185
|
})
|
|
185
186
|
|
|
187
|
+
/** The entry whose detail is shown: the one picked, else the first listed. */
|
|
188
|
+
const selectedId = computed<string | null>(() => {
|
|
189
|
+
const wanted = picked.value ?? queryItem()
|
|
190
|
+
return entries.value.some((e) => e.id === wanted) ? wanted : (groups.value[0]?.[1][0]?.id ?? null)
|
|
191
|
+
})
|
|
192
|
+
|
|
186
193
|
// A search hiding the picked entry moves the detail to the first one shown.
|
|
187
194
|
watch(groups, (shown) => {
|
|
188
195
|
if (loading.value || shown.length === 0) return
|
|
189
196
|
if (!shown.some(([, items]) => items.some((e) => e.id === selectedId.value))) {
|
|
190
|
-
|
|
197
|
+
picked.value = shown[0]![1][0]!.id
|
|
191
198
|
}
|
|
192
199
|
})
|
|
193
200
|
|
|
@@ -200,7 +207,7 @@ watch(selectedId, (id) => {
|
|
|
200
207
|
|
|
201
208
|
/** Below the two-column width the detail sits under the list: bring it into view. */
|
|
202
209
|
async function select(id: string) {
|
|
203
|
-
|
|
210
|
+
picked.value = id
|
|
204
211
|
await nextTick()
|
|
205
212
|
if (detail.value && list.value && detail.value.offsetTop > list.value.offsetTop) {
|
|
206
213
|
detail.value.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
@@ -240,7 +247,7 @@ async function setEnabled(enabled: boolean) {
|
|
|
240
247
|
method: 'PUT',
|
|
241
248
|
body: { enabled },
|
|
242
249
|
})
|
|
243
|
-
entry.
|
|
250
|
+
replaceEntry(entry.id, { enabled })
|
|
244
251
|
toast.add({
|
|
245
252
|
title: t(enabled ? 'dms_automation.library.enabledToast' : 'dms_automation.library.disabledToast', {
|
|
246
253
|
name: processI18n(entry.name),
|
|
@@ -23,7 +23,6 @@ const { t } = useI18n()
|
|
|
23
23
|
const triggerNodeId = ref<string | undefined>(undefined)
|
|
24
24
|
const payload = ref('{}')
|
|
25
25
|
const source = ref<string | null>(null)
|
|
26
|
-
const loadingPayload = ref(false)
|
|
27
26
|
const submitting = ref(false)
|
|
28
27
|
const PAYLOAD_ID = 'run-now-payload'
|
|
29
28
|
const ROW = { layout: 'stack', spacing: 'list', inset: false } as const
|
|
@@ -37,33 +36,43 @@ const triggerItems = computed(() =>
|
|
|
37
36
|
props.triggers.map((trigger) => ({ label: processText(trigger.text), value: trigger.nodeId ?? '' })),
|
|
38
37
|
)
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
const query = triggerNodeId.value ? `?triggerNodeId=${encodeURIComponent(triggerNodeId.value)}` : ''
|
|
44
|
-
const res = await $authFetch<{ last: { runId: string; payload: unknown } | null }>(
|
|
45
|
-
`${props.apiUrl}/procedures/${props.procedureId}/last-payload${query}`,
|
|
46
|
-
)
|
|
47
|
-
payload.value = JSON.stringify(res.last?.payload ?? {}, null, 2)
|
|
48
|
-
source.value = res.last?.runId ?? null
|
|
49
|
-
} catch {
|
|
50
|
-
payload.value = '{}'
|
|
51
|
-
source.value = null
|
|
52
|
-
} finally {
|
|
53
|
-
loadingPayload.value = false
|
|
54
|
-
}
|
|
39
|
+
interface LastPayload {
|
|
40
|
+
last: { runId: string; payload: unknown } | null
|
|
55
41
|
}
|
|
56
42
|
|
|
43
|
+
// The last real payload of the trigger picked, read once the dialog opens and
|
|
44
|
+
// again when another trigger is picked. Under a key of its own, apart from the
|
|
45
|
+
// builder dock's read of the same URL: each copies its answers into its own
|
|
46
|
+
// editable field. The page's refreshes leave the draft payload alone.
|
|
47
|
+
const lastPayloadRead = useApiData<LastPayload>(
|
|
48
|
+
() => `dms-automation-run-now-payload:${props.procedureId}:${triggerNodeId.value ?? ''}`,
|
|
49
|
+
({ $authFetch, signal }) =>
|
|
50
|
+
$authFetch<LastPayload>(`${props.apiUrl}/procedures/${props.procedureId}/last-payload`, {
|
|
51
|
+
query: triggerNodeId.value ? { triggerNodeId: triggerNodeId.value } : {},
|
|
52
|
+
signal,
|
|
53
|
+
}),
|
|
54
|
+
{ immediate: false, refreshOnPageRefresh: false },
|
|
55
|
+
)
|
|
56
|
+
const loadingPayload = computed(() => lastPayloadRead.pending.value)
|
|
57
|
+
|
|
58
|
+
// Each answer, or failure, fills the payload in.
|
|
59
|
+
watch(
|
|
60
|
+
() => lastPayloadRead.status.value,
|
|
61
|
+
(status) => {
|
|
62
|
+
if (status !== 'success' && status !== 'error') return
|
|
63
|
+
const last = status === 'error' ? null : (lastPayloadRead.data.value?.last ?? null)
|
|
64
|
+
payload.value = JSON.stringify(last?.payload ?? {}, null, 2)
|
|
65
|
+
source.value = last?.runId ?? null
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
|
|
57
69
|
watch(open, (isOpen) => {
|
|
58
70
|
if (!isOpen) return
|
|
59
71
|
fieldErrors.clear()
|
|
60
72
|
triggerNodeId.value = props.triggers.find((tr) => tr.typeId === 'manual')?.nodeId ?? props.triggers[0]?.nodeId
|
|
61
|
-
void
|
|
73
|
+
void lastPayloadRead.execute()
|
|
62
74
|
})
|
|
63
75
|
watch(payload, () => fieldErrors.clear('payload'))
|
|
64
|
-
watch(triggerNodeId, () => {
|
|
65
|
-
if (open.value) void loadPayload()
|
|
66
|
-
})
|
|
67
76
|
|
|
68
77
|
async function submit() {
|
|
69
78
|
let body: unknown
|