@hotmeshio/hotmesh 0.0.4 → 0.0.5

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 (353) hide show
  1. package/README.md +2 -2
  2. package/build/{package.json → cjs/package.json} +12 -5
  3. package/build/{services → cjs/services}/activities/trigger.js +2 -2
  4. package/build/{services → cjs/services}/connector/index.js +3 -3
  5. package/build/{services → cjs/services}/durable/client.js +2 -2
  6. package/build/{services → cjs/services}/durable/connection.js +2 -2
  7. package/build/{services → cjs/services}/hotmesh/index.js +2 -2
  8. package/build/{services → cjs/services}/mapper/index.d.ts +3 -3
  9. package/build/{services → cjs/services}/store/index.js +1 -1
  10. package/build/esm/index.d.ts +4 -0
  11. package/build/esm/index.js +3 -0
  12. package/build/esm/modules/errors.d.ts +28 -0
  13. package/build/esm/modules/errors.js +41 -0
  14. package/build/esm/modules/key.d.ts +75 -0
  15. package/build/esm/modules/key.js +111 -0
  16. package/build/esm/modules/utils.d.ts +34 -0
  17. package/build/esm/modules/utils.js +154 -0
  18. package/build/esm/package.json +80 -0
  19. package/build/esm/services/activities/activity.d.ts +61 -0
  20. package/build/esm/services/activities/activity.js +411 -0
  21. package/build/esm/services/activities/await.d.ts +16 -0
  22. package/build/esm/services/activities/await.js +140 -0
  23. package/build/esm/services/activities/emit.d.ts +9 -0
  24. package/build/esm/services/activities/emit.js +10 -0
  25. package/build/esm/services/activities/index.d.ts +15 -0
  26. package/build/esm/services/activities/index.js +14 -0
  27. package/build/esm/services/activities/iterate.d.ts +9 -0
  28. package/build/esm/services/activities/iterate.js +10 -0
  29. package/build/esm/services/activities/trigger.d.ts +22 -0
  30. package/build/esm/services/activities/trigger.js +158 -0
  31. package/build/esm/services/activities/worker.d.ts +17 -0
  32. package/build/esm/services/activities/worker.js +162 -0
  33. package/build/esm/services/collator/index.d.ts +56 -0
  34. package/build/esm/services/collator/index.js +191 -0
  35. package/build/esm/services/compiler/deployer.d.ts +36 -0
  36. package/build/esm/services/compiler/deployer.js +423 -0
  37. package/build/esm/services/compiler/index.d.ts +30 -0
  38. package/build/esm/services/compiler/index.js +82 -0
  39. package/build/esm/services/compiler/validator.d.ts +32 -0
  40. package/build/esm/services/compiler/validator.js +131 -0
  41. package/build/esm/services/connector/clients/ioredis.d.ts +13 -0
  42. package/build/esm/services/connector/clients/ioredis.js +47 -0
  43. package/build/esm/services/connector/clients/redis.d.ts +13 -0
  44. package/build/esm/services/connector/clients/redis.js +59 -0
  45. package/build/esm/services/connector/index.d.ts +5 -0
  46. package/build/esm/services/connector/index.js +27 -0
  47. package/build/esm/services/dimension/index.d.ts +29 -0
  48. package/build/esm/services/dimension/index.js +32 -0
  49. package/build/esm/services/durable/asyncLocalStorage.d.ts +3 -0
  50. package/build/esm/services/durable/asyncLocalStorage.js +2 -0
  51. package/build/esm/services/durable/client.d.ts +15 -0
  52. package/build/esm/services/durable/client.js +114 -0
  53. package/build/esm/services/durable/connection.d.ts +4 -0
  54. package/build/esm/services/durable/connection.js +47 -0
  55. package/build/esm/services/durable/factory.d.ts +3 -0
  56. package/build/esm/services/durable/factory.js +119 -0
  57. package/build/esm/services/durable/handle.d.ts +8 -0
  58. package/build/esm/services/durable/handle.js +34 -0
  59. package/build/esm/services/durable/index.d.ts +57 -0
  60. package/build/esm/services/durable/index.js +55 -0
  61. package/build/esm/services/durable/native.d.ts +4 -0
  62. package/build/esm/services/durable/native.js +43 -0
  63. package/build/esm/services/durable/worker.d.ts +36 -0
  64. package/build/esm/services/durable/worker.js +258 -0
  65. package/build/esm/services/durable/workflow.d.ts +6 -0
  66. package/build/esm/services/durable/workflow.js +128 -0
  67. package/build/esm/services/engine/index.d.ts +82 -0
  68. package/build/esm/services/engine/index.js +522 -0
  69. package/build/esm/services/hotmesh/index.d.ts +45 -0
  70. package/build/esm/services/hotmesh/index.js +131 -0
  71. package/build/esm/services/logger/index.d.ts +17 -0
  72. package/build/esm/services/logger/index.js +70 -0
  73. package/build/esm/services/mapper/index.d.ts +24 -0
  74. package/build/esm/services/mapper/index.js +69 -0
  75. package/build/esm/services/pipe/functions/array.d.ts +24 -0
  76. package/build/esm/services/pipe/functions/array.js +66 -0
  77. package/build/esm/services/pipe/functions/bitwise.d.ts +9 -0
  78. package/build/esm/services/pipe/functions/bitwise.js +21 -0
  79. package/build/esm/services/pipe/functions/conditional.d.ts +10 -0
  80. package/build/esm/services/pipe/functions/conditional.js +24 -0
  81. package/build/esm/services/pipe/functions/date.d.ts +57 -0
  82. package/build/esm/services/pipe/functions/date.js +164 -0
  83. package/build/esm/services/pipe/functions/index.d.ts +25 -0
  84. package/build/esm/services/pipe/functions/index.js +24 -0
  85. package/build/esm/services/pipe/functions/json.d.ts +5 -0
  86. package/build/esm/services/pipe/functions/json.js +9 -0
  87. package/build/esm/services/pipe/functions/math.d.ts +38 -0
  88. package/build/esm/services/pipe/functions/math.js +108 -0
  89. package/build/esm/services/pipe/functions/number.d.ts +25 -0
  90. package/build/esm/services/pipe/functions/number.js +130 -0
  91. package/build/esm/services/pipe/functions/object.d.ts +22 -0
  92. package/build/esm/services/pipe/functions/object.js +60 -0
  93. package/build/esm/services/pipe/functions/string.d.ts +23 -0
  94. package/build/esm/services/pipe/functions/string.js +66 -0
  95. package/build/esm/services/pipe/functions/symbol.d.ts +12 -0
  96. package/build/esm/services/pipe/functions/symbol.js +30 -0
  97. package/build/esm/services/pipe/functions/unary.d.ts +7 -0
  98. package/build/esm/services/pipe/functions/unary.js +15 -0
  99. package/build/esm/services/pipe/index.d.ts +30 -0
  100. package/build/esm/services/pipe/index.js +122 -0
  101. package/build/esm/services/quorum/index.d.ts +34 -0
  102. package/build/esm/services/quorum/index.js +144 -0
  103. package/build/esm/services/reporter/index.d.ts +47 -0
  104. package/build/esm/services/reporter/index.js +327 -0
  105. package/build/esm/services/serializer/index.d.ts +41 -0
  106. package/build/esm/services/serializer/index.js +251 -0
  107. package/build/esm/services/signaler/store.d.ts +15 -0
  108. package/build/esm/services/signaler/store.js +50 -0
  109. package/build/esm/services/signaler/stream.d.ts +43 -0
  110. package/build/esm/services/signaler/stream.js +315 -0
  111. package/build/esm/services/store/cache.d.ts +66 -0
  112. package/build/esm/services/store/cache.js +124 -0
  113. package/build/esm/services/store/clients/ioredis.d.ts +27 -0
  114. package/build/esm/services/store/clients/ioredis.js +93 -0
  115. package/build/esm/services/store/clients/redis.d.ts +29 -0
  116. package/build/esm/services/store/clients/redis.js +140 -0
  117. package/build/esm/services/store/index.d.ts +88 -0
  118. package/build/esm/services/store/index.js +623 -0
  119. package/build/esm/services/stream/clients/ioredis.d.ts +23 -0
  120. package/build/esm/services/stream/clients/ioredis.js +112 -0
  121. package/build/esm/services/stream/clients/redis.d.ts +23 -0
  122. package/build/esm/services/stream/clients/redis.js +116 -0
  123. package/build/esm/services/stream/index.d.ts +21 -0
  124. package/build/esm/services/stream/index.js +6 -0
  125. package/build/esm/services/sub/clients/ioredis.d.ts +20 -0
  126. package/build/esm/services/sub/clients/ioredis.js +69 -0
  127. package/build/esm/services/sub/clients/redis.d.ts +20 -0
  128. package/build/esm/services/sub/clients/redis.js +60 -0
  129. package/build/esm/services/sub/index.d.ts +18 -0
  130. package/build/esm/services/sub/index.js +6 -0
  131. package/build/esm/services/task/index.d.ts +18 -0
  132. package/build/esm/services/task/index.js +70 -0
  133. package/build/esm/services/telemetry/index.d.ts +49 -0
  134. package/build/esm/services/telemetry/index.js +217 -0
  135. package/build/esm/services/worker/index.d.ts +30 -0
  136. package/build/esm/services/worker/index.js +102 -0
  137. package/build/esm/types/activity.d.ts +87 -0
  138. package/build/esm/types/activity.js +1 -0
  139. package/build/esm/types/app.d.ts +16 -0
  140. package/build/esm/types/app.js +1 -0
  141. package/build/esm/types/async.d.ts +5 -0
  142. package/build/esm/types/async.js +1 -0
  143. package/build/esm/types/cache.d.ts +1 -0
  144. package/build/esm/types/cache.js +1 -0
  145. package/build/esm/types/collator.d.ts +8 -0
  146. package/build/esm/types/collator.js +8 -0
  147. package/build/esm/types/durable.d.ts +59 -0
  148. package/build/esm/types/durable.js +1 -0
  149. package/build/esm/types/hook.d.ts +31 -0
  150. package/build/esm/types/hook.js +6 -0
  151. package/build/esm/types/hotmesh.d.ts +82 -0
  152. package/build/esm/types/hotmesh.js +1 -0
  153. package/build/esm/types/index.d.ts +20 -0
  154. package/build/esm/types/index.js +5 -0
  155. package/build/esm/types/ioredisclient.d.ts +5 -0
  156. package/build/esm/types/ioredisclient.js +2 -0
  157. package/build/esm/types/job.d.ts +50 -0
  158. package/build/esm/types/job.js +1 -0
  159. package/build/esm/types/logger.d.ts +6 -0
  160. package/build/esm/types/logger.js +1 -0
  161. package/build/esm/types/map.d.ts +4 -0
  162. package/build/esm/types/map.js +1 -0
  163. package/build/esm/types/pipe.d.ts +4 -0
  164. package/build/esm/types/pipe.js +1 -0
  165. package/build/esm/types/quorum.d.ts +46 -0
  166. package/build/esm/types/quorum.js +1 -0
  167. package/build/esm/types/redis.d.ts +8 -0
  168. package/build/esm/types/redis.js +1 -0
  169. package/build/esm/types/redisclient.d.ts +25 -0
  170. package/build/esm/types/redisclient.js +1 -0
  171. package/build/esm/types/serializer.d.ts +33 -0
  172. package/build/esm/types/serializer.js +1 -0
  173. package/build/esm/types/stats.d.ts +83 -0
  174. package/build/esm/types/stats.js +1 -0
  175. package/build/esm/types/stream.d.ts +67 -0
  176. package/build/esm/types/stream.js +22 -0
  177. package/build/esm/types/telemetry.d.ts +1 -0
  178. package/build/esm/types/telemetry.js +1 -0
  179. package/build/esm/types/transition.d.ts +17 -0
  180. package/build/esm/types/transition.js +1 -0
  181. package/package.json +12 -5
  182. package/services/activities/trigger.ts +2 -2
  183. package/services/connector/index.ts +3 -3
  184. package/services/durable/client.ts +2 -2
  185. package/services/durable/connection.ts +2 -2
  186. package/services/hotmesh/index.ts +2 -2
  187. package/services/mapper/index.ts +6 -7
  188. package/services/store/index.ts +3 -3
  189. package/tsconfig.cjs.json +8 -0
  190. package/tsconfig.esm.json +9 -0
  191. /package/build/{index.d.ts → cjs/index.d.ts} +0 -0
  192. /package/build/{index.js → cjs/index.js} +0 -0
  193. /package/build/{modules → cjs/modules}/errors.d.ts +0 -0
  194. /package/build/{modules → cjs/modules}/errors.js +0 -0
  195. /package/build/{modules → cjs/modules}/key.d.ts +0 -0
  196. /package/build/{modules → cjs/modules}/key.js +0 -0
  197. /package/build/{modules → cjs/modules}/utils.d.ts +0 -0
  198. /package/build/{modules → cjs/modules}/utils.js +0 -0
  199. /package/build/{services → cjs/services}/activities/activity.d.ts +0 -0
  200. /package/build/{services → cjs/services}/activities/activity.js +0 -0
  201. /package/build/{services → cjs/services}/activities/await.d.ts +0 -0
  202. /package/build/{services → cjs/services}/activities/await.js +0 -0
  203. /package/build/{services → cjs/services}/activities/emit.d.ts +0 -0
  204. /package/build/{services → cjs/services}/activities/emit.js +0 -0
  205. /package/build/{services → cjs/services}/activities/index.d.ts +0 -0
  206. /package/build/{services → cjs/services}/activities/index.js +0 -0
  207. /package/build/{services → cjs/services}/activities/iterate.d.ts +0 -0
  208. /package/build/{services → cjs/services}/activities/iterate.js +0 -0
  209. /package/build/{services → cjs/services}/activities/trigger.d.ts +0 -0
  210. /package/build/{services → cjs/services}/activities/worker.d.ts +0 -0
  211. /package/build/{services → cjs/services}/activities/worker.js +0 -0
  212. /package/build/{services → cjs/services}/collator/index.d.ts +0 -0
  213. /package/build/{services → cjs/services}/collator/index.js +0 -0
  214. /package/build/{services → cjs/services}/compiler/deployer.d.ts +0 -0
  215. /package/build/{services → cjs/services}/compiler/deployer.js +0 -0
  216. /package/build/{services → cjs/services}/compiler/index.d.ts +0 -0
  217. /package/build/{services → cjs/services}/compiler/index.js +0 -0
  218. /package/build/{services → cjs/services}/compiler/validator.d.ts +0 -0
  219. /package/build/{services → cjs/services}/compiler/validator.js +0 -0
  220. /package/build/{services → cjs/services}/connector/clients/ioredis.d.ts +0 -0
  221. /package/build/{services → cjs/services}/connector/clients/ioredis.js +0 -0
  222. /package/build/{services → cjs/services}/connector/clients/redis.d.ts +0 -0
  223. /package/build/{services → cjs/services}/connector/clients/redis.js +0 -0
  224. /package/build/{services → cjs/services}/connector/index.d.ts +0 -0
  225. /package/build/{services → cjs/services}/dimension/index.d.ts +0 -0
  226. /package/build/{services → cjs/services}/dimension/index.js +0 -0
  227. /package/build/{services → cjs/services}/durable/asyncLocalStorage.d.ts +0 -0
  228. /package/build/{services → cjs/services}/durable/asyncLocalStorage.js +0 -0
  229. /package/build/{services → cjs/services}/durable/client.d.ts +0 -0
  230. /package/build/{services → cjs/services}/durable/connection.d.ts +0 -0
  231. /package/build/{services → cjs/services}/durable/factory.d.ts +0 -0
  232. /package/build/{services → cjs/services}/durable/factory.js +0 -0
  233. /package/build/{services → cjs/services}/durable/handle.d.ts +0 -0
  234. /package/build/{services → cjs/services}/durable/handle.js +0 -0
  235. /package/build/{services → cjs/services}/durable/index.d.ts +0 -0
  236. /package/build/{services → cjs/services}/durable/index.js +0 -0
  237. /package/build/{services → cjs/services}/durable/native.d.ts +0 -0
  238. /package/build/{services → cjs/services}/durable/native.js +0 -0
  239. /package/build/{services → cjs/services}/durable/worker.d.ts +0 -0
  240. /package/build/{services → cjs/services}/durable/worker.js +0 -0
  241. /package/build/{services → cjs/services}/durable/workflow.d.ts +0 -0
  242. /package/build/{services → cjs/services}/durable/workflow.js +0 -0
  243. /package/build/{services → cjs/services}/engine/index.d.ts +0 -0
  244. /package/build/{services → cjs/services}/engine/index.js +0 -0
  245. /package/build/{services → cjs/services}/hotmesh/index.d.ts +0 -0
  246. /package/build/{services → cjs/services}/logger/index.d.ts +0 -0
  247. /package/build/{services → cjs/services}/logger/index.js +0 -0
  248. /package/build/{services → cjs/services}/mapper/index.js +0 -0
  249. /package/build/{services → cjs/services}/pipe/functions/array.d.ts +0 -0
  250. /package/build/{services → cjs/services}/pipe/functions/array.js +0 -0
  251. /package/build/{services → cjs/services}/pipe/functions/bitwise.d.ts +0 -0
  252. /package/build/{services → cjs/services}/pipe/functions/bitwise.js +0 -0
  253. /package/build/{services → cjs/services}/pipe/functions/conditional.d.ts +0 -0
  254. /package/build/{services → cjs/services}/pipe/functions/conditional.js +0 -0
  255. /package/build/{services → cjs/services}/pipe/functions/date.d.ts +0 -0
  256. /package/build/{services → cjs/services}/pipe/functions/date.js +0 -0
  257. /package/build/{services → cjs/services}/pipe/functions/index.d.ts +0 -0
  258. /package/build/{services → cjs/services}/pipe/functions/index.js +0 -0
  259. /package/build/{services → cjs/services}/pipe/functions/json.d.ts +0 -0
  260. /package/build/{services → cjs/services}/pipe/functions/json.js +0 -0
  261. /package/build/{services → cjs/services}/pipe/functions/math.d.ts +0 -0
  262. /package/build/{services → cjs/services}/pipe/functions/math.js +0 -0
  263. /package/build/{services → cjs/services}/pipe/functions/number.d.ts +0 -0
  264. /package/build/{services → cjs/services}/pipe/functions/number.js +0 -0
  265. /package/build/{services → cjs/services}/pipe/functions/object.d.ts +0 -0
  266. /package/build/{services → cjs/services}/pipe/functions/object.js +0 -0
  267. /package/build/{services → cjs/services}/pipe/functions/string.d.ts +0 -0
  268. /package/build/{services → cjs/services}/pipe/functions/string.js +0 -0
  269. /package/build/{services → cjs/services}/pipe/functions/symbol.d.ts +0 -0
  270. /package/build/{services → cjs/services}/pipe/functions/symbol.js +0 -0
  271. /package/build/{services → cjs/services}/pipe/functions/unary.d.ts +0 -0
  272. /package/build/{services → cjs/services}/pipe/functions/unary.js +0 -0
  273. /package/build/{services → cjs/services}/pipe/index.d.ts +0 -0
  274. /package/build/{services → cjs/services}/pipe/index.js +0 -0
  275. /package/build/{services → cjs/services}/quorum/index.d.ts +0 -0
  276. /package/build/{services → cjs/services}/quorum/index.js +0 -0
  277. /package/build/{services → cjs/services}/reporter/index.d.ts +0 -0
  278. /package/build/{services → cjs/services}/reporter/index.js +0 -0
  279. /package/build/{services → cjs/services}/serializer/index.d.ts +0 -0
  280. /package/build/{services → cjs/services}/serializer/index.js +0 -0
  281. /package/build/{services → cjs/services}/signaler/store.d.ts +0 -0
  282. /package/build/{services → cjs/services}/signaler/store.js +0 -0
  283. /package/build/{services → cjs/services}/signaler/stream.d.ts +0 -0
  284. /package/build/{services → cjs/services}/signaler/stream.js +0 -0
  285. /package/build/{services → cjs/services}/store/cache.d.ts +0 -0
  286. /package/build/{services → cjs/services}/store/cache.js +0 -0
  287. /package/build/{services → cjs/services}/store/clients/ioredis.d.ts +0 -0
  288. /package/build/{services → cjs/services}/store/clients/ioredis.js +0 -0
  289. /package/build/{services → cjs/services}/store/clients/redis.d.ts +0 -0
  290. /package/build/{services → cjs/services}/store/clients/redis.js +0 -0
  291. /package/build/{services → cjs/services}/store/index.d.ts +0 -0
  292. /package/build/{services → cjs/services}/stream/clients/ioredis.d.ts +0 -0
  293. /package/build/{services → cjs/services}/stream/clients/ioredis.js +0 -0
  294. /package/build/{services → cjs/services}/stream/clients/redis.d.ts +0 -0
  295. /package/build/{services → cjs/services}/stream/clients/redis.js +0 -0
  296. /package/build/{services → cjs/services}/stream/index.d.ts +0 -0
  297. /package/build/{services → cjs/services}/stream/index.js +0 -0
  298. /package/build/{services → cjs/services}/sub/clients/ioredis.d.ts +0 -0
  299. /package/build/{services → cjs/services}/sub/clients/ioredis.js +0 -0
  300. /package/build/{services → cjs/services}/sub/clients/redis.d.ts +0 -0
  301. /package/build/{services → cjs/services}/sub/clients/redis.js +0 -0
  302. /package/build/{services → cjs/services}/sub/index.d.ts +0 -0
  303. /package/build/{services → cjs/services}/sub/index.js +0 -0
  304. /package/build/{services → cjs/services}/task/index.d.ts +0 -0
  305. /package/build/{services → cjs/services}/task/index.js +0 -0
  306. /package/build/{services → cjs/services}/telemetry/index.d.ts +0 -0
  307. /package/build/{services → cjs/services}/telemetry/index.js +0 -0
  308. /package/build/{services → cjs/services}/worker/index.d.ts +0 -0
  309. /package/build/{services → cjs/services}/worker/index.js +0 -0
  310. /package/build/{types → cjs/types}/activity.d.ts +0 -0
  311. /package/build/{types → cjs/types}/activity.js +0 -0
  312. /package/build/{types → cjs/types}/app.d.ts +0 -0
  313. /package/build/{types → cjs/types}/app.js +0 -0
  314. /package/build/{types → cjs/types}/async.d.ts +0 -0
  315. /package/build/{types → cjs/types}/async.js +0 -0
  316. /package/build/{types → cjs/types}/cache.d.ts +0 -0
  317. /package/build/{types → cjs/types}/cache.js +0 -0
  318. /package/build/{types → cjs/types}/collator.d.ts +0 -0
  319. /package/build/{types → cjs/types}/collator.js +0 -0
  320. /package/build/{types → cjs/types}/durable.d.ts +0 -0
  321. /package/build/{types → cjs/types}/durable.js +0 -0
  322. /package/build/{types → cjs/types}/hook.d.ts +0 -0
  323. /package/build/{types → cjs/types}/hook.js +0 -0
  324. /package/build/{types → cjs/types}/hotmesh.d.ts +0 -0
  325. /package/build/{types → cjs/types}/hotmesh.js +0 -0
  326. /package/build/{types → cjs/types}/index.d.ts +0 -0
  327. /package/build/{types → cjs/types}/index.js +0 -0
  328. /package/build/{types → cjs/types}/ioredisclient.d.ts +0 -0
  329. /package/build/{types → cjs/types}/ioredisclient.js +0 -0
  330. /package/build/{types → cjs/types}/job.d.ts +0 -0
  331. /package/build/{types → cjs/types}/job.js +0 -0
  332. /package/build/{types → cjs/types}/logger.d.ts +0 -0
  333. /package/build/{types → cjs/types}/logger.js +0 -0
  334. /package/build/{types → cjs/types}/map.d.ts +0 -0
  335. /package/build/{types → cjs/types}/map.js +0 -0
  336. /package/build/{types → cjs/types}/pipe.d.ts +0 -0
  337. /package/build/{types → cjs/types}/pipe.js +0 -0
  338. /package/build/{types → cjs/types}/quorum.d.ts +0 -0
  339. /package/build/{types → cjs/types}/quorum.js +0 -0
  340. /package/build/{types → cjs/types}/redis.d.ts +0 -0
  341. /package/build/{types → cjs/types}/redis.js +0 -0
  342. /package/build/{types → cjs/types}/redisclient.d.ts +0 -0
  343. /package/build/{types → cjs/types}/redisclient.js +0 -0
  344. /package/build/{types → cjs/types}/serializer.d.ts +0 -0
  345. /package/build/{types → cjs/types}/serializer.js +0 -0
  346. /package/build/{types → cjs/types}/stats.d.ts +0 -0
  347. /package/build/{types → cjs/types}/stats.js +0 -0
  348. /package/build/{types → cjs/types}/stream.d.ts +0 -0
  349. /package/build/{types → cjs/types}/stream.js +0 -0
  350. /package/build/{types → cjs/types}/telemetry.d.ts +0 -0
  351. /package/build/{types → cjs/types}/telemetry.js +0 -0
  352. /package/build/{types → cjs/types}/transition.d.ts +0 -0
  353. /package/build/{types → cjs/types}/transition.js +0 -0
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@hotmeshio/hotmesh",
3
+ "version": "0.0.5",
4
+ "description": "Durable Workflows",
5
+ "main": "build/cjs/index.js",
6
+ "module": "build/esm/index.js",
7
+ "types": "build/cjs/index.d.ts",
8
+ "exports": {
9
+ "import": "./build/esm/index.js",
10
+ "require": "./build/cjs/index.js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/hotmeshio/sdk-typescript.git"
15
+ },
16
+ "homepage": "https://github.com/hotmeshio/sdk-typescript#readme",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "scripts": {
21
+ "clean": "rimraf ./build",
22
+ "build:cjs": "tsc --build tsconfig.cjs.json",
23
+ "build:esm": "tsc --build tsconfig.esm.json",
24
+ "build": "npm run build:cjs && npm run build:esm",
25
+ "clean-build": "npm run clean && npm run build",
26
+ "lint": "eslint . --ext .ts",
27
+ "lint:fix": "eslint . --fix --ext .ts",
28
+ "start": "ts-node src/index.ts",
29
+ "test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
30
+ "test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
31
+ "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
32
+ "test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/index.test.ts --detectOpenHandles --forceExit --verbose",
33
+ "test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
34
+ "test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
35
+ "test:parallel": "NODE_ENV=test jest ./tests/functional/parallel/index.test.ts --detectOpenHandles --forceExit --verbose",
36
+ "test:sequence": "NODE_ENV=test jest ./tests/functional/sequence/index.test.ts --detectOpenHandles --forceExit --verbose",
37
+ "test:quorum": "NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
38
+ "test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
39
+ "test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/index.test.ts --detectOpenHandles --forceExit --verbose",
40
+ "test:retry": "NODE_ENV=test jest ./tests/functional/retry/index.test.ts --detectOpenHandles --forceExit --verbose",
41
+ "test:status": "NODE_ENV=test jest ./tests/functional/status/index.test.ts --detectOpenHandles --forceExit --verbose",
42
+ "test:store:redis": "NODE_ENV=test jest ./tests/functional/store/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
43
+ "test:store:ioredis": "NODE_ENV=test jest ./tests/functional/store/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
44
+ "test:stream:redis": "NODE_ENV=test jest ./tests/functional/stream/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
45
+ "test:stream:ioredis": "NODE_ENV=test jest ./tests/functional/stream/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
46
+ "test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
47
+ "test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
48
+ "test:durable": "NODE_ENV=test jest ./tests/durable/*/index.test.ts --detectOpenHandles --forceExit --verbose",
49
+ "test:durable:hello": "NODE_ENV=test jest ./tests/durable/helloworld/index.test.ts --detectOpenHandles --forceExit --verbose",
50
+ "test:durable:goodbye": "NODE_ENV=test jest ./tests/durable/goodbye/index.test.ts --detectOpenHandles --forceExit --verbose",
51
+ "test:durable:loopactivity": "NODE_ENV=test jest ./tests/durable/loopactivity/index.test.ts --detectOpenHandles --forceExit --verbose",
52
+ "test:durable:nested": "NODE_ENV=test jest ./tests/durable/nested/index.test.ts --detectOpenHandles --forceExit --verbose"
53
+ },
54
+ "keywords": [],
55
+ "author": "luke.birdeau@gmail.com",
56
+ "license": "SEE LICENSE IN LICENSE",
57
+ "dependencies": {
58
+ "@apidevtools/json-schema-ref-parser": "^10.1.0",
59
+ "@opentelemetry/api": "^1.4.1",
60
+ "js-yaml": "^4.1.0",
61
+ "ms": "^2.1.3",
62
+ "uuid": "^9.0.1",
63
+ "winston": "^3.8.2"
64
+ },
65
+ "devDependencies": {
66
+ "@types/jest": "^29.5.0",
67
+ "@types/node": "^18.15.11",
68
+ "@typescript-eslint/eslint-plugin": "^5.56.0",
69
+ "@typescript-eslint/parser": "^5.56.0",
70
+ "eslint": "^8.36.0",
71
+ "ioredis": "^5.3.2",
72
+ "jest": "^29.5.0",
73
+ "redis": "^4.6.6",
74
+ "rimraf": "^4.4.1",
75
+ "ts-jest": "^29.0.5",
76
+ "ts-node": "^10.9.1",
77
+ "ts-node-dev": "^2.0.0",
78
+ "typescript": "^5.0.4"
79
+ }
80
+ }
@@ -0,0 +1,61 @@
1
+ import { EngineService } from '../engine';
2
+ import { ILogger } from '../logger';
3
+ import { StoreService } from '../store';
4
+ import { ActivityData, ActivityLeg, ActivityMetadata, ActivityType } from '../../types/activity';
5
+ import { JobState, JobStatus } from '../../types/job';
6
+ import { MultiResponseFlags, RedisClient, RedisMulti } from '../../types/redis';
7
+ import { StringAnyType } from '../../types/serializer';
8
+ import { StreamCode, StreamData, StreamStatus } from '../../types/stream';
9
+ /**
10
+ * The base class for all activities
11
+ */
12
+ declare class Activity {
13
+ config: ActivityType;
14
+ data: ActivityData;
15
+ hook: ActivityData;
16
+ metadata: ActivityMetadata;
17
+ store: StoreService<RedisClient, RedisMulti>;
18
+ context: JobState;
19
+ engine: EngineService;
20
+ logger: ILogger;
21
+ status: StreamStatus;
22
+ code: StreamCode;
23
+ leg: ActivityLeg;
24
+ adjacencyList: StreamData[];
25
+ adjacentIndex: number;
26
+ constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
27
+ process(): Promise<string>;
28
+ setLeg(leg: ActivityLeg): void;
29
+ doesHook(): boolean;
30
+ registerHook(multi?: RedisMulti): Promise<string | void>;
31
+ processWebHookEvent(): Promise<JobStatus | void>;
32
+ processTimeHookEvent(jobId: string): Promise<JobStatus | void>;
33
+ processHookEvent(jobId: string): Promise<JobStatus | void>;
34
+ resolveStatus(multiResponse: MultiResponseFlags): number;
35
+ mapJobData(): void;
36
+ mapInputData(): void;
37
+ registerTimeout(): Promise<void>;
38
+ bindActivityError(data: Record<string, unknown>): void;
39
+ getTriggerConfig(): Promise<ActivityType>;
40
+ getJobStatus(): null | number;
41
+ setStatus(amount: number, multi?: RedisMulti): Promise<void>;
42
+ authorizeEntry(state: StringAnyType): string[];
43
+ bindDimensionalAddress(state: StringAnyType): void;
44
+ setState(multi?: RedisMulti): Promise<string>;
45
+ bindJobMetadata(): void;
46
+ bindActivityMetadata(): void;
47
+ bindJobState(state: StringAnyType): Promise<void>;
48
+ bindActivityState(state: StringAnyType): void;
49
+ bindJobMetadataPaths(): string[];
50
+ bindActivityMetadataPaths(): string[];
51
+ getState(jobId?: string): Promise<void>;
52
+ initDimensionalAddress(dad: string): void;
53
+ initSelf(context: StringAnyType): JobState;
54
+ initPolicies(context: JobState): void;
55
+ bindActivityData(type: 'output' | 'hook'): void;
56
+ resolveDad(): string;
57
+ resolveAdjacentDad(): string;
58
+ filterAdjacent(): Promise<StreamData[]>;
59
+ transition(adjacencyList: StreamData[], jobStatus: JobStatus): Promise<string[]>;
60
+ }
61
+ export { Activity, ActivityType };
@@ -0,0 +1,411 @@
1
+ import { GetStateError } from '../../modules/errors';
2
+ import { formatISODate, getValueByPath, restoreHierarchy } from '../../modules/utils';
3
+ import { CollatorService } from '../collator';
4
+ import { DimensionService } from '../dimension';
5
+ import { MapperService } from '../mapper';
6
+ import { Pipe } from '../pipe';
7
+ import { MDATA_SYMBOLS } from '../serializer';
8
+ import { StoreSignaler } from '../signaler/store';
9
+ import { TelemetryService } from '../telemetry';
10
+ import { StreamDataType, StreamStatus } from '../../types/stream';
11
+ /**
12
+ * The base class for all activities
13
+ */
14
+ class Activity {
15
+ constructor(config, data, metadata, hook, engine, context) {
16
+ this.status = StreamStatus.SUCCESS;
17
+ this.code = 200;
18
+ this.adjacentIndex = 0; //can be updated by leg2 using 'as' metadata hincrby output
19
+ this.config = config;
20
+ this.data = data;
21
+ this.metadata = metadata;
22
+ this.hook = hook;
23
+ this.engine = engine;
24
+ this.context = context || { data: {}, metadata: {} };
25
+ this.logger = engine.logger;
26
+ this.store = engine.store;
27
+ }
28
+ //******** INITIAL ENTRY POINT (A) ********//
29
+ async process() {
30
+ this.logger.debug('activity-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
31
+ let telemetry;
32
+ try {
33
+ this.setLeg(1);
34
+ await CollatorService.notarizeEntry(this);
35
+ await this.getState();
36
+ telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
37
+ telemetry.startActivitySpan(this.leg);
38
+ let multiResponse;
39
+ const multi = this.store.getMulti();
40
+ if (this.doesHook()) {
41
+ //sleep and wait to awaken upon a signal
42
+ await this.registerHook(multi);
43
+ this.mapJobData();
44
+ await this.setState(multi);
45
+ await CollatorService.authorizeReentry(this, multi);
46
+ await this.setStatus(0, multi);
47
+ await multi.exec();
48
+ telemetry.mapActivityAttributes();
49
+ }
50
+ else {
51
+ //end the activity and transition to its children
52
+ this.adjacencyList = await this.filterAdjacent();
53
+ this.mapJobData();
54
+ await this.setState(multi);
55
+ await CollatorService.notarizeEarlyCompletion(this, multi);
56
+ await this.setStatus(this.adjacencyList.length - 1, multi);
57
+ multiResponse = await multi.exec();
58
+ telemetry.mapActivityAttributes();
59
+ const jobStatus = this.resolveStatus(multiResponse);
60
+ const attrs = { 'app.job.jss': jobStatus };
61
+ const messageIds = await this.transition(this.adjacencyList, jobStatus);
62
+ if (messageIds.length) {
63
+ attrs['app.activity.mids'] = messageIds.join(',');
64
+ }
65
+ telemetry.setActivityAttributes(attrs);
66
+ }
67
+ return this.context.metadata.aid;
68
+ }
69
+ catch (error) {
70
+ if (error instanceof GetStateError) {
71
+ this.logger.error('activity-get-state-error', error);
72
+ }
73
+ else {
74
+ this.logger.error('activity-process-error', error);
75
+ }
76
+ telemetry.setActivityError(error.message);
77
+ throw error;
78
+ }
79
+ finally {
80
+ telemetry.endActivitySpan();
81
+ this.logger.debug('activity-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
82
+ }
83
+ }
84
+ setLeg(leg) {
85
+ this.leg = leg;
86
+ }
87
+ //******** SIGNALER RE-ENTRY POINT (B) ********//
88
+ doesHook() {
89
+ return !!(this.config.hook?.topic || this.config.sleep);
90
+ }
91
+ async registerHook(multi) {
92
+ if (this.config.hook?.topic) {
93
+ const signaler = new StoreSignaler(this.store, this.logger);
94
+ return await signaler.registerWebHook(this.config.hook.topic, this.context, multi);
95
+ }
96
+ else if (this.config.sleep) {
97
+ const durationInSeconds = Pipe.resolve(this.config.sleep, this.context);
98
+ const jobId = this.context.metadata.jid;
99
+ const activityId = this.metadata.aid;
100
+ const dId = this.metadata.dad;
101
+ await this.engine.task.registerTimeHook(jobId, `${activityId}${dId || ''}`, 'sleep', durationInSeconds);
102
+ return jobId;
103
+ }
104
+ }
105
+ async processWebHookEvent() {
106
+ this.logger.debug('engine-process-web-hook-event', {
107
+ topic: this.config.hook.topic,
108
+ aid: this.metadata.aid
109
+ });
110
+ const signaler = new StoreSignaler(this.store, this.logger);
111
+ const data = { ...this.data };
112
+ const jobId = await signaler.processWebHookSignal(this.config.hook.topic, data);
113
+ if (jobId) {
114
+ await this.processHookEvent(jobId);
115
+ await signaler.deleteWebHookSignal(this.config.hook.topic, data);
116
+ } //else => already resolved
117
+ }
118
+ async processTimeHookEvent(jobId) {
119
+ this.logger.debug('engine-process-time-hook-event', {
120
+ jid: jobId,
121
+ aid: this.metadata.aid
122
+ });
123
+ return await this.processHookEvent(jobId);
124
+ }
125
+ //todo: hooks are currently singletons. but they can support
126
+ // dimensional threads like `await` and `worker` do.
127
+ // Copy code from those activities to support cyclical
128
+ // timehook and eventhook inputs by adding a 'pending'
129
+ // flag to hooks that allows for repeated signals
130
+ async processHookEvent(jobId) {
131
+ this.logger.debug('activity-process-hook-event', { jobId });
132
+ let telemetry;
133
+ try {
134
+ this.setLeg(2);
135
+ await this.getState(jobId);
136
+ const aState = await CollatorService.notarizeReentry(this);
137
+ this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
138
+ telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
139
+ telemetry.startActivitySpan(this.leg);
140
+ this.bindActivityData('hook');
141
+ this.mapJobData();
142
+ this.adjacencyList = await this.filterAdjacent();
143
+ const multi = this.engine.store.getMulti();
144
+ await this.setState(multi);
145
+ await CollatorService.notarizeCompletion(this, multi);
146
+ await this.setStatus(this.adjacencyList.length - 1, multi);
147
+ const multiResponse = await multi.exec();
148
+ telemetry.mapActivityAttributes();
149
+ const jobStatus = this.resolveStatus(multiResponse);
150
+ const attrs = { 'app.job.jss': jobStatus };
151
+ const messageIds = await this.transition(this.adjacencyList, jobStatus);
152
+ if (messageIds.length) {
153
+ attrs['app.activity.mids'] = messageIds.join(',');
154
+ }
155
+ telemetry.setActivityAttributes(attrs);
156
+ return jobStatus;
157
+ }
158
+ catch (error) {
159
+ console.error('this error?', error);
160
+ this.logger.error('engine-process-hook-event-error', error);
161
+ telemetry.setActivityError(error.message);
162
+ throw error;
163
+ }
164
+ finally {
165
+ telemetry.endActivitySpan();
166
+ }
167
+ }
168
+ resolveStatus(multiResponse) {
169
+ const activityStatus = multiResponse[multiResponse.length - 1];
170
+ if (Array.isArray(activityStatus)) {
171
+ return Number(activityStatus[1]);
172
+ }
173
+ else {
174
+ return Number(activityStatus);
175
+ }
176
+ }
177
+ mapJobData() {
178
+ if (this.config.job?.maps) {
179
+ const mapper = new MapperService(this.config.job.maps, this.context);
180
+ this.context.data = mapper.mapRules();
181
+ }
182
+ }
183
+ mapInputData() {
184
+ if (this.config.input?.maps) {
185
+ const mapper = new MapperService(this.config.input.maps, this.context);
186
+ this.context.data = mapper.mapRules();
187
+ }
188
+ }
189
+ async registerTimeout() {
190
+ //set timeout in support of hook and/or duplex
191
+ }
192
+ bindActivityError(data) {
193
+ //todo: map activity error data into the job error (if defined)
194
+ // map job status via: (500: [3**, 4**, 5**], 202: [$pending])
195
+ this.context.metadata.err = JSON.stringify(data);
196
+ }
197
+ async getTriggerConfig() {
198
+ return await this.store.getSchema(this.config.trigger, await this.engine.getVID());
199
+ }
200
+ getJobStatus() {
201
+ return null;
202
+ }
203
+ async setStatus(amount, multi) {
204
+ const { id: appId } = await this.engine.getVID();
205
+ await this.store.setStatus(amount, this.context.metadata.jid, appId, multi);
206
+ }
207
+ authorizeEntry(state) {
208
+ //pre-authorize activity state to allow entry for adjacent activities
209
+ return this.adjacencyList?.map((streamData) => {
210
+ const { metadata: { aid } } = streamData;
211
+ state[`${aid}/output/metadata/as`] = CollatorService.getSeed();
212
+ return aid;
213
+ }) ?? [];
214
+ }
215
+ bindDimensionalAddress(state) {
216
+ const dad = this.resolveDad();
217
+ state[`${this.metadata.aid}/output/metadata/dad`] = dad;
218
+ }
219
+ async setState(multi) {
220
+ const jobId = this.context.metadata.jid;
221
+ this.bindJobMetadata();
222
+ this.bindActivityMetadata();
223
+ let state = {};
224
+ await this.bindJobState(state);
225
+ const presets = this.authorizeEntry(state);
226
+ this.bindDimensionalAddress(state);
227
+ this.bindActivityState(state);
228
+ //symbolNames holds symkeys
229
+ const symbolNames = [
230
+ `$${this.config.subscribes}`,
231
+ this.metadata.aid,
232
+ ...presets
233
+ ];
234
+ const dIds = CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], this.resolveDad());
235
+ return await this.store.setState(state, this.getJobStatus(), jobId, symbolNames, dIds, multi);
236
+ }
237
+ bindJobMetadata() {
238
+ //both legs of the most recently run activity (1 and 2) modify ju (job_updated)
239
+ this.context.metadata.ju = formatISODate(new Date());
240
+ }
241
+ bindActivityMetadata() {
242
+ const self = this.context['$self'];
243
+ if (!self.output.metadata) {
244
+ self.output.metadata = {};
245
+ }
246
+ if (this.status === StreamStatus.ERROR) {
247
+ self.output.metadata.err = JSON.stringify(this.data);
248
+ }
249
+ //todo: verify leg2 never overwrites leg1 `ac`
250
+ self.output.metadata.ac =
251
+ self.output.metadata.au = formatISODate(new Date());
252
+ self.output.metadata.atp = this.config.type;
253
+ if (this.config.subtype) {
254
+ self.output.metadata.stp = this.config.subtype;
255
+ }
256
+ self.output.metadata.aid = this.metadata.aid;
257
+ }
258
+ async bindJobState(state) {
259
+ const triggerConfig = await this.getTriggerConfig();
260
+ const PRODUCES = [
261
+ ...(triggerConfig.PRODUCES || []),
262
+ ...this.bindJobMetadataPaths()
263
+ ];
264
+ for (const path of PRODUCES) {
265
+ const value = getValueByPath(this.context, path);
266
+ if (value !== undefined) {
267
+ state[path] = value;
268
+ }
269
+ }
270
+ TelemetryService.bindJobTelemetryToState(state, this.config, this.context);
271
+ }
272
+ bindActivityState(state) {
273
+ const produces = [
274
+ ...this.config.produces,
275
+ ...this.bindActivityMetadataPaths()
276
+ ];
277
+ for (const path of produces) {
278
+ const prefixedPath = `${this.metadata.aid}/${path}`;
279
+ const value = getValueByPath(this.context, prefixedPath);
280
+ if (value !== undefined) {
281
+ state[prefixedPath] = value;
282
+ }
283
+ }
284
+ TelemetryService.bindActivityTelemetryToState(state, this.config, this.metadata, this.context, this.leg);
285
+ }
286
+ bindJobMetadataPaths() {
287
+ return MDATA_SYMBOLS.JOB_UPDATE.KEYS.map((key) => `metadata/${key}`);
288
+ }
289
+ bindActivityMetadataPaths() {
290
+ const keys_to_save = this.leg === 1 ? 'ACTIVITY' : 'ACTIVITY_UPDATE';
291
+ return MDATA_SYMBOLS[keys_to_save].KEYS.map((key) => `output/metadata/${key}`);
292
+ }
293
+ async getState(jobId) {
294
+ //assemble list of paths necessary to create 'job state' from the 'symbol hash'
295
+ const jobSymbolHashName = `$${this.config.subscribes}`;
296
+ const consumes = {
297
+ [jobSymbolHashName]: MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`)
298
+ };
299
+ for (let [activityId, paths] of Object.entries(this.config.consumes)) {
300
+ if (activityId === '$job') {
301
+ for (const path of paths) {
302
+ consumes[jobSymbolHashName].push(path);
303
+ }
304
+ }
305
+ else {
306
+ if (activityId === '$self') {
307
+ activityId = this.metadata.aid;
308
+ }
309
+ if (!consumes[activityId]) {
310
+ consumes[activityId] = [];
311
+ }
312
+ for (const path of paths) {
313
+ consumes[activityId].push(`${activityId}/${path}`);
314
+ }
315
+ }
316
+ }
317
+ TelemetryService.addTargetTelemetryPaths(consumes, this.config, this.metadata, this.leg);
318
+ let { dad, jid } = this.context.metadata;
319
+ jobId = jobId || jid;
320
+ //`state` is a flat hash
321
+ const dIds = CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], dad);
322
+ const [state, status] = await this.store.getState(jobId, consumes, dIds);
323
+ //`context` is a tree
324
+ this.context = restoreHierarchy(state);
325
+ this.initDimensionalAddress(dad);
326
+ this.initSelf(this.context);
327
+ this.initPolicies(this.context);
328
+ }
329
+ initDimensionalAddress(dad) {
330
+ this.metadata.dad = dad;
331
+ }
332
+ initSelf(context) {
333
+ const activityId = this.metadata.aid;
334
+ if (!context[activityId]) {
335
+ context[activityId] = {};
336
+ }
337
+ const self = context[activityId];
338
+ if (!self.output) {
339
+ self.output = {};
340
+ }
341
+ if (!self.input) {
342
+ self.input = {};
343
+ }
344
+ if (!self.hook) {
345
+ self.hook = {};
346
+ }
347
+ context['$self'] = self;
348
+ context['$job'] = context; //NEVER call STRINGIFY! (circular)
349
+ return context;
350
+ }
351
+ initPolicies(context) {
352
+ context.metadata.expire = this.config.expire;
353
+ }
354
+ bindActivityData(type) {
355
+ this.context[this.metadata.aid][type].data = this.data;
356
+ }
357
+ resolveDad() {
358
+ let dad = this.metadata.dad;
359
+ if (this.adjacentIndex > 0) {
360
+ //if adjacent index > 0 the activity is cycling; replace last index with cycle index
361
+ dad = `${dad.substring(0, dad.lastIndexOf(','))},${this.adjacentIndex}`;
362
+ }
363
+ return dad;
364
+ }
365
+ resolveAdjacentDad() {
366
+ //concat self and child dimension (all children (leg 1) begin life at 0)
367
+ return `${this.resolveDad()}${DimensionService.getSeed(0)}`;
368
+ }
369
+ ;
370
+ async filterAdjacent() {
371
+ const adjacencyList = [];
372
+ const transitions = await this.store.getTransitions(await this.engine.getVID());
373
+ const transition = transitions[`.${this.metadata.aid}`];
374
+ //resolve the dimensional address for adjacent children
375
+ const adjacentDad = this.resolveAdjacentDad();
376
+ if (transition) {
377
+ for (const toActivityId in transition) {
378
+ const transitionRule = transition[toActivityId];
379
+ if (MapperService.evaluate(transitionRule, this.context, this.code)) {
380
+ adjacencyList.push({
381
+ metadata: {
382
+ jid: this.context.metadata.jid,
383
+ dad: adjacentDad,
384
+ aid: toActivityId,
385
+ spn: this.context['$self'].output.metadata?.l2s,
386
+ trc: this.context.metadata.trc,
387
+ },
388
+ type: StreamDataType.TRANSITION,
389
+ data: {}
390
+ });
391
+ }
392
+ }
393
+ }
394
+ return adjacencyList;
395
+ }
396
+ async transition(adjacencyList, jobStatus) {
397
+ let mIds = [];
398
+ if (adjacencyList.length) {
399
+ const multi = this.store.getMulti();
400
+ for (const execSignal of adjacencyList) {
401
+ await this.engine.streamSignaler?.publishMessage(null, execSignal, multi);
402
+ }
403
+ mIds = (await multi.exec());
404
+ }
405
+ else if (jobStatus <= 0) {
406
+ await this.engine.runJobCompletionTasks(this.context);
407
+ }
408
+ return mIds;
409
+ }
410
+ }
411
+ export { Activity };
@@ -0,0 +1,16 @@
1
+ import { Activity } from './activity';
2
+ import { EngineService } from '../engine';
3
+ import { ActivityData, ActivityMetadata, AwaitActivity, ActivityType } from '../../types/activity';
4
+ import { JobState } from '../../types/job';
5
+ import { MultiResponseFlags } from '../../types/redis';
6
+ import { StreamCode, StreamData, StreamStatus } from '../../types/stream';
7
+ declare class Await extends Activity {
8
+ config: AwaitActivity;
9
+ constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
10
+ process(): Promise<string>;
11
+ execActivity(): Promise<string>;
12
+ processEvent(status?: StreamStatus, code?: StreamCode): Promise<void>;
13
+ processSuccess(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
14
+ processError(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
15
+ }
16
+ export { Await };