oneentry 1.0.38 → 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 (42) 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 +6 -7
  7. package/dist/base/oneEntry.js +25 -73
  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 +7 -6
  12. package/dist/file-uploding/fileUploadingApi.js +9 -7
  13. package/dist/file-uploding/fileUploadingInterfaces.d.ts +4 -4
  14. package/dist/forms/formsApi.d.ts +2 -1
  15. package/dist/forms/formsApi.js +4 -4
  16. package/dist/formsData/formsDataApi.d.ts +2 -1
  17. package/dist/formsData/formsDataApi.js +6 -6
  18. package/dist/formsData/formsDataInterfaces.d.ts +4 -7
  19. package/dist/general-types/GeneralTypesApi.d.ts +2 -1
  20. package/dist/general-types/GeneralTypesApi.js +2 -2
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.js +17 -17
  23. package/dist/locales/localesApi.d.ts +2 -1
  24. package/dist/locales/localesApi.js +2 -2
  25. package/dist/markers/markersApi.d.ts +2 -1
  26. package/dist/markers/markersApi.js +2 -2
  27. package/dist/menus/menusApi.d.ts +2 -1
  28. package/dist/menus/menusApi.js +2 -2
  29. package/dist/pages/pagesApi.d.ts +19 -19
  30. package/dist/pages/pagesApi.js +36 -36
  31. package/dist/pages/pagesInterfaces.d.ts +1 -1
  32. package/dist/product-statuses/productStatusesApi.d.ts +2 -1
  33. package/dist/product-statuses/productStatusesApi.js +2 -2
  34. package/dist/products/productsApi.d.ts +16 -16
  35. package/dist/products/productsApi.js +35 -56
  36. package/dist/system/systemApi.d.ts +2 -1
  37. package/dist/system/systemApi.js +2 -2
  38. package/dist/templates/templatesApi.d.ts +2 -2
  39. package/dist/templates/templatesApi.js +2 -2
  40. package/dist/templates-preview/templatesPreviewApi.d.ts +2 -1
  41. package/dist/templates-preview/templatesPreviewApi.js +2 -2
  42. package/package.json +1 -1
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with file uploading
6
6
  */
7
7
  class FileUploadingApi 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
  type: null,
12
12
  entity: null,
@@ -20,12 +20,12 @@ class FileUploadingApi extends oneEntry_1.default {
20
20
  /**
21
21
  * Upload file function.
22
22
  *
23
- * @param {Event} [data] Array of Express.Multer.File objects
23
+ * @param {File} [data] File objects. Get data as File from your unput as e.target.files[0]
24
24
  *
25
25
  * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
26
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example : "page"
27
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
28
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
26
+ * @param {string} fileQuery.type - Type, determines the folder name in the storage. Example : "page"
27
+ * @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
28
+ * @param {number} fileQuery.id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
29
29
  * @param {number} [fileQuery.width] - Optional width parameter. Example : 0
30
30
  * @param {number} [fileQuery.height] - Optional height parameter. Example : 0
31
31
  * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example : true
@@ -34,7 +34,9 @@ class FileUploadingApi extends oneEntry_1.default {
34
34
  */
35
35
  async upload(data, fileQuery) {
36
36
  const query = { ...this._defaultQuery, ...fileQuery };
37
- const result = await this._fetchPost('?' + this._queryParamsToString(query), data);
37
+ const body = new FormData();
38
+ body.append('files', data);
39
+ const result = await this._fetchPost('?' + this._queryParamsToString(query), body);
38
40
  return result;
39
41
  }
40
42
  /**
@@ -6,7 +6,7 @@
6
6
  * @property {function} getFile - Get file by parameters.
7
7
  */
8
8
  interface IFileUploading {
9
- upload(data: Event, fileQuery?: IUploadingQuery): Promise<IUploadingReturns>;
9
+ upload(data: File, fileQuery?: IUploadingQuery): Promise<IUploadingReturns>;
10
10
  delete(filename: string, fileQuery?: IUploadingQuery): Promise<any>;
11
11
  getFile(id: number, type: string, entity: string, filename?: string): Promise<IFileEntity>;
12
12
  }
@@ -23,9 +23,9 @@ interface IFileEntity {
23
23
  * @property {boolean} [compress] - Flag of optimization (compression) for images.
24
24
  */
25
25
  interface IUploadingQuery {
26
- type?: string | null;
27
- entity?: string | null;
28
- id?: number | null;
26
+ type: string | null;
27
+ entity: string | null;
28
+ id: number | null;
29
29
  width?: number | null;
30
30
  height?: string | null;
31
31
  compress?: boolean | null;
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IForms, IFormsEntity } from "./formsInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for forms objects
5
6
  */
6
7
  export default class FormsApi extends OneEntry implements IForms {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all forms.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for forms objects
6
6
  */
7
7
  class FormsApi 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/forms';
11
11
  }
12
12
  /**
@@ -18,7 +18,7 @@ class FormsApi extends oneEntry_1.default {
18
18
  *
19
19
  * @returns Returns array for all objects of type FormEntity
20
20
  */
21
- async getAllForms(langCode = 'en_US', offset = 0, limit = 30) {
21
+ async getAllForms(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);
24
24
  }
@@ -30,7 +30,7 @@ class FormsApi extends oneEntry_1.default {
30
30
  *
31
31
  * @returns Returns object of type FormEntity
32
32
  */
33
- async getFormByMarker(marker, langCode = 'en_US') {
33
+ async getFormByMarker(marker, langCode = this._defaultLangCode) {
34
34
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
35
35
  return this._normalizeData(result);
36
36
  }
@@ -1,10 +1,11 @@
1
1
  import OneEntry from '../base/oneEntry';
2
2
  import { IFormsPost, IFormsData, IFormsDataEntity } from './formsDataInterfaces';
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with form data
5
6
  */
6
7
  export default class FormsDataApi extends OneEntry implements IFormsData {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all forms data.
10
11
  *
@@ -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,9 +18,9 @@ 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
- return this._normalizeData(result);
23
+ return this._normalizeData(result.items);
24
24
  }
25
25
  /**
26
26
  * Find all product page objects with pagination and multiple filtering.
@@ -41,7 +41,7 @@ class FormsDataApi extends oneEntry_1.default {
41
41
  * @returns - Returns created FormData objects.
42
42
  */
43
43
  async postFormsData(data) {
44
- const result = await this._fetchPost('', data);
44
+ const result = await this._fetchPost('', JSON.stringify(data));
45
45
  return this._normalizeData(result);
46
46
  }
47
47
  /**
@@ -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
  *