activitysmith 1.10.0 → 1.12.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamContentStateStepColorsEnum = exports.StreamContentStateStepColorEnum = exports.StreamContentStateColorEnum = exports.StreamContentStateTypeEnum = exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.LiveActivityWebhookMethod = exports.LiveActivityStreamPutResponseOperationEnum = exports.LiveActivityStreamDeleteResponseOperationEnum = exports.LiveActivityColor = exports.LiveActivityActionType = exports.ContentStateUpdateStepColorsEnum = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateUpdateTypeEnum = exports.ContentStateStartStepColorsEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorsEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = exports.ContentStateEndTypeEnum = exports.ActivityMetricColorEnum = void 0;
3
+ exports.StreamContentStateStepColorsEnum = exports.StreamContentStateStepColorEnum = exports.StreamContentStateColorEnum = exports.StreamContentStateTypeEnum = exports.RateLimitErrorCodeEnum = exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.LiveActivityWebhookMethod = exports.LiveActivityStreamPutResponseOperationEnum = exports.LiveActivityStreamDeleteResponseOperationEnum = exports.LiveActivityColor = exports.LiveActivityActionType = exports.ContentStateUpdateStepColorsEnum = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateUpdateTypeEnum = exports.ContentStateStartStepColorsEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorsEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = exports.ContentStateEndTypeEnum = exports.AppIconBadgeCountUpdateErrorCodeEnum = exports.ActivityMetricColorEnum = void 0;
4
4
  /**
5
5
  * @export
6
6
  */
@@ -16,6 +16,13 @@ exports.ActivityMetricColorEnum = {
16
16
  Yellow: 'yellow',
17
17
  Gray: 'gray'
18
18
  };
19
+ /**
20
+ * @export
21
+ */
22
+ exports.AppIconBadgeCountUpdateErrorCodeEnum = {
23
+ DeviceDisconnected: 'badge_device_disconnected',
24
+ UpdateFailed: 'badge_update_failed'
25
+ };
19
26
  /**
20
27
  * @export
21
28
  */
@@ -25,7 +32,8 @@ exports.ContentStateEndTypeEnum = {
25
32
  Metrics: 'metrics',
26
33
  Stats: 'stats',
27
34
  Alert: 'alert',
28
- Timer: 'timer'
35
+ Timer: 'timer',
36
+ Value: 'value'
29
37
  };
30
38
  /**
31
39
  * @export
@@ -81,7 +89,8 @@ exports.ContentStateStartTypeEnum = {
81
89
  Metrics: 'metrics',
82
90
  Stats: 'stats',
83
91
  Alert: 'alert',
84
- Timer: 'timer'
92
+ Timer: 'timer',
93
+ Value: 'value'
85
94
  };
86
95
  /**
87
96
  * @export
@@ -137,7 +146,8 @@ exports.ContentStateUpdateTypeEnum = {
137
146
  Metrics: 'metrics',
138
147
  Stats: 'stats',
139
148
  Alert: 'alert',
140
- Timer: 'timer'
149
+ Timer: 'timer',
150
+ Value: 'value'
141
151
  };
142
152
  /**
143
153
  * @export
@@ -248,6 +258,12 @@ exports.PushNotificationWebhookMethod = {
248
258
  Get: 'GET',
249
259
  Post: 'POST'
250
260
  };
261
+ /**
262
+ * @export
263
+ */
264
+ exports.RateLimitErrorCodeEnum = {
265
+ RateLimited: 'rate_limited'
266
+ };
251
267
  /**
252
268
  * @export
253
269
  */
@@ -257,7 +273,8 @@ exports.StreamContentStateTypeEnum = {
257
273
  Metrics: 'metrics',
258
274
  Stats: 'stats',
259
275
  Alert: 'alert',
260
- Timer: 'timer'
276
+ Timer: 'timer',
277
+ Value: 'value'
261
278
  };
262
279
  /**
263
280
  * @export
@@ -1,6 +1,10 @@
1
1
  import { AppIconBadgesApi, LiveActivitiesApi, MetricsApi, PushNotificationsApi } from "../generated/index";
2
2
  export interface ActivitySmithOptions {
3
3
  apiKey: string;
4
+ sdk?: {
5
+ name: string;
6
+ version: string;
7
+ };
4
8
  }
5
9
  type PushRequestBody = Parameters<PushNotificationsApi["sendPushNotification"]>[0]["pushNotificationRequest"];
6
10
  type PushSendParameters = Parameters<PushNotificationsApi["sendPushNotification"]>[0];
@@ -32,6 +36,7 @@ declare const LiveActivityTypes: {
32
36
  readonly stats: "stats";
33
37
  readonly alert: "alert";
34
38
  readonly timer: "timer";
39
+ readonly value: "value";
35
40
  };
36
41
  export type LiveActivityType = (typeof LiveActivityTypes)[keyof typeof LiveActivityTypes];
37
42
  export type LiveActivityAlertIcon = {
@@ -47,6 +52,7 @@ export type LiveActivityContentState = Record<string, unknown> & {
47
52
  subtitle?: string;
48
53
  type?: LiveActivityType | string;
49
54
  message?: string;
55
+ value?: string | number;
50
56
  icon?: LiveActivityAlertIcon;
51
57
  badge?: LiveActivityAlertBadge;
52
58
  color?: string;
@@ -94,6 +100,7 @@ export declare class LiveActivitiesResource {
94
100
  readonly stats: "stats";
95
101
  readonly alert: "alert";
96
102
  readonly timer: "timer";
103
+ readonly value: "value";
97
104
  };
98
105
  private readonly api;
99
106
  constructor(api: LiveActivitiesApi);
@@ -128,6 +135,7 @@ export declare class ActivitySmith {
128
135
  readonly stats: "stats";
129
136
  readonly alert: "alert";
130
137
  readonly timer: "timer";
138
+ readonly value: "value";
131
139
  };
132
140
  static readonly contentState: typeof contentState;
133
141
  static readonly alertIcon: typeof alertIcon;
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActivitySmith = exports.MetricsResource = exports.LiveActivitiesResource = exports.NotificationsResource = void 0;
4
4
  const index_1 = require("../generated/index");
5
- const SDK_VERSION = "1.10.0";
5
+ const SDK_VERSION = "1.12.0";
6
6
  const SDK_HEADER_NAME = "X-ActivitySmith-SDK";
7
- const SDK_HEADER_VALUE = `node-v${SDK_VERSION}`;
7
+ const DEFAULT_SDK_NAME = "node";
8
+ const SDK_HEADER_VALUE = `${DEFAULT_SDK_NAME}-v${SDK_VERSION}`;
8
9
  const LiveActivityTypes = {
9
10
  segmentedProgress: "segmented_progress",
10
11
  progress: "progress",
@@ -12,6 +13,7 @@ const LiveActivityTypes = {
12
13
  stats: "stats",
13
14
  alert: "alert",
14
15
  timer: "timer",
16
+ value: "value",
15
17
  };
16
18
  function withTargetChannels(request) {
17
19
  const channels = request.channels;
@@ -28,6 +30,20 @@ function withTargetChannels(request) {
28
30
  function compactObject(value) {
29
31
  return Object.fromEntries(Object.entries(value).filter(([, entryValue]) => entryValue !== undefined));
30
32
  }
33
+ function sdkHeaderValue(sdk) {
34
+ if (!sdk) {
35
+ return SDK_HEADER_VALUE;
36
+ }
37
+ const name = sdk.name.trim().toLowerCase();
38
+ const version = sdk.version.trim();
39
+ if (!/^[a-z][a-z0-9]*$/.test(name)) {
40
+ throw new Error("ActivitySmith: sdk.name must start with a letter and contain only letters and numbers");
41
+ }
42
+ if (!version) {
43
+ throw new Error("ActivitySmith: sdk.version is required");
44
+ }
45
+ return `${name}-v${version}`;
46
+ }
31
47
  function contentState(value) {
32
48
  return compactObject(value);
33
49
  }
@@ -180,7 +196,7 @@ class ActivitySmith {
180
196
  const config = new index_1.Configuration({
181
197
  accessToken: opts.apiKey,
182
198
  headers: {
183
- [SDK_HEADER_NAME]: SDK_HEADER_VALUE,
199
+ [SDK_HEADER_NAME]: sdkHeaderValue(opts.sdk),
184
200
  },
185
201
  });
186
202
  this.notifications = new NotificationsResource(new index_1.PushNotificationsApi(config));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Official ActivitySmith Node.js SDK",
5
5
  "keywords": [
6
6
  "activitysmith",
@@ -44,7 +44,7 @@
44
44
  "node": ">=18"
45
45
  },
46
46
  "scripts": {
47
- "clean": "tsc -b --clean",
47
+ "clean": "tsc -b --clean && node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
48
48
  "build": "npm run clean && tsc -b",
49
49
  "prepublishOnly": "npm run build",
50
50
  "test": "npm run build && vitest run"