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