@hotmeshio/hotmesh 0.3.32 → 0.4.1

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.
Files changed (207) hide show
  1. package/README.md +128 -823
  2. package/build/index.d.ts +9 -9
  3. package/build/index.js +10 -10
  4. package/build/modules/enums.d.ts +23 -23
  5. package/build/modules/enums.js +26 -26
  6. package/build/modules/errors.d.ts +16 -16
  7. package/build/modules/errors.js +28 -28
  8. package/build/modules/key.js +190 -1
  9. package/build/modules/utils.js +374 -1
  10. package/build/package.json +22 -21
  11. package/build/services/activities/activity.js +549 -1
  12. package/build/services/activities/await.js +114 -1
  13. package/build/services/activities/cycle.js +112 -1
  14. package/build/services/activities/hook.js +168 -1
  15. package/build/services/activities/index.js +20 -1
  16. package/build/services/activities/interrupt.js +158 -1
  17. package/build/services/activities/signal.js +134 -1
  18. package/build/services/activities/trigger.js +246 -1
  19. package/build/services/activities/worker.js +106 -1
  20. package/build/services/collator/index.js +293 -1
  21. package/build/services/compiler/deployer.js +488 -1
  22. package/build/services/compiler/index.js +112 -1
  23. package/build/services/compiler/validator.js +147 -1
  24. package/build/services/engine/index.js +761 -1
  25. package/build/services/exporter/index.js +126 -1
  26. package/build/services/hotmesh/index.d.ts +160 -17
  27. package/build/services/hotmesh/index.js +160 -17
  28. package/build/services/mapper/index.js +81 -1
  29. package/build/services/{meshflow → memflow}/client.d.ts +3 -3
  30. package/build/services/{meshflow → memflow}/client.js +17 -16
  31. package/build/services/{meshflow → memflow}/connection.d.ts +2 -2
  32. package/build/services/{meshflow → memflow}/connection.js +1 -1
  33. package/build/services/memflow/context.d.ts +143 -0
  34. package/build/services/memflow/context.js +299 -0
  35. package/build/services/{meshflow → memflow}/exporter.d.ts +6 -6
  36. package/build/services/memflow/exporter.js +215 -0
  37. package/build/services/{meshflow → memflow}/handle.d.ts +4 -4
  38. package/build/services/{meshflow → memflow}/handle.js +2 -2
  39. package/build/services/{meshflow → memflow}/index.d.ts +18 -13
  40. package/build/services/{meshflow → memflow}/index.js +26 -21
  41. package/build/services/{meshflow → memflow}/schemas/factory.d.ts +4 -4
  42. package/build/services/{meshflow → memflow}/schemas/factory.js +5 -5
  43. package/build/services/{meshflow → memflow}/search.d.ts +1 -1
  44. package/build/services/{meshflow → memflow}/search.js +4 -4
  45. package/build/services/{meshflow → memflow}/worker.d.ts +5 -5
  46. package/build/services/{meshflow → memflow}/worker.js +24 -24
  47. package/build/services/memflow/workflow/common.d.ts +20 -0
  48. package/build/services/memflow/workflow/common.js +47 -0
  49. package/build/services/memflow/workflow/contextMethods.d.ts +14 -0
  50. package/build/services/memflow/workflow/contextMethods.js +33 -0
  51. package/build/services/{meshflow → memflow}/workflow/execChild.js +12 -12
  52. package/build/services/memflow/workflow/execHook.d.ts +65 -0
  53. package/build/services/memflow/workflow/execHook.js +73 -0
  54. package/build/services/{meshflow → memflow}/workflow/hook.js +19 -3
  55. package/build/services/{meshflow → memflow}/workflow/index.d.ts +7 -3
  56. package/build/services/{meshflow → memflow}/workflow/index.js +7 -3
  57. package/build/services/{meshflow → memflow}/workflow/proxyActivities.d.ts +2 -2
  58. package/build/services/{meshflow → memflow}/workflow/proxyActivities.js +8 -8
  59. package/build/services/{meshflow → memflow}/workflow/sleepFor.js +2 -2
  60. package/build/services/{meshflow → memflow}/workflow/waitFor.js +2 -2
  61. package/build/services/meshdata/index.d.ts +24 -24
  62. package/build/services/meshdata/index.js +40 -40
  63. package/build/services/pipe/functions/array.js +74 -1
  64. package/build/services/pipe/functions/bitwise.js +24 -1
  65. package/build/services/pipe/functions/conditional.js +36 -1
  66. package/build/services/pipe/functions/cron.js +40 -1
  67. package/build/services/pipe/functions/date.js +171 -1
  68. package/build/services/pipe/functions/index.js +30 -1
  69. package/build/services/pipe/functions/json.js +12 -1
  70. package/build/services/pipe/functions/logical.js +12 -1
  71. package/build/services/pipe/functions/math.js +184 -1
  72. package/build/services/pipe/functions/number.js +60 -1
  73. package/build/services/pipe/functions/object.js +81 -1
  74. package/build/services/pipe/functions/string.js +69 -1
  75. package/build/services/pipe/functions/symbol.js +33 -1
  76. package/build/services/pipe/functions/unary.js +18 -1
  77. package/build/services/pipe/index.js +242 -1
  78. package/build/services/quorum/index.js +263 -1
  79. package/build/services/reporter/index.js +348 -1
  80. package/build/services/router/config/index.d.ts +11 -0
  81. package/build/services/router/config/index.js +36 -0
  82. package/build/services/router/consumption/index.d.ts +34 -0
  83. package/build/services/router/consumption/index.js +395 -0
  84. package/build/services/router/error-handling/index.d.ts +8 -0
  85. package/build/services/router/error-handling/index.js +98 -0
  86. package/build/services/router/index.d.ts +13 -16
  87. package/build/services/router/index.js +121 -1
  88. package/build/services/router/lifecycle/index.d.ts +27 -0
  89. package/build/services/router/lifecycle/index.js +80 -0
  90. package/build/services/router/telemetry/index.d.ts +11 -0
  91. package/build/services/router/telemetry/index.js +32 -0
  92. package/build/services/router/throttling/index.d.ts +23 -0
  93. package/build/services/router/throttling/index.js +76 -0
  94. package/build/services/search/index.d.ts +2 -1
  95. package/build/services/search/providers/postgres/postgres.d.ts +2 -1
  96. package/build/services/search/providers/postgres/postgres.js +149 -1
  97. package/build/services/search/providers/redis/ioredis.d.ts +1 -0
  98. package/build/services/search/providers/redis/ioredis.js +121 -1
  99. package/build/services/search/providers/redis/redis.d.ts +1 -0
  100. package/build/services/search/providers/redis/redis.js +134 -1
  101. package/build/services/serializer/index.js +282 -1
  102. package/build/services/store/providers/postgres/kvsql.d.ts +1 -1
  103. package/build/services/store/providers/postgres/kvsql.js +198 -1
  104. package/build/services/store/providers/postgres/kvtables.js +441 -1
  105. package/build/services/store/providers/postgres/kvtransaction.js +248 -1
  106. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +1 -1
  107. package/build/services/store/providers/postgres/kvtypes/hash.js +1287 -1
  108. package/build/services/store/providers/postgres/kvtypes/list.js +194 -1
  109. package/build/services/store/providers/postgres/kvtypes/string.js +115 -1
  110. package/build/services/store/providers/postgres/kvtypes/zset.js +214 -1
  111. package/build/services/store/providers/postgres/postgres.js +1036 -1
  112. package/build/services/store/providers/redis/_base.js +980 -1
  113. package/build/services/store/providers/redis/ioredis.js +180 -1
  114. package/build/services/store/providers/redis/redis.js +199 -1
  115. package/build/services/store/providers/store-initializable.js +2 -1
  116. package/build/services/stream/index.d.ts +5 -0
  117. package/build/services/stream/providers/nats/nats.d.ts +1 -0
  118. package/build/services/stream/providers/nats/nats.js +225 -1
  119. package/build/services/stream/providers/postgres/kvtables.d.ts +1 -0
  120. package/build/services/stream/providers/postgres/kvtables.js +146 -1
  121. package/build/services/stream/providers/postgres/postgres.d.ts +19 -0
  122. package/build/services/stream/providers/postgres/postgres.js +519 -1
  123. package/build/services/stream/providers/redis/ioredis.d.ts +1 -0
  124. package/build/services/stream/providers/redis/ioredis.js +272 -1
  125. package/build/services/stream/providers/redis/redis.d.ts +1 -0
  126. package/build/services/stream/providers/redis/redis.js +305 -1
  127. package/build/services/stream/providers/stream-initializable.js +2 -1
  128. package/build/services/sub/providers/nats/nats.js +105 -1
  129. package/build/services/sub/providers/postgres/postgres.js +92 -1
  130. package/build/services/sub/providers/redis/ioredis.js +81 -1
  131. package/build/services/sub/providers/redis/redis.js +72 -1
  132. package/build/services/task/index.js +206 -1
  133. package/build/services/telemetry/index.js +306 -1
  134. package/build/services/worker/index.js +197 -1
  135. package/build/types/error.d.ts +5 -5
  136. package/build/types/exporter.d.ts +1 -1
  137. package/build/types/index.d.ts +3 -3
  138. package/build/types/manifest.d.ts +2 -2
  139. package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
  140. package/build/types/meshdata.d.ts +3 -3
  141. package/build/types/postgres.d.ts +7 -0
  142. package/build/types/stream.d.ts +3 -0
  143. package/index.ts +11 -11
  144. package/package.json +22 -21
  145. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  146. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  147. package/build/services/meshflow/exporter.js +0 -1
  148. package/build/services/meshflow/workflow/common.d.ts +0 -18
  149. package/build/services/meshflow/workflow/common.js +0 -45
  150. package/typedoc.json +0 -46
  151. package/types/activity.ts +0 -268
  152. package/types/app.ts +0 -20
  153. package/types/async.ts +0 -6
  154. package/types/cache.ts +0 -1
  155. package/types/collator.ts +0 -9
  156. package/types/error.ts +0 -56
  157. package/types/exporter.ts +0 -102
  158. package/types/hook.ts +0 -44
  159. package/types/hotmesh.ts +0 -314
  160. package/types/index.ts +0 -306
  161. package/types/job.ts +0 -233
  162. package/types/logger.ts +0 -8
  163. package/types/manifest.ts +0 -70
  164. package/types/map.ts +0 -5
  165. package/types/meshcall.ts +0 -235
  166. package/types/meshdata.ts +0 -278
  167. package/types/meshflow.ts +0 -645
  168. package/types/ms.d.ts +0 -7
  169. package/types/nats.ts +0 -270
  170. package/types/pipe.ts +0 -90
  171. package/types/postgres.ts +0 -105
  172. package/types/provider.ts +0 -161
  173. package/types/quorum.ts +0 -167
  174. package/types/redis.ts +0 -404
  175. package/types/serializer.ts +0 -40
  176. package/types/stats.ts +0 -117
  177. package/types/stream.ts +0 -227
  178. package/types/task.ts +0 -7
  179. package/types/telemetry.ts +0 -16
  180. package/types/transition.ts +0 -20
  181. /package/build/services/{meshflow → memflow}/workflow/all.d.ts +0 -0
  182. /package/build/services/{meshflow → memflow}/workflow/all.js +0 -0
  183. /package/build/services/{meshflow → memflow}/workflow/context.d.ts +0 -0
  184. /package/build/services/{meshflow → memflow}/workflow/context.js +0 -0
  185. /package/build/services/{meshflow → memflow}/workflow/didRun.d.ts +0 -0
  186. /package/build/services/{meshflow → memflow}/workflow/didRun.js +0 -0
  187. /package/build/services/{meshflow → memflow}/workflow/emit.d.ts +0 -0
  188. /package/build/services/{meshflow → memflow}/workflow/emit.js +0 -0
  189. /package/build/services/{meshflow → memflow}/workflow/enrich.d.ts +0 -0
  190. /package/build/services/{meshflow → memflow}/workflow/enrich.js +0 -0
  191. /package/build/services/{meshflow → memflow}/workflow/execChild.d.ts +0 -0
  192. /package/build/services/{meshflow → memflow}/workflow/hook.d.ts +0 -0
  193. /package/build/services/{meshflow → memflow}/workflow/interrupt.d.ts +0 -0
  194. /package/build/services/{meshflow → memflow}/workflow/interrupt.js +0 -0
  195. /package/build/services/{meshflow → memflow}/workflow/isSideEffectAllowed.d.ts +0 -0
  196. /package/build/services/{meshflow → memflow}/workflow/isSideEffectAllowed.js +0 -0
  197. /package/build/services/{meshflow → memflow}/workflow/random.d.ts +0 -0
  198. /package/build/services/{meshflow → memflow}/workflow/random.js +0 -0
  199. /package/build/services/{meshflow → memflow}/workflow/searchMethods.d.ts +0 -0
  200. /package/build/services/{meshflow → memflow}/workflow/searchMethods.js +0 -0
  201. /package/build/services/{meshflow → memflow}/workflow/signal.d.ts +0 -0
  202. /package/build/services/{meshflow → memflow}/workflow/signal.js +0 -0
  203. /package/build/services/{meshflow → memflow}/workflow/sleepFor.d.ts +0 -0
  204. /package/build/services/{meshflow → memflow}/workflow/trace.d.ts +0 -0
  205. /package/build/services/{meshflow → memflow}/workflow/trace.js +0 -0
  206. /package/build/services/{meshflow → memflow}/workflow/waitFor.d.ts +0 -0
  207. /package/build/types/{meshflow.js → memflow.js} +0 -0
package/types/meshflow.ts DELETED
@@ -1,645 +0,0 @@
1
- import { WorkflowHandleService } from '../services/meshflow/handle';
2
-
3
- import { LogLevel } from './logger';
4
- import { ProviderConfig, ProvidersConfig } from './provider';
5
- import { StringAnyType, StringStringType } from './serializer';
6
- import { StreamData, StreamError } from './stream';
7
-
8
- /**
9
- * Type definition for workflow configuration.
10
- */
11
- type WorkflowConfig = {
12
- /**
13
- * Backoff coefficient for retry mechanism.
14
- * @default 10 (HMSH_MESHFLOW_EXP_BACKOFF)
15
- */
16
- backoffCoefficient?: number;
17
-
18
- /**
19
- * Maximum number of attempts for retries.
20
- * @default 5 (HMSH_MESHFLOW_MAX_ATTEMPTS)
21
- */
22
- maximumAttempts?: number;
23
-
24
- /**
25
- * Maximum interval between retries.
26
- * @default 120s (HMSH_MESHFLOW_MAX_INTERVAL)
27
- */
28
- maximumInterval?: string;
29
-
30
- /**
31
- * Whether to throw an error on final failure after retries are exhausted
32
- * or return the error object as a standard response containing error-related
33
- * fields like `stack`, `code`, `message`.
34
- * @default true
35
- */
36
- throwOnError?: boolean;
37
- };
38
-
39
- type WorkflowContext = {
40
- /**
41
- * can the workflow be retried if an error occurs
42
- */
43
- canRetry: boolean;
44
-
45
- COUNTER: {
46
- /**
47
- * the reentrant semaphore parent counter object for object reference during increment
48
- */
49
- counter: number;
50
- };
51
-
52
- /**
53
- * the reentrant semaphore, incremented in real-time as idempotent statements are re-traversed upon reentry. Indicates the current semaphore count.
54
- */
55
- counter: number;
56
-
57
- /**
58
- * number as string for the replay cursor
59
- */
60
- cursor: string;
61
-
62
- /**
63
- * the replay hash of name/value pairs representing prior executions
64
- */
65
- replay: StringStringType;
66
-
67
- /**
68
- * the HotMesh App namespace
69
- * @default meshflow
70
- */
71
- namespace: string;
72
-
73
- /**
74
- * holds list of interruption payloads; if list is longer than 1 when the error is thrown, a `collator` subflow will be used
75
- */
76
- interruptionRegistry: any[];
77
-
78
- /**
79
- * entry point ancestor flow; might be the parent; will never be self
80
- */
81
- originJobId: string;
82
-
83
- /**
84
- * the workflow/job ID
85
- */
86
- workflowId: string;
87
-
88
- /**
89
- * the dimensional isolation for the reentrant hook, expressed in the format `0,0`, `0,1`, etc
90
- */
91
- workflowDimension: string;
92
-
93
- /**
94
- * a concatenation of the task queue and workflow name (e.g., `${taskQueueName}-${workflowName}`)
95
- */
96
- workflowTopic: string;
97
-
98
- /**
99
- * the open telemetry trace context for the workflow, used for logging and tracing. If a sink is enabled, this will be sent to the sink.
100
- */
101
- workflowTrace: string;
102
-
103
- /**
104
- * the open telemetry span context for the workflow, used for logging and tracing. If a sink is enabled, this will be sent to the sink.
105
- */
106
- workflowSpan: string;
107
-
108
- /**
109
- * the native HotMesh message that encapsulates the arguments, metadata, and raw data for the workflow
110
- */
111
- raw: StreamData;
112
-
113
- /**
114
- * the HotMesh connection configuration (io/redis NPM package reference and login credentials)
115
- */
116
- connection: Connection;
117
-
118
- /**
119
- * if present, the workflow will delay expiration for the specified number of seconds
120
- */
121
- expire?: number;
122
- };
123
-
124
- /**
125
- * The schema for the full-text-search (RediSearch) index.
126
- */
127
- export type WorkflowSearchSchema = Record<
128
- string,
129
- {
130
- /**
131
- * The FT.SEARCH field type. One of: TEXT, NUMERIC, TAG. TEXT is
132
- * most expensive, but also most expressive.
133
- */
134
- type: 'TEXT' | 'NUMERIC' | 'TAG';
135
-
136
- /**
137
- * FT.SEARCH SORTABLE field. If true, results may be sorted according to this field
138
- * @default false
139
- */
140
- sortable?: boolean;
141
-
142
- /**
143
- * FT.SEARCH NOSTEM field. applies to TEXT fields types.
144
- * If true, the text field index will not stem words
145
- * @default false
146
- */
147
- nostem?: boolean;
148
-
149
- /**
150
- * FT.SEARCH NOINDEX field. If true and if the field is sortable, the field will aid
151
- * in sorting results but not be directly indexed as a standalone
152
- * @default false
153
- */
154
- noindex?: boolean;
155
-
156
- /**
157
- * if true, the field is indexed and searchable within the FT.SEARCH index
158
- * This is different from `noindex` which is FT.SEARCH specific and relates
159
- * to sorting and indexing. This is a general flag for the field that will
160
- * enable or disable indexing and searching entirely. Use for fields with
161
- * absolutely no meaning to query or sorting but which are important
162
- * nonetheless as part of the data record that is saved and returned.
163
- * @default true
164
- */
165
- indexed?: boolean;
166
-
167
- /**
168
- * An array of possible values for the field
169
- */
170
- examples?: string[];
171
-
172
- /**
173
- * The 'nilable' setting may NOT be set to `true` for
174
- * NUMBER types as it causes an indexing error;
175
- * consider a custom (e.g., negative number) value to represent
176
- * `null` if desired for a NUMERIC field.
177
- * Set to true only if the field is a TEXT or TAG type and
178
- * you wish to save the string `null` as a value to search
179
- * on (the tag, {null}, or the string, (null)
180
- * @default false
181
- */
182
- nilable?: boolean;
183
-
184
- /**
185
- * possible scalar/primitive types for the field. Use when
186
- * serializing and restoring data to ensure the field is
187
- * properly typed. If not provided, the field will be
188
- * treated as a string.
189
- */
190
- primitive?: 'string' | 'number' | 'boolean' | 'array' | 'object';
191
-
192
- /**
193
- * if true, the field is required to be present in the data record
194
- * @default false
195
- */
196
- required?: boolean;
197
-
198
- /**
199
- * an enumerated list of allowed values; if field is nilable, it is implied
200
- * and therefore not necessary to include `null` in the list
201
- * @default []
202
- */
203
- enum?: string[];
204
-
205
- /**
206
- * a regular expression pattern for the field
207
- * @default '.*'
208
- * @example '^[a-zA-Z0-9_]*$'
209
- */
210
- pattern?: string;
211
-
212
- /**
213
- * literal value to use for the indexed field name (without including the standard underscore (_) prefix isolate)
214
- */
215
- fieldName?: string;
216
- }
217
- >;
218
-
219
- type WorkflowSearchOptions = {
220
- /** FT index name (myapp:myindex) */
221
- index?: string;
222
-
223
- /** FT prefixes (['myapp:myindex:prefix1', 'myapp:myindex:prefix2']) */
224
- prefix?: string[];
225
-
226
- /**
227
- * Schema mapping each field. Each field is a key-value pair where the key is the field name
228
- * and the value is a record of field options. If the fieldName is provided,
229
- * it will be used as the indexed field name. If not provided
230
- * key will be used as the indexed field name with an underscore prefix.
231
- *
232
- */
233
- schema?: WorkflowSearchSchema;
234
-
235
- /** Additional data as a key-value record */
236
- data?: StringStringType;
237
- };
238
-
239
- type SearchResults = {
240
- /**
241
- * the total number of results
242
- */
243
- count: number;
244
- /**
245
- * the raw FT.SEARCH query string
246
- */
247
- query: string;
248
- /**
249
- * the raw FT.SEARCH results as an array of objects
250
- */
251
- data: StringStringType[];
252
- };
253
-
254
- type WorkflowOptions = {
255
- /**
256
- * the namespace for the workflow
257
- * @default meshflow
258
- */
259
- namespace?: string;
260
-
261
- /**
262
- * the task queue for the workflow; optional if entity is provided
263
- */
264
- taskQueue?: string;
265
-
266
- /**
267
- * input arguments to pass in
268
- */
269
- args: any[];
270
-
271
- /**
272
- * the job id
273
- */
274
- workflowId?: string;
275
-
276
- /**
277
- * if invoking a workflow, passing 'entity' will apply the value as the workflowName, taskQueue, and prefix, ensuring the FT.SEARCH index is properly scoped. This is a convenience method but limits options.
278
- */
279
- entity?: string;
280
-
281
- /**
282
- * the name of the user's workflow function; optional if 'entity' is provided
283
- */
284
- workflowName?: string;
285
-
286
- /**
287
- * the parent workflow id; adjacent ancestor ID
288
- */
289
- parentWorkflowId?: string;
290
-
291
- /**
292
- * the entry point workflow id
293
- */
294
- originJobId?: string;
295
-
296
- /**
297
- * OpenTelemetry trace context for the workflow
298
- */
299
- workflowTrace?: string;
300
-
301
- /**
302
- * OpenTelemetry span context for the workflow
303
- */
304
- workflowSpan?: string;
305
-
306
- /**
307
- * the full-text-search (RediSearch) options for the workflow
308
- */
309
- search?: WorkflowSearchOptions;
310
-
311
- /**
312
- * marker data (begins with a -)
313
- */
314
- marker?: StringStringType;
315
-
316
- /**
317
- * the workflow configuration object
318
- */
319
- config?: WorkflowConfig;
320
-
321
- /**
322
- * sets the number of seconds a workflow may exist after completion. As the process engine is an in-memory cache, the default policy is to expire and scrub the job hash as soon as it completes.
323
- */
324
- expire?: number;
325
-
326
- /**
327
- * system flag to indicate that the flow should remain open beyond main method completion while still emitting the 'job done' event
328
- */
329
- persistent?: boolean;
330
-
331
- /**
332
- * default is true; set to false to optimize workflows that do not require a `signal in`
333
- */
334
- signalIn?: boolean;
335
-
336
- /**
337
- * default is true; if false, will not await the execution
338
- */
339
- await?: boolean;
340
-
341
- /**
342
- * If provided, the job will initialize in a pending state, reserving
343
- * only the job ID (HSETNX) and persisting search and marker (if provided).
344
- * If a `resume` signal is sent before the specified number of seconds,
345
- * the job will resume as normal, transitioning to the adjacent children
346
- * of the trigger. If the job is not resumed within the number
347
- * of seconds specified, the job will be scrubbed. No dependencies
348
- * are added for a job in a pending state; however, dependencies
349
- * will be added after the job is resumed if relevant.
350
- */
351
- pending?: number;
352
-
353
- /**
354
- * Provide to set the engine name. This MUST be unique, so do not
355
- * provide unless it is guaranteed to be a unique engine/worker guid
356
- * when identifying the point of presence within the mesh.
357
- */
358
- guid?: string;
359
- };
360
-
361
- /**
362
- * Options for setting up a hook.
363
- * 'meshflow' is the default namespace if not provided;
364
- * similar to setting `appid` in the YAML
365
- */
366
- type HookOptions = {
367
- /** Optional namespace under which the hook function will be grouped */
368
- namespace?: string;
369
-
370
- /** Optional task queue, needed unless 'entity' is provided */
371
- taskQueue?: string;
372
-
373
- /** Input arguments to pass into the hook */
374
- args: any[];
375
-
376
- /**
377
- * Optional entity name. If provided, applies as the workflowName,
378
- * taskQueue, and prefix. This scopes the FT.SEARCH index appropriately.
379
- * This is a convenience method but limits options.
380
- */
381
- entity?: string;
382
-
383
- /** Execution ID, also known as the job ID to hook into */
384
- workflowId?: string;
385
-
386
- /** The name of the user's hook function */
387
- workflowName?: string;
388
-
389
- /** Bind additional search terms immediately before hook reentry */
390
- search?: WorkflowSearchOptions;
391
-
392
- /** Hook function constraints (backoffCoefficient, maximumAttempts, maximumInterval) */
393
- config?: WorkflowConfig;
394
- };
395
-
396
- /**
397
- * Options for sending signals in a workflow.
398
- */
399
- type SignalOptions = {
400
- /**
401
- * Task queue associated with the workflow
402
- */
403
- taskQueue: string;
404
-
405
- /**
406
- * Input data for the signal (any serializable object)
407
- */
408
- data: StringAnyType;
409
-
410
- /**
411
- * Execution ID, also known as the job ID
412
- */
413
- workflowId: string;
414
-
415
- /**
416
- * Optional name of the user's workflow function
417
- */
418
- workflowName?: string;
419
- };
420
-
421
- type ActivityWorkflowDataType = {
422
- activityName: string;
423
- arguments: any[];
424
- workflowId: string;
425
- workflowTopic: string;
426
- };
427
-
428
- type WorkflowDataType = {
429
- arguments: any[];
430
- workflowId: string;
431
- workflowTopic: string;
432
- workflowDimension?: string; //is present if hook (not main workflow)
433
- originJobId?: string; //is present if there is an originating ancestor job
434
- canRetry?: boolean;
435
- expire?: number;
436
- };
437
-
438
- type Connection = ProviderConfig | ProvidersConfig;
439
-
440
- type ClientConfig = {
441
- connection: Connection;
442
- };
443
-
444
- type Registry = {
445
- [key: string]: Function;
446
- };
447
- type WorkerConfig = {
448
- /** Connection configuration for the worker */
449
- connection: Connection;
450
-
451
- /**
452
- * Namespace used in the app configuration, denoted as `appid` in the YAML
453
- * @default meshflow
454
- */
455
- namespace?: string;
456
-
457
- /** Task queue name, denoted as `subscribes` in the YAML (e.g., 'hello-world') */
458
- taskQueue: string;
459
-
460
- /** Target function or a record type with a name (string) and reference function */
461
- workflow: Function | Record<string | symbol, Function>;
462
-
463
- /** Additional options for configuring the worker */
464
- options?: WorkerOptions;
465
-
466
- /** Search options for workflow execution details */
467
- search?: WorkflowSearchOptions;
468
-
469
- /**
470
- * Provide to set the engine name. This MUST be unique, so do not
471
- * provide unless it is guaranteed to be a unique engine/worker guid
472
- * when identifying the point of presence within the mesh.
473
- */
474
- guid?: string;
475
- };
476
-
477
- type FindWhereQuery = {
478
- field: string;
479
- is: '=' | '==' | '>=' | '<=' | '[]';
480
- value: string | boolean | number | [number, number];
481
- type?: string; //default is TEXT
482
- };
483
-
484
- type FindOptions = {
485
- workflowName?: string; //also the function name
486
- taskQueue?: string;
487
- namespace?: string;
488
- index?: string;
489
- search?: WorkflowSearchOptions;
490
- };
491
-
492
- type FindWhereOptions = {
493
- options?: FindOptions;
494
- count?: boolean;
495
- query: FindWhereQuery[];
496
- return?: string[];
497
- limit?: {
498
- start: number;
499
- size: number;
500
- };
501
- };
502
-
503
- type FindJobsOptions = {
504
- /** The workflow name; include an asterisk for wilcard search; refer to Redis SCAN for the allowed format */
505
- match?: string;
506
-
507
- /**
508
- * application namespace
509
- * @default meshflow
510
- */
511
- namespace?: string;
512
-
513
- /** The suggested response limit. Reduce batch size to reduce the likelihood of large overages. */
514
- limit?: number;
515
-
516
- /** How many records to scan at a time */
517
- batch?: number;
518
-
519
- /** The start cursor; defaults to 0 */
520
- cursor?: string;
521
- };
522
-
523
- type WorkerOptions = {
524
- /** Log level: debug, info, warn, error */
525
- logLevel?: LogLevel;
526
-
527
- /** Maximum number of attempts, default 5 (HMSH_MESHFLOW_MAX_ATTEMPTS) */
528
- maximumAttempts?: number;
529
-
530
- /** Backoff coefficient for retry logic, default 10 (HMSH_MESHFLOW_EXP_BACKOFF) */
531
- backoffCoefficient?: number;
532
-
533
- /** Maximum interval between retries, default 120s (HMSH_MESHFLOW_MAX_INTERVAL) */
534
- maximumInterval?: string;
535
- };
536
-
537
- type ContextType = {
538
- workflowId: string;
539
- workflowTopic: string;
540
- };
541
-
542
- type FunctionSignature<T> = T extends (...args: infer A) => infer R
543
- ? (...args: A) => R
544
- : never;
545
- type ProxyType<ACT> = {
546
- [K in keyof ACT]: FunctionSignature<ACT[K]>;
547
- };
548
-
549
- /**
550
- * Configuration settings for activities within a workflow.
551
- */
552
- type ActivityConfig = {
553
- /** place holder setting; unused at this time (re: activity workflow expire configuration) */
554
- expire?: number;
555
-
556
- /** Start to close timeout for the activity; not yet implemented */
557
- startToCloseTimeout?: string;
558
-
559
- /** Configuration for specific activities, type not yet specified */
560
- activities?: any;
561
-
562
- /** Retry policy configuration for activities */
563
- retryPolicy?: {
564
- /** Maximum number of retry attempts, default is 5 (HMSH_MESHFLOW_MAX_ATTEMPTS) */
565
- maximumAttempts?: number;
566
- /** Factor by which the retry timeout increases, default is 10 (HMSH_MESHFLOW_MAX_INTERVAL) */
567
- backoffCoefficient?: number;
568
- /** Maximum interval between retries, default is '120s' (HMSH_MESHFLOW_EXP_BACKOFF) */
569
- maximumInterval?: string;
570
- /** Whether to throw an error on failure, default is true */
571
- throwOnError?: boolean;
572
- };
573
- };
574
-
575
- /**
576
- * The proxy response object returned from the activity proxy flow
577
- */
578
- type ProxyResponseType<T> = {
579
- data?: T; //expected data
580
- $error?: StreamError;
581
- done?: boolean; //non-existent if error was thrown in transition (not during execution)
582
- jc: string;
583
- ju: string;
584
- };
585
-
586
- /**
587
- * The child flow response object returned from the main flow during recursion
588
- */
589
- type ChildResponseType<T> = {
590
- data?: T; //expected data
591
- $error?: StreamError;
592
- done?: boolean; //non-existent if error was thrown in transition (not during execution)
593
- jc: string;
594
- ju: string;
595
- };
596
-
597
- interface ClientWorkflow {
598
- start(options: WorkflowOptions): Promise<WorkflowHandleService>;
599
- signal(
600
- signalId: string,
601
- data: StringAnyType,
602
- namespace?: string,
603
- ): Promise<string>;
604
- hook(options: HookOptions): Promise<string>;
605
- getHandle(
606
- taskQueue: string,
607
- workflowName: string,
608
- workflowId: string,
609
- namespace?: string,
610
- ): Promise<WorkflowHandleService>;
611
- search(
612
- taskQueue: string,
613
- workflowName: string,
614
- namespace: string | null,
615
- index: string,
616
- ...query: string[]
617
- ): Promise<string[]>;
618
- }
619
-
620
- export {
621
- ActivityConfig,
622
- ActivityWorkflowDataType,
623
- ChildResponseType,
624
- ClientConfig,
625
- ClientWorkflow,
626
- ContextType,
627
- Connection,
628
- ProxyResponseType,
629
- ProxyType,
630
- Registry,
631
- SignalOptions,
632
- FindJobsOptions,
633
- FindOptions,
634
- FindWhereOptions,
635
- FindWhereQuery,
636
- HookOptions,
637
- SearchResults,
638
- WorkerConfig,
639
- WorkflowConfig,
640
- WorkerOptions,
641
- WorkflowSearchOptions,
642
- WorkflowDataType,
643
- WorkflowOptions,
644
- WorkflowContext,
645
- };
package/types/ms.d.ts DELETED
@@ -1,7 +0,0 @@
1
- declare module 'ms' {
2
- function ms(value: string): number;
3
- function ms(value: number): string;
4
- function ms(value: string | number): string | number;
5
-
6
- export = ms;
7
- }