activitysmith 0.1.7 → 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
|
@@ -210,6 +210,34 @@ const response = await activitysmith.notifications.send({
|
|
|
210
210
|
});
|
|
211
211
|
```
|
|
212
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
|
+
|
|
213
241
|
## Push Notification Redirection and Actions
|
|
214
242
|
|
|
215
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.
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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) {
|
|
@@ -715,13 +715,19 @@ export interface PushNotificationRequest {
|
|
|
715
715
|
*/
|
|
716
716
|
subtitle?: string;
|
|
717
717
|
/**
|
|
718
|
-
* Optional HTTPS URL
|
|
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.
|
|
719
725
|
* @type {string}
|
|
720
726
|
* @memberof PushNotificationRequest
|
|
721
727
|
*/
|
|
722
728
|
redirection?: string;
|
|
723
729
|
/**
|
|
724
|
-
* Optional interactive actions shown
|
|
730
|
+
* Optional interactive actions shown when users expand the notification. Cannot be combined with `media`.
|
|
725
731
|
* @type {Array<PushNotificationAction>}
|
|
726
732
|
* @memberof PushNotificationRequest
|
|
727
733
|
*/
|
|
@@ -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(
|
|
22
|
-
sendPushNotificationRaw(
|
|
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
|
-
|
|
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(
|
|
26
|
-
|
|
44
|
+
sendPushNotification(requestParameters, initOverrides) {
|
|
45
|
+
assertValidPushRequest(requestParameters.pushNotificationRequest);
|
|
46
|
+
return this.api.sendPushNotification(requestParameters, initOverrides);
|
|
27
47
|
}
|
|
28
|
-
sendPushNotificationRaw(
|
|
29
|
-
|
|
48
|
+
sendPushNotificationRaw(requestParameters, initOverrides) {
|
|
49
|
+
assertValidPushRequest(requestParameters.pushNotificationRequest);
|
|
50
|
+
return this.api.sendPushNotificationRaw(requestParameters, initOverrides);
|
|
30
51
|
}
|
|
31
52
|
}
|
|
32
53
|
exports.NotificationsResource = NotificationsResource;
|