{"version":3,"file":"scion-toolkit-bean-manager.mjs","sources":["../../../../projects/scion/toolkit/bean-manager/src/bean-manager.ts","../../../../projects/scion/toolkit/bean-manager/src/public_api.ts","../../../../projects/scion/toolkit/bean-manager/src/scion-toolkit-bean-manager.ts"],"sourcesContent":["/*\n * Copyright (c) 2018-2020 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n *  SPDX-License-Identifier: EPL-2.0\n */\n\nimport {Defined, Maps} from '@scion/toolkit/util';\nimport {BehaviorSubject, firstValueFrom, noop} from 'rxjs';\nimport {filter} from 'rxjs/operators';\n\n/**\n * The bean manager allows getting references to singleton objects, so-called beans.\n *\n * #### Bean\n * A bean can be any object or even a primitive like a `boolean`. A bean is registered under some symbol in the bean manager. In most\n * cases, the class of the bean is used as the symbol. You can then look up the bean under its registration symbol. A symbol is either\n * a class type, an abstract class type, or a `Symbol`.\n *\n * #### Bean Scope\n * Beans are application-scoped, sometimes also referred to as singleton objects.\n *\n * #### Bean Construction\n * By default, the bean manager constructs beans lazily when looked up for the first time. Subsequent lookups then get the same bean instance.\n * When registering a bean, however, you can instruct the bean manager to construct the bean eagerly at startup. Eager beans are constructed after\n * all initializers complete.\n *\n * #### Registering Beans\n * A bean is registered in the bean manager under some class type, abstract class type or `Symbol`. In most cases, the symbol is also the type of the bean\n * instance but does not have to be. You can then look up the bean from the bean manager using that symbol.\n *\n * When registering a bean, you must tell the bean manager how to construct the bean. Different strategies are supported, as listed below.\n *\n * |Strategy|Description|Example|\n * |-|-|-|\n * |useClass             |if to create an instance of a class                                   |```Beans.register(Logger, {useClass: ConsoleLogger});```|\n * |useClass (shorthand) |Shorthand syntax if class and lookup symbol are identical             |```Beans.register(ConsoleLogger);```|\n * |useValue             |if to use a static value as bean                                      |```Beans.register(LoggingConfig, {useValue: config});```|\n * |useFactory           |if to construct the bean with a factory function                      |```Beans.register(Logger, {useFactory: () => new ConsoleLogger()});```|\n * |useExisting          |if to create an alias for another bean registered in the bean manager |```Beans.register(Logger, {useExisting: ConsoleLogger});```|\n *\n * #### Registering multiple Beans on the same Symbol\n * Multiple beans can be registered under the same symbol by setting the multi flag to `true`. When looking them up, they are returned in an array in registration order.\n *\n * ```ts\n * Beans.register(MessageInterceptor, {useClass: MessageLoggerInterceptor, multi: true});\n * ```\n * #### Looking up Beans\n * Beans are looked up using the symbol under which they were registered. The bean manager providers different methods to look up beans, as listed below.\n *\n * |Method|Description|\n * |-|-|\n * |`Beans.get` |Returns the bean registered under the given symbol. If no or multiple beans are registered under the passed symbol, an error is thrown. |\n * |`Beans.opt` |Returns the bean registered under the given symbol, if any, or returns `undefined` otherwise. |\n * |`Beans.all` |Returns all beans registered under the given symbol. Returns an empty array if no bean is found. |\n *\n * #### Replacing Beans\n * A bean can be replaced by registering another bean under a bean's symbol. In turn, the replaced bean is disposed and unregistered.\n *\n * #### Decorating Beans\n * The bean manager allows decorating a bean to intercept invocations to its methods and properties. Multiple decorators can decorate a single bean. Decoration\n * takes place in decorator registration order.\n *\n * Decorators are registered in the bean manager using the `Beans.registerDecorator` method under the symbol of the bean to be decorated.\n * As with the registration of a bean, you must tell the bean manager how to construct the decorator. For more information, see Bean Construction Strategies.\n * Decorators must be registered before starting the bean manager.\n *\n * A decorator must implement the decorate method of the BeanDecorator interface and return the proxied bean. To proxy a bean, you can create a JavaScript proxy,\n * or create an anonymous class delegating to the actual bean.\n *\n * #### Initializers\n * Initializers help to run initialization tasks during startup. Initializers can specify a runlevel in which to execute. Initializers bound to lower\n * runlevels execute before initializers of higher runlevels. Initializers of the same runlevel may execute in parallel.\n *\n * Initializers are registered in the bean manager using the `Beans.registerInitializer` method, passing a function or an initializer object, and optionally a runlevel.\n * If not specifying a runlevel, the initializer is executed in runlevel <code>0</code>, or in the default runlevel as specified when starting the bean manager.\n *\n * @category BeanManager\n */\nexport class BeanManager {\n\n  private _beanRegistry = new Map<Type<unknown> | AbstractType<unknown> | symbol, Set<BeanInfo>>();\n  private _decoratorRegistry = new Map<Type<unknown> | AbstractType<unknown> | symbol, BeanDecorator<unknown>[]>();\n  private _initializers: InitializerInfo[] = [];\n\n  private _sequence = 0;\n  private _runlevel$ = new BehaviorSubject<number>(-1);\n  private _eagerBeansConstructed = false;\n  private _started = false;\n\n  /**\n   * Registers a bean under the given symbol.\n   *\n   * If not providing instructions, the given symbol is used as the constructor function to construct the bean.\n   *\n   * By default, bean construction is lazy, meaning that the bean is constructed when looked up for the first time.\n   * If another bean is registered under the same symbol, that other bean is disposed and replaced with the given bean.\n   * To register multiple beans on the same symbol, register it with the flag `multi` set to `true`.\n   *\n   * Beans can be registered, replaced or removed even after starting the bean manager.\n   *\n   * @param  symbol - Symbol under which to register the bean.\n   * @param  instructions - Control bean construction; see {@link BeanInstanceConstructInstructions} for more detail.\n   * @return handle to unregister the bean.\n   */\n  public register<T>(symbol: Type<T> | Type<unknown> | AbstractType<T> | AbstractType<unknown> | symbol, instructions?: BeanInstanceConstructInstructions<T>): Registration {\n    if (!instructions || !containsBeansConstructStrategy(instructions)) {\n      instructions = {...instructions, useClass: symbol as Type<T>};\n    }\n    validateBeanConstructInstructions(symbol, instructions);\n\n    // Check that either 'multi' or 'non-multi' beans are registered on the same symbol.\n    const multi = Defined.orElse(instructions.multi, false);\n    if (multi && this._beanRegistry.has(symbol) && Array.from(this._beanRegistry.get(symbol)!).some(metaData => !metaData.multi)) {\n      throw Error('[BeanRegisterError] Trying to register a bean as \\'multi-bean\\' on a symbol that has already registered a \\'non-multi-bean\\'. This is probably not what was intended.');\n    }\n    if (!multi && this._beanRegistry.has(symbol) && Array.from(this._beanRegistry.get(symbol)!).some(metaData => metaData.multi)) {\n      throw Error('[BeanRegisterError] Trying to register a bean on a symbol that has already registered a \\'multi-bean\\'. This is probably not what was intended.');\n    }\n\n    // Destroy an already registered bean under the same symbol, if any, unless multi is set to `true`.\n    if (!multi && this._beanRegistry.has(symbol)) {\n      this.disposeBean(this._beanRegistry.get(symbol)!.values().next().value!);\n    }\n\n    const beanInfo: BeanInfo<T> = {\n      symbol: symbol,\n      beanConstructFn: createBeanConstructFunction(instructions),\n      eager: instructions.eager ?? false,\n      multi: multi,\n      instructions: instructions,\n      constructing: false,\n    };\n\n    if (multi) {\n      const beans = this._beanRegistry.get(symbol) ?? new Set<BeanInfo>();\n      this._beanRegistry.set(symbol, beans.add(beanInfo));\n    }\n    else {\n      this._beanRegistry.set(symbol, new Set<BeanInfo>([beanInfo]));\n    }\n\n    if (beanInfo.eager && this._eagerBeansConstructed) {\n      this.getOrConstructBeanInstance(beanInfo);\n    }\n\n    return {unregister: (): void => this.disposeBean(beanInfo)};\n  }\n\n  /**\n   * Registers a bean under the given symbol, but only if no other bean is registered under that symbol yet.\n   *\n   * For detailed information about how to register a bean, see {@link register}.\n   *\n   * @param  symbol - Symbol under which to register the bean.\n   * @param  instructions - Control bean construction; see {@link BeanInstanceConstructInstructions} for more detail.\n   * @return handle to unregister the bean.\n   */\n  public registerIfAbsent<T>(symbol: Type<T> | Type<unknown> | AbstractType<T> | AbstractType<unknown> | symbol, instructions?: BeanInstanceConstructInstructions<T>): Registration {\n    if (!this._beanRegistry.has(symbol)) {\n      return this.register(symbol, instructions);\n    }\n    return {unregister: noop};\n  }\n\n  /**\n   * Registers a decorator to proxy a bean.\n   *\n   * The decorator is invoked when the bean is constructed. Multiple decorators can be registered to decorate a bean.\n   * They are invoked in the order as registered.\n   *\n   * Decorators must be registered before starting the bean manager.\n   *\n   * @param symbol - Identifies the bean(s) which to decorate. If multiple beans are registered under that symbol, they all are decorated.\n   * @param decorator - Specifies the decorator.\n   */\n  public registerDecorator<T extends BeanDecorator<unknown>>(symbol: Type<unknown> | AbstractType<unknown> | symbol, decorator: {useValue: T} | {useClass?: Type<T>} | {useFactory?: () => T}): void {\n    if (this._started) {\n      throw Error('[BeanManagerLifecycleError] Decorators can only be registered before starting the bean manager.');\n    }\n\n    validateBeanConstructInstructions(symbol, decorator);\n    const constructFn = createBeanConstructFunction(decorator)();\n    Maps.addListValue(this._decoratorRegistry, symbol, constructFn);\n  }\n\n  /**\n   * Registers an initializer that is executed when the bean manager starts. The bean manager is fully started when all initializers are completed.\n   *\n   * Initializers can specify a runlevel in which to execute. Initializers bound to lower runlevels execute before initializers of higher runlevels.\n   * Initializers of the same runlevel may execute in parallel. Runlevels must be >= 0;\n   *\n   * Initializers must be registered before starting the bean manager.\n   */\n  public registerInitializer(initializer: InitializerFn | {useFunction?: InitializerFn; useClass?: Type<Initializer>; useExisting?: Type<Initializer> | AbstractType<Initializer> | symbol; runlevel?: number}): void {\n    if (this._started) {\n      throw Error('[BeanManagerLifecycleError] Initializers can only be registered before starting the bean manager.');\n    }\n\n    const initializerInfo: InitializerInfo = ((): InitializerInfo => {\n      if (typeof initializer === 'function') {\n        return {fn: initializer};\n      }\n      else if (initializer.runlevel !== undefined && initializer.runlevel < 0) {\n        throw Error(`[InitializerRegisterError] The runlevel of an initializer must be >= 0, but was ${initializer.runlevel}.`);\n      }\n      else if (initializer.useFunction) {\n        return {fn: initializer.useFunction, runlevel: initializer.runlevel};\n      }\n      else if (initializer.useClass) {\n        const useClass = initializer.useClass;\n        return {fn: (): Promise<void> => new useClass().init(), runlevel: initializer.runlevel};\n      }\n      else if (initializer.useExisting) {\n        const useExisting = initializer.useExisting;\n        return {fn: (): Promise<void> => Beans.get(useExisting).init(), runlevel: initializer.runlevel};\n      }\n      throw Error('[NullInitializerError] No initializer specified.');\n    })();\n\n    this._initializers.push(initializerInfo);\n  }\n\n  /**\n   * Returns the bean registered under the given symbol.\n   *\n   * By default, if no or multiple beans are registered under the given symbol, an error is thrown.\n   *\n   * @param  symbol - Symbol to look up the bean.\n   * @param  orElse - Controls what to do if no bean is found under the given symbol. If not set and if no bean is found, the bean manager throws an error.\n   * @throws if not finding a bean, or if multiple beans are found under the given symbol.\n   */\n  public get<T>(symbol: Type<T> | AbstractType<T> | Type<unknown> | AbstractType<unknown> | symbol, orElse?: {orElseGet?: T; orElseSupply?: () => T}): T {\n    const beans = this.all(symbol);\n    switch (beans.length) {\n      case 0: {\n        if (orElse?.orElseGet !== undefined) {\n          return orElse.orElseGet;\n        }\n        if (orElse?.orElseSupply) {\n          return orElse.orElseSupply();\n        }\n\n        throw Error(`[NullBeanError] No bean registered under the symbol '${getSymbolName(symbol)}'.`);\n      }\n      case 1: {\n        return beans[0]!;\n      }\n      default: {\n        throw Error(`[MultiBeanError] Multiple beans registered under the symbol '${getSymbolName(symbol)}'.`);\n      }\n    }\n  }\n\n  /**\n   * Returns the bean registered under the given symbol, if any, or returns `undefined` otherwise.\n   *\n   * @param  symbol - Symbol to look up the bean.\n   * @throws if multiple beans are found under the given symbol.\n   */\n  public opt<T>(symbol: Type<T> | AbstractType<T> | Type<unknown> | AbstractType<unknown> | symbol): T | undefined {\n    return this.get(symbol, {orElseSupply: (): undefined => undefined});\n  }\n\n  /**\n   * Returns all beans registered under the given symbol. Returns an empty array if no bean is found.\n   *\n   * @param symbol - Symbol to look up the beans.\n   */\n  public all<T>(symbol: Type<T> | AbstractType<T> | Type<unknown> | AbstractType<unknown> | symbol): T[] {\n    const beanInfos = Array.from(this._beanRegistry.get(symbol) ?? new Set<BeanInfo<T>>()) as BeanInfo<T>[];\n    if (!beanInfos.length) {\n      return [];\n    }\n    if (beanInfos.some(beanInfo => beanInfo.constructing)) {\n      throw Error(`[BeanConstructError] Circular bean construction cycle detected [bean={${getSymbolName(symbol)}}].`);\n    }\n\n    return beanInfos.map(beanInfo => this.getOrConstructBeanInstance(beanInfo));\n  }\n\n  /**\n   * Starts the bean manager by running initializers and constructing eager beans. By default, constructs eager beans after\n   * all initializers completed.\n   *\n   * Initializers with a lower runlevel are executed before initializers with a higher runlevel. After all initializers of the\n   * same runlevel have completed, initializers of the next higher runlevel are executed, and so on. Initializers of the same\n   * runlevel may run in parallel.\n   *\n   * @param  config - Control initialization of the bean manager.\n   * @return A Promise that resolves when all initializers completed.\n   */\n  public async start(config?: BeanManagerConfig): Promise<void> {\n    if (this._started) {\n      throw Error('[BeanManagerLifecycleError] Bean manager already started.');\n    }\n\n    const initializerDefaultRunlevel = config?.initializerDefaultRunlevel ?? 0;\n    const eagerBeanConstructRunlevel = config?.eagerBeanConstructRunlevel ?? ((): number => {\n      if (this._initializers.length === 0) {\n        return initializerDefaultRunlevel + 1;\n      }\n      return Math.max(...this._initializers.map(initializer => initializer.runlevel ?? initializerDefaultRunlevel)) + 1;\n    })();\n\n    // Register initializer to construct eager beans.\n    this.registerInitializer({\n      useFunction: async () => {\n        this.constructEagerBeans();\n        this._eagerBeansConstructed = true;\n      },\n      runlevel: eagerBeanConstructRunlevel,\n    });\n\n    // Run initializers.\n    await this.runInitializers(initializerDefaultRunlevel);\n\n    this._started = true;\n  }\n\n  /**\n   * Destroys all beans managed by the bean manager.\n   *\n   * After calling this method, beans, initializers and decorators unregistered.\n   *\n   * Calling this method has no effect if the bean manager is not started, or failed to start.\n   */\n  public destroy(): void {\n    this.getBeanInfos()\n      .sort(compareByDestroyOrder)\n      .forEach(bean => this.disposeBean(bean));\n\n    this._beanRegistry.clear();\n    this._decoratorRegistry.clear();\n    this._initializers.length = 0;\n    this._runlevel$.next(-1);\n    this._eagerBeansConstructed = false;\n    this._started = false;\n  }\n\n  private disposeBean(beanInfo: BeanInfo): void {\n    const destroyable = beanInfo.instructions.useClass ?? beanInfo.instructions.useFactory;\n    if (destroyable && beanInfo.instance && typeof (beanInfo.instance as PreDestroy).preDestroy === 'function') {\n      try {\n        (beanInfo.instance as PreDestroy).preDestroy();\n      }\n      catch (error) {\n        console.error('Bean threw an error in `preDestroy`', error);\n      }\n    }\n\n    beanInfo.instance = undefined;\n    beanInfo.constructing = false;\n    Maps.removeSetValue(this._beanRegistry, beanInfo.symbol, beanInfo);\n  }\n\n  /**\n   * Returns a Promise that resolves when the bean manager enters the specified runlevel.\n   * The Promise resolves immediately when the bean manager has already entered or completed that runlevel.\n   */\n  public async whenRunlevel(runlevel: number): Promise<void> {\n    return firstValueFrom(this._runlevel$\n      .pipe(filter(currentRunlevel => currentRunlevel >= runlevel)))\n      .then(() => Promise.resolve());\n  }\n\n  private getBeanInfos(): BeanInfo[] {\n    return Array.from(this._beanRegistry.values()).reduce((acc, beanInfos) => acc.concat(Array.from(beanInfos)), new Array<BeanInfo>());\n  }\n\n  /**\n   * Runs registered initializers, where initializers with a lower runlevel are executed before initializers with a higher runlevel.\n   * After all initializers of the same runlevel have completed, initializers of the next higher runlevel are executed, and so on.\n   * Initializers of the same runlevel may run in parallel.\n   */\n  private async runInitializers(defaultInitializerRunlevel: number): Promise<void> {\n    const initializersGroupedByRunlevel = this._initializers.reduce((grouped, initializer) => Maps.addListValue(grouped, initializer.runlevel ?? defaultInitializerRunlevel, initializer.fn), new Map<number, InitializerFn[]>());\n    const runlevels = Array\n      .from(initializersGroupedByRunlevel.keys())\n      .sort((a, b) => (a - b)); // sort numerically, not alphabetically\n\n    for (const runlevel of runlevels) {\n      this._runlevel$.next(runlevel);\n      try {\n        await Promise.all(initializersGroupedByRunlevel.get(runlevel)!.map(initializerFn => initializerFn()));\n      }\n      catch (error) {\n        throw Error(`[InitializerError] Initializer rejected with an error: ${error} [runlevel=${runlevel}]`);\n      }\n    }\n  }\n\n  /**\n   * Constructs beans with an eager construction.\n   */\n  private constructEagerBeans(): void {\n    this.getBeanInfos()\n      .filter(beanInfo => beanInfo.eager)\n      .forEach(beanInfo => this.getOrConstructBeanInstance(beanInfo));\n  }\n\n  /**\n   * Returns the bean instance if already constructed, or constructs the bean otherwise.\n   */\n  private getOrConstructBeanInstance<T>(beanInfo: BeanInfo<T>): T {\n    // Check if the bean is already constructed.\n    if (beanInfo.instance) {\n      return beanInfo.instance;\n    }\n\n    // Construct the bean and decorate it.\n    beanInfo.constructing = true;\n    try {\n      const bean: T = beanInfo.beanConstructFn();\n      const decorators = (this._decoratorRegistry.get(beanInfo.symbol) ?? []) as BeanDecorator<T>[];\n\n      beanInfo.instance = [...decorators].reverse().reduce((decoratedBean, decorator) => decorator.decorate(decoratedBean), bean);\n      beanInfo.constructInstant = ++this._sequence;\n\n      return beanInfo.instance;\n    }\n    finally {\n      beanInfo.constructing = false;\n    }\n  }\n}\n\n/**\n * Provides access to beans registered in the bean manager.\n *\n * @category BeanManager\n */\nexport const Beans = new BeanManager();\n\n/**\n * Compares beans according to their destroy order. If the order is the same, the construction time of the beans is compared, in reverse construction order.\n *\n * @ignore\n */\nfunction compareByDestroyOrder(bean1: BeanInfo, bean2: BeanInfo): number {\n  if ((bean1.instructions.destroyOrder ?? 0) < (bean2.instructions.destroyOrder ?? 0)) {\n    return -1;\n  }\n  if ((bean1.instructions.destroyOrder ?? 0) > (bean2.instructions.destroyOrder ?? 0)) {\n    return 1;\n  }\n  return (bean2.constructInstant ?? 0) - (bean1.constructInstant ?? 0); // reverse construction order\n}\n\n/** @ignore */\nfunction createBeanConstructFunction<T>(instructions: BeanInstanceConstructInstructions<T>): () => T {\n  if (instructions.useValue !== undefined) {\n    const useValue = instructions.useValue;\n    return (): T => useValue;\n  }\n  else if (instructions.useClass) {\n    const useClassFn = instructions.useClass;\n    return (): T => new useClassFn();\n  }\n  else if (instructions.useFactory) {\n    const useFactoryFn = instructions.useFactory;\n    return (): T => useFactoryFn();\n  }\n  else if (instructions.useExisting) {\n    const useExisting = instructions.useExisting;\n    return (): T => Beans.get<T>(useExisting);\n  }\n  throw Error(`[BeanConstructError] Missing bean construction strategy`);\n}\n\n/**\n * Validates passed instructions to construct the bean to be valid.\n *\n * @ignore\n */\nfunction validateBeanConstructInstructions(symbol: Type<unknown> | AbstractType<unknown> | symbol, instructions: BeanInstanceConstructInstructions): void {\n  switch (Object.keys(instructions).filter(instruction => instruction.startsWith('use')).length) {\n    case 0:\n      throw Error(`[BeanRegisterError] Missing bean construction strategy. Expected one of 'useValue', 'useClass', 'useFactory' or 'useExisting' [bean=${symbol.toString()}, instructions=${JSON.stringify(instructions)}]`);\n    case 1:\n      break;\n    default:\n      throw Error(`[BeanRegisterError] Multiple bean construction strategies specified. Expected one of 'useValue', 'useClass', 'useFactory' or 'useExisting' [bean=${symbol.toString()}, instructions=${JSON.stringify(instructions)}]`);\n  }\n\n  if (Object.keys(instructions).includes('useValue') && instructions.useValue === undefined) {\n    throw Error(`[BeanRegisterError] Passing \\`undefined\\` as bean value is not supported [bean=${symbol.toString()}].`);\n  }\n}\n\n/** @ignore */\nfunction containsBeansConstructStrategy(instructions: BeanInstanceConstructInstructions): boolean {\n  return Object.keys(instructions).some(property => property.startsWith('use'));\n}\n\n/**\n * Lifecycle hook will be executed before destroying this bean.\n *\n * @category BeanManager\n */\nexport interface PreDestroy {\n\n  /**\n   * Method invoked before destroying this bean, e.g., when unregistering it, or when shutting down the bean manager.\n   */\n  preDestroy(): void;\n}\n\n/**\n * Metadata about a bean.\n *\n * @ignore\n */\ninterface BeanInfo<T = unknown> {\n  symbol: Type<T> | AbstractType<T> | Type<unknown> | AbstractType<unknown> | symbol;\n  instance?: T;\n  constructing: boolean;\n  beanConstructFn: () => T;\n  constructInstant?: number;\n  eager: boolean;\n  multi: boolean;\n  instructions: BeanInstanceConstructInstructions;\n}\n\n/**\n * @ignore\n */\ninterface InitializerInfo {\n  fn: InitializerFn;\n  runlevel?: number;\n}\n\n/**\n * Describes how a bean instance is created.\n *\n * @category BeanManager\n */\nexport interface BeanInstanceConstructInstructions<T = unknown> {\n  /**\n   * Set if to use a static value as bean.\n   */\n  useValue?: T;\n  /**\n   * Set if to create an instance of a class.\n   */\n  useClass?: Type<T>;\n  /**\n   * Set if to construct the instance with a factory function.\n   */\n  useFactory?: () => T;\n  /**\n   * Set if to create an alias for another bean.\n   */\n  useExisting?: Type<unknown> | AbstractType<unknown> | symbol;\n  /**\n   * Set if to construct the bean eagerly. By default, bean construction is lazy when the bean is looked up for the first time.\n   */\n  eager?: boolean;\n  /**\n   * Set if to provide multiple beans for a single symbol.\n   */\n  multi?: boolean;\n  /**\n   * Control when to destroy the bean when destroying the bean manager.\n   * Beans with a lower destroy order are destroyed before beans with a higher destroy order. Beans of the same destroy order\n   * are destroyed in reverse construction order.\n   */\n  destroyOrder?: number;\n}\n\n/**\n * Allows executing initialization tasks (synchronous or asynchronous) when starting the bean manager. The bean manager is fully started when all initializers are completed.\n *\n * Initializers can specify a runlevel in which to execute. Initializers bound to lower runlevels execute before initializers of higher runlevels.\n * Initializers of the same runlevel may execute in parallel.\n *\n * @see {@link BeanManager.registerInitializer Beans.registerInitializer}\n * @category BeanManager\n */\nexport interface Initializer {\n  /**\n   * Executes some work during bean manager startup.\n   *\n   * @return a Promise that resolves when this initializer completes its initialization.\n   */\n  init(): Promise<void>;\n}\n\n/**\n * Allows executing initialization tasks (synchronous or asynchronous) when starting the bean manager. The bean manager is fully started when all initializers are completed.\n *\n * Initializers can specify a runlevel in which to execute. Initializers bound to lower runlevels execute before initializers of higher runlevels.\n * Initializers of the same runlevel may execute in parallel.\n *\n * The initializer function must return a Promise that resolves when completed its initialization.\n *\n * @see {@link BeanManager.registerInitializer Beans.registerInitializer}\n * @category BeanManager\n */\nexport declare type InitializerFn = () => Promise<void>;\n\n/**\n * Allows intercepting bean method or property invocations.\n * When the bean is constructed, it is passed to the decorator in order to be proxied.\n *\n * @see {@link BeanManager.registerDecorator Beans.registerDecorator}\n * @category BeanManager\n */\nexport interface BeanDecorator<T> {\n  /**\n   * Method invoked when the bean is instantiated.\n   *\n   * @param  bean - The actual bean instance; use it to delegate invoations to the actual bean.\n   * @return proxied bean\n   */\n  decorate(bean: T): T;\n}\n\n/**\n * Represents a symbol of an abstract class.\n *\n * @category BeanManager\n */\nexport interface AbstractType<T> extends Function { // eslint-disable-line @typescript-eslint/no-unsafe-function-type\n  prototype: T;\n}\n\n/**\n * Represents a symbol of a class.\n *\n * @category BeanManager\n */\nexport interface Type<T> extends Function { // eslint-disable-line @typescript-eslint/no-unsafe-function-type\n  new(...args: any[]): T; // eslint-disable-line @typescript-eslint/prefer-function-type\n}\n\n/**\n * @ignore\n */\nfunction getSymbolName(symbol: Type<unknown> | AbstractType<unknown> | symbol): string {\n  return (typeof symbol === 'function' ? symbol.name : symbol.toString());\n}\n\n/**\n * Handle to undo a registration.\n */\nexport interface Registration {\n  unregister: () => void;\n}\n\n/**\n * Control initialization of the bean manager.\n *\n * @category BeanManager\n */\nexport interface BeanManagerConfig {\n  /**\n   * Defines the runlevel in which to construct eager beans.\n   * If not set, eager beans are constructed after all registered initializers completed.\n   */\n  eagerBeanConstructRunlevel?: number;\n  /**\n   * Defines the runlevel in which initializers, that do not specify a runlevel, should be executed.\n   * If not set, initializers not specifying a runlevel are bound to the runlevel <code>0</code>.\n   */\n  initializerDefaultRunlevel?: number;\n}\n","/*\n * Copyright (c) 2018-2019 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n *  SPDX-License-Identifier: EPL-2.0\n */\n\n/*\n * Secondary entrypoint: '@scion/toolkit/bean-manager'\n *\n * @see https://github.com/ng-packagr/ng-packagr/blob/master/docs/secondary-entrypoints.md\n */\nexport * from './bean-manager';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;AAQG;AAMH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEG;MACU,WAAW,CAAA;AAEd,IAAA,aAAa,GAAG,IAAI,GAAG,EAAiE;AACxF,IAAA,kBAAkB,GAAG,IAAI,GAAG,EAA4E;IACxG,aAAa,GAAsB,EAAE;IAErC,SAAS,GAAG,CAAC;AACb,IAAA,UAAU,GAAG,IAAI,eAAe,CAAS,CAAC,CAAC,CAAC;IAC5C,sBAAsB,GAAG,KAAK;IAC9B,QAAQ,GAAG,KAAK;AAExB;;;;;;;;;;;;;;AAcG;IACI,QAAQ,CAAI,MAAkF,EAAE,YAAmD,EAAA;QACxJ,IAAI,CAAC,YAAY,IAAI,CAAC,8BAA8B,CAAC,YAAY,CAA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