@websolutespa/bom-core 1.8.18 → 1.8.20
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 +9 -1
- package/dist/index.js +16 -3
- package/dist/index.mjs +14 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -262,6 +262,7 @@ type ICategorized = IEntity & {
|
|
|
262
262
|
markets?: string[];
|
|
263
263
|
createdAt?: Date;
|
|
264
264
|
updatedAt?: Date;
|
|
265
|
+
_status?: string;
|
|
265
266
|
};
|
|
266
267
|
|
|
267
268
|
type IClassNameValue = string | boolean | number | null | undefined;
|
|
@@ -1111,6 +1112,7 @@ declare function findRoutesOfCategory(routes: IRoute[], categoryId: IEquatable,
|
|
|
1111
1112
|
declare function getRouteHref(segments: {
|
|
1112
1113
|
slug: ILocalizable;
|
|
1113
1114
|
}[], market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]): string;
|
|
1115
|
+
declare function hasMarket(item: ICategorized, market: IMarket): boolean;
|
|
1114
1116
|
|
|
1115
1117
|
declare function arrayShuffle<T extends IEntity>(items: T[]): T[];
|
|
1116
1118
|
|
|
@@ -1252,6 +1254,12 @@ declare function isValidString(item: unknown): item is string;
|
|
|
1252
1254
|
* @returns True if the item is an array, false otherwise.
|
|
1253
1255
|
*/
|
|
1254
1256
|
declare function isArray<T = unknown>(item: unknown): item is Array<T>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Checks if the given item is an array and is not empty.
|
|
1259
|
+
* @param item The item to check.
|
|
1260
|
+
* @returns True if the item is an array and its length is > 0, false otherwise.
|
|
1261
|
+
*/
|
|
1262
|
+
declare function isNonEmptyArray<T = unknown>(item: unknown): item is Array<T>;
|
|
1255
1263
|
/**
|
|
1256
1264
|
* Checks if the given item is an object.
|
|
1257
1265
|
* @param item The item to check.
|
|
@@ -1344,4 +1352,4 @@ declare function asServerProps(props: any): any;
|
|
|
1344
1352
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1345
1353
|
declare function merge(target: any, source: any): any;
|
|
1346
1354
|
|
|
1347
|
-
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, Headings, IAction, IActionEmailData, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEmailConfig, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, IImageResize, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedMenu, ILocalizedString, IMarket, IMedia, IMediaImage, IMediaInfo, IMediaJson, IMediaPdf, IMediaType, IMediaVideo, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageItem, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, ImageStrategy, Json, JsonService, LiteralUnion, Logger, LoggerLevel, MenuCategoryStrategy, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RequireAtLeastOne, RouteStrategy, SchemaType, ServerSidePropsContext, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, arrayShuffle, asCategoryId, asEntityId, asEquatable, asEquatableNumber, asEquatableString, asServerProps, asSortedOptions, awaitAll, base64ToString, camelToSnakeCase, cloneItem, collectFeatureTypes, collectFeatureTypes__, collectOptions, collectRoutes, consoleWarn, decryptImageResize, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, eachMedia, eachValue, encryptImageToken, enumToList, excludeComponent, findCategoryInCategories, findChildCategories, findRouteOfCategory, findRoutesOfCategory, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getParentCategory, getProto, getRootCategory, getRouteHref, groupComponents, hasComponents, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isComponent, isComponentOfType, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMedia, isMediaImage, isMediaJson, isMediaPdf, isMediaVideo, isMenuCategory, isMenuGroup, isMenuHref, isMenuLink, isMenuPage, isMenuRoute, isNotNullString, isNumber, isObject, isProduction, isPromise, isRelation, isReservedCollectionDescription, isStage, isString, isUndecoratedCategory, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedCategory, isUnresolvedRelation, isValidCollectionDescription, isValidString, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, passwordStrategy, pickComponent, pickHero, prependHero, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, stringToBase64, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, uuidv4, withSchema };
|
|
1355
|
+
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, Headings, IAction, IActionEmailData, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEmailConfig, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, IImageResize, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedMenu, ILocalizedString, IMarket, IMedia, IMediaImage, IMediaInfo, IMediaJson, IMediaPdf, IMediaType, IMediaVideo, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageItem, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, ImageStrategy, Json, JsonService, LiteralUnion, Logger, LoggerLevel, MenuCategoryStrategy, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RequireAtLeastOne, RouteStrategy, SchemaType, ServerSidePropsContext, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, arrayShuffle, asCategoryId, asEntityId, asEquatable, asEquatableNumber, asEquatableString, asServerProps, asSortedOptions, awaitAll, base64ToString, camelToSnakeCase, cloneItem, collectFeatureTypes, collectFeatureTypes__, collectOptions, collectRoutes, consoleWarn, decryptImageResize, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, eachMedia, eachValue, encryptImageToken, enumToList, excludeComponent, findCategoryInCategories, findChildCategories, findRouteOfCategory, findRoutesOfCategory, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getParentCategory, getProto, getRootCategory, getRouteHref, groupComponents, hasComponents, hasMarket, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isComponent, isComponentOfType, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMedia, isMediaImage, isMediaJson, isMediaPdf, isMediaVideo, isMenuCategory, isMenuGroup, isMenuHref, isMenuLink, isMenuPage, isMenuRoute, isNonEmptyArray, isNotNullString, isNumber, isObject, isProduction, isPromise, isRelation, isReservedCollectionDescription, isStage, isString, isUndecoratedCategory, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedCategory, isUnresolvedRelation, isValidCollectionDescription, isValidString, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, passwordStrategy, pickComponent, pickHero, prependHero, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, stringToBase64, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, uuidv4, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -85,6 +85,7 @@ __export(src_exports, {
|
|
|
85
85
|
getRouteHref: () => getRouteHref,
|
|
86
86
|
groupComponents: () => groupComponents,
|
|
87
87
|
hasComponents: () => hasComponents,
|
|
88
|
+
hasMarket: () => hasMarket,
|
|
88
89
|
httpDelete: () => httpDelete,
|
|
89
90
|
httpFetch: () => httpFetch,
|
|
90
91
|
httpGet: () => httpGet,
|
|
@@ -112,6 +113,7 @@ __export(src_exports, {
|
|
|
112
113
|
isMenuLink: () => isMenuLink,
|
|
113
114
|
isMenuPage: () => isMenuPage,
|
|
114
115
|
isMenuRoute: () => isMenuRoute,
|
|
116
|
+
isNonEmptyArray: () => isNonEmptyArray,
|
|
115
117
|
isNotNullString: () => isNotNullString,
|
|
116
118
|
isNumber: () => isNumber,
|
|
117
119
|
isObject: () => isObject,
|
|
@@ -183,6 +185,9 @@ function isValidString(item) {
|
|
|
183
185
|
function isArray(item) {
|
|
184
186
|
return Array.isArray(item);
|
|
185
187
|
}
|
|
188
|
+
function isNonEmptyArray(item) {
|
|
189
|
+
return Array.isArray(item) && item.length > 0;
|
|
190
|
+
}
|
|
186
191
|
function isObject(item) {
|
|
187
192
|
return item != null && typeof item === "object" && !isArray(item);
|
|
188
193
|
}
|
|
@@ -574,7 +579,7 @@ function isMediaPdf(media) {
|
|
|
574
579
|
return false;
|
|
575
580
|
}
|
|
576
581
|
function isMedia(item) {
|
|
577
|
-
return isObject(item) && "type" in item && (isValidString(item.url) || isValidString(item.src));
|
|
582
|
+
return isObject(item) && ("mimeType" in item || "type" in item) && (isValidString(item.url) || isValidString(item.src));
|
|
578
583
|
}
|
|
579
584
|
|
|
580
585
|
// src/types/menu.ts
|
|
@@ -1681,7 +1686,10 @@ function getPickedProps(item) {
|
|
|
1681
1686
|
"order",
|
|
1682
1687
|
"template",
|
|
1683
1688
|
"updatedAt",
|
|
1684
|
-
"useSplat"
|
|
1689
|
+
"useSplat",
|
|
1690
|
+
// 'createdAt',
|
|
1691
|
+
"updatedAt",
|
|
1692
|
+
"_status"
|
|
1685
1693
|
].includes(k)));
|
|
1686
1694
|
return pickedProps;
|
|
1687
1695
|
}
|
|
@@ -1703,7 +1711,7 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1703
1711
|
const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
|
|
1704
1712
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1705
1713
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1706
|
-
if (
|
|
1714
|
+
if (hasMarket(item, market)) {
|
|
1707
1715
|
const title = localize(item.title, locale.id);
|
|
1708
1716
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1709
1717
|
const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
|
|
@@ -1799,6 +1807,9 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1799
1807
|
const prefix = prefixes.length ? `/${prefixes.join("-")}` : "";
|
|
1800
1808
|
return `${prefix}${href}`;
|
|
1801
1809
|
}
|
|
1810
|
+
function hasMarket(item, market) {
|
|
1811
|
+
return !item.markets || item.markets.length === 0 || item.markets.includes(market.id);
|
|
1812
|
+
}
|
|
1802
1813
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1803
1814
|
0 && (module.exports = {
|
|
1804
1815
|
ImageStrategy,
|
|
@@ -1856,6 +1867,7 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1856
1867
|
getRouteHref,
|
|
1857
1868
|
groupComponents,
|
|
1858
1869
|
hasComponents,
|
|
1870
|
+
hasMarket,
|
|
1859
1871
|
httpDelete,
|
|
1860
1872
|
httpFetch,
|
|
1861
1873
|
httpGet,
|
|
@@ -1883,6 +1895,7 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1883
1895
|
isMenuLink,
|
|
1884
1896
|
isMenuPage,
|
|
1885
1897
|
isMenuRoute,
|
|
1898
|
+
isNonEmptyArray,
|
|
1886
1899
|
isNotNullString,
|
|
1887
1900
|
isNumber,
|
|
1888
1901
|
isObject,
|
package/dist/index.mjs
CHANGED
|
@@ -16,6 +16,9 @@ function isValidString(item) {
|
|
|
16
16
|
function isArray(item) {
|
|
17
17
|
return Array.isArray(item);
|
|
18
18
|
}
|
|
19
|
+
function isNonEmptyArray(item) {
|
|
20
|
+
return Array.isArray(item) && item.length > 0;
|
|
21
|
+
}
|
|
19
22
|
function isObject(item) {
|
|
20
23
|
return item != null && typeof item === "object" && !isArray(item);
|
|
21
24
|
}
|
|
@@ -407,7 +410,7 @@ function isMediaPdf(media) {
|
|
|
407
410
|
return false;
|
|
408
411
|
}
|
|
409
412
|
function isMedia(item) {
|
|
410
|
-
return isObject(item) && "type" in item && (isValidString(item.url) || isValidString(item.src));
|
|
413
|
+
return isObject(item) && ("mimeType" in item || "type" in item) && (isValidString(item.url) || isValidString(item.src));
|
|
411
414
|
}
|
|
412
415
|
|
|
413
416
|
// src/types/menu.ts
|
|
@@ -1514,7 +1517,10 @@ function getPickedProps(item) {
|
|
|
1514
1517
|
"order",
|
|
1515
1518
|
"template",
|
|
1516
1519
|
"updatedAt",
|
|
1517
|
-
"useSplat"
|
|
1520
|
+
"useSplat",
|
|
1521
|
+
// 'createdAt',
|
|
1522
|
+
"updatedAt",
|
|
1523
|
+
"_status"
|
|
1518
1524
|
].includes(k)));
|
|
1519
1525
|
return pickedProps;
|
|
1520
1526
|
}
|
|
@@ -1536,7 +1542,7 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1536
1542
|
const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
|
|
1537
1543
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1538
1544
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1539
|
-
if (
|
|
1545
|
+
if (hasMarket(item, market)) {
|
|
1540
1546
|
const title = localize(item.title, locale.id);
|
|
1541
1547
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1542
1548
|
const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
|
|
@@ -1632,6 +1638,9 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1632
1638
|
const prefix = prefixes.length ? `/${prefixes.join("-")}` : "";
|
|
1633
1639
|
return `${prefix}${href}`;
|
|
1634
1640
|
}
|
|
1641
|
+
function hasMarket(item, market) {
|
|
1642
|
+
return !item.markets || item.markets.length === 0 || item.markets.includes(market.id);
|
|
1643
|
+
}
|
|
1635
1644
|
export {
|
|
1636
1645
|
ImageStrategy,
|
|
1637
1646
|
JsonService,
|
|
@@ -1688,6 +1697,7 @@ export {
|
|
|
1688
1697
|
getRouteHref,
|
|
1689
1698
|
groupComponents,
|
|
1690
1699
|
hasComponents,
|
|
1700
|
+
hasMarket,
|
|
1691
1701
|
httpDelete,
|
|
1692
1702
|
httpFetch,
|
|
1693
1703
|
httpGet,
|
|
@@ -1715,6 +1725,7 @@ export {
|
|
|
1715
1725
|
isMenuLink,
|
|
1716
1726
|
isMenuPage,
|
|
1717
1727
|
isMenuRoute,
|
|
1728
|
+
isNonEmptyArray,
|
|
1718
1729
|
isNotNullString,
|
|
1719
1730
|
isNumber,
|
|
1720
1731
|
isObject,
|