@websolutespa/bom-core 1.8.18 → 1.8.19
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 +8 -1
- package/dist/index.js +11 -1
- package/dist/index.mjs +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1111,6 +1111,7 @@ declare function findRoutesOfCategory(routes: IRoute[], categoryId: IEquatable,
|
|
|
1111
1111
|
declare function getRouteHref(segments: {
|
|
1112
1112
|
slug: ILocalizable;
|
|
1113
1113
|
}[], market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]): string;
|
|
1114
|
+
declare function hasMarket(item: ICategorized, market: IMarket): boolean;
|
|
1114
1115
|
|
|
1115
1116
|
declare function arrayShuffle<T extends IEntity>(items: T[]): T[];
|
|
1116
1117
|
|
|
@@ -1252,6 +1253,12 @@ declare function isValidString(item: unknown): item is string;
|
|
|
1252
1253
|
* @returns True if the item is an array, false otherwise.
|
|
1253
1254
|
*/
|
|
1254
1255
|
declare function isArray<T = unknown>(item: unknown): item is Array<T>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Checks if the given item is an array and is not empty.
|
|
1258
|
+
* @param item The item to check.
|
|
1259
|
+
* @returns True if the item is an array and its length is > 0, false otherwise.
|
|
1260
|
+
*/
|
|
1261
|
+
declare function isNonEmptyArray<T = unknown>(item: unknown): item is Array<T>;
|
|
1255
1262
|
/**
|
|
1256
1263
|
* Checks if the given item is an object.
|
|
1257
1264
|
* @param item The item to check.
|
|
@@ -1344,4 +1351,4 @@ declare function asServerProps(props: any): any;
|
|
|
1344
1351
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1345
1352
|
declare function merge(target: any, source: any): any;
|
|
1346
1353
|
|
|
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 };
|
|
1354
|
+
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
|
}
|
|
@@ -1703,7 +1708,7 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1703
1708
|
const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
|
|
1704
1709
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1705
1710
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1706
|
-
if (
|
|
1711
|
+
if (hasMarket(item, market)) {
|
|
1707
1712
|
const title = localize(item.title, locale.id);
|
|
1708
1713
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1709
1714
|
const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
|
|
@@ -1799,6 +1804,9 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1799
1804
|
const prefix = prefixes.length ? `/${prefixes.join("-")}` : "";
|
|
1800
1805
|
return `${prefix}${href}`;
|
|
1801
1806
|
}
|
|
1807
|
+
function hasMarket(item, market) {
|
|
1808
|
+
return !item.markets || item.markets.length === 0 || item.markets.includes(market.id);
|
|
1809
|
+
}
|
|
1802
1810
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1803
1811
|
0 && (module.exports = {
|
|
1804
1812
|
ImageStrategy,
|
|
@@ -1856,6 +1864,7 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1856
1864
|
getRouteHref,
|
|
1857
1865
|
groupComponents,
|
|
1858
1866
|
hasComponents,
|
|
1867
|
+
hasMarket,
|
|
1859
1868
|
httpDelete,
|
|
1860
1869
|
httpFetch,
|
|
1861
1870
|
httpGet,
|
|
@@ -1883,6 +1892,7 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1883
1892
|
isMenuLink,
|
|
1884
1893
|
isMenuPage,
|
|
1885
1894
|
isMenuRoute,
|
|
1895
|
+
isNonEmptyArray,
|
|
1886
1896
|
isNotNullString,
|
|
1887
1897
|
isNumber,
|
|
1888
1898
|
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
|
}
|
|
@@ -1536,7 +1539,7 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1536
1539
|
const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
|
|
1537
1540
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1538
1541
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1539
|
-
if (
|
|
1542
|
+
if (hasMarket(item, market)) {
|
|
1540
1543
|
const title = localize(item.title, locale.id);
|
|
1541
1544
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1542
1545
|
const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
|
|
@@ -1632,6 +1635,9 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1632
1635
|
const prefix = prefixes.length ? `/${prefixes.join("-")}` : "";
|
|
1633
1636
|
return `${prefix}${href}`;
|
|
1634
1637
|
}
|
|
1638
|
+
function hasMarket(item, market) {
|
|
1639
|
+
return !item.markets || item.markets.length === 0 || item.markets.includes(market.id);
|
|
1640
|
+
}
|
|
1635
1641
|
export {
|
|
1636
1642
|
ImageStrategy,
|
|
1637
1643
|
JsonService,
|
|
@@ -1688,6 +1694,7 @@ export {
|
|
|
1688
1694
|
getRouteHref,
|
|
1689
1695
|
groupComponents,
|
|
1690
1696
|
hasComponents,
|
|
1697
|
+
hasMarket,
|
|
1691
1698
|
httpDelete,
|
|
1692
1699
|
httpFetch,
|
|
1693
1700
|
httpGet,
|
|
@@ -1715,6 +1722,7 @@ export {
|
|
|
1715
1722
|
isMenuLink,
|
|
1716
1723
|
isMenuPage,
|
|
1717
1724
|
isMenuRoute,
|
|
1725
|
+
isNonEmptyArray,
|
|
1718
1726
|
isNotNullString,
|
|
1719
1727
|
isNumber,
|
|
1720
1728
|
isObject,
|