activitysmith-cli 1.7.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 +44 -2
- package/package.json +2 -2
- package/src/cli.js +109 -12
package/README.md
CHANGED
|
@@ -339,7 +339,7 @@ activitysmith activity end-stream prod-web-1 \
|
|
|
339
339
|
|
|
340
340
|
### Live Activity Action
|
|
341
341
|
|
|
342
|
-
Live Activities can include
|
|
342
|
+
Live Activities can include an action button.
|
|
343
343
|
|
|
344
344
|
- `open_url`: open an HTTPS URL.
|
|
345
345
|
- `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
|
|
@@ -347,7 +347,7 @@ Live Activities can include one optional action button.
|
|
|
347
347
|
|
|
348
348
|
<p align="center">
|
|
349
349
|
<img
|
|
350
|
-
src="https://cdn.activitysmith.com/features/live-activity-
|
|
350
|
+
src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png"
|
|
351
351
|
alt="Live Activity with action button"
|
|
352
352
|
width="680"
|
|
353
353
|
/>
|
|
@@ -414,6 +414,46 @@ activitysmith activity stream search-reindex \
|
|
|
414
414
|
}'
|
|
415
415
|
```
|
|
416
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
|
+
|
|
417
457
|
### Icons and Badges
|
|
418
458
|
|
|
419
459
|
Add more context to Live Activities with icons and badges.
|
|
@@ -555,6 +595,8 @@ Live Activity action options:
|
|
|
555
595
|
|
|
556
596
|
- `--action <json>`
|
|
557
597
|
- `--action-file <path>`
|
|
598
|
+
- `--secondary-action <json>`
|
|
599
|
+
- `--secondary-action-file <path>`
|
|
558
600
|
|
|
559
601
|
Targeting options:
|
|
560
602
|
|
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
|
@@ -210,7 +210,15 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
|
|
|
210
210
|
const addLiveActivityActionOptions = (command) =>
|
|
211
211
|
command
|
|
212
212
|
.option("--action <json>", "Live Activity action as JSON object")
|
|
213
|
-
.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
|
+
);
|
|
214
222
|
|
|
215
223
|
const getApiKey = (options) =>
|
|
216
224
|
options.apiKey || process.env.ACTIVITYSMITH_API_KEY;
|
|
@@ -695,6 +703,32 @@ const loadLiveActivityAction = async (options) => {
|
|
|
695
703
|
return parseAction(action, "action");
|
|
696
704
|
};
|
|
697
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
|
+
|
|
698
732
|
const validatePushMediaOptions = ({ media, actions }) => {
|
|
699
733
|
if (media === undefined || actions === undefined) {
|
|
700
734
|
return;
|
|
@@ -828,7 +862,11 @@ const toApiContentState = (contentState) => {
|
|
|
828
862
|
return mapped;
|
|
829
863
|
};
|
|
830
864
|
|
|
831
|
-
const toApiLiveActivityStartRequest = (
|
|
865
|
+
const toApiLiveActivityStartRequest = (
|
|
866
|
+
contentState,
|
|
867
|
+
action,
|
|
868
|
+
secondaryAction
|
|
869
|
+
) => {
|
|
832
870
|
const request = {
|
|
833
871
|
content_state: toApiContentState(contentState),
|
|
834
872
|
};
|
|
@@ -837,6 +875,10 @@ const toApiLiveActivityStartRequest = (contentState, action) => {
|
|
|
837
875
|
request.action = action;
|
|
838
876
|
}
|
|
839
877
|
|
|
878
|
+
if (secondaryAction !== undefined) {
|
|
879
|
+
request.secondary_action = secondaryAction;
|
|
880
|
+
}
|
|
881
|
+
|
|
840
882
|
return request;
|
|
841
883
|
};
|
|
842
884
|
|
|
@@ -853,7 +895,12 @@ const withTargetChannels = (request, channels) => {
|
|
|
853
895
|
};
|
|
854
896
|
};
|
|
855
897
|
|
|
856
|
-
const toApiLiveActivityUpdateRequest = (
|
|
898
|
+
const toApiLiveActivityUpdateRequest = (
|
|
899
|
+
activityId,
|
|
900
|
+
contentState,
|
|
901
|
+
action,
|
|
902
|
+
secondaryAction
|
|
903
|
+
) => {
|
|
857
904
|
const request = {
|
|
858
905
|
activity_id: activityId,
|
|
859
906
|
content_state: toApiContentState(contentState),
|
|
@@ -863,10 +910,19 @@ const toApiLiveActivityUpdateRequest = (activityId, contentState, action) => {
|
|
|
863
910
|
request.action = action;
|
|
864
911
|
}
|
|
865
912
|
|
|
913
|
+
if (secondaryAction !== undefined) {
|
|
914
|
+
request.secondary_action = secondaryAction;
|
|
915
|
+
}
|
|
916
|
+
|
|
866
917
|
return request;
|
|
867
918
|
};
|
|
868
919
|
|
|
869
|
-
const toApiLiveActivityEndRequest = (
|
|
920
|
+
const toApiLiveActivityEndRequest = (
|
|
921
|
+
activityId,
|
|
922
|
+
contentState,
|
|
923
|
+
action,
|
|
924
|
+
secondaryAction
|
|
925
|
+
) => {
|
|
870
926
|
const request = {
|
|
871
927
|
activity_id: activityId,
|
|
872
928
|
content_state: toApiContentState(contentState),
|
|
@@ -876,10 +932,18 @@ const toApiLiveActivityEndRequest = (activityId, contentState, action) => {
|
|
|
876
932
|
request.action = action;
|
|
877
933
|
}
|
|
878
934
|
|
|
935
|
+
if (secondaryAction !== undefined) {
|
|
936
|
+
request.secondary_action = secondaryAction;
|
|
937
|
+
}
|
|
938
|
+
|
|
879
939
|
return request;
|
|
880
940
|
};
|
|
881
941
|
|
|
882
|
-
const toApiLiveActivityStreamRequest = (
|
|
942
|
+
const toApiLiveActivityStreamRequest = (
|
|
943
|
+
contentState,
|
|
944
|
+
action,
|
|
945
|
+
secondaryAction
|
|
946
|
+
) => {
|
|
883
947
|
const request = {
|
|
884
948
|
content_state: toApiContentState(contentState),
|
|
885
949
|
};
|
|
@@ -888,10 +952,18 @@ const toApiLiveActivityStreamRequest = (contentState, action) => {
|
|
|
888
952
|
request.action = action;
|
|
889
953
|
}
|
|
890
954
|
|
|
955
|
+
if (secondaryAction !== undefined) {
|
|
956
|
+
request.secondary_action = secondaryAction;
|
|
957
|
+
}
|
|
958
|
+
|
|
891
959
|
return request;
|
|
892
960
|
};
|
|
893
961
|
|
|
894
|
-
const toApiLiveActivityStreamDeleteRequest = (
|
|
962
|
+
const toApiLiveActivityStreamDeleteRequest = (
|
|
963
|
+
contentState,
|
|
964
|
+
action,
|
|
965
|
+
secondaryAction
|
|
966
|
+
) => {
|
|
895
967
|
const request = {};
|
|
896
968
|
|
|
897
969
|
if (contentState !== undefined) {
|
|
@@ -902,6 +974,10 @@ const toApiLiveActivityStreamDeleteRequest = (contentState, action) => {
|
|
|
902
974
|
request.action = action;
|
|
903
975
|
}
|
|
904
976
|
|
|
977
|
+
if (secondaryAction !== undefined) {
|
|
978
|
+
request.secondary_action = secondaryAction;
|
|
979
|
+
}
|
|
980
|
+
|
|
905
981
|
return request;
|
|
906
982
|
};
|
|
907
983
|
|
|
@@ -1204,11 +1280,16 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1204
1280
|
const client = createClient(apiKey);
|
|
1205
1281
|
const contentState = await loadContentState(options, "stream");
|
|
1206
1282
|
const action = await loadLiveActivityAction(options);
|
|
1283
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1207
1284
|
|
|
1208
1285
|
const response = await client.liveActivities.stream(
|
|
1209
1286
|
streamKey,
|
|
1210
1287
|
withTargetChannels(
|
|
1211
|
-
toApiLiveActivityStreamRequest(
|
|
1288
|
+
toApiLiveActivityStreamRequest(
|
|
1289
|
+
contentState,
|
|
1290
|
+
action,
|
|
1291
|
+
secondaryAction
|
|
1292
|
+
),
|
|
1212
1293
|
options.channels
|
|
1213
1294
|
)
|
|
1214
1295
|
);
|
|
@@ -1244,10 +1325,15 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1244
1325
|
const client = createClient(apiKey);
|
|
1245
1326
|
const contentState = await loadContentState(options, "start");
|
|
1246
1327
|
const action = await loadLiveActivityAction(options);
|
|
1328
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1247
1329
|
|
|
1248
1330
|
const response = await client.liveActivities.startLiveActivity({
|
|
1249
1331
|
liveActivityStartRequest: withTargetChannels(
|
|
1250
|
-
toApiLiveActivityStartRequest(
|
|
1332
|
+
toApiLiveActivityStartRequest(
|
|
1333
|
+
contentState,
|
|
1334
|
+
action,
|
|
1335
|
+
secondaryAction
|
|
1336
|
+
),
|
|
1251
1337
|
options.channels
|
|
1252
1338
|
),
|
|
1253
1339
|
});
|
|
@@ -1276,12 +1362,14 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1276
1362
|
const client = createClient(apiKey);
|
|
1277
1363
|
const contentState = await loadContentState(options, "update");
|
|
1278
1364
|
const action = await loadLiveActivityAction(options);
|
|
1365
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1279
1366
|
|
|
1280
1367
|
const response = await client.liveActivities.updateLiveActivity({
|
|
1281
1368
|
liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
|
|
1282
1369
|
options.activityId,
|
|
1283
1370
|
contentState,
|
|
1284
|
-
action
|
|
1371
|
+
action,
|
|
1372
|
+
secondaryAction
|
|
1285
1373
|
),
|
|
1286
1374
|
});
|
|
1287
1375
|
|
|
@@ -1308,12 +1396,14 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1308
1396
|
const client = createClient(apiKey);
|
|
1309
1397
|
const contentState = await loadContentState(options, "end");
|
|
1310
1398
|
const action = await loadLiveActivityAction(options);
|
|
1399
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1311
1400
|
|
|
1312
1401
|
const response = await client.liveActivities.endLiveActivity({
|
|
1313
1402
|
liveActivityEndRequest: toApiLiveActivityEndRequest(
|
|
1314
1403
|
options.activityId,
|
|
1315
1404
|
contentState,
|
|
1316
|
-
action
|
|
1405
|
+
action,
|
|
1406
|
+
secondaryAction
|
|
1317
1407
|
),
|
|
1318
1408
|
});
|
|
1319
1409
|
|
|
@@ -1341,10 +1431,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1341
1431
|
const client = createClient(apiKey);
|
|
1342
1432
|
const contentState = await loadOptionalContentState(options, "end");
|
|
1343
1433
|
const action = await loadLiveActivityAction(options);
|
|
1434
|
+
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1344
1435
|
|
|
1345
1436
|
const request =
|
|
1346
|
-
contentState !== undefined ||
|
|
1347
|
-
|
|
1437
|
+
contentState !== undefined ||
|
|
1438
|
+
action !== undefined ||
|
|
1439
|
+
secondaryAction !== undefined
|
|
1440
|
+
? toApiLiveActivityStreamDeleteRequest(
|
|
1441
|
+
contentState,
|
|
1442
|
+
action,
|
|
1443
|
+
secondaryAction
|
|
1444
|
+
)
|
|
1348
1445
|
: undefined;
|
|
1349
1446
|
|
|
1350
1447
|
const response = await client.liveActivities.endStream(streamKey, request);
|