@h3ravel/core 1.9.7 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -38,8 +38,54 @@ declare class Container implements IContainer {
38
38
  has(key: UseKey): boolean;
39
39
  }
40
40
  //#endregion
41
+ //#region src/ServiceProvider.d.ts
42
+ declare const Inference: {
43
+ new (): IServiceProvider;
44
+ };
45
+ declare abstract class ServiceProvider extends Inference {
46
+ /**
47
+ * The current app instance
48
+ */
49
+ protected app: Application;
50
+ /**
51
+ * Unique Identifier for the service providers
52
+ */
53
+ static uid?: number;
54
+ /**
55
+ * Sort order
56
+ */
57
+ static order?: `before:${string}` | `after:${string}` | string | undefined;
58
+ /**
59
+ * Sort priority
60
+ */
61
+ static priority: number;
62
+ /**
63
+ * Indicate that this service provider only runs in console
64
+ */
65
+ static console: boolean;
66
+ /**
67
+ * List of registered console commands
68
+ */
69
+ registeredCommands?: (new (app: any, kernel: any) => any)[];
70
+ constructor(app: Application);
71
+ /**
72
+ * Register bindings to the container.
73
+ * Runs before boot().
74
+ */
75
+ abstract register(...app: unknown[]): void | Promise<void>;
76
+ /**
77
+ * Perform post-registration booting of services.
78
+ * Runs after all providers have been registered.
79
+ */
80
+ boot?(...app: unknown[]): void | Promise<void>;
81
+ /**
82
+ * An array of console commands to register.
83
+ */
84
+ commands(commands: (new (app: any, kernel: any) => any)[]): void;
85
+ }
86
+ //#endregion
41
87
  //#region src/Application.d.ts
42
- type AServiceProvider = (new (_app: Application) => IServiceProvider) & IServiceProvider;
88
+ type AServiceProvider = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
43
89
  declare class Application extends Container implements IApplication {
44
90
  paths: PathLoader;
45
91
  private tries;
@@ -48,7 +94,8 @@ declare class Application extends Container implements IApplication {
48
94
  private static versions;
49
95
  private basePath;
50
96
  private providers;
51
- protected externalProviders: Array<new (_app: Application) => IServiceProvider>;
97
+ protected externalProviders: Array<AServiceProvider>;
98
+ protected filteredProviders: Array<string>;
52
99
  /**
53
100
  * List of registered console commands
54
101
  */
@@ -58,15 +105,11 @@ declare class Application extends Container implements IApplication {
58
105
  * Register core bindings into the container
59
106
  */
60
107
  protected registerBaseBindings(): void;
61
- /**
62
- * Dynamically register all configured providers
63
- */
64
- registerConfiguredProviders(): Promise<void>;
65
108
  protected loadOptions(): Promise<void>;
66
109
  /**
67
110
  * Get all registered providers
68
111
  */
69
- getRegisteredProviders(): IServiceProvider[];
112
+ getRegisteredProviders(): ServiceProvider[];
70
113
  /**
71
114
  * Load default and optional providers dynamically
72
115
  *
@@ -77,12 +120,29 @@ declare class Application extends Container implements IApplication {
77
120
  */
78
121
  protected getConfiguredProviders(): Promise<Array<AServiceProvider>>;
79
122
  protected getAllProviders(): Promise<Array<AServiceProvider>>;
80
- private sortProviders;
81
- registerProviders(providers: Array<AServiceProvider>): void;
123
+ /**
124
+ * Configure and Dynamically register all configured service providers, then boot the app.
125
+ *
126
+ * @param providers All regitererable service providers
127
+ * @param filtered A list of service provider name strings we do not want to register at all cost
128
+ * @returns
129
+ */
130
+ quickStartup(providers: Array<AServiceProvider>, filtered?: string[]): Promise<void>;
131
+ /**
132
+ * Dynamically register all configured providers
133
+ */
134
+ registerConfiguredProviders(): Promise<void>;
135
+ /**
136
+ * Register service providers
137
+ *
138
+ * @param providers
139
+ * @param filtered
140
+ */
141
+ registerProviders(providers: Array<AServiceProvider>, filtered?: string[]): void;
82
142
  /**
83
143
  * Register a provider
84
144
  */
85
- register(provider: IServiceProvider): Promise<void>;
145
+ register(provider: ServiceProvider): Promise<void>;
86
146
  /**
87
147
  * checks if the application is running in CLI
88
148
  */
@@ -101,10 +161,6 @@ declare class Application extends Container implements IApplication {
101
161
  * @param preferedPort If provided, this will overide the port set in the evironment
102
162
  */
103
163
  fire(h3App: H3, preferedPort?: number): Promise<void>;
104
- /**
105
- * Attempt to dynamically import an optional module
106
- */
107
- private safeImport;
108
164
  /**
109
165
  * Get the base path of the app
110
166
  *
@@ -281,40 +337,73 @@ declare class Kernel {
281
337
  private isPlainObject;
282
338
  }
283
339
  //#endregion
284
- //#region src/ServiceProvider.d.ts
285
- declare abstract class ServiceProvider implements IServiceProvider {
340
+ //#region src/ProviderRegistry.d.ts
341
+ type ProviderCtor = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
342
+ declare class ProviderRegistry {
343
+ private static providers;
344
+ private static priorityMap;
345
+ private static filteredProviders;
346
+ /**
347
+ * Get a unique identifier for the Provider.
348
+ *
349
+ * @param provider
350
+ * @returns
351
+ */
352
+ private static getKey;
286
353
  /**
287
- * Sort order
354
+ * Register one or more providers.
355
+ * Duplicate constructors will be ignored.
356
+ *
357
+ * @param providers
358
+ * @returns
288
359
  */
289
- static order?: `before:${string}` | `after:${string}` | string | undefined;
360
+ static register(...providers: ProviderCtor[]): void;
290
361
  /**
291
- * Sort priority
362
+ * Bulk register providers from an array.
363
+ *
364
+ * @param providers
365
+ * @returns
292
366
  */
293
- static priority: number;
367
+ static registerMany(providers: ProviderCtor[]): void;
294
368
  /**
295
- * Indicate that this service provider only runs in console
369
+ * Get all registered providers as an array.
370
+ *
371
+ * @returns
296
372
  */
297
- static console: boolean;
373
+ static setFiltered(filtered: string[]): void;
298
374
  /**
299
- * List of registered console commands
375
+ * Resolve (instantiate) all providers with the given application or Service Container.
376
+ *
377
+ * @param app
378
+ * @returns
300
379
  */
301
- registeredCommands?: (new (app: any, kernel: any) => any)[];
302
- protected app: Application;
303
- constructor(app: Application);
380
+ static resolve(app: Application, useServiceContainer?: boolean): Promise<ServiceProvider[]>;
304
381
  /**
305
- * Register bindings to the container.
306
- * Runs before boot().
382
+ * Sort the service providers
383
+ *
384
+ * @param providers
385
+ * @returns
307
386
  */
308
- abstract register(...app: unknown[]): void | Promise<void>;
387
+ static sort(providers: ProviderCtor[]): ProviderCtor[];
309
388
  /**
310
- * Perform post-registration booting of services.
311
- * Runs after all providers have been registered.
389
+ * Log the service providers in a table
390
+ *
391
+ * @param priorityMap
312
392
  */
313
- boot?(...app: unknown[]): void | Promise<void>;
393
+ static log<P extends ServiceProvider>(providers?: Array<P> | Map<string, P>): void;
314
394
  /**
315
- * An array of console commands to register.
395
+ * Get all registered providers as an array.
396
+ *
397
+ * @returns
316
398
  */
317
- commands(commands: (new (app: any, kernel: any) => any)[]): void;
399
+ static all(): ProviderCtor[];
400
+ /**
401
+ * Check if a provider is already registered.
402
+ *
403
+ * @param provider
404
+ * @returns
405
+ */
406
+ static has(provider: ProviderCtor): boolean;
318
407
  }
319
408
  //#endregion
320
409
  //#region src/Providers/CoreServiceProvider.d.ts
@@ -330,6 +419,7 @@ declare abstract class ServiceProvider implements IServiceProvider {
330
419
  declare class CoreServiceProvider extends ServiceProvider {
331
420
  static priority: number;
332
421
  register(): void;
422
+ boot(): void | Promise<void>;
333
423
  }
334
424
  //#endregion
335
425
  //#region src/Providers/ViewServiceProvider.d.ts
@@ -351,5 +441,5 @@ declare class Registerer {
351
441
  private databasePath;
352
442
  }
353
443
  //#endregion
354
- export { Application, ConsoleCommand, ConsoleKernel, Container, ContainerResolver, Controller, CoreServiceProvider, Inject, Injectable, Kernel, Registerer, ServiceProvider, ServiceProviderConstructor, ViewServiceProvider };
444
+ export { Application, ConsoleCommand, ConsoleKernel, Container, ContainerResolver, Controller, CoreServiceProvider, Inject, Injectable, Kernel, ProviderRegistry, Registerer, ServiceProvider, ServiceProviderConstructor, ViewServiceProvider };
355
445
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -39,8 +39,54 @@ declare class Container implements IContainer {
39
39
  has(key: UseKey): boolean;
40
40
  }
41
41
  //#endregion
42
+ //#region src/ServiceProvider.d.ts
43
+ declare const Inference: {
44
+ new (): IServiceProvider;
45
+ };
46
+ declare abstract class ServiceProvider extends Inference {
47
+ /**
48
+ * The current app instance
49
+ */
50
+ protected app: Application;
51
+ /**
52
+ * Unique Identifier for the service providers
53
+ */
54
+ static uid?: number;
55
+ /**
56
+ * Sort order
57
+ */
58
+ static order?: `before:${string}` | `after:${string}` | string | undefined;
59
+ /**
60
+ * Sort priority
61
+ */
62
+ static priority: number;
63
+ /**
64
+ * Indicate that this service provider only runs in console
65
+ */
66
+ static console: boolean;
67
+ /**
68
+ * List of registered console commands
69
+ */
70
+ registeredCommands?: (new (app: any, kernel: any) => any)[];
71
+ constructor(app: Application);
72
+ /**
73
+ * Register bindings to the container.
74
+ * Runs before boot().
75
+ */
76
+ abstract register(...app: unknown[]): void | Promise<void>;
77
+ /**
78
+ * Perform post-registration booting of services.
79
+ * Runs after all providers have been registered.
80
+ */
81
+ boot?(...app: unknown[]): void | Promise<void>;
82
+ /**
83
+ * An array of console commands to register.
84
+ */
85
+ commands(commands: (new (app: any, kernel: any) => any)[]): void;
86
+ }
87
+ //#endregion
42
88
  //#region src/Application.d.ts
43
- type AServiceProvider = (new (_app: Application) => IServiceProvider) & IServiceProvider;
89
+ type AServiceProvider = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
44
90
  declare class Application extends Container implements IApplication {
45
91
  paths: PathLoader;
46
92
  private tries;
@@ -49,7 +95,8 @@ declare class Application extends Container implements IApplication {
49
95
  private static versions;
50
96
  private basePath;
51
97
  private providers;
52
- protected externalProviders: Array<new (_app: Application) => IServiceProvider>;
98
+ protected externalProviders: Array<AServiceProvider>;
99
+ protected filteredProviders: Array<string>;
53
100
  /**
54
101
  * List of registered console commands
55
102
  */
@@ -59,15 +106,11 @@ declare class Application extends Container implements IApplication {
59
106
  * Register core bindings into the container
60
107
  */
61
108
  protected registerBaseBindings(): void;
62
- /**
63
- * Dynamically register all configured providers
64
- */
65
- registerConfiguredProviders(): Promise<void>;
66
109
  protected loadOptions(): Promise<void>;
67
110
  /**
68
111
  * Get all registered providers
69
112
  */
70
- getRegisteredProviders(): IServiceProvider[];
113
+ getRegisteredProviders(): ServiceProvider[];
71
114
  /**
72
115
  * Load default and optional providers dynamically
73
116
  *
@@ -78,12 +121,29 @@ declare class Application extends Container implements IApplication {
78
121
  */
79
122
  protected getConfiguredProviders(): Promise<Array<AServiceProvider>>;
80
123
  protected getAllProviders(): Promise<Array<AServiceProvider>>;
81
- private sortProviders;
82
- registerProviders(providers: Array<AServiceProvider>): void;
124
+ /**
125
+ * Configure and Dynamically register all configured service providers, then boot the app.
126
+ *
127
+ * @param providers All regitererable service providers
128
+ * @param filtered A list of service provider name strings we do not want to register at all cost
129
+ * @returns
130
+ */
131
+ quickStartup(providers: Array<AServiceProvider>, filtered?: string[]): Promise<void>;
132
+ /**
133
+ * Dynamically register all configured providers
134
+ */
135
+ registerConfiguredProviders(): Promise<void>;
136
+ /**
137
+ * Register service providers
138
+ *
139
+ * @param providers
140
+ * @param filtered
141
+ */
142
+ registerProviders(providers: Array<AServiceProvider>, filtered?: string[]): void;
83
143
  /**
84
144
  * Register a provider
85
145
  */
86
- register(provider: IServiceProvider): Promise<void>;
146
+ register(provider: ServiceProvider): Promise<void>;
87
147
  /**
88
148
  * checks if the application is running in CLI
89
149
  */
@@ -102,10 +162,6 @@ declare class Application extends Container implements IApplication {
102
162
  * @param preferedPort If provided, this will overide the port set in the evironment
103
163
  */
104
164
  fire(h3App: H3, preferedPort?: number): Promise<void>;
105
- /**
106
- * Attempt to dynamically import an optional module
107
- */
108
- private safeImport;
109
165
  /**
110
166
  * Get the base path of the app
111
167
  *
@@ -282,40 +338,73 @@ declare class Kernel {
282
338
  private isPlainObject;
283
339
  }
284
340
  //#endregion
285
- //#region src/ServiceProvider.d.ts
286
- declare abstract class ServiceProvider implements IServiceProvider {
341
+ //#region src/ProviderRegistry.d.ts
342
+ type ProviderCtor = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
343
+ declare class ProviderRegistry {
344
+ private static providers;
345
+ private static priorityMap;
346
+ private static filteredProviders;
347
+ /**
348
+ * Get a unique identifier for the Provider.
349
+ *
350
+ * @param provider
351
+ * @returns
352
+ */
353
+ private static getKey;
287
354
  /**
288
- * Sort order
355
+ * Register one or more providers.
356
+ * Duplicate constructors will be ignored.
357
+ *
358
+ * @param providers
359
+ * @returns
289
360
  */
290
- static order?: `before:${string}` | `after:${string}` | string | undefined;
361
+ static register(...providers: ProviderCtor[]): void;
291
362
  /**
292
- * Sort priority
363
+ * Bulk register providers from an array.
364
+ *
365
+ * @param providers
366
+ * @returns
293
367
  */
294
- static priority: number;
368
+ static registerMany(providers: ProviderCtor[]): void;
295
369
  /**
296
- * Indicate that this service provider only runs in console
370
+ * Get all registered providers as an array.
371
+ *
372
+ * @returns
297
373
  */
298
- static console: boolean;
374
+ static setFiltered(filtered: string[]): void;
299
375
  /**
300
- * List of registered console commands
376
+ * Resolve (instantiate) all providers with the given application or Service Container.
377
+ *
378
+ * @param app
379
+ * @returns
301
380
  */
302
- registeredCommands?: (new (app: any, kernel: any) => any)[];
303
- protected app: Application;
304
- constructor(app: Application);
381
+ static resolve(app: Application, useServiceContainer?: boolean): Promise<ServiceProvider[]>;
305
382
  /**
306
- * Register bindings to the container.
307
- * Runs before boot().
383
+ * Sort the service providers
384
+ *
385
+ * @param providers
386
+ * @returns
308
387
  */
309
- abstract register(...app: unknown[]): void | Promise<void>;
388
+ static sort(providers: ProviderCtor[]): ProviderCtor[];
310
389
  /**
311
- * Perform post-registration booting of services.
312
- * Runs after all providers have been registered.
390
+ * Log the service providers in a table
391
+ *
392
+ * @param priorityMap
313
393
  */
314
- boot?(...app: unknown[]): void | Promise<void>;
394
+ static log<P extends ServiceProvider>(providers?: Array<P> | Map<string, P>): void;
315
395
  /**
316
- * An array of console commands to register.
396
+ * Get all registered providers as an array.
397
+ *
398
+ * @returns
317
399
  */
318
- commands(commands: (new (app: any, kernel: any) => any)[]): void;
400
+ static all(): ProviderCtor[];
401
+ /**
402
+ * Check if a provider is already registered.
403
+ *
404
+ * @param provider
405
+ * @returns
406
+ */
407
+ static has(provider: ProviderCtor): boolean;
319
408
  }
320
409
  //#endregion
321
410
  //#region src/Providers/CoreServiceProvider.d.ts
@@ -331,6 +420,7 @@ declare abstract class ServiceProvider implements IServiceProvider {
331
420
  declare class CoreServiceProvider extends ServiceProvider {
332
421
  static priority: number;
333
422
  register(): void;
423
+ boot(): void | Promise<void>;
334
424
  }
335
425
  //#endregion
336
426
  //#region src/Providers/ViewServiceProvider.d.ts
@@ -352,5 +442,5 @@ declare class Registerer {
352
442
  private databasePath;
353
443
  }
354
444
  //#endregion
355
- export { Application, ConsoleCommand, ConsoleKernel, Container, ContainerResolver, Controller, CoreServiceProvider, Inject, Injectable, Kernel, Registerer, ServiceProvider, ServiceProviderConstructor, ViewServiceProvider };
445
+ export { Application, ConsoleCommand, ConsoleKernel, Container, ContainerResolver, Controller, CoreServiceProvider, Inject, Injectable, Kernel, ProviderRegistry, Registerer, ServiceProvider, ServiceProviderConstructor, ViewServiceProvider };
356
446
  //# sourceMappingURL=index.d.ts.map