@aws/nx-plugin 1.0.0-rc.79 → 1.0.0-rc.80
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/generators.json +10 -0
- package/migrations.json +1 -1
- package/package.json +1 -1
- package/src/agentcore-gateway/agent-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/agent-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/agent-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/agent-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/attach-upstream.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/generator.d.ts +3 -3
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/react-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/react-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/react-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/react-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/schema.d.js.map +1 -1
- package/src/agentcore-gateway/schema.d.ts +1 -1
- package/src/agentcore-harness/generator.d.ts +4 -4
- package/src/agentcore-harness/generator.js.map +1 -1
- package/src/agentcore-harness/schema.d.js.map +1 -1
- package/src/agentcore-harness/schema.d.ts +1 -1
- package/src/connection/agent-local-dev.d.ts +1 -1
- package/src/connection/agent-local-dev.js.map +1 -1
- package/src/connection/agent-runtime-config.js.map +1 -1
- package/src/connection/gateway-runtime-config.js.map +1 -1
- package/src/connection/generator.d.ts +2 -2
- package/src/connection/generator.js.map +1 -1
- package/src/connection/local-dev.js.map +1 -1
- package/src/connection/scaffold-catalog.d.ts +1 -1
- package/src/connection/scaffold-catalog.js +6 -6
- package/src/connection/scaffold-catalog.js.map +1 -1
- package/src/connection/schema-resolver.d.ts +1 -1
- package/src/connection/schema-resolver.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js.map +1 -1
- package/src/infra/app/generator.d.ts +7 -7
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +3 -3
- package/src/init/generator.js.map +1 -1
- package/src/init/schema.d.js.map +1 -1
- package/src/init/schema.d.ts +2 -2
- package/src/internal/test-matrix/generator.js.map +1 -1
- package/src/license/config-types.d.ts +2 -2
- package/src/license/config-types.js.map +1 -1
- package/src/license/config.d.ts +2 -2
- package/src/license/config.js.map +1 -1
- package/src/license/dependency-check/check.d.ts +2 -2
- package/src/license/dependency-check/check.js.map +1 -1
- package/src/license/dependency-check/collectors/collector.js.map +1 -1
- package/src/license/dependency-check/collectors/python-collector.js.map +1 -1
- package/src/license/dependency-check/evaluator.d.ts +1 -1
- package/src/license/dependency-check/evaluator.js.map +1 -1
- package/src/license/dependency-check/executor.js.map +1 -1
- package/src/license/dependency-check/pre-approved.d.ts +1 -1
- package/src/license/dependency-check/pre-approved.js.map +1 -1
- package/src/license/dependency-check/types.d.ts +1 -1
- package/src/license/dependency-check/types.js.map +1 -1
- package/src/license/generator.d.ts +1 -1
- package/src/license/generator.js.map +1 -1
- package/src/license/index.d.ts +4 -4
- package/src/license/index.js.map +1 -1
- package/src/license/known-exceptions.d.ts +1 -1
- package/src/license/known-exceptions.js.map +1 -1
- package/src/license/sync/generator.js.map +1 -1
- package/src/license/sync/project-file-sync.d.ts +1 -1
- package/src/license/sync/project-file-sync.js.map +1 -1
- package/src/mcp-server/dev-server.js.map +1 -1
- package/src/mcp-server/generator-info.d.ts +3 -3
- package/src/mcp-server/generator-info.js.map +1 -1
- package/src/mcp-server/guide-pipeline.d.ts +1 -1
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/guide-render.js.map +1 -1
- package/src/mcp-server/index.js.map +1 -1
- package/src/mcp-server/mdx-ast.js.map +1 -1
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/add-to-existing-project.d.ts +1 -1
- package/src/mcp-server/tools/add-to-existing-project.js.map +1 -1
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/mcp-server/tools/general-guidance.d.ts +1 -1
- package/src/mcp-server/tools/general-guidance.js +1 -1
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/mcp-server/tools/generator-guide.d.ts +1 -1
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/mcp-server/tools/list-generators.d.ts +1 -1
- package/src/mcp-server/tools/list-generators.js.map +1 -1
- package/src/mcp-server/tools/upgrade-workspace.d.ts +1 -1
- package/src/mcp-server/tools/upgrade-workspace.js.map +1 -1
- package/src/migrations/latest/apt-security-updates-in-container-images/migration.js.map +1 -1
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.js.map +1 -1
- package/src/migrations/latest/py-agent-ag-ui-hooks/migration.js.map +1 -1
- package/src/migrations/latest/py-agent-session-id-middleware-extraction/migration.js.map +1 -1
- package/src/migrations/latest/remove-mcp-inspector-license-exceptions/migration.js.map +1 -1
- package/src/migrations/latest/static-website-configurable-waf-encryption/migration.js.map +1 -1
- package/src/migrations/latest/ts-agent-session-id-middleware-extraction/migration.js.map +1 -1
- package/src/migrations/latest/user-identity-configurable-mfa/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.50/0001-modernize-function-props-cast/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.50/0002-restrict-cors-to-custom-domains/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.50/0003-terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.52/0001-user-identity-waf-allow-localhost-callback/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.54/0001-order-access-log-delivery-after-bucket-policy/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.d.ts +1 -1
- package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.56/0001-dynamodb-local-remove-optimize-flag/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.57/0001-ts-agent-session-management-support/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.59/0001-gateway-agent-targets/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.60/0001-gateway-cognito-passthrough/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.60/0002-waf-log-group-removal/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.60/0003-strip-pip-from-python-images/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.61/0001-py-agent-lifespan-construction/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.62/0001-rename-load-runtime-config-target/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.63/0001-add-deploy-sandbox-target/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.64/0001-smithy-build-without-docker/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.65/0001-vite-config-import-meta-dirname/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.65/0002-rolldown-code-splitting/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.67/0001-smithy-server-package-rename/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.68/0001-translate-script-whole-file-writes/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.70/0001-py-agent-a2a-lifespan-construction/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.71/0001-py-agent-a2a-httpx-client-per-call/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.72/0001-py-agent-session-management-support/migration.js.map +1 -1
- package/src/open-api/ts-client/generator.d.ts +1 -1
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.d.ts +1 -1
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.spec.tsx +6 -6
- package/src/open-api/ts-metadata/generator.d.ts +1 -1
- package/src/open-api/ts-metadata/generator.js.map +1 -1
- package/src/open-api/utils/codegen-data/languages.d.ts +1 -1
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data.d.ts +2 -2
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.d.ts +1 -1
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parse.d.ts +1 -1
- package/src/open-api/utils/parse.js.map +1 -1
- package/src/open-api/utils/parser.d.ts +2 -2
- package/src/open-api/utils/parser.js.map +1 -1
- package/src/open-api/utils/refs.d.ts +1 -1
- package/src/open-api/utils/refs.js.map +1 -1
- package/src/preset/generator.d.ts +3 -3
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.js.map +1 -1
- package/src/preset/schema.d.ts +3 -3
- package/src/py/agent/a2a-connection/generator.d.ts +3 -3
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.ts +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +3 -3
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.ts +1 -1
- package/src/py/agent/generator.d.ts +3 -3
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +3 -3
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.ts +1 -1
- package/src/py/agent/react-connection/generator.d.ts +12 -12
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/local-dev.d.ts +1 -1
- package/src/py/agent/react-connection/local-dev.js.map +1 -1
- package/src/py/agent/react-connection/schema.d.js.map +1 -1
- package/src/py/agent/react-connection/schema.d.ts +1 -1
- package/src/py/agent/schema.d.js.map +1 -1
- package/src/py/agent/schema.d.ts +1 -1
- package/src/py/api/generator.d.ts +1 -1
- package/src/py/api/generator.js.map +1 -1
- package/src/py/api/schema.d.js.map +1 -1
- package/src/py/api/schema.d.ts +1 -1
- package/src/py/dynamodb/agent-connection/generator.d.ts +1 -1
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.ts +1 -1
- package/src/py/dynamodb/fast-api-connection/generator.d.ts +1 -1
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/generator.d.ts +4 -4
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/generator.d.ts +1 -1
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.ts +1 -1
- package/src/py/dynamodb/schema.d.js.map +1 -1
- package/src/py/dynamodb/schema.d.ts +1 -1
- package/src/py/fast-api/generator.d.ts +3 -3
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +3 -3
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/react/open-api.js.map +1 -1
- package/src/py/fast-api/schema.d.js.map +1 -1
- package/src/py/fast-api/schema.d.ts +1 -1
- package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +1 -1
- package/src/py/lambda-function/generator.d.ts +10 -4
- package/src/py/lambda-function/generator.js +8 -1
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.js.map +1 -1
- package/src/py/lambda-function/schema.d.ts +2 -2
- package/src/py/lambda-function/schema.json +1 -1
- package/src/py/mcp-server/generator.d.ts +3 -3
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.js.map +1 -1
- package/src/py/mcp-server/schema.d.ts +1 -1
- package/src/py/project/generator.d.ts +2 -2
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.json +1 -0
- package/src/py/rdb/agent-connection/generator.d.ts +1 -1
- package/src/py/rdb/agent-connection/generator.js.map +1 -1
- package/src/py/rdb/agent-connection/schema.d.js.map +1 -1
- package/src/py/rdb/agent-connection/schema.d.ts +1 -1
- package/src/py/rdb/fast-api-connection/generator.d.ts +1 -1
- package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +3 -3
- package/src/py/rdb/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/generator.d.ts +1 -1
- package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/schema.d.ts +1 -1
- package/src/sdk/agentcore-gateway.d.ts +1 -1
- package/src/sdk/agentcore-gateway.js.map +1 -1
- package/src/sdk/agentcore-harness.d.ts +1 -1
- package/src/sdk/agentcore-harness.js.map +1 -1
- package/src/sdk/connection.d.ts +1 -1
- package/src/sdk/connection.js.map +1 -1
- package/src/sdk/license.d.ts +3 -3
- package/src/sdk/license.js.map +1 -1
- package/src/sdk/open-api.d.ts +3 -3
- package/src/sdk/open-api.js.map +1 -1
- package/src/sdk/py.d.ts +7 -7
- package/src/sdk/py.js.map +1 -1
- package/src/sdk/smithy.d.ts +1 -1
- package/src/sdk/smithy.js.map +1 -1
- package/src/sdk/terraform.d.ts +1 -1
- package/src/sdk/terraform.js.map +1 -1
- package/src/sdk/ts.d.ts +18 -18
- package/src/sdk/ts.js.map +1 -1
- package/src/sdk/utils/ast.d.ts +1 -1
- package/src/sdk/utils/ast.js.map +1 -1
- package/src/sdk/utils/format.d.ts +1 -1
- package/src/sdk/utils/format.js.map +1 -1
- package/src/sdk/utils/test.d.ts +1 -1
- package/src/sdk/utils/test.js.map +1 -1
- package/src/smithy/project/generator.d.ts +4 -4
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +3 -3
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/generator.d.ts +3 -3
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.js.map +1 -1
- package/src/smithy/ts/api/schema.d.ts +1 -1
- package/src/terraform/project/generator.d.ts +5 -5
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/generator.d.ts +3 -3
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +1 -1
- package/src/trpc/react/generator.d.ts +3 -3
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +3 -3
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.ts +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +3 -3
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.ts +1 -1
- package/src/ts/agent/generator.d.ts +3 -3
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +3 -3
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.ts +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +11 -11
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/local-dev.d.ts +1 -1
- package/src/ts/agent/react-connection/local-dev.js.map +1 -1
- package/src/ts/agent/react-connection/schema.d.js.map +1 -1
- package/src/ts/agent/react-connection/schema.d.ts +1 -1
- package/src/ts/agent/schema.d.js.map +1 -1
- package/src/ts/agent/schema.d.ts +1 -1
- package/src/ts/api/generator.d.ts +1 -1
- package/src/ts/api/generator.js.map +1 -1
- package/src/ts/api/schema.d.js.map +1 -1
- package/src/ts/api/schema.d.ts +1 -1
- package/src/ts/astro-docs/generator.d.ts +3 -3
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +5 -5
- package/src/ts/dcr-proxy/generator.js.map +1 -1
- package/src/ts/dcr-proxy/schema.d.js.map +1 -1
- package/src/ts/dcr-proxy/schema.d.ts +1 -1
- package/src/ts/docs/generator.d.ts +1 -1
- package/src/ts/docs/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/schema.d.ts +1 -1
- package/src/ts/dynamodb/generator.d.ts +5 -5
- package/src/ts/dynamodb/generator.js +1 -0
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.ts +1 -1
- package/src/ts/dynamodb/schema.d.js.map +1 -1
- package/src/ts/dynamodb/schema.d.ts +1 -1
- package/src/ts/dynamodb/smithy-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/lambda-function/generator.d.ts +5 -5
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/schema.d.js.map +1 -1
- package/src/ts/lambda-function/schema.d.ts +1 -1
- package/src/ts/lib/biome.d.ts +1 -1
- package/src/ts/lib/biome.js.map +1 -1
- package/src/ts/lib/generator.d.ts +3 -3
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +3 -3
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +2 -2
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/generator.d.ts +3 -3
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +1 -1
- package/src/ts/nx-generator/generator.d.ts +2 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-migration/generator.d.ts +3 -3
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/nx-plugin/generator.d.ts +3 -3
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +1 -1
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/agent-connection/generator.d.ts +1 -1
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/agent-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/agent-connection/schema.d.ts +1 -1
- package/src/ts/rdb/generator.d.ts +4 -4
- package/src/ts/rdb/generator.js +1 -0
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/generator.d.ts +1 -1
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.ts +1 -1
- package/src/ts/rdb/schema.d.js.map +1 -1
- package/src/ts/rdb/schema.d.ts +1 -1
- package/src/ts/rdb/smithy-connection/generator.d.ts +1 -1
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/generator.d.ts +1 -1
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +2 -2
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/generator.d.ts +3 -3
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.js.map +1 -1
- package/src/ts/react-website/app/schema.d.ts +2 -2
- package/src/ts/react-website/cognito-auth/generator.d.ts +5 -5
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.ts +1 -1
- package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
- package/src/ts/react-website/runtime-config/generator.d.ts +1 -1
- package/src/ts/react-website/runtime-config/generator.js.map +1 -1
- package/src/ts/sync/generator.d.ts +1 -1
- package/src/ts/sync/generator.js.map +1 -1
- package/src/ts/website/app/generator.d.ts +1 -1
- package/src/ts/website/app/generator.js.map +1 -1
- package/src/ts/website/app/schema.d.js.map +1 -1
- package/src/ts/website/app/schema.d.ts +2 -2
- package/src/ts/website/auth/generator.d.ts +1 -1
- package/src/ts/website/auth/generator.js.map +1 -1
- package/src/ts/website/auth/schema.d.js.map +1 -1
- package/src/ts/website/auth/schema.d.ts +1 -1
- package/src/utils/add-dependencies.d.ts +1 -1
- package/src/utils/add-dependencies.js.map +1 -1
- package/src/utils/agent-chat/agent-chat.js.map +1 -1
- package/src/utils/agent-connection/agent-connection.d.ts +2 -2
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +4 -4
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/api-constructs/api-constructs.d.ts +3 -3
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/open-api-metadata.d.ts +1 -1
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
- package/src/utils/ast/website.js.map +1 -1
- package/src/utils/ast.js +6 -0
- package/src/utils/ast.js.map +1 -1
- package/src/utils/bundle/bundle.d.ts +1 -1
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.d.ts +1 -1
- package/src/utils/commands.js.map +1 -1
- package/src/utils/config/index.d.ts +6 -6
- package/src/utils/config/index.js.map +1 -1
- package/src/utils/config/utils.d.ts +1 -1
- package/src/utils/config/utils.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +1 -1
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/containers.js.map +1 -1
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.d.ts +1 -1
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js.map +1 -1
- package/src/utils/declared-dependencies.d.ts +1 -1
- package/src/utils/declared-dependencies.js.map +1 -1
- package/src/utils/dependencies.js.map +1 -1
- package/src/utils/docker.d.ts +1 -1
- package/src/utils/docker.js.map +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.d.ts +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
- package/src/utils/format.js.map +1 -1
- package/src/utils/fs.d.ts +1 -1
- package/src/utils/fs.js.map +1 -1
- package/src/utils/function-constructs/function-constructs.d.ts +1 -1
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/iac.d.ts +2 -2
- package/src/utils/iac.js.map +1 -1
- package/src/utils/identity-constructs/identity-constructs.d.ts +2 -2
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/init.d.ts +3 -3
- package/src/utils/init.js.map +1 -1
- package/src/utils/install.d.ts +1 -1
- package/src/utils/install.js.map +1 -1
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/metrics.d.ts +1 -1
- package/src/utils/metrics.js.map +1 -1
- package/src/utils/migration-manifest.d.ts +1 -1
- package/src/utils/migration-manifest.js.map +1 -1
- package/src/utils/nx.d.ts +3 -3
- package/src/utils/nx.js.map +1 -1
- package/src/utils/paths.js.map +1 -1
- package/src/utils/pkg-manager.d.ts +1 -1
- package/src/utils/pkg-manager.js.map +1 -1
- package/src/utils/pnpm-workspace.js.map +1 -1
- package/src/utils/project-package-json.js.map +1 -1
- package/src/utils/py.d.ts +2 -2
- package/src/utils/py.js.map +1 -1
- package/src/utils/rdb-constructs/rdb-constructs.d.ts +2 -2
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +3 -3
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +1 -1
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-config.js.map +1 -1
- package/src/utils/shared-infra-scripts.d.ts +2 -2
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +1 -1
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +1 -1
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/smithy.js.map +1 -1
- package/src/utils/test.js.map +1 -1
- package/src/utils/version-upgrade-migration/migration.js.map +1 -1
- package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -1
- package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +1 -1
- package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -1
- package/src/utils/version-upgrade-migration/register.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-embedded-versions.d.ts +1 -1
- package/src/utils/version-upgrade-migration/sync-embedded-versions.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/website-constructs.d.ts +2 -2
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
package/src/ts/lib/vitest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/vitest.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readNxJson, type Tree, updateNxJson } from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { applyGritQL } from '../../utils/ast';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../../utils/declared-dependencies';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions';\nimport type { ConfigureProjectOptions } from './types';\n\nconst readGritPattern = (name: string): string =>\n readFileSync(\n join(import.meta.dirname, 'grit', `${name}.grit`),\n 'utf-8',\n ).trim();\n\n/**\n * Resolve the config's `root` from `import.meta.dirname`.\n *\n * `@nx/js` writes `root: __dirname`, which Vite's native config loader does not\n * provide — it warns today and will reject once `configLoader: 'native'` becomes\n * the default. Scoped with `some` to a direct property of the object the config\n * factory returns, so a nested `root` (a `test.alias` entry, say) is untouched.\n */\nconst ROOT_IMPORT_META_DIRNAME = `\\`defineConfig(() => ({ $props }))\\` where {\n $props <: some \\`root: __dirname\\` as $root,\n $root => \\`root: import.meta.dirname\\`\n}`;\n\n/** Dependencies a caller must declare to configure vitest. */\nexport const VITEST_DEPENDENCIES = [\n { name: 'vite' },\n { name: 'vitest' },\n { name: '@vitest/coverage-v8' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport const configureVitest = async <const D extends DependencyDeclaration>(\n tree: Tree,\n options: ConfigureProjectOptions,\n declaration: D & MustDeclare<typeof VITEST_DEPENDENCIES, D>,\n) => {\n // Find vitest.config.mts or vite.config.mts\n const configPath = [\n join(options.dir, 'vitest.config.mts'),\n join(options.dir, 'vite.config.mts'),\n ].find((config) => tree.exists(config));\n\n if (configPath) {\n await applyGritQL(\n tree,\n configPath,\n readGritPattern('vitest-pass-with-no-tests'),\n );\n\n await applyGritQL(tree, configPath, ROOT_IMPORT_META_DIRNAME);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n targetDefaults: {\n ...(nxJson.targetDefaults ?? {}),\n '@nx/vitest:test': {\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n 'update-snapshot': {\n args: '--update',\n },\n },\n ...nxJson.targetDefaults['@nx/vitest:test'],\n },\n },\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n {},\n withVersions(forDependencies<typeof VITEST_DEPENDENCIES>(declaration), [\n 'vite',\n 'vitest',\n '@vitest/coverage-v8',\n ]),\n );\n};\n"],"names":["readNxJson","updateNxJson","readFileSync","join","applyGritQL","forDependencies","addDependenciesToPackageJson","withVersions","readGritPattern","name","dirname","trim","ROOT_IMPORT_META_DIRNAME","VITEST_DEPENDENCIES","configureVitest","tree","options","declaration","configPath","dir","find","config","exists","nxJson","targetDefaults","cache","inputs","configurations","args"],"mappings":"AAAA;;;CAGC,GACD,SAASA,UAAU,EAAaC,YAAY,QAAQ,aAAa;AACjE,SAASC,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,WAAW,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/vitest.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readNxJson, type Tree, updateNxJson } from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { applyGritQL } from '../../utils/ast.js';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../../utils/declared-dependencies.js';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies.js';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions.js';\nimport type { ConfigureProjectOptions } from './types.js';\n\nconst readGritPattern = (name: string): string =>\n readFileSync(\n join(import.meta.dirname, 'grit', `${name}.grit`),\n 'utf-8',\n ).trim();\n\n/**\n * Resolve the config's `root` from `import.meta.dirname`.\n *\n * `@nx/js` writes `root: __dirname`, which Vite's native config loader does not\n * provide — it warns today and will reject once `configLoader: 'native'` becomes\n * the default. Scoped with `some` to a direct property of the object the config\n * factory returns, so a nested `root` (a `test.alias` entry, say) is untouched.\n */\nconst ROOT_IMPORT_META_DIRNAME = `\\`defineConfig(() => ({ $props }))\\` where {\n $props <: some \\`root: __dirname\\` as $root,\n $root => \\`root: import.meta.dirname\\`\n}`;\n\n/** Dependencies a caller must declare to configure vitest. */\nexport const VITEST_DEPENDENCIES = [\n { name: 'vite' },\n { name: 'vitest' },\n { name: '@vitest/coverage-v8' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport const configureVitest = async <const D extends DependencyDeclaration>(\n tree: Tree,\n options: ConfigureProjectOptions,\n declaration: D & MustDeclare<typeof VITEST_DEPENDENCIES, D>,\n) => {\n // Find vitest.config.mts or vite.config.mts\n const configPath = [\n join(options.dir, 'vitest.config.mts'),\n join(options.dir, 'vite.config.mts'),\n ].find((config) => tree.exists(config));\n\n if (configPath) {\n await applyGritQL(\n tree,\n configPath,\n readGritPattern('vitest-pass-with-no-tests'),\n );\n\n await applyGritQL(tree, configPath, ROOT_IMPORT_META_DIRNAME);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n targetDefaults: {\n ...(nxJson.targetDefaults ?? {}),\n '@nx/vitest:test': {\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n 'update-snapshot': {\n args: '--update',\n },\n },\n ...nxJson.targetDefaults['@nx/vitest:test'],\n },\n },\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n {},\n withVersions(forDependencies<typeof VITEST_DEPENDENCIES>(declaration), [\n 'vite',\n 'vitest',\n '@vitest/coverage-v8',\n ]),\n );\n};\n"],"names":["readNxJson","updateNxJson","readFileSync","join","applyGritQL","forDependencies","addDependenciesToPackageJson","withVersions","readGritPattern","name","dirname","trim","ROOT_IMPORT_META_DIRNAME","VITEST_DEPENDENCIES","configureVitest","tree","options","declaration","configPath","dir","find","config","exists","nxJson","targetDefaults","cache","inputs","configurations","args"],"mappings":"AAAA;;;CAGC,GACD,SAASA,UAAU,EAAaC,YAAY,QAAQ,aAAa;AACjE,SAASC,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAEEC,eAAe,QAEV,uCAAuC;AAC9C,SAASC,4BAA4B,QAAQ,8BAA8B;AAC3E,SAA6BC,YAAY,QAAQ,0BAA0B;AAG3E,MAAMC,kBAAkB,CAACC,OACvBP,aACEC,KAAK,YAAYO,OAAO,EAAE,QAAQ,GAAGD,KAAK,KAAK,CAAC,GAChD,SACAE,IAAI;AAER;;;;;;;CAOC,GACD,MAAMC,2BAA2B,CAAC;;;CAGjC,CAAC;AAEF,4DAA4D,GAC5D,OAAO,MAAMC,sBAAsB;IACjC;QAAEJ,MAAM;IAAO;IACf;QAAEA,MAAM;IAAS;IACjB;QAAEA,MAAM;IAAsB;CAC/B,CAAuD;AAExD,OAAO,MAAMK,kBAAkB,OAC7BC,MACAC,SACAC;IAEA,4CAA4C;IAC5C,MAAMC,aAAa;QACjBf,KAAKa,QAAQG,GAAG,EAAE;QAClBhB,KAAKa,QAAQG,GAAG,EAAE;KACnB,CAACC,IAAI,CAAC,CAACC,SAAWN,KAAKO,MAAM,CAACD;IAE/B,IAAIH,YAAY;QACd,MAAMd,YACJW,MACAG,YACAV,gBAAgB;QAGlB,MAAMJ,YAAYW,MAAMG,YAAYN;QAEpC,MAAMW,SAASvB,WAAWe;QAC1Bd,aAAac,MAAM;YACjB,GAAGQ,MAAM;YACTC,gBAAgB;gBACd,GAAID,OAAOC,cAAc,IAAI,CAAC,CAAC;gBAC/B,mBAAmB;oBACjBC,OAAO;oBACPC,QAAQ;wBAAC;wBAAW;qBAAc;oBAClCC,gBAAgB;wBACd,mBAAmB;4BACjBC,MAAM;wBACR;oBACF;oBACA,GAAGL,OAAOC,cAAc,CAAC,kBAAkB;gBAC7C;YACF;QACF;IACF;IAEAlB,6BACES,MACA,CAAC,GACDR,aAAaF,gBAA4CY,cAAc;QACrE;QACA;QACA;KACD;AAEL,EAAE"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
-
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
|
-
import type { IacMetadata } from '../../utils/shared-constructs-constants';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../utils/nx.js';
|
|
7
|
+
import type { IacMetadata } from '../../utils/shared-constructs-constants.js';
|
|
8
8
|
import type { TsMcpServerGeneratorSchema } from './schema';
|
|
9
9
|
/** The metadata this generator records, which its predicates read. */
|
|
10
10
|
export interface TsMcpServerMetadata extends IacMetadata {
|
|
@@ -12,7 +12,7 @@ export interface TsMcpServerMetadata extends IacMetadata {
|
|
|
12
12
|
readonly rc: string;
|
|
13
13
|
readonly auth: string;
|
|
14
14
|
}
|
|
15
|
-
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
15
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
16
16
|
readonly name: "@modelcontextprotocol/sdk";
|
|
17
17
|
}, {
|
|
18
18
|
readonly name: "zod";
|
|
@@ -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';\nimport {\n AGENT_CORE_CONSTRUCTS_PY_DEPENDENCIES,\n addMcpServerInfra,\n} from '../../utils/agent-core-constructs/agent-core-constructs';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport {\n ADOT_IMAGE_DEPENDENCIES,\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n NODE_IMAGE_DEPENDENCIES,\n nodeImageVersions,\n} from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants';\nimport { BASE_IMAGES, TS_VERSIONS } from '../../utils/versions';\nimport type { TsMcpServerGeneratorSchema } 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\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 ],\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 // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n targetSourceDir,\n {\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 { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add hosting based on infra\n if (infra === 'agentcore') {\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 dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'mcp',\n name,\n );\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n outputs: [`{workspaceRoot}/${dockerOutputDir}/Dockerfile`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', '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 // 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 dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n containers,\n });\n } else {\n // No Dockerfile needed for non-hosted MCP\n tree.delete(joinPathFragments(targetSourceDir, 'Dockerfile'));\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 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","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","ADOT_IMAGE_DEPENDENCIES","addDockerScanTarget","DOCKER_DEPENDENCIES","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","kebabCase","toClassName","getNpmScope","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","dirname","adotVersion","jaegerVersion","nodeBaseImage","node","overwriteStrategy","KeepExisting","containers","dockerImageTag","targetFilePath","bundleOutputDir","dockerOutputDir","dockerTargetName","fs","targets","cache","outputs","executor","commands","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","mcpServerNameKebabCase","projectName","delete","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,kCAA+B;AACjE,SACEC,qCAAqC,EACrCC,iBAAiB,QACZ,6DAA0D;AACjE,SACEC,yBAAyB,EACzBC,mBAAmB,QACd,+BAA4B;AACnC,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SACEC,uBAAuB,EACvBC,mBAAmB,EACnBC,mBAAmB,EACnBC,uBAAuB,EACvBC,iBAAiB,QACZ,wBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,SAAS,EAAEC,WAAW,QAAQ,uBAAoB;AAC3D,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,qBAAqB,EACrBC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SA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ACZ7D,SAAS;gBACPyC,UAAU;oBAAC,CAAC,YAAY,EAAE9B,kBAAkB,QAAQ,CAAC;iBAAC;gBACtDmD,KAAK;gBACLC,KAAK;oBACHC,MAAM,GAAGX,cAAc;oBACvBY,WAAW;gBACb;YACF;QACF;QACA,CAAC,GAAGzD,gBAAgB,QAAQ,CAAC,CAAC,EAAE;YAC9BgC,UAAU;YACVqB,YAAY;YACZ,uEAAuE;YACvE,wEAAwE;YACxE,aAAa;YACbjB,WAAW;gBAAC,GAAGpC,gBAAgB,IAAI,CAAC;aAAC;YACrCR,SAAS;gBACPyC,UAAU;oBACR,CAAC,6DAA6D,EAAEY,aAAa,IAAI,CAAC;iBACnF;gBACDS,KAAK;YACP;QACF;QACA,CAAC,GAAGtD,gBAAgB,cAAc,CAAC,CAAC,EAAE;YACpCgC,UAAU;YACVqB,YAAY;YACZ7D,SAAS;gBACPyC,UAAU;oBACR,CAAC,6BAA6B,EAAE9B,kBAAkB,SAAS,CAAC;iBAC7D;gBACDmD,KAAK;YACP;QACF;IACF;IAEA,8DAA8D;IAC9DpF,sBAAsBkF,YAAY,GAAGpD,gBAAgB,IAAI,CAAC;IAE1DtD,2BAA2B6C,MAAME,QAAQT,IAAI,EAAE;QAC7C,GAAGS,OAAO;QACV,yEAAyE;QACzE,uBAAuB;QACvBoC,SAAStD,eAAe6E;IAC1B;IAEAjF,8BACEoB,MACAE,QAAQT,IAAI,EACZI,8BACAa,sCACAD,iBACAgD;IAGF,MAAMnF,gCAAgC0B,MAAM;QAACH;KAA6B;IAE1E,MAAM5B,qBAAqB+B;IAC3B,OAAO,IACL3B,oBAAoB2B,MAAMC,QAAQkE,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAerE,qBAAqB"}
|
|
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 addMcpServerInfra,\n} from '../../utils/agent-core-constructs/agent-core-constructs.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 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 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 } 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\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 ],\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 // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n targetSourceDir,\n {\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 { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add hosting based on infra\n if (infra === 'agentcore') {\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 dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'mcp',\n name,\n );\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n outputs: [`{workspaceRoot}/${dockerOutputDir}/Dockerfile`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', '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 // 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 dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n containers,\n });\n } else {\n // No Dockerfile needed for non-hosted MCP\n tree.delete(joinPathFragments(targetSourceDir, 'Dockerfile'));\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 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","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","ADOT_IMAGE_DEPENDENCIES","addDockerScanTarget","DOCKER_DEPENDENCIES","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","kebabCase","toClassName","getNpmScope","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","dirname","adotVersion","jaegerVersion","nodeBaseImage","node","overwriteStrategy","KeepExisting","containers","dockerImageTag","targetFilePath","bundleOutputDir","dockerOutputDir","dockerTargetName","fs","targets","cache","outputs","executor","commands","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","mcpServerNameKebabCase","projectName","delete","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,EACrCC,iBAAiB,QACZ,6DAA6D;AACpE,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,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,qBAAqB,EACrBC,6BAA6B,EA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../../packages/nx-plugin/src/ts/mcp-server/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac';\n\nexport type TsMcpServerInfra = 'none' | 'agentcore';\n\nexport type TsMcpServerAuth = 'iam' | 'cognito';\n\nexport interface TsMcpServerGeneratorSchema {\n project: string;\n name?: string;\n infra?: TsMcpServerInfra;\n auth?: TsMcpServerAuth;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAQD,WAOC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac.js';\n\nexport type TsMcpServerInfra = 'none' | 'agentcore';\n\nexport type TsMcpServerAuth = 'iam' | 'cognito';\n\nexport interface TsMcpServerGeneratorSchema {\n project: string;\n name?: string;\n infra?: TsMcpServerInfra;\n auth?: TsMcpServerAuth;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAQD,WAOC"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
6
|
import type { TsNxGeneratorGeneratorSchema } from './schema';
|
|
7
|
-
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
7
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
8
8
|
readonly name: "@nx/devkit";
|
|
9
|
-
}], readonly import("../../utils/declared-dependencies").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" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
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" | "ruff" | "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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-generator/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n writeJson,\n} from '@nx/devkit';\nimport camelCase from 'lodash.camelcase';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { addStarExport, applyGritQL } from '../../utils/ast';\nimport { declareDependencies } from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, pascalCase, snakeCase } from '../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport {\n configureTsProjectAsNxPlugin,\n NX_PLUGIN_DEPENDENCIES,\n} from '../nx-plugin/utils';\nimport type { TsNxGeneratorGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...NX_PLUGIN_DEPENDENCIES],\n});\n\nexport const NX_GENERATOR_GENERATOR_INFO = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsNxGeneratorGenerator = async (\n tree: Tree,\n options: TsNxGeneratorGeneratorSchema,\n): Promise<GeneratorCallback | void> => {\n const { name, directory, project: pluginProject, description } = options;\n\n const plugin = readProjectConfigurationUnqualified(tree, pluginProject);\n const sourceRoot = plugin.sourceRoot ?? joinPathFragments(plugin.root, 'src');\n const sourceRootParts = sourceRoot.split('/');\n const srcDir = sourceRootParts[sourceRootParts.length - 1];\n const generatorSubDir = directory ?? kebabCase(name);\n const generatorDir = joinPathFragments(sourceRoot, generatorSubDir);\n\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n const isNxPluginForAws = rootPackageJson?.name === '@aws/nx-plugin-source';\n\n // Configure the targeted project as an Nx Plugin\n configureTsProjectAsNxPlugin(tree, pluginProject, DEPENDENCIES);\n\n const enhancedOptions = {\n name,\n description,\n namePascalCase: pascalCase(name),\n nameCamelCase: camelCase(name),\n nameKebabCase: kebabCase(name),\n nameUpperSnakeCase: snakeCase(name).toUpperCase(),\n isNxPluginForAws,\n pathToProjectSourceRoot: getRelativePathToRootByDirectory(generatorSubDir),\n generatorDir,\n generatorSubDir,\n ...esmVars(tree),\n };\n\n // Add the common files, preserving any the user has already implemented\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n generatorDir,\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add the files specific to this repo vs a local generator in another project\n if (isNxPluginForAws) {\n // Generators should be in the @aws/nx-plugin project\n if (pluginProject !== PackageJson.name) {\n throw new Error(\n `Generators should be added to the ${PackageJson.name} project.`,\n );\n }\n\n // Add the generator\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'nx-plugin-for-aws',\n 'generator',\n ),\n generatorDir,\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Generate guide page in docs\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'nx-plugin-for-aws',\n 'docs',\n ),\n joinPathFragments('docs', 'src', 'content', 'docs', 'en', 'guides'),\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Update the docs config to add the page entry to the Generator guides sidebar section\n await applyGritQL(\n tree,\n joinPathFragments('docs', 'astro.config.mjs'),\n `\\`items: [$items]\\` where { $items <: within \\`sidebar: [$_]\\`, $items <: contains \\`'ts#project'\\`, $items <: not contains \\`'/guides/${enhancedOptions.nameKebabCase}'\\`, $items += \\`, { label: '${name}', link: '/guides/${enhancedOptions.nameKebabCase}' }\\` }`,\n );\n\n // Expose the generator from the SDK for known prefixes (ts# / py#)\n addSdkExport(tree, plugin.root, name, generatorSubDir, enhancedOptions);\n } else {\n // Local generator in a project other than nx-plugin-for-aws\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'local'),\n generatorDir,\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const indexPath = joinPathFragments(sourceRoot, 'index.ts');\n if (tree.exists(indexPath)) {\n // ESM projects require the explicit `.js` extension; `addStarExport`\n // strips it for CommonJS workspaces.\n await addStarExport(tree, indexPath, `./${generatorSubDir}/generator.js`);\n }\n\n addComponentGeneratorMetadata(\n tree,\n plugin.name,\n NX_GENERATOR_GENERATOR_INFO,\n joinPathFragments(srcDir, generatorSubDir),\n name,\n );\n }\n\n const factoryBasePath = `./${srcDir}/${generatorSubDir}`;\n\n // Update generators.json\n const generatorsJsonPath = joinPathFragments(plugin.root, 'generators.json');\n const generatorsJson = tree.exists(generatorsJsonPath)\n ? readJson(tree, generatorsJsonPath)\n : { generators: {} };\n // Metrics are only tracked within the @aws/nx-plugin repo. Reuse the existing\n // metric for a same-name re-run, otherwise allocate a new one.\n let metric: string | undefined;\n if (isNxPluginForAws) {\n const existingMetrics = Object.values(generatorsJson?.generators ?? {})\n .map((g: any) => g.metric)\n .filter((m): m is string => typeof m === 'string');\n metric =\n generatorsJson?.generators?.[name]?.metric ??\n (existingMetrics.length > 0 ? incrementMetric(existingMetrics) : 'g1');\n }\n writeJson(tree, generatorsJsonPath, {\n ...generatorsJson,\n generators: sortObjectKeys({\n ...generatorsJson?.generators,\n [name]: {\n factory: `${factoryBasePath}/generator`,\n schema: `${factoryBasePath}/schema.json`,\n description:\n description ?? 'TODO: Add short description of the generator',\n ...(isNxPluginForAws ? { metric } : {}),\n },\n }),\n });\n\n await addGeneratorMetricsIfApplicable(tree, [NX_GENERATOR_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n // The generated generator.ts imports @nx/devkit, which must resolve for\n // Nx to run it (bun's isolated layout doesn't hoist it from @nx/js).\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: ['@nx/devkit'],\n });\n};\n\nconst incrementMetric = (metrics: string[]): string => {\n const maxMetric = Math.max(...metrics.map((m) => Number(m.slice(1))));\n return `g${maxMetric + 1}`;\n};\n\n// Maps a generator name prefix to the SDK entry point that should re-export it\nconst SDK_EXPORT_PREFIXES: Record<string, string> = {\n 'ts#': 'ts',\n 'py#': 'py',\n};\n\n// Re-exports a generated generator from the matching SDK entry point so it is\n// available programmatically as part of @aws/nx-plugin's SDK\nconst addSdkExport = (\n tree: Tree,\n pluginRoot: string,\n name: string,\n generatorSubDir: string,\n options: { nameCamelCase: string; namePascalCase: string },\n): void => {\n const prefix = Object.keys(SDK_EXPORT_PREFIXES).find((p) =>\n name.startsWith(p),\n );\n if (!prefix) {\n return;\n }\n\n const sdkPath = joinPathFragments(\n pluginRoot,\n 'src',\n 'sdk',\n `${SDK_EXPORT_PREFIXES[prefix]}.ts`,\n );\n const generatorExport = `${options.nameCamelCase}Generator`;\n const schemaExport = `${options.namePascalCase}GeneratorSchema`;\n const moduleBase = `../${generatorSubDir}`;\n\n const contents = tree.exists(sdkPath) ? tree.read(sdkPath).toString() : '';\n // Idempotent: skip if this generator is already exported\n if (contents.includes(`${moduleBase}/generator`)) {\n return;\n }\n\n const block = `// ${options.namePascalCase} Generator\\nexport { ${generatorExport} } from '${moduleBase}/generator';\\nexport type { ${schemaExport} } from '${moduleBase}/schema';\\n`;\n\n const prefixContents = contents.trim()\n ? `${contents.replace(/\\s*$/, '')}\\n\\n`\n : '';\n tree.write(sdkPath, `${prefixContents}${block}`);\n};\n\nexport default tsNxGeneratorGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readJson","writeJson","camelCase","PackageJson","type","addStarExport","applyGritQL","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","pascalCase","snakeCase","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","getRelativePathToRootByDirectory","configureTsProjectAsNxPlugin","NX_PLUGIN_DEPENDENCIES","DEPENDENCIES","ts","NX_GENERATOR_GENERATOR_INFO","filename","tsNxGeneratorGenerator","tree","options","name","directory","project","pluginProject","description","plugin","sourceRoot","root","sourceRootParts","split","srcDir","length","generatorSubDir","generatorDir","rootPackageJson","exists","undefined","isNxPluginForAws","enhancedOptions","namePascalCase","nameCamelCase","nameKebabCase","nameUpperSnakeCase","toUpperCase","pathToProjectSourceRoot","dirname","overwriteStrategy","KeepExisting","Error","addSdkExport","indexPath","factoryBasePath","generatorsJsonPath","generatorsJson","generators","metric","existingMetrics","Object","values","map","g","filter","m","incrementMetric","factory","schema","preferInstallDependencies","languages","ensureResolvable","metrics","maxMetric","Math","max","Number","slice","SDK_EXPORT_PREFIXES","pluginRoot","prefix","keys","find","p","startsWith","sdkPath","generatorExport","schemaExport","moduleBase","contents","read","toString","includes","block","prefixContents","trim","replace","write"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,SAAS,QACJ,aAAa;AACpB,OAAOC,eAAe,mBAAmB;AACzC,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,aAAa,EAAEC,WAAW,QAAQ,qBAAkB;AAC7D,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,OAAO,QAAQ,+BAA4B;AACpD,SAASC,SAAS,EAAEC,UAAU,EAAEC,SAAS,QAAQ,uBAAoB;AACrE,SACEC,6BAA6B,EAC7BC,gBAAgB,EAChBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SAASC,gCAAgC,QAAQ,uBAAoB;AACrE,SACEC,4BAA4B,EAC5BC,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AG;AAC5B;AAEA,+EAA+E;AAC/E,MAAMK,sBAA8C;IAClD,OAAO;IACP,OAAO;AACT;AAEA,8EAA8E;AAC9E,6DAA6D;AAC7D,MAAM1B,eAAe,CACnB/B,MACA0D,YACAxD,MACAY,iBACAb;IAEA,MAAM0D,SAASpB,OAAOqB,IAAI,CAACH,qBAAqBI,IAAI,CAAC,CAACC,IACpD5D,KAAK6D,UAAU,CAACD;IAElB,IAAI,CAACH,QAAQ;QACX;IACF;IAEA,MAAMK,UAAU7F,kBACduF,YACA,OACA,OACA,GAAGD,mBAAmB,CAACE,OAAO,CAAC,GAAG,CAAC;IAErC,MAAMM,kBAAkB,GAAGhE,QAAQqB,aAAa,CAAC,SAAS,CAAC;IAC3D,MAAM4C,eAAe,GAAGjE,QAAQoB,cAAc,CAAC,eAAe,CAAC;IAC/D,MAAM8C,aAAa,CAAC,GAAG,EAAErD,iBAAiB;IAE1C,MAAMsD,WAAWpE,KAAKiB,MAAM,CAAC+C,WAAWhE,KAAKqE,IAAI,CAACL,SAASM,QAAQ,KAAK;IACxE,yDAAyD;IACzD,IAAIF,SAASG,QAAQ,CAAC,GAAGJ,WAAW,UAAU,CAAC,GAAG;QAChD;IACF;IAEA,MAAMK,QAAQ,CAAC,GAAG,EAAEvE,QAAQoB,cAAc,CAAC,qBAAqB,EAAE4C,gBAAgB,SAAS,EAAEE,WAAW,4BAA4B,EAAED,aAAa,SAAS,EAAEC,WAAW,WAAW,CAAC;IAErL,MAAMM,iBAAiBL,SAASM,IAAI,KAChC,GAAGN,SAASO,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,GACrC;IACJ3E,KAAK4E,KAAK,CAACZ,SAAS,GAAGS,iBAAiBD,OAAO;AACjD;AAEA,eAAezE,uBAAuB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-generator/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n writeJson,\n} from '@nx/devkit';\nimport camelCase from 'lodash.camelcase';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { addStarExport, applyGritQL } from '../../utils/ast.js';\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { esmVars } from '../../utils/module-format.js';\nimport { kebabCase, pascalCase, snakeCase } from '../../utils/names.js';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths.js';\nimport {\n configureTsProjectAsNxPlugin,\n NX_PLUGIN_DEPENDENCIES,\n} from '../nx-plugin/utils.js';\nimport type { TsNxGeneratorGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...NX_PLUGIN_DEPENDENCIES],\n});\n\nexport const NX_GENERATOR_GENERATOR_INFO = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsNxGeneratorGenerator = async (\n tree: Tree,\n options: TsNxGeneratorGeneratorSchema,\n): Promise<GeneratorCallback | void> => {\n const { name, directory, project: pluginProject, description } = options;\n\n const plugin = readProjectConfigurationUnqualified(tree, pluginProject);\n const sourceRoot = plugin.sourceRoot ?? joinPathFragments(plugin.root, 'src');\n const sourceRootParts = sourceRoot.split('/');\n const srcDir = sourceRootParts[sourceRootParts.length - 1];\n const generatorSubDir = directory ?? kebabCase(name);\n const generatorDir = joinPathFragments(sourceRoot, generatorSubDir);\n\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n const isNxPluginForAws = rootPackageJson?.name === '@aws/nx-plugin-source';\n\n // Configure the targeted project as an Nx Plugin\n configureTsProjectAsNxPlugin(tree, pluginProject, DEPENDENCIES);\n\n const enhancedOptions = {\n name,\n description,\n namePascalCase: pascalCase(name),\n nameCamelCase: camelCase(name),\n nameKebabCase: kebabCase(name),\n nameUpperSnakeCase: snakeCase(name).toUpperCase(),\n isNxPluginForAws,\n pathToProjectSourceRoot: getRelativePathToRootByDirectory(generatorSubDir),\n generatorDir,\n generatorSubDir,\n ...esmVars(tree),\n };\n\n // Add the common files, preserving any the user has already implemented\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n generatorDir,\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add the files specific to this repo vs a local generator in another project\n if (isNxPluginForAws) {\n // Generators should be in the @aws/nx-plugin project\n if (pluginProject !== PackageJson.name) {\n throw new Error(\n `Generators should be added to the ${PackageJson.name} project.`,\n );\n }\n\n // Add the generator\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'nx-plugin-for-aws',\n 'generator',\n ),\n generatorDir,\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Generate guide page in docs\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n 'nx-plugin-for-aws',\n 'docs',\n ),\n joinPathFragments('docs', 'src', 'content', 'docs', 'en', 'guides'),\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Update the docs config to add the page entry to the Generator guides sidebar section\n await applyGritQL(\n tree,\n joinPathFragments('docs', 'astro.config.mjs'),\n `\\`items: [$items]\\` where { $items <: within \\`sidebar: [$_]\\`, $items <: contains \\`'ts#project'\\`, $items <: not contains \\`'/guides/${enhancedOptions.nameKebabCase}'\\`, $items += \\`, { label: '${name}', link: '/guides/${enhancedOptions.nameKebabCase}' }\\` }`,\n );\n\n // Expose the generator from the SDK for known prefixes (ts# / py#)\n addSdkExport(tree, plugin.root, name, generatorSubDir, enhancedOptions);\n } else {\n // Local generator in a project other than nx-plugin-for-aws\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'local'),\n generatorDir,\n {\n ...enhancedOptions,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const indexPath = joinPathFragments(sourceRoot, 'index.ts');\n if (tree.exists(indexPath)) {\n // ESM projects require the explicit `.js` extension; `addStarExport`\n // strips it for CommonJS workspaces.\n await addStarExport(tree, indexPath, `./${generatorSubDir}/generator.js`);\n }\n\n addComponentGeneratorMetadata(\n tree,\n plugin.name,\n NX_GENERATOR_GENERATOR_INFO,\n joinPathFragments(srcDir, generatorSubDir),\n name,\n );\n }\n\n const factoryBasePath = `./${srcDir}/${generatorSubDir}`;\n\n // Update generators.json\n const generatorsJsonPath = joinPathFragments(plugin.root, 'generators.json');\n const generatorsJson = tree.exists(generatorsJsonPath)\n ? readJson(tree, generatorsJsonPath)\n : { generators: {} };\n // Metrics are only tracked within the @aws/nx-plugin repo. Reuse the existing\n // metric for a same-name re-run, otherwise allocate a new one.\n let metric: string | undefined;\n if (isNxPluginForAws) {\n const existingMetrics = Object.values(generatorsJson?.generators ?? {})\n .map((g: any) => g.metric)\n .filter((m): m is string => typeof m === 'string');\n metric =\n generatorsJson?.generators?.[name]?.metric ??\n (existingMetrics.length > 0 ? incrementMetric(existingMetrics) : 'g1');\n }\n writeJson(tree, generatorsJsonPath, {\n ...generatorsJson,\n generators: sortObjectKeys({\n ...generatorsJson?.generators,\n [name]: {\n factory: `${factoryBasePath}/generator`,\n schema: `${factoryBasePath}/schema.json`,\n description:\n description ?? 'TODO: Add short description of the generator',\n ...(isNxPluginForAws ? { metric } : {}),\n },\n }),\n });\n\n await addGeneratorMetricsIfApplicable(tree, [NX_GENERATOR_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n // The generated generator.ts imports @nx/devkit, which must resolve for\n // Nx to run it (bun's isolated layout doesn't hoist it from @nx/js).\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: ['@nx/devkit'],\n });\n};\n\nconst incrementMetric = (metrics: string[]): string => {\n const maxMetric = Math.max(...metrics.map((m) => Number(m.slice(1))));\n return `g${maxMetric + 1}`;\n};\n\n// Maps a generator name prefix to the SDK entry point that should re-export it\nconst SDK_EXPORT_PREFIXES: Record<string, string> = {\n 'ts#': 'ts',\n 'py#': 'py',\n};\n\n// Re-exports a generated generator from the matching SDK entry point so it is\n// available programmatically as part of @aws/nx-plugin's SDK\nconst addSdkExport = (\n tree: Tree,\n pluginRoot: string,\n name: string,\n generatorSubDir: string,\n options: { nameCamelCase: string; namePascalCase: string },\n): void => {\n const prefix = Object.keys(SDK_EXPORT_PREFIXES).find((p) =>\n name.startsWith(p),\n );\n if (!prefix) {\n return;\n }\n\n const sdkPath = joinPathFragments(\n pluginRoot,\n 'src',\n 'sdk',\n `${SDK_EXPORT_PREFIXES[prefix]}.ts`,\n );\n const generatorExport = `${options.nameCamelCase}Generator`;\n const schemaExport = `${options.namePascalCase}GeneratorSchema`;\n const moduleBase = `../${generatorSubDir}`;\n\n const contents = tree.exists(sdkPath) ? tree.read(sdkPath).toString() : '';\n // Idempotent: skip if this generator is already exported\n if (contents.includes(`${moduleBase}/generator`)) {\n return;\n }\n\n const block = `// ${options.namePascalCase} Generator\\nexport { ${generatorExport} } from '${moduleBase}/generator';\\nexport type { ${schemaExport} } from '${moduleBase}/schema';\\n`;\n\n const prefixContents = contents.trim()\n ? `${contents.replace(/\\s*$/, '')}\\n\\n`\n : '';\n tree.write(sdkPath, `${prefixContents}${block}`);\n};\n\nexport default tsNxGeneratorGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readJson","writeJson","camelCase","PackageJson","type","addStarExport","applyGritQL","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","pascalCase","snakeCase","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","getRelativePathToRootByDirectory","configureTsProjectAsNxPlugin","NX_PLUGIN_DEPENDENCIES","DEPENDENCIES","ts","NX_GENERATOR_GENERATOR_INFO","filename","tsNxGeneratorGenerator","tree","options","name","directory","project","pluginProject","description","plugin","sourceRoot","root","sourceRootParts","split","srcDir","length","generatorSubDir","generatorDir","rootPackageJson","exists","undefined","isNxPluginForAws","enhancedOptions","namePascalCase","nameCamelCase","nameKebabCase","nameUpperSnakeCase","toUpperCase","pathToProjectSourceRoot","dirname","overwriteStrategy","KeepExisting","Error","addSdkExport","indexPath","factoryBasePath","generatorsJsonPath","generatorsJson","generators","metric","existingMetrics","Object","values","map","g","filter","m","incrementMetric","factory","schema","preferInstallDependencies","languages","ensureResolvable","metrics","maxMetric","Math","max","Number","slice","SDK_EXPORT_PREFIXES","pluginRoot","prefix","keys","find","p","startsWith","sdkPath","generatorExport","schemaExport","moduleBase","contents","read","toString","includes","block","prefixContents","trim","replace","write"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,SAAS,QACJ,aAAa;AACpB,OAAOC,eAAe,mBAAmB;AACzC,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,aAAa,EAAEC,WAAW,QAAQ,qBAAqB;AAChE,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,OAAO,QAAQ,+BAA+B;AACvD,SAASC,SAAS,EAAEC,UAAU,EAAEC,SAAS,QAAQ,uBAAuB;AACxE,SACEC,6BAA6B,EAC7BC,gBAAgB,EAChBC,mCAAmC,QAC9B,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,gCAAgC,QAAQ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allback, type Tree } from '@nx/devkit';
|
|
6
|
-
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../utils/nx.js';
|
|
7
7
|
import type { TsNxMigrationGeneratorSchema } from './schema';
|
|
8
|
-
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
8
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
9
9
|
readonly name: "@nx/devkit";
|
|
10
|
-
}], readonly import("../../utils/declared-dependencies").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" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
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" | "ruff" | "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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-migration/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { declareDependencies } from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport {\n LATEST_MIGRATIONS_DIR,\n migrationKey,\n} from '../../utils/migration-versions';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { kebabCase } from '../../utils/names';\nimport {\n getGeneratorInfo,\n isNxPluginForAwsWorkspace,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport {\n addNxPluginDependencies,\n configureNxPluginPackageJson,\n NX_PLUGIN_DEPENDENCIES,\n readNxPluginProject,\n} from '../nx-plugin/utils';\nimport type { TsNxMigrationGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...NX_PLUGIN_DEPENDENCIES],\n});\n\nexport const NX_MIGRATION_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Scaffolds a migration in an Nx Plugin project and registers it in the\n * plugin's `migrations.json` (creating the manifest and wiring the\n * `nx-migrations` field into the plugin's `package.json` if absent), so\n * `nx migrate` applies it when users upgrade the plugin.\n *\n * Supports all three migration kinds:\n * - `deterministic`: a codemod (`implementation`).\n * - `agentic`: a `prompt` markdown file applied by the user's agent.\n * - `hybrid`: both — the codemod does the mechanical part and returns\n * `agentContext`, then the prompt hands off to the agent for the rest.\n *\n * No `version` is written — the plugin author stamps versions at release time.\n */\nexport const tsNxMigrationGenerator = async (\n tree: Tree,\n options: TsNxMigrationGeneratorSchema,\n): Promise<GeneratorCallback | void> => {\n const name = kebabCase(options.name);\n // Shown by `nx migrate` when the migration runs, so it needs to say something\n const description =\n options.description ?? 'TODO: Add short description of the migration';\n const kind = options.kind ?? 'deterministic';\n\n const hasImplementation = kind === 'deterministic' || kind === 'hybrid';\n const hasPrompt = kind === 'agentic' || kind === 'hybrid';\n const isHybrid = kind === 'hybrid';\n\n const plugin = readNxPluginProject(tree, options.project);\n\n const sourceRoot = plugin.sourceRoot ?? joinPathFragments(plugin.root, 'src');\n const srcDir = sourceRoot.split('/').filter(Boolean).pop();\n // Migrations are grouped by the release that ships them. A new one lands in\n // `latest` — the release that picks it up moves it into its version folder.\n const migrationPath = `${srcDir}/migrations/${LATEST_MIGRATIONS_DIR}/${name}`;\n const migrationDir = joinPathFragments(\n sourceRoot,\n 'migrations',\n LATEST_MIGRATIONS_DIR,\n name,\n );\n const key = migrationKey(LATEST_MIGRATIONS_DIR, name);\n\n const isNxPluginForAws = isNxPluginForAwsWorkspace(tree);\n\n // Point the plugin at its migrations manifest so `nx migrate` finds them\n const pluginPackageJsonPath = configureNxPluginPackageJson(\n tree,\n plugin,\n 'nx-migrations',\n { migrations: './migrations.json' },\n );\n\n // Migrations sit three levels below the source root, so in this repo the\n // shared utils are relative. Elsewhere they come from the SDK.\n const formatImportPath = isNxPluginForAws\n ? '../../../utils/format'\n : `${PackageJson.name}/sdk/utils/format`;\n const testImportPath = isNxPluginForAws\n ? '../../../utils/test'\n : `${PackageJson.name}/sdk/utils/test`;\n // A generated workspace resolves with `nodenext`, which needs the explicit\n // extension on the spec's sibling import; this repo resolves with `bundler`,\n // which takes it extensionless.\n const esm = !isNxPluginForAws && isEsmWorkspace(tree);\n\n // One template set covers all kinds — scaffold it, then prune what this kind\n // doesn't use.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n migrationDir,\n {\n name,\n description,\n isHybrid,\n formatImportPath,\n testImportPath,\n esm,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n if (!hasImplementation) {\n tree.delete(joinPathFragments(migrationDir, 'migration.ts'));\n tree.delete(joinPathFragments(migrationDir, 'migration.spec.ts'));\n }\n if (!hasPrompt) {\n tree.delete(joinPathFragments(migrationDir, 'prompt.md'));\n }\n\n if (isNxPluginForAws) {\n // In the plugin's own repo migrations.json is assembled from these folders\n // at build time (see utils/migration-manifest.ts), so registration is just\n // the description beside the code — its kind comes from the files present.\n // Two migration PRs then touch disjoint files rather than one shared manifest.\n const metadataPath = joinPathFragments(migrationDir, 'metadata.json');\n if (!tree.exists(metadataPath)) {\n writeJson(tree, metadataPath, { description });\n }\n } else {\n // Elsewhere, register the migration under its folder-prefixed key. The fields\n // present discriminate the kind for nx, and paths are relative to\n // migrations.json. No version is written, but an already-stamped one is kept.\n const migrationsJsonPath = joinPathFragments(\n plugin.root,\n 'migrations.json',\n );\n const migrationsJson = tree.exists(migrationsJsonPath)\n ? readJson(tree, migrationsJsonPath)\n : {\n $schema: 'http://json-schema.org/schema',\n name: readJson(tree, pluginPackageJsonPath).name ?? plugin.name,\n generators: {},\n };\n writeJson(tree, migrationsJsonPath, {\n ...migrationsJson,\n generators: sortObjectKeys({\n ...migrationsJson.generators,\n [key]: {\n ...(migrationsJson.generators?.[key]?.version\n ? { version: migrationsJson.generators[key].version }\n : {}),\n description,\n ...(hasImplementation\n ? { implementation: `./${migrationPath}/migration` }\n : {}),\n ...(hasPrompt ? { prompt: `./${migrationPath}/prompt.md` } : {}),\n },\n }),\n });\n }\n\n // Codemods import @nx/devkit and the @aws/nx-plugin SDK, both of which must\n // resolve for nx to run them\n if (hasImplementation) {\n addNxPluginDependencies(tree, pluginPackageJsonPath, DEPENDENCIES);\n }\n\n await addGeneratorMetricsIfApplicable(tree, [NX_MIGRATION_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n if (hasImplementation && !isNxPluginForAws) {\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: ['@nx/devkit'],\n });\n }\n};\n\nexport default tsNxMigrationGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readJson","writeJson","PackageJson","type","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","LATEST_MIGRATIONS_DIR","migrationKey","isEsmWorkspace","kebabCase","getGeneratorInfo","isNxPluginForAwsWorkspace","sortObjectKeys","addNxPluginDependencies","configureNxPluginPackageJson","NX_PLUGIN_DEPENDENCIES","readNxPluginProject","DEPENDENCIES","ts","NX_MIGRATION_GENERATOR_INFO","filename","tsNxMigrationGenerator","tree","options","name","description","kind","hasImplementation","hasPrompt","isHybrid","plugin","project","sourceRoot","root","srcDir","split","filter","Boolean","pop","migrationPath","migrationDir","key","isNxPluginForAws","pluginPackageJsonPath","migrations","formatImportPath","testImportPath","esm","dirname","overwriteStrategy","KeepExisting","delete","metadataPath","exists","migrationsJsonPath","migrationsJson","$schema","generators","version","implementation","prompt","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SACEC,qBAAqB,EACrBC,YAAY,QACP,oCAAiC;AACxC,SAAS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G2C,eAAeE,UAAU;gBAC5B,CAAChB,IAAI,EAAE;oBACL,GAAIc,eAAeE,UAAU,EAAE,CAAChB,IAAI,EAAEiB,UAClC;wBAAEA,SAASH,eAAeE,UAAU,CAAChB,IAAI,CAACiB,OAAO;oBAAC,IAClD,CAAC,CAAC;oBACNjC;oBACA,GAAIE,oBACA;wBAAEgC,gBAAgB,CAAC,EAAE,EAAEpB,cAAc,UAAU,CAAC;oBAAC,IACjD,CAAC,CAAC;oBACN,GAAIX,YAAY;wBAAEgC,QAAQ,CAAC,EAAE,EAAErB,cAAc,UAAU,CAAC;oBAAC,IAAI,CAAC,CAAC;gBACjE;YACF;QACF;IACF;IAEA,4EAA4E;IAC5E,6BAA6B;IAC7B,IAAIZ,mBAAmB;QACrBd,wBAAwBS,MAAMqB,uBAAuB1B;IACvD;IAEA,MAAMZ,gCAAgCiB,MAAM;QAACH;KAA4B;IAEzE,MAAMhB,qBAAqBmB;IAE3B,IAAIK,qBAAqB,CAACe,kBAAkB;QAC1C,OAAO,IACLtC,oBAAoBkB,MAAMC,QAAQsC,yBAAyB,EAAE;gBAC3DC,WAAW;oBAAC;iBAAa;gBACzBC,kBAAkB;oBAAC;iBAAa;YAClC;IACJ;AACF,EAAE;AAEF,eAAe1C,uBAAuB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-migration/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport {\n LATEST_MIGRATIONS_DIR,\n migrationKey,\n} from '../../utils/migration-versions.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport { kebabCase } from '../../utils/names.js';\nimport {\n getGeneratorInfo,\n isNxPluginForAwsWorkspace,\n type NxGeneratorInfo,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport {\n addNxPluginDependencies,\n configureNxPluginPackageJson,\n NX_PLUGIN_DEPENDENCIES,\n readNxPluginProject,\n} from '../nx-plugin/utils.js';\nimport type { TsNxMigrationGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...NX_PLUGIN_DEPENDENCIES],\n});\n\nexport const NX_MIGRATION_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Scaffolds a migration in an Nx Plugin project and registers it in the\n * plugin's `migrations.json` (creating the manifest and wiring the\n * `nx-migrations` field into the plugin's `package.json` if absent), so\n * `nx migrate` applies it when users upgrade the plugin.\n *\n * Supports all three migration kinds:\n * - `deterministic`: a codemod (`implementation`).\n * - `agentic`: a `prompt` markdown file applied by the user's agent.\n * - `hybrid`: both — the codemod does the mechanical part and returns\n * `agentContext`, then the prompt hands off to the agent for the rest.\n *\n * No `version` is written — the plugin author stamps versions at release time.\n */\nexport const tsNxMigrationGenerator = async (\n tree: Tree,\n options: TsNxMigrationGeneratorSchema,\n): Promise<GeneratorCallback | void> => {\n const name = kebabCase(options.name);\n // Shown by `nx migrate` when the migration runs, so it needs to say something\n const description =\n options.description ?? 'TODO: Add short description of the migration';\n const kind = options.kind ?? 'deterministic';\n\n const hasImplementation = kind === 'deterministic' || kind === 'hybrid';\n const hasPrompt = kind === 'agentic' || kind === 'hybrid';\n const isHybrid = kind === 'hybrid';\n\n const plugin = readNxPluginProject(tree, options.project);\n\n const sourceRoot = plugin.sourceRoot ?? joinPathFragments(plugin.root, 'src');\n const srcDir = sourceRoot.split('/').filter(Boolean).pop();\n // Migrations are grouped by the release that ships them. A new one lands in\n // `latest` — the release that picks it up moves it into its version folder.\n const migrationPath = `${srcDir}/migrations/${LATEST_MIGRATIONS_DIR}/${name}`;\n const migrationDir = joinPathFragments(\n sourceRoot,\n 'migrations',\n LATEST_MIGRATIONS_DIR,\n name,\n );\n const key = migrationKey(LATEST_MIGRATIONS_DIR, name);\n\n const isNxPluginForAws = isNxPluginForAwsWorkspace(tree);\n\n // Point the plugin at its migrations manifest so `nx migrate` finds them\n const pluginPackageJsonPath = configureNxPluginPackageJson(\n tree,\n plugin,\n 'nx-migrations',\n { migrations: './migrations.json' },\n );\n\n // Migrations sit three levels below the source root, so in this repo the\n // shared utils are relative. Elsewhere they come from the SDK.\n const formatImportPath = isNxPluginForAws\n ? '../../../utils/format'\n : `${PackageJson.name}/sdk/utils/format`;\n const testImportPath = isNxPluginForAws\n ? '../../../utils/test'\n : `${PackageJson.name}/sdk/utils/test`;\n // A generated workspace resolves with `nodenext`, which needs the explicit\n // extension on the spec's sibling import; this repo resolves with `bundler`,\n // which takes it extensionless.\n const esm = !isNxPluginForAws && isEsmWorkspace(tree);\n\n // One template set covers all kinds — scaffold it, then prune what this kind\n // doesn't use.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n migrationDir,\n {\n name,\n description,\n isHybrid,\n formatImportPath,\n testImportPath,\n esm,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n if (!hasImplementation) {\n tree.delete(joinPathFragments(migrationDir, 'migration.ts'));\n tree.delete(joinPathFragments(migrationDir, 'migration.spec.ts'));\n }\n if (!hasPrompt) {\n tree.delete(joinPathFragments(migrationDir, 'prompt.md'));\n }\n\n if (isNxPluginForAws) {\n // In the plugin's own repo migrations.json is assembled from these folders\n // at build time (see utils/migration-manifest.ts), so registration is just\n // the description beside the code — its kind comes from the files present.\n // Two migration PRs then touch disjoint files rather than one shared manifest.\n const metadataPath = joinPathFragments(migrationDir, 'metadata.json');\n if (!tree.exists(metadataPath)) {\n writeJson(tree, metadataPath, { description });\n }\n } else {\n // Elsewhere, register the migration under its folder-prefixed key. The fields\n // present discriminate the kind for nx, and paths are relative to\n // migrations.json. No version is written, but an already-stamped one is kept.\n const migrationsJsonPath = joinPathFragments(\n plugin.root,\n 'migrations.json',\n );\n const migrationsJson = tree.exists(migrationsJsonPath)\n ? readJson(tree, migrationsJsonPath)\n : {\n $schema: 'http://json-schema.org/schema',\n name: readJson(tree, pluginPackageJsonPath).name ?? plugin.name,\n generators: {},\n };\n writeJson(tree, migrationsJsonPath, {\n ...migrationsJson,\n generators: sortObjectKeys({\n ...migrationsJson.generators,\n [key]: {\n ...(migrationsJson.generators?.[key]?.version\n ? { version: migrationsJson.generators[key].version }\n : {}),\n description,\n ...(hasImplementation\n ? { implementation: `./${migrationPath}/migration` }\n : {}),\n ...(hasPrompt ? { prompt: `./${migrationPath}/prompt.md` } : {}),\n },\n }),\n });\n }\n\n // Codemods import @nx/devkit and the @aws/nx-plugin SDK, both of which must\n // resolve for nx to run them\n if (hasImplementation) {\n addNxPluginDependencies(tree, pluginPackageJsonPath, DEPENDENCIES);\n }\n\n await addGeneratorMetricsIfApplicable(tree, [NX_MIGRATION_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n if (hasImplementation && !isNxPluginForAws) {\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: ['@nx/devkit'],\n });\n }\n};\n\nexport default tsNxMigrationGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readJson","writeJson","PackageJson","type","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","LATEST_MIGRATIONS_DIR","migrationKey","isEsmWorkspace","kebabCase","getGeneratorInfo","isNxPluginForAwsWorkspace","sortObjectKeys","addNxPluginDependencies","configureNxPluginPackageJson","NX_PLUGIN_DEPENDENCIES","readNxPluginProject","DEPENDENCIES","ts","NX_MIGRATION_GENERATOR_INFO","filename","tsNxMigrationGenerator","tree","options","name","description","kind","hasImplementation","hasPrompt","isHybrid","plugin","project","sourceRoot","root","srcDir","split","filter","Boolean","pop","migrationPath","migrationDir","key","isNxPluginForAws","pluginPackageJsonPath","migrations","formatImportPath","testImportPath","esm","dirname","overwriteStrategy","KeepExisting","delete","metadataPath","exists","migrationsJsonPath","migrationsJson","$schema","generators","version","implementation","prompt","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SACEC,qBAAqB,EACrBC,YAAY,QACP,oCAAoC;AAC3C,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SACEC,gBAAgB,EAChBC,yBAAyB,QAEpB,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SACEC,uBAAuB,EACvBC,4BAA4B,EAC5BC,sBAAsB,EACtBC,mBAAmB,QACd,wBAAwB;AAG/B,OAAO,MAAMC,eAAef,sBAAsB;IAChDgB,IAAI;WAAIH;KAAuB;AACjC,GAAG;AAEH,OAAO,MAAMI,8BAA+CT,iBAC1D,YAAYU,QAAQ,EACpB;AAEF;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,yBAAyB,OACpCC,MACAC;IAEA,MAAMC,OAAOf,UAAUc,QAAQC,IAAI;IACnC,8EAA8E;IAC9E,MAAMC,cACJF,QAAQE,WAAW,IAAI;IACzB,MAAMC,OAAOH,QAAQG,IAAI,IAAI;IAE7B,MAAMC,oBAAoBD,SAAS,mBAAmBA,SAAS;IAC/D,MAAME,YAAYF,SA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O,IACLtC,oBAAoBkB,MAAMC,QAAQsC,yBAAyB,EAAE;gBAC3DC,WAAW;oBAAC;iBAAa;gBACzBC,kBAAkB;oBAAC;iBAAa;YAClC;IACJ;AACF,EAAE;AAEF,eAAe1C,uBAAuB"}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
-
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../utils/nx.js';
|
|
7
7
|
import type { TsNxPluginGeneratorSchema } from './schema';
|
|
8
|
-
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
8
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
9
9
|
readonly name: "@nx/devkit";
|
|
10
|
-
}], readonly import("../../utils/declared-dependencies").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" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
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" | "ruff" | "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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { declareDependencies } from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport tsMcpServerGenerator from '../mcp-server/generator';\nimport type { TsNxPluginGeneratorSchema } from './schema';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { esmVars } from '../../utils/module-format.js';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator.js';\nimport tsMcpServerGenerator from '../mcp-server/generator.js';\nimport type { TsNxPluginGeneratorSchema } from './schema';\nimport {\n configureTsProjectAsNxPlugin,\n NX_PLUGIN_DEPENDENCIES,\n} from './utils.js';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...NX_PLUGIN_DEPENDENCIES],\n});\n\nexport const TS_NX_PLUGIN_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsNxPluginGenerator = async (\n tree: Tree,\n options: TsNxPluginGeneratorSchema,\n): Promise<GeneratorCallback> => {\n // Generate a TypeScript project as the base\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n await tsProjectGenerator(tree, {\n ...options,\n preferInstallDependencies: false,\n });\n\n // Configure the typescript project as an Nx Plugin\n configureTsProjectAsNxPlugin(tree, fullyQualifiedName, DEPENDENCIES);\n\n // Add a \"package\" target which creates a package which can be published to NPM\n const project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n project.targets = {\n ...project.targets,\n package: {\n executor: '@nx/js:tsc',\n outputs: ['{options.outputPath}'],\n options: {\n outputPath: `dist/{projectRoot}/package`,\n main: `{projectRoot}/src/index.ts`,\n tsConfig: `{projectRoot}/tsconfig.lib.json`,\n assets: [\n `{projectRoot}/*.md`,\n `{projectRoot}/LICENSE*`,\n `{projectRoot}/NOTICE`,\n {\n input: './{projectRoot}/src',\n glob: '**/!(*.ts)',\n output: './src',\n },\n {\n input: './{projectRoot}/src',\n glob: '**/*.d.ts',\n output: './src',\n },\n {\n input: './{projectRoot}',\n glob: 'generators.json',\n output: '.',\n },\n {\n input: './{projectRoot}',\n glob: 'executors.json',\n output: '.',\n },\n ],\n },\n },\n build: {\n ...project.targets?.build,\n },\n };\n // Append the package dependency without moving an existing entry, so re-runs\n // do not reorder the build dependencies.\n addDependencyToTargetIfNotPresent(project, 'build', 'package');\n // Sort targets so their order is stable regardless of insertion order.\n project.targets = sortObjectKeys(project.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, project);\n\n // Add an MCP Server\n await tsMcpServerGenerator(tree, {\n project: fullyQualifiedName,\n infra: 'none',\n iac: 'cdk', // not used\n preferInstallDependencies: false,\n });\n\n const mcpPath = joinPathFragments(project.sourceRoot, 'mcp-server');\n const mcpServerPath = joinPathFragments(mcpPath, 'server.ts');\n\n // Remove the sample server and tools\n tree.delete(mcpServerPath);\n tree.delete(joinPathFragments(mcpPath, 'tools', 'add.ts'));\n tree.delete(joinPathFragments(mcpPath, 'resources', 'sample-guidance.ts'));\n\n // Add generator MCP server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'mcp-server'),\n mcpPath,\n {\n name: fullyQualifiedName,\n ...esmVars(tree),\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n addGeneratorMetadata(tree, project.name, TS_NX_PLUGIN_GENERATOR_INFO);\n\n await addGeneratorMetricsIfApplicable(tree, [TS_NX_PLUGIN_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsNxPluginGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","esmVars","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","tsProjectGenerator","getTsLibDetails","tsMcpServerGenerator","configureTsProjectAsNxPlugin","NX_PLUGIN_DEPENDENCIES","DEPENDENCIES","ts","TS_NX_PLUGIN_GENERATOR_INFO","filename","tsNxPluginGenerator","tree","options","fullyQualifiedName","dir","preferInstallDependencies","project","targets","package","executor","outputs","outputPath","main","tsConfig","assets","input","glob","output","build","infra","iac","mcpPath","sourceRoot","mcpServerPath","delete","dirname","name","overwriteStrategy","KeepExisting","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,OAAO,QAAQ,+BAA+B;AACvD,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,OAAOC,sBAAsBC,eAAe,QAAQ,sBAAsB;AAC1E,OAAOC,0BAA0B,6BAA6B;AAE9D,SACEC,4BAA4B,EAC5BC,sBAAsB,QACjB,aAAa;AAEpB,OAAO,MAAMC,eAAef,sBAAsB;IAChDgB,IAAI;WAAIF;KAAuB;AACjC,GAAG;AAEH,OAAO,MAAMG,8BAA+CV,iBAC1D,YAAYW,QAAQ,EACpB;AAEF,OAAO,MAAMC,sBAAsB,OACjCC,MACAC;IAEA,4CAA4C;IAC5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rCpB,KAAKuB,MAAM,CAACD;IACZtB,KAAKuB,MAAM,CAAC9C,kBAAkB2C,SAAS,SAAS;IAChDpB,KAAKuB,MAAM,CAAC9C,kBAAkB2C,SAAS,aAAa;IAEpD,2BAA2B;IAC3B5C,cACEwB,MACAvB,kBAAkB,YAAY+C,OAAO,EAAE,SAAS,eAChDJ,SACA;QACEK,MAAMvB;QACN,GAAGlB,QAAQgB,KAAK;IAClB,GACA;QAAE0B,mBAAmBhD,kBAAkBiD,YAAY;IAAC;IAGtDzC,qBAAqBc,MAAMK,QAAQoB,IAAI,EAAE5B;IAEzC,MAAMd,gCAAgCiB,MAAM;QAACH;KAA4B;IAEzE,MAAMhB,qBAAqBmB;IAC3B,OAAO,IACLlB,oBAAoBkB,MAAMC,QAAQG,yBAAyB,EAAE;YAC3DwB,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe7B,oBAAoB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
6
6
|
import type { PackageJson } from 'nx/src/utils/package-json';
|
|
7
|
-
import { type DependencyDeclaration, type MustDeclare } from '../../utils/declared-dependencies';
|
|
7
|
+
import { type DependencyDeclaration, type MustDeclare } from '../../utils/declared-dependencies.js';
|
|
8
8
|
/** Dependencies a caller must declare to configure an Nx Plugin project. */
|
|
9
9
|
export declare const NX_PLUGIN_DEPENDENCIES: readonly [{
|
|
10
10
|
readonly name: "@nx/devkit";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.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 updateJson,\n writeJson,\n} from '@nx/devkit';\nimport type { PackageJson } from 'nx/src/utils/package-json';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../../utils/declared-dependencies';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport {\n nxPluginSelfDependency,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions';\n\n/** Dependencies a caller must declare to configure an Nx Plugin project. */\nexport const NX_PLUGIN_DEPENDENCIES = [\n { name: '@nx/devkit' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n/**\n * Read the configuration of a project which can host Nx Plugin generators or\n * migrations, ie a TypeScript project.\n */\nexport const readNxPluginProject = (\n tree: Tree,\n projectName: string,\n): ProjectConfiguration => {\n const project = readProjectConfigurationUnqualified(tree, projectName);\n\n const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');\n if (!tree.exists(tsConfigPath)) {\n throw new Error(\n `Selected plugin project ${projectName} is not a TypeScript project`,\n );\n }\n\n return project;\n};\n\n/** `package.json` field pointing Nx at one of a plugin's manifests. */\ntype NxPluginManifestField = 'generators' | 'nx-migrations';\n\n/**\n * Create the plugin project's package.json if absent and point it at the given\n * manifest, returning its path.\n */\nexport const configureNxPluginPackageJson = <\n TField extends NxPluginManifestField,\n>(\n tree: Tree,\n project: ProjectConfiguration,\n manifestField: TField,\n manifestValue: PackageJson[TField],\n): string => {\n const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');\n if (!tree.exists(pluginPackageJsonPath)) {\n writeJson(tree, pluginPackageJsonPath, {\n name: project.name,\n });\n }\n const esm = isEsmWorkspace(tree);\n updateJson(tree, pluginPackageJsonPath, (pkg) => {\n // Match the plugin's module system to the workspace. Nx loads `.ts` files\n // via Node's native type stripping, as ESM (workspace root is\n // `type: module`) or CommonJS accordingly.\n pkg.type ??= esm ? 'module' : 'commonjs';\n pkg.main ??= esm ? './src/index.js' : './src/index';\n pkg[manifestField] ??= manifestValue;\n return pkg;\n });\n return pluginPackageJsonPath;\n};\n\n/**\n * Declare the dependencies the plugin's `.ts` files import on both the\n * workspace and the plugin, since both must resolve for Nx to load them. A\n * no-op inside the plugin's own monorepo, where they are already present.\n */\nexport const addNxPluginDependencies = <const D extends DependencyDeclaration>(\n tree: Tree,\n pluginPackageJsonPath: string,\n declaration: D & MustDeclare<typeof NX_PLUGIN_DEPENDENCIES, D>,\n): void => {\n const selfDependency = nxPluginSelfDependency(tree);\n if (Object.keys(selfDependency).length === 0) {\n return;\n }\n const deps = {\n ...withVersions(\n forDependencies<typeof NX_PLUGIN_DEPENDENCIES>(declaration),\n ['@nx/devkit'],\n ),\n ...selfDependency,\n };\n addDependenciesToPackageJson(tree, {}, deps);\n addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);\n};\n\n/**\n * Configures a TypeScript project as an Nx Plugin\n */\nexport const configureTsProjectAsNxPlugin = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n projectName: string,\n declaration: D & MustDeclare<typeof NX_PLUGIN_DEPENDENCIES, D>,\n) => {\n const project = readNxPluginProject(tree, projectName);\n\n // Create an empty generators.json if one dosn't exist\n const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');\n if (!tree.exists(generatorsJsonPath)) {\n writeJson(tree, generatorsJsonPath, {\n generators: {},\n });\n }\n\n const pluginPackageJsonPath = configureNxPluginPackageJson(\n tree,\n project,\n 'generators',\n './generators.json',\n );\n\n addNxPluginDependencies(\n tree,\n pluginPackageJsonPath,\n forDependencies<typeof NX_PLUGIN_DEPENDENCIES>(declaration),\n );\n};\n"],"names":["joinPathFragments","updateJson","writeJson","forDependencies","addDependenciesToPackageJson","isEsmWorkspace","nxPluginSelfDependency","readProjectConfigurationUnqualified","withVersions","NX_PLUGIN_DEPENDENCIES","name","readNxPluginProject","tree","projectName","project","tsConfigPath","root","exists","Error","configureNxPluginPackageJson","manifestField","manifestValue","pluginPackageJsonPath","esm","pkg","type","main","addNxPluginDependencies","declaration","selfDependency","Object","keys","length","deps","configureTsProjectAsNxPlugin","generatorsJsonPath","generators"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,EAGjBC,UAAU,EACVC,SAAS,QACJ,aAAa;AAEpB,SAEEC,eAAe,QAEV,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.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 updateJson,\n writeJson,\n} from '@nx/devkit';\nimport type { PackageJson } from 'nx/src/utils/package-json';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../../utils/declared-dependencies.js';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport {\n nxPluginSelfDependency,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx.js';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions.js';\n\n/** Dependencies a caller must declare to configure an Nx Plugin project. */\nexport const NX_PLUGIN_DEPENDENCIES = [\n { name: '@nx/devkit' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n/**\n * Read the configuration of a project which can host Nx Plugin generators or\n * migrations, ie a TypeScript project.\n */\nexport const readNxPluginProject = (\n tree: Tree,\n projectName: string,\n): ProjectConfiguration => {\n const project = readProjectConfigurationUnqualified(tree, projectName);\n\n const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');\n if (!tree.exists(tsConfigPath)) {\n throw new Error(\n `Selected plugin project ${projectName} is not a TypeScript project`,\n );\n }\n\n return project;\n};\n\n/** `package.json` field pointing Nx at one of a plugin's manifests. */\ntype NxPluginManifestField = 'generators' | 'nx-migrations';\n\n/**\n * Create the plugin project's package.json if absent and point it at the given\n * manifest, returning its path.\n */\nexport const configureNxPluginPackageJson = <\n TField extends NxPluginManifestField,\n>(\n tree: Tree,\n project: ProjectConfiguration,\n manifestField: TField,\n manifestValue: PackageJson[TField],\n): string => {\n const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');\n if (!tree.exists(pluginPackageJsonPath)) {\n writeJson(tree, pluginPackageJsonPath, {\n name: project.name,\n });\n }\n const esm = isEsmWorkspace(tree);\n updateJson(tree, pluginPackageJsonPath, (pkg) => {\n // Match the plugin's module system to the workspace. Nx loads `.ts` files\n // via Node's native type stripping, as ESM (workspace root is\n // `type: module`) or CommonJS accordingly.\n pkg.type ??= esm ? 'module' : 'commonjs';\n pkg.main ??= esm ? './src/index.js' : './src/index';\n pkg[manifestField] ??= manifestValue;\n return pkg;\n });\n return pluginPackageJsonPath;\n};\n\n/**\n * Declare the dependencies the plugin's `.ts` files import on both the\n * workspace and the plugin, since both must resolve for Nx to load them. A\n * no-op inside the plugin's own monorepo, where they are already present.\n */\nexport const addNxPluginDependencies = <const D extends DependencyDeclaration>(\n tree: Tree,\n pluginPackageJsonPath: string,\n declaration: D & MustDeclare<typeof NX_PLUGIN_DEPENDENCIES, D>,\n): void => {\n const selfDependency = nxPluginSelfDependency(tree);\n if (Object.keys(selfDependency).length === 0) {\n return;\n }\n const deps = {\n ...withVersions(\n forDependencies<typeof NX_PLUGIN_DEPENDENCIES>(declaration),\n ['@nx/devkit'],\n ),\n ...selfDependency,\n };\n addDependenciesToPackageJson(tree, {}, deps);\n addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);\n};\n\n/**\n * Configures a TypeScript project as an Nx Plugin\n */\nexport const configureTsProjectAsNxPlugin = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n projectName: string,\n declaration: D & MustDeclare<typeof NX_PLUGIN_DEPENDENCIES, D>,\n) => {\n const project = readNxPluginProject(tree, projectName);\n\n // Create an empty generators.json if one dosn't exist\n const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');\n if (!tree.exists(generatorsJsonPath)) {\n writeJson(tree, generatorsJsonPath, {\n generators: {},\n });\n }\n\n const pluginPackageJsonPath = configureNxPluginPackageJson(\n tree,\n project,\n 'generators',\n './generators.json',\n );\n\n addNxPluginDependencies(\n tree,\n pluginPackageJsonPath,\n forDependencies<typeof NX_PLUGIN_DEPENDENCIES>(declaration),\n );\n};\n"],"names":["joinPathFragments","updateJson","writeJson","forDependencies","addDependenciesToPackageJson","isEsmWorkspace","nxPluginSelfDependency","readProjectConfigurationUnqualified","withVersions","NX_PLUGIN_DEPENDENCIES","name","readNxPluginProject","tree","projectName","project","tsConfigPath","root","exists","Error","configureNxPluginPackageJson","manifestField","manifestValue","pluginPackageJsonPath","esm","pkg","type","main","addNxPluginDependencies","declaration","selfDependency","Object","keys","length","deps","configureTsProjectAsNxPlugin","generatorsJsonPath","generators"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,EAGjBC,UAAU,EACVC,SAAS,QACJ,aAAa;AAEpB,SAEEC,eAAe,QAEV,uCAAuC;AAC9C,SAASC,4BAA4B,QAAQ,8BAA8B;AAC3E,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SACEC,sBAAsB,EACtBC,mCAAmC,QAC9B,oBAAoB;AAC3B,SAA6BC,YAAY,QAAQ,0BAA0B;AAE3E,0EAA0E,GAC1E,OAAO,MAAMC,yBAAyB;IACpC;QAAEC,MAAM;IAAa;CACtB,CAAuD;AAExD;;;CAGC,GACD,OAAO,MAAMC,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,UAAUP,oCAAoCK,MAAMC;IAE1D,MAAME,eAAef,kBAAkBc,QAAQE,IAAI,EAAE;IACrD,IAAI,CAACJ,KAAKK,MAAM,CAACF,eAAe;QAC9B,MAAM,IAAIG,MACR,CAAC,wBAAwB,EAAEL,YAAY,4BAA4B,CAAC;IAExE;IAEA,OAAOC;AACT,EAAE;AAKF;;;CAGC,GACD,OAAO,MAAMK,+BAA+B,CAG1CP,MACAE,SACAM,eACAC;IAEA,MAAMC,wBAAwBtB,kBAAkBc,QAAQE,IAAI,EAAE;IAC9D,IAAI,CAACJ,KAAKK,MAAM,CAACK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eneratorInfo } from '../../../utils/nx';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../../utils/nx.js';
|
|
7
7
|
import type { TsRdbAgentConnectionGeneratorSchema } from './schema';
|
|
8
8
|
export declare const TS_RDB_AGENT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
9
|
export declare const tsRdbAgentConnectionGenerator: (tree: Tree, options: TsRdbAgentConnectionGeneratorSchema) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/rdb/agent-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport camelCase from 'lodash.camelcase';\nimport { addDestructuredImport, applyGritQL } from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { pascalCase } from '../../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { toProjectRelativePath } from '../../../utils/paths';\nimport { injectRdsCaBundleIntoDockerfile } from '../utils';\nimport type { TsRdbAgentConnectionGeneratorSchema } from './schema';\n\nexport const TS_RDB_AGENT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const tsRdbAgentConnectionGenerator = async (\n tree: Tree,\n options: TsRdbAgentConnectionGeneratorSchema,\n): Promise<void> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const agentName = options.sourceComponent?.name ?? 'agent';\n const devTarget = `${agentName}-dev`;\n\n if (sourceProject.targets?.[devTarget]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTarget, {\n projects: [targetProject.name],\n target: 'dev',\n });\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n const rdbBaseName = targetProject.name.split('/').pop();\n const rdbNameCamel = camelCase(rdbBaseName);\n const rdbNamePascal = pascalCase(rdbBaseName);\n const rdbPackageAlias = targetProject.name;\n const getterAlias = `getPrisma as get${rdbNamePascal}`;\n\n const agentSourceDir = joinPathFragments(\n sourceProject.root,\n 'src',\n agentName,\n );\n const agentPath = joinPathFragments(agentSourceDir, 'agent.ts');\n\n // Dockerfile: install RDS CA bundle for direct Aurora SSL connections\n const dockerfilePath = joinPathFragments(agentSourceDir, 'Dockerfile');\n injectRdsCaBundleIntoDockerfile(tree, dockerfilePath);\n\n if (tree.exists(agentPath)) {\n await addDestructuredImport(\n tree,\n agentPath,\n [getterAlias],\n rdbPackageAlias,\n );\n\n // Block body form: export const getAgent = async () => { ... }\n await applyGritQL(\n tree,\n agentPath,\n `\\`export const getAgent = async () => { $body }\\` => raw\\`export const getAgent = async () => {\n const ${rdbNameCamel} = await get${rdbNamePascal}();\n $body\n}\\` where { $body <: not some \\`const ${rdbNameCamel} = await get${rdbNamePascal}()\\` }`,\n );\n\n // Expression body form: export const getAgent = async () => expr\n await applyGritQL(\n tree,\n agentPath,\n `\\`export const getAgent = async () => $expr\\` => raw\\`export const getAgent = async () => {\n const ${rdbNameCamel} = await get${rdbNamePascal}();\n return $expr;\n}\\` where { $expr <: not \\`{ $_ }\\` }`,\n );\n\n // Add $on error handler after the db declaration.\n // Done via string replacement because GritQL treats $on as a metavariable.\n const dbDecl = `const ${rdbNameCamel} = await get${rdbNamePascal}();`;\n const onCall = `${rdbNameCamel}.$on('error', console.error);`;\n const content = tree.read(agentPath, 'utf-8')!;\n if (content.includes(dbDecl) && !content.includes(`${rdbNameCamel}.$on`)) {\n tree.write(agentPath, content.replace(dbDecl, `${dbDecl}\\n ${onCall}`));\n }\n }\n\n // Recorded so the version sync can identify this connection.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n TS_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n toProjectRelativePath(sourceProject, agentPath),\n `${agentName}-${rdbNameCamel}`,\n // The source component this connection is made from, so the pair is\n // identifiable rather than just the two projects.\n { sourcePath: options.sourceComponent?.path },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n TS_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n};\n\nexport default tsRdbAgentConnectionGenerator;\n"],"names":["joinPathFragments","updateProjectConfiguration","camelCase","addDestructuredImport","applyGritQL","formatFilesInSubtree","addGeneratorMetricsIfApplicable","pascalCase","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","injectRdsCaBundleIntoDockerfile","TS_RDB_AGENT_CONNECTION_GENERATOR_INFO","filename","tsRdbAgentConnectionGenerator","tree","options","sourceProject","targetProject","agentName","sourceComponent","name","devTarget","targets","projects","target","rdbBaseName","split","pop","rdbNameCamel","rdbNamePascal","rdbPackageAlias","getterAlias","agentSourceDir","root","agentPath","dockerfilePath","exists","dbDecl","onCall","content","read","includes","write","replace","sourcePath","path"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,OAAOC,eAAe,mBAAmB;AACzC,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/rdb/agent-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport camelCase from 'lodash.camelcase';\nimport { addDestructuredImport, applyGritQL } from '../../../utils/ast.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { pascalCase } from '../../../utils/names.js';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx.js';\nimport { toProjectRelativePath } from '../../../utils/paths.js';\nimport { injectRdsCaBundleIntoDockerfile } from '../utils.js';\nimport type { TsRdbAgentConnectionGeneratorSchema } from './schema';\n\nexport const TS_RDB_AGENT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const tsRdbAgentConnectionGenerator = async (\n tree: Tree,\n options: TsRdbAgentConnectionGeneratorSchema,\n): Promise<void> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const agentName = options.sourceComponent?.name ?? 'agent';\n const devTarget = `${agentName}-dev`;\n\n if (sourceProject.targets?.[devTarget]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTarget, {\n projects: [targetProject.name],\n target: 'dev',\n });\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n const rdbBaseName = targetProject.name.split('/').pop();\n const rdbNameCamel = camelCase(rdbBaseName);\n const rdbNamePascal = pascalCase(rdbBaseName);\n const rdbPackageAlias = targetProject.name;\n const getterAlias = `getPrisma as get${rdbNamePascal}`;\n\n const agentSourceDir = joinPathFragments(\n sourceProject.root,\n 'src',\n agentName,\n );\n const agentPath = joinPathFragments(agentSourceDir, 'agent.ts');\n\n // Dockerfile: install RDS CA bundle for direct Aurora SSL connections\n const dockerfilePath = joinPathFragments(agentSourceDir, 'Dockerfile');\n injectRdsCaBundleIntoDockerfile(tree, dockerfilePath);\n\n if (tree.exists(agentPath)) {\n await addDestructuredImport(\n tree,\n agentPath,\n [getterAlias],\n rdbPackageAlias,\n );\n\n // Block body form: export const getAgent = async () => { ... }\n await applyGritQL(\n tree,\n agentPath,\n `\\`export const getAgent = async () => { $body }\\` => raw\\`export const getAgent = async () => {\n const ${rdbNameCamel} = await get${rdbNamePascal}();\n $body\n}\\` where { $body <: not some \\`const ${rdbNameCamel} = await get${rdbNamePascal}()\\` }`,\n );\n\n // Expression body form: export const getAgent = async () => expr\n await applyGritQL(\n tree,\n agentPath,\n `\\`export const getAgent = async () => $expr\\` => raw\\`export const getAgent = async () => {\n const ${rdbNameCamel} = await get${rdbNamePascal}();\n return $expr;\n}\\` where { $expr <: not \\`{ $_ }\\` }`,\n );\n\n // Add $on error handler after the db declaration.\n // Done via string replacement because GritQL treats $on as a metavariable.\n const dbDecl = `const ${rdbNameCamel} = await get${rdbNamePascal}();`;\n const onCall = `${rdbNameCamel}.$on('error', console.error);`;\n const content = tree.read(agentPath, 'utf-8')!;\n if (content.includes(dbDecl) && !content.includes(`${rdbNameCamel}.$on`)) {\n tree.write(agentPath, content.replace(dbDecl, `${dbDecl}\\n ${onCall}`));\n }\n }\n\n // Recorded so the version sync can identify this connection.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n TS_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n toProjectRelativePath(sourceProject, agentPath),\n `${agentName}-${rdbNameCamel}`,\n // The source component this connection is made from, so the pair is\n // identifiable rather than just the two projects.\n { sourcePath: options.sourceComponent?.path },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n TS_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n};\n\nexport default tsRdbAgentConnectionGenerator;\n"],"names":["joinPathFragments","updateProjectConfiguration","camelCase","addDestructuredImport","applyGritQL","formatFilesInSubtree","addGeneratorMetricsIfApplicable","pascalCase","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","injectRdsCaBundleIntoDockerfile","TS_RDB_AGENT_CONNECTION_GENERATOR_INFO","filename","tsRdbAgentConnectionGenerator","tree","options","sourceProject","targetProject","agentName","sourceComponent","name","devTarget","targets","projects","target","rdbBaseName","split","pop","rdbNameCamel","rdbNamePascal","rdbPackageAlias","getterAlias","agentSourceDir","root","agentPath","dockerfilePath","exists","dbDecl","onCall","content","read","includes","write","replace","sourcePath","path"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,OAAOC,eAAe,mBAAmB;AACzC,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,wBAAwB;AAC3E,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,+BAA+B,QAAQ,4BAA4B;AAC5E,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAuB;AAC9B,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,+BAA+B,QAAQ,cAAc;AAG9D,OAAO,MAAMC,yCACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC,OAAO,MAAMC,gCAAgC,OAC3CC,MACAC;IAEA,MAAMC,gBAAgBR,oCACpBM,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBT,oCACpBM,MACAC,QAAQE,aAAa;IAGvB,MAAMC,YAAYH,QAAQI,eAAe,EAAEC,QAAQ;IACnD,MAAMC,YAAY,GAAGH,UAAU,IAAI,CAAC;IAEpC,IAAIF,cAAcM,OAAO,EAAE,CAACD,UAAU,EAAE;QACtCf,kCAAkCU,eAAeK,WAAW;YAC1DE,UAAU;gBAACN,cAAcG,IAAI;aAAC;YAC9BI,QAAQ;QACV;QACA1B,2BAA2BgB,MAAME,cAAcI,IAAI,EAAEJ;IACvD;IAEA,MAAMS,cAAcR,cAAcG,IAAI,CAACM,KAAK,CAAC,KAAKC,GAAG;IACrD,MAAMC,eAAe7B,UAAU0B;IAC/B,MAAMI,gBAAgBzB,WAAWqB;IACjC,MAAM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AAgCW,MAAM;QAC1CH;KACD;IACD,MAAMT,qBAAqBY;AAC7B,EAAE;AAEF,eAAeD,8BAA8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/rdb/agent-connection/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { ComponentMetadata } from '../../../utils/nx';\n\n/**\n * TypeScript types for options defined in schema.json\n */\nexport interface TsRdbAgentConnectionGeneratorSchema {\n sourceProject: string;\n targetProject: string;\n sourceComponent?: ComponentMetadata;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD;;CAEC,GACD,WAKC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/rdb/agent-connection/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { ComponentMetadata } from '../../../utils/nx.js';\n\n/**\n * TypeScript types for options defined in schema.json\n */\nexport interface TsRdbAgentConnectionGeneratorSchema {\n sourceProject: string;\n targetProject: string;\n sourceComponent?: ComponentMetadata;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD;;CAEC,GACD,WAKC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import { ComponentMetadata } from '../../../utils/nx';
|
|
5
|
+
import { ComponentMetadata } from '../../../utils/nx.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* TypeScript types for options defined in schema.json
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
-
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
3
|
-
import { type IacMetadata } from '../../utils/shared-constructs-constants';
|
|
2
|
+
import { type NxGeneratorInfo } from '../../utils/nx.js';
|
|
3
|
+
import { type IacMetadata } from '../../utils/shared-constructs-constants.js';
|
|
4
4
|
import type { TsRdbGeneratorSchema } from './schema';
|
|
5
5
|
/** The metadata this generator records, which its predicates read. */
|
|
6
6
|
export interface TsRdbMetadata extends IacMetadata {
|
|
7
7
|
readonly engine: TsRdbGeneratorSchema['engine'];
|
|
8
8
|
}
|
|
9
|
-
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
9
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
10
10
|
readonly name: "@aws-lambda-powertools/parameters";
|
|
11
11
|
}, {
|
|
12
12
|
readonly name: "@aws-sdk/client-appconfigdata";
|
|
@@ -117,7 +117,7 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
|
|
|
117
117
|
readonly name: "minimatch";
|
|
118
118
|
} & {
|
|
119
119
|
versionOnly: true;
|
|
120
|
-
}], readonly import("../../utils/declared-dependencies").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" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", TsRdbMetadata>[]>;
|
|
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" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", TsRdbMetadata>[]>;
|
|
121
121
|
export declare const TS_RDB_GENERATOR_INFO: NxGeneratorInfo;
|
|
122
122
|
export declare const tsRdbGenerator: (tree: Tree, options: TsRdbGeneratorSchema) => Promise<GeneratorCallback>;
|
|
123
123
|
export default tsRdbGenerator;
|