activitysmith 1.2.2 → 1.3.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
@@ -15,11 +15,8 @@ See [API reference](https://activitysmith.com/docs/api-reference/introduction)
15
15
  - [Rich Push Notifications with Media](#rich-push-notifications-with-media)
16
16
  - [Actionable Push Notifications](#actionable-push-notifications)
17
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)
18
+ - [Start & Update Live Activity](#start--update-live-activity)
19
+ - [End Live Activity](#end-live-activity)
23
20
  - [Live Activity Action](#live-activity-action)
24
21
  - [Channels](#channels)
25
22
  - [Widgets](#widgets)
@@ -129,39 +126,49 @@ await activitysmith.notifications.send({
129
126
 
130
127
  ## Live Activities
131
128
 
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:
129
+ There are four types of Live Activities:
137
130
 
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
131
+ - `stats`: best for showing business numbers side by side, such as revenue, sales, new users, conversion, refunds, or any other value you want visible at a glance
132
+ - `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
133
+ - `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
134
+ - `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
141
135
 
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.
136
+ ### Start & Update Live Activity
143
137
 
144
- This is ideal if you want minimal complexity, perfect for automated workflows like cron jobs.
138
+ Use a stable `streamKey` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `streamKey` update it.
145
139
 
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.
140
+ #### Stats
147
141
 
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
142
+ <p align="center">
143
+ <img src="https://cdn.activitysmith.com/features/stats-live-activity.png" alt="Stats Live Activity stream example" width="680" />
144
+ </p>
151
145
 
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.
146
+ ```ts
147
+ await activitysmith.liveActivities.stream("sales-hourly", {
148
+ content_state: {
149
+ title: "Sales",
150
+ subtitle: "last hour",
151
+ type: "stats",
152
+ metrics: [
153
+ { label: "Revenue", value: "$2430", color: "blue" },
154
+ { label: "Orders", value: "37", color: "green" },
155
+ { label: "Conversion", value: "4.8%", color: "magenta" },
156
+ { label: "Avg Order", value: "$65.68", color: "yellow" },
157
+ { label: "Refunds", value: "$84", color: "red" },
158
+ { label: "New Buyers", value: "18", color: "cyan" },
159
+ ],
160
+ },
161
+ });
162
+ ```
156
163
 
157
164
  #### Metrics
158
165
 
159
166
  <p align="center">
160
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics stream example" width="680" />
167
+ <img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics Live Activity stream example" width="680" />
161
168
  </p>
162
169
 
163
170
  ```ts
164
- const status = await activitysmith.liveActivities.stream("prod-web-1", {
171
+ await activitysmith.liveActivities.stream("prod-web-1", {
165
172
  content_state: {
166
173
  title: "Server Health",
167
174
  subtitle: "prod-web-1",
@@ -174,10 +181,10 @@ const status = await activitysmith.liveActivities.stream("prod-web-1", {
174
181
  });
175
182
  ```
176
183
 
177
- #### Segmented progress
184
+ #### Segmented Progress
178
185
 
179
186
  <p align="center">
180
- <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented progress stream example" width="680" />
187
+ <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented Progress Live Activity stream example" width="680" />
181
188
  </p>
182
189
 
183
190
  ```ts
@@ -195,7 +202,7 @@ await activitysmith.liveActivities.stream("nightly-backup", {
195
202
  #### Progress
196
203
 
197
204
  <p align="center">
198
- <img src="https://cdn.activitysmith.com/features/progress-live-activity.png" alt="Progress stream example" width="680" />
205
+ <img src="https://cdn.activitysmith.com/features/progress-live-activity.png" alt="Progress Live Activity stream example" width="680" />
199
206
  </p>
200
207
 
201
208
  ```ts
@@ -209,106 +216,12 @@ await activitysmith.liveActivities.stream("search-reindex", {
209
216
  });
210
217
  ```
211
218
 
212
- Call `stream(...)` again with the same `streamKey` whenever the state changes.
219
+ ### End Live Activity
213
220
 
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.
221
+ Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. By default, iOS removes the Live Activity after two minutes. Set `auto_dismiss_minutes` to choose a different dismissal time, including `0` for immediate dismissal.
219
222
 
220
223
  ```ts
221
224
  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:
249
-
250
- 1. Call `activitysmith.liveActivities.start(...)`.
251
- 2. Save the returned `activity_id`.
252
- 3. Call `activitysmith.liveActivities.update(...)` as progress changes.
253
- 4. Call `activitysmith.liveActivities.end(...)` when the work is finished.
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
225
  content_state: {
313
226
  title: "Server Health",
314
227
  subtitle: "prod-web-1",
@@ -322,144 +235,18 @@ await activitysmith.liveActivities.end({
322
235
  });
323
236
  ```
324
237
 
325
- ### Segmented Progress Type
326
-
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.
329
- `number_of_steps` is dynamic, so you can increase or decrease it later if the
330
- workflow changes.
331
-
332
- #### Start
333
-
334
- <p align="center">
335
- <img src="https://cdn.activitysmith.com/features/start-live-activity.png" alt="Segmented progress start example" width="680" />
336
- </p>
337
-
338
- ```ts
339
- const start = await activitysmith.liveActivities.start({
340
- content_state: {
341
- title: "Nightly database backup",
342
- subtitle: "create snapshot",
343
- number_of_steps: 3,
344
- current_step: 1,
345
- type: "segmented_progress",
346
- color: "yellow",
347
- },
348
- });
349
-
350
- const activityId = start.activity_id;
351
- ```
352
-
353
- #### Update
354
-
355
- <p align="center">
356
- <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented progress update example" width="680" />
357
- </p>
358
-
359
- ```ts
360
- await activitysmith.liveActivities.update({
361
- activity_id: activityId,
362
- content_state: {
363
- title: "Nightly database backup",
364
- subtitle: "upload archive",
365
- number_of_steps: 3,
366
- current_step: 2,
367
- },
368
- });
369
- ```
370
-
371
- #### End
372
-
373
- <p align="center">
374
- <img src="https://cdn.activitysmith.com/features/end-live-activity.png" alt="Segmented progress end example" width="680" />
375
- </p>
376
-
377
- ```ts
378
- await activitysmith.liveActivities.end({
379
- activity_id: activityId,
380
- content_state: {
381
- title: "Nightly database backup",
382
- subtitle: "verify restore",
383
- number_of_steps: 3,
384
- current_step: 3,
385
- auto_dismiss_minutes: 2,
386
- },
387
- });
388
- ```
389
-
390
- ### Progress Type
391
-
392
- Use `progress` when the state is naturally continuous. It fits charging,
393
- downloads, sync jobs, uploads, timers, and any flow where a percentage or
394
- numeric range is the clearest signal.
395
-
396
- #### Start
397
-
398
- <p align="center">
399
- <img src="https://cdn.activitysmith.com/features/progress-live-activity-start.png" alt="Progress start example" width="680" />
400
- </p>
401
-
402
- ```ts
403
- const start = await activitysmith.liveActivities.start({
404
- content_state: {
405
- title: "EV Charging",
406
- subtitle: "Added 30 mi range",
407
- type: "progress",
408
- percentage: 15,
409
- color: "lime",
410
- },
411
- });
412
-
413
- const activityId = start.activity_id;
414
- ```
415
-
416
- #### Update
417
-
418
- <p align="center">
419
- <img src="https://cdn.activitysmith.com/features/progress-live-activity-update.png" alt="Progress update example" width="680" />
420
- </p>
421
-
422
- ```ts
423
- await activitysmith.liveActivities.update({
424
- activity_id: activityId,
425
- content_state: {
426
- title: "EV Charging",
427
- subtitle: "Added 120 mi range",
428
- percentage: 60,
429
- },
430
- });
431
- ```
238
+ ### Live Activity Action
432
239
 
433
- #### End
240
+ Live Activities can include one optional action button. Use it to open a URL from the Live Activity or trigger a backend webhook.
434
241
 
435
242
  <p align="center">
436
- <img src="https://cdn.activitysmith.com/features/progress-live-activity-end.png" alt="Progress end example" width="680" />
243
+ <img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action button" width="680" />
437
244
  </p>
438
245
 
439
- ```ts
440
- await activitysmith.liveActivities.end({
441
- activity_id: activityId,
442
- content_state: {
443
- title: "EV Charging",
444
- subtitle: "Added 200 mi range",
445
- percentage: 100,
446
- auto_dismiss_minutes: 2,
447
- },
448
- });
449
- ```
450
-
451
- ### Live Activity Action
452
-
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.
454
-
455
246
  #### Open URL action
456
247
 
457
- <p align="center">
458
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Metrics Live Activity with action" width="680" />
459
- </p>
460
-
461
248
  ```ts
462
- const start = await activitysmith.liveActivities.start({
249
+ await activitysmith.liveActivities.stream("prod-web-1", {
463
250
  content_state: {
464
251
  title: "Server Health",
465
252
  subtitle: "prod-web-1",
@@ -475,22 +262,16 @@ const start = await activitysmith.liveActivities.start({
475
262
  url: "https://ops.example.com/servers/prod-web-1",
476
263
  },
477
264
  });
478
-
479
- const activityId = start.activity_id;
480
265
  ```
481
266
 
482
267
  #### Webhook action
483
268
 
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
-
488
269
  ```ts
489
- await activitysmith.liveActivities.update({
490
- activity_id: activityId,
270
+ await activitysmith.liveActivities.stream("search-reindex", {
491
271
  content_state: {
492
272
  title: "Reindexing product search",
493
273
  subtitle: "Shard 7 of 12",
274
+ type: "segmented_progress",
494
275
  number_of_steps: 12,
495
276
  current_step: 7,
496
277
  },
@@ -33,13 +33,13 @@ export interface UpdateLiveActivityRequest {
33
33
  */
34
34
  export declare class LiveActivitiesApi extends runtime.BaseAPI {
35
35
  /**
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.
37
- * End a Live Activity
36
+ * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
37
+ * End a Live Activity (legacy manual lifecycle)
38
38
  */
39
39
  endLiveActivityRaw(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityEndResponse>>;
40
40
  /**
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.
42
- * End a Live Activity
41
+ * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
42
+ * End a Live Activity (legacy manual lifecycle)
43
43
  */
44
44
  endLiveActivity(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityEndResponse>;
45
45
  /**
@@ -53,33 +53,33 @@ export declare class LiveActivitiesApi extends runtime.BaseAPI {
53
53
  */
54
54
  endLiveActivityStream(requestParameters: EndLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStreamDeleteResponse>;
55
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
56
+ * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync.
57
+ * Start a new Live Activity or update an existing one
58
58
  */
59
59
  reconcileLiveActivityStreamRaw(requestParameters: ReconcileLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityStreamPutResponse>>;
60
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
61
+ * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync.
62
+ * Start a new Live Activity or update an existing one
63
63
  */
64
64
  reconcileLiveActivityStream(requestParameters: ReconcileLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStreamPutResponse>;
65
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.
67
- * Start a Live Activity
66
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
67
+ * Start a Live Activity (legacy manual lifecycle)
68
68
  */
69
69
  startLiveActivityRaw(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityStartResponse>>;
70
70
  /**
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.
72
- * Start a Live Activity
71
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
72
+ * Start a Live Activity (legacy manual lifecycle)
73
73
  */
74
74
  startLiveActivity(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStartResponse>;
75
75
  /**
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.
77
- * Update a Live Activity
76
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
77
+ * Update a Live Activity (legacy manual lifecycle)
78
78
  */
79
79
  updateLiveActivityRaw(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityUpdateResponse>>;
80
80
  /**
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.
82
- * Update a Live Activity
81
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
82
+ * Update a Live Activity (legacy manual lifecycle)
83
83
  */
84
84
  updateLiveActivity(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityUpdateResponse>;
85
85
  }
@@ -20,8 +20,8 @@ const runtime = require("../runtime");
20
20
  */
21
21
  class LiveActivitiesApi extends runtime.BaseAPI {
22
22
  /**
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
- * End a Live Activity
23
+ * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
24
+ * End a Live Activity (legacy manual lifecycle)
25
25
  */
26
26
  async endLiveActivityRaw(requestParameters, initOverrides) {
27
27
  if (requestParameters['liveActivityEndRequest'] == null) {
@@ -47,8 +47,8 @@ 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. 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
- * End a Live Activity
50
+ * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
51
+ * End a Live Activity (legacy manual lifecycle)
52
52
  */
53
53
  async endLiveActivity(requestParameters, initOverrides) {
54
54
  const response = await this.endLiveActivityRaw(requestParameters, initOverrides);
@@ -90,8 +90,8 @@ class LiveActivitiesApi extends runtime.BaseAPI {
90
90
  return await response.value();
91
91
  }
92
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
93
+ * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync.
94
+ * Start a new Live Activity or update an existing one
95
95
  */
96
96
  async reconcileLiveActivityStreamRaw(requestParameters, initOverrides) {
97
97
  if (requestParameters['streamKey'] == null) {
@@ -120,16 +120,16 @@ class LiveActivitiesApi extends runtime.BaseAPI {
120
120
  return new runtime.JSONApiResponse(response);
121
121
  }
122
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
123
+ * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync.
124
+ * Start a new Live Activity or update an existing one
125
125
  */
126
126
  async reconcileLiveActivityStream(requestParameters, initOverrides) {
127
127
  const response = await this.reconcileLiveActivityStreamRaw(requestParameters, initOverrides);
128
128
  return await response.value();
129
129
  }
130
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.
132
- * Start a Live Activity
131
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
132
+ * Start a Live Activity (legacy manual lifecycle)
133
133
  */
134
134
  async startLiveActivityRaw(requestParameters, initOverrides) {
135
135
  if (requestParameters['liveActivityStartRequest'] == null) {
@@ -155,16 +155,16 @@ class LiveActivitiesApi extends runtime.BaseAPI {
155
155
  return new runtime.JSONApiResponse(response);
156
156
  }
157
157
  /**
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.
159
- * Start a Live Activity
158
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
159
+ * Start a Live Activity (legacy manual lifecycle)
160
160
  */
161
161
  async startLiveActivity(requestParameters, initOverrides) {
162
162
  const response = await this.startLiveActivityRaw(requestParameters, initOverrides);
163
163
  return await response.value();
164
164
  }
165
165
  /**
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.
167
- * Update a Live Activity
166
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
167
+ * Update a Live Activity (legacy manual lifecycle)
168
168
  */
169
169
  async updateLiveActivityRaw(requestParameters, initOverrides) {
170
170
  if (requestParameters['liveActivityUpdateRequest'] == null) {
@@ -190,8 +190,8 @@ class LiveActivitiesApi extends runtime.BaseAPI {
190
190
  return new runtime.JSONApiResponse(response);
191
191
  }
192
192
  /**
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.
194
- * Update a Live Activity
193
+ * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
194
+ * Update a Live Activity (legacy manual lifecycle)
195
195
  */
196
196
  async updateLiveActivity(requestParameters, initOverrides) {
197
197
  const response = await this.updateLiveActivityRaw(requestParameters, initOverrides);
@@ -13,17 +13,44 @@ export interface ActivityMetric {
13
13
  label: string;
14
14
  /**
15
15
  *
16
- * @type {number}
16
+ * @type {ActivityMetricValue}
17
17
  * @memberof ActivityMetric
18
18
  */
19
- value: number;
19
+ value: ActivityMetricValue;
20
20
  /**
21
21
  *
22
22
  * @type {string}
23
23
  * @memberof ActivityMetric
24
24
  */
25
25
  unit?: string;
26
+ /**
27
+ * Optional per-metric accent color for metrics and stats activities.
28
+ * @type {string}
29
+ * @memberof ActivityMetric
30
+ */
31
+ color?: ActivityMetricColorEnum;
26
32
  }
33
+ /**
34
+ * @export
35
+ */
36
+ export declare const ActivityMetricColorEnum: {
37
+ readonly Lime: "lime";
38
+ readonly Green: "green";
39
+ readonly Cyan: "cyan";
40
+ readonly Blue: "blue";
41
+ readonly Purple: "purple";
42
+ readonly Magenta: "magenta";
43
+ readonly Red: "red";
44
+ readonly Orange: "orange";
45
+ readonly Yellow: "yellow";
46
+ };
47
+ export type ActivityMetricColorEnum = typeof ActivityMetricColorEnum[keyof typeof ActivityMetricColorEnum];
48
+ /**
49
+ * @type ActivityMetricValue
50
+ *
51
+ * @export
52
+ */
53
+ export type ActivityMetricValue = number | string;
27
54
  /**
28
55
  *
29
56
  * @export
@@ -79,7 +106,7 @@ export interface ChannelTarget {
79
106
  channels: Array<string>;
80
107
  }
81
108
  /**
82
- * End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
109
+ * End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
83
110
  * @export
84
111
  * @interface ContentStateEnd
85
112
  */
@@ -128,7 +155,7 @@ export interface ContentStateEnd {
128
155
  */
129
156
  upper_limit?: number;
130
157
  /**
131
- * Use for type=metrics.
158
+ * Use for type=metrics or type=stats.
132
159
  * @type {Array<ActivityMetric>}
133
160
  * @memberof ContentStateEnd
134
161
  */
@@ -171,6 +198,7 @@ export declare const ContentStateEndTypeEnum: {
171
198
  readonly SegmentedProgress: "segmented_progress";
172
199
  readonly Progress: "progress";
173
200
  readonly Metrics: "metrics";
201
+ readonly Stats: "stats";
174
202
  };
175
203
  export type ContentStateEndTypeEnum = typeof ContentStateEndTypeEnum[keyof typeof ContentStateEndTypeEnum];
176
204
  /**
@@ -219,7 +247,7 @@ export declare const ContentStateEndStepColorsEnum: {
219
247
  };
220
248
  export type ContentStateEndStepColorsEnum = typeof ContentStateEndStepColorsEnum[keyof typeof ContentStateEndStepColorsEnum];
221
249
  /**
222
- * Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls.
250
+ * Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls.
223
251
  * @export
224
252
  * @interface ContentStateStart
225
253
  */
@@ -268,7 +296,7 @@ export interface ContentStateStart {
268
296
  */
269
297
  upper_limit?: number;
270
298
  /**
271
- * Use for type=metrics.
299
+ * Use for type=metrics or type=stats.
272
300
  * @type {Array<ActivityMetric>}
273
301
  * @memberof ContentStateStart
274
302
  */
@@ -305,6 +333,7 @@ export declare const ContentStateStartTypeEnum: {
305
333
  readonly SegmentedProgress: "segmented_progress";
306
334
  readonly Progress: "progress";
307
335
  readonly Metrics: "metrics";
336
+ readonly Stats: "stats";
308
337
  };
309
338
  export type ContentStateStartTypeEnum = typeof ContentStateStartTypeEnum[keyof typeof ContentStateStartTypeEnum];
310
339
  /**
@@ -353,7 +382,7 @@ export declare const ContentStateStartStepColorsEnum: {
353
382
  };
354
383
  export type ContentStateStartStepColorsEnum = typeof ContentStateStartStepColorsEnum[keyof typeof ContentStateStartStepColorsEnum];
355
384
  /**
356
- * Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
385
+ * Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
357
386
  * @export
358
387
  * @interface ContentStateUpdate
359
388
  */
@@ -402,7 +431,7 @@ export interface ContentStateUpdate {
402
431
  */
403
432
  upper_limit?: number;
404
433
  /**
405
- * Use for type=metrics.
434
+ * Use for type=metrics or type=stats.
406
435
  * @type {Array<ActivityMetric>}
407
436
  * @memberof ContentStateUpdate
408
437
  */
@@ -439,6 +468,7 @@ export declare const ContentStateUpdateTypeEnum: {
439
468
  readonly SegmentedProgress: "segmented_progress";
440
469
  readonly Progress: "progress";
441
470
  readonly Metrics: "metrics";
471
+ readonly Stats: "stats";
442
472
  };
443
473
  export type ContentStateUpdateTypeEnum = typeof ContentStateUpdateTypeEnum[keyof typeof ContentStateUpdateTypeEnum];
444
474
  /**
@@ -1299,7 +1329,7 @@ export interface RateLimitError {
1299
1329
  */
1300
1330
  export type SendPushNotification429Response = LiveActivityLimitError | RateLimitError;
1301
1331
  /**
1302
- * Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, and metrics types.
1332
+ * Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, metrics, and stats types.
1303
1333
  * @export
1304
1334
  * @interface StreamContentState
1305
1335
  */
@@ -1372,7 +1402,7 @@ export interface StreamContentState {
1372
1402
  */
1373
1403
  step_colors?: Array<StreamContentStateStepColorsEnum>;
1374
1404
  /**
1375
- * Use for metrics activities.
1405
+ * Use for metrics and stats activities.
1376
1406
  * @type {Array<ActivityMetric>}
1377
1407
  * @memberof StreamContentState
1378
1408
  */
@@ -1397,6 +1427,7 @@ export declare const StreamContentStateTypeEnum: {
1397
1427
  readonly SegmentedProgress: "segmented_progress";
1398
1428
  readonly Progress: "progress";
1399
1429
  readonly Metrics: "metrics";
1430
+ readonly Stats: "stats";
1400
1431
  };
1401
1432
  export type StreamContentStateTypeEnum = typeof StreamContentStateTypeEnum[keyof typeof StreamContentStateTypeEnum];
1402
1433
  /**
@@ -1,13 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamContentStateStepColorsEnum = exports.StreamContentStateStepColorEnum = exports.StreamContentStateColorEnum = exports.StreamContentStateTypeEnum = exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.LiveActivityWebhookMethod = exports.LiveActivityStreamPutResponseOperationEnum = exports.LiveActivityStreamDeleteResponseOperationEnum = exports.LiveActivityActionType = exports.ContentStateUpdateStepColorsEnum = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateUpdateTypeEnum = exports.ContentStateStartStepColorsEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorsEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = exports.ContentStateEndTypeEnum = void 0;
3
+ exports.StreamContentStateStepColorsEnum = exports.StreamContentStateStepColorEnum = exports.StreamContentStateColorEnum = exports.StreamContentStateTypeEnum = exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.LiveActivityWebhookMethod = exports.LiveActivityStreamPutResponseOperationEnum = exports.LiveActivityStreamDeleteResponseOperationEnum = exports.LiveActivityActionType = exports.ContentStateUpdateStepColorsEnum = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateUpdateTypeEnum = exports.ContentStateStartStepColorsEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorsEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = exports.ContentStateEndTypeEnum = exports.ActivityMetricColorEnum = void 0;
4
+ /**
5
+ * @export
6
+ */
7
+ exports.ActivityMetricColorEnum = {
8
+ Lime: 'lime',
9
+ Green: 'green',
10
+ Cyan: 'cyan',
11
+ Blue: 'blue',
12
+ Purple: 'purple',
13
+ Magenta: 'magenta',
14
+ Red: 'red',
15
+ Orange: 'orange',
16
+ Yellow: 'yellow'
17
+ };
4
18
  /**
5
19
  * @export
6
20
  */
7
21
  exports.ContentStateEndTypeEnum = {
8
22
  SegmentedProgress: 'segmented_progress',
9
23
  Progress: 'progress',
10
- Metrics: 'metrics'
24
+ Metrics: 'metrics',
25
+ Stats: 'stats'
11
26
  };
12
27
  /**
13
28
  * @export
@@ -57,7 +72,8 @@ exports.ContentStateEndStepColorsEnum = {
57
72
  exports.ContentStateStartTypeEnum = {
58
73
  SegmentedProgress: 'segmented_progress',
59
74
  Progress: 'progress',
60
- Metrics: 'metrics'
75
+ Metrics: 'metrics',
76
+ Stats: 'stats'
61
77
  };
62
78
  /**
63
79
  * @export
@@ -107,7 +123,8 @@ exports.ContentStateStartStepColorsEnum = {
107
123
  exports.ContentStateUpdateTypeEnum = {
108
124
  SegmentedProgress: 'segmented_progress',
109
125
  Progress: 'progress',
110
- Metrics: 'metrics'
126
+ Metrics: 'metrics',
127
+ Stats: 'stats'
111
128
  };
112
129
  /**
113
130
  * @export
@@ -205,7 +222,8 @@ exports.PushNotificationWebhookMethod = {
205
222
  exports.StreamContentStateTypeEnum = {
206
223
  SegmentedProgress: 'segmented_progress',
207
224
  Progress: 'progress',
208
- Metrics: 'metrics'
225
+ Metrics: 'metrics',
226
+ Stats: 'stats'
209
227
  };
210
228
  /**
211
229
  * @export
@@ -35,6 +35,12 @@ export declare class NotificationsResource {
35
35
  sendPushNotificationRaw(requestParameters: PushRawParameters, initOverrides?: SendInitOverrides): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").PushNotificationResponse>>;
36
36
  }
37
37
  export declare class LiveActivitiesResource {
38
+ static readonly types: {
39
+ readonly segmentedProgress: "segmented_progress";
40
+ readonly progress: "progress";
41
+ readonly metrics: "metrics";
42
+ readonly stats: "stats";
43
+ };
38
44
  private readonly api;
39
45
  constructor(api: LiveActivitiesApi);
40
46
  start(request: LiveStartSendRequest, initOverrides?: LiveInitOverrides): Promise<import("../generated/models").LiveActivityStartResponse>;
@@ -61,6 +67,12 @@ export declare class MetricsResource {
61
67
  updateMetricValueRaw(requestParameters: MetricRawParameters, initOverrides?: MetricInitOverrides): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").MetricValueUpdateResponse>>;
62
68
  }
63
69
  export declare class ActivitySmith {
70
+ static readonly liveActivityTypes: {
71
+ readonly segmentedProgress: "segmented_progress";
72
+ readonly progress: "progress";
73
+ readonly metrics: "metrics";
74
+ readonly stats: "stats";
75
+ };
64
76
  readonly notifications: NotificationsResource;
65
77
  readonly liveActivities: LiveActivitiesResource;
66
78
  readonly metrics: MetricsResource;
@@ -2,9 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActivitySmith = exports.MetricsResource = exports.LiveActivitiesResource = exports.NotificationsResource = void 0;
4
4
  const index_1 = require("../generated/index");
5
- const SDK_VERSION = "1.2.2";
5
+ const SDK_VERSION = "1.3.0";
6
6
  const SDK_HEADER_NAME = "X-ActivitySmith-SDK";
7
7
  const SDK_HEADER_VALUE = `node-v${SDK_VERSION}`;
8
+ const LiveActivityTypes = {
9
+ segmentedProgress: "segmented_progress",
10
+ progress: "progress",
11
+ metrics: "metrics",
12
+ stats: "stats",
13
+ };
8
14
  function withTargetChannels(request) {
9
15
  const channels = request.channels;
10
16
  if (!channels || channels.length === 0 || request.target) {
@@ -126,6 +132,7 @@ class LiveActivitiesResource {
126
132
  }
127
133
  }
128
134
  exports.LiveActivitiesResource = LiveActivitiesResource;
135
+ LiveActivitiesResource.types = LiveActivityTypes;
129
136
  class MetricsResource {
130
137
  constructor(api) {
131
138
  this.api = api;
@@ -163,3 +170,4 @@ class ActivitySmith {
163
170
  }
164
171
  }
165
172
  exports.ActivitySmith = ActivitySmith;
173
+ ActivitySmith.liveActivityTypes = LiveActivityTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
4
4
  "description": "Official ActivitySmith Node.js SDK",
5
5
  "keywords": [
6
6
  "activitysmith",