oneentry 1.0.142 → 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/dist/admins/adminsApi.d.ts +50 -0
- package/dist/admins/adminsApi.js +65 -0
- package/dist/admins/adminsInterfaces.d.ts +98 -0
- package/dist/admins/adminsInterfaces.js +2 -0
- package/dist/admins/adminsSchemas.d.ts +30 -0
- package/dist/admins/adminsSchemas.js +27 -0
- package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
- package/dist/attribute-sets/attributeSetsApi.js +98 -0
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +185 -0
- package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
- package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
- package/dist/auth-provider/authProviderApi.d.ts +249 -0
- package/dist/auth-provider/authProviderApi.js +354 -0
- package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
- package/dist/auth-provider/authProviderSchemas.js +82 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +412 -0
- package/dist/auth-provider/authProvidersInterfaces.js +2 -0
- package/dist/base/asyncModules.d.ts +80 -0
- package/dist/base/asyncModules.js +448 -0
- package/dist/base/result.d.ts +39 -0
- package/dist/base/result.js +154 -0
- package/dist/base/stateModule.d.ts +41 -0
- package/dist/base/stateModule.js +128 -0
- package/dist/base/syncModules.d.ts +286 -0
- package/dist/base/syncModules.js +716 -0
- package/dist/base/utils.d.ts +197 -0
- package/dist/base/utils.js +2 -0
- package/dist/base/validation.d.ts +118 -0
- package/dist/base/validation.js +132 -0
- package/dist/blocks/blocksApi.d.ts +76 -0
- package/dist/blocks/blocksApi.js +188 -0
- package/dist/blocks/blocksInterfaces.d.ts +168 -0
- package/dist/blocks/blocksInterfaces.js +2 -0
- package/dist/blocks/blocksSchemas.d.ts +195 -0
- package/dist/blocks/blocksSchemas.js +43 -0
- package/dist/discounts/discountsApi.d.ts +56 -0
- package/dist/discounts/discountsApi.js +82 -0
- package/dist/discounts/discountsInterfaces.d.ts +145 -0
- package/dist/discounts/discountsInterfaces.js +2 -0
- package/dist/events/eventsApi.d.ts +60 -0
- package/dist/events/eventsApi.js +97 -0
- package/dist/events/eventsInterfaces.d.ts +87 -0
- package/dist/events/eventsInterfaces.js +2 -0
- package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
- package/dist/file-uploading/fileUploadingApi.js +129 -0
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +114 -0
- package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
- package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
- package/dist/file-uploading/fileUploadingSchemas.js +21 -0
- package/dist/forms/formsApi.d.ts +42 -0
- package/dist/forms/formsApi.js +57 -0
- package/dist/forms/formsInterfaces.d.ts +134 -0
- package/dist/forms/formsInterfaces.js +2 -0
- package/dist/forms/formsSchemas.d.ts +50 -0
- package/dist/forms/formsSchemas.js +31 -0
- package/dist/forms-data/formsDataApi.d.ts +106 -0
- package/dist/forms-data/formsDataApi.js +189 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +522 -0
- package/dist/forms-data/formsDataInterfaces.js +2 -0
- package/dist/forms-data/formsDataSchemas.d.ts +115 -0
- package/dist/forms-data/formsDataSchemas.js +86 -0
- package/dist/general-types/generalTypesApi.d.ts +28 -0
- package/dist/general-types/generalTypesApi.js +38 -0
- package/dist/general-types/generalTypesInterfaces.d.ts +29 -0
- package/dist/general-types/generalTypesInterfaces.js +2 -0
- package/dist/general-types/generalTypesSchemas.d.ts +50 -0
- package/dist/general-types/generalTypesSchemas.js +35 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +103 -0
- package/dist/integration-collections/integrationCollectionsApi.d.ts +163 -0
- package/dist/integration-collections/integrationCollectionsApi.js +220 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
- package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
- package/dist/locales/localesApi.d.ts +27 -0
- package/dist/locales/localesApi.js +37 -0
- package/dist/locales/localesInterfaces.d.ts +40 -0
- package/dist/locales/localesInterfaces.js +2 -0
- package/dist/locales/localesSchemas.d.ts +32 -0
- package/dist/locales/localesSchemas.js +26 -0
- package/dist/menus/menusApi.d.ts +29 -0
- package/dist/menus/menusApi.js +39 -0
- package/dist/menus/menusInterfaces.d.ts +87 -0
- package/dist/menus/menusInterfaces.js +3 -0
- package/dist/menus/menusSchemas.d.ts +16 -0
- package/dist/menus/menusSchemas.js +28 -0
- package/dist/orders/ordersApi.d.ts +149 -0
- package/dist/orders/ordersApi.js +203 -0
- package/dist/orders/ordersInterfaces.d.ts +520 -0
- package/dist/orders/ordersInterfaces.js +2 -0
- package/dist/orders/ordersSchemas.d.ts +120 -0
- package/dist/orders/ordersSchemas.js +101 -0
- package/dist/pages/pagesApi.d.ts +151 -0
- package/dist/pages/pagesApi.js +390 -0
- package/dist/pages/pagesInterfaces.d.ts +284 -0
- package/dist/pages/pagesInterfaces.js +2 -0
- package/dist/pages/pagesSchemas.d.ts +85 -0
- package/dist/pages/pagesSchemas.js +46 -0
- package/dist/payments/paymentsApi.d.ts +82 -0
- package/dist/payments/paymentsApi.js +121 -0
- package/dist/payments/paymentsInterfaces.d.ts +200 -0
- package/dist/payments/paymentsInterfaces.js +2 -0
- package/dist/payments/paymentsSchemas.d.ts +100 -0
- package/dist/payments/paymentsSchemas.js +65 -0
- package/dist/product-statuses/productStatusesApi.d.ts +47 -0
- package/dist/product-statuses/productStatusesApi.js +70 -0
- package/dist/product-statuses/productStatusesInterfaces.d.ts +62 -0
- package/dist/product-statuses/productStatusesInterfaces.js +2 -0
- package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/dist/product-statuses/productStatusesSchemas.js +30 -0
- package/dist/products/productsApi.d.ts +365 -0
- package/dist/products/productsApi.js +459 -0
- package/dist/products/productsInterfaces.d.ts +577 -0
- package/dist/products/productsInterfaces.js +2 -0
- package/dist/products/productsSchemas.d.ts +200 -0
- package/dist/products/productsSchemas.js +98 -0
- package/dist/sitemap/sitemapApi.d.ts +35 -0
- package/dist/sitemap/sitemapApi.js +45 -0
- package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
- package/dist/sitemap/sitemapInterfaces.js +2 -0
- package/dist/system/systemApi.d.ts +43 -0
- package/dist/system/systemApi.js +56 -0
- package/dist/system/systemInterfaces.d.ts +29 -0
- package/dist/system/systemInterfaces.js +2 -0
- package/dist/templates/templatesApi.d.ts +49 -0
- package/dist/templates/templatesApi.js +75 -0
- package/dist/templates/templatesInterfaces.d.ts +67 -0
- package/dist/templates/templatesInterfaces.js +2 -0
- package/dist/templates/templatesSchemas.d.ts +48 -0
- package/dist/templates/templatesSchemas.js +31 -0
- package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
- package/dist/templates-preview/templatesPreviewApi.js +53 -0
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +119 -0
- package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
- package/dist/users/usersApi.d.ts +143 -0
- package/dist/users/usersApi.js +171 -0
- package/dist/users/usersInterfaces.d.ts +229 -0
- package/dist/users/usersInterfaces.js +2 -0
- package/dist/users/usersSchemas.d.ts +38 -0
- package/dist/users/usersSchemas.js +28 -0
- package/dist/web-socket/wsApi.d.ts +25 -0
- package/dist/web-socket/wsApi.js +45 -0
- package/dist/web-socket/wsInterfaces.d.ts +16 -0
- package/dist/web-socket/wsInterfaces.js +2 -0
- package/package.json +3 -81
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IConfig, IError } from './utils';
|
|
2
|
+
/**
|
|
3
|
+
* State module for managing application state and configuration.
|
|
4
|
+
* @description State module for managing application state and configuration.
|
|
5
|
+
*/
|
|
6
|
+
export default class StateModule {
|
|
7
|
+
url: string | undefined;
|
|
8
|
+
lang: string | undefined;
|
|
9
|
+
token: string | undefined;
|
|
10
|
+
accessToken: string | undefined;
|
|
11
|
+
traficLimit: boolean;
|
|
12
|
+
refreshToken: string | undefined;
|
|
13
|
+
providerMarker: string;
|
|
14
|
+
customAuth: boolean;
|
|
15
|
+
_NO_FETCH: boolean;
|
|
16
|
+
_https: any;
|
|
17
|
+
isShell: boolean;
|
|
18
|
+
validationEnabled: boolean;
|
|
19
|
+
validationStrictMode: boolean;
|
|
20
|
+
validationLogErrors: boolean;
|
|
21
|
+
rawData: boolean;
|
|
22
|
+
errorsFunctions: {
|
|
23
|
+
400?: (data: IError) => any | null;
|
|
24
|
+
401?: (data: IError) => any | null;
|
|
25
|
+
403?: (data: IError) => any | null;
|
|
26
|
+
404?: (data: IError) => any | null;
|
|
27
|
+
429?: (data: IError) => any | null;
|
|
28
|
+
500?: (data: IError) => any | null;
|
|
29
|
+
502?: (data: IError) => any | null;
|
|
30
|
+
503?: (data: IError) => any | null;
|
|
31
|
+
504?: (data: IError) => any | null;
|
|
32
|
+
};
|
|
33
|
+
saveFunction: (param: string) => void | null;
|
|
34
|
+
/**
|
|
35
|
+
* Constructor for StateModule
|
|
36
|
+
* @param {string} url - Base URL for API requests.
|
|
37
|
+
* @param {IConfig} config - Configuration object.
|
|
38
|
+
* @description Constructor for StateModule.
|
|
39
|
+
*/
|
|
40
|
+
constructor(url: string, config: IConfig);
|
|
41
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
/**
|
|
37
|
+
* State module for managing application state and configuration.
|
|
38
|
+
* @description State module for managing application state and configuration.
|
|
39
|
+
*/
|
|
40
|
+
class StateModule {
|
|
41
|
+
/**
|
|
42
|
+
* Constructor for StateModule
|
|
43
|
+
* @param {string} url - Base URL for API requests.
|
|
44
|
+
* @param {IConfig} config - Configuration object.
|
|
45
|
+
* @description Constructor for StateModule.
|
|
46
|
+
*/
|
|
47
|
+
constructor(url, config) {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
49
|
+
this.url = url;
|
|
50
|
+
this.lang = (_a = config.langCode) !== null && _a !== void 0 ? _a : 'en_US';
|
|
51
|
+
this.token = config.token;
|
|
52
|
+
this.traficLimit = config.traficLimit || false;
|
|
53
|
+
this.validationEnabled = (_c = (_b = config.validation) === null || _b === void 0 ? void 0 : _b.enabled) !== null && _c !== void 0 ? _c : false;
|
|
54
|
+
this.validationStrictMode = (_e = (_d = config.validation) === null || _d === void 0 ? void 0 : _d.strictMode) !== null && _e !== void 0 ? _e : false;
|
|
55
|
+
this.validationLogErrors = (_g = (_f = config.validation) === null || _f === void 0 ? void 0 : _f.logErrors) !== null && _g !== void 0 ? _g : true;
|
|
56
|
+
this.rawData = (_h = config.rawData) !== null && _h !== void 0 ? _h : false;
|
|
57
|
+
this.refreshToken = (_k = (_j = config.auth) === null || _j === void 0 ? void 0 : _j.refreshToken) !== null && _k !== void 0 ? _k : undefined;
|
|
58
|
+
this.providerMarker = (_m = (_l = config.auth) === null || _l === void 0 ? void 0 : _l.providerMarker) !== null && _m !== void 0 ? _m : 'email';
|
|
59
|
+
this.customAuth = (_p = (_o = config.auth) === null || _o === void 0 ? void 0 : _o.customAuth) !== null && _p !== void 0 ? _p : false;
|
|
60
|
+
this.errorsFunctions = {
|
|
61
|
+
'400': undefined,
|
|
62
|
+
'401': undefined,
|
|
63
|
+
'403': undefined,
|
|
64
|
+
'404': undefined,
|
|
65
|
+
'429': undefined,
|
|
66
|
+
'500': undefined,
|
|
67
|
+
'502': undefined,
|
|
68
|
+
'503': undefined,
|
|
69
|
+
'504': undefined,
|
|
70
|
+
};
|
|
71
|
+
this.saveFunction = (_r = (_q = config.auth) === null || _q === void 0 ? void 0 : _q.saveFunction) !== null && _r !== void 0 ? _r : null;
|
|
72
|
+
if (config.errors) {
|
|
73
|
+
this.isShell = (_s = config.errors.isShell) !== null && _s !== void 0 ? _s : true;
|
|
74
|
+
if (config.errors.customErrors) {
|
|
75
|
+
this.errorsFunctions['400'] =
|
|
76
|
+
(_t = config.errors.customErrors['400']) !== null && _t !== void 0 ? _t : undefined;
|
|
77
|
+
this.errorsFunctions['401'] =
|
|
78
|
+
(_u = config.errors.customErrors['401']) !== null && _u !== void 0 ? _u : undefined;
|
|
79
|
+
this.errorsFunctions['403'] =
|
|
80
|
+
(_v = config.errors.customErrors['403']) !== null && _v !== void 0 ? _v : undefined;
|
|
81
|
+
this.errorsFunctions['404'] =
|
|
82
|
+
(_w = config.errors.customErrors['404']) !== null && _w !== void 0 ? _w : undefined;
|
|
83
|
+
this.errorsFunctions['429'] =
|
|
84
|
+
(_x = config.errors.customErrors['429']) !== null && _x !== void 0 ? _x : undefined;
|
|
85
|
+
this.errorsFunctions['500'] =
|
|
86
|
+
(_y = config.errors.customErrors['500']) !== null && _y !== void 0 ? _y : undefined;
|
|
87
|
+
this.errorsFunctions['502'] =
|
|
88
|
+
(_z = config.errors.customErrors['502']) !== null && _z !== void 0 ? _z : undefined;
|
|
89
|
+
this.errorsFunctions['503'] =
|
|
90
|
+
(_0 = config.errors.customErrors['503']) !== null && _0 !== void 0 ? _0 : undefined;
|
|
91
|
+
this.errorsFunctions['504'] =
|
|
92
|
+
(_1 = config.errors.customErrors['504']) !== null && _1 !== void 0 ? _1 : undefined;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.isShell = true;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
if (typeof process === 'object' &&
|
|
100
|
+
+process.versions.node.split('.')[0] < 18) {
|
|
101
|
+
try {
|
|
102
|
+
this._NO_FETCH = true;
|
|
103
|
+
// Dynamically import https for older Node.js versions
|
|
104
|
+
Promise.resolve().then(() => __importStar(require('https'))).then((https) => {
|
|
105
|
+
this._https = https;
|
|
106
|
+
})
|
|
107
|
+
.catch(() => {
|
|
108
|
+
this._https = null;
|
|
109
|
+
});
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
this._https = null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
this._NO_FETCH = false;
|
|
118
|
+
this._https = null;
|
|
119
|
+
}
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
this._NO_FETCH = false;
|
|
124
|
+
this._https = null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.default = StateModule;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { IUploadingQuery } from '../file-uploading/fileUploadingInterfaces';
|
|
2
|
+
import type { IProductsQuery } from '../products/productsInterfaces';
|
|
3
|
+
import type StateModule from './stateModule';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract class representing synchronization modules.
|
|
6
|
+
*/
|
|
7
|
+
export default abstract class SyncModules {
|
|
8
|
+
/** Protected properties for state and URL */
|
|
9
|
+
protected state: StateModule;
|
|
10
|
+
protected _url: string;
|
|
11
|
+
private readonly _nodeDeviceId;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor to initialize state and URL.
|
|
14
|
+
* @param {StateModule} state - StateModule instance.
|
|
15
|
+
*/
|
|
16
|
+
protected constructor(state: StateModule);
|
|
17
|
+
/**
|
|
18
|
+
* Constructs the full URL path by appending the given path to the base URL.
|
|
19
|
+
* @param {string} path - The path to append to the base URL.
|
|
20
|
+
* @returns {string} The full URL as a string.
|
|
21
|
+
*/
|
|
22
|
+
protected _getFullPath(path: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Converts query parameters into a query string.
|
|
25
|
+
* @param {IProductsQuery | IUploadingQuery | any} query - The query object containing key-value pairs.
|
|
26
|
+
* @returns {string} A string representation of the query parameters.
|
|
27
|
+
*/
|
|
28
|
+
protected _queryParamsToString(query: IProductsQuery | IUploadingQuery | any): string;
|
|
29
|
+
/**
|
|
30
|
+
* Normalizes data based on language code.
|
|
31
|
+
*
|
|
32
|
+
* Recursively traverses the API response and unwraps localized fields.
|
|
33
|
+
* The API stores translations as objects like
|
|
34
|
+
* `{ "en_US": "Hello", "ru_RU": "Hello" }`. The method replaces such an object
|
|
35
|
+
* with the value for the requested `langCode` when that key is present.
|
|
36
|
+
*
|
|
37
|
+
* Traversal order:
|
|
38
|
+
* 1. Array → recursively normalize each element, then `_normalizeAttr`.
|
|
39
|
+
* 2. Object → for each key:
|
|
40
|
+
* - value is an array: recurse;
|
|
41
|
+
* - value is a non-object (primitive) or falsy: copy as-is;
|
|
42
|
+
* - object has key `langCode`: take only the needed translation;
|
|
43
|
+
* - otherwise: recurse deeper.
|
|
44
|
+
* 3. Primitive → return as-is.
|
|
45
|
+
* @param {any} data - The data to normalize.
|
|
46
|
+
* @param {string} langCode - The language code for normalization.
|
|
47
|
+
* @returns {any} Normalized data.
|
|
48
|
+
*/
|
|
49
|
+
protected _normalizeData(data: any, langCode?: string): any;
|
|
50
|
+
/**
|
|
51
|
+
* Normalizes the body of a POST request.
|
|
52
|
+
*
|
|
53
|
+
* Performs two transformations before sending to the API:
|
|
54
|
+
*
|
|
55
|
+
* 1. **phoneSMS cleanup**: the API rejects an empty string as a field value,
|
|
56
|
+
* so if `notificationData.phoneSMS === ''` the key is deleted entirely.
|
|
57
|
+
* A missing key is treated by the API as "not provided"; an empty string is not.
|
|
58
|
+
*
|
|
59
|
+
* 2. **formData localization**: the API expects formData as
|
|
60
|
+
* `{ "<langCode>": [...fields] }`, but callers pass a flat array or a single object.
|
|
61
|
+
* The method wraps the data into the required structure.
|
|
62
|
+
* If `formData` is absent from the body — return the body as-is (only phoneSMS cleanup applied).
|
|
63
|
+
* @param {any} body - The body to normalize.
|
|
64
|
+
* @param {string} [langCode] - The language code for normalization.
|
|
65
|
+
* @returns {any} Normalized body.
|
|
66
|
+
*/
|
|
67
|
+
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
68
|
+
/**
|
|
69
|
+
* Clears arrays within the data structure.
|
|
70
|
+
*
|
|
71
|
+
* Traverses the data and fixes a specific edge case with image attributes:
|
|
72
|
+
* when an `image` attribute has a single-element array in `value`,
|
|
73
|
+
* the API returns an array but consumers expect a plain object.
|
|
74
|
+
* In that case `value` is unwrapped: `[img]` → `img`.
|
|
75
|
+
*
|
|
76
|
+
* For all other keys the method recursively copies the structure unchanged.
|
|
77
|
+
* @param {Record<string, any>} data - The data to clear.
|
|
78
|
+
* @returns {any} Cleared data.
|
|
79
|
+
*/
|
|
80
|
+
protected _clearArray(data: Record<string, any>): any;
|
|
81
|
+
/**
|
|
82
|
+
* Sorts attributes by their positions.
|
|
83
|
+
*
|
|
84
|
+
* The API returns attributes as an object `{ marker: AttrObject }`.
|
|
85
|
+
* Each attribute has a `position` field. The method rebuilds the object
|
|
86
|
+
* with keys sorted by ascending `position` so that the display order
|
|
87
|
+
* matches the order defined in the CMS.
|
|
88
|
+
* @param {any} data - The data containing attributes.
|
|
89
|
+
* @returns {any} Sorted attributes.
|
|
90
|
+
*/
|
|
91
|
+
protected _sortAttributes: (data: any) => any;
|
|
92
|
+
/**
|
|
93
|
+
* Adds a specified number of days to a date.
|
|
94
|
+
* @param {Date} date - The initial date.
|
|
95
|
+
* @param {number} days - The number of days to add.
|
|
96
|
+
* @returns {any} The new date with added days.
|
|
97
|
+
*/
|
|
98
|
+
protected _addDays(date: Date, days: number): any;
|
|
99
|
+
/**
|
|
100
|
+
* Common logic for processing schedule dates (weekly, monthly, or both).
|
|
101
|
+
*
|
|
102
|
+
* Abstracts date iteration for three scheduling modes:
|
|
103
|
+
*
|
|
104
|
+
* - **`inEveryWeek` only**: starting from the start date, generates dates
|
|
105
|
+
* with a 7-day step until the end of the current month.
|
|
106
|
+
*
|
|
107
|
+
* - **`inEveryMonth` only**: pins the day-of-month from the start date
|
|
108
|
+
* and repeats it for each of the next 12 months. If the month does not
|
|
109
|
+
* have that day (e.g. Feb 31), the iteration is skipped.
|
|
110
|
+
*
|
|
111
|
+
* - **`inEveryWeek` + `inEveryMonth`**: for each of the next 12 months finds
|
|
112
|
+
* the first occurrence of the target weekday (from the start date), then
|
|
113
|
+
* iterates all occurrences of that weekday in the month with a 7-day step.
|
|
114
|
+
*
|
|
115
|
+
* `processDate(currentDate)` is called for every resolved date.
|
|
116
|
+
* @param {Date} date - The date for which to process intervals.
|
|
117
|
+
* @param {object} config - Configuration for schedule repetition.
|
|
118
|
+
* @param {boolean} config.inEveryWeek - Whether to repeat weekly.
|
|
119
|
+
* @param {boolean} config.inEveryMonth - Whether to repeat monthly.
|
|
120
|
+
* @param {(currentDate: Date) => void} processDate - Callback function to process each date.
|
|
121
|
+
*/
|
|
122
|
+
protected _processScheduleDates(date: Date, config: {
|
|
123
|
+
inEveryWeek: boolean;
|
|
124
|
+
inEveryMonth: boolean;
|
|
125
|
+
}, processDate: (currentDate: Date) => void): void;
|
|
126
|
+
/**
|
|
127
|
+
* Generates intervals for a specific date based on a schedule.
|
|
128
|
+
*
|
|
129
|
+
* For each date resolved by `_processScheduleDates`, iterates over
|
|
130
|
+
* the `schedule.times` array of time ranges. Each range is a pair
|
|
131
|
+
* `[startTime, endTime]` with `{ hours, minutes }` fields.
|
|
132
|
+
* Creates an ISO interval `[start.toISOString(), end.toISOString()]`
|
|
133
|
+
* and adds it to `utcIntervals` (Set deduplicates automatically).
|
|
134
|
+
* @param {Date} date - The date for which to generate intervals.
|
|
135
|
+
* @param {object} schedule - The schedule defining the intervals.
|
|
136
|
+
* @param {boolean} schedule.inEveryWeek - The number of weeks between intervals.
|
|
137
|
+
* @param {any[]} schedule.times - The times for each interval.
|
|
138
|
+
* @param {boolean} schedule.inEveryMonth - The month intervals for each interval.
|
|
139
|
+
* @param {Set<Array<string>>} utcIntervals - A set to store unique intervals.
|
|
140
|
+
*/
|
|
141
|
+
protected _generateIntervalsForDate(date: Date, schedule: {
|
|
142
|
+
inEveryWeek: boolean;
|
|
143
|
+
times: any[];
|
|
144
|
+
inEveryMonth: boolean;
|
|
145
|
+
}, utcIntervals: Set<Array<string>>): void;
|
|
146
|
+
/**
|
|
147
|
+
* Adds time intervals to schedules.
|
|
148
|
+
*
|
|
149
|
+
* Accepts an array of schedule groups (structure of `timeInterval` attributes
|
|
150
|
+
* for pages/products). For each group iterates over `values` — the set of
|
|
151
|
+
* concrete schedules. Each schedule contains a date range `dates[0..1]`.
|
|
152
|
+
*
|
|
153
|
+
* If both boundaries are equal (`isSameDay`), intervals are generated only
|
|
154
|
+
* for that single date. Otherwise — for every day in the range inclusive.
|
|
155
|
+
*
|
|
156
|
+
* The result (`schedule.timeIntervals`) is a sorted array of ISO pairs,
|
|
157
|
+
* ready to pass to UI components.
|
|
158
|
+
* @param {any[]} schedules - The schedules to process.
|
|
159
|
+
* @returns {any} Schedules with added time intervals.
|
|
160
|
+
*/
|
|
161
|
+
_addTimeIntervalsToSchedules(schedules: any[]): any;
|
|
162
|
+
/**
|
|
163
|
+
* Generates intervals for a specific date for form schedules.
|
|
164
|
+
*
|
|
165
|
+
* Unlike `_generateIntervalsForDate`, time ranges here have a different shape:
|
|
166
|
+
* each `timeInterval` contains `start`, `end` and `period`
|
|
167
|
+
* (slot length in minutes). The method slices the [start, end) window into
|
|
168
|
+
* fixed-length slots of `period` minutes:
|
|
169
|
+
*
|
|
170
|
+
* start=09:00, end=12:00, period=30 → [09:00–09:30], [09:30–10:00], …, [11:30–12:00]
|
|
171
|
+
*
|
|
172
|
+
* Generation stops if the next slot would exceed `end`.
|
|
173
|
+
* Each slot is added to `utcIntervals` (Set deduplicates automatically).
|
|
174
|
+
* @param {Date} date - The date for which to generate intervals.
|
|
175
|
+
* @param {object} interval - The interval configuration.
|
|
176
|
+
* @param {boolean} interval.inEveryWeek - Indicates whether the schedule is weekly.
|
|
177
|
+
* @param {boolean} interval.inEveryMonth - Indicates whether the schedule is monthly.
|
|
178
|
+
* @param {any[]} timeIntervals - The time intervals to process.
|
|
179
|
+
* @param {Set<Array<string>>} utcIntervals - A set to store unique intervals.
|
|
180
|
+
*/
|
|
181
|
+
protected _generateIntervalsForFormDate(date: Date, interval: {
|
|
182
|
+
inEveryWeek: boolean;
|
|
183
|
+
inEveryMonth: boolean;
|
|
184
|
+
}, timeIntervals: any[], utcIntervals: Set<Array<string>>): void;
|
|
185
|
+
/**
|
|
186
|
+
* Adds time intervals to form schedules (different structure).
|
|
187
|
+
*
|
|
188
|
+
* Same as `_addTimeIntervalsToSchedules` but for `timeInterval` attributes
|
|
189
|
+
* in **forms** (different API data structure):
|
|
190
|
+
* - `interval.range[0..1]` instead of `schedule.dates[0..1]`
|
|
191
|
+
* - `interval.intervals` — array of time ranges with slots (`period`)
|
|
192
|
+
* instead of `[startTime, endTime]` pairs
|
|
193
|
+
*
|
|
194
|
+
* Result is written to `interval.timeIntervals`.
|
|
195
|
+
* @param {any[]} intervals - The intervals to process.
|
|
196
|
+
* @returns {any} Intervals with added time intervals.
|
|
197
|
+
*/
|
|
198
|
+
_addTimeIntervalsToFormSchedules(intervals: any[]): any;
|
|
199
|
+
/**
|
|
200
|
+
* Transforms additionalFields from array to object keyed by marker.
|
|
201
|
+
*
|
|
202
|
+
* The API returns `additionalFields` as an array: `[{ marker, ... }, ...]`.
|
|
203
|
+
* For convenient key-based access (`attr.additionalFields['fieldName']`)
|
|
204
|
+
* the method converts it to an object `{ marker: { marker, ... } }`.
|
|
205
|
+
* Transformation is skipped when `rawData` mode is enabled in config
|
|
206
|
+
* (the consumer wants the data as-is, without transformations).
|
|
207
|
+
* @param {any} attr - The attribute object that may contain additionalFields.
|
|
208
|
+
*/
|
|
209
|
+
private _normalizeAdditionalFields;
|
|
210
|
+
/**
|
|
211
|
+
* Normalizes attributes within the data.
|
|
212
|
+
*
|
|
213
|
+
* Handles three different attribute formats returned by the API:
|
|
214
|
+
*
|
|
215
|
+
* **1. `attributeValues`** — attributes of pages, products and other entities.
|
|
216
|
+
* Contains an object `{ marker: AttrObject }`. For each attribute:
|
|
217
|
+
* - `_normalizeAdditionalFields` is called;
|
|
218
|
+
* - numeric types (`integer`, `float`) are cast to a JS number (or `null`);
|
|
219
|
+
* - `timeInterval` attributes are enriched with computed `timeIntervals`;
|
|
220
|
+
* - the whole object is re-sorted by `position`.
|
|
221
|
+
*
|
|
222
|
+
* **2. `attributes`** — form attributes (different API structure).
|
|
223
|
+
* Same `additionalFields` and `timeInterval` processing,
|
|
224
|
+
* but numbers are not normalized here (commented out — logic differs).
|
|
225
|
+
*
|
|
226
|
+
* **3. `type`** — a single attribute from an attribute set.
|
|
227
|
+
* Same transformations as in case 1, but without sorting.
|
|
228
|
+
*
|
|
229
|
+
* If none of the keys are found — data is returned unchanged.
|
|
230
|
+
* @param {any} data - The data to normalize.
|
|
231
|
+
* @returns {any} Normalized attributes.
|
|
232
|
+
*/
|
|
233
|
+
protected _normalizeAttr(data: any): any;
|
|
234
|
+
/**
|
|
235
|
+
* Processes data after fetching or receiving it.
|
|
236
|
+
*
|
|
237
|
+
* Final post-processing of the API response: first unwraps localized fields
|
|
238
|
+
* (`_normalizeData`), then fixes single-element image attributes
|
|
239
|
+
* (`_clearArray`). Called at the end of every fetch method.
|
|
240
|
+
* @param {any} data - The data to process.
|
|
241
|
+
* @param {any} [langCode] - The language code for processing.
|
|
242
|
+
* @returns {any} Processed data.
|
|
243
|
+
*/
|
|
244
|
+
protected _dataPostProcess(data: any, langCode?: string): any;
|
|
245
|
+
/**
|
|
246
|
+
* Sets the access token in the state.
|
|
247
|
+
* @param {string} accessToken - The access token to set.
|
|
248
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
249
|
+
*/
|
|
250
|
+
setAccessToken(accessToken: string): any;
|
|
251
|
+
/**
|
|
252
|
+
* Sets the refresh token in the state.
|
|
253
|
+
* @param {string} refreshToken - The refresh token to set.
|
|
254
|
+
* @returns {any} The instance of SyncModules for chaining.
|
|
255
|
+
*/
|
|
256
|
+
setRefreshToken(refreshToken: string): any;
|
|
257
|
+
/**
|
|
258
|
+
* Get deviceMetadata
|
|
259
|
+
*
|
|
260
|
+
* Builds a device metadata object to be sent in request headers.
|
|
261
|
+
* Used for analytics and anti-fraud on the API side.
|
|
262
|
+
*
|
|
263
|
+
* Returned JSON structure:
|
|
264
|
+
* ```json
|
|
265
|
+
* {
|
|
266
|
+
* "fingerprint": "UQ_<hash>_<instanceId>",
|
|
267
|
+
* "deviceInfo": { "os": "...", "browser": "...", "location": "en-US" }
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* **Fingerprint algorithm:**
|
|
272
|
+
* 1. Builds a string from stable characteristics: platform, userAgent, language,
|
|
273
|
+
* screen resolution, colorDepth, timezone, private-browsing mode, instanceId.
|
|
274
|
+
* 2. Runs it through a simple 32-bit hash (djb2-like).
|
|
275
|
+
* 3. Concatenates the hash and the first 12 characters of instanceId.
|
|
276
|
+
*
|
|
277
|
+
* **instanceId strategy:**
|
|
278
|
+
* - Browser: `_getBrowserDeviceId()` — read from localStorage, stable across sessions.
|
|
279
|
+
* - Node.js / no localStorage: `_nodeDeviceId` — generated at instance creation,
|
|
280
|
+
* lives until the process restarts.
|
|
281
|
+
*
|
|
282
|
+
* In a Node.js environment (no `window`) returns a simplified object without screen/navigator.
|
|
283
|
+
* @returns {string} - Returns an object containing device metadata.
|
|
284
|
+
*/
|
|
285
|
+
protected _getDeviceMetadata(): string;
|
|
286
|
+
}
|