@theholocron/checkly-client 1.58.0-alpha.3 → 1.58.0-alpha.4
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 +55 -0
- package/dist/index.mjs +1 -0
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "@theholocron/http-client";
|
|
2
2
|
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
+
/** Options for `createChecklyClient`. */
|
|
3
4
|
interface ChecklyClientOptions {
|
|
4
5
|
/** Checkly API key — sent as a Bearer token. */
|
|
5
6
|
token: string;
|
|
@@ -14,29 +15,41 @@ interface ChecklyClientOptions {
|
|
|
14
15
|
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
15
16
|
errors?: ErrorSink;
|
|
16
17
|
}
|
|
18
|
+
/** The kinds of alert channel Checkly supports. */
|
|
17
19
|
type AlertChannelType = "EMAIL" | "SLACK" | "SLACK_APP" | "WEBHOOK" | "SMS" | "PAGERDUTY" | "OPSGENIE" | "CALL";
|
|
20
|
+
/** The HTTP methods a webhook alert channel can use. */
|
|
18
21
|
type WebhookMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
|
|
19
22
|
/**
|
|
20
23
|
* Which service a webhook channel is formatted for. Checkly stores a Discord channel as a plain `WEBHOOK` with this
|
|
21
24
|
* marker and a body template; there is no separate Discord type.
|
|
22
25
|
*/
|
|
23
26
|
type WebhookType = "WEBHOOK_DISCORD" | "WEBHOOK_MSTEAMS" | "WEBHOOK_TELEGRAM" | "WEBHOOK_GITHUB" | "WEBHOOK_SPIKE";
|
|
27
|
+
/** A header or query parameter on a webhook channel. */
|
|
24
28
|
interface WebhookKeyValue {
|
|
29
|
+
/** The header or parameter name. */
|
|
25
30
|
key: string;
|
|
31
|
+
/** The header or parameter value. */
|
|
26
32
|
value: string;
|
|
33
|
+
/** Whether the value is locked. */
|
|
27
34
|
locked?: boolean;
|
|
28
35
|
}
|
|
29
36
|
/** The `config` of a `WEBHOOK` channel, as Checkly returns it. */
|
|
30
37
|
interface WebhookConfig {
|
|
38
|
+
/** The channel's display name. */
|
|
31
39
|
name: string;
|
|
32
40
|
/** Where Checkly posts. For Discord this is a webhook URL and is a secret: anyone holding it can post to the channel. */
|
|
33
41
|
url: string;
|
|
42
|
+
/** The HTTP method Checkly uses when it posts. */
|
|
34
43
|
method: WebhookMethod;
|
|
35
44
|
/** Handlebars body template with Checkly's `{{VARIABLES}}`. */
|
|
36
45
|
template?: string;
|
|
46
|
+
/** Extra headers sent with the request. */
|
|
37
47
|
headers?: WebhookKeyValue[];
|
|
48
|
+
/** Extra query parameters appended to the URL. */
|
|
38
49
|
queryParameters?: WebhookKeyValue[];
|
|
50
|
+
/** The service the webhook is formatted for, when it is not a plain webhook. */
|
|
39
51
|
webhookType?: WebhookType;
|
|
52
|
+
/** A secret Checkly sends with the request so the receiver can recognise it. */
|
|
40
53
|
webhookSecret?: string;
|
|
41
54
|
}
|
|
42
55
|
/** A subscription targets exactly one check or one check group. */
|
|
@@ -74,6 +87,7 @@ type PassThroughChannelBody = {
|
|
|
74
87
|
config: Record<string, unknown>;
|
|
75
88
|
};
|
|
76
89
|
type AlertChannelBody = WebhookChannelBody | PassThroughChannelBody;
|
|
90
|
+
/** What to send to Checkly to create or replace an alert channel: its settings plus its type and `config`. */
|
|
77
91
|
type AlertChannelInput = AlertChannelSettings & AlertChannelBody;
|
|
78
92
|
interface AlertChannelRecord {
|
|
79
93
|
id: number;
|
|
@@ -87,6 +101,7 @@ interface AlertChannelRecord {
|
|
|
87
101
|
created_at: string;
|
|
88
102
|
updated_at: string | null;
|
|
89
103
|
}
|
|
104
|
+
/** An alert channel as Checkly returns it: the stored record plus its type and `config`. */
|
|
90
105
|
type AlertChannel = AlertChannelRecord & AlertChannelBody;
|
|
91
106
|
/**
|
|
92
107
|
* The message body of Checkly's own Discord setup (its AI-analysis section left out, since not every account has it), so
|
|
@@ -98,33 +113,51 @@ export declare const DISCORD_TEMPLATE = "{\n\t\"content\": null,\n\t\"username\"
|
|
|
98
113
|
* no run id, and Checkly may answer 404 for it, so callers wait for `lastCheckRunId` before trusting the flags.
|
|
99
114
|
*/
|
|
100
115
|
interface CheckStatus {
|
|
116
|
+
/** The id of the check this status belongs to. */
|
|
101
117
|
checkId: string;
|
|
118
|
+
/** The check's name. */
|
|
102
119
|
name?: string;
|
|
103
120
|
/** The latest run failed. */
|
|
104
121
|
hasFailures: boolean;
|
|
105
122
|
/** The latest run errored (it could not be carried out), as distinct from failing its assertions. */
|
|
106
123
|
hasErrors?: boolean;
|
|
124
|
+
/** The check is in a degraded state. */
|
|
107
125
|
isDegraded?: boolean;
|
|
108
126
|
/** Null or absent until the check has run. */
|
|
109
127
|
lastCheckRunId?: string | null;
|
|
128
|
+
/** The location the latest run was made from. */
|
|
110
129
|
lastRunLocation?: string | null;
|
|
130
|
+
/** When the status record was created, as an ISO timestamp. */
|
|
111
131
|
created_at?: string;
|
|
132
|
+
/** When the status last changed, as an ISO timestamp, or `null`. */
|
|
112
133
|
updated_at?: string | null;
|
|
113
134
|
}
|
|
135
|
+
/** What an assertion reads from the response. */
|
|
114
136
|
type AssertionSource = "STATUS_CODE" | "JSON_BODY" | "HEADERS" | "TEXT_BODY" | "RESPONSE_TIME";
|
|
137
|
+
/** How an assertion compares the value it reads with its `target`. */
|
|
115
138
|
type AssertionComparison = "EQUALS" | "NOT_EQUALS" | "HAS_KEY" | "NOT_HAS_KEY" | "HAS_VALUE" | "NOT_HAS_VALUE" | "IS_EMPTY" | "NOT_EMPTY" | "GREATER_THAN" | "LESS_THAN" | "CONTAINS" | "NOT_CONTAINS" | "IS_NULL" | "NOT_NULL";
|
|
139
|
+
/** One check on an API response: read `source`, compare it with `target`. */
|
|
116
140
|
interface Assertion {
|
|
141
|
+
/** What part of the response to read. */
|
|
117
142
|
source: AssertionSource;
|
|
143
|
+
/** How to compare the value with `target`. */
|
|
118
144
|
comparison: AssertionComparison;
|
|
119
145
|
/** JSON path / header name the assertion reads — required for JSON_BODY and HEADERS. */
|
|
120
146
|
property?: string;
|
|
147
|
+
/** The value to compare against. */
|
|
121
148
|
target?: string;
|
|
149
|
+
/** A regular expression Checkly applies to the value before comparing. */
|
|
122
150
|
regex?: string;
|
|
123
151
|
}
|
|
152
|
+
/** The HTTP methods an API check can use. */
|
|
124
153
|
type HttpMethod = "GET" | "POST" | "PUT" | "HEAD" | "DELETE" | "PATCH";
|
|
154
|
+
/** The request an API check sends. */
|
|
125
155
|
interface ApiCheckRequest {
|
|
156
|
+
/** The URL to request. */
|
|
126
157
|
url: string;
|
|
158
|
+
/** The HTTP method to use. */
|
|
127
159
|
method: HttpMethod;
|
|
160
|
+
/** Assertions on the response; the check passes when all of them hold. */
|
|
128
161
|
assertions?: Assertion[];
|
|
129
162
|
/**
|
|
130
163
|
* Raw request body to send with the check — e.g. simulating a webhook
|
|
@@ -135,13 +168,17 @@ interface ApiCheckRequest {
|
|
|
135
168
|
*/
|
|
136
169
|
body?: string;
|
|
137
170
|
}
|
|
171
|
+
/** What to send to Checkly to create or update an API check. */
|
|
138
172
|
interface ApiCheckInput {
|
|
173
|
+
/** The check's display name. */
|
|
139
174
|
name: string;
|
|
140
175
|
/** Minutes between runs. One of Checkly's fixed frequency values (0, 1, 2, 5, 10, 15, 30, 60, 120, 180, 360, 720, 1440). Defaults to 10. */
|
|
141
176
|
frequency?: number;
|
|
142
177
|
/** Checkly datacenter region ids (e.g. "us-east-1"). Defaults to the account's configured default. */
|
|
143
178
|
locations?: string[];
|
|
179
|
+
/** Whether the check runs on its schedule. */
|
|
144
180
|
activated?: boolean;
|
|
181
|
+
/** Tags attached to the check. */
|
|
145
182
|
tags?: string[];
|
|
146
183
|
/**
|
|
147
184
|
* Inverts pass/fail: when `true`, a response status >= 400 counts as
|
|
@@ -154,27 +191,44 @@ interface ApiCheckInput {
|
|
|
154
191
|
* to `false`.
|
|
155
192
|
*/
|
|
156
193
|
shouldFail?: boolean;
|
|
194
|
+
/** The request the check sends. */
|
|
157
195
|
request: ApiCheckRequest;
|
|
158
196
|
}
|
|
197
|
+
/** An API check as Checkly returns it. */
|
|
159
198
|
interface ApiCheck {
|
|
199
|
+
/** Checkly's id for the check. */
|
|
160
200
|
id: string;
|
|
201
|
+
/** The check's display name. */
|
|
161
202
|
name: string;
|
|
203
|
+
/** The kind of check; always `"API"` here. */
|
|
162
204
|
checkType: "API";
|
|
205
|
+
/** Whether the check runs on its schedule. */
|
|
163
206
|
activated: boolean;
|
|
207
|
+
/** Minutes between runs. */
|
|
164
208
|
frequency: number;
|
|
209
|
+
/** The regions the check runs from, or `null` when none are set. */
|
|
165
210
|
locations: string[] | null;
|
|
211
|
+
/** Tags attached to the check. */
|
|
166
212
|
tags: string[];
|
|
213
|
+
/** Whether a status of 400 or above counts as passing. */
|
|
167
214
|
shouldFail: boolean;
|
|
215
|
+
/** The request the check sends. */
|
|
168
216
|
request: ApiCheckRequest;
|
|
217
|
+
/** When the check was created, as an ISO timestamp. */
|
|
169
218
|
created_at: string;
|
|
219
|
+
/** When the check was last updated, as an ISO timestamp, or `null`. */
|
|
170
220
|
updated_at: string | null;
|
|
171
221
|
}
|
|
222
|
+
/** Options for listing checks. */
|
|
172
223
|
interface ListChecksParams {
|
|
173
224
|
/** Case-insensitive partial match on the check name. */
|
|
174
225
|
search?: string;
|
|
226
|
+
/** The maximum number of checks per page. */
|
|
175
227
|
limit?: number;
|
|
228
|
+
/** The page to fetch. */
|
|
176
229
|
page?: number;
|
|
177
230
|
}
|
|
231
|
+
/** Creates a Checkly client with `alertChannels`, `checkStatuses` and `checks` groups sharing one REST client. */
|
|
178
232
|
export declare function createChecklyClient(opts: ChecklyClientOptions): {
|
|
179
233
|
alertChannels: {
|
|
180
234
|
list: () => Promise<AlertChannel[]>;
|
|
@@ -195,5 +249,6 @@ export declare function createChecklyClient(opts: ChecklyClientOptions): {
|
|
|
195
249
|
delete: (id: string) => Promise<void>;
|
|
196
250
|
};
|
|
197
251
|
};
|
|
252
|
+
/** The client `createChecklyClient` returns. */
|
|
198
253
|
export type ChecklyClient = ReturnType<typeof createChecklyClient>;
|
|
199
254
|
export type { AlertChannel, AlertChannelInput, AlertChannelSubscription, AlertChannelType, ApiCheck, ApiCheckInput, ApiCheckRequest, Assertion, AssertionComparison, AssertionSource, CheckStatus, ChecklyClientOptions, HttpMethod, ListChecksParams, WebhookConfig, WebhookKeyValue, WebhookMethod, WebhookType };
|
package/dist/index.mjs
CHANGED
|
@@ -167,6 +167,7 @@ function createChecklyRestClient(opts) {
|
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
// src/index.ts
|
|
170
|
+
/** Creates a Checkly client with `alertChannels`, `checkStatuses` and `checks` groups sharing one REST client. */
|
|
170
171
|
function createChecklyClient(opts) {
|
|
171
172
|
const rest = createChecklyRestClient(opts);
|
|
172
173
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/checkly-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.4",
|
|
4
4
|
"description": "A TypeScript client for the Checkly monitoring API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checkly",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@theholocron/
|
|
37
|
-
"@theholocron/
|
|
36
|
+
"@theholocron/http-client": "^1.58.0-alpha.4",
|
|
37
|
+
"@theholocron/observability": "^0.6.1-alpha.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^26",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"tsdown": "^0.23.3",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vitest": "^5.0.5",
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/
|
|
51
|
-
"@theholocron/
|
|
52
|
-
"@theholocron/
|
|
49
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.5",
|
|
50
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.5",
|
|
51
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.5",
|
|
52
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.5"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=22.0.0"
|