@hotmeshio/hotmesh 0.4.0 → 0.4.2
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 +39 -14
- package/build/modules/enums.d.ts +110 -0
- package/build/modules/enums.js +134 -0
- package/build/modules/errors.d.ts +124 -0
- package/build/modules/errors.js +191 -0
- package/build/modules/key.d.ts +66 -0
- package/build/modules/key.js +190 -0
- package/build/modules/storage.d.ts +3 -0
- package/build/modules/storage.js +5 -0
- package/build/modules/utils.d.ts +119 -0
- package/build/modules/utils.js +374 -0
- package/build/package.json +1 -1
- package/build/services/activities/activity.d.ts +104 -0
- package/build/services/activities/activity.js +549 -0
- package/build/services/activities/await.d.ts +12 -0
- package/build/services/activities/await.js +114 -0
- package/build/services/activities/cycle.d.ts +19 -0
- package/build/services/activities/cycle.js +112 -0
- package/build/services/activities/hook.d.ts +27 -0
- package/build/services/activities/hook.js +168 -0
- package/build/services/activities/index.d.ts +19 -0
- package/build/services/activities/index.js +20 -0
- package/build/services/activities/interrupt.d.ts +16 -0
- package/build/services/activities/interrupt.js +158 -0
- package/build/services/activities/signal.d.ts +20 -0
- package/build/services/activities/signal.js +134 -0
- package/build/services/activities/trigger.d.ts +37 -0
- package/build/services/activities/trigger.js +246 -0
- package/build/services/activities/worker.d.ts +12 -0
- package/build/services/activities/worker.js +106 -0
- package/build/services/collator/index.d.ts +111 -0
- package/build/services/collator/index.js +293 -0
- package/build/services/compiler/deployer.d.ts +40 -0
- package/build/services/compiler/deployer.js +488 -0
- package/build/services/compiler/index.d.ts +32 -0
- package/build/services/compiler/index.js +112 -0
- package/build/services/compiler/validator.d.ts +34 -0
- package/build/services/compiler/validator.js +147 -0
- package/build/services/connector/factory.d.ts +22 -0
- package/build/services/connector/factory.js +99 -0
- package/build/services/connector/index.d.ts +30 -0
- package/build/services/connector/index.js +54 -0
- package/build/services/connector/providers/ioredis.d.ts +9 -0
- package/build/services/connector/providers/ioredis.js +26 -0
- package/build/services/connector/providers/nats.d.ts +9 -0
- package/build/services/connector/providers/nats.js +34 -0
- package/build/services/connector/providers/postgres.d.ts +20 -0
- package/build/services/connector/providers/postgres.js +102 -0
- package/build/services/connector/providers/redis.d.ts +9 -0
- package/build/services/connector/providers/redis.js +38 -0
- package/build/services/engine/index.d.ts +264 -0
- package/build/services/engine/index.js +761 -0
- package/build/services/exporter/index.d.ts +44 -0
- package/build/services/exporter/index.js +126 -0
- package/build/services/hotmesh/index.d.ts +483 -0
- package/build/services/hotmesh/index.js +622 -0
- package/build/services/logger/index.d.ts +16 -0
- package/build/services/logger/index.js +54 -0
- package/build/services/mapper/index.d.ts +28 -0
- package/build/services/mapper/index.js +81 -0
- package/build/services/memflow/client.d.ts +108 -0
- package/build/services/memflow/client.js +372 -0
- package/build/services/memflow/connection.d.ts +23 -0
- package/build/services/memflow/connection.js +33 -0
- package/build/services/memflow/context.d.ts +143 -0
- package/build/services/memflow/context.js +299 -0
- package/build/services/memflow/exporter.d.ts +51 -0
- package/build/services/memflow/exporter.js +215 -0
- package/build/services/memflow/handle.d.ts +90 -0
- package/build/services/memflow/handle.js +176 -0
- package/build/services/memflow/index.d.ts +116 -0
- package/build/services/memflow/index.js +122 -0
- package/build/services/memflow/schemas/factory.d.ts +29 -0
- package/build/services/memflow/schemas/factory.js +2492 -0
- package/build/services/memflow/search.d.ts +142 -0
- package/build/services/memflow/search.js +320 -0
- package/build/services/memflow/worker.d.ts +124 -0
- package/build/services/memflow/worker.js +514 -0
- package/build/services/memflow/workflow/all.d.ts +7 -0
- package/build/services/memflow/workflow/all.js +15 -0
- package/build/services/memflow/workflow/common.d.ts +20 -0
- package/build/services/memflow/workflow/common.js +47 -0
- package/build/services/memflow/workflow/context.d.ts +6 -0
- package/build/services/memflow/workflow/context.js +45 -0
- package/build/services/memflow/workflow/contextMethods.d.ts +14 -0
- package/build/services/memflow/workflow/contextMethods.js +33 -0
- package/build/services/memflow/workflow/didRun.d.ts +7 -0
- package/build/services/memflow/workflow/didRun.js +22 -0
- package/build/services/memflow/workflow/emit.d.ts +11 -0
- package/build/services/memflow/workflow/emit.js +29 -0
- package/build/services/memflow/workflow/enrich.d.ts +9 -0
- package/build/services/memflow/workflow/enrich.js +17 -0
- package/build/services/memflow/workflow/execChild.d.ts +18 -0
- package/build/services/memflow/workflow/execChild.js +102 -0
- package/build/services/memflow/workflow/execHook.d.ts +65 -0
- package/build/services/memflow/workflow/execHook.js +73 -0
- package/build/services/memflow/workflow/hook.d.ts +9 -0
- package/build/services/memflow/workflow/hook.js +56 -0
- package/build/services/memflow/workflow/index.d.ts +74 -0
- package/build/services/memflow/workflow/index.js +87 -0
- package/build/services/memflow/workflow/interrupt.d.ts +9 -0
- package/build/services/memflow/workflow/interrupt.js +24 -0
- package/build/services/memflow/workflow/isSideEffectAllowed.d.ts +10 -0
- package/build/services/memflow/workflow/isSideEffectAllowed.js +33 -0
- package/build/services/memflow/workflow/proxyActivities.d.ts +20 -0
- package/build/services/memflow/workflow/proxyActivities.js +97 -0
- package/build/services/memflow/workflow/random.d.ts +6 -0
- package/build/services/memflow/workflow/random.js +16 -0
- package/build/services/memflow/workflow/searchMethods.d.ts +6 -0
- package/build/services/memflow/workflow/searchMethods.js +25 -0
- package/build/services/memflow/workflow/signal.d.ts +29 -0
- package/build/services/memflow/workflow/signal.js +50 -0
- package/build/services/memflow/workflow/sleepFor.d.ts +24 -0
- package/build/services/memflow/workflow/sleepFor.js +51 -0
- package/build/services/memflow/workflow/trace.d.ts +14 -0
- package/build/services/memflow/workflow/trace.js +33 -0
- package/build/services/memflow/workflow/waitFor.d.ts +29 -0
- package/build/services/memflow/workflow/waitFor.js +56 -0
- package/build/services/meshcall/index.d.ts +194 -0
- package/build/services/meshcall/index.js +452 -0
- package/build/services/meshcall/schemas/factory.d.ts +9 -0
- package/build/services/meshcall/schemas/factory.js +189 -0
- package/build/services/meshdata/index.d.ts +795 -0
- package/build/services/meshdata/index.js +1235 -0
- package/build/services/meshos/index.d.ts +293 -0
- package/build/services/meshos/index.js +547 -0
- package/build/services/pipe/functions/array.d.ts +17 -0
- package/build/services/pipe/functions/array.js +74 -0
- package/build/services/pipe/functions/bitwise.d.ts +9 -0
- package/build/services/pipe/functions/bitwise.js +24 -0
- package/build/services/pipe/functions/conditional.d.ts +13 -0
- package/build/services/pipe/functions/conditional.js +36 -0
- package/build/services/pipe/functions/cron.d.ts +12 -0
- package/build/services/pipe/functions/cron.js +40 -0
- package/build/services/pipe/functions/date.d.ts +58 -0
- package/build/services/pipe/functions/date.js +171 -0
- package/build/services/pipe/functions/index.d.ts +29 -0
- package/build/services/pipe/functions/index.js +30 -0
- package/build/services/pipe/functions/json.d.ts +5 -0
- package/build/services/pipe/functions/json.js +12 -0
- package/build/services/pipe/functions/logical.d.ts +5 -0
- package/build/services/pipe/functions/logical.js +12 -0
- package/build/services/pipe/functions/math.d.ts +42 -0
- package/build/services/pipe/functions/math.js +184 -0
- package/build/services/pipe/functions/number.d.ts +21 -0
- package/build/services/pipe/functions/number.js +60 -0
- package/build/services/pipe/functions/object.d.ts +25 -0
- package/build/services/pipe/functions/object.js +81 -0
- package/build/services/pipe/functions/string.d.ts +23 -0
- package/build/services/pipe/functions/string.js +69 -0
- package/build/services/pipe/functions/symbol.d.ts +12 -0
- package/build/services/pipe/functions/symbol.js +33 -0
- package/build/services/pipe/functions/unary.d.ts +7 -0
- package/build/services/pipe/functions/unary.js +18 -0
- package/build/services/pipe/index.d.ts +48 -0
- package/build/services/pipe/index.js +242 -0
- package/build/services/quorum/index.d.ts +90 -0
- package/build/services/quorum/index.js +263 -0
- package/build/services/reporter/index.d.ts +50 -0
- package/build/services/reporter/index.js +348 -0
- package/build/services/router/config/index.d.ts +11 -0
- package/build/services/router/config/index.js +36 -0
- package/build/services/router/consumption/index.d.ts +34 -0
- package/build/services/router/consumption/index.js +395 -0
- package/build/services/router/error-handling/index.d.ts +8 -0
- package/build/services/router/error-handling/index.js +98 -0
- package/build/services/router/index.d.ts +57 -0
- package/build/services/router/index.js +121 -0
- package/build/services/router/lifecycle/index.d.ts +27 -0
- package/build/services/router/lifecycle/index.js +80 -0
- package/build/services/router/telemetry/index.d.ts +11 -0
- package/build/services/router/telemetry/index.js +32 -0
- package/build/services/router/throttling/index.d.ts +23 -0
- package/build/services/router/throttling/index.js +76 -0
- package/build/services/search/factory.d.ts +7 -0
- package/build/services/search/factory.js +24 -0
- package/build/services/search/index.d.ts +23 -0
- package/build/services/search/index.js +10 -0
- package/build/services/search/providers/postgres/postgres.d.ts +25 -0
- package/build/services/search/providers/postgres/postgres.js +149 -0
- package/build/services/search/providers/redis/ioredis.d.ts +19 -0
- package/build/services/search/providers/redis/ioredis.js +121 -0
- package/build/services/search/providers/redis/redis.d.ts +19 -0
- package/build/services/search/providers/redis/redis.js +134 -0
- package/build/services/serializer/index.d.ts +42 -0
- package/build/services/serializer/index.js +282 -0
- package/build/services/store/cache.d.ts +67 -0
- package/build/services/store/cache.js +128 -0
- package/build/services/store/factory.d.ts +8 -0
- package/build/services/store/factory.js +24 -0
- package/build/services/store/index.d.ts +89 -0
- package/build/services/store/index.js +9 -0
- package/build/services/store/providers/postgres/kvsql.d.ts +168 -0
- package/build/services/store/providers/postgres/kvsql.js +198 -0
- package/build/services/store/providers/postgres/kvtables.d.ts +20 -0
- package/build/services/store/providers/postgres/kvtables.js +441 -0
- package/build/services/store/providers/postgres/kvtransaction.d.ts +36 -0
- package/build/services/store/providers/postgres/kvtransaction.js +248 -0
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +60 -0
- package/build/services/store/providers/postgres/kvtypes/hash.js +1287 -0
- package/build/services/store/providers/postgres/kvtypes/list.d.ts +33 -0
- package/build/services/store/providers/postgres/kvtypes/list.js +194 -0
- package/build/services/store/providers/postgres/kvtypes/string.d.ts +20 -0
- package/build/services/store/providers/postgres/kvtypes/string.js +115 -0
- package/build/services/store/providers/postgres/kvtypes/zset.d.ts +41 -0
- package/build/services/store/providers/postgres/kvtypes/zset.js +214 -0
- package/build/services/store/providers/postgres/postgres.d.ts +178 -0
- package/build/services/store/providers/postgres/postgres.js +1244 -0
- package/build/services/store/providers/redis/_base.d.ts +137 -0
- package/build/services/store/providers/redis/_base.js +980 -0
- package/build/services/store/providers/redis/ioredis.d.ts +20 -0
- package/build/services/store/providers/redis/ioredis.js +180 -0
- package/build/services/store/providers/redis/redis.d.ts +18 -0
- package/build/services/store/providers/redis/redis.js +199 -0
- package/build/services/store/providers/store-initializable.d.ts +5 -0
- package/build/services/store/providers/store-initializable.js +2 -0
- package/build/services/stream/factory.d.ts +8 -0
- package/build/services/stream/factory.js +37 -0
- package/build/services/stream/index.d.ts +69 -0
- package/build/services/stream/index.js +11 -0
- package/build/services/stream/providers/nats/nats.d.ts +60 -0
- package/build/services/stream/providers/nats/nats.js +225 -0
- package/build/services/stream/providers/postgres/kvtables.d.ts +3 -0
- package/build/services/stream/providers/postgres/kvtables.js +146 -0
- package/build/services/stream/providers/postgres/postgres.d.ts +107 -0
- package/build/services/stream/providers/postgres/postgres.js +519 -0
- package/build/services/stream/providers/redis/ioredis.d.ts +61 -0
- package/build/services/stream/providers/redis/ioredis.js +272 -0
- package/build/services/stream/providers/redis/redis.d.ts +61 -0
- package/build/services/stream/providers/redis/redis.js +305 -0
- package/build/services/stream/providers/stream-initializable.d.ts +4 -0
- package/build/services/stream/providers/stream-initializable.js +2 -0
- package/build/services/sub/factory.d.ts +7 -0
- package/build/services/sub/factory.js +29 -0
- package/build/services/sub/index.d.ts +22 -0
- package/build/services/sub/index.js +10 -0
- package/build/services/sub/providers/nats/nats.d.ts +19 -0
- package/build/services/sub/providers/nats/nats.js +105 -0
- package/build/services/sub/providers/postgres/postgres.d.ts +19 -0
- package/build/services/sub/providers/postgres/postgres.js +92 -0
- package/build/services/sub/providers/redis/ioredis.d.ts +17 -0
- package/build/services/sub/providers/redis/ioredis.js +81 -0
- package/build/services/sub/providers/redis/redis.d.ts +17 -0
- package/build/services/sub/providers/redis/redis.js +72 -0
- package/build/services/task/index.d.ts +48 -0
- package/build/services/task/index.js +253 -0
- package/build/services/telemetry/index.d.ts +52 -0
- package/build/services/telemetry/index.js +306 -0
- package/build/services/worker/index.d.ts +77 -0
- package/build/services/worker/index.js +197 -0
- package/package.json +1 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/typedoc.json +0 -47
- package/types/activity.ts +0 -268
- package/types/app.ts +0 -20
- package/types/async.ts +0 -6
- package/types/cache.ts +0 -1
- package/types/collator.ts +0 -9
- package/types/error.ts +0 -56
- package/types/exporter.ts +0 -102
- package/types/hook.ts +0 -44
- package/types/hotmesh.ts +0 -314
- package/types/index.ts +0 -306
- package/types/job.ts +0 -233
- package/types/logger.ts +0 -8
- package/types/manifest.ts +0 -70
- package/types/map.ts +0 -5
- package/types/memflow.ts +0 -645
- package/types/meshcall.ts +0 -235
- package/types/meshdata.ts +0 -278
- package/types/ms.d.ts +0 -7
- package/types/nats.ts +0 -270
- package/types/pipe.ts +0 -90
- package/types/postgres.ts +0 -114
- package/types/provider.ts +0 -161
- package/types/quorum.ts +0 -167
- package/types/redis.ts +0 -404
- package/types/serializer.ts +0 -40
- package/types/stats.ts +0 -117
- package/types/stream.ts +0 -231
- package/types/task.ts +0 -7
- package/types/telemetry.ts +0 -16
- package/types/transition.ts +0 -20
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { HotMesh } from '../hotmesh';
|
|
2
|
+
import { SearchService } from '../search';
|
|
3
|
+
/**
|
|
4
|
+
* The Context module provides methods for reading and writing
|
|
5
|
+
* JSONB data to a workflow's context. The instance methods
|
|
6
|
+
* exposed by this class are available for use from within
|
|
7
|
+
* a running workflow.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* //contextWorkflow.ts
|
|
12
|
+
* import { workflow } from '@hotmeshio/hotmesh';
|
|
13
|
+
*
|
|
14
|
+
* export async function contextExample(): Promise<void> {
|
|
15
|
+
* const context = await workflow.context();
|
|
16
|
+
* await context.set({ user: { id: 123 } });
|
|
17
|
+
* await context.merge({ user: { name: "John" } });
|
|
18
|
+
* const user = await context.get("user");
|
|
19
|
+
* // user = { id: 123, name: "John" }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class Context {
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
jobId: string;
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
searchSessionId: string;
|
|
32
|
+
/**
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
searchSessionIndex: number;
|
|
36
|
+
/**
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
hotMeshClient: HotMesh;
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
search: SearchService<any> | null;
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
workflowDimension: string;
|
|
48
|
+
/**
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
constructor(workflowId: string, hotMeshClient: HotMesh, searchSessionId: string);
|
|
52
|
+
/**
|
|
53
|
+
* increments the index to return a unique search session guid when
|
|
54
|
+
* calling any method that produces side effects (changes the value)
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
getSearchSessionGuid(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the entire context object. This replaces any existing context.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const context = await workflow.context();
|
|
63
|
+
* await context.set({ user: { id: 123, name: "John" } });
|
|
64
|
+
*/
|
|
65
|
+
set(value: any): Promise<any>;
|
|
66
|
+
/**
|
|
67
|
+
* Deep merges the provided object with the existing context
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const context = await workflow.context();
|
|
71
|
+
* await context.merge({ user: { email: "john@example.com" } });
|
|
72
|
+
*/
|
|
73
|
+
merge<T>(value: T): Promise<T>;
|
|
74
|
+
/**
|
|
75
|
+
* Gets a value from the context by path
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const context = await workflow.context();
|
|
79
|
+
* const user = await context.get("user");
|
|
80
|
+
* const email = await context.get("user.email");
|
|
81
|
+
*/
|
|
82
|
+
get(path?: string): Promise<any>;
|
|
83
|
+
/**
|
|
84
|
+
* Deletes a value from the context by path
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const context = await workflow.context();
|
|
88
|
+
* await context.delete("user.email");
|
|
89
|
+
*/
|
|
90
|
+
delete(path: string): Promise<any>;
|
|
91
|
+
/**
|
|
92
|
+
* Appends a value to an array at the specified path
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* const context = await workflow.context();
|
|
96
|
+
* await context.append("items", { id: 1, name: "New Item" });
|
|
97
|
+
*/
|
|
98
|
+
append(path: string, value: any): Promise<any[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Prepends a value to an array at the specified path
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const context = await workflow.context();
|
|
104
|
+
* await context.prepend("items", { id: 0, name: "First Item" });
|
|
105
|
+
*/
|
|
106
|
+
prepend(path: string, value: any): Promise<any[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Removes an item from an array at the specified path and index
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const context = await workflow.context();
|
|
112
|
+
* await context.remove("items", 0); // Remove first item
|
|
113
|
+
*/
|
|
114
|
+
remove(path: string, index: number): Promise<any[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Increments a numeric value at the specified path
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* const context = await workflow.context();
|
|
120
|
+
* await context.increment("counter", 5);
|
|
121
|
+
*/
|
|
122
|
+
increment(path: string, value?: number): Promise<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Toggles a boolean value at the specified path
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* const context = await workflow.context();
|
|
128
|
+
* await context.toggle("settings.enabled");
|
|
129
|
+
*/
|
|
130
|
+
toggle(path: string): Promise<boolean>;
|
|
131
|
+
/**
|
|
132
|
+
* Sets a value at the specified path only if it doesn't already exist
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const context = await workflow.context();
|
|
136
|
+
* await context.setIfNotExists("user.id", 123);
|
|
137
|
+
*/
|
|
138
|
+
setIfNotExists(path: string, value: any): Promise<any>;
|
|
139
|
+
/**
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
private deepMerge;
|
|
143
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Context = void 0;
|
|
4
|
+
const key_1 = require("../../modules/key");
|
|
5
|
+
const storage_1 = require("../../modules/storage");
|
|
6
|
+
/**
|
|
7
|
+
* The Context module provides methods for reading and writing
|
|
8
|
+
* JSONB data to a workflow's context. The instance methods
|
|
9
|
+
* exposed by this class are available for use from within
|
|
10
|
+
* a running workflow.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* //contextWorkflow.ts
|
|
15
|
+
* import { workflow } from '@hotmeshio/hotmesh';
|
|
16
|
+
*
|
|
17
|
+
* export async function contextExample(): Promise<void> {
|
|
18
|
+
* const context = await workflow.context();
|
|
19
|
+
* await context.set({ user: { id: 123 } });
|
|
20
|
+
* await context.merge({ user: { name: "John" } });
|
|
21
|
+
* const user = await context.get("user");
|
|
22
|
+
* // user = { id: 123, name: "John" }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
class Context {
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
constructor(workflowId, hotMeshClient, searchSessionId) {
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
this.searchSessionIndex = 0;
|
|
35
|
+
const keyParams = {
|
|
36
|
+
appId: hotMeshClient.appId,
|
|
37
|
+
jobId: workflowId,
|
|
38
|
+
};
|
|
39
|
+
this.jobId = key_1.KeyService.mintKey(hotMeshClient.namespace, key_1.KeyType.JOB_STATE, keyParams);
|
|
40
|
+
this.searchSessionId = searchSessionId;
|
|
41
|
+
this.hotMeshClient = hotMeshClient;
|
|
42
|
+
this.search = hotMeshClient.engine.search;
|
|
43
|
+
// Get workflow dimension from async local storage
|
|
44
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
45
|
+
this.workflowDimension = store?.get('workflowDimension') ?? '';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* increments the index to return a unique search session guid when
|
|
49
|
+
* calling any method that produces side effects (changes the value)
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
getSearchSessionGuid() {
|
|
53
|
+
return `${this.searchSessionId}-${this.searchSessionIndex++}-`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sets the entire context object. This replaces any existing context.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* const context = await workflow.context();
|
|
60
|
+
* await context.set({ user: { id: 123, name: "John" } });
|
|
61
|
+
*/
|
|
62
|
+
async set(value) {
|
|
63
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
64
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
65
|
+
const replay = store?.get('replay') ?? {};
|
|
66
|
+
if (ssGuid in replay) {
|
|
67
|
+
return JSON.parse(replay[ssGuid]);
|
|
68
|
+
}
|
|
69
|
+
// Use single transactional call to update context and store replay value
|
|
70
|
+
const result = await this.search.updateContext(this.jobId, {
|
|
71
|
+
'@context': JSON.stringify(value),
|
|
72
|
+
[ssGuid]: '', // Pass replay ID to hash module for transactional replay storage
|
|
73
|
+
});
|
|
74
|
+
return result || value;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Deep merges the provided object with the existing context
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const context = await workflow.context();
|
|
81
|
+
* await context.merge({ user: { email: "john@example.com" } });
|
|
82
|
+
*/
|
|
83
|
+
async merge(value) {
|
|
84
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
85
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
86
|
+
const replay = store?.get('replay') ?? {};
|
|
87
|
+
if (ssGuid in replay) {
|
|
88
|
+
return JSON.parse(replay[ssGuid]);
|
|
89
|
+
}
|
|
90
|
+
// Use server-side JSONB merge operation with replay storage
|
|
91
|
+
const newContext = await this.search.updateContext(this.jobId, {
|
|
92
|
+
'@context:merge': JSON.stringify(value),
|
|
93
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
94
|
+
});
|
|
95
|
+
return newContext;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets a value from the context by path
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const context = await workflow.context();
|
|
102
|
+
* const user = await context.get("user");
|
|
103
|
+
* const email = await context.get("user.email");
|
|
104
|
+
*/
|
|
105
|
+
async get(path) {
|
|
106
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
107
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
108
|
+
const replay = store?.get('replay') ?? {};
|
|
109
|
+
if (ssGuid in replay) {
|
|
110
|
+
// Replay cache stores the already-extracted value, not full context
|
|
111
|
+
return JSON.parse(replay[ssGuid]);
|
|
112
|
+
}
|
|
113
|
+
let value;
|
|
114
|
+
if (!path) {
|
|
115
|
+
// No path - fetch entire context with replay storage
|
|
116
|
+
const result = await this.search.updateContext(this.jobId, {
|
|
117
|
+
'@context:get': '',
|
|
118
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
119
|
+
});
|
|
120
|
+
// setFields returns the actual context value for @context:get operations
|
|
121
|
+
value = result || {};
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// Use PostgreSQL JSONB path extraction for specific paths with replay storage
|
|
125
|
+
const result = await this.search.updateContext(this.jobId, {
|
|
126
|
+
'@context:get': path,
|
|
127
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
128
|
+
});
|
|
129
|
+
// setFields returns the actual path value for @context:get operations
|
|
130
|
+
value = result;
|
|
131
|
+
}
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Deletes a value from the context by path
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* const context = await workflow.context();
|
|
139
|
+
* await context.delete("user.email");
|
|
140
|
+
*/
|
|
141
|
+
async delete(path) {
|
|
142
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
143
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
144
|
+
const replay = store?.get('replay') ?? {};
|
|
145
|
+
if (ssGuid in replay) {
|
|
146
|
+
return JSON.parse(replay[ssGuid]);
|
|
147
|
+
}
|
|
148
|
+
// Use server-side JSONB delete operation with replay storage
|
|
149
|
+
const newContext = await this.search.updateContext(this.jobId, {
|
|
150
|
+
'@context:delete': path,
|
|
151
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
152
|
+
});
|
|
153
|
+
return newContext;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Appends a value to an array at the specified path
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* const context = await workflow.context();
|
|
160
|
+
* await context.append("items", { id: 1, name: "New Item" });
|
|
161
|
+
*/
|
|
162
|
+
async append(path, value) {
|
|
163
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
164
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
165
|
+
const replay = store?.get('replay') ?? {};
|
|
166
|
+
if (ssGuid in replay) {
|
|
167
|
+
return JSON.parse(replay[ssGuid]);
|
|
168
|
+
}
|
|
169
|
+
// Use server-side JSONB array append operation with replay storage
|
|
170
|
+
const newArray = await this.search.updateContext(this.jobId, {
|
|
171
|
+
'@context:append': JSON.stringify({ path, value }),
|
|
172
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
173
|
+
});
|
|
174
|
+
return newArray;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Prepends a value to an array at the specified path
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* const context = await workflow.context();
|
|
181
|
+
* await context.prepend("items", { id: 0, name: "First Item" });
|
|
182
|
+
*/
|
|
183
|
+
async prepend(path, value) {
|
|
184
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
185
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
186
|
+
const replay = store?.get('replay') ?? {};
|
|
187
|
+
if (ssGuid in replay) {
|
|
188
|
+
return JSON.parse(replay[ssGuid]);
|
|
189
|
+
}
|
|
190
|
+
// Use server-side JSONB array prepend operation with replay storage
|
|
191
|
+
const newArray = await this.search.updateContext(this.jobId, {
|
|
192
|
+
'@context:prepend': JSON.stringify({ path, value }),
|
|
193
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
194
|
+
});
|
|
195
|
+
return newArray;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Removes an item from an array at the specified path and index
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* const context = await workflow.context();
|
|
202
|
+
* await context.remove("items", 0); // Remove first item
|
|
203
|
+
*/
|
|
204
|
+
async remove(path, index) {
|
|
205
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
206
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
207
|
+
const replay = store?.get('replay') ?? {};
|
|
208
|
+
if (ssGuid in replay) {
|
|
209
|
+
return JSON.parse(replay[ssGuid]);
|
|
210
|
+
}
|
|
211
|
+
// Use server-side JSONB array remove operation with replay storage
|
|
212
|
+
const newArray = await this.search.updateContext(this.jobId, {
|
|
213
|
+
'@context:remove': JSON.stringify({ path, index }),
|
|
214
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
215
|
+
});
|
|
216
|
+
return newArray;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Increments a numeric value at the specified path
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* const context = await workflow.context();
|
|
223
|
+
* await context.increment("counter", 5);
|
|
224
|
+
*/
|
|
225
|
+
async increment(path, value = 1) {
|
|
226
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
227
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
228
|
+
const replay = store?.get('replay') ?? {};
|
|
229
|
+
if (ssGuid in replay) {
|
|
230
|
+
return JSON.parse(replay[ssGuid]);
|
|
231
|
+
}
|
|
232
|
+
// Use server-side JSONB increment operation with replay storage
|
|
233
|
+
const newValue = await this.search.updateContext(this.jobId, {
|
|
234
|
+
'@context:increment': JSON.stringify({ path, value }),
|
|
235
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
236
|
+
});
|
|
237
|
+
return Number(newValue);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Toggles a boolean value at the specified path
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* const context = await workflow.context();
|
|
244
|
+
* await context.toggle("settings.enabled");
|
|
245
|
+
*/
|
|
246
|
+
async toggle(path) {
|
|
247
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
248
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
249
|
+
const replay = store?.get('replay') ?? {};
|
|
250
|
+
if (ssGuid in replay) {
|
|
251
|
+
return JSON.parse(replay[ssGuid]);
|
|
252
|
+
}
|
|
253
|
+
// Use server-side JSONB toggle operation with replay storage
|
|
254
|
+
const newValue = await this.search.updateContext(this.jobId, {
|
|
255
|
+
'@context:toggle': path,
|
|
256
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
257
|
+
});
|
|
258
|
+
return Boolean(newValue);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Sets a value at the specified path only if it doesn't already exist
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* const context = await workflow.context();
|
|
265
|
+
* await context.setIfNotExists("user.id", 123);
|
|
266
|
+
*/
|
|
267
|
+
async setIfNotExists(path, value) {
|
|
268
|
+
const ssGuid = this.getSearchSessionGuid();
|
|
269
|
+
const store = storage_1.asyncLocalStorage.getStore();
|
|
270
|
+
const replay = store?.get('replay') ?? {};
|
|
271
|
+
if (ssGuid in replay) {
|
|
272
|
+
return JSON.parse(replay[ssGuid]);
|
|
273
|
+
}
|
|
274
|
+
// Use server-side JSONB conditional set operation with replay storage
|
|
275
|
+
const newValue = await this.search.updateContext(this.jobId, {
|
|
276
|
+
'@context:setIfNotExists': JSON.stringify({ path, value }),
|
|
277
|
+
[ssGuid]: '', // Pass replay ID to hash module
|
|
278
|
+
});
|
|
279
|
+
return newValue;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @private
|
|
283
|
+
*/
|
|
284
|
+
deepMerge(target, source) {
|
|
285
|
+
if (!source)
|
|
286
|
+
return target;
|
|
287
|
+
const output = { ...target };
|
|
288
|
+
Object.keys(source).forEach(key => {
|
|
289
|
+
if (source[key] instanceof Object && key in target) {
|
|
290
|
+
output[key] = this.deepMerge(target[key], source[key]);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
output[key] = source[key];
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
return output;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
exports.Context = Context;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ILogger } from '../logger';
|
|
2
|
+
import { StoreService } from '../store';
|
|
3
|
+
import { ExportOptions, MemFlowJobExport, TimelineType, TransitionType, ExportFields } from '../../types/exporter';
|
|
4
|
+
import { ProviderClient, ProviderTransaction } from '../../types/provider';
|
|
5
|
+
import { StringStringType, Symbols } from '../../types/serializer';
|
|
6
|
+
declare class ExporterService {
|
|
7
|
+
appId: string;
|
|
8
|
+
logger: ILogger;
|
|
9
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
10
|
+
symbols: Promise<Symbols> | Symbols;
|
|
11
|
+
private static symbols;
|
|
12
|
+
constructor(appId: string, store: StoreService<ProviderClient, ProviderTransaction>, logger: ILogger);
|
|
13
|
+
/**
|
|
14
|
+
* Convert the job hash from its compiles format into a MemFlowJobExport object with
|
|
15
|
+
* facets that describe the workflow in terms relevant to narrative storytelling.
|
|
16
|
+
*/
|
|
17
|
+
export(jobId: string, options?: ExportOptions): Promise<MemFlowJobExport>;
|
|
18
|
+
/**
|
|
19
|
+
* Inflates the job data from Redis into a MemFlowJobExport object
|
|
20
|
+
* @param jobHash - the job data from Redis
|
|
21
|
+
* @param dependencyList - the list of dependencies for the job
|
|
22
|
+
* @returns - the inflated job data
|
|
23
|
+
*/
|
|
24
|
+
inflate(jobHash: StringStringType, options: ExportOptions): MemFlowJobExport;
|
|
25
|
+
resolveValue(raw: string, withValues: boolean): Record<string, any> | string | number | null;
|
|
26
|
+
/**
|
|
27
|
+
* Inflates the key from Redis, 3-character symbol
|
|
28
|
+
* into a human-readable JSON path, reflecting the
|
|
29
|
+
* tree-like structure of the unidimensional Hash
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
inflateKey(key: string): string;
|
|
33
|
+
filterFields(fullObject: MemFlowJobExport, block?: ExportFields[], allow?: ExportFields[]): Partial<MemFlowJobExport>;
|
|
34
|
+
inflateTransition(match: RegExpMatchArray, value: string, transitionsObject: Record<string, TransitionType>): void;
|
|
35
|
+
sortEntriesByCreated(obj: {
|
|
36
|
+
[key: string]: TransitionType;
|
|
37
|
+
}): TransitionType[];
|
|
38
|
+
/**
|
|
39
|
+
* marker names are overloaded with details like sequence, type, etc
|
|
40
|
+
*/
|
|
41
|
+
keyToObject(key: string): {
|
|
42
|
+
index: number;
|
|
43
|
+
dimension?: string;
|
|
44
|
+
secondary?: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* idem list has a complicated sort order based on indexes and dimensions
|
|
48
|
+
*/
|
|
49
|
+
sortParts(parts: TimelineType[]): TimelineType[];
|
|
50
|
+
}
|
|
51
|
+
export { ExporterService };
|