@theholocron/holocron-plugin-checkly 5.0.0-alpha.272 → 5.0.0-alpha.274
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 +2 -0
- package/dist/index.mjs +44 -0
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,8 @@ export declare class ChecklyMonitoring implements Monitoring {
|
|
|
23
23
|
check: MonitoringCheck;
|
|
24
24
|
alreadyExists: boolean;
|
|
25
25
|
}>;
|
|
26
|
+
/** Every API check on the account, read a page at a time. Checks of another type (browser, heartbeat) are left out. */
|
|
27
|
+
listChecks(): Promise<MonitoringCheckInput[]>;
|
|
26
28
|
/**
|
|
27
29
|
* A Discord alert channel: a `WEBHOOK` Checkly formats for Discord. Found by name, so one made by hand is adopted and
|
|
28
30
|
* kept up to date, not duplicated. Every check on the account is subscribed, since a check made through the API is
|
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,37 @@ const COMPARISON_MAP = {
|
|
|
49
49
|
greater_than: "GREATER_THAN",
|
|
50
50
|
less_than: "LESS_THAN"
|
|
51
51
|
};
|
|
52
|
+
const SOURCE_FROM_CHECKLY = invert(SOURCE_MAP);
|
|
53
|
+
const COMPARISON_FROM_CHECKLY = invert(COMPARISON_MAP);
|
|
54
|
+
function invert(map) {
|
|
55
|
+
return Object.fromEntries(Object.entries(map).map(([ours, theirs]) => [theirs, ours]));
|
|
56
|
+
}
|
|
57
|
+
/** What a Checkly API check reads back as, in the shape `checks` declares. Settings Checkly does not return are left out. */
|
|
58
|
+
function fromChecklyCheck(check) {
|
|
59
|
+
const request = check.request;
|
|
60
|
+
const assertions = (request.assertions ?? []).flatMap((a) => {
|
|
61
|
+
const source = SOURCE_FROM_CHECKLY[a.source];
|
|
62
|
+
const comparison = COMPARISON_FROM_CHECKLY[a.comparison];
|
|
63
|
+
if (!source || !comparison) return [];
|
|
64
|
+
return [{
|
|
65
|
+
source,
|
|
66
|
+
comparison,
|
|
67
|
+
...a.property !== void 0 ? { property: a.property } : {},
|
|
68
|
+
...a.target !== void 0 ? { target: a.target } : {}
|
|
69
|
+
}];
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
name: check.name,
|
|
73
|
+
url: request.url,
|
|
74
|
+
method: request.method,
|
|
75
|
+
frequency: check.frequency,
|
|
76
|
+
activated: check.activated,
|
|
77
|
+
shouldFail: check.shouldFail,
|
|
78
|
+
assertions,
|
|
79
|
+
...check.locations ? { locations: check.locations } : {},
|
|
80
|
+
...request.body ? { body: request.body } : {}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
52
83
|
function toChecklyPayload(input) {
|
|
53
84
|
return {
|
|
54
85
|
name: input.name,
|
|
@@ -109,6 +140,19 @@ var ChecklyMonitoring = class {
|
|
|
109
140
|
alreadyExists: false
|
|
110
141
|
};
|
|
111
142
|
}
|
|
143
|
+
/** Every API check on the account, read a page at a time. Checks of another type (browser, heartbeat) are left out. */
|
|
144
|
+
async listChecks() {
|
|
145
|
+
const PAGE = 100;
|
|
146
|
+
const found = [];
|
|
147
|
+
for (let page = 1;; page++) {
|
|
148
|
+
const batch = await this.client().checks.list({
|
|
149
|
+
limit: PAGE,
|
|
150
|
+
page
|
|
151
|
+
});
|
|
152
|
+
found.push(...batch.filter((c) => c.checkType === "API").map(fromChecklyCheck));
|
|
153
|
+
if (batch.length < PAGE) return found;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
112
156
|
/**
|
|
113
157
|
* A Discord alert channel: a `WEBHOOK` Checkly formats for Discord. Found by name, so one made by hand is adopted and
|
|
114
158
|
* kept up to date, not duplicated. Every check on the account is subscribed, since a check made through the API is
|
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.274",
|
|
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/http-client": "^1.58.0-alpha.2",
|
|
42
41
|
"@theholocron/checkly-client": "^1.58.0-alpha.2",
|
|
42
|
+
"@theholocron/cli": "5.0.0-alpha.274",
|
|
43
43
|
"@theholocron/misc-utils": "^1.16.1-alpha.1",
|
|
44
|
-
"@theholocron/
|
|
44
|
+
"@theholocron/http-client": "^1.58.0-alpha.2",
|
|
45
45
|
"@theholocron/tsconfig": "^8.9.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.274"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=22"
|