@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,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 };
@@ -0,0 +1,423 @@
1
+ import { KeyType } from '../../modules/key';
2
+ import { getSymKey } from '../../modules/utils';
3
+ import { CollatorService } from '../collator';
4
+ import { SerializerService } from '../serializer';
5
+ const DEFAULT_METADATA_RANGE_SIZE = 26; //metadata is 26 slots ([a-z] * 1)
6
+ const DEFAULT_DATA_RANGE_SIZE = 260; //data is 260 slots ([a-zA-Z] * 5)
7
+ const DEFAULT_RANGE_SIZE = DEFAULT_METADATA_RANGE_SIZE + DEFAULT_DATA_RANGE_SIZE;
8
+ class Deployer {
9
+ constructor(manifest) {
10
+ this.manifest = null;
11
+ this.manifest = manifest;
12
+ }
13
+ async deploy(store) {
14
+ this.store = store;
15
+ CollatorService.compile(this.manifest.app.graphs);
16
+ this.convertTopicsToTypes();
17
+ this.copyJobSchemas();
18
+ this.bindBackRefs();
19
+ this.bindParents();
20
+ this.resolveMappingDependencies();
21
+ this.resolveJobMapsPaths();
22
+ await this.generateSymKeys();
23
+ await this.generateSymVals();
24
+ await this.deployHookPatterns();
25
+ await this.deployActivitySchemas();
26
+ await this.deploySubscriptions();
27
+ await this.deployTransitions();
28
+ await this.deployConsumerGroups();
29
+ }
30
+ getVID() {
31
+ return {
32
+ id: this.manifest.app.id,
33
+ version: this.manifest.app.version,
34
+ };
35
+ }
36
+ async generateSymKeys() {
37
+ //note: symbol ranges are additive (per version); path assignments are immutable
38
+ const appId = this.manifest.app.id;
39
+ for (const graph of this.manifest.app.graphs) {
40
+ //generate JOB symbols
41
+ const [, trigger] = this.findTrigger(graph);
42
+ const topic = trigger.subscribes;
43
+ const [lower, upper, symbols] = await this.store.reserveSymbolRange(`$${topic}`, DEFAULT_RANGE_SIZE, 'JOB');
44
+ const prefix = ''; //job meta/data is NOT namespaced
45
+ const newSymbols = this.bindSymbols(lower, upper, symbols, prefix, trigger.PRODUCES);
46
+ if (Object.keys(newSymbols).length) {
47
+ await this.store.addSymbols(`$${topic}`, newSymbols);
48
+ }
49
+ //generate ACTIVITY symbols
50
+ for (const [activityId, activity] of Object.entries(graph.activities)) {
51
+ const [lower, upper, symbols] = await this.store.reserveSymbolRange(activityId, DEFAULT_RANGE_SIZE, 'ACTIVITY');
52
+ const prefix = `${activityId}/`; //activity meta/data is namespaced
53
+ this.bindSelf(activity.consumes, activity.produces, activityId);
54
+ const newSymbols = this.bindSymbols(lower, upper, symbols, prefix, activity.produces);
55
+ if (Object.keys(newSymbols).length) {
56
+ await this.store.addSymbols(activityId, newSymbols);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ bindSelf(consumes, produces, activityId) {
62
+ //bind self-referential mappings
63
+ for (const selfId of [activityId, '$self']) {
64
+ const selfConsumes = consumes[selfId];
65
+ if (selfConsumes) {
66
+ for (const path of selfConsumes) {
67
+ if (!produces.includes(path)) {
68
+ produces.push(path);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ bindSymbols(startIndex, maxIndex, existingSymbols, prefix, produces) {
75
+ let newSymbols = {};
76
+ let currentSymbols = { ...existingSymbols };
77
+ for (let path of produces) {
78
+ const fullPath = `${prefix}${path}`;
79
+ if (!currentSymbols[fullPath]) {
80
+ if (startIndex > maxIndex) {
81
+ throw new Error('Symbol index out of bounds');
82
+ }
83
+ const symbol = getSymKey(startIndex);
84
+ startIndex++;
85
+ newSymbols[fullPath] = symbol;
86
+ currentSymbols[fullPath] = symbol; // update the currentSymbols to include this new symbol
87
+ }
88
+ }
89
+ return newSymbols;
90
+ }
91
+ copyJobSchemas() {
92
+ const graphs = this.manifest.app.graphs;
93
+ for (const graph of graphs) {
94
+ const jobSchema = graph.output?.schema;
95
+ const outputSchema = graph.input?.schema;
96
+ if (!jobSchema && !outputSchema)
97
+ continue;
98
+ const activities = graph.activities;
99
+ // Find the trigger activity and bind the job schema to it
100
+ // at execution time, the trigger is a standin for the job
101
+ for (const activityKey in activities) {
102
+ if (activities[activityKey].type === 'trigger') {
103
+ const trigger = activities[activityKey];
104
+ if (jobSchema) {
105
+ //possible for trigger to have job mappings
106
+ if (!trigger.job) {
107
+ trigger.job = {};
108
+ }
109
+ trigger.job.schema = jobSchema;
110
+ }
111
+ if (outputSchema) {
112
+ //impossible for trigger to have output mappings.
113
+ trigger.output = { schema: outputSchema };
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ bindBackRefs() {
120
+ for (const graph of this.manifest.app.graphs) {
121
+ const activities = graph.activities;
122
+ const triggerId = this.findTrigger(graph)[0];
123
+ for (const activityKey in activities) {
124
+ activities[activityKey].trigger = triggerId;
125
+ activities[activityKey].subscribes = graph.subscribes;
126
+ if (graph.publishes) {
127
+ activities[activityKey].publishes = graph.publishes;
128
+ }
129
+ if (graph.expire) {
130
+ activities[activityKey].expire = graph.expire;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ //more intuitive for SDK users to use 'topic',
136
+ //but the compiler is desiged to be generic and uses 'subtypes'
137
+ convertTopicsToTypes() {
138
+ for (const graph of this.manifest.app.graphs) {
139
+ const activities = graph.activities;
140
+ for (const activityKey in activities) {
141
+ const activity = activities[activityKey];
142
+ if (['worker', 'await'].includes(activity.type) && activity.topic && !activity.subtype) {
143
+ activity.subtype = activity.topic;
144
+ }
145
+ }
146
+ }
147
+ }
148
+ async bindParents() {
149
+ const graphs = this.manifest.app.graphs;
150
+ for (const graph of graphs) {
151
+ if (graph.transitions) {
152
+ for (const fromActivity in graph.transitions) {
153
+ const toTransitions = graph.transitions[fromActivity];
154
+ for (const transition of toTransitions) {
155
+ const to = transition.to;
156
+ //DAGs have one parent; easy to optimize for
157
+ graph.activities[to].parent = fromActivity;
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ collectValues(schema, values) {
164
+ for (const [key, value] of Object.entries(schema)) {
165
+ if (key === 'enum' || key === 'examples' || key === 'default') {
166
+ if (Array.isArray(value)) {
167
+ for (const v of value) {
168
+ if (typeof v === 'string' && v.length > 5) {
169
+ values.add(v);
170
+ }
171
+ }
172
+ }
173
+ else if (typeof value === 'string' && value.length > 5) {
174
+ values.add(value);
175
+ }
176
+ }
177
+ else if (typeof value === 'object') {
178
+ this.collectValues(value, values);
179
+ }
180
+ }
181
+ }
182
+ traverse(obj, values) {
183
+ for (const value of Object.values(obj)) {
184
+ if (typeof value === 'object') {
185
+ if ('schema' in value) {
186
+ this.collectValues(value.schema, values);
187
+ }
188
+ else {
189
+ this.traverse(value, values);
190
+ }
191
+ }
192
+ }
193
+ }
194
+ async generateSymVals() {
195
+ const uniqueStrings = new Set();
196
+ for (const graph of this.manifest.app.graphs) {
197
+ this.traverse(graph, uniqueStrings);
198
+ }
199
+ const existingSymbols = await this.store.getSymbolValues();
200
+ const startIndex = Object.keys(existingSymbols).length;
201
+ const maxIndex = Math.pow(52, 2) - 1;
202
+ const newSymbols = SerializerService.filterSymVals(startIndex, maxIndex, existingSymbols, uniqueStrings);
203
+ await this.store.addSymbolValues(newSymbols);
204
+ }
205
+ resolveJobMapsPaths() {
206
+ function parsePaths(obj) {
207
+ let result = [];
208
+ function traverse(obj, path = []) {
209
+ for (let key in obj) {
210
+ if (typeof obj[key] === 'object' && obj[key] !== null && !('@pipe' in obj[key])) {
211
+ let newPath = [...path, key];
212
+ traverse(obj[key], newPath);
213
+ }
214
+ else {
215
+ const finalPath = `data/${[...path, key].join('/')}`;
216
+ if (!result.includes(finalPath)) {
217
+ result.push(finalPath);
218
+ }
219
+ }
220
+ }
221
+ }
222
+ if (obj) {
223
+ traverse(obj);
224
+ }
225
+ return result;
226
+ }
227
+ for (const graph of this.manifest.app.graphs) {
228
+ let results = [];
229
+ const [, trigger] = this.findTrigger(graph);
230
+ for (const activityKey in graph.activities) {
231
+ const activity = graph.activities[activityKey];
232
+ results = results.concat(parsePaths(activity.job?.maps));
233
+ }
234
+ trigger.PRODUCES = results;
235
+ }
236
+ }
237
+ resolveMappingDependencies() {
238
+ const dynamicMappingRules = [];
239
+ //recursive function to descend into the object and find all dynamic mapping rules
240
+ function traverse(obj, consumes) {
241
+ for (const key in obj) {
242
+ if (typeof obj[key] === 'string') {
243
+ const stringValue = obj[key];
244
+ const dynamicMappingRuleMatch = stringValue.match(/^\{[^@].*}$/);
245
+ if (dynamicMappingRuleMatch) {
246
+ if (stringValue.split('.')[1] !== 'input') {
247
+ dynamicMappingRules.push(stringValue);
248
+ consumes.push(stringValue);
249
+ }
250
+ }
251
+ }
252
+ else if (typeof obj[key] === 'object' && obj[key] !== null) {
253
+ traverse(obj[key], consumes);
254
+ }
255
+ }
256
+ }
257
+ const graphs = this.manifest.app.graphs;
258
+ for (const graph of graphs) {
259
+ const activities = graph.activities;
260
+ for (const activityId in activities) {
261
+ const activity = activities[activityId];
262
+ activity.consumes = [];
263
+ traverse(activity, activity.consumes);
264
+ activity.consumes = this.groupMappingRules(activity.consumes);
265
+ }
266
+ }
267
+ const groupedRules = this.groupMappingRules(dynamicMappingRules);
268
+ // Iterate through the graph and add 'produces' field to each activity
269
+ for (const graph of graphs) {
270
+ const activities = graph.activities;
271
+ for (const activityId in activities) {
272
+ const activity = activities[activityId];
273
+ activity.produces = groupedRules[`${activityId}`] || [];
274
+ }
275
+ }
276
+ }
277
+ groupMappingRules(rules) {
278
+ rules = Array.from(new Set(rules)).sort();
279
+ // Group by the first symbol before the period (this is the activity name)
280
+ const groupedRules = {};
281
+ for (const rule of rules) {
282
+ const [group, resolved] = this.resolveMappableValue(rule);
283
+ if (!groupedRules[group]) {
284
+ groupedRules[group] = [];
285
+ }
286
+ groupedRules[group].push(resolved);
287
+ }
288
+ return groupedRules;
289
+ }
290
+ resolveMappableValue(mappable) {
291
+ mappable = mappable.substring(1, mappable.length - 1);
292
+ const parts = mappable.split('.');
293
+ if (parts[0] === '$job') {
294
+ const [group, ...path] = parts;
295
+ return [group, path.join('/')];
296
+ }
297
+ else {
298
+ //normalize paths to be relative to the activity
299
+ const [group, type, subtype, ...path] = parts;
300
+ const prefix = {
301
+ hook: 'hook/data',
302
+ input: 'input/data',
303
+ output: subtype === 'data' ? 'output/data' : 'output/metadata'
304
+ }[type];
305
+ return [group, `${prefix}/${path.join('/')}`];
306
+ }
307
+ }
308
+ async deployActivitySchemas() {
309
+ const graphs = this.manifest.app.graphs;
310
+ const activitySchemas = {};
311
+ for (const graph of graphs) {
312
+ const activities = graph.activities;
313
+ for (const activityKey in activities) {
314
+ activitySchemas[activityKey] = activities[activityKey];
315
+ }
316
+ }
317
+ await this.store.setSchemas(activitySchemas, this.getVID());
318
+ }
319
+ async deploySubscriptions() {
320
+ const graphs = this.manifest.app.graphs;
321
+ const publicSubscriptions = {};
322
+ for (const graph of graphs) {
323
+ const activities = graph.activities;
324
+ const subscribesTopic = graph.subscribes;
325
+ // Find the activity ID associated with the subscribes topic
326
+ for (const activityKey in activities) {
327
+ if (activities[activityKey].type === 'trigger') {
328
+ publicSubscriptions[subscribesTopic] = activityKey;
329
+ break;
330
+ }
331
+ }
332
+ }
333
+ await this.store.setSubscriptions(publicSubscriptions, this.getVID());
334
+ }
335
+ findTrigger(graph) {
336
+ for (const activityKey in graph.activities) {
337
+ const activity = graph.activities[activityKey];
338
+ if (activity.type === 'trigger') {
339
+ return [activityKey, activity];
340
+ }
341
+ }
342
+ return null;
343
+ }
344
+ async deployTransitions() {
345
+ const graphs = this.manifest.app.graphs;
346
+ const privateSubscriptions = {};
347
+ for (const graph of graphs) {
348
+ if (graph.subscribes && graph.subscribes.startsWith('.')) {
349
+ const [triggerId] = this.findTrigger(graph);
350
+ if (triggerId) {
351
+ privateSubscriptions[graph.subscribes] = { [triggerId]: true };
352
+ }
353
+ }
354
+ if (graph.transitions) {
355
+ for (const fromActivity in graph.transitions) {
356
+ const toTransitions = graph.transitions[fromActivity];
357
+ const toValues = {};
358
+ for (const transition of toTransitions) {
359
+ const to = transition.to;
360
+ if (transition.conditions) {
361
+ toValues[to] = transition.conditions;
362
+ }
363
+ else {
364
+ toValues[to] = true;
365
+ }
366
+ }
367
+ if (Object.keys(toValues).length > 0) {
368
+ privateSubscriptions['.' + fromActivity] = toValues;
369
+ }
370
+ }
371
+ }
372
+ }
373
+ await this.store.setTransitions(privateSubscriptions, this.getVID());
374
+ }
375
+ async deployHookPatterns() {
376
+ const graphs = this.manifest.app.graphs;
377
+ const hookRules = {};
378
+ for (const graph of graphs) {
379
+ if (graph.hooks) {
380
+ for (const topic in graph.hooks) {
381
+ hookRules[topic] = graph.hooks[topic];
382
+ const activityId = graph.hooks[topic][0].to;
383
+ const targetActivity = graph.activities[activityId];
384
+ if (targetActivity) {
385
+ if (!targetActivity.hook) {
386
+ targetActivity.hook = {};
387
+ }
388
+ //create back-reference to the hook topic
389
+ targetActivity.hook.topic = topic;
390
+ }
391
+ }
392
+ }
393
+ }
394
+ await this.store.setHookRules(hookRules);
395
+ }
396
+ async deployConsumerGroups() {
397
+ //create one engine group
398
+ const params = { appId: this.manifest.app.id };
399
+ const key = this.store.mintKey(KeyType.STREAMS, params);
400
+ await this.deployConsumerGroup(key, 'ENGINE');
401
+ for (const graph of this.manifest.app.graphs) {
402
+ const activities = graph.activities;
403
+ for (const activityKey in activities) {
404
+ const activity = activities[activityKey];
405
+ if (activity.type === 'worker') {
406
+ params.topic = activity.subtype;
407
+ const key = this.store.mintKey(KeyType.STREAMS, params);
408
+ //create one worker group per unique activity subtype (the topic)
409
+ await this.deployConsumerGroup(key, 'WORKER');
410
+ }
411
+ }
412
+ }
413
+ }
414
+ async deployConsumerGroup(stream, group) {
415
+ try {
416
+ await this.store.xgroup('CREATE', stream, group, '$', 'MKSTREAM');
417
+ }
418
+ catch (err) {
419
+ this.store.logger.info('consumer-group-exists', { stream, group });
420
+ }
421
+ }
422
+ }
423
+ export { Deployer };
@@ -0,0 +1,30 @@
1
+ import { ILogger } from '../logger';
2
+ import { StoreService } from '../store';
3
+ import { HotMeshManifest } from '../../types/hotmesh';
4
+ import { RedisClient, RedisMulti } from '../../types/redis';
5
+ /**
6
+ * The compiler service converts a graph into a executable program.
7
+ */
8
+ declare class CompilerService {
9
+ store: StoreService<RedisClient, RedisMulti> | null;
10
+ logger: ILogger;
11
+ constructor(store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
12
+ /**
13
+ * verifies and plans the deployment of an app to Redis; the app is not deployed yet
14
+ * @param path
15
+ */
16
+ plan(mySchemaOrPath: string): Promise<HotMeshManifest>;
17
+ isPath(input: string): boolean;
18
+ /**
19
+ * deploys an app to Redis but does NOT activate it.
20
+ */
21
+ deploy(mySchemaOrPath: string): Promise<HotMeshManifest>;
22
+ /**
23
+ * activates a deployed version of an app;
24
+ * @param appId
25
+ * @param appVersion
26
+ */
27
+ activate(appId: string, appVersion: string): Promise<boolean>;
28
+ saveAsJSON(originalPath: string, schema: HotMeshManifest): Promise<void>;
29
+ }
30
+ export { CompilerService };