@websolutespa/bom-core 0.6.2 → 0.6.4
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 +95 -82
- package/dist/index.d.ts +9 -9
- package/dist/index.js +20 -1
- package/dist/index.mjs +18 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,82 +1,95 @@
|
|
|
1
|
-
# @websolutespa/bom-core
|
|
2
|
-
|
|
3
|
-
## 0.6.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- Added:
|
|
27
|
-
|
|
28
|
-
## 0.
|
|
29
|
-
|
|
30
|
-
###
|
|
31
|
-
|
|
32
|
-
- Added
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
## 0.
|
|
79
|
-
|
|
80
|
-
### Patch Changes
|
|
81
|
-
|
|
82
|
-
-
|
|
1
|
+
# @websolutespa/bom-core
|
|
2
|
+
|
|
3
|
+
## 0.6.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added: typeGuards, IPagedResult.
|
|
8
|
+
- Modified: IUndecoratedMenuCustom.
|
|
9
|
+
|
|
10
|
+
## 0.6.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Added: isReservedCollectionDescription.
|
|
15
|
+
|
|
16
|
+
## 0.6.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Modified: IMedia.
|
|
21
|
+
|
|
22
|
+
## 0.6.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Added: defaultMarket, defaultLocale.
|
|
27
|
+
|
|
28
|
+
## 0.6.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- Added Logger, IPaginationResult.
|
|
33
|
+
|
|
34
|
+
## 0.5.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- Modified: JsonService, qs.
|
|
39
|
+
- Added: asEquatable, cloneItem, typeGuards.
|
|
40
|
+
|
|
41
|
+
## 0.4.1
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Added: IAnchor, babelCase.
|
|
46
|
+
- Modified: IApplication, IPageRelation.
|
|
47
|
+
|
|
48
|
+
## 0.4.0
|
|
49
|
+
|
|
50
|
+
### Minor Changes
|
|
51
|
+
|
|
52
|
+
- Updating: next 13.
|
|
53
|
+
|
|
54
|
+
## 0.3.0
|
|
55
|
+
|
|
56
|
+
### Minor Changes
|
|
57
|
+
|
|
58
|
+
- Modified: HttpService.
|
|
59
|
+
|
|
60
|
+
## 0.2.1
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Added: env ROOT_CATEGORY.
|
|
65
|
+
|
|
66
|
+
## 0.2.0
|
|
67
|
+
|
|
68
|
+
### Minor Changes
|
|
69
|
+
|
|
70
|
+
- Modified routes, added redirects.
|
|
71
|
+
|
|
72
|
+
## 0.1.2
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Modified: MockMenuService.
|
|
77
|
+
|
|
78
|
+
## 0.1.1
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- Modified: ILocalizable.
|
|
83
|
+
|
|
84
|
+
## 0.1.0
|
|
85
|
+
|
|
86
|
+
### Minor Changes
|
|
87
|
+
|
|
88
|
+
- Added: splat routes.
|
|
89
|
+
- Added: variants.
|
|
90
|
+
|
|
91
|
+
## 0.0.1
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Added: first release.
|
package/dist/index.d.ts
CHANGED
|
@@ -324,8 +324,7 @@ type IUndecoratedMenuPage = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
|
324
324
|
page: IPageRelation;
|
|
325
325
|
title?: ILocalizable;
|
|
326
326
|
};
|
|
327
|
-
type IUndecoratedMenuCustom =
|
|
328
|
-
id: IEquatable;
|
|
327
|
+
type IUndecoratedMenuCustom = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
329
328
|
type: 'custom';
|
|
330
329
|
blockType: string;
|
|
331
330
|
};
|
|
@@ -394,12 +393,13 @@ type QueryParams = {
|
|
|
394
393
|
richText?: boolean;
|
|
395
394
|
};
|
|
396
395
|
|
|
396
|
+
type IPagedResult<T extends IEntity = IEntity> = {
|
|
397
|
+
docs: T[];
|
|
398
|
+
} & Pagination;
|
|
397
399
|
type IQuerable<T extends IEntity = IEntity> = {
|
|
398
400
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
399
401
|
findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
|
|
400
|
-
findPaged<B extends T = T>(params?: QueryParams): Promise<
|
|
401
|
-
docs: B[];
|
|
402
|
-
} & Pagination>;
|
|
402
|
+
findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
|
|
403
403
|
create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
|
|
404
404
|
update<B extends T = T>(payload: Partial<B>): Promise<B>;
|
|
405
405
|
delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
|
|
@@ -479,6 +479,7 @@ declare function getClassNames(...props: Array<IClassName>): string;
|
|
|
479
479
|
declare function getCollectionDescription(text: string): ICollectionDescription;
|
|
480
480
|
declare function camelToSnakeCase(text: string): string;
|
|
481
481
|
declare function isValidCollectionDescription(description: ICollectionDescription): boolean;
|
|
482
|
+
declare function isReservedCollectionDescription(description: ICollectionDescription): boolean;
|
|
482
483
|
declare function toDisplayName(text: string): string;
|
|
483
484
|
declare function toPluralName(text: string): string;
|
|
484
485
|
declare function toTitleCase(text: string): string;
|
|
@@ -499,9 +500,7 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
|
499
500
|
getItems<B extends T = T>(): Promise<B[]>;
|
|
500
501
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
501
502
|
findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
|
|
502
|
-
findPaged<B extends T = T>(params?: QueryParams): Promise<
|
|
503
|
-
docs: B[];
|
|
504
|
-
} & Pagination>;
|
|
503
|
+
findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
|
|
505
504
|
create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
|
|
506
505
|
update<B extends T = T>(payload: Partial<B>): Promise<B>;
|
|
507
506
|
delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
|
|
@@ -611,6 +610,7 @@ declare function isUnresolvedRelation(item: unknown): item is IPageUnresolvedRel
|
|
|
611
610
|
declare function isRelation(item: unknown): item is IPageRelation;
|
|
612
611
|
declare function isUndecoratedMenuItem(item: unknown): item is IUndecoratedMenuItem;
|
|
613
612
|
declare function isUndecoratedNav<T>(item: unknown): item is IUndecoratedNav<T>;
|
|
613
|
+
declare function isUndecoratedMenuCategory(item: unknown): item is IUndecoratedMenuCategory;
|
|
614
614
|
declare function isUndecoratedMenuPage(item: unknown): item is IUndecoratedMenuPage;
|
|
615
615
|
|
|
616
616
|
declare function getIsDevelopment(): boolean;
|
|
@@ -625,4 +625,4 @@ declare function asServerProps(props: any): any;
|
|
|
625
625
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
626
626
|
declare function merge(target: any, source: any): any;
|
|
627
627
|
|
|
628
|
-
export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IDecoratedNav, IEntity, IEquatable, 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, 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, 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, isStage, 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 };
|
|
628
|
+
export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IDecoratedNav, IEntity, IEquatable, 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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,9 @@ __export(src_exports, {
|
|
|
75
75
|
isObject: () => isObject,
|
|
76
76
|
isProduction: () => isProduction,
|
|
77
77
|
isRelation: () => isRelation,
|
|
78
|
+
isReservedCollectionDescription: () => isReservedCollectionDescription,
|
|
78
79
|
isStage: () => isStage,
|
|
80
|
+
isUndecoratedMenuCategory: () => isUndecoratedMenuCategory,
|
|
79
81
|
isUndecoratedMenuItem: () => isUndecoratedMenuItem,
|
|
80
82
|
isUndecoratedMenuPage: () => isUndecoratedMenuPage,
|
|
81
83
|
isUndecoratedNav: () => isUndecoratedNav,
|
|
@@ -242,6 +244,18 @@ function camelToSnakeCase(text) {
|
|
|
242
244
|
function isValidCollectionDescription(description) {
|
|
243
245
|
return description.singularName !== description.pluralName;
|
|
244
246
|
}
|
|
247
|
+
function isReservedCollectionDescription(description) {
|
|
248
|
+
return [
|
|
249
|
+
"category",
|
|
250
|
+
"label",
|
|
251
|
+
"locale",
|
|
252
|
+
"market",
|
|
253
|
+
"menu",
|
|
254
|
+
"redirect",
|
|
255
|
+
"route",
|
|
256
|
+
"template"
|
|
257
|
+
].includes(description.singularName);
|
|
258
|
+
}
|
|
245
259
|
function toDisplayName(text) {
|
|
246
260
|
return toTitleCase(text).replace(/\s/g, "");
|
|
247
261
|
}
|
|
@@ -363,8 +377,11 @@ function isUndecoratedMenuItem(item) {
|
|
|
363
377
|
function isUndecoratedNav(item) {
|
|
364
378
|
return isObject(item) && isUndecoratedMenuPage(item.nav);
|
|
365
379
|
}
|
|
380
|
+
function isUndecoratedMenuCategory(item) {
|
|
381
|
+
return isObject(item) && item.type === "category" && isNotNullString(item.category) && item.id === void 0 && item.href === void 0;
|
|
382
|
+
}
|
|
366
383
|
function isUndecoratedMenuPage(item) {
|
|
367
|
-
return isObject(item) && item.type === "page" && isNotNullString(item.page.relationTo) && isEquatable(item.page.value);
|
|
384
|
+
return isObject(item) && item.type === "page" && isObject(item.page) && isNotNullString(item.page.relationTo) && isEquatable(item.page.value);
|
|
368
385
|
}
|
|
369
386
|
|
|
370
387
|
// src/utils/cloneItem.ts
|
|
@@ -1125,7 +1142,9 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1125
1142
|
isObject,
|
|
1126
1143
|
isProduction,
|
|
1127
1144
|
isRelation,
|
|
1145
|
+
isReservedCollectionDescription,
|
|
1128
1146
|
isStage,
|
|
1147
|
+
isUndecoratedMenuCategory,
|
|
1129
1148
|
isUndecoratedMenuItem,
|
|
1130
1149
|
isUndecoratedMenuPage,
|
|
1131
1150
|
isUndecoratedNav,
|
package/dist/index.mjs
CHANGED
|
@@ -129,6 +129,18 @@ function camelToSnakeCase(text) {
|
|
|
129
129
|
function isValidCollectionDescription(description) {
|
|
130
130
|
return description.singularName !== description.pluralName;
|
|
131
131
|
}
|
|
132
|
+
function isReservedCollectionDescription(description) {
|
|
133
|
+
return [
|
|
134
|
+
"category",
|
|
135
|
+
"label",
|
|
136
|
+
"locale",
|
|
137
|
+
"market",
|
|
138
|
+
"menu",
|
|
139
|
+
"redirect",
|
|
140
|
+
"route",
|
|
141
|
+
"template"
|
|
142
|
+
].includes(description.singularName);
|
|
143
|
+
}
|
|
132
144
|
function toDisplayName(text) {
|
|
133
145
|
return toTitleCase(text).replace(/\s/g, "");
|
|
134
146
|
}
|
|
@@ -250,8 +262,11 @@ function isUndecoratedMenuItem(item) {
|
|
|
250
262
|
function isUndecoratedNav(item) {
|
|
251
263
|
return isObject(item) && isUndecoratedMenuPage(item.nav);
|
|
252
264
|
}
|
|
265
|
+
function isUndecoratedMenuCategory(item) {
|
|
266
|
+
return isObject(item) && item.type === "category" && isNotNullString(item.category) && item.id === void 0 && item.href === void 0;
|
|
267
|
+
}
|
|
253
268
|
function isUndecoratedMenuPage(item) {
|
|
254
|
-
return isObject(item) && item.type === "page" && isNotNullString(item.page.relationTo) && isEquatable(item.page.value);
|
|
269
|
+
return isObject(item) && item.type === "page" && isObject(item.page) && isNotNullString(item.page.relationTo) && isEquatable(item.page.value);
|
|
255
270
|
}
|
|
256
271
|
|
|
257
272
|
// src/utils/cloneItem.ts
|
|
@@ -1011,7 +1026,9 @@ export {
|
|
|
1011
1026
|
isObject,
|
|
1012
1027
|
isProduction,
|
|
1013
1028
|
isRelation,
|
|
1029
|
+
isReservedCollectionDescription,
|
|
1014
1030
|
isStage,
|
|
1031
|
+
isUndecoratedMenuCategory,
|
|
1015
1032
|
isUndecoratedMenuItem,
|
|
1016
1033
|
isUndecoratedMenuPage,
|
|
1017
1034
|
isUndecoratedNav,
|