@aws/nx-plugin 1.0.0-rc.25 → 1.0.0-rc.26

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin",
3
- "version": "1.0.0-rc.25",
3
+ "version": "1.0.0-rc.26",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -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
- * List of supported source and target project types for connections.
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,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QAClE,OAAO;IACT;IAEA,MAAMK,gBAAgBtH,kBACpByD,qBAAqBuD,IAAI,EACzB;IAEF,IAAIxE,KAAK6E,MAAM,CAACC,gBAAgB;QAC9B,MAAMC,YAAYtF,SAASO,MAAM8E;QACjC,IAAI,AAAC,CAAA,AAACC,WAAmBC,SAASC,gBAAgB,EAAE,AAAD,EAAGC,QAAQ,CAAC,YAAY;YACzE,OAAO;QACT;IACF;IAEA,OAAO;AACT;AAEA,MAAMlB,cAAc,CAClBmB,OACAlE;IAEA,+DAA+D;IAC/D,OAAO;QACL5C,8BAA8B+G,EAAE;QAChC7G,6BAA6B6G,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,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C9B,MAAMC,YAAYrF,SAASI,MAAMgF;QACjC,IAAI,AAAC,CAAA,AAACC,WAAmBC,SAASC,gBAAgB,EAAE,AAAD,EAAGC,QAAQ,CAAC,YAAY;YACzE,OAAO;QACT;IACF;IAEA,OAAO;AACT;AAEA,MAAMlB,cAAc,CAClBmB,OACAlE;IAEA,+DAA+D;IAC/D,OAAO;QACL3C,8BAA8B8G,EAAE;QAChC5G,6BAA6B4G,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,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"}
@@ -101,13 +101,14 @@ import {
101
101
  import {
102
102
  AccountRecovery,
103
103
  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: CfnUserPoolDomain;
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 CfnUserPoolDomain(this, 'UserPoolDomain', {
325
- domain: \`test-\${Stack.of(this).account}\`,
326
- userPoolId: userPool.userPoolId,
327
- managedLoginVersion: 2,
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: CfnUserPoolDomain,
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: CfnUserPoolDomain;
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 CfnUserPoolDomain(this, 'UserPoolDomain', {
233
- domain: `<%= cognitoDomain %>-${Stack.of(this).account}`,
234
- userPoolId: userPool.userPoolId,
235
- managedLoginVersion: 2,
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: CfnUserPoolDomain
288
+ userPoolDomain: UserPoolDomain
286
289
  ) => {
287
290
  new CfnManagedLoginBranding(this, 'ManagedLoginBranding', {
288
291
  userPoolId: userPool.userPoolId,