Skip to content

ConstructNode

Represents the construct node in the scope tree.

Initializers

import { ConstructNode } from '@alicloud/ros-cdk-core'
new ConstructNode(host: Construct, scope: IConstruct, id: string)
Name Type Description
host Construct No description.
scope IConstruct No description.
id string No description.

hostRequired


scopeRequired


idRequired

  • Type: string

Methods

Name Description
addDependency Add an ordering dependency on another Construct.
addError Adds an { "error": } metadata entry to this construct.
addInfo Adds a { "info": } metadata entry to this construct.
addMetadata Adds a metadata entry to this construct.
addWarning Adds a { "warning": } metadata entry to this construct.
findAll Return this construct and all of its children in the given order.
findChild Return a direct child by id.
setContext This can be used to set contextual values.
tryFindChild Return a direct child by id, or undefined.
tryGetContext Retrieves a value from tree context.
tryRemoveChild Remove the child with the given name, if present.

addDependency

public addDependency(dependencies: IDependable): void

Add an ordering dependency on another Construct.

All constructs in the dependency's scope will be deployed before any construct in this construct's scope.

dependenciesRequired


addError

public addError(message: string): void

Adds an { "error": } metadata entry to this construct.

The toolkit will fail synthesis when errors are reported.

messageRequired

  • Type: string

The error message.


addInfo

public addInfo(message: string): void

Adds a { "info": } metadata entry to this construct.

The toolkit will display the info message when apps are synthesized.

messageRequired

  • Type: string

The info message.


addMetadata

public addMetadata(type: string, data: any, fromFunction?: any): void

Adds a metadata entry to this construct.

Entries are arbitrary values and will also include a stack trace to allow tracing back to the code location for when the entry was added. It can be used, for example, to include source mapping in templates to improve diagnostics.

typeRequired

  • Type: string

a string denoting the type of metadata.


dataRequired

  • Type: any

the value of the metadata (can be a Token).

If null/undefined, metadata will not be added.


fromFunctionOptional

  • Type: any

a function under which to restrict the metadata entry's stack trace (defaults to this.addMetadata).


addWarning

public addWarning(message: string): void

Adds a { "warning": } metadata entry to this construct.

The toolkit will display the warning when an app is synthesized, or fail if run in --strict mode.

messageRequired

  • Type: string

The warning message.


findAll

public findAll(order?: ConstructOrder): IConstruct[]

Return this construct and all of its children in the given order.

orderOptional


findChild

public findChild(id: string): IConstruct

Return a direct child by id.

Throws an error if the child is not found.

idRequired

  • Type: string

Identifier of direct child.


setContext

public setContext(key: string, value: any): void

This can be used to set contextual values.

Context must be set before any children are added, since children may consult context info during construction. If the key already exists, it will be overridden.

keyRequired

  • Type: string

The context key.


valueRequired

  • Type: any

The context value.


tryFindChild

public tryFindChild(id: string): IConstruct

Return a direct child by id, or undefined.

idRequired

  • Type: string

Identifier of direct child.


tryGetContext

public tryGetContext(key: string): any

Retrieves a value from tree context.

Context is usually initialized at the root, but can be overridden at any point in the tree.

keyRequired

  • Type: string

The context key.


tryRemoveChild

public tryRemoveChild(childName: string): boolean

Remove the child with the given name, if present.

childNameRequired

  • Type: string

Static Functions

Name Description
prepare Invokes "prepare" on all constructs (depth-first, post-order) in the tree under node.
synth Synthesizes a CloudAssembly from a construct tree.
validate Invokes "validate" on all constructs in the tree (depth-first, pre-order) and returns the list of all errors.

~~prepare~~

import { ConstructNode } from '@alicloud/ros-cdk-core'
ConstructNode.prepare(node: ConstructNode)

Invokes "prepare" on all constructs (depth-first, post-order) in the tree under node.

nodeRequired

The root node.


~~synth~~

import { ConstructNode } from '@alicloud/ros-cdk-core'
ConstructNode.synth(node: ConstructNode, options?: SynthesisOptions)

Synthesizes a CloudAssembly from a construct tree.

nodeRequired

The root of the construct tree.


optionsOptional

Synthesis options.


validate

import { ConstructNode } from '@alicloud/ros-cdk-core'
ConstructNode.validate(node: ConstructNode)

Invokes "validate" on all constructs in the tree (depth-first, pre-order) and returns the list of all errors.

An empty list indicates that there are no errors.

nodeRequired

The root node.


Properties

Name Type Description
children IConstruct[] All direct children of this construct.
dependencies Dependency[] Return all dependencies registered on this node or any of its children.
id string The id of this construct within the current scope.
locked boolean Returns true if this construct or the scopes in which it is defined are locked.
metadata @alicloud/ros-cdk-cxapi.MetadataEntry[] An immutable array of metadata objects associated with this construct.
path string The full, absolute path of this construct in the tree.
root IConstruct No description.
scopes IConstruct[] All parent scopes of this construct.
uniqueId string A tree-global unique alphanumeric identifier for this construct.
scope IConstruct Returns the scope in which this construct is defined.
defaultChild IConstruct Returns the child construct that has the id Default or Resource".

childrenRequired

public readonly children: IConstruct[];

All direct children of this construct.


dependenciesRequired

public readonly dependencies: Dependency[];

Return all dependencies registered on this node or any of its children.


idRequired

public readonly id: string;
  • Type: string

The id of this construct within the current scope.

This is a a scope-unique id. To obtain an app-unique id for this construct, use uniqueId.


lockedRequired

public readonly locked: boolean;
  • Type: boolean

Returns true if this construct or the scopes in which it is defined are locked.


metadataRequired

public readonly metadata: MetadataEntry[];
  • Type: @alicloud/ros-cdk-cxapi.MetadataEntry[]

An immutable array of metadata objects associated with this construct.

This can be used, for example, to implement support for deprecation notices, source mapping, etc.


pathRequired

public readonly path: string;
  • Type: string

The full, absolute path of this construct in the tree.

Components are separated by '/'.


rootRequired

public readonly root: IConstruct;

scopesRequired

public readonly scopes: IConstruct[];

All parent scopes of this construct.


uniqueIdRequired

public readonly uniqueId: string;
  • Type: string

A tree-global unique alphanumeric identifier for this construct.

Includes all components of the tree.


scopeOptional

public readonly scope: IConstruct;

Returns the scope in which this construct is defined.

The value is undefined at the root of the construct scope tree.


defaultChildOptional

public readonly defaultChild: IConstruct;

Returns the child construct that has the id Default or Resource".

This is usually the construct that provides the bulk of the underlying functionality. Useful for modifications of the underlying construct that are not available at the higher levels. Override the defaultChild property.

This should only be used in the cases where the correct default child is not named 'Resource' or 'Default' as it should be.

If you set this to undefined, the default behavior of finding the child named 'Resource' or 'Default' will be used.


Constants

Name Type Description
PATH_SEP string Separator used to delimit construct path components.

PATH_SEPRequired

public readonly PATH_SEP: string;
  • Type: string

Separator used to delimit construct path components.