@aws/nx-plugin 1.0.0-rc.50 → 1.0.0-rc.52
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 +7 -0
- package/migrations.json +5 -0
- package/package.json +1 -1
- package/src/internal/test-matrix/generator.d.ts +29 -0
- package/src/internal/test-matrix/generator.js +660 -0
- package/src/internal/test-matrix/generator.js.map +1 -0
- package/src/internal/test-matrix/schema.d.js +6 -0
- package/src/internal/test-matrix/schema.d.js.map +1 -0
- package/src/internal/test-matrix/schema.d.ts +12 -0
- package/src/internal/test-matrix/schema.json +21 -0
- package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.d.ts +6 -0
- package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js +217 -0
- package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js.map +1 -0
- package/src/sdk/py.d.ts +2 -0
- package/src/sdk/py.js +1 -0
- package/src/sdk/py.js.map +1 -1
- package/src/sdk/ts.d.ts +2 -0
- package/src/sdk/ts.js +2 -0
- package/src/sdk/ts.js.map +1 -1
- package/src/sdk/utils/format.d.ts +1 -1
- package/src/sdk/utils/format.js.map +1 -1
- package/src/ts/rdb/generator.js +19 -1
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +66 -66
- package/src/ts/react-website/app/generator.js +10 -1
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +25 -3
- package/src/utils/format.d.ts +11 -1
- package/src/utils/format.js +25 -2
- package/src/utils/format.js.map +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +25 -3
- package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +25 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/internal/test-matrix/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { GeneratorCallback, Tree } from '@nx/devkit';\nimport { agentcoreGatewayGenerator } from '../../sdk/agentcore-gateway';\nimport {\n type ConnectionGeneratorSchema,\n connectionGenerator,\n} from '../../sdk/connection';\nimport { licenseGenerator } from '../../sdk/license';\nimport {\n type PyAgentGeneratorSchema,\n type PyApiGeneratorSchema,\n type PyRdbGeneratorSchema,\n pyAgentGenerator,\n pyApiGenerator,\n pyDynamoDBGenerator,\n pyLambdaFunctionGenerator,\n pyMcpServerGenerator,\n pyProjectGenerator,\n pyRdbGenerator,\n} from '../../sdk/py';\nimport { terraformProjectGenerator } from '../../sdk/terraform';\nimport {\n type TsAgentGeneratorSchema,\n type TsApiGeneratorSchema,\n type TsNxMigrationGeneratorSchema,\n type TsRdbGeneratorSchema,\n tsAgentGenerator,\n tsApiGenerator,\n tsAstroDocsGenerator,\n tsDcrProxyGenerator,\n tsDynamoDBGenerator,\n tsInfraGenerator,\n tsLambdaFunctionGenerator,\n tsMcpServerGenerator,\n tsNxGeneratorGenerator,\n tsNxMigrationGenerator,\n tsNxPluginGenerator,\n tsProjectGenerator,\n tsRdbGenerator,\n tsWebsiteAuthGenerator,\n tsWebsiteGenerator,\n} from '../../sdk/ts';\nimport { installDependencies } from '../../utils/install';\nimport { toSnakeCase } from '../../utils/names';\nimport { getNpmScope, getNpmScopePrefix } from '../../utils/npm-scope';\nimport type { InternalTestMatrixGeneratorSchema } from './schema';\n\n/**\n * Scaffolds every generator, component and connection permutation the e2e tests\n * cover, by composing the generators in-process on a single tree.\n *\n * This ships with the plugin so each released version carries the matrix of the\n * generators *it* had. A test upgrading an old workspace scaffolds with the\n * released version's own matrix and never has to reason about which generators\n * existed when — driving the CLI from the test repo instead would couple the\n * test to a generator list that only describes today's plugin.\n *\n * Hidden and undocumented: it exists for the e2e suite, not for users.\n *\n * Options are typed against each generator's schema, so adding a required option\n * or changing an enum breaks the build here rather than silently reducing\n * coverage.\n *\n * Projects are generated with `preferInstallDependencies: false` by default and\n * the returned callback installs once. Nothing composed here reads the project\n * graph (only `ts#sync` does, which is not part of the matrix), so no\n * intermediate install is needed.\n */\nexport const internalTestMatrixGenerator = async (\n tree: Tree,\n options: InternalTestMatrixGeneratorSchema = {},\n): Promise<GeneratorCallback> => {\n const preferInstallDependencies = options.preferInstallDependencies ?? false;\n const defaults = { preferInstallDependencies };\n const projectDefaults = { ...defaults, directory: 'packages' };\n // Fully-qualified project names, which differ per language: TypeScript\n // projects are scope-prefixed, Python ones are dotted snake_case. Derived from\n // the workspace rather than hardcoded, so the matrix works in any workspace.\n const ts = (name: string) => `${getNpmScopePrefix(tree)}${name}`;\n const py = (name: string) =>\n `${toSnakeCase(getNpmScope(tree))}.${toSnakeCase(name)}`;\n\n // The infrastructure project every other generator deploys into. Which\n // generator owns it depends on the workspace's IaC provider, so the caller\n // asks for the one matching the workspace it created.\n if (options.infra === 'terraform') {\n await terraformProjectGenerator(tree, {\n name: 'infra',\n type: 'application',\n ...projectDefaults,\n });\n } else {\n await tsInfraGenerator(tree, { name: 'infra', ...projectDefaults });\n // A second CDK app with stage config, which only ts#infra offers.\n await tsInfraGenerator(tree, {\n name: 'infra-with-stages',\n stageConfig: true,\n ...projectDefaults,\n });\n }\n\n // Websites (with and without TanStack Router), a docs site, and auth on each.\n await tsWebsiteGenerator(tree, {\n name: 'website',\n iac: 'inherit',\n ...projectDefaults,\n });\n await tsWebsiteGenerator(tree, {\n name: 'website-no-router',\n tanstackRouter: false,\n iac: 'inherit',\n ...projectDefaults,\n });\n await tsAstroDocsGenerator(tree, { name: 'docs-site', ...defaults });\n await tsWebsiteAuthGenerator(tree, {\n project: ts('website'),\n cognitoDomain: 'test',\n allowSignup: true,\n iac: 'inherit',\n ...defaults,\n });\n await tsWebsiteAuthGenerator(tree, {\n project: ts('website-no-router'),\n cognitoDomain: 'test-no-router',\n allowSignup: true,\n iac: 'inherit',\n ...defaults,\n });\n\n // tRPC APIs — REST + HTTP, with Cognito and custom auth.\n const tsApis: TsApiGeneratorSchema[] = [\n { name: 'my-api', infra: 'rest-lambda', auth: 'iam', iac: 'inherit' },\n { name: 'my-api-http', infra: 'http-lambda', auth: 'iam', iac: 'inherit' },\n {\n name: 'my-api-custom',\n infra: 'rest-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'my-api-custom-http',\n infra: 'http-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'my-smithy-api',\n framework: 'smithy',\n infra: 'rest-lambda',\n auth: 'iam',\n iac: 'inherit',\n },\n ];\n for (const api of tsApis) {\n await tsApiGenerator(tree, { ...api, ...projectDefaults });\n }\n\n // Python FastAPI — REST + HTTP, with Cognito and custom auth.\n const pyApis: PyApiGeneratorSchema[] = [\n { name: 'py-api', infra: 'rest-lambda', auth: 'iam', iac: 'inherit' },\n { name: 'py-api-http', infra: 'http-lambda', auth: 'iam', iac: 'inherit' },\n {\n name: 'py-api-custom',\n infra: 'rest-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'py-api-custom-http',\n infra: 'http-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n ];\n for (const api of pyApis) {\n await pyApiGenerator(tree, { ...api, ...projectDefaults });\n }\n\n // Library projects hosting the components below, each with a lambda function.\n await pyProjectGenerator(tree, {\n name: 'py-project',\n type: 'application',\n ...projectDefaults,\n });\n await tsProjectGenerator(tree, { name: 'ts-project', ...projectDefaults });\n await pyLambdaFunctionGenerator(tree, {\n project: py('py-project'),\n name: 'my-function',\n event: 'Any',\n iac: 'inherit',\n ...defaults,\n });\n await tsLambdaFunctionGenerator(tree, {\n project: 'ts-project',\n name: 'my-function',\n event: 'Any',\n iac: 'inherit',\n ...defaults,\n });\n\n // MCP servers — uninfra'd and hosted on AgentCore.\n await pyMcpServerGenerator(tree, {\n project: 'py_project',\n name: 'my-mcp-server',\n infra: 'agentcore',\n iac: 'inherit',\n ...defaults,\n });\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'my-mcp-server',\n infra: 'none',\n iac: 'inherit',\n ...defaults,\n });\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'hosted-mcp-server',\n infra: 'agentcore',\n iac: 'inherit',\n ...defaults,\n });\n\n // OAuth DCR proxy for Cognito-authenticated MCP servers.\n await tsDcrProxyGenerator(tree, {\n name: 'my-dcr-proxy',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // TypeScript agents across every protocol and auth permutation. The unnamed\n // one takes the generator's default name, which the connections below use.\n const tsAgents: TsAgentGeneratorSchema[] = [\n {\n project: 'ts-project',\n name: 'my-ts-agent',\n infra: 'none',\n iac: 'inherit',\n },\n { project: 'ts-project', infra: 'agentcore', iac: 'inherit' },\n {\n project: 'ts-project',\n name: 'my-ts-a2a-agent',\n protocol: 'a2a',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-a2a-agent-cognito',\n protocol: 'a2a',\n auth: 'cognito',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-agui-agent',\n protocol: 'ag-ui',\n infra: 'agentcore',\n iac: 'inherit',\n },\n ];\n for (const agent of tsAgents) {\n await tsAgentGenerator(tree, { ...agent, ...defaults });\n }\n\n // Python agents: Strands across every protocol, plus LangChain in its own\n // project — langchain's dependency closure would push the zip-bundled Lambda\n // in py-project past its unzipped size limit.\n const pyAgents: PyAgentGeneratorSchema[] = [\n {\n project: 'py_project',\n name: 'my-agent',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-a2a-agent',\n protocol: 'a2a',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-a2a-agent-cognito',\n protocol: 'a2a',\n auth: 'cognito',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-agui-agent',\n protocol: 'ag-ui',\n infra: 'agentcore',\n iac: 'inherit',\n },\n ];\n for (const agent of pyAgents) {\n await pyAgentGenerator(tree, { ...agent, ...defaults });\n }\n await pyProjectGenerator(tree, {\n name: 'py-langchain-project',\n type: 'application',\n ...projectDefaults,\n });\n const langchainAgents: PyAgentGeneratorSchema[] = [\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-agent',\n protocol: 'ag-ui',\n iac: 'inherit',\n },\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-http-agent',\n protocol: 'http',\n iac: 'inherit',\n },\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-a2a-agent',\n protocol: 'a2a',\n iac: 'inherit',\n },\n ];\n for (const agent of langchainAgents) {\n await pyAgentGenerator(tree, {\n ...agent,\n framework: 'langchain',\n infra: 'agentcore',\n ...defaults,\n });\n }\n\n // AgentCore gateways, including a parent fronting the first (chained).\n await agentcoreGatewayGenerator(tree, {\n name: 'my-gateway',\n iac: 'inherit',\n ...projectDefaults,\n });\n await agentcoreGatewayGenerator(tree, {\n name: 'parent-gateway',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // Databases — DynamoDB, plus Aurora across both engines and ORMs.\n await tsDynamoDBGenerator(tree, {\n name: 'my-table',\n framework: 'electrodb',\n infra: 'dynamodb',\n iac: 'inherit',\n ...projectDefaults,\n });\n await pyDynamoDBGenerator(tree, {\n name: 'my-py-table',\n framework: 'pynamodb',\n infra: 'dynamodb',\n iac: 'inherit',\n ...projectDefaults,\n });\n const tsRdbs: TsRdbGeneratorSchema[] = [\n {\n name: 'postgres-db',\n infra: 'aurora',\n engine: 'postgres',\n framework: 'prisma',\n iac: 'inherit',\n },\n {\n name: 'my-sql-db',\n infra: 'aurora',\n engine: 'mysql',\n framework: 'prisma',\n iac: 'inherit',\n },\n ];\n for (const rdb of tsRdbs) {\n await tsRdbGenerator(tree, { ...rdb, ...projectDefaults });\n }\n const pyRdbs: PyRdbGeneratorSchema[] = [\n {\n name: 'py-postgres-db',\n infra: 'aurora',\n engine: 'postgres',\n framework: 'sqlmodel',\n iac: 'inherit',\n },\n {\n name: 'py-mysql-db',\n infra: 'aurora',\n engine: 'mysql',\n framework: 'sqlmodel',\n iac: 'inherit',\n },\n ];\n for (const rdb of pyRdbs) {\n await pyRdbGenerator(tree, { ...rdb, ...projectDefaults });\n }\n\n // Every connection edge the matrix covers.\n const connections: ConnectionGeneratorSchema[] = [\n // Website -> API\n { sourceProject: ts('website'), targetProject: ts('my-api') },\n { sourceProject: ts('website-no-router'), targetProject: ts('my-api') },\n { sourceProject: 'website', targetProject: 'py_api' },\n { sourceProject: 'website', targetProject: 'my-smithy-api' },\n // Agent -> MCP server\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-ts-agui-agent',\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n // HTTP agent <-> A2A agent\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n // Agent -> gateway, gateway -> MCP server, gateway -> gateway\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: ts('my-gateway'),\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: ts('my-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n { sourceProject: ts('parent-gateway'), targetProject: ts('my-gateway') },\n // Website -> agent\n {\n sourceProject: ts('website'),\n targetProject: 'ts-project',\n targetComponent: 'agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'ts-project',\n targetComponent: 'my-ts-agui-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_project',\n targetComponent: 'my-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_project',\n targetComponent: 'my-py-agui-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_langchain_project',\n targetComponent: 'my-py-langchain-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_langchain_project',\n targetComponent: 'my-py-langchain-http-agent',\n },\n // DynamoDB\n { sourceProject: 'my-api', targetProject: ts('my-table') },\n { sourceProject: 'my-smithy-api', targetProject: ts('my-table') },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-ts-agent',\n targetProject: ts('my-table'),\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-mcp-server',\n targetProject: ts('my-table'),\n },\n { sourceProject: 'py_api', targetProject: 'my_py_table' },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'my_py_table',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-mcp-server',\n targetProject: 'my_py_table',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-http-agent',\n targetProject: 'my_py_table',\n },\n // Relational databases\n { sourceProject: 'py_api', targetProject: 'py_postgres_db' },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_postgres_db',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-mcp-server',\n targetProject: 'py_postgres_db',\n },\n ];\n for (const connection of connections) {\n await connectionGenerator(tree, { ...connection, ...defaults });\n }\n\n // Licensing, then an Nx plugin with a custom generator.\n await licenseGenerator(tree, {\n license: 'Apache-2.0',\n copyrightHolder: 'Amazon.com, Inc. or its affiliates',\n ...defaults,\n });\n await tsNxPluginGenerator(tree, {\n ...projectDefaults,\n name: 'plugin',\n directory: 'tools',\n });\n await tsNxGeneratorGenerator(tree, {\n project: ts('plugin'),\n name: 'my#generator',\n ...defaults,\n });\n\n // A migration of each kind, so the scaffolded codemods compile and the\n // plugin's migrations.json (created by the first run) registers all three.\n const migrations: Omit<TsNxMigrationGeneratorSchema, 'project'>[] = [\n {\n name: 'rename-foo-target',\n description: 'Rename the foo target to bar',\n },\n {\n name: 'migrate-custom-handlers',\n description: 'Update custom handlers for the new API',\n kind: 'agentic',\n },\n {\n name: 'upgrade-framework',\n description: 'Upgrade the framework and reconcile call sites',\n kind: 'hybrid',\n },\n ];\n for (const migration of migrations) {\n await tsNxMigrationGenerator(tree, {\n ...migration,\n project: ts('plugin'),\n ...defaults,\n });\n }\n\n return () =>\n installDependencies(tree, preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default internalTestMatrixGenerator;\n"],"names":["agentcoreGatewayGenerator","connectionGenerator","licenseGenerator","pyAgentGenerator","pyApiGenerator","pyDynamoDBGenerator","pyLambdaFunctionGenerator","pyMcpServerGenerator","pyProjectGenerator","pyRdbGenerator","terraformProjectGenerator","tsAgentGenerator","tsApiGenerator","tsAstroDocsGenerator","tsDcrProxyGenerator","tsDynamoDBGenerator","tsInfraGenerator","tsLambdaFunctionGenerator","tsMcpServerGenerator","tsNxGeneratorGenerator","tsNxMigrationGenerator","tsNxPluginGenerator","tsProjectGenerator","tsRdbGenerator","tsWebsiteAuthGenerator","tsWebsiteGenerator","installDependencies","toSnakeCase","getNpmScope","getNpmScopePrefix","internalTestMatrixGenerator","tree","options","preferInstallDependencies","defaults","projectDefaults","directory","ts","name","py","infra","type","stageConfig","iac","tanstackRouter","project","cognitoDomain","allowSignup","tsApis","auth","framework","api","pyApis","event","tsAgents","protocol","agent","pyAgents","langchainAgents","tsRdbs","engine","rdb","pyRdbs","connections","sourceProject","targetProject","sourceComponent","targetComponent","connection","license","copyrightHolder","migrations","description","kind","migration","languages"],"mappings":"AAAA;;;CAGC,GAED,SAASA,yBAAyB,QAAQ,iCAA8B;AACxE,SAEEC,mBAAmB,QACd,0BAAuB;AAC9B,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAIEC,gBAAgB,EAChBC,cAAc,EACdC,mBAAmB,EACnBC,yBAAyB,EACzBC,oBAAoB,EACpBC,kBAAkB,EAClBC,cAAc,QACT,kBAAe;AACtB,SAASC,yBAAyB,QAAQ,yBAAsB;AAChE,SAKEC,gBAAgB,EAChBC,cAAc,EACdC,oBAAoB,EACpBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,yBAAyB,EACzBC,oBAAoB,EACpBC,sBAAsB,EACtBC,sBAAsB,EACtBC,mBAAmB,EACnBC,kBAAkB,EAClBC,cAAc,EACdC,sBAAsB,EACtBC,kBAAkB,QACb,kBAAe;AACtB,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,WAAW,QAAQ,uBAAoB;AAChD,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,2BAAwB;AAGvE;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,MAAMC,8BAA8B,OACzCC,MACAC,UAA6C,CAAC,CAAC;IAE/C,MAAMC,4BAA4BD,QAAQC,yBAAyB,IAA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fE,iBAAiB;YACjBD,eAAe;QACjB;KACD;IACD,KAAK,MAAMG,cAAcL,YAAa;QACpC,MAAM9D,oBAAoB8B,MAAM;YAAE,GAAGqC,UAAU;YAAE,GAAGlC,QAAQ;QAAC;IAC/D;IAEA,wDAAwD;IACxD,MAAMhC,iBAAiB6B,MAAM;QAC3BsC,SAAS;QACTC,iBAAiB;QACjB,GAAGpC,QAAQ;IACb;IACA,MAAMb,oBAAoBU,MAAM;QAC9B,GAAGI,eAAe;QAClBG,MAAM;QACNF,WAAW;IACb;IACA,MAAMjB,uBAAuBY,MAAM;QACjCc,SAASR,GAAG;QACZC,MAAM;QACN,GAAGJ,QAAQ;IACb;IAEA,uEAAuE;IACvE,2EAA2E;IAC3E,MAAMqC,aAA8D;QAClE;YACEjC,MAAM;YACNkC,aAAa;QACf;QACA;YACElC,MAAM;YACNkC,aAAa;YACbC,MAAM;QACR;QACA;YACEnC,MAAM;YACNkC,aAAa;YACbC,MAAM;QACR;KACD;IACD,KAAK,MAAMC,aAAaH,WAAY;QAClC,MAAMnD,uBAAuBW,MAAM;YACjC,GAAG2C,SAAS;YACZ7B,SAASR,GAAG;YACZ,GAAGH,QAAQ;QACb;IACF;IAEA,OAAO,IACLR,oBAAoBK,MAAME,2BAA2B;YACnD0C,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAe7C,4BAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/internal/test-matrix/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface InternalTestMatrixGeneratorSchema {\n preferInstallDependencies?: boolean;\n /**\n * IaC provider of the workspace, so the matrix scaffolds the matching\n * infrastructure project. Defaults to `cdk`.\n */\n infra?: 'cdk' | 'terraform';\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,WAOC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export interface InternalTestMatrixGeneratorSchema {
|
|
6
|
+
preferInstallDependencies?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* IaC provider of the workspace, so the matrix scaffolds the matching
|
|
9
|
+
* infrastructure project. Defaults to `cdk`.
|
|
10
|
+
*/
|
|
11
|
+
infra?: 'cdk' | 'terraform';
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "InternalTestMatrix",
|
|
4
|
+
"title": "Internal test matrix generator",
|
|
5
|
+
"description": "Scaffolds every generator, component and connection permutation for end to end tests",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"preferInstallDependencies": {
|
|
9
|
+
"type": "boolean",
|
|
10
|
+
"description": "Install dependencies after each generator rather than once at the end",
|
|
11
|
+
"default": false
|
|
12
|
+
},
|
|
13
|
+
"infra": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "IaC provider of the workspace, so the matrix scaffolds the matching infrastructure project",
|
|
16
|
+
"enum": ["cdk", "terraform"],
|
|
17
|
+
"default": "cdk"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"required": []
|
|
21
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { applyGritQL, matchGritQL } from "../../../utils/ast.js";
|
|
5
|
+
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
6
|
+
import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, SHARED_TERRAFORM_DIR } from "../../../utils/shared-constructs-constants.js";
|
|
7
|
+
/**
|
|
8
|
+
* Count the EC2MetaDataSSRF_QUERYARGUMENTS WAF rule on the UserIdentity Web ACL
|
|
9
|
+
*
|
|
10
|
+
* `AWSManagedRulesCommonRuleSet` treats the loopback `redirect_uri` the Cognito
|
|
11
|
+
* Hosted UI receives during local sign-in as an SSRF attempt, so sign-in against
|
|
12
|
+
* a local dev server fails with an opaque 403 before the login page renders. The
|
|
13
|
+
* rule is overridden to Count while a local callback URL is allowed; every other
|
|
14
|
+
* rule in the group still blocks.
|
|
15
|
+
*
|
|
16
|
+
* The local callback URLs are lifted into a named constant so the override can be
|
|
17
|
+
* derived from them rather than restating the condition.
|
|
18
|
+
*
|
|
19
|
+
* How to write a migration:
|
|
20
|
+
* - https://nx.dev/docs/kb/migration-generators
|
|
21
|
+
* - What `nextSteps` means: https://nx.dev/docs/reference/devkit/MigrationReturnObject
|
|
22
|
+
*
|
|
23
|
+
* Guardrails:
|
|
24
|
+
* - Pattern-match before writing: skip files that have diverged from the shape
|
|
25
|
+
* your generators produce and report them via `nextSteps`, rather than
|
|
26
|
+
* clobbering the user's changes.
|
|
27
|
+
* - Idempotent: re-running must be a no-op.
|
|
28
|
+
* - Format what you write: finish with `formatFilesInSubtree` so the files your
|
|
29
|
+
* migration wrote are formatted correctly.
|
|
30
|
+
*/ const CDK_USER_IDENTITY_FILE = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/core/user-identity.ts`;
|
|
31
|
+
const TERRAFORM_IDENTITY_FILE = `${PACKAGES_DIR}/${SHARED_TERRAFORM_DIR}/src/core/user-identity/identity/identity.tf`;
|
|
32
|
+
const SSRF_RULE_NAME = 'EC2MetaDataSSRF_QUERYARGUMENTS';
|
|
33
|
+
// Guards each file: present only once the override has been added.
|
|
34
|
+
const CDK_MIGRATED_PATTERN = `\`ruleActionOverrides: allowsLocalCallback ? $_ : undefined\``;
|
|
35
|
+
const TERRAFORM_MIGRATED_PATTERN = `language hcl\n\`name = "${SSRF_RULE_NAME}"\``;
|
|
36
|
+
// Every CDK edit site, matched structurally so formatting doesn't affect whether
|
|
37
|
+
// the construct is recognised.
|
|
38
|
+
const CDK_CONSTANT_ANCHOR_PATTERN = "`const WEB_CLIENT_ID = 'WebClient'`";
|
|
39
|
+
// Scoped to the `.concat` callsite so it can't also rewrite the array literal
|
|
40
|
+
// inside the constant this migration inserts.
|
|
41
|
+
const CDK_LOCAL_URLS_PATTERN = "`['http://localhost:4200', 'http://localhost:4300'].concat($rest)`";
|
|
42
|
+
const CDK_CALL_PATTERN = '`this.createWebAcl($id, this.userPool)`';
|
|
43
|
+
const CDK_SIGNATURE_PATTERN = '`private createWebAcl = ($id: string, $pool: UserPool) => $body`';
|
|
44
|
+
const CDK_STATEMENT_PATTERN = "`managedRuleGroupStatement: { name: 'AWSManagedRulesCommonRuleSet', vendorName: 'AWS' }`";
|
|
45
|
+
const CDK_EDITS = [
|
|
46
|
+
// Local callback URLs become a named constant the override can key off.
|
|
47
|
+
[
|
|
48
|
+
CDK_CONSTANT_ANCHOR_PATTERN,
|
|
49
|
+
`${CDK_CONSTANT_ANCHOR_PATTERN} => \`const WEB_CLIENT_ID = 'WebClient';
|
|
50
|
+
|
|
51
|
+
/** Local dev server origins permitted to complete the sign-in redirect */
|
|
52
|
+
const LOCAL_CALLBACK_URLS = ['http://localhost:4200', 'http://localhost:4300']\``
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
CDK_LOCAL_URLS_PATTERN,
|
|
56
|
+
`${CDK_LOCAL_URLS_PATTERN} => \`LOCAL_CALLBACK_URLS.concat($rest)\``
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
CDK_CALL_PATTERN,
|
|
60
|
+
`${CDK_CALL_PATTERN} => \`this.createWebAcl($id, this.userPool, LOCAL_CALLBACK_URLS.length > 0)\``
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
CDK_SIGNATURE_PATTERN,
|
|
64
|
+
`${CDK_SIGNATURE_PATTERN} => \`private createWebAcl = (
|
|
65
|
+
$id: string,
|
|
66
|
+
$pool: UserPool,
|
|
67
|
+
allowsLocalCallback: boolean
|
|
68
|
+
) => $body\``
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
CDK_STATEMENT_PATTERN,
|
|
72
|
+
`${CDK_STATEMENT_PATTERN} => \`managedRuleGroupStatement: {
|
|
73
|
+
name: 'AWSManagedRulesCommonRuleSet',
|
|
74
|
+
vendorName: 'AWS',
|
|
75
|
+
// ${SSRF_RULE_NAME} treats the loopback redirect_uri the
|
|
76
|
+
// Hosted UI receives during local sign-in as an SSRF attempt. Counted
|
|
77
|
+
// only while a local callback URL is allowed; every other rule blocks.
|
|
78
|
+
ruleActionOverrides: allowsLocalCallback
|
|
79
|
+
? [
|
|
80
|
+
{
|
|
81
|
+
name: '${SSRF_RULE_NAME}',
|
|
82
|
+
actionToUse: { count: {} },
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
: undefined,
|
|
86
|
+
}\``
|
|
87
|
+
]
|
|
88
|
+
];
|
|
89
|
+
const TERRAFORM_DATA_SOURCES_PATTERN = [
|
|
90
|
+
'language hcl',
|
|
91
|
+
'`data "aws_region" "current" {}`'
|
|
92
|
+
].join('\n');
|
|
93
|
+
const TERRAFORM_EDITS = [
|
|
94
|
+
// Local callback URLs become a local the override can key off.
|
|
95
|
+
[
|
|
96
|
+
TERRAFORM_DATA_SOURCES_PATTERN,
|
|
97
|
+
[
|
|
98
|
+
'language hcl',
|
|
99
|
+
'`data "aws_region" "current" {}` => `data "aws_region" "current" {}',
|
|
100
|
+
'',
|
|
101
|
+
'locals {',
|
|
102
|
+
' # Local dev server origins permitted to complete the sign-in redirect',
|
|
103
|
+
' local_callback_urls = [',
|
|
104
|
+
' "http://localhost:4200",',
|
|
105
|
+
' "http://localhost:4300"',
|
|
106
|
+
' ]',
|
|
107
|
+
'}`'
|
|
108
|
+
].join('\n')
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
[
|
|
112
|
+
'language hcl',
|
|
113
|
+
'`callback_urls = concat([',
|
|
114
|
+
' "http://localhost:4200",',
|
|
115
|
+
' "http://localhost:4300"',
|
|
116
|
+
' ], var.callback_urls)`'
|
|
117
|
+
].join('\n'),
|
|
118
|
+
[
|
|
119
|
+
'language hcl',
|
|
120
|
+
'`callback_urls = concat([',
|
|
121
|
+
' "http://localhost:4200",',
|
|
122
|
+
' "http://localhost:4300"',
|
|
123
|
+
' ], var.callback_urls)` => `callback_urls = concat(local.local_callback_urls, var.callback_urls)`'
|
|
124
|
+
].join('\n')
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
[
|
|
128
|
+
'language hcl',
|
|
129
|
+
'`logout_urls = concat([',
|
|
130
|
+
' "http://localhost:4200",',
|
|
131
|
+
' "http://localhost:4300"',
|
|
132
|
+
' ], var.logout_urls)`'
|
|
133
|
+
].join('\n'),
|
|
134
|
+
[
|
|
135
|
+
'language hcl',
|
|
136
|
+
'`logout_urls = concat([',
|
|
137
|
+
' "http://localhost:4200",',
|
|
138
|
+
' "http://localhost:4300"',
|
|
139
|
+
' ], var.logout_urls)` => `logout_urls = concat(local.local_callback_urls, var.logout_urls)`'
|
|
140
|
+
].join('\n')
|
|
141
|
+
],
|
|
142
|
+
[
|
|
143
|
+
[
|
|
144
|
+
'language hcl',
|
|
145
|
+
'`managed_rule_group_statement {',
|
|
146
|
+
' name = "AWSManagedRulesCommonRuleSet"',
|
|
147
|
+
' vendor_name = "AWS"',
|
|
148
|
+
' }`'
|
|
149
|
+
].join('\n'),
|
|
150
|
+
[
|
|
151
|
+
'language hcl',
|
|
152
|
+
'`managed_rule_group_statement {',
|
|
153
|
+
' name = "AWSManagedRulesCommonRuleSet"',
|
|
154
|
+
' vendor_name = "AWS"',
|
|
155
|
+
' }` => `managed_rule_group_statement {',
|
|
156
|
+
' name = "AWSManagedRulesCommonRuleSet"',
|
|
157
|
+
' vendor_name = "AWS"',
|
|
158
|
+
'',
|
|
159
|
+
` # ${SSRF_RULE_NAME} treats the loopback redirect_uri the`,
|
|
160
|
+
' # Hosted UI receives during local sign-in as an SSRF attempt. Counted',
|
|
161
|
+
' # only while a local callback URL is allowed; every other rule blocks.',
|
|
162
|
+
' dynamic "rule_action_override" {',
|
|
163
|
+
' for_each = length(local.local_callback_urls) > 0 ? [1] : []',
|
|
164
|
+
'',
|
|
165
|
+
' content {',
|
|
166
|
+
` name = "${SSRF_RULE_NAME}"`,
|
|
167
|
+
'',
|
|
168
|
+
' action_to_use {',
|
|
169
|
+
' count {}',
|
|
170
|
+
' }',
|
|
171
|
+
' }',
|
|
172
|
+
' }',
|
|
173
|
+
' }`'
|
|
174
|
+
].join('\n')
|
|
175
|
+
]
|
|
176
|
+
];
|
|
177
|
+
const divergedNextStep = (filePath)=>`${filePath}: the UserIdentity Web ACL has diverged from the generated shape - left untouched. To sign in against a local dev server, override ${SSRF_RULE_NAME} in the AWSManagedRulesCommonRuleSet rule group to Count, otherwise the Cognito Hosted UI returns 403 for localhost redirect URIs.`;
|
|
178
|
+
const migratedNextStep = (filePath)=>`${filePath}: ${SSRF_RULE_NAME} is now counted rather than blocked while a local callback URL is allowed, so signing in against a local dev server works. Redeploy to apply it.`;
|
|
179
|
+
export default async function migration(tree) {
|
|
180
|
+
const nextSteps = [];
|
|
181
|
+
for (const [filePath, migratedPattern, edits] of [
|
|
182
|
+
[
|
|
183
|
+
CDK_USER_IDENTITY_FILE,
|
|
184
|
+
CDK_MIGRATED_PATTERN,
|
|
185
|
+
CDK_EDITS
|
|
186
|
+
],
|
|
187
|
+
[
|
|
188
|
+
TERRAFORM_IDENTITY_FILE,
|
|
189
|
+
TERRAFORM_MIGRATED_PATTERN,
|
|
190
|
+
TERRAFORM_EDITS
|
|
191
|
+
]
|
|
192
|
+
]){
|
|
193
|
+
if (!tree.exists(filePath)) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (await matchGritQL(tree, filePath, migratedPattern)) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
// Confirm every edit site is present before writing any of them, so a file
|
|
200
|
+
// that only partly matches is left whole rather than half-edited.
|
|
201
|
+
const allSitesPresent = (await Promise.all(edits.map(([match])=>matchGritQL(tree, filePath, match)))).every(Boolean);
|
|
202
|
+
if (!allSitesPresent) {
|
|
203
|
+
nextSteps.push(divergedNextStep(filePath));
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
for (const [, rewrite] of edits){
|
|
207
|
+
await applyGritQL(tree, filePath, rewrite);
|
|
208
|
+
}
|
|
209
|
+
nextSteps.push(migratedNextStep(filePath));
|
|
210
|
+
}
|
|
211
|
+
await formatFilesInSubtree(tree);
|
|
212
|
+
return {
|
|
213
|
+
nextSteps
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationReturnObject, Tree } from '@nx/devkit';\nimport { applyGritQL, matchGritQL } from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../../../utils/shared-constructs-constants';\n\n/**\n * Count the EC2MetaDataSSRF_QUERYARGUMENTS WAF rule on the UserIdentity Web ACL\n *\n * `AWSManagedRulesCommonRuleSet` treats the loopback `redirect_uri` the Cognito\n * Hosted UI receives during local sign-in as an SSRF attempt, so sign-in against\n * a local dev server fails with an opaque 403 before the login page renders. The\n * rule is overridden to Count while a local callback URL is allowed; every other\n * rule in the group still blocks.\n *\n * The local callback URLs are lifted into a named constant so the override can be\n * derived from them rather than restating the condition.\n *\n * How to write a migration:\n * - https://nx.dev/docs/kb/migration-generators\n * - What `nextSteps` means: https://nx.dev/docs/reference/devkit/MigrationReturnObject\n *\n * Guardrails:\n * - Pattern-match before writing: skip files that have diverged from the shape\n * your generators produce and report them via `nextSteps`, rather than\n * clobbering the user's changes.\n * - Idempotent: re-running must be a no-op.\n * - Format what you write: finish with `formatFilesInSubtree` so the files your\n * migration wrote are formatted correctly.\n */\n\nconst CDK_USER_IDENTITY_FILE = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/core/user-identity.ts`;\nconst TERRAFORM_IDENTITY_FILE = `${PACKAGES_DIR}/${SHARED_TERRAFORM_DIR}/src/core/user-identity/identity/identity.tf`;\n\nconst SSRF_RULE_NAME = 'EC2MetaDataSSRF_QUERYARGUMENTS';\n\n// Guards each file: present only once the override has been added.\nconst CDK_MIGRATED_PATTERN = `\\`ruleActionOverrides: allowsLocalCallback ? $_ : undefined\\``;\nconst TERRAFORM_MIGRATED_PATTERN = `language hcl\\n\\`name = \"${SSRF_RULE_NAME}\"\\``;\n\n// Every CDK edit site, matched structurally so formatting doesn't affect whether\n// the construct is recognised.\nconst CDK_CONSTANT_ANCHOR_PATTERN = \"`const WEB_CLIENT_ID = 'WebClient'`\";\n// Scoped to the `.concat` callsite so it can't also rewrite the array literal\n// inside the constant this migration inserts.\nconst CDK_LOCAL_URLS_PATTERN =\n \"`['http://localhost:4200', 'http://localhost:4300'].concat($rest)`\";\nconst CDK_CALL_PATTERN = '`this.createWebAcl($id, this.userPool)`';\nconst CDK_SIGNATURE_PATTERN =\n '`private createWebAcl = ($id: string, $pool: UserPool) => $body`';\nconst CDK_STATEMENT_PATTERN =\n \"`managedRuleGroupStatement: { name: 'AWSManagedRulesCommonRuleSet', vendorName: 'AWS' }`\";\n\nconst CDK_EDITS: Array<[string, string]> = [\n // Local callback URLs become a named constant the override can key off.\n [\n CDK_CONSTANT_ANCHOR_PATTERN,\n `${CDK_CONSTANT_ANCHOR_PATTERN} => \\`const WEB_CLIENT_ID = 'WebClient';\n\n/** Local dev server origins permitted to complete the sign-in redirect */\nconst LOCAL_CALLBACK_URLS = ['http://localhost:4200', 'http://localhost:4300']\\``,\n ],\n [\n CDK_LOCAL_URLS_PATTERN,\n `${CDK_LOCAL_URLS_PATTERN} => \\`LOCAL_CALLBACK_URLS.concat($rest)\\``,\n ],\n [\n CDK_CALL_PATTERN,\n `${CDK_CALL_PATTERN} => \\`this.createWebAcl($id, this.userPool, LOCAL_CALLBACK_URLS.length > 0)\\``,\n ],\n [\n CDK_SIGNATURE_PATTERN,\n `${CDK_SIGNATURE_PATTERN} => \\`private createWebAcl = (\n $id: string,\n $pool: UserPool,\n allowsLocalCallback: boolean\n ) => $body\\``,\n ],\n [\n CDK_STATEMENT_PATTERN,\n `${CDK_STATEMENT_PATTERN} => \\`managedRuleGroupStatement: {\n name: 'AWSManagedRulesCommonRuleSet',\n vendorName: 'AWS',\n // ${SSRF_RULE_NAME} treats the loopback redirect_uri the\n // Hosted UI receives during local sign-in as an SSRF attempt. Counted\n // only while a local callback URL is allowed; every other rule blocks.\n ruleActionOverrides: allowsLocalCallback\n ? [\n {\n name: '${SSRF_RULE_NAME}',\n actionToUse: { count: {} },\n },\n ]\n : undefined,\n }\\``,\n ],\n];\n\nconst TERRAFORM_DATA_SOURCES_PATTERN = [\n 'language hcl',\n '`data \"aws_region\" \"current\" {}`',\n].join('\\n');\n\nconst TERRAFORM_EDITS: Array<[string, string]> = [\n // Local callback URLs become a local the override can key off.\n [\n TERRAFORM_DATA_SOURCES_PATTERN,\n [\n 'language hcl',\n '`data \"aws_region\" \"current\" {}` => `data \"aws_region\" \"current\" {}',\n '',\n 'locals {',\n ' # Local dev server origins permitted to complete the sign-in redirect',\n ' local_callback_urls = [',\n ' \"http://localhost:4200\",',\n ' \"http://localhost:4300\"',\n ' ]',\n '}`',\n ].join('\\n'),\n ],\n [\n [\n 'language hcl',\n '`callback_urls = concat([',\n ' \"http://localhost:4200\",',\n ' \"http://localhost:4300\"',\n ' ], var.callback_urls)`',\n ].join('\\n'),\n [\n 'language hcl',\n '`callback_urls = concat([',\n ' \"http://localhost:4200\",',\n ' \"http://localhost:4300\"',\n ' ], var.callback_urls)` => `callback_urls = concat(local.local_callback_urls, var.callback_urls)`',\n ].join('\\n'),\n ],\n [\n [\n 'language hcl',\n '`logout_urls = concat([',\n ' \"http://localhost:4200\",',\n ' \"http://localhost:4300\"',\n ' ], var.logout_urls)`',\n ].join('\\n'),\n [\n 'language hcl',\n '`logout_urls = concat([',\n ' \"http://localhost:4200\",',\n ' \"http://localhost:4300\"',\n ' ], var.logout_urls)` => `logout_urls = concat(local.local_callback_urls, var.logout_urls)`',\n ].join('\\n'),\n ],\n [\n [\n 'language hcl',\n '`managed_rule_group_statement {',\n ' name = \"AWSManagedRulesCommonRuleSet\"',\n ' vendor_name = \"AWS\"',\n ' }`',\n ].join('\\n'),\n [\n 'language hcl',\n '`managed_rule_group_statement {',\n ' name = \"AWSManagedRulesCommonRuleSet\"',\n ' vendor_name = \"AWS\"',\n ' }` => `managed_rule_group_statement {',\n ' name = \"AWSManagedRulesCommonRuleSet\"',\n ' vendor_name = \"AWS\"',\n '',\n ` # ${SSRF_RULE_NAME} treats the loopback redirect_uri the`,\n ' # Hosted UI receives during local sign-in as an SSRF attempt. Counted',\n ' # only while a local callback URL is allowed; every other rule blocks.',\n ' dynamic \"rule_action_override\" {',\n ' for_each = length(local.local_callback_urls) > 0 ? [1] : []',\n '',\n ' content {',\n ` name = \"${SSRF_RULE_NAME}\"`,\n '',\n ' action_to_use {',\n ' count {}',\n ' }',\n ' }',\n ' }',\n ' }`',\n ].join('\\n'),\n ],\n];\n\nconst divergedNextStep = (filePath: string) =>\n `${filePath}: the UserIdentity Web ACL has diverged from the generated shape - left untouched. To sign in against a local dev server, override ${SSRF_RULE_NAME} in the AWSManagedRulesCommonRuleSet rule group to Count, otherwise the Cognito Hosted UI returns 403 for localhost redirect URIs.`;\n\nconst migratedNextStep = (filePath: string) =>\n `${filePath}: ${SSRF_RULE_NAME} is now counted rather than blocked while a local callback URL is allowed, so signing in against a local dev server works. Redeploy to apply it.`;\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const [filePath, migratedPattern, edits] of [\n [CDK_USER_IDENTITY_FILE, CDK_MIGRATED_PATTERN, CDK_EDITS],\n [TERRAFORM_IDENTITY_FILE, TERRAFORM_MIGRATED_PATTERN, TERRAFORM_EDITS],\n ] as const) {\n if (!tree.exists(filePath)) {\n // This workspace doesn't use this IaC provider, or has no UserIdentity.\n continue;\n }\n\n if (await matchGritQL(tree, filePath, migratedPattern)) {\n // Already migrated - silent skip keeps re-runs a no-op.\n continue;\n }\n\n // Confirm every edit site is present before writing any of them, so a file\n // that only partly matches is left whole rather than half-edited.\n const allSitesPresent = (\n await Promise.all(\n edits.map(([match]) => matchGritQL(tree, filePath, match)),\n )\n ).every(Boolean);\n\n if (!allSitesPresent) {\n nextSteps.push(divergedNextStep(filePath));\n continue;\n }\n\n for (const [, rewrite] of edits) {\n await applyGritQL(tree, filePath, rewrite);\n }\n nextSteps.push(migratedNextStep(filePath));\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["applyGritQL","matchGritQL","formatFilesInSubtree","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","CDK_USER_IDENTITY_FILE","TERRAFORM_IDENTITY_FILE","SSRF_RULE_NAME","CDK_MIGRATED_PATTERN","TERRAFORM_MIGRATED_PATTERN","CDK_CONSTANT_ANCHOR_PATTERN","CDK_LOCAL_URLS_PATTERN","CDK_CALL_PATTERN","CDK_SIGNATURE_PATTERN","CDK_STATEMENT_PATTERN","CDK_EDITS","TERRAFORM_DATA_SOURCES_PATTERN","join","TERRAFORM_EDITS","divergedNextStep","filePath","migratedNextStep","migration","tree","nextSteps","migratedPattern","edits","exists","allSitesPresent","Promise","all","map","match","every","Boolean","push","rewrite"],"mappings":"AAAA;;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AQ,IAAIV,MAAO;YAC/B,MAAM3B,YAAYwB,MAAMH,UAAUgB;QACpC;QACAZ,UAAUW,IAAI,CAACd,iBAAiBD;IAClC;IAEA,MAAMnB,qBAAqBsB;IAE3B,OAAO;QAAEC;IAAU;AACrB"}
|
package/src/sdk/py.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { pyAgentGenerator } from '../py/agent/generator';
|
|
|
6
6
|
export type { PyAgentGeneratorSchema } from '../py/agent/schema';
|
|
7
7
|
export { pyApiGenerator } from '../py/api/generator';
|
|
8
8
|
export type { PyApiGeneratorSchema } from '../py/api/schema';
|
|
9
|
+
export { pyDynamoDBGenerator } from '../py/dynamodb/generator';
|
|
10
|
+
export type { PyDynamoDBGeneratorSchema } from '../py/dynamodb/schema';
|
|
9
11
|
export { pyLambdaFunctionGenerator } from '../py/lambda-function/generator';
|
|
10
12
|
export type { PyLambdaFunctionGeneratorSchema } from '../py/lambda-function/schema';
|
|
11
13
|
export { pyMcpServerGenerator } from '../py/mcp-server/generator';
|
package/src/sdk/py.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/ export { pyAgentGenerator } from "../py/agent/generator.js";
|
|
5
5
|
export { pyApiGenerator } from "../py/api/generator.js";
|
|
6
|
+
export { pyDynamoDBGenerator } from "../py/dynamodb/generator.js";
|
|
6
7
|
export { pyLambdaFunctionGenerator } from "../py/lambda-function/generator.js";
|
|
7
8
|
export { pyMcpServerGenerator } from "../py/mcp-server/generator.js";
|
|
8
9
|
export { pyProjectGenerator } from "../py/project/generator.js";
|
package/src/sdk/py.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/py.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { pyAgentGenerator } from '../py/agent/generator';\nexport type { PyAgentGeneratorSchema } from '../py/agent/schema';\n\nexport { pyApiGenerator } from '../py/api/generator';\nexport type { PyApiGeneratorSchema } from '../py/api/schema';\n\nexport { pyLambdaFunctionGenerator } from '../py/lambda-function/generator';\nexport type { PyLambdaFunctionGeneratorSchema } from '../py/lambda-function/schema';\n\nexport { pyMcpServerGenerator } from '../py/mcp-server/generator';\nexport type { PyMcpServerGeneratorSchema } from '../py/mcp-server/schema';\nexport { pyProjectGenerator } from '../py/project/generator';\nexport type { PyProjectGeneratorSchema } from '../py/project/schema';\n\nexport { pyRdbGenerator } from '../py/rdb/generator';\nexport type { PyRdbGeneratorSchema } from '../py/rdb/schema';\n"],"names":["pyAgentGenerator","pyApiGenerator","pyLambdaFunctionGenerator","pyMcpServerGenerator","pyProjectGenerator","pyRdbGenerator"],"mappings":"AAAA;;;CAGC,GAED,SAASA,gBAAgB,QAAQ,2BAAwB;AAGzD,SAASC,cAAc,QAAQ,yBAAsB;AAGrD,SAASC,yBAAyB,QAAQ,qCAAkC;AAG5E,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,SAASC,kBAAkB,QAAQ,6BAA0B;AAG7D,SAASC,cAAc,QAAQ,yBAAsB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/py.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { pyAgentGenerator } from '../py/agent/generator';\nexport type { PyAgentGeneratorSchema } from '../py/agent/schema';\n\nexport { pyApiGenerator } from '../py/api/generator';\nexport type { PyApiGeneratorSchema } from '../py/api/schema';\n\nexport { pyDynamoDBGenerator } from '../py/dynamodb/generator';\nexport type { PyDynamoDBGeneratorSchema } from '../py/dynamodb/schema';\n\nexport { pyLambdaFunctionGenerator } from '../py/lambda-function/generator';\nexport type { PyLambdaFunctionGeneratorSchema } from '../py/lambda-function/schema';\n\nexport { pyMcpServerGenerator } from '../py/mcp-server/generator';\nexport type { PyMcpServerGeneratorSchema } from '../py/mcp-server/schema';\nexport { pyProjectGenerator } from '../py/project/generator';\nexport type { PyProjectGeneratorSchema } from '../py/project/schema';\n\nexport { pyRdbGenerator } from '../py/rdb/generator';\nexport type { PyRdbGeneratorSchema } from '../py/rdb/schema';\n"],"names":["pyAgentGenerator","pyApiGenerator","pyDynamoDBGenerator","pyLambdaFunctionGenerator","pyMcpServerGenerator","pyProjectGenerator","pyRdbGenerator"],"mappings":"AAAA;;;CAGC,GAED,SAASA,gBAAgB,QAAQ,2BAAwB;AAGzD,SAASC,cAAc,QAAQ,yBAAsB;AAGrD,SAASC,mBAAmB,QAAQ,8BAA2B;AAG/D,SAASC,yBAAyB,QAAQ,qCAAkC;AAG5E,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,SAASC,kBAAkB,QAAQ,6BAA0B;AAG7D,SAASC,cAAc,QAAQ,yBAAsB"}
|
package/src/sdk/ts.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { tsAgentGenerator } from '../ts/agent/generator';
|
|
|
8
8
|
export type { TsAgentGeneratorSchema } from '../ts/agent/schema';
|
|
9
9
|
export { tsApiGenerator } from '../ts/api/generator';
|
|
10
10
|
export type { TsApiGeneratorSchema } from '../ts/api/schema';
|
|
11
|
+
export { tsAstroDocsGenerator } from '../ts/astro-docs/generator';
|
|
12
|
+
export type { TsAstroDocsGeneratorSchema } from '../ts/astro-docs/schema';
|
|
11
13
|
export { tsDcrProxyGenerator } from '../ts/dcr-proxy/generator';
|
|
12
14
|
export type { TsDcrProxyGeneratorSchema } from '../ts/dcr-proxy/schema';
|
|
13
15
|
export { tsDocsGenerator } from '../ts/docs/generator';
|
package/src/sdk/ts.js
CHANGED
|
@@ -7,6 +7,8 @@ export { tsInfraGenerator } from "../infra/app/generator.js";
|
|
|
7
7
|
export { tsAgentGenerator } from "../ts/agent/generator.js";
|
|
8
8
|
// TypeScript API
|
|
9
9
|
export { tsApiGenerator } from "../ts/api/generator.js";
|
|
10
|
+
// Astro Documentation Site Generator
|
|
11
|
+
export { tsAstroDocsGenerator } from "../ts/astro-docs/generator.js";
|
|
10
12
|
// TypeScript DCR Proxy Generator
|
|
11
13
|
export { tsDcrProxyGenerator } from "../ts/dcr-proxy/generator.js";
|
|
12
14
|
// Documentation Site Generator
|
package/src/sdk/ts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/ts.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// TypeScript Infrastructure\nexport { tsInfraGenerator } from '../infra/app/generator';\nexport type { TsInfraGeneratorSchema } from '../infra/app/schema';\n// TypeScript Agent Generator\nexport { tsAgentGenerator } from '../ts/agent/generator';\nexport type { TsAgentGeneratorSchema } from '../ts/agent/schema';\n// TypeScript API\nexport { tsApiGenerator } from '../ts/api/generator';\nexport type { TsApiGeneratorSchema } from '../ts/api/schema';\n// TypeScript DCR Proxy Generator\nexport { tsDcrProxyGenerator } from '../ts/dcr-proxy/generator';\nexport type { TsDcrProxyGeneratorSchema } from '../ts/dcr-proxy/schema';\n// Documentation Site Generator\nexport { tsDocsGenerator } from '../ts/docs/generator';\nexport type { TsDocsGeneratorSchema } from '../ts/docs/schema';\n// DynamoDB Generator\nexport { tsDynamoDBGenerator } from '../ts/dynamodb/generator';\nexport type { TsDynamoDBGeneratorSchema } from '../ts/dynamodb/schema';\n// TypeScript Lambda Function\nexport { tsLambdaFunctionGenerator } from '../ts/lambda-function/generator';\nexport type { TsLambdaFunctionGeneratorSchema } from '../ts/lambda-function/schema';\n// TypeScript Project Generator\nexport { tsProjectGenerator } from '../ts/lib/generator';\nexport type { TsProjectGeneratorSchema } from '../ts/lib/schema';\n// TypeScript MCP Server Generator\nexport { tsMcpServerGenerator } from '../ts/mcp-server/generator';\nexport type { TsMcpServerGeneratorSchema } from '../ts/mcp-server/schema';\n// TypeScript Nx Generator Generator\nexport { tsNxGeneratorGenerator } from '../ts/nx-generator/generator';\nexport type { TsNxGeneratorGeneratorSchema } from '../ts/nx-generator/schema';\n// TypeScript Nx Migration Generator\nexport { tsNxMigrationGenerator } from '../ts/nx-migration/generator';\nexport type { TsNxMigrationGeneratorSchema } from '../ts/nx-migration/schema';\n// TypeScript Nx Plugin Generator\nexport { tsNxPluginGenerator } from '../ts/nx-plugin/generator';\nexport type { TsNxPluginGeneratorSchema } from '../ts/nx-plugin/schema';\n// Relational Database Generator\nexport { tsRdbGenerator } from '../ts/rdb/generator';\nexport type { TsRdbGeneratorSchema } from '../ts/rdb/schema';\n// Runtime Config\nexport { runtimeConfigGenerator } from '../ts/react-website/runtime-config/generator';\nexport type { RuntimeConfigGeneratorSchema } from '../ts/react-website/runtime-config/schema';\n// TypeScript Website Generator\nexport { tsWebsiteGenerator } from '../ts/website/app/generator';\nexport type { TsWebsiteGeneratorSchema } from '../ts/website/app/schema';\n// TypeScript Website Auth Generator\nexport { tsWebsiteAuthGenerator } from '../ts/website/auth/generator';\nexport type { TsWebsiteAuthGeneratorSchema } from '../ts/website/auth/schema';\n\n// Shared Constructs\nexport { sharedConstructsGenerator } from '../utils/shared-constructs';\n"],"names":["tsInfraGenerator","tsAgentGenerator","tsApiGenerator","tsDcrProxyGenerator","tsDocsGenerator","tsDynamoDBGenerator","tsLambdaFunctionGenerator","tsProjectGenerator","tsMcpServerGenerator","tsNxGeneratorGenerator","tsNxMigrationGenerator","tsNxPluginGenerator","tsRdbGenerator","runtimeConfigGenerator","tsWebsiteGenerator","tsWebsiteAuthGenerator","sharedConstructsGenerator"],"mappings":"AAAA;;;CAGC,GAED,4BAA4B;AAC5B,SAASA,gBAAgB,QAAQ,4BAAyB;AAE1D,6BAA6B;AAC7B,SAASC,gBAAgB,QAAQ,2BAAwB;AAEzD,iBAAiB;AACjB,SAASC,cAAc,QAAQ,yBAAsB;AAErD,iCAAiC;AACjC,SAASC,mBAAmB,QAAQ,+BAA4B;AAEhE,+BAA+B;AAC/B,SAASC,eAAe,QAAQ,0BAAuB;AAEvD,qBAAqB;AACrB,SAASC,mBAAmB,QAAQ,8BAA2B;AAE/D,6BAA6B;AAC7B,SAASC,yBAAyB,QAAQ,qCAAkC;AAE5E,+BAA+B;AAC/B,SAASC,kBAAkB,QAAQ,yBAAsB;AAEzD,kCAAkC;AAClC,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAEtE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAEtE,iCAAiC;AACjC,SAASC,mBAAmB,QAAQ,+BAA4B;AAEhE,gCAAgC;AAChC,SAASC,cAAc,QAAQ,yBAAsB;AAErD,iBAAiB;AACjB,SAASC,sBAAsB,QAAQ,kDAA+C;AAEtF,+BAA+B;AAC/B,SAASC,kBAAkB,QAAQ,iCAA8B;AAEjE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAGtE,oBAAoB;AACpB,SAASC,yBAAyB,QAAQ,gCAA6B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/ts.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// TypeScript Infrastructure\nexport { tsInfraGenerator } from '../infra/app/generator';\nexport type { TsInfraGeneratorSchema } from '../infra/app/schema';\n// TypeScript Agent Generator\nexport { tsAgentGenerator } from '../ts/agent/generator';\nexport type { TsAgentGeneratorSchema } from '../ts/agent/schema';\n// TypeScript API\nexport { tsApiGenerator } from '../ts/api/generator';\nexport type { TsApiGeneratorSchema } from '../ts/api/schema';\n// Astro Documentation Site Generator\nexport { tsAstroDocsGenerator } from '../ts/astro-docs/generator';\nexport type { TsAstroDocsGeneratorSchema } from '../ts/astro-docs/schema';\n// TypeScript DCR Proxy Generator\nexport { tsDcrProxyGenerator } from '../ts/dcr-proxy/generator';\nexport type { TsDcrProxyGeneratorSchema } from '../ts/dcr-proxy/schema';\n// Documentation Site Generator\nexport { tsDocsGenerator } from '../ts/docs/generator';\nexport type { TsDocsGeneratorSchema } from '../ts/docs/schema';\n// DynamoDB Generator\nexport { tsDynamoDBGenerator } from '../ts/dynamodb/generator';\nexport type { TsDynamoDBGeneratorSchema } from '../ts/dynamodb/schema';\n// TypeScript Lambda Function\nexport { tsLambdaFunctionGenerator } from '../ts/lambda-function/generator';\nexport type { TsLambdaFunctionGeneratorSchema } from '../ts/lambda-function/schema';\n// TypeScript Project Generator\nexport { tsProjectGenerator } from '../ts/lib/generator';\nexport type { TsProjectGeneratorSchema } from '../ts/lib/schema';\n// TypeScript MCP Server Generator\nexport { tsMcpServerGenerator } from '../ts/mcp-server/generator';\nexport type { TsMcpServerGeneratorSchema } from '../ts/mcp-server/schema';\n// TypeScript Nx Generator Generator\nexport { tsNxGeneratorGenerator } from '../ts/nx-generator/generator';\nexport type { TsNxGeneratorGeneratorSchema } from '../ts/nx-generator/schema';\n// TypeScript Nx Migration Generator\nexport { tsNxMigrationGenerator } from '../ts/nx-migration/generator';\nexport type { TsNxMigrationGeneratorSchema } from '../ts/nx-migration/schema';\n// TypeScript Nx Plugin Generator\nexport { tsNxPluginGenerator } from '../ts/nx-plugin/generator';\nexport type { TsNxPluginGeneratorSchema } from '../ts/nx-plugin/schema';\n// Relational Database Generator\nexport { tsRdbGenerator } from '../ts/rdb/generator';\nexport type { TsRdbGeneratorSchema } from '../ts/rdb/schema';\n// Runtime Config\nexport { runtimeConfigGenerator } from '../ts/react-website/runtime-config/generator';\nexport type { RuntimeConfigGeneratorSchema } from '../ts/react-website/runtime-config/schema';\n// TypeScript Website Generator\nexport { tsWebsiteGenerator } from '../ts/website/app/generator';\nexport type { TsWebsiteGeneratorSchema } from '../ts/website/app/schema';\n// TypeScript Website Auth Generator\nexport { tsWebsiteAuthGenerator } from '../ts/website/auth/generator';\nexport type { TsWebsiteAuthGeneratorSchema } from '../ts/website/auth/schema';\n\n// Shared Constructs\nexport { sharedConstructsGenerator } from '../utils/shared-constructs';\n"],"names":["tsInfraGenerator","tsAgentGenerator","tsApiGenerator","tsAstroDocsGenerator","tsDcrProxyGenerator","tsDocsGenerator","tsDynamoDBGenerator","tsLambdaFunctionGenerator","tsProjectGenerator","tsMcpServerGenerator","tsNxGeneratorGenerator","tsNxMigrationGenerator","tsNxPluginGenerator","tsRdbGenerator","runtimeConfigGenerator","tsWebsiteGenerator","tsWebsiteAuthGenerator","sharedConstructsGenerator"],"mappings":"AAAA;;;CAGC,GAED,4BAA4B;AAC5B,SAASA,gBAAgB,QAAQ,4BAAyB;AAE1D,6BAA6B;AAC7B,SAASC,gBAAgB,QAAQ,2BAAwB;AAEzD,iBAAiB;AACjB,SAASC,cAAc,QAAQ,yBAAsB;AAErD,qCAAqC;AACrC,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,iCAAiC;AACjC,SAASC,mBAAmB,QAAQ,+BAA4B;AAEhE,+BAA+B;AAC/B,SAASC,eAAe,QAAQ,0BAAuB;AAEvD,qBAAqB;AACrB,SAASC,mBAAmB,QAAQ,8BAA2B;AAE/D,6BAA6B;AAC7B,SAASC,yBAAyB,QAAQ,qCAAkC;AAE5E,+BAA+B;AAC/B,SAASC,kBAAkB,QAAQ,yBAAsB;AAEzD,kCAAkC;AAClC,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAEtE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAEtE,iCAAiC;AACjC,SAASC,mBAAmB,QAAQ,+BAA4B;AAEhE,gCAAgC;AAChC,SAASC,cAAc,QAAQ,yBAAsB;AAErD,iBAAiB;AACjB,SAASC,sBAAsB,QAAQ,kDAA+C;AAEtF,+BAA+B;AAC/B,SAASC,kBAAkB,QAAQ,iCAA8B;AAEjE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAGtE,oBAAoB;AACpB,SAASC,yBAAyB,QAAQ,gCAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/sdk/utils/format.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { formatFilesInSubtree
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/sdk/utils/format.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport {\n type FormatFilesInSubtreeOptions,\n formatFilesInSubtree,\n} from '../../utils/format';\n"],"names":["formatFilesInSubtree"],"mappings":"AAAA;;;CAGC,GAED,SAEEA,oBAAoB,QACf,wBAAqB"}
|
package/src/ts/rdb/generator.js
CHANGED
|
@@ -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
|
*/ import { relative } from "node:path";
|
|
5
|
-
import { generateFiles, joinPathFragments, readProjectConfiguration, updateJson, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
+
import { detectPackageManager, generateFiles, joinPathFragments, readProjectConfiguration, updateJson, updateProjectConfiguration } from "@nx/devkit";
|
|
6
6
|
import { addTypeScriptBundleTarget } from "../../utils/bundle/bundle.js";
|
|
7
7
|
import { resolveContainers } from "../../utils/containers.js";
|
|
8
8
|
import { addDependenciesToPackageJson } from "../../utils/dependencies.js";
|
|
@@ -248,6 +248,24 @@ export const tsRdbGenerator = async (tree, options)=>{
|
|
|
248
248
|
'@types/pg'
|
|
249
249
|
]
|
|
250
250
|
]), joinPathFragments(projectConfig.root, 'package.json'));
|
|
251
|
+
// @prisma/adapter-pg depends on @types/pg ^8.16.0. Yarn does not dedupe it to
|
|
252
|
+
// the workspace's pinned @types/pg, so it installs a separate copy under the
|
|
253
|
+
// adapter's own node_modules whenever a newer @types/pg is published. The two
|
|
254
|
+
// copies declare structurally incompatible Pool types, so passing our `new
|
|
255
|
+
// Pool(...)` to `new PrismaPg(...)` fails to compile. Scope the resolution to
|
|
256
|
+
// the adapter so other @types/pg consumers are unaffected. Classic yarn only
|
|
257
|
+
// honours the `**/`-prefixed descriptor in a workspace and berry only the
|
|
258
|
+
// bare one, so declare both.
|
|
259
|
+
if (options.engine === 'postgres' && detectPackageManager() === 'yarn') {
|
|
260
|
+
updateJson(tree, 'package.json', (packageJson)=>{
|
|
261
|
+
packageJson.resolutions = {
|
|
262
|
+
...packageJson.resolutions,
|
|
263
|
+
'**/@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],
|
|
264
|
+
'@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg']
|
|
265
|
+
};
|
|
266
|
+
return packageJson;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
251
269
|
// The prisma CLI and tsx run migration/seed scripts from the root.
|
|
252
270
|
addDependenciesToPackageJson(tree, {}, withVersions([
|
|
253
271
|
'prisma',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { addDockerScanTarget, nodeImageVersions } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedRdbScriptsGenerator } from '../../utils/shared-rdb-scripts';\nimport { TS_VERSIONS, withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsRdbGeneratorSchema } from './schema';\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n ...nodeImageVersions(),\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n });\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n });\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cp(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cp(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cp(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\n\n addDockerScanTarget(tree, {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n });\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_RDB_GENERATOR_INFO, {\n engine: options.engine,\n });\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n '@aws-sdk/client-secrets-manager',\n '@aws-sdk/rds-signer',\n '@prisma/client',\n ...(options.engine === 'mysql'\n ? (['@prisma/adapter-mariadb', 'mariadb'] as const)\n : (['@prisma/adapter-pg', 'pg'] as const)),\n ]),\n withVersions([\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n joinPathFragments(projectConfig.root, 'package.json'),\n );\n // The prisma CLI and tsx run migration/seed scripts from the root.\n addDependenciesToPackageJson(tree, {}, withVersions(['prisma', 'tsx']));\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","addDependenciesToPackageJson","addDockerScanTarget","nodeImageVersions","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedRdbScriptsGenerator","TS_VERSIONS","withVersions","tsProjectGenerator","getTsLibDetails","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","name","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","engine","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","patterns","waitForDbScript","scriptsDir","relativePathToRoot","root","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","project","trivyTargetName","dockerTargetName","imageTags","projectName","projectRoot","adminUser","createDbUserBundleDir","framework","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SAEEC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,4BAA4B,QAAQ,8BAA2B;AACxE,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,wBAAqB;AAC5E,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,OAAO,QAAQ,+BAA4B;AACpD,SAASC,SAAS,EAAEC,SAAS,EAAEC,WAAW,QAAQ,uBAAoB;AACtE,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,QAEX,oBAAiB;AACxB,SAASC,gCAAgC,QAAQ,uBAAoB;AACrE,SAASC,6BAA6B,QAAQ,gCAA6B;AAC3E,SAASC,UAAU,QAAQ,sBAAmB;AAC9C,SAASC,WAAW,QAAQ,+CAA4C;AACxE,SAASC,yBAAyB,QAAQ,mCAAgC;AAC1E,SACEC,YAAY,EACZC,kBAAkB,QACb,6CAA0C;AACjD,SAASC,yBAAyB,QAAQ,oCAAiC;AAC3E,SAASC,WAAW,EAAEC,YAAY,QAAQ,0BAAuB;AACjE,OAAOC,sBA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EAvC,6BACEgC,MACAN,aAAa;QACX;QACA;QACA;QACA;QACA;WACIO,QAAQiB,MAAM,KAAK,UAClB;YAAC;YAA2B;SAAU,GACtC;YAAC;YAAsB;SAAK;KAClC,GACDxB,aAAa;QACX;WACIO,QAAQiB,MAAM,KAAK,UAClB,EAAE,GACF;YAAC;SAAY;KACnB,GACDxD,kBAAkBsD,cAAcsB,IAAI,EAAE;IAExC,mEAAmE;IACnEtE,6BAA6BgC,MAAM,CAAC,GAAGN,aAAa;QAAC;QAAU;KAAM;IAErER,8BAA8Bc,MAAM;QAClC,mBAAmB;QACnB6B,QAAQ;IACV;IAEA,MAAMrD,gCAAgCwB,MAAM;QAACH;KAAsB;IAEnE,MAAM1B,qBAAqB6B;IAC3B,OAAO,IACLzB,oBAAoByB,MAAMC,QAAQY,yBAAyB,EAAE;YAC3D4D,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe1E,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { addDockerScanTarget, nodeImageVersions } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedRdbScriptsGenerator } from '../../utils/shared-rdb-scripts';\nimport { TS_VERSIONS, withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsRdbGeneratorSchema } from './schema';\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n ...nodeImageVersions(),\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n });\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n });\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cp(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cp(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cp(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\n\n addDockerScanTarget(tree, {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n });\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_RDB_GENERATOR_INFO, {\n engine: options.engine,\n });\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n '@aws-sdk/client-secrets-manager',\n '@aws-sdk/rds-signer',\n '@prisma/client',\n ...(options.engine === 'mysql'\n ? (['@prisma/adapter-mariadb', 'mariadb'] as const)\n : (['@prisma/adapter-pg', 'pg'] as const)),\n ]),\n withVersions([\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n joinPathFragments(projectConfig.root, 'package.json'),\n );\n\n // @prisma/adapter-pg depends on @types/pg ^8.16.0. Yarn does not dedupe it to\n // the workspace's pinned @types/pg, so it installs a separate copy under the\n // adapter's own node_modules whenever a newer @types/pg is published. The two\n // copies declare structurally incompatible Pool types, so passing our `new\n // Pool(...)` to `new PrismaPg(...)` fails to compile. Scope the resolution to\n // the adapter so other @types/pg consumers are unaffected. Classic yarn only\n // honours the `**/`-prefixed descriptor in a workspace and berry only the\n // bare one, so declare both.\n if (options.engine === 'postgres' && detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n '@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n };\n return packageJson;\n });\n }\n\n // The prisma CLI and tsx run migration/seed scripts from the root.\n addDependenciesToPackageJson(tree, {}, withVersions(['prisma', 'tsx']));\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","detectPackageManager","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","addDependenciesToPackageJson","addDockerScanTarget","nodeImageVersions","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedRdbScriptsGenerator","TS_VERSIONS","withVersions","tsProjectGenerator","getTsLibDetails","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","name","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","engine","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","patterns","waitForDbScript","scriptsDir","relativePathToRoot","root","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","project","trivyTargetName","dockerTargetName","imageTags","projectName","projectRoot","adminUser","createDbUserBundleDir","framework","packageJson","resolutions","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,4BAA4B,QAAQ,8BAA2B;AACxE,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,wBAAqB;AAC5E,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,OAAO,QAAQ,+BAA4B;AACpD,SAASC,SAAS,EAAEC,SAAS,EAAEC,WAAW,QAAQ,uBAAoB;AACtE,SAASC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