oneentry 1.0.50 → 1.0.52
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 +259 -34
- package/dist/admins/adminsApi.js +2 -2
- package/dist/base/oneEntry.js +4 -3
- package/dist/base/result.d.ts +8 -0
- package/dist/base/result.js +90 -0
- package/dist/blocks/blocksApi.d.ts +32 -0
- package/dist/blocks/blocksApi.js +77 -15
- package/dist/blocks/blocksInterfaces.d.ts +24 -0
- package/dist/general-types/typesApi.d.ts +15 -0
- package/dist/general-types/typesApi.js +22 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/pages/pagesApi.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -334,6 +334,126 @@ example: List [ OrderedMap { "title": "red", "value": 1, "position": 1, "extende
|
|
|
334
334
|
const { Blocks } = defineOneEntry('your-url');
|
|
335
335
|
```
|
|
336
336
|
|
|
337
|
+
### Blocks.getBlocks(langCode, offset, limit)
|
|
338
|
+
|
|
339
|
+
```js
|
|
340
|
+
const value = await Blocks.getBlocks('en_US', 0, 30)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
> This method return array of all blocks object.
|
|
344
|
+
|
|
345
|
+
Example return:
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
[
|
|
349
|
+
{
|
|
350
|
+
"id": 4,
|
|
351
|
+
"attributeSetId": 14,
|
|
352
|
+
"localizeInfos": {
|
|
353
|
+
"title": "Name"
|
|
354
|
+
},
|
|
355
|
+
"version": 0,
|
|
356
|
+
"position": 3,
|
|
357
|
+
"identifier": "product",
|
|
358
|
+
"type": "forProductBlock",
|
|
359
|
+
"productPageUrls": [],
|
|
360
|
+
"templateIdentifier": null,
|
|
361
|
+
"isVisible": true,
|
|
362
|
+
"attributeValues": {
|
|
363
|
+
"attr": {
|
|
364
|
+
"type": "string",
|
|
365
|
+
"value": "",
|
|
366
|
+
"position": 0,
|
|
367
|
+
"isProductPreview": false
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
"countElementsPerRow": 3,
|
|
371
|
+
"products": [
|
|
372
|
+
{
|
|
373
|
+
"id": 446,
|
|
374
|
+
"localizeInfos": {
|
|
375
|
+
"title": "new product 3"
|
|
376
|
+
},
|
|
377
|
+
"relatedIds": [1, 2],
|
|
378
|
+
"statusId": null,
|
|
379
|
+
"attributeSetId": 11,
|
|
380
|
+
"position": 3,
|
|
381
|
+
"templateIdentifier": null,
|
|
382
|
+
"shortDescTemplateIdentifier": null,
|
|
383
|
+
"price": 543,
|
|
384
|
+
"sku": "ggg",
|
|
385
|
+
"isSync": true,
|
|
386
|
+
"attributeValues": {
|
|
387
|
+
"sku": {
|
|
388
|
+
"type": "string",
|
|
389
|
+
"value": "ggg",
|
|
390
|
+
"position": 0,
|
|
391
|
+
"isProductPreview": false
|
|
392
|
+
},
|
|
393
|
+
"images": {
|
|
394
|
+
"type": "groupOfImages",
|
|
395
|
+
"value": {},
|
|
396
|
+
"position": 3,
|
|
397
|
+
"isProductPreview": false
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
"isVisible": true
|
|
401
|
+
}
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
<details>
|
|
408
|
+
<summary>Schema</summary>
|
|
409
|
+
|
|
410
|
+
**id:** number <br>
|
|
411
|
+
*object identifier*
|
|
412
|
+
example: 1764 <br>
|
|
413
|
+
|
|
414
|
+
**attributeSetId:** number <br>
|
|
415
|
+
*identifier for the used attribute set* <br>
|
|
416
|
+
example: 7 <br>
|
|
417
|
+
|
|
418
|
+
**localizeInfos:** CommonLocalizeInfos <br>
|
|
419
|
+
*block name with localization* <br>
|
|
420
|
+
example: OrderedMap { "en_US": OrderedMap { "title": "My block" } } <br>
|
|
421
|
+
|
|
422
|
+
**customSettings:** BlockCustomSettings <br>
|
|
423
|
+
*custom settings for different block types* <br>
|
|
424
|
+
example: OrderedMap { "sliderDelay": 0, "sliderDelayType": "", "productQuantity": 4, "productSortType": "By_ID", "productSortOrder": "Descending", "productCountElementsPerRow": 10, "similarProductRules": List [ OrderedMap { "property": "Descending", "includes": "", "keywords": "", "strict": "" } ] } <br>
|
|
425
|
+
|
|
426
|
+
**version:** number <br>
|
|
427
|
+
*object version number* <br>
|
|
428
|
+
example: 10 <br>
|
|
429
|
+
|
|
430
|
+
**identifier:** string <br>
|
|
431
|
+
*textual identifier for the field record* <br>
|
|
432
|
+
example: catalog <br>
|
|
433
|
+
default: marker <br>
|
|
434
|
+
|
|
435
|
+
**position:** number <br>
|
|
436
|
+
*position number (for sorting)* <br>
|
|
437
|
+
example: 192 <br>
|
|
438
|
+
|
|
439
|
+
**attributeValues:** Record<string, string> <br>
|
|
440
|
+
*array of attribute values from the index (presented as a pair of custom attribute identifier: attribute value)* <br>
|
|
441
|
+
example: OrderedMap { "en_US": OrderedMap { "marker": OrderedMap { "value": "", "type": "string" } } } <br>
|
|
442
|
+
|
|
443
|
+
**type:** string <br>
|
|
444
|
+
*block type* <br>
|
|
445
|
+
example: forNewsPage <br>
|
|
446
|
+
|
|
447
|
+
**templateIdentifier:** string <br>
|
|
448
|
+
*template marker used by the block (can be null)* <br>
|
|
449
|
+
Enum:
|
|
450
|
+
[ forCatalogProducts, forBasketPage, forErrorPage, forCatalogPages, forProductPreview, forProductPage, forSimilarProductBlock, forStatisticProductBlock, forProductBlock, forForm, forFormField, forNewsPage, forNewsBlock, forNewsPreview, forOneNewsPage, forUsualPage, forTextBlock, forSlider, service ] <br>
|
|
451
|
+
example: null <br>
|
|
452
|
+
|
|
453
|
+
</details>
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
|
|
337
457
|
### Blocks.getBlockByMarker(marker, langCode)
|
|
338
458
|
|
|
339
459
|
```js
|
|
@@ -346,38 +466,52 @@ Example return:
|
|
|
346
466
|
|
|
347
467
|
```json
|
|
348
468
|
{
|
|
349
|
-
"id":
|
|
350
|
-
"attributeSetId":
|
|
469
|
+
"id": 3,
|
|
470
|
+
"attributeSetId": null,
|
|
351
471
|
"localizeInfos": {
|
|
352
|
-
"title": "
|
|
353
|
-
},
|
|
354
|
-
"customSettings": {
|
|
355
|
-
"sliderDelay": 0,
|
|
356
|
-
"sliderDelayType": "",
|
|
357
|
-
"productQuantity": 4,
|
|
358
|
-
"productSortType": "By_ID",
|
|
359
|
-
"productSortOrder": "Descending",
|
|
360
|
-
"productCountElementsPerRow": 10,
|
|
361
|
-
"similarProductRules": [
|
|
362
|
-
{
|
|
363
|
-
"property": "Descending",
|
|
364
|
-
"includes": "",
|
|
365
|
-
"keywords": "",
|
|
366
|
-
"strict": ""
|
|
367
|
-
}
|
|
368
|
-
]
|
|
472
|
+
"title": "test"
|
|
369
473
|
},
|
|
370
|
-
"version":
|
|
371
|
-
"
|
|
372
|
-
"
|
|
373
|
-
"
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
474
|
+
"version": 0,
|
|
475
|
+
"position": 4,
|
|
476
|
+
"identifier": "test",
|
|
477
|
+
"type": "forSimilarProductBlock",
|
|
478
|
+
"productPageUrls": [],
|
|
479
|
+
"templateIdentifier": null,
|
|
480
|
+
"isVisible": true,
|
|
481
|
+
"attributeValues": {},
|
|
482
|
+
"countElementsPerRow": 4,
|
|
483
|
+
"similarProducts": [
|
|
484
|
+
{
|
|
485
|
+
"id": 446,
|
|
486
|
+
"localizeInfos": {
|
|
487
|
+
"title": "new product 3"
|
|
488
|
+
},
|
|
489
|
+
"relatedIds": [1, 2],
|
|
490
|
+
"statusId": null,
|
|
491
|
+
"attributeSetId": 11,
|
|
492
|
+
"position": 3,
|
|
493
|
+
"templateIdentifier": null,
|
|
494
|
+
"shortDescTemplateIdentifier": null,
|
|
495
|
+
"price": 543,
|
|
496
|
+
"sku": "ggg",
|
|
497
|
+
"isSync": true,
|
|
498
|
+
"attributeValues": {
|
|
499
|
+
"sku": {
|
|
500
|
+
"type": "string",
|
|
501
|
+
"value": "ggg",
|
|
502
|
+
"position": 0,
|
|
503
|
+
"isProductPreview": false
|
|
504
|
+
},
|
|
505
|
+
"images": {
|
|
506
|
+
"type": "groupOfImages",
|
|
507
|
+
"value": {},
|
|
508
|
+
"position": 3,
|
|
509
|
+
"isProductPreview": false
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
"isVisible": true
|
|
377
513
|
}
|
|
378
|
-
|
|
379
|
-
"type": "forNewsPage",
|
|
380
|
-
"templateIdentifier": null
|
|
514
|
+
]
|
|
381
515
|
}
|
|
382
516
|
```
|
|
383
517
|
|
|
@@ -430,6 +564,98 @@ example: null <br>
|
|
|
430
564
|
</details>
|
|
431
565
|
---
|
|
432
566
|
|
|
567
|
+
## Blocks.getSimilarProducts(marker, langCode, offset, limit)
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
```js
|
|
571
|
+
const value = await Blocks.getSimilarProducts('my-marker', 'en_US')
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
> This method return array of similar products from block by block marker.
|
|
575
|
+
|
|
576
|
+
Example return:
|
|
577
|
+
|
|
578
|
+
```json
|
|
579
|
+
[
|
|
580
|
+
{
|
|
581
|
+
"id": 446,
|
|
582
|
+
"localizeInfos": {
|
|
583
|
+
"title": "new product 3"
|
|
584
|
+
},
|
|
585
|
+
"relatedIds": [1, 2],
|
|
586
|
+
"statusId": null,
|
|
587
|
+
"attributeSetId": 11,
|
|
588
|
+
"position": 3,
|
|
589
|
+
"templateIdentifier": null,
|
|
590
|
+
"shortDescTemplateIdentifier": null,
|
|
591
|
+
"price": 543,
|
|
592
|
+
"sku": "ggg",
|
|
593
|
+
"isSync": true,
|
|
594
|
+
"attributeValues": {
|
|
595
|
+
"sku": {
|
|
596
|
+
"type": "string",
|
|
597
|
+
"value": "ggg",
|
|
598
|
+
"position": 0,
|
|
599
|
+
"isProductPreview": false
|
|
600
|
+
},
|
|
601
|
+
"images": {
|
|
602
|
+
"type": "groupOfImages",
|
|
603
|
+
"value": {},
|
|
604
|
+
"position": 3,
|
|
605
|
+
"isProductPreview": false
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
"isVisible": true
|
|
609
|
+
}
|
|
610
|
+
]
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
## Blocks.getSimilarProducts(marker, langCode, offset, limit)
|
|
616
|
+
|
|
617
|
+
```js
|
|
618
|
+
const value = await Blocks.getProductsByBlockMarker('my-marker', 'en_US')
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
> This method return array of products from block by block marker.
|
|
622
|
+
|
|
623
|
+
Example return:
|
|
624
|
+
|
|
625
|
+
```json
|
|
626
|
+
[
|
|
627
|
+
{
|
|
628
|
+
"id": 446,
|
|
629
|
+
"localizeInfos": {
|
|
630
|
+
"title": "new product 3"
|
|
631
|
+
},
|
|
632
|
+
"relatedIds": [1, 2],
|
|
633
|
+
"statusId": null,
|
|
634
|
+
"attributeSetId": 11,
|
|
635
|
+
"position": 3,
|
|
636
|
+
"templateIdentifier": null,
|
|
637
|
+
"shortDescTemplateIdentifier": null,
|
|
638
|
+
"price": 543,
|
|
639
|
+
"sku": "ggg",
|
|
640
|
+
"isSync": true,
|
|
641
|
+
"attributeValues": {
|
|
642
|
+
"sku": {
|
|
643
|
+
"type": "string",
|
|
644
|
+
"value": "ggg",
|
|
645
|
+
"position": 0,
|
|
646
|
+
"isProductPreview": false
|
|
647
|
+
},
|
|
648
|
+
"images": {
|
|
649
|
+
"type": "groupOfImages",
|
|
650
|
+
"value": {},
|
|
651
|
+
"position": 3,
|
|
652
|
+
"isProductPreview": false
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
"isVisible": true
|
|
656
|
+
}
|
|
657
|
+
]
|
|
658
|
+
```
|
|
433
659
|
|
|
434
660
|
|
|
435
661
|
## <h2 id="fileuploading"> FileUploading </h2>
|
|
@@ -1179,11 +1405,9 @@ Example return:
|
|
|
1179
1405
|
"id": 11,
|
|
1180
1406
|
"pageUrl": "122",
|
|
1181
1407
|
"localizeInfos": {
|
|
1182
|
-
"
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
"menuTitle": "12"
|
|
1186
|
-
}
|
|
1408
|
+
"title": "12",
|
|
1409
|
+
"content": "",
|
|
1410
|
+
"menuTitle": "12"
|
|
1187
1411
|
},
|
|
1188
1412
|
"position": 0,
|
|
1189
1413
|
"parentId": null
|
|
@@ -1216,6 +1440,7 @@ example: List [ OrderedMap { "id": 11, "pageUrl": "122", "localizeInfos": Ordere
|
|
|
1216
1440
|
|
|
1217
1441
|
## <h2 id="pages"> Pages </h2>
|
|
1218
1442
|
|
|
1443
|
+
|
|
1219
1444
|
```js
|
|
1220
1445
|
const { Pages } = defineOneEntry('your-url')
|
|
1221
1446
|
```
|
package/dist/admins/adminsApi.js
CHANGED
|
@@ -19,8 +19,8 @@ class AdminsApi extends oneEntry_1.default {
|
|
|
19
19
|
* @returns Returns all AdminEntity user objects
|
|
20
20
|
*/
|
|
21
21
|
async getAdminsInfo(langCode = this._defaultLangCode, offset = 0, limit = 30) {
|
|
22
|
-
const
|
|
23
|
-
return this._normalizeData(
|
|
22
|
+
const response = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
23
|
+
return this._normalizeData(response, langCode);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
exports.default = AdminsApi;
|
package/dist/base/oneEntry.js
CHANGED
|
@@ -7,7 +7,8 @@ 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
|
-
this._https = this._NO_FETCH ? require('https') : null
|
|
10
|
+
// this._https = this._NO_FETCH ? require('https') : null
|
|
11
|
+
this._https = null;
|
|
11
12
|
}
|
|
12
13
|
catch (e) {
|
|
13
14
|
this._https = null;
|
|
@@ -26,8 +27,7 @@ class OneEntry {
|
|
|
26
27
|
};
|
|
27
28
|
if (!this._NO_FETCH) {
|
|
28
29
|
const response = await fetch(this._getFullPath(path), options);
|
|
29
|
-
|
|
30
|
-
return result;
|
|
30
|
+
return await response.json();
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
@@ -37,6 +37,7 @@ class OneEntry {
|
|
|
37
37
|
data += chunk;
|
|
38
38
|
});
|
|
39
39
|
res.on('end', () => {
|
|
40
|
+
// const result = new Result(JSON.parse(data))
|
|
40
41
|
resolve(JSON.parse(data));
|
|
41
42
|
});
|
|
42
43
|
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Result {
|
|
4
|
+
constructor(data) {
|
|
5
|
+
this.body = data;
|
|
6
|
+
}
|
|
7
|
+
async blob() {
|
|
8
|
+
this.body = await this.body.blob();
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
async json() {
|
|
12
|
+
this.body = await typeof this.body === 'string' ? JSON.parse(this.body) : this.body.json();
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
makeDataWithoutLang(langCode, data) {
|
|
16
|
+
if (data) {
|
|
17
|
+
if (Array.isArray(data)) {
|
|
18
|
+
return data.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
for (let key in data) {
|
|
22
|
+
if (typeof data[key] === 'object' && data[key] && langCode in data[key]) {
|
|
23
|
+
data[key] = data[key][langCode];
|
|
24
|
+
}
|
|
25
|
+
else if (typeof data[key] === 'object' && data[key] != null) {
|
|
26
|
+
data[key] = this.makeDataWithoutLang(langCode, data[key]);
|
|
27
|
+
}
|
|
28
|
+
else if (Array.isArray(data[key])) {
|
|
29
|
+
data[key] = data.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
if (Array.isArray(this.body)) {
|
|
37
|
+
this.body = this.body.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
for (let key in this.body) {
|
|
41
|
+
if (typeof this.body[key] === 'object' && this.body[key] && langCode in this.body[key]) {
|
|
42
|
+
this.body[key] = this.body[key][langCode];
|
|
43
|
+
}
|
|
44
|
+
else if (typeof this.body[key] === 'object' && this.body[key] != null) {
|
|
45
|
+
this.body[key] = this.makeDataWithoutLang(langCode, this.body[key]);
|
|
46
|
+
}
|
|
47
|
+
else if (Array.isArray(this.body[key])) {
|
|
48
|
+
this.body[key] = this.body[key].map((item) => this.makeDataWithoutLang(langCode, item));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
makeDataWithoutArray(data) {
|
|
56
|
+
if (data) {
|
|
57
|
+
if (Array.isArray(data)) {
|
|
58
|
+
return data.map(item => this.makeDataWithoutArray(item));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
for (let key in data) {
|
|
62
|
+
if (Array.isArray(data[key]) && data[key].length === 1) {
|
|
63
|
+
data[key] = data[key][0];
|
|
64
|
+
}
|
|
65
|
+
else if (typeof data[key] === 'object' && data[key] && !Array.isArray(data[key])) {
|
|
66
|
+
data[key] = this.makeDataWithoutArray(data[key]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (Array.isArray(this.body)) {
|
|
74
|
+
return this.body.map(item => this.makeDataWithoutArray(item));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (let key in this.body) {
|
|
78
|
+
if (Array.isArray(this.body[key]) && this.body[key].length === 1) {
|
|
79
|
+
this.body[key] = this.body[key][0];
|
|
80
|
+
}
|
|
81
|
+
else if (typeof this.body[key] === 'object' && this.body[key] && !Array.isArray(this.body[key])) {
|
|
82
|
+
this.body[key] = this.makeDataWithoutArray(this.body[key]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.default = Result;
|
|
@@ -6,6 +6,16 @@ import { IConfig } from "../base/utils";
|
|
|
6
6
|
*/
|
|
7
7
|
export default class BlocksApi extends OneEntry implements IBlocks {
|
|
8
8
|
constructor(url: string, config: IConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Get blocks by parameters.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
13
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
14
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
15
|
+
*
|
|
16
|
+
* @returns Return array of BlocksEntity object.
|
|
17
|
+
*/
|
|
18
|
+
getBlocks(langCode?: string, offset?: number, limit?: number): Promise<Array<IBlocksEntity>>;
|
|
9
19
|
/**
|
|
10
20
|
* Get block by marker.
|
|
11
21
|
*
|
|
@@ -15,4 +25,26 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
15
25
|
* @returns Return BlocksEntity object.
|
|
16
26
|
*/
|
|
17
27
|
getBlockByMarker(marker: string, langCode?: string): Promise<IBlocksEntity>;
|
|
28
|
+
/**
|
|
29
|
+
* Get similar products by block marker.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} marker - Block identifier
|
|
32
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
33
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
34
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
35
|
+
*
|
|
36
|
+
* @returns Return array of BlocksEntity object.
|
|
37
|
+
*/
|
|
38
|
+
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* Get products by block marker.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} marker - Block identifier
|
|
43
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
44
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
45
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
46
|
+
*
|
|
47
|
+
* @returns Return array of BlocksEntity object.
|
|
48
|
+
*/
|
|
49
|
+
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<any>;
|
|
18
50
|
}
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -9,19 +9,37 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
9
9
|
super(url, config);
|
|
10
10
|
this._url += '/api/content/blocks';
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Get blocks by parameters.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
16
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
17
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
18
|
+
*
|
|
19
|
+
* @returns Return array of BlocksEntity object.
|
|
20
|
+
*/
|
|
21
|
+
async getBlocks(langCode = 'en_US', offset = 0, limit = 30) {
|
|
22
|
+
const response = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
23
|
+
const normalizeResponse = this._normalizeData(response);
|
|
24
|
+
await Promise.all(normalizeResponse.map(async (block) => {
|
|
25
|
+
const customSettings = block.customSettings;
|
|
26
|
+
if (customSettings.hasOwnProperty('productConfig')) {
|
|
27
|
+
block.countElementsPerRow = Number(customSettings.productConfig.countElementsPerRow);
|
|
28
|
+
}
|
|
29
|
+
delete block.customSettings;
|
|
30
|
+
if (block.type === 'forSimilarProductBlock') {
|
|
31
|
+
await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
|
|
32
|
+
block.similarProducts = result;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else if (block.type === 'forProductBlock') {
|
|
36
|
+
await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit).then((result) => {
|
|
37
|
+
block.products = result;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
return normalizeResponse;
|
|
42
|
+
}
|
|
25
43
|
/**
|
|
26
44
|
* Get block by marker.
|
|
27
45
|
*
|
|
@@ -31,8 +49,52 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
31
49
|
* @returns Return BlocksEntity object.
|
|
32
50
|
*/
|
|
33
51
|
async getBlockByMarker(marker, langCode = this._defaultLangCode) {
|
|
34
|
-
const
|
|
35
|
-
|
|
52
|
+
const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
53
|
+
const normalizeResponse = this._normalizeData(response);
|
|
54
|
+
const customSettings = normalizeResponse.customSettings;
|
|
55
|
+
if (customSettings.hasOwnProperty('productConfig')) {
|
|
56
|
+
normalizeResponse.countElementsPerRow = Number(customSettings.productConfig.countElementsPerRow);
|
|
57
|
+
}
|
|
58
|
+
delete normalizeResponse.customSettings;
|
|
59
|
+
if (normalizeResponse.type === 'forSimilarProductBlock') {
|
|
60
|
+
await this.getSimilarProducts(normalizeResponse.identifier, langCode).then((result) => {
|
|
61
|
+
normalizeResponse.similarProducts = result;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else if (normalizeResponse.type === 'forProductBlock') {
|
|
65
|
+
await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode).then((result) => {
|
|
66
|
+
normalizeResponse.products = result;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return normalizeResponse;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get similar products by block marker.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} marker - Block identifier
|
|
75
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
76
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
77
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
78
|
+
*
|
|
79
|
+
* @returns Return array of BlocksEntity object.
|
|
80
|
+
*/
|
|
81
|
+
async getSimilarProducts(marker, langCode = 'en_US', offset = 0, limit = 30) {
|
|
82
|
+
const result = await this._fetchGet(`/${marker}/similar-products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
83
|
+
return this._normalizeData(result.items);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get products by block marker.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} marker - Block identifier
|
|
89
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
90
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
91
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
92
|
+
*
|
|
93
|
+
* @returns Return array of BlocksEntity object.
|
|
94
|
+
*/
|
|
95
|
+
async getProductsByBlockMarker(marker, langCode = 'en_US', offset = 0, limit = 30) {
|
|
96
|
+
const result = await this._fetchGet(`/${marker}/products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
97
|
+
return this._normalizeData(result.items);
|
|
36
98
|
}
|
|
37
99
|
}
|
|
38
100
|
exports.default = BlocksApi;
|
|
@@ -3,9 +3,29 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @property {function} getBlocks - Get all Blocks objects.
|
|
5
5
|
* @property {function} getBlockByMarker - Get Block object by marker.
|
|
6
|
+
* @property {function} getSimilarProducts - Get Array of similar products from product-similar block.
|
|
7
|
+
* @property {function} getProductsByBlockMarker - Get Array of products from product block.
|
|
6
8
|
*/
|
|
7
9
|
interface IBlocks {
|
|
10
|
+
getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<IBlocksEntity>>;
|
|
8
11
|
getBlockByMarker(marker: string, langCode: string): Promise<IBlocksEntity>;
|
|
12
|
+
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<ISimilarProduct>>;
|
|
13
|
+
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<ISimilarProduct>>;
|
|
14
|
+
}
|
|
15
|
+
interface ISimilarProduct {
|
|
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;
|
|
9
29
|
}
|
|
10
30
|
interface IBlocksEntity {
|
|
11
31
|
id: number;
|
|
@@ -19,6 +39,9 @@ interface IBlocksEntity {
|
|
|
19
39
|
attributeValues: Record<string, any>;
|
|
20
40
|
type: string;
|
|
21
41
|
templateIdentifier: string | null;
|
|
42
|
+
countElementsPerRow?: number;
|
|
43
|
+
similarProducts?: Array<ISimilarProduct>;
|
|
44
|
+
products?: Array<ISimilarProduct>;
|
|
22
45
|
}
|
|
23
46
|
interface ICustomSetting {
|
|
24
47
|
sliderDelay: number;
|
|
@@ -33,5 +56,6 @@ interface ICustomSetting {
|
|
|
33
56
|
keywords: string;
|
|
34
57
|
strict: string;
|
|
35
58
|
}> | Record<string, any>;
|
|
59
|
+
[key: string]: any;
|
|
36
60
|
}
|
|
37
61
|
export { IBlocks, IBlocksEntity };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import OneEntry from "../base/oneEntry";
|
|
2
|
+
import { IGeneralTypes, IGeneralTypesEntity } from "./generalTypesInterfaces";
|
|
3
|
+
import { IConfig } from "../base/utils";
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with types
|
|
6
|
+
*/
|
|
7
|
+
export default class GeneralTypesApi extends OneEntry implements IGeneralTypes {
|
|
8
|
+
constructor(url: string, config: IConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Get all types.
|
|
11
|
+
*
|
|
12
|
+
* @returns Returns all objects of type GeneralTypeEntity
|
|
13
|
+
*/
|
|
14
|
+
getAllTypes(): Promise<Array<IGeneralTypesEntity>>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const oneEntry_1 = require("../base/oneEntry");
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with types
|
|
6
|
+
*/
|
|
7
|
+
class GeneralTypesApi extends oneEntry_1.default {
|
|
8
|
+
constructor(url, config) {
|
|
9
|
+
super(url, config);
|
|
10
|
+
this._url += '/api/content/general-types';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get all types.
|
|
14
|
+
*
|
|
15
|
+
* @returns Returns all objects of type GeneralTypeEntity
|
|
16
|
+
*/
|
|
17
|
+
async getAllTypes() {
|
|
18
|
+
const result = await this._fetchGet('');
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = GeneralTypesApi;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import ProductStatusesApi from "./product-statuses/productStatusesApi";
|
|
|
4
4
|
import TemplatesApi from "./templates/templatesApi";
|
|
5
5
|
import TemplatePreviewsApi from "./templates-preview/templatesPreviewApi";
|
|
6
6
|
import AdminsApi from "./admins/adminsApi";
|
|
7
|
-
import GeneralTypesApi from "./general-types/
|
|
7
|
+
import GeneralTypesApi from "./general-types/typesApi";
|
|
8
8
|
import LocalesApi from "./locales/localesApi";
|
|
9
9
|
import MenusApi from "./menus/menusApi";
|
|
10
10
|
import FormsApi from "./forms/formsApi";
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const productStatusesApi_1 = require("./product-statuses/productStatusesApi");
|
|
|
7
7
|
const templatesApi_1 = require("./templates/templatesApi");
|
|
8
8
|
const templatesPreviewApi_1 = require("./templates-preview/templatesPreviewApi");
|
|
9
9
|
const adminsApi_1 = require("./admins/adminsApi");
|
|
10
|
-
const
|
|
10
|
+
const typesApi_1 = require("./general-types/typesApi");
|
|
11
11
|
const localesApi_1 = require("./locales/localesApi");
|
|
12
12
|
const menusApi_1 = require("./menus/menusApi");
|
|
13
13
|
const formsApi_1 = require("./forms/formsApi");
|
|
@@ -32,7 +32,7 @@ function defineOneEntry(url, config) {
|
|
|
32
32
|
const FileUploading = new fileUploadingApi_1.default(url, config);
|
|
33
33
|
const Forms = new formsApi_1.default(url, config);
|
|
34
34
|
const FormData = new formsDataApi_1.default(url, config);
|
|
35
|
-
const GeneralTypes = new
|
|
35
|
+
const GeneralTypes = new typesApi_1.default(url, config);
|
|
36
36
|
const Locales = new localesApi_1.default(url, config);
|
|
37
37
|
const Markers = new markersApi_1.default(url, config);
|
|
38
38
|
const Menus = new menusApi_1.default(url, config);
|
package/dist/pages/pagesApi.js
CHANGED
|
@@ -18,7 +18,8 @@ class PageApi extends oneEntry_1.default {
|
|
|
18
18
|
*/
|
|
19
19
|
async getRootPages(langCode = this._defaultLangCode) {
|
|
20
20
|
const result = await this._fetchGet(`/root?langCode=${langCode}`);
|
|
21
|
-
|
|
21
|
+
console.log(result);
|
|
22
|
+
return this._normalizeData(result, langCode);
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Get all page objects with product information as an array.
|
|
@@ -33,7 +34,7 @@ class PageApi extends oneEntry_1.default {
|
|
|
33
34
|
*/
|
|
34
35
|
async getCatalogPages(langCode = this._defaultLangCode, limit = 30, offset = 0) {
|
|
35
36
|
const result = await this._fetchGet(`/catalog?langCode=${langCode}&limit=${limit}&offset=${offset}`);
|
|
36
|
-
return this._normalizeData(result
|
|
37
|
+
return this._normalizeData(result, langCode);
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Get all page objects with product information as an array.
|
|
@@ -83,7 +84,7 @@ class PageApi extends oneEntry_1.default {
|
|
|
83
84
|
*/
|
|
84
85
|
async getChildPagesByParentUrl(url, langCode = this._defaultLangCode) {
|
|
85
86
|
const result = await this._fetchGet(`/${url}/children?langCode=${langCode}`);
|
|
86
|
-
return this._normalizeData(result
|
|
87
|
+
return this._normalizeData(result, langCode);
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
89
90
|
* Get all forms by page url.
|