@h3ravel/core 1.21.7 → 1.22.0-alpha.2
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/env.d.ts +1 -0
- package/dist/index.cjs +771 -320
- package/dist/index.d.ts +493 -148
- package/dist/index.js +746 -313
- package/package.json +6 -5
- package/dist/app.globals.d.ts +0 -84
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,55 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import {
|
|
2
|
+
import { PathLoader } from "@h3ravel/shared";
|
|
3
3
|
import { H3, H3Event } from "h3";
|
|
4
|
-
import {
|
|
4
|
+
import { Bindings, CallableConstructor, ClassConstructor, ConcreteConstructor, ExtractClassMethods, GenericObject, IApplication, IBinding, IBootstraper, IContainer, IController, IHttpContext, IMiddleware, IPathName, IRegisterer, IRouter, IServiceProvider, IUrl, UseKey } from "@h3ravel/contracts";
|
|
5
|
+
import { AppBuilder, Inject, Injectable, MiddlewareHandler, ResponseCodes } from "@h3ravel/foundation";
|
|
6
|
+
import { ServiceProvider } from "@h3ravel/support";
|
|
5
7
|
|
|
6
|
-
//#region src/Contracts/ServiceProviderConstructor.d.ts
|
|
7
|
-
type ServiceProviderConstructor = (new (app: Application) => ServiceProvider) & IServiceProvider;
|
|
8
|
-
type AServiceProvider = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
|
|
9
|
-
type OServiceProvider = (new (_app: Application) => Partial<ServiceProvider>) & Partial<ServiceProvider>;
|
|
10
|
-
//#endregion
|
|
11
8
|
//#region src/Container.d.ts
|
|
12
|
-
|
|
13
|
-
declare class Container implements IContainer {
|
|
9
|
+
declare class Container extends IContainer {
|
|
14
10
|
bindings: Map<IBinding, () => unknown>;
|
|
15
11
|
singletons: Map<IBinding, unknown>;
|
|
12
|
+
middlewareHandler?: MiddlewareHandler;
|
|
13
|
+
/**
|
|
14
|
+
* The current globally available container (if any).
|
|
15
|
+
*/
|
|
16
|
+
protected static instance?: Application;
|
|
17
|
+
/**
|
|
18
|
+
* All of the before resolving callbacks by class type.
|
|
19
|
+
*/
|
|
20
|
+
private beforeResolvingCallbacks;
|
|
21
|
+
/**
|
|
22
|
+
* All of the after resolving callbacks by class type.
|
|
23
|
+
*/
|
|
24
|
+
private afterResolvingCallbacks;
|
|
25
|
+
/**
|
|
26
|
+
* All of the registered rebound callbacks.
|
|
27
|
+
*/
|
|
28
|
+
protected reboundCallbacks: Map<string | (new (...args: any[]) => unknown), ((...args: any[]) => any)[]>;
|
|
29
|
+
/**
|
|
30
|
+
* The container's shared instances.
|
|
31
|
+
*/
|
|
32
|
+
protected instances: Map<string | (new (...args: any[]) => unknown), new (...args: any[]) => any>;
|
|
33
|
+
/**
|
|
34
|
+
* The container's resolved instances.
|
|
35
|
+
*/
|
|
36
|
+
protected resolvedInstances: Map<string | (new (...args: any[]) => unknown), any>;
|
|
37
|
+
/**
|
|
38
|
+
* The registered type alias.
|
|
39
|
+
*/
|
|
40
|
+
protected aliases: Map<string | ClassConstructor, any>;
|
|
41
|
+
/**
|
|
42
|
+
* The registered aliases keyed by the abstract name.
|
|
43
|
+
*/
|
|
44
|
+
protected abstractAliases: Map<string | ClassConstructor, any[]>;
|
|
45
|
+
/**
|
|
46
|
+
* The registered aliases keyed by the abstract name.
|
|
47
|
+
*/
|
|
48
|
+
protected middlewares: Map<string | IMiddleware, IMiddleware>;
|
|
49
|
+
/**
|
|
50
|
+
* The extension closures for services.
|
|
51
|
+
*/
|
|
52
|
+
protected extenders: Map<string | (new (...args: any[]) => unknown), CallableConstructor[]>;
|
|
16
53
|
/**
|
|
17
54
|
* Check if the target has any decorators
|
|
18
55
|
*
|
|
@@ -23,106 +60,317 @@ declare class Container implements IContainer {
|
|
|
23
60
|
static hasAnyDecorator<F extends (...args: any[]) => any>(target: F): boolean;
|
|
24
61
|
/**
|
|
25
62
|
* Bind a transient service to the container
|
|
63
|
+
*
|
|
64
|
+
* @param key
|
|
65
|
+
* @param factory
|
|
26
66
|
*/
|
|
27
67
|
bind<T>(key: new (...args: any[]) => T, factory: () => T): void;
|
|
28
68
|
bind<T extends UseKey>(key: T, factory: () => Bindings[T]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Bind unregistered middlewares to the service container so we can use them later
|
|
71
|
+
*
|
|
72
|
+
* @param key
|
|
73
|
+
* @param middleware
|
|
74
|
+
*/
|
|
75
|
+
bindMiddleware(key: IMiddleware | string, middleware: ConcreteConstructor<IMiddleware>): void;
|
|
76
|
+
/**
|
|
77
|
+
* Get all bound and unregistered middlewares in the service container
|
|
78
|
+
*
|
|
79
|
+
* @param key
|
|
80
|
+
* @param middleware
|
|
81
|
+
*/
|
|
82
|
+
boundMiddlewares(): MapIterator<[string | IMiddleware, IMiddleware]>;
|
|
83
|
+
boundMiddlewares(key: IMiddleware | string): IMiddleware;
|
|
29
84
|
/**
|
|
30
85
|
* Remove one or more transient services from the container
|
|
86
|
+
*
|
|
87
|
+
* @param key
|
|
31
88
|
*/
|
|
32
89
|
unbind<T extends UseKey>(key: T | T[]): void;
|
|
33
90
|
/**
|
|
34
91
|
* Bind a singleton service to the container
|
|
92
|
+
*
|
|
93
|
+
* @param key
|
|
94
|
+
* @param factory
|
|
95
|
+
*/
|
|
96
|
+
singleton<T extends UseKey>(key: T | (new (...args: any[]) => Bindings[T]), factory: (app: this) => Bindings[T]): void;
|
|
97
|
+
singleton<T extends UseKey>(key: T | (abstract new (...args: any[]) => Bindings[T]), factory: (app: this) => Bindings[T]): void;
|
|
98
|
+
singleton<T extends UseKey>(key: T | (new (...args: any[]) => Bindings[T]), factory: abstract new (...args: any[]) => any): void;
|
|
99
|
+
singleton<T extends UseKey>(key: T | (abstract new (...args: any[]) => Bindings[T]), factory: abstract new (...args: any[]) => any): void;
|
|
100
|
+
/**
|
|
101
|
+
* Read reflected param types, resolve dependencies from the container and
|
|
102
|
+
* optionally transform them, finally invoke the specified method on a class instance
|
|
103
|
+
*
|
|
104
|
+
* @param instance
|
|
105
|
+
* @param method
|
|
106
|
+
* @param defaultArgs
|
|
107
|
+
* @param handler
|
|
108
|
+
* @returns
|
|
35
109
|
*/
|
|
36
|
-
|
|
110
|
+
invoke<X extends InstanceType<ClassConstructor>, M extends ExtractClassMethods<X>>(instance: X, method: M, defaultArgs?: any[], handler?: CallableConstructor): Promise<any>;
|
|
37
111
|
/**
|
|
38
|
-
*
|
|
112
|
+
* Read reflected param types, resolve dependencies from the container and return the result
|
|
113
|
+
*
|
|
114
|
+
* @param instance
|
|
115
|
+
* @param method
|
|
116
|
+
*/
|
|
117
|
+
resolveParams<X extends InstanceType<ClassConstructor>, M extends ExtractClassMethods<X>>(instance: X, method: M): any[];
|
|
118
|
+
/**
|
|
119
|
+
* Resolve the gevein service from the container
|
|
120
|
+
*
|
|
121
|
+
* @param key
|
|
39
122
|
*/
|
|
40
123
|
make<T extends UseKey>(key: T): Bindings[T];
|
|
41
124
|
make<C extends abstract new (...args: any[]) => any>(key: C): InstanceType<C>;
|
|
42
125
|
make<F extends (...args: any[]) => any>(key: F): ReturnType<F>;
|
|
126
|
+
/**
|
|
127
|
+
* Resolve the gevein service from the container
|
|
128
|
+
*
|
|
129
|
+
* @param abstract
|
|
130
|
+
* @param raiseEvents
|
|
131
|
+
*/
|
|
132
|
+
resolve(abstract: any, raiseEvents?: boolean): any;
|
|
133
|
+
/**
|
|
134
|
+
* Register a callback to be executed after a service is resolved
|
|
135
|
+
*
|
|
136
|
+
* @param key
|
|
137
|
+
* @param callback
|
|
138
|
+
*/
|
|
139
|
+
afterResolving<T extends UseKey>(key: T, callback: (resolved: Bindings[T], app: this) => void): void;
|
|
140
|
+
afterResolving<T extends abstract new (...args: any[]) => any>(key: T, callback: (resolved: InstanceType<T>, app: this) => void): void;
|
|
141
|
+
/**
|
|
142
|
+
* Register a new before resolving callback for all types.
|
|
143
|
+
*
|
|
144
|
+
* @param key
|
|
145
|
+
* @param callback
|
|
146
|
+
*/
|
|
147
|
+
beforeResolving<T extends UseKey>(key: T, callback: (app: this) => void): void;
|
|
148
|
+
beforeResolving<T extends abstract new (...args: any[]) => any>(key: T, callback: (app: this) => void): void;
|
|
149
|
+
/**
|
|
150
|
+
* Execute all registered beforeResolving callbacks for a given key
|
|
151
|
+
*
|
|
152
|
+
* @param key
|
|
153
|
+
* @param resolved
|
|
154
|
+
*/
|
|
155
|
+
private runBeforeResolvingCallbacks;
|
|
156
|
+
/**
|
|
157
|
+
* Execute all registered afterResolving callbacks for a given key
|
|
158
|
+
*
|
|
159
|
+
* @param key
|
|
160
|
+
* @param resolved
|
|
161
|
+
*/
|
|
162
|
+
private runAfterResolvingCallbacks;
|
|
43
163
|
/**
|
|
44
164
|
* Automatically build a class with constructor dependency injection
|
|
165
|
+
*
|
|
166
|
+
* @param ClassType
|
|
167
|
+
* @returns
|
|
45
168
|
*/
|
|
46
169
|
private build;
|
|
170
|
+
/**
|
|
171
|
+
* Determine if a given string is an alias.
|
|
172
|
+
*
|
|
173
|
+
* @param name
|
|
174
|
+
*/
|
|
175
|
+
isAlias(name: IBinding | string): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Get the alias for an abstract if available.
|
|
178
|
+
*
|
|
179
|
+
* @param abstract
|
|
180
|
+
*/
|
|
181
|
+
getAlias(abstract: any): any;
|
|
182
|
+
/**
|
|
183
|
+
* Get the extender callbacks for a given type.
|
|
184
|
+
*
|
|
185
|
+
* @param abstract
|
|
186
|
+
*/
|
|
187
|
+
protected getExtenders(abstract: string | IBinding): CallableConstructor[];
|
|
188
|
+
/**
|
|
189
|
+
* Remove all of the extender callbacks for a given type.
|
|
190
|
+
*
|
|
191
|
+
* @param abstract
|
|
192
|
+
*/
|
|
193
|
+
forgetExtenders(abstract: string | IBinding): void;
|
|
194
|
+
/**
|
|
195
|
+
* Set the alias for an abstract.
|
|
196
|
+
*
|
|
197
|
+
* @param token
|
|
198
|
+
* @param target
|
|
199
|
+
*/
|
|
200
|
+
alias(key: [string | ClassConstructor, any][]): this;
|
|
201
|
+
alias(key: string | ClassConstructor, target: any): this;
|
|
202
|
+
/**
|
|
203
|
+
* Bind a new callback to an abstract's rebind event.
|
|
204
|
+
*
|
|
205
|
+
* @param abstract
|
|
206
|
+
* @param callback
|
|
207
|
+
*/
|
|
208
|
+
rebinding<T extends UseKey>(key: T | (new (...args: any[]) => Bindings[T]), callback: (app: this, inst: Bindings[T]) => Bindings[T] | void): void;
|
|
209
|
+
rebinding<T extends UseKey>(key: T | (abstract new (...args: any[]) => Bindings[T]), callback: (app: this, inst: Bindings[T]) => Bindings[T] | void): void;
|
|
210
|
+
/**
|
|
211
|
+
* Determine if the given abstract type has been bound.
|
|
212
|
+
*
|
|
213
|
+
* @param string $abstract
|
|
214
|
+
* @returns
|
|
215
|
+
*/
|
|
216
|
+
bound<T extends UseKey>(abstract: T): boolean;
|
|
217
|
+
bound<C extends abstract new (...args: any[]) => any>(abstract: C): boolean;
|
|
218
|
+
bound<F extends (...args: any[]) => any>(abstract: F): boolean;
|
|
47
219
|
/**
|
|
48
220
|
* Check if a service is registered
|
|
221
|
+
*
|
|
222
|
+
* @param key
|
|
223
|
+
* @returns
|
|
49
224
|
*/
|
|
50
|
-
has(key:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//#region src/ServiceProvider.d.ts
|
|
54
|
-
declare const Inference: {
|
|
55
|
-
new (): IServiceProvider;
|
|
56
|
-
};
|
|
57
|
-
declare abstract class ServiceProvider extends Inference {
|
|
225
|
+
has<T extends UseKey>(key: T): boolean;
|
|
226
|
+
has<C extends abstract new (...args: any[]) => any>(key: C): boolean;
|
|
227
|
+
has<F extends (...args: any[]) => any>(key: F): boolean;
|
|
58
228
|
/**
|
|
59
|
-
*
|
|
229
|
+
* Determine if the given abstract type has been resolved.
|
|
230
|
+
*
|
|
231
|
+
* @param abstract
|
|
60
232
|
*/
|
|
61
|
-
|
|
233
|
+
resolved(abstract: IBinding | string): boolean;
|
|
62
234
|
/**
|
|
63
|
-
*
|
|
235
|
+
* "Extend" an abstract type in the container.
|
|
236
|
+
*
|
|
237
|
+
* @param abstract
|
|
238
|
+
* @param closure
|
|
239
|
+
*
|
|
240
|
+
* @throws {InvalidArgumentException}
|
|
64
241
|
*/
|
|
65
|
-
|
|
242
|
+
extend<T extends UseKey>(key: T | (new (...args: any[]) => Bindings[T]), closure: (inst: Bindings[T], app: this) => Bindings[T]): void;
|
|
243
|
+
extend<T extends UseKey>(key: T | (abstract new (...args: any[]) => Bindings[T]), closure: (inst: Bindings[T], app: this) => Bindings[T]): void;
|
|
66
244
|
/**
|
|
67
|
-
*
|
|
245
|
+
* Register an existing instance as shared in the container.
|
|
246
|
+
*
|
|
247
|
+
* @param abstract
|
|
248
|
+
* @param instance
|
|
68
249
|
*/
|
|
69
|
-
|
|
250
|
+
instance<X = any>(key: string, instance: X): X;
|
|
251
|
+
instance<K extends abstract new (...args: any[]) => any, X = any>(abstract: K, instance: X): X;
|
|
70
252
|
/**
|
|
71
|
-
*
|
|
253
|
+
* Call the given method and inject its dependencies.
|
|
254
|
+
*
|
|
255
|
+
* @param callback
|
|
72
256
|
*/
|
|
73
|
-
|
|
257
|
+
call<C extends abstract new (...args: any[]) => any>(callback: C): any | Promise<any>;
|
|
258
|
+
call<F extends (...args: any[]) => any>(callback: F): any | Promise<any>;
|
|
74
259
|
/**
|
|
75
|
-
*
|
|
260
|
+
* Fire the "rebound" callbacks for the given abstract type.
|
|
261
|
+
*
|
|
262
|
+
* @param abstract
|
|
76
263
|
*/
|
|
77
|
-
|
|
264
|
+
protected rebound(abstract: any): void;
|
|
78
265
|
/**
|
|
79
|
-
*
|
|
266
|
+
* Get the rebound callbacks for a given type.
|
|
267
|
+
*
|
|
268
|
+
* @param abstract
|
|
80
269
|
*/
|
|
81
|
-
|
|
82
|
-
constructor(app: Application);
|
|
270
|
+
protected getReboundCallbacks(abstract: any): ((...args: any[]) => any)[];
|
|
83
271
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
272
|
+
* Remove an alias from the contextual binding alias cache.
|
|
273
|
+
*
|
|
274
|
+
* @param searched
|
|
86
275
|
*/
|
|
87
|
-
|
|
276
|
+
protected removeAbstractAlias(searched: string): void;
|
|
88
277
|
/**
|
|
89
|
-
*
|
|
90
|
-
* Runs after all providers have been registered.
|
|
278
|
+
* Get the globally available instance of the container.
|
|
91
279
|
*/
|
|
92
|
-
|
|
280
|
+
static getInstance(): Application;
|
|
93
281
|
/**
|
|
94
|
-
*
|
|
282
|
+
* Set the shared instance of the container.
|
|
95
283
|
*
|
|
96
|
-
* @param
|
|
284
|
+
* @param container
|
|
285
|
+
*/
|
|
286
|
+
static setInstance(container?: Application): Application | undefined;
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/Contracts/H3ravelContract.d.ts
|
|
290
|
+
interface EntryConfig {
|
|
291
|
+
/**
|
|
292
|
+
* @param h3 You can provide your own `H3` app instance, this is usefull when `@h3ravel/http`
|
|
293
|
+
* is not installed.
|
|
294
|
+
*/
|
|
295
|
+
h3?: H3;
|
|
296
|
+
/**
|
|
297
|
+
* @param H3Event You can provide your own `H3Event` app instance, this is usefull for testing scenarios.
|
|
298
|
+
*/
|
|
299
|
+
h3Event?: H3Event;
|
|
300
|
+
/**
|
|
301
|
+
* Determines if we should initialize the app on call.
|
|
97
302
|
*
|
|
98
|
-
* @
|
|
303
|
+
* @default false
|
|
99
304
|
*/
|
|
100
|
-
|
|
305
|
+
initialize?: boolean;
|
|
101
306
|
/**
|
|
102
|
-
*
|
|
307
|
+
* Determines if service providers should be auto discovered and registered or not.
|
|
103
308
|
*
|
|
104
|
-
* @
|
|
309
|
+
* @default false
|
|
310
|
+
*/
|
|
311
|
+
autoload?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* A list of service provider name strings we do not want to register at all cost
|
|
314
|
+
*
|
|
315
|
+
* @default []
|
|
105
316
|
*/
|
|
106
|
-
|
|
317
|
+
filteredProviders?: string[];
|
|
318
|
+
/**
|
|
319
|
+
* Overide the defined system path
|
|
320
|
+
*/
|
|
321
|
+
customPaths?: Partial<Record<'base' | 'views' | 'assets' | 'routes' | 'config' | 'public' | 'storage' | 'database', string>>;
|
|
107
322
|
}
|
|
108
323
|
//#endregion
|
|
109
324
|
//#region src/Application.d.ts
|
|
110
325
|
declare class Application extends Container implements IApplication {
|
|
326
|
+
#private;
|
|
327
|
+
protected initializer?: string | undefined;
|
|
111
328
|
paths: PathLoader;
|
|
112
|
-
context?: (event: H3Event) => Promise<
|
|
329
|
+
context?: (event: H3Event) => Promise<IHttpContext>;
|
|
330
|
+
h3Event?: H3Event;
|
|
113
331
|
private tries;
|
|
114
|
-
private booted;
|
|
115
332
|
private basePath;
|
|
116
333
|
private versions;
|
|
334
|
+
private namespace?;
|
|
117
335
|
private static versions;
|
|
336
|
+
private h3App?;
|
|
118
337
|
private providers;
|
|
119
|
-
protected externalProviders: Array<
|
|
338
|
+
protected externalProviders: Array<ConcreteConstructor<IServiceProvider, false>>;
|
|
120
339
|
protected filteredProviders: Array<string>;
|
|
340
|
+
private autoRegisterProviders;
|
|
341
|
+
/**
|
|
342
|
+
* The route resolver callback.
|
|
343
|
+
*/
|
|
344
|
+
protected uriResolver?: () => typeof IUrl;
|
|
121
345
|
/**
|
|
122
346
|
* List of registered console commands
|
|
123
347
|
*/
|
|
124
348
|
registeredCommands: (new (app: any, kernel: any) => any)[];
|
|
125
|
-
|
|
349
|
+
/**
|
|
350
|
+
* The array of booted callbacks.
|
|
351
|
+
*/
|
|
352
|
+
protected bootedCallbacks: Array<(app: this) => void>;
|
|
353
|
+
/**
|
|
354
|
+
* The array of booting callbacks.
|
|
355
|
+
*/
|
|
356
|
+
protected bootingCallbacks: Array<(app: this) => void>;
|
|
357
|
+
/**
|
|
358
|
+
* The array of terminating callbacks.
|
|
359
|
+
*/
|
|
360
|
+
protected terminatingCallbacks: Array<(app: this) => void>;
|
|
361
|
+
/**
|
|
362
|
+
* Indicates if the application has been bootstrapped before.
|
|
363
|
+
*/
|
|
364
|
+
protected bootstrapped: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Controls logging
|
|
367
|
+
*/
|
|
368
|
+
private logsDisabled;
|
|
369
|
+
/**
|
|
370
|
+
* The conrrent HttpContext
|
|
371
|
+
*/
|
|
372
|
+
private httpContext?;
|
|
373
|
+
constructor(basePath: string, initializer?: string | undefined);
|
|
126
374
|
/**
|
|
127
375
|
* Register core bindings into the container
|
|
128
376
|
*/
|
|
@@ -131,7 +379,7 @@ declare class Application extends Container implements IApplication {
|
|
|
131
379
|
/**
|
|
132
380
|
* Get all registered providers
|
|
133
381
|
*/
|
|
134
|
-
getRegisteredProviders():
|
|
382
|
+
getRegisteredProviders(): IServiceProvider[];
|
|
135
383
|
/**
|
|
136
384
|
* Load default and optional providers dynamically
|
|
137
385
|
*
|
|
@@ -140,8 +388,8 @@ declare class Application extends Container implements IApplication {
|
|
|
140
388
|
* Minimal App: Loads only core, config, http, router by default.
|
|
141
389
|
* Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
|
|
142
390
|
*/
|
|
143
|
-
protected getConfiguredProviders(): Promise<
|
|
144
|
-
protected getAllProviders(): Promise<Array<
|
|
391
|
+
protected getConfiguredProviders(): Promise<ConcreteConstructor<IServiceProvider, false>[]>;
|
|
392
|
+
protected getAllProviders(): Promise<Array<ConcreteConstructor<IServiceProvider, false>>>;
|
|
145
393
|
/**
|
|
146
394
|
* Configure and Dynamically register all configured service providers, then boot the app.
|
|
147
395
|
*
|
|
@@ -151,24 +399,22 @@ declare class Application extends Container implements IApplication {
|
|
|
151
399
|
*
|
|
152
400
|
* @returns
|
|
153
401
|
*/
|
|
154
|
-
|
|
402
|
+
initialize(providers: Array<ConcreteConstructor<IServiceProvider, false>>, filtered?: string[], autoRegisterProviders?: boolean): this;
|
|
155
403
|
/**
|
|
156
404
|
* Dynamically register all configured providers
|
|
157
|
-
*
|
|
158
|
-
* @param autoRegister If set to false, service providers will not be auto discovered and registered.
|
|
159
405
|
*/
|
|
160
|
-
registerConfiguredProviders(
|
|
406
|
+
registerConfiguredProviders(): Promise<void>;
|
|
161
407
|
/**
|
|
162
408
|
* Register service providers
|
|
163
409
|
*
|
|
164
410
|
* @param providers
|
|
165
411
|
* @param filtered
|
|
166
412
|
*/
|
|
167
|
-
registerProviders(providers: Array<
|
|
413
|
+
registerProviders(providers: Array<ConcreteConstructor<IServiceProvider, false>>, filtered?: string[]): void;
|
|
168
414
|
/**
|
|
169
415
|
* Register a provider
|
|
170
416
|
*/
|
|
171
|
-
register(provider:
|
|
417
|
+
register(provider: IServiceProvider): Promise<void>;
|
|
172
418
|
/**
|
|
173
419
|
* Register the listed service providers.
|
|
174
420
|
*
|
|
@@ -179,11 +425,103 @@ declare class Application extends Container implements IApplication {
|
|
|
179
425
|
* checks if the application is running in CLI
|
|
180
426
|
*/
|
|
181
427
|
runningInConsole(): boolean;
|
|
428
|
+
/**
|
|
429
|
+
* checks if the application is running in Unit Test
|
|
430
|
+
*/
|
|
431
|
+
runningUnitTests(): boolean;
|
|
182
432
|
getRuntimeEnv(): 'browser' | 'node' | 'unknown';
|
|
433
|
+
/**
|
|
434
|
+
* Determine if the application has booted.
|
|
435
|
+
*/
|
|
436
|
+
isBooted(): boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Determine if the application has booted.
|
|
439
|
+
*/
|
|
440
|
+
logging(logging?: boolean): this;
|
|
441
|
+
protected logsEnabled(): boolean;
|
|
183
442
|
/**
|
|
184
443
|
* Boot all service providers after registration
|
|
185
444
|
*/
|
|
186
445
|
boot(): Promise<this>;
|
|
446
|
+
/**
|
|
447
|
+
* Register a new boot listener.
|
|
448
|
+
*
|
|
449
|
+
* @param callable $callback
|
|
450
|
+
*/
|
|
451
|
+
booting(callback: (app: this) => void): void;
|
|
452
|
+
/**
|
|
453
|
+
* Register a new "booted" listener.
|
|
454
|
+
*
|
|
455
|
+
* @param callback
|
|
456
|
+
*/
|
|
457
|
+
booted(callback: (app: this) => void): void;
|
|
458
|
+
/**
|
|
459
|
+
* Throw an HttpException with the given data.
|
|
460
|
+
*
|
|
461
|
+
* @param code
|
|
462
|
+
* @param message
|
|
463
|
+
* @param headers
|
|
464
|
+
*
|
|
465
|
+
* @throws {HttpException}
|
|
466
|
+
* @throws {NotFoundHttpException}
|
|
467
|
+
*/
|
|
468
|
+
abort(code: ResponseCodes, message?: string, headers?: GenericObject): void;
|
|
469
|
+
/**
|
|
470
|
+
* Register a terminating callback with the application.
|
|
471
|
+
*
|
|
472
|
+
* @param callback
|
|
473
|
+
*/
|
|
474
|
+
terminating(callback: (app: this) => void): this;
|
|
475
|
+
/**
|
|
476
|
+
* Terminate the application.
|
|
477
|
+
*/
|
|
478
|
+
terminate(): void;
|
|
479
|
+
/**
|
|
480
|
+
* Call the booting callbacks for the application.
|
|
481
|
+
*
|
|
482
|
+
* @param callbacks
|
|
483
|
+
*/
|
|
484
|
+
protected fireAppCallbacks(callbacks: Array<(app: this) => void>): void;
|
|
485
|
+
/**
|
|
486
|
+
* Handle the incoming HTTP request and send the response to the browser.
|
|
487
|
+
*
|
|
488
|
+
* @param config Configuration option to pass to the initializer
|
|
489
|
+
*/
|
|
490
|
+
handleRequest(config?: EntryConfig): Promise<void>;
|
|
491
|
+
/**
|
|
492
|
+
* Build the http context
|
|
493
|
+
*
|
|
494
|
+
* @param event
|
|
495
|
+
* @param config
|
|
496
|
+
* @returns
|
|
497
|
+
*/
|
|
498
|
+
buildContext(event: H3Event, config?: EntryConfig, fresh?: boolean): Promise<IHttpContext>;
|
|
499
|
+
/**
|
|
500
|
+
* Handle the incoming Artisan command.
|
|
501
|
+
*/
|
|
502
|
+
handleCommand(): Promise<number>;
|
|
503
|
+
/**
|
|
504
|
+
* Get the URI resolver callback.
|
|
505
|
+
*/
|
|
506
|
+
getUriResolver(): () => typeof IUrl | undefined;
|
|
507
|
+
/**
|
|
508
|
+
* Set the URI resolver callback.
|
|
509
|
+
*
|
|
510
|
+
* @param callback
|
|
511
|
+
*/
|
|
512
|
+
setUriResolver(callback: () => typeof IUrl): this;
|
|
513
|
+
/**
|
|
514
|
+
* Determine if middleware has been disabled for the application.
|
|
515
|
+
*/
|
|
516
|
+
shouldSkipMiddleware(): boolean;
|
|
517
|
+
/**
|
|
518
|
+
* Provide safe overides for the app
|
|
519
|
+
*/
|
|
520
|
+
configure(): AppBuilder;
|
|
521
|
+
/**
|
|
522
|
+
* Check if the current application environment matches the one provided
|
|
523
|
+
*/
|
|
524
|
+
environment<E = string | undefined>(env: E): E extends undefined ? string : boolean;
|
|
187
525
|
/**
|
|
188
526
|
* Fire up the developement server using the user provided arguments
|
|
189
527
|
*
|
|
@@ -191,9 +529,62 @@ declare class Application extends Container implements IApplication {
|
|
|
191
529
|
*
|
|
192
530
|
* @param h3App The current H3 app instance
|
|
193
531
|
* @param preferedPort If provided, this will overide the port set in the evironment
|
|
532
|
+
* @alias serve
|
|
194
533
|
*/
|
|
195
534
|
fire(): Promise<this>;
|
|
196
535
|
fire(h3App: H3, preferredPort?: number): Promise<this>;
|
|
536
|
+
/**
|
|
537
|
+
* Fire up the developement server using the user provided arguments
|
|
538
|
+
*
|
|
539
|
+
* Port will be auto assigned if provided one is not available
|
|
540
|
+
*
|
|
541
|
+
* @param h3App The current H3 app instance
|
|
542
|
+
* @param preferedPort If provided, this will overide the port set in the evironment
|
|
543
|
+
*/
|
|
544
|
+
serve(h3App?: H3, preferredPort?: number): Promise<this>;
|
|
545
|
+
/**
|
|
546
|
+
* Run the given array of bootstrap classes.
|
|
547
|
+
*
|
|
548
|
+
* @param bootstrappers
|
|
549
|
+
*/
|
|
550
|
+
bootstrapWith(bootstrappers: ConcreteConstructor<IBootstraper>[]): Promise<void>;
|
|
551
|
+
/**
|
|
552
|
+
* Determine if the application has been bootstrapped before.
|
|
553
|
+
*/
|
|
554
|
+
hasBeenBootstrapped(): boolean;
|
|
555
|
+
/**
|
|
556
|
+
* Save the curretn H3 instance for possible future use.
|
|
557
|
+
*
|
|
558
|
+
* @param h3App The current H3 app instance
|
|
559
|
+
* @returns
|
|
560
|
+
*/
|
|
561
|
+
setH3App(h3App?: H3): this;
|
|
562
|
+
/**
|
|
563
|
+
* Set the HttpContext.
|
|
564
|
+
*
|
|
565
|
+
* @param ctx
|
|
566
|
+
*/
|
|
567
|
+
setHttpContext(ctx: IHttpContext): this;
|
|
568
|
+
/**
|
|
569
|
+
* Get the HttpContext.
|
|
570
|
+
*/
|
|
571
|
+
getHttpContext(): IHttpContext | undefined;
|
|
572
|
+
/**
|
|
573
|
+
* @param key
|
|
574
|
+
*/
|
|
575
|
+
getHttpContext<K extends keyof IHttpContext>(key: K): IHttpContext[K];
|
|
576
|
+
/**
|
|
577
|
+
* Get the application namespace.
|
|
578
|
+
*
|
|
579
|
+
* @throws {RuntimeException}
|
|
580
|
+
*/
|
|
581
|
+
getNamespace(): string;
|
|
582
|
+
/**
|
|
583
|
+
* Get the path of the app dir
|
|
584
|
+
*
|
|
585
|
+
* @returns
|
|
586
|
+
*/
|
|
587
|
+
path(): string;
|
|
197
588
|
/**
|
|
198
589
|
* Get the base path of the app
|
|
199
590
|
*
|
|
@@ -230,68 +621,18 @@ declare class Application extends Container implements IApplication {
|
|
|
230
621
|
static getVersion(key: string): string;
|
|
231
622
|
}
|
|
232
623
|
//#endregion
|
|
233
|
-
//#region src/Contracts/
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
* is not installed.
|
|
238
|
-
*/
|
|
239
|
-
h3?: H3;
|
|
240
|
-
/**
|
|
241
|
-
* Determines if we should initialize the app on call.
|
|
242
|
-
*
|
|
243
|
-
* @default false
|
|
244
|
-
*/
|
|
245
|
-
initialize?: boolean;
|
|
246
|
-
/**
|
|
247
|
-
* Determines if service providers should be auto discovered and registered or not.
|
|
248
|
-
*
|
|
249
|
-
* @default false
|
|
250
|
-
*/
|
|
251
|
-
autoload?: boolean;
|
|
252
|
-
/**
|
|
253
|
-
* A list of service provider name strings we do not want to register at all cost
|
|
254
|
-
*
|
|
255
|
-
* @default []
|
|
256
|
-
*/
|
|
257
|
-
filteredProviders?: string[];
|
|
258
|
-
}
|
|
624
|
+
//#region src/Contracts/ServiceProviderConstructor.d.ts
|
|
625
|
+
type ServiceProviderConstructor = (new (app: Application) => ServiceProvider) & IServiceProvider;
|
|
626
|
+
type AServiceProvider = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
|
|
627
|
+
type OServiceProvider = (new (_app: Application) => Partial<ServiceProvider>) & Partial<ServiceProvider>;
|
|
259
628
|
//#endregion
|
|
260
629
|
//#region src/Controller.d.ts
|
|
261
630
|
/**
|
|
262
631
|
* Base controller class
|
|
263
632
|
*/
|
|
264
|
-
declare abstract class Controller
|
|
633
|
+
declare abstract class Controller extends IController {
|
|
265
634
|
protected app: Application;
|
|
266
|
-
constructor(app
|
|
267
|
-
show?(..._ctx: any[]): any;
|
|
268
|
-
index?(..._ctx: any[]): any;
|
|
269
|
-
store?(..._ctx: any[]): any;
|
|
270
|
-
update?(..._ctx: any[]): any;
|
|
271
|
-
destroy?(..._ctx: any[]): any;
|
|
272
|
-
}
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region src/Di/ContainerResolver.d.ts
|
|
275
|
-
declare class ContainerResolver {
|
|
276
|
-
private app;
|
|
277
|
-
constructor(app: Application);
|
|
278
|
-
resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, ..._default: any[]): Promise<I>;
|
|
279
|
-
static isClass(C: any): boolean;
|
|
280
|
-
}
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/Di/Inject.d.ts
|
|
283
|
-
declare function Inject(...dependencies: string[]): (target: any) => void;
|
|
284
|
-
/**
|
|
285
|
-
* Allows binding dependencies to both class and class methods
|
|
286
|
-
*
|
|
287
|
-
* @returns
|
|
288
|
-
*/
|
|
289
|
-
declare function Injectable(): ClassDecorator & MethodDecorator;
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/Exceptions/ConfigException.d.ts
|
|
292
|
-
declare class ConfigException extends Error {
|
|
293
|
-
key: string;
|
|
294
|
-
constructor(key: string, type?: 'any' | 'config' | 'env', cause?: unknown);
|
|
635
|
+
constructor(app?: Application);
|
|
295
636
|
}
|
|
296
637
|
//#endregion
|
|
297
638
|
//#region src/H3ravel.d.ts
|
|
@@ -314,11 +655,7 @@ basePath?: string,
|
|
|
314
655
|
/**
|
|
315
656
|
* Configuration option to pass to the initializer
|
|
316
657
|
*/
|
|
317
|
-
config?: EntryConfig
|
|
318
|
-
/**
|
|
319
|
-
* final middleware function to call once the server is fired up
|
|
320
|
-
*/
|
|
321
|
-
middleware?: (ctx: HttpContext$1) => Promise<unknown>) => Promise<Application>;
|
|
658
|
+
config?: EntryConfig) => Promise<Application>;
|
|
322
659
|
//#endregion
|
|
323
660
|
//#region src/Http/Kernel.d.ts
|
|
324
661
|
/**
|
|
@@ -326,13 +663,22 @@ middleware?: (ctx: HttpContext$1) => Promise<unknown>) => Promise<Application>;
|
|
|
326
663
|
* It acts as the core middleware pipeline for HTTP requests.
|
|
327
664
|
*/
|
|
328
665
|
declare class Kernel {
|
|
329
|
-
|
|
330
|
-
|
|
666
|
+
app: Application;
|
|
667
|
+
middleware: IMiddleware[];
|
|
331
668
|
/**
|
|
332
|
-
*
|
|
669
|
+
* The router instance.
|
|
670
|
+
*/
|
|
671
|
+
protected router: IRouter;
|
|
672
|
+
/**
|
|
673
|
+
* A factory function that converts an H3Event into an HttpContext.
|
|
674
|
+
*/
|
|
675
|
+
protected context: (event: H3Event) => IHttpContext | Promise<IHttpContext>;
|
|
676
|
+
protected applicationContext: IHttpContext;
|
|
677
|
+
/**
|
|
678
|
+
* @param app - The current application instance
|
|
333
679
|
* @param middleware - An array of middleware classes that will be executed in sequence.
|
|
334
680
|
*/
|
|
335
|
-
constructor(
|
|
681
|
+
constructor(app: Application, middleware?: IMiddleware[]);
|
|
336
682
|
/**
|
|
337
683
|
* Handles an incoming request and passes it through middleware before invoking the next handler.
|
|
338
684
|
*
|
|
@@ -340,26 +686,25 @@ declare class Kernel {
|
|
|
340
686
|
* @param next - A callback function that represents the next layer (usually the controller or final handler).
|
|
341
687
|
* @returns A promise resolving to the result of the request pipeline.
|
|
342
688
|
*/
|
|
343
|
-
handle(event: H3Event, next: (ctx:
|
|
689
|
+
handle(event: H3Event, next: (ctx: IHttpContext) => Promise<unknown>): Promise<unknown>;
|
|
344
690
|
/**
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
* @param context - The standardized HttpContext.
|
|
348
|
-
* @param next - Callback to execute when middleware completes.
|
|
349
|
-
* @returns A promise resolving to the final handler's result.
|
|
691
|
+
* Resolve the provided callback using the current H3 event instance
|
|
350
692
|
*/
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
693
|
+
resolve(event: H3Event, middleware: IMiddleware | IMiddleware[], handler: (ctx: IHttpContext) => Promise<any>): Promise<any>;
|
|
694
|
+
}
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region src/Manager/ContainerResolver.d.ts
|
|
697
|
+
type Predicate = string | ((...args: any[]) => any) | (abstract new (...args: any[]) => any);
|
|
698
|
+
declare class ContainerResolver {
|
|
699
|
+
private app;
|
|
700
|
+
constructor(app: IApplication);
|
|
701
|
+
resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, ..._default: any[]): Promise<I>;
|
|
702
|
+
static isClass(C: Predicate): C is new (...args: any[]) => any;
|
|
703
|
+
static isAbstract(C: Predicate): C is new (...args: any[]) => any;
|
|
704
|
+
static isCallable(C: Predicate): C is (...args: any[]) => any;
|
|
359
705
|
}
|
|
360
706
|
//#endregion
|
|
361
707
|
//#region src/ProviderRegistry.d.ts
|
|
362
|
-
type ProviderCtor = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
|
|
363
708
|
declare class ProviderRegistry {
|
|
364
709
|
private static providers;
|
|
365
710
|
private static priorityMap;
|
|
@@ -385,14 +730,14 @@ declare class ProviderRegistry {
|
|
|
385
730
|
* @param providers
|
|
386
731
|
* @returns
|
|
387
732
|
*/
|
|
388
|
-
static register(...providers:
|
|
733
|
+
static register(...providers: ConcreteConstructor<IServiceProvider, false>[]): void;
|
|
389
734
|
/**
|
|
390
735
|
* Bulk register providers from an array.
|
|
391
736
|
*
|
|
392
737
|
* @param providers
|
|
393
738
|
* @returns
|
|
394
739
|
*/
|
|
395
|
-
static registerMany(providers:
|
|
740
|
+
static registerMany(providers: ConcreteConstructor<IServiceProvider, false>[]): void;
|
|
396
741
|
/**
|
|
397
742
|
* Set the filtered providers.
|
|
398
743
|
*
|
|
@@ -405,14 +750,14 @@ declare class ProviderRegistry {
|
|
|
405
750
|
* @param app
|
|
406
751
|
* @returns
|
|
407
752
|
*/
|
|
408
|
-
static resolve(app: Application, useServiceContainer?: boolean): Promise<
|
|
753
|
+
static resolve(app: Application, useServiceContainer?: boolean): Promise<IServiceProvider[]>;
|
|
409
754
|
/**
|
|
410
755
|
* Sort the service providers
|
|
411
756
|
*
|
|
412
757
|
* @param providers
|
|
413
758
|
* @returns
|
|
414
759
|
*/
|
|
415
|
-
static sort(providers:
|
|
760
|
+
static sort(providers: ConcreteConstructor<IServiceProvider, false>[]): ConcreteConstructor<IServiceProvider, false>[];
|
|
416
761
|
/**
|
|
417
762
|
* Sort service providers
|
|
418
763
|
*/
|
|
@@ -422,27 +767,27 @@ declare class ProviderRegistry {
|
|
|
422
767
|
*
|
|
423
768
|
* @param priorityMap
|
|
424
769
|
*/
|
|
425
|
-
static log<P extends
|
|
770
|
+
static log<P extends IServiceProvider>(providers?: Array<P> | Map<string, P>, enabled?: boolean): void;
|
|
426
771
|
/**
|
|
427
772
|
* Get all registered providers as an array.
|
|
428
773
|
*
|
|
429
774
|
* @returns
|
|
430
775
|
*/
|
|
431
|
-
static all():
|
|
776
|
+
static all(): ConcreteConstructor<IServiceProvider, false>[];
|
|
432
777
|
/**
|
|
433
778
|
* Check if a provider is already registered.
|
|
434
779
|
*
|
|
435
780
|
* @param provider
|
|
436
781
|
* @returns
|
|
437
782
|
*/
|
|
438
|
-
static has(provider:
|
|
783
|
+
static has(provider: ConcreteConstructor<IServiceProvider, false>): boolean;
|
|
439
784
|
/**
|
|
440
785
|
* Automatically search for and discover service providers in packages.
|
|
441
786
|
*
|
|
442
787
|
* @param autoRegister
|
|
443
788
|
* @returns
|
|
444
789
|
*/
|
|
445
|
-
static discoverProviders(autoRegister?: boolean): Promise<
|
|
790
|
+
static discoverProviders(autoRegister?: boolean): Promise<ConcreteConstructor<IServiceProvider, false>[]>;
|
|
446
791
|
/**
|
|
447
792
|
* Get the content of the package.json file
|
|
448
793
|
*
|
|
@@ -469,7 +814,7 @@ declare class CoreServiceProvider extends ServiceProvider {
|
|
|
469
814
|
}
|
|
470
815
|
//#endregion
|
|
471
816
|
//#region src/Registerer.d.ts
|
|
472
|
-
declare class Registerer {
|
|
817
|
+
declare class Registerer extends IRegisterer {
|
|
473
818
|
private app;
|
|
474
819
|
constructor(app: Application);
|
|
475
820
|
static register(app: Application): void;
|
|
@@ -481,4 +826,4 @@ declare class Registerer {
|
|
|
481
826
|
private databasePath;
|
|
482
827
|
}
|
|
483
828
|
//#endregion
|
|
484
|
-
export { AServiceProvider, Application,
|
|
829
|
+
export { AServiceProvider, Application, Container, ContainerResolver, Controller, CoreServiceProvider, EntryConfig, Inject, Injectable, Kernel, OServiceProvider, ProviderRegistry, Registerer, ServiceProvider, ServiceProviderConstructor, h3ravel };
|