activitysmith-cli 1.6.0 → 1.8.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 +133 -14
- package/package.json +2 -2
- package/src/cli.js +180 -16
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
- [Install](#install)
|
|
8
|
-
- [
|
|
8
|
+
- [Agent Skill](#agent-skill)
|
|
9
9
|
- [Auth](#auth)
|
|
10
10
|
- [Push Notifications](#push-notifications)
|
|
11
11
|
- [Send Push Notification](#send-push-notification)
|
|
@@ -29,12 +29,33 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
|
|
|
29
29
|
npm install -g activitysmith-cli
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## Agent Skill
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<img src="https://cdn.activitysmith.com/features/apple-shortcut-actions.png" alt="ActivitySmith Push Notification Actions with an Apple Shortcut action" width="680" />
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
The ActivitySmith skill helps coding agents decide when and how to notify you.
|
|
39
|
+
|
|
40
|
+
Use it for prompts like:
|
|
41
|
+
|
|
42
|
+
- "Notify me when you're done."
|
|
43
|
+
- "Send me a push notification if you get blocked."
|
|
44
|
+
- "When the task finishes, the notification tap should run my Test Shortcut."
|
|
45
|
+
- "Show progress on my Lock Screen while you work."
|
|
46
|
+
|
|
47
|
+
The skill maps those requests to the CLI:
|
|
48
|
+
|
|
49
|
+
- Push Notifications for completion, blockers, and review requests
|
|
50
|
+
- `shortcuts://` redirection for a specific iPhone Shortcut
|
|
51
|
+
- action buttons for follow-up links or Shortcut buttons
|
|
52
|
+
- Live Activities for long-running progress
|
|
53
|
+
- widget metrics for values that should stay visible
|
|
33
54
|
|
|
34
55
|
Install the public skill from this repo:
|
|
35
56
|
|
|
36
57
|
```bash
|
|
37
|
-
npx skills add ActivitySmithHQ/activitysmith-cli --skill activitysmith
|
|
58
|
+
npx -y skills@latest add ActivitySmithHQ/activitysmith-cli --skill activitysmith
|
|
38
59
|
```
|
|
39
60
|
|
|
40
61
|
Skill path in this repo:
|
|
@@ -43,7 +64,7 @@ Skill path in this repo:
|
|
|
43
64
|
skills/activitysmith
|
|
44
65
|
```
|
|
45
66
|
|
|
46
|
-
The skill is agent-neutral and uses `ACTIVITYSMITH_API_KEY` auth plus the same CLI commands shown below.
|
|
67
|
+
The skill is agent-neutral and recipe-driven. It uses `ACTIVITYSMITH_API_KEY` auth plus the same CLI commands shown below.
|
|
47
68
|
|
|
48
69
|
## Auth
|
|
49
70
|
|
|
@@ -98,7 +119,7 @@ What will work:
|
|
|
98
119
|
<img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
|
|
99
120
|
</p>
|
|
100
121
|
|
|
101
|
-
|
|
122
|
+
Push notification `--redirection` and `--actions` are optional. Use them to open HTTPS URLs, run a specific iPhone Shortcut with a `shortcuts://run-shortcut?name=...` URL, or trigger backend webhook workflows.
|
|
102
123
|
Webhooks are executed by the ActivitySmith backend.
|
|
103
124
|
|
|
104
125
|
```bash
|
|
@@ -112,6 +133,11 @@ activitysmith push \
|
|
|
112
133
|
"type": "open_url",
|
|
113
134
|
"url": "https://github.com/org/repo/actions/runs/123456789"
|
|
114
135
|
},
|
|
136
|
+
{
|
|
137
|
+
"title": "Chat with Jarvis",
|
|
138
|
+
"type": "open_url",
|
|
139
|
+
"url": "shortcuts://run-shortcut?name=Jarvis"
|
|
140
|
+
},
|
|
115
141
|
{
|
|
116
142
|
"title": "Create Incident",
|
|
117
143
|
"type": "webhook",
|
|
@@ -137,13 +163,14 @@ activitysmith push \
|
|
|
137
163
|
|
|
138
164
|
## Live Activities
|
|
139
165
|
|
|
140
|
-
There are
|
|
166
|
+
There are six types of Live Activities:
|
|
141
167
|
|
|
142
168
|
- `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
|
|
143
169
|
- `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
|
|
144
170
|
- `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
|
|
145
171
|
- `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
|
|
146
172
|
- `alert`: best for status updates, such as feature adoption, reactivation, onboarding blockers, incidents, escalations, and other operational states
|
|
173
|
+
- `timer`: best for countdowns and elapsed runtime, like benchmark runs, uploads, backups, transcodes, and long-running jobs
|
|
147
174
|
|
|
148
175
|
### Start & Update Live Activity
|
|
149
176
|
|
|
@@ -267,6 +294,31 @@ activitysmith activity stream customer-ops \
|
|
|
267
294
|
}'
|
|
268
295
|
```
|
|
269
296
|
|
|
297
|
+
#### Timer
|
|
298
|
+
|
|
299
|
+
<p align="center">
|
|
300
|
+
<img
|
|
301
|
+
src="https://cdn.activitysmith.com/features/timer-live-activity.png"
|
|
302
|
+
alt="Timer Live Activity showing a benchmark run countdown"
|
|
303
|
+
width="680"
|
|
304
|
+
/>
|
|
305
|
+
</p>
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
activitysmith activity stream benchmark-run \
|
|
309
|
+
--content-state '{
|
|
310
|
+
"title": "Benchmark Run",
|
|
311
|
+
"subtitle": "sampling",
|
|
312
|
+
"type": "timer",
|
|
313
|
+
"durationSeconds": 300,
|
|
314
|
+
"color": "cyan"
|
|
315
|
+
}'
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
For a countdown, send `duration_seconds`. You can update `title`, `subtitle`, `color`, or any other visible field as the work changes. Leave `duration_seconds` out unless you want to change the timer.
|
|
319
|
+
|
|
320
|
+
To start at 00:00 and count up, set `counts_down: false` and leave out `duration_seconds`.
|
|
321
|
+
|
|
270
322
|
### End Live Activity
|
|
271
323
|
|
|
272
324
|
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.
|
|
@@ -287,12 +339,15 @@ activitysmith activity end-stream prod-web-1 \
|
|
|
287
339
|
|
|
288
340
|
### Live Activity Action
|
|
289
341
|
|
|
290
|
-
Live Activities can include
|
|
291
|
-
|
|
342
|
+
Live Activities can include an action button.
|
|
343
|
+
|
|
344
|
+
- `open_url`: open an HTTPS URL.
|
|
345
|
+
- `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
|
|
346
|
+
- `webhook`: trigger a backend GET/POST workflow.
|
|
292
347
|
|
|
293
348
|
<p align="center">
|
|
294
349
|
<img
|
|
295
|
-
src="https://cdn.activitysmith.com/features/live-activity-
|
|
350
|
+
src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png"
|
|
296
351
|
alt="Live Activity with action button"
|
|
297
352
|
width="680"
|
|
298
353
|
/>
|
|
@@ -312,12 +367,30 @@ activitysmith activity stream prod-web-1 \
|
|
|
312
367
|
]
|
|
313
368
|
}' \
|
|
314
369
|
--action '{
|
|
315
|
-
"title": "
|
|
370
|
+
"title": "Dashboard",
|
|
316
371
|
"type": "open_url",
|
|
317
372
|
"url": "https://ops.example.com/servers/prod-web-1"
|
|
318
373
|
}'
|
|
319
374
|
```
|
|
320
375
|
|
|
376
|
+
#### Apple Shortcut action
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
activitysmith activity stream deploy-payments-api \
|
|
380
|
+
--content-state '{
|
|
381
|
+
"title": "Deploying payments-api",
|
|
382
|
+
"subtitle": "Running database migrations",
|
|
383
|
+
"type": "segmented_progress",
|
|
384
|
+
"numberOfSteps": 5,
|
|
385
|
+
"currentStep": 3
|
|
386
|
+
}' \
|
|
387
|
+
--action '{
|
|
388
|
+
"title": "Chat with Jarvis",
|
|
389
|
+
"type": "open_url",
|
|
390
|
+
"url": "shortcuts://run-shortcut?name=Jarvis"
|
|
391
|
+
}'
|
|
392
|
+
```
|
|
393
|
+
|
|
321
394
|
#### Webhook action
|
|
322
395
|
|
|
323
396
|
```bash
|
|
@@ -341,6 +414,46 @@ activitysmith activity stream search-reindex \
|
|
|
341
414
|
}'
|
|
342
415
|
```
|
|
343
416
|
|
|
417
|
+
#### Secondary action
|
|
418
|
+
|
|
419
|
+
<p align="center">
|
|
420
|
+
<img
|
|
421
|
+
src="https://cdn.activitysmith.com/features/live-activity-secondary-action.png"
|
|
422
|
+
alt="Alert Live Activity with primary and secondary action buttons"
|
|
423
|
+
width="680"
|
|
424
|
+
/>
|
|
425
|
+
</p>
|
|
426
|
+
|
|
427
|
+
Use `--secondary-action` when you want a second button beside the primary `--action`.
|
|
428
|
+
|
|
429
|
+
The secondary action button is supported for `alert`, `progress`, and `segmented_progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
activitysmith activity stream agent-approval \
|
|
433
|
+
--content-state '{
|
|
434
|
+
"title": "Approval Needed",
|
|
435
|
+
"message": "Should I send the follow-up email to Brightlane?",
|
|
436
|
+
"type": "alert",
|
|
437
|
+
"color": "green",
|
|
438
|
+
"icon": { "symbol": "sparkles", "color": "green" },
|
|
439
|
+
"badge": { "title": "Agent", "color": "green" }
|
|
440
|
+
}' \
|
|
441
|
+
--action '{
|
|
442
|
+
"title": "Send",
|
|
443
|
+
"type": "webhook",
|
|
444
|
+
"url": "https://hooks.example.com/agent/approval",
|
|
445
|
+
"method": "POST",
|
|
446
|
+
"body": { "decision": "send" }
|
|
447
|
+
}' \
|
|
448
|
+
--secondary-action '{
|
|
449
|
+
"title": "Deny",
|
|
450
|
+
"type": "webhook",
|
|
451
|
+
"url": "https://hooks.example.com/agent/approval",
|
|
452
|
+
"method": "POST",
|
|
453
|
+
"body": { "decision": "deny" }
|
|
454
|
+
}'
|
|
455
|
+
```
|
|
456
|
+
|
|
344
457
|
### Icons and Badges
|
|
345
458
|
|
|
346
459
|
Add more context to Live Activities with icons and badges.
|
|
@@ -470,14 +583,20 @@ Or use flags to build the rest of the payload:
|
|
|
470
583
|
- `--percentage <number>`
|
|
471
584
|
- `--value <number>`
|
|
472
585
|
- `--upper-limit <number>`
|
|
586
|
+
- `--duration-seconds <number>`
|
|
587
|
+
- `--counts-down <true|false>`
|
|
473
588
|
- `--color <color>`
|
|
474
589
|
- `--step-color <color>`
|
|
475
590
|
- `--auto-dismiss-minutes <number>`
|
|
476
591
|
|
|
592
|
+
For `timer`, use `--duration-seconds` for a countdown. To start at 00:00 and count up, use `--counts-down false` and leave out `--duration-seconds`.
|
|
593
|
+
|
|
477
594
|
Live Activity action options:
|
|
478
595
|
|
|
479
596
|
- `--action <json>`
|
|
480
597
|
- `--action-file <path>`
|
|
598
|
+
- `--secondary-action <json>`
|
|
599
|
+
- `--secondary-action-file <path>`
|
|
481
600
|
|
|
482
601
|
Targeting options:
|
|
483
602
|
|
|
@@ -490,10 +609,10 @@ Widget metric options:
|
|
|
490
609
|
|
|
491
610
|
Required fields:
|
|
492
611
|
|
|
493
|
-
- `activity stream`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`,
|
|
494
|
-
- `activity start`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`,
|
|
495
|
-
- `activity update`: `--title`, plus `--metrics`, `--current-step`, `--percentage`,
|
|
496
|
-
- `activity end`: `--title`, plus `--metrics`, `--current-step`, `--percentage`,
|
|
612
|
+
- `activity stream`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
|
|
613
|
+
- `activity start`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
|
|
614
|
+
- `activity update`: `--title`, plus `--metrics`, `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
|
|
615
|
+
- `activity end`: `--title`, plus `--metrics`, `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
|
|
497
616
|
- `activity end-stream`: no content state is required, but if you provide one it follows the same rules as `activity end`
|
|
498
617
|
|
|
499
618
|
## Output
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.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.8.0",
|
|
44
44
|
"commander": "^12.1.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/cli.js
CHANGED
|
@@ -37,6 +37,22 @@ const parseNumberOption = (label) => (value) => {
|
|
|
37
37
|
return parsed;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const parseBooleanOption = (label) => (value) => {
|
|
41
|
+
if (typeof value !== "string") {
|
|
42
|
+
throw new InvalidArgumentError(`${label} must be true or false`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const normalized = value.trim().toLowerCase();
|
|
46
|
+
if (normalized === "true") {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (normalized === "false") {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
throw new InvalidArgumentError(`${label} must be true or false`);
|
|
54
|
+
};
|
|
55
|
+
|
|
40
56
|
const parseChannelsOption = (value) => {
|
|
41
57
|
if (typeof value !== "string") {
|
|
42
58
|
throw new InvalidArgumentError("channels must be a comma-separated string");
|
|
@@ -167,6 +183,16 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
|
|
|
167
183
|
"Content state upper limit",
|
|
168
184
|
parseNumberOption("upper-limit")
|
|
169
185
|
)
|
|
186
|
+
.option(
|
|
187
|
+
"--duration-seconds <number>",
|
|
188
|
+
"Timer duration in seconds",
|
|
189
|
+
parseNumberOption("duration-seconds")
|
|
190
|
+
)
|
|
191
|
+
.option(
|
|
192
|
+
"--counts-down <boolean>",
|
|
193
|
+
"Set to false for an elapsed timer",
|
|
194
|
+
parseBooleanOption("counts-down")
|
|
195
|
+
)
|
|
170
196
|
.option("--color <color>", "Content state color")
|
|
171
197
|
.option("--step-color <color>", "Content state step color");
|
|
172
198
|
|
|
@@ -184,7 +210,15 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
|
|
|
184
210
|
const addLiveActivityActionOptions = (command) =>
|
|
185
211
|
command
|
|
186
212
|
.option("--action <json>", "Live Activity action as JSON object")
|
|
187
|
-
.option("--action-file <path>", "Live Activity action JSON file path")
|
|
213
|
+
.option("--action-file <path>", "Live Activity action JSON file path")
|
|
214
|
+
.option(
|
|
215
|
+
"--secondary-action <json>",
|
|
216
|
+
"Secondary Live Activity action as JSON object"
|
|
217
|
+
)
|
|
218
|
+
.option(
|
|
219
|
+
"--secondary-action-file <path>",
|
|
220
|
+
"Secondary Live Activity action JSON file path"
|
|
221
|
+
);
|
|
188
222
|
|
|
189
223
|
const getApiKey = (options) =>
|
|
190
224
|
options.apiKey || process.env.ACTIVITYSMITH_API_KEY;
|
|
@@ -301,10 +335,11 @@ const validateContentState = (contentState, mode) => {
|
|
|
301
335
|
normalizedType !== "progress" &&
|
|
302
336
|
normalizedType !== "metrics" &&
|
|
303
337
|
normalizedType !== "stats" &&
|
|
304
|
-
normalizedType !== "alert"
|
|
338
|
+
normalizedType !== "alert" &&
|
|
339
|
+
normalizedType !== "timer"
|
|
305
340
|
) {
|
|
306
341
|
throw new Error(
|
|
307
|
-
"contentState.type must be one of: segmented_progress, progress, metrics, stats, alert"
|
|
342
|
+
"contentState.type must be one of: segmented_progress, progress, metrics, stats, alert, timer"
|
|
308
343
|
);
|
|
309
344
|
}
|
|
310
345
|
|
|
@@ -318,6 +353,9 @@ const validateContentState = (contentState, mode) => {
|
|
|
318
353
|
const hasUpperLimit = hasOwn(contentState, "upperLimit");
|
|
319
354
|
const hasStepColor = hasOwn(contentState, "stepColor");
|
|
320
355
|
const hasMetrics = hasOwn(contentState, "metrics");
|
|
356
|
+
const hasDurationSeconds = hasOwn(contentState, "durationSeconds");
|
|
357
|
+
const hasCountsDown = hasOwn(contentState, "countsDown");
|
|
358
|
+
const hasTimerFields = hasDurationSeconds || hasCountsDown;
|
|
321
359
|
|
|
322
360
|
if (hasValue !== hasUpperLimit) {
|
|
323
361
|
throw new Error(
|
|
@@ -344,6 +382,14 @@ const validateContentState = (contentState, mode) => {
|
|
|
344
382
|
throw new Error("contentState.upperLimit must be greater than 0");
|
|
345
383
|
}
|
|
346
384
|
|
|
385
|
+
if (hasDurationSeconds && contentState.durationSeconds <= 0) {
|
|
386
|
+
throw new Error("contentState.durationSeconds must be greater than 0");
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (hasCountsDown && typeof contentState.countsDown !== "boolean") {
|
|
390
|
+
throw new Error("contentState.countsDown must be true or false");
|
|
391
|
+
}
|
|
392
|
+
|
|
347
393
|
const hasSegmentedFields = hasNumberOfSteps || hasCurrentStep || hasStepColor;
|
|
348
394
|
const hasProgressFields = hasPercentage || hasValue || hasUpperLimit;
|
|
349
395
|
const hasAlertFields = hasMessage || hasIcon || hasBadge;
|
|
@@ -474,6 +520,15 @@ const validateContentState = (contentState, mode) => {
|
|
|
474
520
|
return;
|
|
475
521
|
}
|
|
476
522
|
|
|
523
|
+
if (effectiveType === "timer") {
|
|
524
|
+
if (!hasDurationSeconds && contentState.countsDown !== false) {
|
|
525
|
+
throw new Error(
|
|
526
|
+
`timer ${mode} requires contentState.durationSeconds, or contentState.countsDown=false`
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
|
|
477
532
|
if (!hasPercentage && !hasValue) {
|
|
478
533
|
throw new Error(
|
|
479
534
|
`progress ${mode} requires contentState.percentage, or contentState.value with contentState.upperLimit`
|
|
@@ -514,9 +569,19 @@ const validateContentState = (contentState, mode) => {
|
|
|
514
569
|
return;
|
|
515
570
|
}
|
|
516
571
|
|
|
517
|
-
if (
|
|
572
|
+
if (effectiveType === "timer") {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (
|
|
577
|
+
!hasSegmentedFields &&
|
|
578
|
+
!hasProgressFields &&
|
|
579
|
+
!hasMetrics &&
|
|
580
|
+
!hasAlertFields &&
|
|
581
|
+
!hasTimerFields
|
|
582
|
+
) {
|
|
518
583
|
throw new Error(
|
|
519
|
-
`contentState for activity ${mode} must include metrics, segmented_progress fields, progress fields, or
|
|
584
|
+
`contentState for activity ${mode} must include metrics, segmented_progress fields, progress fields, alert fields, or timer fields`
|
|
520
585
|
);
|
|
521
586
|
}
|
|
522
587
|
|
|
@@ -638,6 +703,32 @@ const loadLiveActivityAction = async (options) => {
|
|
|
638
703
|
return parseAction(action, "action");
|
|
639
704
|
};
|
|
640
705
|
|
|
706
|
+
const loadLiveActivitySecondaryAction = async (options) => {
|
|
707
|
+
if (options.secondaryAction && options.secondaryActionFile) {
|
|
708
|
+
throw new Error(
|
|
709
|
+
"Provide either --secondary-action or --secondary-action-file, not both."
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
let action;
|
|
714
|
+
if (options.secondaryActionFile) {
|
|
715
|
+
action = await readJsonFile(
|
|
716
|
+
options.secondaryActionFile,
|
|
717
|
+
"secondary-action-file"
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (options.secondaryAction) {
|
|
722
|
+
action = parseJsonString(options.secondaryAction, "secondary-action");
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (action === undefined) {
|
|
726
|
+
return undefined;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
return parseAction(action, "secondary_action");
|
|
730
|
+
};
|
|
731
|
+
|
|
641
732
|
const validatePushMediaOptions = ({ media, actions }) => {
|
|
642
733
|
if (media === undefined || actions === undefined) {
|
|
643
734
|
return;
|
|
@@ -707,6 +798,14 @@ const buildContentStateFromOptions = (options) => {
|
|
|
707
798
|
contentState.upperLimit = options.upperLimit;
|
|
708
799
|
}
|
|
709
800
|
|
|
801
|
+
if (options.durationSeconds !== undefined) {
|
|
802
|
+
contentState.durationSeconds = options.durationSeconds;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
if (options.countsDown !== undefined) {
|
|
806
|
+
contentState.countsDown = options.countsDown;
|
|
807
|
+
}
|
|
808
|
+
|
|
710
809
|
if (options.color !== undefined) {
|
|
711
810
|
contentState.color = options.color;
|
|
712
811
|
}
|
|
@@ -745,6 +844,8 @@ const toApiContentState = (contentState) => {
|
|
|
745
844
|
upperLimit: "upper_limit",
|
|
746
845
|
stepColor: "step_color",
|
|
747
846
|
autoDismissMinutes: "auto_dismiss_minutes",
|
|
847
|
+
durationSeconds: "duration_seconds",
|
|
848
|
+
countsDown: "counts_down",
|
|
748
849
|
};
|
|
749
850
|
|
|
750
851
|
const mapped = {};
|
|
@@ -761,7 +862,11 @@ const toApiContentState = (contentState) => {
|
|
|
761
862
|
return mapped;
|
|
762
863
|
};
|
|
763
864
|
|
|
764
|
-
const toApiLiveActivityStartRequest = (
|
|
865
|
+
const toApiLiveActivityStartRequest = (
|
|
866
|
+
contentState,
|
|
867
|
+
action,
|
|
868
|
+
secondaryAction
|
|
869
|
+
) => {
|
|
765
870
|
const request = {
|
|
766
871
|
content_state: toApiContentState(contentState),
|
|
767
872
|
};
|
|
@@ -770,6 +875,10 @@ const toApiLiveActivityStartRequest = (contentState, action) => {
|
|
|
770
875
|
request.action = action;
|
|
771
876
|
}
|
|
772
877
|
|
|
878
|
+
if (secondaryAction !== undefined) {
|
|
879
|
+
request.secondary_action = secondaryAction;
|
|
880
|
+
}
|
|
881
|
+
|
|
773
882
|
return request;
|
|
774
883
|
};
|
|
775
884
|
|
|
@@ -786,7 +895,12 @@ const withTargetChannels = (request, channels) => {
|
|
|
786
895
|
};
|
|
787
896
|
};
|
|
788
897
|
|
|
789
|
-
const toApiLiveActivityUpdateRequest = (
|
|
898
|
+
const toApiLiveActivityUpdateRequest = (
|
|
899
|
+
activityId,
|
|
900
|
+
contentState,
|
|
901
|
+
action,
|
|
902
|
+
secondaryAction
|
|
903
|
+
) => {
|
|
790
904
|
const request = {
|
|
791
905
|
activity_id: activityId,
|
|
792
906
|
content_state: toApiContentState(contentState),
|
|
@@ -796,10 +910,19 @@ const toApiLiveActivityUpdateRequest = (activityId, contentState, action) => {
|
|
|
796
910
|
request.action = action;
|
|
797
911
|
}
|
|
798
912
|
|
|
913
|
+
if (secondaryAction !== undefined) {
|
|
914
|
+
request.secondary_action = secondaryAction;
|
|
915
|
+
}
|
|
916
|
+
|
|
799
917
|
return request;
|
|
800
918
|
};
|
|
801
919
|
|
|
802
|
-
const toApiLiveActivityEndRequest = (
|
|
920
|
+
const toApiLiveActivityEndRequest = (
|
|
921
|
+
activityId,
|
|
922
|
+
contentState,
|
|
923
|
+
action,
|
|
924
|
+
secondaryAction
|
|
925
|
+
) => {
|
|
803
926
|
const request = {
|
|
804
927
|
activity_id: activityId,
|
|
805
928
|
content_state: toApiContentState(contentState),
|
|
@@ -809,10 +932,18 @@ const toApiLiveActivityEndRequest = (activityId, contentState, action) => {
|
|
|
809
932
|
request.action = action;
|
|
810
933
|
}
|
|
811
934
|
|
|
935
|
+
if (secondaryAction !== undefined) {
|
|
936
|
+
request.secondary_action = secondaryAction;
|
|
937
|
+
}
|
|
938
|
+
|
|
812
939
|
return request;
|
|
813
940
|
};
|
|
814
941
|
|
|
815
|
-
const toApiLiveActivityStreamRequest = (
|
|
942
|
+
const toApiLiveActivityStreamRequest = (
|
|
943
|
+
contentState,
|
|
944
|
+
action,
|
|
945
|
+
secondaryAction
|
|
946
|
+
) => {
|
|
816
947
|
const request = {
|
|
817
948
|
content_state: toApiContentState(contentState),
|
|
818
949
|
};
|
|
@@ -821,10 +952,18 @@ const toApiLiveActivityStreamRequest = (contentState, action) => {
|
|
|
821
952
|
request.action = action;
|
|
822
953
|
}
|
|
823
954
|
|
|
955
|
+
if (secondaryAction !== undefined) {
|
|
956
|
+
request.secondary_action = secondaryAction;
|
|
957
|
+
}
|
|
958
|
+
|
|
824
959
|
return request;
|
|
825
960
|
};
|
|
826
961
|
|
|
827
|
-
const toApiLiveActivityStreamDeleteRequest = (
|
|
962
|
+
const toApiLiveActivityStreamDeleteRequest = (
|
|
963
|
+
contentState,
|
|
964
|
+
action,
|
|
965
|
+
secondaryAction
|
|
966
|
+
) => {
|
|
828
967
|
const request = {};
|
|
829
968
|
|
|
830
969
|
if (contentState !== undefined) {
|
|
@@ -835,6 +974,10 @@ const toApiLiveActivityStreamDeleteRequest = (contentState, action) => {
|
|
|
835
974
|
request.action = action;
|
|
836
975
|
}
|
|
837
976
|
|
|
977
|
+
if (secondaryAction !== undefined) {
|
|
978
|
+
request.secondary_action = secondaryAction;
|
|
979
|
+
}
|
|
980
|
+
|
|
838
981
|
return request;
|
|
839
982
|
};
|
|
840
983
|
|
|
@@ -1137,11 +1280,16 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1137
1280
|
const client = createClient(apiKey);
|
|
1138
1281
|
const contentState = await loadContentState(options, "stream");
|
|
1139
1282
|
const action = await loadLiveActivityAction(options);
|
|
1283
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1140
1284
|
|
|
1141
1285
|
const response = await client.liveActivities.stream(
|
|
1142
1286
|
streamKey,
|
|
1143
1287
|
withTargetChannels(
|
|
1144
|
-
toApiLiveActivityStreamRequest(
|
|
1288
|
+
toApiLiveActivityStreamRequest(
|
|
1289
|
+
contentState,
|
|
1290
|
+
action,
|
|
1291
|
+
secondaryAction
|
|
1292
|
+
),
|
|
1145
1293
|
options.channels
|
|
1146
1294
|
)
|
|
1147
1295
|
);
|
|
@@ -1177,10 +1325,15 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1177
1325
|
const client = createClient(apiKey);
|
|
1178
1326
|
const contentState = await loadContentState(options, "start");
|
|
1179
1327
|
const action = await loadLiveActivityAction(options);
|
|
1328
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1180
1329
|
|
|
1181
1330
|
const response = await client.liveActivities.startLiveActivity({
|
|
1182
1331
|
liveActivityStartRequest: withTargetChannels(
|
|
1183
|
-
toApiLiveActivityStartRequest(
|
|
1332
|
+
toApiLiveActivityStartRequest(
|
|
1333
|
+
contentState,
|
|
1334
|
+
action,
|
|
1335
|
+
secondaryAction
|
|
1336
|
+
),
|
|
1184
1337
|
options.channels
|
|
1185
1338
|
),
|
|
1186
1339
|
});
|
|
@@ -1209,12 +1362,14 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1209
1362
|
const client = createClient(apiKey);
|
|
1210
1363
|
const contentState = await loadContentState(options, "update");
|
|
1211
1364
|
const action = await loadLiveActivityAction(options);
|
|
1365
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1212
1366
|
|
|
1213
1367
|
const response = await client.liveActivities.updateLiveActivity({
|
|
1214
1368
|
liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
|
|
1215
1369
|
options.activityId,
|
|
1216
1370
|
contentState,
|
|
1217
|
-
action
|
|
1371
|
+
action,
|
|
1372
|
+
secondaryAction
|
|
1218
1373
|
),
|
|
1219
1374
|
});
|
|
1220
1375
|
|
|
@@ -1241,12 +1396,14 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1241
1396
|
const client = createClient(apiKey);
|
|
1242
1397
|
const contentState = await loadContentState(options, "end");
|
|
1243
1398
|
const action = await loadLiveActivityAction(options);
|
|
1399
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1244
1400
|
|
|
1245
1401
|
const response = await client.liveActivities.endLiveActivity({
|
|
1246
1402
|
liveActivityEndRequest: toApiLiveActivityEndRequest(
|
|
1247
1403
|
options.activityId,
|
|
1248
1404
|
contentState,
|
|
1249
|
-
action
|
|
1405
|
+
action,
|
|
1406
|
+
secondaryAction
|
|
1250
1407
|
),
|
|
1251
1408
|
});
|
|
1252
1409
|
|
|
@@ -1274,10 +1431,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1274
1431
|
const client = createClient(apiKey);
|
|
1275
1432
|
const contentState = await loadOptionalContentState(options, "end");
|
|
1276
1433
|
const action = await loadLiveActivityAction(options);
|
|
1434
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1277
1435
|
|
|
1278
1436
|
const request =
|
|
1279
|
-
contentState !== undefined ||
|
|
1280
|
-
|
|
1437
|
+
contentState !== undefined ||
|
|
1438
|
+
action !== undefined ||
|
|
1439
|
+
secondaryAction !== undefined
|
|
1440
|
+
? toApiLiveActivityStreamDeleteRequest(
|
|
1441
|
+
contentState,
|
|
1442
|
+
action,
|
|
1443
|
+
secondaryAction
|
|
1444
|
+
)
|
|
1281
1445
|
: undefined;
|
|
1282
1446
|
|
|
1283
1447
|
const response = await client.liveActivities.endStream(streamKey, request);
|