@websolutespa/bom-core 1.8.6 → 1.8.8

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.8
4
+
5
+ ### Patch Changes
6
+
7
+ - f343ad7: Modified: RouteService collectRoutes
8
+
9
+ ## 1.8.7
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified: routeService getPickedProps
14
+
3
15
  ## 1.8.6
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -94,13 +94,15 @@ type User = Record<string, unknown> & {
94
94
  id: string;
95
95
  email: string;
96
96
  };
97
- type UserRole = 'admin' | 'editor' | 'user' | string;
97
+ type UserRole = ('admin' | 'editor' | 'guest' | 'user') & string;
98
98
  type UserWithRoles = User & {
99
99
  roles: UserRole[];
100
100
  };
101
101
  type IEndUser = UserWithRoles & {
102
102
  email: string;
103
103
  consentPreferences: IConsentPreference[];
104
+ createdAt: string;
105
+ updatedAt: string;
104
106
  };
105
107
 
106
108
  type IAction = Record<string, unknown> & {
@@ -110,7 +112,6 @@ type IAction = Record<string, unknown> & {
110
112
  consentsRevoked?: boolean;
111
113
  consentsRevokedDate?: string | Date;
112
114
  endUser: IEndUser;
113
- loggedEndUser?: IEndUser;
114
115
  email?: string;
115
116
  password?: string;
116
117
  createdAt?: string;
@@ -542,12 +543,8 @@ type ILayout = {
542
543
  tree?: IRouteLink;
543
544
  };
544
545
 
545
- type IUndecoratedNav<T> = T & {
546
- nav?: IUndecoratedMenuPage;
547
- };
548
- type IDecoratedNav<T> = T & {
549
- nav?: IMenuPage;
550
- };
546
+ type IUndecoratedNav = IUndecoratedMenuPage;
547
+ type IDecoratedNav = IMenuPage;
551
548
 
552
549
  type Pagination = {
553
550
  hasNextPage: boolean;
@@ -1265,12 +1262,6 @@ declare function isRelation(item: unknown): item is IPageRelation;
1265
1262
  * @returns True if the item is an undecorated menu item, false otherwise.
1266
1263
  */
1267
1264
  declare function isUndecoratedMenuItem(item: unknown): item is IUndecoratedMenuItem;
1268
- /**
1269
- * Checks if the given item is an undecorated navigation.
1270
- * @param item The item to check.
1271
- * @returns True if the item is an undecorated navigation, false otherwise.
1272
- */
1273
- declare function isUndecoratedNav<T>(item: unknown): item is IUndecoratedNav<T>;
1274
1265
  /**
1275
1266
  * Checks if the given item is an undecorated menu category.
1276
1267
  * @param item The item to check.
@@ -1283,6 +1274,12 @@ declare function isUndecoratedMenuCategory(item: unknown): item is IUndecoratedM
1283
1274
  * @returns True if the item is an undecorated menu page, false otherwise.
1284
1275
  */
1285
1276
  declare function isUndecoratedMenuPage(item: unknown): item is IUndecoratedMenuPage;
1277
+ /**
1278
+ * Checks if the given item is an undecorated navigation.
1279
+ * @param item The item to check.
1280
+ * @returns True if the item is an undecorated navigation, false otherwise.
1281
+ */
1282
+ declare function isUndecoratedNav(item: unknown): item is IUndecoratedNav;
1286
1283
 
1287
1284
  /**
1288
1285
  * Generates a random UUID (Universally Unique Identifier) in version 4 format.
package/dist/index.js CHANGED
@@ -188,15 +188,15 @@ function isRelation(item) {
188
188
  function isUndecoratedMenuItem(item) {
189
189
  return isObject(item) && (item.type === "category" && isEquatable(item.category) || item.type === "page" && isEquatable(item.page.value));
190
190
  }
191
- function isUndecoratedNav(item) {
192
- return isObject(item) && isUndecoratedMenuPage(item.nav);
193
- }
194
191
  function isUndecoratedMenuCategory(item) {
195
192
  return isObject(item) && item.type === "category" && isNotNullString(item.category) && item.id === void 0 && item.href === void 0;
196
193
  }
197
194
  function isUndecoratedMenuPage(item) {
198
195
  return isObject(item) && item.type === "page" && isObject(item.page) && isNotNullString(item.page.relationTo) && isEquatable(item.page.value);
199
196
  }
197
+ function isUndecoratedNav(item) {
198
+ return isUndecoratedMenuPage(item);
199
+ }
200
200
 
201
201
  // src/utils/asEquatable.ts
202
202
  function asEquatable(value) {
@@ -725,7 +725,7 @@ async function httpDelete(url, options = {}) {
725
725
 
726
726
  // src/image/image.ts
727
727
  function getSecret() {
728
- return process.env.IMAGE_SECRET || "The sun sets over the calm ocean";
728
+ return process.env.IMAGE_SECRET || "IMAGE_SECRET";
729
729
  }
730
730
  function textToArrayBuffer_(text) {
731
731
  const encoder = new TextEncoder();
@@ -1378,6 +1378,7 @@ function getPickedProps(item) {
1378
1378
  const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
1379
1379
  "category",
1380
1380
  "isDefault",
1381
+ "media",
1381
1382
  "order",
1382
1383
  "template",
1383
1384
  "updatedAt",
@@ -1398,43 +1399,20 @@ function collectRoutes(store, categories, markets, locales, medias) {
1398
1399
  if (Boolean(item.isDefault) === false) {
1399
1400
  slugs.push({ slug: item.slug });
1400
1401
  }
1401
- if (rootCategory && item.category === rootCategory.id) {
1402
- const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
1403
- const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
1404
- const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
1405
- const title = localize(item.title, defaultMarketLocale);
1406
- const pickedProps = getPickedProps(item);
1407
- const route = {
1408
- ...pickedProps,
1409
- resolvedCategory: rootCategory.id,
1410
- id: "/",
1411
- market: defaultMarket2.id,
1412
- locale: defaultMarketLocale,
1413
- page: item.id,
1414
- schema: key,
1415
- title
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
- }
1424
- routes.push(route);
1425
- }
1402
+ const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
1403
+ const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
1404
+ const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
1405
+ const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
1426
1406
  eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
1427
1407
  if (!item.markets || item.markets.includes(market.id)) {
1428
1408
  const title = localize(item.title, locale.id);
1429
1409
  const id = getRouteHref(slugs, market, locale, markets2, locales2);
1430
- if (!id) {
1431
- return;
1432
- }
1410
+ const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
1433
1411
  const pickedProps = getPickedProps(item);
1434
1412
  const route = {
1435
1413
  ...pickedProps,
1436
1414
  resolvedCategory: visibleCategory.id,
1437
- id,
1415
+ id: isDefaultRootCategory ? "/" : id,
1438
1416
  locale: locale.id,
1439
1417
  market: market.id,
1440
1418
  page: item.id,
package/dist/index.mjs CHANGED
@@ -40,15 +40,15 @@ function isRelation(item) {
40
40
  function isUndecoratedMenuItem(item) {
41
41
  return isObject(item) && (item.type === "category" && isEquatable(item.category) || item.type === "page" && isEquatable(item.page.value));
42
42
  }
43
- function isUndecoratedNav(item) {
44
- return isObject(item) && isUndecoratedMenuPage(item.nav);
45
- }
46
43
  function isUndecoratedMenuCategory(item) {
47
44
  return isObject(item) && item.type === "category" && isNotNullString(item.category) && item.id === void 0 && item.href === void 0;
48
45
  }
49
46
  function isUndecoratedMenuPage(item) {
50
47
  return isObject(item) && item.type === "page" && isObject(item.page) && isNotNullString(item.page.relationTo) && isEquatable(item.page.value);
51
48
  }
49
+ function isUndecoratedNav(item) {
50
+ return isUndecoratedMenuPage(item);
51
+ }
52
52
 
53
53
  // src/utils/asEquatable.ts
54
54
  function asEquatable(value) {
@@ -577,7 +577,7 @@ async function httpDelete(url, options = {}) {
577
577
 
578
578
  // src/image/image.ts
579
579
  function getSecret() {
580
- return process.env.IMAGE_SECRET || "The sun sets over the calm ocean";
580
+ return process.env.IMAGE_SECRET || "IMAGE_SECRET";
581
581
  }
582
582
  function textToArrayBuffer_(text) {
583
583
  const encoder = new TextEncoder();
@@ -1230,6 +1230,7 @@ function getPickedProps(item) {
1230
1230
  const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
1231
1231
  "category",
1232
1232
  "isDefault",
1233
+ "media",
1233
1234
  "order",
1234
1235
  "template",
1235
1236
  "updatedAt",
@@ -1250,43 +1251,20 @@ function collectRoutes(store, categories, markets, locales, medias) {
1250
1251
  if (Boolean(item.isDefault) === false) {
1251
1252
  slugs.push({ slug: item.slug });
1252
1253
  }
1253
- if (rootCategory && item.category === rootCategory.id) {
1254
- const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
1255
- const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
1256
- const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
1257
- const title = localize(item.title, defaultMarketLocale);
1258
- const pickedProps = getPickedProps(item);
1259
- const route = {
1260
- ...pickedProps,
1261
- resolvedCategory: rootCategory.id,
1262
- id: "/",
1263
- market: defaultMarket2.id,
1264
- locale: defaultMarketLocale,
1265
- page: item.id,
1266
- schema: key,
1267
- title
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
- }
1276
- routes.push(route);
1277
- }
1254
+ const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
1255
+ const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
1256
+ const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
1257
+ const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
1278
1258
  eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
1279
1259
  if (!item.markets || item.markets.includes(market.id)) {
1280
1260
  const title = localize(item.title, locale.id);
1281
1261
  const id = getRouteHref(slugs, market, locale, markets2, locales2);
1282
- if (!id) {
1283
- return;
1284
- }
1262
+ const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
1285
1263
  const pickedProps = getPickedProps(item);
1286
1264
  const route = {
1287
1265
  ...pickedProps,
1288
1266
  resolvedCategory: visibleCategory.id,
1289
- id,
1267
+ id: isDefaultRootCategory ? "/" : id,
1290
1268
  locale: locale.id,
1291
1269
  market: market.id,
1292
1270
  page: item.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",