@websolutespa/bom-mixer-store 1.2.0 → 1.2.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 CHANGED
@@ -1,73 +1,85 @@
1
- # @websolutespa/bom-mixer-store
2
-
3
- ## 1.2.0
4
-
5
- ### Minor Changes
6
-
7
- - Updating: next 13.
8
-
9
- ## 1.1.1
10
-
11
- ### Patch Changes
12
-
13
- - Fixing: check redirects by pattern.
14
-
15
- ## 1.1.0
16
-
17
- ### Minor Changes
18
-
19
- - Modified: store refactor.
20
-
21
- ## 1.0.1
22
-
23
- ### Patch Changes
24
-
25
- - Fixing: localhost url.
26
-
27
- ## 1.0.0
28
-
29
- ### Minor Changes
30
-
31
- - Modified routes, added redirects.
32
-
33
- ## 0.3.2
34
-
35
- ### Patch Changes
36
-
37
- - Modified: MockMenuService.
38
-
39
- ## 0.3.1
40
-
41
- ### Patch Changes
42
-
43
- - Added: source files.
44
-
45
- ## 0.3.0
46
-
47
- ### Minor Changes
48
-
49
- - Added: splat routes.
50
-
51
- ## 0.2.0
52
-
53
- ### Minor Changes
54
-
55
- - Added: @websolutespa/bom-core.
56
-
57
- ## 0.1.1
58
-
59
- ### Patch Changes
60
-
61
- - Modified: store service.
62
-
63
- ## 0.1.0
64
-
65
- ### Minor Changes
66
-
67
- - mock refactor.
68
-
69
- ## 0.0.2
70
-
71
- ### Patch Changes
72
-
73
- - Added: first release.
1
+ # @websolutespa/bom-mixer-store
2
+
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: MockMenuService IPageRelationResult.
8
+
9
+ ## 1.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixing: MockMenuService collectPages.
14
+
15
+ ## 1.2.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Updating: next 13.
20
+
21
+ ## 1.1.1
22
+
23
+ ### Patch Changes
24
+
25
+ - Fixing: check redirects by pattern.
26
+
27
+ ## 1.1.0
28
+
29
+ ### Minor Changes
30
+
31
+ - Modified: store refactor.
32
+
33
+ ## 1.0.1
34
+
35
+ ### Patch Changes
36
+
37
+ - Fixing: localhost url.
38
+
39
+ ## 1.0.0
40
+
41
+ ### Minor Changes
42
+
43
+ - Modified routes, added redirects.
44
+
45
+ ## 0.3.2
46
+
47
+ ### Patch Changes
48
+
49
+ - Modified: MockMenuService.
50
+
51
+ ## 0.3.1
52
+
53
+ ### Patch Changes
54
+
55
+ - Added: source files.
56
+
57
+ ## 0.3.0
58
+
59
+ ### Minor Changes
60
+
61
+ - Added: splat routes.
62
+
63
+ ## 0.2.0
64
+
65
+ ### Minor Changes
66
+
67
+ - Added: @websolutespa/bom-core.
68
+
69
+ ## 0.1.1
70
+
71
+ ### Patch Changes
72
+
73
+ - Modified: store service.
74
+
75
+ ## 0.1.0
76
+
77
+ ### Minor Changes
78
+
79
+ - mock refactor.
80
+
81
+ ## 0.0.2
82
+
83
+ ### Patch Changes
84
+
85
+ - Added: first release.
package/dist/index.js CHANGED
@@ -695,9 +695,25 @@ async function collectPages(store, items, params = {}) {
695
695
  }
696
696
  for (const item of items) {
697
697
  if (item.type === "page" && typeof item.page.value === "number" && store[item.page.relationTo] !== void 0) {
698
- const value = await store[item.page.relationTo].findOne(item.page.value, params);
698
+ const value = await store[item.page.relationTo].findOne(item.page.value, { ...params });
699
699
  if (value) {
700
- item.page.value = value;
700
+ const routes = await store.route.findMany({
701
+ where: {
702
+ page: {
703
+ equals: item.page.value
704
+ },
705
+ schema: {
706
+ equals: item.page.relationTo
707
+ }
708
+ },
709
+ market: params.market,
710
+ locale: params.locale
711
+ });
712
+ const page = {
713
+ ...value,
714
+ href: routes.length > 0 ? routes[0].id : ""
715
+ };
716
+ item.page.value = page;
701
717
  }
702
718
  }
703
719
  switch (item.type) {
package/dist/index.mjs CHANGED
@@ -616,9 +616,25 @@ async function collectPages(store, items, params = {}) {
616
616
  }
617
617
  for (const item of items) {
618
618
  if (item.type === "page" && typeof item.page.value === "number" && store[item.page.relationTo] !== void 0) {
619
- const value = await store[item.page.relationTo].findOne(item.page.value, params);
619
+ const value = await store[item.page.relationTo].findOne(item.page.value, { ...params });
620
620
  if (value) {
621
- item.page.value = value;
621
+ const routes = await store.route.findMany({
622
+ where: {
623
+ page: {
624
+ equals: item.page.value
625
+ },
626
+ schema: {
627
+ equals: item.page.relationTo
628
+ }
629
+ },
630
+ market: params.market,
631
+ locale: params.locale
632
+ });
633
+ const page = {
634
+ ...value,
635
+ href: routes.length > 0 ? routes[0].id : ""
636
+ };
637
+ item.page.value = page;
622
638
  }
623
639
  }
624
640
  switch (item.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -59,9 +59,27 @@ async function collectPages(store: IStore, items?: IUndecoratedMenuItem[], param
59
59
  typeof item.page.value === 'number' &&
60
60
  store[item.page.relationTo] !== undefined
61
61
  ) {
62
- const value = await store[item.page.relationTo].findOne<ICategorized>(item.page.value, params);
62
+ // console.log('collectPages', item.page.relationTo, item.page.value);
63
+ // !!! cloned params due to recursion
64
+ const value = await store[item.page.relationTo].findOne<ICategorized>(item.page.value, { ...params });
63
65
  if (value) {
64
- item.page.value = value;
66
+ const routes = await store.route.findMany<IRoute>({
67
+ where: {
68
+ page: {
69
+ equals: item.page.value,
70
+ },
71
+ schema: {
72
+ equals: item.page.relationTo,
73
+ },
74
+ },
75
+ market: params.market,
76
+ locale: params.locale,
77
+ });
78
+ const page = {
79
+ ...value,
80
+ href: routes.length > 0 ? routes[0].id : '',
81
+ };
82
+ item.page.value = page;
65
83
  }
66
84
  }
67
85
  switch (item.type) {
@@ -88,9 +106,9 @@ export async function decorateMenu(store: IStore, item: IUndecoratedMenu, market
88
106
  },
89
107
  locale: {
90
108
  equals: locale,
91
- }
109
+ },
92
110
  },
93
- market, locale
111
+ market, locale,
94
112
  });
95
113
  await collectPages(store, items, { market, locale });
96
114
  decoratedItem.items = items.filter(x => hasMarket(x, market)).map(x => decorateMenuItem(x, categories, routes, market));
@@ -106,7 +124,7 @@ export function decorateMenuCategory(
106
124
  categories: ICategory[],
107
125
  routes: IRoute[],
108
126
  market: string,
109
- depth: number = 0,
127
+ depth: number = 0
110
128
  ): IMenuItem {
111
129
  const decoratedItem: IMenuCategory = {
112
130
  abstract: item.abstract,
@@ -174,7 +192,7 @@ export function decorateMenuCategory(
174
192
  }
175
193
 
176
194
  export function decorateMenuRoute(
177
- item: IRoute,
195
+ item: IRoute
178
196
  ): IMenuItem {
179
197
  const decoratedItem: IMenuRoute = {
180
198
  id: item.page,
@@ -192,7 +210,7 @@ export function decorateMenuGroup(
192
210
  item: IUndecoratedMenuGroup,
193
211
  categories: ICategory[],
194
212
  routes: IRoute[],
195
- market: string,
213
+ market: string
196
214
  ): IMenuItem {
197
215
  const items = item.items || [];
198
216
  const decoratedItem: IMenuGroup = {
@@ -210,7 +228,7 @@ export function decorateMenuLink(
210
228
  item: IUndecoratedMenuLink,
211
229
  categories: ICategory[],
212
230
  routes: IRoute[],
213
- market: string,
231
+ market: string
214
232
  ): IMenuItem {
215
233
  const items = item.items || [];
216
234
  const decoratedItem: IMenuLink = {
@@ -230,7 +248,7 @@ export function decorateMenuPage(
230
248
  item: IUndecoratedMenuPage,
231
249
  categories: ICategory[],
232
250
  routes: IRoute[],
233
- market: string,
251
+ market: string
234
252
  ): IMenuItem {
235
253
  const items = item.items || [];
236
254
  const route = routes.find(x => x.schema === item.page.relationTo && x.page === item.page.value.id);
@@ -254,7 +272,7 @@ export function decorateMenuItem(
254
272
  categories: ICategory[],
255
273
  routes: IRoute[],
256
274
  market: string,
257
- depth: number = 0,
275
+ depth: number = 0
258
276
  ): IMenuItem {
259
277
  let decoratedItem: IMenuItem;
260
278
  switch (item.type) {