@websolutespa/bom-core 0.1.0 → 0.1.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 +6 -0
- package/dist/index.d.ts +74 -68
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,64 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
2
2
|
import { ParsedUrlQuery } from 'querystring';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type Json = string | number | boolean | null | Json[] | {
|
|
5
|
+
[key: string]: Json;
|
|
6
|
+
};
|
|
7
|
+
type ValueOf<T> = T[keyof T];
|
|
8
|
+
type LiteralUnion<T extends string | number> = T | Omit<T, T>;
|
|
9
|
+
type PreviewData = string | false | object | undefined;
|
|
10
|
+
type IContextBaseParams = {
|
|
11
|
+
market: string;
|
|
12
|
+
locale: string;
|
|
13
|
+
};
|
|
14
|
+
type IContextParams = IContextBaseParams & {
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
type StaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
|
|
18
|
+
params: Q;
|
|
19
|
+
preview?: boolean;
|
|
20
|
+
previewData?: D;
|
|
21
|
+
locale?: string;
|
|
22
|
+
locales?: string[];
|
|
23
|
+
defaultLocale?: string;
|
|
24
|
+
};
|
|
25
|
+
type IStaticContext<T extends {} = {}> = StaticPropsContext<IContextParams & T>;
|
|
26
|
+
declare type NextApiRequestCookies = Partial<{
|
|
5
27
|
[key: string]: string;
|
|
28
|
+
}>;
|
|
29
|
+
type ServerSidePropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
|
|
30
|
+
req: IncomingMessage & {
|
|
31
|
+
cookies: NextApiRequestCookies;
|
|
32
|
+
};
|
|
33
|
+
res: ServerResponse;
|
|
34
|
+
params: Q;
|
|
35
|
+
query: ParsedUrlQuery;
|
|
36
|
+
preview?: boolean;
|
|
37
|
+
previewData?: D;
|
|
38
|
+
resolvedUrl: string;
|
|
39
|
+
locale?: string;
|
|
40
|
+
locales?: string[];
|
|
41
|
+
defaultLocale?: string;
|
|
42
|
+
};
|
|
43
|
+
type IServerSideSplatContext<T extends {} = {}> = ServerSidePropsContext<IContextBaseParams & T>;
|
|
44
|
+
type IServerSideContext<T extends {} = {}> = ServerSidePropsContext<IContextParams & T>;
|
|
45
|
+
type StateValue = StateValue[] | {
|
|
46
|
+
[key: string]: StateValue;
|
|
47
|
+
} | number | string | boolean | null | undefined;
|
|
48
|
+
type IPartial<T> = {
|
|
49
|
+
[P in keyof T]?: Partial<T[P]>;
|
|
50
|
+
};
|
|
51
|
+
type IPrettify<T> = {
|
|
52
|
+
[K in keyof T]: T[K];
|
|
53
|
+
} & {};
|
|
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];
|
|
6
56
|
};
|
|
7
57
|
|
|
58
|
+
type ILocalizedString = Record<string, string>;
|
|
59
|
+
type ILocalizable = string | ILocalizedString;
|
|
60
|
+
type ILocalized<T> = IOverride<T, ILocalizable, string>;
|
|
61
|
+
|
|
8
62
|
type IEquatable = number | string;
|
|
9
63
|
type SchemaType = string;
|
|
10
64
|
type IOption = Record<string, any> & {
|
|
@@ -17,10 +71,10 @@ type ISchema = {
|
|
|
17
71
|
};
|
|
18
72
|
type IEntity = Record<string, unknown> & ISchema;
|
|
19
73
|
type INamedEntity = IEntity & {
|
|
20
|
-
name:
|
|
74
|
+
name: ILocalizable;
|
|
21
75
|
};
|
|
22
76
|
type ITitledEntity = IEntity & {
|
|
23
|
-
title:
|
|
77
|
+
title: ILocalizable;
|
|
24
78
|
};
|
|
25
79
|
|
|
26
80
|
type IMediaType = 'image' | 'video' | string;
|
|
@@ -41,8 +95,8 @@ type ICategory = IEntity & {
|
|
|
41
95
|
id: IEquatable;
|
|
42
96
|
media?: IMedia;
|
|
43
97
|
order?: number;
|
|
44
|
-
slug?:
|
|
45
|
-
title?:
|
|
98
|
+
slug?: ILocalizable;
|
|
99
|
+
title?: ILocalizable;
|
|
46
100
|
};
|
|
47
101
|
type ICategoryItem = ICategory & {
|
|
48
102
|
items: ICategory[];
|
|
@@ -55,9 +109,9 @@ type ICategorized = {
|
|
|
55
109
|
media?: IMedia;
|
|
56
110
|
order?: number;
|
|
57
111
|
schema?: string;
|
|
58
|
-
slug?:
|
|
112
|
+
slug?: ILocalizable;
|
|
59
113
|
template?: string;
|
|
60
|
-
title?:
|
|
114
|
+
title?: ILocalizable;
|
|
61
115
|
useSplat?: boolean;
|
|
62
116
|
};
|
|
63
117
|
|
|
@@ -85,7 +139,7 @@ type FetchService<T = any> = (url: string, options?: FetchRequestOptions, servic
|
|
|
85
139
|
|
|
86
140
|
type ILabel = IEntity & {
|
|
87
141
|
id: IEquatable;
|
|
88
|
-
text?:
|
|
142
|
+
text?: ILocalizable;
|
|
89
143
|
};
|
|
90
144
|
|
|
91
145
|
type ILocale = IEntity & {
|
|
@@ -174,30 +228,30 @@ type IMenuBase = {
|
|
|
174
228
|
};
|
|
175
229
|
type IMenuCategory = IMenuBase & {
|
|
176
230
|
type: 'category';
|
|
177
|
-
title:
|
|
231
|
+
title: ILocalizable;
|
|
178
232
|
href: string;
|
|
179
233
|
category: IEquatable;
|
|
180
234
|
};
|
|
181
235
|
type IMenuGroup = IMenuBase & {
|
|
182
236
|
type: 'group';
|
|
183
|
-
title:
|
|
237
|
+
title: ILocalizable;
|
|
184
238
|
};
|
|
185
239
|
type IMenuLink = IMenuBase & {
|
|
186
240
|
type: 'link';
|
|
187
|
-
title:
|
|
241
|
+
title: ILocalizable;
|
|
188
242
|
href: string;
|
|
189
243
|
target: string;
|
|
190
244
|
};
|
|
191
245
|
type IMenuRoute = IMenuBase & {
|
|
192
246
|
type: 'route';
|
|
193
|
-
title:
|
|
247
|
+
title: ILocalizable;
|
|
194
248
|
href: string;
|
|
195
249
|
page: IEquatable;
|
|
196
250
|
schema: string;
|
|
197
251
|
};
|
|
198
252
|
type IMenuPage = IMenuBase & {
|
|
199
253
|
type: 'page';
|
|
200
|
-
title:
|
|
254
|
+
title: ILocalizable;
|
|
201
255
|
href: string;
|
|
202
256
|
page: IEquatable;
|
|
203
257
|
schema: string;
|
|
@@ -215,7 +269,7 @@ type IMenu = {
|
|
|
215
269
|
* this is the original menu model from cms
|
|
216
270
|
*/
|
|
217
271
|
type IUndecoratedMenuBase = {
|
|
218
|
-
abstract?:
|
|
272
|
+
abstract?: ILocalizable;
|
|
219
273
|
id?: string;
|
|
220
274
|
items: IUndecoratedMenuItem[];
|
|
221
275
|
markets?: string[];
|
|
@@ -226,22 +280,22 @@ type IUndecoratedMenuCategory = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
|
226
280
|
type: 'category';
|
|
227
281
|
category: string;
|
|
228
282
|
maxDepth?: number;
|
|
229
|
-
title?:
|
|
283
|
+
title?: ILocalizable;
|
|
230
284
|
};
|
|
231
285
|
type IUndecoratedMenuGroup = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
232
286
|
type: 'group';
|
|
233
|
-
title:
|
|
287
|
+
title: ILocalizable;
|
|
234
288
|
};
|
|
235
289
|
type IUndecoratedMenuLink = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
236
290
|
type: 'link';
|
|
237
|
-
title:
|
|
291
|
+
title: ILocalizable;
|
|
238
292
|
href: string;
|
|
239
293
|
target?: string;
|
|
240
294
|
};
|
|
241
295
|
type IUndecoratedMenuPage = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
242
296
|
type: 'page';
|
|
243
297
|
page: IPageRelation;
|
|
244
|
-
title?:
|
|
298
|
+
title?: ILocalizable;
|
|
245
299
|
};
|
|
246
300
|
type IUndecoratedMenuCustom = Record<string, unknown> & {
|
|
247
301
|
id: IEquatable;
|
|
@@ -359,58 +413,10 @@ type ISerializedStore = Record<string, ISerializedCollection>;
|
|
|
359
413
|
|
|
360
414
|
type ITemplate = {
|
|
361
415
|
id: IEquatable;
|
|
362
|
-
name:
|
|
416
|
+
name: ILocalizable;
|
|
363
417
|
collections: string[];
|
|
364
418
|
};
|
|
365
419
|
|
|
366
|
-
type Json = string | number | boolean | null | Json[] | {
|
|
367
|
-
[key: string]: Json;
|
|
368
|
-
};
|
|
369
|
-
type ValueOf<T> = T[keyof T];
|
|
370
|
-
type LiteralUnion<T extends string | number> = T | Omit<T, T>;
|
|
371
|
-
type PreviewData = string | false | object | undefined;
|
|
372
|
-
type IContextBaseParams = {
|
|
373
|
-
market: string;
|
|
374
|
-
locale: string;
|
|
375
|
-
};
|
|
376
|
-
type IContextParams = IContextBaseParams & {
|
|
377
|
-
id: string;
|
|
378
|
-
};
|
|
379
|
-
type StaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
|
|
380
|
-
params: Q;
|
|
381
|
-
preview?: boolean;
|
|
382
|
-
previewData?: D;
|
|
383
|
-
locale?: string;
|
|
384
|
-
locales?: string[];
|
|
385
|
-
defaultLocale?: string;
|
|
386
|
-
};
|
|
387
|
-
type IStaticContext<T extends {} = {}> = StaticPropsContext<IContextParams & T>;
|
|
388
|
-
declare type NextApiRequestCookies = Partial<{
|
|
389
|
-
[key: string]: string;
|
|
390
|
-
}>;
|
|
391
|
-
type ServerSidePropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
|
|
392
|
-
req: IncomingMessage & {
|
|
393
|
-
cookies: NextApiRequestCookies;
|
|
394
|
-
};
|
|
395
|
-
res: ServerResponse;
|
|
396
|
-
params: Q;
|
|
397
|
-
query: ParsedUrlQuery;
|
|
398
|
-
preview?: boolean;
|
|
399
|
-
previewData?: D;
|
|
400
|
-
resolvedUrl: string;
|
|
401
|
-
locale?: string;
|
|
402
|
-
locales?: string[];
|
|
403
|
-
defaultLocale?: string;
|
|
404
|
-
};
|
|
405
|
-
type IServerSideSplatContext<T extends {} = {}> = ServerSidePropsContext<IContextBaseParams & T>;
|
|
406
|
-
type IServerSideContext<T extends {} = {}> = ServerSidePropsContext<IContextParams & T>;
|
|
407
|
-
type StateValue = StateValue[] | {
|
|
408
|
-
[key: string]: StateValue;
|
|
409
|
-
} | number | string | boolean | null | undefined;
|
|
410
|
-
type IPartial<T> = {
|
|
411
|
-
[P in keyof T]?: Partial<T[P]>;
|
|
412
|
-
};
|
|
413
|
-
|
|
414
420
|
declare function getClassNames(...props: Array<IClassName>): string;
|
|
415
421
|
|
|
416
422
|
declare function getCollectionDescription(text: string): ICollectionDescription;
|
|
@@ -480,4 +486,4 @@ declare function awaitAll(array: any, callback: (item: any, index: number) => Pr
|
|
|
480
486
|
declare function merge(target: any, source: any): any;
|
|
481
487
|
declare function deepCopy<T>(source: T): T;
|
|
482
488
|
|
|
483
|
-
export { FetchRequestOptions, FetchService, FindParams, FindWhereParams, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IEntity, IEquatable, ILabel, ILayout, ILocale, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IPackages, IPage, IPageRelation, IPageResult, IPartial, IQuerable, IRoute, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, Json, JsonService, LiteralUnion, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asEquatable, asServerProps, awaitAll, camelToSnakeCase, consoleWarn, deepCopy, deserializeKey, deserializeValue, getClassNames, getCollectionDescription, getIsDevelopment, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isBrowser, isDevelopment, isLocalizedString, isValidCollectionDescription, localizeItem, localizeValue, localizedToString, merge, qsDeserialize, qsSerialize, titleToSlug, toDisplayName, toFindParams, toPluralName, toTitleCase, toValidCollectionName, withSchema };
|
|
489
|
+
export { FetchRequestOptions, FetchService, FindParams, FindWhereParams, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, 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, IPageResult, IPartial, IPrettify, IQuerable, IRoute, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, Json, JsonService, LiteralUnion, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asEquatable, asServerProps, awaitAll, camelToSnakeCase, consoleWarn, deepCopy, deserializeKey, deserializeValue, getClassNames, getCollectionDescription, getIsDevelopment, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isBrowser, isDevelopment, isLocalizedString, isValidCollectionDescription, localizeItem, localizeValue, localizedToString, merge, qsDeserialize, qsSerialize, titleToSlug, toDisplayName, toFindParams, toPluralName, toTitleCase, toValidCollectionName, withSchema };
|