@aws/nx-plugin 1.0.0-rc.54 → 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 +45 -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/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 +8 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/cognito-auth/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport {\n addDestructuredImport,\n addSingleImport,\n applyGritQL,\n} from '../../../utils/ast';\nimport { addHookResultToRouterProviderContext } from '../../../utils/ast/website';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/cognito-auth/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { addTsDependencies } from '../../../utils/add-dependencies';\nimport {\n addDestructuredImport,\n addSingleImport,\n applyGritQL,\n} from '../../../utils/ast';\nimport { addHookResultToRouterProviderContext } from '../../../utils/ast/website';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { resolveIac } from '../../../utils/iac';\nimport { addIdentityInfra } from '../../../utils/identity-constructs/identity-constructs';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { getNpmScope } from '../../../utils/npm-scope';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { toProjectRelativePath } from '../../../utils/paths';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../../utils/shared-constructs';\nimport { runtimeConfigGenerator } from '../runtime-config/generator';\nimport type { TsReactWebsiteAuthGeneratorSchema } from './schema';\nimport {\n addCloudscapeAuthMenu,\n addNoneAuthMenu,\n addShadcnAuthMenu,\n deriveCognitoDomainPrefix,\n} from './utils';\n\nconst readGritPattern = (name: string): string =>\n readFileSync(\n join(import.meta.dirname, 'grit', `${name}.grit`),\n 'utf-8',\n ).trim();\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n { name: 'oidc-client-ts' },\n { name: 'react-oidc-context' },\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n});\n\nexport const COGNITO_AUTH_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport async function tsReactWebsiteAuthGenerator(\n tree: Tree,\n options: TsReactWebsiteAuthGeneratorSchema,\n) {\n const projectConfig = readProjectConfigurationUnqualified(\n tree,\n options.project,\n );\n const srcRoot = projectConfig.sourceRoot;\n\n const cognitoDomain =\n options.cognitoDomain && options.cognitoDomain.length > 0\n ? options.cognitoDomain\n : deriveCognitoDomainPrefix(getNpmScope(tree), projectConfig.name!);\n\n await runtimeConfigGenerator(tree, {\n project: options.project,\n preferInstallDependencies: false,\n });\n\n const iac = await resolveIac(tree, options.iac);\n\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addIdentityInfra(tree, {\n iac,\n allowSignup: options.allowSignup,\n cognitoDomain,\n });\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'app'),\n srcRoot,\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n addTsDependencies(tree, DEPENDENCIES, { projectRoot: projectConfig.root });\n\n const mainTsxPath = joinPathFragments(srcRoot, 'main.tsx');\n\n await addSingleImport(\n tree,\n mainTsxPath,\n 'CognitoAuth',\n './components/CognitoAuth',\n );\n\n await addHookResultToRouterProviderContext(tree, mainTsxPath, {\n hook: 'useAuth',\n module: 'react-oidc-context',\n contextProp: 'auth',\n });\n\n const projectConfiguration = readProjectConfigurationUnqualified(\n tree,\n options.project,\n );\n\n const ux = (\n (projectConfiguration.metadata as any)?.ux ?? 'shadcn'\n ).toLowerCase();\n\n await applyGritQL(tree, mainTsxPath, readGritPattern('cognito-auth-wrapper'));\n // Update App Layout\n const appLayoutTsxPath = joinPathFragments(\n srcRoot,\n 'components',\n 'AppLayout',\n 'index.tsx',\n );\n if (tree.exists(appLayoutTsxPath)) {\n await addDestructuredImport(\n tree,\n appLayoutTsxPath,\n ['useAuth'],\n 'react-oidc-context',\n );\n await applyGritQL(\n tree,\n appLayoutTsxPath,\n readGritPattern('app-layout-use-auth'),\n );\n // TODO: update utils if they exist by appending to the array\n // Add a top-level navigation menu that shows the signed-in user's profile and actions\n switch (ux) {\n case 'cloudscape':\n await addCloudscapeAuthMenu(tree, appLayoutTsxPath);\n break;\n case 'shadcn':\n await addShadcnAuthMenu(tree, appLayoutTsxPath);\n break;\n case 'none':\n await addNoneAuthMenu(tree, appLayoutTsxPath);\n break;\n default:\n throw new Error(\n `Top-level navigation menu to show the signed-in user for ux \"${ux}\" is not implemented.`,\n );\n }\n } else {\n console.info(\n `Skipping update to ${appLayoutTsxPath} as it does not exist.`,\n );\n }\n // End update App Layout\n\n addComponentGeneratorMetadata(\n tree,\n options.project,\n COGNITO_AUTH_GENERATOR_INFO,\n toProjectRelativePath(\n projectConfig,\n joinPathFragments(srcRoot, 'components', 'CognitoAuth'),\n ),\n undefined,\n { iac },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [COGNITO_AUTH_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n}\nexport default tsReactWebsiteAuthGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readFileSync","join","addTsDependencies","addDestructuredImport","addSingleImport","applyGritQL","addHookResultToRouterProviderContext","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","addIdentityInfra","installDependencies","addGeneratorMetricsIfApplicable","getNpmScope","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","runtimeConfigGenerator","addCloudscapeAuthMenu","addNoneAuthMenu","addShadcnAuthMenu","deriveCognitoDomainPrefix","readGritPattern","name","dirname","trim","DEPENDENCIES","ts","COGNITO_AUTH_GENERATOR_INFO","filename","tsReactWebsiteAuthGenerator","tree","options","projectConfig","project","srcRoot","sourceRoot","cognitoDomain","length","preferInstallDependencies","iac","allowSignup","overwriteStrategy","KeepExisting","projectRoot","root","mainTsxPath","hook","module","contextProp","projectConfiguration","ux","metadata","toLowerCase","appLayoutTsxPath","exists","Error","console","info","undefined","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,iBAAiB,QAAQ,qCAAkC;AACpE,SACEC,qBAAqB,EACrBC,eAAe,EACfC,WAAW,QACN,wBAAqB;AAC5B,SAASC,oCAAoC,QAAQ,gCAA6B;AAClF,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAAuC;AAC9C,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,UAAU,QAAQ,wBAAqB;AAChD,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AE3CwB,WACA;QAAEnB;IAAI;IAGR,MAAM/B,gCAAgCsB,MAAM;QAACH;KAA4B;IAEzE,MAAMvB,qBAAqB0B;IAC3B,OAAO,IACLvB,oBAAoBuB,MAAMC,QAAQO,yBAAyB,EAAE;YAC3DqB,WAAW;gBAAC;aAAa;QAC3B;AACJ;AACA,eAAe9B,4BAA4B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type DependencyDeclaration, type DependencyMetadata } from './declared-dependencies';
|
|
7
|
+
/**
|
|
8
|
+
* Add the dependencies a declaration says apply, so the declaration is the only
|
|
9
|
+
* place packages are listed.
|
|
10
|
+
*
|
|
11
|
+
* Pass the very object recorded as the project's metadata: the version sync
|
|
12
|
+
* migration replays the same predicates against it, so what a generator adds and
|
|
13
|
+
* what the migration owns cannot drift.
|
|
14
|
+
*/
|
|
15
|
+
export interface AddDependenciesOptions {
|
|
16
|
+
/** The metadata the declaration's `when` predicates read. */
|
|
17
|
+
readonly metadata?: DependencyMetadata;
|
|
18
|
+
/**
|
|
19
|
+
* Project whose manifests receive the dependencies. Required unless every
|
|
20
|
+
* applicable entry is marked `root`, which targets the workspace root instead.
|
|
21
|
+
*/
|
|
22
|
+
readonly projectRoot?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Add every applicable TypeScript dependency from a declaration.
|
|
26
|
+
*
|
|
27
|
+
* Runtime deps land in the project's manifest so `noUndeclaredDependencies`
|
|
28
|
+
* passes; `dev: true` entries go to the root, where shared tooling belongs.
|
|
29
|
+
*/
|
|
30
|
+
export declare const addTsDependencies: (tree: Tree, declaration: DependencyDeclaration, { metadata, projectRoot }?: AddDependenciesOptions) => GeneratorCallback;
|
|
31
|
+
/**
|
|
32
|
+
* Add every applicable Python dependency from a declaration, routing `group`
|
|
33
|
+
* entries to their pyproject dependency group.
|
|
34
|
+
*
|
|
35
|
+
* `root: true` entries go to the workspace root pyproject, where shared tooling
|
|
36
|
+
* belongs, mirroring the TypeScript side.
|
|
37
|
+
*/
|
|
38
|
+
export declare const addPyDependencies: (tree: Tree, declaration: DependencyDeclaration, { metadata, projectRoot }?: AddDependenciesOptions) => void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { joinPathFragments } from "@nx/devkit";
|
|
5
|
+
import { applicableDependencies } from "./declared-dependencies.js";
|
|
6
|
+
import { addDependenciesToPackageJson } from "./dependencies.js";
|
|
7
|
+
import { addDependenciesToDependencyGroupInPyProjectToml, addDependenciesToPyProjectToml } from "./py.js";
|
|
8
|
+
import { TS_VERSIONS } from "./versions.js";
|
|
9
|
+
/**
|
|
10
|
+
* The manifest an entry belongs in: the workspace root for shared tooling
|
|
11
|
+
* (`root: true`), otherwise the project's own.
|
|
12
|
+
*
|
|
13
|
+
* A project-level entry with no `projectRoot` is a mistake rather than a default
|
|
14
|
+
* — silently adding it to the root manifest would leave the project failing
|
|
15
|
+
* `noUndeclaredDependencies` on a dependency it imports.
|
|
16
|
+
*/ const requireProjectRoot = (entry, projectRoot, generator)=>{
|
|
17
|
+
if (entry.root) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
if (!projectRoot) {
|
|
21
|
+
throw new Error(`${generator} was called without a projectRoot, but '${String(entry.name)}' is not declared with \`root: true\`. ` + `Pass the project's root, or declare the dependency with \`root: true\` if it belongs to the workspace root.`);
|
|
22
|
+
}
|
|
23
|
+
return projectRoot;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Add every applicable TypeScript dependency from a declaration.
|
|
27
|
+
*
|
|
28
|
+
* Runtime deps land in the project's manifest so `noUndeclaredDependencies`
|
|
29
|
+
* passes; `dev: true` entries go to the root, where shared tooling belongs.
|
|
30
|
+
*/ export const addTsDependencies = (tree, declaration, { metadata = {}, projectRoot } = {})=>{
|
|
31
|
+
const applicable = applicableDependencies(declaration.ts, metadata);
|
|
32
|
+
const manifests = new Map();
|
|
33
|
+
for (const entry of applicable){
|
|
34
|
+
const root = requireProjectRoot(entry, projectRoot, 'addTsDependencies');
|
|
35
|
+
const manifestPath = root ? joinPathFragments(root, 'package.json') : 'package.json';
|
|
36
|
+
const manifest = manifests.get(manifestPath) ?? {
|
|
37
|
+
runtime: {},
|
|
38
|
+
dev: {}
|
|
39
|
+
};
|
|
40
|
+
manifest[entry.dev ? 'dev' : 'runtime'][entry.name] = TS_VERSIONS[entry.name];
|
|
41
|
+
manifests.set(manifestPath, manifest);
|
|
42
|
+
}
|
|
43
|
+
const callbacks = [
|
|
44
|
+
...manifests
|
|
45
|
+
].map(([manifestPath, { runtime, dev }])=>addDependenciesToPackageJson(tree, runtime, dev, manifestPath));
|
|
46
|
+
return async ()=>{
|
|
47
|
+
for (const callback of callbacks){
|
|
48
|
+
await callback();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Add every applicable Python dependency from a declaration, routing `group`
|
|
54
|
+
* entries to their pyproject dependency group.
|
|
55
|
+
*
|
|
56
|
+
* `root: true` entries go to the workspace root pyproject, where shared tooling
|
|
57
|
+
* belongs, mirroring the TypeScript side.
|
|
58
|
+
*/ export const addPyDependencies = (tree, declaration, { metadata = {}, projectRoot } = {})=>{
|
|
59
|
+
const applicable = applicableDependencies(declaration.py, metadata);
|
|
60
|
+
// Keyed by the pyproject to write and the group within it, since one
|
|
61
|
+
// declaration may span the project's and the workspace root's.
|
|
62
|
+
const buckets = new Map();
|
|
63
|
+
for (const entry of applicable){
|
|
64
|
+
const root = requireProjectRoot(entry, projectRoot, 'addPyDependencies') ?? '.';
|
|
65
|
+
const key = `${root}\0${entry.group ?? ''}`;
|
|
66
|
+
const bucket = buckets.get(key) ?? {
|
|
67
|
+
root,
|
|
68
|
+
group: entry.group,
|
|
69
|
+
names: []
|
|
70
|
+
};
|
|
71
|
+
bucket.names.push(entry.name);
|
|
72
|
+
buckets.set(key, bucket);
|
|
73
|
+
}
|
|
74
|
+
for (const { root, group, names } of buckets.values()){
|
|
75
|
+
if (group) {
|
|
76
|
+
addDependenciesToDependencyGroupInPyProjectToml(tree, root, group, declaration, names);
|
|
77
|
+
} else {
|
|
78
|
+
addDependenciesToPyProjectToml(tree, root, declaration, names);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=add-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/add-dependencies.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n joinPathFragments,\n type Tree,\n} from '@nx/devkit';\nimport {\n applicableDependencies,\n type DependencyDeclaration,\n type DependencyMetadata,\n} from './declared-dependencies';\nimport { addDependenciesToPackageJson } from './dependencies';\nimport {\n addDependenciesToDependencyGroupInPyProjectToml,\n addDependenciesToPyProjectToml,\n} from './py';\nimport { TS_VERSIONS } from './versions';\n\n/**\n * Add the dependencies a declaration says apply, so the declaration is the only\n * place packages are listed.\n *\n * Pass the very object recorded as the project's metadata: the version sync\n * migration replays the same predicates against it, so what a generator adds and\n * what the migration owns cannot drift.\n */\nexport interface AddDependenciesOptions {\n /** The metadata the declaration's `when` predicates read. */\n readonly metadata?: DependencyMetadata;\n /**\n * Project whose manifests receive the dependencies. Required unless every\n * applicable entry is marked `root`, which targets the workspace root instead.\n */\n readonly projectRoot?: string;\n}\n\n/**\n * The manifest an entry belongs in: the workspace root for shared tooling\n * (`root: true`), otherwise the project's own.\n *\n * A project-level entry with no `projectRoot` is a mistake rather than a default\n * — silently adding it to the root manifest would leave the project failing\n * `noUndeclaredDependencies` on a dependency it imports.\n */\nconst requireProjectRoot = (\n entry: { name: unknown; root?: boolean },\n projectRoot: string | undefined,\n generator: string,\n): string | undefined => {\n if (entry.root) {\n return undefined;\n }\n if (!projectRoot) {\n throw new Error(\n `${generator} was called without a projectRoot, but '${String(entry.name)}' is not declared with \\`root: true\\`. ` +\n `Pass the project's root, or declare the dependency with \\`root: true\\` if it belongs to the workspace root.`,\n );\n }\n return projectRoot;\n};\n\n/**\n * Add every applicable TypeScript dependency from a declaration.\n *\n * Runtime deps land in the project's manifest so `noUndeclaredDependencies`\n * passes; `dev: true` entries go to the root, where shared tooling belongs.\n */\nexport const addTsDependencies = (\n tree: Tree,\n declaration: DependencyDeclaration,\n { metadata = {}, projectRoot }: AddDependenciesOptions = {},\n): GeneratorCallback => {\n const applicable = applicableDependencies(declaration.ts, metadata);\n const manifests = new Map<\n string,\n { runtime: Record<string, string>; dev: Record<string, string> }\n >();\n for (const entry of applicable) {\n const root = requireProjectRoot(entry, projectRoot, 'addTsDependencies');\n const manifestPath = root\n ? joinPathFragments(root, 'package.json')\n : 'package.json';\n const manifest = manifests.get(manifestPath) ?? { runtime: {}, dev: {} };\n manifest[entry.dev ? 'dev' : 'runtime'][entry.name as string] =\n TS_VERSIONS[entry.name];\n manifests.set(manifestPath, manifest);\n }\n\n const callbacks = [...manifests].map(([manifestPath, { runtime, dev }]) =>\n addDependenciesToPackageJson(tree, runtime, dev, manifestPath),\n );\n return async () => {\n for (const callback of callbacks) {\n await callback();\n }\n };\n};\n\n/**\n * Add every applicable Python dependency from a declaration, routing `group`\n * entries to their pyproject dependency group.\n *\n * `root: true` entries go to the workspace root pyproject, where shared tooling\n * belongs, mirroring the TypeScript side.\n */\nexport const addPyDependencies = (\n tree: Tree,\n declaration: DependencyDeclaration,\n { metadata = {}, projectRoot }: AddDependenciesOptions = {},\n): void => {\n const applicable = applicableDependencies(declaration.py, metadata);\n\n // Keyed by the pyproject to write and the group within it, since one\n // declaration may span the project's and the workspace root's.\n const buckets = new Map<\n string,\n { root: string; group?: string; names: string[] }\n >();\n for (const entry of applicable) {\n const root =\n requireProjectRoot(entry, projectRoot, 'addPyDependencies') ?? '.';\n const key = `${root}\\0${entry.group ?? ''}`;\n const bucket = buckets.get(key) ?? { root, group: entry.group, names: [] };\n bucket.names.push(entry.name as string);\n buckets.set(key, bucket);\n }\n\n for (const { root, group, names } of buckets.values()) {\n if (group) {\n addDependenciesToDependencyGroupInPyProjectToml(\n tree,\n root,\n group,\n declaration,\n names as never,\n );\n } else {\n addDependenciesToPyProjectToml(tree, root, declaration, names as never);\n }\n }\n};\n"],"names":["joinPathFragments","applicableDependencies","addDependenciesToPackageJson","addDependenciesToDependencyGroupInPyProjectToml","addDependenciesToPyProjectToml","TS_VERSIONS","requireProjectRoot","entry","projectRoot","generator","root","undefined","Error","String","name","addTsDependencies","tree","declaration","metadata","applicable","ts","manifests","Map","manifestPath","manifest","get","runtime","dev","set","callbacks","map","callback","addPyDependencies","py","buckets","key","group","bucket","names","push","values"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,iBAAiB,QAEZ,aAAa;AACpB,SACEC,sBAAsB,QAGjB,6BAA0B;AACjC,SAASC,4BAA4B,QAAQ,oBAAiB;AAC9D,SACEC,+CAA+C,EAC/CC,8BAA8B,QACzB,UAAO;AACd,SAASC,WAAW,QAAQ,gBAAa;AAoBzC;;;;;;;CAOC,GACD,MAAMC,qBAAqB,CACzBC,OACAC,aACAC;IAEA,IAAIF,MAAMG,IAAI,EAAE;QACd,OAAOC;IACT;IACA,IAAI,CAACH,aAAa;QAChB,MAAM,IAAII,MACR,GAAGH,UAAU,wCAAwC,EAAEI,OAAON,MAAMO,IAAI,EAAE,uCAAuC,CAAC,GAChH,CAAC,2GAA2G,CAAC;IAEnH;IACA,OAAON;AACT;AAEA;;;;;CAKC,GACD,OAAO,MAAMO,o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AEzB;YAAM0B,OAAO7B,MAAM6B,KAAK;YAAEE,OAAO,EAAE;QAAC;QACzED,OAAOC,KAAK,CAACC,IAAI,CAAChC,MAAMO,IAAI;QAC5BoB,QAAQN,GAAG,CAACO,KAAKE;IACnB;IAEA,KAAK,MAAM,EAAE3B,IAAI,EAAE0B,KAAK,EAAEE,KAAK,EAAE,IAAIJ,QAAQM,MAAM,GAAI;QACrD,IAAIJ,OAAO;YACTjC,gDACEa,MACAN,MACA0B,OACAnB,aACAqB;QAEJ,OAAO;YACLlC,+BAA+BY,MAAMN,MAAMO,aAAaqB;QAC1D;IACF;AACF,EAAE"}
|
|
@@ -3,7 +3,28 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type Tree } from '@nx/devkit';
|
|
6
|
+
import { type DependencyDeclaration, type MustDeclare, type MustDeclarePy } from '../declared-dependencies';
|
|
6
7
|
import { type IPyDepVersion } from '../versions';
|
|
8
|
+
/** TypeScript dependencies a caller must declare to emit agent-connection clients. */
|
|
9
|
+
export declare const AGENT_CONNECTION_DEPENDENCIES: readonly [{
|
|
10
|
+
readonly name: "@aws-lambda-powertools/parameters";
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "@aws-sdk/credential-providers";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "aws4fetch";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "@modelcontextprotocol/sdk";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "@a2a-js/sdk";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "@strands-agents/sdk";
|
|
21
|
+
}];
|
|
22
|
+
/** Python dependencies a caller must declare to emit agent-connection clients. */
|
|
23
|
+
export declare const AGENT_CONNECTION_PY_DEPENDENCIES: readonly [{
|
|
24
|
+
readonly name: "aws-lambda-powertools";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "strands-agents";
|
|
27
|
+
}];
|
|
7
28
|
export declare const AGENT_CONNECTION_PROJECT_DIR: string;
|
|
8
29
|
/**
|
|
9
30
|
* Get the directory of the shared Python agent-connection project.
|
|
@@ -49,7 +70,7 @@ export declare function resolveAgentFramework(framework: string | undefined): Ag
|
|
|
49
70
|
* Per-connection generators emit their own protocol + framework client
|
|
50
71
|
* templates via `addTypeScriptCoreClient`.
|
|
51
72
|
*/
|
|
52
|
-
export declare function ensureTypeScriptAgentConnectionProject(tree: Tree): Promise<void>;
|
|
73
|
+
export declare function ensureTypeScriptAgentConnectionProject<const D extends DependencyDeclaration>(tree: Tree, declaration: D & MustDeclare<typeof AGENT_CONNECTION_DEPENDENCIES, D>): Promise<void>;
|
|
53
74
|
/**
|
|
54
75
|
* Emit a framework's base Layer-2 helpers (model-error logging + per-session
|
|
55
76
|
* agent cache) into the agent-connection project and re-export them. The agent
|
|
@@ -57,7 +78,7 @@ export declare function ensureTypeScriptAgentConnectionProject(tree: Tree): Prom
|
|
|
57
78
|
* is wired in, so the agent generator calls this directly; connection
|
|
58
79
|
* generators call it transitively via `addTypeScriptCoreClient`.
|
|
59
80
|
*/
|
|
60
|
-
export declare function addTypeScriptFrameworkBase(tree: Tree, framework?: AgentFramework): Promise<void>;
|
|
81
|
+
export declare function addTypeScriptFrameworkBase<const D extends DependencyDeclaration>(tree: Tree, declaration: D & MustDeclare<typeof AGENT_CONNECTION_DEPENDENCIES, D>, framework?: AgentFramework): Promise<void>;
|
|
61
82
|
/**
|
|
62
83
|
* Emit the TypeScript client templates for a connection protocol and agent
|
|
63
84
|
* framework into the agent-connection project's `src/core/` directory. Safe to
|
|
@@ -69,13 +90,13 @@ export declare function addTypeScriptFrameworkBase(tree: Tree, framework?: Agent
|
|
|
69
90
|
* - Layer 1 the protocol's transport/client-config — always
|
|
70
91
|
* - Layer 2 the framework's base helpers + protocol client — per framework
|
|
71
92
|
*/
|
|
72
|
-
export declare function addTypeScriptCoreClient(tree: Tree, protocol: ConnectionProtocol, framework?: AgentFramework): Promise<void>;
|
|
93
|
+
export declare function addTypeScriptCoreClient<const D extends DependencyDeclaration>(tree: Tree, protocol: ConnectionProtocol, declaration: D & MustDeclare<typeof AGENT_CONNECTION_DEPENDENCIES, D>, framework?: AgentFramework): Promise<void>;
|
|
73
94
|
/**
|
|
74
95
|
* Ensure the shared Python agent-connection project exists.
|
|
75
96
|
* Only creates the project shell — per-connection generators are responsible
|
|
76
97
|
* for emitting their own core client templates.
|
|
77
98
|
*/
|
|
78
|
-
export declare function ensurePythonAgentConnectionProject(tree: Tree): Promise<void>;
|
|
99
|
+
export declare function ensurePythonAgentConnectionProject<const D extends DependencyDeclaration>(tree: Tree, declaration: D & MustDeclarePy<typeof AGENT_CONNECTION_PY_DEPENDENCIES, D>): Promise<void>;
|
|
79
100
|
/**
|
|
80
101
|
* Emit a framework's base Layer-2 helpers (model-error logging + per-session
|
|
81
102
|
* agent cache) into the Python agent-connection project and re-export them.
|
|
@@ -83,7 +104,7 @@ export declare function ensurePythonAgentConnectionProject(tree: Tree): Promise<
|
|
|
83
104
|
* client is wired in, so the agent generator calls this directly; connection
|
|
84
105
|
* generators call it transitively via `addPythonCoreClient`.
|
|
85
106
|
*/
|
|
86
|
-
export declare function addPythonFrameworkBase(tree: Tree, framework?: AgentFramework): Promise<void>;
|
|
107
|
+
export declare function addPythonFrameworkBase<const D extends DependencyDeclaration>(tree: Tree, declaration: D & MustDeclarePy<typeof AGENT_CONNECTION_PY_DEPENDENCIES, D>, framework?: AgentFramework): Promise<void>;
|
|
87
108
|
/**
|
|
88
109
|
* Emit the Python client templates for a connection protocol and agent
|
|
89
110
|
* framework into the agent-connection project's core directory.
|
|
@@ -94,7 +115,7 @@ export declare function addPythonFrameworkBase(tree: Tree, framework?: AgentFram
|
|
|
94
115
|
* - Layer 1 the protocol's transport/client-config — always
|
|
95
116
|
* - Layer 2 the framework's base helpers + protocol client — per framework
|
|
96
117
|
*/
|
|
97
|
-
export declare function addPythonCoreClient(tree: Tree, protocol: ConnectionProtocol, framework?: AgentFramework): Promise<void>;
|
|
118
|
+
export declare function addPythonCoreClient<const D extends DependencyDeclaration>(tree: Tree, protocol: ConnectionProtocol, declaration: D & MustDeclarePy<typeof AGENT_CONNECTION_PY_DEPENDENCIES, D>, framework?: AgentFramework): Promise<void>;
|
|
98
119
|
/**
|
|
99
120
|
* Patch a TypeScript agent.ts to create a connection client and register it
|
|
100
121
|
* in the Agent's tools. Used by the MCP and gateway connection generators —
|
|
@@ -5,10 +5,39 @@
|
|
|
5
5
|
import pyProjectGenerator, { getPyProjectDetails } from "../../py/project/generator.js";
|
|
6
6
|
import tsProjectGenerator from "../../ts/lib/generator.js";
|
|
7
7
|
import { addStarExport, applyGritQL, matchGritQL } from "../ast.js";
|
|
8
|
+
import { forDependencies } from "../declared-dependencies.js";
|
|
8
9
|
import { addDependenciesToPackageJson } from "../dependencies.js";
|
|
9
10
|
import { esmVars } from "../module-format.js";
|
|
10
11
|
import { addDependenciesToPyProjectToml } from "../py.js";
|
|
11
12
|
import { withVersions } from "../versions.js";
|
|
13
|
+
/** TypeScript dependencies a caller must declare to emit agent-connection clients. */ export const AGENT_CONNECTION_DEPENDENCIES = [
|
|
14
|
+
{
|
|
15
|
+
name: '@aws-lambda-powertools/parameters'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: '@aws-sdk/credential-providers'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'aws4fetch'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: '@modelcontextprotocol/sdk'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: '@a2a-js/sdk'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: '@strands-agents/sdk'
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
/** Python dependencies a caller must declare to emit agent-connection clients. */ export const AGENT_CONNECTION_PY_DEPENDENCIES = [
|
|
34
|
+
{
|
|
35
|
+
name: 'aws-lambda-powertools'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'strands-agents'
|
|
39
|
+
}
|
|
40
|
+
];
|
|
12
41
|
/** Prefix a GritQL pattern with `language python` */ const py = (pattern)=>`language python\n${pattern}`;
|
|
13
42
|
const AGENT_CONNECTION_DIR = 'agent-connection';
|
|
14
43
|
const PACKAGES_DIR = 'packages';
|
|
@@ -197,7 +226,7 @@ const tsCoreDir = ()=>joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'co
|
|
|
197
226
|
'@strands-agents/sdk'
|
|
198
227
|
]
|
|
199
228
|
};
|
|
200
|
-
const emitTs = (tree, templateDir)=>{
|
|
229
|
+
const emitTs = (tree, templateDir, declaration)=>{
|
|
201
230
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', templateDir), tsCoreDir(), {
|
|
202
231
|
...esmVars(tree)
|
|
203
232
|
}, {
|
|
@@ -205,7 +234,7 @@ const emitTs = (tree, templateDir)=>{
|
|
|
205
234
|
});
|
|
206
235
|
const deps = TS_TEMPLATE_DEPS[templateDir];
|
|
207
236
|
if (deps?.length) {
|
|
208
|
-
addDependenciesToPackageJson(tree, withVersions(deps), {}, joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'package.json'));
|
|
237
|
+
addDependenciesToPackageJson(tree, withVersions(forDependencies(declaration), deps), {}, joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'package.json'));
|
|
209
238
|
}
|
|
210
239
|
};
|
|
211
240
|
/**
|
|
@@ -213,7 +242,7 @@ const emitTs = (tree, templateDir)=>{
|
|
|
213
242
|
* framework-agnostic core helpers (runtime-config loader, session context).
|
|
214
243
|
* Per-connection generators emit their own protocol + framework client
|
|
215
244
|
* templates via `addTypeScriptCoreClient`.
|
|
216
|
-
*/ export async function ensureTypeScriptAgentConnectionProject(tree) {
|
|
245
|
+
*/ export async function ensureTypeScriptAgentConnectionProject(tree, declaration) {
|
|
217
246
|
const projectJsonPath = joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'project.json');
|
|
218
247
|
if (!tree.exists(projectJsonPath)) {
|
|
219
248
|
await tsProjectGenerator(tree, {
|
|
@@ -222,7 +251,7 @@ const emitTs = (tree, templateDir)=>{
|
|
|
222
251
|
});
|
|
223
252
|
}
|
|
224
253
|
// Framework-agnostic runtime-config + session-context helpers.
|
|
225
|
-
emitTs(tree, 'core-runtime-config');
|
|
254
|
+
emitTs(tree, 'core-runtime-config', declaration);
|
|
226
255
|
// Re-export session-context helpers so agent server entry points can set the
|
|
227
256
|
// current session on each inbound request without pulling in internals.
|
|
228
257
|
await addStarExport(tree, joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'index.ts'), './core/session-context.js');
|
|
@@ -233,13 +262,13 @@ const emitTs = (tree, templateDir)=>{
|
|
|
233
262
|
* server entry point imports these regardless of whether any connection client
|
|
234
263
|
* is wired in, so the agent generator calls this directly; connection
|
|
235
264
|
* generators call it transitively via `addTypeScriptCoreClient`.
|
|
236
|
-
*/ export async function addTypeScriptFrameworkBase(tree, framework = 'strands') {
|
|
265
|
+
*/ export async function addTypeScriptFrameworkBase(tree, declaration, framework = 'strands') {
|
|
237
266
|
const lang = FRAMEWORKS[framework].ts;
|
|
238
267
|
if (!lang) {
|
|
239
268
|
throw new Error(`The '${framework}' framework does not support TypeScript agents.`);
|
|
240
269
|
}
|
|
241
270
|
if (lang.base) {
|
|
242
|
-
emitTs(tree, lang.base);
|
|
271
|
+
emitTs(tree, lang.base, declaration);
|
|
243
272
|
}
|
|
244
273
|
const indexPath = joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'index.ts');
|
|
245
274
|
for (const reExport of lang.baseReExports){
|
|
@@ -256,23 +285,23 @@ const emitTs = (tree, templateDir)=>{
|
|
|
256
285
|
* - Layer 1 `core-shared` MCP transport — for mcp/gateway protocols
|
|
257
286
|
* - Layer 1 the protocol's transport/client-config — always
|
|
258
287
|
* - Layer 2 the framework's base helpers + protocol client — per framework
|
|
259
|
-
*/ export async function addTypeScriptCoreClient(tree, protocol, framework = 'strands') {
|
|
288
|
+
*/ export async function addTypeScriptCoreClient(tree, protocol, declaration, framework = 'strands') {
|
|
260
289
|
const fw = frameworkLanguage(framework, 'ts', protocol);
|
|
261
|
-
emitTs(tree, 'core-auth');
|
|
290
|
+
emitTs(tree, 'core-auth', declaration);
|
|
262
291
|
if (MCP_TRANSPORT_PROTOCOLS.includes(protocol)) {
|
|
263
|
-
emitTs(tree, 'core-shared');
|
|
292
|
+
emitTs(tree, 'core-shared', declaration);
|
|
264
293
|
}
|
|
265
|
-
emitTs(tree, TS_PROTOCOL_TEMPLATES[protocol]);
|
|
294
|
+
emitTs(tree, TS_PROTOCOL_TEMPLATES[protocol], declaration);
|
|
266
295
|
// Framework Layer 2: base helpers (re-exported for the agent server) + the
|
|
267
296
|
// thin protocol client.
|
|
268
|
-
await addTypeScriptFrameworkBase(tree, framework);
|
|
269
|
-
emitTs(tree, fw.protocol);
|
|
297
|
+
await addTypeScriptFrameworkBase(tree, forDependencies(declaration), framework);
|
|
298
|
+
emitTs(tree, fw.protocol, declaration);
|
|
270
299
|
}
|
|
271
300
|
/**
|
|
272
301
|
* Ensure the shared Python agent-connection project exists.
|
|
273
302
|
* Only creates the project shell — per-connection generators are responsible
|
|
274
303
|
* for emitting their own core client templates.
|
|
275
|
-
*/ export async function ensurePythonAgentConnectionProject(tree) {
|
|
304
|
+
*/ export async function ensurePythonAgentConnectionProject(tree, declaration) {
|
|
276
305
|
const projectDir = getPythonAgentConnectionProjectDir(tree);
|
|
277
306
|
const moduleName = getPythonAgentConnectionModuleName(tree);
|
|
278
307
|
const projectJsonPath = joinPathFragments(projectDir, 'project.json');
|
|
@@ -305,7 +334,7 @@ const emitTs = (tree, templateDir)=>{
|
|
|
305
334
|
await addPythonReExport(tree, moduleInitPath, '.core.session_context', 'get_current_session_id');
|
|
306
335
|
await addPythonReExport(tree, moduleInitPath, '.core.session_context', 'session_id_context');
|
|
307
336
|
// The runtime-config loader reads AppConfig via aws-lambda-powertools.
|
|
308
|
-
addDependenciesToPyProjectToml(tree, projectDir, [
|
|
337
|
+
addDependenciesToPyProjectToml(tree, projectDir, forDependencies(declaration), [
|
|
309
338
|
'aws-lambda-powertools'
|
|
310
339
|
]);
|
|
311
340
|
}
|
|
@@ -319,7 +348,7 @@ const emitPy = (tree, templateDir)=>generateFiles(tree, joinPathFragments(import
|
|
|
319
348
|
* The agent server entry point imports these regardless of whether a connection
|
|
320
349
|
* client is wired in, so the agent generator calls this directly; connection
|
|
321
350
|
* generators call it transitively via `addPythonCoreClient`.
|
|
322
|
-
*/ export async function addPythonFrameworkBase(tree, framework = 'strands') {
|
|
351
|
+
*/ export async function addPythonFrameworkBase(tree, declaration, framework = 'strands') {
|
|
323
352
|
const lang = FRAMEWORKS[framework].py;
|
|
324
353
|
if (!lang) {
|
|
325
354
|
throw new Error(`The '${framework}' framework does not support Python agents.`);
|
|
@@ -332,7 +361,7 @@ const emitPy = (tree, templateDir)=>generateFiles(tree, joinPathFragments(import
|
|
|
332
361
|
await addPythonReExport(tree, moduleInitPath, reExport.fromModule, reExport.importName);
|
|
333
362
|
}
|
|
334
363
|
if (lang.deps.length > 0) {
|
|
335
|
-
addDependenciesToPyProjectToml(tree, getPythonAgentConnectionProjectDir(tree), lang.deps);
|
|
364
|
+
addDependenciesToPyProjectToml(tree, getPythonAgentConnectionProjectDir(tree), forDependencies(declaration), lang.deps);
|
|
336
365
|
}
|
|
337
366
|
}
|
|
338
367
|
/**
|
|
@@ -344,7 +373,7 @@ const emitPy = (tree, templateDir)=>generateFiles(tree, joinPathFragments(import
|
|
|
344
373
|
* - Layer 1 `py-core-shared` MCP transport — for mcp/gateway protocols
|
|
345
374
|
* - Layer 1 the protocol's transport/client-config — always
|
|
346
375
|
* - Layer 2 the framework's base helpers + protocol client — per framework
|
|
347
|
-
*/ export async function addPythonCoreClient(tree, protocol, framework = 'strands') {
|
|
376
|
+
*/ export async function addPythonCoreClient(tree, protocol, declaration, framework = 'strands') {
|
|
348
377
|
const fw = frameworkLanguage(framework, 'py', protocol);
|
|
349
378
|
emitPy(tree, 'py-core-auth');
|
|
350
379
|
if (MCP_TRANSPORT_PROTOCOLS.includes(protocol)) {
|
|
@@ -352,7 +381,7 @@ const emitPy = (tree, templateDir)=>generateFiles(tree, joinPathFragments(import
|
|
|
352
381
|
}
|
|
353
382
|
emitPy(tree, PY_PROTOCOL_TEMPLATES[protocol]);
|
|
354
383
|
// Framework Layer 2: base helpers + the thin protocol client.
|
|
355
|
-
await addPythonFrameworkBase(tree, framework);
|
|
384
|
+
await addPythonFrameworkBase(tree, forDependencies(declaration), framework);
|
|
356
385
|
emitPy(tree, fw.protocol);
|
|
357
386
|
}
|
|
358
387
|
/**
|