aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
69 lines (68 loc) • 2.42 kB
TypeScript
import { Construct, IConstruct } from 'constructs';
/**
* This defines the values needed for Injection.
*/
export interface InjectionContext {
/**
* scope from the constructor
*/
readonly scope: Construct;
/**
* id from the Construct constructor
*/
readonly id: string;
}
/**
* This interface define an inject function that operates on a Construct's Property.
* The Construct must have a constructUniqueId to uniquely identify itself.
*/
export interface IPropertyInjector {
/**
* The unique Id of the Construct class.
*/
readonly constructUniqueId: string;
/**
* The injector to be applied to the constructor properties of the Construct.
*/
inject(originalProps: any, context: InjectionContext): any;
}
/**
* This is a collection of ProjectInjectors assigned to this scope.
* It is keyed by constructUniqueId. There can be only one ProjectInjector for a constructUniqueId.
*/
export declare class PropertyInjectors {
/**
* Return whether the given object has a PropertyInjectors property.
*
* We do attribute detection since we can't reliably use 'instanceof'.
*/
static hasPropertyInjectors(x: any): x is PropertyInjectors;
/**
* Returns the `PropertyInjectors` object associated with a construct scope.
* If `PropertyInjectors` object doesn't exist on this scope, then it creates one and attaches it to scope.
* @param scope The scope for which these PropertyInjectors will apply.
*/
static of(scope: IConstruct): PropertyInjectors;
/**
* The scope attached to Injectors.
*/
readonly scope: IConstruct;
private readonly _injectors;
private constructor();
/**
* Add a list of IPropertyInjectors to this collection of PropertyInjectors.
* @param propsInjectors - a list of IPropertyInjector
*/
add(...propsInjectors: IPropertyInjector[]): void;
/**
* Get the PropertyInjector that is registered to the Construct's uniqueId.
* @param uniqueId - the construct uniqueId
* @returns - the IPropertyInjector for that construct uniqueId
*/
for(uniqueId: string): IPropertyInjector | undefined;
/**
* This returns a list of the Constructs that are supporting by this PropertyInjectors.
* @returns a list of string showing the supported Constructs.
*/
supportedClasses(): string[];
}