oneentry 1.0.52 → 1.0.54
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
|
@@ -348,7 +348,6 @@ Example return:
|
|
|
348
348
|
[
|
|
349
349
|
{
|
|
350
350
|
"id": 4,
|
|
351
|
-
"attributeSetId": 14,
|
|
352
351
|
"localizeInfos": {
|
|
353
352
|
"title": "Name"
|
|
354
353
|
},
|
|
@@ -356,7 +355,6 @@ Example return:
|
|
|
356
355
|
"position": 3,
|
|
357
356
|
"identifier": "product",
|
|
358
357
|
"type": "forProductBlock",
|
|
359
|
-
"productPageUrls": [],
|
|
360
358
|
"templateIdentifier": null,
|
|
361
359
|
"isVisible": true,
|
|
362
360
|
"attributeValues": {
|
|
@@ -467,7 +465,6 @@ Example return:
|
|
|
467
465
|
```json
|
|
468
466
|
{
|
|
469
467
|
"id": 3,
|
|
470
|
-
"attributeSetId": null,
|
|
471
468
|
"localizeInfos": {
|
|
472
469
|
"title": "test"
|
|
473
470
|
},
|
|
@@ -475,7 +472,6 @@ Example return:
|
|
|
475
472
|
"position": 4,
|
|
476
473
|
"identifier": "test",
|
|
477
474
|
"type": "forSimilarProductBlock",
|
|
478
|
-
"productPageUrls": [],
|
|
479
475
|
"templateIdentifier": null,
|
|
480
476
|
"isVisible": true,
|
|
481
477
|
"attributeValues": {},
|
|
@@ -584,7 +580,6 @@ Example return:
|
|
|
584
580
|
},
|
|
585
581
|
"relatedIds": [1, 2],
|
|
586
582
|
"statusId": null,
|
|
587
|
-
"attributeSetId": 11,
|
|
588
583
|
"position": 3,
|
|
589
584
|
"templateIdentifier": null,
|
|
590
585
|
"shortDescTemplateIdentifier": null,
|
|
@@ -631,7 +626,6 @@ Example return:
|
|
|
631
626
|
},
|
|
632
627
|
"relatedIds": [1, 2],
|
|
633
628
|
"statusId": null,
|
|
634
|
-
"attributeSetId": 11,
|
|
635
629
|
"position": 3,
|
|
636
630
|
"templateIdentifier": null,
|
|
637
631
|
"shortDescTemplateIdentifier": null,
|
package/dist/base/oneEntry.js
CHANGED
|
@@ -7,8 +7,7 @@ class OneEntry {
|
|
|
7
7
|
this._defaultLangCode = config.langCode ? config.langCode : 'en_US';
|
|
8
8
|
this._NO_FETCH = !!(typeof process === 'object' && process.versions);
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
this._https = null;
|
|
10
|
+
this._https = this._NO_FETCH ? require('https') : null;
|
|
12
11
|
}
|
|
13
12
|
catch (e) {
|
|
14
13
|
this._https = null;
|
|
@@ -37,7 +36,6 @@ class OneEntry {
|
|
|
37
36
|
data += chunk;
|
|
38
37
|
});
|
|
39
38
|
res.on('end', () => {
|
|
40
|
-
// const result = new Result(JSON.parse(data))
|
|
41
39
|
resolve(JSON.parse(data));
|
|
42
40
|
});
|
|
43
41
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OneEntry from "../base/oneEntry";
|
|
2
|
-
import { IBlocks,
|
|
2
|
+
import { IBlocks, IBlockEntity, IBlockProduct } from "./blocksInterfaces";
|
|
3
3
|
import { IConfig } from "../base/utils";
|
|
4
4
|
/**
|
|
5
5
|
* Controllers for working with blocks
|
|
@@ -15,7 +15,7 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
15
15
|
*
|
|
16
16
|
* @returns Return array of BlocksEntity object.
|
|
17
17
|
*/
|
|
18
|
-
getBlocks(langCode?: string, offset?: number, limit?: number): Promise<Array<
|
|
18
|
+
getBlocks(langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockEntity>>;
|
|
19
19
|
/**
|
|
20
20
|
* Get block by marker.
|
|
21
21
|
*
|
|
@@ -24,7 +24,7 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
24
24
|
*
|
|
25
25
|
* @returns Return BlocksEntity object.
|
|
26
26
|
*/
|
|
27
|
-
getBlockByMarker(marker: string, langCode?: string): Promise<
|
|
27
|
+
getBlockByMarker(marker: string, langCode?: string): Promise<IBlockEntity>;
|
|
28
28
|
/**
|
|
29
29
|
* Get similar products by block marker.
|
|
30
30
|
*
|
|
@@ -35,7 +35,7 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
35
35
|
*
|
|
36
36
|
* @returns Return array of BlocksEntity object.
|
|
37
37
|
*/
|
|
38
|
-
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<
|
|
38
|
+
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockProduct>>;
|
|
39
39
|
/**
|
|
40
40
|
* Get products by block marker.
|
|
41
41
|
*
|
|
@@ -46,5 +46,5 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
46
46
|
*
|
|
47
47
|
* @returns Return array of BlocksEntity object.
|
|
48
48
|
*/
|
|
49
|
-
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<
|
|
49
|
+
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockProduct>>;
|
|
50
50
|
}
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -24,9 +24,11 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
24
24
|
await Promise.all(normalizeResponse.map(async (block) => {
|
|
25
25
|
const customSettings = block.customSettings;
|
|
26
26
|
if (customSettings.hasOwnProperty('productConfig')) {
|
|
27
|
-
block.countElementsPerRow =
|
|
27
|
+
block.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
|
|
28
28
|
}
|
|
29
29
|
delete block.customSettings;
|
|
30
|
+
delete block.attributeSetId;
|
|
31
|
+
delete block.productPageUrls;
|
|
30
32
|
if (block.type === 'forSimilarProductBlock') {
|
|
31
33
|
await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
|
|
32
34
|
block.similarProducts = result;
|
|
@@ -53,9 +55,11 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
53
55
|
const normalizeResponse = this._normalizeData(response);
|
|
54
56
|
const customSettings = normalizeResponse.customSettings;
|
|
55
57
|
if (customSettings.hasOwnProperty('productConfig')) {
|
|
56
|
-
normalizeResponse.countElementsPerRow =
|
|
58
|
+
normalizeResponse.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
|
|
57
59
|
}
|
|
58
60
|
delete normalizeResponse.customSettings;
|
|
61
|
+
delete normalizeResponse.attributeSetId;
|
|
62
|
+
delete normalizeResponse.productPageUrls;
|
|
59
63
|
if (normalizeResponse.type === 'forSimilarProductBlock') {
|
|
60
64
|
await this.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
|
|
61
65
|
normalizeResponse.similarProducts = result;
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* @property {function} getProductsByBlockMarker - Get Array of products from product block.
|
|
8
8
|
*/
|
|
9
9
|
interface IBlocks {
|
|
10
|
-
getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<
|
|
11
|
-
getBlockByMarker(marker: string, langCode: string): Promise<
|
|
12
|
-
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<
|
|
13
|
-
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<
|
|
10
|
+
getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<IBlockEntity>>;
|
|
11
|
+
getBlockByMarker(marker: string, langCode: string): Promise<IBlockEntity>;
|
|
12
|
+
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockProduct>>;
|
|
13
|
+
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockProduct>>;
|
|
14
14
|
}
|
|
15
|
-
interface
|
|
15
|
+
interface IBlockProduct {
|
|
16
16
|
attributeSetId: number;
|
|
17
17
|
attributeValues: Record<string, any>;
|
|
18
18
|
id: number;
|
|
@@ -27,7 +27,7 @@ interface ISimilarProduct {
|
|
|
27
27
|
statusId: number | null;
|
|
28
28
|
templateIdentifier: string | null;
|
|
29
29
|
}
|
|
30
|
-
interface
|
|
30
|
+
interface IBlocksResponse {
|
|
31
31
|
id: number;
|
|
32
32
|
attributeSetId: number | null;
|
|
33
33
|
localizeInfos: Record<string, any>;
|
|
@@ -40,8 +40,23 @@ interface IBlocksEntity {
|
|
|
40
40
|
type: string;
|
|
41
41
|
templateIdentifier: string | null;
|
|
42
42
|
countElementsPerRow?: number;
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
productPageUrls: Array<any>;
|
|
44
|
+
similarProducts?: Array<IBlockProduct>;
|
|
45
|
+
products?: Array<IBlockProduct>;
|
|
46
|
+
}
|
|
47
|
+
interface IBlockEntity {
|
|
48
|
+
attributeValues: Record<string, any>;
|
|
49
|
+
id: number;
|
|
50
|
+
identifier: string;
|
|
51
|
+
isVisible: boolean;
|
|
52
|
+
localizeInfos: Record<string, any>;
|
|
53
|
+
position: number;
|
|
54
|
+
templateIdentifier: string | null;
|
|
55
|
+
type: string;
|
|
56
|
+
version: number;
|
|
57
|
+
similarProducts?: Array<IBlockProduct>;
|
|
58
|
+
products?: Array<IBlockProduct>;
|
|
59
|
+
countElementsPerRow: number;
|
|
45
60
|
}
|
|
46
61
|
interface ICustomSetting {
|
|
47
62
|
sliderDelay: number;
|
|
@@ -58,4 +73,4 @@ interface ICustomSetting {
|
|
|
58
73
|
}> | Record<string, any>;
|
|
59
74
|
[key: string]: any;
|
|
60
75
|
}
|
|
61
|
-
export { IBlocks,
|
|
76
|
+
export { IBlocks, IBlockEntity, IBlocksResponse, IBlockProduct };
|