@hotmeshio/hotmesh 0.1.15 → 0.1.16

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 (134) hide show
  1. package/README.md +623 -209
  2. package/build/index.d.ts +14 -3
  3. package/build/index.js +17 -4
  4. package/build/modules/enums.d.ts +12 -12
  5. package/build/modules/enums.js +15 -25
  6. package/build/modules/errors.d.ts +16 -16
  7. package/build/modules/errors.js +28 -28
  8. package/build/modules/key.d.ts +0 -37
  9. package/build/modules/key.js +4 -45
  10. package/build/modules/utils.d.ts +7 -15
  11. package/build/modules/utils.js +21 -44
  12. package/build/package.json +18 -15
  13. package/build/services/activities/activity.d.ts +0 -31
  14. package/build/services/activities/activity.js +1 -50
  15. package/build/services/activities/await.js +0 -4
  16. package/build/services/activities/cycle.d.ts +0 -7
  17. package/build/services/activities/cycle.js +1 -16
  18. package/build/services/activities/hook.d.ts +0 -6
  19. package/build/services/activities/hook.js +2 -12
  20. package/build/services/activities/interrupt.js +0 -8
  21. package/build/services/activities/signal.d.ts +0 -6
  22. package/build/services/activities/signal.js +0 -15
  23. package/build/services/activities/trigger.d.ts +4 -5
  24. package/build/services/activities/trigger.js +22 -16
  25. package/build/services/activities/worker.js +0 -4
  26. package/build/services/collator/index.d.ts +0 -70
  27. package/build/services/collator/index.js +1 -91
  28. package/build/services/compiler/deployer.js +6 -38
  29. package/build/services/compiler/index.d.ts +0 -15
  30. package/build/services/compiler/index.js +0 -20
  31. package/build/services/compiler/validator.d.ts +0 -3
  32. package/build/services/compiler/validator.js +0 -25
  33. package/build/services/connector/clients/ioredis.js +0 -2
  34. package/build/services/connector/clients/redis.js +0 -2
  35. package/build/services/connector/index.js +0 -2
  36. package/build/services/engine/index.d.ts +1 -10
  37. package/build/services/engine/index.js +1 -48
  38. package/build/services/exporter/index.d.ts +0 -27
  39. package/build/services/exporter/index.js +0 -33
  40. package/build/services/hotmesh/index.d.ts +8 -4
  41. package/build/services/hotmesh/index.js +20 -19
  42. package/build/services/logger/index.js +0 -2
  43. package/build/services/mapper/index.d.ts +0 -14
  44. package/build/services/mapper/index.js +0 -14
  45. package/build/services/meshcall/index.d.ts +21 -0
  46. package/build/services/meshcall/index.js +202 -0
  47. package/build/services/meshcall/schemas/factory.d.ts +2 -0
  48. package/build/services/meshcall/schemas/factory.js +179 -0
  49. package/build/services/meshdata/index.d.ts +75 -0
  50. package/build/services/meshdata/index.js +541 -0
  51. package/build/services/meshflow/client.d.ts +18 -0
  52. package/build/services/{durable → meshflow}/client.js +9 -40
  53. package/build/services/{durable → meshflow}/connection.d.ts +2 -1
  54. package/build/services/{durable → meshflow}/connection.js +1 -0
  55. package/build/services/meshflow/exporter.d.ts +29 -0
  56. package/build/services/{durable → meshflow}/exporter.js +0 -29
  57. package/build/services/meshflow/handle.d.ts +22 -0
  58. package/build/services/{durable → meshflow}/handle.js +0 -46
  59. package/build/services/meshflow/index.d.ts +17 -0
  60. package/build/services/meshflow/index.js +23 -0
  61. package/build/services/meshflow/schemas/factory.d.ts +4 -0
  62. package/build/services/{durable → meshflow}/schemas/factory.js +2 -30
  63. package/build/services/meshflow/search.d.ts +23 -0
  64. package/build/services/{durable → meshflow}/search.js +0 -99
  65. package/build/services/{durable → meshflow}/worker.d.ts +3 -2
  66. package/build/services/{durable → meshflow}/worker.js +23 -39
  67. package/build/services/meshflow/workflow.d.ts +27 -0
  68. package/build/services/{durable → meshflow}/workflow.js +27 -169
  69. package/build/services/pipe/functions/date.d.ts +0 -7
  70. package/build/services/pipe/functions/date.js +0 -7
  71. package/build/services/pipe/functions/math.js +0 -2
  72. package/build/services/pipe/index.d.ts +0 -15
  73. package/build/services/pipe/index.js +2 -23
  74. package/build/services/quorum/index.d.ts +1 -7
  75. package/build/services/quorum/index.js +0 -21
  76. package/build/services/reporter/index.d.ts +0 -5
  77. package/build/services/reporter/index.js +0 -9
  78. package/build/services/router/index.d.ts +0 -9
  79. package/build/services/router/index.js +2 -30
  80. package/build/services/serializer/index.js +6 -23
  81. package/build/services/store/cache.d.ts +0 -19
  82. package/build/services/store/cache.js +0 -19
  83. package/build/services/store/clients/ioredis.d.ts +0 -6
  84. package/build/services/store/clients/ioredis.js +0 -7
  85. package/build/services/store/clients/redis.d.ts +0 -6
  86. package/build/services/store/clients/redis.js +0 -6
  87. package/build/services/store/index.d.ts +0 -55
  88. package/build/services/store/index.js +14 -87
  89. package/build/services/stream/clients/ioredis.js +1 -4
  90. package/build/services/task/index.d.ts +0 -9
  91. package/build/services/task/index.js +0 -31
  92. package/build/services/telemetry/index.d.ts +0 -7
  93. package/build/services/telemetry/index.js +1 -13
  94. package/build/services/worker/index.d.ts +1 -4
  95. package/build/services/worker/index.js +0 -6
  96. package/build/types/activity.d.ts +0 -81
  97. package/build/types/error.d.ts +5 -5
  98. package/build/types/exporter.d.ts +1 -14
  99. package/build/types/hotmesh.d.ts +4 -12
  100. package/build/types/hotmesh.js +0 -3
  101. package/build/types/index.d.ts +5 -3
  102. package/build/types/index.js +1 -1
  103. package/build/types/job.d.ts +1 -95
  104. package/build/types/meshcall.d.ts +54 -0
  105. package/build/types/meshdata.d.ts +59 -0
  106. package/build/types/meshdata.js +2 -0
  107. package/build/types/meshflow.d.ts +202 -0
  108. package/build/types/meshflow.js +2 -0
  109. package/build/types/pipe.d.ts +0 -65
  110. package/build/types/quorum.d.ts +0 -12
  111. package/build/types/redis.d.ts +0 -6
  112. package/build/types/stream.d.ts +0 -59
  113. package/build/types/stream.js +0 -4
  114. package/index.ts +22 -3
  115. package/package.json +18 -15
  116. package/typedoc.json +38 -0
  117. package/types/error.ts +5 -5
  118. package/types/exporter.ts +1 -1
  119. package/types/hotmesh.ts +3 -2
  120. package/types/index.ts +25 -7
  121. package/types/job.ts +19 -1
  122. package/types/meshcall.ts +123 -0
  123. package/types/meshdata.ts +273 -0
  124. package/types/{durable.ts → meshflow.ts} +33 -9
  125. package/build/services/durable/client.d.ts +0 -49
  126. package/build/services/durable/exporter.d.ts +0 -51
  127. package/build/services/durable/handle.d.ts +0 -58
  128. package/build/services/durable/index.d.ts +0 -19
  129. package/build/services/durable/index.js +0 -25
  130. package/build/services/durable/schemas/factory.d.ts +0 -33
  131. package/build/services/durable/search.d.ts +0 -120
  132. package/build/services/durable/workflow.d.ts +0 -143
  133. package/build/types/durable.d.ts +0 -467
  134. /package/build/types/{durable.js → meshcall.js} +0 -0
@@ -1,467 +0,0 @@
1
- import { LogLevel } from './logger';
2
- import { RedisClass, RedisOptions } from './redis';
3
- import { StringAnyType, StringStringType } from './serializer';
4
- import { StreamData, StreamError } from './stream';
5
- /**
6
- * Type definition for workflow configuration.
7
- */
8
- type WorkflowConfig = {
9
- /**
10
- * Backoff coefficient for retry mechanism.
11
- * @default 10 (HMSH_DURABLE_EXP_BACKOFF)
12
- */
13
- backoffCoefficient?: number;
14
- /**
15
- * Maximum number of attempts for retries.
16
- * @default 5 (HMSH_DURABLE_MAX_ATTEMPTS)
17
- */
18
- maximumAttempts?: number;
19
- /**
20
- * Maximum interval between retries.
21
- * @default 120s (HMSH_DURABLE_MAX_INTERVAL)
22
- */
23
- maximumInterval?: string;
24
- /**
25
- * Whether to throw an error on final failure after retries are exhausted
26
- * or return the error object as a standard response containing error-related
27
- * fields like `stack`, `code`, `message`.
28
- * @default true
29
- */
30
- throwOnError?: boolean;
31
- };
32
- type WorkflowContext = {
33
- /**
34
- * can the workflow be retried if an error occurs
35
- */
36
- canRetry: boolean;
37
- COUNTER: {
38
- /**
39
- * the reentrant semaphore parent counter object for object reference during increment
40
- */
41
- counter: number;
42
- };
43
- /**
44
- * the reentrant semaphore, incremented in real-time as idempotent statements are re-traversed upon reentry. Indicates the current semaphore count.
45
- */
46
- counter: number;
47
- /**
48
- * number as string for the replay cursor
49
- */
50
- cursor: string;
51
- /**
52
- * the replay hash of name/value pairs representing prior executions
53
- */
54
- replay: StringStringType;
55
- /**
56
- * the HotMesh App namespace. `durable` is the default.
57
- */
58
- namespace: string;
59
- /**
60
- * holds list of interruption payloads; if list is longer than 1 when the error is thrown, a `collator` subflow will be used
61
- */
62
- interruptionRegistry: any[];
63
- /**
64
- * entry point ancestor flow; might be the parent; will never be self
65
- */
66
- originJobId: string;
67
- /**
68
- * the workflow/job ID
69
- */
70
- workflowId: string;
71
- /**
72
- * the dimensional isolation for the reentrant hook, expressed in the format `0,0`, `0,1`, etc
73
- */
74
- workflowDimension: string;
75
- /**
76
- * a concatenation of the task queue and workflow name (e.g., `${taskQueueName}-${workflowName}`)
77
- */
78
- workflowTopic: string;
79
- /**
80
- * 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.
81
- */
82
- workflowTrace: string;
83
- /**
84
- * 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.
85
- */
86
- workflowSpan: string;
87
- /**
88
- * the native HotMesh message that encapsulates the arguments, metadata, and raw data for the workflow
89
- */
90
- raw: StreamData;
91
- /**
92
- * the HotMesh connection configuration (io/redis NPM package reference and login credentials)
93
- */
94
- connection: Connection;
95
- };
96
- /**
97
- * The schema for the full-text-search (RediSearch) index.
98
- */
99
- export type WorkflowSearchSchema = Record<string, {
100
- /**
101
- * The FT.SEARCH field type. One of: TEXT, NUMERIC, TAG. TEXT is
102
- * most expensive, but also most expressive.
103
- */
104
- type: 'TEXT' | 'NUMERIC' | 'TAG';
105
- /**
106
- * FT.SEARCH SORTABLE field. If true, results may be sorted according to this field
107
- * @default false
108
- */
109
- sortable?: boolean;
110
- /**
111
- * FT.SEARCH NOSTEM field. applies to TEXT fields types.
112
- * If true, the text field index will not stem words
113
- * @default false
114
- */
115
- nostem?: boolean;
116
- /**
117
- * FT.SEARCH NOINDEX field. If true and if the field is sortable, the field will aid
118
- * in sorting results but not be directly indexed as a standalone
119
- * @default false
120
- */
121
- noindex?: boolean;
122
- /**
123
- * if true, the field is indexed and searchable within the FT.SEARCH index
124
- * This is different from `noindex` which is FT.SEARCH specific and relates
125
- * to sorting and indexing. This is a general flag for the field that will
126
- * enable or disable indexing and searching entirely. Use for fields with
127
- * absolutely no meaning to query or sorting but which are important
128
- * nonetheless as part of the data record that is saved and returned.
129
- * @default true
130
- */
131
- indexed?: boolean;
132
- /**
133
- * An array of possible values for the field
134
- */
135
- examples?: string[];
136
- /**
137
- * The 'nilable' setting may NOT be set to `true` for
138
- * NUMBER types as it causes an indexing error;
139
- * consider a custom (e.g., negative number) value to represent
140
- * `null` if desired for a NUMERIC field.
141
- * Set to true only if the field is a TEXT or TAG type and
142
- * you wish to save the string `null` as a value to search
143
- * on (the tag, {null}, or the string, (null)
144
- * @default false
145
- */
146
- nilable?: boolean;
147
- /**
148
- * possible scalar/primitive types for the field. Use when
149
- * serializing and restoring data to ensure the field is
150
- * properly typed. If not provided, the field will be
151
- * treated as a string.
152
- */
153
- primitive?: 'string' | 'number' | 'boolean' | 'array' | 'object';
154
- /**
155
- * if true, the field is required to be present in the data record
156
- * @default false
157
- */
158
- required?: boolean;
159
- /**
160
- * an enumerated list of allowed values; if field is nilable, it is implied
161
- * and therefore not necessary to include `null` in the list
162
- * @default []
163
- */
164
- enum?: string[];
165
- /**
166
- * a regular expression pattern for the field
167
- * @default '.*'
168
- * @example '^[a-zA-Z0-9_]*$'
169
- */
170
- pattern?: string;
171
- /**
172
- * literal value to use for the indexed field name (without including the standard underscore (_) prefix isolate)
173
- */
174
- fieldName?: string;
175
- }>;
176
- type WorkflowSearchOptions = {
177
- /** FT index name (myapp:myindex) */
178
- index?: string;
179
- /** FT prefixes (['myapp:myindex:prefix1', 'myapp:myindex:prefix2']) */
180
- prefix?: string[];
181
- /**
182
- * Schema mapping each field. Each field is a key-value pair where the key is the field name
183
- * and the value is a record of field options. If the fieldName is provided,
184
- * it will be used as the indexed field name. If not provided
185
- * key will be used as the indexed field name with an underscore prefix.
186
- *
187
- */
188
- schema?: WorkflowSearchSchema;
189
- /** Additional data as a key-value record */
190
- data?: StringStringType;
191
- };
192
- type SearchResults = {
193
- /**
194
- * the total number of results
195
- */
196
- count: number;
197
- /**
198
- * the raw FT.SEARCH query string
199
- */
200
- query: string;
201
- /**
202
- * the raw FT.SEARCH results as an array of objects
203
- */
204
- data: StringStringType[];
205
- };
206
- type WorkflowOptions = {
207
- /**
208
- * the namespace for the workflow; `durable` is the default namespace if not provided
209
- */
210
- namespace?: string;
211
- /**
212
- * the task queue for the workflow; optional if entity is provided
213
- */
214
- taskQueue?: string;
215
- /**
216
- * input arguments to pass in
217
- */
218
- args: any[];
219
- /**
220
- * the job id
221
- */
222
- workflowId?: string;
223
- /**
224
- * 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.
225
- */
226
- entity?: string;
227
- /**
228
- * the name of the user's workflow function; optional if 'entity' is provided
229
- */
230
- workflowName?: string;
231
- /**
232
- * the parent workflow id; adjacent ancestor ID
233
- */
234
- parentWorkflowId?: string;
235
- /**
236
- * the entry point workflow id
237
- */
238
- originJobId?: string;
239
- /**
240
- * OpenTelemetry trace context for the workflow
241
- */
242
- workflowTrace?: string;
243
- /**
244
- * OpenTelemetry span context for the workflow
245
- */
246
- workflowSpan?: string;
247
- /**
248
- * the full-text-search (RediSearch) options for the workflow
249
- */
250
- search?: WorkflowSearchOptions;
251
- /**
252
- * marker data (begins with a -)
253
- */
254
- marker?: StringStringType;
255
- /**
256
- * the workflow configuration object
257
- */
258
- config?: WorkflowConfig;
259
- /**
260
- * 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.
261
- */
262
- expire?: number;
263
- /**
264
- * default is true; set to false to optimize workflows that do not require a `signal in`
265
- */
266
- signalIn?: boolean;
267
- /**
268
- * default is true; if false, will not await the execution
269
- */
270
- await?: boolean;
271
- /**
272
- * If provided, the job will initialize in a pending state, reserving
273
- * only the job ID (HSETNX) and persisting search and marker (if provided).
274
- * If a `resume` signal is sent before the specified number of seconds,
275
- * the job will resume as normal, transitioning to the adjacent children
276
- * of the trigger. If the job is not resumed within the number
277
- * of seconds specified, the job will be scrubbed. No dependencies
278
- * are added for a job in a pending state; however, dependencies
279
- * will be added after the job is resumed if relevant.
280
- */
281
- pending?: number;
282
- };
283
- /**
284
- * Options for setting up a hook.
285
- * 'durable' is the default namespace if not provided; similar to setting `appid` in the YAML
286
- */
287
- type HookOptions = {
288
- /** Optional namespace under which the hook function will be grouped */
289
- namespace?: string;
290
- /** Optional task queue, needed unless 'entity' is provided */
291
- taskQueue?: string;
292
- /** Input arguments to pass into the hook */
293
- args: any[];
294
- /**
295
- * Optional entity name. If provided, applies as the workflowName,
296
- * taskQueue, and prefix. This scopes the FT.SEARCH index appropriately.
297
- * This is a convenience method but limits options.
298
- */
299
- entity?: string;
300
- /** Execution ID, also known as the job ID to hook into */
301
- workflowId?: string;
302
- /** The name of the user's hook function */
303
- workflowName?: string;
304
- /** Bind additional search terms immediately before hook reentry */
305
- search?: WorkflowSearchOptions;
306
- /** Hook function constraints (backoffCoefficient, maximumAttempts, maximumInterval) */
307
- config?: WorkflowConfig;
308
- };
309
- /**
310
- * Options for sending signals in a workflow.
311
- */
312
- type SignalOptions = {
313
- /**
314
- * Task queue associated with the workflow
315
- */
316
- taskQueue: string;
317
- /**
318
- * Input data for the signal (any serializable object)
319
- */
320
- data: StringAnyType;
321
- /**
322
- * Execution ID, also known as the job ID
323
- */
324
- workflowId: string;
325
- /**
326
- * Optional name of the user's workflow function
327
- */
328
- workflowName?: string;
329
- };
330
- type ActivityWorkflowDataType = {
331
- activityName: string;
332
- arguments: any[];
333
- workflowId: string;
334
- workflowTopic: string;
335
- };
336
- type WorkflowDataType = {
337
- arguments: any[];
338
- workflowId: string;
339
- workflowTopic: string;
340
- workflowDimension?: string;
341
- originJobId?: string;
342
- canRetry?: boolean;
343
- };
344
- type ConnectionConfig = {
345
- class: Partial<RedisClass>;
346
- options: Partial<RedisOptions>;
347
- };
348
- type Connection = ConnectionConfig;
349
- type ClientConfig = {
350
- connection: Connection;
351
- };
352
- type Registry = {
353
- [key: string]: Function;
354
- };
355
- type WorkerConfig = {
356
- /** Connection configuration for the worker */
357
- connection: Connection;
358
- /**
359
- * Namespace used in the app configuration, denoted as `appid` in the YAML (e.g., 'durable')
360
- * @default durable
361
- */
362
- namespace?: string;
363
- /** Task queue name, denoted as `subscribes` in the YAML (e.g., 'hello-world') */
364
- taskQueue: string;
365
- /** Target function or a record type with a name (string) and reference function */
366
- workflow: Function | Record<string | symbol, Function>;
367
- /** Additional options for configuring the worker */
368
- options?: WorkerOptions;
369
- /** Search options for workflow execution details */
370
- search?: WorkflowSearchOptions;
371
- };
372
- type FindWhereQuery = {
373
- field: string;
374
- is: '=' | '==' | '>=' | '<=' | '[]';
375
- value: string | boolean | number | [number, number];
376
- type?: string;
377
- };
378
- type FindOptions = {
379
- workflowName?: string;
380
- taskQueue?: string;
381
- namespace?: string;
382
- index?: string;
383
- search?: WorkflowSearchOptions;
384
- };
385
- type FindWhereOptions = {
386
- options?: FindOptions;
387
- count?: boolean;
388
- query: FindWhereQuery[];
389
- return?: string[];
390
- limit?: {
391
- start: number;
392
- size: number;
393
- };
394
- };
395
- type FindJobsOptions = {
396
- /** The workflow name; include an asterisk for wilcard search; refer to Redis SCAN for the allowed format */
397
- match?: string;
398
- /** application namespace; defaults to 'durable' */
399
- namespace?: string;
400
- /** The suggested response limit. Reduce batch size to reduce the likelihood of large overages. */
401
- limit?: number;
402
- /** How many records to scan at a time */
403
- batch?: number;
404
- /** The start cursor; defaults to 0 */
405
- cursor?: string;
406
- };
407
- type WorkerOptions = {
408
- /** Log level: debug, info, warn, error */
409
- logLevel?: LogLevel;
410
- /** Maximum number of attempts, default 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
411
- maximumAttempts?: number;
412
- /** Backoff coefficient for retry logic, default 10 (HMSH_DURABLE_EXP_BACKOFF) */
413
- backoffCoefficient?: number;
414
- /** Maximum interval between retries, default 120s (HMSH_DURABLE_MAX_INTERVAL) */
415
- maximumInterval?: string;
416
- };
417
- type ContextType = {
418
- workflowId: string;
419
- workflowTopic: string;
420
- };
421
- type FunctionSignature<T> = T extends (...args: infer A) => infer R ? (...args: A) => R : never;
422
- type ProxyType<ACT> = {
423
- [K in keyof ACT]: FunctionSignature<ACT[K]>;
424
- };
425
- /**
426
- * Configuration settings for activities within a workflow.
427
- */
428
- type ActivityConfig = {
429
- /** place holder setting; unused at this time (re: activity workflow expire configuration) */
430
- expire?: number;
431
- /** Start to close timeout for the activity; not yet implemented */
432
- startToCloseTimeout?: string;
433
- /** Configuration for specific activities, type not yet specified */
434
- activities?: any;
435
- /** Retry policy configuration for activities */
436
- retryPolicy?: {
437
- /** Maximum number of retry attempts, default is 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
438
- maximumAttempts?: number;
439
- /** Factor by which the retry timeout increases, default is 10 (HMSH_DURABLE_MAX_INTERVAL) */
440
- backoffCoefficient?: number;
441
- /** Maximum interval between retries, default is '120s' (HMSH_DURABLE_EXP_BACKOFF) */
442
- maximumInterval?: string;
443
- /** Whether to throw an error on failure, default is true */
444
- throwOnError?: boolean;
445
- };
446
- };
447
- /**
448
- * The proxy response object returned from the activity proxy flow
449
- */
450
- type ProxyResponseType<T> = {
451
- data?: T;
452
- $error?: StreamError;
453
- done?: boolean;
454
- jc: string;
455
- ju: string;
456
- };
457
- /**
458
- * The child flow response object returned from the main flow during recursion
459
- */
460
- type ChildResponseType<T> = {
461
- data?: T;
462
- $error?: StreamError;
463
- done?: boolean;
464
- jc: string;
465
- ju: string;
466
- };
467
- export { ActivityConfig, ActivityWorkflowDataType, ChildResponseType, ClientConfig, ContextType, ConnectionConfig, Connection, ProxyResponseType, ProxyType, Registry, SignalOptions, FindJobsOptions, FindOptions, FindWhereOptions, FindWhereQuery, HookOptions, SearchResults, WorkerConfig, WorkflowConfig, WorkerOptions, WorkflowSearchOptions, WorkflowDataType, WorkflowOptions, WorkflowContext, };
File without changes