@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/README.md +13 -1
- package/dist/app.globals.d.ts +63 -0
- package/dist/index.cjs +577 -544
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +236 -167
- package/dist/index.d.ts +237 -167
- package/dist/index.js +531 -409
- package/dist/index.js.map +1 -1
- package/package.json +13 -10
- package/dist/globals.d.ts +0 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,125 +1,163 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
196
|
-
|
|
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
|
-
|
|
201
|
-
|
|
260
|
+
static priority: number;
|
|
261
|
+
register(): void;
|
|
202
262
|
}
|
|
203
|
-
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/Registerer.d.ts
|
|
204
265
|
declare class Registerer {
|
|
205
|
-
|
|
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,
|
|
276
|
+
//#endregion
|
|
277
|
+
export { Application, Container, ContainerResolver, Controller, CoreServiceProvider, Inject, Injectable, Kernel, Registerer, ServiceProvider, ServiceProviderConstructor, ViewServiceProvider };
|
|
278
|
+
//# sourceMappingURL=index.d.ts.map
|