@h3ravel/shared 0.27.7 → 0.28.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,1106 +1,55 @@
1
1
  /// <reference path="./app.globals.d.ts" />
2
- import { H3, H3Event, HTTPResponse, Middleware, MiddlewareOptions, serve } from "h3";
3
- import { Edge } from "edge.js";
4
- import { DotNestedKeys as DotNestedKeys$1, DotNestedValue as DotNestedValue$1 } from "@h3ravel/shared";
5
2
  import { Separator } from "@inquirer/prompts";
6
3
  import { ChoiceOrSeparatorArray, ChoiceOrSeparatorArray as ChoiceOrSeparatorArray$1 } from "inquirer-autocomplete-standalone";
7
4
  import { ChalkInstance } from "chalk";
5
+ import { ClassConstructor, IPathName } from "@h3ravel/contracts";
8
6
 
9
- //#region src/Contracts/ObjContract.d.ts
10
- /**
11
- * Adds a dot prefix to nested keys
12
- */
13
- type DotPrefix<T extends string, U extends string> = T extends '' ? U : `${T}.${U}`;
14
- /**
15
- * Converts a union of objects into a single merged object
16
- */
17
- type MergeUnion<T> = (T extends any ? (k: T) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
18
- /**
19
- * Flattens nested objects into dotted keys
20
- */
21
- type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{ [K in keyof T & string]: T[K] extends Record<string, any> ? DotFlatten<T[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T[K] } }[keyof T & string]>;
22
- /**
23
- * Builds "nested.key" paths for autocompletion
24
- */
25
- type DotNestedKeys<T> = { [K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}` }[keyof T & string];
26
- /**
27
- * Retrieves type at a given dot-path
28
- */
29
- type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
30
- /**
31
- * A generic object type that supports nullable string values
32
- */
33
- interface GenericWithNullableStringValues {
34
- [name: string]: string | undefined;
35
- }
36
- //#endregion
37
- //#region src/Contracts/IContainer.d.ts
38
- /**
39
- * Interface for the Container contract, defining methods for dependency injection and service resolution.
40
- */
41
- interface IContainer {
42
- /**
43
- * Binds a transient service to the container.
44
- * @param key - The key or constructor for the service.
45
- * @param factory - The factory function to create the service instance.
46
- */
47
- bind<T>(key: new (...args: any[]) => T, factory: () => T): void;
48
- bind<T extends UseKey>(key: T, factory: () => Bindings[T]): void;
49
- /**
50
- * Binds a singleton service to the container.
51
- * @param key - The key or constructor for the service.
52
- * @param factory - The factory function to create the singleton instance.
53
- */
54
- singleton<T extends UseKey>(key: T | (new (...args: any[]) => Bindings[T]), factory: () => Bindings[T]): void;
55
- /**
56
- * Resolves a service from the container.
57
- * @param key - The key or constructor for the service.
58
- * @returns The resolved service instance.
59
- */
60
- make<T extends UseKey, X = undefined>(key: T | (new (..._args: any[]) => Bindings[T])): X extends undefined ? Bindings[T] : X;
61
- /**
62
- * Checks if a service is registered in the container.
63
- * @param key - The key to check.
64
- * @returns True if the service is registered, false otherwise.
65
- */
66
- has(key: UseKey): boolean;
67
- }
68
- //#endregion
69
- //#region src/Contracts/IServiceProvider.d.ts
70
- interface IServiceProvider {
71
- /**
72
- * Unique Identifier for service providers
73
- */
74
- uid?: number;
75
- /**
76
- * Sort order
77
- */
78
- order?: `before:${string}` | `after:${string}` | string | undefined;
79
- /**
80
- * Sort priority
81
- */
82
- priority?: number;
83
- /**
84
- * Indicate that this service provider only runs in console
85
- */
86
- runsInConsole?: boolean;
87
- /**
88
- * List of registered console commands
89
- */
90
- registeredCommands?: (new (app: IApplication, kernel: any) => any)[];
91
- /**
92
- * An array of console commands to register.
93
- */
94
- commands?(commands: (new (app: IApplication, kernel: any) => any)[]): void;
95
- /**
96
- * Register bindings to the container.
97
- * Runs before boot().
98
- */
99
- register?(...app: unknown[]): void | Promise<void>;
100
- /**
101
- * Perform post-registration booting of services.
102
- * Runs after all providers have been registered.
103
- */
104
- boot?(...app: unknown[]): void | Promise<void>;
105
- }
106
- //#endregion
107
- //#region src/Contracts/IApplication.d.ts
108
- type IPathName = 'views' | 'routes' | 'assets' | 'base' | 'public' | 'storage' | 'config' | 'database';
109
- interface IApplication extends IContainer {
110
- /**
111
- * Registers configured service providers.
112
- */
113
- registerConfiguredProviders(): Promise<void>;
114
- /**
115
- * Registers an array of external service provider classes.
116
- * @param providers - Array of service provider constructor functions.
117
- */
118
- registerProviders(providers: Array<(new <A = IApplication, S = IServiceProvider>(app: A) => S)>): void;
119
- /**
120
- * Registers a single service provider.
121
- * @param provider - The service provider instance to register.
122
- */
123
- /**
124
- * Boots all registered providers.
125
- */
126
- boot(): Promise<this>;
127
- /**
128
- * Gets the base path of the application.
129
- * @returns The base path as a string.
130
- */
131
- getBasePath(): string;
132
- /**
133
- * Retrieves a path by name, optionally appending a sub-path.
134
- * @param name - The name of the path property.
135
- * @param pth - Optional sub-path to append.
136
- * @returns The resolved path as a string.
137
- */
138
- getPath(name: string, pth?: string): string;
139
- /**
140
- * Sets a path for a given name.
141
- * @param name - The name of the path property.
142
- * @param path - The path to set.
143
- * @returns
144
- */
145
- setPath(name: IPathName, path: string): void;
146
- /**
147
- * Gets the version of the application or TypeScript.
148
- * @param key - The key to retrieve ('app' or 'ts').
149
- * @returns The version string or undefined.
150
- */
151
- getVersion(key: string): string | undefined;
152
- }
153
- //#endregion
154
- //#region src/Contracts/IHttpResponse.d.ts
155
- /**
156
- * Interface for the Response contract, defining methods for handling HTTP responses.
157
- */
158
- interface IHttpResponse {
159
- /**
160
- * Set HTTP status code.
161
- */
162
- setStatusCode(code: number, text?: string): this;
163
- /**
164
- * Retrieves the status code for the current web response.
165
- */
166
- getStatusCode(): number;
167
- /**
168
- * Sets the response charset.
169
- */
170
- setCharset(charset: string): this;
171
- /**
172
- * Retrieves the response charset.
173
- */
174
- getCharset(): string | undefined;
175
- /**
176
- * Returns true if the response may safely be kept in a shared (surrogate) cache.
177
- *
178
- * Responses marked "private" with an explicit Cache-Control directive are
179
- * considered uncacheable.
180
- *
181
- * Responses with neither a freshness lifetime (Expires, max-age) nor cache
182
- * validator (Last-Modified, ETag) are considered uncacheable because there is
183
- * no way to tell when or how to remove them from the cache.
184
- *
185
- * Note that RFC 7231 and RFC 7234 possibly allow for a more permissive implementation,
186
- * for example "status codes that are defined as cacheable by default [...]
187
- * can be reused by a cache with heuristic expiration unless otherwise indicated"
188
- * (https://tools.ietf.org/html/rfc7231#section-6.1)
189
- *
190
- * @final
191
- */
192
- isCacheable(): boolean;
193
- /**
194
- * Returns true if the response is "fresh".
195
- *
196
- * Fresh responses may be served from cache without any interaction with the
197
- * origin. A response is considered fresh when it includes a Cache-Control/max-age
198
- * indicator or Expires header and the calculated age is less than the freshness lifetime.
199
- */
200
- isFresh(): boolean;
201
- /**
202
- * Returns true if the response includes headers that can be used to validate
203
- * the response with the origin server using a conditional GET request.
204
- */
205
- isValidateable(): boolean;
206
- /**
207
- * Sets the response content.
208
- */
209
- setContent(content?: any): this;
210
- /**
211
- * Gets the current response content.
212
- */
213
- getContent(): any;
214
- /**
215
- * Set a header.
216
- */
217
- setHeader(name: string, value: string): this;
218
- /**
219
- * Sets the HTTP protocol version (1.0 or 1.1).
220
- */
221
- setProtocolVersion(version: string): this;
222
- /**
223
- * Gets the HTTP protocol version.
224
- */
225
- getProtocolVersion(): string;
226
- /**
227
- * Marks the response as "private".
228
- *
229
- * It makes the response ineligible for serving other clients.
230
- */
231
- setPrivate(): this;
232
- /**
233
- * Marks the response as "public".
234
- *
235
- * It makes the response eligible for serving other clients.
236
- */
237
- setPublic(): this;
238
- /**
239
- * Returns the Date header as a DateTime instance.
240
- * @throws {RuntimeException} When the header is not parseable
241
- */
242
- getDate(): any;
243
- /**
244
- * Returns the age of the response in seconds.
245
- *
246
- * @final
247
- */
248
- getAge(): number;
249
- /**
250
- * Marks the response stale by setting the Age header to be equal to the maximum age of the response.
251
- */
252
- expire(): this;
253
- /**
254
- * Returns the value of the Expires header as a DateTime instance.
255
- *
256
- * @final
257
- */
258
- getExpires(): any;
259
- /**
260
- * Returns the number of seconds after the time specified in the response's Date
261
- * header when the response should no longer be considered fresh.
262
- *
263
- * First, it checks for a s-maxage directive, then a max-age directive, and then it falls
264
- * back on an expires header. It returns null when no maximum age can be established.
265
- */
266
- getMaxAge(): number | undefined;
267
- /**
268
- * Sets the number of seconds after which the response should no longer be considered fresh.
269
- *
270
- * This method sets the Cache-Control max-age directive.
271
- */
272
- setMaxAge(value: number): this;
273
- /**
274
- * Sets the number of seconds after which the response should no longer be returned by shared caches when backend is down.
275
- *
276
- * This method sets the Cache-Control stale-if-error directive.
277
- */
278
- setStaleIfError(value: number): this;
279
- /**
280
- * Sets the number of seconds after which the response should no longer return stale content by shared caches.
281
- *
282
- * This method sets the Cache-Control stale-while-revalidate directive.
283
- */
284
- setStaleWhileRevalidate(value: number): this;
285
- /**
286
- * Returns the response's time-to-live in seconds.
287
- *
288
- * It returns null when no freshness information is present in the response.
289
- *
290
- * When the response's TTL is 0, the response may not be served from cache without first
291
- * revalidating with the origin.
292
- *
293
- * @final
294
- */
295
- getTtl(): number | undefined;
296
- /**
297
- * Sets the response's time-to-live for shared caches in seconds.
298
- *
299
- * This method adjusts the Cache-Control/s-maxage directive.
300
- */
301
- setTtl(seconds: number): this;
302
- /**
303
- * Sets the response's time-to-live for private/client caches in seconds.
304
- *
305
- * This method adjusts the Cache-Control/max-age directive.
306
- */
307
- setClientTtl(seconds: number): this;
308
- /**
309
- * Sets the number of seconds after which the response should no longer be considered fresh by shared caches.
310
- *
311
- * This method sets the Cache-Control s-maxage directive.
312
- */
313
- setSharedMaxAge(value: number): this;
314
- /**
315
- * Returns the Last-Modified HTTP header as a DateTime instance.
316
- *
317
- * @throws \RuntimeException When the HTTP header is not parseable
318
- *
319
- * @final
320
- */
321
- getLastModified(): any;
322
- /**
323
- * Sets the Last-Modified HTTP header with a DateTime instance.
324
- *
325
- * Passing null as value will remove the header.
326
- *
327
- * @return $this
328
- *
329
- * @final
330
- */
331
- setLastModified(date?: any): this;
332
- /**
333
- * Returns the literal value of the ETag HTTP header.
334
- */
335
- getEtag(): string | null;
336
- /**
337
- * Sets the ETag value.
338
- *
339
- * @param etag The ETag unique identifier or null to remove the header
340
- * @param weak Whether you want a weak ETag or not
341
- */
342
- setEtag(etag?: string, weak?: boolean): this;
343
- /**
344
- * Sets the response's cache headers (validation and/or expiration).
345
- *
346
- * Available options are: must_revalidate, no_cache, no_store, no_transform, public, private, proxy_revalidate, max_age, s_maxage, immutable, last_modified and etag.
347
- *
348
- * @throws {InvalidArgumentException}
349
- */
350
- setCache(options: any): this;
351
- /**
352
- * Modifies the response so that it conforms to the rules defined for a 304 status code.
353
- *
354
- * This sets the status, removes the body, and discards any headers
355
- * that MUST NOT be included in 304 responses.
356
- * @see https://tools.ietf.org/html/rfc2616#section-10.3.5
357
- */
358
- setNotModified(): this;
359
- /**
360
- * Add an array of headers to the response.
361
- *
362
- */
363
- withHeaders(headers: any): this;
364
- /**
365
- * Set the exception to attach to the response.
366
- */
367
- withException(e: Error): this;
368
- /**
369
- * Throws the response in a HttpResponseException instance.
370
- *
371
- * @throws {HttpResponseException}
372
- */
373
- throwResponse(): void;
374
- /**
375
- * Is response invalid?
376
- *
377
- * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
378
- */
379
- isInvalid(): boolean;
380
- /**
381
- * Is response informative?
382
- */
383
- isInformational(): boolean;
384
- /**
385
- * Is response successful?
386
- */
387
- isSuccessful(): boolean;
388
- /**
389
- * Is the response a redirect?
390
- */
391
- isRedirection(): boolean;
392
- /**
393
- * Is there a client error?
394
- */
395
- isClientError(): boolean;
396
- /**
397
- * Was there a server side error?
398
- */
399
- isServerError(): boolean;
400
- /**
401
- * Is the response OK?
402
- */
403
- isOk(): boolean;
404
- /**
405
- * Is the response forbidden?
406
- */
407
- isForbidden(): boolean;
408
- /**
409
- * Is the response a not found error?
410
- */
411
- isNotFound(): boolean;
412
- /**
413
- * Is the response a redirect of some form?
414
- */
415
- isRedirect(location?: string | null): boolean;
416
- /**
417
- * Is the response empty?
418
- */
419
- isEmpty(): boolean;
420
- /**
421
- * Apply headers before sending response.
422
- */
423
- sendHeaders(statusCode?: number): this;
424
- /**
425
- * Prepares the Response before it is sent to the client.
426
- *
427
- * This method tweaks the Response to ensure that it is
428
- * compliant with RFC 2616. Most of the changes are based on
429
- * the Request that is "associated" with this Response.
430
- **/
431
- prepare(request: IRequest): this;
432
- }
433
- //#endregion
434
- //#region src/Contracts/IResponse.d.ts
435
- /**
436
- * Interface for the Response contract, defining methods for handling HTTP responses.
437
- */
438
- interface IResponse extends IHttpResponse {
439
- /**
440
- * The current app instance
441
- */
442
- app: IApplication;
443
- /**
444
- * Sends content for the current web response.
445
- */
446
- sendContent(type?: 'html' | 'json' | 'text' | 'xml', parse?: boolean): unknown;
447
- /**
448
- * Sends content for the current web response.
449
- */
450
- send(type?: 'html' | 'json' | 'text' | 'xml'): unknown;
451
- /**
452
- *
453
- * @param content The content to serve
454
- * @param send if set to true, the content will be returned, instead of the Response instance
455
- * @returns
456
- */
457
- html(content?: string): this;
458
- html(content: string, parse: boolean): HTTPResponse;
459
- /**
460
- * Send a JSON response.
461
- */
462
- json<T = unknown>(data?: T): this;
463
- json<T = unknown>(data: T, parse: boolean): T;
464
- /**
465
- * Send plain text.
466
- */
467
- text(content?: string): this;
468
- text(content: string, parse: boolean): HTTPResponse;
469
- /**
470
- * Send plain xml.
471
- */
472
- xml(data?: string): this;
473
- xml(data: string, parse: boolean): HTTPResponse;
474
- /**
475
- * Redirect to another URL.
476
- */
477
- redirect(location: string, status?: number, statusText?: string | undefined): HTTPResponse;
478
- /**
479
- * Dump the response.
480
- */
481
- dump(): this;
482
- /**
483
- * Get the base event
484
- */
485
- getEvent(): H3Event;
486
- getEvent<K$1 extends DotNestedKeys$1<H3Event>>(key: K$1): DotNestedValue$1<H3Event, K$1>;
487
- }
488
- //#endregion
489
- //#region src/Contracts/IHttp.d.ts
490
- type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'patch' | 'apiResource' | 'group' | 'route';
491
- type RequestMethod = 'HEAD' | 'GET' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'PURGE' | 'POST' | 'CONNECT' | 'PATCH';
492
- type RequestObject = Record<string, any>;
493
- type ResponseObject = Record<string, any>;
494
- type ExtractControllerMethods<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
495
- /**
496
- * Interface for the Router contract, defining methods for HTTP routing.
497
- */
498
- declare class IRouter {
499
- /**
500
- * Registers a GET route.
501
- * @param path - The route path.
502
- * @param definition - The handler function or [controller class, method] array.
503
- * @param name - Optional route name.
504
- * @param middleware - Optional middleware array.
505
- */
506
- get<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
507
- /**
508
- * Registers a POST route.
509
- * @param path - The route path.
510
- * @param definition - The handler function or [controller class, method] array.
511
- * @param name - Optional route name.
512
- * @param middleware - Optional middleware array.
513
- */
514
- post<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
515
- /**
516
- * Registers a PUT route.
517
- * @param path - The route path.
518
- * @param definition - The handler function or [controller class, method] array.
519
- * @param name - Optional route name.
520
- * @param middleware - Optional middleware array.
521
- */
522
- put<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
523
- /**
524
- * Registers a route that responds to HTTP PATCH requests.
525
- *
526
- * @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
527
- * @param definition Either:
528
- * - An EventHandler function
529
- * - A tuple: [ControllerClass, methodName]
530
- * @param name Optional route name (for URL generation or referencing).
531
- * @param middleware Optional array of middleware functions to execute before the handler.
532
- */
533
- patch<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
534
- /**
535
- * Registers a DELETE route.
536
- * @param path - The route path.
537
- * @param definition - The handler function or [controller class, method] array.
538
- * @param name - Optional route name.
539
- * @param middleware - Optional middleware array.
540
- */
541
- delete<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
542
- /**
543
- * Registers an API resource with standard CRUD routes.
544
- * @param path - The base path for the resource.
545
- * @param controller - The controller class handling the resource.
546
- * @param middleware - Optional middleware array.
547
- */
548
- apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): Omit<this, RouterEnd | 'name'>;
549
- /**
550
- * Generates a URL for a named route.
551
- * @param name - The name of the route.
552
- * @param params - Optional parameters to replace in the route path.
553
- * @returns The generated URL or undefined if the route is not found.
554
- */
555
- route(name: string, params?: Record<string, string>): string | undefined;
556
- /**
557
- * Set the name of the current route
558
- *
559
- * @param name
560
- */
561
- name(name: string): this;
562
- /**
563
- * Groups routes with shared prefix or middleware.
564
- * @param options - Configuration for prefix or middleware.
565
- * @param callback - Callback function defining grouped routes.
566
- */
567
- group(options: {
568
- prefix?: string;
569
- middleware?: EventHandler[];
570
- }, callback: () => this): this;
571
- /**
572
- * Registers middleware for a specific path.
573
- * @param path - The path to apply the middleware.
574
- * @param handler - The middleware handler.
575
- * @param opts - Optional middleware options.
576
- */
577
- middleware(path: Middleware, opts?: Middleware | MiddlewareOptions): this;
578
- middleware(path: string | IMiddleware[] | Middleware, handler: Middleware | MiddlewareOptions, opts?: MiddlewareOptions): this;
579
- }
7
+ //#region src/Container.d.ts
8
+ declare const INTERNAL_METHODS: unique symbol;
580
9
  /**
581
- * Represents the HTTP context for a single request lifecycle.
582
- * Encapsulates the application instance, request, and response objects.
583
- */
584
- declare class HttpContext {
585
- app: IApplication;
586
- request: IRequest;
587
- response: IResponse;
588
- private static contexts;
589
- constructor(app: IApplication, request: IRequest, response: IResponse);
590
- /**
591
- * Factory method to create a new HttpContext instance from a context object.
592
- * @param ctx - Object containing app, request, and response
593
- * @returns A new HttpContext instance
594
- */
595
- static init(ctx: {
596
- app: IApplication;
597
- request: IRequest;
598
- response: IResponse;
599
- }, event?: unknown): HttpContext;
600
- /**
601
- * Retrieve an existing HttpContext instance for an event, if any.
602
- */
603
- static get(event: unknown): HttpContext | undefined;
604
- /**
605
- * Delete the cached context for a given event (optional cleanup).
606
- */
607
- static forget(event: unknown): void;
608
- }
609
- /**
610
- * Type for EventHandler, representing a function that handles an H3 event.
611
- */
612
- type EventHandler = (ctx: HttpContext) => any;
613
- type RouteEventHandler = (...args: any[]) => any;
614
- /**
615
- * Defines the contract for all controllers.
616
- * Any controller implementing this must define these methods.
10
+ * Decorator to mark class properties as internal
11
+ *
12
+ * @param target
13
+ * @param propertyKey
617
14
  */
618
- declare class IController {
619
- show?(...ctx: any[]): any;
620
- index?(...ctx: any[]): any;
621
- store?(...ctx: any[]): any;
622
- update?(...ctx: any[]): any;
623
- destroy?(...ctx: any[]): any;
624
- }
15
+ declare const internal: (target: any, propertyKey: string) => void;
625
16
  /**
626
- * Defines the contract for all middlewares.
627
- * Any middleware implementing this must define these methods.
628
- */
629
- declare class IMiddleware {
630
- handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
631
- }
632
- //#endregion
633
- //#region src/Contracts/IParamBag.d.ts
634
- declare class IParamBag implements Iterable<[string, any]> {
635
- /**
636
- * The current H3 H3Event instance
637
- */
638
- readonly event: H3Event;
639
- constructor(parameters: RequestObject | undefined,
640
- /**
641
- * The current H3 H3Event instance
642
- */
643
- event: H3Event);
644
- /**
645
- * Returns the parameters.
646
- * @
647
- * @param key The name of the parameter to return or null to get them all
648
- *
649
- * @throws BadRequestException if the value is not an array
650
- */
651
- all(key?: string): any;
652
- get(key: string, defaultValue?: any): any;
653
- set(key: string, value: any): void;
654
- /**
655
- * Returns true if the parameter is defined.
656
- *
657
- * @param key
658
- */
659
- has(key: string): boolean;
660
- /**
661
- * Removes a parameter.
662
- *
663
- * @param key
664
- */
665
- remove(key: string): void;
666
- /**
667
- *
668
- * Returns the parameter as string.
669
- *
670
- * @param key
671
- * @param defaultValue
672
- * @throws UnexpectedValueException if the value cannot be converted to string
673
- * @returns
674
- */
675
- getString(key: string, defaultValue?: string): string;
676
- /**
677
- * Returns the parameter value converted to integer.
678
- *
679
- * @param key
680
- * @param defaultValue
681
- * @throws UnexpectedValueException if the value cannot be converted to integer
682
- */
683
- getInt(key: string, defaultValue?: number): number;
684
- /**
685
- * Returns the parameter value converted to boolean.
686
- *
687
- * @param key
688
- * @param defaultValue
689
- * @throws UnexpectedValueException if the value cannot be converted to a boolean
690
- */
691
- getBoolean(key: string, defaultValue?: boolean): boolean;
692
- /**
693
- * Returns the alphabetic characters of the parameter value.
694
- *
695
- * @param key
696
- * @param defaultValue
697
- * @throws UnexpectedValueException if the value cannot be converted to string
698
- */
699
- getAlpha(key: string, defaultValue?: string): string;
700
- /**
701
- * Returns the alphabetic characters and digits of the parameter value.
702
- *
703
- * @param key
704
- * @param defaultValue
705
- * @throws UnexpectedValueException if the value cannot be converted to string
706
- */
707
- getAlnum(key: string, defaultValue?: string): string;
708
- /**
709
- * Returns the digits of the parameter value.
710
- *
711
- * @param key
712
- * @param defaultValue
713
- * @throws UnexpectedValueException if the value cannot be converted to string
714
- * @returns
715
- **/
716
- getDigits(key: string, defaultValue?: string): string;
717
- /**
718
- * Returns the parameter keys.
719
- */
720
- keys(): string[];
721
- /**
722
- * Replaces the current parameters by a new set.
723
- */
724
- replace(parameters?: RequestObject): void;
725
- /**
726
- * Adds parameters.
727
- */
728
- add(parameters?: RequestObject): void;
729
- /**
730
- * Returns the number of parameters.
731
- */
732
- count(): number;
733
- /**
734
- * Returns an iterator for parameters.
735
- *
736
- * @returns
737
- */
738
- [Symbol.iterator](): ArrayIterator<[string, any]>;
739
- }
740
- //#endregion
741
- //#region src/Contracts/IUploadedFile.d.ts
742
- declare class IUploadedFile {
743
- originalName: string;
744
- mimeType: string;
745
- size: number;
746
- content: File;
747
- constructor(originalName: string, mimeType: string, size: number, content: File);
748
- static createFromBase(file: File): IUploadedFile;
749
- /**
750
- * Save to disk (Node environment only)
751
- */
752
- moveTo(destination: string): Promise<void>;
753
- }
17
+ * Checks if a property is decorated with the &#64;internal decorator
18
+ *
19
+ * @param instance
20
+ * @param prop
21
+ * @returns
22
+ */
23
+ declare const isInternal: (instance: any, prop: string) => boolean;
754
24
  //#endregion
755
- //#region src/Contracts/IRequest.d.ts
756
- type RequestObject$1 = Record<string, any>;
25
+ //#region src/Contracts/ObjContract.d.ts
757
26
  /**
758
- * Interface for the Request contract, defining methods for handling HTTP request data.
27
+ * Adds a dot prefix to nested keys
759
28
  */
760
- declare class IRequest {
761
- /**
762
- * The current app instance
763
- */
764
- app: IApplication;
765
- /**
766
- * Parsed request body
767
- */
768
- body: unknown;
769
- /**
770
- * Gets route parameters.
771
- * @returns An object containing route parameters.
772
- */
773
- params: NonNullable<H3Event['context']['params']>;
774
- /**
775
- * Uploaded files (FILES).
776
- */
777
- constructor(
778
- /**
779
- * The current H3 H3Event instance
780
- */
781
- event: H3Event,
782
- /**
783
- * The current app instance
784
- */
785
- app: IApplication);
786
- /**
787
- * Factory method to create a Request instance from an H3Event.
788
- */
789
- static create(
790
- /**
791
- * The current H3 H3Event instance
792
- */
793
- event: H3Event,
794
- /**
795
- * The current app instance
796
- */
797
- app: IApplication): Promise<Request>;
798
- /**
799
- * Sets the parameters for this request.
800
- *
801
- * This method also re-initializes all properties.
802
- *
803
- * @param attributes
804
- * @param cookies The COOKIE parameters
805
- * @param files The FILES parameters
806
- * @param server The SERVER parameters
807
- * @param content The raw body data
808
- */
809
- initialize(): Promise<void>;
810
- /**
811
- * Retrieve all data from the instance (query + body).
812
- */
813
- all<T = Record<string, any>>(keys?: string | string[]): T;
814
- /**
815
- * Retrieve an input item from the request.
816
- *
817
- * @param key
818
- * @param defaultValue
819
- * @returns
820
- */
821
- input<K$1 extends string | undefined>(key?: K$1, defaultValue?: any): K$1 extends undefined ? RequestObject$1 : any;
822
- /**
823
- * Retrieve a file from the request.
824
- *
825
- * By default a single `UploadedFile` instance will always be returned by
826
- * the method (first file in property when there are multiple), unless
827
- * the `expectArray` parameter is set to true, in which case, the method
828
- * returns an `UploadedFile[]` array.
829
- *
830
- * @param key
831
- * @param defaultValue
832
- * @param expectArray set to true to return an `UploadedFile[]` array.
833
- * @returns
834
- */
835
- file<K$1 extends string | undefined = undefined, E extends boolean | undefined = undefined>(key?: K$1, defaultValue?: any, expectArray?: E): K$1 extends undefined ? Record<string, E extends true ? IUploadedFile[] : IUploadedFile> : E extends true ? IUploadedFile[] : IUploadedFile;
836
- /**
837
- * Determine if the uploaded data contains a file.
838
- *
839
- * @param key
840
- * @return boolean
841
- */
842
- hasFile(key: string): boolean;
843
- /**
844
- * Get an object with all the files on the request.
845
- */
846
- allFiles(): Record<string, IUploadedFile | IUploadedFile[]>;
847
- /**
848
- * Extract and convert uploaded files from FormData.
849
- */
850
- convertUploadedFiles(files: Record<string, IUploadedFile | IUploadedFile[]>): Record<string, IUploadedFile | IUploadedFile[]>;
851
- /**
852
- * Determine if the data contains a given key.
853
- *
854
- * @param keys
855
- * @returns
856
- */
857
- has(keys: string[] | string): boolean;
858
- /**
859
- * Determine if the instance is missing a given key.
860
- */
861
- missing(key: string | string[]): boolean;
862
- /**
863
- * Get a subset containing the provided keys with values from the instance data.
864
- *
865
- * @param keys
866
- * @returns
867
- */
868
- only<T = Record<string, any>>(keys: string[]): T;
869
- /**
870
- * Get all of the data except for a specified array of items.
871
- *
872
- * @param keys
873
- * @returns
874
- */
875
- except<T = Record<string, any>>(keys: string[]): T;
876
- /**
877
- * Merges new input data into the current request's input source.
878
- *
879
- * @param input - An object containing key-value pairs to merge.
880
- * @returns this - For fluent chaining.
881
- */
882
- merge(input: Record<string, any>): this;
883
- /**
884
- * Merge new input into the request's input, but only when that key is missing from the request.
885
- *
886
- * @param input
887
- */
888
- mergeIfMissing(input: Record<string, any>): this;
889
- /**
890
- * Get the keys for all of the input and files.
891
- */
892
- keys(): string[];
893
- /**
894
- * Determine if the request is sending JSON.
895
- *
896
- * @return bool
897
- */
898
- isJson(): boolean;
899
- /**
900
- * Determine if the current request probably expects a JSON response.
901
- *
902
- * @returns
903
- */
904
- expectsJson(): boolean;
905
- /**
906
- * Determine if the current request is asking for JSON.
907
- *
908
- * @returns
909
- */
910
- wantsJson(): boolean;
911
- /**
912
- * Gets a list of content types acceptable by the client browser in preferable order.
913
- * @returns {string[]}
914
- */
915
- getAcceptableContentTypes(): string[];
916
- /**
917
- * Determine if the request is the result of a PJAX call.
918
- *
919
- * @return bool
920
- */
921
- pjax(): boolean;
922
- /**
923
- * Returns true if the request is an XMLHttpRequest (AJAX).
924
- *
925
- * @alias isXmlHttpRequest()
926
- * @returns {boolean}
927
- */
928
- ajax(): boolean;
929
- /**
930
- * Returns true if the request is an XMLHttpRequest (AJAX).
931
- */
932
- isXmlHttpRequest(): boolean;
933
- /**
934
- * Returns the value of the requested header.
935
- */
936
- getHeader(name: string): string | undefined | null;
937
- /**
938
- * Checks if the request method is of specified type.
939
- *
940
- * @param method Uppercase request method (GET, POST etc)
941
- */
942
- isMethod(method: string): boolean;
943
- /**
944
- * Checks whether or not the method is safe.
945
- *
946
- * @see https://tools.ietf.org/html/rfc7231#section-4.2.1
947
- */
948
- isMethodSafe(): boolean;
949
- /**
950
- * Checks whether or not the method is idempotent.
951
- */
952
- isMethodIdempotent(): boolean;
953
- /**
954
- * Checks whether the method is cacheable or not.
955
- *
956
- * @see https://tools.ietf.org/html/rfc7231#section-4.2.3
957
- */
958
- isMethodCacheable(): boolean;
959
- /**
960
- * Gets the request "intended" method.
961
- *
962
- * If the X-HTTP-Method-Override header is set, and if the method is a POST,
963
- * then it is used to determine the "real" intended HTTP method.
964
- *
965
- * The _method request parameter can also be used to determine the HTTP method,
966
- * but only if enableHttpMethodParameterOverride() has been called.
967
- *
968
- * The method is always an uppercased string.
969
- *
970
- * @see getRealMethod()
971
- */
972
- getMethod(): RequestMethod;
973
- /**
974
- * Gets the "real" request method.
975
- *
976
- * @see getMethod()
977
- */
978
- getRealMethod(): RequestMethod;
979
- /**
980
- * Get the client IP address.
981
- */
982
- ip(): string | undefined;
983
- /**
984
- * Get a URI instance for the request.
985
- */
986
- uri(): unknown;
987
- /**
988
- * Get the full URL for the request.
989
- */
990
- fullUrl(): string;
991
- /**
992
- * Return the Request instance.
993
- */
994
- instance(): this;
995
- /**
996
- * Get the request method.
997
- */
998
- method(): RequestMethod;
999
- /**
1000
- * Get the JSON payload for the request.
1001
- *
1002
- * @param key
1003
- * @param defaultValue
1004
- * @return {InputBag}
1005
- */
1006
- json<K$1 extends string | undefined = undefined>(key?: string, defaultValue?: any): K$1 extends undefined ? IParamBag : any;
1007
- /**
1008
- * Returns the request body content.
1009
- *
1010
- * @param asStream If true, returns a ReadableStream instead of the parsed string
1011
- * @return {string | ReadableStream | Promise<string | ReadableStream>}
1012
- */
1013
- getContent(asStream?: boolean): string | ReadableStream;
1014
- /**
1015
- * Gets a "parameter" value from any bag.
1016
- *
1017
- * This method is mainly useful for libraries that want to provide some flexibility. If you don't need the
1018
- * flexibility in controllers, it is better to explicitly get request parameters from the appropriate
1019
- * public property instead (attributes, query, request).
1020
- *
1021
- * Order of precedence: PATH (routing placeholders or custom attributes), GET, POST
1022
- *
1023
- * @internal use explicit input sources instead
1024
- */
1025
- get(key: string, defaultValue?: any): any;
1026
- /**
1027
- * Enables support for the _method request parameter to determine the intended HTTP method.
1028
- *
1029
- * Be warned that enabling this feature might lead to CSRF issues in your code.
1030
- * Check that you are using CSRF tokens when required.
1031
- * If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered
1032
- * and used to send a "PUT" or "DELETE" request via the _method request parameter.
1033
- * If these methods are not protected against CSRF, this presents a possible vulnerability.
1034
- *
1035
- * The HTTP method can only be overridden when the real HTTP method is POST.
1036
- */
1037
- static enableHttpMethodParameterOverride(): void;
1038
- /**
1039
- * Checks whether support for the _method request parameter is enabled.
1040
- */
1041
- static getHttpMethodParameterOverride(): boolean;
1042
- /**
1043
- * Dump the items.
1044
- *
1045
- * @param keys
1046
- * @return this
1047
- */
1048
- dump(...keys: any[]): this;
1049
- /**
1050
- * Get the base event
1051
- */
1052
- getEvent(): H3Event;
1053
- getEvent<K$1 extends DotNestedKeys<H3Event>>(key: K$1): DotNestedValue<H3Event, K$1>;
1054
- }
1055
- //#endregion
1056
- //#region src/Utils/PathLoader.d.ts
1057
- declare class PathLoader {
1058
- private paths;
1059
- /**
1060
- * Dynamically retrieves a path property from the class.
1061
- * Any property ending with "Path" is accessible automatically.
1062
- *
1063
- * @param name - The base name of the path property
1064
- * @param prefix - The base path to prefix to the path
1065
- * @returns
1066
- */
1067
- getPath(name: IPathName, prefix?: string): string;
1068
- /**
1069
- * Programatically set the paths.
1070
- *
1071
- * @param name - The base name of the path property
1072
- * @param path - The new path
1073
- * @param base - The base path to include to the path
1074
- */
1075
- setPath(name: IPathName, path: string, base?: string): void;
29
+ type DotPrefix<T extends string, U extends string> = T extends '' ? U : `${T}.${U}`;
30
+ /**
31
+ * Converts a union of objects into a single merged object
32
+ */
33
+ type MergeUnion<T> = (T extends any ? (k: T) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
34
+ /**
35
+ * Flattens nested objects into dotted keys
36
+ */
37
+ type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{ [K in keyof T & string]: T[K] extends Record<string, any> ? DotFlatten<T[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T[K] } }[keyof T & string]>;
38
+ /**
39
+ * Builds "nested.key" paths for autocompletion
40
+ */
41
+ type DotNestedKeys<T> = { [K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}` }[keyof T & string];
42
+ /**
43
+ * Retrieves type at a given dot-path
44
+ */
45
+ type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
46
+ /**
47
+ * A generic object type that supports nullable string values
48
+ */
49
+ interface GenericWithNullableStringValues {
50
+ [name: string]: string | undefined;
1076
51
  }
1077
52
  //#endregion
1078
- //#region src/Contracts/BindingsContract.d.ts
1079
- type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
1080
- type Bindings = {
1081
- [key: string]: any;
1082
- [key: `app.${string}`]: any;
1083
- env(): NodeJS.ProcessEnv;
1084
- env<T extends string>(key: T, def?: any): any;
1085
- view(viewPath: string, params?: Record<string, any>): Promise<HTTPResponse>;
1086
- edge: Edge;
1087
- asset(key: string, def?: string): string;
1088
- router: IRouter;
1089
- config: {
1090
- get<X extends Record<string, any>>(): X;
1091
- get<X extends Record<string, any>, T extends Extract<keyof X, string>>(key: T, def?: any): X[T];
1092
- set<T extends string>(key: T, value: any): void;
1093
- load?(): any;
1094
- };
1095
- 'http.app': H3;
1096
- 'path.base': string;
1097
- 'load.paths': PathLoader;
1098
- 'http.serve': typeof serve;
1099
- 'http.request': IRequest;
1100
- 'http.response': IResponse;
1101
- };
1102
- type UseKey = keyof RemoveIndexSignature<Bindings>;
1103
- //#endregion
1104
53
  //#region src/Contracts/PromptsContract.d.ts
1105
54
  type Choice<Value> = {
1106
55
  value: Value;
@@ -1113,14 +62,13 @@ type Choice<Value> = {
1113
62
  type ISeparator = Separator;
1114
63
  type Choices = readonly (string | Separator)[] | readonly (Separator | Choice<string>)[];
1115
64
  //#endregion
1116
- //#region src/Contracts/Router.d.ts
1117
- type RouteMethod = 'get' | 'head' | 'put' | 'patch' | 'post' | 'delete';
1118
- interface RouteDefinition {
1119
- method: RouteMethod;
1120
- path: string;
1121
- name?: string | undefined;
1122
- handler: EventHandler;
1123
- signature: [string, string | undefined];
65
+ //#region src/Utils/Console.d.ts
66
+ declare class Console {
67
+ static log: (...args: any[]) => string | void;
68
+ static debug: (...args: any[]) => void;
69
+ static warn: (...args: any[]) => void[];
70
+ static info: (...args: any[]) => void[];
71
+ static error: (...args: any[]) => void[];
1124
72
  }
1125
73
  //#endregion
1126
74
  //#region src/Utils/Logger.d.ts
@@ -1182,7 +130,7 @@ declare class Logger {
1182
130
  * @param preserveCol
1183
131
  * @returns
1184
132
  */
1185
- static textFormat(txt: unknown, color: (txt: string) => string, preserveCol?: boolean): string;
133
+ static textFormat(txt: unknown | unknown[], color: (...text: unknown[]) => string, preserveCol?: boolean): string;
1186
134
  /**
1187
135
  * Logs a success message
1188
136
  *
@@ -1206,9 +154,7 @@ declare class Logger {
1206
154
  * @param exit
1207
155
  * @param preserveCol
1208
156
  */
1209
- static error(msg: string | string[] | Error & {
1210
- detail?: string;
1211
- }, exit?: boolean, preserveCol?: boolean): void;
157
+ static error(msg: any, exit?: boolean, preserveCol?: boolean): void;
1212
158
  /**
1213
159
  * Logs a warning message
1214
160
  *
@@ -1246,6 +192,12 @@ declare class Logger {
1246
192
  * @returns
1247
193
  */
1248
194
  static log: LoggerLog;
195
+ /**
196
+ * A simple console like output logger
197
+ *
198
+ * @returns
199
+ */
200
+ static console(): typeof Console;
1249
201
  }
1250
202
  //#endregion
1251
203
  //#region src/Contracts/Utils.d.ts
@@ -1268,6 +220,142 @@ interface LoggerLog {
1268
220
  <L extends boolean>(config?: LoggerParseSignature, joiner?: string, log?: L, sc?: LoggerChalk): L extends true ? void : string | Logger;
1269
221
  }
1270
222
  //#endregion
223
+ //#region src/Mixins/MixinSystem.d.ts
224
+ /**
225
+ * Helper to convert a Union (A | B) into an Intersection (A & B)
226
+ */
227
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
228
+ /**
229
+ * Infers the mixed type of all base classes provided
230
+ */
231
+ type MixedClass<T extends ClassConstructor[]> = UnionToIntersection<T[number]> & (new (...args: any[]) => UnionToIntersection<InstanceType<T[number]>>);
232
+ /**
233
+ * Helper to mix multiple classes into one, this allows extending multiple classes by any single class
234
+ *
235
+ * @param bases
236
+ * @returns
237
+ */
238
+ declare const mix: <T extends ClassConstructor[]>(...bases: T) => MixedClass<T>;
239
+ //#endregion
240
+ //#region src/Mixins/TraitSystem.d.ts
241
+ declare const crc32: (str: string) => number;
242
+ type ResolveTraitLike<T extends Trait | TypeFactory<Trait>> = T extends TypeFactory<Trait> ? ExtractFactory<ReturnType<T>> : T extends Trait ? ExtractFactory<T> : unknown;
243
+ type Combine<T extends any[]> = T extends [infer Head, ...infer Tail] ? Head & Combine<Tail> : object;
244
+ type MapClassesToPrototypes<T extends Array<(new () => any) & {
245
+ prototype: any;
246
+ }>> = { [K in keyof T]: T[K]['prototype'] };
247
+ type MapClassesToInstances<T extends Array<(new () => any) & {
248
+ prototype: any;
249
+ }>> = { [K in keyof T]: InstanceType<T[K]> };
250
+ type CombineClasses<T extends Array<(new () => any) & {
251
+ prototype: any;
252
+ }>> = (new () => Combine<MapClassesToInstances<T>>) & {
253
+ prototype: Combine<MapClassesToPrototypes<T>>;
254
+ };
255
+ type ResolveTraitLikeArray<T extends Array<Trait | TypeFactory<Trait>>> = CombineClasses<{ [K in keyof T]: ResolveTraitLike<T[K]> }>;
256
+ type Cons<T = any> = new (...args: any[]) => T;
257
+ type ConsFactory<T extends Cons = Cons, B = any> = (base: B) => T;
258
+ type TypeFactory<T = any> = () => T;
259
+ type Explode<T = any> = { [P in keyof T]: T[P] };
260
+ type MixParams<T1 extends any[], T2 extends any[]> = T1 extends [] ? (T2 extends [] ? [] : T2) : (T2 extends [] ? T1 : (T1 extends [infer H1, ...infer R1] ? (T2 extends [infer H2, ...infer R2] ? [H1 & H2, ...MixParams<R1, R2>] : []) : []));
261
+ type TraitDefTypeT = ConsFactory<Cons>;
262
+ type TraitDefTypeST = (Trait | TypeFactory<Trait>)[] | undefined;
263
+ type Trait<T extends TraitDefTypeT = TraitDefTypeT, ST$1 extends TraitDefTypeST = TraitDefTypeST> = {
264
+ id: number;
265
+ symbol: symbol;
266
+ factory: T;
267
+ superTraits: ST$1;
268
+ };
269
+ declare function trait<T extends ConsFactory<Cons>>(factory: T): Trait<T, undefined>;
270
+ declare function trait<const ST$1 extends (Trait | TypeFactory<Trait>)[], T extends ConsFactory<Cons, ResolveTraitLikeArray<ST$1>>>(superTraits: ST$1, factory: T): Trait<T, ST$1>;
271
+ type ExtractFactory<T extends Trait> = T extends Trait<ConsFactory<infer C>, TraitDefTypeST> ? C : never;
272
+ type ExtractSuperTrait<T extends Trait> = T extends Trait<TraitDefTypeT, infer ST extends TraitDefTypeST> ? ST : never;
273
+ type DeriveTraitsConsConsMerge<A extends Cons, B extends Cons> = A extends (new (...args: infer ArgsA) => infer RetA) ? (B extends (new (...args: infer ArgsB) => infer RetB) ? (new (...args: MixParams<ArgsA, ArgsB>) => RetA & RetB) : never) : never;
274
+ type DeriveTraitsConsCons<T extends Cons> = new (...args: ConstructorParameters<T>) => InstanceType<T>;
275
+ type DeriveTraitsConsTraitParts<C$1 extends Cons, ST$1 extends ((Trait | TypeFactory<Trait>)[] | undefined)> = ST$1 extends undefined ? DeriveTraitsConsCons<C$1> : ST$1 extends [] ? DeriveTraitsConsCons<C$1> : DeriveTraitsConsConsMerge<DeriveTraitsConsCons<C$1>, DeriveTraitsConsAll<ST$1>>;
276
+ type DeriveTraitsConsTrait<T extends Trait> = DeriveTraitsConsTraitParts<ExtractFactory<T>, ExtractSuperTrait<T>>;
277
+ type DeriveTraitsConsOne<T extends (Trait | TypeFactory<Trait>)> = T extends Trait ? DeriveTraitsConsTrait<T> : T extends TypeFactory<Trait> ? DeriveTraitsConsTrait<ReturnType<T>> : never;
278
+ type DeriveTraitsConsAll<T extends (((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], Cons]) | undefined)> = T extends [...infer Others extends (Trait | TypeFactory<Trait>)[], infer Last extends Cons] ? (DeriveTraitsConsConsMerge<DeriveTraitsConsAll<Others>, /* RECURSION */DeriveTraitsConsCons<Last>>) : T extends (Trait | TypeFactory<Trait>)[] ? (T extends [infer First extends (Trait | TypeFactory<Trait>)] ? (DeriveTraitsConsOne<First>) : (T extends [infer First extends (Trait | TypeFactory<Trait>), ...infer Rest extends (Trait | TypeFactory<Trait>)[]] ? (DeriveTraitsConsConsMerge<DeriveTraitsConsOne<First>, DeriveTraitsConsAll<Rest>>) : never)) : never;
279
+ type DeriveTraitsCons<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], Cons])> = DeriveTraitsConsAll<T>;
280
+ type DeriveTraitsStatsConsMerge<T1 extends object, T2 extends object> = T1 & T2;
281
+ type DeriveTraitsStatsCons<T extends Cons> = Explode<T>;
282
+ type DeriveTraitsStatsTraitParts<C$1 extends Cons, ST$1 extends ((Trait | TypeFactory<Trait>)[] | undefined)> = ST$1 extends undefined ? DeriveTraitsStatsCons<C$1> : ST$1 extends [] ? DeriveTraitsStatsCons<C$1> : DeriveTraitsStatsConsMerge<DeriveTraitsStatsCons<C$1>, DeriveTraitsStatsAll<ST$1>>;
283
+ type DeriveTraitsStatsTrait<T extends Trait> = DeriveTraitsStatsTraitParts<ExtractFactory<T>, ExtractSuperTrait<T>>;
284
+ type DeriveTraitsStatsOne<T extends (Trait | TypeFactory<Trait>)> = T extends Trait ? DeriveTraitsStatsTrait<T> : T extends TypeFactory<Trait> ? DeriveTraitsStatsTrait<ReturnType<T>> : never;
285
+ type DeriveTraitsStatsAll<T extends (((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], Cons]) | undefined)> = T extends [...infer Others extends (Trait | TypeFactory<Trait>)[], infer Last extends Cons] ? (DeriveTraitsStatsConsMerge<DeriveTraitsStatsAll<Others>, /* RECURSION */DeriveTraitsStatsCons<Last>>) : T extends (Trait | TypeFactory<Trait>)[] ? (T extends [infer First extends (Trait | TypeFactory<Trait>)] ? (DeriveTraitsStatsOne<First>) : (T extends [infer First extends (Trait | TypeFactory<Trait>), ...infer Rest extends (Trait | TypeFactory<Trait>)[]] ? (DeriveTraitsStatsConsMerge<DeriveTraitsStatsOne<First>, DeriveTraitsStatsAll<Rest>>) : never)) : never;
286
+ type DeriveTraitsStats<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], Cons])> = DeriveTraitsStatsAll<T>;
287
+ type DeriveTraits<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], Cons])> = DeriveTraitsCons<T> & DeriveTraitsStats<T>;
288
+ declare function use<T extends ([Trait | TypeFactory<Trait>, ...(Trait | TypeFactory<Trait>)[]] | [...(Trait | TypeFactory<Trait>)[], Cons])>(...traits: T): DeriveTraits<T>;
289
+ type DerivedType<T extends Trait> = InstanceType<ExtractFactory<T>>;
290
+ type Derived<T extends (Trait | TypeFactory<Trait> | Cons)> = T extends TypeFactory<Trait> ? DerivedType<ReturnType<T>> : T extends Trait ? DerivedType<T> : T extends Cons ? T : never;
291
+ declare function uses<T extends (Trait | TypeFactory<Trait> | Cons)>(instance: unknown, trait: T): instance is Derived<T>;
292
+ //#endregion
293
+ //#region src/Mixins/UseFinalizable.d.ts
294
+ /**
295
+ * the API trait "Finalizable<T>"
296
+ */
297
+ declare const Finalizable: Trait<(base: any) => {
298
+ new (...args: any[]): {
299
+ [x: string]: any;
300
+ };
301
+ [x: string]: any;
302
+ }, undefined>;
303
+ //#endregion
304
+ //#region src/Mixins/UseMagic.d.ts
305
+ /**
306
+ * Wraps an object in a Proxy to emulate PHP magic methods.
307
+ *
308
+ * Supported:
309
+ * - __call(method, args)
310
+ * - __get(property)
311
+ * - __set(property, value)
312
+ * - __isset(property)
313
+ * - __unset(property)
314
+ *
315
+ * Called automatically by Magic's constructor.
316
+ *
317
+ * Return in any class constructor to use
318
+ *
319
+ * @param target
320
+ * @returns
321
+ */
322
+ declare function makeMagic<T extends object>(target: T): T;
323
+ /**
324
+ * Wraps a class constructor in a Proxy to emulate static PHP magic methods.
325
+ *
326
+ * Supported:
327
+ * - __callStatic(method, args)
328
+ * - static __get(property)
329
+ * - static __set(property, value)
330
+ * - static __isset(property)
331
+ * - static __unset(property)
332
+ *
333
+ * @param cls
334
+ * @returns
335
+ */
336
+ declare function makeStaticMagic<T extends ((...args: any[]) => any) | (abstract new (...args: any[]) => any)>(cls: T): T;
337
+ /**
338
+ * Base class that enables PHP-style magic methods automatically.
339
+ *
340
+ * Any subclass may implement:
341
+ * - __call
342
+ * - __get
343
+ * - __set
344
+ * - __isset
345
+ * - __unset
346
+ *
347
+ * The constructor returns a Proxy transparently.
348
+ */
349
+ declare abstract class Magic {
350
+ constructor();
351
+ }
352
+ declare const UseMagic: Trait<(Base: any) => {
353
+ new (...args: any[]): {
354
+ [x: string]: any;
355
+ };
356
+ [x: string]: any;
357
+ }, undefined>;
358
+ //#endregion
1271
359
  //#region src/Utils/EnvParser.d.ts
1272
360
  declare class EnvParser {
1273
361
  static parse(initial: GenericWithNullableStringValues): {
@@ -1296,6 +384,39 @@ declare class FileSystem {
1296
384
  * @returns
1297
385
  */
1298
386
  static resolveFileUp(name: string, extensions: string[] | ((dir: string, filesNames: string[]) => string | false), cwd?: string): string | undefined;
387
+ /**
388
+ * Recursively find files starting from given cwd
389
+ *
390
+ * @param name
391
+ * @param extensions
392
+ * @param cwd
393
+ *
394
+ * @returns
395
+ */
396
+ static resolveModulePath(moduleId: string, pathName: string | string[], cwd?: string): string | undefined;
397
+ }
398
+ //#endregion
399
+ //#region src/Utils/PathLoader.d.ts
400
+ declare class PathLoader {
401
+ private paths;
402
+ /**
403
+ * Dynamically retrieves a path property from the class.
404
+ * Any property ending with "Path" is accessible automatically.
405
+ *
406
+ * @param name - The base name of the path property
407
+ * @param prefix - The base path to prefix to the path
408
+ * @returns
409
+ */
410
+ getPath(name: IPathName, prefix?: string): string;
411
+ /**
412
+ * Programatically set the paths.
413
+ *
414
+ * @param name - The base name of the path property
415
+ * @param path - The new path
416
+ * @param base - The base path to include to the path
417
+ */
418
+ setPath(name: IPathName, path: string, base?: string): void;
419
+ distPath(path: string, skipExt?: boolean): string;
1299
420
  }
1300
421
  //#endregion
1301
422
  //#region src/Utils/Prompts.d.ts
@@ -1445,5 +566,5 @@ declare class TaskManager {
1445
566
  static advancedTaskRunner<R = any>(info: [[string, string], [string, string]] | [[string, string]], task: (() => Promise<R>) | (() => R)): Promise<R | undefined>;
1446
567
  }
1447
568
  //#endregion
1448
- export { Bindings, Choice, type ChoiceOrSeparatorArray, Choices, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IHttpResponse, IMiddleware, IParamBag, IPathName, IRequest, IResponse, IRouter, ISeparator, IServiceProvider, IUploadedFile, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Prompts, RequestMethod, RequestObject, Resolver, ResponseObject, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
569
+ export { Choice, type ChoiceOrSeparatorArray, Choices, Console, Derived, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, FileSystem, Finalizable, GenericWithNullableStringValues, INTERNAL_METHODS, ISeparator, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, Magic, PathLoader, Prompts, Resolver, TaskManager, Trait, UseMagic, baseTsconfig, crc32, internal, isInternal, mainTsconfig, makeMagic, makeStaticMagic, mix, packageJsonScript, trait, use, uses };
1449
570
  //# sourceMappingURL=index.d.ts.map