@websolutespa/bom-mixer-models 1.3.0 → 1.4.0
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 +6 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +34 -24
- package/dist/index.mjs +33 -24
- package/package.json +1 -1
- package/src/layout/layout.service.ts +7 -7
- package/src/route/route.service.ts +31 -20
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -291,6 +291,7 @@ declare function getRoutesForTemplates(templates: string[], market?: string, loc
|
|
|
291
291
|
declare function getStaticPathsForSchema(schema: string): Promise<StaticPath[]>;
|
|
292
292
|
declare function getBreadcrumbFromSegments(segments: ICategory[], market?: string, locale?: string): Promise<IRouteLink[]>;
|
|
293
293
|
declare function getRouteLinkTree(market?: string, locale?: string): Promise<IRouteLink | undefined>;
|
|
294
|
+
declare function newRouteLink(category: ICategory, route?: IRoute, locale?: string): IRouteLink;
|
|
294
295
|
declare function categoryToRouteLink(routes: IRoute[], categories: ICategory[], category: ICategory, locale?: string): IRouteLink;
|
|
295
296
|
declare function resolveRoute(route: IRoute & {
|
|
296
297
|
splat?: string;
|
|
@@ -324,4 +325,4 @@ type IModelStore = {
|
|
|
324
325
|
[key: string]: IQuerable<IEntity>;
|
|
325
326
|
};
|
|
326
327
|
|
|
327
|
-
export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore, ICompanyAddress, IFeatureType, IKeyedList, ILazyComponent, ILazyComponentProps, ILazyModules, ILazyProps, ILazyableProps, ILazyedProps, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, StaticPath, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCategories, getCategory, getCountries, getCountry, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getPage, getPageCategory, getPageRoutes, getPayment, getPayments, getProvince, getProvinces, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, resolveLabel, resolveRoute, routeInterceptor, routeRevalidateHandler, setDiscountCode, updateCheckout };
|
|
328
|
+
export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore, ICompanyAddress, IFeatureType, IKeyedList, ILazyComponent, ILazyComponentProps, ILazyModules, ILazyProps, ILazyableProps, ILazyedProps, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, StaticPath, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCategories, getCategory, getCountries, getCountry, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getPage, getPageCategory, getPageRoutes, getPayment, getPayments, getProvince, getProvinces, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, newRouteLink, resolveLabel, resolveRoute, routeInterceptor, routeRevalidateHandler, setDiscountCode, updateCheckout };
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,7 @@ __export(src_exports, {
|
|
|
72
72
|
getSiteMapXSLProps: () => getSiteMapXSLProps,
|
|
73
73
|
getStaticPathsForSchema: () => getStaticPathsForSchema,
|
|
74
74
|
getStores: () => getStores,
|
|
75
|
+
newRouteLink: () => newRouteLink,
|
|
75
76
|
resolveLabel: () => resolveLabel,
|
|
76
77
|
resolveRoute: () => resolveRoute,
|
|
77
78
|
routeInterceptor: () => routeInterceptor,
|
|
@@ -225,18 +226,15 @@ async function getBreadcrumbFromSegments(segments, market = "ww", locale = "en")
|
|
|
225
226
|
const route = routes.find(
|
|
226
227
|
(r) => r.category === segment.id
|
|
227
228
|
);
|
|
228
|
-
const href = route ? route.id.toString() : "/#";
|
|
229
|
-
return { segment, href };
|
|
230
|
-
}).map((x) => {
|
|
231
|
-
const segment = x.segment;
|
|
232
|
-
const href = x.href;
|
|
233
|
-
const title = (0, import_bom_core2.localize)(segment.title || "untitled", locale);
|
|
234
229
|
return {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
href,
|
|
238
|
-
items: []
|
|
230
|
+
segment,
|
|
231
|
+
route
|
|
239
232
|
};
|
|
233
|
+
}).map((x) => {
|
|
234
|
+
const category = x.segment;
|
|
235
|
+
const route = x.route;
|
|
236
|
+
const routeLink = newRouteLink(category, route, locale);
|
|
237
|
+
return routeLink;
|
|
240
238
|
});
|
|
241
239
|
return tree;
|
|
242
240
|
}
|
|
@@ -262,24 +260,35 @@ async function getRouteLinkTree(market = "ww", locale = "en") {
|
|
|
262
260
|
}
|
|
263
261
|
return void 0;
|
|
264
262
|
}
|
|
263
|
+
function newRouteLink(category, route, locale = "en") {
|
|
264
|
+
const href = route && route.id ? route.id.toString() : "/";
|
|
265
|
+
const id = route?.page || category.id;
|
|
266
|
+
const media = category.media || route?.media;
|
|
267
|
+
const schema = route?.schema || category?.schema || "unknown";
|
|
268
|
+
const title = (0, import_bom_core2.localize)(category.title || route?.title || "untitled", locale);
|
|
269
|
+
const routeLink = {
|
|
270
|
+
category: category.id,
|
|
271
|
+
href,
|
|
272
|
+
id,
|
|
273
|
+
items: [],
|
|
274
|
+
media,
|
|
275
|
+
schema,
|
|
276
|
+
title
|
|
277
|
+
};
|
|
278
|
+
return routeLink;
|
|
279
|
+
}
|
|
265
280
|
function categoryToRouteLink(routes, categories, category, locale = "en") {
|
|
266
281
|
const route = routes.find(
|
|
267
282
|
(r) => r.category === category.id
|
|
268
283
|
);
|
|
269
|
-
const href = route && route.id ? route.id.toString() : "/";
|
|
270
|
-
const title = (0, import_bom_core2.localize)(category.title || "untitled", locale);
|
|
271
284
|
const rootCategory = (0, import_bom_core2.getRootCategory)(categories);
|
|
272
285
|
const childCategories = categories.filter((x) => {
|
|
273
286
|
const parentId = x.category && typeof x.category === "object" ? x.category["id"] : x.category;
|
|
274
287
|
return rootCategory && category.id === rootCategory.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
|
|
275
288
|
});
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
href,
|
|
280
|
-
media: category.media,
|
|
281
|
-
items: childCategories.map((x) => categoryToRouteLink(routes, categories, x, locale))
|
|
282
|
-
};
|
|
289
|
+
const routeLink = newRouteLink(category, route, locale);
|
|
290
|
+
routeLink.items = childCategories.map((x) => categoryToRouteLink(routes, categories, x, locale));
|
|
291
|
+
return routeLink;
|
|
283
292
|
}
|
|
284
293
|
function resolveRoute(route) {
|
|
285
294
|
const routepath = route.template ? route.template : route.schema;
|
|
@@ -677,13 +686,13 @@ async function getLayout(market, locale) {
|
|
|
677
686
|
const tree = await getRouteLinkTree(market, locale);
|
|
678
687
|
const firstLevelRoutes = tree?.items || [];
|
|
679
688
|
const flatTopLevelRoutes = tree ? [tree, ...firstLevelRoutes] : [];
|
|
680
|
-
const topLevelRoutes = flatTopLevelRoutes.reduce((object,
|
|
681
|
-
object[
|
|
689
|
+
const topLevelRoutes = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
690
|
+
object[routeLink.schema] = routeLink;
|
|
682
691
|
return object;
|
|
683
692
|
}, {});
|
|
684
|
-
const topLevelHrefs = flatTopLevelRoutes.reduce((object,
|
|
685
|
-
if (
|
|
686
|
-
object[
|
|
693
|
+
const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
694
|
+
if (routeLink.href) {
|
|
695
|
+
object[routeLink.schema] = routeLink.href;
|
|
687
696
|
}
|
|
688
697
|
return object;
|
|
689
698
|
}, {});
|
|
@@ -1597,6 +1606,7 @@ var getSiteMapXSLProps = async (context) => {
|
|
|
1597
1606
|
getSiteMapXSLProps,
|
|
1598
1607
|
getStaticPathsForSchema,
|
|
1599
1608
|
getStores,
|
|
1609
|
+
newRouteLink,
|
|
1600
1610
|
resolveLabel,
|
|
1601
1611
|
resolveRoute,
|
|
1602
1612
|
routeInterceptor,
|
package/dist/index.mjs
CHANGED
|
@@ -142,18 +142,15 @@ async function getBreadcrumbFromSegments(segments, market = "ww", locale = "en")
|
|
|
142
142
|
const route = routes.find(
|
|
143
143
|
(r) => r.category === segment.id
|
|
144
144
|
);
|
|
145
|
-
const href = route ? route.id.toString() : "/#";
|
|
146
|
-
return { segment, href };
|
|
147
|
-
}).map((x) => {
|
|
148
|
-
const segment = x.segment;
|
|
149
|
-
const href = x.href;
|
|
150
|
-
const title = localize(segment.title || "untitled", locale);
|
|
151
145
|
return {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
href,
|
|
155
|
-
items: []
|
|
146
|
+
segment,
|
|
147
|
+
route
|
|
156
148
|
};
|
|
149
|
+
}).map((x) => {
|
|
150
|
+
const category = x.segment;
|
|
151
|
+
const route = x.route;
|
|
152
|
+
const routeLink = newRouteLink(category, route, locale);
|
|
153
|
+
return routeLink;
|
|
157
154
|
});
|
|
158
155
|
return tree;
|
|
159
156
|
}
|
|
@@ -179,24 +176,35 @@ async function getRouteLinkTree(market = "ww", locale = "en") {
|
|
|
179
176
|
}
|
|
180
177
|
return void 0;
|
|
181
178
|
}
|
|
179
|
+
function newRouteLink(category, route, locale = "en") {
|
|
180
|
+
const href = route && route.id ? route.id.toString() : "/";
|
|
181
|
+
const id = route?.page || category.id;
|
|
182
|
+
const media = category.media || route?.media;
|
|
183
|
+
const schema = route?.schema || category?.schema || "unknown";
|
|
184
|
+
const title = localize(category.title || route?.title || "untitled", locale);
|
|
185
|
+
const routeLink = {
|
|
186
|
+
category: category.id,
|
|
187
|
+
href,
|
|
188
|
+
id,
|
|
189
|
+
items: [],
|
|
190
|
+
media,
|
|
191
|
+
schema,
|
|
192
|
+
title
|
|
193
|
+
};
|
|
194
|
+
return routeLink;
|
|
195
|
+
}
|
|
182
196
|
function categoryToRouteLink(routes, categories, category, locale = "en") {
|
|
183
197
|
const route = routes.find(
|
|
184
198
|
(r) => r.category === category.id
|
|
185
199
|
);
|
|
186
|
-
const href = route && route.id ? route.id.toString() : "/";
|
|
187
|
-
const title = localize(category.title || "untitled", locale);
|
|
188
200
|
const rootCategory = getRootCategory(categories);
|
|
189
201
|
const childCategories = categories.filter((x) => {
|
|
190
202
|
const parentId = x.category && typeof x.category === "object" ? x.category["id"] : x.category;
|
|
191
203
|
return rootCategory && category.id === rootCategory.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
|
|
192
204
|
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
href,
|
|
197
|
-
media: category.media,
|
|
198
|
-
items: childCategories.map((x) => categoryToRouteLink(routes, categories, x, locale))
|
|
199
|
-
};
|
|
205
|
+
const routeLink = newRouteLink(category, route, locale);
|
|
206
|
+
routeLink.items = childCategories.map((x) => categoryToRouteLink(routes, categories, x, locale));
|
|
207
|
+
return routeLink;
|
|
200
208
|
}
|
|
201
209
|
function resolveRoute(route) {
|
|
202
210
|
const routepath = route.template ? route.template : route.schema;
|
|
@@ -594,13 +602,13 @@ async function getLayout(market, locale) {
|
|
|
594
602
|
const tree = await getRouteLinkTree(market, locale);
|
|
595
603
|
const firstLevelRoutes = tree?.items || [];
|
|
596
604
|
const flatTopLevelRoutes = tree ? [tree, ...firstLevelRoutes] : [];
|
|
597
|
-
const topLevelRoutes = flatTopLevelRoutes.reduce((object,
|
|
598
|
-
object[
|
|
605
|
+
const topLevelRoutes = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
606
|
+
object[routeLink.schema] = routeLink;
|
|
599
607
|
return object;
|
|
600
608
|
}, {});
|
|
601
|
-
const topLevelHrefs = flatTopLevelRoutes.reduce((object,
|
|
602
|
-
if (
|
|
603
|
-
object[
|
|
609
|
+
const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
610
|
+
if (routeLink.href) {
|
|
611
|
+
object[routeLink.schema] = routeLink.href;
|
|
604
612
|
}
|
|
605
613
|
return object;
|
|
606
614
|
}, {});
|
|
@@ -1513,6 +1521,7 @@ export {
|
|
|
1513
1521
|
getSiteMapXSLProps,
|
|
1514
1522
|
getStaticPathsForSchema,
|
|
1515
1523
|
getStores,
|
|
1524
|
+
newRouteLink,
|
|
1516
1525
|
resolveLabel,
|
|
1517
1526
|
resolveRoute,
|
|
1518
1527
|
routeInterceptor,
|
package/package.json
CHANGED
|
@@ -18,17 +18,17 @@ export async function getLayout(market: string, locale: string): Promise<ILayout
|
|
|
18
18
|
// console.log('firstLevelRoutes', firstLevelRoutes);
|
|
19
19
|
const flatTopLevelRoutes = tree ? [tree, ...firstLevelRoutes] : [];
|
|
20
20
|
// console.log('flatTopLevelRoutes', flatTopLevelRoutes);
|
|
21
|
-
const topLevelRoutes = flatTopLevelRoutes.reduce((object,
|
|
22
|
-
object[
|
|
21
|
+
const topLevelRoutes = flatTopLevelRoutes.reduce((object, routeLink: IRouteLink) => {
|
|
22
|
+
object[routeLink.schema] = routeLink;
|
|
23
23
|
return object;
|
|
24
|
-
}, {} as
|
|
24
|
+
}, {} as Record<string, IRouteLink>);
|
|
25
25
|
// console.log('topLevelRoutes', topLevelRoutes);
|
|
26
|
-
const topLevelHrefs = flatTopLevelRoutes.reduce((object,
|
|
27
|
-
if (
|
|
28
|
-
object[
|
|
26
|
+
const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink: IRouteLink) => {
|
|
27
|
+
if (routeLink.href) {
|
|
28
|
+
object[routeLink.schema] = routeLink.href;
|
|
29
29
|
}
|
|
30
30
|
return object;
|
|
31
|
-
}, {} as
|
|
31
|
+
}, {} as Record<string, string>);
|
|
32
32
|
// console.log('topLevelHrefs', topLevelHrefs);
|
|
33
33
|
const menu: Record<string, IMenu> = {};
|
|
34
34
|
// console.log('menu', menu);
|
|
@@ -94,18 +94,15 @@ export async function getBreadcrumbFromSegments(segments: ICategory[], market: s
|
|
|
94
94
|
const route = routes.find(r =>
|
|
95
95
|
r.category === segment.id
|
|
96
96
|
);
|
|
97
|
-
const href = route ? route.id.toString() : '/#';
|
|
98
|
-
return { segment, href };
|
|
99
|
-
}).map(x => {
|
|
100
|
-
const segment: ICategory = x.segment;
|
|
101
|
-
const href: string = x.href;
|
|
102
|
-
const title = localize(segment.title || 'untitled', locale);
|
|
103
97
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
href,
|
|
107
|
-
items: [],
|
|
98
|
+
segment,
|
|
99
|
+
route,
|
|
108
100
|
};
|
|
101
|
+
}).map(x => {
|
|
102
|
+
const category = x.segment;
|
|
103
|
+
const route = x.route;
|
|
104
|
+
const routeLink = newRouteLink(category, route, locale);
|
|
105
|
+
return routeLink;
|
|
109
106
|
});
|
|
110
107
|
return tree;
|
|
111
108
|
}
|
|
@@ -136,13 +133,28 @@ export async function getRouteLinkTree(market: string = 'ww', locale: string = '
|
|
|
136
133
|
return undefined;
|
|
137
134
|
}
|
|
138
135
|
|
|
136
|
+
export function newRouteLink(category: ICategory, route?: IRoute, locale: string = 'en'): IRouteLink {
|
|
137
|
+
const href = (route && route.id) ? route.id.toString() : '/';
|
|
138
|
+
const id = route?.page || category.id;
|
|
139
|
+
const media = category.media || route?.media;
|
|
140
|
+
const schema = route?.schema || category?.schema || 'unknown';
|
|
141
|
+
const title = localize(category.title || route?.title || 'untitled', locale);
|
|
142
|
+
const routeLink = {
|
|
143
|
+
category: category.id,
|
|
144
|
+
href,
|
|
145
|
+
id,
|
|
146
|
+
items: [],
|
|
147
|
+
media,
|
|
148
|
+
schema,
|
|
149
|
+
title,
|
|
150
|
+
};
|
|
151
|
+
return routeLink;
|
|
152
|
+
}
|
|
153
|
+
|
|
139
154
|
export function categoryToRouteLink(routes: IRoute[], categories: ICategory[], category: ICategory, locale: string = 'en'): IRouteLink {
|
|
140
155
|
const route = routes.find(r =>
|
|
141
156
|
r.category === category.id
|
|
142
157
|
);
|
|
143
|
-
const href = (route && route.id) ? route.id.toString() : '/';
|
|
144
|
-
// console.log('categoryToRouteLink', href, category.id, route);
|
|
145
|
-
const title = localize(category.title || 'untitled', locale);
|
|
146
158
|
const rootCategory = getRootCategory(categories);
|
|
147
159
|
const childCategories = categories.filter(x => {
|
|
148
160
|
const parentId = x.category && typeof x.category === 'object' ? x.category['id'] : x.category;
|
|
@@ -151,13 +163,12 @@ export function categoryToRouteLink(routes: IRoute[], categories: ICategory[], c
|
|
|
151
163
|
parentId === category.id;
|
|
152
164
|
});
|
|
153
165
|
// console.log('childCategories', category.id, childCategories);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
};
|
|
166
|
+
const routeLink = newRouteLink(category, route, locale);
|
|
167
|
+
// const title = localize(category.title || 'untitled', locale);
|
|
168
|
+
// const href = (route && route.id) ? route.id.toString() : '/';
|
|
169
|
+
// console.log('categoryToRouteLink', href, category.id, route);
|
|
170
|
+
routeLink.items = childCategories.map(x => categoryToRouteLink(routes, categories, x, locale));
|
|
171
|
+
return routeLink;
|
|
161
172
|
}
|
|
162
173
|
|
|
163
174
|
export function resolveRoute(route: IRoute & { splat?: string }) {
|