oneentry 1.0.101 → 1.0.104
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 +798 -426
- package/configure.js +24 -33
- package/dist/admins/adminsApi.d.ts +11 -7
- package/dist/admins/adminsApi.js +17 -5
- package/dist/admins/adminsInterfaces.d.ts +33 -19
- package/dist/attribute-sets/attributeSetsApi.d.ts +35 -10
- package/dist/attribute-sets/attributeSetsApi.js +49 -7
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +42 -11
- package/dist/auth-provider/authProviderApi.d.ts +17 -5
- package/dist/auth-provider/authProviderApi.js +31 -14
- package/dist/auth-provider/authProvidersInterfaces.d.ts +23 -2
- package/dist/base/asyncModules.d.ts +2 -2
- package/dist/base/asyncModules.js +26 -17
- package/dist/base/result.js +26 -12
- package/dist/base/stateModule.d.ts +1 -1
- package/dist/base/stateModule.js +20 -11
- package/dist/base/syncModules.d.ts +4 -4
- package/dist/base/syncModules.js +16 -12
- package/dist/base/utils.d.ts +2 -2
- package/dist/blocks/blocksApi.d.ts +8 -5
- package/dist/blocks/blocksApi.js +30 -8
- package/dist/blocks/blocksInterfaces.d.ts +38 -5
- package/dist/events/eventsApi.d.ts +7 -7
- package/dist/events/eventsApi.js +14 -9
- package/dist/events/eventsInterfaces.d.ts +5 -2
- package/dist/{file-uploding → file-uploading}/fileUploadingApi.d.ts +3 -3
- package/dist/{file-uploding → file-uploading}/fileUploadingApi.js +9 -5
- package/dist/{file-uploding → file-uploading}/fileUploadingInterfaces.d.ts +8 -5
- package/dist/forms/formsApi.d.ts +4 -4
- package/dist/forms/formsApi.js +4 -1
- package/dist/forms/formsInterfaces.d.ts +2 -3
- package/dist/formsData/formsDataApi.d.ts +5 -5
- package/dist/formsData/formsDataApi.js +10 -4
- package/dist/formsData/formsDataInterfaces.d.ts +2 -2
- package/dist/general-types/{typesApi.d.ts → generalTypesApi.d.ts} +4 -4
- package/dist/general-types/{typesApi.js → generalTypesApi.js} +4 -1
- package/dist/general-types/generalTypesInterfaces.d.ts +2 -2
- package/dist/index.d.ts +33 -21
- package/dist/index.js +37 -26
- package/dist/integration-collections/integrationCollectionsApi.d.ts +128 -0
- package/dist/integration-collections/integrationCollectionsApi.js +161 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +57 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
- package/dist/locales/localesApi.d.ts +4 -4
- package/dist/locales/localesApi.js +4 -1
- package/dist/locales/localesInterfaces.d.ts +2 -2
- package/dist/menus/menusApi.d.ts +4 -4
- package/dist/menus/menusApi.js +4 -1
- package/dist/menus/menusInterfaces.d.ts +6 -4
- package/dist/menus/menusInterfaces.js +1 -0
- package/dist/orders/ordersApi.d.ts +8 -8
- package/dist/orders/ordersApi.js +15 -7
- package/dist/orders/ordersInterfaces.d.ts +13 -3
- package/dist/pages/pagesApi.d.ts +4 -10
- package/dist/pages/pagesApi.js +14 -10
- package/dist/pages/pagesInterfaces.d.ts +13 -22
- package/dist/payments/paymentsApi.d.ts +6 -6
- package/dist/payments/paymentsApi.js +14 -6
- package/dist/payments/paymentsInterfaces.d.ts +20 -5
- package/dist/product-statuses/productStatusesApi.d.ts +3 -3
- package/dist/product-statuses/productStatusesApi.js +4 -1
- package/dist/product-statuses/productStatusesInterfaces.d.ts +2 -5
- package/dist/products/productsApi.d.ts +38 -54
- package/dist/products/productsApi.js +63 -61
- package/dist/products/productsInterfaces.d.ts +52 -40
- package/dist/system/systemApi.d.ts +3 -3
- package/dist/system/systemApi.js +5 -1
- package/dist/system/systemInterfaces.d.ts +1 -1
- package/dist/templates/templatesApi.d.ts +6 -3
- package/dist/templates/templatesApi.js +10 -2
- package/dist/templates/templatesInterfaces.d.ts +2 -2
- package/dist/templates-preview/templatesPreviewApi.d.ts +5 -4
- package/dist/templates-preview/templatesPreviewApi.js +5 -1
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +21 -10
- package/dist/users/usersApi.d.ts +15 -4
- package/dist/users/usersApi.js +29 -2
- package/dist/users/usersInterfaces.d.ts +10 -4
- package/dist/web-socket/wsApi.d.ts +4 -4
- package/dist/web-socket/wsApi.js +15 -14
- package/dist/web-socket/wsInterfaces.d.ts +2 -2
- package/package.json +46 -10
- /package/dist/{file-uploding → file-uploading}/fileUploadingInterfaces.js +0 -0
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const asyncModules_1 = require("../base/asyncModules");
|
|
6
|
+
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
4
7
|
/**
|
|
5
8
|
* Controllers for working with auth services.
|
|
6
9
|
*/
|
|
7
10
|
class AuthProviderApi extends asyncModules_1.default {
|
|
11
|
+
/**
|
|
12
|
+
* '/api/content/users-auth-providers'
|
|
13
|
+
*/
|
|
8
14
|
constructor(state) {
|
|
9
15
|
super(state);
|
|
10
16
|
this._url = state.url + '/api/content/users-auth-providers';
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* User registration
|
|
20
|
+
*
|
|
14
21
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
15
22
|
* @param data - Request body
|
|
16
23
|
* @param {string} langCode - Optional language field
|
|
@@ -50,47 +57,53 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
50
57
|
}
|
|
51
58
|
/**
|
|
52
59
|
* Getting a user activation code. The code is returned via the appropriate user notification method
|
|
60
|
+
*
|
|
53
61
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
54
62
|
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
55
63
|
* @param {string} eventIdentifier - Text identifier of the event object for which the code is generated
|
|
56
64
|
*/
|
|
57
65
|
async generateCode(marker, userIdentifier, eventIdentifier) {
|
|
58
66
|
const data = {
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
userIdentifier: userIdentifier,
|
|
68
|
+
eventIdentifier: eventIdentifier,
|
|
61
69
|
};
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
71
|
const result = await this._fetchPost(`/marker/${marker}/users/generate-code`, data);
|
|
72
|
+
return result;
|
|
63
73
|
}
|
|
64
74
|
/**
|
|
65
75
|
* User activation code verification. Returns true (if the code is correct) or false (if it is incorrect).
|
|
76
|
+
*
|
|
66
77
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
67
78
|
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
68
79
|
* @param {string} code - Service code
|
|
69
80
|
*/
|
|
70
81
|
async checkCode(marker, userIdentifier, code) {
|
|
71
82
|
const data = {
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
userIdentifier: userIdentifier,
|
|
84
|
+
code: code,
|
|
74
85
|
};
|
|
75
86
|
const result = await this._fetchPost(`/marker/${marker}/users/check-code`, data);
|
|
76
87
|
return result;
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
79
90
|
* User activate.
|
|
91
|
+
*
|
|
80
92
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
81
93
|
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
82
94
|
* @param {string} code - Service code
|
|
83
95
|
*/
|
|
84
96
|
async activateUser(marker, userIdentifier, code) {
|
|
85
97
|
const data = {
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
userIdentifier: userIdentifier,
|
|
99
|
+
code: code,
|
|
88
100
|
};
|
|
89
101
|
const result = await this._fetchPost(`/marker/${marker}/users/activate`, data);
|
|
90
102
|
return result;
|
|
91
103
|
}
|
|
92
104
|
/**
|
|
93
105
|
* User authorization
|
|
106
|
+
*
|
|
94
107
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
95
108
|
* @param {IAuthPostBody} data - Array of objects contains auth information
|
|
96
109
|
*
|
|
@@ -120,6 +133,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
120
133
|
}
|
|
121
134
|
/**
|
|
122
135
|
* Refresh token
|
|
136
|
+
*
|
|
123
137
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
124
138
|
* @param {string} token - Refresh token
|
|
125
139
|
*
|
|
@@ -135,8 +149,8 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
135
149
|
return result;
|
|
136
150
|
}
|
|
137
151
|
/**
|
|
138
|
-
*
|
|
139
152
|
* User logout.
|
|
153
|
+
*
|
|
140
154
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
141
155
|
* @param {string} token - Refresh token
|
|
142
156
|
*
|
|
@@ -144,7 +158,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
144
158
|
*/
|
|
145
159
|
async logout(marker, token) {
|
|
146
160
|
const data = {
|
|
147
|
-
|
|
161
|
+
refreshToken: token,
|
|
148
162
|
};
|
|
149
163
|
const result = await this._fetchPost(`/marker/${marker}/users/logout`, data);
|
|
150
164
|
if (result) {
|
|
@@ -158,6 +172,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
158
172
|
}
|
|
159
173
|
/**
|
|
160
174
|
* Change password
|
|
175
|
+
*
|
|
161
176
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
162
177
|
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
163
178
|
* @param {string} code - Service code
|
|
@@ -167,17 +182,18 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
167
182
|
*/
|
|
168
183
|
async changePassword(marker, userIdentifier, type, code, newPassword, repeatPassword) {
|
|
169
184
|
const data = {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
185
|
+
userIdentifier: userIdentifier,
|
|
186
|
+
code: code,
|
|
187
|
+
type: type,
|
|
188
|
+
password1: newPassword,
|
|
189
|
+
password2: repeatPassword !== null && repeatPassword !== void 0 ? repeatPassword : newPassword,
|
|
175
190
|
};
|
|
176
191
|
const result = await this._fetchPost(`/marker/${marker}/users/change-password`, data);
|
|
177
192
|
return result;
|
|
178
193
|
}
|
|
179
194
|
/**
|
|
180
195
|
* Get all auth providers objects
|
|
196
|
+
*
|
|
181
197
|
* @param {string} [langCode] - Language code. Default "en_US"
|
|
182
198
|
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
183
199
|
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
@@ -188,6 +204,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
188
204
|
}
|
|
189
205
|
/**
|
|
190
206
|
* Get one auth provider object by marker
|
|
207
|
+
*
|
|
191
208
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
192
209
|
* @param {string} [langCode] - Optional parameter language code. Default "en_US"
|
|
193
210
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IError, ILocalizeInfo } from
|
|
1
|
+
import type { IError, ILocalizeInfo } from '../base/utils';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a interface object of User Auth Provider Api.
|
|
4
4
|
*
|
|
@@ -25,11 +25,17 @@ interface IAuthProvider {
|
|
|
25
25
|
getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<Array<IAuthProvidersEntity> | IError>;
|
|
26
26
|
getMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity | IError>;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* IAuthFormData
|
|
30
|
+
*/
|
|
28
31
|
interface IAuthFormData {
|
|
29
32
|
marker: string;
|
|
30
33
|
type: string;
|
|
31
34
|
value: string;
|
|
32
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* ISignUpData
|
|
38
|
+
*/
|
|
33
39
|
interface ISignUpData {
|
|
34
40
|
formIdentifier: string;
|
|
35
41
|
langCode?: string;
|
|
@@ -44,6 +50,9 @@ interface ISignUpData {
|
|
|
44
50
|
phoneSMS: string;
|
|
45
51
|
};
|
|
46
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* ISignUpEntity
|
|
55
|
+
*/
|
|
47
56
|
interface ISignUpEntity {
|
|
48
57
|
id: number;
|
|
49
58
|
updatedDate: string;
|
|
@@ -61,16 +70,25 @@ interface ISignUpEntity {
|
|
|
61
70
|
};
|
|
62
71
|
locale: string;
|
|
63
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* ICodeEntity
|
|
75
|
+
*/
|
|
64
76
|
interface ICodeEntity {
|
|
65
77
|
code: string;
|
|
66
78
|
expiredDate: string;
|
|
67
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* IAuthEntity
|
|
82
|
+
*/
|
|
68
83
|
interface IAuthEntity {
|
|
69
84
|
userIdentifier: string;
|
|
70
85
|
authProviderIdentifier: string;
|
|
71
86
|
accessToken: string;
|
|
72
87
|
refreshToken: string;
|
|
73
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* IAuthProvidersEntity
|
|
91
|
+
*/
|
|
74
92
|
interface IAuthProvidersEntity {
|
|
75
93
|
id: number;
|
|
76
94
|
localizeInfos: ILocalizeInfo;
|
|
@@ -82,10 +100,13 @@ interface IAuthProvidersEntity {
|
|
|
82
100
|
formIdentifier: string | null;
|
|
83
101
|
config: Record<string, any>;
|
|
84
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* IAuthPostBody
|
|
105
|
+
*/
|
|
85
106
|
interface IAuthPostBody {
|
|
86
107
|
authData: Array<{
|
|
87
108
|
marker: string;
|
|
88
109
|
value: string | number;
|
|
89
110
|
}>;
|
|
90
111
|
}
|
|
91
|
-
export {
|
|
112
|
+
export type { IAuthEntity, IAuthFormData, IAuthPostBody, IAuthProvider, IAuthProvidersEntity, ICodeEntity, ISignUpData, ISignUpEntity, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type StateModule from './stateModule';
|
|
2
|
+
import SyncModules from './syncModules';
|
|
3
3
|
export default abstract class AsyncModules extends SyncModules {
|
|
4
4
|
protected state: StateModule;
|
|
5
5
|
protected _NO_FETCH: boolean;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const syncModules_1 = require("./syncModules");
|
|
6
|
+
const syncModules_1 = __importDefault(require("./syncModules"));
|
|
7
|
+
// import { IError } from './utils';
|
|
4
8
|
class AsyncModules extends syncModules_1.default {
|
|
5
9
|
constructor(state) {
|
|
6
10
|
var _a;
|
|
7
11
|
super(state);
|
|
8
|
-
this._url = this.state.url;
|
|
9
12
|
this.state = state;
|
|
13
|
+
this._url = this.state.url;
|
|
10
14
|
this._NO_FETCH = state._NO_FETCH;
|
|
11
15
|
this._https = (_a = state._https) !== null && _a !== void 0 ? _a : null;
|
|
12
16
|
}
|
|
@@ -47,6 +51,7 @@ class AsyncModules extends syncModules_1.default {
|
|
|
47
51
|
res.on('end', () => {
|
|
48
52
|
try {
|
|
49
53
|
resolve(JSON.parse(responseData));
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
50
55
|
}
|
|
51
56
|
catch (error) {
|
|
52
57
|
resolve(responseData);
|
|
@@ -85,6 +90,7 @@ class AsyncModules extends syncModules_1.default {
|
|
|
85
90
|
});
|
|
86
91
|
}
|
|
87
92
|
}
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
88
94
|
async _fetchDelete(path, data) {
|
|
89
95
|
const options = this.makeOptions('DELETE');
|
|
90
96
|
if (!this._NO_FETCH) {
|
|
@@ -108,13 +114,14 @@ class AsyncModules extends syncModules_1.default {
|
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
async refreshToken() {
|
|
111
|
-
const response = await fetch(this.state.url +
|
|
117
|
+
const response = await fetch(this.state.url +
|
|
118
|
+
`/api/content/users-auth-providers/marker/email/users/refresh`, {
|
|
112
119
|
method: 'POST',
|
|
113
120
|
headers: {
|
|
114
121
|
'Content-Type': 'application/json',
|
|
115
|
-
'x-app-token': this.state.token
|
|
122
|
+
'x-app-token': this.state.token,
|
|
116
123
|
},
|
|
117
|
-
body: JSON.stringify({ refreshToken: this.state.refreshToken })
|
|
124
|
+
body: JSON.stringify({ refreshToken: this.state.refreshToken }),
|
|
118
125
|
});
|
|
119
126
|
if (response.ok) {
|
|
120
127
|
const result = await response.json();
|
|
@@ -135,7 +142,7 @@ class AsyncModules extends syncModules_1.default {
|
|
|
135
142
|
headers: {
|
|
136
143
|
'Content-Type': 'application/json',
|
|
137
144
|
'x-app-token': this.state.token,
|
|
138
|
-
}
|
|
145
|
+
},
|
|
139
146
|
};
|
|
140
147
|
if (data instanceof FormData || data instanceof Blob) {
|
|
141
148
|
delete options.headers['Content-Type'];
|
|
@@ -154,6 +161,7 @@ class AsyncModules extends syncModules_1.default {
|
|
|
154
161
|
if (response.ok) {
|
|
155
162
|
try {
|
|
156
163
|
return await response.json();
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
157
165
|
}
|
|
158
166
|
catch (e) {
|
|
159
167
|
return;
|
|
@@ -163,7 +171,8 @@ class AsyncModules extends syncModules_1.default {
|
|
|
163
171
|
if (response.status == 401 && !this.state.customAuth) {
|
|
164
172
|
const refresh = await this.refreshToken();
|
|
165
173
|
if (refresh) {
|
|
166
|
-
options.headers['Authorization'] =
|
|
174
|
+
options.headers['Authorization'] =
|
|
175
|
+
'Bearer ' + this.state.accessToken;
|
|
167
176
|
const secondResponse = await fetch(this._getFullPath(path), options);
|
|
168
177
|
return await secondResponse.json();
|
|
169
178
|
}
|
|
@@ -171,28 +180,28 @@ class AsyncModules extends syncModules_1.default {
|
|
|
171
180
|
const status = response.status;
|
|
172
181
|
const res = await response.json();
|
|
173
182
|
if (status == 400) {
|
|
174
|
-
if (this.state.errorsFunctions && this.state.errorsFunctions[
|
|
175
|
-
this.state.errorsFunctions[
|
|
183
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions['400']) {
|
|
184
|
+
this.state.errorsFunctions['400'](res);
|
|
176
185
|
}
|
|
177
186
|
}
|
|
178
187
|
else if (status == 401) {
|
|
179
|
-
if (this.state.errorsFunctions && this.state.errorsFunctions[
|
|
180
|
-
this.state.errorsFunctions[
|
|
188
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions['401']) {
|
|
189
|
+
this.state.errorsFunctions['401'](res);
|
|
181
190
|
}
|
|
182
191
|
}
|
|
183
192
|
else if (status == 403) {
|
|
184
|
-
if (this.state.errorsFunctions && this.state.errorsFunctions[
|
|
185
|
-
this.state.errorsFunctions[
|
|
193
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions['403']) {
|
|
194
|
+
this.state.errorsFunctions['403'](res);
|
|
186
195
|
}
|
|
187
196
|
}
|
|
188
197
|
else if (status == 404) {
|
|
189
|
-
if (this.state.errorsFunctions && this.state.errorsFunctions[
|
|
190
|
-
this.state.errorsFunctions[
|
|
198
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions['404']) {
|
|
199
|
+
this.state.errorsFunctions['404'](res);
|
|
191
200
|
}
|
|
192
201
|
}
|
|
193
202
|
else if (status == 500) {
|
|
194
|
-
if (this.state.errorsFunctions && this.state.errorsFunctions[
|
|
195
|
-
this.state.errorsFunctions[
|
|
203
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions['500']) {
|
|
204
|
+
this.state.errorsFunctions['500'](res);
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
207
|
if (this.state.isShell) {
|
package/dist/base/result.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable no-restricted-syntax */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
5
|
class Result {
|
|
4
6
|
constructor(data) {
|
|
5
7
|
this.body = data;
|
|
@@ -9,7 +11,10 @@ class Result {
|
|
|
9
11
|
return this;
|
|
10
12
|
}
|
|
11
13
|
async json() {
|
|
12
|
-
this.body =
|
|
14
|
+
this.body =
|
|
15
|
+
(await typeof this.body) === 'string'
|
|
16
|
+
? JSON.parse(this.body)
|
|
17
|
+
: this.body.json();
|
|
13
18
|
return this;
|
|
14
19
|
}
|
|
15
20
|
makeDataWithoutLang(langCode, data) {
|
|
@@ -18,8 +23,10 @@ class Result {
|
|
|
18
23
|
return data.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
19
24
|
}
|
|
20
25
|
else {
|
|
21
|
-
for (
|
|
22
|
-
if (typeof data[key] === 'object' &&
|
|
26
|
+
for (const key in data) {
|
|
27
|
+
if (typeof data[key] === 'object' &&
|
|
28
|
+
data[key] &&
|
|
29
|
+
langCode in data[key]) {
|
|
23
30
|
data[key] = data[key][langCode];
|
|
24
31
|
}
|
|
25
32
|
else if (typeof data[key] === 'object' && data[key] != null) {
|
|
@@ -37,11 +44,14 @@ class Result {
|
|
|
37
44
|
this.body = this.body.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
38
45
|
}
|
|
39
46
|
else {
|
|
40
|
-
for (
|
|
41
|
-
if (typeof this.body[key] === 'object' &&
|
|
47
|
+
for (const key in this.body) {
|
|
48
|
+
if (typeof this.body[key] === 'object' &&
|
|
49
|
+
this.body[key] &&
|
|
50
|
+
langCode in this.body[key]) {
|
|
42
51
|
this.body[key] = this.body[key][langCode];
|
|
43
52
|
}
|
|
44
|
-
else if (typeof this.body[key] === 'object' &&
|
|
53
|
+
else if (typeof this.body[key] === 'object' &&
|
|
54
|
+
this.body[key] != null) {
|
|
45
55
|
this.body[key] = this.makeDataWithoutLang(langCode, this.body[key]);
|
|
46
56
|
}
|
|
47
57
|
else if (Array.isArray(this.body[key])) {
|
|
@@ -55,14 +65,16 @@ class Result {
|
|
|
55
65
|
makeDataWithoutArray(data) {
|
|
56
66
|
if (data) {
|
|
57
67
|
if (Array.isArray(data)) {
|
|
58
|
-
return data.map(item => this.makeDataWithoutArray(item));
|
|
68
|
+
return data.map((item) => this.makeDataWithoutArray(item));
|
|
59
69
|
}
|
|
60
70
|
else {
|
|
61
|
-
for (
|
|
71
|
+
for (const key in data) {
|
|
62
72
|
if (Array.isArray(data[key]) && data[key].length === 1) {
|
|
63
73
|
data[key] = data[key][0];
|
|
64
74
|
}
|
|
65
|
-
else if (typeof data[key] === 'object' &&
|
|
75
|
+
else if (typeof data[key] === 'object' &&
|
|
76
|
+
data[key] &&
|
|
77
|
+
!Array.isArray(data[key])) {
|
|
66
78
|
data[key] = this.makeDataWithoutArray(data[key]);
|
|
67
79
|
}
|
|
68
80
|
}
|
|
@@ -71,14 +83,16 @@ class Result {
|
|
|
71
83
|
}
|
|
72
84
|
else {
|
|
73
85
|
if (Array.isArray(this.body)) {
|
|
74
|
-
return this.body.map(item => this.makeDataWithoutArray(item));
|
|
86
|
+
return this.body.map((item) => this.makeDataWithoutArray(item));
|
|
75
87
|
}
|
|
76
88
|
else {
|
|
77
|
-
for (
|
|
89
|
+
for (const key in this.body) {
|
|
78
90
|
if (Array.isArray(this.body[key]) && this.body[key].length === 1) {
|
|
79
91
|
this.body[key] = this.body[key][0];
|
|
80
92
|
}
|
|
81
|
-
else if (typeof this.body[key] === 'object' &&
|
|
93
|
+
else if (typeof this.body[key] === 'object' &&
|
|
94
|
+
this.body[key] &&
|
|
95
|
+
!Array.isArray(this.body[key])) {
|
|
82
96
|
this.body[key] = this.makeDataWithoutArray(this.body[key]);
|
|
83
97
|
}
|
|
84
98
|
}
|
package/dist/base/stateModule.js
CHANGED
|
@@ -10,31 +10,39 @@ class StateModule {
|
|
|
10
10
|
this.refreshToken = (_d = (_c = config.auth) === null || _c === void 0 ? void 0 : _c.refreshToken) !== null && _d !== void 0 ? _d : undefined;
|
|
11
11
|
this.customAuth = (_f = (_e = config.auth) === null || _e === void 0 ? void 0 : _e.customAuth) !== null && _f !== void 0 ? _f : false;
|
|
12
12
|
this.errorsFunctions = {
|
|
13
|
-
'400':
|
|
14
|
-
'401':
|
|
15
|
-
'403':
|
|
16
|
-
'404':
|
|
17
|
-
'500':
|
|
13
|
+
'400': undefined,
|
|
14
|
+
'401': undefined,
|
|
15
|
+
'403': undefined,
|
|
16
|
+
'404': undefined,
|
|
17
|
+
'500': undefined,
|
|
18
18
|
};
|
|
19
19
|
this.saveFunction = (_h = (_g = config.auth) === null || _g === void 0 ? void 0 : _g.saveFunction) !== null && _h !== void 0 ? _h : null;
|
|
20
20
|
if (config.errors) {
|
|
21
21
|
this.isShell = (_j = config.errors.isShell) !== null && _j !== void 0 ? _j : true;
|
|
22
22
|
if (config.errors.customErrors) {
|
|
23
|
-
this.errorsFunctions[
|
|
24
|
-
|
|
25
|
-
this.errorsFunctions[
|
|
26
|
-
|
|
27
|
-
this.errorsFunctions[
|
|
23
|
+
this.errorsFunctions['400'] =
|
|
24
|
+
(_k = config.errors.customErrors['400']) !== null && _k !== void 0 ? _k : undefined;
|
|
25
|
+
this.errorsFunctions['401'] =
|
|
26
|
+
(_l = config.errors.customErrors['401']) !== null && _l !== void 0 ? _l : undefined;
|
|
27
|
+
this.errorsFunctions['403'] =
|
|
28
|
+
(_m = config.errors.customErrors['403']) !== null && _m !== void 0 ? _m : undefined;
|
|
29
|
+
this.errorsFunctions['404'] =
|
|
30
|
+
(_o = config.errors.customErrors['404']) !== null && _o !== void 0 ? _o : undefined;
|
|
31
|
+
this.errorsFunctions['500'] =
|
|
32
|
+
(_p = config.errors.customErrors['400']) !== null && _p !== void 0 ? _p : undefined;
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
else {
|
|
31
36
|
this.isShell = false;
|
|
32
37
|
}
|
|
33
38
|
try {
|
|
34
|
-
if (typeof process === 'object' &&
|
|
39
|
+
if (typeof process === 'object' &&
|
|
40
|
+
+process.versions.node.split('.')[0] < 18) {
|
|
35
41
|
try {
|
|
36
42
|
this._NO_FETCH = true;
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
37
44
|
this._https = require('https'); //file extension
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
46
|
}
|
|
39
47
|
catch (e) {
|
|
40
48
|
this._https = null;
|
|
@@ -44,6 +52,7 @@ class StateModule {
|
|
|
44
52
|
this._NO_FETCH = false;
|
|
45
53
|
this._https = null;
|
|
46
54
|
}
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
56
|
}
|
|
48
57
|
catch (e) {
|
|
49
58
|
this._NO_FETCH = false;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import StateModule from
|
|
1
|
+
import type { IUploadingQuery } from '../file-uploading/fileUploadingInterfaces';
|
|
2
|
+
import type { IProductsQuery } from '../products/productsInterfaces';
|
|
3
|
+
import type StateModule from './stateModule';
|
|
4
4
|
export default abstract class SyncModules {
|
|
5
5
|
protected state: StateModule;
|
|
6
6
|
protected _url: string;
|
|
7
7
|
protected constructor(state: StateModule);
|
|
8
8
|
protected _getFullPath(path: string): string;
|
|
9
|
-
protected _queryParamsToString(query: IProductsQuery | IUploadingQuery): string;
|
|
9
|
+
protected _queryParamsToString(query: IProductsQuery | IUploadingQuery | any): string;
|
|
10
10
|
protected _normalizeData(data: any, langCode?: string): any;
|
|
11
11
|
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
12
12
|
protected _clearArray(data: Record<string, any>): any;
|
package/dist/base/syncModules.js
CHANGED
|
@@ -6,24 +6,24 @@ class SyncModules {
|
|
|
6
6
|
this._url = state.url;
|
|
7
7
|
}
|
|
8
8
|
_getFullPath(path) {
|
|
9
|
-
return
|
|
9
|
+
return this._url + path;
|
|
10
10
|
}
|
|
11
11
|
_queryParamsToString(query) {
|
|
12
12
|
let result = '';
|
|
13
|
-
for (
|
|
13
|
+
for (const key in query) {
|
|
14
14
|
if (query[key] !== null) {
|
|
15
15
|
result += `${key}=${query[key]}&`;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
return result.slice(0,
|
|
18
|
+
return result.slice(0, result.length - 1);
|
|
19
19
|
}
|
|
20
20
|
_normalizeData(data, langCode = this.state.lang) {
|
|
21
21
|
if (Array.isArray(data)) {
|
|
22
|
-
return this._normalizeAttr(data.map(item => this._normalizeData(item, langCode)));
|
|
22
|
+
return this._normalizeAttr(data.map((item) => this._normalizeData(item, langCode)));
|
|
23
23
|
}
|
|
24
24
|
else if (typeof data === 'object' && data) {
|
|
25
25
|
const normalizeData = {};
|
|
26
|
-
for (
|
|
26
|
+
for (const key in data) {
|
|
27
27
|
if (Array.isArray(data[key])) {
|
|
28
28
|
normalizeData[key] = this._normalizeData(data[key], langCode);
|
|
29
29
|
}
|
|
@@ -45,17 +45,19 @@ class SyncModules {
|
|
|
45
45
|
}
|
|
46
46
|
_normalizePostBody(body, langCode = this.state.lang) {
|
|
47
47
|
const formData = {};
|
|
48
|
-
formData[langCode] = Array.isArray(body.formData)
|
|
48
|
+
formData[langCode] = Array.isArray(body.formData)
|
|
49
|
+
? body.formData
|
|
50
|
+
: [body.formData];
|
|
49
51
|
body.formData = formData;
|
|
50
52
|
return body;
|
|
51
53
|
}
|
|
52
54
|
_clearArray(data) {
|
|
53
55
|
if (Array.isArray(data)) {
|
|
54
|
-
return data.map(item => this._clearArray(item));
|
|
56
|
+
return data.map((item) => this._clearArray(item));
|
|
55
57
|
}
|
|
56
58
|
else if (typeof data === 'object' && data) {
|
|
57
59
|
const normalizeData = {};
|
|
58
|
-
for (
|
|
60
|
+
for (const key in data) {
|
|
59
61
|
if (Array.isArray(data[key])) {
|
|
60
62
|
normalizeData[key] = this._clearArray(data[key]);
|
|
61
63
|
}
|
|
@@ -64,8 +66,9 @@ class SyncModules {
|
|
|
64
66
|
}
|
|
65
67
|
else if (key === 'attributeValues') {
|
|
66
68
|
const attrs = data[key];
|
|
67
|
-
for (
|
|
68
|
-
if (attrs[attr].type === 'image' &&
|
|
69
|
+
for (const attr in attrs) {
|
|
70
|
+
if (attrs[attr].type === 'image' &&
|
|
71
|
+
attrs[attr].value.length === 1) {
|
|
69
72
|
attrs[attr].value = attrs[attr].value[0];
|
|
70
73
|
}
|
|
71
74
|
}
|
|
@@ -83,8 +86,9 @@ class SyncModules {
|
|
|
83
86
|
}
|
|
84
87
|
_normalizeAttr(data) {
|
|
85
88
|
if ('attributeValues' in data) {
|
|
86
|
-
for (
|
|
87
|
-
if (data.attributeValues[attr].type === 'integer' ||
|
|
89
|
+
for (const attr in data.attributeValues) {
|
|
90
|
+
if (data.attributeValues[attr].type === 'integer' ||
|
|
91
|
+
data.attributeValues[attr].type === 'float') {
|
|
88
92
|
data.attributeValues[attr].value = Number(data.attributeValues[attr].value);
|
|
89
93
|
}
|
|
90
94
|
}
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Types = 'forCatalogProducts' | 'forBasketPage' | 'forErrorPage' | 'forCatalogPages' | 'forProductPreview' | 'forProductPage' | 'forSimilarProductBlock' | 'forStatisticProductBlock' | 'forProductBlock' | 'forForm' | 'forFormField' | 'forNewsPage' | 'forNewsBlock' | 'forNewsPreview' | 'forOneNewsPage' | 'forUsualPage' | 'forTextBlock' | 'forSlider' | 'forOrder' | 'service' | 'none';
|
|
1
|
+
type Types = 'forCatalogProducts' | 'forBasketPage' | 'forErrorPage' | 'forCatalogPages' | 'forProductPreview' | 'forProductPage' | 'forSimilarProductBlock' | 'forStatisticProductBlock' | 'forProductBlock' | 'forForm' | 'forFormField' | 'forNewsPage' | 'forNewsBlock' | 'forNewsPreview' | 'forOneNewsPage' | 'forUsualPage' | 'forTextBlock' | 'forSlider' | 'forSliderBlock' | 'forOrder' | 'service' | 'none';
|
|
2
2
|
/**
|
|
3
3
|
* @param {string} [token] - If your project is protected by a token, specify this token in this parameter.
|
|
4
4
|
* @param {string} [langCode] - specify the default language to avoid specifying it in every request.
|
|
@@ -92,4 +92,4 @@ interface IError {
|
|
|
92
92
|
timestamp: string;
|
|
93
93
|
[key: string]: any;
|
|
94
94
|
}
|
|
95
|
-
export {
|
|
95
|
+
export type { AttributeType, IAttributes, IAttributeValues, IConfig, IError, ILocalizeInfo, ILocalizeInfos, LangType, LocalizeType, Types, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import AsyncModules from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import AsyncModules from '../base/asyncModules';
|
|
2
|
+
import type StateModule from '../base/stateModule';
|
|
3
|
+
import type { IError } from '../base/utils';
|
|
4
|
+
import type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock } from './blocksInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with blocks
|
|
7
7
|
*/
|
|
@@ -39,7 +39,7 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
|
39
39
|
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
40
40
|
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
41
41
|
*
|
|
42
|
-
* @returns Return array of BlocksEntity object.
|
|
42
|
+
* @returns Return IProductsResponse with total and items array of BlocksEntity object.
|
|
43
43
|
*/
|
|
44
44
|
private getSimilarProducts;
|
|
45
45
|
/**
|
|
@@ -55,8 +55,11 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
|
55
55
|
private getProductsByBlockMarker;
|
|
56
56
|
/**
|
|
57
57
|
* Quick search for block objects with limited output
|
|
58
|
+
*
|
|
58
59
|
* @param name - Search string
|
|
59
60
|
* @param [langCode] - Language code. Default "en_US"
|
|
61
|
+
*
|
|
62
|
+
* @returns Return array of BlocksEntity object.
|
|
60
63
|
*/
|
|
61
64
|
searchBlock(name: string, langCode?: string): Promise<Array<ISearchBlock> | IError>;
|
|
62
65
|
}
|