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

Class Node

src/construct.ts:34–495  ·  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 app-unique id for this construct, use `addr`.
61 */
62 public readonly id: string;
63
64 private _locked = false; // if this is "true", addChild will fail
65 private _children: { [id: string]: IConstruct } | undefined;
66 private _context: { [key: string]: any } | undefined;
67 private _metadata: Array<MetadataEntry> | undefined;
68 private _dependencies: Set<IDependable> | undefined;
69 private _defaultChild: IConstruct | undefined;
70 private _validations: Array<IValidation> | undefined;
71 private _addr?: string; // cache
72
73 public constructor(private readonly host: Construct, scope: IConstruct, id: string) {
74 id = id ?? ''; // if undefined, convert to empty string
75
76 this.id = sanitizeId(id);
77 this.scope = scope;
78
79 if (scope && !this.id) {
80 throw new Error('Only root constructs may have an empty ID');
81 }
82
83 // add to parent scope
84 scope?.node.addChild(host, this.id);
85 }
86
87 /**
88 * The full, absolute path of this construct in the tree.
89 *
90 * Components are separated by '/'.
91 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…