@theholocron/checkly-client 1.52.0 → 1.53.1

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
@@ -96,17 +96,23 @@ const channel = await checkly.alertChannels.create({
96
96
  sendFailure: true,
97
97
  sendRecovery: true,
98
98
  sendDegraded: true,
99
- // Checks made through the API are never auto-subscribed: list each one.
100
- subscriptions: [{ checkId: check.id, activated: true }],
101
99
  });
102
100
 
101
+ // Checks made through the API are never auto-subscribed. Subscribe each one with `subscribe`, then read the channel
102
+ // back: Checkly's create and update accept a `subscriptions` list but have been seen not to apply it.
103
+ await checkly.alertChannels.subscribe(channel.id, {
104
+ checkId: check.id,
105
+ activated: true,
106
+ });
107
+ const subscribed = (await checkly.alertChannels.get(channel.id)).subscriptions;
108
+
103
109
  const all = await checkly.alertChannels.list(); // every page
104
110
  const one = await checkly.alertChannels.get(channel.id);
105
111
  await checkly.alertChannels.update(channel.id, {/* the complete channel */});
106
112
  await checkly.alertChannels.delete(channel.id);
107
113
  ```
108
114
 
109
- `update` replaces the whole channel (settings and subscriptions), so send everything you want to keep. Checkly offers
115
+ `update` replaces the whole channel (settings and subscriptions), so send everything you want to keep, and re-read the channel before updating it if anything may have subscribed a check since you last did. Checkly offers
110
116
  no version check, so do not update one channel from two places at once.
111
117
 
112
118
  > **Note:** This client covers API checks (`checks.*`) and alert channels (`alertChannels.*`) — the subset this org
package/dist/index.d.mts CHANGED
@@ -173,6 +173,7 @@ declare function createChecklyClient(opts: ChecklyClientOptions): {
173
173
  get: (id: number) => Promise<AlertChannel>;
174
174
  create: (input: AlertChannelInput) => Promise<AlertChannel>;
175
175
  update: (id: number, input: AlertChannelInput) => Promise<AlertChannel>;
176
+ subscribe: (id: number, subscription: AlertChannelSubscription) => Promise<AlertChannelSubscription>;
176
177
  delete: (id: number) => Promise<void>;
177
178
  };
178
179
  checks: {
package/dist/index.mjs CHANGED
@@ -90,6 +90,15 @@ function alertChannels(rest) {
90
90
  method: "PUT",
91
91
  body: { ...input }
92
92
  }),
93
+ /**
94
+ * Subscribe one check (or group) to a channel, or switch that subscription on or off. This is the call that makes
95
+ * a subscription take effect: Checkly's create and update accept a `subscriptions` list but have been seen not to
96
+ * apply it, so read the channel back after writing it and use this for whatever is missing.
97
+ */
98
+ subscribe: (id, subscription) => rest.request(`/alert-channels/${id}/subscriptions`, {
99
+ method: "PUT",
100
+ body: { ...subscription }
101
+ }),
93
102
  delete: (id) => rest.request(`/alert-channels/${id}`, { method: "DELETE" })
94
103
  };
95
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/checkly-client",
3
- "version": "1.52.0",
3
+ "version": "1.53.1",
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.52.0"
37
+ "@theholocron/http-client": "^1.53.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@theholocron/cli": "5.0.0-alpha.79",