diff --git a/CHANGELOG.md b/CHANGELOG.md index 9485214..0118f44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.10.0 + +### New Features + +- **New Feature: Tags** — Organize and filter your Push Notification and Live Activity history using one or more tags. + ## 1.9.0 ### New Features diff --git a/README.md b/README.md index 7dc1631..7da79bb 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ See [API reference](https://activitysmith.com/docs/api-reference/introduction) - [Widgets](#widgets) - [App Icon Badge Count](#app-icon-badge-count) - [Channels](#channels) +- [Tags](#tags) ## Installation @@ -549,6 +550,18 @@ await activitysmith.badgeCount(3, { }); ``` +## Tags + +Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them. + +```ts +await activitysmith.notifications.send({ + title: "New subscription 💸", + message: "Customer upgraded to Pro plan", + tags: ["user:382", "billing"], +}); +``` + ## Error Handling ```ts diff --git a/generated/apis/AppIconBadgesApi.ts b/generated/apis/AppIconBadgesApi.ts index f78cbe1..3346b05 100644 --- a/generated/apis/AppIconBadgesApi.ts +++ b/generated/apis/AppIconBadgesApi.ts @@ -33,8 +33,8 @@ export interface UpdateAppIconBadgeCountRequest { export class AppIconBadgesApi extends runtime.BaseAPI { /** - * Updates the App Icon Badge Count on devices matched by API key scope and optional target channels. Send `badge: 0` to clear the count. Badge updates are independent of push notifications and do not create a push notification history item. - * Update App Icon Badge Count + * Shows a number on the ActivitySmith app icon. + * Set App Icon Badge Count */ async updateAppIconBadgeCountRaw(requestParameters: UpdateAppIconBadgeCountRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['appIconBadgeCountUpdateRequest'] == null) { @@ -70,8 +70,8 @@ export class AppIconBadgesApi extends runtime.BaseAPI { } /** - * Updates the App Icon Badge Count on devices matched by API key scope and optional target channels. Send `badge: 0` to clear the count. Badge updates are independent of push notifications and do not create a push notification history item. - * Update App Icon Badge Count + * Shows a number on the ActivitySmith app icon. + * Set App Icon Badge Count */ async updateAppIconBadgeCount(requestParameters: UpdateAppIconBadgeCountRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.updateAppIconBadgeCountRaw(requestParameters, initOverrides); diff --git a/generated/apis/LiveActivitiesApi.ts b/generated/apis/LiveActivitiesApi.ts index cb2d13e..534f7d6 100644 --- a/generated/apis/LiveActivitiesApi.ts +++ b/generated/apis/LiveActivitiesApi.ts @@ -61,7 +61,7 @@ export interface UpdateLiveActivityRequest { export class LiveActivitiesApi extends runtime.BaseAPI { /** - * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. * End a Live Activity (legacy manual lifecycle) */ async endLiveActivityRaw(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -98,7 +98,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. * End a Live Activity (legacy manual lifecycle) */ async endLiveActivity(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { @@ -107,7 +107,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. * End a stream */ async endLiveActivityStreamRaw(requestParameters: EndLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -144,7 +144,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. * End a stream */ async endLiveActivityStream(requestParameters: EndLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { @@ -153,7 +153,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them. * Start a new Live Activity or update an existing one */ async reconcileLiveActivityStreamRaw(requestParameters: ReconcileLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -197,7 +197,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them. * Start a new Live Activity or update an existing one */ async reconcileLiveActivityStream(requestParameters: ReconcileLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { @@ -206,7 +206,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. * Start a Live Activity (legacy manual lifecycle) */ async startLiveActivityRaw(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -243,7 +243,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. Optional tags to organize and filter notification history. * Start a Live Activity (legacy manual lifecycle) */ async startLiveActivity(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { @@ -252,7 +252,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. * Update a Live Activity (legacy manual lifecycle) */ async updateLiveActivityRaw(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -289,7 +289,7 @@ export class LiveActivitiesApi extends runtime.BaseAPI { } /** - * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities only. + * Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, and timer activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, and segmented_progress Live Activities. * Update a Live Activity (legacy manual lifecycle) */ async updateLiveActivity(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { diff --git a/generated/apis/PushNotificationsApi.ts b/generated/apis/PushNotificationsApi.ts index c2d3666..6fb1252 100644 --- a/generated/apis/PushNotificationsApi.ts +++ b/generated/apis/PushNotificationsApi.ts @@ -33,7 +33,7 @@ export interface SendPushNotificationRequest { export class PushNotificationsApi extends runtime.BaseAPI { /** - * 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`. + * 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`. Optional tags to organize and filter notification history. * Send a push notification */ async sendPushNotificationRaw(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -70,7 +70,7 @@ export class PushNotificationsApi extends runtime.BaseAPI { } /** - * 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`. + * 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`. Optional tags to organize and filter notification history. * Send a push notification */ async sendPushNotification(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { diff --git a/generated/models/index.ts b/generated/models/index.ts index 3d12627..0572d22 100644 --- a/generated/models/index.ts +++ b/generated/models/index.ts @@ -76,7 +76,7 @@ export interface AlertPayload { body?: string; } /** - * App Icon Badge Count update. Send badge 0 to clear the count. + * * @export * @interface AppIconBadgeCountUpdateRequest */ @@ -757,7 +757,7 @@ export interface LiveActivityAction { */ type: LiveActivityActionType; /** - * Action URL. For open_url, use an HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. + * Action URL. For open_url, use an HTTP or HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. * @type {string} * @memberof LiveActivityAction */ @@ -868,7 +868,7 @@ export interface LiveActivityEndRequest { */ action?: LiveActivityAction; /** - * Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * @type {LiveActivityAction} * @memberof LiveActivityEndRequest */ @@ -961,7 +961,7 @@ export interface LiveActivityStartRequest { */ action?: LiveActivityAction; /** - * Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * @type {LiveActivityAction} * @memberof LiveActivityStartRequest */ @@ -978,6 +978,12 @@ export interface LiveActivityStartRequest { * @memberof LiveActivityStartRequest */ target?: ChannelTarget; + /** + * Optional tags to organize and filter notification history. + * @type {Array} + * @memberof LiveActivityStartRequest + */ + tags?: Array; } /** * Returned after a Live Activity starts. Save activity_id and use it for all later updates and for the final end call. @@ -1015,6 +1021,12 @@ export interface LiveActivityStartResponse { * @memberof LiveActivityStartResponse */ effective_channel_slugs?: Array; + /** + * Optional tags to organize and filter notification history. + * @type {Array} + * @memberof LiveActivityStartResponse + */ + tags?: Array; /** * * @type {string} @@ -1041,7 +1053,7 @@ export interface LiveActivityStreamDeleteRequest { */ action?: LiveActivityAction; /** - * Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * @type {LiveActivityAction} * @memberof LiveActivityStreamDeleteRequest */ @@ -1172,6 +1184,12 @@ export interface LiveActivityStreamPutResponse { * @memberof LiveActivityStreamPutResponse */ effective_channel_slugs?: Array; + /** + * Optional tags to organize and filter notification history. + * @type {Array} + * @memberof LiveActivityStreamPutResponse + */ + tags?: Array; /** * * @type {string} @@ -1212,7 +1230,7 @@ export interface LiveActivityStreamRequest { */ action?: LiveActivityAction; /** - * Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * @type {LiveActivityAction} * @memberof LiveActivityStreamRequest */ @@ -1235,6 +1253,12 @@ export interface LiveActivityStreamRequest { * @memberof LiveActivityStreamRequest */ target?: ChannelTarget; + /** + * Optional tags to organize and filter notification history. + * @type {Array} + * @memberof LiveActivityStreamRequest + */ + tags?: Array; } /** * Update an existing Live Activity by activity_id. @@ -1261,7 +1285,7 @@ export interface LiveActivityUpdateRequest { */ action?: LiveActivityAction; /** - * Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * @type {LiveActivityAction} * @memberof LiveActivityUpdateRequest */ @@ -1436,7 +1460,7 @@ export interface PushNotificationAction { */ type: PushNotificationActionType; /** - * Action URL. For open_url, use an HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. + * Action URL. For open_url, use an HTTP or HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. * @type {string} * @memberof PushNotificationAction */ @@ -1497,7 +1521,7 @@ export interface PushNotificationRequest { */ media?: string; /** - * Optional HTTPS URL or shortcuts://run-shortcut?name=... URL opened when the user taps the notification body. Use shortcuts://run-shortcut?name=... to run a specific iPhone Shortcut that already exists on the user's device. Overrides the default tap target from `media` when both are provided. + * Optional HTTP URL, HTTPS URL, or shortcuts://run-shortcut?name=... URL opened when the user taps the notification body. Use shortcuts://run-shortcut?name=... to run a specific iPhone Shortcut that already exists on the user's device. Overrides the default tap target from `media` when both are provided. * @type {string} * @memberof PushNotificationRequest */ @@ -1532,6 +1556,12 @@ export interface PushNotificationRequest { * @memberof PushNotificationRequest */ target?: ChannelTarget; + /** + * Optional tags to organize and filter notification history. + * @type {Array} + * @memberof PushNotificationRequest + */ + tags?: Array; } /** * @@ -1563,6 +1593,12 @@ export interface PushNotificationResponse { * @memberof PushNotificationResponse */ effective_channel_slugs?: Array; + /** + * Optional tags to organize and filter notification history. + * @type {Array} + * @memberof PushNotificationResponse + */ + tags?: Array; /** * * @type {string} diff --git a/package-lock.json b/package-lock.json index 713333d..33d0408 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "activitysmith", - "version": "1.9.0", + "version": "1.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "activitysmith", - "version": "1.9.0", + "version": "1.10.0", "license": "MIT", "devDependencies": { "typescript": "^5.3.3", diff --git a/package.json b/package.json index 9a1241e..c69c536 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "activitysmith", - "version": "1.9.0", + "version": "1.10.0", "description": "Official ActivitySmith Node.js SDK", "keywords": [ "activitysmith", diff --git a/src/ActivitySmith.ts b/src/ActivitySmith.ts index 1222797..d262b48 100644 --- a/src/ActivitySmith.ts +++ b/src/ActivitySmith.ts @@ -6,7 +6,7 @@ import { PushNotificationsApi, } from "../generated/index"; -const SDK_VERSION = "1.9.0"; +const SDK_VERSION = "1.10.0"; const SDK_HEADER_NAME = "X-ActivitySmith-SDK"; const SDK_HEADER_VALUE = `node-v${SDK_VERSION}`; diff --git a/tests/resources.test.js b/tests/resources.test.js index 87f1499..4899022 100644 --- a/tests/resources.test.js +++ b/tests/resources.test.js @@ -49,6 +49,31 @@ describe("resource wrappers", () => { ); }); + it("passes tags through notifications.send", async () => { + const ActivitySmith = require("../dist/src/index.js"); + const generated = require("../dist/generated/index.js"); + + const sendSpy = vi + .spyOn(generated.PushNotificationsApi.prototype, "sendPushNotification") + .mockResolvedValue({ success: true }); + + const client = new ActivitySmith({ apiKey: "test" }); + await client.notifications.send({ + title: "Build Failed", + tags: ["user:382", "environment:production"], + }); + + expect(sendSpy).toHaveBeenCalledWith( + { + pushNotificationRequest: { + title: "Build Failed", + tags: ["user:382", "environment:production"], + }, + }, + undefined, + ); + }); + it("preserves media and redirection for notifications.send", async () => { const ActivitySmith = require("../dist/src/index.js"); const generated = require("../dist/generated/index.js"); @@ -288,6 +313,41 @@ describe("resource wrappers", () => { ); }); + it("passes tags through liveActivities.start", async () => { + const ActivitySmith = require("../dist/src/index.js"); + const generated = require("../dist/generated/index.js"); + + const startSpy = vi + .spyOn(generated.LiveActivitiesApi.prototype, "startLiveActivity") + .mockResolvedValue({ activity_id: "act-1" }); + + const client = new ActivitySmith({ apiKey: "test" }); + await client.liveActivities.start({ + content_state: { + title: "Deploy", + number_of_steps: 4, + current_step: 1, + type: "segmented_progress", + }, + tags: ["user:382", "deployment"], + }); + + expect(startSpy).toHaveBeenCalledWith( + { + liveActivityStartRequest: { + content_state: { + title: "Deploy", + number_of_steps: 4, + current_step: 1, + type: "segmented_progress", + }, + tags: ["user:382", "deployment"], + }, + }, + undefined, + ); + }); + it("passes through progress content_state without segmented fields", async () => { const ActivitySmith = require("../dist/src/index.js"); const generated = require("../dist/generated/index.js"); @@ -521,6 +581,40 @@ describe("resource wrappers", () => { expect(endStreamSpy).toHaveBeenCalledWith({ streamKey: "prod-web-1" }, undefined); }); + it("passes tags through liveActivities.stream", async () => { + const ActivitySmith = require("../dist/src/index.js"); + const generated = require("../dist/generated/index.js"); + + const streamSpy = vi + .spyOn(generated.LiveActivitiesApi.prototype, "reconcileLiveActivityStream") + .mockResolvedValue({ operation: "started", stream_key: "prod-web-1" }); + + const client = new ActivitySmith({ apiKey: "test" }); + await client.liveActivities.stream("prod-web-1", { + content_state: { + title: "Server Health", + type: "metrics", + metrics: [{ label: "CPU", value: 9, unit: "%" }], + }, + tags: ["user:382", "environment:production"], + }); + + expect(streamSpy).toHaveBeenCalledWith( + { + streamKey: "prod-web-1", + liveActivityStreamRequest: { + content_state: { + title: "Server Health", + type: "metrics", + metrics: [{ label: "CPU", value: 9, unit: "%" }], + }, + tags: ["user:382", "environment:production"], + }, + }, + undefined, + ); + }); + it("keeps long stream aliases working", async () => { const ActivitySmith = require("../dist/src/index.js"); const generated = require("../dist/generated/index.js");