@hotmeshio/hotmesh 0.0.58 → 0.0.60

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.
package/README.md CHANGED
@@ -295,28 +295,28 @@ const hotMesh = await HotMesh.init({
295
295
  ```
296
296
 
297
297
  ### Observability
298
- Workflows and activities are run according to the rules you define, offering [Graph-Oriented](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/system_lifecycle.md#telemetry) telemetry insights into your legacy function executions.
298
+ Workflows and activities are run according to the rules you define, offering [Graph-Oriented](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/system_lifecycle.md#telemetry) telemetry insights into your legacy function executions.
299
299
 
300
300
  ## FAQ
301
- Refer to the [FAQ](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/faq.md) for terminology, definitions, and an exploration of how HotMesh facilitates orchestration use cases.
301
+ Refer to the [FAQ](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/faq.md) for terminology, definitions, and an exploration of how HotMesh facilitates orchestration use cases.
302
302
 
303
303
  ## Quick Start
304
- Refer to the [Quick Start](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/quickstart.md) for sample YAML workflows you can copy, paste, and modify to get started.
304
+ Refer to the [Quick Start](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/quickstart.md) for sample YAML workflows you can copy, paste, and modify to get started.
305
305
 
306
306
  ## Developer Guide
307
- For more details on the complete development process, including information about schemas, APIs, and deployment, consult the [Developer Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/developer_guide.md).
307
+ For more details on the complete development process, including information about schemas, APIs, and deployment, consult the [Developer Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/developer_guide.md).
308
308
 
309
309
  ## Model Driven Development
310
- [Model Driven Development](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/model_driven_development.md) is an established strategy for managing process-oriented tasks. Check out this guide to understand its foundational principles.
310
+ [Model Driven Development](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/model_driven_development.md) is an established strategy for managing process-oriented tasks. Check out this guide to understand its foundational principles.
311
311
 
312
312
  ## Data Mapping
313
- Exchanging data between activities is central to HotMesh. For detailed information on supported functions and the functional mapping syntax (@pipes), see the [Data Mapping Overview](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/data_mapping.md).
313
+ Exchanging data between activities is central to HotMesh. For detailed information on supported functions and the functional mapping syntax (@pipes), see the [Data Mapping Overview](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/data_mapping.md).
314
314
 
315
315
  ## Composition
316
- While the simplest graphs are linear, detailing a consistent sequence of non-cyclical activities, graphs can be layered to represent intricate business scenarios. Some can even be designed to accommodate long-lasting workflows that span months. For more details, check out the [Composable Workflow Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/composable_workflow.md).
316
+ While the simplest graphs are linear, detailing a consistent sequence of non-cyclical activities, graphs can be layered to represent intricate business scenarios. Some can even be designed to accommodate long-lasting workflows that span months. For more details, check out the [Composable Workflow Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/composable_workflow.md).
317
317
 
318
318
  ## Distributed Orchestration
319
- HotMesh is a distributed orchestration engine. Refer to the [Distributed Orchestration Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/distributed_orchestration.md) for a detailed breakdown of the approach.
319
+ HotMesh is a distributed orchestration engine. Refer to the [Distributed Orchestration Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/distributed_orchestration.md) for a detailed breakdown of the approach.
320
320
 
321
321
  ## System Lifecycle
322
- Gain insight into HotMesh's monitoring, exception handling, and alarm configurations via the [System Lifecycle Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/system_lifecycle.md).
322
+ Gain insight into HotMesh's monitoring, exception handling, and alarm configurations via the [System Lifecycle Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/system_lifecycle.md).
@@ -35,3 +35,4 @@ export declare const HMSH_XPENDING_COUNT: number;
35
35
  export declare const HMSH_EXPIRE_DURATION: number;
36
36
  export declare const HMSH_FIDELITY_SECONDS: number;
37
37
  export declare const HMSH_SCOUT_INTERVAL_SECONDS: number;
38
+ export declare const HMSH_GUID_SIZE: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HMSH_SCOUT_INTERVAL_SECONDS = exports.HMSH_FIDELITY_SECONDS = exports.HMSH_EXPIRE_DURATION = exports.HMSH_XPENDING_COUNT = exports.HMSH_XCLAIM_COUNT = exports.HMSH_XCLAIM_DELAY_MS = exports.HMSH_BLOCK_TIME_MS = exports.HMSH_DURABLE_EXP_BACKOFF = exports.HMSH_DURABLE_MAX_INTERVAL = exports.HMSH_DURABLE_MAX_ATTEMPTS = exports.HMSH_GRADUATED_INTERVAL_MS = exports.HMSH_MAX_TIMEOUT_MS = exports.HMSH_MAX_RETRIES = exports.HMSH_EXPIRE_JOB_SECONDS = exports.HMSH_OTT_WAIT_TIME = exports.HMSH_ACTIVATION_MAX_RETRY = exports.HMSH_QUORUM_DELAY_MS = exports.HMSH_QUORUM_ROLLCALL_CYCLES = exports.HMSH_STATUS_UNKNOWN = exports.HMSH_CODE_DURABLE_RETRYABLE = exports.HMSH_CODE_DURABLE_FATAL = exports.HMSH_CODE_DURABLE_MAXED = exports.HMSH_CODE_DURABLE_TIMEOUT = exports.HMSH_CODE_DURABLE_WAIT = exports.HMSH_CODE_DURABLE_PROXY = exports.HMSH_CODE_DURABLE_CHILD = exports.HMSH_CODE_DURABLE_ALL = exports.HMSH_CODE_DURABLE_SLEEP = exports.HMSH_CODE_UNACKED = exports.HMSH_CODE_TIMEOUT = exports.HMSH_CODE_UNKNOWN = exports.HMSH_CODE_INTERRUPT = exports.HMSH_CODE_NOTFOUND = exports.HMSH_CODE_PENDING = exports.HMSH_CODE_SUCCESS = exports.HMSH_LOGLEVEL = void 0;
3
+ exports.HMSH_GUID_SIZE = exports.HMSH_SCOUT_INTERVAL_SECONDS = exports.HMSH_FIDELITY_SECONDS = exports.HMSH_EXPIRE_DURATION = exports.HMSH_XPENDING_COUNT = exports.HMSH_XCLAIM_COUNT = exports.HMSH_XCLAIM_DELAY_MS = exports.HMSH_BLOCK_TIME_MS = exports.HMSH_DURABLE_EXP_BACKOFF = exports.HMSH_DURABLE_MAX_INTERVAL = exports.HMSH_DURABLE_MAX_ATTEMPTS = exports.HMSH_GRADUATED_INTERVAL_MS = exports.HMSH_MAX_TIMEOUT_MS = exports.HMSH_MAX_RETRIES = exports.HMSH_EXPIRE_JOB_SECONDS = exports.HMSH_OTT_WAIT_TIME = exports.HMSH_ACTIVATION_MAX_RETRY = exports.HMSH_QUORUM_DELAY_MS = exports.HMSH_QUORUM_ROLLCALL_CYCLES = exports.HMSH_STATUS_UNKNOWN = exports.HMSH_CODE_DURABLE_RETRYABLE = exports.HMSH_CODE_DURABLE_FATAL = exports.HMSH_CODE_DURABLE_MAXED = exports.HMSH_CODE_DURABLE_TIMEOUT = exports.HMSH_CODE_DURABLE_WAIT = exports.HMSH_CODE_DURABLE_PROXY = exports.HMSH_CODE_DURABLE_CHILD = exports.HMSH_CODE_DURABLE_ALL = exports.HMSH_CODE_DURABLE_SLEEP = exports.HMSH_CODE_UNACKED = exports.HMSH_CODE_TIMEOUT = exports.HMSH_CODE_UNKNOWN = exports.HMSH_CODE_INTERRUPT = exports.HMSH_CODE_NOTFOUND = exports.HMSH_CODE_PENDING = exports.HMSH_CODE_SUCCESS = exports.HMSH_LOGLEVEL = void 0;
4
4
  // HOTMESH SYSTEM
5
5
  exports.HMSH_LOGLEVEL = process.env.HMSH_LOGLEVEL || 'info';
6
6
  // HOTMESH STATUS CODES
@@ -50,3 +50,5 @@ const BASE_FIDELITY_SECONDS = 5;
50
50
  const TEST_FIDELITY_SECONDS = 1;
51
51
  exports.HMSH_FIDELITY_SECONDS = process.env.HMSH_FIDELITY_SECONDS ? parseInt(process.env.HMSH_FIDELITY_SECONDS, 10) : (process.env.NODE_ENV === 'test' ? TEST_FIDELITY_SECONDS : BASE_FIDELITY_SECONDS);
52
52
  exports.HMSH_SCOUT_INTERVAL_SECONDS = parseInt(process.env.HMSH_SCOUT_INTERVAL_SECONDS, 10) || 60;
53
+ // UTILS
54
+ exports.HMSH_GUID_SIZE = Math.min(parseInt(process.env.HMSH_GUID_SIZE, 10) || 22, 32);
@@ -8,7 +8,7 @@ import { SystemHealth } from '../types/quorum';
8
8
  export declare function getSystemHealth(): Promise<SystemHealth>;
9
9
  export declare function sleepFor(ms: number): Promise<unknown>;
10
10
  export declare function sleepImmediate(): Promise<void>;
11
- export declare function guid(): string;
11
+ export declare function guid(size?: number): string;
12
12
  export declare function deterministicRandom(seed: number): number;
13
13
  export declare function identifyRedisType(redisInstance: any): 'redis' | 'ioredis' | null;
14
14
  export declare const polyfill: {
@@ -7,6 +7,7 @@ exports.restoreHierarchy = exports.getValueByPath = exports.getIndexedHash = exp
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const systeminformation_1 = __importDefault(require("systeminformation"));
9
9
  const nanoid_1 = require("nanoid");
10
+ const enums_1 = require("./enums");
10
11
  async function safeExecute(operation, defaultValue) {
11
12
  try {
12
13
  return await operation;
@@ -49,8 +50,11 @@ function sleepImmediate() {
49
50
  return new Promise((resolve) => setImmediate(resolve));
50
51
  }
51
52
  exports.sleepImmediate = sleepImmediate;
52
- function guid() {
53
- return (0, nanoid_1.nanoid)().replace(/[_-]/g, '0');
53
+ function s4() {
54
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
55
+ }
56
+ function guid(size = enums_1.HMSH_GUID_SIZE) {
57
+ return s4() + `H` + (0, nanoid_1.nanoid)(size);
54
58
  }
55
59
  exports.guid = guid;
56
60
  function deterministicRandom(seed) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -21,6 +21,7 @@
21
21
  "start": "ts-node src/index.ts",
22
22
  "test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
23
23
  "test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
24
+ "test:unit": "NODE_ENV=test jest ./tests/unit/*/*/index.test.ts --detectOpenHandles --forceExit --verbose",
24
25
  "test:pipe": "NODE_ENV=test jest ./tests/unit/services/pipe/index.test.ts --detectOpenHandles --forceExit --verbose",
25
26
  "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
26
27
  "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/index.test.ts --detectOpenHandles --forceExit --verbose",
@@ -236,7 +236,7 @@ class WorkerService {
236
236
  const workflowInput = data.data;
237
237
  const execIndex = counter.counter - interruptionRegistry.length + 1;
238
238
  const { workflowId, workflowTopic, workflowDimension, originJobId } = workflowInput;
239
- const collatorFlowId = (0, utils_1.guid)();
239
+ const collatorFlowId = `${(0, utils_1.guid)()}$C`;
240
240
  return {
241
241
  status: stream_1.StreamStatus.SUCCESS,
242
242
  code: enums_1.HMSH_CODE_DURABLE_ALL,
@@ -18,6 +18,7 @@ declare class Pipe {
18
18
  * @returns {any} the result of the pipe
19
19
  */
20
20
  process(resolved?: unknown[] | null): any;
21
+ cloneUnknown<T>(value: T): T;
21
22
  /**
22
23
  * Transforms iterable `input` into a single value. Vars $output, $item, $key
23
24
  * and $input are available. The final statement in the iterator (the reduction)
@@ -47,6 +47,27 @@ class Pipe {
47
47
  }
48
48
  return resolved[0];
49
49
  }
50
+ cloneUnknown(value) {
51
+ if (value === null || typeof value !== 'object') {
52
+ return value;
53
+ }
54
+ if (value instanceof Date) {
55
+ return new Date(value.getTime());
56
+ }
57
+ if (value instanceof RegExp) {
58
+ return new RegExp(value);
59
+ }
60
+ if (Array.isArray(value)) {
61
+ return value.map(item => this.cloneUnknown(item));
62
+ }
63
+ const clonedObj = {};
64
+ for (const key in value) {
65
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
66
+ clonedObj[key] = this.cloneUnknown(value[key]);
67
+ }
68
+ }
69
+ return clonedObj;
70
+ }
50
71
  /**
51
72
  * Transforms iterable `input` into a single value. Vars $output, $item, $key
52
73
  * and $input are available. The final statement in the iterator (the reduction)
@@ -59,7 +80,7 @@ class Pipe {
59
80
  * @private
60
81
  */
61
82
  reduce(input) {
62
- let resolved = input[1] ?? null;
83
+ let resolved = this.cloneUnknown(input[1] ?? null);
63
84
  if (Array.isArray(input[0])) {
64
85
  for (let index = 0; index < input[0].length; index++) {
65
86
  this.context = { $input: input[0], $output: resolved, $item: input[0][index], $key: index.toString(), $index: index };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -21,6 +21,7 @@
21
21
  "start": "ts-node src/index.ts",
22
22
  "test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
23
23
  "test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
24
+ "test:unit": "NODE_ENV=test jest ./tests/unit/*/*/index.test.ts --detectOpenHandles --forceExit --verbose",
24
25
  "test:pipe": "NODE_ENV=test jest ./tests/unit/services/pipe/index.test.ts --detectOpenHandles --forceExit --verbose",
25
26
  "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
26
27
  "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/index.test.ts --detectOpenHandles --forceExit --verbose",