@theholocron/checkly-client 1.40.0 → 1.42.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
@@ -21,11 +21,16 @@ const checkly = createChecklyClient({
21
21
  // Find an existing check by name (case-insensitive partial match)
22
22
  const existing = await checkly.checks.list({ search: "sentinel webhook" });
23
23
 
24
- // Create an API check
24
+ // Create an API check. shouldFail: true is required whenever the
25
+ // "healthy" response is itself an HTTP error status (here, a 405) --
26
+ // without it, Checkly's platform-level retry/failure classification
27
+ // treats any 4xx/5xx as a failure before your assertions are even
28
+ // evaluated, regardless of whether they match.
25
29
  const check = await checkly.checks.create({
26
30
  name: "Sentinel webhook uptime",
27
31
  frequency: 5,
28
32
  locations: ["us-east-1"],
33
+ shouldFail: true,
29
34
  request: {
30
35
  url: "https://sentinel.theholocron.dev/api/webhook",
31
36
  method: "GET",
@@ -40,6 +45,22 @@ await checkly.checks.update(check.id, {
40
45
  request: check.request,
41
46
  });
42
47
 
48
+ // A second check with a request body -- e.g. to verify the endpoint's own
49
+ // signature checking, not just that it's reachable. request.body is sent
50
+ // as-is; the client sets Checkly's own bodyType to "RAW" whenever a body
51
+ // is given.
52
+ const signatureCheck = await checkly.checks.create({
53
+ name: "Sentinel webhook signature verification",
54
+ locations: ["us-east-1"],
55
+ shouldFail: true,
56
+ request: {
57
+ url: "https://sentinel.theholocron.dev/api/webhook",
58
+ method: "POST",
59
+ body: "{}",
60
+ assertions: [{ source: "STATUS_CODE", comparison: "EQUALS", target: "401" }],
61
+ },
62
+ });
63
+
43
64
  // Delete it
44
65
  await checkly.checks.delete(check.id);
45
66
  ```
package/dist/index.d.mts CHANGED
@@ -32,6 +32,14 @@ interface ApiCheckRequest {
32
32
  url: string;
33
33
  method: HttpMethod;
34
34
  assertions?: Assertion[];
35
+ /**
36
+ * Raw request body to send with the check — e.g. simulating a webhook
37
+ * delivery to verify signature checking is wired correctly end-to-end,
38
+ * as opposed to just the endpoint being reachable. Omitted entirely by
39
+ * default, leaving Checkly's own `bodyType` at `"NONE"`; `create()`/
40
+ * `update()` set it to `"RAW"` whenever a body is given.
41
+ */
42
+ body?: string;
35
43
  }
36
44
  interface ApiCheckInput {
37
45
  name: string;
@@ -41,6 +49,17 @@ interface ApiCheckInput {
41
49
  locations?: string[];
42
50
  activated?: boolean;
43
51
  tags?: string[];
52
+ /**
53
+ * Inverts pass/fail: when `true`, a response status >= 400 counts as
54
+ * passing (and a < 400 status fails) *before* assertions are even
55
+ * evaluated. Required for any check whose "healthy" response is
56
+ * itself an HTTP error status (e.g. asserting a 404/405 on an
57
+ * endpoint that should reject certain requests) — without it,
58
+ * Checkly's platform-level retry/failure classification treats any
59
+ * 4xx/5xx as a failure regardless of matching assertions. Defaults
60
+ * to `false`.
61
+ */
62
+ shouldFail?: boolean;
44
63
  request: ApiCheckRequest;
45
64
  }
46
65
  interface ApiCheck {
@@ -51,6 +70,7 @@ interface ApiCheck {
51
70
  frequency: number;
52
71
  locations: string[] | null;
53
72
  tags: string[];
73
+ shouldFail: boolean;
54
74
  request: ApiCheckRequest;
55
75
  created_at: string;
56
76
  updated_at: string | null;
package/dist/index.mjs CHANGED
@@ -1,5 +1,24 @@
1
1
  import { createRestClient } from "@theholocron/http-client";
2
2
  //#region ../../../../../src/checks/checks.ts
3
+ /**
4
+ * `ApiCheckInput.request.body` is holocron's simplified shape (just the raw
5
+ * string); Checkly's wire format pairs it with a `bodyType` discriminator.
6
+ * `"RAW"` whenever a body is given — the only body shape this client
7
+ * exposes today — otherwise left unset, so Checkly's own `"NONE"` default
8
+ * stands.
9
+ */
10
+ function toWirePayload(input) {
11
+ return {
12
+ ...input,
13
+ request: {
14
+ ...input.request,
15
+ ...input.request.body !== void 0 ? {
16
+ body: input.request.body,
17
+ bodyType: "RAW"
18
+ } : {}
19
+ }
20
+ };
21
+ }
3
22
  function checks(rest) {
4
23
  return {
5
24
  /** List checks, optionally filtered by a case-insensitive partial name match. */
@@ -13,12 +32,12 @@ function checks(rest) {
13
32
  /** Create a new API check. */
14
33
  create: (input) => rest.request("/checks/api", {
15
34
  method: "POST",
16
- body: input
35
+ body: toWirePayload(input)
17
36
  }),
18
37
  /** Update an existing API check. */
19
38
  update: (id, input) => rest.request(`/checks/api/${id}`, {
20
39
  method: "PUT",
21
- body: input
40
+ body: toWirePayload(input)
22
41
  }),
23
42
  /** Delete a check (any type) by id. */
24
43
  delete: (id) => rest.request(`/checks/${id}`, { method: "DELETE" })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/checkly-client",
3
- "version": "1.40.0",
3
+ "version": "1.42.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.40.0"
37
+ "@theholocron/http-client": "^1.42.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@theholocron/cli": "5.0.0-alpha.79",