oneentry 1.0.54 → 1.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,11 +65,11 @@ You can get a token as follows
65
65
  5) Log in to the project, go to the settings section and open the token tab
66
66
  6) Get and copy the token of your project
67
67
 
68
- Also, you can connect a tls certificate to secure your project. In this case, do not transfer the "token" at all.
68
+ You can also connect a tls certificate to protect your project. In this case, do not pass the "token" at all. When using the certificate, set up a proxy in your project. Pass an empty string as an url parameter.
69
69
  [Learn more about security](https://oneentry.ru/instructions.html#START)
70
70
 
71
71
 
72
- ```js
72
+ ```js
73
73
  const api = defineOneEntry('your-url', {token: 'my-token', langCode:'my-langCode'})
74
74
  ```
75
75
  Now you can use the following links to jump to specific entries:
@@ -560,7 +560,7 @@ example: null <br>
560
560
  </details>
561
561
  ---
562
562
 
563
- ## Blocks.getSimilarProducts(marker, langCode, offset, limit)
563
+ ### Blocks.getSimilarProducts(marker, langCode, offset, limit)
564
564
 
565
565
 
566
566
  ```js
@@ -607,7 +607,7 @@ Example return:
607
607
 
608
608
 
609
609
 
610
- ## Blocks.getSimilarProducts(marker, langCode, offset, limit)
610
+ ### Blocks.getSimilarProducts(marker, langCode, offset, limit)
611
611
 
612
612
  ```js
613
613
  const value = await Blocks.getProductsByBlockMarker('my-marker', 'en_US')
@@ -10,6 +10,13 @@ interface IAttributesSets {
10
10
  getAttributesByMarker(marker: string, langCode: string): Promise<Array<IAttributesSetsEntity>>;
11
11
  getSingleAttributeByMarkerSet(attributeMarker: string, setMarker: string, langCode: string): Promise<IAttributesSetsEntity>;
12
12
  }
13
+ interface IListTitle {
14
+ title: string;
15
+ value: number | string;
16
+ position: string | number | null;
17
+ extendedValue: string | number | null;
18
+ extendedValueType: string | number | null;
19
+ }
13
20
  /**
14
21
  * Represents a template entity object.
15
22
  *
@@ -35,12 +42,6 @@ interface IAttributesSetsEntity {
35
42
  };
36
43
  };
37
44
  localizeInfos: Record<string, any>;
38
- listTitles: Array<{
39
- title: string;
40
- value: number | string;
41
- position: string | number | null;
42
- extendedValue: string | number | null;
43
- extendedValueType: string | number | null;
44
- }> | Record<string, any>;
45
+ listTitles: Array<IListTitle> | Record<string, any>;
45
46
  }
46
47
  export { IAttributesSets, IAttributesSetsEntity };
@@ -23,21 +23,34 @@ class BlocksApi extends oneEntry_1.default {
23
23
  const normalizeResponse = this._normalizeData(response);
24
24
  await Promise.all(normalizeResponse.map(async (block) => {
25
25
  const customSettings = block.customSettings;
26
- if (customSettings.hasOwnProperty('productConfig')) {
26
+ if (customSettings && customSettings.hasOwnProperty('productConfig')) {
27
27
  block.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
28
28
  }
29
+ else {
30
+ block.countElementsPerRow = 0;
31
+ }
29
32
  delete block.customSettings;
30
33
  delete block.attributeSetId;
31
34
  delete block.productPageUrls;
32
35
  if (block.type === 'forSimilarProductBlock') {
33
- await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
34
- block.similarProducts = result;
35
- });
36
+ try {
37
+ await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
38
+ block.similarProducts = result;
39
+ });
40
+ }
41
+ catch {
42
+ block.similarProducts = [];
43
+ }
36
44
  }
37
45
  else if (block.type === 'forProductBlock') {
38
- await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit).then((result) => {
39
- block.products = result;
40
- });
46
+ try {
47
+ await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit).then((result) => {
48
+ block.products = result;
49
+ });
50
+ }
51
+ catch {
52
+ block.products = [];
53
+ }
41
54
  }
42
55
  }));
43
56
  return normalizeResponse;
@@ -54,21 +67,34 @@ class BlocksApi extends oneEntry_1.default {
54
67
  const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
55
68
  const normalizeResponse = this._normalizeData(response);
56
69
  const customSettings = normalizeResponse.customSettings;
57
- if (customSettings.hasOwnProperty('productConfig')) {
70
+ if (customSettings && customSettings.hasOwnProperty('productConfig')) {
58
71
  normalizeResponse.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
59
72
  }
73
+ else {
74
+ normalizeResponse.countElementsPerRow = 0;
75
+ }
60
76
  delete normalizeResponse.customSettings;
61
77
  delete normalizeResponse.attributeSetId;
62
78
  delete normalizeResponse.productPageUrls;
63
79
  if (normalizeResponse.type === 'forSimilarProductBlock') {
64
- await this.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
65
- normalizeResponse.similarProducts = result;
66
- });
80
+ try {
81
+ await this.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
82
+ normalizeResponse.similarProducts = result;
83
+ });
84
+ }
85
+ catch {
86
+ normalizeResponse.similarProducts = [];
87
+ }
67
88
  }
68
89
  else if (normalizeResponse.type === 'forProductBlock') {
69
- await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode).then((result) => {
70
- normalizeResponse.products = result;
71
- });
90
+ try {
91
+ await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode).then((result) => {
92
+ normalizeResponse.products = result;
93
+ });
94
+ }
95
+ catch {
96
+ normalizeResponse.products = [];
97
+ }
72
98
  }
73
99
  return normalizeResponse;
74
100
  }
@@ -73,4 +73,4 @@ interface ICustomSetting {
73
73
  }> | Record<string, any>;
74
74
  [key: string]: any;
75
75
  }
76
- export { IBlocks, IBlockEntity, IBlocksResponse, IBlockProduct };
76
+ export { IBlocks, IBlockEntity, IBlocksResponse, IBlockProduct, ICustomSetting };
@@ -30,8 +30,8 @@ interface IFormsEntity {
30
30
  id: number;
31
31
  identifier: string;
32
32
  localizeInfos: Record<string, any>;
33
+ templateId: number | null;
33
34
  position: number;
34
- processingData: Record<string, any> | string;
35
35
  processingType: string;
36
36
  version: number;
37
37
  }
@@ -40,4 +40,4 @@ interface IMenusEntity {
40
40
  localizeInfos: Record<string, any>;
41
41
  pages: Array<IMenusPages> | IMenusPages;
42
42
  }
43
- export { IMenus, IMenusEntity };
43
+ export { IMenus, IMenusEntity, IMenusPages };
@@ -70,7 +70,7 @@ interface IProductsQuery {
70
70
  * @property {number | null} conditionValue - The value that is being searched for, default null.
71
71
  * @property {string | null} conditionMarker - Id of the filter condition by which the values are filtered, default null.
72
72
  * @property {string | null} attributeMarker - The text identifier of the indexed attribute by which values are filtered, default null.
73
- * @property {number | null} pageId - Id of the category page object.
73
+ * @property {Array<string> | null} pageUrl - Url of the category page object.
74
74
  */
75
75
  interface IFilterParams {
76
76
  attributeMarker: string;
@@ -86,7 +86,7 @@ interface IFilterParams {
86
86
  */
87
87
  conditionMarker?: 'in' | 'nin' | 'eq' | 'neq' | 'mth' | 'lth' | 'exs' | 'nexs' | null;
88
88
  conditionValue: number | string | null;
89
- pageId?: number;
89
+ pageUrl?: Array<string> | null;
90
90
  }
91
91
  /**
92
92
  * Represents a product entity object.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",