@hotmeshio/hotmesh 0.3.18 → 0.3.19
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 +160 -63
- package/build/modules/key.js +1 -1
- package/build/modules/utils.js +1 -1
- package/build/package.json +6 -4
- package/build/services/activities/activity.js +1 -1
- package/build/services/activities/await.js +1 -1
- package/build/services/activities/cycle.js +1 -1
- package/build/services/activities/hook.js +1 -1
- package/build/services/activities/index.js +1 -1
- package/build/services/activities/interrupt.js +1 -1
- package/build/services/activities/signal.js +1 -1
- package/build/services/activities/trigger.js +1 -1
- package/build/services/activities/worker.js +1 -1
- package/build/services/collator/index.js +1 -1
- package/build/services/compiler/deployer.js +1 -1
- package/build/services/compiler/index.js +1 -1
- package/build/services/compiler/validator.js +1 -1
- package/build/services/engine/index.d.ts +1 -1
- package/build/services/engine/index.js +1 -1
- package/build/services/exporter/index.js +1 -1
- package/build/services/mapper/index.js +1 -1
- package/build/services/meshflow/exporter.js +1 -1
- package/build/services/pipe/functions/array.js +1 -1
- package/build/services/pipe/functions/bitwise.js +1 -1
- package/build/services/pipe/functions/conditional.js +1 -1
- package/build/services/pipe/functions/cron.js +1 -1
- package/build/services/pipe/functions/date.js +1 -1
- package/build/services/pipe/functions/index.js +1 -1
- package/build/services/pipe/functions/json.js +1 -1
- package/build/services/pipe/functions/logical.js +1 -1
- package/build/services/pipe/functions/math.js +1 -1
- package/build/services/pipe/functions/number.js +1 -1
- package/build/services/pipe/functions/object.js +1 -1
- package/build/services/pipe/functions/string.js +1 -1
- package/build/services/pipe/functions/symbol.js +1 -1
- package/build/services/pipe/functions/unary.js +1 -1
- package/build/services/pipe/index.js +1 -1
- package/build/services/quorum/index.d.ts +1 -1
- package/build/services/quorum/index.js +1 -1
- package/build/services/reporter/index.js +1 -1
- package/build/services/router/index.js +1 -1
- package/build/services/search/providers/postgres/postgres.js +1 -1
- package/build/services/search/providers/redis/ioredis.js +1 -1
- package/build/services/search/providers/redis/redis.js +1 -1
- package/build/services/serializer/index.js +1 -1
- package/build/services/store/providers/postgres/kvsql.js +1 -1
- package/build/services/store/providers/postgres/kvtables.d.ts +1 -0
- package/build/services/store/providers/postgres/kvtables.js +1 -1
- package/build/services/store/providers/postgres/kvtransaction.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +1 -0
- package/build/services/store/providers/postgres/kvtypes/hash.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/list.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/string.js +1 -1
- package/build/services/store/providers/postgres/kvtypes/zset.js +1 -1
- package/build/services/store/providers/postgres/postgres.js +1 -1
- package/build/services/store/providers/redis/_base.js +1 -1
- package/build/services/store/providers/redis/ioredis.js +1 -1
- package/build/services/store/providers/redis/redis.js +1 -1
- package/build/services/store/providers/store-initializable.js +1 -1
- package/build/services/stream/providers/nats/nats.js +1 -1
- package/build/services/stream/providers/postgres/postgres.d.ts +1 -0
- package/build/services/stream/providers/postgres/postgres.js +1 -1
- package/build/services/stream/providers/redis/ioredis.js +1 -1
- package/build/services/stream/providers/redis/redis.js +1 -1
- package/build/services/stream/providers/stream-initializable.js +1 -1
- package/build/services/sub/factory.d.ts +2 -2
- package/build/services/sub/factory.js +8 -4
- package/build/services/sub/index.d.ts +3 -2
- package/build/services/sub/providers/postgres/postgres.d.ts +18 -0
- package/build/services/sub/providers/postgres/postgres.js +1 -0
- package/build/services/sub/providers/redis/ioredis.d.ts +1 -1
- package/build/services/sub/providers/redis/ioredis.js +1 -1
- package/build/services/sub/providers/redis/redis.d.ts +1 -1
- package/build/services/sub/providers/redis/redis.js +1 -1
- package/build/services/task/index.js +1 -1
- package/build/services/telemetry/index.js +1 -1
- package/build/services/worker/index.d.ts +1 -1
- package/build/services/worker/index.js +1 -1
- package/build/types/redis.d.ts +8 -8
- package/package.json +6 -4
- package/types/redis.ts +8 -8
package/README.md
CHANGED
|
@@ -25,7 +25,6 @@ npm install @hotmeshio/hotmesh
|
|
|
25
25
|
## Learn
|
|
26
26
|
[🏠 Home](https://hotmesh.io/) | [📄 SDK Docs](https://hotmeshio.github.io/sdk-typescript/) | [💼 General Examples](https://github.com/hotmeshio/samples-typescript) | [💼 Temporal Examples](https://github.com/hotmeshio/temporal-patterns-typescript)
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
<br/>
|
|
30
29
|
|
|
31
30
|
## MeshCall | Fast, Simple, Inter-Service Calls
|
|
@@ -43,14 +42,16 @@ npm install @hotmeshio/hotmesh
|
|
|
43
42
|
```typescript
|
|
44
43
|
//cron.ts
|
|
45
44
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
46
|
-
import
|
|
45
|
+
import { Client as Postgres } from 'pg';
|
|
47
46
|
|
|
48
47
|
export const runMyCron = async (id: string, interval = '0 0 * * *'): Promise<boolean> => {
|
|
49
48
|
return await MeshCall.cron({
|
|
50
49
|
topic: 'my.cron.function',
|
|
51
50
|
connection: {
|
|
52
|
-
class:
|
|
53
|
-
options: {
|
|
51
|
+
class: Postgres,
|
|
52
|
+
options: {
|
|
53
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
54
|
+
}
|
|
54
55
|
},
|
|
55
56
|
callback: async () => {
|
|
56
57
|
//your code here...
|
|
@@ -78,13 +79,15 @@ npm install @hotmeshio/hotmesh
|
|
|
78
79
|
1. Use the same `id` and `topic` that were used to create the cron to cancel it.
|
|
79
80
|
```typescript
|
|
80
81
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
81
|
-
import
|
|
82
|
+
import { Client as Postgres } from 'pg';
|
|
82
83
|
|
|
83
84
|
MeshCall.interrupt({
|
|
84
85
|
topic: 'my.cron.function',
|
|
85
86
|
connection: {
|
|
86
|
-
class:
|
|
87
|
-
options: {
|
|
87
|
+
class: Postgres,
|
|
88
|
+
options: {
|
|
89
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
90
|
+
}
|
|
88
91
|
},
|
|
89
92
|
options: { id: 'myNightlyCron123' }
|
|
90
93
|
});
|
|
@@ -95,21 +98,23 @@ npm install @hotmeshio/hotmesh
|
|
|
95
98
|
<summary style="font-size:1.25em;">Call any function in any service <small>[more]</small></summary>
|
|
96
99
|
|
|
97
100
|
### Call a Function
|
|
98
|
-
Make
|
|
101
|
+
Make interservice calls that behave like HTTP but without the setup and performance overhead. This example demonstrates how to connect and call a function.
|
|
99
102
|
|
|
100
103
|
1. Call `MeshCall.connect` and provide a `topic` to uniquely identify the function.
|
|
101
104
|
|
|
102
105
|
```typescript
|
|
103
106
|
//myFunctionWrapper.ts
|
|
104
107
|
import { MeshCall, Types } from '@hotmeshio/hotmesh';
|
|
105
|
-
import
|
|
108
|
+
import { Client as Postgres } from 'pg';
|
|
106
109
|
|
|
107
110
|
export const connectMyFunction = async () => {
|
|
108
111
|
return await MeshCall.connect({
|
|
109
112
|
topic: 'my.demo.function',
|
|
110
113
|
connection: {
|
|
111
|
-
class:
|
|
112
|
-
options: {
|
|
114
|
+
class: Postgres,
|
|
115
|
+
options: {
|
|
116
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
117
|
+
}
|
|
113
118
|
},
|
|
114
119
|
callback: async (input: string) => {
|
|
115
120
|
//your code goes here; response must be JSON serializable
|
|
@@ -131,14 +136,16 @@ npm install @hotmeshio/hotmesh
|
|
|
131
136
|
|
|
132
137
|
```typescript
|
|
133
138
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
134
|
-
import
|
|
139
|
+
import { Client as Postgres } from 'pg';
|
|
135
140
|
|
|
136
141
|
const result = await MeshCall.exec({
|
|
137
142
|
topic: 'my.demo.function',
|
|
138
143
|
args: ['something'],
|
|
139
144
|
connection: {
|
|
140
|
-
class:
|
|
141
|
-
options: {
|
|
145
|
+
class: Postgres,
|
|
146
|
+
options: {
|
|
147
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
148
|
+
}
|
|
142
149
|
},
|
|
143
150
|
}); //returns `{ hello: 'something'}`
|
|
144
151
|
```
|
|
@@ -154,14 +161,16 @@ npm install @hotmeshio/hotmesh
|
|
|
154
161
|
|
|
155
162
|
```typescript
|
|
156
163
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
157
|
-
import
|
|
164
|
+
import { Client as Postgres } from 'pg';
|
|
158
165
|
|
|
159
166
|
const result = await MeshCall.exec({
|
|
160
167
|
topic: 'my.demo.function',
|
|
161
168
|
args: ['anything'],
|
|
162
169
|
connection: {
|
|
163
|
-
class:
|
|
164
|
-
options: {
|
|
170
|
+
class: Postgres,
|
|
171
|
+
options: {
|
|
172
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
173
|
+
}
|
|
165
174
|
},
|
|
166
175
|
options: { id: 'myid123', ttl: '15 minutes' },
|
|
167
176
|
}); //returns `{ hello: 'anything'}`
|
|
@@ -171,13 +180,15 @@ npm install @hotmeshio/hotmesh
|
|
|
171
180
|
|
|
172
181
|
```typescript
|
|
173
182
|
import { MeshCall } from '@hotmeshio/hotmesh';
|
|
174
|
-
import
|
|
183
|
+
import { Client as Postgres } from 'pg';
|
|
175
184
|
|
|
176
185
|
await MeshCall.flush({
|
|
177
186
|
topic: 'my.demo.function',
|
|
178
187
|
connection: {
|
|
179
|
-
class:
|
|
180
|
-
options: {
|
|
188
|
+
class: Postgres,
|
|
189
|
+
options: {
|
|
190
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
191
|
+
}
|
|
181
192
|
},
|
|
182
193
|
options: { id: 'myid123' },
|
|
183
194
|
});
|
|
@@ -236,13 +247,15 @@ When an endpoint is unpredictable, use `proxyActivities`. HotMesh will retry as
|
|
|
236
247
|
```typescript
|
|
237
248
|
//client.ts
|
|
238
249
|
import { Client, HotMesh } from '@hotmeshio/hotmesh';
|
|
239
|
-
import
|
|
250
|
+
import { Client as Postgres } from 'pg';
|
|
240
251
|
|
|
241
252
|
async function run(): Promise<string> {
|
|
242
253
|
const client = new Client({
|
|
243
254
|
connection: {
|
|
244
|
-
class:
|
|
245
|
-
options: {
|
|
255
|
+
class: Postgres,
|
|
256
|
+
options: {
|
|
257
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
258
|
+
}
|
|
246
259
|
}
|
|
247
260
|
});
|
|
248
261
|
|
|
@@ -263,14 +276,16 @@ When an endpoint is unpredictable, use `proxyActivities`. HotMesh will retry as
|
|
|
263
276
|
```typescript
|
|
264
277
|
//worker.ts
|
|
265
278
|
import { worker } from '@hotmeshio/hotmesh';
|
|
266
|
-
import
|
|
279
|
+
import { Client as Postgres } from 'pg';
|
|
267
280
|
import * as workflows from './workflows';
|
|
268
281
|
|
|
269
282
|
async function run() {
|
|
270
283
|
const worker = await Worker.create({
|
|
271
284
|
connection: {
|
|
272
|
-
class:
|
|
273
|
-
options: {
|
|
285
|
+
class: Postgres,
|
|
286
|
+
options: {
|
|
287
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
288
|
+
}
|
|
274
289
|
},
|
|
275
290
|
taskQueue: 'default',
|
|
276
291
|
workflow: workflows.example,
|
|
@@ -304,13 +319,15 @@ Pause a function and only awaken when a matching signal is received from the out
|
|
|
304
319
|
```typescript
|
|
305
320
|
//client.ts
|
|
306
321
|
import { Client, HotMesh } from '@hotmeshio/hotmesh';
|
|
307
|
-
import
|
|
322
|
+
import { Client as Postgres } from 'pg';
|
|
308
323
|
|
|
309
324
|
async function run(): Promise<string> {
|
|
310
325
|
const client = new Client({
|
|
311
326
|
connection: {
|
|
312
|
-
class:
|
|
313
|
-
options: {
|
|
327
|
+
class: Postgres,
|
|
328
|
+
options: {
|
|
329
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
330
|
+
}
|
|
314
331
|
}
|
|
315
332
|
});
|
|
316
333
|
|
|
@@ -330,14 +347,16 @@ Pause a function and only awaken when a matching signal is received from the out
|
|
|
330
347
|
```typescript
|
|
331
348
|
//worker.ts
|
|
332
349
|
import { Worker } from '@hotmeshio/hotmesh';
|
|
333
|
-
import
|
|
350
|
+
import { Client as Postgres } from 'pg';
|
|
334
351
|
import * as workflows from './waitForWorkflow';
|
|
335
352
|
|
|
336
353
|
async function run() {
|
|
337
354
|
const worker = await Worker.create({
|
|
338
355
|
connection: {
|
|
339
|
-
class:
|
|
340
|
-
options: {
|
|
356
|
+
class: Postgres,
|
|
357
|
+
options: {
|
|
358
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
359
|
+
}
|
|
341
360
|
},
|
|
342
361
|
taskQueue: 'default',
|
|
343
362
|
workflow: workflows.waitForExample,
|
|
@@ -351,12 +370,14 @@ Pause a function and only awaken when a matching signal is received from the out
|
|
|
351
370
|
|
|
352
371
|
```typescript
|
|
353
372
|
import { Client } from '@hotmeshio/hotmesh';
|
|
354
|
-
import
|
|
373
|
+
import { Client as Postgres } from 'pg';
|
|
355
374
|
|
|
356
375
|
const client = new Client({
|
|
357
376
|
connection: {
|
|
358
|
-
class:
|
|
359
|
-
options: {
|
|
377
|
+
class: Postgres,
|
|
378
|
+
options: {
|
|
379
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
380
|
+
}
|
|
360
381
|
}
|
|
361
382
|
});
|
|
362
383
|
|
|
@@ -400,12 +421,14 @@ Use a standard `Promise` to collate and cache multiple signals. HotMesh will onl
|
|
|
400
421
|
|
|
401
422
|
```typescript
|
|
402
423
|
import { Client } from '@hotmeshio/hotmesh';
|
|
403
|
-
import
|
|
424
|
+
import { Client as Postgres } from 'pg';
|
|
404
425
|
|
|
405
426
|
const client = new Client({
|
|
406
427
|
connection: {
|
|
407
|
-
class:
|
|
408
|
-
options: {
|
|
428
|
+
class: Postgres,
|
|
429
|
+
options: {
|
|
430
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
431
|
+
}
|
|
409
432
|
}
|
|
410
433
|
});
|
|
411
434
|
|
|
@@ -456,13 +479,15 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
456
479
|
```typescript
|
|
457
480
|
//client.ts
|
|
458
481
|
import { Client, HotMesh } from '@hotmeshio/hotmesh';
|
|
459
|
-
import
|
|
482
|
+
import { Client as Postgres } from 'pg';
|
|
460
483
|
|
|
461
484
|
async function run(): Promise<string> {
|
|
462
485
|
const client = new Client({
|
|
463
486
|
connection: {
|
|
464
|
-
class:
|
|
465
|
-
options: {
|
|
487
|
+
class: Postgres,
|
|
488
|
+
options: {
|
|
489
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
490
|
+
}
|
|
466
491
|
}
|
|
467
492
|
});
|
|
468
493
|
|
|
@@ -482,14 +507,16 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
482
507
|
```typescript
|
|
483
508
|
//worker.ts
|
|
484
509
|
import { Worker } from '@hotmeshio/hotmesh';
|
|
485
|
-
import
|
|
510
|
+
import { Client as Postgres } from 'pg';
|
|
486
511
|
import * as workflows from './recurringWorkflow';
|
|
487
512
|
|
|
488
513
|
async function run() {
|
|
489
514
|
const worker = await Worker.create({
|
|
490
515
|
connection: {
|
|
491
|
-
class:
|
|
492
|
-
options: {
|
|
516
|
+
class: Postgres,
|
|
517
|
+
options: {
|
|
518
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
519
|
+
}
|
|
493
520
|
},
|
|
494
521
|
taskQueue: 'default',
|
|
495
522
|
workflow: workflows.recurringExample,
|
|
@@ -503,12 +530,14 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
503
530
|
|
|
504
531
|
```typescript
|
|
505
532
|
import { Client } from '@hotmeshio/hotmesh';
|
|
506
|
-
import
|
|
533
|
+
import { Client as Postgres } from 'pg';
|
|
507
534
|
|
|
508
535
|
const client = new Client({
|
|
509
536
|
connection: {
|
|
510
|
-
class:
|
|
511
|
-
options: {
|
|
537
|
+
class: Postgres,
|
|
538
|
+
options: {
|
|
539
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
540
|
+
}
|
|
512
541
|
}
|
|
513
542
|
});
|
|
514
543
|
|
|
@@ -555,12 +584,14 @@ This example demonstrates how to define a schema and deploy an index for a 'user
|
|
|
555
584
|
```typescript
|
|
556
585
|
//server.ts
|
|
557
586
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
558
|
-
import
|
|
587
|
+
import { Client as Postgres } from 'pg';
|
|
559
588
|
import { schema } from './schema';
|
|
560
589
|
|
|
561
590
|
const meshData = new MeshData(
|
|
562
|
-
|
|
563
|
-
|
|
591
|
+
Postgres,
|
|
592
|
+
options: {
|
|
593
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
594
|
+
},
|
|
564
595
|
schema,
|
|
565
596
|
);
|
|
566
597
|
await meshData.createSearchIndex('user', { namespace: 'meshdata' });
|
|
@@ -578,13 +609,15 @@ This example demonstrates how to create a 'user' workflow backed by the searchab
|
|
|
578
609
|
```typescript
|
|
579
610
|
//connect.ts
|
|
580
611
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
581
|
-
import
|
|
612
|
+
import { Client as Postgres } from 'pg';
|
|
582
613
|
import { schema } from './schema';
|
|
583
614
|
|
|
584
615
|
export const connectUserWorker = async (): Promise<void> => {
|
|
585
616
|
const meshData = new MeshData(
|
|
586
|
-
|
|
587
|
-
|
|
617
|
+
Postgres,
|
|
618
|
+
options: {
|
|
619
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
620
|
+
},
|
|
588
621
|
schema,
|
|
589
622
|
);
|
|
590
623
|
|
|
@@ -614,11 +647,13 @@ This example demonstrates how to create a 'user' workflow backed by the searchab
|
|
|
614
647
|
```typescript
|
|
615
648
|
//exec.ts
|
|
616
649
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
617
|
-
import
|
|
650
|
+
import { Client as Postgres } from 'pg';
|
|
618
651
|
|
|
619
652
|
const meshData = new MeshData(
|
|
620
|
-
|
|
621
|
-
|
|
653
|
+
Postgres,
|
|
654
|
+
options: {
|
|
655
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
656
|
+
},
|
|
622
657
|
schema,
|
|
623
658
|
);
|
|
624
659
|
|
|
@@ -658,12 +693,14 @@ This example demonstrates how to read data fields directly from a workflow.
|
|
|
658
693
|
```typescript
|
|
659
694
|
//read.ts
|
|
660
695
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
661
|
-
import
|
|
696
|
+
import { Client as Postgres } from 'pg';
|
|
662
697
|
import { schema } from './schema';
|
|
663
698
|
|
|
664
699
|
const meshData = new MeshData(
|
|
665
|
-
|
|
666
|
-
|
|
700
|
+
Postgres,
|
|
701
|
+
options: {
|
|
702
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
703
|
+
},
|
|
667
704
|
schema,
|
|
668
705
|
);
|
|
669
706
|
|
|
@@ -689,12 +726,14 @@ This example demonstrates how to search for those workflows where a given condit
|
|
|
689
726
|
```typescript
|
|
690
727
|
//read.ts
|
|
691
728
|
import { MeshData } from '@hotmeshio/hotmesh';
|
|
692
|
-
import
|
|
729
|
+
import { Client as Postgres } from 'pg';
|
|
693
730
|
import { schema } from './schema';
|
|
694
731
|
|
|
695
732
|
const meshData = new MeshData(
|
|
696
|
-
|
|
697
|
-
|
|
733
|
+
Postgres,
|
|
734
|
+
options: {
|
|
735
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
736
|
+
},
|
|
698
737
|
schema,
|
|
699
738
|
);
|
|
700
739
|
|
|
@@ -708,8 +747,66 @@ This example demonstrates how to search for those workflows where a given condit
|
|
|
708
747
|
|
|
709
748
|
<br/>
|
|
710
749
|
|
|
750
|
+
## Connect
|
|
751
|
+
HotMesh is pluggable and ships with support for Postgres (pg) and Redis (ioredis/redis) as standalone backends.
|
|
752
|
+
|
|
753
|
+
### Postgres
|
|
754
|
+
```typescript
|
|
755
|
+
import { Client as Postgres } from 'pg';
|
|
756
|
+
//OR `import { Pool as Postgres } from 'pg';`
|
|
757
|
+
|
|
758
|
+
const connection = {
|
|
759
|
+
class: Postgres,
|
|
760
|
+
options: {
|
|
761
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db'
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### Redis
|
|
767
|
+
```typescript
|
|
768
|
+
import * as Redis from 'redis';
|
|
769
|
+
//OR `import { Client as Postgres } from 'pg';`
|
|
770
|
+
|
|
771
|
+
const connection = {
|
|
772
|
+
class: Redis,
|
|
773
|
+
options: {
|
|
774
|
+
url: 'redis://:your_password@localhost:6379',
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
### NATS
|
|
780
|
+
Add NATS for improved pub/sub support, including patterned subscriptions. Note the explicit channel subscription in the example below.
|
|
781
|
+
|
|
782
|
+
```typescript
|
|
783
|
+
import { Client as Postgres } from 'pg';
|
|
784
|
+
import { connect as NATS } from 'nats';
|
|
785
|
+
|
|
786
|
+
const connection = {
|
|
787
|
+
store: {
|
|
788
|
+
class: Postgres,
|
|
789
|
+
options: {
|
|
790
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
stream: {
|
|
794
|
+
class: Postgres,
|
|
795
|
+
options: {
|
|
796
|
+
connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
sub: {
|
|
800
|
+
class: NATS,
|
|
801
|
+
options: { servers: ['nats:4222'] }
|
|
802
|
+
},
|
|
803
|
+
};
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
<br/>
|
|
807
|
+
|
|
711
808
|
## Metrics and Monitoring
|
|
712
|
-
HotMesh's **OpenTelemetry** output provides
|
|
809
|
+
HotMesh's **OpenTelemetry** output provides insight into long-running, cross-service transactions. Add an OpenTelemetry sink to any service where HotMesh is deployed and HotMesh will emit the full **OpenTelemetry** execution tree organized as a single, unified DAG.
|
|
713
810
|
|
|
714
811
|
The **HotMesh Dashboard** provides a detailed overview of all running workflows. It includes an LLM to simplify querying and analyzing workflow data. An example Web server with REST APIs and the Dashboard (a WebApp) is included in the [samples-typescript](https://github.com/hotmeshio/samples-typescript) Git repo.
|
|
715
812
|
|
package/build/modules/key.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';(function(
|
|
1
|
+
'use strict';(function(_0x29113b,_0xebf334){const _0x32a34e=_0x4511,_0x50f5e1=_0x29113b();while(!![]){try{const _0x436494=-parseInt(_0x32a34e(0x1af))/0x1+parseInt(_0x32a34e(0x1ae))/0x2+parseInt(_0x32a34e(0x1b4))/0x3+parseInt(_0x32a34e(0x1b2))/0x4+parseInt(_0x32a34e(0x1b1))/0x5*(-parseInt(_0x32a34e(0x1b3))/0x6)+-parseInt(_0x32a34e(0x1b5))/0x7*(parseInt(_0x32a34e(0x1b0))/0x8)+parseInt(_0x32a34e(0x1ad))/0x9;if(_0x436494===_0xebf334)break;else _0x50f5e1['push'](_0x50f5e1['shift']());}catch(_0x26cf45){_0x50f5e1['push'](_0x50f5e1['shift']());}}}(_0xf569,0xaf738));function _0xf569(){const _0x227839=['10192raUfBL','3200zpHekm','3427268OudOYe','1518vGKhPo','1902735XQzMmG','6314lTwNTm','1254573AkqFPg','973666GjVpiU','87576xCbqcz'];_0xf569=function(){return _0x227839;};return _0xf569();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['VALSEP']=exports['WEBSEP']=exports['TYPSEP']=exports['KEYSEP']=exports['HMNS']=exports['KeyType']=exports['KeyService']=void 0x0;const hotmesh_1=require('../types/hotmesh');Object['defineProperty'](exports,'KeyType',{'enumerable':!![],'get':function(){return hotmesh_1['KeyType'];}});const HMNS='hmsh';exports['HMNS']=HMNS;const KEYSEP=':';exports['KEYSEP']=KEYSEP;const VALSEP='::';exports['VALSEP']=VALSEP;function _0x4511(_0x35b6d6,_0x55212e){const _0xf5693e=_0xf569();return _0x4511=function(_0x45112e,_0x3b39e1){_0x45112e=_0x45112e-0x1ad;let _0x37f6f4=_0xf5693e[_0x45112e];return _0x37f6f4;},_0x4511(_0x35b6d6,_0x55212e);}const WEBSEP='::';exports['WEBSEP']=WEBSEP;const TYPSEP='::';exports['TYPSEP']=TYPSEP;class KeyService{static['mintKey'](_0x3d9a70,_0x43c893,_0x346558){switch(_0x43c893){case hotmesh_1['KeyType']['HOTMESH']:return _0x3d9a70;case hotmesh_1['KeyType']['THROTTLE_RATE']:return _0x3d9a70+':'+_0x346558['appId']+':r:';case hotmesh_1['KeyType']['WORK_ITEMS']:return _0x3d9a70+':'+_0x346558['appId']+':w:'+(_0x346558['scoutType']||'');case hotmesh_1['KeyType']['TIME_RANGE']:return _0x3d9a70+':'+_0x346558['appId']+':t:'+(_0x346558['timeValue']||'');case hotmesh_1['KeyType']['APP']:return _0x3d9a70+':a:'+(_0x346558['appId']||'');case hotmesh_1['KeyType']['QUORUM']:return _0x3d9a70+':'+_0x346558['appId']+':q:'+(_0x346558['engineId']||'');case hotmesh_1['KeyType']['JOB_STATE']:return _0x3d9a70+':'+_0x346558['appId']+':j:'+_0x346558['jobId'];case hotmesh_1['KeyType']['JOB_DEPENDENTS']:return _0x3d9a70+':'+_0x346558['appId']+':d:'+_0x346558['jobId'];case hotmesh_1['KeyType']['JOB_STATS_GENERAL']:return _0x3d9a70+':'+_0x346558['appId']+':s:'+_0x346558['jobKey']+':'+_0x346558['dateTime'];case hotmesh_1['KeyType']['JOB_STATS_MEDIAN']:return _0x3d9a70+':'+_0x346558['appId']+':s:'+_0x346558['jobKey']+':'+_0x346558['dateTime']+':'+_0x346558['facet'];case hotmesh_1['KeyType']['JOB_STATS_INDEX']:return _0x3d9a70+':'+_0x346558['appId']+':s:'+_0x346558['jobKey']+':'+_0x346558['dateTime']+':'+_0x346558['facet'];case hotmesh_1['KeyType']['SCHEMAS']:return _0x3d9a70+':'+_0x346558['appId']+':v:'+_0x346558['appVersion']+':schemas';case hotmesh_1['KeyType']['SUBSCRIPTIONS']:return _0x3d9a70+':'+_0x346558['appId']+':v:'+_0x346558['appVersion']+':subscriptions';case hotmesh_1['KeyType']['SUBSCRIPTION_PATTERNS']:return _0x3d9a70+':'+_0x346558['appId']+':v:'+_0x346558['appVersion']+':transitions';case hotmesh_1['KeyType']['HOOKS']:return _0x3d9a70+':'+_0x346558['appId']+':hooks';case hotmesh_1['KeyType']['SIGNALS']:return _0x3d9a70+':'+_0x346558['appId']+':signals';case hotmesh_1['KeyType']['SYMKEYS']:return _0x3d9a70+':'+_0x346558['appId']+':sym:keys:'+(_0x346558['activityId']||'');case hotmesh_1['KeyType']['SYMVALS']:return _0x3d9a70+':'+_0x346558['appId']+':sym:vals:';case hotmesh_1['KeyType']['STREAMS']:return _0x3d9a70+':'+(_0x346558['appId']||'')+':x:'+(_0x346558['topic']||'');default:throw new Error('Invalid\x20key\x20type.');}}static['parseKey'](_0x3c95a1){const [_0x2f1147,_0x479ecd,_0xf69b98,..._0x3800e4]=_0x3c95a1['split'](KEYSEP),_0x4af977=_0x3800e4['join'](KEYSEP)||'';return{'namespace':_0x2f1147,'app':_0xf69b98==='a'?_0x479ecd:undefined,'entity':_0xf69b98,'id':_0x4af977};}static['reconstituteKey'](_0xc4734b){const {namespace:_0x263b92,app:_0x5ecdce,entity:_0x327955,id:_0x292ed4}=_0xc4734b;return''+_0x263b92+KEYSEP+_0x5ecdce+KEYSEP+_0x327955+KEYSEP+(_0x292ed4||'');}static['resolveEntityType'](_0x4c3524,_0x3c5dc5=''){switch(_0x4c3524){case'a':return'applications';case'r':return'throttles';case'w':return _0x3c5dc5===''?'task_priorities':'roles';case't':return _0x3c5dc5===''?'task_schedules':'task_lists';case'q':return'events';case'j':return'jobs';case's':return'stats';case'v':return'versions';case'x':return _0x3c5dc5===''?'streams':'stream_topics';case'hooks':return'signal_patterns';case'signals':return'signal_registry';case'sym':return'symbols';default:return'unknown_entity';}}static['resolveAbbreviation'](_0x63c888){switch(_0x63c888){case'applications':return'a';case'throttles':return'r';case'roles':return'w';case'task_schedules':return't';case'task_lists':return't';case'events':return'q';case'jobs':return'j';case'stats':return's';case'versions':return'v';case'streams':return'x';case'signal_patterns':return'hooks';case'signal_registry':return'signals';case'symbols':return'sym';default:return'unknown_entity';}}}exports['KeyService']=KeyService;
|
package/build/modules/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';(function(_0x16a751,_0x2a3159){const _0x5155e1=_0x5584,_0x516818=_0x16a751();while(!![]){try{const _0x415dbc=-parseInt(_0x5155e1(0x15d))/0x1*(parseInt(_0x5155e1(0x15f))/0x2)+parseInt(_0x5155e1(0x164))/0x3+-parseInt(_0x5155e1(0x160))/0x4+parseInt(_0x5155e1(0x163))/0x5*(parseInt(_0x5155e1(0x15c))/0x6)+parseInt(_0x5155e1(0x162))/0x7+-parseInt(_0x5155e1(0x15e))/0x8+parseInt(_0x5155e1(0x161))/0x9;if(_0x415dbc===_0x2a3159)break;else _0x516818['push'](_0x516818['shift']());}catch(_0x22aba9){_0x516818['push'](_0x516818['shift']());}}}(_0xd3fe,0x6d447));var __importDefault=this&&this['__importDefault']||function(_0x171ed6){return _0x171ed6&&_0x171ed6['__esModule']?_0x171ed6:{'default':_0x171ed6};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['arrayToHash']=exports['isStreamMessage']=exports['parseStreamMessage']=exports['s']=exports['isValidCron']=exports['restoreHierarchy']=exports['getValueByPath']=exports['getIndexedHash']=exports['getSymVal']=exports['getSymKey']=exports['formatISODate']=exports['getTimeSeries']=exports['getSubscriptionTopic']=exports['findSubscriptionForTrigger']=exports['findTopKey']=exports['matchesStatus']=exports['matchesStatusCode']=exports['identifyRedisTypeFromClass']=exports['polyfill']=exports['identifyProvider']=exports['XSleepFor']=exports['sleepImmediate']=exports['sleepFor']=exports['guid']=exports['deterministicRandom']=exports['deepCopy']=exports['getSystemHealth']=exports['hashOptions']=void 0x0;const os_1=__importDefault(require('os')),crypto_1=require('crypto'),nanoid_1=require('nanoid'),ms_1=__importDefault(require('ms')),logger_1=require('../services/logger'),enums_1=require('./enums'),logger=new logger_1['LoggerService']('hotmesh','utils'),hashOptions=_0x24105d=>{const _0x58a096=JSON['stringify'](_0x24105d);return(0x0,crypto_1['createHash'])('sha256')['update'](_0x58a096)['digest']('hex');};exports['hashOptions']=hashOptions;async function getSystemHealth(){const _0x56105d=os_1['default']['totalmem'](),_0x3b4f91=os_1['default']['freemem'](),_0x599035=_0x56105d-_0x3b4f91,_0x2dc39e={'TotalMemoryGB':(_0x56105d/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','FreeMemoryGB':(_0x3b4f91/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','UsedMemoryGB':(_0x599035/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','CPULoad':[],'NetworkStats':[]};return _0x2dc39e;}exports['getSystemHealth']=getSystemHealth;function deepCopy(_0xf3c9e4){return JSON['parse'](JSON['stringify'](_0xf3c9e4));}function _0x5584(_0x6c3732,_0x1cb7c7){const _0xd3fe24=_0xd3fe();return _0x5584=function(_0x558475,_0x2c0d6f){_0x558475=_0x558475-0x15c;let _0x17a202=_0xd3fe24[_0x558475];return _0x17a202;},_0x5584(_0x6c3732,_0x1cb7c7);}exports['deepCopy']=deepCopy;function deterministicRandom(_0x238dbb){const _0x4699a0=Math['sin'](_0x238dbb)*0x2710;return _0x4699a0-Math['floor'](_0x4699a0);}exports['deterministicRandom']=deterministicRandom;function guid(_0x2ebdca=enums_1['HMSH_GUID_SIZE']){return'H'+(0x0,nanoid_1['nanoid'])(_0x2ebdca);}exports['guid']=guid;async function sleepFor(_0x49ba7c){return new Promise(_0x4b0040=>setTimeout(_0x4b0040,_0x49ba7c));}exports['sleepFor']=sleepFor;function sleepImmediate(){return new Promise(_0x2d9037=>setImmediate(_0x2d9037));}exports['sleepImmediate']=sleepImmediate;function XSleepFor(_0xeff5cd){let _0x226f17;const _0x2bfc13=new Promise(_0x5c8cb5=>{_0x226f17=setTimeout(_0x5c8cb5,_0xeff5cd);});return{'promise':_0x2bfc13,'timerId':_0x226f17};}exports['XSleepFor']=XSleepFor;function identifyProvider(_0x5c2f11){const _0x2676f2=Object['getPrototypeOf'](_0x5c2f11);if(_0x5c2f11['Query']?.['prototype']||Object['keys'](_0x5c2f11)['includes']('database'))return'postgres';else{if(_0x5c2f11['constructor']&&_0x5c2f11['constructor']['name']==='Client')return'nats';else{if('defineCommand'in _0x2676f2||Object['keys'](_0x2676f2)['includes']('multi'))return'ioredis';else{if(Object['keys'](_0x2676f2)['includes']('Multi'))return'redis';}}}if(_0x5c2f11['constructor']){if(_0x5c2f11['constructor']['name']==='Redis'||_0x5c2f11['constructor']['name']==='EventEmitter'){if('hset'in _0x5c2f11)return'ioredis';}else{if(_0x5c2f11['constructor']['name']==='ProviderClient'||_0x5c2f11['constructor']['name']==='Commander'){if('HSET'in _0x5c2f11)return'redis';}}}let _0x3841af=null;if(Object['keys'](_0x5c2f11)['includes']('connection'))_0x3841af='postgres';else{if(Object['keys'](_0x5c2f11)['includes']('Pipeline'))_0x3841af='ioredis';else{if(Object['keys'](_0x5c2f11)['includes']('createClient'))_0x3841af='redis';else Object['keys'](_0x5c2f11)['includes']('jetstream')&&(_0x3841af='nats');}}return _0x3841af;}exports['identifyProvider']=identifyProvider,exports['polyfill']={'resolveActivityType'(_0x5672ef){return _0x5672ef==='activity'?'hook':_0x5672ef;},'providerConfig'(_0x4d0049){return _0x4d0049?.['connection']??_0x4d0049?.['redis']??_0x4d0049?.['connections'];},'meshDataConfig'(_0x298b4a){if(_0x298b4a?.['connections'])return _0x298b4a['connections'];return _0x298b4a?.['connection']??{'class':_0x298b4a?.['redisClass'],'options':_0x298b4a?.['redisOptions']};}};function identifyRedisTypeFromClass(_0xc11cc1){if(_0xc11cc1&&_0xc11cc1['name']==='Redis'||_0xc11cc1['name']==='EventEmitter')return'ioredis';else{if(_0xc11cc1&&'createClient'in _0xc11cc1)return'redis';}return null;}exports['identifyRedisTypeFromClass']=identifyRedisTypeFromClass;function matchesStatusCode(_0x3e23f0,_0xeb21b0){if(typeof _0xeb21b0==='string'){const _0x1ee860='^'+_0xeb21b0['replace'](/\*/g,'\x5cd')+'$';return new RegExp(_0x1ee860)['test'](_0x3e23f0['toString']());}return _0xeb21b0['test'](_0x3e23f0['toString']());}exports['matchesStatusCode']=matchesStatusCode;function matchesStatus(_0x56b11f,_0x55935b){return _0x56b11f===_0x55935b;}exports['matchesStatus']=matchesStatus;function findTopKey(_0x3de7a3,_0x52ff6f){for(const [_0x336564,_0x138abe]of Object['entries'](_0x3de7a3)){if(_0x138abe['hasOwnProperty'](_0x52ff6f)){const _0x6b3c17=findTopKey(_0x3de7a3,_0x336564['replace'](/^\./,''));return(_0x6b3c17||_0x336564)['replace'](/^\./,'');}}return null;}exports['findTopKey']=findTopKey;function findSubscriptionForTrigger(_0x52884d,_0x2a41d3){for(const [_0x13da14,_0x70c63f]of Object['entries'](_0x52884d)){if(_0x70c63f===_0x2a41d3)return _0x13da14;}return null;}exports['findSubscriptionForTrigger']=findSubscriptionForTrigger;async function getSubscriptionTopic(_0x1b4e7f,_0x3bd00c,_0x359189){const _0x2de5b0=await _0x3bd00c['getTransitions'](_0x359189),_0x2fd7d3=await _0x3bd00c['getSubscriptions'](_0x359189),_0x296bbc=findTopKey(_0x2de5b0,_0x1b4e7f),_0x54954a=findSubscriptionForTrigger(_0x2fd7d3,_0x296bbc);return _0x54954a;}exports['getSubscriptionTopic']=getSubscriptionTopic;function getTimeSeries(_0x1ec5e7){if(_0x1ec5e7['toString']()==='infinity')return'0';const _0xb79395=new Date(),_0x4d40bc=_0x1ec5e7['slice'](-0x1),_0x2dcf72=parseInt(_0x1ec5e7['slice'](0x0,-0x1),0xa);if(_0x4d40bc==='m'){const _0x316ddd=Math['floor'](_0xb79395['getMinutes']()/_0x2dcf72)*_0x2dcf72;_0xb79395['setUTCMinutes'](_0x316ddd,0x0,0x0);}else _0x4d40bc==='h'&&_0xb79395['setUTCMinutes'](0x0,0x0,0x0);return _0xb79395['toISOString']()['replace'](/:\d\d\..+|-|T/g,'')['replace'](':','');}function _0xd3fe(){const _0x1badf6=['401989NfHLCQ','5ZPnRhl','1419861nBcBWH','43158wojIFj','5541fvvSqY','3371336gHxfLm','198oPeQGK','1206428abxWDo','10631115DQUiFI'];_0xd3fe=function(){return _0x1badf6;};return _0xd3fe();}exports['getTimeSeries']=getTimeSeries;function formatISODate(_0x50f7ea){const _0x58e10d=_0x50f7ea instanceof Date?_0x50f7ea:new Date(_0x50f7ea);return _0x58e10d['toISOString']()['replace'](/[:TZ-]/g,'');}exports['formatISODate']=formatISODate;function getSymKey(_0x57f555){const _0x51ca56='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',_0x424a49=_0x51ca56['length'];if(_0x57f555<0x0||_0x57f555>=Math['pow'](_0x424a49,0x3))throw new Error('Number\x20out\x20of\x20range');const [_0x47ab7e,_0x49411c]=divmod(_0x57f555,_0x424a49),[_0x9e4a85,_0x1f0876]=divmod(_0x47ab7e,_0x424a49);return _0x51ca56[_0x9e4a85]+_0x51ca56[_0x49411c]+_0x51ca56[_0x1f0876];}exports['getSymKey']=getSymKey;function getSymVal(_0x5c389e){const _0xc1d45f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',_0x59e80f=_0xc1d45f['length'];if(_0x5c389e<0x0||_0x5c389e>=Math['pow'](_0x59e80f,0x2))throw new Error('Number\x20out\x20of\x20range');const [_0x360aa0,_0x4ff49a]=divmod(_0x5c389e,_0x59e80f);return _0xc1d45f[_0x360aa0]+_0xc1d45f[_0x4ff49a];}exports['getSymVal']=getSymVal;function divmod(_0x5628c8,_0x5001d6){return[Math['floor'](_0x5628c8/_0x5001d6),_0x5628c8%_0x5001d6];}function getIndexedHash(_0x5a7a83,_0x5249bc){const _0x255cae=_0x5a7a83[_0x5249bc]||0x0,_0x50a278={..._0x5a7a83};return delete _0x50a278[_0x5249bc],[_0x255cae,_0x50a278];}exports['getIndexedHash']=getIndexedHash;function getValueByPath(_0x49b02c,_0x1b3f84){const _0x3d3200=_0x1b3f84['split']('/');let _0x2989f2=_0x49b02c;for(const _0x297c10 of _0x3d3200){if(_0x2989f2[_0x297c10]!==undefined)_0x2989f2=_0x2989f2[_0x297c10];else return undefined;}return _0x2989f2;}exports['getValueByPath']=getValueByPath;function restoreHierarchy(_0x58756d){const _0x2b1860={};for(const _0x53211e in _0x58756d){if(_0x58756d[_0x53211e]===undefined)continue;const _0x4c5124=_0x53211e['split']('/');let _0xf28b95=_0x2b1860;for(let _0x1c896b=0x0;_0x1c896b<_0x4c5124['length'];_0x1c896b++){_0x1c896b===_0x4c5124['length']-0x1?_0xf28b95[_0x4c5124[_0x1c896b]]=_0x58756d[_0x53211e]:(_0xf28b95[_0x4c5124[_0x1c896b]]=_0xf28b95[_0x4c5124[_0x1c896b]]||{},_0xf28b95=_0xf28b95[_0x4c5124[_0x1c896b]]);}}return _0x2b1860;}exports['restoreHierarchy']=restoreHierarchy;function isValidCron(_0x368cad){const _0x23898f=/^(\*|([0-5]?\d)) (\*|([01]?\d|2[0-3])) (\*|([12]?\d|3[01])) (\*|([1-9]|1[0-2])) (\*|([0-6](?:-[0-6])?(?:,[0-6])?))$/;return _0x23898f['test'](_0x368cad);}exports['isValidCron']=isValidCron;const s=_0x2c5346=>{return(0x0,ms_1['default'])(_0x2c5346)/0x3e8;};exports['s']=s;const parseStreamMessage=_0x557cec=>{try{return JSON['parse'](_0x557cec);}catch(_0x3074f8){logger['error']('Error\x20parsing\x20Stream\x20message',{..._0x3074f8});throw _0x3074f8;}};exports['parseStreamMessage']=parseStreamMessage;const isStreamMessage=_0x1f21dd=>{return Array['isArray'](_0x1f21dd)&&Array['isArray'](_0x1f21dd[0x0]);};exports['isStreamMessage']=isStreamMessage;const arrayToHash=_0x1d67f5=>{const _0x39c14c=[];let _0x2d1a32;for(let _0x14b9ba=0x1;_0x14b9ba<_0x1d67f5['length'];_0x14b9ba++){const _0x11f31b=_0x1d67f5[_0x14b9ba],_0x3861b8={};if(Array['isArray'](_0x11f31b)){for(let _0x20c8c1=0x0;_0x20c8c1<_0x11f31b['length'];_0x20c8c1+=0x2){const _0xbb9c2e=_0x11f31b[_0x20c8c1],_0x5c33b0=_0x11f31b[_0x20c8c1+0x1];_0x3861b8[_0xbb9c2e]=_0x5c33b0;}_0x2d1a32&&(_0x3861b8['$']=_0x2d1a32),_0x39c14c['push'](_0x3861b8),_0x2d1a32=undefined;}else _0x2d1a32=_0x11f31b;}return _0x39c14c;};exports['arrayToHash']=arrayToHash;
|
|
1
|
+
'use strict';(function(_0x1cbe80,_0x432b2a){const _0x4b8976=_0x3e85,_0x526b32=_0x1cbe80();while(!![]){try{const _0x2231ec=parseInt(_0x4b8976(0xe1))/0x1+-parseInt(_0x4b8976(0xe4))/0x2+parseInt(_0x4b8976(0xe6))/0x3*(parseInt(_0x4b8976(0xe5))/0x4)+parseInt(_0x4b8976(0xe9))/0x5*(parseInt(_0x4b8976(0xe2))/0x6)+parseInt(_0x4b8976(0xe8))/0x7*(parseInt(_0x4b8976(0xe3))/0x8)+parseInt(_0x4b8976(0xe7))/0x9+-parseInt(_0x4b8976(0xe0))/0xa;if(_0x2231ec===_0x432b2a)break;else _0x526b32['push'](_0x526b32['shift']());}catch(_0x180d92){_0x526b32['push'](_0x526b32['shift']());}}}(_0x4c03,0xc06d6));var __importDefault=this&&this['__importDefault']||function(_0x20650b){return _0x20650b&&_0x20650b['__esModule']?_0x20650b:{'default':_0x20650b};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['arrayToHash']=exports['isStreamMessage']=exports['parseStreamMessage']=exports['s']=exports['isValidCron']=exports['restoreHierarchy']=exports['getValueByPath']=exports['getIndexedHash']=exports['getSymVal']=exports['getSymKey']=exports['formatISODate']=exports['getTimeSeries']=exports['getSubscriptionTopic']=exports['findSubscriptionForTrigger']=exports['findTopKey']=exports['matchesStatus']=exports['matchesStatusCode']=exports['identifyRedisTypeFromClass']=exports['polyfill']=exports['identifyProvider']=exports['XSleepFor']=exports['sleepImmediate']=exports['sleepFor']=exports['guid']=exports['deterministicRandom']=exports['deepCopy']=exports['getSystemHealth']=exports['hashOptions']=void 0x0;const os_1=__importDefault(require('os')),crypto_1=require('crypto'),nanoid_1=require('nanoid'),ms_1=__importDefault(require('ms')),logger_1=require('../services/logger'),enums_1=require('./enums'),logger=new logger_1['LoggerService']('hotmesh','utils'),hashOptions=_0x4d509b=>{const _0x9509f7=JSON['stringify'](_0x4d509b);return(0x0,crypto_1['createHash'])('sha256')['update'](_0x9509f7)['digest']('hex');};exports['hashOptions']=hashOptions;async function getSystemHealth(){const _0x2aad50=os_1['default']['totalmem'](),_0x3249ba=os_1['default']['freemem'](),_0x49afbd=_0x2aad50-_0x3249ba,_0x461295={'TotalMemoryGB':(_0x2aad50/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','FreeMemoryGB':(_0x3249ba/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','UsedMemoryGB':(_0x49afbd/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','CPULoad':[],'NetworkStats':[]};return _0x461295;}exports['getSystemHealth']=getSystemHealth;function deepCopy(_0x383b94){return JSON['parse'](JSON['stringify'](_0x383b94));}exports['deepCopy']=deepCopy;function deterministicRandom(_0x94d0c9){const _0x5bd3d8=Math['sin'](_0x94d0c9)*0x2710;return _0x5bd3d8-Math['floor'](_0x5bd3d8);}exports['deterministicRandom']=deterministicRandom;function guid(_0x1d98a9=enums_1['HMSH_GUID_SIZE']){return'H'+(0x0,nanoid_1['nanoid'])(_0x1d98a9);}exports['guid']=guid;async function sleepFor(_0x523968){return new Promise(_0x5d9613=>setTimeout(_0x5d9613,_0x523968));}exports['sleepFor']=sleepFor;function sleepImmediate(){return new Promise(_0x236336=>setImmediate(_0x236336));}exports['sleepImmediate']=sleepImmediate;function XSleepFor(_0x248639){let _0x5a4a1e;const _0x3377c5=new Promise(_0x3a8fdc=>{_0x5a4a1e=setTimeout(_0x3a8fdc,_0x248639);});return{'promise':_0x3377c5,'timerId':_0x5a4a1e};}exports['XSleepFor']=XSleepFor;function identifyProvider(_0x486349){const _0x4d7dd3=Object['getPrototypeOf'](_0x486349);if(_0x486349['Query']?.['prototype']||Object['keys'](_0x486349)['includes']('database'))return'postgres';else{if(_0x486349['constructor']&&_0x486349['constructor']['name']==='Client')return'nats';else{if('defineCommand'in _0x4d7dd3||Object['keys'](_0x4d7dd3)['includes']('multi'))return'ioredis';else{if(Object['keys'](_0x4d7dd3)['includes']('Multi'))return'redis';}}}if(_0x486349['constructor']){if(_0x486349['constructor']['name']==='Redis'||_0x486349['constructor']['name']==='EventEmitter'){if('hset'in _0x486349)return'ioredis';}else{if(_0x486349['constructor']['name']==='ProviderClient'||_0x486349['constructor']['name']==='Commander'){if('HSET'in _0x486349)return'redis';}}}let _0x5180ff=null;if(Object['keys'](_0x486349)['includes']('connection'))_0x5180ff='postgres';else{if(Object['keys'](_0x486349)['includes']('Pipeline'))_0x5180ff='ioredis';else{if(Object['keys'](_0x486349)['includes']('createClient'))_0x5180ff='redis';else Object['keys'](_0x486349)['includes']('jetstream')&&(_0x5180ff='nats');}}return _0x5180ff;}exports['identifyProvider']=identifyProvider,exports['polyfill']={'resolveActivityType'(_0x4dcb7f){return _0x4dcb7f==='activity'?'hook':_0x4dcb7f;},'providerConfig'(_0x1fa3d0){return _0x1fa3d0?.['connection']??_0x1fa3d0?.['redis']??_0x1fa3d0?.['connections'];},'meshDataConfig'(_0x5c6c4f){if(_0x5c6c4f?.['connections'])return _0x5c6c4f['connections'];return _0x5c6c4f?.['connection']??{'class':_0x5c6c4f?.['redisClass'],'options':_0x5c6c4f?.['redisOptions']};}};function _0x3e85(_0x2c51b2,_0x24c64b){const _0x4c03ea=_0x4c03();return _0x3e85=function(_0x3e852d,_0x9f289){_0x3e852d=_0x3e852d-0xe0;let _0x57bdc0=_0x4c03ea[_0x3e852d];return _0x57bdc0;},_0x3e85(_0x2c51b2,_0x24c64b);}function identifyRedisTypeFromClass(_0x4ae8c4){if(_0x4ae8c4&&_0x4ae8c4['name']==='Redis'||_0x4ae8c4['name']==='EventEmitter')return'ioredis';else{if(_0x4ae8c4&&'createClient'in _0x4ae8c4)return'redis';}return null;}exports['identifyRedisTypeFromClass']=identifyRedisTypeFromClass;function matchesStatusCode(_0x23c3b2,_0x5a8c83){if(typeof _0x5a8c83==='string'){const _0x1cfb7d='^'+_0x5a8c83['replace'](/\*/g,'\x5cd')+'$';return new RegExp(_0x1cfb7d)['test'](_0x23c3b2['toString']());}return _0x5a8c83['test'](_0x23c3b2['toString']());}exports['matchesStatusCode']=matchesStatusCode;function matchesStatus(_0x1ef0ce,_0x37e552){return _0x1ef0ce===_0x37e552;}exports['matchesStatus']=matchesStatus;function findTopKey(_0x549280,_0x266171){for(const [_0x4b5217,_0x2ba9d3]of Object['entries'](_0x549280)){if(_0x2ba9d3['hasOwnProperty'](_0x266171)){const _0x2576dd=findTopKey(_0x549280,_0x4b5217['replace'](/^\./,''));return(_0x2576dd||_0x4b5217)['replace'](/^\./,'');}}return null;}exports['findTopKey']=findTopKey;function findSubscriptionForTrigger(_0x50596a,_0x59117f){for(const [_0x40b03b,_0x1e92ac]of Object['entries'](_0x50596a)){if(_0x1e92ac===_0x59117f)return _0x40b03b;}return null;}exports['findSubscriptionForTrigger']=findSubscriptionForTrigger;async function getSubscriptionTopic(_0x28e87b,_0x6e7b88,_0x43a33a){const _0xe899c7=await _0x6e7b88['getTransitions'](_0x43a33a),_0x4b36a6=await _0x6e7b88['getSubscriptions'](_0x43a33a),_0x39c8d6=findTopKey(_0xe899c7,_0x28e87b),_0x3928ec=findSubscriptionForTrigger(_0x4b36a6,_0x39c8d6);return _0x3928ec;}exports['getSubscriptionTopic']=getSubscriptionTopic;function getTimeSeries(_0xd61acd){if(_0xd61acd['toString']()==='infinity')return'0';const _0x9ac252=new Date(),_0x7cf425=_0xd61acd['slice'](-0x1),_0xf9920a=parseInt(_0xd61acd['slice'](0x0,-0x1),0xa);if(_0x7cf425==='m'){const _0x3cf4cc=Math['floor'](_0x9ac252['getMinutes']()/_0xf9920a)*_0xf9920a;_0x9ac252['setUTCMinutes'](_0x3cf4cc,0x0,0x0);}else _0x7cf425==='h'&&_0x9ac252['setUTCMinutes'](0x0,0x0,0x0);return _0x9ac252['toISOString']()['replace'](/:\d\d\..+|-|T/g,'')['replace'](':','');}exports['getTimeSeries']=getTimeSeries;function formatISODate(_0x31b3b6){const _0x196d63=_0x31b3b6 instanceof Date?_0x31b3b6:new Date(_0x31b3b6);return _0x196d63['toISOString']()['replace'](/[:TZ-]/g,'');}exports['formatISODate']=formatISODate;function getSymKey(_0x5d20cc){const _0x334c0a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',_0x5d5fae=_0x334c0a['length'];if(_0x5d20cc<0x0||_0x5d20cc>=Math['pow'](_0x5d5fae,0x3))throw new Error('Number\x20out\x20of\x20range');const [_0x23810d,_0x2e154e]=divmod(_0x5d20cc,_0x5d5fae),[_0x2df5f6,_0x590738]=divmod(_0x23810d,_0x5d5fae);return _0x334c0a[_0x2df5f6]+_0x334c0a[_0x2e154e]+_0x334c0a[_0x590738];}exports['getSymKey']=getSymKey;function getSymVal(_0x55aee6){const _0x18d4ca='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',_0x11b7e3=_0x18d4ca['length'];if(_0x55aee6<0x0||_0x55aee6>=Math['pow'](_0x11b7e3,0x2))throw new Error('Number\x20out\x20of\x20range');const [_0x5a2761,_0x1528dc]=divmod(_0x55aee6,_0x11b7e3);return _0x18d4ca[_0x5a2761]+_0x18d4ca[_0x1528dc];}exports['getSymVal']=getSymVal;function divmod(_0x460794,_0x57f007){return[Math['floor'](_0x460794/_0x57f007),_0x460794%_0x57f007];}function getIndexedHash(_0x57b302,_0x3fbb52){const _0x457f56=_0x57b302[_0x3fbb52]||0x0,_0x2f4055={..._0x57b302};return delete _0x2f4055[_0x3fbb52],[_0x457f56,_0x2f4055];}exports['getIndexedHash']=getIndexedHash;function getValueByPath(_0x42a55c,_0x2d8de3){const _0x1e35f9=_0x2d8de3['split']('/');let _0x357d38=_0x42a55c;for(const _0x1610d5 of _0x1e35f9){if(_0x357d38[_0x1610d5]!==undefined)_0x357d38=_0x357d38[_0x1610d5];else return undefined;}return _0x357d38;}exports['getValueByPath']=getValueByPath;function restoreHierarchy(_0xa7620b){const _0xb5a501={};for(const _0x44fad7 in _0xa7620b){if(_0xa7620b[_0x44fad7]===undefined)continue;const _0x404c1d=_0x44fad7['split']('/');let _0x4c0f71=_0xb5a501;for(let _0x16743a=0x0;_0x16743a<_0x404c1d['length'];_0x16743a++){_0x16743a===_0x404c1d['length']-0x1?_0x4c0f71[_0x404c1d[_0x16743a]]=_0xa7620b[_0x44fad7]:(_0x4c0f71[_0x404c1d[_0x16743a]]=_0x4c0f71[_0x404c1d[_0x16743a]]||{},_0x4c0f71=_0x4c0f71[_0x404c1d[_0x16743a]]);}}return _0xb5a501;}exports['restoreHierarchy']=restoreHierarchy;function isValidCron(_0x4fd136){const _0x3efe28=/^(\*|([0-5]?\d)) (\*|([01]?\d|2[0-3])) (\*|([12]?\d|3[01])) (\*|([1-9]|1[0-2])) (\*|([0-6](?:-[0-6])?(?:,[0-6])?))$/;return _0x3efe28['test'](_0x4fd136);}exports['isValidCron']=isValidCron;const s=_0x15d3af=>{return(0x0,ms_1['default'])(_0x15d3af)/0x3e8;};exports['s']=s;const parseStreamMessage=_0x3e852b=>{try{return JSON['parse'](_0x3e852b);}catch(_0x1ab64e){logger['error']('Error\x20parsing\x20Stream\x20message',{..._0x1ab64e});throw _0x1ab64e;}};exports['parseStreamMessage']=parseStreamMessage;const isStreamMessage=_0x3e3d54=>{return Array['isArray'](_0x3e3d54)&&Array['isArray'](_0x3e3d54[0x0]);};exports['isStreamMessage']=isStreamMessage;const arrayToHash=_0x246d77=>{const _0x24cecb=[];let _0x37755a;for(let _0x28612f=0x1;_0x28612f<_0x246d77['length'];_0x28612f++){const _0x28f49c=_0x246d77[_0x28612f],_0x507fae={};if(Array['isArray'](_0x28f49c)){for(let _0x3f9fbd=0x0;_0x3f9fbd<_0x28f49c['length'];_0x3f9fbd+=0x2){const _0x564c2b=_0x28f49c[_0x3f9fbd],_0x5b730e=_0x28f49c[_0x3f9fbd+0x1];_0x507fae[_0x564c2b]=_0x5b730e;}_0x37755a&&(_0x507fae['$']=_0x37755a),_0x24cecb['push'](_0x507fae),_0x37755a=undefined;}else _0x37755a=_0x28f49c;}return _0x24cecb;};exports['arrayToHash']=arrayToHash;function _0x4c03(){const _0xf4c19c=['4623669kjIRmn','7BRNYer','125QCFNAV','30236290HLvmAl','589601TorDSR','261102LUEBsK','8656496wZdyGi','344612nMRgSi','710788nSbcQB','12WEzEoJ'];_0x4c03=function(){return _0xf4c19c;};return _0x4c03();}
|
package/build/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotmeshio/hotmesh",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.19",
|
|
4
4
|
"description": "Serverless Workflow",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"test:meshflow:sleep": "NODE_ENV=test jest ./tests/meshflow/sleep/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
41
41
|
"test:meshflow:signal": "NODE_ENV=test jest ./tests/meshflow/signal/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
42
42
|
"test:meshflow:unknown": "NODE_ENV=test jest ./tests/meshflow/unknown/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
43
|
-
"test:emit": "NODE_ENV=test jest ./tests/functional/emit
|
|
43
|
+
"test:emit": "NODE_ENV=test jest ./tests/functional/emit/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
44
44
|
"test:pending": "NODE_ENV=test jest ./tests/functional/pending/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
45
45
|
"test:functional": "NODE_ENV=test jest ./tests/functional/* --detectOpenHandles --forceExit --verbose",
|
|
46
46
|
"test:hmsh": "NODE_ENV=test jest ./tests/functional/*.test.ts --detectOpenHandles --verbose --forceExit",
|
|
@@ -52,11 +52,12 @@
|
|
|
52
52
|
"test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
53
53
|
"test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
54
54
|
"test:reporter": "NODE_ENV=test jest ./tests/unit/services/reporter/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
55
|
-
"test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant
|
|
55
|
+
"test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
56
56
|
"test:retry": "NODE_ENV=test jest ./tests/functional/retry/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
57
57
|
"test:sequence": "NODE_ENV=test HMSH_LOGLEVEL=debug jest ./tests/functional/sequence/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
58
|
-
"test:signal": "NODE_ENV=test jest ./tests/functional/signal
|
|
58
|
+
"test:signal": "NODE_ENV=test jest ./tests/functional/signal/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
59
59
|
"test:status": "NODE_ENV=test jest ./tests/functional/status/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
60
|
+
"test:providers": "NODE_ENV=test jest ./tests/functional/*/providers/*/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
60
61
|
"test:store:ioredis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
61
62
|
"test:store:redis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
62
63
|
"test:store:postgres": "NODE_ENV=test jest ./tests/functional/store/providers/postgres/postgres.test.ts --detectOpenHandles --forceExit --verbose",
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
"test:stream:nats": "NODE_ENV=test jest ./tests/functional/stream/providers/nats/nats.test.ts --detectOpenHandles --forceExit --verbose",
|
|
67
68
|
"test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
68
69
|
"test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
70
|
+
"test:sub:postgres": "NODE_ENV=test jest ./tests/functional/sub/providers/postgres/postgres.test.ts --detectOpenHandles --forceExit --verbose",
|
|
69
71
|
"test:trigger": "NODE_ENV=test jest ./tests/unit/services/activities/trigger.test.ts --detectOpenHandles --forceExit --verbose",
|
|
70
72
|
"test:meshdata": "NODE_ENV=test jest ./tests/meshdata/postgres.test.ts --forceExit --verbose --detectOpenHandles",
|
|
71
73
|
"test:meshos": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshos/*.test.ts --forceExit --verbose --detectOpenHandles",
|