@theholocron/holocron-plugin-checkly 5.0.0-alpha.463 → 5.0.0-alpha.464
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/README.md +1 -0
- package/dist/index.d.mts +35 -3
- package/dist/index.mjs +512 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -61,6 +61,7 @@ monitoring: [
|
|
|
61
61
|
url: "https://sentinel.theholocron.dev/api/webhook",
|
|
62
62
|
method: "GET",
|
|
63
63
|
locations: ["us-east-1"],
|
|
64
|
+
tags: ["sentinel"], // groups checks for a dashboard or status page; `ensureCheck` sets them exactly
|
|
64
65
|
shouldFail: true, // 405 is the EXPECTED healthy response here
|
|
65
66
|
assertions: [
|
|
66
67
|
{ source: "status_code", comparison: "equals", target: "405" },
|
package/dist/index.d.mts
CHANGED
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
* Also exports `verifyToken` + `AUTH_HINT` for `holocron check token`. See
|
|
6
6
|
* README for auth + config docs.
|
|
7
7
|
*/
|
|
8
|
-
import { AuthError, Monitoring, MonitoringAlertChannelInput, MonitoringAlertChannelResult, MonitoringAlertChannelState, MonitoringCheck, MonitoringCheckInput, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
9
|
-
import { ApiCheck, ApiCheckInput, ApiCheckRequest, Assertion, AssertionComparison, AssertionSource, ChecklyClient, ChecklyClientOptions, HttpMethod, ListChecksParams, createChecklyClient } from "@theholocron/checkly-client";
|
|
8
|
+
import { AuthError, Monitoring, MonitoringAlertChannelInput, MonitoringAlertChannelResult, MonitoringAlertChannelState, MonitoringCheck, MonitoringCheckInput, MonitoringDashboardInput, MonitoringDashboardState, MonitoringHeartbeatInput, MonitoringHeartbeatResult, MonitoringStatusPageInput, MonitoringStatusPageResult, MonitoringStatusPageState, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
9
|
+
import { ApiCheck, ApiCheckInput, ApiCheckRequest, Assertion, AssertionComparison, AssertionSource, ChecklyClient, ChecklyClientOptions, Dashboard, DashboardInput, Heartbeat, HeartbeatInput, HeartbeatUnit, HttpMethod, ListChecksParams, createChecklyClient } from "@theholocron/checkly-client";
|
|
10
10
|
/** Resolves the Checkly API key from `--token`, `HOLOCRON_CHECKLY_TOKEN`, `CHECKLY_API_KEY` or the keyring, and throws an `AuthError` when none is set. */
|
|
11
11
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
12
12
|
/** Every token this plugin takes, for `holocron doctor secrets --verify`. */
|
|
13
13
|
export declare const tokens: PluginToken[];
|
|
14
14
|
interface ChecklyMonitoringOptions {
|
|
15
15
|
checks?: MonitoringCheckInput[];
|
|
16
|
+
dashboards?: MonitoringDashboardInput[];
|
|
17
|
+
/** Status pages `holocron setup` ensures exist (see `capabilities/status-pages.ts`). */
|
|
18
|
+
statusPages?: MonitoringStatusPageInput[];
|
|
19
|
+
/** Heartbeats `holocron setup` ensures exist. */
|
|
20
|
+
heartbeats?: MonitoringHeartbeatInput[];
|
|
16
21
|
}
|
|
17
22
|
/** The Checkly implementation of the `monitoring` capability: ensures the configured API checks and alert channels exist. */
|
|
18
23
|
export declare class ChecklyMonitoring implements Monitoring {
|
|
@@ -26,6 +31,9 @@ export declare class ChecklyMonitoring implements Monitoring {
|
|
|
26
31
|
readonly dataUri: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATAAAAEwCAMAAAAHJd3BAAAA6lBMVEX////f7v+/3f+fy/+Qwv+Auv9wsv9gqf9QoP9Al/8wj/8ghv8Qff8Adf/P5f/v9v+v1P+gy//f7f8Qfv9wsf+Qw/+w0/8wjv9Qof+v0/+Pwv/v9/9/uv+Pw/+/ydOAkqhQaoggQWgAJlIwT3Pv8fRvsf+QoLNgd5JAXH1gd5Ogrb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/TXjHxBjHpUTDt94zvMyTf8Nizpnw8UlkvLsejMBmf0W94jCwpHw9f4z8mg0/7QQlnf5LYvd4v/HZS17W/Mo442DYs5TRYcqAWOV6DDTUr+NyFc5XE4JB8ce0plwIB6ttHm0LKUtd8zDw4JN1+x22CMiXRhVdm6Ce/lnZ/kMfc0pgUCNDfprnBK7tyS2AvAMoy9jyBO7ID9Yw6xjUTzFR1hE/4BMZYDwovvXIFSFZ77Dxo4X2RGPvuLvG/xvsiNsYdZlkDoKFrGlX+1foFLfvqIR6JTmL2WYTYBzKG9kElNoVtoAgqL5TEejF9PaETMKuxNbK14MEP71f2DvLHAZDihTZjE4FhBMXIUCEmbb6YD+QEzGxsTB9g6BDLNV/U4aUxZCZjF/gMRh9iyuQr8qAkvK3KWsicr6AwY1zW/xojzpSV2DDbfxMIxlCcNSrrP9t2piyBsvFDzdnfkS2ynDb5D/yZsrKc/bOkFoksXv/1ILYIbGFIzu+dcvq3cOcCioOsX/5zF1on/gCqJzk9+d3af/H1ZEGUQPC/XwOrH55TysIz8M9D+TEnr1rxM+H8/yeBB3UlW85vVmMHcbAfUwdRcppu1gqeBtl6nq7kR2FCWi9aSKfTaZrOF4WSGP84Xd3MFTxN1PrXgHNPYdlEiju48b6A5faQ+kVUBsfA8hdvMt958iBLc83CHLaSizvyj9N0s8zg6MjutCnTh5N1ZlfmSiyXU631HaO22RgzCcEV6Lzmx6cKP2mDMNbwCXUCskHhxgUNHDUwaLgWdmTTKHEzXDN4SMMcuUTe8OpwS+SNsTlgaIxtAEFjLF9Cg4E5t+3d12lQM/1oSIP7BnN5k0HDTpY3KynldLVpbDU0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ8LX4GOldjeT7Ifd8AAAAASUVORK5CYII=";
|
|
27
32
|
};
|
|
28
33
|
readonly checks: readonly MonitoringCheckInput[];
|
|
34
|
+
readonly dashboards: readonly MonitoringDashboardInput[];
|
|
35
|
+
readonly statusPages: readonly MonitoringStatusPageInput[];
|
|
36
|
+
readonly heartbeats: readonly MonitoringHeartbeatInput[];
|
|
29
37
|
constructor(client: () => ChecklyClient, opts?: ChecklyMonitoringOptions);
|
|
30
38
|
whoami(): Promise<{
|
|
31
39
|
ok: boolean;
|
|
@@ -36,6 +44,14 @@ export declare class ChecklyMonitoring implements Monitoring {
|
|
|
36
44
|
}>;
|
|
37
45
|
/** Every API check on the account, read a page at a time. Checks of another type (browser, heartbeat) are left out. */
|
|
38
46
|
listChecks(): Promise<MonitoringCheckInput[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Find-or-create-or-update a heartbeat by exact name (never deleting one). The ping URL comes back on every call, not
|
|
49
|
+
* only on create, and is a credential: the caller hands it to a secret store and never prints it. Alert channels
|
|
50
|
+
* subscribe a heartbeat with the checks, since Checkly lists it among them.
|
|
51
|
+
*/
|
|
52
|
+
ensureHeartbeat(input: MonitoringHeartbeatInput): Promise<MonitoringHeartbeatResult>;
|
|
53
|
+
/** Every heartbeat on the account, in the shape `heartbeats` declares them; the ping URL is left out. */
|
|
54
|
+
listHeartbeats(): Promise<MonitoringHeartbeatInput[]>;
|
|
39
55
|
/**
|
|
40
56
|
* A Discord alert channel: a `WEBHOOK` Checkly formats for Discord. Found by name, so one made by hand is adopted and
|
|
41
57
|
* kept up to date, not duplicated. Every check routed to the channel is subscribed (all of them, unless a configured
|
|
@@ -77,8 +93,18 @@ export declare class ChecklyMonitoring implements Monitoring {
|
|
|
77
93
|
private routedTo;
|
|
78
94
|
/** Every check on the account, read a page at a time. */
|
|
79
95
|
private allChecks;
|
|
96
|
+
/** A status page, its components and one automation rule per component; see `capabilities/status-pages.ts`. */
|
|
97
|
+
ensureStatusPage(input: MonitoringStatusPageInput): Promise<MonitoringStatusPageResult>;
|
|
98
|
+
/** Reads the status page `input.name` and compares it with the declaration. */
|
|
99
|
+
inspectStatusPage(input: MonitoringStatusPageInput): Promise<MonitoringStatusPageState>;
|
|
80
100
|
/** Checkly's `search` param is a case-insensitive partial match — narrow to the exact name ourselves. */
|
|
81
101
|
private findByExactName;
|
|
102
|
+
/** Find-or-create-or-update a dashboard by its header; see `./dashboards.ts`. */
|
|
103
|
+
ensureDashboard(input: MonitoringDashboardInput): Promise<import("@theholocron/cli").EnsuredResource & {
|
|
104
|
+
key?: string;
|
|
105
|
+
}>;
|
|
106
|
+
/** Read the dashboard named `name` and the names of the account's others; never returns its key. */
|
|
107
|
+
inspectDashboard(name: string): Promise<MonitoringDashboardState>;
|
|
82
108
|
}
|
|
83
109
|
interface VerifyTokenOptions {
|
|
84
110
|
baseUrl?: string;
|
|
@@ -92,6 +118,12 @@ export interface ChecklyPluginOptions extends ResolveTokenInput {
|
|
|
92
118
|
accountId: string;
|
|
93
119
|
/** Checks `holocron setup` should ensure exist. */
|
|
94
120
|
checks?: MonitoringCheckInput[];
|
|
121
|
+
/** Dashboards `holocron setup` should ensure exist, private unless a declaration says otherwise. */
|
|
122
|
+
dashboards?: MonitoringDashboardInput[];
|
|
123
|
+
/** Status pages `holocron setup` should ensure exist, with their components and rules. */
|
|
124
|
+
statusPages?: MonitoringStatusPageInput[];
|
|
125
|
+
/** Heartbeats `holocron setup` should ensure exist; the ping URL of each is handed to the private import file. */
|
|
126
|
+
heartbeats?: MonitoringHeartbeatInput[];
|
|
95
127
|
/** Override base URL for tests. */
|
|
96
128
|
baseUrl?: string;
|
|
97
129
|
/** Override `fetch` for tests. */
|
|
@@ -123,4 +155,4 @@ export declare function createPlugin(options: ChecklyPluginOptions): {
|
|
|
123
155
|
* is supplied or the supplied token is rejected.
|
|
124
156
|
*/
|
|
125
157
|
export declare const AUTH_HINT: string;
|
|
126
|
-
export { type ApiCheck, type ApiCheckInput, type ApiCheckRequest, type Assertion, type AssertionComparison, type AssertionSource, AuthError, type ChecklyClient, type ChecklyClientOptions, type HttpMethod, type ListChecksParams, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createChecklyClient };
|
|
158
|
+
export { type ApiCheck, type ApiCheckInput, type ApiCheckRequest, type Assertion, type AssertionComparison, type AssertionSource, AuthError, type ChecklyClient, type ChecklyClientOptions, type Dashboard, type DashboardInput, type Heartbeat, type HeartbeatInput, type HeartbeatUnit, type HttpMethod, type ListChecksParams, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createChecklyClient };
|
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,474 @@ function routedAway(declared, checkName, channelName) {
|
|
|
38
38
|
// src/same-template.ts
|
|
39
39
|
/** Whether two templates are the same message, whatever the whitespace between the lines. */
|
|
40
40
|
const sameTemplate = (a, b) => (a ?? "").replace(/\s+/g, "") === b.replace(/\s+/g, "");
|
|
41
|
+
// src/capabilities/dashboards.ts
|
|
42
|
+
/** Whether two tag lists hold the same tags, in any order. */
|
|
43
|
+
function sameTags(a, b) {
|
|
44
|
+
const left = [...new Set(a)].sort();
|
|
45
|
+
const right = [...new Set(b)].sort();
|
|
46
|
+
return left.length === right.length && left.every((tag, i) => tag === right[i]);
|
|
47
|
+
}
|
|
48
|
+
/** The dashboard whose header is exactly `name`, from the account's list. */
|
|
49
|
+
async function findDashboard(client, name) {
|
|
50
|
+
return (await client.dashboards.list()).find((d) => d.header === name);
|
|
51
|
+
}
|
|
52
|
+
/** The first view key the provider returned for a dashboard, if it returned one. */
|
|
53
|
+
function viewKey(dashboard) {
|
|
54
|
+
return dashboard.keys?.find((k) => k.rawKey)?.rawKey;
|
|
55
|
+
}
|
|
56
|
+
/** Find-or-create-or-update the dashboard `input.name`; see the file header. */
|
|
57
|
+
async function ensureDashboard(client, input) {
|
|
58
|
+
const wantPrivate = input.private ?? true;
|
|
59
|
+
const existing = await findDashboard(client, input.name);
|
|
60
|
+
if (!existing) {
|
|
61
|
+
const body = {
|
|
62
|
+
header: input.name,
|
|
63
|
+
tags: input.tags,
|
|
64
|
+
isPrivate: wantPrivate,
|
|
65
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
66
|
+
...input.domain !== void 0 ? { customDomain: input.domain } : {}
|
|
67
|
+
};
|
|
68
|
+
const created = await client.dashboards.create(body);
|
|
69
|
+
const id = created.dashboardId;
|
|
70
|
+
if (!wantPrivate) return {
|
|
71
|
+
id,
|
|
72
|
+
created: true
|
|
73
|
+
};
|
|
74
|
+
const key = viewKey(created) ?? viewKey(await client.dashboards.get(id));
|
|
75
|
+
return {
|
|
76
|
+
id,
|
|
77
|
+
created: true,
|
|
78
|
+
...key ? { key } : {}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const changes = {};
|
|
82
|
+
const updated = [];
|
|
83
|
+
if (!sameTags(existing.tags ?? [], input.tags)) {
|
|
84
|
+
changes.tags = input.tags;
|
|
85
|
+
updated.push("tags");
|
|
86
|
+
}
|
|
87
|
+
const wasPrivate = existing.isPrivate === true;
|
|
88
|
+
if (wasPrivate !== wantPrivate) {
|
|
89
|
+
changes.isPrivate = wantPrivate;
|
|
90
|
+
updated.push("private");
|
|
91
|
+
}
|
|
92
|
+
if (input.description !== void 0 && existing.description !== input.description) {
|
|
93
|
+
changes.description = input.description;
|
|
94
|
+
updated.push("description");
|
|
95
|
+
}
|
|
96
|
+
if (input.domain !== void 0 && existing.customDomain !== input.domain) {
|
|
97
|
+
changes.customDomain = input.domain;
|
|
98
|
+
updated.push("domain");
|
|
99
|
+
}
|
|
100
|
+
if (updated.length === 0) return {
|
|
101
|
+
id: existing.dashboardId,
|
|
102
|
+
created: false
|
|
103
|
+
};
|
|
104
|
+
await client.dashboards.update(existing.dashboardId, changes);
|
|
105
|
+
const key = wantPrivate && !wasPrivate ? viewKey(await client.dashboards.get(existing.dashboardId)) : void 0;
|
|
106
|
+
return {
|
|
107
|
+
id: existing.dashboardId,
|
|
108
|
+
created: false,
|
|
109
|
+
updated,
|
|
110
|
+
...key ? { key } : {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Read the dashboard `name` and the headers of the account's others. Read-only; never returns a key. */
|
|
114
|
+
async function inspectDashboard(client, name) {
|
|
115
|
+
const all = await client.dashboards.list();
|
|
116
|
+
const found = all.find((d) => d.header === name);
|
|
117
|
+
const others = all.filter((d) => d !== found).map((d) => d.header ?? d.dashboardId);
|
|
118
|
+
if (!found) return {
|
|
119
|
+
exists: false,
|
|
120
|
+
others
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
exists: true,
|
|
124
|
+
private: found.isPrivate === true,
|
|
125
|
+
tags: [...found.tags ?? []],
|
|
126
|
+
...found.customDomain ? { domain: found.customDomain } : {},
|
|
127
|
+
others
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
// src/capabilities/heartbeats.ts
|
|
131
|
+
const PAGE$1 = 100;
|
|
132
|
+
/** A heartbeat as Checkly holds it, in the shape `heartbeats` declares them. The ping URL is never part of it. */
|
|
133
|
+
function fromChecklyHeartbeat(h) {
|
|
134
|
+
return {
|
|
135
|
+
name: h.name,
|
|
136
|
+
period: h.heartbeat.period,
|
|
137
|
+
periodUnit: h.heartbeat.periodUnit,
|
|
138
|
+
grace: h.heartbeat.grace,
|
|
139
|
+
graceUnit: h.heartbeat.graceUnit,
|
|
140
|
+
tags: h.tags ?? []
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/** The request body: the settings the config states, and, on an existing heartbeat, its own ping token so its URL holds. */
|
|
144
|
+
function payload(input, existing) {
|
|
145
|
+
return {
|
|
146
|
+
name: input.name,
|
|
147
|
+
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
148
|
+
heartbeat: {
|
|
149
|
+
period: input.period,
|
|
150
|
+
periodUnit: input.periodUnit,
|
|
151
|
+
grace: input.grace,
|
|
152
|
+
graceUnit: input.graceUnit,
|
|
153
|
+
...existing?.heartbeat.pingToken ? { pingToken: existing.heartbeat.pingToken } : {}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function differs(input, h) {
|
|
158
|
+
const have = h.heartbeat;
|
|
159
|
+
if (have.period !== input.period || have.periodUnit !== input.periodUnit || have.grace !== input.grace || have.graceUnit !== input.graceUnit) return true;
|
|
160
|
+
if (input.tags === void 0) return false;
|
|
161
|
+
return [...input.tags].sort().join("\n") !== [...h.tags ?? []].sort().join("\n");
|
|
162
|
+
}
|
|
163
|
+
/** Find the heartbeat named `input.name` and bring it in line, or make it. A field the config leaves out is left alone. */
|
|
164
|
+
async function ensureChecklyHeartbeat(client, input) {
|
|
165
|
+
const existing = (await client.heartbeats.list({
|
|
166
|
+
search: input.name,
|
|
167
|
+
limit: PAGE$1
|
|
168
|
+
})).find((h) => h.name === input.name);
|
|
169
|
+
if (!existing) return result(await client.heartbeats.create(payload(input)), false);
|
|
170
|
+
return result(differs(input, existing) ? await client.heartbeats.update(existing.id, payload(input, existing)) : existing, true);
|
|
171
|
+
}
|
|
172
|
+
function result(h, alreadyExists) {
|
|
173
|
+
return {
|
|
174
|
+
heartbeat: {
|
|
175
|
+
id: h.id,
|
|
176
|
+
name: h.name
|
|
177
|
+
},
|
|
178
|
+
alreadyExists,
|
|
179
|
+
...h.heartbeat.pingUrl ? { pingUrl: h.heartbeat.pingUrl } : {}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
// src/capabilities/status-pages.ts
|
|
183
|
+
/** What a failing check does to a component's status: the full outage (the spec's choice; a milder impact is later). */
|
|
184
|
+
const IMPACT = "MAJOR_OUTAGE";
|
|
185
|
+
/** The fields of a page that can be written back (Checkly rejects the read-only ones). */
|
|
186
|
+
const PAGE_FIELDS = [
|
|
187
|
+
"name",
|
|
188
|
+
"description",
|
|
189
|
+
"url",
|
|
190
|
+
"customDomain",
|
|
191
|
+
"themeColors",
|
|
192
|
+
"logo",
|
|
193
|
+
"logoDark",
|
|
194
|
+
"redirectTo",
|
|
195
|
+
"favicon",
|
|
196
|
+
"defaultTheme",
|
|
197
|
+
"privacyPolicyLink",
|
|
198
|
+
"termsOfServiceLink",
|
|
199
|
+
"supportLink",
|
|
200
|
+
"footerText",
|
|
201
|
+
"googleAnalyticsTag",
|
|
202
|
+
"allowIndexing",
|
|
203
|
+
"isPrivate"
|
|
204
|
+
];
|
|
205
|
+
/** The page as a write body: what it has now, so a PUT, which replaces, changes nothing it was not asked to. */
|
|
206
|
+
function writable(page) {
|
|
207
|
+
const out = {};
|
|
208
|
+
for (const key of PAGE_FIELDS) if (page[key] !== void 0) out[key] = page[key];
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
/** The page fields the config states, in Checkly's names. */
|
|
212
|
+
function declaredFields(input) {
|
|
213
|
+
return {
|
|
214
|
+
url: input.slug,
|
|
215
|
+
...input.domain !== void 0 ? { customDomain: input.domain.toLowerCase() } : {},
|
|
216
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
217
|
+
...input.logo !== void 0 ? { logo: input.logo } : {},
|
|
218
|
+
...input.private !== void 0 ? { isPrivate: input.private } : {}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
async function findPage(client, name) {
|
|
222
|
+
return (await client.statusPages.list()).find((p) => p.name === name);
|
|
223
|
+
}
|
|
224
|
+
/** The order a declared component is shown at: top-level items (groups and ungrouped components) by first appearance. */
|
|
225
|
+
function layout(components) {
|
|
226
|
+
const groups = [];
|
|
227
|
+
const top = [];
|
|
228
|
+
const inGroup = /* @__PURE__ */ new Map();
|
|
229
|
+
for (const c of components) {
|
|
230
|
+
if (c.group === void 0) {
|
|
231
|
+
top.push({
|
|
232
|
+
kind: "service",
|
|
233
|
+
name: c.name
|
|
234
|
+
});
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (!groups.includes(c.group)) {
|
|
238
|
+
groups.push(c.group);
|
|
239
|
+
top.push({
|
|
240
|
+
kind: "group",
|
|
241
|
+
name: c.group
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
inGroup.set(c.group, [...inGroup.get(c.group) ?? [], c.name]);
|
|
245
|
+
}
|
|
246
|
+
const order = /* @__PURE__ */ new Map();
|
|
247
|
+
top.forEach((t, i) => order.set(`${t.kind}:${t.name}`, i));
|
|
248
|
+
for (const [group, names] of inGroup) names.forEach((n, i) => order.set(`child:${group}:${n}`, i));
|
|
249
|
+
return {
|
|
250
|
+
groups,
|
|
251
|
+
order
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/** Whether a rule already does what the declaration asks: the tags are held and the component is hit at full outage. */
|
|
255
|
+
function ruleOk(rule, tags, componentId) {
|
|
256
|
+
if (!rule) return false;
|
|
257
|
+
return tags.every((t) => rule.tags.includes(t)) && rule.components.some((c) => c.componentId === componentId && c.targetImpact === IMPACT);
|
|
258
|
+
}
|
|
259
|
+
/** Whether Checkly has accepted the custom domain and issued its certificate. */
|
|
260
|
+
function isVerified(v) {
|
|
261
|
+
return v.status === "active" && v.sslStatus === "active";
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* The records to make for a domain that is not verified: the `CNAME` the domain points at (Checkly's `CNAME` field,
|
|
265
|
+
* else its ownership record when that is a CNAME) and any `TXT` record it asks for (ownership, certificate).
|
|
266
|
+
*/
|
|
267
|
+
function recordsFor(domain, v) {
|
|
268
|
+
const ownership = v.ownershipVerification;
|
|
269
|
+
const target = v.CNAME ?? (ownership?.type === "cname" ? ownership.value : void 0);
|
|
270
|
+
return {
|
|
271
|
+
record: target ? {
|
|
272
|
+
type: "CNAME",
|
|
273
|
+
name: domain,
|
|
274
|
+
value: target
|
|
275
|
+
} : void 0,
|
|
276
|
+
txt: [...ownership?.type === "txt" ? [{
|
|
277
|
+
type: "TXT",
|
|
278
|
+
name: ownership.name,
|
|
279
|
+
value: ownership.value
|
|
280
|
+
}] : [], ...(v.validationRecords ?? []).map((r) => ({
|
|
281
|
+
type: "TXT",
|
|
282
|
+
name: r.txt_name,
|
|
283
|
+
value: r.txt_value
|
|
284
|
+
}))]
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** Find or make the page, its components and their rules, and report the custom domain's state. Never deletes. */
|
|
288
|
+
async function ensureStatusPage(client, input) {
|
|
289
|
+
const api = client.statusPages;
|
|
290
|
+
const wanted = declaredFields(input);
|
|
291
|
+
let page = await findPage(client, input.name);
|
|
292
|
+
const created = page === void 0;
|
|
293
|
+
const pageUpdated = [];
|
|
294
|
+
if (!page) page = await api.create({
|
|
295
|
+
name: input.name,
|
|
296
|
+
isPrivate: false,
|
|
297
|
+
...wanted
|
|
298
|
+
});
|
|
299
|
+
else {
|
|
300
|
+
const have = writable(page);
|
|
301
|
+
const changed = Object.keys(wanted).filter((k) => have[k] !== wanted[k]);
|
|
302
|
+
if (changed.length > 0) {
|
|
303
|
+
page = await api.update(page.id, {
|
|
304
|
+
...have,
|
|
305
|
+
...wanted
|
|
306
|
+
});
|
|
307
|
+
pageUpdated.push(...changed.map((k) => k === "url" ? "slug" : k === "customDomain" ? "domain" : String(k)));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const existing = await api.components.list(page.id);
|
|
311
|
+
const { groups, order } = layout(input.components);
|
|
312
|
+
const made = [];
|
|
313
|
+
const changedComponents = [];
|
|
314
|
+
const groupIds = /* @__PURE__ */ new Map();
|
|
315
|
+
for (const name of groups) {
|
|
316
|
+
const displayOrder = order.get(`group:${name}`);
|
|
317
|
+
const found = existing.find((c) => c.type === "GROUP" && c.name === name);
|
|
318
|
+
if (!found) {
|
|
319
|
+
const group = await api.components.create(page.id, {
|
|
320
|
+
name,
|
|
321
|
+
type: "GROUP",
|
|
322
|
+
displayOrder
|
|
323
|
+
});
|
|
324
|
+
groupIds.set(name, group.id);
|
|
325
|
+
made.push(name);
|
|
326
|
+
} else {
|
|
327
|
+
groupIds.set(name, found.id);
|
|
328
|
+
if (found.displayOrder !== displayOrder) {
|
|
329
|
+
await api.components.update(page.id, found.id, {
|
|
330
|
+
name,
|
|
331
|
+
type: "GROUP",
|
|
332
|
+
displayOrder,
|
|
333
|
+
description: found.description ?? null,
|
|
334
|
+
hidden: found.hidden ?? false,
|
|
335
|
+
parentId: found.parentId ?? null,
|
|
336
|
+
configuration: found.configuration
|
|
337
|
+
});
|
|
338
|
+
changedComponents.push(name);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const componentIds = /* @__PURE__ */ new Map();
|
|
343
|
+
for (const c of input.components) {
|
|
344
|
+
const displayOrder = c.group === void 0 ? order.get(`service:${c.name}`) : order.get(`child:${c.group}:${c.name}`);
|
|
345
|
+
const parentId = c.group === void 0 ? void 0 : groupIds.get(c.group);
|
|
346
|
+
const found = existing.find((e) => e.type === "SERVICE" && e.name === c.name);
|
|
347
|
+
if (!found) {
|
|
348
|
+
const service = await api.components.create(page.id, {
|
|
349
|
+
name: c.name,
|
|
350
|
+
type: "SERVICE",
|
|
351
|
+
displayOrder,
|
|
352
|
+
...c.description !== void 0 ? { description: c.description } : {},
|
|
353
|
+
...parentId !== void 0 ? { parentId } : {}
|
|
354
|
+
});
|
|
355
|
+
componentIds.set(c.name, service.id);
|
|
356
|
+
made.push(c.name);
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
componentIds.set(c.name, found.id);
|
|
360
|
+
if (found.displayOrder !== displayOrder || parentId !== void 0 && (found.parentId ?? null) !== parentId || c.description !== void 0 && (found.description ?? null) !== c.description) {
|
|
361
|
+
await api.components.update(page.id, found.id, {
|
|
362
|
+
name: c.name,
|
|
363
|
+
type: "SERVICE",
|
|
364
|
+
displayOrder,
|
|
365
|
+
description: c.description !== void 0 ? c.description : found.description ?? null,
|
|
366
|
+
hidden: found.hidden ?? false,
|
|
367
|
+
parentId: parentId !== void 0 ? parentId : found.parentId ?? null,
|
|
368
|
+
configuration: found.configuration
|
|
369
|
+
});
|
|
370
|
+
changedComponents.push(c.name);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const rules = await api.rules.list(page.id);
|
|
374
|
+
const rulesMade = [];
|
|
375
|
+
const rulesChanged = [];
|
|
376
|
+
for (const c of input.components) {
|
|
377
|
+
const componentId = componentIds.get(c.name);
|
|
378
|
+
const rule = rules.find((r) => r.name === c.name);
|
|
379
|
+
if (ruleOk(rule, c.tags, componentId)) continue;
|
|
380
|
+
if (!rule) {
|
|
381
|
+
await api.rules.create(page.id, {
|
|
382
|
+
name: c.name,
|
|
383
|
+
firstUpdate: `${c.name} is failing its checks.`,
|
|
384
|
+
lastUpdate: `${c.name} is passing its checks again.`,
|
|
385
|
+
tags: c.tags,
|
|
386
|
+
components: [{
|
|
387
|
+
componentId,
|
|
388
|
+
targetImpact: IMPACT
|
|
389
|
+
}]
|
|
390
|
+
});
|
|
391
|
+
rulesMade.push(c.name);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
await api.rules.update(page.id, rule.id, {
|
|
395
|
+
name: rule.name,
|
|
396
|
+
firstUpdate: rule.firstUpdate,
|
|
397
|
+
lastUpdate: rule.lastUpdate,
|
|
398
|
+
tags: [.../* @__PURE__ */ new Set([...rule.tags, ...c.tags])],
|
|
399
|
+
...rule.enabled !== void 0 ? { enabled: rule.enabled } : {},
|
|
400
|
+
...rule.notifySubscribers !== void 0 ? { notifySubscribers: rule.notifySubscribers } : {},
|
|
401
|
+
...rule.coolDownWindowMinutes !== void 0 ? { coolDownWindowMinutes: rule.coolDownWindowMinutes } : {},
|
|
402
|
+
components: [...rule.components.filter((e) => e.componentId !== componentId).map(({ componentId: id, targetImpact }) => ({
|
|
403
|
+
componentId: id,
|
|
404
|
+
targetImpact
|
|
405
|
+
})), {
|
|
406
|
+
componentId,
|
|
407
|
+
targetImpact: IMPACT
|
|
408
|
+
}]
|
|
409
|
+
});
|
|
410
|
+
rulesChanged.push(c.name);
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
id: page.id,
|
|
414
|
+
created,
|
|
415
|
+
...pageUpdated.length > 0 ? { updated: pageUpdated } : {},
|
|
416
|
+
components: {
|
|
417
|
+
created: made,
|
|
418
|
+
updated: changedComponents
|
|
419
|
+
},
|
|
420
|
+
rules: {
|
|
421
|
+
created: rulesMade,
|
|
422
|
+
updated: rulesChanged
|
|
423
|
+
},
|
|
424
|
+
...input.domain !== void 0 ? { domain: await domainState(client, page.id, input.domain) } : {}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
/** The custom domain's state; asks Checkly to look again first when it is not verified. */
|
|
428
|
+
async function domainState(client, pageId, domain) {
|
|
429
|
+
let verification = await client.statusPages.customDomain.verification(pageId);
|
|
430
|
+
if (!isVerified(verification)) verification = await client.statusPages.customDomain.recheck(pageId);
|
|
431
|
+
if (isVerified(verification)) return {
|
|
432
|
+
name: domain,
|
|
433
|
+
verified: true
|
|
434
|
+
};
|
|
435
|
+
const { record, txt } = recordsFor(domain, verification);
|
|
436
|
+
return {
|
|
437
|
+
name: domain,
|
|
438
|
+
verified: false,
|
|
439
|
+
...record ? { record } : {},
|
|
440
|
+
...txt.length > 0 ? { extraRecords: txt } : {}
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
/** Read the page and compare it with the declaration. Read-only: the one thing it asks Checkly is the domain's state. */
|
|
444
|
+
async function inspectStatusPage(client, input) {
|
|
445
|
+
const page = await findPage(client, input.name);
|
|
446
|
+
if (!page) return {
|
|
447
|
+
exists: false,
|
|
448
|
+
domainProblems: [],
|
|
449
|
+
missingComponents: [],
|
|
450
|
+
misplacedComponents: [],
|
|
451
|
+
missingRules: [],
|
|
452
|
+
extraComponents: [],
|
|
453
|
+
extraRules: []
|
|
454
|
+
};
|
|
455
|
+
const api = client.statusPages;
|
|
456
|
+
const [components, rules] = await Promise.all([api.components.list(page.id), api.rules.list(page.id)]);
|
|
457
|
+
const { groups, order } = layout(input.components);
|
|
458
|
+
const byId = new Map(components.map((c) => [c.id, c]));
|
|
459
|
+
const declaredNames = /* @__PURE__ */ new Set([...input.components.map((c) => c.name), ...groups]);
|
|
460
|
+
const services = /* @__PURE__ */ new Map();
|
|
461
|
+
for (const c of components) if (c.type === "SERVICE") services.set(c.name, c);
|
|
462
|
+
const missing = [];
|
|
463
|
+
const misplaced = [];
|
|
464
|
+
const missingRules = [];
|
|
465
|
+
for (const name of groups) {
|
|
466
|
+
const g = components.find((c) => c.type === "GROUP" && c.name === name);
|
|
467
|
+
if (!g) missing.push(name);
|
|
468
|
+
else if (g.displayOrder !== order.get(`group:${name}`)) misplaced.push(`${name}: order ${g.displayOrder}`);
|
|
469
|
+
}
|
|
470
|
+
for (const c of input.components) {
|
|
471
|
+
const found = services.get(c.name);
|
|
472
|
+
if (!found) {
|
|
473
|
+
missing.push(c.name);
|
|
474
|
+
missingRules.push(c.name);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (c.group !== void 0) {
|
|
478
|
+
if ((found.parentId ? byId.get(found.parentId) : void 0)?.name !== c.group) misplaced.push(`${c.name}: not under group ${c.group}`);
|
|
479
|
+
}
|
|
480
|
+
const want = c.group === void 0 ? order.get(`service:${c.name}`) : order.get(`child:${c.group}:${c.name}`);
|
|
481
|
+
if (found.displayOrder !== want) misplaced.push(`${c.name}: order ${found.displayOrder}, expected ${want}`);
|
|
482
|
+
if (!ruleOk(rules.find((r) => r.name === c.name), c.tags, found.id)) missingRules.push(c.name);
|
|
483
|
+
}
|
|
484
|
+
const state = {
|
|
485
|
+
exists: true,
|
|
486
|
+
public: page.isPrivate !== true,
|
|
487
|
+
domainProblems: [],
|
|
488
|
+
missingComponents: missing,
|
|
489
|
+
misplacedComponents: misplaced,
|
|
490
|
+
missingRules,
|
|
491
|
+
extraComponents: components.filter((c) => !declaredNames.has(c.name)).map((c) => c.name),
|
|
492
|
+
extraRules: rules.filter((r) => !input.components.some((c) => c.name === r.name)).map((r) => r.name)
|
|
493
|
+
};
|
|
494
|
+
if (page.customDomain) state.domain = page.customDomain;
|
|
495
|
+
if (input.domain !== void 0) {
|
|
496
|
+
if ((page.customDomain ?? "").toLowerCase() !== input.domain.toLowerCase()) state.domainProblems.push(`serves ${page.customDomain ?? "no custom domain"}, declared ${input.domain}`);
|
|
497
|
+
else {
|
|
498
|
+
const verification = await api.customDomain.verification(page.id);
|
|
499
|
+
state.domainVerified = isVerified(verification);
|
|
500
|
+
if (!state.domainVerified) {
|
|
501
|
+
const { record } = recordsFor(input.domain, verification);
|
|
502
|
+
if (record) state.domainRecord = record;
|
|
503
|
+
state.domainProblems.push(...verification.verificationErrors ?? []);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return state;
|
|
508
|
+
}
|
|
41
509
|
// src/capabilities/monitoring.ts
|
|
42
510
|
/**
|
|
43
511
|
* `monitoring` capability for Checkly.
|
|
@@ -94,6 +562,7 @@ function fromChecklyCheck(check) {
|
|
|
94
562
|
shouldFail: check.shouldFail,
|
|
95
563
|
assertions,
|
|
96
564
|
...check.locations ? { locations: check.locations } : {},
|
|
565
|
+
...check.tags ? { tags: check.tags } : {},
|
|
97
566
|
...request.body ? { body: request.body } : {}
|
|
98
567
|
};
|
|
99
568
|
}
|
|
@@ -104,6 +573,7 @@ function toChecklyPayload(input) {
|
|
|
104
573
|
...input.activated !== void 0 ? { activated: input.activated } : {},
|
|
105
574
|
...input.locations !== void 0 ? { locations: input.locations } : {},
|
|
106
575
|
...input.shouldFail !== void 0 ? { shouldFail: input.shouldFail } : {},
|
|
576
|
+
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
107
577
|
request: {
|
|
108
578
|
url: input.url,
|
|
109
579
|
method: input.method ?? "GET",
|
|
@@ -136,9 +606,15 @@ var ChecklyMonitoring = class {
|
|
|
136
606
|
providerName = "checkly";
|
|
137
607
|
icon = CHECKLY_ICON;
|
|
138
608
|
checks;
|
|
609
|
+
dashboards;
|
|
610
|
+
statusPages;
|
|
611
|
+
heartbeats;
|
|
139
612
|
constructor(client, opts = {}) {
|
|
140
613
|
this.client = client;
|
|
141
614
|
this.checks = opts.checks ?? [];
|
|
615
|
+
this.dashboards = opts.dashboards ?? [];
|
|
616
|
+
this.statusPages = opts.statusPages ?? [];
|
|
617
|
+
this.heartbeats = opts.heartbeats ?? [];
|
|
142
618
|
}
|
|
143
619
|
async whoami() {
|
|
144
620
|
try {
|
|
@@ -184,6 +660,18 @@ var ChecklyMonitoring = class {
|
|
|
184
660
|
}
|
|
185
661
|
}
|
|
186
662
|
/**
|
|
663
|
+
* Find-or-create-or-update a heartbeat by exact name (never deleting one). The ping URL comes back on every call, not
|
|
664
|
+
* only on create, and is a credential: the caller hands it to a secret store and never prints it. Alert channels
|
|
665
|
+
* subscribe a heartbeat with the checks, since Checkly lists it among them.
|
|
666
|
+
*/
|
|
667
|
+
async ensureHeartbeat(input) {
|
|
668
|
+
return ensureChecklyHeartbeat(this.client(), input);
|
|
669
|
+
}
|
|
670
|
+
/** Every heartbeat on the account, in the shape `heartbeats` declares them; the ping URL is left out. */
|
|
671
|
+
async listHeartbeats() {
|
|
672
|
+
return (await this.client().heartbeats.listAll()).map(fromChecklyHeartbeat);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
187
675
|
* A Discord alert channel: a `WEBHOOK` Checkly formats for Discord. Found by name, so one made by hand is adopted and
|
|
188
676
|
* kept up to date, not duplicated. Every check routed to the channel is subscribed (all of them, unless a configured
|
|
189
677
|
* check names its `alertChannels`; a check the config does not declare is not subject to routing), since a check
|
|
@@ -390,7 +878,8 @@ var ChecklyMonitoring = class {
|
|
|
390
878
|
* it alerts through every channel, as one made by hand always has.
|
|
391
879
|
*/
|
|
392
880
|
routedTo(name, checks) {
|
|
393
|
-
const
|
|
881
|
+
const declared = [...this.checks, ...this.heartbeats];
|
|
882
|
+
const away = (c) => routedAway(declared, c.name, name);
|
|
394
883
|
return {
|
|
395
884
|
routed: checks.filter((c) => !away(c)),
|
|
396
885
|
routedAway: checks.filter(away)
|
|
@@ -412,10 +901,26 @@ var ChecklyMonitoring = class {
|
|
|
412
901
|
if (batch.length < PAGE) return found;
|
|
413
902
|
}
|
|
414
903
|
}
|
|
904
|
+
/** A status page, its components and one automation rule per component; see `capabilities/status-pages.ts`. */
|
|
905
|
+
ensureStatusPage(input) {
|
|
906
|
+
return ensureStatusPage(this.client(), input);
|
|
907
|
+
}
|
|
908
|
+
/** Reads the status page `input.name` and compares it with the declaration. */
|
|
909
|
+
inspectStatusPage(input) {
|
|
910
|
+
return inspectStatusPage(this.client(), input);
|
|
911
|
+
}
|
|
415
912
|
/** Checkly's `search` param is a case-insensitive partial match — narrow to the exact name ourselves. */
|
|
416
913
|
async findByExactName(name) {
|
|
417
914
|
return (await this.client().checks.list({ search: name })).find((c) => c.name === name);
|
|
418
915
|
}
|
|
916
|
+
/** Find-or-create-or-update a dashboard by its header; see `./dashboards.ts`. */
|
|
917
|
+
ensureDashboard(input) {
|
|
918
|
+
return ensureDashboard(this.client(), input);
|
|
919
|
+
}
|
|
920
|
+
/** Read the dashboard named `name` and the names of the account's others; never returns its key. */
|
|
921
|
+
inspectDashboard(name) {
|
|
922
|
+
return inspectDashboard(this.client(), name);
|
|
923
|
+
}
|
|
419
924
|
};
|
|
420
925
|
const channelName = (deps) => createEnvLookup(deps.env).get("HOLOCRON_CHECKLY_PROBE_CHANNEL") ?? "Message to #uptime";
|
|
421
926
|
// src/probes/find-channel.ts
|
|
@@ -643,7 +1148,12 @@ function createContext(options) {
|
|
|
643
1148
|
}
|
|
644
1149
|
/** Builds the `monitoring` capability for a context, passing it the configured checks. */
|
|
645
1150
|
function monitoring(ctx) {
|
|
646
|
-
return new ChecklyMonitoring(ctx.client, {
|
|
1151
|
+
return new ChecklyMonitoring(ctx.client, {
|
|
1152
|
+
checks: ctx.options.checks,
|
|
1153
|
+
dashboards: ctx.options.dashboards,
|
|
1154
|
+
statusPages: ctx.options.statusPages,
|
|
1155
|
+
heartbeats: ctx.options.heartbeats
|
|
1156
|
+
});
|
|
647
1157
|
}
|
|
648
1158
|
/** Creates the Checkly plugin: its `monitoring` capability and its `connection` and Checkly probes. */
|
|
649
1159
|
function createPlugin(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-checkly",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.464",
|
|
4
4
|
"description": "Holocron plugin for Checkly. Implements the monitoring capability against Checkly's REST API, plus exports verifyToken + AUTH_HINT for `holocron auth`.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checkly",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"tsx": "4.23.15",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
43
|
"vitest": "^5.1.0",
|
|
44
|
-
"@theholocron/
|
|
45
|
-
"@theholocron/
|
|
46
|
-
"@theholocron/
|
|
47
|
-
"@theholocron/
|
|
48
|
-
"@theholocron/
|
|
44
|
+
"@theholocron/checkly-client": "^1.58.0-alpha.39",
|
|
45
|
+
"@theholocron/http-client": "^1.58.0-alpha.39",
|
|
46
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.18",
|
|
47
|
+
"@theholocron/cli": "5.0.0-alpha.464",
|
|
48
|
+
"@theholocron/misc-utils": "^1.17.0-alpha.4"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@theholocron/checkly-client": "^1.55.0",
|
|
52
52
|
"@theholocron/misc-utils": "^1.16.0",
|
|
53
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
53
|
+
"@theholocron/cli": "5.0.0-alpha.464"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=22"
|