oneentry 1.0.39 → 1.0.40

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 (41) hide show
  1. package/README.md +42 -133
  2. package/dist/admins/adminsApi.d.ts +2 -1
  3. package/dist/admins/adminsApi.js +3 -3
  4. package/dist/attribute-sets/attributeSetsApi.d.ts +2 -1
  5. package/dist/attribute-sets/attributeSetsApi.js +4 -4
  6. package/dist/base/oneEntry.d.ts +5 -6
  7. package/dist/base/oneEntry.js +19 -70
  8. package/dist/base/utils.d.ts +5 -1
  9. package/dist/blocks/blocksApi.d.ts +2 -1
  10. package/dist/blocks/blocksApi.js +3 -3
  11. package/dist/file-uploding/fileUploadingApi.d.ts +2 -1
  12. package/dist/file-uploding/fileUploadingApi.js +2 -2
  13. package/dist/forms/formsApi.d.ts +2 -1
  14. package/dist/forms/formsApi.js +4 -4
  15. package/dist/formsData/formsDataApi.d.ts +2 -1
  16. package/dist/formsData/formsDataApi.js +4 -4
  17. package/dist/formsData/formsDataInterfaces.d.ts +4 -7
  18. package/dist/general-types/GeneralTypesApi.d.ts +2 -1
  19. package/dist/general-types/GeneralTypesApi.js +2 -2
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.js +17 -17
  22. package/dist/locales/localesApi.d.ts +2 -1
  23. package/dist/locales/localesApi.js +2 -2
  24. package/dist/markers/markersApi.d.ts +2 -1
  25. package/dist/markers/markersApi.js +2 -2
  26. package/dist/menus/menusApi.d.ts +2 -1
  27. package/dist/menus/menusApi.js +2 -2
  28. package/dist/pages/pagesApi.d.ts +19 -19
  29. package/dist/pages/pagesApi.js +36 -36
  30. package/dist/pages/pagesInterfaces.d.ts +1 -1
  31. package/dist/product-statuses/productStatusesApi.d.ts +2 -1
  32. package/dist/product-statuses/productStatusesApi.js +2 -2
  33. package/dist/products/productsApi.d.ts +16 -16
  34. package/dist/products/productsApi.js +35 -56
  35. package/dist/system/systemApi.d.ts +2 -1
  36. package/dist/system/systemApi.js +2 -2
  37. package/dist/templates/templatesApi.d.ts +2 -2
  38. package/dist/templates/templatesApi.js +2 -2
  39. package/dist/templates-preview/templatesPreviewApi.d.ts +2 -1
  40. package/dist/templates-preview/templatesPreviewApi.js +2 -2
  41. package/package.json +1 -1
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with product pages
6
6
  */
7
7
  class ProductApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._defaultQuery = {
11
11
  offset: 0,
12
12
  limit: 30,
@@ -22,7 +22,7 @@ class ProductApi extends oneEntry_1.default {
22
22
  /**
23
23
  * Search for all product page objects with pagination and filtering.
24
24
  *
25
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
25
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
26
26
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
27
27
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
28
28
  *
@@ -42,15 +42,15 @@ class ProductApi extends oneEntry_1.default {
42
42
  *
43
43
  * @returns Array with ProductEntity objects
44
44
  */
45
- async getProducts(langCode = 'en_US', userQuery) {
45
+ async getProducts(langCode = this._defaultLangCode, userQuery) {
46
46
  const query = { ...this._defaultQuery, ...userQuery };
47
- const result = await this._fetchRequests(`?langCode=${this._LANGCODE_KEY}&` + this._queryParamsToString(query), langCode);
48
- return result;
47
+ const result = await this._fetchGet(`?langCode=${langCode}&` + this._queryParamsToString(query));
48
+ return this._normalizeData(result.items);
49
49
  }
50
50
  /**
51
51
  * Search for all product page objects with pagination that do not have a category.
52
52
  *
53
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
53
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
54
54
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
55
55
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
56
56
  *
@@ -70,17 +70,17 @@ class ProductApi extends oneEntry_1.default {
70
70
  *
71
71
  * @returns Array with ProductEntity objects
72
72
  */
73
- async getProductsEmptyPage(langCode = 'en_US', userQuery) {
73
+ async getProductsEmptyPage(langCode = this._defaultLangCode, userQuery) {
74
74
  const query = { ...this._defaultQuery, ...userQuery };
75
- const result = await this._fetchRequests(`/empty-page?langCode=${this._LANGCODE_KEY}&` + this._queryParamsToString(query), langCode);
76
- return result;
75
+ const result = await this._fetchGet(`/empty-page?langCode=${langCode}&` + this._queryParamsToString(query));
76
+ return this._normalizeData(result.items);
77
77
  }
78
78
  /**
79
79
  * Search for all product page objects with pagination for the selected category.
80
80
  *
81
81
  * @param {number} [id] - Page identifier.
82
82
  *
83
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
83
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
84
84
  *
85
85
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
86
86
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -101,17 +101,17 @@ class ProductApi extends oneEntry_1.default {
101
101
  *
102
102
  * @returns Array with ProductEntity objects
103
103
  */
104
- async getProductsPageById(id, langCode = 'en_US', userQuery) {
104
+ async getProductsPageById(id, langCode = this._defaultLangCode, userQuery) {
105
105
  const query = { ...this._defaultQuery, ...userQuery };
106
- const result = await this._fetchRequests(`/page/${id}?langCode=${this._LANGCODE_KEY}&` + this._queryParamsToString(query), langCode);
107
- return result;
106
+ const result = await this._fetchGet(`/page/${id}?langCode=${langCode}&` + this._queryParamsToString(query));
107
+ return this._normalizeData(result.items);
108
108
  }
109
109
  /**
110
110
  * Search for all product page objects with pagination for the selected category (by its URL).
111
111
  *
112
112
  * @param {string} [url] - URL of the category page.
113
113
  *
114
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
114
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
115
115
  *
116
116
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
117
117
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -132,17 +132,17 @@ class ProductApi extends oneEntry_1.default {
132
132
  *
133
133
  * @returns Array with ProductEntity objects
134
134
  */
135
- async getProductsPageByUrl(url, langCode = 'en_US', userQuery) {
135
+ async getProductsPageByUrl(url = this._defaultLangCode, langCode, userQuery) {
136
136
  const query = { ...this._defaultQuery, ...userQuery };
137
- const result = await this._fetchRequests(`/page/url/${url}?langCode=${this._LANGCODE_KEY}&` + this._queryParamsToString(query), langCode);
138
- return result;
137
+ const result = await this._fetchGet(`/page/url/${url}?langCode=${langCode}&` + this._queryParamsToString(query));
138
+ return this._normalizeData(result.items);
139
139
  }
140
140
  /**
141
141
  * Find all related product page objects.
142
142
  *
143
143
  * @param {number} [id] - Product page identifier for which to find relationship.
144
144
  *
145
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
145
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
146
146
  *
147
147
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
148
148
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -155,30 +155,30 @@ class ProductApi extends oneEntry_1.default {
155
155
  *
156
156
  * @returns Array with ProductEntity objects
157
157
  */
158
- async getRelatedProductsById(id, langCode = 'en_US', userQuery) {
158
+ async getRelatedProductsById(id, langCode = this._defaultLangCode, userQuery) {
159
159
  const query = { ...this._defaultQuery, ...userQuery };
160
- const result = await this._fetchRequests(`/${id}/related?langCode=${this._LANGCODE_KEY}&` + this._queryParamsToString(query), langCode);
161
- return result;
160
+ const result = await this._fetchGet(`/${id}/related?langCode=${langCode}&` + this._queryParamsToString(query));
161
+ return this._normalizeData(result.items);
162
162
  }
163
163
  /**
164
164
  * Retrieve one product object.
165
165
  *
166
166
  * @param {number} [id] - Product id.
167
167
  *
168
- * @param {string | Array<string>} [langCode] Language code parameter. Default "en_US". You can also pass several language parameters ['en_US', 'it_IT']
168
+ * @param {string} [langCode] Language code parameter. Default "en_US". You can also pass several language parameters ['en_US', 'it_IT']
169
169
  *
170
170
  * @returns ProductEntity object.
171
171
  */
172
- async getProductById(id, langCode = 'en_US') {
173
- const result = await this._fetchRequests(`/${id}?langCode=${this._LANGCODE_KEY}`, langCode);
174
- return result;
172
+ async getProductById(id, langCode = this._defaultLangCode) {
173
+ const result = await this._fetchGet(`/${id}?langCode=${langCode}`);
174
+ return this._normalizeData(result);
175
175
  }
176
176
  /**
177
177
  * Find all product page objects with pagination and multiple filtering.
178
178
  *
179
179
  * @param {array} [data] - Request body.
180
180
  *
181
- * @param {string | Array<string>} [langCode] Language code parameter. Default "en_US".
181
+ * @param {string} [langCode] Language code parameter. Default "en_US".
182
182
  *
183
183
  * @example
184
184
  * const objects = [
@@ -220,33 +220,12 @@ class ProductApi extends oneEntry_1.default {
220
220
  *
221
221
  * @returns Array with ProductEntity objects
222
222
  */
223
- async filterProduct(data, langCode = 'en_US', userQuery) {
223
+ async filterProduct(data, langCode = this._defaultLangCode, userQuery) {
224
224
  const query = { ...this._defaultQuery, ...userQuery };
225
- if (typeof langCode === 'string') {
226
- const response = await this._fetchPost(`/conditions-filter?langCode=${langCode}&` + this._queryParamsToString(query), JSON.stringify(data));
227
- const products = response.items;
228
- const result = products.map(item => this._normalizeData(item));
229
- return result;
230
- }
231
- else {
232
- const productList = [];
233
- await Promise.all(langCode.map(async (lang) => {
234
- const response = await this._fetchPost(`/conditions-filter?langCode=${lang}&` + this._queryParamsToString(query), JSON.stringify(data));
235
- productList.push(response.items);
236
- }));
237
- const result = [];
238
- productList.flat().forEach(product => {
239
- if (!result.find(prod => prod.id === product.id)) {
240
- result.push(product);
241
- }
242
- else {
243
- const relatedProduct = result.find(prod => prod.id === product.id);
244
- Object.assign(relatedProduct.attributeValues, product.attributeValues);
245
- Object.assign(relatedProduct.localizeInfos, product.localizeInfos);
246
- }
247
- });
248
- return result;
249
- }
225
+ const response = await this._fetchPost(`/conditions-filter?langCode=${langCode}&` + this._queryParamsToString(query), JSON.stringify(data));
226
+ const products = response.items;
227
+ const result = products.map(item => this._normalizeData(item));
228
+ return result;
250
229
  }
251
230
  /**
252
231
  * Quick search for product page objects with limited output.
@@ -257,15 +236,15 @@ class ProductApi extends oneEntry_1.default {
257
236
  *
258
237
  * @returns Array with ProductEntity objects
259
238
  */
260
- async searchProduct(name, langCode = 'en_US') {
239
+ async searchProduct(name, langCode = this._defaultLangCode) {
261
240
  const searchProducts = await this._fetchGet(`/quick/search?lang=${langCode}&name=${name}`);
262
241
  const productsList = [];
263
242
  await Promise.all(searchProducts.map(async (product) => {
264
- await this.getProductById(product.id).then((result) => {
243
+ await this.getProductById(product.id, langCode).then((result) => {
265
244
  productsList.push(result);
266
245
  });
267
246
  }));
268
- return productsList;
247
+ return this._normalizeData(productsList);
269
248
  }
270
249
  }
271
250
  exports.default = ProductApi;
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { ISystem } from "./systemInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with system - system
5
6
  */
6
7
  export default class SystemApi extends OneEntry implements ISystem {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  test404(): Promise<any>;
9
10
  test500(): Promise<any>;
10
11
  }
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with system - system
6
6
  */
7
7
  class SystemApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._url += '/api/content/system';
11
11
  }
12
12
  async test404() {
@@ -1,11 +1,11 @@
1
1
  import OneEntry from '../base/oneEntry';
2
2
  import { ITemplatesApi, ITemplateEntity } from './templatesInterfaces';
3
- import { Types } from "../base/utils";
3
+ import { IConfig, Types } from "../base/utils";
4
4
  /**
5
5
  * Controllers for working with template objects
6
6
  */
7
7
  export default class TemplatesPreviewApi extends OneEntry implements ITemplatesApi {
8
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
9
9
  /**
10
10
  * Get all template objects grouped by types.
11
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with template objects
6
6
  */
7
7
  class TemplatesPreviewApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._url += '/api/content/templates';
11
11
  }
12
12
  /**
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { ITemplatesPreview, ITemplatesPreviewEntity } from "./templatesPreviewInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with template objects for preview
5
6
  */
6
7
  export default class TemplatePreviewsApi extends OneEntry implements ITemplatesPreview {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all template objects.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with template objects for preview
6
6
  */
7
7
  class TemplatePreviewsApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._url += '/api/content/template-previews';
11
11
  }
12
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",