@websolutespa/bom-core 2.0.1-next.2 → 2.0.1
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 +9 -9
- package/dist/index.d.ts +88 -63
- package/dist/index.js +236 -50
- package/dist/index.mjs +1807 -0
- package/package.json +22 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
# @websolutespa/bom-core
|
|
2
2
|
|
|
3
|
-
## 2.0.1
|
|
3
|
+
## 2.0.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Modified: getOrigin prioritize NEXT_PUBLIC_URL
|
|
8
8
|
|
|
9
|
-
## 2.0.
|
|
9
|
+
## 2.0.0
|
|
10
10
|
|
|
11
11
|
### Major Changes
|
|
12
12
|
|
|
13
|
-
-
|
|
13
|
+
- Release: Bom 2.0
|
|
14
14
|
|
|
15
|
-
## 1.
|
|
15
|
+
## 1.8.24
|
|
16
16
|
|
|
17
17
|
### Patch Changes
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
- Added: IApp global
|
|
20
20
|
|
|
21
|
-
## 1.
|
|
21
|
+
## 1.8.23
|
|
22
22
|
|
|
23
|
-
###
|
|
23
|
+
### Patch Changes
|
|
24
24
|
|
|
25
|
-
-
|
|
25
|
+
- 0c7f05f: Modified: IRoute isRoot noindex, routeService
|
|
26
26
|
|
|
27
27
|
## 1.8.22
|
|
28
28
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from '
|
|
2
|
-
import { ParsedUrlQuery } from '
|
|
3
|
-
import
|
|
1
|
+
import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
2
|
+
import { ParsedUrlQuery } from 'querystring';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
|
|
5
5
|
declare function base64ToString(text: string): string;
|
|
6
6
|
declare function stringToBase64(text: string): string;
|
|
@@ -20,13 +20,11 @@ type IContextParams = IContextBaseParams & {
|
|
|
20
20
|
};
|
|
21
21
|
type StaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
|
|
22
22
|
params: Q;
|
|
23
|
-
|
|
23
|
+
preview?: boolean;
|
|
24
|
+
previewData?: D;
|
|
24
25
|
locale?: string;
|
|
25
26
|
locales?: string[];
|
|
26
27
|
defaultLocale?: string;
|
|
27
|
-
revalidateReason?: 'build' | 'stale' | 'on-demand';
|
|
28
|
-
preview?: boolean;
|
|
29
|
-
previewData?: D;
|
|
30
28
|
};
|
|
31
29
|
type IStaticContext<T extends {} = {}> = StaticPropsContext<IContextParams & T>;
|
|
32
30
|
declare type NextApiRequestCookies = Partial<{
|
|
@@ -38,15 +36,13 @@ type ServerSidePropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends
|
|
|
38
36
|
};
|
|
39
37
|
res: ServerResponse;
|
|
40
38
|
params: Q;
|
|
41
|
-
draftMode?: boolean;
|
|
42
39
|
query: ParsedUrlQuery;
|
|
40
|
+
preview?: boolean;
|
|
41
|
+
previewData?: D;
|
|
43
42
|
resolvedUrl: string;
|
|
44
43
|
locale?: string;
|
|
45
44
|
locales?: string[];
|
|
46
45
|
defaultLocale?: string;
|
|
47
|
-
revalidateReason?: 'build' | 'stale' | 'on-demand';
|
|
48
|
-
preview?: boolean;
|
|
49
|
-
previewData?: D;
|
|
50
46
|
};
|
|
51
47
|
type IServerSideSplatContext<T extends {} = {}> = ServerSidePropsContext<IContextBaseParams & T>;
|
|
52
48
|
type IServerSideContext<T extends {} = {}> = ServerSidePropsContext<IContextParams & T>;
|
|
@@ -67,14 +63,6 @@ type IOverride<T, FromType, ToType> = {
|
|
|
67
63
|
type RequireAtLeastOne<T> = {
|
|
68
64
|
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
69
65
|
}[keyof T];
|
|
70
|
-
type Shift<T extends any[]> = ((...t: T) => any) extends ((first: any, ...rest: infer Rest) => any) ? Rest : never;
|
|
71
|
-
type ShiftUnion<P extends PropertyKey, T extends any[]> = T extends any[] ? T[0] extends P ? Shift<T> : never : never;
|
|
72
|
-
type DeepRequiredProps<T, P extends string[]> = T extends object ? (Omit<T, Extract<keyof T, P[0]>> & Required<{
|
|
73
|
-
[K in Extract<keyof T, P[0]>]: NonNullable<DeepRequiredProps<T[K], ShiftUnion<K, P>>>;
|
|
74
|
-
}>) : T;
|
|
75
|
-
type DeepRequired<T> = {
|
|
76
|
-
[K in keyof T]: Required<DeepRequired<T[K]>>;
|
|
77
|
-
};
|
|
78
66
|
|
|
79
67
|
/**
|
|
80
68
|
* List of ISO 639 language codes (set 1)
|
|
@@ -144,45 +132,6 @@ type IAnchor = {
|
|
|
144
132
|
title: string;
|
|
145
133
|
};
|
|
146
134
|
|
|
147
|
-
type IEquatable = number | string;
|
|
148
|
-
type SchemaType = string;
|
|
149
|
-
type ISchema = {
|
|
150
|
-
id: IEquatable;
|
|
151
|
-
schema?: string;
|
|
152
|
-
};
|
|
153
|
-
type IEntity = ISchema & Record<string, unknown>;
|
|
154
|
-
type INamedEntity = IEntity & {
|
|
155
|
-
name: ILocalizable;
|
|
156
|
-
};
|
|
157
|
-
type ITitledEntity = IEntity & {
|
|
158
|
-
title: ILocalizable;
|
|
159
|
-
};
|
|
160
|
-
type IOption = Record<string, any> & {
|
|
161
|
-
id: IEquatable;
|
|
162
|
-
name: string;
|
|
163
|
-
};
|
|
164
|
-
type IFeature = Record<string, any> & {
|
|
165
|
-
id: IEquatable;
|
|
166
|
-
title: string;
|
|
167
|
-
};
|
|
168
|
-
type IFeatureType = IEntity & {
|
|
169
|
-
id: string;
|
|
170
|
-
title: string;
|
|
171
|
-
mode: string;
|
|
172
|
-
features: IFeature[];
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
176
|
-
|
|
177
|
-
type IComponent = {
|
|
178
|
-
id?: IEquatable;
|
|
179
|
-
blockType?: string;
|
|
180
|
-
schema?: string;
|
|
181
|
-
anchor?: IAnchor;
|
|
182
|
-
seoWeight?: Headings;
|
|
183
|
-
[key: string]: unknown;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
135
|
type IMediaType = 'image' | 'video' | 'json' | 'pdf' | string;
|
|
187
136
|
type IMediaInfo = {
|
|
188
137
|
id: string;
|
|
@@ -239,6 +188,68 @@ declare function isMediaPdf(media: {
|
|
|
239
188
|
}): media is IMediaPdf;
|
|
240
189
|
declare function isMedia(item: unknown): item is IMedia;
|
|
241
190
|
|
|
191
|
+
type IAppExtended = Record<string, any>;
|
|
192
|
+
type IApp<T extends IAppExtended = IAppExtended> = {
|
|
193
|
+
id: 'app';
|
|
194
|
+
brand: {
|
|
195
|
+
name: string;
|
|
196
|
+
businessName?: string;
|
|
197
|
+
appName?: string;
|
|
198
|
+
logo?: IMedia;
|
|
199
|
+
email?: string;
|
|
200
|
+
telephone?: string;
|
|
201
|
+
address?: string;
|
|
202
|
+
city?: string;
|
|
203
|
+
provinceCode?: string;
|
|
204
|
+
zipCode?: string;
|
|
205
|
+
countryCode?: string;
|
|
206
|
+
twitterName?: string;
|
|
207
|
+
social: {
|
|
208
|
+
key: string;
|
|
209
|
+
url: string;
|
|
210
|
+
}[];
|
|
211
|
+
};
|
|
212
|
+
} & T;
|
|
213
|
+
|
|
214
|
+
type IEquatable = number | string;
|
|
215
|
+
type SchemaType = string;
|
|
216
|
+
type ISchema = {
|
|
217
|
+
id: IEquatable;
|
|
218
|
+
schema?: string;
|
|
219
|
+
};
|
|
220
|
+
type IEntity = ISchema & Record<string, unknown>;
|
|
221
|
+
type INamedEntity = IEntity & {
|
|
222
|
+
name: ILocalizable;
|
|
223
|
+
};
|
|
224
|
+
type ITitledEntity = IEntity & {
|
|
225
|
+
title: ILocalizable;
|
|
226
|
+
};
|
|
227
|
+
type IOption = Record<string, any> & {
|
|
228
|
+
id: IEquatable;
|
|
229
|
+
name: string;
|
|
230
|
+
};
|
|
231
|
+
type IFeature = Record<string, any> & {
|
|
232
|
+
id: IEquatable;
|
|
233
|
+
title: string;
|
|
234
|
+
};
|
|
235
|
+
type IFeatureType = IEntity & {
|
|
236
|
+
id: string;
|
|
237
|
+
title: string;
|
|
238
|
+
mode: string;
|
|
239
|
+
features: IFeature[];
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
243
|
+
|
|
244
|
+
type IComponent = {
|
|
245
|
+
id?: IEquatable;
|
|
246
|
+
blockType?: string;
|
|
247
|
+
schema?: string;
|
|
248
|
+
anchor?: IAnchor;
|
|
249
|
+
seoWeight?: Headings;
|
|
250
|
+
[key: string]: unknown;
|
|
251
|
+
};
|
|
252
|
+
|
|
242
253
|
type IMeta = {
|
|
243
254
|
title?: string;
|
|
244
255
|
description?: string;
|
|
@@ -359,14 +370,16 @@ type IMarket = IEntity & {
|
|
|
359
370
|
|
|
360
371
|
type IRoute = {
|
|
361
372
|
category: IEquatable;
|
|
362
|
-
resolvedCategory: IEquatable;
|
|
363
373
|
id: string;
|
|
364
374
|
isDefault?: boolean;
|
|
375
|
+
isRoot?: boolean;
|
|
365
376
|
locale: string;
|
|
366
377
|
market: string;
|
|
367
378
|
media?: IMedia;
|
|
379
|
+
noindex?: boolean;
|
|
368
380
|
order?: number;
|
|
369
381
|
page: IEquatable;
|
|
382
|
+
resolvedCategory: IEquatable;
|
|
370
383
|
schema: string;
|
|
371
384
|
template?: string;
|
|
372
385
|
title: string;
|
|
@@ -562,12 +575,13 @@ type IUndecoratedMenu = IEntity & {
|
|
|
562
575
|
items: IUndecoratedMenuItem[];
|
|
563
576
|
};
|
|
564
577
|
|
|
565
|
-
type ILayout = {
|
|
578
|
+
type ILayout<T extends IAppExtended = IAppExtended> = {
|
|
566
579
|
labels: ILabel[];
|
|
567
580
|
locale: string;
|
|
568
581
|
locales: ILocale[];
|
|
569
582
|
market: string;
|
|
570
583
|
markets: IMarket[];
|
|
584
|
+
app: IPrettify<IApp<T>>;
|
|
571
585
|
menu: Record<string, ILocalizedMenu>;
|
|
572
586
|
topLevelHrefs: Record<string, string>;
|
|
573
587
|
topLevelRoutes: Record<string, IRouteLink>;
|
|
@@ -631,11 +645,19 @@ type QueryParams = {
|
|
|
631
645
|
sort?: string;
|
|
632
646
|
where?: Where;
|
|
633
647
|
};
|
|
648
|
+
type GlobalQueryParams = {
|
|
649
|
+
depth?: number;
|
|
650
|
+
draft?: boolean;
|
|
651
|
+
locale?: string;
|
|
652
|
+
market?: string;
|
|
653
|
+
richText?: boolean;
|
|
654
|
+
};
|
|
634
655
|
|
|
635
656
|
type IPagedResult<T extends IEntity = IEntity> = {
|
|
636
657
|
docs: T[];
|
|
637
658
|
} & Pagination;
|
|
638
659
|
type IQuerable<T extends IEntity = IEntity> = {
|
|
660
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams, token?: string): Promise<B | undefined>;
|
|
639
661
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams, token?: string): Promise<B | undefined>;
|
|
640
662
|
findMany<B extends T = T>(params?: QueryParams, token?: string): Promise<B[]>;
|
|
641
663
|
findPaged<B extends T = T>(params?: QueryParams, token?: string): Promise<IPagedResult<B>>;
|
|
@@ -891,7 +913,7 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
|
891
913
|
items: T[];
|
|
892
914
|
constructor(items: T[]);
|
|
893
915
|
getItems<B extends T = T>(): Promise<B[]>;
|
|
894
|
-
|
|
916
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams): Promise<B | undefined>;
|
|
895
917
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
896
918
|
findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
|
|
897
919
|
findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
|
|
@@ -1065,6 +1087,9 @@ declare function getOrigin(headers?: IncomingHttpHeaders | Headers): string;
|
|
|
1065
1087
|
|
|
1066
1088
|
/**
|
|
1067
1089
|
* Represents the route strategy options.
|
|
1090
|
+
* - **Auto** dynamically add/remove prefixes based on number of markets & languages.
|
|
1091
|
+
* - **Default** add prefixes based on !isDefault market or language flag.
|
|
1092
|
+
* - **Manual** add prefixes based on !isHidden market or language flag.
|
|
1068
1093
|
*/
|
|
1069
1094
|
declare enum RouteStrategy {
|
|
1070
1095
|
Auto = "auto",
|
|
@@ -1361,9 +1386,9 @@ declare const isProduction: boolean;
|
|
|
1361
1386
|
declare const isStage: boolean;
|
|
1362
1387
|
declare const isBrowser: boolean;
|
|
1363
1388
|
declare function getEnv(): Record<string, Json>;
|
|
1364
|
-
declare function withSchema<Component extends FC<any>, Schema>(component: Component, schema: Schema): Component & Schema;
|
|
1389
|
+
declare function withSchema<Component extends React.FC<any>, Schema>(component: Component, schema: Schema): Component & Schema;
|
|
1365
1390
|
declare function asServerProps(props: any): any;
|
|
1366
1391
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1367
1392
|
declare function merge(target: any, source: any): any;
|
|
1368
1393
|
|
|
1369
|
-
export {
|
|
1394
|
+
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, GlobalQueryParams, Headings, IAction, IActionEmailData, IAnchor, IApp, IAppExtended, 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 };
|