@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 CHANGED
@@ -1,82 +1,95 @@
1
- # @websolutespa/bom-core
2
-
3
- ## 0.6.2
4
-
5
- ### Patch Changes
6
-
7
- - Modified: IMedia.
8
-
9
- ## 0.6.1
10
-
11
- ### Patch Changes
12
-
13
- - Added: defaultMarket, defaultLocale
14
-
15
- ## 0.6.0
16
-
17
- ### Minor Changes
18
-
19
- - Added Logger, IPaginationResult.
20
-
21
- ## 0.5.0
22
-
23
- ### Minor Changes
24
-
25
- - Modified: JsonService, qs.
26
- - Added: asEquatable, cloneItem, typeGuards.
27
-
28
- ## 0.4.1
29
-
30
- ### Patch Changes
31
-
32
- - Added: IAnchor, babelCase.
33
- - Modified: IApplication, IPageRelation.
34
-
35
- ## 0.4.0
36
-
37
- ### Minor Changes
38
-
39
- - Updating: next 13.
40
-
41
- ## 0.3.0
42
-
43
- ### Minor Changes
44
-
45
- - Modified: HttpService.
46
-
47
- ## 0.2.1
48
-
49
- ### Patch Changes
50
-
51
- - Added: env ROOT_CATEGORY.
52
-
53
- ## 0.2.0
54
-
55
- ### Minor Changes
56
-
57
- - Modified routes, added redirects.
58
-
59
- ## 0.1.2
60
-
61
- ### Patch Changes
62
-
63
- - Modified: MockMenuService.
64
-
65
- ## 0.1.1
66
-
67
- ### Patch Changes
68
-
69
- - Modified: ILocalizable.
70
-
71
- ## 0.1.0
72
-
73
- ### Minor Changes
74
-
75
- - Added: splat routes.
76
- - Added: variants.
77
-
78
- ## 0.0.1
79
-
80
- ### Patch Changes
81
-
82
- - Added: first release.
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 = Record<string, unknown> & {
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",