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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/aws-amplify-cli-internal-gen2-migration-experimental-alpha-0.2.0.tgz +0 -0
  2. package/lib/commands/drift-detection/detect-local-drift.d.ts +3 -6
  3. package/lib/commands/drift-detection/detect-local-drift.d.ts.map +1 -1
  4. package/lib/commands/drift-detection/detect-local-drift.js +4 -8
  5. package/lib/commands/drift-detection/detect-local-drift.js.map +1 -1
  6. package/lib/commands/drift-detection/detect-stack-drift.d.ts +3 -2
  7. package/lib/commands/drift-detection/detect-stack-drift.d.ts.map +1 -1
  8. package/lib/commands/drift-detection/detect-stack-drift.js +12 -0
  9. package/lib/commands/drift-detection/detect-stack-drift.js.map +1 -1
  10. package/lib/commands/drift-detection/detect-template-drift.d.ts +4 -5
  11. package/lib/commands/drift-detection/detect-template-drift.d.ts.map +1 -1
  12. package/lib/commands/drift-detection/detect-template-drift.js +122 -94
  13. package/lib/commands/drift-detection/detect-template-drift.js.map +1 -1
  14. package/lib/commands/drift-detection/index.d.ts +3 -2
  15. package/lib/commands/drift-detection/index.d.ts.map +1 -1
  16. package/lib/commands/drift-detection/index.js +3 -1
  17. package/lib/commands/drift-detection/index.js.map +1 -1
  18. package/lib/commands/drift-detection/services/cloudformation-service.d.ts.map +1 -1
  19. package/lib/commands/drift-detection/services/cloudformation-service.js +3 -5
  20. package/lib/commands/drift-detection/services/cloudformation-service.js.map +1 -1
  21. package/lib/commands/drift-detection/services/drift-formatter.d.ts +4 -5
  22. package/lib/commands/drift-detection/services/drift-formatter.d.ts.map +1 -1
  23. package/lib/commands/drift-detection/services/drift-formatter.js +15 -38
  24. package/lib/commands/drift-detection/services/drift-formatter.js.map +1 -1
  25. package/lib/commands/drift.d.ts +0 -2
  26. package/lib/commands/drift.d.ts.map +1 -1
  27. package/lib/commands/drift.js +47 -57
  28. package/lib/commands/drift.js.map +1 -1
  29. package/lib/commands/gen2-migration/_step.d.ts +2 -1
  30. package/lib/commands/gen2-migration/_step.d.ts.map +1 -1
  31. package/lib/commands/gen2-migration/_step.js +2 -1
  32. package/lib/commands/gen2-migration/_step.js.map +1 -1
  33. package/lib/commands/gen2-migration/generate/adapters/auth/index.d.ts +24 -0
  34. package/lib/commands/gen2-migration/generate/adapters/auth/index.d.ts.map +1 -0
  35. package/lib/commands/gen2-migration/generate/adapters/auth/index.js +297 -0
  36. package/lib/commands/gen2-migration/generate/adapters/auth/index.js.map +1 -0
  37. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.d.ts +2 -0
  38. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.d.ts.map +1 -0
  39. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.js +140 -0
  40. package/lib/commands/gen2-migration/generate/adapters/auth/index.test.js.map +1 -0
  41. package/lib/commands/gen2-migration/generate/adapters/data/index.d.ts +5 -0
  42. package/lib/commands/gen2-migration/generate/adapters/data/index.d.ts.map +1 -0
  43. package/lib/commands/gen2-migration/generate/adapters/data/index.js +17 -0
  44. package/lib/commands/gen2-migration/generate/adapters/data/index.js.map +1 -0
  45. package/lib/commands/gen2-migration/generate/adapters/functions/index.d.ts +17 -0
  46. package/lib/commands/gen2-migration/generate/adapters/functions/index.d.ts.map +1 -0
  47. package/lib/commands/gen2-migration/generate/adapters/functions/index.js +46 -0
  48. package/lib/commands/gen2-migration/generate/adapters/functions/index.js.map +1 -0
  49. package/lib/commands/gen2-migration/generate/adapters/project/index.d.ts +2 -0
  50. package/lib/commands/gen2-migration/generate/adapters/project/index.d.ts.map +1 -0
  51. package/lib/commands/gen2-migration/generate/adapters/project/index.js +7 -0
  52. package/lib/commands/gen2-migration/generate/adapters/project/index.js.map +1 -0
  53. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.d.ts +30 -0
  54. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.d.ts.map +1 -0
  55. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.js +18 -0
  56. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.js.map +1 -0
  57. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.d.ts +2 -0
  58. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.d.ts.map +1 -0
  59. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.js +181 -0
  60. package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.js.map +1 -0
  61. package/lib/commands/gen2-migration/generate/adapters/storage/index.d.ts +3 -0
  62. package/lib/commands/gen2-migration/generate/adapters/storage/index.d.ts.map +1 -0
  63. package/lib/commands/gen2-migration/generate/adapters/storage/index.js +6 -0
  64. package/lib/commands/gen2-migration/generate/adapters/storage/index.js.map +1 -0
  65. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.d.ts +14 -0
  66. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.d.ts.map +1 -0
  67. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.js +27 -0
  68. package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.js.map +1 -0
  69. package/lib/commands/gen2-migration/generate/backend/synthesizer.d.ts +80 -0
  70. package/lib/commands/gen2-migration/generate/backend/synthesizer.d.ts.map +1 -0
  71. package/lib/commands/gen2-migration/generate/backend/synthesizer.js +901 -0
  72. package/lib/commands/gen2-migration/generate/backend/synthesizer.js.map +1 -0
  73. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.d.ts +2 -0
  74. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.d.ts.map +1 -0
  75. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.js +700 -0
  76. package/lib/commands/gen2-migration/generate/backend/synthesizer.test.js.map +1 -0
  77. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.d.ts +14 -0
  78. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.d.ts.map +1 -0
  79. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.js +82 -0
  80. package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.js.map +1 -0
  81. package/lib/commands/gen2-migration/generate/codegen-head/analytics.d.ts +10 -0
  82. package/lib/commands/gen2-migration/generate/codegen-head/analytics.d.ts.map +1 -0
  83. package/lib/commands/gen2-migration/generate/codegen-head/analytics.js +11 -0
  84. package/lib/commands/gen2-migration/generate/codegen-head/analytics.js.map +1 -0
  85. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.d.ts +13 -0
  86. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.d.ts.map +1 -0
  87. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.js +22 -0
  88. package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.js.map +1 -0
  89. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.d.ts +24 -0
  90. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.d.ts.map +1 -0
  91. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.js +167 -0
  92. package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.js.map +1 -0
  93. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.d.ts +19 -0
  94. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.d.ts.map +1 -0
  95. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.js +133 -0
  96. package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.js.map +1 -0
  97. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.d.ts +23 -0
  98. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.d.ts.map +1 -0
  99. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.js +172 -0
  100. package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.js.map +1 -0
  101. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.d.ts +10 -0
  102. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.d.ts.map +1 -0
  103. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.js +48 -0
  104. package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.js.map +1 -0
  105. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.d.ts +11 -0
  106. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.d.ts.map +1 -0
  107. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.js +38 -0
  108. package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.js.map +1 -0
  109. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.d.ts +13 -0
  110. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.d.ts.map +1 -0
  111. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.js +462 -0
  112. package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.js.map +1 -0
  113. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.d.ts +47 -0
  114. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.d.ts.map +1 -0
  115. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.js +222 -0
  116. package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.js.map +1 -0
  117. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.d.ts +2 -0
  118. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.d.ts.map +1 -0
  119. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.js +15 -0
  120. package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.js.map +1 -0
  121. package/lib/commands/gen2-migration/generate/codegen-head/format.d.ts +8 -0
  122. package/lib/commands/gen2-migration/generate/codegen-head/format.d.ts.map +1 -0
  123. package/lib/commands/gen2-migration/generate/codegen-head/format.js +66 -0
  124. package/lib/commands/gen2-migration/generate/codegen-head/format.js.map +1 -0
  125. package/lib/commands/gen2-migration/generate/codegen-head/logger.d.ts +15 -0
  126. package/lib/commands/gen2-migration/generate/codegen-head/logger.d.ts.map +1 -0
  127. package/lib/commands/gen2-migration/generate/codegen-head/logger.js +14 -0
  128. package/lib/commands/gen2-migration/generate/codegen-head/logger.js.map +1 -0
  129. package/lib/commands/gen2-migration/generate/codegen-head/printer.d.ts +26 -0
  130. package/lib/commands/gen2-migration/generate/codegen-head/printer.d.ts.map +1 -0
  131. package/lib/commands/gen2-migration/generate/codegen-head/printer.js +103 -0
  132. package/lib/commands/gen2-migration/generate/codegen-head/printer.js.map +1 -0
  133. package/lib/commands/gen2-migration/generate/core/migration-pipeline.d.ts +26 -0
  134. package/lib/commands/gen2-migration/generate/core/migration-pipeline.d.ts.map +1 -0
  135. package/lib/commands/gen2-migration/generate/core/migration-pipeline.js +233 -0
  136. package/lib/commands/gen2-migration/generate/core/migration-pipeline.js.map +1 -0
  137. package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.d.ts.map +1 -0
  138. package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.js.map +1 -0
  139. package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.d.ts.map +1 -0
  140. package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.js.map +1 -0
  141. package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.d.ts.map +1 -0
  142. package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.js.map +1 -0
  143. package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.d.ts.map +1 -0
  144. package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.js.map +1 -0
  145. package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.d.ts.map +1 -0
  146. package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.js.map +1 -0
  147. package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.d.ts.map +1 -0
  148. package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.js.map +1 -0
  149. package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.d.ts.map +1 -0
  150. package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.js.map +1 -0
  151. package/lib/commands/gen2-migration/generate/custom-resources/transformer/amplify-helper-transformer.d.ts.map +1 -0
  152. package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/transformer/amplify-helper-transformer.js +25 -3
  153. package/lib/commands/gen2-migration/generate/custom-resources/transformer/amplify-helper-transformer.js.map +1 -0
  154. package/lib/commands/gen2-migration/generate/custom-resources/types.d.ts.map +1 -0
  155. package/lib/commands/gen2-migration/generate/custom-resources/types.js.map +1 -0
  156. package/lib/commands/gen2-migration/generate/generators/analytics/index.d.ts +9 -0
  157. package/lib/commands/gen2-migration/generate/generators/analytics/index.d.ts.map +1 -0
  158. package/lib/commands/gen2-migration/generate/generators/analytics/index.js +40 -0
  159. package/lib/commands/gen2-migration/generate/generators/analytics/index.js.map +1 -0
  160. package/lib/commands/gen2-migration/generate/generators/auth/index.d.ts +106 -0
  161. package/lib/commands/gen2-migration/generate/generators/auth/index.d.ts.map +1 -0
  162. package/lib/commands/gen2-migration/generate/generators/auth/index.js +286 -0
  163. package/lib/commands/gen2-migration/generate/generators/auth/index.js.map +1 -0
  164. package/lib/commands/gen2-migration/generate/generators/auth/index.test.d.ts +2 -0
  165. package/lib/commands/gen2-migration/generate/generators/auth/index.test.d.ts.map +1 -0
  166. package/lib/commands/gen2-migration/generate/generators/auth/index.test.js +437 -0
  167. package/lib/commands/gen2-migration/generate/generators/auth/index.test.js.map +1 -0
  168. package/lib/commands/gen2-migration/generate/generators/data/index.d.ts +35 -0
  169. package/lib/commands/gen2-migration/generate/generators/data/index.d.ts.map +1 -0
  170. package/lib/commands/gen2-migration/generate/generators/data/index.js +199 -0
  171. package/lib/commands/gen2-migration/generate/generators/data/index.js.map +1 -0
  172. package/lib/commands/gen2-migration/generate/generators/data/index.test.d.ts +2 -0
  173. package/lib/commands/gen2-migration/generate/generators/data/index.test.d.ts.map +1 -0
  174. package/lib/commands/gen2-migration/generate/generators/data/index.test.js +50 -0
  175. package/lib/commands/gen2-migration/generate/generators/data/index.test.js.map +1 -0
  176. package/lib/commands/gen2-migration/generate/generators/functions/index.d.ts +17 -0
  177. package/lib/commands/gen2-migration/generate/generators/functions/index.d.ts.map +1 -0
  178. package/lib/commands/gen2-migration/generate/generators/functions/index.js +125 -0
  179. package/lib/commands/gen2-migration/generate/generators/functions/index.js.map +1 -0
  180. package/lib/commands/gen2-migration/generate/generators/functions/lambda.d.ts +6 -0
  181. package/lib/commands/gen2-migration/generate/generators/functions/lambda.d.ts.map +1 -0
  182. package/lib/commands/gen2-migration/generate/generators/functions/lambda.js +16 -0
  183. package/lib/commands/gen2-migration/generate/generators/functions/lambda.js.map +1 -0
  184. package/lib/commands/gen2-migration/generate/generators/storage/access.d.ts +4 -0
  185. package/lib/commands/gen2-migration/generate/generators/storage/access.d.ts.map +1 -0
  186. package/lib/commands/gen2-migration/generate/generators/storage/access.js +53 -0
  187. package/lib/commands/gen2-migration/generate/generators/storage/access.js.map +1 -0
  188. package/lib/commands/gen2-migration/generate/generators/storage/index.d.ts +31 -0
  189. package/lib/commands/gen2-migration/generate/generators/storage/index.d.ts.map +1 -0
  190. package/lib/commands/gen2-migration/generate/generators/storage/index.js +66 -0
  191. package/lib/commands/gen2-migration/generate/generators/storage/index.js.map +1 -0
  192. package/lib/commands/gen2-migration/generate/npm_package/renderer.d.ts +27 -0
  193. package/lib/commands/gen2-migration/generate/npm_package/renderer.d.ts.map +1 -0
  194. package/lib/commands/gen2-migration/generate/npm_package/renderer.js +28 -0
  195. package/lib/commands/gen2-migration/generate/npm_package/renderer.js.map +1 -0
  196. package/lib/commands/gen2-migration/generate/render_pipeline.d.ts +9 -0
  197. package/lib/commands/gen2-migration/generate/render_pipeline.d.ts.map +1 -0
  198. package/lib/commands/gen2-migration/generate/render_pipeline.js +15 -0
  199. package/lib/commands/gen2-migration/generate/render_pipeline.js.map +1 -0
  200. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.d.ts +7 -0
  201. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.d.ts.map +1 -0
  202. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.js +17 -0
  203. package/lib/commands/gen2-migration/generate/renderers/ensure_directory.js.map +1 -0
  204. package/lib/commands/gen2-migration/generate/renderers/package_json.d.ts +8 -0
  205. package/lib/commands/gen2-migration/generate/renderers/package_json.d.ts.map +1 -0
  206. package/lib/commands/gen2-migration/generate/renderers/package_json.js +15 -0
  207. package/lib/commands/gen2-migration/generate/renderers/package_json.js.map +1 -0
  208. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.d.ts +11 -0
  209. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.d.ts.map +1 -0
  210. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.js +22 -0
  211. package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.js.map +1 -0
  212. package/lib/commands/gen2-migration/generate/resource/resource.d.ts +20 -0
  213. package/lib/commands/gen2-migration/generate/resource/resource.d.ts.map +1 -0
  214. package/lib/commands/gen2-migration/generate/resource/resource.js +60 -0
  215. package/lib/commands/gen2-migration/generate/resource/resource.js.map +1 -0
  216. package/lib/commands/gen2-migration/generate/test_utils/import_regex.d.ts +2 -0
  217. package/lib/commands/gen2-migration/generate/test_utils/import_regex.d.ts.map +1 -0
  218. package/lib/commands/gen2-migration/generate/test_utils/import_regex.js +6 -0
  219. package/lib/commands/gen2-migration/generate/test_utils/import_regex.js.map +1 -0
  220. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.d.ts +4 -0
  221. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.d.ts.map +1 -0
  222. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.js +22 -0
  223. package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.js.map +1 -0
  224. package/lib/commands/gen2-migration/generate/todo_error.d.ts +3 -0
  225. package/lib/commands/gen2-migration/generate/todo_error.d.ts.map +1 -0
  226. package/lib/commands/gen2-migration/generate/todo_error.js +11 -0
  227. package/lib/commands/gen2-migration/generate/todo_error.js.map +1 -0
  228. package/lib/commands/gen2-migration/generate/ts_factory_utils.d.ts +3 -0
  229. package/lib/commands/gen2-migration/generate/ts_factory_utils.d.ts.map +1 -0
  230. package/lib/commands/gen2-migration/generate/ts_factory_utils.js +10 -0
  231. package/lib/commands/gen2-migration/generate/ts_factory_utils.js.map +1 -0
  232. package/lib/commands/gen2-migration/generate/types.d.ts +4 -0
  233. package/lib/commands/gen2-migration/generate/types.d.ts.map +1 -0
  234. package/lib/commands/gen2-migration/generate/types.js +3 -0
  235. package/lib/commands/gen2-migration/generate/types.js.map +1 -0
  236. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.d.ts +26 -0
  237. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.d.ts.map +1 -0
  238. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.js +152 -0
  239. package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.js.map +1 -0
  240. package/lib/commands/gen2-migration/generate.js +2 -2
  241. package/lib/commands/gen2-migration/generate.js.map +1 -1
  242. package/lib/commands/gen2-migration.d.ts.map +1 -1
  243. package/lib/commands/gen2-migration.js +2 -1
  244. package/lib/commands/gen2-migration.js.map +1 -1
  245. package/package.json +2 -1
  246. package/aws-amplify-cli-internal-gen2-migration-experimental-alpha-0.1.0.tgz +0 -0
  247. package/lib/commands/gen2-migration/codegen-custom-resources/generator/backend-updater.d.ts.map +0 -1
  248. package/lib/commands/gen2-migration/codegen-custom-resources/generator/backend-updater.js.map +0 -1
  249. package/lib/commands/gen2-migration/codegen-custom-resources/generator/dependency-merger.d.ts.map +0 -1
  250. package/lib/commands/gen2-migration/codegen-custom-resources/generator/dependency-merger.js.map +0 -1
  251. package/lib/commands/gen2-migration/codegen-custom-resources/generator/file-converter.d.ts.map +0 -1
  252. package/lib/commands/gen2-migration/codegen-custom-resources/generator/file-converter.js.map +0 -1
  253. package/lib/commands/gen2-migration/codegen-custom-resources/generator/gen2-file-generator.d.ts.map +0 -1
  254. package/lib/commands/gen2-migration/codegen-custom-resources/generator/gen2-file-generator.js.map +0 -1
  255. package/lib/commands/gen2-migration/codegen-custom-resources/parser/cdk-stack-parser.d.ts.map +0 -1
  256. package/lib/commands/gen2-migration/codegen-custom-resources/parser/cdk-stack-parser.js.map +0 -1
  257. package/lib/commands/gen2-migration/codegen-custom-resources/parser/pattern-detector.d.ts.map +0 -1
  258. package/lib/commands/gen2-migration/codegen-custom-resources/parser/pattern-detector.js.map +0 -1
  259. package/lib/commands/gen2-migration/codegen-custom-resources/scanner/custom-resource-scanner.d.ts.map +0 -1
  260. package/lib/commands/gen2-migration/codegen-custom-resources/scanner/custom-resource-scanner.js.map +0 -1
  261. package/lib/commands/gen2-migration/codegen-custom-resources/transformer/amplify-helper-transformer.d.ts.map +0 -1
  262. package/lib/commands/gen2-migration/codegen-custom-resources/transformer/amplify-helper-transformer.js.map +0 -1
  263. package/lib/commands/gen2-migration/codegen-custom-resources/types.d.ts.map +0 -1
  264. package/lib/commands/gen2-migration/codegen-custom-resources/types.js.map +0 -1
  265. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/backend-updater.d.ts +0 -0
  266. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/backend-updater.js +0 -0
  267. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/dependency-merger.d.ts +0 -0
  268. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/dependency-merger.js +0 -0
  269. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/file-converter.d.ts +0 -0
  270. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/file-converter.js +0 -0
  271. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/gen2-file-generator.d.ts +0 -0
  272. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/generator/gen2-file-generator.js +0 -0
  273. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/cdk-stack-parser.d.ts +0 -0
  274. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/cdk-stack-parser.js +0 -0
  275. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/pattern-detector.d.ts +0 -0
  276. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/parser/pattern-detector.js +0 -0
  277. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/scanner/custom-resource-scanner.d.ts +0 -0
  278. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/scanner/custom-resource-scanner.js +0 -0
  279. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/transformer/amplify-helper-transformer.d.ts +0 -0
  280. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/types.d.ts +0 -0
  281. /package/lib/commands/gen2-migration/{codegen-custom-resources → generate/custom-resources}/types.js +0 -0
@@ -0,0 +1,199 @@
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.generateDataSource = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const resource_1 = require("../../resource/resource");
9
+ const factory = typescript_1.default.factory;
10
+ const createDataSourceMapping = (schema, apiId, envName) => {
11
+ const models = extractModelsFromSchema(schema);
12
+ const mapping = {};
13
+ models.forEach((modelName) => {
14
+ mapping[modelName] = [modelName, apiId, envName].join('-');
15
+ });
16
+ return mapping;
17
+ };
18
+ const extractModelsFromSchema = (schema) => {
19
+ const modelRegex = /type\s+(\w+)\s+@model/g;
20
+ const models = [];
21
+ let match;
22
+ while ((match = modelRegex.exec(schema)) !== null) {
23
+ models.push(match[1]);
24
+ }
25
+ return models;
26
+ };
27
+ const getCurrentEnvironment = () => {
28
+ try {
29
+ const { stateManager } = require('@aws-amplify/amplify-cli-core');
30
+ return stateManager.getCurrentEnvName() || 'main';
31
+ }
32
+ catch (_a) {
33
+ return 'main';
34
+ }
35
+ };
36
+ const getProjectName = () => {
37
+ try {
38
+ const fs = require('fs');
39
+ const path = require('path');
40
+ const { pathManager } = require('@aws-amplify/amplify-cli-core');
41
+ const projectRoot = pathManager.findProjectRoot();
42
+ if (!projectRoot)
43
+ return undefined;
44
+ const projectConfigPath = path.join(projectRoot, 'amplify', '.config', 'project-config.json');
45
+ if (fs.existsSync(projectConfigPath)) {
46
+ const projectConfig = JSON.parse(fs.readFileSync(projectConfigPath, 'utf8'));
47
+ return projectConfig.projectName;
48
+ }
49
+ return undefined;
50
+ }
51
+ catch (_a) {
52
+ return undefined;
53
+ }
54
+ };
55
+ const getApiId = async () => {
56
+ var _a;
57
+ try {
58
+ const { AppSyncClient, ListGraphqlApisCommand } = require('@aws-sdk/client-appsync');
59
+ const client = new AppSyncClient({});
60
+ const response = await client.send(new ListGraphqlApisCommand({}));
61
+ const currentEnv = getCurrentEnvironment();
62
+ const projectName = getProjectName();
63
+ const api = (_a = response.graphqlApis) === null || _a === void 0 ? void 0 : _a.find((api) => {
64
+ var _a, _b;
65
+ const matchesEnv = ((_a = api.tags) === null || _a === void 0 ? void 0 : _a['user:Stack']) === currentEnv;
66
+ const matchesProject = projectName ? ((_b = api.tags) === null || _b === void 0 ? void 0 : _b['user:Application']) === projectName : true;
67
+ return matchesEnv && matchesProject;
68
+ });
69
+ return api === null || api === void 0 ? void 0 : api.apiId;
70
+ }
71
+ catch (error) {
72
+ console.warn('Failed to fetch API ID from AWS:', error.message);
73
+ return undefined;
74
+ }
75
+ };
76
+ const migratedAmplifyGen1DynamoDbTableMappingsKeyName = 'migratedAmplifyGen1DynamoDbTableMappings';
77
+ const generateDataSource = async (gen1Env, dataDefinition) => {
78
+ var _a, _b, _c;
79
+ if (!dataDefinition) {
80
+ return undefined;
81
+ }
82
+ if (!dataDefinition.schema && (!dataDefinition.restApis || dataDefinition.restApis.length === 0)) {
83
+ return undefined;
84
+ }
85
+ const dataRenderProperties = [];
86
+ const namedImports = { '@aws-amplify/backend': new Set() };
87
+ namedImports['@aws-amplify/backend'].add('defineData');
88
+ const schemaStatements = [];
89
+ if (dataDefinition && dataDefinition.schema) {
90
+ if (dataDefinition.schema.includes('${env}')) {
91
+ const branchNameStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
92
+ factory.createVariableDeclaration('branchName', undefined, undefined, factory.createIdentifier('process.env.AWS_BRANCH ?? "sandbox"')),
93
+ ], typescript_1.default.NodeFlags.Const));
94
+ schemaStatements.push(branchNameStatement);
95
+ dataDefinition.schema = dataDefinition.schema.replaceAll('${env}', '${branchName}');
96
+ }
97
+ const schemaVariableDeclaration = factory.createVariableDeclaration('schema', undefined, undefined, factory.createIdentifier('`' + dataDefinition.schema + '`'));
98
+ const schemaStatementAssignment = factory.createVariableStatement([], factory.createVariableDeclarationList([schemaVariableDeclaration], typescript_1.default.NodeFlags.Const));
99
+ schemaStatements.push(schemaStatementAssignment);
100
+ }
101
+ let tableMappings = dataDefinition === null || dataDefinition === void 0 ? void 0 : dataDefinition.tableMappings;
102
+ if (!tableMappings && (dataDefinition === null || dataDefinition === void 0 ? void 0 : dataDefinition.schema)) {
103
+ const apiId = await getApiId();
104
+ if (apiId) {
105
+ tableMappings = createDataSourceMapping(dataDefinition.schema, apiId, gen1Env);
106
+ }
107
+ }
108
+ if (tableMappings) {
109
+ const tableMappingProperties = [];
110
+ for (const [tableName, tableId] of Object.entries(tableMappings)) {
111
+ tableMappingProperties.push(factory.createPropertyAssignment(factory.createIdentifier(tableName), factory.createStringLiteral(tableId)));
112
+ }
113
+ const branchNameExpression = typescript_1.default.addSyntheticLeadingComment(factory.createPropertyAssignment('branchName', factory.createStringLiteral(gen1Env)), typescript_1.default.SyntaxKind.SingleLineCommentTrivia, 'The "branchname" variable needs to be the same as your deployment branch if you want to reuse your Gen1 app tables', true);
114
+ const tableMappingExpression = factory.createPropertyAssignment('modelNameToTableNameMapping', factory.createObjectLiteralExpression(tableMappingProperties));
115
+ const tableMappingForEnvironment = factory.createObjectLiteralExpression([branchNameExpression, tableMappingExpression], true);
116
+ dataRenderProperties.push(factory.createPropertyAssignment(migratedAmplifyGen1DynamoDbTableMappingsKeyName, factory.createArrayLiteralExpression([tableMappingForEnvironment])));
117
+ }
118
+ if (dataDefinition === null || dataDefinition === void 0 ? void 0 : dataDefinition.authorizationModes) {
119
+ const gen1AuthModes = dataDefinition.authorizationModes;
120
+ const authModeProperties = [];
121
+ const authModeMap = {
122
+ AWS_IAM: 'iam',
123
+ AMAZON_COGNITO_USER_POOLS: 'userPool',
124
+ API_KEY: 'apiKey',
125
+ AWS_LAMBDA: 'lambda',
126
+ OPENID_CONNECT: 'oidc',
127
+ };
128
+ if ((_a = gen1AuthModes.defaultAuthentication) === null || _a === void 0 ? void 0 : _a.authenticationType) {
129
+ const gen2AuthMode = authModeMap[gen1AuthModes.defaultAuthentication.authenticationType] || 'userPool';
130
+ authModeProperties.push(factory.createPropertyAssignment('defaultAuthorizationMode', factory.createStringLiteral(gen2AuthMode)));
131
+ switch (gen1AuthModes.defaultAuthentication.authenticationType) {
132
+ case 'API_KEY':
133
+ if ((_b = gen1AuthModes.defaultAuthentication.apiKeyConfig) === null || _b === void 0 ? void 0 : _b.apiKeyExpirationDays) {
134
+ authModeProperties.push(factory.createPropertyAssignment('apiKeyAuthorizationMode', factory.createObjectLiteralExpression([
135
+ factory.createPropertyAssignment('expiresInDays', factory.createNumericLiteral(gen1AuthModes.defaultAuthentication.apiKeyConfig.apiKeyExpirationDays.toString())),
136
+ ])));
137
+ }
138
+ break;
139
+ case 'AWS_LAMBDA':
140
+ if ((_c = gen1AuthModes.defaultAuthentication.lambdaAuthorizerConfig) === null || _c === void 0 ? void 0 : _c.ttlSeconds) {
141
+ authModeProperties.push(factory.createPropertyAssignment('lambdaAuthorizationMode', factory.createObjectLiteralExpression([
142
+ factory.createPropertyAssignment('timeToLiveInSeconds', factory.createNumericLiteral(gen1AuthModes.defaultAuthentication.lambdaAuthorizerConfig.ttlSeconds.toString())),
143
+ ])));
144
+ }
145
+ break;
146
+ case 'OPENID_CONNECT':
147
+ if (gen1AuthModes.defaultAuthentication.openIDConnectConfig) {
148
+ const oidcProps = [];
149
+ if (gen1AuthModes.defaultAuthentication.openIDConnectConfig.issuer) {
150
+ oidcProps.push(factory.createPropertyAssignment('oidcIssuerUrl', factory.createStringLiteral(gen1AuthModes.defaultAuthentication.openIDConnectConfig.issuer)));
151
+ }
152
+ if (gen1AuthModes.defaultAuthentication.openIDConnectConfig.clientId) {
153
+ oidcProps.push(factory.createPropertyAssignment('clientId', factory.createStringLiteral(gen1AuthModes.defaultAuthentication.openIDConnectConfig.clientId)));
154
+ }
155
+ if (oidcProps.length > 0) {
156
+ authModeProperties.push(factory.createPropertyAssignment('oidcAuthorizationMode', factory.createObjectLiteralExpression(oidcProps)));
157
+ }
158
+ }
159
+ break;
160
+ }
161
+ }
162
+ if (authModeProperties.length > 0) {
163
+ dataRenderProperties.push(factory.createPropertyAssignment('authorizationModes', factory.createObjectLiteralExpression(authModeProperties, true)));
164
+ }
165
+ }
166
+ if (dataDefinition === null || dataDefinition === void 0 ? void 0 : dataDefinition.logging) {
167
+ if (dataDefinition.logging === true) {
168
+ dataRenderProperties.push(factory.createPropertyAssignment('logging', factory.createTrue()));
169
+ }
170
+ else if (typeof dataDefinition.logging === 'object') {
171
+ const loggingConfig = dataDefinition.logging;
172
+ const loggingProperties = [];
173
+ if (loggingConfig.fieldLogLevel !== undefined) {
174
+ loggingProperties.push(factory.createPropertyAssignment('fieldLogLevel', factory.createStringLiteral(loggingConfig.fieldLogLevel)));
175
+ }
176
+ if (loggingConfig.excludeVerboseContent !== undefined) {
177
+ loggingProperties.push(factory.createPropertyAssignment('excludeVerboseContent', loggingConfig.excludeVerboseContent ? factory.createTrue() : factory.createFalse()));
178
+ }
179
+ if (loggingConfig.retention !== undefined) {
180
+ loggingProperties.push(factory.createPropertyAssignment('retention', factory.createStringLiteral(loggingConfig.retention)));
181
+ }
182
+ if (loggingProperties.length > 0) {
183
+ dataRenderProperties.push(factory.createPropertyAssignment('logging', factory.createObjectLiteralExpression(loggingProperties)));
184
+ }
185
+ }
186
+ }
187
+ if (dataDefinition === null || dataDefinition === void 0 ? void 0 : dataDefinition.schema) {
188
+ dataRenderProperties.push(factory.createShorthandPropertyAssignment(factory.createIdentifier('schema')));
189
+ }
190
+ return (0, resource_1.renderResourceTsFile)({
191
+ exportedVariableName: factory.createIdentifier('data'),
192
+ functionCallParameter: factory.createObjectLiteralExpression(dataRenderProperties, true),
193
+ backendFunctionConstruct: 'defineData',
194
+ postImportStatements: schemaStatements,
195
+ additionalImportedBackendIdentifiers: namedImports,
196
+ });
197
+ };
198
+ exports.generateDataSource = generateDataSource;
199
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/data/index.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA0D;AAC1D,sDAA+D;AAwB/D,MAAM,OAAO,GAAG,oBAAE,CAAC,OAAO,CAAC;AAW3B,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAE,KAAa,EAAE,OAAe,EAA0B,EAAE;IACzG,MAAM,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAE3B,OAA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 -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/data/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const ts_node_printer_1 = require("../../test_utils/ts_node_printer");
8
+ const index_1 = require("./index");
9
+ describe('Data Category code generation', () => {
10
+ beforeEach(() => {
11
+ jest.spyOn(console, 'warn').mockImplementation(() => { });
12
+ });
13
+ afterEach(() => {
14
+ jest.restoreAllMocks();
15
+ });
16
+ it('generates the correct import', async () => {
17
+ const source = (0, ts_node_printer_1.printNodeArray)(await (0, index_1.generateDataSource)('main', { schema: 'type Test { id: ID! }' }));
18
+ node_assert_1.default.match(source, /import\s?\{\s?defineData\s?\}\s?from\s?"\@aws-amplify\/backend"/);
19
+ });
20
+ it('returns undefined when no data definition provided', async () => {
21
+ const result = await (0, index_1.generateDataSource)('main');
22
+ node_assert_1.default.strictEqual(result, undefined);
23
+ });
24
+ it('returns undefined when no schema and no REST APIs', async () => {
25
+ const result = await (0, index_1.generateDataSource)('main', {});
26
+ node_assert_1.default.strictEqual(result, undefined);
27
+ });
28
+ describe('import map', () => {
29
+ it('is rendered', async () => {
30
+ const tableMappings = { Todo: 'my-todo-mapping' };
31
+ const source = (0, ts_node_printer_1.printNodeArray)(await (0, index_1.generateDataSource)('main', { tableMappings, schema: 'schema' }));
32
+ node_assert_1.default.match(source, /migratedAmplifyGen1DynamoDbTableMappings: \[\{\n\s+\/\/.*\n\s+branchName: ['"]\w+['"],\n\s+modelNameToTableNameMapping: { Todo: ['"]my-todo-mapping['"] }\n\s+}]/);
33
+ });
34
+ it('includes multiple models in table mappings', async () => {
35
+ const tableMappings = { Todo: 'Todo-abc123-dev', User: 'User-abc123-dev', Post: 'Post-abc123-dev' };
36
+ const source = (0, ts_node_printer_1.printNodeArray)(await (0, index_1.generateDataSource)('main', { tableMappings, schema: 'schema' }));
37
+ node_assert_1.default.match(source, /modelNameToTableNameMapping: { Todo: ['"]Todo-abc123-dev['"], User: ['"]User-abc123-dev['"], Post: ['"]Post-abc123-dev['"] }/);
38
+ });
39
+ it('includes a comment for missing table mappings', async () => {
40
+ const source = (0, ts_node_printer_1.printNodeArray)(await (0, index_1.generateDataSource)('main', { schema: 'schema' }));
41
+ node_assert_1.default.match(source, /const schema = `schema`;\n\nexport const data = defineData\(\{\n\s+schema\n\}\)/);
42
+ });
43
+ it('has each each key in defineData', async () => {
44
+ const tableMappings = { Todo: 'my-todo-mapping' };
45
+ const source = (0, ts_node_printer_1.printNodeArray)(await (0, index_1.generateDataSource)('main', { tableMappings, schema: 'schema' }));
46
+ node_assert_1.default.match(source, /const schema = `schema`;\n\nexport const data = defineData\(\{\n\s+migratedAmplifyGen1DynamoDbTableMappings: \[\{\n\s+\/\/.*\n\s+branchName: ['"]\w+['"],\n\s+modelNameToTableNameMapping: { Todo: ['"]my-todo-mapping['"] }\n\s+}],\n\s+schema\n\}\)/);
47
+ });
48
+ });
49
+ });
50
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/data/index.test.ts"],"names":[],"mappings":";;;;;AAAA,8DAAiC;AACjC,sEAAkE;AAClE,mCAA6C;AAE7C,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,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G,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;YACpG,MAAM,MAAM,GAAG,IAAA,gCAAc,EAAC,MAAM,IAAA,0BAAkB,EAAC,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;YACrG,qBAAM,CAAC,KAAK,CACV,MAAM,EACN,8HAA8H,CAC/H,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;YAC7D,MAAM,MAAM,GAAG,IAAA,gCAAc,EAAC,MAAM,IAAA,0BAAkB,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;YACtF,qBAAM,CAAC,KAAK,CAAC,MAAM,EAAE,iFAAiF,CAAC,CAAC;QAC1G,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;YAClD,MAAM,MAAM,GAAG,IAAA,gCAAc,EAAC,MAAM,IAAA,0BAAkB,EAAC,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;YACrG,qBAAM,CAAC,KAAK,CACV,MAAM,EACN,uPAAuP,CACxP,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import ts from 'typescript';
2
+ import type { EnvironmentResponse } from '@aws-sdk/client-lambda';
3
+ import { Runtime } from '@aws-sdk/client-lambda';
4
+ export interface FunctionDefinition {
5
+ category?: string;
6
+ entry?: string;
7
+ name?: string;
8
+ timeoutSeconds?: number;
9
+ memoryMB?: number;
10
+ environment?: EnvironmentResponse;
11
+ runtime?: Runtime | string;
12
+ resourceName?: string;
13
+ schedule?: string;
14
+ }
15
+ export declare function renderFunctions(definition: FunctionDefinition, appId?: string, backendEnvironmentName?: string | undefined): ts.NodeArray<ts.Node>;
16
+ export declare function createFunctionDefinition(definition?: FunctionDefinition, postImportStatements?: (ts.CallExpression | ts.JSDoc | ts.ExpressionStatement)[], namedImports?: Record<string, Set<string>>, appId?: string, backendEnvironmentName?: string): ts.ObjectLiteralElementLike[];
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AASjD,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAElC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA8ED,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,yBA4B1H;AAqBD,wBAAgB,wBAAwB,CACtC,UAAU,CAAC,EAAE,kBAAkB,EAC/B,oBAAoB,CAAC,EAAE,CAAC,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,mBAAmB,CAAC,EAAE,EAChF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EAC1C,KAAK,CAAC,EAAE,MAAM,EACd,sBAAsB,CAAC,EAAE,MAAM,iCAuIhC"}
@@ -0,0 +1,125 @@
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.renderFunctions = renderFunctions;
7
+ exports.createFunctionDefinition = createFunctionDefinition;
8
+ const typescript_1 = __importDefault(require("typescript"));
9
+ const client_lambda_1 = require("@aws-sdk/client-lambda");
10
+ const resource_1 = require("../../resource/resource");
11
+ const node_assert_1 = __importDefault(require("node:assert"));
12
+ const factory = typescript_1.default.factory;
13
+ const gen2BranchNameVariableName = 'branchName';
14
+ const createParameter = (name, value) => factory.createPropertyAssignment(factory.createIdentifier(name), value);
15
+ const createVariableStatement = (variableDeclaration) => {
16
+ return factory.createVariableStatement([], factory.createVariableDeclarationList([variableDeclaration], typescript_1.default.NodeFlags.Const));
17
+ };
18
+ const createTemplateLiteral = (templateHead, templateSpan, templateTail) => {
19
+ return factory.createTemplateExpression(factory.createTemplateHead(templateHead), [
20
+ factory.createTemplateSpan(factory.createIdentifier(templateSpan), factory.createTemplateTail(templateTail)),
21
+ ]);
22
+ };
23
+ function renderFunctions(definition, appId, backendEnvironmentName) {
24
+ const postImportStatements = [];
25
+ const namedImports = { '@aws-amplify/backend': new Set() };
26
+ namedImports['@aws-amplify/backend'].add('defineFunction');
27
+ const defineFunctionProperty = createFunctionDefinition(definition, postImportStatements, namedImports, appId, backendEnvironmentName);
28
+ const amplifyGen1EnvStatement = createVariableStatement(factory.createVariableDeclaration(gen2BranchNameVariableName, undefined, undefined, factory.createIdentifier('process.env.AWS_BRANCH ?? "sandbox"')));
29
+ postImportStatements.push(amplifyGen1EnvStatement);
30
+ return (0, resource_1.renderResourceTsFile)({
31
+ exportedVariableName: factory.createIdentifier((definition === null || definition === void 0 ? void 0 : definition.resourceName) || 'sayHello'),
32
+ functionCallParameter: factory.createObjectLiteralExpression(defineFunctionProperty, true),
33
+ backendFunctionConstruct: 'defineFunction',
34
+ additionalImportedBackendIdentifiers: namedImports,
35
+ postImportStatements,
36
+ });
37
+ }
38
+ function createFunctionDefinition(definition, postImportStatements, namedImports, appId, backendEnvironmentName) {
39
+ var _a;
40
+ const defineFunctionProperties = [];
41
+ const entryPoint = (definition === null || definition === void 0 ? void 0 : definition.entry) || './index.js';
42
+ defineFunctionProperties.push(createParameter('entry', factory.createStringLiteral(entryPoint)));
43
+ if (definition === null || definition === void 0 ? void 0 : definition.name) {
44
+ const funcNameAssignment = createTemplateLiteral(`${definition.resourceName}-`, gen2BranchNameVariableName, '');
45
+ defineFunctionProperties.push(createParameter('name', funcNameAssignment));
46
+ }
47
+ if (definition === null || definition === void 0 ? void 0 : definition.timeoutSeconds) {
48
+ defineFunctionProperties.push(createParameter('timeoutSeconds', factory.createNumericLiteral(definition.timeoutSeconds)));
49
+ }
50
+ if (definition === null || definition === void 0 ? void 0 : definition.memoryMB) {
51
+ defineFunctionProperties.push(createParameter('memoryMB', factory.createNumericLiteral(definition.memoryMB)));
52
+ }
53
+ if ((_a = definition === null || definition === void 0 ? void 0 : definition.environment) === null || _a === void 0 ? void 0 : _a.Variables) {
54
+ defineFunctionProperties.push(createParameter('environment', factory.createObjectLiteralExpression(Object.entries(definition.environment.Variables).map(([key, value]) => {
55
+ if (key == 'API_KEY' && value.startsWith(`/amplify/${appId}/${backendEnvironmentName}`)) {
56
+ if (namedImports && namedImports['@aws-amplify/backend']) {
57
+ namedImports['@aws-amplify/backend'].add('secret');
58
+ }
59
+ else {
60
+ const namedImports = { '@aws-amplify/backend': new Set() };
61
+ namedImports['@aws-amplify/backend'].add('secret');
62
+ }
63
+ return factory.createPropertyAssignment(key, factory.createCallExpression(factory.createIdentifier('secret'), undefined, [factory.createStringLiteral('API_KEY')]));
64
+ }
65
+ else if (key == 'ENV') {
66
+ const envNameAssignment = createTemplateLiteral('', gen2BranchNameVariableName, '');
67
+ return createParameter(key, envNameAssignment);
68
+ }
69
+ return createParameter(key, factory.createStringLiteral(value));
70
+ }))));
71
+ }
72
+ const runtime = definition === null || definition === void 0 ? void 0 : definition.runtime;
73
+ if (runtime && runtime.includes('nodejs')) {
74
+ let nodeRuntime;
75
+ switch (runtime) {
76
+ case client_lambda_1.Runtime.nodejs16x:
77
+ nodeRuntime = 16;
78
+ break;
79
+ case client_lambda_1.Runtime.nodejs18x:
80
+ nodeRuntime = 18;
81
+ break;
82
+ case client_lambda_1.Runtime.nodejs20x:
83
+ nodeRuntime = 20;
84
+ break;
85
+ case 'nodejs22x':
86
+ case client_lambda_1.Runtime.nodejs22x:
87
+ nodeRuntime = 22;
88
+ break;
89
+ default:
90
+ throw new Error(`Unsupported nodejs runtime for function: ${runtime}`);
91
+ }
92
+ (0, node_assert_1.default)(nodeRuntime, 'Expected nodejs version to be set');
93
+ defineFunctionProperties.push(createParameter('runtime', factory.createNumericLiteral(nodeRuntime)));
94
+ }
95
+ if (definition === null || definition === void 0 ? void 0 : definition.schedule) {
96
+ const rawScheduleExpression = definition.schedule;
97
+ let scheduleExpression;
98
+ const startIndex = rawScheduleExpression.indexOf('(') + 1;
99
+ const endIndex = rawScheduleExpression.lastIndexOf(')');
100
+ const scheduleValue = startIndex > 0 && endIndex > startIndex ? rawScheduleExpression.slice(startIndex, endIndex) : undefined;
101
+ if (rawScheduleExpression === null || rawScheduleExpression === void 0 ? void 0 : rawScheduleExpression.startsWith('rate(')) {
102
+ const rateValue = scheduleValue;
103
+ if (rateValue) {
104
+ const [value, unit] = rateValue.split(' ');
105
+ const unitMap = {
106
+ minute: 'm',
107
+ minutes: 'm',
108
+ hour: 'h',
109
+ hours: 'h',
110
+ day: 'd',
111
+ days: 'd',
112
+ };
113
+ scheduleExpression = `every ${value}${unitMap[unit]}`;
114
+ }
115
+ }
116
+ else if (rawScheduleExpression === null || rawScheduleExpression === void 0 ? void 0 : rawScheduleExpression.startsWith('cron(')) {
117
+ scheduleExpression = scheduleValue;
118
+ }
119
+ if (scheduleExpression) {
120
+ defineFunctionProperties.push(createParameter('schedule', factory.createStringLiteral(scheduleExpression)));
121
+ }
122
+ }
123
+ return defineFunctionProperties;
124
+ }
125
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/functions/index.ts"],"names":[],"mappings":";;;;;AA6GA,0CA4BC;AAqBD,4DA4IC;AA1SD,4DAA4B;AAG5B,0DAAiD;AACjD,sDAA+D;AAC/D,8DAAiC;AA6BjC,MAAM,OAAO,GAAG,oBAAE,CAAC,OAAO,CAAC;AAE3B,MAAM,0BAA0B,GAAG,YAAY,CAAC;AAUhD,MAAM,eAAe,GAAG,CACtB,IAAY,EACZ,KAAgF,EACzD,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;AASpG,MAAM,uBAAuB,GAAG,CAAC,mBAAwC,EAAqB,EAAE;IAC9F,OAAO,OAAO,CAAC,uBAAuB,CAAC,EAAE,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CAAC,EAAE,oBAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/H,CAAC,CAAC;AAWF,MAAM,qBAAqB,GAAG,CAAC,YAAoB,EAAE,YAAoB,EAAE,YAAoB,EAAE,EAAE;IACjG,OAAO,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE;QAChF,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;KAC7G,CAAC,CAAC;AACL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AAkB,GAAG,SAAS,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxD,CAAC;QACH,CAAC;aAEI,IAAI,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAEpD,kBAAkB,GAAG,aAAa,CAAC;QACrC,CAAC;QAGD,IAAI,kBAAkB,EAAE,CAAC;YACvB,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAC9G,CAAC;IACH,CAAC;IAGD,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import ts from 'typescript';
2
+ export type Lambda = {
3
+ source: string;
4
+ };
5
+ export declare const createTriggersProperty: (triggers: Record<string, Lambda>) => ts.PropertyAssignment;
6
+ //# sourceMappingURL=lambda.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda.d.ts","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/functions/lambda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF,eAAO,MAAM,sBAAsB,GAAI,UAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,0BAWtE,CAAC"}
@@ -0,0 +1,16 @@
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.createTriggersProperty = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const factory = typescript_1.default.factory;
9
+ const createTriggersProperty = (triggers) => {
10
+ return factory.createPropertyAssignment(factory.createIdentifier('triggers'), factory.createObjectLiteralExpression(Object.entries(triggers).map(([key, value]) => {
11
+ const functionName = value.source.split('/')[3];
12
+ return factory.createPropertyAssignment(factory.createIdentifier(key), factory.createIdentifier(functionName));
13
+ }), true));
14
+ };
15
+ exports.createTriggersProperty = createTriggersProperty;
16
+ //# sourceMappingURL=lambda.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda.js","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/functions/lambda.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAK5B,MAAM,OAAO,GAAG,oBAAE,CAAC,OAAO,CAAC;AAEpB,MAAM,sBAAsB,GAAG,CAAC,QAAgC,EAAE,EAAE;IACzE,OAAO,OAAO,CAAC,wBAAwB,CACrC,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,EACpC,OAAO,CAAC,6BAA6B,CACnC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,OAAO,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC;IACjH,CAAC,CAAC,EACF,IAAI,CACL,CACF,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC"}
@@ -0,0 +1,4 @@
1
+ import ts from 'typescript';
2
+ import { AccessPatterns } from '.';
3
+ export declare const getAccessPatterns: (accessPatterns: AccessPatterns) => ts.PropertyAssignment;
4
+ //# sourceMappingURL=access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/storage/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAc,MAAM,GAAG,CAAC;AAoB/C,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,cAAc,KAAG,EAAE,CAAC,kBAqDrE,CAAC"}
@@ -0,0 +1,53 @@
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.getAccessPatterns = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const factory = typescript_1.default.factory;
9
+ const createAllowPattern = (allowIdentifier, userLevel, permissions) => {
10
+ return factory.createCallExpression(factory.createPropertyAccessExpression(allowIdentifier, factory.createIdentifier(`${userLevel}.to`)), undefined, [factory.createArrayLiteralExpression(permissions.map((p) => factory.createStringLiteral(p)))]);
11
+ };
12
+ const getAccessPatterns = (accessPatterns) => {
13
+ var _a, _b;
14
+ const accessIdentifier = factory.createIdentifier('access');
15
+ const allowIdentifier = factory.createIdentifier('allow');
16
+ const publicPathAccess = [];
17
+ const privatePathAccess = [];
18
+ const protectedPathAccess = [];
19
+ if (accessPatterns.guest && accessPatterns.guest.length) {
20
+ publicPathAccess.push(createAllowPattern(allowIdentifier, 'guest', (_a = accessPatterns.guest) !== null && _a !== void 0 ? _a : []));
21
+ }
22
+ if (accessPatterns.auth && accessPatterns.auth.length) {
23
+ const accessPattern = createAllowPattern(allowIdentifier, 'authenticated', (_b = accessPatterns.auth) !== null && _b !== void 0 ? _b : []);
24
+ publicPathAccess.push(accessPattern);
25
+ protectedPathAccess.push(accessPattern);
26
+ privatePathAccess.push(accessPattern);
27
+ }
28
+ if (accessPatterns.groups && Object.keys(accessPatterns.groups).length) {
29
+ Object.entries(accessPatterns.groups).forEach(([key, value]) => {
30
+ publicPathAccess.push(createAllowPattern(allowIdentifier, `groups(['${key}'])`, value));
31
+ privatePathAccess.push(createAllowPattern(allowIdentifier, `groups(['${key}'])`, value));
32
+ protectedPathAccess.push(createAllowPattern(allowIdentifier, `groups(['${key}'])`, value));
33
+ });
34
+ }
35
+ const publicPath = 'public/*';
36
+ const privatePath = 'private/{entity_id}/*';
37
+ const protectedPath = 'protected/{entity_id}/*';
38
+ const allowAssignments = [];
39
+ const createAccessPropertyAssignment = (bucketPath, accessArray) => factory.createPropertyAssignment(factory.createStringLiteral(bucketPath), factory.createArrayLiteralExpression(accessArray));
40
+ if (publicPathAccess.length) {
41
+ allowAssignments.push(createAccessPropertyAssignment(publicPath, publicPathAccess));
42
+ }
43
+ if (protectedPathAccess.length) {
44
+ allowAssignments.push(createAccessPropertyAssignment(protectedPath, protectedPathAccess));
45
+ }
46
+ if (privatePathAccess.length) {
47
+ allowAssignments.push(createAccessPropertyAssignment(privatePath, privatePathAccess));
48
+ }
49
+ const accessFunction = factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, allowIdentifier)], undefined, undefined, factory.createParenthesizedExpression(factory.createObjectLiteralExpression(allowAssignments, true)));
50
+ return factory.createPropertyAssignment(accessIdentifier, accessFunction);
51
+ };
52
+ exports.getAccessPatterns = getAccessPatterns;
53
+ //# sourceMappingURL=access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.js","sourceRoot":"","sources":["../../../../../../src/commands/gen2-migration/generate/generators/storage/access.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4D;AAE5D,MAAM,OAAO,GAAG,oBAAE,CAAC,OAAO,CAAC;AAW3B,MAAM,kBAAkB,GAAG,CAAC,eAA2B,EAAE,SAAoB,EAAE,WAAyB,EAAE,EAAE;IAC1G,OAAO,OAAO,CAAC,oBAAoB,CACjC,OAAO,CAAC,8BAA8B,CAAC,eAAe,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,EACpG,SAAS,EACT,CAAC,OAAO,CAAC,4BAA4B,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,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eAAe,CAAC,CAAC,EAC3E,SAAS,EACT,SAAS,EACT,OAAO,CAAC,6BAA6B,CAAC,OAAO,CAAC,6BAA6B,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,CACrG,CAAC;IACF,OAAO,OAAO,CAAC,wBAAwB,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;AAC5E,CAAC,CAAC;AArDW,QAAA,iBAAiB,qBAqD5B"}
@@ -0,0 +1,31 @@
1
+ import ts from 'typescript';
2
+ import { Lambda } from '../functions/lambda';
3
+ import type { BucketAccelerateStatus, BucketVersioningStatus, ServerSideEncryptionByDefault } from '@aws-sdk/client-s3';
4
+ export type S3TriggerDefinition = Record<string, never>;
5
+ export type Permission = 'read' | 'write' | 'create' | 'delete';
6
+ export type GroupPermissions<G extends readonly string[]> = {
7
+ [Key in G[number]]: Permission[];
8
+ };
9
+ export type StorageTriggerEvent = 'onDelete' | 'onUpload';
10
+ export type AccessPatterns = {
11
+ auth?: Permission[];
12
+ guest?: Permission[];
13
+ groups?: Record<string, Permission[]>;
14
+ };
15
+ export type ServerSideEncryptionConfiguration = {
16
+ serverSideEncryptionByDefault: ServerSideEncryptionByDefault;
17
+ bucketKeyEnabled: boolean;
18
+ };
19
+ export interface StorageRenderParameters {
20
+ bucketName?: string;
21
+ triggers?: Partial<Record<StorageTriggerEvent, Lambda>>;
22
+ accessPatterns?: AccessPatterns;
23
+ storageIdentifier?: string;
24
+ lambdas?: S3TriggerDefinition[];
25
+ bucketEncryptionAlgorithm?: ServerSideEncryptionConfiguration;
26
+ dynamoTables?: import('../../adapters/storage').DynamoDBTableDefinition[];
27
+ accelerateConfiguration?: BucketAccelerateStatus;
28
+ versioningConfiguration?: BucketVersioningStatus;
29
+ }
30
+ export declare const renderStorage: (storageParams?: StorageRenderParameters) => ts.NodeArray<ts.Node>;
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/comm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