JSPM

constructs

4.1.1-pre.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3373715
  • Score
    100M100P100Q197505F
  • License Apache-2.0

A programming model for composable configuration

Package Exports

  • constructs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (constructs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Constructs Programming Model

Define composable configuration models through code

Release npm version PyPI version NuGet version Maven Central

User Manual

Scope Relocation

The path of a scope is used as a seed for all names generated within that scope such as logical names in the AWS CDK or node.uniqueId.

There are use cases in which an entire construct subtree (scope) needs to be "relocated" to a different path. The main use case is in order to allow refactoring while preserving old names.

Be careful: relocating a scope may result in duplicate names. Use at your own risk.

To relocate a scope, use the node.relocate(root) method. This method can only be called before any children are added to the scope and it will impact the value of node.path and node.uniqueId.

If implementing name generation, make sure to refer to node.path as the root of the scope's path instead of node.scopes.

Let's say we had a scope foo that was originally under the foo path and it has a child called childOfFoo:

const foo = new Construct(root, 'foo');
const childOfFoo = new Construct(foo, 'childOfFoo');
expect(Node.of(foo).path).toBe('foo');
expect(Node.of(childOfFoo).path).toBe('foo/childOfFoo');

Now, we want to refactor our code and hoist it under a new root, say baz:

const baz = new Construct(root, 'baz');
const foo = new Construct(baz, 'foo');
const childOfFoo = new Construct(foo, 'childOfFoo');

// now the paths (andu uniqudIds) are different
expect(Node.of(foo).path).toBe('bar/foo');
expect(Node.of(childOfFoo).path).toBe('baz/foo/childOfFoo');

If we relocate foo to foo, the original paths are preserved:

const baz = new Construct(root, 'baz');
const foo = new Construct(baz, 'foo');
Node.of(construct).relocate('foo'); // must be done before adding children

const childOfFoo = new Construct(foo, 'childOfFoo');

// now the paths (andu uniqudIds) are different
expect(Node.of(foo).path).toBe('foo');
expect(Node.of(childOfFoo).path).toBe('foo/childOfFoo');

Similarly, the uniqueId of a construct will be derived from this path.

Contributing

This project has adopted the Amazon Open Source Code of Conduct.

We welcome community contributions and pull requests. See our contribution guide for more information on how to report issues, set up a development environment and submit code.

License

This project is distributed under the Apache License, Version 2.0.