@websolutespa/bom-core 1.8.5 → 1.8.6

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,11 @@
1
1
  # @websolutespa/bom-core
2
2
 
3
+ ## 1.8.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: collectRoutes
8
+
3
9
  ## 1.8.5
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1041,7 +1041,7 @@ declare enum RouteStrategy {
1041
1041
  * @param locales - The list of locales.
1042
1042
  * @returns An array of collected routes.
1043
1043
  */
1044
- declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
1044
+ declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[], medias?: IMedia[]): IRoute[];
1045
1045
  /**
1046
1046
  * Iterates over each market and locale combination and invokes the callback function.
1047
1047
  *
package/dist/index.js CHANGED
@@ -1378,7 +1378,6 @@ function getPickedProps(item) {
1378
1378
  const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
1379
1379
  "category",
1380
1380
  "isDefault",
1381
- "media",
1382
1381
  "order",
1383
1382
  "template",
1384
1383
  "updatedAt",
@@ -1386,7 +1385,7 @@ function getPickedProps(item) {
1386
1385
  ].includes(k)));
1387
1386
  return pickedProps;
1388
1387
  }
1389
- function collectRoutes(store, categories, markets, locales) {
1388
+ function collectRoutes(store, categories, markets, locales, medias) {
1390
1389
  const routes = [];
1391
1390
  if (locales.length > 0 && markets.length > 0) {
1392
1391
  const rootCategory = getRootCategory(categories);
@@ -1415,12 +1414,22 @@ function collectRoutes(store, categories, markets, locales) {
1415
1414
  schema: key,
1416
1415
  title
1417
1416
  };
1417
+ const mediaId = typeof item.media === "string" ? item.media : void 0;
1418
+ if (Array.isArray(medias) && mediaId) {
1419
+ const media = item.media && medias.find((x) => x.id === mediaId);
1420
+ if (media) {
1421
+ route.media = media;
1422
+ }
1423
+ }
1418
1424
  routes.push(route);
1419
1425
  }
1420
1426
  eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
1421
1427
  if (!item.markets || item.markets.includes(market.id)) {
1422
1428
  const title = localize(item.title, locale.id);
1423
1429
  const id = getRouteHref(slugs, market, locale, markets2, locales2);
1430
+ if (!id) {
1431
+ return;
1432
+ }
1424
1433
  const pickedProps = getPickedProps(item);
1425
1434
  const route = {
1426
1435
  ...pickedProps,
@@ -1432,6 +1441,13 @@ function collectRoutes(store, categories, markets, locales) {
1432
1441
  schema: key,
1433
1442
  title
1434
1443
  };
1444
+ const mediaId = typeof item.media === "string" ? item.media : void 0;
1445
+ if (Array.isArray(medias) && mediaId) {
1446
+ const media = item.media && medias.find((x) => x.id === mediaId);
1447
+ if (media) {
1448
+ route.media = media;
1449
+ }
1450
+ }
1435
1451
  routes.push(route);
1436
1452
  }
1437
1453
  });
package/dist/index.mjs CHANGED
@@ -1230,7 +1230,6 @@ function getPickedProps(item) {
1230
1230
  const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
1231
1231
  "category",
1232
1232
  "isDefault",
1233
- "media",
1234
1233
  "order",
1235
1234
  "template",
1236
1235
  "updatedAt",
@@ -1238,7 +1237,7 @@ function getPickedProps(item) {
1238
1237
  ].includes(k)));
1239
1238
  return pickedProps;
1240
1239
  }
1241
- function collectRoutes(store, categories, markets, locales) {
1240
+ function collectRoutes(store, categories, markets, locales, medias) {
1242
1241
  const routes = [];
1243
1242
  if (locales.length > 0 && markets.length > 0) {
1244
1243
  const rootCategory = getRootCategory(categories);
@@ -1267,12 +1266,22 @@ function collectRoutes(store, categories, markets, locales) {
1267
1266
  schema: key,
1268
1267
  title
1269
1268
  };
1269
+ const mediaId = typeof item.media === "string" ? item.media : void 0;
1270
+ if (Array.isArray(medias) && mediaId) {
1271
+ const media = item.media && medias.find((x) => x.id === mediaId);
1272
+ if (media) {
1273
+ route.media = media;
1274
+ }
1275
+ }
1270
1276
  routes.push(route);
1271
1277
  }
1272
1278
  eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
1273
1279
  if (!item.markets || item.markets.includes(market.id)) {
1274
1280
  const title = localize(item.title, locale.id);
1275
1281
  const id = getRouteHref(slugs, market, locale, markets2, locales2);
1282
+ if (!id) {
1283
+ return;
1284
+ }
1276
1285
  const pickedProps = getPickedProps(item);
1277
1286
  const route = {
1278
1287
  ...pickedProps,
@@ -1284,6 +1293,13 @@ function collectRoutes(store, categories, markets, locales) {
1284
1293
  schema: key,
1285
1294
  title
1286
1295
  };
1296
+ const mediaId = typeof item.media === "string" ? item.media : void 0;
1297
+ if (Array.isArray(medias) && mediaId) {
1298
+ const media = item.media && medias.find((x) => x.id === mediaId);
1299
+ if (media) {
1300
+ route.media = media;
1301
+ }
1302
+ }
1287
1303
  routes.push(route);
1288
1304
  }
1289
1305
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "1.8.5",
3
+ "version": "1.8.6",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",