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 form data
6
6
  */
7
7
  class FormsDataApi 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/form-data';
11
11
  }
12
12
  /**
@@ -18,7 +18,7 @@ class FormsDataApi extends oneEntry_1.default {
18
18
  *
19
19
  * @returns Returns array for all objects of FormData
20
20
  */
21
- async getFormsData(langCode = 'en_US', offset = 0, limit = 30) {
21
+ async getFormsData(langCode = this._defaultLangCode, offset = 0, limit = 30) {
22
22
  const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
23
23
  return this._normalizeData(result.items);
24
24
  }
@@ -54,7 +54,7 @@ class FormsDataApi extends oneEntry_1.default {
54
54
  *
55
55
  * @returns Returns array of object FormDataEntity
56
56
  */
57
- async getFormsDataByMarker(marker, langCode = 'en_US', offset = 0, limit = 30) {
57
+ async getFormsDataByMarker(marker, langCode = this._defaultLangCode, offset = 0, limit = 30) {
58
58
  const result = await this._fetchGet(`/${marker}?langCode=${langCode}&offset=${offset}&limit=${limit}`);
59
59
  return this._normalizeData(result);
60
60
  }
@@ -44,13 +44,10 @@ interface IFormsDataEntity {
44
44
  * @property {string} value Form data value.
45
45
  */
46
46
  interface IFormData {
47
- formIdentifier?: string;
48
- formData: {
49
- [langcode: string]: Array<{
50
- marker?: string;
51
- value?: string;
52
- }>;
53
- };
47
+ [langcode: string]: Array<{
48
+ marker?: string;
49
+ value?: string;
50
+ }>;
54
51
  }
55
52
  /**
56
53
  * interface to create an object of information about saving data using the form
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IGeneralTypes, IGeneralTypesEntity } from "./generalTypesInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with types
5
6
  */
6
7
  export default class GeneralTypesApi extends OneEntry implements IGeneralTypes {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all types.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with types
6
6
  */
7
7
  class GeneralTypesApi 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/general-types';
11
11
  }
12
12
  /**
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ import SystemApi from "./system/systemApi";
14
14
  import BlocksApi from "./blocks/blocksApi";
15
15
  import AttributesSetsApi from "./attribute-sets/attributeSetsApi";
16
16
  import MarkersApi from "./markers/markersApi";
17
+ import { IConfig } from "./base/utils";
17
18
  interface IDefineApi {
18
19
  Admins: AdminsApi;
19
20
  AttributesSets: AttributesSetsApi;
@@ -37,5 +38,5 @@ interface IDefineApi {
37
38
  * @param {string} url - URl of your project.
38
39
  * @returns {IDefineApi} - List of methods set.
39
40
  */
40
- export declare function defineOneEntry(url: string, token?: string): IDefineApi;
41
+ export declare function defineOneEntry(url: string, config: IConfig): IDefineApi;
41
42
  export {};
package/dist/index.js CHANGED
@@ -22,23 +22,23 @@ const markersApi_1 = require("./markers/markersApi");
22
22
  * @param {string} url - URl of your project.
23
23
  * @returns {IDefineApi} - List of methods set.
24
24
  */
25
- function defineOneEntry(url, token) {
26
- const Admins = new adminsApi_1.default(url, token);
27
- const AttributesSets = new attributeSetsApi_1.default(url, token);
28
- const Blocks = new blocksApi_1.default(url, token);
29
- const FileUploading = new fileUploadingApi_1.default(url, token);
30
- const Forms = new formsApi_1.default(url, token);
31
- const FormData = new formsDataApi_1.default(url, token);
32
- const GeneralTypes = new GeneralTypesApi_1.default(url, token);
33
- const Locales = new localesApi_1.default(url, token);
34
- const Markers = new markersApi_1.default(url, token);
35
- const Menus = new menusApi_1.default(url, token);
36
- const Pages = new pagesApi_1.default(url, token);
37
- const Products = new productsApi_1.default(url, token);
38
- const ProductStatuses = new productStatusesApi_1.default(url, token);
39
- const System = new systemApi_1.default(url, token);
40
- const Templates = new templatesApi_1.default(url, token);
41
- const TemplatePreviews = new templatesPreviewApi_1.default(url, token);
25
+ function defineOneEntry(url, config) {
26
+ const Admins = new adminsApi_1.default(url, config);
27
+ const AttributesSets = new attributeSetsApi_1.default(url, config);
28
+ const Blocks = new blocksApi_1.default(url, config);
29
+ const FileUploading = new fileUploadingApi_1.default(url, config);
30
+ const Forms = new formsApi_1.default(url, config);
31
+ const FormData = new formsDataApi_1.default(url, config);
32
+ const GeneralTypes = new GeneralTypesApi_1.default(url, config);
33
+ const Locales = new localesApi_1.default(url, config);
34
+ const Markers = new markersApi_1.default(url, config);
35
+ const Menus = new menusApi_1.default(url, config);
36
+ const Pages = new pagesApi_1.default(url, config);
37
+ const Products = new productsApi_1.default(url, config);
38
+ const ProductStatuses = new productStatusesApi_1.default(url, config);
39
+ const System = new systemApi_1.default(url, config);
40
+ const Templates = new templatesApi_1.default(url, config);
41
+ const TemplatePreviews = new templatesPreviewApi_1.default(url, config);
42
42
  return {
43
43
  Admins,
44
44
  AttributesSets,
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { ILocales, ILocalEntity } from "./localesInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with localizations (content language)
5
6
  */
6
7
  export default class LocalesApi extends OneEntry implements ILocales {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Find all active language localization objects.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with localizations (content language)
6
6
  */
7
7
  class LocalesApi 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/locales';
11
11
  }
12
12
  /**
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IMarkersApi, IMarkersEntity } from "./markersInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with markers
5
6
  */
6
7
  export default class MarkersApi extends OneEntry implements IMarkersApi {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all markers.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with markers
6
6
  */
7
7
  class MarkersApi 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/markers';
11
11
  }
12
12
  /**
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IMenus, IMenusEntity } from "./menusInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with menu objects
5
6
  */
6
7
  export default class MenusApi extends OneEntry implements IMenus {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get pages includes in menu by marker.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with menu objects
6
6
  */
7
7
  class MenusApi 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/menus';
11
11
  }
12
12
  /**
@@ -1,23 +1,23 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IPageApi, IPageConfig, IPagesEntity, IPositionForm, IPositionBlock } from "./pagesInterfaces";
3
- import { LangType } from "../base/utils";
3
+ import { IConfig } from "../base/utils";
4
4
  /**
5
5
  * Controllers for working with page objects, including catalog pages
6
6
  */
7
7
  export default class PageApi extends OneEntry implements IPageApi {
8
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
9
9
  /**
10
10
  * Get all top-level page objects.
11
11
  *
12
- * @param {string | Array<string>} [langCode] Required parameter lang code
12
+ * @param {string} [langCode] Required parameter lang code
13
13
  *
14
14
  * @returns Returns all created pages without parents as an array of PageEntity objects or an empty array [] (if there is no data)
15
15
  */
16
- getRootPages(langCode?: LangType): Promise<Array<IPagesEntity>>;
16
+ getRootPages(langCode?: string): Promise<Array<IPagesEntity>>;
17
17
  /**
18
18
  * Get all page objects with product information as an array.
19
19
  *
20
- * @param {string | Array<string>} [langCode] Required parameter lang code
20
+ * @param {string} [langCode] Required parameter lang code
21
21
  *
22
22
  * @param {number} [limit] - Optional parameter for pagination, default is 30
23
23
  *
@@ -25,65 +25,65 @@ export default class PageApi extends OneEntry implements IPageApi {
25
25
  *
26
26
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
27
27
  */
28
- getCatalogPages(langCode?: LangType, limit?: number, offset?: number): Promise<Array<IPagesEntity>>;
28
+ getCatalogPages(langCode?: string, limit?: number, offset?: number): Promise<Array<IPagesEntity>>;
29
29
  /**
30
30
  * Get all page objects with product information as an array.
31
31
  *
32
- * @param {string | Array<string>} [langCode] Required parameter lang code
32
+ * @param {string} [langCode] Required parameter lang code
33
33
  *
34
34
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
35
35
  */
36
- getPages(langCode?: LangType): Promise<Array<IPagesEntity>>;
36
+ getPages(langCode: string): Promise<Array<IPagesEntity>>;
37
37
  /**
38
38
  * Get page object with information about forms, blocks, menus, linked to the page.
39
39
  *
40
- * @param {string | Array<string>} [langCode] Required parameter lang code
40
+ * @param {string} [langCode] Required parameter lang code
41
41
  *
42
42
  * @param {number} [id] - Page object identifier
43
43
  *
44
44
  * @returns Returns PageEntity object
45
45
  */
46
- getPageById(id: number, langCode?: LangType): Promise<IPagesEntity>;
46
+ getPageById(id: number, langCode?: string): Promise<IPagesEntity>;
47
47
  /**
48
48
  * Get page object with information about forms, blocks, menus, linked to the page by URL.
49
49
  *
50
- * @param {string | Array<string>} [langCode] Required parameter lang code
50
+ * @param {string} [langCode] Required parameter lang code
51
51
  *
52
52
  * @param {string} [url] - Page URL
53
53
  *
54
54
  * @returns Returns PageEntity object
55
55
  */
56
- getPageByUrl(url: string, langCode?: LangType): Promise<IPagesEntity>;
56
+ getPageByUrl(url: string, langCode?: string): Promise<IPagesEntity>;
57
57
  /**
58
58
  * Get child pages object with information as an array.
59
59
  *
60
- * @param {string | Array<string>} [langCode] Required parameter lang code
60
+ * @param {string} [langCode] Required parameter lang code
61
61
  *
62
62
  * @param {string} [url] - Page URL
63
63
  *
64
64
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data) for the selected parent
65
65
  */
66
- getChildPagesByParentUrl(url: string, langCode?: LangType): Promise<IPagesEntity>;
66
+ getChildPagesByParentUrl(url: string, langCode?: string): Promise<Array<IPagesEntity>>;
67
67
  /**
68
68
  * Get all forms by page url.
69
69
  *
70
- * @param {string | Array<string>} [langCode] Required parameter lang code
70
+ * @param {string} [langCode] Required parameter lang code
71
71
  *
72
72
  * @param {string} [url] - Page URL
73
73
  *
74
74
  * @returns Returns all forms as an array of PositionForm objects or an empty array [] (if there is no data) for the selected parent
75
75
  */
76
- getFormsByPageUrl(url: string, langCode?: LangType): Promise<Array<IPositionForm>>;
76
+ getFormsByPageUrl(url: string, langCode?: string): Promise<Array<IPositionForm>>;
77
77
  /**
78
78
  * Get all blocks by page url.
79
79
  *
80
- * @param {string | Array<string>} [langCode] Required parameter lang code
80
+ * @param {string} [langCode] Required parameter lang code
81
81
  *
82
82
  * @param {string} [url] - Page URL
83
83
  *
84
84
  * @returns Returns all blocks as an array of PositionBlock objects or an empty array [] (if there is no data) for the selected parent
85
85
  */
86
- getBlocksByPageUrl(url: string, langCode?: LangType): Promise<Array<IPositionBlock>>;
86
+ getBlocksByPageUrl(url: string, langCode?: string): Promise<Array<IPositionBlock>>;
87
87
  /**
88
88
  * Get settings for the page.
89
89
  *
@@ -101,5 +101,5 @@ export default class PageApi extends OneEntry implements IPageApi {
101
101
  *
102
102
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
103
103
  */
104
- searchPage(name: string, langCode?: LangType): Promise<Array<IPagesEntity>>;
104
+ searchPage(name: string, langCode?: string): Promise<Array<IPagesEntity>>;
105
105
  }
@@ -5,25 +5,25 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with page objects, including catalog pages
6
6
  */
7
7
  class PageApi 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/pages';
11
11
  }
12
12
  /**
13
13
  * Get all top-level page objects.
14
14
  *
15
- * @param {string | Array<string>} [langCode] Required parameter lang code
15
+ * @param {string} [langCode] Required parameter lang code
16
16
  *
17
17
  * @returns Returns all created pages without parents as an array of PageEntity objects or an empty array [] (if there is no data)
18
18
  */
19
- async getRootPages(langCode = 'en_US') {
20
- const result = await this._fetchRequests(`/root?langCode=${this._LANGCODE_KEY}`, langCode);
21
- return result;
19
+ async getRootPages(langCode = this._defaultLangCode) {
20
+ const result = await this._fetchGet(`/root?langCode=${langCode}`);
21
+ return this._normalizeData(result.items);
22
22
  }
23
23
  /**
24
24
  * Get all page objects with product information as an array.
25
25
  *
26
- * @param {string | Array<string>} [langCode] Required parameter lang code
26
+ * @param {string} [langCode] Required parameter lang code
27
27
  *
28
28
  * @param {number} [limit] - Optional parameter for pagination, default is 30
29
29
  *
@@ -31,85 +31,85 @@ class PageApi extends oneEntry_1.default {
31
31
  *
32
32
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
33
33
  */
34
- async getCatalogPages(langCode = 'en_US', limit = 30, offset = 0) {
35
- const result = await this._fetchRequests(`/catalog?langCode=${this._LANGCODE_KEY}&limit=${limit}&offset=${offset}`, langCode);
36
- return result;
34
+ async getCatalogPages(langCode = this._defaultLangCode, limit = 30, offset = 0) {
35
+ const result = await this._fetchGet(`/catalog?langCode=${langCode}&limit=${limit}&offset=${offset}`);
36
+ return this._normalizeData(result.items);
37
37
  }
38
38
  /**
39
39
  * Get all page objects with product information as an array.
40
40
  *
41
- * @param {string | Array<string>} [langCode] Required parameter lang code
41
+ * @param {string} [langCode] Required parameter lang code
42
42
  *
43
43
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
44
44
  */
45
- async getPages(langCode = 'en_US') {
46
- const result = await this._fetchRequests(`?langCode=${this._LANGCODE_KEY}`, langCode);
47
- return result;
45
+ async getPages(langCode) {
46
+ const result = await this._fetchGet(`?langCode=${langCode}`);
47
+ return this._normalizeData(result.items);
48
48
  }
49
49
  /**
50
50
  * Get page object with information about forms, blocks, menus, linked to the page.
51
51
  *
52
- * @param {string | Array<string>} [langCode] Required parameter lang code
52
+ * @param {string} [langCode] Required parameter lang code
53
53
  *
54
54
  * @param {number} [id] - Page object identifier
55
55
  *
56
56
  * @returns Returns PageEntity object
57
57
  */
58
- async getPageById(id, langCode = 'en_US') {
59
- const result = await this._fetchRequests(`/${id}?langCode=${this._LANGCODE_KEY}`, langCode);
60
- return result;
58
+ async getPageById(id, langCode = this._defaultLangCode) {
59
+ const result = await this._fetchGet(`/${id}?langCode=${langCode}`);
60
+ return this._normalizeData(result);
61
61
  }
62
62
  /**
63
63
  * Get page object with information about forms, blocks, menus, linked to the page by URL.
64
64
  *
65
- * @param {string | Array<string>} [langCode] Required parameter lang code
65
+ * @param {string} [langCode] Required parameter lang code
66
66
  *
67
67
  * @param {string} [url] - Page URL
68
68
  *
69
69
  * @returns Returns PageEntity object
70
70
  */
71
- async getPageByUrl(url, langCode = 'en_US') {
72
- const result = await this._fetchRequests(`/url/${url}?langCode=${this._LANGCODE_KEY}`, langCode);
73
- return result;
71
+ async getPageByUrl(url, langCode = this._defaultLangCode) {
72
+ const result = await this._fetchGet(`/url/${url}?langCode=${langCode}`);
73
+ return this._normalizeData(result);
74
74
  }
75
75
  /**
76
76
  * Get child pages object with information as an array.
77
77
  *
78
- * @param {string | Array<string>} [langCode] Required parameter lang code
78
+ * @param {string} [langCode] Required parameter lang code
79
79
  *
80
80
  * @param {string} [url] - Page URL
81
81
  *
82
82
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data) for the selected parent
83
83
  */
84
- async getChildPagesByParentUrl(url, langCode = 'en_US') {
85
- const result = await this._fetchRequests(`/${url}/children?langCode=${this._LANGCODE_KEY}`, langCode);
86
- return result;
84
+ async getChildPagesByParentUrl(url, langCode = this._defaultLangCode) {
85
+ const result = await this._fetchGet(`/${url}/children?langCode=${langCode}`);
86
+ return this._normalizeData(result.items);
87
87
  }
88
88
  /**
89
89
  * Get all forms by page url.
90
90
  *
91
- * @param {string | Array<string>} [langCode] Required parameter lang code
91
+ * @param {string} [langCode] Required parameter lang code
92
92
  *
93
93
  * @param {string} [url] - Page URL
94
94
  *
95
95
  * @returns Returns all forms as an array of PositionForm objects or an empty array [] (if there is no data) for the selected parent
96
96
  */
97
- async getFormsByPageUrl(url, langCode = 'en_US') {
98
- const result = await this._fetchRequests(`/${url}/forms?langCode=${this._LANGCODE_KEY}`, langCode);
99
- return result;
97
+ async getFormsByPageUrl(url, langCode = this._defaultLangCode) {
98
+ const result = await this._fetchGet(`/${url}/forms?langCode=${langCode}`);
99
+ return this._normalizeData(result.items);
100
100
  }
101
101
  /**
102
102
  * Get all blocks by page url.
103
103
  *
104
- * @param {string | Array<string>} [langCode] Required parameter lang code
104
+ * @param {string} [langCode] Required parameter lang code
105
105
  *
106
106
  * @param {string} [url] - Page URL
107
107
  *
108
108
  * @returns Returns all blocks as an array of PositionBlock objects or an empty array [] (if there is no data) for the selected parent
109
109
  */
110
- async getBlocksByPageUrl(url, langCode = 'en_US') {
111
- const result = await this._fetchRequests(`/${url}/blocks?langCode=${this._LANGCODE_KEY}`, langCode);
112
- return result;
110
+ async getBlocksByPageUrl(url, langCode = this._defaultLangCode) {
111
+ const result = await this._fetchGet(`/${url}/blocks?langCode=${langCode}`);
112
+ return this._normalizeData(result.items);
113
113
  }
114
114
  /**
115
115
  * Get settings for the page.
@@ -131,9 +131,9 @@ class PageApi extends oneEntry_1.default {
131
131
  *
132
132
  * @returns Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
133
133
  */
134
- async searchPage(name, langCode = 'en_US') {
134
+ async searchPage(name, langCode = this._defaultLangCode) {
135
135
  const result = await this._fetchGet(`/quick/search?lang=${langCode}&name=${name}`);
136
- return result;
136
+ return this._normalizeData(result.items);
137
137
  }
138
138
  }
139
139
  exports.default = PageApi;
@@ -26,7 +26,7 @@ interface IPageApi {
26
26
  getPages(langCode: LangType): Promise<Array<IPagesEntity>>;
27
27
  getPageById(id: number, langCode: LangType): Promise<IPagesEntity>;
28
28
  getPageByUrl(url: string, langCode: LangType): Promise<IPagesEntity>;
29
- getChildPagesByParentUrl(url: string, langCode: LangType): Promise<IPagesEntity>;
29
+ getChildPagesByParentUrl(url: string, langCode: LangType): Promise<Array<IPagesEntity>>;
30
30
  getFormsByPageUrl(url: string, langCode: LangType): Promise<Array<IPositionForm>>;
31
31
  getBlocksByPageUrl(url: string, langCode: LangType): Promise<Array<IPositionBlock>>;
32
32
  getConfigPageByUrl(url: string): Promise<IPageConfig>;
@@ -1,10 +1,11 @@
1
1
  import OneEntry from '../base/oneEntry';
2
2
  import { IProductStatusEntity, IProductStatuses } from "./productStatusesInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with product statuses
5
6
  */
6
7
  export default class ProductStatusesApi extends OneEntry implements IProductStatuses {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Search for all product status objects.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with product statuses
6
6
  */
7
7
  class ProductStatusesApi 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/product-statuses';
11
11
  }
12
12
  /**
@@ -1,16 +1,16 @@
1
1
  import { IProductsQuery, IFilterParams, IProductApi, IProductsEntity } from './productsInterfaces';
2
2
  import OneEntry from '../base/oneEntry';
3
- import { LangType } from "../base/utils";
3
+ import { IConfig } from "../base/utils";
4
4
  /**
5
5
  * Controllers for working with product pages
6
6
  */
7
7
  export default class ProductApi extends OneEntry implements IProductApi {
8
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
9
9
  private _defaultQuery;
10
10
  /**
11
11
  * Search for all product page objects with pagination and filtering.
12
12
  *
13
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
13
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
14
14
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
15
15
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
16
16
  *
@@ -30,11 +30,11 @@ export default class ProductApi extends OneEntry implements IProductApi {
30
30
  *
31
31
  * @returns Array with ProductEntity objects
32
32
  */
33
- getProducts(langCode?: LangType, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
33
+ getProducts(langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
34
34
  /**
35
35
  * Search for all product page objects with pagination that do not have a category.
36
36
  *
37
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
37
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
38
38
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
39
39
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
40
40
  *
@@ -54,13 +54,13 @@ export default class ProductApi extends OneEntry implements IProductApi {
54
54
  *
55
55
  * @returns Array with ProductEntity objects
56
56
  */
57
- getProductsEmptyPage(langCode?: LangType, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
57
+ getProductsEmptyPage(langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
58
58
  /**
59
59
  * Search for all product page objects with pagination for the selected category.
60
60
  *
61
61
  * @param {number} [id] - Page identifier.
62
62
  *
63
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
63
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
64
64
  *
65
65
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
66
66
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -81,13 +81,13 @@ export default class ProductApi extends OneEntry implements IProductApi {
81
81
  *
82
82
  * @returns Array with ProductEntity objects
83
83
  */
84
- getProductsPageById(id: number, langCode?: LangType, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
84
+ getProductsPageById(id: number, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
85
85
  /**
86
86
  * Search for all product page objects with pagination for the selected category (by its URL).
87
87
  *
88
88
  * @param {string} [url] - URL of the category page.
89
89
  *
90
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
90
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
91
91
  *
92
92
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
93
93
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -108,13 +108,13 @@ export default class ProductApi extends OneEntry implements IProductApi {
108
108
  *
109
109
  * @returns Array with ProductEntity objects
110
110
  */
111
- getProductsPageByUrl(url: string, langCode?: LangType, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
111
+ getProductsPageByUrl(url: string, langCode: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
112
112
  /**
113
113
  * Find all related product page objects.
114
114
  *
115
115
  * @param {number} [id] - Product page identifier for which to find relationship.
116
116
  *
117
- * @param {string | Array<string>} [langCode] - Language code parameter. Default "en_US"
117
+ * @param {string} [langCode] - Language code parameter. Default "en_US"
118
118
  *
119
119
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
120
120
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -127,23 +127,23 @@ export default class ProductApi extends OneEntry implements IProductApi {
127
127
  *
128
128
  * @returns Array with ProductEntity objects
129
129
  */
130
- getRelatedProductsById(id: number, langCode?: LangType, userQuery?: IProductsQuery): Promise<IProductsEntity>;
130
+ getRelatedProductsById(id: number, langCode?: string, userQuery?: IProductsQuery): Promise<IProductsEntity>;
131
131
  /**
132
132
  * Retrieve one product object.
133
133
  *
134
134
  * @param {number} [id] - Product id.
135
135
  *
136
- * @param {string | Array<string>} [langCode] Language code parameter. Default "en_US". You can also pass several language parameters ['en_US', 'it_IT']
136
+ * @param {string} [langCode] Language code parameter. Default "en_US". You can also pass several language parameters ['en_US', 'it_IT']
137
137
  *
138
138
  * @returns ProductEntity object.
139
139
  */
140
- getProductById(id: number, langCode?: LangType): Promise<IProductsEntity>;
140
+ getProductById(id: number, langCode?: string): Promise<IProductsEntity>;
141
141
  /**
142
142
  * Find all product page objects with pagination and multiple filtering.
143
143
  *
144
144
  * @param {array} [data] - Request body.
145
145
  *
146
- * @param {string | Array<string>} [langCode] Language code parameter. Default "en_US".
146
+ * @param {string} [langCode] Language code parameter. Default "en_US".
147
147
  *
148
148
  * @example
149
149
  * const objects = [
@@ -185,7 +185,7 @@ export default class ProductApi extends OneEntry implements IProductApi {
185
185
  *
186
186
  * @returns Array with ProductEntity objects
187
187
  */
188
- filterProduct(data: Array<IFilterParams>, langCode?: LangType, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
188
+ filterProduct(data: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
189
189
  /**
190
190
  * Quick search for product page objects with limited output.
191
191
  *