@websolutespa/bom-core 0.1.0 → 0.1.2
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 +12 -0
- package/dist/index.d.ts +75 -70
- 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,13 +95,14 @@ 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[];
|
|
49
103
|
};
|
|
50
104
|
type ICategorized = {
|
|
105
|
+
abstract?: ILocalizable;
|
|
51
106
|
category: IEquatable | ICategory;
|
|
52
107
|
id: IEquatable;
|
|
53
108
|
isDefault?: boolean;
|
|
@@ -55,9 +110,9 @@ type ICategorized = {
|
|
|
55
110
|
media?: IMedia;
|
|
56
111
|
order?: number;
|
|
57
112
|
schema?: string;
|
|
58
|
-
slug?:
|
|
113
|
+
slug?: ILocalizable;
|
|
59
114
|
template?: string;
|
|
60
|
-
title?:
|
|
115
|
+
title?: ILocalizable;
|
|
61
116
|
useSplat?: boolean;
|
|
62
117
|
};
|
|
63
118
|
|
|
@@ -85,7 +140,7 @@ type FetchService<T = any> = (url: string, options?: FetchRequestOptions, servic
|
|
|
85
140
|
|
|
86
141
|
type ILabel = IEntity & {
|
|
87
142
|
id: IEquatable;
|
|
88
|
-
text?:
|
|
143
|
+
text?: ILocalizable;
|
|
89
144
|
};
|
|
90
145
|
|
|
91
146
|
type ILocale = IEntity & {
|
|
@@ -167,37 +222,34 @@ type PageProps<T extends ICategorized = ICategorized> = {
|
|
|
167
222
|
};
|
|
168
223
|
|
|
169
224
|
type IMenuBase = {
|
|
225
|
+
abstract?: ILocalizable;
|
|
226
|
+
customClass?: string;
|
|
170
227
|
id: IEquatable;
|
|
171
|
-
abstract?: string;
|
|
172
|
-
media?: IMedia;
|
|
173
228
|
items?: IMenuItem[];
|
|
229
|
+
media?: IMedia;
|
|
230
|
+
title: ILocalizable;
|
|
174
231
|
};
|
|
175
232
|
type IMenuCategory = IMenuBase & {
|
|
176
233
|
type: 'category';
|
|
177
|
-
title: string | ILocalizedString;
|
|
178
234
|
href: string;
|
|
179
235
|
category: IEquatable;
|
|
180
236
|
};
|
|
181
237
|
type IMenuGroup = IMenuBase & {
|
|
182
238
|
type: 'group';
|
|
183
|
-
title: string | ILocalizedString;
|
|
184
239
|
};
|
|
185
240
|
type IMenuLink = IMenuBase & {
|
|
186
241
|
type: 'link';
|
|
187
|
-
title: string | ILocalizedString;
|
|
188
242
|
href: string;
|
|
189
243
|
target: string;
|
|
190
244
|
};
|
|
191
245
|
type IMenuRoute = IMenuBase & {
|
|
192
246
|
type: 'route';
|
|
193
|
-
title: string | ILocalizedString;
|
|
194
247
|
href: string;
|
|
195
248
|
page: IEquatable;
|
|
196
249
|
schema: string;
|
|
197
250
|
};
|
|
198
251
|
type IMenuPage = IMenuBase & {
|
|
199
252
|
type: 'page';
|
|
200
|
-
title: string | ILocalizedString;
|
|
201
253
|
href: string;
|
|
202
254
|
page: IEquatable;
|
|
203
255
|
schema: string;
|
|
@@ -215,7 +267,8 @@ type IMenu = {
|
|
|
215
267
|
* this is the original menu model from cms
|
|
216
268
|
*/
|
|
217
269
|
type IUndecoratedMenuBase = {
|
|
218
|
-
abstract?:
|
|
270
|
+
abstract?: ILocalizable;
|
|
271
|
+
customClass?: string;
|
|
219
272
|
id?: string;
|
|
220
273
|
items: IUndecoratedMenuItem[];
|
|
221
274
|
markets?: string[];
|
|
@@ -226,22 +279,22 @@ type IUndecoratedMenuCategory = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
|
226
279
|
type: 'category';
|
|
227
280
|
category: string;
|
|
228
281
|
maxDepth?: number;
|
|
229
|
-
title?:
|
|
282
|
+
title?: ILocalizable;
|
|
230
283
|
};
|
|
231
284
|
type IUndecoratedMenuGroup = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
232
285
|
type: 'group';
|
|
233
|
-
title:
|
|
286
|
+
title: ILocalizable;
|
|
234
287
|
};
|
|
235
288
|
type IUndecoratedMenuLink = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
236
289
|
type: 'link';
|
|
237
|
-
title:
|
|
290
|
+
title: ILocalizable;
|
|
238
291
|
href: string;
|
|
239
292
|
target?: string;
|
|
240
293
|
};
|
|
241
294
|
type IUndecoratedMenuPage = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
242
295
|
type: 'page';
|
|
243
296
|
page: IPageRelation;
|
|
244
|
-
title?:
|
|
297
|
+
title?: ILocalizable;
|
|
245
298
|
};
|
|
246
299
|
type IUndecoratedMenuCustom = Record<string, unknown> & {
|
|
247
300
|
id: IEquatable;
|
|
@@ -359,58 +412,10 @@ type ISerializedStore = Record<string, ISerializedCollection>;
|
|
|
359
412
|
|
|
360
413
|
type ITemplate = {
|
|
361
414
|
id: IEquatable;
|
|
362
|
-
name:
|
|
415
|
+
name: ILocalizable;
|
|
363
416
|
collections: string[];
|
|
364
417
|
};
|
|
365
418
|
|
|
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
419
|
declare function getClassNames(...props: Array<IClassName>): string;
|
|
415
420
|
|
|
416
421
|
declare function getCollectionDescription(text: string): ICollectionDescription;
|
|
@@ -480,4 +485,4 @@ declare function awaitAll(array: any, callback: (item: any, index: number) => Pr
|
|
|
480
485
|
declare function merge(target: any, source: any): any;
|
|
481
486
|
declare function deepCopy<T>(source: T): T;
|
|
482
487
|
|
|
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 };
|
|
488
|
+
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 };
|