@marinoscar/platform-contract 0.1.0-next.19 → 0.1.0-next.21
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/CHANGELOG.md +10 -0
- package/README.md +4 -0
- package/dist/cjs/alerts/constants.d.ts +195 -0
- package/dist/cjs/alerts/constants.d.ts.map +1 -0
- package/dist/cjs/alerts/constants.js +165 -0
- package/dist/cjs/alerts/constants.js.map +1 -0
- package/dist/cjs/alerts/enum.d.ts +5 -0
- package/dist/cjs/alerts/enum.d.ts.map +1 -0
- package/dist/cjs/alerts/enum.js +9 -0
- package/dist/cjs/alerts/enum.js.map +1 -0
- package/dist/cjs/alerts/index.d.ts +5 -0
- package/dist/cjs/alerts/index.d.ts.map +1 -0
- package/dist/cjs/alerts/index.js +68 -0
- package/dist/cjs/alerts/index.js.map +1 -0
- package/dist/cjs/alerts/schemas.d.ts +351 -0
- package/dist/cjs/alerts/schemas.d.ts.map +1 -0
- package/dist/cjs/alerts/schemas.js +432 -0
- package/dist/cjs/alerts/schemas.js.map +1 -0
- package/dist/cjs/nodes/admin-schemas.d.ts +85 -1
- package/dist/cjs/nodes/admin-schemas.d.ts.map +1 -1
- package/dist/cjs/nodes/admin-schemas.js +55 -1
- package/dist/cjs/nodes/admin-schemas.js.map +1 -1
- package/dist/cjs/nodes/constants.d.ts +12 -0
- package/dist/cjs/nodes/constants.d.ts.map +1 -1
- package/dist/cjs/nodes/constants.js +13 -1
- package/dist/cjs/nodes/constants.js.map +1 -1
- package/dist/cjs/nodes/index.d.ts +5 -5
- package/dist/cjs/nodes/index.d.ts.map +1 -1
- package/dist/cjs/nodes/index.js +14 -1
- package/dist/cjs/nodes/index.js.map +1 -1
- package/dist/cjs/nodes/schemas.d.ts +178 -0
- package/dist/cjs/nodes/schemas.d.ts.map +1 -1
- package/dist/cjs/nodes/schemas.js +149 -1
- package/dist/cjs/nodes/schemas.js.map +1 -1
- package/dist/cjs/telemetry/constants.d.ts.map +1 -1
- package/dist/cjs/telemetry/constants.js +6 -0
- package/dist/cjs/telemetry/constants.js.map +1 -1
- package/dist/cjs/telemetry/dashboard.d.ts +5 -5
- package/dist/cjs/telemetry/presentation.d.ts +5 -5
- package/dist/cjs/telemetry/stack.d.ts +2 -2
- package/dist/cjs/webhooks/constants.d.ts +154 -0
- package/dist/cjs/webhooks/constants.d.ts.map +1 -0
- package/dist/cjs/webhooks/constants.js +136 -0
- package/dist/cjs/webhooks/constants.js.map +1 -0
- package/dist/cjs/webhooks/enum.d.ts +5 -0
- package/dist/cjs/webhooks/enum.d.ts.map +1 -0
- package/dist/cjs/webhooks/enum.js +9 -0
- package/dist/cjs/webhooks/enum.js.map +1 -0
- package/dist/cjs/webhooks/index.d.ts +7 -0
- package/dist/cjs/webhooks/index.d.ts.map +1 -0
- package/dist/cjs/webhooks/index.js +48 -0
- package/dist/cjs/webhooks/index.js.map +1 -0
- package/dist/cjs/webhooks/schemas.d.ts +288 -0
- package/dist/cjs/webhooks/schemas.d.ts.map +1 -0
- package/dist/cjs/webhooks/schemas.js +295 -0
- package/dist/cjs/webhooks/schemas.js.map +1 -0
- package/dist/cjs/webhooks/signature.d.ts +54 -0
- package/dist/cjs/webhooks/signature.d.ts.map +1 -0
- package/dist/cjs/webhooks/signature.js +97 -0
- package/dist/cjs/webhooks/signature.js.map +1 -0
- package/dist/esm/alerts/constants.d.ts +195 -0
- package/dist/esm/alerts/constants.d.ts.map +1 -0
- package/dist/esm/alerts/constants.js +162 -0
- package/dist/esm/alerts/constants.js.map +1 -0
- package/dist/esm/alerts/enum.d.ts +5 -0
- package/dist/esm/alerts/enum.d.ts.map +1 -0
- package/dist/esm/alerts/enum.js +6 -0
- package/dist/esm/alerts/enum.js.map +1 -0
- package/dist/esm/alerts/index.d.ts +5 -0
- package/dist/esm/alerts/index.d.ts.map +1 -0
- package/dist/esm/alerts/index.js +8 -0
- package/dist/esm/alerts/index.js.map +1 -0
- package/dist/esm/alerts/schemas.d.ts +351 -0
- package/dist/esm/alerts/schemas.d.ts.map +1 -0
- package/dist/esm/alerts/schemas.js +429 -0
- package/dist/esm/alerts/schemas.js.map +1 -0
- package/dist/esm/nodes/admin-schemas.d.ts +85 -1
- package/dist/esm/nodes/admin-schemas.d.ts.map +1 -1
- package/dist/esm/nodes/admin-schemas.js +55 -1
- package/dist/esm/nodes/admin-schemas.js.map +1 -1
- package/dist/esm/nodes/constants.d.ts +12 -0
- package/dist/esm/nodes/constants.d.ts.map +1 -1
- package/dist/esm/nodes/constants.js +12 -0
- package/dist/esm/nodes/constants.js.map +1 -1
- package/dist/esm/nodes/index.d.ts +5 -5
- package/dist/esm/nodes/index.d.ts.map +1 -1
- package/dist/esm/nodes/index.js +3 -3
- package/dist/esm/nodes/index.js.map +1 -1
- package/dist/esm/nodes/schemas.d.ts +178 -0
- package/dist/esm/nodes/schemas.d.ts.map +1 -1
- package/dist/esm/nodes/schemas.js +149 -1
- package/dist/esm/nodes/schemas.js.map +1 -1
- package/dist/esm/telemetry/constants.d.ts.map +1 -1
- package/dist/esm/telemetry/constants.js +6 -0
- package/dist/esm/telemetry/constants.js.map +1 -1
- package/dist/esm/telemetry/dashboard.d.ts +5 -5
- package/dist/esm/telemetry/presentation.d.ts +5 -5
- package/dist/esm/telemetry/stack.d.ts +2 -2
- package/dist/esm/webhooks/constants.d.ts +154 -0
- package/dist/esm/webhooks/constants.d.ts.map +1 -0
- package/dist/esm/webhooks/constants.js +133 -0
- package/dist/esm/webhooks/constants.js.map +1 -0
- package/dist/esm/webhooks/enum.d.ts +5 -0
- package/dist/esm/webhooks/enum.d.ts.map +1 -0
- package/dist/esm/webhooks/enum.js +6 -0
- package/dist/esm/webhooks/enum.js.map +1 -0
- package/dist/esm/webhooks/index.d.ts +7 -0
- package/dist/esm/webhooks/index.d.ts.map +1 -0
- package/dist/esm/webhooks/index.js +8 -0
- package/dist/esm/webhooks/index.js.map +1 -0
- package/dist/esm/webhooks/schemas.d.ts +288 -0
- package/dist/esm/webhooks/schemas.d.ts.map +1 -0
- package/dist/esm/webhooks/schemas.js +292 -0
- package/dist/esm/webhooks/schemas.js.map +1 -0
- package/dist/esm/webhooks/signature.d.ts +54 -0
- package/dist/esm/webhooks/signature.d.ts.map +1 -0
- package/dist/esm/webhooks/signature.js +93 -0
- package/dist/esm/webhooks/signature.js.map +1 -0
- package/package.json +21 -1
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// The alerts slice's wire shapes (issue #1047)
|
|
3
|
+
// =============================================================================
|
|
4
|
+
//
|
|
5
|
+
// Rules, the per-kind configs of the built-in kinds, incidents, the dry-run
|
|
6
|
+
// response, the kind catalog, the dashboard summary and the webhook payload.
|
|
7
|
+
// Dates are ISO 8601 strings. A rule's `config` is validated by its KIND's own
|
|
8
|
+
// schema in the API (the kind id is an open string); the schemas here are the
|
|
9
|
+
// built-in kinds' and what the generic routes accept.
|
|
10
|
+
// =============================================================================
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { wireEnum } from './enum.js';
|
|
13
|
+
import { ALERT_AGGREGATIONS, ALERT_ATTRIBUTE_PATTERN, ALERT_COMPARATORS, ALERT_COOLDOWN_SECONDS_DEFAULT, ALERT_COOLDOWN_SECONDS_MAX, ALERT_DESCRIPTION_MAX, ALERT_FILTERS_MAX, ALERT_FILTER_OPS, ALERT_FOR_SECONDS_MAX, ALERT_GROUP_BY_MAX, ALERT_INCIDENT_STATES, ALERT_KEY_MAX, ALERT_KEY_PATTERN, ALERT_KIND_MAX, ALERT_KIND_PATTERN, ALERT_METRIC_NAME_PATTERN, ALERT_NAME_MAX, ALERT_NODE_EVENT_RESOLVE_AFTER_DEFAULT, ALERT_NOTIFY_CHANNELS_MAX, ALERT_PAGE_SIZE_DEFAULT, ALERT_PAGE_SIZE_MAX, ALERT_SEVERITIES, ALERT_SUMMARY_MAX, ALERT_WINDOW_SECONDS_MAX, ALERT_WINDOW_SECONDS_MIN, } from './constants.js';
|
|
14
|
+
const isoDate = z.string();
|
|
15
|
+
/** One of `info`, `warning`, `critical`. @stability experimental */
|
|
16
|
+
export const alertSeveritySchema = wireEnum(ALERT_SEVERITIES);
|
|
17
|
+
/** One of `pending`, `firing`, `resolved`. @stability experimental */
|
|
18
|
+
export const alertIncidentStateSchema = wireEnum(ALERT_INCIDENT_STATES);
|
|
19
|
+
/** One comparator. @stability experimental */
|
|
20
|
+
export const alertComparatorSchema = wireEnum(ALERT_COMPARATORS);
|
|
21
|
+
/** One aggregation. @stability experimental */
|
|
22
|
+
export const alertAggregationSchema = wireEnum(ALERT_AGGREGATIONS);
|
|
23
|
+
/** A rule kind id: an open vocabulary, lower snake case. @stability experimental */
|
|
24
|
+
export const alertKindIdSchema = z.string().max(ALERT_KIND_MAX).regex(ALERT_KIND_PATTERN);
|
|
25
|
+
// ---- per-kind configs -----------------------------------------------------
|
|
26
|
+
/**
|
|
27
|
+
* One attribute filter of a `metric_threshold` rule.
|
|
28
|
+
*
|
|
29
|
+
* @stability experimental
|
|
30
|
+
*/
|
|
31
|
+
export const alertMetricFilterSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
/** The attribute (column) to match. */
|
|
34
|
+
attr: z.string().regex(ALERT_ATTRIBUTE_PATTERN),
|
|
35
|
+
/** `eq` or `neq`. */
|
|
36
|
+
op: wireEnum(ALERT_FILTER_OPS),
|
|
37
|
+
/** The value (the observed number, or the filter value). */
|
|
38
|
+
value: z.string().max(200),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
/**
|
|
42
|
+
* `metric_threshold`: an aggregate of one metric over a window compared to a
|
|
43
|
+
* threshold, per group. `metric` is the dotted metric name (`app.nodes.host.cpu.utilization`)
|
|
44
|
+
* or its table name; the API resolves it against the store's schema.
|
|
45
|
+
*
|
|
46
|
+
* @stability experimental
|
|
47
|
+
*/
|
|
48
|
+
export const metricThresholdConfigSchema = z
|
|
49
|
+
.object({
|
|
50
|
+
/** The dotted metric name or its table name. */
|
|
51
|
+
metric: z.string().regex(ALERT_METRIC_NAME_PATTERN),
|
|
52
|
+
/** How the points in the window are reduced to one number. */
|
|
53
|
+
aggregation: alertAggregationSchema,
|
|
54
|
+
/** The window, in seconds. */
|
|
55
|
+
windowSeconds: z.number().int().min(ALERT_WINDOW_SECONDS_MIN).max(ALERT_WINDOW_SECONDS_MAX),
|
|
56
|
+
/** How the value is compared to the threshold. */
|
|
57
|
+
comparator: alertComparatorSchema,
|
|
58
|
+
/** The threshold the value is compared with. */
|
|
59
|
+
threshold: z.number().finite(),
|
|
60
|
+
/** Attribute columns to group by; one incident per group. */
|
|
61
|
+
groupBy: z.array(z.string().regex(ALERT_ATTRIBUTE_PATTERN)).max(ALERT_GROUP_BY_MAX).optional(),
|
|
62
|
+
/** Attribute filters applied before aggregating. */
|
|
63
|
+
filters: z.array(alertMetricFilterSchema).max(ALERT_FILTERS_MAX).optional(),
|
|
64
|
+
})
|
|
65
|
+
.strict();
|
|
66
|
+
/**
|
|
67
|
+
* An attribute match of a `node_event` rule: every entry must equal the
|
|
68
|
+
* event's attribute (compared as text).
|
|
69
|
+
*
|
|
70
|
+
* @stability experimental
|
|
71
|
+
*/
|
|
72
|
+
export const alertEventAttrsSchema = z
|
|
73
|
+
.record(z.string().regex(ALERT_ATTRIBUTE_PATTERN), z.union([z.string().max(200), z.number(), z.boolean()]))
|
|
74
|
+
.refine((attrs) => Object.keys(attrs).length <= 5, 'At most 5 attributes');
|
|
75
|
+
/**
|
|
76
|
+
* `node_event`: a worker node reported a matching event. `eventTypes` are node
|
|
77
|
+
* event types or a prefix such as `power.*`. The incident resolves when a
|
|
78
|
+
* `recovery` event arrives for the same node, or after `resolveAfterSeconds`.
|
|
79
|
+
*
|
|
80
|
+
* @stability experimental
|
|
81
|
+
*/
|
|
82
|
+
export const nodeEventConfigSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
/** Node event types or prefixes such as `power.*`. */
|
|
85
|
+
eventTypes: z.array(z.string().min(1).max(64)).min(1).max(20),
|
|
86
|
+
/** The lowest event severity that counts. */
|
|
87
|
+
minSeverity: alertSeveritySchema.optional(),
|
|
88
|
+
/** Only these nodes. */
|
|
89
|
+
nodeIds: z.array(z.string().max(64)).max(100).optional(),
|
|
90
|
+
/** Attributes the event must carry, compared as text. */
|
|
91
|
+
attrs: alertEventAttrsSchema.optional(),
|
|
92
|
+
/** The events that clear the incident. */
|
|
93
|
+
recovery: z
|
|
94
|
+
.object({
|
|
95
|
+
/** Node event types or prefixes such as `power.*`. */
|
|
96
|
+
eventTypes: z.array(z.string().min(1).max(64)).min(1).max(20),
|
|
97
|
+
/** Attributes the event must carry, compared as text. */
|
|
98
|
+
attrs: alertEventAttrsSchema.optional(),
|
|
99
|
+
})
|
|
100
|
+
.strict()
|
|
101
|
+
.optional(),
|
|
102
|
+
/** Seconds after which the incident clears without a recovery event. */
|
|
103
|
+
resolveAfterSeconds: z.number().int().min(60).max(604_800).default(ALERT_NODE_EVENT_RESOLVE_AFTER_DEFAULT),
|
|
104
|
+
})
|
|
105
|
+
.strict();
|
|
106
|
+
/**
|
|
107
|
+
* `verdict`: the telemetry dashboard verdict is at or past `minLevel`.
|
|
108
|
+
*
|
|
109
|
+
* @stability experimental
|
|
110
|
+
*/
|
|
111
|
+
export const verdictConfigSchema = z
|
|
112
|
+
.object({
|
|
113
|
+
/** The verdict level at or past which the rule breaches. */
|
|
114
|
+
minLevel: wireEnum(['degraded', 'critical']),
|
|
115
|
+
})
|
|
116
|
+
.strict();
|
|
117
|
+
/**
|
|
118
|
+
* `node_offline` and `telemetry_unavailable` take no configuration.
|
|
119
|
+
*
|
|
120
|
+
* @stability experimental
|
|
121
|
+
*/
|
|
122
|
+
export const emptyAlertConfigSchema = z.object({}).strict();
|
|
123
|
+
// ---- rules ------------------------------------------------------------------
|
|
124
|
+
const notifyChannelsSchema = z
|
|
125
|
+
.array(z.string().min(1).max(32))
|
|
126
|
+
.max(ALERT_NOTIFY_CHANNELS_MAX)
|
|
127
|
+
.refine((ids) => new Set(ids).size === ids.length, 'Channels must be unique');
|
|
128
|
+
/**
|
|
129
|
+
* An alert rule as the API returns it.
|
|
130
|
+
*
|
|
131
|
+
* @stability experimental
|
|
132
|
+
*/
|
|
133
|
+
export const alertRuleSchema = z.object({
|
|
134
|
+
/** The id. */
|
|
135
|
+
id: z.string(),
|
|
136
|
+
/** The stable key of a seeded starter rule, else `null`. */
|
|
137
|
+
key: z.string().nullable(),
|
|
138
|
+
/** `true` for a seeded starter rule (it may be edited and disabled, not deleted). */
|
|
139
|
+
starter: z.boolean(),
|
|
140
|
+
/** The display name. */
|
|
141
|
+
name: z.string(),
|
|
142
|
+
/** Free text, or `null`. */
|
|
143
|
+
description: z.string().nullable(),
|
|
144
|
+
/** Whether the evaluator runs the rule. */
|
|
145
|
+
enabled: z.boolean(),
|
|
146
|
+
/** The rule kind id. */
|
|
147
|
+
kind: z.string(),
|
|
148
|
+
/** How serious the incidents are. */
|
|
149
|
+
severity: alertSeveritySchema,
|
|
150
|
+
/** The kind-specific configuration. */
|
|
151
|
+
config: z.record(z.string(), z.unknown()),
|
|
152
|
+
/** Seconds the condition must hold before the rule fires. */
|
|
153
|
+
forSeconds: z.number().int().min(0),
|
|
154
|
+
/** Seconds after a resolve in which a re-fire is not notified. */
|
|
155
|
+
cooldownSeconds: z.number().int().min(0),
|
|
156
|
+
/** Notification channel ids the alert is sent over; empty means every channel the recipient has on. */
|
|
157
|
+
notifyChannels: z.array(z.string()),
|
|
158
|
+
/** Also emit the `alerts.alert.*` webhook events. */
|
|
159
|
+
webhook: z.boolean(),
|
|
160
|
+
/** The administrator who created the rule, or `null`. */
|
|
161
|
+
createdById: z.string().nullable(),
|
|
162
|
+
/** When it was created. */
|
|
163
|
+
createdAt: isoDate,
|
|
164
|
+
/** When it was last updated. */
|
|
165
|
+
updatedAt: isoDate,
|
|
166
|
+
/** When the rule was last evaluated, or `null`. */
|
|
167
|
+
lastEvaluatedAt: isoDate.nullable(),
|
|
168
|
+
/** The last evaluation error (kept until the next clean evaluation), else `null`. */
|
|
169
|
+
lastError: z.string().nullable(),
|
|
170
|
+
/** Incidents currently `pending` or `firing`. */
|
|
171
|
+
openIncidents: z.number().int().min(0),
|
|
172
|
+
});
|
|
173
|
+
/**
|
|
174
|
+
* `POST /api/admin/alerts/rules` body. `config` is validated against the
|
|
175
|
+
* kind's schema; a rule is created disabled unless `enabled` says otherwise.
|
|
176
|
+
*
|
|
177
|
+
* @stability experimental
|
|
178
|
+
*/
|
|
179
|
+
export const createAlertRuleSchema = z.object({
|
|
180
|
+
/** The display name. */
|
|
181
|
+
name: z.string().trim().min(1).max(ALERT_NAME_MAX),
|
|
182
|
+
/** Free text, or `null`. */
|
|
183
|
+
description: z.string().trim().max(ALERT_DESCRIPTION_MAX).nullable().optional(),
|
|
184
|
+
/** Whether the evaluator runs the rule. */
|
|
185
|
+
enabled: z.boolean().default(false),
|
|
186
|
+
/** The rule kind id. */
|
|
187
|
+
kind: alertKindIdSchema,
|
|
188
|
+
/** How serious the incidents are. */
|
|
189
|
+
severity: alertSeveritySchema,
|
|
190
|
+
/** The kind-specific configuration. */
|
|
191
|
+
config: z.record(z.string(), z.unknown()).default({}),
|
|
192
|
+
/** Seconds the condition must hold before the rule fires. */
|
|
193
|
+
forSeconds: z.number().int().min(0).max(ALERT_FOR_SECONDS_MAX).default(0),
|
|
194
|
+
/** Seconds after a resolve in which a re-fire is not notified. */
|
|
195
|
+
cooldownSeconds: z.number().int().min(0).max(ALERT_COOLDOWN_SECONDS_MAX).default(ALERT_COOLDOWN_SECONDS_DEFAULT),
|
|
196
|
+
/** Notification channel ids; empty means no restriction. */
|
|
197
|
+
notifyChannels: notifyChannelsSchema.default([]),
|
|
198
|
+
/** Also emit the `alerts.alert.*` webhook events. */
|
|
199
|
+
webhook: z.boolean().default(true),
|
|
200
|
+
});
|
|
201
|
+
/**
|
|
202
|
+
* `PATCH /api/admin/alerts/rules/:id` body. The kind cannot change; a new
|
|
203
|
+
* `config` is validated against the rule's kind.
|
|
204
|
+
*
|
|
205
|
+
* @stability experimental
|
|
206
|
+
*/
|
|
207
|
+
export const updateAlertRuleSchema = z
|
|
208
|
+
.object({
|
|
209
|
+
/** The display name. */
|
|
210
|
+
name: z.string().trim().min(1).max(ALERT_NAME_MAX),
|
|
211
|
+
/** Free text, or `null`. */
|
|
212
|
+
description: z.string().trim().max(ALERT_DESCRIPTION_MAX).nullable(),
|
|
213
|
+
/** Whether the evaluator runs the rule. */
|
|
214
|
+
enabled: z.boolean(),
|
|
215
|
+
/** How serious the incidents are. */
|
|
216
|
+
severity: alertSeveritySchema,
|
|
217
|
+
/** The kind-specific configuration. */
|
|
218
|
+
config: z.record(z.string(), z.unknown()),
|
|
219
|
+
/** Seconds the condition must hold before the rule fires. */
|
|
220
|
+
forSeconds: z.number().int().min(0).max(ALERT_FOR_SECONDS_MAX),
|
|
221
|
+
/** Seconds after a resolve in which a re-fire is not notified. */
|
|
222
|
+
cooldownSeconds: z.number().int().min(0).max(ALERT_COOLDOWN_SECONDS_MAX),
|
|
223
|
+
/** Notification channel ids; empty means no restriction. */
|
|
224
|
+
notifyChannels: notifyChannelsSchema,
|
|
225
|
+
/** Also emit the `alerts.alert.*` webhook events. */
|
|
226
|
+
webhook: z.boolean(),
|
|
227
|
+
})
|
|
228
|
+
.partial()
|
|
229
|
+
.strict()
|
|
230
|
+
.refine((body) => Object.keys(body).length > 0, 'Send at least one field');
|
|
231
|
+
/** A rule key, for a seeded starter rule. @stability experimental */
|
|
232
|
+
export const alertRuleKeySchema = z.string().max(ALERT_KEY_MAX).regex(ALERT_KEY_PATTERN);
|
|
233
|
+
/**
|
|
234
|
+
* `GET /api/admin/alerts/rules` query.
|
|
235
|
+
*
|
|
236
|
+
* @stability experimental
|
|
237
|
+
*/
|
|
238
|
+
export const alertRuleListQuerySchema = z.object({
|
|
239
|
+
/** The rule kind id. */
|
|
240
|
+
kind: alertKindIdSchema.optional(),
|
|
241
|
+
/** How serious the incidents are. */
|
|
242
|
+
severity: alertSeveritySchema.optional(),
|
|
243
|
+
/** Whether the evaluator runs the rule. */
|
|
244
|
+
enabled: wireEnum(['true', 'false'])
|
|
245
|
+
.transform((value) => value === 'true')
|
|
246
|
+
.optional(),
|
|
247
|
+
});
|
|
248
|
+
/** `GET /api/admin/alerts/rules` response data. @stability experimental */
|
|
249
|
+
export const alertRuleListSchema = z.array(alertRuleSchema);
|
|
250
|
+
// ---- incidents ----------------------------------------------------------------
|
|
251
|
+
/**
|
|
252
|
+
* One incident: one rule breached for one label set.
|
|
253
|
+
*
|
|
254
|
+
* @stability experimental
|
|
255
|
+
*/
|
|
256
|
+
export const alertIncidentSchema = z.object({
|
|
257
|
+
/** The id. */
|
|
258
|
+
id: z.string(),
|
|
259
|
+
/** The rule. */
|
|
260
|
+
ruleId: z.string(),
|
|
261
|
+
/** The rule name. */
|
|
262
|
+
ruleName: z.string(),
|
|
263
|
+
/** The rule kind. */
|
|
264
|
+
ruleKind: z.string(),
|
|
265
|
+
/** The label set that identifies the incident within its rule. */
|
|
266
|
+
labels: z.record(z.string(), z.string()),
|
|
267
|
+
/** `pending`, `firing` or `resolved`. */
|
|
268
|
+
state: alertIncidentStateSchema,
|
|
269
|
+
/** How serious the incidents are. */
|
|
270
|
+
severity: alertSeveritySchema,
|
|
271
|
+
/** When the condition first held, or `null`. */
|
|
272
|
+
pendingSince: isoDate.nullable(),
|
|
273
|
+
/** When it fired, or `null`. */
|
|
274
|
+
firedAt: isoDate.nullable(),
|
|
275
|
+
/** When it resolved, or `null`. */
|
|
276
|
+
resolvedAt: isoDate.nullable(),
|
|
277
|
+
/** The last observed value, or `null`. */
|
|
278
|
+
lastValue: z.number().nullable(),
|
|
279
|
+
/** The last evaluation that saw it breached. */
|
|
280
|
+
lastSeenAt: isoDate,
|
|
281
|
+
/** One human sentence. */
|
|
282
|
+
summary: z.string().max(ALERT_SUMMARY_MAX),
|
|
283
|
+
/** When an administrator acknowledged it, or `null`. */
|
|
284
|
+
acknowledgedAt: isoDate.nullable(),
|
|
285
|
+
/** Who acknowledged it, or `null`. */
|
|
286
|
+
acknowledgedById: z.string().nullable(),
|
|
287
|
+
/** When it was created. */
|
|
288
|
+
createdAt: isoDate,
|
|
289
|
+
});
|
|
290
|
+
/**
|
|
291
|
+
* `GET /api/admin/alerts/incidents` query.
|
|
292
|
+
*
|
|
293
|
+
* @stability experimental
|
|
294
|
+
*/
|
|
295
|
+
export const alertIncidentListQuerySchema = z.object({
|
|
296
|
+
/** `pending`, `firing` or `resolved`. */
|
|
297
|
+
state: alertIncidentStateSchema.optional(),
|
|
298
|
+
/** How serious the incidents are. */
|
|
299
|
+
severity: alertSeveritySchema.optional(),
|
|
300
|
+
/** The rule. */
|
|
301
|
+
ruleId: z.uuid().optional(),
|
|
302
|
+
/** The 1-based page. */
|
|
303
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
304
|
+
/** Rows per page. */
|
|
305
|
+
pageSize: z.coerce.number().int().min(1).max(ALERT_PAGE_SIZE_MAX).default(ALERT_PAGE_SIZE_DEFAULT),
|
|
306
|
+
});
|
|
307
|
+
/** `GET /api/admin/alerts/incidents` response data. @stability experimental */
|
|
308
|
+
export const alertIncidentListSchema = z.object({
|
|
309
|
+
/** The rows of this page. */
|
|
310
|
+
items: z.array(alertIncidentSchema),
|
|
311
|
+
/** Rows across all pages. */
|
|
312
|
+
total: z.number().int().min(0),
|
|
313
|
+
/** The 1-based page. */
|
|
314
|
+
page: z.number().int().min(1),
|
|
315
|
+
/** Rows per page. */
|
|
316
|
+
pageSize: z.number().int().min(1),
|
|
317
|
+
/** Pages across all rows. */
|
|
318
|
+
totalPages: z.number().int().min(0),
|
|
319
|
+
});
|
|
320
|
+
// ---- dry run, kinds, summary ----------------------------------------------------
|
|
321
|
+
/**
|
|
322
|
+
* One observation a kind produced: a label set, its value and whether it
|
|
323
|
+
* breaches the rule.
|
|
324
|
+
*
|
|
325
|
+
* @stability experimental
|
|
326
|
+
*/
|
|
327
|
+
export const alertObservationSchema = z.object({
|
|
328
|
+
/** The label set that identifies the incident within its rule. */
|
|
329
|
+
labels: z.record(z.string(), z.string()),
|
|
330
|
+
/** The value (the observed number, or the filter value). */
|
|
331
|
+
value: z.number().nullable(),
|
|
332
|
+
/** Whether the observation breaches the rule. */
|
|
333
|
+
breached: z.boolean(),
|
|
334
|
+
/** One human sentence. */
|
|
335
|
+
summary: z.string().max(ALERT_SUMMARY_MAX),
|
|
336
|
+
});
|
|
337
|
+
/**
|
|
338
|
+
* `POST /api/admin/alerts/rules/:id/test` response: the rule evaluated now.
|
|
339
|
+
* Nothing is stored and nothing is dispatched.
|
|
340
|
+
*
|
|
341
|
+
* @stability experimental
|
|
342
|
+
*/
|
|
343
|
+
export const alertRuleTestResponseSchema = z.object({
|
|
344
|
+
/** The rule. */
|
|
345
|
+
ruleId: z.string(),
|
|
346
|
+
/** The rule kind id. */
|
|
347
|
+
kind: z.string(),
|
|
348
|
+
/** When the evaluation ran. */
|
|
349
|
+
evaluatedAt: isoDate,
|
|
350
|
+
/** How long it took, in milliseconds. */
|
|
351
|
+
durationMs: z.number().int().min(0),
|
|
352
|
+
/** What the kind observed, per label set. */
|
|
353
|
+
observations: z.array(alertObservationSchema),
|
|
354
|
+
/** Why the evaluation failed (for instance the store is unreachable), else `null`. */
|
|
355
|
+
error: z.string().nullable(),
|
|
356
|
+
});
|
|
357
|
+
/**
|
|
358
|
+
* One registered rule kind and the JSON Schema of its config.
|
|
359
|
+
*
|
|
360
|
+
* @stability experimental
|
|
361
|
+
*/
|
|
362
|
+
export const alertKindSchema = z.object({
|
|
363
|
+
/** The id. */
|
|
364
|
+
id: z.string(),
|
|
365
|
+
/** Short display label. */
|
|
366
|
+
label: z.string(),
|
|
367
|
+
/** Free text, or `null`. */
|
|
368
|
+
description: z.string(),
|
|
369
|
+
/** The kind reacts to events (it is also evaluated when one arrives). */
|
|
370
|
+
eventDriven: z.boolean(),
|
|
371
|
+
/** One of the kinds the slice ships. */
|
|
372
|
+
builtin: z.boolean(),
|
|
373
|
+
/** JSON Schema (draft 2020-12) of the kind's `config`. */
|
|
374
|
+
configSchema: z.record(z.string(), z.unknown()),
|
|
375
|
+
});
|
|
376
|
+
/** `GET /api/admin/alerts/kinds` response data. @stability experimental */
|
|
377
|
+
export const alertKindListSchema = z.array(alertKindSchema);
|
|
378
|
+
/**
|
|
379
|
+
* `GET /api/admin/alerts/summary` response: what the dashboard banner shows.
|
|
380
|
+
*
|
|
381
|
+
* @stability experimental
|
|
382
|
+
*/
|
|
383
|
+
export const alertSummarySchema = z.object({
|
|
384
|
+
/** Incidents firing now, by severity. */
|
|
385
|
+
firing: z.object({
|
|
386
|
+
/** Critical incidents. */
|
|
387
|
+
critical: z.number().int().min(0),
|
|
388
|
+
/** Warning incidents. */
|
|
389
|
+
warning: z.number().int().min(0),
|
|
390
|
+
/** Info incidents. */
|
|
391
|
+
info: z.number().int().min(0),
|
|
392
|
+
}),
|
|
393
|
+
/** Newest `lastEvaluatedAt` among the enabled rules, else `null`. */
|
|
394
|
+
lastEvaluatedAt: isoDate.nullable(),
|
|
395
|
+
});
|
|
396
|
+
/**
|
|
397
|
+
* The `data` of the `alerts.alert.fired` and `alerts.alert.resolved` webhook
|
|
398
|
+
* events.
|
|
399
|
+
*
|
|
400
|
+
* @stability experimental
|
|
401
|
+
*/
|
|
402
|
+
export const alertWebhookDataSchema = z.object({
|
|
403
|
+
/** The incident. */
|
|
404
|
+
incidentId: z.string(),
|
|
405
|
+
/** The rule that produced it. */
|
|
406
|
+
rule: z.object({
|
|
407
|
+
/** The id. */
|
|
408
|
+
id: z.string(),
|
|
409
|
+
/** The stable key of a seeded starter rule, else `null`. */
|
|
410
|
+
key: z.string().nullable(),
|
|
411
|
+
/** The display name. */
|
|
412
|
+
name: z.string(),
|
|
413
|
+
/** The rule kind id. */
|
|
414
|
+
kind: z.string(),
|
|
415
|
+
/** How serious the incidents are. */
|
|
416
|
+
severity: alertSeveritySchema,
|
|
417
|
+
}),
|
|
418
|
+
/** The label set that identifies the incident within its rule. */
|
|
419
|
+
labels: z.record(z.string(), z.string()),
|
|
420
|
+
/** The value (the observed number, or the filter value). */
|
|
421
|
+
value: z.number().nullable(),
|
|
422
|
+
/** One human sentence. */
|
|
423
|
+
summary: z.string(),
|
|
424
|
+
/** When it fired, or `null`. */
|
|
425
|
+
firedAt: isoDate.nullable(),
|
|
426
|
+
/** When it resolved, or `null`. */
|
|
427
|
+
resolvedAt: isoDate.nullable(),
|
|
428
|
+
});
|
|
429
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/alerts/schemas.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,gFAAgF;AAChF,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,sDAAsD;AACtD,gFAAgF;AAEhF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,8BAA8B,EAC9B,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,sCAAsC,EACtC,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAExB,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AAE3B,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAE9D,sEAAsE;AACtE,MAAM,CAAC,MAAM,wBAAwB,GAAG,QAAQ,CAAC,qB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|
90
90
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
91
|
+
host: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
cpuPercent: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
cpuCount: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
loadAvg1: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
loadAvg5: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
loadAvg15: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
memTotalBytes: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
memFreeBytes: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
memAvailableBytes: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
osRelease: z.ZodOptional<z.ZodString>;
|
|
101
|
+
arch: z.ZodOptional<z.ZodString>;
|
|
102
|
+
uptimeSeconds: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
}, z.core.$strict>>;
|
|
104
|
+
power: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
source: z.ZodEnum<import("./schemas.js").NodePowerSourceEnum>;
|
|
106
|
+
batteryPercent: z.ZodOptional<z.ZodNumber>;
|
|
107
|
+
charging: z.ZodOptional<z.ZodBoolean>;
|
|
108
|
+
timeRemainingSeconds: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
lowPowerMode: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
}, z.core.$strict>>;
|
|
91
111
|
}, z.core.$strict>>;
|
|
92
112
|
lastVitalsAt: z.ZodNullable<z.ZodString>;
|
|
93
113
|
owner: z.ZodObject<{
|
|
@@ -103,6 +123,52 @@ export declare const adminNodeSchema: z.ZodObject<{
|
|
|
103
123
|
total: z.ZodNumber;
|
|
104
124
|
}, z.core.$strip>;
|
|
105
125
|
}, z.core.$strip>;
|
|
126
|
+
/**
|
|
127
|
+
* One stored node event as `GET /api/nodes/:id/events` returns it.
|
|
128
|
+
*
|
|
129
|
+
* @stability experimental
|
|
130
|
+
*/
|
|
131
|
+
export declare const adminNodeEventSchema: z.ZodObject<{
|
|
132
|
+
id: z.ZodString;
|
|
133
|
+
nodeId: z.ZodString;
|
|
134
|
+
type: z.ZodString;
|
|
135
|
+
severity: z.ZodEnum<import("./schemas.js").NodeEventSeverityEnum>;
|
|
136
|
+
attrs: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
137
|
+
occurredAt: z.ZodString;
|
|
138
|
+
receivedAt: z.ZodString;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
/**
|
|
141
|
+
* The query of `GET /api/nodes/:id/events` (and the admin twin): newest first,
|
|
142
|
+
* `type` and `severity` matched for equality.
|
|
143
|
+
*
|
|
144
|
+
* @stability experimental
|
|
145
|
+
*/
|
|
146
|
+
export declare const nodeEventListQuerySchema: z.ZodObject<{
|
|
147
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
148
|
+
pageSize: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
149
|
+
type: z.ZodOptional<z.ZodString>;
|
|
150
|
+
severity: z.ZodOptional<z.ZodEnum<import("./schemas.js").NodeEventSeverityEnum>>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
/**
|
|
153
|
+
* A page of node events (`page`, `pageSize`, `items`, `total`, `totalPages`).
|
|
154
|
+
*
|
|
155
|
+
* @stability experimental
|
|
156
|
+
*/
|
|
157
|
+
export declare const adminNodeEventListSchema: z.ZodObject<{
|
|
158
|
+
items: z.ZodArray<z.ZodObject<{
|
|
159
|
+
id: z.ZodString;
|
|
160
|
+
nodeId: z.ZodString;
|
|
161
|
+
type: z.ZodString;
|
|
162
|
+
severity: z.ZodEnum<import("./schemas.js").NodeEventSeverityEnum>;
|
|
163
|
+
attrs: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
164
|
+
occurredAt: z.ZodString;
|
|
165
|
+
receivedAt: z.ZodString;
|
|
166
|
+
}, z.core.$strip>>;
|
|
167
|
+
total: z.ZodNumber;
|
|
168
|
+
page: z.ZodNumber;
|
|
169
|
+
pageSize: z.ZodNumber;
|
|
170
|
+
totalPages: z.ZodNumber;
|
|
171
|
+
}, z.core.$strip>;
|
|
106
172
|
/**
|
|
107
173
|
* One credential as `GET /api/admin/nodes/credentials` returns it
|
|
108
174
|
* (`AdminNodeCredentialDto`). No `token`, no hash; revoked credentials are
|
|
@@ -133,8 +199,8 @@ export declare const adminNodeCredentialSchema: z.ZodObject<{
|
|
|
133
199
|
export declare const nodeCredentialListItemSchema: z.ZodObject<{
|
|
134
200
|
id: z.ZodString;
|
|
135
201
|
createdAt: z.ZodString;
|
|
136
|
-
expiresAt: z.ZodNullable<z.ZodString>;
|
|
137
202
|
name: z.ZodString;
|
|
203
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
138
204
|
tokenPrefix: z.ZodString;
|
|
139
205
|
lastUsedAt: z.ZodNullable<z.ZodString>;
|
|
140
206
|
revokedAt: z.ZodNullable<z.ZodString>;
|
|
@@ -153,6 +219,24 @@ export declare const nodeCredentialCreatedSchema: z.ZodObject<{
|
|
|
153
219
|
expiresAt: z.ZodNullable<z.ZodString>;
|
|
154
220
|
createdAt: z.ZodString;
|
|
155
221
|
}, z.core.$strip>;
|
|
222
|
+
/**
|
|
223
|
+
* One stored node event.
|
|
224
|
+
*
|
|
225
|
+
* @stability experimental
|
|
226
|
+
*/
|
|
227
|
+
export type AdminNodeEvent = z.output<typeof adminNodeEventSchema>;
|
|
228
|
+
/**
|
|
229
|
+
* The parsed events-list query.
|
|
230
|
+
*
|
|
231
|
+
* @stability experimental
|
|
232
|
+
*/
|
|
233
|
+
export type NodeEventListQuery = z.output<typeof nodeEventListQuerySchema>;
|
|
234
|
+
/**
|
|
235
|
+
* A page of node events.
|
|
236
|
+
*
|
|
237
|
+
* @stability experimental
|
|
238
|
+
*/
|
|
239
|
+
export type AdminNodeEventList = z.output<typeof adminNodeEventListSchema>;
|
|
156
240
|
/**
|
|
157
241
|
* One admin node.
|
|
158
242
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-schemas.d.ts","sourceRoot":"","sources":["../../../src/nodes/admin-schemas.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG7D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;KAAG,CAAC,IAAI,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;CAAE,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;KAAG,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;CAAE,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;iBAO1B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;iBAW9B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;;;;;;;YAgBO,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;YAE1B,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"admin-schemas.d.ts","sourceRoot":"","sources":["../../../src/nodes/admin-schemas.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG7D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;KAAG,CAAC,IAAI,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;CAAE,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;KAAG,CAAC,IAAI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AAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AACzD;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACjE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC7E;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACnF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;AACjF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// =============================================================================
|
|
21
21
|
import { z } from 'zod';
|
|
22
22
|
import { NODE_HEALTHS, NODE_STATUSES } from './constants.js';
|
|
23
|
-
import { nodeVitalsSchema } from './schemas.js';
|
|
23
|
+
import { nodeEventSchema, nodeVitalsSchema } from './schemas.js';
|
|
24
24
|
/**
|
|
25
25
|
* Who registered a node or minted a credential.
|
|
26
26
|
*
|
|
@@ -95,6 +95,60 @@ export const adminNodeSchema = z.object({
|
|
|
95
95
|
/** The jobs it holds, per state. */
|
|
96
96
|
jobCounts: nodeJobCountsSchema,
|
|
97
97
|
});
|
|
98
|
+
/**
|
|
99
|
+
* One stored node event as `GET /api/nodes/:id/events` returns it.
|
|
100
|
+
*
|
|
101
|
+
* @stability experimental
|
|
102
|
+
*/
|
|
103
|
+
export const adminNodeEventSchema = z.object({
|
|
104
|
+
/** The event id (UUID). */
|
|
105
|
+
id: z.string(),
|
|
106
|
+
/** The node it belongs to. */
|
|
107
|
+
nodeId: z.string(),
|
|
108
|
+
/** Dotted type, e.g. `power.battery_low`. */
|
|
109
|
+
type: nodeEventSchema.shape.type,
|
|
110
|
+
/** How loud it is. */
|
|
111
|
+
severity: nodeEventSchema.shape.severity,
|
|
112
|
+
/** The node's scalar attributes, `{}` when none. */
|
|
113
|
+
attrs: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])),
|
|
114
|
+
/** When it happened on the node's clock (ISO 8601). */
|
|
115
|
+
occurredAt: z.string(),
|
|
116
|
+
/** When the server received it (ISO 8601). */
|
|
117
|
+
receivedAt: z.string(),
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* The query of `GET /api/nodes/:id/events` (and the admin twin): newest first,
|
|
121
|
+
* `type` and `severity` matched for equality.
|
|
122
|
+
*
|
|
123
|
+
* @stability experimental
|
|
124
|
+
*/
|
|
125
|
+
export const nodeEventListQuerySchema = z.object({
|
|
126
|
+
/** Page, from 1. */
|
|
127
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
128
|
+
/** Page size, at most 100. */
|
|
129
|
+
pageSize: z.coerce.number().int().min(1).max(100).default(20),
|
|
130
|
+
/** Exactly one dotted event type. */
|
|
131
|
+
type: z.string().max(64).optional(),
|
|
132
|
+
/** Exactly one severity. */
|
|
133
|
+
severity: nodeEventSchema.shape.severity.optional(),
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* A page of node events (`page`, `pageSize`, `items`, `total`, `totalPages`).
|
|
137
|
+
*
|
|
138
|
+
* @stability experimental
|
|
139
|
+
*/
|
|
140
|
+
export const adminNodeEventListSchema = z.object({
|
|
141
|
+
/** The page's events, newest first. */
|
|
142
|
+
items: z.array(adminNodeEventSchema),
|
|
143
|
+
/** Events matching the filters, across all pages. */
|
|
144
|
+
total: z.number().int(),
|
|
145
|
+
/** The current page, from 1. */
|
|
146
|
+
page: z.number().int(),
|
|
147
|
+
/** The page size. */
|
|
148
|
+
pageSize: z.number().int(),
|
|
149
|
+
/** The page count, at least 1. */
|
|
150
|
+
totalPages: z.number().int(),
|
|
151
|
+
});
|
|
98
152
|
/**
|
|
99
153
|
* One credential as `GET /api/admin/nodes/credentials` returns it
|
|
100
154
|
* (`AdminNodeCredentialDto`). No `token`, no hash; revoked credentials are
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-schemas.js","sourceRoot":"","sources":["../../../src/nodes/admin-schemas.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wDAAwD;AACxD,gFAAgF;AAChF,EAAE;AACF,0EAA0E;AAC1E,sFAAsF;AACtF,2EAA2E;AAC3E,+EAA+E;AAC/E,iDAAiD;AACjD,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,0EAA0E;AAC1E,uDAAuD;AACvD,gFAAgF;AAEhF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"admin-schemas.js","sourceRoot":"","sources":["../../../src/nodes/admin-schemas.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wDAAwD;AACxD,gFAAgF;AAChF,EAAE;AACF,0EAA0E;AAC1E,sFAAsF;AACtF,2EAA2E;AAC3E,+EAA+E;AAC/E,iDAAiD;AACjD,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,0EAA0E;AAC1E,uDAAuD;AACvD,gFAAgF;AAEhF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBA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