oneentry 1.0.123 → 1.0.124

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.
Files changed (73) hide show
  1. package/dist/admins/adminsApi.d.ts +16 -8
  2. package/dist/admins/adminsApi.js +17 -9
  3. package/dist/admins/adminsInterfaces.d.ts +49 -25
  4. package/dist/attribute-sets/attributeSetsApi.d.ts +43 -21
  5. package/dist/attribute-sets/attributeSetsApi.js +49 -25
  6. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +70 -24
  7. package/dist/auth-provider/authProviderApi.d.ts +94 -83
  8. package/dist/auth-provider/authProviderApi.js +96 -83
  9. package/dist/auth-provider/authProvidersInterfaces.d.ts +188 -10
  10. package/dist/base/asyncModules.d.ts +32 -28
  11. package/dist/base/asyncModules.js +61 -36
  12. package/dist/base/syncModules.d.ts +44 -44
  13. package/dist/base/syncModules.js +65 -63
  14. package/dist/blocks/blocksApi.d.ts +56 -25
  15. package/dist/blocks/blocksApi.js +56 -25
  16. package/dist/blocks/blocksInterfaces.d.ts +71 -22
  17. package/dist/events/eventsApi.d.ts +45 -11
  18. package/dist/events/eventsApi.js +47 -17
  19. package/dist/events/eventsInterfaces.d.ts +44 -2
  20. package/dist/file-uploading/fileUploadingApi.d.ts +44 -24
  21. package/dist/file-uploading/fileUploadingApi.js +46 -27
  22. package/dist/file-uploading/fileUploadingInterfaces.d.ts +63 -14
  23. package/dist/forms/formsApi.d.ts +23 -8
  24. package/dist/forms/formsApi.js +23 -8
  25. package/dist/forms/formsInterfaces.d.ts +62 -15
  26. package/dist/formsData/formsDataApi.d.ts +33 -33
  27. package/dist/formsData/formsDataApi.js +33 -33
  28. package/dist/formsData/formsDataInterfaces.d.ts +123 -35
  29. package/dist/general-types/generalTypesApi.d.ts +12 -1
  30. package/dist/general-types/generalTypesApi.js +12 -1
  31. package/dist/general-types/generalTypesInterfaces.d.ts +18 -5
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/integration-collections/integrationCollectionsApi.d.ts +96 -70
  35. package/dist/integration-collections/integrationCollectionsApi.js +114 -81
  36. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +152 -30
  37. package/dist/locales/localesApi.d.ts +6 -1
  38. package/dist/locales/localesApi.js +6 -1
  39. package/dist/locales/localesInterfaces.d.ts +20 -11
  40. package/dist/menus/menusApi.d.ts +8 -3
  41. package/dist/menus/menusApi.js +8 -3
  42. package/dist/menus/menusInterfaces.d.ts +30 -17
  43. package/dist/orders/ordersApi.d.ts +64 -64
  44. package/dist/orders/ordersApi.js +67 -65
  45. package/dist/orders/ordersInterfaces.d.ts +174 -60
  46. package/dist/pages/pagesApi.d.ts +87 -28
  47. package/dist/pages/pagesApi.js +87 -28
  48. package/dist/pages/pagesInterfaces.d.ts +117 -23
  49. package/dist/payments/paymentsApi.d.ts +56 -22
  50. package/dist/payments/paymentsApi.js +56 -22
  51. package/dist/payments/paymentsInterfaces.d.ts +119 -36
  52. package/dist/product-statuses/productStatusesApi.d.ts +21 -15
  53. package/dist/product-statuses/productStatusesApi.js +21 -18
  54. package/dist/product-statuses/productStatusesInterfaces.d.ts +37 -9
  55. package/dist/products/productsApi.d.ts +137 -157
  56. package/dist/products/productsApi.js +137 -157
  57. package/dist/products/productsInterfaces.d.ts +240 -57
  58. package/dist/system/systemApi.d.ts +29 -10
  59. package/dist/system/systemApi.js +29 -10
  60. package/dist/system/systemInterfaces.d.ts +8 -0
  61. package/dist/templates/templatesApi.d.ts +26 -16
  62. package/dist/templates/templatesApi.js +26 -19
  63. package/dist/templates/templatesInterfaces.d.ts +40 -14
  64. package/dist/templates-preview/templatesPreviewApi.d.ts +18 -14
  65. package/dist/templates-preview/templatesPreviewApi.js +18 -17
  66. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +54 -26
  67. package/dist/users/usersApi.d.ts +37 -33
  68. package/dist/users/usersApi.js +37 -33
  69. package/dist/users/usersInterfaces.d.ts +80 -9
  70. package/dist/web-socket/wsApi.d.ts +6 -3
  71. package/dist/web-socket/wsApi.js +6 -3
  72. package/dist/web-socket/wsInterfaces.d.ts +3 -1
  73. package/package.json +11 -11
@@ -1,6 +1,6 @@
1
1
  import type { IError, ILocalizeInfo } from '../base/utils';
2
2
  /**
3
- * Represents a interface object of User Auth Provider Api.
3
+ * @interface IAuthProvider
4
4
  *
5
5
  * @property {function} signUp - User registration.
6
6
  * @property {function} generateCode - Getting a user activation code.
@@ -12,21 +12,131 @@ import type { IError, ILocalizeInfo } from '../base/utils';
12
12
  * @property {function} changePassword - Change password.
13
13
  * @property {function} getAuthProviders - Get all auth providers objects.
14
14
  * @property {function} getMarker - Get one auth provider object by marker.
15
+ *
16
+ * @description This interface defines methods for user authentication and registration through various auth providers.
15
17
  */
16
18
  interface IAuthProvider {
19
+ /**
20
+ * Registers a new user.
21
+ *
22
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
23
+ * @param {ISignUpData} data - The data required for user registration. Example: { "formIdentifier": "reg", "authData": [ { "marker": "login", "value": "example@oneentry.cloud" }, { "marker": "password", "value": "12345" } ], "formData": [ { "marker": "last_name", "type": "string", "value": "Name" } ], "notificationData": {"email": "example@oneentry.cloud", "phonePush": ["+99999999999"], "phoneSMS": "+99999999999" } }
24
+ * @param {string} [langCode] - Optional language code for localization. Default: "en_US".
25
+ *
26
+ * @return {ISignUpEntity} A promise that resolves to a sign-up entity or an error.
27
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
28
+ */
17
29
  signUp(marker: string, data: ISignUpData, langCode?: string): Promise<ISignUpEntity | IError>;
30
+ /**
31
+ * Generates an activation code for a user.
32
+ *
33
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
34
+ * @param {string} userIdentifier - The user's identifier. Example: "example@oneentry.cloud".
35
+ * @param {string} eventIdentifier - The event identifier related to the code generation. Example: "user_registration".
36
+ *
37
+ * @return {void} A promise that resolves to void or an error.
38
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
39
+ */
18
40
  generateCode(marker: string, userIdentifier: string, eventIdentifier: string): Promise<void | IError>;
41
+ /**
42
+ * Verifies a user activation code.
43
+ *
44
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
45
+ * @param {string} userIdentifier - The user's identifier. Example: "example@oneentry.cloud".
46
+ * @param {string} eventIdentifier - The event identifier related to the code verification. Example: "user_registration".
47
+ * @param {string} code - The activation code to verify. Example: "123456".
48
+ *
49
+ * @return {boolean} A promise that resolves to a boolean indicating success or failure, or an error.
50
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
51
+ */
19
52
  checkCode(marker: string, userIdentifier: string, eventIdentifier: string, code: string): Promise<boolean | IError>;
53
+ /**
54
+ * Activates a user account.
55
+ *
56
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
57
+ * @param {string} userIdentifier - The user's identifier. Example: "example@oneentry.cloud".
58
+ * @param {string} code - The activation code. Example: "123456".
59
+ *
60
+ * @return {boolean} A promise that resolves to a boolean indicating success or failure, or an error.
61
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
62
+ */
20
63
  activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean | IError>;
64
+ /**
65
+ * Authorizes a user.
66
+ *
67
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
68
+ * @param {IAuthPostBody} data - The data required for user authorization. Example: .
69
+ *
70
+ * @return {IAuthEntity} A promise that resolves to an auth entity or an error.
71
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
72
+ */
21
73
  auth(marker: string, data: IAuthPostBody): Promise<IAuthEntity | IError>;
74
+ /**
75
+ * Refreshes a user's access token.
76
+ *
77
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
78
+ * @param {string} token - The refresh token. Example: "abcdef123456".
79
+ *
80
+ * @return {IAuthEntity} A promise that resolves to an auth entity or an error.
81
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
82
+ */
22
83
  refresh(marker: string, token: string): Promise<IAuthEntity | IError>;
84
+ /**
85
+ * Logs out a user.
86
+ *
87
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
88
+ * @param {string} token - The access token. Example: "abcdef123456".
89
+ *
90
+ * @return {boolean} A promise that resolves to a boolean indicating success or failure, or an error.
91
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
92
+ */
23
93
  logout(marker: string, token: string): Promise<boolean | IError>;
24
- changePassword(marker: string, userIdentifier: string, type: number, code: string, newPassword: string, repeatPassword?: string): Promise<boolean | IError>;
94
+ /**
95
+ * Changes a user's password.
96
+ *
97
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
98
+ * @param {string} userIdentifier - The user's identifier. Example: "example@oneentry.cloud".
99
+ * @param {number} type - The type of password change. 1 for changing password, 2 for recovery. Example: 1.
100
+ * @param {string} code - The code for password change verification. Example: "123456".
101
+ * @param {string} newPassword - The new password. Example: "newPassword123".
102
+ * @param {string} [repeatPassword] - Optional repeat of the new password for confirmation. Example: "newPassword123".
103
+ *
104
+ * @return {boolean} A promise that resolves to a boolean indicating success or failure, or an error.
105
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
106
+ */
107
+ changePassword(marker: string, userIdentifier: string, eventIdentifier: string, type: number, code: string, newPassword: string, repeatPassword?: string): Promise<boolean | IError>;
108
+ /**
109
+ * Retrieves all authentication providers.
110
+ *
111
+ * @param {string} [langCode] - Optional language code for localization. Default: "en_US".
112
+ * @param {number} [offset] - Optional offset for pagination. Default: 0.
113
+ * @param {number} [limit] - Optional limit for pagination. Default: 30.
114
+ *
115
+ * @return {IAuthProvidersEntity[]} A promise that resolves to an array of auth provider entities or an error.
116
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
117
+ */
25
118
  getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<Array<IAuthProvidersEntity> | IError>;
119
+ /**
120
+ * Retrieves a specific auth provider by its marker.
121
+ *
122
+ * @param {string} marker - The marker identifying the auth provider. Example: "email".
123
+ * @param {string} [langCode] - Optional language code for localization. Default: "en_US".
124
+ *
125
+ * @return {IAuthProvidersEntity} A promise that resolves to an auth provider entity or an error.
126
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
127
+ */
26
128
  getMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity | IError>;
27
129
  }
28
130
  /**
29
- * IAuthFormData
131
+ * Interface representing the structure of authentication form data.
132
+ *
133
+ * @interface IAuthFormData
134
+ *
135
+ * @property {string} marker - A unique identifier for the form field. Example: "email".
136
+ * @property {string} type - The type of the form field, such as 'string', 'email', etc. Example: "string".
137
+ * @property {string} value - The value entered in the form field. Example: "example@oneentry.cloud".
138
+ *
139
+ * @description This interface defines the structure of authentication form data used in user registration and authentication processes.
30
140
  */
31
141
  interface IAuthFormData {
32
142
  marker: string;
@@ -34,7 +144,17 @@ interface IAuthFormData {
34
144
  value: string;
35
145
  }
36
146
  /**
37
- * ISignUpData
147
+ * Interface representing the data required for user registration.
148
+ *
149
+ * @interface ISignUpData
150
+ *
151
+ * @property {string} formIdentifier - The identifier for the registration form. Example: "reg".
152
+ * @property {string} [langCode] - Language code. Default "en_US".
153
+ * @property {Array<{ marker: string; value: string }>} authData - An array of authentication data objects, each containing a marker and its corresponding value. Example: [{ "marker": "login", "value": "example@oneentry.cloud" }, { "marker": "password", "value": "12345" }].
154
+ * @property {IAuthFormData | Array<IAuthFormData>} formData - The form data for the registration, which can be a single object or an array of objects. Example: { "marker": "last_name", "type": "string", "value": "Name" }.
155
+ * @property {Object} notificationData - An object containing notification data, including email, phonePush, and phoneSMS. Example: { "email": "example@oneentry.cloud", "phonePush": ["+99999999999"], "phoneSMS": "+99999999999" }.
156
+ *
157
+ * @description This interface defines the structure of the data required for user registration, including authentication and notification information.
38
158
  */
39
159
  interface ISignUpData {
40
160
  formIdentifier: string;
@@ -51,7 +171,20 @@ interface ISignUpData {
51
171
  };
52
172
  }
53
173
  /**
54
- * ISignUpEntity
174
+ * Interface representing a sign-up entity.
175
+ *
176
+ * @interface ISignUpEntity
177
+ *
178
+ * @property {number} id - The unique identifier of the sign-up entity. Example: 12345.
179
+ * @property {string} updatedDate - The date when the sign-up entity was last updated. Example: "2023-10-01T12:00:00Z".
180
+ * @property {number} version - The version number of the sign-up entity. Example: 1.
181
+ * @property {string} identifier - A unique string that identifies the sign-up entity. Example: "signup_12345".
182
+ * @property {boolean} isActive - Indicates whether the sign-up entity is active. Example: true.
183
+ * @property {Array<{ marker: string; value: string }>} formData - An array of objects representing the form data, each containing a marker and its corresponding value. Example: [{ "marker": "first_name", "value": "John" }, { "marker": "last_name", "value": "Doe" }].
184
+ * @property {Object} notificationData - An object containing notification data, including email, phonePush, and phoneSMS. Example: { "email": "example@oneentry.cloud", "phonePush": ["+99999999999"], "phoneSMS": "+99999999999" }.
185
+ * @property {string} locale - The locale or language code associated with the sign-up entity. Example: "en_US".
186
+ *
187
+ * @description This interface defines the structure of a sign-up entity.
55
188
  */
56
189
  interface ISignUpEntity {
57
190
  id: number;
@@ -71,14 +204,30 @@ interface ISignUpEntity {
71
204
  locale: string;
72
205
  }
73
206
  /**
74
- * ICodeEntity
207
+ * Interface representing a code entity used for user registration or verification processes.
208
+ *
209
+ * @interface ICodeEntity
210
+ *
211
+ * @property {string} code - The activation code for user registration or verification. Example: "123456".
212
+ * @property {string} expiredDate - The date when the activation code expires. Example: "2023-10-01T12:00:00Z".
213
+ *
214
+ * @description This interface defines the structure of a code entity used for user registration or verification processes.
75
215
  */
76
216
  interface ICodeEntity {
77
217
  code: string;
78
218
  expiredDate: string;
79
219
  }
80
220
  /**
81
- * IAuthEntity
221
+ * Interface representing an authentication entity.
222
+ *
223
+ * @interface IAuthEntity
224
+ *
225
+ * @property {string} userIdentifier - The unique identifier for the user. Example: "user12345".
226
+ * @property {string} authProviderIdentifier - The identifier for the authentication provider. Example: "email".
227
+ * @property {string} accessToken - The access token for the user session. Example: "abcdef123456".
228
+ * @property {string} refreshToken - The refresh token for renewing the access token. Example: "ghijkl789012".
229
+ *
230
+ * @description This interface defines the structure of an authentication entity.
82
231
  */
83
232
  interface IAuthEntity {
84
233
  userIdentifier: string;
@@ -87,7 +236,21 @@ interface IAuthEntity {
87
236
  refreshToken: string;
88
237
  }
89
238
  /**
90
- * IAuthProvidersEntity
239
+ * Interface representing an authentication provider entity.
240
+ *
241
+ * @interface IAuthProvidersEntity
242
+ *
243
+ * @property {number} id - The unique identifier of the auth provider entity. Example: 194.
244
+ * @property {ILocalizeInfo} localizeInfos - Localized information for the auth provider. Example: .
245
+ * @property {number} version - The version number of the auth provider entity. Example: 1.
246
+ * @property {string} identifier - A unique string that identifies the auth provider. Example: "email".
247
+ * @property {boolean} isActive - Indicates whether the auth provider is active. Example: true.
248
+ * @property {boolean} isCheckCode - Indicates whether the auth provider requires code verification. Example: false.
249
+ * @property {string} type - The type of the auth provider (e.g., 'email', 'google', etc.). Example: "email".
250
+ * @property {string | null} formIdentifier - The identifier for the form associated with the auth provider, or null if not applicable. Example: "reg_form".
251
+ * @property {Record<string, any>} config - Configuration settings for the auth provider, stored as a key-value pair object. Example: .
252
+ *
253
+ * @description This interface defines the structure of an authentication provider entity.
91
254
  */
92
255
  interface IAuthProvidersEntity {
93
256
  id: number;
@@ -98,10 +261,25 @@ interface IAuthProvidersEntity {
98
261
  isCheckCode: boolean;
99
262
  type: string;
100
263
  formIdentifier: string | null;
101
- config: Record<string, any>;
264
+ config: IAuthProvidersEntityConfig;
265
+ userGroupIdentifier: string;
266
+ }
267
+ interface IAuthProvidersEntityConfig {
268
+ accessTokenTtlSec: string;
269
+ refreshTokenTtlMc: string;
270
+ tokenSecretKey: string;
271
+ deleteNoneActiveUsersAfterDays: string;
272
+ systemCodeTlsSec: string;
273
+ systemCodeLength: string;
102
274
  }
103
275
  /**
104
- * IAuthPostBody
276
+ * Interface representing the body used in authentication requests.
277
+ *
278
+ * @interface IAuthPostBody
279
+ *
280
+ * @property {Array<{ marker: string; value: string | number }>} authData - An array of authentication data objects, each containing a marker and its corresponding value. Example: [{ "marker": "login", "value": "user@example.com" }]
281
+ *
282
+ * @description This interface defines the structure of the body used in authentication requests, containing an array of authentication data.
105
283
  */
106
284
  interface IAuthPostBody {
107
285
  authData: Array<{
@@ -1,58 +1,62 @@
1
1
  import type StateModule from './stateModule';
2
2
  import SyncModules from './syncModules';
3
+ /**
4
+ * Abstract class AsyncModules extends SyncModules to provide asynchronous HTTP request functionalities.
5
+ */
3
6
  export default abstract class AsyncModules extends SyncModules {
4
7
  protected state: StateModule;
5
8
  protected _NO_FETCH: boolean;
6
9
  protected _https: any;
7
10
  protected _url: string;
11
+ /**
12
+ * Constructor initializes the AsyncModules with a given state.
13
+ * @param state - Instance of StateModule containing configuration and state data.
14
+ */
8
15
  protected constructor(state: StateModule);
9
16
  /**
10
- * fetchGet
11
- *
12
- * @param path
13
- * @returns
17
+ * Performs an HTTP GET request.
18
+ * @param path - The path to append to the base URL.
19
+ * @return A promise resolving to the response data.
14
20
  */
15
21
  protected _fetchGet(path: string): Promise<any>;
16
22
  /**
17
- * fetchPost
18
- *
19
- * @param path
20
- * @param data
21
- * @returns
23
+ * Performs an HTTP POST request.
24
+ * @param path - The path to append to the base URL.
25
+ * @param data - The data to send in the request body.
26
+ * @return A promise resolving to the response data.
22
27
  */
23
28
  protected _fetchPost(path: string, data?: any): Promise<any>;
24
29
  /**
25
- * fetchPut
26
- * @param path
27
- * @param data
28
- * @returns
30
+ * Performs an HTTP PUT request.
31
+ * @param path - The path to append to the base URL.
32
+ * @param data - The data to send in the request body.
33
+ * @return A promise resolving to the response data.
29
34
  */
30
35
  protected _fetchPut(path: string, data: any): Promise<any>;
31
36
  /**
32
- * _fetchDelete
33
- * @param path
34
- * @param data
35
- * @returns
37
+ * Performs an HTTP DELETE request.
38
+ * @param path - The path to append to the base URL.
39
+ * @param data - Optional data to send in the request body.
40
+ * @return A promise resolving to the response data.
36
41
  */
37
42
  protected _fetchDelete(path: string, data?: any): Promise<any>;
38
43
  /**
39
- * refreshToken
40
- *
41
- * @returns
44
+ * Refreshes the authentication token.
45
+ * @return A promise resolving to a boolean indicating success or failure.
42
46
  */
43
47
  protected refreshToken(): Promise<boolean>;
44
48
  /**
45
- * makeOptions
46
- * @param method
47
- * @param data
48
- * @returns
49
+ * Creates options for HTTP requests.
50
+ * @param method - The HTTP method (GET, POST, etc.).
51
+ * @param data - Optional data to include in the request body.
52
+ * @return An object representing the request options.
49
53
  */
50
54
  private makeOptions;
51
55
  /**
52
- * browserResponse
53
- * @param path
54
- * @param options
55
- * @returns
56
+ * Handles responses from the browser's fetch API.
57
+ * @param path - The path to append to the base URL.
58
+ * @param options - The options for the fetch request.
59
+ * @return A promise resolving to the response data.
56
60
  */
57
61
  private browserResponse;
58
62
  }
@@ -5,7 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const syncModules_1 = __importDefault(require("./syncModules"));
7
7
  // import { IError } from './utils';
8
+ /**
9
+ * Abstract class AsyncModules extends SyncModules to provide asynchronous HTTP request functionalities.
10
+ */
8
11
  class AsyncModules extends syncModules_1.default {
12
+ /**
13
+ * Constructor initializes the AsyncModules with a given state.
14
+ * @param state - Instance of StateModule containing configuration and state data.
15
+ */
9
16
  constructor(state) {
10
17
  var _a;
11
18
  super(state);
@@ -15,25 +22,31 @@ class AsyncModules extends syncModules_1.default {
15
22
  this._https = (_a = state._https) !== null && _a !== void 0 ? _a : null;
16
23
  }
17
24
  /**
18
- * fetchGet
19
- *
20
- * @param path
21
- * @returns
25
+ * Performs an HTTP GET request.
26
+ * @param path - The path to append to the base URL.
27
+ * @return A promise resolving to the response data.
22
28
  */
23
29
  async _fetchGet(path) {
24
30
  const options = this.makeOptions('GET');
31
+ // console.log(this._NO_FETCH);
25
32
  if (!this._NO_FETCH) {
26
33
  return await this.browserResponse(path, options);
27
34
  }
28
35
  else {
29
36
  return new Promise((resolve, reject) => {
30
37
  const req = this._https.get(this._getFullPath(path), options, (res) => {
31
- let data = '';
38
+ let responseData = '';
32
39
  res.on('data', (chunk) => {
33
- data += chunk;
40
+ responseData += chunk;
34
41
  });
35
42
  res.on('end', () => {
36
- resolve(JSON.parse(data));
43
+ try {
44
+ resolve(JSON.parse(responseData));
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
+ }
47
+ catch (error) {
48
+ resolve(responseData);
49
+ }
37
50
  });
38
51
  });
39
52
  req.on('error', (error) => {
@@ -43,11 +56,10 @@ class AsyncModules extends syncModules_1.default {
43
56
  }
44
57
  }
45
58
  /**
46
- * fetchPost
47
- *
48
- * @param path
49
- * @param data
50
- * @returns
59
+ * Performs an HTTP POST request.
60
+ * @param path - The path to append to the base URL.
61
+ * @param data - The data to send in the request body.
62
+ * @return A promise resolving to the response data.
51
63
  */
52
64
  async _fetchPost(path, data) {
53
65
  const options = this.makeOptions('POST', data);
@@ -80,10 +92,10 @@ class AsyncModules extends syncModules_1.default {
80
92
  }
81
93
  }
82
94
  /**
83
- * fetchPut
84
- * @param path
85
- * @param data
86
- * @returns
95
+ * Performs an HTTP PUT request.
96
+ * @param path - The path to append to the base URL.
97
+ * @param data - The data to send in the request body.
98
+ * @return A promise resolving to the response data.
87
99
  */
88
100
  async _fetchPut(path, data) {
89
101
  const options = this.makeOptions('PUT', data);
@@ -98,7 +110,13 @@ class AsyncModules extends syncModules_1.default {
98
110
  responseData += chunk;
99
111
  });
100
112
  res.on('end', () => {
101
- resolve(JSON.parse(responseData));
113
+ try {
114
+ resolve(JSON.parse(responseData));
115
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
116
+ }
117
+ catch (error) {
118
+ resolve(responseData);
119
+ }
102
120
  });
103
121
  });
104
122
  req.on('error', (error) => {
@@ -110,10 +128,10 @@ class AsyncModules extends syncModules_1.default {
110
128
  }
111
129
  }
112
130
  /**
113
- * _fetchDelete
114
- * @param path
115
- * @param data
116
- * @returns
131
+ * Performs an HTTP DELETE request.
132
+ * @param path - The path to append to the base URL.
133
+ * @param data - Optional data to send in the request body.
134
+ * @return A promise resolving to the response data.
117
135
  */
118
136
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
119
137
  async _fetchDelete(path, data) {
@@ -124,12 +142,18 @@ class AsyncModules extends syncModules_1.default {
124
142
  else {
125
143
  return new Promise((resolve, reject) => {
126
144
  const req = this._https.delete(this._getFullPath(path), options, (res) => {
127
- let data = '';
145
+ let responseData = '';
128
146
  res.on('data', (chunk) => {
129
- data += chunk;
147
+ responseData += chunk;
130
148
  });
131
149
  res.on('end', () => {
132
- resolve(JSON.parse(data));
150
+ try {
151
+ resolve(JSON.parse(responseData));
152
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
153
+ }
154
+ catch (error) {
155
+ resolve(responseData);
156
+ }
133
157
  });
134
158
  });
135
159
  req.on('error', (error) => {
@@ -139,9 +163,8 @@ class AsyncModules extends syncModules_1.default {
139
163
  }
140
164
  }
141
165
  /**
142
- * refreshToken
143
- *
144
- * @returns
166
+ * Refreshes the authentication token.
167
+ * @return A promise resolving to a boolean indicating success or failure.
145
168
  */
146
169
  async refreshToken() {
147
170
  const response = await fetch(this.state.url +
@@ -167,10 +190,10 @@ class AsyncModules extends syncModules_1.default {
167
190
  }
168
191
  }
169
192
  /**
170
- * makeOptions
171
- * @param method
172
- * @param data
173
- * @returns
193
+ * Creates options for HTTP requests.
194
+ * @param method - The HTTP method (GET, POST, etc.).
195
+ * @param data - Optional data to include in the request body.
196
+ * @return An object representing the request options.
174
197
  */
175
198
  makeOptions(method, data) {
176
199
  const options = {
@@ -197,17 +220,19 @@ class AsyncModules extends syncModules_1.default {
197
220
  return options;
198
221
  }
199
222
  /**
200
- * browserResponse
201
- * @param path
202
- * @param options
203
- * @returns
223
+ * Handles responses from the browser's fetch API.
224
+ * @param path - The path to append to the base URL.
225
+ * @param options - The options for the fetch request.
226
+ * @return A promise resolving to the response data.
204
227
  */
205
228
  async browserResponse(path, options) {
206
229
  try {
207
230
  const response = await fetch(this._getFullPath(path), options);
208
231
  if (response.ok) {
209
232
  try {
210
- return await response.json();
233
+ const text = await response.text();
234
+ return text ? JSON.parse(text) : {};
235
+ // return await response.json();
211
236
  }
212
237
  catch (e) {
213
238
  return e;