activitysmith-cli 1.13.0 → 1.14.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 +20 -5
  2. package/package.json +2 -2
  3. package/src/cli.js +32 -8
package/README.md CHANGED
@@ -61,7 +61,7 @@ activitysmith push \
61
61
 
62
62
  ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png)
63
63
 
64
- Set `--icon` to a publicly accessible HTTPS image URL to show an avatar or service logo alongside a smaller ActivitySmith app icon. With a custom icon, iOS may omit the subtitle from the notification.
64
+ Set `--icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. With a custom icon, iOS may omit the subtitle from the notification.
65
65
 
66
66
  ```bash
67
67
  activitysmith push \
@@ -210,6 +210,22 @@ activitysmith push \
210
210
  --interruption-level "time-sensitive"
211
211
  ```
212
212
 
213
+ ### Replace a Push Notification
214
+
215
+ Every `push` prints a `Notification ID`. Pass it to `--replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original, so `--channels` and `--interruption-level` don't apply.
216
+
217
+ ```bash
218
+ activitysmith push \
219
+ --title "🚨 checkout-api is down" \
220
+ --message "500 errors on 62% of requests."
221
+ # Notification ID: Xk3pQ8mV2nR7tL9wB4yZ
222
+
223
+ activitysmith push \
224
+ --replace "Xk3pQ8mV2nR7tL9wB4yZ" \
225
+ --title "✅ checkout-api recovered" \
226
+ --message "Error rate is back to normal. Incident resolved."
227
+ ```
228
+
213
229
  ## Live Activities
214
230
 
215
231
  Choose the Live Activity type that matches what you want to show:
@@ -246,6 +262,9 @@ Choose the Live Activity type that matches what you want to show:
246
262
 
247
263
  Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `activity stream` command starts the Live Activity. Later commands with the same `stream_key` update it.
248
264
 
265
+ > [!WARNING]
266
+ > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](https://activitysmith.com/docs/live-activity-stream#update-frequency-and-ios-limits)
267
+
249
268
  #### Value
250
269
 
251
270
  ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png)
@@ -679,7 +698,3 @@ The CLI exits non-zero on non-2xx responses and prints the API error body. That
679
698
  ### [NPM Package](https://www.npmjs.com/package/activitysmith-cli)
680
699
 
681
700
  Install the ActivitySmith CLI from npm
682
-
683
- ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-cli)
684
-
685
- View the CLI source on GitHub
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "Command-line interface for ActivitySmith. Send Push Notifications, start, update, and end Live Activities, and set App Icon Badge Counts from your terminal.",
5
5
  "keywords": [
6
6
  "activitysmith",
@@ -42,7 +42,7 @@
42
42
  "test": "node --test"
43
43
  },
44
44
  "dependencies": {
45
- "activitysmith": "^1.13.0",
45
+ "activitysmith": "^1.14.0",
46
46
  "commander": "^12.1.0"
47
47
  }
48
48
  }
package/src/cli.js CHANGED
@@ -1257,15 +1257,19 @@ const outputResult = (payload, options, lines) => {
1257
1257
 
1258
1258
  program
1259
1259
  .command("push")
1260
- .description("Send a push notification")
1260
+ .description("Send a push notification, or replace one you already sent")
1261
1261
  .requiredOption("--title <title>", "Push title")
1262
+ .option(
1263
+ "--replace <notification-id>",
1264
+ "Silently replace a sent push notification, using the notification ID from its send output"
1265
+ )
1262
1266
  .option("--message <message>", "Push message")
1263
1267
  .option("--subtitle <subtitle>", "Push subtitle")
1264
1268
  .option(
1265
1269
  "--media <url>",
1266
1270
  "HTTPS URL for image, audio, or video shown when the notification is expanded"
1267
1271
  )
1268
- .option("--icon <url>", "HTTPS image URL for the notification icon, such as an avatar or service logo")
1272
+ .option("--icon <url>", "HTTPS image URL for the notification icon, such as a logo or avatar")
1269
1273
  .addOption(
1270
1274
  new Option("--interruption-level <level>", "Notification interruption level").choices([
1271
1275
  "passive",
@@ -1299,6 +1303,16 @@ program
1299
1303
  media: options.media,
1300
1304
  actions,
1301
1305
  });
1306
+ if (options.replace !== undefined) {
1307
+ if (options.channels !== undefined || options.interruptionLevel !== undefined) {
1308
+ throw new Error(
1309
+ "--channels and --interruption-level cannot be combined with --replace. Replacements go to the original recipients and arrive silently."
1310
+ );
1311
+ }
1312
+ if (options.replace.trim() === "") {
1313
+ throw new Error("--replace requires the notification ID from the original push output.");
1314
+ }
1315
+ }
1302
1316
 
1303
1317
  const pushNotificationRequest = withTargetChannels(
1304
1318
  {
@@ -1325,18 +1339,24 @@ program
1325
1339
  options.channels
1326
1340
  );
1327
1341
 
1328
- const response = await client.notifications.sendPushNotification({
1329
- pushNotificationRequest,
1330
- });
1342
+ const isReplacement = options.replace !== undefined;
1343
+ const response = isReplacement
1344
+ ? await client.notifications.replace(options.replace.trim(), pushNotificationRequest)
1345
+ : await client.notifications.sendPushNotification({
1346
+ pushNotificationRequest,
1347
+ });
1348
+ const devicesNotified = response?.devices_notified ?? response?.devicesNotified;
1349
+ const notificationId = response?.notification_id ?? response?.notificationId;
1331
1350
 
1332
1351
  outputResult(response, globalOptions, [
1333
- "Push sent.",
1352
+ isReplacement ? "Push replaced." : "Push sent.",
1334
1353
  response?.success !== undefined
1335
1354
  ? `Success: ${response.success}`
1336
1355
  : null,
1337
- response?.devicesNotified !== undefined
1338
- ? `Devices notified: ${response.devicesNotified}`
1356
+ devicesNotified !== undefined
1357
+ ? `Devices notified: ${devicesNotified}`
1339
1358
  : null,
1359
+ notificationId ? `Notification ID: ${notificationId}` : null,
1340
1360
  ]);
1341
1361
  } catch (error) {
1342
1362
  await handleError(error, globalOptions);
@@ -1417,6 +1437,10 @@ addLiveActivityActionOptions(addContentStateOptions(
1417
1437
  activityCommand
1418
1438
  .command("stream")
1419
1439
  .description("Send a stateless Live Activity stream update")
1440
+ .addHelpText(
1441
+ "after",
1442
+ "\niOS limits how often a Live Activity can update. Short bursts are fine, but avoid updating the same Live Activity more often than every couple of minutes for long periods.\n"
1443
+ )
1420
1444
  .argument("<stream-key>", "Stable stream key")
1421
1445
  .option(
1422
1446
  "--channels <channels>",