@h3ravel/core 1.14.0 → 1.16.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
@@ -24,7 +24,7 @@ declare class Container implements IContainer {
24
24
  /**
25
25
  * Bind a singleton service to the container
26
26
  */
27
- singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: () => Bindings[T]): void;
27
+ singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: (app: this) => Bindings[T]): void;
28
28
  /**
29
29
  * Resolve a service from the container
30
30
  */
@@ -82,9 +82,19 @@ declare abstract class ServiceProvider extends Inference {
82
82
  */
83
83
  boot?(...app: unknown[]): void | Promise<void>;
84
84
  /**
85
- * An array of console commands to register.
85
+ * Register the listed service providers.
86
+ *
87
+ * @param commands An array of console commands to register.
88
+ *
89
+ * @deprecated since version 1.16.0. Will be removed in future versions, use `registerCommands` instead
86
90
  */
87
91
  commands(commands: (new (app: any, kernel: any) => any)[]): void;
92
+ /**
93
+ * Register the listed service providers.
94
+ *
95
+ * @param commands An array of console commands to register.
96
+ */
97
+ registerCommands(commands: (new (app: any, kernel: any) => any)[]): void;
88
98
  }
89
99
  //#endregion
90
100
  //#region src/Application.d.ts
@@ -128,13 +138,17 @@ declare class Application extends Container implements IApplication {
128
138
  *
129
139
  * @param providers All regitererable service providers
130
140
  * @param filtered A list of service provider name strings we do not want to register at all cost
141
+ * @param autoRegisterProviders If set to false, service providers will not be auto discovered and registered.
142
+ *
131
143
  * @returns
132
144
  */
133
- quickStartup(providers: Array<AServiceProvider>, filtered?: string[]): Promise<void>;
145
+ quickStartup(providers: Array<AServiceProvider>, filtered?: string[], autoRegisterProviders?: boolean): Promise<this>;
134
146
  /**
135
147
  * Dynamically register all configured providers
148
+ *
149
+ * @param autoRegister If set to false, service providers will not be auto discovered and registered.
136
150
  */
137
- registerConfiguredProviders(): Promise<void>;
151
+ registerConfiguredProviders(autoRegister?: boolean): Promise<void>;
138
152
  /**
139
153
  * Register service providers
140
154
  *
@@ -146,6 +160,12 @@ declare class Application extends Container implements IApplication {
146
160
  * Register a provider
147
161
  */
148
162
  register(provider: ServiceProvider): Promise<void>;
163
+ /**
164
+ * Register the listed service providers.
165
+ *
166
+ * @param commands An array of console commands to register.
167
+ */
168
+ withCommands(commands: (new (app: any, kernel: any) => any)[]): this;
149
169
  /**
150
170
  * checks if the application is running in CLI
151
171
  */
@@ -154,7 +174,7 @@ declare class Application extends Container implements IApplication {
154
174
  /**
155
175
  * Boot all service providers after registration
156
176
  */
157
- boot(): Promise<void>;
177
+ boot(): Promise<this>;
158
178
  /**
159
179
  * Fire up the developement server using the user provided arguments
160
180
  *
@@ -258,7 +278,9 @@ declare class ConsoleCommand {
258
278
  */
259
279
  handle(..._args: any[]): Promise<void>;
260
280
  setApplication(app: Application): void;
261
- setInput(options: XGeneric, args: string[], regArgs: readonly Argument[], dictionary: Record<string, any>, program: Command): void;
281
+ setInput(options: XGeneric, args: string[], regArgs: readonly Argument[], dictionary: Record<string, any>, program: Command): this;
282
+ setOption(key: string, value: unknown): this;
283
+ setProgram(program: Command): this;
262
284
  getSignature(): string;
263
285
  getDescription(): string | undefined;
264
286
  option(key: string, def?: any): any;
@@ -266,34 +288,65 @@ declare class ConsoleCommand {
266
288
  argument(key: string, def?: any): any;
267
289
  arguments(): Record<string, any>;
268
290
  loadBaseFlags(): void;
291
+ /**
292
+ * Check if the command is quiet
293
+ *
294
+ * @returns
295
+ */
296
+ isQuiet(): any;
297
+ /**
298
+ * Check if the command is silent
299
+ *
300
+ * @returns
301
+ */
302
+ isSilent(): any;
303
+ /**
304
+ * Check if the command is non interactive
305
+ *
306
+ * @returns
307
+ */
308
+ isNonInteractive(): boolean;
309
+ /**
310
+ * Get the verbosity of the command
311
+ *
312
+ * @returns
313
+ */
314
+ getVerbosity(): number;
269
315
  /**
270
316
  * Log an info message
271
317
  */
272
- info(message: string): void;
318
+ info(message: string): this;
273
319
  /**
274
320
  * Log a warning message
275
321
  */
276
- warn(message: string): void;
322
+ warn(message: string): this;
277
323
  /**
278
324
  * Log a line message
279
325
  */
280
- line(message: string): void;
326
+ line(message: string): this;
281
327
  /**
282
328
  * Log a new line
283
329
  */
284
- newLine(count?: number): void;
330
+ newLine(count?: number): this;
285
331
  /**
286
332
  * Log a success message
287
333
  */
288
- success(message: string): void;
334
+ success(message: string): this;
289
335
  /**
290
336
  * Log an error message
291
337
  */
292
- error(message: string): void;
338
+ error(message: string): this;
339
+ /**
340
+ * Log an error message and terminate execution of the command
341
+ * return an exit code of 1
342
+ *
343
+ * This method is not chainable
344
+ */
345
+ fail(message: string): void;
293
346
  /**
294
347
  * Log a debug message
295
348
  */
296
- debug(message: string | string[]): void;
349
+ debug(message: string | string[]): this;
297
350
  }
298
351
  //#endregion
299
352
  //#region src/Contracts/ServiceProviderConstructor.d.ts
@@ -317,7 +370,7 @@ declare abstract class Controller implements IController {
317
370
  declare class ContainerResolver {
318
371
  private app;
319
372
  constructor(app: Application);
320
- resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, _default?: any): Promise<I>;
373
+ resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, ..._default: any[]): Promise<I>;
321
374
  static isClass(C: any): boolean;
322
375
  }
323
376
  //#endregion
@@ -380,6 +433,13 @@ declare class ProviderRegistry {
380
433
  private static providers;
381
434
  private static priorityMap;
382
435
  private static filteredProviders;
436
+ private static sortable;
437
+ /**
438
+ * Set wether providers should be sorted or not.
439
+ *
440
+ * @returns
441
+ */
442
+ static setSortable(sort?: boolean): void;
383
443
  /**
384
444
  * Get a unique identifier for the Provider.
385
445
  *
@@ -422,6 +482,10 @@ declare class ProviderRegistry {
422
482
  * @returns
423
483
  */
424
484
  static sort(providers: ProviderCtor[]): ProviderCtor[];
485
+ /**
486
+ * Sort service providers
487
+ */
488
+ static doSort(): void;
425
489
  /**
426
490
  * Log the service providers in a table
427
491
  *
@@ -441,6 +505,20 @@ declare class ProviderRegistry {
441
505
  * @returns
442
506
  */
443
507
  static has(provider: ProviderCtor): boolean;
508
+ /**
509
+ * Automatically search for and discover service providers in packages.
510
+ *
511
+ * @param autoRegister
512
+ * @returns
513
+ */
514
+ static discoverProviders(autoRegister?: boolean): Promise<ProviderCtor[]>;
515
+ /**
516
+ * Get the content of the package.json file
517
+ *
518
+ * @param manifestPath
519
+ * @returns
520
+ */
521
+ private static getManifest;
444
522
  }
445
523
  //#endregion
446
524
  //#region src/Providers/CoreServiceProvider.d.ts
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@ declare class Container implements IContainer {
25
25
  /**
26
26
  * Bind a singleton service to the container
27
27
  */
28
- singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: () => Bindings[T]): void;
28
+ singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: (app: this) => Bindings[T]): void;
29
29
  /**
30
30
  * Resolve a service from the container
31
31
  */
@@ -83,9 +83,19 @@ declare abstract class ServiceProvider extends Inference {
83
83
  */
84
84
  boot?(...app: unknown[]): void | Promise<void>;
85
85
  /**
86
- * An array of console commands to register.
86
+ * Register the listed service providers.
87
+ *
88
+ * @param commands An array of console commands to register.
89
+ *
90
+ * @deprecated since version 1.16.0. Will be removed in future versions, use `registerCommands` instead
87
91
  */
88
92
  commands(commands: (new (app: any, kernel: any) => any)[]): void;
93
+ /**
94
+ * Register the listed service providers.
95
+ *
96
+ * @param commands An array of console commands to register.
97
+ */
98
+ registerCommands(commands: (new (app: any, kernel: any) => any)[]): void;
89
99
  }
90
100
  //#endregion
91
101
  //#region src/Application.d.ts
@@ -129,13 +139,17 @@ declare class Application extends Container implements IApplication {
129
139
  *
130
140
  * @param providers All regitererable service providers
131
141
  * @param filtered A list of service provider name strings we do not want to register at all cost
142
+ * @param autoRegisterProviders If set to false, service providers will not be auto discovered and registered.
143
+ *
132
144
  * @returns
133
145
  */
134
- quickStartup(providers: Array<AServiceProvider>, filtered?: string[]): Promise<void>;
146
+ quickStartup(providers: Array<AServiceProvider>, filtered?: string[], autoRegisterProviders?: boolean): Promise<this>;
135
147
  /**
136
148
  * Dynamically register all configured providers
149
+ *
150
+ * @param autoRegister If set to false, service providers will not be auto discovered and registered.
137
151
  */
138
- registerConfiguredProviders(): Promise<void>;
152
+ registerConfiguredProviders(autoRegister?: boolean): Promise<void>;
139
153
  /**
140
154
  * Register service providers
141
155
  *
@@ -147,6 +161,12 @@ declare class Application extends Container implements IApplication {
147
161
  * Register a provider
148
162
  */
149
163
  register(provider: ServiceProvider): Promise<void>;
164
+ /**
165
+ * Register the listed service providers.
166
+ *
167
+ * @param commands An array of console commands to register.
168
+ */
169
+ withCommands(commands: (new (app: any, kernel: any) => any)[]): this;
150
170
  /**
151
171
  * checks if the application is running in CLI
152
172
  */
@@ -155,7 +175,7 @@ declare class Application extends Container implements IApplication {
155
175
  /**
156
176
  * Boot all service providers after registration
157
177
  */
158
- boot(): Promise<void>;
178
+ boot(): Promise<this>;
159
179
  /**
160
180
  * Fire up the developement server using the user provided arguments
161
181
  *
@@ -259,7 +279,9 @@ declare class ConsoleCommand {
259
279
  */
260
280
  handle(..._args: any[]): Promise<void>;
261
281
  setApplication(app: Application): void;
262
- setInput(options: XGeneric, args: string[], regArgs: readonly Argument[], dictionary: Record<string, any>, program: Command): void;
282
+ setInput(options: XGeneric, args: string[], regArgs: readonly Argument[], dictionary: Record<string, any>, program: Command): this;
283
+ setOption(key: string, value: unknown): this;
284
+ setProgram(program: Command): this;
263
285
  getSignature(): string;
264
286
  getDescription(): string | undefined;
265
287
  option(key: string, def?: any): any;
@@ -267,34 +289,65 @@ declare class ConsoleCommand {
267
289
  argument(key: string, def?: any): any;
268
290
  arguments(): Record<string, any>;
269
291
  loadBaseFlags(): void;
292
+ /**
293
+ * Check if the command is quiet
294
+ *
295
+ * @returns
296
+ */
297
+ isQuiet(): any;
298
+ /**
299
+ * Check if the command is silent
300
+ *
301
+ * @returns
302
+ */
303
+ isSilent(): any;
304
+ /**
305
+ * Check if the command is non interactive
306
+ *
307
+ * @returns
308
+ */
309
+ isNonInteractive(): boolean;
310
+ /**
311
+ * Get the verbosity of the command
312
+ *
313
+ * @returns
314
+ */
315
+ getVerbosity(): number;
270
316
  /**
271
317
  * Log an info message
272
318
  */
273
- info(message: string): void;
319
+ info(message: string): this;
274
320
  /**
275
321
  * Log a warning message
276
322
  */
277
- warn(message: string): void;
323
+ warn(message: string): this;
278
324
  /**
279
325
  * Log a line message
280
326
  */
281
- line(message: string): void;
327
+ line(message: string): this;
282
328
  /**
283
329
  * Log a new line
284
330
  */
285
- newLine(count?: number): void;
331
+ newLine(count?: number): this;
286
332
  /**
287
333
  * Log a success message
288
334
  */
289
- success(message: string): void;
335
+ success(message: string): this;
290
336
  /**
291
337
  * Log an error message
292
338
  */
293
- error(message: string): void;
339
+ error(message: string): this;
340
+ /**
341
+ * Log an error message and terminate execution of the command
342
+ * return an exit code of 1
343
+ *
344
+ * This method is not chainable
345
+ */
346
+ fail(message: string): void;
294
347
  /**
295
348
  * Log a debug message
296
349
  */
297
- debug(message: string | string[]): void;
350
+ debug(message: string | string[]): this;
298
351
  }
299
352
  //#endregion
300
353
  //#region src/Contracts/ServiceProviderConstructor.d.ts
@@ -318,7 +371,7 @@ declare abstract class Controller implements IController {
318
371
  declare class ContainerResolver {
319
372
  private app;
320
373
  constructor(app: Application);
321
- resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, _default?: any): Promise<I>;
374
+ resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, ..._default: any[]): Promise<I>;
322
375
  static isClass(C: any): boolean;
323
376
  }
324
377
  //#endregion
@@ -381,6 +434,13 @@ declare class ProviderRegistry {
381
434
  private static providers;
382
435
  private static priorityMap;
383
436
  private static filteredProviders;
437
+ private static sortable;
438
+ /**
439
+ * Set wether providers should be sorted or not.
440
+ *
441
+ * @returns
442
+ */
443
+ static setSortable(sort?: boolean): void;
384
444
  /**
385
445
  * Get a unique identifier for the Provider.
386
446
  *
@@ -423,6 +483,10 @@ declare class ProviderRegistry {
423
483
  * @returns
424
484
  */
425
485
  static sort(providers: ProviderCtor[]): ProviderCtor[];
486
+ /**
487
+ * Sort service providers
488
+ */
489
+ static doSort(): void;
426
490
  /**
427
491
  * Log the service providers in a table
428
492
  *
@@ -442,6 +506,20 @@ declare class ProviderRegistry {
442
506
  * @returns
443
507
  */
444
508
  static has(provider: ProviderCtor): boolean;
509
+ /**
510
+ * Automatically search for and discover service providers in packages.
511
+ *
512
+ * @param autoRegister
513
+ * @returns
514
+ */
515
+ static discoverProviders(autoRegister?: boolean): Promise<ProviderCtor[]>;
516
+ /**
517
+ * Get the content of the package.json file
518
+ *
519
+ * @param manifestPath
520
+ * @returns
521
+ */
522
+ private static getManifest;
445
523
  }
446
524
  //#endregion
447
525
  //#region src/Providers/CoreServiceProvider.d.ts