@theholocron/checkly-client 1.54.2 → 1.56.0

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 CHANGED
@@ -65,6 +65,14 @@ const signatureCheck = await checkly.checks.create({
65
65
  await checkly.checks.delete(check.id);
66
66
  ```
67
67
 
68
+ ## Check status
69
+
70
+ ```ts
71
+ // Has the latest run failed? A check that has not run yet has no status (404) or no `lastCheckRunId`.
72
+ const status = await checkly.checkStatuses.get(check.id);
73
+ if (status.lastCheckRunId && status.hasFailures) console.log("failing");
74
+ ```
75
+
68
76
  ## Auth
69
77
 
70
78
  Generate an [API key](https://www.checklyhq.com/docs/accounts-and-users/creating-api-key/)
package/dist/index.d.mts CHANGED
@@ -100,6 +100,26 @@ type AlertChannel = AlertChannelRecord & ({
100
100
  */
101
101
  declare const DISCORD_TEMPLATE = "{\n\t\"content\": null,\n\t\"username\": \"Checkly\",\n\t\"avatar_url\": \"https://s3.eu-central-1.amazonaws.com/cdn.checklyhq.com/slack/checkly-slack-icon.png\",\n\t{{! Embeds for the SSL expiry notifications}}\n\t{{#eq ALERT_TYPE \"ALERT_SSL\" }}\n\t\"embeds\": [\n\t\t{\n\t\t\t\"title\": \"{{ALERT_TITLE}}\",\n\t\t\t\"url\": \"{{RESULT_LINK}}\",\n\t\t\t\"color\": 16762924\n\t\t}\n\t]\n\t{{else}}\n\t{{! Embeds for the standard failure, recovery and degraded notifications}}\n\t\"embeds\": [\n\t\t{\n\t\t\t\"title\": \"{{ALERT_TITLE}}\",\n\t\t\t\"url\": \"{{RESULT_LINK}}\",\n\t\t\t{{! Green for a recovery, red for a failure, amber for anything degraded}}\n\t\t\t\"color\": {{#eq ALERT_TYPE \"ALERT_RECOVERY\"}}3187820{{else}}{{#eq ALERT_TYPE \"ALERT_DEGRADED_RECOVERY\"}}3187820{{else}}{{#eq ALERT_TYPE \"ALERT_FAILURE\"}}15033421{{else}}16098596{{/eq}}{{/eq}}{{/eq}},\n\t\t\t\"fields\": [\n\t\t\t\t{{#eq CHECK_TYPE \"API\" }}\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Status code\",\n\t\t\t\t\t\"value\": \"{{API_CHECK_RESPONSE_STATUS_CODE}}\"\n\t\t\t\t},\n\t\t\t\t{{/eq}}\n\t\t\t\t{{#if GROUP_NAME}}\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Group\",\n\t\t\t\t\t\"value\": \"{{GROUP_NAME}}\"\n\t\t\t\t},\n\t\t\t\t{{/if}}\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Response Time\",\n\t\t\t\t\t\"value\": \"{{RESPONSE_TIME}}ms\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Location\",\n\t\t\t\t\t\"value\": \"{{RUN_LOCATION}}\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Tags\",\n\t\t\t\t\t\"value\": \"[{{#each TAGS}} {{this}} {{#unless @last}},{{/unless}} {{/each}}]\"\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"timestamp\": \"{{STARTED_AT}}\"\n\t\t}\n\t]\n\t{{/eq}}\n}\n";
102
102
  //#endregion
103
+ //#region ../../../../../src/check-statuses/check-statuses.d.ts
104
+ /**
105
+ * Where a check stands after its latest run, from `GET /v1/check-statuses/{checkId}`. A check that has not run yet has
106
+ * no run id, and Checkly may answer 404 for it, so callers wait for `lastCheckRunId` before trusting the flags.
107
+ */
108
+ interface CheckStatus {
109
+ checkId: string;
110
+ name?: string;
111
+ /** The latest run failed. */
112
+ hasFailures: boolean;
113
+ /** The latest run errored (it could not be carried out), as distinct from failing its assertions. */
114
+ hasErrors?: boolean;
115
+ isDegraded?: boolean;
116
+ /** Null or absent until the check has run. */
117
+ lastCheckRunId?: string | null;
118
+ lastRunLocation?: string | null;
119
+ created_at?: string;
120
+ updated_at?: string | null;
121
+ }
122
+ //#endregion
103
123
  //#region ../../../../../src/checks/checks.d.ts
104
124
  type AssertionSource = "STATUS_CODE" | "JSON_BODY" | "HEADERS" | "TEXT_BODY" | "RESPONSE_TIME";
105
125
  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";
@@ -176,6 +196,9 @@ declare function createChecklyClient(opts: ChecklyClientOptions): {
176
196
  subscribe: (id: number, subscription: AlertChannelSubscription) => Promise<AlertChannelSubscription>;
177
197
  delete: (id: number) => Promise<void>;
178
198
  };
199
+ checkStatuses: {
200
+ get: (checkId: string) => Promise<CheckStatus>;
201
+ };
179
202
  checks: {
180
203
  list: (params?: ListChecksParams) => Promise<ApiCheck[]>;
181
204
  get: (id: string) => Promise<ApiCheck>;
@@ -186,4 +209,4 @@ declare function createChecklyClient(opts: ChecklyClientOptions): {
186
209
  };
187
210
  type ChecklyClient = ReturnType<typeof createChecklyClient>;
188
211
  //#endregion
189
- export { type AlertChannel, type AlertChannelInput, type AlertChannelSubscription, type AlertChannelType, type ApiCheck, type ApiCheckInput, type ApiCheckRequest, type Assertion, type AssertionComparison, type AssertionSource, ChecklyClient, type ChecklyClientOptions, DISCORD_TEMPLATE, type HttpMethod, type ListChecksParams, type WebhookConfig, type WebhookKeyValue, type WebhookMethod, type WebhookType, createChecklyClient };
212
+ export { type AlertChannel, type AlertChannelInput, type AlertChannelSubscription, type AlertChannelType, type ApiCheck, type ApiCheckInput, type ApiCheckRequest, type Assertion, type AssertionComparison, type AssertionSource, type CheckStatus, ChecklyClient, type ChecklyClientOptions, DISCORD_TEMPLATE, type HttpMethod, type ListChecksParams, type WebhookConfig, type WebhookKeyValue, type WebhookMethod, type WebhookType, createChecklyClient };
package/dist/index.mjs CHANGED
@@ -105,6 +105,13 @@ function alertChannels(rest) {
105
105
  };
106
106
  }
107
107
  //#endregion
108
+ //#region ../../../../../src/check-statuses/check-statuses.ts
109
+ function checkStatuses(rest) {
110
+ return {
111
+ /** The latest status of one check. Throws ProviderApiError 404 if Checkly has none yet (the check has not run). */
112
+ get: (checkId) => rest.request(`/check-statuses/${encodeURIComponent(checkId)}`) };
113
+ }
114
+ //#endregion
108
115
  //#region ../../../../../src/checks/checks.ts
109
116
  /**
110
117
  * `ApiCheckInput.request.body` is holocron's simplified shape (just the raw
@@ -168,6 +175,7 @@ function createChecklyClient(opts) {
168
175
  const rest = createChecklyRestClient(opts);
169
176
  return {
170
177
  alertChannels: alertChannels(rest),
178
+ checkStatuses: checkStatuses(rest),
171
179
  checks: checks(rest)
172
180
  };
173
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/checkly-client",
3
- "version": "1.54.2",
3
+ "version": "1.56.0",
4
4
  "description": "A TypeScript client for the Checkly monitoring API",
5
5
  "keywords": [
6
6
  "checkly",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@theholocron/observability": "^0.3.0",
37
- "@theholocron/http-client": "^1.54.2"
37
+ "@theholocron/http-client": "^1.56.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@theholocron/cli": "5.0.0-alpha.79",