@aws/nx-plugin 1.0.0-rc.93 → 1.0.0-rc.94
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 +16 -1
- package/package.json +1 -1
- package/src/agentcore-harness/generator.d.ts +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/infra/app/generator.d.ts +1 -1
- package/src/infra/app/generator.js +5 -3
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +1 -1
- package/src/migrations/latest/agent-core-vendor-target/metadata.json +3 -0
- package/src/migrations/latest/agent-core-vendor-target/migration.d.ts +6 -0
- package/src/migrations/latest/agent-core-vendor-target/migration.js +98 -0
- package/src/migrations/latest/agent-core-vendor-target/migration.js.map +1 -0
- package/src/migrations/latest/infra-deploy-express-mode/metadata.json +3 -0
- package/src/migrations/latest/infra-deploy-express-mode/migration.d.ts +6 -0
- package/src/migrations/latest/infra-deploy-express-mode/migration.js +83 -0
- package/src/migrations/latest/infra-deploy-express-mode/migration.js.map +1 -0
- package/src/migrations/latest/shx-fs-commands/metadata.json +3 -0
- package/src/migrations/latest/shx-fs-commands/migration.d.ts +6 -0
- package/src/migrations/latest/shx-fs-commands/migration.js +216 -0
- package/src/migrations/latest/shx-fs-commands/migration.js.map +1 -0
- package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +18 -12
- package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +5 -2
- package/src/open-api/utils/codegen-data/types.d.ts +6 -0
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.js +32 -7
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +39 -14
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.js +51 -5
- package/src/open-api/utils/parser.js.map +1 -1
- package/src/preset/generator.d.ts +1 -1
- package/src/py/agent/a2a-connection/generator.d.ts +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +1 -1
- package/src/py/agent/generator.d.ts +2 -26
- package/src/py/agent/generator.js +2 -2
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +1 -1
- package/src/py/agent/react-connection/generator.d.ts +1 -1
- package/src/py/fast-api/generator.d.ts +1 -13
- package/src/py/fast-api/generator.js +1 -1
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +1 -1
- package/src/py/mcp-server/generator.d.ts +2 -26
- package/src/py/mcp-server/generator.js +2 -2
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +2 -26
- package/src/py/rdb/generator.js +6 -6
- package/src/py/rdb/generator.js.map +1 -1
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +24 -20
- package/src/smithy/project/generator.d.ts +2 -14
- package/src/smithy/project/generator.js +2 -1
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +8 -7
- package/src/smithy/ts/api/generator.d.ts +1 -13
- package/src/smithy/ts/api/generator.js +1 -1
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/generator.d.ts +2 -2
- package/src/terraform/project/generator.js +4 -4
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/react/generator.d.ts +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +1 -1
- package/src/ts/agent/generator.d.ts +3 -39
- package/src/ts/agent/generator.js +1 -1
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +1 -1
- package/src/ts/astro-docs/generator.d.ts +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +1 -1
- package/src/ts/dynamodb/generator.d.ts +1 -1
- package/src/ts/lambda-function/generator.d.ts +1 -1
- package/src/ts/lib/generator.d.ts +1 -1
- package/src/ts/mcp-server/generator.d.ts +3 -39
- package/src/ts/mcp-server/generator.js +1 -1
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/generator.d.ts +1 -1
- package/src/ts/nx-migration/generator.d.ts +1 -1
- package/src/ts/nx-plugin/generator.d.ts +1 -1
- package/src/ts/rdb/generator.d.ts +3 -27
- package/src/ts/rdb/generator.js +3 -3
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +1 -1
- package/src/utils/agent-core-packaging.d.ts +25 -12
- package/src/utils/agent-core-packaging.js +47 -11
- package/src/utils/agent-core-packaging.js.map +1 -1
- package/src/utils/docker.d.ts +1 -7
- package/src/utils/docker.js +1 -1
- package/src/utils/docker.js.map +1 -1
- package/src/utils/format.d.ts +5 -0
- package/src/utils/format.js +5 -0
- package/src/utils/format.js.map +1 -1
- package/src/utils/fs.d.ts +21 -11
- package/src/utils/fs.js +30 -22
- package/src/utils/fs.js.map +1 -1
- package/src/utils/version-lockstep/lockstep.d.ts +27 -0
- package/src/utils/version-lockstep/lockstep.js +46 -0
- package/src/utils/version-lockstep/lockstep.js.map +1 -0
- package/src/utils/versions.d.ts +9 -4
- package/src/utils/versions.js +24 -4
- package/src/utils/versions.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport {\n AGENT_CORE_CONSTRUCTS_PY_DEPENDENCIES,\n type AgentCoreArtifact,\n addMcpServerInfra,\n} from '../../utils/agent-core-constructs/agent-core-constructs.js';\nimport {\n addTypeScriptCodePackageTarget,\n agentCoreNodeRuntime,\n CODE_PACKAGE_DEPENDENCIES,\n isAgentCoreHosted,\n isContainerHosted,\n} from '../../utils/agent-core-packaging.js';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle.js';\nimport { resolveContainers } from '../../utils/containers.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport {\n ADOT_IMAGE_DEPENDENCIES,\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n IMAGE_BUILD_CACHE,\n NODE_IMAGE_DEPENDENCIES,\n nodeImageVersions,\n} from '../../utils/docker.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport { kebabCase, toClassName } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addArtifactDependencyToTargets,\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace.js';\nimport { assignPort } from '../../utils/port.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants.js';\nimport { BASE_IMAGES, TS_VERSIONS } from '../../utils/versions.js';\nimport type { TsMcpServerGeneratorSchema, TsMcpServerInfra } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsMcpServerMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n /**\n * How this component is packaged and hosted, so a consumer can tell a\n * code-packaged runtime from a container-packaged one without re-deriving it.\n */\n readonly infra: TsMcpServerInfra;\n}\n\nexport const DEPENDENCIES = declareDependencies<TsMcpServerMetadata>()({\n ts: [\n { name: '@modelcontextprotocol/sdk' },\n { name: 'zod' },\n { name: 'express' },\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@types/express', dev: true },\n // tsx (local dev) and the MCP inspector are shared tooling.\n { name: 'tsx', dev: true, root: true },\n { name: '@modelcontextprotocol/inspector', dev: true, root: true },\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(NODE_IMAGE_DEPENDENCIES),\n ...ownedElsewhere(ADOT_IMAGE_DEPENDENCIES),\n ...ownedElsewhere(CODE_PACKAGE_DEPENDENCIES),\n ],\n py: ownedElsewhere(AGENT_CORE_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const TS_MCP_SERVER_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsMcpServerGenerator = async (\n tree: Tree,\n options: TsMcpServerGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n if (!tree.exists(joinPathFragments(project.root, 'tsconfig.json'))) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a TypeScript project (with a tsconfig.json)`,\n );\n }\n\n const defaultName = `${kebabCase(project.name.split('/').pop())}-mcp-server`;\n const name = kebabCase(options.name || defaultName);\n const mcpServerNameClassName = toClassName(name);\n const mcpTargetPrefix = options.name ? name : 'mcp-server';\n const targetSourceDirRelativeToProjectRoot = joinPathFragments(\n 'src',\n mcpTargetPrefix,\n );\n const targetSourceDir = joinPathFragments(\n project.root,\n targetSourceDirRelativeToProjectRoot,\n );\n const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');\n const distDir = joinPathFragments('dist', project.root);\n\n const infra = options.infra ?? 'agentcore';\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 if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n const projectPackageJsonPath = joinPathFragments(\n project.root,\n 'package.json',\n );\n\n // Generate esm if the project's package.json is `type: module`, falling\n // back to the workspace format when the project has no manifest.\n const esm = tree.exists(projectPackageJsonPath)\n ? readJson(tree, projectPackageJsonPath).type === 'module'\n : isEsmWorkspace(tree);\n\n const templateContext = {\n name,\n esm,\n distDir,\n adotVersion:\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],\n jaegerVersion: TS_VERSIONS['@opentelemetry/propagator-jaeger'],\n nodeBaseImage: BASE_IMAGES.node,\n ...nodeImageVersions(),\n };\n\n // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'app'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add hosting based on infra\n if (isAgentCoreHosted(infra)) {\n const container = isContainerHosted(infra);\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n await addTypeScriptBundleTarget(\n tree,\n project,\n {\n targetFilePath: `${targetSourceDirRelativeToProjectRoot}/http.ts`,\n bundleOutputDir: joinPathFragments('mcp', name),\n },\n DEPENDENCIES,\n );\n\n const bundleOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'mcp',\n name,\n );\n\n let artifact: AgentCoreArtifact;\n\n if (container) {\n // Add the Dockerfile\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: IMAGE_BUILD_CACHE,\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${bundleOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${bundleOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addArtifactDependencyToTargets(project, 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project,\n containerEngine: containers,\n trivyTargetName: `${mcpTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n },\n DEPENDENCIES,\n );\n\n artifact = {\n type: 'container',\n dockerImageTag,\n outputDir: bundleOutputDir,\n };\n } else {\n const packageOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'package',\n 'mcp',\n name,\n );\n addTypeScriptCodePackageTarget(\n tree,\n {\n project,\n targetName: `${mcpTargetPrefix}-package`,\n bundleTargetName: 'bundle',\n bundleOutputDir,\n packageOutputDir,\n },\n DEPENDENCIES,\n );\n\n artifact = {\n type: 'code',\n outputDir: packageOutputDir,\n runtime: agentCoreNodeRuntime(),\n entryPoint: 'index.js',\n };\n }\n\n // Add shared constructs\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n\n // Add the construct to deploy the mcp server\n await addMcpServerInfra(tree, {\n mcpServerNameKebabCase: name,\n mcpServerNameClassName,\n projectName: project.name,\n artifact,\n iac,\n auth,\n containers,\n });\n }\n\n // @modelcontextprotocol/sdk declares zod as a peer dependency with a wide range\n // (^3.25 || ^4.0). Yarn does not dedupe the peer to the workspace's pinned zod, so\n // without a resolution it installs a separate zod under the SDK's own node_modules.\n // The two zod copies have structurally incompatible types, which breaks type\n // inference for registerTool inputSchema. Scope the resolution to the SDK so\n // other consumers (e.g. @tanstack/router-generator pinning zod@3) are unaffected.\n // Classic yarn only honours the `**/`-prefixed descriptor in a workspace, and\n // berry only the bare one — it deletes a glob descriptor on install — so\n // declare both.\n if (detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@modelcontextprotocol/sdk/zod': TS_VERSIONS['zod'],\n '@modelcontextprotocol/sdk/zod': TS_VERSIONS['zod'],\n };\n return packageJson;\n });\n }\n\n const localDevPort = assignPort(tree, project, 8000, {\n component: { info: TS_MCP_SERVER_GENERATOR_INFO, name: mcpTargetPrefix },\n });\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: TsMcpServerMetadata = {\n infra,\n port: localDevPort,\n rc: mcpServerNameClassName,\n auth,\n ...(iac ? { iac } : {}),\n };\n\n // The MCP inspector has a postinstall script that cascades installs into its\n // client packages, which no-ops when the package is installed as a dependency.\n // Register it as an explicitly-rejected build so pnpm 11's default\n // `strictDepBuilds=true` skips it instead of failing the install.\n registerPnpmBuiltDependencies(tree, {\n '@modelcontextprotocol/inspector': false,\n });\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n\n const mcpTargets = {\n ...project.targets,\n // Add targets for running the MCP server\n [`${mcpTargetPrefix}-serve-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/stdio.ts`],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${mcpTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${mcpTargetPrefix}-inspect`]: {\n executor: 'nx:run-commands',\n continuous: true,\n // Launch the inspector against the locally served HTTP server. The dev\n // target starts the server and any connected dependencies (e.g. a local\n // database).\n dependsOn: [`${mcpTargetPrefix}-dev`],\n options: {\n commands: [\n `mcp-inspector --transport http --server-url http://localhost:${localDevPort}/mcp`,\n ],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-inspect-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `mcp-inspector -- tsx --watch ${relativeSourceDir}/stdio.ts`,\n ],\n cwd: '{projectRoot}',\n },\n },\n };\n\n // Aggregate `<mcp>-dev` under the project-level `dev` target.\n addComponentDevTarget(mcpTargets, `${mcpTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n // Sort targets so their order is stable regardless of insertion order on\n // first run vs re-run.\n targets: sortObjectKeys(mcpTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n TS_MCP_SERVER_GENERATOR_INFO,\n targetSourceDirRelativeToProjectRoot,\n mcpTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_MCP_SERVER_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsMcpServerGenerator;\n"],"names":["detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readJson","updateJson","updateProjectConfiguration","addTsDependencies","AGENT_CORE_CONSTRUCTS_PY_DEPENDENCIES","addMcpServerInfra","addTypeScriptCodePackageTarget","agentCoreNodeRuntime","CODE_PACKAGE_DEPENDENCIES","isAgentCoreHosted","isContainerHosted","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","ADOT_IMAGE_DEPENDENCIES","addDockerScanTarget","DOCKER_DEPENDENCIES","IMAGE_BUILD_CACHE","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","kebabCase","toClassName","getNpmScope","addArtifactDependencyToTargets","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","registerPnpmBuiltDependencies","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","TS_VERSIONS","DEPENDENCIES","ts","name","dev","root","py","TS_MCP_SERVER_GENERATOR_INFO","filename","tsMcpServerGenerator","tree","options","project","exists","Error","defaultName","split","pop","mcpServerNameClassName","mcpTargetPrefix","targetSourceDirRelativeToProjectRoot","targetSourceDir","relativeSourceDir","replace","distDir","infra","iac","undefined","auth","console","warn","projectPackageJsonPath","esm","type","templateContext","adotVersion","jaegerVersion","nodeBaseImage","node","dirname","overwriteStrategy","KeepExisting","container","containers","dockerImageTag","targetFilePath","bundleOutputDir","artifact","dockerTargetName","fs","targets","cache","executor","commands","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","outputDir","packageOutputDir","targetName","bundleTargetName","runtime","entryPoint","mcpServerNameKebabCase","projectName","packageJson","resolutions","localDevPort","component","info","metadata","port","rc","projectRoot","mcpTargets","continuous","cwd","env","PORT","LOCAL_DEV","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC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plugin/src/ts/mcp-server/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport {\n AGENT_CORE_CONSTRUCTS_PY_DEPENDENCIES,\n type AgentCoreArtifact,\n addMcpServerInfra,\n} from '../../utils/agent-core-constructs/agent-core-constructs.js';\nimport {\n addTypeScriptCodePackageTarget,\n agentCoreNodeRuntime,\n CODE_PACKAGE_DEPENDENCIES,\n isAgentCoreHosted,\n isContainerHosted,\n} from '../../utils/agent-core-packaging.js';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle.js';\nimport { resolveContainers } from '../../utils/containers.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport {\n ADOT_IMAGE_DEPENDENCIES,\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n IMAGE_BUILD_CACHE,\n NODE_IMAGE_DEPENDENCIES,\n nodeImageVersions,\n} from '../../utils/docker.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport { kebabCase, toClassName } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addArtifactDependencyToTargets,\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace.js';\nimport { assignPort } from '../../utils/port.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants.js';\nimport { BASE_IMAGES, TS_VERSIONS } from '../../utils/versions.js';\nimport type { TsMcpServerGeneratorSchema, TsMcpServerInfra } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsMcpServerMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n /**\n * How this component is packaged and hosted, so a consumer can tell a\n * code-packaged runtime from a container-packaged one without re-deriving it.\n */\n readonly infra: TsMcpServerInfra;\n}\n\nexport const DEPENDENCIES = declareDependencies<TsMcpServerMetadata>()({\n ts: [\n { name: '@modelcontextprotocol/sdk' },\n { name: 'zod' },\n { name: 'express' },\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@types/express', dev: true },\n // tsx (local dev) and the MCP inspector are shared tooling.\n { name: 'tsx', dev: true, root: true },\n { name: '@modelcontextprotocol/inspector', dev: true, root: true },\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(NODE_IMAGE_DEPENDENCIES),\n ...ownedElsewhere(ADOT_IMAGE_DEPENDENCIES),\n ...ownedElsewhere(CODE_PACKAGE_DEPENDENCIES),\n ],\n py: ownedElsewhere(AGENT_CORE_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const TS_MCP_SERVER_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsMcpServerGenerator = async (\n tree: Tree,\n options: TsMcpServerGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n if (!tree.exists(joinPathFragments(project.root, 'tsconfig.json'))) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a TypeScript project (with a tsconfig.json)`,\n );\n }\n\n const defaultName = `${kebabCase(project.name.split('/').pop())}-mcp-server`;\n const name = kebabCase(options.name || defaultName);\n const mcpServerNameClassName = toClassName(name);\n const mcpTargetPrefix = options.name ? name : 'mcp-server';\n const targetSourceDirRelativeToProjectRoot = joinPathFragments(\n 'src',\n mcpTargetPrefix,\n );\n const targetSourceDir = joinPathFragments(\n project.root,\n targetSourceDirRelativeToProjectRoot,\n );\n const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');\n const distDir = joinPathFragments('dist', project.root);\n\n const infra = options.infra ?? 'agentcore';\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 if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n const projectPackageJsonPath = joinPathFragments(\n project.root,\n 'package.json',\n );\n\n // Generate esm if the project's package.json is `type: module`, falling\n // back to the workspace format when the project has no manifest.\n const esm = tree.exists(projectPackageJsonPath)\n ? readJson(tree, projectPackageJsonPath).type === 'module'\n : isEsmWorkspace(tree);\n\n const templateContext = {\n name,\n esm,\n distDir,\n adotVersion:\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],\n jaegerVersion: TS_VERSIONS['@opentelemetry/propagator-jaeger'],\n nodeBaseImage: BASE_IMAGES.node,\n ...nodeImageVersions(),\n };\n\n // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'app'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add hosting based on infra\n if (isAgentCoreHosted(infra)) {\n const container = isContainerHosted(infra);\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n await addTypeScriptBundleTarget(\n tree,\n project,\n {\n targetFilePath: `${targetSourceDirRelativeToProjectRoot}/http.ts`,\n bundleOutputDir: joinPathFragments('mcp', name),\n },\n DEPENDENCIES,\n );\n\n const bundleOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'mcp',\n name,\n );\n\n let artifact: AgentCoreArtifact;\n\n if (container) {\n // Add the Dockerfile\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: IMAGE_BUILD_CACHE,\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cpFile(\n `${targetSourceDir}/Dockerfile`,\n `${bundleOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${bundleOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addArtifactDependencyToTargets(project, 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project,\n containerEngine: containers,\n trivyTargetName: `${mcpTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n },\n DEPENDENCIES,\n );\n\n artifact = {\n type: 'container',\n dockerImageTag,\n outputDir: bundleOutputDir,\n };\n } else {\n const packageOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'package',\n 'mcp',\n name,\n );\n addTypeScriptCodePackageTarget(\n tree,\n {\n project,\n targetName: `${mcpTargetPrefix}-package`,\n bundleTargetName: 'bundle',\n bundleOutputDir,\n packageOutputDir,\n },\n DEPENDENCIES,\n );\n\n artifact = {\n type: 'code',\n outputDir: packageOutputDir,\n runtime: agentCoreNodeRuntime(),\n entryPoint: 'index.js',\n };\n }\n\n // Add shared constructs\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n\n // Add the construct to deploy the mcp server\n await addMcpServerInfra(tree, {\n mcpServerNameKebabCase: name,\n mcpServerNameClassName,\n projectName: project.name,\n artifact,\n iac,\n auth,\n containers,\n });\n }\n\n // @modelcontextprotocol/sdk declares zod as a peer dependency with a wide range\n // (^3.25 || ^4.0). Yarn does not dedupe the peer to the workspace's pinned zod, so\n // without a resolution it installs a separate zod under the SDK's own node_modules.\n // The two zod copies have structurally incompatible types, which breaks type\n // inference for registerTool inputSchema. Scope the resolution to the SDK so\n // other consumers (e.g. @tanstack/router-generator pinning zod@3) are unaffected.\n // Classic yarn only honours the `**/`-prefixed descriptor in a workspace, and\n // berry only the bare one — it deletes a glob descriptor on install — so\n // declare both.\n if (detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@modelcontextprotocol/sdk/zod': TS_VERSIONS['zod'],\n '@modelcontextprotocol/sdk/zod': TS_VERSIONS['zod'],\n };\n return packageJson;\n });\n }\n\n const localDevPort = assignPort(tree, project, 8000, {\n component: { info: TS_MCP_SERVER_GENERATOR_INFO, name: mcpTargetPrefix },\n });\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: TsMcpServerMetadata = {\n infra,\n port: localDevPort,\n rc: mcpServerNameClassName,\n auth,\n ...(iac ? { iac } : {}),\n };\n\n // The MCP inspector has a postinstall script that cascades installs into its\n // client packages, which no-ops when the package is installed as a dependency.\n // Register it as an explicitly-rejected build so pnpm 11's default\n // `strictDepBuilds=true` skips it instead of failing the install.\n registerPnpmBuiltDependencies(tree, {\n '@modelcontextprotocol/inspector': false,\n });\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n\n const mcpTargets = {\n ...project.targets,\n // Add targets for running the MCP server\n [`${mcpTargetPrefix}-serve-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/stdio.ts`],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${mcpTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${mcpTargetPrefix}-inspect`]: {\n executor: 'nx:run-commands',\n continuous: true,\n // Launch the inspector against the locally served HTTP server. The dev\n // target starts the server and any connected dependencies (e.g. a local\n // database).\n dependsOn: [`${mcpTargetPrefix}-dev`],\n options: {\n commands: [\n `mcp-inspector --transport http --server-url http://localhost:${localDevPort}/mcp`,\n ],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-inspect-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `mcp-inspector -- tsx --watch ${relativeSourceDir}/stdio.ts`,\n ],\n cwd: '{projectRoot}',\n },\n },\n };\n\n // Aggregate `<mcp>-dev` under the project-level `dev` target.\n addComponentDevTarget(mcpTargets, `${mcpTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n // Sort targets so their order is stable regardless of insertion order on\n // first run vs re-run.\n targets: sortObjectKeys(mcpTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n TS_MCP_SERVER_GENERATOR_INFO,\n targetSourceDirRelativeToProjectRoot,\n mcpTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_MCP_SERVER_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsMcpServerGenerator;\n"],"names":["detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readJson","updateJson","updateProjectConfiguration","addTsDependencies","AGENT_CORE_CONSTRUCTS_PY_DEPENDENCIES","addMcpServerInfra","addTypeScriptCodePackageTarget","agentCoreNodeRuntime","CODE_PACKAGE_DEPENDENCIES","isAgentCoreHosted","isContainerHosted","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","ADOT_IMAGE_DEPENDENCIES","addDockerScanTarget","DOCKER_DEPENDENCIES","IMAGE_BUILD_CACHE","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","kebabCase","toClassName","getNpmScope","addArtifactDependencyToTargets","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","registerPnpmBuiltDependencies","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","TS_VERSIONS","DEPENDENCIES","ts","name","dev","root","py","TS_MCP_SERVER_GENERATOR_INFO","filename","tsMcpServerGenerator","tree","options","project","exists","Error","defaultName","split","pop","mcpServerNameClassName","mcpTargetPrefix","targetSourceDirRelativeToProjectRoot","targetSourceDir","relativeSourceDir","replace","distDir","infra","iac","undefined","auth","console","warn","projectPackageJsonPath","esm","type","templateContext","adotVersion","jaegerVersion","nodeBaseImage","node","dirname","overwriteStrategy","KeepExisting","container","containers","dockerImageTag","targetFilePath","bundleOutputDir","artifact","dockerTargetName","fs","targets","cache","executor","commands","cpFile","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","outputDir","packageOutputDir","targetName","bundleTargetName","runtime","entryPoint","mcpServerNameKebabCase","projectName","packageJson","resolutions","localDevPort","component","info","metadata","port","rc","projectRoot","mcpTargets","continuous","cwd","env","PORT","LOCAL_DEV","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SACEC,qCAAqC,EAErCC,iBAAiB,QACZ,6DAA6D;AACpE,SACEC,8BAA8B,EAC9BC,oBAAoB,EACpBC,yBAAyB,EACzBC,iBAAiB,EACjBC,iBAAiB,QACZ,sCAAsC;AAC7C,SACEC,yBAAyB,EACzBC,mBAAmB,QACd,+BAA+B;AACtC,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SACEC,uBAAuB,EACvBC,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB,QACZ,wBAAwB;AAC/B,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAoB;AAChE,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,SAAS,EAAEC,WAAW,QAAQ,uBAAuB;AAC9D,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,wBAA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E,uBAAuB;QACvBsC,SAASxD,eAAemF;IAC1B;IAEAvF,8BACEoB,MACAE,QAAQT,IAAI,EACZI,8BACAa,sCACAD,iBACAsD;IAGF,MAAM1F,gCAAgC2B,MAAM;QAACH;KAA6B;IAE1E,MAAM7B,qBAAqBgC;IAC3B,OAAO,IACL5B,oBAAoB4B,MAAMC,QAAQwE,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe3E,qBAAqB"}
|
|
@@ -6,7 +6,7 @@ import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
|
6
6
|
import type { TsNxGeneratorGeneratorSchema } from './schema';
|
|
7
7
|
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
8
8
|
readonly name: "@nx/devkit";
|
|
9
|
-
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "
|
|
9
|
+
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
10
10
|
export declare const NX_GENERATOR_GENERATOR_INFO: import("../../utils/generators").GeneratorInfo;
|
|
11
11
|
export declare const tsNxGeneratorGenerator: (tree: Tree, options: TsNxGeneratorGeneratorSchema) => Promise<GeneratorCallback | void>;
|
|
12
12
|
export default tsNxGeneratorGenerator;
|
|
@@ -7,7 +7,7 @@ import { type NxGeneratorInfo } from '../../utils/nx.js';
|
|
|
7
7
|
import type { TsNxMigrationGeneratorSchema } from './schema';
|
|
8
8
|
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
9
9
|
readonly name: "@nx/devkit";
|
|
10
|
-
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "
|
|
10
|
+
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
11
11
|
export declare const NX_MIGRATION_GENERATOR_INFO: NxGeneratorInfo;
|
|
12
12
|
/**
|
|
13
13
|
* Scaffolds a migration in an Nx Plugin project and registers it in the
|
|
@@ -7,7 +7,7 @@ import { type NxGeneratorInfo } from '../../utils/nx.js';
|
|
|
7
7
|
import type { TsNxPluginGeneratorSchema } from './schema';
|
|
8
8
|
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
9
9
|
readonly name: "@nx/devkit";
|
|
10
|
-
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "
|
|
10
|
+
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
11
11
|
export declare const TS_NX_PLUGIN_GENERATOR_INFO: NxGeneratorInfo;
|
|
12
12
|
export declare const tsNxPluginGenerator: (tree: Tree, options: TsNxPluginGeneratorSchema) => Promise<GeneratorCallback>;
|
|
13
13
|
export default tsNxPluginGenerator;
|
|
@@ -48,35 +48,11 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js"
|
|
|
48
48
|
} & {
|
|
49
49
|
versionOnly: true;
|
|
50
50
|
}, {
|
|
51
|
-
readonly name: "
|
|
51
|
+
readonly name: "shx";
|
|
52
52
|
} & {
|
|
53
53
|
versionOnly: true;
|
|
54
54
|
}, {
|
|
55
|
-
readonly name: "
|
|
56
|
-
} & {
|
|
57
|
-
versionOnly: true;
|
|
58
|
-
}, {
|
|
59
|
-
readonly name: "make-dir-cli";
|
|
60
|
-
} & {
|
|
61
|
-
versionOnly: true;
|
|
62
|
-
}, {
|
|
63
|
-
readonly name: "cpy-cli";
|
|
64
|
-
} & {
|
|
65
|
-
versionOnly: true;
|
|
66
|
-
}, {
|
|
67
|
-
readonly name: "ncp";
|
|
68
|
-
} & {
|
|
69
|
-
versionOnly: true;
|
|
70
|
-
}, {
|
|
71
|
-
readonly name: "rimraf";
|
|
72
|
-
} & {
|
|
73
|
-
versionOnly: true;
|
|
74
|
-
}, {
|
|
75
|
-
readonly name: "make-dir-cli";
|
|
76
|
-
} & {
|
|
77
|
-
versionOnly: true;
|
|
78
|
-
}, {
|
|
79
|
-
readonly name: "cpy-cli";
|
|
55
|
+
readonly name: "shx";
|
|
80
56
|
} & {
|
|
81
57
|
versionOnly: true;
|
|
82
58
|
}, {
|
|
@@ -117,7 +93,7 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js"
|
|
|
117
93
|
readonly name: "minimatch";
|
|
118
94
|
} & {
|
|
119
95
|
versionOnly: true;
|
|
120
|
-
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "
|
|
96
|
+
}], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", TsRdbMetadata>[]>;
|
|
121
97
|
export declare const TS_RDB_GENERATOR_INFO: NxGeneratorInfo;
|
|
122
98
|
export declare const tsRdbGenerator: (tree: Tree, options: TsRdbGeneratorSchema) => Promise<GeneratorCallback>;
|
|
123
99
|
export default tsRdbGenerator;
|
package/src/ts/rdb/generator.js
CHANGED
|
@@ -210,9 +210,9 @@ export const tsRdbGenerator = async (tree, options)=>{
|
|
|
210
210
|
commands: [
|
|
211
211
|
fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),
|
|
212
212
|
fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),
|
|
213
|
-
fs.
|
|
214
|
-
fs.
|
|
215
|
-
fs.
|
|
213
|
+
fs.cpDir('prisma', `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`),
|
|
214
|
+
fs.cpFile('prisma.config.ts', `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`),
|
|
215
|
+
fs.cpFile('Dockerfile', `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`),
|
|
216
216
|
rolldownCommand
|
|
217
217
|
],
|
|
218
218
|
parallel: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport { addStarExport } from '../../utils/ast.js';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle.js';\nimport { resolveContainers } from '../../utils/containers.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport {\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n IMAGE_BUILD_CACHE,\n NODE_IMAGE_DEPENDENCIES,\n nodeImageVersions,\n} from '../../utils/docker.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { updateGitIgnore } from '../../utils/git.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { esmVars } from '../../utils/module-format.js';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addArtifactDependencyToTargets,\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx.js';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths.js';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace.js';\nimport { assignPort } from '../../utils/port.js';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants.js';\nimport {\n SHARED_RDB_SCRIPTS_DEPENDENCIES,\n sharedRdbScriptsGenerator,\n} from '../../utils/shared-rdb-scripts.js';\nimport { TS_VERSIONS } from '../../utils/versions.js';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator.js';\nimport type { TsRdbGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsRdbMetadata extends IacMetadata {\n readonly engine: TsRdbGeneratorSchema['engine'];\n}\n\n// Each entry names the engine branch it belongs to, so the same declaration\n// drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsRdbMetadata>()({\n ts: [\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@aws-sdk/client-secrets-manager' },\n { name: '@aws-sdk/rds-signer' },\n { name: '@prisma/client' },\n { name: '@prisma/adapter-mariadb', when: (m) => m.engine === 'mysql' },\n { name: 'mariadb', when: (m) => m.engine === 'mysql' },\n { name: '@prisma/adapter-pg', when: (m) => m.engine !== 'mysql' },\n { name: 'pg', when: (m) => m.engine !== 'mysql' },\n { name: '@types/aws-lambda', dev: true },\n { name: '@types/pg', when: (m) => m.engine !== 'mysql', dev: true },\n // The prisma CLI and tsx run migration/seed scripts from the root.\n { name: 'prisma', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_RDB_SCRIPTS_DEPENDENCIES),\n ...ownedElsewhere(NODE_IMAGE_DEPENDENCIES),\n ],\n});\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n ...nodeImageVersions(),\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n // The Prisma schema and models, the handlers and the prisma client module are\n // all user-editable, so a re-run (to add infrastructure, or after a failed\n // run) must not clobber the user's schema and edits.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The barrel re-exports prisma.ts. `tsProjectGenerator` writes a stub index.ts\n // when it creates the project, so the re-export is added to whatever is there\n // rather than replacing it — which also leaves a user's own additions to the\n // barrel alone on a re-run.\n await addStarExport(\n tree,\n joinPathFragments(dir, 'src', 'index.ts'),\n './prisma.js',\n );\n\n // config.json is framework-owned: it carries values derived from the\n // generator's options, so it converges on a re-run with changed options.\n writeJson(tree, joinPathFragments(dir, 'config.json'), {\n runtimeConfigKey: nameClassName,\n localDev: {\n containerEngine,\n containerName,\n image: dockerImage,\n port: localDbPort,\n host: localDbHost,\n dbName: databaseName,\n dbUser: localDbUser,\n dbPassword: localDbPassword,\n dbEngine: options.engine,\n },\n });\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine, DEPENDENCIES);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree, DEPENDENCIES);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n },\n DEPENDENCIES,\n );\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n },\n DEPENDENCIES,\n );\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cp(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cp(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cp(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n dependsOn: ['pull-image'],\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n // Recorded in the metadata below so the version sync can tell a CDK project\n // from a Terraform one; undefined when no infrastructure was generated, in\n // which case neither provider's packages were added.\n const iac =\n options.infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (options.infra !== 'none') {\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: IMAGE_BUILD_CACHE,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addArtifactDependencyToTargets(projectConfig, 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n },\n DEPENDENCIES,\n );\n }\n addArtifactDependencyToTargets(projectConfig, 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsRdbMetadata = {\n engine: options.engine,\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n TS_RDB_GENERATOR_INFO,\n metadata,\n );\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: projectConfig.root,\n });\n\n // @prisma/adapter-pg depends on @types/pg ^8.16.0. Yarn does not dedupe it to\n // the workspace's pinned @types/pg, so it installs a separate copy under the\n // adapter's own node_modules whenever a newer @types/pg is published. The two\n // copies declare structurally incompatible Pool types, so passing our `new\n // Pool(...)` to `new PrismaPg(...)` fails to compile. Scope the resolution to\n // the adapter so other @types/pg consumers are unaffected. Classic yarn only\n // honours the `**/`-prefixed descriptor in a workspace and berry only the\n // bare one, so declare both.\n if (options.engine === 'postgres' && detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n '@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n };\n return packageJson;\n });\n }\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","writeJson","addTsDependencies","addStarExport","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","IMAGE_BUILD_CACHE","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addArtifactDependencyToTargets","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","SHARED_RDB_SCRIPTS_DEPENDENCIES","sharedRdbScriptsGenerator","TS_VERSIONS","tsProjectGenerator","getTsLibDetails","DEPENDENCIES","ts","name","when","m","engine","dev","root","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","overwriteStrategy","KeepExisting","localDev","image","port","host","dbName","dbUser","dbPassword","dbEngine","patterns","waitForDbScript","scriptsDir","relativePathToRoot","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","dependsOn","continuous","env","LOCAL_DEV","iac","undefined","cache","project","trivyTargetName","dockerTargetName","imageTags","metadata","projectName","projectRoot","adminUser","createDbUserBundleD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KAAK,QAAQ;QAC5B,MAAMoB,MAAM,MAAMzG,WAAWoC,MAAMC,QAAQoE,GAAG;QAC9C,MAAMxF,0BAA0BmB,MAAM;YAAEqE;QAAI,GAAGhF;QAC/C,MAAMV,YAAYqB,MAAM;YACtBqE;YACAQ,aAAatE;YACbuE,aAAatE;YACbL;YACAD;YACAsB,sBAAsBjB;YACtBF;YACA0E,WAAW3E;YACXV,QAAQO,QAAQP,MAAM;YACtBqD;YACAiC,uBAAuB1I,kBACrB,QACAyE,cAAcnB,IAAI,EAClB,UACA;YAEFqF,WAAWhF,QAAQgF,SAAS;YAC5BjC;YACA1C;QACF;IACF;IAEA1D,kBAAkBoD,MAAMX,cAAc;QACpCuF;QACAE,aAAa/D,cAAcnB,IAAI;IACjC;IAEA,8EAA8E;IAC9E,6EAA6E;IAC7E,8EAA8E;IAC9E,2EAA2E;IAC3E,8EAA8E;IAC9E,6EAA6E;IAC7E,0EAA0E;IAC1E,6BAA6B;IAC7B,IAAIK,QAAQP,MAAM,KAAK,cAActD,2BAA2B,QAAQ;QACtEK,WAAWuD,MAAM,gBAAgB,CAACkF;YAChCA,YAAYC,WAAW,GAAG;gBACxB,GAAGD,YAAYC,WAAW;gBAC1B,mCAAmCjG,WAAW,CAAC,YAAY;gBAC3D,gCAAgCA,WAAW,CAAC,YAAY;YAC1D;YACA,OAAOgG;QACT;IACF;IAEAzG,8BAA8BuB,MAAM;QAClC,mBAAmB;QACnB2B,QAAQ;IACV;IAEA,MAAM7D,gCAAgCkC,MAAM;QAACH;KAAsB;IAEnE,MAAMrC,qBAAqBwC;IAC3B,OAAO,IACLnC,oBAAoBmC,MAAMC,QAAQW,yBAAyB,EAAE;YAC3DwE,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAerF,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport { addStarExport } from '../../utils/ast.js';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle.js';\nimport { resolveContainers } from '../../utils/containers.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport {\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n IMAGE_BUILD_CACHE,\n NODE_IMAGE_DEPENDENCIES,\n nodeImageVersions,\n} from '../../utils/docker.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { updateGitIgnore } from '../../utils/git.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { esmVars } from '../../utils/module-format.js';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addArtifactDependencyToTargets,\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx.js';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths.js';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace.js';\nimport { assignPort } from '../../utils/port.js';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants.js';\nimport {\n SHARED_RDB_SCRIPTS_DEPENDENCIES,\n sharedRdbScriptsGenerator,\n} from '../../utils/shared-rdb-scripts.js';\nimport { TS_VERSIONS } from '../../utils/versions.js';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator.js';\nimport type { TsRdbGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsRdbMetadata extends IacMetadata {\n readonly engine: TsRdbGeneratorSchema['engine'];\n}\n\n// Each entry names the engine branch it belongs to, so the same declaration\n// drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsRdbMetadata>()({\n ts: [\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@aws-sdk/client-secrets-manager' },\n { name: '@aws-sdk/rds-signer' },\n { name: '@prisma/client' },\n { name: '@prisma/adapter-mariadb', when: (m) => m.engine === 'mysql' },\n { name: 'mariadb', when: (m) => m.engine === 'mysql' },\n { name: '@prisma/adapter-pg', when: (m) => m.engine !== 'mysql' },\n { name: 'pg', when: (m) => m.engine !== 'mysql' },\n { name: '@types/aws-lambda', dev: true },\n { name: '@types/pg', when: (m) => m.engine !== 'mysql', dev: true },\n // The prisma CLI and tsx run migration/seed scripts from the root.\n { name: 'prisma', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_RDB_SCRIPTS_DEPENDENCIES),\n ...ownedElsewhere(NODE_IMAGE_DEPENDENCIES),\n ],\n});\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n ...nodeImageVersions(),\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n // The Prisma schema and models, the handlers and the prisma client module are\n // all user-editable, so a re-run (to add infrastructure, or after a failed\n // run) must not clobber the user's schema and edits.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The barrel re-exports prisma.ts. `tsProjectGenerator` writes a stub index.ts\n // when it creates the project, so the re-export is added to whatever is there\n // rather than replacing it — which also leaves a user's own additions to the\n // barrel alone on a re-run.\n await addStarExport(\n tree,\n joinPathFragments(dir, 'src', 'index.ts'),\n './prisma.js',\n );\n\n // config.json is framework-owned: it carries values derived from the\n // generator's options, so it converges on a re-run with changed options.\n writeJson(tree, joinPathFragments(dir, 'config.json'), {\n runtimeConfigKey: nameClassName,\n localDev: {\n containerEngine,\n containerName,\n image: dockerImage,\n port: localDbPort,\n host: localDbHost,\n dbName: databaseName,\n dbUser: localDbUser,\n dbPassword: localDbPassword,\n dbEngine: options.engine,\n },\n });\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine, DEPENDENCIES);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree, DEPENDENCIES);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n },\n DEPENDENCIES,\n );\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n },\n DEPENDENCIES,\n );\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cpDir(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cpFile(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cpFile(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n dependsOn: ['pull-image'],\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n // Recorded in the metadata below so the version sync can tell a CDK project\n // from a Terraform one; undefined when no infrastructure was generated, in\n // which case neither provider's packages were added.\n const iac =\n options.infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (options.infra !== 'none') {\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: IMAGE_BUILD_CACHE,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addArtifactDependencyToTargets(projectConfig, 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n },\n DEPENDENCIES,\n );\n }\n addArtifactDependencyToTargets(projectConfig, 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsRdbMetadata = {\n engine: options.engine,\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n TS_RDB_GENERATOR_INFO,\n metadata,\n );\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: projectConfig.root,\n });\n\n // @prisma/adapter-pg depends on @types/pg ^8.16.0. Yarn does not dedupe it to\n // the workspace's pinned @types/pg, so it installs a separate copy under the\n // adapter's own node_modules whenever a newer @types/pg is published. The two\n // copies declare structurally incompatible Pool types, so passing our `new\n // Pool(...)` to `new PrismaPg(...)` fails to compile. Scope the resolution to\n // the adapter so other @types/pg consumers are unaffected. Classic yarn only\n // honours the `**/`-prefixed descriptor in a workspace and berry only the\n // bare one, so declare both.\n if (options.engine === 'postgres' && detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n '@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n };\n return packageJson;\n });\n }\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","writeJson","addTsDependencies","addStarExport","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","IMAGE_BUILD_CACHE","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addArtifactDependencyToTargets","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","SHARED_RDB_SCRIPTS_DEPENDENCIES","sharedRdbScriptsGenerator","TS_VERSIONS","tsProjectGenerator","getTsLibDetails","DEPENDENCIES","ts","name","when","m","engine","dev","root","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","overwriteStrategy","KeepExisting","localDev","image","port","host","dbName","dbUser","dbPassword","dbEngine","patterns","waitForDbScript","scriptsDir","relativePathToRoot","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cpDir","cpFile","parallel","generate","executor","outputs","cwd","dependsOn","continuous","env","LOCAL_DEV","iac","undefined","cache","project","trivyTargetName","dockerTargetName","imageTags","metadata","projectName","projectRoot","adminUser","createDbUserBundleDir","framework","packageJson","resolutions","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,EAC1BC,SAAS,QACJ,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SACEC,yBAAyB,EACzBC,mBAAmB,QACd,+BAA+B;AACtC,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SACEC,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,EACjBC,uBAAuB,EACvBC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9E,6EAA6E;IAC7E,8EAA8E;IAC9E,2EAA2E;IAC3E,8EAA8E;IAC9E,6EAA6E;IAC7E,0EAA0E;IAC1E,6BAA6B;IAC7B,IAAIK,QAAQP,MAAM,KAAK,cAActD,2BAA2B,QAAQ;QACtEK,WAAWuD,MAAM,gBAAgB,CAACmF;YAChCA,YAAYC,WAAW,GAAG;gBACxB,GAAGD,YAAYC,WAAW;gBAC1B,mCAAmClG,WAAW,CAAC,YAAY;gBAC3D,gCAAgCA,WAAW,CAAC,YAAY;YAC1D;YACA,OAAOiG;QACT;IACF;IAEA1G,8BAA8BuB,MAAM;QAClC,mBAAmB;QACnB2B,QAAQ;IACV;IAEA,MAAM7D,gCAAgCkC,MAAM;QAACH;KAAsB;IAEnE,MAAMrC,qBAAqBwC;IAC3B,OAAO,IACLnC,oBAAoBmC,MAAMC,QAAQW,yBAAyB,EAAE;YAC3DyE,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAetF,eAAe"}
|
|
@@ -81,7 +81,7 @@ export declare const DEPENDENCIES: import("../../../utils/declared-dependencies.
|
|
|
81
81
|
readonly name: "@vitest/coverage-v8";
|
|
82
82
|
} & {
|
|
83
83
|
versionOnly: true;
|
|
84
|
-
}], readonly import("../../../utils/declared-dependencies.js").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "
|
|
84
|
+
}], readonly import("../../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "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" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", AgUiMetadata>[]>;
|
|
85
85
|
export type AgUiAuth = 'iam' | 'cognito' | 'none';
|
|
86
86
|
export type AgUiTheme = 'cloudscape' | 'shadcn' | 'default';
|
|
87
87
|
export interface AgUiReactConnectionOptions {
|
|
@@ -34,13 +34,7 @@ export declare const agentCorePythonRuntime: () => string;
|
|
|
34
34
|
* rather than any workspace manifest).
|
|
35
35
|
*/
|
|
36
36
|
export declare const CODE_PACKAGE_DEPENDENCIES: readonly [{
|
|
37
|
-
readonly name: "
|
|
38
|
-
}, {
|
|
39
|
-
readonly name: "rimraf";
|
|
40
|
-
}, {
|
|
41
|
-
readonly name: "make-dir-cli";
|
|
42
|
-
}, {
|
|
43
|
-
readonly name: "cpy-cli";
|
|
37
|
+
readonly name: "shx";
|
|
44
38
|
}, {
|
|
45
39
|
readonly name: "@aws/aws-distro-opentelemetry-node-autoinstrumentation";
|
|
46
40
|
}];
|
|
@@ -56,6 +50,20 @@ export interface AddTypeScriptCodePackageTargetOptions {
|
|
|
56
50
|
/** Directory to assemble the deployable package in, relative to the workspace root. */
|
|
57
51
|
readonly packageOutputDir: string;
|
|
58
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Name of the target that installs ADOT for the project's code packages. Every
|
|
55
|
+
* code package in a project vendors the same thing, so they share one.
|
|
56
|
+
*/
|
|
57
|
+
export declare const ADOT_VENDOR_TARGET_NAME = "agent-core-vendor";
|
|
58
|
+
/**
|
|
59
|
+
* Directory the vendor target installs into, relative to the workspace root.
|
|
60
|
+
*
|
|
61
|
+
* A sibling of the `package` directory rather than a path inside it: Nx replaces
|
|
62
|
+
* a cached target's whole declared output directory on restore, so an output
|
|
63
|
+
* nested inside another target's output would have each wipe the other's work on
|
|
64
|
+
* a cache hit.
|
|
65
|
+
*/
|
|
66
|
+
export declare const adotVendorDir: (projectRoot: string) => string;
|
|
59
67
|
/**
|
|
60
68
|
* Add a target assembling the deployable code package for a TypeScript
|
|
61
69
|
* AgentCore Runtime.
|
|
@@ -67,11 +75,16 @@ export interface AddTypeScriptCodePackageTargetOptions {
|
|
|
67
75
|
* being installed at runtime — the `opentelemetry-instrument` entry point
|
|
68
76
|
* prefix resolves it from there.
|
|
69
77
|
*
|
|
70
|
-
* The install is scoped to
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
78
|
+
* The install is scoped to its own directory with `--prefix` and `--no-save`, so
|
|
79
|
+
* it never touches the project's own manifest. `--omit=dev` keeps the package to
|
|
80
|
+
* what the runtime loads. ADOT is pure JavaScript with no native binaries, so the
|
|
81
|
+
* package is architecture independent even though AgentCore only runs arm64.
|
|
82
|
+
*
|
|
83
|
+
* Vendoring is a separate target so Nx caches it independently of the source. It
|
|
84
|
+
* depends on nothing but the pinned ADOT version, which the install command
|
|
85
|
+
* carries and Nx hashes as part of the target's configuration, so it declares no
|
|
86
|
+
* `inputs`: editing an agent replays a directory copy rather than re-running the
|
|
87
|
+
* install, while bumping the version still invalidates it.
|
|
75
88
|
*/
|
|
76
89
|
export declare const addTypeScriptCodePackageTarget: <const D extends DependencyDeclaration>(tree: Tree, options: AddTypeScriptCodePackageTargetOptions, declaration: D & MustDeclare<typeof CODE_PACKAGE_DEPENDENCIES, D>) => void;
|
|
77
90
|
export interface AddPythonCodePackageTargetOptions {
|
|
@@ -37,6 +37,18 @@ import { agentCoreRuntime, TS_VERSIONS } from "./versions.js";
|
|
|
37
37
|
name: '@aws/aws-distro-opentelemetry-node-autoinstrumentation'
|
|
38
38
|
}
|
|
39
39
|
];
|
|
40
|
+
/**
|
|
41
|
+
* Name of the target that installs ADOT for the project's code packages. Every
|
|
42
|
+
* code package in a project vendors the same thing, so they share one.
|
|
43
|
+
*/ export const ADOT_VENDOR_TARGET_NAME = 'agent-core-vendor';
|
|
44
|
+
/**
|
|
45
|
+
* Directory the vendor target installs into, relative to the workspace root.
|
|
46
|
+
*
|
|
47
|
+
* A sibling of the `package` directory rather than a path inside it: Nx replaces
|
|
48
|
+
* a cached target's whole declared output directory on restore, so an output
|
|
49
|
+
* nested inside another target's output would have each wipe the other's work on
|
|
50
|
+
* a cache hit.
|
|
51
|
+
*/ export const adotVendorDir = (projectRoot)=>joinPathFragments('dist', projectRoot, 'agent-core-vendor');
|
|
40
52
|
/**
|
|
41
53
|
* Add a target assembling the deployable code package for a TypeScript
|
|
42
54
|
* AgentCore Runtime.
|
|
@@ -48,16 +60,39 @@ import { agentCoreRuntime, TS_VERSIONS } from "./versions.js";
|
|
|
48
60
|
* being installed at runtime — the `opentelemetry-instrument` entry point
|
|
49
61
|
* prefix resolves it from there.
|
|
50
62
|
*
|
|
51
|
-
* The install is scoped to
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
63
|
+
* The install is scoped to its own directory with `--prefix` and `--no-save`, so
|
|
64
|
+
* it never touches the project's own manifest. `--omit=dev` keeps the package to
|
|
65
|
+
* what the runtime loads. ADOT is pure JavaScript with no native binaries, so the
|
|
66
|
+
* package is architecture independent even though AgentCore only runs arm64.
|
|
67
|
+
*
|
|
68
|
+
* Vendoring is a separate target so Nx caches it independently of the source. It
|
|
69
|
+
* depends on nothing but the pinned ADOT version, which the install command
|
|
70
|
+
* carries and Nx hashes as part of the target's configuration, so it declares no
|
|
71
|
+
* `inputs`: editing an agent replays a directory copy rather than re-running the
|
|
72
|
+
* install, while bumping the version still invalidates it.
|
|
56
73
|
*/ export const addTypeScriptCodePackageTarget = (tree, options, declaration)=>{
|
|
57
74
|
const { project, targetName, bundleTargetName, bundleOutputDir, packageOutputDir } = options;
|
|
58
75
|
const fs = new FsCommands(tree, forDependencies(declaration));
|
|
59
76
|
const adotVersion = TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'];
|
|
77
|
+
const vendorDir = adotVendorDir(project.root);
|
|
60
78
|
project.targets ??= {};
|
|
79
|
+
// Shared by every code package in the project, so only added once.
|
|
80
|
+
project.targets[ADOT_VENDOR_TARGET_NAME] ??= {
|
|
81
|
+
cache: true,
|
|
82
|
+
inputs: [],
|
|
83
|
+
outputs: [
|
|
84
|
+
`{workspaceRoot}/${vendorDir}`
|
|
85
|
+
],
|
|
86
|
+
executor: 'nx:run-commands',
|
|
87
|
+
options: {
|
|
88
|
+
commands: [
|
|
89
|
+
fs.rm(vendorDir),
|
|
90
|
+
fs.mkdir(vendorDir),
|
|
91
|
+
`npm install --prefix ${vendorDir} --no-save --no-audit --no-fund --omit=dev @aws/aws-distro-opentelemetry-node-autoinstrumentation@${adotVersion}`
|
|
92
|
+
],
|
|
93
|
+
parallel: false
|
|
94
|
+
}
|
|
95
|
+
};
|
|
61
96
|
project.targets[targetName] = {
|
|
62
97
|
cache: true,
|
|
63
98
|
inputs: [
|
|
@@ -71,13 +106,14 @@ import { agentCoreRuntime, TS_VERSIONS } from "./versions.js";
|
|
|
71
106
|
commands: [
|
|
72
107
|
fs.rm(packageOutputDir),
|
|
73
108
|
fs.mkdir(packageOutputDir),
|
|
74
|
-
fs.
|
|
75
|
-
|
|
109
|
+
fs.cpFile(joinPathFragments(bundleOutputDir, 'index.js'), joinPathFragments(packageOutputDir, 'index.js')),
|
|
110
|
+
fs.cpDir(joinPathFragments(vendorDir, 'node_modules'), joinPathFragments(packageOutputDir, 'node_modules'))
|
|
76
111
|
],
|
|
77
112
|
parallel: false
|
|
78
113
|
},
|
|
79
114
|
dependsOn: [
|
|
80
|
-
bundleTargetName
|
|
115
|
+
bundleTargetName,
|
|
116
|
+
ADOT_VENDOR_TARGET_NAME
|
|
81
117
|
]
|
|
82
118
|
};
|
|
83
119
|
addArtifactDependencyToTargets(project, targetName);
|
|
@@ -115,9 +151,9 @@ import { agentCoreRuntime, TS_VERSIONS } from "./versions.js";
|
|
|
115
151
|
commands: [
|
|
116
152
|
fs.rm(packageOutputDir),
|
|
117
153
|
fs.mkdir(packageOutputDir),
|
|
118
|
-
fs.
|
|
119
|
-
fs.
|
|
120
|
-
fs.
|
|
154
|
+
fs.cpDir(bundleOutputDir, packageOutputDir),
|
|
155
|
+
fs.cpDir(sourceRoot, joinPathFragments(packageOutputDir, moduleName)),
|
|
156
|
+
fs.cpFile(entryPointPath, joinPathFragments(packageOutputDir, entryPointFileName))
|
|
121
157
|
],
|
|
122
158
|
parallel: false
|
|
123
159
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/agent-core-packaging.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies.js';\nimport { FS_DEPENDENCIES, FsCommands } from './fs.js';\nimport { addArtifactDependencyToTargets } from './nx.js';\nimport {\n agentCoreRuntime,\n type ITsDepVersion,\n TS_VERSIONS,\n} from './versions.js';\n\n/**\n * How an AgentCore Runtime's artifact is packaged and hosted.\n *\n * `agentcore` uploads a `.zip` of the built code to S3 and runs it on an\n * AgentCore managed language runtime, which skips the container build, ECR\n * repository and image push entirely — the fastest build and deploy cycle.\n * `agentcore-ecr` builds an arm64 container image and hosts it from ECR, for\n * workloads needing OS-level control (e.g. native system libraries) or an\n * established container pipeline.\n */\nexport const AGENT_CORE_INFRA = ['agentcore', 'agentcore-ecr', 'none'] as const;\n\nexport type AgentCoreInfra = (typeof AGENT_CORE_INFRA)[number];\n\n/** Whether the given infra option hosts on AgentCore Runtime at all. */\nexport const isAgentCoreHosted = (infra: AgentCoreInfra): boolean =>\n infra === 'agentcore' || infra === 'agentcore-ecr';\n\n/** Whether the given infra option builds and hosts a container image. */\nexport const isContainerHosted = (infra: AgentCoreInfra): boolean =>\n infra === 'agentcore-ecr';\n\n/** The AgentCore managed runtime a TypeScript component targets. */\nexport const agentCoreNodeRuntime = (): string => agentCoreRuntime('node');\n\n/** The AgentCore managed runtime a Python component targets. */\nexport const agentCorePythonRuntime = (): string => agentCoreRuntime('python');\n\n/**\n * Dependencies a caller must declare to add a code (`.zip`) packaging target.\n *\n * The TypeScript package target vendors the AWS Distro for OpenTelemetry into\n * the package directory, so its version is declared here (spread through\n * `ownedElsewhere` by callers, since the install targets the built package\n * rather than any workspace manifest).\n */\nexport const CODE_PACKAGE_DEPENDENCIES = [\n ...FS_DEPENDENCIES,\n { name: '@aws/aws-distro-opentelemetry-node-autoinstrumentation' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport interface AddTypeScriptCodePackageTargetOptions {\n /** Project configuration to add the target to (mutated in place). */\n readonly project: ProjectConfiguration;\n /** Name of the packaging target to add, e.g. `agent-package`. */\n readonly targetName: string;\n /** Name of the target producing the bundled `index.js`, depended on here. */\n readonly bundleTargetName: string;\n /** Directory holding the bundled `index.js`, relative to the workspace root. */\n readonly bundleOutputDir: string;\n /** Directory to assemble the deployable package in, relative to the workspace root. */\n readonly packageOutputDir: string;\n}\n\n/**\n * Add a target assembling the deployable code package for a TypeScript\n * AgentCore Runtime.\n *\n * The package is the rolldown bundle plus a vendored AWS Distro for\n * OpenTelemetry install. AgentCore rejects a code package with no OpenTelemetry\n * dependencies present (`CREATE_FAILED`: \"OpenTelemetry instrumentation\n * executable not found\"), so ADOT must ship inside the package rather than\n * being installed at runtime — the `opentelemetry-instrument` entry point\n * prefix resolves it from there.\n *\n * The install is scoped to the package directory with `--prefix` and\n * `--no-save`, so it never touches the project's own manifest. `--omit=dev`\n * keeps the package to what the runtime loads. ADOT is pure JavaScript with no\n * native binaries, so the package is architecture independent even though\n * AgentCore only runs arm64.\n */\nexport const addTypeScriptCodePackageTarget = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n options: AddTypeScriptCodePackageTargetOptions,\n declaration: D & MustDeclare<typeof CODE_PACKAGE_DEPENDENCIES, D>,\n): void => {\n const {\n project,\n targetName,\n bundleTargetName,\n bundleOutputDir,\n packageOutputDir,\n } = options;\n\n const fs = new FsCommands(\n tree,\n forDependencies<typeof FS_DEPENDENCIES>(declaration),\n );\n const adotVersion =\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'];\n\n project.targets ??= {};\n project.targets[targetName] = {\n cache: true,\n inputs: ['default'],\n outputs: [`{workspaceRoot}/${packageOutputDir}`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(packageOutputDir),\n fs.mkdir(packageOutputDir),\n fs.cp(\n joinPathFragments(bundleOutputDir, 'index.js'),\n joinPathFragments(packageOutputDir, 'index.js'),\n ),\n `npm install --prefix ${packageOutputDir} --no-save --no-audit --no-fund --omit=dev @aws/aws-distro-opentelemetry-node-autoinstrumentation@${adotVersion}`,\n ],\n parallel: false,\n },\n dependsOn: [bundleTargetName],\n };\n\n addArtifactDependencyToTargets(project, targetName);\n};\n\nexport interface AddPythonCodePackageTargetOptions {\n /** Project configuration to add the target to (mutated in place). */\n readonly project: ProjectConfiguration;\n /** Name of the packaging target to add, e.g. `agent-package`. */\n readonly targetName: string;\n /** Name of the arm64 bundle target, depended on here. */\n readonly bundleTargetName: string;\n /** Directory holding the arm64 bundle, relative to the workspace root. */\n readonly bundleOutputDir: string;\n /** Directory to assemble the deployable package in, relative to the workspace root. */\n readonly packageOutputDir: string;\n /**\n * The project's source root, which is itself the module directory — copied\n * into the package under {@link moduleName} so the agent's imports resolve.\n */\n readonly sourceRoot: string;\n /** Python module name (the source root's last segment). */\n readonly moduleName: string;\n /**\n * Path to the entry point script, relative to the workspace root. Copied to\n * the package root, where AgentCore's `entryPoint` runs it.\n */\n readonly entryPointPath: string;\n /** File name the entry point takes at the package root. */\n readonly entryPointFileName: string;\n}\n\n/**\n * Add a target assembling the deployable code package for a Python AgentCore\n * Runtime.\n *\n * The package is the arm64 dependency bundle (which already carries\n * `bin/opentelemetry-instrument` from `aws-opentelemetry-distro`, satisfying\n * AgentCore's requirement that OpenTelemetry be present), the project's own\n * module tree, and a root entry point script.\n *\n * The entry point sits at the package root rather than inside the module:\n * AgentCore runs it as a file path, and Python gives a script run that way no\n * parent package, so the agent's own `from .init import app` would raise\n * `ImportError: attempted relative import with no known parent package`. The\n * root script imports the module absolutely instead, which resolves those\n * relative imports normally.\n */\nexport const addPythonCodePackageTarget = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n options: AddPythonCodePackageTargetOptions,\n declaration: D & MustDeclare<typeof FS_DEPENDENCIES, D>,\n): void => {\n const {\n project,\n targetName,\n bundleTargetName,\n bundleOutputDir,\n packageOutputDir,\n sourceRoot,\n moduleName,\n entryPointPath,\n entryPointFileName,\n } = options;\n\n const fs = new FsCommands(\n tree,\n forDependencies<typeof FS_DEPENDENCIES>(declaration),\n );\n\n project.targets ??= {};\n project.targets[targetName] = {\n cache: true,\n inputs: ['production', '^production'],\n outputs: [`{workspaceRoot}/${packageOutputDir}`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(packageOutputDir),\n fs.mkdir(packageOutputDir),\n fs.cp(bundleOutputDir, packageOutputDir),\n fs.cp(sourceRoot, joinPathFragments(packageOutputDir, moduleName)),\n fs.cp(\n entryPointPath,\n joinPathFragments(packageOutputDir, entryPointFileName),\n ),\n ],\n parallel: false,\n },\n dependsOn: [bundleTargetName],\n };\n\n addArtifactDependencyToTargets(project, targetName);\n};\n"],"names":["joinPathFragments","forDependencies","FS_DEPENDENCIES","FsCommands","addArtifactDependencyToTargets","agentCoreRuntime","TS_VERSIONS","AGENT_CORE_INFRA","isAgentCoreHosted","infra","isContainerHosted","agentCoreNodeRuntime","agentCorePythonRuntime","CODE_PACKAGE_DEPENDENCIES","name","addTypeScriptCodePackageTarget","tree","options","declaration","project","targetName","bundleTargetName","bundleOutputDir","packageOutputDir","fs","adotVersion","targets","cache","inputs","outputs","executor","commands","rm","mkdir","cp","parallel","dependsOn","addPythonCodePackageTarget","sourceRoot","moduleName","entryPointPath","entryPointFileName"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,QAGZ,aAAa;AACpB,SAEEC,eAAe,QAEV,6BAA6B;AACpC,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,8BAA8B,QAAQ,UAAU;AACzD,SACEC,gBAAgB,EAEhBC,WAAW,QACN,gBAAgB;AAEvB;;;;;;;;;CASC,GACD,OAAO,MAAMC,mBAAmB;IAAC;IAAa;IAAiB;CAAO,CAAU;AAIhF,sEAAsE,GACtE,OAAO,MAAMC,oBAAoB,CAACC,QAChCA,UAAU,eAAeA,UAAU,gBAAgB;AAErD,uEAAuE,GACvE,OAAO,MAAMC,oBAAoB,CAACD,QAChCA,UAAU,gBAAgB;AAE5B,kEAAkE,GAClE,OAAO,MAAME,uBAAuB,IAAcN,iBAAiB,QAAQ;AAE3E,8DAA8D,GAC9D,OAAO,MAAMO,yBAAyB,IAAcP,iBAAiB,UAAU;AAE/E;;;;;;;CAOC,GACD,OAAO,MAAMQ,4BAA4B;OACpCX;IACH;QAAEY,MAAM;IAAyD;CAClE,CAAuD;AAexD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,iCAAiC,CAG5CC,MACAC,SACAC;IAEA,MAAM,EACJC,OAAO,EACPC,UAAU,EACVC,gBAAgB,EAChBC,eAAe,EACfC,gBAAgB,EACjB,GAAGN;IAEJ,MAAMO,KAAK,IAAIrB,WACba,MACAf,gBAAwCiB;IAE1C,MAAMO,cACJnB,WAAW,CAAC,yDAAyD;IAEvE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IAEAjB,+BAA+Be,SAASC;AAC1C,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/agent-core-packaging.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies.js';\nimport { FS_DEPENDENCIES, FsCommands } from './fs.js';\nimport { addArtifactDependencyToTargets } from './nx.js';\nimport {\n agentCoreRuntime,\n type ITsDepVersion,\n TS_VERSIONS,\n} from './versions.js';\n\n/**\n * How an AgentCore Runtime's artifact is packaged and hosted.\n *\n * `agentcore` uploads a `.zip` of the built code to S3 and runs it on an\n * AgentCore managed language runtime, which skips the container build, ECR\n * repository and image push entirely — the fastest build and deploy cycle.\n * `agentcore-ecr` builds an arm64 container image and hosts it from ECR, for\n * workloads needing OS-level control (e.g. native system libraries) or an\n * established container pipeline.\n */\nexport const AGENT_CORE_INFRA = ['agentcore', 'agentcore-ecr', 'none'] as const;\n\nexport type AgentCoreInfra = (typeof AGENT_CORE_INFRA)[number];\n\n/** Whether the given infra option hosts on AgentCore Runtime at all. */\nexport const isAgentCoreHosted = (infra: AgentCoreInfra): boolean =>\n infra === 'agentcore' || infra === 'agentcore-ecr';\n\n/** Whether the given infra option builds and hosts a container image. */\nexport const isContainerHosted = (infra: AgentCoreInfra): boolean =>\n infra === 'agentcore-ecr';\n\n/** The AgentCore managed runtime a TypeScript component targets. */\nexport const agentCoreNodeRuntime = (): string => agentCoreRuntime('node');\n\n/** The AgentCore managed runtime a Python component targets. */\nexport const agentCorePythonRuntime = (): string => agentCoreRuntime('python');\n\n/**\n * Dependencies a caller must declare to add a code (`.zip`) packaging target.\n *\n * The TypeScript package target vendors the AWS Distro for OpenTelemetry into\n * the package directory, so its version is declared here (spread through\n * `ownedElsewhere` by callers, since the install targets the built package\n * rather than any workspace manifest).\n */\nexport const CODE_PACKAGE_DEPENDENCIES = [\n ...FS_DEPENDENCIES,\n { name: '@aws/aws-distro-opentelemetry-node-autoinstrumentation' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport interface AddTypeScriptCodePackageTargetOptions {\n /** Project configuration to add the target to (mutated in place). */\n readonly project: ProjectConfiguration;\n /** Name of the packaging target to add, e.g. `agent-package`. */\n readonly targetName: string;\n /** Name of the target producing the bundled `index.js`, depended on here. */\n readonly bundleTargetName: string;\n /** Directory holding the bundled `index.js`, relative to the workspace root. */\n readonly bundleOutputDir: string;\n /** Directory to assemble the deployable package in, relative to the workspace root. */\n readonly packageOutputDir: string;\n}\n\n/**\n * Name of the target that installs ADOT for the project's code packages. Every\n * code package in a project vendors the same thing, so they share one.\n */\nexport const ADOT_VENDOR_TARGET_NAME = 'agent-core-vendor';\n\n/**\n * Directory the vendor target installs into, relative to the workspace root.\n *\n * A sibling of the `package` directory rather than a path inside it: Nx replaces\n * a cached target's whole declared output directory on restore, so an output\n * nested inside another target's output would have each wipe the other's work on\n * a cache hit.\n */\nexport const adotVendorDir = (projectRoot: string): string =>\n joinPathFragments('dist', projectRoot, 'agent-core-vendor');\n\n/**\n * Add a target assembling the deployable code package for a TypeScript\n * AgentCore Runtime.\n *\n * The package is the rolldown bundle plus a vendored AWS Distro for\n * OpenTelemetry install. AgentCore rejects a code package with no OpenTelemetry\n * dependencies present (`CREATE_FAILED`: \"OpenTelemetry instrumentation\n * executable not found\"), so ADOT must ship inside the package rather than\n * being installed at runtime — the `opentelemetry-instrument` entry point\n * prefix resolves it from there.\n *\n * The install is scoped to its own directory with `--prefix` and `--no-save`, so\n * it never touches the project's own manifest. `--omit=dev` keeps the package to\n * what the runtime loads. ADOT is pure JavaScript with no native binaries, so the\n * package is architecture independent even though AgentCore only runs arm64.\n *\n * Vendoring is a separate target so Nx caches it independently of the source. It\n * depends on nothing but the pinned ADOT version, which the install command\n * carries and Nx hashes as part of the target's configuration, so it declares no\n * `inputs`: editing an agent replays a directory copy rather than re-running the\n * install, while bumping the version still invalidates it.\n */\nexport const addTypeScriptCodePackageTarget = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n options: AddTypeScriptCodePackageTargetOptions,\n declaration: D & MustDeclare<typeof CODE_PACKAGE_DEPENDENCIES, D>,\n): void => {\n const {\n project,\n targetName,\n bundleTargetName,\n bundleOutputDir,\n packageOutputDir,\n } = options;\n\n const fs = new FsCommands(\n tree,\n forDependencies<typeof FS_DEPENDENCIES>(declaration),\n );\n const adotVersion =\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'];\n const vendorDir = adotVendorDir(project.root);\n\n project.targets ??= {};\n\n // Shared by every code package in the project, so only added once.\n project.targets[ADOT_VENDOR_TARGET_NAME] ??= {\n cache: true,\n inputs: [],\n outputs: [`{workspaceRoot}/${vendorDir}`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(vendorDir),\n fs.mkdir(vendorDir),\n `npm install --prefix ${vendorDir} --no-save --no-audit --no-fund --omit=dev @aws/aws-distro-opentelemetry-node-autoinstrumentation@${adotVersion}`,\n ],\n parallel: false,\n },\n };\n\n project.targets[targetName] = {\n cache: true,\n inputs: ['default'],\n outputs: [`{workspaceRoot}/${packageOutputDir}`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(packageOutputDir),\n fs.mkdir(packageOutputDir),\n fs.cpFile(\n joinPathFragments(bundleOutputDir, 'index.js'),\n joinPathFragments(packageOutputDir, 'index.js'),\n ),\n fs.cpDir(\n joinPathFragments(vendorDir, 'node_modules'),\n joinPathFragments(packageOutputDir, 'node_modules'),\n ),\n ],\n parallel: false,\n },\n dependsOn: [bundleTargetName, ADOT_VENDOR_TARGET_NAME],\n };\n\n addArtifactDependencyToTargets(project, targetName);\n};\n\nexport interface AddPythonCodePackageTargetOptions {\n /** Project configuration to add the target to (mutated in place). */\n readonly project: ProjectConfiguration;\n /** Name of the packaging target to add, e.g. `agent-package`. */\n readonly targetName: string;\n /** Name of the arm64 bundle target, depended on here. */\n readonly bundleTargetName: string;\n /** Directory holding the arm64 bundle, relative to the workspace root. */\n readonly bundleOutputDir: string;\n /** Directory to assemble the deployable package in, relative to the workspace root. */\n readonly packageOutputDir: string;\n /**\n * The project's source root, which is itself the module directory — copied\n * into the package under {@link moduleName} so the agent's imports resolve.\n */\n readonly sourceRoot: string;\n /** Python module name (the source root's last segment). */\n readonly moduleName: string;\n /**\n * Path to the entry point script, relative to the workspace root. Copied to\n * the package root, where AgentCore's `entryPoint` runs it.\n */\n readonly entryPointPath: string;\n /** File name the entry point takes at the package root. */\n readonly entryPointFileName: string;\n}\n\n/**\n * Add a target assembling the deployable code package for a Python AgentCore\n * Runtime.\n *\n * The package is the arm64 dependency bundle (which already carries\n * `bin/opentelemetry-instrument` from `aws-opentelemetry-distro`, satisfying\n * AgentCore's requirement that OpenTelemetry be present), the project's own\n * module tree, and a root entry point script.\n *\n * The entry point sits at the package root rather than inside the module:\n * AgentCore runs it as a file path, and Python gives a script run that way no\n * parent package, so the agent's own `from .init import app` would raise\n * `ImportError: attempted relative import with no known parent package`. The\n * root script imports the module absolutely instead, which resolves those\n * relative imports normally.\n */\nexport const addPythonCodePackageTarget = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n options: AddPythonCodePackageTargetOptions,\n declaration: D & MustDeclare<typeof FS_DEPENDENCIES, D>,\n): void => {\n const {\n project,\n targetName,\n bundleTargetName,\n bundleOutputDir,\n packageOutputDir,\n sourceRoot,\n moduleName,\n entryPointPath,\n entryPointFileName,\n } = options;\n\n const fs = new FsCommands(\n tree,\n forDependencies<typeof FS_DEPENDENCIES>(declaration),\n );\n\n project.targets ??= {};\n project.targets[targetName] = {\n cache: true,\n inputs: ['production', '^production'],\n outputs: [`{workspaceRoot}/${packageOutputDir}`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(packageOutputDir),\n fs.mkdir(packageOutputDir),\n fs.cpDir(bundleOutputDir, packageOutputDir),\n fs.cpDir(sourceRoot, joinPathFragments(packageOutputDir, moduleName)),\n fs.cpFile(\n entryPointPath,\n joinPathFragments(packageOutputDir, entryPointFileName),\n ),\n ],\n parallel: false,\n },\n dependsOn: [bundleTargetName],\n };\n\n addArtifactDependencyToTargets(project, targetName);\n};\n"],"names":["joinPathFragments","forDependencies","FS_DEPENDENCIES","FsCommands","addArtifactDependencyToTargets","agentCoreRuntime","TS_VERSIONS","AGENT_CORE_INFRA","isAgentCoreHosted","infra","isContainerHosted","agentCoreNodeRuntime","agentCorePythonRuntime","CODE_PACKAGE_DEPENDENCIES","name","ADOT_VENDOR_TARGET_NAME","adotVendorDir","projectRoot","addTypeScriptCodePackageTarget","tree","options","declaration","project","targetName","bundleTargetName","bundleOutputDir","packageOutputDir","fs","adotVersion","vendorDir","root","targets","cache","inputs","outputs","executor","commands","rm","mkdir","parallel","cpFile","cpDir","dependsOn","addPythonCodePackageTarget","sourceRoot","moduleName","entryPointPath","entryPointFileName"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,QAGZ,aAAa;AACpB,SAEEC,eAAe,QAEV,6BAA6B;AACpC,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,8BAA8B,QAAQ,UAAU;AACzD,SACEC,gBAAgB,EAEhBC,WAAW,QACN,gBAAgB;AAEvB;;;;;;;;;CASC,GACD,OAAO,MAAMC,mBAAmB;IAAC;IAAa;IAAiB;CAAO,CAAU;AAIhF,sEAAsE,GACtE,OAAO,MAAMC,oBAAoB,CAACC,QAChCA,UAAU,eAAeA,UAAU,gBAAgB;AAErD,uEAAuE,GACvE,OAAO,MAAMC,oBAAoB,CAACD,QAChCA,UAAU,gBAAgB;AAE5B,kEAAkE,GAClE,OAAO,MAAME,uBAAuB,IAAcN,iBAAiB,QAAQ;AAE3E,8DAA8D,GAC9D,OAAO,MAAMO,yBAAyB,IAAcP,iBAAiB,UAAU;AAE/E;;;;;;;C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