@h3ravel/core 1.7.4 → 1.9.0

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,125 +1,232 @@
1
- import { IContainer, UseKey, Bindings, IApplication, PathLoader, IServiceProvider, IPathName, IController, HttpContext, IMiddleware } from '@h3ravel/shared';
2
- import { H3Event } from 'h3';
1
+ import "reflect-metadata";
2
+ import { Bindings, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IServiceProvider, PathLoader, UseKey } from "@h3ravel/shared";
3
+ import { XGeneric } from "@h3ravel/support";
4
+ import { H3, H3Event } from "h3";
5
+ import { Argument, Command } from "commander";
3
6
 
7
+ //#region src/Container.d.ts
4
8
  declare class Container implements IContainer {
5
- private bindings;
6
- private singletons;
7
- /**
8
- * Check if the target has any decorators
9
- *
10
- * @param target
11
- * @returns
12
- */
13
- static hasAnyDecorator(target: Function): boolean;
14
- /**
15
- * Bind a transient service to the container
16
- */
17
- bind<T>(key: new (...args: any[]) => T, factory: () => T): void;
18
- bind<T extends UseKey>(key: T, factory: () => Bindings[T]): void;
19
- /**
20
- * Bind a singleton service to the container
21
- */
22
- singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: () => Bindings[T]): void;
23
- /**
24
- * Resolve a service from the container
25
- */
26
- make<T extends UseKey, X = undefined>(key: T | (new (..._args: any[]) => Bindings[T])): X extends undefined ? Bindings[T] : X;
27
- /**
28
- * Automatically build a class with constructor dependency injection
29
- */
30
- private build;
31
- /**
32
- * Check if a service is registered
33
- */
34
- has(key: UseKey): boolean;
9
+ private bindings;
10
+ private singletons;
11
+ /**
12
+ * Check if the target has any decorators
13
+ *
14
+ * @param target
15
+ * @returns
16
+ */
17
+ static hasAnyDecorator(target: Function): boolean;
18
+ /**
19
+ * Bind a transient service to the container
20
+ */
21
+ bind<T>(key: new (...args: any[]) => T, factory: () => T): void;
22
+ bind<T extends UseKey>(key: T, factory: () => Bindings[T]): void;
23
+ /**
24
+ * Bind a singleton service to the container
25
+ */
26
+ singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: () => Bindings[T]): void;
27
+ /**
28
+ * Resolve a service from the container
29
+ */
30
+ make<T extends UseKey, X = undefined>(key: T | (new (..._args: any[]) => Bindings[T])): X extends undefined ? Bindings[T] : X;
31
+ /**
32
+ * Automatically build a class with constructor dependency injection
33
+ */
34
+ private build;
35
+ /**
36
+ * Check if a service is registered
37
+ */
38
+ has(key: UseKey): boolean;
35
39
  }
36
-
40
+ //#endregion
41
+ //#region src/Application.d.ts
42
+ type AServiceProvider = (new (_app: Application) => IServiceProvider) & IServiceProvider;
37
43
  declare class Application extends Container implements IApplication {
38
- paths: PathLoader;
39
- private booted;
40
- private versions;
41
- private basePath;
42
- private providers;
43
- protected externalProviders: Array<new (_app: Application) => IServiceProvider>;
44
- constructor(basePath: string);
45
- /**
46
- * Register core bindings into the container
47
- */
48
- protected registerBaseBindings(): void;
49
- /**
50
- * Dynamically register all configured providers
51
- */
52
- registerConfiguredProviders(): Promise<void>;
53
- protected loadOptions(): Promise<void>;
54
- /**
55
- * Load default and optional providers dynamically
56
- *
57
- * Auto-Registration Behavior
58
- *
59
- * Minimal App: Loads only core, config, http, router by default.
60
- * Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
61
- */
62
- protected getConfiguredProviders(): Promise<Array<new (_app: Application) => IServiceProvider>>;
63
- protected getAllProviders(): Promise<Array<new (_app: Application) => IServiceProvider>>;
64
- private sortProviders;
65
- registerProviders(providers: Array<new (_app: Application) => IServiceProvider>): void;
66
- /**
67
- * Register a provider
68
- */
69
- register(provider: IServiceProvider): Promise<void>;
70
- /**
71
- * Boot all providers after registration
72
- */
73
- boot(): Promise<void>;
74
- /**
75
- * Attempt to dynamically import an optional module
76
- */
77
- private safeImport;
78
- /**
79
- * Get the base path of the app
80
- *
81
- * @returns
82
- */
83
- getBasePath(): string;
84
- /**
85
- * Dynamically retrieves a path property from the class.
86
- * Any property ending with "Path" is accessible automatically.
87
- *
88
- * @param name - The base name of the path property
89
- * @returns
90
- */
91
- getPath(name: IPathName, pth?: string): string;
92
- /**
93
- * Programatically set the paths.
94
- *
95
- * @param name - The base name of the path property
96
- * @param path - The new path
97
- * @returns
98
- */
99
- setPath(name: IPathName, path: string): void;
100
- /**
101
- * Returns the installed version of the system core and typescript.
102
- *
103
- * @returns
104
- */
105
- getVersion(key: 'app' | 'ts'): string;
44
+ paths: PathLoader;
45
+ private tries;
46
+ private booted;
47
+ private versions;
48
+ private basePath;
49
+ private providers;
50
+ protected externalProviders: Array<new (_app: Application) => IServiceProvider>;
51
+ /**
52
+ * List of registered console commands
53
+ */
54
+ registeredCommands: (new (app: any, kernel: any) => any)[];
55
+ constructor(basePath: string);
56
+ /**
57
+ * Register core bindings into the container
58
+ */
59
+ protected registerBaseBindings(): void;
60
+ /**
61
+ * Dynamically register all configured providers
62
+ */
63
+ registerConfiguredProviders(): Promise<void>;
64
+ protected loadOptions(): Promise<void>;
65
+ /**
66
+ * Get all registered providers
67
+ */
68
+ getRegisteredProviders(): IServiceProvider[];
69
+ /**
70
+ * Load default and optional providers dynamically
71
+ *
72
+ * Auto-Registration Behavior
73
+ *
74
+ * Minimal App: Loads only core, config, http, router by default.
75
+ * Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
76
+ */
77
+ protected getConfiguredProviders(): Promise<Array<AServiceProvider>>;
78
+ protected getAllProviders(): Promise<Array<AServiceProvider>>;
79
+ private sortProviders;
80
+ registerProviders(providers: Array<AServiceProvider>): void;
81
+ /**
82
+ * Register a provider
83
+ */
84
+ register(provider: IServiceProvider): Promise<void>;
85
+ /**
86
+ * checks if the application is running in CLI
87
+ */
88
+ runningInConsole(): boolean;
89
+ getRuntimeEnv(): 'browser' | 'node' | 'unknown';
90
+ /**
91
+ * Boot all service providers after registration
92
+ */
93
+ boot(): Promise<void>;
94
+ /**
95
+ * Fire up the developement server using the user provided arguments
96
+ *
97
+ * Port will be auto assigned if provided one is not available
98
+ *
99
+ * @param h3App The current H3 app instance
100
+ * @param preferedPort If provided, this will overide the port set in the evironment
101
+ */
102
+ fire(h3App: H3, preferedPort?: number): Promise<void>;
103
+ /**
104
+ * Attempt to dynamically import an optional module
105
+ */
106
+ private safeImport;
107
+ /**
108
+ * Get the base path of the app
109
+ *
110
+ * @returns
111
+ */
112
+ getBasePath(): string;
113
+ /**
114
+ * Dynamically retrieves a path property from the class.
115
+ * Any property ending with "Path" is accessible automatically.
116
+ *
117
+ * @param name - The base name of the path property
118
+ * @returns
119
+ */
120
+ getPath(name: IPathName, suffix?: string): string;
121
+ /**
122
+ * Programatically set the paths.
123
+ *
124
+ * @param name - The base name of the path property
125
+ * @param path - The new path
126
+ * @returns
127
+ */
128
+ setPath(name: IPathName, path: string): void;
129
+ /**
130
+ * Returns the installed version of the system core and typescript.
131
+ *
132
+ * @returns
133
+ */
134
+ getVersion(key: 'app' | 'ts'): string;
106
135
  }
107
-
136
+ //#endregion
137
+ //#region src/Console/ConsoleKernel.d.ts
138
+ declare class ConsoleKernel {
139
+ app: Application;
140
+ cwd: string;
141
+ output: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
142
+ basePath: string;
143
+ modulePath: string;
144
+ consolePath: string;
145
+ modulePackage: XGeneric<{
146
+ version: string;
147
+ }>;
148
+ consolePackage: XGeneric<{
149
+ version: string;
150
+ }>;
151
+ constructor(app: Application);
152
+ ensureDirectoryExists(dir: string): Promise<void>;
153
+ }
154
+ //#endregion
155
+ //#region src/Console/ConsoleCommand.d.ts
156
+ declare class ConsoleCommand {
157
+ protected app: Application;
158
+ protected kernel: ConsoleKernel;
159
+ constructor(app: Application, kernel: ConsoleKernel);
160
+ /**
161
+ * The underlying commander instance.
162
+ *
163
+ * @var Command
164
+ */
165
+ program: Command;
166
+ /**
167
+ * The name and signature of the console command.
168
+ *
169
+ * @var string
170
+ */
171
+ protected signature: string;
172
+ /**
173
+ * A dictionary of signatures or what not.
174
+ *
175
+ * @var object
176
+ */
177
+ protected dictionary: Record<string, any>;
178
+ /**
179
+ * The console command description.
180
+ *
181
+ * @var string
182
+ */
183
+ protected description?: string;
184
+ /**
185
+ * The console command input.
186
+ *
187
+ * @var object
188
+ */
189
+ private input;
190
+ /**
191
+ * Execute the console command.
192
+ */
193
+ handle(..._args: any[]): Promise<void>;
194
+ setApplication(app: Application): void;
195
+ setInput(options: XGeneric, args: string[], regArgs: readonly Argument[], dictionary: Record<string, any>, program: Command): void;
196
+ getSignature(): string;
197
+ getDescription(): string | undefined;
198
+ option(key: string, def?: any): any;
199
+ options(key?: string): any;
200
+ argument(key: string, def?: any): any;
201
+ arguments(): Record<string, any>;
202
+ }
203
+ //#endregion
204
+ //#region src/Contracts/ServiceProviderConstructor.d.ts
108
205
  type ServiceProviderConstructor = (new (app: Application) => ServiceProvider) & IServiceProvider;
109
-
206
+ //#endregion
207
+ //#region src/Controller.d.ts
110
208
  /**
111
209
  * Base controller class
112
210
  */
113
211
  declare abstract class Controller implements IController {
114
- protected app: Application;
115
- constructor(app: Application);
116
- show(..._ctx: any[]): any;
117
- index(..._ctx: any[]): any;
118
- store(..._ctx: any[]): any;
119
- update(..._ctx: any[]): any;
120
- destroy(..._ctx: any[]): any;
212
+ protected app: Application;
213
+ constructor(app: Application);
214
+ show(..._ctx: any[]): any;
215
+ index(..._ctx: any[]): any;
216
+ store(..._ctx: any[]): any;
217
+ update(..._ctx: any[]): any;
218
+ destroy(..._ctx: any[]): any;
121
219
  }
122
-
220
+ //#endregion
221
+ //#region src/Di/ContainerResolver.d.ts
222
+ declare class ContainerResolver {
223
+ private app;
224
+ constructor(app: Application);
225
+ resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, _default?: any): Promise<I>;
226
+ static isClass(C: any): boolean;
227
+ }
228
+ //#endregion
229
+ //#region src/Di/Inject.d.ts
123
230
  declare function Inject(...dependencies: string[]): (target: any) => void;
124
231
  /**
125
232
  * Allows binding dependencies to both class and class methods
@@ -127,61 +234,82 @@ declare function Inject(...dependencies: string[]): (target: any) => void;
127
234
  * @returns
128
235
  */
129
236
  declare function Injectable(): ClassDecorator & MethodDecorator;
130
-
237
+ //#endregion
238
+ //#region src/Http/Kernel.d.ts
131
239
  /**
132
240
  * Kernel class handles middleware execution and response transformations.
133
241
  * It acts as the core middleware pipeline for HTTP requests.
134
242
  */
135
243
  declare class Kernel {
136
- protected context: (event: H3Event) => HttpContext;
137
- protected middleware: IMiddleware[];
138
- /**
139
- * @param context - A factory function that converts an H3Event into an HttpContext.
140
- * @param middleware - An array of middleware classes that will be executed in sequence.
141
- */
142
- constructor(context: (event: H3Event) => HttpContext, middleware?: IMiddleware[]);
143
- /**
144
- * Handles an incoming request and passes it through middleware before invoking the next handler.
145
- *
146
- * @param event - The raw H3 event object.
147
- * @param next - A callback function that represents the next layer (usually the controller or final handler).
148
- * @returns A promise resolving to the result of the request pipeline.
149
- */
150
- handle(event: H3Event, next: (ctx: HttpContext) => Promise<unknown>): Promise<unknown>;
151
- /**
152
- * Sequentially runs middleware in the order they were registered.
153
- *
154
- * @param context - The standardized HttpContext.
155
- * @param next - Callback to execute when middleware completes.
156
- * @returns A promise resolving to the final handler's result.
157
- */
158
- private runMiddleware;
159
- /**
160
- * Utility function to determine if a value is a plain object or array.
161
- *
162
- * @param value - The value to check.
163
- * @returns True if the value is a plain object or array, otherwise false.
164
- */
165
- private isPlainObject;
244
+ protected context: (event: H3Event) => HttpContext;
245
+ protected middleware: IMiddleware[];
246
+ /**
247
+ * @param context - A factory function that converts an H3Event into an HttpContext.
248
+ * @param middleware - An array of middleware classes that will be executed in sequence.
249
+ */
250
+ constructor(context: (event: H3Event) => HttpContext, middleware?: IMiddleware[]);
251
+ /**
252
+ * Handles an incoming request and passes it through middleware before invoking the next handler.
253
+ *
254
+ * @param event - The raw H3 event object.
255
+ * @param next - A callback function that represents the next layer (usually the controller or final handler).
256
+ * @returns A promise resolving to the result of the request pipeline.
257
+ */
258
+ handle(event: H3Event, next: (ctx: HttpContext) => Promise<unknown>): Promise<unknown>;
259
+ /**
260
+ * Sequentially runs middleware in the order they were registered.
261
+ *
262
+ * @param context - The standardized HttpContext.
263
+ * @param next - Callback to execute when middleware completes.
264
+ * @returns A promise resolving to the final handler's result.
265
+ */
266
+ private runMiddleware;
267
+ /**
268
+ * Utility function to determine if a value is a plain object or array.
269
+ *
270
+ * @param value - The value to check.
271
+ * @returns True if the value is a plain object or array, otherwise false.
272
+ */
273
+ private isPlainObject;
166
274
  }
167
-
275
+ //#endregion
276
+ //#region src/ServiceProvider.d.ts
168
277
  declare abstract class ServiceProvider implements IServiceProvider {
169
- static order?: `before:${string}` | `after:${string}` | string | undefined;
170
- static priority: number;
171
- protected app: Application;
172
- constructor(app: Application);
173
- /**
174
- * Register bindings to the container.
175
- * Runs before boot().
176
- */
177
- abstract register(): void | Promise<void>;
178
- /**
179
- * Perform post-registration booting of services.
180
- * Runs after all providers have been registered.
181
- */
182
- boot?(): void | Promise<void>;
278
+ /**
279
+ * Sort order
280
+ */
281
+ static order?: `before:${string}` | `after:${string}` | string | undefined;
282
+ /**
283
+ * Sort priority
284
+ */
285
+ static priority: number;
286
+ /**
287
+ * Indicate that this service provider only runs in console
288
+ */
289
+ static console: boolean;
290
+ /**
291
+ * List of registered console commands
292
+ */
293
+ registeredCommands?: (new (app: any, kernel: any) => any)[];
294
+ protected app: Application;
295
+ constructor(app: Application);
296
+ /**
297
+ * Register bindings to the container.
298
+ * Runs before boot().
299
+ */
300
+ abstract register(...app: unknown[]): void | Promise<void>;
301
+ /**
302
+ * Perform post-registration booting of services.
303
+ * Runs after all providers have been registered.
304
+ */
305
+ boot?(...app: unknown[]): void | Promise<void>;
306
+ /**
307
+ * An array of console commands to register.
308
+ */
309
+ commands(commands: (new (app: any, kernel: any) => any)[]): void;
183
310
  }
184
-
311
+ //#endregion
312
+ //#region src/Providers/CoreServiceProvider.d.ts
185
313
  /**
186
314
  * Bootstraps core services and bindings.
187
315
  *
@@ -192,17 +320,28 @@ declare abstract class ServiceProvider implements IServiceProvider {
192
320
  * Auto-Registered
193
321
  */
194
322
  declare class CoreServiceProvider extends ServiceProvider {
195
- static priority: number;
196
- register(): void;
323
+ static priority: number;
324
+ register(): void;
197
325
  }
198
-
326
+ //#endregion
327
+ //#region src/Providers/ViewServiceProvider.d.ts
199
328
  declare class ViewServiceProvider extends ServiceProvider {
200
- static priority: number;
201
- register(): void;
329
+ static priority: number;
330
+ register(): void;
202
331
  }
203
-
332
+ //#endregion
333
+ //#region src/Registerer.d.ts
204
334
  declare class Registerer {
205
- static register(): void;
335
+ private app;
336
+ constructor(app: Application);
337
+ static register(app: Application): void;
338
+ bootRegister(): void;
339
+ private appPath;
340
+ private basePath;
341
+ private publicPath;
342
+ private storagePath;
343
+ private databasePath;
206
344
  }
207
-
208
- export { Application, Container, Controller, CoreServiceProvider, Inject, Injectable, Kernel, Registerer, ServiceProvider, type ServiceProviderConstructor, ViewServiceProvider };
345
+ //#endregion
346
+ export { Application, ConsoleCommand, ConsoleKernel, Container, ContainerResolver, Controller, CoreServiceProvider, Inject, Injectable, Kernel, Registerer, ServiceProvider, ServiceProviderConstructor, ViewServiceProvider };
347
+ //# sourceMappingURL=index.d.ts.map