oneentry 1.0.126 → 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/README.md +0 -2
- package/configure.js +25 -18
- package/dist/admins/adminsApi.d.ts +18 -13
- package/dist/admins/adminsApi.js +18 -13
- package/dist/admins/adminsInterfaces.d.ts +16 -25
- package/dist/attribute-sets/attributeSetsApi.d.ts +14 -15
- package/dist/attribute-sets/attributeSetsApi.js +14 -15
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +78 -84
- package/dist/auth-provider/authProviderApi.d.ts +53 -79
- package/dist/auth-provider/authProviderApi.js +52 -78
- package/dist/auth-provider/authProvidersInterfaces.d.ts +98 -94
- package/dist/base/asyncModules.d.ts +23 -21
- package/dist/base/asyncModules.js +39 -29
- package/dist/base/result.d.ts +31 -0
- package/dist/base/result.js +32 -5
- package/dist/base/stateModule.d.ts +10 -0
- package/dist/base/stateModule.js +50 -2
- package/dist/base/syncModules.d.ts +42 -50
- package/dist/base/syncModules.js +106 -58
- package/dist/base/utils.d.ts +33 -2
- package/dist/blocks/blocksApi.d.ts +9 -18
- package/dist/blocks/blocksApi.js +9 -18
- package/dist/blocks/blocksInterfaces.d.ts +41 -46
- package/dist/config.d.ts +13 -0
- package/dist/config.js +30 -0
- package/dist/events/eventsApi.d.ts +10 -27
- package/dist/events/eventsApi.js +26 -40
- package/dist/events/eventsInterfaces.d.ts +33 -28
- package/dist/file-uploading/fileUploadingApi.d.ts +12 -17
- package/dist/file-uploading/fileUploadingApi.js +14 -17
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +8 -19
- package/dist/forms/formsApi.d.ts +10 -9
- package/dist/forms/formsApi.js +10 -9
- package/dist/forms/formsInterfaces.d.ts +20 -12
- package/dist/forms-data/formsDataApi.d.ts +24 -28
- package/dist/forms-data/formsDataApi.js +25 -28
- package/dist/forms-data/formsDataInterfaces.d.ts +71 -71
- package/dist/general-types/generalTypesApi.d.ts +5 -5
- package/dist/general-types/generalTypesApi.js +5 -5
- package/dist/general-types/generalTypesInterfaces.d.ts +5 -8
- package/dist/index.d.ts +3 -4
- package/dist/index.js +3 -4
- package/dist/integration-collections/integrationCollectionsApi.d.ts +29 -47
- package/dist/integration-collections/integrationCollectionsApi.js +31 -51
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +62 -58
- package/dist/locales/localesApi.d.ts +7 -3
- package/dist/locales/localesApi.js +7 -3
- package/dist/locales/localesInterfaces.d.ts +6 -5
- package/dist/menus/menusApi.d.ts +7 -3
- package/dist/menus/menusApi.js +7 -3
- package/dist/menus/menusInterfaces.d.ts +5 -10
- package/dist/menus/menusInterfaces.js +1 -0
- package/dist/orders/ordersApi.d.ts +17 -25
- package/dist/orders/ordersApi.js +17 -26
- package/dist/orders/ordersInterfaces.d.ts +94 -53
- package/dist/pages/pagesApi.d.ts +47 -60
- package/dist/pages/pagesApi.js +51 -61
- package/dist/pages/pagesInterfaces.d.ts +44 -48
- package/dist/payments/paymentsApi.d.ts +17 -27
- package/dist/payments/paymentsApi.js +17 -31
- package/dist/payments/paymentsInterfaces.d.ts +35 -29
- package/dist/product-statuses/productStatusesApi.d.ts +9 -9
- package/dist/product-statuses/productStatusesApi.js +9 -9
- package/dist/product-statuses/productStatusesInterfaces.d.ts +14 -12
- package/dist/products/productsApi.d.ts +23 -44
- package/dist/products/productsApi.js +24 -44
- package/dist/products/productsInterfaces.d.ts +51 -57
- package/dist/system/systemApi.d.ts +11 -13
- package/dist/system/systemApi.js +12 -13
- package/dist/system/systemInterfaces.d.ts +14 -3
- package/dist/templates/templatesApi.d.ts +8 -11
- package/dist/templates/templatesApi.js +8 -11
- package/dist/templates/templatesInterfaces.d.ts +13 -12
- package/dist/templates-preview/templatesPreviewApi.d.ts +7 -8
- package/dist/templates-preview/templatesPreviewApi.js +7 -8
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +15 -18
- package/dist/users/usersApi.d.ts +13 -20
- package/dist/users/usersApi.js +13 -20
- package/dist/users/usersInterfaces.d.ts +26 -30
- package/dist/web-socket/wsApi.d.ts +5 -3
- package/dist/web-socket/wsApi.js +6 -3
- package/dist/web-socket/wsInterfaces.d.ts +7 -2
- package/package.json +16 -12
package/dist/base/syncModules.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// Abstract class representing synchronization modules
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
4
7
|
class SyncModules {
|
|
5
8
|
// Constructor to initialize state and URL
|
|
6
9
|
constructor(state) {
|
|
7
10
|
/**
|
|
8
11
|
* Sorts attributes by their positions.
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
-
* @return Sorted attributes.
|
|
12
|
+
* @param {any} data - The data containing attributes.
|
|
13
|
+
* @returns {any} Sorted attributes.
|
|
12
14
|
*/
|
|
13
15
|
this._sortAttributes = (data) => Object.fromEntries(Object.entries(data).sort(([, a], [, b]) => a.position - b.position));
|
|
14
16
|
this.state = state;
|
|
@@ -16,18 +18,16 @@ class SyncModules {
|
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Constructs the full URL path by appending the given path to the base URL.
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
21
|
-
* @return The full URL as a string.
|
|
21
|
+
* @param {string} path - The path to append to the base URL.
|
|
22
|
+
* @returns {string} The full URL as a string.
|
|
22
23
|
*/
|
|
23
24
|
_getFullPath(path) {
|
|
24
25
|
return this._url + path;
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Converts query parameters into a query string.
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
* @return A string representation of the query parameters.
|
|
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,10 +40,9 @@ class SyncModules {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Normalizes data based on language code.
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @
|
|
46
|
-
* @return Normalized data.
|
|
43
|
+
* @param {any} data - The data to normalize.
|
|
44
|
+
* @param {string} langCode - The language code for normalization.
|
|
45
|
+
* @returns {any} Normalized data.
|
|
47
46
|
*/
|
|
48
47
|
_normalizeData(data, langCode = this.state.lang) {
|
|
49
48
|
if (Array.isArray(data)) {
|
|
@@ -73,10 +72,9 @@ class SyncModules {
|
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
74
|
* Normalizes the body of a POST request.
|
|
76
|
-
*
|
|
77
|
-
* @param
|
|
78
|
-
* @
|
|
79
|
-
* @return Normalized body.
|
|
75
|
+
* @param {any} body - The body to normalize.
|
|
76
|
+
* @param {string} langCode - The language code for normalization.
|
|
77
|
+
* @returns {any} Normalized body.
|
|
80
78
|
*/
|
|
81
79
|
_normalizePostBody(body, langCode = this.state.lang) {
|
|
82
80
|
const formData = {};
|
|
@@ -88,9 +86,8 @@ class SyncModules {
|
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
90
88
|
* Clears arrays within the data structure.
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
93
|
-
* @return Cleared data.
|
|
89
|
+
* @param {Record<string, any>} data - The data to clear.
|
|
90
|
+
* @returns {any} Cleared data.
|
|
94
91
|
*/
|
|
95
92
|
_clearArray(data) {
|
|
96
93
|
if (Array.isArray(data)) {
|
|
@@ -127,10 +124,9 @@ class SyncModules {
|
|
|
127
124
|
}
|
|
128
125
|
/**
|
|
129
126
|
* Adds a specified number of days to a date.
|
|
130
|
-
*
|
|
131
|
-
* @param
|
|
132
|
-
* @
|
|
133
|
-
* @return The new date with added days.
|
|
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.
|
|
134
130
|
*/
|
|
135
131
|
_addDays(date, days) {
|
|
136
132
|
const result = new Date(date);
|
|
@@ -139,10 +135,12 @@ class SyncModules {
|
|
|
139
135
|
}
|
|
140
136
|
/**
|
|
141
137
|
* Generates intervals for a specific date based on a schedule.
|
|
142
|
-
*
|
|
143
|
-
* @param
|
|
144
|
-
* @param schedule
|
|
145
|
-
* @param
|
|
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.
|
|
146
144
|
*/
|
|
147
145
|
_generateIntervalsForDate(date, schedule, utcIntervals) {
|
|
148
146
|
// Handle weekly schedules
|
|
@@ -163,14 +161,18 @@ class SyncModules {
|
|
|
163
161
|
intervalEnd.toISOString(),
|
|
164
162
|
]);
|
|
165
163
|
});
|
|
166
|
-
|
|
164
|
+
// Move to the next week
|
|
165
|
+
currentDate = this._addDays(currentDate, 7);
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
168
|
// Handle monthly schedules
|
|
170
169
|
if (schedule.inEveryMonth && !schedule.inEveryWeek) {
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
170
|
+
// Начальная дата
|
|
171
|
+
const startDate = new Date(date);
|
|
172
|
+
// Определяем день месяца начальной даты
|
|
173
|
+
const targetDayOfMonth = startDate.getUTCDate();
|
|
174
|
+
// Количество месяцев, на которые нужно повторить
|
|
175
|
+
const numberOfMonths = 12;
|
|
174
176
|
for (let i = 0; i < numberOfMonths; i++) {
|
|
175
177
|
const currentDate = new Date(startDate);
|
|
176
178
|
currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
|
|
@@ -195,13 +197,17 @@ class SyncModules {
|
|
|
195
197
|
}
|
|
196
198
|
// Handle both weekly and monthly schedules
|
|
197
199
|
if (schedule.inEveryMonth && schedule.inEveryWeek) {
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
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;
|
|
201
206
|
for (let i = 0; i < numberOfMonths; i++) {
|
|
202
207
|
const currentDate = new Date(startDate);
|
|
203
208
|
currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
|
|
204
|
-
|
|
209
|
+
// Set to the first day of the month
|
|
210
|
+
currentDate.setUTCDate(1);
|
|
205
211
|
// Find the first target day of the week in the current month
|
|
206
212
|
const daysUntilTargetDay = (targetDayOfWeek - currentDate.getUTCDay() + 7) % 7;
|
|
207
213
|
currentDate.setUTCDate(currentDate.getUTCDate() + daysUntilTargetDay);
|
|
@@ -227,9 +233,8 @@ class SyncModules {
|
|
|
227
233
|
}
|
|
228
234
|
/**
|
|
229
235
|
* Adds time intervals to schedules.
|
|
230
|
-
*
|
|
231
|
-
* @
|
|
232
|
-
* @return Schedules with added time intervals.
|
|
236
|
+
* @param {any[]} schedules - The schedules to process.
|
|
237
|
+
* @returns {any} Schedules with added time intervals.
|
|
233
238
|
*/
|
|
234
239
|
_addTimeIntervalsToSchedules(schedules) {
|
|
235
240
|
schedules.forEach((scheduleGroup) => {
|
|
@@ -253,9 +258,8 @@ class SyncModules {
|
|
|
253
258
|
}
|
|
254
259
|
/**
|
|
255
260
|
* Normalizes attributes within the data.
|
|
256
|
-
*
|
|
257
|
-
* @
|
|
258
|
-
* @return Normalized attributes.
|
|
261
|
+
* @param {any} data - The data to normalize.
|
|
262
|
+
* @returns {any} Normalized attributes.
|
|
259
263
|
*/
|
|
260
264
|
_normalizeAttr(data) {
|
|
261
265
|
// For regular attributes
|
|
@@ -305,10 +309,9 @@ class SyncModules {
|
|
|
305
309
|
}
|
|
306
310
|
/**
|
|
307
311
|
* Processes data after fetching or receiving it.
|
|
308
|
-
*
|
|
309
|
-
* @param
|
|
310
|
-
* @
|
|
311
|
-
* @return Processed data.
|
|
312
|
+
* @param {any} data - The data to process.
|
|
313
|
+
* @param {any} langCode - The language code for processing.
|
|
314
|
+
* @returns {any} Processed data.
|
|
312
315
|
*/
|
|
313
316
|
_dataPostProcess(data, langCode = this.state.lang) {
|
|
314
317
|
const normalize = this._normalizeData(data, langCode);
|
|
@@ -317,9 +320,8 @@ class SyncModules {
|
|
|
317
320
|
}
|
|
318
321
|
/**
|
|
319
322
|
* Sets the access token in the state.
|
|
320
|
-
*
|
|
321
|
-
* @
|
|
322
|
-
* @return The instance of SyncModules for chaining.
|
|
323
|
+
* @param {string} accessToken - The access token to set.
|
|
324
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
323
325
|
*/
|
|
324
326
|
setAccessToken(accessToken) {
|
|
325
327
|
this.state.accessToken = accessToken;
|
|
@@ -327,9 +329,8 @@ class SyncModules {
|
|
|
327
329
|
}
|
|
328
330
|
/**
|
|
329
331
|
* Sets the refresh token in the state.
|
|
330
|
-
*
|
|
331
|
-
* @
|
|
332
|
-
* @return The instance of SyncModules for chaining.
|
|
332
|
+
* @param {any} refreshToken - The refresh token to set.
|
|
333
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
333
334
|
*/
|
|
334
335
|
setRefreshToken(refreshToken) {
|
|
335
336
|
this.state.refreshToken = refreshToken;
|
|
@@ -337,16 +338,63 @@ class SyncModules {
|
|
|
337
338
|
}
|
|
338
339
|
/**
|
|
339
340
|
* Get deviceMetadata
|
|
341
|
+
* @returns {string} - Returns an object containing device metadata.
|
|
340
342
|
*/
|
|
341
343
|
_getDeviceMetadata() {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
// Check if we're in a browser environment
|
|
345
|
+
if (typeof globalThis === 'undefined') {
|
|
346
|
+
return '';
|
|
347
|
+
}
|
|
348
|
+
// Access navigator through globalThis.window object to avoid direct reference
|
|
349
|
+
const win = globalThis.window;
|
|
350
|
+
const nav = (win === null || win === void 0 ? void 0 : win.navigator) || {};
|
|
351
|
+
const platform = nav.platform || 'Win32';
|
|
352
|
+
const userAgent = nav.userAgent || 'Node.js/22';
|
|
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
|
+
}
|
|
345
393
|
const deviceMetadata = {
|
|
346
|
-
fingerprint:
|
|
394
|
+
fingerprint: `UQ_${Math.abs(hash).toString(36)}`,
|
|
347
395
|
deviceInfo: {
|
|
348
|
-
os: platform,
|
|
349
|
-
browser: userAgent,
|
|
396
|
+
os: platform.replace(/ /g, '_'),
|
|
397
|
+
browser: userAgent.replace(/ /g, '_'),
|
|
350
398
|
location: language,
|
|
351
399
|
},
|
|
352
400
|
};
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'si
|
|
|
7
7
|
* @param {boolean} [auth.customAuth] - Set this flag to true if you want to configure the authorization process yourself. Set the flag to false, or do not pass it at all to have automatic authorization and token renewal
|
|
8
8
|
* @param {boolean} [auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created
|
|
9
9
|
* @param {boolean} [auth.saveFunction] - If you want to store the token between sessions, for example in local storage, create a custom function that takes refreshToken as a parameter and executes the necessary instructions. This function will be called every time the tokens are updated
|
|
10
|
-
*
|
|
11
10
|
* @example
|
|
12
11
|
* const saveToken = (token) => {
|
|
13
12
|
* localStorage.setItem('refresh', token)
|
|
@@ -30,7 +29,6 @@ type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'si
|
|
|
30
29
|
* }
|
|
31
30
|
* }
|
|
32
31
|
* }
|
|
33
|
-
*
|
|
34
32
|
*/
|
|
35
33
|
interface IConfig {
|
|
36
34
|
token?: string;
|
|
@@ -52,6 +50,19 @@ interface IConfig {
|
|
|
52
50
|
};
|
|
53
51
|
};
|
|
54
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* @interface IAttributes
|
|
55
|
+
* @property {Array<object>} listTitles - List of titles.
|
|
56
|
+
* @property {ILocalizeInfo} localizeInfos - Localization information.
|
|
57
|
+
* @property {string} marker - Attribute marker.
|
|
58
|
+
* @property {number} position - Attribute position.
|
|
59
|
+
* @property {boolean} isVisible - Indicates whether the attribute is visible.
|
|
60
|
+
* @property {string} type - Attribute type.
|
|
61
|
+
* @property {Record<string, any>} settings - Additional settings for the attribute.
|
|
62
|
+
* @property {Record<string, any>} validators - Validators for the attribute.
|
|
63
|
+
* @property {Record<string, any>} additionalFields - Additional fields for the attribute.
|
|
64
|
+
* @description Interface for attributes.
|
|
65
|
+
*/
|
|
55
66
|
interface IAttributes {
|
|
56
67
|
listTitles: Array<{
|
|
57
68
|
title: string;
|
|
@@ -72,15 +83,35 @@ interface IAttributes {
|
|
|
72
83
|
additionalFields?: any;
|
|
73
84
|
[key: string]: any;
|
|
74
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* @interface ILocalizeInfos
|
|
88
|
+
* @property {Record<string, ILocalizeInfo>} Localization information.
|
|
89
|
+
* @description Interface for localization information.
|
|
90
|
+
*/
|
|
75
91
|
interface ILocalizeInfos {
|
|
76
92
|
[key: string]: ILocalizeInfo;
|
|
77
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Interface for localization information.
|
|
96
|
+
* @property {Record<string, any>} Localization information.
|
|
97
|
+
* @description Interface for localization information.
|
|
98
|
+
*/
|
|
78
99
|
interface ILocalizeInfo {
|
|
79
100
|
[key: string]: any;
|
|
80
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* @interface IAttributeValues
|
|
104
|
+
* @property {Record<string, IAttributeValue>} Attribute values.
|
|
105
|
+
* @description Interface for attribute values.
|
|
106
|
+
*/
|
|
81
107
|
interface IAttributeValues {
|
|
82
108
|
[key: string]: IAttributeValue;
|
|
83
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* @interface IAttributeValue
|
|
112
|
+
* @property {Record<string, any>} Attribute value.
|
|
113
|
+
* @description Interface for attribute value.
|
|
114
|
+
*/
|
|
84
115
|
interface IAttributeValue {
|
|
85
116
|
[key: string]: any;
|
|
86
117
|
}
|
|
@@ -4,82 +4,73 @@ import type { IError } from '../base/utils';
|
|
|
4
4
|
import type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock } from './blocksInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with blocks.
|
|
7
|
-
*
|
|
8
7
|
* @handle /api/content/blocks
|
|
9
8
|
* @class BlocksApi
|
|
10
|
-
* @
|
|
9
|
+
* @augments AsyncModules
|
|
11
10
|
* @implements {IBlocks}
|
|
12
|
-
*
|
|
13
11
|
* @description This class provides methods to interact with blocks.
|
|
14
12
|
*/
|
|
15
13
|
export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
16
14
|
protected state: StateModule;
|
|
17
15
|
protected _url: string;
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for BlocksApi class.
|
|
18
|
+
*/
|
|
18
19
|
constructor(state: StateModule);
|
|
19
20
|
/**
|
|
20
21
|
* Get blocks by parameters.
|
|
21
|
-
*
|
|
22
22
|
* @handleName getBlocks
|
|
23
|
-
*
|
|
24
23
|
* @param {BlockType} type - Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". Example: 'product'.
|
|
25
24
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
26
25
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
27
26
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
28
|
-
* @
|
|
27
|
+
* @returns {IBlocksResponse} Returns BlocksEntity object.
|
|
29
28
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
30
29
|
* @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.
|
|
31
30
|
*/
|
|
32
31
|
getBlocks(type?: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
|
|
33
32
|
/**
|
|
34
33
|
* Get block by marker.
|
|
35
|
-
*
|
|
36
34
|
* @handleName getBlockByMarker
|
|
37
|
-
*
|
|
38
35
|
* @param {string} marker - Marker of Block. Example: "product_block".
|
|
39
36
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
40
37
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
41
38
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
42
|
-
* @
|
|
39
|
+
* @returns {IBlockEntity} - Returns a BlockEntity object.
|
|
43
40
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
44
41
|
* @description This method retrieves a block by its marker and includes additional information such as similar products or products associated with the block.
|
|
45
42
|
*/
|
|
46
43
|
getBlockByMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<IBlockEntity | IError>;
|
|
47
44
|
/**
|
|
48
45
|
* Get similar products by block marker.
|
|
49
|
-
*
|
|
50
46
|
* @handleName getSimilarProducts
|
|
51
|
-
*
|
|
52
47
|
* @param {string} marker - Block identifier. Example: "similar_products_block".
|
|
53
48
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
54
49
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
55
50
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
56
|
-
* @
|
|
51
|
+
* @returns {IProductsResponse} - Returns the total count and an array of product items in object by specified block marker.
|
|
57
52
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
58
53
|
* @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.
|
|
59
54
|
*/
|
|
60
55
|
private getSimilarProducts;
|
|
61
56
|
/**
|
|
62
57
|
* Get products by block marker.
|
|
63
|
-
*
|
|
64
58
|
* @handleName getProductsByBlockMarker
|
|
65
|
-
*
|
|
66
59
|
* @param {string} marker - Block identifier. Example: "product_block".
|
|
67
60
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
68
61
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
69
62
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
70
|
-
* @
|
|
63
|
+
* @returns {IProductsEntity[]} Return array of BlocksEntity object.
|
|
71
64
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
72
65
|
* @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.
|
|
73
66
|
*/
|
|
74
67
|
private getProductsByBlockMarker;
|
|
75
68
|
/**
|
|
76
69
|
* Quick search for block objects with limited output.
|
|
77
|
-
*
|
|
78
70
|
* @handleName searchBlock
|
|
79
|
-
*
|
|
80
71
|
* @param {string} name - Search string. Example: "product_block".
|
|
81
72
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
82
|
-
* @
|
|
73
|
+
* @returns {ISearchBlock[]} Returns an array of ISearchBlock objects.
|
|
83
74
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
84
75
|
* @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.
|
|
85
76
|
*/
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -6,29 +6,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
7
|
/**
|
|
8
8
|
* Controllers for working with blocks.
|
|
9
|
-
*
|
|
10
9
|
* @handle /api/content/blocks
|
|
11
10
|
* @class BlocksApi
|
|
12
|
-
* @
|
|
11
|
+
* @augments AsyncModules
|
|
13
12
|
* @implements {IBlocks}
|
|
14
|
-
*
|
|
15
13
|
* @description This class provides methods to interact with blocks.
|
|
16
14
|
*/
|
|
17
15
|
class BlocksApi extends asyncModules_1.default {
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for BlocksApi class.
|
|
18
|
+
*/
|
|
18
19
|
constructor(state) {
|
|
19
20
|
super(state);
|
|
20
21
|
this._url = state.url + '/api/content/blocks';
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Get blocks by parameters.
|
|
24
|
-
*
|
|
25
25
|
* @handleName getBlocks
|
|
26
|
-
*
|
|
27
26
|
* @param {BlockType} type - Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". Example: 'product'.
|
|
28
27
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
29
28
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
30
29
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
31
|
-
* @
|
|
30
|
+
* @returns {IBlocksResponse} Returns BlocksEntity object.
|
|
32
31
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
33
32
|
* @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.
|
|
34
33
|
*/
|
|
@@ -79,14 +78,12 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
79
78
|
}
|
|
80
79
|
/**
|
|
81
80
|
* Get block by marker.
|
|
82
|
-
*
|
|
83
81
|
* @handleName getBlockByMarker
|
|
84
|
-
*
|
|
85
82
|
* @param {string} marker - Marker of Block. Example: "product_block".
|
|
86
83
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
87
84
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
88
85
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
89
|
-
* @
|
|
86
|
+
* @returns {IBlockEntity} - Returns a BlockEntity object.
|
|
90
87
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
91
88
|
* @description This method retrieves a block by its marker and includes additional information such as similar products or products associated with the block.
|
|
92
89
|
*/
|
|
@@ -131,14 +128,12 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
131
128
|
}
|
|
132
129
|
/**
|
|
133
130
|
* Get similar products by block marker.
|
|
134
|
-
*
|
|
135
131
|
* @handleName getSimilarProducts
|
|
136
|
-
*
|
|
137
132
|
* @param {string} marker - Block identifier. Example: "similar_products_block".
|
|
138
133
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
139
134
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
140
135
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
141
|
-
* @
|
|
136
|
+
* @returns {IProductsResponse} - Returns the total count and an array of product items in object by specified block marker.
|
|
142
137
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
143
138
|
* @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.
|
|
144
139
|
*/
|
|
@@ -153,14 +148,12 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
153
148
|
}
|
|
154
149
|
/**
|
|
155
150
|
* Get products by block marker.
|
|
156
|
-
*
|
|
157
151
|
* @handleName getProductsByBlockMarker
|
|
158
|
-
*
|
|
159
152
|
* @param {string} marker - Block identifier. Example: "product_block".
|
|
160
153
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
161
154
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
162
155
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
163
|
-
* @
|
|
156
|
+
* @returns {IProductsEntity[]} Return array of BlocksEntity object.
|
|
164
157
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
165
158
|
* @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.
|
|
166
159
|
*/
|
|
@@ -175,12 +168,10 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
175
168
|
}
|
|
176
169
|
/**
|
|
177
170
|
* Quick search for block objects with limited output.
|
|
178
|
-
*
|
|
179
171
|
* @handleName searchBlock
|
|
180
|
-
*
|
|
181
172
|
* @param {string} name - Search string. Example: "product_block".
|
|
182
173
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
183
|
-
* @
|
|
174
|
+
* @returns {ISearchBlock[]} Returns an array of ISearchBlock objects.
|
|
184
175
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
185
176
|
* @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.
|
|
186
177
|
*/
|