@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,101 @@
1
+ // ExtensionPoint Lambda entry point.
2
+ // At cold start: reads HANDLER_CONFIG, dynamically imports Spec/Mappings,
3
+ // wires ExtensionPoint_Callback.Make + CommandTopic_Callback.Make,
4
+ // routes SQS events through handleQueueEvent.
5
+
6
+ import * as Effect from "effect/Effect";
7
+ import { patchSpecId, makeQueueRef, log, pluginName } from "./HandlerFactoryHelpers.mjs";
8
+ import { tag as requestContextTag } from "@reventlessdev/reventless-core/src/RequestContext.res.mjs";
9
+ import { Make as extensionPointCallbackMake } from "@reventlessdev/reventless-core/src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs";
10
+ import { Make as commandTopicCallbackMake } from "@reventlessdev/reventless-core/src/components/CommandTopic/CommandTopic_Callback.res.mjs";
11
+ import { handleQueueEvent, publishJsons as sqsPublishJsons } from "@reventlessdev/reventless-aws/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res.mjs";
12
+
13
+ const dynamicImport = (specifier) => import('/var/task/node_modules/' + specifier);
14
+
15
+ // Set at handler entry; read by runEffect to tag logs with the Lambda request id.
16
+ let _currentRequestId = "unknown";
17
+
18
+ function runEffect(correlationId, effect) {
19
+ let e = effect
20
+ // Promote correlationId/requestId/plugin to top-level JSON log fields —
21
+ // decoded by EffectLogger.install() from Effect log annotations. Harmless
22
+ // no-op if the unified logger isn't installed.
23
+ .pipe(Effect.annotateLogs("correlationId", correlationId || "unknown"))
24
+ .pipe(Effect.annotateLogs("requestId", _currentRequestId));
25
+ if (pluginName) e = e.pipe(Effect.annotateLogs("plugin", pluginName));
26
+ return e
27
+ .pipe(Effect.provideService(requestContextTag, { correlationId: correlationId || "unknown" }))
28
+ .pipe(Effect.runPromise);
29
+ }
30
+
31
+ function extractCorrelationId(records) {
32
+ const first = records[0];
33
+ if (!first) return undefined;
34
+ const body = first.body;
35
+ if (!body) return undefined;
36
+ try {
37
+ const parsed = JSON.parse(body);
38
+ if (typeof parsed === "object" && parsed !== null) {
39
+ const meta = parsed.meta;
40
+ if (meta && typeof meta === "object" && typeof meta.correlationId === "string") {
41
+ return meta.correlationId;
42
+ }
43
+ }
44
+ } catch (_) {}
45
+ return undefined;
46
+ }
47
+
48
+ async function buildHandler() {
49
+ const configStr = process.env["HANDLER_CONFIG"] || "{}";
50
+ const config = JSON.parse(configStr);
51
+
52
+ const specModule = await dynamicImport(config.specModule);
53
+ const mappingsModule = await dynamicImport(config.mappingsModule);
54
+
55
+ const patchedSpec = patchSpecId(specModule);
56
+
57
+ // Build publishToAggregates dict from env var queue URLs. The deploy-side
58
+ // builder writes HANDLER_CONFIG.publishToAggregates as { aggregateName: envVarName }
59
+ // (see ExtensionPointRuntime_Builder_PerExtensionPoint.res), so iterate accordingly.
60
+ const publishToAggregates = {};
61
+ for (const [aggName, envVarName] of Object.entries(config.publishToAggregates || {})) {
62
+ const queueUrl = process.env[envVarName] || "";
63
+ publishToAggregates[aggName] = sqsPublishJsons(makeQueueRef(queueUrl), "SQS_FIFO");
64
+ }
65
+
66
+ const callbackConfig = {
67
+ publishToAggregates,
68
+ commandTopicResources: [],
69
+ scheduler: {
70
+ create: async () => { throw new Error("Scheduler not available in bundled ExtensionPoint handler"); },
71
+ delete: async () => { throw new Error("Scheduler not available in bundled ExtensionPoint handler"); },
72
+ },
73
+ queryEngine: {
74
+ scan: async () => { throw new Error("QueryEngine not available in bundled ExtensionPoint handler"); },
75
+ query: async () => { throw new Error("QueryEngine not available in bundled ExtensionPoint handler"); },
76
+ },
77
+ resourceNaming: { name: (n) => n, resolve: (n) => n },
78
+ };
79
+
80
+ const callback = extensionPointCallbackMake(callbackConfig)(patchedSpec)(mappingsModule);
81
+ const commandTopicCallback = commandTopicCallbackMake(patchedSpec)({
82
+ Spec: patchedSpec,
83
+ commandsHandler: callback.handleIncomingCommands,
84
+ });
85
+
86
+ const resolvedQueue = makeQueueRef(config.queueUrl);
87
+ return handleQueueEvent(resolvedQueue, commandTopicCallback.handleJsonCommands);
88
+ }
89
+
90
+ const initPromise = buildHandler();
91
+
92
+ export async function handler(event, context) {
93
+ _currentRequestId = context?.awsRequestId || "unknown";
94
+ const sqsHandler = await initPromise;
95
+ const records = event.Records || [];
96
+ const correlationId = extractCorrelationId(records);
97
+
98
+ log.debug("processing " + records.length.toString() + " record(s)", { comp: "ExtensionPointRuntime" });
99
+ await runEffect(correlationId, sqsHandler(event, context));
100
+ return "";
101
+ }
@@ -0,0 +1,83 @@
1
+ module CommandTopicChannel = CommandTopicChannel.SQS_Sync
2
+ module RuntimeEnvironment = RuntimeEnvironment.Lambda
3
+
4
+ type context = PulumiAws.Lambda.context
5
+ type runtimeParts = Util.Lambda.runtimeParts
6
+
7
+ let forCommandTopic = (
8
+ ~handler as _,
9
+ ~connect,
10
+ ~memorySize=1024,
11
+ ~timeout=30,
12
+ ~specModulePath as specModuleUrl,
13
+ ~mappingsModulePath as mappingsModuleUrl,
14
+ ~publishToAggregatesQueueUrls,
15
+ commandTopic,
16
+ ) => {
17
+ let commandTopicResource = commandTopic->ReventlessCore.Component.toPulumiResource
18
+ let channel = commandTopic->ReventlessCore.CommandTopic_Adapter.channel
19
+ let channelParts: Util.SQS.channelParts = Obj.magic(channel.parts)
20
+ let queue = channelParts.queue
21
+
22
+ // The EP command-handler Lambda inherits the bare EP CommandTopic resource
23
+ // name (`<EP>ExtPoint`) and appends the unified `CmdHandler` kind so it is
24
+ // greppable alongside the aggregate/DCB command handlers (analysis §8.2).
25
+ let name = commandTopicResource.name->Option.getOr("UnnamedExtPoint") ++ "CmdHandler"
26
+ let opts = {Pulumi.ComponentResource.parent: commandTopicResource}
27
+
28
+ let specModulePath = Util_Bundle.getModuleSpecifier(specModuleUrl)
29
+ let mappingsModulePath = Util_Bundle.getModuleSpecifier(mappingsModuleUrl)
30
+
31
+ // Build HANDLER_CONFIG with publishToAggregates mapping aggregate names to env var names
32
+ let envVars: dict<Pulumi.Input.t<string>> = Dict.make()
33
+ envVars->Dict.set("EP_QUEUE_URL", queue.id->Pulumi.Output.asInput)
34
+
35
+ let publishToAggregatesEnvVars: dict<string> = Dict.make()
36
+ publishToAggregatesQueueUrls->Dict.forEachWithKey((queueUrlOutput, aggName) => {
37
+ let envVar = `PTA_${aggName}_QUEUE_URL`
38
+ envVars->Dict.set(envVar, queueUrlOutput->Pulumi.Output.asInput)
39
+ publishToAggregatesEnvVars->Dict.set(aggName, envVar)
40
+ })
41
+
42
+ let specModule = specModulePath->JSON.stringifyAny->Option.getOr(`""`)
43
+ let mappingsModule = mappingsModulePath->JSON.stringifyAny->Option.getOr(`""`)
44
+ let publishToAggregatesJson =
45
+ publishToAggregatesEnvVars
46
+ ->Dict.toArray
47
+ ->Array.map(((aggName, envVar)) =>
48
+ `${aggName->JSON.stringifyAny->Option.getOr(`""`)}: ${envVar->JSON.stringifyAny->Option.getOr(`""`)}`
49
+ )
50
+ ->Array.join(",")
51
+
52
+ let handlerConfigJson =
53
+ queue.id
54
+ ->Pulumi.Output.apply(queueUrl =>
55
+ `{"specModule":${specModule},"mappingsModule":${mappingsModule},"queueUrl":"${queueUrl}","publishToAggregates":{${publishToAggregatesJson}}}`
56
+ )
57
+ envVars->Dict.set("HANDLER_CONFIG", handlerConfigJson->Pulumi.Output.asInput)
58
+
59
+ // Collect unique user packages for the code asset
60
+ let packageDirs: dict<string> = Dict.make()
61
+ let specPkg = Util_Bundle.extractPackageName(specModulePath)
62
+ let mappingsPkg = Util_Bundle.extractPackageName(mappingsModulePath)
63
+ packageDirs->Dict.set(specPkg, Util_Bundle.resolvePackageRoot(specPkg))
64
+ packageDirs->Dict.set(mappingsPkg, Util_Bundle.resolvePackageRoot(mappingsPkg))
65
+
66
+ let {code, sourceCodeHash} = Util_Bundle.buildCodeArchive(
67
+ ~entryPointModule="@reventlessdev/reventless-aws/src/adapter/Runtime/ExtensionPointEntryPoint.mjs",
68
+ ~packageDirs,
69
+ )
70
+
71
+ let runtime = RuntimeEnvironment_Lambda.makeFromCodeAsset(
72
+ ~name,
73
+ ~code,
74
+ ~sourceCodeHash,
75
+ ~envVars,
76
+ ~memorySize,
77
+ ~timeout,
78
+ ~opts,
79
+ )
80
+ connect(~runtime)
81
+ }
82
+
83
+ let finish = () => ()
@@ -0,0 +1,59 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
4
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
5
+ import * as Component$ReventlessCore from "@reventlessdev/reventless-core/src/components/Component.res.mjs";
6
+ import * as Util_Bundle$ReventlessAws from "../../util/Util_Bundle.res.mjs";
7
+ import * as RuntimeEnvironment_Lambda$ReventlessAws from "./RuntimeEnvironment_Lambda.res.mjs";
8
+
9
+ function forCommandTopic(param, connect, memorySizeOpt, timeoutOpt, specModuleUrl, mappingsModuleUrl, publishToAggregatesQueueUrls, commandTopic) {
10
+ let memorySize = memorySizeOpt !== undefined ? memorySizeOpt : 1024;
11
+ let timeout = timeoutOpt !== undefined ? timeoutOpt : 30;
12
+ let commandTopicResource = Component$ReventlessCore.toPulumiResource(commandTopic);
13
+ let channel = commandTopic.channel;
14
+ let channelParts = channel.parts;
15
+ let queue = channelParts.queue;
16
+ let name = Stdlib_Option.getOr(commandTopicResource.__name, "UnnamedExtPoint") + "CmdHandler";
17
+ let opts_parent = commandTopicResource;
18
+ let opts = {
19
+ parent: opts_parent
20
+ };
21
+ let specModulePath = Util_Bundle$ReventlessAws.getModuleSpecifier(specModuleUrl);
22
+ let mappingsModulePath = Util_Bundle$ReventlessAws.getModuleSpecifier(mappingsModuleUrl);
23
+ let envVars = {};
24
+ envVars["EP_QUEUE_URL"] = queue.id;
25
+ let publishToAggregatesEnvVars = {};
26
+ Stdlib_Dict.forEachWithKey(publishToAggregatesQueueUrls, (queueUrlOutput, aggName) => {
27
+ let envVar = `PTA_` + aggName + `_QUEUE_URL`;
28
+ envVars[envVar] = queueUrlOutput;
29
+ publishToAggregatesEnvVars[aggName] = envVar;
30
+ });
31
+ let specModule = Stdlib_Option.getOr(JSON.stringify(specModulePath), `""`);
32
+ let mappingsModule = Stdlib_Option.getOr(JSON.stringify(mappingsModulePath), `""`);
33
+ let publishToAggregatesJson = Object.entries(publishToAggregatesEnvVars).map(param => Stdlib_Option.getOr(JSON.stringify(param[0]), `""`) + `: ` + Stdlib_Option.getOr(JSON.stringify(param[1]), `""`)).join(",");
34
+ let handlerConfigJson = queue.id.apply(queueUrl => `{"specModule":` + specModule + `,"mappingsModule":` + mappingsModule + `,"queueUrl":"` + queueUrl + `","publishToAggregates":{` + publishToAggregatesJson + `}}`);
35
+ envVars["HANDLER_CONFIG"] = handlerConfigJson;
36
+ let packageDirs = {};
37
+ let specPkg = Util_Bundle$ReventlessAws.extractPackageName(specModulePath);
38
+ let mappingsPkg = Util_Bundle$ReventlessAws.extractPackageName(mappingsModulePath);
39
+ packageDirs[specPkg] = Util_Bundle$ReventlessAws.resolvePackageRoot(specPkg);
40
+ packageDirs[mappingsPkg] = Util_Bundle$ReventlessAws.resolvePackageRoot(mappingsPkg);
41
+ let match = Util_Bundle$ReventlessAws.buildCodeArchive("@reventlessdev/reventless-aws/src/adapter/Runtime/ExtensionPointEntryPoint.mjs", packageDirs, undefined);
42
+ return connect(RuntimeEnvironment_Lambda$ReventlessAws.makeFromCodeAsset(name, match.code, match.sourceCodeHash, envVars, memorySize, timeout, undefined, undefined, undefined, undefined, opts));
43
+ }
44
+
45
+ function finish() {
46
+
47
+ }
48
+
49
+ let CommandTopicChannel;
50
+
51
+ let RuntimeEnvironment;
52
+
53
+ export {
54
+ CommandTopicChannel,
55
+ RuntimeEnvironment,
56
+ forCommandTopic,
57
+ finish,
58
+ }
59
+ /* Component-ReventlessCore Not a pure module */
@@ -0,0 +1,142 @@
1
+ // Shared runtime utilities for compiled Lambda entry points.
2
+
3
+ import { $$String as IdString } from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
4
+ import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
5
+ import { DynamoDBDocumentClient, ScanCommand } from "@aws-sdk/lib-dynamodb";
6
+
7
+ // ─── Structured logging from the .mjs entry-point shims ─────────────────────
8
+ // Mirrors ReScript's Logger.t API and Logger.emit's JSON sink shape (time,
9
+ // level, message, service, plugin, comp, detail) so shim-side init/error
10
+ // traces land alongside ReScript logs as homogeneous JSON in CloudWatch.
11
+ //
12
+ // Usage: `log.debug("msg", { comp: "AggregateRuntime" })` —
13
+ // level-specific method, no stringly-typed level argument.
14
+
15
+ const LEVEL_DEBUG = 0;
16
+ const LEVEL_INFO = 1;
17
+ const LEVEL_WARN = 2;
18
+ const LEVEL_ERROR = 3;
19
+ const LEVEL_SILENT = 99;
20
+
21
+ function envMinLevel() {
22
+ switch ((process.env.LOG_LEVEL || "info").toLowerCase()) {
23
+ case "silent": return LEVEL_SILENT;
24
+ case "debug": return LEVEL_DEBUG;
25
+ case "warn": return LEVEL_WARN;
26
+ case "error": return LEVEL_ERROR;
27
+ default: return LEVEL_INFO;
28
+ }
29
+ }
30
+
31
+ // Per-plugin Lambdas follow the naming pattern `<Plugin>Plugin<Suffix>` (e.g.
32
+ // `CatalogPluginEventColl`, `OrderingPluginHeartbeat`). Multi-plugin Lambdas
33
+ // (`AllAggregatesCmdHandler`, `AllReadModels`, the platform-level `PluginAggr*`)
34
+ // don't carry a single plugin identity; returns null so callers omit the field.
35
+ export function derivePluginFromLambdaName(name) {
36
+ if (typeof name !== "string") return null;
37
+ const match = /^([A-Z][a-zA-Z0-9]+)Plugin(?:[A-Z]|$|-)/.exec(name);
38
+ return match ? match[1] : null;
39
+ }
40
+
41
+ const PLUGIN_NAME = derivePluginFromLambdaName(process.env.AWS_LAMBDA_FUNCTION_NAME);
42
+ const SERVICE_NAME = process.env.REVENTLESS_SERVICE || process.env.AWS_LAMBDA_FUNCTION_NAME;
43
+
44
+ function emit(level, levelLabel, message, extra) {
45
+ if (level < envMinLevel()) return;
46
+ const fields = { time: new Date().toISOString(), level: levelLabel, message };
47
+ if (SERVICE_NAME) fields.service = SERVICE_NAME;
48
+ if (PLUGIN_NAME) fields.plugin = PLUGIN_NAME;
49
+ if (extra && typeof extra === "object") {
50
+ for (const [k, v] of Object.entries(extra)) {
51
+ if (v !== undefined && v !== null) fields[k] = v;
52
+ }
53
+ }
54
+ // eslint-disable-next-line no-console
55
+ console.log(JSON.stringify(fields));
56
+ }
57
+
58
+ export const log = {
59
+ debug: (message, extra) => emit(LEVEL_DEBUG, "DEBUG", message, extra),
60
+ info: (message, extra) => emit(LEVEL_INFO, "INFO", message, extra),
61
+ warn: (message, extra) => emit(LEVEL_WARN, "WARN", message, extra),
62
+ error: (message, extra) => emit(LEVEL_ERROR, "ERROR", message, extra),
63
+ };
64
+
65
+ // Plugin name derived from the Lambda function name (null on multi-plugin
66
+ // Lambdas). Export so shim runEffect wrappers can annotate Effect logs with it.
67
+ export const pluginName = PLUGIN_NAME;
68
+
69
+ // Patch a spec module's Id field to use IdString if undefined.
70
+ // Workaround for `module Id = Id.String` not producing an ESM export.
71
+ export const patchSpecId = (specModule) => ({ ...specModule, Id: specModule.Id || IdString });
72
+
73
+ // Create a minimal DynamoDB table stub from a table name.
74
+ export function makeTableRef(name) {
75
+ return { name, hashKey: "id" };
76
+ }
77
+
78
+ // Create a minimal SQS queue stub from a queue URL.
79
+ export function makeQueueRef(url) {
80
+ return { id: url, name: url, arn: "" };
81
+ }
82
+
83
+ // DynamoDB scan with filter expression support.
84
+ export async function scanByTableName(tableName, filterConfigs, limit) {
85
+ if (!scanByTableName._client) {
86
+ scanByTableName._client = DynamoDBDocumentClient.from(new DynamoDBClient({}));
87
+ }
88
+ var client = scanByTableName._client;
89
+ var filterParts = [];
90
+ var attrNames = {};
91
+ var attrValues = {};
92
+
93
+ (filterConfigs || []).forEach(function(entry, idx) {
94
+ var fieldName = entry[0];
95
+ var comparator = entry[1];
96
+ var value = entry[2];
97
+ var valueName = fieldName + idx;
98
+ attrNames["#" + fieldName] = fieldName;
99
+
100
+ var attrValue;
101
+ if (typeof value === "object" && value !== null && "TAG" in value) {
102
+ attrValue = value._0;
103
+ } else {
104
+ attrValue = value;
105
+ }
106
+ attrValues[":" + valueName] = attrValue;
107
+
108
+ var comp = typeof comparator === "object" ? comparator.TAG || comparator : comparator;
109
+ switch (comp) {
110
+ case "Equal": filterParts.push("#" + fieldName + " = :" + valueName); break;
111
+ case "Unequal": filterParts.push("#" + fieldName + " <> :" + valueName); break;
112
+ case "Contains": filterParts.push("contains( #" + fieldName + ", :" + valueName + " )"); break;
113
+ case "NotContains": filterParts.push("NOT contains( #" + fieldName + ", :" + valueName + " )"); break;
114
+ case "BeginsWith": filterParts.push("begins_with( #" + fieldName + ", :" + valueName + " )"); break;
115
+ case "Exists": filterParts.push("attribute_exists( #" + fieldName + " )"); break;
116
+ case "NotExists": filterParts.push("attribute_not_exists( #" + fieldName + " )"); break;
117
+ case "LessOrEqual": filterParts.push("#" + fieldName + " <= :" + valueName); break;
118
+ case "Less": filterParts.push("#" + fieldName + " < :" + valueName); break;
119
+ case "GreaterOrEqual": filterParts.push("#" + fieldName + " >= :" + valueName); break;
120
+ case "Greater": filterParts.push("#" + fieldName + " > :" + valueName); break;
121
+ default: filterParts.push("#" + fieldName + " = :" + valueName);
122
+ }
123
+ });
124
+
125
+ var params = { TableName: tableName, Limit: limit };
126
+ if (filterParts.length > 0) {
127
+ params.FilterExpression = filterParts.join(" AND ");
128
+ params.ExpressionAttributeNames = attrNames;
129
+ params.ExpressionAttributeValues = attrValues;
130
+ }
131
+
132
+ var items = [];
133
+ var lastKey;
134
+ do {
135
+ if (lastKey) params.ExclusiveStartKey = lastKey;
136
+ var result = await client.send(new ScanCommand(params));
137
+ if (result.Items) items.push.apply(items, result.Items);
138
+ lastKey = result.LastEvaluatedKey;
139
+ } while (lastKey && items.length < limit);
140
+
141
+ return items;
142
+ }
@@ -0,0 +1,38 @@
1
+ // Heartbeat Lambda handler.
2
+ // Publishes a Heartbeat(timeout) command to the PluginExtensionPoint CommandTopic.
3
+ // Triggered by CloudWatch Events on a schedule.
4
+
5
+ import { reverseConvertToJsonOrThrow } from "sury/src/S.res.mjs";
6
+ import { makeQueueRef } from "./HandlerFactoryHelpers.mjs";
7
+ import { uuid } from "@reventlessdev/reventless-core/src/Message.res.mjs";
8
+ import { name as pluginExtensionPointName, commandSchema } from "@reventlessdev/reventless-infra/src/types/PluginExtensionPointSpec.res.mjs";
9
+ import { publishJsons as sqsPublishJsons } from "@reventlessdev/reventless-aws/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res.mjs";
10
+
11
+ // === Initialize eagerly at module load (Lambda cold start) ===
12
+
13
+ const epQueueUrl = process.env["EP_QUEUE_URL"] || "";
14
+ const pluginId = process.env["PLUGIN_ID"] || "";
15
+ const timeout = parseInt(process.env["HEARTBEAT_TIMEOUT"], 10) || 10;
16
+
17
+ const publishJsons = sqsPublishJsons(makeQueueRef(epQueueUrl), "SQS_FIFO");
18
+
19
+ // === Exported handler ===
20
+
21
+ export async function handler(_event, _context) {
22
+ const msgId = uuid();
23
+ const commandJson = reverseConvertToJsonOrThrow({ TAG: "Heartbeat", _0: timeout }, commandSchema);
24
+ const message = {
25
+ id: pluginId,
26
+ meta: {
27
+ service: pluginExtensionPointName,
28
+ time: new Date().toISOString(),
29
+ ip: "",
30
+ user: "Heartbeat",
31
+ msgId,
32
+ correlationId: msgId,
33
+ },
34
+ commandJson,
35
+ };
36
+ await publishJsons([message]);
37
+ return "";
38
+ }
@@ -0,0 +1,137 @@
1
+ // PluginExtensionPoint Lambda entry point.
2
+ // All imports are framework packages — no user modules needed.
3
+ // Handles Heartbeat, Cloner, and other plugin-level extension point commands.
4
+
5
+ import * as Effect from "effect/Effect";
6
+ import { patchSpecId, makeQueueRef, scanByTableName, log, pluginName } from "./HandlerFactoryHelpers.mjs";
7
+ import { tag as requestContextTag } from "@reventlessdev/reventless-core/src/RequestContext.res.mjs";
8
+ import { sendMessage } from "@reventlessdev/reventless-aws/src/plugin/runtime/Util_PluginMessage_Runtime.res.mjs";
9
+ import * as PluginExtensionPointSpec from "@reventlessdev/reventless-infra/src/types/PluginExtensionPointSpec.res.mjs";
10
+ import { Make as pluginEPPluginMake } from "@reventlessdev/reventless-core/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs";
11
+ import { Make as extensionPointCallbackMake } from "@reventlessdev/reventless-core/src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs";
12
+ import { Make as commandTopicCallbackMake } from "@reventlessdev/reventless-core/src/components/CommandTopic/CommandTopic_Callback.res.mjs";
13
+ import { handleQueueEvent, publishJsons as sqsPublishJsons } from "@reventlessdev/reventless-aws/src/adapter/CommandTopic/CommandTopicChannel_SQS_Runtime.res.mjs";
14
+ import { createSchedule as cwCreateSchedule, deleteSchedule as cwDeleteSchedule } from "@reventlessdev/reventless-aws/src/adapter/ScheduledPublisher/ScheduledPublisher_CloudWatchEvents_Runtime.res.mjs";
15
+
16
+ // Set at handler entry; read by runEffect to tag logs with the Lambda request id.
17
+ let _currentRequestId = "unknown";
18
+
19
+ function runEffect(correlationId, effect) {
20
+ let e = effect
21
+ // Promote correlationId/requestId/plugin to top-level JSON log fields —
22
+ // decoded by EffectLogger.install() from Effect log annotations. Harmless
23
+ // no-op if the unified logger isn't installed.
24
+ .pipe(Effect.annotateLogs("correlationId", correlationId || "unknown"))
25
+ .pipe(Effect.annotateLogs("requestId", _currentRequestId));
26
+ if (pluginName) e = e.pipe(Effect.annotateLogs("plugin", pluginName));
27
+ return e
28
+ .pipe(Effect.provideService(requestContextTag, { correlationId: correlationId || "unknown" }))
29
+ .pipe(Effect.runPromise);
30
+ }
31
+
32
+ function extractCorrelationId(records) {
33
+ const first = records[0];
34
+ if (!first) return undefined;
35
+ const body = first.body;
36
+ if (!body) return undefined;
37
+ try {
38
+ const parsed = JSON.parse(body);
39
+ if (typeof parsed === "object" && parsed !== null) {
40
+ const meta = parsed.meta;
41
+ if (meta && typeof meta === "object" && typeof meta.correlationId === "string") {
42
+ return meta.correlationId;
43
+ }
44
+ }
45
+ } catch (_) {}
46
+ return undefined;
47
+ }
48
+
49
+ function buildHandler() {
50
+ const configStr = process.env["HANDLER_CONFIG"] || "{}";
51
+ const config = JSON.parse(configStr);
52
+
53
+ const patchedSpec = patchSpecId(PluginExtensionPointSpec);
54
+
55
+ // Reconstruct runtimeOps — only sendMessageToChannel is used by this
56
+ // Lambda's incoming-command path (ForwardCommand). Cross-plugin
57
+ // subscribe / unsubscribe directives were retired in Phase 3 Step 3.
58
+ const runtimeOps = {
59
+ messagePublish: { sendMessageToChannel: sendMessage },
60
+ };
61
+
62
+ // Instantiate Plugin EP mapping. updateApiSchema and manageSubscriptions are
63
+ // admin-only hooks; this Lambda only handles incoming commands (Heartbeat,
64
+ // ForwardCommand) so they stay undefined here.
65
+ const lambdaFunctionName = process.env["AWS_LAMBDA_FUNCTION_NAME"] || "unknown";
66
+ const pluginModule = pluginEPPluginMake({
67
+ runtimeOps,
68
+ environment: lambdaFunctionName,
69
+ updateApiSchema: undefined,
70
+ manageSubscriptions: undefined,
71
+ });
72
+ const mappingsModule = { mappings: [pluginModule.Mapping] };
73
+
74
+ // Reconstruct publishToAggregates. The deploy-side builder writes
75
+ // HANDLER_CONFIG.publishToAggregates as { aggregateName: envVarName }
76
+ // (see PluginExtensionPointRuntime_Builder.res), so iterate accordingly.
77
+ const publishToAggregates = {};
78
+ for (const [aggName, envVarName] of Object.entries(config.publishToAggregates || {})) {
79
+ const queueUrl = process.env[envVarName] || "";
80
+ publishToAggregates[aggName] = sqsPublishJsons(makeQueueRef(queueUrl), "SQS_FIFO");
81
+ }
82
+
83
+ // Reconstruct queryEngine
84
+ const queryEngine = {
85
+ scan: (readModelName, filterConfigs, limit) => scanByTableName(config.pluginReadModelTableName, filterConfigs, limit),
86
+ query: async () => { throw new Error("QueryEngine.query not available in bundled Plugin EP handler"); },
87
+ };
88
+
89
+ // Reconstruct scheduler
90
+ const scheduler = {
91
+ createSchedule: cwCreateSchedule(config.schedulerRoleArn),
92
+ deleteSchedule: cwDeleteSchedule,
93
+ };
94
+
95
+ // CommandTopic resources for scheduler targets
96
+ const commandTopicResources = config.schedulerQueueArn !== ""
97
+ ? [{
98
+ name: config.schedulerQueueName,
99
+ id: config.schedulerQueueName,
100
+ urn: config.schedulerQueueArn,
101
+ service: "unknown",
102
+ resourceInfo: "NoInfo",
103
+ role: "",
104
+ region: "",
105
+ resourceType: "",
106
+ configuration: {},
107
+ tags: {},
108
+ }]
109
+ : [];
110
+
111
+ const invalidNameChars = /[^.\-_a-zA-Z0-9]/g;
112
+ const resourceNaming = {
113
+ validateName: (n) => n.replace(invalidNameChars, "_"),
114
+ urnName: (arn) => { const parts = arn.split(":"); return parts[5] || "unknown"; },
115
+ };
116
+
117
+ const callbackConfig = { publishToAggregates, commandTopicResources, scheduler, queryEngine, resourceNaming };
118
+ const callback = extensionPointCallbackMake(callbackConfig)(patchedSpec)(mappingsModule);
119
+ const commandTopicCallback = commandTopicCallbackMake(patchedSpec)({
120
+ Spec: patchedSpec,
121
+ commandsHandler: callback.handleIncomingCommands,
122
+ });
123
+
124
+ return handleQueueEvent(makeQueueRef(config.queueUrl), commandTopicCallback.handleJsonCommands);
125
+ }
126
+
127
+ const sqsHandler = buildHandler();
128
+
129
+ export async function handler(event, context) {
130
+ _currentRequestId = context?.awsRequestId || "unknown";
131
+ const records = event.Records || [];
132
+ const correlationId = extractCorrelationId(records);
133
+
134
+ log.debug("processing " + records.length.toString() + " record(s)", { comp: "PluginExtensionPointRuntime" });
135
+ await runEffect(correlationId, sqsHandler(event, context));
136
+ return "";
137
+ }