@h3ravel/shared 0.25.0 → 0.26.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.cjs +10 -41
- package/dist/index.d.ts +741 -69
- package/dist/index.js +11 -39
- package/package.json +3 -3
- package/dist/index.d.cts +0 -776
package/dist/index.d.cts
DELETED
|
@@ -1,776 +0,0 @@
|
|
|
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
|
-
import { Separator } from "@inquirer/prompts";
|
|
6
|
-
import { ChoiceOrSeparatorArray, ChoiceOrSeparatorArray as ChoiceOrSeparatorArray$1 } from "inquirer-autocomplete-standalone";
|
|
7
|
-
import { ChalkInstance } from "chalk";
|
|
8
|
-
|
|
9
|
-
//#region src/Contracts/ObjContract.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Adds a dot prefix to nested keys
|
|
12
|
-
*/
|
|
13
|
-
type DotPrefix<T$1 extends string, U extends string> = T$1 extends '' ? U : `${T$1}.${U}`;
|
|
14
|
-
/**
|
|
15
|
-
* Converts a union of objects into a single merged object
|
|
16
|
-
*/
|
|
17
|
-
type MergeUnion<T$1> = (T$1 extends any ? (k: T$1) => 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$1, Prefix extends string = ''> = MergeUnion<{ [K in keyof T$1 & string]: T$1[K] extends Record<string, any> ? DotFlatten<T$1[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T$1[K] } }[keyof T$1 & string]>;
|
|
22
|
-
/**
|
|
23
|
-
* Builds "nested.key" paths for autocompletion
|
|
24
|
-
*/
|
|
25
|
-
type DotNestedKeys<T$1> = { [K in keyof T$1 & string]: T$1[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T$1[K]>}` : `${K}` }[keyof T$1 & string];
|
|
26
|
-
/**
|
|
27
|
-
* Retrieves type at a given dot-path
|
|
28
|
-
*/
|
|
29
|
-
type DotNestedValue<T$1, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T$1 ? DotNestedValue<T$1[Key], Rest> : never : Path extends keyof T$1 ? T$1[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/IRequest.d.ts
|
|
155
|
-
/**
|
|
156
|
-
* Interface for the Request contract, defining methods for handling HTTP request data.
|
|
157
|
-
*/
|
|
158
|
-
interface IRequest {
|
|
159
|
-
/**
|
|
160
|
-
* The current app instance
|
|
161
|
-
*/
|
|
162
|
-
app: IApplication;
|
|
163
|
-
/**
|
|
164
|
-
* Gets route parameters.
|
|
165
|
-
* @returns An object containing route parameters.
|
|
166
|
-
*/
|
|
167
|
-
params: NonNullable<H3Event['context']['params']>;
|
|
168
|
-
/**
|
|
169
|
-
* Gets query parameters.
|
|
170
|
-
* @returns An object containing query parameters.
|
|
171
|
-
*/
|
|
172
|
-
query: Record<string, any>;
|
|
173
|
-
/**
|
|
174
|
-
* Gets all input data (query parameters, route parameters, and body).
|
|
175
|
-
* @returns A promise resolving to an object containing all input data.
|
|
176
|
-
*/
|
|
177
|
-
all<T = Record<string, unknown>>(): Promise<T>;
|
|
178
|
-
/**
|
|
179
|
-
* Gets a single input field from query or body.
|
|
180
|
-
* @param key - The key of the input field.
|
|
181
|
-
* @param defaultValue - Optional default value if the key is not found.
|
|
182
|
-
* @returns A promise resolving to the value of the input field or the default value.
|
|
183
|
-
*/
|
|
184
|
-
input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
|
|
185
|
-
/**
|
|
186
|
-
* Gets the underlying event object or a specific property of it.
|
|
187
|
-
* @param key - Optional key to access a nested property of the event.
|
|
188
|
-
* @returns The entire event object or the value of the specified property.
|
|
189
|
-
*/
|
|
190
|
-
getEvent(): H3Event;
|
|
191
|
-
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/Contracts/IResponse.d.ts
|
|
195
|
-
/**
|
|
196
|
-
* Interface for the Response contract, defining methods for handling HTTP responses.
|
|
197
|
-
*/
|
|
198
|
-
interface IResponse {
|
|
199
|
-
/**
|
|
200
|
-
* The current app instance
|
|
201
|
-
*/
|
|
202
|
-
app: IApplication;
|
|
203
|
-
/**
|
|
204
|
-
* Sets the HTTP status code for the response.
|
|
205
|
-
* @param code - The HTTP status code.
|
|
206
|
-
* @returns The instance for method chaining.
|
|
207
|
-
*/
|
|
208
|
-
setStatusCode(code: number): this;
|
|
209
|
-
/**
|
|
210
|
-
* Sets a response header.
|
|
211
|
-
* @param name - The header name.
|
|
212
|
-
* @param value - The header value.
|
|
213
|
-
* @returns The instance for method chaining.
|
|
214
|
-
*/
|
|
215
|
-
setHeader(name: string, value: string): this;
|
|
216
|
-
/**
|
|
217
|
-
* Sends an HTML response.
|
|
218
|
-
* @param content - The HTML content to send.
|
|
219
|
-
* @returns The HTML content.
|
|
220
|
-
*/
|
|
221
|
-
html(content: string): HTTPResponse;
|
|
222
|
-
/**
|
|
223
|
-
* Sends a JSON response.
|
|
224
|
-
* @param data - The data to send as JSON.
|
|
225
|
-
* @returns The input data.
|
|
226
|
-
*/
|
|
227
|
-
json<T = unknown>(data: T): T;
|
|
228
|
-
/**
|
|
229
|
-
* Sends a plain text response.
|
|
230
|
-
* @param data - The text content to send.
|
|
231
|
-
* @returns The text content.
|
|
232
|
-
*/
|
|
233
|
-
text(data: string): string;
|
|
234
|
-
/**
|
|
235
|
-
* Redirects to another URL.
|
|
236
|
-
* @param url - The URL to redirect to.
|
|
237
|
-
* @param status - The HTTP status code for the redirect (default: 302).
|
|
238
|
-
* @returns The redirect URL.
|
|
239
|
-
*/
|
|
240
|
-
redirect(url: string, status?: number): HTTPResponse;
|
|
241
|
-
/**
|
|
242
|
-
* Gets the underlying event object or a specific property of it.
|
|
243
|
-
* @param key - Optional key to access a nested property of the event.
|
|
244
|
-
* @returns The entire event object or the value of the specified property.
|
|
245
|
-
*/
|
|
246
|
-
getEvent(): H3Event;
|
|
247
|
-
getEvent<K extends DotNestedKeys$1<H3Event>>(key: K): DotNestedValue$1<H3Event, K>;
|
|
248
|
-
}
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/Contracts/IHttp.d.ts
|
|
251
|
-
type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'patch' | 'apiResource' | 'group' | 'route';
|
|
252
|
-
type ExtractControllerMethods<T$1> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? K : never }[keyof T$1];
|
|
253
|
-
/**
|
|
254
|
-
* Interface for the Router contract, defining methods for HTTP routing.
|
|
255
|
-
*/
|
|
256
|
-
interface IRouter {
|
|
257
|
-
/**
|
|
258
|
-
* Registers a GET route.
|
|
259
|
-
* @param path - The route path.
|
|
260
|
-
* @param definition - The handler function or [controller class, method] array.
|
|
261
|
-
* @param name - Optional route name.
|
|
262
|
-
* @param middleware - Optional middleware array.
|
|
263
|
-
*/
|
|
264
|
-
get<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
265
|
-
/**
|
|
266
|
-
* Registers a POST route.
|
|
267
|
-
* @param path - The route path.
|
|
268
|
-
* @param definition - The handler function or [controller class, method] array.
|
|
269
|
-
* @param name - Optional route name.
|
|
270
|
-
* @param middleware - Optional middleware array.
|
|
271
|
-
*/
|
|
272
|
-
post<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
273
|
-
/**
|
|
274
|
-
* Registers a PUT route.
|
|
275
|
-
* @param path - The route path.
|
|
276
|
-
* @param definition - The handler function or [controller class, method] array.
|
|
277
|
-
* @param name - Optional route name.
|
|
278
|
-
* @param middleware - Optional middleware array.
|
|
279
|
-
*/
|
|
280
|
-
put<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
281
|
-
/**
|
|
282
|
-
* Registers a route that responds to HTTP PATCH requests.
|
|
283
|
-
*
|
|
284
|
-
* @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
|
|
285
|
-
* @param definition Either:
|
|
286
|
-
* - An EventHandler function
|
|
287
|
-
* - A tuple: [ControllerClass, methodName]
|
|
288
|
-
* @param name Optional route name (for URL generation or referencing).
|
|
289
|
-
* @param middleware Optional array of middleware functions to execute before the handler.
|
|
290
|
-
*/
|
|
291
|
-
patch<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
292
|
-
/**
|
|
293
|
-
* Registers a DELETE route.
|
|
294
|
-
* @param path - The route path.
|
|
295
|
-
* @param definition - The handler function or [controller class, method] array.
|
|
296
|
-
* @param name - Optional route name.
|
|
297
|
-
* @param middleware - Optional middleware array.
|
|
298
|
-
*/
|
|
299
|
-
delete<C extends new (...args: any) => any>(path: string, definition: EventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
300
|
-
/**
|
|
301
|
-
* Registers an API resource with standard CRUD routes.
|
|
302
|
-
* @param path - The base path for the resource.
|
|
303
|
-
* @param controller - The controller class handling the resource.
|
|
304
|
-
* @param middleware - Optional middleware array.
|
|
305
|
-
*/
|
|
306
|
-
apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): Omit<this, RouterEnd | 'name'>;
|
|
307
|
-
/**
|
|
308
|
-
* Generates a URL for a named route.
|
|
309
|
-
* @param name - The name of the route.
|
|
310
|
-
* @param params - Optional parameters to replace in the route path.
|
|
311
|
-
* @returns The generated URL or undefined if the route is not found.
|
|
312
|
-
*/
|
|
313
|
-
route(name: string, params?: Record<string, string>): string | undefined;
|
|
314
|
-
/**
|
|
315
|
-
* Set the name of the current route
|
|
316
|
-
*
|
|
317
|
-
* @param name
|
|
318
|
-
*/
|
|
319
|
-
name(name: string): this;
|
|
320
|
-
/**
|
|
321
|
-
* Groups routes with shared prefix or middleware.
|
|
322
|
-
* @param options - Configuration for prefix or middleware.
|
|
323
|
-
* @param callback - Callback function defining grouped routes.
|
|
324
|
-
*/
|
|
325
|
-
group(options: {
|
|
326
|
-
prefix?: string;
|
|
327
|
-
middleware?: EventHandler[];
|
|
328
|
-
}, callback: () => this): this;
|
|
329
|
-
/**
|
|
330
|
-
* Registers middleware for a specific path.
|
|
331
|
-
* @param path - The path to apply the middleware.
|
|
332
|
-
* @param handler - The middleware handler.
|
|
333
|
-
* @param opts - Optional middleware options.
|
|
334
|
-
*/
|
|
335
|
-
middleware(path: Middleware, opts?: Middleware | MiddlewareOptions): this;
|
|
336
|
-
middleware(path: string | IMiddleware[] | Middleware, handler: Middleware | MiddlewareOptions, opts?: MiddlewareOptions): this;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Represents the HTTP context for a single request lifecycle.
|
|
340
|
-
* Encapsulates the application instance, request, and response objects.
|
|
341
|
-
*/
|
|
342
|
-
declare class HttpContext {
|
|
343
|
-
app: IApplication;
|
|
344
|
-
request: IRequest;
|
|
345
|
-
response: IResponse;
|
|
346
|
-
private static contexts;
|
|
347
|
-
constructor(app: IApplication, request: IRequest, response: IResponse);
|
|
348
|
-
/**
|
|
349
|
-
* Factory method to create a new HttpContext instance from a context object.
|
|
350
|
-
* @param ctx - Object containing app, request, and response
|
|
351
|
-
* @returns A new HttpContext instance
|
|
352
|
-
*/
|
|
353
|
-
static init(ctx: {
|
|
354
|
-
app: IApplication;
|
|
355
|
-
request: IRequest;
|
|
356
|
-
response: IResponse;
|
|
357
|
-
}, event?: unknown): HttpContext;
|
|
358
|
-
/**
|
|
359
|
-
* Retrieve an existing HttpContext instance for an event, if any.
|
|
360
|
-
*/
|
|
361
|
-
static get(event: unknown): HttpContext | undefined;
|
|
362
|
-
/**
|
|
363
|
-
* Delete the cached context for a given event (optional cleanup).
|
|
364
|
-
*/
|
|
365
|
-
static forget(event: unknown): void;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Type for EventHandler, representing a function that handles an H3 event.
|
|
369
|
-
*/
|
|
370
|
-
type EventHandler = (ctx: HttpContext) => any;
|
|
371
|
-
type RouteEventHandler = (...args: any[]) => any;
|
|
372
|
-
/**
|
|
373
|
-
* Defines the contract for all controllers.
|
|
374
|
-
* Any controller implementing this must define these methods.
|
|
375
|
-
*/
|
|
376
|
-
interface IController {
|
|
377
|
-
show?(...ctx: any[]): any;
|
|
378
|
-
index?(...ctx: any[]): any;
|
|
379
|
-
store?(...ctx: any[]): any;
|
|
380
|
-
update?(...ctx: any[]): any;
|
|
381
|
-
destroy?(...ctx: any[]): any;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Defines the contract for all middlewares.
|
|
385
|
-
* Any middleware implementing this must define these methods.
|
|
386
|
-
*/
|
|
387
|
-
interface IMiddleware {
|
|
388
|
-
handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
|
|
389
|
-
}
|
|
390
|
-
//#endregion
|
|
391
|
-
//#region src/Utils/PathLoader.d.ts
|
|
392
|
-
declare class PathLoader {
|
|
393
|
-
private paths;
|
|
394
|
-
/**
|
|
395
|
-
* Dynamically retrieves a path property from the class.
|
|
396
|
-
* Any property ending with "Path" is accessible automatically.
|
|
397
|
-
*
|
|
398
|
-
* @param name - The base name of the path property
|
|
399
|
-
* @param prefix - The base path to prefix to the path
|
|
400
|
-
* @returns
|
|
401
|
-
*/
|
|
402
|
-
getPath(name: IPathName, prefix?: string): string;
|
|
403
|
-
/**
|
|
404
|
-
* Programatically set the paths.
|
|
405
|
-
*
|
|
406
|
-
* @param name - The base name of the path property
|
|
407
|
-
* @param path - The new path
|
|
408
|
-
* @param base - The base path to include to the path
|
|
409
|
-
*/
|
|
410
|
-
setPath(name: IPathName, path: string, base?: string): void;
|
|
411
|
-
}
|
|
412
|
-
//#endregion
|
|
413
|
-
//#region src/Contracts/BindingsContract.d.ts
|
|
414
|
-
type RemoveIndexSignature<T$1> = { [K in keyof T$1 as string extends K ? never : number extends K ? never : K]: T$1[K] };
|
|
415
|
-
type Bindings = {
|
|
416
|
-
[key: string]: any;
|
|
417
|
-
[key: `app.${string}`]: any;
|
|
418
|
-
env(): NodeJS.ProcessEnv;
|
|
419
|
-
env<T extends string>(key: T, def?: any): any;
|
|
420
|
-
view(viewPath: string, params?: Record<string, any>): Promise<HTTPResponse>;
|
|
421
|
-
edge: Edge;
|
|
422
|
-
asset(key: string, def?: string): string;
|
|
423
|
-
router: IRouter;
|
|
424
|
-
config: {
|
|
425
|
-
get<X extends Record<string, any>>(): X;
|
|
426
|
-
get<X extends Record<string, any>, T extends Extract<keyof X, string>>(key: T, def?: any): X[T];
|
|
427
|
-
set<T extends string>(key: T, value: any): void;
|
|
428
|
-
load?(): any;
|
|
429
|
-
};
|
|
430
|
-
'http.app': H3;
|
|
431
|
-
'path.base': string;
|
|
432
|
-
'load.paths': PathLoader;
|
|
433
|
-
'http.serve': typeof serve;
|
|
434
|
-
'http.request': IRequest;
|
|
435
|
-
'http.response': IResponse;
|
|
436
|
-
};
|
|
437
|
-
type UseKey = keyof RemoveIndexSignature<Bindings>;
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region src/Contracts/PromptsContract.d.ts
|
|
440
|
-
type Choice<Value> = {
|
|
441
|
-
value: Value;
|
|
442
|
-
name?: string;
|
|
443
|
-
description?: string;
|
|
444
|
-
short?: string;
|
|
445
|
-
disabled?: boolean | string;
|
|
446
|
-
type?: never;
|
|
447
|
-
};
|
|
448
|
-
type ISeparator = Separator;
|
|
449
|
-
type Choices = readonly (string | Separator)[] | readonly (Separator | Choice<string>)[];
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region src/Contracts/Router.d.ts
|
|
452
|
-
type RouteMethod = 'get' | 'head' | 'put' | 'patch' | 'post' | 'delete';
|
|
453
|
-
interface RouteDefinition {
|
|
454
|
-
method: RouteMethod;
|
|
455
|
-
path: string;
|
|
456
|
-
name?: string | undefined;
|
|
457
|
-
handler: EventHandler;
|
|
458
|
-
signature: [string, string | undefined];
|
|
459
|
-
}
|
|
460
|
-
//#endregion
|
|
461
|
-
//#region src/Utils/Logger.d.ts
|
|
462
|
-
declare class Logger {
|
|
463
|
-
/**
|
|
464
|
-
* Global verbosity configuration
|
|
465
|
-
*/
|
|
466
|
-
private static verbosity;
|
|
467
|
-
private static isQuiet;
|
|
468
|
-
private static isSilent;
|
|
469
|
-
/**
|
|
470
|
-
* Configure global verbosity levels
|
|
471
|
-
*/
|
|
472
|
-
static configure(options?: {
|
|
473
|
-
verbosity?: number;
|
|
474
|
-
quiet?: boolean;
|
|
475
|
-
silent?: boolean;
|
|
476
|
-
}): void;
|
|
477
|
-
/**
|
|
478
|
-
* Check if output should be suppressed
|
|
479
|
-
*/
|
|
480
|
-
private static shouldSuppressOutput;
|
|
481
|
-
/**
|
|
482
|
-
* Logs the message in two columns
|
|
483
|
-
*
|
|
484
|
-
* @param name
|
|
485
|
-
* @param value
|
|
486
|
-
* @param log If set to false, array of [name, dots, value] output will be returned and not logged
|
|
487
|
-
* @returns
|
|
488
|
-
*/
|
|
489
|
-
static twoColumnDetail(name: string, value: string, log?: true, spacer?: string): void;
|
|
490
|
-
static twoColumnDetail(name: string, value: string, log?: false, spacer?: string): [string, string, string];
|
|
491
|
-
/**
|
|
492
|
-
* Logs the message in two columns
|
|
493
|
-
*
|
|
494
|
-
* @param name
|
|
495
|
-
* @param desc
|
|
496
|
-
* @param width
|
|
497
|
-
* @param log If set to false, array of [name, dots, value] output will be returned and not logged
|
|
498
|
-
* @returns
|
|
499
|
-
*/
|
|
500
|
-
static describe(name: string, desc: string, width?: number, log?: true): void;
|
|
501
|
-
static describe(name: string, desc: string, width?: number, log?: false): [string, string, string];
|
|
502
|
-
/**
|
|
503
|
-
* Logs the message in two columns but allways passing status
|
|
504
|
-
*
|
|
505
|
-
* @param name
|
|
506
|
-
* @param value
|
|
507
|
-
* @param status
|
|
508
|
-
* @param exit
|
|
509
|
-
* @param preserveCol
|
|
510
|
-
*/
|
|
511
|
-
static split(name: string, value: string, status?: 'success' | 'info' | 'error', exit?: boolean, preserveCol?: boolean): void;
|
|
512
|
-
/**
|
|
513
|
-
* Wraps text with chalk
|
|
514
|
-
*
|
|
515
|
-
* @param txt
|
|
516
|
-
* @param color
|
|
517
|
-
* @param preserveCol
|
|
518
|
-
* @returns
|
|
519
|
-
*/
|
|
520
|
-
static textFormat(txt: unknown, color: (txt: string) => string, preserveCol?: boolean): string;
|
|
521
|
-
/**
|
|
522
|
-
* Logs a success message
|
|
523
|
-
*
|
|
524
|
-
* @param msg
|
|
525
|
-
* @param exit
|
|
526
|
-
* @param preserveCol
|
|
527
|
-
*/
|
|
528
|
-
static success(msg: any, exit?: boolean, preserveCol?: boolean): void;
|
|
529
|
-
/**
|
|
530
|
-
* Logs an informational message
|
|
531
|
-
*
|
|
532
|
-
* @param msg
|
|
533
|
-
* @param exit
|
|
534
|
-
* @param preserveCol
|
|
535
|
-
*/
|
|
536
|
-
static info(msg: any, exit?: boolean, preserveCol?: boolean): void;
|
|
537
|
-
/**
|
|
538
|
-
* Logs an error message
|
|
539
|
-
*
|
|
540
|
-
* @param msg
|
|
541
|
-
* @param exit
|
|
542
|
-
* @param preserveCol
|
|
543
|
-
*/
|
|
544
|
-
static error(msg: string | string[] | Error & {
|
|
545
|
-
detail?: string;
|
|
546
|
-
}, exit?: boolean, preserveCol?: boolean): void;
|
|
547
|
-
/**
|
|
548
|
-
* Logs a warning message
|
|
549
|
-
*
|
|
550
|
-
* @param msg
|
|
551
|
-
* @param exit
|
|
552
|
-
* @param preserveCol
|
|
553
|
-
*/
|
|
554
|
-
static warn(msg: any, exit?: boolean, preserveCol?: boolean): void;
|
|
555
|
-
/**
|
|
556
|
-
* Logs a debug message (only shown with verbosity >= 3)
|
|
557
|
-
*
|
|
558
|
-
* @param msg
|
|
559
|
-
* @param exit
|
|
560
|
-
* @param preserveCol
|
|
561
|
-
*/
|
|
562
|
-
static debug<M = any>(msg: M | M[], exit?: boolean, preserveCol?: boolean): void;
|
|
563
|
-
/**
|
|
564
|
-
* Terminates the process
|
|
565
|
-
*/
|
|
566
|
-
static quiet(): void;
|
|
567
|
-
static chalker(styles: LoggerChalk[]): (input: any) => string;
|
|
568
|
-
/**
|
|
569
|
-
* Parse an array formated message and logs it
|
|
570
|
-
*
|
|
571
|
-
* @param config
|
|
572
|
-
* @param joiner
|
|
573
|
-
* @param log If set to false, string output will be returned and not logged
|
|
574
|
-
* @param sc color to use ue on split text if : is found
|
|
575
|
-
*/
|
|
576
|
-
static parse(config: LoggerParseSignature, joiner?: string, log?: true, sc?: LoggerChalk): void;
|
|
577
|
-
static parse(config: LoggerParseSignature, joiner?: string, log?: false, sc?: LoggerChalk): string;
|
|
578
|
-
/**
|
|
579
|
-
* Ouput formater object or format the output
|
|
580
|
-
*
|
|
581
|
-
* @returns
|
|
582
|
-
*/
|
|
583
|
-
static log: LoggerLog;
|
|
584
|
-
}
|
|
585
|
-
//#endregion
|
|
586
|
-
//#region src/Contracts/Utils.d.ts
|
|
587
|
-
type LoggerChalk = keyof ChalkInstance | ChalkInstance | (keyof ChalkInstance)[];
|
|
588
|
-
type LoggerParseSignature = [string, LoggerChalk][];
|
|
589
|
-
/**
|
|
590
|
-
* Ouput formater object or format the output
|
|
591
|
-
*
|
|
592
|
-
* @param config
|
|
593
|
-
* @param joiner
|
|
594
|
-
* @param log If set to false, string output will be returned and not logged
|
|
595
|
-
* @param sc color to use ue on split text if : is found
|
|
596
|
-
*
|
|
597
|
-
* @returns
|
|
598
|
-
*/
|
|
599
|
-
interface LoggerLog {
|
|
600
|
-
(): typeof Logger;
|
|
601
|
-
<L extends boolean>(config: string, joiner: LoggerChalk, log?: L, sc?: LoggerChalk): L extends true ? void : string;
|
|
602
|
-
<L extends boolean>(config: LoggerParseSignature, joiner?: string, log?: L, sc?: LoggerChalk): L extends true ? void : string;
|
|
603
|
-
<L extends boolean>(config?: LoggerParseSignature, joiner?: string, log?: L, sc?: LoggerChalk): L extends true ? void : string | Logger;
|
|
604
|
-
}
|
|
605
|
-
//#endregion
|
|
606
|
-
//#region src/Utils/EnvParser.d.ts
|
|
607
|
-
declare class EnvParser {
|
|
608
|
-
static parse(initial: GenericWithNullableStringValues): {
|
|
609
|
-
[name: string]: string | undefined;
|
|
610
|
-
};
|
|
611
|
-
static parseValue(value: any): any;
|
|
612
|
-
}
|
|
613
|
-
//#endregion
|
|
614
|
-
//#region src/Utils/FileSystem.d.ts
|
|
615
|
-
declare class FileSystem {
|
|
616
|
-
static findModulePkg(moduleId: string, cwd?: string): string | undefined;
|
|
617
|
-
/**
|
|
618
|
-
* Check if file exists
|
|
619
|
-
*
|
|
620
|
-
* @param path
|
|
621
|
-
* @returns
|
|
622
|
-
*/
|
|
623
|
-
static fileExists(path: string): Promise<boolean>;
|
|
624
|
-
/**
|
|
625
|
-
* Recursively find files starting from given cwd
|
|
626
|
-
*
|
|
627
|
-
* @param name
|
|
628
|
-
* @param extensions
|
|
629
|
-
* @param cwd
|
|
630
|
-
*
|
|
631
|
-
* @returns
|
|
632
|
-
*/
|
|
633
|
-
static resolveFileUp(name: string, extensions: string[] | ((dir: string, filesNames: string[]) => string | false), cwd?: string): string | undefined;
|
|
634
|
-
}
|
|
635
|
-
//#endregion
|
|
636
|
-
//#region src/Utils/Prompts.d.ts
|
|
637
|
-
declare class Prompts extends Logger {
|
|
638
|
-
/**
|
|
639
|
-
* Allows users to pick from a predefined set of choices when asked a question.
|
|
640
|
-
*/
|
|
641
|
-
static choice(
|
|
642
|
-
/**
|
|
643
|
-
* Message to dislpay
|
|
644
|
-
*/
|
|
645
|
-
message: string,
|
|
646
|
-
/**
|
|
647
|
-
* The choices available to the user
|
|
648
|
-
*/
|
|
649
|
-
choices: Choices,
|
|
650
|
-
/**
|
|
651
|
-
* Item index front of which the cursor will initially appear
|
|
652
|
-
*/
|
|
653
|
-
defaultIndex?: number): Promise<string>;
|
|
654
|
-
/**
|
|
655
|
-
* Ask the user for a simple "yes or no" confirmation.
|
|
656
|
-
* By default, this method returns `false`. However, if the user enters y or yes
|
|
657
|
-
* in response to the prompt, the method would return `true`.
|
|
658
|
-
*/
|
|
659
|
-
static confirm(
|
|
660
|
-
/**
|
|
661
|
-
* Message to dislpay
|
|
662
|
-
*/
|
|
663
|
-
message: string,
|
|
664
|
-
/**
|
|
665
|
-
* The default value
|
|
666
|
-
*/
|
|
667
|
-
def?: boolean | undefined): Promise<boolean>;
|
|
668
|
-
/**
|
|
669
|
-
* Prompt the user with the given question, accept their input,
|
|
670
|
-
* and then return the user's input back to your command.
|
|
671
|
-
*/
|
|
672
|
-
static ask(
|
|
673
|
-
/**
|
|
674
|
-
* Message to dislpay
|
|
675
|
-
*/
|
|
676
|
-
message: string,
|
|
677
|
-
/**
|
|
678
|
-
* The default value
|
|
679
|
-
*/
|
|
680
|
-
def?: string | undefined): Promise<string>;
|
|
681
|
-
/**
|
|
682
|
-
* Prompt the user with the given question, accept their input which
|
|
683
|
-
* will not be visible to them as they type in the console,
|
|
684
|
-
* and then return the user's input back to your command.
|
|
685
|
-
*/
|
|
686
|
-
static secret(
|
|
687
|
-
/**
|
|
688
|
-
* Message to dislpay
|
|
689
|
-
*/
|
|
690
|
-
message: string,
|
|
691
|
-
/**
|
|
692
|
-
* Mask the user input
|
|
693
|
-
*
|
|
694
|
-
* @default true
|
|
695
|
-
*/
|
|
696
|
-
mask?: string | boolean): Promise<string>;
|
|
697
|
-
/**
|
|
698
|
-
* Provide auto-completion for possible choices.
|
|
699
|
-
* The user can still provide any answer, regardless of the auto-completion hints.
|
|
700
|
-
*/
|
|
701
|
-
static anticipate(
|
|
702
|
-
/**
|
|
703
|
-
* Message to dislpay
|
|
704
|
-
*/
|
|
705
|
-
message: string,
|
|
706
|
-
/**
|
|
707
|
-
* The source of completions
|
|
708
|
-
*/
|
|
709
|
-
source: string[] | ((input?: string | undefined) => Promise<ChoiceOrSeparatorArray$1<any>>),
|
|
710
|
-
/**
|
|
711
|
-
* Set a default value
|
|
712
|
-
*/
|
|
713
|
-
def?: string): Promise<any>;
|
|
714
|
-
}
|
|
715
|
-
//#endregion
|
|
716
|
-
//#region src/Utils/Resolver.d.ts
|
|
717
|
-
declare class Resolver {
|
|
718
|
-
static getPakageInstallCommand(pkg?: string): Promise<string>;
|
|
719
|
-
static getInstallCommand(pkg: string): Promise<string>;
|
|
720
|
-
/**
|
|
721
|
-
* Create a hash for a function or an object
|
|
722
|
-
*
|
|
723
|
-
* @param provider
|
|
724
|
-
* @returns
|
|
725
|
-
*/
|
|
726
|
-
static hashObjectOrFunction(provider: object | ((..._: any[]) => any)): string;
|
|
727
|
-
}
|
|
728
|
-
//#endregion
|
|
729
|
-
//#region src/Utils/scripts.d.ts
|
|
730
|
-
declare const mainTsconfig: {
|
|
731
|
-
extends: string;
|
|
732
|
-
compilerOptions: {
|
|
733
|
-
baseUrl: string;
|
|
734
|
-
outDir: string;
|
|
735
|
-
paths: {
|
|
736
|
-
'src/*': string[];
|
|
737
|
-
'App/*': string[];
|
|
738
|
-
'root/*': string[];
|
|
739
|
-
'routes/*': string[];
|
|
740
|
-
'config/*': string[];
|
|
741
|
-
'resources/*': string[];
|
|
742
|
-
};
|
|
743
|
-
target: string;
|
|
744
|
-
module: string;
|
|
745
|
-
moduleResolution: string;
|
|
746
|
-
esModuleInterop: boolean;
|
|
747
|
-
strict: boolean;
|
|
748
|
-
allowJs: boolean;
|
|
749
|
-
skipLibCheck: boolean;
|
|
750
|
-
resolveJsonModule: boolean;
|
|
751
|
-
noEmit: boolean;
|
|
752
|
-
experimentalDecorators: boolean;
|
|
753
|
-
emitDecoratorMetadata: boolean;
|
|
754
|
-
};
|
|
755
|
-
include: string[];
|
|
756
|
-
exclude: string[];
|
|
757
|
-
};
|
|
758
|
-
declare const baseTsconfig: {
|
|
759
|
-
extends: string;
|
|
760
|
-
};
|
|
761
|
-
declare const packageJsonScript: {
|
|
762
|
-
build: string;
|
|
763
|
-
dev: string;
|
|
764
|
-
start: string;
|
|
765
|
-
lint: string;
|
|
766
|
-
test: string;
|
|
767
|
-
postinstall: string;
|
|
768
|
-
};
|
|
769
|
-
//#endregion
|
|
770
|
-
//#region src/Utils/TaskManager.d.ts
|
|
771
|
-
declare class TaskManager {
|
|
772
|
-
static taskRunner(description: string, task: (() => Promise<any>) | (() => any)): Promise<void>;
|
|
773
|
-
static advancedTaskRunner<R = any>(info: [[string, string], [string, string]] | [[string, string]], task: (() => Promise<R>) | (() => R)): Promise<R | undefined>;
|
|
774
|
-
}
|
|
775
|
-
//#endregion
|
|
776
|
-
export { Bindings, Choice, type ChoiceOrSeparatorArray, Choices, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, ISeparator, IServiceProvider, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Prompts, Resolver, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
|