@h3ravel/core 1.29.0-alpha.13 → 1.29.0-alpha.15
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 +840 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,841 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
|
+
import { PathLoader } from "@h3ravel/shared";
|
|
3
|
+
import { H3, H3Event } from "h3";
|
|
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";
|
|
7
|
+
|
|
8
|
+
//#region src/Container.d.ts
|
|
9
|
+
declare class Container extends IContainer {
|
|
10
|
+
bindings: Map<IBinding, () => unknown>;
|
|
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[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Check if the target has any decorators
|
|
55
|
+
*
|
|
56
|
+
* @param target
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
static hasAnyDecorator<C extends abstract new (...args: any[]) => any>(target: C): boolean;
|
|
60
|
+
static hasAnyDecorator<F extends (...args: any[]) => any>(target: F): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Bind a transient service to the container
|
|
63
|
+
*
|
|
64
|
+
* @param key
|
|
65
|
+
* @param factory
|
|
66
|
+
*/
|
|
67
|
+
bind<T>(key: new (...args: any[]) => T, factory: () => T): void;
|
|
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;
|
|
84
|
+
/**
|
|
85
|
+
* Remove one or more transient services from the container
|
|
86
|
+
*
|
|
87
|
+
* @param key
|
|
88
|
+
*/
|
|
89
|
+
unbind<T extends UseKey>(key: T | T[]): void;
|
|
90
|
+
/**
|
|
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
|
|
109
|
+
*/
|
|
110
|
+
invoke<X extends InstanceType<ClassConstructor>, M extends ExtractClassMethods<X>>(instance: X, method: M, defaultArgs?: any[], handler?: CallableConstructor): Promise<any>;
|
|
111
|
+
/**
|
|
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
|
|
122
|
+
*/
|
|
123
|
+
make<T extends UseKey>(key: T): Bindings[T];
|
|
124
|
+
make<C extends abstract new (...args: any[]) => any>(key: C): InstanceType<C>;
|
|
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;
|
|
163
|
+
/**
|
|
164
|
+
* Automatically build a class with constructor dependency injection
|
|
165
|
+
*
|
|
166
|
+
* @param ClassType
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
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;
|
|
219
|
+
/**
|
|
220
|
+
* Check if a service is registered
|
|
221
|
+
*
|
|
222
|
+
* @param key
|
|
223
|
+
* @returns
|
|
224
|
+
*/
|
|
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;
|
|
228
|
+
/**
|
|
229
|
+
* Determine if the given abstract type has been resolved.
|
|
230
|
+
*
|
|
231
|
+
* @param abstract
|
|
232
|
+
*/
|
|
233
|
+
resolved(abstract: IBinding | string): boolean;
|
|
234
|
+
/**
|
|
235
|
+
* "Extend" an abstract type in the container.
|
|
236
|
+
*
|
|
237
|
+
* @param abstract
|
|
238
|
+
* @param closure
|
|
239
|
+
*
|
|
240
|
+
* @throws {InvalidArgumentException}
|
|
241
|
+
*/
|
|
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;
|
|
244
|
+
/**
|
|
245
|
+
* Register an existing instance as shared in the container.
|
|
246
|
+
*
|
|
247
|
+
* @param abstract
|
|
248
|
+
* @param instance
|
|
249
|
+
*/
|
|
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;
|
|
252
|
+
/**
|
|
253
|
+
* Call the given method and inject its dependencies.
|
|
254
|
+
*
|
|
255
|
+
* @param callback
|
|
256
|
+
*/
|
|
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>;
|
|
259
|
+
/**
|
|
260
|
+
* Fire the "rebound" callbacks for the given abstract type.
|
|
261
|
+
*
|
|
262
|
+
* @param abstract
|
|
263
|
+
*/
|
|
264
|
+
protected rebound(abstract: any): void;
|
|
265
|
+
/**
|
|
266
|
+
* Get the rebound callbacks for a given type.
|
|
267
|
+
*
|
|
268
|
+
* @param abstract
|
|
269
|
+
*/
|
|
270
|
+
protected getReboundCallbacks(abstract: any): ((...args: any[]) => any)[];
|
|
271
|
+
/**
|
|
272
|
+
* Remove an alias from the contextual binding alias cache.
|
|
273
|
+
*
|
|
274
|
+
* @param searched
|
|
275
|
+
*/
|
|
276
|
+
protected removeAbstractAlias(searched: string): void;
|
|
277
|
+
/**
|
|
278
|
+
* Get the globally available instance of the container.
|
|
279
|
+
*/
|
|
280
|
+
static getInstance(): Application;
|
|
281
|
+
/**
|
|
282
|
+
* Set the shared instance of the container.
|
|
283
|
+
*
|
|
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.
|
|
302
|
+
*
|
|
303
|
+
* @default false
|
|
304
|
+
*/
|
|
305
|
+
initialize?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Determines if service providers should be auto discovered and registered or not.
|
|
308
|
+
*
|
|
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 []
|
|
316
|
+
*/
|
|
317
|
+
filteredProviders?: string[];
|
|
318
|
+
/**
|
|
319
|
+
* Overide the defined system path
|
|
320
|
+
*/
|
|
321
|
+
customPaths?: Partial<Record<'base' | 'views' | 'assets' | 'routes' | 'config' | 'public' | 'storage' | 'database', string>>;
|
|
322
|
+
}
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/Application.d.ts
|
|
325
|
+
declare class Application extends Container implements IApplication {
|
|
326
|
+
#private;
|
|
327
|
+
protected initializer?: string | undefined;
|
|
328
|
+
paths: PathLoader;
|
|
329
|
+
context?: (event: H3Event) => Promise<IHttpContext>;
|
|
330
|
+
h3Event?: H3Event;
|
|
331
|
+
private tries;
|
|
332
|
+
private basePath;
|
|
333
|
+
private versions;
|
|
334
|
+
private namespace?;
|
|
335
|
+
private static versions;
|
|
336
|
+
private h3App?;
|
|
337
|
+
private providers;
|
|
338
|
+
protected externalProviders: Array<ConcreteConstructor<IServiceProvider, false>>;
|
|
339
|
+
protected filteredProviders: Array<string>;
|
|
340
|
+
private autoRegisterProviders;
|
|
341
|
+
/**
|
|
342
|
+
* The route resolver callback.
|
|
343
|
+
*/
|
|
344
|
+
protected uriResolver?: () => typeof IUrl;
|
|
345
|
+
/**
|
|
346
|
+
* List of registered console commands
|
|
347
|
+
*/
|
|
348
|
+
registeredCommands: (new (app: any, kernel: any) => any)[];
|
|
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);
|
|
374
|
+
/**
|
|
375
|
+
* Register core bindings into the container
|
|
376
|
+
*/
|
|
377
|
+
protected registerBaseBindings(): void;
|
|
378
|
+
protected loadOptions(): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Get all registered providers
|
|
381
|
+
*/
|
|
382
|
+
getRegisteredProviders(): IServiceProvider[];
|
|
383
|
+
/**
|
|
384
|
+
* Load default and optional providers dynamically
|
|
385
|
+
*
|
|
386
|
+
* Auto-Registration Behavior
|
|
387
|
+
*
|
|
388
|
+
* Minimal App: Loads only core, config, http, router by default.
|
|
389
|
+
* Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
|
|
390
|
+
*/
|
|
391
|
+
protected getConfiguredProviders(): Promise<ConcreteConstructor<IServiceProvider, false>[]>;
|
|
392
|
+
protected getAllProviders(): Promise<Array<ConcreteConstructor<IServiceProvider, false>>>;
|
|
393
|
+
/**
|
|
394
|
+
* Configure and Dynamically register all configured service providers, then boot the app.
|
|
395
|
+
*
|
|
396
|
+
* @param providers All regitererable service providers
|
|
397
|
+
* @param filtered A list of service provider name strings we do not want to register at all cost
|
|
398
|
+
* @param autoRegisterProviders If set to false, service providers will not be auto discovered and registered.
|
|
399
|
+
*
|
|
400
|
+
* @returns
|
|
401
|
+
*/
|
|
402
|
+
initialize(providers: Array<ConcreteConstructor<IServiceProvider, false>>, filtered?: string[], autoRegisterProviders?: boolean): this;
|
|
403
|
+
/**
|
|
404
|
+
* Dynamically register all configured providers
|
|
405
|
+
*/
|
|
406
|
+
registerConfiguredProviders(): Promise<void>;
|
|
407
|
+
/**
|
|
408
|
+
* Register service providers
|
|
409
|
+
*
|
|
410
|
+
* @param providers
|
|
411
|
+
* @param filtered
|
|
412
|
+
*/
|
|
413
|
+
registerProviders(providers: Array<ConcreteConstructor<IServiceProvider, false>>, filtered?: string[]): void;
|
|
414
|
+
/**
|
|
415
|
+
* Register a provider
|
|
416
|
+
*/
|
|
417
|
+
register(provider: IServiceProvider): Promise<void>;
|
|
418
|
+
/**
|
|
419
|
+
* Register the listed service providers.
|
|
420
|
+
*
|
|
421
|
+
* @param commands An array of console commands to register.
|
|
422
|
+
*/
|
|
423
|
+
withCommands(commands: (new (app: any, kernel: any) => any)[]): this;
|
|
424
|
+
/**
|
|
425
|
+
* checks if the application is running in CLI
|
|
426
|
+
*/
|
|
427
|
+
runningInConsole(): boolean;
|
|
428
|
+
/**
|
|
429
|
+
* checks if the application is running in Unit Test
|
|
430
|
+
*/
|
|
431
|
+
runningUnitTests(): boolean;
|
|
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;
|
|
442
|
+
/**
|
|
443
|
+
* Boot all service providers after registration
|
|
444
|
+
*/
|
|
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;
|
|
525
|
+
/**
|
|
526
|
+
* Fire up the developement server using the user provided arguments
|
|
527
|
+
*
|
|
528
|
+
* Port will be auto assigned if provided one is not available
|
|
529
|
+
*
|
|
530
|
+
* @alias serve
|
|
531
|
+
*/
|
|
532
|
+
fire(): Promise<this>;
|
|
533
|
+
/**
|
|
534
|
+
*
|
|
535
|
+
* @param h3App The current H3 app instance
|
|
536
|
+
* @param preferedPort If provided, this will overide the port set in the evironment
|
|
537
|
+
*/
|
|
538
|
+
fire(h3App: H3, preferredPort?: number): Promise<this>;
|
|
539
|
+
/**
|
|
540
|
+
* Fire up the developement server using the user provided arguments
|
|
541
|
+
*
|
|
542
|
+
* Port will be auto assigned if provided one is not available
|
|
543
|
+
*
|
|
544
|
+
* @param h3App The current H3 app instance
|
|
545
|
+
* @param preferedPort If provided, this will overide the port set in the evironment
|
|
546
|
+
*/
|
|
547
|
+
serve(h3App?: H3, preferredPort?: number): Promise<this>;
|
|
548
|
+
/**
|
|
549
|
+
* Run the given array of bootstrap classes.
|
|
550
|
+
*
|
|
551
|
+
* @param bootstrappers
|
|
552
|
+
*/
|
|
553
|
+
bootstrapWith(bootstrappers: ConcreteConstructor<IBootstraper>[]): Promise<void>;
|
|
554
|
+
/**
|
|
555
|
+
* Determine if the application has been bootstrapped before.
|
|
556
|
+
*/
|
|
557
|
+
hasBeenBootstrapped(): boolean;
|
|
558
|
+
/**
|
|
559
|
+
* Save the current H3 app instance for possible future use.
|
|
560
|
+
*
|
|
561
|
+
* @param h3App The current H3 app instance
|
|
562
|
+
* @returns
|
|
563
|
+
*/
|
|
564
|
+
setH3App(h3App?: H3): this;
|
|
565
|
+
/**
|
|
566
|
+
* Get the current H3 app instance.
|
|
567
|
+
*
|
|
568
|
+
* @returns
|
|
569
|
+
*/
|
|
570
|
+
getH3App(): H3 | undefined;
|
|
571
|
+
/**
|
|
572
|
+
* Set the HttpContext.
|
|
573
|
+
*
|
|
574
|
+
* @param ctx
|
|
575
|
+
*/
|
|
576
|
+
setHttpContext(ctx: IHttpContext): this;
|
|
577
|
+
/**
|
|
578
|
+
* Get the HttpContext.
|
|
579
|
+
*/
|
|
580
|
+
getHttpContext(): IHttpContext | undefined;
|
|
581
|
+
/**
|
|
582
|
+
* @param key
|
|
583
|
+
*/
|
|
584
|
+
getHttpContext<K extends keyof IHttpContext>(key: K): IHttpContext[K];
|
|
585
|
+
/**
|
|
586
|
+
* Get the application namespace.
|
|
587
|
+
*
|
|
588
|
+
* @throws {RuntimeException}
|
|
589
|
+
*/
|
|
590
|
+
getNamespace(): string;
|
|
591
|
+
/**
|
|
592
|
+
* Get the path of the app dir
|
|
593
|
+
*
|
|
594
|
+
* @returns
|
|
595
|
+
*/
|
|
596
|
+
path(): string;
|
|
597
|
+
/**
|
|
598
|
+
* Get the base path of the app
|
|
599
|
+
*
|
|
600
|
+
* @returns
|
|
601
|
+
*/
|
|
602
|
+
getBasePath(): string;
|
|
603
|
+
/**
|
|
604
|
+
* Dynamically retrieves a path property from the class.
|
|
605
|
+
* Any property ending with "Path" is accessible automatically.
|
|
606
|
+
*
|
|
607
|
+
* @param name - The base name of the path property
|
|
608
|
+
* @returns
|
|
609
|
+
*/
|
|
610
|
+
getPath(name: IPathName, suffix?: string): string;
|
|
611
|
+
/**
|
|
612
|
+
* Programatically set the paths.
|
|
613
|
+
*
|
|
614
|
+
* @param name - The base name of the path property
|
|
615
|
+
* @param path - The new path
|
|
616
|
+
* @returns
|
|
617
|
+
*/
|
|
618
|
+
setPath(name: IPathName, path: string): void;
|
|
619
|
+
/**
|
|
620
|
+
* Returns the installed version of the system core and typescript.
|
|
621
|
+
*
|
|
622
|
+
* @returns
|
|
623
|
+
*/
|
|
624
|
+
getVersion(key: string): string;
|
|
625
|
+
/**
|
|
626
|
+
* Returns the installed version of the system core and typescript.
|
|
627
|
+
*
|
|
628
|
+
* @returns
|
|
629
|
+
*/
|
|
630
|
+
static getVersion(key: string): string;
|
|
631
|
+
}
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/Contracts/ServiceProviderConstructor.d.ts
|
|
634
|
+
type ServiceProviderConstructor = (new (app: Application) => ServiceProvider) & IServiceProvider;
|
|
635
|
+
type AServiceProvider = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
|
|
636
|
+
type OServiceProvider = (new (_app: Application) => Partial<ServiceProvider>) & Partial<ServiceProvider>;
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/Controller.d.ts
|
|
639
|
+
/**
|
|
640
|
+
* Base controller class
|
|
641
|
+
*/
|
|
642
|
+
declare abstract class Controller extends IController {
|
|
643
|
+
protected app: Application;
|
|
644
|
+
constructor(app?: Application);
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/H3ravel.d.ts
|
|
648
|
+
/**
|
|
649
|
+
* Simple global entry point for H3ravel applications
|
|
650
|
+
*
|
|
651
|
+
* @param providers
|
|
652
|
+
* @param basePath
|
|
653
|
+
* @param callback
|
|
654
|
+
*/
|
|
655
|
+
declare const h3ravel: (
|
|
656
|
+
/**
|
|
657
|
+
* List of intial service providers to register with your app
|
|
658
|
+
*/
|
|
659
|
+
|
|
660
|
+
providers?: Exclude<OServiceProvider, "app" | "commands">[],
|
|
661
|
+
/**
|
|
662
|
+
* Entry path of your app
|
|
663
|
+
*/
|
|
664
|
+
|
|
665
|
+
basePath?: string,
|
|
666
|
+
/**
|
|
667
|
+
* Configuration option to pass to the initializer
|
|
668
|
+
*/
|
|
669
|
+
|
|
670
|
+
config?: EntryConfig) => Promise<Application>;
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/Http/Kernel.d.ts
|
|
673
|
+
/**
|
|
674
|
+
* Kernel class handles middleware execution and response transformations.
|
|
675
|
+
* It acts as the core middleware pipeline for HTTP requests.
|
|
676
|
+
*/
|
|
677
|
+
declare class Kernel {
|
|
678
|
+
app: Application;
|
|
679
|
+
middleware: IMiddleware[];
|
|
680
|
+
/**
|
|
681
|
+
* The router instance.
|
|
682
|
+
*/
|
|
683
|
+
protected router: IRouter;
|
|
684
|
+
/**
|
|
685
|
+
* A factory function that converts an H3Event into an HttpContext.
|
|
686
|
+
*/
|
|
687
|
+
protected context: (event: H3Event) => IHttpContext | Promise<IHttpContext>;
|
|
688
|
+
protected applicationContext: IHttpContext;
|
|
689
|
+
/**
|
|
690
|
+
* @param app - The current application instance
|
|
691
|
+
* @param middleware - An array of middleware classes that will be executed in sequence.
|
|
692
|
+
*/
|
|
693
|
+
constructor(app: Application, middleware?: IMiddleware[]);
|
|
694
|
+
/**
|
|
695
|
+
* Handles an incoming request and passes it through middleware before invoking the next handler.
|
|
696
|
+
*
|
|
697
|
+
* @param event - The raw H3 event object.
|
|
698
|
+
* @param next - A callback function that represents the next layer (usually the controller or final handler).
|
|
699
|
+
* @returns A promise resolving to the result of the request pipeline.
|
|
700
|
+
*/
|
|
701
|
+
handle(event: H3Event, next: (ctx: IHttpContext) => Promise<unknown>): Promise<unknown>;
|
|
702
|
+
/**
|
|
703
|
+
* Resolve the provided callback using the current H3 event instance
|
|
704
|
+
*/
|
|
705
|
+
resolve(event: H3Event, middleware: IMiddleware | IMiddleware[], handler: (ctx: IHttpContext) => Promise<any>): Promise<any>;
|
|
706
|
+
}
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region src/Manager/ContainerResolver.d.ts
|
|
709
|
+
type Predicate = string | ((...args: any[]) => any) | (abstract new (...args: any[]) => any);
|
|
710
|
+
declare class ContainerResolver {
|
|
711
|
+
private app;
|
|
712
|
+
constructor(app: IApplication);
|
|
713
|
+
resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, ..._default: any[]): Promise<I>;
|
|
714
|
+
static isClass(C: Predicate): C is new (...args: any[]) => any;
|
|
715
|
+
static isAbstract(C: Predicate): C is new (...args: any[]) => any;
|
|
716
|
+
static isCallable(C: Predicate): C is (...args: any[]) => any;
|
|
717
|
+
}
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region src/ProviderRegistry.d.ts
|
|
720
|
+
declare class ProviderRegistry {
|
|
721
|
+
private static providers;
|
|
722
|
+
private static priorityMap;
|
|
723
|
+
private static filteredProviders;
|
|
724
|
+
private static sortable;
|
|
725
|
+
/**
|
|
726
|
+
* Set wether providers should be sorted or not.
|
|
727
|
+
*
|
|
728
|
+
* @returns
|
|
729
|
+
*/
|
|
730
|
+
static setSortable(sort?: boolean): void;
|
|
731
|
+
/**
|
|
732
|
+
* Get a unique identifier for the Provider.
|
|
733
|
+
*
|
|
734
|
+
* @param provider
|
|
735
|
+
* @returns
|
|
736
|
+
*/
|
|
737
|
+
private static getKey;
|
|
738
|
+
/**
|
|
739
|
+
* Register one or more providers.
|
|
740
|
+
* Duplicate constructors will be ignored.
|
|
741
|
+
*
|
|
742
|
+
* @param providers
|
|
743
|
+
* @returns
|
|
744
|
+
*/
|
|
745
|
+
static register(...providers: ConcreteConstructor<IServiceProvider, false>[]): void;
|
|
746
|
+
/**
|
|
747
|
+
* Bulk register providers from an array.
|
|
748
|
+
*
|
|
749
|
+
* @param providers
|
|
750
|
+
* @returns
|
|
751
|
+
*/
|
|
752
|
+
static registerMany(providers: ConcreteConstructor<IServiceProvider, false>[]): void;
|
|
753
|
+
/**
|
|
754
|
+
* Set the filtered providers.
|
|
755
|
+
*
|
|
756
|
+
* @returns
|
|
757
|
+
*/
|
|
758
|
+
static setFiltered(filtered: string[]): void;
|
|
759
|
+
/**
|
|
760
|
+
* Resolve (instantiate) all providers with the given application or Service Container.
|
|
761
|
+
*
|
|
762
|
+
* @param app
|
|
763
|
+
* @returns
|
|
764
|
+
*/
|
|
765
|
+
static resolve(app: Application, useServiceContainer?: boolean): Promise<IServiceProvider[]>;
|
|
766
|
+
/**
|
|
767
|
+
* Sort the service providers
|
|
768
|
+
*
|
|
769
|
+
* @param providers
|
|
770
|
+
* @returns
|
|
771
|
+
*/
|
|
772
|
+
static sort(providers: ConcreteConstructor<IServiceProvider, false>[]): ConcreteConstructor<IServiceProvider, false>[];
|
|
773
|
+
/**
|
|
774
|
+
* Sort service providers
|
|
775
|
+
*/
|
|
776
|
+
static doSort(): void;
|
|
777
|
+
/**
|
|
778
|
+
* Log the service providers in a table
|
|
779
|
+
*
|
|
780
|
+
* @param priorityMap
|
|
781
|
+
*/
|
|
782
|
+
static log<P extends IServiceProvider>(providers?: Array<P> | Map<string, P>, enabled?: boolean): void;
|
|
783
|
+
/**
|
|
784
|
+
* Get all registered providers as an array.
|
|
785
|
+
*
|
|
786
|
+
* @returns
|
|
787
|
+
*/
|
|
788
|
+
static all(): ConcreteConstructor<IServiceProvider, false>[];
|
|
789
|
+
/**
|
|
790
|
+
* Check if a provider is already registered.
|
|
791
|
+
*
|
|
792
|
+
* @param provider
|
|
793
|
+
* @returns
|
|
794
|
+
*/
|
|
795
|
+
static has(provider: ConcreteConstructor<IServiceProvider, false>): boolean;
|
|
796
|
+
/**
|
|
797
|
+
* Automatically search for and discover service providers in packages.
|
|
798
|
+
*
|
|
799
|
+
* @param autoRegister
|
|
800
|
+
* @returns
|
|
801
|
+
*/
|
|
802
|
+
static discoverProviders(autoRegister?: boolean): Promise<ConcreteConstructor<IServiceProvider, false>[]>;
|
|
803
|
+
/**
|
|
804
|
+
* Get the content of the package.json file
|
|
805
|
+
*
|
|
806
|
+
* @param manifestPath
|
|
807
|
+
* @returns
|
|
808
|
+
*/
|
|
809
|
+
private static getManifest;
|
|
810
|
+
}
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/Providers/CoreServiceProvider.d.ts
|
|
813
|
+
/**
|
|
814
|
+
* Bootstraps core services and bindings.
|
|
815
|
+
*
|
|
816
|
+
* Bind essential services to the container (logger, config repository).
|
|
817
|
+
* Register app-level singletons.
|
|
818
|
+
* Set up exception handling.
|
|
819
|
+
*
|
|
820
|
+
* Auto-Registered
|
|
821
|
+
*/
|
|
822
|
+
declare class CoreServiceProvider extends ServiceProvider {
|
|
823
|
+
static priority: number;
|
|
824
|
+
register(): void;
|
|
825
|
+
boot(): void | Promise<void>;
|
|
826
|
+
}
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region src/Registerer.d.ts
|
|
829
|
+
declare class Registerer extends IRegisterer {
|
|
830
|
+
private app;
|
|
831
|
+
constructor(app: Application);
|
|
832
|
+
static register(app: Application): void;
|
|
833
|
+
bootRegister(): void;
|
|
834
|
+
private appPath;
|
|
835
|
+
private basePath;
|
|
836
|
+
private publicPath;
|
|
837
|
+
private storagePath;
|
|
838
|
+
private databasePath;
|
|
839
|
+
}
|
|
840
|
+
//#endregion
|
|
841
|
+
export { AServiceProvider, Application, Container, ContainerResolver, Controller, CoreServiceProvider, EntryConfig, Inject, Injectable, Kernel, OServiceProvider, ProviderRegistry, Registerer, ServiceProvider, ServiceProviderConstructor, h3ravel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/core",
|
|
3
|
-
"version": "1.29.0-alpha.
|
|
3
|
+
"version": "1.29.0-alpha.15",
|
|
4
4
|
"description": "Core application container, lifecycle management and service providers for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"laravel"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@h3ravel/shared": "^1.29.0-alpha.
|
|
47
|
-
"@h3ravel/support": "^1.29.0-alpha.
|
|
48
|
-
"@h3ravel/foundation": "^1.29.0-alpha.
|
|
46
|
+
"@h3ravel/shared": "^1.29.0-alpha.15",
|
|
47
|
+
"@h3ravel/support": "^1.29.0-alpha.15",
|
|
48
|
+
"@h3ravel/foundation": "^1.29.0-alpha.15",
|
|
49
49
|
"chalk": "^5.6.2",
|
|
50
50
|
"commander": "^14.0.1",
|
|
51
51
|
"detect-port": "^2.1.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"tslib": "^2.8.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@h3ravel/contracts": "^1.29.0-alpha.
|
|
62
|
+
"@h3ravel/contracts": "^1.29.0-alpha.15",
|
|
63
63
|
"@types/semver": "^7.7.1",
|
|
64
64
|
"typescript": "^6.0.0"
|
|
65
65
|
},
|