@theholocron/holocron-plugin-checkly 5.0.0-alpha.536 → 5.0.0-alpha.537
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/dist/index.d.mts +7 -1
- package/dist/index.mjs +82 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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, MonitoringDashboardInput, MonitoringDashboardState, MonitoringHeartbeatInput, MonitoringHeartbeatResult, MonitoringIncident, MonitoringIncidentQuery, MonitoringStatusPageInput, MonitoringStatusPageResult, MonitoringStatusPageState, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
8
|
+
import { AuthError, Monitoring, MonitoringAlertChannelInput, MonitoringAlertChannelResult, MonitoringAlertChannelState, MonitoringCheck, MonitoringCheckInput, MonitoringDashboardInput, MonitoringDashboardState, MonitoringHeartbeatInput, MonitoringHeartbeatResult, MonitoringIncident, MonitoringIncidentInput, MonitoringIncidentQuery, MonitoringIncidentResolveInput, MonitoringIncidentUpdateInput, MonitoringIncidentWrite, MonitoringStatusPageInput, MonitoringStatusPageResult, MonitoringStatusPageState, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
9
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;
|
|
@@ -99,6 +99,12 @@ export declare class ChecklyMonitoring implements Monitoring {
|
|
|
99
99
|
inspectStatusPage(input: MonitoringStatusPageInput): Promise<MonitoringStatusPageState>;
|
|
100
100
|
/** The incidents of a status page, with their updates; see `capabilities/incidents.ts`. */
|
|
101
101
|
listIncidents(query: MonitoringIncidentQuery): Promise<MonitoringIncident[]>;
|
|
102
|
+
/** Opens an incident with its first update; see `capabilities/incident-writes.ts`. */
|
|
103
|
+
openIncident(input: MonitoringIncidentInput): Promise<MonitoringIncidentWrite>;
|
|
104
|
+
/** Appends an update to an incident. */
|
|
105
|
+
updateIncident(input: MonitoringIncidentUpdateInput): Promise<MonitoringIncidentWrite>;
|
|
106
|
+
/** Appends a `resolved` update, which closes the incident. */
|
|
107
|
+
resolveIncident(input: MonitoringIncidentResolveInput): Promise<MonitoringIncidentWrite>;
|
|
102
108
|
/** Checkly's `search` param is a case-insensitive partial match — narrow to the exact name ourselves. */
|
|
103
109
|
private findByExactName;
|
|
104
110
|
/** Find-or-create-or-update a dashboard by its header; see `./dashboards.ts`. */
|
package/dist/index.mjs
CHANGED
|
@@ -257,6 +257,72 @@ async function listChecklyIncidents(client, query) {
|
|
|
257
257
|
if (needNames) for (const c of await client.statusPages.components.list(page.id)) names.set(c.id, c.name);
|
|
258
258
|
return incidents.map((i) => fromChecklyIncident(i, names));
|
|
259
259
|
}
|
|
260
|
+
// src/capabilities/incident-writes.ts
|
|
261
|
+
const STATUSES = {
|
|
262
|
+
investigating: "INVESTIGATING",
|
|
263
|
+
identified: "IDENTIFIED",
|
|
264
|
+
monitoring: "MONITORING",
|
|
265
|
+
resolved: "RESOLVED"
|
|
266
|
+
};
|
|
267
|
+
/** The neutral impact word for each Checkly impact, turned around. */
|
|
268
|
+
const CHECKLY_IMPACTS = Object.fromEntries(Object.entries(IMPACTS).map(([checkly, neutral]) => [neutral, checkly]));
|
|
269
|
+
/** The longest incident name Checkly accepts. */
|
|
270
|
+
const MAX_NAME = 255;
|
|
271
|
+
async function pageId(client, name) {
|
|
272
|
+
const page = (await client.statusPages.list()).find((p) => p.name === name);
|
|
273
|
+
if (!page) throw new Error(`status page "${name}" not found`);
|
|
274
|
+
return page.id;
|
|
275
|
+
}
|
|
276
|
+
async function impactsOf(client, id, impacts) {
|
|
277
|
+
if (impacts.length === 0) return [];
|
|
278
|
+
const components = await client.statusPages.components.list(id);
|
|
279
|
+
const ids = new Map(components.map((c) => [c.name, c.id]));
|
|
280
|
+
const unknown = impacts.filter((i) => !ids.has(i.component)).map((i) => i.component);
|
|
281
|
+
if (unknown.length > 0) throw new Error(`status page has no component named ${unknown.map((n) => `"${n}"`).join(", ")} (it has ${[...ids.keys()].join(", ") || "none"})`);
|
|
282
|
+
return impacts.map((i) => ({
|
|
283
|
+
componentId: ids.get(i.component),
|
|
284
|
+
status: CHECKLY_IMPACTS[i.impact]
|
|
285
|
+
}));
|
|
286
|
+
}
|
|
287
|
+
/** Opens an incident with its one opening update; the components it marks are looked up by name. */
|
|
288
|
+
async function openChecklyIncident(client, input) {
|
|
289
|
+
if (input.title.length > MAX_NAME) throw new Error(`an incident title is at most ${MAX_NAME} characters (this one is ${input.title.length})`);
|
|
290
|
+
const id = await pageId(client, input.statusPage);
|
|
291
|
+
const componentImpacts = await impactsOf(client, id, input.impacts);
|
|
292
|
+
const incident = await client.statusPages.incidents.create(id, {
|
|
293
|
+
name: input.title,
|
|
294
|
+
incidentUpdates: [{
|
|
295
|
+
description: input.message,
|
|
296
|
+
status: STATUSES[input.status],
|
|
297
|
+
notifySubscribers: input.notify
|
|
298
|
+
}],
|
|
299
|
+
...componentImpacts.length > 0 ? { componentImpacts } : {}
|
|
300
|
+
});
|
|
301
|
+
return {
|
|
302
|
+
id: incident.id,
|
|
303
|
+
status: statusOf$1(incident.lastUpdateStatus ?? STATUSES[input.status])
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/** Appends an update with the status `input.status`. */
|
|
307
|
+
async function updateChecklyIncident(client, input) {
|
|
308
|
+
const id = await pageId(client, input.statusPage);
|
|
309
|
+
const incident = await client.statusPages.incidents.addUpdate(id, input.id, {
|
|
310
|
+
description: input.message,
|
|
311
|
+
status: STATUSES[input.status],
|
|
312
|
+
notifySubscribers: input.notify
|
|
313
|
+
});
|
|
314
|
+
return {
|
|
315
|
+
id: incident.id,
|
|
316
|
+
status: statusOf$1(incident.lastUpdateStatus ?? STATUSES[input.status])
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/** Appends a `RESOLVED` update, which is how Checkly closes an incident. */
|
|
320
|
+
function resolveChecklyIncident(client, input) {
|
|
321
|
+
return updateChecklyIncident(client, {
|
|
322
|
+
...input,
|
|
323
|
+
status: "resolved"
|
|
324
|
+
});
|
|
325
|
+
}
|
|
260
326
|
// src/capabilities/status-pages.ts
|
|
261
327
|
/**
|
|
262
328
|
* Status pages for the Checkly `monitoring` capability (spec `tech-monitoring-dashboards-status-pages`, #2302).
|
|
@@ -1025,6 +1091,18 @@ var ChecklyMonitoring = class {
|
|
|
1025
1091
|
listIncidents(query) {
|
|
1026
1092
|
return listChecklyIncidents(this.client(), query);
|
|
1027
1093
|
}
|
|
1094
|
+
/** Opens an incident with its first update; see `capabilities/incident-writes.ts`. */
|
|
1095
|
+
openIncident(input) {
|
|
1096
|
+
return openChecklyIncident(this.client(), input);
|
|
1097
|
+
}
|
|
1098
|
+
/** Appends an update to an incident. */
|
|
1099
|
+
updateIncident(input) {
|
|
1100
|
+
return updateChecklyIncident(this.client(), input);
|
|
1101
|
+
}
|
|
1102
|
+
/** Appends a `resolved` update, which closes the incident. */
|
|
1103
|
+
resolveIncident(input) {
|
|
1104
|
+
return resolveChecklyIncident(this.client(), input);
|
|
1105
|
+
}
|
|
1028
1106
|
/** Checkly's `search` param is a case-insensitive partial match — narrow to the exact name ourselves. */
|
|
1029
1107
|
async findByExactName(name) {
|
|
1030
1108
|
return (await this.client().checks.list({ search: name })).find((c) => c.name === name);
|
|
@@ -1342,6 +1420,8 @@ async function verifyToken(token, opts = {}) {
|
|
|
1342
1420
|
}
|
|
1343
1421
|
}
|
|
1344
1422
|
// src/index.ts
|
|
1423
|
+
/** A request that has not answered after this long is abandoned, so a stalled API never hangs a command. */
|
|
1424
|
+
const REQUEST_TIMEOUT_MS = 3e4;
|
|
1345
1425
|
/** Builds the plugin context from its options; the API key is resolved lazily on the first client use. */
|
|
1346
1426
|
function createContext(options) {
|
|
1347
1427
|
let client;
|
|
@@ -1351,7 +1431,8 @@ function createContext(options) {
|
|
|
1351
1431
|
if (client) return client;
|
|
1352
1432
|
const clientOpts = {
|
|
1353
1433
|
token: resolveToken(options),
|
|
1354
|
-
accountId: options.accountId
|
|
1434
|
+
accountId: options.accountId,
|
|
1435
|
+
timeoutMs: REQUEST_TIMEOUT_MS
|
|
1355
1436
|
};
|
|
1356
1437
|
if (options.baseUrl !== void 0) clientOpts.baseUrl = options.baseUrl;
|
|
1357
1438
|
if (options.fetch !== void 0) clientOpts.fetch = options.fetch;
|
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.537",
|
|
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": "^6.0.3",
|
|
43
43
|
"vitest": "^5.1.0",
|
|
44
|
-
"@theholocron/
|
|
45
|
-
"@theholocron/
|
|
46
|
-
"@theholocron/checkly-client": "^1.58.0-alpha.
|
|
44
|
+
"@theholocron/cli": "5.0.0-alpha.537",
|
|
45
|
+
"@theholocron/http-client": "^1.58.0-alpha.56",
|
|
46
|
+
"@theholocron/checkly-client": "^1.58.0-alpha.56",
|
|
47
47
|
"@theholocron/misc-utils": "^1.17.0-alpha.5",
|
|
48
48
|
"@theholocron/tsconfig": "^8.9.0-alpha.22"
|
|
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.537"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=22"
|