oneentry 1.0.127 → 1.0.128
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/dist/admins/adminsApi.d.ts +20 -20
- package/dist/admins/adminsApi.js +20 -20
- package/dist/admins/adminsInterfaces.d.ts +43 -43
- package/dist/attribute-sets/attributeSetsApi.d.ts +16 -16
- package/dist/attribute-sets/attributeSetsApi.js +16 -16
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +87 -85
- package/dist/auth-provider/authProviderApi.d.ts +126 -126
- package/dist/auth-provider/authProviderApi.js +126 -126
- package/dist/auth-provider/authProvidersInterfaces.d.ts +201 -201
- package/dist/base/asyncModules.d.ts +17 -17
- package/dist/base/asyncModules.js +26 -21
- package/dist/base/result.d.ts +5 -5
- package/dist/base/result.js +5 -9
- package/dist/base/stateModule.d.ts +1 -1
- package/dist/base/stateModule.js +1 -1
- package/dist/base/syncModules.d.ts +35 -35
- package/dist/base/syncModules.js +92 -45
- package/dist/base/utils.d.ts +13 -13
- package/dist/blocks/blocksApi.d.ts +24 -24
- package/dist/blocks/blocksApi.js +24 -24
- package/dist/blocks/blocksInterfaces.d.ts +85 -85
- package/dist/events/eventsApi.d.ts +11 -11
- package/dist/events/eventsApi.js +11 -11
- package/dist/events/eventsInterfaces.d.ts +23 -23
- package/dist/file-uploading/fileUploadingApi.d.ts +38 -38
- package/dist/file-uploading/fileUploadingApi.js +38 -38
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +44 -44
- package/dist/forms/formsApi.d.ts +7 -7
- package/dist/forms/formsApi.js +7 -7
- package/dist/forms/formsInterfaces.d.ts +43 -31
- package/dist/forms-data/formsDataApi.d.ts +37 -37
- package/dist/forms-data/formsDataApi.js +37 -38
- package/dist/forms-data/formsDataInterfaces.d.ts +219 -219
- package/dist/general-types/generalTypesApi.d.ts +1 -1
- package/dist/general-types/generalTypesApi.js +1 -1
- package/dist/general-types/generalTypesInterfaces.d.ts +2 -2
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/integration-collections/integrationCollectionsApi.d.ts +76 -80
- package/dist/integration-collections/integrationCollectionsApi.js +76 -80
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +145 -149
- package/dist/locales/localesInterfaces.d.ts +8 -8
- package/dist/menus/menusApi.d.ts +3 -3
- package/dist/menus/menusApi.js +3 -3
- package/dist/menus/menusInterfaces.d.ts +39 -39
- package/dist/orders/ordersApi.d.ts +56 -56
- package/dist/orders/ordersApi.js +56 -56
- package/dist/orders/ordersInterfaces.d.ts +204 -198
- package/dist/pages/pagesApi.d.ts +60 -60
- package/dist/pages/pagesApi.js +60 -60
- package/dist/pages/pagesInterfaces.d.ts +133 -141
- package/dist/payments/paymentsApi.d.ts +15 -15
- package/dist/payments/paymentsApi.js +15 -15
- package/dist/payments/paymentsInterfaces.d.ts +55 -55
- package/dist/product-statuses/productStatusesApi.d.ts +7 -7
- package/dist/product-statuses/productStatusesApi.js +7 -7
- package/dist/product-statuses/productStatusesInterfaces.d.ts +21 -21
- package/dist/products/productsApi.d.ts +240 -240
- package/dist/products/productsApi.js +240 -240
- package/dist/products/productsInterfaces.d.ts +311 -311
- package/dist/system/systemApi.d.ts +10 -10
- package/dist/system/systemApi.js +10 -10
- package/dist/templates/templatesApi.d.ts +8 -8
- package/dist/templates/templatesApi.js +8 -8
- package/dist/templates/templatesInterfaces.d.ts +22 -22
- package/dist/templates-preview/templatesPreviewApi.d.ts +5 -5
- package/dist/templates-preview/templatesPreviewApi.js +5 -5
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +54 -54
- package/dist/users/usersApi.d.ts +29 -29
- package/dist/users/usersApi.js +29 -29
- package/dist/users/usersInterfaces.d.ts +77 -77
- package/package.json +1 -1
|
@@ -17,32 +17,32 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
17
17
|
protected constructor(state: StateModule);
|
|
18
18
|
/**
|
|
19
19
|
* Performs an HTTP GET request.
|
|
20
|
-
* @param
|
|
21
|
-
* @returns {Promise<any>}
|
|
20
|
+
* @param {string} path - The path to append to the base URL.
|
|
21
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
22
22
|
* @description Define a protected asynchronous method '_fetchGet' that performs a GET request
|
|
23
23
|
*/
|
|
24
24
|
protected _fetchGet(path: string): Promise<any>;
|
|
25
25
|
/**
|
|
26
26
|
* Performs an HTTP POST request.
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @returns {Promise<any>}
|
|
27
|
+
* @param {string} path - The path to append to the base URL.
|
|
28
|
+
* @param {any} [data] - The data to send in the request body.
|
|
29
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
30
30
|
* @description Define a protected asynchronous method '_fetchPost' that performs a POST request
|
|
31
31
|
*/
|
|
32
32
|
protected _fetchPost(path: string, data?: any): Promise<any>;
|
|
33
33
|
/**
|
|
34
34
|
* Performs an HTTP PUT request.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @returns {Promise<any>}
|
|
35
|
+
* @param {string} path - The path to append to the base URL.
|
|
36
|
+
* @param {any} body - The data to send in the request body.
|
|
37
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
38
38
|
* @description Define a protected asynchronous method '_fetchPut' that performs a PUT request
|
|
39
39
|
*/
|
|
40
40
|
protected _fetchPut(path: string, body: any): Promise<any>;
|
|
41
41
|
/**
|
|
42
42
|
* Performs an HTTP DELETE request.
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @returns {Promise<any>}
|
|
43
|
+
* @param {string} path - The path to append to the base URL.
|
|
44
|
+
* @param {any} body - The body of the request.
|
|
45
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
46
46
|
* @description Define a protected asynchronous method '_fetchDelete' that performs a DELETE request
|
|
47
47
|
*/
|
|
48
48
|
protected _fetchDelete(path: string, body?: any): Promise<any>;
|
|
@@ -54,16 +54,16 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
54
54
|
protected refreshToken(): Promise<boolean>;
|
|
55
55
|
/**
|
|
56
56
|
* Creates options for HTTP requests.
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @returns {any}
|
|
57
|
+
* @param {string} method - The HTTP method (GET, POST, PUT, DELETE, etc.).
|
|
58
|
+
* @param {any} data - Optional data to include in the request body.
|
|
59
|
+
* @returns {any} An object representing the request options.
|
|
60
60
|
*/
|
|
61
61
|
private makeOptions;
|
|
62
62
|
/**
|
|
63
63
|
* Handles responses from the browser's fetch API.
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @returns {any}
|
|
64
|
+
* @param {string} path - The path to append to the base URL.
|
|
65
|
+
* @param {any} options - The options for the fetch request.
|
|
66
|
+
* @returns {any} A promise resolving to the response data.
|
|
67
67
|
* @description Define an asynchronous method 'browserResponse' that takes a path and options as parameters
|
|
68
68
|
*/
|
|
69
69
|
private browserResponse;
|
|
@@ -25,8 +25,8 @@ class AsyncModules extends syncModules_1.default {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Performs an HTTP GET request.
|
|
28
|
-
* @param
|
|
29
|
-
* @returns {Promise<any>}
|
|
28
|
+
* @param {string} path - The path to append to the base URL.
|
|
29
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
30
30
|
* @description Define a protected asynchronous method '_fetchGet' that performs a GET request
|
|
31
31
|
*/
|
|
32
32
|
async _fetchGet(path) {
|
|
@@ -74,9 +74,9 @@ class AsyncModules extends syncModules_1.default {
|
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Performs an HTTP POST request.
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
79
|
-
* @returns {Promise<any>}
|
|
77
|
+
* @param {string} path - The path to append to the base URL.
|
|
78
|
+
* @param {any} [data] - The data to send in the request body.
|
|
79
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
80
80
|
* @description Define a protected asynchronous method '_fetchPost' that performs a POST request
|
|
81
81
|
*/
|
|
82
82
|
async _fetchPost(path, data) {
|
|
@@ -96,10 +96,11 @@ class AsyncModules extends syncModules_1.default {
|
|
|
96
96
|
options, // Pass the options for the request
|
|
97
97
|
(res) => {
|
|
98
98
|
// Handle the response from the server
|
|
99
|
-
|
|
99
|
+
// Initialize a variable to accumulate response data
|
|
100
|
+
let responseData = '';
|
|
100
101
|
// Listen for 'data' events to receive chunks of data from the response
|
|
101
102
|
res.on('data', (chunk) => {
|
|
102
|
-
responseData += chunk;
|
|
103
|
+
responseData += chunk;
|
|
103
104
|
});
|
|
104
105
|
// Listen for the 'end' event to know when the response has been fully received
|
|
105
106
|
res.on('end', () => {
|
|
@@ -128,9 +129,9 @@ class AsyncModules extends syncModules_1.default {
|
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
130
131
|
* Performs an HTTP PUT request.
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @returns {Promise<any>}
|
|
132
|
+
* @param {string} path - The path to append to the base URL.
|
|
133
|
+
* @param {any} body - The data to send in the request body.
|
|
134
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
134
135
|
* @description Define a protected asynchronous method '_fetchPut' that performs a PUT request
|
|
135
136
|
*/
|
|
136
137
|
async _fetchPut(path, body) {
|
|
@@ -182,9 +183,9 @@ class AsyncModules extends syncModules_1.default {
|
|
|
182
183
|
}
|
|
183
184
|
/**
|
|
184
185
|
* Performs an HTTP DELETE request.
|
|
185
|
-
* @param
|
|
186
|
-
* @param
|
|
187
|
-
* @returns {Promise<any>}
|
|
186
|
+
* @param {string} path - The path to append to the base URL.
|
|
187
|
+
* @param {any} body - The body of the request.
|
|
188
|
+
* @returns {Promise<any>} A promise resolving to the response data.
|
|
188
189
|
* @description Define a protected asynchronous method '_fetchDelete' that performs a DELETE request
|
|
189
190
|
*/
|
|
190
191
|
async _fetchDelete(path, body) {
|
|
@@ -243,8 +244,12 @@ class AsyncModules extends syncModules_1.default {
|
|
|
243
244
|
method: 'POST',
|
|
244
245
|
// Set the necessary headers for the request
|
|
245
246
|
headers: {
|
|
246
|
-
|
|
247
|
-
'
|
|
247
|
+
// Indicate that the request body is in JSON format
|
|
248
|
+
'Content-Type': 'application/json',
|
|
249
|
+
// Include the application token from the state
|
|
250
|
+
'x-app-token': this.state.token,
|
|
251
|
+
// Include the device fingerprint
|
|
252
|
+
'x-device-metadata': this._getDeviceMetadata(),
|
|
248
253
|
},
|
|
249
254
|
// Send the current refresh token in the request body as a JSON string
|
|
250
255
|
body: JSON.stringify({ refreshToken: this.state.refreshToken }),
|
|
@@ -270,9 +275,9 @@ class AsyncModules extends syncModules_1.default {
|
|
|
270
275
|
}
|
|
271
276
|
/**
|
|
272
277
|
* Creates options for HTTP requests.
|
|
273
|
-
* @param
|
|
274
|
-
* @param
|
|
275
|
-
* @returns {any}
|
|
278
|
+
* @param {string} method - The HTTP method (GET, POST, PUT, DELETE, etc.).
|
|
279
|
+
* @param {any} data - Optional data to include in the request body.
|
|
280
|
+
* @returns {any} An object representing the request options.
|
|
276
281
|
*/
|
|
277
282
|
makeOptions(method, data) {
|
|
278
283
|
const options = {
|
|
@@ -315,9 +320,9 @@ class AsyncModules extends syncModules_1.default {
|
|
|
315
320
|
}
|
|
316
321
|
/**
|
|
317
322
|
* Handles responses from the browser's fetch API.
|
|
318
|
-
* @param
|
|
319
|
-
* @param
|
|
320
|
-
* @returns {any}
|
|
323
|
+
* @param {string} path - The path to append to the base URL.
|
|
324
|
+
* @param {any} options - The options for the fetch request.
|
|
325
|
+
* @returns {any} A promise resolving to the response data.
|
|
321
326
|
* @description Define an asynchronous method 'browserResponse' that takes a path and options as parameters
|
|
322
327
|
*/
|
|
323
328
|
async browserResponse(path, options) {
|
package/dist/base/result.d.ts
CHANGED
|
@@ -24,16 +24,16 @@ export default class Result {
|
|
|
24
24
|
json(): Promise<Result>;
|
|
25
25
|
/**
|
|
26
26
|
* Recursively removes language-specific data from the provided data or the body.
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @returns {any}
|
|
27
|
+
* @param {string} langCode - Language code
|
|
28
|
+
* @param {any} [data] - Data to process
|
|
29
|
+
* @returns {any} Processed data
|
|
30
30
|
* @description Recursively removes language-specific data from the provided data or the body.
|
|
31
31
|
*/
|
|
32
32
|
makeDataWithoutLang(langCode: string, data?: any): any;
|
|
33
33
|
/**
|
|
34
34
|
* Recursively simplifies arrays in the provided data or the body by removing single-element arrays.
|
|
35
|
-
* @param
|
|
36
|
-
* @returns {any}
|
|
35
|
+
* @param {any} data - The data to simplify.
|
|
36
|
+
* @returns {any} The simplified data.
|
|
37
37
|
*/
|
|
38
38
|
makeDataWithoutArray(data?: any): any;
|
|
39
39
|
}
|
package/dist/base/result.js
CHANGED
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
* @description Result class for handling response data
|
|
9
9
|
*/
|
|
10
10
|
class Result {
|
|
11
|
-
// Constructor that initializes the class with a given data, which can be of type Response or string.
|
|
12
11
|
/**
|
|
13
12
|
* Constructor that initializes the class with a given data
|
|
14
13
|
* @param {Response | string} data - Response or string data
|
|
@@ -17,7 +16,6 @@ class Result {
|
|
|
17
16
|
constructor(data) {
|
|
18
17
|
this.body = data;
|
|
19
18
|
}
|
|
20
|
-
// Asynchronously converts the body to a blob and returns the current instance.
|
|
21
19
|
/**
|
|
22
20
|
* Asynchronously converts the body to a blob and returns the current instance.
|
|
23
21
|
* @returns {Promise<Result>} Current instance
|
|
@@ -28,7 +26,6 @@ class Result {
|
|
|
28
26
|
this.body = await this.body.blob();
|
|
29
27
|
return this;
|
|
30
28
|
}
|
|
31
|
-
// Asynchronously parses the body as JSON and returns the current instance.
|
|
32
29
|
/**
|
|
33
30
|
* Asynchronously parses the body as JSON and returns the current instance.
|
|
34
31
|
* @returns {Promise<Result>} Current instance
|
|
@@ -42,12 +39,11 @@ class Result {
|
|
|
42
39
|
: this.body.json();
|
|
43
40
|
return this;
|
|
44
41
|
}
|
|
45
|
-
// Recursively removes language-specific data from the provided data or the body.
|
|
46
42
|
/**
|
|
47
43
|
* Recursively removes language-specific data from the provided data or the body.
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @returns {any}
|
|
44
|
+
* @param {string} langCode - Language code
|
|
45
|
+
* @param {any} [data] - Data to process
|
|
46
|
+
* @returns {any} Processed data
|
|
51
47
|
* @description Recursively removes language-specific data from the provided data or the body.
|
|
52
48
|
*/
|
|
53
49
|
makeDataWithoutLang(langCode, data) {
|
|
@@ -106,8 +102,8 @@ class Result {
|
|
|
106
102
|
}
|
|
107
103
|
/**
|
|
108
104
|
* Recursively simplifies arrays in the provided data or the body by removing single-element arrays.
|
|
109
|
-
* @param
|
|
110
|
-
* @returns {any}
|
|
105
|
+
* @param {any} data - The data to simplify.
|
|
106
|
+
* @returns {any} The simplified data.
|
|
111
107
|
*/
|
|
112
108
|
makeDataWithoutArray(data) {
|
|
113
109
|
if (data) {
|
|
@@ -24,7 +24,7 @@ export default class StateModule {
|
|
|
24
24
|
saveFunction: (param: string) => void | null;
|
|
25
25
|
/**
|
|
26
26
|
* Constructor for StateModule
|
|
27
|
-
* @param {string}
|
|
27
|
+
* @param {string} url - Base URL for API requests
|
|
28
28
|
* @param {IConfig} config - Configuration object
|
|
29
29
|
* @description Constructor for StateModule
|
|
30
30
|
*/
|
package/dist/base/stateModule.js
CHANGED
|
@@ -40,7 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
class StateModule {
|
|
41
41
|
/**
|
|
42
42
|
* Constructor for StateModule
|
|
43
|
-
* @param {string}
|
|
43
|
+
* @param {string} url - Base URL for API requests
|
|
44
44
|
* @param {IConfig} config - Configuration object
|
|
45
45
|
* @description Constructor for StateModule
|
|
46
46
|
*/
|
|
@@ -10,57 +10,57 @@ export default abstract class SyncModules {
|
|
|
10
10
|
protected constructor(state: StateModule);
|
|
11
11
|
/**
|
|
12
12
|
* Constructs the full URL path by appending the given path to the base URL.
|
|
13
|
-
* @param
|
|
14
|
-
* @returns {string}
|
|
13
|
+
* @param {string} path - The path to append to the base URL.
|
|
14
|
+
* @returns {string} The full URL as a string.
|
|
15
15
|
*/
|
|
16
16
|
protected _getFullPath(path: string): string;
|
|
17
17
|
/**
|
|
18
18
|
* Converts query parameters into a query string.
|
|
19
|
-
* @param
|
|
20
|
-
* @returns {string}
|
|
19
|
+
* @param {IProductsQuery | IUploadingQuery | any} query - The query object containing key-value pairs.
|
|
20
|
+
* @returns {string} A string representation of the query parameters.
|
|
21
21
|
*/
|
|
22
22
|
protected _queryParamsToString(query: IProductsQuery | IUploadingQuery | any): string;
|
|
23
23
|
/**
|
|
24
24
|
* Normalizes data based on language code.
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @returns {any}
|
|
25
|
+
* @param {any} data - The data to normalize.
|
|
26
|
+
* @param {string} langCode - The language code for normalization.
|
|
27
|
+
* @returns {any} Normalized data.
|
|
28
28
|
*/
|
|
29
29
|
protected _normalizeData(data: any, langCode?: string): any;
|
|
30
30
|
/**
|
|
31
31
|
* Normalizes the body of a POST request.
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @returns {any}
|
|
32
|
+
* @param {any} body - The body to normalize.
|
|
33
|
+
* @param {string} langCode - The language code for normalization.
|
|
34
|
+
* @returns {any} Normalized body.
|
|
35
35
|
*/
|
|
36
36
|
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
37
37
|
/**
|
|
38
38
|
* Clears arrays within the data structure.
|
|
39
|
-
* @param
|
|
40
|
-
* @returns {any}
|
|
39
|
+
* @param {Record<string, any>} data - The data to clear.
|
|
40
|
+
* @returns {any} Cleared data.
|
|
41
41
|
*/
|
|
42
42
|
protected _clearArray(data: Record<string, any>): any;
|
|
43
43
|
/**
|
|
44
44
|
* Sorts attributes by their positions.
|
|
45
|
-
* @param
|
|
46
|
-
* @returns {any}
|
|
45
|
+
* @param {any} data - The data containing attributes.
|
|
46
|
+
* @returns {any} Sorted attributes.
|
|
47
47
|
*/
|
|
48
48
|
protected _sortAttributes: (data: any) => any;
|
|
49
49
|
/**
|
|
50
50
|
* Adds a specified number of days to a date.
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @returns {any}
|
|
51
|
+
* @param {Date} date - The initial date.
|
|
52
|
+
* @param {number} days - The number of days to add.
|
|
53
|
+
* @returns {any} The new date with added days.
|
|
54
54
|
*/
|
|
55
55
|
protected _addDays(date: Date, days: number): Date;
|
|
56
56
|
/**
|
|
57
57
|
* Generates intervals for a specific date based on a schedule.
|
|
58
|
-
* @param {Date}
|
|
59
|
-
* @param {object}
|
|
60
|
-
* @param {boolean}
|
|
61
|
-
* @param {any[]}
|
|
62
|
-
* @param {boolean}
|
|
63
|
-
* @param {Set<Array<string>>} utcIntervals
|
|
58
|
+
* @param {Date} date - The date for which to generate intervals.
|
|
59
|
+
* @param {object} schedule - The schedule defining the intervals.
|
|
60
|
+
* @param {boolean} schedule.inEveryWeek - The number of weeks between intervals.
|
|
61
|
+
* @param {any[]} schedule.times - The times for each interval.
|
|
62
|
+
* @param {boolean} schedule.inEveryMonth - The month intervals for each interval.
|
|
63
|
+
* @param {Set<Array<string>>} utcIntervals - A set to store unique intervals.
|
|
64
64
|
*/
|
|
65
65
|
protected _generateIntervalsForDate(date: Date, schedule: {
|
|
66
66
|
inEveryWeek: boolean;
|
|
@@ -69,33 +69,33 @@ export default abstract class SyncModules {
|
|
|
69
69
|
}, utcIntervals: Set<Array<string>>): void;
|
|
70
70
|
/**
|
|
71
71
|
* Adds time intervals to schedules.
|
|
72
|
-
* @param
|
|
73
|
-
* @returns {any}
|
|
72
|
+
* @param {any[]} schedules - The schedules to process.
|
|
73
|
+
* @returns {any} Schedules with added time intervals.
|
|
74
74
|
*/
|
|
75
|
-
_addTimeIntervalsToSchedules(schedules: any[]): any
|
|
75
|
+
_addTimeIntervalsToSchedules(schedules: any[]): any;
|
|
76
76
|
/**
|
|
77
77
|
* Normalizes attributes within the data.
|
|
78
|
-
* @param
|
|
79
|
-
* @returns {any}
|
|
78
|
+
* @param {any} data - The data to normalize.
|
|
79
|
+
* @returns {any} Normalized attributes.
|
|
80
80
|
*/
|
|
81
81
|
protected _normalizeAttr(data: any): any;
|
|
82
82
|
/**
|
|
83
83
|
* Processes data after fetching or receiving it.
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
86
|
-
* @returns {any}
|
|
84
|
+
* @param {any} data - The data to process.
|
|
85
|
+
* @param {any} langCode - The language code for processing.
|
|
86
|
+
* @returns {any} Processed data.
|
|
87
87
|
*/
|
|
88
88
|
protected _dataPostProcess(data: any, langCode?: string): any;
|
|
89
89
|
/**
|
|
90
90
|
* Sets the access token in the state.
|
|
91
|
-
* @param
|
|
92
|
-
* @returns {any}
|
|
91
|
+
* @param {string} accessToken - The access token to set.
|
|
92
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
93
93
|
*/
|
|
94
94
|
setAccessToken(accessToken: string): any;
|
|
95
95
|
/**
|
|
96
96
|
* Sets the refresh token in the state.
|
|
97
|
-
* @param
|
|
98
|
-
* @returns {any}
|
|
97
|
+
* @param {any} refreshToken - The refresh token to set.
|
|
98
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
99
99
|
*/
|
|
100
100
|
setRefreshToken(refreshToken: string): any;
|
|
101
101
|
/**
|
package/dist/base/syncModules.js
CHANGED
|
@@ -9,8 +9,8 @@ class SyncModules {
|
|
|
9
9
|
constructor(state) {
|
|
10
10
|
/**
|
|
11
11
|
* Sorts attributes by their positions.
|
|
12
|
-
* @param
|
|
13
|
-
* @returns {any}
|
|
12
|
+
* @param {any} data - The data containing attributes.
|
|
13
|
+
* @returns {any} Sorted attributes.
|
|
14
14
|
*/
|
|
15
15
|
this._sortAttributes = (data) => Object.fromEntries(Object.entries(data).sort(([, a], [, b]) => a.position - b.position));
|
|
16
16
|
this.state = state;
|
|
@@ -18,16 +18,16 @@ class SyncModules {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Constructs the full URL path by appending the given path to the base URL.
|
|
21
|
-
* @param
|
|
22
|
-
* @returns {string}
|
|
21
|
+
* @param {string} path - The path to append to the base URL.
|
|
22
|
+
* @returns {string} The full URL as a string.
|
|
23
23
|
*/
|
|
24
24
|
_getFullPath(path) {
|
|
25
25
|
return this._url + path;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Converts query parameters into a query string.
|
|
29
|
-
* @param
|
|
30
|
-
* @returns {string}
|
|
29
|
+
* @param {IProductsQuery | IUploadingQuery | any} query - The query object containing key-value pairs.
|
|
30
|
+
* @returns {string} A string representation of the query parameters.
|
|
31
31
|
*/
|
|
32
32
|
_queryParamsToString(query) {
|
|
33
33
|
let result = '';
|
|
@@ -40,9 +40,9 @@ class SyncModules {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Normalizes data based on language code.
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @returns {any}
|
|
43
|
+
* @param {any} data - The data to normalize.
|
|
44
|
+
* @param {string} langCode - The language code for normalization.
|
|
45
|
+
* @returns {any} Normalized data.
|
|
46
46
|
*/
|
|
47
47
|
_normalizeData(data, langCode = this.state.lang) {
|
|
48
48
|
if (Array.isArray(data)) {
|
|
@@ -72,9 +72,9 @@ class SyncModules {
|
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Normalizes the body of a POST request.
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @returns {any}
|
|
75
|
+
* @param {any} body - The body to normalize.
|
|
76
|
+
* @param {string} langCode - The language code for normalization.
|
|
77
|
+
* @returns {any} Normalized body.
|
|
78
78
|
*/
|
|
79
79
|
_normalizePostBody(body, langCode = this.state.lang) {
|
|
80
80
|
const formData = {};
|
|
@@ -86,8 +86,8 @@ class SyncModules {
|
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Clears arrays within the data structure.
|
|
89
|
-
* @param
|
|
90
|
-
* @returns {any}
|
|
89
|
+
* @param {Record<string, any>} data - The data to clear.
|
|
90
|
+
* @returns {any} Cleared data.
|
|
91
91
|
*/
|
|
92
92
|
_clearArray(data) {
|
|
93
93
|
if (Array.isArray(data)) {
|
|
@@ -124,9 +124,9 @@ class SyncModules {
|
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Adds a specified number of days to a date.
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @returns {any}
|
|
127
|
+
* @param {Date} date - The initial date.
|
|
128
|
+
* @param {number} days - The number of days to add.
|
|
129
|
+
* @returns {any} The new date with added days.
|
|
130
130
|
*/
|
|
131
131
|
_addDays(date, days) {
|
|
132
132
|
const result = new Date(date);
|
|
@@ -135,12 +135,12 @@ class SyncModules {
|
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Generates intervals for a specific date based on a schedule.
|
|
138
|
-
* @param {Date}
|
|
139
|
-
* @param {object}
|
|
140
|
-
* @param {boolean}
|
|
141
|
-
* @param {any[]}
|
|
142
|
-
* @param {boolean}
|
|
143
|
-
* @param {Set<Array<string>>} utcIntervals
|
|
138
|
+
* @param {Date} date - The date for which to generate intervals.
|
|
139
|
+
* @param {object} schedule - The schedule defining the intervals.
|
|
140
|
+
* @param {boolean} schedule.inEveryWeek - The number of weeks between intervals.
|
|
141
|
+
* @param {any[]} schedule.times - The times for each interval.
|
|
142
|
+
* @param {boolean} schedule.inEveryMonth - The month intervals for each interval.
|
|
143
|
+
* @param {Set<Array<string>>} utcIntervals - A set to store unique intervals.
|
|
144
144
|
*/
|
|
145
145
|
_generateIntervalsForDate(date, schedule, utcIntervals) {
|
|
146
146
|
// Handle weekly schedules
|
|
@@ -161,14 +161,18 @@ class SyncModules {
|
|
|
161
161
|
intervalEnd.toISOString(),
|
|
162
162
|
]);
|
|
163
163
|
});
|
|
164
|
-
|
|
164
|
+
// Move to the next week
|
|
165
|
+
currentDate = this._addDays(currentDate, 7);
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
// Handle monthly schedules
|
|
168
169
|
if (schedule.inEveryMonth && !schedule.inEveryWeek) {
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
170
|
+
// Начальная дата
|
|
171
|
+
const startDate = new Date(date);
|
|
172
|
+
// Определяем день месяца начальной даты
|
|
173
|
+
const targetDayOfMonth = startDate.getUTCDate();
|
|
174
|
+
// Количество месяцев, на которые нужно повторить
|
|
175
|
+
const numberOfMonths = 12;
|
|
172
176
|
for (let i = 0; i < numberOfMonths; i++) {
|
|
173
177
|
const currentDate = new Date(startDate);
|
|
174
178
|
currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
|
|
@@ -193,13 +197,17 @@ class SyncModules {
|
|
|
193
197
|
}
|
|
194
198
|
// Handle both weekly and monthly schedules
|
|
195
199
|
if (schedule.inEveryMonth && schedule.inEveryWeek) {
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
200
|
+
// Initial date
|
|
201
|
+
const startDate = new Date(date);
|
|
202
|
+
// Determine the day of the week
|
|
203
|
+
const targetDayOfWeek = startDate.getUTCDay();
|
|
204
|
+
// Number of months to repeat
|
|
205
|
+
const numberOfMonths = 12;
|
|
199
206
|
for (let i = 0; i < numberOfMonths; i++) {
|
|
200
207
|
const currentDate = new Date(startDate);
|
|
201
208
|
currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
|
|
202
|
-
|
|
209
|
+
// Set to the first day of the month
|
|
210
|
+
currentDate.setUTCDate(1);
|
|
203
211
|
// Find the first target day of the week in the current month
|
|
204
212
|
const daysUntilTargetDay = (targetDayOfWeek - currentDate.getUTCDay() + 7) % 7;
|
|
205
213
|
currentDate.setUTCDate(currentDate.getUTCDate() + daysUntilTargetDay);
|
|
@@ -225,8 +233,8 @@ class SyncModules {
|
|
|
225
233
|
}
|
|
226
234
|
/**
|
|
227
235
|
* Adds time intervals to schedules.
|
|
228
|
-
* @param
|
|
229
|
-
* @returns {any}
|
|
236
|
+
* @param {any[]} schedules - The schedules to process.
|
|
237
|
+
* @returns {any} Schedules with added time intervals.
|
|
230
238
|
*/
|
|
231
239
|
_addTimeIntervalsToSchedules(schedules) {
|
|
232
240
|
schedules.forEach((scheduleGroup) => {
|
|
@@ -250,8 +258,8 @@ class SyncModules {
|
|
|
250
258
|
}
|
|
251
259
|
/**
|
|
252
260
|
* Normalizes attributes within the data.
|
|
253
|
-
* @param
|
|
254
|
-
* @returns {any}
|
|
261
|
+
* @param {any} data - The data to normalize.
|
|
262
|
+
* @returns {any} Normalized attributes.
|
|
255
263
|
*/
|
|
256
264
|
_normalizeAttr(data) {
|
|
257
265
|
// For regular attributes
|
|
@@ -301,9 +309,9 @@ class SyncModules {
|
|
|
301
309
|
}
|
|
302
310
|
/**
|
|
303
311
|
* Processes data after fetching or receiving it.
|
|
304
|
-
* @param
|
|
305
|
-
* @param
|
|
306
|
-
* @returns {any}
|
|
312
|
+
* @param {any} data - The data to process.
|
|
313
|
+
* @param {any} langCode - The language code for processing.
|
|
314
|
+
* @returns {any} Processed data.
|
|
307
315
|
*/
|
|
308
316
|
_dataPostProcess(data, langCode = this.state.lang) {
|
|
309
317
|
const normalize = this._normalizeData(data, langCode);
|
|
@@ -312,8 +320,8 @@ class SyncModules {
|
|
|
312
320
|
}
|
|
313
321
|
/**
|
|
314
322
|
* Sets the access token in the state.
|
|
315
|
-
* @param
|
|
316
|
-
* @returns {any}
|
|
323
|
+
* @param {string} accessToken - The access token to set.
|
|
324
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
317
325
|
*/
|
|
318
326
|
setAccessToken(accessToken) {
|
|
319
327
|
this.state.accessToken = accessToken;
|
|
@@ -321,8 +329,8 @@ class SyncModules {
|
|
|
321
329
|
}
|
|
322
330
|
/**
|
|
323
331
|
* Sets the refresh token in the state.
|
|
324
|
-
* @param
|
|
325
|
-
* @returns {any}
|
|
332
|
+
* @param {any} refreshToken - The refresh token to set.
|
|
333
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
326
334
|
*/
|
|
327
335
|
setRefreshToken(refreshToken) {
|
|
328
336
|
this.state.refreshToken = refreshToken;
|
|
@@ -343,11 +351,50 @@ class SyncModules {
|
|
|
343
351
|
const platform = nav.platform || 'Win32';
|
|
344
352
|
const userAgent = nav.userAgent || 'Node.js/22';
|
|
345
353
|
const language = nav.language || 'en-US';
|
|
354
|
+
// Get screen information if available
|
|
355
|
+
const screen = (win === null || win === void 0 ? void 0 : win.screen) || {};
|
|
356
|
+
const screenWidth = screen.width || 0;
|
|
357
|
+
const screenHeight = screen.height || 0;
|
|
358
|
+
const colorDepth = screen.colorDepth || 0;
|
|
359
|
+
// Get timezone
|
|
360
|
+
let timezone = 'UTC';
|
|
361
|
+
try {
|
|
362
|
+
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
363
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
364
|
+
}
|
|
365
|
+
catch (e) {
|
|
366
|
+
// Ignore error, fallback to UTC
|
|
367
|
+
}
|
|
368
|
+
// Detect private browsing mode
|
|
369
|
+
let isPrivateBrowsing = false;
|
|
370
|
+
try {
|
|
371
|
+
// Simple localStorage test to detect private browsing
|
|
372
|
+
if (win === null || win === void 0 ? void 0 : win.localStorage) {
|
|
373
|
+
const testKey = 'test_private_browsing';
|
|
374
|
+
win.localStorage.setItem(testKey, '1');
|
|
375
|
+
win.localStorage.removeItem(testKey);
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
isPrivateBrowsing = true; // If localStorage is not available, likely private browsing
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
catch (e) {
|
|
382
|
+
isPrivateBrowsing = true; // Error during localStorage access indicates private browsing
|
|
383
|
+
}
|
|
384
|
+
// Create a stable fingerprint string using stable device/browser characteristics
|
|
385
|
+
const fingerprintString = `${platform}|${userAgent}|${language}|${screenWidth}|${screenHeight}|${colorDepth}|${timezone}|${isPrivateBrowsing ? 'private' : 'normal'}`;
|
|
386
|
+
// Simple but stable hash function
|
|
387
|
+
let hash = 0;
|
|
388
|
+
for (let i = 0; i < fingerprintString.length; i++) {
|
|
389
|
+
const char = fingerprintString.charCodeAt(i);
|
|
390
|
+
hash = (hash << 5) - hash + char;
|
|
391
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
392
|
+
}
|
|
346
393
|
const deviceMetadata = {
|
|
347
|
-
fingerprint: `UQ_${
|
|
394
|
+
fingerprint: `UQ_${Math.abs(hash).toString(36)}`,
|
|
348
395
|
deviceInfo: {
|
|
349
|
-
os: platform,
|
|
350
|
-
browser: userAgent,
|
|
396
|
+
os: platform.replace(/ /g, '_'),
|
|
397
|
+
browser: userAgent.replace(/ /g, '_'),
|
|
351
398
|
location: language,
|
|
352
399
|
},
|
|
353
400
|
};
|