@extrahorizon/javascript-sdk 8.7.0-dev-99-db18adc → 8.7.0-dev-101-9e49b6c

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.
@@ -5361,10 +5361,26 @@ var notificationV2Users = (client, httpWithAuth) => {
5361
5361
  return result.data;
5362
5362
  }
5363
5363
  return {
5364
+ async getById(userId, options) {
5365
+ const result = await client.get(httpWithAuth, `/users/${userId}`, options);
5366
+ return result.data;
5367
+ },
5364
5368
  async update(userId, requestBody, options) {
5365
5369
  const result = await client.put(httpWithAuth, `/users/${userId}`, requestBody, options);
5366
5370
  return result.data;
5367
5371
  },
5372
+ async remove(userId, options) {
5373
+ const result = await client.delete(httpWithAuth, `/users/${userId}`, options);
5374
+ return result.data;
5375
+ },
5376
+ async addOrUpdateDevice(userId, deviceName, requestBody, options) {
5377
+ const result = await client.put(httpWithAuth, `/users/${userId}/devices/${deviceName}`, requestBody, options);
5378
+ return result.data;
5379
+ },
5380
+ async removeDevice(userId, deviceName, options) {
5381
+ const result = await client.delete(httpWithAuth, `/users/${userId}/devices/${deviceName}`, options);
5382
+ return result.data;
5383
+ },
5368
5384
  async find(options) {
5369
5385
  const result = await find(options);
5370
5386
  return addPagersFn(find, options, result);
@@ -5372,11 +5388,6 @@ var notificationV2Users = (client, httpWithAuth) => {
5372
5388
  async findAll(options) {
5373
5389
  return findAllGeneric(find, options);
5374
5390
  },
5375
- async findByUserId(userId, options) {
5376
- const rqlWithUserId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', userId).build();
5377
- const result = await find({ ...options, rql: rqlWithUserId });
5378
- return result.data[0];
5379
- },
5380
5391
  async findFirst(options) {
5381
5392
  const result = await find(options);
5382
5393
  return result.data[0];
@@ -5487,7 +5498,7 @@ const logsService = (httpWithAuth) => {
5487
5498
  };
5488
5499
  };
5489
5500
 
5490
- const version = '8.7.0-dev-99-db18adc';
5501
+ const version = '8.7.0-dev-101-9e49b6c';
5491
5502
 
5492
5503
  /**
5493
5504
  * Create ExtraHorizon client.
package/build/index.mjs CHANGED
@@ -5331,10 +5331,26 @@ var notificationV2Users = (client, httpWithAuth) => {
5331
5331
  return result.data;
5332
5332
  }
5333
5333
  return {
5334
+ async getById(userId, options) {
5335
+ const result = await client.get(httpWithAuth, `/users/${userId}`, options);
5336
+ return result.data;
5337
+ },
5334
5338
  async update(userId, requestBody, options) {
5335
5339
  const result = await client.put(httpWithAuth, `/users/${userId}`, requestBody, options);
5336
5340
  return result.data;
5337
5341
  },
5342
+ async remove(userId, options) {
5343
+ const result = await client.delete(httpWithAuth, `/users/${userId}`, options);
5344
+ return result.data;
5345
+ },
5346
+ async addOrUpdateDevice(userId, deviceName, requestBody, options) {
5347
+ const result = await client.put(httpWithAuth, `/users/${userId}/devices/${deviceName}`, requestBody, options);
5348
+ return result.data;
5349
+ },
5350
+ async removeDevice(userId, deviceName, options) {
5351
+ const result = await client.delete(httpWithAuth, `/users/${userId}/devices/${deviceName}`, options);
5352
+ return result.data;
5353
+ },
5338
5354
  async find(options) {
5339
5355
  const result = await find(options);
5340
5356
  return addPagersFn(find, options, result);
@@ -5342,11 +5358,6 @@ var notificationV2Users = (client, httpWithAuth) => {
5342
5358
  async findAll(options) {
5343
5359
  return findAllGeneric(find, options);
5344
5360
  },
5345
- async findByUserId(userId, options) {
5346
- const rqlWithUserId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', userId).build();
5347
- const result = await find({ ...options, rql: rqlWithUserId });
5348
- return result.data[0];
5349
- },
5350
5361
  async findFirst(options) {
5351
5362
  const result = await find(options);
5352
5363
  return result.data[0];
@@ -5457,7 +5468,7 @@ const logsService = (httpWithAuth) => {
5457
5468
  };
5458
5469
  };
5459
5470
 
5460
- const version = '8.7.0-dev-99-db18adc';
5471
+ const version = '8.7.0-dev-101-9e49b6c';
5461
5472
 
5462
5473
  /**
5463
5474
  * Create ExtraHorizon client.
@@ -436,10 +436,13 @@ export declare type MockClientOAuth1<MockFn> = {
436
436
  findFirst: MockFn;
437
437
  findById: MockFn;
438
438
  users: {
439
+ getById: MockFn;
439
440
  update: MockFn;
441
+ remove: MockFn;
442
+ addOrUpdateDevice: MockFn;
443
+ removeDevice: MockFn;
440
444
  find: MockFn;
441
445
  findAll: MockFn;
442
- findByUserId: MockFn;
443
446
  findFirst: MockFn;
444
447
  };
445
448
  };
@@ -986,10 +989,13 @@ export declare type MockClientOAuth2<MockFn> = {
986
989
  findFirst: MockFn;
987
990
  findById: MockFn;
988
991
  users: {
992
+ getById: MockFn;
989
993
  update: MockFn;
994
+ remove: MockFn;
995
+ addOrUpdateDevice: MockFn;
996
+ removeDevice: MockFn;
990
997
  find: MockFn;
991
998
  findAll: MockFn;
992
- findByUserId: MockFn;
993
999
  findFirst: MockFn;
994
1000
  };
995
1001
  };
@@ -1536,10 +1542,13 @@ export declare type MockClientProxy<MockFn> = {
1536
1542
  findFirst: MockFn;
1537
1543
  findById: MockFn;
1538
1544
  users: {
1545
+ getById: MockFn;
1539
1546
  update: MockFn;
1547
+ remove: MockFn;
1548
+ addOrUpdateDevice: MockFn;
1549
+ removeDevice: MockFn;
1540
1550
  find: MockFn;
1541
1551
  findAll: MockFn;
1542
- findByUserId: MockFn;
1543
1552
  findFirst: MockFn;
1544
1553
  };
1545
1554
  };
@@ -1,13 +1,38 @@
1
1
  import { AffectedRecords, ObjectId, OptionsBase, OptionsWithRql, PagedResultWithPager } from '../../types';
2
2
  export interface NotificationV2UserUpsert {
3
+ /** @deprecated We recommend using `devices` instead */
3
4
  fcmToken: string;
4
5
  }
5
6
  export interface NotificationV2User extends NotificationV2UserUpsert {
6
7
  id: ObjectId;
8
+ devices?: NotificationV2UserDevice[];
9
+ creationTimestamp: Date;
10
+ updateTimestamp: Date;
11
+ }
12
+ export interface NotificationV2UserDeviceUpsert {
13
+ description?: string | null;
14
+ fcmToken?: string | null;
15
+ }
16
+ export interface NotificationV2UserDevice {
17
+ name: string;
18
+ description?: string;
19
+ fcmToken?: string;
7
20
  creationTimestamp: Date;
8
21
  updateTimestamp: Date;
9
22
  }
10
23
  export interface NotificationV2UserService {
24
+ /**
25
+ * # Get the notification settings for a specific user
26
+ *
27
+ * This will always return a notification settings object, even if the user does not have any notification settings set up.
28
+ *
29
+ * ## Access via permissions
30
+ * Permission | Scopes | Effect
31
+ * - | - | -
32
+ * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
33
+ * none | | View your own notification settings
34
+ */
35
+ getById(userId: ObjectId, options?: OptionsBase): Promise<NotificationV2User>;
11
36
  /**
12
37
  * # Update a user its notification settings
13
38
  *
@@ -19,12 +44,58 @@ export interface NotificationV2UserService {
19
44
  * `UPDATE_NOTIFICATION_SETTINGS` | `global` | Update the notification settings of any user
20
45
  * none | | Update your own notification settings
21
46
  *
22
- * # Interface
47
+ * ## Interface
23
48
  * @param requestBody
24
49
  * @param options
25
50
  * @returns AffectedRecords
26
51
  */
27
52
  update(userId: ObjectId, requestBody: NotificationV2UserUpsert, options?: OptionsBase): Promise<AffectedRecords>;
53
+ /**
54
+ * # Delete the notification settings for a specific user
55
+ *
56
+ * ## Access via permissions
57
+ * Permission | Scopes | Effect
58
+ * - | - | -
59
+ * `DELETE_NOTIFICATION_SETTINGS` | `global` | Delete the notification settings of any user
60
+ * none | | Delete your own notification settings
61
+ *
62
+ * ## Interface
63
+ * @throws {ResourceUnknownError} when notification settings for the specified user do not exist
64
+ */
65
+ remove(userId: ObjectId, options?: OptionsBase): Promise<AffectedRecords>;
66
+ /**
67
+ * # Add or update a device for the notification settings of a user
68
+ *
69
+ * Create or update the device with the specified name for the user with the given Id.
70
+ *
71
+ * If the user already has a device with the specified name, it will be updated.
72
+ *
73
+ * If the user does not have a device with the specified name, it will be created.
74
+ *
75
+ * If the user does not have user settings, it will be created.
76
+ *
77
+ * Setting `null` for `fcmToken` or `description` will remove the configured value.
78
+ *
79
+ * ## Access via permissions
80
+ * Permission | Scopes | Effect
81
+ * - | - | -
82
+ * `UPDATE_NOTIFICATION_SETTINGS_DEVICE` | `global` | Update devices for notification settings of any user
83
+ * none | | Update devices for your own notification settings
84
+ */
85
+ addOrUpdateDevice(userId: ObjectId, deviceName: string, requestBody: NotificationV2UserDeviceUpsert, options?: OptionsBase): Promise<AffectedRecords>;
86
+ /**
87
+ * # Remove a device from the notification settings of a user
88
+ *
89
+ * ## Access via permissions
90
+ * Permission | Scopes | Effect
91
+ * - | - | -
92
+ * `DELETE_NOTIFICATION_SETTINGS_DEVICE` | `global` | Delete devices from notification settings of any user
93
+ * none | | Delete devices from your own notification settings
94
+ *
95
+ * ## Interface
96
+ * @throws {ResourceUnknownError} when specified user or device does not exist
97
+ */
98
+ removeDevice(userId: ObjectId, deviceName: string, options?: OptionsBase): Promise<AffectedRecords>;
28
99
  /**
29
100
  * # Request a list of user notification settings
30
101
  *
@@ -33,7 +104,7 @@ export interface NotificationV2UserService {
33
104
  * - | - | -
34
105
  * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
35
106
  *
36
- * # Interface
107
+ * ## Interface
37
108
  * @returns PagedResultWithPager<NotificationV2User>
38
109
  */
39
110
  find(options?: OptionsWithRql): Promise<PagedResultWithPager<NotificationV2User>>;
@@ -47,23 +118,10 @@ export interface NotificationV2UserService {
47
118
  * - | - | -
48
119
  * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
49
120
  *
50
- * # Interface
121
+ * ## Interface
51
122
  * @returns NotificationV2User[]
52
123
  */
53
124
  findAll(options?: OptionsWithRql): Promise<NotificationV2User[]>;
54
- /**
55
- * # Request notification settings for a specific user
56
- *
57
- * ## Access via permissions
58
- * Permission | Scopes | Effect
59
- * - | - | -
60
- * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
61
- *
62
- * # Interface
63
- * @param userId the user id to search for
64
- * @returns NotificationV2User | undefined
65
- */
66
- findByUserId(userId: ObjectId, options?: OptionsWithRql): Promise<NotificationV2User | undefined>;
67
125
  /**
68
126
  * # Request the first user notification settings
69
127
  *
@@ -72,7 +130,7 @@ export interface NotificationV2UserService {
72
130
  * - | - | -
73
131
  * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
74
132
  *
75
- * # Interface
133
+ * ## Interface
76
134
  * @returns NotificationV2User | undefined
77
135
  */
78
136
  findFirst(options?: OptionsWithRql): Promise<NotificationV2User | undefined>;
@@ -1 +1 @@
1
- export declare const version = "8.7.0-dev-99-db18adc";
1
+ export declare const version = "8.7.0-dev-101-9e49b6c";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/javascript-sdk",
3
- "version": "8.7.0-dev-99-db18adc",
3
+ "version": "8.7.0-dev-101-9e49b6c",
4
4
  "description": "This package serves as a JavaScript wrapper around all Extra Horizon cloud services.",
5
5
  "main": "build/index.cjs.js",
6
6
  "types": "build/types/index.d.ts",