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