oneentry 1.0.141 → 1.0.143
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/configure.js +107 -15
- package/dist/admins/adminsInterfaces.d.ts +1 -2
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +11 -13
- package/dist/auth-provider/authProviderApi.d.ts +1 -1
- package/dist/auth-provider/authProviderApi.js +13 -10
- package/dist/auth-provider/authProvidersInterfaces.d.ts +4 -17
- package/dist/base/asyncModules.js +8 -0
- package/dist/base/stateModule.js +1 -1
- package/dist/base/syncModules.d.ts +139 -2
- package/dist/base/syncModules.js +188 -21
- package/dist/base/utils.d.ts +1 -1
- package/dist/blocks/blocksInterfaces.d.ts +0 -5
- package/dist/blocks/blocksSchemas.d.ts +8 -0
- package/dist/file-uploading/fileUploadingApi.d.ts +5 -5
- package/dist/file-uploading/fileUploadingApi.js +3 -6
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -8
- package/dist/forms/formsInterfaces.d.ts +4 -2
- package/dist/forms-data/formsDataInterfaces.d.ts +0 -3
- package/dist/general-types/generalTypesInterfaces.d.ts +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/integration-collections/integrationCollectionsApi.d.ts +3 -13
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +26 -26
- package/dist/locales/localesInterfaces.d.ts +0 -1
- package/dist/menus/menusInterfaces.d.ts +0 -1
- package/dist/menus/menusInterfaces.js +0 -1
- package/dist/orders/ordersInterfaces.d.ts +8 -15
- package/dist/pages/pagesInterfaces.d.ts +0 -8
- package/dist/payments/paymentsInterfaces.d.ts +0 -6
- package/dist/product-statuses/productStatusesInterfaces.d.ts +0 -4
- package/dist/products/productsInterfaces.d.ts +10 -19
- package/dist/products/productsSchemas.d.ts +8 -0
- package/dist/products/productsSchemas.js +2 -0
- package/dist/system/systemApi.d.ts +6 -6
- package/dist/system/systemApi.js +3 -5
- package/dist/system/systemInterfaces.d.ts +6 -8
- package/dist/system/systemInterfaces.js +0 -3
- package/dist/templates/templatesInterfaces.d.ts +0 -3
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
- package/dist/users/usersApi.js +1 -3
- package/dist/users/usersInterfaces.d.ts +1 -7
- package/dist/web-socket/wsInterfaces.d.ts +0 -1
- package/package.json +1 -1
package/dist/base/syncModules.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//
|
|
3
|
+
// Module-level device ID cache — survives class re-instantiation,
|
|
4
|
+
// but resets on page reload if localStorage is unavailable.
|
|
4
5
|
let _persistentDeviceId = null;
|
|
6
|
+
/**
|
|
7
|
+
* Returns a stable device ID for the browser environment.
|
|
8
|
+
*
|
|
9
|
+
* Algorithm:
|
|
10
|
+
* 1. If the module-level cache is already populated — return it (fastest path).
|
|
11
|
+
* 2. Otherwise try reading the ID from localStorage (key `oneentry_device_id`).
|
|
12
|
+
* This ensures the same browser gets the same ID across sessions and tabs.
|
|
13
|
+
* 3. If localStorage has nothing — generate a new ID from timestamp + random,
|
|
14
|
+
* persist it to localStorage and cache it in the module variable.
|
|
15
|
+
* 4. If localStorage is unavailable (SSR, private mode, iframe sandbox) —
|
|
16
|
+
* return null; the caller falls back to `_nodeDeviceId`.
|
|
17
|
+
* @returns {string | null} Device ID or null if localStorage is unavailable.
|
|
18
|
+
*/
|
|
5
19
|
function _getBrowserDeviceId() {
|
|
6
20
|
const win = typeof globalThis !== 'undefined' ? globalThis.window : undefined;
|
|
7
21
|
if (!(win === null || win === void 0 ? void 0 : win.localStorage))
|
|
@@ -19,6 +33,8 @@ function _getBrowserDeviceId() {
|
|
|
19
33
|
catch (_e) {
|
|
20
34
|
// ignore
|
|
21
35
|
}
|
|
36
|
+
// Generate ID: base-36 timestamp + two random segments.
|
|
37
|
+
// base-36 is more compact than hex and contains no special characters.
|
|
22
38
|
const id = Date.now().toString(36) +
|
|
23
39
|
Math.random().toString(36).substring(2, 15) +
|
|
24
40
|
Math.random().toString(36).substring(2, 15);
|
|
@@ -43,6 +59,11 @@ class SyncModules {
|
|
|
43
59
|
constructor(state) {
|
|
44
60
|
/**
|
|
45
61
|
* Sorts attributes by their positions.
|
|
62
|
+
*
|
|
63
|
+
* The API returns attributes as an object `{ marker: AttrObject }`.
|
|
64
|
+
* Each attribute has a `position` field. The method rebuilds the object
|
|
65
|
+
* with keys sorted by ascending `position` so that the display order
|
|
66
|
+
* matches the order defined in the CMS.
|
|
46
67
|
* @param {any} data - The data containing attributes.
|
|
47
68
|
* @returns {any} Sorted attributes.
|
|
48
69
|
*/
|
|
@@ -68,16 +89,29 @@ class SyncModules {
|
|
|
68
89
|
* @returns {string} A string representation of the query parameters.
|
|
69
90
|
*/
|
|
70
91
|
_queryParamsToString(query) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return result.slice(0, result.length - 1);
|
|
92
|
+
// Skip null/undefined to avoid sending empty parameters.
|
|
93
|
+
// 0, false and '' are kept — they are semantically meaningful.
|
|
94
|
+
return Object.keys(query)
|
|
95
|
+
.filter((key) => query[key] !== null && query[key] !== undefined)
|
|
96
|
+
.map((key) => `${key}=${query[key]}`)
|
|
97
|
+
.join('&');
|
|
78
98
|
}
|
|
79
99
|
/**
|
|
80
100
|
* Normalizes data based on language code.
|
|
101
|
+
*
|
|
102
|
+
* Recursively traverses the API response and unwraps localized fields.
|
|
103
|
+
* The API stores translations as objects like
|
|
104
|
+
* `{ "en_US": "Hello", "ru_RU": "Hello" }`. The method replaces such an object
|
|
105
|
+
* with the value for the requested `langCode` when that key is present.
|
|
106
|
+
*
|
|
107
|
+
* Traversal order:
|
|
108
|
+
* 1. Array → recursively normalize each element, then `_normalizeAttr`.
|
|
109
|
+
* 2. Object → for each key:
|
|
110
|
+
* - value is an array: recurse;
|
|
111
|
+
* - value is a non-object (primitive) or falsy: copy as-is;
|
|
112
|
+
* - object has key `langCode`: take only the needed translation;
|
|
113
|
+
* - otherwise: recurse deeper.
|
|
114
|
+
* 3. Primitive → return as-is.
|
|
81
115
|
* @param {any} data - The data to normalize.
|
|
82
116
|
* @param {string} langCode - The language code for normalization.
|
|
83
117
|
* @returns {any} Normalized data.
|
|
@@ -88,7 +122,7 @@ class SyncModules {
|
|
|
88
122
|
}
|
|
89
123
|
else if (typeof data === 'object' && data) {
|
|
90
124
|
const normalizeData = {};
|
|
91
|
-
|
|
125
|
+
Object.keys(data).forEach((key) => {
|
|
92
126
|
if (Array.isArray(data[key])) {
|
|
93
127
|
normalizeData[key] = this._normalizeData(data[key], langCode);
|
|
94
128
|
}
|
|
@@ -96,12 +130,13 @@ class SyncModules {
|
|
|
96
130
|
normalizeData[key] = data[key];
|
|
97
131
|
}
|
|
98
132
|
else if (langCode in data[key]) {
|
|
133
|
+
// Field contains a translation map — pick the requested locale.
|
|
99
134
|
normalizeData[key] = data[key][langCode];
|
|
100
135
|
}
|
|
101
136
|
else {
|
|
102
137
|
normalizeData[key] = this._normalizeData(data[key], langCode);
|
|
103
138
|
}
|
|
104
|
-
}
|
|
139
|
+
});
|
|
105
140
|
return this._normalizeAttr(normalizeData);
|
|
106
141
|
}
|
|
107
142
|
else {
|
|
@@ -110,11 +145,31 @@ class SyncModules {
|
|
|
110
145
|
}
|
|
111
146
|
/**
|
|
112
147
|
* Normalizes the body of a POST request.
|
|
148
|
+
*
|
|
149
|
+
* Performs two transformations before sending to the API:
|
|
150
|
+
*
|
|
151
|
+
* 1. **phoneSMS cleanup**: the API rejects an empty string as a field value,
|
|
152
|
+
* so if `notificationData.phoneSMS === ''` the key is deleted entirely.
|
|
153
|
+
* A missing key is treated by the API as "not provided"; an empty string is not.
|
|
154
|
+
*
|
|
155
|
+
* 2. **formData localization**: the API expects formData as
|
|
156
|
+
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
157
|
+
* The method wraps the data into the required structure.
|
|
158
|
+
* If `formData` is absent from the body — return the body as-is (only phoneSMS cleanup applied).
|
|
113
159
|
* @param {any} body - The body to normalize.
|
|
114
160
|
* @param {string} [langCode] - The language code for normalization.
|
|
115
161
|
* @returns {any} Normalized body.
|
|
116
162
|
*/
|
|
117
163
|
_normalizePostBody(body, langCode = this.state.lang) {
|
|
164
|
+
// API does not accept phoneSMS = '' — delete the field if empty.
|
|
165
|
+
if (body.notificationData && body.notificationData.phoneSMS === '') {
|
|
166
|
+
delete body.notificationData.phoneSMS;
|
|
167
|
+
}
|
|
168
|
+
// If formData is not provided — no further normalization needed.
|
|
169
|
+
if (!body.formData)
|
|
170
|
+
return body;
|
|
171
|
+
// Wrap form fields in an object keyed by locale:
|
|
172
|
+
// [{ marker, value }] → { "en_US": [{ marker, value }] }
|
|
118
173
|
const formData = {};
|
|
119
174
|
formData[langCode] = Array.isArray(body.formData)
|
|
120
175
|
? body.formData
|
|
@@ -124,6 +179,13 @@ class SyncModules {
|
|
|
124
179
|
}
|
|
125
180
|
/**
|
|
126
181
|
* Clears arrays within the data structure.
|
|
182
|
+
*
|
|
183
|
+
* Traverses the data and fixes a specific edge case with image attributes:
|
|
184
|
+
* when an `image` attribute has a single-element array in `value`,
|
|
185
|
+
* the API returns an array but consumers expect a plain object.
|
|
186
|
+
* In that case `value` is unwrapped: `[img]` → `img`.
|
|
187
|
+
*
|
|
188
|
+
* For all other keys the method recursively copies the structure unchanged.
|
|
127
189
|
* @param {Record<string, any>} data - The data to clear.
|
|
128
190
|
* @returns {any} Cleared data.
|
|
129
191
|
*/
|
|
@@ -133,7 +195,7 @@ class SyncModules {
|
|
|
133
195
|
}
|
|
134
196
|
else if (typeof data === 'object' && data) {
|
|
135
197
|
const normalizeData = {};
|
|
136
|
-
|
|
198
|
+
Object.keys(data).forEach((key) => {
|
|
137
199
|
if (Array.isArray(data[key])) {
|
|
138
200
|
normalizeData[key] = this._clearArray(data[key]);
|
|
139
201
|
}
|
|
@@ -142,18 +204,20 @@ class SyncModules {
|
|
|
142
204
|
}
|
|
143
205
|
else if (key === 'attributeValues') {
|
|
144
206
|
const attrs = data[key];
|
|
145
|
-
|
|
207
|
+
Object.keys(attrs).forEach((attr) => {
|
|
208
|
+
// If an image attribute has a single-element value array,
|
|
209
|
+
// unwrap it to a plain object for consumer convenience.
|
|
146
210
|
if (attrs[attr].type === 'image' &&
|
|
147
211
|
attrs[attr].value.length === 1) {
|
|
148
212
|
attrs[attr].value = attrs[attr].value[0];
|
|
149
213
|
}
|
|
150
|
-
}
|
|
214
|
+
});
|
|
151
215
|
normalizeData[key] = data[key];
|
|
152
216
|
}
|
|
153
217
|
else {
|
|
154
218
|
normalizeData[key] = this._clearArray(data[key]);
|
|
155
219
|
}
|
|
156
|
-
}
|
|
220
|
+
});
|
|
157
221
|
return normalizeData;
|
|
158
222
|
}
|
|
159
223
|
else {
|
|
@@ -173,11 +237,26 @@ class SyncModules {
|
|
|
173
237
|
}
|
|
174
238
|
/**
|
|
175
239
|
* Common logic for processing schedule dates (weekly, monthly, or both).
|
|
240
|
+
*
|
|
241
|
+
* Abstracts date iteration for three scheduling modes:
|
|
242
|
+
*
|
|
243
|
+
* - **`inEveryWeek` only**: starting from the start date, generates dates
|
|
244
|
+
* with a 7-day step until the end of the current month.
|
|
245
|
+
*
|
|
246
|
+
* - **`inEveryMonth` only**: pins the day-of-month from the start date
|
|
247
|
+
* and repeats it for each of the next 12 months. If the month does not
|
|
248
|
+
* have that day (e.g. Feb 31), the iteration is skipped.
|
|
249
|
+
*
|
|
250
|
+
* - **`inEveryWeek` + `inEveryMonth`**: for each of the next 12 months finds
|
|
251
|
+
* the first occurrence of the target weekday (from the start date), then
|
|
252
|
+
* iterates all occurrences of that weekday in the month with a 7-day step.
|
|
253
|
+
*
|
|
254
|
+
* `processDate(currentDate)` is called for every resolved date.
|
|
176
255
|
* @param {Date} date - The date for which to process intervals.
|
|
177
256
|
* @param {object} config - Configuration for schedule repetition.
|
|
178
257
|
* @param {boolean} config.inEveryWeek - Whether to repeat weekly.
|
|
179
258
|
* @param {boolean} config.inEveryMonth - Whether to repeat monthly.
|
|
180
|
-
* @param {
|
|
259
|
+
* @param {(currentDate: Date) => void} processDate - Callback function to process each date.
|
|
181
260
|
*/
|
|
182
261
|
_processScheduleDates(date, config, processDate) {
|
|
183
262
|
// Handle weekly schedules
|
|
@@ -233,6 +312,12 @@ class SyncModules {
|
|
|
233
312
|
}
|
|
234
313
|
/**
|
|
235
314
|
* Generates intervals for a specific date based on a schedule.
|
|
315
|
+
*
|
|
316
|
+
* For each date resolved by `_processScheduleDates`, iterates over
|
|
317
|
+
* the `schedule.times` array of time ranges. Each range is a pair
|
|
318
|
+
* `[startTime, endTime]` with `{ hours, minutes }` fields.
|
|
319
|
+
* Creates an ISO interval `[start.toISOString(), end.toISOString()]`
|
|
320
|
+
* and adds it to `utcIntervals` (Set deduplicates automatically).
|
|
236
321
|
* @param {Date} date - The date for which to generate intervals.
|
|
237
322
|
* @param {object} schedule - The schedule defining the intervals.
|
|
238
323
|
* @param {boolean} schedule.inEveryWeek - The number of weeks between intervals.
|
|
@@ -257,6 +342,16 @@ class SyncModules {
|
|
|
257
342
|
}
|
|
258
343
|
/**
|
|
259
344
|
* Adds time intervals to schedules.
|
|
345
|
+
*
|
|
346
|
+
* Accepts an array of schedule groups (structure of `timeInterval` attributes
|
|
347
|
+
* for pages/products). For each group iterates over `values` — the set of
|
|
348
|
+
* concrete schedules. Each schedule contains a date range `dates[0..1]`.
|
|
349
|
+
*
|
|
350
|
+
* If both boundaries are equal (`isSameDay`), intervals are generated only
|
|
351
|
+
* for that single date. Otherwise — for every day in the range inclusive.
|
|
352
|
+
*
|
|
353
|
+
* The result (`schedule.timeIntervals`) is a sorted array of ISO pairs,
|
|
354
|
+
* ready to pass to UI components.
|
|
260
355
|
* @param {any[]} schedules - The schedules to process.
|
|
261
356
|
* @returns {any} Schedules with added time intervals.
|
|
262
357
|
*/
|
|
@@ -288,6 +383,16 @@ class SyncModules {
|
|
|
288
383
|
}
|
|
289
384
|
/**
|
|
290
385
|
* Generates intervals for a specific date for form schedules.
|
|
386
|
+
*
|
|
387
|
+
* Unlike `_generateIntervalsForDate`, time ranges here have a different shape:
|
|
388
|
+
* each `timeInterval` contains `start`, `end` and `period`
|
|
389
|
+
* (slot length in minutes). The method slices the [start, end) window into
|
|
390
|
+
* fixed-length slots of `period` minutes:
|
|
391
|
+
*
|
|
392
|
+
* start=09:00, end=12:00, period=30 → [09:00–09:30], [09:30–10:00], …, [11:30–12:00]
|
|
393
|
+
*
|
|
394
|
+
* Generation stops if the next slot would exceed `end`.
|
|
395
|
+
* Each slot is added to `utcIntervals` (Set deduplicates automatically).
|
|
291
396
|
* @param {Date} date - The date for which to generate intervals.
|
|
292
397
|
* @param {object} interval - The interval configuration.
|
|
293
398
|
* @param {boolean} interval.inEveryWeek - Indicates whether the schedule is weekly.
|
|
@@ -300,14 +405,17 @@ class SyncModules {
|
|
|
300
405
|
timeIntervals.forEach((timeInterval) => {
|
|
301
406
|
let currentStart = timeInterval.start;
|
|
302
407
|
const endTime = timeInterval.end;
|
|
408
|
+
// Slice the window into slots of `period` minutes each.
|
|
303
409
|
while (currentStart.hours < endTime.hours ||
|
|
304
410
|
(currentStart.hours === endTime.hours &&
|
|
305
411
|
currentStart.minutes < endTime.minutes)) {
|
|
306
412
|
const intervalStart = new Date(currentDate);
|
|
307
413
|
intervalStart.setUTCHours(currentStart.hours, currentStart.minutes, 0, 0);
|
|
414
|
+
// Compute slot end: add period minutes with hour carry normalization.
|
|
308
415
|
const nextMinutes = currentStart.minutes + timeInterval.period;
|
|
309
416
|
const nextHours = currentStart.hours + Math.floor(nextMinutes / 60);
|
|
310
417
|
const minutes = nextMinutes % 60;
|
|
418
|
+
// If the slot end exceeds `end` — stop; partial slots are not emitted.
|
|
311
419
|
if (nextHours > endTime.hours ||
|
|
312
420
|
(nextHours === endTime.hours && minutes > endTime.minutes)) {
|
|
313
421
|
break;
|
|
@@ -326,6 +434,14 @@ class SyncModules {
|
|
|
326
434
|
}
|
|
327
435
|
/**
|
|
328
436
|
* Adds time intervals to form schedules (different structure).
|
|
437
|
+
*
|
|
438
|
+
* Same as `_addTimeIntervalsToSchedules` but for `timeInterval` attributes
|
|
439
|
+
* in **forms** (different API data structure):
|
|
440
|
+
* - `interval.range[0..1]` instead of `schedule.dates[0..1]`
|
|
441
|
+
* - `interval.intervals` — array of time ranges with slots (`period`)
|
|
442
|
+
* instead of `[startTime, endTime]` pairs
|
|
443
|
+
*
|
|
444
|
+
* Result is written to `interval.timeIntervals`.
|
|
329
445
|
* @param {any[]} intervals - The intervals to process.
|
|
330
446
|
* @returns {any} Intervals with added time intervals.
|
|
331
447
|
*/
|
|
@@ -357,7 +473,12 @@ class SyncModules {
|
|
|
357
473
|
}
|
|
358
474
|
/**
|
|
359
475
|
* Transforms additionalFields from array to object keyed by marker.
|
|
360
|
-
*
|
|
476
|
+
*
|
|
477
|
+
* The API returns `additionalFields` as an array: `[{ marker, ... }, ...]`.
|
|
478
|
+
* For convenient key-based access (`attr.additionalFields['fieldName']`)
|
|
479
|
+
* the method converts it to an object `{ marker: { marker, ... } }`.
|
|
480
|
+
* Transformation is skipped when `rawData` mode is enabled in config
|
|
481
|
+
* (the consumer wants the data as-is, without transformations).
|
|
361
482
|
* @param {any} attr - The attribute object that may contain additionalFields.
|
|
362
483
|
*/
|
|
363
484
|
_normalizeAdditionalFields(attr) {
|
|
@@ -367,14 +488,31 @@ class SyncModules {
|
|
|
367
488
|
}
|
|
368
489
|
/**
|
|
369
490
|
* Normalizes attributes within the data.
|
|
491
|
+
*
|
|
492
|
+
* Handles three different attribute formats returned by the API:
|
|
493
|
+
*
|
|
494
|
+
* **1. `attributeValues`** — attributes of pages, products and other entities.
|
|
495
|
+
* Contains an object `{ marker: AttrObject }`. For each attribute:
|
|
496
|
+
* - `_normalizeAdditionalFields` is called;
|
|
497
|
+
* - numeric types (`integer`, `float`) are cast to a JS number (or `null`);
|
|
498
|
+
* - `timeInterval` attributes are enriched with computed `timeIntervals`;
|
|
499
|
+
* - the whole object is re-sorted by `position`.
|
|
500
|
+
*
|
|
501
|
+
* **2. `attributes`** — form attributes (different API structure).
|
|
502
|
+
* Same `additionalFields` and `timeInterval` processing,
|
|
503
|
+
* but numbers are not normalized here (commented out — logic differs).
|
|
504
|
+
*
|
|
505
|
+
* **3. `type`** — a single attribute from an attribute set.
|
|
506
|
+
* Same transformations as in case 1, but without sorting.
|
|
507
|
+
*
|
|
508
|
+
* If none of the keys are found — data is returned unchanged.
|
|
370
509
|
* @param {any} data - The data to normalize.
|
|
371
510
|
* @returns {any} Normalized attributes.
|
|
372
511
|
*/
|
|
373
512
|
_normalizeAttr(data) {
|
|
374
|
-
var _a;
|
|
375
513
|
// For regular attributes collections - pages, products, etc.
|
|
376
514
|
if ('attributeValues' in data) {
|
|
377
|
-
|
|
515
|
+
Object.keys(data.attributeValues).forEach((attr) => {
|
|
378
516
|
const d = data.attributeValues[attr];
|
|
379
517
|
this._normalizeAdditionalFields(d);
|
|
380
518
|
// normalize numbers
|
|
@@ -391,7 +529,7 @@ class SyncModules {
|
|
|
391
529
|
data.attributeValues[attr].value = result;
|
|
392
530
|
}
|
|
393
531
|
}
|
|
394
|
-
}
|
|
532
|
+
});
|
|
395
533
|
return {
|
|
396
534
|
...data,
|
|
397
535
|
attributeValues: this._sortAttributes(data.attributeValues),
|
|
@@ -400,7 +538,8 @@ class SyncModules {
|
|
|
400
538
|
// for forms attributes - forms attributes collections
|
|
401
539
|
if ('attributes' in data) {
|
|
402
540
|
const d = data.attributes;
|
|
403
|
-
|
|
541
|
+
Object.keys(d).forEach((attr) => {
|
|
542
|
+
var _a;
|
|
404
543
|
this._normalizeAdditionalFields(d[attr]);
|
|
405
544
|
// Normalize numbers
|
|
406
545
|
// if (d[attr].type === 'integer' || d[attr].type === 'float') {
|
|
@@ -416,7 +555,7 @@ class SyncModules {
|
|
|
416
555
|
d[attr].localizeInfos.intervals = result;
|
|
417
556
|
}
|
|
418
557
|
}
|
|
419
|
-
}
|
|
558
|
+
});
|
|
420
559
|
return data;
|
|
421
560
|
}
|
|
422
561
|
// For single attribute - for attribute sets
|
|
@@ -440,6 +579,10 @@ class SyncModules {
|
|
|
440
579
|
}
|
|
441
580
|
/**
|
|
442
581
|
* Processes data after fetching or receiving it.
|
|
582
|
+
*
|
|
583
|
+
* Final post-processing of the API response: first unwraps localized fields
|
|
584
|
+
* (`_normalizeData`), then fixes single-element image attributes
|
|
585
|
+
* (`_clearArray`). Called at the end of every fetch method.
|
|
443
586
|
* @param {any} data - The data to process.
|
|
444
587
|
* @param {any} [langCode] - The language code for processing.
|
|
445
588
|
* @returns {any} Processed data.
|
|
@@ -469,6 +612,30 @@ class SyncModules {
|
|
|
469
612
|
}
|
|
470
613
|
/**
|
|
471
614
|
* Get deviceMetadata
|
|
615
|
+
*
|
|
616
|
+
* Builds a device metadata object to be sent in request headers.
|
|
617
|
+
* Used for analytics and anti-fraud on the API side.
|
|
618
|
+
*
|
|
619
|
+
* Returned JSON structure:
|
|
620
|
+
* ```json
|
|
621
|
+
* {
|
|
622
|
+
* "fingerprint": "UQ_<hash>_<instanceId>",
|
|
623
|
+
* "deviceInfo": { "os": "...", "browser": "...", "location": "en-US" }
|
|
624
|
+
* }
|
|
625
|
+
* ```
|
|
626
|
+
*
|
|
627
|
+
* **Fingerprint algorithm:**
|
|
628
|
+
* 1. Builds a string from stable characteristics: platform, userAgent, language,
|
|
629
|
+
* screen resolution, colorDepth, timezone, private-browsing mode, instanceId.
|
|
630
|
+
* 2. Runs it through a simple 32-bit hash (djb2-like).
|
|
631
|
+
* 3. Concatenates the hash and the first 12 characters of instanceId.
|
|
632
|
+
*
|
|
633
|
+
* **instanceId strategy:**
|
|
634
|
+
* - Browser: `_getBrowserDeviceId()` — read from localStorage, stable across sessions.
|
|
635
|
+
* - Node.js / no localStorage: `_nodeDeviceId` — generated at instance creation,
|
|
636
|
+
* lives until the process restarts.
|
|
637
|
+
*
|
|
638
|
+
* In a Node.js environment (no `window`) returns a simplified object without screen/navigator.
|
|
472
639
|
* @returns {string} - Returns an object containing device metadata.
|
|
473
640
|
*/
|
|
474
641
|
_getDeviceMetadata() {
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {string} Types - Type of block.
|
|
3
3
|
*/
|
|
4
|
-
type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'none';
|
|
4
|
+
type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
|
|
5
5
|
/**
|
|
6
6
|
* @property {string} [token] - If your project is protected by a token, specify this token in this parameter.
|
|
7
7
|
* @property {string} [langCode] - specify the default language to avoid specifying it in every request.
|
|
@@ -3,11 +3,6 @@ import type { IProductsEntity, IProductsResponse } from '../products/productsInt
|
|
|
3
3
|
/**
|
|
4
4
|
* Interface for managing and retrieving blocks in the system.
|
|
5
5
|
* @interface IBlocks
|
|
6
|
-
* @property {Function} getBlocks - Get all Blocks objects.
|
|
7
|
-
* @property {Function} getBlockByMarker - Get Block object by marker.
|
|
8
|
-
* @property {Function} getSimilarProducts - Get Array of similar products from product-similar block.
|
|
9
|
-
* @property {Function} getProductsByBlockMarker - Get Array of products from product block.
|
|
10
|
-
* @property {Function} searchBlock - Quick search for block objects with limited output.
|
|
11
6
|
* @description This interface defines methods for retrieving and managing blocks in the system.
|
|
12
7
|
*/
|
|
13
8
|
interface IBlocks {
|
|
@@ -45,6 +45,8 @@ export declare const BlockEntitySchema: z.ZodObject<{
|
|
|
45
45
|
}, z.core.$strip>>>;
|
|
46
46
|
relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
47
47
|
pageId: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
49
|
+
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
48
50
|
}, z.core.$strip>>;
|
|
49
51
|
total: z.ZodNumber;
|
|
50
52
|
}, z.core.$strip>>;
|
|
@@ -81,6 +83,8 @@ export declare const BlockEntitySchema: z.ZodObject<{
|
|
|
81
83
|
}, z.core.$strip>>>;
|
|
82
84
|
relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
83
85
|
pageId: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
87
|
+
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
84
88
|
}, z.core.$strip>>>;
|
|
85
89
|
}, z.core.$strip>;
|
|
86
90
|
/**
|
|
@@ -129,6 +133,8 @@ export declare const BlocksResponseSchema: z.ZodObject<{
|
|
|
129
133
|
}, z.core.$strip>>>;
|
|
130
134
|
relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
131
135
|
pageId: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
137
|
+
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
132
138
|
}, z.core.$strip>>;
|
|
133
139
|
total: z.ZodNumber;
|
|
134
140
|
}, z.core.$strip>>;
|
|
@@ -165,6 +171,8 @@ export declare const BlocksResponseSchema: z.ZodObject<{
|
|
|
165
171
|
}, z.core.$strip>>>;
|
|
166
172
|
relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
167
173
|
pageId: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
175
|
+
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
168
176
|
}, z.core.$strip>>>;
|
|
169
177
|
}, z.core.$strip>>;
|
|
170
178
|
total: z.ZodNumber;
|
|
@@ -40,7 +40,7 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
|
|
|
40
40
|
* @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
|
|
41
41
|
* @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
|
|
42
42
|
* @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
|
|
43
|
-
* @param {
|
|
43
|
+
* @param {string | number} [fileQuery.template] - preview template identifier. Example: 1.
|
|
44
44
|
* @returns {Promise<IUploadingReturn[] | IError>} Uploads a file to an Amazon S3-compatible cloud file storage.
|
|
45
45
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
46
46
|
*/
|
|
@@ -61,10 +61,10 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
|
|
|
61
61
|
* @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
|
|
62
62
|
* @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
|
|
63
63
|
* @param {number} [fileQuery.template] - preview template identifier. Example: 1.
|
|
64
|
-
* @returns {Promise<
|
|
64
|
+
* @returns {Promise<boolean | IError>} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
|
|
65
65
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
66
66
|
*/
|
|
67
|
-
delete(filename: string, fileQuery?: IUploadingQuery): Promise<
|
|
67
|
+
delete(filename: string, fileQuery?: IUploadingQuery): Promise<boolean | IError>;
|
|
68
68
|
/**
|
|
69
69
|
* Create a File object from a URL.
|
|
70
70
|
* @param {string} url - The URL to fetch the file from.
|
|
@@ -81,8 +81,8 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
|
|
|
81
81
|
* @param {string} entity - Entity name, from which the file is uploaded, determines the folder name in the storage. Example: "editor".
|
|
82
82
|
* @param {string} filename - Filename. Example: "file.png".
|
|
83
83
|
* @param {string} [template] - Preview template identifier. Example: 1.
|
|
84
|
-
* @returns {Promise<
|
|
84
|
+
* @returns {Promise<Response | IError>} Returns a promise that resolves to a Response object containing the file data or an error object if there was an issue.
|
|
85
85
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
86
86
|
*/
|
|
87
|
-
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<
|
|
87
|
+
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<Response | IError>;
|
|
88
88
|
}
|
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable jsdoc/reject-any-type */
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
/// <reference lib="dom" />
|
|
9
6
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
10
7
|
// import { IFileEntity } from './fileUploadingInterfaces';
|
|
11
8
|
const fileUploadingSchemas_1 = require("./fileUploadingSchemas");
|
|
@@ -55,7 +52,7 @@ class FileUploadingApi extends asyncModules_1.default {
|
|
|
55
52
|
* @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
|
|
56
53
|
* @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
|
|
57
54
|
* @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
|
|
58
|
-
* @param {
|
|
55
|
+
* @param {string | number} [fileQuery.template] - preview template identifier. Example: 1.
|
|
59
56
|
* @returns {Promise<IUploadingReturn[] | IError>} Uploads a file to an Amazon S3-compatible cloud file storage.
|
|
60
57
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
61
58
|
*/
|
|
@@ -84,7 +81,7 @@ class FileUploadingApi extends asyncModules_1.default {
|
|
|
84
81
|
* @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
|
|
85
82
|
* @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
|
|
86
83
|
* @param {number} [fileQuery.template] - preview template identifier. Example: 1.
|
|
87
|
-
* @returns {Promise<
|
|
84
|
+
* @returns {Promise<boolean | IError>} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
|
|
88
85
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
89
86
|
*/
|
|
90
87
|
async delete(filename, fileQuery) {
|
|
@@ -114,7 +111,7 @@ class FileUploadingApi extends asyncModules_1.default {
|
|
|
114
111
|
* @param {string} entity - Entity name, from which the file is uploaded, determines the folder name in the storage. Example: "editor".
|
|
115
112
|
* @param {string} filename - Filename. Example: "file.png".
|
|
116
113
|
* @param {string} [template] - Preview template identifier. Example: 1.
|
|
117
|
-
* @returns {Promise<
|
|
114
|
+
* @returns {Promise<Response | IError>} Returns a promise that resolves to a Response object containing the file data or an error object if there was an issue.
|
|
118
115
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
119
116
|
*/
|
|
120
117
|
async getFile(id, type, entity, filename, template) {
|
|
@@ -2,9 +2,6 @@ import type { IError } from '../base/utils';
|
|
|
2
2
|
/**
|
|
3
3
|
* Interface for uploading, deleting, and retrieving files in the CMS.
|
|
4
4
|
* @interface IFileUploading
|
|
5
|
-
* @property {Function} upload - Upload file from CMS.
|
|
6
|
-
* @property {Function} delete - Delete file from CMS.
|
|
7
|
-
* @property {Function} getFile - Get file by parameters.
|
|
8
5
|
* @description This interface defines methods for uploading, deleting, and retrieving files in the CMS.
|
|
9
6
|
*/
|
|
10
7
|
interface IFileUploading {
|
|
@@ -37,7 +34,7 @@ interface IFileUploading {
|
|
|
37
34
|
* @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
|
|
38
35
|
* @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
|
|
39
36
|
* @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
|
|
40
|
-
* @param {
|
|
37
|
+
* @param {number} [fileQuery.template] - preview template identifier. Example: 1.
|
|
41
38
|
* @returns {IUploadingReturn[]} Uploads a file to an Amazon S3-compatible cloud file storage.
|
|
42
39
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
43
40
|
*/
|
|
@@ -58,10 +55,10 @@ interface IFileUploading {
|
|
|
58
55
|
* @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
|
|
59
56
|
* @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
|
|
60
57
|
* @param {number} [fileQuery.template] - preview template identifier. Example: 1.
|
|
61
|
-
* @returns {
|
|
58
|
+
* @returns {boolean | IError} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
|
|
62
59
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
63
60
|
*/
|
|
64
|
-
delete(filename: string, fileQuery?: IUploadingQuery): Promise<
|
|
61
|
+
delete(filename: string, fileQuery?: IUploadingQuery): Promise<boolean | IError>;
|
|
65
62
|
/**
|
|
66
63
|
* Get file by parameters.
|
|
67
64
|
* @handleName getFile
|
|
@@ -70,10 +67,10 @@ interface IFileUploading {
|
|
|
70
67
|
* @param {string} entity - Entity name, from which the file is uploaded, determines the folder name in the storage. Example: "editor".
|
|
71
68
|
* @param {string} filename - Filename. Example: "file.png".
|
|
72
69
|
* @param {string} [template] - Preview template identifier. Example: 1.
|
|
73
|
-
* @returns {
|
|
70
|
+
* @returns {Response | IError} Returns a promise that resolves to a Response object containing the file data or an error object if there was an issue.
|
|
74
71
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
75
72
|
*/
|
|
76
|
-
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<
|
|
73
|
+
getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<Response | IError>;
|
|
77
74
|
}
|
|
78
75
|
/**
|
|
79
76
|
* Represents a file entity that may contain a file object or a path as a string.
|
|
@@ -3,8 +3,6 @@ import type { IAttributes, IError, ILocalizeInfo } from '../base/utils';
|
|
|
3
3
|
/**
|
|
4
4
|
* Interface for retrieving forms in the system.
|
|
5
5
|
* @interface IForms
|
|
6
|
-
* @property {Function} getAllForms - Get all forms in array.
|
|
7
|
-
* @property {Function} getFormByMarker - Get one form by form marker.
|
|
8
6
|
* @description This interface defines methods for retrieving forms in the system.
|
|
9
7
|
*/
|
|
10
8
|
interface IForms {
|
|
@@ -110,6 +108,8 @@ interface IFormsEntity {
|
|
|
110
108
|
* @property {string} entityIdentifiers[].id - Entity identifier. Example: "catalog".
|
|
111
109
|
* @property {boolean} entityIdentifiers[].isNested - Indicates if entity is nested. Example: false.
|
|
112
110
|
* @property {string[]} [nestedEntityIdentifiers] - An array of nested entity identifier strings (only in products/pages API). Example: ["catalog"].
|
|
111
|
+
* @property {number} [formDataCount] - Total count of form data entries (only in products/pages API). Example: 306.
|
|
112
|
+
* @property {Record<string, number>} [entityFormDataCount] - Form data count per entity identifier (only in products/pages API). Example: {"catalog": 306}.
|
|
113
113
|
* @description This interface defines the structure of a form configuration, including its identifiers, module association, and entity identifiers. Different APIs return different field variants.
|
|
114
114
|
*/
|
|
115
115
|
interface IFormConfig {
|
|
@@ -128,5 +128,7 @@ interface IFormConfig {
|
|
|
128
128
|
isNested: boolean;
|
|
129
129
|
}[];
|
|
130
130
|
nestedEntityIdentifiers?: string[];
|
|
131
|
+
formDataCount?: number;
|
|
132
|
+
entityFormDataCount?: Record<string, number>;
|
|
131
133
|
}
|
|
132
134
|
export type { IFormConfig, IForms, IFormsEntity, IFromPages };
|
|
@@ -3,9 +3,6 @@ import type { IUploadingQuery } from '../file-uploading/fileUploadingInterfaces'
|
|
|
3
3
|
/**
|
|
4
4
|
* Interface for retrieving and posting form data in the system.
|
|
5
5
|
* @interface IFormsData
|
|
6
|
-
* @property {Function} getFormsData - Get all forms data.
|
|
7
|
-
* @property {Function} postFormsData - Find all product page objects with pagination and multiple filtering.
|
|
8
|
-
* @property {Function} getFormsDataByMarker - Get one object of form data by marker.
|
|
9
6
|
* @description This interface defines methods for retrieving and posting form data in the system.
|
|
10
7
|
*/
|
|
11
8
|
interface IFormsData {
|
|
@@ -3,7 +3,6 @@ import type { BlockType } from '../blocks/blocksInterfaces';
|
|
|
3
3
|
/**
|
|
4
4
|
* Interface for retrieving all general types in the system.
|
|
5
5
|
* @interface IGeneralTypes
|
|
6
|
-
* @property {Function} getAllTypes - Get all types.
|
|
7
6
|
* @description This interface defines a method for retrieving all general types in the system.
|
|
8
7
|
*/
|
|
9
8
|
interface IGeneralTypes {
|
|
@@ -20,7 +19,7 @@ interface IGeneralTypes {
|
|
|
20
19
|
* Represents a general type entity.
|
|
21
20
|
* @interface IGeneralTypesEntity
|
|
22
21
|
* @property {number} id - Type id. Example: 1.
|
|
23
|
-
* @property {
|
|
22
|
+
* @property {BlockType} type - Types enum. Example: "product", "category", "etc".
|
|
24
23
|
* @description Represents a general type entity with an identifier and a type.
|
|
25
24
|
*/
|
|
26
25
|
interface IGeneralTypesEntity {
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ import WsApi from './web-socket/wsApi';
|
|
|
43
43
|
* @property {LocalesApi} Locales - Locales API module.
|
|
44
44
|
* @property {MenusApi} Menus - Menus API module.
|
|
45
45
|
* @property {OrdersApi} Orders - Orders API module.
|
|
46
|
-
* @property {
|
|
46
|
+
* @property {PagesApi} Pages - Pages API module.
|
|
47
47
|
* @property {PaymentsApi} Payments - Payments API module.
|
|
48
48
|
* @property {ProductsApi} Products - Products API module.
|
|
49
49
|
* @property {ProductStatusesApi} ProductStatuses - Product statuses API module.
|