@websolutespa/bom-core 0.3.0 → 0.4.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/dist/index.d.ts CHANGED
@@ -1,549 +1,571 @@
1
1
  import { IncomingMessage, ServerResponse } from 'http';
2
2
  import { ParsedUrlQuery } from 'querystring';
3
3
 
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<{
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];
56
- };
57
-
58
- type ILocalizedString = Record<string, string>;
59
- type ILocalizable = string | ILocalizedString;
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<{
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];
56
+ };
57
+
58
+ type ILocalizedString = Record<string, string>;
59
+ type ILocalizable = string | ILocalizedString;
60
60
  type ILocalized<T> = IOverride<T, ILocalizable, string>;
61
61
 
62
- type IEquatable = number | string;
63
- type SchemaType = string;
64
- type IOption = Record<string, any> & {
65
- id: IEquatable;
66
- name: string;
67
- };
68
- type ISchema = {
69
- id: IEquatable;
70
- schema?: string;
71
- };
72
- type IEntity = Record<string, unknown> & ISchema;
73
- type INamedEntity = IEntity & {
74
- name: ILocalizable;
75
- };
76
- type ITitledEntity = IEntity & {
77
- title: ILocalizable;
78
- };
79
-
80
- type IMediaType = 'image' | 'video' | string;
81
- type IMedia = {
82
- src: string;
83
- type: IMediaType;
84
- alt?: string;
85
- title?: string;
86
- abstract?: string;
87
- width?: number;
88
- height?: number;
89
- url?: string;
90
- media?: IMedia;
91
- };
92
-
93
- type ICategory = IEntity & {
94
- category?: IEquatable | ICategory;
95
- id: IEquatable;
96
- media?: IMedia;
97
- order?: number;
98
- slug: ILocalizable;
99
- title: ILocalizable;
100
- };
101
- type ICategoryItem = ICategory & {
102
- items: ICategory[];
103
- };
104
- type ICategorized = {
105
- abstract?: ILocalizable;
106
- category: IEquatable | ICategory;
107
- id: IEquatable;
108
- isDefault?: boolean;
109
- markets?: string[];
110
- media?: IMedia;
111
- order?: number;
112
- schema?: string;
113
- slug: ILocalizable;
114
- template?: string;
115
- title: ILocalizable;
116
- useSplat?: boolean;
117
- createdAt?: Date;
118
- updatedAt?: Date;
119
- };
120
-
121
- type IClassNameValue = string | boolean | number | null | undefined;
122
- type IClassNameCollection = Record<string, IClassNameValue>;
62
+ type IAnchor = {
63
+ id: string;
64
+ title?: ILocalizable;
65
+ };
66
+
67
+ type IEquatable = number | string;
68
+ type SchemaType = string;
69
+ type IOption = Record<string, any> & {
70
+ id: IEquatable;
71
+ name: string;
72
+ };
73
+ type ISchema = {
74
+ id: IEquatable;
75
+ schema?: string;
76
+ };
77
+ type IEntity = Record<string, unknown> & ISchema;
78
+ type INamedEntity = IEntity & {
79
+ name: ILocalizable;
80
+ };
81
+ type ITitledEntity = IEntity & {
82
+ title: ILocalizable;
83
+ };
84
+
85
+ type IMediaType = 'image' | 'video' | string;
86
+ type IMedia = {
87
+ src: string;
88
+ type: IMediaType;
89
+ alt?: string;
90
+ title?: string;
91
+ abstract?: string;
92
+ width?: number;
93
+ height?: number;
94
+ url?: string;
95
+ media?: IMedia;
96
+ };
97
+
98
+ type ICategory = IEntity & {
99
+ category?: IEquatable | ICategory;
100
+ id: IEquatable;
101
+ media?: IMedia;
102
+ order?: number;
103
+ slug: ILocalizable;
104
+ title: ILocalizable;
105
+ };
106
+ type ICategoryItem = ICategory & {
107
+ items: ICategory[];
108
+ };
109
+ type ICategorized = {
110
+ abstract?: ILocalizable;
111
+ category: IEquatable | ICategory;
112
+ id: IEquatable;
113
+ isDefault?: boolean;
114
+ markets?: string[];
115
+ media?: IMedia;
116
+ order?: number;
117
+ schema?: string;
118
+ slug: ILocalizable;
119
+ template?: string;
120
+ title: ILocalizable;
121
+ useSplat?: boolean;
122
+ createdAt?: Date;
123
+ updatedAt?: Date;
124
+ };
125
+
126
+ type IClassNameValue = string | boolean | number | null | undefined;
127
+ type IClassNameCollection = Record<string, IClassNameValue>;
123
128
  type IClassName = IClassNameCollection | IClassNameValue;
124
129
 
125
- type FetchRequestOptions = {
126
- method?: string;
127
- headers?: {
128
- [key: string]: string;
129
- };
130
- body?: Blob | BufferSource | FormData | URLSearchParams | string | ReadableStream;
131
- mode?: 'cors' | 'no-cors' | 'same-origin';
132
- credentials?: 'omit' | 'same-origin' | 'include';
133
- cache?: 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached';
134
- redirect?: 'follow' | 'error' | 'manual';
135
- referrer?: string;
136
- referrerPolicy?: 'no-referrer, no-referrer-when-downgrade, same-origin, origin, strict-origin, origin-when-cross-origin, strict-origin-when-cross-origin, or unsafe-url';
137
- integrity?: string;
138
- keepalive?: boolean;
139
- signal?: AbortSignal;
140
- };
141
- type FetchService<T = unknown> = (url: string, options?: FetchRequestOptions, serviceOptions?: any) => Promise<T>;
130
+ type FetchRequestOptions = {
131
+ method?: string;
132
+ headers?: {
133
+ [key: string]: string;
134
+ };
135
+ body?: Blob | BufferSource | FormData | URLSearchParams | string | ReadableStream;
136
+ mode?: 'cors' | 'no-cors' | 'same-origin';
137
+ credentials?: 'omit' | 'same-origin' | 'include';
138
+ cache?: 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached';
139
+ redirect?: 'follow' | 'error' | 'manual';
140
+ referrer?: string;
141
+ referrerPolicy?: 'no-referrer, no-referrer-when-downgrade, same-origin, origin, strict-origin, origin-when-cross-origin, strict-origin-when-cross-origin, or unsafe-url';
142
+ integrity?: string;
143
+ keepalive?: boolean;
144
+ signal?: AbortSignal;
145
+ };
146
+ type FetchService<T = unknown> = (url: string, options?: FetchRequestOptions, serviceOptions?: any) => Promise<T>;
142
147
  type FetchError = any;
143
148
 
144
- type ILabel = IEntity & {
145
- id: IEquatable;
146
- text?: ILocalizable;
147
- };
148
-
149
- type ILocale = IEntity & {
150
- id: string;
151
- title?: string;
152
- isActive?: boolean;
153
- isDefault?: boolean;
154
- isHidden?: boolean;
155
- };
156
-
157
- type IMarket = IEntity & {
158
- id: string;
159
- title?: string;
160
- countries?: string[];
161
- languages?: string[];
162
- defaultLanguage?: string;
163
- isActive?: boolean;
164
- isDefault?: boolean;
165
- isHidden?: boolean;
166
- };
167
-
168
- type IMeta = {
169
- title?: string;
170
- description?: string;
171
- keywords?: string;
172
- robots?: string;
173
- };
174
-
175
- type IRoute = {
176
- category: IEquatable | ICategory;
177
- id: string;
178
- isDefault?: boolean;
179
- locale: string;
180
- market: string;
181
- order?: number;
182
- page: IEquatable;
183
- schema: string;
184
- template?: string;
185
- title: string;
186
- media?: IMedia;
187
- useSplat?: boolean;
188
- updatedAt?: Date;
189
- };
190
- type IRouteCanonical = IRoute & {
191
- alternates: IRoute[];
192
- };
193
- type IRouteLink = {
194
- href: string;
195
- id: IEquatable;
196
- items?: IRouteLink[];
197
- media?: IMedia;
198
- title: string;
199
- };
200
- type IRouteParams = Record<string, any> & {
201
- id: IEquatable;
202
- locale: string;
203
- market: string;
204
- };
205
-
206
- type IPage = Record<string, any> & ICategorized & {
207
- abstract?: string;
208
- alternates: IRoute[];
209
- breadcrumb: IRouteLink[];
210
- content?: string;
211
- description?: string;
212
- href: string;
213
- locale: string;
214
- market: string;
215
- meta?: IMeta;
216
- parentRoute?: IRouteLink;
217
- slug: string;
218
- title: string;
219
- };
220
- type IPageRelation = {
221
- relationTo: string;
222
- value: ICategorized;
223
- };
224
- type IPageResult<T extends ICategorized = ICategorized> = IPage & T;
225
- type PageProps<T extends ICategorized = ICategorized> = {
226
- layout: ILayout;
227
- page: IPageResult<T>;
228
- params: IRouteParams;
229
- locales?: string[];
230
- locale?: string;
231
- defaultLocale?: string;
232
- };
233
-
234
- type IMenuBase = {
235
- abstract?: ILocalizable;
236
- customClass?: string;
237
- id: IEquatable;
238
- items?: IMenuItem[];
239
- media?: IMedia;
240
- title: ILocalizable;
241
- };
242
- type IMenuCategory = IMenuBase & {
243
- type: 'category';
244
- href: string;
245
- category: IEquatable;
246
- };
247
- type IMenuGroup = IMenuBase & {
248
- type: 'group';
249
- };
250
- type IMenuLink = IMenuBase & {
251
- type: 'link';
252
- href: string;
253
- target: string;
254
- };
255
- type IMenuRoute = IMenuBase & {
256
- type: 'route';
257
- href: string;
258
- page: IEquatable;
259
- schema: string;
260
- };
261
- type IMenuPage = IMenuBase & {
262
- type: 'page';
263
- href: string;
264
- page: IEquatable;
265
- schema: string;
266
- };
267
- type IMenuCustom = Record<string, unknown> & {
268
- id: IEquatable;
269
- type: string;
270
- };
271
- type IMenuItem = IMenuCategory | IMenuGroup | IMenuLink | IMenuPage | IMenuRoute;
272
- type IMenu = {
273
- id: string;
274
- items: IMenuItem[];
275
- };
276
- /**
277
- * this is the original menu model from cms
278
- */
279
- type IUndecoratedMenuBase = {
280
- abstract?: ILocalizable;
281
- customClass?: string;
282
- id?: string;
283
- items: IUndecoratedMenuItem[];
284
- markets?: string[];
285
- media?: IMedia;
286
- type: string;
287
- };
288
- type IUndecoratedMenuCategory = Omit<IUndecoratedMenuBase, 'type'> & {
289
- type: 'category';
290
- category: string;
291
- maxDepth?: number;
292
- title?: ILocalizable;
293
- };
294
- type IUndecoratedMenuGroup = Omit<IUndecoratedMenuBase, 'type'> & {
295
- type: 'group';
296
- title: ILocalizable;
297
- };
298
- type IUndecoratedMenuLink = Omit<IUndecoratedMenuBase, 'type'> & {
299
- type: 'link';
300
- title: ILocalizable;
301
- href: string;
302
- target?: string;
303
- };
304
- type IUndecoratedMenuPage = Omit<IUndecoratedMenuBase, 'type'> & {
305
- type: 'page';
306
- page: IPageRelation;
307
- title?: ILocalizable;
308
- };
309
- type IUndecoratedMenuCustom = Record<string, unknown> & {
310
- id: IEquatable;
311
- type: 'custom';
312
- blockType: string;
313
- };
314
- type IUndecoratedMenuItem = IUndecoratedMenuCategory | IUndecoratedMenuGroup | IUndecoratedMenuLink | IUndecoratedMenuPage | IUndecoratedMenuCustom;
315
- type IUndecoratedMenu = {
316
- id: string;
317
- items: IUndecoratedMenuItem[];
318
- };
319
-
320
- type ILayout = {
321
- labels: ILabel[];
322
- locale: string;
323
- locales: ILocale[];
324
- market: string;
325
- markets: IMarket[];
326
- menu: Record<string, IMenu>;
327
- topLevelHrefs: Record<string, string>;
328
- topLevelRoutes: Record<string, IRouteLink>;
329
- tree?: IRouteLink;
330
- };
331
-
332
- type Pagination = {
333
- hasNextPage: boolean;
334
- hasPrevPage: boolean;
335
- limit: number;
336
- nextPage: number | null;
337
- page: number;
338
- pagingCounter: number;
339
- prevPage: number | null;
340
- totalDocs: number;
341
- totalPages: number;
342
- };
343
-
344
- type Operator = 'equals' | 'contains' | 'not_equals' | 'in' | 'not_in' | 'exists' | 'greater_than' | 'greater_than_equal' | 'less_than' | 'less_than_equal' | 'like' | 'near';
345
- type WhereField = {
346
- [key in Operator]?: unknown;
347
- };
348
- type WhereBase = {
349
- [key: string]: WhereField | Where[];
350
- };
351
- type WhereAndOr = {
352
- or?: Where[];
353
- and?: Where[];
354
- };
355
- type Where = WhereBase & WhereAndOr;
356
- type QueryParams = {
357
- where?: Where;
358
- locale?: string;
359
- market?: string;
360
- sort?: string;
361
- page?: number;
362
- limit?: number;
363
- depth?: number;
364
- draft?: boolean;
365
- pagination?: boolean;
366
- richText?: boolean;
367
- };
368
-
369
- type IQuerable<T extends IEntity = IEntity> = {
370
- findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
371
- findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
372
- findPaged<B extends T = T>(params?: QueryParams): Promise<{
373
- docs: B[];
374
- } & Pagination>;
375
- create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
376
- update<B extends T = T>(payload: Partial<B>): Promise<B>;
377
- delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
378
- };
379
- type FindParams = {
380
- where?: {
381
- [key: string]: unknown;
382
- };
383
- market?: string;
384
- locale?: string;
385
- };
386
- type FindWhereParams = {
387
- where: {
388
- [key: string]: unknown;
389
- };
390
- market?: string;
391
- locale?: string;
392
- };
149
+ type ILabel = IEntity & {
150
+ id: IEquatable;
151
+ text?: ILocalizable;
152
+ };
153
+
154
+ type ILocale = IEntity & {
155
+ id: string;
156
+ title?: string;
157
+ isActive?: boolean;
158
+ isDefault?: boolean;
159
+ isHidden?: boolean;
160
+ };
161
+
162
+ type IMarket = IEntity & {
163
+ id: string;
164
+ title?: string;
165
+ countries?: string[];
166
+ languages?: string[];
167
+ defaultLanguage?: string;
168
+ isActive?: boolean;
169
+ isDefault?: boolean;
170
+ isHidden?: boolean;
171
+ };
172
+
173
+ type IMeta = {
174
+ title?: string;
175
+ description?: string;
176
+ keywords?: string;
177
+ robots?: string;
178
+ };
179
+
180
+ type IRoute = {
181
+ category: IEquatable | ICategory;
182
+ id: string;
183
+ isDefault?: boolean;
184
+ locale: string;
185
+ market: string;
186
+ order?: number;
187
+ page: IEquatable;
188
+ schema: string;
189
+ template?: string;
190
+ title: string;
191
+ media?: IMedia;
192
+ useSplat?: boolean;
193
+ updatedAt?: Date;
194
+ };
195
+ type IRouteCanonical = IRoute & {
196
+ alternates: IRoute[];
197
+ };
198
+ type IRouteLink = {
199
+ href: string;
200
+ id: IEquatable;
201
+ items?: IRouteLink[];
202
+ media?: IMedia;
203
+ title: string;
204
+ };
205
+ type IRouteParams = Record<string, any> & {
206
+ id: IEquatable;
207
+ locale: string;
208
+ market: string;
209
+ };
210
+
211
+ type IPage = Record<string, any> & ICategorized & {
212
+ abstract?: string;
213
+ alternates: IRoute[];
214
+ breadcrumb: IRouteLink[];
215
+ content?: string;
216
+ description?: string;
217
+ href: string;
218
+ locale: string;
219
+ market: string;
220
+ meta?: IMeta;
221
+ parentRoute?: IRouteLink;
222
+ slug: string;
223
+ title: string;
224
+ };
225
+ type IPageRelationResult<T extends ICategorized = ICategorized> = {
226
+ href: string;
227
+ } & T;
228
+ type IPageRelation<T extends ICategorized = ICategorized> = {
229
+ relationTo: string;
230
+ value: IPageRelationResult<T>;
231
+ };
232
+ type IPageResult<T extends ICategorized = ICategorized> = IPage & T;
233
+ type PageProps<T extends ICategorized = ICategorized> = {
234
+ layout: ILayout;
235
+ page: IPageResult<T>;
236
+ params: IRouteParams;
237
+ locales?: string[];
238
+ locale?: string;
239
+ defaultLocale?: string;
240
+ };
241
+
242
+ type IMenuBase = {
243
+ abstract?: ILocalizable;
244
+ customClass?: string;
245
+ id: IEquatable;
246
+ items?: IMenuItem[];
247
+ media?: IMedia;
248
+ title: ILocalizable;
249
+ };
250
+ type IMenuCategory = IMenuBase & {
251
+ type: 'category';
252
+ href: string;
253
+ category: IEquatable;
254
+ };
255
+ type IMenuGroup = IMenuBase & {
256
+ type: 'group';
257
+ };
258
+ type IMenuLink = IMenuBase & {
259
+ type: 'link';
260
+ href: string;
261
+ target: string;
262
+ };
263
+ type IMenuRoute = IMenuBase & {
264
+ type: 'route';
265
+ href: string;
266
+ page: IEquatable;
267
+ schema: string;
268
+ };
269
+ type IMenuPage = IMenuBase & {
270
+ type: 'page';
271
+ href: string;
272
+ page: IEquatable;
273
+ schema: string;
274
+ };
275
+ type IMenuCustom = Record<string, unknown> & {
276
+ id: IEquatable;
277
+ type: string;
278
+ };
279
+ type IMenuItem = IMenuCategory | IMenuGroup | IMenuLink | IMenuPage | IMenuRoute;
280
+ type IMenu = {
281
+ id: string;
282
+ items: IMenuItem[];
283
+ };
284
+ /**
285
+ * this is the original menu model from cms
286
+ */
287
+ type IUndecoratedMenuBase = {
288
+ abstract?: ILocalizable;
289
+ customClass?: string;
290
+ id?: string;
291
+ items: IUndecoratedMenuItem[];
292
+ markets?: string[];
293
+ media?: IMedia;
294
+ type: string;
295
+ };
296
+ type IUndecoratedMenuCategory = Omit<IUndecoratedMenuBase, 'type'> & {
297
+ type: 'category';
298
+ category: string;
299
+ maxDepth?: number;
300
+ title?: ILocalizable;
301
+ };
302
+ type IUndecoratedMenuGroup = Omit<IUndecoratedMenuBase, 'type'> & {
303
+ type: 'group';
304
+ title: ILocalizable;
305
+ };
306
+ type IUndecoratedMenuLink = Omit<IUndecoratedMenuBase, 'type'> & {
307
+ type: 'link';
308
+ title: ILocalizable;
309
+ href: string;
310
+ target?: string;
311
+ };
312
+ type IUndecoratedMenuPage = Omit<IUndecoratedMenuBase, 'type'> & {
313
+ type: 'page';
314
+ page: IPageRelation;
315
+ title?: ILocalizable;
316
+ };
317
+ type IUndecoratedMenuCustom = Record<string, unknown> & {
318
+ id: IEquatable;
319
+ type: 'custom';
320
+ blockType: string;
321
+ };
322
+ type IUndecoratedMenuItem = IUndecoratedMenuCategory | IUndecoratedMenuGroup | IUndecoratedMenuLink | IUndecoratedMenuPage | IUndecoratedMenuCustom;
323
+ type IUndecoratedMenu = {
324
+ id: string;
325
+ items: IUndecoratedMenuItem[];
326
+ };
327
+
328
+ type ILayout = {
329
+ labels: ILabel[];
330
+ locale: string;
331
+ locales: ILocale[];
332
+ market: string;
333
+ markets: IMarket[];
334
+ menu: Record<string, IMenu>;
335
+ topLevelHrefs: Record<string, string>;
336
+ topLevelRoutes: Record<string, IRouteLink>;
337
+ tree?: IRouteLink;
338
+ };
339
+
340
+ type Pagination = {
341
+ hasNextPage: boolean;
342
+ hasPrevPage: boolean;
343
+ limit: number;
344
+ nextPage: number | null;
345
+ page: number;
346
+ pagingCounter: number;
347
+ prevPage: number | null;
348
+ totalDocs: number;
349
+ totalPages: number;
350
+ };
351
+
352
+ type Operator = 'equals' | 'contains' | 'not_equals' | 'in' | 'not_in' | 'exists' | 'greater_than' | 'greater_than_equal' | 'less_than' | 'less_than_equal' | 'like' | 'near';
353
+ type WhereField = {
354
+ [key in Operator]?: unknown;
355
+ };
356
+ type WhereBase = {
357
+ [key: string]: WhereField | Where[];
358
+ };
359
+ type WhereAndOr = {
360
+ or?: Where[];
361
+ and?: Where[];
362
+ };
363
+ type Where = WhereBase & WhereAndOr;
364
+ type QueryParams = {
365
+ where?: Where;
366
+ locale?: string;
367
+ market?: string;
368
+ sort?: string;
369
+ page?: number;
370
+ limit?: number;
371
+ depth?: number;
372
+ draft?: boolean;
373
+ pagination?: boolean;
374
+ richText?: boolean;
375
+ };
376
+
377
+ type IQuerable<T extends IEntity = IEntity> = {
378
+ findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
379
+ findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
380
+ findPaged<B extends T = T>(params?: QueryParams): Promise<{
381
+ docs: B[];
382
+ } & Pagination>;
383
+ create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
384
+ update<B extends T = T>(payload: Partial<B>): Promise<B>;
385
+ delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
386
+ };
387
+ type FindParams = {
388
+ where?: {
389
+ [key: string]: unknown;
390
+ };
391
+ market?: string;
392
+ locale?: string;
393
+ };
394
+ type FindWhereParams = {
395
+ where: {
396
+ [key: string]: unknown;
397
+ };
398
+ market?: string;
399
+ locale?: string;
400
+ };
393
401
  declare function toFindParams(idOrParams: IEquatable | FindWhereParams): FindWhereParams;
394
402
 
395
- declare enum RedirectReason {
396
- MovedPermanently = "301",
397
- Found = "302",
398
- TemporaryRedirect = "307",
399
- PermanentRedirect = "308",
400
- Gone = "410"
401
- }
402
- type IRedirect = {
403
- id: IEquatable;
404
- status: RedirectReason;
405
- from: string;
406
- to?: string;
407
- name?: string;
408
- order?: number;
409
- isActive: boolean;
410
- };
411
-
412
- type IMemoryStore<T extends IEntity = IEntity> = Record<string, T[]>;
413
- type IStore = Record<string, IQuerable<IEntity>>;
414
- type IConfig = {
415
- collections: string[];
416
- mocks: string[];
417
- pages: string[];
418
- };
419
- type IPackages = {
420
- icons: string;
421
- models: string;
422
- ui: string;
423
- };
424
- type ICollectionDescription = {
425
- singularName: string;
426
- pluralName: string;
427
- pluralDisplayName: string;
428
- displayName: string;
429
- title: string;
430
- };
431
- type ISerializedCollection = {
432
- singularName: string;
433
- pluralName: string;
434
- pluralDisplayName: string;
435
- displayName: string;
436
- items: IEntity[];
437
- };
403
+ declare enum RedirectReason {
404
+ MovedPermanently = "301",
405
+ Found = "302",
406
+ TemporaryRedirect = "307",
407
+ PermanentRedirect = "308",
408
+ Gone = "410"
409
+ }
410
+ type IRedirect = {
411
+ id: IEquatable;
412
+ status: RedirectReason;
413
+ from: string;
414
+ to?: string;
415
+ name?: string;
416
+ order?: number;
417
+ isActive: boolean;
418
+ };
419
+
420
+ type IMemoryStore<T extends IEntity = IEntity> = Record<string, T[]>;
421
+ type IStore = Record<string, IQuerable<IEntity>>;
422
+ type IConfig = {
423
+ collections: string[];
424
+ mocks: string[];
425
+ pages: string[];
426
+ };
427
+ type IPackages = {
428
+ icons: string;
429
+ models: string;
430
+ ui: string;
431
+ };
432
+ type ICollectionDescription = {
433
+ singularName: string;
434
+ pluralName: string;
435
+ pluralDisplayName: string;
436
+ displayName: string;
437
+ title: string;
438
+ };
439
+ type ISerializedCollection<T extends IEntity = IEntity> = ICollectionDescription & {
440
+ items: T[];
441
+ };
438
442
  type ISerializedStore = Record<string, ISerializedCollection>;
439
443
 
440
- type ITemplate = {
441
- id: IEquatable;
442
- name: ILocalizable;
443
- collections: string[];
444
+ type ITemplate = {
445
+ id: IEquatable;
446
+ name: ILocalizable;
447
+ collections: string[];
444
448
  };
445
449
 
446
- declare function isCategory(value?: ICategory | IEquatable): value is ICategory;
447
- declare function asCategoryId(value?: ICategory | IEquatable): string | undefined;
448
- declare function getRootCategory(categories: ICategory[]): ICategory | undefined;
449
- declare function getParentCategoriesById(id: string | undefined, categories: ICategory[]): ICategory[];
450
- declare function getCategorySegments(item: ICategorized, categories: ICategory[]): ICategory[];
450
+ declare function isCategory(value?: ICategory | IEquatable): value is ICategory;
451
+ declare function asCategoryId(value?: ICategory | IEquatable): string | undefined;
452
+ declare function getRootCategory(categories: ICategory[]): ICategory | undefined;
453
+ declare function getParentCategoriesById(id: string | undefined, categories: ICategory[]): ICategory[];
454
+ declare function getCategorySegments(item: ICategorized, categories: ICategory[]): ICategory[];
451
455
  declare function getCategorySegmentsByCategory(item: ICategory, categories: ICategory[]): ICategory[];
452
456
 
453
457
  declare function getClassNames(...props: Array<IClassName>): string;
454
458
 
455
- declare function getCollectionDescription(text: string): ICollectionDescription;
456
- declare function isValidCollectionDescription(description: ICollectionDescription): boolean;
457
- declare function toValidCollectionName(text: string): string;
458
- declare function camelToSnakeCase(text: string): string;
459
- declare function toDisplayName(text: string): string;
460
- declare function toPluralName(text: string): string;
459
+ declare function getCollectionDescription(text: string): ICollectionDescription;
460
+ declare function camelToSnakeCase(text: string): string;
461
+ declare function isValidCollectionDescription(description: ICollectionDescription): boolean;
462
+ declare function toDisplayName(text: string): string;
463
+ declare function toPluralName(text: string): string;
461
464
  declare function toTitleCase(text: string): string;
465
+ declare function toValidCollectionName(text: string): string;
462
466
 
463
467
  declare function consoleWarn(message: string, component?: string): void;
464
468
 
465
- declare function httpFetch(url: string, options?: FetchRequestOptions, serviceOptions?: any): Promise<any>;
466
- declare function httpGet(url: string, options?: FetchRequestOptions): Promise<any>;
467
- declare function httpPost(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
468
- declare function httpPut(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
469
- declare function httpPatch(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
469
+ declare function httpFetch(url: string, options?: FetchRequestOptions, serviceOptions?: any): Promise<any>;
470
+ declare function httpGet(url: string, options?: FetchRequestOptions): Promise<any>;
471
+ declare function httpPost(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
472
+ declare function httpPut(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
473
+ declare function httpPatch(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
470
474
  declare function httpDelete(url: string, options?: FetchRequestOptions): Promise<any>;
471
475
 
472
- declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
473
- items: T[];
474
- constructor(items: T[]);
475
- getItems<B extends T = T>(): Promise<B[]>;
476
- findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
477
- findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
478
- findPaged<B extends T = T>(params?: QueryParams): Promise<{
479
- docs: B[];
480
- } & Pagination>;
481
- create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
482
- update<B extends T = T>(payload: Partial<B>): Promise<B>;
483
- delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
484
- protected decorator_<B extends T = T>(item: B, params?: QueryParams): B;
485
- protected newUUID_(): number;
486
- protected evaluateValue_(value: unknown): unknown;
487
- protected existsClause_(value: unknown, exists?: boolean): boolean;
488
- protected equalsClause_(value: unknown, equals?: unknown): boolean;
489
- protected inClause_(value: unknown, values?: unknown[]): boolean;
490
- protected notInClause_(value: unknown, values?: unknown[]): boolean;
491
- protected likeClause_(value: unknown, query?: string): boolean;
492
- protected whereItem_<B extends T = T>(item: B, where?: Where): boolean;
493
- protected whereItems_<B extends T = T>(items: B[], where?: Where): B[];
494
- protected sortCollection_<B extends T = T>(items: B[], sort?: string): B[];
495
- protected paginatedItems_<B extends T = T>(items: B[], page?: number, limit?: number): ({
496
- docs: B[];
497
- } & Pagination);
476
+ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
477
+ items: T[];
478
+ constructor(items: T[]);
479
+ getItems<B extends T = T>(): Promise<B[]>;
480
+ findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
481
+ findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
482
+ findPaged<B extends T = T>(params?: QueryParams): Promise<{
483
+ docs: B[];
484
+ } & Pagination>;
485
+ create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
486
+ update<B extends T = T>(payload: Partial<B>): Promise<B>;
487
+ delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
488
+ protected decorator_<B extends T = T>(item: B, params?: QueryParams): B;
489
+ protected newUUID_(): number;
490
+ protected evaluateValue_(value: unknown): unknown;
491
+ protected existsClause_(value: unknown, exists?: boolean): boolean;
492
+ protected equalsClause_(value: unknown, equals?: unknown): boolean;
493
+ protected inClause_(value: unknown, values?: unknown[]): boolean;
494
+ protected notInClause_(value: unknown, values?: unknown[]): boolean;
495
+ protected likeClause_(value: unknown, query?: string): boolean;
496
+ protected whereItem_<B extends T = T>(item: B, where?: Where): boolean;
497
+ protected whereItems_<B extends T = T>(items: B[], where?: Where): B[];
498
+ protected sortCollection_<B extends T = T>(items: B[], sort?: string): B[];
499
+ protected paginatedItems_<B extends T = T>(items: B[], page?: number, limit?: number): ({
500
+ docs: B[];
501
+ } & Pagination);
498
502
  }
499
503
 
500
- declare function isLocalizedString(value: any): value is ILocalizedString;
501
- declare function localizedToString(json: ILocalizedString, locale?: string, defaultLocale?: string): string;
502
- declare function localize(value: ILocalizable, locale?: string, defaultLocale?: string): string;
503
- declare function localizeValue(value: any, locale?: string, defaultLocale?: string): any;
504
+ declare function isLocalizedString(value: any): value is ILocalizedString;
505
+ declare function localizedToString(json: ILocalizedString, locale?: string, defaultLocale?: string): string;
506
+ declare function localize(value: ILocalizable, locale?: string, defaultLocale?: string): string;
507
+ declare function localizeValue(value: any, locale?: string, defaultLocale?: string): any;
504
508
  declare function localizeItem(item: any, locale?: string, defaultLocale?: string): any;
505
509
 
506
- declare function qsSerialize(queryParams?: QueryParams): string;
507
- declare function asEquatable(value: string): IEquatable;
508
- declare function deserializeValue(value: string): string | boolean | number;
509
- declare function deserializeKey(value: string): string | number;
510
+ declare function qsSerialize(queryParams?: QueryParams): string;
511
+ declare function asEquatable(value: string): IEquatable;
512
+ declare function deserializeValue(value: string): string | boolean | number;
513
+ declare function deserializeKey(value: string): string | number;
510
514
  declare function qsDeserialize(query?: string, deserializedParams?: {}): QueryParams;
511
515
 
512
- declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
513
- declare function eachMarketLocale(markets: IMarket[], locales: ILocale[], callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): void;
514
- declare function eachCategorized(store: IMemoryStore<ICategorized>, callback: (item: ICategorized, key: string) => void): void;
515
- declare enum RouteStrategy {
516
- Auto = "auto",
517
- Default = "default",
518
- Manual = "manual"
519
- }
516
+ declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
517
+ declare function eachMarketLocale(markets: IMarket[], locales: ILocale[], callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): void;
518
+ declare function eachCategorized(store: IMemoryStore<ICategorized>, callback: (item: ICategorized, key: string) => void): void;
519
+ declare enum RouteStrategy {
520
+ Auto = "auto",
521
+ Default = "default",
522
+ Manual = "manual"
523
+ }
520
524
  declare function getRouteHref(segments: ICategory[], market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]): string;
521
525
 
522
526
  declare function textToSlug(title: string): string;
523
527
 
524
- type ListItem<T> = {
525
- [K in keyof T]: {
526
- readonly key: string;
527
- readonly value: T[K];
528
- };
529
- }[keyof T];
530
- /**
531
- * Helper to produce an array of enum descriptors.
532
- * @param enumeration Enumeration object.
533
- * @param separatorRegex Regex that would catch the separator in your enum key.
534
- */
528
+ /**
529
+ * PascalCase
530
+ * camelCase
531
+ * kebab-case
532
+ * snake_case
533
+ * char*case
534
+ **/
535
+ declare function unknownCaseToPascalCase(unknownCase: string): string;
536
+ declare function pascalCaseToCamelCase(pascalCase: string): string;
537
+ declare function pascalCaseToCharCase(pascalCase: string, char?: string): string;
538
+ declare function pascalCaseToKebabCase(pascalCase: string): string;
539
+ declare function pascalCaseToSnakeCase(pascalCase: string): string;
540
+ declare function toPascalCase(unknownCase: string): string;
541
+ declare function toCamelCase(unknownCase: string): string;
542
+ declare function toCharCase(unknownCase: string, char?: string): string;
543
+ declare function toKebabCase(unknownCase: string): string;
544
+ declare function toSnakeCase(unknownCase: string): string;
545
+
546
+ type ListItem<T> = {
547
+ [K in keyof T]: {
548
+ readonly key: string;
549
+ readonly value: T[K];
550
+ };
551
+ }[keyof T];
552
+ /**
553
+ * Helper to produce an array of enum descriptors.
554
+ * @param enumeration Enumeration object.
555
+ * @param separatorRegex Regex that would catch the separator in your enum key.
556
+ */
535
557
  declare function enumToList<T extends Record<string, number | string>>(enumeration: T, separatorRegex?: RegExp): ListItem<T>[];
536
558
 
537
- declare function getIsDevelopment(): boolean;
538
- declare function getIsProduction(): boolean;
539
- declare const isDevelopment: boolean;
540
- declare const isProduction: boolean;
541
- declare const isStage: boolean;
542
- declare const isBrowser: boolean;
543
- declare function getEnv(): Record<string, Json>;
544
- declare function withSchema<Component extends {}, Schema>(component: Component, schema: Schema): Component & Schema;
545
- declare function asServerProps(props: any): any;
546
- declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
559
+ declare function getIsDevelopment(): boolean;
560
+ declare function getIsProduction(): boolean;
561
+ declare const isDevelopment: boolean;
562
+ declare const isProduction: boolean;
563
+ declare const isStage: boolean;
564
+ declare const isBrowser: boolean;
565
+ declare function getEnv(): Record<string, Json>;
566
+ declare function withSchema<Component extends {}, Schema>(component: Component, schema: Schema): Component & Schema;
567
+ declare function asServerProps(props: any): any;
568
+ declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
547
569
  declare function merge(target: any, source: any): any;
548
570
 
549
- export { FetchError, 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, IRedirect, IRoute, IRouteCanonical, 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, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, collectRoutes, consoleWarn, deserializeKey, deserializeValue, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getIsDevelopment, getIsProduction, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isBrowser, isCategory, isDevelopment, isLocalizedString, isProduction, isStage, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, qsDeserialize, qsSerialize, textToSlug, toDisplayName, toFindParams, toPluralName, toTitleCase, toValidCollectionName, withSchema };
571
+ export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAnchor, 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, IPageRelationResult, IPageResult, IPartial, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, 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, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, collectRoutes, consoleWarn, deserializeKey, deserializeValue, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getIsDevelopment, getIsProduction, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isBrowser, isCategory, isDevelopment, isLocalizedString, isProduction, isStage, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsSerialize, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };