activitysmith-cli 1.9.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.
Files changed (3) hide show
  1. package/README.md +16 -0
  2. package/package.json +4 -3
  3. package/src/cli.js +62 -12
package/README.md CHANGED
@@ -20,6 +20,7 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
20
20
  - [Widgets](#widgets)
21
21
  - [App Icon Badge Count](#app-icon-badge-count)
22
22
  - [Channels](#channels)
23
+ - [Tags](#tags)
23
24
  - [Aliases](#aliases)
24
25
  - [Content State Options](#content-state-options)
25
26
  - [Output](#output)
@@ -595,6 +596,17 @@ activitysmith activity start \
595
596
  activitysmith badge 3 --channels "sales,customer-success"
596
597
  ```
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
+
598
610
  ## Aliases
599
611
 
600
612
  The CLI installs two bin names:
@@ -643,6 +655,10 @@ Targeting options:
643
655
 
644
656
  - `--channels <comma-separated-slugs>` (for `push`, `badge`, `activity stream`, and `activity start`)
645
657
 
658
+ Organization options:
659
+
660
+ - `--tags <comma-separated-tags>` (for `push`, `activity stream`, and `activity start`; repeat the option to add more tags)
661
+
646
662
  Widget metric options:
647
663
 
648
664
  - `activitysmith metrics update <metric-key> <value>`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
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",
@@ -38,10 +38,11 @@
38
38
  "node": ">=24"
39
39
  },
40
40
  "scripts": {
41
- "lint": "node --check src/cli.js"
41
+ "lint": "node --check src/cli.js",
42
+ "test": "node --test"
42
43
  },
43
44
  "dependencies": {
44
- "activitysmith": "^1.9.0",
45
+ "activitysmith": "^1.10.0",
45
46
  "commander": "^12.1.0"
46
47
  }
47
48
  }
package/src/cli.js CHANGED
@@ -80,6 +80,23 @@ const parseChannelsOption = (value) => {
80
80
  return channels;
81
81
  };
82
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
+
83
100
  const parseMetricValueArgument = (value) => {
84
101
  if (typeof value !== "string") {
85
102
  throw new InvalidArgumentError("value must be a string or number");
@@ -909,6 +926,17 @@ const withTargetChannels = (request, channels) => {
909
926
  };
910
927
  };
911
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
+
912
940
  const toApiLiveActivityUpdateRequest = (
913
941
  activityId,
914
942
  contentState,
@@ -1199,6 +1227,11 @@ program
1199
1227
  "Comma-separated channel slugs (optional)",
1200
1228
  parseChannelsOption
1201
1229
  )
1230
+ .option(
1231
+ "--tags <tags>",
1232
+ "Comma-separated tags for organizing history (repeatable)",
1233
+ parseTagsOption
1234
+ )
1202
1235
  .action(async (options) => {
1203
1236
  const globalOptions = program.opts();
1204
1237
 
@@ -1225,6 +1258,7 @@ program
1225
1258
  ? normalizeOpenUrl(options.redirection, "redirection")
1226
1259
  : undefined,
1227
1260
  actions,
1261
+ tags: options.tags,
1228
1262
  },
1229
1263
  options.channels
1230
1264
  );
@@ -1325,6 +1359,11 @@ addLiveActivityActionOptions(addContentStateOptions(
1325
1359
  "Comma-separated channel slugs (optional)",
1326
1360
  parseChannelsOption
1327
1361
  )
1362
+ .option(
1363
+ "--tags <tags>",
1364
+ "Comma-separated tags for organizing history (repeatable)",
1365
+ parseTagsOption
1366
+ )
1328
1367
  .action(async (streamKey, options) => {
1329
1368
  const globalOptions = program.opts();
1330
1369
 
@@ -1337,13 +1376,16 @@ addLiveActivityActionOptions(addContentStateOptions(
1337
1376
 
1338
1377
  const response = await client.liveActivities.stream(
1339
1378
  streamKey,
1340
- withTargetChannels(
1341
- toApiLiveActivityStreamRequest(
1342
- contentState,
1343
- action,
1344
- secondaryAction
1379
+ withTags(
1380
+ withTargetChannels(
1381
+ toApiLiveActivityStreamRequest(
1382
+ contentState,
1383
+ action,
1384
+ secondaryAction
1385
+ ),
1386
+ options.channels
1345
1387
  ),
1346
- options.channels
1388
+ options.tags
1347
1389
  )
1348
1390
  );
1349
1391
 
@@ -1370,6 +1412,11 @@ addLiveActivityActionOptions(addContentStateOptions(
1370
1412
  "Comma-separated channel slugs (optional)",
1371
1413
  parseChannelsOption
1372
1414
  )
1415
+ .option(
1416
+ "--tags <tags>",
1417
+ "Comma-separated tags for organizing history (repeatable)",
1418
+ parseTagsOption
1419
+ )
1373
1420
  .action(async (options) => {
1374
1421
  const globalOptions = program.opts();
1375
1422
 
@@ -1381,13 +1428,16 @@ addLiveActivityActionOptions(addContentStateOptions(
1381
1428
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1382
1429
 
1383
1430
  const response = await client.liveActivities.startLiveActivity({
1384
- liveActivityStartRequest: withTargetChannels(
1385
- toApiLiveActivityStartRequest(
1386
- contentState,
1387
- action,
1388
- secondaryAction
1431
+ liveActivityStartRequest: withTags(
1432
+ withTargetChannels(
1433
+ toApiLiveActivityStartRequest(
1434
+ contentState,
1435
+ action,
1436
+ secondaryAction
1437
+ ),
1438
+ options.channels
1389
1439
  ),
1390
- options.channels
1440
+ options.tags
1391
1441
  ),
1392
1442
  });
1393
1443