@hotmeshio/hotmesh 0.3.17 → 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 +161 -64
- package/build/modules/key.js +1 -1
- package/build/modules/utils.js +1 -1
- package/build/package.json +6 -8
- 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 -8
- 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
|
|
|
@@ -525,7 +554,7 @@ This example calls an activity and then sleeps for a week. It runs indefinitely
|
|
|
525
554
|
<br/>
|
|
526
555
|
|
|
527
556
|
## MeshData | Transactional Analytics
|
|
528
|
-
[MeshData](https://hotmeshio.github.io/sdk-typescript/classes/services_meshdata.MeshData.html)
|
|
557
|
+
[MeshData](https://hotmeshio.github.io/sdk-typescript/classes/services_meshdata.MeshData.html) adds analytics to your workflows.
|
|
529
558
|
|
|
530
559
|
<details style="padding: .5em">
|
|
531
560
|
<summary style="font-size:1.25em;">Create a search index <small>[more]</small></summary>
|
|
@@ -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(_0x39a741,_0x4f06aa){const _0x2f4c6b=_0x3b19,_0x32d838=_0x39a741();while(!![]){try{const _0x216418=parseInt(_0x2f4c6b(0x1c2))/0x1*(parseInt(_0x2f4c6b(0x1c9))/0x2)+-parseInt(_0x2f4c6b(0x1c7))/0x3*(parseInt(_0x2f4c6b(0x1be))/0x4)+parseInt(_0x2f4c6b(0x1c6))/0x5*(-parseInt(_0x2f4c6b(0x1c0))/0x6)+parseInt(_0x2f4c6b(0x1c4))/0x7*(-parseInt(_0x2f4c6b(0x1bd))/0x8)+-parseInt(_0x2f4c6b(0x1c5))/0x9+-parseInt(_0x2f4c6b(0x1c1))/0xa*(parseInt(_0x2f4c6b(0x1c8))/0xb)+parseInt(_0x2f4c6b(0x1bf))/0xc*(parseInt(_0x2f4c6b(0x1c3))/0xd);if(_0x216418===_0x4f06aa)break;else _0x32d838['push'](_0x32d838['shift']());}catch(_0x1bb3d4){_0x32d838['push'](_0x32d838['shift']());}}}(_0x5e93,0x5f617));var __importDefault=this&&this['__importDefault']||function(_0x45c4e6){return _0x45c4e6&&_0x45c4e6['__esModule']?_0x45c4e6:{'default':_0x45c4e6};};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=_0x3d74b5=>{const _0x57d5f4=JSON['stringify'](_0x3d74b5);return(0x0,crypto_1['createHash'])('sha256')['update'](_0x57d5f4)['digest']('hex');};exports['hashOptions']=hashOptions;async function getSystemHealth(){const _0x46870c=os_1['default']['totalmem'](),_0xecf354=os_1['default']['freemem'](),_0x23fddb=_0x46870c-_0xecf354,_0x33f834={'TotalMemoryGB':(_0x46870c/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','FreeMemoryGB':(_0xecf354/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','UsedMemoryGB':(_0x23fddb/0x400/0x400/0x400)['toFixed'](0x2)+'\x20GB','CPULoad':[],'NetworkStats':[]};return _0x33f834;}exports['getSystemHealth']=getSystemHealth;function deepCopy(_0x291d68){return JSON['parse'](JSON['stringify'](_0x291d68));}exports['deepCopy']=deepCopy;function deterministicRandom(_0xd5cb12){const _0x446ca9=Math['sin'](_0xd5cb12)*0x2710;return _0x446ca9-Math['floor'](_0x446ca9);}exports['deterministicRandom']=deterministicRandom;function guid(_0x3a6c8f=enums_1['HMSH_GUID_SIZE']){return'H'+(0x0,nanoid_1['nanoid'])(_0x3a6c8f);}exports['guid']=guid;async function sleepFor(_0x182d8a){return new Promise(_0x41e55d=>setTimeout(_0x41e55d,_0x182d8a));}exports['sleepFor']=sleepFor;function sleepImmediate(){return new Promise(_0x56a76f=>setImmediate(_0x56a76f));}exports['sleepImmediate']=sleepImmediate;function _0x5e93(){const _0x433b8d=['15942Bgyvxj','231JchcFS','8eQHGLD','349208ZiiuIe','284XXHZNh','1539852LvgNyq','282YnTggY','203760OohNRS','74740dvKxlD','169BHvAVF','21CujXIB','2806029mFiivs','34950thfAkx'];_0x5e93=function(){return _0x433b8d;};return _0x5e93();}function XSleepFor(_0x3a1dfd){let _0x41a38a;const _0x581ccc=new Promise(_0x225723=>{_0x41a38a=setTimeout(_0x225723,_0x3a1dfd);});return{'promise':_0x581ccc,'timerId':_0x41a38a};}exports['XSleepFor']=XSleepFor;function identifyProvider(_0x45958d){const _0xc8f55f=Object['getPrototypeOf'](_0x45958d);if(_0x45958d['Query']?.['prototype']||Object['keys'](_0x45958d)['includes']('database'))return'postgres';else{if(_0x45958d['constructor']&&_0x45958d['constructor']['name']==='Client')return'nats';else{if('defineCommand'in _0xc8f55f||Object['keys'](_0xc8f55f)['includes']('multi'))return'ioredis';else{if(Object['keys'](_0xc8f55f)['includes']('Multi'))return'redis';}}}if(_0x45958d['constructor']){if(_0x45958d['constructor']['name']==='Redis'||_0x45958d['constructor']['name']==='EventEmitter'){if('hset'in _0x45958d)return'ioredis';}else{if(_0x45958d['constructor']['name']==='ProviderClient'||_0x45958d['constructor']['name']==='Commander'){if('HSET'in _0x45958d)return'redis';}}}let _0x44ccef=null;if(Object['keys'](_0x45958d)['includes']('connection'))_0x44ccef='postgres';else{if(Object['keys'](_0x45958d)['includes']('Pipeline'))_0x44ccef='ioredis';else{if(Object['keys'](_0x45958d)['includes']('createClient'))_0x44ccef='redis';else Object['keys'](_0x45958d)['includes']('jetstream')&&(_0x44ccef='nats');}}return _0x44ccef;}exports['identifyProvider']=identifyProvider,exports['polyfill']={'resolveActivityType'(_0x1a7829){return _0x1a7829==='activity'?'hook':_0x1a7829;},'providerConfig'(_0x5db966){return _0x5db966?.['connection']??_0x5db966?.['redis']??_0x5db966?.['connections'];},'meshDataConfig'(_0x5d6232){if(_0x5d6232?.['connections'])return _0x5d6232['connections'];return _0x5d6232?.['connection']??{'class':_0x5d6232?.['redisClass'],'options':_0x5d6232?.['redisOptions']};}};function identifyRedisTypeFromClass(_0x2758e2){if(_0x2758e2&&_0x2758e2['name']==='Redis'||_0x2758e2['name']==='EventEmitter')return'ioredis';else{if(_0x2758e2&&'createClient'in _0x2758e2)return'redis';}return null;}exports['identifyRedisTypeFromClass']=identifyRedisTypeFromClass;function matchesStatusCode(_0x1fcb6e,_0x2819dc){if(typeof _0x2819dc==='string'){const _0x365d14='^'+_0x2819dc['replace'](/\*/g,'\x5cd')+'$';return new RegExp(_0x365d14)['test'](_0x1fcb6e['toString']());}return _0x2819dc['test'](_0x1fcb6e['toString']());}exports['matchesStatusCode']=matchesStatusCode;function matchesStatus(_0x7901b0,_0x11961d){return _0x7901b0===_0x11961d;}exports['matchesStatus']=matchesStatus;function findTopKey(_0x51f169,_0x46bd8a){for(const [_0x3f0a7d,_0x224512]of Object['entries'](_0x51f169)){if(_0x224512['hasOwnProperty'](_0x46bd8a)){const _0x5bf32d=findTopKey(_0x51f169,_0x3f0a7d['replace'](/^\./,''));return(_0x5bf32d||_0x3f0a7d)['replace'](/^\./,'');}}return null;}exports['findTopKey']=findTopKey;function findSubscriptionForTrigger(_0x12e7c5,_0x37034f){for(const [_0x1aeb58,_0x452f46]of Object['entries'](_0x12e7c5)){if(_0x452f46===_0x37034f)return _0x1aeb58;}return null;}exports['findSubscriptionForTrigger']=findSubscriptionForTrigger;async function getSubscriptionTopic(_0x1e0e5c,_0xecf942,_0x7fa2b1){const _0x44564d=await _0xecf942['getTransitions'](_0x7fa2b1),_0x53ccf5=await _0xecf942['getSubscriptions'](_0x7fa2b1),_0x53946d=findTopKey(_0x44564d,_0x1e0e5c),_0x10295c=findSubscriptionForTrigger(_0x53ccf5,_0x53946d);return _0x10295c;}function _0x3b19(_0x4c4a1b,_0x29cc26){const _0x5e936e=_0x5e93();return _0x3b19=function(_0x3b1996,_0x22240e){_0x3b1996=_0x3b1996-0x1bd;let _0x1e0a97=_0x5e936e[_0x3b1996];return _0x1e0a97;},_0x3b19(_0x4c4a1b,_0x29cc26);}exports['getSubscriptionTopic']=getSubscriptionTopic;function getTimeSeries(_0x2ced0d){if(_0x2ced0d['toString']()==='infinity')return'0';const _0x4f4493=new Date(),_0x1526f6=_0x2ced0d['slice'](-0x1),_0x462e74=parseInt(_0x2ced0d['slice'](0x0,-0x1),0xa);if(_0x1526f6==='m'){const _0x521c0f=Math['floor'](_0x4f4493['getMinutes']()/_0x462e74)*_0x462e74;_0x4f4493['setUTCMinutes'](_0x521c0f,0x0,0x0);}else _0x1526f6==='h'&&_0x4f4493['setUTCMinutes'](0x0,0x0,0x0);return _0x4f4493['toISOString']()['replace'](/:\d\d\..+|-|T/g,'')['replace'](':','');}exports['getTimeSeries']=getTimeSeries;function formatISODate(_0x2aac6f){const _0x2f11ed=_0x2aac6f instanceof Date?_0x2aac6f:new Date(_0x2aac6f);return _0x2f11ed['toISOString']()['replace'](/[:TZ-]/g,'');}exports['formatISODate']=formatISODate;function getSymKey(_0x952196){const _0x8943a6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',_0x5596e2=_0x8943a6['length'];if(_0x952196<0x0||_0x952196>=Math['pow'](_0x5596e2,0x3))throw new Error('Number\x20out\x20of\x20range');const [_0x3f0a3d,_0x54dce7]=divmod(_0x952196,_0x5596e2),[_0x433f1e,_0x16833f]=divmod(_0x3f0a3d,_0x5596e2);return _0x8943a6[_0x433f1e]+_0x8943a6[_0x54dce7]+_0x8943a6[_0x16833f];}exports['getSymKey']=getSymKey;function getSymVal(_0x51fb2d){const _0x1bcd29='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',_0x46252c=_0x1bcd29['length'];if(_0x51fb2d<0x0||_0x51fb2d>=Math['pow'](_0x46252c,0x2))throw new Error('Number\x20out\x20of\x20range');const [_0x12f932,_0x15c0b2]=divmod(_0x51fb2d,_0x46252c);return _0x1bcd29[_0x12f932]+_0x1bcd29[_0x15c0b2];}exports['getSymVal']=getSymVal;function divmod(_0x11b10d,_0x6c533d){return[Math['floor'](_0x11b10d/_0x6c533d),_0x11b10d%_0x6c533d];}function getIndexedHash(_0x53cd32,_0x32298c){const _0x37d287=_0x53cd32[_0x32298c]||0x0,_0x190b60={..._0x53cd32};return delete _0x190b60[_0x32298c],[_0x37d287,_0x190b60];}exports['getIndexedHash']=getIndexedHash;function getValueByPath(_0x5386bc,_0x4487b3){const _0xede79d=_0x4487b3['split']('/');let _0x16b2cf=_0x5386bc;for(const _0x4cb641 of _0xede79d){if(_0x16b2cf[_0x4cb641]!==undefined)_0x16b2cf=_0x16b2cf[_0x4cb641];else return undefined;}return _0x16b2cf;}exports['getValueByPath']=getValueByPath;function restoreHierarchy(_0x2b4797){const _0x907b2a={};for(const _0x11c70f in _0x2b4797){if(_0x2b4797[_0x11c70f]===undefined)continue;const _0x24f8e7=_0x11c70f['split']('/');let _0x342927=_0x907b2a;for(let _0x2ef784=0x0;_0x2ef784<_0x24f8e7['length'];_0x2ef784++){_0x2ef784===_0x24f8e7['length']-0x1?_0x342927[_0x24f8e7[_0x2ef784]]=_0x2b4797[_0x11c70f]:(_0x342927[_0x24f8e7[_0x2ef784]]=_0x342927[_0x24f8e7[_0x2ef784]]||{},_0x342927=_0x342927[_0x24f8e7[_0x2ef784]]);}}return _0x907b2a;}exports['restoreHierarchy']=restoreHierarchy;function isValidCron(_0x366863){const _0x1d56c2=/^(\*|([0-5]?\d)) (\*|([01]?\d|2[0-3])) (\*|([12]?\d|3[01])) (\*|([1-9]|1[0-2])) (\*|([0-6](?:-[0-6])?(?:,[0-6])?))$/;return _0x1d56c2['test'](_0x366863);}exports['isValidCron']=isValidCron;const s=_0x16ebc3=>{return(0x0,ms_1['default'])(_0x16ebc3)/0x3e8;};exports['s']=s;const parseStreamMessage=_0x23f23f=>{try{return JSON['parse'](_0x23f23f);}catch(_0x5a97eb){logger['error']('Error\x20parsing\x20Stream\x20message',{..._0x5a97eb});throw _0x5a97eb;}};exports['parseStreamMessage']=parseStreamMessage;const isStreamMessage=_0x168efb=>{return Array['isArray'](_0x168efb)&&Array['isArray'](_0x168efb[0x0]);};exports['isStreamMessage']=isStreamMessage;const arrayToHash=_0x22d796=>{const _0x34c4df=[];let _0xf3e0f0;for(let _0x272a56=0x1;_0x272a56<_0x22d796['length'];_0x272a56++){const _0x101841=_0x22d796[_0x272a56],_0x21a062={};if(Array['isArray'](_0x101841)){for(let _0x342a81=0x0;_0x342a81<_0x101841['length'];_0x342a81+=0x2){const _0x28ef01=_0x101841[_0x342a81],_0x21b610=_0x101841[_0x342a81+0x1];_0x21a062[_0x28ef01]=_0x21b610;}_0xf3e0f0&&(_0x21a062['$']=_0xf3e0f0),_0x34c4df['push'](_0x21a062),_0xf3e0f0=undefined;}else _0xf3e0f0=_0x101841;}return _0x34c4df;};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,13 +1,9 @@
|
|
|
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",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/hotmeshio/sdk-typescript.git"
|
|
10
|
-
},
|
|
11
7
|
"homepage": "https://hotmesh.io/",
|
|
12
8
|
"publishConfig": {
|
|
13
9
|
"access": "public"
|
|
@@ -44,7 +40,7 @@
|
|
|
44
40
|
"test:meshflow:sleep": "NODE_ENV=test jest ./tests/meshflow/sleep/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
45
41
|
"test:meshflow:signal": "NODE_ENV=test jest ./tests/meshflow/signal/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
46
42
|
"test:meshflow:unknown": "NODE_ENV=test jest ./tests/meshflow/unknown/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
47
|
-
"test:emit": "NODE_ENV=test jest ./tests/functional/emit
|
|
43
|
+
"test:emit": "NODE_ENV=test jest ./tests/functional/emit/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
48
44
|
"test:pending": "NODE_ENV=test jest ./tests/functional/pending/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
49
45
|
"test:functional": "NODE_ENV=test jest ./tests/functional/* --detectOpenHandles --forceExit --verbose",
|
|
50
46
|
"test:hmsh": "NODE_ENV=test jest ./tests/functional/*.test.ts --detectOpenHandles --verbose --forceExit",
|
|
@@ -56,11 +52,12 @@
|
|
|
56
52
|
"test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
57
53
|
"test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
58
54
|
"test:reporter": "NODE_ENV=test jest ./tests/unit/services/reporter/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
59
|
-
"test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant
|
|
55
|
+
"test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
60
56
|
"test:retry": "NODE_ENV=test jest ./tests/functional/retry/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
61
57
|
"test:sequence": "NODE_ENV=test HMSH_LOGLEVEL=debug jest ./tests/functional/sequence/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
62
|
-
"test:signal": "NODE_ENV=test jest ./tests/functional/signal
|
|
58
|
+
"test:signal": "NODE_ENV=test jest ./tests/functional/signal/*.test.ts --detectOpenHandles --forceExit --verbose",
|
|
63
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",
|
|
64
61
|
"test:store:ioredis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
65
62
|
"test:store:redis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
66
63
|
"test:store:postgres": "NODE_ENV=test jest ./tests/functional/store/providers/postgres/postgres.test.ts --detectOpenHandles --forceExit --verbose",
|
|
@@ -70,6 +67,7 @@
|
|
|
70
67
|
"test:stream:nats": "NODE_ENV=test jest ./tests/functional/stream/providers/nats/nats.test.ts --detectOpenHandles --forceExit --verbose",
|
|
71
68
|
"test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
72
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",
|
|
73
71
|
"test:trigger": "NODE_ENV=test jest ./tests/unit/services/activities/trigger.test.ts --detectOpenHandles --forceExit --verbose",
|
|
74
72
|
"test:meshdata": "NODE_ENV=test jest ./tests/meshdata/postgres.test.ts --forceExit --verbose --detectOpenHandles",
|
|
75
73
|
"test:meshos": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshos/*.test.ts --forceExit --verbose --detectOpenHandles",
|