@aws/nx-plugin 1.0.0-rc.53 → 1.0.0-rc.55
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/migrations.json +50 -0
- package/package.json +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.js +3 -1
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/generator.d.ts +49 -1
- package/src/agentcore-gateway/generator.js +55 -22
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.js +3 -1
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/infra/app/generator.d.ts +43 -0
- package/src/infra/app/generator.js +47 -18
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +13 -0
- package/src/init/generator.js +14 -3
- package/src/init/generator.js.map +1 -1
- package/src/migrations/latest/backfill-generator-metadata/migration.d.ts +96 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js +670 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js.map +1 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.d.ts +6 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js +94 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js.map +1 -0
- package/src/preset/generator.d.ts +13 -0
- package/src/preset/generator.js +12 -3
- package/src/preset/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/generator.d.ts +24 -0
- package/src/py/agent/a2a-connection/generator.js +49 -20
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +23 -0
- package/src/py/agent/gateway-connection/generator.js +45 -11
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/generator.d.ts +146 -1
- package/src/py/agent/generator.js +173 -76
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +23 -0
- package/src/py/agent/mcp-connection/generator.js +45 -11
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/generator.d.ts +146 -0
- package/src/py/agent/react-connection/generator.js +27 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/agent-connection/generator.js +7 -1
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/py/dynamodb/fast-api-connection/generator.js +3 -1
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/generator.d.ts +29 -0
- package/src/py/dynamodb/generator.js +32 -12
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/fast-api/generator.d.ts +63 -0
- package/src/py/fast-api/generator.js +58 -23
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +16 -1
- package/src/py/fast-api/react/generator.js +15 -3
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/lambda-function/generator.d.ts +21 -0
- package/src/py/lambda-function/generator.js +29 -10
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/mcp-server/generator.d.ts +60 -0
- package/src/py/mcp-server/generator.js +62 -25
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/project/generator.d.ts +13 -0
- package/src/py/project/generator.js +29 -10
- package/src/py/project/generator.js.map +1 -1
- package/src/py/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +19 -0
- package/src/py/rdb/agent-connection/generator.js +7 -1
- package/src/py/rdb/agent-connection/generator.js.map +1 -1
- package/src/py/rdb/fast-api-connection/__snapshots__/generator.spec.ts.snap +7 -0
- package/src/py/rdb/fast-api-connection/generator.js +3 -1
- package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +89 -0
- package/src/py/rdb/generator.js +88 -40
- package/src/py/rdb/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/rdb/mcp-server-connection/generator.js +7 -1
- package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/smithy/project/generator.d.ts +7 -0
- package/src/smithy/project/generator.js +8 -2
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +15 -0
- package/src/smithy/react-connection/generator.js +17 -3
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/smithy/ts/api/generator.d.ts +79 -0
- package/src/smithy/ts/api/generator.js +77 -33
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/generator.d.ts +50 -0
- package/src/terraform/project/generator.js +63 -17
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/generator.d.ts +84 -0
- package/src/trpc/backend/generator.js +98 -38
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/generator.d.ts +37 -0
- package/src/trpc/react/generator.js +63 -26
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +46 -0
- package/src/ts/agent/a2a-connection/generator.js +53 -16
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +37 -0
- package/src/ts/agent/gateway-connection/generator.js +41 -14
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.d.ts +162 -0
- package/src/ts/agent/generator.js +166 -75
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +37 -0
- package/src/ts/agent/mcp-connection/generator.js +41 -14
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +186 -0
- package/src/ts/agent/react-connection/generator.js +70 -21
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/astro-docs/generator.d.ts +38 -0
- package/src/ts/astro-docs/generator.js +58 -19
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +24 -0
- package/src/ts/dcr-proxy/generator.js +31 -14
- package/src/ts/dcr-proxy/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/agent-connection/generator.js +7 -1
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/generator.d.ts +41 -0
- package/src/ts/dynamodb/generator.js +47 -20
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/smithy-connection/generator.js +3 -1
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/trpc-connection/generator.js +3 -1
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/lambda-function/generator.d.ts +38 -0
- package/src/ts/lambda-function/generator.js +49 -20
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lib/generator.d.ts +7 -0
- package/src/ts/lib/generator.js +8 -1
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +3 -1
- package/src/ts/lib/ts-project-utils.js +3 -2
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +10 -1
- package/src/ts/lib/vitest.js +14 -2
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/generator.d.ts +71 -0
- package/src/ts/mcp-server/generator.js +73 -36
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/generator.d.ts +3 -0
- package/src/ts/nx-generator/generator.js +8 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-migration/generator.d.ts +3 -0
- package/src/ts/nx-migration/generator.js +8 -2
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/nx-plugin/generator.d.ts +3 -0
- package/src/ts/nx-plugin/generator.js +8 -2
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +7 -2
- package/src/ts/nx-plugin/utils.js +10 -4
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/agent-connection/generator.js +8 -1
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/generator.d.ts +101 -0
- package/src/ts/rdb/generator.js +93 -41
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/mcp-server-connection/generator.js +8 -1
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/smithy-connection/generator.js +4 -1
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/trpc-connection/generator.js +3 -1
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +86 -0
- package/src/ts/react-website/agui/generator.js +63 -28
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +20 -2
- package/src/ts/react-website/app/generator.d.ts +136 -1
- package/src/ts/react-website/app/generator.js +109 -40
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/generator.d.ts +19 -0
- package/src/ts/react-website/cognito-auth/generator.js +21 -9
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/utils/add-dependencies.d.ts +38 -0
- package/src/utils/add-dependencies.js +83 -0
- package/src/utils/add-dependencies.js.map +1 -0
- package/src/utils/agent-connection/agent-connection.d.ts +27 -6
- package/src/utils/agent-connection/agent-connection.js +47 -18
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +19 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js +26 -6
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/api-constructs/api-constructs.d.ts +21 -2
- package/src/utils/api-constructs/api-constructs.js +26 -5
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/bundle/bundle.d.ts +6 -1
- package/src/utils/bundle/bundle.js +8 -2
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.d.ts +5 -4
- package/src/utils/commands.js +2 -6
- package/src/utils/commands.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +18 -1
- package/src/utils/connection/open-api/react.js +27 -3
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/declared-dependencies.d.ts +140 -0
- package/src/utils/declared-dependencies.js +64 -0
- package/src/utils/declared-dependencies.js.map +1 -0
- package/src/utils/docker.d.ts +10 -1
- package/src/utils/docker.js +7 -3
- package/src/utils/docker.js.map +1 -1
- package/src/utils/fs.d.ts +15 -4
- package/src/utils/fs.js +26 -13
- package/src/utils/fs.js.map +1 -1
- package/src/utils/init.d.ts +14 -1
- package/src/utils/init.js +25 -7
- package/src/utils/init.js.map +1 -1
- package/src/utils/migration-versions.d.ts +15 -1
- package/src/utils/migration-versions.js +53 -7
- package/src/utils/migration-versions.js.map +1 -1
- package/src/utils/nx.d.ts +18 -0
- package/src/utils/nx.js +4 -0
- package/src/utils/nx.js.map +1 -1
- package/src/utils/py.d.ts +3 -2
- package/src/utils/py.js +10 -10
- package/src/utils/py.js.map +1 -1
- package/src/utils/shared-constructs-constants.d.ts +39 -4
- package/src/utils/shared-constructs-constants.js +29 -0
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +4 -1
- package/src/utils/shared-constructs.js +5 -4
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +8 -1
- package/src/utils/shared-dynamodb-scripts.js +11 -3
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-scripts.d.ts +16 -1
- package/src/utils/shared-infra-scripts.js +18 -3
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +12 -1
- package/src/utils/shared-rdb-scripts.js +17 -3
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +26 -1
- package/src/utils/shared-shadcn.js +31 -14
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/version-upgrade-migration/migration.d.ts +14 -0
- package/src/utils/version-upgrade-migration/migration.js +16 -0
- package/src/utils/version-upgrade-migration/migration.js.map +1 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.d.ts +35 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js +42 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +50 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js +98 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -0
- package/src/utils/version-upgrade-migration/register.d.ts +18 -0
- package/src/utils/version-upgrade-migration/register.js +33 -0
- package/src/utils/version-upgrade-migration/register.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.d.ts +13 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js +33 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.d.ts +10 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js +504 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.d.ts +14 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js +40 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js.map +1 -0
- package/src/utils/versions.d.ts +25 -5
- package/src/utils/versions.js +46 -4
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +4 -0
package/migrations.json
CHANGED
|
@@ -21,6 +21,56 @@
|
|
|
21
21
|
"version": "1.0.0-rc.52",
|
|
22
22
|
"description": "Count the EC2MetaDataSSRF_QUERYARGUMENTS WAF rule on the UserIdentity Web ACL so sign-in from a local dev server is not blocked",
|
|
23
23
|
"implementation": "./src/migrations/latest/user-identity-waf-allow-localhost-callback/migration"
|
|
24
|
+
},
|
|
25
|
+
"latest-order-access-log-delivery-after-bucket-policy": {
|
|
26
|
+
"version": "1.0.0-rc.54",
|
|
27
|
+
"description": "Order the S3 server access log delivery source after the bucket policy to avoid a 409 from concurrent bucket configuration writes",
|
|
28
|
+
"implementation": "./src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration"
|
|
29
|
+
},
|
|
30
|
+
"latest-backfill-generator-metadata": {
|
|
31
|
+
"version": "1.0.0-rc.55",
|
|
32
|
+
"description": "Backfill the project metadata the version sync reads, recovered from the files the generators left behind",
|
|
33
|
+
"implementation": "./src/migrations/latest/backfill-generator-metadata/migration"
|
|
34
|
+
},
|
|
35
|
+
"sync-vended-versions": {
|
|
36
|
+
"version": "1.0.0-rc.55",
|
|
37
|
+
"description": "Sync vended dependency versions and the tracked plugin version to those vended by this release",
|
|
38
|
+
"implementation": "./src/utils/version-upgrade-migration/migration"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"packageJsonUpdates": {
|
|
42
|
+
"v1.0.0-rc.55-nx-packages": {
|
|
43
|
+
"version": "1.0.0-rc.55",
|
|
44
|
+
"packages": {
|
|
45
|
+
"nx": {
|
|
46
|
+
"version": "23.1.0",
|
|
47
|
+
"alwaysAddToPackageJson": false
|
|
48
|
+
},
|
|
49
|
+
"@nx/devkit": {
|
|
50
|
+
"version": "23.1.0",
|
|
51
|
+
"alwaysAddToPackageJson": false
|
|
52
|
+
},
|
|
53
|
+
"@nx/js": {
|
|
54
|
+
"version": "23.1.0",
|
|
55
|
+
"alwaysAddToPackageJson": false
|
|
56
|
+
},
|
|
57
|
+
"@nx/react": {
|
|
58
|
+
"version": "23.1.0",
|
|
59
|
+
"alwaysAddToPackageJson": false
|
|
60
|
+
},
|
|
61
|
+
"@nx/vite": {
|
|
62
|
+
"version": "23.1.0",
|
|
63
|
+
"alwaysAddToPackageJson": false
|
|
64
|
+
},
|
|
65
|
+
"@nx/vitest": {
|
|
66
|
+
"version": "23.1.0",
|
|
67
|
+
"alwaysAddToPackageJson": false
|
|
68
|
+
},
|
|
69
|
+
"@nx/workspace": {
|
|
70
|
+
"version": "23.1.0",
|
|
71
|
+
"alwaysAddToPackageJson": false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
24
74
|
}
|
|
25
75
|
}
|
|
26
76
|
}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { installDependencies } from "../../utils/install.js";
|
|
6
6
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
7
7
|
import { kebabCase } from "../../utils/names.js";
|
|
8
|
-
import { getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
8
|
+
import { addComponentGeneratorMetadata, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
9
9
|
import { attachUpstreamToLocalGateway } from "../attach-upstream.js";
|
|
10
10
|
import { AGENTCORE_GATEWAY_GENERATOR_INFO, readAgentCoreGatewayMetadata } from "../generator.js";
|
|
11
11
|
export const AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
@@ -53,6 +53,8 @@ export const AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO = getGeneratorI
|
|
|
53
53
|
upstreamProjectName: targetProject.name,
|
|
54
54
|
upstreamDevTargetName: 'dev'
|
|
55
55
|
});
|
|
56
|
+
// Recorded so the version sync can identify this connection.
|
|
57
|
+
addComponentGeneratorMetadata(tree, sourceProject.name, AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO, targetProject.root, targetGatewayKebabCase);
|
|
56
58
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
57
59
|
AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO
|
|
58
60
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/agentcore-gateway/gateway-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { GeneratorCallback, Tree } from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase } from '../../utils/names';\nimport {\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { attachUpstreamToLocalGateway } from '../attach-upstream';\nimport {\n AGENTCORE_GATEWAY_GENERATOR_INFO,\n readAgentCoreGatewayMetadata,\n} from '../generator';\nimport type { AgentcoreGatewayGatewayConnectionGeneratorSchema } from './schema';\n\nexport const AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\n/**\n * Connect an AgentCore Gateway to another AgentCore Gateway.\n *\n * Chains the source gateway's dev target to the target gateway's\n * dev target, and registers the target gateway in the source\n * gateway's local local-dev.ts so the local gateway aggregates its tools\n * (already prefixed by the target gateway) under\n * `<targetGateway>___<targetName>___<toolName>`. Users must still call\n * `gateway.addGateway(...)` in their application stack to create the\n * actual CDK/Terraform resource.\n */\nexport const agentcoreGatewayGatewayConnectionGenerator = async (\n tree: Tree,\n options: AgentcoreGatewayGatewayConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const sourceGateway = readAgentCoreGatewayMetadata(sourceProject);\n const targetGateway = readAgentCoreGatewayMetadata(targetProject);\n\n if (sourceProject.name === targetProject.name) {\n throw new Error(\n `Cannot connect gateway '${sourceGateway.name}' to itself.`,\n );\n }\n\n for (const gateway of [sourceGateway, targetGateway]) {\n if (gateway.protocol !== 'mcp') {\n throw new Error(\n `Gateway '${gateway.name}' has protocol='${gateway.protocol}'. Gateway->Gateway connections are only supported between MCP-protocol gateways.`,\n );\n }\n }\n\n // The source gateway invokes the target signing with its own IAM role, so\n // only the target's inbound auth must be IAM. The source's inbound auth (how\n // its own callers reach it) is irrelevant to this hop.\n if (targetGateway.auth !== 'iam') {\n throw new Error(\n `Gateway '${targetGateway.name}' uses auth='${targetGateway.auth}'. Gateway->Gateway connections currently require the target gateway to use IAM authentication.`,\n );\n }\n\n assertNoCycle(tree, sourceProject.name, targetProject.name);\n\n // The target name must match the deployed Gateway target (`gatewayName` on\n // the gateway construct, the project's class name in kebab-case) so\n // `<targetGateway>___<target>___<tool>` resolves identically locally and\n // deployed.\n const targetGatewayKebabCase = kebabCase(targetGateway.rc);\n\n await attachUpstreamToLocalGateway(tree, sourceProject, 'dev', {\n targetName: targetGatewayKebabCase,\n port: targetGateway.port,\n upstreamProjectName: targetProject.name,\n upstreamDevTargetName: 'dev',\n });\n\n await addGeneratorMetricsIfApplicable(tree, [\n AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\n/**\n * Reject connections that would make the local gateway graph cyclic — a\n * cycle would recurse infinitely on tools/list both locally and deployed.\n *\n * Walks gateway dev dependsOn edges from the target gateway; the\n * source gateway must not be reachable.\n */\nconst assertNoCycle = (\n tree: Tree,\n sourceProjectName: string,\n targetProjectName: string,\n) => {\n const visited = new Set<string>();\n const stack = [targetProjectName];\n while (stack.length > 0) {\n const current = stack.pop();\n if (current === sourceProjectName) {\n throw new Error(\n `Connecting '${sourceProjectName}' to '${targetProjectName}' would create a cycle: '${targetProjectName}' already routes to '${sourceProjectName}'.`,\n );\n }\n if (visited.has(current)) {\n continue;\n }\n visited.add(current);\n const project = readProjectConfigurationUnqualified(tree, current);\n if (\n (project.metadata as any)?.generator !==\n AGENTCORE_GATEWAY_GENERATOR_INFO.id\n ) {\n continue;\n }\n readAgentCoreGatewayMetadata(project);\n const devTarget = project.targets?.['dev'];\n for (const dep of devTarget?.dependsOn ?? []) {\n if (typeof dep !== 'string') {\n stack.push(...(dep.projects ?? []));\n }\n }\n }\n};\n\nexport default agentcoreGatewayGatewayConnectionGenerator;\n"],"names":["formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","getGeneratorInfo","readProjectConfigurationUnqualified","attachUpstreamToLocalGateway","AGENTCORE_GATEWAY_GENERATOR_INFO","readAgentCoreGatewayMetadata","AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO","filename","agentcoreGatewayGatewayConnectionGenerator","tree","options","sourceProject","targetProject","sourceGateway","targetGateway","name","Error","gateway","protocol","auth","assertNoCycle","targetGatewayKebabCase","rc","targetName","port","upstreamProjectName","upstreamDevTargetName","preferInstallDependencies","languages","sourceProjectName","targetProjectName","visited","Set","stack","length","current","pop","has","add","project","metadata","generator","id","devTarget","targets","dep","dependsOn","push","projects"],"mappings":"AAAA;;;CAGC,GAED,SAASA,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SACEC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,4BAA4B,QAAQ,wBAAqB;AAClE,SACEC,gCAAgC,EAChCC,4BAA4B,QACvB,kBAAe;AAGtB,OAAO,MAAMC,sDACXL,iBAAiB,YAAYM,QAAQ,EAAE;AAEzC;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,6CAA6C,OACxDC,MACAC;IAEA,MAAMC,gBAAgBT,oCACpBO,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBV,oCACpBO,MACAC,QAAQE,aAAa;IAGvB,MAAMC,gBAAgBR,6BAA6BM;IACnD,MAAMG,gBAAgBT,6BAA6BO;IAEnD,IAAID,cAAcI,IAAI,KAAKH,cAAcG,IAAI,EAAE;QAC7C,MAAM,IAAIC,MACR,CAAC,wBAAwB,EAAEH,cAAcE,IAAI,CAAC,YAAY,CAAC;IAE/D;IAEA,KAAK,MAAME,WAAW;QAACJ;QAAeC;KAAc,CAAE;QACpD,IAAIG,QAAQC,QAAQ,KAAK,OAAO;YAC9B,MAAM,IAAIF,MACR,CAAC,SAAS,EAAEC,QAAQF,IAAI,CAAC,gBAAgB,EAAEE,QAAQC,QAAQ,CAAC,iFAAiF,CAAC;QAElJ;IACF;IAEA,0EAA0E;IAC1E,6EAA6E;IAC7E,uDAAuD;IACvD,IAAIJ,cAAcK,IAAI,KAAK,OAAO;QAChC,MAAM,IAAIH,MACR,CAAC,SAAS,EAAEF,cAAcC,IAAI,CAAC,aAAa,EAAED,cAAcK,IAAI,CAAC,+FAA+F,CAAC;IAErK;IAEAC,cAAcX,MAAME,cAAcI,IAAI,EAAEH,cAAcG,IAAI;IAE1D,2EAA2E;IAC3E,oEAAoE;IACpE,yEAAyE;IACzE,YAAY;IACZ,MAAMM,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/agentcore-gateway/gateway-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { GeneratorCallback, Tree } from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase } from '../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { attachUpstreamToLocalGateway } from '../attach-upstream';\nimport {\n AGENTCORE_GATEWAY_GENERATOR_INFO,\n readAgentCoreGatewayMetadata,\n} from '../generator';\nimport type { AgentcoreGatewayGatewayConnectionGeneratorSchema } from './schema';\n\nexport const AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\n/**\n * Connect an AgentCore Gateway to another AgentCore Gateway.\n *\n * Chains the source gateway's dev target to the target gateway's\n * dev target, and registers the target gateway in the source\n * gateway's local local-dev.ts so the local gateway aggregates its tools\n * (already prefixed by the target gateway) under\n * `<targetGateway>___<targetName>___<toolName>`. Users must still call\n * `gateway.addGateway(...)` in their application stack to create the\n * actual CDK/Terraform resource.\n */\nexport const agentcoreGatewayGatewayConnectionGenerator = async (\n tree: Tree,\n options: AgentcoreGatewayGatewayConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const sourceGateway = readAgentCoreGatewayMetadata(sourceProject);\n const targetGateway = readAgentCoreGatewayMetadata(targetProject);\n\n if (sourceProject.name === targetProject.name) {\n throw new Error(\n `Cannot connect gateway '${sourceGateway.name}' to itself.`,\n );\n }\n\n for (const gateway of [sourceGateway, targetGateway]) {\n if (gateway.protocol !== 'mcp') {\n throw new Error(\n `Gateway '${gateway.name}' has protocol='${gateway.protocol}'. Gateway->Gateway connections are only supported between MCP-protocol gateways.`,\n );\n }\n }\n\n // The source gateway invokes the target signing with its own IAM role, so\n // only the target's inbound auth must be IAM. The source's inbound auth (how\n // its own callers reach it) is irrelevant to this hop.\n if (targetGateway.auth !== 'iam') {\n throw new Error(\n `Gateway '${targetGateway.name}' uses auth='${targetGateway.auth}'. Gateway->Gateway connections currently require the target gateway to use IAM authentication.`,\n );\n }\n\n assertNoCycle(tree, sourceProject.name, targetProject.name);\n\n // The target name must match the deployed Gateway target (`gatewayName` on\n // the gateway construct, the project's class name in kebab-case) so\n // `<targetGateway>___<target>___<tool>` resolves identically locally and\n // deployed.\n const targetGatewayKebabCase = kebabCase(targetGateway.rc);\n\n await attachUpstreamToLocalGateway(tree, sourceProject, 'dev', {\n targetName: targetGatewayKebabCase,\n port: targetGateway.port,\n upstreamProjectName: targetProject.name,\n upstreamDevTargetName: 'dev',\n });\n\n // Recorded so the version sync can identify this connection.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO,\n targetProject.root,\n targetGatewayKebabCase,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\n/**\n * Reject connections that would make the local gateway graph cyclic — a\n * cycle would recurse infinitely on tools/list both locally and deployed.\n *\n * Walks gateway dev dependsOn edges from the target gateway; the\n * source gateway must not be reachable.\n */\nconst assertNoCycle = (\n tree: Tree,\n sourceProjectName: string,\n targetProjectName: string,\n) => {\n const visited = new Set<string>();\n const stack = [targetProjectName];\n while (stack.length > 0) {\n const current = stack.pop();\n if (current === sourceProjectName) {\n throw new Error(\n `Connecting '${sourceProjectName}' to '${targetProjectName}' would create a cycle: '${targetProjectName}' already routes to '${sourceProjectName}'.`,\n );\n }\n if (visited.has(current)) {\n continue;\n }\n visited.add(current);\n const project = readProjectConfigurationUnqualified(tree, current);\n if (\n (project.metadata as any)?.generator !==\n AGENTCORE_GATEWAY_GENERATOR_INFO.id\n ) {\n continue;\n }\n readAgentCoreGatewayMetadata(project);\n const devTarget = project.targets?.['dev'];\n for (const dep of devTarget?.dependsOn ?? []) {\n if (typeof dep !== 'string') {\n stack.push(...(dep.projects ?? []));\n }\n }\n }\n};\n\nexport default agentcoreGatewayGatewayConnectionGenerator;\n"],"names":["formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","attachUpstreamToLocalGateway","AGENTCORE_GATEWAY_GENERATOR_INFO","readAgentCoreGatewayMetadata","AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO","filename","agentcoreGatewayGatewayConnectionGenerator","tree","options","sourceProject","targetProject","sourceGateway","targetGateway","name","Error","gateway","protocol","auth","assertNoCycle","targetGatewayKebabCase","rc","targetName","port","upstreamProjectName","upstreamDevTargetName","root","preferInstallDependencies","languages","sourceProjectName","targetProjectName","visited","Set","stack","length","current","pop","has","add","project","metadata","generator","id","devTarget","targets","dep","dependsOn","push","projects"],"mappings":"AAAA;;;CAGC,GAED,SAASA,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,QA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ree } from '@nx/devkit';
|
|
6
6
|
import { type NxGeneratorInfo } from '../utils/nx';
|
|
7
|
+
import type { IacMetadata } from '../utils/shared-constructs-constants';
|
|
7
8
|
import type { AgentcoreGatewayGeneratorSchema } from './schema';
|
|
9
|
+
export declare const DEPENDENCIES: import("../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
10
|
+
readonly name: "@modelcontextprotocol/sdk";
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "express";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "@types/express";
|
|
15
|
+
readonly dev: true;
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "ejs";
|
|
18
|
+
readonly dev: true;
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "@types/ejs";
|
|
21
|
+
readonly dev: true;
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "tsx";
|
|
24
|
+
readonly dev: true;
|
|
25
|
+
readonly root: true;
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "ejs";
|
|
28
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
29
|
+
} & {
|
|
30
|
+
versionOnly: true;
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "@aws-sdk/client-bedrock-agentcore";
|
|
33
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
34
|
+
} & {
|
|
35
|
+
versionOnly: true;
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "@types/ejs";
|
|
38
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
39
|
+
} & {
|
|
40
|
+
versionOnly: true;
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "constructs";
|
|
43
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
44
|
+
} & {
|
|
45
|
+
versionOnly: true;
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "aws-cdk-lib";
|
|
48
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
49
|
+
} & {
|
|
50
|
+
versionOnly: true;
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "@types/node";
|
|
53
|
+
} & {
|
|
54
|
+
versionOnly: true;
|
|
55
|
+
}], readonly import("../utils/declared-dependencies").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "mcp" | "pip-check-updates" | "pip-licenses" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", AgentCoreGatewayMetadata>[]>;
|
|
8
56
|
export declare const AGENTCORE_GATEWAY_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
57
|
export declare const agentcoreGatewayGenerator: (tree: Tree, options: AgentcoreGatewayGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
58
|
/**
|
|
11
59
|
* Gateway details stored in the gateway project's metadata.
|
|
12
60
|
*/
|
|
13
|
-
export interface AgentCoreGatewayMetadata {
|
|
61
|
+
export interface AgentCoreGatewayMetadata extends IacMetadata {
|
|
14
62
|
name: string;
|
|
15
63
|
rc: string;
|
|
16
64
|
protocol: string;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/ import { addProjectConfiguration, generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { addTsDependencies } from "../utils/add-dependencies.js";
|
|
6
|
+
import { AGENT_CORE_CONSTRUCTS_DEPENDENCIES, addAgentCoreGatewayInfra } from "../utils/agent-core-constructs/agent-core-constructs.js";
|
|
7
|
+
import { declareDependencies, ownedElsewhere } from "../utils/declared-dependencies.js";
|
|
7
8
|
import { formatFilesInSubtree } from "../utils/format.js";
|
|
8
9
|
import { resolveIac } from "../utils/iac.js";
|
|
9
10
|
import { installDependencies } from "../utils/install.js";
|
|
@@ -13,8 +14,40 @@ import { getNpmScopePrefix } from "../utils/npm-scope.js";
|
|
|
13
14
|
import { addGeneratorMetadata, getGeneratorInfo, projectExists, readProjectConfigurationUnqualified } from "../utils/nx.js";
|
|
14
15
|
import { assignPort } from "../utils/port.js";
|
|
15
16
|
import { ensureProjectPackageJson } from "../utils/project-package-json.js";
|
|
16
|
-
import { sharedConstructsGenerator } from "../utils/shared-constructs.js";
|
|
17
|
-
|
|
17
|
+
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../utils/shared-constructs.js";
|
|
18
|
+
// The gateway's local-dev server and Cedar policy rendering need these whatever
|
|
19
|
+
// the protocol or auth, so no entry is conditional.
|
|
20
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
21
|
+
ts: [
|
|
22
|
+
{
|
|
23
|
+
name: '@modelcontextprotocol/sdk'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'express'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: '@types/express',
|
|
30
|
+
dev: true
|
|
31
|
+
},
|
|
32
|
+
// ejs renders the Cedar policy in the shared gateway construct.
|
|
33
|
+
{
|
|
34
|
+
name: 'ejs',
|
|
35
|
+
dev: true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: '@types/ejs',
|
|
39
|
+
dev: true
|
|
40
|
+
},
|
|
41
|
+
// local-dev.ts runs via tsx, which is shared tooling.
|
|
42
|
+
{
|
|
43
|
+
name: 'tsx',
|
|
44
|
+
dev: true,
|
|
45
|
+
root: true
|
|
46
|
+
},
|
|
47
|
+
...ownedElsewhere(AGENT_CORE_CONSTRUCTS_DEPENDENCIES),
|
|
48
|
+
...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES)
|
|
49
|
+
]
|
|
50
|
+
});
|
|
18
51
|
export const AGENTCORE_GATEWAY_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
19
52
|
export const agentcoreGatewayGenerator = async (tree, options)=>{
|
|
20
53
|
const name = kebabCase(options.name);
|
|
@@ -104,33 +137,33 @@ export const agentcoreGatewayGenerator = async (tree, options)=>{
|
|
|
104
137
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
105
138
|
});
|
|
106
139
|
}
|
|
107
|
-
|
|
140
|
+
// Recorded in the metadata below so the version sync can tell a CDK
|
|
141
|
+
// project from a Terraform one; undefined when no infrastructure was
|
|
142
|
+
// generated, in which case neither provider's packages were added.
|
|
143
|
+
const iac = infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;
|
|
144
|
+
// Recorded below and read by the declaration's predicates, so the packages
|
|
145
|
+
// added here are exactly the ones the version sync will own.
|
|
146
|
+
const metadata = {
|
|
108
147
|
name,
|
|
109
148
|
rc: nameClassName,
|
|
110
149
|
protocol,
|
|
111
150
|
auth,
|
|
112
|
-
port
|
|
151
|
+
port,
|
|
152
|
+
...iac ? {
|
|
153
|
+
iac
|
|
154
|
+
} : {}
|
|
155
|
+
};
|
|
156
|
+
addGeneratorMetadata(tree, fullyQualifiedName, AGENTCORE_GATEWAY_GENERATOR_INFO, metadata);
|
|
157
|
+
addTsDependencies(tree, DEPENDENCIES, {
|
|
158
|
+
metadata,
|
|
159
|
+
projectRoot
|
|
113
160
|
});
|
|
114
|
-
// local-dev.ts dependencies (+ ejs for Cedar policy rendering in the
|
|
115
|
-
// shared gateway construct)
|
|
116
|
-
addDependenciesToPackageJson(tree, withVersions([
|
|
117
|
-
'@modelcontextprotocol/sdk',
|
|
118
|
-
'express'
|
|
119
|
-
]), withVersions([
|
|
120
|
-
'@types/express',
|
|
121
|
-
'ejs',
|
|
122
|
-
'@types/ejs'
|
|
123
|
-
]), joinPathFragments(projectRoot, 'package.json'));
|
|
124
|
-
addDependenciesToPackageJson(tree, {}, withVersions([
|
|
125
|
-
'tsx'
|
|
126
|
-
]));
|
|
127
161
|
// Wire up infra (CDK or Terraform); re-running with infra=agentcore adds
|
|
128
162
|
// the infrastructure to a previously infra-less gateway.
|
|
129
163
|
if (infra === 'agentcore') {
|
|
130
|
-
const iac = await resolveIac(tree, options.iac);
|
|
131
164
|
await sharedConstructsGenerator(tree, {
|
|
132
165
|
iac
|
|
133
|
-
});
|
|
166
|
+
}, DEPENDENCIES);
|
|
134
167
|
await addAgentCoreGatewayInfra(tree, {
|
|
135
168
|
gatewayNameClassName: nameClassName,
|
|
136
169
|
gatewayNameKebabCase: name,
|
|
@@ -139,7 +172,7 @@ export const agentcoreGatewayGenerator = async (tree, options)=>{
|
|
|
139
172
|
cedarPolicy,
|
|
140
173
|
auth,
|
|
141
174
|
iac
|
|
142
|
-
});
|
|
175
|
+
}, DEPENDENCIES);
|
|
143
176
|
}
|
|
144
177
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
145
178
|
AGENTCORE_GATEWAY_GENERATOR_INFO
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/agentcore-gateway/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addAgentCoreGatewayInfra } from '../utils/agent-core-constructs/agent-core-constructs';\nimport { addDependenciesToPackageJson } from '../utils/dependencies';\nimport { formatFilesInSubtree } from '../utils/format';\nimport { resolveIac } from '../utils/iac';\nimport { installDependencies } from '../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../utils/metrics';\nimport { kebabCase, toClassName } from '../utils/names';\nimport { getNpmScopePrefix } from '../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n readProjectConfigurationUnqualified,\n} from '../utils/nx';\nimport { assignPort } from '../utils/port';\nimport { ensureProjectPackageJson } from '../utils/project-package-json';\nimport { sharedConstructsGenerator } from '../utils/shared-constructs';\nimport { withVersions } from '../utils/versions';\nimport type { AgentcoreGatewayGeneratorSchema } from './schema';\n\nexport const AGENTCORE_GATEWAY_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const agentcoreGatewayGenerator = async (\n tree: Tree,\n options: AgentcoreGatewayGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const name = kebabCase(options.name);\n const nameClassName = toClassName(name);\n const parentDir = options.directory ?? 'packages';\n const subDir = options.subDirectory ?? name;\n const projectRoot = joinPathFragments(parentDir, subDir);\n const fullyQualifiedName = `${getNpmScopePrefix(tree)}${name}`;\n\n // Protocol is fixed to mcp — the enum accepts only this value, but we still\n // persist the resolved value in metadata so connection generators can read\n // it uniformly (and future additions are non-breaking).\n const protocol = options.protocol ?? 'mcp';\n // Inbound auth is iam (default) or cognito. Persisted in metadata so\n // connection generators can validate it (agent -> gateway connections\n // require an IAM gateway).\n const auth = options.auth ?? 'iam';\n const cedarPolicy = options.cedarPolicy ?? true;\n const infra = options.infra ?? 'agentcore';\n\n // local-dev.ts is the local gateway: a continuous MCP aggregator chaining\n // onto attached MCP servers' dev targets (added by the mcp-connection\n // generator), so a single `nx dev <gateway>` boots the gateway and every\n // attached MCP server together.\n //\n // `serve` exists for parity with other generators; the deployed Gateway is\n // a managed AWS resource, so `serve`-mode agents talk to it via runtime\n // config and the local gateway sits idle.\n const localGatewayTarget = (port: number) => ({\n executor: 'nx:run-commands' as const,\n continuous: true,\n options: {\n command: 'tsx local-dev.ts',\n cwd: '{projectRoot}',\n env: { PORT: `${port}` },\n },\n dependsOn: [] as Array<string | { projects: string[]; target: string }>,\n });\n let project: ProjectConfiguration;\n if (projectExists(tree, fullyQualifiedName)) {\n project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n } else {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: projectRoot,\n projectType: 'library',\n sourceRoot: projectRoot,\n tags: [],\n targets: {},\n metadata: {\n generator: AGENTCORE_GATEWAY_GENERATOR_INFO.id,\n } as any,\n });\n project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n }\n // Ensure the project has its own package.json so its runtime dependencies\n // (added below) are declared in it rather than the workspace root.\n ensureProjectPackageJson(tree, {\n dir: projectRoot,\n fullyQualifiedName,\n });\n const port = assignPort(tree, project, 8100);\n // A gateway is its own standalone project, so it uses plain `serve` / `dev`\n // targets. Re-run: keep existing targets (their dependsOn may have been\n // populated by the mcp-connection generator), just ensure both exist.\n project.targets ??= {};\n project.targets['serve'] ??= localGatewayTarget(port);\n project.targets['dev'] ??= localGatewayTarget(port);\n updateProjectConfiguration(tree, project.name, project);\n\n // Scaffold the gateway project: local-dev.ts (+ Cedar policies if requested)\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'project'),\n projectRoot,\n { nameClassName, nameKebabCase: name, port, attachedMcpServers: [] },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n if (cedarPolicy) {\n // The default permit-all policy differs by auth type: AgentCore represents\n // IAM callers as `AgentCore::IamEntity` and Cognito/JWT callers as\n // `AgentCore::OAuthUser`, so the two policies match different principals.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cedar'),\n projectRoot,\n { nameClassName, auth },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n AGENTCORE_GATEWAY_GENERATOR_INFO,\n {\n name,\n rc: nameClassName,\n protocol,\n auth,\n port,\n },\n );\n\n // local-dev.ts dependencies (+ ejs for Cedar policy rendering in the\n // shared gateway construct)\n addDependenciesToPackageJson(\n tree,\n withVersions(['@modelcontextprotocol/sdk', 'express']),\n withVersions(['@types/express', 'ejs', '@types/ejs']),\n joinPathFragments(projectRoot, 'package.json'),\n );\n addDependenciesToPackageJson(tree, {}, withVersions(['tsx']));\n\n // Wire up infra (CDK or Terraform); re-running with infra=agentcore adds\n // the infrastructure to a previously infra-less gateway.\n if (infra === 'agentcore') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n\n await addAgentCoreGatewayInfra(tree, {\n gatewayNameClassName: nameClassName,\n gatewayNameKebabCase: name,\n projectName: fullyQualifiedName,\n projectDirectory: projectRoot,\n cedarPolicy,\n auth,\n iac,\n });\n }\n\n await addGeneratorMetricsIfApplicable(tree, [\n AGENTCORE_GATEWAY_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\n/**\n * Gateway details stored in the gateway project's metadata.\n */\nexport interface AgentCoreGatewayMetadata {\n name: string;\n rc: string;\n protocol: string;\n auth: string;\n port: number;\n}\n\n/**\n * Read a gateway project's metadata, validating it was generated by the\n * agentcore-gateway generator.\n */\nexport const readAgentCoreGatewayMetadata = (\n project: ProjectConfiguration,\n): AgentCoreGatewayMetadata => {\n const metadata = project.metadata as any;\n if (metadata?.generator !== AGENTCORE_GATEWAY_GENERATOR_INFO.id) {\n throw new Error(\n `Project '${project.name}' was not generated by the '${AGENTCORE_GATEWAY_GENERATOR_INFO.id}' generator.`,\n );\n }\n return metadata as AgentCoreGatewayMetadata;\n};\n\nexport default agentcoreGatewayGenerator;\n"],"names":["addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addAgentCoreGatewayInfra","addDependenciesToPackageJson","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","readProjectConfigurationUnqualified","assignPort","ensureProjectPackageJson","sharedConstructsGenerator","withVersions","AGENTCORE_GATEWAY_GENERATOR_INFO","filename","agentcoreGatewayGenerator","tree","options","name","nameClassName","parentDir","directory","subDir","subDirectory","projectRoot","fullyQualifiedName","protocol","auth","cedarPolicy","infra","localGatewayTarget","port","executor","continuous","command","cwd","env","PORT","dependsOn","project","root","projectType","sourceRoot","tags","targets","metadata","generator","id","dir","dirname","nameKebabCase","attachedMcpServers","overwriteStrategy","KeepExisting","rc","iac","gatewayNameClassName","gatewayNameKebabCase","projectName","projectDirectory","preferInstallDependencies","languages","readAgentCoreGatewayMetadata","Error"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,wBAAwB,QAAQ,0DAAuD;AAChG,SAASC,4BAA4B,QAAQ,2BAAwB;AACrE,SAASC,oBAAoB,QAAQ,qBAAkB;AACvD,SAASC,UAAU,QAAQ,kBAAe;AAC1C,SAASC,mBAAmB,QAAQ,sBAAmB;AACvD,SAASC,+BAA+B,QAAQ,sBAAmB;AACnE,SAASC,SAAS,EAAEC,WAAW,QAAQ,oBAAiB;AACxD,SAASC,iBAAiB,QAAQ,wBAAqB;AACvD,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,EACbC,mCAAmC,QAC9B,iBAAc;AACrB,SAASC,UAAU,QAAQ,mBAAgB;AAC3C,SAASC,wBAAwB,QAAQ,mCAAgC;AACzE,SAASC,yBAAyB,QAAQ,gCAA6B;AACvE,SAASC,YAAY,QAAQ,uBAAoB;AAGjD,OAAO,MAAMC,mCACXP,iBAAiB,YAAYQ,QAAQ,EAAE;AAEzC,OAAO,MAAMC,4BAA4B,OACvCC,MACAC;IAEA,MAAMC,OAAOhB,UAAUe,QAAQC,IAAI;IACnC,MAAMC,gBAAgBhB,YAAYe;IAClC,MAAME,YAAYH,QAAQI,SAAS,IAAI;IACvC,MAAMC,SAASL,QAAQM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AAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAaF;;;CAGC,GACD,OAAO,MAAMC,+BAA+B,CAC1CvB;IAEA,MAAMM,WAAWN,QAAQM,QAAQ;IACjC,IAAIA,UAAUC,cAAcjC,iCAAiCkC,EAAE,EAAE;QAC/D,MAAM,IAAIgB,MACR,CAAC,SAAS,EAAExB,QAAQrB,IAAI,CAAC,4BAA4B,EAAEL,iCAAiCkC,EAAE,CAAC,YAAY,CAAC;IAE5G;IACA,OAAOF;AACT,EAAE;AAEF,eAAe9B,0BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/agentcore-gateway/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../utils/add-dependencies';\nimport {\n AGENT_CORE_CONSTRUCTS_DEPENDENCIES,\n addAgentCoreGatewayInfra,\n} from '../utils/agent-core-constructs/agent-core-constructs';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../utils/format';\nimport { resolveIac } from '../utils/iac';\nimport { installDependencies } from '../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../utils/metrics';\nimport { kebabCase, toClassName } from '../utils/names';\nimport { getNpmScopePrefix } from '../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n readProjectConfigurationUnqualified,\n} from '../utils/nx';\nimport { assignPort } from '../utils/port';\nimport { ensureProjectPackageJson } from '../utils/project-package-json';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../utils/shared-constructs';\nimport type { IacMetadata } from '../utils/shared-constructs-constants';\nimport type { AgentcoreGatewayGeneratorSchema } from './schema';\n\n// The gateway's local-dev server and Cedar policy rendering need these whatever\n// the protocol or auth, so no entry is conditional.\nexport const DEPENDENCIES = declareDependencies<AgentCoreGatewayMetadata>()({\n ts: [\n { name: '@modelcontextprotocol/sdk' },\n { name: 'express' },\n { name: '@types/express', dev: true },\n // ejs renders the Cedar policy in the shared gateway construct.\n { name: 'ejs', dev: true },\n { name: '@types/ejs', dev: true },\n // local-dev.ts runs via tsx, which is shared tooling.\n { name: 'tsx', dev: true, root: true },\n ...ownedElsewhere(AGENT_CORE_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n});\n\nexport const AGENTCORE_GATEWAY_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const agentcoreGatewayGenerator = async (\n tree: Tree,\n options: AgentcoreGatewayGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const name = kebabCase(options.name);\n const nameClassName = toClassName(name);\n const parentDir = options.directory ?? 'packages';\n const subDir = options.subDirectory ?? name;\n const projectRoot = joinPathFragments(parentDir, subDir);\n const fullyQualifiedName = `${getNpmScopePrefix(tree)}${name}`;\n\n // Protocol is fixed to mcp — the enum accepts only this value, but we still\n // persist the resolved value in metadata so connection generators can read\n // it uniformly (and future additions are non-breaking).\n const protocol = options.protocol ?? 'mcp';\n // Inbound auth is iam (default) or cognito. Persisted in metadata so\n // connection generators can validate it (agent -> gateway connections\n // require an IAM gateway).\n const auth = options.auth ?? 'iam';\n const cedarPolicy = options.cedarPolicy ?? true;\n const infra = options.infra ?? 'agentcore';\n\n // local-dev.ts is the local gateway: a continuous MCP aggregator chaining\n // onto attached MCP servers' dev targets (added by the mcp-connection\n // generator), so a single `nx dev <gateway>` boots the gateway and every\n // attached MCP server together.\n //\n // `serve` exists for parity with other generators; the deployed Gateway is\n // a managed AWS resource, so `serve`-mode agents talk to it via runtime\n // config and the local gateway sits idle.\n const localGatewayTarget = (port: number) => ({\n executor: 'nx:run-commands' as const,\n continuous: true,\n options: {\n command: 'tsx local-dev.ts',\n cwd: '{projectRoot}',\n env: { PORT: `${port}` },\n },\n dependsOn: [] as Array<string | { projects: string[]; target: string }>,\n });\n let project: ProjectConfiguration;\n if (projectExists(tree, fullyQualifiedName)) {\n project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n } else {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: projectRoot,\n projectType: 'library',\n sourceRoot: projectRoot,\n tags: [],\n targets: {},\n metadata: {\n generator: AGENTCORE_GATEWAY_GENERATOR_INFO.id,\n } as any,\n });\n project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n }\n // Ensure the project has its own package.json so its runtime dependencies\n // (added below) are declared in it rather than the workspace root.\n ensureProjectPackageJson(tree, {\n dir: projectRoot,\n fullyQualifiedName,\n });\n const port = assignPort(tree, project, 8100);\n // A gateway is its own standalone project, so it uses plain `serve` / `dev`\n // targets. Re-run: keep existing targets (their dependsOn may have been\n // populated by the mcp-connection generator), just ensure both exist.\n project.targets ??= {};\n project.targets['serve'] ??= localGatewayTarget(port);\n project.targets['dev'] ??= localGatewayTarget(port);\n updateProjectConfiguration(tree, project.name, project);\n\n // Scaffold the gateway project: local-dev.ts (+ Cedar policies if requested)\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'project'),\n projectRoot,\n { nameClassName, nameKebabCase: name, port, attachedMcpServers: [] },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n if (cedarPolicy) {\n // The default permit-all policy differs by auth type: AgentCore represents\n // IAM callers as `AgentCore::IamEntity` and Cognito/JWT callers as\n // `AgentCore::OAuthUser`, so the two policies match different principals.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cedar'),\n projectRoot,\n { nameClassName, auth },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n // Recorded in the metadata below so the version sync can tell a CDK\n // project from a Terraform one; undefined when no infrastructure was\n // generated, in which case neither provider's packages were added.\n const iac =\n infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n // Recorded below and read by the declaration's predicates, so the packages\n // added here are exactly the ones the version sync will own.\n const metadata: AgentCoreGatewayMetadata = {\n name,\n rc: nameClassName,\n protocol,\n auth,\n port,\n ...(iac ? { iac } : {}),\n };\n\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n AGENTCORE_GATEWAY_GENERATOR_INFO,\n metadata,\n );\n\n addTsDependencies(tree, DEPENDENCIES, { metadata, projectRoot });\n\n // Wire up infra (CDK or Terraform); re-running with infra=agentcore adds\n // the infrastructure to a previously infra-less gateway.\n\n if (infra === 'agentcore') {\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n\n await addAgentCoreGatewayInfra(\n tree,\n {\n gatewayNameClassName: nameClassName,\n gatewayNameKebabCase: name,\n projectName: fullyQualifiedName,\n projectDirectory: projectRoot,\n cedarPolicy,\n auth,\n iac,\n },\n DEPENDENCIES,\n );\n }\n\n await addGeneratorMetricsIfApplicable(tree, [\n AGENTCORE_GATEWAY_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\n/**\n * Gateway details stored in the gateway project's metadata.\n */\nexport interface AgentCoreGatewayMetadata extends IacMetadata {\n name: string;\n rc: string;\n protocol: string;\n auth: string;\n port: number;\n}\n\n/**\n * Read a gateway project's metadata, validating it was generated by the\n * agentcore-gateway generator.\n */\nexport const readAgentCoreGatewayMetadata = (\n project: ProjectConfiguration,\n): AgentCoreGatewayMetadata => {\n const metadata = project.metadata as any;\n if (metadata?.generator !== AGENTCORE_GATEWAY_GENERATOR_INFO.id) {\n throw new Error(\n `Project '${project.name}' was not generated by the '${AGENTCORE_GATEWAY_GENERATOR_INFO.id}' generator.`,\n );\n }\n return metadata as AgentCoreGatewayMetadata;\n};\n\nexport default agentcoreGatewayGenerator;\n"],"names":["addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addTsDependencies","AGENT_CORE_CONSTRUCTS_DEPENDENCIES","addAgentCoreGatewayInfra","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","readProjectConfigurationUnqualified","assignPort","ensureProjectPackageJson","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","DEPENDENCIES","ts","name","dev","root","AGENTCORE_GATEWAY_GENERATOR_INFO","filename","agentcoreGatewayGenerator","tree","options","nameClassName","parentDir","directory","subDir","subDirectory","projectRoot","fullyQualifiedName","protocol","auth","cedarPolicy","infra","localGatewayTarget","port","executor","continuous","command","cwd","env","PORT","dependsOn","project","projectType","sourceRoot","tags","targets","metadata","generator","id","dir","dirname","nameKebabCase","attachedMcpServers","overwriteStrategy","KeepExisting","iac","undefined","rc","gatewayNameClassName","gatewayNameKebabCase","projectName","projectDirectory","preferInstallDependencies","languages","readAgentCoreGatewayMetadata","Error"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,+BAA4B;AAC9D,SACEC,kCAAkC,EAClCC,wBAAwB,QACnB,0DAAuD;AAC9D,SACEC,mBAAmB,EACnBC,cAAc,QACT,oCAAiC;AACxC,SAASC,oBAAoB,QAAQ,qBAAkB;AACvD,SAASC,UAAU,QAAQ,kBAAe;AAC1C,SAASC,mBAAmB,QAAQ,sBAAmB;AACvD,SAASC,+BAA+B,QAAQ,sBAAmB;AACnE,SAASC,SAAS,EAAEC,WAAW,QAAQ,oBAAiB;AACxD,SAASC,iBAAiB,QAAQ,wBAAqB;AACvD,SACEC,oBAAoB,EACpBC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../utils/install.js";
|
|
6
6
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
7
7
|
import { kebabCase } from "../../utils/names.js";
|
|
8
|
-
import { getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
8
|
+
import { addComponentGeneratorMetadata, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
9
9
|
import { attachUpstreamToLocalGateway } from "../attach-upstream.js";
|
|
10
10
|
import { readAgentCoreGatewayMetadata } from "../generator.js";
|
|
11
11
|
export const AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
@@ -44,6 +44,8 @@ export const AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO = getGeneratorInfo(
|
|
|
44
44
|
upstreamProjectName: targetProject.name,
|
|
45
45
|
upstreamDevTargetName: `${mcpComponentName}-dev`
|
|
46
46
|
});
|
|
47
|
+
// Recorded so the version sync can identify this connection.
|
|
48
|
+
addComponentGeneratorMetadata(tree, sourceProject.name, AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO, targetProject.root, mcpTargetName);
|
|
47
49
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
48
50
|
AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO
|
|
49
51
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/agentcore-gateway/mcp-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { GeneratorCallback, Tree } from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase } from '../../utils/names';\nimport {\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { attachUpstreamToLocalGateway } from '../attach-upstream';\nimport { readAgentCoreGatewayMetadata } from '../generator';\nimport type { AgentcoreGatewayMcpConnectionGeneratorSchema } from './schema';\n\nexport const AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\n/**\n * Connect an AgentCore Gateway to an MCP server.\n *\n * Chains the gateway's dev target to the MCP server's dev\n * target, and registers the server in the gateway's local local-dev.ts so\n * the local gateway aggregates its tools. Users must still call\n * `gateway.addMcpServer(...)` in their application stack to create the\n * actual CDK/Terraform resource.\n */\nexport const agentcoreGatewayMcpConnectionGenerator = async (\n tree: Tree,\n options: AgentcoreGatewayMcpConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const gateway = readAgentCoreGatewayMetadata(sourceProject);\n const mcpComponent = options.targetComponent;\n\n if (!mcpComponent) {\n throw new Error(\n `Target project '${options.targetProject}' has no MCP server component metadata. Did you run the 'ts#mcp-server' or 'py#mcp-server' generator?`,\n );\n }\n\n if (gateway.protocol !== 'mcp') {\n throw new Error(\n `Gateway '${gateway.name}' has protocol='${gateway.protocol}'. MCP server targets can only be attached to MCP-protocol gateways.`,\n );\n }\n if (mcpComponent.auth && mcpComponent.auth !== 'iam') {\n throw new Error(\n `MCP server '${mcpComponent.name}' uses auth='${mcpComponent.auth}'. Gateway->MCP connections currently require the MCP server to use IAM authentication.`,\n );\n }\n\n // The target name must match what the deployed Gateway uses\n // (`mcpServerName` on the MCP construct, derived from the project's class\n // name) so `<target>___<tool>` resolves identically locally and deployed.\n // Component-level `name` would clash whenever two MCP server projects\n // both default to `mcp-server`.\n const mcpTargetName = kebabCase(mcpComponent.rc as string);\n const mcpComponentName = mcpComponent.name ?? 'mcp-server';\n\n await attachUpstreamToLocalGateway(tree, sourceProject, 'dev', {\n targetName: mcpTargetName,\n port: (mcpComponent.port as number | undefined) ?? 8000,\n upstreamProjectName: targetProject.name,\n upstreamDevTargetName: `${mcpComponentName}-dev`,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [\n AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default agentcoreGatewayMcpConnectionGenerator;\n"],"names":["formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","getGeneratorInfo","readProjectConfigurationUnqualified","attachUpstreamToLocalGateway","readAgentCoreGatewayMetadata","AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO","filename","agentcoreGatewayMcpConnectionGenerator","tree","options","sourceProject","targetProject","gateway","mcpComponent","targetComponent","Error","protocol","name","auth","mcpTargetName","rc","mcpComponentName","targetName","port","upstreamProjectName","upstreamDevTargetName","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GAED,SAASA,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SACEC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,4BAA4B,QAAQ,wBAAqB;AAClE,SAASC,4BAA4B,QAAQ,kBAAe;AAG5D,OAAO,MAAMC,kDACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC;;;;;;;;CAQC,GACD,OAAO,MAAMC,yCAAyC,OACpDC,MACAC;IAEA,MAAMC,gBAAgBR,oCACpBM,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBT,oCACpBM,MACAC,QAAQE,aAAa;IAGvB,MAAMC,UAAUR,6BAA6BM;IAC7C,MAAMG,eAAeJ,QAAQK,eAAe;IAE5C,IAAI,CAACD,cAAc;QACjB,MAAM,IAAIE,MACR,CAAC,gBAAgB,EAAEN,QAAQE,aAAa,CAAC,qGAAqG,CAAC;IAEnJ;IAEA,IAAIC,QAAQI,QAAQ,KAAK,OAAO;QAC9B,MAAM,IAAID,MACR,CAAC,SAAS,EAAEH,QAAQK,IAAI,CAAC,gBAAgB,EAAEL,QAAQI,QAAQ,CAAC,oEAAoE,CAAC;IAErI;IACA,IAAIH,aAAaK,IAAI,IAAIL,aAAaK,IAAI,KAAK,OAAO;QACpD,MAAM,IAAIH,MACR,CAAC,YAAY,EAAEF,aAAaI,IAAI,CAAC,aAAa,EAAEJ,aAAaK,IAAI,CAAC,uFAAuF,CAAC;IAE9J;IAEA,4DAA4D;IAC5D,0EAA0E;IAC1E,0EAA0E;IAC1E,sEAAsE;IACtE,gCAAgC;IAChC,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/agentcore-gateway/mcp-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { GeneratorCallback, Tree } from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase } from '../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { attachUpstreamToLocalGateway } from '../attach-upstream';\nimport { readAgentCoreGatewayMetadata } from '../generator';\nimport type { AgentcoreGatewayMcpConnectionGeneratorSchema } from './schema';\n\nexport const AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\n/**\n * Connect an AgentCore Gateway to an MCP server.\n *\n * Chains the gateway's dev target to the MCP server's dev\n * target, and registers the server in the gateway's local local-dev.ts so\n * the local gateway aggregates its tools. Users must still call\n * `gateway.addMcpServer(...)` in their application stack to create the\n * actual CDK/Terraform resource.\n */\nexport const agentcoreGatewayMcpConnectionGenerator = async (\n tree: Tree,\n options: AgentcoreGatewayMcpConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const gateway = readAgentCoreGatewayMetadata(sourceProject);\n const mcpComponent = options.targetComponent;\n\n if (!mcpComponent) {\n throw new Error(\n `Target project '${options.targetProject}' has no MCP server component metadata. Did you run the 'ts#mcp-server' or 'py#mcp-server' generator?`,\n );\n }\n\n if (gateway.protocol !== 'mcp') {\n throw new Error(\n `Gateway '${gateway.name}' has protocol='${gateway.protocol}'. MCP server targets can only be attached to MCP-protocol gateways.`,\n );\n }\n if (mcpComponent.auth && mcpComponent.auth !== 'iam') {\n throw new Error(\n `MCP server '${mcpComponent.name}' uses auth='${mcpComponent.auth}'. Gateway->MCP connections currently require the MCP server to use IAM authentication.`,\n );\n }\n\n // The target name must match what the deployed Gateway uses\n // (`mcpServerName` on the MCP construct, derived from the project's class\n // name) so `<target>___<tool>` resolves identically locally and deployed.\n // Component-level `name` would clash whenever two MCP server projects\n // both default to `mcp-server`.\n const mcpTargetName = kebabCase(mcpComponent.rc as string);\n const mcpComponentName = mcpComponent.name ?? 'mcp-server';\n\n await attachUpstreamToLocalGateway(tree, sourceProject, 'dev', {\n targetName: mcpTargetName,\n port: (mcpComponent.port as number | undefined) ?? 8000,\n upstreamProjectName: targetProject.name,\n upstreamDevTargetName: `${mcpComponentName}-dev`,\n });\n\n // Recorded so the version sync can identify this connection.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO,\n targetProject.root,\n mcpTargetName,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default agentcoreGatewayMcpConnectionGenerator;\n"],"names":["formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","attachUpstreamToLocalGateway","readAgentCoreGatewayMetadata","AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO","filename","agentcoreGatewayMcpConnectionGenerator","tree","options","sourceProject","targetProject","gateway","mcpComponent","targetComponent","Error","protocol","name","auth","mcpTargetName","rc","mcpComponentName","targetName","port","upstreamProjectName","upstreamDevTargetName","root","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GAED,SAASA,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SACEC,6BAA6B,EAC7BC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,4BAA4B,QAAQ,wBAAqB;AAClE,SAASC,4BAA4B,QAAQ,kBAAe;AAG5D,OAAO,MAAMC,kDACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC;;;;;;;;CAQC,GACD,OAAO,MAAMC,yCAAyC,OACpDC,MACAC;IAEA,MAAMC,gBAAgBR,oCACpBM,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBT,oCACpBM,MACAC,QAAQE,aAAa;IAGvB,MAAMC,UAAUR,6BAA6BM;IAC7C,MAAMG,eAAeJ,QAAQK,eAAe;IAE5C,IAAI,CAACD,cAAc;QACjB,MAAM,IAAIE,MACR,CAAC,gBAAgB,EAAEN,QAAQE,aAAa,CAAC,qGAAqG,CAAC;IAEnJ;IAEA,IAAIC,QAAQI,QAAQ,KAAK,OAAO;QAC9B,MAAM,IAAID,MACR,CAAC,SAAS,EAAEH,QAAQK,IAAI,CAAC,gBAAgB,EAAEL,QAAQI,QAAQ,CAAC,oEAAoE,CAAC;IAErI;IACA,IAAIH,aAAaK,IAAI,IAAIL,aAAaK,IAAI,KAAK,OAAO;QACpD,MAAM,IAAIH,MACR,CAAC,YAAY,EAAEF,aAAaI,IAAI,CAAC,aAAa,EAAEJ,aAAaK,IAAI,CAAC,uFAAuF,CAAC;IAE9J;IAEA,4DAA4D;IAC5D,0EAA0E;IAC1E,0EAA0E;IAC1E,sEAAsE;IACtE,gCAAgC;IAChC,MAAMC,gBAAgBpB,UAAUc,aAAaO,EAAE;IAC/C,MAAMC,mBAAmBR,aAAaI,IAAI,IAAI;IAE9C,MAAMd,6BAA6BK,MAAME,eAAe,OAAO;QAC7DY,YAAYH;QACZI,MAAM,AAACV,aAAaU,IAAI,IAA2B;QACnDC,qBAAqBb,cAAcM,IAAI;QACvCQ,uBAAuB,GAAGJ,iBAAiB,IAAI,CAAC;IAClD;IAEA,6DAA6D;IAC7DrB,8BACEQ,MACAE,cAAcO,IAAI,EAClBZ,iDACAM,cAAce,IAAI,EAClBP;IAGF,MAAMrB,gCAAgCU,MAAM;QAC1CH;KACD;IAED,MAAMT,qBAAqBY;IAE3B,OAAO,IACLX,oBAAoBW,MAAMC,QAAQkB,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAerB,uCAAuC"}
|
|
@@ -109,6 +109,7 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
109
109
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
110
110
|
"metadata": {
|
|
111
111
|
"generator": "ts#infra",
|
|
112
|
+
"iac": "cdk",
|
|
112
113
|
},
|
|
113
114
|
"name": "@proj/test",
|
|
114
115
|
"projectType": "application",
|
|
@@ -686,6 +687,7 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
686
687
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
687
688
|
"metadata": {
|
|
688
689
|
"generator": "ts#infra",
|
|
690
|
+
"iac": "cdk",
|
|
689
691
|
},
|
|
690
692
|
"name": "@proj/custom-infra",
|
|
691
693
|
"projectType": "application",
|
|
@@ -5,6 +5,49 @@
|
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
6
|
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
7
|
import type { TsInfraGeneratorSchema } from './schema';
|
|
8
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
9
|
+
readonly name: "aws-cdk-lib";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "constructs";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "source-map-support";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "aws-cdk";
|
|
16
|
+
readonly dev: true;
|
|
17
|
+
readonly root: true;
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "esbuild";
|
|
20
|
+
readonly dev: true;
|
|
21
|
+
readonly root: true;
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "tsx";
|
|
24
|
+
readonly dev: true;
|
|
25
|
+
readonly root: true;
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "constructs";
|
|
28
|
+
readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
|
|
29
|
+
} & {
|
|
30
|
+
versionOnly: true;
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "aws-cdk-lib";
|
|
33
|
+
readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
|
|
34
|
+
} & {
|
|
35
|
+
versionOnly: true;
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "@types/node";
|
|
38
|
+
} & {
|
|
39
|
+
versionOnly: true;
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "@aws-sdk/client-sts";
|
|
42
|
+
readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
|
|
43
|
+
} & {
|
|
44
|
+
versionOnly: true;
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "@aws-sdk/credential-providers";
|
|
47
|
+
readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
|
|
48
|
+
} & {
|
|
49
|
+
versionOnly: true;
|
|
50
|
+
}], readonly import("../../utils/declared-dependencies").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "mcp" | "pip-check-updates" | "pip-licenses" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
8
51
|
export declare const INFRA_APP_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
52
|
export declare function tsInfraGenerator(tree: Tree, schema: TsInfraGeneratorSchema): Promise<GeneratorCallback>;
|
|
10
53
|
export default tsInfraGenerator;
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import tsProjectGenerator, { getTsLibDetails } from "../../ts/lib/generator.js";
|
|
7
7
|
import { mergeTsReferences } from "../../ts/lib/ts-project-utils.js";
|
|
8
|
+
import { addTsDependencies } from "../../utils/add-dependencies.js";
|
|
8
9
|
import { resolveContainers } from "../../utils/containers.js";
|
|
9
|
-
import {
|
|
10
|
+
import { declareDependencies, ownedElsewhere } from "../../utils/declared-dependencies.js";
|
|
10
11
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
11
12
|
import { installDependencies } from "../../utils/install.js";
|
|
12
13
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
@@ -17,11 +18,44 @@ import { addDependencyToTargetIfNotPresent, addGeneratorMetadata, getGeneratorIn
|
|
|
17
18
|
import { sortObjectKeys } from "../../utils/object.js";
|
|
18
19
|
import { getPackageManagerDisplayCommands } from "../../utils/pkg-manager.js";
|
|
19
20
|
import { uvxCommand } from "../../utils/py.js";
|
|
20
|
-
import { sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
21
|
+
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
21
22
|
import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, SHARED_INFRA_CONFIG_DIR } from "../../utils/shared-constructs-constants.js";
|
|
22
23
|
import { sharedInfraConfigGenerator } from "../../utils/shared-infra-config.js";
|
|
23
|
-
import { sharedInfraScriptsGenerator } from "../../utils/shared-infra-scripts.js";
|
|
24
|
-
|
|
24
|
+
import { SHARED_INFRA_SCRIPTS_DEPENDENCIES, sharedInfraScriptsGenerator } from "../../utils/shared-infra-scripts.js";
|
|
25
|
+
// This generator records no metadata, so nothing a predicate could read: the
|
|
26
|
+
// CDK app always needs the app libraries, and the CLI, bundler and tsx are
|
|
27
|
+
// shared tooling.
|
|
28
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
29
|
+
ts: [
|
|
30
|
+
{
|
|
31
|
+
name: 'aws-cdk-lib'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'constructs'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'source-map-support'
|
|
38
|
+
},
|
|
39
|
+
// The `aws-cdk` CLI, esbuild (CDK bundling) and tsx are shared tooling.
|
|
40
|
+
{
|
|
41
|
+
name: 'aws-cdk',
|
|
42
|
+
dev: true,
|
|
43
|
+
root: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'esbuild',
|
|
47
|
+
dev: true,
|
|
48
|
+
root: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'tsx',
|
|
52
|
+
dev: true,
|
|
53
|
+
root: true
|
|
54
|
+
},
|
|
55
|
+
...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),
|
|
56
|
+
...ownedElsewhere(SHARED_INFRA_SCRIPTS_DEPENDENCIES)
|
|
57
|
+
]
|
|
58
|
+
});
|
|
25
59
|
export const INFRA_APP_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
26
60
|
export async function tsInfraGenerator(tree, schema) {
|
|
27
61
|
const lib = getTsLibDetails(tree, schema);
|
|
@@ -49,16 +83,19 @@ export async function tsInfraGenerator(tree, schema) {
|
|
|
49
83
|
}
|
|
50
84
|
};
|
|
51
85
|
};
|
|
52
|
-
|
|
86
|
+
// This generator IS the CDK infrastructure project, so the provider is fixed.
|
|
87
|
+
addGeneratorMetadata(tree, lib.fullyQualifiedName, INFRA_APP_GENERATOR_INFO, {
|
|
88
|
+
iac: 'cdk'
|
|
89
|
+
});
|
|
53
90
|
// Shared constructs always in CDK for typescript infra generator
|
|
54
91
|
await sharedConstructsGenerator(tree, {
|
|
55
92
|
iac: 'cdk'
|
|
56
|
-
});
|
|
93
|
+
}, DEPENDENCIES);
|
|
57
94
|
// Shared infra-config and infra-scripts packages (lazy creation, only when enabled)
|
|
58
95
|
const stageConfig = schema.stageConfig ?? false;
|
|
59
96
|
if (stageConfig) {
|
|
60
97
|
await sharedInfraConfigGenerator(tree);
|
|
61
|
-
await sharedInfraScriptsGenerator(tree);
|
|
98
|
+
await sharedInfraScriptsGenerator(tree, DEPENDENCIES);
|
|
62
99
|
}
|
|
63
100
|
const synthDirFromRoot = `/dist/${lib.dir}/cdk.out`;
|
|
64
101
|
const synthDirFromProject = lib.dir.split('/').map(()=>'..').join('/') + `/dist/${lib.dir}/cdk.out`;
|
|
@@ -180,17 +217,9 @@ export async function tsInfraGenerator(tree, schema) {
|
|
|
180
217
|
config.targets = sortObjectKeys(config.targets);
|
|
181
218
|
return config;
|
|
182
219
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
'source-map-support'
|
|
187
|
-
]), {}, joinPathFragments(libraryRoot, 'package.json'));
|
|
188
|
-
// The `aws-cdk` CLI, esbuild (CDK bundling) and tsx are shared tooling.
|
|
189
|
-
addDependenciesToPackageJson(tree, {}, withVersions([
|
|
190
|
-
'aws-cdk',
|
|
191
|
-
'esbuild',
|
|
192
|
-
'tsx'
|
|
193
|
-
]));
|
|
220
|
+
addTsDependencies(tree, DEPENDENCIES, {
|
|
221
|
+
projectRoot: libraryRoot
|
|
222
|
+
});
|
|
194
223
|
updateJson(tree, `${libraryRoot}/tsconfig.lib.json`, (tsConfig)=>({
|
|
195
224
|
...tsConfig,
|
|
196
225
|
references: mergeTsReferences(tsConfig.references, [
|