@overvis/hmi-workspace-ui 0.1.0 → 0.1.2
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/dist/alarm-list-DKFio0hg.js +414 -0
- package/dist/alarm-rule-dialog-mb4_nHRW.js +417 -0
- package/dist/{alarm-rule-lists-C5v1Kf7A.js → alarm-rule-lists-CfZXTWkK.js} +123 -125
- package/dist/{alarm-rules-page-CqFzofPd.js → alarm-rules-page-DBLSkrrG.js} +15 -18
- package/dist/alert-dialog-D_iDv2lQ.js +891 -0
- package/dist/{base-revision-YCO27zR4.js → base-revision-DLF9EnGV.js} +26 -29
- package/dist/{breadcrumbs-0cjsV2cq.js → breadcrumbs-D5R6Fz74.js} +6 -7
- package/dist/{catalog-list-DjZojYLJ.js → catalog-list-BkWosvh1.js} +2 -4
- package/dist/{code-editor-BVimvjDV.js → code-editor-DCM0KdMJ.js} +9 -6
- package/dist/dashboard-bindings.js +1 -2
- package/dist/{dashboards-page-BlrJguNz.js → dashboards-page-DLc11Vzu.js} +335 -359
- package/dist/{de-14WdmJxZ.js → de-Z2er-E5v.js} +4 -2
- package/dist/diagnostic-text-CYZFPiND.js +116 -0
- package/dist/{dialogs-D_v1LeH4.js → dialogs-BX023zml.js} +2523 -2590
- package/dist/{dialogs-B6BRnf3Q.js → dialogs-DEOg9lxy.js} +219 -227
- package/dist/{display-DmOo23mi.js → display-VYGzneE0.js} +4 -6
- package/dist/{editor-language-To9MxloY.js → editor-language-CGENZxbI.js} +3 -5
- package/dist/editor-page-CaN52OQh.js +1337 -0
- package/dist/{en-BgercpT0.js → en-CKPPL6bQ.js} +4 -2
- package/dist/entity-controls-DJT47yeV.js +71 -0
- package/dist/errors-BAWoH_5w.js +25 -0
- package/dist/{footer-DC-Q0052.js → footer-CbPMP8aq.js} +2404 -2515
- package/dist/host.js +8254 -675
- package/dist/{i18n-BgzakKoC.js → i18n-ChjEbYEg.js} +77 -90
- package/dist/i18n.js +1 -2
- package/dist/index.js +5168 -5353
- package/dist/{lat-lng-B12P7QyY.js → lat-lng-Bl77AGSO.js} +1 -2
- package/dist/{list-page-CvsdZb86.js → list-page-Fa29SkaJ.js} +116 -123
- package/dist/{location-map-renderer-DO5yfdSU.js → location-map-renderer-DvXIYc1Z.js} +6 -6
- package/dist/{location-picker-renderer-CjCxg6ai.js → location-picker-renderer-B1_-n8lf.js} +3 -4
- package/dist/{model-B8gGi4OK.js → model-tpg_xpFB.js} +1 -2
- package/dist/{notice-card-DyGywFsW.js → notice-card-V_0K0lO0.js} +54 -58
- package/dist/page-B5te_1Lc.js +449 -0
- package/dist/{page-v6LCwswN.js → page-BorlLnMX.js} +92 -100
- package/dist/page-DxF7FOve.js +507 -0
- package/dist/panel-DuZD-cBP.js +949 -0
- package/dist/parameter-values.js +3 -16
- package/dist/{pl-lQ9HXV9k.js → pl-DVABrn5G.js} +4 -2
- package/dist/presence-code-DsabLTZs.js +73 -0
- package/dist/{query-gate-DVhNIkge.js → query-gate-BbIo1Xrj.js} +6 -6
- package/dist/{provider-DoEpKcQ-.js → quick-report-BcZsfkCZ.js} +9423 -5102
- package/dist/{retention-BYXNpYmR.js → retention-C7EZsq8u.js} +4 -6
- package/dist/retention-note-CmMeHV_u.js +40 -0
- package/dist/{rolldown-runtime-Dy4uBu1J.js → rolldown-runtime-CGnMp29N.js} +1 -2
- package/dist/{ru-qTKINoUj.js → ru-CBRLC_xM.js} +8 -6
- package/dist/run-text-CDdfbKbg.js +112 -0
- package/dist/{search-D4rDnE9T.js → search-C6xQ_Hvo.js} +26 -29
- package/dist/{sections-kCOyc4NR.js → sections-D_SBfVzV.js} +2 -3
- package/dist/{select-BKiOWdSr.js → select-nNLG-AMz.js} +17 -23
- package/dist/{spinner-C-HPNxOc.js → spinner-B-KLtBjp.js} +182 -201
- package/dist/src/code-editor/code-editor.d.ts +3 -0
- package/dist/src/code-editor/taskfile-language.d.ts +22 -2
- package/dist/src/i18n/catalogs/de/edge-program.d.ts +3 -0
- package/dist/src/i18n/catalogs/de.d.ts +3 -0
- package/dist/src/i18n/catalogs/en/edge-program.d.ts +3 -0
- package/dist/src/i18n/catalogs/en.d.ts +3 -0
- package/dist/src/i18n/catalogs/pl/edge-program.d.ts +3 -0
- package/dist/src/i18n/catalogs/pl.d.ts +3 -0
- package/dist/src/i18n/catalogs/ru/edge-program.d.ts +5 -2
- package/dist/src/i18n/catalogs/ru/graphics.d.ts +2 -2
- package/dist/src/i18n/catalogs/ru.d.ts +7 -4
- package/dist/src/i18n/catalogs/uk/edge-program.d.ts +5 -2
- package/dist/src/i18n/catalogs/uk/graphics.d.ts +2 -2
- package/dist/src/i18n/catalogs/uk.d.ts +7 -4
- package/dist/src/version.d.ts +1 -1
- package/dist/src/workspace/graphics/inspector/item.d.ts +6 -6
- package/dist/src/workspace/local-workspace-app.d.ts +1 -1
- package/dist/src/workspace/routes.d.ts +1 -1
- package/dist/{starter-fields-BRLX0z-v.js → starter-fields-7S3LmtGa.js} +154 -157
- package/dist/{starter-handoff-BA3ucMKL.js → starter-handoff-BaK8Ss8I.js} +1 -2
- package/dist/styles.css +1 -1
- package/dist/ui.js +334 -374
- package/dist/{uk-CwpJAxmx.js → uk-17pbVYZa.js} +8 -6
- package/dist/{wireguard-docs-AfU6NzTL.js → wireguard-docs-Clb-7xRY.js} +14 -17
- package/package.json +15 -9
- package/dist/alarm-list-BL3xQ5Lf.js +0 -423
- package/dist/alarm-rule-dialog-S1ZUg-74.js +0 -423
- package/dist/alert-B8MAoIO8.js +0 -45
- package/dist/alert-dialog-CYkuMg5D.js +0 -129
- package/dist/api-error-9rQmUN5L.js +0 -93
- package/dist/breadcrumb-DzVL1yHa.js +0 -74
- package/dist/button-6SxPBYMz.js +0 -44
- package/dist/context-u9KJQmdB.js +0 -102
- package/dist/copyable-id-DYGiAcnq.js +0 -40
- package/dist/dashboard-context-CBfG6DoT.js +0 -191
- package/dist/date-time-picker-C3FhMXk6.js +0 -266
- package/dist/diagnostic-text-BAkzW0SE.js +0 -111
- package/dist/diagnostic-text-DiKd2i1w.js +0 -76
- package/dist/dialog-BIhQXcZC.js +0 -237
- package/dist/dialog-BqyIxMD-.js +0 -54
- package/dist/dropdown-menu-DSzbBq3v.js +0 -136
- package/dist/editor-page-BiSZJz5b.js +0 -1353
- package/dist/empty-B-QJ-06w.js +0 -59
- package/dist/entity-controls-D1K4Ot3O.js +0 -76
- package/dist/errors-CcsvDHu8.js +0 -26
- package/dist/history-page-sAAhG54V.js +0 -1400
- package/dist/icon-D-pR9htW.js +0 -57
- package/dist/index-page-DMH82fZe.js +0 -214
- package/dist/item-B5SaTFQU.js +0 -120
- package/dist/mutation-form-validators-BNz5bsv1.js +0 -2408
- package/dist/mutations-THtGG6Ai.js +0 -240
- package/dist/page-2KPemaAj.js +0 -328
- package/dist/page-6rIoTg2L.js +0 -459
- package/dist/page-C6giEoEd.js +0 -1935
- package/dist/page-DCbTxKsi.js +0 -313
- package/dist/page-DWO427hT.js +0 -208
- package/dist/page-LXu_2zm3.js +0 -137
- package/dist/page-aaUiVOnk.js +0 -513
- package/dist/page-header-RB2YFWlE.js +0 -55
- package/dist/page-title-CdCbiLt8.js +0 -14
- package/dist/panel-DDy8tUNR.js +0 -338
- package/dist/presence-code-BfSXr50g.js +0 -83
- package/dist/progress-C7cxNJA1.js +0 -83
- package/dist/provider-BOeYHi0n.js +0 -134
- package/dist/quick-report-CUVJnbKP.js +0 -416
- package/dist/radio-group-CZGqVbkJ.js +0 -26
- package/dist/retention-note-CHhA6gjY.js +0 -42
- package/dist/run-text-DvaO8LDF.js +0 -113
- package/dist/select-eNgZdZ30.js +0 -521
- package/dist/skeleton-6yk8Tdh5.js +0 -19
- package/dist/slider-DorDsoF8.js +0 -37
- package/dist/status-page-DAHiKM9P.js +0 -3286
- package/dist/switch-BqD0RH_G.js +0 -18
- package/dist/table-Q2-voLuw.js +0 -65
- package/dist/tabs-CSIucYFP.js +0 -57
- package/dist/theme-provider-BkRohQFU.js +0 -61
- package/dist/toggle-group-9Bs0Mm3r.js +0 -82
- package/dist/trpc-CvJUuUXp.js +0 -153
- package/dist/utils-CX-Pz5p6.js +0 -8
- package/dist/writability-BuH-spxv.js +0 -57
|
@@ -0,0 +1,1337 @@
|
|
|
1
|
+
import { Fr as e, Jr as t, Kn as n, Nt as r, Qn as i, Wn as a, ii as o, zn as s } from "./quick-report-BcZsfkCZ.js";
|
|
2
|
+
import { h as c, m as l, n as u } from "./i18n-ChjEbYEg.js";
|
|
3
|
+
import { $ as d, B as f, Nt as p, R as m, at as h, ct as g, jt as _, lt as v, rt as y, st as b, tt as x, ut as S, xt as C } from "./alert-dialog-D_iDv2lQ.js";
|
|
4
|
+
import { A as w, H as T, L as E, M as D, Y as O, j as k, l as A, t as j } from "./spinner-B-KLtBjp.js";
|
|
5
|
+
import { a as M, c as N, d as P, i as F, n as ee, r as I, s as L, u as R } from "./notice-card-V_0K0lO0.js";
|
|
6
|
+
import { t as z } from "./diagnostic-text-CYZFPiND.js";
|
|
7
|
+
import { a as te, b as ne, i as re, n as ie } from "./panel-DuZD-cBP.js";
|
|
8
|
+
import { n as ae, r as oe, t as B } from "./query-gate-BbIo1Xrj.js";
|
|
9
|
+
import { t as se } from "./breadcrumbs-D5R6Fz74.js";
|
|
10
|
+
import { n as ce, t as le } from "./base-revision-DLF9EnGV.js";
|
|
11
|
+
import { t as ue } from "./code-editor-DCM0KdMJ.js";
|
|
12
|
+
import { a as de, i as fe, n as pe, o as V, r as me, t as he } from "./run-text-CDdfbKbg.js";
|
|
13
|
+
import { n as ge, t as _e } from "./editor-language-CGENZxbI.js";
|
|
14
|
+
import { n as ve } from "./starter-handoff-BaK8Ss8I.js";
|
|
15
|
+
import { n as ye, t as be } from "./entity-controls-DJT47yeV.js";
|
|
16
|
+
import { useCallback as xe, useDeferredValue as Se, useEffect as Ce, useId as we, useMemo as H, useRef as Te, useState as U } from "react";
|
|
17
|
+
import { Fragment as Ee, jsx as W, jsxs as G } from "react/jsx-runtime";
|
|
18
|
+
import K from "typebox";
|
|
19
|
+
import { ChevronRightIcon as De, CircleAlertIcon as Oe, CircleCheckIcon as ke, FlaskConicalIcon as Ae, HistoryIcon as je, RefreshCwIcon as Me, SparklesIcon as Ne, Trash2Icon as Pe, TriangleAlertIcon as Fe, WorkflowIcon as Ie } from "lucide-react";
|
|
20
|
+
import { formatAppDateTime as Le, resolveLocalized as q, schema as Re } from "@overvis/hmi-shared";
|
|
21
|
+
import { Value as ze } from "typebox/value";
|
|
22
|
+
import { automationCatalog as Be, automationContextOf as Ve, automationLanguageService as He, automationTextsInLocale as Ue, automationType as We, automationTypedValueType as Ge, maxProcedureSteps as Ke, restoreAutomationTexts as qe, validateAutomation as Je } from "@overvis/hmi-shared/automation";
|
|
23
|
+
import { useNavigate as Ye, useRouter as Xe } from "@tanstack/react-router";
|
|
24
|
+
import { formatExpressionValue as Ze } from "@overvis/hmi-shared/expression";
|
|
25
|
+
import { json as Qe, jsonLanguage as $e } from "@codemirror/lang-json";
|
|
26
|
+
// src/code-editor/json-positions.ts
|
|
27
|
+
var et = /* @__PURE__ */ new Set([
|
|
28
|
+
"{",
|
|
29
|
+
"}",
|
|
30
|
+
"[",
|
|
31
|
+
"]",
|
|
32
|
+
",",
|
|
33
|
+
":"
|
|
34
|
+
]);
|
|
35
|
+
function J(e) {
|
|
36
|
+
return $e.parser.parse(e);
|
|
37
|
+
}
|
|
38
|
+
function Y(e) {
|
|
39
|
+
let t = [];
|
|
40
|
+
for (let n = e.firstChild; n !== null; n = n.nextSibling) !et.has(n.name) && !n.type.isError && t.push(n);
|
|
41
|
+
return t;
|
|
42
|
+
}
|
|
43
|
+
function tt(e) {
|
|
44
|
+
return e.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
45
|
+
}
|
|
46
|
+
function nt(e, t) {
|
|
47
|
+
try {
|
|
48
|
+
let n = JSON.parse(e.slice(t.from, t.to));
|
|
49
|
+
return typeof n == "string" ? n : null;
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function rt(e) {
|
|
55
|
+
return e.name === "Property" ? Y(e)[1] ?? null : e;
|
|
56
|
+
}
|
|
57
|
+
function it(e, t, n) {
|
|
58
|
+
let r = Y(e.topNode)[0];
|
|
59
|
+
if (r === void 0) return null;
|
|
60
|
+
let i = n === "" ? [] : n.split("/").slice(1).map(tt);
|
|
61
|
+
for (let e of i) {
|
|
62
|
+
let n = null;
|
|
63
|
+
if (r.name === "Object") {
|
|
64
|
+
let i = [...Y(r)].reverse().find((n) => {
|
|
65
|
+
let r = n.firstChild;
|
|
66
|
+
return r !== null && nt(t, r) === e;
|
|
67
|
+
});
|
|
68
|
+
n = i === void 0 ? null : rt(i);
|
|
69
|
+
} else r.name === "Array" && /^\d+$/.test(e) && (n = Y(r)[Number(e)] ?? null);
|
|
70
|
+
if (n === null) return {
|
|
71
|
+
node: r,
|
|
72
|
+
exact: !1
|
|
73
|
+
};
|
|
74
|
+
r = n;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
node: r,
|
|
78
|
+
exact: !0
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function at(e) {
|
|
82
|
+
if (e.name !== "Object" && e.name !== "Array") return {
|
|
83
|
+
from: e.from,
|
|
84
|
+
to: e.to
|
|
85
|
+
};
|
|
86
|
+
let t = e.parent, n = t?.name === "Property" ? t.firstChild : null;
|
|
87
|
+
return n === null ? {
|
|
88
|
+
from: e.from,
|
|
89
|
+
to: Math.min(e.from + 1, e.to)
|
|
90
|
+
} : {
|
|
91
|
+
from: n.from,
|
|
92
|
+
to: n.to
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function ot(e, t, n) {
|
|
96
|
+
let r = [], i = t + 1, a = Math.max(i, n - 1);
|
|
97
|
+
for (; i < a;) r.push(i), e[i] === "\\" ? i += e[i + 1] === "u" ? 6 : 2 : i += 1;
|
|
98
|
+
return r.push(a), r;
|
|
99
|
+
}
|
|
100
|
+
function X(e, t, n, r) {
|
|
101
|
+
let i = it(e, t, n);
|
|
102
|
+
if (i === null) return {
|
|
103
|
+
from: 0,
|
|
104
|
+
to: Math.min(1, t.length)
|
|
105
|
+
};
|
|
106
|
+
let { node: a, exact: o } = i;
|
|
107
|
+
if (o && r !== void 0 && a.name === "String") {
|
|
108
|
+
let e = ot(t, a.from, a.to), n = e.length - 1, i = e[Math.min(Math.max(r.start, 0), n)] ?? a.from, o = e[Math.min(Math.max(r.end, r.start), n)] ?? a.to;
|
|
109
|
+
return o > i ? {
|
|
110
|
+
from: i,
|
|
111
|
+
to: o
|
|
112
|
+
} : {
|
|
113
|
+
from: i,
|
|
114
|
+
to: Math.min(i + 1, a.to)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return at(a);
|
|
118
|
+
}
|
|
119
|
+
function st(e, t) {
|
|
120
|
+
let n = { span: null };
|
|
121
|
+
if (e.iterate({ enter: (e) => {
|
|
122
|
+
if (n.span !== null) return !1;
|
|
123
|
+
if (!e.type.isError) return;
|
|
124
|
+
let r = Math.max(0, Math.min(e.from, t.length - 1));
|
|
125
|
+
return n.span = {
|
|
126
|
+
from: r,
|
|
127
|
+
to: Math.min(Math.max(e.to, r + 1), t.length)
|
|
128
|
+
}, !1;
|
|
129
|
+
} }), n.span !== null) return n.span;
|
|
130
|
+
try {
|
|
131
|
+
return JSON.parse(t), null;
|
|
132
|
+
} catch {
|
|
133
|
+
return {
|
|
134
|
+
from: 0,
|
|
135
|
+
to: Math.min(1, t.length)
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// src/workspace/automations/use-catalog.ts
|
|
140
|
+
function ct(e) {
|
|
141
|
+
let t = c(), n = o.parameter.listTree.useQuery({ workspaceId: e }), r = o.endpoint.listSummaries.useQuery({ workspaceId: e }), i = o.alarmRule.list.useQuery({ workspaceId: e }), a = o.automation.list.useQuery({ workspaceId: e }), s = o.automation.members.useQuery({ workspaceId: e });
|
|
142
|
+
return H(() => Be({
|
|
143
|
+
locale: t,
|
|
144
|
+
branches: n.data?.branches ?? [],
|
|
145
|
+
parameters: n.data?.parameters ?? [],
|
|
146
|
+
endpoints: r.data?.endpoints ?? [],
|
|
147
|
+
alarmRules: i.data?.items ?? [],
|
|
148
|
+
automations: a.data?.items ?? [],
|
|
149
|
+
members: s.data?.members ?? []
|
|
150
|
+
}), [
|
|
151
|
+
t,
|
|
152
|
+
n.data,
|
|
153
|
+
r.data,
|
|
154
|
+
i.data,
|
|
155
|
+
a.data,
|
|
156
|
+
s.data
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
function lt(e) {
|
|
160
|
+
let t = Xe();
|
|
161
|
+
return xe((n, r) => {
|
|
162
|
+
let i = (() => {
|
|
163
|
+
switch (n) {
|
|
164
|
+
case "parameter": return t.buildLocation({
|
|
165
|
+
to: "/workspace/$workspaceId/setup/parameters/$parameterId",
|
|
166
|
+
params: {
|
|
167
|
+
workspaceId: e,
|
|
168
|
+
parameterId: r
|
|
169
|
+
}
|
|
170
|
+
}).publicHref;
|
|
171
|
+
case "endpoint": return t.buildLocation({
|
|
172
|
+
to: "/workspace/$workspaceId/setup/endpoints/$endpointId",
|
|
173
|
+
params: {
|
|
174
|
+
workspaceId: e,
|
|
175
|
+
endpointId: r
|
|
176
|
+
}
|
|
177
|
+
}).publicHref;
|
|
178
|
+
case "alarmRule": return t.buildLocation({
|
|
179
|
+
to: "/workspace/$workspaceId/setup/automations/alarm-rules/$alarmRuleId",
|
|
180
|
+
params: {
|
|
181
|
+
workspaceId: e,
|
|
182
|
+
alarmRuleId: r
|
|
183
|
+
}
|
|
184
|
+
}).publicHref;
|
|
185
|
+
case "automation": return t.buildLocation({
|
|
186
|
+
to: "/workspace/$workspaceId/setup/automations/$automationId",
|
|
187
|
+
params: {
|
|
188
|
+
workspaceId: e,
|
|
189
|
+
automationId: r
|
|
190
|
+
}
|
|
191
|
+
}).publicHref;
|
|
192
|
+
case "member": return null;
|
|
193
|
+
}
|
|
194
|
+
})();
|
|
195
|
+
i !== null && window.open(i, "_blank", "noopener");
|
|
196
|
+
}, [t, e]);
|
|
197
|
+
}
|
|
198
|
+
// src/workspace/setup/automations/document.ts
|
|
199
|
+
var ut = K.Object({
|
|
200
|
+
text: K.String(),
|
|
201
|
+
dashboardId: K.String()
|
|
202
|
+
}), dt = Re(ut), ft = /* @__PURE__ */ "kind.name.description.pollIntervalMs.minRunIntervalMs.writeLimit.count.periodMs.type.lifetime.source.parameterId.endpointId.alarm.alarmRuleId.automationId.key.initial.formula.event.offsetMs.everyMs.times.weekdays.inputs.transitions.command.minRole.run.variable.procedure.max.counter.value.level.severity.message.title.body.params.latching.recipients.roles.userIds.notifyDelayMs.excludeChannels.delayMs.cancelKey.branches.when.heldForMs.once.steps.else.triggers.variables.procedures.onInit".split("."), pt = new Map(ft.map((e, t) => [e, t]));
|
|
203
|
+
function Z(e) {
|
|
204
|
+
if (Array.isArray(e)) return e.map(Z);
|
|
205
|
+
if (typeof e != "object" || !e) return e;
|
|
206
|
+
let t = Object.entries(e), n = (e) => pt.get(e) ?? ft.length;
|
|
207
|
+
return Object.fromEntries(t.map(([e, t], n) => ({
|
|
208
|
+
key: e,
|
|
209
|
+
inner: t,
|
|
210
|
+
index: n
|
|
211
|
+
})).sort((e, t) => n(e.key) - n(t.key) || e.index - t.index).map(({ key: e, inner: t }) => [e, Z(t)]));
|
|
212
|
+
}
|
|
213
|
+
function mt(e) {
|
|
214
|
+
return `${JSON.stringify(Z(e), null, 2)}\n`;
|
|
215
|
+
}
|
|
216
|
+
function ht(e, t) {
|
|
217
|
+
let n = Math.max(6e4, t.minTriggerIntervalMs);
|
|
218
|
+
return {
|
|
219
|
+
name: e,
|
|
220
|
+
pollIntervalMs: Math.max(1e4, t.minTriggerIntervalMs),
|
|
221
|
+
minRunIntervalMs: Math.max(1e4, t.minTriggerIntervalMs),
|
|
222
|
+
writeLimit: {
|
|
223
|
+
count: Math.min(10, t.maxWritesPerMinute),
|
|
224
|
+
periodMs: 6e4
|
|
225
|
+
},
|
|
226
|
+
triggers: [{
|
|
227
|
+
kind: "period",
|
|
228
|
+
everyMs: n,
|
|
229
|
+
run: "main"
|
|
230
|
+
}],
|
|
231
|
+
variables: [],
|
|
232
|
+
procedures: [{
|
|
233
|
+
name: "main",
|
|
234
|
+
steps: [{
|
|
235
|
+
kind: "writeLog",
|
|
236
|
+
level: "info",
|
|
237
|
+
message: "\"Hello\""
|
|
238
|
+
}]
|
|
239
|
+
}]
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
var gt = /^(?:\/name|\/description|.*\/message\/(?:title|body))$/;
|
|
243
|
+
function _t(e, t, n, r = (e) => e) {
|
|
244
|
+
let i = J(e), a = st(i, e);
|
|
245
|
+
if (a !== null) return {
|
|
246
|
+
value: null,
|
|
247
|
+
automation: null,
|
|
248
|
+
problems: [{
|
|
249
|
+
span: a,
|
|
250
|
+
severity: "error",
|
|
251
|
+
diagnostic: null
|
|
252
|
+
}],
|
|
253
|
+
errorCount: 1,
|
|
254
|
+
stepBudget: /* @__PURE__ */ new Map(),
|
|
255
|
+
maxSteps: null
|
|
256
|
+
};
|
|
257
|
+
let o = r(JSON.parse(e)), s = Je(o, Ve(t, n), t.limits), c = s.diagnostics.map((t) => ({
|
|
258
|
+
span: X(i, e, t.path, gt.test(t.path) ? void 0 : t.range),
|
|
259
|
+
severity: t.severity,
|
|
260
|
+
diagnostic: t
|
|
261
|
+
})).sort((e, t) => (e.severity === t.severity ? 0 : e.severity === "error" ? -1 : 1) || e.span.from - t.span.from), l = ze.Check(We, o) ? o : null;
|
|
262
|
+
return {
|
|
263
|
+
value: o,
|
|
264
|
+
automation: l,
|
|
265
|
+
problems: c,
|
|
266
|
+
errorCount: c.filter((e) => e.severity === "error").length,
|
|
267
|
+
stepBudget: l === null ? /* @__PURE__ */ new Map() : Ke(l.procedures),
|
|
268
|
+
maxSteps: s.maxSteps
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
// src/workspace/automations/parameter-names.ts
|
|
272
|
+
function vt(e) {
|
|
273
|
+
let t = c(), n = o.parameter.listTree.useQuery({ workspaceId: e }), r = H(() => new Map((n.data?.parameters ?? []).map((e) => [e.id, q(e.name, t)])), [n.data, t]);
|
|
274
|
+
return (e) => r.get(e) ?? null;
|
|
275
|
+
}
|
|
276
|
+
// src/workspace/automations/trace-view.tsx
|
|
277
|
+
function yt(e) {
|
|
278
|
+
if (typeof e != "object" || !e || !("procedures" in e)) return [];
|
|
279
|
+
let t = e.procedures;
|
|
280
|
+
return Array.isArray(t) ? t.map((e) => typeof e == "object" && e && "name" in e && typeof e.name == "string" ? e.name : "") : [];
|
|
281
|
+
}
|
|
282
|
+
function bt() {
|
|
283
|
+
let e = l();
|
|
284
|
+
return (t, n) => {
|
|
285
|
+
let r = t.split("/").slice(1);
|
|
286
|
+
if (r[0] !== "procedures" || r[1] === void 0) return t;
|
|
287
|
+
let i = Number(r[1]), a = [n[i] ?? `#${String(i + 1)}`];
|
|
288
|
+
for (let t = 2; t < r.length; t += 2) {
|
|
289
|
+
let n = r[t], i = Number(r[t + 1]);
|
|
290
|
+
if (n === "steps") a.push(String(i + 1));
|
|
291
|
+
else if (n === "branches") a.push(e("automation_location_branch", { n: String(i + 1) }));
|
|
292
|
+
else if (n === "else") a.push(e("automation_location_else")), --t;
|
|
293
|
+
else break;
|
|
294
|
+
}
|
|
295
|
+
return a.join(" › ");
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function xt(e) {
|
|
299
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
300
|
+
}
|
|
301
|
+
function St() {
|
|
302
|
+
let e = c();
|
|
303
|
+
return (t) => {
|
|
304
|
+
if (!xt(t)) return "";
|
|
305
|
+
let n = t.title, r;
|
|
306
|
+
if (typeof n == "string") r = n;
|
|
307
|
+
else if (xt(n)) {
|
|
308
|
+
let t = Object.fromEntries(Object.entries(n).filter((e) => typeof e[1] == "string"));
|
|
309
|
+
r = q(t, e);
|
|
310
|
+
} else return "";
|
|
311
|
+
let i = xt(t.params) ? t.params : {};
|
|
312
|
+
return r.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g, (e, t) => {
|
|
313
|
+
let n = i[t];
|
|
314
|
+
return ze.Check(Ge, n) ? typeof n.value == "string" ? n.value : (n.type === "duration" || n.type === "timeOfDay") && n.value !== null ? Ze(n.value, n.type, "UTC") ?? e : me(n) : e;
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function Q({ values: e, empty: t }) {
|
|
319
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t));
|
|
320
|
+
return n.length === 0 ? /* @__PURE__ */ W("p", {
|
|
321
|
+
className: "text-sm text-muted-foreground",
|
|
322
|
+
children: t
|
|
323
|
+
}) : /* @__PURE__ */ W("dl", {
|
|
324
|
+
className: "grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",
|
|
325
|
+
children: n.map(([e, t]) => /* @__PURE__ */ G("div", {
|
|
326
|
+
className: "contents",
|
|
327
|
+
children: [/* @__PURE__ */ W("dt", {
|
|
328
|
+
className: "truncate font-mono text-muted-foreground",
|
|
329
|
+
children: e
|
|
330
|
+
}), /* @__PURE__ */ W("dd", {
|
|
331
|
+
className: "truncate font-mono",
|
|
332
|
+
children: me(t)
|
|
333
|
+
})]
|
|
334
|
+
}, e))
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function Ct(e) {
|
|
338
|
+
if (e.kind === "writeLog") switch (e.detail.level) {
|
|
339
|
+
case "error": return "destructive";
|
|
340
|
+
case "warn": return "warning";
|
|
341
|
+
case "info": return "secondary";
|
|
342
|
+
default: return "outline";
|
|
343
|
+
}
|
|
344
|
+
return e.kind === "fail" || e.kind === "writeFailed" || e.kind === "writeDropped" || e.kind === "writeLimited" ? "destructive" : "outline";
|
|
345
|
+
}
|
|
346
|
+
function wt({ step: e }) {
|
|
347
|
+
let t = e.detail.level, n = Ct(e);
|
|
348
|
+
return /* @__PURE__ */ W(A, {
|
|
349
|
+
variant: n,
|
|
350
|
+
className: "shrink-0 font-mono",
|
|
351
|
+
children: e.kind === "writeLog" && typeof t == "string" ? `${V(e.kind)} · ${t}` : V(e.kind)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function Tt({ steps: e, procedures: t, parameterName: n, onReveal: r }) {
|
|
355
|
+
let i = bt();
|
|
356
|
+
return /* @__PURE__ */ W("ol", {
|
|
357
|
+
className: "divide-y rounded-md border text-sm",
|
|
358
|
+
children: e.map((e, a) => {
|
|
359
|
+
let o = de(e, n);
|
|
360
|
+
return /* @__PURE__ */ G("li", {
|
|
361
|
+
className: "\n flex flex-col gap-1 px-3 py-1.5\n sm:flex-row sm:items-center sm:gap-3\n ",
|
|
362
|
+
children: [/* @__PURE__ */ G("div", {
|
|
363
|
+
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
364
|
+
children: [
|
|
365
|
+
/* @__PURE__ */ W("span", {
|
|
366
|
+
className: "w-8 shrink-0 text-right text-xs text-muted-foreground tabular-nums",
|
|
367
|
+
children: a + 1
|
|
368
|
+
}),
|
|
369
|
+
/* @__PURE__ */ W(wt, { step: e }),
|
|
370
|
+
o === "" ? null : /* @__PURE__ */ W("span", {
|
|
371
|
+
className: "min-w-0 truncate font-mono",
|
|
372
|
+
children: o
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
}), e.path === "" ? null : r == null ? /* @__PURE__ */ W("span", {
|
|
376
|
+
className: "shrink-0 text-xs text-muted-foreground",
|
|
377
|
+
children: i(e.path, t)
|
|
378
|
+
}) : /* @__PURE__ */ W(_, {
|
|
379
|
+
type: "button",
|
|
380
|
+
variant: "link",
|
|
381
|
+
size: "sm",
|
|
382
|
+
className: "\n h-auto shrink-0 self-start p-0 text-xs\n sm:self-auto\n ",
|
|
383
|
+
onClick: () => {
|
|
384
|
+
r(e.path);
|
|
385
|
+
},
|
|
386
|
+
children: i(e.path, t)
|
|
387
|
+
})]
|
|
388
|
+
}, a);
|
|
389
|
+
})
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
function Et({ effects: e, parameterName: t, empty: n }) {
|
|
393
|
+
let r = l(), i = St();
|
|
394
|
+
if (e.length === 0) return /* @__PURE__ */ W("p", {
|
|
395
|
+
className: "text-sm text-muted-foreground",
|
|
396
|
+
children: n
|
|
397
|
+
});
|
|
398
|
+
let a = (e) => typeof e == "string" ? e : "";
|
|
399
|
+
return /* @__PURE__ */ W("ul", {
|
|
400
|
+
className: "divide-y rounded-md border text-sm",
|
|
401
|
+
children: e.map((e, n) => {
|
|
402
|
+
let o = e.detail, s;
|
|
403
|
+
switch (e.kind) {
|
|
404
|
+
case "writeParameter": {
|
|
405
|
+
let e = a(o.parameterId);
|
|
406
|
+
s = `${t(e) ?? e} ← ${a(o.value)}`;
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
case "notify":
|
|
410
|
+
case "reply":
|
|
411
|
+
s = i(o.message);
|
|
412
|
+
break;
|
|
413
|
+
case "raiseAlarm":
|
|
414
|
+
s = r("automation_effect_alarm", {
|
|
415
|
+
key: a(o.key),
|
|
416
|
+
title: i(o.message)
|
|
417
|
+
});
|
|
418
|
+
break;
|
|
419
|
+
case "clearAlarm":
|
|
420
|
+
s = a(o.key);
|
|
421
|
+
break;
|
|
422
|
+
case "cancelNotify":
|
|
423
|
+
s = a(o.cancelKey);
|
|
424
|
+
break;
|
|
425
|
+
default: s = "";
|
|
426
|
+
}
|
|
427
|
+
let c = a(o.severity);
|
|
428
|
+
return /* @__PURE__ */ G("li", {
|
|
429
|
+
className: "flex items-center gap-2 px-3 py-1.5",
|
|
430
|
+
children: [
|
|
431
|
+
/* @__PURE__ */ W(A, {
|
|
432
|
+
variant: "outline",
|
|
433
|
+
className: "shrink-0",
|
|
434
|
+
children: V(e.kind)
|
|
435
|
+
}),
|
|
436
|
+
o.limited === !0 ? /* @__PURE__ */ W(A, {
|
|
437
|
+
variant: "destructive",
|
|
438
|
+
className: "shrink-0",
|
|
439
|
+
children: V("writeLimited")
|
|
440
|
+
}) : null,
|
|
441
|
+
c === "" ? null : /* @__PURE__ */ W(A, {
|
|
442
|
+
variant: c === "urgent" ? "destructive" : "secondary",
|
|
443
|
+
children: fe(c)
|
|
444
|
+
}),
|
|
445
|
+
/* @__PURE__ */ W("span", {
|
|
446
|
+
className: "min-w-0 truncate",
|
|
447
|
+
children: s
|
|
448
|
+
})
|
|
449
|
+
]
|
|
450
|
+
}, n);
|
|
451
|
+
})
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
// src/workspace/setup/automations/dry-run.tsx
|
|
455
|
+
function Dt(e) {
|
|
456
|
+
return e.triggers[0]?.run ?? e.procedures[0]?.name ?? "";
|
|
457
|
+
}
|
|
458
|
+
function $({ title: e, children: t }) {
|
|
459
|
+
return /* @__PURE__ */ G("section", {
|
|
460
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
461
|
+
children: [/* @__PURE__ */ W("h4", {
|
|
462
|
+
className: "text-sm font-medium",
|
|
463
|
+
children: e
|
|
464
|
+
}), t]
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function Ot({ workspaceId: e, automationId: t, automation: n, onReveal: r }) {
|
|
468
|
+
let i = l(), s = we(), c = we(), [u, d] = U(null), [f, p] = U(!1), m = vt(e), h = o.automation.dryRun.useMutation(), g = n?.procedures.map((e) => e.name) ?? [], v = u !== null && g.includes(u) ? u : n === null ? "" : Dt(n), b = n?.triggers.some((e) => e.kind === "telegram" && e.run === v) ?? !1, S = h.data, C = h.variables;
|
|
469
|
+
return /* @__PURE__ */ G(M, { children: [/* @__PURE__ */ G(R, { children: [/* @__PURE__ */ G(P, {
|
|
470
|
+
className: "flex items-center gap-2",
|
|
471
|
+
children: [/* @__PURE__ */ W(Ae, { className: "size-4" }), i("automation_dry_run_title")]
|
|
472
|
+
}), /* @__PURE__ */ W(N, { children: i("automation_dry_run_description") })] }), /* @__PURE__ */ G(L, {
|
|
473
|
+
className: "flex flex-col gap-4",
|
|
474
|
+
children: [
|
|
475
|
+
/* @__PURE__ */ G("div", {
|
|
476
|
+
className: "\n flex flex-col gap-3\n sm:flex-row sm:items-end\n ",
|
|
477
|
+
children: [
|
|
478
|
+
/* @__PURE__ */ G(E, {
|
|
479
|
+
className: "sm:max-w-64",
|
|
480
|
+
children: [/* @__PURE__ */ W(T, {
|
|
481
|
+
htmlFor: s,
|
|
482
|
+
children: i("automation_dry_run_procedure")
|
|
483
|
+
}), /* @__PURE__ */ W(w, {
|
|
484
|
+
id: s,
|
|
485
|
+
value: v,
|
|
486
|
+
disabled: n === null,
|
|
487
|
+
onChange: (e) => {
|
|
488
|
+
d(e.target.value);
|
|
489
|
+
},
|
|
490
|
+
children: g.map((e) => /* @__PURE__ */ W(D, {
|
|
491
|
+
value: e,
|
|
492
|
+
children: e
|
|
493
|
+
}, e))
|
|
494
|
+
})]
|
|
495
|
+
}),
|
|
496
|
+
b ? /* @__PURE__ */ G("div", {
|
|
497
|
+
className: "\n flex items-center gap-2\n sm:pb-2\n ",
|
|
498
|
+
children: [/* @__PURE__ */ W(O, {
|
|
499
|
+
id: c,
|
|
500
|
+
checked: f,
|
|
501
|
+
onCheckedChange: (e) => {
|
|
502
|
+
p(e);
|
|
503
|
+
}
|
|
504
|
+
}), /* @__PURE__ */ W("label", {
|
|
505
|
+
htmlFor: c,
|
|
506
|
+
className: "text-sm",
|
|
507
|
+
children: i("automation_dry_run_command")
|
|
508
|
+
})]
|
|
509
|
+
}) : null,
|
|
510
|
+
/* @__PURE__ */ G(_, {
|
|
511
|
+
type: "button",
|
|
512
|
+
variant: "outline",
|
|
513
|
+
disabled: n === null || v === "" || h.isPending,
|
|
514
|
+
onClick: () => {
|
|
515
|
+
n !== null && h.mutate({
|
|
516
|
+
workspaceId: e,
|
|
517
|
+
...t === void 0 ? {} : { automationId: t },
|
|
518
|
+
document: n,
|
|
519
|
+
procedure: v,
|
|
520
|
+
...b && f ? { command: !0 } : {}
|
|
521
|
+
});
|
|
522
|
+
},
|
|
523
|
+
children: [h.isPending ? /* @__PURE__ */ W(j, { "data-icon": "inline-start" }) : null, i("automation_dry_run_submit")]
|
|
524
|
+
})
|
|
525
|
+
]
|
|
526
|
+
}),
|
|
527
|
+
n === null ? /* @__PURE__ */ W("p", {
|
|
528
|
+
className: "text-sm text-muted-foreground",
|
|
529
|
+
children: i("automation_dry_run_needs_valid")
|
|
530
|
+
}) : null,
|
|
531
|
+
h.isError ? /* @__PURE__ */ W(x, {
|
|
532
|
+
variant: "destructive",
|
|
533
|
+
children: /* @__PURE__ */ W(y, { children: a(h.error) })
|
|
534
|
+
}) : null,
|
|
535
|
+
S != null && C != null && n !== null ? /* @__PURE__ */ G("div", {
|
|
536
|
+
className: "flex flex-col gap-4",
|
|
537
|
+
children: [
|
|
538
|
+
/* @__PURE__ */ G("div", {
|
|
539
|
+
className: "flex flex-wrap items-center gap-2 text-sm",
|
|
540
|
+
children: [/* @__PURE__ */ W(A, {
|
|
541
|
+
variant: S.status === "ok" ? "success" : "destructive",
|
|
542
|
+
children: S.status === "ok" ? i("automation_run_ok") : i("automation_run_failed")
|
|
543
|
+
}), /* @__PURE__ */ W("span", {
|
|
544
|
+
className: "text-muted-foreground",
|
|
545
|
+
children: i("automation_dry_run_summary", {
|
|
546
|
+
procedure: C.procedure,
|
|
547
|
+
at: Le(S.startedAt),
|
|
548
|
+
steps: String(S.steps),
|
|
549
|
+
limit: String(S.maxSteps)
|
|
550
|
+
})
|
|
551
|
+
})]
|
|
552
|
+
}),
|
|
553
|
+
S.errorCode === null ? null : /* @__PURE__ */ W(x, {
|
|
554
|
+
variant: "destructive",
|
|
555
|
+
children: /* @__PURE__ */ W(y, { children: he(S.errorCode, S.error) })
|
|
556
|
+
}),
|
|
557
|
+
/* @__PURE__ */ W("p", {
|
|
558
|
+
className: "text-sm text-muted-foreground",
|
|
559
|
+
children: i("automation_dry_run_applied_nothing")
|
|
560
|
+
}),
|
|
561
|
+
/* @__PURE__ */ G("div", {
|
|
562
|
+
className: "\n grid grid-cols-1 gap-4\n lg:grid-cols-2\n ",
|
|
563
|
+
children: [
|
|
564
|
+
/* @__PURE__ */ W($, {
|
|
565
|
+
title: i("automation_run_inputs"),
|
|
566
|
+
children: /* @__PURE__ */ W(Q, {
|
|
567
|
+
values: S.inputs,
|
|
568
|
+
empty: i("automation_run_no_inputs")
|
|
569
|
+
})
|
|
570
|
+
}),
|
|
571
|
+
/* @__PURE__ */ G($, {
|
|
572
|
+
title: i("automation_dry_run_effects"),
|
|
573
|
+
children: [S.status === "failed" && S.effects.length > 0 ? /* @__PURE__ */ W("p", {
|
|
574
|
+
className: "text-sm text-muted-foreground",
|
|
575
|
+
children: i("automation_dry_run_failed_applies_nothing")
|
|
576
|
+
}) : null, /* @__PURE__ */ W(Et, {
|
|
577
|
+
effects: S.effects,
|
|
578
|
+
parameterName: m,
|
|
579
|
+
empty: i("automation_dry_run_no_effects")
|
|
580
|
+
})]
|
|
581
|
+
}),
|
|
582
|
+
/* @__PURE__ */ W($, {
|
|
583
|
+
title: i("automation_dry_run_state_before"),
|
|
584
|
+
children: /* @__PURE__ */ W(Q, {
|
|
585
|
+
values: S.stateBefore,
|
|
586
|
+
empty: i("automation_run_no_state")
|
|
587
|
+
})
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ W($, {
|
|
590
|
+
title: i("automation_dry_run_state_after"),
|
|
591
|
+
children: /* @__PURE__ */ W(Q, {
|
|
592
|
+
values: S.stateAfter,
|
|
593
|
+
empty: i("automation_run_no_state")
|
|
594
|
+
})
|
|
595
|
+
})
|
|
596
|
+
]
|
|
597
|
+
}),
|
|
598
|
+
/* @__PURE__ */ W($, {
|
|
599
|
+
title: i("automation_run_steps"),
|
|
600
|
+
children: S.trace.length === 0 ? /* @__PURE__ */ W("p", {
|
|
601
|
+
className: "text-sm text-muted-foreground",
|
|
602
|
+
children: i("automation_run_no_steps")
|
|
603
|
+
}) : /* @__PURE__ */ W(Tt, {
|
|
604
|
+
steps: S.trace,
|
|
605
|
+
procedures: yt(C.document),
|
|
606
|
+
parameterName: m,
|
|
607
|
+
...JSON.stringify(C.document) === JSON.stringify(n) ? { onReveal: r } : {}
|
|
608
|
+
})
|
|
609
|
+
})
|
|
610
|
+
]
|
|
611
|
+
}) : null
|
|
612
|
+
]
|
|
613
|
+
})] });
|
|
614
|
+
}
|
|
615
|
+
// src/workspace/setup/automations/editor-form.tsx
|
|
616
|
+
var kt = [];
|
|
617
|
+
function At(e) {
|
|
618
|
+
return String(e / 1e3);
|
|
619
|
+
}
|
|
620
|
+
function jt({ workspaceId: e, detail: t, context: a, editorRef: o, onCreated: d, onReload: f, onDirtyChange: p, starter: m }) {
|
|
621
|
+
let h = l(), g = u(), _ = c(), [v] = U(_), y = r(e), b = ce(t?.revision), x = t?.id, [S, C] = U(t?.document ?? m ?? null), [w, T] = U(t?.dashboardId ?? ""), [E, D] = U(() => {
|
|
622
|
+
let e = t?.document ?? m;
|
|
623
|
+
return mt(e === void 0 ? ht(h("automation_new_name"), a.limits) : Ue(e, v));
|
|
624
|
+
}), O = n({
|
|
625
|
+
defaultValues: {
|
|
626
|
+
text: E,
|
|
627
|
+
dashboardId: t?.dashboardId ?? ""
|
|
628
|
+
},
|
|
629
|
+
validators: s({
|
|
630
|
+
schema: dt,
|
|
631
|
+
submit: async (t) => {
|
|
632
|
+
let n = _t(t.text, a, x, (e) => qe(S, e, v));
|
|
633
|
+
if (n.errorCount > 0 || n.automation === null) return {
|
|
634
|
+
form: () => h("automation_editor_save_has_errors"),
|
|
635
|
+
fields: {}
|
|
636
|
+
};
|
|
637
|
+
let r = n.automation, i = t.dashboardId === "" ? null : t.dashboardId;
|
|
638
|
+
if (x == null) {
|
|
639
|
+
let t = await y.create.mutateAsync({
|
|
640
|
+
workspaceId: e,
|
|
641
|
+
document: r,
|
|
642
|
+
dashboardId: i
|
|
643
|
+
});
|
|
644
|
+
d?.(t.id);
|
|
645
|
+
} else {
|
|
646
|
+
let e = await y.update.mutateAsync({
|
|
647
|
+
id: x,
|
|
648
|
+
document: r,
|
|
649
|
+
dashboardId: i,
|
|
650
|
+
...b.baseRevision === void 0 ? {} : { baseRevision: b.baseRevision }
|
|
651
|
+
});
|
|
652
|
+
b.rebase(e.revision), C(r), D(t.text), T(t.dashboardId);
|
|
653
|
+
}
|
|
654
|
+
return null;
|
|
655
|
+
},
|
|
656
|
+
mapError: b.mapError(),
|
|
657
|
+
onError: b.onError
|
|
658
|
+
}),
|
|
659
|
+
onSubmitInvalid: i,
|
|
660
|
+
onSubmit: () => {
|
|
661
|
+
g.success(h(x == null ? "automation_create_toast" : "automation_save_toast"));
|
|
662
|
+
}
|
|
663
|
+
}), [k, A] = U(t?.revision), [j, M] = U(null);
|
|
664
|
+
if (t !== void 0 && t.revision !== k && (A(t.revision), t.revision !== b.baseRevision && O.state.values.text === E && O.state.values.dashboardId === w)) {
|
|
665
|
+
let e = mt(Ue(t.document, v));
|
|
666
|
+
C(t.document), D(e), b.rebase(t.revision), T(t.dashboardId ?? ""), M({
|
|
667
|
+
text: e,
|
|
668
|
+
dashboardId: t.dashboardId ?? ""
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
return Ce(() => {
|
|
672
|
+
j !== null && O.reset(j);
|
|
673
|
+
}, [j, O]), /* @__PURE__ */ W(O.AppForm, { children: /* @__PURE__ */ G(O.FormRoot, {
|
|
674
|
+
banner: !1,
|
|
675
|
+
className: "flex flex-col gap-4",
|
|
676
|
+
children: [/* @__PURE__ */ W(O.Subscribe, {
|
|
677
|
+
selector: (e) => e.values.text,
|
|
678
|
+
children: (n) => /* @__PURE__ */ W(Rt, {
|
|
679
|
+
automationName: t == null ? h("automation_new_name") : q(t.name, v),
|
|
680
|
+
text: n,
|
|
681
|
+
savedText: E,
|
|
682
|
+
original: S,
|
|
683
|
+
locale: v,
|
|
684
|
+
...p === void 0 ? {} : { onDirtyChange: p },
|
|
685
|
+
context: a,
|
|
686
|
+
automationId: x,
|
|
687
|
+
workspaceId: e,
|
|
688
|
+
onText: (e) => {
|
|
689
|
+
O.setFieldValue("text", e);
|
|
690
|
+
},
|
|
691
|
+
editorRef: o,
|
|
692
|
+
dashboardField: /* @__PURE__ */ W(O.AppField, {
|
|
693
|
+
name: "dashboardId",
|
|
694
|
+
children: (t) => /* @__PURE__ */ W(t.DashboardPickerField, {
|
|
695
|
+
label: h("automation_field_dashboard"),
|
|
696
|
+
workspaceId: e,
|
|
697
|
+
description: h("automation_field_dashboard_description")
|
|
698
|
+
})
|
|
699
|
+
})
|
|
700
|
+
})
|
|
701
|
+
}), /* @__PURE__ */ G("div", {
|
|
702
|
+
className: "flex flex-col gap-2",
|
|
703
|
+
children: [
|
|
704
|
+
/* @__PURE__ */ W(le, {
|
|
705
|
+
base: b,
|
|
706
|
+
onReload: f
|
|
707
|
+
}),
|
|
708
|
+
/* @__PURE__ */ W(O.FormErrorBanner, {}),
|
|
709
|
+
/* @__PURE__ */ W("div", {
|
|
710
|
+
className: "flex justify-end",
|
|
711
|
+
children: /* @__PURE__ */ W(O.SubmitButton, {
|
|
712
|
+
label: h(x == null ? "automation_create_submit" : "action_save"),
|
|
713
|
+
pendingLabel: h("action_saving")
|
|
714
|
+
})
|
|
715
|
+
})
|
|
716
|
+
]
|
|
717
|
+
})]
|
|
718
|
+
}) });
|
|
719
|
+
}
|
|
720
|
+
var Mt = 30;
|
|
721
|
+
function Nt(e, t) {
|
|
722
|
+
let n = t.span.from, r = e.lastIndexOf("\n", n - 1) + 1, i = e.indexOf("\n", n);
|
|
723
|
+
return {
|
|
724
|
+
line: String(e.slice(0, n).split("\n").length),
|
|
725
|
+
column: String(n - r + 1),
|
|
726
|
+
excerpt: e.slice(r, i === -1 ? e.length : i).trim(),
|
|
727
|
+
code: t.diagnostic?.code ?? "json_syntax",
|
|
728
|
+
path: t.diagnostic?.path ?? ""
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
function Pt({ actions: e, onApply: t }) {
|
|
732
|
+
return e.length === 0 ? null : /* @__PURE__ */ W("div", {
|
|
733
|
+
className: "flex flex-wrap gap-x-1 gap-y-0.5 pb-1 pl-8",
|
|
734
|
+
children: e.map((e, n) => /* @__PURE__ */ G(_, {
|
|
735
|
+
type: "button",
|
|
736
|
+
variant: "link",
|
|
737
|
+
size: "xs",
|
|
738
|
+
className: "h-auto max-w-full px-0 py-0.5 text-left text-xs whitespace-normal",
|
|
739
|
+
onClick: () => {
|
|
740
|
+
t(e);
|
|
741
|
+
},
|
|
742
|
+
children: [e.run !== void 0 && e.edit === void 0 ? /* @__PURE__ */ W(Ne, { "data-icon": "inline-start" }) : null, e.label]
|
|
743
|
+
}, n))
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
var Ft = [
|
|
747
|
+
"trigger",
|
|
748
|
+
"variable",
|
|
749
|
+
"procedure",
|
|
750
|
+
"field"
|
|
751
|
+
];
|
|
752
|
+
function It({ outline: e, onPick: t }) {
|
|
753
|
+
let n = l(), r = (e) => {
|
|
754
|
+
switch (e) {
|
|
755
|
+
case "trigger": return n("automation_outline_triggers");
|
|
756
|
+
case "variable": return n("automation_outline_variables");
|
|
757
|
+
case "procedure": return n("automation_outline_procedures");
|
|
758
|
+
case "field": return n("automation_outline_fields");
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
return /* @__PURE__ */ G(w, {
|
|
762
|
+
size: "sm",
|
|
763
|
+
"aria-label": n("automation_outline_label"),
|
|
764
|
+
value: "",
|
|
765
|
+
disabled: e.length === 0,
|
|
766
|
+
className: "\n w-full\n sm:w-72\n ",
|
|
767
|
+
onChange: (n) => {
|
|
768
|
+
let r = e[Number(n.target.value)];
|
|
769
|
+
r !== void 0 && t(r);
|
|
770
|
+
},
|
|
771
|
+
children: [/* @__PURE__ */ W(D, {
|
|
772
|
+
value: "",
|
|
773
|
+
children: n("automation_outline_placeholder")
|
|
774
|
+
}), Ft.map((t) => {
|
|
775
|
+
let n = e.map((e, t) => ({
|
|
776
|
+
item: e,
|
|
777
|
+
index: t
|
|
778
|
+
})).filter(({ item: e }) => e.kind === t);
|
|
779
|
+
return n.length === 0 ? null : /* @__PURE__ */ W(k, {
|
|
780
|
+
label: r(t),
|
|
781
|
+
children: n.map(({ item: e, index: t }) => /* @__PURE__ */ W(D, {
|
|
782
|
+
value: String(t),
|
|
783
|
+
children: e.detail === void 0 ? e.label : `${e.label} → ${e.detail}`
|
|
784
|
+
}, t))
|
|
785
|
+
}, t);
|
|
786
|
+
})]
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
function Lt({ problem: e }) {
|
|
790
|
+
return e.severity === "error" ? /* @__PURE__ */ W(Oe, { className: "mt-0.5 size-4 shrink-0 text-destructive" }) : /* @__PURE__ */ W(Fe, { className: "\n mt-0.5 size-4 shrink-0 text-amber-600\n dark:text-amber-400\n " });
|
|
791
|
+
}
|
|
792
|
+
function Rt({ text: n, savedText: r, original: i, locale: a, context: o, automationId: s, workspaceId: c, onText: u, editorRef: d, dashboardField: f, onDirtyChange: m, automationName: h }) {
|
|
793
|
+
let g = l(), _ = n !== r;
|
|
794
|
+
Ce(() => {
|
|
795
|
+
m?.(_);
|
|
796
|
+
}, [_, m]);
|
|
797
|
+
let v = Se(n), y = H(() => _t(v, o, s, (e) => qe(i, e, a)), [
|
|
798
|
+
v,
|
|
799
|
+
o,
|
|
800
|
+
s,
|
|
801
|
+
i,
|
|
802
|
+
a
|
|
803
|
+
]), b = ct(c), x = lt(c), S = H(() => He({
|
|
804
|
+
document: "automation",
|
|
805
|
+
context: Ve(o, s),
|
|
806
|
+
catalog: b
|
|
807
|
+
}), [
|
|
808
|
+
o,
|
|
809
|
+
s,
|
|
810
|
+
b
|
|
811
|
+
]), C = g("automation_language_docs"), w = H(() => [Qe(), t(_e(S, x, C))], [
|
|
812
|
+
S,
|
|
813
|
+
x,
|
|
814
|
+
C
|
|
815
|
+
]), { openAssistant: T } = e(), E = (e) => e.diagnostic === null ? g("automation_editor_json_syntax") : z(e.diagnostic), D = H(() => y.problems.map((e, t) => {
|
|
816
|
+
let n = T === void 0 ? [] : [{
|
|
817
|
+
label: g("automation_ask_assistant"),
|
|
818
|
+
run: () => {
|
|
819
|
+
T(g("automation_ask_assistant_message", {
|
|
820
|
+
...Nt(v, e),
|
|
821
|
+
automation: s === void 0 ? h : `${h} (${s})`,
|
|
822
|
+
problem: e.diagnostic === null ? g("automation_editor_json_syntax") : z(e.diagnostic)
|
|
823
|
+
}));
|
|
824
|
+
}
|
|
825
|
+
}];
|
|
826
|
+
return [...e.diagnostic === null || t >= Mt ? [] : ge(S, v, e.diagnostic), ...n];
|
|
827
|
+
}), [
|
|
828
|
+
y,
|
|
829
|
+
v,
|
|
830
|
+
S,
|
|
831
|
+
T,
|
|
832
|
+
h,
|
|
833
|
+
s,
|
|
834
|
+
g
|
|
835
|
+
]), O = H(() => y.problems.map((e, t) => ({
|
|
836
|
+
from: e.span.from,
|
|
837
|
+
to: e.span.to,
|
|
838
|
+
severity: e.severity,
|
|
839
|
+
message: e.diagnostic === null ? g("automation_editor_json_syntax") : z(e.diagnostic),
|
|
840
|
+
actions: D[t] ?? []
|
|
841
|
+
})), [
|
|
842
|
+
y,
|
|
843
|
+
D,
|
|
844
|
+
g
|
|
845
|
+
]), k = H(() => S.outline(v), [S, v]), A = y.problems.length - y.errorCount, j = (e, t) => {
|
|
846
|
+
d.current?.reveal(e, t);
|
|
847
|
+
}, N = o.limits.maxStepsPerRun, F = y.automation?.procedures ?? [];
|
|
848
|
+
return /* @__PURE__ */ G("div", {
|
|
849
|
+
className: "flex flex-col gap-4",
|
|
850
|
+
children: [/* @__PURE__ */ G("div", {
|
|
851
|
+
className: "\n grid grid-cols-1 gap-4\n lg:grid-cols-[minmax(0,1fr)_20rem]\n ",
|
|
852
|
+
children: [/* @__PURE__ */ G("div", {
|
|
853
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
854
|
+
children: [
|
|
855
|
+
/* @__PURE__ */ W(It, {
|
|
856
|
+
outline: k,
|
|
857
|
+
onPick: (e) => {
|
|
858
|
+
j(e.from, e.from);
|
|
859
|
+
}
|
|
860
|
+
}),
|
|
861
|
+
/* @__PURE__ */ W(ue, {
|
|
862
|
+
ref: d,
|
|
863
|
+
id: "automation-document",
|
|
864
|
+
ariaLabel: g("automation_editor_document"),
|
|
865
|
+
ariaDescribedBy: "automation-document-status",
|
|
866
|
+
value: n,
|
|
867
|
+
onChange: u,
|
|
868
|
+
extensions: w,
|
|
869
|
+
diagnostics: v === n ? O : kt,
|
|
870
|
+
invalid: y.errorCount > 0,
|
|
871
|
+
className: "h-[60vh] min-h-80"
|
|
872
|
+
}),
|
|
873
|
+
/* @__PURE__ */ G("p", {
|
|
874
|
+
id: "automation-document-status",
|
|
875
|
+
className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",
|
|
876
|
+
children: [
|
|
877
|
+
/* @__PURE__ */ W("span", { children: y.problems.length === 0 ? g("automation_editor_no_problems") : g("automation_editor_problem_counts", {
|
|
878
|
+
errors: String(y.errorCount),
|
|
879
|
+
warnings: String(A)
|
|
880
|
+
}) }),
|
|
881
|
+
n === r ? null : /* @__PURE__ */ W("span", { children: g("automation_editor_unsaved") }),
|
|
882
|
+
/* @__PURE__ */ W("span", { children: g("automation_editor_keyboard_hint") })
|
|
883
|
+
]
|
|
884
|
+
})
|
|
885
|
+
]
|
|
886
|
+
}), /* @__PURE__ */ G("div", {
|
|
887
|
+
className: "flex min-w-0 flex-col gap-4",
|
|
888
|
+
children: [
|
|
889
|
+
/* @__PURE__ */ G(M, {
|
|
890
|
+
size: "sm",
|
|
891
|
+
children: [/* @__PURE__ */ W(R, { children: /* @__PURE__ */ W(P, { children: g("automation_editor_problems") }) }), /* @__PURE__ */ W(L, { children: y.problems.length === 0 ? /* @__PURE__ */ G("p", {
|
|
892
|
+
className: "flex items-center gap-2 text-sm text-muted-foreground",
|
|
893
|
+
children: [/* @__PURE__ */ W(ke, { className: "\n size-4 text-emerald-600\n dark:text-emerald-400\n " }), g("automation_editor_no_problems")]
|
|
894
|
+
}) : /* @__PURE__ */ W("ul", {
|
|
895
|
+
className: "-mx-2 flex max-h-72 flex-col overflow-y-auto",
|
|
896
|
+
children: y.problems.map((e, t) => /* @__PURE__ */ G("li", { children: [/* @__PURE__ */ G("button", {
|
|
897
|
+
type: "button",
|
|
898
|
+
className: "\n flex w-full gap-2 rounded-md px-2 py-1.5 text-left text-sm\n hover:bg-muted\n focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none\n ",
|
|
899
|
+
onClick: () => {
|
|
900
|
+
j(e.span.from, e.span.to);
|
|
901
|
+
},
|
|
902
|
+
children: [/* @__PURE__ */ W(Lt, { problem: e }), /* @__PURE__ */ W("span", {
|
|
903
|
+
className: "min-w-0 wrap-break-word",
|
|
904
|
+
children: E(e)
|
|
905
|
+
})]
|
|
906
|
+
}), /* @__PURE__ */ W(Pt, {
|
|
907
|
+
actions: (D[t] ?? []).filter((e) => e.edit === void 0 || v === n),
|
|
908
|
+
onApply: (e) => {
|
|
909
|
+
let t = d.current;
|
|
910
|
+
if (e.edit !== void 0) {
|
|
911
|
+
if (t?.text() !== v) return;
|
|
912
|
+
t.apply(e.edit);
|
|
913
|
+
}
|
|
914
|
+
e.run?.();
|
|
915
|
+
}
|
|
916
|
+
})] }, t))
|
|
917
|
+
}) })]
|
|
918
|
+
}),
|
|
919
|
+
/* @__PURE__ */ G(M, {
|
|
920
|
+
size: "sm",
|
|
921
|
+
children: [/* @__PURE__ */ W(R, { children: /* @__PURE__ */ W(P, { children: g("automation_editor_step_budget") }) }), /* @__PURE__ */ G(L, {
|
|
922
|
+
className: "flex flex-col gap-2 text-sm",
|
|
923
|
+
children: [/* @__PURE__ */ W("p", {
|
|
924
|
+
className: "text-muted-foreground",
|
|
925
|
+
children: g("automation_editor_step_budget_description", { limit: String(N) })
|
|
926
|
+
}), F.length === 0 ? null : /* @__PURE__ */ W("dl", {
|
|
927
|
+
className: "grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1",
|
|
928
|
+
children: F.map((e) => {
|
|
929
|
+
let t = y.stepBudget.get(e.name);
|
|
930
|
+
return /* @__PURE__ */ G("div", {
|
|
931
|
+
className: "contents",
|
|
932
|
+
children: [/* @__PURE__ */ W("dt", {
|
|
933
|
+
className: "truncate font-mono",
|
|
934
|
+
children: e.name
|
|
935
|
+
}), /* @__PURE__ */ W("dd", {
|
|
936
|
+
className: p("text-right tabular-nums", t !== void 0 && t > N && "text-destructive"),
|
|
937
|
+
children: t === void 0 ? "—" : `${String(t)} / ${String(N)}`
|
|
938
|
+
})]
|
|
939
|
+
}, e.name);
|
|
940
|
+
})
|
|
941
|
+
})]
|
|
942
|
+
})]
|
|
943
|
+
}),
|
|
944
|
+
/* @__PURE__ */ G(M, {
|
|
945
|
+
size: "sm",
|
|
946
|
+
children: [/* @__PURE__ */ W(R, { children: /* @__PURE__ */ W(P, { children: g("automation_editor_limits") }) }), /* @__PURE__ */ W(L, { children: /* @__PURE__ */ G("dl", {
|
|
947
|
+
className: "grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1 text-sm",
|
|
948
|
+
children: [
|
|
949
|
+
/* @__PURE__ */ W("dt", {
|
|
950
|
+
className: "text-muted-foreground",
|
|
951
|
+
children: g("automation_limit_steps")
|
|
952
|
+
}),
|
|
953
|
+
/* @__PURE__ */ W("dd", {
|
|
954
|
+
className: "text-right tabular-nums",
|
|
955
|
+
children: o.limits.maxStepsPerRun
|
|
956
|
+
}),
|
|
957
|
+
/* @__PURE__ */ W("dt", {
|
|
958
|
+
className: "text-muted-foreground",
|
|
959
|
+
children: g("automation_limit_interval")
|
|
960
|
+
}),
|
|
961
|
+
/* @__PURE__ */ W("dd", {
|
|
962
|
+
className: "text-right tabular-nums",
|
|
963
|
+
children: g("automation_seconds", { seconds: At(o.limits.minTriggerIntervalMs) })
|
|
964
|
+
}),
|
|
965
|
+
/* @__PURE__ */ W("dt", {
|
|
966
|
+
className: "text-muted-foreground",
|
|
967
|
+
children: g("automation_limit_writes")
|
|
968
|
+
}),
|
|
969
|
+
/* @__PURE__ */ W("dd", {
|
|
970
|
+
className: "text-right tabular-nums",
|
|
971
|
+
children: o.limits.maxWritesPerMinute
|
|
972
|
+
})
|
|
973
|
+
]
|
|
974
|
+
}) })]
|
|
975
|
+
}),
|
|
976
|
+
f
|
|
977
|
+
]
|
|
978
|
+
})]
|
|
979
|
+
}), /* @__PURE__ */ W(Ot, {
|
|
980
|
+
workspaceId: c,
|
|
981
|
+
automationId: s,
|
|
982
|
+
automation: y.errorCount === 0 ? y.automation : null,
|
|
983
|
+
onReveal: (e) => {
|
|
984
|
+
let t = X(J(n), n, e);
|
|
985
|
+
j(t.from, t.to);
|
|
986
|
+
}
|
|
987
|
+
})]
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
// src/workspace/setup/automations/history.tsx
|
|
991
|
+
var zt = 50;
|
|
992
|
+
function Bt(e) {
|
|
993
|
+
return e < 1e3 ? `${String(e)} µs` : `${(e / 1e3).toFixed(e < 1e4 ? 2 : 0)} ms`;
|
|
994
|
+
}
|
|
995
|
+
function Vt({ automationId: e, workspaceId: t, run: n, procedures: r, onReveal: i, sameVersion: s }) {
|
|
996
|
+
let c = l(), u = vt(t), d = o.automation.runTrace.useQuery({
|
|
997
|
+
id: e,
|
|
998
|
+
runId: n.runId
|
|
999
|
+
});
|
|
1000
|
+
if (d.isPending) return /* @__PURE__ */ W(C, { className: "h-24 w-full" });
|
|
1001
|
+
if (d.isError) return /* @__PURE__ */ W(B, { message: a(d.error) });
|
|
1002
|
+
let { inputs: f, steps: p } = d.data;
|
|
1003
|
+
return f === null && p.length === 0 ? /* @__PURE__ */ W("p", {
|
|
1004
|
+
className: "text-sm text-muted-foreground",
|
|
1005
|
+
children: n.steps === 0 ? c("automation_run_no_steps") : c("automation_run_trace_expired")
|
|
1006
|
+
}) : /* @__PURE__ */ G("div", {
|
|
1007
|
+
className: "flex flex-col gap-4",
|
|
1008
|
+
children: [f === null ? null : /* @__PURE__ */ G("section", {
|
|
1009
|
+
className: "flex flex-col gap-2",
|
|
1010
|
+
children: [/* @__PURE__ */ W("h4", {
|
|
1011
|
+
className: "text-sm font-medium",
|
|
1012
|
+
children: c("automation_run_inputs")
|
|
1013
|
+
}), /* @__PURE__ */ W(Q, {
|
|
1014
|
+
values: f,
|
|
1015
|
+
empty: c("automation_run_no_inputs")
|
|
1016
|
+
})]
|
|
1017
|
+
}), /* @__PURE__ */ G("section", {
|
|
1018
|
+
className: "flex flex-col gap-2",
|
|
1019
|
+
children: [
|
|
1020
|
+
/* @__PURE__ */ W("h4", {
|
|
1021
|
+
className: "text-sm font-medium",
|
|
1022
|
+
children: c("automation_run_steps")
|
|
1023
|
+
}),
|
|
1024
|
+
p.length === 0 ? /* @__PURE__ */ W("p", {
|
|
1025
|
+
className: "text-sm text-muted-foreground",
|
|
1026
|
+
children: c("automation_run_no_steps")
|
|
1027
|
+
}) : /* @__PURE__ */ W(Tt, {
|
|
1028
|
+
steps: p,
|
|
1029
|
+
procedures: s ? r : [],
|
|
1030
|
+
parameterName: u,
|
|
1031
|
+
...i === void 0 ? {} : { onReveal: i }
|
|
1032
|
+
}),
|
|
1033
|
+
s ? null : /* @__PURE__ */ W("p", {
|
|
1034
|
+
className: "text-xs text-muted-foreground",
|
|
1035
|
+
children: c("automation_run_earlier_version")
|
|
1036
|
+
}),
|
|
1037
|
+
n.traceTruncated ? /* @__PURE__ */ W("p", {
|
|
1038
|
+
className: "text-xs text-muted-foreground",
|
|
1039
|
+
children: c("automation_run_trace_truncated", { steps: String(n.steps) })
|
|
1040
|
+
}) : null
|
|
1041
|
+
]
|
|
1042
|
+
})]
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
function Ht({ automationId: e, workspaceId: t, run: n, procedures: r, onReveal: i, savedRevision: a, editorShowsSaved: o }) {
|
|
1046
|
+
let s = l(), [c, u] = U(!1), d = n.procedure === "";
|
|
1047
|
+
return /* @__PURE__ */ G(ee, {
|
|
1048
|
+
open: c,
|
|
1049
|
+
onOpenChange: u,
|
|
1050
|
+
render: /* @__PURE__ */ W("li", {}),
|
|
1051
|
+
children: [/* @__PURE__ */ G(F, {
|
|
1052
|
+
className: "\n flex w-full items-start gap-2 px-3 py-2 text-left text-sm\n hover:bg-muted/40\n focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none\n ",
|
|
1053
|
+
children: [/* @__PURE__ */ W(De, { className: p("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform", c && "rotate-90") }), /* @__PURE__ */ G("div", {
|
|
1054
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
1055
|
+
children: [
|
|
1056
|
+
/* @__PURE__ */ G("div", {
|
|
1057
|
+
className: "flex flex-wrap items-center gap-x-3 gap-y-1",
|
|
1058
|
+
children: [
|
|
1059
|
+
/* @__PURE__ */ W("span", {
|
|
1060
|
+
className: "tabular-nums",
|
|
1061
|
+
children: Le(n.startedAt)
|
|
1062
|
+
}),
|
|
1063
|
+
/* @__PURE__ */ W(A, {
|
|
1064
|
+
variant: n.status === "ok" ? "success" : "destructive",
|
|
1065
|
+
children: n.status === "ok" ? s("automation_run_ok") : s("automation_run_failed")
|
|
1066
|
+
}),
|
|
1067
|
+
/* @__PURE__ */ W("span", {
|
|
1068
|
+
className: "min-w-0 truncate text-muted-foreground",
|
|
1069
|
+
children: pe(n.triggerKind, n.trigger)
|
|
1070
|
+
}),
|
|
1071
|
+
d ? null : /* @__PURE__ */ W("span", {
|
|
1072
|
+
className: "font-mono text-xs",
|
|
1073
|
+
children: n.procedure
|
|
1074
|
+
})
|
|
1075
|
+
]
|
|
1076
|
+
}),
|
|
1077
|
+
d ? null : /* @__PURE__ */ G("div", {
|
|
1078
|
+
className: "flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",
|
|
1079
|
+
children: [
|
|
1080
|
+
/* @__PURE__ */ W("span", { children: s("automation_run_duration", { duration: Bt(n.durationUs) }) }),
|
|
1081
|
+
/* @__PURE__ */ W("span", { children: s("automation_run_step_count", { steps: String(n.steps) }) }),
|
|
1082
|
+
/* @__PURE__ */ W("span", { children: s("automation_run_write_count", { writes: String(n.writes) }) }),
|
|
1083
|
+
n.writesLimited > 0 ? /* @__PURE__ */ W("span", {
|
|
1084
|
+
className: "text-destructive",
|
|
1085
|
+
children: s("automation_run_limited_count", { writes: String(n.writesLimited) })
|
|
1086
|
+
}) : null,
|
|
1087
|
+
/* @__PURE__ */ W("span", { children: s("automation_run_notification_count", { notifications: String(n.notifications) }) })
|
|
1088
|
+
]
|
|
1089
|
+
}),
|
|
1090
|
+
n.errorCode === null ? null : /* @__PURE__ */ W("p", {
|
|
1091
|
+
className: "text-destructive",
|
|
1092
|
+
children: he(n.errorCode, n.error)
|
|
1093
|
+
})
|
|
1094
|
+
]
|
|
1095
|
+
})]
|
|
1096
|
+
}), /* @__PURE__ */ W(I, {
|
|
1097
|
+
className: "\n border-t bg-muted/20 p-3\n sm:pl-9\n ",
|
|
1098
|
+
children: c ? /* @__PURE__ */ W(Vt, {
|
|
1099
|
+
automationId: e,
|
|
1100
|
+
workspaceId: t,
|
|
1101
|
+
run: n,
|
|
1102
|
+
procedures: r,
|
|
1103
|
+
sameVersion: n.revision === a,
|
|
1104
|
+
onReveal: n.revision === a && o ? i : void 0
|
|
1105
|
+
}) : null
|
|
1106
|
+
})]
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
function Ut({ workspaceId: e, automationId: t, document: n, savedRevision: r, editorShowsSaved: i, onReveal: s }) {
|
|
1110
|
+
let c = l(), [u, f] = U(!1), [p, m] = U(null), [y, x] = U(!1), [w, T] = U(null), E = o.useUtils(), D = o.automation.runs.useQuery({
|
|
1111
|
+
id: t,
|
|
1112
|
+
failedOnly: u,
|
|
1113
|
+
limit: zt
|
|
1114
|
+
}), O = yt(n), k = Te(0), A = () => {
|
|
1115
|
+
k.current += 1, m(null), T(null), x(!1);
|
|
1116
|
+
}, j = D.data?.next ?? null, M = j === null ? "" : `${j.startedAt}|${j.runId}`, N = p?.after === M ? p : null, P = N === null ? j : N.next, F = [...D.data?.items ?? [], ...N?.items ?? []];
|
|
1117
|
+
return /* @__PURE__ */ G("div", {
|
|
1118
|
+
className: "flex flex-col gap-3",
|
|
1119
|
+
children: [
|
|
1120
|
+
/* @__PURE__ */ G("div", {
|
|
1121
|
+
className: "flex flex-wrap items-center justify-between gap-2",
|
|
1122
|
+
children: [/* @__PURE__ */ W("p", {
|
|
1123
|
+
className: "text-sm text-muted-foreground",
|
|
1124
|
+
children: c("automation_history_description")
|
|
1125
|
+
}), /* @__PURE__ */ G("div", {
|
|
1126
|
+
className: "flex items-center gap-3",
|
|
1127
|
+
children: [/* @__PURE__ */ G("label", {
|
|
1128
|
+
className: "flex items-center gap-2 text-sm",
|
|
1129
|
+
children: [/* @__PURE__ */ W(d, {
|
|
1130
|
+
size: "sm",
|
|
1131
|
+
checked: u,
|
|
1132
|
+
onCheckedChange: (e) => {
|
|
1133
|
+
f(e), A();
|
|
1134
|
+
}
|
|
1135
|
+
}), c("automation_history_failed_only")]
|
|
1136
|
+
}), /* @__PURE__ */ G(_, {
|
|
1137
|
+
type: "button",
|
|
1138
|
+
variant: "outline",
|
|
1139
|
+
size: "sm",
|
|
1140
|
+
disabled: D.isFetching,
|
|
1141
|
+
onClick: () => {
|
|
1142
|
+
A(), D.refetch();
|
|
1143
|
+
},
|
|
1144
|
+
children: [/* @__PURE__ */ W(Me, { "data-icon": "inline-start" }), c("automation_history_refresh")]
|
|
1145
|
+
})]
|
|
1146
|
+
})]
|
|
1147
|
+
}),
|
|
1148
|
+
D.isPending ? /* @__PURE__ */ G("div", {
|
|
1149
|
+
className: "flex flex-col gap-2",
|
|
1150
|
+
children: [/* @__PURE__ */ W(C, { className: "h-12 w-full" }), /* @__PURE__ */ W(C, { className: "h-12 w-full" })]
|
|
1151
|
+
}) : D.isError ? /* @__PURE__ */ W(B, { message: a(D.error) }) : F.length === 0 ? /* @__PURE__ */ W(h, {
|
|
1152
|
+
className: "border",
|
|
1153
|
+
children: /* @__PURE__ */ G(g, { children: [
|
|
1154
|
+
/* @__PURE__ */ W(v, {
|
|
1155
|
+
variant: "icon",
|
|
1156
|
+
children: /* @__PURE__ */ W(je, {})
|
|
1157
|
+
}),
|
|
1158
|
+
/* @__PURE__ */ W(S, { children: c("automation_history_empty_title") }),
|
|
1159
|
+
/* @__PURE__ */ W(b, { children: c("automation_history_empty_description") })
|
|
1160
|
+
] })
|
|
1161
|
+
}) : /* @__PURE__ */ W("ul", {
|
|
1162
|
+
className: "divide-y rounded-lg border bg-card",
|
|
1163
|
+
children: F.map((n) => /* @__PURE__ */ W(Ht, {
|
|
1164
|
+
automationId: t,
|
|
1165
|
+
workspaceId: e,
|
|
1166
|
+
run: n,
|
|
1167
|
+
procedures: O,
|
|
1168
|
+
onReveal: s,
|
|
1169
|
+
savedRevision: r,
|
|
1170
|
+
editorShowsSaved: i
|
|
1171
|
+
}, n.runId))
|
|
1172
|
+
}),
|
|
1173
|
+
w === null ? null : /* @__PURE__ */ W(B, { message: a(w) }),
|
|
1174
|
+
P === null || D.isPending ? null : /* @__PURE__ */ W(_, {
|
|
1175
|
+
type: "button",
|
|
1176
|
+
variant: "outline",
|
|
1177
|
+
className: "self-center",
|
|
1178
|
+
disabled: y,
|
|
1179
|
+
onClick: () => {
|
|
1180
|
+
let e = k.current, n = M, r = () => k.current === e;
|
|
1181
|
+
x(!0), T(null), E.client.automation.runs.query({
|
|
1182
|
+
id: t,
|
|
1183
|
+
failedOnly: u,
|
|
1184
|
+
limit: zt,
|
|
1185
|
+
before: P
|
|
1186
|
+
}).then((e) => {
|
|
1187
|
+
r() && m((t) => ({
|
|
1188
|
+
after: n,
|
|
1189
|
+
items: [...t?.after === n ? t.items : [], ...e.items],
|
|
1190
|
+
next: e.next
|
|
1191
|
+
}));
|
|
1192
|
+
}, (e) => {
|
|
1193
|
+
r() && T(e);
|
|
1194
|
+
}).finally(() => {
|
|
1195
|
+
r() && x(!1);
|
|
1196
|
+
});
|
|
1197
|
+
},
|
|
1198
|
+
children: c("automation_history_older")
|
|
1199
|
+
})
|
|
1200
|
+
]
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
// src/workspace/setup/automations/editor-page.tsx
|
|
1204
|
+
function Wt({ workspaceId: e, automationId: t, tab: n = "editor", onTabChange: r, onCreated: i, starterHandoff: s }) {
|
|
1205
|
+
let d = l(), h = u(), g = c(), v = Ye(), y = o.useUtils(), b = Te(null), [x, S] = U(0), [w, T] = U(!1), [E, D] = U(!1), O = t != null, [k] = U(() => O ? void 0 : ve(s)), A = o.automation.validationContext.useQuery({ workspaceId: e }), j = o.automation.get.useQuery({ id: t ?? "" }, { enabled: O }), M = A.data, N = j.data, P = M != null && (!O || N != null), F = {
|
|
1206
|
+
isLoading: A.isLoading || O && j.isLoading,
|
|
1207
|
+
isError: !P && (A.isError || O && j.isError),
|
|
1208
|
+
error: O ? j.error : A.error,
|
|
1209
|
+
data: P ? {
|
|
1210
|
+
context: M,
|
|
1211
|
+
detail: N
|
|
1212
|
+
} : void 0
|
|
1213
|
+
}, ee = P && (A.isError || O && j.isError), I = O ? n : "editor", L = () => {
|
|
1214
|
+
v({
|
|
1215
|
+
to: "/workspace/$workspaceId/setup/automations",
|
|
1216
|
+
params: { workspaceId: e }
|
|
1217
|
+
});
|
|
1218
|
+
};
|
|
1219
|
+
return /* @__PURE__ */ G("div", {
|
|
1220
|
+
className: "flex size-full min-h-0 flex-col",
|
|
1221
|
+
children: [
|
|
1222
|
+
/* @__PURE__ */ W(ne, {
|
|
1223
|
+
icon: /* @__PURE__ */ W(Ie, {}),
|
|
1224
|
+
breadcrumbs: /* @__PURE__ */ W(se, {
|
|
1225
|
+
workspaceId: e,
|
|
1226
|
+
section: "automations"
|
|
1227
|
+
}),
|
|
1228
|
+
title: N == null ? d("automation_create_title") : q(N.name, g),
|
|
1229
|
+
actions: N == null ? null : /* @__PURE__ */ G("div", {
|
|
1230
|
+
className: "flex items-center gap-2",
|
|
1231
|
+
children: [/* @__PURE__ */ W(ye, {
|
|
1232
|
+
workspaceId: e,
|
|
1233
|
+
entity: N,
|
|
1234
|
+
kind: "automation"
|
|
1235
|
+
}), /* @__PURE__ */ W(_, {
|
|
1236
|
+
type: "button",
|
|
1237
|
+
variant: "ghost",
|
|
1238
|
+
size: "icon-sm",
|
|
1239
|
+
"aria-label": d("automation_delete_action"),
|
|
1240
|
+
onClick: () => {
|
|
1241
|
+
T(!0);
|
|
1242
|
+
},
|
|
1243
|
+
children: /* @__PURE__ */ W(Pe, {})
|
|
1244
|
+
})]
|
|
1245
|
+
})
|
|
1246
|
+
}),
|
|
1247
|
+
/* @__PURE__ */ W("div", {
|
|
1248
|
+
className: "flex w-full max-w-7xl flex-1 flex-col gap-4 p-4",
|
|
1249
|
+
children: /* @__PURE__ */ W(oe, {
|
|
1250
|
+
query: F,
|
|
1251
|
+
loading: /* @__PURE__ */ G("div", {
|
|
1252
|
+
className: "flex flex-col gap-4",
|
|
1253
|
+
children: [/* @__PURE__ */ W(C, { className: "h-8 w-64" }), /* @__PURE__ */ W(C, { className: "h-96 w-full" })]
|
|
1254
|
+
}),
|
|
1255
|
+
error: (e) => /* @__PURE__ */ W(ae, {
|
|
1256
|
+
className: "flex-1 justify-center p-8",
|
|
1257
|
+
message: a(e ?? "automation_not_found"),
|
|
1258
|
+
onRetry: () => Promise.all([A.refetch(), j.refetch()])
|
|
1259
|
+
}),
|
|
1260
|
+
children: (n) => /* @__PURE__ */ G(Ee, { children: [
|
|
1261
|
+
ee ? /* @__PURE__ */ W(B, {
|
|
1262
|
+
message: a(j.error ?? A.error),
|
|
1263
|
+
onRetry: () => Promise.all([A.refetch(), j.refetch()])
|
|
1264
|
+
}) : null,
|
|
1265
|
+
O ? /* @__PURE__ */ W(ie, {
|
|
1266
|
+
value: I,
|
|
1267
|
+
onValueChange: (e) => {
|
|
1268
|
+
(e === "editor" || e === "history") && r?.(e);
|
|
1269
|
+
},
|
|
1270
|
+
children: /* @__PURE__ */ G(re, {
|
|
1271
|
+
variant: "line",
|
|
1272
|
+
children: [/* @__PURE__ */ W(te, {
|
|
1273
|
+
value: "editor",
|
|
1274
|
+
children: d("automation_tab_editor")
|
|
1275
|
+
}), /* @__PURE__ */ W(te, {
|
|
1276
|
+
value: "history",
|
|
1277
|
+
children: d("automation_tab_history")
|
|
1278
|
+
})]
|
|
1279
|
+
})
|
|
1280
|
+
}) : null,
|
|
1281
|
+
/* @__PURE__ */ W("div", {
|
|
1282
|
+
className: p(I !== "editor" && "hidden"),
|
|
1283
|
+
children: /* @__PURE__ */ W(jt, {
|
|
1284
|
+
onDirtyChange: D,
|
|
1285
|
+
...k === void 0 ? {} : { starter: k },
|
|
1286
|
+
workspaceId: e,
|
|
1287
|
+
detail: n.detail,
|
|
1288
|
+
context: n.context,
|
|
1289
|
+
editorRef: b,
|
|
1290
|
+
...i == null ? {} : { onCreated: i },
|
|
1291
|
+
onReload: async () => {
|
|
1292
|
+
if (t == null) return;
|
|
1293
|
+
let e = await y.client.automation.get.query({ id: t });
|
|
1294
|
+
y.automation.get.setData({ id: t }, e), S((e) => e + 1);
|
|
1295
|
+
}
|
|
1296
|
+
}, `${t ?? "new"}-${String(x)}`)
|
|
1297
|
+
}),
|
|
1298
|
+
O && I === "history" && n.detail != null ? /* @__PURE__ */ W(Ut, {
|
|
1299
|
+
workspaceId: e,
|
|
1300
|
+
automationId: n.detail.id,
|
|
1301
|
+
document: n.detail.document,
|
|
1302
|
+
savedRevision: n.detail.revision,
|
|
1303
|
+
editorShowsSaved: !E,
|
|
1304
|
+
onReveal: (e) => {
|
|
1305
|
+
r?.("editor"), requestAnimationFrame(() => {
|
|
1306
|
+
let t = b.current;
|
|
1307
|
+
if (t == null) return;
|
|
1308
|
+
let n = t.text(), r = X(J(n), n, e);
|
|
1309
|
+
t.reveal(r.from, r.to);
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
}) : null
|
|
1313
|
+
] })
|
|
1314
|
+
})
|
|
1315
|
+
}),
|
|
1316
|
+
/* @__PURE__ */ W(m, {
|
|
1317
|
+
open: w && N != null,
|
|
1318
|
+
onOpenChange: (e) => {
|
|
1319
|
+
e || T(!1);
|
|
1320
|
+
},
|
|
1321
|
+
children: /* @__PURE__ */ W(f, { children: N == null ? null : /* @__PURE__ */ W(be, {
|
|
1322
|
+
workspaceId: e,
|
|
1323
|
+
kind: "automation",
|
|
1324
|
+
id: N.id,
|
|
1325
|
+
baseRevision: N.revision,
|
|
1326
|
+
onCancel: () => {
|
|
1327
|
+
T(!1);
|
|
1328
|
+
},
|
|
1329
|
+
onDeleted: () => {
|
|
1330
|
+
T(!1), h.success(d("automation_delete_toast")), L();
|
|
1331
|
+
}
|
|
1332
|
+
}) })
|
|
1333
|
+
})
|
|
1334
|
+
]
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
export { Wt as SetupAutomationEditorPage };
|