@websolutespa/bom-mixer-models 1.9.2 → 1.9.3
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 -2
- package/dist/index.js +19 -13
- package/dist/index.mjs +18 -12
- package/package.json +1 -1
- package/src/route/route.service.ts +26 -18
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -430,7 +430,7 @@ declare function getStaticPathsForSchemaAndFallback(schema: string, fallback?: '
|
|
|
430
430
|
}>;
|
|
431
431
|
declare function getBreadcrumbFromSegments(segments: ICategory[], route: IRoute): Promise<IRouteLink[]>;
|
|
432
432
|
declare function getRouteLinkTree(market: string, locale: string): Promise<IRouteLink | undefined>;
|
|
433
|
-
declare function
|
|
433
|
+
declare function getRouteLinkCategory(locale: string, routes: IRoute[], categories: ICategory[], rootCategory: ICategory, category: ICategory): IRouteLink | IRouteLink[] | undefined;
|
|
434
434
|
declare function newRouteLink(category: ICategory, route: IRoute | undefined, locale: string): IRouteLink;
|
|
435
435
|
declare function routeToRouteLink(route: IRoute): IRouteLink;
|
|
436
436
|
declare function resolveRoute(route: IRoute & {
|
|
@@ -488,4 +488,4 @@ type IModelStore = {
|
|
|
488
488
|
|
|
489
489
|
declare function getUtmz(request: NextApiRequest): string;
|
|
490
490
|
|
|
491
|
-
export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, IBrand, ICompanyAddress, IConsentPreference, ILazyComponent, ILazyComponentFunc, ILazyComponentProps, ILazyFuncProps, ILazyModules, ILazyProps, ILazyStaticProps, ILazyStaticPropsFunc, ILazyableProps, ILazyedProps, ILegalNotice, IMeta, IMetaData, IModelStore, INullableLazyableProps, ISiteMap, LAZY_PROPS, NotFound, OpenGraphArticle, OpenGraphAudio, OpenGraphBase, OpenGraphBook, OpenGraphBusiness, OpenGraphImage, OpenGraphMusic, OpenGraphPlace, OpenGraphProduct, OpenGraphProductGroup, OpenGraphProfile, OpenGraphRestaurant, OpenGraphType, OpenGraphVideo, OpenGraphWebsite, PartialPageProps, SeoWeight, SessionWithToken, StaticPath, StructuredDataType, TwitterCardApp, TwitterCardBase, TwitterCardPlayer, TwitterCardSummary, TwitterCardSummaryLargeImage, TwitterCardType,
|
|
491
|
+
export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, IBrand, ICompanyAddress, IConsentPreference, ILazyComponent, ILazyComponentFunc, ILazyComponentProps, ILazyFuncProps, ILazyModules, ILazyProps, ILazyStaticProps, ILazyStaticPropsFunc, ILazyableProps, ILazyedProps, ILegalNotice, IMeta, IMetaData, IModelStore, INullableLazyableProps, ISiteMap, LAZY_PROPS, NotFound, OpenGraphArticle, OpenGraphAudio, OpenGraphBase, OpenGraphBook, OpenGraphBusiness, OpenGraphImage, OpenGraphMusic, OpenGraphPlace, OpenGraphProduct, OpenGraphProductGroup, OpenGraphProfile, OpenGraphRestaurant, OpenGraphType, OpenGraphVideo, OpenGraphWebsite, PartialPageProps, SeoWeight, SessionWithToken, StaticPath, StructuredDataType, TwitterCardApp, TwitterCardBase, TwitterCardPlayer, TwitterCardSummary, TwitterCardSummaryLargeImage, TwitterCardType, escapeHtml, findManyPages, findOnePage, getAddressOptions, getBreadcrumbFromSegments, getCaptionsVttProps, getCategories, getCategory, getConsentPreference, getConsentPreferences, getConsentPreferencesPagination, getCountries, getCountriesPagination, getCountry, getDecoratedComponents, getErrorPageLayout, getLabel, getLabels, getLayout, getLink, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getPage, getPageCategory, getPageProps, getPageRoutes, getPreviewProps, getProvince, getProvinces, getProvincesPagination, getPublicUrl, getRedirect, getRedirects, getRedirectsPagination, getRegion, getRegions, getRegionsPagination, getRoute, getRouteLinkCategory, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSeoWeight, getSession, getSessionToken, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStaticPathsForSchemaAndFallback, getUtmz, newRouteLink, pushDataLayer, redirectTo, resolveHref, resolveLabel, resolveRoute, routeInterceptor, routeRevalidateHandler, routeToRouteLink, withLazyProps };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
LAZY_PROPS: () => LAZY_PROPS,
|
|
24
24
|
NotFound: () => NotFound,
|
|
25
|
-
categoryToRouteLink: () => categoryToRouteLink,
|
|
26
25
|
escapeHtml: () => escapeHtml,
|
|
27
26
|
findManyPages: () => findManyPages,
|
|
28
27
|
findOnePage: () => findOnePage,
|
|
@@ -66,6 +65,7 @@ __export(src_exports, {
|
|
|
66
65
|
getRegions: () => getRegions,
|
|
67
66
|
getRegionsPagination: () => getRegionsPagination,
|
|
68
67
|
getRoute: () => getRoute,
|
|
68
|
+
getRouteLinkCategory: () => getRouteLinkCategory,
|
|
69
69
|
getRouteLinkTree: () => getRouteLinkTree,
|
|
70
70
|
getRoutes: () => getRoutes,
|
|
71
71
|
getRoutesForSchemas: () => getRoutesForSchemas,
|
|
@@ -430,23 +430,29 @@ async function getRouteLinkTree(market, locale) {
|
|
|
430
430
|
const categories = await store.category.findMany({ market, locale });
|
|
431
431
|
const rootCategory = (0, import_bom_core3.getRootCategory)(categories);
|
|
432
432
|
if (rootCategory) {
|
|
433
|
-
const root =
|
|
433
|
+
const root = getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
|
|
434
434
|
return root;
|
|
435
435
|
}
|
|
436
436
|
return void 0;
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function getRouteLinkCategory(locale, routes, categories, rootCategory, category) {
|
|
439
439
|
const route = (0, import_bom_core3.findRouteOfCategory)(routes, category.id);
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
const rootCategory = (0, import_bom_core3.getRootCategory)(categories);
|
|
444
|
-
const childCategories = categories.filter((x) => {
|
|
445
|
-
const parentId = (0, import_bom_core3.asCategoryId)(x.category);
|
|
446
|
-
return rootCategory && rootCategory.id === category.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
|
|
447
|
-
});
|
|
440
|
+
const otherCategories = categories.filter((x) => x.id !== category.id);
|
|
441
|
+
const childCategories = otherCategories.filter((x) => (0, import_bom_core3.asCategoryId)(x.category) === category.id);
|
|
448
442
|
const routeLink = newRouteLink(category, route, locale);
|
|
449
|
-
|
|
443
|
+
const items = [];
|
|
444
|
+
for (const childCategory of childCategories) {
|
|
445
|
+
const itemOrItems = getRouteLinkCategory(locale, routes, otherCategories, rootCategory, childCategory);
|
|
446
|
+
if (Array.isArray(itemOrItems)) {
|
|
447
|
+
items.push(...itemOrItems);
|
|
448
|
+
} else if (itemOrItems) {
|
|
449
|
+
items.push(itemOrItems);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (category.isHidden || !route) {
|
|
453
|
+
return items;
|
|
454
|
+
}
|
|
455
|
+
routeLink.items = items;
|
|
450
456
|
return routeLink;
|
|
451
457
|
}
|
|
452
458
|
function newRouteLink(category, route, locale) {
|
|
@@ -1281,7 +1287,6 @@ function getUtmz(request) {
|
|
|
1281
1287
|
0 && (module.exports = {
|
|
1282
1288
|
LAZY_PROPS,
|
|
1283
1289
|
NotFound,
|
|
1284
|
-
categoryToRouteLink,
|
|
1285
1290
|
escapeHtml,
|
|
1286
1291
|
findManyPages,
|
|
1287
1292
|
findOnePage,
|
|
@@ -1325,6 +1330,7 @@ function getUtmz(request) {
|
|
|
1325
1330
|
getRegions,
|
|
1326
1331
|
getRegionsPagination,
|
|
1327
1332
|
getRoute,
|
|
1333
|
+
getRouteLinkCategory,
|
|
1328
1334
|
getRouteLinkTree,
|
|
1329
1335
|
getRoutes,
|
|
1330
1336
|
getRoutesForSchemas,
|
package/dist/index.mjs
CHANGED
|
@@ -332,23 +332,29 @@ async function getRouteLinkTree(market, locale) {
|
|
|
332
332
|
const categories = await store.category.findMany({ market, locale });
|
|
333
333
|
const rootCategory = getRootCategory(categories);
|
|
334
334
|
if (rootCategory) {
|
|
335
|
-
const root =
|
|
335
|
+
const root = getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
|
|
336
336
|
return root;
|
|
337
337
|
}
|
|
338
338
|
return void 0;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function getRouteLinkCategory(locale, routes, categories, rootCategory, category) {
|
|
341
341
|
const route = findRouteOfCategory(routes, category.id);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
const rootCategory = getRootCategory(categories);
|
|
346
|
-
const childCategories = categories.filter((x) => {
|
|
347
|
-
const parentId = asCategoryId(x.category);
|
|
348
|
-
return rootCategory && rootCategory.id === category.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
|
|
349
|
-
});
|
|
342
|
+
const otherCategories = categories.filter((x) => x.id !== category.id);
|
|
343
|
+
const childCategories = otherCategories.filter((x) => asCategoryId(x.category) === category.id);
|
|
350
344
|
const routeLink = newRouteLink(category, route, locale);
|
|
351
|
-
|
|
345
|
+
const items = [];
|
|
346
|
+
for (const childCategory of childCategories) {
|
|
347
|
+
const itemOrItems = getRouteLinkCategory(locale, routes, otherCategories, rootCategory, childCategory);
|
|
348
|
+
if (Array.isArray(itemOrItems)) {
|
|
349
|
+
items.push(...itemOrItems);
|
|
350
|
+
} else if (itemOrItems) {
|
|
351
|
+
items.push(itemOrItems);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (category.isHidden || !route) {
|
|
355
|
+
return items;
|
|
356
|
+
}
|
|
357
|
+
routeLink.items = items;
|
|
352
358
|
return routeLink;
|
|
353
359
|
}
|
|
354
360
|
function newRouteLink(category, route, locale) {
|
|
@@ -1182,7 +1188,6 @@ function getUtmz(request) {
|
|
|
1182
1188
|
export {
|
|
1183
1189
|
LAZY_PROPS,
|
|
1184
1190
|
NotFound,
|
|
1185
|
-
categoryToRouteLink,
|
|
1186
1191
|
escapeHtml,
|
|
1187
1192
|
findManyPages,
|
|
1188
1193
|
findOnePage,
|
|
@@ -1226,6 +1231,7 @@ export {
|
|
|
1226
1231
|
getRegions,
|
|
1227
1232
|
getRegionsPagination,
|
|
1228
1233
|
getRoute,
|
|
1234
|
+
getRouteLinkCategory,
|
|
1229
1235
|
getRouteLinkTree,
|
|
1230
1236
|
getRoutes,
|
|
1231
1237
|
getRoutesForSchemas,
|
package/package.json
CHANGED
|
@@ -167,31 +167,39 @@ export async function getRouteLinkTree(market: string, locale: string): Promise<
|
|
|
167
167
|
const rootCategory = getRootCategory(categories);
|
|
168
168
|
// console.log('getRouteLinkTree.rootCategory', rootCategory?.id);
|
|
169
169
|
if (rootCategory) {
|
|
170
|
-
const root =
|
|
170
|
+
const root = getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
|
|
171
171
|
// console.log('getRouteLinkTree', root);
|
|
172
|
-
return root;
|
|
172
|
+
return root as IRouteLink;
|
|
173
173
|
}
|
|
174
174
|
return undefined;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
export function
|
|
177
|
+
export function getRouteLinkCategory(
|
|
178
|
+
locale: string,
|
|
179
|
+
routes: IRoute[],
|
|
180
|
+
categories: ICategory[],
|
|
181
|
+
rootCategory: ICategory,
|
|
182
|
+
category: ICategory
|
|
183
|
+
): IRouteLink | IRouteLink[] | undefined {
|
|
178
184
|
const route = findRouteOfCategory(routes, category.id);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const rootCategory = getRootCategory(categories);
|
|
183
|
-
const childCategories = categories.filter(x => {
|
|
184
|
-
const parentId = asCategoryId(x.category);
|
|
185
|
-
return rootCategory && rootCategory.id === category.id ?
|
|
186
|
-
(x.id !== rootCategory.id && (parentId === category.id || !parentId)) :
|
|
187
|
-
parentId === category.id;
|
|
188
|
-
});
|
|
189
|
-
// console.log('childCategories', category.id, childCategories);
|
|
185
|
+
const otherCategories = categories.filter(x => x.id !== category.id);
|
|
186
|
+
const childCategories = otherCategories.filter(x => asCategoryId(x.category) === category.id);
|
|
187
|
+
// console.log('childCategories', category.id, childCategories.map(x => x.id));
|
|
190
188
|
const routeLink = newRouteLink(category, route, locale);
|
|
191
|
-
// console.log('
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
// console.log('getRouteLinkCategory', href, category.id, route);
|
|
190
|
+
const items: IRouteLink[] = [];
|
|
191
|
+
for (const childCategory of childCategories) {
|
|
192
|
+
const itemOrItems = getRouteLinkCategory(locale, routes, otherCategories, rootCategory, childCategory);
|
|
193
|
+
if (Array.isArray(itemOrItems)) {
|
|
194
|
+
items.push(...itemOrItems);
|
|
195
|
+
} else if (itemOrItems) {
|
|
196
|
+
items.push(itemOrItems);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (category.isHidden || !route) {
|
|
200
|
+
return items;
|
|
201
|
+
}
|
|
202
|
+
routeLink.items = items;
|
|
195
203
|
return routeLink;
|
|
196
204
|
}
|
|
197
205
|
|