@hotmeshio/hotmesh 0.0.4 → 0.0.6

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 (355) 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}/durable/worker.d.ts +1 -0
  8. package/build/{services → cjs/services}/durable/worker.js +13 -3
  9. package/build/{services → cjs/services}/hotmesh/index.js +2 -2
  10. package/build/{services → cjs/services}/mapper/index.d.ts +3 -3
  11. package/build/{services → cjs/services}/store/index.js +1 -1
  12. package/build/esm/index.d.ts +4 -0
  13. package/build/esm/index.js +3 -0
  14. package/build/esm/modules/errors.d.ts +28 -0
  15. package/build/esm/modules/errors.js +41 -0
  16. package/build/esm/modules/key.d.ts +75 -0
  17. package/build/esm/modules/key.js +111 -0
  18. package/build/esm/modules/utils.d.ts +34 -0
  19. package/build/esm/modules/utils.js +154 -0
  20. package/build/esm/package.json +80 -0
  21. package/build/esm/services/activities/activity.d.ts +61 -0
  22. package/build/esm/services/activities/activity.js +411 -0
  23. package/build/esm/services/activities/await.d.ts +16 -0
  24. package/build/esm/services/activities/await.js +140 -0
  25. package/build/esm/services/activities/emit.d.ts +9 -0
  26. package/build/esm/services/activities/emit.js +10 -0
  27. package/build/esm/services/activities/index.d.ts +15 -0
  28. package/build/esm/services/activities/index.js +14 -0
  29. package/build/esm/services/activities/iterate.d.ts +9 -0
  30. package/build/esm/services/activities/iterate.js +10 -0
  31. package/build/esm/services/activities/trigger.d.ts +22 -0
  32. package/build/esm/services/activities/trigger.js +158 -0
  33. package/build/esm/services/activities/worker.d.ts +17 -0
  34. package/build/esm/services/activities/worker.js +162 -0
  35. package/build/esm/services/collator/index.d.ts +56 -0
  36. package/build/esm/services/collator/index.js +191 -0
  37. package/build/esm/services/compiler/deployer.d.ts +36 -0
  38. package/build/esm/services/compiler/deployer.js +423 -0
  39. package/build/esm/services/compiler/index.d.ts +30 -0
  40. package/build/esm/services/compiler/index.js +82 -0
  41. package/build/esm/services/compiler/validator.d.ts +32 -0
  42. package/build/esm/services/compiler/validator.js +131 -0
  43. package/build/esm/services/connector/clients/ioredis.d.ts +13 -0
  44. package/build/esm/services/connector/clients/ioredis.js +47 -0
  45. package/build/esm/services/connector/clients/redis.d.ts +13 -0
  46. package/build/esm/services/connector/clients/redis.js +59 -0
  47. package/build/esm/services/connector/index.d.ts +5 -0
  48. package/build/esm/services/connector/index.js +27 -0
  49. package/build/esm/services/dimension/index.d.ts +29 -0
  50. package/build/esm/services/dimension/index.js +32 -0
  51. package/build/esm/services/durable/asyncLocalStorage.d.ts +3 -0
  52. package/build/esm/services/durable/asyncLocalStorage.js +2 -0
  53. package/build/esm/services/durable/client.d.ts +15 -0
  54. package/build/esm/services/durable/client.js +114 -0
  55. package/build/esm/services/durable/connection.d.ts +4 -0
  56. package/build/esm/services/durable/connection.js +47 -0
  57. package/build/esm/services/durable/factory.d.ts +3 -0
  58. package/build/esm/services/durable/factory.js +119 -0
  59. package/build/esm/services/durable/handle.d.ts +8 -0
  60. package/build/esm/services/durable/handle.js +34 -0
  61. package/build/esm/services/durable/index.d.ts +57 -0
  62. package/build/esm/services/durable/index.js +55 -0
  63. package/build/esm/services/durable/native.d.ts +4 -0
  64. package/build/esm/services/durable/native.js +43 -0
  65. package/build/esm/services/durable/worker.d.ts +37 -0
  66. package/build/esm/services/durable/worker.js +268 -0
  67. package/build/esm/services/durable/workflow.d.ts +6 -0
  68. package/build/esm/services/durable/workflow.js +128 -0
  69. package/build/esm/services/engine/index.d.ts +82 -0
  70. package/build/esm/services/engine/index.js +522 -0
  71. package/build/esm/services/hotmesh/index.d.ts +45 -0
  72. package/build/esm/services/hotmesh/index.js +131 -0
  73. package/build/esm/services/logger/index.d.ts +17 -0
  74. package/build/esm/services/logger/index.js +70 -0
  75. package/build/esm/services/mapper/index.d.ts +24 -0
  76. package/build/esm/services/mapper/index.js +69 -0
  77. package/build/esm/services/pipe/functions/array.d.ts +24 -0
  78. package/build/esm/services/pipe/functions/array.js +66 -0
  79. package/build/esm/services/pipe/functions/bitwise.d.ts +9 -0
  80. package/build/esm/services/pipe/functions/bitwise.js +21 -0
  81. package/build/esm/services/pipe/functions/conditional.d.ts +10 -0
  82. package/build/esm/services/pipe/functions/conditional.js +24 -0
  83. package/build/esm/services/pipe/functions/date.d.ts +57 -0
  84. package/build/esm/services/pipe/functions/date.js +164 -0
  85. package/build/esm/services/pipe/functions/index.d.ts +25 -0
  86. package/build/esm/services/pipe/functions/index.js +24 -0
  87. package/build/esm/services/pipe/functions/json.d.ts +5 -0
  88. package/build/esm/services/pipe/functions/json.js +9 -0
  89. package/build/esm/services/pipe/functions/math.d.ts +38 -0
  90. package/build/esm/services/pipe/functions/math.js +108 -0
  91. package/build/esm/services/pipe/functions/number.d.ts +25 -0
  92. package/build/esm/services/pipe/functions/number.js +130 -0
  93. package/build/esm/services/pipe/functions/object.d.ts +22 -0
  94. package/build/esm/services/pipe/functions/object.js +60 -0
  95. package/build/esm/services/pipe/functions/string.d.ts +23 -0
  96. package/build/esm/services/pipe/functions/string.js +66 -0
  97. package/build/esm/services/pipe/functions/symbol.d.ts +12 -0
  98. package/build/esm/services/pipe/functions/symbol.js +30 -0
  99. package/build/esm/services/pipe/functions/unary.d.ts +7 -0
  100. package/build/esm/services/pipe/functions/unary.js +15 -0
  101. package/build/esm/services/pipe/index.d.ts +30 -0
  102. package/build/esm/services/pipe/index.js +122 -0
  103. package/build/esm/services/quorum/index.d.ts +34 -0
  104. package/build/esm/services/quorum/index.js +144 -0
  105. package/build/esm/services/reporter/index.d.ts +47 -0
  106. package/build/esm/services/reporter/index.js +327 -0
  107. package/build/esm/services/serializer/index.d.ts +41 -0
  108. package/build/esm/services/serializer/index.js +251 -0
  109. package/build/esm/services/signaler/store.d.ts +15 -0
  110. package/build/esm/services/signaler/store.js +50 -0
  111. package/build/esm/services/signaler/stream.d.ts +43 -0
  112. package/build/esm/services/signaler/stream.js +315 -0
  113. package/build/esm/services/store/cache.d.ts +66 -0
  114. package/build/esm/services/store/cache.js +124 -0
  115. package/build/esm/services/store/clients/ioredis.d.ts +27 -0
  116. package/build/esm/services/store/clients/ioredis.js +93 -0
  117. package/build/esm/services/store/clients/redis.d.ts +29 -0
  118. package/build/esm/services/store/clients/redis.js +140 -0
  119. package/build/esm/services/store/index.d.ts +88 -0
  120. package/build/esm/services/store/index.js +623 -0
  121. package/build/esm/services/stream/clients/ioredis.d.ts +23 -0
  122. package/build/esm/services/stream/clients/ioredis.js +112 -0
  123. package/build/esm/services/stream/clients/redis.d.ts +23 -0
  124. package/build/esm/services/stream/clients/redis.js +116 -0
  125. package/build/esm/services/stream/index.d.ts +21 -0
  126. package/build/esm/services/stream/index.js +6 -0
  127. package/build/esm/services/sub/clients/ioredis.d.ts +20 -0
  128. package/build/esm/services/sub/clients/ioredis.js +69 -0
  129. package/build/esm/services/sub/clients/redis.d.ts +20 -0
  130. package/build/esm/services/sub/clients/redis.js +60 -0
  131. package/build/esm/services/sub/index.d.ts +18 -0
  132. package/build/esm/services/sub/index.js +6 -0
  133. package/build/esm/services/task/index.d.ts +18 -0
  134. package/build/esm/services/task/index.js +70 -0
  135. package/build/esm/services/telemetry/index.d.ts +49 -0
  136. package/build/esm/services/telemetry/index.js +217 -0
  137. package/build/esm/services/worker/index.d.ts +30 -0
  138. package/build/esm/services/worker/index.js +102 -0
  139. package/build/esm/types/activity.d.ts +87 -0
  140. package/build/esm/types/activity.js +1 -0
  141. package/build/esm/types/app.d.ts +16 -0
  142. package/build/esm/types/app.js +1 -0
  143. package/build/esm/types/async.d.ts +5 -0
  144. package/build/esm/types/async.js +1 -0
  145. package/build/esm/types/cache.d.ts +1 -0
  146. package/build/esm/types/cache.js +1 -0
  147. package/build/esm/types/collator.d.ts +8 -0
  148. package/build/esm/types/collator.js +8 -0
  149. package/build/esm/types/durable.d.ts +59 -0
  150. package/build/esm/types/durable.js +1 -0
  151. package/build/esm/types/hook.d.ts +31 -0
  152. package/build/esm/types/hook.js +6 -0
  153. package/build/esm/types/hotmesh.d.ts +82 -0
  154. package/build/esm/types/hotmesh.js +1 -0
  155. package/build/esm/types/index.d.ts +20 -0
  156. package/build/esm/types/index.js +5 -0
  157. package/build/esm/types/ioredisclient.d.ts +5 -0
  158. package/build/esm/types/ioredisclient.js +2 -0
  159. package/build/esm/types/job.d.ts +50 -0
  160. package/build/esm/types/job.js +1 -0
  161. package/build/esm/types/logger.d.ts +6 -0
  162. package/build/esm/types/logger.js +1 -0
  163. package/build/esm/types/map.d.ts +4 -0
  164. package/build/esm/types/map.js +1 -0
  165. package/build/esm/types/pipe.d.ts +4 -0
  166. package/build/esm/types/pipe.js +1 -0
  167. package/build/esm/types/quorum.d.ts +46 -0
  168. package/build/esm/types/quorum.js +1 -0
  169. package/build/esm/types/redis.d.ts +8 -0
  170. package/build/esm/types/redis.js +1 -0
  171. package/build/esm/types/redisclient.d.ts +25 -0
  172. package/build/esm/types/redisclient.js +1 -0
  173. package/build/esm/types/serializer.d.ts +33 -0
  174. package/build/esm/types/serializer.js +1 -0
  175. package/build/esm/types/stats.d.ts +83 -0
  176. package/build/esm/types/stats.js +1 -0
  177. package/build/esm/types/stream.d.ts +67 -0
  178. package/build/esm/types/stream.js +22 -0
  179. package/build/esm/types/telemetry.d.ts +1 -0
  180. package/build/esm/types/telemetry.js +1 -0
  181. package/build/esm/types/transition.d.ts +17 -0
  182. package/build/esm/types/transition.js +1 -0
  183. package/package.json +12 -5
  184. package/services/activities/activity.ts +1 -1
  185. package/services/activities/trigger.ts +2 -2
  186. package/services/connector/index.ts +3 -3
  187. package/services/durable/client.ts +2 -2
  188. package/services/durable/connection.ts +2 -2
  189. package/services/durable/worker.ts +13 -3
  190. package/services/hotmesh/index.ts +2 -2
  191. package/services/mapper/index.ts +6 -7
  192. package/services/store/index.ts +3 -3
  193. package/tsconfig.cjs.json +8 -0
  194. package/tsconfig.esm.json +9 -0
  195. package/build/{index.d.ts → cjs/index.d.ts} +0 -0
  196. package/build/{index.js → cjs/index.js} +0 -0
  197. package/build/{modules → cjs/modules}/errors.d.ts +0 -0
  198. package/build/{modules → cjs/modules}/errors.js +0 -0
  199. package/build/{modules → cjs/modules}/key.d.ts +0 -0
  200. package/build/{modules → cjs/modules}/key.js +0 -0
  201. package/build/{modules → cjs/modules}/utils.d.ts +0 -0
  202. package/build/{modules → cjs/modules}/utils.js +0 -0
  203. package/build/{services → cjs/services}/activities/activity.d.ts +0 -0
  204. package/build/{services → cjs/services}/activities/activity.js +1 -1
  205. /package/build/{services → cjs/services}/activities/await.d.ts +0 -0
  206. /package/build/{services → cjs/services}/activities/await.js +0 -0
  207. /package/build/{services → cjs/services}/activities/emit.d.ts +0 -0
  208. /package/build/{services → cjs/services}/activities/emit.js +0 -0
  209. /package/build/{services → cjs/services}/activities/index.d.ts +0 -0
  210. /package/build/{services → cjs/services}/activities/index.js +0 -0
  211. /package/build/{services → cjs/services}/activities/iterate.d.ts +0 -0
  212. /package/build/{services → cjs/services}/activities/iterate.js +0 -0
  213. /package/build/{services → cjs/services}/activities/trigger.d.ts +0 -0
  214. /package/build/{services → cjs/services}/activities/worker.d.ts +0 -0
  215. /package/build/{services → cjs/services}/activities/worker.js +0 -0
  216. /package/build/{services → cjs/services}/collator/index.d.ts +0 -0
  217. /package/build/{services → cjs/services}/collator/index.js +0 -0
  218. /package/build/{services → cjs/services}/compiler/deployer.d.ts +0 -0
  219. /package/build/{services → cjs/services}/compiler/deployer.js +0 -0
  220. /package/build/{services → cjs/services}/compiler/index.d.ts +0 -0
  221. /package/build/{services → cjs/services}/compiler/index.js +0 -0
  222. /package/build/{services → cjs/services}/compiler/validator.d.ts +0 -0
  223. /package/build/{services → cjs/services}/compiler/validator.js +0 -0
  224. /package/build/{services → cjs/services}/connector/clients/ioredis.d.ts +0 -0
  225. /package/build/{services → cjs/services}/connector/clients/ioredis.js +0 -0
  226. /package/build/{services → cjs/services}/connector/clients/redis.d.ts +0 -0
  227. /package/build/{services → cjs/services}/connector/clients/redis.js +0 -0
  228. /package/build/{services → cjs/services}/connector/index.d.ts +0 -0
  229. /package/build/{services → cjs/services}/dimension/index.d.ts +0 -0
  230. /package/build/{services → cjs/services}/dimension/index.js +0 -0
  231. /package/build/{services → cjs/services}/durable/asyncLocalStorage.d.ts +0 -0
  232. /package/build/{services → cjs/services}/durable/asyncLocalStorage.js +0 -0
  233. /package/build/{services → cjs/services}/durable/client.d.ts +0 -0
  234. /package/build/{services → cjs/services}/durable/connection.d.ts +0 -0
  235. /package/build/{services → cjs/services}/durable/factory.d.ts +0 -0
  236. /package/build/{services → cjs/services}/durable/factory.js +0 -0
  237. /package/build/{services → cjs/services}/durable/handle.d.ts +0 -0
  238. /package/build/{services → cjs/services}/durable/handle.js +0 -0
  239. /package/build/{services → cjs/services}/durable/index.d.ts +0 -0
  240. /package/build/{services → cjs/services}/durable/index.js +0 -0
  241. /package/build/{services → cjs/services}/durable/native.d.ts +0 -0
  242. /package/build/{services → cjs/services}/durable/native.js +0 -0
  243. /package/build/{services → cjs/services}/durable/workflow.d.ts +0 -0
  244. /package/build/{services → cjs/services}/durable/workflow.js +0 -0
  245. /package/build/{services → cjs/services}/engine/index.d.ts +0 -0
  246. /package/build/{services → cjs/services}/engine/index.js +0 -0
  247. /package/build/{services → cjs/services}/hotmesh/index.d.ts +0 -0
  248. /package/build/{services → cjs/services}/logger/index.d.ts +0 -0
  249. /package/build/{services → cjs/services}/logger/index.js +0 -0
  250. /package/build/{services → cjs/services}/mapper/index.js +0 -0
  251. /package/build/{services → cjs/services}/pipe/functions/array.d.ts +0 -0
  252. /package/build/{services → cjs/services}/pipe/functions/array.js +0 -0
  253. /package/build/{services → cjs/services}/pipe/functions/bitwise.d.ts +0 -0
  254. /package/build/{services → cjs/services}/pipe/functions/bitwise.js +0 -0
  255. /package/build/{services → cjs/services}/pipe/functions/conditional.d.ts +0 -0
  256. /package/build/{services → cjs/services}/pipe/functions/conditional.js +0 -0
  257. /package/build/{services → cjs/services}/pipe/functions/date.d.ts +0 -0
  258. /package/build/{services → cjs/services}/pipe/functions/date.js +0 -0
  259. /package/build/{services → cjs/services}/pipe/functions/index.d.ts +0 -0
  260. /package/build/{services → cjs/services}/pipe/functions/index.js +0 -0
  261. /package/build/{services → cjs/services}/pipe/functions/json.d.ts +0 -0
  262. /package/build/{services → cjs/services}/pipe/functions/json.js +0 -0
  263. /package/build/{services → cjs/services}/pipe/functions/math.d.ts +0 -0
  264. /package/build/{services → cjs/services}/pipe/functions/math.js +0 -0
  265. /package/build/{services → cjs/services}/pipe/functions/number.d.ts +0 -0
  266. /package/build/{services → cjs/services}/pipe/functions/number.js +0 -0
  267. /package/build/{services → cjs/services}/pipe/functions/object.d.ts +0 -0
  268. /package/build/{services → cjs/services}/pipe/functions/object.js +0 -0
  269. /package/build/{services → cjs/services}/pipe/functions/string.d.ts +0 -0
  270. /package/build/{services → cjs/services}/pipe/functions/string.js +0 -0
  271. /package/build/{services → cjs/services}/pipe/functions/symbol.d.ts +0 -0
  272. /package/build/{services → cjs/services}/pipe/functions/symbol.js +0 -0
  273. /package/build/{services → cjs/services}/pipe/functions/unary.d.ts +0 -0
  274. /package/build/{services → cjs/services}/pipe/functions/unary.js +0 -0
  275. /package/build/{services → cjs/services}/pipe/index.d.ts +0 -0
  276. /package/build/{services → cjs/services}/pipe/index.js +0 -0
  277. /package/build/{services → cjs/services}/quorum/index.d.ts +0 -0
  278. /package/build/{services → cjs/services}/quorum/index.js +0 -0
  279. /package/build/{services → cjs/services}/reporter/index.d.ts +0 -0
  280. /package/build/{services → cjs/services}/reporter/index.js +0 -0
  281. /package/build/{services → cjs/services}/serializer/index.d.ts +0 -0
  282. /package/build/{services → cjs/services}/serializer/index.js +0 -0
  283. /package/build/{services → cjs/services}/signaler/store.d.ts +0 -0
  284. /package/build/{services → cjs/services}/signaler/store.js +0 -0
  285. /package/build/{services → cjs/services}/signaler/stream.d.ts +0 -0
  286. /package/build/{services → cjs/services}/signaler/stream.js +0 -0
  287. /package/build/{services → cjs/services}/store/cache.d.ts +0 -0
  288. /package/build/{services → cjs/services}/store/cache.js +0 -0
  289. /package/build/{services → cjs/services}/store/clients/ioredis.d.ts +0 -0
  290. /package/build/{services → cjs/services}/store/clients/ioredis.js +0 -0
  291. /package/build/{services → cjs/services}/store/clients/redis.d.ts +0 -0
  292. /package/build/{services → cjs/services}/store/clients/redis.js +0 -0
  293. /package/build/{services → cjs/services}/store/index.d.ts +0 -0
  294. /package/build/{services → cjs/services}/stream/clients/ioredis.d.ts +0 -0
  295. /package/build/{services → cjs/services}/stream/clients/ioredis.js +0 -0
  296. /package/build/{services → cjs/services}/stream/clients/redis.d.ts +0 -0
  297. /package/build/{services → cjs/services}/stream/clients/redis.js +0 -0
  298. /package/build/{services → cjs/services}/stream/index.d.ts +0 -0
  299. /package/build/{services → cjs/services}/stream/index.js +0 -0
  300. /package/build/{services → cjs/services}/sub/clients/ioredis.d.ts +0 -0
  301. /package/build/{services → cjs/services}/sub/clients/ioredis.js +0 -0
  302. /package/build/{services → cjs/services}/sub/clients/redis.d.ts +0 -0
  303. /package/build/{services → cjs/services}/sub/clients/redis.js +0 -0
  304. /package/build/{services → cjs/services}/sub/index.d.ts +0 -0
  305. /package/build/{services → cjs/services}/sub/index.js +0 -0
  306. /package/build/{services → cjs/services}/task/index.d.ts +0 -0
  307. /package/build/{services → cjs/services}/task/index.js +0 -0
  308. /package/build/{services → cjs/services}/telemetry/index.d.ts +0 -0
  309. /package/build/{services → cjs/services}/telemetry/index.js +0 -0
  310. /package/build/{services → cjs/services}/worker/index.d.ts +0 -0
  311. /package/build/{services → cjs/services}/worker/index.js +0 -0
  312. /package/build/{types → cjs/types}/activity.d.ts +0 -0
  313. /package/build/{types → cjs/types}/activity.js +0 -0
  314. /package/build/{types → cjs/types}/app.d.ts +0 -0
  315. /package/build/{types → cjs/types}/app.js +0 -0
  316. /package/build/{types → cjs/types}/async.d.ts +0 -0
  317. /package/build/{types → cjs/types}/async.js +0 -0
  318. /package/build/{types → cjs/types}/cache.d.ts +0 -0
  319. /package/build/{types → cjs/types}/cache.js +0 -0
  320. /package/build/{types → cjs/types}/collator.d.ts +0 -0
  321. /package/build/{types → cjs/types}/collator.js +0 -0
  322. /package/build/{types → cjs/types}/durable.d.ts +0 -0
  323. /package/build/{types → cjs/types}/durable.js +0 -0
  324. /package/build/{types → cjs/types}/hook.d.ts +0 -0
  325. /package/build/{types → cjs/types}/hook.js +0 -0
  326. /package/build/{types → cjs/types}/hotmesh.d.ts +0 -0
  327. /package/build/{types → cjs/types}/hotmesh.js +0 -0
  328. /package/build/{types → cjs/types}/index.d.ts +0 -0
  329. /package/build/{types → cjs/types}/index.js +0 -0
  330. /package/build/{types → cjs/types}/ioredisclient.d.ts +0 -0
  331. /package/build/{types → cjs/types}/ioredisclient.js +0 -0
  332. /package/build/{types → cjs/types}/job.d.ts +0 -0
  333. /package/build/{types → cjs/types}/job.js +0 -0
  334. /package/build/{types → cjs/types}/logger.d.ts +0 -0
  335. /package/build/{types → cjs/types}/logger.js +0 -0
  336. /package/build/{types → cjs/types}/map.d.ts +0 -0
  337. /package/build/{types → cjs/types}/map.js +0 -0
  338. /package/build/{types → cjs/types}/pipe.d.ts +0 -0
  339. /package/build/{types → cjs/types}/pipe.js +0 -0
  340. /package/build/{types → cjs/types}/quorum.d.ts +0 -0
  341. /package/build/{types → cjs/types}/quorum.js +0 -0
  342. /package/build/{types → cjs/types}/redis.d.ts +0 -0
  343. /package/build/{types → cjs/types}/redis.js +0 -0
  344. /package/build/{types → cjs/types}/redisclient.d.ts +0 -0
  345. /package/build/{types → cjs/types}/redisclient.js +0 -0
  346. /package/build/{types → cjs/types}/serializer.d.ts +0 -0
  347. /package/build/{types → cjs/types}/serializer.js +0 -0
  348. /package/build/{types → cjs/types}/stats.d.ts +0 -0
  349. /package/build/{types → cjs/types}/stats.js +0 -0
  350. /package/build/{types → cjs/types}/stream.d.ts +0 -0
  351. /package/build/{types → cjs/types}/stream.js +0 -0
  352. /package/build/{types → cjs/types}/telemetry.d.ts +0 -0
  353. /package/build/{types → cjs/types}/telemetry.js +0 -0
  354. /package/build/{types → cjs/types}/transition.d.ts +0 -0
  355. /package/build/{types → cjs/types}/transition.js +0 -0
@@ -0,0 +1,158 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import { DuplicateJobError } from '../../modules/errors';
3
+ import { formatISODate, getTimeSeries } from '../../modules/utils';
4
+ import { Activity } from './activity';
5
+ import { CollatorService } from '../collator';
6
+ import { DimensionService } from '../dimension';
7
+ import { Pipe } from '../pipe';
8
+ import { ReporterService } from '../reporter';
9
+ import { MDATA_SYMBOLS } from '../serializer';
10
+ import { TelemetryService } from '../telemetry';
11
+ class Trigger extends Activity {
12
+ constructor(config, data, metadata, hook, engine, context) {
13
+ super(config, data, metadata, hook, engine, context);
14
+ }
15
+ async process() {
16
+ this.logger.debug('trigger-process', { subscribes: this.config.subscribes });
17
+ let telemetry;
18
+ try {
19
+ this.setLeg(2);
20
+ await this.getState();
21
+ telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
22
+ telemetry.startJobSpan();
23
+ telemetry.startActivitySpan(this.leg);
24
+ this.mapJobData();
25
+ await this.setStateNX();
26
+ this.adjacencyList = await this.filterAdjacent();
27
+ await this.setStatus(this.adjacencyList.length);
28
+ const multi = this.store.getMulti();
29
+ await this.setState(multi);
30
+ await this.setStats(multi);
31
+ await multi.exec();
32
+ telemetry.mapActivityAttributes();
33
+ const jobStatus = Number(this.context.metadata.js);
34
+ telemetry.setJobAttributes({ 'app.job.jss': jobStatus });
35
+ const attrs = { 'app.job.jss': jobStatus };
36
+ const messageIds = await this.transition(this.adjacencyList, jobStatus);
37
+ if (messageIds.length) {
38
+ attrs['app.activity.mids'] = messageIds.join(',');
39
+ }
40
+ telemetry.setActivityAttributes(attrs);
41
+ return this.context.metadata.jid;
42
+ }
43
+ catch (error) {
44
+ if (error instanceof DuplicateJobError) {
45
+ this.logger.error('duplicate-job-error', error);
46
+ }
47
+ else {
48
+ this.logger.error('trigger-process-error', error);
49
+ }
50
+ telemetry.setActivityError(error.message);
51
+ throw error;
52
+ }
53
+ finally {
54
+ telemetry.endJobSpan();
55
+ telemetry.endActivitySpan();
56
+ this.logger.debug('trigger-process-end', { subscribes: this.config.subscribes, jid: this.context.metadata.jid });
57
+ }
58
+ }
59
+ async setStatus(amount) {
60
+ this.context.metadata.js = amount;
61
+ }
62
+ createInputContext() {
63
+ const input = {
64
+ [this.metadata.aid]: {
65
+ input: { data: this.data }
66
+ },
67
+ '$self': {
68
+ input: { data: this.data },
69
+ output: { data: this.data }
70
+ },
71
+ };
72
+ return input;
73
+ }
74
+ async getState() {
75
+ const inputContext = this.createInputContext();
76
+ const jobId = this.resolveJobId(inputContext);
77
+ const jobKey = this.resolveJobKey(inputContext);
78
+ const utc = formatISODate(new Date());
79
+ const { id, version } = await this.engine.getVID();
80
+ this.initDimensionalAddress(DimensionService.getSeed());
81
+ const activityMetadata = {
82
+ ...this.metadata,
83
+ jid: jobId,
84
+ key: jobKey,
85
+ as: CollatorService.getTriggerSeed(),
86
+ };
87
+ this.context = {
88
+ metadata: {
89
+ ...this.metadata,
90
+ ngn: this.context.metadata.ngn,
91
+ pj: this.context.metadata.pj,
92
+ pd: this.context.metadata.pd,
93
+ pa: this.context.metadata.pa,
94
+ app: id,
95
+ vrs: version,
96
+ tpc: this.config.subscribes,
97
+ trc: this.context.metadata.trc,
98
+ spn: this.context.metadata.spn,
99
+ jid: jobId,
100
+ dad: DimensionService.getSeed(),
101
+ key: jobKey,
102
+ jc: utc,
103
+ ju: utc,
104
+ ts: getTimeSeries(this.resolveGranularity()),
105
+ js: 0,
106
+ },
107
+ data: {},
108
+ [this.metadata.aid]: {
109
+ input: {
110
+ data: this.data,
111
+ metadata: activityMetadata
112
+ },
113
+ output: {
114
+ data: this.data,
115
+ metadata: activityMetadata
116
+ },
117
+ settings: { data: {} },
118
+ errors: { data: {} },
119
+ },
120
+ };
121
+ this.context['$self'] = this.context[this.metadata.aid];
122
+ }
123
+ bindJobMetadataPaths() {
124
+ return MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`);
125
+ }
126
+ bindActivityMetadataPaths() {
127
+ return MDATA_SYMBOLS.ACTIVITY.KEYS.map((key) => `output/metadata/${key}`);
128
+ }
129
+ resolveGranularity() {
130
+ return ReporterService.DEFAULT_GRANULARITY;
131
+ }
132
+ getJobStatus() {
133
+ return this.context.metadata.js;
134
+ }
135
+ resolveJobId(context) {
136
+ const jobId = this.config.stats?.id;
137
+ return jobId ? Pipe.resolve(jobId, context) : uuidv4();
138
+ }
139
+ resolveJobKey(context) {
140
+ const jobKey = this.config.stats?.key;
141
+ return jobKey ? Pipe.resolve(jobKey, context) : '';
142
+ }
143
+ async setStateNX() {
144
+ const jobId = this.context.metadata.jid;
145
+ if (!await this.store.setStateNX(jobId, this.engine.appId)) {
146
+ throw new DuplicateJobError(jobId);
147
+ }
148
+ }
149
+ async setStats(multi) {
150
+ const md = this.context.metadata;
151
+ if (this.config.stats?.measures) {
152
+ const config = await this.engine.getVID();
153
+ const reporter = new ReporterService(config, this.store, this.logger);
154
+ await this.store.setStats(md.key, md.jid, md.ts, reporter.resolveTriggerStatistics(this.config, this.context), config, multi);
155
+ }
156
+ }
157
+ }
158
+ export { Trigger };
@@ -0,0 +1,17 @@
1
+ import { Activity } from './activity';
2
+ import { EngineService } from '../engine';
3
+ import { ActivityData, ActivityMetadata, ActivityType, WorkerActivity } from '../../types/activity';
4
+ import { JobState } from '../../types/job';
5
+ import { StreamCode, StreamStatus } from '../../types/stream';
6
+ import { TelemetryService } from '../telemetry';
7
+ declare class Worker extends Activity {
8
+ config: WorkerActivity;
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
+ processPending(telemetry: TelemetryService): Promise<void>;
14
+ processSuccess(telemetry: TelemetryService): Promise<void>;
15
+ processError(telemetry: TelemetryService): Promise<void>;
16
+ }
17
+ export { Worker };
@@ -0,0 +1,162 @@
1
+ import { GetStateError } from '../../modules/errors';
2
+ import { Activity } from './activity';
3
+ import { CollatorService } from '../collator';
4
+ import { StreamStatus } from '../../types/stream';
5
+ import { TelemetryService } from '../telemetry';
6
+ class Worker extends Activity {
7
+ constructor(config, data, metadata, hook, engine, context) {
8
+ super(config, data, metadata, hook, engine, context);
9
+ }
10
+ //******** INITIAL ENTRY POINT (A) ********//
11
+ async process() {
12
+ this.logger.debug('worker-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
13
+ let telemetry;
14
+ try {
15
+ this.setLeg(1);
16
+ await CollatorService.notarizeEntry(this);
17
+ await this.getState();
18
+ telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
19
+ telemetry.startActivitySpan(this.leg);
20
+ this.mapInputData();
21
+ const multi = this.store.getMulti();
22
+ //await this.registerTimeout();
23
+ await CollatorService.authorizeReentry(this, multi);
24
+ await this.setState(multi);
25
+ await this.setStatus(0, multi);
26
+ const multiResponse = await multi.exec();
27
+ telemetry.mapActivityAttributes();
28
+ const jobStatus = this.resolveStatus(multiResponse);
29
+ const messageId = await this.execActivity();
30
+ telemetry.setActivityAttributes({
31
+ 'app.activity.mid': messageId,
32
+ 'app.job.jss': jobStatus
33
+ });
34
+ //TODO: UPDATE ACTIVITY STATE (LEG 1 EXIT)
35
+ return this.context.metadata.aid;
36
+ }
37
+ catch (error) {
38
+ if (error instanceof GetStateError) {
39
+ this.logger.error('worker-get-state-error', error);
40
+ }
41
+ else {
42
+ console.error(error);
43
+ this.logger.error('worker-process-error', error);
44
+ }
45
+ telemetry.setActivityError(error.message);
46
+ throw error;
47
+ }
48
+ finally {
49
+ telemetry.endActivitySpan();
50
+ this.logger.debug('worker-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
51
+ }
52
+ }
53
+ async execActivity() {
54
+ const streamData = {
55
+ metadata: {
56
+ jid: this.context.metadata.jid,
57
+ dad: this.metadata.dad,
58
+ aid: this.metadata.aid,
59
+ topic: this.config.subtype,
60
+ spn: this.context['$self'].output.metadata.l1s,
61
+ trc: this.context.metadata.trc,
62
+ },
63
+ data: this.context.data
64
+ };
65
+ if (this.config.retry) {
66
+ streamData.policies = {
67
+ retry: this.config.retry
68
+ };
69
+ }
70
+ return (await this.engine.streamSignaler?.publishMessage(this.config.subtype, streamData));
71
+ }
72
+ //******** SIGNAL RE-ENTRY POINT (DUPLEX LEG 2 of 2) ********//
73
+ async processEvent(status = StreamStatus.SUCCESS, code = 200) {
74
+ this.setLeg(2);
75
+ const jid = this.context.metadata.jid;
76
+ const aid = this.metadata.aid;
77
+ this.status = status;
78
+ this.code = code;
79
+ this.logger.debug('worker-process-event', { topic: this.config.subtype, jid, aid, status, code });
80
+ let telemetry;
81
+ try {
82
+ await this.getState();
83
+ const aState = await CollatorService.notarizeReentry(this);
84
+ this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
85
+ telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
86
+ let isComplete = CollatorService.isActivityComplete(this.context.metadata.js);
87
+ if (isComplete) {
88
+ this.logger.warn('worker-process-event-duplicate', { jid, aid });
89
+ this.logger.debug('worker-process-event-duplicate-resolution', { resolution: 'Increase HotMesh config `reclaimDelay` timeout.' });
90
+ return;
91
+ }
92
+ telemetry.startActivitySpan(this.leg);
93
+ if (status === StreamStatus.PENDING) {
94
+ await this.processPending(telemetry);
95
+ }
96
+ else if (status === StreamStatus.SUCCESS) {
97
+ await this.processSuccess(telemetry);
98
+ }
99
+ else {
100
+ await this.processError(telemetry);
101
+ }
102
+ }
103
+ catch (error) {
104
+ this.logger.error('worker-process-event-error', error);
105
+ telemetry.setActivityError(error.message);
106
+ throw error;
107
+ }
108
+ finally {
109
+ telemetry.endActivitySpan();
110
+ this.logger.debug('worker-process-event-end', { jid, aid });
111
+ }
112
+ }
113
+ async processPending(telemetry) {
114
+ this.bindActivityData('output');
115
+ this.adjacencyList = await this.filterAdjacent();
116
+ this.mapJobData();
117
+ const multi = this.store.getMulti();
118
+ await this.setState(multi);
119
+ await CollatorService.notarizeContinuation(this, multi);
120
+ await this.setStatus(0, multi);
121
+ const multiResponse = await multi.exec();
122
+ telemetry.mapActivityAttributes();
123
+ const jobStatus = this.resolveStatus(multiResponse);
124
+ telemetry.setActivityAttributes({ 'app.job.jss': jobStatus });
125
+ }
126
+ async processSuccess(telemetry) {
127
+ this.bindActivityData('output');
128
+ this.adjacencyList = await this.filterAdjacent();
129
+ this.mapJobData();
130
+ const multi = this.store.getMulti();
131
+ await this.setState(multi);
132
+ await CollatorService.notarizeCompletion(this, multi);
133
+ await this.setStatus(this.adjacencyList.length - 1, multi);
134
+ const multiResponse = await multi.exec();
135
+ telemetry.mapActivityAttributes();
136
+ const jobStatus = this.resolveStatus(multiResponse);
137
+ const attrs = { 'app.job.jss': jobStatus };
138
+ const messageIds = await this.transition(this.adjacencyList, jobStatus);
139
+ if (messageIds.length) {
140
+ attrs['app.activity.mids'] = messageIds.join(',');
141
+ }
142
+ telemetry.setActivityAttributes(attrs);
143
+ }
144
+ async processError(telemetry) {
145
+ this.bindActivityError(this.data);
146
+ this.adjacencyList = await this.filterAdjacent();
147
+ const multi = this.store.getMulti();
148
+ await this.setState(multi);
149
+ await CollatorService.notarizeCompletion(this, multi);
150
+ await this.setStatus(this.adjacencyList.length - 1, multi);
151
+ const multiResponse = await multi.exec();
152
+ telemetry.mapActivityAttributes();
153
+ const jobStatus = this.resolveStatus(multiResponse);
154
+ const attrs = { 'app.job.jss': jobStatus };
155
+ const messageIds = await this.transition(this.adjacencyList, jobStatus);
156
+ if (messageIds.length) {
157
+ attrs['app.activity.mids'] = messageIds.join(',');
158
+ }
159
+ telemetry.setActivityAttributes(attrs);
160
+ }
161
+ }
162
+ export { Worker };
@@ -0,0 +1,56 @@
1
+ import { RedisMulti } from '../../types/redis';
2
+ import { CollationStage } from '../../types/collator';
3
+ import { ActivityDuplex } from '../../types/activity';
4
+ import { HotMeshGraph } from '../../types/hotmesh';
5
+ import { Activity } from '../activities/activity';
6
+ declare class CollatorService {
7
+ static targetLength: number;
8
+ static getDimensionalAddress(activity: Activity): Record<string, string>;
9
+ static notarizeEntry(activity: Activity, multi?: RedisMulti): Promise<number>;
10
+ static authorizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
11
+ static notarizeEarlyCompletion(activity: Activity, multi?: RedisMulti): Promise<number>;
12
+ static notarizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
13
+ static notarizeContinuation(activity: Activity, multi?: RedisMulti): Promise<number>;
14
+ static notarizeCompletion(activity: Activity, multi?: RedisMulti): Promise<number>;
15
+ static getDigitAtIndex(num: number, targetDigitIndex: number): number | null;
16
+ static getDimensionalIndex(num: number): number | null;
17
+ static isDuplicate(num: number, targetDigitIndex: number): boolean;
18
+ static isInactive(num: number): boolean;
19
+ static isPrimed(amount: number, leg: ActivityDuplex): boolean;
20
+ static verifyInteger(amount: number, leg: ActivityDuplex, stage: CollationStage): void;
21
+ static getDimensionsById(ancestors: string[], dad: string): Record<string, string>;
22
+ /**
23
+ * All non-trigger activities are assigned a status seed by their parent
24
+ */
25
+ static getSeed(): string;
26
+ /**
27
+ * All trigger activities are assigned a status seed in a completed state
28
+ */
29
+ static getTriggerSeed(): string;
30
+ /**
31
+ * entry point for compiler-type activities. This is called by the compiler
32
+ * to bind the sorted activity IDs to the trigger activity. These are then used
33
+ * at runtime by the activities to track job/activity status.
34
+ * @param graphs
35
+ */
36
+ static compile(graphs: HotMeshGraph[]): void;
37
+ /**
38
+ * binds the ancestor array to each activity.
39
+ * Used in conjunction with the dimensional
40
+ * address (dad). If dad is `,0,1,0,0` and the
41
+ * ancestor array is `['t1', 'a1', 'a2']` for
42
+ * activity 'a3', then the SAVED DAD
43
+ * will always have the trailing
44
+ * 0's removed. This ensures that the addressing
45
+ * remains consistent even if the graph changes.
46
+ * id DAD SAVED DAD
47
+ * * t1 => ,0 => [empty]
48
+ * * a1 => ,0,1 => ,0,1
49
+ * * a2 => ,0,1,0 => ,0,1
50
+ * * a3 => ,0,1,0,0 => ,0,1
51
+ *
52
+ */
53
+ static bindAncestorArray(graphs: HotMeshGraph[]): void;
54
+ static isActivityComplete(status: number): boolean;
55
+ }
56
+ export { CollatorService };
@@ -0,0 +1,191 @@
1
+ import { CollationError } from '../../modules/errors';
2
+ import { CollationFaultType } from '../../types/collator';
3
+ class CollatorService {
4
+ static getDimensionalAddress(activity) {
5
+ let dad = activity.context.metadata.dad || activity.metadata.dad;
6
+ //todo: unsure about this reset
7
+ // if (dad && activity.leg === 2) {
8
+ // console.log('setting dad index back to 0=>', dad);
9
+ // dad = `${dad.substring(0, dad.lastIndexOf(','))},0`;
10
+ // }
11
+ return CollatorService.getDimensionsById([...activity.config.ancestors, activity.metadata.aid], dad);
12
+ }
13
+ static async notarizeEntry(activity, multi) {
14
+ //decrement by -100_000_000_000_000
15
+ const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -100000000000000, this.getDimensionalAddress(activity), multi);
16
+ this.verifyInteger(amount, 1, 'enter');
17
+ return amount;
18
+ }
19
+ ;
20
+ static async authorizeReentry(activity, multi) {
21
+ //set second digit to 8, allowing for re-entry
22
+ //decrement by -10_000_000_000_000
23
+ const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -10000000000000, this.getDimensionalAddress(activity), multi);
24
+ //this.verifyInteger(amount, 1, 'exit');
25
+ return amount;
26
+ }
27
+ static async notarizeEarlyCompletion(activity, multi) {
28
+ //initialize both `possible` (1m) and `actualized` (1) zero dimension, while decrementing the 2nd and 3rd digits to deactivate the activity
29
+ return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1000001 - 11000000000000, this.getDimensionalAddress(activity), multi);
30
+ }
31
+ ;
32
+ static async notarizeReentry(activity, multi) {
33
+ //increment by 1_000_000 (indicates re-entry and is used to drive the 'dimensional address' for adjacent activities (minus 1))
34
+ const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1000000, this.getDimensionalAddress(activity), multi);
35
+ this.verifyInteger(amount, 2, 'enter');
36
+ return amount;
37
+ }
38
+ ;
39
+ static async notarizeContinuation(activity, multi) {
40
+ //keep open; actualize the leg2 dimension (+1)
41
+ return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1, this.getDimensionalAddress(activity), multi);
42
+ }
43
+ ;
44
+ static async notarizeCompletion(activity, multi) {
45
+ //close out; actualize leg2 dimension (+1) and decrement the 3rd digit (-1_000_000_000_000)
46
+ return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1 - 1000000000000, this.getDimensionalAddress(activity), multi);
47
+ }
48
+ ;
49
+ static getDigitAtIndex(num, targetDigitIndex) {
50
+ const numStr = num.toString();
51
+ if (targetDigitIndex < 0 || targetDigitIndex >= numStr.length) {
52
+ return null;
53
+ }
54
+ const digit = parseInt(numStr[targetDigitIndex], 10);
55
+ return digit;
56
+ }
57
+ static getDimensionalIndex(num) {
58
+ const numStr = num.toString();
59
+ if (numStr.length < 9) {
60
+ return null;
61
+ }
62
+ const extractedStr = numStr.substring(3, 9);
63
+ const extractedInt = parseInt(extractedStr, 10);
64
+ return extractedInt - 1;
65
+ }
66
+ static isDuplicate(num, targetDigitIndex) {
67
+ return this.getDigitAtIndex(num, targetDigitIndex) < 8;
68
+ }
69
+ static isInactive(num) {
70
+ return this.getDigitAtIndex(num, 2) < 9;
71
+ }
72
+ static isPrimed(amount, leg) {
73
+ //activity entry is not allowed if paths not properly pre-set
74
+ if (leg == 1) {
75
+ return amount != -100000000000000;
76
+ }
77
+ else {
78
+ return this.getDigitAtIndex(amount, 0) < 9 &&
79
+ this.getDigitAtIndex(amount, 1) < 9;
80
+ }
81
+ }
82
+ static verifyInteger(amount, leg, stage) {
83
+ let faultType;
84
+ if (leg === 1 && stage === 'enter') {
85
+ if (!this.isPrimed(amount, 1)) {
86
+ faultType = CollationFaultType.MISSING;
87
+ }
88
+ else if (this.isDuplicate(amount, 0)) {
89
+ faultType = CollationFaultType.DUPLICATE;
90
+ }
91
+ else if (amount != 899000000000000) {
92
+ faultType = CollationFaultType.INVALID;
93
+ }
94
+ }
95
+ else if (leg === 1 && stage === 'exit') {
96
+ if (amount === -10000000000000) {
97
+ faultType = CollationFaultType.MISSING;
98
+ }
99
+ else if (this.isDuplicate(amount, 1)) {
100
+ faultType = CollationFaultType.DUPLICATE;
101
+ }
102
+ }
103
+ else if (leg === 2 && stage === 'enter') {
104
+ if (!this.isPrimed(amount, 2)) {
105
+ faultType = CollationFaultType.FORBIDDEN;
106
+ }
107
+ else if (this.isInactive(amount)) {
108
+ faultType = CollationFaultType.INACTIVE;
109
+ }
110
+ }
111
+ if (faultType) {
112
+ throw new CollationError(amount, leg, stage, faultType);
113
+ }
114
+ }
115
+ static getDimensionsById(ancestors, dad) {
116
+ //ancestors is an ordered list of all ancestors, starting with the trigger (['t1', 'a1', 'a2'])
117
+ //dad is the dimensional address of the ancestors list (',0,5,3')
118
+ //loop through the ancestors list and create a map of the ancestor to the dimensional address.
119
+ //return { 't1': ',0', 'a1': ',0,5', 'a1': ',0,5,3', $ADJACENT: ',0,5,3,0' };
120
+ // `adjacent` is a special key that is used to track the dimensional address of adjacent activities
121
+ const map = { '$ADJACENT': `${dad},0` };
122
+ let dadStr = dad;
123
+ ancestors.reverse().forEach((ancestor) => {
124
+ map[ancestor] = dadStr;
125
+ dadStr = dadStr.substring(0, dadStr.lastIndexOf(','));
126
+ });
127
+ return map;
128
+ }
129
+ /**
130
+ * All non-trigger activities are assigned a status seed by their parent
131
+ */
132
+ static getSeed() {
133
+ return '999000000000000';
134
+ }
135
+ /**
136
+ * All trigger activities are assigned a status seed in a completed state
137
+ */
138
+ static getTriggerSeed() {
139
+ return '888000001000001';
140
+ }
141
+ /**
142
+ * entry point for compiler-type activities. This is called by the compiler
143
+ * to bind the sorted activity IDs to the trigger activity. These are then used
144
+ * at runtime by the activities to track job/activity status.
145
+ * @param graphs
146
+ */
147
+ static compile(graphs) {
148
+ CollatorService.bindAncestorArray(graphs);
149
+ }
150
+ /**
151
+ * binds the ancestor array to each activity.
152
+ * Used in conjunction with the dimensional
153
+ * address (dad). If dad is `,0,1,0,0` and the
154
+ * ancestor array is `['t1', 'a1', 'a2']` for
155
+ * activity 'a3', then the SAVED DAD
156
+ * will always have the trailing
157
+ * 0's removed. This ensures that the addressing
158
+ * remains consistent even if the graph changes.
159
+ * id DAD SAVED DAD
160
+ * * t1 => ,0 => [empty]
161
+ * * a1 => ,0,1 => ,0,1
162
+ * * a2 => ,0,1,0 => ,0,1
163
+ * * a3 => ,0,1,0,0 => ,0,1
164
+ *
165
+ */
166
+ static bindAncestorArray(graphs) {
167
+ graphs.forEach((graph) => {
168
+ const ancestors = {};
169
+ const startingNode = Object.keys(graph.activities).find((activity) => graph.activities[activity].type === 'trigger');
170
+ if (!startingNode) {
171
+ throw new Error('collator-trigger-activity-not-found');
172
+ }
173
+ const dfs = (node, parentList) => {
174
+ ancestors[node] = parentList;
175
+ graph.activities[node]['ancestors'] = parentList;
176
+ const transitions = graph.transitions?.[node] || [];
177
+ transitions.forEach((transition) => {
178
+ dfs(transition.to, [...parentList, node]);
179
+ });
180
+ };
181
+ // Start the DFS traversal
182
+ dfs(startingNode, []);
183
+ });
184
+ }
185
+ static isActivityComplete(status) {
186
+ return (status - 0) <= 0;
187
+ }
188
+ }
189
+ //max int digit count that supports `hincrby`
190
+ CollatorService.targetLength = 15;
191
+ export { CollatorService };
@@ -0,0 +1,36 @@
1
+ import { StoreService } from '../store';
2
+ import { HotMeshGraph, HotMeshManifest } from '../../types/hotmesh';
3
+ import { RedisClient, RedisMulti } from '../../types/redis';
4
+ import { Symbols } from '../../types/serializer';
5
+ declare class Deployer {
6
+ manifest: HotMeshManifest | null;
7
+ store: StoreService<RedisClient, RedisMulti> | null;
8
+ constructor(manifest: HotMeshManifest);
9
+ deploy(store: StoreService<RedisClient, RedisMulti>): Promise<void>;
10
+ getVID(): {
11
+ id: string;
12
+ version: string;
13
+ };
14
+ generateSymKeys(): Promise<void>;
15
+ bindSelf(consumes: Record<string, string[]>, produces: string[], activityId: string): void;
16
+ bindSymbols(startIndex: number, maxIndex: number, existingSymbols: Symbols, prefix: string, produces: string[]): Symbols;
17
+ copyJobSchemas(): void;
18
+ bindBackRefs(): void;
19
+ convertTopicsToTypes(): void;
20
+ bindParents(): Promise<void>;
21
+ collectValues(schema: Record<string, any>, values: Set<string>): void;
22
+ traverse(obj: any, values: Set<string>): void;
23
+ generateSymVals(): Promise<void>;
24
+ resolveJobMapsPaths(): void;
25
+ resolveMappingDependencies(): void;
26
+ groupMappingRules(rules: string[]): Record<string, string[]>;
27
+ resolveMappableValue(mappable: string): [string, string];
28
+ deployActivitySchemas(): Promise<void>;
29
+ deploySubscriptions(): Promise<void>;
30
+ findTrigger(graph: HotMeshGraph): [string, Record<string, any>] | null;
31
+ deployTransitions(): Promise<void>;
32
+ deployHookPatterns(): Promise<void>;
33
+ deployConsumerGroups(): Promise<void>;
34
+ deployConsumerGroup(stream: string, group: string): Promise<void>;
35
+ }
36
+ export { Deployer };