oneentry 1.0.56 → 1.0.58
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 +118 -82
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +1 -1
- package/dist/base/oneEntry.d.ts +1 -0
- package/dist/base/oneEntry.js +15 -2
- package/dist/base/utils.d.ts +14 -1
- package/dist/blocks/blocksApi.d.ts +5 -4
- package/dist/blocks/blocksApi.js +52 -47
- package/dist/blocks/blocksInterfaces.d.ts +9 -23
- package/dist/formsData/formsDataInterfaces.d.ts +1 -1
- package/dist/pages/pagesApi.js +42 -3
- package/dist/product-statuses/productStatusesInterfaces.d.ts +2 -3
- package/dist/products/productsApi.js +10 -7
- package/dist/products/productsInterfaces.d.ts +4 -2
- package/dist/templates/templatesApi.d.ts +2 -2
- package/dist/templates/templatesApi.js +6 -2
- package/dist/templates/templatesInterfaces.d.ts +5 -2
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ To get started with OneEntry, sign up for an account at [https://account.oneentr
|
|
|
14
14
|
|
|
15
15
|
To install the OneEntry Headless CMS SDK in your project, run the following command:
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```bash
|
|
18
18
|
npm install oneentry
|
|
19
19
|
```
|
|
20
20
|
|
|
@@ -37,7 +37,7 @@ const {
|
|
|
37
37
|
Menus,
|
|
38
38
|
Pages,
|
|
39
39
|
Products,
|
|
40
|
-
|
|
40
|
+
ProductStatuses,
|
|
41
41
|
System,
|
|
42
42
|
Templates,
|
|
43
43
|
TemplatePreviews
|
|
@@ -50,10 +50,11 @@ Or
|
|
|
50
50
|
const api = defineOneEntry('your-url')
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
The second parameter of the function takes a configuration object with the keys "token" and "
|
|
53
|
+
The second parameter of the function takes a configuration object with the keys "token", "langCode" and "multipleResponse".
|
|
54
54
|
Set the token key if your project secure "Security API Token"
|
|
55
55
|
|
|
56
56
|
Set the "langCode" to set the default language. By specifying this parameter once, you don't have to pass the langCode to the methods ONEENTRY API. If you have not passed the default language, it will be set "en_US"
|
|
57
|
+
Some methods use more than one request to the CMS so that the data you receive is complete and easy to work with. Pass the value "false" for this parameter to save traffic and decide for yourself what data you need. The default value "true"
|
|
57
58
|
|
|
58
59
|
>If you chose token protection to ensure connection security, just pass your token to the function as an optional parameter.
|
|
59
60
|
|
|
@@ -85,7 +86,7 @@ Now you can use the following links to jump to specific entries:
|
|
|
85
86
|
- [Menus](#menus)
|
|
86
87
|
- [Pages](#pages)
|
|
87
88
|
- [Products](#products)
|
|
88
|
-
- [
|
|
89
|
+
- [ProductStatuses](#productstatuses)
|
|
89
90
|
- [System](#system)
|
|
90
91
|
- [Templates](#templates)
|
|
91
92
|
- [TemplatePreviews](#templatepreviews)
|
|
@@ -464,50 +465,17 @@ Example return:
|
|
|
464
465
|
|
|
465
466
|
```json
|
|
466
467
|
{
|
|
467
|
-
"id":
|
|
468
|
+
"id": 1,
|
|
468
469
|
"localizeInfos": {
|
|
469
|
-
"title": "
|
|
470
|
+
"title": "Block"
|
|
470
471
|
},
|
|
471
472
|
"version": 0,
|
|
472
|
-
"position":
|
|
473
|
-
"identifier": "
|
|
474
|
-
"type": "
|
|
473
|
+
"position": 1,
|
|
474
|
+
"identifier": "block",
|
|
475
|
+
"type": "forTextBlock",
|
|
475
476
|
"templateIdentifier": null,
|
|
476
477
|
"isVisible": true,
|
|
477
|
-
"attributeValues": {}
|
|
478
|
-
"countElementsPerRow": 4,
|
|
479
|
-
"similarProducts": [
|
|
480
|
-
{
|
|
481
|
-
"id": 446,
|
|
482
|
-
"localizeInfos": {
|
|
483
|
-
"title": "new product 3"
|
|
484
|
-
},
|
|
485
|
-
"relatedIds": [1, 2],
|
|
486
|
-
"statusId": null,
|
|
487
|
-
"attributeSetId": 11,
|
|
488
|
-
"position": 3,
|
|
489
|
-
"templateIdentifier": null,
|
|
490
|
-
"shortDescTemplateIdentifier": null,
|
|
491
|
-
"price": 543,
|
|
492
|
-
"sku": "ggg",
|
|
493
|
-
"isSync": true,
|
|
494
|
-
"attributeValues": {
|
|
495
|
-
"sku": {
|
|
496
|
-
"type": "string",
|
|
497
|
-
"value": "ggg",
|
|
498
|
-
"position": 0,
|
|
499
|
-
"isProductPreview": false
|
|
500
|
-
},
|
|
501
|
-
"images": {
|
|
502
|
-
"type": "groupOfImages",
|
|
503
|
-
"value": {},
|
|
504
|
-
"position": 3,
|
|
505
|
-
"isProductPreview": false
|
|
506
|
-
}
|
|
507
|
-
},
|
|
508
|
-
"isVisible": true
|
|
509
|
-
}
|
|
510
|
-
]
|
|
478
|
+
"attributeValues": {}
|
|
511
479
|
}
|
|
512
480
|
```
|
|
513
481
|
|
|
@@ -574,29 +542,30 @@ Example return:
|
|
|
574
542
|
```json
|
|
575
543
|
[
|
|
576
544
|
{
|
|
577
|
-
"id":
|
|
545
|
+
"id": 2,
|
|
578
546
|
"localizeInfos": {
|
|
579
|
-
"title": "
|
|
547
|
+
"title": "Box"
|
|
580
548
|
},
|
|
581
|
-
"relatedIds": [
|
|
582
|
-
"statusId":
|
|
583
|
-
"
|
|
549
|
+
"relatedIds": [],
|
|
550
|
+
"statusId": 2,
|
|
551
|
+
"attributeSetId": 5,
|
|
552
|
+
"position": 1,
|
|
584
553
|
"templateIdentifier": null,
|
|
585
554
|
"shortDescTemplateIdentifier": null,
|
|
586
|
-
"price":
|
|
587
|
-
"sku":
|
|
555
|
+
"price": 150,
|
|
556
|
+
"sku": null,
|
|
588
557
|
"isSync": true,
|
|
589
558
|
"attributeValues": {
|
|
590
|
-
"
|
|
591
|
-
"type": "
|
|
592
|
-
"value": "
|
|
593
|
-
"position":
|
|
559
|
+
"price": {
|
|
560
|
+
"type": "integer",
|
|
561
|
+
"value": "150",
|
|
562
|
+
"position": 1,
|
|
594
563
|
"isProductPreview": false
|
|
595
564
|
},
|
|
596
|
-
"
|
|
597
|
-
"type": "
|
|
598
|
-
"value":
|
|
599
|
-
"position":
|
|
565
|
+
"product-name": {
|
|
566
|
+
"type": "string",
|
|
567
|
+
"value": "Box text",
|
|
568
|
+
"position": 0,
|
|
600
569
|
"isProductPreview": false
|
|
601
570
|
}
|
|
602
571
|
},
|
|
@@ -607,7 +576,7 @@ Example return:
|
|
|
607
576
|
|
|
608
577
|
|
|
609
578
|
|
|
610
|
-
### Blocks.
|
|
579
|
+
### Blocks.getProductsByBlockMarker(marker, langCode, offset, limit)
|
|
611
580
|
|
|
612
581
|
```js
|
|
613
582
|
const value = await Blocks.getProductsByBlockMarker('my-marker', 'en_US')
|
|
@@ -1676,6 +1645,7 @@ example: 0 <br>
|
|
|
1676
1645
|
|
|
1677
1646
|
</details>
|
|
1678
1647
|
|
|
1648
|
+
|
|
1679
1649
|
### Pages.getPages(langCode)
|
|
1680
1650
|
|
|
1681
1651
|
```js
|
|
@@ -2464,6 +2434,7 @@ Example return:
|
|
|
2464
2434
|
"isSync": true,
|
|
2465
2435
|
"price": 0,
|
|
2466
2436
|
"templateIdentifier": "my-template",
|
|
2437
|
+
"sku": "0-123",
|
|
2467
2438
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
2468
2439
|
"attributeValues": {
|
|
2469
2440
|
"marker": {
|
|
@@ -2515,6 +2486,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
2515
2486
|
*status identifiers of the product page (can be null)* <br>
|
|
2516
2487
|
example: 1 <br>
|
|
2517
2488
|
|
|
2489
|
+
**sku:** string <br>
|
|
2490
|
+
*product SKU value taken from the index* <br>
|
|
2491
|
+
example: 1 <br>
|
|
2492
|
+
|
|
2518
2493
|
**relatedIds:** array <br>
|
|
2519
2494
|
*identifiers of related product pages* <br>
|
|
2520
2495
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -2559,10 +2534,12 @@ Example return:
|
|
|
2559
2534
|
3
|
|
2560
2535
|
],
|
|
2561
2536
|
"attributeSetId": 7,
|
|
2537
|
+
"blocks": ["product_block"],
|
|
2562
2538
|
"isSync": true,
|
|
2563
2539
|
"price": 0,
|
|
2564
2540
|
"templateIdentifier": "my-template",
|
|
2565
2541
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
2542
|
+
"sku": "0-123",
|
|
2566
2543
|
"attributeValues": {
|
|
2567
2544
|
"marker": {
|
|
2568
2545
|
"value": "",
|
|
@@ -2600,6 +2577,10 @@ example: my-template <br>
|
|
|
2600
2577
|
*attribute set identifier* <br>
|
|
2601
2578
|
example: 7 <br>
|
|
2602
2579
|
|
|
2580
|
+
**blocks:** array <br>
|
|
2581
|
+
*product blocks* <br>
|
|
2582
|
+
example: ['product_block'] <br>
|
|
2583
|
+
|
|
2603
2584
|
**isSync:** boolean <br>
|
|
2604
2585
|
*indicator of page indexing (true or false)* <br>
|
|
2605
2586
|
example: false <br>
|
|
@@ -2612,6 +2593,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
2612
2593
|
*status identifiers of the product page (can be null)* <br>
|
|
2613
2594
|
example: 1 <br>
|
|
2614
2595
|
|
|
2596
|
+
**sku:** string <br>
|
|
2597
|
+
*product SKU value taken from the index* <br>
|
|
2598
|
+
example: 1 <br>
|
|
2599
|
+
|
|
2615
2600
|
**relatedIds:** array <br>
|
|
2616
2601
|
*identifiers of related product pages* <br>
|
|
2617
2602
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -2662,11 +2647,13 @@ Example return:
|
|
|
2662
2647
|
}
|
|
2663
2648
|
],
|
|
2664
2649
|
"attributeSetId": 7,
|
|
2650
|
+
"blocks": ["product_block"],
|
|
2665
2651
|
"version": 10,
|
|
2666
2652
|
"isSync": 0,
|
|
2667
2653
|
"price": 0,
|
|
2668
2654
|
"templateIdentifier": "my-template",
|
|
2669
2655
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
2656
|
+
"sku": "0-123",
|
|
2670
2657
|
"attributeValues": {
|
|
2671
2658
|
"marker": {
|
|
2672
2659
|
"value": "",
|
|
@@ -2703,6 +2690,10 @@ example: my-template <br>
|
|
|
2703
2690
|
*attribute set identifier* <br>
|
|
2704
2691
|
example: 7 <br>
|
|
2705
2692
|
|
|
2693
|
+
**blocks:** array <br>
|
|
2694
|
+
*product blocks* <br>
|
|
2695
|
+
example: ['product_block'] <br>
|
|
2696
|
+
|
|
2706
2697
|
**isSync:** boolean <br>
|
|
2707
2698
|
*indicator of page indexing (true or false)* <br>
|
|
2708
2699
|
example: false <br>
|
|
@@ -2715,6 +2706,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
2715
2706
|
*status identifiers of the product page (can be null)* <br>
|
|
2716
2707
|
example: 1 <br>
|
|
2717
2708
|
|
|
2709
|
+
**sku:** string <br>
|
|
2710
|
+
*product SKU value taken from the index* <br>
|
|
2711
|
+
example: 1 <br>
|
|
2712
|
+
|
|
2718
2713
|
**relatedIds:** array <br>
|
|
2719
2714
|
*identifiers of related product pages* <br>
|
|
2720
2715
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -2764,11 +2759,13 @@ Example return:
|
|
|
2764
2759
|
}
|
|
2765
2760
|
],
|
|
2766
2761
|
"attributeSetId": 7,
|
|
2762
|
+
"blocks": ["product_block"],
|
|
2767
2763
|
"version": 10,
|
|
2768
2764
|
"isSync": 0,
|
|
2769
2765
|
"price": 0,
|
|
2770
2766
|
"templateIdentifier": "my-template",
|
|
2771
2767
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
2768
|
+
"sku": "0-123",
|
|
2772
2769
|
"attributeValues": {
|
|
2773
2770
|
"marker": {
|
|
2774
2771
|
"value": "",
|
|
@@ -2805,6 +2802,10 @@ example: my-template <br>
|
|
|
2805
2802
|
*attribute set identifier* <br>
|
|
2806
2803
|
example: 7 <br>
|
|
2807
2804
|
|
|
2805
|
+
**blocks:** array <br>
|
|
2806
|
+
*product blocks* <br>
|
|
2807
|
+
example: ['product_block'] <br>
|
|
2808
|
+
|
|
2808
2809
|
**isSync:** boolean <br>
|
|
2809
2810
|
*indicator of page indexing (true or false)* <br>
|
|
2810
2811
|
example: false <br>
|
|
@@ -2817,6 +2818,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
2817
2818
|
*status identifiers of the product page (can be null)* <br>
|
|
2818
2819
|
example: 1 <br>
|
|
2819
2820
|
|
|
2821
|
+
**sku:** string <br>
|
|
2822
|
+
*product SKU value taken from the index* <br>
|
|
2823
|
+
example: 1 <br>
|
|
2824
|
+
|
|
2820
2825
|
**relatedIds:** array <br>
|
|
2821
2826
|
*identifiers of related product pages* <br>
|
|
2822
2827
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -2859,10 +2864,12 @@ Example return:
|
|
|
2859
2864
|
3
|
|
2860
2865
|
],
|
|
2861
2866
|
"attributeSetId": 7,
|
|
2867
|
+
"blocks": ["product_block"],
|
|
2862
2868
|
"isSync": true,
|
|
2863
2869
|
"price": 0,
|
|
2864
2870
|
"templateIdentifier": "my-template",
|
|
2865
2871
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
2872
|
+
"sku": "0-123",
|
|
2866
2873
|
"attributeValues": {
|
|
2867
2874
|
"marker": {
|
|
2868
2875
|
"value": "",
|
|
@@ -2899,6 +2906,10 @@ example: my-template <br>
|
|
|
2899
2906
|
*attribute set identifier* <br>
|
|
2900
2907
|
example: 7 <br>
|
|
2901
2908
|
|
|
2909
|
+
**blocks:** array <br>
|
|
2910
|
+
*product blocks* <br>
|
|
2911
|
+
example: ['product_block'] <br>
|
|
2912
|
+
|
|
2902
2913
|
**isSync:** boolean <br>
|
|
2903
2914
|
*indicator of page indexing (true or false)* <br>
|
|
2904
2915
|
example: false <br>
|
|
@@ -2911,6 +2922,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
2911
2922
|
*status identifiers of the product page (can be null)* <br>
|
|
2912
2923
|
example: 1 <br>
|
|
2913
2924
|
|
|
2925
|
+
**sku:** string <br>
|
|
2926
|
+
*product SKU value taken from the index* <br>
|
|
2927
|
+
example: 1 <br>
|
|
2928
|
+
|
|
2914
2929
|
**relatedIds:** array <br>
|
|
2915
2930
|
*identifiers of related product pages* <br>
|
|
2916
2931
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -2953,10 +2968,12 @@ Example return:
|
|
|
2953
2968
|
3
|
|
2954
2969
|
],
|
|
2955
2970
|
"attributeSetId": 7,
|
|
2971
|
+
"blocks": ["product_block"],
|
|
2956
2972
|
"isSync": true,
|
|
2957
2973
|
"price": 0,
|
|
2958
2974
|
"templateIdentifier": "my-template",
|
|
2959
2975
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
2976
|
+
"sku": "0-123",
|
|
2960
2977
|
"attributeValues": {
|
|
2961
2978
|
"marker": {
|
|
2962
2979
|
"value": "",
|
|
@@ -2993,6 +3010,10 @@ example: my-template <br>
|
|
|
2993
3010
|
*attribute set identifier* <br>
|
|
2994
3011
|
example: 7 <br>
|
|
2995
3012
|
|
|
3013
|
+
**blocks:** array <br>
|
|
3014
|
+
*product blocks* <br>
|
|
3015
|
+
example: ['product_block'] <br>
|
|
3016
|
+
|
|
2996
3017
|
**isSync:** boolean <br>
|
|
2997
3018
|
*indicator of page indexing (true or false)* <br>
|
|
2998
3019
|
example: false <br>
|
|
@@ -3005,6 +3026,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
3005
3026
|
*status identifiers of the product page (can be null)* <br>
|
|
3006
3027
|
example: 1 <br>
|
|
3007
3028
|
|
|
3029
|
+
**sku:** string <br>
|
|
3030
|
+
*product SKU value taken from the index* <br>
|
|
3031
|
+
example: 1 <br>
|
|
3032
|
+
|
|
3008
3033
|
**relatedIds:** array <br>
|
|
3009
3034
|
*identifiers of related product pages* <br>
|
|
3010
3035
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -3080,11 +3105,13 @@ Example return:
|
|
|
3080
3105
|
}
|
|
3081
3106
|
],
|
|
3082
3107
|
"attributeSetId": 7,
|
|
3108
|
+
"blocks": ["product_block"],
|
|
3083
3109
|
"version": 10,
|
|
3084
3110
|
"isSync": 0,
|
|
3085
3111
|
"price": 0,
|
|
3086
3112
|
"templateIdentifier": "my-template",
|
|
3087
3113
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
3114
|
+
"sku": "0-123",
|
|
3088
3115
|
"attributeValues": {
|
|
3089
3116
|
"marker": {
|
|
3090
3117
|
"value": "",
|
|
@@ -3121,6 +3148,10 @@ example: my-template <br>
|
|
|
3121
3148
|
*attribute set identifier* <br>
|
|
3122
3149
|
example: 7 <br>
|
|
3123
3150
|
|
|
3151
|
+
**blocks:** array <br>
|
|
3152
|
+
*product blocks* <br>
|
|
3153
|
+
example: ['product_block'] <br>
|
|
3154
|
+
|
|
3124
3155
|
**isSync:** boolean <br>
|
|
3125
3156
|
*indicator of page indexing (true or false)* <br>
|
|
3126
3157
|
example: false <br>
|
|
@@ -3133,6 +3164,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
3133
3164
|
*status identifiers of the product page (can be null)* <br>
|
|
3134
3165
|
example: 1 <br>
|
|
3135
3166
|
|
|
3167
|
+
**sku:** string <br>
|
|
3168
|
+
*product SKU value taken from the index* <br>
|
|
3169
|
+
example: 1 <br>
|
|
3170
|
+
|
|
3136
3171
|
**relatedIds:** array <br>
|
|
3137
3172
|
*identifiers of related product pages* <br>
|
|
3138
3173
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -3183,12 +3218,14 @@ Example return:
|
|
|
3183
3218
|
}
|
|
3184
3219
|
],
|
|
3185
3220
|
"attributeSetId": 7,
|
|
3221
|
+
"blocks": ["product_block"],
|
|
3186
3222
|
"version": 10,
|
|
3187
3223
|
"isSync": 0,
|
|
3188
3224
|
"price": 0,
|
|
3189
3225
|
"templateIdentifier": "my-template",
|
|
3190
3226
|
"shortDescTemplateIdentifier": "my-template-short",
|
|
3191
|
-
|
|
3227
|
+
"sku": "0-123",
|
|
3228
|
+
"attributeValues": {
|
|
3192
3229
|
"marker": {
|
|
3193
3230
|
"value": "",
|
|
3194
3231
|
"type": "string"
|
|
@@ -3225,6 +3262,10 @@ example: my-template <br>
|
|
|
3225
3262
|
*attribute set identifier* <br>
|
|
3226
3263
|
example: 7 <br>
|
|
3227
3264
|
|
|
3265
|
+
**blocks:** array <br>
|
|
3266
|
+
*product blocks* <br>
|
|
3267
|
+
example: ['product_block'] <br>
|
|
3268
|
+
|
|
3228
3269
|
**isSync:** boolean <br>
|
|
3229
3270
|
*indicator of page indexing (true or false)* <br>
|
|
3230
3271
|
example: false <br>
|
|
@@ -3237,6 +3278,10 @@ example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "",
|
|
|
3237
3278
|
*status identifiers of the product page (can be null)* <br>
|
|
3238
3279
|
example: 1 <br>
|
|
3239
3280
|
|
|
3281
|
+
**sku:** string <br>
|
|
3282
|
+
*product SKU value taken from the index* <br>
|
|
3283
|
+
example: 1 <br>
|
|
3284
|
+
|
|
3240
3285
|
**relatedIds:** array <br>
|
|
3241
3286
|
*identifiers of related product pages* <br>
|
|
3242
3287
|
example: List [ 1, 2, 3 ] <br>
|
|
@@ -3258,17 +3303,17 @@ example: my-template-short <br>
|
|
|
3258
3303
|
---
|
|
3259
3304
|
|
|
3260
3305
|
|
|
3261
|
-
## <h2 id="productstatuses">
|
|
3306
|
+
## <h2 id="productstatuses"> ProductStatuses </h2>
|
|
3262
3307
|
|
|
3263
3308
|
|
|
3264
3309
|
```js
|
|
3265
|
-
const {
|
|
3310
|
+
const { ProductStatuses } = defineOneEntry('your-url');
|
|
3266
3311
|
```
|
|
3267
3312
|
|
|
3268
|
-
###
|
|
3313
|
+
### ProductStatuses.getProductStatuses()
|
|
3269
3314
|
|
|
3270
3315
|
```js
|
|
3271
|
-
const value = await
|
|
3316
|
+
const value = await ProductStatuses.getProductStatuses()
|
|
3272
3317
|
```
|
|
3273
3318
|
|
|
3274
3319
|
> This method searches for all product status objects from the API. It returns a Promise that resolves to an array of product status objects.
|
|
@@ -3279,8 +3324,8 @@ Example return:
|
|
|
3279
3324
|
[
|
|
3280
3325
|
{
|
|
3281
3326
|
"id": 1764,
|
|
3282
|
-
"updatedDate": "2023-11-20T22:14:19.438Z",
|
|
3283
3327
|
"version": 10,
|
|
3328
|
+
"position": 2,
|
|
3284
3329
|
"identifier": "catalog",
|
|
3285
3330
|
"localizeInfos": {
|
|
3286
3331
|
"title": "Status 1"
|
|
@@ -3295,9 +3340,6 @@ Example return:
|
|
|
3295
3340
|
*object identifier* <br>
|
|
3296
3341
|
example: 1764 <br>
|
|
3297
3342
|
|
|
3298
|
-
**updatedDate:** string($date-time) <br>
|
|
3299
|
-
*object's date of modification* <br>
|
|
3300
|
-
|
|
3301
3343
|
**version** number <br>
|
|
3302
3344
|
*object's version number of modification* <br>
|
|
3303
3345
|
example: 10 <br>
|
|
@@ -3312,10 +3354,10 @@ example: OrderedMap { "en_US": OrderedMap { "title": "Catalog", "plainContent":
|
|
|
3312
3354
|
|
|
3313
3355
|
</details>
|
|
3314
3356
|
|
|
3315
|
-
###
|
|
3357
|
+
### ProductStatuses.getProductStatusesById(id)
|
|
3316
3358
|
|
|
3317
3359
|
```js
|
|
3318
|
-
const value = await
|
|
3360
|
+
const value = await ProductStatuses.getProductStatusesById(1)
|
|
3319
3361
|
```
|
|
3320
3362
|
|
|
3321
3363
|
> This method searches for a product status object based on its identifier (id) from the API. It returns a Promise that resolves to a product status object.
|
|
@@ -3325,8 +3367,8 @@ Example return:
|
|
|
3325
3367
|
```json
|
|
3326
3368
|
{
|
|
3327
3369
|
"id": 1764,
|
|
3328
|
-
"updatedDate": "2023-09-25T13:36:05.907Z",
|
|
3329
3370
|
"version": 10,
|
|
3371
|
+
"position": 2,
|
|
3330
3372
|
"identifier": "catalog",
|
|
3331
3373
|
"localizeInfos": {
|
|
3332
3374
|
"title": "Status 1"
|
|
@@ -3340,9 +3382,6 @@ Example return:
|
|
|
3340
3382
|
*object identifier* <br>
|
|
3341
3383
|
example: 1764 <br>
|
|
3342
3384
|
|
|
3343
|
-
**updatedDate:** string($date-time) <br>
|
|
3344
|
-
*object's date of modification* <br>
|
|
3345
|
-
|
|
3346
3385
|
**version** number <br>
|
|
3347
3386
|
*object's version number of modification* <br>
|
|
3348
3387
|
example: 10 <br>
|
|
@@ -3357,10 +3396,10 @@ example: OrderedMap { "en_US": OrderedMap { "title": "Catalog", "plainContent":
|
|
|
3357
3396
|
|
|
3358
3397
|
</details>
|
|
3359
3398
|
|
|
3360
|
-
###
|
|
3399
|
+
### ProductStatuses.getProductsByStatusMarker(marker)
|
|
3361
3400
|
|
|
3362
3401
|
```js
|
|
3363
|
-
const value = await
|
|
3402
|
+
const value = await ProductStatuses.getProductsByStatusMarker('my-marker')
|
|
3364
3403
|
```
|
|
3365
3404
|
|
|
3366
3405
|
> This method searches for a product status object based on its textual identifier (marker) from the API. It returns a Promise that resolves to a product status object.
|
|
@@ -3370,8 +3409,8 @@ Example return:
|
|
|
3370
3409
|
```json
|
|
3371
3410
|
{
|
|
3372
3411
|
"id": 1764,
|
|
3373
|
-
"updatedDate": "2023-09-25T13:39:19.384Z",
|
|
3374
3412
|
"version": 10,
|
|
3413
|
+
"position": 2,
|
|
3375
3414
|
"identifier": "catalog",
|
|
3376
3415
|
"localizeInfos": {
|
|
3377
3416
|
"title": "Status 1"
|
|
@@ -3385,9 +3424,6 @@ Example return:
|
|
|
3385
3424
|
*object identifier* <br>
|
|
3386
3425
|
example: 1764 <br>
|
|
3387
3426
|
|
|
3388
|
-
**updatedDate:** string($date-time) <br>
|
|
3389
|
-
*object's date of modification* <br>
|
|
3390
|
-
|
|
3391
3427
|
**version** number <br>
|
|
3392
3428
|
*object's version number of modification* <br>
|
|
3393
3429
|
example: 10 <br>
|
|
@@ -3402,10 +3438,10 @@ example: OrderedMap { "en_US": OrderedMap { "title": "Catalog", "plainContent":
|
|
|
3402
3438
|
|
|
3403
3439
|
</details>
|
|
3404
3440
|
|
|
3405
|
-
###
|
|
3441
|
+
### ProductStatuses.validateMarker(marker)
|
|
3406
3442
|
|
|
3407
3443
|
```js
|
|
3408
|
-
const value = await
|
|
3444
|
+
const value = await ProductStatuses.validateMarker('marker')
|
|
3409
3445
|
```
|
|
3410
3446
|
|
|
3411
3447
|
> This method checks the existence of a textual identifier (marker). It takes a marker parameter as input, representing the product marker to validate. It returns a Promise that resolves to true if the textual identifier (marker) exists or false if it doesn't.
|
package/dist/base/oneEntry.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export default abstract class OneEntry {
|
|
|
5
5
|
protected _url: string;
|
|
6
6
|
protected _token: string | undefined;
|
|
7
7
|
protected _defaultLangCode: string;
|
|
8
|
+
protected _multipleResponse: boolean;
|
|
8
9
|
protected _NO_FETCH: boolean;
|
|
9
10
|
protected _https: any;
|
|
10
11
|
constructor(url: string, config?: IConfig);
|
package/dist/base/oneEntry.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class OneEntry {
|
|
4
4
|
constructor(url, config = {}) {
|
|
5
|
+
var _a;
|
|
5
6
|
this._url = url;
|
|
6
7
|
this._token = config.token;
|
|
7
8
|
this._defaultLangCode = config.langCode ? config.langCode : 'en_US';
|
|
9
|
+
this._multipleResponse = (_a = config.multipleRequests) !== null && _a !== void 0 ? _a : true;
|
|
8
10
|
this._NO_FETCH = !!(typeof process === 'object' && process.versions);
|
|
9
11
|
try {
|
|
10
12
|
this._https = this._NO_FETCH ? require('https') : null;
|
|
@@ -26,6 +28,10 @@ class OneEntry {
|
|
|
26
28
|
};
|
|
27
29
|
if (!this._NO_FETCH) {
|
|
28
30
|
const response = await fetch(this._getFullPath(path), options);
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
const error = await response.json();
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
29
35
|
return await response.json();
|
|
30
36
|
}
|
|
31
37
|
else {
|
|
@@ -61,6 +67,10 @@ class OneEntry {
|
|
|
61
67
|
...options,
|
|
62
68
|
body: data
|
|
63
69
|
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const error = await response.json();
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
64
74
|
return await response.json();
|
|
65
75
|
}
|
|
66
76
|
else {
|
|
@@ -92,8 +102,11 @@ class OneEntry {
|
|
|
92
102
|
};
|
|
93
103
|
if (!this._NO_FETCH) {
|
|
94
104
|
const response = await fetch(this._getFullPath(path), options);
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
if (!response.ok) {
|
|
106
|
+
const error = await response.json();
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
return await response.json();
|
|
97
110
|
}
|
|
98
111
|
else {
|
|
99
112
|
return new Promise((resolve, reject) => {
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -19,9 +19,15 @@ declare enum Types {
|
|
|
19
19
|
forSlider = "forSlider",
|
|
20
20
|
service = "service"
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} [token] - If your project is protected by a token, specify this token in this parameter.
|
|
24
|
+
* @param {string} [langCode] - specify the default language to avoid specifying it in every request.
|
|
25
|
+
* @param {boolean} [multipleRequests] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
|
|
26
|
+
*/
|
|
22
27
|
interface IConfig {
|
|
23
28
|
token?: string;
|
|
24
29
|
langCode?: string;
|
|
30
|
+
multipleRequests?: boolean;
|
|
25
31
|
}
|
|
26
32
|
interface IAttributes {
|
|
27
33
|
listTitles: Array<{
|
|
@@ -69,4 +75,11 @@ interface IAttributeSetEntity {
|
|
|
69
75
|
}
|
|
70
76
|
type LangType = string | Array<string>;
|
|
71
77
|
type LocalizeType = ILocalizeInfos | ILocalizeInfo;
|
|
72
|
-
|
|
78
|
+
interface IError {
|
|
79
|
+
message: string;
|
|
80
|
+
pageData: any;
|
|
81
|
+
statusCode: number;
|
|
82
|
+
timestamp: string;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
}
|
|
85
|
+
export { LocalizeType, ILocalizeInfos, ILocalizeInfo, Types, IAttributeSetEntity, LangType, AttributeType, IAttributeValues, IAttributes, IConfig, IError };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import OneEntry from "../base/oneEntry";
|
|
2
|
-
import { IBlocks,
|
|
2
|
+
import { IBlocks, IBlocksResponse, IBlockEntity } from "./blocksInterfaces";
|
|
3
|
+
import { IProductsEntity } from "../products/productsInterfaces";
|
|
3
4
|
import { IConfig } from "../base/utils";
|
|
4
5
|
/**
|
|
5
6
|
* Controllers for working with blocks
|
|
@@ -15,7 +16,7 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
15
16
|
*
|
|
16
17
|
* @returns Return array of BlocksEntity object.
|
|
17
18
|
*/
|
|
18
|
-
getBlocks(langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockEntity>>;
|
|
19
|
+
getBlocks(langCode?: string, offset?: number, limit?: number): Promise<Array<IBlockEntity | IBlocksResponse>>;
|
|
19
20
|
/**
|
|
20
21
|
* Get block by marker.
|
|
21
22
|
*
|
|
@@ -35,7 +36,7 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
35
36
|
*
|
|
36
37
|
* @returns Return array of BlocksEntity object.
|
|
37
38
|
*/
|
|
38
|
-
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<
|
|
39
|
+
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
|
|
39
40
|
/**
|
|
40
41
|
* Get products by block marker.
|
|
41
42
|
*
|
|
@@ -46,5 +47,5 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
46
47
|
*
|
|
47
48
|
* @returns Return array of BlocksEntity object.
|
|
48
49
|
*/
|
|
49
|
-
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<
|
|
50
|
+
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
|
|
50
51
|
}
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -20,40 +20,43 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
20
20
|
*/
|
|
21
21
|
async getBlocks(langCode = 'en_US', offset = 0, limit = 30) {
|
|
22
22
|
const response = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
else {
|
|
30
|
-
block.countElementsPerRow = 0;
|
|
31
|
-
}
|
|
32
|
-
delete block.customSettings;
|
|
33
|
-
delete block.attributeSetId;
|
|
34
|
-
delete block.productPageUrls;
|
|
35
|
-
if (block.type === 'forSimilarProductBlock') {
|
|
36
|
-
try {
|
|
37
|
-
await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
|
|
38
|
-
block.similarProducts = result;
|
|
39
|
-
});
|
|
23
|
+
if (this._multipleResponse) {
|
|
24
|
+
const normalizeResponse = this._normalizeData(response);
|
|
25
|
+
await Promise.all(normalizeResponse.map(async (block) => {
|
|
26
|
+
const customSettings = block.customSettings;
|
|
27
|
+
if (customSettings && customSettings.hasOwnProperty('productConfig')) {
|
|
28
|
+
block.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
|
-
block.
|
|
30
|
+
else {
|
|
31
|
+
block.countElementsPerRow = 0;
|
|
43
32
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
delete block.customSettings;
|
|
34
|
+
delete block.attributeSetId;
|
|
35
|
+
delete block.productPageUrls;
|
|
36
|
+
if (block.type === 'forSimilarProductBlock') {
|
|
37
|
+
try {
|
|
38
|
+
await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
|
|
39
|
+
block.similarProducts = result;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
block.similarProducts = [];
|
|
44
|
+
}
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
else if (block.type === 'forProductBlock') {
|
|
47
|
+
try {
|
|
48
|
+
await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit).then((result) => {
|
|
49
|
+
block.products = result;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
block.products = [];
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
}));
|
|
57
|
+
return normalizeResponse;
|
|
58
|
+
}
|
|
59
|
+
return response;
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
62
|
* Get block by marker.
|
|
@@ -76,24 +79,26 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
76
79
|
delete normalizeResponse.customSettings;
|
|
77
80
|
delete normalizeResponse.attributeSetId;
|
|
78
81
|
delete normalizeResponse.productPageUrls;
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
normalizeResponse.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
else if (normalizeResponse.type === 'forProductBlock') {
|
|
90
|
-
try {
|
|
91
|
-
await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode).then((result) => {
|
|
92
|
-
normalizeResponse.products = result;
|
|
93
|
-
});
|
|
82
|
+
if (this._multipleResponse) {
|
|
83
|
+
if (normalizeResponse.type === 'forSimilarProductBlock') {
|
|
84
|
+
try {
|
|
85
|
+
await this.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
|
|
86
|
+
normalizeResponse.similarProducts = result;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
normalizeResponse.similarProducts = [];
|
|
91
|
+
}
|
|
94
92
|
}
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
else if (normalizeResponse.type === 'forProductBlock') {
|
|
94
|
+
try {
|
|
95
|
+
await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode).then((result) => {
|
|
96
|
+
normalizeResponse.products = result;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
normalizeResponse.products = [];
|
|
101
|
+
}
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
return normalizeResponse;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IProductsEntity } from "../products/productsInterfaces";
|
|
1
2
|
/**
|
|
2
3
|
* Represents a interface object of Blocks Api.
|
|
3
4
|
*
|
|
@@ -7,25 +8,10 @@
|
|
|
7
8
|
* @property {function} getProductsByBlockMarker - Get Array of products from product block.
|
|
8
9
|
*/
|
|
9
10
|
interface IBlocks {
|
|
10
|
-
getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<IBlockEntity>>;
|
|
11
|
+
getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<IBlockEntity | IBlocksResponse>>;
|
|
11
12
|
getBlockByMarker(marker: string, langCode: string): Promise<IBlockEntity>;
|
|
12
|
-
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<
|
|
13
|
-
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<
|
|
14
|
-
}
|
|
15
|
-
interface IBlockProduct {
|
|
16
|
-
attributeSetId: number;
|
|
17
|
-
attributeValues: Record<string, any>;
|
|
18
|
-
id: number;
|
|
19
|
-
isSync: boolean;
|
|
20
|
-
isVisible: boolean;
|
|
21
|
-
localizeInfos: Record<string, any>;
|
|
22
|
-
position: number;
|
|
23
|
-
price: number;
|
|
24
|
-
relatedIds: Array<number>;
|
|
25
|
-
shortDescTemplateIdentifier: string | null;
|
|
26
|
-
sku: string;
|
|
27
|
-
statusId: number | null;
|
|
28
|
-
templateIdentifier: string | null;
|
|
13
|
+
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
|
|
14
|
+
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
|
|
29
15
|
}
|
|
30
16
|
interface IBlocksResponse {
|
|
31
17
|
id: number;
|
|
@@ -41,8 +27,8 @@ interface IBlocksResponse {
|
|
|
41
27
|
templateIdentifier: string | null;
|
|
42
28
|
countElementsPerRow?: number;
|
|
43
29
|
productPageUrls: Array<any>;
|
|
44
|
-
similarProducts?: Array<
|
|
45
|
-
products?: Array<
|
|
30
|
+
similarProducts?: Array<IProductsEntity>;
|
|
31
|
+
products?: Array<IProductsEntity>;
|
|
46
32
|
}
|
|
47
33
|
interface IBlockEntity {
|
|
48
34
|
attributeValues: Record<string, any>;
|
|
@@ -54,8 +40,8 @@ interface IBlockEntity {
|
|
|
54
40
|
templateIdentifier: string | null;
|
|
55
41
|
type: string;
|
|
56
42
|
version: number;
|
|
57
|
-
similarProducts?: Array<
|
|
58
|
-
products?: Array<
|
|
43
|
+
similarProducts?: Array<IProductsEntity>;
|
|
44
|
+
products?: Array<IProductsEntity>;
|
|
59
45
|
countElementsPerRow: number;
|
|
60
46
|
}
|
|
61
47
|
interface ICustomSetting {
|
|
@@ -73,4 +59,4 @@ interface ICustomSetting {
|
|
|
73
59
|
}> | Record<string, any>;
|
|
74
60
|
[key: string]: any;
|
|
75
61
|
}
|
|
76
|
-
export { IBlocks, IBlockEntity, IBlocksResponse,
|
|
62
|
+
export { IBlocks, IBlockEntity, IBlocksResponse, ICustomSetting };
|
package/dist/pages/pagesApi.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const oneEntry_1 = require("../base/oneEntry");
|
|
4
|
+
const blocksApi_1 = require("../blocks/blocksApi");
|
|
4
5
|
/**
|
|
5
6
|
* Controllers for working with page objects, including catalog pages
|
|
6
7
|
*/
|
|
@@ -18,7 +19,6 @@ class PageApi extends oneEntry_1.default {
|
|
|
18
19
|
*/
|
|
19
20
|
async getRootPages(langCode = this._defaultLangCode) {
|
|
20
21
|
const result = await this._fetchGet(`/root?langCode=${langCode}`);
|
|
21
|
-
console.log(result);
|
|
22
22
|
return this._normalizeData(result, langCode);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
@@ -109,8 +109,47 @@ class PageApi extends oneEntry_1.default {
|
|
|
109
109
|
* @returns Returns all blocks as an array of PositionBlock objects or an empty array [] (if there is no data) for the selected parent
|
|
110
110
|
*/
|
|
111
111
|
async getBlocksByPageUrl(url, langCode = this._defaultLangCode) {
|
|
112
|
-
const
|
|
113
|
-
|
|
112
|
+
const response = await this._fetchGet(`/${url}/blocks?langCode=${langCode}`);
|
|
113
|
+
const normalizeResponse = this._normalizeData(response);
|
|
114
|
+
normalizeResponse.map((item) => {
|
|
115
|
+
const customSettings = item.customSettings;
|
|
116
|
+
if (customSettings && customSettings.hasOwnProperty('productConfig')) {
|
|
117
|
+
item.countElementsPerRow = customSettings.productConfig.countElementsPerRow ? (+customSettings.productConfig.countElementsPerRow) : 0;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
item.countElementsPerRow = 0;
|
|
121
|
+
}
|
|
122
|
+
delete item.customSettings;
|
|
123
|
+
delete item.attributeSetId;
|
|
124
|
+
return item;
|
|
125
|
+
});
|
|
126
|
+
if (this._multipleResponse) {
|
|
127
|
+
const Blocks = new blocksApi_1.default(this._url.split('/api')[0], {
|
|
128
|
+
langCode: this._defaultLangCode,
|
|
129
|
+
token: this._token
|
|
130
|
+
});
|
|
131
|
+
if (normalizeResponse.type === 'forSimilarProductBlock') {
|
|
132
|
+
try {
|
|
133
|
+
await Blocks.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
|
|
134
|
+
normalizeResponse.similarProducts = result;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
normalizeResponse.similarProducts = [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (normalizeResponse.type === 'forProductBlock') {
|
|
142
|
+
try {
|
|
143
|
+
await Blocks.getProductsByBlockMarker(normalizeResponse.identifier, langCode).then((result) => {
|
|
144
|
+
normalizeResponse.products = result;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
normalizeResponse.products = [];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return normalizeResponse;
|
|
114
153
|
}
|
|
115
154
|
/**
|
|
116
155
|
* Get settings for the page.
|
|
@@ -20,15 +20,14 @@ interface IProductStatuses {
|
|
|
20
20
|
*
|
|
21
21
|
* @interface
|
|
22
22
|
* @property {number} id - The unique identifier of the position.
|
|
23
|
-
* @property {Date | string} updatedDate - The date of last updated.
|
|
24
23
|
* @property {number} version - The version number of the object.
|
|
25
24
|
* @property {string} identifier - The textual identifier for the record field.
|
|
26
|
-
* @property {
|
|
25
|
+
* @property {number} position - Position number.
|
|
27
26
|
* @property {Record<string, any>} localizeInfos - The name of the products statuses, taking into account localization.
|
|
28
27
|
*/
|
|
29
28
|
interface IProductStatusEntity {
|
|
30
29
|
id: number;
|
|
31
|
-
|
|
30
|
+
position: number;
|
|
32
31
|
version: number;
|
|
33
32
|
identifier: string;
|
|
34
33
|
localizeInfos: Record<string, any>;
|
|
@@ -238,13 +238,16 @@ class ProductApi extends oneEntry_1.default {
|
|
|
238
238
|
*/
|
|
239
239
|
async searchProduct(name, langCode = this._defaultLangCode) {
|
|
240
240
|
const searchProducts = await this._fetchGet(`/quick/search?lang=${langCode}&name=${name}`);
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
await
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
241
|
+
if (this._multipleResponse) {
|
|
242
|
+
const productsList = [];
|
|
243
|
+
await Promise.all(searchProducts.map(async (product) => {
|
|
244
|
+
await this.getProductById(product.id, langCode).then((result) => {
|
|
245
|
+
productsList.push(result);
|
|
246
|
+
});
|
|
247
|
+
}));
|
|
248
|
+
return this._dataPostProcess(productsList, langCode);
|
|
249
|
+
}
|
|
250
|
+
return searchProducts;
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
253
|
exports.default = ProductApi;
|
|
@@ -107,6 +107,7 @@ interface IFilterParams {
|
|
|
107
107
|
interface IProductsEntity {
|
|
108
108
|
id: number;
|
|
109
109
|
localizeInfos: Record<string, any>;
|
|
110
|
+
blocks?: string | Array<string>;
|
|
110
111
|
isVisible: boolean;
|
|
111
112
|
statusId: number | null;
|
|
112
113
|
relatedIds: number[];
|
|
@@ -117,6 +118,7 @@ interface IProductsEntity {
|
|
|
117
118
|
shortDescTemplateIdentifier: string;
|
|
118
119
|
attributeValues: Record<string, any>;
|
|
119
120
|
position: number;
|
|
120
|
-
|
|
121
|
+
sku: string | null;
|
|
122
|
+
productPages?: Array<Record<string, any>> | Record<string, any>;
|
|
121
123
|
}
|
|
122
|
-
export { IFilterParams, IProductsQuery, IProductApi, IProductsEntity };
|
|
124
|
+
export { IFilterParams, IProductsQuery, IProductApi, IProductsEntity, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OneEntry from '../base/oneEntry';
|
|
2
|
-
import { ITemplatesApi, ITemplateEntity } from './templatesInterfaces';
|
|
2
|
+
import { ITemplatesApi, ITemplateEntity, ITemplateList } from './templatesInterfaces';
|
|
3
3
|
import { IConfig, Types } from "../base/utils";
|
|
4
4
|
/**
|
|
5
5
|
* Controllers for working with template objects
|
|
@@ -12,7 +12,7 @@ export default class TemplatesPreviewApi extends OneEntry implements ITemplatesA
|
|
|
12
12
|
*
|
|
13
13
|
* @returns Returns an object GroupedTemplatesObject, which contains an array of template objects TemplateEntity
|
|
14
14
|
*/
|
|
15
|
-
getAllTemplates(langCode?: string): Promise<
|
|
15
|
+
getAllTemplates(langCode?: string): Promise<ITemplateList>;
|
|
16
16
|
/**
|
|
17
17
|
* Get template objects by type.
|
|
18
18
|
*
|
|
@@ -16,8 +16,12 @@ class TemplatesPreviewApi extends oneEntry_1.default {
|
|
|
16
16
|
* @returns Returns an object GroupedTemplatesObject, which contains an array of template objects TemplateEntity
|
|
17
17
|
*/
|
|
18
18
|
async getAllTemplates(langCode = this._defaultLangCode) {
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const response = await this._fetchGet('/all');
|
|
20
|
+
const result = {};
|
|
21
|
+
for (let item in response) {
|
|
22
|
+
result[item] = this._normalizeData(response[item], langCode);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* Get template objects by type.
|
|
@@ -8,7 +8,7 @@ import { Types } from "../base/utils";
|
|
|
8
8
|
* @property {function} getTemplateByType - Get template objects by type.
|
|
9
9
|
*/
|
|
10
10
|
interface ITemplatesApi {
|
|
11
|
-
getAllTemplates(langCode: string): Promise<
|
|
11
|
+
getAllTemplates(langCode: string): Promise<ITemplateList>;
|
|
12
12
|
getTemplateByType(type: Types, langCode: string): Promise<Array<ITemplateEntity>>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -39,4 +39,7 @@ interface ITemplateEntity {
|
|
|
39
39
|
positionId?: number;
|
|
40
40
|
generalTypeName: Types;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
interface ITemplateList {
|
|
43
|
+
[key: string]: ITemplateEntity;
|
|
44
|
+
}
|
|
45
|
+
export { ITemplatesApi, ITemplateEntity, ITemplateList };
|