activitysmith-cli 1.3.0 → 1.4.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 +67 -320
- package/package.json +2 -2
- package/src/cli.js +105 -10
package/README.md
CHANGED
|
@@ -12,12 +12,8 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
|
|
|
12
12
|
- [Rich Push Notifications with Media](#rich-push-notifications-with-media)
|
|
13
13
|
- [Actionable Push Notifications](#actionable-push-notifications)
|
|
14
14
|
- [Live Activities](#live-activities)
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [Stats](#stats)
|
|
18
|
-
- [Metrics](#metrics)
|
|
19
|
-
- [Segmented Progress](#segmented-progress)
|
|
20
|
-
- [Progress](#progress)
|
|
15
|
+
- [Start & Update Live Activity](#start--update-live-activity)
|
|
16
|
+
- [End Live Activity](#end-live-activity)
|
|
21
17
|
- [Live Activity Action](#live-activity-action)
|
|
22
18
|
- [Channels](#channels)
|
|
23
19
|
- [Widgets](#widgets)
|
|
@@ -139,43 +135,26 @@ activitysmith push \
|
|
|
139
135
|
|
|
140
136
|
## Live Activities
|
|
141
137
|
|
|
142
|
-
|
|
143
|
-
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Metrics Live Activity screenshot" width="680" />
|
|
144
|
-
</p>
|
|
145
|
-
|
|
146
|
-
There are four types of Live Activities:
|
|
147
|
-
|
|
148
|
-
- `stats`: best for compact business or product stats like revenue, orders, conversion, and average order value
|
|
149
|
-
- `metrics`: best for live operational stats like server CPU and memory, queue depth, or replica lag
|
|
150
|
-
- `segmented_progress`: best for step-based workflows like deployments, backups, and ETL pipelines
|
|
151
|
-
- `progress`: best for continuous jobs like uploads, reindexes, and long-running migrations tracked as a percentage
|
|
152
|
-
|
|
153
|
-
When working with Live Activities via our API, you have two approaches tailored
|
|
154
|
-
to different needs. First, the stateless mode is the simplest path - one API
|
|
155
|
-
call can initiate or update an activity, and another ends it - no state
|
|
156
|
-
tracking on your side.
|
|
157
|
-
|
|
158
|
-
This is ideal if you want minimal complexity, perfect for automated workflows
|
|
159
|
-
like cron jobs.
|
|
138
|
+
There are five types of Live Activities:
|
|
160
139
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
140
|
+
- `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
|
|
141
|
+
- `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
|
|
142
|
+
- `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
|
|
143
|
+
- `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
|
|
144
|
+
- `alert`: best for status updates, such as feature adoption, reactivation, onboarding blockers, incidents, escalations, and other operational states
|
|
164
145
|
|
|
165
|
-
|
|
166
|
-
can choose what fits your use case best.
|
|
146
|
+
### Start & Update Live Activity
|
|
167
147
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
Use a stable `stream_key` to identify the system or workflow you are tracking,
|
|
171
|
-
such as a server, deployment, build pipeline, cron job, or charging session.
|
|
172
|
-
This is especially useful for cron jobs and other scheduled tasks where you do
|
|
173
|
-
not want to store `activity_id` between runs.
|
|
148
|
+
Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `activity stream` command starts the Live Activity. Later commands with the same `stream_key` update it.
|
|
174
149
|
|
|
175
150
|
#### Stats
|
|
176
151
|
|
|
177
152
|
<p align="center">
|
|
178
|
-
<img
|
|
153
|
+
<img
|
|
154
|
+
src="https://cdn.activitysmith.com/features/stats-live-activity.png"
|
|
155
|
+
alt="Stats Live Activity stream example"
|
|
156
|
+
width="680"
|
|
157
|
+
/>
|
|
179
158
|
</p>
|
|
180
159
|
|
|
181
160
|
```bash
|
|
@@ -198,7 +177,11 @@ activitysmith activity stream sales-hourly \
|
|
|
198
177
|
#### Metrics
|
|
199
178
|
|
|
200
179
|
<p align="center">
|
|
201
|
-
<img
|
|
180
|
+
<img
|
|
181
|
+
src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png"
|
|
182
|
+
alt="Metrics Live Activity stream example"
|
|
183
|
+
width="680"
|
|
184
|
+
/>
|
|
202
185
|
</p>
|
|
203
186
|
|
|
204
187
|
```bash
|
|
@@ -214,10 +197,14 @@ activitysmith activity stream prod-web-1 \
|
|
|
214
197
|
}'
|
|
215
198
|
```
|
|
216
199
|
|
|
217
|
-
#### Segmented
|
|
200
|
+
#### Segmented Progress
|
|
218
201
|
|
|
219
202
|
<p align="center">
|
|
220
|
-
<img
|
|
203
|
+
<img
|
|
204
|
+
src="https://cdn.activitysmith.com/features/update-live-activity.png"
|
|
205
|
+
alt="Segmented Progress Live Activity stream example"
|
|
206
|
+
width="680"
|
|
207
|
+
/>
|
|
221
208
|
</p>
|
|
222
209
|
|
|
223
210
|
```bash
|
|
@@ -234,7 +221,11 @@ activitysmith activity stream nightly-backup \
|
|
|
234
221
|
#### Progress
|
|
235
222
|
|
|
236
223
|
<p align="center">
|
|
237
|
-
<img
|
|
224
|
+
<img
|
|
225
|
+
src="https://cdn.activitysmith.com/features/progress-live-activity.png"
|
|
226
|
+
alt="Progress Live Activity stream example"
|
|
227
|
+
width="680"
|
|
228
|
+
/>
|
|
238
229
|
</p>
|
|
239
230
|
|
|
240
231
|
```bash
|
|
@@ -247,177 +238,47 @@ activitysmith activity stream search-reindex \
|
|
|
247
238
|
}'
|
|
248
239
|
```
|
|
249
240
|
|
|
250
|
-
|
|
251
|
-
`stream_key` whenever the state changes.
|
|
252
|
-
|
|
253
|
-
#### End a stream
|
|
254
|
-
|
|
255
|
-
Use this when the tracked process is finished and you no longer want the Live
|
|
256
|
-
Activity on devices. `content_state` is optional here; include it if you want
|
|
257
|
-
to end the stream with a final state.
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
activitysmith activity end-stream prod-web-1 \
|
|
261
|
-
--content-state '{
|
|
262
|
-
"title": "Server Health",
|
|
263
|
-
"subtitle": "prod-web-1",
|
|
264
|
-
"type": "metrics",
|
|
265
|
-
"metrics": [
|
|
266
|
-
{ "label": "CPU", "value": 7, "unit": "%" },
|
|
267
|
-
{ "label": "MEM", "value": 38, "unit": "%" }
|
|
268
|
-
]
|
|
269
|
-
}'
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
If you later send another `activity stream` request with the same `stream_key`,
|
|
273
|
-
ActivitySmith starts a new Live Activity for that stream again.
|
|
274
|
-
|
|
275
|
-
Stream responses include an `operation` field:
|
|
276
|
-
|
|
277
|
-
- `started`: ActivitySmith started a new Live Activity for this `stream_key`
|
|
278
|
-
- `updated`: ActivitySmith updated the current Live Activity
|
|
279
|
-
- `rotated`: ActivitySmith ended the previous Live Activity and started a new one
|
|
280
|
-
- `noop`: the incoming state matched the current state, so no update was sent
|
|
281
|
-
- `paused`: the stream is paused, so no Live Activity was started or updated
|
|
282
|
-
- `ended`: returned by `activity end-stream` after the stream is ended
|
|
283
|
-
|
|
284
|
-
### Advanced: Full lifecycle control
|
|
285
|
-
|
|
286
|
-
Use these commands when you want to manage the Live Activity lifecycle yourself:
|
|
287
|
-
|
|
288
|
-
1. Run `activitysmith activity start ...`.
|
|
289
|
-
2. Save the returned `activity_id`.
|
|
290
|
-
3. Run `activitysmith activity update ...` as progress changes.
|
|
291
|
-
4. Run `activitysmith activity end ...` when the work is finished.
|
|
292
|
-
|
|
293
|
-
You can use `--content-state <json>` for the examples below, or build the same
|
|
294
|
-
payload with flags as documented in `Content State Options`.
|
|
295
|
-
|
|
296
|
-
### Stats
|
|
297
|
-
|
|
298
|
-
Keep your key numbers on your Lock Screen. `stats` fits up to 8 labeled values,
|
|
299
|
-
such as revenue, orders, conversion, uptime, or any other business metric you
|
|
300
|
-
want visible at a glance. Each metric can use a formatted string or number as
|
|
301
|
-
its `value`. Add `color` to a metric to show an accent dot next to its label;
|
|
302
|
-
omit `color` to show the label without a dot.
|
|
303
|
-
|
|
304
|
-
#### Start
|
|
241
|
+
#### Alert
|
|
305
242
|
|
|
306
243
|
<p align="center">
|
|
307
|
-
<img
|
|
244
|
+
<img
|
|
245
|
+
src="https://cdn.activitysmith.com/features/alert-live-activity.png"
|
|
246
|
+
alt="Alert Live Activity stream example"
|
|
247
|
+
width="680"
|
|
248
|
+
/>
|
|
308
249
|
</p>
|
|
309
250
|
|
|
310
251
|
```bash
|
|
311
|
-
activitysmith activity
|
|
312
|
-
--content-state '{
|
|
313
|
-
"title": "Sales",
|
|
314
|
-
"subtitle": "last hour",
|
|
315
|
-
"type": "stats",
|
|
316
|
-
"metrics": [
|
|
317
|
-
{ "label": "Revenue", "value": "$2430", "color": "blue" },
|
|
318
|
-
{ "label": "Orders", "value": "37", "color": "green" },
|
|
319
|
-
{ "label": "Conversion", "value": "4.8%", "color": "magenta" },
|
|
320
|
-
{ "label": "Avg Order", "value": "$65.68", "color": "yellow" },
|
|
321
|
-
{ "label": "Refunds", "value": "$84", "color": "red" },
|
|
322
|
-
{ "label": "New Buyers", "value": "18", "color": "cyan" }
|
|
323
|
-
]
|
|
324
|
-
}'
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
#### Update
|
|
328
|
-
|
|
329
|
-
```bash
|
|
330
|
-
activitysmith activity update \
|
|
331
|
-
--activity-id "<activityId>" \
|
|
332
|
-
--content-state '{
|
|
333
|
-
"title": "Sales",
|
|
334
|
-
"subtitle": "last hour",
|
|
335
|
-
"type": "stats",
|
|
336
|
-
"metrics": [
|
|
337
|
-
{ "label": "Revenue", "value": "$3180", "color": "blue" },
|
|
338
|
-
{ "label": "Orders", "value": "51", "color": "green" },
|
|
339
|
-
{ "label": "Conversion", "value": "5.2%", "color": "magenta" },
|
|
340
|
-
{ "label": "Avg Order", "value": "$62.35", "color": "yellow" },
|
|
341
|
-
{ "label": "Refunds", "value": "$126", "color": "red" },
|
|
342
|
-
{ "label": "New Buyers", "value": "24", "color": "cyan" }
|
|
343
|
-
]
|
|
344
|
-
}'
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
#### End
|
|
348
|
-
|
|
349
|
-
```bash
|
|
350
|
-
activitysmith activity end \
|
|
351
|
-
--activity-id "<activityId>" \
|
|
252
|
+
activitysmith activity stream customer-ops \
|
|
352
253
|
--content-state '{
|
|
353
|
-
"title": "
|
|
354
|
-
"
|
|
355
|
-
"type": "
|
|
356
|
-
"
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
"autoDismissMinutes": 2
|
|
254
|
+
"title": "Reactivation",
|
|
255
|
+
"message": "Lumen came back after 2 weeks",
|
|
256
|
+
"type": "alert",
|
|
257
|
+
"icon": {
|
|
258
|
+
"symbol": "cloud.sun",
|
|
259
|
+
"color": "yellow"
|
|
260
|
+
},
|
|
261
|
+
"badge": {
|
|
262
|
+
"title": "Customer",
|
|
263
|
+
"color": "magenta"
|
|
264
|
+
}
|
|
365
265
|
}'
|
|
366
266
|
```
|
|
367
267
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
Use `metrics` when you want to keep a small set of live stats visible, such as
|
|
371
|
-
server health, queue pressure, or database load.
|
|
268
|
+
The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
|
|
372
269
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics start example" width="680" />
|
|
377
|
-
</p>
|
|
270
|
+
- [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
|
|
271
|
+
- [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
|
|
272
|
+
- [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
|
|
378
273
|
|
|
379
|
-
|
|
380
|
-
activitysmith activity start \
|
|
381
|
-
--content-state '{
|
|
382
|
-
"title": "Server Health",
|
|
383
|
-
"subtitle": "prod-web-1",
|
|
384
|
-
"type": "metrics",
|
|
385
|
-
"metrics": [
|
|
386
|
-
{ "label": "CPU", "value": 9, "unit": "%" },
|
|
387
|
-
{ "label": "MEM", "value": 45, "unit": "%" }
|
|
388
|
-
]
|
|
389
|
-
}'
|
|
390
|
-
```
|
|
274
|
+
`icon` and `badge` are optional. If you omit either one, that element is not shown in the Live Activity.
|
|
391
275
|
|
|
392
|
-
|
|
276
|
+
### End Live Activity
|
|
393
277
|
|
|
394
|
-
|
|
395
|
-
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-update.png" alt="Metrics update example" width="680" />
|
|
396
|
-
</p>
|
|
278
|
+
Call `activity end-stream` with the same `stream_key` 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 `autoDismissMinutes` to choose a different dismissal time, including `0` for immediate dismissal.
|
|
397
279
|
|
|
398
280
|
```bash
|
|
399
|
-
activitysmith activity
|
|
400
|
-
--activity-id "<activityId>" \
|
|
401
|
-
--content-state '{
|
|
402
|
-
"title": "Server Health",
|
|
403
|
-
"subtitle": "prod-web-1",
|
|
404
|
-
"type": "metrics",
|
|
405
|
-
"metrics": [
|
|
406
|
-
{ "label": "CPU", "value": 76, "unit": "%" },
|
|
407
|
-
{ "label": "MEM", "value": 52, "unit": "%" }
|
|
408
|
-
]
|
|
409
|
-
}'
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
#### End
|
|
413
|
-
|
|
414
|
-
<p align="center">
|
|
415
|
-
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-end.png" alt="Metrics end example" width="680" />
|
|
416
|
-
</p>
|
|
417
|
-
|
|
418
|
-
```bash
|
|
419
|
-
activitysmith activity end \
|
|
420
|
-
--activity-id "<activityId>" \
|
|
281
|
+
activitysmith activity end-stream prod-web-1 \
|
|
421
282
|
--content-state '{
|
|
422
283
|
"title": "Server Health",
|
|
423
284
|
"subtitle": "prod-web-1",
|
|
@@ -430,133 +291,23 @@ activitysmith activity end \
|
|
|
430
291
|
}'
|
|
431
292
|
```
|
|
432
293
|
|
|
433
|
-
### Segmented Progress Type
|
|
434
|
-
|
|
435
|
-
Use `segmented_progress` for jobs and workflows that move through clear steps or
|
|
436
|
-
phases. It fits jobs like deployments, backups, ETL pipelines, and checklists.
|
|
437
|
-
`numberOfSteps` is dynamic, so you can increase or decrease it later if the
|
|
438
|
-
workflow changes.
|
|
439
|
-
|
|
440
|
-
#### Start
|
|
441
|
-
|
|
442
|
-
<p align="center">
|
|
443
|
-
<img src="https://cdn.activitysmith.com/features/start-live-activity.png" alt="Segmented progress start example" width="680" />
|
|
444
|
-
</p>
|
|
445
|
-
|
|
446
|
-
```bash
|
|
447
|
-
activitysmith activity start \
|
|
448
|
-
--content-state '{
|
|
449
|
-
"title": "Nightly database backup",
|
|
450
|
-
"subtitle": "create snapshot",
|
|
451
|
-
"numberOfSteps": 3,
|
|
452
|
-
"currentStep": 1,
|
|
453
|
-
"type": "segmented_progress",
|
|
454
|
-
"color": "yellow"
|
|
455
|
-
}'
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
#### Update
|
|
459
|
-
|
|
460
|
-
<p align="center">
|
|
461
|
-
<img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented progress update example" width="680" />
|
|
462
|
-
</p>
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
activitysmith activity update \
|
|
466
|
-
--activity-id "<activityId>" \
|
|
467
|
-
--content-state '{
|
|
468
|
-
"title": "Nightly database backup",
|
|
469
|
-
"subtitle": "upload archive",
|
|
470
|
-
"numberOfSteps": 3,
|
|
471
|
-
"currentStep": 2
|
|
472
|
-
}'
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
#### End
|
|
476
|
-
|
|
477
|
-
<p align="center">
|
|
478
|
-
<img src="https://cdn.activitysmith.com/features/end-live-activity.png" alt="Segmented progress end example" width="680" />
|
|
479
|
-
</p>
|
|
480
|
-
|
|
481
|
-
```bash
|
|
482
|
-
activitysmith activity end \
|
|
483
|
-
--activity-id "<activityId>" \
|
|
484
|
-
--content-state '{
|
|
485
|
-
"title": "Nightly database backup",
|
|
486
|
-
"subtitle": "verify restore",
|
|
487
|
-
"numberOfSteps": 3,
|
|
488
|
-
"currentStep": 3,
|
|
489
|
-
"autoDismissMinutes": 2
|
|
490
|
-
}'
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
### Progress Type
|
|
494
|
-
|
|
495
|
-
Use `progress` when the state is naturally continuous. It fits charging,
|
|
496
|
-
downloads, sync jobs, uploads, timers, and any flow where a percentage or
|
|
497
|
-
numeric range is the clearest signal.
|
|
498
|
-
|
|
499
|
-
#### Start
|
|
500
|
-
|
|
501
|
-
<p align="center">
|
|
502
|
-
<img src="https://cdn.activitysmith.com/features/progress-live-activity-start.png" alt="Progress start example" width="680" />
|
|
503
|
-
</p>
|
|
504
|
-
|
|
505
|
-
```bash
|
|
506
|
-
activitysmith activity start \
|
|
507
|
-
--content-state '{
|
|
508
|
-
"title": "EV Charging",
|
|
509
|
-
"subtitle": "Added 30 mi range",
|
|
510
|
-
"type": "progress",
|
|
511
|
-
"percentage": 15
|
|
512
|
-
}'
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
#### Update
|
|
516
|
-
|
|
517
|
-
<p align="center">
|
|
518
|
-
<img src="https://cdn.activitysmith.com/features/progress-live-activity-update.png" alt="Progress update example" width="680" />
|
|
519
|
-
</p>
|
|
520
|
-
|
|
521
|
-
```bash
|
|
522
|
-
activitysmith activity update \
|
|
523
|
-
--activity-id "<activityId>" \
|
|
524
|
-
--content-state '{
|
|
525
|
-
"title": "EV Charging",
|
|
526
|
-
"subtitle": "Added 120 mi range",
|
|
527
|
-
"percentage": 60
|
|
528
|
-
}'
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
#### End
|
|
532
|
-
|
|
533
|
-
<p align="center">
|
|
534
|
-
<img src="https://cdn.activitysmith.com/features/progress-live-activity-end.png" alt="Progress end example" width="680" />
|
|
535
|
-
</p>
|
|
536
|
-
|
|
537
|
-
```bash
|
|
538
|
-
activitysmith activity end \
|
|
539
|
-
--activity-id "<activityId>" \
|
|
540
|
-
--content-state '{
|
|
541
|
-
"title": "EV Charging",
|
|
542
|
-
"subtitle": "Added 200 mi range",
|
|
543
|
-
"percentage": 100,
|
|
544
|
-
"autoDismissMinutes": 2
|
|
545
|
-
}'
|
|
546
|
-
```
|
|
547
|
-
|
|
548
294
|
### Live Activity Action
|
|
549
295
|
|
|
550
|
-
|
|
296
|
+
Live Activities can include one optional action button. Use it to open a URL from the Live Activity or trigger a backend webhook.
|
|
297
|
+
For Alert Live Activities, set `color` in `--content-state` to tint the action button. `icon.color` and `badge.color` only affect the icon and badge.
|
|
551
298
|
|
|
552
299
|
<p align="center">
|
|
553
|
-
<img
|
|
300
|
+
<img
|
|
301
|
+
src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1"
|
|
302
|
+
alt="Live Activity with action button"
|
|
303
|
+
width="680"
|
|
304
|
+
/>
|
|
554
305
|
</p>
|
|
555
306
|
|
|
556
307
|
#### Open URL action
|
|
557
308
|
|
|
558
309
|
```bash
|
|
559
|
-
activitysmith activity
|
|
310
|
+
activitysmith activity stream prod-web-1 \
|
|
560
311
|
--content-state '{
|
|
561
312
|
"title": "Server Health",
|
|
562
313
|
"subtitle": "prod-web-1",
|
|
@@ -575,16 +326,12 @@ activitysmith activity start \
|
|
|
575
326
|
|
|
576
327
|
#### Webhook action
|
|
577
328
|
|
|
578
|
-
<p align="center">
|
|
579
|
-
<img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action" width="680" />
|
|
580
|
-
</p>
|
|
581
|
-
|
|
582
329
|
```bash
|
|
583
|
-
activitysmith activity
|
|
584
|
-
--activity-id "<activityId>" \
|
|
330
|
+
activitysmith activity stream search-reindex \
|
|
585
331
|
--content-state '{
|
|
586
332
|
"title": "Reindexing product search",
|
|
587
333
|
"subtitle": "Shard 7 of 12",
|
|
334
|
+
"type": "segmented_progress",
|
|
588
335
|
"numberOfSteps": 12,
|
|
589
336
|
"currentStep": 7
|
|
590
337
|
}' \
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Command-line interface for ActivitySmith. Send push notifications and manage Live Activities from your terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activitysmith",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"lint": "node --check src/cli.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"activitysmith": "^1.
|
|
43
|
+
"activitysmith": "^1.4.0",
|
|
44
44
|
"commander": "^12.1.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/cli.js
CHANGED
|
@@ -106,6 +106,11 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
|
|
|
106
106
|
.option("--title <title>", "Content state title")
|
|
107
107
|
.option("--subtitle <subtitle>", "Content state subtitle")
|
|
108
108
|
.option("--type <type>", "Content state type")
|
|
109
|
+
.option("--message <message>", "Alert message")
|
|
110
|
+
.option("--icon-symbol <symbol>", "Alert SF Symbol name")
|
|
111
|
+
.option("--icon-color <color>", "Alert icon color")
|
|
112
|
+
.option("--badge-title <title>", "Alert badge title")
|
|
113
|
+
.option("--badge-color <color>", "Alert badge color")
|
|
109
114
|
.option(
|
|
110
115
|
"--number-of-steps <number>",
|
|
111
116
|
"Content state number of steps",
|
|
@@ -236,9 +241,10 @@ const isNonEmptyString = (value) =>
|
|
|
236
241
|
const hasOwn = (object, key) =>
|
|
237
242
|
Object.prototype.hasOwnProperty.call(object, key);
|
|
238
243
|
|
|
239
|
-
const
|
|
244
|
+
const liveActivityColors = new Set([
|
|
240
245
|
"blue",
|
|
241
246
|
"cyan",
|
|
247
|
+
"gray",
|
|
242
248
|
"green",
|
|
243
249
|
"lime",
|
|
244
250
|
"magenta",
|
|
@@ -248,6 +254,8 @@ const liveActivityMetricColors = new Set([
|
|
|
248
254
|
"yellow",
|
|
249
255
|
]);
|
|
250
256
|
|
|
257
|
+
const liveActivityColorList = [...liveActivityColors].join(", ");
|
|
258
|
+
|
|
251
259
|
const validateContentState = (contentState, mode) => {
|
|
252
260
|
const normalizedType =
|
|
253
261
|
typeof contentState.type === "string" ? contentState.type.trim() : undefined;
|
|
@@ -261,13 +269,17 @@ const validateContentState = (contentState, mode) => {
|
|
|
261
269
|
normalizedType !== "segmented_progress" &&
|
|
262
270
|
normalizedType !== "progress" &&
|
|
263
271
|
normalizedType !== "metrics" &&
|
|
264
|
-
normalizedType !== "stats"
|
|
272
|
+
normalizedType !== "stats" &&
|
|
273
|
+
normalizedType !== "alert"
|
|
265
274
|
) {
|
|
266
275
|
throw new Error(
|
|
267
|
-
"contentState.type must be one of: segmented_progress, progress, metrics, stats"
|
|
276
|
+
"contentState.type must be one of: segmented_progress, progress, metrics, stats, alert"
|
|
268
277
|
);
|
|
269
278
|
}
|
|
270
279
|
|
|
280
|
+
const hasMessage = hasOwn(contentState, "message");
|
|
281
|
+
const hasIcon = hasOwn(contentState, "icon");
|
|
282
|
+
const hasBadge = hasOwn(contentState, "badge");
|
|
271
283
|
const hasNumberOfSteps = hasOwn(contentState, "numberOfSteps");
|
|
272
284
|
const hasCurrentStep = hasOwn(contentState, "currentStep");
|
|
273
285
|
const hasPercentage = hasOwn(contentState, "percentage");
|
|
@@ -303,6 +315,41 @@ const validateContentState = (contentState, mode) => {
|
|
|
303
315
|
|
|
304
316
|
const hasSegmentedFields = hasNumberOfSteps || hasCurrentStep || hasStepColor;
|
|
305
317
|
const hasProgressFields = hasPercentage || hasValue || hasUpperLimit;
|
|
318
|
+
const hasAlertFields = hasMessage || hasIcon || hasBadge;
|
|
319
|
+
|
|
320
|
+
if (hasIcon) {
|
|
321
|
+
assertPlainObject(contentState.icon, "contentState.icon");
|
|
322
|
+
if (!isNonEmptyString(contentState.icon.symbol)) {
|
|
323
|
+
throw new Error("contentState.icon.symbol is required");
|
|
324
|
+
}
|
|
325
|
+
if (contentState.icon.color !== undefined) {
|
|
326
|
+
if (!isNonEmptyString(contentState.icon.color)) {
|
|
327
|
+
throw new Error("contentState.icon.color must be a string");
|
|
328
|
+
}
|
|
329
|
+
if (!liveActivityColors.has(contentState.icon.color.trim())) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
`contentState.icon.color must be one of: ${liveActivityColorList}`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (hasBadge) {
|
|
338
|
+
assertPlainObject(contentState.badge, "contentState.badge");
|
|
339
|
+
if (!isNonEmptyString(contentState.badge.title)) {
|
|
340
|
+
throw new Error("contentState.badge.title is required");
|
|
341
|
+
}
|
|
342
|
+
if (contentState.badge.color !== undefined) {
|
|
343
|
+
if (!isNonEmptyString(contentState.badge.color)) {
|
|
344
|
+
throw new Error("contentState.badge.color must be a string");
|
|
345
|
+
}
|
|
346
|
+
if (!liveActivityColors.has(contentState.badge.color.trim())) {
|
|
347
|
+
throw new Error(
|
|
348
|
+
`contentState.badge.color must be one of: ${liveActivityColorList}`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
306
353
|
|
|
307
354
|
if (hasSegmentedFields && hasProgressFields) {
|
|
308
355
|
throw new Error(
|
|
@@ -316,6 +363,15 @@ const validateContentState = (contentState, mode) => {
|
|
|
316
363
|
);
|
|
317
364
|
}
|
|
318
365
|
|
|
366
|
+
if (
|
|
367
|
+
hasAlertFields &&
|
|
368
|
+
(hasMetrics || hasSegmentedFields || hasProgressFields || hasStepColor)
|
|
369
|
+
) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
"Do not mix alert fields with metrics, segmented_progress, or progress fields in the same contentState"
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
319
375
|
if (hasMetrics) {
|
|
320
376
|
if (!Array.isArray(contentState.metrics) || contentState.metrics.length === 0) {
|
|
321
377
|
throw new Error("contentState.metrics must be a non-empty array");
|
|
@@ -348,11 +404,9 @@ const validateContentState = (contentState, mode) => {
|
|
|
348
404
|
if (!isNonEmptyString(metric.color)) {
|
|
349
405
|
throw new Error(`contentState.metrics[${index}].color must be a string`);
|
|
350
406
|
}
|
|
351
|
-
if (!
|
|
407
|
+
if (!liveActivityColors.has(metric.color.trim())) {
|
|
352
408
|
throw new Error(
|
|
353
|
-
`contentState.metrics[${index}].color must be one of: ${
|
|
354
|
-
...liveActivityMetricColors,
|
|
355
|
-
].join(", ")}`
|
|
409
|
+
`contentState.metrics[${index}].color must be one of: ${liveActivityColorList}`
|
|
356
410
|
);
|
|
357
411
|
}
|
|
358
412
|
}
|
|
@@ -382,6 +436,13 @@ const validateContentState = (contentState, mode) => {
|
|
|
382
436
|
return;
|
|
383
437
|
}
|
|
384
438
|
|
|
439
|
+
if (effectiveType === "alert") {
|
|
440
|
+
if (!isNonEmptyString(contentState.message)) {
|
|
441
|
+
throw new Error(`alert ${mode} requires contentState.message`);
|
|
442
|
+
}
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
385
446
|
if (!hasPercentage && !hasValue) {
|
|
386
447
|
throw new Error(
|
|
387
448
|
`progress ${mode} requires contentState.percentage, or contentState.value with contentState.upperLimit`
|
|
@@ -415,9 +476,16 @@ const validateContentState = (contentState, mode) => {
|
|
|
415
476
|
return;
|
|
416
477
|
}
|
|
417
478
|
|
|
418
|
-
if (
|
|
479
|
+
if (effectiveType === "alert") {
|
|
480
|
+
if (!isNonEmptyString(contentState.message)) {
|
|
481
|
+
throw new Error(`alert ${mode} requires contentState.message`);
|
|
482
|
+
}
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (!hasSegmentedFields && !hasProgressFields && !hasMetrics && !hasAlertFields) {
|
|
419
487
|
throw new Error(
|
|
420
|
-
`contentState for activity ${mode} must include metrics, segmented_progress fields, or
|
|
488
|
+
`contentState for activity ${mode} must include metrics, segmented_progress fields, progress fields, or alert fields`
|
|
421
489
|
);
|
|
422
490
|
}
|
|
423
491
|
|
|
@@ -436,6 +504,10 @@ const validateContentState = (contentState, mode) => {
|
|
|
436
504
|
`progress ${mode} requires contentState.percentage, or contentState.value with contentState.upperLimit`
|
|
437
505
|
);
|
|
438
506
|
}
|
|
507
|
+
|
|
508
|
+
if (hasAlertFields && !isNonEmptyString(contentState.message)) {
|
|
509
|
+
throw new Error(`alert ${mode} requires contentState.message`);
|
|
510
|
+
}
|
|
439
511
|
};
|
|
440
512
|
|
|
441
513
|
const parseAction = (value, label) => {
|
|
@@ -560,6 +632,30 @@ const buildContentStateFromOptions = (options) => {
|
|
|
560
632
|
contentState.type = options.type;
|
|
561
633
|
}
|
|
562
634
|
|
|
635
|
+
if (options.message !== undefined) {
|
|
636
|
+
contentState.message = options.message;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
if (options.iconSymbol !== undefined || options.iconColor !== undefined) {
|
|
640
|
+
contentState.icon = {};
|
|
641
|
+
if (options.iconSymbol !== undefined) {
|
|
642
|
+
contentState.icon.symbol = options.iconSymbol;
|
|
643
|
+
}
|
|
644
|
+
if (options.iconColor !== undefined) {
|
|
645
|
+
contentState.icon.color = options.iconColor;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (options.badgeTitle !== undefined || options.badgeColor !== undefined) {
|
|
650
|
+
contentState.badge = {};
|
|
651
|
+
if (options.badgeTitle !== undefined) {
|
|
652
|
+
contentState.badge.title = options.badgeTitle;
|
|
653
|
+
}
|
|
654
|
+
if (options.badgeColor !== undefined) {
|
|
655
|
+
contentState.badge.color = options.badgeColor;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
563
659
|
if (options.numberOfSteps !== undefined) {
|
|
564
660
|
contentState.numberOfSteps = options.numberOfSteps;
|
|
565
661
|
}
|
|
@@ -957,7 +1053,6 @@ program
|
|
|
957
1053
|
response?.devicesNotified !== undefined
|
|
958
1054
|
? `Devices notified: ${response.devicesNotified}`
|
|
959
1055
|
: null,
|
|
960
|
-
response?.timestamp ? `Timestamp: ${response.timestamp}` : null,
|
|
961
1056
|
]);
|
|
962
1057
|
} catch (error) {
|
|
963
1058
|
await handleError(error, globalOptions);
|