@websolutespa/bom-core 1.6.0 → 1.7.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @websolutespa/bom-core
2
2
 
3
+ ## 1.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 28e86bd: Modified: IPage, Store services & decorators
8
+
3
9
  ## 1.6.0
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'http';
2
2
  import { ParsedUrlQuery } from 'querystring';
3
+ import React from 'react';
3
4
 
4
5
  type Json = string | number | boolean | null | Json[] | {
5
6
  [key: string]: Json;
@@ -51,11 +52,19 @@ type IPartial<T> = {
51
52
  type IPrettify<T> = {
52
53
  [K in keyof T]: T[K];
53
54
  } & {};
54
- type IOverride<T, TypeToReplace, TypeToReplaceWith> = {
55
- [K in keyof T]: T[K] extends Record<string, unknown> ? IOverride<T[K], TypeToReplace, TypeToReplaceWith> : T[K] extends TypeToReplace ? TypeToReplaceWith : T[K];
55
+ type IOverrideReturnValue<T, FromType, ToType> = T extends Record<string, unknown> ? IOverride<T, FromType, ToType> : T;
56
+ type IOverrideValue<T, FromType, ToType> = T extends FromType ? ToType : IOverrideReturnValue<T, FromType, ToType>;
57
+ type IOverride<T, FromType, ToType> = {
58
+ [Property in keyof T]: IOverrideValue<T[Property], FromType, ToType>;
56
59
  };
57
60
 
58
- type ILocalizedString = Record<string, string>;
61
+ /**
62
+ * List of ISO 639 language codes (set 1)
63
+ * https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
64
+ */
65
+ type ILetter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
66
+ type ILocaleId = `${ILetter}${ILetter}`;
67
+ type ILocalizedString = Record<ILocaleId, string>;
59
68
  type ILocalizable = string | ILocalizedString;
60
69
  type ILocalized<T> = IOverride<T, ILocalizable, string>;
61
70
 
@@ -102,6 +111,11 @@ type IAnchor = {
102
111
  title?: ILocalizable;
103
112
  };
104
113
 
114
+ type IComponent = {
115
+ schema: string;
116
+ [key: string]: unknown;
117
+ };
118
+
105
119
  type IEquatable = number | string;
106
120
  type SchemaType = string;
107
121
  type ISchema = {
@@ -146,6 +160,13 @@ type IMedia = {
146
160
  };
147
161
  declare function resolveMediaType(media: IMedia): IMediaType;
148
162
 
163
+ type IMeta = {
164
+ title?: string;
165
+ description?: string;
166
+ keywords?: string;
167
+ robots?: string;
168
+ };
169
+
149
170
  type ICategory = IEntity & {
150
171
  category?: IEquatable | ICategory;
151
172
  id: IEquatable;
@@ -157,19 +178,20 @@ type ICategory = IEntity & {
157
178
  type ICategoryItem = ICategory & {
158
179
  items: ICategory[];
159
180
  };
160
- type ICategorized = {
161
- abstract?: ILocalizable;
162
- category: IEquatable | ICategory;
163
- id: IEquatable;
164
- isDefault?: boolean;
165
- markets?: string[];
181
+ type ICategorized = IEntity & {
182
+ title: ILocalizable;
183
+ abstract?: string;
184
+ description?: string;
166
185
  media?: IMedia;
167
- order?: number;
168
- schema?: string;
186
+ meta?: IMeta;
187
+ components?: IComponent[];
188
+ category: IEquatable | ICategory;
169
189
  slug: ILocalizable;
170
190
  template?: string;
171
- title: ILocalizable;
191
+ isDefault?: boolean;
172
192
  useSplat?: boolean;
193
+ order?: number;
194
+ markets?: string[];
173
195
  createdAt?: Date;
174
196
  updatedAt?: Date;
175
197
  };
@@ -221,13 +243,6 @@ type IMarket = IEntity & {
221
243
  isHidden?: boolean;
222
244
  };
223
245
 
224
- type IMeta = {
225
- title?: string;
226
- description?: string;
227
- keywords?: string;
228
- robots?: string;
229
- };
230
-
231
246
  type IRoute = {
232
247
  category: IEquatable | ICategory;
233
248
  id: string;
@@ -261,20 +276,25 @@ type IRouteParams = Record<string, any> & {
261
276
  market: string;
262
277
  };
263
278
 
264
- type IPage = Record<string, any> & ICategorized & {
265
- abstract?: string;
279
+ type IPage<T extends ICategorized = ICategorized> = ILocalized<T> & {
266
280
  alternates: IRoute[];
267
281
  breadcrumb: IRouteLink[];
268
- content?: string;
269
- description?: string;
282
+ category: ILocalized<ICategory>;
270
283
  href: string;
271
284
  locale: string;
272
285
  market: string;
273
- meta?: IMeta;
274
286
  parentRoute?: IRouteLink;
275
287
  slug: string;
276
288
  title: string;
277
289
  };
290
+ type PageProps<T extends ICategorized = ICategorized> = {
291
+ layout: ILayout;
292
+ page: IPage<T>;
293
+ params: IRouteParams;
294
+ locales?: string[];
295
+ locale?: string;
296
+ defaultLocale?: string;
297
+ };
278
298
  type IPageRelationResult<T extends ICategorized = ICategorized> = {
279
299
  href: string;
280
300
  } & T;
@@ -286,15 +306,6 @@ type IPageUnresolvedRelation = {
286
306
  relationTo: string;
287
307
  value: IEquatable | IEquatable[];
288
308
  };
289
- type IPageResult<T extends ICategorized = ICategorized> = IPage & T;
290
- type PageProps<T extends ICategorized = ICategorized> = {
291
- layout: ILayout;
292
- page: IPageResult<T>;
293
- params: IRouteParams;
294
- locales?: string[];
295
- locale?: string;
296
- defaultLocale?: string;
297
- };
298
309
 
299
310
  type IMenuBase = {
300
311
  abstract?: ILocalizable;
@@ -391,7 +402,7 @@ type ILayout = {
391
402
  locales: ILocale[];
392
403
  market: string;
393
404
  markets: IMarket[];
394
- menu: Record<string, IMenu>;
405
+ menu: Record<string, ILocalized<IMenu>>;
395
406
  topLevelHrefs: Record<string, string>;
396
407
  topLevelRoutes: Record<string, IRouteLink>;
397
408
  tree?: IRouteLink;
@@ -489,7 +500,7 @@ type IRedirect = {
489
500
  };
490
501
 
491
502
  type IMemoryStore<T extends IEntity = IEntity> = Record<string, T[]>;
492
- type IStore = Record<string, IQuerable<IEntity>>;
503
+ type IStore = Record<string, IQuerable>;
493
504
  type IConfig = {
494
505
  collections: string[];
495
506
  mocks: string[];
@@ -677,9 +688,9 @@ declare const isProduction: boolean;
677
688
  declare const isStage: boolean;
678
689
  declare const isBrowser: boolean;
679
690
  declare function getEnv(): Record<string, Json>;
680
- declare function withSchema<Component extends {}, Schema>(component: Component, schema: Schema): Component & Schema;
691
+ declare function withSchema<Component extends React.FC<any>, Schema>(component: Component, schema: Schema): Component & Schema;
681
692
  declare function asServerProps(props: any): any;
682
693
  declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
683
694
  declare function merge(target: any, source: any): any;
684
695
 
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 };
696
+ export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, 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, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",