@theholocron/holocron-plugin-checkly 5.0.0-alpha.275 → 5.0.0-alpha.277
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 +8 -1
- package/dist/index.mjs +36 -3
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthError, Monitoring, MonitoringAlertChannelInput, MonitoringAlertChannelResult, MonitoringCheck, MonitoringCheckInput, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, Monitoring, MonitoringAlertChannelInput, MonitoringAlertChannelResult, MonitoringAlertChannelState, MonitoringCheck, MonitoringCheckInput, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
2
2
|
import { ApiCheck, ApiCheckInput, ApiCheckRequest, Assertion, AssertionComparison, AssertionSource, ChecklyClient, ChecklyClientOptions, HttpMethod, ListChecksParams, createChecklyClient } from "@theholocron/checkly-client";
|
|
3
3
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
4
4
|
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
@@ -49,8 +49,15 @@ export declare class ChecklyMonitoring implements Monitoring {
|
|
|
49
49
|
* and the shortfall reported, with the first failure's reason. Returns how many were added and how many checks now alert.
|
|
50
50
|
*/
|
|
51
51
|
private subscribeMissing;
|
|
52
|
+
/**
|
|
53
|
+
* Read the alert channel named `name` and which of the account's checks it alerts for. Read-only. The URL it posts to
|
|
54
|
+
* is a credential, so only the webhook id inside it is returned, enough to tell which webhook it is.
|
|
55
|
+
*/
|
|
56
|
+
inspectAlertChannel(name: string): Promise<MonitoringAlertChannelState>;
|
|
52
57
|
/** The id of every check on the account, read a page at a time. */
|
|
53
58
|
private allCheckIds;
|
|
59
|
+
/** Every check on the account, read a page at a time. */
|
|
60
|
+
private allChecks;
|
|
54
61
|
/** Checkly's `search` param is a case-insensitive partial match — narrow to the exact name ourselves. */
|
|
55
62
|
private findByExactName;
|
|
56
63
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,8 @@ const COMPARISON_MAP = {
|
|
|
49
49
|
greater_than: "GREATER_THAN",
|
|
50
50
|
less_than: "LESS_THAN"
|
|
51
51
|
};
|
|
52
|
+
/** The id in a Discord webhook URL (`.../api/webhooks/<id>/<token>`): public, unlike the token after it. */
|
|
53
|
+
const DISCORD_WEBHOOK_ID = /\/api(?:\/v\d+)?\/webhooks\/(\d+)\//;
|
|
52
54
|
const SOURCE_FROM_CHECKLY = invert(SOURCE_MAP);
|
|
53
55
|
const COMPARISON_FROM_CHECKLY = invert(COMPARISON_MAP);
|
|
54
56
|
function invert(map) {
|
|
@@ -297,17 +299,48 @@ var ChecklyMonitoring = class {
|
|
|
297
299
|
active: active.size
|
|
298
300
|
};
|
|
299
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Read the alert channel named `name` and which of the account's checks it alerts for. Read-only. The URL it posts to
|
|
304
|
+
* is a credential, so only the webhook id inside it is returned, enough to tell which webhook it is.
|
|
305
|
+
*/
|
|
306
|
+
async inspectAlertChannel(name) {
|
|
307
|
+
const client = this.client();
|
|
308
|
+
const [channels, checks] = await Promise.all([client.alertChannels.list(), this.allChecks()]);
|
|
309
|
+
const listed = channels.find((c) => c.type === "WEBHOOK" && c.config.name === name);
|
|
310
|
+
if (!listed) return {
|
|
311
|
+
exists: false,
|
|
312
|
+
unsubscribed: [],
|
|
313
|
+
deactivated: []
|
|
314
|
+
};
|
|
315
|
+
const channel = await client.alertChannels.get(listed.id);
|
|
316
|
+
const subscribed = new Map(channel.subscriptions.flatMap((s) => s.checkId ? [[s.checkId, s.activated]] : []));
|
|
317
|
+
const webhookId = DISCORD_WEBHOOK_ID.exec(listed.config.url)?.[1];
|
|
318
|
+
return {
|
|
319
|
+
exists: true,
|
|
320
|
+
discord: listed.config.webhookType === "WEBHOOK_DISCORD",
|
|
321
|
+
...webhookId ? { webhookId } : {},
|
|
322
|
+
unsubscribed: checks.filter((c) => !subscribed.has(c.id)).map((c) => c.name),
|
|
323
|
+
deactivated: checks.filter((c) => subscribed.get(c.id) === false).map((c) => c.name)
|
|
324
|
+
};
|
|
325
|
+
}
|
|
300
326
|
/** The id of every check on the account, read a page at a time. */
|
|
301
327
|
async allCheckIds() {
|
|
328
|
+
return (await this.allChecks()).map((c) => c.id);
|
|
329
|
+
}
|
|
330
|
+
/** Every check on the account, read a page at a time. */
|
|
331
|
+
async allChecks() {
|
|
302
332
|
const PAGE = 100;
|
|
303
|
-
const
|
|
333
|
+
const found = [];
|
|
304
334
|
for (let page = 1;; page++) {
|
|
305
335
|
const batch = await this.client().checks.list({
|
|
306
336
|
limit: PAGE,
|
|
307
337
|
page
|
|
308
338
|
});
|
|
309
|
-
|
|
310
|
-
|
|
339
|
+
found.push(...batch.map((c) => ({
|
|
340
|
+
id: c.id,
|
|
341
|
+
name: c.name
|
|
342
|
+
})));
|
|
343
|
+
if (batch.length < PAGE) return found;
|
|
311
344
|
}
|
|
312
345
|
}
|
|
313
346
|
/** Checkly's `search` param is a case-insensitive partial match — narrow to the exact name ourselves. */
|
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.277",
|
|
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",
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"tsx": "4.23.15",
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
40
|
"vitest": "^5.0.5",
|
|
41
|
-
"@theholocron/checkly-client": "^1.58.0-alpha.3",
|
|
42
|
-
"@theholocron/misc-utils": "^1.16.1-alpha.1",
|
|
43
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.3",
|
|
44
41
|
"@theholocron/http-client": "^1.58.0-alpha.3",
|
|
45
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
42
|
+
"@theholocron/cli": "5.0.0-alpha.277",
|
|
43
|
+
"@theholocron/misc-utils": "^1.16.1-alpha.2",
|
|
44
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.3",
|
|
45
|
+
"@theholocron/checkly-client": "^1.58.0-alpha.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@theholocron/checkly-client": "^1.55.0",
|
|
49
49
|
"@theholocron/misc-utils": "^1.16.0",
|
|
50
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
50
|
+
"@theholocron/cli": "5.0.0-alpha.277"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=22"
|