@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,899 @@
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
+ exports.BackendSynthesizer = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
9
+ const assert_1 = __importDefault(require("assert"));
10
+ const ts_factory_utils_1 = require("../ts_factory_utils");
11
+ const factory = typescript_1.default.factory;
12
+ class BackendSynthesizer {
13
+ constructor() {
14
+ this.importDurationFlag = false;
15
+ this.oAuthFlag = false;
16
+ this.readWriteAttributeFlag = false;
17
+ this.supportedIdentityProviderFlag = false;
18
+ }
19
+ createPropertyAccessExpression(objectIdentifier, propertyPath) {
20
+ const parts = propertyPath.split('.');
21
+ let expression = objectIdentifier;
22
+ for (let i = 0; i < parts.length; i++) {
23
+ expression = factory.createPropertyAccessExpression(expression, factory.createIdentifier(parts[i]));
24
+ }
25
+ return expression;
26
+ }
27
+ createVariableDeclaration(identifierName, propertyPath) {
28
+ const identifier = factory.createIdentifier(identifierName);
29
+ const propertyAccessExpression = this.createPropertyAccessExpression(factory.createIdentifier('backend'), propertyPath);
30
+ return factory.createVariableDeclaration(identifier, undefined, undefined, propertyAccessExpression);
31
+ }
32
+ createVariableStatement(variableDeclaration) {
33
+ return factory.createVariableStatement([], factory.createVariableDeclarationList([variableDeclaration], typescript_1.default.NodeFlags.Const));
34
+ }
35
+ createImportStatement(identifiers, backendPackageName) {
36
+ return factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports(identifiers.map((identifier) => factory.createImportSpecifier(false, undefined, identifier)))), factory.createStringLiteral(backendPackageName));
37
+ }
38
+ defineBackendCall(backendFunctionIdentifier, properties) {
39
+ const backendFunctionArgs = factory.createObjectLiteralExpression(properties, true);
40
+ return factory.createCallExpression(backendFunctionIdentifier, undefined, [backendFunctionArgs]);
41
+ }
42
+ setPropertyValue(objectIdentifier, propertyPath, value) {
43
+ const propertyAccessExpression = this.createPropertyAccessExpression(objectIdentifier, propertyPath);
44
+ const overrideValue = this.getOverrideValue(value);
45
+ return factory.createExpressionStatement(factory.createAssignment(propertyAccessExpression, overrideValue));
46
+ }
47
+ getOverrideValue(value) {
48
+ if (typeof value === 'number') {
49
+ return factory.createNumericLiteral(value);
50
+ }
51
+ else if (typeof value === 'string') {
52
+ return factory.createStringLiteral(value);
53
+ }
54
+ else if (Array.isArray(value) && value.every((item) => typeof item === 'string')) {
55
+ return factory.createArrayLiteralExpression(value.map((item) => factory.createStringLiteral(item)));
56
+ }
57
+ else if (typeof value === 'boolean') {
58
+ return value ? factory.createTrue() : factory.createFalse();
59
+ }
60
+ else if (typeof value === 'object' && value !== null) {
61
+ const properties = [];
62
+ for (const [key, val] of Object.entries(value)) {
63
+ const property = factory.createPropertyAssignment(factory.createIdentifier(key), this.getOverrideValue(val));
64
+ properties.push(property);
65
+ }
66
+ return factory.createObjectLiteralExpression(properties, true);
67
+ }
68
+ else if (value === undefined) {
69
+ return factory.createIdentifier('undefined');
70
+ }
71
+ throw new TypeError(`Unrecognized type: ${typeof value}`);
72
+ }
73
+ createBooleanPropertyAssignment(identifier, condition) {
74
+ return factory.createPropertyAssignment(factory.createIdentifier(identifier), condition ? factory.createTrue() : factory.createFalse());
75
+ }
76
+ createListPropertyAssignment(identifier, listAttribute) {
77
+ return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createArrayLiteralExpression(listAttribute.map((attribute) => factory.createStringLiteral(attribute))));
78
+ }
79
+ createEnumListPropertyAssignment(identifier, enumIdentifier, listAttribute) {
80
+ return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createArrayLiteralExpression(listAttribute.map((attribute) => factory.createPropertyAccessExpression(factory.createIdentifier(enumIdentifier), factory.createIdentifier(attribute))), true));
81
+ }
82
+ createNumericPropertyAssignment(identifier, numericLiteral) {
83
+ return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createNumericLiteral(numericLiteral));
84
+ }
85
+ createDurationPropertyAssignment(identifier, numericLiteral, durationUnit) {
86
+ const duration = factory.createCallExpression(factory.createIdentifier(`Duration.${durationUnit}`), undefined, [
87
+ factory.createNumericLiteral(numericLiteral),
88
+ ]);
89
+ return factory.createPropertyAssignment(factory.createIdentifier(identifier), duration);
90
+ }
91
+ createStringPropertyAssignment(identifier, stringLiteral) {
92
+ return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createStringLiteral(stringLiteral));
93
+ }
94
+ createUserPoolClientAssignment(userPoolClient, imports, createConstant) {
95
+ const userPoolClientAttributesMap = new Map();
96
+ userPoolClientAttributesMap.set('ClientSecret', 'generateSecret');
97
+ userPoolClientAttributesMap.set('ReadAttributes', 'readAttributes');
98
+ userPoolClientAttributesMap.set('WriteAttributes', 'writeAttributes');
99
+ userPoolClientAttributesMap.set('RefreshTokenValidity', 'refreshTokenValidity');
100
+ userPoolClientAttributesMap.set('AccessTokenValidity', 'accessTokenValidity');
101
+ userPoolClientAttributesMap.set('IdTokenValidity', 'idTokenValidity');
102
+ userPoolClientAttributesMap.set('RefreshToken', 'refreshToken');
103
+ userPoolClientAttributesMap.set('AccessToken', 'accessToken');
104
+ userPoolClientAttributesMap.set('IdToken', 'idToken');
105
+ userPoolClientAttributesMap.set('AllowedOAuthScopes', 'scopes');
106
+ userPoolClientAttributesMap.set('CallbackURLs', 'callbackUrls');
107
+ userPoolClientAttributesMap.set('LogoutURLs', 'logoutUrls');
108
+ userPoolClientAttributesMap.set('DefaultRedirectURI', 'defaultRedirectUri');
109
+ userPoolClientAttributesMap.set('AllowedOAuthFlowsUserPoolClient', 'disableOAuth');
110
+ userPoolClientAttributesMap.set('EnableTokenRevocation', 'enableTokenRevocation');
111
+ userPoolClientAttributesMap.set('EnablePropagateAdditionalUserContextData', 'enablePropagateAdditionalUserContextData');
112
+ userPoolClientAttributesMap.set('SupportedIdentityProviders', 'supportedIdentityProviders');
113
+ userPoolClientAttributesMap.set('AuthSessionValidity', 'authSessionValidity');
114
+ userPoolClientAttributesMap.set('ExplicitAuthFlows', 'authFlows');
115
+ userPoolClientAttributesMap.set('AllowedOAuthFlows', 'flows');
116
+ const addClientCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('userPool'), factory.createIdentifier('addClient')), undefined, [factory.createStringLiteral('NativeAppClient'), this.createNestedObjectExpression(userPoolClient, userPoolClientAttributesMap)]);
117
+ if (this.importDurationFlag) {
118
+ imports.push(this.createImportStatement([factory.createIdentifier('Duration')], 'aws-cdk-lib'));
119
+ }
120
+ if (this.readWriteAttributeFlag || this.oAuthFlag || this.supportedIdentityProviderFlag) {
121
+ const identifiers = [
122
+ ...(this.readWriteAttributeFlag ? [factory.createIdentifier('ClientAttributes')] : []),
123
+ ...(this.oAuthFlag ? [factory.createIdentifier('OAuthScope')] : []),
124
+ ...(this.supportedIdentityProviderFlag ? [factory.createIdentifier('UserPoolClientIdentityProvider')] : []),
125
+ ];
126
+ if (identifiers.length > 0) {
127
+ imports.push(this.createImportStatement(identifiers, 'aws-cdk-lib/aws-cognito'));
128
+ }
129
+ }
130
+ if (createConstant) {
131
+ return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier('userPoolClient'), undefined, undefined, addClientCall)], typescript_1.default.NodeFlags.Const));
132
+ }
133
+ else {
134
+ return factory.createExpressionStatement(addClientCall);
135
+ }
136
+ }
137
+ createPropertyAccessChain(identifiers) {
138
+ return identifiers
139
+ .slice(1)
140
+ .reduce((acc, curr) => factory.createPropertyAccessExpression(acc, factory.createIdentifier(curr)), factory.createIdentifier(identifiers[0]));
141
+ }
142
+ getProviderSetupDeclaration() {
143
+ const providerSetupResult = 'providerSetupResult';
144
+ return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
145
+ factory.createVariableDeclaration(factory.createIdentifier(providerSetupResult), undefined, undefined, factory.createPropertyAccessExpression(factory.createParenthesizedExpression(factory.createAsExpression(factory.createCallExpression(factory.createPropertyAccessExpression(this.createPropertyAccessChain(['backend', 'auth', 'stack', 'node', 'children']), factory.createIdentifier('find')), undefined, [
146
+ factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, factory.createIdentifier('child'))], undefined, factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), factory.createBinaryExpression(this.createPropertyAccessChain(['child', 'node', 'id']), factory.createToken(typescript_1.default.SyntaxKind.EqualsEqualsEqualsToken), factory.createStringLiteral('amplifyAuth'))),
147
+ ]), factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.AnyKeyword))), factory.createIdentifier(providerSetupResult))),
148
+ ], typescript_1.default.NodeFlags.Const));
149
+ }
150
+ getProviderSetupForeachStatement() {
151
+ const providerSetupResult = 'providerSetupResult';
152
+ return factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('Object'), factory.createIdentifier('keys')), undefined, [factory.createIdentifier(providerSetupResult)]), factory.createIdentifier('forEach')), undefined, [
153
+ factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, factory.createIdentifier('provider'))], undefined, factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), factory.createBlock([
154
+ factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
155
+ factory.createVariableDeclaration(factory.createIdentifier('providerSetupPropertyValue'), undefined, undefined, factory.createElementAccessExpression(factory.createIdentifier(providerSetupResult), factory.createIdentifier('provider'))),
156
+ ], typescript_1.default.NodeFlags.Const)),
157
+ factory.createIfStatement(factory.createLogicalAnd(factory.createPropertyAccessExpression(factory.createIdentifier('providerSetupPropertyValue'), factory.createIdentifier('node')), factory.createCallExpression(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createPropertyAccessExpression(this.createPropertyAccessChain(['providerSetupPropertyValue', 'node', 'id']), factory.createIdentifier('toLowerCase')), undefined, []), factory.createIdentifier('endsWith')), undefined, [factory.createStringLiteral('idp')])), factory.createBlock([
158
+ factory.createExpressionStatement(factory.createCallExpression(this.createPropertyAccessChain(['userPoolClient', 'node', 'addDependency']), undefined, [factory.createIdentifier('providerSetupPropertyValue')])),
159
+ ], true)),
160
+ ], true)),
161
+ ]));
162
+ }
163
+ createProviderSetupCode() {
164
+ const providerSetupDeclaration = this.getProviderSetupDeclaration();
165
+ const forEachStatement = this.getProviderSetupForeachStatement();
166
+ return [providerSetupDeclaration, forEachStatement];
167
+ }
168
+ createNestedObjectExpression(object, gen2PropertyMap) {
169
+ const objectLiterals = [];
170
+ const clientSecretKey = 'ClientSecret';
171
+ for (const [key, value] of Object.entries(object)) {
172
+ const mappedProperty = gen2PropertyMap.get(key);
173
+ if (mappedProperty) {
174
+ if (typeof value == 'boolean') {
175
+ if (key === 'AllowedOAuthFlowsUserPoolClient') {
176
+ objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, !value));
177
+ }
178
+ else {
179
+ objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, value));
180
+ }
181
+ }
182
+ else if (typeof value == 'string') {
183
+ if (!this.oAuthFlag && key == 'DefaultRedirectURI') {
184
+ this.oAuthFlag = true;
185
+ objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
186
+ }
187
+ else if (key === clientSecretKey) {
188
+ objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, true));
189
+ }
190
+ else if (key != 'DefaultRedirectURI') {
191
+ objectLiterals.push(this.createStringPropertyAssignment(mappedProperty, value));
192
+ }
193
+ }
194
+ else if (typeof value == 'number') {
195
+ if (['IdTokenValidity', 'RefreshTokenValidity', 'AccessTokenValidity', 'AuthSessionValidity'].includes(key)) {
196
+ this.importDurationFlag = true;
197
+ if (key == 'IdTokenValidity') {
198
+ let durationUnit = 'hours';
199
+ if (object['TokenValidityUnits'] && object['TokenValidityUnits'].IdToken) {
200
+ durationUnit = object['TokenValidityUnits'].IdToken;
201
+ }
202
+ objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, durationUnit));
203
+ }
204
+ else if (key == 'RefreshTokenValidity') {
205
+ let durationUnit = 'days';
206
+ if (object['TokenValidityUnits'] && object['TokenValidityUnits'].RefreshToken) {
207
+ durationUnit = object['TokenValidityUnits'].RefreshToken;
208
+ }
209
+ objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, durationUnit));
210
+ }
211
+ else if (key == 'AccessTokenValidity') {
212
+ let durationUnit = 'hours';
213
+ if (object['TokenValidityUnits'] && object['TokenValidityUnits'].AccessToken) {
214
+ durationUnit = object['TokenValidityUnits'].AccessToken;
215
+ }
216
+ objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, durationUnit));
217
+ }
218
+ else if (key == 'AuthSessionValidity') {
219
+ objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, 'minutes'));
220
+ }
221
+ }
222
+ else {
223
+ objectLiterals.push(this.createNumericPropertyAssignment(mappedProperty, value));
224
+ }
225
+ }
226
+ else if (Array.isArray(value) && gen2PropertyMap.has(key)) {
227
+ if (key == 'ReadAttributes' || key == 'WriteAttributes') {
228
+ objectLiterals.push(this.createReadWriteAttributes(mappedProperty, value));
229
+ }
230
+ else if (key == 'SupportedIdentityProviders') {
231
+ this.supportedIdentityProviderFlag = true;
232
+ objectLiterals.push(this.createEnumListPropertyAssignment(mappedProperty, 'UserPoolClientIdentityProvider', value.map((provider) => {
233
+ if (provider.toUpperCase() == 'LOGINWITHAMAZON') {
234
+ return 'AMAZON';
235
+ }
236
+ else if (provider.toUpperCase() === 'SIGNINWITHAPPLE') {
237
+ return 'APPLE';
238
+ }
239
+ return provider.toUpperCase();
240
+ })));
241
+ }
242
+ else if (!this.oAuthFlag && key == 'AllowedOAuthFlows') {
243
+ this.oAuthFlag = true;
244
+ objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
245
+ }
246
+ else if (key == 'ExplicitAuthFlows') {
247
+ objectLiterals.push(factory.createPropertyAssignment(factory.createIdentifier(mappedProperty), this.createAuthFlowsObjectExpression(value)));
248
+ }
249
+ else if (!this.oAuthFlag && key == 'AllowedOAuthScopes') {
250
+ this.oAuthFlag = true;
251
+ objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
252
+ }
253
+ else {
254
+ if (!this.oAuthFlag && (key == 'CallbackURLs' || key == 'LogoutURLs')) {
255
+ this.oAuthFlag = true;
256
+ objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
257
+ }
258
+ else if (key != 'CallbackURLs' && key != 'LogoutURLs' && key != 'AllowedOAuthScopes') {
259
+ objectLiterals.push(this.createListPropertyAssignment(mappedProperty, value));
260
+ }
261
+ }
262
+ }
263
+ else if (typeof value == 'object' && value !== null) {
264
+ objectLiterals.push(factory.createPropertyAssignment(factory.createIdentifier(key), this.createNestedObjectExpression(value, gen2PropertyMap)));
265
+ }
266
+ }
267
+ }
268
+ if (object[clientSecretKey] === undefined && gen2PropertyMap.has(clientSecretKey)) {
269
+ const mappedClientSecretKey = gen2PropertyMap.get(clientSecretKey);
270
+ (0, assert_1.default)(mappedClientSecretKey);
271
+ objectLiterals.push(this.createBooleanPropertyAssignment(mappedClientSecretKey, false));
272
+ }
273
+ return factory.createObjectLiteralExpression(objectLiterals, true);
274
+ }
275
+ createReadWriteAttributes(identifier, attributes) {
276
+ const standardAttrMap = new Map();
277
+ standardAttrMap.set('address', 'address');
278
+ standardAttrMap.set('birthdate', 'birthdate');
279
+ standardAttrMap.set('email', 'email');
280
+ standardAttrMap.set('family_name', 'familyName');
281
+ standardAttrMap.set('gender', 'gender');
282
+ standardAttrMap.set('given_name', 'givenName');
283
+ standardAttrMap.set('locale', 'locale');
284
+ standardAttrMap.set('middle_name', 'middleName');
285
+ standardAttrMap.set('name', 'fullname');
286
+ standardAttrMap.set('nickname', 'nickname');
287
+ standardAttrMap.set('phone_number', 'phoneNumber');
288
+ standardAttrMap.set('picture', 'profilePicture');
289
+ standardAttrMap.set('preferred_username', 'preferredUsername');
290
+ standardAttrMap.set('profile', 'profilePage');
291
+ standardAttrMap.set('updated_at', 'lastUpdateTime');
292
+ standardAttrMap.set('website', 'website');
293
+ standardAttrMap.set('zoneinfo', 'timezone');
294
+ standardAttrMap.set('email_verified', 'emailVerified');
295
+ standardAttrMap.set('phone_number_verified', 'phoneNumberVerified');
296
+ this.readWriteAttributeFlag = true;
297
+ const standardAttributes = attributes.filter((attribute) => !attribute.startsWith('custom:'));
298
+ const standardAttributesLiterals = [];
299
+ standardAttributes.forEach((attribute) => {
300
+ if (standardAttrMap.has(attribute)) {
301
+ const mappedAttribute = standardAttrMap.get(attribute);
302
+ if (mappedAttribute) {
303
+ standardAttributesLiterals.push(factory.createPropertyAssignment(factory.createIdentifier(mappedAttribute), factory.createTrue()));
304
+ }
305
+ }
306
+ });
307
+ let clientAttributes = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('new ClientAttributes()'), factory.createIdentifier('withStandardAttributes')), undefined, [factory.createObjectLiteralExpression(standardAttributesLiterals, true)]);
308
+ const customAttributes = attributes.filter((attribute) => attribute.startsWith('custom:'));
309
+ if (customAttributes) {
310
+ clientAttributes = factory.createCallExpression(factory.createPropertyAccessExpression(clientAttributes, factory.createIdentifier('withCustomAttributes')), undefined, customAttributes.map((attr) => factory.createStringLiteral(attr)));
311
+ }
312
+ return factory.createPropertyAssignment(factory.createIdentifier(identifier), clientAttributes);
313
+ }
314
+ mapOAuthScopes(scopes) {
315
+ const scopeMap = new Map();
316
+ scopeMap.set('phone', 'PHONE');
317
+ scopeMap.set('email', 'EMAIL');
318
+ scopeMap.set('openid', 'OPENID');
319
+ scopeMap.set('profile', 'PROFILE');
320
+ scopeMap.set('aws.cognito.signin.user.admin', 'COGNITO_ADMIN');
321
+ const scopesList = [];
322
+ scopes.forEach((scope) => {
323
+ if (scopeMap.has(scope)) {
324
+ const scopeValue = scopeMap.get(scope);
325
+ if (scopeValue) {
326
+ scopesList.push(scopeValue);
327
+ }
328
+ }
329
+ });
330
+ return scopesList;
331
+ }
332
+ createOAuthObjectExpression(object, map) {
333
+ const oAuthLiterals = [];
334
+ for (const [key, value] of Object.entries(object)) {
335
+ if (key == 'AllowedOAuthFlows') {
336
+ oAuthLiterals.push(factory.createPropertyAssignment(factory.createIdentifier('flows'), this.createOAuthFlowsObjectExpression(value)));
337
+ }
338
+ else if (key == 'AllowedOAuthScopes') {
339
+ oAuthLiterals.push(this.createEnumListPropertyAssignment('scopes', 'OAuthScope', this.mapOAuthScopes(value)));
340
+ }
341
+ else if (key == 'CallbackURLs' || key == 'LogoutURLs') {
342
+ const urlValue = map.get(key);
343
+ if (urlValue) {
344
+ oAuthLiterals.push(this.createListPropertyAssignment(urlValue, value));
345
+ }
346
+ }
347
+ else if (key == 'DefaultRedirectURI') {
348
+ const redirectUriValue = map.get(key);
349
+ if (redirectUriValue) {
350
+ oAuthLiterals.push(this.createStringPropertyAssignment(redirectUriValue, value));
351
+ }
352
+ }
353
+ }
354
+ return factory.createPropertyAssignment(factory.createIdentifier('oAuth'), factory.createObjectLiteralExpression(oAuthLiterals, true));
355
+ }
356
+ createOAuthFlowsObjectExpression(value) {
357
+ return factory.createObjectLiteralExpression([
358
+ this.createBooleanPropertyAssignment('authorizationCodeGrant', value.includes(client_cognito_identity_provider_1.OAuthFlowType.code)),
359
+ this.createBooleanPropertyAssignment('implicitCodeGrant', value.includes(client_cognito_identity_provider_1.OAuthFlowType.implicit)),
360
+ this.createBooleanPropertyAssignment('clientCredentials', value.includes(client_cognito_identity_provider_1.OAuthFlowType.client_credentials)),
361
+ ]);
362
+ }
363
+ createAuthFlowsObjectExpression(value) {
364
+ return factory.createObjectLiteralExpression([
365
+ this.createBooleanPropertyAssignment('adminUserPassword', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_ADMIN_USER_PASSWORD_AUTH)),
366
+ this.createBooleanPropertyAssignment('custom', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_CUSTOM_AUTH)),
367
+ this.createBooleanPropertyAssignment('userPassword', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_USER_PASSWORD_AUTH)),
368
+ this.createBooleanPropertyAssignment('userSrp', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_USER_SRP_AUTH)),
369
+ ]);
370
+ }
371
+ createAdditionalAuthProvidersArray(providers) {
372
+ const providerElements = providers.map((provider) => {
373
+ const properties = [];
374
+ properties.push(factory.createPropertyAssignment(factory.createIdentifier('authenticationType'), factory.createStringLiteral(provider.authenticationType)));
375
+ if (provider.userPoolConfig) {
376
+ const userPoolConfigProps = [];
377
+ if (provider.userPoolConfig.appIdClientRegex) {
378
+ userPoolConfigProps.push(factory.createPropertyAssignment(factory.createIdentifier('appIdClientRegex'), factory.createStringLiteral(provider.userPoolConfig.appIdClientRegex)));
379
+ }
380
+ if (provider.userPoolConfig.awsRegion) {
381
+ userPoolConfigProps.push(factory.createPropertyAssignment(factory.createIdentifier('awsRegion'), factory.createPropertyAccessExpression(factory.createIdentifier('backend'), 'auth.resources.userPool.stack.region')));
382
+ }
383
+ if (provider.userPoolConfig.userPoolId) {
384
+ userPoolConfigProps.push(factory.createPropertyAssignment(factory.createIdentifier('userPoolId'), this.createPropertyAccessExpression(factory.createIdentifier('backend'), 'auth.resources.userPool.userPoolId')));
385
+ }
386
+ properties.push(factory.createPropertyAssignment(factory.createIdentifier('userPoolConfig'), factory.createObjectLiteralExpression(userPoolConfigProps, true)));
387
+ }
388
+ if (provider.lambdaAuthorizerConfig) {
389
+ properties.push(factory.createPropertyAssignment(factory.createIdentifier('lambdaAuthorizerConfig'), this.getOverrideValue(provider.lambdaAuthorizerConfig)));
390
+ }
391
+ if (provider.openIdConnectConfig) {
392
+ properties.push(factory.createPropertyAssignment(factory.createIdentifier('openIdConnectConfig'), this.getOverrideValue(provider.openIdConnectConfig)));
393
+ }
394
+ return factory.createObjectLiteralExpression(properties, true);
395
+ });
396
+ return factory.createArrayLiteralExpression(providerElements, true);
397
+ }
398
+ createTemplateLiteralExpression(id1, id2, templateHead, templateSpan, templateTail) {
399
+ return factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier(id1), factory.createIdentifier(id2)), factory.createTemplateExpression(factory.createTemplateHead(templateHead), [
400
+ factory.createTemplateSpan(factory.createIdentifier(templateSpan), factory.createTemplateTail(templateTail)),
401
+ ])));
402
+ }
403
+ createAmplifyEnvNameLogic() {
404
+ const variableDeclaration = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
405
+ factory.createVariableDeclaration(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'), undefined, undefined, factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('process'), factory.createIdentifier('env')), factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'))),
406
+ ], typescript_1.default.NodeFlags.Let));
407
+ const ifStatement = factory.createIfStatement(factory.createLogicalAnd(factory.createPropertyAccessExpression(factory.createIdentifier('ci'), factory.createIdentifier('isCI')), factory.createLogicalNot(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'))), factory.createBlock([
408
+ factory.createThrowStatement(factory.createNewExpression(factory.createIdentifier('Error'), undefined, [
409
+ factory.createStringLiteral('AMPLIFY_GEN_1_ENV_NAME is required in CI environment'),
410
+ ])),
411
+ ], true), factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalNot(factory.createPropertyAccessExpression(factory.createIdentifier('ci'), factory.createIdentifier('isCI'))), factory.createLogicalNot(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'))), factory.createBlock([
412
+ factory.createExpressionStatement(factory.createBinaryExpression(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'), factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), factory.createStringLiteral('sandbox'))),
413
+ ], true)));
414
+ return [variableDeclaration, ifStatement];
415
+ }
416
+ sanitizeVariableName(name) {
417
+ return name.replace(/-/g, '_');
418
+ }
419
+ render(renderArgs) {
420
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
421
+ const authFunctionIdentifier = factory.createIdentifier('auth');
422
+ const storageFunctionIdentifier = factory.createIdentifier('storage');
423
+ const dataFunctionIdentifier = factory.createIdentifier('data');
424
+ const backendFunctionIdentifier = factory.createIdentifier('defineBackend');
425
+ const imports = [];
426
+ const errors = [];
427
+ const defineBackendProperties = [];
428
+ const nodes = [];
429
+ const mappedPolicyType = {
430
+ MinimumLength: 'minimumLength',
431
+ RequireUppercase: 'requireUppercase',
432
+ RequireLowercase: 'requireLowercase',
433
+ RequireNumbers: 'requireNumbers',
434
+ RequireSymbols: 'requireSymbols',
435
+ PasswordHistorySize: 'passwordHistorySize',
436
+ TemporaryPasswordValidityDays: 'temporaryPasswordValidityDays',
437
+ };
438
+ if (renderArgs.auth) {
439
+ imports.push(this.createImportStatement([authFunctionIdentifier], renderArgs.auth.importFrom));
440
+ const auth = factory.createShorthandPropertyAssignment(authFunctionIdentifier);
441
+ defineBackendProperties.push(auth);
442
+ }
443
+ if (renderArgs.data) {
444
+ imports.push(this.createImportStatement([dataFunctionIdentifier], renderArgs.data.importFrom));
445
+ const data = factory.createShorthandPropertyAssignment(dataFunctionIdentifier);
446
+ defineBackendProperties.push(data);
447
+ }
448
+ if (((_a = renderArgs.storage) === null || _a === void 0 ? void 0 : _a.hasS3Bucket) || ((_c = (_b = renderArgs.storage) === null || _b === void 0 ? void 0 : _b.dynamoTables) === null || _c === void 0 ? void 0 : _c.length)) {
449
+ if (renderArgs.storage.hasS3Bucket) {
450
+ imports.push(this.createImportStatement([storageFunctionIdentifier], renderArgs.storage.importFrom));
451
+ const storage = factory.createShorthandPropertyAssignment(storageFunctionIdentifier);
452
+ defineBackendProperties.push(storage);
453
+ }
454
+ }
455
+ if (renderArgs.function) {
456
+ const functionNameCategories = renderArgs.function.functionNamesAndCategories;
457
+ for (const [functionName, category] of functionNameCategories) {
458
+ const functionProperty = factory.createShorthandPropertyAssignment(factory.createIdentifier(functionName));
459
+ defineBackendProperties.push(functionProperty);
460
+ imports.push(this.createImportStatement([factory.createIdentifier(functionName)], `./${category}/${functionName}/resource`));
461
+ }
462
+ }
463
+ if ((_d = renderArgs.data) === null || _d === void 0 ? void 0 : _d.restApis) {
464
+ const allUniqueFunctions = new Set();
465
+ renderArgs.data.restApis.forEach((restApi) => {
466
+ if (restApi.uniqueFunctions) {
467
+ restApi.uniqueFunctions.forEach((funcName) => allUniqueFunctions.add(funcName));
468
+ }
469
+ });
470
+ const existingFunctions = ((_e = renderArgs.function) === null || _e === void 0 ? void 0 : _e.functionNamesAndCategories) || new Map();
471
+ allUniqueFunctions.forEach((funcName) => {
472
+ if (!existingFunctions.has(funcName)) {
473
+ const functionProperty = factory.createShorthandPropertyAssignment(factory.createIdentifier(funcName));
474
+ defineBackendProperties.push(functionProperty);
475
+ imports.push(this.createImportStatement([factory.createIdentifier(funcName)], `./function/${funcName}/resource`));
476
+ }
477
+ });
478
+ }
479
+ if ((_g = (_f = renderArgs.storage) === null || _f === void 0 ? void 0 : _f.dynamoTables) === null || _g === void 0 ? void 0 : _g.length) {
480
+ imports.push(this.createImportStatement([
481
+ factory.createIdentifier('Table'),
482
+ factory.createIdentifier('AttributeType'),
483
+ factory.createIdentifier('BillingMode'),
484
+ factory.createIdentifier('StreamViewType'),
485
+ ], 'aws-cdk-lib/aws-dynamodb'));
486
+ const stackDeclaration = factory.createVariableStatement([], factory.createVariableDeclarationList([
487
+ factory.createVariableDeclaration('storageStack', undefined, undefined, renderArgs.storage.hasS3Bucket
488
+ ? factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('storage')), factory.createIdentifier('stack'))
489
+ : factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('createStack')), undefined, [factory.createStringLiteral('storage')])),
490
+ ], typescript_1.default.NodeFlags.Const));
491
+ nodes.push(stackDeclaration);
492
+ renderArgs.storage.dynamoTables.forEach((table) => {
493
+ var _a;
494
+ const baseTableName = table.tableName.replace(/-[^-]+$/, '');
495
+ const sanitizedTableName = this.sanitizeVariableName(baseTableName);
496
+ const tableProps = [
497
+ factory.createPropertyAssignment('partitionKey', factory.createObjectLiteralExpression([
498
+ factory.createPropertyAssignment('name', factory.createStringLiteral(table.partitionKey.name)),
499
+ factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(table.partitionKey.type))),
500
+ ])),
501
+ factory.createPropertyAssignment('billingMode', factory.createPropertyAccessExpression(factory.createIdentifier('BillingMode'), factory.createIdentifier(table.billingMode || 'PROVISIONED'))),
502
+ ];
503
+ if (table.billingMode !== 'PAY_PER_REQUEST') {
504
+ tableProps.push(factory.createPropertyAssignment('readCapacity', factory.createNumericLiteral(String(table.readCapacity || 5))));
505
+ tableProps.push(factory.createPropertyAssignment('writeCapacity', factory.createNumericLiteral(String(table.writeCapacity || 5))));
506
+ }
507
+ if (table.streamEnabled && table.streamViewType) {
508
+ tableProps.push(factory.createPropertyAssignment('stream', factory.createPropertyAccessExpression(factory.createIdentifier('StreamViewType'), factory.createIdentifier(table.streamViewType))));
509
+ }
510
+ if (table.sortKey) {
511
+ tableProps.push(factory.createPropertyAssignment('sortKey', factory.createObjectLiteralExpression([
512
+ factory.createPropertyAssignment('name', factory.createStringLiteral(table.sortKey.name)),
513
+ factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(table.sortKey.type))),
514
+ ])));
515
+ }
516
+ if (table.gsis && table.gsis.length > 0) {
517
+ const tableDeclaration = factory.createVariableStatement([], factory.createVariableDeclarationList([
518
+ factory.createVariableDeclaration(sanitizedTableName, undefined, undefined, factory.createNewExpression(factory.createIdentifier('Table'), undefined, [
519
+ factory.createIdentifier('storageStack'),
520
+ factory.createStringLiteral(sanitizedTableName),
521
+ factory.createObjectLiteralExpression(tableProps),
522
+ ])),
523
+ ], typescript_1.default.NodeFlags.Const));
524
+ nodes.push(tableDeclaration);
525
+ }
526
+ else {
527
+ const tableCreation = factory.createExpressionStatement(factory.createNewExpression(factory.createIdentifier('Table'), undefined, [
528
+ factory.createIdentifier('storageStack'),
529
+ factory.createStringLiteral(sanitizedTableName),
530
+ factory.createObjectLiteralExpression(tableProps),
531
+ ]));
532
+ nodes.push(tableCreation);
533
+ }
534
+ (_a = table.gsis) === null || _a === void 0 ? void 0 : _a.forEach((gsi) => {
535
+ const gsiProps = [
536
+ factory.createPropertyAssignment('indexName', factory.createStringLiteral(gsi.indexName)),
537
+ factory.createPropertyAssignment('partitionKey', factory.createObjectLiteralExpression([
538
+ factory.createPropertyAssignment('name', factory.createStringLiteral(gsi.partitionKey.name)),
539
+ factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(gsi.partitionKey.type))),
540
+ ])),
541
+ ];
542
+ if (gsi.sortKey) {
543
+ gsiProps.push(factory.createPropertyAssignment('sortKey', factory.createObjectLiteralExpression([
544
+ factory.createPropertyAssignment('name', factory.createStringLiteral(gsi.sortKey.name)),
545
+ factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(gsi.sortKey.type))),
546
+ ])));
547
+ }
548
+ gsiProps.push(factory.createPropertyAssignment('readCapacity', factory.createNumericLiteral('5')));
549
+ gsiProps.push(factory.createPropertyAssignment('writeCapacity', factory.createNumericLiteral('5')));
550
+ const gsiCall = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(sanitizedTableName), factory.createIdentifier('addGlobalSecondaryIndex')), undefined, [factory.createObjectLiteralExpression(gsiProps)]));
551
+ nodes.push(gsiCall);
552
+ });
553
+ });
554
+ }
555
+ imports.push(this.createImportStatement([backendFunctionIdentifier], '@aws-amplify/backend'));
556
+ if (renderArgs.analytics) {
557
+ const analyticsFunctionIdentifier = factory.createIdentifier('analytics');
558
+ imports.push(this.createImportStatement([analyticsFunctionIdentifier], renderArgs.analytics.importFrom));
559
+ }
560
+ if (((_h = renderArgs.data) === null || _h === void 0 ? void 0 : _h.restApis) && renderArgs.function) {
561
+ const functionNameCategories = renderArgs.function.functionNamesAndCategories;
562
+ const hasRestApis = renderArgs.data.restApis.some((restApi) => functionNameCategories.has(restApi.functionName));
563
+ if (hasRestApis) {
564
+ imports.push(this.createImportStatement([factory.createIdentifier('HttpApi'), factory.createIdentifier('HttpMethod'), factory.createIdentifier('CorsHttpMethod')], 'aws-cdk-lib/aws-apigatewayv2'));
565
+ imports.push(this.createImportStatement([factory.createIdentifier('HttpLambdaIntegration')], 'aws-cdk-lib/aws-apigatewayv2-integrations'));
566
+ const hasPrivateAuth = renderArgs.data.restApis.some((restApi) => restApi.paths.some((path) => path.authType === 'private'));
567
+ const hasProtectedAuth = renderArgs.data.restApis.some((restApi) => restApi.paths.some((path) => path.authType === 'protected'));
568
+ const hasUserPoolGroups = renderArgs.data.restApis.some((restApi) => restApi.paths.some((path) => path.userPoolGroups && path.userPoolGroups.length > 0));
569
+ const authorizerImports = [];
570
+ if (hasPrivateAuth) {
571
+ authorizerImports.push(factory.createIdentifier('HttpIamAuthorizer'));
572
+ }
573
+ if (hasProtectedAuth && renderArgs.auth) {
574
+ authorizerImports.push(factory.createIdentifier('HttpUserPoolAuthorizer'));
575
+ }
576
+ if (hasUserPoolGroups && renderArgs.auth) {
577
+ authorizerImports.push(factory.createIdentifier('HttpUserPoolAuthorizer'));
578
+ }
579
+ if (authorizerImports.length > 0) {
580
+ imports.push(this.createImportStatement(authorizerImports, 'aws-cdk-lib/aws-apigatewayv2-authorizers'));
581
+ }
582
+ imports.push(this.createImportStatement([factory.createIdentifier('Policy'), factory.createIdentifier('PolicyStatement')], 'aws-cdk-lib/aws-iam'));
583
+ imports.push(this.createImportStatement([factory.createIdentifier('Stack')], 'aws-cdk-lib'));
584
+ }
585
+ }
586
+ if (renderArgs.unsupportedCategories) {
587
+ const categories = renderArgs.unsupportedCategories;
588
+ for (const [key, value] of categories) {
589
+ errors.push(factory.createCallExpression(factory.createIdentifier('throw new Error'), undefined, [
590
+ factory.createStringLiteral(`Category ${key} is unsupported, please follow ${value}`),
591
+ ]));
592
+ }
593
+ }
594
+ const callBackendFn = this.defineBackendCall(backendFunctionIdentifier, defineBackendProperties);
595
+ const backendVariable = factory.createVariableDeclaration('backend', undefined, undefined, callBackendFn);
596
+ const backendStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([backendVariable], typescript_1.default.NodeFlags.Const));
597
+ if (renderArgs.analytics) {
598
+ const analyticsCall = factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier('analytics'), undefined, [factory.createIdentifier('backend')]));
599
+ nodes.push(analyticsCall);
600
+ }
601
+ if (((_j = renderArgs.auth) === null || _j === void 0 ? void 0 : _j.userPoolOverrides) && !((_k = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _k === void 0 ? void 0 : _k.referenceAuth)) {
602
+ const cfnUserPoolVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnUserPool', 'auth.resources.cfnResources.cfnUserPool'));
603
+ nodes.push(cfnUserPoolVariableStatement);
604
+ const policies = {
605
+ passwordPolicy: {},
606
+ };
607
+ for (const [overridePath, value] of Object.entries(renderArgs.auth.userPoolOverrides)) {
608
+ if (overridePath.includes('PasswordPolicy')) {
609
+ const policyKey = overridePath.split('.')[2];
610
+ if (value !== undefined && policyKey in mappedPolicyType) {
611
+ policies.passwordPolicy[mappedPolicyType[policyKey]] = value;
612
+ }
613
+ }
614
+ else {
615
+ nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPool'), overridePath, value));
616
+ }
617
+ }
618
+ nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPool'), 'policies', policies));
619
+ }
620
+ if (((_l = renderArgs.auth) === null || _l === void 0 ? void 0 : _l.guestLogin) === false && !((_m = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _m === void 0 ? void 0 : _m.referenceAuth)) {
621
+ const cfnIdentityPoolVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnIdentityPool', 'auth.resources.cfnResources.cfnIdentityPool'));
622
+ nodes.push(cfnIdentityPoolVariableStatement);
623
+ nodes.push(this.setPropertyValue(factory.createIdentifier('cfnIdentityPool'), 'allowUnauthenticatedIdentities', false));
624
+ }
625
+ if ((((_o = renderArgs.auth) === null || _o === void 0 ? void 0 : _o.oAuthFlows) || ((_p = renderArgs.auth) === null || _p === void 0 ? void 0 : _p.readAttributes) || ((_q = renderArgs.auth) === null || _q === void 0 ? void 0 : _q.writeAttributes)) &&
626
+ !((_r = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _r === void 0 ? void 0 : _r.referenceAuth)) {
627
+ const cfnUserPoolClientVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnUserPoolClient', 'auth.resources.cfnResources.cfnUserPoolClient'));
628
+ nodes.push(cfnUserPoolClientVariableStatement);
629
+ if ((_s = renderArgs.auth) === null || _s === void 0 ? void 0 : _s.oAuthFlows) {
630
+ nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPoolClient'), 'allowedOAuthFlows', (_t = renderArgs.auth) === null || _t === void 0 ? void 0 : _t.oAuthFlows));
631
+ }
632
+ if ((_u = renderArgs.auth) === null || _u === void 0 ? void 0 : _u.readAttributes) {
633
+ nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPoolClient'), 'readAttributes', (_v = renderArgs.auth) === null || _v === void 0 ? void 0 : _v.readAttributes));
634
+ }
635
+ }
636
+ if (((_w = renderArgs.auth) === null || _w === void 0 ? void 0 : _w.writeAttributes) && !((_x = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _x === void 0 ? void 0 : _x.referenceAuth)) {
637
+ nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPoolClient'), 'writeAttributes', (_y = renderArgs.auth) === null || _y === void 0 ? void 0 : _y.writeAttributes));
638
+ }
639
+ if ((_z = renderArgs.auth) === null || _z === void 0 ? void 0 : _z.userPoolClient) {
640
+ const userPoolVariableStatement = this.createVariableStatement(this.createVariableDeclaration('userPool', 'auth.resources.userPool'));
641
+ nodes.push(userPoolVariableStatement);
642
+ const needsUserPoolClientConstant = renderArgs.auth.userPoolClient.SupportedIdentityProviders && renderArgs.auth.userPoolClient.SupportedIdentityProviders.length > 0;
643
+ nodes.push(this.createUserPoolClientAssignment((_0 = renderArgs.auth) === null || _0 === void 0 ? void 0 : _0.userPoolClient, imports, needsUserPoolClientConstant));
644
+ }
645
+ if (renderArgs.storage && renderArgs.storage.hasS3Bucket) {
646
+ (0, assert_1.default)(renderArgs.storage.bucketName);
647
+ const cfnStorageVariableStatement = this.createVariableStatement(this.createVariableDeclaration('s3Bucket', 'storage.resources.cfnResources.cfnBucket'));
648
+ nodes.push(cfnStorageVariableStatement);
649
+ const bucketNameComment1 = factory.createNotEmittedStatement(factory.createStringLiteral(''));
650
+ typescript_1.default.addSyntheticLeadingComment(bucketNameComment1, typescript_1.default.SyntaxKind.SingleLineCommentTrivia, ` Use this bucket name post refactor`, true);
651
+ const bucketNameComment2 = factory.createNotEmittedStatement(factory.createStringLiteral(''));
652
+ typescript_1.default.addSyntheticLeadingComment(bucketNameComment2, typescript_1.default.SyntaxKind.SingleLineCommentTrivia, ` s3Bucket.bucketName = '${renderArgs.storage.bucketName}';`, true);
653
+ nodes.push(bucketNameComment1, bucketNameComment2);
654
+ }
655
+ if (((_1 = renderArgs.storage) === null || _1 === void 0 ? void 0 : _1.accelerateConfiguration) ||
656
+ ((_2 = renderArgs.storage) === null || _2 === void 0 ? void 0 : _2.versionConfiguration) ||
657
+ ((_3 = renderArgs.storage) === null || _3 === void 0 ? void 0 : _3.bucketEncryptionAlgorithm)) {
658
+ if ((_4 = renderArgs.storage) === null || _4 === void 0 ? void 0 : _4.accelerateConfiguration) {
659
+ const accelerateConfigAssignment = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('s3Bucket'), factory.createIdentifier('accelerateConfiguration')), factory.createObjectLiteralExpression([this.createStringPropertyAssignment('accelerationStatus', renderArgs.storage.accelerateConfiguration)], false)));
660
+ nodes.push(accelerateConfigAssignment);
661
+ }
662
+ if ((_5 = renderArgs.storage) === null || _5 === void 0 ? void 0 : _5.versionConfiguration) {
663
+ const versionConfigAssignment = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('s3Bucket'), factory.createIdentifier('versioningConfiguration')), factory.createObjectLiteralExpression([this.createStringPropertyAssignment('status', renderArgs.storage.versionConfiguration)], false)));
664
+ nodes.push(versionConfigAssignment);
665
+ }
666
+ if ((_6 = renderArgs.storage) === null || _6 === void 0 ? void 0 : _6.bucketEncryptionAlgorithm) {
667
+ const serverSideEncryptionByDefaultMap = new Map();
668
+ serverSideEncryptionByDefaultMap.set('SSEAlgorithm', 'sseAlgorithm');
669
+ serverSideEncryptionByDefaultMap.set('KMSMasterKeyID', 'kmsMasterKeyId');
670
+ serverSideEncryptionByDefaultMap.set('bucketKeyEnabled', 'bucketKeyEnabled');
671
+ serverSideEncryptionByDefaultMap.set('serverSideEncryptionByDefault', 'serverSideEncryptionByDefault');
672
+ const bucketEncryptionAssignment = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('s3Bucket'), factory.createIdentifier('bucketEncryption')), factory.createObjectLiteralExpression([
673
+ factory.createPropertyAssignment(factory.createIdentifier('serverSideEncryptionConfiguration'), factory.createArrayLiteralExpression([this.createNestedObjectExpression(renderArgs.storage.bucketEncryptionAlgorithm, serverSideEncryptionByDefaultMap)], true)),
674
+ ], true)));
675
+ nodes.push(bucketEncryptionAssignment);
676
+ }
677
+ }
678
+ if (((_7 = renderArgs.auth) === null || _7 === void 0 ? void 0 : _7.userPoolClient) &&
679
+ renderArgs.auth.userPoolClient.SupportedIdentityProviders &&
680
+ renderArgs.auth.userPoolClient.SupportedIdentityProviders.length > 0) {
681
+ const idpStatements = this.createProviderSetupCode();
682
+ nodes.push(...idpStatements);
683
+ const userPoolDomainRemovalStatementCommented = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('// backend.auth.resources.userPool'), factory.createIdentifier('node')), factory.createIdentifier('tryRemoveChild')), undefined, [factory.createStringLiteral('UserPoolDomain')]));
684
+ nodes.push(userPoolDomainRemovalStatementCommented);
685
+ }
686
+ if (((_8 = renderArgs.data) === null || _8 === void 0 ? void 0 : _8.additionalAuthProviders) && renderArgs.auth) {
687
+ const cfnGraphqlApiVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnGraphqlApi', 'data.resources.cfnResources.cfnGraphqlApi'));
688
+ nodes.push(cfnGraphqlApiVariableStatement);
689
+ const additionalAuthProviders = this.createAdditionalAuthProvidersArray(renderArgs.data.additionalAuthProviders);
690
+ nodes.push(factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('cfnGraphqlApi'), factory.createIdentifier('additionalAuthenticationProviders')), additionalAuthProviders)));
691
+ }
692
+ if (renderArgs.function) {
693
+ const branchNameStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
694
+ factory.createVariableDeclaration('branchName', undefined, undefined, factory.createIdentifier('process.env.AWS_BRANCH ?? "sandbox"')),
695
+ ], typescript_1.default.NodeFlags.Const));
696
+ nodes.push(branchNameStatement);
697
+ const functionNameCategories = renderArgs.function.functionNamesAndCategories;
698
+ for (const [functionName] of functionNameCategories) {
699
+ nodes.push(factory.createExpressionStatement(factory.createBinaryExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier(functionName)), factory.createIdentifier('resources')), factory.createIdentifier('cfnResources')), factory.createIdentifier('cfnFunction')), factory.createIdentifier('functionName')), factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), factory.createTemplateExpression(factory.createTemplateHead(`${functionName}-`), [
700
+ factory.createTemplateSpan(factory.createIdentifier('branchName'), factory.createTemplateTail('')),
701
+ ]))));
702
+ }
703
+ }
704
+ if (((_9 = renderArgs.data) === null || _9 === void 0 ? void 0 : _9.restApis) && renderArgs.function) {
705
+ const functionNameCategories = renderArgs.function.functionNamesAndCategories;
706
+ const validRestApis = renderArgs.data.restApis.filter((restApi) => functionNameCategories.has(restApi.functionName));
707
+ if (validRestApis.length > 0) {
708
+ const apiStackStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
709
+ factory.createVariableDeclaration('apiStack', undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('createStack')), undefined, [factory.createStringLiteral('api-stack')])),
710
+ ], typescript_1.default.NodeFlags.Const));
711
+ nodes.push(apiStackStatement);
712
+ const hasPrivateAuth = validRestApis.some((restApi) => restApi.paths.some((path) => path.authType === 'private'));
713
+ const hasProtectedAuth = validRestApis.some((restApi) => restApi.paths.some((path) => path.authType === 'protected'));
714
+ const hasUserPoolGroups = validRestApis.some((restApi) => restApi.paths.some((path) => path.userPoolGroups && path.userPoolGroups.length > 0));
715
+ if (hasPrivateAuth) {
716
+ const iamAuthorizerStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
717
+ factory.createVariableDeclaration('iamAuthorizer', undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpIamAuthorizer'), undefined, [])),
718
+ ], typescript_1.default.NodeFlags.Const));
719
+ nodes.push(iamAuthorizerStatement);
720
+ }
721
+ if (hasProtectedAuth && renderArgs.auth) {
722
+ const userPoolAuthorizerStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
723
+ factory.createVariableDeclaration('userPoolAuthorizer', undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpUserPoolAuthorizer'), undefined, [
724
+ factory.createStringLiteral('userPoolAuth'),
725
+ factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPool')),
726
+ factory.createObjectLiteralExpression([
727
+ factory.createPropertyAssignment(factory.createIdentifier('userPoolClients'), factory.createArrayLiteralExpression([
728
+ factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPoolClient')),
729
+ ])),
730
+ ]),
731
+ ])),
732
+ ], typescript_1.default.NodeFlags.Const));
733
+ nodes.push(userPoolAuthorizerStatement);
734
+ }
735
+ if (hasUserPoolGroups && renderArgs.auth) {
736
+ const allGroups = new Set();
737
+ validRestApis.forEach((restApi) => {
738
+ restApi.paths.forEach((path) => {
739
+ if (path.userPoolGroups) {
740
+ path.userPoolGroups.forEach((group) => allGroups.add(group));
741
+ }
742
+ });
743
+ });
744
+ allGroups.forEach((groupName) => {
745
+ const groupAuthorizerStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
746
+ factory.createVariableDeclaration(`${groupName}Authorizer`, undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpUserPoolAuthorizer'), undefined, [
747
+ factory.createStringLiteral(`${groupName}Auth`),
748
+ factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPool')),
749
+ factory.createObjectLiteralExpression([
750
+ factory.createPropertyAssignment(factory.createIdentifier('userPoolClients'), factory.createArrayLiteralExpression([
751
+ factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPoolClient')),
752
+ ])),
753
+ factory.createPropertyAssignment(factory.createIdentifier('identitySource'), factory.createArrayLiteralExpression([factory.createStringLiteral('$request.header.Authorization')])),
754
+ ]),
755
+ ])),
756
+ ], typescript_1.default.NodeFlags.Const));
757
+ nodes.push(groupAuthorizerStatement);
758
+ });
759
+ }
760
+ const httpApiVariables = [];
761
+ validRestApis.forEach((restApi, index) => {
762
+ var _a, _b, _c;
763
+ const httpApiVarName = `httpApi${index > 0 ? index + 1 : ''}`;
764
+ httpApiVariables.push(httpApiVarName);
765
+ const httpApiStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
766
+ factory.createVariableDeclaration(httpApiVarName, undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpApi'), undefined, [
767
+ factory.createIdentifier('apiStack'),
768
+ factory.createStringLiteral(`HttpApi${index > 0 ? index + 1 : ''}`),
769
+ factory.createObjectLiteralExpression([
770
+ factory.createPropertyAssignment(factory.createIdentifier('apiName'), factory.createTemplateExpression(factory.createTemplateHead(`${restApi.apiName}-`), [
771
+ factory.createTemplateSpan(factory.createIdentifier('branchName'), factory.createTemplateTail('')),
772
+ ])),
773
+ factory.createPropertyAssignment(factory.createIdentifier('createDefaultStage'), factory.createTrue()),
774
+ factory.createPropertyAssignment(factory.createIdentifier('corsPreflight'), factory.createObjectLiteralExpression([
775
+ factory.createPropertyAssignment(factory.createIdentifier('allowMethods'), factory.createArrayLiteralExpression((((_a = restApi.corsConfiguration) === null || _a === void 0 ? void 0 : _a.allowMethods) || ['GET', 'POST', 'PUT', 'DELETE']).map((method) => factory.createPropertyAccessExpression(factory.createIdentifier('CorsHttpMethod'), factory.createIdentifier(method.toUpperCase()))))),
776
+ factory.createPropertyAssignment(factory.createIdentifier('allowOrigins'), factory.createArrayLiteralExpression((((_b = restApi.corsConfiguration) === null || _b === void 0 ? void 0 : _b.allowOrigins) || ['*']).map((origin) => factory.createStringLiteral(origin)))),
777
+ factory.createPropertyAssignment(factory.createIdentifier('allowHeaders'), factory.createArrayLiteralExpression((((_c = restApi.corsConfiguration) === null || _c === void 0 ? void 0 : _c.allowHeaders) || ['content-type', 'authorization']).map((header) => factory.createStringLiteral(header)))),
778
+ ])),
779
+ ]),
780
+ ])),
781
+ ], typescript_1.default.NodeFlags.Const));
782
+ nodes.push(httpApiStatement);
783
+ restApi.paths.forEach((pathConfig) => {
784
+ const pathFunctionName = pathConfig.lambdaFunction || restApi.functionName;
785
+ if (!functionNameCategories.has(pathFunctionName)) {
786
+ return;
787
+ }
788
+ const routeConfig = [
789
+ factory.createPropertyAssignment(factory.createIdentifier('path'), factory.createStringLiteral(pathConfig.path)),
790
+ factory.createPropertyAssignment(factory.createIdentifier('methods'), factory.createArrayLiteralExpression(pathConfig.methods.map((method) => factory.createPropertyAccessExpression(factory.createIdentifier('HttpMethod'), factory.createIdentifier(method.toUpperCase()))))),
791
+ factory.createPropertyAssignment(factory.createIdentifier('integration'), factory.createNewExpression(factory.createIdentifier('HttpLambdaIntegration'), undefined, [
792
+ factory.createStringLiteral(`${pathFunctionName}Integration`),
793
+ factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${pathFunctionName}.resources`), factory.createIdentifier('lambda')),
794
+ ])),
795
+ ];
796
+ if (pathConfig.userPoolGroups && pathConfig.userPoolGroups.length > 0) {
797
+ pathConfig.userPoolGroups.forEach((groupName) => {
798
+ const groupRouteConfig = [...routeConfig];
799
+ groupRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier(`${groupName}Authorizer`)));
800
+ const addGroupRouteStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(groupRouteConfig)]));
801
+ nodes.push(addGroupRouteStatement);
802
+ });
803
+ }
804
+ else if (pathConfig.authType === 'private') {
805
+ routeConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('iamAuthorizer')));
806
+ const addRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(routeConfig)]));
807
+ nodes.push(addRoutesStatement);
808
+ }
809
+ else if (pathConfig.authType === 'protected') {
810
+ routeConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('userPoolAuthorizer')));
811
+ const addRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(routeConfig)]));
812
+ nodes.push(addRoutesStatement);
813
+ }
814
+ else {
815
+ const addRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(routeConfig)]));
816
+ nodes.push(addRoutesStatement);
817
+ }
818
+ const proxyRouteConfig = [
819
+ factory.createPropertyAssignment(factory.createIdentifier('path'), factory.createStringLiteral(`${pathConfig.path}/{proxy+}`)),
820
+ factory.createPropertyAssignment(factory.createIdentifier('methods'), factory.createArrayLiteralExpression([
821
+ factory.createPropertyAccessExpression(factory.createIdentifier('HttpMethod'), factory.createIdentifier('ANY')),
822
+ ])),
823
+ factory.createPropertyAssignment(factory.createIdentifier('integration'), factory.createNewExpression(factory.createIdentifier('HttpLambdaIntegration'), undefined, [
824
+ factory.createStringLiteral(`${pathFunctionName}ProxyIntegration`),
825
+ factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${pathFunctionName}.resources`), factory.createIdentifier('lambda')),
826
+ ])),
827
+ ];
828
+ if (pathConfig.userPoolGroups && pathConfig.userPoolGroups.length > 0) {
829
+ pathConfig.userPoolGroups.forEach((groupName) => {
830
+ const groupProxyRouteConfig = [...proxyRouteConfig];
831
+ groupProxyRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier(`${groupName}Authorizer`)));
832
+ const addGroupProxyRouteStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(groupProxyRouteConfig)]));
833
+ nodes.push(addGroupProxyRouteStatement);
834
+ });
835
+ }
836
+ else if (pathConfig.authType === 'private') {
837
+ proxyRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('iamAuthorizer')));
838
+ const addProxyRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(proxyRouteConfig)]));
839
+ nodes.push(addProxyRoutesStatement);
840
+ }
841
+ else if (pathConfig.authType === 'protected') {
842
+ proxyRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('userPoolAuthorizer')));
843
+ const addProxyRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(proxyRouteConfig)]));
844
+ nodes.push(addProxyRoutesStatement);
845
+ }
846
+ else {
847
+ const addProxyRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(proxyRouteConfig)]));
848
+ nodes.push(addProxyRoutesStatement);
849
+ }
850
+ });
851
+ });
852
+ if (renderArgs.auth) {
853
+ const policyResources = httpApiVariables.map((httpApiVar) => factory.createTemplateExpression(factory.createTemplateHead(''), [
854
+ factory.createTemplateSpan(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVar), factory.createIdentifier('arnForExecuteApi')), undefined, [factory.createStringLiteral('*'), factory.createStringLiteral('/*')]), factory.createTemplateTail('')),
855
+ ]));
856
+ const apiPolicyStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
857
+ factory.createVariableDeclaration('apiPolicy', undefined, undefined, factory.createNewExpression(factory.createIdentifier('Policy'), undefined, [
858
+ factory.createIdentifier('apiStack'),
859
+ factory.createStringLiteral('ApiPolicy'),
860
+ factory.createObjectLiteralExpression([
861
+ factory.createPropertyAssignment(factory.createIdentifier('statements'), factory.createArrayLiteralExpression([
862
+ factory.createNewExpression(factory.createIdentifier('PolicyStatement'), undefined, [
863
+ factory.createObjectLiteralExpression([
864
+ factory.createPropertyAssignment(factory.createIdentifier('actions'), factory.createArrayLiteralExpression([factory.createStringLiteral('execute-api:Invoke')])),
865
+ factory.createPropertyAssignment(factory.createIdentifier('resources'), factory.createArrayLiteralExpression(policyResources)),
866
+ ]),
867
+ ]),
868
+ ])),
869
+ ]),
870
+ ])),
871
+ ], typescript_1.default.NodeFlags.Const));
872
+ nodes.push(apiPolicyStatement);
873
+ const attachAuthenticatedPolicyStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources.authenticatedUserIamRole'), factory.createIdentifier('attachInlinePolicy')), undefined, [factory.createIdentifier('apiPolicy')]));
874
+ nodes.push(attachAuthenticatedPolicyStatement);
875
+ const attachUnauthenticatedPolicyStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources.unauthenticatedUserIamRole'), factory.createIdentifier('attachInlinePolicy')), undefined, [factory.createIdentifier('apiPolicy')]));
876
+ nodes.push(attachUnauthenticatedPolicyStatement);
877
+ }
878
+ const apiOutputs = httpApiVariables.map((httpApiVar, index) => {
879
+ const restApi = validRestApis[index];
880
+ return factory.createPropertyAssignment(factory.createComputedPropertyName(factory.createNonNullExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVar), factory.createIdentifier('httpApiName')))), factory.createObjectLiteralExpression([
881
+ factory.createPropertyAssignment(factory.createIdentifier('endpoint'), factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVar), factory.createIdentifier('url'))),
882
+ factory.createPropertyAssignment(factory.createIdentifier('region'), factory.createPropertyAccessExpression(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('Stack'), factory.createIdentifier('of')), undefined, [factory.createIdentifier(httpApiVar)]), factory.createIdentifier('region'))),
883
+ ]));
884
+ });
885
+ const addOutputStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('addOutput')), undefined, [
886
+ factory.createObjectLiteralExpression([
887
+ factory.createPropertyAssignment(factory.createIdentifier('api'), factory.createObjectLiteralExpression([
888
+ factory.createPropertyAssignment(factory.createIdentifier('REST'), factory.createObjectLiteralExpression(apiOutputs)),
889
+ ])),
890
+ ]),
891
+ ]));
892
+ nodes.push(addOutputStatement);
893
+ }
894
+ }
895
+ return factory.createNodeArray([...imports, ts_factory_utils_1.newLineIdentifier, ...errors, ts_factory_utils_1.newLineIdentifier, backendStatement, ...nodes], true);
896
+ }
897
+ }
898
+ exports.BackendSynthesizer = BackendSynthesizer;
899
+ //# sourceMappingURL=synthesizer.js.map