@extrahorizon/javascript-sdk 8.7.0-dev-99-db18adc → 8.7.0-dev-100-fdabf51

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-100-fdabf51';
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-100-fdabf51';
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
  };
@@ -7,7 +7,30 @@ export interface NotificationV2User extends NotificationV2UserUpsert {
7
7
  creationTimestamp: Date;
8
8
  updateTimestamp: Date;
9
9
  }
10
+ export interface NotificationV2UserDeviceUpsert {
11
+ description?: string;
12
+ fcmToken?: string;
13
+ }
14
+ export interface NotificationV2UserDevice {
15
+ name: string;
16
+ description?: string;
17
+ fcmToken?: string;
18
+ creationTimestamp: Date;
19
+ updateTimestamp: Date;
20
+ }
10
21
  export interface NotificationV2UserService {
22
+ /**
23
+ * # Get the notification settings for a specific user
24
+ *
25
+ * This will always return a notification settings object, even if the user does not have any notification settings set up.
26
+ *
27
+ * ## Access via permissions
28
+ * Permission | Scopes | Effect
29
+ * - | - | -
30
+ * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
31
+ * none | | View your own notification settings
32
+ */
33
+ getById(userId: ObjectId, options?: OptionsBase): Promise<NotificationV2User>;
11
34
  /**
12
35
  * # Update a user its notification settings
13
36
  *
@@ -19,12 +42,56 @@ export interface NotificationV2UserService {
19
42
  * `UPDATE_NOTIFICATION_SETTINGS` | `global` | Update the notification settings of any user
20
43
  * none | | Update your own notification settings
21
44
  *
22
- * # Interface
45
+ * ## Interface
23
46
  * @param requestBody
24
47
  * @param options
25
48
  * @returns AffectedRecords
26
49
  */
27
50
  update(userId: ObjectId, requestBody: NotificationV2UserUpsert, options?: OptionsBase): Promise<AffectedRecords>;
51
+ /**
52
+ * # Delete the notification settings for a specific user
53
+ *
54
+ * ## Access via permissions
55
+ * Permission | Scopes | Effect
56
+ * - | - | -
57
+ * `DELETE_NOTIFICATION_SETTINGS` | `global` | Delete the notification settings of any user
58
+ * none | | Delete your own notification settings
59
+ *
60
+ * ## Interface
61
+ * @throws {ResourceUnknownError} when notification settings for the specified user do not exist
62
+ */
63
+ remove(userId: ObjectId, options?: OptionsBase): Promise<AffectedRecords>;
64
+ /**
65
+ * # Add or update a device for the notification settings of a user
66
+ *
67
+ * Create or update the device with the specified name for the user with the given Id.
68
+ *
69
+ * If the user already has a device with the specified name, it will be updated.
70
+ *
71
+ * If the user does not have a device with the specified name, it will be created.
72
+ *
73
+ * If the user does not have user settings, it will be created.
74
+ *
75
+ * ## Access via permissions
76
+ * Permission | Scopes | Effect
77
+ * - | - | -
78
+ * `UPDATE_NOTIFICATION_SETTINGS_DEVICE` | `global` | Update devices for notification settings of any user
79
+ * none | | Update devices for your own notification settings
80
+ */
81
+ addOrUpdateDevice(userId: ObjectId, deviceName: string, requestBody: NotificationV2UserDeviceUpsert, options?: OptionsBase): Promise<AffectedRecords>;
82
+ /**
83
+ * # Remove a device from the notification settings of a user
84
+ *
85
+ * ## Access via permissions
86
+ * Permission | Scopes | Effect
87
+ * - | - | -
88
+ * `DELETE_NOTIFICATION_SETTINGS_DEVICE` | `global` | Delete devices from notification settings of any user
89
+ * none | | Delete devices from your own notification settings
90
+ *
91
+ * ## Interface
92
+ * @throws {ResourceUnknownError} when specified user or device does not exist
93
+ */
94
+ removeDevice(userId: ObjectId, deviceName: string, options?: OptionsBase): Promise<AffectedRecords>;
28
95
  /**
29
96
  * # Request a list of user notification settings
30
97
  *
@@ -33,7 +100,7 @@ export interface NotificationV2UserService {
33
100
  * - | - | -
34
101
  * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
35
102
  *
36
- * # Interface
103
+ * ## Interface
37
104
  * @returns PagedResultWithPager<NotificationV2User>
38
105
  */
39
106
  find(options?: OptionsWithRql): Promise<PagedResultWithPager<NotificationV2User>>;
@@ -47,23 +114,10 @@ export interface NotificationV2UserService {
47
114
  * - | - | -
48
115
  * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
49
116
  *
50
- * # Interface
117
+ * ## Interface
51
118
  * @returns NotificationV2User[]
52
119
  */
53
120
  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
121
  /**
68
122
  * # Request the first user notification settings
69
123
  *
@@ -72,7 +126,7 @@ export interface NotificationV2UserService {
72
126
  * - | - | -
73
127
  * `VIEW_NOTIFICATION_SETTINGS` | `global` | View all notifications
74
128
  *
75
- * # Interface
129
+ * ## Interface
76
130
  * @returns NotificationV2User | undefined
77
131
  */
78
132
  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-100-fdabf51";
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-100-fdabf51",
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",