@websolutespa/bom-core 3.0.3 → 3.0.5
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 +12 -0
- package/dist/index.d.ts +8 -16
- package/dist/index.js +9 -51
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -383,25 +383,19 @@ type IMarket = IEntity & {
|
|
|
383
383
|
type IRoute = {
|
|
384
384
|
category: IEquatable;
|
|
385
385
|
id: string;
|
|
386
|
+
isDefault?: boolean;
|
|
387
|
+
isRoot?: boolean;
|
|
386
388
|
locale: string;
|
|
387
389
|
market: string;
|
|
390
|
+
media?: IMedia;
|
|
391
|
+
noindex?: boolean;
|
|
392
|
+
order?: number;
|
|
388
393
|
page: IEquatable;
|
|
389
394
|
resolvedCategory: IEquatable;
|
|
390
395
|
schema: string;
|
|
391
|
-
title: string;
|
|
392
|
-
_status?: 'published' | 'draft';
|
|
393
|
-
isDefault?: boolean;
|
|
394
|
-
isRoot?: boolean;
|
|
395
|
-
media?: {
|
|
396
|
-
url: string;
|
|
397
|
-
src?: string;
|
|
398
|
-
type: string;
|
|
399
|
-
updatedAt?: Date | string;
|
|
400
|
-
};
|
|
401
|
-
noindex?: boolean;
|
|
402
|
-
order?: number;
|
|
403
396
|
template?: string;
|
|
404
|
-
|
|
397
|
+
title: string;
|
|
398
|
+
updatedAt?: Date;
|
|
405
399
|
useSplat?: boolean;
|
|
406
400
|
};
|
|
407
401
|
type IRouteCanonical = IRoute & {
|
|
@@ -490,9 +484,7 @@ type IPageUnresolvedRelation = {
|
|
|
490
484
|
|
|
491
485
|
declare enum MenuCategoryStrategy {
|
|
492
486
|
Default = "default",// show hidden categories recursively,
|
|
493
|
-
ExcludeHidden = "exclude-hidden"
|
|
494
|
-
ExcludeRoute = "exclude-route",
|
|
495
|
-
ExcludeHiddenAndRoute = "exclude-hidden-and-route"
|
|
487
|
+
ExcludeHidden = "exclude-hidden"
|
|
496
488
|
}
|
|
497
489
|
type IMenuBase = {
|
|
498
490
|
abstract?: ILocalizable;
|
package/dist/index.js
CHANGED
|
@@ -417,8 +417,6 @@ function isMedia(item) {
|
|
|
417
417
|
var MenuCategoryStrategy = /* @__PURE__ */ ((MenuCategoryStrategy2) => {
|
|
418
418
|
MenuCategoryStrategy2["Default"] = "default";
|
|
419
419
|
MenuCategoryStrategy2["ExcludeHidden"] = "exclude-hidden";
|
|
420
|
-
MenuCategoryStrategy2["ExcludeRoute"] = "exclude-route";
|
|
421
|
-
MenuCategoryStrategy2["ExcludeHiddenAndRoute"] = "exclude-hidden-and-route";
|
|
422
420
|
return MenuCategoryStrategy2;
|
|
423
421
|
})(MenuCategoryStrategy || {});
|
|
424
422
|
function isMenuHref(item) {
|
|
@@ -1441,7 +1439,7 @@ function qsDeserializeKey(value) {
|
|
|
1441
1439
|
return value;
|
|
1442
1440
|
}
|
|
1443
1441
|
function qsDeserializeKeys(key) {
|
|
1444
|
-
const keys = key.replace(/[\]]/g, "").split("[").map((x) => qsDeserializeKey(x))
|
|
1442
|
+
const keys = key.replace(/[\]]/g, "").split("[").map((x) => qsDeserializeKey(x));
|
|
1445
1443
|
return keys;
|
|
1446
1444
|
}
|
|
1447
1445
|
function getNextKeyItem(key) {
|
|
@@ -1540,37 +1538,8 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1540
1538
|
const routes = [];
|
|
1541
1539
|
if (locales.length > 0 && markets.length > 0) {
|
|
1542
1540
|
const rootCategory = getRootCategory(categories);
|
|
1543
|
-
const activeLocales = locales.filter((locale) => locale.isActive !== false);
|
|
1544
|
-
const activeMarkets = markets.filter((market) => market.isActive !== false);
|
|
1545
|
-
const categoryById = new Map(categories.filter((category) => typeof category.id === "string").map((category) => [category.id, category]));
|
|
1546
|
-
const localeById = new Map(activeLocales.filter((locale) => typeof locale.id === "string").map((locale) => [locale.id, locale]));
|
|
1547
|
-
const mediaById = new Map((medias || []).filter((media) => typeof media.id === "string").map((media) => [media.id, media]));
|
|
1548
|
-
const marketLocales = activeMarkets.flatMap((market) => {
|
|
1549
|
-
const localesForMarket = market.languages && market.languages.length > 0 ? market.languages.map((language) => localeById.get(String(asEntityId(language)))).filter((locale) => locale !== void 0) : activeLocales;
|
|
1550
|
-
return localesForMarket.map((locale) => ({ market, locale }));
|
|
1551
|
-
});
|
|
1552
|
-
const getSegments = (item) => {
|
|
1553
|
-
const routeCategories = [];
|
|
1554
|
-
const segments = [];
|
|
1555
|
-
let parentId = asCategoryId(item.category);
|
|
1556
|
-
while (parentId != null) {
|
|
1557
|
-
const parentCategory = categoryById.get(parentId);
|
|
1558
|
-
if (parentCategory) {
|
|
1559
|
-
segments.unshift({ ...parentCategory });
|
|
1560
|
-
routeCategories.push(parentId);
|
|
1561
|
-
parentId = asCategoryId(parentCategory.category);
|
|
1562
|
-
if (parentId && routeCategories.includes(parentId)) {
|
|
1563
|
-
console.log("ICategory.getParentCategoriesById", "circular reference found", parentId);
|
|
1564
|
-
parentId = void 0;
|
|
1565
|
-
}
|
|
1566
|
-
} else {
|
|
1567
|
-
parentId = void 0;
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
return segments;
|
|
1571
|
-
};
|
|
1572
1541
|
eachCategorized(store, (item, key) => {
|
|
1573
|
-
const segments =
|
|
1542
|
+
const segments = getCategorySegments(categories, item);
|
|
1574
1543
|
const visibleSegments = segments.filter((x) => x.id !== rootCategory?.id && Boolean(x.isHidden) === false);
|
|
1575
1544
|
const visibleCategory = visibleSegments.length > 0 ? visibleSegments[visibleSegments.length - 1] : rootCategory;
|
|
1576
1545
|
if (visibleCategory) {
|
|
@@ -1579,10 +1548,10 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1579
1548
|
slugs.push({ slug: item.slug });
|
|
1580
1549
|
}
|
|
1581
1550
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1582
|
-
|
|
1551
|
+
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1583
1552
|
if (hasMarket(item, market)) {
|
|
1584
1553
|
const title = localize(item.title, locale.id);
|
|
1585
|
-
const id = getRouteHref(slugs, market, locale,
|
|
1554
|
+
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1586
1555
|
const {
|
|
1587
1556
|
_status,
|
|
1588
1557
|
category,
|
|
@@ -1596,10 +1565,11 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1596
1565
|
const route = {
|
|
1597
1566
|
_status,
|
|
1598
1567
|
category,
|
|
1568
|
+
// id: isDefaultRootCategory ? '/' : id,
|
|
1599
1569
|
id,
|
|
1600
1570
|
locale: locale.id,
|
|
1601
1571
|
market: market.id,
|
|
1602
|
-
media
|
|
1572
|
+
media,
|
|
1603
1573
|
page: item.id,
|
|
1604
1574
|
resolvedCategory: visibleCategory.id,
|
|
1605
1575
|
schema: key,
|
|
@@ -1624,10 +1594,10 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1624
1594
|
route.useSplat = true;
|
|
1625
1595
|
}
|
|
1626
1596
|
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1627
|
-
if (mediaId) {
|
|
1628
|
-
const media2 =
|
|
1597
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1598
|
+
const media2 = item.media && medias.find((x) => x.id === mediaId);
|
|
1629
1599
|
if (media2) {
|
|
1630
|
-
route.media =
|
|
1600
|
+
route.media = media2;
|
|
1631
1601
|
}
|
|
1632
1602
|
}
|
|
1633
1603
|
routes.push(route);
|
|
@@ -1638,18 +1608,6 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1638
1608
|
}
|
|
1639
1609
|
return routes;
|
|
1640
1610
|
}
|
|
1641
|
-
function routeMedia(media) {
|
|
1642
|
-
const url = media?.url || media?.src;
|
|
1643
|
-
return media && url ? {
|
|
1644
|
-
// createdAt: media.createdAt,
|
|
1645
|
-
updatedAt: media.updatedAt,
|
|
1646
|
-
// filename: media.filename,
|
|
1647
|
-
// mimeType: media.mimeType,
|
|
1648
|
-
// id: media.id,
|
|
1649
|
-
url,
|
|
1650
|
-
type: media.type
|
|
1651
|
-
} : void 0;
|
|
1652
|
-
}
|
|
1653
1611
|
function eachMarketLocale(markets, locales, callback) {
|
|
1654
1612
|
locales = locales.filter((x) => x.isActive !== false);
|
|
1655
1613
|
markets = markets.filter((x) => x.isActive !== false);
|