@websolutespa/bom-core 0.6.5 → 1.6.0
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 +114 -102
- package/dist/index.d.ts +41 -1
- package/dist/index.js +12 -1
- package/dist/index.mjs +11 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,102 +1,114 @@
|
|
|
1
|
-
# @websolutespa/bom-core
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Added:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- Modified:
|
|
28
|
-
|
|
29
|
-
## 0.6.
|
|
30
|
-
|
|
31
|
-
### Patch Changes
|
|
32
|
-
|
|
33
|
-
- Added:
|
|
34
|
-
|
|
35
|
-
## 0.6.
|
|
36
|
-
|
|
37
|
-
###
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
## 0.
|
|
42
|
-
|
|
43
|
-
###
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
- Modified:
|
|
66
|
-
|
|
67
|
-
## 0.
|
|
68
|
-
|
|
69
|
-
###
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
|
|
73
|
-
## 0.
|
|
74
|
-
|
|
75
|
-
### Minor Changes
|
|
76
|
-
|
|
77
|
-
- Modified
|
|
78
|
-
|
|
79
|
-
## 0.1
|
|
80
|
-
|
|
81
|
-
### Patch Changes
|
|
82
|
-
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
## 0.
|
|
86
|
-
|
|
87
|
-
###
|
|
88
|
-
|
|
89
|
-
- Modified
|
|
90
|
-
|
|
91
|
-
## 0.1.
|
|
92
|
-
|
|
93
|
-
###
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
1
|
+
# @websolutespa/bom-core
|
|
2
|
+
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6cbf4cb: Added: IAction, IEndUser, IConsentPreference, IPreference, ILegalNotice
|
|
8
|
+
|
|
9
|
+
## 0.6.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Modified: collectRoutes
|
|
14
|
+
|
|
15
|
+
## 0.6.5
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Added: collectFeatureTypes, collectOptions
|
|
20
|
+
- Modified: Category, collectRoutes, getRouteHref, entity
|
|
21
|
+
|
|
22
|
+
## 0.6.4
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Added: typeGuards, IPagedResult
|
|
27
|
+
- Modified: IUndecoratedMenuCustom
|
|
28
|
+
|
|
29
|
+
## 0.6.3
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Added: isReservedCollectionDescription
|
|
34
|
+
|
|
35
|
+
## 0.6.2
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Modified: IMedia
|
|
40
|
+
|
|
41
|
+
## 0.6.1
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Added: defaultMarket, defaultLocale
|
|
46
|
+
|
|
47
|
+
## 0.6.0
|
|
48
|
+
|
|
49
|
+
### Minor Changes
|
|
50
|
+
|
|
51
|
+
- Added Logger, IPaginationResult
|
|
52
|
+
|
|
53
|
+
## 0.5.0
|
|
54
|
+
|
|
55
|
+
### Minor Changes
|
|
56
|
+
|
|
57
|
+
- Modified: JsonService, qs
|
|
58
|
+
- Added: asEquatable, cloneItem, typeGuards
|
|
59
|
+
|
|
60
|
+
## 0.4.1
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Added: IAnchor, babelCase
|
|
65
|
+
- Modified: IApplication, IPageRelation
|
|
66
|
+
|
|
67
|
+
## 0.4.0
|
|
68
|
+
|
|
69
|
+
### Minor Changes
|
|
70
|
+
|
|
71
|
+
- Updating: next 13
|
|
72
|
+
|
|
73
|
+
## 0.3.0
|
|
74
|
+
|
|
75
|
+
### Minor Changes
|
|
76
|
+
|
|
77
|
+
- Modified: HttpService
|
|
78
|
+
|
|
79
|
+
## 0.2.1
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Added: env ROOT_CATEGORY
|
|
84
|
+
|
|
85
|
+
## 0.2.0
|
|
86
|
+
|
|
87
|
+
### Minor Changes
|
|
88
|
+
|
|
89
|
+
- Modified routes, added redirects
|
|
90
|
+
|
|
91
|
+
## 0.1.2
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Modified: MockMenuService
|
|
96
|
+
|
|
97
|
+
## 0.1.1
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Modified: ILocalizable
|
|
102
|
+
|
|
103
|
+
## 0.1.0
|
|
104
|
+
|
|
105
|
+
### Minor Changes
|
|
106
|
+
|
|
107
|
+
- Added: splat routes
|
|
108
|
+
- Added: variants
|
|
109
|
+
|
|
110
|
+
## 0.0.1
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Added: first release
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,44 @@ type ILocalizedString = Record<string, string>;
|
|
|
59
59
|
type ILocalizable = string | ILocalizedString;
|
|
60
60
|
type ILocalized<T> = IOverride<T, ILocalizable, string>;
|
|
61
61
|
|
|
62
|
+
type ILegalNotice = {
|
|
63
|
+
id: string;
|
|
64
|
+
text: ILocalizable;
|
|
65
|
+
};
|
|
66
|
+
type IPreference = {
|
|
67
|
+
id: string;
|
|
68
|
+
description: string;
|
|
69
|
+
legalNotice: ILegalNotice;
|
|
70
|
+
};
|
|
71
|
+
type IConsentPreference = {
|
|
72
|
+
id: string;
|
|
73
|
+
consentPreference: IPreference;
|
|
74
|
+
date: Date | string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type User = Record<string, unknown> & {
|
|
78
|
+
collection: string;
|
|
79
|
+
id: string;
|
|
80
|
+
email: string;
|
|
81
|
+
};
|
|
82
|
+
type UserRole = 'admin' | 'editor' | 'user' | string;
|
|
83
|
+
type UserWithRoles = User & {
|
|
84
|
+
roles: UserRole[];
|
|
85
|
+
};
|
|
86
|
+
type IEndUser = UserWithRoles & {
|
|
87
|
+
email: string;
|
|
88
|
+
consentPreferences: IConsentPreference[];
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type IAction = Record<string, unknown> & {
|
|
92
|
+
id: string;
|
|
93
|
+
consentPreferences: IConsentPreference[];
|
|
94
|
+
endUser: IEndUser;
|
|
95
|
+
loggedEndUser?: IEndUser;
|
|
96
|
+
email?: string;
|
|
97
|
+
password?: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
62
100
|
type IAnchor = {
|
|
63
101
|
id: string;
|
|
64
102
|
title?: ILocalizable;
|
|
@@ -297,6 +335,8 @@ type IMenuCustom = Record<string, unknown> & {
|
|
|
297
335
|
type: string;
|
|
298
336
|
};
|
|
299
337
|
type IMenuItem = IMenuCategory | IMenuGroup | IMenuLink | IMenuPage | IMenuRoute;
|
|
338
|
+
type IMenuHref = IMenuCategory | IMenuLink | IMenuPage | IMenuRoute;
|
|
339
|
+
declare function isMenuHref(item: IMenuItem): item is IMenuHref;
|
|
300
340
|
type IMenu = {
|
|
301
341
|
id: string;
|
|
302
342
|
items: IMenuItem[];
|
|
@@ -642,4 +682,4 @@ declare function asServerProps(props: any): any;
|
|
|
642
682
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
643
683
|
declare function merge(target: any, source: any): any;
|
|
644
684
|
|
|
645
|
-
export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IDecoratedNav, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILocale, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IPackages, IPage, IPageRelation, IPageRelationResult, IPageResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, 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, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getIsDevelopment, getIsProduction, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isLocalizedString, isNotNullString, isObject, isProduction, isRelation, isReservedCollectionDescription, isStage, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
|
685
|
+
export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILocale, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IPackages, IPage, IPageRelation, IPageRelationResult, IPageResult, 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, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getIsDevelopment, getIsProduction, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isLocalizedString, isMenuHref, isNotNullString, isObject, isProduction, isRelation, isReservedCollectionDescription, isStage, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -73,6 +73,7 @@ __export(src_exports, {
|
|
|
73
73
|
isEntity: () => isEntity,
|
|
74
74
|
isEquatable: () => isEquatable,
|
|
75
75
|
isLocalizedString: () => isLocalizedString,
|
|
76
|
+
isMenuHref: () => isMenuHref,
|
|
76
77
|
isNotNullString: () => isNotNullString,
|
|
77
78
|
isObject: () => isObject,
|
|
78
79
|
isProduction: () => isProduction,
|
|
@@ -1005,10 +1006,14 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1005
1006
|
const rootCategory = getRootCategory(categories);
|
|
1006
1007
|
eachCategorized(store, (item, key) => {
|
|
1007
1008
|
const segments = getCategorySegments(item, categories);
|
|
1009
|
+
const slugs = segments.map((x) => ({ slug: x.slug }));
|
|
1010
|
+
if (!item.isDefault) {
|
|
1011
|
+
slugs.push({ slug: item.slug });
|
|
1012
|
+
}
|
|
1008
1013
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1009
1014
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
1010
1015
|
const title = localize(item.title, locale.id);
|
|
1011
|
-
const id = getRouteHref(
|
|
1016
|
+
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1012
1017
|
const route = {
|
|
1013
1018
|
category: item.category,
|
|
1014
1019
|
id,
|
|
@@ -1125,6 +1130,11 @@ function resolveMediaType(media) {
|
|
|
1125
1130
|
return media.type || (media.mimeType ? media.mimeType.split("/")[0] : "image");
|
|
1126
1131
|
}
|
|
1127
1132
|
|
|
1133
|
+
// src/types/menu.ts
|
|
1134
|
+
function isMenuHref(item) {
|
|
1135
|
+
return ["category", "link", "page", "route"].includes(item.type);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1128
1138
|
// src/types/querable.ts
|
|
1129
1139
|
function toFindParams(idOrParams) {
|
|
1130
1140
|
if (typeof idOrParams === "number" || typeof idOrParams === "string") {
|
|
@@ -1188,6 +1198,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1188
1198
|
isEntity,
|
|
1189
1199
|
isEquatable,
|
|
1190
1200
|
isLocalizedString,
|
|
1201
|
+
isMenuHref,
|
|
1191
1202
|
isNotNullString,
|
|
1192
1203
|
isObject,
|
|
1193
1204
|
isProduction,
|
package/dist/index.mjs
CHANGED
|
@@ -888,10 +888,14 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
888
888
|
const rootCategory = getRootCategory(categories);
|
|
889
889
|
eachCategorized(store, (item, key) => {
|
|
890
890
|
const segments = getCategorySegments(item, categories);
|
|
891
|
+
const slugs = segments.map((x) => ({ slug: x.slug }));
|
|
892
|
+
if (!item.isDefault) {
|
|
893
|
+
slugs.push({ slug: item.slug });
|
|
894
|
+
}
|
|
891
895
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
892
896
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
893
897
|
const title = localize(item.title, locale.id);
|
|
894
|
-
const id = getRouteHref(
|
|
898
|
+
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
895
899
|
const route = {
|
|
896
900
|
category: item.category,
|
|
897
901
|
id,
|
|
@@ -1008,6 +1012,11 @@ function resolveMediaType(media) {
|
|
|
1008
1012
|
return media.type || (media.mimeType ? media.mimeType.split("/")[0] : "image");
|
|
1009
1013
|
}
|
|
1010
1014
|
|
|
1015
|
+
// src/types/menu.ts
|
|
1016
|
+
function isMenuHref(item) {
|
|
1017
|
+
return ["category", "link", "page", "route"].includes(item.type);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1011
1020
|
// src/types/querable.ts
|
|
1012
1021
|
function toFindParams(idOrParams) {
|
|
1013
1022
|
if (typeof idOrParams === "number" || typeof idOrParams === "string") {
|
|
@@ -1070,6 +1079,7 @@ export {
|
|
|
1070
1079
|
isEntity,
|
|
1071
1080
|
isEquatable,
|
|
1072
1081
|
isLocalizedString,
|
|
1082
|
+
isMenuHref,
|
|
1073
1083
|
isNotNullString,
|
|
1074
1084
|
isObject,
|
|
1075
1085
|
isProduction,
|