activitysmith-cli 1.4.0 → 1.6.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 +67 -8
  2. package/package.json +2 -2
  3. package/src/cli.js +38 -7
package/README.md CHANGED
@@ -15,6 +15,8 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
15
15
  - [Start & Update Live Activity](#start--update-live-activity)
16
16
  - [End Live Activity](#end-live-activity)
17
17
  - [Live Activity Action](#live-activity-action)
18
+ - [Icons and Badges](#icons-and-badges)
19
+ - [Live Activity Colors](#live-activity-colors)
18
20
  - [Channels](#channels)
19
21
  - [Widgets](#widgets)
20
22
  - [Aliases](#aliases)
@@ -265,14 +267,6 @@ activitysmith activity stream customer-ops \
265
267
  }'
266
268
  ```
267
269
 
268
- The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
269
-
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
273
-
274
- `icon` and `badge` are optional. If you omit either one, that element is not shown in the Live Activity.
275
-
276
270
  ### End Live Activity
277
271
 
278
272
  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.
@@ -347,6 +341,71 @@ activitysmith activity stream search-reindex \
347
341
  }'
348
342
  ```
349
343
 
344
+ ### Icons and Badges
345
+
346
+ Add more context to Live Activities with icons and badges.
347
+
348
+ #### Icon
349
+
350
+ Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, and `alert`.
351
+
352
+ <p align="center">
353
+ <img
354
+ src="https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png"
355
+ alt="Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen"
356
+ width="680"
357
+ />
358
+ </p>
359
+
360
+ ```bash
361
+ activitysmith activity stream prod-web-1 \
362
+ --content-state '{
363
+ "title": "Server Health",
364
+ "subtitle": "prod-web-1",
365
+ "type": "metrics",
366
+ "icon": { "symbol": "server.rack", "color": "blue" },
367
+ "metrics": [
368
+ { "label": "CPU", "value": 18, "unit": "%" },
369
+ { "label": "MEM", "value": 42, "unit": "%" }
370
+ ]
371
+ }'
372
+ ```
373
+
374
+ The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
375
+
376
+ - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
377
+ - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
378
+ - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
379
+
380
+ #### Badge
381
+
382
+ Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
383
+
384
+ <p align="center">
385
+ <img
386
+ src="https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png"
387
+ alt="Progress Live Activity with a badge on the iPhone Lock Screen"
388
+ width="680"
389
+ />
390
+ </p>
391
+
392
+ ```bash
393
+ activitysmith activity stream nightly-database-backup \
394
+ --content-state '{
395
+ "title": "Nightly Database Backup",
396
+ "subtitle": "verify restore",
397
+ "type": "progress",
398
+ "badge": { "title": "S3", "color": "cyan" },
399
+ "percentage": 62
400
+ }'
401
+ ```
402
+
403
+ ### Live Activity Colors
404
+
405
+ Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
406
+
407
+ `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
408
+
350
409
  ## Channels
351
410
 
352
411
  Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.4.0",
3
+ "version": "1.6.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.4.0",
43
+ "activitysmith": "^1.6.0",
44
44
  "commander": "^12.1.0"
45
45
  }
46
46
  }
package/src/cli.js CHANGED
@@ -97,6 +97,37 @@ const normalizeHttpsUrl = (value, label) => {
97
97
  return parsed.toString();
98
98
  };
99
99
 
100
+ const normalizeUrlWithSchemes = (value, label, schemes) => {
101
+ if (typeof value !== "string" || value.trim().length === 0) {
102
+ throw new Error(`${label} must be a non-empty string`);
103
+ }
104
+
105
+ let parsed;
106
+ try {
107
+ parsed = new URL(value.trim());
108
+ } catch {
109
+ throw new Error(`${label} must be a valid URL`);
110
+ }
111
+
112
+ const allowedProtocols = schemes.map((scheme) => `${scheme}:`);
113
+ if (!allowedProtocols.includes(parsed.protocol)) {
114
+ throw new Error(`${label} must use ${schemes.join(" or ")}`);
115
+ }
116
+
117
+ return parsed.toString();
118
+ };
119
+
120
+ const normalizeActionUrl = (value, label, type) => {
121
+ if (type === "open_url") {
122
+ return normalizeUrlWithSchemes(value, label, ["https", "shortcuts"]);
123
+ }
124
+
125
+ return normalizeHttpsUrl(value, label);
126
+ };
127
+
128
+ const normalizeOpenUrl = (value, label) =>
129
+ normalizeUrlWithSchemes(value, label, ["https", "shortcuts"]);
130
+
100
131
  const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
101
132
  command
102
133
  .option("--content-state <json>", "Content state as JSON string")
@@ -107,10 +138,10 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
107
138
  .option("--subtitle <subtitle>", "Content state subtitle")
108
139
  .option("--type <type>", "Content state type")
109
140
  .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")
141
+ .option("--icon-symbol <symbol>", "SF Symbol name")
142
+ .option("--icon-color <color>", "Icon color")
143
+ .option("--badge-title <title>", "Badge title")
144
+ .option("--badge-color <color>", "Badge color")
114
145
  .option(
115
146
  "--number-of-steps <number>",
116
147
  "Content state number of steps",
@@ -529,7 +560,7 @@ const parseAction = (value, label) => {
529
560
  const action = {
530
561
  title: value.title.trim(),
531
562
  type: normalizedType,
532
- url: normalizeHttpsUrl(value.url, `${label}.url`),
563
+ url: normalizeActionUrl(value.url, `${label}.url`, normalizedType),
533
564
  };
534
565
 
535
566
  if (value.method !== undefined) {
@@ -1003,7 +1034,7 @@ program
1003
1034
  "--media <url>",
1004
1035
  "HTTPS URL for image, audio, or video shown when the notification is expanded"
1005
1036
  )
1006
- .option("--redirection <url>", "HTTPS URL opened when notification is tapped")
1037
+ .option("--redirection <url>", "HTTPS or shortcuts:// URL opened when notification is tapped")
1007
1038
  .option("--actions <json>", "Actions JSON array (max 4)")
1008
1039
  .option("--actions-file <path>", "Path to actions JSON array file")
1009
1040
  .option(
@@ -1034,7 +1065,7 @@ program
1034
1065
  : undefined,
1035
1066
  redirection:
1036
1067
  options.redirection !== undefined
1037
- ? normalizeHttpsUrl(options.redirection, "redirection")
1068
+ ? normalizeOpenUrl(options.redirection, "redirection")
1038
1069
  : undefined,
1039
1070
  actions,
1040
1071
  },