@burdenoff/microfe-bigconsole 2026.1004.7 → 2026.1004.8
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/bigconsole/BigConsoleRoutes.d.ts.map +1 -1
- package/dist/bigconsole/BigConsoleRoutes.js +35 -31
- package/dist/bigconsole/BigConsoleRoutes.js.map +1 -1
- package/dist/bigconsole/components/datasink/AlertExecutionHistory.d.ts +11 -0
- package/dist/bigconsole/components/datasink/AlertExecutionHistory.d.ts.map +1 -0
- package/dist/bigconsole/components/datasink/AlertExecutionHistory.js +248 -0
- package/dist/bigconsole/components/datasink/AlertExecutionHistory.js.map +1 -0
- package/dist/bigconsole/components/datasink/AlertRuleEditor.d.ts +23 -0
- package/dist/bigconsole/components/datasink/AlertRuleEditor.d.ts.map +1 -0
- package/dist/bigconsole/components/datasink/AlertRuleEditor.js +357 -0
- package/dist/bigconsole/components/datasink/AlertRuleEditor.js.map +1 -0
- package/dist/bigconsole/hooks/useDataSinkAlerts.d.ts +146 -0
- package/dist/bigconsole/hooks/useDataSinkAlerts.d.ts.map +1 -0
- package/dist/bigconsole/hooks/useDataSinkAlerts.js +221 -0
- package/dist/bigconsole/hooks/useDataSinkAlerts.js.map +1 -0
- package/dist/bigconsole/pages/DataSinkAlertsPage.d.ts +2 -0
- package/dist/bigconsole/pages/DataSinkAlertsPage.d.ts.map +1 -0
- package/dist/bigconsole/pages/DataSinkAlertsPage.js +422 -0
- package/dist/bigconsole/pages/DataSinkAlertsPage.js.map +1 -0
- package/dist/bigconsole/pages/DataSinkViewPage.d.ts.map +1 -1
- package/dist/bigconsole/pages/DataSinkViewPage.js +235 -229
- package/dist/bigconsole/pages/DataSinkViewPage.js.map +1 -1
- package/dist/bigconsole/utils/alertRules.d.ts +40 -0
- package/dist/bigconsole/utils/alertRules.d.ts.map +1 -0
- package/dist/bigconsole/utils/alertRules.js +83 -0
- package/dist/bigconsole/utils/alertRules.js.map +1 -0
- package/dist/generated/wspace-operations.d.ts +376 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +321 -200
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +122 -0
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +7 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AlertChannel, AlertPreview } from '../../hooks/useDataSinkAlerts';
|
|
2
|
+
import { AlertDraft } from '../../utils/alertRules';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
draft: AlertDraft;
|
|
6
|
+
channels: AlertChannel[];
|
|
7
|
+
channelError: string | null;
|
|
8
|
+
canUpdate: boolean;
|
|
9
|
+
pending: boolean;
|
|
10
|
+
previewing: boolean;
|
|
11
|
+
preview: AlertPreview | null;
|
|
12
|
+
previewError: string | null;
|
|
13
|
+
previewStale: boolean;
|
|
14
|
+
error: string | null;
|
|
15
|
+
onChange: (draft: AlertDraft) => void;
|
|
16
|
+
onSave: () => void;
|
|
17
|
+
onCancel: () => void;
|
|
18
|
+
onPreview: () => void;
|
|
19
|
+
onReloadChannels: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function AlertRuleEditor(props: Props): import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=AlertRuleEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlertRuleEditor.d.ts","sourceRoot":"","sources":["../../../../src/bigconsole/components/datasink/AlertRuleEditor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,UAAU,KAAK;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,+BAgY3C"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { SECTION_FOCUS_RING as e } from "../common/sectionStyles.js";
|
|
2
|
+
import { Section as t } from "../common/Section.js";
|
|
3
|
+
import "../common/index.js";
|
|
4
|
+
import { AlertSeverity as n, DataSinkAlertChannel as r, DataSinkAlertConditionType as i } from "../../../generated/wspace-types.js";
|
|
5
|
+
import { Loader2 as a, Play as o, Plus as s, Save as c, Trash2 as l } from "lucide-react";
|
|
6
|
+
import { Button as u } from "@burdenoff/fe-libs/ui";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
+
import { useI18n as p } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
9
|
+
//#region src/bigconsole/components/datasink/AlertRuleEditor.tsx
|
|
10
|
+
var m = `w-full min-w-0 rounded-control border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary ${e}`;
|
|
11
|
+
function h(h) {
|
|
12
|
+
let { t: g } = p(), { draft: _, channels: v, channelError: y, canUpdate: b, pending: x, previewing: S, preview: C, previewError: w, previewStale: T, error: E, onChange: D, onSave: O, onCancel: k, onPreview: A, onReloadChannels: j } = h, M = x || !b, N = v.filter((e) => e.status.toUpperCase() === "ACTIVE"), P = (e) => D({
|
|
13
|
+
..._,
|
|
14
|
+
...e
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ d(t, {
|
|
17
|
+
title: g("bigconsole.alerts.rule.title", "Alert rule"),
|
|
18
|
+
headingLevel: 2,
|
|
19
|
+
emphasis: "primary",
|
|
20
|
+
children: /* @__PURE__ */ f("form", {
|
|
21
|
+
onSubmit: (e) => {
|
|
22
|
+
e.preventDefault(), O();
|
|
23
|
+
},
|
|
24
|
+
className: "flex min-w-0 flex-col gap-form-gap",
|
|
25
|
+
"aria-label": g("bigconsole.alerts.rule.form", "Alert rule editor"),
|
|
26
|
+
children: [
|
|
27
|
+
!b && /* @__PURE__ */ d("p", {
|
|
28
|
+
className: "text-sm text-text-secondary",
|
|
29
|
+
children: g("bigconsole.alerts.rule.readOnly", "You have read-only access to these alert rules.")
|
|
30
|
+
}),
|
|
31
|
+
E && /* @__PURE__ */ d("p", {
|
|
32
|
+
role: "alert",
|
|
33
|
+
className: "break-words text-sm text-status-error-text",
|
|
34
|
+
children: E
|
|
35
|
+
}),
|
|
36
|
+
/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
|
|
37
|
+
htmlFor: "alert-name",
|
|
38
|
+
className: "mb-1 block text-sm font-medium text-text-primary",
|
|
39
|
+
children: g("bigconsole.alerts.rule.name", "Name")
|
|
40
|
+
}), /* @__PURE__ */ d("input", {
|
|
41
|
+
id: "alert-name",
|
|
42
|
+
className: m,
|
|
43
|
+
value: _.name,
|
|
44
|
+
onChange: (e) => P({ name: e.target.value }),
|
|
45
|
+
required: !0,
|
|
46
|
+
maxLength: 200,
|
|
47
|
+
disabled: M
|
|
48
|
+
})] }),
|
|
49
|
+
/* @__PURE__ */ f("div", {
|
|
50
|
+
className: "grid min-w-0 gap-form-gap sm:grid-cols-2",
|
|
51
|
+
children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
|
|
52
|
+
htmlFor: "alert-condition-type",
|
|
53
|
+
className: "mb-1 block text-sm font-medium text-text-primary",
|
|
54
|
+
children: g("bigconsole.alerts.rule.language", "Condition language")
|
|
55
|
+
}), /* @__PURE__ */ f("select", {
|
|
56
|
+
id: "alert-condition-type",
|
|
57
|
+
className: m,
|
|
58
|
+
value: _.conditionType,
|
|
59
|
+
onChange: (e) => P({ conditionType: e.target.value === i.Jsonata ? i.Jsonata : i.Jq }),
|
|
60
|
+
disabled: M,
|
|
61
|
+
children: [/* @__PURE__ */ d("option", {
|
|
62
|
+
value: i.Jq,
|
|
63
|
+
children: "JQ"
|
|
64
|
+
}), /* @__PURE__ */ d("option", {
|
|
65
|
+
value: i.Jsonata,
|
|
66
|
+
children: "JSONata"
|
|
67
|
+
})]
|
|
68
|
+
})] }), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
|
|
69
|
+
htmlFor: "alert-severity",
|
|
70
|
+
className: "mb-1 block text-sm font-medium text-text-primary",
|
|
71
|
+
children: g("bigconsole.alerts.rule.severity", "Severity")
|
|
72
|
+
}), /* @__PURE__ */ d("select", {
|
|
73
|
+
id: "alert-severity",
|
|
74
|
+
className: m,
|
|
75
|
+
value: _.severity,
|
|
76
|
+
onChange: (e) => P({ severity: Object.values(n).find((t) => t === e.target.value) ?? n.Medium }),
|
|
77
|
+
disabled: M,
|
|
78
|
+
children: Object.values(n).map((e) => /* @__PURE__ */ d("option", {
|
|
79
|
+
value: e,
|
|
80
|
+
children: g(`bigconsole.alerts.severity.${e}`, e.charAt(0).toUpperCase() + e.slice(1))
|
|
81
|
+
}, e))
|
|
82
|
+
})] })]
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ f("div", { children: [
|
|
85
|
+
/* @__PURE__ */ d("label", {
|
|
86
|
+
htmlFor: "alert-condition",
|
|
87
|
+
className: "mb-1 block text-sm font-medium text-text-primary",
|
|
88
|
+
children: g("bigconsole.alerts.rule.condition", "Condition")
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ d("textarea", {
|
|
91
|
+
id: "alert-condition",
|
|
92
|
+
className: `${m} min-h-32 font-mono`,
|
|
93
|
+
value: _.condition,
|
|
94
|
+
onChange: (e) => P({ condition: e.target.value }),
|
|
95
|
+
rows: 5,
|
|
96
|
+
required: !0,
|
|
97
|
+
disabled: M,
|
|
98
|
+
"aria-describedby": "alert-condition-help"
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ d("p", {
|
|
101
|
+
id: "alert-condition-help",
|
|
102
|
+
className: "mt-2 text-xs text-text-secondary",
|
|
103
|
+
children: g("bigconsole.alerts.rule.conditionHelp", "Evaluates the entire current sink payload and must return one boolean. Preview does not send notifications.")
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ d("p", {
|
|
106
|
+
className: "mt-1 break-words text-xs text-text-muted",
|
|
107
|
+
children: _.conditionType === i.Jq ? "JQ: any(.[]; .boarding_minutes > 240)" : "JSONata: $count($[boarding_minutes > 240]) > 0"
|
|
108
|
+
}),
|
|
109
|
+
/* @__PURE__ */ f(u, {
|
|
110
|
+
type: "button",
|
|
111
|
+
variant: "secondary",
|
|
112
|
+
size: "sm",
|
|
113
|
+
onClick: A,
|
|
114
|
+
disabled: x || S || !_.condition.trim(),
|
|
115
|
+
className: "mt-3",
|
|
116
|
+
children: [S ? /* @__PURE__ */ d(a, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ d(o, { className: "mr-2 h-4 w-4" }), S ? g("bigconsole.alerts.rule.previewing", "Evaluating…") : g("bigconsole.alerts.rule.preview", "Preview condition")]
|
|
117
|
+
}),
|
|
118
|
+
w && /* @__PURE__ */ d("p", {
|
|
119
|
+
role: "alert",
|
|
120
|
+
className: "mt-2 break-words text-sm text-status-error-text",
|
|
121
|
+
children: w
|
|
122
|
+
}),
|
|
123
|
+
T && /* @__PURE__ */ d("p", {
|
|
124
|
+
role: "status",
|
|
125
|
+
className: "mt-2 text-xs text-text-secondary",
|
|
126
|
+
children: g("bigconsole.alerts.rule.previewStale", "The condition or data changed. Preview again to see the current result.")
|
|
127
|
+
}),
|
|
128
|
+
C && !T && /* @__PURE__ */ f("div", {
|
|
129
|
+
role: "status",
|
|
130
|
+
className: "mt-3 rounded-control border border-border-subtle bg-bg-sunken p-3 text-sm",
|
|
131
|
+
children: [C.error ? /* @__PURE__ */ d("p", {
|
|
132
|
+
className: "break-words text-status-error-text",
|
|
133
|
+
children: C.error
|
|
134
|
+
}) : /* @__PURE__ */ d("p", {
|
|
135
|
+
className: "font-medium text-text-primary",
|
|
136
|
+
children: C.matched ? g("bigconsole.alerts.rule.matched", "Condition matched") : g("bigconsole.alerts.rule.noMatch", "Condition did not match")
|
|
137
|
+
}), /* @__PURE__ */ f("p", {
|
|
138
|
+
className: "mt-1 text-xs text-text-secondary",
|
|
139
|
+
children: [
|
|
140
|
+
g("bigconsole.alerts.rule.previewMetadata", "Evaluated data version"),
|
|
141
|
+
" ",
|
|
142
|
+
C.version,
|
|
143
|
+
" ·",
|
|
144
|
+
" ",
|
|
145
|
+
C.durationMs,
|
|
146
|
+
" ms"
|
|
147
|
+
]
|
|
148
|
+
})]
|
|
149
|
+
})
|
|
150
|
+
] }),
|
|
151
|
+
/* @__PURE__ */ f("fieldset", {
|
|
152
|
+
disabled: M,
|
|
153
|
+
className: "min-w-0",
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ d("legend", {
|
|
156
|
+
className: "mb-2 text-sm font-medium text-text-primary",
|
|
157
|
+
children: g("bigconsole.alerts.rule.destinations", "Delivery destinations")
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ d("p", {
|
|
160
|
+
className: "mb-3 text-xs text-text-secondary",
|
|
161
|
+
children: g("bigconsole.alerts.rule.destinationHelp", "Choose an available active delivery channel and its actual recipient.")
|
|
162
|
+
}),
|
|
163
|
+
y && /* @__PURE__ */ f("div", {
|
|
164
|
+
className: "mb-3 text-sm",
|
|
165
|
+
children: [/* @__PURE__ */ d("p", {
|
|
166
|
+
role: "alert",
|
|
167
|
+
className: "break-words text-status-error-text",
|
|
168
|
+
children: y
|
|
169
|
+
}), /* @__PURE__ */ d(u, {
|
|
170
|
+
type: "button",
|
|
171
|
+
variant: "secondary",
|
|
172
|
+
size: "sm",
|
|
173
|
+
onClick: j,
|
|
174
|
+
children: g("bigconsole.alerts.rule.reloadChannels", "Reload channels")
|
|
175
|
+
})]
|
|
176
|
+
}),
|
|
177
|
+
!y && N.length === 0 && /* @__PURE__ */ d("p", {
|
|
178
|
+
className: "mb-3 text-sm text-text-secondary",
|
|
179
|
+
children: g("bigconsole.alerts.rule.noChannels", "No active delivery channels are available to BigConsole in this organization. You can save this rule disabled.")
|
|
180
|
+
}),
|
|
181
|
+
!_.deliveries.length && /* @__PURE__ */ d("p", {
|
|
182
|
+
className: "mb-3 text-xs text-text-muted",
|
|
183
|
+
children: g("bigconsole.alerts.rule.noDestinations", "No delivery destinations selected.")
|
|
184
|
+
}),
|
|
185
|
+
_.deliveries.map((e, t) => /* @__PURE__ */ f("div", {
|
|
186
|
+
className: "mb-3 min-w-0 rounded-control border border-border-subtle p-3",
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ f("label", {
|
|
189
|
+
htmlFor: `alert-channel-${e.key}`,
|
|
190
|
+
className: "mb-1 block text-xs font-medium text-text-primary",
|
|
191
|
+
children: [
|
|
192
|
+
g("bigconsole.alerts.rule.channel", "Configured channel"),
|
|
193
|
+
" ",
|
|
194
|
+
t + 1
|
|
195
|
+
]
|
|
196
|
+
}),
|
|
197
|
+
/* @__PURE__ */ f("select", {
|
|
198
|
+
id: `alert-channel-${e.key}`,
|
|
199
|
+
className: m,
|
|
200
|
+
value: e.channelId,
|
|
201
|
+
onChange: (t) => {
|
|
202
|
+
let n = v.find((e) => e.id === t.target.value);
|
|
203
|
+
P({ deliveries: _.deliveries.map((t) => t.key === e.key ? {
|
|
204
|
+
...t,
|
|
205
|
+
channelId: n?.id ?? "",
|
|
206
|
+
channel: n?.platform ?? r.Email,
|
|
207
|
+
recipient: n?.platform === t.channel ? t.recipient : ""
|
|
208
|
+
} : t) });
|
|
209
|
+
},
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ d("option", {
|
|
212
|
+
value: "",
|
|
213
|
+
children: g("bigconsole.alerts.rule.chooseChannel", "Choose a configured channel")
|
|
214
|
+
}),
|
|
215
|
+
e.channelId && !N.some((t) => t.id === e.channelId) && /* @__PURE__ */ f("option", {
|
|
216
|
+
value: e.channelId,
|
|
217
|
+
children: [
|
|
218
|
+
g("bigconsole.alerts.rule.unavailableChannel", "Unavailable channel"),
|
|
219
|
+
" · ",
|
|
220
|
+
e.channelId
|
|
221
|
+
]
|
|
222
|
+
}),
|
|
223
|
+
N.map((e) => /* @__PURE__ */ f("option", {
|
|
224
|
+
value: e.id,
|
|
225
|
+
children: [
|
|
226
|
+
e.name,
|
|
227
|
+
" · ",
|
|
228
|
+
e.platform
|
|
229
|
+
]
|
|
230
|
+
}, e.id))
|
|
231
|
+
]
|
|
232
|
+
}),
|
|
233
|
+
/* @__PURE__ */ d("label", {
|
|
234
|
+
htmlFor: `alert-recipient-${e.key}`,
|
|
235
|
+
className: "mb-1 mt-3 block text-xs font-medium text-text-primary",
|
|
236
|
+
children: e.channel === r.Email ? g("bigconsole.alerts.rule.emailRecipient", "Email address") : e.channel === r.Slack ? g("bigconsole.alerts.rule.slackRecipient", "Slack recipient ID") : g("bigconsole.alerts.rule.webhookRecipient", "HTTPS webhook URL")
|
|
237
|
+
}),
|
|
238
|
+
/* @__PURE__ */ d("input", {
|
|
239
|
+
id: `alert-recipient-${e.key}`,
|
|
240
|
+
className: m,
|
|
241
|
+
type: e.channel === r.Email ? "email" : e.channel === r.Webhook ? "url" : "text",
|
|
242
|
+
value: e.recipient,
|
|
243
|
+
onChange: (t) => P({ deliveries: _.deliveries.map((n) => n.key === e.key ? {
|
|
244
|
+
...n,
|
|
245
|
+
recipient: t.target.value
|
|
246
|
+
} : n) }),
|
|
247
|
+
required: !0
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ f(u, {
|
|
250
|
+
type: "button",
|
|
251
|
+
variant: "ghost",
|
|
252
|
+
size: "sm",
|
|
253
|
+
onClick: () => P({ deliveries: _.deliveries.filter((t) => t.key !== e.key) }),
|
|
254
|
+
className: "mt-2",
|
|
255
|
+
children: [/* @__PURE__ */ d(l, { className: "mr-2 h-4 w-4" }), g("bigconsole.alerts.rule.removeDestination", "Remove destination")]
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
}, e.key)),
|
|
259
|
+
/* @__PURE__ */ f(u, {
|
|
260
|
+
type: "button",
|
|
261
|
+
variant: "secondary",
|
|
262
|
+
size: "sm",
|
|
263
|
+
onClick: () => P({ deliveries: [..._.deliveries, {
|
|
264
|
+
key: crypto.randomUUID(),
|
|
265
|
+
channel: r.Email,
|
|
266
|
+
channelId: "",
|
|
267
|
+
recipient: ""
|
|
268
|
+
}] }),
|
|
269
|
+
disabled: N.length === 0,
|
|
270
|
+
children: [/* @__PURE__ */ d(s, { className: "mr-2 h-4 w-4" }), g("bigconsole.alerts.rule.addDestination", "Add destination")]
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
}),
|
|
274
|
+
/* @__PURE__ */ f("fieldset", {
|
|
275
|
+
disabled: M,
|
|
276
|
+
className: "min-w-0",
|
|
277
|
+
children: [
|
|
278
|
+
/* @__PURE__ */ d("legend", {
|
|
279
|
+
className: "mb-2 text-sm font-medium text-text-primary",
|
|
280
|
+
children: g("bigconsole.alerts.rule.throttle", "Throttle")
|
|
281
|
+
}),
|
|
282
|
+
/* @__PURE__ */ f("label", {
|
|
283
|
+
className: "flex items-center gap-2 text-sm text-text-primary",
|
|
284
|
+
children: [/* @__PURE__ */ d("input", {
|
|
285
|
+
type: "checkbox",
|
|
286
|
+
checked: _.throttleEnabled,
|
|
287
|
+
onChange: (e) => P({ throttleEnabled: e.target.checked }),
|
|
288
|
+
className: e
|
|
289
|
+
}), g("bigconsole.alerts.rule.limitFrequency", "Limit alert frequency")]
|
|
290
|
+
}),
|
|
291
|
+
_.throttleEnabled && /* @__PURE__ */ f("div", {
|
|
292
|
+
className: "mt-3 grid gap-form-gap sm:grid-cols-2",
|
|
293
|
+
children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
|
|
294
|
+
htmlFor: "alert-window",
|
|
295
|
+
className: "mb-1 block text-xs font-medium text-text-primary",
|
|
296
|
+
children: g("bigconsole.alerts.rule.window", "Time window (minutes)")
|
|
297
|
+
}), /* @__PURE__ */ d("input", {
|
|
298
|
+
id: "alert-window",
|
|
299
|
+
type: "number",
|
|
300
|
+
min: 1,
|
|
301
|
+
step: 1,
|
|
302
|
+
className: m,
|
|
303
|
+
value: _.windowMinutes,
|
|
304
|
+
onChange: (e) => P({ windowMinutes: e.target.value }),
|
|
305
|
+
required: !0
|
|
306
|
+
})] }), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("label", {
|
|
307
|
+
htmlFor: "alert-max",
|
|
308
|
+
className: "mb-1 block text-xs font-medium text-text-primary",
|
|
309
|
+
children: g("bigconsole.alerts.rule.maxAlerts", "Maximum alerts per window")
|
|
310
|
+
}), /* @__PURE__ */ d("input", {
|
|
311
|
+
id: "alert-max",
|
|
312
|
+
type: "number",
|
|
313
|
+
min: 1,
|
|
314
|
+
step: 1,
|
|
315
|
+
className: m,
|
|
316
|
+
value: _.maxAlerts,
|
|
317
|
+
onChange: (e) => P({ maxAlerts: e.target.value }),
|
|
318
|
+
required: !0
|
|
319
|
+
})] })]
|
|
320
|
+
})
|
|
321
|
+
]
|
|
322
|
+
}),
|
|
323
|
+
/* @__PURE__ */ f("label", {
|
|
324
|
+
className: "flex items-start gap-2 text-sm text-text-primary",
|
|
325
|
+
children: [/* @__PURE__ */ d("input", {
|
|
326
|
+
type: "checkbox",
|
|
327
|
+
checked: _.enabled,
|
|
328
|
+
onChange: (e) => P({ enabled: e.target.checked }),
|
|
329
|
+
disabled: M,
|
|
330
|
+
className: `mt-1 ${e}`
|
|
331
|
+
}), /* @__PURE__ */ f("span", { children: [g("bigconsole.alerts.rule.enabled", "Rule enabled"), /* @__PURE__ */ d("span", {
|
|
332
|
+
className: "mt-1 block text-xs text-text-secondary",
|
|
333
|
+
children: g("bigconsole.alerts.rule.enabledHelp", "Enabled rules evaluate when this sink is updated or refreshed. Saving a disabled rule does not send notifications.")
|
|
334
|
+
})] })]
|
|
335
|
+
}),
|
|
336
|
+
/* @__PURE__ */ f("div", {
|
|
337
|
+
className: "flex flex-wrap justify-end gap-control-gap border-t border-border-subtle pt-4",
|
|
338
|
+
children: [/* @__PURE__ */ d(u, {
|
|
339
|
+
type: "button",
|
|
340
|
+
variant: "secondary",
|
|
341
|
+
onClick: k,
|
|
342
|
+
disabled: x,
|
|
343
|
+
children: g("bigconsole.alerts.rule.cancel", "Cancel")
|
|
344
|
+
}), /* @__PURE__ */ f(u, {
|
|
345
|
+
type: "submit",
|
|
346
|
+
disabled: M,
|
|
347
|
+
children: [x ? /* @__PURE__ */ d(a, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ d(c, { className: "mr-2 h-4 w-4" }), x ? g("bigconsole.alerts.rule.saving", "Saving…") : g("bigconsole.alerts.rule.save", "Save rule")]
|
|
348
|
+
})]
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
})
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
//#endregion
|
|
355
|
+
export { h as AlertRuleEditor };
|
|
356
|
+
|
|
357
|
+
//# sourceMappingURL=AlertRuleEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlertRuleEditor.js","names":[],"sources":["../../../../src/bigconsole/components/datasink/AlertRuleEditor.tsx"],"sourcesContent":["import type { FormEvent } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Loader2, Plus, Save, Trash2, Play } from 'lucide-react';\nimport { Section, SECTION_FOCUS_RING } from '../common';\nimport { AlertSeverity, DataSinkAlertConditionType, DataSinkAlertChannel } from '../../../generated/wspace-types';\nimport type { AlertChannel, AlertPreview } from '../../hooks/useDataSinkAlerts';\nimport type { AlertDraft } from '../../utils/alertRules';\n\nconst FIELD = `w-full min-w-0 rounded-control border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary ${SECTION_FOCUS_RING}`;\ninterface Props {\n draft: AlertDraft;\n channels: AlertChannel[];\n channelError: string | null;\n canUpdate: boolean;\n pending: boolean;\n previewing: boolean;\n preview: AlertPreview | null;\n previewError: string | null;\n previewStale: boolean;\n error: string | null;\n onChange: (draft: AlertDraft) => void;\n onSave: () => void;\n onCancel: () => void;\n onPreview: () => void;\n onReloadChannels: () => void;\n}\n\nexport function AlertRuleEditor(props: Props) {\n const { t } = useI18n();\n const {\n draft,\n channels,\n channelError,\n canUpdate,\n pending,\n previewing,\n preview,\n previewError,\n previewStale,\n error,\n onChange,\n onSave,\n onCancel,\n onPreview,\n onReloadChannels,\n } = props;\n const disabled = pending || !canUpdate;\n const activeChannels = channels.filter((channel) => channel.status.toUpperCase() === 'ACTIVE');\n const change = (patch: Partial<AlertDraft>) => onChange({ ...draft, ...patch });\n const submit = (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n onSave();\n };\n return (\n <Section title={t('bigconsole.alerts.rule.title', 'Alert rule')} headingLevel={2} emphasis=\"primary\">\n <form\n onSubmit={submit}\n className=\"flex min-w-0 flex-col gap-form-gap\"\n aria-label={t('bigconsole.alerts.rule.form', 'Alert rule editor')}\n >\n {!canUpdate && (\n <p className=\"text-sm text-text-secondary\">\n {t('bigconsole.alerts.rule.readOnly', 'You have read-only access to these alert rules.')}\n </p>\n )}\n {error && (\n <p role=\"alert\" className=\"break-words text-sm text-status-error-text\">\n {error}\n </p>\n )}\n <div>\n <label htmlFor=\"alert-name\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.name', 'Name')}\n </label>\n <input\n id=\"alert-name\"\n className={FIELD}\n value={draft.name}\n onChange={(event) => change({ name: event.target.value })}\n required\n maxLength={200}\n disabled={disabled}\n />\n </div>\n <div className=\"grid min-w-0 gap-form-gap sm:grid-cols-2\">\n <div>\n <label htmlFor=\"alert-condition-type\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.language', 'Condition language')}\n </label>\n <select\n id=\"alert-condition-type\"\n className={FIELD}\n value={draft.conditionType}\n onChange={(event) =>\n change({\n conditionType:\n event.target.value === DataSinkAlertConditionType.Jsonata\n ? DataSinkAlertConditionType.Jsonata\n : DataSinkAlertConditionType.Jq,\n })\n }\n disabled={disabled}\n >\n <option value={DataSinkAlertConditionType.Jq}>JQ</option>\n <option value={DataSinkAlertConditionType.Jsonata}>JSONata</option>\n </select>\n </div>\n <div>\n <label htmlFor=\"alert-severity\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.severity', 'Severity')}\n </label>\n <select\n id=\"alert-severity\"\n className={FIELD}\n value={draft.severity}\n onChange={(event) =>\n change({\n severity:\n Object.values(AlertSeverity).find((value) => value === event.target.value) ?? AlertSeverity.Medium,\n })\n }\n disabled={disabled}\n >\n {Object.values(AlertSeverity).map((value) => (\n <option key={value} value={value}>\n {t(`bigconsole.alerts.severity.${value}`, value.charAt(0).toUpperCase() + value.slice(1))}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div>\n <label htmlFor=\"alert-condition\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.condition', 'Condition')}\n </label>\n <textarea\n id=\"alert-condition\"\n className={`${FIELD} min-h-32 font-mono`}\n value={draft.condition}\n onChange={(event) => change({ condition: event.target.value })}\n rows={5}\n required\n disabled={disabled}\n aria-describedby=\"alert-condition-help\"\n />\n <p id=\"alert-condition-help\" className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.conditionHelp',\n 'Evaluates the entire current sink payload and must return one boolean. Preview does not send notifications.'\n )}\n </p>\n <p className=\"mt-1 break-words text-xs text-text-muted\">\n {draft.conditionType === DataSinkAlertConditionType.Jq\n ? 'JQ: any(.[]; .boarding_minutes > 240)'\n : 'JSONata: $count($[boarding_minutes > 240]) > 0'}\n </p>\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={onPreview}\n disabled={pending || previewing || !draft.condition.trim()}\n className=\"mt-3\"\n >\n {previewing ? <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" /> : <Play className=\"mr-2 h-4 w-4\" />}\n {previewing\n ? t('bigconsole.alerts.rule.previewing', 'Evaluating…')\n : t('bigconsole.alerts.rule.preview', 'Preview condition')}\n </Button>\n {previewError && (\n <p role=\"alert\" className=\"mt-2 break-words text-sm text-status-error-text\">\n {previewError}\n </p>\n )}\n {previewStale && (\n <p role=\"status\" className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.previewStale',\n 'The condition or data changed. Preview again to see the current result.'\n )}\n </p>\n )}\n {preview && !previewStale && (\n <div role=\"status\" className=\"mt-3 rounded-control border border-border-subtle bg-bg-sunken p-3 text-sm\">\n {preview.error ? (\n <p className=\"break-words text-status-error-text\">{preview.error}</p>\n ) : (\n <p className=\"font-medium text-text-primary\">\n {preview.matched\n ? t('bigconsole.alerts.rule.matched', 'Condition matched')\n : t('bigconsole.alerts.rule.noMatch', 'Condition did not match')}\n </p>\n )}\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('bigconsole.alerts.rule.previewMetadata', 'Evaluated data version')} {preview.version} ·{' '}\n {preview.durationMs} ms\n </p>\n </div>\n )}\n </div>\n <fieldset disabled={disabled} className=\"min-w-0\">\n <legend className=\"mb-2 text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.destinations', 'Delivery destinations')}\n </legend>\n <p className=\"mb-3 text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.destinationHelp',\n 'Choose an available active delivery channel and its actual recipient.'\n )}\n </p>\n {channelError && (\n <div className=\"mb-3 text-sm\">\n <p role=\"alert\" className=\"break-words text-status-error-text\">\n {channelError}\n </p>\n <Button type=\"button\" variant=\"secondary\" size=\"sm\" onClick={onReloadChannels}>\n {t('bigconsole.alerts.rule.reloadChannels', 'Reload channels')}\n </Button>\n </div>\n )}\n {!channelError && activeChannels.length === 0 && (\n <p className=\"mb-3 text-sm text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.noChannels',\n 'No active delivery channels are available to BigConsole in this organization. You can save this rule disabled.'\n )}\n </p>\n )}\n {!draft.deliveries.length && (\n <p className=\"mb-3 text-xs text-text-muted\">\n {t('bigconsole.alerts.rule.noDestinations', 'No delivery destinations selected.')}\n </p>\n )}\n {draft.deliveries.map((delivery, index) => (\n <div key={delivery.key} className=\"mb-3 min-w-0 rounded-control border border-border-subtle p-3\">\n <label\n htmlFor={`alert-channel-${delivery.key}`}\n className=\"mb-1 block text-xs font-medium text-text-primary\"\n >\n {t('bigconsole.alerts.rule.channel', 'Configured channel')} {index + 1}\n </label>\n <select\n id={`alert-channel-${delivery.key}`}\n className={FIELD}\n value={delivery.channelId}\n onChange={(event) => {\n const channel = channels.find((item) => item.id === event.target.value);\n change({\n deliveries: draft.deliveries.map((item) =>\n item.key === delivery.key\n ? {\n ...item,\n channelId: channel?.id ?? '',\n channel: channel?.platform ?? DataSinkAlertChannel.Email,\n recipient: channel?.platform === item.channel ? item.recipient : '',\n }\n : item\n ),\n });\n }}\n >\n <option value=\"\">{t('bigconsole.alerts.rule.chooseChannel', 'Choose a configured channel')}</option>\n {delivery.channelId && !activeChannels.some((channel) => channel.id === delivery.channelId) && (\n <option value={delivery.channelId}>\n {t('bigconsole.alerts.rule.unavailableChannel', 'Unavailable channel')} · {delivery.channelId}\n </option>\n )}\n {activeChannels.map((channel) => (\n <option key={channel.id} value={channel.id}>\n {channel.name} · {channel.platform}\n </option>\n ))}\n </select>\n <label\n htmlFor={`alert-recipient-${delivery.key}`}\n className=\"mb-1 mt-3 block text-xs font-medium text-text-primary\"\n >\n {delivery.channel === DataSinkAlertChannel.Email\n ? t('bigconsole.alerts.rule.emailRecipient', 'Email address')\n : delivery.channel === DataSinkAlertChannel.Slack\n ? t('bigconsole.alerts.rule.slackRecipient', 'Slack recipient ID')\n : t('bigconsole.alerts.rule.webhookRecipient', 'HTTPS webhook URL')}\n </label>\n <input\n id={`alert-recipient-${delivery.key}`}\n className={FIELD}\n type={\n delivery.channel === DataSinkAlertChannel.Email\n ? 'email'\n : delivery.channel === DataSinkAlertChannel.Webhook\n ? 'url'\n : 'text'\n }\n value={delivery.recipient}\n onChange={(event) =>\n change({\n deliveries: draft.deliveries.map((item) =>\n item.key === delivery.key ? { ...item, recipient: event.target.value } : item\n ),\n })\n }\n required\n />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => change({ deliveries: draft.deliveries.filter((item) => item.key !== delivery.key) })}\n className=\"mt-2\"\n >\n <Trash2 className=\"mr-2 h-4 w-4\" />\n {t('bigconsole.alerts.rule.removeDestination', 'Remove destination')}\n </Button>\n </div>\n ))}\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={() =>\n change({\n deliveries: [\n ...draft.deliveries,\n { key: crypto.randomUUID(), channel: DataSinkAlertChannel.Email, channelId: '', recipient: '' },\n ],\n })\n }\n disabled={activeChannels.length === 0}\n >\n <Plus className=\"mr-2 h-4 w-4\" />\n {t('bigconsole.alerts.rule.addDestination', 'Add destination')}\n </Button>\n </fieldset>\n <fieldset disabled={disabled} className=\"min-w-0\">\n <legend className=\"mb-2 text-sm font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.throttle', 'Throttle')}\n </legend>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={draft.throttleEnabled}\n onChange={(event) => change({ throttleEnabled: event.target.checked })}\n className={SECTION_FOCUS_RING}\n />\n {t('bigconsole.alerts.rule.limitFrequency', 'Limit alert frequency')}\n </label>\n {draft.throttleEnabled && (\n <div className=\"mt-3 grid gap-form-gap sm:grid-cols-2\">\n <div>\n <label htmlFor=\"alert-window\" className=\"mb-1 block text-xs font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.window', 'Time window (minutes)')}\n </label>\n <input\n id=\"alert-window\"\n type=\"number\"\n min={1}\n step={1}\n className={FIELD}\n value={draft.windowMinutes}\n onChange={(event) => change({ windowMinutes: event.target.value })}\n required\n />\n </div>\n <div>\n <label htmlFor=\"alert-max\" className=\"mb-1 block text-xs font-medium text-text-primary\">\n {t('bigconsole.alerts.rule.maxAlerts', 'Maximum alerts per window')}\n </label>\n <input\n id=\"alert-max\"\n type=\"number\"\n min={1}\n step={1}\n className={FIELD}\n value={draft.maxAlerts}\n onChange={(event) => change({ maxAlerts: event.target.value })}\n required\n />\n </div>\n </div>\n )}\n </fieldset>\n <label className=\"flex items-start gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={draft.enabled}\n onChange={(event) => change({ enabled: event.target.checked })}\n disabled={disabled}\n className={`mt-1 ${SECTION_FOCUS_RING}`}\n />\n <span>\n {t('bigconsole.alerts.rule.enabled', 'Rule enabled')}\n <span className=\"mt-1 block text-xs text-text-secondary\">\n {t(\n 'bigconsole.alerts.rule.enabledHelp',\n 'Enabled rules evaluate when this sink is updated or refreshed. Saving a disabled rule does not send notifications.'\n )}\n </span>\n </span>\n </label>\n <div className=\"flex flex-wrap justify-end gap-control-gap border-t border-border-subtle pt-4\">\n <Button type=\"button\" variant=\"secondary\" onClick={onCancel} disabled={pending}>\n {t('bigconsole.alerts.rule.cancel', 'Cancel')}\n </Button>\n <Button type=\"submit\" disabled={disabled}>\n {pending ? <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" /> : <Save className=\"mr-2 h-4 w-4\" />}\n {pending ? t('bigconsole.alerts.rule.saving', 'Saving…') : t('bigconsole.alerts.rule.save', 'Save rule')}\n </Button>\n </div>\n </form>\n </Section>\n );\n}\n"],"mappings":";;;;;;;;;AASA,IAAM,IAAQ,gHAAgH;AAmB9H,SAAgB,EAAgB,GAAc;CAC5C,IAAM,EAAE,SAAM,GAAS,EACjB,EACJ,UACA,aACA,iBACA,cACA,YACA,eACA,YACA,iBACA,iBACA,UACA,aACA,WACA,aACA,cACA,wBACE,GACE,IAAW,KAAW,CAAC,GACvB,IAAiB,EAAS,QAAQ,MAAY,EAAQ,OAAO,aAAa,KAAK,SAAS,EACxF,KAAU,MAA+B,EAAS;EAAE,GAAG;EAAO,GAAG;EAAO,CAAC;AAK/E,QACE,kBAAC,GAAD;EAAS,OAAO,EAAE,gCAAgC,aAAa;EAAE,cAAc;EAAG,UAAS;YACzF,kBAAC,QAAD;GACE,WAPU,MAAsC;AAEpD,IADA,EAAM,gBAAgB,EACtB,GAAQ;;GAMJ,WAAU;GACV,cAAY,EAAE,+BAA+B,oBAAoB;aAHnE;IAKG,CAAC,KACA,kBAAC,KAAD;KAAG,WAAU;eACV,EAAE,mCAAmC,kDAAkD;KACtF,CAAA;IAEL,KACC,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;eACvB;KACC,CAAA;IAEN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;KAAO,SAAQ;KAAa,WAAU;eACnC,EAAE,+BAA+B,OAAO;KACnC,CAAA,EACR,kBAAC,SAAD;KACE,IAAG;KACH,WAAW;KACX,OAAO,EAAM;KACb,WAAW,MAAU,EAAO,EAAE,MAAM,EAAM,OAAO,OAAO,CAAC;KACzD,UAAA;KACA,WAAW;KACD;KACV,CAAA,CACE,EAAA,CAAA;IACN,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;MAAO,SAAQ;MAAuB,WAAU;gBAC7C,EAAE,mCAAmC,qBAAqB;MACrD,CAAA,E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MAAS,SAAQ;MAAY,SAAS;MAAU,UAAU;gBACpE,EAAE,iCAAiC,SAAS;MACtC,CAAA,EACT,kBAAC,GAAD;MAAQ,MAAK;MAAmB;gBAAhC,CACG,IAAU,kBAAC,GAAD,EAAS,WAAU,6BAA8B,CAAA,GAAG,kBAAC,GAAD,EAAM,WAAU,gBAAiB,CAAA,EAC/F,IAAU,EAAE,iCAAiC,UAAU,GAAG,EAAE,+BAA+B,YAAY,CACjG;QACL;;IACD;;EACC,CAAA"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { BigConsoleDataSinkAlertsQuery, BigConsoleDataSinkAlertChannelsQuery, BigConsoleDataSinkAlertExecutionsQuery, BigConsolePreviewDataSinkAlertQuery } from '../../generated/wspace-operations';
|
|
2
|
+
import { DataSinkAlertInput, DataSinkAlertConditionType } from '../../generated/wspace-types';
|
|
3
|
+
|
|
4
|
+
export type AlertSink = NonNullable<BigConsoleDataSinkAlertsQuery['getDataSink']>;
|
|
5
|
+
export type AlertRule = NonNullable<AlertSink['alerts']>[number];
|
|
6
|
+
export type AlertChannel = BigConsoleDataSinkAlertChannelsQuery['dataSinkAlertChannels'][number];
|
|
7
|
+
export type AlertExecution = BigConsoleDataSinkAlertExecutionsQuery['dataSinkAlertExecutions'][number];
|
|
8
|
+
export type AlertPreview = BigConsolePreviewDataSinkAlertQuery['previewDataSinkAlert'];
|
|
9
|
+
export declare const alertErrorMessage: (error: unknown) => string;
|
|
10
|
+
/** Every read and write uses the selected workspace; late requests cannot populate a new owner. */
|
|
11
|
+
export declare function useDataSinkAlerts(dataSinkId: string, enabled: boolean): {
|
|
12
|
+
owner: string;
|
|
13
|
+
refreshing: boolean;
|
|
14
|
+
reload: () => Promise<{
|
|
15
|
+
__typename?: "DataSink";
|
|
16
|
+
id: string;
|
|
17
|
+
workspaceId: string;
|
|
18
|
+
name?: string | null;
|
|
19
|
+
key: string;
|
|
20
|
+
version: number;
|
|
21
|
+
alerts?: Array<{
|
|
22
|
+
__typename?: "DataSinkAlert";
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
condition: string;
|
|
26
|
+
conditionType: DataSinkAlertConditionType;
|
|
27
|
+
severity: import('../../generated/wspace-types').AlertSeverity;
|
|
28
|
+
channels: Array<string>;
|
|
29
|
+
recipients: Array<string>;
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
throttle?: {
|
|
32
|
+
__typename?: "AlertThrottle";
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
windowMinutes: number;
|
|
35
|
+
maxAlertsPerWindow: number;
|
|
36
|
+
} | null;
|
|
37
|
+
deliveries: Array<{
|
|
38
|
+
__typename?: "DataSinkAlertDelivery";
|
|
39
|
+
channel: import('../../generated/wspace-types').DataSinkAlertChannel;
|
|
40
|
+
channelId: string;
|
|
41
|
+
recipient: string;
|
|
42
|
+
}>;
|
|
43
|
+
}> | null;
|
|
44
|
+
} | null | undefined>;
|
|
45
|
+
reloadChannels: () => Promise<void>;
|
|
46
|
+
save: (alert: DataSinkAlertInput, expectedVersion: number) => Promise<{
|
|
47
|
+
__typename?: "DataSink";
|
|
48
|
+
id: string;
|
|
49
|
+
workspaceId: string;
|
|
50
|
+
name?: string | null;
|
|
51
|
+
key: string;
|
|
52
|
+
version: number;
|
|
53
|
+
alerts?: Array<{
|
|
54
|
+
__typename?: "DataSinkAlert";
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
condition: string;
|
|
58
|
+
conditionType: DataSinkAlertConditionType;
|
|
59
|
+
severity: import('../../generated/wspace-types').AlertSeverity;
|
|
60
|
+
channels: Array<string>;
|
|
61
|
+
recipients: Array<string>;
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
throttle?: {
|
|
64
|
+
__typename?: "AlertThrottle";
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
windowMinutes: number;
|
|
67
|
+
maxAlertsPerWindow: number;
|
|
68
|
+
} | null;
|
|
69
|
+
deliveries: Array<{
|
|
70
|
+
__typename?: "DataSinkAlertDelivery";
|
|
71
|
+
channel: import('../../generated/wspace-types').DataSinkAlertChannel;
|
|
72
|
+
channelId: string;
|
|
73
|
+
recipient: string;
|
|
74
|
+
}>;
|
|
75
|
+
}> | null;
|
|
76
|
+
} | null>;
|
|
77
|
+
remove: (alertId: string, expectedVersion: number) => Promise<{
|
|
78
|
+
__typename?: "DataSink";
|
|
79
|
+
id: string;
|
|
80
|
+
workspaceId: string;
|
|
81
|
+
name?: string | null;
|
|
82
|
+
key: string;
|
|
83
|
+
version: number;
|
|
84
|
+
alerts?: Array<{
|
|
85
|
+
__typename?: "DataSinkAlert";
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
condition: string;
|
|
89
|
+
conditionType: DataSinkAlertConditionType;
|
|
90
|
+
severity: import('../../generated/wspace-types').AlertSeverity;
|
|
91
|
+
channels: Array<string>;
|
|
92
|
+
recipients: Array<string>;
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
throttle?: {
|
|
95
|
+
__typename?: "AlertThrottle";
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
windowMinutes: number;
|
|
98
|
+
maxAlertsPerWindow: number;
|
|
99
|
+
} | null;
|
|
100
|
+
deliveries: Array<{
|
|
101
|
+
__typename?: "DataSinkAlertDelivery";
|
|
102
|
+
channel: import('../../generated/wspace-types').DataSinkAlertChannel;
|
|
103
|
+
channelId: string;
|
|
104
|
+
recipient: string;
|
|
105
|
+
}>;
|
|
106
|
+
}> | null;
|
|
107
|
+
} | null>;
|
|
108
|
+
preview: (condition: string, conditionType: DataSinkAlertConditionType) => Promise<{
|
|
109
|
+
__typename?: "DataSinkAlertPreview";
|
|
110
|
+
matched: boolean;
|
|
111
|
+
result?: Record<string, unknown> | null;
|
|
112
|
+
error?: string | null;
|
|
113
|
+
durationMs: number;
|
|
114
|
+
version: number;
|
|
115
|
+
} | null>;
|
|
116
|
+
history: (alertId?: string, after?: string) => Promise<{
|
|
117
|
+
__typename?: "DataSinkAlertExecution";
|
|
118
|
+
id: string;
|
|
119
|
+
alertId: string;
|
|
120
|
+
dataSinkId: string;
|
|
121
|
+
version: number;
|
|
122
|
+
source: string;
|
|
123
|
+
status: import('../../generated/wspace-types').DataSinkAlertExecutionStatus;
|
|
124
|
+
matched: boolean;
|
|
125
|
+
error?: string | null;
|
|
126
|
+
durationMs: number;
|
|
127
|
+
createdAt: string;
|
|
128
|
+
completedAt?: string | null;
|
|
129
|
+
deliveries: Array<{
|
|
130
|
+
__typename?: "DataSinkAlertDeliveryAttempt";
|
|
131
|
+
channel: import('../../generated/wspace-types').DataSinkAlertChannel;
|
|
132
|
+
channelId: string;
|
|
133
|
+
recipient: string;
|
|
134
|
+
notificationId?: string | null;
|
|
135
|
+
status: string;
|
|
136
|
+
error?: string | null;
|
|
137
|
+
attemptedAt?: string | null;
|
|
138
|
+
}>;
|
|
139
|
+
}[] | null>;
|
|
140
|
+
sink: AlertSink | null;
|
|
141
|
+
channels: AlertChannel[];
|
|
142
|
+
loading: boolean;
|
|
143
|
+
error: string | null;
|
|
144
|
+
channelError: string | null;
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=useDataSinkAlerts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataSinkAlerts.d.ts","sourceRoot":"","sources":["../../../src/bigconsole/hooks/useDataSinkAlerts.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,KAAK,6BAA6B,EAClC,KAAK,oCAAoC,EACzC,KAAK,sCAAsC,EAC3C,KAAK,mCAAmC,EAGzC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAEnG,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,6BAA6B,CAAC,aAAa,CAAC,CAAC,CAAC;AAClF,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,C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