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. |
host
Required
- Type: Construct
scope
Required
- Type: IConstruct
id
Required
- Type: string
Methods
Name | Description |
---|---|
addDependency |
Add an ordering dependency on another Construct. |
addError |
Adds an { "error": |
addInfo |
Adds a { "info": |
addMetadata |
Adds a metadata entry to this construct. |
addWarning |
Adds a { "warning": |
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.
- Type: IDependable
addError
public addError(message: string): void
Adds an { "error":
The toolkit will fail synthesis when errors are reported.
- Type: string
The error message.
addInfo
public addInfo(message: string): void
Adds a { "info":
The toolkit will display the info message when apps are synthesized.
- 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.
- Type: string
a string denoting the type of metadata.
- Type: any
the value of the metadata (can be a Token).
If null/undefined, metadata will not be added.
- 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":
The toolkit will display the warning when an app is synthesized, or fail if run in --strict mode.
- Type: string
The warning message.
findAll
public findAll(order?: ConstructOrder): IConstruct[]
Return this construct and all of its children in the given order.
- Type: ConstructOrder
findChild
public findChild(id: string): IConstruct
Return a direct child by id.
Throws an error if the child is not found.
- 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.
- Type: string
The context key.
- Type: any
The context value.
tryFindChild
public tryFindChild(id: string): IConstruct
Return a direct child by id, or undefined.
- 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.
- Type: string
The context key.
tryRemoveChild
public tryRemoveChild(childName: string): boolean
Remove the child with the given name, if present.
- 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
.
- Type: ConstructNode
The root node.
~~synth
~~
import { ConstructNode } from '@alicloud/ros-cdk-core'
ConstructNode.synth(node: ConstructNode, options?: SynthesisOptions)
Synthesizes a CloudAssembly from a construct tree.
- Type: ConstructNode
The root of the construct tree.
- Type: SynthesisOptions
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.
- Type: ConstructNode
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" . |
children
Required
public readonly children: IConstruct[];
- Type: IConstruct[]
All direct children of this construct.
dependencies
Required
public readonly dependencies: Dependency[];
- Type: Dependency[]
Return all dependencies registered on this node or any of its children.
id
Required
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
.
locked
Required
public readonly locked: boolean;
- Type: boolean
Returns true if this construct or the scopes in which it is defined are locked.
metadata
Required
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.
path
Required
public readonly path: string;
- Type: string
The full, absolute path of this construct in the tree.
Components are separated by '/'.
root
Required
public readonly root: IConstruct;
- Type: IConstruct
scopes
Required
public readonly scopes: IConstruct[];
- Type: IConstruct[]
All parent scopes of this construct.
uniqueId
Required
public readonly uniqueId: string;
- Type: string
A tree-global unique alphanumeric identifier for this construct.
Includes all components of the tree.
scope
Optional
public readonly scope: IConstruct;
- Type: IConstruct
Returns the scope in which this construct is defined.
The value is undefined
at the root of the construct scope tree.
defaultChild
Optional
public readonly defaultChild: IConstruct;
- Type: 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_SEP
Required
public readonly PATH_SEP: string;
- Type: string
Separator used to delimit construct path components.