@websolutespa/bom-core 1.8.7 → 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 +6 -0
- package/dist/index.d.ts +11 -14
- package/dist/index.js +10 -33
- package/dist/index.mjs +10 -33
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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' | '
|
|
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
|
|
546
|
-
|
|
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 || "
|
|
728
|
+
return process.env.IMAGE_SECRET || "IMAGE_SECRET";
|
|
729
729
|
}
|
|
730
730
|
function textToArrayBuffer_(text) {
|
|
731
731
|
const encoder = new TextEncoder();
|
|
@@ -1399,43 +1399,20 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1399
1399
|
if (Boolean(item.isDefault) === false) {
|
|
1400
1400
|
slugs.push({ slug: item.slug });
|
|
1401
1401
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
const title = localize(item.title, defaultMarketLocale);
|
|
1407
|
-
const pickedProps = getPickedProps(item);
|
|
1408
|
-
const route = {
|
|
1409
|
-
...pickedProps,
|
|
1410
|
-
resolvedCategory: rootCategory.id,
|
|
1411
|
-
id: "/",
|
|
1412
|
-
market: defaultMarket2.id,
|
|
1413
|
-
locale: defaultMarketLocale,
|
|
1414
|
-
page: item.id,
|
|
1415
|
-
schema: key,
|
|
1416
|
-
title
|
|
1417
|
-
};
|
|
1418
|
-
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1419
|
-
if (Array.isArray(medias) && mediaId) {
|
|
1420
|
-
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1421
|
-
if (media) {
|
|
1422
|
-
route.media = media;
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
routes.push(route);
|
|
1426
|
-
}
|
|
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;
|
|
1427
1406
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1428
1407
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
1429
1408
|
const title = localize(item.title, locale.id);
|
|
1430
1409
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1431
|
-
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1410
|
+
const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
|
|
1434
1411
|
const pickedProps = getPickedProps(item);
|
|
1435
1412
|
const route = {
|
|
1436
1413
|
...pickedProps,
|
|
1437
1414
|
resolvedCategory: visibleCategory.id,
|
|
1438
|
-
id,
|
|
1415
|
+
id: isDefaultRootCategory ? "/" : id,
|
|
1439
1416
|
locale: locale.id,
|
|
1440
1417
|
market: market.id,
|
|
1441
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 || "
|
|
580
|
+
return process.env.IMAGE_SECRET || "IMAGE_SECRET";
|
|
581
581
|
}
|
|
582
582
|
function textToArrayBuffer_(text) {
|
|
583
583
|
const encoder = new TextEncoder();
|
|
@@ -1251,43 +1251,20 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1251
1251
|
if (Boolean(item.isDefault) === false) {
|
|
1252
1252
|
slugs.push({ slug: item.slug });
|
|
1253
1253
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
const title = localize(item.title, defaultMarketLocale);
|
|
1259
|
-
const pickedProps = getPickedProps(item);
|
|
1260
|
-
const route = {
|
|
1261
|
-
...pickedProps,
|
|
1262
|
-
resolvedCategory: rootCategory.id,
|
|
1263
|
-
id: "/",
|
|
1264
|
-
market: defaultMarket2.id,
|
|
1265
|
-
locale: defaultMarketLocale,
|
|
1266
|
-
page: item.id,
|
|
1267
|
-
schema: key,
|
|
1268
|
-
title
|
|
1269
|
-
};
|
|
1270
|
-
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1271
|
-
if (Array.isArray(medias) && mediaId) {
|
|
1272
|
-
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1273
|
-
if (media) {
|
|
1274
|
-
route.media = media;
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
routes.push(route);
|
|
1278
|
-
}
|
|
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;
|
|
1279
1258
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1280
1259
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
1281
1260
|
const title = localize(item.title, locale.id);
|
|
1282
1261
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1283
|
-
|
|
1284
|
-
return;
|
|
1285
|
-
}
|
|
1262
|
+
const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
|
|
1286
1263
|
const pickedProps = getPickedProps(item);
|
|
1287
1264
|
const route = {
|
|
1288
1265
|
...pickedProps,
|
|
1289
1266
|
resolvedCategory: visibleCategory.id,
|
|
1290
|
-
id,
|
|
1267
|
+
id: isDefaultRootCategory ? "/" : id,
|
|
1291
1268
|
locale: locale.id,
|
|
1292
1269
|
market: market.id,
|
|
1293
1270
|
page: item.id,
|