@websolutespa/bom-mixer-store 0.3.1 → 0.3.2
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/CHANGELOG.md +43 -37
- package/dist/index.js +37 -29
- package/dist/index.mjs +37 -29
- package/package.json +1 -1
- package/src/mock/mock-menu.service.ts +42 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-store
|
|
2
|
-
|
|
3
|
-
## 0.3.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
## 0.3.
|
|
10
|
-
|
|
11
|
-
###
|
|
12
|
-
|
|
13
|
-
- Added:
|
|
14
|
-
|
|
15
|
-
## 0.
|
|
16
|
-
|
|
17
|
-
### Minor Changes
|
|
18
|
-
|
|
19
|
-
- Added:
|
|
20
|
-
|
|
21
|
-
## 0.
|
|
22
|
-
|
|
23
|
-
###
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
## 0.1.
|
|
28
|
-
|
|
29
|
-
###
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
## 0.0
|
|
34
|
-
|
|
35
|
-
###
|
|
36
|
-
|
|
37
|
-
-
|
|
1
|
+
# @websolutespa/bom-mixer-store
|
|
2
|
+
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: MockMenuService.
|
|
8
|
+
|
|
9
|
+
## 0.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Added: source files.
|
|
14
|
+
|
|
15
|
+
## 0.3.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Added: splat routes.
|
|
20
|
+
|
|
21
|
+
## 0.2.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- Added: @websolutespa/bom-core.
|
|
26
|
+
|
|
27
|
+
## 0.1.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Modified: store service.
|
|
32
|
+
|
|
33
|
+
## 0.1.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- mock refactor.
|
|
38
|
+
|
|
39
|
+
## 0.0.2
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Added: first release.
|
package/dist/index.js
CHANGED
|
@@ -573,6 +573,26 @@ var MockMenuService = class extends MockService {
|
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
575
|
};
|
|
576
|
+
async function collectPages(store, items) {
|
|
577
|
+
if (!items) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
for (const item of items) {
|
|
581
|
+
if (item.type === "page" && typeof item.page.value === "number" && store[item.page.relationTo] !== void 0) {
|
|
582
|
+
const value = await store[item.page.relationTo].findOne(item.page.value);
|
|
583
|
+
if (value) {
|
|
584
|
+
item.page.value = value;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
switch (item.type) {
|
|
588
|
+
case "group":
|
|
589
|
+
case "link":
|
|
590
|
+
case "page":
|
|
591
|
+
await collectPages(store, item.items);
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
576
596
|
async function decorateMenu(store, item, market = "ww", locale = "en") {
|
|
577
597
|
const items = item.items || [];
|
|
578
598
|
const decoratedItem = {
|
|
@@ -590,27 +610,7 @@ async function decorateMenu(store, item, market = "ww", locale = "en") {
|
|
|
590
610
|
}
|
|
591
611
|
}
|
|
592
612
|
});
|
|
593
|
-
|
|
594
|
-
if (!items2) {
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
for (const item2 of items2) {
|
|
598
|
-
if (item2.type === "page" && typeof item2.page.value === "number" && store[item2.page.relationTo] !== void 0) {
|
|
599
|
-
const value = await store[item2.page.relationTo].findOne(item2.page.value);
|
|
600
|
-
if (value) {
|
|
601
|
-
item2.page.value = value;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
switch (item2.type) {
|
|
605
|
-
case "group":
|
|
606
|
-
case "link":
|
|
607
|
-
case "page":
|
|
608
|
-
await collectPages(item2.items);
|
|
609
|
-
break;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
await collectPages(items);
|
|
613
|
+
await collectPages(store, items);
|
|
614
614
|
decoratedItem.items = items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem(x, categories, routes, market));
|
|
615
615
|
return decoratedItem;
|
|
616
616
|
}
|
|
@@ -619,12 +619,14 @@ async function decorateMenus(store, items, market = "ww", locale = "en") {
|
|
|
619
619
|
}
|
|
620
620
|
function decorateMenuCategory(item, categories, routes, market, depth = 0) {
|
|
621
621
|
const decoratedItem = {
|
|
622
|
-
|
|
623
|
-
type: item.type,
|
|
624
|
-
title: "",
|
|
622
|
+
abstract: item.abstract,
|
|
625
623
|
category: "",
|
|
624
|
+
customClass: item.customClass,
|
|
626
625
|
href: "",
|
|
627
|
-
|
|
626
|
+
id: item.id || "",
|
|
627
|
+
items: [],
|
|
628
|
+
title: "",
|
|
629
|
+
type: item.type
|
|
628
630
|
};
|
|
629
631
|
const category = typeof item.category === "string" ? categories.find((x) => x.id === item.category) : item.category;
|
|
630
632
|
if (category) {
|
|
@@ -680,9 +682,11 @@ function decorateMenuRoute(item) {
|
|
|
680
682
|
function decorateMenuGroup(item, categories, routes, market) {
|
|
681
683
|
const items = item.items || [];
|
|
682
684
|
const decoratedItem = {
|
|
685
|
+
abstract: item.abstract,
|
|
686
|
+
customClass: item.customClass,
|
|
683
687
|
id: item.id || "",
|
|
684
|
-
type: item.type,
|
|
685
688
|
title: item.title,
|
|
689
|
+
type: item.type,
|
|
686
690
|
items: items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem(x, categories, routes, market))
|
|
687
691
|
};
|
|
688
692
|
return decoratedItem;
|
|
@@ -690,11 +694,13 @@ function decorateMenuGroup(item, categories, routes, market) {
|
|
|
690
694
|
function decorateMenuLink(item, categories, routes, market) {
|
|
691
695
|
const items = item.items || [];
|
|
692
696
|
const decoratedItem = {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
title: item.title,
|
|
697
|
+
abstract: item.abstract,
|
|
698
|
+
customClass: item.customClass,
|
|
696
699
|
href: item.href,
|
|
700
|
+
id: item.id || "",
|
|
697
701
|
target: item.target || "",
|
|
702
|
+
title: item.title,
|
|
703
|
+
type: item.type,
|
|
698
704
|
items: items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem(x, categories, routes, market))
|
|
699
705
|
};
|
|
700
706
|
return decoratedItem;
|
|
@@ -706,6 +712,8 @@ function decorateMenuPage(item, categories, routes, market) {
|
|
|
706
712
|
id: item.id || "",
|
|
707
713
|
type: item.type,
|
|
708
714
|
title: item.title || item.page.value.title || "",
|
|
715
|
+
abstract: item.abstract || item.page.value.abstract || "",
|
|
716
|
+
customClass: item.customClass,
|
|
709
717
|
href: route?.id || "",
|
|
710
718
|
media: item.page.value.media,
|
|
711
719
|
page: route?.page || "",
|
package/dist/index.mjs
CHANGED
|
@@ -523,6 +523,26 @@ var MockMenuService = class extends MockService {
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
};
|
|
526
|
+
async function collectPages(store, items) {
|
|
527
|
+
if (!items) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
for (const item of items) {
|
|
531
|
+
if (item.type === "page" && typeof item.page.value === "number" && store[item.page.relationTo] !== void 0) {
|
|
532
|
+
const value = await store[item.page.relationTo].findOne(item.page.value);
|
|
533
|
+
if (value) {
|
|
534
|
+
item.page.value = value;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
switch (item.type) {
|
|
538
|
+
case "group":
|
|
539
|
+
case "link":
|
|
540
|
+
case "page":
|
|
541
|
+
await collectPages(store, item.items);
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
526
546
|
async function decorateMenu(store, item, market = "ww", locale = "en") {
|
|
527
547
|
const items = item.items || [];
|
|
528
548
|
const decoratedItem = {
|
|
@@ -540,27 +560,7 @@ async function decorateMenu(store, item, market = "ww", locale = "en") {
|
|
|
540
560
|
}
|
|
541
561
|
}
|
|
542
562
|
});
|
|
543
|
-
|
|
544
|
-
if (!items2) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
for (const item2 of items2) {
|
|
548
|
-
if (item2.type === "page" && typeof item2.page.value === "number" && store[item2.page.relationTo] !== void 0) {
|
|
549
|
-
const value = await store[item2.page.relationTo].findOne(item2.page.value);
|
|
550
|
-
if (value) {
|
|
551
|
-
item2.page.value = value;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
switch (item2.type) {
|
|
555
|
-
case "group":
|
|
556
|
-
case "link":
|
|
557
|
-
case "page":
|
|
558
|
-
await collectPages(item2.items);
|
|
559
|
-
break;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
await collectPages(items);
|
|
563
|
+
await collectPages(store, items);
|
|
564
564
|
decoratedItem.items = items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem(x, categories, routes, market));
|
|
565
565
|
return decoratedItem;
|
|
566
566
|
}
|
|
@@ -569,12 +569,14 @@ async function decorateMenus(store, items, market = "ww", locale = "en") {
|
|
|
569
569
|
}
|
|
570
570
|
function decorateMenuCategory(item, categories, routes, market, depth = 0) {
|
|
571
571
|
const decoratedItem = {
|
|
572
|
-
|
|
573
|
-
type: item.type,
|
|
574
|
-
title: "",
|
|
572
|
+
abstract: item.abstract,
|
|
575
573
|
category: "",
|
|
574
|
+
customClass: item.customClass,
|
|
576
575
|
href: "",
|
|
577
|
-
|
|
576
|
+
id: item.id || "",
|
|
577
|
+
items: [],
|
|
578
|
+
title: "",
|
|
579
|
+
type: item.type
|
|
578
580
|
};
|
|
579
581
|
const category = typeof item.category === "string" ? categories.find((x) => x.id === item.category) : item.category;
|
|
580
582
|
if (category) {
|
|
@@ -630,9 +632,11 @@ function decorateMenuRoute(item) {
|
|
|
630
632
|
function decorateMenuGroup(item, categories, routes, market) {
|
|
631
633
|
const items = item.items || [];
|
|
632
634
|
const decoratedItem = {
|
|
635
|
+
abstract: item.abstract,
|
|
636
|
+
customClass: item.customClass,
|
|
633
637
|
id: item.id || "",
|
|
634
|
-
type: item.type,
|
|
635
638
|
title: item.title,
|
|
639
|
+
type: item.type,
|
|
636
640
|
items: items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem(x, categories, routes, market))
|
|
637
641
|
};
|
|
638
642
|
return decoratedItem;
|
|
@@ -640,11 +644,13 @@ function decorateMenuGroup(item, categories, routes, market) {
|
|
|
640
644
|
function decorateMenuLink(item, categories, routes, market) {
|
|
641
645
|
const items = item.items || [];
|
|
642
646
|
const decoratedItem = {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
title: item.title,
|
|
647
|
+
abstract: item.abstract,
|
|
648
|
+
customClass: item.customClass,
|
|
646
649
|
href: item.href,
|
|
650
|
+
id: item.id || "",
|
|
647
651
|
target: item.target || "",
|
|
652
|
+
title: item.title,
|
|
653
|
+
type: item.type,
|
|
648
654
|
items: items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem(x, categories, routes, market))
|
|
649
655
|
};
|
|
650
656
|
return decoratedItem;
|
|
@@ -656,6 +662,8 @@ function decorateMenuPage(item, categories, routes, market) {
|
|
|
656
662
|
id: item.id || "",
|
|
657
663
|
type: item.type,
|
|
658
664
|
title: item.title || item.page.value.title || "",
|
|
665
|
+
abstract: item.abstract || item.page.value.abstract || "",
|
|
666
|
+
customClass: item.customClass,
|
|
659
667
|
href: route?.id || "",
|
|
660
668
|
media: item.page.value.media,
|
|
661
669
|
page: route?.page || "",
|
package/package.json
CHANGED
|
@@ -48,6 +48,32 @@ export class MockMenuService<T extends IEntity = IEntity> extends MockService<T>
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
|
|
52
|
+
async function collectPages(store: IStore, items?: IUndecoratedMenuItem[]) {
|
|
53
|
+
if (!items) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
if (
|
|
58
|
+
item.type === 'page' &&
|
|
59
|
+
typeof item.page.value === 'number' &&
|
|
60
|
+
store[item.page.relationTo] !== undefined
|
|
61
|
+
) {
|
|
62
|
+
const value = await store[item.page.relationTo].findOne<ICategorized>(item.page.value);
|
|
63
|
+
if (value) {
|
|
64
|
+
item.page.value = value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
switch (item.type) {
|
|
68
|
+
case 'group':
|
|
69
|
+
case 'link':
|
|
70
|
+
case 'page':
|
|
71
|
+
await collectPages(store, item.items);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
51
77
|
export async function decorateMenu(store: IStore, item: IUndecoratedMenu, market: string = 'ww', locale: string = 'en'): Promise<IMenu> {
|
|
52
78
|
const items = item.items || [];
|
|
53
79
|
const decoratedItem: IMenu = {
|
|
@@ -65,31 +91,7 @@ export async function decorateMenu(store: IStore, item: IUndecoratedMenu, market
|
|
|
65
91
|
}
|
|
66
92
|
}
|
|
67
93
|
});
|
|
68
|
-
|
|
69
|
-
if (!items) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
for (const item of items) {
|
|
73
|
-
if (
|
|
74
|
-
item.type === 'page' &&
|
|
75
|
-
typeof item.page.value === 'number' &&
|
|
76
|
-
store[item.page.relationTo] !== undefined
|
|
77
|
-
) {
|
|
78
|
-
const value = await store[item.page.relationTo].findOne<ICategorized>(item.page.value);
|
|
79
|
-
if (value) {
|
|
80
|
-
item.page.value = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
switch (item.type) {
|
|
84
|
-
case 'group':
|
|
85
|
-
case 'link':
|
|
86
|
-
case 'page':
|
|
87
|
-
await collectPages(item.items);
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
await collectPages(items);
|
|
94
|
+
await collectPages(store, items);
|
|
93
95
|
decoratedItem.items = items.filter(x => hasMarket(x, market)).map(x => decorateMenuItem(x, categories, routes, market));
|
|
94
96
|
return decoratedItem;
|
|
95
97
|
}
|
|
@@ -106,12 +108,14 @@ export function decorateMenuCategory(
|
|
|
106
108
|
depth: number = 0,
|
|
107
109
|
): IMenuItem {
|
|
108
110
|
const decoratedItem: IMenuCategory = {
|
|
109
|
-
|
|
110
|
-
type: item.type,
|
|
111
|
-
title: '',
|
|
111
|
+
abstract: item.abstract,
|
|
112
112
|
category: '',
|
|
113
|
+
customClass: item.customClass,
|
|
113
114
|
href: '',
|
|
115
|
+
id: item.id || '',
|
|
114
116
|
items: [],
|
|
117
|
+
title: '',
|
|
118
|
+
type: item.type,
|
|
115
119
|
};
|
|
116
120
|
const category = (typeof item.category === 'string' ? categories.find(x => x.id === item.category) : item.category) as ICategory;
|
|
117
121
|
if (category) {
|
|
@@ -191,9 +195,11 @@ export function decorateMenuGroup(
|
|
|
191
195
|
): IMenuItem {
|
|
192
196
|
const items = item.items || [];
|
|
193
197
|
const decoratedItem: IMenuGroup = {
|
|
198
|
+
abstract: item.abstract,
|
|
199
|
+
customClass: item.customClass,
|
|
194
200
|
id: item.id || '',
|
|
195
|
-
type: item.type,
|
|
196
201
|
title: item.title,
|
|
202
|
+
type: item.type,
|
|
197
203
|
items: items.filter(x => hasMarket(x, market)).map(x => decorateMenuItem(x, categories, routes, market)),
|
|
198
204
|
};
|
|
199
205
|
return decoratedItem;
|
|
@@ -207,11 +213,13 @@ export function decorateMenuLink(
|
|
|
207
213
|
): IMenuItem {
|
|
208
214
|
const items = item.items || [];
|
|
209
215
|
const decoratedItem: IMenuLink = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
title: item.title,
|
|
216
|
+
abstract: item.abstract,
|
|
217
|
+
customClass: item.customClass,
|
|
213
218
|
href: item.href,
|
|
219
|
+
id: item.id || '',
|
|
214
220
|
target: item.target || '',
|
|
221
|
+
title: item.title,
|
|
222
|
+
type: item.type,
|
|
215
223
|
items: items.filter(x => hasMarket(x, market)).map(x => decorateMenuItem(x, categories, routes, market)),
|
|
216
224
|
};
|
|
217
225
|
return decoratedItem;
|
|
@@ -229,6 +237,8 @@ export function decorateMenuPage(
|
|
|
229
237
|
id: item.id || '',
|
|
230
238
|
type: item.type,
|
|
231
239
|
title: item.title || item.page.value.title || '',
|
|
240
|
+
abstract: item.abstract || item.page.value.abstract || '',
|
|
241
|
+
customClass: item.customClass,
|
|
232
242
|
href: route?.id || '',
|
|
233
243
|
media: item.page.value.media,
|
|
234
244
|
page: route?.page || '',
|