@reventlessdev/reventless-aws 3.0.0-alpha.167

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 (394) hide show
  1. package/CHANGELOG.md +1564 -0
  2. package/README.md +62 -0
  3. package/__mocks__/emptyModule.js +1 -0
  4. package/all-licenses.csv +565 -0
  5. package/docker-compose.dynamodb-local.yml +12 -0
  6. package/jest.setup.cjs +5 -0
  7. package/licenses-analysis.ods +0 -0
  8. package/package.json +73 -0
  9. package/rescript.json +39 -0
  10. package/reventless-licenses-analysis.xls +0 -0
  11. package/scripts/run-integration-tests.sh +43 -0
  12. package/src/Platform.res +1940 -0
  13. package/src/Platform.res.mjs +2281 -0
  14. package/src/Platform_Casts.res +106 -0
  15. package/src/Platform_Casts.res.mjs +13 -0
  16. package/src/Platform_Stack.res +153 -0
  17. package/src/Platform_Stack.res.mjs +121 -0
  18. package/src/Types.res +39 -0
  19. package/src/Types.res.mjs +21 -0
  20. package/src/adapter/AWS.res +96 -0
  21. package/src/adapter/AWS.res.mjs +186 -0
  22. package/src/adapter/AWS_Tags.res +16 -0
  23. package/src/adapter/AWS_Tags.res.mjs +48 -0
  24. package/src/adapter/Adapter_Helpers.res +19 -0
  25. package/src/adapter/Adapter_Helpers.res.mjs +37 -0
  26. package/src/adapter/Api/AppSync_EventsApi.res +172 -0
  27. package/src/adapter/Api/AppSync_EventsApi.res.mjs +96 -0
  28. package/src/adapter/Api/AppSync_Resolver_Native.res +93 -0
  29. package/src/adapter/Api/AppSync_Resolver_Native.res.mjs +67 -0
  30. package/src/adapter/Api/AppSync_Resolver_Retrying.res +653 -0
  31. package/src/adapter/Api/AppSync_Resolver_Retrying.res.mjs +462 -0
  32. package/src/adapter/Api/CommandSubscriptionResolvers_AppSync.res +29 -0
  33. package/src/adapter/Api/CommandSubscriptionResolvers_AppSync.res.mjs +15 -0
  34. package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res +238 -0
  35. package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res.mjs +179 -0
  36. package/src/adapter/Api/Platform_UIFragments_Lambda.res +229 -0
  37. package/src/adapter/Api/Platform_UIFragments_Lambda.res.mjs +245 -0
  38. package/src/adapter/Auth/Auth_Cognito.res +209 -0
  39. package/src/adapter/Auth/Auth_Cognito.res.mjs +135 -0
  40. package/src/adapter/CommandGenerator/CommandGeneratorResolvers.res +2 -0
  41. package/src/adapter/CommandGenerator/CommandGeneratorResolvers.res.mjs +12 -0
  42. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync.res +251 -0
  43. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync.res.mjs +126 -0
  44. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync_NoOp.res +20 -0
  45. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync_NoOp.res.mjs +23 -0
  46. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync_Runtime.res +1 -0
  47. package/src/adapter/CommandGenerator/CommandGeneratorResolvers_AppSync_Runtime.res.mjs +11 -0
  48. package/src/adapter/CommandGenerator/InboundTranslationResolvers_AppSync.res +95 -0
  49. package/src/adapter/CommandGenerator/InboundTranslationResolvers_AppSync.res.mjs +50 -0
  50. package/src/adapter/CommandTopic/CommandTopicChannel.res +6 -0
  51. package/src/adapter/CommandTopic/CommandTopicChannel.res.mjs +21 -0
  52. package/src/adapter/CommandTopic/CommandTopicChannel_Helpers.res +196 -0
  53. package/src/adapter/CommandTopic/CommandTopicChannel_Helpers.res.mjs +145 -0
  54. package/src/adapter/CommandTopic/CommandTopicChannel_SQS.res +91 -0
  55. package/src/adapter/CommandTopic/CommandTopicChannel_SQS.res.mjs +74 -0
  56. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Async.res +69 -0
  57. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Async.res.mjs +62 -0
  58. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_FIFO.res +60 -0
  59. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_FIFO.res.mjs +56 -0
  60. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res +73 -0
  61. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res.mjs +65 -0
  62. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Sync.res +88 -0
  63. package/src/adapter/CommandTopic/CommandTopicChannel_SQS_Sync.res.mjs +76 -0
  64. package/src/adapter/CommandTopic/CommandTopicRemoteChannel.res +1 -0
  65. package/src/adapter/CommandTopic/CommandTopicRemoteChannel.res.mjs +9 -0
  66. package/src/adapter/CommandTopic/CommandTopicRemoteChannel_SQS.res +7 -0
  67. package/src/adapter/CommandTopic/CommandTopicRemoteChannel_SQS.res.mjs +17 -0
  68. package/src/adapter/Counter/CounterHandler_DynamoDbStream.res +103 -0
  69. package/src/adapter/Counter/CounterHandler_DynamoDbStream.res.mjs +68 -0
  70. package/src/adapter/Counter/CounterHandler_DynamoDbStream_Runtime.res +107 -0
  71. package/src/adapter/Counter/CounterHandler_DynamoDbStream_Runtime.res.mjs +145 -0
  72. package/src/adapter/DcbEventLog/DcbEventLogStorage.res +1 -0
  73. package/src/adapter/DcbEventLog/DcbEventLogStorage.res.mjs +9 -0
  74. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb.res +84 -0
  75. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb.res.mjs +52 -0
  76. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb_Runtime.res +1436 -0
  77. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb_Runtime.res.mjs +1143 -0
  78. package/src/adapter/EventCollector/EventCollectorChannel.res +6 -0
  79. package/src/adapter/EventCollector/EventCollectorChannel.res.mjs +21 -0
  80. package/src/adapter/EventCollector/EventCollectorChannel_DynamoDbStream.res +63 -0
  81. package/src/adapter/EventCollector/EventCollectorChannel_DynamoDbStream.res.mjs +56 -0
  82. package/src/adapter/EventCollector/EventCollectorChannel_DynamoDbStream_Runtime.res +20 -0
  83. package/src/adapter/EventCollector/EventCollectorChannel_DynamoDbStream_Runtime.res.mjs +32 -0
  84. package/src/adapter/EventCollector/EventCollectorChannel_Helpers.res +266 -0
  85. package/src/adapter/EventCollector/EventCollectorChannel_Helpers.res.mjs +166 -0
  86. package/src/adapter/EventCollector/EventCollectorChannel_SQS.res +81 -0
  87. package/src/adapter/EventCollector/EventCollectorChannel_SQS.res.mjs +54 -0
  88. package/src/adapter/EventCollector/EventCollectorChannel_SQS_FIFO.res +59 -0
  89. package/src/adapter/EventCollector/EventCollectorChannel_SQS_FIFO.res.mjs +45 -0
  90. package/src/adapter/EventCollector/EventCollectorChannel_SQS_Runtime.res +91 -0
  91. package/src/adapter/EventCollector/EventCollectorChannel_SQS_Runtime.res.mjs +89 -0
  92. package/src/adapter/EventLog/EventLogStorage.res +3 -0
  93. package/src/adapter/EventLog/EventLogStorage.res.mjs +15 -0
  94. package/src/adapter/EventLog/EventLogStorage_DynamoDb.res +25 -0
  95. package/src/adapter/EventLog/EventLogStorage_DynamoDb.res.mjs +34 -0
  96. package/src/adapter/EventLog/EventLogStorage_DynamoDbStream.res +26 -0
  97. package/src/adapter/EventLog/EventLogStorage_DynamoDbStream.res.mjs +35 -0
  98. package/src/adapter/EventLog/EventLogStorage_DynamoDb_Runtime.res +121 -0
  99. package/src/adapter/EventLog/EventLogStorage_DynamoDb_Runtime.res.mjs +137 -0
  100. package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res +265 -0
  101. package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res.mjs +185 -0
  102. package/src/adapter/EventTopic/EventTopicPublisher.res +6 -0
  103. package/src/adapter/EventTopic/EventTopicPublisher.res.mjs +21 -0
  104. package/src/adapter/EventTopic/EventTopicPublisher_DynamoDbStream.res +25 -0
  105. package/src/adapter/EventTopic/EventTopicPublisher_DynamoDbStream.res.mjs +28 -0
  106. package/src/adapter/EventTopic/EventTopicPublisher_SNS.res +40 -0
  107. package/src/adapter/EventTopic/EventTopicPublisher_SNS.res.mjs +39 -0
  108. package/src/adapter/EventTopic/EventTopicPublisher_SNS_FIFO.res +39 -0
  109. package/src/adapter/EventTopic/EventTopicPublisher_SNS_FIFO.res.mjs +38 -0
  110. package/src/adapter/EventTopic/EventTopicPublisher_SNS_Runtime.res +5 -0
  111. package/src/adapter/EventTopic/EventTopicPublisher_SNS_Runtime.res.mjs +18 -0
  112. package/src/adapter/Mcp/MCP_Lambda.res +502 -0
  113. package/src/adapter/Mcp/MCP_Lambda.res.mjs +289 -0
  114. package/src/adapter/QueryDb/NodeResolver_AppSync.res +71 -0
  115. package/src/adapter/QueryDb/NodeResolver_AppSync.res.mjs +44 -0
  116. package/src/adapter/QueryDb/QueryDbResolvers.res +2 -0
  117. package/src/adapter/QueryDb/QueryDbResolvers.res.mjs +12 -0
  118. package/src/adapter/QueryDb/QueryDbResolvers_AppSync.res +434 -0
  119. package/src/adapter/QueryDb/QueryDbResolvers_AppSync.res.mjs +243 -0
  120. package/src/adapter/QueryDb/QueryDbResolvers_AppSync_NoOp.res +21 -0
  121. package/src/adapter/QueryDb/QueryDbResolvers_AppSync_NoOp.res.mjs +14 -0
  122. package/src/adapter/QueryDb/QueryDbResolvers_NoOp.res +21 -0
  123. package/src/adapter/QueryDb/QueryDbResolvers_NoOp.res.mjs +14 -0
  124. package/src/adapter/QueryDb/QueryDbStorage.res +5 -0
  125. package/src/adapter/QueryDb/QueryDbStorage.res.mjs +18 -0
  126. package/src/adapter/QueryDb/QueryDbStorage_DynamoDb.res +115 -0
  127. package/src/adapter/QueryDb/QueryDbStorage_DynamoDb.res.mjs +100 -0
  128. package/src/adapter/QueryDb/QueryDbStorage_DynamoDbStream.res +52 -0
  129. package/src/adapter/QueryDb/QueryDbStorage_DynamoDbStream.res.mjs +38 -0
  130. package/src/adapter/QueryDb/QueryDbStorage_DynamoDb_Runtime.res +271 -0
  131. package/src/adapter/QueryDb/QueryDbStorage_DynamoDb_Runtime.res.mjs +306 -0
  132. package/src/adapter/QueryDb/QueryInterceptor_Lambda.res +20 -0
  133. package/src/adapter/QueryDb/QueryInterceptor_Lambda.res.mjs +22 -0
  134. package/src/adapter/QueryEngine/QueryEngine.res +3 -0
  135. package/src/adapter/QueryEngine/QueryEngine.res.mjs +12 -0
  136. package/src/adapter/QueryEngine/QueryEngine_DynamoDb.res +184 -0
  137. package/src/adapter/QueryEngine/QueryEngine_DynamoDb.res.mjs +221 -0
  138. package/src/adapter/Runtime/AdminEventCollectorEntryPoint.mjs +879 -0
  139. package/src/adapter/Runtime/AggregateEntryPoint.mjs +313 -0
  140. package/src/adapter/Runtime/AggregateRuntime_Builder_Micro.res +327 -0
  141. package/src/adapter/Runtime/AggregateRuntime_Builder_Micro.res.mjs +239 -0
  142. package/src/adapter/Runtime/AggregateRuntime_Builder_Micro_Async.res +331 -0
  143. package/src/adapter/Runtime/AggregateRuntime_Builder_Micro_Async.res.mjs +240 -0
  144. package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate.res +247 -0
  145. package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate.res.mjs +185 -0
  146. package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate_Async.res +244 -0
  147. package/src/adapter/Runtime/AggregateRuntime_Builder_PerAggregate_Async.res.mjs +185 -0
  148. package/src/adapter/Runtime/AggregateRuntime_Builder_Single.res +347 -0
  149. package/src/adapter/Runtime/AggregateRuntime_Builder_Single.res.mjs +244 -0
  150. package/src/adapter/Runtime/AggregateRuntime_Builder_Single_Async.res +285 -0
  151. package/src/adapter/Runtime/AggregateRuntime_Builder_Single_Async.res.mjs +212 -0
  152. package/src/adapter/Runtime/AutomationSliceEntryPoint.mjs +124 -0
  153. package/src/adapter/Runtime/AutomationSliceRuntime_Builder_Single.res +187 -0
  154. package/src/adapter/Runtime/AutomationSliceRuntime_Builder_Single.res.mjs +147 -0
  155. package/src/adapter/Runtime/CounterEntryPoint.mjs +91 -0
  156. package/src/adapter/Runtime/DcbCommandTopicEntryPoint.mjs +265 -0
  157. package/src/adapter/Runtime/EventCollectorRuntime_Builder_PerEventCollector.res +122 -0
  158. package/src/adapter/Runtime/EventCollectorRuntime_Builder_PerEventCollector.res.mjs +89 -0
  159. package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res +193 -0
  160. package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res.mjs +137 -0
  161. package/src/adapter/Runtime/EventMapperEntryPoint.mjs +97 -0
  162. package/src/adapter/Runtime/ExtensionPointEntryPoint.mjs +101 -0
  163. package/src/adapter/Runtime/ExtensionPointRuntime_Builder_PerExtensionPoint.res +83 -0
  164. package/src/adapter/Runtime/ExtensionPointRuntime_Builder_PerExtensionPoint.res.mjs +59 -0
  165. package/src/adapter/Runtime/HandlerFactoryHelpers.mjs +142 -0
  166. package/src/adapter/Runtime/HeartbeatEntryPoint.mjs +38 -0
  167. package/src/adapter/Runtime/PluginExtensionPointEntryPoint.mjs +137 -0
  168. package/src/adapter/Runtime/ReadModelEntryPoint.mjs +143 -0
  169. package/src/adapter/Runtime/RuntimeEnvironment.res +1 -0
  170. package/src/adapter/Runtime/RuntimeEnvironment.res.mjs +9 -0
  171. package/src/adapter/Runtime/RuntimeEnvironment_Lambda.res +254 -0
  172. package/src/adapter/Runtime/RuntimeEnvironment_Lambda.res.mjs +169 -0
  173. package/src/adapter/Runtime/SideEffectEntryPoint.mjs +81 -0
  174. package/src/adapter/Runtime/SideEffectHandlerRuntime_Builder_Single.res +178 -0
  175. package/src/adapter/Runtime/SideEffectHandlerRuntime_Builder_Single.res.mjs +129 -0
  176. package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res +166 -0
  177. package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res.mjs +87 -0
  178. package/src/adapter/Runtime/StateViewSliceEntryPoint.mjs +136 -0
  179. package/src/adapter/Runtime/StateViewSliceRuntime_Builder_Single.res +344 -0
  180. package/src/adapter/Runtime/StateViewSliceRuntime_Builder_Single.res.mjs +242 -0
  181. package/src/adapter/Runtime/TaskBucketEntryPoint.mjs +150 -0
  182. package/src/adapter/Runtime/TaskRuntime_Builder_PerBucket.res +123 -0
  183. package/src/adapter/Runtime/TaskRuntime_Builder_PerBucket.res.mjs +74 -0
  184. package/src/adapter/ScheduledPublisher/ScheduledPublisher.res +2 -0
  185. package/src/adapter/ScheduledPublisher/ScheduledPublisher.res.mjs +12 -0
  186. package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents.res +54 -0
  187. package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents.res.mjs +41 -0
  188. package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents_Runtime.res +97 -0
  189. package/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents_Runtime.res.mjs +85 -0
  190. package/src/adapter/StateTopic/StateTopic_AppSync.res +418 -0
  191. package/src/adapter/StateTopic/StateTopic_AppSync.res.mjs +295 -0
  192. package/src/adapter/Task/TaskBucket.res +1 -0
  193. package/src/adapter/Task/TaskBucket.res.mjs +9 -0
  194. package/src/adapter/Task/TaskBucket_S3.res +157 -0
  195. package/src/adapter/Task/TaskBucket_S3.res.mjs +108 -0
  196. package/src/adapter/Task/TaskBucket_S3_Runtime.res +11 -0
  197. package/src/adapter/Task/TaskBucket_S3_Runtime.res.mjs +15 -0
  198. package/src/components/Aggregate_Builder.res +1 -0
  199. package/src/components/Aggregate_Builder.res.mjs +25 -0
  200. package/src/components/Aggregate_Builder_Micro.res +63 -0
  201. package/src/components/Aggregate_Builder_Micro.res.mjs +80 -0
  202. package/src/components/Aggregate_Builder_NoResolver.res +61 -0
  203. package/src/components/Aggregate_Builder_NoResolver.res.mjs +80 -0
  204. package/src/components/Aggregate_Builder_PerAggregate.res +57 -0
  205. package/src/components/Aggregate_Builder_PerAggregate.res.mjs +80 -0
  206. package/src/components/Aggregate_Builder_Single.res +59 -0
  207. package/src/components/Aggregate_Builder_Single.res.mjs +80 -0
  208. package/src/components/Aggregate_Builder_Single_Async.res +59 -0
  209. package/src/components/Aggregate_Builder_Single_Async.res.mjs +80 -0
  210. package/src/components/Api/AppSync_Adapter.res +500 -0
  211. package/src/components/Api/AppSync_Adapter.res.mjs +396 -0
  212. package/src/components/AutomationSlice_Builder.res +52 -0
  213. package/src/components/AutomationSlice_Builder.res.mjs +72 -0
  214. package/src/components/AutomationSlice_Builder_Bundled.res.mjs +70 -0
  215. package/src/components/Counter_Builder.res +10 -0
  216. package/src/components/Counter_Builder.res.mjs +16 -0
  217. package/src/components/DataCleaner.res +170 -0
  218. package/src/components/DataCleaner.res.mjs +2 -0
  219. package/src/components/DcbEventLog_Builder.res +8 -0
  220. package/src/components/DcbEventLog_Builder.res.mjs +14 -0
  221. package/src/components/ExtensionPoint_Builder.res +16 -0
  222. package/src/components/ExtensionPoint_Builder.res.mjs +37 -0
  223. package/src/components/ForeignReadModel_Builder.res +19 -0
  224. package/src/components/ForeignReadModel_Builder.res.mjs +48 -0
  225. package/src/components/InboundTranslationSlice_Builder.res +25 -0
  226. package/src/components/InboundTranslationSlice_Builder.res.mjs +31 -0
  227. package/src/components/OutboundTranslationSlice_Builder.res +60 -0
  228. package/src/components/OutboundTranslationSlice_Builder.res.mjs +76 -0
  229. package/src/components/OutboundTranslationSlice_Builder_Bundled.res.mjs +75 -0
  230. package/src/components/Plugin.res +29 -0
  231. package/src/components/Plugin.res.mjs +63 -0
  232. package/src/components/ReadModel_Builder.res +1 -0
  233. package/src/components/ReadModel_Builder.res.mjs +19 -0
  234. package/src/components/ReadModel_Builder_NoResolver.res +55 -0
  235. package/src/components/ReadModel_Builder_NoResolver.res.mjs +64 -0
  236. package/src/components/ReadModel_Builder_NoResolver_Stream.res +60 -0
  237. package/src/components/ReadModel_Builder_NoResolver_Stream.res.mjs +64 -0
  238. package/src/components/ReadModel_Builder_PerReadModel.res +53 -0
  239. package/src/components/ReadModel_Builder_PerReadModel.res.mjs +66 -0
  240. package/src/components/ReadModel_Builder_Single.res +52 -0
  241. package/src/components/ReadModel_Builder_Single.res.mjs +66 -0
  242. package/src/components/ReadModel_Builder_Single_Stream.res +60 -0
  243. package/src/components/ReadModel_Builder_Single_Stream.res.mjs +66 -0
  244. package/src/components/Scheduler.res +1 -0
  245. package/src/components/Scheduler.res.mjs +13 -0
  246. package/src/components/SideEffectHandler.res +1 -0
  247. package/src/components/SideEffectHandler.res.mjs +19 -0
  248. package/src/components/SideEffectHandler_PerSideEffectHandler.res +13 -0
  249. package/src/components/SideEffectHandler_PerSideEffectHandler.res.mjs +52 -0
  250. package/src/components/SideEffectHandler_Single.res +54 -0
  251. package/src/components/SideEffectHandler_Single.res.mjs +60 -0
  252. package/src/components/StateChangeSlice_Builder.res +17 -0
  253. package/src/components/StateChangeSlice_Builder.res.mjs +23 -0
  254. package/src/components/StateViewSlice_Builder.res +46 -0
  255. package/src/components/StateViewSlice_Builder.res.mjs +68 -0
  256. package/src/components/StateViewSlice_Builder_Bundled.res.mjs +69 -0
  257. package/src/components/StateViewSlice_Builder_Stream.res +50 -0
  258. package/src/components/StateViewSlice_Builder_Stream.res.mjs +68 -0
  259. package/src/components/Task_Builder.res +1 -0
  260. package/src/components/Task_Builder.res.mjs +28 -0
  261. package/src/components/Task_Builder_PerBucket.res +22 -0
  262. package/src/components/Task_Builder_PerBucket.res.mjs +63 -0
  263. package/src/components/Vpc.res +214 -0
  264. package/src/components/Vpc.res.mjs +117 -0
  265. package/src/components/Vpc.resi +22 -0
  266. package/src/errors/AppSync_Error.res +36 -0
  267. package/src/errors/AppSync_Error.res.mjs +38 -0
  268. package/src/errors/Cognito_Error.res +36 -0
  269. package/src/errors/Cognito_Error.res.mjs +38 -0
  270. package/src/errors/DynamoDb_Error.res +75 -0
  271. package/src/errors/DynamoDb_Error.res.mjs +86 -0
  272. package/src/errors/Kinesis_Error.res +36 -0
  273. package/src/errors/Kinesis_Error.res.mjs +38 -0
  274. package/src/errors/SNS_Error.res +34 -0
  275. package/src/errors/SNS_Error.res.mjs +38 -0
  276. package/src/errors/SQS_Error.res +40 -0
  277. package/src/errors/SQS_Error.res.mjs +41 -0
  278. package/src/plugin/cloner/ClonerRunner.res +1 -0
  279. package/src/plugin/cloner/ClonerRunner.res.mjs +9 -0
  280. package/src/plugin/cloner/ClonerRunner_Fargate.res +362 -0
  281. package/src/plugin/cloner/ClonerRunner_Fargate.res.mjs +246 -0
  282. package/src/plugin/cloner/ClonerRunner_Fargate_Runtime.res +42 -0
  283. package/src/plugin/cloner/ClonerRunner_Fargate_Runtime.res.mjs +45 -0
  284. package/src/plugin/heartbeat/HeartbeatRunner.res +1 -0
  285. package/src/plugin/heartbeat/HeartbeatRunner.res.mjs +9 -0
  286. package/src/plugin/heartbeat/HeartbeatRunner_CloudWatchEvents.res +96 -0
  287. package/src/plugin/heartbeat/HeartbeatRunner_CloudWatchEvents.res.mjs +69 -0
  288. package/src/plugin/runtime/PluginExtensionPointRuntime_Builder.res +115 -0
  289. package/src/plugin/runtime/PluginExtensionPointRuntime_Builder.res.mjs +88 -0
  290. package/src/plugin/runtime/PluginRuntimeOperations.res +5 -0
  291. package/src/plugin/runtime/PluginRuntimeOperations.res.mjs +14 -0
  292. package/src/plugin/runtime/PluginRuntime_Builder.res +769 -0
  293. package/src/plugin/runtime/PluginRuntime_Builder.res.mjs +464 -0
  294. package/src/plugin/runtime/Util_PluginMessage_Runtime.res +13 -0
  295. package/src/plugin/runtime/Util_PluginMessage_Runtime.res.mjs +19 -0
  296. package/src/plugin/stack/Plugin_ExtensionPoint_Builder.res +28 -0
  297. package/src/plugin/stack/Plugin_ExtensionPoint_Builder.res.mjs +67 -0
  298. package/src/plugin/stack/Plugin_Stack.res +439 -0
  299. package/src/plugin/stack/Plugin_Stack.res.mjs +263 -0
  300. package/src/util/Util.res +29 -0
  301. package/src/util/Util.res.mjs +93 -0
  302. package/src/util/Util_AppSync.res +36 -0
  303. package/src/util/Util_AppSync.res.mjs +35 -0
  304. package/src/util/Util_AppSync_Caller.res +213 -0
  305. package/src/util/Util_AppSync_Caller.res.mjs +170 -0
  306. package/src/util/Util_Bundle.res +255 -0
  307. package/src/util/Util_Bundle.res.mjs +179 -0
  308. package/src/util/Util_Cloudwatch.res +14 -0
  309. package/src/util/Util_Cloudwatch.res.mjs +19 -0
  310. package/src/util/Util_CognitoGroupUser.res +39 -0
  311. package/src/util/Util_CognitoGroupUser.res.mjs +32 -0
  312. package/src/util/Util_CognitoGroupUser_Runtime.res +65 -0
  313. package/src/util/Util_CognitoGroupUser_Runtime.res.mjs +50 -0
  314. package/src/util/Util_Cognito_Runtime.res +52 -0
  315. package/src/util/Util_Cognito_Runtime.res.mjs +35 -0
  316. package/src/util/Util_DeadLetterQueue.res +154 -0
  317. package/src/util/Util_DeadLetterQueue.res.mjs +158 -0
  318. package/src/util/Util_DynamoDb.res +210 -0
  319. package/src/util/Util_DynamoDb.res.mjs +218 -0
  320. package/src/util/Util_DynamoDbStream.res +138 -0
  321. package/src/util/Util_DynamoDbStream.res.mjs +134 -0
  322. package/src/util/Util_DynamoDbStream_Runtime.res +94 -0
  323. package/src/util/Util_DynamoDbStream_Runtime.res.mjs +131 -0
  324. package/src/util/Util_DynamoDb_Runtime.res +216 -0
  325. package/src/util/Util_DynamoDb_Runtime.res.mjs +257 -0
  326. package/src/util/Util_DynamoDb_TableManager.res +23 -0
  327. package/src/util/Util_DynamoDb_TableManager.res.mjs +35 -0
  328. package/src/util/Util_DynamoDb_TableManager.resi +3 -0
  329. package/src/util/Util_Env.res +5 -0
  330. package/src/util/Util_Env.res.mjs +2 -0
  331. package/src/util/Util_EventSourceMapping.res +49 -0
  332. package/src/util/Util_EventSourceMapping.res.mjs +32 -0
  333. package/src/util/Util_HostUiDomain.res +28 -0
  334. package/src/util/Util_HostUiDomain.res.mjs +26 -0
  335. package/src/util/Util_IAM_Role.res +14 -0
  336. package/src/util/Util_IAM_Role.res.mjs +28 -0
  337. package/src/util/Util_Kinesis_Runtime.res +20 -0
  338. package/src/util/Util_Kinesis_Runtime.res.mjs +24 -0
  339. package/src/util/Util_Lambda.res +39 -0
  340. package/src/util/Util_Lambda.res.mjs +45 -0
  341. package/src/util/Util_LocalConfig.res +119 -0
  342. package/src/util/Util_LocalConfig.res.mjs +112 -0
  343. package/src/util/Util_ResourceNaming.res +15 -0
  344. package/src/util/Util_ResourceNaming.res.mjs +26 -0
  345. package/src/util/Util_S3.res +17 -0
  346. package/src/util/Util_S3.res.mjs +30 -0
  347. package/src/util/Util_S3_Runtime.res +11 -0
  348. package/src/util/Util_S3_Runtime.res.mjs +15 -0
  349. package/src/util/Util_SNS.res +33 -0
  350. package/src/util/Util_SNS.res.mjs +50 -0
  351. package/src/util/Util_SNS_FIFO.res +21 -0
  352. package/src/util/Util_SNS_FIFO.res.mjs +27 -0
  353. package/src/util/Util_SNS_Runtime.res +33 -0
  354. package/src/util/Util_SNS_Runtime.res.mjs +27 -0
  355. package/src/util/Util_SQS.res +70 -0
  356. package/src/util/Util_SQS.res.mjs +83 -0
  357. package/src/util/Util_SQS_FIFO.res +16 -0
  358. package/src/util/Util_SQS_FIFO.res.mjs +28 -0
  359. package/src/util/Util_SQS_Runtime.res +169 -0
  360. package/src/util/Util_SQS_Runtime.res.mjs +150 -0
  361. package/src/util/Util_SesPolicy_Runtime.res +54 -0
  362. package/src/util/Util_SesPolicy_Runtime.res.mjs +55 -0
  363. package/src/util/Util_StaticBundle.res +124 -0
  364. package/src/util/Util_StaticBundle.res.mjs +132 -0
  365. package/src/util/Util_Vpc.res +22 -0
  366. package/src/util/Util_Vpc.res.mjs +27 -0
  367. package/tests/AppSync_AdapterTest.res +396 -0
  368. package/tests/AppSync_AdapterTest.res.mjs +326 -0
  369. package/tests/AppSync_Resolver_RetryingTest.res +59 -0
  370. package/tests/AppSync_Resolver_RetryingTest.res.mjs +66 -0
  371. package/tests/Auth_CognitoTest.res +203 -0
  372. package/tests/Auth_CognitoTest.res.mjs +248 -0
  373. package/tests/DcbEventLogStorage_DynamoDb_RuntimeTest.res +602 -0
  374. package/tests/DcbEventLogStorage_DynamoDb_RuntimeTest.res.mjs +742 -0
  375. package/tests/EventLogStorage_DynamoDb_RuntimeTest.res +57 -0
  376. package/tests/EventLogStorage_DynamoDb_RuntimeTest.res.mjs +68 -0
  377. package/tests/MCP_LambdaTest.res +101 -0
  378. package/tests/MCP_LambdaTest.res.mjs +56 -0
  379. package/tests/Util_HostUiDomainTest.res +90 -0
  380. package/tests/Util_HostUiDomainTest.res.mjs +50 -0
  381. package/tests/Util_SQS_RuntimeTest.res +46 -0
  382. package/tests/Util_SQS_RuntimeTest.res.mjs +45 -0
  383. package/tests/Util_StaticBundleTest.res +136 -0
  384. package/tests/Util_StaticBundleTest.res.mjs +149 -0
  385. package/tests/integration/DcbCommandTopicEntryPoint_IntegrationTest.res +101 -0
  386. package/tests/integration/DcbCommandTopicEntryPoint_IntegrationTest.res.mjs +91 -0
  387. package/tests/integration/DcbEventLogStorage_DynamoDb_IntegrationTest.res +315 -0
  388. package/tests/integration/DcbEventLogStorage_DynamoDb_IntegrationTest.res.mjs +435 -0
  389. package/tests/integration/DcbIntegrationHarness.res +102 -0
  390. package/tests/integration/DcbIntegrationHarness.res.mjs +163 -0
  391. package/tests/integration/EpTestSlice.res +28 -0
  392. package/tests/integration/EpTestSlice.res.mjs +43 -0
  393. package/tests/integration/EpTestSliceBehavior.res +18 -0
  394. package/tests/integration/EpTestSliceBehavior.res.mjs +35 -0
@@ -0,0 +1,187 @@
1
+ module EventCollectorChannel = EventCollectorChannel.DynamoDbStream
2
+ module RuntimeEnvironment = RuntimeEnvironment.Lambda
3
+
4
+ let log = ReventlessCore.Logger.fromEnv()
5
+
6
+ type context = PulumiAws.Lambda.context
7
+ type runtimeParts = Util.Lambda.runtimeParts
8
+
9
+ type sliceInfo = {
10
+ specModulePath: string,
11
+ callbackType: string,
12
+ queryDbTableName: Pulumi.Output.t<string>,
13
+ }
14
+
15
+ let bundledInfos: dict<sliceInfo> = Dict.make()
16
+
17
+ let dcbQueueUrlRef: ref<option<Pulumi.Output.t<string>>> = ref(None)
18
+ let setDcbQueueUrl = url => dcbQueueUrlRef := Some(url)
19
+
20
+ let registerAutomationSlice = (
21
+ ~name,
22
+ ~specModulePath,
23
+ ~callbackType="automation",
24
+ ~queryDbTableName,
25
+ ) =>
26
+ bundledInfos->Dict.set(name, {specModulePath, callbackType, queryDbTableName})
27
+
28
+ type storedSpec = {
29
+ componentName: string,
30
+ parentResource: Pulumi.Resource.t,
31
+ sourceUrns: Pulumi.Output.t<array<string>>,
32
+ channelSpec: ReventlessCore.EventCollector_Adapter.channelSpec<
33
+ EventCollectorChannel.callbackEvent,
34
+ context,
35
+ EventCollectorChannel.channelParts,
36
+ >,
37
+ memorySize: int,
38
+ timeout: int,
39
+ }
40
+
41
+ let storedSpecs: array<storedSpec> = []
42
+ let grandParent = ref(None)
43
+
44
+ let forEventCollector: ReventlessCore.Runtime.forEventCollector<
45
+ ReventlessCore.Runtime.effectHandler<
46
+ EventCollectorChannel.callbackEvent,
47
+ context,
48
+ unit,
49
+ string,
50
+ >,
51
+ ReventlessCore.EventCollector.component,
52
+ > = (
53
+ ~handler as _,
54
+ ~eventTopics,
55
+ ~resources,
56
+ ~memorySize=1024,
57
+ ~timeout=30,
58
+ eventCollector,
59
+ ) => {
60
+ let eventCollectorResource = eventCollector->ReventlessCore.Component.toPulumiResource
61
+ let channel = eventCollector->ReventlessCore.EventCollector_Adapter.channel
62
+ let eventCollectorName = eventCollectorResource.name->Option.getOr("Unnamed")
63
+
64
+ switch eventCollectorResource.parent {
65
+ | Some(parentResource) =>
66
+ let parentName = parentResource.name->Option.getOr("Unnamed")
67
+ if grandParent.contents == None {
68
+ grandParent := parentResource.parent
69
+ }
70
+
71
+ let sourceUrns =
72
+ (eventCollector->ReventlessCore.Component.outputs).resources
73
+ ->Array.map(({urn}) => urn)
74
+ ->Pulumi.Output.all
75
+
76
+ storedSpecs
77
+ ->Array.push({
78
+ componentName: parentName,
79
+ parentResource,
80
+ sourceUrns,
81
+ channelSpec: {channel, eventTopics, resources},
82
+ memorySize,
83
+ timeout,
84
+ })
85
+ ->ignore
86
+
87
+ log.info(
88
+ ~comp="AutomationSliceRuntime_Builder_Single",
89
+ `registered ${eventCollectorName} for ${parentName}`,
90
+ )
91
+ | None =>
92
+ JsError.throwWithMessage(
93
+ `forEventCollector(single): eventCollector ${eventCollectorName} has no parent`,
94
+ )
95
+ }
96
+ }
97
+
98
+ let finished = ref(false)
99
+
100
+ let finish = () =>
101
+ if !finished.contents {
102
+ if storedSpecs->Array.length > 0 {
103
+ let (maxMemorySize, maxTimeout) = storedSpecs->Array.reduce((0, 0), (
104
+ (accMemorySize, accTimeout),
105
+ {memorySize, timeout},
106
+ ) => {
107
+ (Math.Int.max(accMemorySize, memorySize), Math.Int.max(accTimeout, timeout))
108
+ })
109
+
110
+ switch grandParent.contents {
111
+ | Some(parent) =>
112
+ let opts = {Pulumi.ComponentResource.parent: parent}
113
+
114
+ let handlerOutputs: array<Pulumi.Output.t<string>> = []
115
+ let packageDirs: dict<string> = Dict.make()
116
+
117
+ let dcbQueueUrl = switch dcbQueueUrlRef.contents {
118
+ | Some(url) => url
119
+ | None => Pulumi.Output.make("NOT_AVAILABLE")
120
+ }
121
+
122
+ storedSpecs->Array.forEach(spec => {
123
+ switch bundledInfos->Dict.get(spec.componentName) {
124
+ | Some(info) =>
125
+ let pkg = Util_Bundle.extractPackageName(info.specModulePath)
126
+ packageDirs->Dict.set(pkg, Util_Bundle.resolvePackageRoot(pkg))
127
+
128
+ let specModule =
129
+ info.specModulePath->JSON.stringifyAny->Option.getOr(`""`)
130
+ let callbackType =
131
+ info.callbackType->JSON.stringifyAny->Option.getOr(`""`)
132
+
133
+ let handlerJson =
134
+ Pulumi.Output.all3((info.queryDbTableName, dcbQueueUrl, spec.sourceUrns))
135
+ ->Pulumi.Output.apply(((tableName, queueUrl, urns)) => {
136
+ let sourceUrn = urns->Array.getUnsafe(0)
137
+ `{"specModule":${specModule},"callbackType":${callbackType},"queryDbTableName":"${tableName}","dcbQueueUrl":"${queueUrl}","sourceUrn":"${sourceUrn}"}`
138
+ })
139
+ let _ = handlerOutputs->Array.push(handlerJson)
140
+ | None =>
141
+ log.warn(
142
+ ~comp="AutomationSliceRuntime_Builder_Single",
143
+ `no bundled info registered for ${spec.componentName}`,
144
+ )
145
+ }
146
+ })
147
+
148
+ let handlerConfigOutput =
149
+ Pulumi.Output.all(handlerOutputs)
150
+ ->Pulumi.Output.apply(handlers =>
151
+ `{"handlers":[${handlers->Array.join(",")}]}`
152
+ )
153
+
154
+ let envVars: dict<Pulumi.Input.t<string>> = Dict.make()
155
+ envVars->Dict.set("HANDLER_CONFIG", handlerConfigOutput->Pulumi.Output.asInput)
156
+
157
+ let {code, sourceCodeHash} = Util_Bundle.buildCodeArchive(
158
+ ~entryPointModule="@reventlessdev/reventless-aws/src/adapter/Runtime/AutomationSliceEntryPoint.mjs",
159
+ ~packageDirs,
160
+ )
161
+
162
+ let runtime = RuntimeEnvironment_Lambda.makeFromCodeAsset(
163
+ ~name="AllAutomationSlices",
164
+ ~code,
165
+ ~sourceCodeHash,
166
+ ~envVars,
167
+ ~memorySize=maxMemorySize,
168
+ ~timeout=maxTimeout,
169
+ ~opts,
170
+ )
171
+
172
+ let channelSpecs = storedSpecs->Array.map(({channelSpec}) => channelSpec)
173
+ let _connectResources = EventCollectorChannel.connect(
174
+ ~name="AllAutomationSlices",
175
+ ~channelSpecs,
176
+ ~runtime,
177
+ ~opts,
178
+ )
179
+ | None =>
180
+ log.warn(
181
+ ~comp="AutomationSliceRuntime_Builder_Single",
182
+ `finish: grandParent not set`,
183
+ )
184
+ }
185
+ }
186
+ finished := true
187
+ }
@@ -0,0 +1,147 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
4
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
5
+ import * as Pulumi from "@pulumi/pulumi";
6
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
7
+ import * as Logger$ReventlessCore from "@reventlessdev/reventless-core/src/util/Logger.res.mjs";
8
+ import * as Component$ReventlessCore from "@reventlessdev/reventless-core/src/components/Component.res.mjs";
9
+ import * as Util_Bundle$ReventlessAws from "../../util/Util_Bundle.res.mjs";
10
+ import * as RuntimeEnvironment_Lambda$ReventlessAws from "./RuntimeEnvironment_Lambda.res.mjs";
11
+ import * as EventCollectorChannel_DynamoDbStream$ReventlessAws from "../EventCollector/EventCollectorChannel_DynamoDbStream.res.mjs";
12
+
13
+ let log = Logger$ReventlessCore.fromEnv();
14
+
15
+ let bundledInfos = {};
16
+
17
+ let dcbQueueUrlRef = {
18
+ contents: undefined
19
+ };
20
+
21
+ function setDcbQueueUrl(url) {
22
+ dcbQueueUrlRef.contents = url;
23
+ }
24
+
25
+ function registerAutomationSlice(name, specModulePath, callbackTypeOpt, queryDbTableName) {
26
+ let callbackType = callbackTypeOpt !== undefined ? callbackTypeOpt : "automation";
27
+ bundledInfos[name] = {
28
+ specModulePath: specModulePath,
29
+ callbackType: callbackType,
30
+ queryDbTableName: queryDbTableName
31
+ };
32
+ }
33
+
34
+ let storedSpecs = [];
35
+
36
+ let grandParent = {
37
+ contents: undefined
38
+ };
39
+
40
+ function forEventCollector(param, eventTopics, resources, memorySizeOpt, timeoutOpt, eventCollector) {
41
+ let memorySize = memorySizeOpt !== undefined ? memorySizeOpt : 1024;
42
+ let timeout = timeoutOpt !== undefined ? timeoutOpt : 30;
43
+ let eventCollectorResource = Component$ReventlessCore.toPulumiResource(eventCollector);
44
+ let channel = eventCollector.channel;
45
+ let eventCollectorName = Stdlib_Option.getOr(eventCollectorResource.__name, "Unnamed");
46
+ let parentResource = eventCollectorResource.__parentResource;
47
+ if (parentResource === undefined) {
48
+ return Stdlib_JsError.throwWithMessage(`forEventCollector(single): eventCollector ` + eventCollectorName + ` has no parent`);
49
+ }
50
+ let parentName = Stdlib_Option.getOr(parentResource.__name, "Unnamed");
51
+ if (grandParent.contents === undefined) {
52
+ grandParent.contents = parentResource.__parentResource;
53
+ }
54
+ let sourceUrns = Pulumi.all(Component$ReventlessCore.outputs(eventCollector).resources.map(param => param.urn));
55
+ storedSpecs.push({
56
+ componentName: parentName,
57
+ parentResource: parentResource,
58
+ sourceUrns: sourceUrns,
59
+ channelSpec: {
60
+ channel: channel,
61
+ eventTopics: eventTopics,
62
+ resources: resources
63
+ },
64
+ memorySize: memorySize,
65
+ timeout: timeout
66
+ });
67
+ log.info("AutomationSliceRuntime_Builder_Single", undefined, `registered ` + eventCollectorName + ` for ` + parentName);
68
+ }
69
+
70
+ let finished = {
71
+ contents: false
72
+ };
73
+
74
+ function finish() {
75
+ if (finished.contents) {
76
+ return;
77
+ }
78
+ if (storedSpecs.length !== 0) {
79
+ let match = Stdlib_Array.reduce(storedSpecs, [
80
+ 0,
81
+ 0
82
+ ], (param, param$1) => [
83
+ Math.max(param[0], param$1.memorySize),
84
+ Math.max(param[1], param$1.timeout)
85
+ ]);
86
+ let parent = grandParent.contents;
87
+ if (parent !== undefined) {
88
+ let opts_parent = parent;
89
+ let opts = {
90
+ parent: opts_parent
91
+ };
92
+ let handlerOutputs = [];
93
+ let packageDirs = {};
94
+ let url = dcbQueueUrlRef.contents;
95
+ let dcbQueueUrl = url !== undefined ? url : Pulumi.output("NOT_AVAILABLE");
96
+ storedSpecs.forEach(spec => {
97
+ let info = bundledInfos[spec.componentName];
98
+ if (info === undefined) {
99
+ return log.warn("AutomationSliceRuntime_Builder_Single", undefined, `no bundled info registered for ` + spec.componentName);
100
+ }
101
+ let pkg = Util_Bundle$ReventlessAws.extractPackageName(info.specModulePath);
102
+ packageDirs[pkg] = Util_Bundle$ReventlessAws.resolvePackageRoot(pkg);
103
+ let specModule = Stdlib_Option.getOr(JSON.stringify(info.specModulePath), `""`);
104
+ let callbackType = Stdlib_Option.getOr(JSON.stringify(info.callbackType), `""`);
105
+ let handlerJson = Pulumi.all([
106
+ info.queryDbTableName,
107
+ dcbQueueUrl,
108
+ spec.sourceUrns
109
+ ]).apply(param => {
110
+ let sourceUrn = param[2][0];
111
+ return `{"specModule":` + specModule + `,"callbackType":` + callbackType + `,"queryDbTableName":"` + param[0] + `","dcbQueueUrl":"` + param[1] + `","sourceUrn":"` + sourceUrn + `"}`;
112
+ });
113
+ handlerOutputs.push(handlerJson);
114
+ });
115
+ let handlerConfigOutput = Pulumi.all(handlerOutputs).apply(handlers => `{"handlers":[` + handlers.join(",") + `]}`);
116
+ let envVars = {};
117
+ envVars["HANDLER_CONFIG"] = handlerConfigOutput;
118
+ let match$1 = Util_Bundle$ReventlessAws.buildCodeArchive("@reventlessdev/reventless-aws/src/adapter/Runtime/AutomationSliceEntryPoint.mjs", packageDirs, undefined);
119
+ let runtime = RuntimeEnvironment_Lambda$ReventlessAws.makeFromCodeAsset("AllAutomationSlices", match$1.code, match$1.sourceCodeHash, envVars, match[0], match[1], undefined, undefined, undefined, undefined, opts);
120
+ let channelSpecs = storedSpecs.map(param => param.channelSpec);
121
+ EventCollectorChannel_DynamoDbStream$ReventlessAws.connect("AllAutomationSlices", channelSpecs, runtime, opts);
122
+ } else {
123
+ log.warn("AutomationSliceRuntime_Builder_Single", undefined, `finish: grandParent not set`);
124
+ }
125
+ }
126
+ finished.contents = true;
127
+ }
128
+
129
+ let EventCollectorChannel;
130
+
131
+ let RuntimeEnvironment;
132
+
133
+ export {
134
+ EventCollectorChannel,
135
+ RuntimeEnvironment,
136
+ log,
137
+ bundledInfos,
138
+ dcbQueueUrlRef,
139
+ setDcbQueueUrl,
140
+ registerAutomationSlice,
141
+ storedSpecs,
142
+ grandParent,
143
+ forEventCollector,
144
+ finished,
145
+ finish,
146
+ }
147
+ /* log Not a pure module */
@@ -0,0 +1,91 @@
1
+ // Counter Lambda entry point.
2
+ // At cold start: reads HANDLER_CONFIG, dynamically imports Target Spec and Mappings,
3
+ // wires Counter_Callback.Make + EventMapper_Callback.MakeCounterHandler.
4
+ // Routes DynamoDB Stream events from references and counts tables.
5
+
6
+ import { schema as surySchema, string as suryString, $$int as suryInt, parseJsonOrThrow } from "sury/src/S.res.mjs";
7
+ import { patchSpecId, makeTableRef, makeQueueRef, log } from "./HandlerFactoryHelpers.mjs";
8
+ import { parseDynamoDbStreamRecordState } from "@reventlessdev/reventless-aws/src/util/Util_DynamoDbStream_Runtime.res.mjs";
9
+ import { Make as counterCallbackMake } from "@reventlessdev/reventless-core/src/components/Counter/Counter_Callback.res.mjs";
10
+ import { MakeCounterHandler } from "@reventlessdev/reventless-core/src/components/EventMapper/EventMapper_Callback.res.mjs";
11
+ import { count as qdbCount } from "@reventlessdev/reventless-aws/src/adapter/QueryDb/QueryDbStorage_DynamoDb_Runtime.res.mjs";
12
+ import { publishJsons as sqsPublishJsons } from "@reventlessdev/reventless-aws/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res.mjs";
13
+
14
+ const dynamicImport = (specifier) => import('/var/task/node_modules/' + specifier);
15
+
16
+ // Build the referencesView schema: {id: string, inc: int}
17
+ const referencesViewSchema = surySchema(s => ({
18
+ id: s.m(suryString),
19
+ inc: s.m(suryInt),
20
+ }));
21
+
22
+ async function buildHandler() {
23
+ const configStr = process.env["HANDLER_CONFIG"] || "{}";
24
+ const config = JSON.parse(configStr);
25
+
26
+ const targetSpecModule = await dynamicImport(config.targetSpecModule);
27
+ const mappingsModule = await dynamicImport(config.mappingsModule);
28
+
29
+ const patchedTarget = patchSpecId(targetSpecModule);
30
+ const countsTable = makeTableRef(config.countsTableName);
31
+ const countsDbCount = qdbCount(countsTable);
32
+
33
+ const pubJsons = sqsPublishJsons(makeQueueRef(config.publishQueueUrl), "SQS_FIFO");
34
+ const queryEngine = { query: async () => [], queryAll: async () => [] };
35
+
36
+ const counterHandler = MakeCounterHandler(patchedTarget)(mappingsModule)({ publishJsons: pubJsons, queryEngine });
37
+ const callback = counterCallbackMake({
38
+ name: "BundledCounter",
39
+ countsDbCount,
40
+ jsonEventsHandler: counterHandler.handleCounterEvents,
41
+ });
42
+
43
+ return [config.referencesStreamArn, config.countsStreamArn, callback];
44
+ }
45
+
46
+ const initPromise = buildHandler();
47
+
48
+ export async function handler(event, _context) {
49
+ const [referencesStreamArn, countsStreamArn, callback] = await initPromise;
50
+ const records = event.Records || [];
51
+
52
+ const dynamoDbRecords = records.filter(r =>
53
+ r.eventSource === "aws:dynamodb" &&
54
+ (r.eventSourceARN === referencesStreamArn || r.eventSourceARN === countsStreamArn)
55
+ );
56
+
57
+ const referenceRecords = dynamoDbRecords.filter(r => r.eventSourceARN === referencesStreamArn);
58
+ const countRecords = dynamoDbRecords.filter(r => r.eventSourceARN === countsStreamArn);
59
+
60
+ const references = referenceRecords.flatMap(record => {
61
+ const state = parseDynamoDbStreamRecordState(record);
62
+ switch (state.TAG) {
63
+ case 0: { // NewImage(id, newImage)
64
+ const id = state._0;
65
+ let inc;
66
+ try {
67
+ inc = parseJsonOrThrow(state._1, referencesViewSchema).inc;
68
+ } catch (_) {
69
+ inc = 1;
70
+ }
71
+ return [[id, inc]];
72
+ }
73
+ case 2: // NewAndOldImage — duplicate
74
+ log.debug("ignoring duplicate id: " + state._0, { comp: "CounterEntryPoint" });
75
+ return [];
76
+ default:
77
+ return [];
78
+ }
79
+ });
80
+
81
+ const counts = countRecords.flatMap(record => {
82
+ const state = parseDynamoDbStreamRecordState(record);
83
+ if (state.TAG === 0 || state.TAG === 2) {
84
+ return [state._1];
85
+ }
86
+ return [];
87
+ });
88
+
89
+ await callback.counterHandler(references, counts);
90
+ return "";
91
+ }
@@ -0,0 +1,265 @@
1
+ // DcbCommandTopic Lambda entry point.
2
+ // At cold start: reads HANDLER_CONFIG, dynamically imports StateChangeSlice modules,
3
+ // builds shared DcbEventLog operations and per-slice handlers keyed by command type name.
4
+ // Dual routing: AppSync direct invocation and SQS CommandTopic events.
5
+
6
+ import * as Chunk from "effect/Chunk";
7
+ import * as Effect from "effect/Effect";
8
+ import * as Stream from "effect/Stream";
9
+ import { patchSpecId, makeQueueRef, log, pluginName } from "./HandlerFactoryHelpers.mjs";
10
+ import { decodeCommand$p as decodeCommandPrime } from "@reventlessdev/reventless-core/src/Message.res.mjs";
11
+ import { tag as requestContextTag } from "@reventlessdev/reventless-core/src/RequestContext.res.mjs";
12
+ import {
13
+ extractVariantNames,
14
+ extractTagKeysByEventType,
15
+ mergeTagKeysByEventType,
16
+ extractCrossPartitionTagKeys,
17
+ } from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
18
+ import { $$String as IdString } from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
19
+ import { Make as dcbEventLogOperationsMake } from "@reventlessdev/reventless-core/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs";
20
+ import { Make as stateChangeSliceCallbackMake } from "@reventlessdev/reventless-core/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs";
21
+ import { makeGenerateCommand } from "@reventlessdev/reventless-core/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs";
22
+ import { commandOutcomeToJson, runInlineAndCollect } from "@reventlessdev/reventless-core/src/components/CommandTopic/CommandTopic_Helpers.res.mjs";
23
+ import { json as jsonSchema } from "sury/src/S.res.mjs";
24
+ import { read, append, readStream } from "@reventlessdev/reventless-aws/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb_Runtime.res.mjs";
25
+ import { handleQueueEvent, publishJsons as sqsPublishJsons } from "@reventlessdev/reventless-aws/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res.mjs";
26
+
27
+ const dynamicImport = (specifier) => import('/var/task/node_modules/' + specifier);
28
+
29
+ // DISPATCH_MODE controls whether AppSync direct-invoke commands are run inline
30
+ // (sync, default) or pushed to SQS for asynchronous processing (async).
31
+ // Set by PluginRuntime_Builder.forDcbCommandTopic when wiring the async DCB
32
+ // CommandTopic; sync is the default for the primary DCB topic.
33
+ const DISPATCH_MODE = process.env["DISPATCH_MODE"] === "async" ? "async" : "sync";
34
+
35
+ function extractTypeName(json) {
36
+ if (typeof json === 'string') return json;
37
+ if (json && typeof json === 'object') {
38
+ const commandJson = json.commandJson || json.command || json;
39
+ if (typeof commandJson === 'string') return commandJson;
40
+ if (commandJson && commandJson.TAG) return commandJson.TAG;
41
+ const keys = Object.keys(commandJson);
42
+ if (keys.length === 1 && keys[0] !== 'id' && keys[0] !== 'meta') return keys[0];
43
+ }
44
+ return undefined;
45
+ }
46
+
47
+ // Set at handler entry; read by runEffect to tag logs with the Lambda request id.
48
+ let _currentRequestId = "unknown";
49
+
50
+ function runEffect(correlationId, effect) {
51
+ let e = effect
52
+ // Promote correlationId/requestId/plugin to top-level JSON log fields —
53
+ // decoded by EffectLogger.install() from Effect log annotations. Harmless
54
+ // no-op if the unified logger isn't installed.
55
+ .pipe(Effect.annotateLogs("correlationId", correlationId || "unknown"))
56
+ .pipe(Effect.annotateLogs("requestId", _currentRequestId));
57
+ if (pluginName) e = e.pipe(Effect.annotateLogs("plugin", pluginName));
58
+ return e
59
+ .pipe(Effect.provideService(requestContextTag, { correlationId: correlationId || "unknown" }))
60
+ .pipe(Effect.runPromise);
61
+ }
62
+
63
+ function extractCorrelationId(records) {
64
+ const first = records[0];
65
+ if (!first) return undefined;
66
+ const body = first.body;
67
+ if (body == null) return undefined;
68
+ try {
69
+ const parsed = JSON.parse(body);
70
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
71
+ const meta = parsed.meta;
72
+ if (meta && typeof meta === "object" && !Array.isArray(meta)) {
73
+ const cid = meta.correlationId;
74
+ if (typeof cid === "string") return cid;
75
+ }
76
+ }
77
+ } catch (_) {}
78
+ return undefined;
79
+ }
80
+
81
+ function getIdStringSchema() {
82
+ return IdString.schema;
83
+ }
84
+
85
+ // Exported for tests: build the [sqsHandler, cmdGenHandler] pair from an
86
+ // already-parsed `HANDLER_CONFIG` shape, with an injectable module loader.
87
+ // In production, `buildHandler` below wraps this with the env-config + the
88
+ // Lambda's `/var/task/node_modules` dynamic-import; integration tests inject
89
+ // their own loader that returns pre-imported spec/behavior modules so the test
90
+ // can drive the real `cmdGenHandler` end-to-end against DynamoDB Local.
91
+ export async function buildHandlersForConfig(config, opts = {}) {
92
+ const loadModule = opts.loadModule ?? dynamicImport;
93
+ const resolvedTable = { name: config.dcbEventLogTableName };
94
+ const rawStorageOps = {
95
+ read: read(resolvedTable),
96
+ append: append(resolvedTable),
97
+ readStream: readStream(resolvedTable),
98
+ };
99
+
100
+ const handlersByType = {};
101
+ const sharedDcbEventLogOps = dcbEventLogOperationsMake({
102
+ name: config.pluginName,
103
+ // Mirrors DcbEventLog_Builder.res's `name ++ "DcbEventLog"` — the
104
+ // canonical service identity used by Plugin_Callback dispatch and the
105
+ // DcbEventLog_Operations meta.service normalisation in append.
106
+ serviceName: config.pluginName + "DcbEventLog",
107
+ storage: rawStorageOps,
108
+ publishJson: async (_name, _meta, _json) => {},
109
+ });
110
+
111
+ // Load all spec/behavior pairs first, then derive the per-plugin
112
+ // tagKeysByEventType / crossPartitionTagKeys across the produced event
113
+ // schemas — mirroring Dcb_Builder.res's build-time derivation — so the
114
+ // runtime slice callback receives the same values it would in-process.
115
+ const loadedSlices = await Promise.all(
116
+ config.stateChangeSliceModules.map(async ({ spec, behavior }) => {
117
+ const specModule = await loadModule(spec);
118
+ const behaviorModule = await loadModule(behavior);
119
+ const patchedSpec = patchSpecId(specModule);
120
+ return { patchedSpec, behaviorModule };
121
+ })
122
+ );
123
+
124
+ const producedSchemas = loadedSlices.map(({ patchedSpec }) => patchedSpec.eventSchema);
125
+ const tagKeysByEventType = mergeTagKeysByEventType(
126
+ producedSchemas.map(s => extractTagKeysByEventType(s))
127
+ );
128
+ const crossPartitionTagKeys = Array.from(
129
+ new Set(producedSchemas.flatMap(s => extractCrossPartitionTagKeys(s)))
130
+ );
131
+
132
+ loadedSlices.forEach(({ patchedSpec, behaviorModule }) => {
133
+ const sliceCallback = stateChangeSliceCallbackMake(patchedSpec)(behaviorModule);
134
+ const commandSchema = patchedSpec.commandSchema;
135
+ const typeNames = extractVariantNames(commandSchema);
136
+
137
+ const jsonHandler = stream => {
138
+ const decodedStream = Stream.flatMap(
139
+ Stream.mapEffect(stream, topicItem => Effect.sync(() => {
140
+ try {
141
+ const decoded = decodeCommandPrime(topicItem.command, getIdStringSchema(), commandSchema);
142
+ return { TAG: "Some", _0: { command: decoded, reference: topicItem.reference } };
143
+ } catch (_) {
144
+ return { TAG: "None", _0: 0 };
145
+ }
146
+ })),
147
+ opt => opt.TAG === "Some" ? Stream.make(opt._0) : Stream.empty
148
+ );
149
+ // Positional args match StateChangeSlice_Callback.res's compiled signature:
150
+ // (tagKeysByEventTypeOpt, crossPartitionTagKeysOpt, dcbEventLog, stream).
151
+ return sliceCallback.handleCommands(
152
+ tagKeysByEventType,
153
+ crossPartitionTagKeys,
154
+ sharedDcbEventLogOps,
155
+ decodedStream,
156
+ );
157
+ };
158
+
159
+ typeNames.forEach(typeName => {
160
+ handlersByType[typeName] = jsonHandler;
161
+ });
162
+ });
163
+
164
+ // Composite handler used by Route 2 (SQS event source) AND inline dispatch
165
+ // for Route 1 sync mode. Routes each item to the slice handler matching its
166
+ // command TAG; unknown TAGs are dropped with a warning.
167
+ const compositeJsonCommandsHandler = stream => Effect.map(
168
+ Stream.runCollect(
169
+ Stream.mapEffect(stream, topicItem => {
170
+ const typeNameOpt = extractTypeName(topicItem.command);
171
+ if (typeNameOpt !== undefined) {
172
+ const sliceHandler = handlersByType[typeNameOpt];
173
+ if (sliceHandler !== undefined) {
174
+ return sliceHandler(Stream.make(topicItem));
175
+ } else {
176
+ log.warn("no handler for command type: " + typeNameOpt, { comp: "DcbCommandTopicRuntime" });
177
+ return Effect.succeed([]);
178
+ }
179
+ }
180
+ log.warn("could not extract command type", { comp: "DcbCommandTopicRuntime" });
181
+ return Effect.succeed([]);
182
+ })
183
+ ),
184
+ chunk => Chunk.toReadonlyArray(chunk).flat()
185
+ );
186
+
187
+ const resolvedQueue = makeQueueRef(config.queueUrl);
188
+ const sqsHandler = handleQueueEvent(resolvedQueue, compositeJsonCommandsHandler);
189
+ const publishJsons = sqsPublishJsons(resolvedQueue, "SQS_FIFO");
190
+
191
+ // Sync (default): inline-dispatch the command via the same composite handler
192
+ // that Route 2 uses, so the AppSync resolver gets a typed Accepted/Rejected
193
+ // outcome. Async: undefined → makeGenerateCommand falls back to publishJsons
194
+ // and returns Pending. The schema is permissive (S.json) because AppSync has
195
+ // already validated input against the SDL — per-slice schemas reapply inside
196
+ // the slice handlers via decodeCommandPrime.
197
+ const publishJsonsAndWait = DISPATCH_MODE === "async"
198
+ ? undefined
199
+ : (jsons) => runInlineAndCollect(jsons, compositeJsonCommandsHandler);
200
+
201
+ // Positional args match CommandGenerator_Callback.makeGenerateCommand's
202
+ // ReScript-compiled signature: (publishJsons, publishJsonsAndWait,
203
+ // serviceName, commandSchema, componentKind, stripIdFromParams).
204
+ // stripIdFromParams=false: DCB slices may declare a literal `id` field as part
205
+ // of the command schema (composite partition keys etc.) — don't strip it.
206
+ const generateCommand = makeGenerateCommand(
207
+ publishJsons,
208
+ publishJsonsAndWait,
209
+ config.pluginName,
210
+ jsonSchema,
211
+ "StateChangeSlice",
212
+ false,
213
+ );
214
+
215
+ const cmdGenHandler = (event) => {
216
+ // CommandGenerator.meta declares ip as array<string> (X-Forwarded-For chain).
217
+ // AppSync sends a single string or null from identity.sourceIp.
218
+ const rawIp = event.meta && event.meta.ip;
219
+ const ip = rawIp == null ? [] : Array.isArray(rawIp) ? rawIp : [rawIp];
220
+ const meta = { ...event.meta, ip };
221
+ const identity = (event.identity != null && typeof event.identity === 'object')
222
+ ? event.identity
223
+ : {
224
+ userId: (event.meta && event.meta.user) ?? "anonymous",
225
+ username: (event.meta && event.meta.user) ?? "anonymous",
226
+ groups: [],
227
+ provider: { TAG: "Custom", _0: "aws" },
228
+ };
229
+ return generateCommand({ ...event, meta, identity });
230
+ };
231
+
232
+ return [sqsHandler, cmdGenHandler];
233
+ }
234
+
235
+ async function buildHandler() {
236
+ const configStr = process.env["HANDLER_CONFIG"];
237
+ // Importing this module without HANDLER_CONFIG (e.g. from a test that drives
238
+ // `buildHandlersForConfig` directly) must not crash module evaluation.
239
+ // Lambda always sets HANDLER_CONFIG; the production path is unchanged.
240
+ if (!configStr) return [null, null];
241
+ const config = JSON.parse(configStr);
242
+ return buildHandlersForConfig(config, { loadModule: dynamicImport });
243
+ }
244
+
245
+ const initPromise = buildHandler();
246
+
247
+ export async function handler(event, context) {
248
+ _currentRequestId = context?.awsRequestId || "unknown";
249
+ const [sqsHandler, cmdGenHandler] = await initPromise;
250
+
251
+ // Route 1: AppSync direct invocation — payload carries the CommandGenerator.payload
252
+ // shape (`{command, arguments, meta, identity?}`).
253
+ if (event.command != null && event.arguments != null) {
254
+ log.debug("AppSync direct invocation (" + DISPATCH_MODE + ")", { comp: "DcbCommandTopicRuntime" });
255
+ const outcome = await runEffect(undefined, cmdGenHandler(event));
256
+ return commandOutcomeToJson(outcome);
257
+ }
258
+
259
+ // Route 2: SQS CommandTopic events
260
+ const records = event.Records || [];
261
+ const correlationId = extractCorrelationId(records);
262
+ log.debug("processing " + records.length.toString() + " record(s)", { comp: "DcbCommandTopicRuntime" });
263
+ await runEffect(correlationId, sqsHandler(event, context));
264
+ return "";
265
+ }