@flow-as-code/cdk 0.1.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.
- package/LICENSE +202 -0
- package/README.md +96 -0
- package/dist/binder.d.ts +38 -0
- package/dist/binder.d.ts.map +1 -0
- package/dist/binder.js +40 -0
- package/dist/binder.js.map +1 -0
- package/dist/flow-set.d.ts +35 -0
- package/dist/flow-set.d.ts.map +1 -0
- package/dist/flow-set.js +225 -0
- package/dist/flow-set.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/scaffold.d.ts +31 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +176 -0
- package/dist/scaffold.js.map +1 -0
- package/package.json +72 -0
- package/src/binder.ts +77 -0
- package/src/flow-set.ts +275 -0
- package/src/index.ts +51 -0
- package/src/scaffold.ts +193 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-set.js","sourceRoot":"","sources":["../src/flow-set.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oEAAoE;AACpE,0BAA0B;AAC1B,EAAE;AACF,4DAA4D;AAC5D,iFAAiF;AACjF,qEAAqE;AACrE,mCAAmC;AACnC,uGAAuG;AACvG,6GAA6G;AAC7G,EAAE;AACF,oBAAoB;AACpB,sFAAsF;AACtF,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,8EAA8E;AAC9E,8CAA8C;AAC9C,sHAAsH;AACtH,oHAAoH;AACpH,4EAA4E;AAC5E,0EAA0E;AAC1E,0CAA0C;AAC1C,8FAA8F;AAC9F,0BAA0B;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,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AM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,mCAAmC,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QACD,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,0CAA0C,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC/E,CAAC;QACJ,CAAC;QAED,mEAAmE;QACnE,oEAAoE;QACpE,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,CAAC,MAAM,kBAAkB,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FlowSet as FlowSetClass, FlowSetProps } from "./flow-set.js";
|
|
2
|
+
export { bindRef, type TokenBinder } from "./binder.js";
|
|
3
|
+
export type { FlowSetProps };
|
|
4
|
+
export declare const DEFAULT_MODULE_ALIAS: string;
|
|
5
|
+
export declare const FlowSet: typeof FlowSetClass;
|
|
6
|
+
export type FlowSet = FlowSetClass;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,CAAC;AAqB7B,eAAO,MAAM,oBAAoB,EAAE,MAAqC,CAAC;AACzE,eAAO,MAAM,OAAO,EAAE,OAAO,YAA8B,CAAC;AAC5D,MAAM,MAAM,OAAO,GAAG,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 The flow-as-code Authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
// CDK binding for @flow-as-code/core. See README.md.
|
|
6
|
+
//
|
|
7
|
+
// TokenBinder maps FlowDoc references to CloudFormation-token strings;
|
|
8
|
+
// FlowSet turns a set of FlowDocs into AWS::Connect resources with module
|
|
9
|
+
// version publishing and alias repointing.
|
|
10
|
+
//
|
|
11
|
+
// aws-cdk-lib and constructs are OPTIONAL peers, so that installing @flow-as-code/cli
|
|
12
|
+
// (which only reaches this package through the ./scaffold subpath, and that
|
|
13
|
+
// subpath imports no CDK) does not drag 168 MB of CDK in. The cost is that npm
|
|
14
|
+
// no longer warns at install time, so a consumer who forgets them used to meet
|
|
15
|
+
// a bare ERR_MODULE_NOT_FOUND for aws-cdk-lib raised from flow-set.js. ESM
|
|
16
|
+
// resolves the whole graph before any module body runs, so the only way to
|
|
17
|
+
// front-run that is to keep flow-set.js off the static import graph: this
|
|
18
|
+
// module checks the peer itself and then loads flow-set through a dynamic
|
|
19
|
+
// import. The type-only imports below are erased and pull in nothing.
|
|
20
|
+
import { createRequire } from "node:module";
|
|
21
|
+
import { PACKAGE_NAMES } from "@flow-as-code/core";
|
|
22
|
+
export { bindRef } from "./binder.js";
|
|
23
|
+
/** Peer floor, kept in step with peerDependencies in package.json. */
|
|
24
|
+
const CDK_PEERS = "aws-cdk-lib@^2.267.0 constructs@^10.8.1";
|
|
25
|
+
function assertCdkPeersInstalled() {
|
|
26
|
+
try {
|
|
27
|
+
createRequire(import.meta.url).resolve("aws-cdk-lib");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new Error(`${PACKAGE_NAMES.cdk} needs the CDK at runtime, but aws-cdk-lib is not installed. ` +
|
|
31
|
+
"It and constructs are optional peers so that a CLI-only install stays small, " +
|
|
32
|
+
`which means npm does not warn about them at install time. Install them with: npm install ${CDK_PEERS}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
assertCdkPeersInstalled();
|
|
36
|
+
const flowSet = await import("./flow-set.js");
|
|
37
|
+
export const DEFAULT_MODULE_ALIAS = flowSet.DEFAULT_MODULE_ALIAS;
|
|
38
|
+
export const FlowSet = flowSet.FlowSet;
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qDAAqD;AACrD,EAAE;AACF,uEAAuE;AACvE,0EAA0E;AAC1E,2CAA2C;AAC3C,EAAE;AACF,sFAAsF;AACtF,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,sEAAsE;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,OAAO,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AAGxD,sEAAsE;AACtE,MAAM,SAAS,GAAG,yCAAyC,CAAC;AAE5D,SAAS,uBAAuB;IAC9B,IAAI,CAAC;QACH,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,GAAG,aAAa,CAAC,GAAG,+DAA+D;YACjF,+EAA+E;YAC/E,4FAA4F,SAAS,EAAE,CAC1G,CAAC;IACJ,CAAC;AACH,CAAC;AAED,uBAAuB,EAAE,CAAC;AAE1B,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAW,OAAO,CAAC,oBAAoB,CAAC;AACzE,MAAM,CAAC,MAAM,OAAO,GAAwB,OAAO,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type FlowDoc, type RefType } from "@flow-as-code/core";
|
|
2
|
+
/** Basename of the file the scaffold is written to. */
|
|
3
|
+
export declare const CDK_SCAFFOLD_FILE = "flow-stack.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Reference names per type across the whole set, sorted and deduplicated.
|
|
6
|
+
*
|
|
7
|
+
* A document's `refs` index is the authored answer, but it is derived data and
|
|
8
|
+
* nothing in the schema forces it to be current, so the content is scanned too
|
|
9
|
+
* and the two are unioned. A stale index can therefore only add a binder method
|
|
10
|
+
* the set does not strictly need, never drop one it does.
|
|
11
|
+
*/
|
|
12
|
+
export declare function referencedNames(docs: readonly FlowDoc[]): Map<RefType, string[]>;
|
|
13
|
+
/**
|
|
14
|
+
* The FLOW_DOCS expression for an output directory `depth` levels below the
|
|
15
|
+
* directory holding the FlowDocs: `.`, `..`, `../..`. This is what node's
|
|
16
|
+
* `path.relative` produces for the same pair, which is what the CLI passes;
|
|
17
|
+
* packages/studio/tests/exportParity.test.ts compares the two byte for
|
|
18
|
+
* byte on a real `flow-cli emit --target cdk --out` run.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sourceForDepth(depth: number): string;
|
|
21
|
+
export interface CdkScaffoldInput {
|
|
22
|
+
docs: readonly FlowDoc[];
|
|
23
|
+
/**
|
|
24
|
+
* Where FlowSet reads the `*.flowdoc.json` files, relative to the scaffold:
|
|
25
|
+
* `.` when they sit beside it, `..` from a subdirectory. See sourceForDepth.
|
|
26
|
+
*/
|
|
27
|
+
source: string;
|
|
28
|
+
}
|
|
29
|
+
/** The scaffold source. Pure: no filesystem access, no clock, no randomness. */
|
|
30
|
+
export declare function cdkScaffold({ docs, source }: CdkScaffoldInput): string;
|
|
31
|
+
//# sourceMappingURL=scaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,KAAK,OAAO,EAAiB,KAAK,OAAO,EAAe,MAAM,oBAAoB,CAAC;AAE5F,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAyBjD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAWhF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAmBD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,gBAAgB,GAAG,MAAM,CAuEtE"}
|
package/dist/scaffold.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 The flow-as-code Authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
// The CDK stack scaffold, shared by `flow-cli emit --target cdk` and the
|
|
6
|
+
// studio's CDK export button.
|
|
7
|
+
//
|
|
8
|
+
// @flow-as-code/cdk is a library, not a code generator: FlowSet reads the FlowDoc
|
|
9
|
+
// directory at synth time, so there is nothing per-document to emit. What a
|
|
10
|
+
// user actually has to write by hand is the stack that instantiates it and,
|
|
11
|
+
// above all, the TokenBinder, whose method set depends on which reference types
|
|
12
|
+
// their documents use. That is what this generates: a valid, compiling starting
|
|
13
|
+
// point with a TODO on exactly the binder methods the document set needs.
|
|
14
|
+
//
|
|
15
|
+
// It lives in the package whose API it writes, and is published as
|
|
16
|
+
// `@flow-as-code/cdk/scaffold`, so the CLI and the studio emit the
|
|
17
|
+
// same bytes instead of two implementations that drift. The studio cannot
|
|
18
|
+
// import the CLI (the CLI depends on the studio for its built assets) and
|
|
19
|
+
// parity between the two is the point of the feature, so a shared module is
|
|
20
|
+
// the only arrangement that holds.
|
|
21
|
+
//
|
|
22
|
+
// Pure by contract: no node builtins, no filesystem, no clock, no randomness,
|
|
23
|
+
// because this module is bundled into a browser. The one calculation that
|
|
24
|
+
// needs a path, the FLOW_DOCS expression, is passed in as `source`: the CLI
|
|
25
|
+
// computes it with node:path and the studio with `sourceForDepth` below.
|
|
26
|
+
//
|
|
27
|
+
// Deterministic: same documents in, byte-identical TypeScript out. Reference
|
|
28
|
+
// types and names are sorted, and nothing in the output depends on the order
|
|
29
|
+
// files were read.
|
|
30
|
+
//
|
|
31
|
+
// FlowSet resolves `${cdref:module:...}` itself against the modules it manages,
|
|
32
|
+
// so `module` never appears on a binder (packages/cdk/src/binder.ts).
|
|
33
|
+
import { PACKAGE_NAMES, collectRefs } from "@flow-as-code/core";
|
|
34
|
+
/** Basename of the file the scaffold is written to. */
|
|
35
|
+
export const CDK_SCAFFOLD_FILE = "flow-stack.ts";
|
|
36
|
+
/** Required TokenBinder methods, in the order they are emitted. */
|
|
37
|
+
const REQUIRED_TYPES = ["hours", "lambda", "lex", "prompt", "queue"];
|
|
38
|
+
/** What each binder method must return, echoing packages/cdk/src/binder.ts. */
|
|
39
|
+
const RETURNS = {
|
|
40
|
+
flow: "ARN of a contact flow not managed by this FlowSet",
|
|
41
|
+
hours: "ARN of the hours of operation, e.g. hours.attrHoursOfOperationArn",
|
|
42
|
+
lambda: "ARN of the Lambda function, e.g. fn.functionArn",
|
|
43
|
+
lex: "ARN of the Lex bot alias",
|
|
44
|
+
prompt: "ARN of the prompt",
|
|
45
|
+
queue: "ARN of the queue, e.g. queue.attrQueueArn",
|
|
46
|
+
};
|
|
47
|
+
/** What each reference type names, for the comment on an unused method. */
|
|
48
|
+
const NOUNS = {
|
|
49
|
+
flow: "contact flow",
|
|
50
|
+
hours: "hours of operation",
|
|
51
|
+
lambda: "Lambda function",
|
|
52
|
+
lex: "Lex bot alias",
|
|
53
|
+
prompt: "prompt",
|
|
54
|
+
queue: "queue",
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Reference names per type across the whole set, sorted and deduplicated.
|
|
58
|
+
*
|
|
59
|
+
* A document's `refs` index is the authored answer, but it is derived data and
|
|
60
|
+
* nothing in the schema forces it to be current, so the content is scanned too
|
|
61
|
+
* and the two are unioned. A stale index can therefore only add a binder method
|
|
62
|
+
* the set does not strictly need, never drop one it does.
|
|
63
|
+
*/
|
|
64
|
+
export function referencedNames(docs) {
|
|
65
|
+
const byType = new Map();
|
|
66
|
+
for (const doc of docs) {
|
|
67
|
+
for (const ref of [...(doc.refs ?? []), ...collectRefs(doc.content)]) {
|
|
68
|
+
if (ref.type === "module")
|
|
69
|
+
continue;
|
|
70
|
+
const names = byType.get(ref.type) ?? new Set();
|
|
71
|
+
names.add(ref.name);
|
|
72
|
+
byType.set(ref.type, names);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return new Map([...byType].map(([type, names]) => [type, [...names].sort()]));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The FLOW_DOCS expression for an output directory `depth` levels below the
|
|
79
|
+
* directory holding the FlowDocs: `.`, `..`, `../..`. This is what node's
|
|
80
|
+
* `path.relative` produces for the same pair, which is what the CLI passes;
|
|
81
|
+
* packages/studio/tests/exportParity.test.ts compares the two byte for
|
|
82
|
+
* byte on a real `flow-cli emit --target cdk --out` run.
|
|
83
|
+
*/
|
|
84
|
+
export function sourceForDepth(depth) {
|
|
85
|
+
if (depth <= 0)
|
|
86
|
+
return ".";
|
|
87
|
+
return Array.from({ length: depth }, () => "..").join("/");
|
|
88
|
+
}
|
|
89
|
+
function binderMethod(type, names) {
|
|
90
|
+
const returns = RETURNS[type] ?? "ARN of the referenced resource";
|
|
91
|
+
const noun = NOUNS[type] ?? type;
|
|
92
|
+
const head = names.length === 0
|
|
93
|
+
? [` // No document in this set references a ${noun}.`]
|
|
94
|
+
: [` // TODO: return the ${returns}.`, ` // Names referenced: ${names.join(", ")}.`];
|
|
95
|
+
return [
|
|
96
|
+
...head,
|
|
97
|
+
` ${type}: (name) => {`,
|
|
98
|
+
names.length === 0
|
|
99
|
+
? ` throw new Error(\`Unexpected ${type} reference "\${name}".\`);`
|
|
100
|
+
: ` throw new Error(\`TODO: bind ${type} "\${name}" to an ARN.\`);`,
|
|
101
|
+
" },",
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
/** The scaffold source. Pure: no filesystem access, no clock, no randomness. */
|
|
105
|
+
export function cdkScaffold({ docs, source }) {
|
|
106
|
+
const referenced = referencedNames(docs);
|
|
107
|
+
const types = [...REQUIRED_TYPES];
|
|
108
|
+
// `flow` is optional on TokenBinder, so it is emitted only when it is used.
|
|
109
|
+
if ((referenced.get("flow") ?? []).length > 0)
|
|
110
|
+
types.unshift("flow");
|
|
111
|
+
const used = [...referenced]
|
|
112
|
+
.filter(([, names]) => names.length > 0)
|
|
113
|
+
.map(([type]) => type)
|
|
114
|
+
.sort();
|
|
115
|
+
const names = docs.map((d) => `${d.kind} ${d.name}`).sort();
|
|
116
|
+
// No licence header: this file lands in a user's project and is theirs, not
|
|
117
|
+
// ours. Same reasoning as codegen's banner (packages/core/src/codegen.ts).
|
|
118
|
+
const lines = [
|
|
119
|
+
"// Generated by `flow-cli emit --target cdk` as a starting point, then yours to",
|
|
120
|
+
"// keep: re-running the command overwrites this file, so move it or rename it",
|
|
121
|
+
"// once you have edited it.",
|
|
122
|
+
"//",
|
|
123
|
+
`// Documents in the set: ${names.join(", ")}.`,
|
|
124
|
+
"//",
|
|
125
|
+
"// FlowSet reads every *.flowdoc.json in the source directory at synth time and",
|
|
126
|
+
"// creates AWS::Connect::ContactFlow and AWS::Connect::ContactFlowModule",
|
|
127
|
+
"// resources, publishing a module version and repointing its alias whenever the",
|
|
128
|
+
`// module content changes. See the ${PACKAGE_NAMES.cdk} README.`,
|
|
129
|
+
"",
|
|
130
|
+
'import { fileURLToPath } from "node:url";',
|
|
131
|
+
"",
|
|
132
|
+
'import { Stack, type StackProps } from "aws-cdk-lib";',
|
|
133
|
+
`import { FlowSet, type TokenBinder } from "${PACKAGE_NAMES.cdk}";`,
|
|
134
|
+
'import type { Construct } from "constructs";',
|
|
135
|
+
"",
|
|
136
|
+
"/**",
|
|
137
|
+
" * Directory holding the FlowDocs. Resolved against this file rather than the",
|
|
138
|
+
" * working directory, so `cdk synth` works from the project root, from here, or",
|
|
139
|
+
" * from anywhere else.",
|
|
140
|
+
" */",
|
|
141
|
+
`const FLOW_DOCS = fileURLToPath(new URL(${JSON.stringify(source)}, import.meta.url));`,
|
|
142
|
+
"",
|
|
143
|
+
"/**",
|
|
144
|
+
" * Resolves each reference token in the documents to a CloudFormation token,",
|
|
145
|
+
` * normally a construct attribute. ${PACKAGE_NAMES.cdk} inserts what you`,
|
|
146
|
+
" * return byte for byte, so CDK tokens pass through and CloudFormation",
|
|
147
|
+
" * resolves them at deploy time. Never return a literal ARN here.",
|
|
148
|
+
" *",
|
|
149
|
+
used.length === 0
|
|
150
|
+
? " * These documents contain no references."
|
|
151
|
+
: ` * These documents reference: ${used.join(", ")}.`,
|
|
152
|
+
" */",
|
|
153
|
+
"const binder: TokenBinder = {",
|
|
154
|
+
...types.flatMap((type) => binderMethod(type, referenced.get(type) ?? [])),
|
|
155
|
+
"};",
|
|
156
|
+
"",
|
|
157
|
+
"export interface FlowStackProps extends StackProps {",
|
|
158
|
+
" /** ARN of the Amazon Connect instance these flows deploy into. */",
|
|
159
|
+
" instanceArn: string;",
|
|
160
|
+
"}",
|
|
161
|
+
"",
|
|
162
|
+
"export class FlowStack extends Stack {",
|
|
163
|
+
" constructor(scope: Construct, id: string, props: FlowStackProps) {",
|
|
164
|
+
" super(scope, id, props);",
|
|
165
|
+
"",
|
|
166
|
+
' new FlowSet(this, "Flows", {',
|
|
167
|
+
" instanceArn: props.instanceArn,",
|
|
168
|
+
" source: FLOW_DOCS,",
|
|
169
|
+
" binder,",
|
|
170
|
+
" });",
|
|
171
|
+
" }",
|
|
172
|
+
"}",
|
|
173
|
+
];
|
|
174
|
+
return lines.join("\n") + "\n";
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=scaffold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,yEAAyE;AACzE,8BAA8B;AAC9B,EAAE;AACF,kFAAkF;AAClF,4EAA4E;AAC5E,4EAA4E;AAC5E,gFAAgF;AAChF,gFAAgF;AAChF,0EAA0E;AAC1E,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,mCAAmC;AACnC,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,4EAA4E;AAC5E,yEAAyE;AACzE,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,mBAAmB;AACnB,EAAE;AACF,gFAAgF;AAChF,sEAAsE;AAEtE,OAAO,EAAgB,aAAa,EAAgB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE5F,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAA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CAAC,CAAC,iCAAiC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACvD,KAAK;QACL,+BAA+B;QAC/B,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1E,IAAI;QACJ,EAAE;QACF,sDAAsD;QACtD,sEAAsE;QACtE,wBAAwB;QACxB,GAAG;QACH,EAAE;QACF,wCAAwC;QACxC,sEAAsE;QACtE,8BAA8B;QAC9B,EAAE;QACF,kCAAkC;QAClC,uCAAuC;QACvC,0BAA0B;QAC1B,eAAe;QACf,SAAS;QACT,KAAK;QACL,GAAG;KACJ,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flow-as-code/cdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CDK binding for @flow-as-code/core: materialize FlowDoc refs as CloudFormation tokens; FlowSet construct with module version/alias publishing; a CDK stack scaffold generator on the /scaffold subpath.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./scaffold": {
|
|
15
|
+
"types": "./dist/scaffold.d.ts",
|
|
16
|
+
"import": "./dist/scaffold.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"src",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"!**/*.test.ts",
|
|
25
|
+
"!**/*.test.tsx",
|
|
26
|
+
"!**/__fixtures__",
|
|
27
|
+
"!**/__generated__",
|
|
28
|
+
"!**/*.tsbuildinfo",
|
|
29
|
+
"!**/__snapshots__",
|
|
30
|
+
"!**/*.snap",
|
|
31
|
+
"!**/test-helpers.ts",
|
|
32
|
+
"!**/test-helpers.tsx"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=22.12"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc -p tsconfig.json",
|
|
42
|
+
"test": "vitest run"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@flow-as-code/core": "0.1.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"aws-cdk-lib": "^2.267.0",
|
|
49
|
+
"constructs": "^10.8.1"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"aws-cdk-lib": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"constructs": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"aws-cdk-lib": "^2.267.0",
|
|
61
|
+
"constructs": "^10.8.1"
|
|
62
|
+
},
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "git+https://github.com/flow-as-code/flow-as-code.git",
|
|
66
|
+
"directory": "packages/cdk"
|
|
67
|
+
},
|
|
68
|
+
"homepage": "https://github.com/flow-as-code/flow-as-code/tree/main/packages/cdk#readme",
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/flow-as-code/flow-as-code/issues"
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/binder.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 The flow-as-code Authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
// TokenBinder: the user's side of CDK materialization.
|
|
6
|
+
//
|
|
7
|
+
// A binder maps each non-module reference in a FlowDoc to a string, normally a
|
|
8
|
+
// CloudFormation token from an L1/L2 construct attribute (queue.attrQueueArn,
|
|
9
|
+
// fn.functionArn, a Lex alias ARN). @flow-as-code/core's materializeWithBinder inserts
|
|
10
|
+
// the returned string byte-for-byte, so CDK tokens survive untouched and
|
|
11
|
+
// CloudFormation resolves them per account at deploy time. No resource map, no
|
|
12
|
+
// literal ARNs in this path.
|
|
13
|
+
//
|
|
14
|
+
// Module references (`${cdref:module:name@alias}`) are deliberately absent:
|
|
15
|
+
// FlowSet manages the module resources itself and resolves those tokens to the
|
|
16
|
+
// alias ARN of the CfnContactFlowModuleAlias it created (see flow-set.ts).
|
|
17
|
+
|
|
18
|
+
import type { RefEntry } from "@flow-as-code/core";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Maps reference names to CloudFormation-token strings. Implemented by the
|
|
22
|
+
* user, typically as thin closures over constructs in the same stack.
|
|
23
|
+
*
|
|
24
|
+
* `flow` is optional because cross-flow references are rare; a doc set that
|
|
25
|
+
* uses `${cdref:flow:...}` against a binder without `flow()` fails synth with
|
|
26
|
+
* an error naming the token.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Boundary worth knowing: a binder may return any opaque string and it passes
|
|
30
|
+
* through byte-exact, EXCEPT that CDK itself parses `${Token[...]}` markers.
|
|
31
|
+
* Returning a string containing an unregistered marker such as
|
|
32
|
+
* `${Token[TOKEN.999]}` fails deep inside aws-cdk-lib with "Unrecognized token
|
|
33
|
+
* key". Real tokens (Fn.importValue, attr getters) are registered and fine.
|
|
34
|
+
* This is CDK's behavior, not something this package can intercept.
|
|
35
|
+
*/
|
|
36
|
+
export interface TokenBinder {
|
|
37
|
+
/** ARN of the queue, e.g. `queue.attrQueueArn`. */
|
|
38
|
+
queue(name: string): string;
|
|
39
|
+
/** ARN of the hours of operation, e.g. `hours.attrHoursOfOperationArn`. */
|
|
40
|
+
hours(name: string): string;
|
|
41
|
+
/** ARN of the Lambda function, e.g. `fn.functionArn`. */
|
|
42
|
+
lambda(name: string): string;
|
|
43
|
+
/** ARN of the Lex bot alias. */
|
|
44
|
+
lex(name: string): string;
|
|
45
|
+
/** ARN of the prompt. */
|
|
46
|
+
prompt(name: string): string;
|
|
47
|
+
/** ARN of a contact flow not managed by this FlowSet. */
|
|
48
|
+
flow?(name: string): string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Resolves one non-module reference through the binder. Throws a diagnostic
|
|
53
|
+
* naming the token, the document, and the missing method when the binder
|
|
54
|
+
* cannot answer, so the failure is actionable without a stack-trace dig.
|
|
55
|
+
*/
|
|
56
|
+
export function bindRef(binder: TokenBinder, ref: RefEntry, docName: string): string {
|
|
57
|
+
if (ref.type === "module") {
|
|
58
|
+
// FlowSet resolves module refs itself; reaching here is a programming
|
|
59
|
+
// error in the caller, not a binder gap.
|
|
60
|
+
throw new Error(`Internal: module ref ${ref.token} must be resolved by FlowSet, not a binder.`);
|
|
61
|
+
}
|
|
62
|
+
const method = binder[ref.type];
|
|
63
|
+
if (typeof method !== "function") {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`TokenBinder has no ${ref.type}() method, but "${docName}" contains ${ref.token}. ` +
|
|
66
|
+
`Implement ${ref.type}(name) on the binder.`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const value = method.call(binder, ref.name);
|
|
70
|
+
if (typeof value !== "string") {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`TokenBinder.${ref.type}("${ref.name}") returned ${String(value)} for ${ref.token} ` +
|
|
73
|
+
`in "${docName}". Binder methods must return a string.`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|