@aws/nx-plugin 1.0.0-rc.25 → 1.0.0-rc.27
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/package.json +1 -1
- package/src/connection/generator.d.ts +2 -10
- package/src/connection/generator.js +10 -144
- package/src/connection/generator.js.map +1 -1
- package/src/connection/supported-connections.d.ts +98 -0
- package/src/connection/supported-connections.js +138 -0
- package/src/connection/supported-connections.js.map +1 -0
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +38 -76
- package/src/ts/rdb/files/src/create-db-user-handler.ts.template +7 -9
- package/src/ts/rdb/files/src/migration-handler.ts.template +1 -28
- package/src/ts/rdb/generator.js +2 -2
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +10 -7
- package/src/utils/files/common/scripts/src/rdb/shared/start-container.ts.template +2 -2
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +10 -7
- package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +5 -15
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +0 -28
package/package.json
CHANGED
|
@@ -5,17 +5,9 @@
|
|
|
5
5
|
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
6
6
|
import { type ComponentMetadata } from '../utils/nx';
|
|
7
7
|
import type { ConnectionGeneratorSchema } from './schema';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* These can be project-level types (determined by introspection) or
|
|
11
|
-
* component generator ids (from component metadata).
|
|
12
|
-
*/
|
|
13
|
-
declare const SUPPORTED_PROJECT_TYPES: readonly ["ts#trpc-api", "py#fast-api", "react", "smithy", "ts#rdb", "ts#dynamodb", "py#dynamodb", "agentcore-gateway"];
|
|
8
|
+
import { type Connection, type SUPPORTED_PROJECT_TYPES } from './supported-connections';
|
|
9
|
+
export type { Connection };
|
|
14
10
|
type ProjectType = (typeof SUPPORTED_PROJECT_TYPES)[number];
|
|
15
|
-
export type Connection = {
|
|
16
|
-
source: string;
|
|
17
|
-
target: string;
|
|
18
|
-
};
|
|
19
11
|
/**
|
|
20
12
|
* Sentinel value for sourceComponent/targetComponent that means
|
|
21
13
|
* "use the project-level connection, not a component".
|
|
@@ -35,171 +35,37 @@ import tsRdbTrpcConnectionGenerator from "../ts/rdb/trpc-connection/generator.js
|
|
|
35
35
|
import { hasExportDeclaration } from "../utils/ast.js";
|
|
36
36
|
import { readProjectConfigurationUnqualified } from "../utils/nx.js";
|
|
37
37
|
import { readToml } from "../utils/toml.js";
|
|
38
|
-
|
|
39
|
-
* List of supported source and target project types for connections.
|
|
40
|
-
* These can be project-level types (determined by introspection) or
|
|
41
|
-
* component generator ids (from component metadata).
|
|
42
|
-
*/ const SUPPORTED_PROJECT_TYPES = [
|
|
43
|
-
'ts#trpc-api',
|
|
44
|
-
'py#fast-api',
|
|
45
|
-
'react',
|
|
46
|
-
'smithy',
|
|
47
|
-
'ts#rdb',
|
|
48
|
-
'ts#dynamodb',
|
|
49
|
-
'py#dynamodb',
|
|
50
|
-
'agentcore-gateway'
|
|
51
|
-
];
|
|
38
|
+
import { SUPPORTED_CONNECTIONS } from "./supported-connections.js";
|
|
52
39
|
/**
|
|
53
40
|
* Sentinel value for sourceComponent/targetComponent that means
|
|
54
41
|
* "use the project-level connection, not a component".
|
|
55
42
|
*/ export const PROJECT_COMPONENT_SENTINEL = '.';
|
|
56
|
-
/**
|
|
57
|
-
* Enumerates the supported project connections.
|
|
58
|
-
* Source and target can be project-level types or component generator ids.
|
|
59
|
-
*/ const SUPPORTED_CONNECTIONS = [
|
|
60
|
-
{
|
|
61
|
-
source: 'ts#trpc-api',
|
|
62
|
-
target: 'ts#rdb'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
source: 'ts#trpc-api',
|
|
66
|
-
target: 'ts#dynamodb'
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
source: 'ts#agent',
|
|
70
|
-
target: 'ts#rdb'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
source: 'smithy',
|
|
74
|
-
target: 'ts#rdb'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
source: 'smithy',
|
|
78
|
-
target: 'ts#dynamodb'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
source: 'ts#mcp-server',
|
|
82
|
-
target: 'ts#rdb'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
source: 'ts#mcp-server',
|
|
86
|
-
target: 'ts#dynamodb'
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
source: 'react',
|
|
90
|
-
target: 'ts#trpc-api'
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
source: 'react',
|
|
94
|
-
target: 'py#fast-api'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
source: 'react',
|
|
98
|
-
target: 'smithy'
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
source: 'react',
|
|
102
|
-
target: 'ts#agent'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
source: 'react',
|
|
106
|
-
target: 'py#agent'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
source: 'ts#agent',
|
|
110
|
-
target: 'ts#mcp-server'
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
source: 'ts#agent',
|
|
114
|
-
target: 'py#mcp-server'
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
source: 'ts#agent',
|
|
118
|
-
target: 'ts#dynamodb'
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
source: 'py#agent',
|
|
122
|
-
target: 'ts#mcp-server'
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
source: 'py#agent',
|
|
126
|
-
target: 'py#mcp-server'
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
source: 'ts#agent',
|
|
130
|
-
target: 'ts#agent'
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
source: 'ts#agent',
|
|
134
|
-
target: 'py#agent'
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
source: 'py#agent',
|
|
138
|
-
target: 'ts#agent'
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
source: 'py#agent',
|
|
142
|
-
target: 'py#agent'
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
source: 'ts#agent',
|
|
146
|
-
target: 'agentcore-gateway'
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
source: 'py#agent',
|
|
150
|
-
target: 'agentcore-gateway'
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
source: 'agentcore-gateway',
|
|
154
|
-
target: 'ts#mcp-server'
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
source: 'agentcore-gateway',
|
|
158
|
-
target: 'py#mcp-server'
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
source: 'agentcore-gateway',
|
|
162
|
-
target: 'agentcore-gateway'
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
source: 'py#fast-api',
|
|
166
|
-
target: 'py#dynamodb'
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
source: 'py#agent',
|
|
170
|
-
target: 'py#dynamodb'
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
source: 'py#mcp-server',
|
|
174
|
-
target: 'py#dynamodb'
|
|
175
|
-
}
|
|
176
|
-
];
|
|
177
43
|
const CONNECTION_GENERATORS = {
|
|
178
44
|
'ts#trpc-api -> ts#rdb': (tree, options)=>tsRdbTrpcConnectionGenerator(tree, options),
|
|
179
45
|
'ts#agent -> ts#rdb': (tree, options)=>tsRdbAgentConnectionGenerator(tree, options),
|
|
180
|
-
'smithy -> ts#rdb': (tree, options)=>tsRdbSmithyConnectionGenerator(tree, options),
|
|
46
|
+
'ts#smithy-api -> ts#rdb': (tree, options)=>tsRdbSmithyConnectionGenerator(tree, options),
|
|
181
47
|
'ts#mcp-server -> ts#rdb': (tree, options)=>tsRdbMcpServerConnectionGenerator(tree, options),
|
|
182
48
|
'ts#trpc-api -> ts#dynamodb': (tree, options)=>tsDynamoDBTrpcConnectionGenerator(tree, options),
|
|
183
49
|
'ts#agent -> ts#dynamodb': (tree, options)=>tsDynamoDBAgentConnectionGenerator(tree, options),
|
|
184
|
-
'smithy -> ts#dynamodb': (tree, options)=>tsDynamoDBSmithyConnectionGenerator(tree, options),
|
|
50
|
+
'ts#smithy-api -> ts#dynamodb': (tree, options)=>tsDynamoDBSmithyConnectionGenerator(tree, options),
|
|
185
51
|
'ts#mcp-server -> ts#dynamodb': (tree, options)=>tsDynamoDBMcpServerConnectionGenerator(tree, options),
|
|
186
|
-
'react -> ts#trpc-api': (tree, options)=>trpcReactGenerator(tree, {
|
|
52
|
+
'ts#react-website -> ts#trpc-api': (tree, options)=>trpcReactGenerator(tree, {
|
|
187
53
|
frontendProjectName: options.sourceProject,
|
|
188
54
|
backendProjectName: options.targetProject,
|
|
189
55
|
preferInstallDependencies: options.preferInstallDependencies
|
|
190
56
|
}),
|
|
191
|
-
'react -> py#fast-api': (tree, options)=>fastApiReactGenerator(tree, {
|
|
57
|
+
'ts#react-website -> py#fast-api': (tree, options)=>fastApiReactGenerator(tree, {
|
|
192
58
|
frontendProjectName: options.sourceProject,
|
|
193
59
|
fastApiProjectName: options.targetProject,
|
|
194
60
|
preferInstallDependencies: options.preferInstallDependencies
|
|
195
61
|
}),
|
|
196
|
-
'react -> smithy': (tree, options)=>smithyReactConnectionGenerator(tree, {
|
|
62
|
+
'ts#react-website -> ts#smithy-api': (tree, options)=>smithyReactConnectionGenerator(tree, {
|
|
197
63
|
frontendProjectName: options.sourceProject,
|
|
198
64
|
smithyModelOrBackendProjectName: options.targetProject,
|
|
199
65
|
preferInstallDependencies: options.preferInstallDependencies
|
|
200
66
|
}),
|
|
201
|
-
'react -> ts#agent': (tree, options)=>tsAgentReactConnectionGenerator(tree, options),
|
|
202
|
-
'react -> py#agent': (tree, options)=>pyAgentReactConnectionGenerator(tree, options),
|
|
67
|
+
'ts#react-website -> ts#agent': (tree, options)=>tsAgentReactConnectionGenerator(tree, options),
|
|
68
|
+
'ts#react-website -> py#agent': (tree, options)=>pyAgentReactConnectionGenerator(tree, options),
|
|
203
69
|
'ts#agent -> ts#mcp-server': (tree, options)=>tsAgentMcpConnectionGenerator(tree, options),
|
|
204
70
|
'ts#agent -> py#mcp-server': (tree, options)=>tsAgentMcpConnectionGenerator(tree, options),
|
|
205
71
|
'py#agent -> ts#mcp-server': (tree, options)=>pyAgentMcpConnectionGenerator(tree, options),
|
|
@@ -349,10 +215,10 @@ const CONNECTION_GENERATORS = {
|
|
|
349
215
|
return 'py#fast-api';
|
|
350
216
|
}
|
|
351
217
|
if (isSmithyApi(tree, projectConfiguration)) {
|
|
352
|
-
return 'smithy';
|
|
218
|
+
return 'ts#smithy-api';
|
|
353
219
|
}
|
|
354
220
|
if (isReact(tree, projectConfiguration)) {
|
|
355
|
-
return 'react';
|
|
221
|
+
return 'ts#react-website';
|
|
356
222
|
}
|
|
357
223
|
if (isRdb(projectConfiguration)) {
|
|
358
224
|
return 'ts#rdb';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport agentcoreGatewayGatewayConnectionGenerator from '../agentcore-gateway/gateway-connection/generator';\nimport { AGENTCORE_GATEWAY_GENERATOR_INFO } from '../agentcore-gateway/generator';\nimport agentcoreGatewayMcpConnectionGenerator from '../agentcore-gateway/mcp-connection/generator';\nimport pyAgentA2aConnectionGenerator from '../py/agent/a2a-connection/generator';\nimport pyAgentGatewayConnectionGenerator from '../py/agent/gateway-connection/generator';\nimport pyAgentMcpConnectionGenerator from '../py/agent/mcp-connection/generator';\nimport pyAgentReactConnectionGenerator from '../py/agent/react-connection/generator';\nimport pyDynamoDBAgentConnectionGenerator from '../py/dynamodb/agent-connection/generator';\nimport pyDynamoDBFastApiConnectionGenerator from '../py/dynamodb/fast-api-connection/generator';\nimport { PY_DYNAMODB_GENERATOR_INFO } from '../py/dynamodb/generator';\nimport pyDynamoDBMcpServerConnectionGenerator from '../py/dynamodb/mcp-server-connection/generator';\nimport fastApiReactGenerator from '../py/fast-api/react/generator';\nimport { SMITHY_PROJECT_GENERATOR_INFO } from '../smithy/project/generator';\nimport smithyReactConnectionGenerator from '../smithy/react-connection/generator';\nimport { TS_SMITHY_API_GENERATOR_INFO } from '../smithy/ts/api/generator';\nimport trpcReactGenerator from '../trpc/react/generator';\nimport tsAgentA2aConnectionGenerator from '../ts/agent/a2a-connection/generator';\nimport tsAgentGatewayConnectionGenerator from '../ts/agent/gateway-connection/generator';\nimport tsAgentMcpConnectionGenerator from '../ts/agent/mcp-connection/generator';\nimport tsAgentReactConnectionGenerator from '../ts/agent/react-connection/generator';\nimport tsDynamoDBAgentConnectionGenerator from '../ts/dynamodb/agent-connection/generator';\nimport { TS_DYNAMODB_GENERATOR_INFO } from '../ts/dynamodb/generator';\nimport tsDynamoDBMcpServerConnectionGenerator from '../ts/dynamodb/mcp-server-connection/generator';\nimport tsDynamoDBSmithyConnectionGenerator from '../ts/dynamodb/smithy-connection/generator';\nimport tsDynamoDBTrpcConnectionGenerator from '../ts/dynamodb/trpc-connection/generator';\nimport tsRdbAgentConnectionGenerator from '../ts/rdb/agent-connection/generator';\nimport { TS_RDB_GENERATOR_INFO } from '../ts/rdb/generator';\nimport tsRdbMcpServerConnectionGenerator from '../ts/rdb/mcp-server-connection/generator';\nimport tsRdbSmithyConnectionGenerator from '../ts/rdb/smithy-connection/generator';\nimport tsRdbTrpcConnectionGenerator from '../ts/rdb/trpc-connection/generator';\nimport { hasExportDeclaration } from '../utils/ast';\nimport {\n type ComponentMetadata,\n readProjectConfigurationUnqualified,\n} from '../utils/nx';\nimport { readToml } from '../utils/toml';\nimport type { ConnectionGeneratorSchema } from './schema';\n\n/**\n * List of supported source and target project types for connections.\n * These can be project-level types (determined by introspection) or\n * component generator ids (from component metadata).\n */\nconst SUPPORTED_PROJECT_TYPES = [\n 'ts#trpc-api',\n 'py#fast-api',\n 'react',\n 'smithy',\n 'ts#rdb',\n 'ts#dynamodb',\n 'py#dynamodb',\n 'agentcore-gateway',\n] as const;\n\ntype ProjectType = (typeof SUPPORTED_PROJECT_TYPES)[number];\n\nexport type Connection = { source: string; target: string };\n\n/**\n * Sentinel value for sourceComponent/targetComponent that means\n * \"use the project-level connection, not a component\".\n */\nexport const PROJECT_COMPONENT_SENTINEL = '.';\n\n/**\n * The result of resolving a connection, including the matched connection\n * and any resolved source/target component metadata.\n */\nexport interface ResolvedConnection {\n readonly connection: Connection;\n readonly sourceComponent?: ComponentMetadata;\n readonly targetComponent?: ComponentMetadata;\n}\n\n/**\n * Enumerates the supported project connections.\n * Source and target can be project-level types or component generator ids.\n */\nconst SUPPORTED_CONNECTIONS = [\n { source: 'ts#trpc-api', target: 'ts#rdb' },\n { source: 'ts#trpc-api', target: 'ts#dynamodb' },\n { source: 'ts#agent', target: 'ts#rdb' },\n { source: 'smithy', target: 'ts#rdb' },\n { source: 'smithy', target: 'ts#dynamodb' },\n { source: 'ts#mcp-server', target: 'ts#rdb' },\n { source: 'ts#mcp-server', target: 'ts#dynamodb' },\n { source: 'react', target: 'ts#trpc-api' },\n { source: 'react', target: 'py#fast-api' },\n { source: 'react', target: 'smithy' },\n { source: 'react', target: 'ts#agent' },\n { source: 'react', target: 'py#agent' },\n { source: 'ts#agent', target: 'ts#mcp-server' },\n { source: 'ts#agent', target: 'py#mcp-server' },\n { source: 'ts#agent', target: 'ts#dynamodb' },\n { source: 'py#agent', target: 'ts#mcp-server' },\n { source: 'py#agent', target: 'py#mcp-server' },\n { source: 'ts#agent', target: 'ts#agent' },\n { source: 'ts#agent', target: 'py#agent' },\n { source: 'py#agent', target: 'ts#agent' },\n { source: 'py#agent', target: 'py#agent' },\n { source: 'ts#agent', target: 'agentcore-gateway' },\n { source: 'py#agent', target: 'agentcore-gateway' },\n { source: 'agentcore-gateway', target: 'ts#mcp-server' },\n { source: 'agentcore-gateway', target: 'py#mcp-server' },\n { source: 'agentcore-gateway', target: 'agentcore-gateway' },\n { source: 'py#fast-api', target: 'py#dynamodb' },\n { source: 'py#agent', target: 'py#dynamodb' },\n { source: 'py#mcp-server', target: 'py#dynamodb' },\n] as const satisfies readonly Connection[];\n\ntype ConnectionKey = (typeof SUPPORTED_CONNECTIONS)[number] extends infer C\n ? C extends Connection\n ? `${C['source']} -> ${C['target']}`\n : never\n : never;\n\n/**\n * Generators for each connection type\n */\n/**\n * Options passed to connection generators, including resolved component metadata.\n */\nexport interface ResolvedConnectionOptions {\n sourceProject: string;\n targetProject: string;\n sourceComponent?: ComponentMetadata;\n targetComponent?: ComponentMetadata;\n preferInstallDependencies?: boolean;\n}\n\nconst CONNECTION_GENERATORS = {\n 'ts#trpc-api -> ts#rdb': (tree, options) =>\n tsRdbTrpcConnectionGenerator(tree, options),\n 'ts#agent -> ts#rdb': (tree, options) =>\n tsRdbAgentConnectionGenerator(tree, options),\n 'smithy -> ts#rdb': (tree, options) =>\n tsRdbSmithyConnectionGenerator(tree, options),\n 'ts#mcp-server -> ts#rdb': (tree, options) =>\n tsRdbMcpServerConnectionGenerator(tree, options),\n 'ts#trpc-api -> ts#dynamodb': (tree, options) =>\n tsDynamoDBTrpcConnectionGenerator(tree, options),\n 'ts#agent -> ts#dynamodb': (tree, options) =>\n tsDynamoDBAgentConnectionGenerator(tree, options),\n 'smithy -> ts#dynamodb': (tree, options) =>\n tsDynamoDBSmithyConnectionGenerator(tree, options),\n 'ts#mcp-server -> ts#dynamodb': (tree, options) =>\n tsDynamoDBMcpServerConnectionGenerator(tree, options),\n 'react -> ts#trpc-api': (tree, options) =>\n trpcReactGenerator(tree, {\n frontendProjectName: options.sourceProject,\n backendProjectName: options.targetProject,\n preferInstallDependencies: options.preferInstallDependencies,\n }),\n 'react -> py#fast-api': (tree, options) =>\n fastApiReactGenerator(tree, {\n frontendProjectName: options.sourceProject,\n fastApiProjectName: options.targetProject,\n preferInstallDependencies: options.preferInstallDependencies,\n }),\n 'react -> smithy': (tree, options) =>\n smithyReactConnectionGenerator(tree, {\n frontendProjectName: options.sourceProject,\n smithyModelOrBackendProjectName: options.targetProject,\n preferInstallDependencies: options.preferInstallDependencies,\n }),\n 'react -> ts#agent': (tree, options) =>\n tsAgentReactConnectionGenerator(tree, options),\n 'react -> py#agent': (tree, options) =>\n pyAgentReactConnectionGenerator(tree, options),\n 'ts#agent -> ts#mcp-server': (tree, options) =>\n tsAgentMcpConnectionGenerator(tree, options),\n 'ts#agent -> py#mcp-server': (tree, options) =>\n tsAgentMcpConnectionGenerator(tree, options),\n 'py#agent -> ts#mcp-server': (tree, options) =>\n pyAgentMcpConnectionGenerator(tree, options),\n 'py#agent -> py#mcp-server': (tree, options) =>\n pyAgentMcpConnectionGenerator(tree, options),\n 'ts#agent -> ts#agent': (tree, options) =>\n tsAgentA2aConnectionGenerator(tree, options),\n 'ts#agent -> py#agent': (tree, options) =>\n tsAgentA2aConnectionGenerator(tree, options),\n 'py#agent -> ts#agent': (tree, options) =>\n pyAgentA2aConnectionGenerator(tree, options),\n 'py#agent -> py#agent': (tree, options) =>\n pyAgentA2aConnectionGenerator(tree, options),\n 'ts#agent -> agentcore-gateway': (tree, options) =>\n tsAgentGatewayConnectionGenerator(tree, options),\n 'py#agent -> agentcore-gateway': (tree, options) =>\n pyAgentGatewayConnectionGenerator(tree, options),\n 'agentcore-gateway -> ts#mcp-server': (tree, options) =>\n agentcoreGatewayMcpConnectionGenerator(tree, options),\n 'agentcore-gateway -> py#mcp-server': (tree, options) =>\n agentcoreGatewayMcpConnectionGenerator(tree, options),\n 'agentcore-gateway -> agentcore-gateway': (tree, options) =>\n agentcoreGatewayGatewayConnectionGenerator(tree, options),\n 'py#fast-api -> py#dynamodb': (tree, options) =>\n pyDynamoDBFastApiConnectionGenerator(tree, options),\n 'py#agent -> py#dynamodb': (tree, options) =>\n pyDynamoDBAgentConnectionGenerator(tree, options),\n 'py#mcp-server -> py#dynamodb': (tree, options) =>\n pyDynamoDBMcpServerConnectionGenerator(tree, options),\n} satisfies Record<\n ConnectionKey,\n (tree: Tree, options: ResolvedConnectionOptions) => Promise<any>\n>;\n\n/**\n * Generator for a connection between two projects\n */\nexport const connectionGenerator = async (\n tree: Tree,\n options: ConnectionGeneratorSchema,\n) => {\n const resolved = await resolveConnection(tree, options);\n\n const connectionKey =\n `${resolved.connection.source} -> ${resolved.connection.target}` as ConnectionKey;\n\n return await CONNECTION_GENERATORS[connectionKey](tree, {\n sourceProject: options.sourceProject,\n targetProject: options.targetProject,\n sourceComponent: resolved.sourceComponent,\n targetComponent: resolved.targetComponent,\n preferInstallDependencies: options.preferInstallDependencies,\n });\n};\n\n/**\n * Find a component in project metadata matching the given reference.\n * Checks by name first, then by path, then by generator.\n */\nexport const findComponentInMetadata = (\n projectConfiguration: ProjectConfiguration,\n componentRef: string,\n): ComponentMetadata | undefined => {\n const components: ComponentMetadata[] =\n (projectConfiguration.metadata as any)?.components ?? [];\n\n return (\n components.find((c) => c.name === componentRef) ??\n components.find((c) => c.path === componentRef) ??\n components.find((c) => c.generator === componentRef)\n );\n};\n\n/**\n * Represents a candidate source or target for a connection, which may be\n * the project itself or a specific component within the project.\n */\ninterface ConnectionCandidate {\n readonly type: string;\n readonly component?: ComponentMetadata;\n}\n\n/**\n * A matched connection between source and target candidates.\n */\ninterface ConnectionMatch {\n readonly connection: Connection;\n readonly sourceComponent?: ComponentMetadata;\n readonly targetComponent?: ComponentMetadata;\n}\n\n/**\n * Gather all connection candidates for a project configuration. This includes:\n * - The project-level type (if it's a supported type)\n * - Each component's generator id as a candidate type\n */\nconst gatherCandidates = async (\n tree: Tree,\n projectConfig: ProjectConfiguration,\n): Promise<ConnectionCandidate[]> => {\n const type = await determineProjectTypeFromConfig(tree, projectConfig);\n const components: ComponentMetadata[] =\n (projectConfig.metadata as any)?.components ?? [];\n\n return [\n ...(type ? [{ type: type }] : []),\n ...components.map((component) => ({\n type: component.generator,\n component,\n })),\n ];\n};\n\n/**\n * Validate that a specified component exists in the project metadata.\n * Skips validation for undefined refs and the project sentinel '.'.\n */\nconst validateComponent = (\n componentRef: string | undefined,\n projectConfig: ProjectConfiguration,\n side: 'source' | 'target',\n) => {\n if (!componentRef || componentRef === PROJECT_COMPONENT_SENTINEL) return;\n const found = findComponentInMetadata(projectConfig, componentRef);\n if (!found) {\n const components: ComponentMetadata[] =\n (projectConfig.metadata as any)?.components ?? [];\n throw new Error(\n `Component '${componentRef}' not found in ${side} project ${projectConfig.name}. ` +\n `Available components: ${components.length > 0 ? components.map((c) => c.name ?? c.generator).join(', ') : 'none'}`,\n );\n }\n};\n\n/**\n * Narrow candidates based on the user's specified component reference.\n */\nconst filterConnectionCandidatesForComponentReference = (\n componentRef: string | undefined,\n projectConfig: ProjectConfiguration,\n candidates: ConnectionCandidate[],\n supportedConnections: readonly Connection[],\n side: 'source' | 'target',\n): ConnectionCandidate[] => {\n if (!componentRef) return candidates;\n if (componentRef === PROJECT_COMPONENT_SENTINEL) {\n return candidates.filter((c) => !c.component);\n }\n const component = findComponentInMetadata(projectConfig, componentRef);\n if (!component) return candidates;\n const isConnectionParticipant = supportedConnections.some(\n (c) => c[side] === component.generator,\n );\n if (!isConnectionParticipant) return candidates;\n // Filter to the specific matched component, not all components with the same generator\n return candidates.filter((c) => c.component === component);\n};\n\n/**\n * Resolve the connection to use, considering source/target projects and components.\n */\nexport const resolveConnection = async (\n tree: Tree,\n options: ConnectionGeneratorSchema,\n supportedConnections: readonly Connection[] = SUPPORTED_CONNECTIONS,\n): Promise<ResolvedConnection> => {\n const sourceConfig = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetConfig = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n // Validate explicitly specified components exist\n validateComponent(options.sourceComponent, sourceConfig, 'source');\n validateComponent(options.targetComponent, targetConfig, 'target');\n\n // Gather and narrow candidates\n const sourceCandidates = filterConnectionCandidatesForComponentReference(\n options.sourceComponent,\n sourceConfig,\n await gatherCandidates(tree, sourceConfig),\n supportedConnections,\n 'source',\n );\n const targetCandidates = filterConnectionCandidatesForComponentReference(\n options.targetComponent,\n targetConfig,\n await gatherCandidates(tree, targetConfig),\n supportedConnections,\n 'target',\n );\n\n // Cross-product candidates and find supported connections\n const matches: ConnectionMatch[] = [];\n for (const source of sourceCandidates) {\n for (const target of targetCandidates) {\n const match = supportedConnections.find(\n (c) => c.source === source.type && c.target === target.type,\n );\n if (match) {\n matches.push({\n connection: match,\n sourceComponent: source.component,\n targetComponent: target.component,\n });\n }\n }\n }\n\n if (matches.length === 0) {\n const sourceTypes = [...new Set(sourceCandidates.map((c) => c.type))];\n const targetTypes = [...new Set(targetCandidates.map((c) => c.type))];\n throw new Error(\n `This generator does not support a connection from ${options.sourceProject}${sourceTypes.length > 0 ? ` (${sourceTypes.join(', ')})` : ''} to ${options.targetProject}${targetTypes.length > 0 ? ` (${targetTypes.join(', ')})` : ''}`,\n );\n }\n\n if (matches.length > 1) {\n const connectionDescriptions = matches\n .map((m) => {\n const sourceName = m.sourceComponent?.name;\n const targetName = m.targetComponent?.name;\n const sourceLabel = sourceName\n ? `${sourceName} (${m.connection.source})`\n : m.connection.source;\n const targetLabel = targetName\n ? `${targetName} (${m.connection.target})`\n : m.connection.target;\n return `${sourceLabel} -> ${targetLabel}`;\n })\n .join(', ');\n throw new Error(\n `Ambiguous connection from ${options.sourceProject} to ${options.targetProject}. ` +\n `Multiple supported connections found: ${connectionDescriptions}. ` +\n `Please specify sourceComponent and/or targetComponent to disambiguate.`,\n );\n }\n\n return {\n connection: matches[0].connection,\n sourceComponent: matches[0].sourceComponent,\n targetComponent: matches[0].targetComponent,\n };\n};\n\n/**\n * Determine whether the given project is of a known project type\n */\nexport const determineProjectType = async (\n tree: Tree,\n projectName: string,\n): Promise<ProjectType | undefined> => {\n const projectConfiguration = readProjectConfigurationUnqualified(\n tree,\n projectName,\n );\n return await determineProjectTypeFromConfig(tree, projectConfiguration);\n};\n\n/**\n * Determine whether the given project configuration is of a known project type\n */\nconst determineProjectTypeFromConfig = async (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): Promise<ProjectType | undefined> => {\n // NB: if adding new checks, ensure these go from most to least specific\n // eg. react website is more specific than typescript project\n\n if (await isTrpcApi(tree, projectConfiguration)) {\n return 'ts#trpc-api';\n }\n\n if (isFastApi(tree, projectConfiguration)) {\n return 'py#fast-api';\n }\n\n if (isSmithyApi(tree, projectConfiguration)) {\n return 'smithy';\n }\n\n if (isReact(tree, projectConfiguration)) {\n return 'react';\n }\n\n if (isRdb(projectConfiguration)) {\n return 'ts#rdb';\n }\n\n if (isTsDynamoDB(projectConfiguration)) {\n return 'ts#dynamodb';\n }\n\n if (isPyDynamoDB(projectConfiguration)) {\n return 'py#dynamodb';\n }\n\n if (isAgentCoreGateway(projectConfiguration)) {\n return 'agentcore-gateway';\n }\n\n return undefined;\n};\n\nconst sourceRoot = (projectConfiguration: ProjectConfiguration) =>\n projectConfiguration.sourceRoot ??\n joinPathFragments(projectConfiguration.root, 'src');\n\nconst isTrpcApi = async (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): Promise<boolean> => {\n // If the project.json says it's a trpc api, there's no need for introspection\n if ((projectConfiguration.metadata as any)?.apiType === 'trpc') {\n return true;\n }\n\n // Find the src/index.ts\n const indexTs = tree.read(\n joinPathFragments(sourceRoot(projectConfiguration), 'index.ts'),\n 'utf-8',\n );\n if (indexTs === null) {\n return false;\n }\n\n // If the index file exports an AppRouter, it's a trpc api\n if (await hasExportDeclaration(tree, indexTs, 'AppRouter')) {\n return true;\n }\n\n // If there's a src/router.ts or src/lambdas/router.ts which exports an AppRouter, it's a trpc api\n const trpcRouter =\n tree.read(\n joinPathFragments(sourceRoot(projectConfiguration), 'router.ts'),\n 'utf-8',\n ) ??\n tree.read(\n joinPathFragments(\n sourceRoot(projectConfiguration),\n 'lambdas',\n 'router.ts',\n ),\n 'utf-8',\n );\n\n if (trpcRouter === null) {\n return false;\n }\n\n if (await hasExportDeclaration(tree, trpcRouter, 'AppRouter')) {\n return true;\n }\n\n return false;\n};\n\nconst isReact = (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): boolean => {\n // if there's a main.tsx, it's a react app\n return tree.exists(\n joinPathFragments(sourceRoot(projectConfiguration), 'main.tsx'),\n );\n};\n\nconst isFastApi = (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): boolean => {\n // If the project.json says it's a fast api, there's no need for introspection\n if ((projectConfiguration.metadata as any)?.apiType === 'fast-api') {\n return true;\n }\n\n const pyProjectPath = joinPathFragments(\n projectConfiguration.root,\n 'pyproject.toml',\n );\n if (tree.exists(pyProjectPath)) {\n const pyProject = readToml(tree, pyProjectPath);\n if (((pyProject as any)?.project?.dependencies ?? []).includes('fastapi')) {\n return true;\n }\n }\n\n return false;\n};\n\nconst isSmithyApi = (\n _tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): boolean => {\n // Support selecting either the smithy model or backend project\n return [\n SMITHY_PROJECT_GENERATOR_INFO.id,\n TS_SMITHY_API_GENERATOR_INFO.id,\n ].includes(((projectConfiguration.metadata as any) ?? {}).generator);\n};\n\nconst isRdb = (projectConfiguration: ProjectConfiguration): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n TS_RDB_GENERATOR_INFO.id;\n\nconst isTsDynamoDB = (projectConfiguration: ProjectConfiguration): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n TS_DYNAMODB_GENERATOR_INFO.id;\n\nconst isPyDynamoDB = (projectConfiguration: ProjectConfiguration): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n PY_DYNAMODB_GENERATOR_INFO.id;\n\nconst isAgentCoreGateway = (\n projectConfiguration: ProjectConfiguration,\n): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n AGENTCORE_GATEWAY_GENERATOR_INFO.id;\n\nexport default connectionGenerator;\n"],"names":["joinPathFragments","agentcoreGatewayGatewayConnectionGenerator","AGENTCORE_GATEWAY_GENERATOR_INFO","agentcoreGatewayMcpConnectionGenerator","pyAgentA2aConnectionGenerator","pyAgentGatewayConnectionGenerator","pyAgentMcpConnectionGenerator","pyAgentReactConnectionGenerator","pyDynamoDBAgentConnectionGenerator","pyDynamoDBFastApiConnectionGenerator","PY_DYNAMODB_GENERATOR_INFO","pyDynamoDBMcpServerConnectionGenerator","fastApiReactGenerator","SMITHY_PROJECT_GENERATOR_INFO","smithyReactConnectionGenerator","TS_SMITHY_API_GENERATOR_INFO","trpcReactGenerator","tsAgentA2aConnectionGenerator","tsAgentGatewayConnectionGenerator","tsAgentMcpConnectionGenerator","tsAgentReactConnectionGenerator","tsDynamoDBAgentConnectionGenerator","TS_DYNAMODB_GENERATOR_INFO","tsDynamoDBMcpServerConnectionGenerator","tsDynamoDBSmithyConnectionGenerator","tsDynamoDBTrpcConnectionGenerator","tsRdbAgentConnectionGenerator","TS_RDB_GENERATOR_INFO","tsRdbMcpServerConnectionGenerator","tsRdbSmithyConnectionGenerator","tsRdbTrpcConnectionGenerator","hasExportDeclaration","readProjectConfigurationUnqualified","readToml","SUPPORTED_PROJECT_TYPES","PROJECT_COMPONENT_SENTINEL","SUPPORTED_CONNECTIONS","source","target","CONNECTION_GENERATORS","tree","options","frontendProjectName","sourceProject","backendProjectName","targetProject","preferInstallDependencies","fastApiProjectName","smithyModelOrBackendProjectName","connectionGenerator","resolved","resolveConnection","connectionKey","connection","sourceComponent","targetComponent","findComponentInMetadata","projectConfiguration","componentRef","components","metadata","find","c","name","path","generator","gatherCandidates","projectConfig","type","determineProjectTypeFromConfig","map","component","validateComponent","side","found","Error","length","join","filterConnectionCandidatesForComponentReference","candidates","supportedConnections","filter","isConnectionParticipant","some","sourceConfig","targetConfig","sourceCandidates","targetCandidates","matches","match","push","sourceTypes","Set","targetTypes","connectionDescriptions","m","sourceName","targetName","sourceLabel","targetLabel","determineProjectType","projectName","isTrpcApi","isFastApi","isSmithyApi","isReact","isRdb","isTsDynamoDB","isPyDynamoDB","isAgentCoreGateway","undefined","sourceRoot","root","apiType","indexTs","read","trpcRouter","exists","pyProjectPath","pyProject","project","dependencies","includes","_tree","id"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,QAGZ,aAAa;AACpB,OAAOC,gDAAgD,uDAAoD;AAC3G,SAASC,gCAAgC,QAAQ,oCAAiC;AAClF,OAAOC,4CAA4C,mDAAgD;AACnG,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,uCAAuC,8CAA2C;AACzF,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,qCAAqC,4CAAyC;AACrF,OAAOC,wCAAwC,+CAA4C;AAC3F,OAAOC,0CAA0C,kDAA+C;AAChG,SAASC,0BAA0B,QAAQ,8BAA2B;AACtE,OAAOC,4CAA4C,oDAAiD;AACpG,OAAOC,2BAA2B,oCAAiC;AACnE,SAASC,6BAA6B,QAAQ,iCAA8B;AAC5E,OAAOC,oCAAoC,0CAAuC;AAClF,SAASC,4BAA4B,QAAQ,gCAA6B;AAC1E,OAAOC,wBAAwB,6BAA0B;AACzD,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,uCAAuC,8CAA2C;AACzF,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,qCAAqC,4CAAyC;AACrF,OAAOC,wCAAwC,+CAA4C;AAC3F,SAASC,0BAA0B,QAAQ,8BAA2B;AACtE,OAAOC,4CAA4C,oDAAiD;AACpG,OAAOC,yCAAyC,gDAA6C;AAC7F,OAAOC,uCAAuC,8CAA2C;AACzF,OAAOC,mCAAmC,0CAAuC;AACjF,SAASC,qBAAqB,QAAQ,yBAAsB;AAC5D,OAAOC,uCAAuC,+CAA4C;AAC1F,OAAOC,oC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G,EAAE;KAChC,CAACF,QAAQ,CAAC,AAAC,CAAA,AAACjE,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS;AACrE;AAEA,MAAMyC,QAAQ,CAACjD,uBACb,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxDtC,sBAAsBiG,EAAE;AAE1B,MAAMjB,eAAe,CAAClD,uBACpB,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxD3C,2BAA2BsG,EAAE;AAE/B,MAAMhB,eAAe,CAACnD,uBACpB,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxDvD,2BAA2BkH,EAAE;AAE/B,MAAMf,qBAAqB,CACzBpD,uBAEA,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxD/D,iCAAiC0H,EAAE;AAErC,eAAe3E,oBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport agentcoreGatewayGatewayConnectionGenerator from '../agentcore-gateway/gateway-connection/generator';\nimport { AGENTCORE_GATEWAY_GENERATOR_INFO } from '../agentcore-gateway/generator';\nimport agentcoreGatewayMcpConnectionGenerator from '../agentcore-gateway/mcp-connection/generator';\nimport pyAgentA2aConnectionGenerator from '../py/agent/a2a-connection/generator';\nimport pyAgentGatewayConnectionGenerator from '../py/agent/gateway-connection/generator';\nimport pyAgentMcpConnectionGenerator from '../py/agent/mcp-connection/generator';\nimport pyAgentReactConnectionGenerator from '../py/agent/react-connection/generator';\nimport pyDynamoDBAgentConnectionGenerator from '../py/dynamodb/agent-connection/generator';\nimport pyDynamoDBFastApiConnectionGenerator from '../py/dynamodb/fast-api-connection/generator';\nimport { PY_DYNAMODB_GENERATOR_INFO } from '../py/dynamodb/generator';\nimport pyDynamoDBMcpServerConnectionGenerator from '../py/dynamodb/mcp-server-connection/generator';\nimport fastApiReactGenerator from '../py/fast-api/react/generator';\nimport { SMITHY_PROJECT_GENERATOR_INFO } from '../smithy/project/generator';\nimport smithyReactConnectionGenerator from '../smithy/react-connection/generator';\nimport { TS_SMITHY_API_GENERATOR_INFO } from '../smithy/ts/api/generator';\nimport trpcReactGenerator from '../trpc/react/generator';\nimport tsAgentA2aConnectionGenerator from '../ts/agent/a2a-connection/generator';\nimport tsAgentGatewayConnectionGenerator from '../ts/agent/gateway-connection/generator';\nimport tsAgentMcpConnectionGenerator from '../ts/agent/mcp-connection/generator';\nimport tsAgentReactConnectionGenerator from '../ts/agent/react-connection/generator';\nimport tsDynamoDBAgentConnectionGenerator from '../ts/dynamodb/agent-connection/generator';\nimport { TS_DYNAMODB_GENERATOR_INFO } from '../ts/dynamodb/generator';\nimport tsDynamoDBMcpServerConnectionGenerator from '../ts/dynamodb/mcp-server-connection/generator';\nimport tsDynamoDBSmithyConnectionGenerator from '../ts/dynamodb/smithy-connection/generator';\nimport tsDynamoDBTrpcConnectionGenerator from '../ts/dynamodb/trpc-connection/generator';\nimport tsRdbAgentConnectionGenerator from '../ts/rdb/agent-connection/generator';\nimport { TS_RDB_GENERATOR_INFO } from '../ts/rdb/generator';\nimport tsRdbMcpServerConnectionGenerator from '../ts/rdb/mcp-server-connection/generator';\nimport tsRdbSmithyConnectionGenerator from '../ts/rdb/smithy-connection/generator';\nimport tsRdbTrpcConnectionGenerator from '../ts/rdb/trpc-connection/generator';\nimport { hasExportDeclaration } from '../utils/ast';\nimport {\n type ComponentMetadata,\n readProjectConfigurationUnqualified,\n} from '../utils/nx';\nimport { readToml } from '../utils/toml';\nimport type { ConnectionGeneratorSchema } from './schema';\nimport {\n type Connection,\n type ConnectionKey,\n SUPPORTED_CONNECTIONS,\n type SUPPORTED_PROJECT_TYPES,\n} from './supported-connections';\n\nexport type { Connection };\n\ntype ProjectType = (typeof SUPPORTED_PROJECT_TYPES)[number];\n\n/**\n * Sentinel value for sourceComponent/targetComponent that means\n * \"use the project-level connection, not a component\".\n */\nexport const PROJECT_COMPONENT_SENTINEL = '.';\n\n/**\n * The result of resolving a connection, including the matched connection\n * and any resolved source/target component metadata.\n */\nexport interface ResolvedConnection {\n readonly connection: Connection;\n readonly sourceComponent?: ComponentMetadata;\n readonly targetComponent?: ComponentMetadata;\n}\n\n/**\n * Generators for each connection type\n */\n/**\n * Options passed to connection generators, including resolved component metadata.\n */\nexport interface ResolvedConnectionOptions {\n sourceProject: string;\n targetProject: string;\n sourceComponent?: ComponentMetadata;\n targetComponent?: ComponentMetadata;\n preferInstallDependencies?: boolean;\n}\n\nconst CONNECTION_GENERATORS = {\n 'ts#trpc-api -> ts#rdb': (tree, options) =>\n tsRdbTrpcConnectionGenerator(tree, options),\n 'ts#agent -> ts#rdb': (tree, options) =>\n tsRdbAgentConnectionGenerator(tree, options),\n 'ts#smithy-api -> ts#rdb': (tree, options) =>\n tsRdbSmithyConnectionGenerator(tree, options),\n 'ts#mcp-server -> ts#rdb': (tree, options) =>\n tsRdbMcpServerConnectionGenerator(tree, options),\n 'ts#trpc-api -> ts#dynamodb': (tree, options) =>\n tsDynamoDBTrpcConnectionGenerator(tree, options),\n 'ts#agent -> ts#dynamodb': (tree, options) =>\n tsDynamoDBAgentConnectionGenerator(tree, options),\n 'ts#smithy-api -> ts#dynamodb': (tree, options) =>\n tsDynamoDBSmithyConnectionGenerator(tree, options),\n 'ts#mcp-server -> ts#dynamodb': (tree, options) =>\n tsDynamoDBMcpServerConnectionGenerator(tree, options),\n 'ts#react-website -> ts#trpc-api': (tree, options) =>\n trpcReactGenerator(tree, {\n frontendProjectName: options.sourceProject,\n backendProjectName: options.targetProject,\n preferInstallDependencies: options.preferInstallDependencies,\n }),\n 'ts#react-website -> py#fast-api': (tree, options) =>\n fastApiReactGenerator(tree, {\n frontendProjectName: options.sourceProject,\n fastApiProjectName: options.targetProject,\n preferInstallDependencies: options.preferInstallDependencies,\n }),\n 'ts#react-website -> ts#smithy-api': (tree, options) =>\n smithyReactConnectionGenerator(tree, {\n frontendProjectName: options.sourceProject,\n smithyModelOrBackendProjectName: options.targetProject,\n preferInstallDependencies: options.preferInstallDependencies,\n }),\n 'ts#react-website -> ts#agent': (tree, options) =>\n tsAgentReactConnectionGenerator(tree, options),\n 'ts#react-website -> py#agent': (tree, options) =>\n pyAgentReactConnectionGenerator(tree, options),\n 'ts#agent -> ts#mcp-server': (tree, options) =>\n tsAgentMcpConnectionGenerator(tree, options),\n 'ts#agent -> py#mcp-server': (tree, options) =>\n tsAgentMcpConnectionGenerator(tree, options),\n 'py#agent -> ts#mcp-server': (tree, options) =>\n pyAgentMcpConnectionGenerator(tree, options),\n 'py#agent -> py#mcp-server': (tree, options) =>\n pyAgentMcpConnectionGenerator(tree, options),\n 'ts#agent -> ts#agent': (tree, options) =>\n tsAgentA2aConnectionGenerator(tree, options),\n 'ts#agent -> py#agent': (tree, options) =>\n tsAgentA2aConnectionGenerator(tree, options),\n 'py#agent -> ts#agent': (tree, options) =>\n pyAgentA2aConnectionGenerator(tree, options),\n 'py#agent -> py#agent': (tree, options) =>\n pyAgentA2aConnectionGenerator(tree, options),\n 'ts#agent -> agentcore-gateway': (tree, options) =>\n tsAgentGatewayConnectionGenerator(tree, options),\n 'py#agent -> agentcore-gateway': (tree, options) =>\n pyAgentGatewayConnectionGenerator(tree, options),\n 'agentcore-gateway -> ts#mcp-server': (tree, options) =>\n agentcoreGatewayMcpConnectionGenerator(tree, options),\n 'agentcore-gateway -> py#mcp-server': (tree, options) =>\n agentcoreGatewayMcpConnectionGenerator(tree, options),\n 'agentcore-gateway -> agentcore-gateway': (tree, options) =>\n agentcoreGatewayGatewayConnectionGenerator(tree, options),\n 'py#fast-api -> py#dynamodb': (tree, options) =>\n pyDynamoDBFastApiConnectionGenerator(tree, options),\n 'py#agent -> py#dynamodb': (tree, options) =>\n pyDynamoDBAgentConnectionGenerator(tree, options),\n 'py#mcp-server -> py#dynamodb': (tree, options) =>\n pyDynamoDBMcpServerConnectionGenerator(tree, options),\n} satisfies Record<\n ConnectionKey,\n (tree: Tree, options: ResolvedConnectionOptions) => Promise<any>\n>;\n\n/**\n * Generator for a connection between two projects\n */\nexport const connectionGenerator = async (\n tree: Tree,\n options: ConnectionGeneratorSchema,\n) => {\n const resolved = await resolveConnection(tree, options);\n\n const connectionKey =\n `${resolved.connection.source} -> ${resolved.connection.target}` as ConnectionKey;\n\n return await CONNECTION_GENERATORS[connectionKey](tree, {\n sourceProject: options.sourceProject,\n targetProject: options.targetProject,\n sourceComponent: resolved.sourceComponent,\n targetComponent: resolved.targetComponent,\n preferInstallDependencies: options.preferInstallDependencies,\n });\n};\n\n/**\n * Find a component in project metadata matching the given reference.\n * Checks by name first, then by path, then by generator.\n */\nexport const findComponentInMetadata = (\n projectConfiguration: ProjectConfiguration,\n componentRef: string,\n): ComponentMetadata | undefined => {\n const components: ComponentMetadata[] =\n (projectConfiguration.metadata as any)?.components ?? [];\n\n return (\n components.find((c) => c.name === componentRef) ??\n components.find((c) => c.path === componentRef) ??\n components.find((c) => c.generator === componentRef)\n );\n};\n\n/**\n * Represents a candidate source or target for a connection, which may be\n * the project itself or a specific component within the project.\n */\ninterface ConnectionCandidate {\n readonly type: string;\n readonly component?: ComponentMetadata;\n}\n\n/**\n * A matched connection between source and target candidates.\n */\ninterface ConnectionMatch {\n readonly connection: Connection;\n readonly sourceComponent?: ComponentMetadata;\n readonly targetComponent?: ComponentMetadata;\n}\n\n/**\n * Gather all connection candidates for a project configuration. This includes:\n * - The project-level type (if it's a supported type)\n * - Each component's generator id as a candidate type\n */\nconst gatherCandidates = async (\n tree: Tree,\n projectConfig: ProjectConfiguration,\n): Promise<ConnectionCandidate[]> => {\n const type = await determineProjectTypeFromConfig(tree, projectConfig);\n const components: ComponentMetadata[] =\n (projectConfig.metadata as any)?.components ?? [];\n\n return [\n ...(type ? [{ type: type }] : []),\n ...components.map((component) => ({\n type: component.generator,\n component,\n })),\n ];\n};\n\n/**\n * Validate that a specified component exists in the project metadata.\n * Skips validation for undefined refs and the project sentinel '.'.\n */\nconst validateComponent = (\n componentRef: string | undefined,\n projectConfig: ProjectConfiguration,\n side: 'source' | 'target',\n) => {\n if (!componentRef || componentRef === PROJECT_COMPONENT_SENTINEL) return;\n const found = findComponentInMetadata(projectConfig, componentRef);\n if (!found) {\n const components: ComponentMetadata[] =\n (projectConfig.metadata as any)?.components ?? [];\n throw new Error(\n `Component '${componentRef}' not found in ${side} project ${projectConfig.name}. ` +\n `Available components: ${components.length > 0 ? components.map((c) => c.name ?? c.generator).join(', ') : 'none'}`,\n );\n }\n};\n\n/**\n * Narrow candidates based on the user's specified component reference.\n */\nconst filterConnectionCandidatesForComponentReference = (\n componentRef: string | undefined,\n projectConfig: ProjectConfiguration,\n candidates: ConnectionCandidate[],\n supportedConnections: readonly Connection[],\n side: 'source' | 'target',\n): ConnectionCandidate[] => {\n if (!componentRef) return candidates;\n if (componentRef === PROJECT_COMPONENT_SENTINEL) {\n return candidates.filter((c) => !c.component);\n }\n const component = findComponentInMetadata(projectConfig, componentRef);\n if (!component) return candidates;\n const isConnectionParticipant = supportedConnections.some(\n (c) => c[side] === component.generator,\n );\n if (!isConnectionParticipant) return candidates;\n // Filter to the specific matched component, not all components with the same generator\n return candidates.filter((c) => c.component === component);\n};\n\n/**\n * Resolve the connection to use, considering source/target projects and components.\n */\nexport const resolveConnection = async (\n tree: Tree,\n options: ConnectionGeneratorSchema,\n supportedConnections: readonly Connection[] = SUPPORTED_CONNECTIONS,\n): Promise<ResolvedConnection> => {\n const sourceConfig = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetConfig = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n // Validate explicitly specified components exist\n validateComponent(options.sourceComponent, sourceConfig, 'source');\n validateComponent(options.targetComponent, targetConfig, 'target');\n\n // Gather and narrow candidates\n const sourceCandidates = filterConnectionCandidatesForComponentReference(\n options.sourceComponent,\n sourceConfig,\n await gatherCandidates(tree, sourceConfig),\n supportedConnections,\n 'source',\n );\n const targetCandidates = filterConnectionCandidatesForComponentReference(\n options.targetComponent,\n targetConfig,\n await gatherCandidates(tree, targetConfig),\n supportedConnections,\n 'target',\n );\n\n // Cross-product candidates and find supported connections\n const matches: ConnectionMatch[] = [];\n for (const source of sourceCandidates) {\n for (const target of targetCandidates) {\n const match = supportedConnections.find(\n (c) => c.source === source.type && c.target === target.type,\n );\n if (match) {\n matches.push({\n connection: match,\n sourceComponent: source.component,\n targetComponent: target.component,\n });\n }\n }\n }\n\n if (matches.length === 0) {\n const sourceTypes = [...new Set(sourceCandidates.map((c) => c.type))];\n const targetTypes = [...new Set(targetCandidates.map((c) => c.type))];\n throw new Error(\n `This generator does not support a connection from ${options.sourceProject}${sourceTypes.length > 0 ? ` (${sourceTypes.join(', ')})` : ''} to ${options.targetProject}${targetTypes.length > 0 ? ` (${targetTypes.join(', ')})` : ''}`,\n );\n }\n\n if (matches.length > 1) {\n const connectionDescriptions = matches\n .map((m) => {\n const sourceName = m.sourceComponent?.name;\n const targetName = m.targetComponent?.name;\n const sourceLabel = sourceName\n ? `${sourceName} (${m.connection.source})`\n : m.connection.source;\n const targetLabel = targetName\n ? `${targetName} (${m.connection.target})`\n : m.connection.target;\n return `${sourceLabel} -> ${targetLabel}`;\n })\n .join(', ');\n throw new Error(\n `Ambiguous connection from ${options.sourceProject} to ${options.targetProject}. ` +\n `Multiple supported connections found: ${connectionDescriptions}. ` +\n `Please specify sourceComponent and/or targetComponent to disambiguate.`,\n );\n }\n\n return {\n connection: matches[0].connection,\n sourceComponent: matches[0].sourceComponent,\n targetComponent: matches[0].targetComponent,\n };\n};\n\n/**\n * Determine whether the given project is of a known project type\n */\nexport const determineProjectType = async (\n tree: Tree,\n projectName: string,\n): Promise<ProjectType | undefined> => {\n const projectConfiguration = readProjectConfigurationUnqualified(\n tree,\n projectName,\n );\n return await determineProjectTypeFromConfig(tree, projectConfiguration);\n};\n\n/**\n * Determine whether the given project configuration is of a known project type\n */\nconst determineProjectTypeFromConfig = async (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): Promise<ProjectType | undefined> => {\n // NB: if adding new checks, ensure these go from most to least specific\n // eg. react website is more specific than typescript project\n\n if (await isTrpcApi(tree, projectConfiguration)) {\n return 'ts#trpc-api';\n }\n\n if (isFastApi(tree, projectConfiguration)) {\n return 'py#fast-api';\n }\n\n if (isSmithyApi(tree, projectConfiguration)) {\n return 'ts#smithy-api';\n }\n\n if (isReact(tree, projectConfiguration)) {\n return 'ts#react-website';\n }\n\n if (isRdb(projectConfiguration)) {\n return 'ts#rdb';\n }\n\n if (isTsDynamoDB(projectConfiguration)) {\n return 'ts#dynamodb';\n }\n\n if (isPyDynamoDB(projectConfiguration)) {\n return 'py#dynamodb';\n }\n\n if (isAgentCoreGateway(projectConfiguration)) {\n return 'agentcore-gateway';\n }\n\n return undefined;\n};\n\nconst sourceRoot = (projectConfiguration: ProjectConfiguration) =>\n projectConfiguration.sourceRoot ??\n joinPathFragments(projectConfiguration.root, 'src');\n\nconst isTrpcApi = async (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): Promise<boolean> => {\n // If the project.json says it's a trpc api, there's no need for introspection\n if ((projectConfiguration.metadata as any)?.apiType === 'trpc') {\n return true;\n }\n\n // Find the src/index.ts\n const indexTs = tree.read(\n joinPathFragments(sourceRoot(projectConfiguration), 'index.ts'),\n 'utf-8',\n );\n if (indexTs === null) {\n return false;\n }\n\n // If the index file exports an AppRouter, it's a trpc api\n if (await hasExportDeclaration(tree, indexTs, 'AppRouter')) {\n return true;\n }\n\n // If there's a src/router.ts or src/lambdas/router.ts which exports an AppRouter, it's a trpc api\n const trpcRouter =\n tree.read(\n joinPathFragments(sourceRoot(projectConfiguration), 'router.ts'),\n 'utf-8',\n ) ??\n tree.read(\n joinPathFragments(\n sourceRoot(projectConfiguration),\n 'lambdas',\n 'router.ts',\n ),\n 'utf-8',\n );\n\n if (trpcRouter === null) {\n return false;\n }\n\n if (await hasExportDeclaration(tree, trpcRouter, 'AppRouter')) {\n return true;\n }\n\n return false;\n};\n\nconst isReact = (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): boolean => {\n // if there's a main.tsx, it's a react app\n return tree.exists(\n joinPathFragments(sourceRoot(projectConfiguration), 'main.tsx'),\n );\n};\n\nconst isFastApi = (\n tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): boolean => {\n // If the project.json says it's a fast api, there's no need for introspection\n if ((projectConfiguration.metadata as any)?.apiType === 'fast-api') {\n return true;\n }\n\n const pyProjectPath = joinPathFragments(\n projectConfiguration.root,\n 'pyproject.toml',\n );\n if (tree.exists(pyProjectPath)) {\n const pyProject = readToml(tree, pyProjectPath);\n if (((pyProject as any)?.project?.dependencies ?? []).includes('fastapi')) {\n return true;\n }\n }\n\n return false;\n};\n\nconst isSmithyApi = (\n _tree: Tree,\n projectConfiguration: ProjectConfiguration,\n): boolean => {\n // Support selecting either the smithy model or backend project\n return [\n SMITHY_PROJECT_GENERATOR_INFO.id,\n TS_SMITHY_API_GENERATOR_INFO.id,\n ].includes(((projectConfiguration.metadata as any) ?? {}).generator);\n};\n\nconst isRdb = (projectConfiguration: ProjectConfiguration): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n TS_RDB_GENERATOR_INFO.id;\n\nconst isTsDynamoDB = (projectConfiguration: ProjectConfiguration): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n TS_DYNAMODB_GENERATOR_INFO.id;\n\nconst isPyDynamoDB = (projectConfiguration: ProjectConfiguration): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n PY_DYNAMODB_GENERATOR_INFO.id;\n\nconst isAgentCoreGateway = (\n projectConfiguration: ProjectConfiguration,\n): boolean =>\n ((projectConfiguration.metadata as any) ?? {}).generator ===\n AGENTCORE_GATEWAY_GENERATOR_INFO.id;\n\nexport default connectionGenerator;\n"],"names":["joinPathFragments","agentcoreGatewayGatewayConnectionGenerator","AGENTCORE_GATEWAY_GENERATOR_INFO","agentcoreGatewayMcpConnectionGenerator","pyAgentA2aConnectionGenerator","pyAgentGatewayConnectionGenerator","pyAgentMcpConnectionGenerator","pyAgentReactConnectionGenerator","pyDynamoDBAgentConnectionGenerator","pyDynamoDBFastApiConnectionGenerator","PY_DYNAMODB_GENERATOR_INFO","pyDynamoDBMcpServerConnectionGenerator","fastApiReactGenerator","SMITHY_PROJECT_GENERATOR_INFO","smithyReactConnectionGenerator","TS_SMITHY_API_GENERATOR_INFO","trpcReactGenerator","tsAgentA2aConnectionGenerator","tsAgentGatewayConnectionGenerator","tsAgentMcpConnectionGenerator","tsAgentReactConnectionGenerator","tsDynamoDBAgentConnectionGenerator","TS_DYNAMODB_GENERATOR_INFO","tsDynamoDBMcpServerConnectionGenerator","tsDynamoDBSmithyConnectionGenerator","tsDynamoDBTrpcConnectionGenerator","tsRdbAgentConnectionGenerator","TS_RDB_GENERATOR_INFO","tsRdbMcpServerConnectionGenerator","tsRdbSmithyConnectionGenerator","tsRdbTrpcConnectionGenerator","hasExportDeclaration","readProjectConfigurationUnqualified","readToml","SUPPORTED_CONNECTIONS","PROJECT_COMPONENT_SENTINEL","CONNECTION_GENERATORS","tree","options","frontendProjectName","sourceProject","backendProjectName","targetProject","preferInstallDependencies","fastApiProjectName","smithyModelOrBackendProjectName","connectionGenerator","resolved","resolveConnection","connectionKey","connection","source","target","sourceComponent","targetComponent","findComponentInMetadata","projectConfiguration","componentRef","components","metadata","find","c","name","path","generator","gatherCandidates","projectConfig","type","determineProjectTypeFromConfig","map","component","validateComponent","side","found","Error","length","join","filterConnectionCandidatesForComponentReference","candidates","supportedConnections","filter","isConnectionParticipant","some","sourceConfig","targetConfig","sourceCandidates","targetCandidates","matches","match","push","sourceTypes","Set","targetTypes","connectionDescriptions","m","sourceName","targetName","sourceLabel","targetLabel","determineProjectType","projectName","isTrpcApi","isFastApi","isSmithyApi","isReact","isRdb","isTsDynamoDB","isPyDynamoDB","isAgentCoreGateway","undefined","sourceRoot","root","apiType","indexTs","read","trpcRouter","exists","pyProjectPath","pyProject","project","dependencies","includes","_tree","id"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,QAGZ,aAAa;AACpB,OAAOC,gDAAgD,uDAAoD;AAC3G,SAASC,gCAAgC,QAAQ,oCAAiC;AAClF,OAAOC,4CAA4C,mDAAgD;AACnG,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,uCAAuC,8CAA2C;AACzF,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,qCAAqC,4CAAyC;AACrF,OAAOC,wCAAwC,+CAA4C;AAC3F,OAAOC,0CAA0C,kDAA+C;AAChG,SAASC,0BAA0B,QAAQ,8BAA2B;AACtE,OAAOC,4CAA4C,oDAAiD;AACpG,OAAOC,2BAA2B,oCAAiC;AACnE,SAASC,6BAA6B,QAAQ,iCAA8B;AAC5E,OAAOC,oCAAoC,0CAAuC;AAClF,SAASC,4BAA4B,QAAQ,gCAA6B;AAC1E,OAAOC,wBAAwB,6BAA0B;AACzD,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,uCAAuC,8CAA2C;AACzF,OAAOC,mCAAmC,0CAAuC;AACjF,OAAOC,qCAAqC,4CAAyC;AACrF,OAAOC,wCAAwC,+CAA4C;AAC3F,SAASC,0BAA0B,QAAQ,8BAA2B;AACtE,OAAOC,4CAA4C,oDAAiD;AACpG,OAAOC,yCAAyC,gDAA6C;AAC7F,OAAOC,uCAAuC,8CAA2C;AACzF,OAAOC,mCAAmC,0CAAuC;AACjF,SAASC,qBAAqB,QAAQ,yBAAsB;AAC5D,OAAOC,uCAAuC,+CAA4C;AAC1F,OAAOC,oCAAoC,2CAAwC;AACnF,OAAOC,kCAAkC,yCAAsC;AAC/E,SAASC,oB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A,MAAMyC,QAAQ,CAACjD,uBACb,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxDrC,sBAAsBgG,EAAE;AAE1B,MAAMjB,eAAe,CAAClD,uBACpB,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxD1C,2BAA2BqG,EAAE;AAE/B,MAAMhB,eAAe,CAACnD,uBACpB,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxDtD,2BAA2BiH,EAAE;AAE/B,MAAMf,qBAAqB,CACzBpD,uBAEA,AAAC,CAAA,AAACA,qBAAqBG,QAAQ,IAAY,CAAC,CAAA,EAAGK,SAAS,KACxD9D,iCAAiCyH,EAAE;AAErC,eAAe7E,oBAAoB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export type Connection = {
|
|
6
|
+
source: string;
|
|
7
|
+
target: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const SUPPORTED_PROJECT_TYPES: readonly ["ts#trpc-api", "py#fast-api", "ts#react-website", "ts#smithy-api", "ts#rdb", "ts#dynamodb", "py#dynamodb", "agentcore-gateway"];
|
|
10
|
+
export declare const SUPPORTED_CONNECTIONS: readonly [{
|
|
11
|
+
readonly source: "ts#trpc-api";
|
|
12
|
+
readonly target: "ts#rdb";
|
|
13
|
+
}, {
|
|
14
|
+
readonly source: "ts#trpc-api";
|
|
15
|
+
readonly target: "ts#dynamodb";
|
|
16
|
+
}, {
|
|
17
|
+
readonly source: "ts#agent";
|
|
18
|
+
readonly target: "ts#rdb";
|
|
19
|
+
}, {
|
|
20
|
+
readonly source: "ts#smithy-api";
|
|
21
|
+
readonly target: "ts#rdb";
|
|
22
|
+
}, {
|
|
23
|
+
readonly source: "ts#smithy-api";
|
|
24
|
+
readonly target: "ts#dynamodb";
|
|
25
|
+
}, {
|
|
26
|
+
readonly source: "ts#mcp-server";
|
|
27
|
+
readonly target: "ts#rdb";
|
|
28
|
+
}, {
|
|
29
|
+
readonly source: "ts#mcp-server";
|
|
30
|
+
readonly target: "ts#dynamodb";
|
|
31
|
+
}, {
|
|
32
|
+
readonly source: "ts#react-website";
|
|
33
|
+
readonly target: "ts#trpc-api";
|
|
34
|
+
}, {
|
|
35
|
+
readonly source: "ts#react-website";
|
|
36
|
+
readonly target: "py#fast-api";
|
|
37
|
+
}, {
|
|
38
|
+
readonly source: "ts#react-website";
|
|
39
|
+
readonly target: "ts#smithy-api";
|
|
40
|
+
}, {
|
|
41
|
+
readonly source: "ts#react-website";
|
|
42
|
+
readonly target: "ts#agent";
|
|
43
|
+
}, {
|
|
44
|
+
readonly source: "ts#react-website";
|
|
45
|
+
readonly target: "py#agent";
|
|
46
|
+
}, {
|
|
47
|
+
readonly source: "ts#agent";
|
|
48
|
+
readonly target: "ts#mcp-server";
|
|
49
|
+
}, {
|
|
50
|
+
readonly source: "ts#agent";
|
|
51
|
+
readonly target: "py#mcp-server";
|
|
52
|
+
}, {
|
|
53
|
+
readonly source: "ts#agent";
|
|
54
|
+
readonly target: "ts#dynamodb";
|
|
55
|
+
}, {
|
|
56
|
+
readonly source: "py#agent";
|
|
57
|
+
readonly target: "ts#mcp-server";
|
|
58
|
+
}, {
|
|
59
|
+
readonly source: "py#agent";
|
|
60
|
+
readonly target: "py#mcp-server";
|
|
61
|
+
}, {
|
|
62
|
+
readonly source: "ts#agent";
|
|
63
|
+
readonly target: "ts#agent";
|
|
64
|
+
}, {
|
|
65
|
+
readonly source: "ts#agent";
|
|
66
|
+
readonly target: "py#agent";
|
|
67
|
+
}, {
|
|
68
|
+
readonly source: "py#agent";
|
|
69
|
+
readonly target: "ts#agent";
|
|
70
|
+
}, {
|
|
71
|
+
readonly source: "py#agent";
|
|
72
|
+
readonly target: "py#agent";
|
|
73
|
+
}, {
|
|
74
|
+
readonly source: "ts#agent";
|
|
75
|
+
readonly target: "agentcore-gateway";
|
|
76
|
+
}, {
|
|
77
|
+
readonly source: "py#agent";
|
|
78
|
+
readonly target: "agentcore-gateway";
|
|
79
|
+
}, {
|
|
80
|
+
readonly source: "agentcore-gateway";
|
|
81
|
+
readonly target: "ts#mcp-server";
|
|
82
|
+
}, {
|
|
83
|
+
readonly source: "agentcore-gateway";
|
|
84
|
+
readonly target: "py#mcp-server";
|
|
85
|
+
}, {
|
|
86
|
+
readonly source: "agentcore-gateway";
|
|
87
|
+
readonly target: "agentcore-gateway";
|
|
88
|
+
}, {
|
|
89
|
+
readonly source: "py#fast-api";
|
|
90
|
+
readonly target: "py#dynamodb";
|
|
91
|
+
}, {
|
|
92
|
+
readonly source: "py#agent";
|
|
93
|
+
readonly target: "py#dynamodb";
|
|
94
|
+
}, {
|
|
95
|
+
readonly source: "py#mcp-server";
|
|
96
|
+
readonly target: "py#dynamodb";
|
|
97
|
+
}];
|
|
98
|
+
export type ConnectionKey = (typeof SUPPORTED_CONNECTIONS)[number] extends infer C ? C extends Connection ? `${C['source']} -> ${C['target']}` : never : never;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ // Supported source/target project types: either project-level types (resolved
|
|
5
|
+
// by introspection) or component generator ids (from component metadata).
|
|
6
|
+
export const SUPPORTED_PROJECT_TYPES = [
|
|
7
|
+
'ts#trpc-api',
|
|
8
|
+
'py#fast-api',
|
|
9
|
+
'ts#react-website',
|
|
10
|
+
'ts#smithy-api',
|
|
11
|
+
'ts#rdb',
|
|
12
|
+
'ts#dynamodb',
|
|
13
|
+
'py#dynamodb',
|
|
14
|
+
'agentcore-gateway'
|
|
15
|
+
];
|
|
16
|
+
// The single source of truth for supported connections, in a dependency-free
|
|
17
|
+
// module so the e2e connection matrix can import it without pulling in the
|
|
18
|
+
// generator implementation graph.
|
|
19
|
+
export const SUPPORTED_CONNECTIONS = [
|
|
20
|
+
{
|
|
21
|
+
source: 'ts#trpc-api',
|
|
22
|
+
target: 'ts#rdb'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
source: 'ts#trpc-api',
|
|
26
|
+
target: 'ts#dynamodb'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
source: 'ts#agent',
|
|
30
|
+
target: 'ts#rdb'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
source: 'ts#smithy-api',
|
|
34
|
+
target: 'ts#rdb'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
source: 'ts#smithy-api',
|
|
38
|
+
target: 'ts#dynamodb'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
source: 'ts#mcp-server',
|
|
42
|
+
target: 'ts#rdb'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
source: 'ts#mcp-server',
|
|
46
|
+
target: 'ts#dynamodb'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
source: 'ts#react-website',
|
|
50
|
+
target: 'ts#trpc-api'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
source: 'ts#react-website',
|
|
54
|
+
target: 'py#fast-api'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
source: 'ts#react-website',
|
|
58
|
+
target: 'ts#smithy-api'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
source: 'ts#react-website',
|
|
62
|
+
target: 'ts#agent'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
source: 'ts#react-website',
|
|
66
|
+
target: 'py#agent'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
source: 'ts#agent',
|
|
70
|
+
target: 'ts#mcp-server'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
source: 'ts#agent',
|
|
74
|
+
target: 'py#mcp-server'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
source: 'ts#agent',
|
|
78
|
+
target: 'ts#dynamodb'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
source: 'py#agent',
|
|
82
|
+
target: 'ts#mcp-server'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
source: 'py#agent',
|
|
86
|
+
target: 'py#mcp-server'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
source: 'ts#agent',
|
|
90
|
+
target: 'ts#agent'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
source: 'ts#agent',
|
|
94
|
+
target: 'py#agent'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
source: 'py#agent',
|
|
98
|
+
target: 'ts#agent'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
source: 'py#agent',
|
|
102
|
+
target: 'py#agent'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
source: 'ts#agent',
|
|
106
|
+
target: 'agentcore-gateway'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
source: 'py#agent',
|
|
110
|
+
target: 'agentcore-gateway'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
source: 'agentcore-gateway',
|
|
114
|
+
target: 'ts#mcp-server'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
source: 'agentcore-gateway',
|
|
118
|
+
target: 'py#mcp-server'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
source: 'agentcore-gateway',
|
|
122
|
+
target: 'agentcore-gateway'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
source: 'py#fast-api',
|
|
126
|
+
target: 'py#dynamodb'
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
source: 'py#agent',
|
|
130
|
+
target: 'py#dynamodb'
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
source: 'py#mcp-server',
|
|
134
|
+
target: 'py#dynamodb'
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=supported-connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/connection/supported-connections.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport type Connection = { source: string; target: string };\n\n// Supported source/target project types: either project-level types (resolved\n// by introspection) or component generator ids (from component metadata).\nexport const SUPPORTED_PROJECT_TYPES = [\n 'ts#trpc-api',\n 'py#fast-api',\n 'ts#react-website',\n 'ts#smithy-api',\n 'ts#rdb',\n 'ts#dynamodb',\n 'py#dynamodb',\n 'agentcore-gateway',\n] as const;\n\n// The single source of truth for supported connections, in a dependency-free\n// module so the e2e connection matrix can import it without pulling in the\n// generator implementation graph.\nexport const SUPPORTED_CONNECTIONS = [\n { source: 'ts#trpc-api', target: 'ts#rdb' },\n { source: 'ts#trpc-api', target: 'ts#dynamodb' },\n { source: 'ts#agent', target: 'ts#rdb' },\n { source: 'ts#smithy-api', target: 'ts#rdb' },\n { source: 'ts#smithy-api', target: 'ts#dynamodb' },\n { source: 'ts#mcp-server', target: 'ts#rdb' },\n { source: 'ts#mcp-server', target: 'ts#dynamodb' },\n { source: 'ts#react-website', target: 'ts#trpc-api' },\n { source: 'ts#react-website', target: 'py#fast-api' },\n { source: 'ts#react-website', target: 'ts#smithy-api' },\n { source: 'ts#react-website', target: 'ts#agent' },\n { source: 'ts#react-website', target: 'py#agent' },\n { source: 'ts#agent', target: 'ts#mcp-server' },\n { source: 'ts#agent', target: 'py#mcp-server' },\n { source: 'ts#agent', target: 'ts#dynamodb' },\n { source: 'py#agent', target: 'ts#mcp-server' },\n { source: 'py#agent', target: 'py#mcp-server' },\n { source: 'ts#agent', target: 'ts#agent' },\n { source: 'ts#agent', target: 'py#agent' },\n { source: 'py#agent', target: 'ts#agent' },\n { source: 'py#agent', target: 'py#agent' },\n { source: 'ts#agent', target: 'agentcore-gateway' },\n { source: 'py#agent', target: 'agentcore-gateway' },\n { source: 'agentcore-gateway', target: 'ts#mcp-server' },\n { source: 'agentcore-gateway', target: 'py#mcp-server' },\n { source: 'agentcore-gateway', target: 'agentcore-gateway' },\n { source: 'py#fast-api', target: 'py#dynamodb' },\n { source: 'py#agent', target: 'py#dynamodb' },\n { source: 'py#mcp-server', target: 'py#dynamodb' },\n] as const satisfies readonly Connection[];\n\n// `<source> -> <target>` string union of every supported connection. Used to\n// key exhaustive maps so a new connection is a compile error until handled.\nexport type ConnectionKey =\n (typeof SUPPORTED_CONNECTIONS)[number] extends infer C\n ? C extends Connection\n ? `${C['source']} -> ${C['target']}`\n : never\n : never;\n"],"names":["SUPPORTED_PROJECT_TYPES","SUPPORTED_CONNECTIONS","source","target"],"mappings":"AAAA;;;CAGC,GAID,8EAA8E;AAC9E,0EAA0E;AAC1E,OAAO,MAAMA,0BAA0B;IACrC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AAEX,6EAA6E;AAC7E,2EAA2E;AAC3E,kCAAkC;AAClC,OAAO,MAAMC,wBAAwB;IACnC;QAAEC,QAAQ;QAAeC,QAAQ;IAAS;IAC1C;QAAED,QAAQ;QAAeC,QAAQ;IAAc;IAC/C;QAAED,QAAQ;QAAYC,QAAQ;IAAS;IACvC;QAAED,QAAQ;QAAiBC,QAAQ;IAAS;IAC5C;QAAED,QAAQ;QAAiBC,QAAQ;IAAc;IACjD;QAAED,QAAQ;QAAiBC,QAAQ;IAAS;IAC5C;QAAED,QAAQ;QAAiBC,QAAQ;IAAc;IACjD;QAAED,QAAQ;QAAoBC,QAAQ;IAAc;IACpD;QAAED,QAAQ;QAAoBC,QAAQ;IAAc;IACpD;QAAED,QAAQ;QAAoBC,QAAQ;IAAgB;IACtD;QAAED,QAAQ;QAAoBC,QAAQ;IAAW;IACjD;QAAED,QAAQ;QAAoBC,QAAQ;IAAW;IACjD;QAAED,QAAQ;QAAYC,QAAQ;IAAgB;IAC9C;QAAED,QAAQ;QAAYC,QAAQ;IAAgB;IAC9C;QAAED,QAAQ;QAAYC,QAAQ;IAAc;IAC5C;QAAED,QAAQ;QAAYC,QAAQ;IAAgB;IAC9C;QAAED,QAAQ;QAAYC,QAAQ;IAAgB;IAC9C;QAAED,QAAQ;QAAYC,QAAQ;IAAW;IACzC;QAAED,QAAQ;QAAYC,QAAQ;IAAW;IACzC;QAAED,QAAQ;QAAYC,QAAQ;IAAW;IACzC;QAAED,QAAQ;QAAYC,QAAQ;IAAW;IACzC;QAAED,QAAQ;QAAYC,QAAQ;IAAoB;IAClD;QAAED,QAAQ;QAAYC,QAAQ;IAAoB;IAClD;QAAED,QAAQ;QAAqBC,QAAQ;IAAgB;IACvD;QAAED,QAAQ;QAAqBC,QAAQ;IAAgB;IACvD;QAAED,QAAQ;QAAqBC,QAAQ;IAAoB;IAC3D;QAAED,QAAQ;QAAeC,QAAQ;IAAc;IAC/C;QAAED,QAAQ;QAAYC,QAAQ;IAAc;IAC5C;QAAED,QAAQ;QAAiBC,QAAQ;IAAc;CAClD,CAA0C"}
|
|
@@ -68,7 +68,7 @@ const ensureDatabaseUser = async (dbUser: string): Promise<void> => {
|
|
|
68
68
|
[
|
|
69
69
|
\`CREATE USER IF NOT EXISTS \${quotedUser}@\${quotedHost} IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS'\`,
|
|
70
70
|
\`ALTER USER \${quotedUser}@\${quotedHost} IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS' REQUIRE SSL\`,
|
|
71
|
-
\`GRANT
|
|
71
|
+
\`GRANT SELECT, INSERT, UPDATE, DELETE ON \${quotedDbName}.* TO \${quotedUser}@\${quotedHost}\`,
|
|
72
72
|
].join(';\\n'),
|
|
73
73
|
);
|
|
74
74
|
} finally {
|
|
@@ -706,32 +706,19 @@ export abstract class AuroraDatabase extends Construct {
|
|
|
706
706
|
timeout: Duration.minutes(5),
|
|
707
707
|
tracing: Tracing.ACTIVE,
|
|
708
708
|
vpc,
|
|
709
|
-
environment:
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
|
|
713
|
-
}
|
|
714
|
-
: {
|
|
715
|
-
HOSTNAME: databaseHostname,
|
|
716
|
-
DATABASE: databaseName,
|
|
717
|
-
PORT: databasePort.toString(),
|
|
718
|
-
DBUSER: this.dbUser,
|
|
719
|
-
},
|
|
709
|
+
environment: {
|
|
710
|
+
DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
|
|
711
|
+
},
|
|
720
712
|
architecture: Architecture.ARM_64,
|
|
721
713
|
});
|
|
722
714
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
this.grantSecretRead(migrationHandler);
|
|
726
|
-
} else {
|
|
727
|
-
this.allowDefaultPortFrom(migrationHandler);
|
|
728
|
-
this.grantConnect(migrationHandler);
|
|
729
|
-
}
|
|
715
|
+
this.cluster.connections.allowDefaultPortFrom(migrationHandler);
|
|
716
|
+
this.grantSecretRead(migrationHandler);
|
|
730
717
|
|
|
731
|
-
const
|
|
718
|
+
const migrationTrigger = new Trigger(this, 'MigrationTrigger', {
|
|
732
719
|
handler: migrationHandler,
|
|
733
720
|
});
|
|
734
|
-
|
|
721
|
+
migrationTrigger.node.addDependency(createDbUserResource);
|
|
735
722
|
|
|
736
723
|
new CfnOutput(this, 'ClusterEndpoint', {
|
|
737
724
|
value: this.cluster.clusterEndpoint.hostname,
|
|
@@ -1909,11 +1896,16 @@ resource "aws_iam_role_policy" "migration_handler_access" {
|
|
|
1909
1896
|
{
|
|
1910
1897
|
Effect = "Allow"
|
|
1911
1898
|
Action = [
|
|
1912
|
-
"
|
|
1899
|
+
"secretsmanager:GetSecretValue"
|
|
1913
1900
|
]
|
|
1914
|
-
Resource = [
|
|
1915
|
-
|
|
1901
|
+
Resource = [module.aurora.secret_arn]
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
Effect = "Allow"
|
|
1905
|
+
Action = [
|
|
1906
|
+
"kms:Decrypt"
|
|
1916
1907
|
]
|
|
1908
|
+
Resource = [module.aurora.kms_key_arn]
|
|
1917
1909
|
}
|
|
1918
1910
|
]
|
|
1919
1911
|
})
|
|
@@ -2002,7 +1994,7 @@ resource "aws_security_group" "migration_handler" {
|
|
|
2002
1994
|
|
|
2003
1995
|
resource "aws_vpc_security_group_egress_rule" "migration_handler_to_database" {
|
|
2004
1996
|
security_group_id = aws_security_group.migration_handler.id
|
|
2005
|
-
referenced_security_group_id = module.aurora.
|
|
1997
|
+
referenced_security_group_id = module.aurora.database_security_group_id
|
|
2006
1998
|
from_port = module.aurora.cluster_port
|
|
2007
1999
|
to_port = module.aurora.cluster_port
|
|
2008
2000
|
ip_protocol = "tcp"
|
|
@@ -2044,7 +2036,7 @@ resource "aws_vpc_security_group_egress_rule" "create_db_user_https" {
|
|
|
2044
2036
|
}
|
|
2045
2037
|
|
|
2046
2038
|
resource "aws_vpc_security_group_ingress_rule" "migration_handler_to_database" {
|
|
2047
|
-
security_group_id = module.aurora.
|
|
2039
|
+
security_group_id = module.aurora.database_security_group_id
|
|
2048
2040
|
referenced_security_group_id = aws_security_group.migration_handler.id
|
|
2049
2041
|
from_port = module.aurora.cluster_port
|
|
2050
2042
|
to_port = module.aurora.cluster_port
|
|
@@ -2165,10 +2157,7 @@ resource "aws_lambda_function" "migration_handler" {
|
|
|
2165
2157
|
|
|
2166
2158
|
environment {
|
|
2167
2159
|
variables = {
|
|
2168
|
-
|
|
2169
|
-
DATABASE = module.aurora.database_name
|
|
2170
|
-
PORT = tostring(module.aurora.cluster_port)
|
|
2171
|
-
DBUSER = local.database_runtime_user
|
|
2160
|
+
DATABASE_SECRET_ARN = module.aurora.secret_arn
|
|
2172
2161
|
}
|
|
2173
2162
|
}
|
|
2174
2163
|
|
|
@@ -3841,14 +3830,12 @@ const ensureDatabaseUser = async (dbUser: string): Promise<void> => {
|
|
|
3841
3830
|
|
|
3842
3831
|
await client.query(
|
|
3843
3832
|
\`ALTER ROLE \${quotedDbUser} WITH LOGIN;
|
|
3844
|
-
GRANT
|
|
3845
|
-
GRANT USAGE
|
|
3846
|
-
GRANT
|
|
3847
|
-
GRANT
|
|
3848
|
-
|
|
3849
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT
|
|
3850
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO \${quotedDbUser};
|
|
3851
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON FUNCTIONS TO \${quotedDbUser};
|
|
3833
|
+
GRANT CONNECT ON DATABASE \${quotedDbName} TO \${quotedDbUser};
|
|
3834
|
+
GRANT USAGE ON SCHEMA public TO \${quotedDbUser};
|
|
3835
|
+
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO \${quotedDbUser};
|
|
3836
|
+
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO \${quotedDbUser};
|
|
3837
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO \${quotedDbUser};
|
|
3838
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO \${quotedDbUser};
|
|
3852
3839
|
GRANT rds_iam TO \${quotedDbUser};\`,
|
|
3853
3840
|
);
|
|
3854
3841
|
|
|
@@ -3890,28 +3877,16 @@ exports[`ts#rdb generator > should generate the aurora shared construct > packag
|
|
|
3890
3877
|
exports[`ts#rdb generator > should generate the aurora shared construct > packages/db/src/migration-handler.ts 1`] = `
|
|
3891
3878
|
"import { execFile } from 'node:child_process';
|
|
3892
3879
|
import { promisify } from 'node:util';
|
|
3893
|
-
import {
|
|
3894
|
-
import { withConnectionRetry } from './utils.js';
|
|
3880
|
+
import { getDatabaseSecret, withConnectionRetry } from './utils.js';
|
|
3895
3881
|
|
|
3896
3882
|
const buildDatabaseUrl = async (): Promise<string> => {
|
|
3897
|
-
const
|
|
3898
|
-
const port = process.env.PORT!;
|
|
3899
|
-
const database = process.env.DATABASE!;
|
|
3900
|
-
const dbUser = process.env.DBUSER!;
|
|
3901
|
-
const region = process.env.AWS_REGION!;
|
|
3902
|
-
|
|
3903
|
-
const iamAuthToken = await new Signer({
|
|
3904
|
-
hostname,
|
|
3905
|
-
port: Number(port),
|
|
3906
|
-
region,
|
|
3907
|
-
username: dbUser,
|
|
3908
|
-
}).getAuthToken();
|
|
3883
|
+
const { host, port, dbname, username, password } = await getDatabaseSecret();
|
|
3909
3884
|
|
|
3910
3885
|
return (
|
|
3911
|
-
\`postgresql://\${encodeURIComponent(
|
|
3912
|
-
\`:\${encodeURIComponent(
|
|
3913
|
-
\`@\${
|
|
3914
|
-
\`?sslaccept=strict\`
|
|
3886
|
+
\`postgresql://\${encodeURIComponent(username)}\` +
|
|
3887
|
+
\`:\${encodeURIComponent(password)}\` +
|
|
3888
|
+
\`@\${host}:\${port}/\${dbname}\` +
|
|
3889
|
+
\`?sslaccept=strict\`
|
|
3915
3890
|
);
|
|
3916
3891
|
};
|
|
3917
3892
|
|
|
@@ -4515,32 +4490,19 @@ export abstract class AuroraDatabase extends Construct {
|
|
|
4515
4490
|
timeout: Duration.minutes(5),
|
|
4516
4491
|
tracing: Tracing.ACTIVE,
|
|
4517
4492
|
vpc,
|
|
4518
|
-
environment:
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
|
|
4522
|
-
}
|
|
4523
|
-
: {
|
|
4524
|
-
HOSTNAME: databaseHostname,
|
|
4525
|
-
DATABASE: databaseName,
|
|
4526
|
-
PORT: databasePort.toString(),
|
|
4527
|
-
DBUSER: this.dbUser,
|
|
4528
|
-
},
|
|
4493
|
+
environment: {
|
|
4494
|
+
DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
|
|
4495
|
+
},
|
|
4529
4496
|
architecture: Architecture.ARM_64,
|
|
4530
4497
|
});
|
|
4531
4498
|
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
this.grantSecretRead(migrationHandler);
|
|
4535
|
-
} else {
|
|
4536
|
-
this.allowDefaultPortFrom(migrationHandler);
|
|
4537
|
-
this.grantConnect(migrationHandler);
|
|
4538
|
-
}
|
|
4499
|
+
this.cluster.connections.allowDefaultPortFrom(migrationHandler);
|
|
4500
|
+
this.grantSecretRead(migrationHandler);
|
|
4539
4501
|
|
|
4540
|
-
const
|
|
4502
|
+
const migrationTrigger = new Trigger(this, 'MigrationTrigger', {
|
|
4541
4503
|
handler: migrationHandler,
|
|
4542
4504
|
});
|
|
4543
|
-
|
|
4505
|
+
migrationTrigger.node.addDependency(createDbUserResource);
|
|
4544
4506
|
|
|
4545
4507
|
new CfnOutput(this, 'ClusterEndpoint', {
|
|
4546
4508
|
value: this.cluster.clusterEndpoint.hostname,
|
|
@@ -49,7 +49,7 @@ const ensureDatabaseUser = async (dbUser: string): Promise<void> => {
|
|
|
49
49
|
[
|
|
50
50
|
`CREATE USER IF NOT EXISTS ${quotedUser}@${quotedHost} IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS'`,
|
|
51
51
|
`ALTER USER ${quotedUser}@${quotedHost} IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS' REQUIRE SSL`,
|
|
52
|
-
`GRANT
|
|
52
|
+
`GRANT SELECT, INSERT, UPDATE, DELETE ON ${quotedDbName}.* TO ${quotedUser}@${quotedHost}`,
|
|
53
53
|
].join(';\n'),
|
|
54
54
|
);
|
|
55
55
|
} finally {
|
|
@@ -87,14 +87,12 @@ const ensureDatabaseUser = async (dbUser: string): Promise<void> => {
|
|
|
87
87
|
|
|
88
88
|
await client.query(
|
|
89
89
|
`ALTER ROLE ${quotedDbUser} WITH LOGIN;
|
|
90
|
-
GRANT
|
|
91
|
-
GRANT USAGE
|
|
92
|
-
GRANT
|
|
93
|
-
GRANT
|
|
94
|
-
|
|
95
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT
|
|
96
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO ${quotedDbUser};
|
|
97
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON FUNCTIONS TO ${quotedDbUser};
|
|
90
|
+
GRANT CONNECT ON DATABASE ${quotedDbName} TO ${quotedDbUser};
|
|
91
|
+
GRANT USAGE ON SCHEMA public TO ${quotedDbUser};
|
|
92
|
+
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO ${quotedDbUser};
|
|
93
|
+
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO ${quotedDbUser};
|
|
94
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO ${quotedDbUser};
|
|
95
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO ${quotedDbUser};
|
|
98
96
|
GRANT rds_iam TO ${quotedDbUser};`,
|
|
99
97
|
);
|
|
100
98
|
|
|
@@ -1,43 +1,16 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
-
<%_ if (engine === 'mysql') { _%>
|
|
4
3
|
import { getDatabaseSecret, withConnectionRetry } from './utils.js';
|
|
5
|
-
<%_ } else { _%>
|
|
6
|
-
import { Signer } from '@aws-sdk/rds-signer';
|
|
7
|
-
import { withConnectionRetry } from './utils.js';
|
|
8
|
-
<%_ } _%>
|
|
9
4
|
|
|
10
5
|
const buildDatabaseUrl = async (): Promise<string> => {
|
|
11
|
-
<%_ if (engine === 'mysql') { _%>
|
|
12
6
|
const { host, port, dbname, username, password } = await getDatabaseSecret();
|
|
13
7
|
|
|
14
8
|
return (
|
|
15
|
-
|
|
9
|
+
`<%= engine === 'mysql' ? 'mysql' : 'postgresql' %>://${encodeURIComponent(username)}` +
|
|
16
10
|
`:${encodeURIComponent(password)}` +
|
|
17
11
|
`@${host}:${port}/${dbname}` +
|
|
18
12
|
`?sslaccept=strict`
|
|
19
13
|
);
|
|
20
|
-
<%_ } else { _%>
|
|
21
|
-
const hostname = process.env.HOSTNAME!;
|
|
22
|
-
const port = process.env.PORT!;
|
|
23
|
-
const database = process.env.DATABASE!;
|
|
24
|
-
const dbUser = process.env.DBUSER!;
|
|
25
|
-
const region = process.env.AWS_REGION!;
|
|
26
|
-
|
|
27
|
-
const iamAuthToken = await new Signer({
|
|
28
|
-
hostname,
|
|
29
|
-
port: Number(port),
|
|
30
|
-
region,
|
|
31
|
-
username: dbUser,
|
|
32
|
-
}).getAuthToken();
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
`postgresql://${encodeURIComponent(dbUser)}` +
|
|
36
|
-
`:${encodeURIComponent(iamAuthToken)}` +
|
|
37
|
-
`@${hostname}:${port}/${database}` +
|
|
38
|
-
`?sslaccept=strict` // `sslaccept` is the correct parameter here for postgresql. The Prisma CLI Rust engine does not use the standard libpq `sslmode` option.
|
|
39
|
-
);
|
|
40
|
-
<%_ } _%>
|
|
41
14
|
};
|
|
42
15
|
|
|
43
16
|
export const handler = async () => {
|
package/src/ts/rdb/generator.js
CHANGED
|
@@ -85,7 +85,7 @@ export const tsRdbGenerator = async (tree, options)=>{
|
|
|
85
85
|
...patterns,
|
|
86
86
|
'generated/prisma'
|
|
87
87
|
]);
|
|
88
|
-
await sharedRdbScriptsGenerator(tree, options.engine
|
|
88
|
+
await sharedRdbScriptsGenerator(tree, options.engine);
|
|
89
89
|
const waitForDbScript = options.engine === 'mysql' ? 'wait-for-mysql-db.ts' : 'wait-for-postgres-db.ts';
|
|
90
90
|
const scriptsDir = relative(dir, joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'));
|
|
91
91
|
const relativePathToRoot = getRelativePathToRootByDirectory(projectConfig.root);
|
|
@@ -207,7 +207,7 @@ export const tsRdbGenerator = async (tree, options)=>{
|
|
|
207
207
|
databasePackageAlias: toScopeAlias(fullyQualifiedName),
|
|
208
208
|
databaseName,
|
|
209
209
|
adminUser: databaseUser,
|
|
210
|
-
engine: options.engine
|
|
210
|
+
engine: options.engine,
|
|
211
211
|
migrationBundleDir,
|
|
212
212
|
createDbUserBundleDir: joinPathFragments('dist', projectConfig.root, 'bundle', 'create-db-user'),
|
|
213
213
|
dockerImageTag,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n addDependenciesToPackageJson,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names';\nimport { getNpmScope, toScopeAlias } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedRdbScriptsGenerator } from '../../utils/shared-rdb-scripts';\nimport { TS_VERSIONS, withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsRdbGeneratorSchema } from './schema';\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: toScopeAlias(fullyQualifiedName),\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(\n tree,\n options.engine === 'mysql' ? 'mysql' : 'postgres',\n );\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const dockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n });\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n });\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cp(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cp(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cp(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${dockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_RDB_GENERATOR_INFO, {\n engine: options.engine,\n });\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: toScopeAlias(fullyQualifiedName),\n databaseName,\n adminUser: databaseUser,\n engine: options.engine === 'mysql' ? 'mysql' : 'postgres',\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n dockerImageTag,\n containerEngine,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n '@aws-sdk/client-secrets-manager',\n '@aws-sdk/rds-signer',\n '@prisma/client',\n ...(options.engine === 'mysql'\n ? (['@prisma/adapter-mariadb', 'mariadb'] as const)\n : (['@prisma/adapter-pg', 'pg'] as const)),\n ]),\n withVersions([\n 'prisma',\n 'tsx',\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n );\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","addDependenciesToPackageJson","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","snakeCase","toClassName","getNpmScope","toScopeAlias","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedRdbScriptsGenerator","TS_VERSIONS","withVersions","tsProjectGenerator","getTsLibDetails","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","name","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","engine","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","patterns","waitForDbScript","scriptsDir","relativePathToRoot","root","fs","migrationBundleDir","dockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","projectName","projectRoot","adminUser","createDbUserBundleDir","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,4BAA4B,EAE5BC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,EAAEC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AG;QAC9C,MAAMzE,0BAA0BW,MAAM;YAAE8D;QAAI;QAC5C,MAAM1E,YAAYY,MAAM;YACtB8D;YACAE,aAAaxD;YACbyD,aAAaxD;YACbL;YACAF;YACAwB,sBAAsB7C,aAAa2B;YACnCF;YACA4D,WAAW7D;YACXa,QAAQjB,QAAQiB,MAAM,KAAK,UAAU,UAAU;YAC/CsB;YACA2B,uBAAuBtG,kBACrB,QACAmD,cAAcsB,IAAI,EAClB,UACA;YAEFG;YACAlC;QACF;IACF;IAEA5C,6BACEqC,MACAN,aAAa;QACX;QACA;QACA;QACA;QACA;WACIO,QAAQiB,MAAM,KAAK,UAClB;YAAC;YAA2B;SAAU,GACtC;YAAC;YAAsB;SAAK;KAClC,GACDxB,aAAa;QACX;QACA;QACA;WACIO,QAAQiB,MAAM,KAAK,UAClB,EAAE,GACF;YAAC;SAAY;KACnB;IAGHhC,8BAA8Bc,MAAM;QAClC,mBAAmB;QACnB6B,QAAQ;IACV;IAEA,MAAMrD,gCAAgCwB,MAAM;QAACH;KAAsB;IAEnE,MAAM1B,qBAAqB6B;IAC3B,OAAO,IACLzB,oBAAoByB,MAAMC,QAAQY,yBAAyB,EAAE;YAC3DuD,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAerE,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n addDependenciesToPackageJson,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names';\nimport { getNpmScope, toScopeAlias } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedRdbScriptsGenerator } from '../../utils/shared-rdb-scripts';\nimport { TS_VERSIONS, withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsRdbGeneratorSchema } from './schema';\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: toScopeAlias(fullyQualifiedName),\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const dockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n });\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n });\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cp(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cp(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cp(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${dockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_RDB_GENERATOR_INFO, {\n engine: options.engine,\n });\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: toScopeAlias(fullyQualifiedName),\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n dockerImageTag,\n containerEngine,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n '@aws-sdk/client-secrets-manager',\n '@aws-sdk/rds-signer',\n '@prisma/client',\n ...(options.engine === 'mysql'\n ? (['@prisma/adapter-mariadb', 'mariadb'] as const)\n : (['@prisma/adapter-pg', 'pg'] as const)),\n ]),\n withVersions([\n 'prisma',\n 'tsx',\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n );\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","addDependenciesToPackageJson","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","snakeCase","toClassName","getNpmScope","toScopeAlias","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedRdbScriptsGenerator","TS_VERSIONS","withVersions","tsProjectGenerator","getTsLibDetails","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","name","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","engine","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","patterns","waitForDbScript","scriptsDir","relativePathToRoot","root","fs","migrationBundleDir","dockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","projectName","projectRoot","adminUser","createDbUserBundleDir","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,4BAA4B,EAE5BC,a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
CfnManagedLoginBranding,
|
|
104
|
-
CfnUserPoolDomain,
|
|
105
104
|
FeaturePlan,
|
|
105
|
+
ManagedLoginVersion,
|
|
106
106
|
Mfa,
|
|
107
107
|
OAuthScope,
|
|
108
108
|
StandardThreatProtectionMode,
|
|
109
109
|
UserPool,
|
|
110
110
|
UserPoolClient,
|
|
111
|
+
UserPoolDomain,
|
|
111
112
|
} from 'aws-cdk-lib/aws-cognito';
|
|
112
113
|
import {
|
|
113
114
|
CfnLoggingConfiguration,
|
|
@@ -141,7 +142,7 @@ export class UserIdentity extends Construct {
|
|
|
141
142
|
public readonly identityPool: IdentityPool;
|
|
142
143
|
public readonly userPool: UserPool;
|
|
143
144
|
public readonly userPoolClient: UserPoolClient;
|
|
144
|
-
public readonly userPoolDomain:
|
|
145
|
+
public readonly userPoolDomain: UserPoolDomain;
|
|
145
146
|
|
|
146
147
|
/** The WAFv2 Web ACL associated with the user pool, if WAF is enabled */
|
|
147
148
|
public readonly webAcl?: CfnWebACL;
|
|
@@ -321,10 +322,12 @@ export class UserIdentity extends Construct {
|
|
|
321
322
|
};
|
|
322
323
|
|
|
323
324
|
private createUserPoolDomain = (userPool: UserPool) =>
|
|
324
|
-
new
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
new UserPoolDomain(this, 'UserPoolDomain', {
|
|
326
|
+
userPool,
|
|
327
|
+
cognitoDomain: {
|
|
328
|
+
domainPrefix: \`test-\${Stack.of(this).account}\`,
|
|
329
|
+
},
|
|
330
|
+
managedLoginVersion: ManagedLoginVersion.NEWER_MANAGED_LOGIN,
|
|
328
331
|
});
|
|
329
332
|
|
|
330
333
|
private createUserPoolClient = (userPool: UserPool) => {
|
|
@@ -374,7 +377,7 @@ export class UserIdentity extends Construct {
|
|
|
374
377
|
private createManagedLoginBranding = (
|
|
375
378
|
userPool: UserPool,
|
|
376
379
|
userPoolClient: UserPoolClient,
|
|
377
|
-
userPoolDomain:
|
|
380
|
+
userPoolDomain: UserPoolDomain,
|
|
378
381
|
) => {
|
|
379
382
|
new CfnManagedLoginBranding(this, 'ManagedLoginBranding', {
|
|
380
383
|
userPoolId: userPool.userPoolId,
|
|
@@ -13,13 +13,14 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
AccountRecovery,
|
|
15
15
|
CfnManagedLoginBranding,
|
|
16
|
-
CfnUserPoolDomain,
|
|
17
16
|
FeaturePlan,
|
|
17
|
+
ManagedLoginVersion,
|
|
18
18
|
Mfa,
|
|
19
19
|
OAuthScope,
|
|
20
20
|
StandardThreatProtectionMode,
|
|
21
21
|
UserPool,
|
|
22
22
|
UserPoolClient,
|
|
23
|
+
UserPoolDomain,
|
|
23
24
|
} from 'aws-cdk-lib/aws-cognito';
|
|
24
25
|
import {
|
|
25
26
|
CfnLoggingConfiguration,
|
|
@@ -53,7 +54,7 @@ export class UserIdentity extends Construct {
|
|
|
53
54
|
public readonly identityPool: IdentityPool;
|
|
54
55
|
public readonly userPool: UserPool;
|
|
55
56
|
public readonly userPoolClient: UserPoolClient;
|
|
56
|
-
public readonly userPoolDomain:
|
|
57
|
+
public readonly userPoolDomain: UserPoolDomain;
|
|
57
58
|
|
|
58
59
|
/** The WAFv2 Web ACL associated with the user pool, if WAF is enabled */
|
|
59
60
|
public readonly webAcl?: CfnWebACL;
|
|
@@ -229,10 +230,12 @@ export class UserIdentity extends Construct {
|
|
|
229
230
|
};
|
|
230
231
|
|
|
231
232
|
private createUserPoolDomain = (userPool: UserPool) =>
|
|
232
|
-
new
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
new UserPoolDomain(this, 'UserPoolDomain', {
|
|
234
|
+
userPool,
|
|
235
|
+
cognitoDomain: {
|
|
236
|
+
domainPrefix: `<%= cognitoDomain %>-${Stack.of(this).account}`,
|
|
237
|
+
},
|
|
238
|
+
managedLoginVersion: ManagedLoginVersion.NEWER_MANAGED_LOGIN,
|
|
236
239
|
});
|
|
237
240
|
|
|
238
241
|
private createUserPoolClient = (userPool: UserPool) => {
|
|
@@ -282,7 +285,7 @@ export class UserIdentity extends Construct {
|
|
|
282
285
|
private createManagedLoginBranding = (
|
|
283
286
|
userPool: UserPool,
|
|
284
287
|
userPoolClient: UserPoolClient,
|
|
285
|
-
userPoolDomain:
|
|
288
|
+
userPoolDomain: UserPoolDomain
|
|
286
289
|
) => {
|
|
287
290
|
new CfnManagedLoginBranding(this, 'ManagedLoginBranding', {
|
|
288
291
|
userPoolId: userPool.userPoolId,
|
|
@@ -350,29 +350,19 @@ export abstract class AuroraDatabase extends Construct {
|
|
|
350
350
|
timeout: Duration.minutes(5),
|
|
351
351
|
tracing: Tracing.ACTIVE,
|
|
352
352
|
vpc,
|
|
353
|
-
environment:
|
|
353
|
+
environment: {
|
|
354
354
|
DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
|
|
355
|
-
} : {
|
|
356
|
-
HOSTNAME: databaseHostname,
|
|
357
|
-
DATABASE: databaseName,
|
|
358
|
-
PORT: databasePort.toString(),
|
|
359
|
-
DBUSER: this.dbUser,
|
|
360
355
|
},
|
|
361
356
|
architecture: Architecture.ARM_64,
|
|
362
357
|
});
|
|
363
358
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
this.grantSecretRead(migrationHandler);
|
|
367
|
-
} else {
|
|
368
|
-
this.allowDefaultPortFrom(migrationHandler);
|
|
369
|
-
this.grantConnect(migrationHandler);
|
|
370
|
-
}
|
|
359
|
+
this.cluster.connections.allowDefaultPortFrom(migrationHandler);
|
|
360
|
+
this.grantSecretRead(migrationHandler);
|
|
371
361
|
|
|
372
|
-
const
|
|
362
|
+
const migrationTrigger = new Trigger(this, 'MigrationTrigger', {
|
|
373
363
|
handler: migrationHandler,
|
|
374
364
|
});
|
|
375
|
-
|
|
365
|
+
migrationTrigger.node.addDependency(createDbUserResource);
|
|
376
366
|
|
|
377
367
|
new CfnOutput(this, 'ClusterEndpoint', {
|
|
378
368
|
value: this.cluster.clusterEndpoint.hostname,
|
|
@@ -347,7 +347,6 @@ resource "aws_iam_role_policy" "migration_handler_access" {
|
|
|
347
347
|
policy = jsonencode({
|
|
348
348
|
Version = "2012-10-17"
|
|
349
349
|
Statement = [
|
|
350
|
-
<%_ if (engine === 'mysql') { _%>
|
|
351
350
|
{
|
|
352
351
|
Effect = "Allow"
|
|
353
352
|
Action = [
|
|
@@ -362,17 +361,6 @@ resource "aws_iam_role_policy" "migration_handler_access" {
|
|
|
362
361
|
]
|
|
363
362
|
Resource = [module.aurora.kms_key_arn]
|
|
364
363
|
}
|
|
365
|
-
<%_ } else { _%>
|
|
366
|
-
{
|
|
367
|
-
Effect = "Allow"
|
|
368
|
-
Action = [
|
|
369
|
-
"rds-db:connect"
|
|
370
|
-
]
|
|
371
|
-
Resource = [
|
|
372
|
-
"arn:aws:rds-db:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:dbuser:${var.enable_rds_proxy ? module.aurora.proxy_resource_id : module.aurora.cluster_resource_id}/${local.database_runtime_user}"
|
|
373
|
-
]
|
|
374
|
-
}
|
|
375
|
-
<%_ } _%>
|
|
376
364
|
]
|
|
377
365
|
})
|
|
378
366
|
}
|
|
@@ -459,13 +447,8 @@ resource "aws_security_group" "migration_handler" {
|
|
|
459
447
|
}
|
|
460
448
|
|
|
461
449
|
resource "aws_vpc_security_group_egress_rule" "migration_handler_to_database" {
|
|
462
|
-
<%_ if (engine === 'mysql') { _%>
|
|
463
450
|
security_group_id = aws_security_group.migration_handler.id
|
|
464
451
|
referenced_security_group_id = module.aurora.database_security_group_id
|
|
465
|
-
<%_ } else { _%>
|
|
466
|
-
security_group_id = aws_security_group.migration_handler.id
|
|
467
|
-
referenced_security_group_id = module.aurora.security_group_id
|
|
468
|
-
<%_ } _%>
|
|
469
452
|
from_port = module.aurora.cluster_port
|
|
470
453
|
to_port = module.aurora.cluster_port
|
|
471
454
|
ip_protocol = "tcp"
|
|
@@ -507,11 +490,7 @@ resource "aws_vpc_security_group_egress_rule" "create_db_user_https" {
|
|
|
507
490
|
}
|
|
508
491
|
|
|
509
492
|
resource "aws_vpc_security_group_ingress_rule" "migration_handler_to_database" {
|
|
510
|
-
<%_ if (engine === 'mysql') { _%>
|
|
511
493
|
security_group_id = module.aurora.database_security_group_id
|
|
512
|
-
<%_ } else { _%>
|
|
513
|
-
security_group_id = module.aurora.security_group_id
|
|
514
|
-
<%_ } _%>
|
|
515
494
|
referenced_security_group_id = aws_security_group.migration_handler.id
|
|
516
495
|
from_port = module.aurora.cluster_port
|
|
517
496
|
to_port = module.aurora.cluster_port
|
|
@@ -632,14 +611,7 @@ resource "aws_lambda_function" "migration_handler" {
|
|
|
632
611
|
|
|
633
612
|
environment {
|
|
634
613
|
variables = {
|
|
635
|
-
<%_ if (engine === 'mysql') { _%>
|
|
636
614
|
DATABASE_SECRET_ARN = module.aurora.secret_arn
|
|
637
|
-
<%_ } else { _%>
|
|
638
|
-
HOSTNAME = module.aurora.cluster_endpoint
|
|
639
|
-
DATABASE = module.aurora.database_name
|
|
640
|
-
PORT = tostring(module.aurora.cluster_port)
|
|
641
|
-
DBUSER = local.database_runtime_user
|
|
642
|
-
<%_ } _%>
|
|
643
615
|
}
|
|
644
616
|
}
|
|
645
617
|
|