@aws-amplify/graphql-api-construct 1.3.0 → 1.4.0-construct-publish-test.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. package/.jsii +903 -176
  2. package/API.md +80 -1
  3. package/CHANGELOG.md +11 -0
  4. package/README.md +623 -10
  5. package/lib/amplify-dynamodb-table-wrapper.d.ts +128 -0
  6. package/lib/amplify-dynamodb-table-wrapper.js +102 -0
  7. package/lib/amplify-graphql-api.d.ts +4 -0
  8. package/lib/amplify-graphql-api.js +10 -3
  9. package/lib/amplify-graphql-definition.d.ts +19 -2
  10. package/lib/amplify-graphql-definition.js +57 -5
  11. package/lib/index.d.ts +2 -1
  12. package/lib/index.js +5 -2
  13. package/lib/internal/construct-exports.js +8 -1
  14. package/lib/internal/data-source-config.d.ts +7 -0
  15. package/lib/internal/data-source-config.js +37 -0
  16. package/lib/internal/index.d.ts +1 -1
  17. package/lib/internal/index.js +2 -2
  18. package/lib/internal/model-type-name.d.ts +8 -0
  19. package/lib/internal/model-type-name.js +27 -0
  20. package/lib/types.d.ts +47 -7
  21. package/lib/types.js +1 -1
  22. package/node_modules/@aws-amplify/backend-output-schemas/lib/auth/index.js +7 -9
  23. package/node_modules/@aws-amplify/backend-output-schemas/lib/auth/v1.js +15 -18
  24. package/node_modules/@aws-amplify/backend-output-schemas/lib/graphql/index.js +10 -16
  25. package/node_modules/@aws-amplify/backend-output-schemas/lib/graphql/v1.js +22 -20
  26. package/node_modules/@aws-amplify/backend-output-schemas/lib/index.d.ts +12 -1
  27. package/node_modules/@aws-amplify/backend-output-schemas/lib/index.js +37 -63
  28. package/node_modules/@aws-amplify/backend-output-schemas/lib/platform/index.js +16 -14
  29. package/node_modules/@aws-amplify/backend-output-schemas/lib/platform/stack_metadata_schemas.js +7 -11
  30. package/node_modules/@aws-amplify/backend-output-schemas/lib/stack/index.d.ts +5 -0
  31. package/node_modules/@aws-amplify/backend-output-schemas/lib/stack/index.js +7 -9
  32. package/node_modules/@aws-amplify/backend-output-schemas/lib/stack/v1.d.ts +5 -0
  33. package/node_modules/@aws-amplify/backend-output-schemas/lib/stack/v1.js +9 -11
  34. package/node_modules/@aws-amplify/backend-output-schemas/lib/storage/index.js +7 -9
  35. package/node_modules/@aws-amplify/backend-output-schemas/lib/storage/v1.js +9 -12
  36. package/node_modules/@aws-amplify/backend-output-schemas/package.json +4 -23
  37. package/node_modules/@aws-amplify/backend-output-storage/lib/index.d.ts +1 -0
  38. package/node_modules/@aws-amplify/backend-output-storage/lib/index.js +17 -14
  39. package/node_modules/@aws-amplify/backend-output-storage/lib/stack_metadata_output_storage_strategy.js +28 -32
  40. package/node_modules/@aws-amplify/backend-output-storage/lib/store_attribution_metadata.d.ts +50 -0
  41. package/node_modules/@aws-amplify/backend-output-storage/lib/store_attribution_metadata.js +104 -0
  42. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/backend_deployment_type.d.ts +5 -0
  43. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/backend_deployment_type.js +9 -0
  44. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/cdk_context_key.d.ts +9 -0
  45. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/cdk_context_key.js +13 -0
  46. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/index.d.ts +4 -0
  47. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/index.js +22 -0
  48. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/unique_backend_identifier.d.ts +53 -0
  49. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/lib/unique_backend_identifier.js +74 -0
  50. package/node_modules/@aws-amplify/backend-output-storage/node_modules/@aws-amplify/platform-core/package.json +23 -0
  51. package/node_modules/@aws-amplify/backend-output-storage/package.json +6 -4
  52. package/node_modules/@aws-amplify/graphql-auth-transformer/CHANGELOG.md +4 -0
  53. package/node_modules/@aws-amplify/graphql-auth-transformer/LICENSE +201 -0
  54. package/node_modules/@aws-amplify/graphql-auth-transformer/package.json +11 -10
  55. package/node_modules/@aws-amplify/graphql-default-value-transformer/CHANGELOG.md +4 -0
  56. package/node_modules/@aws-amplify/graphql-default-value-transformer/LICENSE +201 -0
  57. package/node_modules/@aws-amplify/graphql-default-value-transformer/package.json +8 -7
  58. package/node_modules/@aws-amplify/graphql-function-transformer/CHANGELOG.md +4 -0
  59. package/node_modules/@aws-amplify/graphql-function-transformer/LICENSE +201 -0
  60. package/node_modules/@aws-amplify/graphql-function-transformer/package.json +7 -6
  61. package/node_modules/@aws-amplify/graphql-http-transformer/CHANGELOG.md +4 -0
  62. package/node_modules/@aws-amplify/graphql-http-transformer/LICENSE +201 -0
  63. package/node_modules/@aws-amplify/graphql-http-transformer/package.json +7 -6
  64. package/node_modules/@aws-amplify/graphql-index-transformer/API.md +3 -0
  65. package/node_modules/@aws-amplify/graphql-index-transformer/CHANGELOG.md +6 -0
  66. package/node_modules/@aws-amplify/graphql-index-transformer/LICENSE +201 -0
  67. package/node_modules/@aws-amplify/graphql-index-transformer/lib/graphql-index-transformer.js +4 -0
  68. package/node_modules/@aws-amplify/graphql-index-transformer/lib/graphql-index-transformer.js.map +1 -1
  69. package/node_modules/@aws-amplify/graphql-index-transformer/lib/graphql-primary-key-transformer.d.ts.map +1 -1
  70. package/node_modules/@aws-amplify/graphql-index-transformer/lib/graphql-primary-key-transformer.js.map +1 -1
  71. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.d.ts +1 -1
  72. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.d.ts.map +1 -1
  73. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.js +2 -1
  74. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.js.map +1 -1
  75. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.d.ts +5 -5
  76. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.d.ts.map +1 -1
  77. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.js +34 -8
  78. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.js.map +1 -1
  79. package/node_modules/@aws-amplify/graphql-index-transformer/package.json +8 -7
  80. package/node_modules/@aws-amplify/graphql-maps-to-transformer/CHANGELOG.md +4 -0
  81. package/node_modules/@aws-amplify/graphql-maps-to-transformer/LICENSE +201 -0
  82. package/node_modules/@aws-amplify/graphql-maps-to-transformer/lib/assets/mapping-lambda.zip +0 -0
  83. package/node_modules/@aws-amplify/graphql-maps-to-transformer/package.json +11 -10
  84. package/node_modules/@aws-amplify/graphql-model-transformer/CHANGELOG.md +6 -0
  85. package/node_modules/@aws-amplify/graphql-model-transformer/LICENSE +201 -0
  86. package/node_modules/@aws-amplify/graphql-model-transformer/lib/graphql-model-transformer.d.ts +2 -1
  87. package/node_modules/@aws-amplify/graphql-model-transformer/lib/graphql-model-transformer.d.ts.map +1 -1
  88. package/node_modules/@aws-amplify/graphql-model-transformer/lib/graphql-model-transformer.js +52 -47
  89. package/node_modules/@aws-amplify/graphql-model-transformer/lib/graphql-model-transformer.js.map +1 -1
  90. package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-lambda.zip +0 -0
  91. package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-notification-lambda.zip +0 -0
  92. package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-patching-lambda.zip +0 -0
  93. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.d.ts +15 -0
  94. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.d.ts.map +1 -0
  95. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.js +169 -0
  96. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.js.map +1 -0
  97. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.d.ts +40 -0
  98. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.d.ts.map +1 -0
  99. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.js +242 -0
  100. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.js.map +1 -0
  101. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.d.ts +12 -0
  102. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.d.ts.map +1 -0
  103. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.js +663 -0
  104. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.js.map +1 -0
  105. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.d.ts +5 -2
  106. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.d.ts.map +1 -1
  107. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.js +47 -60
  108. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.js.map +1 -1
  109. package/node_modules/@aws-amplify/graphql-model-transformer/package.json +9 -6
  110. package/node_modules/@aws-amplify/graphql-predictions-transformer/CHANGELOG.md +4 -0
  111. package/node_modules/@aws-amplify/graphql-predictions-transformer/LICENSE +201 -0
  112. package/node_modules/@aws-amplify/graphql-predictions-transformer/lib/predictionsLambdaFunction.zip +0 -0
  113. package/node_modules/@aws-amplify/graphql-predictions-transformer/package.json +7 -6
  114. package/node_modules/@aws-amplify/graphql-relational-transformer/CHANGELOG.md +6 -0
  115. package/node_modules/@aws-amplify/graphql-relational-transformer/LICENSE +201 -0
  116. package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.d.ts.map +1 -1
  117. package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.js +3 -10
  118. package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.js.map +1 -1
  119. package/node_modules/@aws-amplify/graphql-relational-transformer/package.json +9 -8
  120. package/node_modules/@aws-amplify/graphql-searchable-transformer/CHANGELOG.md +4 -0
  121. package/node_modules/@aws-amplify/graphql-searchable-transformer/LICENSE +201 -0
  122. package/node_modules/@aws-amplify/graphql-searchable-transformer/lib/streaming-lambda.zip +0 -0
  123. package/node_modules/@aws-amplify/graphql-searchable-transformer/package.json +8 -7
  124. package/node_modules/@aws-amplify/graphql-transformer/API.md +2 -2
  125. package/node_modules/@aws-amplify/graphql-transformer/CHANGELOG.md +6 -0
  126. package/node_modules/@aws-amplify/graphql-transformer/LICENSE +201 -0
  127. package/node_modules/@aws-amplify/graphql-transformer/lib/graphql-transformer.d.ts +3 -3
  128. package/node_modules/@aws-amplify/graphql-transformer/lib/graphql-transformer.d.ts.map +1 -1
  129. package/node_modules/@aws-amplify/graphql-transformer/lib/graphql-transformer.js.map +1 -1
  130. package/node_modules/@aws-amplify/graphql-transformer/package.json +15 -14
  131. package/node_modules/@aws-amplify/graphql-transformer/src/graphql-transformer.ts +3 -8
  132. package/node_modules/@aws-amplify/graphql-transformer-core/API.md +9 -11
  133. package/node_modules/@aws-amplify/graphql-transformer-core/CHANGELOG.md +6 -0
  134. package/node_modules/@aws-amplify/graphql-transformer-core/LICENSE +201 -0
  135. package/node_modules/@aws-amplify/graphql-transformer-core/lib/config/index.d.ts +0 -1
  136. package/node_modules/@aws-amplify/graphql-transformer-core/lib/config/index.d.ts.map +1 -1
  137. package/node_modules/@aws-amplify/graphql-transformer-core/lib/config/index.js.map +1 -1
  138. package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.d.ts +3 -3
  139. package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.d.ts.map +1 -1
  140. package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.js +3 -1
  141. package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.js.map +1 -1
  142. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/index.d.ts +1 -0
  143. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/index.d.ts.map +1 -1
  144. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/index.js +3 -1
  145. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/index.js.map +1 -1
  146. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/transform.d.ts.map +1 -1
  147. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/transform.js.map +1 -1
  148. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/types.d.ts +2 -3
  149. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/types.d.ts.map +1 -1
  150. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/utils.d.ts +2 -1
  151. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/utils.d.ts.map +1 -1
  152. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/utils.js +12 -1
  153. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/utils.js.map +1 -1
  154. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/index.d.ts +3 -4
  155. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/index.d.ts.map +1 -1
  156. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.d.ts +1 -0
  157. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.d.ts.map +1 -1
  158. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.js +3 -1
  159. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.js.map +1 -1
  160. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/provision-strategy-utils.d.ts +3 -0
  161. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/provision-strategy-utils.d.ts.map +1 -0
  162. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/provision-strategy-utils.js +15 -0
  163. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/provision-strategy-utils.js.map +1 -0
  164. package/node_modules/@aws-amplify/graphql-transformer-core/package.json +5 -4
  165. package/node_modules/@aws-amplify/graphql-transformer-interfaces/API.md +25 -3
  166. package/node_modules/@aws-amplify/graphql-transformer-interfaces/CHANGELOG.md +6 -0
  167. package/node_modules/@aws-amplify/graphql-transformer-interfaces/LICENSE +201 -0
  168. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/index.d.ts +1 -1
  169. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/index.d.ts.map +1 -1
  170. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/index.js +2 -1
  171. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/index.js.map +1 -1
  172. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transformer-context-provider.d.ts +2 -2
  173. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transformer-datasource-provider.d.ts +7 -1
  174. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transformer-datasource-provider.d.ts.map +1 -1
  175. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transformer-datasource-provider.js +6 -1
  176. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transformer-datasource-provider.js.map +1 -1
  177. package/node_modules/@aws-amplify/graphql-transformer-interfaces/package.json +3 -2
  178. package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transformer-context/index.ts +4 -0
  179. package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transformer-context/transformer-context-provider.ts +2 -2
  180. package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transformer-context/transformer-datasource-provider.ts +16 -1
  181. package/node_modules/@aws-amplify/graphql-transformer-interfaces/tsconfig.tsbuildinfo +1 -1
  182. package/node_modules/@aws-amplify/platform-core/lib/backend_deployment_type.d.ts +5 -0
  183. package/node_modules/@aws-amplify/platform-core/lib/backend_deployment_type.js +9 -0
  184. package/node_modules/@aws-amplify/platform-core/lib/cdk_context_key.d.ts +9 -0
  185. package/node_modules/@aws-amplify/platform-core/lib/cdk_context_key.js +13 -0
  186. package/node_modules/@aws-amplify/platform-core/lib/index.d.ts +4 -0
  187. package/node_modules/@aws-amplify/platform-core/lib/index.js +22 -0
  188. package/node_modules/@aws-amplify/platform-core/lib/unique_backend_identifier.d.ts +53 -0
  189. package/node_modules/@aws-amplify/platform-core/lib/unique_backend_identifier.js +74 -0
  190. package/node_modules/@aws-amplify/platform-core/package.json +24 -0
  191. package/node_modules/@aws-amplify/plugin-types/lib/amplify_function.d.ts +4 -0
  192. package/node_modules/@aws-amplify/plugin-types/lib/amplify_function.js +3 -0
  193. package/node_modules/@aws-amplify/plugin-types/lib/amplify_output_writer.d.ts +9 -0
  194. package/node_modules/@aws-amplify/plugin-types/lib/amplify_output_writer.js +3 -0
  195. package/node_modules/@aws-amplify/plugin-types/lib/auth_resources.d.ts +42 -0
  196. package/node_modules/@aws-amplify/plugin-types/lib/auth_resources.js +3 -0
  197. package/node_modules/@aws-amplify/plugin-types/lib/backend_output.d.ts +6 -0
  198. package/node_modules/@aws-amplify/plugin-types/lib/backend_output.js +3 -0
  199. package/node_modules/@aws-amplify/plugin-types/lib/backend_secret_resolver.d.ts +13 -0
  200. package/node_modules/@aws-amplify/plugin-types/lib/backend_secret_resolver.js +3 -0
  201. package/node_modules/@aws-amplify/plugin-types/lib/backend_stack_creator.d.ts +8 -0
  202. package/node_modules/@aws-amplify/plugin-types/lib/backend_stack_creator.js +3 -0
  203. package/node_modules/@aws-amplify/plugin-types/lib/backend_stack_resolver.d.ts +7 -0
  204. package/node_modules/@aws-amplify/plugin-types/lib/backend_stack_resolver.js +3 -0
  205. package/node_modules/@aws-amplify/plugin-types/lib/construct_container.d.ts +26 -0
  206. package/node_modules/@aws-amplify/plugin-types/lib/construct_container.js +3 -0
  207. package/node_modules/@aws-amplify/plugin-types/lib/construct_factory.d.ts +21 -0
  208. package/node_modules/@aws-amplify/plugin-types/lib/construct_factory.js +3 -0
  209. package/node_modules/@aws-amplify/plugin-types/lib/function_resources.d.ts +5 -0
  210. package/node_modules/@aws-amplify/plugin-types/lib/function_resources.js +3 -0
  211. package/node_modules/@aws-amplify/plugin-types/lib/import_path_verifier.d.ts +14 -0
  212. package/node_modules/@aws-amplify/plugin-types/lib/import_path_verifier.js +3 -0
  213. package/node_modules/@aws-amplify/plugin-types/lib/index.d.ts +16 -0
  214. package/node_modules/@aws-amplify/plugin-types/lib/index.js +32 -0
  215. package/node_modules/@aws-amplify/plugin-types/lib/output_retrieval_strategy.d.ts +11 -0
  216. package/node_modules/@aws-amplify/plugin-types/lib/output_retrieval_strategy.js +3 -0
  217. package/node_modules/@aws-amplify/plugin-types/lib/output_storage_strategy.d.ts +8 -0
  218. package/node_modules/@aws-amplify/plugin-types/lib/output_storage_strategy.js +3 -0
  219. package/node_modules/@aws-amplify/plugin-types/lib/resource_provider.d.ts +7 -0
  220. package/node_modules/@aws-amplify/plugin-types/lib/resource_provider.js +3 -0
  221. package/node_modules/@aws-amplify/plugin-types/lib/unique_backend_identifier.d.ts +25 -0
  222. package/node_modules/@aws-amplify/plugin-types/lib/unique_backend_identifier.js +3 -0
  223. package/node_modules/@aws-amplify/plugin-types/package.json +20 -0
  224. package/node_modules/graphql-transformer-common/API.md +3 -0
  225. package/node_modules/graphql-transformer-common/CHANGELOG.md +6 -0
  226. package/node_modules/graphql-transformer-common/LICENSE +201 -0
  227. package/node_modules/graphql-transformer-common/lib/ResourceConstants.d.ts +3 -0
  228. package/node_modules/graphql-transformer-common/lib/ResourceConstants.d.ts.map +1 -1
  229. package/node_modules/graphql-transformer-common/lib/ResourceConstants.js +3 -0
  230. package/node_modules/graphql-transformer-common/lib/ResourceConstants.js.map +1 -1
  231. package/node_modules/graphql-transformer-common/package.json +3 -2
  232. package/package.json +24 -24
  233. package/src/amplify-dynamodb-table-wrapper.ts +177 -0
  234. package/src/amplify-graphql-api.ts +10 -3
  235. package/src/amplify-graphql-definition.ts +63 -3
  236. package/src/index.ts +13 -0
  237. package/src/internal/construct-exports.ts +7 -0
  238. package/src/internal/data-source-config.ts +39 -0
  239. package/src/internal/index.ts +1 -1
  240. package/src/internal/model-type-name.ts +30 -0
  241. package/src/types.ts +54 -7
  242. package/babel.config.js +0 -13
  243. package/lib/internal/amplify-metadata.d.ts +0 -6
  244. package/lib/internal/amplify-metadata.js +0 -58
  245. package/node_modules/@aws-amplify/backend-output-schemas/lib/index.internal.d.ts +0 -3
  246. package/node_modules/@aws-amplify/backend-output-schemas/lib/index.internal.js +0 -27
  247. package/node_modules/@aws-amplify/graphql-transformer-core/lib/config/project-config.d.ts +0 -6
  248. package/node_modules/@aws-amplify/graphql-transformer-core/lib/config/project-config.d.ts.map +0 -1
  249. package/node_modules/@aws-amplify/graphql-transformer-core/lib/config/project-config.js +0 -3
  250. package/node_modules/@aws-amplify/graphql-transformer-core/lib/config/project-config.js.map +0 -1
  251. package/remove-module-type-from-package-json.ts +0 -19
  252. package/src/internal/amplify-metadata.ts +0 -58
@@ -0,0 +1,663 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toCreateTableInput = exports.extractTableInputFromEvent = exports.getPointInTimeRecoveryUpdate = exports.getTtlUpdate = exports.getDeletionProtectionUpdate = exports.getSseUpdate = exports.getStreamUpdate = exports.getNextGSIUpdate = exports.isComplete = exports.onEvent = void 0;
4
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
5
+ const ddbClient = new client_dynamodb_1.DynamoDB();
6
+ const finished = {
7
+ IsComplete: true,
8
+ };
9
+ const notFinished = {
10
+ IsComplete: false,
11
+ };
12
+ const log = (msg, ...other) => {
13
+ console.log(msg, other.map((o) => (typeof o === 'object' ? JSON.stringify(o, undefined, 2) : o)));
14
+ };
15
+ const onEvent = async (event) => {
16
+ var _a;
17
+ console.log({ ...event, ResponseURL: '[redacted]' });
18
+ const tableDef = (0, exports.extractTableInputFromEvent)(event);
19
+ console.log('Input table state: ', tableDef);
20
+ let result;
21
+ switch (event.RequestType) {
22
+ case 'Create':
23
+ console.log('Initiating CREATE event');
24
+ const createTableInput = (0, exports.toCreateTableInput)(tableDef);
25
+ console.log('Create Table Params: ', createTableInput);
26
+ const response = await createNewTable(createTableInput);
27
+ result = {
28
+ PhysicalResourceId: response.tableName,
29
+ Data: {
30
+ TableArn: response.tableArn,
31
+ TableStreamArn: response.streamArn,
32
+ TableName: response.tableName,
33
+ },
34
+ };
35
+ console.log('Returning result: ', result);
36
+ return result;
37
+ case 'Update':
38
+ if (!event.PhysicalResourceId) {
39
+ throw new Error(`Could not find the physical ID for the updated resource`);
40
+ }
41
+ console.log('Fetching current table state');
42
+ const describeTableResult = await ddbClient.describeTable({ TableName: event.PhysicalResourceId });
43
+ if (!describeTableResult.Table) {
44
+ throw new Error(`Could not find ${event.PhysicalResourceId} to update`);
45
+ }
46
+ log('Current table state: ', describeTableResult);
47
+ if (isKeySchemaModified(describeTableResult.Table.KeySchema, tableDef.keySchema)) {
48
+ console.log('Update requires replacement');
49
+ console.log('Deleting the old table');
50
+ await ddbClient.deleteTable({ TableName: event.PhysicalResourceId });
51
+ await retry(async () => await doesTableExist(event.PhysicalResourceId), (res) => res === false);
52
+ console.log(`Table '${event.PhysicalResourceId}' does not exist. Deletion is finished.`);
53
+ const createTableInput = (0, exports.toCreateTableInput)(tableDef);
54
+ const response = await createNewTable(createTableInput);
55
+ result = {
56
+ PhysicalResourceId: response.tableName,
57
+ Data: {
58
+ TableArn: response.tableArn,
59
+ TableStreamArn: response.streamArn,
60
+ TableName: response.tableName,
61
+ IsTableReplaced: true,
62
+ },
63
+ };
64
+ log('Returning result', result);
65
+ return result;
66
+ }
67
+ const describePointInTimeRecoveryResult = await ddbClient.describeContinuousBackups({ TableName: event.PhysicalResourceId });
68
+ console.log('Current point in time recovery: ', describePointInTimeRecoveryResult);
69
+ const pointInTimeUpdate = (0, exports.getPointInTimeRecoveryUpdate)(describePointInTimeRecoveryResult.ContinuousBackupsDescription, tableDef);
70
+ if (pointInTimeUpdate) {
71
+ log('Computed point in time recovery update', pointInTimeUpdate);
72
+ await ddbClient.updateContinuousBackups(pointInTimeUpdate);
73
+ await retry(async () => await isTableReady(event.PhysicalResourceId), (res) => res === true);
74
+ console.log(`Table '${event.PhysicalResourceId}' is ready after the update of PointInTimeRecovery.`);
75
+ }
76
+ const deletionProtectionUpdate = (0, exports.getDeletionProtectionUpdate)(describeTableResult.Table, tableDef);
77
+ if (deletionProtectionUpdate) {
78
+ log('Computed deletion protection update', deletionProtectionUpdate);
79
+ await ddbClient.updateTable(deletionProtectionUpdate);
80
+ await retry(async () => await isTableReady(event.PhysicalResourceId), (res) => res === true);
81
+ console.log(`Table '${event.PhysicalResourceId}' is ready after the update of deletion protection.`);
82
+ }
83
+ const sseUpdate = (0, exports.getSseUpdate)(describeTableResult.Table, tableDef);
84
+ if (sseUpdate) {
85
+ log('Computed server side encryption update', sseUpdate);
86
+ await ddbClient.updateTable(sseUpdate);
87
+ await retry(async () => await isTableReady(event.PhysicalResourceId), (res) => res === true);
88
+ console.log(`Table '${event.PhysicalResourceId}' is ready after the update of sever side encryption.`);
89
+ }
90
+ const streamUpdate = await (0, exports.getStreamUpdate)(describeTableResult.Table, tableDef);
91
+ if (streamUpdate) {
92
+ log('Computed stream specification update', streamUpdate);
93
+ await ddbClient.updateTable(streamUpdate);
94
+ await retry(async () => await isTableReady(event.PhysicalResourceId), (res) => res === true);
95
+ console.log(`Table '${event.PhysicalResourceId}' is ready after the update of stream specificaion.`);
96
+ }
97
+ const describeTimeToLiveResult = await ddbClient.describeTimeToLive({ TableName: event.PhysicalResourceId });
98
+ console.log('Current TTL: ', describeTimeToLiveResult);
99
+ const ttlUpdate = (0, exports.getTtlUpdate)(describeTimeToLiveResult.TimeToLiveDescription, tableDef);
100
+ if (ttlUpdate) {
101
+ log('Computed time to live update', ttlUpdate);
102
+ console.log('Initiating TTL update');
103
+ await ddbClient.updateTimeToLive(ttlUpdate);
104
+ result = {
105
+ PhysicalResourceId: event.PhysicalResourceId,
106
+ Data: {
107
+ TableArn: describeTableResult.Table.TableArn,
108
+ TableStreamArn: describeTableResult.Table.LatestStreamArn,
109
+ TableName: describeTableResult.Table.TableName,
110
+ },
111
+ };
112
+ return result;
113
+ }
114
+ const nextGsiUpdate = (0, exports.getNextGSIUpdate)(describeTableResult.Table, tableDef);
115
+ if (nextGsiUpdate) {
116
+ log('Computed next update', nextGsiUpdate);
117
+ console.log('Initiating table GSI update');
118
+ await ddbClient.updateTable(nextGsiUpdate);
119
+ }
120
+ result = {
121
+ PhysicalResourceId: event.PhysicalResourceId,
122
+ Data: {
123
+ TableArn: describeTableResult.Table.TableArn,
124
+ TableStreamArn: describeTableResult.Table.LatestStreamArn,
125
+ TableName: describeTableResult.Table.TableName,
126
+ },
127
+ };
128
+ return result;
129
+ case 'Delete':
130
+ if (!event.PhysicalResourceId) {
131
+ throw new Error(`Could not find the physical ID for the resource`);
132
+ }
133
+ result = {
134
+ PhysicalResourceId: event.PhysicalResourceId,
135
+ };
136
+ console.log('Fetching current table state');
137
+ const describeTableResultBeforeDeletion = await ddbClient.describeTable({ TableName: event.PhysicalResourceId });
138
+ if ((_a = describeTableResultBeforeDeletion.Table) === null || _a === void 0 ? void 0 : _a.DeletionProtectionEnabled) {
139
+ return result;
140
+ }
141
+ try {
142
+ console.log('Initiating table deletion');
143
+ await ddbClient.deleteTable({ TableName: event.PhysicalResourceId });
144
+ return result;
145
+ }
146
+ catch (err) {
147
+ if (err.code === 'ResourceNotFoundException') {
148
+ return result;
149
+ }
150
+ throw err;
151
+ }
152
+ default:
153
+ throw new Error(`Event type ${event.RequestType} is not supported`);
154
+ }
155
+ };
156
+ exports.onEvent = onEvent;
157
+ const isComplete = async (event) => {
158
+ var _a, _b, _c;
159
+ log('got event', { ...event, ResponseURL: '[redacted]' });
160
+ if (event.RequestType === 'Delete') {
161
+ console.log('Delete is finished');
162
+ return finished;
163
+ }
164
+ if (!event.PhysicalResourceId) {
165
+ throw new Error('PhysicalResourceId not set in call to isComplete');
166
+ }
167
+ console.log('Fetching current table state');
168
+ const describeTableResult = await retry(async () => await ddbClient.describeTable({ TableName: event.PhysicalResourceId }), (result) => !!(result === null || result === void 0 ? void 0 : result.Table));
169
+ if (((_a = describeTableResult.Table) === null || _a === void 0 ? void 0 : _a.TableStatus) !== 'ACTIVE') {
170
+ console.log('Table not active yet');
171
+ return notFinished;
172
+ }
173
+ if ((_b = describeTableResult.Table.GlobalSecondaryIndexes) === null || _b === void 0 ? void 0 : _b.some((gsi) => gsi.IndexStatus !== 'ACTIVE' || gsi.Backfilling)) {
174
+ console.log('Some GSI is not active yet');
175
+ return notFinished;
176
+ }
177
+ const endState = (0, exports.extractTableInputFromEvent)(event);
178
+ if (event.RequestType === 'Create' || ((_c = event.Data) === null || _c === void 0 ? void 0 : _c.IsTableReplaced) === true) {
179
+ const describePointInTimeRecoveryResult = await ddbClient.describeContinuousBackups({ TableName: event.PhysicalResourceId });
180
+ const pointInTimeUpdate = (0, exports.getPointInTimeRecoveryUpdate)(describePointInTimeRecoveryResult.ContinuousBackupsDescription, endState);
181
+ if (pointInTimeUpdate) {
182
+ console.log('Updating table with point in time recovery enabled');
183
+ await ddbClient.updateContinuousBackups(pointInTimeUpdate);
184
+ return notFinished;
185
+ }
186
+ const describeTimeToLiveResult = await ddbClient.describeTimeToLive({ TableName: event.PhysicalResourceId });
187
+ const ttlUpdate = (0, exports.getTtlUpdate)(describeTimeToLiveResult.TimeToLiveDescription, endState);
188
+ if (ttlUpdate) {
189
+ console.log('Updating table with TTL enabled');
190
+ await ddbClient.updateTimeToLive(ttlUpdate);
191
+ return notFinished;
192
+ }
193
+ console.log('Create is finished');
194
+ return finished;
195
+ }
196
+ const nextUpdate = (0, exports.getNextGSIUpdate)(describeTableResult.Table, endState);
197
+ log('Computed next update', nextUpdate);
198
+ if (!nextUpdate) {
199
+ console.log('No additional updates needed. Update finished');
200
+ return finished;
201
+ }
202
+ console.log('Initiating table update');
203
+ await ddbClient.updateTable(nextUpdate);
204
+ return notFinished;
205
+ };
206
+ exports.isComplete = isComplete;
207
+ const getNextGSIUpdate = (currentState, endState) => {
208
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
209
+ const endStateGSIs = endState.globalSecondaryIndexes || [];
210
+ const endStateGSINames = endStateGSIs.map((gsi) => gsi.indexName);
211
+ const currentStateGSIs = currentState.GlobalSecondaryIndexes || [];
212
+ const currentStateGSINames = currentStateGSIs.map((gsi) => gsi.IndexName);
213
+ const isTableBillingModeModified = (((_a = currentState.BillingModeSummary) === null || _a === void 0 ? void 0 : _a.BillingMode) !== undefined && ((_b = currentState.BillingModeSummary) === null || _b === void 0 ? void 0 : _b.BillingMode) !== endState.billingMode) ||
214
+ (((_c = currentState.BillingModeSummary) === null || _c === void 0 ? void 0 : _c.BillingMode) == undefined && endState.billingMode === 'PAY_PER_REQUEST');
215
+ const isTableProvisionThroughputModified = (((_d = endState.provisionedThroughput) === null || _d === void 0 ? void 0 : _d.readCapacityUnits) !== undefined &&
216
+ ((_e = currentState.ProvisionedThroughput) === null || _e === void 0 ? void 0 : _e.ReadCapacityUnits) !== ((_f = endState.provisionedThroughput) === null || _f === void 0 ? void 0 : _f.readCapacityUnits)) ||
217
+ (((_g = endState.provisionedThroughput) === null || _g === void 0 ? void 0 : _g.writeCapacityUnits) !== undefined &&
218
+ ((_h = currentState.ProvisionedThroughput) === null || _h === void 0 ? void 0 : _h.WriteCapacityUnits) !== ((_j = endState.provisionedThroughput) === null || _j === void 0 ? void 0 : _j.writeCapacityUnits));
219
+ if (isTableBillingModeModified || isTableProvisionThroughputModified) {
220
+ let updateInput = {
221
+ TableName: currentState.TableName,
222
+ BillingMode: isTableBillingModeModified ? endState.billingMode : undefined,
223
+ ProvisionedThroughput: isTableProvisionThroughputModified && endState.billingMode === 'PROVISIONED'
224
+ ? {
225
+ ReadCapacityUnits: (_k = endState.provisionedThroughput) === null || _k === void 0 ? void 0 : _k.readCapacityUnits,
226
+ WriteCapacityUnits: (_l = endState.provisionedThroughput) === null || _l === void 0 ? void 0 : _l.writeCapacityUnits,
227
+ }
228
+ : undefined,
229
+ };
230
+ if (isTableBillingModeModified && endState.billingMode === 'PROVISIONED') {
231
+ const indexToBeUpdated = currentStateGSIs.map((gsiToUpdate) => {
232
+ var _a, _b;
233
+ return {
234
+ Update: {
235
+ IndexName: gsiToUpdate.IndexName,
236
+ ProvisionedThroughput: {
237
+ ReadCapacityUnits: (_a = endState.provisionedThroughput) === null || _a === void 0 ? void 0 : _a.readCapacityUnits,
238
+ WriteCapacityUnits: (_b = endState.provisionedThroughput) === null || _b === void 0 ? void 0 : _b.writeCapacityUnits,
239
+ },
240
+ },
241
+ };
242
+ });
243
+ updateInput = {
244
+ ...updateInput,
245
+ GlobalSecondaryIndexUpdates: indexToBeUpdated.length > 0 ? indexToBeUpdated : undefined,
246
+ };
247
+ }
248
+ return parsePropertiesToDynamoDBInput(updateInput);
249
+ }
250
+ const gsiRequiresReplacementPredicate = (currentGSI) => {
251
+ if (!endStateGSINames.includes(currentGSI.IndexName))
252
+ return true;
253
+ const respectiveEndStateGSI = endStateGSIs.find((endStateGSI) => endStateGSI.indexName === currentGSI.IndexName);
254
+ if (isProjectionModified(currentGSI.Projection, respectiveEndStateGSI.projection))
255
+ return true;
256
+ if (isKeySchemaModified(currentGSI.KeySchema, respectiveEndStateGSI.keySchema))
257
+ return true;
258
+ return false;
259
+ };
260
+ const gsiToRemove = currentStateGSIs.find(gsiRequiresReplacementPredicate);
261
+ if (gsiToRemove) {
262
+ return {
263
+ TableName: currentState.TableName,
264
+ GlobalSecondaryIndexUpdates: [
265
+ {
266
+ Delete: {
267
+ IndexName: gsiToRemove.IndexName,
268
+ },
269
+ },
270
+ ],
271
+ };
272
+ }
273
+ const gsiRequiresCreationPredicate = (endStateGSI) => !currentStateGSINames.includes(endStateGSI.indexName);
274
+ const gsiToAdd = endStateGSIs.find(gsiRequiresCreationPredicate);
275
+ if (gsiToAdd) {
276
+ const attributeNamesToInclude = gsiToAdd.keySchema.map((schema) => schema.attributeName);
277
+ const gsiToAddAction = {
278
+ IndexName: gsiToAdd.indexName,
279
+ KeySchema: gsiToAdd.keySchema,
280
+ Projection: gsiToAdd.projection,
281
+ ProvisionedThroughput: gsiToAdd.provisionedThroughput,
282
+ };
283
+ return {
284
+ TableName: currentState.TableName,
285
+ AttributeDefinitions: (_m = endState.attributeDefinitions) === null || _m === void 0 ? void 0 : _m.filter((def) => attributeNamesToInclude.includes(def.attributeName)).map((def) => usePascalCaseForObjectKeys(def)),
286
+ GlobalSecondaryIndexUpdates: [
287
+ {
288
+ Create: parsePropertiesToDynamoDBInput(gsiToAddAction),
289
+ },
290
+ ],
291
+ };
292
+ }
293
+ const gsiRequiresUpdatePredicate = (endStateGSI) => {
294
+ var _a, _b, _c, _d;
295
+ if (endState.provisionedThroughput &&
296
+ endState.provisionedThroughput.readCapacityUnits &&
297
+ endState.provisionedThroughput.writeCapacityUnits &&
298
+ currentStateGSINames.includes(endStateGSI.indexName)) {
299
+ const currentStateGSI = currentStateGSIs.find((gsi) => gsi.IndexName === endStateGSI.indexName);
300
+ if (currentStateGSI) {
301
+ if (((_a = currentStateGSI.ProvisionedThroughput) === null || _a === void 0 ? void 0 : _a.ReadCapacityUnits) !== ((_b = endStateGSI.provisionedThroughput) === null || _b === void 0 ? void 0 : _b.readCapacityUnits) ||
302
+ ((_c = currentStateGSI.ProvisionedThroughput) === null || _c === void 0 ? void 0 : _c.WriteCapacityUnits) !== ((_d = endStateGSI.provisionedThroughput) === null || _d === void 0 ? void 0 : _d.writeCapacityUnits)) {
303
+ return true;
304
+ }
305
+ }
306
+ }
307
+ return false;
308
+ };
309
+ const gsiToUpdate = endStateGSIs.find(gsiRequiresUpdatePredicate);
310
+ if (gsiToUpdate) {
311
+ return {
312
+ TableName: currentState.TableName,
313
+ GlobalSecondaryIndexUpdates: [
314
+ {
315
+ Update: {
316
+ IndexName: gsiToUpdate.indexName,
317
+ ProvisionedThroughput: {
318
+ ReadCapacityUnits: (_o = gsiToUpdate.provisionedThroughput) === null || _o === void 0 ? void 0 : _o.readCapacityUnits,
319
+ WriteCapacityUnits: (_p = gsiToUpdate.provisionedThroughput) === null || _p === void 0 ? void 0 : _p.writeCapacityUnits,
320
+ },
321
+ },
322
+ },
323
+ ],
324
+ };
325
+ }
326
+ return undefined;
327
+ };
328
+ exports.getNextGSIUpdate = getNextGSIUpdate;
329
+ const getStreamUpdate = async (currentState, endState) => {
330
+ var _a, _b, _c, _d, _e, _f;
331
+ let streamUpdate;
332
+ if (((_a = endState.streamSpecification) === null || _a === void 0 ? void 0 : _a.streamViewType) !== undefined &&
333
+ (currentState.StreamSpecification === undefined || currentState.StreamSpecification.StreamEnabled === false)) {
334
+ streamUpdate = { StreamEnabled: true, StreamViewType: endState.streamSpecification.streamViewType };
335
+ }
336
+ else if (((_b = endState.streamSpecification) === null || _b === void 0 ? void 0 : _b.streamViewType) === undefined && ((_c = currentState.StreamSpecification) === null || _c === void 0 ? void 0 : _c.StreamEnabled) === true) {
337
+ streamUpdate = { StreamEnabled: false };
338
+ }
339
+ else if (((_d = currentState.StreamSpecification) === null || _d === void 0 ? void 0 : _d.StreamEnabled) === true &&
340
+ ((_e = endState.streamSpecification) === null || _e === void 0 ? void 0 : _e.streamViewType) !== undefined &&
341
+ currentState.StreamSpecification.StreamViewType !== ((_f = endState.streamSpecification) === null || _f === void 0 ? void 0 : _f.streamViewType)) {
342
+ console.log('Detect stream view type is changed. Disabling stream before the type change.');
343
+ await ddbClient.updateTable({
344
+ TableName: currentState.TableName,
345
+ StreamSpecification: { StreamEnabled: false },
346
+ });
347
+ await retry(async () => await isTableReady(currentState.TableName), (res) => res === true);
348
+ streamUpdate = { StreamEnabled: true, StreamViewType: endState.streamSpecification.streamViewType };
349
+ }
350
+ if (streamUpdate) {
351
+ return {
352
+ TableName: currentState.TableName,
353
+ StreamSpecification: streamUpdate,
354
+ };
355
+ }
356
+ return undefined;
357
+ };
358
+ exports.getStreamUpdate = getStreamUpdate;
359
+ const getSseUpdate = (currentState, endState) => {
360
+ var _a, _b, _c;
361
+ let sseUpdate;
362
+ if (currentState.SSEDescription) {
363
+ if (!((_a = endState.sseSpecification) === null || _a === void 0 ? void 0 : _a.sseEnabled)) {
364
+ sseUpdate = {
365
+ Enabled: false,
366
+ };
367
+ }
368
+ else if (((_b = endState.sseSpecification) === null || _b === void 0 ? void 0 : _b.sseEnabled) === true &&
369
+ endState.sseSpecification.sseType !== undefined &&
370
+ endState.sseSpecification.sseType !== currentState.SSEDescription.SSEType) {
371
+ sseUpdate = {
372
+ Enabled: true,
373
+ SSEType: endState.sseSpecification.sseType,
374
+ KMSMasterKeyId: endState.sseSpecification.kmsMasterKeyId,
375
+ };
376
+ }
377
+ }
378
+ else {
379
+ if ((_c = endState.sseSpecification) === null || _c === void 0 ? void 0 : _c.sseEnabled) {
380
+ sseUpdate = {
381
+ Enabled: true,
382
+ SSEType: endState.sseSpecification.sseType,
383
+ KMSMasterKeyId: endState.sseSpecification.kmsMasterKeyId,
384
+ };
385
+ }
386
+ }
387
+ if (sseUpdate) {
388
+ return parsePropertiesToDynamoDBInput({
389
+ TableName: currentState.TableName,
390
+ SSESpecification: sseUpdate,
391
+ });
392
+ }
393
+ return undefined;
394
+ };
395
+ exports.getSseUpdate = getSseUpdate;
396
+ const getDeletionProtectionUpdate = (currentState, endState) => {
397
+ if (endState.deletionProtectionEnabled !== undefined && currentState.DeletionProtectionEnabled !== endState.deletionProtectionEnabled) {
398
+ return {
399
+ TableName: currentState.TableName,
400
+ DeletionProtectionEnabled: endState.deletionProtectionEnabled,
401
+ };
402
+ }
403
+ else if (endState.deletionProtectionEnabled === undefined && currentState.DeletionProtectionEnabled === true) {
404
+ return {
405
+ TableName: currentState.TableName,
406
+ DeletionProtectionEnabled: false,
407
+ };
408
+ }
409
+ return undefined;
410
+ };
411
+ exports.getDeletionProtectionUpdate = getDeletionProtectionUpdate;
412
+ const getTtlUpdate = (currentTTL, endState) => {
413
+ const endTTL = endState.timeToLiveSpecification;
414
+ if (currentTTL && currentTTL.TimeToLiveStatus) {
415
+ if (currentTTL.TimeToLiveStatus === 'ENABLED' && currentTTL.AttributeName) {
416
+ if (!endTTL || !endTTL.enabled) {
417
+ return {
418
+ TableName: endState.tableName,
419
+ TimeToLiveSpecification: {
420
+ Enabled: false,
421
+ AttributeName: currentTTL.AttributeName,
422
+ },
423
+ };
424
+ }
425
+ else if (currentTTL.AttributeName !== endTTL.attributeName) {
426
+ return {
427
+ TableName: endState.tableName,
428
+ TimeToLiveSpecification: {
429
+ Enabled: true,
430
+ AttributeName: endTTL.attributeName,
431
+ },
432
+ };
433
+ }
434
+ }
435
+ else if (currentTTL.TimeToLiveStatus === 'DISABLED' && endTTL && endTTL.enabled) {
436
+ return {
437
+ TableName: endState.tableName,
438
+ TimeToLiveSpecification: {
439
+ Enabled: true,
440
+ AttributeName: endTTL.attributeName,
441
+ },
442
+ };
443
+ }
444
+ }
445
+ return undefined;
446
+ };
447
+ exports.getTtlUpdate = getTtlUpdate;
448
+ const getPointInTimeRecoveryUpdate = (currentPointInTime, endState) => {
449
+ var _a, _b;
450
+ if (!currentPointInTime) {
451
+ return undefined;
452
+ }
453
+ const currentStatus = (_a = currentPointInTime.PointInTimeRecoveryDescription) === null || _a === void 0 ? void 0 : _a.PointInTimeRecoveryStatus;
454
+ const endStatus = (_b = endState.pointInTimeRecoverySpecification) === null || _b === void 0 ? void 0 : _b.pointInTimeRecoveryEnabled;
455
+ if (endStatus === undefined || endStatus === false) {
456
+ if (currentStatus === 'ENABLED') {
457
+ return {
458
+ TableName: endState.tableName,
459
+ PointInTimeRecoverySpecification: {
460
+ PointInTimeRecoveryEnabled: false,
461
+ },
462
+ };
463
+ }
464
+ }
465
+ else {
466
+ if (currentStatus === 'DISABLED') {
467
+ return {
468
+ TableName: endState.tableName,
469
+ PointInTimeRecoverySpecification: {
470
+ PointInTimeRecoveryEnabled: true,
471
+ },
472
+ };
473
+ }
474
+ }
475
+ return undefined;
476
+ };
477
+ exports.getPointInTimeRecoveryUpdate = getPointInTimeRecoveryUpdate;
478
+ const extractTableInputFromEvent = (event) => {
479
+ const resourceProperties = { ...event.ResourceProperties };
480
+ delete resourceProperties.ServiceToken;
481
+ const tableDef = convertStringToBooleanOrNumber(resourceProperties);
482
+ return tableDef;
483
+ };
484
+ exports.extractTableInputFromEvent = extractTableInputFromEvent;
485
+ const parsePropertiesToDynamoDBInput = (obj) => {
486
+ return usePascalCaseForObjectKeys(removeUndefinedAttributes(obj));
487
+ };
488
+ const usePascalCaseForObjectKeys = (obj) => {
489
+ const result = {};
490
+ for (const key in obj) {
491
+ if (obj.hasOwnProperty(key) && key !== '') {
492
+ const capitalizedKey = key.charAt(0).toUpperCase() + key.slice(1);
493
+ const value = obj[key];
494
+ if (Array.isArray(value)) {
495
+ result[capitalizedKey] = value.map((v) => usePascalCaseForObjectKeys(v));
496
+ }
497
+ else if (typeof value === 'object' && value !== null) {
498
+ result[capitalizedKey] = usePascalCaseForObjectKeys(value);
499
+ }
500
+ else {
501
+ result[capitalizedKey] = value;
502
+ }
503
+ }
504
+ }
505
+ return result;
506
+ };
507
+ const convertStringToBooleanOrNumber = (obj) => {
508
+ const fieldsToBeConvertedToBoolean = ['deletionProtectionEnabled', 'enabled', 'sseEnabled', 'pointInTimeRecoveryEnabled'];
509
+ const fieldsToBeConvertedToNumber = ['readCapacityUnits', 'writeCapacityUnits'];
510
+ for (const key in obj) {
511
+ if (Array.isArray(obj[key])) {
512
+ obj[key] = obj[key].map((o) => convertStringToBooleanOrNumber(o));
513
+ }
514
+ else if (typeof obj[key] === 'object') {
515
+ obj[key] = convertStringToBooleanOrNumber(obj[key]);
516
+ }
517
+ else if (typeof obj[key] === 'string') {
518
+ if ((obj[key] === 'true' || obj[key] === 'false') && fieldsToBeConvertedToBoolean.includes(key)) {
519
+ obj[key] = obj[key] === 'true';
520
+ }
521
+ else if (!isNaN(Number(obj[key])) && fieldsToBeConvertedToNumber.includes(key)) {
522
+ obj[key] = Number(obj[key]);
523
+ }
524
+ }
525
+ }
526
+ return obj;
527
+ };
528
+ const removeUndefinedAttributes = (obj) => {
529
+ for (const key in obj) {
530
+ if (Array.isArray(obj[key])) {
531
+ obj[key].map((o) => removeUndefinedAttributes(o));
532
+ }
533
+ else if (typeof obj[key] === 'object') {
534
+ removeUndefinedAttributes(obj[key]);
535
+ }
536
+ else if (obj[key] === undefined) {
537
+ delete obj[key];
538
+ }
539
+ }
540
+ return obj;
541
+ };
542
+ const toCreateTableInput = (props) => {
543
+ const createTableInput = {
544
+ TableName: props.tableName,
545
+ AttributeDefinitions: props.attributeDefinitions,
546
+ KeySchema: props.keySchema,
547
+ GlobalSecondaryIndexes: props.globalSecondaryIndexes,
548
+ BillingMode: props.billingMode,
549
+ StreamSpecification: props.streamSpecification
550
+ ? {
551
+ StreamEnabled: true,
552
+ StreamViewType: props.streamSpecification.streamViewType,
553
+ }
554
+ : undefined,
555
+ ProvisionedThroughput: props.provisionedThroughput,
556
+ SSESpecification: props.sseSpecification ? { Enabled: props.sseSpecification.sseEnabled } : undefined,
557
+ };
558
+ return parsePropertiesToDynamoDBInput(createTableInput);
559
+ };
560
+ exports.toCreateTableInput = toCreateTableInput;
561
+ const createNewTable = async (input) => {
562
+ var _a;
563
+ const tableName = input.TableName;
564
+ const createTableInput = input;
565
+ const result = await ddbClient.createTable(createTableInput);
566
+ return { tableName: tableName, tableArn: result.TableDescription.TableArn, streamArn: (_a = result.TableDescription) === null || _a === void 0 ? void 0 : _a.LatestStreamArn };
567
+ };
568
+ const doesTableExist = async (tableName) => {
569
+ try {
570
+ await ddbClient.describeTable({ TableName: tableName });
571
+ return true;
572
+ }
573
+ catch (error) {
574
+ if (error.code === 'ResourceNotFoundException') {
575
+ return false;
576
+ }
577
+ throw error;
578
+ }
579
+ };
580
+ const isTableReady = async (tableName) => {
581
+ var _a, _b;
582
+ const result = await ddbClient.describeTable({ TableName: tableName });
583
+ if (((_a = result.Table) === null || _a === void 0 ? void 0 : _a.TableStatus) !== 'ACTIVE') {
584
+ console.log('Table not active yet');
585
+ return false;
586
+ }
587
+ if ((_b = result.Table.GlobalSecondaryIndexes) === null || _b === void 0 ? void 0 : _b.some((gsi) => gsi.IndexStatus !== 'ACTIVE' || gsi.Backfilling)) {
588
+ console.log('Some GSI is not active yet');
589
+ return false;
590
+ }
591
+ return true;
592
+ };
593
+ const isProjectionModified = (currentProjection, endProjection) => {
594
+ if (currentProjection.ProjectionType !== endProjection.projectionType)
595
+ return true;
596
+ if (currentProjection.ProjectionType === 'ALL')
597
+ return false;
598
+ const currentNonKeyAttributes = currentProjection.NonKeyAttributes || [];
599
+ const endNonKeyAttributes = endProjection.nonKeyAttributes || [];
600
+ if (currentNonKeyAttributes.length !== endNonKeyAttributes.length)
601
+ return true;
602
+ if (currentNonKeyAttributes.some((currentNonKeyAttribute) => !endNonKeyAttributes.includes(currentNonKeyAttribute)))
603
+ return true;
604
+ return false;
605
+ };
606
+ const isKeySchemaModified = (currentSchema, endSchema) => {
607
+ const currentHashKey = currentSchema.find((schema) => schema.KeyType === 'HASH');
608
+ const endHashKey = endSchema.find((schema) => schema.keyType === 'HASH');
609
+ if ((currentHashKey === null || currentHashKey === void 0 ? void 0 : currentHashKey.AttributeName) !== (endHashKey === null || endHashKey === void 0 ? void 0 : endHashKey.attributeName))
610
+ return true;
611
+ const currentSortKey = currentSchema.find((schema) => schema.KeyType === 'RANGE');
612
+ const endSortKey = endSchema.find((schema) => schema.keyType === 'RANGE');
613
+ if (currentSortKey === undefined && endSortKey === undefined)
614
+ return false;
615
+ if ((currentSortKey === undefined && endSortKey !== undefined) || (currentSortKey !== undefined && endSortKey === undefined))
616
+ return true;
617
+ if ((currentSortKey === null || currentSortKey === void 0 ? void 0 : currentSortKey.AttributeName) !== (endSortKey === null || endSortKey === void 0 ? void 0 : endSortKey.attributeName))
618
+ return true;
619
+ return false;
620
+ };
621
+ const defaultSettings = {
622
+ times: Infinity,
623
+ delayMS: 1000 * 15,
624
+ timeoutMS: 1000 * 60 * 14,
625
+ stopOnError: false,
626
+ };
627
+ const retry = async (func, successPredicate, settings, failurePredicate) => {
628
+ const { times, delayMS, timeoutMS, stopOnError } = {
629
+ ...defaultSettings,
630
+ ...settings,
631
+ };
632
+ let count = 0;
633
+ let result;
634
+ let terminate = false;
635
+ const startTime = Date.now();
636
+ do {
637
+ try {
638
+ result = await func();
639
+ if (successPredicate(result)) {
640
+ return result;
641
+ }
642
+ if (typeof failurePredicate === 'function' && failurePredicate(result)) {
643
+ throw new Error('Retry-able function execution result matched failure predicate. Stopping retries.');
644
+ }
645
+ console.warn(`Retry-able function execution did not match success predicate. Result was [${JSON.stringify(result)}]. Retrying...`);
646
+ }
647
+ catch (err) {
648
+ console.warn(`Retry-able function execution failed with [${err.message || err}]`);
649
+ if (stopOnError) {
650
+ console.log('Stopping retries on error.');
651
+ }
652
+ else {
653
+ console.log('Retrying...');
654
+ }
655
+ terminate = stopOnError;
656
+ }
657
+ count++;
658
+ await sleep(delayMS);
659
+ } while (!terminate && count <= times && Date.now() - startTime < timeoutMS);
660
+ throw new Error('Retry-able function did not match predicate within the given retry constraints');
661
+ };
662
+ const sleep = async (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
663
+ //# sourceMappingURL=amplify-table-manager-handler.js.map