@hotmeshio/hotmesh 0.3.32 → 0.4.0
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 +128 -823
- package/build/index.d.ts +9 -9
- package/build/index.js +10 -10
- package/build/package.json +22 -21
- package/build/types/error.d.ts +5 -5
- package/build/types/exporter.d.ts +1 -1
- package/build/types/index.d.ts +3 -3
- package/build/types/manifest.d.ts +2 -2
- package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
- package/build/types/meshdata.d.ts +3 -3
- package/build/types/postgres.d.ts +7 -0
- package/build/types/stream.d.ts +3 -0
- package/index.ts +11 -11
- package/package.json +22 -21
- package/typedoc.json +8 -7
- package/types/error.ts +5 -5
- package/types/exporter.ts +1 -1
- package/types/index.ts +7 -7
- package/types/manifest.ts +2 -2
- package/types/{meshflow.ts → memflow.ts} +15 -15
- package/types/meshdata.ts +3 -3
- package/types/postgres.ts +9 -0
- package/types/stream.ts +4 -0
- package/build/modules/enums.d.ts +0 -110
- package/build/modules/enums.js +0 -134
- package/build/modules/errors.d.ts +0 -124
- package/build/modules/errors.js +0 -191
- package/build/modules/key.d.ts +0 -66
- package/build/modules/key.js +0 -1
- package/build/modules/storage.d.ts +0 -3
- package/build/modules/storage.js +0 -5
- package/build/modules/utils.d.ts +0 -119
- package/build/modules/utils.js +0 -1
- package/build/services/activities/activity.d.ts +0 -104
- package/build/services/activities/activity.js +0 -1
- package/build/services/activities/await.d.ts +0 -12
- package/build/services/activities/await.js +0 -1
- package/build/services/activities/cycle.d.ts +0 -19
- package/build/services/activities/cycle.js +0 -1
- package/build/services/activities/hook.d.ts +0 -27
- package/build/services/activities/hook.js +0 -1
- package/build/services/activities/index.d.ts +0 -19
- package/build/services/activities/index.js +0 -1
- package/build/services/activities/interrupt.d.ts +0 -16
- package/build/services/activities/interrupt.js +0 -1
- package/build/services/activities/signal.d.ts +0 -20
- package/build/services/activities/signal.js +0 -1
- package/build/services/activities/trigger.d.ts +0 -37
- package/build/services/activities/trigger.js +0 -1
- package/build/services/activities/worker.d.ts +0 -12
- package/build/services/activities/worker.js +0 -1
- package/build/services/collator/index.d.ts +0 -111
- package/build/services/collator/index.js +0 -1
- package/build/services/compiler/deployer.d.ts +0 -40
- package/build/services/compiler/deployer.js +0 -1
- package/build/services/compiler/index.d.ts +0 -32
- package/build/services/compiler/index.js +0 -1
- package/build/services/compiler/validator.d.ts +0 -34
- package/build/services/compiler/validator.js +0 -1
- package/build/services/connector/factory.d.ts +0 -22
- package/build/services/connector/factory.js +0 -99
- package/build/services/connector/index.d.ts +0 -30
- package/build/services/connector/index.js +0 -54
- package/build/services/connector/providers/ioredis.d.ts +0 -9
- package/build/services/connector/providers/ioredis.js +0 -26
- package/build/services/connector/providers/nats.d.ts +0 -9
- package/build/services/connector/providers/nats.js +0 -34
- package/build/services/connector/providers/postgres.d.ts +0 -20
- package/build/services/connector/providers/postgres.js +0 -102
- package/build/services/connector/providers/redis.d.ts +0 -9
- package/build/services/connector/providers/redis.js +0 -38
- package/build/services/engine/index.d.ts +0 -264
- package/build/services/engine/index.js +0 -1
- package/build/services/exporter/index.d.ts +0 -44
- package/build/services/exporter/index.js +0 -1
- package/build/services/hotmesh/index.d.ts +0 -340
- package/build/services/hotmesh/index.js +0 -479
- package/build/services/logger/index.d.ts +0 -16
- package/build/services/logger/index.js +0 -54
- package/build/services/mapper/index.d.ts +0 -28
- package/build/services/mapper/index.js +0 -1
- package/build/services/meshcall/index.d.ts +0 -194
- package/build/services/meshcall/index.js +0 -452
- package/build/services/meshcall/schemas/factory.d.ts +0 -9
- package/build/services/meshcall/schemas/factory.js +0 -189
- package/build/services/meshdata/index.d.ts +0 -795
- package/build/services/meshdata/index.js +0 -1235
- package/build/services/meshflow/client.d.ts +0 -108
- package/build/services/meshflow/client.js +0 -371
- package/build/services/meshflow/connection.d.ts +0 -23
- package/build/services/meshflow/connection.js +0 -33
- package/build/services/meshflow/exporter.d.ts +0 -51
- package/build/services/meshflow/exporter.js +0 -1
- package/build/services/meshflow/handle.d.ts +0 -90
- package/build/services/meshflow/handle.js +0 -176
- package/build/services/meshflow/index.d.ts +0 -111
- package/build/services/meshflow/index.js +0 -117
- package/build/services/meshflow/schemas/factory.d.ts +0 -29
- package/build/services/meshflow/schemas/factory.js +0 -2492
- package/build/services/meshflow/search.d.ts +0 -142
- package/build/services/meshflow/search.js +0 -320
- package/build/services/meshflow/worker.d.ts +0 -124
- package/build/services/meshflow/worker.js +0 -514
- package/build/services/meshflow/workflow/all.d.ts +0 -7
- package/build/services/meshflow/workflow/all.js +0 -15
- package/build/services/meshflow/workflow/common.d.ts +0 -18
- package/build/services/meshflow/workflow/common.js +0 -45
- package/build/services/meshflow/workflow/context.d.ts +0 -6
- package/build/services/meshflow/workflow/context.js +0 -45
- package/build/services/meshflow/workflow/didRun.d.ts +0 -7
- package/build/services/meshflow/workflow/didRun.js +0 -22
- package/build/services/meshflow/workflow/emit.d.ts +0 -11
- package/build/services/meshflow/workflow/emit.js +0 -29
- package/build/services/meshflow/workflow/enrich.d.ts +0 -9
- package/build/services/meshflow/workflow/enrich.js +0 -17
- package/build/services/meshflow/workflow/execChild.d.ts +0 -18
- package/build/services/meshflow/workflow/execChild.js +0 -102
- package/build/services/meshflow/workflow/hook.d.ts +0 -9
- package/build/services/meshflow/workflow/hook.js +0 -40
- package/build/services/meshflow/workflow/index.d.ts +0 -70
- package/build/services/meshflow/workflow/index.js +0 -83
- package/build/services/meshflow/workflow/interrupt.d.ts +0 -9
- package/build/services/meshflow/workflow/interrupt.js +0 -24
- package/build/services/meshflow/workflow/isSideEffectAllowed.d.ts +0 -10
- package/build/services/meshflow/workflow/isSideEffectAllowed.js +0 -33
- package/build/services/meshflow/workflow/proxyActivities.d.ts +0 -20
- package/build/services/meshflow/workflow/proxyActivities.js +0 -97
- package/build/services/meshflow/workflow/random.d.ts +0 -6
- package/build/services/meshflow/workflow/random.js +0 -16
- package/build/services/meshflow/workflow/searchMethods.d.ts +0 -6
- package/build/services/meshflow/workflow/searchMethods.js +0 -25
- package/build/services/meshflow/workflow/signal.d.ts +0 -7
- package/build/services/meshflow/workflow/signal.js +0 -28
- package/build/services/meshflow/workflow/sleepFor.d.ts +0 -8
- package/build/services/meshflow/workflow/sleepFor.js +0 -35
- package/build/services/meshflow/workflow/trace.d.ts +0 -14
- package/build/services/meshflow/workflow/trace.js +0 -33
- package/build/services/meshflow/workflow/waitFor.d.ts +0 -8
- package/build/services/meshflow/workflow/waitFor.js +0 -35
- package/build/services/meshos/index.d.ts +0 -293
- package/build/services/meshos/index.js +0 -547
- package/build/services/pipe/functions/array.d.ts +0 -17
- package/build/services/pipe/functions/array.js +0 -1
- package/build/services/pipe/functions/bitwise.d.ts +0 -9
- package/build/services/pipe/functions/bitwise.js +0 -1
- package/build/services/pipe/functions/conditional.d.ts +0 -13
- package/build/services/pipe/functions/conditional.js +0 -1
- package/build/services/pipe/functions/cron.d.ts +0 -12
- package/build/services/pipe/functions/cron.js +0 -1
- package/build/services/pipe/functions/date.d.ts +0 -58
- package/build/services/pipe/functions/date.js +0 -1
- package/build/services/pipe/functions/index.d.ts +0 -29
- package/build/services/pipe/functions/index.js +0 -1
- package/build/services/pipe/functions/json.d.ts +0 -5
- package/build/services/pipe/functions/json.js +0 -1
- package/build/services/pipe/functions/logical.d.ts +0 -5
- package/build/services/pipe/functions/logical.js +0 -1
- package/build/services/pipe/functions/math.d.ts +0 -42
- package/build/services/pipe/functions/math.js +0 -1
- package/build/services/pipe/functions/number.d.ts +0 -21
- package/build/services/pipe/functions/number.js +0 -1
- package/build/services/pipe/functions/object.d.ts +0 -25
- package/build/services/pipe/functions/object.js +0 -1
- package/build/services/pipe/functions/string.d.ts +0 -23
- package/build/services/pipe/functions/string.js +0 -1
- package/build/services/pipe/functions/symbol.d.ts +0 -12
- package/build/services/pipe/functions/symbol.js +0 -1
- package/build/services/pipe/functions/unary.d.ts +0 -7
- package/build/services/pipe/functions/unary.js +0 -1
- package/build/services/pipe/index.d.ts +0 -48
- package/build/services/pipe/index.js +0 -1
- package/build/services/quorum/index.d.ts +0 -90
- package/build/services/quorum/index.js +0 -1
- package/build/services/reporter/index.d.ts +0 -50
- package/build/services/reporter/index.js +0 -1
- package/build/services/router/index.d.ts +0 -60
- package/build/services/router/index.js +0 -1
- package/build/services/search/factory.d.ts +0 -7
- package/build/services/search/factory.js +0 -24
- package/build/services/search/index.d.ts +0 -22
- package/build/services/search/index.js +0 -10
- package/build/services/search/providers/postgres/postgres.d.ts +0 -24
- package/build/services/search/providers/postgres/postgres.js +0 -1
- package/build/services/search/providers/redis/ioredis.d.ts +0 -18
- package/build/services/search/providers/redis/ioredis.js +0 -1
- package/build/services/search/providers/redis/redis.d.ts +0 -18
- package/build/services/search/providers/redis/redis.js +0 -1
- package/build/services/serializer/index.d.ts +0 -42
- package/build/services/serializer/index.js +0 -1
- package/build/services/store/cache.d.ts +0 -67
- package/build/services/store/cache.js +0 -128
- package/build/services/store/factory.d.ts +0 -8
- package/build/services/store/factory.js +0 -24
- package/build/services/store/index.d.ts +0 -89
- package/build/services/store/index.js +0 -9
- package/build/services/store/providers/postgres/kvsql.d.ts +0 -168
- package/build/services/store/providers/postgres/kvsql.js +0 -1
- package/build/services/store/providers/postgres/kvtables.d.ts +0 -20
- package/build/services/store/providers/postgres/kvtables.js +0 -1
- package/build/services/store/providers/postgres/kvtransaction.d.ts +0 -36
- package/build/services/store/providers/postgres/kvtransaction.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
- package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/list.d.ts +0 -33
- package/build/services/store/providers/postgres/kvtypes/list.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/string.d.ts +0 -20
- package/build/services/store/providers/postgres/kvtypes/string.js +0 -1
- package/build/services/store/providers/postgres/kvtypes/zset.d.ts +0 -41
- package/build/services/store/providers/postgres/kvtypes/zset.js +0 -1
- package/build/services/store/providers/postgres/postgres.d.ts +0 -145
- package/build/services/store/providers/postgres/postgres.js +0 -1
- package/build/services/store/providers/redis/_base.d.ts +0 -137
- package/build/services/store/providers/redis/_base.js +0 -1
- package/build/services/store/providers/redis/ioredis.d.ts +0 -20
- package/build/services/store/providers/redis/ioredis.js +0 -1
- package/build/services/store/providers/redis/redis.d.ts +0 -18
- package/build/services/store/providers/redis/redis.js +0 -1
- package/build/services/store/providers/store-initializable.d.ts +0 -5
- package/build/services/store/providers/store-initializable.js +0 -1
- package/build/services/stream/factory.d.ts +0 -8
- package/build/services/stream/factory.js +0 -37
- package/build/services/stream/index.d.ts +0 -64
- package/build/services/stream/index.js +0 -11
- package/build/services/stream/providers/nats/nats.d.ts +0 -59
- package/build/services/stream/providers/nats/nats.js +0 -1
- package/build/services/stream/providers/postgres/kvtables.d.ts +0 -2
- package/build/services/stream/providers/postgres/kvtables.js +0 -1
- package/build/services/stream/providers/postgres/postgres.d.ts +0 -88
- package/build/services/stream/providers/postgres/postgres.js +0 -1
- package/build/services/stream/providers/redis/ioredis.d.ts +0 -60
- package/build/services/stream/providers/redis/ioredis.js +0 -1
- package/build/services/stream/providers/redis/redis.d.ts +0 -60
- package/build/services/stream/providers/redis/redis.js +0 -1
- package/build/services/stream/providers/stream-initializable.d.ts +0 -4
- package/build/services/stream/providers/stream-initializable.js +0 -1
- package/build/services/sub/factory.d.ts +0 -7
- package/build/services/sub/factory.js +0 -29
- package/build/services/sub/index.d.ts +0 -22
- package/build/services/sub/index.js +0 -10
- package/build/services/sub/providers/nats/nats.d.ts +0 -19
- package/build/services/sub/providers/nats/nats.js +0 -1
- package/build/services/sub/providers/postgres/postgres.d.ts +0 -19
- package/build/services/sub/providers/postgres/postgres.js +0 -1
- package/build/services/sub/providers/redis/ioredis.d.ts +0 -17
- package/build/services/sub/providers/redis/ioredis.js +0 -1
- package/build/services/sub/providers/redis/redis.d.ts +0 -17
- package/build/services/sub/providers/redis/redis.js +0 -1
- package/build/services/task/index.d.ts +0 -36
- package/build/services/task/index.js +0 -1
- package/build/services/telemetry/index.d.ts +0 -52
- package/build/services/telemetry/index.js +0 -1
- package/build/services/worker/index.d.ts +0 -77
- package/build/services/worker/index.js +0 -1
- /package/build/types/{meshflow.js → memflow.js} +0 -0
|
@@ -1,795 +0,0 @@
|
|
|
1
|
-
import { HotMesh } from '../hotmesh';
|
|
2
|
-
import { WorkflowOptions, WorkflowSearchOptions, FindJobsOptions, FindOptions, FindWhereOptions, SearchResults, FindWhereQuery } from '../../types/meshflow';
|
|
3
|
-
import { CallOptions, ConnectionInput, ExecInput, HookInput } from '../../types/meshdata';
|
|
4
|
-
import { StringAnyType, StringStringType } from '../../types/serializer';
|
|
5
|
-
import { JobInterruptOptions, JobOutput } from '../../types/job';
|
|
6
|
-
import { QuorumMessage, QuorumMessageCallback, QuorumProfile, RollCallOptions, SubscriptionOptions, ThrottleOptions } from '../../types/quorum';
|
|
7
|
-
import { MeshFlowJobExport, ExportOptions } from '../../types/exporter';
|
|
8
|
-
import { ProviderConfig, ProvidersConfig } from '../../types/provider';
|
|
9
|
-
/**
|
|
10
|
-
* The `MeshData` service extends the `MeshFlow` service.
|
|
11
|
-
* It serves to unify both data record and
|
|
12
|
-
* transactional workflow principles into a single
|
|
13
|
-
* *Operational Data Layer*. Deployments with a 'search'
|
|
14
|
-
* provider configured (e.g.,Redis FT.SEARCH) can deliver
|
|
15
|
-
* both OLTP (transactions) and OLAP (analytics)
|
|
16
|
-
* with no additional infrastructure.
|
|
17
|
-
*
|
|
18
|
-
* The following example depicts the full end-to-end
|
|
19
|
-
* lifecycle of a `MeshData` app, including the
|
|
20
|
-
* connection of a worker function, the execution of
|
|
21
|
-
* a remote function, the retrieval of data,
|
|
22
|
-
* the creation of a search index, and the execution
|
|
23
|
-
* of a full-text search query.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import { MeshData, Types } from '@hotmeshio/hotmesh';
|
|
28
|
-
* import * as Redis from 'redis';
|
|
29
|
-
*
|
|
30
|
-
* //1) Define a search schema
|
|
31
|
-
* const schema = {
|
|
32
|
-
* schema: {
|
|
33
|
-
* id: { type: 'TAG', sortable: true },
|
|
34
|
-
* plan: { type: 'TAG', sortable: true },
|
|
35
|
-
* active: { type: 'TEXT', sortable: false },
|
|
36
|
-
* },
|
|
37
|
-
* index: 'user',
|
|
38
|
-
* prefix: ['user'], //index items with keys starting with 'user'
|
|
39
|
-
* } as unknown as Types.WorkflowSearchOptions;
|
|
40
|
-
*
|
|
41
|
-
* //2) Initialize MeshData and Redis
|
|
42
|
-
* const meshData = new MeshData(
|
|
43
|
-
* {
|
|
44
|
-
* class: Redis,
|
|
45
|
-
* options: { url: 'redis://:key_admin@redis:6379' },
|
|
46
|
-
* },
|
|
47
|
-
* schema,
|
|
48
|
-
* );
|
|
49
|
-
*
|
|
50
|
-
* //3) Connect a 'user' worker function
|
|
51
|
-
* await meshData.connect({
|
|
52
|
-
* entity: 'user',
|
|
53
|
-
* target: async function(userID: string): Promise<string> {
|
|
54
|
-
* //used the `search` extension to add searchable data
|
|
55
|
-
* const search = await MeshData.workflow.search();
|
|
56
|
-
* await search.set('active', 'yes');
|
|
57
|
-
* return `Welcome, ${userID}.`;
|
|
58
|
-
* },
|
|
59
|
-
* options: { namespace: 'meshdata' },
|
|
60
|
-
* });
|
|
61
|
-
*
|
|
62
|
-
* const userID = 'someTestUser123';
|
|
63
|
-
*
|
|
64
|
-
* //4) Call the 'user' worker function; include search data
|
|
65
|
-
* const response = await meshData.exec({
|
|
66
|
-
* entity: 'user',
|
|
67
|
-
* args: [userID],
|
|
68
|
-
* options: {
|
|
69
|
-
* ttl: 'infinity',
|
|
70
|
-
* id: userID,
|
|
71
|
-
* search: {
|
|
72
|
-
* data: { id: userID, plan: 'pro' }
|
|
73
|
-
* },
|
|
74
|
-
* namespace: 'meshdata',
|
|
75
|
-
* },
|
|
76
|
-
* });
|
|
77
|
-
*
|
|
78
|
-
* //5) Read data by field name
|
|
79
|
-
* const data = await meshData.get(
|
|
80
|
-
* 'user',
|
|
81
|
-
* userID,
|
|
82
|
-
* {
|
|
83
|
-
* fields: ['plan', 'id', 'active'],
|
|
84
|
-
* namespace: 'meshdata'
|
|
85
|
-
* },
|
|
86
|
-
* );
|
|
87
|
-
*
|
|
88
|
-
* //6) Create a search index
|
|
89
|
-
* await meshData.createSearchIndex('user', { namespace: 'meshdata' }, schema);
|
|
90
|
-
*
|
|
91
|
-
* //7) Perform Full Text Search on the indexed dataset
|
|
92
|
-
* const results = await meshData.findWhere('user', {
|
|
93
|
-
* query: [{ field: 'id', is: '=', value: userID }],
|
|
94
|
-
* limit: { start: 0, size: 100 },
|
|
95
|
-
* return: ['plan', 'id', 'active']
|
|
96
|
-
* });
|
|
97
|
-
*
|
|
98
|
-
* //8) Shutdown MeshData
|
|
99
|
-
* await MeshData.shutdown();
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
declare class MeshData {
|
|
104
|
-
/**
|
|
105
|
-
* unused; allows wrapped functions to be stringified
|
|
106
|
-
* so their source can be shared on the network for
|
|
107
|
-
* remote analysis. this is useful for targeting which
|
|
108
|
-
* version of a function is being executed.
|
|
109
|
-
* @private
|
|
110
|
-
*/
|
|
111
|
-
connectionSignatures: StringStringType;
|
|
112
|
-
/**
|
|
113
|
-
* The provider configuration for the MeshData service.
|
|
114
|
-
* @private
|
|
115
|
-
* @example
|
|
116
|
-
* // Example 1) Instantiate MeshData with `ioredis`
|
|
117
|
-
* import Redis from 'ioredis';
|
|
118
|
-
*
|
|
119
|
-
* const meshData = new MeshData({
|
|
120
|
-
* class: Redis,
|
|
121
|
-
* options: {
|
|
122
|
-
* host: 'localhost',
|
|
123
|
-
* port: 6379,
|
|
124
|
-
* password: 'shhh123',
|
|
125
|
-
* db: 0,
|
|
126
|
-
* }});
|
|
127
|
-
*
|
|
128
|
-
* // Example 2) Instantiate MeshData with `redis`
|
|
129
|
-
* import * as Redis from 'redis';
|
|
130
|
-
*
|
|
131
|
-
* const meshData = new MeshData({
|
|
132
|
-
* class: Redis,
|
|
133
|
-
* options: {
|
|
134
|
-
* url: 'redis://:shhh123@localhost:6379'
|
|
135
|
-
* }});
|
|
136
|
-
*
|
|
137
|
-
* // Example 3) Instantiate MeshData with `postgres`
|
|
138
|
-
* import { Client as PostgresClient } from 'pg';
|
|
139
|
-
*
|
|
140
|
-
* const meshData = new MeshData({
|
|
141
|
-
* class: PostgresClient,
|
|
142
|
-
* options: {
|
|
143
|
-
* connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
144
|
-
* }});
|
|
145
|
-
*
|
|
146
|
-
* // Example 4) Instantiate MeshData with `postgres` and `nats`
|
|
147
|
-
* import { connect as NATS } from 'nats';
|
|
148
|
-
*
|
|
149
|
-
* const meshData = new MeshData({
|
|
150
|
-
* store:{
|
|
151
|
-
* class: PostgresClient,
|
|
152
|
-
* options: {
|
|
153
|
-
* connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
154
|
-
* }
|
|
155
|
-
* },
|
|
156
|
-
* stream:{
|
|
157
|
-
* class: PostgresClient,
|
|
158
|
-
* options: {
|
|
159
|
-
* connectionString: 'postgresql://usr:pwd@localhost:5432/db',
|
|
160
|
-
* }
|
|
161
|
-
* },
|
|
162
|
-
* sub :{
|
|
163
|
-
* class: NATS,
|
|
164
|
-
* options: {
|
|
165
|
-
* server: ['nats://localhost:4222'],
|
|
166
|
-
* }
|
|
167
|
-
* },
|
|
168
|
-
* });
|
|
169
|
-
*/
|
|
170
|
-
connection: ProviderConfig | ProvidersConfig;
|
|
171
|
-
/**
|
|
172
|
-
* Cached local instances (map) of HotMesh organized by namespace
|
|
173
|
-
* @private
|
|
174
|
-
*/
|
|
175
|
-
instances: Map<string, Promise<HotMesh> | HotMesh>;
|
|
176
|
-
/**
|
|
177
|
-
* Search backend configuration (indexed/searchable fields and types)
|
|
178
|
-
*/
|
|
179
|
-
search: WorkflowSearchOptions;
|
|
180
|
-
/**
|
|
181
|
-
* Provides a set of static extensions that can be invoked by
|
|
182
|
-
* your linked workflow functions during their execution.
|
|
183
|
-
* @example
|
|
184
|
-
*
|
|
185
|
-
* function greet (email: string, user: { first: string}) {
|
|
186
|
-
* //persist the user's email and newsletter preferences
|
|
187
|
-
* const search = await MeshData.workflow.search();
|
|
188
|
-
* await search.set('email', email, 'newsletter', 'yes');
|
|
189
|
-
*
|
|
190
|
-
* //hook a function to send a newsletter
|
|
191
|
-
* await MeshData.workflow.hook({
|
|
192
|
-
* entity: 'user.newsletter',
|
|
193
|
-
* args: [email]
|
|
194
|
-
* });
|
|
195
|
-
*
|
|
196
|
-
* return `Hello, ${user.first}. Your email is [${email}].`;
|
|
197
|
-
* }
|
|
198
|
-
*/
|
|
199
|
-
static workflow: {
|
|
200
|
-
sleep: typeof import("../meshflow/workflow/sleepFor").sleepFor;
|
|
201
|
-
sleepFor: typeof import("../meshflow/workflow/sleepFor").sleepFor;
|
|
202
|
-
signal: typeof import("../meshflow/workflow/signal").signal;
|
|
203
|
-
hook: typeof import("../meshflow/workflow/hook").hook;
|
|
204
|
-
waitForSignal: typeof import("../meshflow/workflow/waitFor").waitFor;
|
|
205
|
-
waitFor: typeof import("../meshflow/workflow/waitFor").waitFor;
|
|
206
|
-
getHotMesh: typeof import("../..").workflow.getHotMesh;
|
|
207
|
-
random: typeof import("../meshflow/workflow/random").random;
|
|
208
|
-
search: typeof import("../meshflow/workflow/searchMethods").search;
|
|
209
|
-
getContext: typeof import("../meshflow/workflow/context").getContext;
|
|
210
|
-
/**
|
|
211
|
-
* Interrupts a job by its entity and id.
|
|
212
|
-
*/
|
|
213
|
-
interrupt: (entity: string, id: string, options?: JobInterruptOptions) => Promise<void>;
|
|
214
|
-
/**
|
|
215
|
-
* Starts a new, subordinated workflow/job execution. NOTE: The child workflow's
|
|
216
|
-
* lifecycle is bound to the parent workflow, and it will be terminated/scrubbed
|
|
217
|
-
* when the parent workflow is terminated/scrubbed.
|
|
218
|
-
*
|
|
219
|
-
* @template T The expected return type of the target function.
|
|
220
|
-
*/
|
|
221
|
-
execChild: <T>(options?: Partial<WorkflowOptions>) => Promise<T>;
|
|
222
|
-
/**
|
|
223
|
-
* Starts a new, subordinated workflow/job execution. NOTE: The child workflow's
|
|
224
|
-
* lifecycle is bound to the parent workflow, and it will be terminated/scrubbed
|
|
225
|
-
* when the parent workflow is terminated/scrubbed.
|
|
226
|
-
*
|
|
227
|
-
* @template T The expected return type of the target function.
|
|
228
|
-
*/
|
|
229
|
-
executeChild: <T_1>(options?: Partial<WorkflowOptions>) => Promise<T_1>;
|
|
230
|
-
/**
|
|
231
|
-
* Starts a new, subordinated workflow/job execution, awaiting only the jobId, namely,
|
|
232
|
-
* the confirmation that the suboridinated job has begun. NOTE: The child workflow's
|
|
233
|
-
* lifecycle is bound to the parent workflow, and it will be terminated/scrubbed
|
|
234
|
-
* when the parent workflow is terminated/scrubbed.
|
|
235
|
-
*/
|
|
236
|
-
startChild: (options?: Partial<WorkflowOptions>) => Promise<string>;
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* Instances a new `MeshData` service.
|
|
240
|
-
* @param {ProviderConfig|ProvidersConfig} connection - the connection class and options
|
|
241
|
-
* @param {WorkflowSearchOptions} search - the search options for JSON-based configuration of the backend search module (e.g., Redis FT.Search)
|
|
242
|
-
* @example
|
|
243
|
-
* // Example 1) Instantiate MeshData with `ioredis`
|
|
244
|
-
* import Redis from 'ioredis';
|
|
245
|
-
*
|
|
246
|
-
* const meshData = new MeshData({
|
|
247
|
-
* class: Redis,
|
|
248
|
-
* options: {
|
|
249
|
-
* host: 'localhost',
|
|
250
|
-
* port: 6379,
|
|
251
|
-
* password: 'shhh123',
|
|
252
|
-
* db: 0,
|
|
253
|
-
* }});
|
|
254
|
-
*
|
|
255
|
-
* // Example 2) Instantiate MeshData with `redis`
|
|
256
|
-
* import * as Redis from 'redis';
|
|
257
|
-
*
|
|
258
|
-
* const meshData = new MeshData({
|
|
259
|
-
* class: Redis,
|
|
260
|
-
* options: {
|
|
261
|
-
* url: 'redis://:shhh123@localhost:6379'
|
|
262
|
-
* }});
|
|
263
|
-
*
|
|
264
|
-
* // Instantiate MeshData with `postgres`
|
|
265
|
-
* //...
|
|
266
|
-
*/
|
|
267
|
-
constructor(connection: ProviderConfig | ProvidersConfig, search?: WorkflowSearchOptions);
|
|
268
|
-
/**
|
|
269
|
-
* @private
|
|
270
|
-
*/
|
|
271
|
-
validate(entity: string): void;
|
|
272
|
-
/**
|
|
273
|
-
* @private
|
|
274
|
-
*/
|
|
275
|
-
getConnection(): Promise<ProviderConfig | ProvidersConfig>;
|
|
276
|
-
/**
|
|
277
|
-
* Return a MeshFlow client
|
|
278
|
-
* @private
|
|
279
|
-
*/
|
|
280
|
-
getClient(): import("../..").Client;
|
|
281
|
-
/**
|
|
282
|
-
* @private
|
|
283
|
-
*/
|
|
284
|
-
safeKey(key: string): string;
|
|
285
|
-
/**
|
|
286
|
-
* @private
|
|
287
|
-
* todo: move to `utils` (might already be there);
|
|
288
|
-
* also might be better as specialized provider utils
|
|
289
|
-
*/
|
|
290
|
-
arrayToHash(input: [number, ...Array<string | string[]>]): StringStringType[];
|
|
291
|
-
/**
|
|
292
|
-
* serialize using the HotMesh `toString` format
|
|
293
|
-
* @private
|
|
294
|
-
*/
|
|
295
|
-
toString(value: unknown): string | undefined;
|
|
296
|
-
/**
|
|
297
|
-
* returns an entity-namespaced guid
|
|
298
|
-
* @param {string|null} entity - entity namespace
|
|
299
|
-
* @param {string} [id] - workflow id (allowed to be namespaced)
|
|
300
|
-
* @returns {string}
|
|
301
|
-
* @private
|
|
302
|
-
*/
|
|
303
|
-
static mintGuid(entity: string, id?: string): string;
|
|
304
|
-
/**
|
|
305
|
-
* Returns a HotMesh client
|
|
306
|
-
* @param {string} [namespace='meshflow'] - the namespace for the client
|
|
307
|
-
* @returns {Promise<HotMesh>}
|
|
308
|
-
*/
|
|
309
|
-
getHotMesh(namespace?: string): Promise<HotMesh>;
|
|
310
|
-
/**
|
|
311
|
-
* Returns the HASH key given an `entity` name and workflow/job. The
|
|
312
|
-
* item identified by this key is a HASH record with multidimensional process
|
|
313
|
-
* data interleaved with the function state data.
|
|
314
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
315
|
-
* @param {string} workflowId - the workflow/job id
|
|
316
|
-
* @param {string} [namespace='meshflow'] - the namespace for the client
|
|
317
|
-
* @returns {Promise<string>}
|
|
318
|
-
* @example
|
|
319
|
-
* // mint a key
|
|
320
|
-
* const key = await meshData.mintKey('greeting', 'jsmith123');
|
|
321
|
-
*
|
|
322
|
-
* // returns 'hmsh:meshflow:j:greeting-jsmith123'
|
|
323
|
-
*/
|
|
324
|
-
mintKey(entity: string, workflowId: string, namespace?: string): Promise<string>;
|
|
325
|
-
/**
|
|
326
|
-
* Exposes the the service mesh control plane through the
|
|
327
|
-
* mesh 'events' (pub/sub) system. This is useful for
|
|
328
|
-
* monitoring and managing the operational data layer.
|
|
329
|
-
*/
|
|
330
|
-
mesh: {
|
|
331
|
-
/**
|
|
332
|
-
* subscribes to the mesh control plane
|
|
333
|
-
* @param {QuorumMessageCallback} callback - the callback function
|
|
334
|
-
* @param {SubscriptionOptions} options - connection options
|
|
335
|
-
* @returns {Promise<void>}
|
|
336
|
-
*/
|
|
337
|
-
sub: (callback: QuorumMessageCallback, options?: SubscriptionOptions) => Promise<void>;
|
|
338
|
-
/**
|
|
339
|
-
* publishes a message to the mesh control plane
|
|
340
|
-
* @param {QuorumMessage} message - the message payload
|
|
341
|
-
* @param {SubscriptionOptions} options - connection options
|
|
342
|
-
* @returns {Promise<void>}
|
|
343
|
-
*/
|
|
344
|
-
pub: (message: QuorumMessage, options?: SubscriptionOptions) => Promise<void>;
|
|
345
|
-
/**
|
|
346
|
-
* unsubscribes from the mesh control plane
|
|
347
|
-
* @param {QuorumMessageCallback} callback - the callback function
|
|
348
|
-
* @param {SubscriptionOptions} options - connection options
|
|
349
|
-
* @returns {Promise<void>}
|
|
350
|
-
*/
|
|
351
|
-
unsub: (callback: QuorumMessageCallback, options?: SubscriptionOptions) => Promise<void>;
|
|
352
|
-
};
|
|
353
|
-
/**
|
|
354
|
-
* Connects a function to the operational data layer.
|
|
355
|
-
*
|
|
356
|
-
* @template T The expected return type of the target function.
|
|
357
|
-
*
|
|
358
|
-
* @param {object} connection - The options for connecting a function.
|
|
359
|
-
* @param {string} connection.entity - The global entity identifier for the function (e.g, 'user', 'order', 'product').
|
|
360
|
-
* @param {(...args: any[]) => T} connection.target - Function to connect, returns type T.
|
|
361
|
-
* @param {ConnectOptions} connection.options={} - Extended connection options (e.g., ttl, taskQueue). A
|
|
362
|
-
* ttl of 'infinity' will cache the function indefinitely.
|
|
363
|
-
*
|
|
364
|
-
* @returns {Promise<boolean>} True if connection is successfully established.
|
|
365
|
-
*
|
|
366
|
-
* @example
|
|
367
|
-
* // Instantiate MeshData with Redis configuration.
|
|
368
|
-
* const meshData = new MeshData({
|
|
369
|
-
* class: Redis,
|
|
370
|
-
* options: { host: 'localhost', port: 6379 }
|
|
371
|
-
* });
|
|
372
|
-
*
|
|
373
|
-
* // Define and connect a function with the 'greeting' entity.
|
|
374
|
-
* // The function will be cached indefinitely (infinite TTL).
|
|
375
|
-
* await meshData.connect({
|
|
376
|
-
* entity: 'greeting',
|
|
377
|
-
* target: (email, user) => `Hello, ${user.first}.`,
|
|
378
|
-
* options: { ttl: 'infinity' }
|
|
379
|
-
* });
|
|
380
|
-
*/
|
|
381
|
-
connect<T>({ entity, target, options, }: ConnectionInput<T>): Promise<boolean>;
|
|
382
|
-
/**
|
|
383
|
-
* During remote execution, an argument is injected (the last argument)
|
|
384
|
-
* this is then used by the 'connect' function to determine if the call
|
|
385
|
-
* is a hook or a exec call. If it is an exec, the connected function has
|
|
386
|
-
* precedence and can say that all calls are cached indefinitely.
|
|
387
|
-
*
|
|
388
|
-
* @param {any[]} args
|
|
389
|
-
* @param {StringAnyType} callOptions
|
|
390
|
-
* @returns {StringAnyType}
|
|
391
|
-
* @private
|
|
392
|
-
*/
|
|
393
|
-
bindCallOptions(args: any[], callOptions?: CallOptions): StringAnyType;
|
|
394
|
-
/**
|
|
395
|
-
* Sleeps/WaitsForSignal to keep the function open
|
|
396
|
-
* and remain part of the operational data layer
|
|
397
|
-
*
|
|
398
|
-
* @template T The expected return type of the remote function
|
|
399
|
-
*
|
|
400
|
-
* @param {string} result - the result to emit before going to sleep
|
|
401
|
-
* @param {CallOptions} options - call options
|
|
402
|
-
* @private
|
|
403
|
-
*/
|
|
404
|
-
pauseForTTL<T>(result: T, options: CallOptions): Promise<void>;
|
|
405
|
-
/**
|
|
406
|
-
* Publishes the job result, because pausing the job (in support of
|
|
407
|
-
* the 'ttl' option) interrupts the response.
|
|
408
|
-
*
|
|
409
|
-
* @template T The expected return type of the remote function
|
|
410
|
-
*
|
|
411
|
-
* @param {string} result - the result to emit before going to sleep
|
|
412
|
-
* @param {HotMesh} hotMesh - call options
|
|
413
|
-
* @param {CallOptions} options - call options
|
|
414
|
-
*
|
|
415
|
-
* @returns {Promise<void>}
|
|
416
|
-
* @private
|
|
417
|
-
*/
|
|
418
|
-
publishDone<T>(result: T, hotMesh: HotMesh, options: CallOptions): Promise<void>;
|
|
419
|
-
/**
|
|
420
|
-
* Flushes a function with a `ttl` of 'infinity'. These entities were
|
|
421
|
-
* created by a connect method that was configured with a
|
|
422
|
-
* `ttl` of 'infinity'. It can take several seconds for the function
|
|
423
|
-
* to be removed from the cache as it might be actively orchestrating
|
|
424
|
-
* sub-workflows.
|
|
425
|
-
*
|
|
426
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
427
|
-
* @param {string} id - The workflow/job id
|
|
428
|
-
* @param {string} [namespace='meshflow'] - the namespace for the client
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* // Flush a function
|
|
432
|
-
* await meshData.flush('greeting', 'jsmith123');
|
|
433
|
-
*/
|
|
434
|
-
flush(entity: string, id: string, namespace?: string): Promise<string | void>;
|
|
435
|
-
/**
|
|
436
|
-
* Interrupts a job by its entity and id. It is best not to call this
|
|
437
|
-
* method directly for entries with a ttl of `infinity` (call `flush` instead).
|
|
438
|
-
* For those entities that are cached for a specified duration (e.g., '15 minutes'),
|
|
439
|
-
* this method will interrupt the job and start the cascaded cleanup/expire/delete.
|
|
440
|
-
* As jobs are asynchronous, there is no way to stop descendant flows immediately.
|
|
441
|
-
* Use an `expire` option to keep the interrupted job in the cache for a specified
|
|
442
|
-
* duration before it is fully removed.
|
|
443
|
-
*
|
|
444
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
445
|
-
* @param {string} id - The workflow/job id
|
|
446
|
-
* @param {JobInterruptOptions} [options={}] - call options
|
|
447
|
-
* @param {string} [namespace='meshflow'] - the namespace for the client
|
|
448
|
-
*
|
|
449
|
-
* @example
|
|
450
|
-
* // Interrupt a function
|
|
451
|
-
* await meshData.interrupt('greeting', 'jsmith123');
|
|
452
|
-
*/
|
|
453
|
-
interrupt(entity: string, id: string, options?: JobInterruptOptions, namespace?: string): Promise<void>;
|
|
454
|
-
/**
|
|
455
|
-
* Signals a Hook Function or Main Function to awaken that
|
|
456
|
-
* is paused and registered to awaken upon receiving the signal
|
|
457
|
-
* matching @guid.
|
|
458
|
-
*
|
|
459
|
-
* @param {string} guid - The global identifier for the signal
|
|
460
|
-
* @param {StringAnyType} payload - The payload to send with the signal
|
|
461
|
-
* @param {string} [namespace='meshflow'] - the namespace for the client
|
|
462
|
-
* @returns {Promise<string>} - the signal id
|
|
463
|
-
* @example
|
|
464
|
-
* // Signal a function with a payload
|
|
465
|
-
* await meshData.signal('signal123', { message: 'hi!' });
|
|
466
|
-
*
|
|
467
|
-
* // returns '123456732345-0' (stream message receipt)
|
|
468
|
-
*/
|
|
469
|
-
signal(guid: string, payload: StringAnyType, namespace?: string): Promise<string>;
|
|
470
|
-
/**
|
|
471
|
-
* Sends a signal to the backend Service Mesh (workers and engines)
|
|
472
|
-
* to announce their presence, including message counts, target
|
|
473
|
-
* functions, topics, etc. This is useful for establishing
|
|
474
|
-
* the network profile and overall message throughput
|
|
475
|
-
* of the operational data layer as a unified quorum.
|
|
476
|
-
* @param {RollCallOptions} options
|
|
477
|
-
* @returns {Promise<QuorumProfile[]>}
|
|
478
|
-
*/
|
|
479
|
-
rollCall(options?: RollCallOptions): Promise<QuorumProfile[]>;
|
|
480
|
-
/**
|
|
481
|
-
* Throttles a worker or engine in the backend Service Mesh, using either
|
|
482
|
-
* a 'guid' to target a specific worker or engine, or a 'topic' to target
|
|
483
|
-
* a group of worker(s) connected to that topic. The throttle value is
|
|
484
|
-
* specified in milliseconds and will cause the target(s) to delay consuming
|
|
485
|
-
* the next message by this amount. By default, the value is set to `0`.
|
|
486
|
-
* @param {ThrottleOptions} options
|
|
487
|
-
* @returns {Promise<boolean>}
|
|
488
|
-
*
|
|
489
|
-
* @example
|
|
490
|
-
* // Throttle a worker or engine
|
|
491
|
-
* await meshData.throttle({ guid: '1234567890', throttle: 10_000 });
|
|
492
|
-
*/
|
|
493
|
-
throttle(options: ThrottleOptions): Promise<boolean>;
|
|
494
|
-
/**
|
|
495
|
-
* Similar to `exec`, except it augments the workflow state without creating a new job.
|
|
496
|
-
*
|
|
497
|
-
* @param {object} input - The input parameters for hooking a function.
|
|
498
|
-
* @param {string} input.entity - The target entity name (e.g., 'user', 'order', 'product').
|
|
499
|
-
* @param {string} input.id - The target execution/workflow/job id.
|
|
500
|
-
* @param {string} input.hookEntity - The hook entity name (e.g, 'user.notification').
|
|
501
|
-
* @param {any[]} input.hookArgs - The arguments for the hook function; must be JSON serializable.
|
|
502
|
-
* @param {HookOptions} input.options={} - Extended hook options (taskQueue, namespace, etc).
|
|
503
|
-
* @returns {Promise<string>} The signal id.
|
|
504
|
-
*
|
|
505
|
-
* @example
|
|
506
|
-
* // Hook a function
|
|
507
|
-
* const signalId = await meshData.hook({
|
|
508
|
-
* entity: 'greeting',
|
|
509
|
-
* id: 'jsmith123',
|
|
510
|
-
* hookEntity: 'greeting.newsletter',
|
|
511
|
-
* hookArgs: ['xxxx@xxxxx'],
|
|
512
|
-
* options: {}
|
|
513
|
-
* });
|
|
514
|
-
*/
|
|
515
|
-
hook({ entity, id, hookEntity, hookArgs, options, }: HookInput): Promise<string>;
|
|
516
|
-
/**
|
|
517
|
-
* Executes a remote function by its global entity identifier with specified arguments.
|
|
518
|
-
* If options.ttl is infinity, the function will be cached indefinitely and can only be
|
|
519
|
-
* removed by calling `flush`. During this time, the function will remain active and
|
|
520
|
-
* its state can be augmented by calling `set`, `incr`, `del`, etc OR by calling a
|
|
521
|
-
* transactional 'hook' function.
|
|
522
|
-
*
|
|
523
|
-
* @template T The expected return type of the remote function.
|
|
524
|
-
*
|
|
525
|
-
* @param {object} input - The execution parameters.
|
|
526
|
-
* @param {string} input.entity - The function entity name (e.g., 'user', 'order', 'user.bill').
|
|
527
|
-
* @param {any[]} input.args - The arguments for the remote function.
|
|
528
|
-
* @param {CallOptions} input.options={} - Extended configuration options for execution (e.g, taskQueue).
|
|
529
|
-
*
|
|
530
|
-
* @returns {Promise<T>} A promise that resolves with the result of the remote function execution. If
|
|
531
|
-
* the input options include `await: false`, the promise will resolve with the
|
|
532
|
-
* workflow ID (string) instead of the result. Make sure to pass string as the
|
|
533
|
-
* return type if you are using `await: false`.
|
|
534
|
-
*
|
|
535
|
-
* @example
|
|
536
|
-
* // Invoke a remote function with arguments and options
|
|
537
|
-
* const response = await meshData.exec({
|
|
538
|
-
* entity: 'greeting',
|
|
539
|
-
* args: ['jsmith@hotmesh', { first: 'Jan' }],
|
|
540
|
-
* options: { ttl: '15 minutes', id: 'jsmith123' }
|
|
541
|
-
* });
|
|
542
|
-
*/
|
|
543
|
-
exec<T>({ entity, args, options }: ExecInput): Promise<T>;
|
|
544
|
-
/**
|
|
545
|
-
* Retrieves the job profile for the function execution, including metadata such as
|
|
546
|
-
* execution status and result.
|
|
547
|
-
*
|
|
548
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
549
|
-
* @param {string} id - identifier for the job
|
|
550
|
-
* @param {CallOptions} [options={}] - Configuration options for the execution,
|
|
551
|
-
* including custom IDs, time-to-live (TTL) settings, etc.
|
|
552
|
-
* Defaults to an empty object if not provided.
|
|
553
|
-
*
|
|
554
|
-
* @returns {Promise<JobOutput>} A promise that resolves with the job's output, which
|
|
555
|
-
* includes metadata about the job's execution status. The
|
|
556
|
-
* structure of `JobOutput` should contain all relevant
|
|
557
|
-
* information such as execution result, status, and any
|
|
558
|
-
* error messages if the job failed.
|
|
559
|
-
*
|
|
560
|
-
* @example
|
|
561
|
-
* // Retrieve information about a remote function's execution by job ID
|
|
562
|
-
* const jobInfoById = await meshData.info('greeting', 'job-12345');
|
|
563
|
-
*
|
|
564
|
-
* // Response: JobOutput
|
|
565
|
-
* {
|
|
566
|
-
* metadata: {
|
|
567
|
-
* tpc: 'meshflow.execute',
|
|
568
|
-
* app: 'meshflow',
|
|
569
|
-
* vrs: '1',
|
|
570
|
-
* jid: 'greeting-jsmith123',
|
|
571
|
-
* aid: 't1',
|
|
572
|
-
* ts: '0',
|
|
573
|
-
* jc: '20240208014803.980',
|
|
574
|
-
* ju: '20240208065017.762',
|
|
575
|
-
* js: 0
|
|
576
|
-
* },
|
|
577
|
-
* data: {
|
|
578
|
-
* done: true,
|
|
579
|
-
* response: 'Hello, Jan. Your email is [jsmith@hotmesh.com].',
|
|
580
|
-
* workflowId: 'greeting-jsmith123'
|
|
581
|
-
* }
|
|
582
|
-
* }
|
|
583
|
-
*/
|
|
584
|
-
info(entity: string, id: string, options?: CallOptions): Promise<JobOutput>;
|
|
585
|
-
/**
|
|
586
|
-
* Exports the job profile for the function execution, including
|
|
587
|
-
* all state, process, and timeline data. The information in the export
|
|
588
|
-
* is sufficient to capture the full state of the function in the moment
|
|
589
|
-
* and over time.
|
|
590
|
-
*
|
|
591
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
592
|
-
* @param {string} id - The workflow/job id
|
|
593
|
-
* @param {ExportOptions} [options={}] - Configuration options for the export
|
|
594
|
-
* @param {string} [namespace='meshflow'] - the namespace for the client
|
|
595
|
-
*
|
|
596
|
-
* @example
|
|
597
|
-
* // Export a function
|
|
598
|
-
* await meshData.export('greeting', 'jsmith123');
|
|
599
|
-
*/
|
|
600
|
-
export(entity: string, id: string, options?: ExportOptions, namespace?: string): Promise<MeshFlowJobExport>;
|
|
601
|
-
/**
|
|
602
|
-
* Returns the remote function state. this is different than the function response
|
|
603
|
-
* returned by the `exec` method which represents the return value from the
|
|
604
|
-
* function at the moment it completed. Instead, function state represents
|
|
605
|
-
* mutable shared state that can be set:
|
|
606
|
-
* 1) when the record is first created (provide `options.search.data` to `exec`)
|
|
607
|
-
* 2) during function execution ((await MeshData.workflow.search()).set(...))
|
|
608
|
-
* 3) during hook execution ((await MeshData.workflow.search()).set(...))
|
|
609
|
-
* 4) via the meshData SDK (`meshData.set(...)`)
|
|
610
|
-
*
|
|
611
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
612
|
-
* @param {string} id - the job id
|
|
613
|
-
* @param {CallOptions} [options={}] - call options
|
|
614
|
-
*
|
|
615
|
-
* @returns {Promise<StringAnyType>} - the function state
|
|
616
|
-
*
|
|
617
|
-
* @example
|
|
618
|
-
* // get the state of a function
|
|
619
|
-
* const state = await meshData.get('greeting', 'jsmith123', { fields: ['fred', 'barney'] });
|
|
620
|
-
*
|
|
621
|
-
* // returns { fred: 'flintstone', barney: 'rubble' }
|
|
622
|
-
*/
|
|
623
|
-
get(entity: string, id: string, options?: CallOptions): Promise<StringAnyType>;
|
|
624
|
-
/**
|
|
625
|
-
* Returns the remote function state for all fields. NOTE:
|
|
626
|
-
* `all` can be less efficient than calling `get` as it returns all
|
|
627
|
-
* fields (HGETALL), not just the ones requested (HMGET). Depending
|
|
628
|
-
* upon the duration of the workflow, this could represent a large
|
|
629
|
-
* amount of process/history data.
|
|
630
|
-
*
|
|
631
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
632
|
-
* @param {string} id - the workflow/job id
|
|
633
|
-
* @param {CallOptions} [options={}] - call options
|
|
634
|
-
*
|
|
635
|
-
* @returns {Promise<StringAnyType>} - the function state
|
|
636
|
-
*
|
|
637
|
-
* @example
|
|
638
|
-
* // get the state of the job (this is not the response...this is job state)
|
|
639
|
-
* const state = await meshData.all('greeting', 'jsmith123');
|
|
640
|
-
*
|
|
641
|
-
* // returns { fred: 'flintstone', barney: 'rubble', ... }
|
|
642
|
-
*/
|
|
643
|
-
all(entity: string, id: string, options?: CallOptions): Promise<StringAnyType>;
|
|
644
|
-
/**
|
|
645
|
-
* Returns all fields in the HASH record:
|
|
646
|
-
*
|
|
647
|
-
* 1) `:`: workflow status (a semaphore where `0` is complete)
|
|
648
|
-
* 2) `_*`: function state (name/value pairs are prefixed with `_`)
|
|
649
|
-
* 3) `-*`: workflow cycle state (cycles are prefixed with `-`)
|
|
650
|
-
* 4) `[a-zA-Z]{3}`: mutable workflow job state
|
|
651
|
-
* 5) `[a-zA-Z]{3}[,\d]+`: immutable workflow activity state
|
|
652
|
-
*
|
|
653
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
654
|
-
* @param {string} id - the workflow/job id
|
|
655
|
-
* @param {CallOptions} [options={}] - call options
|
|
656
|
-
*
|
|
657
|
-
* @returns {Promise<StringAnyType>} - the function state
|
|
658
|
-
*
|
|
659
|
-
* @example
|
|
660
|
-
* // get the state of a function
|
|
661
|
-
* const state = await meshData.raw('greeting', 'jsmith123');
|
|
662
|
-
*
|
|
663
|
-
* // returns { : '0', _barney: 'rubble', aBa: 'Hello, John Doe. Your email is [jsmith@hotmesh].', ... }
|
|
664
|
-
*/
|
|
665
|
-
raw(entity: string, id: string, options?: CallOptions): Promise<StringAnyType>;
|
|
666
|
-
/**
|
|
667
|
-
* Sets the remote function state. this is different than the function response
|
|
668
|
-
* returned by the exec method which represents the return value from the
|
|
669
|
-
* function at the moment it completed. Instead, function state represents
|
|
670
|
-
* mutable shared state that can be set
|
|
671
|
-
*
|
|
672
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
673
|
-
* @param {string} id - the job id
|
|
674
|
-
* @param {CallOptions} [options={}] - call options
|
|
675
|
-
*
|
|
676
|
-
* @returns {Promise<number>} - count. The number inserted (Postgres) / updated(Redis)
|
|
677
|
-
* @example
|
|
678
|
-
* // set the state of a function
|
|
679
|
-
* const count = await meshData.set('greeting', 'jsmith123', { search: { data: { fred: 'flintstone', barney: 'rubble' } } });
|
|
680
|
-
*/
|
|
681
|
-
set(entity: string, id: string, options?: CallOptions): Promise<number>;
|
|
682
|
-
/**
|
|
683
|
-
* Increments a field in the remote function state.
|
|
684
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
685
|
-
* @param {string} id - the job id
|
|
686
|
-
* @param {string} field - the field name
|
|
687
|
-
* @param {number} amount - the amount to increment
|
|
688
|
-
* @param {CallOptions} [options={}] - call options
|
|
689
|
-
*
|
|
690
|
-
* @returns {Promise<number>} - the new value
|
|
691
|
-
* @example
|
|
692
|
-
* // increment a field in the function state
|
|
693
|
-
* const count = await meshData.incr('greeting', 'jsmith123', 'counter', 1);
|
|
694
|
-
*/
|
|
695
|
-
incr(entity: string, id: string, field: string, amount: number, options?: CallOptions): Promise<number>;
|
|
696
|
-
/**
|
|
697
|
-
* Deletes one or more fields from the remote function state.
|
|
698
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
699
|
-
* @param {string} id - the job id
|
|
700
|
-
* @param {CallOptions} [options={}] - call options
|
|
701
|
-
*
|
|
702
|
-
* @returns {Promise<number>} - the count of fields deleted
|
|
703
|
-
* @example
|
|
704
|
-
* // remove two hash fields from the function state
|
|
705
|
-
* const count = await meshData.del('greeting', 'jsmith123', { fields: ['fred', 'barney'] });
|
|
706
|
-
*/
|
|
707
|
-
del(entity: string, id: string, options: CallOptions): Promise<number>;
|
|
708
|
-
/**
|
|
709
|
-
* For those implementations without a search backend, this quasi-equivalent
|
|
710
|
-
* method is provided with a cursor for rudimentary pagination.
|
|
711
|
-
* @param {FindJobsOptions} [options]
|
|
712
|
-
* @returns {Promise<[string, string[]]>}
|
|
713
|
-
* @example
|
|
714
|
-
* // find jobs
|
|
715
|
-
* const [cursor, jobs] = await meshData.findJobs({ match: 'greeting*' });
|
|
716
|
-
*
|
|
717
|
-
* // returns [ '0', [ 'hmsh:meshflow:j:greeting-jsmith123', 'hmsh:meshflow:j:greeting-jdoe456' ] ]
|
|
718
|
-
*/
|
|
719
|
-
findJobs(options?: FindJobsOptions): Promise<[string, string[]]>;
|
|
720
|
-
/**
|
|
721
|
-
* Executes the search query; optionally specify other commands
|
|
722
|
-
* @example '@_quantity:[89 89]'
|
|
723
|
-
* @example '@_quantity:[89 89] @_name:"John"'
|
|
724
|
-
* @example 'FT.search my-index @_quantity:[89 89]'
|
|
725
|
-
* @param {FindOptions} options
|
|
726
|
-
* @param {any[]} args
|
|
727
|
-
* @returns {Promise<string[] | [number] | Array<number, string | number | string[]>>}
|
|
728
|
-
*/
|
|
729
|
-
find(entity: string, options: FindOptions, ...args: string[]): Promise<string[] | [number] | Array<string | number | string[]>>;
|
|
730
|
-
/**
|
|
731
|
-
* Provides a JSON abstraction for the backend search engine
|
|
732
|
-
* (e.g, `count`, `query`, `return`, `limit`)
|
|
733
|
-
* NOTE: If the type is TAG for an entity, `.`, `@`, and `-` must be escaped.
|
|
734
|
-
*
|
|
735
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
736
|
-
* @param {FindWhereOptions} options - find options (the query). A custom search schema may be provided.
|
|
737
|
-
* @returns {Promise<SearchResults | number>} Returns a number if `count` is true, otherwise a SearchResults object.
|
|
738
|
-
* @example
|
|
739
|
-
* const results = await meshData.findWhere('greeting', {
|
|
740
|
-
* query: [
|
|
741
|
-
* { field: 'name', is: '=', value: 'John' },
|
|
742
|
-
* { field: 'age', is: '>', value: 2 },
|
|
743
|
-
* { field: 'quantity', is: '[]', value: [89, 89] }
|
|
744
|
-
* ],
|
|
745
|
-
* count: false,
|
|
746
|
-
* limit: { start: 0, size: 10 },
|
|
747
|
-
* return: ['name', 'quantity']
|
|
748
|
-
* });
|
|
749
|
-
*
|
|
750
|
-
* // returns { count: 1, query: 'FT.SEARCH my-index @_name:"John" @_age:[2 +inf] @_quantity:[89 89] LIMIT 0 10', data: [ { name: 'John', quantity: '89' } ] }
|
|
751
|
-
*/
|
|
752
|
-
findWhere(entity: string, options: FindWhereOptions): Promise<SearchResults | number>;
|
|
753
|
-
/**
|
|
754
|
-
* Generates a search query from a FindWhereQuery array
|
|
755
|
-
* @param {FindWhereQuery[] | string} [query]
|
|
756
|
-
* @param {WorkflowSearchOptions} [search]
|
|
757
|
-
* @returns {string}
|
|
758
|
-
* @private
|
|
759
|
-
*/
|
|
760
|
-
generateSearchQuery(query: FindWhereQuery[] | string, search?: WorkflowSearchOptions): string;
|
|
761
|
-
/**
|
|
762
|
-
* Creates a search index for the specified search backend (e.g., FT.search).
|
|
763
|
-
* @param {string} entity - the entity name (e.g, 'user', 'order', 'product')
|
|
764
|
-
* @param {CallOptions} [options={}] - call options
|
|
765
|
-
* @param {WorkflowSearchOptions} [searchOptions] - search options
|
|
766
|
-
* @returns {Promise<string>} - the search index name
|
|
767
|
-
* @example
|
|
768
|
-
* // create a search index for the 'greeting' entity. pass in search options.
|
|
769
|
-
* const index = await meshData.createSearchIndex('greeting', {}, { prefix: 'greeting', ... });
|
|
770
|
-
*
|
|
771
|
-
* // creates a search index for the 'greeting' entity, using the default search options.
|
|
772
|
-
* const index = await meshData.createSearchIndex('greeting');
|
|
773
|
-
*/
|
|
774
|
-
createSearchIndex(entity: string, options?: CallOptions, searchOptions?: WorkflowSearchOptions): Promise<void>;
|
|
775
|
-
/**
|
|
776
|
-
* Lists all search indexes in the operational data layer when the
|
|
777
|
-
* targeted search backend is configured/enabled.
|
|
778
|
-
* @returns {Promise<string[]>}
|
|
779
|
-
* @example
|
|
780
|
-
* // list all search indexes
|
|
781
|
-
* const indexes = await meshData.listSearchIndexes();
|
|
782
|
-
*
|
|
783
|
-
* // returns ['greeting', 'user', 'order', 'product']
|
|
784
|
-
*/
|
|
785
|
-
listSearchIndexes(): Promise<string[]>;
|
|
786
|
-
/**
|
|
787
|
-
* Wrap activities in a proxy that will durably run them, once.
|
|
788
|
-
*/
|
|
789
|
-
static proxyActivities: typeof import("../..").proxyActivities;
|
|
790
|
-
/**
|
|
791
|
-
* shut down MeshData (typically on sigint or sigterm)
|
|
792
|
-
*/
|
|
793
|
-
static shutdown(): Promise<void>;
|
|
794
|
-
}
|
|
795
|
-
export { MeshData };
|