oneentry 1.0.65 → 1.0.67

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.
Files changed (59) hide show
  1. package/README.md +304 -243
  2. package/dist/_cjs/admins/adminsApi.d.ts +1 -1
  3. package/dist/admins/adminsApi.d.ts +6 -4
  4. package/dist/admins/adminsApi.js +6 -6
  5. package/dist/attribute-sets/attributeSetsApi.d.ts +6 -4
  6. package/dist/attribute-sets/attributeSetsApi.js +7 -7
  7. package/dist/auth-provider/authProviderApi.d.ts +6 -4
  8. package/dist/auth-provider/authProviderApi.js +14 -10
  9. package/dist/auth-provider/authProvidersInterfaces.d.ts +2 -2
  10. package/dist/base/asyncModules.d.ts +16 -0
  11. package/dist/base/asyncModules.js +164 -0
  12. package/dist/base/modules.d.ts +14 -0
  13. package/dist/base/modules.js +173 -0
  14. package/dist/base/oneEntry.d.ts +0 -23
  15. package/dist/base/oneEntry.js +74 -236
  16. package/dist/base/stateModule.d.ts +10 -0
  17. package/dist/base/stateModule.js +13 -0
  18. package/dist/base/syncModules.d.ts +14 -0
  19. package/dist/base/syncModules.js +72 -0
  20. package/dist/blocks/blocksApi.d.ts +9 -6
  21. package/dist/blocks/blocksApi.js +17 -16
  22. package/dist/blocks/blocksInterfaces.d.ts +3 -2
  23. package/dist/events/eventsApi.d.ts +6 -4
  24. package/dist/events/eventsApi.js +5 -5
  25. package/dist/file-uploding/fileUploadingApi.d.ts +6 -4
  26. package/dist/file-uploding/fileUploadingApi.js +6 -6
  27. package/dist/forms/formsApi.d.ts +7 -5
  28. package/dist/forms/formsApi.js +8 -8
  29. package/dist/formsData/formsDataApi.d.ts +8 -6
  30. package/dist/formsData/formsDataApi.js +10 -10
  31. package/dist/general-types/typesApi.d.ts +6 -4
  32. package/dist/general-types/typesApi.js +5 -5
  33. package/dist/index.js +22 -20
  34. package/dist/locales/localesApi.d.ts +6 -4
  35. package/dist/locales/localesApi.js +5 -5
  36. package/dist/menus/menusApi.d.ts +7 -5
  37. package/dist/menus/menusApi.js +7 -7
  38. package/dist/orders/ordersApi.d.ts +6 -4
  39. package/dist/orders/ordersApi.js +10 -10
  40. package/dist/pages/pagesApi.d.ts +6 -4
  41. package/dist/pages/pagesApi.js +16 -19
  42. package/dist/payments/paymentsApi.d.ts +6 -10
  43. package/dist/payments/paymentsApi.js +5 -14
  44. package/dist/payments/paymentsInterfaces.d.ts +0 -2
  45. package/dist/product-statuses/productStatusesApi.d.ts +6 -4
  46. package/dist/product-statuses/productStatusesApi.js +8 -8
  47. package/dist/products/productsApi.d.ts +107 -52
  48. package/dist/products/productsApi.js +119 -65
  49. package/dist/products/productsInterfaces.d.ts +16 -8
  50. package/dist/system/systemApi.d.ts +6 -4
  51. package/dist/system/systemApi.js +5 -5
  52. package/dist/templates/templatesApi.d.ts +9 -6
  53. package/dist/templates/templatesApi.js +9 -9
  54. package/dist/templates/templatesInterfaces.d.ts +2 -1
  55. package/dist/templates-preview/templatesPreviewApi.d.ts +8 -6
  56. package/dist/templates-preview/templatesPreviewApi.js +10 -10
  57. package/dist/users/usersApi.d.ts +6 -4
  58. package/dist/users/usersApi.js +7 -7
  59. package/package.json +1 -1
@@ -1,236 +1,74 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class OneEntry {
4
- constructor(url, config = {}) {
5
- var _a;
6
- this._url = url;
7
- this._token = config.token;
8
- this._userToken = config.userToken;
9
- this._defaultLangCode = config.langCode ? config.langCode : 'en_US';
10
- this._multipleResponse = (_a = config.multipleRequests) !== null && _a !== void 0 ? _a : true;
11
- this._NO_FETCH = !!(typeof process === 'object' && process.versions);
12
- try {
13
- this._https = this._NO_FETCH ? require('https') : null;
14
- }
15
- catch (e) {
16
- this._https = null;
17
- }
18
- }
19
- _getFullPath(path) {
20
- return (this._url + path);
21
- }
22
- async _fetchGet(path) {
23
- const options = {
24
- method: 'GET',
25
- headers: {
26
- 'Content-Type': 'application/json',
27
- 'x-app-token': this._token,
28
- 'Authorization': this._userToken
29
- }
30
- };
31
- if (!this._NO_FETCH) {
32
- const response = await fetch(this._getFullPath(path), options);
33
- if (!response.ok) {
34
- const error = await response.json();
35
- throw error;
36
- }
37
- return await response.json();
38
- }
39
- else {
40
- return new Promise((resolve, reject) => {
41
- const req = this._https.get(this._getFullPath(path), options, (res) => {
42
- let data = '';
43
- res.on('data', (chunk) => {
44
- data += chunk;
45
- });
46
- res.on('end', () => {
47
- resolve(JSON.parse(data));
48
- });
49
- });
50
- req.on('error', (error) => {
51
- reject(error);
52
- });
53
- });
54
- }
55
- }
56
- async _fetchPost(path, data) {
57
- const options = {
58
- method: 'POST',
59
- headers: {
60
- 'x-app-token': this._token,
61
- 'Content-Type': 'application/json',
62
- 'Authorization': this._userToken ? 'Bearer ' + this._userToken : null
63
- }
64
- };
65
- if (data instanceof FormData || data instanceof Blob) {
66
- delete options.headers['Content-Type'];
67
- }
68
- if (!this._NO_FETCH) {
69
- const response = await fetch(this._getFullPath(path), {
70
- ...options,
71
- body: JSON.stringify(data)
72
- });
73
- if (!response.ok) {
74
- const error = await response.json();
75
- throw error;
76
- }
77
- return await response.json();
78
- }
79
- else {
80
- return new Promise((resolve, reject) => {
81
- const req = this._https.request(this._getFullPath(path), options, (res) => {
82
- let responseData = '';
83
- res.on('data', (chunk) => {
84
- responseData += chunk;
85
- });
86
- res.on('end', () => {
87
- resolve(JSON.parse(responseData));
88
- });
89
- });
90
- req.on('error', (error) => {
91
- reject(error);
92
- });
93
- req.write(JSON.stringify(data));
94
- req.end();
95
- });
96
- }
97
- }
98
- async _fetchPut(path, data) {
99
- const options = {
100
- method: 'PUT',
101
- headers: {
102
- 'x-app-token': this._token,
103
- 'Content-Type': 'application/json',
104
- 'Authorization': this._userToken ? 'Bearer ' + this._userToken : null
105
- },
106
- };
107
- if (data instanceof FormData || data instanceof Blob) {
108
- delete options.headers['Content-Type'];
109
- }
110
- if (!this._NO_FETCH) {
111
- const response = await fetch(this._getFullPath(path), {
112
- ...options,
113
- body: JSON.stringify(data),
114
- });
115
- if (!response.ok) {
116
- const error = await response.json();
117
- throw error;
118
- }
119
- return await response.json();
120
- }
121
- else {
122
- return new Promise((resolve, reject) => {
123
- const req = this._https.request(this._getFullPath(path), options, (res) => {
124
- let responseData = '';
125
- res.on('data', (chunk) => {
126
- responseData += chunk;
127
- });
128
- res.on('end', () => {
129
- resolve(JSON.parse(responseData));
130
- });
131
- });
132
- req.on('error', (error) => {
133
- reject(error);
134
- });
135
- req.write(JSON.stringify(data));
136
- req.end();
137
- });
138
- }
139
- }
140
- async _fetchDelete(path, data) {
141
- const options = {
142
- method: 'DELETE',
143
- headers: {
144
- 'Content-Type': 'application/json',
145
- 'x-app-token': this._token,
146
- 'Authorization': this._userToken ? 'Bearer ' + this._userToken : null
147
- },
148
- body: data
149
- };
150
- if (!this._NO_FETCH) {
151
- const response = await fetch(this._getFullPath(path), options);
152
- if (!response.ok) {
153
- const error = await response.json();
154
- throw error;
155
- }
156
- return await response.json();
157
- }
158
- else {
159
- return new Promise((resolve, reject) => {
160
- const req = this._https.delete(this._getFullPath(path), options, (res) => {
161
- let data = '';
162
- res.on('data', (chunk) => {
163
- data += chunk;
164
- });
165
- res.on('end', () => {
166
- resolve(JSON.parse(data));
167
- });
168
- });
169
- req.on('error', (error) => {
170
- reject(error);
171
- });
172
- });
173
- }
174
- }
175
- _queryParamsToString(query) {
176
- let result = '';
177
- for (let key in query) {
178
- if (query[key] !== null) {
179
- result += `${key}=${query[key]}&`;
180
- }
181
- }
182
- return result.slice(0, (result.length - 1));
183
- }
184
- _normalizeData(data, langCode = this._defaultLangCode) {
185
- if (Array.isArray(data)) {
186
- return data.map(item => this._normalizeData(item, langCode));
187
- }
188
- else {
189
- const normalizeData = {};
190
- for (let key in data) {
191
- if (Array.isArray(data[key]) || !data[key] || typeof data[key] !== 'object') {
192
- normalizeData[key] = data[key];
193
- }
194
- else if (langCode in data[key]) {
195
- normalizeData[key] = data[key][langCode];
196
- }
197
- else {
198
- normalizeData[key] = this._normalizeData(data[key], langCode);
199
- }
200
- }
201
- return normalizeData;
202
- }
203
- }
204
- _normalizePostBody(body, langCode = this._defaultLangCode) {
205
- const formData = {};
206
- formData[langCode] = Array.isArray(body.formData) ? body.formData : [body.formData];
207
- body.formData = formData;
208
- return body;
209
- }
210
- _clearArray(data) {
211
- if (Array.isArray(data)) {
212
- return data.map(item => this._clearArray(item));
213
- }
214
- else {
215
- const dataWithoutArray = {};
216
- for (let key in data) {
217
- if (Array.isArray(data[key]) && data[key].length === 1) {
218
- dataWithoutArray[key] = data[key][0];
219
- }
220
- else if (typeof data[key] === 'object' && data[key] && !Array.isArray(data[key])) {
221
- dataWithoutArray[key] = this._clearArray(data[key]);
222
- }
223
- else {
224
- dataWithoutArray[key] = data[key];
225
- }
226
- }
227
- return dataWithoutArray;
228
- }
229
- }
230
- _dataPostProcess(data, langCode = this._defaultLangCode) {
231
- const normalize = this._normalizeData(data, langCode);
232
- const result = this._clearArray(normalize);
233
- return result;
234
- }
235
- }
236
- exports.default = OneEntry;
1
+ // import {IConfig} from "./utils";
2
+ // import {IConfig, IError} from "./utils";
3
+ // import AdminsApi from "../admins/adminsApi";
4
+ // import AttributesSetsApi from "../attribute-sets/attributeSetsApi";
5
+ // import AuthProviderApi from "../auth-provider/authProviderApi";
6
+ // import BlocksApi from "../blocks/blocksApi";
7
+ // import EventsApi from "../events/eventsApi";
8
+ // import FileUploadingApi from "../file-uploding/fileUploadingApi";
9
+ // import FormsApi from "../forms/formsApi";
10
+ // import FormsDataApi from "../formsData/formsDataApi";
11
+ // import GeneralTypesApi from "../general-types/typesApi";
12
+ // import LocalesApi from "../locales/localesApi";
13
+ // import MenusApi from "../menus/menusApi";
14
+ // import OrdersApi from "../orders/ordersApi";
15
+ // import PageApi from "../pages/pagesApi";
16
+ // import PaymentsApi from "../payments/paymentsApi";
17
+ // import ProductApi from "../products/productsApi";
18
+ // import ProductStatusesApi from "../product-statuses/productStatusesApi";
19
+ // import SystemApi from "../system/systemApi";
20
+ // import TemplatesApi from "../templates/templatesApi";
21
+ // import TemplatePreviewsApi from "../templates-preview/templatesPreviewApi";
22
+ // import UsersApi from "../users/usersApi";
23
+ //
24
+ //
25
+ // export default class OneEntry {
26
+ // protected _url
27
+ // protected _token:string | undefined
28
+ // protected _userToken:string | undefined
29
+ // protected _defaultLangCode:string
30
+ // protected _multipleResponse:boolean
31
+ // protected _NO_FETCH:boolean
32
+ // protected _https:any
33
+ //
34
+ // constructor(url:string, config:IConfig = {}) {
35
+ // this._url = url
36
+ //
37
+ // this._token = config.token
38
+ //
39
+ // this._userToken = config.userToken
40
+ //
41
+ // this._defaultLangCode = config.langCode ? config.langCode : 'en_US'
42
+ //
43
+ // this._multipleResponse = config.multipleRequests ?? true
44
+ //
45
+ // this._NO_FETCH = !!(typeof process === 'object' && process.versions)
46
+ //
47
+ // try {
48
+ // this._https = this._NO_FETCH ? require('https') : null
49
+ // } catch (e) {
50
+ // this._https = null
51
+ // }
52
+ // }
53
+ //
54
+ // Admins:AdminsApi = new AdminsApi()
55
+ // AttributesSets:AttributesSetsApi = new AttributesSetsApi()
56
+ // AuthProvider:AuthProviderApi = new AuthProviderApi()
57
+ // Blocks:BlocksApi = new BlocksApi()
58
+ // Events:EventsApi = new EventsApi()
59
+ // FileUploading:FileUploadingApi = new FileUploadingApi()
60
+ // Forms:FormsApi = new FormsApi()
61
+ // FormData:FormsDataApi = new FormsDataApi()
62
+ // GeneralTypes:GeneralTypesApi = new GeneralTypesApi()
63
+ // Locales:LocalesApi = new LocalesApi()
64
+ // Menus:MenusApi = new MenusApi()
65
+ // Orders:OrdersApi = new OrdersApi()
66
+ // Pages:PageApi = new PageApi()
67
+ // Payments:PaymentsApi = new PaymentsApi()
68
+ // Products:ProductApi = new ProductApi()
69
+ // ProductStatuses:ProductStatusesApi = new ProductStatusesApi()
70
+ // System:SystemApi = new SystemApi()
71
+ // Templates:TemplatesApi = new TemplatesApi()
72
+ // TemplatePreviews:TemplatePreviewsApi = new TemplatePreviewsApi()
73
+ // Users:UsersApi = new UsersApi()
74
+ // }
@@ -0,0 +1,10 @@
1
+ import { IConfig } from "./utils";
2
+ export default class StateModule {
3
+ url: string | undefined;
4
+ lang: string | undefined;
5
+ token: string | undefined;
6
+ userToken: string | undefined;
7
+ multipleResponse: boolean;
8
+ refreshToken: string | undefined;
9
+ constructor(url: string, config: IConfig);
10
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class StateModule {
4
+ constructor(url, config) {
5
+ var _a;
6
+ this.url = url;
7
+ this.lang = config.langCode;
8
+ this.token = config.token;
9
+ this.multipleResponse = (_a = config.multipleRequests) !== null && _a !== void 0 ? _a : true;
10
+ this.userToken = config.userToken;
11
+ }
12
+ }
13
+ exports.default = StateModule;
@@ -0,0 +1,14 @@
1
+ import { IProductsQuery } from "../products/productsInterfaces";
2
+ import { IUploadingQuery } from "../file-uploding/fileUploadingInterfaces";
3
+ import StateModule from "./stateModule";
4
+ export default abstract class SyncModules {
5
+ protected state: StateModule;
6
+ protected _url: string;
7
+ protected constructor(state: StateModule);
8
+ protected _getFullPath(path: string): string;
9
+ protected _queryParamsToString(query: IProductsQuery | IUploadingQuery): string;
10
+ protected _normalizeData(data: any, langCode?: string): any;
11
+ protected _normalizePostBody(body: any, langCode?: string): any;
12
+ protected _clearArray(data: Record<string, any>): any;
13
+ protected _dataPostProcess(data: any, langCode?: string): any;
14
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class SyncModules {
4
+ constructor(state) {
5
+ this.state = state;
6
+ this._url = state.url;
7
+ }
8
+ _getFullPath(path) {
9
+ return (this._url + path);
10
+ }
11
+ _queryParamsToString(query) {
12
+ let result = '';
13
+ for (let key in query) {
14
+ if (query[key] !== null) {
15
+ result += `${key}=${query[key]}&`;
16
+ }
17
+ }
18
+ return result.slice(0, (result.length - 1));
19
+ }
20
+ _normalizeData(data, langCode = this.state.lang) {
21
+ if (Array.isArray(data)) {
22
+ return data.map(item => this._normalizeData(item, langCode));
23
+ }
24
+ else {
25
+ const normalizeData = {};
26
+ for (let key in data) {
27
+ if (Array.isArray(data[key]) || !data[key] || typeof data[key] !== 'object') {
28
+ normalizeData[key] = data[key];
29
+ }
30
+ else if (langCode in data[key]) {
31
+ normalizeData[key] = data[key][langCode];
32
+ }
33
+ else {
34
+ normalizeData[key] = this._normalizeData(data[key], langCode);
35
+ }
36
+ }
37
+ return normalizeData;
38
+ }
39
+ }
40
+ _normalizePostBody(body, langCode = this.state.lang) {
41
+ const formData = {};
42
+ formData[langCode] = Array.isArray(body.formData) ? body.formData : [body.formData];
43
+ body.formData = formData;
44
+ return body;
45
+ }
46
+ _clearArray(data) {
47
+ if (Array.isArray(data)) {
48
+ return data.map(item => this._clearArray(item));
49
+ }
50
+ else {
51
+ const dataWithoutArray = {};
52
+ for (let key in data) {
53
+ if (Array.isArray(data[key]) && data[key].length === 1) {
54
+ dataWithoutArray[key] = data[key][0];
55
+ }
56
+ else if (typeof data[key] === 'object' && data[key] && !Array.isArray(data[key])) {
57
+ dataWithoutArray[key] = this._clearArray(data[key]);
58
+ }
59
+ else {
60
+ dataWithoutArray[key] = data[key];
61
+ }
62
+ }
63
+ return dataWithoutArray;
64
+ }
65
+ }
66
+ _dataPostProcess(data, langCode = this.state.lang) {
67
+ const normalize = this._normalizeData(data, langCode);
68
+ const result = this._clearArray(normalize);
69
+ return result;
70
+ }
71
+ }
72
+ exports.default = SyncModules;
@@ -1,22 +1,25 @@
1
- import OneEntry from "../base/oneEntry";
2
- import { IBlocks, IBlocksResponse, IBlockEntity, ISearchBlock } from "./blocksInterfaces";
1
+ import AsyncModules from "../base/asyncModules";
2
+ import { IBlocks, IBlocksResponse, IBlockEntity, ISearchBlock, BlockType } from "./blocksInterfaces";
3
3
  import { IProductsEntity } from "../products/productsInterfaces";
4
- import { IConfig } from "../base/utils";
4
+ import StateModule from "../base/stateModule";
5
5
  /**
6
6
  * Controllers for working with blocks
7
7
  */
8
- export default class BlocksApi extends OneEntry implements IBlocks {
9
- constructor(url: string, config: IConfig);
8
+ export default class BlocksApi extends AsyncModules implements IBlocks {
9
+ protected state: StateModule;
10
+ protected _url: string;
11
+ constructor(state: StateModule);
10
12
  /**
11
13
  * Get blocks by parameters.
12
14
  *
15
+ * @param {BlockType} [type] - Available values : forCatalogProducts, forBasketPage, forErrorPage, forCatalogPages, forProductPreview, forProductPage, forSimilarProductBlock, forStatisticProductBlock, forProductBlock, forForm, forFormField, forNewsPage, forNewsBlock, forNewsPreview, forOneNewsPage, forUsualPage, forTextBlock, forSlider, forOrder, service
13
16
  * @param {string} [langCode] - Language code. Default "en_US"
14
17
  * @param {number} [offset] - Parameter for pagination. Default 0
15
18
  * @param {number} [limit] - Parameter for pagination. Default 30
16
19
  *
17
20
  * @returns Return array of BlocksEntity object.
18
21
  */
19
- getBlocks(langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockEntity | IBlocksResponse>>;
22
+ getBlocks(type?: BlockType, langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockEntity | IBlocksResponse>>;
20
23
  /**
21
24
  * Get block by marker.
22
25
  *
@@ -1,27 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const oneEntry_1 = require("../base/oneEntry");
3
+ const asyncModules_1 = require("../base/asyncModules");
4
4
  /**
5
5
  * Controllers for working with blocks
6
6
  */
7
- class BlocksApi extends oneEntry_1.default {
8
- constructor(url, config) {
9
- super(url, config);
10
- this._url += '/api/content/blocks';
7
+ class BlocksApi extends asyncModules_1.default {
8
+ constructor(state) {
9
+ super(state);
10
+ this._url = state.url + '/api/content/blocks';
11
11
  }
12
12
  /**
13
13
  * Get blocks by parameters.
14
14
  *
15
+ * @param {BlockType} [type] - Available values : forCatalogProducts, forBasketPage, forErrorPage, forCatalogPages, forProductPreview, forProductPage, forSimilarProductBlock, forStatisticProductBlock, forProductBlock, forForm, forFormField, forNewsPage, forNewsBlock, forNewsPreview, forOneNewsPage, forUsualPage, forTextBlock, forSlider, forOrder, service
15
16
  * @param {string} [langCode] - Language code. Default "en_US"
16
17
  * @param {number} [offset] - Parameter for pagination. Default 0
17
18
  * @param {number} [limit] - Parameter for pagination. Default 30
18
19
  *
19
20
  * @returns Return array of BlocksEntity object.
20
21
  */
21
- async getBlocks(langCode = 'en_US', offset = 0, limit = 30) {
22
- const response = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
23
- if (this._multipleResponse) {
24
- const normalizeResponse = this._normalizeData(response);
22
+ async getBlocks(type = 'none', langCode = this.state.lang, offset = 0, limit = 30) {
23
+ const response = await this._fetchGet(`?langCode=${langCode}&type=${type}&offset=${offset}&limit=${limit}`);
24
+ if (this.state.multipleResponse) {
25
+ const normalizeResponse = this._normalizeData(response.items);
25
26
  await Promise.all(normalizeResponse.map(async (block) => {
26
27
  const customSettings = block.customSettings;
27
28
  if (customSettings && customSettings.hasOwnProperty('productConfig')) {
@@ -56,7 +57,7 @@ class BlocksApi extends oneEntry_1.default {
56
57
  }));
57
58
  return this._normalizeData(normalizeResponse);
58
59
  }
59
- return this._normalizeData(response);
60
+ return this._normalizeData(response.items);
60
61
  }
61
62
  /**
62
63
  * Get block by marker.
@@ -66,9 +67,9 @@ class BlocksApi extends oneEntry_1.default {
66
67
  *
67
68
  * @returns Return BlocksEntity object.
68
69
  */
69
- async getBlockByMarker(marker, langCode = this._defaultLangCode) {
70
+ async getBlockByMarker(marker, langCode = this.state.lang) {
70
71
  const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
71
- const normalizeResponse = this._normalizeData(response);
72
+ const normalizeResponse = this._normalizeData(response.items);
72
73
  const customSettings = normalizeResponse.customSettings;
73
74
  if (customSettings && customSettings.hasOwnProperty('productConfig')) {
74
75
  normalizeResponse.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
@@ -79,7 +80,7 @@ class BlocksApi extends oneEntry_1.default {
79
80
  delete normalizeResponse.customSettings;
80
81
  delete normalizeResponse.attributeSetId;
81
82
  delete normalizeResponse.productPageUrls;
82
- if (this._multipleResponse) {
83
+ if (this.state.multipleResponse) {
83
84
  if (normalizeResponse.type === 'forSimilarProductBlock') {
84
85
  try {
85
86
  await this.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
@@ -113,7 +114,7 @@ class BlocksApi extends oneEntry_1.default {
113
114
  *
114
115
  * @returns Return array of BlocksEntity object.
115
116
  */
116
- async getSimilarProducts(marker, langCode = 'en_US', offset = 0, limit = 30) {
117
+ async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30) {
117
118
  const result = await this._fetchGet(`/${marker}/similar-products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
118
119
  return this._normalizeData(result.items);
119
120
  }
@@ -127,7 +128,7 @@ class BlocksApi extends oneEntry_1.default {
127
128
  *
128
129
  * @returns Return array of BlocksEntity object.
129
130
  */
130
- async getProductsByBlockMarker(marker, langCode = 'en_US', offset = 0, limit = 30) {
131
+ async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
131
132
  const result = await this._fetchGet(`/${marker}/products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
132
133
  return this._normalizeData(result.items);
133
134
  }
@@ -136,7 +137,7 @@ class BlocksApi extends oneEntry_1.default {
136
137
  * @param name - Search string
137
138
  * @param [langCode] - Language code. Default "en_US"
138
139
  */
139
- async searchBlock(name, langCode = this._defaultLangCode) {
140
+ async searchBlock(name, langCode = this.state.lang) {
140
141
  const result = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
141
142
  return result;
142
143
  }
@@ -9,7 +9,7 @@ import { IProductsEntity } from "../products/productsInterfaces";
9
9
  * @property {function} searchBlock - Quick search for block objects with limited output.
10
10
  */
11
11
  interface IBlocks {
12
- getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<IBlockEntity | IBlocksResponse>>;
12
+ getBlocks(type: BlockType, langCode: string, offset?: number, limit?: number): Promise<Array<IBlockEntity | IBlocksResponse>>;
13
13
  getBlockByMarker(marker: string, langCode: string): Promise<IBlockEntity>;
14
14
  getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
15
15
  getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
@@ -66,4 +66,5 @@ interface ISearchBlock {
66
66
  name: string;
67
67
  identifier: string;
68
68
  }
69
- export { IBlocks, IBlockEntity, IBlocksResponse, ICustomSetting, ISearchBlock };
69
+ type BlockType = 'forCatalogProducts' | 'forBasketPage' | 'forErrorPage' | 'forCatalogPages' | 'forProductPreview' | 'forProductPage' | 'forSimilarProductBlock' | 'forStatisticProductBlock' | 'forProductBlock' | 'forForm' | 'forFormField' | 'forNewsPage' | 'forNewsBlock' | 'forNewsPreview' | 'forOneNewsPage' | 'forUsualPage' | 'forTextBlock' | 'forSlider' | 'forOrder' | 'service' | 'none';
70
+ export { IBlocks, IBlockEntity, IBlocksResponse, ICustomSetting, ISearchBlock, BlockType };
@@ -1,11 +1,13 @@
1
- import OneEntry from "../base/oneEntry";
2
- import { IConfig } from "../base/utils";
1
+ import AsyncModules from "../base/asyncModules";
3
2
  import { IEvents } from "./eventsInterfaces";
3
+ import StateModule from "../base/stateModule";
4
4
  /**
5
5
  * Controllers for working with events
6
6
  */
7
- export default class EventsApi extends OneEntry implements IEvents {
8
- constructor(url: string, config: IConfig);
7
+ export default class EventsApi extends AsyncModules implements IEvents {
8
+ protected state: StateModule;
9
+ protected _url: string;
10
+ constructor(state: StateModule);
9
11
  /**
10
12
  * Subscribing to an event on a product.
11
13
  * @param marker - Event marker.
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const oneEntry_1 = require("../base/oneEntry");
3
+ const asyncModules_1 = require("../base/asyncModules");
4
4
  /**
5
5
  * Controllers for working with events
6
6
  */
7
- class EventsApi extends oneEntry_1.default {
8
- constructor(url, config) {
9
- super(url, config);
10
- this._url += '/api/content/events';
7
+ class EventsApi extends asyncModules_1.default {
8
+ constructor(state) {
9
+ super(state);
10
+ this._url = state.url + '/api/content/events';
11
11
  }
12
12
  /**
13
13
  * Subscribing to an event on a product.
@@ -1,11 +1,13 @@
1
- import OneEntry from '../base/oneEntry';
1
+ import AsyncModules from '../base/asyncModules';
2
2
  import { IUploadingQuery, IUploadingReturns, IFileUploading } from "./fileUploadingInterfaces";
3
- import { IConfig } from "../base/utils";
3
+ import StateModule from "../base/stateModule";
4
4
  /**
5
5
  * Controllers for working with file uploading
6
6
  */
7
- export default class FileUploadingApi extends OneEntry implements IFileUploading {
8
- constructor(url: string, config: IConfig);
7
+ export default class FileUploadingApi extends AsyncModules implements IFileUploading {
8
+ protected state: StateModule;
9
+ protected _url: string;
10
+ constructor(state: StateModule);
9
11
  private _defaultQuery;
10
12
  /**
11
13
  * Upload file function.