activitysmith-cli 1.8.0 → 1.10.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 +70 -13
- package/package.json +6 -4
- package/src/cli.js +116 -13
package/README.md
CHANGED
|
@@ -17,8 +17,10 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
|
|
|
17
17
|
- [Live Activity Action](#live-activity-action)
|
|
18
18
|
- [Icons and Badges](#icons-and-badges)
|
|
19
19
|
- [Live Activity Colors](#live-activity-colors)
|
|
20
|
-
- [Channels](#channels)
|
|
21
20
|
- [Widgets](#widgets)
|
|
21
|
+
- [App Icon Badge Count](#app-icon-badge-count)
|
|
22
|
+
- [Channels](#channels)
|
|
23
|
+
- [Tags](#tags)
|
|
22
24
|
- [Aliases](#aliases)
|
|
23
25
|
- [Content State Options](#content-state-options)
|
|
24
26
|
- [Output](#output)
|
|
@@ -51,6 +53,7 @@ The skill maps those requests to the CLI:
|
|
|
51
53
|
- action buttons for follow-up links or Shortcut buttons
|
|
52
54
|
- Live Activities for long-running progress
|
|
53
55
|
- widget metrics for values that should stay visible
|
|
56
|
+
- App Icon Badge Counts for a number that should stay on the app icon
|
|
54
57
|
|
|
55
58
|
Install the public skill from this repo:
|
|
56
59
|
|
|
@@ -519,17 +522,6 @@ Choose from these colors for the Live Activity accent, including progress bars a
|
|
|
519
522
|
|
|
520
523
|
`lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
|
|
521
524
|
|
|
522
|
-
## Channels
|
|
523
|
-
|
|
524
|
-
Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
|
|
525
|
-
|
|
526
|
-
```bash
|
|
527
|
-
activitysmith push \
|
|
528
|
-
--title "Build Failed 🚨" \
|
|
529
|
-
--message "CI pipeline failed on main branch" \
|
|
530
|
-
--channels "devs,ops"
|
|
531
|
-
```
|
|
532
|
-
|
|
533
525
|
## Widgets
|
|
534
526
|
|
|
535
527
|
<p align="center">
|
|
@@ -554,6 +546,67 @@ String metric values work too.
|
|
|
554
546
|
activitysmith metrics update prod.status healthy
|
|
555
547
|
```
|
|
556
548
|
|
|
549
|
+
## App Icon Badge Count
|
|
550
|
+
|
|
551
|
+
<p align="center">
|
|
552
|
+
<img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
|
|
553
|
+
</p>
|
|
554
|
+
|
|
555
|
+
Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view.
|
|
556
|
+
|
|
557
|
+
Set or update the badge value.
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
activitysmith badge 8333
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
To clear the badge, set its value to 0.
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
activitysmith badge 0
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
## Channels
|
|
570
|
+
|
|
571
|
+
Use `--channels` to target specific team members or devices
|
|
572
|
+
|
|
573
|
+
### Push Notifications
|
|
574
|
+
|
|
575
|
+
```bash
|
|
576
|
+
activitysmith push \
|
|
577
|
+
--title "New subscription 💸" \
|
|
578
|
+
--message "Customer upgraded to Pro plan" \
|
|
579
|
+
--channels "sales,customer-success"
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### Live Activities
|
|
583
|
+
|
|
584
|
+
```bash
|
|
585
|
+
activitysmith activity start \
|
|
586
|
+
--title "Nightly Database Backup" \
|
|
587
|
+
--subtitle "verify restore" \
|
|
588
|
+
--type progress \
|
|
589
|
+
--percentage 62 \
|
|
590
|
+
--channels "sales,customer-success"
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### App Icon Badge Count
|
|
594
|
+
|
|
595
|
+
```bash
|
|
596
|
+
activitysmith badge 3 --channels "sales,customer-success"
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
## Tags
|
|
600
|
+
|
|
601
|
+
Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them.
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
activitysmith push \
|
|
605
|
+
--title "New subscription 💸" \
|
|
606
|
+
--message "Customer upgraded to Pro plan" \
|
|
607
|
+
--tags "user:382,billing"
|
|
608
|
+
```
|
|
609
|
+
|
|
557
610
|
## Aliases
|
|
558
611
|
|
|
559
612
|
The CLI installs two bin names:
|
|
@@ -600,7 +653,11 @@ Live Activity action options:
|
|
|
600
653
|
|
|
601
654
|
Targeting options:
|
|
602
655
|
|
|
603
|
-
- `--channels <comma-separated-slugs>` (for `push`, `activity stream`, and `activity start`)
|
|
656
|
+
- `--channels <comma-separated-slugs>` (for `push`, `badge`, `activity stream`, and `activity start`)
|
|
657
|
+
|
|
658
|
+
Organization options:
|
|
659
|
+
|
|
660
|
+
- `--tags <comma-separated-tags>` (for `push`, `activity stream`, and `activity start`; repeat the option to add more tags)
|
|
604
661
|
|
|
605
662
|
Widget metric options:
|
|
606
663
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith-cli",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Command-line interface for ActivitySmith. Send push notifications
|
|
3
|
+
"version": "1.10.0",
|
|
4
|
+
"description": "Command-line interface for ActivitySmith. Send push notifications, manage Live Activities, and set App Icon Badge Counts from your terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activitysmith",
|
|
7
7
|
"live-activities",
|
|
8
8
|
"push-notifications",
|
|
9
|
+
"app-icon-badge",
|
|
9
10
|
"api",
|
|
10
11
|
"cli",
|
|
11
12
|
"deployment",
|
|
@@ -37,10 +38,11 @@
|
|
|
37
38
|
"node": ">=24"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
|
-
"lint": "node --check src/cli.js"
|
|
41
|
+
"lint": "node --check src/cli.js",
|
|
42
|
+
"test": "node --test"
|
|
41
43
|
},
|
|
42
44
|
"dependencies": {
|
|
43
|
-
"activitysmith": "^1.
|
|
45
|
+
"activitysmith": "^1.10.0",
|
|
44
46
|
"commander": "^12.1.0"
|
|
45
47
|
}
|
|
46
48
|
}
|
package/src/cli.js
CHANGED
|
@@ -29,6 +29,16 @@ const parseIntegerOption = (label) => (value) => {
|
|
|
29
29
|
return parsed;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const parseBadgeCountArgument = (value) => {
|
|
33
|
+
const badge = parseIntegerOption("badge")(value);
|
|
34
|
+
if (badge < 0 || badge > 2147483647) {
|
|
35
|
+
throw new InvalidArgumentError(
|
|
36
|
+
"badge must be an integer between 0 and 2147483647"
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return badge;
|
|
40
|
+
};
|
|
41
|
+
|
|
32
42
|
const parseNumberOption = (label) => (value) => {
|
|
33
43
|
const parsed = Number(value);
|
|
34
44
|
if (!Number.isFinite(parsed)) {
|
|
@@ -70,6 +80,23 @@ const parseChannelsOption = (value) => {
|
|
|
70
80
|
return channels;
|
|
71
81
|
};
|
|
72
82
|
|
|
83
|
+
const parseTagsOption = (value, previous = []) => {
|
|
84
|
+
if (typeof value !== "string") {
|
|
85
|
+
throw new InvalidArgumentError("tags must be a comma-separated string");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const tags = value
|
|
89
|
+
.split(",")
|
|
90
|
+
.map((tag) => tag.trim())
|
|
91
|
+
.filter((tag) => tag.length > 0);
|
|
92
|
+
|
|
93
|
+
if (tags.length === 0) {
|
|
94
|
+
throw new InvalidArgumentError("tags must contain at least one tag");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return [...previous, ...tags];
|
|
98
|
+
};
|
|
99
|
+
|
|
73
100
|
const parseMetricValueArgument = (value) => {
|
|
74
101
|
if (typeof value !== "string") {
|
|
75
102
|
throw new InvalidArgumentError("value must be a string or number");
|
|
@@ -223,7 +250,11 @@ const addLiveActivityActionOptions = (command) =>
|
|
|
223
250
|
const getApiKey = (options) =>
|
|
224
251
|
options.apiKey || process.env.ACTIVITYSMITH_API_KEY;
|
|
225
252
|
|
|
226
|
-
const createClient = (apiKey) =>
|
|
253
|
+
const createClient = (apiKey) =>
|
|
254
|
+
new ActivitySmith({
|
|
255
|
+
apiKey,
|
|
256
|
+
sdk: { name: "cli", version },
|
|
257
|
+
});
|
|
227
258
|
|
|
228
259
|
const assertPlainObject = (value, label) => {
|
|
229
260
|
const isPlainObject =
|
|
@@ -895,6 +926,17 @@ const withTargetChannels = (request, channels) => {
|
|
|
895
926
|
};
|
|
896
927
|
};
|
|
897
928
|
|
|
929
|
+
const withTags = (request, tags) => {
|
|
930
|
+
if (!tags || tags.length === 0) {
|
|
931
|
+
return request;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
return {
|
|
935
|
+
...request,
|
|
936
|
+
tags,
|
|
937
|
+
};
|
|
938
|
+
};
|
|
939
|
+
|
|
898
940
|
const toApiLiveActivityUpdateRequest = (
|
|
899
941
|
activityId,
|
|
900
942
|
contentState,
|
|
@@ -1185,6 +1227,11 @@ program
|
|
|
1185
1227
|
"Comma-separated channel slugs (optional)",
|
|
1186
1228
|
parseChannelsOption
|
|
1187
1229
|
)
|
|
1230
|
+
.option(
|
|
1231
|
+
"--tags <tags>",
|
|
1232
|
+
"Comma-separated tags for organizing history (repeatable)",
|
|
1233
|
+
parseTagsOption
|
|
1234
|
+
)
|
|
1188
1235
|
.action(async (options) => {
|
|
1189
1236
|
const globalOptions = program.opts();
|
|
1190
1237
|
|
|
@@ -1211,6 +1258,7 @@ program
|
|
|
1211
1258
|
? normalizeOpenUrl(options.redirection, "redirection")
|
|
1212
1259
|
: undefined,
|
|
1213
1260
|
actions,
|
|
1261
|
+
tags: options.tags,
|
|
1214
1262
|
},
|
|
1215
1263
|
options.channels
|
|
1216
1264
|
);
|
|
@@ -1233,6 +1281,45 @@ program
|
|
|
1233
1281
|
}
|
|
1234
1282
|
});
|
|
1235
1283
|
|
|
1284
|
+
program
|
|
1285
|
+
.command("badge")
|
|
1286
|
+
.alias("badge-count")
|
|
1287
|
+
.description("Set App Icon Badge Count; pass 0 to clear it")
|
|
1288
|
+
.argument(
|
|
1289
|
+
"<value>",
|
|
1290
|
+
"App Icon Badge Count; pass 0 to clear it",
|
|
1291
|
+
parseBadgeCountArgument
|
|
1292
|
+
)
|
|
1293
|
+
.option(
|
|
1294
|
+
"--channels <channels>",
|
|
1295
|
+
"Comma-separated channel slugs (optional)",
|
|
1296
|
+
parseChannelsOption
|
|
1297
|
+
)
|
|
1298
|
+
.action(async (value, options) => {
|
|
1299
|
+
const globalOptions = program.opts();
|
|
1300
|
+
|
|
1301
|
+
try {
|
|
1302
|
+
const apiKey = requireApiKey(globalOptions);
|
|
1303
|
+
const client = createClient(apiKey);
|
|
1304
|
+
const response = await client.badgeCount(
|
|
1305
|
+
value,
|
|
1306
|
+
options.channels ? { channels: options.channels } : undefined
|
|
1307
|
+
);
|
|
1308
|
+
|
|
1309
|
+
outputResult(response, globalOptions, [
|
|
1310
|
+
value === 0
|
|
1311
|
+
? "App Icon Badge Count cleared."
|
|
1312
|
+
: "App Icon Badge Count updated.",
|
|
1313
|
+
response?.badge !== undefined ? `Badge: ${response.badge}` : null,
|
|
1314
|
+
response?.devicesNotified !== undefined
|
|
1315
|
+
? `Devices notified: ${response.devicesNotified}`
|
|
1316
|
+
: null,
|
|
1317
|
+
]);
|
|
1318
|
+
} catch (error) {
|
|
1319
|
+
await handleError(error, globalOptions);
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1236
1323
|
const metricsCommand = program
|
|
1237
1324
|
.command("metrics")
|
|
1238
1325
|
.alias("metric")
|
|
@@ -1272,6 +1359,11 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1272
1359
|
"Comma-separated channel slugs (optional)",
|
|
1273
1360
|
parseChannelsOption
|
|
1274
1361
|
)
|
|
1362
|
+
.option(
|
|
1363
|
+
"--tags <tags>",
|
|
1364
|
+
"Comma-separated tags for organizing history (repeatable)",
|
|
1365
|
+
parseTagsOption
|
|
1366
|
+
)
|
|
1275
1367
|
.action(async (streamKey, options) => {
|
|
1276
1368
|
const globalOptions = program.opts();
|
|
1277
1369
|
|
|
@@ -1284,13 +1376,16 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1284
1376
|
|
|
1285
1377
|
const response = await client.liveActivities.stream(
|
|
1286
1378
|
streamKey,
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1379
|
+
withTags(
|
|
1380
|
+
withTargetChannels(
|
|
1381
|
+
toApiLiveActivityStreamRequest(
|
|
1382
|
+
contentState,
|
|
1383
|
+
action,
|
|
1384
|
+
secondaryAction
|
|
1385
|
+
),
|
|
1386
|
+
options.channels
|
|
1292
1387
|
),
|
|
1293
|
-
options.
|
|
1388
|
+
options.tags
|
|
1294
1389
|
)
|
|
1295
1390
|
);
|
|
1296
1391
|
|
|
@@ -1317,6 +1412,11 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1317
1412
|
"Comma-separated channel slugs (optional)",
|
|
1318
1413
|
parseChannelsOption
|
|
1319
1414
|
)
|
|
1415
|
+
.option(
|
|
1416
|
+
"--tags <tags>",
|
|
1417
|
+
"Comma-separated tags for organizing history (repeatable)",
|
|
1418
|
+
parseTagsOption
|
|
1419
|
+
)
|
|
1320
1420
|
.action(async (options) => {
|
|
1321
1421
|
const globalOptions = program.opts();
|
|
1322
1422
|
|
|
@@ -1328,13 +1428,16 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1328
1428
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1329
1429
|
|
|
1330
1430
|
const response = await client.liveActivities.startLiveActivity({
|
|
1331
|
-
liveActivityStartRequest:
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1431
|
+
liveActivityStartRequest: withTags(
|
|
1432
|
+
withTargetChannels(
|
|
1433
|
+
toApiLiveActivityStartRequest(
|
|
1434
|
+
contentState,
|
|
1435
|
+
action,
|
|
1436
|
+
secondaryAction
|
|
1437
|
+
),
|
|
1438
|
+
options.channels
|
|
1336
1439
|
),
|
|
1337
|
-
options.
|
|
1440
|
+
options.tags
|
|
1338
1441
|
),
|
|
1339
1442
|
});
|
|
1340
1443
|
|