activitysmith 1.0.0 → 1.2.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
@@ -6,6 +6,24 @@ The ActivitySmith Node SDK provides convenient access to the ActivitySmith API f
6
6
 
7
7
  See [API reference](https://activitysmith.com/docs/api-reference/introduction)
8
8
 
9
+ ## Table of Contents
10
+
11
+ - [Installation](#installation)
12
+ - [Setup](#setup)
13
+ - [Push Notifications](#push-notifications)
14
+ - [Send a Push Notification](#send-a-push-notification)
15
+ - [Rich Push Notifications with Media](#rich-push-notifications-with-media)
16
+ - [Actionable Push Notifications](#actionable-push-notifications)
17
+ - [Live Activities](#live-activities)
18
+ - [Simple: Let ActivitySmith manage the Live Activity for you](#simple-let-activitysmith-manage-the-live-activity-for-you)
19
+ - [Advanced: Full lifecycle control](#advanced-full-lifecycle-control)
20
+ - [Metrics Type](#metrics-type)
21
+ - [Segmented Progress Type](#segmented-progress-type)
22
+ - [Progress Type](#progress-type)
23
+ - [Live Activity Action](#live-activity-action)
24
+ - [Channels](#channels)
25
+ - [Widgets](#widgets)
26
+
9
27
  ## Installation
10
28
 
11
29
  ```sh
@@ -111,25 +129,203 @@ await activitysmith.notifications.send({
111
129
 
112
130
  ## Live Activities
113
131
 
114
- Live Activities come in two UI types, but the lifecycle stays the same:
115
- start the activity, keep the returned `activity_id`, update it as state
116
- changes, then end it when the work is done.
132
+ <p align="center">
133
+ <img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Metrics Live Activity screenshot" width="680" />
134
+ </p>
135
+
136
+ There are three types of Live Activities:
137
+
138
+ - `metrics`: best for live operational stats like server CPU and memory, queue depth, or replica lag
139
+ - `segmented_progress`: best for step-based workflows like deployments, backups, and ETL pipelines
140
+ - `progress`: best for continuous jobs like uploads, reindexes, and long-running migrations tracked as a percentage
141
+
142
+ When working with Live Activities via our API, you have two approaches tailored to different needs. First, the stateless mode is the simplest path - one API call can initiate or update an activity, and another ends it - no state tracking on your side.
143
+
144
+ This is ideal if you want minimal complexity, perfect for automated workflows like cron jobs.
145
+
146
+ In contrast, if you need precise lifecycle control, the classic approach offers distinct calls for start, updates, and end, giving you full control over the activity's state.
147
+
148
+ In the following sections, we'll break down how to implement each method so you can choose what fits your use case best.
149
+
150
+ ### Simple: Let ActivitySmith manage the Live Activity for you
151
+
152
+ Use a stable `streamKey` to identify the system or workflow you are tracking,
153
+ such as a server, deployment, or build pipeline.
154
+ This is especially useful for cron jobs and other scheduled tasks where you do
155
+ not want to store `activity_id` between runs.
156
+
157
+ #### Metrics
158
+
159
+ <p align="center">
160
+ <img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics stream example" width="680" />
161
+ </p>
162
+
163
+ ```ts
164
+ const status = await activitysmith.liveActivities.stream("prod-web-1", {
165
+ content_state: {
166
+ title: "Server Health",
167
+ subtitle: "prod-web-1",
168
+ type: "metrics",
169
+ metrics: [
170
+ { label: "CPU", value: 9, unit: "%" },
171
+ { label: "MEM", value: 45, unit: "%" },
172
+ ],
173
+ },
174
+ });
175
+ ```
176
+
177
+ #### Segmented progress
178
+
179
+ <p align="center">
180
+ <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented progress stream example" width="680" />
181
+ </p>
182
+
183
+ ```ts
184
+ await activitysmith.liveActivities.stream("nightly-backup", {
185
+ content_state: {
186
+ title: "Nightly Backup",
187
+ subtitle: "upload archive",
188
+ type: "segmented_progress",
189
+ number_of_steps: 3,
190
+ current_step: 2,
191
+ },
192
+ });
193
+ ```
194
+
195
+ #### Progress
117
196
 
118
- - `segmented_progress`: best for jobs tracked in steps
119
- - `progress`: best for jobs tracked as a percentage or numeric range
197
+ <p align="center">
198
+ <img src="https://cdn.activitysmith.com/features/progress-live-activity.png" alt="Progress stream example" width="680" />
199
+ </p>
120
200
 
121
- ### Shared flow
201
+ ```ts
202
+ await activitysmith.liveActivities.stream("search-reindex", {
203
+ content_state: {
204
+ title: "Search Reindex",
205
+ subtitle: "catalog-v2",
206
+ type: "progress",
207
+ percentage: 42,
208
+ },
209
+ });
210
+ ```
211
+
212
+ Call `stream(...)` again with the same `streamKey` whenever the state changes.
213
+
214
+ #### End a stream
215
+
216
+ Use this when the tracked process is finished and you no longer want the Live
217
+ Activity on devices. `content_state` is optional here; include it if you want
218
+ to end the stream with a final state.
219
+
220
+ ```ts
221
+ await activitysmith.liveActivities.endStream("prod-web-1", {
222
+ content_state: {
223
+ title: "Server Health",
224
+ subtitle: "prod-web-1",
225
+ type: "metrics",
226
+ metrics: [
227
+ { label: "CPU", value: 7, unit: "%" },
228
+ { label: "MEM", value: 38, unit: "%" },
229
+ ],
230
+ },
231
+ });
232
+ ```
233
+
234
+ If you later send another `stream(...)` request with the same `streamKey`,
235
+ ActivitySmith starts a new Live Activity for that stream again.
236
+
237
+ Stream responses include an `operation` field:
238
+
239
+ - `started`: ActivitySmith started a new Live Activity for this `streamKey`
240
+ - `updated`: ActivitySmith updated the current Live Activity
241
+ - `rotated`: ActivitySmith ended the previous Live Activity and started a new one
242
+ - `noop`: the incoming state matched the current state, so no update was sent
243
+ - `paused`: the stream is paused, so no Live Activity was started or updated
244
+ - `ended`: returned by `endStream(...)` after the stream is ended
245
+
246
+ ### Advanced: Full lifecycle control
247
+
248
+ Use these methods when you want to manage the Live Activity lifecycle yourself:
122
249
 
123
250
  1. Call `activitysmith.liveActivities.start(...)`.
124
251
  2. Save the returned `activity_id`.
125
252
  3. Call `activitysmith.liveActivities.update(...)` as progress changes.
126
253
  4. Call `activitysmith.liveActivities.end(...)` when the work is finished.
127
254
 
255
+ ### Metrics Type
256
+
257
+ Use `metrics` when you want to keep a small set of live stats visible, such as
258
+ server health, queue pressure, or database load.
259
+
260
+ #### Start
261
+
262
+ <p align="center">
263
+ <img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics start example" width="680" />
264
+ </p>
265
+
266
+ ```ts
267
+ const start = await activitysmith.liveActivities.start({
268
+ content_state: {
269
+ title: "Server Health",
270
+ subtitle: "prod-web-1",
271
+ type: "metrics",
272
+ metrics: [
273
+ { label: "CPU", value: 9, unit: "%" },
274
+ { label: "MEM", value: 45, unit: "%" },
275
+ ],
276
+ },
277
+ });
278
+
279
+ const activityId = start.activity_id;
280
+ ```
281
+
282
+ #### Update
283
+
284
+ <p align="center">
285
+ <img src="https://cdn.activitysmith.com/features/metrics-live-activity-update.png" alt="Metrics update example" width="680" />
286
+ </p>
287
+
288
+ ```ts
289
+ await activitysmith.liveActivities.update({
290
+ activity_id: activityId,
291
+ content_state: {
292
+ title: "Server Health",
293
+ subtitle: "prod-web-1",
294
+ type: "metrics",
295
+ metrics: [
296
+ { label: "CPU", value: 76, unit: "%" },
297
+ { label: "MEM", value: 52, unit: "%" },
298
+ ],
299
+ },
300
+ });
301
+ ```
302
+
303
+ #### End
304
+
305
+ <p align="center">
306
+ <img src="https://cdn.activitysmith.com/features/metrics-live-activity-end.png" alt="Metrics end example" width="680" />
307
+ </p>
308
+
309
+ ```ts
310
+ await activitysmith.liveActivities.end({
311
+ activity_id: activityId,
312
+ content_state: {
313
+ title: "Server Health",
314
+ subtitle: "prod-web-1",
315
+ type: "metrics",
316
+ metrics: [
317
+ { label: "CPU", value: 7, unit: "%" },
318
+ { label: "MEM", value: 38, unit: "%" },
319
+ ],
320
+ auto_dismiss_minutes: 2,
321
+ },
322
+ });
323
+ ```
324
+
128
325
  ### Segmented Progress Type
129
326
 
130
- Use `segmented_progress` when progress is easier to follow as steps instead of a
131
- raw percentage. It fits jobs like backups, deployments, ETL pipelines, and
132
- checklists where "step 2 of 3" is more useful than "67%".
327
+ Use `segmented_progress` for jobs and workflows that move through clear steps or
328
+ phases. It fits jobs like backups, deployments, ETL pipelines, and checklists.
133
329
  `number_of_steps` is dynamic, so you can increase or decrease it later if the
134
330
  workflow changes.
135
331
 
@@ -149,7 +345,6 @@ const start = await activitysmith.liveActivities.start({
149
345
  type: "segmented_progress",
150
346
  color: "yellow",
151
347
  },
152
- channels: ["devs", "ops"], // Optional
153
348
  });
154
349
 
155
350
  const activityId = start.activity_id;
@@ -167,7 +362,7 @@ await activitysmith.liveActivities.update({
167
362
  content_state: {
168
363
  title: "Nightly database backup",
169
364
  subtitle: "upload archive",
170
- number_of_steps: 4,
365
+ number_of_steps: 3,
171
366
  current_step: 2,
172
367
  },
173
368
  });
@@ -185,8 +380,8 @@ await activitysmith.liveActivities.end({
185
380
  content_state: {
186
381
  title: "Nightly database backup",
187
382
  subtitle: "verify restore",
188
- number_of_steps: 4,
189
- current_step: 4,
383
+ number_of_steps: 3,
384
+ current_step: 3,
190
385
  auto_dismiss_minutes: 2,
191
386
  },
192
387
  });
@@ -257,25 +452,27 @@ await activitysmith.liveActivities.end({
257
452
 
258
453
  Just like Actionable Push Notifications, Live Activities can have a button that opens provided URL in a browser or triggers a webhook. Webhooks are executed by the ActivitySmith backend.
259
454
 
455
+ #### Open URL action
456
+
260
457
  <p align="center">
261
- <img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action" width="680" />
458
+ <img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Metrics Live Activity with action" width="680" />
262
459
  </p>
263
460
 
264
- #### Open URL action
265
-
266
461
  ```ts
267
462
  const start = await activitysmith.liveActivities.start({
268
463
  content_state: {
269
- title: "Deploying payments-api",
270
- subtitle: "Running database migrations",
271
- number_of_steps: 5,
272
- current_step: 3,
273
- type: "segmented_progress",
464
+ title: "Server Health",
465
+ subtitle: "prod-web-1",
466
+ type: "metrics",
467
+ metrics: [
468
+ { label: "CPU", value: 76, unit: "%" },
469
+ { label: "MEM", value: 52, unit: "%" },
470
+ ],
274
471
  },
275
472
  action: {
276
- title: "Open Workflow",
473
+ title: "Open Dashboard",
277
474
  type: "open_url",
278
- url: "https://github.com/acme/payments-api/actions/runs/1234567890",
475
+ url: "https://ops.example.com/servers/prod-web-1",
279
476
  },
280
477
  });
281
478
 
@@ -284,6 +481,10 @@ const activityId = start.activity_id;
284
481
 
285
482
  #### Webhook action
286
483
 
484
+ <p align="center">
485
+ <img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action" width="680" />
486
+ </p>
487
+
287
488
  ```ts
288
489
  await activitysmith.liveActivities.update({
289
490
  activity_id: activityId,
@@ -318,6 +519,30 @@ await activitysmith.notifications.send({
318
519
  });
319
520
  ```
320
521
 
522
+ ## Widgets
523
+
524
+ <p align="center">
525
+ <img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
526
+ </p>
527
+
528
+ ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Create a metric in the web app, then update the metric value using our API, add a widget to your lock screen and it will fetch the latest update automatically.
529
+
530
+ <p align="center">
531
+ <img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
532
+ </p>
533
+
534
+ Use the metric key to update its value.
535
+
536
+ ```ts
537
+ await activitysmith.metrics.update("deploy.success_rate", 99.9);
538
+ ```
539
+
540
+ String metric values work too.
541
+
542
+ ```ts
543
+ await activitysmith.metrics.update("prod.status", "healthy");
544
+ ```
545
+
321
546
  ## Error Handling
322
547
 
323
548
  ```ts
@@ -10,10 +10,18 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import * as runtime from '../runtime';
13
- import type { LiveActivityEndRequest, LiveActivityEndResponse, LiveActivityStartRequest, LiveActivityStartResponse, LiveActivityUpdateRequest, LiveActivityUpdateResponse } from '../models/index';
13
+ import type { LiveActivityEndRequest, LiveActivityEndResponse, LiveActivityStartRequest, LiveActivityStartResponse, LiveActivityStreamDeleteRequest, LiveActivityStreamDeleteResponse, LiveActivityStreamPutResponse, LiveActivityStreamRequest, LiveActivityUpdateRequest, LiveActivityUpdateResponse } from '../models/index';
14
14
  export interface EndLiveActivityRequest {
15
15
  liveActivityEndRequest: LiveActivityEndRequest;
16
16
  }
17
+ export interface EndLiveActivityStreamRequest {
18
+ streamKey: string;
19
+ liveActivityStreamDeleteRequest?: LiveActivityStreamDeleteRequest;
20
+ }
21
+ export interface ReconcileLiveActivityStreamRequest {
22
+ streamKey: string;
23
+ liveActivityStreamRequest: LiveActivityStreamRequest;
24
+ }
17
25
  export interface StartLiveActivityRequest {
18
26
  liveActivityStartRequest: LiveActivityStartRequest;
19
27
  }
@@ -25,32 +33,52 @@ export interface UpdateLiveActivityRequest {
25
33
  */
26
34
  export declare class LiveActivitiesApi extends runtime.BaseAPI {
27
35
  /**
28
- * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
36
+ * Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
29
37
  * End a Live Activity
30
38
  */
31
39
  endLiveActivityRaw(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityEndResponse>>;
32
40
  /**
33
- * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
41
+ * Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
34
42
  * End a Live Activity
35
43
  */
36
44
  endLiveActivity(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityEndResponse>;
37
45
  /**
38
- * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
46
+ * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
47
+ * End a stream
48
+ */
49
+ endLiveActivityStreamRaw(requestParameters: EndLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityStreamDeleteResponse>>;
50
+ /**
51
+ * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
52
+ * End a stream
53
+ */
54
+ endLiveActivityStream(requestParameters: EndLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStreamDeleteResponse>;
55
+ /**
56
+ * Use this endpoint when you want the easiest, stateless way to trigger Live Activities. You do not need to store activity_id or manage the Live Activity lifecycle yourself. Send the latest state for a stable stream_key and ActivitySmith will handle the rest for you: if there is no Live Activity yet, it starts one; if there is already one for this stream, it updates it. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
57
+ * Send a stream update
58
+ */
59
+ reconcileLiveActivityStreamRaw(requestParameters: ReconcileLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityStreamPutResponse>>;
60
+ /**
61
+ * Use this endpoint when you want the easiest, stateless way to trigger Live Activities. You do not need to store activity_id or manage the Live Activity lifecycle yourself. Send the latest state for a stable stream_key and ActivitySmith will handle the rest for you: if there is no Live Activity yet, it starts one; if there is already one for this stream, it updates it. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
62
+ * Send a stream update
63
+ */
64
+ reconcileLiveActivityStream(requestParameters: ReconcileLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStreamPutResponse>;
65
+ /**
66
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
39
67
  * Start a Live Activity
40
68
  */
41
69
  startLiveActivityRaw(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityStartResponse>>;
42
70
  /**
43
- * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
71
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
44
72
  * Start a Live Activity
45
73
  */
46
74
  startLiveActivity(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStartResponse>;
47
75
  /**
48
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
76
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
49
77
  * Update a Live Activity
50
78
  */
51
79
  updateLiveActivityRaw(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityUpdateResponse>>;
52
80
  /**
53
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
81
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
54
82
  * Update a Live Activity
55
83
  */
56
84
  updateLiveActivity(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityUpdateResponse>;
@@ -20,7 +20,7 @@ const runtime = require("../runtime");
20
20
  */
21
21
  class LiveActivitiesApi extends runtime.BaseAPI {
22
22
  /**
23
- * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
23
+ * Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
24
24
  * End a Live Activity
25
25
  */
26
26
  async endLiveActivityRaw(requestParameters, initOverrides) {
@@ -47,7 +47,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
47
47
  return new runtime.JSONApiResponse(response);
48
48
  }
49
49
  /**
50
- * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
50
+ * Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
51
51
  * End a Live Activity
52
52
  */
53
53
  async endLiveActivity(requestParameters, initOverrides) {
@@ -55,7 +55,80 @@ class LiveActivitiesApi extends runtime.BaseAPI {
55
55
  return await response.value();
56
56
  }
57
57
  /**
58
- * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
58
+ * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
59
+ * End a stream
60
+ */
61
+ async endLiveActivityStreamRaw(requestParameters, initOverrides) {
62
+ if (requestParameters['streamKey'] == null) {
63
+ throw new runtime.RequiredError('streamKey', 'Required parameter "streamKey" was null or undefined when calling endLiveActivityStream().');
64
+ }
65
+ const queryParameters = {};
66
+ const headerParameters = {};
67
+ headerParameters['Content-Type'] = 'application/json';
68
+ if (this.configuration && this.configuration.accessToken) {
69
+ const token = this.configuration.accessToken;
70
+ const tokenString = await token("apiKeyAuth", []);
71
+ if (tokenString) {
72
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
73
+ }
74
+ }
75
+ const response = await this.request({
76
+ path: `/live-activity/stream/{stream_key}`.replace(`{${"stream_key"}}`, encodeURIComponent(String(requestParameters['streamKey']))),
77
+ method: 'DELETE',
78
+ headers: headerParameters,
79
+ query: queryParameters,
80
+ body: requestParameters['liveActivityStreamDeleteRequest'],
81
+ }, initOverrides);
82
+ return new runtime.JSONApiResponse(response);
83
+ }
84
+ /**
85
+ * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
86
+ * End a stream
87
+ */
88
+ async endLiveActivityStream(requestParameters, initOverrides) {
89
+ const response = await this.endLiveActivityStreamRaw(requestParameters, initOverrides);
90
+ return await response.value();
91
+ }
92
+ /**
93
+ * Use this endpoint when you want the easiest, stateless way to trigger Live Activities. You do not need to store activity_id or manage the Live Activity lifecycle yourself. Send the latest state for a stable stream_key and ActivitySmith will handle the rest for you: if there is no Live Activity yet, it starts one; if there is already one for this stream, it updates it. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
94
+ * Send a stream update
95
+ */
96
+ async reconcileLiveActivityStreamRaw(requestParameters, initOverrides) {
97
+ if (requestParameters['streamKey'] == null) {
98
+ throw new runtime.RequiredError('streamKey', 'Required parameter "streamKey" was null or undefined when calling reconcileLiveActivityStream().');
99
+ }
100
+ if (requestParameters['liveActivityStreamRequest'] == null) {
101
+ throw new runtime.RequiredError('liveActivityStreamRequest', 'Required parameter "liveActivityStreamRequest" was null or undefined when calling reconcileLiveActivityStream().');
102
+ }
103
+ const queryParameters = {};
104
+ const headerParameters = {};
105
+ headerParameters['Content-Type'] = 'application/json';
106
+ if (this.configuration && this.configuration.accessToken) {
107
+ const token = this.configuration.accessToken;
108
+ const tokenString = await token("apiKeyAuth", []);
109
+ if (tokenString) {
110
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
111
+ }
112
+ }
113
+ const response = await this.request({
114
+ path: `/live-activity/stream/{stream_key}`.replace(`{${"stream_key"}}`, encodeURIComponent(String(requestParameters['streamKey']))),
115
+ method: 'PUT',
116
+ headers: headerParameters,
117
+ query: queryParameters,
118
+ body: requestParameters['liveActivityStreamRequest'],
119
+ }, initOverrides);
120
+ return new runtime.JSONApiResponse(response);
121
+ }
122
+ /**
123
+ * Use this endpoint when you want the easiest, stateless way to trigger Live Activities. You do not need to store activity_id or manage the Live Activity lifecycle yourself. Send the latest state for a stable stream_key and ActivitySmith will handle the rest for you: if there is no Live Activity yet, it starts one; if there is already one for this stream, it updates it. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead.
124
+ * Send a stream update
125
+ */
126
+ async reconcileLiveActivityStream(requestParameters, initOverrides) {
127
+ const response = await this.reconcileLiveActivityStreamRaw(requestParameters, initOverrides);
128
+ return await response.value();
129
+ }
130
+ /**
131
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
59
132
  * Start a Live Activity
60
133
  */
61
134
  async startLiveActivityRaw(requestParameters, initOverrides) {
@@ -82,7 +155,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
82
155
  return new runtime.JSONApiResponse(response);
83
156
  }
84
157
  /**
85
- * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
158
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
86
159
  * Start a Live Activity
87
160
  */
88
161
  async startLiveActivity(requestParameters, initOverrides) {
@@ -90,7 +163,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
90
163
  return await response.value();
91
164
  }
92
165
  /**
93
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
166
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
94
167
  * Update a Live Activity
95
168
  */
96
169
  async updateLiveActivityRaw(requestParameters, initOverrides) {
@@ -117,7 +190,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
117
190
  return new runtime.JSONApiResponse(response);
118
191
  }
119
192
  /**
120
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
193
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
121
194
  * Update a Live Activity
122
195
  */
123
196
  async updateLiveActivity(requestParameters, initOverrides) {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ActivitySmith API
3
+ * Send push notifications and Live Activities to your own devices via a single API key.
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import * as runtime from '../runtime';
13
+ import type { MetricValueUpdateRequest, MetricValueUpdateResponse } from '../models/index';
14
+ export interface UpdateMetricValueRequest {
15
+ key: string;
16
+ metricValueUpdateRequest: MetricValueUpdateRequest;
17
+ }
18
+ /**
19
+ *
20
+ */
21
+ export declare class MetricsApi extends runtime.BaseAPI {
22
+ /**
23
+ * Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
24
+ * Update a widget metric value
25
+ */
26
+ updateMetricValueRaw(requestParameters: UpdateMetricValueRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MetricValueUpdateResponse>>;
27
+ /**
28
+ * Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
29
+ * Update a widget metric value
30
+ */
31
+ updateMetricValue(requestParameters: UpdateMetricValueRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MetricValueUpdateResponse>;
32
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * ActivitySmith API
6
+ * Send push notifications and Live Activities to your own devices via a single API key.
7
+ *
8
+ * The version of the OpenAPI document: 1.0.0
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.MetricsApi = void 0;
17
+ const runtime = require("../runtime");
18
+ /**
19
+ *
20
+ */
21
+ class MetricsApi extends runtime.BaseAPI {
22
+ /**
23
+ * Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
24
+ * Update a widget metric value
25
+ */
26
+ async updateMetricValueRaw(requestParameters, initOverrides) {
27
+ if (requestParameters['key'] == null) {
28
+ throw new runtime.RequiredError('key', 'Required parameter "key" was null or undefined when calling updateMetricValue().');
29
+ }
30
+ if (requestParameters['metricValueUpdateRequest'] == null) {
31
+ throw new runtime.RequiredError('metricValueUpdateRequest', 'Required parameter "metricValueUpdateRequest" was null or undefined when calling updateMetricValue().');
32
+ }
33
+ const queryParameters = {};
34
+ const headerParameters = {};
35
+ headerParameters['Content-Type'] = 'application/json';
36
+ if (this.configuration && this.configuration.accessToken) {
37
+ const token = this.configuration.accessToken;
38
+ const tokenString = await token("apiKeyAuth", []);
39
+ if (tokenString) {
40
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
41
+ }
42
+ }
43
+ const response = await this.request({
44
+ path: `/metrics/{key}/value`.replace(`{${"key"}}`, encodeURIComponent(String(requestParameters['key']))),
45
+ method: 'POST',
46
+ headers: headerParameters,
47
+ query: queryParameters,
48
+ body: requestParameters['metricValueUpdateRequest'],
49
+ }, initOverrides);
50
+ return new runtime.JSONApiResponse(response);
51
+ }
52
+ /**
53
+ * Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
54
+ * Update a widget metric value
55
+ */
56
+ async updateMetricValue(requestParameters, initOverrides) {
57
+ const response = await this.updateMetricValueRaw(requestParameters, initOverrides);
58
+ return await response.value();
59
+ }
60
+ }
61
+ exports.MetricsApi = MetricsApi;
@@ -1,2 +1,3 @@
1
1
  export * from './LiveActivitiesApi';
2
+ export * from './MetricsApi';
2
3
  export * from './PushNotificationsApi';
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  /* tslint:disable */
18
18
  /* eslint-disable */
19
19
  __exportStar(require("./LiveActivitiesApi"), exports);
20
+ __exportStar(require("./MetricsApi"), exports);
20
21
  __exportStar(require("./PushNotificationsApi"), exports);