import { Binding, BindingSpec, Constructor } from '@loopback/core'; /** * Type definition for ArtifactOptions. These are the options supported by * this Booter. */ export declare type ArtifactOptions = { /** * Array of directories to check for artifacts. * Paths must be relative. Defaults to ['controllers'] */ dirs?: string | string[]; /** * Array of file extensions to match artifact * files in dirs. Defaults to ['.controller.js'] */ extensions?: string | string[]; /** * A flag to control if artifact discovery should check nested * folders or not. Default to true */ nested?: boolean; /** * A `glob` string to use when searching for files. This takes * precedence over other options. */ glob?: string; }; /** * Defines the requirements to implement a Booter for LoopBack applications: * - configure() * - discover() * - load() * * A Booter will run through the above methods in order. */ export interface Booter { /** * Configure phase of the Booter. It should set options / defaults in this phase. */ configure?(): Promise; /** * Discover phase of the Booter. It should search for artifacts in this phase. */ discover?(): Promise; /** * Load phase of the Booter. It should bind the artifacts in this phase. */ load?(): Promise; } /** * Export of an array of all the Booter phases supported by the interface * above, in the order they should be run. */ export declare const BOOTER_PHASES: string[]; /** * Options to configure `Bootstrapper` */ export declare type BootOptions = { controllers?: ArtifactOptions; repositories?: ArtifactOptions; /** * Additional Properties */ [prop: string]: any; }; /** * Options for boot() execution */ export declare type BootExecutionOptions = { /** * Optional array of Booter Classes to bind to the application before running bootstrapper. */ booters?: Constructor[]; /** * Filter Object for Bootstrapper */ filter?: { /** * Names of booters that should be run by Bootstrapper */ booters?: string[]; /** * Names of phases that should be run by Bootstrapper */ phases?: string[]; }; /** * Additional Properties */ [prop: string]: any; }; /** * Interface to describe the additions made available to an Application * that uses BootMixin. */ export interface Bootable { /** * Root directory for the project to be booted */ projectRoot: string; /** * Options for boot */ bootOptions?: BootOptions; /** * Boot up the project */ boot(): Promise; /** * Register booters * @param booterClasses - A list of booter classes */ booters(...booterClasses: Constructor[]): Binding[]; } /** * `@booter` decorator to mark a class as a `Booter` and specify the artifact * namespace for the configuration of the booter * * @example * ```ts * @booter('controllers') * export class ControllerBooter extends BaseArtifactBooter { * constructor( * @inject(CoreBindings.APPLICATION_INSTANCE) public app: Application, * @inject(BootBindings.PROJECT_ROOT) projectRoot: string, * @config() * public controllerConfig: ArtifactOptions = {}, * ) { * // ... * } * } * ``` * * @param artifactNamespace - Namespace for the artifact. It will be used to * inject configuration from boot options. For example, the Booter class * decorated with `@booter('controllers')` can receive its configuration via * `@config()` from the `controllers` property of boot options. * * @param specs - Extra specs for the binding */ export declare function booter(artifactNamespace: string, ...specs: BindingSpec[]): ClassDecorator; /** * Interface to describe an object that may have an array of `booters`. */ export interface InstanceWithBooters { booters?: Constructor[]; }