@molecule/api-resource-status-page 1.0.0
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 +115 -0
- package/dist/authorizers/index.d.ts +79 -0
- package/dist/authorizers/index.d.ts.map +1 -0
- package/dist/authorizers/index.js +158 -0
- package/dist/authorizers/index.js.map +1 -0
- package/dist/browser-guard.d.ts +2 -0
- package/dist/browser-guard.d.ts.map +1 -0
- package/dist/browser-guard.js +19 -0
- package/dist/browser-guard.js.map +1 -0
- package/dist/handlers/createIncident.d.ts +44 -0
- package/dist/handlers/createIncident.d.ts.map +1 -0
- package/dist/handlers/createIncident.js +73 -0
- package/dist/handlers/createIncident.js.map +1 -0
- package/dist/handlers/createService.d.ts +44 -0
- package/dist/handlers/createService.d.ts.map +1 -0
- package/dist/handlers/createService.js +70 -0
- package/dist/handlers/createService.js.map +1 -0
- package/dist/handlers/deleteService.d.ts +34 -0
- package/dist/handlers/deleteService.d.ts.map +1 -0
- package/dist/handlers/deleteService.js +64 -0
- package/dist/handlers/deleteService.js.map +1 -0
- package/dist/handlers/getService.d.ts +52 -0
- package/dist/handlers/getService.d.ts.map +1 -0
- package/dist/handlers/getService.js +58 -0
- package/dist/handlers/getService.js.map +1 -0
- package/dist/handlers/getStatus.d.ts +48 -0
- package/dist/handlers/getStatus.d.ts.map +1 -0
- package/dist/handlers/getStatus.js +76 -0
- package/dist/handlers/getStatus.js.map +1 -0
- package/dist/handlers/getUptime.d.ts +35 -0
- package/dist/handlers/getUptime.d.ts.map +1 -0
- package/dist/handlers/getUptime.js +47 -0
- package/dist/handlers/getUptime.js.map +1 -0
- package/dist/handlers/index.d.ts +11 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +11 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/listIncidents.d.ts +39 -0
- package/dist/handlers/listIncidents.d.ts.map +1 -0
- package/dist/handlers/listIncidents.js +51 -0
- package/dist/handlers/listIncidents.js.map +1 -0
- package/dist/handlers/listServices.d.ts +47 -0
- package/dist/handlers/listServices.d.ts.map +1 -0
- package/dist/handlers/listServices.js +51 -0
- package/dist/handlers/listServices.js.map +1 -0
- package/dist/handlers/updateIncident.d.ts +44 -0
- package/dist/handlers/updateIncident.d.ts.map +1 -0
- package/dist/handlers/updateIncident.js +87 -0
- package/dist/handlers/updateIncident.js.map +1 -0
- package/dist/handlers/updateService.d.ts +44 -0
- package/dist/handlers/updateService.d.ts.map +1 -0
- package/dist/handlers/updateService.js +82 -0
- package/dist/handlers/updateService.js.map +1 -0
- package/dist/i18n.d.ts +14 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +22 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/requestHandlerMap.d.ts +25 -0
- package/dist/requestHandlerMap.d.ts.map +1 -0
- package/dist/requestHandlerMap.js +37 -0
- package/dist/requestHandlerMap.js.map +1 -0
- package/dist/resource.d.ts +17 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +21 -0
- package/dist/resource.js.map +1 -0
- package/dist/routes.d.ts +39 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +67 -0
- package/dist/routes.js.map +1 -0
- package/dist/schema.d.ts +199 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +140 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +76 -0
- package/setup/checks.sql +12 -0
- package/setup/incidents.sql +16 -0
- package/setup/services.sql +15 -0
- package/setup/uptimeWindows.sql +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestHandlerMap.js","sourceRoot":"","sources":["../src/requestHandlerMap.ts"],"names":[],"mappings":"AAAA;;;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+
/**
|
|
8
|
+
* Creates a new status resource definition.
|
|
9
|
+
*
|
|
10
|
+
* @returns The status resource descriptor with name, tableName, and schema.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createResource: () => types.Resource;
|
|
13
|
+
/**
|
|
14
|
+
* The status resource definition.
|
|
15
|
+
*/
|
|
16
|
+
export declare const resource: types.Resource;
|
|
17
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AAExC;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,KAAK,CAAC,QAItC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,QAA2B,CAAA"}
|
package/dist/resource.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status resource definition.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { servicePropsSchema } from './schema.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new status resource definition.
|
|
9
|
+
*
|
|
10
|
+
* @returns The status resource descriptor with name, tableName, and schema.
|
|
11
|
+
*/
|
|
12
|
+
export const createResource = () => ({
|
|
13
|
+
name: 'Service',
|
|
14
|
+
tableName: 'services',
|
|
15
|
+
schema: servicePropsSchema,
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* The status resource definition.
|
|
19
|
+
*/
|
|
20
|
+
export const resource = createResource();
|
|
21
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAmB,EAAE,CAAC,CAAC;IACnD,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAmB,cAAc,EAAE,CAAA"}
|
package/dist/routes.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status resource route definitions.
|
|
3
|
+
*
|
|
4
|
+
* Declarative route definitions used to generate the Express router.
|
|
5
|
+
*
|
|
6
|
+
* The GET routes are intentionally **public** (the status page is a public
|
|
7
|
+
* surface). The mutating routes are gated by the `requireAdmin` status-management
|
|
8
|
+
* authorizer (a real `requestHandlerMap` key — see `authorizers/index.ts` — so the
|
|
9
|
+
* injector preserves it; the previously declared `'auth'` string was silently
|
|
10
|
+
* dropped by the route scanner because it isn't a handler-map key, leaving the
|
|
11
|
+
* mutating routes open to any caller). Each mutation handler additionally
|
|
12
|
+
* re-checks authorization internally, so the gate holds even if a consumer wires
|
|
13
|
+
* the routes without applying these middlewares.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
/** Route array for status page endpoints: public read routes and admin-gated mutation routes. */
|
|
18
|
+
export declare const routes: ({
|
|
19
|
+
method: "get";
|
|
20
|
+
path: string;
|
|
21
|
+
middlewares: never[];
|
|
22
|
+
handler: string;
|
|
23
|
+
} | {
|
|
24
|
+
method: "post";
|
|
25
|
+
path: string;
|
|
26
|
+
middlewares: string[];
|
|
27
|
+
handler: string;
|
|
28
|
+
} | {
|
|
29
|
+
method: "patch";
|
|
30
|
+
path: string;
|
|
31
|
+
middlewares: string[];
|
|
32
|
+
handler: string;
|
|
33
|
+
} | {
|
|
34
|
+
method: "delete";
|
|
35
|
+
path: string;
|
|
36
|
+
middlewares: string[];
|
|
37
|
+
handler: string;
|
|
38
|
+
})[];
|
|
39
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iGAAiG;AACjG,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;IAiDlB,CAAA"}
|
package/dist/routes.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status resource route definitions.
|
|
3
|
+
*
|
|
4
|
+
* Declarative route definitions used to generate the Express router.
|
|
5
|
+
*
|
|
6
|
+
* The GET routes are intentionally **public** (the status page is a public
|
|
7
|
+
* surface). The mutating routes are gated by the `requireAdmin` status-management
|
|
8
|
+
* authorizer (a real `requestHandlerMap` key — see `authorizers/index.ts` — so the
|
|
9
|
+
* injector preserves it; the previously declared `'auth'` string was silently
|
|
10
|
+
* dropped by the route scanner because it isn't a handler-map key, leaving the
|
|
11
|
+
* mutating routes open to any caller). Each mutation handler additionally
|
|
12
|
+
* re-checks authorization internally, so the gate holds even if a consumer wires
|
|
13
|
+
* the routes without applying these middlewares.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
/** Route array for status page endpoints: public read routes and admin-gated mutation routes. */
|
|
18
|
+
export const routes = [
|
|
19
|
+
// Public endpoints
|
|
20
|
+
{ method: 'get', path: '/status', middlewares: [], handler: 'getStatus' },
|
|
21
|
+
{ method: 'get', path: '/status/services', middlewares: [], handler: 'listServices' },
|
|
22
|
+
{
|
|
23
|
+
method: 'get',
|
|
24
|
+
path: '/status/services/:id',
|
|
25
|
+
middlewares: [],
|
|
26
|
+
handler: 'getService',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
method: 'get',
|
|
30
|
+
path: '/status/incidents',
|
|
31
|
+
middlewares: [],
|
|
32
|
+
handler: 'listIncidents',
|
|
33
|
+
},
|
|
34
|
+
{ method: 'get', path: '/status/uptime', middlewares: [], handler: 'getUptime' },
|
|
35
|
+
// Admin endpoints
|
|
36
|
+
{
|
|
37
|
+
method: 'post',
|
|
38
|
+
path: '/status/services',
|
|
39
|
+
middlewares: ['requireAdmin'],
|
|
40
|
+
handler: 'createService',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
method: 'patch',
|
|
44
|
+
path: '/status/services/:id',
|
|
45
|
+
middlewares: ['requireAdmin'],
|
|
46
|
+
handler: 'updateService',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
method: 'delete',
|
|
50
|
+
path: '/status/services/:id',
|
|
51
|
+
middlewares: ['requireAdmin'],
|
|
52
|
+
handler: 'deleteService',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
method: 'post',
|
|
56
|
+
path: '/status/incidents',
|
|
57
|
+
middlewares: ['requireAdmin'],
|
|
58
|
+
handler: 'createIncident',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
method: 'patch',
|
|
62
|
+
path: '/status/incidents/:id',
|
|
63
|
+
middlewares: ['requireAdmin'],
|
|
64
|
+
handler: 'updateIncident',
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iGAAiG;AACjG,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,mBAAmB;IACnB,EAAE,MAAM,EAAE,KAAc,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;IAClF,EAAE,MAAM,EAAE,KAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;IAC9F;QACE,MAAM,EAAE,KAAc;QACtB,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,YAAY;KACtB;IACD;QACE,MAAM,EAAE,KAAc;QACtB,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,eAAe;KACzB;IACD,EAAE,MAAM,EAAE,KAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;IAEzF,kBAAkB;IAClB;QACE,MAAM,EAAE,MAAe;QACvB,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,CAAC,cAAc,CAAC;QAC7B,OAAO,EAAE,eAAe;KACzB;IACD;QACE,MAAM,EAAE,OAAgB;QACxB,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,CAAC,cAAc,CAAC;QAC7B,OAAO,EAAE,eAAe;KACzB;IACD;QACE,MAAM,EAAE,QAAiB;QACzB,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,CAAC,cAAc,CAAC;QAC7B,OAAO,EAAE,eAAe;KACzB;IACD;QACE,MAAM,EAAE,MAAe;QACvB,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,CAAC,cAAc,CAAC;QAC7B,OAAO,EAAE,gBAAgB;KAC1B;IACD;QACE,MAAM,EAAE,OAAgB;QACxB,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,CAAC,cAAc,CAAC;QAC7B,OAAO,EAAE,gBAAgB;KAC1B;CACF,CAAA"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status resource schema definitions using Zod.
|
|
3
|
+
*
|
|
4
|
+
* Defines schemas for services, checks, incidents, and uptime windows.
|
|
5
|
+
* Types are automatically inferred from schemas using z.infer<>.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
/**
|
|
11
|
+
* Full schema for a monitored service.
|
|
12
|
+
*/
|
|
13
|
+
export declare const servicePropsSchema: z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
createdAt: z.ZodString;
|
|
16
|
+
updatedAt: z.ZodString;
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
url: z.ZodString;
|
|
19
|
+
method: z.ZodDefault<z.ZodEnum<{
|
|
20
|
+
GET: "GET";
|
|
21
|
+
HEAD: "HEAD";
|
|
22
|
+
POST: "POST";
|
|
23
|
+
}>>;
|
|
24
|
+
expectedStatus: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
26
|
+
intervalMs: z.ZodDefault<z.ZodNumber>;
|
|
27
|
+
groupName: z.ZodOptional<z.ZodString>;
|
|
28
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
/**
|
|
31
|
+
* Full service record properties.
|
|
32
|
+
*/
|
|
33
|
+
export type ServiceProps = z.infer<typeof servicePropsSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* Schema for creating a new service.
|
|
36
|
+
*/
|
|
37
|
+
export declare const createServicePropsSchema: z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
url: z.ZodString;
|
|
40
|
+
method: z.ZodDefault<z.ZodEnum<{
|
|
41
|
+
GET: "GET";
|
|
42
|
+
HEAD: "HEAD";
|
|
43
|
+
POST: "POST";
|
|
44
|
+
}>>;
|
|
45
|
+
expectedStatus: z.ZodDefault<z.ZodNumber>;
|
|
46
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
47
|
+
intervalMs: z.ZodDefault<z.ZodNumber>;
|
|
48
|
+
groupName: z.ZodOptional<z.ZodString>;
|
|
49
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/**
|
|
52
|
+
* Fields accepted when creating a new service.
|
|
53
|
+
*/
|
|
54
|
+
export type CreateServiceProps = z.infer<typeof createServicePropsSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* Schema for updating an existing service (all fields optional).
|
|
57
|
+
*/
|
|
58
|
+
export declare const updateServicePropsSchema: z.ZodObject<{
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
url: z.ZodOptional<z.ZodString>;
|
|
61
|
+
method: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
62
|
+
GET: "GET";
|
|
63
|
+
HEAD: "HEAD";
|
|
64
|
+
POST: "POST";
|
|
65
|
+
}>>>;
|
|
66
|
+
expectedStatus: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
67
|
+
timeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
68
|
+
intervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
69
|
+
groupName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
70
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
/**
|
|
73
|
+
* Updatable service fields.
|
|
74
|
+
*/
|
|
75
|
+
export type UpdateServiceProps = z.infer<typeof updateServicePropsSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* Schema for a single health check result.
|
|
78
|
+
*/
|
|
79
|
+
export declare const checkPropsSchema: z.ZodObject<{
|
|
80
|
+
id: z.ZodString;
|
|
81
|
+
serviceId: z.ZodString;
|
|
82
|
+
status: z.ZodEnum<{
|
|
83
|
+
up: "up";
|
|
84
|
+
down: "down";
|
|
85
|
+
degraded: "degraded";
|
|
86
|
+
}>;
|
|
87
|
+
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
latencyMs: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
error: z.ZodOptional<z.ZodString>;
|
|
90
|
+
checkedAt: z.ZodString;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
/**
|
|
93
|
+
* Health check result properties.
|
|
94
|
+
*/
|
|
95
|
+
export type CheckProps = z.infer<typeof checkPropsSchema>;
|
|
96
|
+
/**
|
|
97
|
+
* Full schema for a service incident.
|
|
98
|
+
*/
|
|
99
|
+
export declare const incidentPropsSchema: z.ZodObject<{
|
|
100
|
+
id: z.ZodString;
|
|
101
|
+
createdAt: z.ZodString;
|
|
102
|
+
updatedAt: z.ZodString;
|
|
103
|
+
serviceId: z.ZodString;
|
|
104
|
+
title: z.ZodString;
|
|
105
|
+
description: z.ZodOptional<z.ZodString>;
|
|
106
|
+
severity: z.ZodEnum<{
|
|
107
|
+
minor: "minor";
|
|
108
|
+
major: "major";
|
|
109
|
+
critical: "critical";
|
|
110
|
+
}>;
|
|
111
|
+
status: z.ZodEnum<{
|
|
112
|
+
investigating: "investigating";
|
|
113
|
+
identified: "identified";
|
|
114
|
+
monitoring: "monitoring";
|
|
115
|
+
resolved: "resolved";
|
|
116
|
+
}>;
|
|
117
|
+
autoDetected: z.ZodDefault<z.ZodBoolean>;
|
|
118
|
+
startedAt: z.ZodString;
|
|
119
|
+
resolvedAt: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
/**
|
|
122
|
+
* Full incident record properties.
|
|
123
|
+
*/
|
|
124
|
+
export type IncidentProps = z.infer<typeof incidentPropsSchema>;
|
|
125
|
+
/**
|
|
126
|
+
* Schema for creating a new incident.
|
|
127
|
+
*/
|
|
128
|
+
export declare const createIncidentPropsSchema: z.ZodObject<{
|
|
129
|
+
status: z.ZodEnum<{
|
|
130
|
+
investigating: "investigating";
|
|
131
|
+
identified: "identified";
|
|
132
|
+
monitoring: "monitoring";
|
|
133
|
+
resolved: "resolved";
|
|
134
|
+
}>;
|
|
135
|
+
serviceId: z.ZodString;
|
|
136
|
+
title: z.ZodString;
|
|
137
|
+
description: z.ZodOptional<z.ZodString>;
|
|
138
|
+
severity: z.ZodEnum<{
|
|
139
|
+
minor: "minor";
|
|
140
|
+
major: "major";
|
|
141
|
+
critical: "critical";
|
|
142
|
+
}>;
|
|
143
|
+
autoDetected: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
+
startedAt: z.ZodString;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
/**
|
|
147
|
+
* Fields accepted when creating a new incident.
|
|
148
|
+
*/
|
|
149
|
+
export type CreateIncidentProps = z.infer<typeof createIncidentPropsSchema>;
|
|
150
|
+
/**
|
|
151
|
+
* Schema for updating an existing incident (all fields optional).
|
|
152
|
+
*/
|
|
153
|
+
export declare const updateIncidentPropsSchema: z.ZodObject<{
|
|
154
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
155
|
+
investigating: "investigating";
|
|
156
|
+
identified: "identified";
|
|
157
|
+
monitoring: "monitoring";
|
|
158
|
+
resolved: "resolved";
|
|
159
|
+
}>>;
|
|
160
|
+
title: z.ZodOptional<z.ZodString>;
|
|
161
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
162
|
+
severity: z.ZodOptional<z.ZodEnum<{
|
|
163
|
+
minor: "minor";
|
|
164
|
+
major: "major";
|
|
165
|
+
critical: "critical";
|
|
166
|
+
}>>;
|
|
167
|
+
resolvedAt: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
/**
|
|
170
|
+
* Updatable incident fields.
|
|
171
|
+
*/
|
|
172
|
+
export type UpdateIncidentProps = z.infer<typeof updateIncidentPropsSchema>;
|
|
173
|
+
/**
|
|
174
|
+
* Schema for a pre-computed uptime statistics window.
|
|
175
|
+
*/
|
|
176
|
+
export declare const uptimeWindowPropsSchema: z.ZodObject<{
|
|
177
|
+
id: z.ZodString;
|
|
178
|
+
serviceId: z.ZodString;
|
|
179
|
+
window: z.ZodEnum<{
|
|
180
|
+
"1h": "1h";
|
|
181
|
+
"24h": "24h";
|
|
182
|
+
"7d": "7d";
|
|
183
|
+
"30d": "30d";
|
|
184
|
+
"90d": "90d";
|
|
185
|
+
}>;
|
|
186
|
+
uptimePct: z.ZodNumber;
|
|
187
|
+
totalChecks: z.ZodNumber;
|
|
188
|
+
upChecks: z.ZodNumber;
|
|
189
|
+
avgLatencyMs: z.ZodNumber;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
/**
|
|
192
|
+
* Uptime window statistics properties.
|
|
193
|
+
*/
|
|
194
|
+
export type UptimeWindowProps = z.infer<typeof uptimeWindowPropsSchema>;
|
|
195
|
+
/**
|
|
196
|
+
* Re-export zod for convenience.
|
|
197
|
+
*/
|
|
198
|
+
export { z };
|
|
199
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;iBAiB7B,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;iBASnC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;iBAAqC,CAAA;AAE1E;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAIzE;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;iBAe3B,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAIzD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;iBAiB9B,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;iBAQpC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAE3E;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;iBAQ1B,CAAA;AAEZ;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAI3E;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;iBAelC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,CAAA"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status resource schema definitions using Zod.
|
|
3
|
+
*
|
|
4
|
+
* Defines schemas for services, checks, incidents, and uptime windows.
|
|
5
|
+
* Types are automatically inferred from schemas using z.infer<>.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { basePropsSchema } from '@molecule/api-resource/schema';
|
|
11
|
+
// --- Services ---
|
|
12
|
+
/**
|
|
13
|
+
* Full schema for a monitored service.
|
|
14
|
+
*/
|
|
15
|
+
export const servicePropsSchema = basePropsSchema.extend({
|
|
16
|
+
/** Display name of the service. */
|
|
17
|
+
name: z.string(),
|
|
18
|
+
/** URL to check for uptime. */
|
|
19
|
+
url: z.string().url(),
|
|
20
|
+
/** HTTP method to use for the health check. */
|
|
21
|
+
method: z.enum(['GET', 'HEAD', 'POST']).default('GET'),
|
|
22
|
+
/** Expected HTTP status code from the health check. */
|
|
23
|
+
expectedStatus: z.number().int().default(200),
|
|
24
|
+
/** Request timeout in milliseconds. */
|
|
25
|
+
timeoutMs: z.number().int().default(10000),
|
|
26
|
+
/** Interval between checks in milliseconds. */
|
|
27
|
+
intervalMs: z.number().int().default(60000),
|
|
28
|
+
/** Optional group name for organizing services. */
|
|
29
|
+
groupName: z.string().optional(),
|
|
30
|
+
/** Whether the service is actively monitored. */
|
|
31
|
+
enabled: z.boolean().default(true),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Schema for creating a new service.
|
|
35
|
+
*/
|
|
36
|
+
export const createServicePropsSchema = servicePropsSchema.pick({
|
|
37
|
+
name: true,
|
|
38
|
+
url: true,
|
|
39
|
+
method: true,
|
|
40
|
+
expectedStatus: true,
|
|
41
|
+
timeoutMs: true,
|
|
42
|
+
intervalMs: true,
|
|
43
|
+
groupName: true,
|
|
44
|
+
enabled: true,
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Schema for updating an existing service (all fields optional).
|
|
48
|
+
*/
|
|
49
|
+
export const updateServicePropsSchema = createServicePropsSchema.partial();
|
|
50
|
+
// --- Checks ---
|
|
51
|
+
/**
|
|
52
|
+
* Schema for a single health check result.
|
|
53
|
+
*/
|
|
54
|
+
export const checkPropsSchema = z.object({
|
|
55
|
+
/** Unique identifier for the check. */
|
|
56
|
+
id: z.string().uuid(),
|
|
57
|
+
/** The service this check belongs to. */
|
|
58
|
+
serviceId: z.string().uuid(),
|
|
59
|
+
/** The result status of the check. */
|
|
60
|
+
status: z.enum(['up', 'down', 'degraded']),
|
|
61
|
+
/** HTTP status code returned by the service. */
|
|
62
|
+
httpStatus: z.number().int().optional(),
|
|
63
|
+
/** Response latency in milliseconds. */
|
|
64
|
+
latencyMs: z.number().int().optional(),
|
|
65
|
+
/** Error message if the check failed. */
|
|
66
|
+
error: z.string().optional(),
|
|
67
|
+
/** When the check was performed. */
|
|
68
|
+
checkedAt: z.string().datetime(),
|
|
69
|
+
});
|
|
70
|
+
// --- Incidents ---
|
|
71
|
+
/**
|
|
72
|
+
* Full schema for a service incident.
|
|
73
|
+
*/
|
|
74
|
+
export const incidentPropsSchema = basePropsSchema.extend({
|
|
75
|
+
/** The service affected by this incident. */
|
|
76
|
+
serviceId: z.string().uuid(),
|
|
77
|
+
/** Short title describing the incident. */
|
|
78
|
+
title: z.string(),
|
|
79
|
+
/** Detailed description of the incident. */
|
|
80
|
+
description: z.string().optional(),
|
|
81
|
+
/** Severity level of the incident. */
|
|
82
|
+
severity: z.enum(['minor', 'major', 'critical']),
|
|
83
|
+
/** Current investigation/resolution status. */
|
|
84
|
+
status: z.enum(['investigating', 'identified', 'monitoring', 'resolved']),
|
|
85
|
+
/** Whether this incident was auto-detected from failed checks. */
|
|
86
|
+
autoDetected: z.boolean().default(false),
|
|
87
|
+
/** When the incident started. */
|
|
88
|
+
startedAt: z.string().datetime(),
|
|
89
|
+
/** When the incident was resolved (if applicable). */
|
|
90
|
+
resolvedAt: z.string().datetime().optional(),
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Schema for creating a new incident.
|
|
94
|
+
*/
|
|
95
|
+
export const createIncidentPropsSchema = incidentPropsSchema.pick({
|
|
96
|
+
serviceId: true,
|
|
97
|
+
title: true,
|
|
98
|
+
description: true,
|
|
99
|
+
severity: true,
|
|
100
|
+
status: true,
|
|
101
|
+
autoDetected: true,
|
|
102
|
+
startedAt: true,
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Schema for updating an existing incident (all fields optional).
|
|
106
|
+
*/
|
|
107
|
+
export const updateIncidentPropsSchema = incidentPropsSchema
|
|
108
|
+
.pick({
|
|
109
|
+
title: true,
|
|
110
|
+
description: true,
|
|
111
|
+
severity: true,
|
|
112
|
+
status: true,
|
|
113
|
+
resolvedAt: true,
|
|
114
|
+
})
|
|
115
|
+
.partial();
|
|
116
|
+
// --- Uptime Windows ---
|
|
117
|
+
/**
|
|
118
|
+
* Schema for a pre-computed uptime statistics window.
|
|
119
|
+
*/
|
|
120
|
+
export const uptimeWindowPropsSchema = z.object({
|
|
121
|
+
/** Unique identifier for the uptime window record. */
|
|
122
|
+
id: z.string().uuid(),
|
|
123
|
+
/** The service this uptime window belongs to. */
|
|
124
|
+
serviceId: z.string().uuid(),
|
|
125
|
+
/** The time window this record covers. */
|
|
126
|
+
window: z.enum(['1h', '24h', '7d', '30d', '90d']),
|
|
127
|
+
/** Uptime percentage for this window. */
|
|
128
|
+
uptimePct: z.number(),
|
|
129
|
+
/** Total number of checks in this window. */
|
|
130
|
+
totalChecks: z.number().int(),
|
|
131
|
+
/** Number of successful checks in this window. */
|
|
132
|
+
upChecks: z.number().int(),
|
|
133
|
+
/** Average response latency in milliseconds. */
|
|
134
|
+
avgLatencyMs: z.number(),
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* Re-export zod for convenience.
|
|
138
|
+
*/
|
|
139
|
+
export { z };
|
|
140
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,mBAAmB;AAEnB;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC,MAAM,CAAC;IACvD,mCAAmC;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,+BAA+B;IAC/B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACrB,+CAA+C;IAC/C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,M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* Status resource type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Types are inferred from Zod schemas in schema.ts.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type * as resourceTypes from '@molecule/api-resource/types';
|
|
9
|
+
export type { CheckProps, CreateIncidentProps, CreateServiceProps, IncidentProps, ServiceProps, UpdateIncidentProps, UpdateServiceProps, UptimeWindowProps, } from './schema.js';
|
|
10
|
+
/**
|
|
11
|
+
* An object describing the `status` resource.
|
|
12
|
+
*/
|
|
13
|
+
export type Resource<T = unknown> = resourceTypes.Resource<T>;
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,aAAa,MAAM,8BAA8B,CAAA;AAElE,YAAY,EACV,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,aAAa,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/api-resource-status-page",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "System status page resource for molecule.dev.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"setup"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"molecule",
|
|
25
|
+
"resource",
|
|
26
|
+
"status",
|
|
27
|
+
"monitoring"
|
|
28
|
+
],
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"zod": "4.4.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@molecule/api-bond": "1.0.0",
|
|
35
|
+
"@molecule/api-permissions": "1.0.0",
|
|
36
|
+
"@types/node": "26.1.2",
|
|
37
|
+
"typescript": "6.0.3",
|
|
38
|
+
"vitest": "4.1.10",
|
|
39
|
+
"@molecule/api-locales-status-page": "1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"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"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"@molecule/api-monitoring": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@molecule/api-notifications": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"@molecule/api-permissions": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"@molecule/api-scheduler": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
69
|
+
"directory": "packages/api/resources/status-page"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/resources/status-page",
|
|
72
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
75
|
+
}
|
|
76
|
+
}
|
package/setup/checks.sql
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "checks" (
|
|
2
|
+
"id" uuid UNIQUE PRIMARY KEY NOT NULL,
|
|
3
|
+
"serviceId" uuid NOT NULL REFERENCES "services"("id") ON DELETE CASCADE,
|
|
4
|
+
"status" varchar(20) NOT NULL,
|
|
5
|
+
"httpStatus" integer,
|
|
6
|
+
"latencyMs" integer,
|
|
7
|
+
"error" text,
|
|
8
|
+
"checkedAt" timestamptz DEFAULT current_timestamp NOT NULL
|
|
9
|
+
);
|
|
10
|
+
CREATE INDEX IF NOT EXISTS "checks_serviceId_index" ON "checks" ("serviceId");
|
|
11
|
+
CREATE INDEX IF NOT EXISTS "checks_checkedAt_index" ON "checks" ("checkedAt");
|
|
12
|
+
CREATE INDEX IF NOT EXISTS "checks_serviceId_checkedAt_index" ON "checks" ("serviceId", "checkedAt" DESC);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "incidents" (
|
|
2
|
+
"id" uuid UNIQUE PRIMARY KEY NOT NULL,
|
|
3
|
+
"createdAt" timestamptz DEFAULT current_timestamp NOT NULL,
|
|
4
|
+
"updatedAt" timestamptz DEFAULT current_timestamp NOT NULL,
|
|
5
|
+
"serviceId" uuid NOT NULL REFERENCES "services"("id") ON DELETE CASCADE,
|
|
6
|
+
"title" varchar(500) NOT NULL,
|
|
7
|
+
"description" text,
|
|
8
|
+
"severity" varchar(20) NOT NULL,
|
|
9
|
+
"status" varchar(20) NOT NULL,
|
|
10
|
+
"autoDetected" boolean DEFAULT false NOT NULL,
|
|
11
|
+
"startedAt" timestamptz NOT NULL,
|
|
12
|
+
"resolvedAt" timestamptz
|
|
13
|
+
);
|
|
14
|
+
CREATE INDEX IF NOT EXISTS "incidents_serviceId_index" ON "incidents" ("serviceId");
|
|
15
|
+
CREATE INDEX IF NOT EXISTS "incidents_status_index" ON "incidents" ("status");
|
|
16
|
+
CREATE INDEX IF NOT EXISTS "incidents_startedAt_index" ON "incidents" ("startedAt" DESC);
|