@hotmeshio/hotmesh 0.3.32 → 0.4.0

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 (254) hide show
  1. package/README.md +128 -823
  2. package/build/index.d.ts +9 -9
  3. package/build/index.js +10 -10
  4. package/build/package.json +22 -21
  5. package/build/types/error.d.ts +5 -5
  6. package/build/types/exporter.d.ts +1 -1
  7. package/build/types/index.d.ts +3 -3
  8. package/build/types/manifest.d.ts +2 -2
  9. package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
  10. package/build/types/meshdata.d.ts +3 -3
  11. package/build/types/postgres.d.ts +7 -0
  12. package/build/types/stream.d.ts +3 -0
  13. package/index.ts +11 -11
  14. package/package.json +22 -21
  15. package/typedoc.json +8 -7
  16. package/types/error.ts +5 -5
  17. package/types/exporter.ts +1 -1
  18. package/types/index.ts +7 -7
  19. package/types/manifest.ts +2 -2
  20. package/types/{meshflow.ts → memflow.ts} +15 -15
  21. package/types/meshdata.ts +3 -3
  22. package/types/postgres.ts +9 -0
  23. package/types/stream.ts +4 -0
  24. package/build/modules/enums.d.ts +0 -110
  25. package/build/modules/enums.js +0 -134
  26. package/build/modules/errors.d.ts +0 -124
  27. package/build/modules/errors.js +0 -191
  28. package/build/modules/key.d.ts +0 -66
  29. package/build/modules/key.js +0 -1
  30. package/build/modules/storage.d.ts +0 -3
  31. package/build/modules/storage.js +0 -5
  32. package/build/modules/utils.d.ts +0 -119
  33. package/build/modules/utils.js +0 -1
  34. package/build/services/activities/activity.d.ts +0 -104
  35. package/build/services/activities/activity.js +0 -1
  36. package/build/services/activities/await.d.ts +0 -12
  37. package/build/services/activities/await.js +0 -1
  38. package/build/services/activities/cycle.d.ts +0 -19
  39. package/build/services/activities/cycle.js +0 -1
  40. package/build/services/activities/hook.d.ts +0 -27
  41. package/build/services/activities/hook.js +0 -1
  42. package/build/services/activities/index.d.ts +0 -19
  43. package/build/services/activities/index.js +0 -1
  44. package/build/services/activities/interrupt.d.ts +0 -16
  45. package/build/services/activities/interrupt.js +0 -1
  46. package/build/services/activities/signal.d.ts +0 -20
  47. package/build/services/activities/signal.js +0 -1
  48. package/build/services/activities/trigger.d.ts +0 -37
  49. package/build/services/activities/trigger.js +0 -1
  50. package/build/services/activities/worker.d.ts +0 -12
  51. package/build/services/activities/worker.js +0 -1
  52. package/build/services/collator/index.d.ts +0 -111
  53. package/build/services/collator/index.js +0 -1
  54. package/build/services/compiler/deployer.d.ts +0 -40
  55. package/build/services/compiler/deployer.js +0 -1
  56. package/build/services/compiler/index.d.ts +0 -32
  57. package/build/services/compiler/index.js +0 -1
  58. package/build/services/compiler/validator.d.ts +0 -34
  59. package/build/services/compiler/validator.js +0 -1
  60. package/build/services/connector/factory.d.ts +0 -22
  61. package/build/services/connector/factory.js +0 -99
  62. package/build/services/connector/index.d.ts +0 -30
  63. package/build/services/connector/index.js +0 -54
  64. package/build/services/connector/providers/ioredis.d.ts +0 -9
  65. package/build/services/connector/providers/ioredis.js +0 -26
  66. package/build/services/connector/providers/nats.d.ts +0 -9
  67. package/build/services/connector/providers/nats.js +0 -34
  68. package/build/services/connector/providers/postgres.d.ts +0 -20
  69. package/build/services/connector/providers/postgres.js +0 -102
  70. package/build/services/connector/providers/redis.d.ts +0 -9
  71. package/build/services/connector/providers/redis.js +0 -38
  72. package/build/services/engine/index.d.ts +0 -264
  73. package/build/services/engine/index.js +0 -1
  74. package/build/services/exporter/index.d.ts +0 -44
  75. package/build/services/exporter/index.js +0 -1
  76. package/build/services/hotmesh/index.d.ts +0 -340
  77. package/build/services/hotmesh/index.js +0 -479
  78. package/build/services/logger/index.d.ts +0 -16
  79. package/build/services/logger/index.js +0 -54
  80. package/build/services/mapper/index.d.ts +0 -28
  81. package/build/services/mapper/index.js +0 -1
  82. package/build/services/meshcall/index.d.ts +0 -194
  83. package/build/services/meshcall/index.js +0 -452
  84. package/build/services/meshcall/schemas/factory.d.ts +0 -9
  85. package/build/services/meshcall/schemas/factory.js +0 -189
  86. package/build/services/meshdata/index.d.ts +0 -795
  87. package/build/services/meshdata/index.js +0 -1235
  88. package/build/services/meshflow/client.d.ts +0 -108
  89. package/build/services/meshflow/client.js +0 -371
  90. package/build/services/meshflow/connection.d.ts +0 -23
  91. package/build/services/meshflow/connection.js +0 -33
  92. package/build/services/meshflow/exporter.d.ts +0 -51
  93. package/build/services/meshflow/exporter.js +0 -1
  94. package/build/services/meshflow/handle.d.ts +0 -90
  95. package/build/services/meshflow/handle.js +0 -176
  96. package/build/services/meshflow/index.d.ts +0 -111
  97. package/build/services/meshflow/index.js +0 -117
  98. package/build/services/meshflow/schemas/factory.d.ts +0 -29
  99. package/build/services/meshflow/schemas/factory.js +0 -2492
  100. package/build/services/meshflow/search.d.ts +0 -142
  101. package/build/services/meshflow/search.js +0 -320
  102. package/build/services/meshflow/worker.d.ts +0 -124
  103. package/build/services/meshflow/worker.js +0 -514
  104. package/build/services/meshflow/workflow/all.d.ts +0 -7
  105. package/build/services/meshflow/workflow/all.js +0 -15
  106. package/build/services/meshflow/workflow/common.d.ts +0 -18
  107. package/build/services/meshflow/workflow/common.js +0 -45
  108. package/build/services/meshflow/workflow/context.d.ts +0 -6
  109. package/build/services/meshflow/workflow/context.js +0 -45
  110. package/build/services/meshflow/workflow/didRun.d.ts +0 -7
  111. package/build/services/meshflow/workflow/didRun.js +0 -22
  112. package/build/services/meshflow/workflow/emit.d.ts +0 -11
  113. package/build/services/meshflow/workflow/emit.js +0 -29
  114. package/build/services/meshflow/workflow/enrich.d.ts +0 -9
  115. package/build/services/meshflow/workflow/enrich.js +0 -17
  116. package/build/services/meshflow/workflow/execChild.d.ts +0 -18
  117. package/build/services/meshflow/workflow/execChild.js +0 -102
  118. package/build/services/meshflow/workflow/hook.d.ts +0 -9
  119. package/build/services/meshflow/workflow/hook.js +0 -40
  120. package/build/services/meshflow/workflow/index.d.ts +0 -70
  121. package/build/services/meshflow/workflow/index.js +0 -83
  122. package/build/services/meshflow/workflow/interrupt.d.ts +0 -9
  123. package/build/services/meshflow/workflow/interrupt.js +0 -24
  124. package/build/services/meshflow/workflow/isSideEffectAllowed.d.ts +0 -10
  125. package/build/services/meshflow/workflow/isSideEffectAllowed.js +0 -33
  126. package/build/services/meshflow/workflow/proxyActivities.d.ts +0 -20
  127. package/build/services/meshflow/workflow/proxyActivities.js +0 -97
  128. package/build/services/meshflow/workflow/random.d.ts +0 -6
  129. package/build/services/meshflow/workflow/random.js +0 -16
  130. package/build/services/meshflow/workflow/searchMethods.d.ts +0 -6
  131. package/build/services/meshflow/workflow/searchMethods.js +0 -25
  132. package/build/services/meshflow/workflow/signal.d.ts +0 -7
  133. package/build/services/meshflow/workflow/signal.js +0 -28
  134. package/build/services/meshflow/workflow/sleepFor.d.ts +0 -8
  135. package/build/services/meshflow/workflow/sleepFor.js +0 -35
  136. package/build/services/meshflow/workflow/trace.d.ts +0 -14
  137. package/build/services/meshflow/workflow/trace.js +0 -33
  138. package/build/services/meshflow/workflow/waitFor.d.ts +0 -8
  139. package/build/services/meshflow/workflow/waitFor.js +0 -35
  140. package/build/services/meshos/index.d.ts +0 -293
  141. package/build/services/meshos/index.js +0 -547
  142. package/build/services/pipe/functions/array.d.ts +0 -17
  143. package/build/services/pipe/functions/array.js +0 -1
  144. package/build/services/pipe/functions/bitwise.d.ts +0 -9
  145. package/build/services/pipe/functions/bitwise.js +0 -1
  146. package/build/services/pipe/functions/conditional.d.ts +0 -13
  147. package/build/services/pipe/functions/conditional.js +0 -1
  148. package/build/services/pipe/functions/cron.d.ts +0 -12
  149. package/build/services/pipe/functions/cron.js +0 -1
  150. package/build/services/pipe/functions/date.d.ts +0 -58
  151. package/build/services/pipe/functions/date.js +0 -1
  152. package/build/services/pipe/functions/index.d.ts +0 -29
  153. package/build/services/pipe/functions/index.js +0 -1
  154. package/build/services/pipe/functions/json.d.ts +0 -5
  155. package/build/services/pipe/functions/json.js +0 -1
  156. package/build/services/pipe/functions/logical.d.ts +0 -5
  157. package/build/services/pipe/functions/logical.js +0 -1
  158. package/build/services/pipe/functions/math.d.ts +0 -42
  159. package/build/services/pipe/functions/math.js +0 -1
  160. package/build/services/pipe/functions/number.d.ts +0 -21
  161. package/build/services/pipe/functions/number.js +0 -1
  162. package/build/services/pipe/functions/object.d.ts +0 -25
  163. package/build/services/pipe/functions/object.js +0 -1
  164. package/build/services/pipe/functions/string.d.ts +0 -23
  165. package/build/services/pipe/functions/string.js +0 -1
  166. package/build/services/pipe/functions/symbol.d.ts +0 -12
  167. package/build/services/pipe/functions/symbol.js +0 -1
  168. package/build/services/pipe/functions/unary.d.ts +0 -7
  169. package/build/services/pipe/functions/unary.js +0 -1
  170. package/build/services/pipe/index.d.ts +0 -48
  171. package/build/services/pipe/index.js +0 -1
  172. package/build/services/quorum/index.d.ts +0 -90
  173. package/build/services/quorum/index.js +0 -1
  174. package/build/services/reporter/index.d.ts +0 -50
  175. package/build/services/reporter/index.js +0 -1
  176. package/build/services/router/index.d.ts +0 -60
  177. package/build/services/router/index.js +0 -1
  178. package/build/services/search/factory.d.ts +0 -7
  179. package/build/services/search/factory.js +0 -24
  180. package/build/services/search/index.d.ts +0 -22
  181. package/build/services/search/index.js +0 -10
  182. package/build/services/search/providers/postgres/postgres.d.ts +0 -24
  183. package/build/services/search/providers/postgres/postgres.js +0 -1
  184. package/build/services/search/providers/redis/ioredis.d.ts +0 -18
  185. package/build/services/search/providers/redis/ioredis.js +0 -1
  186. package/build/services/search/providers/redis/redis.d.ts +0 -18
  187. package/build/services/search/providers/redis/redis.js +0 -1
  188. package/build/services/serializer/index.d.ts +0 -42
  189. package/build/services/serializer/index.js +0 -1
  190. package/build/services/store/cache.d.ts +0 -67
  191. package/build/services/store/cache.js +0 -128
  192. package/build/services/store/factory.d.ts +0 -8
  193. package/build/services/store/factory.js +0 -24
  194. package/build/services/store/index.d.ts +0 -89
  195. package/build/services/store/index.js +0 -9
  196. package/build/services/store/providers/postgres/kvsql.d.ts +0 -168
  197. package/build/services/store/providers/postgres/kvsql.js +0 -1
  198. package/build/services/store/providers/postgres/kvtables.d.ts +0 -20
  199. package/build/services/store/providers/postgres/kvtables.js +0 -1
  200. package/build/services/store/providers/postgres/kvtransaction.d.ts +0 -36
  201. package/build/services/store/providers/postgres/kvtransaction.js +0 -1
  202. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
  203. package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1
  204. package/build/services/store/providers/postgres/kvtypes/list.d.ts +0 -33
  205. package/build/services/store/providers/postgres/kvtypes/list.js +0 -1
  206. package/build/services/store/providers/postgres/kvtypes/string.d.ts +0 -20
  207. package/build/services/store/providers/postgres/kvtypes/string.js +0 -1
  208. package/build/services/store/providers/postgres/kvtypes/zset.d.ts +0 -41
  209. package/build/services/store/providers/postgres/kvtypes/zset.js +0 -1
  210. package/build/services/store/providers/postgres/postgres.d.ts +0 -145
  211. package/build/services/store/providers/postgres/postgres.js +0 -1
  212. package/build/services/store/providers/redis/_base.d.ts +0 -137
  213. package/build/services/store/providers/redis/_base.js +0 -1
  214. package/build/services/store/providers/redis/ioredis.d.ts +0 -20
  215. package/build/services/store/providers/redis/ioredis.js +0 -1
  216. package/build/services/store/providers/redis/redis.d.ts +0 -18
  217. package/build/services/store/providers/redis/redis.js +0 -1
  218. package/build/services/store/providers/store-initializable.d.ts +0 -5
  219. package/build/services/store/providers/store-initializable.js +0 -1
  220. package/build/services/stream/factory.d.ts +0 -8
  221. package/build/services/stream/factory.js +0 -37
  222. package/build/services/stream/index.d.ts +0 -64
  223. package/build/services/stream/index.js +0 -11
  224. package/build/services/stream/providers/nats/nats.d.ts +0 -59
  225. package/build/services/stream/providers/nats/nats.js +0 -1
  226. package/build/services/stream/providers/postgres/kvtables.d.ts +0 -2
  227. package/build/services/stream/providers/postgres/kvtables.js +0 -1
  228. package/build/services/stream/providers/postgres/postgres.d.ts +0 -88
  229. package/build/services/stream/providers/postgres/postgres.js +0 -1
  230. package/build/services/stream/providers/redis/ioredis.d.ts +0 -60
  231. package/build/services/stream/providers/redis/ioredis.js +0 -1
  232. package/build/services/stream/providers/redis/redis.d.ts +0 -60
  233. package/build/services/stream/providers/redis/redis.js +0 -1
  234. package/build/services/stream/providers/stream-initializable.d.ts +0 -4
  235. package/build/services/stream/providers/stream-initializable.js +0 -1
  236. package/build/services/sub/factory.d.ts +0 -7
  237. package/build/services/sub/factory.js +0 -29
  238. package/build/services/sub/index.d.ts +0 -22
  239. package/build/services/sub/index.js +0 -10
  240. package/build/services/sub/providers/nats/nats.d.ts +0 -19
  241. package/build/services/sub/providers/nats/nats.js +0 -1
  242. package/build/services/sub/providers/postgres/postgres.d.ts +0 -19
  243. package/build/services/sub/providers/postgres/postgres.js +0 -1
  244. package/build/services/sub/providers/redis/ioredis.d.ts +0 -17
  245. package/build/services/sub/providers/redis/ioredis.js +0 -1
  246. package/build/services/sub/providers/redis/redis.d.ts +0 -17
  247. package/build/services/sub/providers/redis/redis.js +0 -1
  248. package/build/services/task/index.d.ts +0 -36
  249. package/build/services/task/index.js +0 -1
  250. package/build/services/telemetry/index.d.ts +0 -52
  251. package/build/services/telemetry/index.js +0 -1
  252. package/build/services/worker/index.d.ts +0 -77
  253. package/build/services/worker/index.js +0 -1
  254. /package/build/types/{meshflow.js → memflow.js} +0 -0
@@ -1,108 +0,0 @@
1
- import { HotMesh } from '../hotmesh';
2
- import { ClientConfig, ClientWorkflow, Connection, WorkflowOptions } from '../../types/meshflow';
3
- /**
4
- * The MeshFlow `Client` service is functionally
5
- * equivalent to the Temporal `Client` service.
6
- * Start a new workflow execution by calling
7
- * `workflow.start`. Note the direct connection to
8
- * Postgres.
9
- *
10
- * NATS can be used as the message broker if advanced
11
- * messaging is required (i.e, patterned subscriptions).
12
- * @example
13
-
14
- * ```typescript
15
- * //client.ts
16
- * import { Client, HotMesh } from '@hotmeshio/hotmesh';
17
- * import { Client as Postgres } from 'pg';
18
-
19
- * async function run(): Promise<string> {
20
- * const client = new Client({
21
- * connection: {
22
- * class: Postgres,
23
- * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
24
- * }
25
- * });
26
-
27
- * const handle = await client.workflow.start({
28
- * args: ['HotMesh'],
29
- * taskQueue: 'default',
30
- * workflowName: 'example',
31
- * workflowId: HotMesh.guid()
32
- * });
33
-
34
- * return await handle.result();
35
- * //returns ['Hello HotMesh', '¡Hola, HotMesh!']
36
- * }
37
- * ```
38
- */
39
- export declare class ClientService {
40
- /**
41
- * @private
42
- */
43
- connection: Connection;
44
- /**
45
- * @private
46
- */
47
- options: WorkflowOptions;
48
- /**
49
- * @private
50
- */
51
- static topics: string[];
52
- /**
53
- * @private
54
- */
55
- static instances: Map<string, HotMesh | Promise<HotMesh>>;
56
- /**
57
- * @private
58
- */
59
- constructor(config: ClientConfig);
60
- /**
61
- * @private
62
- */
63
- getHotMeshClient: (workflowTopic: string | null, namespace?: string) => Promise<HotMesh>;
64
- /**
65
- * Creates a stream where messages can be published to ensure there is a
66
- * channel in place when the message arrives (a race condition for those
67
- * platforms without implicit topic setup).
68
- * @private
69
- */
70
- static createStream: (hotMeshClient: HotMesh, workflowTopic: string, namespace?: string) => Promise<void>;
71
- hashOptions(): string;
72
- /**
73
- * It is possible for a client to invoke a workflow without first
74
- * creating the stream. This method will verify that the stream
75
- * exists and if not, create it.
76
- * @private
77
- */
78
- verifyStream: (hotMeshClient: HotMesh, workflowTopic: string, namespace?: string) => Promise<void>;
79
- /**
80
- * @private
81
- */
82
- search: (hotMeshClient: HotMesh, index: string, query: string[]) => Promise<string[]>;
83
- /**
84
- * The MeshFlow `Client` service is functionally
85
- * equivalent to the Temporal `Client` service.
86
- * Starting a workflow is the primary use case and
87
- * is accessed by calling workflow.start().
88
- */
89
- workflow: ClientWorkflow;
90
- /**
91
- * Any router can be used to deploy and activate the HotMesh
92
- * distributed executable to the active quorum EXCEPT for
93
- * those routers in `readonly` mode.
94
- */
95
- deployAndActivate(namespace?: string, version?: string): Promise<void>;
96
- /**
97
- * @private
98
- */
99
- verifyWorkflowActive(hotMesh: HotMesh, appId?: string, count?: number): Promise<boolean>;
100
- /**
101
- * @private
102
- */
103
- activateWorkflow(hotMesh: HotMesh, appId?: string, version?: string): Promise<void>;
104
- /**
105
- * @private
106
- */
107
- static shutdown(): Promise<void>;
108
- }
@@ -1,371 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ClientService = void 0;
5
- const enums_1 = require("../../modules/enums");
6
- const utils_1 = require("../../modules/utils");
7
- const hotmesh_1 = require("../hotmesh");
8
- const key_1 = require("../../modules/key");
9
- const types_1 = require("../../types");
10
- const search_1 = require("./search");
11
- const handle_1 = require("./handle");
12
- const factory_1 = require("./schemas/factory");
13
- /**
14
- * The MeshFlow `Client` service is functionally
15
- * equivalent to the Temporal `Client` service.
16
- * Start a new workflow execution by calling
17
- * `workflow.start`. Note the direct connection to
18
- * Postgres.
19
- *
20
- * NATS can be used as the message broker if advanced
21
- * messaging is required (i.e, patterned subscriptions).
22
- * @example
23
-
24
- * ```typescript
25
- * //client.ts
26
- * import { Client, HotMesh } from '@hotmeshio/hotmesh';
27
- * import { Client as Postgres } from 'pg';
28
-
29
- * async function run(): Promise<string> {
30
- * const client = new Client({
31
- * connection: {
32
- * class: Postgres,
33
- * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
34
- * }
35
- * });
36
-
37
- * const handle = await client.workflow.start({
38
- * args: ['HotMesh'],
39
- * taskQueue: 'default',
40
- * workflowName: 'example',
41
- * workflowId: HotMesh.guid()
42
- * });
43
-
44
- * return await handle.result();
45
- * //returns ['Hello HotMesh', '¡Hola, HotMesh!']
46
- * }
47
- * ```
48
- */
49
- class ClientService {
50
- /**
51
- * @private
52
- */
53
- constructor(config) {
54
- /**
55
- * @private
56
- */
57
- this.getHotMeshClient = async (workflowTopic, namespace) => {
58
- //namespace isolation requires the connection options to be hashed
59
- //as multiple intersecting databases can be used by the same service
60
- //hashing options allows for reuse of the same connection without risk of
61
- //overwriting data in another namespace.
62
- const optionsHash = this.hashOptions();
63
- const targetNS = namespace ?? factory_1.APP_ID;
64
- const connectionNS = `${optionsHash}.${targetNS}`;
65
- if (ClientService.instances.has(connectionNS)) {
66
- const hotMeshClient = await ClientService.instances.get(connectionNS);
67
- await this.verifyWorkflowActive(hotMeshClient, targetNS);
68
- return hotMeshClient;
69
- }
70
- //init, but don't await
71
- const readonly = this.connection.readonly ?? undefined;
72
- let hotMeshClient = hotmesh_1.HotMesh.init({
73
- appId: targetNS,
74
- logLevel: enums_1.HMSH_LOGLEVEL,
75
- engine: {
76
- readonly,
77
- connection: this.connection,
78
- },
79
- });
80
- //synchronously cache the promise (before awaiting)
81
- ClientService.instances.set(connectionNS, hotMeshClient);
82
- //resolve, activate, and return the client
83
- const resolvedClient = await hotMeshClient;
84
- if (!readonly) {
85
- resolvedClient.engine.logger.info('meshflow-readonly-client', {
86
- guid: resolvedClient.engine.guid,
87
- appId: targetNS,
88
- });
89
- await this.activateWorkflow(resolvedClient, targetNS);
90
- }
91
- return resolvedClient;
92
- };
93
- /**
94
- * It is possible for a client to invoke a workflow without first
95
- * creating the stream. This method will verify that the stream
96
- * exists and if not, create it.
97
- * @private
98
- */
99
- this.verifyStream = async (hotMeshClient, workflowTopic, namespace) => {
100
- const optionsHash = this.hashOptions();
101
- const targetNS = namespace ?? factory_1.APP_ID;
102
- const targetTopic = `${optionsHash}.${targetNS}.${workflowTopic}`;
103
- if (!ClientService.topics.includes(targetTopic)) {
104
- ClientService.topics.push(targetTopic);
105
- await ClientService.createStream(hotMeshClient, workflowTopic, namespace);
106
- }
107
- };
108
- /**
109
- * @private
110
- */
111
- this.search = async (hotMeshClient, index, query) => {
112
- const searchClient = hotMeshClient.engine.search;
113
- return await searchClient.sendIndexedQuery(index, query);
114
- };
115
- /**
116
- * The MeshFlow `Client` service is functionally
117
- * equivalent to the Temporal `Client` service.
118
- * Starting a workflow is the primary use case and
119
- * is accessed by calling workflow.start().
120
- */
121
- this.workflow = {
122
- /**
123
- * Starts a workflow, verifies the idempotent id, and
124
- * adds searchable data to the record.
125
- */
126
- start: async (options) => {
127
- const taskQueueName = options.taskQueue ?? options.entity;
128
- const workflowName = options.entity ?? options.workflowName;
129
- const trc = options.workflowTrace;
130
- const spn = options.workflowSpan;
131
- //hotmesh `topic` is equivalent to `queue+workflowname` pattern in other systems
132
- const workflowTopic = `${taskQueueName}-${workflowName}`;
133
- const hotMeshClient = await this.getHotMeshClient(workflowTopic, options.namespace);
134
- //verify that the stream channel exists before enqueueing
135
- await this.verifyStream(hotMeshClient, workflowTopic, options.namespace);
136
- const payload = {
137
- arguments: [...options.args],
138
- originJobId: options.originJobId,
139
- expire: options.expire ?? enums_1.HMSH_EXPIRE_JOB_SECONDS,
140
- persistent: options.persistent,
141
- signalIn: options.signalIn,
142
- parentWorkflowId: options.parentWorkflowId,
143
- workflowId: options.workflowId || hotmesh_1.HotMesh.guid(),
144
- workflowTopic: workflowTopic,
145
- backoffCoefficient: options.config?.backoffCoefficient || enums_1.HMSH_MESHFLOW_EXP_BACKOFF,
146
- maximumAttempts: options.config?.maximumAttempts || enums_1.HMSH_MESHFLOW_MAX_ATTEMPTS,
147
- maximumInterval: (0, utils_1.s)(options.config?.maximumInterval || enums_1.HMSH_MESHFLOW_MAX_INTERVAL),
148
- };
149
- const context = { metadata: { trc, spn }, data: {} };
150
- const jobId = await hotMeshClient.pub(`${options.namespace ?? factory_1.APP_ID}.execute`, payload, context, {
151
- search: options?.search?.data,
152
- marker: options?.marker,
153
- pending: options?.pending,
154
- });
155
- return new handle_1.WorkflowHandleService(hotMeshClient, workflowTopic, jobId);
156
- },
157
- /**
158
- * Sends a message payload to a running workflow that is paused and awaiting the signal
159
- */
160
- signal: async (signalId, data, namespace) => {
161
- const topic = `${namespace ?? factory_1.APP_ID}.wfs.signal`;
162
- return await (await this.getHotMeshClient(topic, namespace)).hook(topic, { id: signalId, data });
163
- },
164
- /**
165
- * Spawns an a new, isolated execution cycle within the same job.
166
- * Similar to `worker` functions, `hook` functions have a linked
167
- * function. But hooks do not start a new job and instead read/write
168
- * their isolated activity data to an existing Job record (HASH).
169
- *
170
- * This example spawns a hook that will update workflow `guid123`.
171
- *
172
- * @example
173
- * ```typescript
174
- * await client.workflow.hook({
175
- * namespace: 'demo',
176
- * taskQueue: 'default',
177
- * workflowName: 'myDemoFunction',
178
- * workflowId: 'guid123',
179
- * args: ['Hello'],
180
- * });
181
- * ```
182
- */
183
- hook: async (options) => {
184
- const workflowTopic = `${options.taskQueue ?? options.entity}-${options.entity ?? options.workflowName}`;
185
- const payload = {
186
- arguments: [...options.args],
187
- id: options.workflowId,
188
- workflowTopic,
189
- backoffCoefficient: options.config?.backoffCoefficient || enums_1.HMSH_MESHFLOW_EXP_BACKOFF,
190
- maximumAttempts: options.config?.maximumAttempts || enums_1.HMSH_MESHFLOW_MAX_ATTEMPTS,
191
- maximumInterval: (0, utils_1.s)(options.config?.maximumInterval || enums_1.HMSH_MESHFLOW_MAX_INTERVAL),
192
- };
193
- //seed search data before entering
194
- const hotMeshClient = await this.getHotMeshClient(workflowTopic, options.namespace);
195
- const msgId = await hotMeshClient.hook(`${hotMeshClient.appId}.flow.signal`, payload, types_1.StreamStatus.PENDING, 202);
196
- //todo: commit search data BEFORE enqueuing hook
197
- if (options.search?.data) {
198
- const searchSessionId = `-search-${hotmesh_1.HotMesh.guid()}-0`;
199
- const search = new search_1.Search(options.workflowId, hotMeshClient, searchSessionId);
200
- const entries = Object.entries(options.search.data).flat();
201
- await search.set(...entries);
202
- }
203
- return msgId;
204
- },
205
- /**
206
- * Returns a reference to a running workflow,
207
- * allowing callers to check the status of the workflow,
208
- * interrupt it, and even await its eventual response
209
- * if still in a pending state.
210
- *
211
- * @example
212
- * ```typescript
213
- * const handle = await client.workflow.getHandle(
214
- * 'default',
215
- * 'myFunction',
216
- * 'someGuid123',
217
- * 'demo',
218
- * );
219
- * ```
220
- */
221
- getHandle: async (taskQueue, workflowName, workflowId, namespace) => {
222
- const workflowTopic = `${taskQueue}-${workflowName}`;
223
- const hotMeshClient = await this.getHotMeshClient(workflowTopic, namespace);
224
- return new handle_1.WorkflowHandleService(hotMeshClient, workflowTopic, workflowId);
225
- },
226
- /**
227
- * Provides direct access to the SEARCH backend when making
228
- * queries. Taskqueues and workflow names are
229
- * used to identify the point of presence to use. `...args` is
230
- * the tokenized query. When querying Redis/FTSEARCH, the trailing
231
- * ...args might be `'@_custom1:meshflow'`. For postgres,
232
- * the trailing ...args would be: `'_custom', 'meshflow'`. In each case,
233
- * the query looks for all job data where the field `_custom` is
234
- * equal to `meshflow`.
235
- *
236
- * @example
237
- * ```typescript
238
- * await client.workflow.search(
239
- * 'someTaskQueue'
240
- * 'someWorkflowName',
241
- * 'meshflow',
242
- * 'user',
243
- * ...args,
244
- * );
245
- * //returns [count, [id, fields[]], [id, fields[]], [id, fields[]], ...]]
246
- * ```
247
- */
248
- search: async (taskQueue, workflowName, namespace, index, ...query) => {
249
- const workflowTopic = `${taskQueue}-${workflowName}`;
250
- const hotMeshClient = await this.getHotMeshClient(workflowTopic, namespace);
251
- try {
252
- return await this.search(hotMeshClient, index, query);
253
- }
254
- catch (error) {
255
- hotMeshClient.engine.logger.error('meshflow-client-search-err', {
256
- error,
257
- });
258
- throw error;
259
- }
260
- },
261
- };
262
- this.connection = config.connection;
263
- }
264
- hashOptions() {
265
- if ('options' in this.connection) {
266
- //shorthand format
267
- return (0, utils_1.hashOptions)(this.connection.options);
268
- }
269
- else {
270
- //longhand format (sub, store, stream, pub, search)
271
- const response = [];
272
- for (const p in this.connection) {
273
- if (this.connection[p].options) {
274
- response.push((0, utils_1.hashOptions)(this.connection[p].options));
275
- }
276
- }
277
- return response.join('');
278
- }
279
- }
280
- /**
281
- * Any router can be used to deploy and activate the HotMesh
282
- * distributed executable to the active quorum EXCEPT for
283
- * those routers in `readonly` mode.
284
- */
285
- async deployAndActivate(namespace = factory_1.APP_ID, version = factory_1.APP_VERSION) {
286
- if (isNaN(Number(version))) {
287
- throw new Error('Invalid version number');
288
- }
289
- const hotMesh = await this.getHotMeshClient('', namespace);
290
- await this.activateWorkflow(hotMesh, namespace, version);
291
- }
292
- /**
293
- * @private
294
- */
295
- async verifyWorkflowActive(hotMesh, appId = factory_1.APP_ID, count = 0) {
296
- const app = await hotMesh.engine.store.getApp(appId);
297
- const appVersion = app?.version;
298
- if (isNaN(appVersion)) {
299
- if (count > 10) {
300
- throw new Error('Workflow failed to activate');
301
- }
302
- await (0, utils_1.sleepFor)(enums_1.HMSH_QUORUM_DELAY_MS * 2);
303
- return await this.verifyWorkflowActive(hotMesh, appId, count + 1);
304
- }
305
- return true;
306
- }
307
- /**
308
- * @private
309
- */
310
- async activateWorkflow(hotMesh, appId = factory_1.APP_ID, version = factory_1.APP_VERSION) {
311
- const app = await hotMesh.engine.store.getApp(appId);
312
- const appVersion = app?.version;
313
- if (appVersion === version && !app.active) {
314
- try {
315
- await hotMesh.activate(version);
316
- }
317
- catch (error) {
318
- hotMesh.engine.logger.error('meshflow-client-activate-err', {
319
- error,
320
- });
321
- throw error;
322
- }
323
- }
324
- else if (isNaN(Number(appVersion)) || appVersion < version) {
325
- try {
326
- await hotMesh.deploy((0, factory_1.getWorkflowYAML)(appId, version));
327
- await hotMesh.activate(version);
328
- }
329
- catch (error) {
330
- hotMesh.engine.logger.error('meshflow-client-deploy-activate-err', {
331
- error,
332
- });
333
- throw error;
334
- }
335
- }
336
- }
337
- /**
338
- * @private
339
- */
340
- static async shutdown() {
341
- for (const [_, hotMeshInstance] of ClientService.instances) {
342
- (await hotMeshInstance).stop();
343
- }
344
- }
345
- }
346
- _a = ClientService;
347
- /**
348
- * @private
349
- */
350
- ClientService.topics = [];
351
- /**
352
- * @private
353
- */
354
- ClientService.instances = new Map();
355
- /**
356
- * Creates a stream where messages can be published to ensure there is a
357
- * channel in place when the message arrives (a race condition for those
358
- * platforms without implicit topic setup).
359
- * @private
360
- */
361
- ClientService.createStream = async (hotMeshClient, workflowTopic, namespace) => {
362
- const params = { appId: namespace ?? factory_1.APP_ID, topic: workflowTopic };
363
- const streamKey = hotMeshClient.engine.store.mintKey(key_1.KeyType.STREAMS, params);
364
- try {
365
- await hotMeshClient.engine.stream.createConsumerGroup(streamKey, 'WORKER');
366
- }
367
- catch (err) {
368
- //ignore if already exists
369
- }
370
- };
371
- exports.ClientService = ClientService;
@@ -1,23 +0,0 @@
1
- import { Connection } from '../../types/meshflow';
2
- import { ProviderConfig, ProvidersConfig } from '../../types/provider';
3
- /**
4
- * The Connection service is used to declare the class
5
- * and connection options but does not connect quite yet. Connection
6
- * happens at a later lifecycle stage when a workflow
7
- * is started by the MeshFlow Client module (`(new MeshFlow.Client())).start()`).
8
- *
9
- * The config options optionall support a multi-connection setup
10
- * where the `store` connection explicitly defined along with `stream`, `sub`, etc.
11
- * For example, Postgres can be used for stream and store while
12
- * Redis is used for sub.
13
- */
14
- export declare class ConnectionService {
15
- /**
16
- * @private
17
- */
18
- constructor();
19
- /**
20
- * Instance initializer
21
- */
22
- static connect(config: ProviderConfig | ProvidersConfig): Promise<Connection>;
23
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectionService = void 0;
4
- /**
5
- * The Connection service is used to declare the class
6
- * and connection options but does not connect quite yet. Connection
7
- * happens at a later lifecycle stage when a workflow
8
- * is started by the MeshFlow Client module (`(new MeshFlow.Client())).start()`).
9
- *
10
- * The config options optionall support a multi-connection setup
11
- * where the `store` connection explicitly defined along with `stream`, `sub`, etc.
12
- * For example, Postgres can be used for stream and store while
13
- * Redis is used for sub.
14
- */
15
- class ConnectionService {
16
- /**
17
- * @private
18
- */
19
- constructor() { }
20
- /**
21
- * Instance initializer
22
- */
23
- static async connect(config) {
24
- return 'store' in config
25
- ? config
26
- : {
27
- class: config.class,
28
- options: { ...config.options },
29
- provider: config.provider,
30
- };
31
- }
32
- }
33
- exports.ConnectionService = ConnectionService;
@@ -1,51 +0,0 @@
1
- import { ILogger } from '../logger';
2
- import { StoreService } from '../store';
3
- import { ExportOptions, MeshFlowJobExport, TimelineType, TransitionType, ExportFields } from '../../types/exporter';
4
- import { ProviderClient, ProviderTransaction } from '../../types/provider';
5
- import { StringStringType, Symbols } from '../../types/serializer';
6
- declare class ExporterService {
7
- appId: string;
8
- logger: ILogger;
9
- store: StoreService<ProviderClient, ProviderTransaction>;
10
- symbols: Promise<Symbols> | Symbols;
11
- private static symbols;
12
- constructor(appId: string, store: StoreService<ProviderClient, ProviderTransaction>, logger: ILogger);
13
- /**
14
- * Convert the job hash from its compiles format into a MeshFlowJobExport object with
15
- * facets that describe the workflow in terms relevant to narrative storytelling.
16
- */
17
- export(jobId: string, options?: ExportOptions): Promise<MeshFlowJobExport>;
18
- /**
19
- * Inflates the job data from Redis into a MeshFlowJobExport object
20
- * @param jobHash - the job data from Redis
21
- * @param dependencyList - the list of dependencies for the job
22
- * @returns - the inflated job data
23
- */
24
- inflate(jobHash: StringStringType, options: ExportOptions): MeshFlowJobExport;
25
- resolveValue(raw: string, withValues: boolean): Record<string, any> | string | number | null;
26
- /**
27
- * Inflates the key from Redis, 3-character symbol
28
- * into a human-readable JSON path, reflecting the
29
- * tree-like structure of the unidimensional Hash
30
- * @private
31
- */
32
- inflateKey(key: string): string;
33
- filterFields(fullObject: MeshFlowJobExport, block?: ExportFields[], allow?: ExportFields[]): Partial<MeshFlowJobExport>;
34
- inflateTransition(match: RegExpMatchArray, value: string, transitionsObject: Record<string, TransitionType>): void;
35
- sortEntriesByCreated(obj: {
36
- [key: string]: TransitionType;
37
- }): TransitionType[];
38
- /**
39
- * marker names are overloaded with details like sequence, type, etc
40
- */
41
- keyToObject(key: string): {
42
- index: number;
43
- dimension?: string;
44
- secondary?: number;
45
- };
46
- /**
47
- * idem list has a complicated sort order based on indexes and dimensions
48
- */
49
- sortParts(parts: TimelineType[]): TimelineType[];
50
- }
51
- export { ExporterService };
@@ -1 +0,0 @@
1
- 'use strict';const y=b;function a(){const L=['getRaw','updated','9jzSDhP','get','SerializerService','join','localeCompare','6502856qmtcGQ','appId','/output/metadata/ac','entries','66894lHtLFd','__esModule','defineProperty','getAllSymbols','sort','../serializer','split','resolveValue','logger','inflateKey','match','7ovBXSX','store','shift','/output/metadata/au','keyToObject','sortParts','139932aJYKKN','inflate','385767pmciYU','sortEntriesByCreated','../../modules/utils','has','restoreHierarchy','substring','1933008bMdrHA','export','values','startsWith','push','created','inflateTransition','$error','length','ExporterService','endsWith','1992138tWVggU','data','forEach','590RrLYZT','symbols','set','filterFields','2346615cqidAr','fromString'];a=function(){return L;};return a();}(function(c,d){const x=b,e=c();while(!![]){try{const f=parseInt(x(0x170))/0x1*(parseInt(x(0x141))/0x2)+-parseInt(x(0x165))/0x3+-parseInt(x(0x152))/0x4+-parseInt(x(0x16c))/0x5+-parseInt(x(0x15a))/0x6+parseInt(x(0x14c))/0x7*(-parseInt(x(0x13d))/0x8)+-parseInt(x(0x154))/0x9*(-parseInt(x(0x168))/0xa);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0x808e3));function b(c,d){const e=a();return b=function(f,g){f=f-0x13c;let h=e[f];return h;},b(c,d);}Object[y(0x143)](exports,y(0x142),{'value':!0x0}),exports[y(0x163)]=void 0x0;const utils_1=require(y(0x156)),serializer_1=require(y(0x146));class ExporterService{constructor(c,d,f){const z=y;this['appId']=c,this[z(0x149)]=f,this[z(0x14d)]=d;}async[y(0x15b)](c,d={}){const A=y;if(!ExporterService[A(0x169)][A(0x157)](this['appId'])){const g=this[A(0x14d)][A(0x144)]();ExporterService[A(0x169)][A(0x16a)](this[A(0x13e)],await g);}const f=await this['store'][A(0x16e)](c);return this[A(0x153)](f,d);}[y(0x153)](c,d){const B=y,f=[],g={},h={},j={},k=/^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;return Object[B(0x140)](c)[B(0x167)](([m,p])=>{const C=B,q=m[C(0x14b)](k);if(q)this[C(0x160)](q,p,j);else{if(m[C(0x15d)]('_'))h[m[C(0x159)](0x1)]=p;else{if(m[C(0x15d)]('-')){const u=this[C(0x150)](m);f[C(0x15e)]({...u,'key':m,'value':this[C(0x148)](p,d['values'])});}else 0x3===m[C(0x162)]&&(g[this[C(0x14a)](m)]=serializer_1[C(0x172)][C(0x16d)](p));}}}),this['filterFields']({'data':(0x0,utils_1[B(0x158)])(h),'state':Object[B(0x140)]((0x0,utils_1['restoreHierarchy'])(g))[0x0][0x1],'status':parseInt(c[':'],0xa),'timeline':this[B(0x151)](f),'transitions':this['sortEntriesByCreated'](j)},d['block'],d['allow']);}['resolveValue'](c,d){const D=y,f=serializer_1[D(0x172)][D(0x16d)](c);return!0x1!==d||f&&'object'==typeof f&&(D(0x166)in f&&(f[D(0x166)]={}),D(0x161)in f&&(f[D(0x161)]={})),f;}[y(0x14a)](c){const E=y,d=ExporterService['symbols'][E(0x171)](this[E(0x13e)]);if(c in d)return d[c]['split']('/')[E(0x173)]('/');return c;}[y(0x16b)](c,d=[],f=[]){const F=y;let g={};return f&&f[F(0x162)]>0x0?f[F(0x167)](h=>{h in c&&(g[h]=c[h]);}):g={...c},d&&d[F(0x162)]>0x0&&d['forEach'](h=>{h in g&&delete g[h];}),g;}[y(0x160)](c,f,g){const G=y,[h,j,k]=c,m=this['inflateKey'](j),p=m[G(0x147)]('/')[0x0],q=m[G(0x164)](G(0x13f)),u=m[G(0x164)](G(0x14f));if(q||u){const v=p+','+k,w=g[v];w?w[q?G(0x15f):G(0x16f)]=f:g[v]={'activity':p,'dimensions':k,'created':q?f:null,'updated':u?f:null};}}[y(0x155)](c){const H=y,d=Object[H(0x15c)](c);return d[H(0x145)]((f,g)=>(f[H(0x15f)]||f[H(0x16f)])[H(0x13c)](g[H(0x15f)]||g['updated'])),d;}[y(0x150)](c){const J=y;function d(g){const I=b,h=g[I(0x147)](',');if(h[I(0x162)]>0x1)return h[I(0x14e)](),h[I(0x173)](',');}const f=c['split']('-');return 0x4===f[J(0x162)]?{'index':parseInt(f[0x2],0xa),'dimension':d(f[0x1])}:{'index':parseInt(f[0x2],0xa),'secondary':parseInt(f[0x3],0xa),'dimension':d(f[0x1])};}[y(0x151)](c){const K=y;return c[K(0x145)]((d,f)=>{const {dimension:g,index:h,secondary:j}=d,{dimension:k,index:l,secondary:m}=f;if(void 0x0===g&&void 0x0!==k)return-0x1;if(void 0x0!==g&&void 0x0===k)return 0x1;if(void 0x0!==g&&void 0x0!==k){if(g<k)return-0x1;if(g>k)return 0x1;}if(h<l)return-0x1;if(h>l)return 0x1;if(void 0x0===j&&void 0x0!==m)return-0x1;if(void 0x0!==j&&void 0x0===m)return 0x1;if(void 0x0!==j&&void 0x0!==m){if(j<m)return-0x1;if(j>m)return 0x1;}return 0x0;});}}exports['ExporterService']=ExporterService,ExporterService[y(0x169)]=new Map();