@aws-amplify/cli-internal-gen2-migration-experimental-alpha 0.1.0 → 0.3.0

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 (281) hide show
  1. package/aws-amplify-cli-internal-gen2-migration-experimental-alpha-0.3.0.tgz +0 -0
  2. package/lib/commands/drift-detection/detect-local-drift.d.ts +3 -6
  3. package/lib/commands/drift-detection/detect-local-drift.d.ts.map +1 -1
  4. package/lib/commands/drift-detection/detect-local-drift.js +4 -8
  5. package/lib/commands/drift-detection/detect-local-drift.js.map +1 -1
  6. package/lib/commands/drift-detection/detect-stack-drift.d.ts +3 -2
  7. package/lib/commands/drift-detection/detect-stack-drift.d.ts.map +1 -1
  8. package/lib/commands/drift-detection/detect-stack-drift.js +12 -0
  9. package/lib/commands/drift-detection/detect-stack-drift.js.map +1 -1
  10. package/lib/commands/drift-detection/detect-template-drift.d.ts +4 -5
  11. package/lib/commands/drift-detection/detect-template-drift.d.ts.map +1 -1
  12. package/lib/commands/drift-detection/detect-template-drift.js +122 -94
  13. package/lib/commands/drift-detection/detect-template-drift.js.map +1 -1
  14. package/lib/commands/drift-detection/index.d.ts +3 -2
  15. package/lib/commands/drift-detection/index.d.ts.map +1 -1
  16. package/lib/commands/drift-detection/index.js +3 -1
  17. package/lib/commands/drift-detection/index.js.map +1 -1
  18. package/lib/commands/drift-detection/services/cloudformation-service.d.ts.map +1 -1
  19. package/lib/commands/drift-detection/services/cloudformation-service.js +3 -5
  20. package/lib/commands/drift-detection/services/cloudformation-service.js.map +1 -1
  21. package/lib/commands/drift-detection/services/drift-formatter.d.ts +4 -5
  22. package/lib/commands/drift-detection/services/drift-formatter.d.ts.map +1 -1
  23. package/lib/commands/drift-detection/services/drift-formatter.js +15 -38
  24. package/lib/commands/drift-detection/services/drift-formatter.js.map +1 -1
  25. package/lib/commands/drift.d.ts +0 -2
  26. package/lib/commands/drift.d.ts.map +1 -1
  27. package/lib/commands/drift.js +47 -57
  28. package/lib/commands/drift.js.map +1 -1
  29. package/lib/commands/gen2-migration/_step.d.ts +2 -1
  30. package/lib/commands/gen2-migration/_step.d.ts.map +1 -1
  31. package/lib/commands/gen2-migration/_step.js +2 -1
  32. package/lib/commands/gen2-migration/_step.js.map +1 -1
  33. package/lib/commands/gen2-migration/generate/adapters/auth/index.d.ts +24 -0
  34. package/lib/commands/gen2-migration/generate/adapters/auth/index.d.ts.map +1 -0
  35. package/lib/commands/gen2-migration/generate/adapters/auth/index.js +297 -0
  36. package/lib/commands/gen2-migration/generate/adapters/auth/index.js.map +1 -0
  37. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.d.ts +2 -0
  38. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.d.ts.map +1 -0
  39. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.js +140 -0
  40. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.js.map +1 -0
  41. package/lib/commands/gen2-migration/generate/adapters/data/index.d.ts +5 -0
  42. package/lib/commands/gen2-migration/generate/adapters/data/index.d.ts.map +1 -0
  43. package/lib/commands/gen2-migration/generate/adapters/data/index.js +17 -0
  44. package/lib/commands/gen2-migration/generate/adapters/data/index.js.map +1 -0
  45. package/lib/commands/gen2-migration/generate/adapters/functions/index.d.ts +17 -0
  46. package/lib/commands/gen2-migration/generate/adapters/functions/index.d.ts.map +1 -0
  47. package/lib/commands/gen2-migration/generate/adapters/functions/index.js +46 -0
  48. package/lib/commands/gen2-migration/generate/adapters/functions/index.js.map +1 -0
  49. package/lib/commands/gen2-migration/generate/adapters/project/index.d.ts +2 -0
  50. package/lib/commands/gen2-migration/generate/adapters/project/index.d.ts.map +1 -0
  51. package/lib/commands/gen2-migration/generate/adapters/project/index.js +7 -0
  52. package/lib/commands/gen2-migration/generate/adapters/project/index.js.map +1 -0
  53. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.d.ts +30 -0
  54. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.d.ts.map +1 -0
  55. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.js +18 -0
  56. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.js.map +1 -0
  57. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.d.ts +2 -0
  58. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.d.ts.map +1 -0
  59. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.js +181 -0
  60. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.js.map +1 -0
  61. package/lib/commands/gen2-migration/generate/adapters/storage/index.d.ts +3 -0
  62. package/lib/commands/gen2-migration/generate/adapters/storage/index.d.ts.map +1 -0
  63. package/lib/commands/gen2-migration/generate/adapters/storage/index.js +6 -0
  64. package/lib/commands/gen2-migration/generate/adapters/storage/index.js.map +1 -0
  65. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.d.ts +14 -0
  66. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.d.ts.map +1 -0
  67. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.js +27 -0
  68. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.js.map +1 -0
  69. package/lib/commands/gen2-migration/generate/backend/synthesizer.d.ts +80 -0
  70. package/lib/commands/gen2-migration/generate/backend/synthesizer.d.ts.map +1 -0
  71. package/lib/commands/gen2-migration/generate/backend/synthesizer.js +899 -0
  72. package/lib/commands/gen2-migration/generate/backend/synthesizer.js.map +1 -0
  73. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.d.ts +2 -0
  74. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.d.ts.map +1 -0
  75. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.js +744 -0
  76. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.js.map +1 -0
  77. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.d.ts +14 -0
  78. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.d.ts.map +1 -0
  79. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.js +82 -0
  80. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.js.map +1 -0
  81. package/lib/commands/gen2-migration/generate/codegen-head/analytics.d.ts +10 -0
  82. package/lib/commands/gen2-migration/generate/codegen-head/analytics.d.ts.map +1 -0
  83. package/lib/commands/gen2-migration/generate/codegen-head/analytics.js +11 -0
  84. package/lib/commands/gen2-migration/generate/codegen-head/analytics.js.map +1 -0
  85. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.d.ts +13 -0
  86. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.d.ts.map +1 -0
  87. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.js +22 -0
  88. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.js.map +1 -0
  89. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.d.ts +24 -0
  90. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.d.ts.map +1 -0
  91. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.js +167 -0
  92. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.js.map +1 -0
  93. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.d.ts +19 -0
  94. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.d.ts.map +1 -0
  95. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.js +133 -0
  96. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.js.map +1 -0
  97. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.d.ts +23 -0
  98. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.d.ts.map +1 -0
  99. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.js +172 -0
  100. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.js.map +1 -0
  101. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.d.ts +10 -0
  102. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.d.ts.map +1 -0
  103. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.js +48 -0
  104. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.js.map +1 -0
  105. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.d.ts +11 -0
  106. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.d.ts.map +1 -0
  107. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.js +38 -0
  108. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.js.map +1 -0
  109. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.d.ts +13 -0
  110. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.d.ts.map +1 -0
  111. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.js +462 -0
  112. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.js.map +1 -0
  113. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.d.ts +47 -0
  114. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.d.ts.map +1 -0
  115. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.js +222 -0
  116. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.js.map +1 -0
  117. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.d.ts +2 -0
  118. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.d.ts.map +1 -0
  119. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.js +15 -0
  120. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.js.map +1 -0
  121. package/lib/commands/gen2-migration/generate/codegen-head/format.d.ts +8 -0
  122. package/lib/commands/gen2-migration/generate/codegen-head/format.d.ts.map +1 -0
  123. package/lib/commands/gen2-migration/generate/codegen-head/format.js +66 -0
  124. package/lib/commands/gen2-migration/generate/codegen-head/format.js.map +1 -0
  125. package/lib/commands/gen2-migration/generate/codegen-head/logger.d.ts +15 -0
  126. package/lib/commands/gen2-migration/generate/codegen-head/logger.d.ts.map +1 -0
  127. package/lib/commands/gen2-migration/generate/codegen-head/logger.js +14 -0
  128. package/lib/commands/gen2-migration/generate/codegen-head/logger.js.map +1 -0
  129. package/lib/commands/gen2-migration/generate/codegen-head/printer.d.ts +26 -0
  130. package/lib/commands/gen2-migration/generate/codegen-head/printer.d.ts.map +1 -0
  131. package/lib/commands/gen2-migration/generate/codegen-head/printer.js +103 -0
  132. package/lib/commands/gen2-migration/generate/codegen-head/printer.js.map +1 -0
  133. package/lib/commands/gen2-migration/generate/core/migration-pipeline.d.ts +26 -0
  134. package/lib/commands/gen2-migration/generate/core/migration-pipeline.d.ts.map +1 -0
  135. package/lib/commands/gen2-migration/generate/core/migration-pipeline.js +233 -0
  136. package/lib/commands/gen2-migration/generate/core/migration-pipeline.js.map +1 -0
  137. package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.d.ts.map +1 -0
  138. package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.js.map +1 -0
  139. package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.d.ts.map +1 -0
  140. package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.js.map +1 -0
  141. package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.d.ts.map +1 -0
  142. package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.js.map +1 -0
  143. package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.d.ts.map +1 -0
  144. package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.js.map +1 -0
  145. package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.d.ts.map +1 -0
  146. package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.js.map +1 -0
  147. package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.d.ts.map +1 -0
  148. package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.js.map +1 -0
  149. package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.d.ts.map +1 -0
  150. package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.js.map +1 -0
  151. package/lib/commands/gen2-migration/generate/custom-resources/transformer/amplify-helper-transformer.d.ts.map +1 -0
  152. package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/transformer/amplify-helper-transformer.js +25 -3
  153. package/lib/commands/gen2-migration/generate/custom-resources/transformer/amplify-helper-transformer.js.map +1 -0
  154. package/lib/commands/gen2-migration/generate/custom-resources/types.d.ts.map +1 -0
  155. package/lib/commands/gen2-migration/generate/custom-resources/types.js.map +1 -0
  156. package/lib/commands/gen2-migration/generate/generators/analytics/index.d.ts +9 -0
  157. package/lib/commands/gen2-migration/generate/generators/analytics/index.d.ts.map +1 -0
  158. package/lib/commands/gen2-migration/generate/generators/analytics/index.js +40 -0
  159. package/lib/commands/gen2-migration/generate/generators/analytics/index.js.map +1 -0
  160. package/lib/commands/gen2-migration/generate/generators/auth/index.d.ts +106 -0
  161. package/lib/commands/gen2-migration/generate/generators/auth/index.d.ts.map +1 -0
  162. package/lib/commands/gen2-migration/generate/generators/auth/index.js +286 -0
  163. package/lib/commands/gen2-migration/generate/generators/auth/index.js.map +1 -0
  164. package/lib/commands/gen2-migration/generate/generators/auth/index.test.d.ts +2 -0
  165. package/lib/commands/gen2-migration/generate/generators/auth/index.test.d.ts.map +1 -0
  166. package/lib/commands/gen2-migration/generate/generators/auth/index.test.js +437 -0
  167. package/lib/commands/gen2-migration/generate/generators/auth/index.test.js.map +1 -0
  168. package/lib/commands/gen2-migration/generate/generators/data/index.d.ts +35 -0
  169. package/lib/commands/gen2-migration/generate/generators/data/index.d.ts.map +1 -0
  170. package/lib/commands/gen2-migration/generate/generators/data/index.js +199 -0
  171. package/lib/commands/gen2-migration/generate/generators/data/index.js.map +1 -0
  172. package/lib/commands/gen2-migration/generate/generators/data/index.test.d.ts +2 -0
  173. package/lib/commands/gen2-migration/generate/generators/data/index.test.d.ts.map +1 -0
  174. package/lib/commands/gen2-migration/generate/generators/data/index.test.js +50 -0
  175. package/lib/commands/gen2-migration/generate/generators/data/index.test.js.map +1 -0
  176. package/lib/commands/gen2-migration/generate/generators/functions/index.d.ts +17 -0
  177. package/lib/commands/gen2-migration/generate/generators/functions/index.d.ts.map +1 -0
  178. package/lib/commands/gen2-migration/generate/generators/functions/index.js +125 -0
  179. package/lib/commands/gen2-migration/generate/generators/functions/index.js.map +1 -0
  180. package/lib/commands/gen2-migration/generate/generators/functions/lambda.d.ts +6 -0
  181. package/lib/commands/gen2-migration/generate/generators/functions/lambda.d.ts.map +1 -0
  182. package/lib/commands/gen2-migration/generate/generators/functions/lambda.js +16 -0
  183. package/lib/commands/gen2-migration/generate/generators/functions/lambda.js.map +1 -0
  184. package/lib/commands/gen2-migration/generate/generators/storage/access.d.ts +4 -0
  185. package/lib/commands/gen2-migration/generate/generators/storage/access.d.ts.map +1 -0
  186. package/lib/commands/gen2-migration/generate/generators/storage/access.js +53 -0
  187. package/lib/commands/gen2-migration/generate/generators/storage/access.js.map +1 -0
  188. package/lib/commands/gen2-migration/generate/generators/storage/index.d.ts +31 -0
  189. package/lib/commands/gen2-migration/generate/generators/storage/index.d.ts.map +1 -0
  190. package/lib/commands/gen2-migration/generate/generators/storage/index.js +66 -0
  191. package/lib/commands/gen2-migration/generate/generators/storage/index.js.map +1 -0
  192. package/lib/commands/gen2-migration/generate/npm_package/renderer.d.ts +27 -0
  193. package/lib/commands/gen2-migration/generate/npm_package/renderer.d.ts.map +1 -0
  194. package/lib/commands/gen2-migration/generate/npm_package/renderer.js +28 -0
  195. package/lib/commands/gen2-migration/generate/npm_package/renderer.js.map +1 -0
  196. package/lib/commands/gen2-migration/generate/render_pipeline.d.ts +9 -0
  197. package/lib/commands/gen2-migration/generate/render_pipeline.d.ts.map +1 -0
  198. package/lib/commands/gen2-migration/generate/render_pipeline.js +15 -0
  199. package/lib/commands/gen2-migration/generate/render_pipeline.js.map +1 -0
  200. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.d.ts +7 -0
  201. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.d.ts.map +1 -0
  202. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.js +17 -0
  203. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.js.map +1 -0
  204. package/lib/commands/gen2-migration/generate/renderers/package_json.d.ts +8 -0
  205. package/lib/commands/gen2-migration/generate/renderers/package_json.d.ts.map +1 -0
  206. package/lib/commands/gen2-migration/generate/renderers/package_json.js +15 -0
  207. package/lib/commands/gen2-migration/generate/renderers/package_json.js.map +1 -0
  208. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.d.ts +11 -0
  209. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.d.ts.map +1 -0
  210. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.js +22 -0
  211. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.js.map +1 -0
  212. package/lib/commands/gen2-migration/generate/resource/resource.d.ts +20 -0
  213. package/lib/commands/gen2-migration/generate/resource/resource.d.ts.map +1 -0
  214. package/lib/commands/gen2-migration/generate/resource/resource.js +60 -0
  215. package/lib/commands/gen2-migration/generate/resource/resource.js.map +1 -0
  216. package/lib/commands/gen2-migration/generate/test_utils/import_regex.d.ts +2 -0
  217. package/lib/commands/gen2-migration/generate/test_utils/import_regex.d.ts.map +1 -0
  218. package/lib/commands/gen2-migration/generate/test_utils/import_regex.js +6 -0
  219. package/lib/commands/gen2-migration/generate/test_utils/import_regex.js.map +1 -0
  220. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.d.ts +4 -0
  221. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.d.ts.map +1 -0
  222. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.js +22 -0
  223. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.js.map +1 -0
  224. package/lib/commands/gen2-migration/generate/todo_error.d.ts +3 -0
  225. package/lib/commands/gen2-migration/generate/todo_error.d.ts.map +1 -0
  226. package/lib/commands/gen2-migration/generate/todo_error.js +11 -0
  227. package/lib/commands/gen2-migration/generate/todo_error.js.map +1 -0
  228. package/lib/commands/gen2-migration/generate/ts_factory_utils.d.ts +3 -0
  229. package/lib/commands/gen2-migration/generate/ts_factory_utils.d.ts.map +1 -0
  230. package/lib/commands/gen2-migration/generate/ts_factory_utils.js +10 -0
  231. package/lib/commands/gen2-migration/generate/ts_factory_utils.js.map +1 -0
  232. package/lib/commands/gen2-migration/generate/types.d.ts +4 -0
  233. package/lib/commands/gen2-migration/generate/types.d.ts.map +1 -0
  234. package/lib/commands/gen2-migration/generate/types.js +3 -0
  235. package/lib/commands/gen2-migration/generate/types.js.map +1 -0
  236. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.d.ts +26 -0
  237. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.d.ts.map +1 -0
  238. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.js +152 -0
  239. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.js.map +1 -0
  240. package/lib/commands/gen2-migration/generate.js +2 -2
  241. package/lib/commands/gen2-migration/generate.js.map +1 -1
  242. package/lib/commands/gen2-migration.d.ts.map +1 -1
  243. package/lib/commands/gen2-migration.js +2 -1
  244. package/lib/commands/gen2-migration.js.map +1 -1
  245. package/package.json +3 -2
  246. package/aws-amplify-cli-internal-gen2-migration-experimental-alpha-0.1.0.tgz +0 -0
  247. package/lib/commands/gen2-migration/codegen-custom-resources/generator/backend-updater.d.ts.map +0 -1
  248. package/lib/commands/gen2-migration/codegen-custom-resources/generator/backend-updater.js.map +0 -1
  249. package/lib/commands/gen2-migration/codegen-custom-resources/generator/dependency-merger.d.ts.map +0 -1
  250. package/lib/commands/gen2-migration/codegen-custom-resources/generator/dependency-merger.js.map +0 -1
  251. package/lib/commands/gen2-migration/codegen-custom-resources/generator/file-converter.d.ts.map +0 -1
  252. package/lib/commands/gen2-migration/codegen-custom-resources/generator/file-converter.js.map +0 -1
  253. package/lib/commands/gen2-migration/codegen-custom-resources/generator/gen2-file-generator.d.ts.map +0 -1
  254. package/lib/commands/gen2-migration/codegen-custom-resources/generator/gen2-file-generator.js.map +0 -1
  255. package/lib/commands/gen2-migration/codegen-custom-resources/parser/cdk-stack-parser.d.ts.map +0 -1
  256. package/lib/commands/gen2-migration/codegen-custom-resources/parser/cdk-stack-parser.js.map +0 -1
  257. package/lib/commands/gen2-migration/codegen-custom-resources/parser/pattern-detector.d.ts.map +0 -1
  258. package/lib/commands/gen2-migration/codegen-custom-resources/parser/pattern-detector.js.map +0 -1
  259. package/lib/commands/gen2-migration/codegen-custom-resources/scanner/custom-resource-scanner.d.ts.map +0 -1
  260. package/lib/commands/gen2-migration/codegen-custom-resources/scanner/custom-resource-scanner.js.map +0 -1
  261. package/lib/commands/gen2-migration/codegen-custom-resources/transformer/amplify-helper-transformer.d.ts.map +0 -1
  262. package/lib/commands/gen2-migration/codegen-custom-resources/transformer/amplify-helper-transformer.js.map +0 -1
  263. package/lib/commands/gen2-migration/codegen-custom-resources/types.d.ts.map +0 -1
  264. package/lib/commands/gen2-migration/codegen-custom-resources/types.js.map +0 -1
  265. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/backend-updater.d.ts +0 -0
  266. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/backend-updater.js +0 -0
  267. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/dependency-merger.d.ts +0 -0
  268. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/dependency-merger.js +0 -0
  269. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/file-converter.d.ts +0 -0
  270. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/file-converter.js +0 -0
  271. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/gen2-file-generator.d.ts +0 -0
  272. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/gen2-file-generator.js +0 -0
  273. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/cdk-stack-parser.d.ts +0 -0
  274. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/cdk-stack-parser.js +0 -0
  275. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/pattern-detector.d.ts +0 -0
  276. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/pattern-detector.js +0 -0
  277. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/scanner/custom-resource-scanner.d.ts +0 -0
  278. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/scanner/custom-resource-scanner.js +0 -0
  279. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/transformer/amplify-helper-transformer.d.ts +0 -0
  280. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/types.d.ts +0 -0
  281. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/types.js +0 -0
@@ -0,0 +1,744 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const globals_1 = require("@jest/globals");
7
+ const synthesizer_1 = require("./synthesizer");
8
+ const ts_node_printer_1 = require("../test_utils/ts_node_printer");
9
+ const typescript_1 = __importDefault(require("typescript"));
10
+ (0, globals_1.describe)('BackendSynthesizer', () => {
11
+ let synthesizer;
12
+ beforeEach(() => {
13
+ synthesizer = new synthesizer_1.BackendSynthesizer();
14
+ });
15
+ (0, globals_1.describe)('identity pool overrides', () => {
16
+ (0, globals_1.it)('allowUnauthenticatedIdentities is escape hatched if guest login is false', () => {
17
+ const renderArgs = {
18
+ auth: {
19
+ importFrom: './auth/resource',
20
+ guestLogin: false,
21
+ },
22
+ };
23
+ const result = synthesizer.render(renderArgs);
24
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
25
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
26
+ "import { auth } from "./auth/resource";
27
+ import { defineBackend } from "@aws-amplify/backend";
28
+
29
+
30
+ const backend = defineBackend({
31
+ auth
32
+ });
33
+ const cfnIdentityPool = backend.auth.resources.cfnResources.cfnIdentityPool;
34
+ cfnIdentityPool.allowUnauthenticatedIdentities = false;
35
+ "
36
+ `);
37
+ });
38
+ (0, globals_1.it)('cfnIdentityPool is not declared as a const if guest login is true', () => {
39
+ const renderArgs = {
40
+ auth: {
41
+ importFrom: './auth/resource',
42
+ guestLogin: true,
43
+ },
44
+ };
45
+ const result = synthesizer.render(renderArgs);
46
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
47
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
48
+ "import { auth } from "./auth/resource";
49
+ import { defineBackend } from "@aws-amplify/backend";
50
+
51
+
52
+ const backend = defineBackend({
53
+ auth
54
+ });
55
+ "
56
+ `);
57
+ });
58
+ });
59
+ (0, globals_1.describe)('AppSync API Generation', () => {
60
+ (0, globals_1.it)('should set awsRegion to a dynamic value from backend', () => {
61
+ const renderArgs = {
62
+ data: {
63
+ importFrom: './data/resource',
64
+ additionalAuthProviders: [
65
+ {
66
+ authenticationType: 'AMAZON_COGNITO_USER_POOLS',
67
+ userPoolConfig: {
68
+ awsRegion: 'us-east-1',
69
+ userPoolId: 'userpool_1234',
70
+ },
71
+ },
72
+ ],
73
+ },
74
+ auth: {
75
+ importFrom: './auth/resource',
76
+ },
77
+ };
78
+ const result = synthesizer.render(renderArgs);
79
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
80
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
81
+ "import { auth } from "./auth/resource";
82
+ import { data } from "./data/resource";
83
+ import { defineBackend } from "@aws-amplify/backend";
84
+
85
+
86
+ const backend = defineBackend({
87
+ auth,
88
+ data
89
+ });
90
+ const cfnGraphqlApi = backend.data.resources.cfnResources.cfnGraphqlApi;
91
+ cfnGraphqlApi.additionalAuthenticationProviders = [
92
+ {
93
+ authenticationType: "AMAZON_COGNITO_USER_POOLS",
94
+ userPoolConfig: {
95
+ awsRegion: backend.auth.resources.userPool.stack.region,
96
+ userPoolId: backend.auth.resources.userPool.userPoolId
97
+ }
98
+ }
99
+ ];
100
+ "
101
+ `);
102
+ });
103
+ });
104
+ (0, globals_1.describe)('REST API Generation', () => {
105
+ (0, globals_1.it)('should generate HttpApi with CORS configuration', () => {
106
+ const renderArgs = {
107
+ data: {
108
+ importFrom: './data/resource',
109
+ restApis: [
110
+ {
111
+ apiName: 'testapi',
112
+ functionName: 'testFunction',
113
+ paths: [
114
+ {
115
+ path: '/items',
116
+ methods: ['GET', 'POST'],
117
+ authType: 'private',
118
+ lambdaFunction: 'testFunction',
119
+ },
120
+ ],
121
+ },
122
+ ],
123
+ },
124
+ function: {
125
+ importFrom: './function/resource',
126
+ functionNamesAndCategories: new Map([['testFunction', 'function']]),
127
+ },
128
+ };
129
+ const result = synthesizer.render(renderArgs);
130
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
131
+ const printer = typescript_1.default.createPrinter();
132
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
133
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod');
134
+ (0, globals_1.expect)(output).toContain('aws-cdk-lib/aws-apigatewayv2');
135
+ (0, globals_1.expect)(output).toContain('corsPreflight');
136
+ (0, globals_1.expect)(output).toContain('allowMethods');
137
+ (0, globals_1.expect)(output).toContain('allowOrigins');
138
+ (0, globals_1.expect)(output).toContain('allowHeaders');
139
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.GET');
140
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.POST');
141
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.PUT');
142
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.DELETE');
143
+ });
144
+ (0, globals_1.it)('should map auth types to correct authorizers', () => {
145
+ const renderArgs = {
146
+ data: {
147
+ importFrom: './data/resource',
148
+ restApis: [
149
+ {
150
+ apiName: 'testapi',
151
+ functionName: 'testFunction',
152
+ paths: [
153
+ {
154
+ path: '/private',
155
+ methods: ['GET'],
156
+ authType: 'private',
157
+ lambdaFunction: 'testFunction',
158
+ },
159
+ {
160
+ path: '/protected',
161
+ methods: ['POST'],
162
+ authType: 'protected',
163
+ lambdaFunction: 'testFunction',
164
+ },
165
+ {
166
+ path: '/open',
167
+ methods: ['GET'],
168
+ authType: 'open',
169
+ lambdaFunction: 'testFunction',
170
+ },
171
+ ],
172
+ },
173
+ ],
174
+ },
175
+ function: {
176
+ importFrom: './function/resource',
177
+ functionNamesAndCategories: new Map([['testFunction', 'function']]),
178
+ },
179
+ auth: {
180
+ importFrom: './auth/resource',
181
+ },
182
+ };
183
+ const result = synthesizer.render(renderArgs);
184
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
185
+ const printer = typescript_1.default.createPrinter();
186
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
187
+ (0, globals_1.expect)(output).toContain('HttpIamAuthorizer');
188
+ (0, globals_1.expect)(output).toContain('HttpUserPoolAuthorizer');
189
+ (0, globals_1.expect)(output).toContain('authorizer: iamAuthorizer');
190
+ (0, globals_1.expect)(output).toContain('authorizer: userPoolAuthorizer');
191
+ });
192
+ (0, globals_1.it)('should generate unique integration names per function', () => {
193
+ const renderArgs = {
194
+ data: {
195
+ importFrom: './data/resource',
196
+ restApis: [
197
+ {
198
+ apiName: 'testapi',
199
+ functionName: 'function1',
200
+ paths: [
201
+ {
202
+ path: '/items',
203
+ methods: ['GET'],
204
+ authType: 'open',
205
+ lambdaFunction: 'function1',
206
+ },
207
+ {
208
+ path: '/books',
209
+ methods: ['POST'],
210
+ authType: 'open',
211
+ lambdaFunction: 'function2',
212
+ },
213
+ ],
214
+ },
215
+ ],
216
+ },
217
+ function: {
218
+ importFrom: './function/resource',
219
+ functionNamesAndCategories: new Map([
220
+ ['function1', 'function'],
221
+ ['function2', 'function'],
222
+ ]),
223
+ },
224
+ };
225
+ const result = synthesizer.render(renderArgs);
226
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
227
+ const printer = typescript_1.default.createPrinter();
228
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
229
+ (0, globals_1.expect)(output).toContain('function1Integration');
230
+ (0, globals_1.expect)(output).toContain('function2Integration');
231
+ (0, globals_1.expect)(output).toContain('backend.function1.resources');
232
+ (0, globals_1.expect)(output).toContain('backend.function2.resources');
233
+ });
234
+ (0, globals_1.it)('should respect HTTP methods from path configuration', () => {
235
+ const renderArgs = {
236
+ data: {
237
+ importFrom: './data/resource',
238
+ restApis: [
239
+ {
240
+ apiName: 'testapi',
241
+ functionName: 'testFunction',
242
+ paths: [
243
+ {
244
+ path: '/items',
245
+ methods: ['GET', 'POST'],
246
+ authType: 'open',
247
+ lambdaFunction: 'testFunction',
248
+ },
249
+ {
250
+ path: '/books',
251
+ methods: ['PUT', 'DELETE'],
252
+ authType: 'open',
253
+ lambdaFunction: 'testFunction',
254
+ },
255
+ ],
256
+ },
257
+ ],
258
+ },
259
+ function: {
260
+ importFrom: './function/resource',
261
+ functionNamesAndCategories: new Map([['testFunction', 'function']]),
262
+ },
263
+ };
264
+ const result = synthesizer.render(renderArgs);
265
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
266
+ const printer = typescript_1.default.createPrinter();
267
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
268
+ (0, globals_1.expect)(output).toContain('HttpMethod.GET');
269
+ (0, globals_1.expect)(output).toContain('HttpMethod.POST');
270
+ (0, globals_1.expect)(output).toContain('HttpMethod.PUT');
271
+ (0, globals_1.expect)(output).toContain('HttpMethod.DELETE');
272
+ (0, globals_1.expect)(output).not.toContain('HttpMethod.PATCH');
273
+ (0, globals_1.expect)(output).not.toContain('HttpMethod.OPTIONS');
274
+ });
275
+ (0, globals_1.it)('should generate IAM policy for all HttpApis', () => {
276
+ const renderArgs = {
277
+ data: {
278
+ importFrom: './data/resource',
279
+ restApis: [
280
+ {
281
+ apiName: 'testapi',
282
+ functionName: 'testFunction',
283
+ paths: [
284
+ {
285
+ path: '/items',
286
+ methods: ['GET'],
287
+ authType: 'open',
288
+ lambdaFunction: 'testFunction',
289
+ },
290
+ ],
291
+ },
292
+ ],
293
+ },
294
+ function: {
295
+ importFrom: './function/resource',
296
+ functionNamesAndCategories: new Map([['testFunction', 'function']]),
297
+ },
298
+ auth: {
299
+ importFrom: './auth/resource',
300
+ },
301
+ };
302
+ const result = synthesizer.render(renderArgs);
303
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
304
+ const printer = typescript_1.default.createPrinter();
305
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
306
+ (0, globals_1.expect)(output).toContain('Policy');
307
+ (0, globals_1.expect)(output).toContain('PolicyStatement');
308
+ (0, globals_1.expect)(output).toContain('execute-api:Invoke');
309
+ (0, globals_1.expect)(output).toContain('arnForExecuteApi');
310
+ (0, globals_1.expect)(output).toContain('authenticatedUserIamRole');
311
+ (0, globals_1.expect)(output).toContain('unauthenticatedUserIamRole');
312
+ (0, globals_1.expect)(output).toContain('attachInlinePolicy');
313
+ });
314
+ (0, globals_1.it)('should generate backend output for client configuration', () => {
315
+ const renderArgs = {
316
+ data: {
317
+ importFrom: './data/resource',
318
+ restApis: [
319
+ {
320
+ apiName: 'testapi',
321
+ functionName: 'testFunction',
322
+ paths: [
323
+ {
324
+ path: '/items',
325
+ methods: ['GET'],
326
+ authType: 'open',
327
+ lambdaFunction: 'testFunction',
328
+ },
329
+ ],
330
+ },
331
+ ],
332
+ },
333
+ function: {
334
+ importFrom: './function/resource',
335
+ functionNamesAndCategories: new Map([['testFunction', 'function']]),
336
+ },
337
+ };
338
+ const result = synthesizer.render(renderArgs);
339
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
340
+ const printer = typescript_1.default.createPrinter();
341
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
342
+ (0, globals_1.expect)(output).toContain('backend.addOutput');
343
+ (0, globals_1.expect)(output).toContain('api');
344
+ (0, globals_1.expect)(output).toContain('REST');
345
+ (0, globals_1.expect)(output).toContain('endpoint');
346
+ (0, globals_1.expect)(output).toContain('region');
347
+ });
348
+ (0, globals_1.it)('should skip routes for non-existent functions', () => {
349
+ const renderArgs = {
350
+ data: {
351
+ importFrom: './data/resource',
352
+ restApis: [
353
+ {
354
+ apiName: 'testapi',
355
+ functionName: 'existingFunction',
356
+ paths: [
357
+ {
358
+ path: '/items',
359
+ methods: ['GET'],
360
+ authType: 'open',
361
+ lambdaFunction: 'existingFunction',
362
+ },
363
+ {
364
+ path: '/missing',
365
+ methods: ['GET'],
366
+ authType: 'open',
367
+ lambdaFunction: 'nonExistentFunction',
368
+ },
369
+ ],
370
+ },
371
+ ],
372
+ },
373
+ function: {
374
+ importFrom: './function/resource',
375
+ functionNamesAndCategories: new Map([['existingFunction', 'function']]),
376
+ },
377
+ };
378
+ const result = synthesizer.render(renderArgs);
379
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
380
+ const printer = typescript_1.default.createPrinter();
381
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
382
+ (0, globals_1.expect)(output).toContain('/items');
383
+ (0, globals_1.expect)(output).toContain('existingFunction');
384
+ (0, globals_1.expect)(output).not.toContain('/missing');
385
+ (0, globals_1.expect)(output).not.toContain('nonExistentFunction');
386
+ });
387
+ (0, globals_1.it)('should respect CORS configuration from Gen1 project', () => {
388
+ const renderArgs = {
389
+ data: {
390
+ importFrom: './data/resource',
391
+ restApis: [
392
+ {
393
+ apiName: 'testapi',
394
+ functionName: 'testFunction',
395
+ paths: [
396
+ {
397
+ path: '/items',
398
+ methods: ['GET'],
399
+ authType: 'open',
400
+ lambdaFunction: 'testFunction',
401
+ },
402
+ ],
403
+ corsConfiguration: {
404
+ allowOrigins: ['https://example.com'],
405
+ allowMethods: ['GET', 'POST'],
406
+ allowHeaders: ['content-type', 'authorization'],
407
+ },
408
+ },
409
+ ],
410
+ },
411
+ function: {
412
+ importFrom: './function/resource',
413
+ functionNamesAndCategories: new Map([['testFunction', 'function']]),
414
+ },
415
+ };
416
+ const result = synthesizer.render(renderArgs);
417
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
418
+ const printer = typescript_1.default.createPrinter();
419
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
420
+ (0, globals_1.expect)(output).toContain('https://example.com');
421
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.GET');
422
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.POST');
423
+ (0, globals_1.expect)(output).toContain('content-type');
424
+ (0, globals_1.expect)(output).toContain('authorization');
425
+ (0, globals_1.expect)(output).not.toContain('CorsHttpMethod.ANY');
426
+ });
427
+ (0, globals_1.it)('should use default CORS configuration when not specified in Gen1', () => {
428
+ const renderArgs = {
429
+ data: {
430
+ importFrom: './data/resource',
431
+ restApis: [
432
+ {
433
+ apiName: 'testapi',
434
+ functionName: 'testFunction',
435
+ paths: [
436
+ {
437
+ path: '/items',
438
+ methods: ['GET'],
439
+ authType: 'open',
440
+ lambdaFunction: 'testFunction',
441
+ },
442
+ ],
443
+ },
444
+ ],
445
+ },
446
+ function: {
447
+ importFrom: './function/resource',
448
+ functionNamesAndCategories: new Map([['testFunction', 'function']]),
449
+ },
450
+ };
451
+ const result = synthesizer.render(renderArgs);
452
+ const sourceFile = typescript_1.default.createSourceFile('test.ts', '', typescript_1.default.ScriptTarget.Latest);
453
+ const printer = typescript_1.default.createPrinter();
454
+ const output = printer.printList(typescript_1.default.ListFormat.SourceFileStatements, result, sourceFile);
455
+ (0, globals_1.expect)(output).toContain('corsPreflight');
456
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.GET');
457
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.POST');
458
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.PUT');
459
+ (0, globals_1.expect)(output).toContain('CorsHttpMethod.DELETE');
460
+ (0, globals_1.expect)(output).toContain('content-type');
461
+ (0, globals_1.expect)(output).toContain('authorization');
462
+ });
463
+ });
464
+ (0, globals_1.describe)('DynamoDB table generation', () => {
465
+ (0, globals_1.it)('should generate table with underscores in name', () => {
466
+ const tableDefinition = {
467
+ tableName: 'countsTable-dev',
468
+ partitionKey: { name: 'postId', type: 'STRING' },
469
+ sortKey: { name: 'metricType', type: 'STRING' },
470
+ billingMode: 'PROVISIONED',
471
+ readCapacity: 5,
472
+ writeCapacity: 5,
473
+ };
474
+ const result = synthesizer.render({
475
+ storage: {
476
+ importFrom: './storage/resource',
477
+ dynamoTables: [tableDefinition],
478
+ },
479
+ });
480
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
481
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
482
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
483
+ import { defineBackend } from "@aws-amplify/backend";
484
+
485
+
486
+ const backend = defineBackend({});
487
+ const storageStack = backend.createStack("storage");
488
+ new Table(storageStack, "countsTable", { partitionKey: { name: "postId", type: AttributeType.STRING }, billingMode: BillingMode.PROVISIONED, readCapacity: 5, writeCapacity: 5, sortKey: { name: "metricType", type: AttributeType.STRING } });
489
+ "
490
+ `);
491
+ });
492
+ (0, globals_1.it)('should generate table with partition key and sort key', () => {
493
+ const tableDefinition = {
494
+ tableName: 'testTable',
495
+ partitionKey: { name: 'id', type: 'STRING' },
496
+ sortKey: { name: 'timestamp', type: 'NUMBER' },
497
+ billingMode: 'PAY_PER_REQUEST',
498
+ };
499
+ const result = synthesizer.render({
500
+ storage: {
501
+ importFrom: './storage/resource',
502
+ dynamoTables: [tableDefinition],
503
+ },
504
+ });
505
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
506
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
507
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
508
+ import { defineBackend } from "@aws-amplify/backend";
509
+
510
+
511
+ const backend = defineBackend({});
512
+ const storageStack = backend.createStack("storage");
513
+ new Table(storageStack, "testTable", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST, sortKey: { name: "timestamp", type: AttributeType.NUMBER } });
514
+ "
515
+ `);
516
+ });
517
+ (0, globals_1.it)('should generate table with GSI', () => {
518
+ const tableDefinition = {
519
+ tableName: 'testTable',
520
+ partitionKey: { name: 'id', type: 'STRING' },
521
+ billingMode: 'PROVISIONED',
522
+ readCapacity: 5,
523
+ writeCapacity: 5,
524
+ gsis: [
525
+ {
526
+ indexName: 'testIndex',
527
+ partitionKey: { name: 'gsiPK', type: 'STRING' },
528
+ sortKey: { name: 'gsiSK', type: 'NUMBER' },
529
+ },
530
+ ],
531
+ };
532
+ const result = synthesizer.render({
533
+ storage: {
534
+ importFrom: './storage/resource',
535
+ dynamoTables: [tableDefinition],
536
+ },
537
+ });
538
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
539
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
540
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
541
+ import { defineBackend } from "@aws-amplify/backend";
542
+
543
+
544
+ const backend = defineBackend({});
545
+ const storageStack = backend.createStack("storage");
546
+ const testTable = new Table(storageStack, "testTable", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PROVISIONED, readCapacity: 5, writeCapacity: 5 });
547
+ testTable.addGlobalSecondaryIndex({ indexName: "testIndex", partitionKey: { name: "gsiPK", type: AttributeType.STRING }, sortKey: { name: "gsiSK", type: AttributeType.NUMBER }, readCapacity: 5, writeCapacity: 5 });
548
+ "
549
+ `);
550
+ });
551
+ (0, globals_1.it)('should generate table with stream configuration', () => {
552
+ const tableDefinition = {
553
+ tableName: 'streamTable',
554
+ partitionKey: { name: 'id', type: 'STRING' },
555
+ billingMode: 'PAY_PER_REQUEST',
556
+ streamEnabled: true,
557
+ streamViewType: 'NEW_AND_OLD_IMAGES',
558
+ };
559
+ const result = synthesizer.render({
560
+ storage: {
561
+ importFrom: './storage/resource',
562
+ dynamoTables: [tableDefinition],
563
+ },
564
+ });
565
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
566
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
567
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
568
+ import { defineBackend } from "@aws-amplify/backend";
569
+
570
+
571
+ const backend = defineBackend({});
572
+ const storageStack = backend.createStack("storage");
573
+ new Table(storageStack, "streamTable", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST, stream: StreamViewType.NEW_AND_OLD_IMAGES });
574
+ "
575
+ `);
576
+ });
577
+ (0, globals_1.it)('should handle multiple tables with different configurations', () => {
578
+ const tables = [
579
+ {
580
+ tableName: 'table-one',
581
+ partitionKey: { name: 'pk1', type: 'STRING' },
582
+ billingMode: 'PAY_PER_REQUEST',
583
+ },
584
+ {
585
+ tableName: 'table-two',
586
+ partitionKey: { name: 'pk2', type: 'NUMBER' },
587
+ sortKey: { name: 'sk2', type: 'STRING' },
588
+ billingMode: 'PROVISIONED',
589
+ readCapacity: 10,
590
+ writeCapacity: 10,
591
+ },
592
+ ];
593
+ const result = synthesizer.render({
594
+ storage: {
595
+ importFrom: './storage/resource',
596
+ dynamoTables: tables,
597
+ },
598
+ });
599
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
600
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
601
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
602
+ import { defineBackend } from "@aws-amplify/backend";
603
+
604
+
605
+ const backend = defineBackend({});
606
+ const storageStack = backend.createStack("storage");
607
+ new Table(storageStack, "table", { partitionKey: { name: "pk1", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST });
608
+ new Table(storageStack, "table", { partitionKey: { name: "pk2", type: AttributeType.NUMBER }, billingMode: BillingMode.PROVISIONED, readCapacity: 10, writeCapacity: 10, sortKey: { name: "sk2", type: AttributeType.STRING } });
609
+ "
610
+ `);
611
+ });
612
+ (0, globals_1.it)('should include required CDK imports for DynamoDB', () => {
613
+ const tableDefinition = {
614
+ tableName: 'importTest',
615
+ partitionKey: { name: 'id', type: 'STRING' },
616
+ billingMode: 'PAY_PER_REQUEST',
617
+ };
618
+ const result = synthesizer.render({
619
+ storage: {
620
+ importFrom: './storage/resource',
621
+ dynamoTables: [tableDefinition],
622
+ },
623
+ });
624
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
625
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
626
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
627
+ import { defineBackend } from "@aws-amplify/backend";
628
+
629
+
630
+ const backend = defineBackend({});
631
+ const storageStack = backend.createStack("storage");
632
+ new Table(storageStack, "importTest", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST });
633
+ "
634
+ `);
635
+ });
636
+ (0, globals_1.it)('should create storage stack when no S3 bucket exists', () => {
637
+ const tableDefinition = {
638
+ tableName: 'stackTest',
639
+ partitionKey: { name: 'id', type: 'STRING' },
640
+ billingMode: 'PAY_PER_REQUEST',
641
+ };
642
+ const result = synthesizer.render({
643
+ storage: {
644
+ importFrom: './storage/resource',
645
+ dynamoTables: [tableDefinition],
646
+ },
647
+ });
648
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
649
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
650
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
651
+ import { defineBackend } from "@aws-amplify/backend";
652
+
653
+
654
+ const backend = defineBackend({});
655
+ const storageStack = backend.createStack("storage");
656
+ new Table(storageStack, "stackTest", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST });
657
+ "
658
+ `);
659
+ });
660
+ (0, globals_1.it)('should use existing storage stack when S3 bucket exists', () => {
661
+ const tableDefinition = {
662
+ tableName: 'stackTest',
663
+ partitionKey: { name: 'id', type: 'STRING' },
664
+ billingMode: 'PAY_PER_REQUEST',
665
+ };
666
+ const result = synthesizer.render({
667
+ storage: {
668
+ importFrom: './storage/resource',
669
+ dynamoTables: [tableDefinition],
670
+ hasS3Bucket: 'testBucket',
671
+ bucketName: 'testBucket',
672
+ },
673
+ });
674
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
675
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
676
+ "import { storage } from "./storage/resource";
677
+ import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
678
+ import { defineBackend } from "@aws-amplify/backend";
679
+
680
+
681
+ const backend = defineBackend({
682
+ storage
683
+ });
684
+ const storageStack = backend.storage.stack;
685
+ new Table(storageStack, "stackTest", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST });
686
+ const s3Bucket = backend.storage.resources.cfnResources.cfnBucket;
687
+ // Use this bucket name post refactor
688
+ // s3Bucket.bucketName = 'testBucket';
689
+ "
690
+ `);
691
+ });
692
+ });
693
+ (0, globals_1.describe)('Table name transformation', () => {
694
+ (0, globals_1.it)('should replace multiple hyphens with underscores', () => {
695
+ const tableDefinition = {
696
+ tableName: 'my-complex-table-name-dev',
697
+ partitionKey: { name: 'id', type: 'STRING' },
698
+ billingMode: 'PAY_PER_REQUEST',
699
+ };
700
+ const result = synthesizer.render({
701
+ storage: {
702
+ importFrom: './storage/resource',
703
+ dynamoTables: [tableDefinition],
704
+ },
705
+ });
706
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
707
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
708
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
709
+ import { defineBackend } from "@aws-amplify/backend";
710
+
711
+
712
+ const backend = defineBackend({});
713
+ const storageStack = backend.createStack("storage");
714
+ new Table(storageStack, "my_complex_table_name", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST });
715
+ "
716
+ `);
717
+ });
718
+ (0, globals_1.it)('should handle table names without hyphens', () => {
719
+ const tableDefinition = {
720
+ tableName: 'simpleTableName',
721
+ partitionKey: { name: 'id', type: 'STRING' },
722
+ billingMode: 'PAY_PER_REQUEST',
723
+ };
724
+ const result = synthesizer.render({
725
+ storage: {
726
+ importFrom: './storage/resource',
727
+ dynamoTables: [tableDefinition],
728
+ },
729
+ });
730
+ const source = (0, ts_node_printer_1.printNodeArray)(result);
731
+ (0, globals_1.expect)(source).toMatchInlineSnapshot(`
732
+ "import { Table, AttributeType, BillingMode, StreamViewType } from "aws-cdk-lib/aws-dynamodb";
733
+ import { defineBackend } from "@aws-amplify/backend";
734
+
735
+
736
+ const backend = defineBackend({});
737
+ const storageStack = backend.createStack("storage");
738
+ new Table(storageStack, "simpleTableName", { partitionKey: { name: "id", type: AttributeType.STRING }, billingMode: BillingMode.PAY_PER_REQUEST });
739
+ "
740
+ `);
741
+ });
742
+ });
743
+ });
744
+ //# sourceMappingURL=synthesizer.test.js.map