@molecule/api-resource-status-page 1.0.2 → 1.0.4
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/LICENSE +111 -24
- package/README.md +618 -466
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-10-16T20:59:34.726Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-status-page
|
|
@@ -18,6 +18,24 @@ Public status-page backend: monitored services, incidents with lifecycle
|
|
|
18
18
|
updates, health-check history, and uptime windows. The read endpoints power
|
|
19
19
|
a public status page; the mutation endpoints are for operators.
|
|
20
20
|
|
|
21
|
+
**Tables this package owns: four.** `services` is the parent; `checks`, `incidents` and
|
|
22
|
+
`uptimeWindows` each join to it on their own `serviceId` = `services.id` (a declared FK,
|
|
23
|
+
`ON DELETE CASCADE`) — that `serviceId` is the column every per-service query filters on.
|
|
24
|
+
|
|
25
|
+
**`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
|
|
26
|
+
`res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
|
|
27
|
+
for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
|
|
28
|
+
`res.send(body)`); calling a handler directly is only correct if you apply the result yourself:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const { statusCode, headers, body } = await handlers.getStatus(resource)(req, res)
|
|
32
|
+
if (headers) res.set(headers)
|
|
33
|
+
res.status(statusCode).send(body)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Monkey-patching `res.json` to re-shape a handler's answer intercepts nothing the handler
|
|
37
|
+
produces, so the request it was meant to answer is left unanswered and hangs.
|
|
38
|
+
|
|
21
39
|
## Quick Start
|
|
22
40
|
|
|
23
41
|
```typescript
|
|
@@ -48,28 +66,36 @@ npm install @molecule/api-resource-status-page @molecule/api-bond @molecule/api-
|
|
|
48
66
|
|
|
49
67
|
### Types
|
|
50
68
|
|
|
51
|
-
#### `
|
|
69
|
+
#### `ServiceProps`
|
|
52
70
|
|
|
53
|
-
|
|
71
|
+
Full service record properties.
|
|
54
72
|
|
|
55
73
|
```typescript
|
|
56
|
-
type
|
|
74
|
+
type ServiceProps = z.infer<typeof servicePropsSchema>
|
|
57
75
|
```
|
|
58
76
|
|
|
59
|
-
#### `
|
|
77
|
+
#### `CreateServiceProps`
|
|
60
78
|
|
|
61
|
-
Fields accepted when creating a new
|
|
79
|
+
Fields accepted when creating a new service.
|
|
62
80
|
|
|
63
81
|
```typescript
|
|
64
|
-
type
|
|
82
|
+
type CreateServiceProps = z.infer<typeof createServicePropsSchema>
|
|
65
83
|
```
|
|
66
84
|
|
|
67
|
-
#### `
|
|
85
|
+
#### `UpdateServiceProps`
|
|
68
86
|
|
|
69
|
-
|
|
87
|
+
Updatable service fields.
|
|
70
88
|
|
|
71
89
|
```typescript
|
|
72
|
-
type
|
|
90
|
+
type UpdateServiceProps = z.infer<typeof updateServicePropsSchema>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### `CheckProps`
|
|
94
|
+
|
|
95
|
+
Health check result properties.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
type CheckProps = z.infer<typeof checkPropsSchema>
|
|
73
99
|
```
|
|
74
100
|
|
|
75
101
|
#### `IncidentProps`
|
|
@@ -80,12 +106,12 @@ Full incident record properties.
|
|
|
80
106
|
type IncidentProps = z.infer<typeof incidentPropsSchema>
|
|
81
107
|
```
|
|
82
108
|
|
|
83
|
-
#### `
|
|
109
|
+
#### `CreateIncidentProps`
|
|
84
110
|
|
|
85
|
-
|
|
111
|
+
Fields accepted when creating a new incident.
|
|
86
112
|
|
|
87
113
|
```typescript
|
|
88
|
-
type
|
|
114
|
+
type CreateIncidentProps = z.infer<typeof createIncidentPropsSchema>
|
|
89
115
|
```
|
|
90
116
|
|
|
91
117
|
#### `UpdateIncidentProps`
|
|
@@ -96,23 +122,51 @@ Updatable incident fields.
|
|
|
96
122
|
type UpdateIncidentProps = z.infer<typeof updateIncidentPropsSchema>
|
|
97
123
|
```
|
|
98
124
|
|
|
99
|
-
#### `
|
|
125
|
+
#### `UptimeWindowProps`
|
|
100
126
|
|
|
101
|
-
|
|
127
|
+
Uptime window statistics properties.
|
|
102
128
|
|
|
103
129
|
```typescript
|
|
104
|
-
type
|
|
130
|
+
type UptimeWindowProps = z.infer<typeof uptimeWindowPropsSchema>
|
|
105
131
|
```
|
|
106
132
|
|
|
107
|
-
|
|
133
|
+
### Functions
|
|
108
134
|
|
|
109
|
-
|
|
135
|
+
#### `isStatusAdmin(res)`
|
|
136
|
+
|
|
137
|
+
Resolves whether the current request's session belongs to an actor authorized
|
|
138
|
+
to administer the status page (create/update/delete services + incidents).
|
|
139
|
+
Fail-closed: returns `false` when there is no authenticated session, and
|
|
140
|
+
otherwise only `true` when the session carries an admin claim or a bonded
|
|
141
|
+
permissions provider grants the `manage status` permission.
|
|
142
|
+
|
|
143
|
+
Use this for in-handler defense-in-depth (it does not depend on the route
|
|
144
|
+
middleware being preserved by the injector).
|
|
110
145
|
|
|
111
146
|
```typescript
|
|
112
|
-
|
|
147
|
+
function isStatusAdmin(res: MoleculeResponse): Promise<boolean>
|
|
113
148
|
```
|
|
114
149
|
|
|
115
|
-
|
|
150
|
+
- `res` — The response whose `locals.session` is inspected.
|
|
151
|
+
|
|
152
|
+
**Returns:** `true` when the session is an authorized status page admin.
|
|
153
|
+
|
|
154
|
+
#### `requireAdmin()`
|
|
155
|
+
|
|
156
|
+
Route middleware that gates the admin-only status page mutation routes. Calls
|
|
157
|
+
`next()` only for an authenticated status page admin; otherwise forwards an
|
|
158
|
+
error to the framework error handler — `Unauthorized` when no session is
|
|
159
|
+
present, `Forbidden` when the session is authenticated but not authorized to
|
|
160
|
+
manage the status page.
|
|
161
|
+
|
|
162
|
+
Exposed as a request-handler-map key so the injector's route scanner keeps it
|
|
163
|
+
(unlike the inert global `'auth'` string, which is dropped).
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
function requireAdmin(): MoleculeRequestHandler
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Returns:** An Express-compatible middleware function.
|
|
116
170
|
|
|
117
171
|
#### `createRequestHandlerMap(createRequestHandler)`
|
|
118
172
|
|
|
@@ -149,82 +203,91 @@ function createResource(): types.Resource<unknown>
|
|
|
149
203
|
|
|
150
204
|
**Returns:** The status resource descriptor with name, tableName, and schema.
|
|
151
205
|
|
|
152
|
-
|
|
206
|
+
### Constants
|
|
153
207
|
|
|
154
|
-
|
|
155
|
-
to administer the status page (create/update/delete services + incidents).
|
|
156
|
-
Fail-closed: returns `false` when there is no authenticated session, and
|
|
157
|
-
otherwise only `true` when the session carries an admin claim or a bonded
|
|
158
|
-
permissions provider grants the `manage status` permission.
|
|
208
|
+
#### `STATUS_PERMISSION_ACTION`
|
|
159
209
|
|
|
160
|
-
|
|
161
|
-
|
|
210
|
+
Permission action checked against `@molecule/api-permissions` for status page
|
|
211
|
+
administration.
|
|
162
212
|
|
|
163
213
|
```typescript
|
|
164
|
-
|
|
214
|
+
const STATUS_PERMISSION_ACTION: 'manage'
|
|
165
215
|
```
|
|
166
216
|
|
|
167
|
-
|
|
217
|
+
#### `STATUS_PERMISSION_RESOURCE`
|
|
168
218
|
|
|
169
|
-
|
|
219
|
+
Permission resource checked against `@molecule/api-permissions` for status page
|
|
220
|
+
administration.
|
|
170
221
|
|
|
171
|
-
|
|
222
|
+
```typescript
|
|
223
|
+
const STATUS_PERMISSION_RESOURCE: 'status'
|
|
224
|
+
```
|
|
172
225
|
|
|
173
|
-
|
|
174
|
-
`next()` only for an authenticated status page admin; otherwise forwards an
|
|
175
|
-
error to the framework error handler — `Unauthorized` when no session is
|
|
176
|
-
present, `Forbidden` when the session is authenticated but not authorized to
|
|
177
|
-
manage the status page.
|
|
226
|
+
#### `STATUS_ADMIN_PERMISSION`
|
|
178
227
|
|
|
179
|
-
|
|
180
|
-
|
|
228
|
+
Session-claim permission string (`'status:manage'`) that, when present in a
|
|
229
|
+
session's `permissions` array, grants status page administration without a
|
|
230
|
+
bonded permissions provider.
|
|
181
231
|
|
|
182
232
|
```typescript
|
|
183
|
-
|
|
233
|
+
const STATUS_ADMIN_PERMISSION: 'status:manage'
|
|
184
234
|
```
|
|
185
235
|
|
|
186
|
-
|
|
236
|
+
#### `i18nNamespace`
|
|
187
237
|
|
|
188
|
-
|
|
238
|
+
The i18n namespace for the status resource.
|
|
189
239
|
|
|
190
|
-
|
|
240
|
+
```typescript
|
|
241
|
+
const i18nNamespace: 'status'
|
|
242
|
+
```
|
|
191
243
|
|
|
192
|
-
|
|
244
|
+
#### `i18nRegistered`
|
|
245
|
+
|
|
246
|
+
The i18n registered.
|
|
193
247
|
|
|
194
248
|
```typescript
|
|
195
|
-
const
|
|
196
|
-
{
|
|
197
|
-
id: z.ZodString
|
|
198
|
-
serviceId: z.ZodString
|
|
199
|
-
status: z.ZodEnum<{ up: 'up'; down: 'down'; degraded: 'degraded' }>
|
|
200
|
-
httpStatus: z.ZodOptional<z.ZodNumber>
|
|
201
|
-
latencyMs: z.ZodOptional<z.ZodNumber>
|
|
202
|
-
error: z.ZodOptional<z.ZodString>
|
|
203
|
-
checkedAt: z.ZodString
|
|
204
|
-
},
|
|
205
|
-
z.core.$strip
|
|
206
|
-
>
|
|
249
|
+
const i18nRegistered: true
|
|
207
250
|
```
|
|
208
251
|
|
|
209
|
-
#### `
|
|
252
|
+
#### `resource`
|
|
210
253
|
|
|
211
|
-
|
|
254
|
+
The status resource definition.
|
|
212
255
|
|
|
213
256
|
```typescript
|
|
214
|
-
const
|
|
257
|
+
const resource: types.Resource<unknown>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
#### `routes`
|
|
261
|
+
|
|
262
|
+
Route array for status page endpoints: public read routes and admin-gated mutation routes.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const routes: (
|
|
266
|
+
| { method: 'get'; path: string; middlewares: never[]; handler: string }
|
|
267
|
+
| { method: 'post'; path: string; middlewares: string[]; handler: string }
|
|
268
|
+
| { method: 'patch'; path: string; middlewares: string[]; handler: string }
|
|
269
|
+
| { method: 'delete'; path: string; middlewares: string[]; handler: string }
|
|
270
|
+
)[]
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### `servicePropsSchema`
|
|
274
|
+
|
|
275
|
+
Full schema for a monitored service.
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
const servicePropsSchema: z.ZodObject<
|
|
215
279
|
{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
startedAt: z.ZodString
|
|
280
|
+
id: z.ZodString
|
|
281
|
+
createdAt: z.ZodString
|
|
282
|
+
updatedAt: z.ZodString
|
|
283
|
+
name: z.ZodString
|
|
284
|
+
url: z.ZodString
|
|
285
|
+
method: z.ZodDefault<z.ZodEnum<{ GET: 'GET'; HEAD: 'HEAD'; POST: 'POST' }>>
|
|
286
|
+
expectedStatus: z.ZodDefault<z.ZodNumber>
|
|
287
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>
|
|
288
|
+
intervalMs: z.ZodDefault<z.ZodNumber>
|
|
289
|
+
groupName: z.ZodOptional<z.ZodString>
|
|
290
|
+
enabled: z.ZodDefault<z.ZodBoolean>
|
|
228
291
|
},
|
|
229
292
|
z.core.$strip
|
|
230
293
|
>
|
|
@@ -250,20 +313,43 @@ const createServicePropsSchema: z.ZodObject<
|
|
|
250
313
|
>
|
|
251
314
|
```
|
|
252
315
|
|
|
253
|
-
#### `
|
|
316
|
+
#### `updateServicePropsSchema`
|
|
254
317
|
|
|
255
|
-
|
|
318
|
+
Schema for updating an existing service (all fields optional).
|
|
256
319
|
|
|
257
320
|
```typescript
|
|
258
|
-
const
|
|
321
|
+
const updateServicePropsSchema: z.ZodObject<
|
|
322
|
+
{
|
|
323
|
+
name: z.ZodOptional<z.ZodString>
|
|
324
|
+
url: z.ZodOptional<z.ZodString>
|
|
325
|
+
method: z.ZodOptional<z.ZodDefault<z.ZodEnum<{ GET: 'GET'; HEAD: 'HEAD'; POST: 'POST' }>>>
|
|
326
|
+
expectedStatus: z.ZodOptional<z.ZodDefault<z.ZodNumber>>
|
|
327
|
+
timeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>
|
|
328
|
+
intervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>
|
|
329
|
+
groupName: z.ZodOptional<z.ZodOptional<z.ZodString>>
|
|
330
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>
|
|
331
|
+
},
|
|
332
|
+
z.core.$strip
|
|
333
|
+
>
|
|
259
334
|
```
|
|
260
335
|
|
|
261
|
-
#### `
|
|
336
|
+
#### `checkPropsSchema`
|
|
262
337
|
|
|
263
|
-
|
|
338
|
+
Schema for a single health check result.
|
|
264
339
|
|
|
265
340
|
```typescript
|
|
266
|
-
const
|
|
341
|
+
const checkPropsSchema: z.ZodObject<
|
|
342
|
+
{
|
|
343
|
+
id: z.ZodString
|
|
344
|
+
serviceId: z.ZodString
|
|
345
|
+
status: z.ZodEnum<{ up: 'up'; down: 'down'; degraded: 'degraded' }>
|
|
346
|
+
httpStatus: z.ZodOptional<z.ZodNumber>
|
|
347
|
+
latencyMs: z.ZodOptional<z.ZodNumber>
|
|
348
|
+
error: z.ZodOptional<z.ZodString>
|
|
349
|
+
checkedAt: z.ZodString
|
|
350
|
+
},
|
|
351
|
+
z.core.$strip
|
|
352
|
+
>
|
|
267
353
|
```
|
|
268
354
|
|
|
269
355
|
#### `incidentPropsSchema`
|
|
@@ -294,457 +380,523 @@ const incidentPropsSchema: z.ZodObject<
|
|
|
294
380
|
>
|
|
295
381
|
```
|
|
296
382
|
|
|
297
|
-
#### `
|
|
383
|
+
#### `createIncidentPropsSchema`
|
|
298
384
|
|
|
299
|
-
|
|
385
|
+
Schema for creating a new incident.
|
|
300
386
|
|
|
301
387
|
```typescript
|
|
302
|
-
const
|
|
388
|
+
const createIncidentPropsSchema: z.ZodObject<
|
|
389
|
+
{
|
|
390
|
+
serviceId: z.ZodString
|
|
391
|
+
title: z.ZodString
|
|
392
|
+
description: z.ZodOptional<z.ZodString>
|
|
393
|
+
severity: z.ZodEnum<{ minor: 'minor'; major: 'major'; critical: 'critical' }>
|
|
394
|
+
status: z.ZodEnum<{
|
|
395
|
+
investigating: 'investigating'
|
|
396
|
+
identified: 'identified'
|
|
397
|
+
monitoring: 'monitoring'
|
|
398
|
+
resolved: 'resolved'
|
|
399
|
+
}>
|
|
400
|
+
autoDetected: z.ZodDefault<z.ZodBoolean>
|
|
401
|
+
startedAt: z.ZodString
|
|
402
|
+
},
|
|
403
|
+
z.core.$strip
|
|
404
|
+
>
|
|
303
405
|
```
|
|
304
406
|
|
|
305
|
-
#### `
|
|
407
|
+
#### `updateIncidentPropsSchema`
|
|
306
408
|
|
|
307
|
-
|
|
409
|
+
Schema for updating an existing incident (all fields optional).
|
|
308
410
|
|
|
309
411
|
```typescript
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
412
|
+
const updateIncidentPropsSchema: z.ZodObject<
|
|
413
|
+
{
|
|
414
|
+
title: z.ZodOptional<z.ZodString>
|
|
415
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>
|
|
416
|
+
severity: z.ZodOptional<z.ZodEnum<{ minor: 'minor'; major: 'major'; critical: 'critical' }>>
|
|
417
|
+
status: z.ZodOptional<
|
|
418
|
+
z.ZodEnum<{
|
|
419
|
+
investigating: 'investigating'
|
|
420
|
+
identified: 'identified'
|
|
421
|
+
monitoring: 'monitoring'
|
|
422
|
+
resolved: 'resolved'
|
|
423
|
+
}>
|
|
424
|
+
>
|
|
425
|
+
resolvedAt: z.ZodOptional<z.ZodOptional<z.ZodString>>
|
|
426
|
+
},
|
|
427
|
+
z.core.$strip
|
|
428
|
+
>
|
|
316
429
|
```
|
|
317
430
|
|
|
318
|
-
#### `
|
|
431
|
+
#### `uptimeWindowPropsSchema`
|
|
319
432
|
|
|
320
|
-
|
|
433
|
+
Schema for a pre-computed uptime statistics window.
|
|
321
434
|
|
|
322
435
|
```typescript
|
|
323
|
-
const
|
|
436
|
+
const uptimeWindowPropsSchema: z.ZodObject<
|
|
324
437
|
{
|
|
325
438
|
id: z.ZodString
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
timeoutMs: z.ZodDefault<z.ZodNumber>
|
|
333
|
-
intervalMs: z.ZodDefault<z.ZodNumber>
|
|
334
|
-
groupName: z.ZodOptional<z.ZodString>
|
|
335
|
-
enabled: z.ZodDefault<z.ZodBoolean>
|
|
439
|
+
serviceId: z.ZodString
|
|
440
|
+
window: z.ZodEnum<{ '1h': '1h'; '24h': '24h'; '7d': '7d'; '30d': '30d'; '90d': '90d' }>
|
|
441
|
+
uptimePct: z.ZodNumber
|
|
442
|
+
totalChecks: z.ZodNumber
|
|
443
|
+
upChecks: z.ZodNumber
|
|
444
|
+
avgLatencyMs: z.ZodNumber
|
|
336
445
|
},
|
|
337
446
|
z.core.$strip
|
|
338
447
|
>
|
|
339
448
|
```
|
|
340
449
|
|
|
341
|
-
|
|
450
|
+
### Namespaces
|
|
342
451
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
452
|
+
#### `z`
|
|
453
|
+
|
|
454
|
+
Re-exports the `zod` module — `z.<name>` is exactly `zod.<name>`, documented by that package (installed at `node_modules/zod`).
|
|
455
|
+
|
|
456
|
+
#### `handlers`
|
|
457
|
+
|
|
458
|
+
Re-exported as a namespace — reach every member below through it (e.g. `handlers.<name>`).
|
|
459
|
+
|
|
460
|
+
##### `handlers.createIncident(_resource)`
|
|
461
|
+
|
|
462
|
+
Creates a new incident record. Validates the request body against
|
|
463
|
+
the create incident schema before inserting.
|
|
346
464
|
|
|
347
465
|
```typescript
|
|
348
|
-
|
|
466
|
+
function createIncident({ tableName: _tableName }: { tableName: string }): (
|
|
467
|
+
req: MoleculeRequest,
|
|
468
|
+
res: MoleculeResponse,
|
|
469
|
+
) => Promise<
|
|
470
|
+
| { statusCode: number; body: { error: string; errorKey: string; props?: undefined } }
|
|
471
|
+
| {
|
|
472
|
+
statusCode: number
|
|
473
|
+
body: {
|
|
474
|
+
props: {
|
|
475
|
+
id: string
|
|
476
|
+
createdAt: string
|
|
477
|
+
updatedAt: string
|
|
478
|
+
serviceId: string
|
|
479
|
+
title: string
|
|
480
|
+
severity: 'minor' | 'major' | 'critical'
|
|
481
|
+
status: 'investigating' | 'identified' | 'monitoring' | 'resolved'
|
|
482
|
+
autoDetected: boolean
|
|
483
|
+
startedAt: string
|
|
484
|
+
description?: string | undefined
|
|
485
|
+
resolvedAt?: string | undefined
|
|
486
|
+
} | null
|
|
487
|
+
error?: undefined
|
|
488
|
+
errorKey?: undefined
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
>
|
|
349
492
|
```
|
|
350
493
|
|
|
351
|
-
|
|
494
|
+
- `_resource` — The service resource configuration (unused).
|
|
495
|
+
- `_resource.tableName` — The database table name for services.
|
|
352
496
|
|
|
353
|
-
|
|
354
|
-
|
|
497
|
+
**Returns:** A request handler that creates an incident and responds with the created record.
|
|
498
|
+
|
|
499
|
+
##### `handlers.createService(resource)`
|
|
500
|
+
|
|
501
|
+
Creates a new monitored service. Validates the request body against
|
|
502
|
+
the create service schema before inserting into the database.
|
|
355
503
|
|
|
356
504
|
```typescript
|
|
357
|
-
|
|
505
|
+
function createService({ tableName }: { tableName: string }): (
|
|
506
|
+
req: MoleculeRequest,
|
|
507
|
+
res: MoleculeResponse,
|
|
508
|
+
) => Promise<
|
|
509
|
+
| { statusCode: number; body: { error: string; errorKey: string; props?: undefined } }
|
|
510
|
+
| {
|
|
511
|
+
statusCode: number
|
|
512
|
+
body: {
|
|
513
|
+
props: {
|
|
514
|
+
id: string
|
|
515
|
+
createdAt: string
|
|
516
|
+
updatedAt: string
|
|
517
|
+
name: string
|
|
518
|
+
url: string
|
|
519
|
+
method: 'GET' | 'HEAD' | 'POST'
|
|
520
|
+
expectedStatus: number
|
|
521
|
+
timeoutMs: number
|
|
522
|
+
intervalMs: number
|
|
523
|
+
enabled: boolean
|
|
524
|
+
groupName?: string | undefined
|
|
525
|
+
} | null
|
|
526
|
+
error?: undefined
|
|
527
|
+
errorKey?: undefined
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
>
|
|
358
531
|
```
|
|
359
532
|
|
|
360
|
-
|
|
533
|
+
- `resource` — The service resource configuration.
|
|
534
|
+
- `resource.tableName` — The database table name for services.
|
|
361
535
|
|
|
362
|
-
|
|
363
|
-
|
|
536
|
+
**Returns:** A request handler that creates a service and responds with the created record.
|
|
537
|
+
|
|
538
|
+
##### `handlers.deleteService(resource)`
|
|
539
|
+
|
|
540
|
+
Deletes a monitored service by ID. Returns 404 if the service does not exist.
|
|
541
|
+
Associated checks, incidents, and uptime windows are removed via CASCADE.
|
|
364
542
|
|
|
365
543
|
```typescript
|
|
366
|
-
|
|
544
|
+
function deleteService({
|
|
545
|
+
tableName,
|
|
546
|
+
}: {
|
|
547
|
+
tableName: string
|
|
548
|
+
}): (
|
|
549
|
+
req: MoleculeRequest,
|
|
550
|
+
res: MoleculeResponse,
|
|
551
|
+
) => Promise<
|
|
552
|
+
| { statusCode: number; body: { error: string; errorKey: string; props?: undefined } }
|
|
553
|
+
| { statusCode: number; body: { props: { id: string }; error?: undefined; errorKey?: undefined } }
|
|
554
|
+
>
|
|
367
555
|
```
|
|
368
556
|
|
|
369
|
-
|
|
557
|
+
- `resource` — The service resource configuration.
|
|
558
|
+
- `resource.tableName` — The database table name for services.
|
|
370
559
|
|
|
371
|
-
|
|
560
|
+
**Returns:** A request handler that deletes a service and responds with 204 on success.
|
|
561
|
+
|
|
562
|
+
##### `handlers.getService(resource)`
|
|
563
|
+
|
|
564
|
+
Returns a single service by ID along with the last 50 check results.
|
|
372
565
|
|
|
373
566
|
```typescript
|
|
374
|
-
|
|
375
|
-
{
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
567
|
+
function getService({ tableName }: { tableName: string }): (req: MoleculeRequest) => Promise<
|
|
568
|
+
| { statusCode: number; body: { error: string; errorKey: string; props?: undefined } }
|
|
569
|
+
| {
|
|
570
|
+
statusCode: number
|
|
571
|
+
body: {
|
|
572
|
+
props: {
|
|
573
|
+
recentChecks: {
|
|
574
|
+
id: string
|
|
575
|
+
serviceId: string
|
|
576
|
+
status: 'up' | 'down' | 'degraded'
|
|
577
|
+
checkedAt: string
|
|
578
|
+
httpStatus?: number | undefined
|
|
579
|
+
latencyMs?: number | undefined
|
|
580
|
+
error?: string | undefined
|
|
581
|
+
}[]
|
|
582
|
+
id: string
|
|
583
|
+
createdAt: string
|
|
584
|
+
updatedAt: string
|
|
585
|
+
name: string
|
|
586
|
+
url: string
|
|
587
|
+
method: 'GET' | 'HEAD' | 'POST'
|
|
588
|
+
expectedStatus: number
|
|
589
|
+
timeoutMs: number
|
|
590
|
+
intervalMs: number
|
|
591
|
+
enabled: boolean
|
|
592
|
+
groupName?: string | undefined
|
|
593
|
+
}
|
|
594
|
+
error?: undefined
|
|
595
|
+
errorKey?: undefined
|
|
596
|
+
}
|
|
597
|
+
}
|
|
390
598
|
>
|
|
391
599
|
```
|
|
392
600
|
|
|
393
|
-
|
|
601
|
+
- `resource` — The service resource configuration.
|
|
602
|
+
- `resource.tableName` — The database table name for services.
|
|
394
603
|
|
|
395
|
-
|
|
604
|
+
**Returns:** A request handler that responds with a service and its recent checks.
|
|
605
|
+
|
|
606
|
+
##### `handlers.getStatus(resource)`
|
|
607
|
+
|
|
608
|
+
Returns the aggregated system health status.
|
|
609
|
+
|
|
610
|
+
Finds all enabled services, fetches the latest check for each,
|
|
611
|
+
and computes an overall status: `operational`, `degraded`, or `down`.
|
|
396
612
|
|
|
397
613
|
```typescript
|
|
398
|
-
|
|
399
|
-
{
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
614
|
+
function getStatus({ tableName }: { tableName: string }): (_req: MoleculeRequest) => Promise<
|
|
615
|
+
| {
|
|
616
|
+
statusCode: number
|
|
617
|
+
body: {
|
|
618
|
+
status: 'down' | 'degraded' | 'operational'
|
|
619
|
+
services: { id: string; name: string; status: string; latencyMs: number | null }[]
|
|
620
|
+
checkedAt: string
|
|
621
|
+
error?: undefined
|
|
622
|
+
errorKey?: undefined
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
| {
|
|
626
|
+
statusCode: number
|
|
627
|
+
body: {
|
|
628
|
+
error: string
|
|
629
|
+
errorKey: string
|
|
630
|
+
status?: undefined
|
|
631
|
+
services?: undefined
|
|
632
|
+
checkedAt?: undefined
|
|
633
|
+
}
|
|
634
|
+
}
|
|
410
635
|
>
|
|
411
636
|
```
|
|
412
637
|
|
|
413
|
-
|
|
638
|
+
- `resource` — The service resource configuration.
|
|
639
|
+
- `resource.tableName` — The database table name for services.
|
|
414
640
|
|
|
415
|
-
|
|
641
|
+
**Returns:** A request handler that responds with overall system status.
|
|
642
|
+
|
|
643
|
+
##### `handlers.getUptime(_resource)`
|
|
644
|
+
|
|
645
|
+
Returns uptime window statistics for all services, or filtered by
|
|
646
|
+
`?serviceId=` query parameter for a specific service.
|
|
416
647
|
|
|
417
648
|
```typescript
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
649
|
+
function getUptime({ tableName: _tableName }: { tableName: string }): (
|
|
650
|
+
req: MoleculeRequest,
|
|
651
|
+
) => Promise<
|
|
652
|
+
| {
|
|
653
|
+
statusCode: number
|
|
654
|
+
body: {
|
|
655
|
+
id: string
|
|
656
|
+
serviceId: string
|
|
657
|
+
window: '1h' | '24h' | '7d' | '30d' | '90d'
|
|
658
|
+
uptimePct: number
|
|
659
|
+
totalChecks: number
|
|
660
|
+
upChecks: number
|
|
661
|
+
avgLatencyMs: number
|
|
662
|
+
}[]
|
|
663
|
+
}
|
|
664
|
+
| { statusCode: number; body: { error: string; errorKey: string } }
|
|
429
665
|
>
|
|
430
666
|
```
|
|
431
667
|
|
|
432
|
-
|
|
668
|
+
- `_resource` — The service resource configuration (unused).
|
|
669
|
+
- `_resource.tableName` — The database table name for services.
|
|
433
670
|
|
|
434
|
-
|
|
671
|
+
**Returns:** A request handler that responds with uptime window records.
|
|
435
672
|
|
|
436
|
-
|
|
673
|
+
##### `handlers.listIncidents(_resource)`
|
|
437
674
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
675
|
+
Lists incidents with support for `?status=` filtering and pagination
|
|
676
|
+
via `?limit=` and `?offset=` query parameters.
|
|
677
|
+
|
|
678
|
+
```typescript
|
|
679
|
+
function listIncidents({ tableName: _tableName }: { tableName: string }): (
|
|
680
|
+
req: MoleculeRequest,
|
|
681
|
+
) => Promise<
|
|
682
|
+
| {
|
|
683
|
+
statusCode: number
|
|
684
|
+
body: {
|
|
685
|
+
id: string
|
|
686
|
+
createdAt: string
|
|
687
|
+
updatedAt: string
|
|
688
|
+
serviceId: string
|
|
689
|
+
title: string
|
|
690
|
+
severity: 'minor' | 'major' | 'critical'
|
|
691
|
+
status: 'investigating' | 'identified' | 'monitoring' | 'resolved'
|
|
692
|
+
autoDetected: boolean
|
|
693
|
+
startedAt: string
|
|
694
|
+
description?: string | undefined
|
|
695
|
+
resolvedAt?: string | undefined
|
|
696
|
+
}[]
|
|
697
|
+
}
|
|
698
|
+
| { statusCode: number; body: { error: string; errorKey: string } }
|
|
699
|
+
>
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
- `_resource` — The service resource configuration (unused).
|
|
703
|
+
- `_resource.tableName` — The database table name for services.
|
|
704
|
+
|
|
705
|
+
**Returns:** A request handler that responds with a paginated array of incidents.
|
|
706
|
+
|
|
707
|
+
##### `handlers.listServices(resource)`
|
|
708
|
+
|
|
709
|
+
Lists all services along with each service's latest check result.
|
|
710
|
+
|
|
711
|
+
```typescript
|
|
712
|
+
function listServices({ tableName }: { tableName: string }): (_req: MoleculeRequest) => Promise<
|
|
713
|
+
| {
|
|
714
|
+
statusCode: number
|
|
715
|
+
body: {
|
|
716
|
+
latestCheck: {
|
|
717
|
+
id: string
|
|
718
|
+
serviceId: string
|
|
719
|
+
status: 'up' | 'down' | 'degraded'
|
|
720
|
+
checkedAt: string
|
|
721
|
+
httpStatus?: number | undefined
|
|
722
|
+
latencyMs?: number | undefined
|
|
723
|
+
error?: string | undefined
|
|
724
|
+
}
|
|
725
|
+
id: string
|
|
726
|
+
createdAt: string
|
|
727
|
+
updatedAt: string
|
|
728
|
+
name: string
|
|
729
|
+
url: string
|
|
730
|
+
method: 'GET' | 'HEAD' | 'POST'
|
|
731
|
+
expectedStatus: number
|
|
732
|
+
timeoutMs: number
|
|
733
|
+
intervalMs: number
|
|
734
|
+
enabled: boolean
|
|
735
|
+
groupName?: string | undefined
|
|
736
|
+
}[]
|
|
737
|
+
}
|
|
738
|
+
| { statusCode: number; body: { error: string; errorKey: string } }
|
|
739
|
+
>
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
- `resource` — The service resource configuration.
|
|
743
|
+
- `resource.tableName` — The database table name for services.
|
|
744
|
+
|
|
745
|
+
**Returns:** A request handler that responds with an array of services and their latest check.
|
|
746
|
+
|
|
747
|
+
##### `handlers.updateIncident(_resource)`
|
|
748
|
+
|
|
749
|
+
Updates an existing incident by ID. Validates the request body against
|
|
750
|
+
the update incident schema (all fields optional) before patching.
|
|
751
|
+
|
|
752
|
+
```typescript
|
|
753
|
+
function updateIncident({ tableName: _tableName }: { tableName: string }): (
|
|
754
|
+
req: MoleculeRequest,
|
|
755
|
+
res: MoleculeResponse,
|
|
756
|
+
) => Promise<
|
|
757
|
+
| { statusCode: number; body: { error: string; errorKey: string; props?: undefined } }
|
|
758
|
+
| {
|
|
759
|
+
statusCode: number
|
|
760
|
+
body: {
|
|
761
|
+
props: {
|
|
762
|
+
id: string
|
|
763
|
+
createdAt: string
|
|
764
|
+
updatedAt: string
|
|
765
|
+
serviceId: string
|
|
766
|
+
title: string
|
|
767
|
+
severity: 'minor' | 'major' | 'critical'
|
|
768
|
+
status: 'investigating' | 'identified' | 'monitoring' | 'resolved'
|
|
769
|
+
autoDetected: boolean
|
|
770
|
+
startedAt: string
|
|
771
|
+
description?: string | undefined
|
|
772
|
+
resolvedAt?: string | undefined
|
|
773
|
+
} | null
|
|
774
|
+
error?: undefined
|
|
775
|
+
errorKey?: undefined
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
>
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
- `_resource` — The service resource configuration (unused).
|
|
782
|
+
- `_resource.tableName` — The database table name for services.
|
|
783
|
+
|
|
784
|
+
**Returns:** A request handler that updates an incident and responds with the updated record.
|
|
785
|
+
|
|
786
|
+
##### `handlers.updateService(resource)`
|
|
787
|
+
|
|
788
|
+
Updates an existing monitored service by ID. Validates the request body
|
|
789
|
+
against the update service schema (all fields optional) before patching.
|
|
790
|
+
|
|
791
|
+
```typescript
|
|
792
|
+
function updateService({ tableName }: { tableName: string }): (
|
|
793
|
+
req: MoleculeRequest,
|
|
794
|
+
res: MoleculeResponse,
|
|
795
|
+
) => Promise<
|
|
796
|
+
| { statusCode: number; body: { error: string; errorKey: string; props?: undefined } }
|
|
797
|
+
| {
|
|
798
|
+
statusCode: number
|
|
799
|
+
body: {
|
|
800
|
+
props: {
|
|
801
|
+
id: string
|
|
802
|
+
createdAt: string
|
|
803
|
+
updatedAt: string
|
|
804
|
+
name: string
|
|
805
|
+
url: string
|
|
806
|
+
method: 'GET' | 'HEAD' | 'POST'
|
|
807
|
+
expectedStatus: number
|
|
808
|
+
timeoutMs: number
|
|
809
|
+
intervalMs: number
|
|
810
|
+
enabled: boolean
|
|
811
|
+
groupName?: string | undefined
|
|
812
|
+
} | null
|
|
813
|
+
error?: undefined
|
|
814
|
+
errorKey?: undefined
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
>
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
- `resource` — The service resource configuration.
|
|
821
|
+
- `resource.tableName` — The database table name for services.
|
|
822
|
+
|
|
823
|
+
**Returns:** A request handler that updates a service and responds with the updated record.
|
|
448
824
|
|
|
449
825
|
#### `types`
|
|
450
826
|
|
|
451
|
-
|
|
827
|
+
Re-exported as a namespace — reach every member below through it (e.g. `types.<name>`).
|
|
452
828
|
|
|
453
|
-
|
|
454
|
-
- `types.CreateIncidentProps` — type: Fields accepted when creating a new incident.
|
|
455
|
-
- `types.CreateServiceProps` — type: Fields accepted when creating a new service.
|
|
456
|
-
- `types.IncidentProps` — type: Full incident record properties.
|
|
457
|
-
- `types.ServiceProps` — type: Full service record properties.
|
|
458
|
-
- `types.UpdateIncidentProps` — type: Updatable incident fields.
|
|
459
|
-
- `types.UpdateServiceProps` — type: Updatable service fields.
|
|
460
|
-
- `types.UptimeWindowProps` — type: Uptime window statistics properties.
|
|
461
|
-
- `types.Resource` — type: An object describing the `status` resource.
|
|
829
|
+
##### `types.ServiceProps`
|
|
462
830
|
|
|
463
|
-
|
|
831
|
+
Full service record properties.
|
|
832
|
+
|
|
833
|
+
```typescript
|
|
834
|
+
type ServiceProps = z.infer<typeof servicePropsSchema>
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
##### `types.CreateServiceProps`
|
|
838
|
+
|
|
839
|
+
Fields accepted when creating a new service.
|
|
840
|
+
|
|
841
|
+
```typescript
|
|
842
|
+
type CreateServiceProps = z.infer<typeof createServicePropsSchema>
|
|
843
|
+
```
|
|
844
|
+
|
|
845
|
+
##### `types.UpdateServiceProps`
|
|
846
|
+
|
|
847
|
+
Updatable service fields.
|
|
848
|
+
|
|
849
|
+
```typescript
|
|
850
|
+
type UpdateServiceProps = z.infer<typeof updateServicePropsSchema>
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
##### `types.CheckProps`
|
|
854
|
+
|
|
855
|
+
Health check result properties.
|
|
856
|
+
|
|
857
|
+
```typescript
|
|
858
|
+
type CheckProps = z.infer<typeof checkPropsSchema>
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
##### `types.IncidentProps`
|
|
862
|
+
|
|
863
|
+
Full incident record properties.
|
|
464
864
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
- `z.ZodCoercedDate` — interface
|
|
501
|
-
- `z.coerce` — namespace
|
|
502
|
-
- `z.string` — function
|
|
503
|
-
- `z.email` — function
|
|
504
|
-
- `z.guid` — function
|
|
505
|
-
- `z.uuid` — function
|
|
506
|
-
- `z.uuidv4` — function
|
|
507
|
-
- `z.uuidv6` — function
|
|
508
|
-
- `z.uuidv7` — function
|
|
509
|
-
- `z.url` — function
|
|
510
|
-
- `z.httpUrl` — function
|
|
511
|
-
- `z.emoji` — function
|
|
512
|
-
- `z.nanoid` — function
|
|
513
|
-
- `z.cuid` — function: Validates a CUID v1 string.
|
|
514
|
-
- `z.cuid2` — function
|
|
515
|
-
- `z.ulid` — function
|
|
516
|
-
- `z.xid` — function
|
|
517
|
-
- `z.ksuid` — function
|
|
518
|
-
- `z.ipv4` — function
|
|
519
|
-
- `z.mac` — function
|
|
520
|
-
- `z.ipv6` — function
|
|
521
|
-
- `z.cidrv4` — function
|
|
522
|
-
- `z.cidrv6` — function
|
|
523
|
-
- `z.base64` — function
|
|
524
|
-
- `z.base64url` — function
|
|
525
|
-
- `z.e164` — function
|
|
526
|
-
- `z.jwt` — function
|
|
527
|
-
- `z.stringFormat` — function
|
|
528
|
-
- `z.hostname` — function
|
|
529
|
-
- `z.hex` — function
|
|
530
|
-
- `z.hash` — function
|
|
531
|
-
- `z.number` — function
|
|
532
|
-
- `z.int` — function
|
|
533
|
-
- `z.float32` — function
|
|
534
|
-
- `z.float64` — function
|
|
535
|
-
- `z.int32` — function
|
|
536
|
-
- `z.uint32` — function
|
|
537
|
-
- `z.boolean` — function
|
|
538
|
-
- `z.bigint` — function
|
|
539
|
-
- `z.int64` — function
|
|
540
|
-
- `z.uint64` — function
|
|
541
|
-
- `z.symbol` — function
|
|
542
|
-
- `z.any` — function
|
|
543
|
-
- `z.unknown` — function
|
|
544
|
-
- `z.never` — function
|
|
545
|
-
- `z.date` — function
|
|
546
|
-
- `z.array` — function
|
|
547
|
-
- `z.keyof` — function
|
|
548
|
-
- `z.object` — function
|
|
549
|
-
- `z.strictObject` — function
|
|
550
|
-
- `z.looseObject` — function
|
|
551
|
-
- `z.union` — function
|
|
552
|
-
- `z.xor` — function: Creates an exclusive union (XOR) where exactly one option must match.
|
|
553
|
-
- `z.discriminatedUnion` — function
|
|
554
|
-
- `z.intersection` — function
|
|
555
|
-
- `z.tuple` — function
|
|
556
|
-
- `z.record` — function
|
|
557
|
-
- `z.partialRecord` — function
|
|
558
|
-
- `z.looseRecord` — function
|
|
559
|
-
- `z.map` — function
|
|
560
|
-
- `z.set` — function
|
|
561
|
-
- `z.nativeEnum` — function
|
|
562
|
-
- `z.literal` — function
|
|
563
|
-
- `z.file` — function
|
|
564
|
-
- `z.transform` — function
|
|
565
|
-
- `z.optional` — function
|
|
566
|
-
- `z.exactOptional` — function
|
|
567
|
-
- `z.nullable` — function
|
|
568
|
-
- `z.nullish` — function
|
|
569
|
-
- `z._default` — function
|
|
570
|
-
- `z.prefault` — function
|
|
571
|
-
- `z.nonoptional` — function
|
|
572
|
-
- `z.success` — function
|
|
573
|
-
- `z.nan` — function
|
|
574
|
-
- `z.pipe` — function
|
|
575
|
-
- `z.codec` — function
|
|
576
|
-
- `z.invertCodec` — function
|
|
577
|
-
- `z.readonly` — function
|
|
578
|
-
- `z.templateLiteral` — function
|
|
579
|
-
- `z.lazy` — function
|
|
580
|
-
- `z.promise` — function
|
|
581
|
-
- `z._function` — function
|
|
582
|
-
- `z.check` — function
|
|
583
|
-
- `z.custom` — function
|
|
584
|
-
- `z.refine` — function
|
|
585
|
-
- `z.superRefine` — function
|
|
586
|
-
- `z.json` — function
|
|
587
|
-
- `z.preprocess` — function
|
|
588
|
-
- `z.ZodStandardSchemaWithJSON` — type
|
|
589
|
-
- `z.ZodType` — interface
|
|
590
|
-
- `z._ZodType` — interface
|
|
591
|
-
- `z._ZodString` — interface
|
|
592
|
-
- `z.ZodString` — interface
|
|
593
|
-
- `z.ZodStringFormat` — interface
|
|
594
|
-
- `z.ZodEmail` — interface
|
|
595
|
-
- `z.ZodGUID` — interface
|
|
596
|
-
- `z.ZodUUID` — interface
|
|
597
|
-
- `z.ZodURL` — interface
|
|
598
|
-
- `z.ZodEmoji` — interface
|
|
599
|
-
- `z.ZodNanoID` — interface
|
|
600
|
-
- `z.ZodCUID` — interface
|
|
601
|
-
- `z.ZodCUID2` — interface
|
|
602
|
-
- `z.ZodULID` — interface
|
|
603
|
-
- `z.ZodXID` — interface
|
|
604
|
-
- `z.ZodKSUID` — interface
|
|
605
|
-
- `z.ZodIPv4` — interface
|
|
606
|
-
- `z.ZodMAC` — interface
|
|
607
|
-
- `z.ZodIPv6` — interface
|
|
608
|
-
- `z.ZodCIDRv4` — interface
|
|
609
|
-
- `z.ZodCIDRv6` — interface
|
|
610
|
-
- `z.ZodBase64` — interface
|
|
611
|
-
- `z.ZodBase64URL` — interface
|
|
612
|
-
- `z.ZodE164` — interface
|
|
613
|
-
- `z.ZodJWT` — interface
|
|
614
|
-
- `z.ZodCustomStringFormat` — interface
|
|
615
|
-
- `z._ZodNumber` — interface
|
|
616
|
-
- `z.ZodNumber` — interface
|
|
617
|
-
- `z.ZodNumberFormat` — interface
|
|
618
|
-
- `z.ZodInt` — interface
|
|
619
|
-
- `z.ZodFloat32` — interface
|
|
620
|
-
- `z.ZodFloat64` — interface
|
|
621
|
-
- `z.ZodInt32` — interface
|
|
622
|
-
- `z.ZodUInt32` — interface
|
|
623
|
-
- `z._ZodBoolean` — interface
|
|
624
|
-
- `z.ZodBoolean` — interface
|
|
625
|
-
- `z._ZodBigInt` — interface
|
|
626
|
-
- `z.ZodBigInt` — interface
|
|
627
|
-
- `z.ZodBigIntFormat` — interface
|
|
628
|
-
- `z.ZodSymbol` — interface
|
|
629
|
-
- `z.ZodUndefined` — interface
|
|
630
|
-
- `z.undefined` — function
|
|
631
|
-
- `z.ZodNull` — interface
|
|
632
|
-
- `z.null` — function
|
|
633
|
-
- `z.ZodAny` — interface
|
|
634
|
-
- `z.ZodUnknown` — interface
|
|
635
|
-
- `z.ZodNever` — interface
|
|
636
|
-
- `z.ZodVoid` — interface
|
|
637
|
-
- `z.void` — function
|
|
638
|
-
- `z._ZodDate` — interface
|
|
639
|
-
- `z.ZodDate` — interface
|
|
640
|
-
- `z.ZodArray` — interface
|
|
641
|
-
- `z.SafeExtendShape` — type
|
|
642
|
-
- `z.ZodObject` — interface
|
|
643
|
-
- `z.ZodUnion` — interface
|
|
644
|
-
- `z.ZodXor` — interface
|
|
645
|
-
- `z.ZodDiscriminatedUnion` — interface
|
|
646
|
-
- `z.ZodIntersection` — interface
|
|
647
|
-
- `z.ZodTuple` — interface
|
|
648
|
-
- `z.ZodRecord` — interface
|
|
649
|
-
- `z.ZodMap` — interface
|
|
650
|
-
- `z.ZodSet` — interface
|
|
651
|
-
- `z.ZodEnum` — interface
|
|
652
|
-
- `z.enum` — function
|
|
653
|
-
- `z.ZodLiteral` — interface
|
|
654
|
-
- `z.ZodFile` — interface
|
|
655
|
-
- `z.ZodTransform` — interface
|
|
656
|
-
- `z.ZodOptional` — interface
|
|
657
|
-
- `z.ZodExactOptional` — interface
|
|
658
|
-
- `z.ZodNullable` — interface
|
|
659
|
-
- `z.ZodDefault` — interface
|
|
660
|
-
- `z.ZodPrefault` — interface
|
|
661
|
-
- `z.ZodNonOptional` — interface
|
|
662
|
-
- `z.ZodSuccess` — interface
|
|
663
|
-
- `z.ZodCatch` — interface
|
|
664
|
-
- `z.catch` — function
|
|
665
|
-
- `z.ZodNaN` — interface
|
|
666
|
-
- `z.ZodPipe` — interface
|
|
667
|
-
- `z.ZodCodec` — interface
|
|
668
|
-
- `z.ZodPreprocess` — interface
|
|
669
|
-
- `z.ZodReadonly` — interface
|
|
670
|
-
- `z.ZodTemplateLiteral` — interface
|
|
671
|
-
- `z.ZodLazy` — interface
|
|
672
|
-
- `z.ZodPromise` — interface
|
|
673
|
-
- `z.ZodFunction` — interface
|
|
674
|
-
- `z.function` — function
|
|
675
|
-
- `z.ZodCustom` — interface
|
|
676
|
-
- `z.describe` — const
|
|
677
|
-
- `z.meta` — const
|
|
678
|
-
- `z.instanceof` — function
|
|
679
|
-
- `z.stringbool` — const
|
|
680
|
-
- `z.ZodJSONSchemaInternals` — interface
|
|
681
|
-
- `z.ZodJSONSchema` — interface
|
|
682
|
-
- `z.lt` — function
|
|
683
|
-
- `z.lte` — function
|
|
684
|
-
- `z.gt` — function
|
|
685
|
-
- `z.gte` — function
|
|
686
|
-
- `z.positive` — function
|
|
687
|
-
- `z.negative` — function
|
|
688
|
-
- `z.nonpositive` — function
|
|
689
|
-
- `z.nonnegative` — function
|
|
690
|
-
- `z.multipleOf` — function
|
|
691
|
-
- `z.maxSize` — function
|
|
692
|
-
- `z.minSize` — function
|
|
693
|
-
- `z.size` — function
|
|
694
|
-
- `z.maxLength` — function
|
|
695
|
-
- `z.minLength` — function
|
|
696
|
-
- `z.length` — function
|
|
697
|
-
- `z.regex` — function
|
|
698
|
-
- `z.lowercase` — function
|
|
699
|
-
- `z.uppercase` — function
|
|
700
|
-
- `z.includes` — function
|
|
701
|
-
- `z.startsWith` — function
|
|
702
|
-
- `z.endsWith` — function
|
|
703
|
-
- `z.property` — function
|
|
704
|
-
- `z.mime` — function
|
|
705
|
-
- `z.overwrite` — function
|
|
706
|
-
- `z.normalize` — function
|
|
707
|
-
- `z.trim` — function
|
|
708
|
-
- `z.toLowerCase` — function
|
|
709
|
-
- `z.toUpperCase` — function
|
|
710
|
-
- `z.slugify` — function
|
|
711
|
-
- `z.RefinementCtx` — interface
|
|
712
|
-
- `z.ZodIssue` — type
|
|
713
|
-
- `z.ZodError` — interface: An Error-like class used to store Zod validation issues.
|
|
714
|
-
- `z.ZodRealError` — const
|
|
715
|
-
- `z.ZodFlattenedError` — type
|
|
716
|
-
- `z.ZodFormattedError` — type
|
|
717
|
-
- `z.ZodErrorMap` — interface
|
|
718
|
-
- `z.IssueData` — type
|
|
719
|
-
- `z.ZodSafeParseResult` — type
|
|
720
|
-
- `z.ZodSafeParseSuccess` — type
|
|
721
|
-
- `z.ZodSafeParseError` — type
|
|
722
|
-
- `z.parse` — const
|
|
723
|
-
- `z.parseAsync` — const
|
|
724
|
-
- `z.safeParse` — const
|
|
725
|
-
- `z.safeParseAsync` — const
|
|
726
|
-
- `z.encode` — const
|
|
727
|
-
- `z.decode` — const
|
|
728
|
-
- `z.encodeAsync` — const
|
|
729
|
-
- `z.decodeAsync` — const
|
|
730
|
-
- `z.safeEncode` — const
|
|
731
|
-
- `z.safeDecode` — const
|
|
732
|
-
- `z.safeEncodeAsync` — const
|
|
733
|
-
- `z.safeDecodeAsync` — const
|
|
734
|
-
- `z.setErrorMap` — function
|
|
735
|
-
- `z.getErrorMap` — function
|
|
736
|
-
- `z.TypeOf` — type
|
|
737
|
-
- `z.Infer` — type
|
|
738
|
-
- `z.ZodFirstPartySchemaTypes` — type
|
|
739
|
-
- `z.ZodIssueCode` — const
|
|
740
|
-
- `z.inferFlattenedErrors` — type
|
|
741
|
-
- `z.inferFormattedError` — type
|
|
742
|
-
- `z.BRAND` — type: Use `z.$brand` instead
|
|
743
|
-
- `z.ZodTypeAny` — interface
|
|
744
|
-
- `z.ZodSchema` — interface
|
|
745
|
-
- `z.Schema` — interface
|
|
746
|
-
- `z.ZodRawShape` — type: Included for Zod 3 compatibility
|
|
747
|
-
- `z.ZodFirstPartyTypeKind` — enum
|
|
865
|
+
```typescript
|
|
866
|
+
type IncidentProps = z.infer<typeof incidentPropsSchema>
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
##### `types.CreateIncidentProps`
|
|
870
|
+
|
|
871
|
+
Fields accepted when creating a new incident.
|
|
872
|
+
|
|
873
|
+
```typescript
|
|
874
|
+
type CreateIncidentProps = z.infer<typeof createIncidentPropsSchema>
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
##### `types.UpdateIncidentProps`
|
|
878
|
+
|
|
879
|
+
Updatable incident fields.
|
|
880
|
+
|
|
881
|
+
```typescript
|
|
882
|
+
type UpdateIncidentProps = z.infer<typeof updateIncidentPropsSchema>
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
##### `types.UptimeWindowProps`
|
|
886
|
+
|
|
887
|
+
Uptime window statistics properties.
|
|
888
|
+
|
|
889
|
+
```typescript
|
|
890
|
+
type UptimeWindowProps = z.infer<typeof uptimeWindowPropsSchema>
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
##### `types.Resource`
|
|
894
|
+
|
|
895
|
+
An object describing the `status` resource.
|
|
896
|
+
|
|
897
|
+
```typescript
|
|
898
|
+
type Resource<T = unknown> = resourceTypes.Resource<T>
|
|
899
|
+
```
|
|
748
900
|
|
|
749
901
|
## Injection Notes
|
|
750
902
|
|