@hotmeshio/hotmesh 0.0.55 → 0.0.56

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 (181) hide show
  1. package/build/modules/enums.js +1 -10
  2. package/build/modules/key.d.ts +0 -38
  3. package/build/modules/key.js +4 -46
  4. package/build/modules/utils.d.ts +0 -8
  5. package/build/modules/utils.js +0 -14
  6. package/build/package.json +11 -4
  7. package/build/services/activities/activity.d.ts +0 -28
  8. package/build/services/activities/activity.js +1 -46
  9. package/build/services/activities/await.js +0 -4
  10. package/build/services/activities/cycle.d.ts +0 -7
  11. package/build/services/activities/cycle.js +1 -16
  12. package/build/services/activities/hook.d.ts +0 -6
  13. package/build/services/activities/hook.js +2 -12
  14. package/build/services/activities/interrupt.js +0 -8
  15. package/build/services/activities/signal.d.ts +0 -6
  16. package/build/services/activities/signal.js +0 -15
  17. package/build/services/activities/trigger.d.ts +0 -4
  18. package/build/services/activities/trigger.js +1 -7
  19. package/build/services/activities/worker.js +0 -4
  20. package/build/services/collator/index.d.ts +0 -70
  21. package/build/services/collator/index.js +1 -91
  22. package/build/services/compiler/deployer.js +6 -38
  23. package/build/services/compiler/index.d.ts +0 -15
  24. package/build/services/compiler/index.js +0 -20
  25. package/build/services/compiler/validator.d.ts +0 -3
  26. package/build/services/compiler/validator.js +0 -25
  27. package/build/services/connector/clients/ioredis.d.ts +2 -2
  28. package/build/services/connector/clients/ioredis.js +0 -2
  29. package/build/services/connector/clients/redis.d.ts +4 -4
  30. package/build/services/connector/clients/redis.js +1 -3
  31. package/build/services/connector/index.d.ts +1 -1
  32. package/build/services/connector/index.js +0 -2
  33. package/build/services/durable/client.d.ts +1 -26
  34. package/build/services/durable/client.js +0 -56
  35. package/build/services/durable/exporter.d.ts +0 -22
  36. package/build/services/durable/exporter.js +1 -30
  37. package/build/services/durable/handle.d.ts +0 -36
  38. package/build/services/durable/handle.js +0 -46
  39. package/build/services/durable/index.d.ts +0 -4
  40. package/build/services/durable/index.js +0 -4
  41. package/build/services/durable/schemas/factory.d.ts +0 -29
  42. package/build/services/durable/schemas/factory.js +0 -29
  43. package/build/services/durable/search.d.ts +1 -36
  44. package/build/services/durable/search.js +57 -56
  45. package/build/services/durable/worker.js +2 -22
  46. package/build/services/durable/workflow.d.ts +0 -114
  47. package/build/services/durable/workflow.js +1 -141
  48. package/build/services/engine/index.d.ts +1 -6
  49. package/build/services/engine/index.js +1 -43
  50. package/build/services/exporter/index.d.ts +0 -27
  51. package/build/services/exporter/index.js +0 -33
  52. package/build/services/hotmesh/index.d.ts +2 -2
  53. package/build/services/hotmesh/index.js +1 -9
  54. package/build/services/logger/index.js +0 -2
  55. package/build/services/mapper/index.d.ts +0 -14
  56. package/build/services/mapper/index.js +0 -14
  57. package/build/services/pipe/functions/date.d.ts +0 -7
  58. package/build/services/pipe/functions/date.js +0 -7
  59. package/build/services/pipe/functions/math.js +0 -2
  60. package/build/services/pipe/index.d.ts +0 -15
  61. package/build/services/pipe/index.js +2 -23
  62. package/build/services/quorum/index.d.ts +0 -7
  63. package/build/services/quorum/index.js +0 -21
  64. package/build/services/reporter/index.d.ts +0 -5
  65. package/build/services/reporter/index.js +0 -9
  66. package/build/services/router/index.d.ts +0 -9
  67. package/build/services/router/index.js +2 -38
  68. package/build/services/serializer/index.js +7 -26
  69. package/build/services/store/cache.d.ts +0 -18
  70. package/build/services/store/cache.js +0 -18
  71. package/build/services/store/clients/ioredis.d.ts +1 -1
  72. package/build/services/store/clients/ioredis.js +0 -1
  73. package/build/services/store/clients/redis.d.ts +1 -1
  74. package/build/services/store/index.d.ts +0 -55
  75. package/build/services/store/index.js +5 -81
  76. package/build/services/stream/clients/ioredis.d.ts +1 -1
  77. package/build/services/stream/clients/ioredis.js +1 -4
  78. package/build/services/stream/clients/redis.d.ts +1 -1
  79. package/build/services/sub/clients/ioredis.d.ts +1 -1
  80. package/build/services/sub/clients/redis.d.ts +1 -1
  81. package/build/services/task/index.d.ts +0 -9
  82. package/build/services/task/index.js +0 -31
  83. package/build/services/telemetry/index.d.ts +0 -7
  84. package/build/services/telemetry/index.js +1 -13
  85. package/build/services/worker/index.d.ts +0 -4
  86. package/build/services/worker/index.js +2 -6
  87. package/build/types/activity.d.ts +0 -81
  88. package/build/types/durable.d.ts +25 -177
  89. package/build/types/exporter.d.ts +0 -13
  90. package/build/types/hotmesh.d.ts +4 -16
  91. package/build/types/hotmesh.js +0 -3
  92. package/build/types/index.d.ts +4 -6
  93. package/build/types/index.js +4 -3
  94. package/build/types/job.d.ts +1 -86
  95. package/build/types/pipe.d.ts +0 -65
  96. package/build/types/quorum.d.ts +15 -10
  97. package/build/types/redis.d.ts +225 -7
  98. package/build/types/redis.js +9 -0
  99. package/build/types/stream.d.ts +0 -58
  100. package/build/types/stream.js +0 -4
  101. package/package.json +11 -4
  102. package/types/durable.ts +121 -3
  103. package/types/hotmesh.ts +3 -6
  104. package/types/index.ts +23 -10
  105. package/types/job.ts +1 -1
  106. package/types/quorum.ts +22 -0
  107. package/types/redis.ts +267 -18
  108. package/build/types/ioredisclient.d.ts +0 -5
  109. package/build/types/ioredisclient.js +0 -5
  110. package/build/types/redisclient.d.ts +0 -26
  111. package/build/types/redisclient.js +0 -2
  112. package/modules/enums.ts +0 -62
  113. package/modules/errors.ts +0 -280
  114. package/modules/key.ts +0 -101
  115. package/modules/storage.ts +0 -3
  116. package/modules/utils.ts +0 -242
  117. package/services/activities/activity.ts +0 -589
  118. package/services/activities/await.ts +0 -113
  119. package/services/activities/cycle.ts +0 -115
  120. package/services/activities/hook.ts +0 -197
  121. package/services/activities/index.ts +0 -19
  122. package/services/activities/interrupt.ts +0 -172
  123. package/services/activities/signal.ts +0 -148
  124. package/services/activities/trigger.ts +0 -295
  125. package/services/activities/worker.ts +0 -107
  126. package/services/collator/README.md +0 -102
  127. package/services/collator/index.ts +0 -291
  128. package/services/compiler/deployer.ts +0 -504
  129. package/services/compiler/index.ts +0 -98
  130. package/services/compiler/validator.ts +0 -158
  131. package/services/connector/clients/ioredis.ts +0 -57
  132. package/services/connector/clients/redis.ts +0 -72
  133. package/services/connector/index.ts +0 -42
  134. package/services/durable/client.ts +0 -266
  135. package/services/durable/connection.ts +0 -10
  136. package/services/durable/exporter.ts +0 -232
  137. package/services/durable/handle.ts +0 -160
  138. package/services/durable/index.ts +0 -27
  139. package/services/durable/schemas/factory.ts +0 -2358
  140. package/services/durable/search.ts +0 -196
  141. package/services/durable/worker.ts +0 -401
  142. package/services/durable/workflow.ts +0 -557
  143. package/services/engine/index.ts +0 -761
  144. package/services/exporter/index.ts +0 -146
  145. package/services/hotmesh/index.ts +0 -237
  146. package/services/logger/index.ts +0 -79
  147. package/services/mapper/index.ts +0 -89
  148. package/services/pipe/functions/array.ts +0 -78
  149. package/services/pipe/functions/bitwise.ts +0 -27
  150. package/services/pipe/functions/conditional.ts +0 -35
  151. package/services/pipe/functions/date.ts +0 -220
  152. package/services/pipe/functions/index.ts +0 -27
  153. package/services/pipe/functions/json.ts +0 -11
  154. package/services/pipe/functions/logical.ts +0 -11
  155. package/services/pipe/functions/math.ts +0 -217
  156. package/services/pipe/functions/number.ts +0 -75
  157. package/services/pipe/functions/object.ts +0 -98
  158. package/services/pipe/functions/string.ts +0 -86
  159. package/services/pipe/functions/symbol.ts +0 -39
  160. package/services/pipe/functions/unary.ts +0 -19
  161. package/services/pipe/index.ts +0 -216
  162. package/services/quorum/index.ts +0 -319
  163. package/services/reporter/index.ts +0 -387
  164. package/services/router/index.ts +0 -426
  165. package/services/serializer/README.md +0 -10
  166. package/services/serializer/index.ts +0 -285
  167. package/services/store/cache.ts +0 -172
  168. package/services/store/clients/ioredis.ts +0 -145
  169. package/services/store/clients/redis.ts +0 -191
  170. package/services/store/index.ts +0 -1091
  171. package/services/stream/clients/ioredis.ts +0 -157
  172. package/services/stream/clients/redis.ts +0 -158
  173. package/services/stream/index.ts +0 -58
  174. package/services/sub/clients/ioredis.ts +0 -83
  175. package/services/sub/clients/redis.ts +0 -74
  176. package/services/sub/index.ts +0 -25
  177. package/services/task/index.ts +0 -250
  178. package/services/telemetry/index.ts +0 -273
  179. package/services/worker/index.ts +0 -248
  180. package/types/ioredisclient.ts +0 -10
  181. package/types/redisclient.ts +0 -30
@@ -96,7 +96,6 @@ class EngineService {
96
96
  if (this.cacheMode === 'nocache') {
97
97
  const app = await this.store.getApp(this.appId, true);
98
98
  if (app.version.toString() === this.untilVersion.toString()) {
99
- //new version is deployed; OK to cache again
100
99
  if (!this.apps)
101
100
  this.apps = {};
102
101
  this.apps[this.appId] = app;
@@ -134,7 +133,6 @@ class EngineService {
134
133
  async throttle(delayInMillis) {
135
134
  this.router.setThrottle(delayInMillis);
136
135
  }
137
- // ************* METADATA/MODEL METHODS *************
138
136
  async initActivity(topic, data = {}, context) {
139
137
  const [activityId, schema] = await this.getSchema(topic);
140
138
  const ActivityHandler = activities_1.default[utils_1.polyfill.resolveActivityType(schema.type)];
@@ -160,13 +158,11 @@ class EngineService {
160
158
  throw new Error(`no app found for id ${this.appId}`);
161
159
  }
162
160
  if (this.isPrivate(topic)) {
163
- //private subscriptions use the schema id (.activityId)
164
161
  const activityId = topic.substring(1);
165
162
  const schema = await this.store.getSchema(activityId, await this.getVID(app));
166
163
  return [activityId, schema];
167
164
  }
168
165
  else {
169
- //public subscriptions use a topic (a.b.c) that is associated with a schema id
170
166
  const activityId = await this.store.getSubscription(topic, await this.getVID(app));
171
167
  if (activityId) {
172
168
  const schema = await this.store.getSchema(activityId, await this.getVID(app));
@@ -181,7 +177,6 @@ class EngineService {
181
177
  isPrivate(topic) {
182
178
  return topic.startsWith('.');
183
179
  }
184
- // ************* COMPILER METHODS *************
185
180
  async plan(pathOrYAML) {
186
181
  const compiler = new compiler_1.CompilerService(this.store, this.logger);
187
182
  return await compiler.plan(pathOrYAML);
@@ -190,7 +185,6 @@ class EngineService {
190
185
  const compiler = new compiler_1.CompilerService(this.store, this.logger);
191
186
  return await compiler.deploy(pathOrYAML);
192
187
  }
193
- // ************* REPORTER METHODS *************
194
188
  async getStats(topic, query) {
195
189
  const { id, version } = await this.getVID();
196
190
  const reporter = new reporter_1.ReporterService({ id, version }, this.store, this.logger);
@@ -215,7 +209,6 @@ class EngineService {
215
209
  sparse: query.sparse,
216
210
  };
217
211
  }
218
- // ****************** STREAM RE-ENTRY POINT *****************
219
212
  async processStreamMessage(streamData) {
220
213
  this.logger.debug('engine-process-stream-message', {
221
214
  jid: streamData.metadata.jid,
@@ -237,22 +230,18 @@ class EngineService {
237
230
  data: streamData.data,
238
231
  };
239
232
  if (streamData.type === stream_1.StreamDataType.TIMEHOOK) {
240
- //TIMEHOOK AWAKEN
241
233
  const activityHandler = await this.initActivity(`.${streamData.metadata.aid}`, context.data, context);
242
234
  await activityHandler.processTimeHookEvent(streamData.metadata.jid);
243
235
  }
244
236
  else if (streamData.type === stream_1.StreamDataType.WEBHOOK) {
245
- //WEBHOOK AWAKEN (SIGNAL IN)
246
237
  const activityHandler = await this.initActivity(`.${streamData.metadata.aid}`, context.data, context);
247
238
  await activityHandler.processWebHookEvent(streamData.status, streamData.code);
248
239
  }
249
240
  else if (streamData.type === stream_1.StreamDataType.TRANSITION) {
250
- //TRANSITION (ADJACENT ACTIVITY)
251
- const activityHandler = await this.initActivity(`.${streamData.metadata.aid}`, context.data, context); //todo: `as Activity` (type is more generic)
241
+ const activityHandler = await this.initActivity(`.${streamData.metadata.aid}`, context.data, context);
252
242
  await activityHandler.process();
253
243
  }
254
244
  else if (streamData.type === stream_1.StreamDataType.AWAIT) {
255
- //TRIGGER JOB
256
245
  context.metadata = {
257
246
  ...context.metadata,
258
247
  pj: streamData.metadata.jid,
@@ -267,12 +256,10 @@ class EngineService {
267
256
  await activityHandler.process();
268
257
  }
269
258
  else if (streamData.type === stream_1.StreamDataType.RESULT) {
270
- //AWAIT RESULT
271
259
  const activityHandler = await this.initActivity(`.${context.metadata.aid}`, streamData.data, context);
272
260
  await activityHandler.processEvent(streamData.status, streamData.code);
273
261
  }
274
262
  else {
275
- //WORKER RESULT
276
263
  const activityHandler = await this.initActivity(`.${streamData.metadata.aid}`, streamData.data, context);
277
264
  await activityHandler.processEvent(streamData.status, streamData.code, 'output');
278
265
  }
@@ -282,10 +269,8 @@ class EngineService {
282
269
  aid: streamData.metadata.aid
283
270
  });
284
271
  }
285
- // ***************** `AWAIT` ACTIVITY RETURN RESPONSE ****************
286
272
  async execAdjacentParent(context, jobOutput, emit = false) {
287
273
  if (this.hasParentJob(context)) {
288
- //errors are stringified `StreamError` objects
289
274
  const error = this.resolveError(jobOutput.metadata);
290
275
  const spn = context['$self']?.output?.metadata?.l2s || context['$self']?.output?.metadata?.l1s;
291
276
  const streamData = {
@@ -329,11 +314,8 @@ class EngineService {
329
314
  return JSON.parse(metadata.err);
330
315
  }
331
316
  }
332
- // ****************** `INTERRUPT` ACTIVE JOBS *****************
333
317
  async interrupt(topic, jobId, options = {}) {
334
- //immediately interrupt the job, going directly to the data source
335
318
  await this.store.interrupt(topic, jobId, options);
336
- //now that the job is interrupted, we can clean up
337
319
  const context = await this.getState(topic, jobId);
338
320
  const completionOpts = {
339
321
  interrupt: options.descend,
@@ -341,12 +323,9 @@ class EngineService {
341
323
  };
342
324
  return await this.runJobCompletionTasks(context, completionOpts);
343
325
  }
344
- // ****************** `SCRUB` CLEAN COMPLETED JOBS *****************
345
326
  async scrub(jobId) {
346
- //todo: do not allow scrubbing of non-existent or actively running job
347
327
  await this.store.scrub(jobId);
348
328
  }
349
- // ****************** `HOOK` ACTIVITY RE-ENTRY POINT *****************
350
329
  async hook(topic, data, status = stream_1.StreamStatus.SUCCESS, code = 200) {
351
330
  const hookRule = await this.taskService.getHookRule(topic);
352
331
  const [aid] = await this.getSchema(`.${hookRule.to}`);
@@ -406,8 +385,6 @@ class EngineService {
406
385
  throw new Error(`unable to find hook rule for topic ${hookTopic}`);
407
386
  }
408
387
  }
409
- // ********************** PUB/SUB ENTRY POINT **********************
410
- //publish (returns just the job id)
411
388
  async pub(topic, data, context, extended) {
412
389
  const activityHandler = await this.initActivity(topic, data, context);
413
390
  if (activityHandler) {
@@ -417,29 +394,24 @@ class EngineService {
417
394
  throw new Error(`unable to process activity for topic ${topic}`);
418
395
  }
419
396
  }
420
- //subscribe to all jobs for a topic
421
397
  async sub(topic, callback) {
422
398
  const subscriptionCallback = async (topic, message) => {
423
399
  callback(message.topic, message.job);
424
400
  };
425
401
  return await this.subscribe.subscribe(key_1.KeyType.QUORUM, subscriptionCallback, this.appId, topic);
426
402
  }
427
- //unsubscribe to all jobs for a topic
428
403
  async unsub(topic) {
429
404
  return await this.subscribe.unsubscribe(key_1.KeyType.QUORUM, this.appId, topic);
430
405
  }
431
- //subscribe to all jobs for a wildcard topic
432
406
  async psub(wild, callback) {
433
407
  const subscriptionCallback = async (topic, message) => {
434
408
  callback(message.topic, message.job);
435
409
  };
436
410
  return await this.subscribe.psubscribe(key_1.KeyType.QUORUM, subscriptionCallback, this.appId, wild);
437
411
  }
438
- //unsubscribe to all jobs for a wildcard topic
439
412
  async punsub(wild) {
440
413
  return await this.subscribe.punsubscribe(key_1.KeyType.QUORUM, this.appId, wild);
441
414
  }
442
- //publish and await (returns the job and data (if ready)); throws error with jobid if not
443
415
  async pubsub(topic, data, context, timeout = enums_1.HMSH_OTT_WAIT_TIME) {
444
416
  context = {
445
417
  metadata: {
@@ -463,7 +435,6 @@ class EngineService {
463
435
  }
464
436
  });
465
437
  setTimeout(() => {
466
- //note: job is still active (the subscriber timed out)
467
438
  this.delistJobCallback(jobId);
468
439
  reject({
469
440
  code: enums_1.HMSH_CODE_TIMEOUT,
@@ -474,7 +445,6 @@ class EngineService {
474
445
  });
475
446
  }
476
447
  async pubOneTimeSubs(context, jobOutput, emit = false) {
477
- //todo: subscriber should query for the job...only publish minimum context needed
478
448
  if (this.hasOneTimeSubscription(context)) {
479
449
  const message = {
480
450
  type: 'job',
@@ -513,9 +483,7 @@ class EngineService {
513
483
  hasOneTimeSubscription(context) {
514
484
  return Boolean(context.metadata.ngn);
515
485
  }
516
- // ********** JOB COMPLETION/CLEANUP (AND JOB EMIT) ***********
517
486
  async runJobCompletionTasks(context, options = {}) {
518
- //'emit' indicates the job is still active
519
487
  const isAwait = this.hasParentJob(context, true);
520
488
  const isOneTimeSub = this.hasOneTimeSubscription(context);
521
489
  const topic = await this.getPublishesTopic(context);
@@ -531,15 +499,9 @@ class EngineService {
531
499
  }
532
500
  return msgId;
533
501
  }
534
- /**
535
- * Job hash expiration is typically reliant on the metadata field
536
- * if the activity concludes normally. However, if the job is `interrupted`,
537
- * it will be expired immediately.
538
- */
539
502
  resolveExpires(context, options) {
540
503
  return options.expire ?? context.metadata.expire ?? enums_1.HMSH_EXPIRE_JOB_SECONDS;
541
504
  }
542
- // ****** GET JOB STATE/COLLATION STATUS BY ID *********
543
505
  async export(jobId) {
544
506
  return await this.exporter.export(jobId);
545
507
  }
@@ -550,15 +512,11 @@ class EngineService {
550
512
  const { id: appId } = await this.getVID();
551
513
  return await this.store.getStatus(jobId, appId);
552
514
  }
553
- //todo: add 'options' parameter;
554
- // (e.g, if {dimensions:true}, use hscan to deliver
555
- // the full set of dimensional job data)
556
515
  async getState(topic, jobId) {
557
516
  const jobSymbols = await this.store.getSymbols(`$${topic}`);
558
517
  const consumes = {
559
518
  [`$${topic}`]: Object.keys(jobSymbols)
560
519
  };
561
- //job data exists at the 'zero' dimension; pass an empty object
562
520
  const dIds = {};
563
521
  const output = await this.store.getState(jobId, consumes, dIds);
564
522
  if (!output) {
@@ -3,42 +3,15 @@ import { StoreService } from '../store';
3
3
  import { DependencyExport, ExportOptions, JobActionExport, JobExport } from '../../types/exporter';
4
4
  import { RedisClient, RedisMulti } from '../../types/redis';
5
5
  import { StringStringType, Symbols } from "../../types/serializer";
6
- /**
7
- * Downloads job data from Redis (hscan, hmget, hgetall)
8
- * Expands process data and includes dependency list
9
- */
10
6
  declare class ExporterService {
11
7
  appId: string;
12
8
  logger: ILogger;
13
9
  store: StoreService<RedisClient, RedisMulti>;
14
10
  symbols: Promise<Symbols> | Symbols;
15
11
  constructor(appId: string, store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
16
- /**
17
- * Convert the job hash and dependency list into a JobExport object.
18
- * This object contains various facets that describe the interaction
19
- * in terms relevant to narrative storytelling.
20
- */
21
12
  export(jobId: string, options?: ExportOptions): Promise<JobExport>;
22
- /**
23
- * Inflates the key from Redis, 3-character symbol
24
- * into a human-readable JSON path, reflecting the
25
- * tree-like structure of the unidimensional Hash
26
- */
27
13
  inflateKey(key: string): string;
28
- /**
29
- * Inflates the job data from Redis into a JobExport object
30
- * @param jobHash - the job data from Redis
31
- * @param dependencyList - the list of dependencies for the job
32
- * @returns - the inflated job data
33
- */
34
14
  inflate(jobHash: StringStringType, dependencyList: string[]): JobExport;
35
- /**
36
- * Inflates the dependency data from Redis into a JobExport object by
37
- * organizing the dimensional isolate in sch a way asto interleave
38
- * into a story
39
- * @param data - the dependency data from Redis
40
- * @returns - the organized dependency data
41
- */
42
15
  inflateDependencyData(data: string[], actions: JobActionExport): DependencyExport[];
43
16
  }
44
17
  export { ExporterService };
@@ -4,21 +4,12 @@ exports.ExporterService = void 0;
4
4
  const key_1 = require("../../modules/key");
5
5
  const utils_1 = require("../../modules/utils");
6
6
  const serializer_1 = require("../serializer");
7
- /**
8
- * Downloads job data from Redis (hscan, hmget, hgetall)
9
- * Expands process data and includes dependency list
10
- */
11
7
  class ExporterService {
12
8
  constructor(appId, store, logger) {
13
9
  this.appId = appId;
14
10
  this.logger = logger;
15
11
  this.store = store;
16
12
  }
17
- /**
18
- * Convert the job hash and dependency list into a JobExport object.
19
- * This object contains various facets that describe the interaction
20
- * in terms relevant to narrative storytelling.
21
- */
22
13
  async export(jobId, options = {}) {
23
14
  if (!this.symbols) {
24
15
  this.symbols = this.store.getAllSymbols();
@@ -29,22 +20,10 @@ class ExporterService {
29
20
  const jobExport = this.inflate(jobData, depData);
30
21
  return jobExport;
31
22
  }
32
- /**
33
- * Inflates the key from Redis, 3-character symbol
34
- * into a human-readable JSON path, reflecting the
35
- * tree-like structure of the unidimensional Hash
36
- */
37
23
  inflateKey(key) {
38
24
  return (key in this.symbols) ? this.symbols[key] : key;
39
25
  }
40
- /**
41
- * Inflates the job data from Redis into a JobExport object
42
- * @param jobHash - the job data from Redis
43
- * @param dependencyList - the list of dependencies for the job
44
- * @returns - the inflated job data
45
- */
46
26
  inflate(jobHash, dependencyList) {
47
- //the list of actions taken in the workflow and hook functions
48
27
  const actions = {
49
28
  hooks: {},
50
29
  main: {
@@ -58,7 +37,6 @@ class ExporterService {
58
37
  Object.entries(jobHash).forEach(([key, value]) => {
59
38
  const match = key.match(regex);
60
39
  if (match) {
61
- //activity process state
62
40
  const [_, letters, numbers] = match;
63
41
  const path = this.inflateKey(letters);
64
42
  const dimensions = `${numbers.replace(/,/g, '/')}`;
@@ -66,7 +44,6 @@ class ExporterService {
66
44
  process[`${dimensions}/${path}`] = resolved;
67
45
  }
68
46
  else if (key.length === 3) {
69
- //job state
70
47
  process[this.inflateKey(key)] = serializer_1.SerializerService.fromString(value);
71
48
  }
72
49
  });
@@ -76,13 +53,6 @@ class ExporterService {
76
53
  status: jobHash[':'],
77
54
  };
78
55
  }
79
- /**
80
- * Inflates the dependency data from Redis into a JobExport object by
81
- * organizing the dimensional isolate in sch a way asto interleave
82
- * into a story
83
- * @param data - the dependency data from Redis
84
- * @returns - the organized dependency data
85
- */
86
56
  inflateDependencyData(data, actions) {
87
57
  const hookReg = /([0-9,]+)-(\d+)$/;
88
58
  const flowReg = /-(\d+)$/;
@@ -94,7 +64,6 @@ class ExporterService {
94
64
  let type;
95
65
  let dimensionKey = '';
96
66
  if (match) {
97
- //hook-originating dependency
98
67
  const [_, dimension, counter] = match;
99
68
  dimensionKey = dimension.split(',').join('/');
100
69
  prefix = `${dimensionKey}[${counter}]`;
@@ -103,13 +72,11 @@ class ExporterService {
103
72
  else {
104
73
  const match = jobId.match(flowReg);
105
74
  if (match) {
106
- //main workflow-originating dependency
107
75
  const [_, counter] = match;
108
76
  prefix = `[${counter}]`;
109
77
  type = 'flow';
110
78
  }
111
79
  else {
112
- //'other' types like signal cleanup
113
80
  prefix = '/';
114
81
  type = 'other';
115
82
  }
@@ -4,11 +4,11 @@ import { QuorumService } from '../quorum';
4
4
  import { WorkerService } from '../worker';
5
5
  import { JobState, JobData, JobOutput, JobStatus, JobInterruptOptions, ExtensionType } from '../../types/job';
6
6
  import { HotMeshConfig, HotMeshManifest } from '../../types/hotmesh';
7
+ import { JobExport } from '../../types/exporter';
7
8
  import { JobMessageCallback, QuorumProfile, ThrottleOptions } from '../../types/quorum';
9
+ import { StringAnyType, StringStringType } from '../../types/serializer';
8
10
  import { JobStatsInput, GetStatsOptions, IdsResponse, StatsResponse } from '../../types/stats';
9
11
  import { StreamCode, StreamData, StreamDataResponse, StreamStatus } from '../../types/stream';
10
- import { StringAnyType, StringStringType } from '../../types/serializer';
11
- import { JobExport } from '../../types/exporter';
12
12
  declare class HotMeshService {
13
13
  namespace: string;
14
14
  appId: string;
@@ -5,12 +5,12 @@ const key_1 = require("../../modules/key");
5
5
  const utils_1 = require("../../modules/utils");
6
6
  const redis_1 = require("../connector/clients/redis");
7
7
  const ioredis_1 = require("../connector/clients/ioredis");
8
+ const connector_1 = require("../connector");
8
9
  const engine_1 = require("../engine");
9
10
  const logger_1 = require("../logger");
10
11
  const quorum_1 = require("../quorum");
11
12
  const router_1 = require("../router");
12
13
  const worker_1 = require("../worker");
13
- const connector_1 = require("../connector");
14
14
  class HotMeshService {
15
15
  constructor() {
16
16
  this.engine = null;
@@ -67,7 +67,6 @@ class HotMeshService {
67
67
  async doWork(config, logger) {
68
68
  this.workers = await worker_1.WorkerService.init(this.namespace, this.appId, this.guid, config, logger);
69
69
  }
70
- // ************* PUB/SUB METHODS *************
71
70
  async pub(topic, data = {}, context, extended) {
72
71
  return await this.engine?.pub(topic, data, context, extended);
73
72
  }
@@ -89,7 +88,6 @@ class HotMeshService {
89
88
  async add(streamData) {
90
89
  return await this.engine.add(streamData);
91
90
  }
92
- // ************* QUORUM METHODS *************
93
91
  async rollCall(delay) {
94
92
  return await this.quorum?.rollCall(delay);
95
93
  }
@@ -106,7 +104,6 @@ class HotMeshService {
106
104
  }
107
105
  return await this.quorum?.pub(throttleMessage);
108
106
  }
109
- // ************* COMPILER METHODS *************
110
107
  async plan(path) {
111
108
  return await this.engine?.plan(path);
112
109
  }
@@ -114,10 +111,8 @@ class HotMeshService {
114
111
  return await this.engine?.deploy(pathOrYAML);
115
112
  }
116
113
  async activate(version, delay) {
117
- //activation is a quorum operation
118
114
  return await this.quorum?.activate(version, delay);
119
115
  }
120
- // ************* REPORTER METHODS *************
121
116
  async export(jobId) {
122
117
  return await this.engine?.export(jobId);
123
118
  }
@@ -142,15 +137,12 @@ class HotMeshService {
142
137
  async resolveQuery(topic, query) {
143
138
  return await this.engine?.resolveQuery(topic, query);
144
139
  }
145
- // ****************** `INTERRUPT` ACTIVE JOBS *****************
146
140
  async interrupt(topic, jobId, options = {}) {
147
141
  return await this.engine?.interrupt(topic, jobId, options);
148
142
  }
149
- // ****************** `SCRUB` CLEAN COMPLETED JOBS *****************
150
143
  async scrub(jobId) {
151
144
  await this.engine?.scrub(jobId);
152
145
  }
153
- // ****** `HOOK` ACTIVITY RE-ENTRY POINT ******
154
146
  async hook(topic, data, status, code) {
155
147
  return await this.engine?.hook(topic, data, status, code);
156
148
  }
@@ -15,14 +15,12 @@ class LoggerService {
15
15
  level: this.logLevel,
16
16
  format: winston_1.format.combine(winston_1.format.colorize(), winston_1.format.timestamp(), winston_1.format.printf((info) => {
17
17
  const { timestamp, level, message } = info;
18
- // Extract the object from the `info` object's `Symbol(splat)` field
19
18
  const symbols = Object.getOwnPropertySymbols(info);
20
19
  const splatSymbol = symbols.find(symbol => symbol.toString() === 'Symbol(splat)');
21
20
  let splatData = {};
22
21
  if (splatSymbol) {
23
22
  splatData = info[splatSymbol][0] || {};
24
23
  }
25
- // Pass it to the `tagify` method
26
24
  const tags = this.tagify(splatData);
27
25
  return `${timestamp} [${level}] [${this.name || this.appId}:${this.instanceId}] ${message} ${tags}`;
28
26
  })),
@@ -7,22 +7,8 @@ declare class MapperService {
7
7
  constructor(rules: Record<string, unknown>, data: JobState);
8
8
  mapRules(): Record<string, unknown>;
9
9
  private traverseRules;
10
- /**
11
- * resolves a pipe expression of the form: { @pipe: [["{data.foo.bar}", 2, false, "hello world"]] }
12
- * @param value
13
- * @returns
14
- */
15
10
  private pipe;
16
- /**
17
- * resolves a mapping expression in the form: "{data.foo.bar}" or 2 or false or "hello world"
18
- * @param value
19
- * @returns
20
- */
21
11
  private resolve;
22
- /**
23
- * Evaluates a transition rule against the current job state and incoming Stream message
24
- * to determine which (if any) transition should be taken.
25
- */
26
12
  static evaluate(transitionRule: TransitionRule | boolean, context: JobState, code: StreamCode): boolean;
27
13
  }
28
14
  export { MapperService };
@@ -27,28 +27,14 @@ class MapperService {
27
27
  return this.resolve(rules);
28
28
  }
29
29
  }
30
- /**
31
- * resolves a pipe expression of the form: { @pipe: [["{data.foo.bar}", 2, false, "hello world"]] }
32
- * @param value
33
- * @returns
34
- */
35
30
  pipe(value) {
36
31
  const pipe = new pipe_1.Pipe(value, this.data);
37
32
  return pipe.process();
38
33
  }
39
- /**
40
- * resolves a mapping expression in the form: "{data.foo.bar}" or 2 or false or "hello world"
41
- * @param value
42
- * @returns
43
- */
44
34
  resolve(value) {
45
35
  const pipe = new pipe_1.Pipe([[value]], this.data);
46
36
  return pipe.process();
47
37
  }
48
- /**
49
- * Evaluates a transition rule against the current job state and incoming Stream message
50
- * to determine which (if any) transition should be taken.
51
- */
52
38
  static evaluate(transitionRule, context, code) {
53
39
  if (typeof transitionRule === 'boolean') {
54
40
  return transitionRule;
@@ -1,12 +1,5 @@
1
1
  type DateInput = Date | string | number;
2
2
  declare class DateHandler {
3
- /**
4
- * It is so common in mapping operations to use a string (ISO) date as input. This helper
5
- * method allows for a more-concise mapping ruleset by avoiding date initialization boilerplate
6
- * code and instead handles the ISO, Milliseconds, and ECMAScript Date input types.
7
- * @param input
8
- * @returns
9
- */
10
3
  static getDateInstance(input: DateInput): Date;
11
4
  fromISOString(isoString: string): Date;
12
5
  now(): number;
@@ -3,13 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateHandler = void 0;
4
4
  const utils_1 = require("../../../modules/utils");
5
5
  class DateHandler {
6
- /**
7
- * It is so common in mapping operations to use a string (ISO) date as input. This helper
8
- * method allows for a more-concise mapping ruleset by avoiding date initialization boilerplate
9
- * code and instead handles the ISO, Milliseconds, and ECMAScript Date input types.
10
- * @param input
11
- * @returns
12
- */
13
6
  static getDateInstance(input) {
14
7
  const ISO_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z)?$/;
15
8
  if (typeof input === 'string') {
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MathHandler = void 0;
4
4
  class MathHandler {
5
5
  add(...operands) {
6
- // @ts-ignore
7
6
  return operands.reduce((a, b) => {
8
7
  if (Array.isArray(b)) {
9
8
  return a + this.add(...b);
@@ -38,7 +37,6 @@ class MathHandler {
38
37
  if (operands.length === 0) {
39
38
  throw new Error('At least one operand is required.');
40
39
  }
41
- // @ts-ignore
42
40
  return operands.reduce((a, b) => {
43
41
  if (Array.isArray(b)) {
44
42
  return a * this.multiply(...b);
@@ -13,22 +13,7 @@ declare class Pipe {
13
13
  static resolve(unresolved: {
14
14
  [key: string]: unknown;
15
15
  } | PipeItem, context: Partial<JobState>): any;
16
- /**
17
- * loop through each PipeItem row in this Pipe, resolving and transforming line by line
18
- * @returns {any} the result of the pipe
19
- */
20
16
  process(resolved?: unknown[] | null): any;
21
- /**
22
- * Transforms iterable `input` into a single value. Vars $output, $item, $key
23
- * and $input are available. The final statement in the iterator (the reduction)
24
- * is assumed to be the return value. A default $output object may be provided
25
- * to the iterator by placing the the second cell of the preceding row. Otherwise,
26
- * construct the object during first run and ensure it is the first cell of the
27
- * last row of the iterator, so it is returned as the $output for the next cycle
28
- * @param {unknown[]} input
29
- * @returns {unknown}
30
- * @private
31
- */
32
17
  reduce(input: Array<unknown[]>): unknown;
33
18
  private processRow;
34
19
  static resolveFunction(functionName: string): any;
@@ -30,14 +30,10 @@ class Pipe {
30
30
  }
31
31
  return pipe.process();
32
32
  }
33
- /**
34
- * loop through each PipeItem row in this Pipe, resolving and transforming line by line
35
- * @returns {any} the result of the pipe
36
- */
37
33
  process(resolved = null) {
38
34
  let index = 0;
39
35
  if (!(resolved || this.isPipeType(this.rules[0]) || this.isreduceType(this.rules[0]))) {
40
- resolved = this.processCells(this.rules[0]); // Add type assertion
36
+ resolved = this.processCells(this.rules[0]);
41
37
  index = 1;
42
38
  }
43
39
  const len = this.rules.length;
@@ -47,17 +43,6 @@ class Pipe {
47
43
  }
48
44
  return resolved[0];
49
45
  }
50
- /**
51
- * Transforms iterable `input` into a single value. Vars $output, $item, $key
52
- * and $input are available. The final statement in the iterator (the reduction)
53
- * is assumed to be the return value. A default $output object may be provided
54
- * to the iterator by placing the the second cell of the preceding row. Otherwise,
55
- * construct the object during first run and ensure it is the first cell of the
56
- * last row of the iterator, so it is returned as the $output for the next cycle
57
- * @param {unknown[]} input
58
- * @returns {unknown}
59
- * @private
60
- */
61
46
  reduce(input) {
62
47
  let resolved = input[1] ?? null;
63
48
  if (Array.isArray(input[0])) {
@@ -78,30 +63,25 @@ class Pipe {
78
63
  }
79
64
  processRow(currentRow, resolvedPriorRow, subPipeQueue) {
80
65
  if (resolvedPriorRow && this.isreduceType(currentRow)) {
81
- //reduce the resolvedPriorRow and return the output from the reducer
82
66
  const subPipe = new Pipe(currentRow['@reduce'], this.jobData);
83
67
  const reduced = subPipe.reduce(resolvedPriorRow);
84
68
  return reduced;
85
69
  }
86
70
  else if (this.isPipeType(currentRow)) {
87
- //process subPipe and push to subPipeQueue; echo resolvedPriorRow
88
71
  const subPipe = new Pipe(currentRow['@pipe'], this.jobData, this.context);
89
72
  subPipeQueue.push(subPipe.process());
90
73
  return resolvedPriorRow;
91
74
  }
92
75
  else {
93
- //pivot the subPipeQueue into the arguments array (resolvedPriorRow)
94
76
  if (subPipeQueue.length > 0) {
95
77
  resolvedPriorRow = [...subPipeQueue];
96
78
  subPipeQueue.length = 0;
97
79
  }
98
80
  if (!resolvedPriorRow) {
99
- //if no prior row, use current row as prior row
100
81
  return [].concat(this.processCells(Array.isArray(currentRow) ? [...currentRow] : []));
101
82
  }
102
83
  else {
103
- const [functionName, ...params] = currentRow; // Add type assertion
104
- //use resolved values from prior row (n - 1) as input params to cell 1 function
84
+ const [functionName, ...params] = currentRow;
105
85
  let resolvedValue;
106
86
  if (this.isContextVariable(functionName)) {
107
87
  resolvedValue = this.resolveContextValue(functionName);
@@ -109,7 +89,6 @@ class Pipe {
109
89
  else {
110
90
  resolvedValue = Pipe.resolveFunction(functionName)(...resolvedPriorRow);
111
91
  }
112
- //resolve remaining cells in row and return concatenated with resolvedValue
113
92
  return [resolvedValue].concat(this.processCells([...params]));
114
93
  }
115
94
  }
@@ -28,10 +28,6 @@ declare class QuorumService {
28
28
  subscriptionHandler(): SubscriptionCallback;
29
29
  sayPong(appId: string, guid: string, originator: string, details?: boolean): Promise<void>;
30
30
  requestQuorum(delay?: number, details?: boolean): Promise<number>;
31
- /**
32
- * A quorum-wide command to broadcaset system details.
33
- *
34
- */
35
31
  doRollCall(message: RollCallMessage): Promise<void>;
36
32
  cancelRollCall(): void;
37
33
  stop(): void;
@@ -39,9 +35,6 @@ declare class QuorumService {
39
35
  sub(callback: QuorumMessageCallback): Promise<void>;
40
36
  unsub(callback: QuorumMessageCallback): Promise<void>;
41
37
  rollCall(delay?: number): Promise<QuorumProfile[]>;
42
- /**
43
- * request a quorum; if successful activate the app version
44
- */
45
38
  activate(version: string, delay?: number, count?: number): Promise<boolean>;
46
39
  }
47
40
  export { QuorumService };