import { Handler } from './interfaces/handler.interface'; import { ServiceOptions } from './interfaces/service-options.interface'; import { ContainerIdentifier } from './types/container-identifier.type'; import { ServiceIdentifier } from './types/service-identifier.type'; /** * TypeDI can have multiple containers. * One container is ContainerInstance. */ export declare class ContainerInstance { /** Container instance id. */ readonly id: ContainerIdentifier; /** Metadata for all registered services in this container. */ private metadataMap; /** * Services registered with 'multiple: true' are saved as simple services * with a generated token and the mapping between the original ID and the * generated one is stored here. This is handled like this to allow simplifying * the inner workings of the service instance. */ private multiServiceIds; /** * All registered handlers. The @Inject() decorator uses handlers internally to mark a property for injection. **/ private readonly handlers; /** * The default global container. By default services are registered into this * container when registered via `Container.set()` or `@Service` decorator. */ private static _default; static get default(): ContainerInstance; /** * Indicates if the container has been disposed or not. * Any function call should fail when called after being disposed. * * NOTE: Currently not in used */ private disposed; constructor(id: ContainerIdentifier); /** * Checks if the service with given name or type is registered service container. * Optionally, parameters can be passed in case if instance is initialized in the container for the first time. */ has(identifier: ServiceIdentifier): boolean; /** * Retrieves the service with given name or type from the service container. * Optionally, parameters can be passed in case if instance is initialized in the container for the first time. */ get(identifier: ServiceIdentifier): T; /** * Gets all instances registered in the container of the given service identifier. * Used when service defined with multiple: true flag. */ getMany(identifier: ServiceIdentifier): T[]; /** * Sets a value for the given type or service name in the container. */ set(serviceOptions: ServiceOptions): this; /** * Removes services with a given service identifiers. */ remove(identifierOrIdentifierArray: ServiceIdentifier | ServiceIdentifier[]): this; /** * Gets a separate container instance for the given instance id. */ of(containerId?: ContainerIdentifier): ContainerInstance; /** * Registers a new handler. */ registerHandler(handler: Handler): ContainerInstance; /** * Helper method that imports given services. */ import(services: Function[]): ContainerInstance; /** * Completely resets the container by removing all previously registered services from it. */ reset(options?: { strategy: 'resetValue' | 'resetServices'; }): this; dispose(): Promise; private throwIfDisposed; /** * Gets the value belonging to passed in `ServiceMetadata` instance. * * - if `serviceMetadata.value` is already set it is immediately returned * - otherwise the requested type is resolved to the value saved to `serviceMetadata.value` and returned */ private getServiceValue; /** * Initializes all parameter types for a given target service class. */ private initializeParams; /** * Checks if given parameter type is primitive type or not. */ private isPrimitiveParamType; /** * Applies all registered handlers on a given target class. */ private applyPropertyHandlers; /** * Checks if the given service metadata contains a destroyable service instance and destroys it in place. If the service * contains a callable function named `destroy` it is called but not awaited and the return value is ignored.. * * @param serviceMetadata the service metadata containing the instance to destroy * @param force when true the service will be always destroyed even if it's cannot be re-created */ private disposeServiceInstance; } /** We export the default container under the Container alias. */ export declare const Container: ContainerInstance;