@composurecdk/cloudformation 0.1.2 → 0.1.3

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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { createStackBuilder, type IStackBuilder, type StackBuilderResult, } from "./stack-builder.js";
2
2
  export { singleStack, groupedStacks } from "./strategies.js";
3
+ export { outputs, type OutputDefinition, type OutputDefinitions } from "./outputs.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { createStackBuilder, } from "./stack-builder.js";
2
2
  export { singleStack, groupedStacks } from "./strategies.js";
3
+ export { outputs } from "./outputs.js";
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAGnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAGnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAiD,MAAM,cAAc,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { type AfterBuildHook, type Resolvable } from "@composurecdk/core";
2
+ /**
3
+ * Defines a CloudFormation stack output with a value that can be a
4
+ * {@link Resolvable} — either a concrete string or a {@link Ref} that
5
+ * resolves against the system's build results at build time.
6
+ */
7
+ export interface OutputDefinition {
8
+ /** The output value, or a Ref that resolves to one. */
9
+ value: Resolvable<string>;
10
+ /** A description of the output. */
11
+ description?: string;
12
+ /**
13
+ * The name under which the output is exported for cross-stack references.
14
+ * When set, this creates a CloudFormation Export.
15
+ */
16
+ exportName?: string;
17
+ }
18
+ /**
19
+ * A record of output definitions keyed by logical output name.
20
+ */
21
+ export type OutputDefinitions = Record<string, OutputDefinition>;
22
+ /**
23
+ * Returns an {@link AfterBuildHook} that creates CloudFormation stack outputs
24
+ * from the composed system's build results.
25
+ *
26
+ * Each output definition's `value` can be a concrete string or a {@link Ref}
27
+ * that is resolved against the build results. This enables outputs that
28
+ * reference values produced by composed components without breaking the
29
+ * composition abstraction.
30
+ *
31
+ * Intended for use with {@link ComposedSystem.afterBuild}.
32
+ *
33
+ * @param defs - A record of output definitions keyed by logical name.
34
+ * @returns An {@link AfterBuildHook} that creates `CfnOutput` constructs.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { compose, ref } from "@composurecdk/core";
39
+ * import { outputs } from "@composurecdk/cloudformation";
40
+ *
41
+ * compose(
42
+ * { site: createBucketBuilder(), cdn: createDistributionBuilder() },
43
+ * { site: [], cdn: ["site"] },
44
+ * )
45
+ * .afterBuild(outputs({
46
+ * DistributionUrl: {
47
+ * value: ref("cdn", (r: DistributionBuilderResult) =>
48
+ * `https://${r.distribution.distributionDomainName}`),
49
+ * description: "CloudFront distribution URL",
50
+ * },
51
+ * BucketName: {
52
+ * value: ref("site", (r: BucketBuilderResult) => r.bucket.bucketName),
53
+ * description: "S3 bucket name for site content",
54
+ * },
55
+ * }))
56
+ * .build(stack, "StaticWebsite");
57
+ * ```
58
+ */
59
+ export declare function outputs(defs: OutputDefinitions): AfterBuildHook<object>;
60
+ //# sourceMappingURL=outputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputs.d.ts","sourceRoot":"","sources":["../src/outputs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAW,MAAM,oBAAoB,CAAC;AAEnF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAE1B,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,CAAC,MAAM,CAAC,CAYvE"}
@@ -0,0 +1,52 @@
1
+ import { CfnOutput } from "aws-cdk-lib";
2
+ import { resolve } from "@composurecdk/core";
3
+ /**
4
+ * Returns an {@link AfterBuildHook} that creates CloudFormation stack outputs
5
+ * from the composed system's build results.
6
+ *
7
+ * Each output definition's `value` can be a concrete string or a {@link Ref}
8
+ * that is resolved against the build results. This enables outputs that
9
+ * reference values produced by composed components without breaking the
10
+ * composition abstraction.
11
+ *
12
+ * Intended for use with {@link ComposedSystem.afterBuild}.
13
+ *
14
+ * @param defs - A record of output definitions keyed by logical name.
15
+ * @returns An {@link AfterBuildHook} that creates `CfnOutput` constructs.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { compose, ref } from "@composurecdk/core";
20
+ * import { outputs } from "@composurecdk/cloudformation";
21
+ *
22
+ * compose(
23
+ * { site: createBucketBuilder(), cdn: createDistributionBuilder() },
24
+ * { site: [], cdn: ["site"] },
25
+ * )
26
+ * .afterBuild(outputs({
27
+ * DistributionUrl: {
28
+ * value: ref("cdn", (r: DistributionBuilderResult) =>
29
+ * `https://${r.distribution.distributionDomainName}`),
30
+ * description: "CloudFront distribution URL",
31
+ * },
32
+ * BucketName: {
33
+ * value: ref("site", (r: BucketBuilderResult) => r.bucket.bucketName),
34
+ * description: "S3 bucket name for site content",
35
+ * },
36
+ * }))
37
+ * .build(stack, "StaticWebsite");
38
+ * ```
39
+ */
40
+ export function outputs(defs) {
41
+ return (scope, _id, results) => {
42
+ const resultAsContext = results;
43
+ for (const [name, def] of Object.entries(defs)) {
44
+ new CfnOutput(scope, name, {
45
+ value: resolve(def.value, resultAsContext),
46
+ ...(def.description !== undefined ? { description: def.description } : {}),
47
+ ...(def.exportName !== undefined ? { exportName: def.exportName } : {}),
48
+ });
49
+ }
50
+ };
51
+ }
52
+ //# sourceMappingURL=outputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputs.js","sourceRoot":"","sources":["../src/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAwC,OAAO,EAAE,MAAM,oBAAoB,CAAC;AA0BnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,OAAO,CAAC,IAAuB;IAC7C,OAAO,CAAC,KAAiB,EAAE,GAAW,EAAE,OAAe,EAAE,EAAE;QACzD,MAAM,eAAe,GAAG,OAAiC,CAAC;QAE1D,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/C,IAAI,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;gBACzB,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,CAAC;gBAC1C,GAAG,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1E,GAAG,CAAC,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composurecdk/cloudformation",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Composable CloudFormation stack builder and stack assignment strategies",
5
5
  "repository": {
6
6
  "type": "git",