aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
98 lines (97 loc) • 3.19 kB
TypeScript
import { Construct, IConstruct } from 'constructs';
/**
* A construct centric view of a stack trace
*/
export interface ConstructTrace {
/**
* The construct node id
*/
readonly id: string;
/**
* The construct path
*/
readonly path: string;
/**
* The construct trace for the next construct
* in the trace tree
*
* @default - undefined if this is the last construct in the tree
*/
readonly child?: ConstructTrace;
/**
* The name of the construct
*
* This will be equal to the fqn so will also include
* library information
*
* @default - undefined if this is a locally defined construct
*/
readonly construct?: string;
/**
* The version of the library the construct comes from
*
* @default - undefined if this is a locally defined construct
*/
readonly libraryVersion?: string;
/**
* If `CDK_DEBUG` is set to true, then this will show
* the line from the stack trace that contains the location
* in the source file where the construct is defined.
*
* If `CDK_DEBUG` is not set then this will instruct the user
* to run with `--debug` if they would like the location
*
* @default - undefined if the construct comes from a library
* and the location would point to node_modules
*/
readonly location?: string;
}
/**
* Utility class to help accessing information on constructs in the
* construct tree. This can be created once and shared between
* all the validation plugin executions.
*/
export declare class ConstructTree {
/**
* A cache of the ConstructTrace by node.path. Each construct
*/
private readonly _constructByPath;
private readonly _constructByTemplatePathAndLogicalId;
private readonly root;
constructor(root: IConstruct);
private setLogicalId;
/**
* Turn a construct path into a trace
*
* The trace contains all constructs from the root to the construct indicated
* by the given path. It does not include the root itself.
*/
traceFromPath(constructPath: string): ConstructTrace;
/**
* Convert a Tree Metadata Node into a ConstructTrace object, except its child and stack trace info
*
* FIXME: This could probably use the construct tree directly.
*/
constructTraceLevelFromTreeNode(node: IConstruct): Omit<ConstructTrace, 'child' | 'location'>;
/**
* Return the stack trace for a given construct path
*
* Returns a stack trace if stack trace information is found, or `undefined` if not.
*/
private stackTrace;
/**
* Get a specific Construct by the node.addr
*
* @param path the node.addr of the construct
* @returns the Construct
*/
getConstructByPath(path: string): Construct | undefined;
/**
* Get a specific Construct by the CfnResource logical ID. This will
* be the construct.node.defaultChild with the given ID
*
* @param logicalId the ID of the CfnResource
* @returns the Construct
*/
getConstructByLogicalId(templateFile: string, logicalId: string): Construct | undefined;
}