resora 0.1.11 → 0.2.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.mts CHANGED
@@ -11,7 +11,76 @@ import { Response } from "express";
11
11
  */
12
12
  declare function ApiResource<R extends Resource>(instance: Resource<R>): Resource<R>;
13
13
  //#endregion
14
- //#region src/types.d.ts
14
+ //#region src/types/common.d.ts
15
+ /**
16
+ * @description A type representing a case transformation strategy.
17
+ * Can be a preset string ('camel', 'snake', 'pascal', 'kebab') or a custom transformer function.
18
+ */
19
+ type CaseStyle = 'camel' | 'snake' | 'pascal' | 'kebab' | ((key: string) => string);
20
+ /**
21
+ * @description A type representing the resource serializer variant.
22
+ */
23
+ type ResponseKind = 'resource' | 'collection' | 'generic';
24
+ /**
25
+ * @description Context passed into a response factory function.
26
+ */
27
+ interface ResponseFactoryContext {
28
+ type: ResponseKind;
29
+ rootKey: string;
30
+ resource: any;
31
+ meta?: Record<string, any> | undefined;
32
+ }
33
+ /**
34
+ * @description A factory used to produce a fully custom response envelope.
35
+ */
36
+ type ResponseFactory = (payload: any, context: ResponseFactoryContext) => Record<string, any>;
37
+ /**
38
+ * @description Structure options for customizing the response envelope.
39
+ */
40
+ interface ResponseStructureConfig {
41
+ /**
42
+ * @description Whether payloads should be wrapped in a root key.
43
+ * Set to false to return unwrapped payloads when possible.
44
+ * @default true
45
+ */
46
+ wrap?: boolean | undefined;
47
+ /**
48
+ * @description The key used to wrap resource payloads.
49
+ * @default 'data'
50
+ */
51
+ rootKey?: string | undefined;
52
+ /**
53
+ * @description A factory for complete control over the final response structure.
54
+ */
55
+ factory?: ResponseFactory | undefined;
56
+ }
57
+ //#endregion
58
+ //#region src/types/pagination.d.ts
59
+ /**
60
+ * @description A type that represents the pagination information for a collection of resources. It includes properties such as currentPage, from, to, perPage, total, firstPage, lastPage, prevPage, and nextPage. All properties are optional and can be undefined if not applicable.
61
+ */
62
+ interface Pagination {
63
+ currentPage?: number | undefined;
64
+ from?: number | undefined;
65
+ to?: number | undefined;
66
+ perPage?: number | undefined;
67
+ total?: number | undefined;
68
+ firstPage?: number | undefined;
69
+ lastPage?: number | undefined;
70
+ prevPage?: number | undefined;
71
+ nextPage?: number | undefined;
72
+ path?: string | undefined;
73
+ links?: any;
74
+ }
75
+ /**
76
+ * @description A type that represents the cursor information for pagination. It includes properties such as before and after, which are optional and can be undefined if not applicable. The before property represents the cursor for the previous page, while the after property represents the cursor for the next page.
77
+ */
78
+ interface Cursor {
79
+ previous?: string | undefined;
80
+ next?: string | undefined;
81
+ }
82
+ //#endregion
83
+ //#region src/types/resource.d.ts
15
84
  interface MetaData {
16
85
  [key: string]: any;
17
86
  }
@@ -35,183 +104,47 @@ interface ResponseData<R extends ResourceData = any> extends ResourceDef {
35
104
  meta?: MetaData | undefined;
36
105
  }
37
106
  /**
38
- * @description A type that represents the metadata for a paginated collection of resources. It extends the MetaData type and includes all properties of a Collectible object except for the data property. This type is used to provide additional information about the paginated collection, such as pagination details, without including the actual resource data.
39
- * @example
40
- * const paginatedMeta: PaginatedMetaData = {
41
- * pagination: {
42
- * currentPage: 1,
43
- * total: 100
44
- * },
45
- * timestamp: '2024-06-01T12:00:00Z'
46
- * };
107
+ * @description A type that represents the metadata for a paginated collection of resources.
47
108
  */
48
109
  type PaginatedMetaData<R extends Collectible = Collectible> = MetaData & Omit<R, 'data'>;
49
110
  /**
50
- * @description A type that represents the body of a response for a collection of resources. It includes a data property, which can be either an array of ResourceData objects or a Collectible object, and an optional meta property that can contain any additional metadata related to the response. The type is generic and can be used to define the structure of the response body for API endpoints that return collections of resources.
51
- * @example
52
- * const collectionResponse: CollectionBody = {
53
- * data: [
54
- * { id: 1, name: 'Resource 1' },
55
- * { id: 2, name: 'Resource 2' }
56
- * ],
57
- * meta: {
58
- * pagination: {
59
- * currentPage: 1,
60
- * total: 2
61
- * }
62
- * }
63
- * };
111
+ * @description A type that represents the body of a response for a collection of resources.
64
112
  */
65
113
  interface ResponseDataCollection<R extends Collectible | undefined = undefined> extends ResourceData {
66
114
  data: R extends Collectible ? R['data'] : R;
67
115
  meta?: R extends Collectible ? PaginatedMetaData<R> | undefined : undefined;
68
116
  }
69
- /**
70
- * @description A type that represents the body of a response for a collection of resources.
71
- * It can be either an array of ResourceData objects or a Collectible object, which contains an
72
- * array of ResourceData objects. The type also includes the meta property, which is optional
73
- * and can contain any additional metadata related to the response.
74
- * @example
75
- * const collectionResponse: CollectionBody = {
76
- * data: [
77
- * { id: 1, name: 'Resource 1' },
78
- * { id: 2, name: 'Resource 2' }
79
- * ],
80
- * meta: {
81
- * pagination: {
82
- * currentPage: 1,
83
- * total: 2
84
- * }
85
- * }
86
- * };
87
- */
88
117
  type CollectionBody<R extends ResourceData[] | Collectible = ResourceData[]> = ResponseDataCollection<R extends Collectible ? R : {
89
118
  data: R;
90
119
  }>;
91
- /**
92
- * @description A type that represents the body of a response for a single resource.
93
- * It can be either a ResourceData object or a NonCollectible object, which contains a
94
- * ResourceData object. The type also includes the meta property, which is optional and can
95
- * contain any additional metadata related to the response.
96
- * @example
97
- * const resourceResponse: ResourceBody = {
98
- * data: {
99
- * id: 1,
100
- * name: 'Resource Name',
101
- * description: 'Resource Description'
102
- * },
103
- * meta: {
104
- * timestamp: '2024-06-01T12:00:00Z'
105
- * }
106
- * };
107
- */
108
120
  type ResourceBody<R extends ResourceData | NonCollectible = ResourceData> = ResponseData<R extends NonCollectible ? R : {
109
121
  data: R;
110
122
  }>;
111
- /**
112
- * @description A type that represents the body of a response for either a single resource or a collection of resources.
113
- * It can be either a ResourceData object, an array of ResourceData objects, a NonCollectible object, or a Collectible object.
114
- * The type also includes the meta property, which is optional and can contain any additional metadata related to the response.
115
- * @example
116
- * const genericResponse: GenericBody = {
117
- * data: {
118
- * id: 1,
119
- * name: 'Resource Name',
120
- * description: 'Resource Description'
121
- * },
122
- * meta: {
123
- * timestamp: '2024-06-01T12:00:00Z'
124
- * }
125
- * };
126
- */
127
123
  type GenericBody<R extends NonCollectible | Collectible | ResourceData = ResourceData> = ResponseData<R>;
128
- /**
129
- * @description A type that represents the pagination information for a collection of resources. It includes properties such as currentPage, from, to, perPage, total, firstPage, lastPage, prevPage, and nextPage. All properties are optional and can be undefined if not applicable.
130
- * @example
131
- * const paginationInfo: Pagination = {
132
- * currentPage: 1,
133
- * from: 1,
134
- * to: 10,
135
- * perPage: 10,
136
- * total: 100,
137
- * firstPage: 1,
138
- * lastPage: 10,
139
- * prevPage: null,
140
- * nextPage: 2
141
- * };
142
- */
143
- interface Pagination {
144
- currentPage?: number | undefined;
145
- from?: number | undefined;
146
- to?: number | undefined;
147
- perPage?: number | undefined;
148
- total?: number | undefined;
149
- firstPage?: number | undefined;
150
- lastPage?: number | undefined;
151
- prevPage?: number | undefined;
152
- nextPage?: number | undefined;
153
- }
154
- /**
155
- * @description A type that represents the cursor information for pagination. It includes properties such as before and after, which are optional and can be undefined if not applicable. The before property represents the cursor for the previous page, while the after property represents the cursor for the next page.
156
- * @example
157
- * const cursorInfo: Cursor = {
158
- * previous: 'cursor-for-previous-page',
159
- * next: 'cursor-for-next-page'
160
- * };
161
- */
162
- interface Cursor {
163
- previous?: string | undefined;
164
- next?: string | undefined;
165
- }
124
+ //#endregion
125
+ //#region src/types/config.d.ts
166
126
  interface Config {
167
- /**
168
- * @description The directory where resource files are stored. This is the location where the generated resource files will be saved. It should be a valid path on the file system relative to the project root.
169
- */
170
127
  resourcesDir: string;
171
- /**
172
- * @description The directory where stub files are stored. Stub files are templates used for generating resource files. This should also be a valid path on the file system relative to the project root where the stub templates are located.
173
- */
174
128
  stubsDir: string;
175
- /**
176
- * @description An object that defines the stub file names for different types of resources.
177
- */
178
129
  stubs: {
179
- /**
180
- * @description The stub file name for the configuration file. This stub will be used when generating the default configuration file.
181
- */
182
130
  config: string;
183
- /**
184
- * @description The stub file name for a resource. This stub will be used when generating a resource file.
185
- */
186
131
  resource: string;
187
- /**
188
- * @description The stub file name for a collection resource. This stub will be used when generating a collection resource file.
189
- */
190
132
  collection: string;
191
133
  };
192
- /**
193
- * @description This option allows you to specify the case style that should be used for the keys in API responses returned by the resources.
194
- */
195
- preferredCase: 'camel' | 'snake' | 'pascal' | 'kebab';
196
- /**
197
- * @description This option allows you to specify the extra properties that should be included in the response body when a resource is paginated. You can choose to include either 'meta', 'links', or both, or you can provide custom property names for these extras.
198
- */
199
- paginatedExtras: ['meta', 'links'] | {
134
+ preferredCase: CaseStyle;
135
+ paginatedExtras: ('meta' | 'links' | 'cursor')[] | {
200
136
  meta?: string | undefined;
201
137
  links?: string | undefined;
138
+ cursor?: string | undefined;
202
139
  };
203
- /**
204
- * @description This option allows you to specify the property names that should be used for pagination links in the response body when a resource is paginated. You can provide custom property names for the pagination links, and if not specified, the default property names will be used.
205
- */
140
+ baseUrl: string;
141
+ pageName: string;
206
142
  paginatedLinks: {
207
143
  first?: string | undefined;
208
144
  last?: string | undefined;
209
145
  prev?: string | undefined;
210
146
  next?: string | undefined;
211
147
  };
212
- /**
213
- * @description This option allows you to specify the property names that should be used for pagination metadata in the response body when a resource is paginated. You can provide custom property names for properties, and if not specified, the default property names will be used.
214
- */
215
148
  paginatedMeta: {
216
149
  to?: string | undefined;
217
150
  from?: string | undefined;
@@ -222,6 +155,12 @@ interface Config {
222
155
  last_page?: string | undefined;
223
156
  current_page?: string | undefined;
224
157
  };
158
+ cursorMeta: {
159
+ previous?: string | undefined;
160
+ next?: string | undefined;
161
+ };
162
+ responseStructure: ResponseStructureConfig;
163
+ extraCommands?: typeof Command<any>[];
225
164
  }
226
165
  //#endregion
227
166
  //#region src/cli/CliApp.d.ts
@@ -230,6 +169,11 @@ declare class CliApp {
230
169
  protected config: Config;
231
170
  constructor(config?: Partial<Config>);
232
171
  loadConfig(config?: Partial<Config>): Promise<this>;
172
+ /**
173
+ * Get the current configuration object
174
+ * @returns
175
+ */
176
+ getConfig(): Config;
233
177
  /**
234
178
  * Initialize Resora by creating a default config file in the current directory
235
179
  *
@@ -264,6 +208,13 @@ declare class CliApp {
264
208
  };
265
209
  }
266
210
  //#endregion
211
+ //#region src/cli/commands/InitCommand.d.ts
212
+ declare class InitCommand extends Command<CliApp> {
213
+ protected signature: string;
214
+ protected description: string;
215
+ handle(): Promise<void>;
216
+ }
217
+ //#endregion
267
218
  //#region src/cli/commands/MakeResource.d.ts
268
219
  declare class MakeResource extends Command<CliApp> {
269
220
  protected signature: string;
@@ -272,7 +223,7 @@ declare class MakeResource extends Command<CliApp> {
272
223
  }
273
224
  //#endregion
274
225
  //#region src/ServerResponse.d.ts
275
- declare class ServerResponse<R extends NonCollectible | Collectible | ResourceData[] | ResourceData = ResourceData> {
226
+ declare class ServerResponse<R extends NonCollectible | Collectible | ResourceData[] | ResourceData = any> {
276
227
  #private;
277
228
  private response;
278
229
  private body;
@@ -354,9 +305,23 @@ declare class ServerResponse<R extends NonCollectible | Collectible | ResourceDa
354
305
  declare class ResourceCollection<R extends ResourceData[] | Collectible = ResourceData[], T extends ResourceData = any> {
355
306
  private res?;
356
307
  [key: string]: any;
357
- body: CollectionBody<R>;
308
+ private body;
358
309
  resource: R;
359
310
  collects?: typeof Resource<T>;
311
+ private additionalMeta?;
312
+ protected withResponseContext?: {
313
+ response: ServerResponse<CollectionBody<R>>;
314
+ raw: Response | H3Event['res'];
315
+ };
316
+ /**
317
+ * Preferred case style for this collection's output keys.
318
+ * Set on a subclass to override the global default.
319
+ */
320
+ static preferredCase?: CaseStyle;
321
+ /**
322
+ * Response structure override for this collection class.
323
+ */
324
+ static responseStructure?: ResponseStructureConfig;
360
325
  private called;
361
326
  constructor(rsc: R);
362
327
  constructor(rsc: R, res: Response);
@@ -364,12 +329,48 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible = Resour
364
329
  * Get the original resource data
365
330
  */
366
331
  data(): (R extends Collectible ? R["data"][number] : R extends ResourceData[] ? R[number] : never)[];
332
+ /**
333
+ * Get the current serialized output body.
334
+ */
335
+ getBody(): CollectionBody<R>;
336
+ /**
337
+ * Replace the current serialized output body.
338
+ */
339
+ protected setBody(body: CollectionBody<R>): this;
340
+ /**
341
+ * Conditionally include a value in serialized output.
342
+ */
343
+ when<T>(condition: any, value: T | (() => T)): T | undefined;
344
+ /**
345
+ * Include a value only when it is not null/undefined.
346
+ */
347
+ whenNotNull<T>(value: T | null | undefined): T | undefined;
348
+ /**
349
+ * Conditionally merge object attributes into serialized output.
350
+ */
351
+ mergeWhen<T extends Record<string, any>>(condition: any, value: T | (() => T)): Partial<T>;
352
+ private resolveResponseStructure;
353
+ private getPayloadKey;
367
354
  /**
368
355
  * Convert resource to JSON response format
369
356
  *
370
357
  * @returns
371
358
  */
372
359
  json(): this;
360
+ /**
361
+ * Append structured metadata to the response body.
362
+ *
363
+ * @param meta Metadata object or metadata factory
364
+ * @returns
365
+ */
366
+ with(meta?: any): any;
367
+ /**
368
+ * Typed fluent metadata helper.
369
+ *
370
+ * @param meta Metadata object or metadata factory
371
+ * @returns
372
+ */
373
+ withMeta<M extends MetaData>(meta: M | ((resource: R) => M)): this;
373
374
  /**
374
375
  * Flatten resource to return original data
375
376
  *
@@ -385,6 +386,12 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible = Resour
385
386
  additional<X extends Record<string, any>>(extra: X): this;
386
387
  response(): ServerResponse<CollectionBody<R>>;
387
388
  response(res: H3Event['res']): ServerResponse<CollectionBody<R>>;
389
+ /**
390
+ * Customize the outgoing transport response right before dispatch.
391
+ *
392
+ * Override in custom classes to mutate headers/status/body.
393
+ */
394
+ withResponse(_response?: ServerResponse<CollectionBody<R>>, _rawResponse?: Response | H3Event['res']): any;
388
395
  setCollects(collects: typeof Resource<T>): this;
389
396
  /**
390
397
  * Promise-like then method to allow chaining with async/await or .then() syntax
@@ -417,8 +424,22 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible = Resour
417
424
  declare class Resource<R extends ResourceData | NonCollectible = ResourceData> {
418
425
  private res?;
419
426
  [key: string]: any;
420
- body: ResourceBody<R>;
427
+ private body;
421
428
  resource: R;
429
+ private additionalMeta?;
430
+ protected withResponseContext?: {
431
+ response: ServerResponse<ResourceBody<R>>;
432
+ raw: Response | H3Event['res'];
433
+ };
434
+ /**
435
+ * Preferred case style for this resource's output keys.
436
+ * Set on a subclass to override the global default.
437
+ */
438
+ static preferredCase?: CaseStyle;
439
+ /**
440
+ * Response structure override for this resource class.
441
+ */
442
+ static responseStructure?: ResponseStructureConfig;
422
443
  private called;
423
444
  constructor(rsc: R, res?: Response | undefined);
424
445
  /**
@@ -432,12 +453,48 @@ declare class Resource<R extends ResourceData | NonCollectible = ResourceData> {
432
453
  * Get the original resource data
433
454
  */
434
455
  data(): R extends NonCollectible ? R["data"] : R;
456
+ /**
457
+ * Get the current serialized output body.
458
+ */
459
+ getBody(): ResourceBody<R>;
460
+ /**
461
+ * Replace the current serialized output body.
462
+ */
463
+ protected setBody(body: ResourceBody<R>): this;
464
+ /**
465
+ * Conditionally include a value in serialized output.
466
+ */
467
+ when<T>(condition: any, value: T | (() => T)): T | undefined;
468
+ /**
469
+ * Include a value only when it is not null/undefined.
470
+ */
471
+ whenNotNull<T>(value: T | null | undefined): T | undefined;
472
+ /**
473
+ * Conditionally merge object attributes into serialized output.
474
+ */
475
+ mergeWhen<T extends Record<string, any>>(condition: any, value: T | (() => T)): Partial<T>;
476
+ private resolveResponseStructure;
477
+ private getPayloadKey;
435
478
  /**
436
479
  * Convert resource to JSON response format
437
480
  *
438
481
  * @returns
439
482
  */
440
483
  json(): this;
484
+ /**
485
+ * Append structured metadata to the response body.
486
+ *
487
+ * @param meta Metadata object or metadata factory
488
+ * @returns
489
+ */
490
+ with(meta?: any): any;
491
+ /**
492
+ * Typed fluent metadata helper.
493
+ *
494
+ * @param meta Metadata object or metadata factory
495
+ * @returns
496
+ */
497
+ withMeta<M extends MetaData>(meta: M | ((resource: R) => M)): this;
441
498
  /**
442
499
  * Flatten resource to array format (for collections) or return original data for single resources
443
500
  *
@@ -453,6 +510,12 @@ declare class Resource<R extends ResourceData | NonCollectible = ResourceData> {
453
510
  additional<X extends Record<string, any>>(extra: X): this;
454
511
  response(): ServerResponse<ResourceBody<R>>;
455
512
  response(res: H3Event['res']): ServerResponse<ResourceBody<R>>;
513
+ /**
514
+ * Customize the outgoing transport response right before dispatch.
515
+ *
516
+ * Override in custom classes to mutate headers/status/body.
517
+ */
518
+ withResponse(_response?: ServerResponse<ResourceBody<R>>, _rawResponse?: Response | H3Event['res']): any;
456
519
  /**
457
520
  * Promise-like then method to allow chaining with async/await or .then() syntax
458
521
  *
@@ -484,21 +547,71 @@ declare class Resource<R extends ResourceData | NonCollectible = ResourceData> {
484
547
  declare class GenericResource<R extends NonCollectible | Collectible | ResourceData = ResourceData, T extends ResourceData = any> {
485
548
  private res?;
486
549
  [key: string]: any;
487
- body: GenericBody<R>;
550
+ private body;
488
551
  resource: R;
489
552
  collects?: typeof Resource<T>;
553
+ private additionalMeta?;
554
+ protected withResponseContext?: {
555
+ response: ServerResponse<GenericBody<R>>;
556
+ raw: Response | H3Event['res'];
557
+ };
558
+ /**
559
+ * Preferred case style for this resource's output keys.
560
+ * Set on a subclass to override the global default.
561
+ */
562
+ static preferredCase?: CaseStyle;
563
+ /**
564
+ * Response structure override for this generic resource class.
565
+ */
566
+ static responseStructure?: ResponseStructureConfig;
490
567
  private called;
491
568
  constructor(rsc: R, res?: Response | undefined);
492
569
  /**
493
570
  * Get the original resource data
494
571
  */
495
572
  data(): R;
573
+ /**
574
+ * Get the current serialized output body.
575
+ */
576
+ getBody(): GenericBody<R>;
577
+ /**
578
+ * Replace the current serialized output body.
579
+ */
580
+ protected setBody(body: GenericBody<R>): this;
581
+ /**
582
+ * Conditionally include a value in serialized output.
583
+ */
584
+ when<T>(condition: any, value: T | (() => T)): T | undefined;
585
+ /**
586
+ * Include a value only when it is not null/undefined.
587
+ */
588
+ whenNotNull<T>(value: T | null | undefined): T | undefined;
589
+ /**
590
+ * Conditionally merge object attributes into serialized output.
591
+ */
592
+ mergeWhen<T extends Record<string, any>>(condition: any, value: T | (() => T)): Partial<T>;
593
+ private resolveResponseStructure;
594
+ private getPayloadKey;
496
595
  /**
497
596
  * Convert resource to JSON response format
498
597
  *
499
598
  * @returns
500
599
  */
501
600
  json(): this;
601
+ /**
602
+ * Append structured metadata to the response body.
603
+ *
604
+ * @param meta Metadata object or metadata factory
605
+ * @returns
606
+ */
607
+ with(meta?: any): any;
608
+ /**
609
+ * Typed fluent metadata helper.
610
+ *
611
+ * @param meta Metadata object or metadata factory
612
+ * @returns
613
+ */
614
+ withMeta<M extends MetaData>(meta: M | ((resource: R) => M)): this;
502
615
  /**
503
616
  * Convert resource to array format (for collections)
504
617
  *
@@ -514,6 +627,12 @@ declare class GenericResource<R extends NonCollectible | Collectible | ResourceD
514
627
  additional<X extends Record<string, any>>(extra: X): this;
515
628
  response(): ServerResponse<GenericBody<R>>;
516
629
  response(res: H3Event['res']): ServerResponse<GenericBody<R>>;
630
+ /**
631
+ * Customize the outgoing transport response right before dispatch.
632
+ *
633
+ * Override in custom classes to mutate headers/status/body.
634
+ */
635
+ withResponse(_response?: ServerResponse<GenericBody<R>>, _rawResponse?: Response | H3Event['res']): any;
517
636
  /**
518
637
  * Promise-like then method to allow chaining with async/await or .then() syntax
519
638
  *
@@ -524,16 +643,85 @@ declare class GenericResource<R extends NonCollectible | Collectible | ResourceD
524
643
  then<TResult1 = GenericBody<R>, TResult2 = never>(onfulfilled?: ((value: GenericBody<R>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
525
644
  }
526
645
  //#endregion
527
- //#region src/utility.d.ts
646
+ //#region src/utilities/case.d.ts
647
+ declare const splitWords: (str: string) => string[];
648
+ declare const toCamelCase: (str: string) => string;
649
+ declare const toSnakeCase: (str: string) => string;
650
+ declare const toPascalCase: (str: string) => string;
651
+ declare const toKebabCase: (str: string) => string;
652
+ declare const getCaseTransformer: (style: CaseStyle) => ((key: string) => string);
653
+ declare const transformKeys: (obj: any, transformer: (key: string) => string) => any;
654
+ //#endregion
655
+ //#region src/utilities/conditional.d.ts
656
+ declare const CONDITIONAL_ATTRIBUTE_MISSING: unique symbol;
657
+ declare const resolveWhen: <T>(condition: any, value: T | (() => T)) => T | typeof CONDITIONAL_ATTRIBUTE_MISSING;
658
+ declare const resolveWhenNotNull: <T>(value: T | null | undefined) => T | typeof CONDITIONAL_ATTRIBUTE_MISSING;
659
+ declare const resolveMergeWhen: <T extends Record<string, any>>(condition: any, value: T | (() => T)) => Partial<T>;
660
+ declare const sanitizeConditionalAttributes: (value: any) => any;
661
+ //#endregion
662
+ //#region src/utilities/config.d.ts
528
663
  declare const getDefaultConfig: () => Config;
529
- /**
530
- * Define the configuration for the package
531
- *
532
- * @param userConfig The user configuration to override the default configuration
533
- * @returns The merged configuration object
534
- */
535
664
  declare const defineConfig: (userConfig?: Partial<Omit<Config, "stubs">> & {
536
665
  stubs?: Partial<Config["stubs"]>;
537
666
  }) => Config;
538
667
  //#endregion
539
- export { ApiResource, CliApp, Collectible, CollectionBody, Config, Cursor, GenericBody, GenericResource, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResponseData, ResponseDataCollection, ServerResponse, defineConfig, getDefaultConfig };
668
+ //#region src/utilities/metadata.d.ts
669
+ declare const resolveWithHookMetadata: (instance: any, baseWithMethod: (...args: any[]) => any) => MetaData | undefined;
670
+ //#endregion
671
+ //#region src/utilities/objects.d.ts
672
+ declare const isPlainObject: (value: any) => value is Record<string, any>;
673
+ declare const appendRootProperties: (body: any, extra?: Record<string, any> | undefined, rootKey?: string) => any;
674
+ declare const mergeMetadata: (base?: Record<string, any> | undefined, incoming?: Record<string, any> | undefined) => Record<string, any> | undefined;
675
+ //#endregion
676
+ //#region src/utilities/pagination.d.ts
677
+ declare const getPaginationExtraKeys: () => {
678
+ metaKey?: string;
679
+ linksKey?: string;
680
+ cursorKey?: string;
681
+ };
682
+ declare const buildPaginationExtras: (resource: any) => Record<string, any>;
683
+ //#endregion
684
+ //#region src/utilities/response.d.ts
685
+ declare const buildResponseEnvelope: ({
686
+ payload,
687
+ meta,
688
+ metaKey,
689
+ wrap,
690
+ rootKey,
691
+ factory,
692
+ context
693
+ }: {
694
+ payload: any;
695
+ meta?: Record<string, any> | undefined;
696
+ metaKey?: string;
697
+ wrap?: boolean;
698
+ rootKey?: string;
699
+ factory?: ResponseFactory | undefined;
700
+ context: Omit<ResponseFactoryContext, "rootKey" | "meta">;
701
+ }) => Record<string, any>;
702
+ //#endregion
703
+ //#region src/utilities/state.d.ts
704
+ declare const setGlobalCase: (style: CaseStyle | undefined) => void;
705
+ declare const getGlobalCase: () => CaseStyle | undefined;
706
+ declare const setGlobalResponseStructure: (config: ResponseStructureConfig | undefined) => void;
707
+ declare const getGlobalResponseStructure: () => ResponseStructureConfig | undefined;
708
+ declare const setGlobalResponseRootKey: (rootKey: string | undefined) => void;
709
+ declare const setGlobalResponseWrap: (wrap: boolean | undefined) => void;
710
+ declare const getGlobalResponseWrap: () => boolean | undefined;
711
+ declare const getGlobalResponseRootKey: () => string | undefined;
712
+ declare const setGlobalResponseFactory: (factory: ResponseFactory | undefined) => void;
713
+ declare const getGlobalResponseFactory: () => ResponseFactory | undefined;
714
+ declare const setGlobalPaginatedExtras: (extras: Config["paginatedExtras"]) => void;
715
+ declare const getGlobalPaginatedExtras: () => Config["paginatedExtras"];
716
+ declare const setGlobalPaginatedLinks: (links: Config["paginatedLinks"]) => void;
717
+ declare const getGlobalPaginatedLinks: () => Config["paginatedLinks"];
718
+ declare const setGlobalBaseUrl: (baseUrl: Config["baseUrl"]) => void;
719
+ declare const getGlobalBaseUrl: () => Config["baseUrl"];
720
+ declare const setGlobalPageName: (pageName: Config["pageName"]) => void;
721
+ declare const getGlobalPageName: () => Config["pageName"];
722
+ declare const setGlobalPaginatedMeta: (meta: Config["paginatedMeta"]) => void;
723
+ declare const getGlobalPaginatedMeta: () => Config["paginatedMeta"];
724
+ declare const setGlobalCursorMeta: (meta: Config["cursorMeta"]) => void;
725
+ declare const getGlobalCursorMeta: () => Config["cursorMeta"];
726
+ //#endregion
727
+ export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponseStructureConfig, ServerResponse, appendRootProperties, buildPaginationExtras, buildResponseEnvelope, defineConfig, getCaseTransformer, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, isPlainObject, mergeMetadata, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, sanitizeConditionalAttributes, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };