@websolutespa/bom-core 0.0.1 → 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 +13 -0
- package/dist/index.d.ts +80 -65
- 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,10 @@ 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;
|
|
115
|
+
useSplat?: boolean;
|
|
61
116
|
};
|
|
62
117
|
|
|
63
118
|
type IClassNameValue = string | boolean | number | null | undefined;
|
|
@@ -84,7 +139,7 @@ type FetchService<T = any> = (url: string, options?: FetchRequestOptions, servic
|
|
|
84
139
|
|
|
85
140
|
type ILabel = IEntity & {
|
|
86
141
|
id: IEquatable;
|
|
87
|
-
text?:
|
|
142
|
+
text?: ILocalizable;
|
|
88
143
|
};
|
|
89
144
|
|
|
90
145
|
type ILocale = IEntity & {
|
|
@@ -112,16 +167,17 @@ type IMeta = {
|
|
|
112
167
|
};
|
|
113
168
|
|
|
114
169
|
type IRoute = {
|
|
170
|
+
category: IEquatable | ICategory;
|
|
115
171
|
id: string;
|
|
116
|
-
|
|
172
|
+
isDefault?: boolean;
|
|
117
173
|
locale: string;
|
|
118
|
-
|
|
174
|
+
market: string;
|
|
175
|
+
order?: number;
|
|
119
176
|
page: IEquatable;
|
|
120
177
|
schema: string;
|
|
121
178
|
template?: string;
|
|
122
179
|
title: string;
|
|
123
|
-
|
|
124
|
-
order?: number;
|
|
180
|
+
useSplat?: boolean;
|
|
125
181
|
};
|
|
126
182
|
type IRouteLink = {
|
|
127
183
|
href: string;
|
|
@@ -172,30 +228,30 @@ type IMenuBase = {
|
|
|
172
228
|
};
|
|
173
229
|
type IMenuCategory = IMenuBase & {
|
|
174
230
|
type: 'category';
|
|
175
|
-
title:
|
|
231
|
+
title: ILocalizable;
|
|
176
232
|
href: string;
|
|
177
233
|
category: IEquatable;
|
|
178
234
|
};
|
|
179
235
|
type IMenuGroup = IMenuBase & {
|
|
180
236
|
type: 'group';
|
|
181
|
-
title:
|
|
237
|
+
title: ILocalizable;
|
|
182
238
|
};
|
|
183
239
|
type IMenuLink = IMenuBase & {
|
|
184
240
|
type: 'link';
|
|
185
|
-
title:
|
|
241
|
+
title: ILocalizable;
|
|
186
242
|
href: string;
|
|
187
243
|
target: string;
|
|
188
244
|
};
|
|
189
245
|
type IMenuRoute = IMenuBase & {
|
|
190
246
|
type: 'route';
|
|
191
|
-
title:
|
|
247
|
+
title: ILocalizable;
|
|
192
248
|
href: string;
|
|
193
249
|
page: IEquatable;
|
|
194
250
|
schema: string;
|
|
195
251
|
};
|
|
196
252
|
type IMenuPage = IMenuBase & {
|
|
197
253
|
type: 'page';
|
|
198
|
-
title:
|
|
254
|
+
title: ILocalizable;
|
|
199
255
|
href: string;
|
|
200
256
|
page: IEquatable;
|
|
201
257
|
schema: string;
|
|
@@ -213,7 +269,7 @@ type IMenu = {
|
|
|
213
269
|
* this is the original menu model from cms
|
|
214
270
|
*/
|
|
215
271
|
type IUndecoratedMenuBase = {
|
|
216
|
-
abstract?:
|
|
272
|
+
abstract?: ILocalizable;
|
|
217
273
|
id?: string;
|
|
218
274
|
items: IUndecoratedMenuItem[];
|
|
219
275
|
markets?: string[];
|
|
@@ -224,22 +280,22 @@ type IUndecoratedMenuCategory = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
|
224
280
|
type: 'category';
|
|
225
281
|
category: string;
|
|
226
282
|
maxDepth?: number;
|
|
227
|
-
title?:
|
|
283
|
+
title?: ILocalizable;
|
|
228
284
|
};
|
|
229
285
|
type IUndecoratedMenuGroup = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
230
286
|
type: 'group';
|
|
231
|
-
title:
|
|
287
|
+
title: ILocalizable;
|
|
232
288
|
};
|
|
233
289
|
type IUndecoratedMenuLink = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
234
290
|
type: 'link';
|
|
235
|
-
title:
|
|
291
|
+
title: ILocalizable;
|
|
236
292
|
href: string;
|
|
237
293
|
target?: string;
|
|
238
294
|
};
|
|
239
295
|
type IUndecoratedMenuPage = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
240
296
|
type: 'page';
|
|
241
297
|
page: IPageRelation;
|
|
242
|
-
title?:
|
|
298
|
+
title?: ILocalizable;
|
|
243
299
|
};
|
|
244
300
|
type IUndecoratedMenuCustom = Record<string, unknown> & {
|
|
245
301
|
id: IEquatable;
|
|
@@ -357,51 +413,10 @@ type ISerializedStore = Record<string, ISerializedCollection>;
|
|
|
357
413
|
|
|
358
414
|
type ITemplate = {
|
|
359
415
|
id: IEquatable;
|
|
360
|
-
name:
|
|
416
|
+
name: ILocalizable;
|
|
361
417
|
collections: string[];
|
|
362
418
|
};
|
|
363
419
|
|
|
364
|
-
type Json = string | number | boolean | null | Json[] | {
|
|
365
|
-
[key: string]: Json;
|
|
366
|
-
};
|
|
367
|
-
type ValueOf<T> = T[keyof T];
|
|
368
|
-
type PreviewData = string | false | object | undefined;
|
|
369
|
-
type IContextParams = {
|
|
370
|
-
id: string;
|
|
371
|
-
market: string;
|
|
372
|
-
locale: string;
|
|
373
|
-
};
|
|
374
|
-
type StaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
|
|
375
|
-
params: Q;
|
|
376
|
-
preview?: boolean;
|
|
377
|
-
previewData?: D;
|
|
378
|
-
locale?: string;
|
|
379
|
-
locales?: string[];
|
|
380
|
-
defaultLocale?: string;
|
|
381
|
-
};
|
|
382
|
-
type IStaticContext = StaticPropsContext<IContextParams>;
|
|
383
|
-
declare type NextApiRequestCookies = Partial<{
|
|
384
|
-
[key: string]: string;
|
|
385
|
-
}>;
|
|
386
|
-
type ServerSidePropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
|
|
387
|
-
req: IncomingMessage & {
|
|
388
|
-
cookies: NextApiRequestCookies;
|
|
389
|
-
};
|
|
390
|
-
res: ServerResponse;
|
|
391
|
-
params: Q;
|
|
392
|
-
query: ParsedUrlQuery;
|
|
393
|
-
preview?: boolean;
|
|
394
|
-
previewData?: D;
|
|
395
|
-
resolvedUrl: string;
|
|
396
|
-
locale?: string;
|
|
397
|
-
locales?: string[];
|
|
398
|
-
defaultLocale?: string;
|
|
399
|
-
};
|
|
400
|
-
type IServerSideContext = ServerSidePropsContext<IContextParams>;
|
|
401
|
-
type StateValue = StateValue[] | {
|
|
402
|
-
[key: string]: StateValue;
|
|
403
|
-
} | number | string | boolean | null | undefined;
|
|
404
|
-
|
|
405
420
|
declare function getClassNames(...props: Array<IClassName>): string;
|
|
406
421
|
|
|
407
422
|
declare function getCollectionDescription(text: string): ICollectionDescription;
|
|
@@ -471,4 +486,4 @@ declare function awaitAll(array: any, callback: (item: any, index: number) => Pr
|
|
|
471
486
|
declare function merge(target: any, source: any): any;
|
|
472
487
|
declare function deepCopy<T>(source: T): T;
|
|
473
488
|
|
|
474
|
-
export { FetchRequestOptions, FetchService, FindParams, FindWhereParams, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, 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, IQuerable, IRoute, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, Json, JsonService, 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 };
|