@aws-cdk/toolkit-lib 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/build-info.json +2 -2
  2. package/lib/actions/bootstrap/index.js +69 -5
  3. package/lib/actions/diff/index.d.ts +8 -0
  4. package/lib/actions/diff/index.js +1 -1
  5. package/lib/actions/diff/private/helpers.d.ts +16 -0
  6. package/lib/actions/diff/private/helpers.js +31 -6
  7. package/lib/actions/index.d.ts +1 -0
  8. package/lib/actions/index.js +2 -1
  9. package/lib/actions/refactor/index.d.ts +15 -0
  10. package/lib/actions/refactor/index.js +3 -0
  11. package/lib/api/cloud-assembly/cached-source.d.ts +36 -0
  12. package/lib/api/cloud-assembly/cached-source.js +52 -0
  13. package/lib/api/cloud-assembly/index.d.ts +1 -0
  14. package/lib/api/cloud-assembly/index.js +2 -1
  15. package/lib/api/cloud-assembly/private/borrowed-assembly.d.ts +14 -0
  16. package/lib/api/cloud-assembly/private/borrowed-assembly.js +22 -0
  17. package/lib/api/cloud-assembly/private/context-aware-source.d.ts +18 -5
  18. package/lib/api/cloud-assembly/private/context-aware-source.js +25 -8
  19. package/lib/api/cloud-assembly/private/index.d.ts +0 -2
  20. package/lib/api/cloud-assembly/private/index.js +1 -3
  21. package/lib/api/cloud-assembly/private/prepare-source.d.ts +37 -8
  22. package/lib/api/cloud-assembly/private/prepare-source.js +76 -17
  23. package/lib/api/cloud-assembly/private/readable-assembly.d.ts +26 -0
  24. package/lib/api/cloud-assembly/private/readable-assembly.js +34 -0
  25. package/lib/api/cloud-assembly/private/source-builder.d.ts +27 -0
  26. package/lib/api/cloud-assembly/private/source-builder.js +139 -30
  27. package/lib/api/cloud-assembly/private/stack-assembly.d.ts +9 -4
  28. package/lib/api/cloud-assembly/private/stack-assembly.js +21 -3
  29. package/lib/api/cloud-assembly/source-builder.d.ts +6 -0
  30. package/lib/api/cloud-assembly/source-builder.js +1 -1
  31. package/lib/api/cloud-assembly/types.d.ts +32 -1
  32. package/lib/api/cloud-assembly/types.js +1 -1
  33. package/lib/api/shared-private.js +373 -20
  34. package/lib/api/shared-private.js.map +4 -4
  35. package/lib/api/shared-public.d.ts +82 -61
  36. package/lib/index_bg.wasm +0 -0
  37. package/lib/toolkit/private/index.d.ts +4 -0
  38. package/lib/toolkit/private/index.js +7 -2
  39. package/lib/toolkit/toolkit.d.ts +15 -2
  40. package/lib/toolkit/toolkit.js +326 -162
  41. package/package.json +11 -11
  42. package/lib/api/cloud-assembly/private/cached-source.d.ts +0 -15
  43. package/lib/api/cloud-assembly/private/cached-source.js +0 -25
  44. package/lib/api/cloud-assembly/private/identity-source.d.ts +0 -10
  45. package/lib/api/cloud-assembly/private/identity-source.js +0 -17
@@ -1112,7 +1112,7 @@ export interface StackSelector {
1112
1112
  /**
1113
1113
  * The current action being performed by the CLI. 'none' represents the absence of an action.
1114
1114
  */
1115
- export type ToolkitAction = "assembly" | "bootstrap" | "synth" | "list" | "diff" | "deploy" | "rollback" | "watch" | "destroy" | "doctor" | "gc" | "import" | "metadata" | "init" | "migrate";
1115
+ export type ToolkitAction = "assembly" | "bootstrap" | "synth" | "list" | "diff" | "deploy" | "rollback" | "watch" | "destroy" | "doctor" | "gc" | "import" | "metadata" | "init" | "migrate" | "refactor";
1116
1116
  /**
1117
1117
  * The reporting level of the message.
1118
1118
  * All messages are always reported, it's up to the IoHost to decide what to log.
@@ -1641,66 +1641,6 @@ export interface StackSelectionDetails {
1641
1641
  */
1642
1642
  readonly stacks: StackSelector;
1643
1643
  }
1644
- /**
1645
- * The computed file watch settings
1646
- */
1647
- export interface WatchSettings {
1648
- /**
1649
- * The directory observed for file changes
1650
- */
1651
- readonly watchDir: string;
1652
- /**
1653
- * List of include patterns for watching files
1654
- */
1655
- readonly includes: string[];
1656
- /**
1657
- * List of excludes patterns for watching files
1658
- */
1659
- readonly excludes: string[];
1660
- }
1661
- export interface FileWatchEvent {
1662
- /**
1663
- * The change to the path
1664
- */
1665
- readonly event: string;
1666
- /**
1667
- * The path that has an observed event
1668
- */
1669
- readonly path?: string;
1670
- }
1671
- /**
1672
- * Payload when stack monitoring is starting or stopping for a given stack deployment.
1673
- */
1674
- export interface CloudWatchLogMonitorControlEvent {
1675
- /**
1676
- * A unique identifier for a monitor
1677
- *
1678
- * Use this value to attribute events received for concurrent log monitoring.
1679
- */
1680
- readonly monitor: string;
1681
- /**
1682
- * The names of monitored log groups
1683
- */
1684
- readonly logGroupNames: string[];
1685
- }
1686
- /**
1687
- * Represents a CloudWatch Log Event that will be
1688
- * printed to the terminal
1689
- */
1690
- export interface CloudWatchLogEvent {
1691
- /**
1692
- * The log event message
1693
- */
1694
- readonly message: string;
1695
- /**
1696
- * The name of the log group
1697
- */
1698
- readonly logGroupName: string;
1699
- /**
1700
- * The time at which the event occurred
1701
- */
1702
- readonly timestamp: Date;
1703
- }
1704
1644
  interface IDifference<ValueType> {
1705
1645
  readonly oldValue: ValueType | undefined;
1706
1646
  readonly newValue: ValueType | undefined;
@@ -1761,6 +1701,87 @@ interface Resource {
1761
1701
  };
1762
1702
  [key: string]: any;
1763
1703
  }
1704
+ interface TypedMapping {
1705
+ readonly type: string;
1706
+ readonly sourcePath: string;
1707
+ readonly destinationPath: string;
1708
+ }
1709
+ /**
1710
+ * Output of the refactor command
1711
+ */
1712
+ export interface RefactorResult {
1713
+ /**
1714
+ * Mappings along with the resource type
1715
+ */
1716
+ readonly typedMappings?: TypedMapping[];
1717
+ /**
1718
+ * Ambiguous path correspondences, if any
1719
+ */
1720
+ readonly ambiguousPaths?: [
1721
+ string[],
1722
+ string[]
1723
+ ][];
1724
+ }
1725
+ /**
1726
+ * The computed file watch settings
1727
+ */
1728
+ export interface WatchSettings {
1729
+ /**
1730
+ * The directory observed for file changes
1731
+ */
1732
+ readonly watchDir: string;
1733
+ /**
1734
+ * List of include patterns for watching files
1735
+ */
1736
+ readonly includes: string[];
1737
+ /**
1738
+ * List of excludes patterns for watching files
1739
+ */
1740
+ readonly excludes: string[];
1741
+ }
1742
+ export interface FileWatchEvent {
1743
+ /**
1744
+ * The change to the path
1745
+ */
1746
+ readonly event: string;
1747
+ /**
1748
+ * The path that has an observed event
1749
+ */
1750
+ readonly path?: string;
1751
+ }
1752
+ /**
1753
+ * Payload when stack monitoring is starting or stopping for a given stack deployment.
1754
+ */
1755
+ export interface CloudWatchLogMonitorControlEvent {
1756
+ /**
1757
+ * A unique identifier for a monitor
1758
+ *
1759
+ * Use this value to attribute events received for concurrent log monitoring.
1760
+ */
1761
+ readonly monitor: string;
1762
+ /**
1763
+ * The names of monitored log groups
1764
+ */
1765
+ readonly logGroupNames: string[];
1766
+ }
1767
+ /**
1768
+ * Represents a CloudWatch Log Event that will be
1769
+ * printed to the terminal
1770
+ */
1771
+ export interface CloudWatchLogEvent {
1772
+ /**
1773
+ * The log event message
1774
+ */
1775
+ readonly message: string;
1776
+ /**
1777
+ * The name of the log group
1778
+ */
1779
+ readonly logGroupName: string;
1780
+ /**
1781
+ * The time at which the event occurred
1782
+ */
1783
+ readonly timestamp: Date;
1784
+ }
1764
1785
  /**
1765
1786
  * A resource affected by a change
1766
1787
  */
package/lib/index_bg.wasm CHANGED
Binary file
@@ -10,6 +10,10 @@ export interface ToolkitServices {
10
10
  }
11
11
  /**
12
12
  * Creates a Toolkit internal CloudAssembly from a CloudAssemblySource.
13
+ *
14
+ * The caller assumes ownership of the returned `StackAssembly`, and `dispose()`
15
+ * should be called on this object after use.
16
+ *
13
17
  * @param assemblySource the source for the cloud assembly
14
18
  * @param cache if the assembly should be cached, default: `true`
15
19
  * @returns the CloudAssembly object
@@ -4,6 +4,10 @@ exports.assemblyFromSource = assemblyFromSource;
4
4
  const private_1 = require("../../api/cloud-assembly/private");
5
5
  /**
6
6
  * Creates a Toolkit internal CloudAssembly from a CloudAssemblySource.
7
+ *
8
+ * The caller assumes ownership of the returned `StackAssembly`, and `dispose()`
9
+ * should be called on this object after use.
10
+ *
7
11
  * @param assemblySource the source for the cloud assembly
8
12
  * @param cache if the assembly should be cached, default: `true`
9
13
  * @returns the CloudAssembly object
@@ -13,8 +17,9 @@ async function assemblyFromSource(ioHelper, assemblySource, cache = true) {
13
17
  return assemblySource;
14
18
  }
15
19
  if (cache) {
16
- return new private_1.StackAssembly(await new private_1.CachedCloudAssemblySource(assemblySource).produce(), ioHelper);
20
+ const ret = new private_1.StackAssembly(await assemblySource.produce(), ioHelper);
21
+ return ret;
17
22
  }
18
23
  return new private_1.StackAssembly(await assemblySource.produce(), ioHelper);
19
24
  }
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQW1CQSxnREFVQztBQTNCRCw4REFBNEY7QUFXNUY7Ozs7O0dBS0c7QUFDSSxLQUFLLFVBQVUsa0JBQWtCLENBQUMsUUFBa0IsRUFBRSxjQUFvQyxFQUFFLFFBQWlCLElBQUk7SUFDdEgsSUFBSSxjQUFjLFlBQVksdUJBQWEsRUFBRSxDQUFDO1FBQzVDLE9BQU8sY0FBYyxDQUFDO0lBQ3hCLENBQUM7SUFFRCxJQUFJLEtBQUssRUFBRSxDQUFDO1FBQ1YsT0FBTyxJQUFJLHVCQUFhLENBQUMsTUFBTSxJQUFJLG1DQUF5QixDQUFDLGNBQWMsQ0FBQyxDQUFDLE9BQU8sRUFBRSxFQUFFLFFBQVEsQ0FBQyxDQUFDO0lBQ3BHLENBQUM7SUFFRCxPQUFPLElBQUksdUJBQWEsQ0FBQyxNQUFNLGNBQWMsQ0FBQyxPQUFPLEVBQUUsRUFBRSxRQUFRLENBQUMsQ0FBQztBQUNyRSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiXG5pbXBvcnQgdHlwZSB7IElDbG91ZEFzc2VtYmx5U291cmNlIH0gZnJvbSAnLi4vLi4vYXBpL2Nsb3VkLWFzc2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FuID0gdHJ1ZSk6IFByb21pc2U8U3RhY2tBc3NlbWJseT4ge1xuICBpZiAoYXNzZW1ibHlTb3VyY2UgaW5zdGFuY2VvZiBTdGFja0Fzc2VtYmx5KSB7XG4gICAgcmV0dXJuIGFzc2VtYmx5U291cmNlO1xuICB9XG5cbiAgaWYgKGNhY2hlKSB7XG4gICAgY29uc3QgcmV0ID0gbmV3IFN0YWNrQXNzZW1ibHkoYXdhaXQgYXNzZW1ibHlTb3VyY2UucHJvZHVjZSgpLCBpb0hlbHBlcik7XG4gICAgcmV0dXJuIHJldDtcbiAgfVxuXG4gIHJldHVybiBuZXcgU3RhY2tBc3NlbWJseShhd2FpdCBhc3NlbWJseVNvdXJjZS5wcm9kdWNlKCksIGlvSGVscGVyKTtcbn1cbiJdfQ==
@@ -1,14 +1,17 @@
1
+ import type { TemplateDiff } from '@aws-cdk/cloudformation-diff';
1
2
  import type { DeployResult, DestroyResult, RollbackResult } from './types';
2
3
  import type { BootstrapEnvironments, BootstrapOptions, BootstrapResult } from '../actions/bootstrap';
3
4
  import { type DeployOptions } from '../actions/deploy';
4
5
  import { type DestroyOptions } from '../actions/destroy';
5
6
  import type { DiffOptions } from '../actions/diff';
6
7
  import { type ListOptions } from '../actions/list';
8
+ import type { RefactorOptions } from '../actions/refactor';
7
9
  import { type RollbackOptions } from '../actions/rollback';
8
10
  import { type SynthOptions } from '../actions/synth';
9
11
  import type { WatchOptions } from '../actions/watch';
10
12
  import { type SdkConfig } from '../api/aws-auth';
11
13
  import type { ICloudAssemblySource } from '../api/cloud-assembly';
14
+ import { CachedCloudAssembly } from '../api/cloud-assembly';
12
15
  import { CloudAssemblySourceBuilder } from '../api/cloud-assembly/private';
13
16
  import type { IIoHost } from '../api/io';
14
17
  import type { StackDetails } from '../api/shared-public';
@@ -73,12 +76,17 @@ export declare class Toolkit extends CloudAssemblySourceBuilder {
73
76
  bootstrap(environments: BootstrapEnvironments, options: BootstrapOptions): Promise<BootstrapResult>;
74
77
  /**
75
78
  * Synth Action
79
+ *
80
+ * The caller assumes ownership of the `CachedCloudAssembly` and is responsible for calling `dispose()` on
81
+ * it after use.
76
82
  */
77
- synth(cx: ICloudAssemblySource, options?: SynthOptions): Promise<ICloudAssemblySource>;
83
+ synth(cx: ICloudAssemblySource, options?: SynthOptions): Promise<CachedCloudAssembly>;
78
84
  /**
79
85
  * Diff Action
80
86
  */
81
- diff(cx: ICloudAssemblySource, options: DiffOptions): Promise<void>;
87
+ diff(cx: ICloudAssemblySource, options: DiffOptions): Promise<{
88
+ [name: string]: TemplateDiff;
89
+ }>;
82
90
  /**
83
91
  * List Action
84
92
  *
@@ -114,6 +122,11 @@ export declare class Toolkit extends CloudAssemblySourceBuilder {
114
122
  * Helper to allow rollback being called as part of the deploy or watch action.
115
123
  */
116
124
  private _rollback;
125
+ /**
126
+ * Refactor Action. Moves resources from one location (stack + logical ID) to another.
127
+ */
128
+ refactor(cx: ICloudAssemblySource, options?: RefactorOptions): Promise<void>;
129
+ private _refactor;
117
130
  /**
118
131
  * Destroy Action
119
132
  *