activitysmith 0.1.6 → 0.1.8

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 CHANGED
@@ -50,10 +50,34 @@ console.log(response.success);
50
50
  console.log(response.devices_notified);
51
51
  ```
52
52
 
53
- ### Start a Live Activity
53
+ ## Live Activities
54
+
55
+ Live Activities come in two UI types, but the lifecycle stays the same:
56
+ start the activity, keep the returned `activity_id`, update it as state
57
+ changes, then end it when the work is done.
58
+
59
+ - `segmented_progress`: best for jobs tracked in steps
60
+ - `progress`: best for jobs tracked as a percentage or numeric range
61
+
62
+ ### Shared flow
63
+
64
+ 1. Call `activitysmith.liveActivities.start(...)`.
65
+ 2. Save the returned `activity_id`.
66
+ 3. Call `activitysmith.liveActivities.update(...)` as progress changes.
67
+ 4. Call `activitysmith.liveActivities.end(...)` when the work is finished.
68
+
69
+ ### Segmented Progress Type
70
+
71
+ Use `segmented_progress` when progress is easier to follow as steps instead of a
72
+ raw percentage. It fits jobs like backups, deployments, ETL pipelines, and
73
+ checklists where "step 2 of 3" is more useful than "67%".
74
+ `number_of_steps` is dynamic, so you can increase or decrease it later if the
75
+ workflow changes.
76
+
77
+ #### Start
54
78
 
55
79
  <p align="center">
56
- <img src="https://cdn.activitysmith.com/features/start-live-activity.png" alt="Start live activity example" width="680" />
80
+ <img src="https://cdn.activitysmith.com/features/start-live-activity.png" alt="Segmented progress start example" width="680" />
57
81
  </p>
58
82
 
59
83
  ```ts
@@ -72,10 +96,10 @@ const start = await activitysmith.liveActivities.start({
72
96
  const activityId = start.activity_id;
73
97
  ```
74
98
 
75
- ### Update a Live Activity
99
+ #### Update
76
100
 
77
101
  <p align="center">
78
- <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Update live activity example" width="680" />
102
+ <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented progress update example" width="680" />
79
103
  </p>
80
104
 
81
105
  ```ts
@@ -84,6 +108,7 @@ const update = await activitysmith.liveActivities.update({
84
108
  content_state: {
85
109
  title: "Nightly database backup",
86
110
  subtitle: "upload archive",
111
+ number_of_steps: 4,
87
112
  current_step: 2,
88
113
  },
89
114
  });
@@ -91,10 +116,10 @@ const update = await activitysmith.liveActivities.update({
91
116
  console.log(update.devices_notified);
92
117
  ```
93
118
 
94
- ### End a Live Activity
119
+ #### End
95
120
 
96
121
  <p align="center">
97
- <img src="https://cdn.activitysmith.com/features/end-live-activity.png" alt="End live activity example" width="680" />
122
+ <img src="https://cdn.activitysmith.com/features/end-live-activity.png" alt="Segmented progress end example" width="680" />
98
123
  </p>
99
124
 
100
125
  ```ts
@@ -103,7 +128,8 @@ const end = await activitysmith.liveActivities.end({
103
128
  content_state: {
104
129
  title: "Nightly database backup",
105
130
  subtitle: "verify restore",
106
- current_step: 3,
131
+ number_of_steps: 4,
132
+ current_step: 4,
107
133
  auto_dismiss_minutes: 2,
108
134
  },
109
135
  });
@@ -111,6 +137,67 @@ const end = await activitysmith.liveActivities.end({
111
137
  console.log(end.success);
112
138
  ```
113
139
 
140
+ ### Progress Type
141
+
142
+ Use `progress` when the state is naturally continuous. It fits charging,
143
+ downloads, sync jobs, uploads, timers, and any flow where a percentage or
144
+ numeric range is the clearest signal.
145
+
146
+ #### Start
147
+
148
+ <p align="center">
149
+ <img src="https://cdn.activitysmith.com/features/progress-live-activity-start.png" alt="Progress start example" width="680" />
150
+ </p>
151
+
152
+ ```ts
153
+ const start = await activitysmith.liveActivities.start({
154
+ content_state: {
155
+ title: "EV Charging",
156
+ subtitle: "Added 30 mi range",
157
+ type: "progress",
158
+ percentage: 15,
159
+ color: "lime",
160
+ },
161
+ });
162
+
163
+ const activityId = start.activity_id;
164
+ ```
165
+
166
+ #### Update
167
+
168
+ <p align="center">
169
+ <img src="https://cdn.activitysmith.com/features/progress-live-activity-update.png" alt="Progress update example" width="680" />
170
+ </p>
171
+
172
+ ```ts
173
+ await activitysmith.liveActivities.update({
174
+ activity_id: activityId,
175
+ content_state: {
176
+ title: "EV Charging",
177
+ subtitle: "Added 120 mi range",
178
+ percentage: 60,
179
+ },
180
+ });
181
+ ```
182
+
183
+ #### End
184
+
185
+ <p align="center">
186
+ <img src="https://cdn.activitysmith.com/features/progress-live-activity-end.png" alt="Progress end example" width="680" />
187
+ </p>
188
+
189
+ ```ts
190
+ await activitysmith.liveActivities.end({
191
+ activity_id: activityId,
192
+ content_state: {
193
+ title: "EV Charging",
194
+ subtitle: "Added 200 mi range",
195
+ percentage: 100,
196
+ auto_dismiss_minutes: 2,
197
+ },
198
+ });
199
+ ```
200
+
114
201
  ## Channels
115
202
 
116
203
  Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
@@ -123,6 +210,34 @@ const response = await activitysmith.notifications.send({
123
210
  });
124
211
  ```
125
212
 
213
+ ## Rich Push Notifications with Media
214
+
215
+ <p align="center">
216
+ <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
217
+ </p>
218
+
219
+ ```ts
220
+ const response = await activitysmith.notifications.send({
221
+ title: "Homepage ready",
222
+ message: "Your agent finished the redesign.",
223
+ media: "https://cdn.example.com/output/homepage-v2.png",
224
+ redirection: "https://github.com/acme/web/pull/482",
225
+ });
226
+ ```
227
+
228
+ Send images, videos, or audio with your push notifications, press and hold to preview media directly from the notification, then tap through to open the linked content.
229
+
230
+ <p align="center">
231
+ <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
232
+ </p>
233
+
234
+ What will work:
235
+
236
+ - direct image URL: `.jpg`, `.png`, `.gif`, etc.
237
+ - direct audio file URL: `.mp3`, `.m4a`, etc.
238
+ - direct video file URL: `.mp4`, `.mov`, etc.
239
+ - URL that responds with a proper media `Content-Type`, even if the path has no extension
240
+
126
241
  ## Push Notification Redirection and Actions
127
242
 
128
243
  Push notification redirection and actions are optional and can be used to redirect the user to a specific URL when they tap the notification or to trigger a specific action when they long-press the notification.
@@ -25,32 +25,32 @@ export interface UpdateLiveActivityRequest {
25
25
  */
26
26
  export declare class LiveActivitiesApi extends runtime.BaseAPI {
27
27
  /**
28
- * Ends a Live Activity and archives its lifecycle.
28
+ * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
29
29
  * End a Live Activity
30
30
  */
31
31
  endLiveActivityRaw(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityEndResponse>>;
32
32
  /**
33
- * Ends a Live Activity and archives its lifecycle.
33
+ * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
34
34
  * End a Live Activity
35
35
  */
36
36
  endLiveActivity(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityEndResponse>;
37
37
  /**
38
- * Starts a Live Activity on devices matched by API key scope and optional target channels.
38
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
39
39
  * Start a Live Activity
40
40
  */
41
41
  startLiveActivityRaw(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityStartResponse>>;
42
42
  /**
43
- * Starts a Live Activity on devices matched by API key scope and optional target channels.
43
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
44
44
  * Start a Live Activity
45
45
  */
46
46
  startLiveActivity(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStartResponse>;
47
47
  /**
48
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued.
48
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
49
49
  * Update a Live Activity
50
50
  */
51
51
  updateLiveActivityRaw(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityUpdateResponse>>;
52
52
  /**
53
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued.
53
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
54
54
  * Update a Live Activity
55
55
  */
56
56
  updateLiveActivity(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityUpdateResponse>;
@@ -20,7 +20,7 @@ const runtime = require("../runtime");
20
20
  */
21
21
  class LiveActivitiesApi extends runtime.BaseAPI {
22
22
  /**
23
- * Ends a Live Activity and archives its lifecycle.
23
+ * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
24
24
  * End a Live Activity
25
25
  */
26
26
  async endLiveActivityRaw(requestParameters, initOverrides) {
@@ -47,7 +47,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
47
47
  return new runtime.JSONApiResponse(response);
48
48
  }
49
49
  /**
50
- * Ends a Live Activity and archives its lifecycle.
50
+ * Ends a Live Activity and archives its lifecycle. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
51
51
  * End a Live Activity
52
52
  */
53
53
  async endLiveActivity(requestParameters, initOverrides) {
@@ -55,7 +55,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
55
55
  return await response.value();
56
56
  }
57
57
  /**
58
- * Starts a Live Activity on devices matched by API key scope and optional target channels.
58
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
59
59
  * Start a Live Activity
60
60
  */
61
61
  async startLiveActivityRaw(requestParameters, initOverrides) {
@@ -82,7 +82,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
82
82
  return new runtime.JSONApiResponse(response);
83
83
  }
84
84
  /**
85
- * Starts a Live Activity on devices matched by API key scope and optional target channels.
85
+ * Starts a Live Activity on devices matched by API key scope and optional target channels. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
86
86
  * Start a Live Activity
87
87
  */
88
88
  async startLiveActivity(requestParameters, initOverrides) {
@@ -90,7 +90,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
90
90
  return await response.value();
91
91
  }
92
92
  /**
93
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued.
93
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
94
94
  * Update a Live Activity
95
95
  */
96
96
  async updateLiveActivityRaw(requestParameters, initOverrides) {
@@ -117,7 +117,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
117
117
  return new runtime.JSONApiResponse(response);
118
118
  }
119
119
  /**
120
- * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued.
120
+ * Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
121
121
  * Update a Live Activity
122
122
  */
123
123
  async updateLiveActivity(requestParameters, initOverrides) {
@@ -19,12 +19,12 @@ export interface SendPushNotificationRequest {
19
19
  */
20
20
  export declare class PushNotificationsApi extends runtime.BaseAPI {
21
21
  /**
22
- * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
22
+ * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`.
23
23
  * Send a push notification
24
24
  */
25
25
  sendPushNotificationRaw(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PushNotificationResponse>>;
26
26
  /**
27
- * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
27
+ * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`.
28
28
  * Send a push notification
29
29
  */
30
30
  sendPushNotification(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PushNotificationResponse>;
@@ -20,7 +20,7 @@ const runtime = require("../runtime");
20
20
  */
21
21
  class PushNotificationsApi extends runtime.BaseAPI {
22
22
  /**
23
- * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
23
+ * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`.
24
24
  * Send a push notification
25
25
  */
26
26
  async sendPushNotificationRaw(requestParameters, initOverrides) {
@@ -47,7 +47,7 @@ class PushNotificationsApi extends runtime.BaseAPI {
47
47
  return new runtime.JSONApiResponse(response);
48
48
  }
49
49
  /**
50
- * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
50
+ * Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`.
51
51
  * Send a push notification
52
52
  */
53
53
  async sendPushNotification(requestParameters, initOverrides) {
@@ -53,7 +53,7 @@ export interface ChannelTarget {
53
53
  channels: Array<string>;
54
54
  }
55
55
  /**
56
- * End payload. Required fields are title and current_step. number_of_steps is optional.
56
+ * End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
57
57
  * @export
58
58
  * @interface ContentStateEnd
59
59
  */
@@ -72,17 +72,41 @@ export interface ContentStateEnd {
72
72
  */
73
73
  subtitle?: string;
74
74
  /**
75
- *
75
+ * Total number of steps. Use for type=segmented_progress. Optional on end, and safe to change if the final workflow used more or fewer steps than originally planned.
76
76
  * @type {number}
77
77
  * @memberof ContentStateEnd
78
78
  */
79
79
  number_of_steps?: number;
80
80
  /**
81
- *
81
+ * Current step. Use for type=segmented_progress.
82
+ * @type {number}
83
+ * @memberof ContentStateEnd
84
+ */
85
+ current_step?: number;
86
+ /**
87
+ * Progress percentage (0–100). Use for type=progress. Takes precedence over value/upper_limit if both are provided.
88
+ * @type {number}
89
+ * @memberof ContentStateEnd
90
+ */
91
+ percentage?: number;
92
+ /**
93
+ * Current progress value. Use with upper_limit for type=progress.
94
+ * @type {number}
95
+ * @memberof ContentStateEnd
96
+ */
97
+ value?: number;
98
+ /**
99
+ * Maximum progress value. Use with value for type=progress.
82
100
  * @type {number}
83
101
  * @memberof ContentStateEnd
84
102
  */
85
- current_step: number;
103
+ upper_limit?: number;
104
+ /**
105
+ * Optional. When omitted, the API uses the existing Live Activity type.
106
+ * @type {string}
107
+ * @memberof ContentStateEnd
108
+ */
109
+ type?: ContentStateEndTypeEnum;
86
110
  /**
87
111
  * Optional. Accent color for the Live Activity. Defaults to blue.
88
112
  * @type {string}
@@ -90,7 +114,7 @@ export interface ContentStateEnd {
90
114
  */
91
115
  color?: ContentStateEndColorEnum;
92
116
  /**
93
- * Optional. Overrides color for the current step.
117
+ * Optional. Overrides color for the current step. Only applies to type=segmented_progress.
94
118
  * @type {string}
95
119
  * @memberof ContentStateEnd
96
120
  */
@@ -102,6 +126,14 @@ export interface ContentStateEnd {
102
126
  */
103
127
  auto_dismiss_minutes?: number;
104
128
  }
129
+ /**
130
+ * @export
131
+ */
132
+ export declare const ContentStateEndTypeEnum: {
133
+ readonly SegmentedProgress: "segmented_progress";
134
+ readonly Progress: "progress";
135
+ };
136
+ export type ContentStateEndTypeEnum = typeof ContentStateEndTypeEnum[keyof typeof ContentStateEndTypeEnum];
105
137
  /**
106
138
  * @export
107
139
  */
@@ -133,7 +165,7 @@ export declare const ContentStateEndStepColorEnum: {
133
165
  };
134
166
  export type ContentStateEndStepColorEnum = typeof ContentStateEndStepColorEnum[keyof typeof ContentStateEndStepColorEnum];
135
167
  /**
136
- * Start payload requires title, number_of_steps, current_step, and type.
168
+ * Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls.
137
169
  * @export
138
170
  * @interface ContentStateStart
139
171
  */
@@ -152,17 +184,35 @@ export interface ContentStateStart {
152
184
  */
153
185
  subtitle?: string;
154
186
  /**
155
- *
187
+ * Total number of steps. Use for type=segmented_progress. This value can be increased or decreased later when updating or ending the same activity.
156
188
  * @type {number}
157
189
  * @memberof ContentStateStart
158
190
  */
159
- number_of_steps: number;
191
+ number_of_steps?: number;
160
192
  /**
161
- *
193
+ * Current step. Use for type=segmented_progress.
194
+ * @type {number}
195
+ * @memberof ContentStateStart
196
+ */
197
+ current_step?: number;
198
+ /**
199
+ * Progress percentage (0–100). Use for type=progress. Takes precedence over value/upper_limit if both are provided.
162
200
  * @type {number}
163
201
  * @memberof ContentStateStart
164
202
  */
165
- current_step: number;
203
+ percentage?: number;
204
+ /**
205
+ * Current progress value. Use with upper_limit for type=progress.
206
+ * @type {number}
207
+ * @memberof ContentStateStart
208
+ */
209
+ value?: number;
210
+ /**
211
+ * Maximum progress value. Use with value for type=progress.
212
+ * @type {number}
213
+ * @memberof ContentStateStart
214
+ */
215
+ upper_limit?: number;
166
216
  /**
167
217
  *
168
218
  * @type {string}
@@ -176,7 +226,7 @@ export interface ContentStateStart {
176
226
  */
177
227
  color?: ContentStateStartColorEnum;
178
228
  /**
179
- * Optional. Overrides color for the current step.
229
+ * Optional. Overrides color for the current step. Only applies to type=segmented_progress.
180
230
  * @type {string}
181
231
  * @memberof ContentStateStart
182
232
  */
@@ -187,6 +237,7 @@ export interface ContentStateStart {
187
237
  */
188
238
  export declare const ContentStateStartTypeEnum: {
189
239
  readonly SegmentedProgress: "segmented_progress";
240
+ readonly Progress: "progress";
190
241
  };
191
242
  export type ContentStateStartTypeEnum = typeof ContentStateStartTypeEnum[keyof typeof ContentStateStartTypeEnum];
192
243
  /**
@@ -220,7 +271,7 @@ export declare const ContentStateStartStepColorEnum: {
220
271
  };
221
272
  export type ContentStateStartStepColorEnum = typeof ContentStateStartStepColorEnum[keyof typeof ContentStateStartStepColorEnum];
222
273
  /**
223
- * Update payload. Required fields are title and current_step. number_of_steps is optional.
274
+ * Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
224
275
  * @export
225
276
  * @interface ContentStateUpdate
226
277
  */
@@ -239,17 +290,41 @@ export interface ContentStateUpdate {
239
290
  */
240
291
  subtitle?: string;
241
292
  /**
242
- *
293
+ * Total number of steps. Use for type=segmented_progress. Optional on update, and safe to change if the workflow gains or loses steps.
243
294
  * @type {number}
244
295
  * @memberof ContentStateUpdate
245
296
  */
246
297
  number_of_steps?: number;
247
298
  /**
248
- *
299
+ * Current step. Use for type=segmented_progress.
300
+ * @type {number}
301
+ * @memberof ContentStateUpdate
302
+ */
303
+ current_step?: number;
304
+ /**
305
+ * Progress percentage (0–100). Use for type=progress. Takes precedence over value/upper_limit if both are provided.
306
+ * @type {number}
307
+ * @memberof ContentStateUpdate
308
+ */
309
+ percentage?: number;
310
+ /**
311
+ * Current progress value. Use with upper_limit for type=progress.
249
312
  * @type {number}
250
313
  * @memberof ContentStateUpdate
251
314
  */
252
- current_step: number;
315
+ value?: number;
316
+ /**
317
+ * Maximum progress value. Use with value for type=progress.
318
+ * @type {number}
319
+ * @memberof ContentStateUpdate
320
+ */
321
+ upper_limit?: number;
322
+ /**
323
+ * Optional. When omitted, the API uses the existing Live Activity type.
324
+ * @type {string}
325
+ * @memberof ContentStateUpdate
326
+ */
327
+ type?: ContentStateUpdateTypeEnum;
253
328
  /**
254
329
  * Optional. Accent color for the Live Activity. Defaults to blue.
255
330
  * @type {string}
@@ -257,12 +332,20 @@ export interface ContentStateUpdate {
257
332
  */
258
333
  color?: ContentStateUpdateColorEnum;
259
334
  /**
260
- * Optional. Overrides color for the current step.
335
+ * Optional. Overrides color for the current step. Only applies to type=segmented_progress.
261
336
  * @type {string}
262
337
  * @memberof ContentStateUpdate
263
338
  */
264
339
  step_color?: ContentStateUpdateStepColorEnum;
265
340
  }
341
+ /**
342
+ * @export
343
+ */
344
+ export declare const ContentStateUpdateTypeEnum: {
345
+ readonly SegmentedProgress: "segmented_progress";
346
+ readonly Progress: "progress";
347
+ };
348
+ export type ContentStateUpdateTypeEnum = typeof ContentStateUpdateTypeEnum[keyof typeof ContentStateUpdateTypeEnum];
266
349
  /**
267
350
  * @export
268
351
  */
@@ -314,7 +397,7 @@ export interface ForbiddenError {
314
397
  message: string;
315
398
  }
316
399
  /**
317
- *
400
+ * End an existing Live Activity by activity_id.
318
401
  * @export
319
402
  * @interface LiveActivityEndRequest
320
403
  */
@@ -334,7 +417,7 @@ export interface LiveActivityEndRequest {
334
417
  content_state: ContentStateEnd;
335
418
  }
336
419
  /**
337
- *
420
+ * Returned after a Live Activity end event is sent or queued.
338
421
  * @export
339
422
  * @interface LiveActivityEndResponse
340
423
  */
@@ -404,7 +487,7 @@ export interface LiveActivityLimitError {
404
487
  active: number;
405
488
  }
406
489
  /**
407
- *
490
+ * Start a new Live Activity. The response includes activity_id for later update and end calls.
408
491
  * @export
409
492
  * @interface LiveActivityStartRequest
410
493
  */
@@ -430,7 +513,7 @@ export interface LiveActivityStartRequest {
430
513
  target?: ChannelTarget;
431
514
  }
432
515
  /**
433
- *
516
+ * Returned after a Live Activity starts. Save activity_id and use it for all later updates and for the final end call.
434
517
  * @export
435
518
  * @interface LiveActivityStartResponse
436
519
  */
@@ -474,7 +557,7 @@ export interface LiveActivityStartResponse {
474
557
  timestamp: string;
475
558
  }
476
559
  /**
477
- *
560
+ * Update an existing Live Activity by activity_id.
478
561
  * @export
479
562
  * @interface LiveActivityUpdateRequest
480
563
  */
@@ -494,7 +577,7 @@ export interface LiveActivityUpdateRequest {
494
577
  content_state: ContentStateUpdate;
495
578
  }
496
579
  /**
497
- *
580
+ * Returned after a Live Activity update is sent or queued.
498
581
  * @export
499
582
  * @interface LiveActivityUpdateResponse
500
583
  */
@@ -632,13 +715,19 @@ export interface PushNotificationRequest {
632
715
  */
633
716
  subtitle?: string;
634
717
  /**
635
- * Optional HTTPS URL opened when user taps the notification body.
718
+ * Optional HTTPS URL for an image, audio file, or video that users can preview or play when they expand the notification. If `redirection` is omitted, tapping the notification opens this URL. Cannot be combined with `actions`.
719
+ * @type {string}
720
+ * @memberof PushNotificationRequest
721
+ */
722
+ media?: string;
723
+ /**
724
+ * Optional HTTPS URL opened when user taps the notification body. Overrides the default tap target from `media` when both are provided.
636
725
  * @type {string}
637
726
  * @memberof PushNotificationRequest
638
727
  */
639
728
  redirection?: string;
640
729
  /**
641
- * Optional interactive actions shown on iOS long-press.
730
+ * Optional interactive actions shown when users expand the notification. Cannot be combined with `media`.
642
731
  * @type {Array<PushNotificationAction>}
643
732
  * @memberof PushNotificationRequest
644
733
  */
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = void 0;
3
+ exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateUpdateTypeEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = exports.ContentStateEndTypeEnum = void 0;
4
+ /**
5
+ * @export
6
+ */
7
+ exports.ContentStateEndTypeEnum = {
8
+ SegmentedProgress: 'segmented_progress',
9
+ Progress: 'progress'
10
+ };
4
11
  /**
5
12
  * @export
6
13
  */
@@ -33,7 +40,8 @@ exports.ContentStateEndStepColorEnum = {
33
40
  * @export
34
41
  */
35
42
  exports.ContentStateStartTypeEnum = {
36
- SegmentedProgress: 'segmented_progress'
43
+ SegmentedProgress: 'segmented_progress',
44
+ Progress: 'progress'
37
45
  };
38
46
  /**
39
47
  * @export
@@ -63,6 +71,13 @@ exports.ContentStateStartStepColorEnum = {
63
71
  Orange: 'orange',
64
72
  Yellow: 'yellow'
65
73
  };
74
+ /**
75
+ * @export
76
+ */
77
+ exports.ContentStateUpdateTypeEnum = {
78
+ SegmentedProgress: 'segmented_progress',
79
+ Progress: 'progress'
80
+ };
66
81
  /**
67
82
  * @export
68
83
  */
@@ -3,6 +3,8 @@ export interface ActivitySmithOptions {
3
3
  apiKey: string;
4
4
  }
5
5
  type PushRequestBody = Parameters<PushNotificationsApi["sendPushNotification"]>[0]["pushNotificationRequest"];
6
+ type PushSendParameters = Parameters<PushNotificationsApi["sendPushNotification"]>[0];
7
+ type PushRawParameters = Parameters<PushNotificationsApi["sendPushNotificationRaw"]>[0];
6
8
  type SendInitOverrides = Parameters<PushNotificationsApi["sendPushNotification"]>[1];
7
9
  type StartRequestBody = Parameters<LiveActivitiesApi["startLiveActivity"]>[0]["liveActivityStartRequest"];
8
10
  type UpdateRequestBody = Parameters<LiveActivitiesApi["updateLiveActivity"]>[0]["liveActivityUpdateRequest"];
@@ -18,8 +20,8 @@ export declare class NotificationsResource {
18
20
  private readonly api;
19
21
  constructor(api: PushNotificationsApi);
20
22
  send(request: PushSendRequest, initOverrides?: SendInitOverrides): Promise<import("../generated/models").PushNotificationResponse>;
21
- sendPushNotification(...args: Parameters<PushNotificationsApi["sendPushNotification"]>): Promise<import("../generated/models").PushNotificationResponse>;
22
- sendPushNotificationRaw(...args: Parameters<PushNotificationsApi["sendPushNotificationRaw"]>): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").PushNotificationResponse>>;
23
+ sendPushNotification(requestParameters: PushSendParameters, initOverrides?: SendInitOverrides): Promise<import("../generated/models").PushNotificationResponse>;
24
+ sendPushNotificationRaw(requestParameters: PushRawParameters, initOverrides?: SendInitOverrides): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").PushNotificationResponse>>;
23
25
  }
24
26
  export declare class LiveActivitiesResource {
25
27
  private readonly api;
@@ -14,19 +14,40 @@ function withTargetChannels(request) {
14
14
  target: { channels },
15
15
  };
16
16
  }
17
+ function hasMediaValue(media) {
18
+ if (typeof media === "string") {
19
+ return media.trim().length > 0;
20
+ }
21
+ return media !== null && media !== undefined;
22
+ }
23
+ function hasActionsValue(actions) {
24
+ if (Array.isArray(actions)) {
25
+ return actions.length > 0;
26
+ }
27
+ return actions !== null && actions !== undefined;
28
+ }
29
+ function assertValidPushRequest(request) {
30
+ if (hasMediaValue(request.media) && hasActionsValue(request.actions)) {
31
+ throw new Error("ActivitySmith: media cannot be combined with actions");
32
+ }
33
+ }
17
34
  class NotificationsResource {
18
35
  constructor(api) {
19
36
  this.api = api;
20
37
  }
21
38
  send(request, initOverrides) {
22
- return this.api.sendPushNotification({ pushNotificationRequest: withTargetChannels(request) }, initOverrides);
39
+ const normalized = withTargetChannels(request);
40
+ assertValidPushRequest(normalized);
41
+ return this.api.sendPushNotification({ pushNotificationRequest: normalized }, initOverrides);
23
42
  }
24
43
  // Backward-compatible alias.
25
- sendPushNotification(...args) {
26
- return this.api.sendPushNotification(...args);
44
+ sendPushNotification(requestParameters, initOverrides) {
45
+ assertValidPushRequest(requestParameters.pushNotificationRequest);
46
+ return this.api.sendPushNotification(requestParameters, initOverrides);
27
47
  }
28
- sendPushNotificationRaw(...args) {
29
- return this.api.sendPushNotificationRaw(...args);
48
+ sendPushNotificationRaw(requestParameters, initOverrides) {
49
+ assertValidPushRequest(requestParameters.pushNotificationRequest);
50
+ return this.api.sendPushNotificationRaw(requestParameters, initOverrides);
30
51
  }
31
52
  }
32
53
  exports.NotificationsResource = NotificationsResource;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Official ActivitySmith Node.js SDK",
5
5
  "keywords": [
6
6
  "activitysmith",