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