oneentry 1.0.76 → 1.0.77

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
@@ -1281,6 +1281,7 @@ Example return:
1281
1281
  },
1282
1282
  "processingData": "Unknown Type: ProcessingData",
1283
1283
  "version": 10,
1284
+ "type": "data",
1284
1285
  "identifier": "catalog",
1285
1286
  "position": 192,
1286
1287
  "attributes": [
@@ -1349,6 +1350,10 @@ default: marker <br>
1349
1350
  *position number (for sorting)* <br>
1350
1351
  example: 192 <br>
1351
1352
 
1353
+ **position:** string <br>
1354
+ *Form type* <br>
1355
+ example: 'data' <br>
1356
+
1352
1357
  **attributes:** <br>
1353
1358
  *array of attribute values from the used attribute set for displaying the form (taking into account the specified language)* <br>
1354
1359
  example: List [ OrderedMap { "type": "list", "marker": "l1", "position": 2, "listTitles": List [ OrderedMap { "title": "red", "value": 1, "position": 1, "extendedValue": null, "extendedValueType": null }, OrderedMap { "title": "yellow", "value": 2, "position": 2, "extendedValue": null, "extendedValueType": null } ], "validators": OrderedMap {}, "localizeInfos": OrderedMap { "title": "l1" } } ] <br>
@@ -1382,6 +1387,7 @@ Example return:
1382
1387
  },
1383
1388
  "processingData": "Unknown Type: ProcessingData",
1384
1389
  "version": 10,
1390
+ "type": "data",
1385
1391
  "identifier": "catalog",
1386
1392
  "position": 192,
1387
1393
  "attributes": [
@@ -1449,6 +1455,10 @@ default: marker <br>
1449
1455
  *position number (for sorting)* <br>
1450
1456
  example: 192 <br>
1451
1457
 
1458
+ **position:** string <br>
1459
+ *Form type* <br>
1460
+ example: 'data' <br>
1461
+
1452
1462
  **attributes:** <br>
1453
1463
  *array of attribute values from the used attribute set for displaying the form (taking into account the specified language)* <br>
1454
1464
  example: List [ OrderedMap { "type": "list", "marker": "l1", "position": 2, "listTitles": List [ OrderedMap { "title": "red", "value": 1, "position": 1, "extendedValue": null, "extendedValueType": null }, OrderedMap { "title": "yellow", "value": 2, "position": 2, "extendedValue": null, "extendedValueType": null } ], "validators": OrderedMap {}, "localizeInfos": OrderedMap { "title": "l1" } } ] <br>
@@ -5429,3 +5439,31 @@ example: List [ OrderedMap { "marker": "password", "value": "12345" } ] <br>
5429
5439
  example: OrderedMap { "email": "example@oneentry.cloud", "phonePush": "", "phoneSMS": "+9999999999" } <br>
5430
5440
 
5431
5441
  </details>
5442
+
5443
+ ### Users.addFCMToken(token)
5444
+
5445
+ ```js
5446
+ const value = await Users.addFCMToken('my-token')
5447
+ ```
5448
+
5449
+ > This method adds FCM token for sending Push notifications. Return true in case of successful token update.
5450
+
5451
+ Example return:
5452
+
5453
+ ```json
5454
+ true
5455
+ ```
5456
+
5457
+ ### Users.deleteFCMToken(token)
5458
+
5459
+ ```js
5460
+ const value = await Users.deleteFCMToken('my-token')
5461
+ ```
5462
+
5463
+ > This method delete FCM token for sending Push notifications. Return true in case of successful token deletion.
5464
+
5465
+ Example return:
5466
+
5467
+ ```json
5468
+ true
5469
+ ```
@@ -60,7 +60,6 @@ class AuthProviderApi extends asyncModules_1.default {
60
60
  "eventIdentifier": eventIdentifier
61
61
  };
62
62
  const result = await this._fetchPost(`/marker/${marker}/users/generate-code`, data);
63
- return result;
64
63
  }
65
64
  /**
66
65
  * User activation code verification. Returns true (if the code is correct) or false (if it is incorrect).
@@ -7,7 +7,7 @@ export default abstract class AsyncModules extends SyncModules {
7
7
  protected _url: string;
8
8
  protected constructor(state: StateModule);
9
9
  protected _fetchGet(path: string): Promise<any>;
10
- protected _fetchPost(path: string, data: any): Promise<any>;
10
+ protected _fetchPost(path: string, data?: any): Promise<any>;
11
11
  protected _fetchPut(path: string, data: any): Promise<any>;
12
12
  protected _fetchDelete(path: string, data?: any): Promise<any>;
13
13
  protected refreshToken(): Promise<boolean>;
@@ -45,7 +45,12 @@ class AsyncModules extends syncModules_1.default {
45
45
  responseData += chunk;
46
46
  });
47
47
  res.on('end', () => {
48
- resolve(JSON.parse(responseData));
48
+ try {
49
+ resolve(JSON.parse(responseData));
50
+ }
51
+ catch (error) {
52
+ resolve(responseData);
53
+ }
49
54
  });
50
55
  });
51
56
  req.on('error', (error) => {
@@ -157,7 +162,12 @@ class AsyncModules extends syncModules_1.default {
157
162
  const error = await response.json();
158
163
  throw error;
159
164
  }
160
- return await response.json();
165
+ try {
166
+ return await response.json();
167
+ }
168
+ catch (e) {
169
+ return response;
170
+ }
161
171
  }
162
172
  }
163
173
  exports.default = AsyncModules;
@@ -10,6 +10,8 @@ export default class EventsApi extends AsyncModules implements IEvents {
10
10
  constructor(state: StateModule);
11
11
  /**
12
12
  * Subscribing to an event on a product.
13
+ *
14
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
13
15
  * @param marker - Event marker.
14
16
  * @param userId - User id.
15
17
  * @param productId - Product id.
@@ -17,6 +19,8 @@ export default class EventsApi extends AsyncModules implements IEvents {
17
19
  subscribeByMarker(marker: string, userId: number, productId: number): Promise<any>;
18
20
  /**
19
21
  * Unsubscribing to an event on a product.
22
+ *
23
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
20
24
  * @param marker - Event marker.
21
25
  * @param userId - User id.
22
26
  * @param productId - Product id.
@@ -11,6 +11,8 @@ class EventsApi extends asyncModules_1.default {
11
11
  }
12
12
  /**
13
13
  * Subscribing to an event on a product.
14
+ *
15
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
14
16
  * @param marker - Event marker.
15
17
  * @param userId - User id.
16
18
  * @param productId - Product id.
@@ -24,6 +26,8 @@ class EventsApi extends asyncModules_1.default {
24
26
  }
25
27
  /**
26
28
  * Unsubscribing to an event on a product.
29
+ *
30
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
27
31
  * @param marker - Event marker.
28
32
  * @param userId - User id.
29
33
  * @param productId - Product id.
@@ -21,6 +21,7 @@ interface IForms {
21
21
  * @property {object} processingData - Form data.
22
22
  * @property {Array<IAttributes>} attribute - Array of attribute values from the used attribute set for displaying the form (taking into account the specified language)
23
23
  * @property {number} version - The version number of the object.
24
+ * @property {string} type - Form type.
24
25
  * @property {string} identifier - The textual identifier for the record field.
25
26
  * @property {number} position - The position of the object.
26
27
  */
@@ -32,6 +33,7 @@ interface IFormsEntity {
32
33
  localizeInfos: Record<string, any>;
33
34
  templateId: number | null;
34
35
  position: number;
36
+ type: string | null;
35
37
  processingType: string;
36
38
  version: number;
37
39
  }
@@ -15,7 +15,6 @@ interface IOrdersApi {
15
15
  updateOrderByMarkerAndId(marker: string, id: number, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
16
16
  getAllOrders(langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersEntity>>;
17
17
  getAllOrdersByMarker(marker: string, langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersByMarkersEntity>>;
18
- setAccessToken(accessToken: string): IOrdersApi;
19
18
  }
20
19
  /**
21
20
  * @property {string} filename
@@ -18,7 +18,6 @@ interface IPaymentsApi {
18
18
  getAccounts(): Promise<Array<IAccountsEntity>>;
19
19
  getAccountById(id: number): Promise<IAccountsEntity>;
20
20
  webhookStripe(): Promise<boolean>;
21
- setAccessToken(accessToken: string): IPaymentsApi;
22
21
  }
23
22
  /**
24
23
  *
@@ -45,4 +45,18 @@ export default class UsersApi extends AsyncModules implements IUsers {
45
45
  * }
46
46
  */
47
47
  updateUser(data: IUserBody, langCode?: string): Promise<boolean>;
48
+ /**
49
+ * Adds FCM token for sending Push notification.
50
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
51
+ *
52
+ * @param {string} token - Cloud messaging token.
53
+ */
54
+ addFCMToken(token: string): Promise<boolean>;
55
+ /**
56
+ * Delete FCM token.
57
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
58
+ *
59
+ * @param {string} token - Cloud messaging token.
60
+ */
61
+ deleteFCMToken(token: string): Promise<boolean>;
48
62
  }
@@ -54,5 +54,25 @@ class UsersApi extends asyncModules_1.default {
54
54
  const result = await this._fetchPut('/me', this._normalizePostBody(data, langCode));
55
55
  return result;
56
56
  }
57
+ /**
58
+ * Adds FCM token for sending Push notification.
59
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
60
+ *
61
+ * @param {string} token - Cloud messaging token.
62
+ */
63
+ async addFCMToken(token) {
64
+ const result = await this._fetchPost(`/me/fcm-token/${token}`);
65
+ return result;
66
+ }
67
+ /**
68
+ * Delete FCM token.
69
+ * @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
70
+ *
71
+ * @param {string} token - Cloud messaging token.
72
+ */
73
+ async deleteFCMToken(token) {
74
+ const result = await this._fetchDelete(`/me/fcm-token/${token}`);
75
+ return result;
76
+ }
57
77
  }
58
78
  exports.default = UsersApi;
@@ -1,19 +1,24 @@
1
1
  import { IAuthFormData } from "../auth-provider/authProvidersInterfaces";
2
+ import { FormDataType } from "../formsData/formsDataInterfaces";
2
3
  /**
3
4
  * Represents a interface object of Users Api.
4
5
  *
5
6
  * @property {function} subscribeByMarker - Getting the data of an authorized user.
6
7
  * @property {function} unsubscribeByMarker - Updating a single user object.
8
+ * @property {function} addFCMToken - Adds FCM token for sending Push notification.
9
+ * @property {function} deleteFCMToken - Delete FCM token.
7
10
  * @property {function} setAccessToken - Only for custom authorization. An intermediate method for setting up an access token.
8
11
  */
9
12
  interface IUsers {
10
13
  getUser(langCode?: string): Promise<IUserEntity>;
11
14
  updateUser(data: IUserBody, langCode?: string): Promise<boolean>;
12
- setAccessToken(accessToken: string): IUsers;
15
+ addFCMToken(token: string): Promise<boolean>;
16
+ deleteFCMToken(token: string): Promise<boolean>;
13
17
  }
14
18
  interface IUserEntity {
15
19
  id: number;
16
20
  identifier: string;
21
+ formData: Array<FormDataType>;
17
22
  formIdentifier: string;
18
23
  authProviderIdentifier: string;
19
24
  groups: Array<string>;
@@ -28,7 +33,7 @@ interface IUserBody {
28
33
  formData: IAuthFormData | Array<IAuthFormData>;
29
34
  notificationData: {
30
35
  email: string;
31
- phonePush: string;
36
+ phonePush: Array<string>;
32
37
  phoneSMS: string;
33
38
  };
34
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.76",
3
+ "version": "1.0.77",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",