@aws/nx-plugin 1.0.0-rc.31 → 1.0.0-rc.33

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.
Files changed (198) hide show
  1. package/LICENSE-THIRD-PARTY +72 -70
  2. package/package.json +5 -5
  3. package/src/infra/app/__snapshots__/generator.spec.ts.snap +15 -15
  4. package/src/infra/app/files/app/src/main.ts.template +1 -1
  5. package/src/infra/app/files/app/src/stages/application-stage.ts.template +1 -1
  6. package/src/infra/app/generator.js +3 -1
  7. package/src/infra/app/generator.js.map +1 -1
  8. package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +64 -3
  9. package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +280 -0
  10. package/src/open-api/ts-client/files/client.gen.ts.template +37 -2
  11. package/src/open-api/ts-client/generator.js +5 -1
  12. package/src/open-api/ts-client/generator.js.map +1 -1
  13. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +2 -2
  14. package/src/open-api/ts-hooks/generator.js +5 -1
  15. package/src/open-api/ts-hooks/generator.js.map +1 -1
  16. package/src/open-api/utils/normalise.js +13 -6
  17. package/src/open-api/utils/normalise.js.map +1 -1
  18. package/src/open-api/utils/parser.js +12 -1
  19. package/src/open-api/utils/parser.js.map +1 -1
  20. package/src/open-api/utils/types.d.ts +4 -1
  21. package/src/open-api/utils/types.js.map +1 -1
  22. package/src/preset/__snapshots__/generator.spec.ts.snap +1 -1
  23. package/src/preset/generator.d.ts +1 -1
  24. package/src/preset/generator.js +5 -2
  25. package/src/preset/generator.js.map +1 -1
  26. package/src/preset/schema.d.js.map +1 -1
  27. package/src/preset/schema.d.ts +2 -0
  28. package/src/preset/schema.json +6 -0
  29. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +7 -7
  30. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
  31. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +89 -3
  32. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  33. package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +426 -18
  34. package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  35. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +91 -5
  36. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +283 -11
  37. package/src/smithy/ts/api/files/handler.ts.template +2 -2
  38. package/src/smithy/ts/api/files/local-server.ts.template +2 -2
  39. package/src/smithy/ts/api/files/operations/echo.ts.template +2 -2
  40. package/src/smithy/ts/api/files/service.ts.template +3 -3
  41. package/src/smithy/ts/api/generator.js +3 -1
  42. package/src/smithy/ts/api/generator.js.map +1 -1
  43. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +426 -18
  44. package/src/trpc/backend/files/src/client/index.ts.template +1 -1
  45. package/src/trpc/backend/files/src/handler.ts.template +1 -1
  46. package/src/trpc/backend/files/src/index.ts.template +5 -5
  47. package/src/trpc/backend/files/src/init.ts.template +1 -1
  48. package/src/trpc/backend/files/src/local-server.ts.template +1 -1
  49. package/src/trpc/backend/files/src/middleware/index.ts.template +7 -7
  50. package/src/trpc/backend/files/src/procedures/echo.ts.template +2 -2
  51. package/src/trpc/backend/files/src/router.ts.template +2 -2
  52. package/src/trpc/backend/files/src/schema/index.ts.template +1 -1
  53. package/src/trpc/backend/generator.js +3 -1
  54. package/src/trpc/backend/generator.js.map +1 -1
  55. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +89 -3
  56. package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +2 -2
  57. package/src/ts/agent/a2a-connection/generator.js +3 -1
  58. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  59. package/src/ts/agent/files/a2a/index.ts.template +1 -1
  60. package/src/ts/agent/files/ag-ui/index.ts.template +1 -1
  61. package/src/ts/agent/files/http/client.ts.template +2 -2
  62. package/src/ts/agent/files/http/index.ts.template +2 -2
  63. package/src/ts/agent/files/http/router.ts.template +3 -3
  64. package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +2 -2
  65. package/src/ts/agent/gateway-connection/generator.js +3 -1
  66. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  67. package/src/ts/agent/generator.js +5 -2
  68. package/src/ts/agent/generator.js.map +1 -1
  69. package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +2 -2
  70. package/src/ts/agent/mcp-connection/generator.js +3 -1
  71. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  72. package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +3 -2
  73. package/src/ts/astro-docs/generator.js +2 -0
  74. package/src/ts/astro-docs/generator.js.map +1 -1
  75. package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  76. package/src/ts/dynamodb/files/src/client.ts.template +5 -2
  77. package/src/ts/dynamodb/files/src/entities/example.ts.template +1 -1
  78. package/src/ts/dynamodb/files/src/entities/index.ts.template +1 -1
  79. package/src/ts/dynamodb/files/src/index.ts.template +2 -2
  80. package/src/ts/dynamodb/generator.js +3 -1
  81. package/src/ts/dynamodb/generator.js.map +1 -1
  82. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  83. package/src/ts/lib/generator.js +7 -1
  84. package/src/ts/lib/generator.js.map +1 -1
  85. package/src/ts/lib/ts-project-utils.js +19 -4
  86. package/src/ts/lib/ts-project-utils.js.map +1 -1
  87. package/src/ts/lib/types.d.ts +6 -0
  88. package/src/ts/lib/types.js.map +1 -1
  89. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +94 -31
  90. package/src/ts/mcp-server/generator.js +11 -22
  91. package/src/ts/mcp-server/generator.js.map +1 -1
  92. package/src/ts/nx-generator/files/local/generator.ts.template +2 -2
  93. package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +2 -2
  94. package/src/ts/nx-generator/generator.js +5 -2
  95. package/src/ts/nx-generator/generator.js.map +1 -1
  96. package/src/ts/nx-plugin/files/mcp-server/server.ts.template +5 -5
  97. package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +2 -2
  98. package/src/ts/nx-plugin/files/mcp-server/tools/general-guidance.ts.template +1 -1
  99. package/src/ts/nx-plugin/files/mcp-server/tools/generator-guide.ts.template +2 -2
  100. package/src/ts/nx-plugin/files/mcp-server/tools/list-generators.ts.template +2 -2
  101. package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +3 -3
  102. package/src/ts/nx-plugin/generator.js +3 -1
  103. package/src/ts/nx-plugin/generator.js.map +1 -1
  104. package/src/ts/nx-plugin/utils.js +7 -4
  105. package/src/ts/nx-plugin/utils.js.map +1 -1
  106. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -4
  107. package/src/ts/rdb/files/src/create-db-user-handler.ts.template +2 -2
  108. package/src/ts/rdb/files/src/index.ts.template +1 -1
  109. package/src/ts/rdb/files/src/migration-handler.ts.template +1 -1
  110. package/src/ts/rdb/files/src/prisma.ts.template +7 -4
  111. package/src/ts/rdb/generator.js +3 -1
  112. package/src/ts/rdb/generator.js.map +1 -1
  113. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +35 -35
  114. package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
  115. package/src/utils/agent-chat/agent-chat.js +3 -1
  116. package/src/utils/agent-chat/agent-chat.js.map +1 -1
  117. package/src/utils/agent-chat/files/a2a/chat.ts.template +1 -1
  118. package/src/utils/agent-chat/files/ag-ui/chat.ts.template +1 -1
  119. package/src/utils/agent-chat/files/http-py/chat.ts.template +2 -2
  120. package/src/utils/agent-chat/files/http-ts/chat.ts.template +1 -1
  121. package/src/utils/agent-connection/agent-connection.js +4 -1
  122. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  123. package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +2 -2
  124. package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +1 -1
  125. package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +2 -2
  126. package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +2 -2
  127. package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +1 -1
  128. package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +1 -1
  129. package/src/utils/agent-connection/files/core-strands/base/with-session-id-strands.ts.template +1 -1
  130. package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +1 -1
  131. package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +1 -1
  132. package/src/utils/agent-core-constructs/agent-core-constructs.js +10 -3
  133. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  134. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +3 -3
  135. package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +4 -4
  136. package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +1 -1
  137. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +27 -0
  138. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +60 -1
  139. package/src/utils/api-constructs/api-constructs.js +8 -2
  140. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  141. package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +8 -8
  142. package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +8 -8
  143. package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +3 -3
  144. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template +32 -20
  145. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account.ts.template +1 -1
  146. package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +4 -4
  147. package/src/utils/api-constructs/files/cdk/core/api/trpc/trpc-utils.ts.template +1 -1
  148. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
  149. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
  150. package/src/utils/ast.js +16 -0
  151. package/src/utils/ast.js.map +1 -1
  152. package/src/utils/commands.d.ts +1 -1
  153. package/src/utils/commands.js +4 -1
  154. package/src/utils/commands.js.map +1 -1
  155. package/src/utils/dynamodb-constructs/dynamodb-constructs.js +9 -2
  156. package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
  157. package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +3 -3
  158. package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +1 -1
  159. package/src/utils/files/common/constructs/src/core/index.ts.template +4 -4
  160. package/src/utils/files/common/constructs/src/index.ts.template +2 -2
  161. package/src/utils/files/common/infra-config/src/index.ts.template +3 -3
  162. package/src/utils/files/common/infra-config/src/resolve-stage.ts.template +2 -2
  163. package/src/utils/files/common/infra-config/src/stages.config.ts.template +1 -1
  164. package/src/utils/files/common/scripts/src/infra/infra-deploy.ts.template +1 -1
  165. package/src/utils/files/common/scripts/src/infra/infra-destroy.ts.template +1 -1
  166. package/src/utils/files/common/scripts/src/infra/stage-credentials/run.ts.template +3 -3
  167. package/src/utils/files/common/shadcn/src/index.ts.template +2 -2
  168. package/src/utils/function-constructs/files/cdk/app/lambda-functions/__nameKebabCase__.ts.template +1 -1
  169. package/src/utils/function-constructs/function-constructs.js +3 -1
  170. package/src/utils/function-constructs/function-constructs.js.map +1 -1
  171. package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +2 -2
  172. package/src/utils/identity-constructs/identity-constructs.js +5 -1
  173. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  174. package/src/utils/module-format.d.ts +28 -0
  175. package/src/utils/module-format.js +28 -0
  176. package/src/utils/module-format.js.map +1 -0
  177. package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +5 -5
  178. package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +1 -1
  179. package/src/utils/rdb-constructs/rdb-constructs.js +9 -2
  180. package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
  181. package/src/utils/shared-constructs.js +3 -1
  182. package/src/utils/shared-constructs.js.map +1 -1
  183. package/src/utils/shared-infra-config.js +3 -1
  184. package/src/utils/shared-infra-config.js.map +1 -1
  185. package/src/utils/shared-infra-scripts.js +3 -1
  186. package/src/utils/shared-infra-scripts.js.map +1 -1
  187. package/src/utils/shared-shadcn.js +3 -1
  188. package/src/utils/shared-shadcn.js.map +1 -1
  189. package/src/utils/test.d.ts +2 -0
  190. package/src/utils/test.js +7 -1
  191. package/src/utils/test.js.map +1 -1
  192. package/src/utils/versions.d.ts +61 -61
  193. package/src/utils/versions.js +59 -59
  194. package/src/utils/versions.js.map +1 -1
  195. package/src/utils/website-constructs/files/cdk/app/static-websites/__websiteNameKebabCase__.ts.template +2 -2
  196. package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +2 -2
  197. package/src/utils/website-constructs/website-constructs.js +9 -2
  198. package/src/utils/website-constructs/website-constructs.js.map +1 -1
@@ -1,6 +1,6 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { PackageManagerSchema } from '../schema.js';
3
- import { renderGeneratorInfo, listGenerators } from '../utils.js';
2
+ import { PackageManagerSchema } from '../schema<% if (esm) { %>.js<% } %>';
3
+ import { renderGeneratorInfo, listGenerators } from '../utils<% if (esm) { %>.js<% } %>';
4
4
 
5
5
  /**
6
6
  * Registers a tool which lists details about the available generators
@@ -9,20 +9,20 @@ export interface NxGeneratorInfo {
9
9
 
10
10
  export const getPackageName = (): string =>
11
11
  JSON.parse(
12
- fs.readFileSync(path.resolve(import.meta.dirname, '../../package.json'), 'utf-8'),
12
+ fs.readFileSync(path.resolve(<% if (esm) { %>import.meta.dirname<% } else { %>__dirname<% } %>, '../../package.json'), 'utf-8'),
13
13
  ).name;
14
14
 
15
15
  export const listGenerators = (): NxGeneratorInfo[] =>
16
16
  Object.entries(
17
17
  JSON.parse(
18
18
  fs.readFileSync(
19
- path.resolve(import.meta.dirname, '../../generators.json'),
19
+ path.resolve(<% if (esm) { %>import.meta.dirname<% } else { %>__dirname<% } %>, '../../generators.json'),
20
20
  'utf-8',
21
21
  ),
22
22
  ).generators,
23
23
  ).map(([id, info]: any) => ({
24
24
  id,
25
- resolvedPath: path.resolve(import.meta.dirname, '..', '..', info.factory, '..'),
25
+ resolvedPath: path.resolve(<% if (esm) { %>import.meta.dirname<% } else { %>__dirname<% } %>, '..', '..', info.factory, '..'),
26
26
  description: info.description,
27
27
  }));
28
28
 
@@ -5,6 +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 { esmVars } from "../../utils/module-format.js";
8
9
  import { addDependencyToTargetIfNotPresent, addGeneratorMetadata, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
9
10
  import { sortObjectKeys } from "../../utils/object.js";
10
11
  import tsProjectGenerator, { getTsLibDetails } from "../lib/generator.js";
@@ -85,7 +86,8 @@ export const tsNxPluginGenerator = async (tree, options)=>{
85
86
  tree.delete(joinPathFragments(mcpPath, 'resources', 'sample-guidance.ts'));
86
87
  // Add generator MCP server
87
88
  generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'mcp-server'), mcpPath, {
88
- name: fullyQualifiedName
89
+ name: fullyQualifiedName,
90
+ ...esmVars(tree)
89
91
  }, {
90
92
  overwriteStrategy: OverwriteStrategy.KeepExisting
91
93
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport tsMcpServerGenerator from '../mcp-server/generator';\nimport type { TsNxPluginGeneratorSchema } from './schema';\nimport { configureTsProjectAsNxPlugin } from './utils';\n\nexport const TS_NX_PLUGIN_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsNxPluginGenerator = async (\n tree: Tree,\n options: TsNxPluginGeneratorSchema,\n): Promise<GeneratorCallback> => {\n // Generate a TypeScript project as the base\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n await tsProjectGenerator(tree, {\n ...options,\n preferInstallDependencies: false,\n });\n\n // Configure the typescript project as an Nx Plugin\n configureTsProjectAsNxPlugin(tree, fullyQualifiedName);\n\n // Add a \"package\" target which creates a package which can be published to NPM\n const project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n project.targets = {\n ...project.targets,\n package: {\n executor: '@nx/js:tsc',\n outputs: ['{options.outputPath}'],\n options: {\n outputPath: `dist/{projectRoot}/package`,\n main: `{projectRoot}/src/index.ts`,\n tsConfig: `{projectRoot}/tsconfig.lib.json`,\n assets: [\n `{projectRoot}/*.md`,\n `{projectRoot}/LICENSE*`,\n `{projectRoot}/NOTICE`,\n {\n input: './{projectRoot}/src',\n glob: '**/!(*.ts)',\n output: './src',\n },\n {\n input: './{projectRoot}/src',\n glob: '**/*.d.ts',\n output: './src',\n },\n {\n input: './{projectRoot}',\n glob: 'generators.json',\n output: '.',\n },\n {\n input: './{projectRoot}',\n glob: 'executors.json',\n output: '.',\n },\n ],\n },\n },\n build: {\n ...project.targets?.build,\n },\n };\n // Append the package dependency without moving an existing entry, so re-runs\n // do not reorder the build dependencies.\n addDependencyToTargetIfNotPresent(project, 'build', 'package');\n // Sort targets so their order is stable regardless of insertion order.\n project.targets = sortObjectKeys(project.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, project);\n\n // Add an MCP Server\n await tsMcpServerGenerator(tree, {\n project: fullyQualifiedName,\n infra: 'none',\n iac: 'cdk', // not used\n preferInstallDependencies: false,\n });\n\n const mcpPath = joinPathFragments(project.sourceRoot, 'mcp-server');\n const mcpServerPath = joinPathFragments(mcpPath, 'server.ts');\n\n // Remove the sample server and tools\n tree.delete(mcpServerPath);\n tree.delete(joinPathFragments(mcpPath, 'tools', 'add.ts'));\n tree.delete(joinPathFragments(mcpPath, 'resources', 'sample-guidance.ts'));\n\n // Add generator MCP server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'mcp-server'),\n mcpPath,\n {\n name: fullyQualifiedName,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n addGeneratorMetadata(tree, project.name, TS_NX_PLUGIN_GENERATOR_INFO);\n\n await addGeneratorMetricsIfApplicable(tree, [TS_NX_PLUGIN_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsNxPluginGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","tsProjectGenerator","getTsLibDetails","tsMcpServerGenerator","configureTsProjectAsNxPlugin","TS_NX_PLUGIN_GENERATOR_INFO","filename","tsNxPluginGenerator","tree","options","fullyQualifiedName","dir","preferInstallDependencies","project","targets","package","executor","outputs","outputPath","main","tsConfig","assets","input","glob","output","build","infra","iac","mcpPath","sourceRoot","mcpServerPath","delete","dirname","name","overwriteStrategy","KeepExisting","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,OAAOC,sBAAsBC,eAAe,QAAQ,sBAAmB;AACvE,OAAOC,0BAA0B,6BAA0B;AAE3D,SAASC,4BAA4B,QAAQ,aAAU;AAEvD,OAAO,MAAMC,8BAA+CP,iBAC1D,YAAYQ,QAAQ,EACpB;AAEF,OAAO,MAAMC,sBAAsB,OACjCC,MACAC;IAEA,4CAA4C;IAC5C,MAAM,EAAEC,kBAAkB,EAAEC,GAAG,EAAE,GAAGT,gBAAgBM,MAAMC;IAC1D,MAAMR,mBAAmBO,MAAM;QAC7B,GAAGC,OAAO;QACVG,2BAA2B;IAC7B;IAEA,mDAAmD;IACnDR,6BAA6BI,MAAME;IAEnC,+EAA+E;IAC/E,MAAMG,UAAUd,oCAAoCS,MAAME;IAC1DG,QAAQC,OAAO,GAAG;QAChB,GAAGD,QAAQC,OAAO;QAClBC,SAAS;YACPC,UAAU;YACVC,SAAS;gBAAC;aAAuB;YACjCR,SAAS;gBACPS,YAAY,CAAC,0BAA0B,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,qBAAqBe;IAC3B,OAAO,IACLd,oBAAoBc,MAAMC,QAAQG,yBAAyB,EAAE;YAC3DwB,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe7B,oBAAoB"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport tsMcpServerGenerator from '../mcp-server/generator';\nimport type { TsNxPluginGeneratorSchema } from './schema';\nimport { configureTsProjectAsNxPlugin } from './utils';\n\nexport const TS_NX_PLUGIN_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsNxPluginGenerator = async (\n tree: Tree,\n options: TsNxPluginGeneratorSchema,\n): Promise<GeneratorCallback> => {\n // Generate a TypeScript project as the base\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n await tsProjectGenerator(tree, {\n ...options,\n preferInstallDependencies: false,\n });\n\n // Configure the typescript project as an Nx Plugin\n configureTsProjectAsNxPlugin(tree, fullyQualifiedName);\n\n // Add a \"package\" target which creates a package which can be published to NPM\n const project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n project.targets = {\n ...project.targets,\n package: {\n executor: '@nx/js:tsc',\n outputs: ['{options.outputPath}'],\n options: {\n outputPath: `dist/{projectRoot}/package`,\n main: `{projectRoot}/src/index.ts`,\n tsConfig: `{projectRoot}/tsconfig.lib.json`,\n assets: [\n `{projectRoot}/*.md`,\n `{projectRoot}/LICENSE*`,\n `{projectRoot}/NOTICE`,\n {\n input: './{projectRoot}/src',\n glob: '**/!(*.ts)',\n output: './src',\n },\n {\n input: './{projectRoot}/src',\n glob: '**/*.d.ts',\n output: './src',\n },\n {\n input: './{projectRoot}',\n glob: 'generators.json',\n output: '.',\n },\n {\n input: './{projectRoot}',\n glob: 'executors.json',\n output: '.',\n },\n ],\n },\n },\n build: {\n ...project.targets?.build,\n },\n };\n // Append the package dependency without moving an existing entry, so re-runs\n // do not reorder the build dependencies.\n addDependencyToTargetIfNotPresent(project, 'build', 'package');\n // Sort targets so their order is stable regardless of insertion order.\n project.targets = sortObjectKeys(project.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, project);\n\n // Add an MCP Server\n await tsMcpServerGenerator(tree, {\n project: fullyQualifiedName,\n infra: 'none',\n iac: 'cdk', // not used\n preferInstallDependencies: false,\n });\n\n const mcpPath = joinPathFragments(project.sourceRoot, 'mcp-server');\n const mcpServerPath = joinPathFragments(mcpPath, 'server.ts');\n\n // Remove the sample server and tools\n tree.delete(mcpServerPath);\n tree.delete(joinPathFragments(mcpPath, 'tools', 'add.ts'));\n tree.delete(joinPathFragments(mcpPath, 'resources', 'sample-guidance.ts'));\n\n // Add generator MCP server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'mcp-server'),\n mcpPath,\n {\n name: fullyQualifiedName,\n ...esmVars(tree),\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n addGeneratorMetadata(tree, project.name, TS_NX_PLUGIN_GENERATOR_INFO);\n\n await addGeneratorMetricsIfApplicable(tree, [TS_NX_PLUGIN_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsNxPluginGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","esmVars","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","tsProjectGenerator","getTsLibDetails","tsMcpServerGenerator","configureTsProjectAsNxPlugin","TS_NX_PLUGIN_GENERATOR_INFO","filename","tsNxPluginGenerator","tree","options","fullyQualifiedName","dir","preferInstallDependencies","project","targets","package","executor","outputs","outputPath","main","tsConfig","assets","input","glob","output","build","infra","iac","mcpPath","sourceRoot","mcpServerPath","delete","dirname","name","overwriteStrategy","KeepExisting","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,OAAO,QAAQ,+BAA4B;AACpD,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,OAAOC,sBAAsBC,eAAe,QAAQ,sBAAmB;AACvE,OAAOC,0BAA0B,6BAA0B;AAE3D,SAASC,4BAA4B,QAAQ,aAAU;AAEvD,OAAO,MAAMC,8BAA+CP,iBAC1D,YAAYQ,QAAQ,EACpB;AAEF,OAAO,MAAMC,sBAAsB,OACjCC,MACAC;IAEA,4CAA4C;IAC5C,MAAM,EAAEC,kBAAkB,EAAEC,GAAG,EAAE,GAAGT,gBAAgBM,MAAMC;IAC1D,MAAMR,mBAAmBO,MAAM;QAC7B,GAAGC,OAAO;QACVG,2BAA2B;IAC7B;IAEA,mDAAmD;IACnDR,6BAA6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YAAY2C,OAAO,EAAE,SAAS,eAChDJ,SACA;QACEK,MAAMvB;QACN,GAAGf,QAAQa,KAAK;IAClB,GACA;QAAE0B,mBAAmB5C,kBAAkB6C,YAAY;IAAC;IAGtDtC,qBAAqBW,MAAMK,QAAQoB,IAAI,EAAE5B;IAEzC,MAAMX,gCAAgCc,MAAM;QAACH;KAA4B;IAEzE,MAAMb,qBAAqBgB;IAC3B,OAAO,IACLf,oBAAoBe,MAAMC,QAAQG,yBAAyB,EAAE;YAC3DwB,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe7B,oBAAoB"}
@@ -5,6 +5,7 @@
5
5
  import PackageJson from "../../../package.json" with {
6
6
  type: 'json'
7
7
  };
8
+ import { isEsmWorkspace } from "../../utils/module-format.js";
8
9
  import { readProjectConfigurationUnqualified } from "../../utils/nx.js";
9
10
  import { withVersions } from "../../utils/versions.js";
10
11
  /**
@@ -30,11 +31,13 @@ import { withVersions } from "../../utils/versions.js";
30
31
  name: project.name
31
32
  });
32
33
  }
34
+ const esm = isEsmWorkspace(tree);
33
35
  updateJson(tree, pluginPackageJsonPath, (pkg)=>{
34
- // Mark the plugin as ESM so Nx loads its `.ts` generators as ES modules via
35
- // Node's native type stripping (the workspace root is also `type: module`).
36
- pkg.type ??= 'module';
37
- pkg.main ??= './src/index.js';
36
+ // Match the plugin's module system to the workspace. Nx loads `.ts`
37
+ // generators via Node's native type stripping, as ESM (workspace root is
38
+ // `type: module`) or CommonJS accordingly.
39
+ pkg.type ??= esm ? 'module' : 'commonjs';
40
+ pkg.main ??= esm ? './src/index.js' : './src/index';
38
41
  pkg.generators ??= './generators.json';
39
42
  return pkg;
40
43
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n joinPathFragments,\n readJson,\n type Tree,\n updateJson,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { readProjectConfigurationUnqualified } from '../../utils/nx';\nimport { withVersions } from '../../utils/versions';\n\n/**\n * Configures a TypeScript project as an Nx Plugin\n */\nexport const configureTsProjectAsNxPlugin = (\n tree: Tree,\n projectName: string,\n) => {\n const project = readProjectConfigurationUnqualified(tree, projectName);\n\n const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');\n if (!tree.exists(tsConfigPath)) {\n throw new Error(\n `Selected plugin project ${projectName} is not a TypeScript project`,\n );\n }\n\n // Create an empty generators.json if one dosn't exist\n const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');\n if (!tree.exists(generatorsJsonPath)) {\n writeJson(tree, generatorsJsonPath, {\n generators: {},\n });\n }\n\n // Create a package.json if one doesn't exist, and configure \"type\", \"main\"\n // and \"generators\"\n const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');\n if (!tree.exists(pluginPackageJsonPath)) {\n writeJson(tree, pluginPackageJsonPath, {\n name: project.name,\n });\n }\n updateJson(tree, pluginPackageJsonPath, (pkg) => {\n // Mark the plugin as ESM so Nx loads its `.ts` generators as ES modules via\n // Node's native type stripping (the workspace root is also `type: module`).\n pkg.type ??= 'module';\n pkg.main ??= './src/index.js';\n pkg.generators ??= './generators.json';\n return pkg;\n });\n\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n const isNxPluginForAws = rootPackageJson?.name === '@aws/nx-plugin-source';\n\n if (!isNxPluginForAws) {\n // Add the required dependencies to the root package.json, and project's package.json\n const deps = {\n ...withVersions(['@nx/devkit']),\n // Include dependency on @aws/nx-plugin\n [PackageJson.name]: `^${PackageJson.version}`,\n };\n // Generated workspaces are `\"type\": \"module\"`, so Nx loads the plugin's\n // `.ts` generators as ESM via Node's native type stripping — no swc/ts-node\n // transpiler is required.\n addDependenciesToPackageJson(tree, {}, deps);\n addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);\n }\n};\n"],"names":["addDependenciesToPackageJson","joinPathFragments","readJson","updateJson","writeJson","PackageJson","type","readProjectConfigurationUnqualified","withVersions","configureTsProjectAsNxPlugin","tree","projectName","project","tsConfigPath","root","exists","Error","generatorsJsonPath","generators","pluginPackageJsonPath","name","pkg","main","rootPackageJson","undefined","isNxPluginForAws","deps","version"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,iBAAiB,EACjBC,QAAQ,EAERC,UAAU,EACVC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,mCAAmC,QAAQ,oBAAiB;AACrE,SAASC,YAAY,QAAQ,0BAAuB;AAEpD;;CAEC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC,MACAC;IAEA,MAAMC,UAAUL,oCAAoCG,MAAMC;IAE1D,MAAME,eAAeZ,kBAAkBW,QAAQE,IAAI,EAAE;IACrD,IAAI,CAACJ,KAAKK,MAAM,CAACF,eAAe;QAC9B,MAAM,IAAIG,MACR,CAAC,wBAAwB,EAAEL,YAAY,4BAA4B,CAAC;IAExE;IAEA,sDAAsD;IACtD,MAAMM,qBAAqBhB,kBAAkBW,QAAQE,IAAI,EAAE;IAC3D,IAAI,CAACJ,KAAKK,MAAM,CAACE,qBAAqB;QACpCb,UAAUM,MAAMO,oBAAoB;YAClCC,YAAY,CAAC;QACf;IACF;IAEA,2EAA2E;IAC3E,mBAAmB;IACnB,MAAMC,wBAAwBlB,kBAAkBW,QAAQE,IAAI,EAAE;IAC9D,IAAI,CAACJ,KAAKK,MAAM,CAACI,wBAAwB;QACvCf,UAAUM,MAAMS,uBAAuB;YACrCC,MAAMR,QAAQQ,IAAI;QACpB;IACF;IACAjB,WAAWO,MAAMS,uBAAuB,CAACE;QACvC,4EAA4E;QAC5E,4EAA4E;QAC5EA,IAAIf,IAAI,KAAK;QACbe,IAAIC,IAAI,KAAK;QACbD,IAAIH,UAAU,KAAK;QACnB,OAAOG;IACT;IAEA,MAAME,kBAAkBb,KAAKK,MAAM,CAAC,kBAChCb,SAASQ,MAAM,kBACfc;IACJ,MAAMC,mBAAmBF,iBAAiBH,SAAS;IAEnD,IAAI,CAACK,kBAAkB;QACrB,qFAAqF;QACrF,MAAMC,OAAO;YACX,GAAGlB,aAAa;gBAAC;aAAa,CAAC;YAC/B,uCAAuC;YACvC,CAACH,YAAYe,IAAI,CAAC,EAAE,CAAC,CAAC,EAAEf,YAAYsB,OAAO,EAAE;QAC/C;QACA,wEAAwE;QACxE,4EAA4E;QAC5E,0BAA0B;QAC1B3B,6BAA6BU,MAAM,CAAC,GAAGgB;QACvC1B,6BAA6BU,MAAMgB,MAAM,CAAC,GAAGP;IAC/C;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n joinPathFragments,\n readJson,\n type Tree,\n updateJson,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { readProjectConfigurationUnqualified } from '../../utils/nx';\nimport { withVersions } from '../../utils/versions';\n\n/**\n * Configures a TypeScript project as an Nx Plugin\n */\nexport const configureTsProjectAsNxPlugin = (\n tree: Tree,\n projectName: string,\n) => {\n const project = readProjectConfigurationUnqualified(tree, projectName);\n\n const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');\n if (!tree.exists(tsConfigPath)) {\n throw new Error(\n `Selected plugin project ${projectName} is not a TypeScript project`,\n );\n }\n\n // Create an empty generators.json if one dosn't exist\n const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');\n if (!tree.exists(generatorsJsonPath)) {\n writeJson(tree, generatorsJsonPath, {\n generators: {},\n });\n }\n\n // Create a package.json if one doesn't exist, and configure \"type\", \"main\"\n // and \"generators\"\n const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');\n if (!tree.exists(pluginPackageJsonPath)) {\n writeJson(tree, pluginPackageJsonPath, {\n name: project.name,\n });\n }\n const esm = isEsmWorkspace(tree);\n updateJson(tree, pluginPackageJsonPath, (pkg) => {\n // Match the plugin's module system to the workspace. Nx loads `.ts`\n // generators via Node's native type stripping, as ESM (workspace root is\n // `type: module`) or CommonJS accordingly.\n pkg.type ??= esm ? 'module' : 'commonjs';\n pkg.main ??= esm ? './src/index.js' : './src/index';\n pkg.generators ??= './generators.json';\n return pkg;\n });\n\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n const isNxPluginForAws = rootPackageJson?.name === '@aws/nx-plugin-source';\n\n if (!isNxPluginForAws) {\n // Add the required dependencies to the root package.json, and project's package.json\n const deps = {\n ...withVersions(['@nx/devkit']),\n // Include dependency on @aws/nx-plugin\n [PackageJson.name]: `^${PackageJson.version}`,\n };\n // Generated workspaces are `\"type\": \"module\"`, so Nx loads the plugin's\n // `.ts` generators as ESM via Node's native type stripping — no swc/ts-node\n // transpiler is required.\n addDependenciesToPackageJson(tree, {}, deps);\n addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);\n }\n};\n"],"names":["addDependenciesToPackageJson","joinPathFragments","readJson","updateJson","writeJson","PackageJson","type","isEsmWorkspace","readProjectConfigurationUnqualified","withVersions","configureTsProjectAsNxPlugin","tree","projectName","project","tsConfigPath","root","exists","Error","generatorsJsonPath","generators","pluginPackageJsonPath","name","esm","pkg","main","rootPackageJson","undefined","isNxPluginForAws","deps","version"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,iBAAiB,EACjBC,QAAQ,EAERC,UAAU,EACVC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,cAAc,QAAQ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,EAAEhB,YAAYwB,OAAO,EAAE;QAC/C;QACA,wEAAwE;QACxE,4EAA4E;QAC5E,0BAA0B;QAC1B7B,6BAA6BW,MAAM,CAAC,GAAGiB;QACvC5B,6BAA6BW,MAAMiB,MAAM,CAAC,GAAGR;IAC/C;AACF,EAAE"}
@@ -792,7 +792,7 @@ terraform {
792
792
  required_providers {
793
793
  aws = {
794
794
  source = "hashicorp/aws"
795
- version = "6.52.0"
795
+ version = "6.54.0"
796
796
  }
797
797
  null = {
798
798
  source = "hashicorp/null"
@@ -1554,7 +1554,7 @@ exports[`ts#rdb generator > should generate terraform modules when iac is Terraf
1554
1554
  }
1555
1555
  aws = {
1556
1556
  source = "hashicorp/aws"
1557
- version = "6.52.0"
1557
+ version = "6.54.0"
1558
1558
  }
1559
1559
  null = {
1560
1560
  source = "hashicorp/null"
@@ -2281,7 +2281,7 @@ terraform {
2281
2281
  required_providers {
2282
2282
  aws = {
2283
2283
  source = "hashicorp/aws"
2284
- version = "6.52.0"
2284
+ version = "6.54.0"
2285
2285
  }
2286
2286
  null = {
2287
2287
  source = "hashicorp/null"
@@ -3043,7 +3043,7 @@ exports[`ts#rdb generator > should generate terraform modules with MySQL engine
3043
3043
  }
3044
3044
  aws = {
3045
3045
  source = "hashicorp/aws"
3046
- version = "6.52.0"
3046
+ version = "6.54.0"
3047
3047
  }
3048
3048
  null = {
3049
3049
  source = "hashicorp/null"
@@ -2,10 +2,10 @@ import type { CloudFormationCustomResourceEvent } from 'aws-lambda';
2
2
  import { randomBytes } from 'node:crypto';
3
3
  <%_ if (engine === 'mysql') { _%>
4
4
  import { createPool, type PoolConnection } from 'mariadb';
5
- import { getDatabaseSecret, withConnectionRetry } from './utils.js';
5
+ import { getDatabaseSecret, withConnectionRetry } from './utils<% if (esm) { %>.js<% } %>';
6
6
  <%_ } else { _%>
7
7
  import { Client, escapeIdentifier } from 'pg';
8
- import { getDatabaseSecret, withConnectionRetry } from './utils.js';
8
+ import { getDatabaseSecret, withConnectionRetry } from './utils<% if (esm) { %>.js<% } %>';
9
9
  <%_ } _%>
10
10
 
11
11
  type OnEventResult = {
@@ -1 +1 @@
1
- export { getPrisma } from './prisma.js';
1
+ export { getPrisma } from './prisma<% if (esm) { %>.js<% } %>';
@@ -1,6 +1,6 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import { promisify } from 'node:util';
3
- import { getDatabaseSecret, withConnectionRetry } from './utils.js';
3
+ import { getDatabaseSecret, withConnectionRetry } from './utils<% if (esm) { %>.js<% } %>';
4
4
 
5
5
  const buildDatabaseUrl = async (): Promise<string> => {
6
6
  const { host, port, dbname, username, password } = await getDatabaseSecret();
@@ -1,18 +1,21 @@
1
1
  import { <%= prismaAdapterClassName %> } from '<%= prismaAdapterPackage %>';
2
2
  import { Signer } from '@aws-sdk/rds-signer';
3
- import { Prisma, PrismaClient } from '../generated/prisma/client.js';
3
+ import { Prisma, PrismaClient } from '../generated/prisma/client<% if (esm) { %>.js<% } %>';
4
4
  <%_ if (engine === 'postgres') { _%>
5
5
  import { Pool } from 'pg';
6
6
  <%_ } _%>
7
7
  import { readFileSync } from 'fs';
8
- import { join, dirname } from 'path';
8
+ import { join<% if (esm) { %>, dirname<% } %> } from 'path';
9
+ <%_ if (esm) { _%>
9
10
  import { fileURLToPath } from 'url';
10
- import { getDatabaseConfig } from './utils.js';
11
+ <%_ } _%>
12
+ import { getDatabaseConfig } from './utils<% if (esm) { %>.js<% } %>';
11
13
 
12
14
  // Generated: must match runtimeConfigKey in config.json
13
15
  const runtimeConfigKey = '<%= runtimeConfigKey %>';
14
-
16
+ <% if (esm) { %>
15
17
  const __dirname = dirname(fileURLToPath(import.meta.url));
18
+ <%_ } _%>
16
19
  // config.json is only present in local dev (not included in the deployed bundle); guard with LOCAL_DEV check
17
20
  const localDev = () =>
18
21
  JSON.parse(readFileSync(join(__dirname, '../config.json'), 'utf-8')).localDev;
@@ -11,6 +11,7 @@ import { updateGitIgnore } from "../../utils/git.js";
11
11
  import { resolveIac } from "../../utils/iac.js";
12
12
  import { installDependencies } from "../../utils/install.js";
13
13
  import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
14
+ import { esmVars } from "../../utils/module-format.js";
14
15
  import { kebabCase, snakeCase, toClassName } from "../../utils/names.js";
15
16
  import { getNpmScope, toScopeAlias } from "../../utils/npm-scope.js";
16
17
  import { addDependencyToTargetIfNotPresent, addGeneratorMetadata, getGeneratorInfo } from "../../utils/nx.js";
@@ -78,7 +79,8 @@ export const tsRdbGenerator = async (tree, options)=>{
78
79
  localDbPassword,
79
80
  containerEngine,
80
81
  containerName,
81
- dockerImage
82
+ dockerImage,
83
+ ...esmVars(tree)
82
84
  };
83
85
  generateFiles(tree, joinPathFragments(import.meta.dirname, 'files'), dir, templateOptions);
84
86
  updateGitIgnore(tree, dir, (patterns)=>[
@@ -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 addDependenciesToPackageJson,\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 { 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 { kebabCase, snakeCase, toClassName } from '../../utils/names';\nimport { getNpmScope, toScopeAlias } 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: toScopeAlias(fullyQualifiedName),\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\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 };\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 dockerImageTag = `${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 ${dockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\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: toScopeAlias(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 dockerImageTag,\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 'prisma',\n 'tsx',\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n );\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","addDependenciesToPackageJson","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","snakeCase","toClassName","getNpmScope","toScopeAlias","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","dockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","projectName","projectRoot","adminUser","createDbUserBundleDir","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,4BAA4B,EAE5BC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7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,KAAK,KAAK,QAAQ;QAC5B,MAAMoB,MAAM,MAAMxF,WAAW0B,MAAMC,QAAQ6D,GAAG;QAC9C,MAAMzE,0BAA0BW,MAAM;YAAE8D;QAAI;QAC5C,MAAM1E,YAAYY,MAAM;YACtB8D;YACAE,aAAaxD;YACbyD,aAAaxD;YACbL;YACAF;YACAwB,sBAAsB7C,aAAa2B;YACnCF;YACA4D,WAAW7D;YACXa,QAAQjB,QAAQiB,MAAM;YACtBsB;YACA2B,uBAAuBtG,kBACrB,QACAmD,cAAcsB,IAAI,EAClB,UACA;YAEFG;YACAlC;QACF;IACF;IAEA5C,6BACEqC,MACAN,aAAa;QACX;QACA;QACA;QACA;QACA;WACIO,QAAQiB,MAAM,KAAK,UAClB;YAAC;YAA2B;SAAU,GACtC;YAAC;YAAsB;SAAK;KAClC,GACDxB,aAAa;QACX;QACA;QACA;WACIO,QAAQiB,MAAM,KAAK,UAClB,EAAE,GACF;YAAC;SAAY;KACnB;IAGHhC,8BAA8Bc,MAAM;QAClC,mBAAmB;QACnB6B,QAAQ;IACV;IAEA,MAAMrD,gCAAgCwB,MAAM;QAACH;KAAsB;IAEnE,MAAM1B,qBAAqB6B;IAC3B,OAAO,IACLzB,oBAAoByB,MAAMC,QAAQY,yBAAyB,EAAE;YAC3DuD,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAerE,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 addDependenciesToPackageJson,\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 { 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, toScopeAlias } 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: toScopeAlias(fullyQualifiedName),\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\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 dockerImageTag = `${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 ${dockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\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: toScopeAlias(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 dockerImageTag,\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 'prisma',\n 'tsx',\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n );\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","addDependenciesToPackageJson","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","toScopeAlias","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","dockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","projectName","projectRoot","adminUser","createDb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AAyB,EAAE;YAC3DuD,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAerE,eAAe"}
@@ -131,7 +131,7 @@ exports[`react-website generator > TailwindCSS integration > terraform iac > sho
131
131
  required_providers {
132
132
  aws = {
133
133
  source = "hashicorp/aws"
134
- version = "6.52.0"
134
+ version = "6.54.0"
135
135
  configuration_aliases = [aws.us_east_1]
136
136
  }
137
137
  random = {
@@ -696,7 +696,7 @@ resource "null_resource" "upload_website_files" {
696
696
  provisioner "local-exec" {
697
697
  command = <<-EOT
698
698
  cd "$ROOT_PATH"
699
- uv run --with boto3==1.43.37 python3 -c "
699
+ uv run --with boto3==1.43.46 python3 -c "
700
700
  import os
701
701
  import sys
702
702
  import boto3
@@ -819,7 +819,7 @@ resource "null_resource" "cloudfront_invalidation" {
819
819
 
820
820
  provisioner "local-exec" {
821
821
  command = <<-EOT
822
- uv run --with boto3==1.43.37 python3 -c "
822
+ uv run --with boto3==1.43.46 python3 -c "
823
823
  import boto3
824
824
  import os
825
825
  import sys
@@ -905,7 +905,7 @@ output "waf_web_acl_arn" {
905
905
  required_providers {
906
906
  aws = {
907
907
  source = "hashicorp/aws"
908
- version = "6.52.0"
908
+ version = "6.54.0"
909
909
  configuration_aliases = [aws.us_east_1]
910
910
  }
911
911
  }
@@ -1113,14 +1113,14 @@ exports[`react-website generator > Tanstack router integration > should generate
1113
1113
  "{
1114
1114
  "name": "@proj/source",
1115
1115
  "dependencies": {
1116
- "@cloudscape-design/board-components": "3.0.197",
1117
- "@cloudscape-design/components": "3.0.1320",
1118
- "@cloudscape-design/global-styles": "1.0.61",
1119
- "aws-cdk-lib": "2.260.0",
1116
+ "@cloudscape-design/board-components": "3.0.200",
1117
+ "@cloudscape-design/components": "3.0.1324",
1118
+ "@cloudscape-design/global-styles": "1.0.62",
1119
+ "aws-cdk-lib": "2.261.0",
1120
1120
  "constructs": "10.6.0",
1121
1121
  "react": "19.2.7",
1122
1122
  "react-dom": "19.2.7",
1123
- "tailwindcss": "4.2.2"
1123
+ "tailwindcss": "4.3.2"
1124
1124
  },
1125
1125
  "devDependencies": {
1126
1126
  "@nx/js": "23.0.1",
@@ -1129,20 +1129,20 @@ exports[`react-website generator > Tanstack router integration > should generate
1129
1129
  "@nx/vitest": "23.0.1",
1130
1130
  "@nx/web": "23.0.1",
1131
1131
  "@swc/helpers": "~0.5.18",
1132
- "@tailwindcss/vite": "4.2.2",
1132
+ "@tailwindcss/vite": "4.3.2",
1133
1133
  "@testing-library/dom": "10.4.0",
1134
1134
  "@testing-library/react": "16.3.0",
1135
- "@types/node": "25.9.4",
1135
+ "@types/node": "26.1.1",
1136
1136
  "@types/react": "^19.0.0",
1137
1137
  "@types/react-dom": "^19.0.0",
1138
1138
  "@vitejs/plugin-react": "^6.0.0",
1139
- "@vitest/coverage-v8": "4.1.9",
1140
- "@vitest/ui": "4.1.9",
1139
+ "@vitest/coverage-v8": "4.1.10",
1140
+ "@vitest/ui": "4.1.10",
1141
1141
  "jiti": "2.4.2",
1142
1142
  "jsdom": "^27.1.0",
1143
1143
  "typescript": "~5.9.2",
1144
- "vite": "8.1.0",
1145
- "vitest": "4.1.9"
1144
+ "vite": "8.1.4",
1145
+ "vitest": "4.1.10"
1146
1146
  },
1147
1147
  "type": "module"
1148
1148
  }
@@ -2684,15 +2684,15 @@ exports[`react-website generator > Tanstack router integration > should generate
2684
2684
  "{
2685
2685
  "name": "@proj/source",
2686
2686
  "dependencies": {
2687
- "@cloudscape-design/board-components": "3.0.197",
2688
- "@cloudscape-design/components": "3.0.1320",
2689
- "@cloudscape-design/global-styles": "1.0.61",
2690
- "@tanstack/react-router": "1.170.16",
2691
- "aws-cdk-lib": "2.260.0",
2687
+ "@cloudscape-design/board-components": "3.0.200",
2688
+ "@cloudscape-design/components": "3.0.1324",
2689
+ "@cloudscape-design/global-styles": "1.0.62",
2690
+ "@tanstack/react-router": "1.170.17",
2691
+ "aws-cdk-lib": "2.261.0",
2692
2692
  "constructs": "10.6.0",
2693
2693
  "react": "19.2.7",
2694
2694
  "react-dom": "19.2.7",
2695
- "tailwindcss": "4.2.2"
2695
+ "tailwindcss": "4.3.2"
2696
2696
  },
2697
2697
  "devDependencies": {
2698
2698
  "@nx/js": "23.0.1",
@@ -2701,24 +2701,24 @@ exports[`react-website generator > Tanstack router integration > should generate
2701
2701
  "@nx/vitest": "23.0.1",
2702
2702
  "@nx/web": "23.0.1",
2703
2703
  "@swc/helpers": "~0.5.18",
2704
- "@tailwindcss/vite": "4.2.2",
2705
- "@tanstack/router-generator": "1.167.17",
2706
- "@tanstack/router-plugin": "1.168.18",
2704
+ "@tailwindcss/vite": "4.3.2",
2705
+ "@tanstack/router-generator": "1.167.18",
2706
+ "@tanstack/router-plugin": "1.168.19",
2707
2707
  "@tanstack/router-utils": "1.162.2",
2708
2708
  "@tanstack/virtual-file-routes": "1.162.0",
2709
2709
  "@testing-library/dom": "10.4.0",
2710
2710
  "@testing-library/react": "16.3.0",
2711
- "@types/node": "25.9.4",
2711
+ "@types/node": "26.1.1",
2712
2712
  "@types/react": "^19.0.0",
2713
2713
  "@types/react-dom": "^19.0.0",
2714
2714
  "@vitejs/plugin-react": "^6.0.0",
2715
- "@vitest/coverage-v8": "4.1.9",
2716
- "@vitest/ui": "4.1.9",
2715
+ "@vitest/coverage-v8": "4.1.10",
2716
+ "@vitest/ui": "4.1.10",
2717
2717
  "jiti": "2.4.2",
2718
2718
  "jsdom": "^27.1.0",
2719
2719
  "typescript": "~5.9.2",
2720
- "vite": "8.1.0",
2721
- "vitest": "4.1.9"
2720
+ "vite": "8.1.4",
2721
+ "vitest": "4.1.10"
2722
2722
  },
2723
2723
  "type": "module"
2724
2724
  }
@@ -4990,15 +4990,15 @@ root &&
4990
4990
 
4991
4991
  exports[`react-website generator > should handle npm scope prefix correctly > scoped-dependencies 1`] = `
4992
4992
  {
4993
- "@cloudscape-design/board-components": "3.0.197",
4994
- "@cloudscape-design/components": "3.0.1320",
4995
- "@cloudscape-design/global-styles": "1.0.61",
4996
- "@tanstack/react-router": "1.170.16",
4997
- "aws-cdk-lib": "2.260.0",
4993
+ "@cloudscape-design/board-components": "3.0.200",
4994
+ "@cloudscape-design/components": "3.0.1324",
4995
+ "@cloudscape-design/global-styles": "1.0.62",
4996
+ "@tanstack/react-router": "1.170.17",
4997
+ "aws-cdk-lib": "2.261.0",
4998
4998
  "constructs": "10.6.0",
4999
4999
  "react": "19.2.7",
5000
5000
  "react-dom": "19.2.7",
5001
- "tailwindcss": "4.2.2",
5001
+ "tailwindcss": "4.3.2",
5002
5002
  }
5003
5003
  `;
5004
5004
 
@@ -6,7 +6,7 @@ exports[`cognito-auth generator terraform iac > should generate terraform files
6
6
  required_providers {
7
7
  aws = {
8
8
  source = "hashicorp/aws"
9
- version = "6.52.0"
9
+ version = "6.54.0"
10
10
  }
11
11
  }
12
12
  }
@@ -63,7 +63,7 @@ resource "null_resource" "add_callback_url" {
63
63
 
64
64
  provisioner "local-exec" {
65
65
  command = <<-EOT
66
- uv run --with boto3==1.43.37 python -c "
66
+ uv run --with boto3==1.43.46 python -c "
67
67
  import boto3
68
68
  import os
69
69
  import sys
@@ -2,6 +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 { generateFiles, joinPathFragments, OverwriteStrategy } from "@nx/devkit";
5
+ import { esmVars } from "../module-format.js";
5
6
  /**
6
7
  * Emit the chat CLI scripts for an agent. Every protocol gets a small
7
8
  * `chat.ts` that connects to the local `dev` server by default, and
@@ -12,7 +13,8 @@
12
13
  const templateContext = {
13
14
  agentNameClassName: options.agentNameClassName,
14
15
  auth: options.auth,
15
- relativeAgentImport: options.relativeAgentImport ?? ''
16
+ relativeAgentImport: options.relativeAgentImport ?? '',
17
+ ...esmVars(tree)
16
18
  };
17
19
  // Shared remote-resolution + auth helper, used by every protocol.
18
20
  generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'common'), options.scriptsDir, templateContext, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/agent-chat/agent-chat.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Tree } from '@nx/devkit';\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n} from '@nx/devkit';\n\nexport type AgentChatProtocol = 'http' | 'a2a' | 'ag-ui';\nexport type AgentChatAuth = 'iam' | 'cognito';\n\nexport interface AddAgentChatScriptsOptions {\n /** Absolute (tree) directory to emit the chat scripts into. */\n scriptsDir: string;\n protocol: AgentChatProtocol;\n /** Agent server language. Only affects the HTTP chat adapter. */\n language: 'ts' | 'py';\n /** Construct class name — the runtime-config key for the deployed agent. */\n agentNameClassName: string;\n /** Authentication used by the deployed agent. */\n auth: AgentChatAuth;\n /**\n * Import path to the agent's `client.ts` (TypeScript HTTP agents only),\n * relative to the chat script.\n */\n relativeAgentImport?: string;\n}\n\n/**\n * Emit the chat CLI scripts for an agent. Every protocol gets a small\n * `chat.ts` that connects to the local `dev` server by default, and\n * to the deployed agent on Bedrock AgentCore (resolved from runtime config)\n * when `RUNTIME_CONFIG_APP_ID` is set. The shared `agentcore.ts` helper\n * handles ARN resolution and request authentication.\n */\nexport const addAgentChatScripts = (\n tree: Tree,\n options: AddAgentChatScriptsOptions,\n): void => {\n const templateContext = {\n agentNameClassName: options.agentNameClassName,\n auth: options.auth,\n relativeAgentImport: options.relativeAgentImport ?? '',\n };\n\n // Shared remote-resolution + auth helper, used by every protocol.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n options.scriptsDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Protocol-specific chat adapter. HTTP differs by server language; A2A and\n // AG-UI speak standard protocols so the same script serves both languages.\n const protocolDir =\n options.protocol === 'http' ? `http-${options.language}` : options.protocol;\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', protocolDir),\n options.scriptsDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","addAgentChatScripts","tree","options","templateContext","agentNameClassName","auth","relativeAgentImport","dirname","scriptsDir","overwriteStrategy","KeepExisting","protocolDir","protocol","language"],"mappings":"AAAA;;;CAGC,GAGD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QACZ,aAAa;AAsBpB;;;;;;CAMC,GACD,OAAO,MAAMC,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,kBAAkB;QACtBC,oBAAoBF,QAAQE,kBAAkB;QAC9CC,MAAMH,QAAQG,IAAI;QAClBC,qBAAqBJ,QAAQI,mBAAmB,IAAI;IACtD;IAEA,kEAAkE;IAClET,cACEI,MACAH,kBAAkB,YAAYS,OAAO,EAAE,SAAS,WAChDL,QAAQM,UAAU,EAClBL,iBACA;QAAEM,mBAAmBV,kBAAkBW,YAAY;IAAC;IAGtD,2EAA2E;IAC3E,2EAA2E;IAC3E,MAAMC,cACJT,QAAQU,QAAQ,KAAK,SAAS,CAAC,KAAK,EAAEV,QAAQW,QAAQ,EAAE,GAAGX,QAAQU,QAAQ;IAC7Ef,cACEI,MACAH,kBAAkB,YAAYS,OAAO,EAAE,SAASI,cAChDT,QAAQM,UAAU,EAClBL,iBACA;QAAEM,mBAAmBV,kBAAkBW,YAAY;IAAC;AAExD,EAAE"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/agent-chat/agent-chat.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Tree } from '@nx/devkit';\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n} from '@nx/devkit';\nimport { esmVars } from '../module-format';\n\nexport type AgentChatProtocol = 'http' | 'a2a' | 'ag-ui';\nexport type AgentChatAuth = 'iam' | 'cognito';\n\nexport interface AddAgentChatScriptsOptions {\n /** Absolute (tree) directory to emit the chat scripts into. */\n scriptsDir: string;\n protocol: AgentChatProtocol;\n /** Agent server language. Only affects the HTTP chat adapter. */\n language: 'ts' | 'py';\n /** Construct class name — the runtime-config key for the deployed agent. */\n agentNameClassName: string;\n /** Authentication used by the deployed agent. */\n auth: AgentChatAuth;\n /**\n * Import path to the agent's `client.ts` (TypeScript HTTP agents only),\n * relative to the chat script.\n */\n relativeAgentImport?: string;\n}\n\n/**\n * Emit the chat CLI scripts for an agent. Every protocol gets a small\n * `chat.ts` that connects to the local `dev` server by default, and\n * to the deployed agent on Bedrock AgentCore (resolved from runtime config)\n * when `RUNTIME_CONFIG_APP_ID` is set. The shared `agentcore.ts` helper\n * handles ARN resolution and request authentication.\n */\nexport const addAgentChatScripts = (\n tree: Tree,\n options: AddAgentChatScriptsOptions,\n): void => {\n const templateContext = {\n agentNameClassName: options.agentNameClassName,\n auth: options.auth,\n relativeAgentImport: options.relativeAgentImport ?? '',\n ...esmVars(tree),\n };\n\n // Shared remote-resolution + auth helper, used by every protocol.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n options.scriptsDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Protocol-specific chat adapter. HTTP differs by server language; A2A and\n // AG-UI speak standard protocols so the same script serves both languages.\n const protocolDir =\n options.protocol === 'http' ? `http-${options.language}` : options.protocol;\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', protocolDir),\n options.scriptsDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","esmVars","addAgentChatScripts","tree","options","templateContext","agentNameClassName","auth","relativeAgentImport","dirname","scriptsDir","overwriteStrategy","KeepExisting","protocolDir","protocol","language"],"mappings":"AAAA;;;CAGC,GAGD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QACZ,aAAa;AACpB,SAASC,OAAO,QAAQ,sBAAmB;AAsB3C;;;;;;CAMC,GACD,OAAO,MAAMC,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,kBAAkB;QACtBC,oBAAoBF,QAAQE,kBAAkB;QAC9CC,MAAMH,QAAQG,IAAI;QAClBC,qBAAqBJ,QAAQI,mBAAmB,IAAI;QACpD,GAAGP,QAAQE,KAAK;IAClB;IAEA,kEAAkE;IAClEL,cACEK,MACAJ,kBAAkB,YAAYU,OAAO,EAAE,SAAS,WAChDL,QAAQM,UAAU,EAClBL,iBACA;QAAEM,mBAAmBX,kBAAkBY,YAAY;IAAC;IAGtD,2EAA2E;IAC3E,2EAA2E;IAC3E,MAAMC,cACJT,QAAQU,QAAQ,KAAK,SAAS,CAAC,KAAK,EAAEV,QAAQW,QAAQ,EAAE,GAAGX,QAAQU,QAAQ;IAC7EhB,cACEK,MACAJ,kBAAkB,YAAYU,OAAO,EAAE,SAASI,cAChDT,QAAQM,UAAU,EAClBL,iBACA;QAAEM,mBAAmBX,kBAAkBY,YAAY;IAAC;AAExD,EAAE"}
@@ -7,7 +7,7 @@ import {
7
7
  JsonRpcTransportFactory,
8
8
  } from '@a2a-js/sdk/client';
9
9
  import { A2AChatAdapter, chatLoop } from 'agent-chat-cli';
10
- import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
10
+ import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore<% if (esm) { %>.js<% } %>';
11
11
 
12
12
  const remote = await resolveRemoteAgent();
13
13
 
@@ -1,7 +1,7 @@
1
1
  // Chat CLI for <%- agentNameClassName %> (AG-UI protocol). Connects to the local
2
2
  // `dev` server, or the deployed agent when `RUNTIME_CONFIG_APP_ID` is set.
3
3
  import { AGUIChatAdapter, chatLoop } from 'agent-chat-cli';
4
- import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
4
+ import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore<% if (esm) { %>.js<% } %>';
5
5
 
6
6
  const remote = await resolveRemoteAgent();
7
7
 
@@ -2,12 +2,12 @@
2
2
  // generated client. Connects to the local `dev` server, or the deployed
3
3
  // agent when `RUNTIME_CONFIG_APP_ID` is set.
4
4
  import { chatLoop, type ChatAdapter } from 'agent-chat-cli';
5
- import { <%- agentNameClassName %> } from './generated/client.gen.js';
5
+ import { <%- agentNameClassName %> } from './generated/client.gen<% if (esm) { %>.js<% } %>';
6
6
  import {
7
7
  createAgentCoreFetch,
8
8
  resolveRemoteAgent,
9
9
  SESSION_ID,
10
- } from './agentcore.js';
10
+ } from './agentcore<% if (esm) { %>.js<% } %>';
11
11
 
12
12
  const SESSION_ID_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
13
13