@molecule/api-resource-status-page 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +839 -0
  2. package/package.json +15 -14
package/README.md ADDED
@@ -0,0 +1,839 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T01:49:21.194Z
7
+ -->
8
+
9
+ # @molecule/api-resource-status-page
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ Status page resource for molecule.dev.
16
+
17
+ Public status-page backend: monitored services, incidents with lifecycle
18
+ updates, health-check history, and uptime windows. The read endpoints power
19
+ a public status page; the mutation endpoints are for operators.
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { createRequestHandler } from '@molecule/api-resource'
25
+ import { createRequestHandlerMap, routes } from '@molecule/api-resource-status-page'
26
+
27
+ // The handler map is a FACTORY (like api-resource-device) — build it with
28
+ // the createRequestHandler from @molecule/api-resource (mlcl inject does this):
29
+ const requestHandlerMap = createRequestHandlerMap(createRequestHandler)
30
+
31
+ // Public reads: GET /status, GET /status/services, GET /status/services/:id,
32
+ // GET /status/incidents, GET /status/uptime
33
+ // Admin-only: POST/PATCH/DELETE /status/services(/:id),
34
+ // POST/PATCH /status/incidents(/:id)
35
+ ```
36
+
37
+ ## Type
38
+
39
+ `resource`
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install @molecule/api-resource-status-page @molecule/api-bond @molecule/api-database @molecule/api-i18n @molecule/api-locales-status-page @molecule/api-monitoring @molecule/api-notifications @molecule/api-permissions @molecule/api-resource @molecule/api-scheduler zod
45
+ ```
46
+
47
+ ## API
48
+
49
+ ### Types
50
+
51
+ #### `CheckProps`
52
+
53
+ Health check result properties.
54
+
55
+ ```typescript
56
+ type CheckProps = z.infer<typeof checkPropsSchema>
57
+ ```
58
+
59
+ #### `CreateIncidentProps`
60
+
61
+ Fields accepted when creating a new incident.
62
+
63
+ ```typescript
64
+ type CreateIncidentProps = z.infer<typeof createIncidentPropsSchema>
65
+ ```
66
+
67
+ #### `CreateServiceProps`
68
+
69
+ Fields accepted when creating a new service.
70
+
71
+ ```typescript
72
+ type CreateServiceProps = z.infer<typeof createServicePropsSchema>
73
+ ```
74
+
75
+ #### `IncidentProps`
76
+
77
+ Full incident record properties.
78
+
79
+ ```typescript
80
+ type IncidentProps = z.infer<typeof incidentPropsSchema>
81
+ ```
82
+
83
+ #### `ServiceProps`
84
+
85
+ Full service record properties.
86
+
87
+ ```typescript
88
+ type ServiceProps = z.infer<typeof servicePropsSchema>
89
+ ```
90
+
91
+ #### `UpdateIncidentProps`
92
+
93
+ Updatable incident fields.
94
+
95
+ ```typescript
96
+ type UpdateIncidentProps = z.infer<typeof updateIncidentPropsSchema>
97
+ ```
98
+
99
+ #### `UpdateServiceProps`
100
+
101
+ Updatable service fields.
102
+
103
+ ```typescript
104
+ type UpdateServiceProps = z.infer<typeof updateServicePropsSchema>
105
+ ```
106
+
107
+ #### `UptimeWindowProps`
108
+
109
+ Uptime window statistics properties.
110
+
111
+ ```typescript
112
+ type UptimeWindowProps = z.infer<typeof uptimeWindowPropsSchema>
113
+ ```
114
+
115
+ ### Functions
116
+
117
+ #### `createRequestHandlerMap(createRequestHandler)`
118
+
119
+ Creates the full request handler map for the Status resource. Maps handler names
120
+ (matching route definitions) to Express middleware via `createRequestHandler`.
121
+
122
+ `requireAdmin` is the status-management authorizer middleware referenced by the
123
+ mutating routes (`createService`/`updateService`/`deleteService`/`createIncident`/
124
+ `updateIncident`). It must live here as a real handler-map key so the mlcl
125
+ injector's route scanner preserves it — a bare middleware string that isn't a
126
+ handler-map key is silently dropped (which is why the previous `'auth'` gate was
127
+ inert and the mutating routes shipped public). It is already an Express
128
+ middleware, so it is NOT wrapped in `createRequestHandler`.
129
+
130
+ ```typescript
131
+ function createRequestHandlerMap(
132
+ createRequestHandler: (
133
+ handler: Handler,
134
+ ) => (req: MoleculeRequest, res: MoleculeResponse, next: MoleculeNextFunction) => Promise<void>,
135
+ ): Record<string, MoleculeRequestHandler>
136
+ ```
137
+
138
+ - `createRequestHandler` — Factory from `@molecule/api-resource` that wraps handler configs into Express middleware.
139
+
140
+ **Returns:** A record mapping handler names to Express middleware functions.
141
+
142
+ #### `createResource()`
143
+
144
+ Creates a new status resource definition.
145
+
146
+ ```typescript
147
+ function createResource(): types.Resource<unknown>
148
+ ```
149
+
150
+ **Returns:** The status resource descriptor with name, tableName, and schema.
151
+
152
+ #### `isStatusAdmin(res)`
153
+
154
+ Resolves whether the current request's session belongs to an actor authorized
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.
159
+
160
+ Use this for in-handler defense-in-depth (it does not depend on the route
161
+ middleware being preserved by the injector).
162
+
163
+ ```typescript
164
+ function isStatusAdmin(res: MoleculeResponse): Promise<boolean>
165
+ ```
166
+
167
+ - `res` — The response whose `locals.session` is inspected.
168
+
169
+ **Returns:** `true` when the session is an authorized status page admin.
170
+
171
+ #### `requireAdmin()`
172
+
173
+ Route middleware that gates the admin-only status page mutation routes. Calls
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.
178
+
179
+ Exposed as a request-handler-map key so the injector's route scanner keeps it
180
+ (unlike the inert global `'auth'` string, which is dropped).
181
+
182
+ ```typescript
183
+ function requireAdmin(): MoleculeRequestHandler
184
+ ```
185
+
186
+ **Returns:** An Express-compatible middleware function.
187
+
188
+ ### Constants
189
+
190
+ #### `checkPropsSchema`
191
+
192
+ Schema for a single health check result.
193
+
194
+ ```typescript
195
+ const checkPropsSchema: z.ZodObject<
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
+ >
207
+ ```
208
+
209
+ #### `createIncidentPropsSchema`
210
+
211
+ Schema for creating a new incident.
212
+
213
+ ```typescript
214
+ const createIncidentPropsSchema: z.ZodObject<
215
+ {
216
+ status: z.ZodEnum<{
217
+ investigating: 'investigating'
218
+ identified: 'identified'
219
+ monitoring: 'monitoring'
220
+ resolved: 'resolved'
221
+ }>
222
+ serviceId: z.ZodString
223
+ title: z.ZodString
224
+ description: z.ZodOptional<z.ZodString>
225
+ severity: z.ZodEnum<{ minor: 'minor'; major: 'major'; critical: 'critical' }>
226
+ autoDetected: z.ZodDefault<z.ZodBoolean>
227
+ startedAt: z.ZodString
228
+ },
229
+ z.core.$strip
230
+ >
231
+ ```
232
+
233
+ #### `createServicePropsSchema`
234
+
235
+ Schema for creating a new service.
236
+
237
+ ```typescript
238
+ const createServicePropsSchema: z.ZodObject<
239
+ {
240
+ name: z.ZodString
241
+ url: z.ZodString
242
+ method: z.ZodDefault<z.ZodEnum<{ GET: 'GET'; HEAD: 'HEAD'; POST: 'POST' }>>
243
+ expectedStatus: z.ZodDefault<z.ZodNumber>
244
+ timeoutMs: z.ZodDefault<z.ZodNumber>
245
+ intervalMs: z.ZodDefault<z.ZodNumber>
246
+ groupName: z.ZodOptional<z.ZodString>
247
+ enabled: z.ZodDefault<z.ZodBoolean>
248
+ },
249
+ z.core.$strip
250
+ >
251
+ ```
252
+
253
+ #### `i18nNamespace`
254
+
255
+ The i18n namespace for the status resource.
256
+
257
+ ```typescript
258
+ const i18nNamespace: 'status'
259
+ ```
260
+
261
+ #### `i18nRegistered`
262
+
263
+ The i18n registered.
264
+
265
+ ```typescript
266
+ const i18nRegistered: true
267
+ ```
268
+
269
+ #### `incidentPropsSchema`
270
+
271
+ Full schema for a service incident.
272
+
273
+ ```typescript
274
+ const incidentPropsSchema: z.ZodObject<
275
+ {
276
+ id: z.ZodString
277
+ createdAt: z.ZodString
278
+ updatedAt: z.ZodString
279
+ serviceId: z.ZodString
280
+ title: z.ZodString
281
+ description: z.ZodOptional<z.ZodString>
282
+ severity: z.ZodEnum<{ minor: 'minor'; major: 'major'; critical: 'critical' }>
283
+ status: z.ZodEnum<{
284
+ investigating: 'investigating'
285
+ identified: 'identified'
286
+ monitoring: 'monitoring'
287
+ resolved: 'resolved'
288
+ }>
289
+ autoDetected: z.ZodDefault<z.ZodBoolean>
290
+ startedAt: z.ZodString
291
+ resolvedAt: z.ZodOptional<z.ZodString>
292
+ },
293
+ z.core.$strip
294
+ >
295
+ ```
296
+
297
+ #### `resource`
298
+
299
+ The status resource definition.
300
+
301
+ ```typescript
302
+ const resource: types.Resource<unknown>
303
+ ```
304
+
305
+ #### `routes`
306
+
307
+ Route array for status page endpoints: public read routes and admin-gated mutation routes.
308
+
309
+ ```typescript
310
+ const routes: (
311
+ | { method: 'get'; path: string; middlewares: never[]; handler: string }
312
+ | { method: 'post'; path: string; middlewares: string[]; handler: string }
313
+ | { method: 'patch'; path: string; middlewares: string[]; handler: string }
314
+ | { method: 'delete'; path: string; middlewares: string[]; handler: string }
315
+ )[]
316
+ ```
317
+
318
+ #### `servicePropsSchema`
319
+
320
+ Full schema for a monitored service.
321
+
322
+ ```typescript
323
+ const servicePropsSchema: z.ZodObject<
324
+ {
325
+ id: z.ZodString
326
+ createdAt: z.ZodString
327
+ updatedAt: z.ZodString
328
+ name: z.ZodString
329
+ url: z.ZodString
330
+ method: z.ZodDefault<z.ZodEnum<{ GET: 'GET'; HEAD: 'HEAD'; POST: 'POST' }>>
331
+ expectedStatus: z.ZodDefault<z.ZodNumber>
332
+ timeoutMs: z.ZodDefault<z.ZodNumber>
333
+ intervalMs: z.ZodDefault<z.ZodNumber>
334
+ groupName: z.ZodOptional<z.ZodString>
335
+ enabled: z.ZodDefault<z.ZodBoolean>
336
+ },
337
+ z.core.$strip
338
+ >
339
+ ```
340
+
341
+ #### `STATUS_ADMIN_PERMISSION`
342
+
343
+ Session-claim permission string (`'status:manage'`) that, when present in a
344
+ session's `permissions` array, grants status page administration without a
345
+ bonded permissions provider.
346
+
347
+ ```typescript
348
+ const STATUS_ADMIN_PERMISSION: 'status:manage'
349
+ ```
350
+
351
+ #### `STATUS_PERMISSION_ACTION`
352
+
353
+ Permission action checked against `@molecule/api-permissions` for status page
354
+ administration.
355
+
356
+ ```typescript
357
+ const STATUS_PERMISSION_ACTION: 'manage'
358
+ ```
359
+
360
+ #### `STATUS_PERMISSION_RESOURCE`
361
+
362
+ Permission resource checked against `@molecule/api-permissions` for status page
363
+ administration.
364
+
365
+ ```typescript
366
+ const STATUS_PERMISSION_RESOURCE: 'status'
367
+ ```
368
+
369
+ #### `updateIncidentPropsSchema`
370
+
371
+ Schema for updating an existing incident (all fields optional).
372
+
373
+ ```typescript
374
+ const updateIncidentPropsSchema: z.ZodObject<
375
+ {
376
+ status: z.ZodOptional<
377
+ z.ZodEnum<{
378
+ investigating: 'investigating'
379
+ identified: 'identified'
380
+ monitoring: 'monitoring'
381
+ resolved: 'resolved'
382
+ }>
383
+ >
384
+ title: z.ZodOptional<z.ZodString>
385
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>
386
+ severity: z.ZodOptional<z.ZodEnum<{ minor: 'minor'; major: 'major'; critical: 'critical' }>>
387
+ resolvedAt: z.ZodOptional<z.ZodOptional<z.ZodString>>
388
+ },
389
+ z.core.$strip
390
+ >
391
+ ```
392
+
393
+ #### `updateServicePropsSchema`
394
+
395
+ Schema for updating an existing service (all fields optional).
396
+
397
+ ```typescript
398
+ const updateServicePropsSchema: z.ZodObject<
399
+ {
400
+ name: z.ZodOptional<z.ZodString>
401
+ url: z.ZodOptional<z.ZodString>
402
+ method: z.ZodOptional<z.ZodDefault<z.ZodEnum<{ GET: 'GET'; HEAD: 'HEAD'; POST: 'POST' }>>>
403
+ expectedStatus: z.ZodOptional<z.ZodDefault<z.ZodNumber>>
404
+ timeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>
405
+ intervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>
406
+ groupName: z.ZodOptional<z.ZodOptional<z.ZodString>>
407
+ enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>
408
+ },
409
+ z.core.$strip
410
+ >
411
+ ```
412
+
413
+ #### `uptimeWindowPropsSchema`
414
+
415
+ Schema for a pre-computed uptime statistics window.
416
+
417
+ ```typescript
418
+ const uptimeWindowPropsSchema: z.ZodObject<
419
+ {
420
+ id: z.ZodString
421
+ serviceId: z.ZodString
422
+ window: z.ZodEnum<{ '1h': '1h'; '24h': '24h'; '7d': '7d'; '30d': '30d'; '90d': '90d' }>
423
+ uptimePct: z.ZodNumber
424
+ totalChecks: z.ZodNumber
425
+ upChecks: z.ZodNumber
426
+ avgLatencyMs: z.ZodNumber
427
+ },
428
+ z.core.$strip
429
+ >
430
+ ```
431
+
432
+ ### Namespaces
433
+
434
+ #### `handlers`
435
+
436
+ Members:
437
+
438
+ - `handlers.createIncident` — function: Creates a new incident record. Validates the request body against
439
+ - `handlers.createService` — function: Creates a new monitored service. Validates the request body against
440
+ - `handlers.deleteService` — function: Deletes a monitored service by ID. Returns 404 if the service does not exist.
441
+ - `handlers.getService` — function: Returns a single service by ID along with the last 50 check results.
442
+ - `handlers.getStatus` — function: Returns the aggregated system health status.
443
+ - `handlers.getUptime` — function: Returns uptime window statistics for all services, or filtered by
444
+ - `handlers.listIncidents` — function: Lists incidents with support for `?status=` filtering and pagination
445
+ - `handlers.listServices` — function: Lists all services along with each service's latest check result.
446
+ - `handlers.updateIncident` — function: Updates an existing incident by ID. Validates the request body against
447
+ - `handlers.updateService` — function: Updates an existing monitored service by ID. Validates the request body
448
+
449
+ #### `types`
450
+
451
+ Members:
452
+
453
+ - `types.CheckProps` — type: Health check result properties.
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.
462
+
463
+ #### `z`
464
+
465
+ Members:
466
+
467
+ - `z.core` — namespace
468
+ - `z.infer` — type
469
+ - `z.output` — type
470
+ - `z.input` — type
471
+ - `z.JSONType` — type
472
+ - `z.globalRegistry` — const
473
+ - `z.GlobalMeta` — interface
474
+ - `z.registry` — function
475
+ - `z.config` — function
476
+ - `z.$output` — const
477
+ - `z.$input` — const
478
+ - `z.$brand` — const
479
+ - `z.clone` — function
480
+ - `z.regexes` — namespace
481
+ - `z.treeifyError` — function
482
+ - `z.prettifyError` — function
483
+ - `z.formatError` — function
484
+ - `z.flattenError` — function
485
+ - `z.TimePrecision` — const
486
+ - `z.util` — namespace
487
+ - `z.NEVER` — const: A special constant with type `never`
488
+ - `z.toJSONSchema` — function
489
+ - `z.fromJSONSchema` — function: Converts a JSON Schema to a Zod schema. This function should be considered semi-experimental. It's behavior is liable to change.
490
+ - `z.locales` — namespace
491
+ - `z.ZodISODateTime` — interface
492
+ - `z.ZodISODate` — interface
493
+ - `z.ZodISOTime` — interface
494
+ - `z.ZodISODuration` — interface
495
+ - `z.iso` — namespace
496
+ - `z.ZodCoercedString` — interface
497
+ - `z.ZodCoercedNumber` — interface
498
+ - `z.ZodCoercedBigInt` — interface
499
+ - `z.ZodCoercedBoolean` — interface
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
748
+
749
+ ## Injection Notes
750
+
751
+ ### Requirements
752
+
753
+ Peer dependencies:
754
+
755
+ - `@molecule/api-bond` ^1.0.1
756
+ - `@molecule/api-database` ^1.0.1
757
+ - `@molecule/api-i18n` ^1.0.1
758
+ - `@molecule/api-monitoring` ^1.0.1
759
+ - `@molecule/api-notifications` ^1.0.1
760
+ - `@molecule/api-permissions` ^1.0.1
761
+ - `@molecule/api-resource` ^1.0.1
762
+ - `@molecule/api-scheduler` ^1.0.1
763
+ - `@molecule/api-locales-status-page` ^1.0.1
764
+
765
+ ### Runtime Dependencies
766
+
767
+ - `@molecule/api-bond`
768
+ - `@molecule/api-database`
769
+ - `@molecule/api-i18n`
770
+ - `@molecule/api-locales-status-page`
771
+ - `@molecule/api-monitoring`
772
+ - `@molecule/api-notifications`
773
+ - `@molecule/api-permissions`
774
+ - `@molecule/api-resource`
775
+ - `@molecule/api-scheduler`
776
+ - `zod`
777
+
778
+ The GET routes are PUBLIC by design — a status page is a public surface; do
779
+ not put them behind auth. The mutating routes are ADMIN-ONLY and DENY by
780
+ default: they are gated by the `requireAdmin` middleware AND re-checked
781
+ inside every mutation handler via `isStatusAdmin` — fail-closed
782
+ defense-in-depth that holds even if a route scanner drops the middleware.
783
+ "Admin" resolves as: an admin session claim (`isAdmin: true`,
784
+ `role: 'admin'`, `roles` containing `'admin'`, or a `'status:manage'` /
785
+ `'admin'` entry in `session.permissions`) OR a bonded
786
+ `@molecule/api-permissions` grant of `manage` on `status`. Until the app
787
+ grants one of those, every mutation is denied — grant the claim/permission
788
+ at startup, do NOT strip the gate: an open mutation surface lets any caller
789
+ deface the public status page (fabricate outages, delete services).
790
+
791
+ Handler text flows through `t()` with English defaults; the companion
792
+ locale bond `@molecule/api-locales-status-page` provides translations.
793
+
794
+ Tables: `setup/*.sql` creates `services`, `incidents`, `checks`, and
795
+ `uptimeWindows`. An mlcl-scaffolded API replays these setup files
796
+ automatically on migrate; anywhere else run them once — nothing at runtime
797
+ creates them.
798
+
799
+ ## E2E Tests
800
+
801
+ Integration checklist — drive the real UI (live preview, no mocks), adapt
802
+ each item to this app's actual status-page screens/flows, and check every
803
+ box off one by one. A box you can't check is an integration bug to fix — not
804
+ a skip. Verify BEHAVIOR and the public/admin split, not just that CRUD
805
+ compiles:
806
+
807
+ - [ ] The PUBLIC status page renders every monitored service (component)
808
+ with its current status and an OVERALL banner that is DERIVED, never
809
+ hardcoded: GET /status returns `operational` when no enabled service's
810
+ latest `check` is `down` or `degraded` ("All systems operational"), `down`
811
+ if ANY latest check is `down`, else `degraded` if any is `degraded` — the
812
+ banner reflects the WORST service, and a service with no check reads
813
+ `unknown` (which never turns the banner red). GET /status/services lists
814
+ each service with its latest check.
815
+ - [ ] An admin creating an INCIDENT (POST /status/incidents with serviceId,
816
+ title, severity minor|major|critical, status `investigating`, startedAt)
817
+ persists it and it shows on the public GET /status/incidents. The affected
818
+ service reads down/degraded on the page because its latest `check` says so
819
+ (checks are monitor-written, never typed in), so the overall banner goes
820
+ non-green while the incident is open.
821
+ - [ ] Updating the incident (PATCH /status/incidents/:id) advances its
822
+ timeline through the real lifecycle investigating -> identified ->
823
+ monitoring -> resolved (bumping updatedAt), and each stage shows on the
824
+ public page. Marking it `resolved` (with resolvedAt) moves it to history —
825
+ the public list filtered `?status=resolved` includes it while the active
826
+ incidents drop it — and once the affected service's latest check returns
827
+ to `up`, GET /status recovers to "All systems operational" (the banner
828
+ tracks live check state, so a still-down check keeps it red).
829
+ - [ ] AUTHORIZATION — reads are PUBLIC: with NO session, every GET (/status,
830
+ /status/services, /status/services/:id, /status/incidents, /status/uptime)
831
+ returns 200 — the status page is meant to be seen without signing in.
832
+ - [ ] AUTHORIZATION — writes are ADMIN-ONLY, deny by default: every mutation
833
+ (POST/PATCH/DELETE /status/services(/:id), POST/PATCH
834
+ /status/incidents(/:id)) is refused for an anonymous caller (401) and for
835
+ a normal signed-in user with no admin claim / `manage status` grant (403),
836
+ and nothing changes — enforced twice (the `requireAdmin` route middleware
837
+ AND the in-handler `isStatusAdmin` re-check). A non-admin has NO path to
838
+ fabricate an outage, delete a service, or post a fake incident, and no
839
+ endpoint sets a service up/down at all (that is monitor-written).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-status-page",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "System status page resource for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,7 +18,8 @@
18
18
  },
19
19
  "files": [
20
20
  "dist",
21
- "setup"
21
+ "setup",
22
+ "README.md"
22
23
  ],
23
24
  "keywords": [
24
25
  "molecule",
@@ -31,23 +32,23 @@
31
32
  "zod": "4.4.3"
32
33
  },
33
34
  "devDependencies": {
34
- "@molecule/api-bond": "1.0.0",
35
- "@molecule/api-permissions": "1.0.0",
35
+ "@molecule/api-bond": "1.0.1",
36
+ "@molecule/api-permissions": "1.0.1",
36
37
  "@types/node": "26.1.2",
37
38
  "typescript": "6.0.3",
38
39
  "vitest": "4.1.10",
39
- "@molecule/api-locales-status-page": "1.0.0"
40
+ "@molecule/api-locales-status-page": "1.0.1"
40
41
  },
41
42
  "peerDependencies": {
42
- "@molecule/api-bond": "^1.0.0",
43
- "@molecule/api-database": "^1.0.0",
44
- "@molecule/api-i18n": "^1.0.0",
45
- "@molecule/api-monitoring": "^1.0.0",
46
- "@molecule/api-notifications": "^1.0.0",
47
- "@molecule/api-permissions": "^1.0.0",
48
- "@molecule/api-resource": "^1.0.0",
49
- "@molecule/api-scheduler": "^1.0.0",
50
- "@molecule/api-locales-status-page": "^1.0.0"
43
+ "@molecule/api-bond": "^1.0.1",
44
+ "@molecule/api-database": "^1.0.1",
45
+ "@molecule/api-i18n": "^1.0.1",
46
+ "@molecule/api-monitoring": "^1.0.1",
47
+ "@molecule/api-notifications": "^1.0.1",
48
+ "@molecule/api-permissions": "^1.0.1",
49
+ "@molecule/api-resource": "^1.0.1",
50
+ "@molecule/api-scheduler": "^1.0.1",
51
+ "@molecule/api-locales-status-page": "^1.0.1"
51
52
  },
52
53
  "peerDependenciesMeta": {
53
54
  "@molecule/api-monitoring": {