@hotmeshio/hotmesh 0.3.29 → 0.3.31

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 (193) hide show
  1. package/build/index.d.ts +8 -2
  2. package/build/index.js +13 -7
  3. package/build/modules/enums.d.ts +65 -1
  4. package/build/modules/enums.js +79 -5
  5. package/build/modules/key.d.ts +52 -0
  6. package/build/modules/key.js +1 -1
  7. package/build/modules/utils.d.ts +73 -0
  8. package/build/modules/utils.js +1 -1
  9. package/build/package.json +6 -4
  10. package/build/services/activities/activity.d.ts +36 -0
  11. package/build/services/activities/activity.js +1 -1
  12. package/build/services/activities/await.js +1 -1
  13. package/build/services/activities/cycle.d.ts +7 -0
  14. package/build/services/activities/cycle.js +1 -1
  15. package/build/services/activities/hook.d.ts +6 -0
  16. package/build/services/activities/hook.js +1 -1
  17. package/build/services/activities/index.js +1 -1
  18. package/build/services/activities/interrupt.js +1 -1
  19. package/build/services/activities/signal.d.ts +6 -0
  20. package/build/services/activities/signal.js +1 -1
  21. package/build/services/activities/trigger.d.ts +7 -0
  22. package/build/services/activities/trigger.js +1 -1
  23. package/build/services/activities/worker.js +1 -1
  24. package/build/services/collator/index.d.ts +76 -0
  25. package/build/services/collator/index.js +1 -1
  26. package/build/services/compiler/deployer.js +1 -1
  27. package/build/services/compiler/index.d.ts +15 -0
  28. package/build/services/compiler/index.js +1 -1
  29. package/build/services/compiler/validator.d.ts +3 -0
  30. package/build/services/compiler/validator.js +1 -1
  31. package/build/services/connector/factory.d.ts +14 -0
  32. package/build/services/connector/factory.js +22 -2
  33. package/build/services/connector/index.d.ts +13 -1
  34. package/build/services/connector/index.js +13 -1
  35. package/build/services/connector/providers/postgres.js +7 -0
  36. package/build/services/engine/index.d.ts +162 -0
  37. package/build/services/engine/index.js +1 -1
  38. package/build/services/exporter/index.d.ts +27 -0
  39. package/build/services/exporter/index.js +1 -1
  40. package/build/services/hotmesh/index.d.ts +280 -0
  41. package/build/services/hotmesh/index.js +286 -0
  42. package/build/services/logger/index.js +1 -0
  43. package/build/services/mapper/index.d.ts +14 -0
  44. package/build/services/mapper/index.js +1 -1
  45. package/build/services/meshcall/index.d.ts +171 -0
  46. package/build/services/meshcall/index.js +190 -0
  47. package/build/services/meshcall/schemas/factory.d.ts +7 -0
  48. package/build/services/meshcall/schemas/factory.js +7 -0
  49. package/build/services/meshdata/index.d.ts +725 -3
  50. package/build/services/meshdata/index.js +689 -3
  51. package/build/services/meshflow/client.d.ts +89 -0
  52. package/build/services/meshflow/client.js +173 -4
  53. package/build/services/meshflow/connection.d.ts +17 -0
  54. package/build/services/meshflow/connection.js +17 -0
  55. package/build/services/meshflow/exporter.d.ts +22 -0
  56. package/build/services/meshflow/exporter.js +1 -1
  57. package/build/services/meshflow/handle.d.ts +68 -0
  58. package/build/services/meshflow/handle.js +75 -0
  59. package/build/services/meshflow/index.d.ts +92 -0
  60. package/build/services/meshflow/index.js +92 -0
  61. package/build/services/meshflow/schemas/factory.d.ts +25 -0
  62. package/build/services/meshflow/schemas/factory.js +26 -1
  63. package/build/services/meshflow/search.d.ts +120 -0
  64. package/build/services/meshflow/search.js +108 -0
  65. package/build/services/meshflow/worker.d.ts +97 -0
  66. package/build/services/meshflow/worker.js +116 -2
  67. package/build/services/meshflow/workflow/all.d.ts +6 -0
  68. package/build/services/meshflow/workflow/all.js +7 -0
  69. package/build/services/meshflow/workflow/context.d.ts +4 -0
  70. package/build/services/meshflow/workflow/context.js +4 -0
  71. package/build/services/meshflow/workflow/didRun.d.ts +6 -0
  72. package/build/services/meshflow/workflow/didRun.js +6 -0
  73. package/build/services/meshflow/workflow/emit.d.ts +7 -0
  74. package/build/services/meshflow/workflow/emit.js +7 -0
  75. package/build/services/meshflow/workflow/enrich.d.ts +7 -0
  76. package/build/services/meshflow/workflow/enrich.js +7 -0
  77. package/build/services/meshflow/workflow/execChild.d.ts +14 -0
  78. package/build/services/meshflow/workflow/execChild.js +18 -0
  79. package/build/services/meshflow/workflow/hook.d.ts +7 -0
  80. package/build/services/meshflow/workflow/hook.js +7 -0
  81. package/build/services/meshflow/workflow/index.d.ts +31 -0
  82. package/build/services/meshflow/workflow/index.js +31 -0
  83. package/build/services/meshflow/workflow/interrupt.d.ts +7 -0
  84. package/build/services/meshflow/workflow/interrupt.js +7 -0
  85. package/build/services/meshflow/workflow/isSideEffectAllowed.d.ts +8 -0
  86. package/build/services/meshflow/workflow/isSideEffectAllowed.js +8 -0
  87. package/build/services/meshflow/workflow/proxyActivities.d.ts +14 -0
  88. package/build/services/meshflow/workflow/proxyActivities.js +18 -3
  89. package/build/services/meshflow/workflow/random.d.ts +5 -0
  90. package/build/services/meshflow/workflow/random.js +5 -0
  91. package/build/services/meshflow/workflow/searchMethods.d.ts +4 -0
  92. package/build/services/meshflow/workflow/searchMethods.js +4 -0
  93. package/build/services/meshflow/workflow/signal.d.ts +6 -0
  94. package/build/services/meshflow/workflow/signal.js +6 -0
  95. package/build/services/meshflow/workflow/sleepFor.d.ts +7 -0
  96. package/build/services/meshflow/workflow/sleepFor.js +7 -0
  97. package/build/services/meshflow/workflow/trace.d.ts +10 -0
  98. package/build/services/meshflow/workflow/trace.js +10 -0
  99. package/build/services/meshflow/workflow/waitFor.d.ts +7 -0
  100. package/build/services/meshflow/workflow/waitFor.js +7 -0
  101. package/build/services/meshos/index.d.ts +213 -2
  102. package/build/services/meshos/index.js +221 -1
  103. package/build/services/pipe/functions/array.js +1 -1
  104. package/build/services/pipe/functions/bitwise.js +1 -1
  105. package/build/services/pipe/functions/conditional.js +1 -1
  106. package/build/services/pipe/functions/cron.d.ts +6 -0
  107. package/build/services/pipe/functions/cron.js +1 -1
  108. package/build/services/pipe/functions/date.d.ts +7 -0
  109. package/build/services/pipe/functions/date.js +1 -1
  110. package/build/services/pipe/functions/index.js +1 -1
  111. package/build/services/pipe/functions/json.js +1 -1
  112. package/build/services/pipe/functions/logical.js +1 -1
  113. package/build/services/pipe/functions/math.js +1 -1
  114. package/build/services/pipe/functions/number.js +1 -1
  115. package/build/services/pipe/functions/object.js +1 -1
  116. package/build/services/pipe/functions/string.js +1 -1
  117. package/build/services/pipe/functions/symbol.js +1 -1
  118. package/build/services/pipe/functions/unary.js +1 -1
  119. package/build/services/pipe/index.d.ts +15 -0
  120. package/build/services/pipe/index.js +1 -1
  121. package/build/services/quorum/index.d.ts +49 -0
  122. package/build/services/quorum/index.js +1 -1
  123. package/build/services/reporter/index.d.ts +5 -0
  124. package/build/services/reporter/index.js +1 -1
  125. package/build/services/router/index.d.ts +10 -0
  126. package/build/services/router/index.js +1 -1
  127. package/build/services/search/providers/postgres/postgres.d.ts +3 -0
  128. package/build/services/search/providers/postgres/postgres.js +1 -1
  129. package/build/services/search/providers/redis/ioredis.js +1 -1
  130. package/build/services/search/providers/redis/redis.js +1 -1
  131. package/build/services/serializer/index.js +1 -1
  132. package/build/services/store/cache.d.ts +19 -0
  133. package/build/services/store/cache.js +19 -0
  134. package/build/services/store/factory.js +1 -1
  135. package/build/services/store/providers/postgres/kvsql.d.ts +7 -0
  136. package/build/services/store/providers/postgres/kvsql.js +1 -1
  137. package/build/services/store/providers/postgres/kvtables.d.ts +4 -0
  138. package/build/services/store/providers/postgres/kvtables.js +1 -1
  139. package/build/services/store/providers/postgres/kvtransaction.js +1 -1
  140. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +4 -0
  141. package/build/services/store/providers/postgres/kvtypes/hash.js +1 -1
  142. package/build/services/store/providers/postgres/kvtypes/list.js +1 -1
  143. package/build/services/store/providers/postgres/kvtypes/string.js +1 -1
  144. package/build/services/store/providers/postgres/kvtypes/zset.js +1 -1
  145. package/build/services/store/providers/postgres/postgres.d.ts +48 -1
  146. package/build/services/store/providers/postgres/postgres.js +1 -1
  147. package/build/services/store/providers/redis/_base.d.ts +42 -0
  148. package/build/services/store/providers/redis/_base.js +1 -1
  149. package/build/services/store/providers/redis/ioredis.d.ts +8 -0
  150. package/build/services/store/providers/redis/ioredis.js +1 -1
  151. package/build/services/store/providers/redis/redis.d.ts +6 -0
  152. package/build/services/store/providers/redis/redis.js +1 -1
  153. package/build/services/store/providers/store-initializable.js +1 -1
  154. package/build/services/stream/factory.js +2 -1
  155. package/build/services/stream/index.d.ts +4 -0
  156. package/build/services/stream/providers/nats/nats.js +1 -1
  157. package/build/services/stream/providers/postgres/kvtables.js +1 -1
  158. package/build/services/stream/providers/postgres/postgres.d.ts +21 -0
  159. package/build/services/stream/providers/postgres/postgres.js +1 -1
  160. package/build/services/stream/providers/redis/ioredis.js +1 -1
  161. package/build/services/stream/providers/redis/redis.js +1 -1
  162. package/build/services/stream/providers/stream-initializable.js +1 -1
  163. package/build/services/sub/providers/nats/nats.js +1 -1
  164. package/build/services/sub/providers/postgres/postgres.js +1 -1
  165. package/build/services/sub/providers/redis/ioredis.js +1 -1
  166. package/build/services/sub/providers/redis/redis.js +1 -1
  167. package/build/services/task/index.d.ts +9 -0
  168. package/build/services/task/index.js +1 -1
  169. package/build/services/telemetry/index.d.ts +7 -0
  170. package/build/services/telemetry/index.js +1 -1
  171. package/build/services/worker/index.d.ts +37 -0
  172. package/build/services/worker/index.js +1 -1
  173. package/build/types/activity.d.ts +81 -0
  174. package/build/types/exporter.d.ts +13 -0
  175. package/build/types/hotmesh.d.ts +144 -0
  176. package/build/types/hotmesh.js +3 -0
  177. package/build/types/job.d.ts +101 -0
  178. package/build/types/manifest.d.ts +8 -0
  179. package/build/types/meshcall.d.ts +148 -0
  180. package/build/types/meshdata.d.ts +193 -0
  181. package/build/types/meshflow.d.ts +297 -0
  182. package/build/types/nats.d.ts +55 -0
  183. package/build/types/pipe.d.ts +65 -0
  184. package/build/types/provider.d.ts +43 -0
  185. package/build/types/quorum.d.ts +12 -0
  186. package/build/types/redis.d.ts +6 -0
  187. package/build/types/stream.d.ts +65 -0
  188. package/build/types/stream.js +4 -0
  189. package/index.ts +8 -1
  190. package/package.json +6 -4
  191. package/types/manifest.ts +2 -2
  192. package/types/meshcall.ts +1 -2
  193. package/types/meshdata.ts +1 -1
@@ -8,8 +8,42 @@ const utils_1 = require("../../modules/utils");
8
8
  const key_1 = require("../../modules/key");
9
9
  const cron_1 = require("../pipe/functions/cron");
10
10
  const factory_1 = require("./schemas/factory");
11
+ /**
12
+ * MeshCall connects any function as an idempotent endpoint.
13
+ * Call functions from anywhere on the network connected to the
14
+ * target backend (Postgres, Redis/ValKey, NATS, etc). Function
15
+ * responses are cacheable and invocations can be scheduled to
16
+ * run as idempotent cron jobs (this one runs nightly at midnight
17
+ * and uses Postgres as the backend provider).
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { Client as Postgres } from 'pg';
22
+ * import { MeshCall } from '@hotmesh/meshcall';
23
+ *
24
+ * MeshCall.cron({
25
+ * topic: 'my.cron.function',
26
+ * connection: {
27
+ * class: Postgres,
28
+ * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
29
+ * },
30
+ * callback: async () => {
31
+ * //your code here...anything goes
32
+ * },
33
+ * options: { id: 'myDailyCron123', interval: '0 0 * * *' }
34
+ * });
35
+ * ```
36
+ */
11
37
  class MeshCall {
38
+ /**
39
+ * @private
40
+ */
12
41
  constructor() { }
42
+ /**
43
+ * iterates cached worker/engine instances to locate the first match
44
+ * with the provided namespace and connection options
45
+ * @private
46
+ */
13
47
  static async findFirstMatching(targets, namespace = key_1.HMNS, config, options = {}) {
14
48
  for (const [id, hotMeshInstance] of targets) {
15
49
  const hotMesh = await hotMeshInstance;
@@ -23,6 +57,9 @@ class MeshCall {
23
57
  }
24
58
  }
25
59
  }
60
+ /**
61
+ * @private
62
+ */
26
63
  static async verifyWorkflowActive(hotMesh, appId = key_1.HMNS, count = 0) {
27
64
  const app = await hotMesh.engine.store.getApp(appId);
28
65
  const appVersion = app?.version;
@@ -35,6 +72,9 @@ class MeshCall {
35
72
  }
36
73
  return true;
37
74
  }
75
+ /**
76
+ * @private
77
+ */
38
78
  static async activateWorkflow(hotMesh, appId = key_1.HMNS, version = factory_1.VERSION) {
39
79
  const app = await hotMesh.engine.store.getApp(appId);
40
80
  const appVersion = app?.version;
@@ -62,6 +102,10 @@ class MeshCall {
62
102
  }
63
103
  }
64
104
  }
105
+ /**
106
+ * Returns a cached worker instance or creates a new one
107
+ * @private
108
+ */
65
109
  static async getInstance(namespace, providerConfig, options = {}) {
66
110
  let hotMeshInstance;
67
111
  if (!options.readonly) {
@@ -75,11 +119,18 @@ class MeshCall {
75
119
  }
76
120
  return hotMeshInstance;
77
121
  }
122
+ /**
123
+ * connection re-use is important when making repeated calls, but
124
+ * only if the connection options are an exact match. this method
125
+ * hashes the connection options to ensure that the same connection
126
+ */
78
127
  static hashOptions(connection) {
79
128
  if ('options' in connection) {
129
+ //shorthand format
80
130
  return (0, utils_1.hashOptions)(connection.options);
81
131
  }
82
132
  else {
133
+ //longhand format (sub, store, stream, pub, search)
83
134
  const response = [];
84
135
  for (const p in connection) {
85
136
  if (connection[p].options) {
@@ -89,6 +140,25 @@ class MeshCall {
89
140
  return response.join('');
90
141
  }
91
142
  }
143
+ /**
144
+ * Connects and links a worker function to the mesh
145
+ * @example
146
+ * ```typescript
147
+ * import { Client as Postgres } from 'pg';
148
+ * import { MeshCall } from '@hotmesh/meshcall';
149
+ *
150
+ * MeshCall.connect({
151
+ * topic: 'my.function',
152
+ * connection: {
153
+ * class: Postgres,
154
+ * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
155
+ * },
156
+ * callback: async (arg1: any) => {
157
+ * //your code here...
158
+ * }
159
+ * });
160
+ * ```
161
+ */
92
162
  static async connect(params) {
93
163
  const targetNamespace = params.namespace ?? key_1.HMNS;
94
164
  const optionsHash = MeshCall.hashOptions(utils_1.polyfill.providerConfig(params));
@@ -117,6 +187,23 @@ class MeshCall {
117
187
  await MeshCall.activateWorkflow(hotMeshWorker, targetNamespace);
118
188
  return hotMeshWorker;
119
189
  }
190
+ /**
191
+ * Calls a function and returns the response.
192
+ *
193
+ * @template U - the return type of the linked worker function
194
+ *
195
+ * @example
196
+ * ```typescript
197
+ * const response = await MeshCall.exec({
198
+ * topic: 'my.function',
199
+ * args: [{ my: 'args' }],
200
+ * connection: {
201
+ * class: Postgres,
202
+ * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
203
+ * }
204
+ * });
205
+ * ```
206
+ */
120
207
  static async exec(params) {
121
208
  const TOPIC = `${params.namespace ?? key_1.HMNS}.call`;
122
209
  const hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params));
@@ -126,13 +213,16 @@ class MeshCall {
126
213
  await hotMeshInstance.scrub(id);
127
214
  }
128
215
  else if (params.options?.ttl) {
216
+ //check cache
129
217
  try {
130
218
  const cached = await hotMeshInstance.getState(TOPIC, id);
131
219
  if (cached) {
220
+ //todo: check if present; await if not (subscribe)
132
221
  return cached.data.response;
133
222
  }
134
223
  }
135
224
  catch (error) {
225
+ //just swallow error; it means the cache is empty (no doc by that id)
136
226
  }
137
227
  }
138
228
  }
@@ -146,14 +236,59 @@ class MeshCall {
146
236
  const jobOutput = await hotMeshInstance.pubsub(TOPIC, { id, expire, topic: params.topic, args: params.args }, null, 30000);
147
237
  return jobOutput?.data?.response;
148
238
  }
239
+ /**
240
+ * Clears a cached function response.
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * import { Client as Postgres } from 'pg';
245
+ * import { MeshCall } from '@hotmesh/meshcall';
246
+ *
247
+ * MeshCall.flush({
248
+ * topic: 'my.function',
249
+ * connection: {
250
+ * class: Postgres,
251
+ * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
252
+ * },
253
+ * options: { id: 'myCachedExecFunctionId' }
254
+ * });
255
+ * ```
256
+ */
149
257
  static async flush(params) {
150
258
  const hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params));
151
259
  await hotMeshInstance.scrub(params.id ?? params?.options?.id);
152
260
  }
261
+ /**
262
+ * Schedules a cron job to run at a specified interval
263
+ * with optional args. Provided arguments are passed to the
264
+ * callback function each time the cron job runs. The `id`
265
+ * option is used to uniquely identify the cron job, allowing
266
+ * it to be interrupted at any time.
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * import { Client as Postgres } from 'pg';
271
+ * import { MeshCall } from '@hotmesh/meshcall';
272
+ *
273
+ * MeshCall.cron({
274
+ * topic: 'my.cron.function',
275
+ * args: ['arg1', 'arg2'], //optionally pass args
276
+ * connection: {
277
+ * class: Postgres,
278
+ * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
279
+ * },
280
+ * callback: async (arg1: any, arg2: any) => {
281
+ * //your code here...
282
+ * },
283
+ * options: { id: 'myDailyCron123', interval: '0 0 * * *' }
284
+ * });
285
+ * ```
286
+ */
153
287
  static async cron(params) {
154
288
  let hotMeshInstance;
155
289
  let readonly = true;
156
290
  if (params.callback) {
291
+ //always connect cron worker if provided
157
292
  hotMeshInstance = await MeshCall.connect({
158
293
  logLevel: params.logLevel,
159
294
  guid: params.guid,
@@ -165,13 +300,19 @@ class MeshCall {
165
300
  readonly = false;
166
301
  }
167
302
  else {
303
+ //this is a readonly cron connection which means
304
+ //it is only being created to connect as a readonly member
305
+ //of the mesh network that the cron is running on. it
306
+ //can start a job, but it cannot run the job itself in RO mode.
168
307
  }
308
+ //configure job inputs
169
309
  const TOPIC = `${params.namespace ?? key_1.HMNS}.cron`;
170
310
  const maxCycles = params.options.maxCycles ?? 100000;
171
311
  let interval = enums_1.HMSH_FIDELITY_SECONDS;
172
312
  let delay;
173
313
  let cron;
174
314
  if ((0, utils_1.isValidCron)(params.options.interval)) {
315
+ //cron syntax
175
316
  cron = params.options.interval;
176
317
  const nextDelay = new cron_1.CronHandler().nextDelay(cron);
177
318
  delay = nextDelay > 0 ? nextDelay : undefined;
@@ -183,9 +324,11 @@ class MeshCall {
183
324
  }
184
325
  try {
185
326
  if (!hotMeshInstance) {
327
+ //get or create a read-only engine instance to start the cron
186
328
  hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params), { readonly, guid: params.guid });
187
329
  await MeshCall.createStream(hotMeshInstance, params.topic, params.namespace);
188
330
  }
331
+ //spawn the job (ok if it's a duplicate)
189
332
  await hotMeshInstance.pub(TOPIC, {
190
333
  id: params.options.id,
191
334
  topic: params.topic,
@@ -204,16 +347,41 @@ class MeshCall {
204
347
  throw error;
205
348
  }
206
349
  }
350
+ /**
351
+ * Interrupts a running cron job. Returns `true` if the job
352
+ * was successfully interrupted, or `false` if the job was not
353
+ * found.
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * import { Client as Postgres } from 'pg';
358
+ * import { MeshCall } from '@hotmesh/meshcall';
359
+ *
360
+ * MeshCall.interrupt({
361
+ * topic: 'my.cron.function',
362
+ * connection: {
363
+ * class: Postgres,
364
+ * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }
365
+ * },
366
+ * options: { id: 'myDailyCron123' }
367
+ * });
368
+ * ```
369
+ */
207
370
  static async interrupt(params) {
208
371
  const hotMeshInstance = await MeshCall.getInstance(params.namespace, utils_1.polyfill.providerConfig(params));
209
372
  try {
210
373
  await hotMeshInstance.interrupt(`${params.namespace ?? key_1.HMNS}.cron`, params.options.id, { throw: false, expire: 1 });
211
374
  }
212
375
  catch (error) {
376
+ //job doesn't exist; is already stopped
213
377
  return false;
214
378
  }
215
379
  return true;
216
380
  }
381
+ /**
382
+ * Shuts down all meshcall instances. Call this method
383
+ * from the SIGTERM handler in your application.
384
+ */
217
385
  static async shutdown() {
218
386
  for (const [_, hotMeshInstance] of MeshCall.workers) {
219
387
  (await hotMeshInstance).stop();
@@ -226,10 +394,24 @@ class MeshCall {
226
394
  }
227
395
  exports.MeshCall = MeshCall;
228
396
  _a = MeshCall;
397
+ /**
398
+ * @private
399
+ */
229
400
  MeshCall.workers = new Map();
401
+ /**
402
+ * @private
403
+ */
230
404
  MeshCall.engines = new Map();
405
+ /**
406
+ * @private
407
+ */
231
408
  MeshCall.connections = new Map();
409
+ /**
410
+ * @private
411
+ */
232
412
  MeshCall.getHotMeshClient = async (namespace, connection, options = {}) => {
413
+ //namespace isolation requires the connection options to be hashed
414
+ //as multiple intersecting databases can be used by the same service
233
415
  const optionsHash = MeshCall.hashOptions(connection);
234
416
  const targetNS = namespace ?? key_1.HMNS;
235
417
  const connectionNS = `${optionsHash}.${targetNS}`;
@@ -238,6 +420,7 @@ MeshCall.getHotMeshClient = async (namespace, connection, options = {}) => {
238
420
  await _a.verifyWorkflowActive(hotMeshClient, targetNS);
239
421
  return hotMeshClient;
240
422
  }
423
+ //create and cache an instance
241
424
  const hotMeshClient = hotmesh_1.HotMesh.init({
242
425
  guid: options.guid,
243
426
  appId: targetNS,
@@ -251,6 +434,12 @@ MeshCall.getHotMeshClient = async (namespace, connection, options = {}) => {
251
434
  await _a.activateWorkflow(await hotMeshClient, targetNS);
252
435
  return hotMeshClient;
253
436
  };
437
+ /**
438
+ * Creates a stream where messages can be published to ensure there is a
439
+ * channel in place when the message arrives (a race condition for those
440
+ * platforms without implicit topic setup).
441
+ * @private
442
+ */
254
443
  MeshCall.createStream = async (hotMeshClient, workflowTopic, namespace) => {
255
444
  const params = { appId: namespace ?? key_1.HMNS, topic: workflowTopic };
256
445
  const streamKey = hotMeshClient.engine.store.mintKey(key_1.KeyType.STREAMS, params);
@@ -258,5 +447,6 @@ MeshCall.createStream = async (hotMeshClient, workflowTopic, namespace) => {
258
447
  await hotMeshClient.engine.stream.createConsumerGroup(streamKey, 'WORKER');
259
448
  }
260
449
  catch (err) {
450
+ //ignore if already exists
261
451
  }
262
452
  };
@@ -1,2 +1,9 @@
1
1
  export declare const VERSION = "2";
2
+ /**
3
+ * Provides the YAML necessary to create a workflow for the `MeshCall` service.
4
+ * The `appId` parameter is optional and defaults to the HMNS constant ('hmsh').
5
+ *
6
+ * The version is a string as it supports semantic versioning. It is also optional
7
+ * and defaults to '1'.
8
+ */
2
9
  export declare const getWorkflowYAML: (appId?: string, version?: string) => string;
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWorkflowYAML = exports.VERSION = void 0;
4
4
  const key_1 = require("../../../modules/key");
5
5
  exports.VERSION = '2';
6
+ /**
7
+ * Provides the YAML necessary to create a workflow for the `MeshCall` service.
8
+ * The `appId` parameter is optional and defaults to the HMNS constant ('hmsh').
9
+ *
10
+ * The version is a string as it supports semantic versioning. It is also optional
11
+ * and defaults to '1'.
12
+ */
6
13
  const getWorkflowYAML = (appId = key_1.HMNS, version = exports.VERSION) => {
7
14
  return `app:
8
15
  id: ${appId}