@aws/nx-plugin 1.0.0-rc.79 → 1.0.0-rc.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (469) hide show
  1. package/generators.json +10 -0
  2. package/migrations.json +1 -1
  3. package/package.json +1 -1
  4. package/src/agentcore-gateway/agent-connection/generator.d.ts +1 -1
  5. package/src/agentcore-gateway/agent-connection/generator.js.map +1 -1
  6. package/src/agentcore-gateway/agent-connection/schema.d.js.map +1 -1
  7. package/src/agentcore-gateway/agent-connection/schema.d.ts +1 -1
  8. package/src/agentcore-gateway/attach-upstream.js.map +1 -1
  9. package/src/agentcore-gateway/gateway-connection/generator.d.ts +1 -1
  10. package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
  11. package/src/agentcore-gateway/gateway-connection/schema.d.js.map +1 -1
  12. package/src/agentcore-gateway/gateway-connection/schema.d.ts +1 -1
  13. package/src/agentcore-gateway/generator.d.ts +3 -3
  14. package/src/agentcore-gateway/generator.js.map +1 -1
  15. package/src/agentcore-gateway/mcp-connection/generator.d.ts +1 -1
  16. package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
  17. package/src/agentcore-gateway/mcp-connection/schema.d.js.map +1 -1
  18. package/src/agentcore-gateway/mcp-connection/schema.d.ts +1 -1
  19. package/src/agentcore-gateway/react-connection/generator.d.ts +1 -1
  20. package/src/agentcore-gateway/react-connection/generator.js.map +1 -1
  21. package/src/agentcore-gateway/react-connection/schema.d.js.map +1 -1
  22. package/src/agentcore-gateway/react-connection/schema.d.ts +1 -1
  23. package/src/agentcore-gateway/schema.d.js.map +1 -1
  24. package/src/agentcore-gateway/schema.d.ts +1 -1
  25. package/src/agentcore-harness/generator.d.ts +4 -4
  26. package/src/agentcore-harness/generator.js.map +1 -1
  27. package/src/agentcore-harness/schema.d.js.map +1 -1
  28. package/src/agentcore-harness/schema.d.ts +1 -1
  29. package/src/connection/agent-local-dev.d.ts +1 -1
  30. package/src/connection/agent-local-dev.js.map +1 -1
  31. package/src/connection/agent-runtime-config.js.map +1 -1
  32. package/src/connection/gateway-runtime-config.js.map +1 -1
  33. package/src/connection/generator.d.ts +2 -2
  34. package/src/connection/generator.js.map +1 -1
  35. package/src/connection/local-dev.js.map +1 -1
  36. package/src/connection/scaffold-catalog.d.ts +1 -1
  37. package/src/connection/scaffold-catalog.js +6 -6
  38. package/src/connection/scaffold-catalog.js.map +1 -1
  39. package/src/connection/schema-resolver.d.ts +1 -1
  40. package/src/connection/schema-resolver.js.map +1 -1
  41. package/src/index.d.ts +1 -1
  42. package/src/index.js.map +1 -1
  43. package/src/infra/app/generator.d.ts +7 -7
  44. package/src/infra/app/generator.js.map +1 -1
  45. package/src/init/generator.d.ts +3 -3
  46. package/src/init/generator.js.map +1 -1
  47. package/src/init/schema.d.js.map +1 -1
  48. package/src/init/schema.d.ts +2 -2
  49. package/src/internal/test-matrix/generator.js.map +1 -1
  50. package/src/license/config-types.d.ts +2 -2
  51. package/src/license/config-types.js.map +1 -1
  52. package/src/license/config.d.ts +2 -2
  53. package/src/license/config.js.map +1 -1
  54. package/src/license/dependency-check/check.d.ts +2 -2
  55. package/src/license/dependency-check/check.js.map +1 -1
  56. package/src/license/dependency-check/collectors/collector.js.map +1 -1
  57. package/src/license/dependency-check/collectors/python-collector.js.map +1 -1
  58. package/src/license/dependency-check/evaluator.d.ts +1 -1
  59. package/src/license/dependency-check/evaluator.js.map +1 -1
  60. package/src/license/dependency-check/executor.js.map +1 -1
  61. package/src/license/dependency-check/pre-approved.d.ts +1 -1
  62. package/src/license/dependency-check/pre-approved.js.map +1 -1
  63. package/src/license/dependency-check/types.d.ts +1 -1
  64. package/src/license/dependency-check/types.js.map +1 -1
  65. package/src/license/generator.d.ts +1 -1
  66. package/src/license/generator.js.map +1 -1
  67. package/src/license/index.d.ts +4 -4
  68. package/src/license/index.js.map +1 -1
  69. package/src/license/known-exceptions.d.ts +1 -1
  70. package/src/license/known-exceptions.js.map +1 -1
  71. package/src/license/sync/generator.js.map +1 -1
  72. package/src/license/sync/project-file-sync.d.ts +1 -1
  73. package/src/license/sync/project-file-sync.js.map +1 -1
  74. package/src/mcp-server/dev-server.js.map +1 -1
  75. package/src/mcp-server/generator-info.d.ts +3 -3
  76. package/src/mcp-server/generator-info.js.map +1 -1
  77. package/src/mcp-server/guide-pipeline.d.ts +1 -1
  78. package/src/mcp-server/guide-pipeline.js.map +1 -1
  79. package/src/mcp-server/guide-render.js.map +1 -1
  80. package/src/mcp-server/index.js.map +1 -1
  81. package/src/mcp-server/mdx-ast.js.map +1 -1
  82. package/src/mcp-server/server.js.map +1 -1
  83. package/src/mcp-server/tools/add-to-existing-project.d.ts +1 -1
  84. package/src/mcp-server/tools/add-to-existing-project.js.map +1 -1
  85. package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
  86. package/src/mcp-server/tools/general-guidance.d.ts +1 -1
  87. package/src/mcp-server/tools/general-guidance.js +1 -1
  88. package/src/mcp-server/tools/general-guidance.js.map +1 -1
  89. package/src/mcp-server/tools/generator-guide.d.ts +1 -1
  90. package/src/mcp-server/tools/generator-guide.js.map +1 -1
  91. package/src/mcp-server/tools/list-generators.d.ts +1 -1
  92. package/src/mcp-server/tools/list-generators.js.map +1 -1
  93. package/src/mcp-server/tools/upgrade-workspace.d.ts +1 -1
  94. package/src/mcp-server/tools/upgrade-workspace.js.map +1 -1
  95. package/src/migrations/latest/apt-security-updates-in-container-images/migration.js.map +1 -1
  96. package/src/migrations/latest/dynamodb-configurable-encryption/migration.js.map +1 -1
  97. package/src/migrations/latest/py-agent-ag-ui-hooks/migration.js.map +1 -1
  98. package/src/migrations/latest/py-agent-session-id-middleware-extraction/migration.js.map +1 -1
  99. package/src/migrations/latest/remove-mcp-inspector-license-exceptions/migration.js.map +1 -1
  100. package/src/migrations/latest/static-website-configurable-waf-encryption/migration.js.map +1 -1
  101. package/src/migrations/latest/ts-agent-session-id-middleware-extraction/migration.js.map +1 -1
  102. package/src/migrations/latest/user-identity-configurable-mfa/migration.js.map +1 -1
  103. package/src/migrations/v1.0.0-rc.50/0001-modernize-function-props-cast/migration.js.map +1 -1
  104. package/src/migrations/v1.0.0-rc.50/0002-restrict-cors-to-custom-domains/migration.js.map +1 -1
  105. package/src/migrations/v1.0.0-rc.50/0003-terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -1
  106. package/src/migrations/v1.0.0-rc.52/0001-user-identity-waf-allow-localhost-callback/migration.js.map +1 -1
  107. package/src/migrations/v1.0.0-rc.54/0001-order-access-log-delivery-after-bucket-policy/migration.js.map +1 -1
  108. package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.d.ts +1 -1
  109. package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.js.map +1 -1
  110. package/src/migrations/v1.0.0-rc.56/0001-dynamodb-local-remove-optimize-flag/migration.js.map +1 -1
  111. package/src/migrations/v1.0.0-rc.57/0001-ts-agent-session-management-support/migration.js.map +1 -1
  112. package/src/migrations/v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins/migration.js.map +1 -1
  113. package/src/migrations/v1.0.0-rc.59/0001-gateway-agent-targets/migration.js.map +1 -1
  114. package/src/migrations/v1.0.0-rc.60/0001-gateway-cognito-passthrough/migration.js.map +1 -1
  115. package/src/migrations/v1.0.0-rc.60/0002-waf-log-group-removal/migration.js.map +1 -1
  116. package/src/migrations/v1.0.0-rc.60/0003-strip-pip-from-python-images/migration.js.map +1 -1
  117. package/src/migrations/v1.0.0-rc.61/0001-py-agent-lifespan-construction/migration.js.map +1 -1
  118. package/src/migrations/v1.0.0-rc.62/0001-rename-load-runtime-config-target/migration.js.map +1 -1
  119. package/src/migrations/v1.0.0-rc.63/0001-add-deploy-sandbox-target/migration.js.map +1 -1
  120. package/src/migrations/v1.0.0-rc.64/0001-smithy-build-without-docker/migration.js.map +1 -1
  121. package/src/migrations/v1.0.0-rc.65/0001-vite-config-import-meta-dirname/migration.js.map +1 -1
  122. package/src/migrations/v1.0.0-rc.65/0002-rolldown-code-splitting/migration.js.map +1 -1
  123. package/src/migrations/v1.0.0-rc.67/0001-smithy-server-package-rename/migration.js.map +1 -1
  124. package/src/migrations/v1.0.0-rc.68/0001-translate-script-whole-file-writes/migration.js.map +1 -1
  125. package/src/migrations/v1.0.0-rc.70/0001-py-agent-a2a-lifespan-construction/migration.js.map +1 -1
  126. package/src/migrations/v1.0.0-rc.71/0001-py-agent-a2a-httpx-client-per-call/migration.js.map +1 -1
  127. package/src/migrations/v1.0.0-rc.72/0001-py-agent-session-management-support/migration.js.map +1 -1
  128. package/src/open-api/ts-client/generator.d.ts +1 -1
  129. package/src/open-api/ts-client/generator.js.map +1 -1
  130. package/src/open-api/ts-hooks/generator.d.ts +1 -1
  131. package/src/open-api/ts-hooks/generator.js.map +1 -1
  132. package/src/open-api/ts-hooks/generator.spec.tsx +6 -6
  133. package/src/open-api/ts-metadata/generator.d.ts +1 -1
  134. package/src/open-api/ts-metadata/generator.js.map +1 -1
  135. package/src/open-api/utils/codegen-data/languages.d.ts +1 -1
  136. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  137. package/src/open-api/utils/codegen-data.d.ts +2 -2
  138. package/src/open-api/utils/codegen-data.js.map +1 -1
  139. package/src/open-api/utils/normalise.d.ts +1 -1
  140. package/src/open-api/utils/normalise.js.map +1 -1
  141. package/src/open-api/utils/parse.d.ts +1 -1
  142. package/src/open-api/utils/parse.js.map +1 -1
  143. package/src/open-api/utils/parser.d.ts +2 -2
  144. package/src/open-api/utils/parser.js.map +1 -1
  145. package/src/open-api/utils/refs.d.ts +1 -1
  146. package/src/open-api/utils/refs.js.map +1 -1
  147. package/src/preset/generator.d.ts +3 -3
  148. package/src/preset/generator.js.map +1 -1
  149. package/src/preset/schema.d.js.map +1 -1
  150. package/src/preset/schema.d.ts +3 -3
  151. package/src/py/agent/a2a-connection/generator.d.ts +3 -3
  152. package/src/py/agent/a2a-connection/generator.js.map +1 -1
  153. package/src/py/agent/a2a-connection/schema.d.js.map +1 -1
  154. package/src/py/agent/a2a-connection/schema.d.ts +1 -1
  155. package/src/py/agent/gateway-connection/generator.d.ts +3 -3
  156. package/src/py/agent/gateway-connection/generator.js.map +1 -1
  157. package/src/py/agent/gateway-connection/schema.d.js.map +1 -1
  158. package/src/py/agent/gateway-connection/schema.d.ts +1 -1
  159. package/src/py/agent/generator.d.ts +3 -3
  160. package/src/py/agent/generator.js.map +1 -1
  161. package/src/py/agent/mcp-connection/generator.d.ts +3 -3
  162. package/src/py/agent/mcp-connection/generator.js.map +1 -1
  163. package/src/py/agent/mcp-connection/schema.d.js.map +1 -1
  164. package/src/py/agent/mcp-connection/schema.d.ts +1 -1
  165. package/src/py/agent/react-connection/generator.d.ts +12 -12
  166. package/src/py/agent/react-connection/generator.js.map +1 -1
  167. package/src/py/agent/react-connection/local-dev.d.ts +1 -1
  168. package/src/py/agent/react-connection/local-dev.js.map +1 -1
  169. package/src/py/agent/react-connection/schema.d.js.map +1 -1
  170. package/src/py/agent/react-connection/schema.d.ts +1 -1
  171. package/src/py/agent/schema.d.js.map +1 -1
  172. package/src/py/agent/schema.d.ts +1 -1
  173. package/src/py/api/generator.d.ts +1 -1
  174. package/src/py/api/generator.js.map +1 -1
  175. package/src/py/api/schema.d.js.map +1 -1
  176. package/src/py/api/schema.d.ts +1 -1
  177. package/src/py/dynamodb/agent-connection/generator.d.ts +1 -1
  178. package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
  179. package/src/py/dynamodb/agent-connection/schema.d.js.map +1 -1
  180. package/src/py/dynamodb/agent-connection/schema.d.ts +1 -1
  181. package/src/py/dynamodb/fast-api-connection/generator.d.ts +1 -1
  182. package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
  183. package/src/py/dynamodb/generator.d.ts +4 -4
  184. package/src/py/dynamodb/generator.js.map +1 -1
  185. package/src/py/dynamodb/mcp-server-connection/generator.d.ts +1 -1
  186. package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
  187. package/src/py/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
  188. package/src/py/dynamodb/mcp-server-connection/schema.d.ts +1 -1
  189. package/src/py/dynamodb/schema.d.js.map +1 -1
  190. package/src/py/dynamodb/schema.d.ts +1 -1
  191. package/src/py/fast-api/generator.d.ts +3 -3
  192. package/src/py/fast-api/generator.js.map +1 -1
  193. package/src/py/fast-api/react/generator.d.ts +3 -3
  194. package/src/py/fast-api/react/generator.js.map +1 -1
  195. package/src/py/fast-api/react/open-api.js.map +1 -1
  196. package/src/py/fast-api/schema.d.js.map +1 -1
  197. package/src/py/fast-api/schema.d.ts +1 -1
  198. package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +1 -1
  199. package/src/py/lambda-function/generator.d.ts +10 -4
  200. package/src/py/lambda-function/generator.js +8 -1
  201. package/src/py/lambda-function/generator.js.map +1 -1
  202. package/src/py/lambda-function/schema.d.js.map +1 -1
  203. package/src/py/lambda-function/schema.d.ts +2 -2
  204. package/src/py/lambda-function/schema.json +1 -1
  205. package/src/py/mcp-server/generator.d.ts +3 -3
  206. package/src/py/mcp-server/generator.js.map +1 -1
  207. package/src/py/mcp-server/schema.d.js.map +1 -1
  208. package/src/py/mcp-server/schema.d.ts +1 -1
  209. package/src/py/project/generator.d.ts +2 -2
  210. package/src/py/project/generator.js.map +1 -1
  211. package/src/py/project/schema.json +1 -0
  212. package/src/py/rdb/agent-connection/generator.d.ts +1 -1
  213. package/src/py/rdb/agent-connection/generator.js.map +1 -1
  214. package/src/py/rdb/agent-connection/schema.d.js.map +1 -1
  215. package/src/py/rdb/agent-connection/schema.d.ts +1 -1
  216. package/src/py/rdb/fast-api-connection/generator.d.ts +1 -1
  217. package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
  218. package/src/py/rdb/generator.d.ts +3 -3
  219. package/src/py/rdb/generator.js.map +1 -1
  220. package/src/py/rdb/mcp-server-connection/generator.d.ts +1 -1
  221. package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
  222. package/src/py/rdb/mcp-server-connection/schema.d.js.map +1 -1
  223. package/src/py/rdb/mcp-server-connection/schema.d.ts +1 -1
  224. package/src/sdk/agentcore-gateway.d.ts +1 -1
  225. package/src/sdk/agentcore-gateway.js.map +1 -1
  226. package/src/sdk/agentcore-harness.d.ts +1 -1
  227. package/src/sdk/agentcore-harness.js.map +1 -1
  228. package/src/sdk/connection.d.ts +1 -1
  229. package/src/sdk/connection.js.map +1 -1
  230. package/src/sdk/license.d.ts +3 -3
  231. package/src/sdk/license.js.map +1 -1
  232. package/src/sdk/open-api.d.ts +3 -3
  233. package/src/sdk/open-api.js.map +1 -1
  234. package/src/sdk/py.d.ts +7 -7
  235. package/src/sdk/py.js.map +1 -1
  236. package/src/sdk/smithy.d.ts +1 -1
  237. package/src/sdk/smithy.js.map +1 -1
  238. package/src/sdk/terraform.d.ts +1 -1
  239. package/src/sdk/terraform.js.map +1 -1
  240. package/src/sdk/ts.d.ts +18 -18
  241. package/src/sdk/ts.js.map +1 -1
  242. package/src/sdk/utils/ast.d.ts +1 -1
  243. package/src/sdk/utils/ast.js.map +1 -1
  244. package/src/sdk/utils/format.d.ts +1 -1
  245. package/src/sdk/utils/format.js.map +1 -1
  246. package/src/sdk/utils/test.d.ts +1 -1
  247. package/src/sdk/utils/test.js.map +1 -1
  248. package/src/smithy/project/generator.d.ts +4 -4
  249. package/src/smithy/project/generator.js.map +1 -1
  250. package/src/smithy/react-connection/generator.d.ts +3 -3
  251. package/src/smithy/react-connection/generator.js.map +1 -1
  252. package/src/smithy/ts/api/generator.d.ts +3 -3
  253. package/src/smithy/ts/api/generator.js.map +1 -1
  254. package/src/smithy/ts/api/schema.d.js.map +1 -1
  255. package/src/smithy/ts/api/schema.d.ts +1 -1
  256. package/src/terraform/project/generator.d.ts +5 -5
  257. package/src/terraform/project/generator.js.map +1 -1
  258. package/src/trpc/backend/generator.d.ts +3 -3
  259. package/src/trpc/backend/generator.js.map +1 -1
  260. package/src/trpc/backend/schema.d.js.map +1 -1
  261. package/src/trpc/backend/schema.d.ts +1 -1
  262. package/src/trpc/react/generator.d.ts +3 -3
  263. package/src/trpc/react/generator.js.map +1 -1
  264. package/src/ts/agent/a2a-connection/generator.d.ts +3 -3
  265. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  266. package/src/ts/agent/a2a-connection/schema.d.js.map +1 -1
  267. package/src/ts/agent/a2a-connection/schema.d.ts +1 -1
  268. package/src/ts/agent/gateway-connection/generator.d.ts +3 -3
  269. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  270. package/src/ts/agent/gateway-connection/schema.d.js.map +1 -1
  271. package/src/ts/agent/gateway-connection/schema.d.ts +1 -1
  272. package/src/ts/agent/generator.d.ts +3 -3
  273. package/src/ts/agent/generator.js.map +1 -1
  274. package/src/ts/agent/mcp-connection/generator.d.ts +3 -3
  275. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  276. package/src/ts/agent/mcp-connection/schema.d.js.map +1 -1
  277. package/src/ts/agent/mcp-connection/schema.d.ts +1 -1
  278. package/src/ts/agent/react-connection/generator.d.ts +11 -11
  279. package/src/ts/agent/react-connection/generator.js.map +1 -1
  280. package/src/ts/agent/react-connection/local-dev.d.ts +1 -1
  281. package/src/ts/agent/react-connection/local-dev.js.map +1 -1
  282. package/src/ts/agent/react-connection/schema.d.js.map +1 -1
  283. package/src/ts/agent/react-connection/schema.d.ts +1 -1
  284. package/src/ts/agent/schema.d.js.map +1 -1
  285. package/src/ts/agent/schema.d.ts +1 -1
  286. package/src/ts/api/generator.d.ts +1 -1
  287. package/src/ts/api/generator.js.map +1 -1
  288. package/src/ts/api/schema.d.js.map +1 -1
  289. package/src/ts/api/schema.d.ts +1 -1
  290. package/src/ts/astro-docs/generator.d.ts +3 -3
  291. package/src/ts/astro-docs/generator.js.map +1 -1
  292. package/src/ts/dcr-proxy/generator.d.ts +5 -5
  293. package/src/ts/dcr-proxy/generator.js.map +1 -1
  294. package/src/ts/dcr-proxy/schema.d.js.map +1 -1
  295. package/src/ts/dcr-proxy/schema.d.ts +1 -1
  296. package/src/ts/docs/generator.d.ts +1 -1
  297. package/src/ts/docs/generator.js.map +1 -1
  298. package/src/ts/dynamodb/agent-connection/generator.d.ts +1 -1
  299. package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
  300. package/src/ts/dynamodb/agent-connection/schema.d.js.map +1 -1
  301. package/src/ts/dynamodb/agent-connection/schema.d.ts +1 -1
  302. package/src/ts/dynamodb/generator.d.ts +5 -5
  303. package/src/ts/dynamodb/generator.js +1 -0
  304. package/src/ts/dynamodb/generator.js.map +1 -1
  305. package/src/ts/dynamodb/mcp-server-connection/generator.d.ts +1 -1
  306. package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
  307. package/src/ts/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
  308. package/src/ts/dynamodb/mcp-server-connection/schema.d.ts +1 -1
  309. package/src/ts/dynamodb/schema.d.js.map +1 -1
  310. package/src/ts/dynamodb/schema.d.ts +1 -1
  311. package/src/ts/dynamodb/smithy-connection/generator.d.ts +1 -1
  312. package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
  313. package/src/ts/dynamodb/trpc-connection/generator.d.ts +1 -1
  314. package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
  315. package/src/ts/lambda-function/generator.d.ts +5 -5
  316. package/src/ts/lambda-function/generator.js.map +1 -1
  317. package/src/ts/lambda-function/schema.d.js.map +1 -1
  318. package/src/ts/lambda-function/schema.d.ts +1 -1
  319. package/src/ts/lib/biome.d.ts +1 -1
  320. package/src/ts/lib/biome.js.map +1 -1
  321. package/src/ts/lib/generator.d.ts +3 -3
  322. package/src/ts/lib/generator.js.map +1 -1
  323. package/src/ts/lib/ts-project-utils.d.ts +3 -3
  324. package/src/ts/lib/ts-project-utils.js.map +1 -1
  325. package/src/ts/lib/vitest.d.ts +2 -2
  326. package/src/ts/lib/vitest.js.map +1 -1
  327. package/src/ts/mcp-server/generator.d.ts +3 -3
  328. package/src/ts/mcp-server/generator.js.map +1 -1
  329. package/src/ts/mcp-server/schema.d.js.map +1 -1
  330. package/src/ts/mcp-server/schema.d.ts +1 -1
  331. package/src/ts/nx-generator/generator.d.ts +2 -2
  332. package/src/ts/nx-generator/generator.js.map +1 -1
  333. package/src/ts/nx-migration/generator.d.ts +3 -3
  334. package/src/ts/nx-migration/generator.js.map +1 -1
  335. package/src/ts/nx-plugin/generator.d.ts +3 -3
  336. package/src/ts/nx-plugin/generator.js.map +1 -1
  337. package/src/ts/nx-plugin/utils.d.ts +1 -1
  338. package/src/ts/nx-plugin/utils.js.map +1 -1
  339. package/src/ts/rdb/agent-connection/generator.d.ts +1 -1
  340. package/src/ts/rdb/agent-connection/generator.js.map +1 -1
  341. package/src/ts/rdb/agent-connection/schema.d.js.map +1 -1
  342. package/src/ts/rdb/agent-connection/schema.d.ts +1 -1
  343. package/src/ts/rdb/generator.d.ts +4 -4
  344. package/src/ts/rdb/generator.js +1 -0
  345. package/src/ts/rdb/generator.js.map +1 -1
  346. package/src/ts/rdb/mcp-server-connection/generator.d.ts +1 -1
  347. package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
  348. package/src/ts/rdb/mcp-server-connection/schema.d.js.map +1 -1
  349. package/src/ts/rdb/mcp-server-connection/schema.d.ts +1 -1
  350. package/src/ts/rdb/schema.d.js.map +1 -1
  351. package/src/ts/rdb/schema.d.ts +1 -1
  352. package/src/ts/rdb/smithy-connection/generator.d.ts +1 -1
  353. package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
  354. package/src/ts/rdb/trpc-connection/generator.d.ts +1 -1
  355. package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
  356. package/src/ts/react-website/agui/generator.d.ts +2 -2
  357. package/src/ts/react-website/agui/generator.js.map +1 -1
  358. package/src/ts/react-website/app/generator.d.ts +3 -3
  359. package/src/ts/react-website/app/generator.js.map +1 -1
  360. package/src/ts/react-website/app/schema.d.js.map +1 -1
  361. package/src/ts/react-website/app/schema.d.ts +2 -2
  362. package/src/ts/react-website/cognito-auth/generator.d.ts +5 -5
  363. package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
  364. package/src/ts/react-website/cognito-auth/schema.d.js.map +1 -1
  365. package/src/ts/react-website/cognito-auth/schema.d.ts +1 -1
  366. package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
  367. package/src/ts/react-website/runtime-config/generator.d.ts +1 -1
  368. package/src/ts/react-website/runtime-config/generator.js.map +1 -1
  369. package/src/ts/sync/generator.d.ts +1 -1
  370. package/src/ts/sync/generator.js.map +1 -1
  371. package/src/ts/website/app/generator.d.ts +1 -1
  372. package/src/ts/website/app/generator.js.map +1 -1
  373. package/src/ts/website/app/schema.d.js.map +1 -1
  374. package/src/ts/website/app/schema.d.ts +2 -2
  375. package/src/ts/website/auth/generator.d.ts +1 -1
  376. package/src/ts/website/auth/generator.js.map +1 -1
  377. package/src/ts/website/auth/schema.d.js.map +1 -1
  378. package/src/ts/website/auth/schema.d.ts +1 -1
  379. package/src/utils/add-dependencies.d.ts +1 -1
  380. package/src/utils/add-dependencies.js.map +1 -1
  381. package/src/utils/agent-chat/agent-chat.js.map +1 -1
  382. package/src/utils/agent-connection/agent-connection.d.ts +2 -2
  383. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  384. package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +4 -4
  385. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  386. package/src/utils/api-constructs/api-constructs.d.ts +3 -3
  387. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  388. package/src/utils/api-constructs/open-api-metadata.d.ts +1 -1
  389. package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
  390. package/src/utils/ast/website.js.map +1 -1
  391. package/src/utils/ast.js +6 -0
  392. package/src/utils/ast.js.map +1 -1
  393. package/src/utils/bundle/bundle.d.ts +1 -1
  394. package/src/utils/bundle/bundle.js.map +1 -1
  395. package/src/utils/commands.d.ts +1 -1
  396. package/src/utils/commands.js.map +1 -1
  397. package/src/utils/config/index.d.ts +6 -6
  398. package/src/utils/config/index.js.map +1 -1
  399. package/src/utils/config/utils.d.ts +1 -1
  400. package/src/utils/config/utils.js.map +1 -1
  401. package/src/utils/connection/open-api/react.d.ts +1 -1
  402. package/src/utils/connection/open-api/react.js.map +1 -1
  403. package/src/utils/containers.js.map +1 -1
  404. package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.d.ts +1 -1
  405. package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js.map +1 -1
  406. package/src/utils/declared-dependencies.d.ts +1 -1
  407. package/src/utils/declared-dependencies.js.map +1 -1
  408. package/src/utils/dependencies.js.map +1 -1
  409. package/src/utils/docker.d.ts +1 -1
  410. package/src/utils/docker.js.map +1 -1
  411. package/src/utils/dynamodb-constructs/dynamodb-constructs.d.ts +1 -1
  412. package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
  413. package/src/utils/format.js.map +1 -1
  414. package/src/utils/fs.d.ts +1 -1
  415. package/src/utils/fs.js.map +1 -1
  416. package/src/utils/function-constructs/function-constructs.d.ts +1 -1
  417. package/src/utils/function-constructs/function-constructs.js.map +1 -1
  418. package/src/utils/iac.d.ts +2 -2
  419. package/src/utils/iac.js.map +1 -1
  420. package/src/utils/identity-constructs/identity-constructs.d.ts +2 -2
  421. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  422. package/src/utils/init.d.ts +3 -3
  423. package/src/utils/init.js.map +1 -1
  424. package/src/utils/install.d.ts +1 -1
  425. package/src/utils/install.js.map +1 -1
  426. package/src/utils/mcp.js.map +1 -1
  427. package/src/utils/metrics.d.ts +1 -1
  428. package/src/utils/metrics.js.map +1 -1
  429. package/src/utils/migration-manifest.d.ts +1 -1
  430. package/src/utils/migration-manifest.js.map +1 -1
  431. package/src/utils/nx.d.ts +3 -3
  432. package/src/utils/nx.js.map +1 -1
  433. package/src/utils/paths.js.map +1 -1
  434. package/src/utils/pkg-manager.d.ts +1 -1
  435. package/src/utils/pkg-manager.js.map +1 -1
  436. package/src/utils/pnpm-workspace.js.map +1 -1
  437. package/src/utils/project-package-json.js.map +1 -1
  438. package/src/utils/py.d.ts +2 -2
  439. package/src/utils/py.js.map +1 -1
  440. package/src/utils/rdb-constructs/rdb-constructs.d.ts +2 -2
  441. package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
  442. package/src/utils/shared-constructs-constants.js.map +1 -1
  443. package/src/utils/shared-constructs.d.ts +3 -3
  444. package/src/utils/shared-constructs.js.map +1 -1
  445. package/src/utils/shared-dynamodb-scripts.d.ts +1 -1
  446. package/src/utils/shared-dynamodb-scripts.js.map +1 -1
  447. package/src/utils/shared-infra-config.js.map +1 -1
  448. package/src/utils/shared-infra-scripts.d.ts +2 -2
  449. package/src/utils/shared-infra-scripts.js.map +1 -1
  450. package/src/utils/shared-rdb-scripts.d.ts +1 -1
  451. package/src/utils/shared-rdb-scripts.js.map +1 -1
  452. package/src/utils/shared-scripts.js.map +1 -1
  453. package/src/utils/shared-shadcn.d.ts +1 -1
  454. package/src/utils/shared-shadcn.js.map +1 -1
  455. package/src/utils/smithy.js.map +1 -1
  456. package/src/utils/test.js.map +1 -1
  457. package/src/utils/version-upgrade-migration/migration.js.map +1 -1
  458. package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -1
  459. package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +1 -1
  460. package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -1
  461. package/src/utils/version-upgrade-migration/register.js.map +1 -1
  462. package/src/utils/version-upgrade-migration/sync-embedded-versions.d.ts +1 -1
  463. package/src/utils/version-upgrade-migration/sync-embedded-versions.js.map +1 -1
  464. package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -1
  465. package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -1
  466. package/src/utils/versions.d.ts +1 -1
  467. package/src/utils/versions.js.map +1 -1
  468. package/src/utils/website-constructs/website-constructs.d.ts +2 -2
  469. package/src/utils/website-constructs/website-constructs.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/fast-api/react/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport {\n addOpenApiReactClient,\n OPEN_API_REACT_DEPENDENCIES,\n} from '../../../utils/connection/open-api/react';\nimport { declareDependencies } from '../../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { toClassName } from '../../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { toProjectRelativePath } from '../../../utils/paths';\nimport { addOpenApiGeneration } from './open-api';\nimport type { FastApiReactGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...OPEN_API_REACT_DEPENDENCIES],\n});\n\nexport const FAST_API_REACT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const fastApiReactGenerator = async (\n tree: Tree,\n options: FastApiReactGeneratorSchema,\n) => {\n const frontendProjectConfig = readProjectConfigurationUnqualified(\n tree,\n options.frontendProjectName,\n );\n const fastApiProjectConfig = readProjectConfigurationUnqualified(\n tree,\n options.fastApiProjectName,\n );\n\n // Add OpenAPI spec generation to the project, run as part of build\n const { specPath } = addOpenApiGeneration(tree, {\n project: fastApiProjectConfig,\n });\n\n const metadata = fastApiProjectConfig.metadata as any;\n const apiName = metadata?.apiName;\n const auth = (metadata?.auth ?? 'iam').toLowerCase();\n const port = metadata?.port ?? metadata?.ports?.[0] ?? 8000;\n\n await addOpenApiReactClient(\n tree,\n {\n apiName,\n frontendProjectConfig,\n backendProjectConfig: fastApiProjectConfig,\n specBuildProject: fastApiProjectConfig,\n specPath,\n specBuildTargetName: `${fastApiProjectConfig.name}:openapi`,\n auth,\n port,\n },\n DEPENDENCIES,\n );\n\n const apiNameClassName = toClassName(apiName);\n\n // Recorded so the version sync knows this connection's dependencies are ours.\n addComponentGeneratorMetadata(\n tree,\n frontendProjectConfig.name,\n FAST_API_REACT_GENERATOR_INFO,\n toProjectRelativePath(\n frontendProjectConfig,\n joinPathFragments(\n frontendProjectConfig.sourceRoot,\n 'components',\n `${apiNameClassName}Provider`,\n ),\n ),\n apiNameClassName,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [FAST_API_REACT_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default fastApiReactGenerator;\n"],"names":["joinPathFragments","addOpenApiReactClient","OPEN_API_REACT_DEPENDENCIES","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toClassName","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","addOpenApiGeneration","DEPENDENCIES","ts","FAST_API_REACT_GENERATOR_INFO","filename","fastApiReactGenerator","tree","options","frontendProjectConfig","frontendProjectName","fastApiProjectConfig","fastApiProjectName","specPath","project","metadata","apiName","auth","toLowerCase","port","ports","backendProjectConfig","specBuildProject","specBuildTargetName","name","apiNameClassName","sourceRoot","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,iBAAiB,QAAmB,aAAa;AAC1D,SACEC,qBAAqB,EACrBC,2BAA2B,QACtB,8CAA2C;AAClD,SAASC,mBAAmB,QAAQ,0CAAuC;AAC3E,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SAASC,WAAW,QAAQ,0BAAuB;AACnD,SACEC,6BAA6B,EAC7BC,gBAAgB,EAEhBC,mCAAmC,QAC9B,u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":["../../../../../../../packages/nx-plugin/src/py/fast-api/react/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport {\n addOpenApiReactClient,\n OPEN_API_REACT_DEPENDENCIES,\n} from '../../../utils/connection/open-api/react.js';\nimport { declareDependencies } from '../../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { toClassName } from '../../../utils/names.js';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx.js';\nimport { toProjectRelativePath } from '../../../utils/paths.js';\nimport { addOpenApiGeneration } from './open-api.js';\nimport type { FastApiReactGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...OPEN_API_REACT_DEPENDENCIES],\n});\n\nexport const FAST_API_REACT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const fastApiReactGenerator = async (\n tree: Tree,\n options: FastApiReactGeneratorSchema,\n) => {\n const frontendProjectConfig = readProjectConfigurationUnqualified(\n tree,\n options.frontendProjectName,\n );\n const fastApiProjectConfig = readProjectConfigurationUnqualified(\n tree,\n options.fastApiProjectName,\n );\n\n // Add OpenAPI spec generation to the project, run as part of build\n const { specPath } = addOpenApiGeneration(tree, {\n project: fastApiProjectConfig,\n });\n\n const metadata = fastApiProjectConfig.metadata as any;\n const apiName = metadata?.apiName;\n const auth = (metadata?.auth ?? 'iam').toLowerCase();\n const port = metadata?.port ?? metadata?.ports?.[0] ?? 8000;\n\n await addOpenApiReactClient(\n tree,\n {\n apiName,\n frontendProjectConfig,\n backendProjectConfig: fastApiProjectConfig,\n specBuildProject: fastApiProjectConfig,\n specPath,\n specBuildTargetName: `${fastApiProjectConfig.name}:openapi`,\n auth,\n port,\n },\n DEPENDENCIES,\n );\n\n const apiNameClassName = toClassName(apiName);\n\n // Recorded so the version sync knows this connection's dependencies are ours.\n addComponentGeneratorMetadata(\n tree,\n frontendProjectConfig.name,\n FAST_API_REACT_GENERATOR_INFO,\n toProjectRelativePath(\n frontendProjectConfig,\n joinPathFragments(\n frontendProjectConfig.sourceRoot,\n 'components',\n `${apiNameClassName}Provider`,\n ),\n ),\n apiNameClassName,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [FAST_API_REACT_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default fastApiReactGenerator;\n"],"names":["joinPathFragments","addOpenApiReactClient","OPEN_API_REACT_DEPENDENCIES","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toClassName","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","addOpenApiGeneration","DEPENDENCIES","ts","FAST_API_REACT_GENERATOR_INFO","filename","fastApiReactGenerator","tree","options","frontendProjectConfig","frontendProjectName","fastApiProjectConfig","fastApiProjectName","specPath","project","metadata","apiName","auth","toLowerCase","port","ports","backendProjectConfig","specBuildProject","specBuildTargetName","name","apiNameClassName","sourceRoot","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,iBAAiB,QAAmB,aAAa;AAC1D,SACEC,qBAAqB,EACrBC,2BAA2B,QACtB,8CAA8C;AACrD,SAASC,mBAAmB,QAAQ,0CAA0C;AAC9E,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,+BAA+B,QAAQ,4BAA4B;AAC5E,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SACEC,6BAA6B,EAC7BC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAuB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":3,"sources":["../../../../../../../packages/nx-plugin/src/py/fast-api/react/open-api.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { snakeCase } from '../../../utils/names';\nimport { sortObjectKeys } from '../../../utils/object';\n\nexport interface AddOpenApiGenerationOptions {\n project: ProjectConfiguration;\n}\n\n/**\n * Adds FastAPI -> OpenApi spec generation as part of the FastAPI project build\n */\nexport const addOpenApiGeneration = (\n tree: Tree,\n { project }: AddOpenApiGenerationOptions,\n): { specPath: string } => {\n const moduleName = getFastApiModuleName(project);\n\n // Add OpenAPI spec generation script to FastAPI spec, preserving an existing\n // copy so re-running does not reformat it nondeterministically\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files/fast-api'),\n project.root,\n {\n moduleName,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Instrument the script as part of the fastapi project build\n const fastApiOpenApiDist = joinPathFragments('dist', project.root, 'openapi');\n const specPath = joinPathFragments(fastApiOpenApiDist, 'openapi.json');\n updateProjectConfiguration(tree, project.name, {\n ...project,\n targets: sortObjectKeys({\n ...project.targets,\n build: {\n ...project.targets?.build,\n dependsOn: [\n ...(project.targets?.build?.dependsOn ?? []).filter(\n (t) => t !== 'openapi',\n ),\n 'openapi',\n ],\n },\n openapi: {\n cache: true,\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/openapi'],\n options: {\n commands: [\n 'uv run python {projectRoot}/scripts/generate_open_api.py \"dist/{projectRoot}/openapi/openapi.json\"',\n ],\n },\n },\n }),\n });\n\n return { specPath };\n};\n\nconst getFastApiModuleName = (projectConfig: ProjectConfiguration): string => {\n if (projectConfig.sourceRoot) {\n const sourceRootParts = projectConfig.sourceRoot.split('/');\n return sourceRootParts[sourceRootParts.length - 1];\n }\n const apiName = (projectConfig.metadata as any)?.apiName;\n if (apiName) {\n return snakeCase(apiName);\n }\n new Error(`Could not determine sourceRoot for project ${projectConfig.name}`);\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","snakeCase","sortObjectKeys","addOpenApiGeneration","tree","project","moduleName","getFastApiModuleName","dirname","root","overwriteStrategy","KeepExisting","fastApiOpenApiDist","specPath","name","targets","build","dependsOn","filter","t","openapi","cache","executor","outputs","options","commands","projectConfig","sourceRoot","sourceRootParts","split","length","apiName","metadata","Error"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,SAAS,QAAQ,0BAAuB;AACjD,SAASC,cAAc,QAAQ,2BAAwB;AAMvD;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAClCC,MACA,EAAEC,OAAO,EAA+B;IAExC,MAAMC,aAAaC,qBAAqBF;IAExC,6EAA6E;IAC7E,+DAA+D;IAC/DR,cACEO,MACAN,kBAAkB,YAAYU,OAAO,EAAE,mBACvCH,QAAQI,IAAI,EACZ;QACEH;IACF,GACA;QACEI,mBAAmBX,kBAAkBY,YAAY;IACnD;IAGF,6DAA6D;IAC7D,MAAMC,qBAAqBd,kBAAkB,QAAQO,QAAQI,IAAI,EAAE;IACnE,MAAMI,WAAWf,kBAAkBc,oBAAoB;IACvDZ,2BAA2BI,MAAMC,QAAQS,IAAI,EAAE;QAC7C,GAAGT,OAAO;QACVU,SAASb,eAAe;YACtB,GAAGG,QAAQU,OAAO;YAClBC,OAAO;gBACL,GAAGX,QAAQU,OAAO,EAAEC,KAAK;gBACzBC,WAAW;uBACN,AAACZ,CAAAA,QAAQU,OAAO,EAAEC,OAAOC,aAAa,EAAE,AAAD,EAAGC,MAAM,CACjD,CAACC,IAAMA,MAAM;oBAEf;iBACD;YACH;YACAC,SAAS;gBACPC,OAAO;gBACPC,UAAU;gBACVC,SAAS;oBAAC;iBAA6C;gBACvDC,SAAS;oBACPC,UAAU;wBACR;qBACD;gBACH;YACF;QACF;IACF;IAEA,OAAO;QAAEZ;IAAS;AACpB,EAAE;AAEF,MAAMN,uBAAuB,CAACmB;IAC5B,IAAIA,cAAcC,UAAU,EAAE;QAC5B,MAAMC,kBAAkBF,cAAcC,UAAU,CAACE,KAAK,CAAC;QACvD,OAAOD,eAAe,CAACA,gBAAgBE,MAAM,GAAG,EAAE;IACpD;IACA,MAAMC,UAAWL,cAAcM,QAAQ,EAAUD;IACjD,IAAIA,SAAS;QACX,OAAO9B,UAAU8B;IACnB;IACA,IAAIE,MAAM,CAAC,2CAA2C,EAAEP,cAAcZ,IAAI,EAAE;AAC9E"}
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/fast-api/react/open-api.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { snakeCase } from '../../../utils/names.js';\nimport { sortObjectKeys } from '../../../utils/object.js';\n\nexport interface AddOpenApiGenerationOptions {\n project: ProjectConfiguration;\n}\n\n/**\n * Adds FastAPI -> OpenApi spec generation as part of the FastAPI project build\n */\nexport const addOpenApiGeneration = (\n tree: Tree,\n { project }: AddOpenApiGenerationOptions,\n): { specPath: string } => {\n const moduleName = getFastApiModuleName(project);\n\n // Add OpenAPI spec generation script to FastAPI spec, preserving an existing\n // copy so re-running does not reformat it nondeterministically\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files/fast-api'),\n project.root,\n {\n moduleName,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Instrument the script as part of the fastapi project build\n const fastApiOpenApiDist = joinPathFragments('dist', project.root, 'openapi');\n const specPath = joinPathFragments(fastApiOpenApiDist, 'openapi.json');\n updateProjectConfiguration(tree, project.name, {\n ...project,\n targets: sortObjectKeys({\n ...project.targets,\n build: {\n ...project.targets?.build,\n dependsOn: [\n ...(project.targets?.build?.dependsOn ?? []).filter(\n (t) => t !== 'openapi',\n ),\n 'openapi',\n ],\n },\n openapi: {\n cache: true,\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/openapi'],\n options: {\n commands: [\n 'uv run python {projectRoot}/scripts/generate_open_api.py \"dist/{projectRoot}/openapi/openapi.json\"',\n ],\n },\n },\n }),\n });\n\n return { specPath };\n};\n\nconst getFastApiModuleName = (projectConfig: ProjectConfiguration): string => {\n if (projectConfig.sourceRoot) {\n const sourceRootParts = projectConfig.sourceRoot.split('/');\n return sourceRootParts[sourceRootParts.length - 1];\n }\n const apiName = (projectConfig.metadata as any)?.apiName;\n if (apiName) {\n return snakeCase(apiName);\n }\n new Error(`Could not determine sourceRoot for project ${projectConfig.name}`);\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","snakeCase","sortObjectKeys","addOpenApiGeneration","tree","project","moduleName","getFastApiModuleName","dirname","root","overwriteStrategy","KeepExisting","fastApiOpenApiDist","specPath","name","targets","build","dependsOn","filter","t","openapi","cache","executor","outputs","options","commands","projectConfig","sourceRoot","sourceRootParts","split","length","apiName","metadata","Error"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,cAAc,QAAQ,2BAA2B;AAM1D;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAClCC,MACA,EAAEC,OAAO,EAA+B;IAExC,MAAMC,aAAaC,qBAAqBF;IAExC,6EAA6E;IAC7E,+DAA+D;IAC/DR,cACEO,MACAN,kBAAkB,YAAYU,OAAO,EAAE,mBACvCH,QAAQI,IAAI,EACZ;QACEH;IACF,GACA;QACEI,mBAAmBX,kBAAkBY,YAAY;IACnD;IAGF,6DAA6D;IAC7D,MAAMC,qBAAqBd,kBAAkB,QAAQO,QAAQI,IAAI,EAAE;IACnE,MAAMI,WAAWf,kBAAkBc,oBAAoB;IACvDZ,2BAA2BI,MAAMC,QAAQS,IAAI,EAAE;QAC7C,GAAGT,OAAO;QACVU,SAASb,eAAe;YACtB,GAAGG,QAAQU,OAAO;YAClBC,OAAO;gBACL,GAAGX,QAAQU,OAAO,EAAEC,KAAK;gBACzBC,WAAW;uBACN,AAACZ,CAAAA,QAAQU,OAAO,EAAEC,OAAOC,aAAa,EAAE,AAAD,EAAGC,MAAM,CACjD,CAACC,IAAMA,MAAM;oBAEf;iBACD;YACH;YACAC,SAAS;gBACPC,OAAO;gBACPC,UAAU;gBACVC,SAAS;oBAAC;iBAA6C;gBACvDC,SAAS;oBACPC,UAAU;wBACR;qBACD;gBACH;YACF;QACF;IACF;IAEA,OAAO;QAAEZ;IAAS;AACpB,EAAE;AAEF,MAAMN,uBAAuB,CAACmB;IAC5B,IAAIA,cAAcC,UAAU,EAAE;QAC5B,MAAMC,kBAAkBF,cAAcC,UAAU,CAACE,KAAK,CAAC;QACvD,OAAOD,eAAe,CAACA,gBAAgBE,MAAM,GAAG,EAAE;IACpD;IACA,MAAMC,UAAWL,cAAcM,QAAQ,EAAUD;IACjD,IAAIA,SAAS;QACX,OAAO9B,UAAU8B;IACnB;IACA,IAAIE,MAAM,CAAC,2CAA2C,EAAEP,cAAcZ,IAAI,EAAE;AAC9E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/fast-api/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac';\n\nexport interface PyFastApiProjectGeneratorSchema {\n readonly name: string;\n readonly infra: 'rest-lambda' | 'http-lambda' | 'none';\n readonly integrationPattern?: 'isolated' | 'shared';\n readonly auth: 'iam' | 'cognito' | 'custom';\n readonly directory?: string;\n readonly subDirectory?: string;\n readonly moduleName?: string;\n readonly iac: IacOption;\n readonly preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAID,WAUC"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/fast-api/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac.js';\n\nexport interface PyFastApiProjectGeneratorSchema {\n readonly name: string;\n readonly infra: 'rest-lambda' | 'http-lambda' | 'none';\n readonly integrationPattern?: 'isolated' | 'shared';\n readonly auth: 'iam' | 'cognito' | 'custom';\n readonly directory?: string;\n readonly subDirectory?: string;\n readonly moduleName?: string;\n readonly iac: IacOption;\n readonly preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAID,WAUC"}
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { IacOption } from '../../utils/iac';
6
+ import { IacOption } from '../../utils/iac.js';
7
7
 
8
8
  export interface PyFastApiProjectGeneratorSchema {
9
9
  readonly name: string;
@@ -4,7 +4,7 @@ from aws_lambda_powertools import Logger, Metrics, Tracer
4
4
  from aws_lambda_powertools.metrics import MetricUnit
5
5
  <%_ if (event !== 'Any') { _%>
6
6
  from aws_lambda_powertools.utilities.parser import event_parser
7
- from aws_lambda_powertools.utilities.parser.models import <%= event %>
7
+ from <%= eventModule %> import <%= event %>
8
8
  <%_ } _%>
9
9
  from aws_lambda_powertools.utilities.typing import LambdaContext
10
10
 
@@ -3,16 +3,16 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type GeneratorCallback, type Tree } from '@nx/devkit';
6
- import { type NxGeneratorInfo } from '../../utils/nx';
6
+ import { type NxGeneratorInfo } from '../../utils/nx.js';
7
7
  import type { PyLambdaFunctionGeneratorSchema } from './schema';
8
- export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
8
+ export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
9
9
  readonly name: "constructs";
10
- readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
10
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
11
11
  } & {
12
12
  versionOnly: true;
13
13
  }, {
14
14
  readonly name: "aws-cdk-lib";
15
- readonly when: (m: import("../../utils/shared-constructs-constants").IacMetadata) => boolean;
15
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
16
16
  } & {
17
17
  versionOnly: true;
18
18
  }, {
@@ -27,6 +27,12 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
27
27
  readonly name: "aws-lambda-powertools[parser]";
28
28
  }]>;
29
29
  export declare const LAMBDA_FUNCTION_GENERATOR_INFO: NxGeneratorInfo;
30
+ /**
31
+ * The module an event model is importable from. Most are re-exported by the
32
+ * `models` package, but the IoT Core registry events are only available from
33
+ * the submodule that defines them.
34
+ */
35
+ export declare const eventModuleFor: (event: string) => string;
30
36
  export interface LambdaFunctionDetails {
31
37
  /**
32
38
  * The normalized name of the lambda handler project
@@ -33,6 +33,12 @@ export const DEPENDENCIES = declareDependencies()({
33
33
  ]
34
34
  });
35
35
  export const LAMBDA_FUNCTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
36
+ const PARSER_MODELS_MODULE = 'aws_lambda_powertools.utilities.parser.models';
37
+ /**
38
+ * The module an event model is importable from. Most are re-exported by the
39
+ * `models` package, but the IoT Core registry events are only available from
40
+ * the submodule that defines them.
41
+ */ export const eventModuleFor = (event)=>event.startsWith('IoTCore') ? `${PARSER_MODELS_MODULE}.iot_registry_events` : PARSER_MODELS_MODULE;
36
42
  const getLambdaFunctionDetails = (tree, schema)=>{
37
43
  const scope = toSnakeCase(getNpmScope(tree));
38
44
  const normalizedFunctionName = toSnakeCase(schema.name);
@@ -101,7 +107,8 @@ const getLambdaFunctionDetails = (tree, schema)=>{
101
107
  ...schema,
102
108
  dir,
103
109
  lambdaFunctionClassName,
104
- lambdaFunctionSnakeCase: normalizedFunctionName
110
+ lambdaFunctionSnakeCase: normalizedFunctionName,
111
+ eventModule: eventModuleFor(schema.event ?? 'Any')
105
112
  };
106
113
  projectConfig.targets = sortObjectKeys(projectConfig.targets);
107
114
  updateProjectConfiguration(tree, projectConfig.name, projectConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/lambda-function/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 updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addPyDependencies } from '../../utils/add-dependencies';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { addLambdaFunctionInfra } from '../../utils/function-constructs/function-constructs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport {\n toClassName,\n toDotNotation,\n toKebabCase,\n toSnakeCase,\n} from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { toProjectRelativePath } from '../../utils/paths';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport type { PyLambdaFunctionGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES)],\n py: [\n { name: 'aws-lambda-powertools' },\n { name: 'aws-lambda-powertools[tracer]' },\n { name: 'aws-lambda-powertools[parser]' },\n ],\n});\n\nexport const LAMBDA_FUNCTION_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport interface LambdaFunctionDetails {\n /**\n * The normalized name of the lambda handler project\n */\n readonly normalizedFunctionName: string;\n /**\n * The full package name of the lambda handler construct\n */\n readonly fullyQualifiedFunctionName: string;\n /**\n * The normalized python path to the lambda handler file in dot notation (e.g. `app.lambda_functions.lambda_handler`)\n */\n readonly normalizedFunctionPath: string;\n}\n\nconst getLambdaFunctionDetails = (\n tree: Tree,\n schema: { moduleName: string; name: string; functionPath?: string },\n): LambdaFunctionDetails => {\n const scope = toSnakeCase(getNpmScope(tree));\n const normalizedFunctionName = toSnakeCase(schema.name);\n const fullyQualifiedFunctionName = `${scope}.${normalizedFunctionName}`;\n const normalizedFunctionPath = `${schema.moduleName}.${schema.functionPath ? `${toDotNotation(schema.functionPath)}.` : ''}${normalizedFunctionName}.lambda_handler`;\n\n return {\n fullyQualifiedFunctionName,\n normalizedFunctionName,\n normalizedFunctionPath,\n };\n};\n\n/**\n * Generates a Python Lambda Function to add to a python project\n */\nexport const pyLambdaFunctionGenerator = async (\n tree: Tree,\n schema: PyLambdaFunctionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const projectConfig = readProjectConfigurationUnqualified(\n tree,\n schema.project,\n );\n\n const pyProjectPath = joinPathFragments(projectConfig.root, 'pyproject.toml');\n\n // Check if the project has a pyproject.toml file\n if (!pyProjectPath) {\n throw new Error(\n `This generator does not support selected project ${schema.project}`,\n );\n }\n\n if (!projectConfig.sourceRoot) {\n throw new Error(\n `This project does not have a source root. Please add a source root to the project configuration before running this generator.`,\n );\n }\n\n const dir = projectConfig.root;\n const projectNameWithOutScope = projectConfig.name.split('.').pop();\n const normalizedProjectName = toSnakeCase(projectNameWithOutScope);\n\n // Module name is the last part of the source root,\n const sourceParts = projectConfig.sourceRoot.split('/');\n const moduleName = sourceParts[sourceParts.length - 1];\n\n const { normalizedFunctionName, normalizedFunctionPath } =\n getLambdaFunctionDetails(tree, {\n moduleName,\n name: schema.name,\n functionPath: schema.functionPath,\n });\n\n const constructFunctionName = `${normalizedProjectName}_${normalizedFunctionName}`;\n const constructFunctionClassName = toClassName(constructFunctionName);\n const constructFunctionKebabCase = toKebabCase(constructFunctionName);\n const lambdaFunctionClassName = toClassName(schema.name);\n const lambdaFunctionKebabCase = toKebabCase(schema.name);\n\n const functionPath = joinPathFragments(\n projectConfig.sourceRoot,\n schema.functionPath ?? '',\n `${normalizedFunctionName}.py`,\n );\n\n const infra = schema.infra ?? 'lambda';\n const handlerAlreadyExists = tree.exists(functionPath);\n\n if (handlerAlreadyExists && infra === 'none') {\n throw new Error(\n `This project already has a lambda function with the name ${normalizedFunctionName}. Please remove the lambda function before running this generator or use a different name.`,\n );\n }\n\n // Check if the project has a bundle target and if not add it\n const { bundleOutputDir } = addPythonBundleTarget(projectConfig);\n\n // Recorded below so the version sync can tell a CDK project from a\n // Terraform one; undefined when no infrastructure was generated.\n const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;\n\n if (infra !== 'none') {\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addLambdaFunctionInfra(tree, {\n functionProjectName: projectConfig.name,\n nameClassName: constructFunctionClassName,\n nameKebabCase: constructFunctionKebabCase,\n handler: normalizedFunctionPath,\n bundlePathFromRoot: bundleOutputDir,\n runtime: 'python',\n iac,\n });\n }\n\n const enhancedOptions = {\n ...schema,\n dir,\n lambdaFunctionClassName,\n lambdaFunctionSnakeCase: normalizedFunctionName,\n };\n\n projectConfig.targets = sortObjectKeys(projectConfig.targets);\n updateProjectConfiguration(tree, projectConfig.name, projectConfig);\n\n // Generate the lambda handler file\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, 'files', 'handler'), // path to the file templates\n joinPathFragments(projectConfig.sourceRoot, schema.functionPath ?? ''),\n enhancedOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Generate the lambda handler test file\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'tests'),\n joinPathFragments(dir, 'tests'),\n enhancedOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n addPyDependencies(tree, DEPENDENCIES, { projectRoot: dir });\n\n addComponentGeneratorMetadata(\n tree,\n projectConfig.name,\n LAMBDA_FUNCTION_GENERATOR_INFO,\n toProjectRelativePath(projectConfig, functionPath),\n lambdaFunctionKebabCase,\n iac ? { iac } : {},\n );\n\n await addGeneratorMetricsIfApplicable(tree, [LAMBDA_FUNCTION_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\nexport default pyLambdaFunctionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addPyDependencies","addPythonBundleTarget","declareDependencies","ownedElsewhere","formatFilesInSubtree","addLambdaFunctionInfra","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toDotNotation","toKebabCase","toSnakeCase","getNpmScope","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","toProjectRelativePath","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","DEPENDENCIES","ts","py","name","LAMBDA_FUNCTION_GENERATOR_INFO","filename","getLambdaFunctionDetails","tree","schema","scope","normalizedFunctionName","fullyQualifiedFunctionName","normalizedFunctionPath","moduleName","functionPath","pyLambdaFunctionGenerator","projectConfig","project","pyProjectPath","root","Error","sourceRoot","dir","projectNameWithOutScope","split","pop","normalizedProjectName","sourceParts","length","constructFunctionName","constructFunctionClassName","constructFunctionKebabCase","lambdaFunctionClassName","lambdaFunctionKebabCase","infra","handlerAlreadyExists","exists","bundleOutputDir","iac","undefined","functionProjectName","nameClassName","nameKebabCase","handler","bundlePathFromRoot","runtime","enhancedOptions","lambdaFunctionSnakeCase","targets","dirname","overwriteStrategy","KeepExisting","projectRoot","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAA+B;AACjE,SAASC,qBAAqB,QAAQ,+BAA4B;AAClE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,sBAAsB,QAAQ,yDAAsD;AAC7F,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SACEC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,WAAW,QACN,uBAAoB;AAC3B,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,6BAA6B,EAC7BC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SAASC,qBAAqB,QAAQ,uBAAoB;AAC1D,SACEC,8BAA8B,EAC9BC,yBAAyB,QACpB,mCAAgC;AAGvC,OAAO,MAAMC,eAAenB,sBAAsB;IAChDoB,IAAI;WAAInB,eAAegB;KAAgC;IACvDI,IAAI;QACF;YAAEC,MAAM;QAAwB;QAChC;YAAEA,MAAM;QAAgC;QACxC;YAAEA,MAAM;QAAgC;KACzC;AACH,GAAG;AAEH,OAAO,MAAMC,iCAAkDV,iBAC7D,YAAYW,QAAQ,EACpB;AAiBF,MAAMC,2BAA2B,CAC/BC,MACAC;IAEA,MA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EAAE,SAAS,UAChDzE,kBAAkB8C,KAAK,UACvBwB,iBACA;QAAEI,mBAAmBzE,kBAAkB0E,YAAY;IAAC;IAGtDxE,kBAAkB4B,MAAMP,cAAc;QAAEoD,aAAa9B;IAAI;IAEzD7B,8BACEc,MACAS,cAAcb,IAAI,EAClBC,gCACAP,sBAAsBmB,eAAeF,eACrCmB,yBACAK,MAAM;QAAEA;IAAI,IAAI,CAAC;IAGnB,MAAMnD,gCAAgCoB,MAAM;QAACH;KAA+B;IAE5E,MAAMrB,qBAAqBwB;IAE3B,OAAO,IACLrB,oBAAoBqB,MAAMC,OAAO6C,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AACF,eAAevC,0BAA0B"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/lambda-function/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 updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addPyDependencies } from '../../utils/add-dependencies.js';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { addLambdaFunctionInfra } from '../../utils/function-constructs/function-constructs.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport {\n toClassName,\n toDotNotation,\n toKebabCase,\n toSnakeCase,\n} from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { toProjectRelativePath } from '../../utils/paths.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport type { PyLambdaFunctionGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES)],\n py: [\n { name: 'aws-lambda-powertools' },\n { name: 'aws-lambda-powertools[tracer]' },\n { name: 'aws-lambda-powertools[parser]' },\n ],\n});\n\nexport const LAMBDA_FUNCTION_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nconst PARSER_MODELS_MODULE = 'aws_lambda_powertools.utilities.parser.models';\n\n/**\n * The module an event model is importable from. Most are re-exported by the\n * `models` package, but the IoT Core registry events are only available from\n * the submodule that defines them.\n */\nexport const eventModuleFor = (event: string): string =>\n event.startsWith('IoTCore')\n ? `${PARSER_MODELS_MODULE}.iot_registry_events`\n : PARSER_MODELS_MODULE;\n\nexport interface LambdaFunctionDetails {\n /**\n * The normalized name of the lambda handler project\n */\n readonly normalizedFunctionName: string;\n /**\n * The full package name of the lambda handler construct\n */\n readonly fullyQualifiedFunctionName: string;\n /**\n * The normalized python path to the lambda handler file in dot notation (e.g. `app.lambda_functions.lambda_handler`)\n */\n readonly normalizedFunctionPath: string;\n}\n\nconst getLambdaFunctionDetails = (\n tree: Tree,\n schema: { moduleName: string; name: string; functionPath?: string },\n): LambdaFunctionDetails => {\n const scope = toSnakeCase(getNpmScope(tree));\n const normalizedFunctionName = toSnakeCase(schema.name);\n const fullyQualifiedFunctionName = `${scope}.${normalizedFunctionName}`;\n const normalizedFunctionPath = `${schema.moduleName}.${schema.functionPath ? `${toDotNotation(schema.functionPath)}.` : ''}${normalizedFunctionName}.lambda_handler`;\n\n return {\n fullyQualifiedFunctionName,\n normalizedFunctionName,\n normalizedFunctionPath,\n };\n};\n\n/**\n * Generates a Python Lambda Function to add to a python project\n */\nexport const pyLambdaFunctionGenerator = async (\n tree: Tree,\n schema: PyLambdaFunctionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const projectConfig = readProjectConfigurationUnqualified(\n tree,\n schema.project,\n );\n\n const pyProjectPath = joinPathFragments(projectConfig.root, 'pyproject.toml');\n\n // Check if the project has a pyproject.toml file\n if (!pyProjectPath) {\n throw new Error(\n `This generator does not support selected project ${schema.project}`,\n );\n }\n\n if (!projectConfig.sourceRoot) {\n throw new Error(\n `This project does not have a source root. Please add a source root to the project configuration before running this generator.`,\n );\n }\n\n const dir = projectConfig.root;\n const projectNameWithOutScope = projectConfig.name.split('.').pop();\n const normalizedProjectName = toSnakeCase(projectNameWithOutScope);\n\n // Module name is the last part of the source root,\n const sourceParts = projectConfig.sourceRoot.split('/');\n const moduleName = sourceParts[sourceParts.length - 1];\n\n const { normalizedFunctionName, normalizedFunctionPath } =\n getLambdaFunctionDetails(tree, {\n moduleName,\n name: schema.name,\n functionPath: schema.functionPath,\n });\n\n const constructFunctionName = `${normalizedProjectName}_${normalizedFunctionName}`;\n const constructFunctionClassName = toClassName(constructFunctionName);\n const constructFunctionKebabCase = toKebabCase(constructFunctionName);\n const lambdaFunctionClassName = toClassName(schema.name);\n const lambdaFunctionKebabCase = toKebabCase(schema.name);\n\n const functionPath = joinPathFragments(\n projectConfig.sourceRoot,\n schema.functionPath ?? '',\n `${normalizedFunctionName}.py`,\n );\n\n const infra = schema.infra ?? 'lambda';\n const handlerAlreadyExists = tree.exists(functionPath);\n\n if (handlerAlreadyExists && infra === 'none') {\n throw new Error(\n `This project already has a lambda function with the name ${normalizedFunctionName}. Please remove the lambda function before running this generator or use a different name.`,\n );\n }\n\n // Check if the project has a bundle target and if not add it\n const { bundleOutputDir } = addPythonBundleTarget(projectConfig);\n\n // Recorded below so the version sync can tell a CDK project from a\n // Terraform one; undefined when no infrastructure was generated.\n const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;\n\n if (infra !== 'none') {\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addLambdaFunctionInfra(tree, {\n functionProjectName: projectConfig.name,\n nameClassName: constructFunctionClassName,\n nameKebabCase: constructFunctionKebabCase,\n handler: normalizedFunctionPath,\n bundlePathFromRoot: bundleOutputDir,\n runtime: 'python',\n iac,\n });\n }\n\n const enhancedOptions = {\n ...schema,\n dir,\n lambdaFunctionClassName,\n lambdaFunctionSnakeCase: normalizedFunctionName,\n eventModule: eventModuleFor(schema.event ?? 'Any'),\n };\n\n projectConfig.targets = sortObjectKeys(projectConfig.targets);\n updateProjectConfiguration(tree, projectConfig.name, projectConfig);\n\n // Generate the lambda handler file\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, 'files', 'handler'), // path to the file templates\n joinPathFragments(projectConfig.sourceRoot, schema.functionPath ?? ''),\n enhancedOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Generate the lambda handler test file\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'tests'),\n joinPathFragments(dir, 'tests'),\n enhancedOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n addPyDependencies(tree, DEPENDENCIES, { projectRoot: dir });\n\n addComponentGeneratorMetadata(\n tree,\n projectConfig.name,\n LAMBDA_FUNCTION_GENERATOR_INFO,\n toProjectRelativePath(projectConfig, functionPath),\n lambdaFunctionKebabCase,\n iac ? { iac } : {},\n );\n\n await addGeneratorMetricsIfApplicable(tree, [LAMBDA_FUNCTION_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\nexport default pyLambdaFunctionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addPyDependencies","addPythonBundleTarget","declareDependencies","ownedElsewhere","formatFilesInSubtree","addLambdaFunctionInfra","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toDotNotation","toKebabCase","toSnakeCase","getNpmScope","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","toProjectRelativePath","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","DEPENDENCIES","ts","py","name","LAMBDA_FUNCTION_GENERATOR_INFO","filename","PARSER_MODELS_MODULE","eventModuleFor","event","startsWith","getLambdaFunctionDetails","tree","schema","scope","normalizedFunctionName","fullyQualifiedFunctionName","normalizedFunctionPath","moduleName","functionPath","pyLambdaFunctionGenerator","projectConfig","project","pyProjectPath","root","Error","sourceRoot","dir","projectNameWithOutScope","split","pop","normalizedProjectName","sourceParts","length","constructFunctionName","constructFunctionClassName","constructFunctionKebabCase","lambdaFunctionClassName","lambdaFunctionKebabCase","infra","handlerAlreadyExists","exists","bundleOutputDir","iac","undefined","functionProjectName","nameClassName","nameKebabCase","handler","bundlePathFromRoot","runtime","enhancedOptions","lambdaFunctionSnakeCase","eventModule","targets","dirname","overwriteStrategy","KeepExisting","projectRoot","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,sBAAsB,QAAQ,yDAAyD;AAChG,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SACEC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,WAAW,QACN,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,6BAA6B,EAC7BC,gBAAgB,EAEhBC,mCAAmC,QAC9B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hB,uBAAuB2B,MAAM;YACjCiC,qBAAqBxB,cAAcjB,IAAI;YACvC0C,eAAeX;YACfY,eAAeX;YACfY,SAAS/B;YACTgC,oBAAoBP;YACpBQ,SAAS;YACTP;QACF;IACF;IAEA,MAAMQ,kBAAkB;QACtB,GAAGtC,MAAM;QACTc;QACAU;QACAe,yBAAyBrC;QACzBsC,aAAa7C,eAAeK,OAAOJ,KAAK,IAAI;IAC9C;IAEAY,cAAciC,OAAO,GAAGzD,eAAewB,cAAciC,OAAO;IAC5D3E,2BAA2BiC,MAAMS,cAAcjB,IAAI,EAAEiB;IAErD,mCAAmC;IACnC7C,cACEoC,MACAnC,kBAAkB,YAAY8E,OAAO,EAAE,SAAS,YAChD9E,kBAAkB4C,cAAcK,UAAU,EAAEb,OAAOM,YAAY,IAAI,KACnEgC,iBACA;QAAEK,mBAAmB9E,kBAAkB+E,YAAY;IAAC;IAGtD,wCAAwC;IACxCjF,cACEoC,MACAnC,kBAAkB,YAAY8E,OAAO,EAAE,SAAS,UAChD9E,kBAAkBkD,KAAK,UACvBwB,iBACA;QAAEK,mBAAmB9E,kBAAkB+E,YAAY;IAAC;IAGtD7E,kBAAkBgC,MAAMX,cAAc;QAAEyD,aAAa/B;IAAI;IAEzDjC,8BACEkB,MACAS,cAAcjB,IAAI,EAClBC,gCACAP,sBAAsBuB,eAAeF,eACrCmB,yBACAK,MAAM;QAAEA;IAAI,IAAI,CAAC;IAGnB,MAAMvD,gCAAgCwB,MAAM;QAACP;KAA+B;IAE5E,MAAMrB,qBAAqB4B;IAE3B,OAAO,IACLzB,oBAAoByB,MAAMC,OAAO8C,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AACF,eAAexC,0BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/lambda-function/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac';\n\ntype EventSource =\n | 'Any'\n | 'AlbModel'\n | 'APIGatewayProxyEventModel'\n | 'ApiGatewayAuthorizerToken'\n | 'ApiGatewayAuthorizerRequest'\n | 'APIGatewayProxyEventV2Model'\n | 'ApiGatewayAuthorizerRequestV2'\n | 'APIGatewayWebSocketMessageEventModel'\n | 'APIGatewayWebSocketConnectEventModel'\n | 'APIGatewayWebSocketDisconnectEventModel'\n | 'BedrockAgentEventModel'\n | 'CloudFormationCustomResourceCreateModel'\n | 'CloudFormationCustomResourceUpdateModel'\n | 'CloudFormationCustomResourceDeleteModel'\n | 'CloudwatchLogsModel'\n | 'DynamoDBStreamModel'\n | 'EventBridgeModel'\n | 'IoTCoreThingEvent'\n | 'IoTCoreThingTypeEvent'\n | 'IoTCoreThingTypeAssociationEvent'\n | 'IoTCoreThingGroupEvent'\n | 'IoTCoreAddOrRemoveFromThingGroupEvent'\n | 'IoTCoreAddOrDeleteFromThingGroupEvent'\n | 'KafkaMskEventModel'\n | 'KafkaSelfManagedEventModel'\n | 'KinesisDataStreamModel'\n | 'KinesisFirehoseModel'\n | 'KinesisFirehoseSqsModel'\n | 'LambdaFunctionUrlModel'\n | 'S3BatchOperationModel'\n | 'S3EventNotificationEventBridgeModel'\n | 'S3Model'\n | 'S3ObjectLambdaEvent'\n | 'S3SqsEventNotificationModel'\n | 'SesModel'\n | 'SnsModel'\n | 'SqsModel'\n | 'TransferFamilyAuthorizer'\n | 'VpcLatticeModel'\n | 'VpcLatticeV2Model';\n\nexport type LambdaInfraOption = 'lambda' | 'none';\n\nexport interface PyLambdaFunctionGeneratorSchema {\n readonly project: string;\n readonly name: string;\n readonly functionPath?: string;\n readonly event?: EventSource;\n readonly infra?: LambdaInfraOption;\n readonly iac: IacOption;\n readonly preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAgDD,WAQC"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/lambda-function/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac.js';\n\ntype EventSource =\n | 'Any'\n | 'AlbModel'\n | 'APIGatewayProxyEventModel'\n | 'ApiGatewayAuthorizerToken'\n | 'ApiGatewayAuthorizerRequest'\n | 'APIGatewayProxyEventV2Model'\n | 'ApiGatewayAuthorizerRequestV2'\n | 'APIGatewayWebSocketMessageEventModel'\n | 'APIGatewayWebSocketConnectEventModel'\n | 'APIGatewayWebSocketDisconnectEventModel'\n | 'BedrockAgentEventModel'\n | 'CloudFormationCustomResourceCreateModel'\n | 'CloudFormationCustomResourceUpdateModel'\n | 'CloudFormationCustomResourceDeleteModel'\n | 'CloudWatchLogsModel'\n | 'DynamoDBStreamModel'\n | 'EventBridgeModel'\n | 'IoTCoreThingEvent'\n | 'IoTCoreThingTypeEvent'\n | 'IoTCoreThingTypeAssociationEvent'\n | 'IoTCoreThingGroupEvent'\n | 'IoTCoreAddOrRemoveFromThingGroupEvent'\n | 'IoTCoreAddOrDeleteFromThingGroupEvent'\n | 'KafkaMskEventModel'\n | 'KafkaSelfManagedEventModel'\n | 'KinesisDataStreamModel'\n | 'KinesisFirehoseModel'\n | 'KinesisFirehoseSqsModel'\n | 'LambdaFunctionUrlModel'\n | 'S3BatchOperationModel'\n | 'S3EventNotificationEventBridgeModel'\n | 'S3Model'\n | 'S3ObjectLambdaEvent'\n | 'S3SqsEventNotificationModel'\n | 'SesModel'\n | 'SnsModel'\n | 'SqsModel'\n | 'TransferFamilyAuthorizer'\n | 'VpcLatticeModel'\n | 'VpcLatticeV2Model';\n\nexport type LambdaInfraOption = 'lambda' | 'none';\n\nexport interface PyLambdaFunctionGeneratorSchema {\n readonly project: string;\n readonly name: string;\n readonly functionPath?: string;\n readonly event?: EventSource;\n readonly infra?: LambdaInfraOption;\n readonly iac: IacOption;\n readonly preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAgDD,WAQC"}
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { IacOption } from '../../utils/iac';
6
+ import { IacOption } from '../../utils/iac.js';
7
7
 
8
8
  type EventSource =
9
9
  | 'Any'
@@ -20,7 +20,7 @@ type EventSource =
20
20
  | 'CloudFormationCustomResourceCreateModel'
21
21
  | 'CloudFormationCustomResourceUpdateModel'
22
22
  | 'CloudFormationCustomResourceDeleteModel'
23
- | 'CloudwatchLogsModel'
23
+ | 'CloudWatchLogsModel'
24
24
  | 'DynamoDBStreamModel'
25
25
  | 'EventBridgeModel'
26
26
  | 'IoTCoreThingEvent'
@@ -45,7 +45,7 @@
45
45
  "CloudFormationCustomResourceCreateModel",
46
46
  "CloudFormationCustomResourceUpdateModel",
47
47
  "CloudFormationCustomResourceDeleteModel",
48
- "CloudwatchLogsModel",
48
+ "CloudWatchLogsModel",
49
49
  "DynamoDBStreamModel",
50
50
  "EventBridgeModel",
51
51
  "IoTCoreThingEvent",
@@ -3,8 +3,8 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type GeneratorCallback, type Tree } from '@nx/devkit';
6
- import { type NxGeneratorInfo } from '../../utils/nx';
7
- import type { IacMetadata } from '../../utils/shared-constructs-constants';
6
+ import { type NxGeneratorInfo } from '../../utils/nx.js';
7
+ import type { IacMetadata } from '../../utils/shared-constructs-constants.js';
8
8
  import type { PyMcpServerGeneratorSchema } from './schema';
9
9
  /** The metadata this generator records, which its predicates read. */
10
10
  export interface PyMcpServerMetadata extends IacMetadata {
@@ -12,7 +12,7 @@ export interface PyMcpServerMetadata extends IacMetadata {
12
12
  readonly rc: string;
13
13
  readonly auth: string;
14
14
  }
15
- export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
15
+ export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
16
16
  readonly name: "@modelcontextprotocol/inspector";
17
17
  readonly dev: true;
18
18
  readonly root: true;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/mcp-server/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport {\n addPyDependencies,\n addTsDependencies,\n} from '../../utils/add-dependencies';\nimport { addMcpServerInfra } from '../../utils/agent-core-constructs/agent-core-constructs';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport { addDockerScanTarget, DOCKER_DEPENDENCIES } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, toClassName, toSnakeCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { toProjectRelativePath } from '../../utils/paths';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants';\nimport { BASE_IMAGES } from '../../utils/versions';\nimport type { PyMcpServerGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface PyMcpServerMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n}\n\nexport const DEPENDENCIES = declareDependencies<PyMcpServerMetadata>()({\n ts: [\n // The MCP inspector is shared tooling.\n { name: '@modelcontextprotocol/inspector', dev: true, root: true },\n // Added by the helpers that own the projects they belong to.\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: [\n { name: 'aws-lambda-powertools' },\n { name: 'mcp' },\n { name: 'uvicorn' },\n { name: 'boto3' },\n { name: 'aws-opentelemetry-distro' },\n ],\n});\n\nexport const PY_MCP_SERVER_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const pyMcpServerGenerator = async (\n tree: Tree,\n options: PyMcpServerGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n const pyProjectPath = joinPathFragments(project.root, 'pyproject.toml');\n\n // Check if the project has a pyproject.toml file\n if (!pyProjectPath) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a Python project (with a pyproject.toml)`,\n );\n }\n\n if (!project.sourceRoot) {\n throw new Error(\n `This project does not have a source root. Please add a source root to the project configuration before running this generator.`,\n );\n }\n\n // Module name is the last part of the source root,\n const sourceParts = project.sourceRoot.split('/');\n const moduleName = sourceParts[sourceParts.length - 1];\n\n const name = kebabCase(\n options.name || `${kebabCase(project.name.split('.').pop())}-mcp-server`,\n );\n const mcpTargetPrefix = options.name ? name : 'mcp-server';\n\n const mcpServerNameSnakeCase = toSnakeCase(options.name || 'mcp-server');\n const mcpServerNameClassName = toClassName(name);\n\n const targetSourceDir = joinPathFragments(\n project.sourceRoot,\n mcpServerNameSnakeCase,\n );\n\n const infra = options.infra ?? 'agentcore';\n\n // Recorded in the metadata below so the version sync can tell a CDK\n // project from a Terraform one; undefined when no infrastructure was\n // generated, in which case neither provider's packages were added.\n const iac =\n infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'app'),\n targetSourceDir,\n {\n name,\n mcpServerNameSnakeCase,\n mcpServerNameClassName,\n moduleName,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n if (infra === 'agentcore') {\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n const { bundleTargetName, bundleOutputDir } = addPythonBundleTarget(\n project,\n {\n pythonPlatform: 'aarch64-manylinux_2_28',\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n {\n mcpServerNameSnakeCase,\n moduleName,\n bundleOutputDir,\n pythonBaseImage: BASE_IMAGES.python,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'docker',\n name,\n );\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n // Add a docker target that prepares the docker context and builds the image\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(dockerOutputDir),\n fs.mkdir(dockerOutputDir),\n fs.cp(bundleOutputDir, dockerOutputDir),\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: [bundleTargetName],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project,\n containerEngine: containers,\n trivyTargetName: `${mcpTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n },\n DEPENDENCIES,\n );\n\n // Add shared constructs\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n\n // Add the construct to deploy the mcp server\n await addMcpServerInfra(tree, {\n mcpServerNameKebabCase: name,\n mcpServerNameClassName,\n projectName: project.name,\n dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n containers,\n });\n }\n\n const localDevPort = assignPort(tree, project, 8000, {\n component: { info: PY_MCP_SERVER_GENERATOR_INFO, name: mcpTargetPrefix },\n });\n\n // Recorded below and read by the declaration's predicates, so the packages\n // added here are exactly the ones the version sync will own.\n const metadata: PyMcpServerMetadata = {\n port: localDevPort,\n rc: mcpServerNameClassName,\n auth,\n ...(iac ? { iac } : {}),\n };\n\n // The MCP inspector has a postinstall script that cascades installs into its\n // client packages, which no-ops when the package is installed as a dependency.\n // Register it as an explicitly-rejected build so pnpm 11's default\n // `strictDepBuilds=true` skips it instead of failing the install.\n registerPnpmBuiltDependencies(tree, {\n '@modelcontextprotocol/inspector': false,\n });\n\n addPyDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n addTsDependencies(tree, DEPENDENCIES, { metadata });\n\n const mcpTargets = {\n ...project.targets,\n // Add targets for running the MCP server\n [`${mcpTargetPrefix}-serve-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`uv run -m ${moduleName}.${mcpServerNameSnakeCase}.stdio`],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `uv run uvicorn --reload ${moduleName}.${mcpServerNameSnakeCase}.http:app --host 0.0.0.0 --port ${localDevPort}`,\n ],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${mcpTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `uv run uvicorn --reload ${moduleName}.${mcpServerNameSnakeCase}.http:app --host 0.0.0.0 --port ${localDevPort}`,\n ],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${mcpTargetPrefix}-inspect`]: {\n executor: 'nx:run-commands',\n continuous: true,\n // Launch the inspector against the locally served HTTP server. The dev\n // target starts the server and any connected dependencies (e.g. a local\n // database).\n dependsOn: [`${mcpTargetPrefix}-dev`],\n options: {\n commands: [\n `mcp-inspector --transport http --server-url http://localhost:${localDevPort}/mcp`,\n ],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-inspect-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `mcp-inspector -- uv run -m ${moduleName}.${mcpServerNameSnakeCase}.stdio`,\n ],\n cwd: '{projectRoot}',\n },\n },\n };\n\n // Aggregate `<mcp>-dev` under the project-level `dev` target.\n addComponentDevTarget(mcpTargets, `${mcpTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n targets: mcpTargets,\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n PY_MCP_SERVER_GENERATOR_INFO,\n toProjectRelativePath(project, targetSourceDir),\n mcpTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [PY_MCP_SERVER_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyMcpServerGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addPyDependencies","addTsDependencies","addMcpServerInfra","addPythonBundleTarget","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toSnakeCase","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","registerPnpmBuiltDependencies","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","DEPENDENCIES","ts","name","dev","root","py","PY_MCP_SERVER_GENERATOR_INFO","filename","pyMcpServerGenerator","tree","options","project","pyProjectPath","Error","sourceRoot","sourceParts","split","moduleName","length","pop","mcpTargetPrefix","mcpServerNameSnakeCase","mcpServerNameClassName","targetSourceDir","infra","iac","undefined","auth","console","warn","dirname","overwriteStrategy","KeepExisting","containers","dockerImageTag","bundleTargetName","bundleOutputDir","pythonPlatform","pythonBaseImage","python","dockerOutputDir","dockerTargetName","fs","targets","cache","executor","commands","rm","mkdir","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","mcpServerNameKebabCase","projectName","localDevPort","component","info","metadata","port","rc","projectRoot","mcpTargets","continuous","cwd","env","PORT","LOCAL_DEV","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,kCAA+B;AACtC,SAASC,iBAAiB,QAAQ,6DAA0D;AAC5F,SAASC,qBAAqB,QAAQ,+BAA4B;AAClE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,wBAAqB;AAC9E,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,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AAU;YACVoB,YAAY;YACZ,uEAAuE;YACvE,wEAAwE;YACxE,aAAa;YACbd,WAAW;gBAAC,GAAG/B,gBAAgB,IAAI,CAAC;aAAC;YACrCV,SAAS;gBACPoC,UAAU;oBACR,CAAC,6DAA6D,EAAEW,aAAa,IAAI,CAAC;iBACnF;gBACDS,KAAK;YACP;QACF;QACA,CAAC,GAAG9C,gBAAgB,cAAc,CAAC,CAAC,EAAE;YACpCyB,UAAU;YACVoB,YAAY;YACZvD,SAAS;gBACPoC,UAAU;oBACR,CAAC,2BAA2B,EAAE7B,WAAW,CAAC,EAAEI,uBAAuB,MAAM,CAAC;iBAC3E;gBACD6C,KAAK;YACP;QACF;IACF;IAEA,8DAA8D;IAC9D7E,sBAAsB2E,YAAY,GAAG5C,gBAAgB,IAAI,CAAC;IAE1DnD,2BAA2BwC,MAAME,QAAQT,IAAI,EAAE;QAC7C,GAAGS,OAAO;QACVgC,SAASqB;IACX;IAEA1E,8BACEmB,MACAE,QAAQT,IAAI,EACZI,8BACAZ,sBAAsBiB,SAASY,kBAC/BH,iBACAwC;IAGF,MAAM5E,gCAAgCyB,MAAM;QAACH;KAA6B;IAE1E,MAAM3B,qBAAqB8B;IAC3B,OAAO,IACL1B,oBAAoB0B,MAAMC,QAAQ4D,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAe/D,qBAAqB"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/mcp-server/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport {\n addPyDependencies,\n addTsDependencies,\n} from '../../utils/add-dependencies.js';\nimport { addMcpServerInfra } from '../../utils/agent-core-constructs/agent-core-constructs.js';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle.js';\nimport { resolveContainers } from '../../utils/containers.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport {\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n} from '../../utils/docker.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { kebabCase, toClassName, toSnakeCase } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx.js';\nimport { toProjectRelativePath } from '../../utils/paths.js';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace.js';\nimport { assignPort } from '../../utils/port.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants.js';\nimport { BASE_IMAGES } from '../../utils/versions.js';\nimport type { PyMcpServerGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface PyMcpServerMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n}\n\nexport const DEPENDENCIES = declareDependencies<PyMcpServerMetadata>()({\n ts: [\n // The MCP inspector is shared tooling.\n { name: '@modelcontextprotocol/inspector', dev: true, root: true },\n // Added by the helpers that own the projects they belong to.\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: [\n { name: 'aws-lambda-powertools' },\n { name: 'mcp' },\n { name: 'uvicorn' },\n { name: 'boto3' },\n { name: 'aws-opentelemetry-distro' },\n ],\n});\n\nexport const PY_MCP_SERVER_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const pyMcpServerGenerator = async (\n tree: Tree,\n options: PyMcpServerGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n const pyProjectPath = joinPathFragments(project.root, 'pyproject.toml');\n\n // Check if the project has a pyproject.toml file\n if (!pyProjectPath) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a Python project (with a pyproject.toml)`,\n );\n }\n\n if (!project.sourceRoot) {\n throw new Error(\n `This project does not have a source root. Please add a source root to the project configuration before running this generator.`,\n );\n }\n\n // Module name is the last part of the source root,\n const sourceParts = project.sourceRoot.split('/');\n const moduleName = sourceParts[sourceParts.length - 1];\n\n const name = kebabCase(\n options.name || `${kebabCase(project.name.split('.').pop())}-mcp-server`,\n );\n const mcpTargetPrefix = options.name ? name : 'mcp-server';\n\n const mcpServerNameSnakeCase = toSnakeCase(options.name || 'mcp-server');\n const mcpServerNameClassName = toClassName(name);\n\n const targetSourceDir = joinPathFragments(\n project.sourceRoot,\n mcpServerNameSnakeCase,\n );\n\n const infra = options.infra ?? 'agentcore';\n\n // Recorded in the metadata below so the version sync can tell a CDK\n // project from a Terraform one; undefined when no infrastructure was\n // generated, in which case neither provider's packages were added.\n const iac =\n infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'app'),\n targetSourceDir,\n {\n name,\n mcpServerNameSnakeCase,\n mcpServerNameClassName,\n moduleName,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n if (infra === 'agentcore') {\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n const { bundleTargetName, bundleOutputDir } = addPythonBundleTarget(\n project,\n {\n pythonPlatform: 'aarch64-manylinux_2_28',\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n {\n mcpServerNameSnakeCase,\n moduleName,\n bundleOutputDir,\n pythonBaseImage: BASE_IMAGES.python,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'docker',\n name,\n );\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n // Add a docker target that prepares the docker context and builds the image\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(dockerOutputDir),\n fs.mkdir(dockerOutputDir),\n fs.cp(bundleOutputDir, dockerOutputDir),\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: [bundleTargetName],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project,\n containerEngine: containers,\n trivyTargetName: `${mcpTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n },\n DEPENDENCIES,\n );\n\n // Add shared constructs\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n\n // Add the construct to deploy the mcp server\n await addMcpServerInfra(tree, {\n mcpServerNameKebabCase: name,\n mcpServerNameClassName,\n projectName: project.name,\n dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n containers,\n });\n }\n\n const localDevPort = assignPort(tree, project, 8000, {\n component: { info: PY_MCP_SERVER_GENERATOR_INFO, name: mcpTargetPrefix },\n });\n\n // Recorded below and read by the declaration's predicates, so the packages\n // added here are exactly the ones the version sync will own.\n const metadata: PyMcpServerMetadata = {\n port: localDevPort,\n rc: mcpServerNameClassName,\n auth,\n ...(iac ? { iac } : {}),\n };\n\n // The MCP inspector has a postinstall script that cascades installs into its\n // client packages, which no-ops when the package is installed as a dependency.\n // Register it as an explicitly-rejected build so pnpm 11's default\n // `strictDepBuilds=true` skips it instead of failing the install.\n registerPnpmBuiltDependencies(tree, {\n '@modelcontextprotocol/inspector': false,\n });\n\n addPyDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n addTsDependencies(tree, DEPENDENCIES, { metadata });\n\n const mcpTargets = {\n ...project.targets,\n // Add targets for running the MCP server\n [`${mcpTargetPrefix}-serve-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`uv run -m ${moduleName}.${mcpServerNameSnakeCase}.stdio`],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `uv run uvicorn --reload ${moduleName}.${mcpServerNameSnakeCase}.http:app --host 0.0.0.0 --port ${localDevPort}`,\n ],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${mcpTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `uv run uvicorn --reload ${moduleName}.${mcpServerNameSnakeCase}.http:app --host 0.0.0.0 --port ${localDevPort}`,\n ],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${mcpTargetPrefix}-inspect`]: {\n executor: 'nx:run-commands',\n continuous: true,\n // Launch the inspector against the locally served HTTP server. The dev\n // target starts the server and any connected dependencies (e.g. a local\n // database).\n dependsOn: [`${mcpTargetPrefix}-dev`],\n options: {\n commands: [\n `mcp-inspector --transport http --server-url http://localhost:${localDevPort}/mcp`,\n ],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-inspect-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `mcp-inspector -- uv run -m ${moduleName}.${mcpServerNameSnakeCase}.stdio`,\n ],\n cwd: '{projectRoot}',\n },\n },\n };\n\n // Aggregate `<mcp>-dev` under the project-level `dev` target.\n addComponentDevTarget(mcpTargets, `${mcpTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n targets: mcpTargets,\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n PY_MCP_SERVER_GENERATOR_INFO,\n toProjectRelativePath(project, targetSourceDir),\n mcpTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [PY_MCP_SERVER_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyMcpServerGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addPyDependencies","addTsDependencies","addMcpServerInfra","addPythonBundleTarget","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toSnakeCase","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","registerPnpmBuiltDependencies","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","DEPENDENCIES","ts","name","dev","root","py","PY_MCP_SERVER_GENERATOR_INFO","filename","pyMcpServerGenerator","tree","options","project","pyProjectPath","Error","sourceRoot","sourceParts","split","moduleName","length","pop","mcpTargetPrefix","mcpServerNameSnakeCase","mcpServerNameClassName","targetSourceDir","infra","iac","undefined","auth","console","warn","dirname","overwriteStrategy","KeepExisting","containers","dockerImageTag","bundleTargetName","bundleOutputDir","pythonPlatform","pythonBaseImage","python","dockerOutputDir","dockerTargetName","fs","targets","cache","executor","commands","rm","mkdir","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","mcpServerNameKebabCase","projectName","localDevPort","component","info","metadata","port","rc","projectRoot","mcpTargets","continuous","cwd","env","PORT","LOCAL_DEV","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,kCAAkC;AACzC,SAASC,iBAAiB,QAAQ,6DAA6D;AAC/F,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SACEC,mBAAmB,EACnBC,mBAAmB,QACd,wBAAwB;AAC/B,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAoB;AAChE,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,SAAS,EAAEC,WAAW,EAAEC,WAAW,QAAQ,uBAAuB;AAC3E,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,qBAAqB,EACrBC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAoB;AAC3B,SAASC,qBAAqB,QAAQ,uBAAuB;AAC7D,SAASC,6BAA6B,QAAQ,gCAAgC;AAC9E,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SACEC,8BAA8B,EAC9BC,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CAAC;iBAC3E;gBACD6C,KAAK;YACP;QACF;IACF;IAEA,8DAA8D;IAC9D7E,sBAAsB2E,YAAY,GAAG5C,gBAAgB,IAAI,CAAC;IAE1DnD,2BAA2BwC,MAAME,QAAQT,IAAI,EAAE;QAC7C,GAAGS,OAAO;QACVgC,SAASqB;IACX;IAEA1E,8BACEmB,MACAE,QAAQT,IAAI,EACZI,8BACAZ,sBAAsBiB,SAASY,kBAC/BH,iBACAwC;IAGF,MAAM5E,gCAAgCyB,MAAM;QAACH;KAA6B;IAE1E,MAAM3B,qBAAqB8B;IAC3B,OAAO,IACL1B,oBAAoB0B,MAAMC,QAAQ4D,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAe/D,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/mcp-server/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac';\n\nexport type PyMcpServerInfra = 'none' | 'agentcore';\n\nexport type PyMcpServerAuth = 'iam' | 'cognito';\n\nexport interface PyMcpServerGeneratorSchema {\n project: string;\n name?: string;\n infra?: PyMcpServerInfra;\n auth?: PyMcpServerAuth;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAQD,WAOC"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/mcp-server/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac.js';\n\nexport type PyMcpServerInfra = 'none' | 'agentcore';\n\nexport type PyMcpServerAuth = 'iam' | 'cognito';\n\nexport interface PyMcpServerGeneratorSchema {\n project: string;\n name?: string;\n infra?: PyMcpServerInfra;\n auth?: PyMcpServerAuth;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAQD,WAOC"}
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { IacOption } from '../../utils/iac';
6
+ import { IacOption } from '../../utils/iac.js';
7
7
 
8
8
  export type PyMcpServerInfra = 'none' | 'agentcore';
9
9
 
@@ -3,9 +3,9 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type GeneratorCallback, type Tree } from '@nx/devkit';
6
- import { type NxGeneratorInfo } from '../../utils/nx';
6
+ import { type NxGeneratorInfo } from '../../utils/nx.js';
7
7
  import type { PyProjectGeneratorSchema } from './schema';
8
- export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
8
+ export declare const DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
9
9
  readonly name: "@nxlv/python";
10
10
  readonly dev: true;
11
11
  readonly root: true;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n ensurePackage,\n type GeneratorCallback,\n joinPathFragments,\n readNxJson,\n readProjectConfiguration,\n type Tree,\n updateNxJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport {\n addLicenseCheckToLintTarget,\n ensurePythonLicenseCollector,\n} from '../../license/config';\nimport {\n addPyDependencies,\n addTsDependencies,\n} from '../../utils/add-dependencies';\nimport { declareDependencies } from '../../utils/declared-dependencies';\nimport { updateGitIgnore } from '../../utils/git';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { normalizeDistributionName, toSnakeCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport type { UVPyprojectToml } from '../../utils/nxlv-python';\nimport {\n migrateToSharedVenvGenerator,\n uvProjectGenerator,\n} from '../../utils/nxlv-python';\nimport { sortObjectKeys } from '../../utils/object';\nimport { updateToml } from '../../utils/toml';\nimport { withVersions } from '../../utils/versions';\nimport type { PyProjectGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [{ name: '@nxlv/python', dev: true, root: true }],\n py: [\n // The linting and type checking tools live in the workspace root pyproject.\n // Pinned to the version generation-time formatting uses, so generated files\n // stay `ruff format --check`-clean across ruff releases.\n { name: 'ruff', group: 'dev', root: true },\n { name: 'ty', group: 'dev', root: true },\n ],\n});\n\nexport const PY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n// Transient artifacts that pytest, coverage and ruff create and remove while\n// the test, typecheck and compile targets run concurrently. `.coverage.*` are\n// the per-process data files pytest-cov writes (`.coverage.<host>.<pid>.<rand>`)\n// before combining them. Both `ty` (which respects .gitignore) and the\n// `@nxlv/python:build` copy (which respects `ignorePaths`) would otherwise fail\n// when they read one of these mid-deletion.\nconst PYTHON_TRANSIENT_ARTIFACTS = [\n '__pycache__',\n '.coverage',\n '.coverage.*',\n '.pytest_cache',\n 'pytest-cache-files-*',\n '.ruff_cache',\n];\n\nexport interface PyProjectDetails {\n /**\n * Fully qualified Nx project id including scope, in dot notation (eg foo.bar).\n * This is the identifier Nx uses (readProjectConfiguration, the project\n * graph, target references) and is intentionally kept dotted.\n */\n readonly fullyQualifiedName: string;\n /**\n * PEP 503 normalised Python distribution name (eg foo-bar). This is the name\n * written to the project's `[project].name`, the root `[tool.uv.sources]`\n * key, and any inter-project dependency string. It is hyphenated (not dotted)\n * so `uv` and `@nxlv/python` can match it: uv writes `uv.lock` keyed by the\n * PEP 503 hyphenated name, and `@nxlv/python`'s dependency inference splits a\n * dotted name on `.` and so would otherwise drop the edge entirely. Keeping\n * the distribution name decoupled from `fullyQualifiedName` is what lets the\n * workspace dependency edge appear in the Nx project graph.\n */\n readonly distributionName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n /**\n * Module name for the project\n */\n readonly normalizedModuleName: string;\n}\n\n/**\n * Returns details about the Python project to be created\n */\nexport const getPyProjectDetails = (\n tree: Tree,\n schema: {\n name: string;\n directory?: string;\n subDirectory?: string;\n moduleName?: string;\n },\n): PyProjectDetails => {\n const scope = toSnakeCase(getNpmScope(tree));\n const normalizedName = toSnakeCase(schema.name);\n const normalizedModuleName = toSnakeCase(\n schema.moduleName ?? `${scope}_${normalizedName}`,\n );\n const fullyQualifiedName = `${scope}.${normalizedName}`;\n // The Python distribution name is the PEP 503 normalised form of the\n // fully qualified name: hyphenated, never dotted. See PyProjectDetails.\n const distributionName = normalizeDistributionName(fullyQualifiedName);\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || normalizedName,\n );\n return { dir, fullyQualifiedName, distributionName, normalizedModuleName };\n};\n\n/**\n * Generates a Python project\n */\nexport const pyProjectGenerator = async (\n tree: Tree,\n schema: PyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { dir, normalizedModuleName, fullyQualifiedName, distributionName } =\n getPyProjectDetails(tree, schema);\n\n addTsDependencies(tree, DEPENDENCIES);\n\n const pythonPlugin = withVersions(DEPENDENCIES, ['@nxlv/python']);\n Object.entries(pythonPlugin).forEach(([name, version]) =>\n ensurePackage(name, version),\n );\n\n const nxJson = readNxJson(tree);\n\n // Only rewrite nx.json when the plugin needs adding, so re-running does not\n // reserialize (and reformat) the file when nothing has changed.\n if (\n !nxJson.plugins?.find((p) =>\n typeof p === 'string'\n ? p === '@nxlv/python'\n : p.plugin === '@nxlv/python',\n )\n ) {\n nxJson.plugins = [\n ...(nxJson.plugins ?? []),\n {\n plugin: '@nxlv/python',\n options: {\n packageManager: 'uv',\n },\n },\n ];\n updateNxJson(tree, nxJson);\n }\n\n // Only scaffold the project when it does not already exist so re-running with\n // the same name does not throw. The rest of the generator still runs to apply\n // any changed options to the existing project.\n if (!projectExists(tree, fullyQualifiedName)) {\n if (!tree.exists('uv.lock')) {\n await migrateToSharedVenvGenerator(tree, {\n autoActivate: true,\n packageManager: 'uv',\n moveDevDependencies: false,\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n });\n }\n\n await uvProjectGenerator(tree, {\n // The Nx project id (and `uv.workspace.members` etc.) keys off `name`, so\n // keep it dotted. `packageName` is the separate PEP 503 distribution name\n // written to `[project].name` and the root `[tool.uv.sources]` key; it is\n // hyphenated so `@nxlv/python` infers the workspace dependency edge (it\n // splits a dotted name on `.` and would otherwise drop it). This split is\n // the whole fix (see PyProjectDetails.distributionName).\n name: fullyQualifiedName,\n packageName: distributionName,\n publishable: false,\n buildLockedVersions: true,\n buildBundleLocalDependencies: true,\n linter: 'ruff',\n rootPyprojectDependencyGroup: 'main',\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n projectType: schema.type,\n projectNameAndRootFormat: 'as-provided',\n moduleName: normalizedModuleName,\n directory: dir,\n unitTestRunner: 'pytest',\n codeCoverage: true,\n codeCoverageHtmlReport: true,\n codeCoverageXmlReport: true,\n unitTestHtmlReport: true,\n unitTestJUnitReport: true,\n buildSystem: 'hatch',\n srcDir: false,\n });\n\n // Remove generated hello.py and test_hello.py as they are not needed\n [\n joinPathFragments(dir, normalizedModuleName, 'hello.py'),\n joinPathFragments(dir, 'tests', 'test_hello.py'),\n ].forEach((f) => tree.delete(f));\n\n // Add a placeholder test so pytest doesn't fail with \"no tests collected\"\n tree.write(\n joinPathFragments(dir, 'tests', 'test_noop.py'),\n 'def test_noop():\\n pass\\n',\n );\n }\n\n const outputPath = '{workspaceRoot}/dist/{projectRoot}';\n const buildOutputPath = joinPathFragments(outputPath, 'build');\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n projectConfiguration.name = fullyQualifiedName;\n // Derive the compile target from the uv build target, and rewrite build to\n // orchestrate the other targets. This only runs on first creation: on re-run\n // build has already been transformed, so re-deriving would corrupt compile\n // and duplicate the build dependencies.\n if (!projectConfiguration.targets.compile) {\n const buildTarget = projectConfiguration.targets.build;\n projectConfiguration.targets.compile = {\n ...buildTarget,\n inputs: ['default', '^production'],\n outputs: [buildOutputPath],\n options: {\n ...buildTarget.options,\n outputPath: buildOutputPath,\n // The build executor copies the project to a temp folder; exclude the\n // executor defaults plus transient artifacts so the copy does not race\n // a concurrent test/typecheck target deleting a file mid-copy.\n ignorePaths: ['.venv', '.tox', 'tests', ...PYTHON_TRANSIENT_ARTIFACTS],\n },\n };\n projectConfiguration.targets.build = {\n inputs: ['default', '^production'],\n dependsOn: [\n 'lint',\n 'compile',\n 'test',\n 'typecheck',\n ...(buildTarget.dependsOn ?? []),\n ],\n options: {\n outputPath,\n },\n };\n }\n projectConfiguration.targets.typecheck = {\n cache: true,\n inputs: ['default', '^production'],\n executor: '@nxlv/python:run-commands',\n options: {\n command: 'uv run ty check',\n cwd: '{projectRoot}',\n },\n };\n\n // Set the default line length to 120, as 88 is a little too strict\n updateToml(\n tree,\n joinPathFragments(dir, 'pyproject.toml'),\n (pyProjectToml: UVPyprojectToml) => {\n if ((pyProjectToml.tool as any)?.ruff) {\n (pyProjectToml.tool as any).ruff['line-length'] = 120;\n }\n return pyProjectToml;\n },\n );\n\n addPyDependencies(tree, DEPENDENCIES);\n\n // Base format target checks rather than writes (so build/lint don't rewrite\n // source); `fix` writes, and `skip-lint` writes without failing so it stays\n // a no-op when propagated through the lint -> format dependency.\n projectConfiguration.targets.format = {\n ...projectConfiguration.targets.format,\n cache: true,\n inputs: ['default', '^production'],\n options: {\n ...projectConfiguration.targets.format?.options,\n check: true,\n },\n configurations: {\n ...projectConfiguration.targets.format?.configurations,\n fix: {\n check: false,\n },\n 'skip-lint': {\n check: false,\n },\n },\n };\n\n // Add a dependency on the format target for lint in order to reduce the number of\n // fixable lint errors (eg line too long)\n projectConfiguration.targets.lint = {\n ...projectConfiguration.targets.lint,\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n ...projectConfiguration.targets.lint?.configurations,\n fix: {\n fix: true,\n },\n 'skip-lint': {\n exitZero: true,\n },\n },\n };\n // Append `format` without moving an existing entry, so re-running does not\n // reorder lint dependencies (e.g. relative to a later-added license-check).\n addDependencyToTargetIfNotPresent(projectConfiguration, 'lint', 'format');\n\n projectConfiguration.targets = sortObjectKeys(projectConfiguration.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, PY_PROJECT_GENERATOR_INFO);\n\n // Update root .gitignore\n updateGitIgnore(tree, '.', (patterns) => [...patterns, '/reports']);\n\n // Update project level .gitignore. The cache directories are also kept out\n // of type checking: `ty` respects .gitignore, and pytest creates and removes\n // transient `pytest-cache-files-*` directories while the test and typecheck\n // targets run concurrently, which would otherwise make `ty` fail with an I/O\n // error when it scans one mid-deletion.\n updateGitIgnore(tree, dir, (patterns) => [\n ...patterns,\n '**/__pycache__',\n ...PYTHON_TRANSIENT_ARTIFACTS.filter((p) => p !== '__pycache__'),\n ]);\n\n await addGeneratorMetricsIfApplicable(tree, [PY_PROJECT_GENERATOR_INFO]);\n\n await ensurePythonLicenseCollector(tree);\n\n // If license checking is configured, make this project's lint target depend\n // on the root license-check target. No-op if license checking isn't set up;\n // the license generator wires up existing projects itself, so the dependency\n // is added regardless of which generator runs first.\n addLicenseCheckToLintTarget(tree, fullyQualifiedName);\n\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\nexport default pyProjectGenerator;\n"],"names":["ensurePackage","joinPathFragments","readNxJson","readProjectConfiguration","updateNxJson","updateProjectConfiguration","addLicenseCheckToLintTarget","ensurePythonLicenseCollector","addPyDependencies","addTsDependencies","declareDependencies","updateGitIgnore","installDependencies","addGeneratorMetricsIfApplicable","normalizeDistributionName","toSnakeCase","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","projectExists","migrateToSharedVenvGenerator","uvProjectGenerator","sortObjectKeys","updateToml","withVersions","DEPENDENCIES","ts","name","dev","root","py","group","PY_PROJECT_GENERATOR_INFO","filename","PYTHON_TRANSIENT_ARTIFACTS","getPyProjectDetails","tree","schema","scope","normalizedName","normalizedModuleName","moduleName","fullyQualifiedName","distributionName","dir","directory","subDirectory","pyProjectGenerator","pythonPlugin","Object","entries","forEach","version","nxJson","plugins","find","p","plugin","options","packageManager","exists","autoActivate","moveDevDependencies","pyenvPythonVersion","pyprojectPythonDependency","packageName","publishable","buildLockedVersions","buildBundleLocalDependencies","linter","rootPyprojectDependencyGroup","projectType","type","projectNameAndRootFormat","unitTestRunner","codeCoverage","codeCoverageHtmlReport","codeCoverageXmlReport","unitTestHtmlReport","unitTestJUnitReport","buildSystem","srcDir","f","delete","write","outputPath","buildOutputPath","projectConfiguration","targets","compile","buildTarget","build","inputs","outputs","ignorePaths","dependsOn","typecheck","cache","executor","command","cwd","pyProjectToml","tool","ruff","format","check","configurations","fix","lint","exitZero","patterns","filter","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EAEbC,iBAAiB,EACjBC,UAAU,EACVC,wBAAwB,EAExBC,YAAY,EACZC,0BAA0B,QACrB,aAAa;AACpB,SACEC,2BAA2B,EAC3BC,4BAA4B,QACvB,0BAAuB;AAC9B,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,kCAA+B;AACtC,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,yBAAyB,EAAEC,WAAW,QAAQ,uBAAoB;AAC3E,SAASC,WAAW,QAAQ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MAAM,KAAK,CAAC0E,WAAa;eAAIA;YAAU;SAAW;IAElE,2EAA2E;IAC3E,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,wCAAwC;IACxCpG,gBAAgB0B,MAAMQ,KAAK,CAACkE,WAAa;eACpCA;YACH;eACG5E,2BAA2B6E,MAAM,CAAC,CAACvD,IAAMA,MAAM;SACnD;IAED,MAAM5C,gCAAgCwB,MAAM;QAACJ;KAA0B;IAEvE,MAAM1B,6BAA6B8B;IAEnC,4EAA4E;IAC5E,4EAA4E;IAC5E,6EAA6E;IAC7E,qDAAqD;IACrD/B,4BAA4B+B,MAAMM;IAElC,OAAO,IACL/B,oBAAoByB,MAAMC,OAAO2E,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AACF,eAAelE,mBAAmB"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n ensurePackage,\n type GeneratorCallback,\n joinPathFragments,\n readNxJson,\n readProjectConfiguration,\n type Tree,\n updateNxJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport {\n addLicenseCheckToLintTarget,\n ensurePythonLicenseCollector,\n} from '../../license/config.js';\nimport {\n addPyDependencies,\n addTsDependencies,\n} from '../../utils/add-dependencies.js';\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { updateGitIgnore } from '../../utils/git.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { normalizeDistributionName, toSnakeCase } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport type { UVPyprojectToml } from '../../utils/nxlv-python.js';\nimport {\n migrateToSharedVenvGenerator,\n uvProjectGenerator,\n} from '../../utils/nxlv-python.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { updateToml } from '../../utils/toml.js';\nimport { withVersions } from '../../utils/versions.js';\nimport type { PyProjectGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [{ name: '@nxlv/python', dev: true, root: true }],\n py: [\n // The linting and type checking tools live in the workspace root pyproject.\n // Pinned to the version generation-time formatting uses, so generated files\n // stay `ruff format --check`-clean across ruff releases.\n { name: 'ruff', group: 'dev', root: true },\n { name: 'ty', group: 'dev', root: true },\n ],\n});\n\nexport const PY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n// Transient artifacts that pytest, coverage and ruff create and remove while\n// the test, typecheck and compile targets run concurrently. `.coverage.*` are\n// the per-process data files pytest-cov writes (`.coverage.<host>.<pid>.<rand>`)\n// before combining them. Both `ty` (which respects .gitignore) and the\n// `@nxlv/python:build` copy (which respects `ignorePaths`) would otherwise fail\n// when they read one of these mid-deletion.\nconst PYTHON_TRANSIENT_ARTIFACTS = [\n '__pycache__',\n '.coverage',\n '.coverage.*',\n '.pytest_cache',\n 'pytest-cache-files-*',\n '.ruff_cache',\n];\n\nexport interface PyProjectDetails {\n /**\n * Fully qualified Nx project id including scope, in dot notation (eg foo.bar).\n * This is the identifier Nx uses (readProjectConfiguration, the project\n * graph, target references) and is intentionally kept dotted.\n */\n readonly fullyQualifiedName: string;\n /**\n * PEP 503 normalised Python distribution name (eg foo-bar). This is the name\n * written to the project's `[project].name`, the root `[tool.uv.sources]`\n * key, and any inter-project dependency string. It is hyphenated (not dotted)\n * so `uv` and `@nxlv/python` can match it: uv writes `uv.lock` keyed by the\n * PEP 503 hyphenated name, and `@nxlv/python`'s dependency inference splits a\n * dotted name on `.` and so would otherwise drop the edge entirely. Keeping\n * the distribution name decoupled from `fullyQualifiedName` is what lets the\n * workspace dependency edge appear in the Nx project graph.\n */\n readonly distributionName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n /**\n * Module name for the project\n */\n readonly normalizedModuleName: string;\n}\n\n/**\n * Returns details about the Python project to be created\n */\nexport const getPyProjectDetails = (\n tree: Tree,\n schema: {\n name: string;\n directory?: string;\n subDirectory?: string;\n moduleName?: string;\n },\n): PyProjectDetails => {\n const scope = toSnakeCase(getNpmScope(tree));\n const normalizedName = toSnakeCase(schema.name);\n const normalizedModuleName = toSnakeCase(\n schema.moduleName ?? `${scope}_${normalizedName}`,\n );\n const fullyQualifiedName = `${scope}.${normalizedName}`;\n // The Python distribution name is the PEP 503 normalised form of the\n // fully qualified name: hyphenated, never dotted. See PyProjectDetails.\n const distributionName = normalizeDistributionName(fullyQualifiedName);\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || normalizedName,\n );\n return { dir, fullyQualifiedName, distributionName, normalizedModuleName };\n};\n\n/**\n * Generates a Python project\n */\nexport const pyProjectGenerator = async (\n tree: Tree,\n schema: PyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { dir, normalizedModuleName, fullyQualifiedName, distributionName } =\n getPyProjectDetails(tree, schema);\n\n addTsDependencies(tree, DEPENDENCIES);\n\n const pythonPlugin = withVersions(DEPENDENCIES, ['@nxlv/python']);\n Object.entries(pythonPlugin).forEach(([name, version]) =>\n ensurePackage(name, version),\n );\n\n const nxJson = readNxJson(tree);\n\n // Only rewrite nx.json when the plugin needs adding, so re-running does not\n // reserialize (and reformat) the file when nothing has changed.\n if (\n !nxJson.plugins?.find((p) =>\n typeof p === 'string'\n ? p === '@nxlv/python'\n : p.plugin === '@nxlv/python',\n )\n ) {\n nxJson.plugins = [\n ...(nxJson.plugins ?? []),\n {\n plugin: '@nxlv/python',\n options: {\n packageManager: 'uv',\n },\n },\n ];\n updateNxJson(tree, nxJson);\n }\n\n // Only scaffold the project when it does not already exist so re-running with\n // the same name does not throw. The rest of the generator still runs to apply\n // any changed options to the existing project.\n if (!projectExists(tree, fullyQualifiedName)) {\n if (!tree.exists('uv.lock')) {\n await migrateToSharedVenvGenerator(tree, {\n autoActivate: true,\n packageManager: 'uv',\n moveDevDependencies: false,\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n });\n }\n\n await uvProjectGenerator(tree, {\n // The Nx project id (and `uv.workspace.members` etc.) keys off `name`, so\n // keep it dotted. `packageName` is the separate PEP 503 distribution name\n // written to `[project].name` and the root `[tool.uv.sources]` key; it is\n // hyphenated so `@nxlv/python` infers the workspace dependency edge (it\n // splits a dotted name on `.` and would otherwise drop it). This split is\n // the whole fix (see PyProjectDetails.distributionName).\n name: fullyQualifiedName,\n packageName: distributionName,\n publishable: false,\n buildLockedVersions: true,\n buildBundleLocalDependencies: true,\n linter: 'ruff',\n rootPyprojectDependencyGroup: 'main',\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n projectType: schema.type,\n projectNameAndRootFormat: 'as-provided',\n moduleName: normalizedModuleName,\n directory: dir,\n unitTestRunner: 'pytest',\n codeCoverage: true,\n codeCoverageHtmlReport: true,\n codeCoverageXmlReport: true,\n unitTestHtmlReport: true,\n unitTestJUnitReport: true,\n buildSystem: 'hatch',\n srcDir: false,\n });\n\n // Remove generated hello.py and test_hello.py as they are not needed\n [\n joinPathFragments(dir, normalizedModuleName, 'hello.py'),\n joinPathFragments(dir, 'tests', 'test_hello.py'),\n ].forEach((f) => tree.delete(f));\n\n // Add a placeholder test so pytest doesn't fail with \"no tests collected\"\n tree.write(\n joinPathFragments(dir, 'tests', 'test_noop.py'),\n 'def test_noop():\\n pass\\n',\n );\n }\n\n const outputPath = '{workspaceRoot}/dist/{projectRoot}';\n const buildOutputPath = joinPathFragments(outputPath, 'build');\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n projectConfiguration.name = fullyQualifiedName;\n // Derive the compile target from the uv build target, and rewrite build to\n // orchestrate the other targets. This only runs on first creation: on re-run\n // build has already been transformed, so re-deriving would corrupt compile\n // and duplicate the build dependencies.\n if (!projectConfiguration.targets.compile) {\n const buildTarget = projectConfiguration.targets.build;\n projectConfiguration.targets.compile = {\n ...buildTarget,\n inputs: ['default', '^production'],\n outputs: [buildOutputPath],\n options: {\n ...buildTarget.options,\n outputPath: buildOutputPath,\n // The build executor copies the project to a temp folder; exclude the\n // executor defaults plus transient artifacts so the copy does not race\n // a concurrent test/typecheck target deleting a file mid-copy.\n ignorePaths: ['.venv', '.tox', 'tests', ...PYTHON_TRANSIENT_ARTIFACTS],\n },\n };\n projectConfiguration.targets.build = {\n inputs: ['default', '^production'],\n dependsOn: [\n 'lint',\n 'compile',\n 'test',\n 'typecheck',\n ...(buildTarget.dependsOn ?? []),\n ],\n options: {\n outputPath,\n },\n };\n }\n projectConfiguration.targets.typecheck = {\n cache: true,\n inputs: ['default', '^production'],\n executor: '@nxlv/python:run-commands',\n options: {\n command: 'uv run ty check',\n cwd: '{projectRoot}',\n },\n };\n\n // Set the default line length to 120, as 88 is a little too strict\n updateToml(\n tree,\n joinPathFragments(dir, 'pyproject.toml'),\n (pyProjectToml: UVPyprojectToml) => {\n if ((pyProjectToml.tool as any)?.ruff) {\n (pyProjectToml.tool as any).ruff['line-length'] = 120;\n }\n return pyProjectToml;\n },\n );\n\n addPyDependencies(tree, DEPENDENCIES);\n\n // Base format target checks rather than writes (so build/lint don't rewrite\n // source); `fix` writes, and `skip-lint` writes without failing so it stays\n // a no-op when propagated through the lint -> format dependency.\n projectConfiguration.targets.format = {\n ...projectConfiguration.targets.format,\n cache: true,\n inputs: ['default', '^production'],\n options: {\n ...projectConfiguration.targets.format?.options,\n check: true,\n },\n configurations: {\n ...projectConfiguration.targets.format?.configurations,\n fix: {\n check: false,\n },\n 'skip-lint': {\n check: false,\n },\n },\n };\n\n // Add a dependency on the format target for lint in order to reduce the number of\n // fixable lint errors (eg line too long)\n projectConfiguration.targets.lint = {\n ...projectConfiguration.targets.lint,\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n ...projectConfiguration.targets.lint?.configurations,\n fix: {\n fix: true,\n },\n 'skip-lint': {\n exitZero: true,\n },\n },\n };\n // Append `format` without moving an existing entry, so re-running does not\n // reorder lint dependencies (e.g. relative to a later-added license-check).\n addDependencyToTargetIfNotPresent(projectConfiguration, 'lint', 'format');\n\n projectConfiguration.targets = sortObjectKeys(projectConfiguration.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, PY_PROJECT_GENERATOR_INFO);\n\n // Update root .gitignore\n updateGitIgnore(tree, '.', (patterns) => [...patterns, '/reports']);\n\n // Update project level .gitignore. The cache directories are also kept out\n // of type checking: `ty` respects .gitignore, and pytest creates and removes\n // transient `pytest-cache-files-*` directories while the test and typecheck\n // targets run concurrently, which would otherwise make `ty` fail with an I/O\n // error when it scans one mid-deletion.\n updateGitIgnore(tree, dir, (patterns) => [\n ...patterns,\n '**/__pycache__',\n ...PYTHON_TRANSIENT_ARTIFACTS.filter((p) => p !== '__pycache__'),\n ]);\n\n await addGeneratorMetricsIfApplicable(tree, [PY_PROJECT_GENERATOR_INFO]);\n\n await ensurePythonLicenseCollector(tree);\n\n // If license checking is configured, make this project's lint target depend\n // on the root license-check target. No-op if license checking isn't set up;\n // the license generator wires up existing projects itself, so the dependency\n // is added regardless of which generator runs first.\n addLicenseCheckToLintTarget(tree, fullyQualifiedName);\n\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\nexport default pyProjectGenerator;\n"],"names":["ensurePackage","joinPathFragments","readNxJson","readProjectConfiguration","updateNxJson","updateProjectConfiguration","addLicenseCheckToLintTarget","ensurePythonLicenseCollector","addPyDependencies","addTsDependencies","declareDependencies","updateGitIgnore","installDependencies","addGeneratorMetricsIfApplicable","normalizeDistributionName","toSnakeCase","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","projectExists","migrateToSharedVenvGenerator","uvProjectGenerator","sortObjectKeys","updateToml","withVersions","DEPENDENCIES","ts","name","dev","root","py","group","PY_PROJECT_GENERATOR_INFO","filename","PYTHON_TRANSIENT_ARTIFACTS","getPyProjectDetails","tree","schema","scope","normalizedName","normalizedModuleName","moduleName","fullyQualifiedName","distributionName","dir","directory","subDirectory","pyProjectGenerator","pythonPlugin","Object","entries","forEach","version","nxJson","plugins","find","p","plugin","options","packageManager","exists","autoActivate","moveDevDependencies","pyenvPythonVersion","pyprojectPythonDependency","packageName","publishable","buildLockedVersions","buildBundleLocalDependencies","linter","rootPyprojectDependencyGroup","projectType","type","projectNameAndRootFormat","unitTestRunner","codeCoverage","codeCoverageHtmlReport","codeCoverageXmlReport","unitTestHtmlReport","unitTestJUnitReport","buildSystem","srcDir","f","delete","write","outputPath","buildOutputPath","projectConfiguration","targets","compile","buildTarget","build","inputs","outputs","ignorePaths","dependsOn","typecheck","cache","executor","command","cwd","pyProjectToml","tool","ruff","format","check","configurations","fix","lint","exitZero","patterns","filter","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EAEbC,iBAAiB,EACjBC,UAAU,EACVC,wBAAwB,EAExBC,YAAY,EACZC,0BAA0B,QACrB,aAAa;AACpB,SACEC,2BAA2B,EAC3BC,4BAA4B,QACvB,0BAA0B;AACjC,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,kCAAkC;AACzC,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,yBAAyB,EAAEC,WAAW,QAAQ,uBAAuB;AAC9E,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAoB;AAE3B,SAC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EAA6E;IAC7E,wCAAwC;IACxCpG,gBAAgB0B,MAAMQ,KAAK,CAACkE,WAAa;eACpCA;YACH;eACG5E,2BAA2B6E,MAAM,CAAC,CAACvD,IAAMA,MAAM;SACnD;IAED,MAAM5C,gCAAgCwB,MAAM;QAACJ;KAA0B;IAEvE,MAAM1B,6BAA6B8B;IAEnC,4EAA4E;IAC5E,4EAA4E;IAC5E,6EAA6E;IAC7E,qDAAqD;IACrD/B,4BAA4B+B,MAAMM;IAElC,OAAO,IACL/B,oBAAoByB,MAAMC,OAAO2E,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AACF,eAAelE,mBAAmB"}
@@ -8,6 +8,7 @@
8
8
  "name": {
9
9
  "type": "string",
10
10
  "description": "The name of the Python project",
11
+ "pattern": "^[a-zA-Z0-9][^:/\\\\]*$",
11
12
  "$default": {
12
13
  "$source": "argv",
13
14
  "index": 0
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type GeneratorCallback, type Tree } from '@nx/devkit';
6
- import { type NxGeneratorInfo } from '../../../utils/nx';
6
+ import { type NxGeneratorInfo } from '../../../utils/nx.js';
7
7
  import type { PyRdbAgentConnectionGeneratorSchema } from './schema';
8
8
  export declare const PY_RDB_AGENT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
9
9
  export declare const pyRdbAgentConnectionGenerator: (tree: Tree, options: PyRdbAgentConnectionGeneratorSchema) => Promise<GeneratorCallback>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/rdb/agent-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n joinPathFragments,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { toSnakeCase } from '../../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { addWorkspaceDependencyToPyProject } from '../../../utils/py';\nimport { injectRdsCaBundleIntoDockerfile } from '../utils';\nimport type { PyRdbAgentConnectionGeneratorSchema } from './schema';\n\nexport const PY_RDB_AGENT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyRdbAgentConnectionGenerator = async (\n tree: Tree,\n options: PyRdbAgentConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n addWorkspaceDependencyToPyProject(tree, sourceProject, targetProject);\n\n const agentName = options.sourceComponent?.name ?? 'agent';\n const devTarget = `${agentName}-dev`;\n const agentSourceDir = options.sourceComponent?.path\n ? joinPathFragments(sourceProject.root, options.sourceComponent.path)\n : sourceProject.sourceRoot\n ? joinPathFragments(sourceProject.sourceRoot, toSnakeCase(agentName))\n : undefined;\n const dockerfilePath = agentSourceDir\n ? joinPathFragments(agentSourceDir, 'Dockerfile')\n : undefined;\n\n if (dockerfilePath) {\n injectRdsCaBundleIntoDockerfile(tree, dockerfilePath);\n }\n\n if (sourceProject.targets?.[devTarget]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTarget, {\n projects: [targetProject.name],\n target: 'dev',\n });\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n // Recorded so the version sync can identify this connection.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n PY_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n targetProject.root,\n `${agentName}-${targetProject.name}`,\n // The source component this connection is made from, so the pair is\n // identifiable rather than just the two projects.\n { sourcePath: options.sourceComponent?.path },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n PY_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyRdbAgentConnectionGenerator;\n"],"names":["joinPathFragments","updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toSnakeCase","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","addWorkspaceDependencyToPyProject","injectRdsCaBundleIntoDockerfile","PY_RDB_AGENT_CONNECTION_GENERATOR_INFO","filename","pyRdbAgentConnectionGenerator","tree","options","sourceProject","targetProject","agentName","sourceComponent","name","devTarget","agentSourceDir","path","root","sourceRoot","undefined","dockerfilePath","targets","projects","target","sourcePath","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SAASC,WAAW,QAAQ,0BAAuB;AACnD,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SAASC,iCAAiC,QAAQ,uBAAoB;AACtE,SAASC,+BAA+B,QAAQ,cAAW;AAG3D,OAAO,MAAMC,yCACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC,OAAO,MAAMC,gCAAgC,OAC3CC,MACAC;IAEA,MAAMC,gBAAgBR,oCACpBM,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBT,oCACpBM,MACAC,QAAQE,aAAa;IAGvBR,kCAAkCK,MAAME,eAAeC;IAEvD,MAAMC,YAAYH,QAAQI,eAAe,EAAEC,QAAQ;IACnD,MAAMC,YAAY,GAAGH,UAAU,IAAI,CAAC;IACpC,MAAMI,iBAAiBP,QAAQI,eAAe,EAAEI,OAC5CxB,kBAAkBiB,cAAcQ,IAAI,EAAET,QAAQI,eAAe,CAACI,IAAI,IAClEP,cAAcS,UAAU,GACtB1B,kBAAkBiB,cAAcS,UAAU,EAAErB,YAAYc,cACxDQ;IACN,MAAMC,iBAAiBL,iBACnBvB,kBAAkBuB,gBAAgB,gBAClCI;IAEJ,IAAIC,gBAAgB;QAClBjB,gCAAgCI,MAAMa;IACxC;IAEA,IAAIX,cAAcY,OAAO,EAAE,CAACP,UAAU,EAAE;QACtCf,kCAAkCU,eAAeK,WAAW;YAC1DQ,UAAU;gBAACZ,cAAcG,IAAI;aAAC;YAC9BU,QAAQ;QACV;QACA9B,2BAA2Bc,MAAME,cAAcI,IAAI,EAAEJ;IACvD;IAEA,6DAA6D;IAC7DX,8BACES,MACAE,cAAcI,IAAI,EAClBT,wCACAM,cAAcO,IAAI,EAClB,GAAGN,UAAU,CAAC,EAAED,cAAcG,IAAI,EAAE,EACpC,oEAAoE;IACpE,kDAAkD;IAClD;QAAEW,YAAYhB,QAAQI,eAAe,EAAEI;IAAK;IAG9C,MAAMpB,gCAAgCW,MAAM;QAC1CH;KACD;IACD,MAAMV,qBAAqBa;IAC3B,OAAO,IACLZ,oBAAoBY,MAAMC,QAAQiB,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAepB,8BAA8B"}
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/rdb/agent-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n joinPathFragments,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { toSnakeCase } from '../../../utils/names.js';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx.js';\nimport { addWorkspaceDependencyToPyProject } from '../../../utils/py.js';\nimport { injectRdsCaBundleIntoDockerfile } from '../utils.js';\nimport type { PyRdbAgentConnectionGeneratorSchema } from './schema';\n\nexport const PY_RDB_AGENT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyRdbAgentConnectionGenerator = async (\n tree: Tree,\n options: PyRdbAgentConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n addWorkspaceDependencyToPyProject(tree, sourceProject, targetProject);\n\n const agentName = options.sourceComponent?.name ?? 'agent';\n const devTarget = `${agentName}-dev`;\n const agentSourceDir = options.sourceComponent?.path\n ? joinPathFragments(sourceProject.root, options.sourceComponent.path)\n : sourceProject.sourceRoot\n ? joinPathFragments(sourceProject.sourceRoot, toSnakeCase(agentName))\n : undefined;\n const dockerfilePath = agentSourceDir\n ? joinPathFragments(agentSourceDir, 'Dockerfile')\n : undefined;\n\n if (dockerfilePath) {\n injectRdsCaBundleIntoDockerfile(tree, dockerfilePath);\n }\n\n if (sourceProject.targets?.[devTarget]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTarget, {\n projects: [targetProject.name],\n target: 'dev',\n });\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n // Recorded so the version sync can identify this connection.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n PY_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n targetProject.root,\n `${agentName}-${targetProject.name}`,\n // The source component this connection is made from, so the pair is\n // identifiable rather than just the two projects.\n { sourcePath: options.sourceComponent?.path },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n PY_RDB_AGENT_CONNECTION_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyRdbAgentConnectionGenerator;\n"],"names":["joinPathFragments","updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toSnakeCase","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","addWorkspaceDependencyToPyProject","injectRdsCaBundleIntoDockerfile","PY_RDB_AGENT_CONNECTION_GENERATOR_INFO","filename","pyRdbAgentConnectionGenerator","tree","options","sourceProject","targetProject","agentName","sourceComponent","name","devTarget","agentSourceDir","path","root","sourceRoot","undefined","dockerfilePath","targets","projects","target","sourcePath","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,+BAA+B,QAAQ,4BAA4B;AAC5E,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAuB;AAC9B,SAASC,iCAAiC,QAAQ,uBAAuB;AACzE,SAASC,+BAA+B,QAAQ,cAAc;AAG9D,OAAO,MAAMC,yCACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC,OAAO,MAAMC,gCAAgC,OAC3CC,MACAC;IAEA,MAAMC,gBAAgBR,oCACpBM,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBT,oCACpBM,MACAC,QAAQE,aAAa;IAGvBR,kCAAkCK,MAAME,eAAeC;IAEvD,MAAMC,YAAYH,QAAQI,eAAe,EAAEC,QAAQ;IACnD,MAAMC,YAAY,GAAGH,UAAU,IAAI,CAAC;IACpC,MAAMI,iBAAiBP,QAAQI,eAAe,EAAEI,OAC5CxB,kBAAkBiB,cAAcQ,IAAI,EAAET,QAAQI,eAAe,CAACI,IAAI,IAClEP,cAAcS,UAAU,GACtB1B,kBAAkBiB,cAAcS,UAAU,EAAErB,YAAYc,cACxDQ;IACN,MAAMC,iBAAiBL,iBACnBvB,kBAAkBuB,gBAAgB,gBAClCI;IAEJ,IAAIC,gBAAgB;QAClBjB,gCAAgCI,MAAMa;IACxC;IAEA,IAAIX,cAAcY,OAAO,EAAE,CAACP,UAAU,EAAE;QACtCf,kCAAkCU,eAAeK,WAAW;YAC1DQ,UAAU;gBAACZ,cAAcG,IAAI;aAAC;YAC9BU,QAAQ;QACV;QACA9B,2BAA2Bc,MAAME,cAAcI,IAAI,EAAEJ;IACvD;IAEA,6DAA6D;IAC7DX,8BACES,MACAE,cAAcI,IAAI,EAClBT,wCACAM,cAAcO,IAAI,EAClB,GAAGN,UAAU,CAAC,EAAED,cAAcG,IAAI,EAAE,EACpC,oEAAoE;IACpE,kDAAkD;IAClD;QAAEW,YAAYhB,QAAQI,eAAe,EAAEI;IAAK;IAG9C,MAAMpB,gCAAgCW,MAAM;QAC1CH;KACD;IACD,MAAMV,qBAAqBa;IAC3B,OAAO,IACLZ,oBAAoBY,MAAMC,QAAQiB,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAepB,8BAA8B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/rdb/agent-connection/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { ComponentMetadata } from '../../../utils/nx';\n\n/**\n * TypeScript types for options defined in schema.json\n */\nexport interface PyRdbAgentConnectionGeneratorSchema {\n sourceProject: string;\n targetProject: string;\n sourceComponent?: ComponentMetadata;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD;;CAEC,GACD,WAKC"}
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/rdb/agent-connection/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { ComponentMetadata } from '../../../utils/nx.js';\n\n/**\n * TypeScript types for options defined in schema.json\n */\nexport interface PyRdbAgentConnectionGeneratorSchema {\n sourceProject: string;\n targetProject: string;\n sourceComponent?: ComponentMetadata;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD;;CAEC,GACD,WAKC"}
@@ -2,7 +2,7 @@
2
2
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { ComponentMetadata } from '../../../utils/nx';
5
+ import { ComponentMetadata } from '../../../utils/nx.js';
6
6
 
7
7
  /**
8
8
  * TypeScript types for options defined in schema.json