MCPcopy Create free account
hub / github.com/aws/constructs / Node

Class Node

src/construct.ts:34–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 * Represents the construct node in the scope tree.
33 */
34export class Node {
35 /**
36 * Separator used to delimit construct path components.
37 */
38 public static readonly PATH_SEP = '/';
39
40 /**
41 * Returns the node associated with a construct.
42 * @param construct the construct
43 *
44 * @deprecated use `construct.node` instead
45 */
46 public static of(construct: IConstruct): Node {
47 return construct.node;
48 }
49
50 /**
51 * Returns the scope in which this construct is defined.
52 *
53 * The value is `undefined` at the root of the construct scope tree.
54 */
55 public readonly scope?: IConstruct;
56
57 /**
58 * The id of this construct within the current scope.
59 *
60 * This is a scope-unique id. To obtain an id that reflects the full location
61 * of this construct in the tree, use `path` or `addr`.
62 */
63 public readonly id: string;
64
65 /**
66 * The full, absolute path of this construct in the tree.
67 *
68 * Components are separated by '/'.
69 */
70 public readonly path: string;
71
72 private _locked = false; // if this is "true", addChild will fail
73 private _children: { [id: string]: IConstruct } | undefined;
74 private _context: { [key: string]: any } | undefined;
75 private _metadata: Array<MetadataEntry> | undefined;
76 private _dependencies: Set<IDependable> | undefined;
77 private _defaultChild: IConstruct | undefined;
78 private _validations: Array<IValidation> | undefined;
79 private _addr?: string; // cache
80 private _scopes: readonly IConstruct[];
81
82
83 public constructor(private readonly host: Construct, scope: IConstruct, id: string) {
84 id = id ?? ''; // if undefined, convert to empty string
85
86 this.id = sanitizeId(id);
87 this.scope = scope;
88
89 if (scope && !this.id) {
90 throw new Error('Only root constructs may have an empty ID');
91 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected