@aws/nx-plugin 1.0.0-rc.53 → 1.0.0-rc.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +50 -0
- package/package.json +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.js +3 -1
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/generator.d.ts +49 -1
- package/src/agentcore-gateway/generator.js +55 -22
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.js +3 -1
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/infra/app/generator.d.ts +43 -0
- package/src/infra/app/generator.js +47 -18
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +13 -0
- package/src/init/generator.js +14 -3
- package/src/init/generator.js.map +1 -1
- package/src/migrations/latest/backfill-generator-metadata/migration.d.ts +96 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js +670 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js.map +1 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.d.ts +6 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js +94 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js.map +1 -0
- package/src/preset/generator.d.ts +13 -0
- package/src/preset/generator.js +12 -3
- package/src/preset/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/generator.d.ts +24 -0
- package/src/py/agent/a2a-connection/generator.js +49 -20
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +23 -0
- package/src/py/agent/gateway-connection/generator.js +45 -11
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/generator.d.ts +146 -1
- package/src/py/agent/generator.js +173 -76
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +23 -0
- package/src/py/agent/mcp-connection/generator.js +45 -11
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/generator.d.ts +146 -0
- package/src/py/agent/react-connection/generator.js +27 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/agent-connection/generator.js +7 -1
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/py/dynamodb/fast-api-connection/generator.js +3 -1
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/generator.d.ts +29 -0
- package/src/py/dynamodb/generator.js +32 -12
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/fast-api/generator.d.ts +63 -0
- package/src/py/fast-api/generator.js +58 -23
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +16 -1
- package/src/py/fast-api/react/generator.js +15 -3
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/lambda-function/generator.d.ts +21 -0
- package/src/py/lambda-function/generator.js +29 -10
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/mcp-server/generator.d.ts +60 -0
- package/src/py/mcp-server/generator.js +62 -25
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/project/generator.d.ts +13 -0
- package/src/py/project/generator.js +29 -10
- package/src/py/project/generator.js.map +1 -1
- package/src/py/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +19 -0
- package/src/py/rdb/agent-connection/generator.js +7 -1
- package/src/py/rdb/agent-connection/generator.js.map +1 -1
- package/src/py/rdb/fast-api-connection/__snapshots__/generator.spec.ts.snap +7 -0
- package/src/py/rdb/fast-api-connection/generator.js +3 -1
- package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +89 -0
- package/src/py/rdb/generator.js +88 -40
- package/src/py/rdb/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/rdb/mcp-server-connection/generator.js +7 -1
- package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/smithy/project/generator.d.ts +7 -0
- package/src/smithy/project/generator.js +8 -2
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +15 -0
- package/src/smithy/react-connection/generator.js +17 -3
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/smithy/ts/api/generator.d.ts +79 -0
- package/src/smithy/ts/api/generator.js +77 -33
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/generator.d.ts +50 -0
- package/src/terraform/project/generator.js +63 -17
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/generator.d.ts +84 -0
- package/src/trpc/backend/generator.js +98 -38
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/generator.d.ts +37 -0
- package/src/trpc/react/generator.js +63 -26
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +46 -0
- package/src/ts/agent/a2a-connection/generator.js +53 -16
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +37 -0
- package/src/ts/agent/gateway-connection/generator.js +41 -14
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.d.ts +162 -0
- package/src/ts/agent/generator.js +166 -75
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +37 -0
- package/src/ts/agent/mcp-connection/generator.js +41 -14
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +186 -0
- package/src/ts/agent/react-connection/generator.js +70 -21
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/astro-docs/generator.d.ts +38 -0
- package/src/ts/astro-docs/generator.js +58 -19
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +24 -0
- package/src/ts/dcr-proxy/generator.js +31 -14
- package/src/ts/dcr-proxy/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/agent-connection/generator.js +7 -1
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/generator.d.ts +41 -0
- package/src/ts/dynamodb/generator.js +47 -20
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/smithy-connection/generator.js +3 -1
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/trpc-connection/generator.js +3 -1
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/lambda-function/generator.d.ts +38 -0
- package/src/ts/lambda-function/generator.js +49 -20
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lib/generator.d.ts +7 -0
- package/src/ts/lib/generator.js +8 -1
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +3 -1
- package/src/ts/lib/ts-project-utils.js +3 -2
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +10 -1
- package/src/ts/lib/vitest.js +14 -2
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/generator.d.ts +71 -0
- package/src/ts/mcp-server/generator.js +73 -36
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/generator.d.ts +3 -0
- package/src/ts/nx-generator/generator.js +8 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-migration/generator.d.ts +3 -0
- package/src/ts/nx-migration/generator.js +8 -2
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/nx-plugin/generator.d.ts +3 -0
- package/src/ts/nx-plugin/generator.js +8 -2
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +7 -2
- package/src/ts/nx-plugin/utils.js +10 -4
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/agent-connection/generator.js +8 -1
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/generator.d.ts +101 -0
- package/src/ts/rdb/generator.js +93 -41
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/mcp-server-connection/generator.js +8 -1
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/smithy-connection/generator.js +4 -1
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/trpc-connection/generator.js +3 -1
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +86 -0
- package/src/ts/react-website/agui/generator.js +63 -28
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +20 -2
- package/src/ts/react-website/app/generator.d.ts +136 -1
- package/src/ts/react-website/app/generator.js +109 -40
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/generator.d.ts +19 -0
- package/src/ts/react-website/cognito-auth/generator.js +21 -9
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/utils/add-dependencies.d.ts +38 -0
- package/src/utils/add-dependencies.js +83 -0
- package/src/utils/add-dependencies.js.map +1 -0
- package/src/utils/agent-connection/agent-connection.d.ts +27 -6
- package/src/utils/agent-connection/agent-connection.js +47 -18
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +19 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js +26 -6
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/api-constructs/api-constructs.d.ts +21 -2
- package/src/utils/api-constructs/api-constructs.js +26 -5
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/bundle/bundle.d.ts +6 -1
- package/src/utils/bundle/bundle.js +8 -2
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.d.ts +5 -4
- package/src/utils/commands.js +2 -6
- package/src/utils/commands.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +18 -1
- package/src/utils/connection/open-api/react.js +27 -3
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/declared-dependencies.d.ts +140 -0
- package/src/utils/declared-dependencies.js +64 -0
- package/src/utils/declared-dependencies.js.map +1 -0
- package/src/utils/docker.d.ts +10 -1
- package/src/utils/docker.js +7 -3
- package/src/utils/docker.js.map +1 -1
- package/src/utils/fs.d.ts +15 -4
- package/src/utils/fs.js +26 -13
- package/src/utils/fs.js.map +1 -1
- package/src/utils/init.d.ts +14 -1
- package/src/utils/init.js +25 -7
- package/src/utils/init.js.map +1 -1
- package/src/utils/migration-versions.d.ts +15 -1
- package/src/utils/migration-versions.js +53 -7
- package/src/utils/migration-versions.js.map +1 -1
- package/src/utils/nx.d.ts +18 -0
- package/src/utils/nx.js +4 -0
- package/src/utils/nx.js.map +1 -1
- package/src/utils/py.d.ts +3 -2
- package/src/utils/py.js +10 -10
- package/src/utils/py.js.map +1 -1
- package/src/utils/shared-constructs-constants.d.ts +39 -4
- package/src/utils/shared-constructs-constants.js +29 -0
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +4 -1
- package/src/utils/shared-constructs.js +5 -4
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +8 -1
- package/src/utils/shared-dynamodb-scripts.js +11 -3
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-scripts.d.ts +16 -1
- package/src/utils/shared-infra-scripts.js +18 -3
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +12 -1
- package/src/utils/shared-rdb-scripts.js +17 -3
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +26 -1
- package/src/utils/shared-shadcn.js +31 -14
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/version-upgrade-migration/migration.d.ts +14 -0
- package/src/utils/version-upgrade-migration/migration.js +16 -0
- package/src/utils/version-upgrade-migration/migration.js.map +1 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.d.ts +35 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js +42 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +50 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js +98 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -0
- package/src/utils/version-upgrade-migration/register.d.ts +18 -0
- package/src/utils/version-upgrade-migration/register.js +33 -0
- package/src/utils/version-upgrade-migration/register.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.d.ts +13 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js +33 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.d.ts +10 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js +504 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.d.ts +14 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js +40 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js.map +1 -0
- package/src/utils/versions.d.ts +25 -5
- package/src/utils/versions.js +46 -4
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/dynamodb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { relative } from 'node:path';\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDynamoDBInfra } from '../../utils/dynamodb-constructs/dynamodb-constructs';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { assignSharedPort } from '../../utils/port';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/dynamodb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { relative } from 'node:path';\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addPyDependencies } from '../../utils/add-dependencies';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport { addDynamoDBInfra } from '../../utils/dynamodb-constructs/dynamodb-constructs';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { assignSharedPort } from '../../utils/port';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport {\n DYNAMODB_GENERATOR_IDS,\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport {\n SHARED_DYNAMODB_SCRIPTS_DEPENDENCIES,\n sharedDynamoDBScriptsGenerator,\n} from '../../utils/shared-dynamodb-scripts';\nimport pyProjectGenerator, { getPyProjectDetails } from '../project/generator';\nimport type { PyDynamoDBGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n ...ownedElsewhere(SHARED_DYNAMODB_SCRIPTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: [\n { name: 'pynamodb' },\n { name: 'boto3' },\n { name: 'aws-lambda-powertools' },\n ],\n});\n\nexport const PY_DYNAMODB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const pyDynamoDBGenerator = async (\n tree: Tree,\n options: PyDynamoDBGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameClassName = toClassName(options.name);\n const localTableName = `${getNpmScope(tree)}-${kebabCase(options.tableName ?? options.name)}`;\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir, normalizedModuleName } = getPyProjectDetails(\n tree,\n {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n },\n );\n\n if (!projectExists(tree, fullyQualifiedName)) {\n await pyProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n type: 'library',\n preferInstallDependencies: false,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n\n const localDynamoDBPort = assignSharedPort(\n tree,\n projectConfig,\n DYNAMODB_GENERATOR_IDS,\n 8000,\n );\n\n const containerName = `${getNpmScope(tree)}-dynamodb`;\n\n const templateOptions = {\n name: normalizedModuleName,\n runtimeConfigKey: nameClassName,\n localDynamoDBPort,\n localTableName,\n containerName,\n containerEngine,\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n\n await sharedDynamoDBScriptsGenerator(tree, DEPENDENCIES);\n\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'dynamodb'),\n );\n\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n continuous: true,\n dependsOn: ['pull-image'],\n options: {\n commands: [\n `tsx ${scriptsDir}/start-container.ts`,\n `tsx ${scriptsDir}/create-local-table.ts`,\n ],\n parallel: true,\n cwd: '{projectRoot}',\n },\n };\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n // Recorded so the version sync can tell a CDK project from a Terraform one;\n // undefined when no infrastructure was generated.\n const iac =\n options.infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n PY_DYNAMODB_GENERATOR_INFO,\n iac ? { iac } : {},\n );\n\n if (options.infra !== 'none') {\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n await addDynamoDBInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n nameClassName,\n nameKebabCase: kebabCase(options.name),\n tableName: localTableName,\n projectRoot: dir,\n });\n }\n\n addPyDependencies(tree, DEPENDENCIES, { projectRoot: dir });\n\n await addGeneratorMetricsIfApplicable(tree, [PY_DYNAMODB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyDynamoDBGenerator;\n"],"names":["relative","generateFiles","joinPathFragments","readProjectConfiguration","updateProjectConfiguration","addPyDependencies","resolveContainers","declareDependencies","ownedElsewhere","addDynamoDBInfra","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","getNpmScope","addGeneratorMetadata","getGeneratorInfo","projectExists","assignSharedPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","DYNAMODB_GENERATOR_IDS","PACKAGES_DIR","SHARED_SCRIPTS_DIR","SHARED_DYNAMODB_SCRIPTS_DEPENDENCIES","sharedDynamoDBScriptsGenerator","pyProjectGenerator","getPyProjectDetails","DEPENDENCIES","ts","py","name","PY_DYNAMODB_GENERATOR_INFO","filename","pyDynamoDBGenerator","tree","options","nameClassName","localTableName","tableName","containerEngine","fullyQualifiedName","dir","normalizedModuleName","directory","subDirectory","type","preferInstallDependencies","projectConfig","localDynamoDBPort","containerName","templateOptions","runtimeConfigKey","dirname","scriptsDir","targets","executor","command","cwd","continuous","dependsOn","commands","parallel","iac","infra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WAAW,sBAAsB,CAAC;aAC1C;YACDQ,UAAU;YACVJ,KAAK;QACP;IACF;IAEAxD,2BAA2BiC,MAAMM,oBAAoBO;IACrD,4EAA4E;IAC5E,kDAAkD;IAClD,MAAMe,MACJ3B,QAAQ4B,KAAK,KAAK,SAAS,MAAMvD,WAAW0B,MAAMC,QAAQ2B,GAAG,IAAIE;IAEnElD,qBACEoB,MACAM,oBACAT,4BACA+B,MAAM;QAAEA;IAAI,IAAI,CAAC;IAGnB,IAAI3B,QAAQ4B,KAAK,KAAK,QAAQ;QAC5B,MAAM5C,0BAA0Be,MAAM;YAAE4B;QAAI,GAAGnC;QAC/C,MAAMrB,iBAAiB4B,MAAM;YAC3B4B;YACAG,aAAazB;YACbJ;YACA8B,eAAevD,UAAUwB,QAAQL,IAAI;YACrCQ,WAAWD;YACX8B,aAAa1B;QACf;IACF;IAEAvC,kBAAkBgC,MAAMP,cAAc;QAAEwC,aAAa1B;IAAI;IAEzD,MAAM/B,gCAAgCwB,MAAM;QAACH;KAA2B;IAExE,MAAMxB,qBAAqB2B;IAC3B,OAAO,IACLzB,oBAAoByB,MAAMC,QAAQW,yBAAyB,EAAE;YAC3DsB,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAenC,oBAAoB"}
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
exports[`py#dynamodb mcp-server-connection generator > should add dynamodb dev dependency to mcp-server dev 1`] = `
|
|
4
4
|
{
|
|
5
5
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
6
|
+
"metadata": {
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"generator": "py#dynamodb#mcp-server-connection",
|
|
10
|
+
"name": "mcp-server-db",
|
|
11
|
+
"path": "packages/db",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
6
15
|
"name": "my-mcp-server",
|
|
7
16
|
"root": "packages/my-mcp-server",
|
|
8
17
|
"targets": {
|
|
@@ -25,6 +34,15 @@ exports[`py#dynamodb mcp-server-connection generator > should add dynamodb dev d
|
|
|
25
34
|
exports[`py#dynamodb mcp-server-connection generator > should use sourceComponent name when provided 1`] = `
|
|
26
35
|
{
|
|
27
36
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
37
|
+
"metadata": {
|
|
38
|
+
"components": [
|
|
39
|
+
{
|
|
40
|
+
"generator": "py#dynamodb#mcp-server-connection",
|
|
41
|
+
"name": "custom-mcp-server-db",
|
|
42
|
+
"path": "packages/db",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
28
46
|
"name": "my-mcp-server",
|
|
29
47
|
"root": "packages/my-mcp-server",
|
|
30
48
|
"targets": {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
6
6
|
import { installDependencies } from "../../../utils/install.js";
|
|
7
7
|
import { addGeneratorMetricsIfApplicable } from "../../../utils/metrics.js";
|
|
8
|
-
import { addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
8
|
+
import { addComponentGeneratorMetadata, addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
9
9
|
import { addWorkspaceDependencyToPyProject } from "../../../utils/py.js";
|
|
10
10
|
export const PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
11
11
|
export const pyDynamoDBMcpServerConnectionGenerator = async (tree, options)=>{
|
|
@@ -23,6 +23,12 @@ export const pyDynamoDBMcpServerConnectionGenerator = async (tree, options)=>{
|
|
|
23
23
|
});
|
|
24
24
|
updateProjectConfiguration(tree, sourceProject.name, sourceProject);
|
|
25
25
|
}
|
|
26
|
+
// Recorded so the version sync can identify this connection.
|
|
27
|
+
addComponentGeneratorMetadata(tree, sourceProject.name, PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO, targetProject.root, `${mcpServerName}-${targetProject.name}`, // The source component this connection is made from, so the pair is
|
|
28
|
+
// identifiable rather than just the two projects.
|
|
29
|
+
{
|
|
30
|
+
sourcePath: options.sourceComponent?.path
|
|
31
|
+
});
|
|
26
32
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
27
33
|
PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO
|
|
28
34
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/dynamodb/mcp-server-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 type GeneratorCallback,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport {\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { addWorkspaceDependencyToPyProject } from '../../../utils/py';\nimport type { PyDynamoDBMcpServerConnectionGeneratorSchema } from './schema';\n\nexport const PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyDynamoDBMcpServerConnectionGenerator = async (\n tree: Tree,\n options: PyDynamoDBMcpServerConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n addWorkspaceDependencyToPyProject(tree, sourceProject, targetProject);\n\n const mcpServerName = options.sourceComponent?.name ?? 'mcp-server';\n const devTarget = `${mcpServerName}-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 await addGeneratorMetricsIfApplicable(tree, [\n PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyDynamoDBMcpServerConnectionGenerator;\n"],"names":["updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","addWorkspaceDependencyToPyProject","PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO","filename","pyDynamoDBMcpServerConnectionGenerator","tree","options","sourceProject","targetProject","mcpServerName","sourceComponent","name","devTarget","targets","projects","target","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAGEA,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SACEC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SAASC,iCAAiC,QAAQ,uBAAoB;AAGtE,OAAO,MAAMC,mDACXH,iBAAiB,YAAYI,QAAQ,EAAE;AAEzC,OAAO,MAAMC,yCAAyC,OACpDC,MACAC;IAEA,MAAMC,gBAAgBP,oCACpBK,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBR,oCACpBK,MACAC,QAAQE,aAAa;IAGvBP,kCAAkCI,MAAME,eAAeC;IAEvD,MAAMC,gBAAgBH,QAAQI,eAAe,EAAEC,QAAQ;IACvD,MAAMC,YAAY,GAAGH,cAAc,IAAI,CAAC;IAExC,IAAIF,cAAcM,OAAO,EAAE,CAACD,UAAU,EAAE;QACtCd,kCAAkCS,eAAeK,WAAW;YAC1DE,UAAU;gBAACN,cAAcG,IAAI;aAAC;YAC9BI,QAAQ;QACV;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/dynamodb/mcp-server-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 type GeneratorCallback,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { addWorkspaceDependencyToPyProject } from '../../../utils/py';\nimport type { PyDynamoDBMcpServerConnectionGeneratorSchema } from './schema';\n\nexport const PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyDynamoDBMcpServerConnectionGenerator = async (\n tree: Tree,\n options: PyDynamoDBMcpServerConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n addWorkspaceDependencyToPyProject(tree, sourceProject, targetProject);\n\n const mcpServerName = options.sourceComponent?.name ?? 'mcp-server';\n const devTarget = `${mcpServerName}-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 // Recorded so the version sync can identify this connection.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO,\n targetProject.root,\n `${mcpServerName}-${targetProject.name}`,\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 PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyDynamoDBMcpServerConnectionGenerator;\n"],"names":["updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","addWorkspaceDependencyToPyProject","PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO","filename","pyDynamoDBMcpServerConnectionGenerator","tree","options","sourceProject","targetProject","mcpServerName","sourceComponent","name","devTarget","targets","projects","target","root","sourcePath","path","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAGEA,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SAASC,iCAAiC,QAAQ,uBAAoB;AAGtE,OAAO,MAAMC,mDACXH,iBAAiB,YAAYI,QAAQ,EAAE;AAEzC,OAAO,MAAMC,yCAAyC,OACpDC,MACAC;IAEA,MAAMC,gBAAgBP,oCACpBK,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBR,oCACpBK,MACAC,QAAQE,aAAa;IAGvBP,kCAAkCI,MAAME,eAAeC;IAEvD,MAAMC,gBAAgBH,QAAQI,eAAe,EAAEC,QAAQ;IACvD,MAAMC,YAAY,GAAGH,cAAc,IAAI,CAAC;IAExC,IAAIF,cAAcM,OAAO,EAAE,CAACD,UAAU,EAAE;QACtCd,kCAAkCS,eAAeK,WAAW;YAC1DE,UAAU;gBAACN,cAAcG,IAAI;aAAC;YAC9BI,QAAQ;QACV;QACAtB,2BAA2BY,MAAME,cAAcI,IAAI,EAAEJ;IACvD;IAEA,6DAA6D;IAC7DV,8BACEQ,MACAE,cAAcI,IAAI,EAClBT,kDACAM,cAAcQ,IAAI,EAClB,GAAGP,cAAc,CAAC,EAAED,cAAcG,IAAI,EAAE,EACxC,oEAAoE;IACpE,kDAAkD;IAClD;QAAEM,YAAYX,QAAQI,eAAe,EAAEQ;IAAK;IAG9C,MAAMtB,gCAAgCS,MAAM;QAC1CH;KACD;IACD,MAAMR,qBAAqBW;IAC3B,OAAO,IACLV,oBAAoBU,MAAMC,QAAQa,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAehB,uCAAuC"}
|
|
@@ -4,7 +4,70 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
6
|
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
|
+
import type { IacMetadata } from '../../utils/shared-constructs-constants';
|
|
7
8
|
import type { PyFastApiProjectGeneratorSchema } from './schema';
|
|
9
|
+
/** The metadata this generator records, which its predicates read. */
|
|
10
|
+
export interface PyFastApiMetadata extends IacMetadata {
|
|
11
|
+
readonly apiName: string;
|
|
12
|
+
readonly apiType: string;
|
|
13
|
+
readonly auth: PyFastApiProjectGeneratorSchema['auth'];
|
|
14
|
+
}
|
|
15
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
16
|
+
readonly name: "ncp";
|
|
17
|
+
} & {
|
|
18
|
+
versionOnly: true;
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "rimraf";
|
|
21
|
+
} & {
|
|
22
|
+
versionOnly: true;
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "make-dir-cli";
|
|
25
|
+
} & {
|
|
26
|
+
versionOnly: true;
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "constructs";
|
|
29
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
30
|
+
} & {
|
|
31
|
+
versionOnly: true;
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "aws-cdk-lib";
|
|
34
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
35
|
+
} & {
|
|
36
|
+
versionOnly: true;
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "@types/node";
|
|
39
|
+
} & {
|
|
40
|
+
versionOnly: true;
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "@aws-sdk/client-api-gateway";
|
|
43
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
44
|
+
} & {
|
|
45
|
+
versionOnly: true;
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "@aws-sdk/client-iam";
|
|
48
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
49
|
+
} & {
|
|
50
|
+
versionOnly: true;
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "@trpc/server";
|
|
53
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
54
|
+
} & {
|
|
55
|
+
versionOnly: true;
|
|
56
|
+
}], readonly [{
|
|
57
|
+
readonly name: "fastapi";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "uvicorn";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "aws-lambda-powertools";
|
|
62
|
+
}, {
|
|
63
|
+
readonly name: "aws-lambda-powertools[tracer]";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "aws-lambda-powertools[parser]";
|
|
66
|
+
readonly when: (m: PyFastApiMetadata) => boolean;
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "fastapi[standard]";
|
|
69
|
+
readonly group: "dev";
|
|
70
|
+
}]>;
|
|
8
71
|
export declare const FAST_API_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
72
|
/**
|
|
10
73
|
* Generates a Python FastAPI project
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, readProjectConfiguration, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
-
import {
|
|
5
|
+
import { addPyDependencies } from "../../utils/add-dependencies.js";
|
|
6
|
+
import { API_CONSTRUCTS_DEPENDENCIES, addApiGatewayInfra } from "../../utils/api-constructs/api-constructs.js";
|
|
6
7
|
import { addSharedConstructsOpenApiMetadataGenerateTarget } from "../../utils/api-constructs/open-api-metadata.js";
|
|
7
8
|
import { addPythonBundleTarget } from "../../utils/bundle/bundle.js";
|
|
9
|
+
import { declareDependencies, ownedElsewhere } from "../../utils/declared-dependencies.js";
|
|
8
10
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
9
|
-
import { FsCommands } from "../../utils/fs.js";
|
|
11
|
+
import { FS_DEPENDENCIES, FsCommands } from "../../utils/fs.js";
|
|
10
12
|
import { resolveIac } from "../../utils/iac.js";
|
|
11
13
|
import { installDependencies } from "../../utils/install.js";
|
|
12
14
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
@@ -14,10 +16,40 @@ import { toClassName, toKebabCase } from "../../utils/names.js";
|
|
|
14
16
|
import { addGeneratorMetadata, getGeneratorInfo } from "../../utils/nx.js";
|
|
15
17
|
import { sortObjectKeys } from "../../utils/object.js";
|
|
16
18
|
import { assignPort } from "../../utils/port.js";
|
|
17
|
-
import {
|
|
18
|
-
import { sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
19
|
+
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
19
20
|
import pyProjectGenerator, { getPyProjectDetails } from "../project/generator.js";
|
|
20
21
|
import { addOpenApiGeneration } from "./react/open-api.js";
|
|
22
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
23
|
+
ts: [
|
|
24
|
+
...ownedElsewhere(FS_DEPENDENCIES),
|
|
25
|
+
...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),
|
|
26
|
+
...ownedElsewhere(API_CONSTRUCTS_DEPENDENCIES)
|
|
27
|
+
],
|
|
28
|
+
py: [
|
|
29
|
+
{
|
|
30
|
+
name: 'fastapi'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'uvicorn'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'aws-lambda-powertools'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'aws-lambda-powertools[tracer]'
|
|
40
|
+
},
|
|
41
|
+
// The custom authorizer handler parses its event with the parser extra.
|
|
42
|
+
{
|
|
43
|
+
name: 'aws-lambda-powertools[parser]',
|
|
44
|
+
when: (m)=>m.auth === 'custom'
|
|
45
|
+
},
|
|
46
|
+
// `fastapi dev` runs the local server.
|
|
47
|
+
{
|
|
48
|
+
name: 'fastapi[standard]',
|
|
49
|
+
group: 'dev'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
});
|
|
21
53
|
export const FAST_API_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
22
54
|
/**
|
|
23
55
|
* Generates a Python FastAPI project
|
|
@@ -52,7 +84,7 @@ export const FAST_API_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
52
84
|
const port = assignPort(tree, projectConfig, 8000);
|
|
53
85
|
const { bundleOutputDir, bundleTargetName } = addPythonBundleTarget(projectConfig);
|
|
54
86
|
// Add a command to copy run.sh to the bundle output for Lambda Web Adapter
|
|
55
|
-
const fs = new FsCommands(tree);
|
|
87
|
+
const fs = new FsCommands(tree, DEPENDENCIES);
|
|
56
88
|
const bundleTarget = projectConfig.targets[bundleTargetName];
|
|
57
89
|
const copyRunShCommand = fs.cp(`{projectRoot}/run.sh`, `dist/{projectRoot}/${bundleTargetName}/run.sh`);
|
|
58
90
|
if (!bundleTarget.options.commands.includes(copyRunShCommand)) {
|
|
@@ -79,11 +111,23 @@ export const FAST_API_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
79
111
|
}
|
|
80
112
|
}
|
|
81
113
|
};
|
|
82
|
-
|
|
83
|
-
|
|
114
|
+
// Recorded in the metadata below so the version sync can tell a CDK
|
|
115
|
+
// project from a Terraform one; undefined when no infrastructure was
|
|
116
|
+
// generated, in which case neither provider's packages were added.
|
|
117
|
+
const iac = schema.infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;
|
|
118
|
+
// Recorded below and read by the declaration's predicates, so the packages
|
|
119
|
+
// added here are exactly the ones the version sync will own.
|
|
120
|
+
const metadata = {
|
|
84
121
|
apiName: schema.name,
|
|
85
122
|
apiType: 'fast-api',
|
|
86
|
-
auth: schema.auth
|
|
123
|
+
auth: schema.auth,
|
|
124
|
+
...iac ? {
|
|
125
|
+
iac
|
|
126
|
+
} : {}
|
|
127
|
+
};
|
|
128
|
+
projectConfig.metadata = {
|
|
129
|
+
...projectConfig.metadata,
|
|
130
|
+
...metadata
|
|
87
131
|
};
|
|
88
132
|
projectConfig.targets = sortObjectKeys(projectConfig.targets);
|
|
89
133
|
updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);
|
|
@@ -105,10 +149,9 @@ export const FAST_API_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
105
149
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
106
150
|
});
|
|
107
151
|
if (schema.infra !== 'none') {
|
|
108
|
-
const iac = await resolveIac(tree, schema.iac);
|
|
109
152
|
await sharedConstructsGenerator(tree, {
|
|
110
153
|
iac
|
|
111
|
-
});
|
|
154
|
+
}, DEPENDENCIES);
|
|
112
155
|
if (schema.auth === 'custom') {
|
|
113
156
|
const authorizerType = schema.infra === 'http-lambda' ? 'http' : 'rest';
|
|
114
157
|
generateFiles(tree, joinPathFragments(import.meta.dirname, '..', '..', 'utils', 'api-constructs', 'files', 'py-authorizer', authorizerType), joinPathFragments(dir, normalizedModuleName), {}, {
|
|
@@ -129,7 +172,7 @@ export const FAST_API_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
129
172
|
},
|
|
130
173
|
auth: schema.auth,
|
|
131
174
|
iac
|
|
132
|
-
});
|
|
175
|
+
}, DEPENDENCIES);
|
|
133
176
|
addSharedConstructsOpenApiMetadataGenerateTarget(tree, {
|
|
134
177
|
iac,
|
|
135
178
|
apiNameKebabCase,
|
|
@@ -137,18 +180,10 @@ export const FAST_API_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
137
180
|
specBuildTargetName: `${projectConfig.name}:openapi`
|
|
138
181
|
});
|
|
139
182
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
'aws-lambda-powertools[tracer]',
|
|
145
|
-
...schema.auth === 'custom' ? [
|
|
146
|
-
'aws-lambda-powertools[parser]'
|
|
147
|
-
] : []
|
|
148
|
-
]);
|
|
149
|
-
addDependenciesToDependencyGroupInPyProjectToml(tree, dir, 'dev', [
|
|
150
|
-
'fastapi[standard]'
|
|
151
|
-
]);
|
|
183
|
+
addPyDependencies(tree, DEPENDENCIES, {
|
|
184
|
+
metadata,
|
|
185
|
+
projectRoot: dir
|
|
186
|
+
});
|
|
152
187
|
addGeneratorMetadata(tree, fullyQualifiedName, FAST_API_GENERATOR_INFO);
|
|
153
188
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
154
189
|
FAST_API_GENERATOR_INFO
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/fast-api/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 ProjectConfiguration,\n readProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addApiGatewayInfra } from '../../utils/api-constructs/api-constructs';\nimport { addSharedConstructsOpenApiMetadataGenerateTarget } from '../../utils/api-constructs/open-api-metadata';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { toClassName, toKebabCase } from '../../utils/names';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { assignPort } from '../../utils/port';\nimport {\n addDependenciesToDependencyGroupInPyProjectToml,\n addDependenciesToPyProjectToml,\n} from '../../utils/py';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport pyProjectGenerator, { getPyProjectDetails } from '../project/generator';\nimport { addOpenApiGeneration } from './react/open-api';\nimport type { PyFastApiProjectGeneratorSchema } from './schema';\n\nexport const FAST_API_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Generates a Python FastAPI project\n */\nexport const pyFastApiProjectGenerator = async (\n tree: Tree,\n schema: PyFastApiProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const integrationPattern = getIntegrationPattern(schema);\n\n const { dir, normalizedModuleName, fullyQualifiedName } = getPyProjectDetails(\n tree,\n {\n name: schema.name,\n directory: schema.directory,\n subDirectory: schema.subDirectory,\n moduleName: schema.moduleName,\n },\n );\n const apiNameKebabCase = toKebabCase(schema.name);\n const apiNameClassName = toClassName(schema.name);\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await pyProjectGenerator(tree, {\n name: schema.name,\n directory: schema.directory,\n subDirectory: schema.subDirectory,\n moduleName: normalizedModuleName,\n type: 'application',\n preferInstallDependencies: false,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const port = assignPort(tree, projectConfig, 8000);\n\n const { bundleOutputDir, bundleTargetName } =\n addPythonBundleTarget(projectConfig);\n\n // Add a command to copy run.sh to the bundle output for Lambda Web Adapter\n const fs = new FsCommands(tree);\n const bundleTarget = projectConfig.targets[bundleTargetName];\n const copyRunShCommand = fs.cp(\n `{projectRoot}/run.sh`,\n `dist/{projectRoot}/${bundleTargetName}/run.sh`,\n );\n if (!bundleTarget.options.commands.includes(copyRunShCommand)) {\n bundleTarget.options.commands = [\n ...bundleTarget.options.commands,\n copyRunShCommand,\n ];\n }\n\n projectConfig.targets.serve = {\n executor: '@nxlv/python:run-commands',\n continuous: true,\n options: {\n command: `uv run fastapi dev ${normalizedModuleName}/main.py --port ${port}`,\n cwd: '{projectRoot}',\n },\n };\n\n projectConfig.targets['dev'] = {\n ...projectConfig.targets['dev'],\n ...projectConfig.targets.serve,\n options: {\n ...projectConfig.targets.serve.options,\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n\n projectConfig.metadata = {\n ...projectConfig.metadata,\n apiName: schema.name,\n apiType: 'fast-api',\n auth: schema.auth,\n } as any;\n\n projectConfig.targets = sortObjectKeys(projectConfig.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n\n // Add OpenAPI spec generation to the project, run as part of build\n const { specPath } = addOpenApiGeneration(tree, { project: projectConfig });\n\n [\n joinPathFragments(dir, normalizedModuleName, 'hello.py'),\n joinPathFragments(dir, 'tests', 'test_hello.py'),\n ].forEach((f) => tree.delete(f));\n\n // User-owned source files: preserve any existing copies so re-running does\n // not clobber user edits (and does not reformat them nondeterministically).\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, 'files', 'app'), // path to the file templates\n dir, // destination path of the files\n {\n name: normalizedModuleName,\n apiNameClassName,\n infra: schema.infra,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (schema.infra !== 'none') {\n const iac = await resolveIac(tree, schema.iac);\n\n await sharedConstructsGenerator(tree, {\n iac,\n });\n\n if (schema.auth === 'custom') {\n const authorizerType = schema.infra === 'http-lambda' ? 'http' : 'rest';\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '..',\n '..',\n 'utils',\n 'api-constructs',\n 'files',\n 'py-authorizer',\n authorizerType,\n ),\n joinPathFragments(dir, normalizedModuleName),\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n\n // Add the CDK construct to deploy the FastAPI to shared constructs\n await addApiGatewayInfra(tree, {\n apiProjectName: projectConfig.name,\n apiNameClassName,\n apiNameKebabCase,\n constructType: schema.infra === 'http-lambda' ? 'http' : 'rest',\n backend: {\n type: 'fastapi',\n moduleName: normalizedModuleName,\n bundleOutputDir,\n integrationPattern,\n },\n auth: schema.auth,\n iac,\n });\n\n addSharedConstructsOpenApiMetadataGenerateTarget(tree, {\n iac,\n apiNameKebabCase,\n specPath,\n specBuildTargetName: `${projectConfig.name}:openapi`,\n });\n }\n\n addDependenciesToPyProjectToml(tree, dir, [\n 'fastapi',\n 'uvicorn',\n 'aws-lambda-powertools',\n 'aws-lambda-powertools[tracer]',\n ...(schema.auth === 'custom'\n ? (['aws-lambda-powertools[parser]'] as const)\n : []),\n ]);\n addDependenciesToDependencyGroupInPyProjectToml(tree, dir, 'dev', [\n 'fastapi[standard]',\n ]);\n\n addGeneratorMetadata(tree, fullyQualifiedName, FAST_API_GENERATOR_INFO);\n\n await addGeneratorMetricsIfApplicable(tree, [FAST_API_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nconst getIntegrationPattern = (\n schema: PyFastApiProjectGeneratorSchema,\n): 'isolated' | 'shared' => schema.integrationPattern ?? 'isolated';\n\nexport default pyFastApiProjectGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateProjectConfiguration","addApiGatewayInfra","addSharedConstructsOpenApiMetadataGenerateTarget","addPythonBundleTarget","formatFilesInSubtree","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","addGeneratorMetadata","getGeneratorInfo","sortObjectKeys","assignPort","addDependenciesToDependencyGroupInPyProjectToml","addDependenciesToPyProjectToml","sharedConstructsGenerator","pyProjectGenerator","getPyProjectDetails","addOpenApiGeneration","FAST_API_GENERATOR_INFO","filename","pyFastApiProjectGenerator","tree","schema","integrationPattern","getIntegrationPattern","dir","normalizedModuleName","fullyQualifiedName","name","directory","subDirectory","moduleName","apiNameKebabCase","apiNameClassName","projectExists","type","preferInstallDependencies","projectConfig","port","bundleOutputDir","bundleTargetName","fs","bundleTarget","targets","copyRunShCommand","cp","options","commands","includes","serve","executor","continuous","command","cwd","env","LOCAL_DEV","metadata","apiName","apiType","auth","specPath","project","forEach","f","delete","dirname","infra","overwriteStrategy","KeepExisting","iac","authorizerType","apiProjectName","constructType","backend","specBuildTargetName","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,wBAAwB,EAExBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,kBAAkB,QAAQ,+CAA4C;AAC/E,SAASC,gDAAgD,QAAQ,kDAA+C;AAChH,SAASC,qBAAqB,QAAQ,+BAA4B;AAClE,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,WAAW,EAAEC,WAAW,QAAQ,uBAAoB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MC,OAAOc,yBAAyB,EAAE;YAC1DuC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,MAAMnD,wBAAwB,CAC5BF,SAC0BA,OAAOC,kBAAkB,IAAI;AAEzD,eAAeH,0BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/fast-api/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 ProjectConfiguration,\n readProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addPyDependencies } from '../../utils/add-dependencies';\nimport {\n API_CONSTRUCTS_DEPENDENCIES,\n addApiGatewayInfra,\n} from '../../utils/api-constructs/api-constructs';\nimport { addSharedConstructsOpenApiMetadataGenerateTarget } from '../../utils/api-constructs/open-api-metadata';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\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 { toClassName, toKebabCase } from '../../utils/names';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\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 pyProjectGenerator, { getPyProjectDetails } from '../project/generator';\nimport { addOpenApiGeneration } from './react/open-api';\nimport type { PyFastApiProjectGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface PyFastApiMetadata extends IacMetadata {\n readonly apiName: string;\n readonly apiType: string;\n readonly auth: PyFastApiProjectGeneratorSchema['auth'];\n}\n\nexport const DEPENDENCIES = declareDependencies<PyFastApiMetadata>()({\n ts: [\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(API_CONSTRUCTS_DEPENDENCIES),\n ],\n py: [\n { name: 'fastapi' },\n { name: 'uvicorn' },\n { name: 'aws-lambda-powertools' },\n { name: 'aws-lambda-powertools[tracer]' },\n // The custom authorizer handler parses its event with the parser extra.\n {\n name: 'aws-lambda-powertools[parser]',\n when: (m) => m.auth === 'custom',\n },\n // `fastapi dev` runs the local server.\n { name: 'fastapi[standard]', group: 'dev' },\n ],\n});\n\nexport const FAST_API_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Generates a Python FastAPI project\n */\nexport const pyFastApiProjectGenerator = async (\n tree: Tree,\n schema: PyFastApiProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const integrationPattern = getIntegrationPattern(schema);\n\n const { dir, normalizedModuleName, fullyQualifiedName } = getPyProjectDetails(\n tree,\n {\n name: schema.name,\n directory: schema.directory,\n subDirectory: schema.subDirectory,\n moduleName: schema.moduleName,\n },\n );\n const apiNameKebabCase = toKebabCase(schema.name);\n const apiNameClassName = toClassName(schema.name);\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await pyProjectGenerator(tree, {\n name: schema.name,\n directory: schema.directory,\n subDirectory: schema.subDirectory,\n moduleName: normalizedModuleName,\n type: 'application',\n preferInstallDependencies: false,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const port = assignPort(tree, projectConfig, 8000);\n\n const { bundleOutputDir, bundleTargetName } =\n addPythonBundleTarget(projectConfig);\n\n // Add a command to copy run.sh to the bundle output for Lambda Web Adapter\n const fs = new FsCommands(tree, DEPENDENCIES);\n const bundleTarget = projectConfig.targets[bundleTargetName];\n const copyRunShCommand = fs.cp(\n `{projectRoot}/run.sh`,\n `dist/{projectRoot}/${bundleTargetName}/run.sh`,\n );\n if (!bundleTarget.options.commands.includes(copyRunShCommand)) {\n bundleTarget.options.commands = [\n ...bundleTarget.options.commands,\n copyRunShCommand,\n ];\n }\n\n projectConfig.targets.serve = {\n executor: '@nxlv/python:run-commands',\n continuous: true,\n options: {\n command: `uv run fastapi dev ${normalizedModuleName}/main.py --port ${port}`,\n cwd: '{projectRoot}',\n },\n };\n\n projectConfig.targets['dev'] = {\n ...projectConfig.targets['dev'],\n ...projectConfig.targets.serve,\n options: {\n ...projectConfig.targets.serve.options,\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n\n // Recorded in the metadata below so the version sync can tell a CDK\n // project from a Terraform one; undefined when no infrastructure was\n // generated, in which case neither provider's packages were added.\n const iac =\n schema.infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;\n\n // Recorded below and read by the declaration's predicates, so the packages\n // added here are exactly the ones the version sync will own.\n const metadata: PyFastApiMetadata = {\n apiName: schema.name,\n apiType: 'fast-api',\n auth: schema.auth,\n ...(iac ? { iac } : {}),\n };\n\n projectConfig.metadata = {\n ...projectConfig.metadata,\n ...metadata,\n } as any;\n\n projectConfig.targets = sortObjectKeys(projectConfig.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n\n // Add OpenAPI spec generation to the project, run as part of build\n const { specPath } = addOpenApiGeneration(tree, { project: projectConfig });\n\n [\n joinPathFragments(dir, normalizedModuleName, 'hello.py'),\n joinPathFragments(dir, 'tests', 'test_hello.py'),\n ].forEach((f) => tree.delete(f));\n\n // User-owned source files: preserve any existing copies so re-running does\n // not clobber user edits (and does not reformat them nondeterministically).\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, 'files', 'app'), // path to the file templates\n dir, // destination path of the files\n {\n name: normalizedModuleName,\n apiNameClassName,\n infra: schema.infra,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (schema.infra !== 'none') {\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n if (schema.auth === 'custom') {\n const authorizerType = schema.infra === 'http-lambda' ? 'http' : 'rest';\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '..',\n '..',\n 'utils',\n 'api-constructs',\n 'files',\n 'py-authorizer',\n authorizerType,\n ),\n joinPathFragments(dir, normalizedModuleName),\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n\n // Add the CDK construct to deploy the FastAPI to shared constructs\n await addApiGatewayInfra(\n tree,\n {\n apiProjectName: projectConfig.name,\n apiNameClassName,\n apiNameKebabCase,\n constructType: schema.infra === 'http-lambda' ? 'http' : 'rest',\n backend: {\n type: 'fastapi',\n moduleName: normalizedModuleName,\n bundleOutputDir,\n integrationPattern,\n },\n auth: schema.auth,\n iac,\n },\n DEPENDENCIES,\n );\n\n addSharedConstructsOpenApiMetadataGenerateTarget(tree, {\n iac,\n apiNameKebabCase,\n specPath,\n specBuildTargetName: `${projectConfig.name}:openapi`,\n });\n }\n\n addPyDependencies(tree, DEPENDENCIES, { metadata, projectRoot: dir });\n\n addGeneratorMetadata(tree, fullyQualifiedName, FAST_API_GENERATOR_INFO);\n\n await addGeneratorMetricsIfApplicable(tree, [FAST_API_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nconst getIntegrationPattern = (\n schema: PyFastApiProjectGeneratorSchema,\n): 'isolated' | 'shared' => schema.integrationPattern ?? 'isolated';\n\nexport default pyFastApiProjectGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateProjectConfiguration","addPyDependencies","API_CONSTRUCTS_DEPENDENCIES","addApiGatewayInfra","addSharedConstructsOpenApiMetadataGenerateTarget","addPythonBundleTarget","declareDependencies","ownedElsewhere","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","addGeneratorMetadata","getGeneratorInfo","sortObjectKeys","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","pyProjectGenerator","getPyProjectDetails","addOpenApiGeneration","DEPENDENCIES","ts","py","name","when","m","auth","group","FAST_API_GENERATOR_INFO","filename","pyFastApiProjectGenerator","tree","schema","integrationPattern","getIntegrationPattern","dir","normalizedModuleName","fullyQualifiedName","directory","subDirectory","moduleName","apiNameKebabCase","apiNameClassName","projectExists","type","preferInstallDependencies","projectConfig","port","bundleOutputDir","bundleTargetName","fs","bundleTarget","targets","copyRunShCommand","cp","options","commands","includes","serve","executor","continuous","command","cwd","env","LOCAL_DEV","iac","infra","undefined","metadata","apiName","apiType","specPath","project","forEach","f","delete","dirname","overwriteStrategy","KeepExisting","authorizerType","apiProjectName","constructType","backend","specBuildTargetName","projectRoot","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,wBAAwB,EAExBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAA+B;AACjE,SACEC,2BAA2B,EAC3BC,kBAAkB,QACb,+CAA4C;AACnD,SAASC,gDAAgD,QAAQ,kDAA+C;AAChH,SAASC,qBAAqB,QAAQ,+BAA4B;AAClE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+B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ACA;YACEiD,gBAAgBlC,cAAcvB,IAAI;YAClCmB;YACAD;YACAwC,eAAejD,OAAOkC,KAAK,KAAK,gBAAgB,SAAS;YACzDgB,SAAS;gBACPtC,MAAM;gBACNJ,YAAYJ;gBACZY;gBACAf;YACF;YACAP,MAAMM,OAAON,IAAI;YACjBuC;QACF,GACA7C;QAGFrB,iDAAiDgC,MAAM;YACrDkC;YACAxB;YACA8B;YACAY,qBAAqB,GAAGrC,cAAcvB,IAAI,CAAC,QAAQ,CAAC;QACtD;IACF;IAEA3B,kBAAkBmC,MAAMX,cAAc;QAAEgD;QAAUgB,aAAajD;IAAI;IAEnExB,qBAAqBoB,MAAMM,oBAAoBT;IAE/C,MAAMpB,gCAAgCuB,MAAM;QAACH;KAAwB;IAErE,MAAMzB,qBAAqB4B;IAE3B,OAAO,IACLxB,oBAAoBwB,MAAMC,OAAOa,yBAAyB,EAAE;YAC1DwC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,MAAMnD,wBAAwB,CAC5BF,SAC0BA,OAAOC,kBAAkB,IAAI;AAEzD,eAAeH,0BAA0B"}
|
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import type
|
|
5
|
+
import { type Tree } from '@nx/devkit';
|
|
6
6
|
import { type NxGeneratorInfo } from '../../../utils/nx';
|
|
7
7
|
import type { FastApiReactGeneratorSchema } from './schema';
|
|
8
|
+
export declare const DEPENDENCIES: import("../../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
9
|
+
readonly name: "oidc-client-ts";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "react-oidc-context";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "@aws-sdk/credential-provider-cognito-identity";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "aws4fetch";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "@tanstack/react-query";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "@tanstack/react-query-devtools";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "@smithy/types";
|
|
22
|
+
}], readonly import("../../../utils/declared-dependencies").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "mcp" | "pip-check-updates" | "pip-licenses" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
8
23
|
export declare const FAST_API_REACT_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
24
|
export declare const fastApiReactGenerator: (tree: Tree, options: FastApiReactGeneratorSchema) => Promise<() => Promise<void>>;
|
|
10
25
|
export default fastApiReactGenerator;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import {
|
|
4
|
+
*/ import { joinPathFragments } from "@nx/devkit";
|
|
5
|
+
import { addOpenApiReactClient, OPEN_API_REACT_DEPENDENCIES } from "../../../utils/connection/open-api/react.js";
|
|
6
|
+
import { declareDependencies } from "../../../utils/declared-dependencies.js";
|
|
5
7
|
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
6
8
|
import { installDependencies } from "../../../utils/install.js";
|
|
7
9
|
import { addGeneratorMetricsIfApplicable } from "../../../utils/metrics.js";
|
|
8
|
-
import {
|
|
10
|
+
import { toClassName } from "../../../utils/names.js";
|
|
11
|
+
import { addComponentGeneratorMetadata, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
12
|
+
import { toProjectRelativePath } from "../../../utils/paths.js";
|
|
9
13
|
import { addOpenApiGeneration } from "./open-api.js";
|
|
14
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
15
|
+
ts: [
|
|
16
|
+
...OPEN_API_REACT_DEPENDENCIES
|
|
17
|
+
]
|
|
18
|
+
});
|
|
10
19
|
export const FAST_API_REACT_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
11
20
|
export const fastApiReactGenerator = async (tree, options)=>{
|
|
12
21
|
const frontendProjectConfig = readProjectConfigurationUnqualified(tree, options.frontendProjectName);
|
|
@@ -28,7 +37,10 @@ export const fastApiReactGenerator = async (tree, options)=>{
|
|
|
28
37
|
specBuildTargetName: `${fastApiProjectConfig.name}:openapi`,
|
|
29
38
|
auth,
|
|
30
39
|
port
|
|
31
|
-
});
|
|
40
|
+
}, DEPENDENCIES);
|
|
41
|
+
const apiNameClassName = toClassName(apiName);
|
|
42
|
+
// Recorded so the version sync knows this connection's dependencies are ours.
|
|
43
|
+
addComponentGeneratorMetadata(tree, frontendProjectConfig.name, FAST_API_REACT_GENERATOR_INFO, toProjectRelativePath(frontendProjectConfig, joinPathFragments(frontendProjectConfig.sourceRoot, 'components', `${apiNameClassName}Provider`)), apiNameClassName);
|
|
32
44
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
33
45
|
FAST_API_REACT_GENERATOR_INFO
|
|
34
46
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/fast-api/react/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/fast-api/react/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport {\n addOpenApiReactClient,\n OPEN_API_REACT_DEPENDENCIES,\n} from '../../../utils/connection/open-api/react';\nimport { declareDependencies } from '../../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { toClassName } from '../../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { toProjectRelativePath } from '../../../utils/paths';\nimport { addOpenApiGeneration } from './open-api';\nimport type { FastApiReactGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...OPEN_API_REACT_DEPENDENCIES],\n});\n\nexport const FAST_API_REACT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const fastApiReactGenerator = async (\n tree: Tree,\n options: FastApiReactGeneratorSchema,\n) => {\n const frontendProjectConfig = readProjectConfigurationUnqualified(\n tree,\n options.frontendProjectName,\n );\n const fastApiProjectConfig = readProjectConfigurationUnqualified(\n tree,\n options.fastApiProjectName,\n );\n\n // Add OpenAPI spec generation to the project, run as part of build\n const { specPath } = addOpenApiGeneration(tree, {\n project: fastApiProjectConfig,\n });\n\n const metadata = fastApiProjectConfig.metadata as any;\n const apiName = metadata?.apiName;\n const auth = (metadata?.auth ?? 'iam').toLowerCase();\n const port = metadata?.port ?? metadata?.ports?.[0] ?? 8000;\n\n await addOpenApiReactClient(\n tree,\n {\n apiName,\n frontendProjectConfig,\n backendProjectConfig: fastApiProjectConfig,\n specBuildProject: fastApiProjectConfig,\n specPath,\n specBuildTargetName: `${fastApiProjectConfig.name}:openapi`,\n auth,\n port,\n },\n DEPENDENCIES,\n );\n\n const apiNameClassName = toClassName(apiName);\n\n // Recorded so the version sync knows this connection's dependencies are ours.\n addComponentGeneratorMetadata(\n tree,\n frontendProjectConfig.name,\n FAST_API_REACT_GENERATOR_INFO,\n toProjectRelativePath(\n frontendProjectConfig,\n joinPathFragments(\n frontendProjectConfig.sourceRoot,\n 'components',\n `${apiNameClassName}Provider`,\n ),\n ),\n apiNameClassName,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [FAST_API_REACT_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default fastApiReactGenerator;\n"],"names":["joinPathFragments","addOpenApiReactClient","OPEN_API_REACT_DEPENDENCIES","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toClassName","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","addOpenApiGeneration","DEPENDENCIES","ts","FAST_API_REACT_GENERATOR_INFO","filename","fastApiReactGenerator","tree","options","frontendProjectConfig","frontendProjectName","fastApiProjectConfig","fastApiProjectName","specPath","project","metadata","apiName","auth","toLowerCase","port","ports","backendProjectConfig","specBuildProject","specBuildTargetName","name","apiNameClassName","sourceRoot","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,iBAAiB,QAAmB,aAAa;AAC1D,SACEC,qBAAqB,EACrBC,2BAA2B,QACtB,8CAA2C;AAClD,SAASC,mBAAmB,QAAQ,0CAAuC;AAC3E,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SAASC,WAAW,QAAQ,0BAAuB;AACnD,SACEC,6BAA6B,EAC7BC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SAASC,qBAAqB,QAAQ,0BAAuB;AAC7D,SAASC,oBAAoB,QAAQ,gBAAa;AAGlD,OA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utils/nx';
|
|
7
7
|
import type { PyLambdaFunctionGeneratorSchema } from './schema';
|
|
8
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
9
|
+
readonly name: "constructs";
|
|
10
|
+
readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
|
|
11
|
+
} & {
|
|
12
|
+
versionOnly: true;
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "aws-cdk-lib";
|
|
15
|
+
readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
|
|
16
|
+
} & {
|
|
17
|
+
versionOnly: true;
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "@types/node";
|
|
20
|
+
} & {
|
|
21
|
+
versionOnly: true;
|
|
22
|
+
}], readonly [{
|
|
23
|
+
readonly name: "aws-lambda-powertools";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "aws-lambda-powertools[tracer]";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "aws-lambda-powertools[parser]";
|
|
28
|
+
}]>;
|
|
8
29
|
export declare const LAMBDA_FUNCTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
30
|
export interface LambdaFunctionDetails {
|
|
10
31
|
/**
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
+
import { addPyDependencies } from "../../utils/add-dependencies.js";
|
|
5
6
|
import { addPythonBundleTarget } from "../../utils/bundle/bundle.js";
|
|
7
|
+
import { declareDependencies, ownedElsewhere } from "../../utils/declared-dependencies.js";
|
|
6
8
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
7
9
|
import { addLambdaFunctionInfra } from "../../utils/function-constructs/function-constructs.js";
|
|
8
10
|
import { resolveIac } from "../../utils/iac.js";
|
|
@@ -13,8 +15,23 @@ import { getNpmScope } from "../../utils/npm-scope.js";
|
|
|
13
15
|
import { addComponentGeneratorMetadata, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
14
16
|
import { sortObjectKeys } from "../../utils/object.js";
|
|
15
17
|
import { toProjectRelativePath } from "../../utils/paths.js";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
+
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
19
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
20
|
+
ts: [
|
|
21
|
+
...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES)
|
|
22
|
+
],
|
|
23
|
+
py: [
|
|
24
|
+
{
|
|
25
|
+
name: 'aws-lambda-powertools'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'aws-lambda-powertools[tracer]'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'aws-lambda-powertools[parser]'
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
});
|
|
18
35
|
export const LAMBDA_FUNCTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
19
36
|
const getLambdaFunctionDetails = (tree, schema)=>{
|
|
20
37
|
const scope = toSnakeCase(getNpmScope(tree));
|
|
@@ -63,11 +80,13 @@ const getLambdaFunctionDetails = (tree, schema)=>{
|
|
|
63
80
|
}
|
|
64
81
|
// Check if the project has a bundle target and if not add it
|
|
65
82
|
const { bundleOutputDir } = addPythonBundleTarget(projectConfig);
|
|
83
|
+
// Recorded below so the version sync can tell a CDK project from a
|
|
84
|
+
// Terraform one; undefined when no infrastructure was generated.
|
|
85
|
+
const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;
|
|
66
86
|
if (infra !== 'none') {
|
|
67
|
-
const iac = await resolveIac(tree, schema.iac);
|
|
68
87
|
await sharedConstructsGenerator(tree, {
|
|
69
88
|
iac
|
|
70
|
-
});
|
|
89
|
+
}, DEPENDENCIES);
|
|
71
90
|
await addLambdaFunctionInfra(tree, {
|
|
72
91
|
functionProjectName: projectConfig.name,
|
|
73
92
|
nameClassName: constructFunctionClassName,
|
|
@@ -94,12 +113,12 @@ const getLambdaFunctionDetails = (tree, schema)=>{
|
|
|
94
113
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'tests'), joinPathFragments(dir, 'tests'), enhancedOptions, {
|
|
95
114
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
96
115
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
116
|
+
addPyDependencies(tree, DEPENDENCIES, {
|
|
117
|
+
projectRoot: dir
|
|
118
|
+
});
|
|
119
|
+
addComponentGeneratorMetadata(tree, projectConfig.name, LAMBDA_FUNCTION_GENERATOR_INFO, toProjectRelativePath(projectConfig, functionPath), lambdaFunctionKebabCase, iac ? {
|
|
120
|
+
iac
|
|
121
|
+
} : {});
|
|
103
122
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
104
123
|
LAMBDA_FUNCTION_GENERATOR_INFO
|
|
105
124
|
]);
|