@websolutespa/bom-core 1.8.21 → 1.8.23

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,5 +1,17 @@
1
1
  # @websolutespa/bom-core
2
2
 
3
+ ## 1.8.23
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c7f05f: Modified: IRoute isRoot noindex, routeService
8
+
9
+ ## 1.8.22
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixing: JsonService whereItem\_ unresolved relations
14
+
3
15
  ## 1.8.21
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -347,14 +347,16 @@ type IMarket = IEntity & {
347
347
 
348
348
  type IRoute = {
349
349
  category: IEquatable;
350
- resolvedCategory: IEquatable;
351
350
  id: string;
352
351
  isDefault?: boolean;
352
+ isRoot?: boolean;
353
353
  locale: string;
354
354
  market: string;
355
355
  media?: IMedia;
356
+ noindex?: boolean;
356
357
  order?: number;
357
358
  page: IEquatable;
359
+ resolvedCategory: IEquatable;
358
360
  schema: string;
359
361
  template?: string;
360
362
  title: string;
@@ -1052,6 +1054,9 @@ declare function getOrigin(headers?: IncomingHttpHeaders | Headers): string;
1052
1054
 
1053
1055
  /**
1054
1056
  * Represents the route strategy options.
1057
+ * - **Auto** dynamically add/remove prefixes based on number of markets & languages.
1058
+ * - **Default** add prefixes based on !isDefault market or language flag.
1059
+ * - **Manual** add prefixes based on !isHidden market or language flag.
1055
1060
  */
1056
1061
  declare enum RouteStrategy {
1057
1062
  Auto = "auto",
package/dist/index.js CHANGED
@@ -1392,7 +1392,11 @@ function getValue(item, key) {
1392
1392
  const keys = key.split(".");
1393
1393
  const value = keys.reduce((p, c) => {
1394
1394
  if (isObject(p)) {
1395
- return p[c];
1395
+ const v = p[c];
1396
+ if (isUnresolvedRelation(v)) {
1397
+ return v.value;
1398
+ }
1399
+ return v;
1396
1400
  } else {
1397
1401
  return void 0;
1398
1402
  }
@@ -1677,22 +1681,7 @@ var RouteStrategy = /* @__PURE__ */ ((RouteStrategy2) => {
1677
1681
  RouteStrategy2["Manual"] = "manual";
1678
1682
  return RouteStrategy2;
1679
1683
  })(RouteStrategy || {});
1680
- var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "auto" /* Auto */;
1681
- function getPickedProps(item) {
1682
- const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
1683
- "category",
1684
- "isDefault",
1685
- "media",
1686
- "order",
1687
- "template",
1688
- "updatedAt",
1689
- "useSplat",
1690
- // 'createdAt',
1691
- "updatedAt",
1692
- "_status"
1693
- ].includes(k)));
1694
- return pickedProps;
1695
- }
1684
+ var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "manual" /* Manual */;
1696
1685
  function collectRoutes(store, categories, markets, locales, medias) {
1697
1686
  const routes = [];
1698
1687
  if (locales.length > 0 && markets.length > 0) {
@@ -1706,31 +1695,57 @@ function collectRoutes(store, categories, markets, locales, medias) {
1706
1695
  if (Boolean(item.isDefault) === false) {
1707
1696
  slugs.push({ slug: item.slug });
1708
1697
  }
1709
- const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
1710
- const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
1711
- const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
1712
1698
  const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
1713
1699
  eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
1714
1700
  if (hasMarket(item, market)) {
1715
1701
  const title = localize(item.title, locale.id);
1716
1702
  const id = getRouteHref(slugs, market, locale, markets2, locales2);
1717
- const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
1718
- const pickedProps = getPickedProps(item);
1703
+ const {
1704
+ _status,
1705
+ category,
1706
+ isDefault,
1707
+ media,
1708
+ order,
1709
+ template,
1710
+ updatedAt,
1711
+ useSplat
1712
+ } = item;
1719
1713
  const route = {
1720
- ...pickedProps,
1721
- resolvedCategory: visibleCategory.id,
1722
- id: isDefaultRootCategory ? "/" : id,
1714
+ _status,
1715
+ category,
1716
+ // id: isDefaultRootCategory ? '/' : id,
1717
+ id,
1723
1718
  locale: locale.id,
1724
1719
  market: market.id,
1720
+ media,
1725
1721
  page: item.id,
1722
+ resolvedCategory: visibleCategory.id,
1726
1723
  schema: key,
1727
- title
1724
+ template,
1725
+ title,
1726
+ updatedAt
1728
1727
  };
1728
+ if (isDefault) {
1729
+ route.isDefault = true;
1730
+ }
1731
+ if (isRootCategory) {
1732
+ route.isRoot = true;
1733
+ }
1734
+ const noindex = (item.meta?.robots || "").includes("noindex");
1735
+ if (noindex) {
1736
+ route.noindex = true;
1737
+ }
1738
+ if (order != null) {
1739
+ route.order = order;
1740
+ }
1741
+ if (useSplat) {
1742
+ route.useSplat = true;
1743
+ }
1729
1744
  const mediaId = typeof item.media === "string" ? item.media : void 0;
1730
1745
  if (Array.isArray(medias) && mediaId) {
1731
- const media = item.media && medias.find((x) => x.id === mediaId);
1732
- if (media) {
1733
- route.media = media;
1746
+ const media2 = item.media && medias.find((x) => x.id === mediaId);
1747
+ if (media2) {
1748
+ route.media = media2;
1734
1749
  }
1735
1750
  }
1736
1751
  routes.push(route);
package/dist/index.mjs CHANGED
@@ -1223,7 +1223,11 @@ function getValue(item, key) {
1223
1223
  const keys = key.split(".");
1224
1224
  const value = keys.reduce((p, c) => {
1225
1225
  if (isObject(p)) {
1226
- return p[c];
1226
+ const v = p[c];
1227
+ if (isUnresolvedRelation(v)) {
1228
+ return v.value;
1229
+ }
1230
+ return v;
1227
1231
  } else {
1228
1232
  return void 0;
1229
1233
  }
@@ -1508,22 +1512,7 @@ var RouteStrategy = /* @__PURE__ */ ((RouteStrategy2) => {
1508
1512
  RouteStrategy2["Manual"] = "manual";
1509
1513
  return RouteStrategy2;
1510
1514
  })(RouteStrategy || {});
1511
- var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "auto" /* Auto */;
1512
- function getPickedProps(item) {
1513
- const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
1514
- "category",
1515
- "isDefault",
1516
- "media",
1517
- "order",
1518
- "template",
1519
- "updatedAt",
1520
- "useSplat",
1521
- // 'createdAt',
1522
- "updatedAt",
1523
- "_status"
1524
- ].includes(k)));
1525
- return pickedProps;
1526
- }
1515
+ var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "manual" /* Manual */;
1527
1516
  function collectRoutes(store, categories, markets, locales, medias) {
1528
1517
  const routes = [];
1529
1518
  if (locales.length > 0 && markets.length > 0) {
@@ -1537,31 +1526,57 @@ function collectRoutes(store, categories, markets, locales, medias) {
1537
1526
  if (Boolean(item.isDefault) === false) {
1538
1527
  slugs.push({ slug: item.slug });
1539
1528
  }
1540
- const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
1541
- const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
1542
- const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
1543
1529
  const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
1544
1530
  eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
1545
1531
  if (hasMarket(item, market)) {
1546
1532
  const title = localize(item.title, locale.id);
1547
1533
  const id = getRouteHref(slugs, market, locale, markets2, locales2);
1548
- const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
1549
- const pickedProps = getPickedProps(item);
1534
+ const {
1535
+ _status,
1536
+ category,
1537
+ isDefault,
1538
+ media,
1539
+ order,
1540
+ template,
1541
+ updatedAt,
1542
+ useSplat
1543
+ } = item;
1550
1544
  const route = {
1551
- ...pickedProps,
1552
- resolvedCategory: visibleCategory.id,
1553
- id: isDefaultRootCategory ? "/" : id,
1545
+ _status,
1546
+ category,
1547
+ // id: isDefaultRootCategory ? '/' : id,
1548
+ id,
1554
1549
  locale: locale.id,
1555
1550
  market: market.id,
1551
+ media,
1556
1552
  page: item.id,
1553
+ resolvedCategory: visibleCategory.id,
1557
1554
  schema: key,
1558
- title
1555
+ template,
1556
+ title,
1557
+ updatedAt
1559
1558
  };
1559
+ if (isDefault) {
1560
+ route.isDefault = true;
1561
+ }
1562
+ if (isRootCategory) {
1563
+ route.isRoot = true;
1564
+ }
1565
+ const noindex = (item.meta?.robots || "").includes("noindex");
1566
+ if (noindex) {
1567
+ route.noindex = true;
1568
+ }
1569
+ if (order != null) {
1570
+ route.order = order;
1571
+ }
1572
+ if (useSplat) {
1573
+ route.useSplat = true;
1574
+ }
1560
1575
  const mediaId = typeof item.media === "string" ? item.media : void 0;
1561
1576
  if (Array.isArray(medias) && mediaId) {
1562
- const media = item.media && medias.find((x) => x.id === mediaId);
1563
- if (media) {
1564
- route.media = media;
1577
+ const media2 = item.media && medias.find((x) => x.id === mediaId);
1578
+ if (media2) {
1579
+ route.media = media2;
1565
1580
  }
1566
1581
  }
1567
1582
  routes.push(route);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "1.8.21",
3
+ "version": "1.8.23",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",