@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.
Files changed (254) 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/package.json +22 -21
  5. package/build/types/error.d.ts +5 -5
  6. package/build/types/exporter.d.ts +1 -1
  7. package/build/types/index.d.ts +3 -3
  8. package/build/types/manifest.d.ts +2 -2
  9. package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
  10. package/build/types/meshdata.d.ts +3 -3
  11. package/build/types/postgres.d.ts +7 -0
  12. package/build/types/stream.d.ts +3 -0
  13. package/index.ts +11 -11
  14. package/package.json +22 -21
  15. package/typedoc.json +8 -7
  16. package/types/error.ts +5 -5
  17. package/types/exporter.ts +1 -1
  18. package/types/index.ts +7 -7
  19. package/types/manifest.ts +2 -2
  20. package/types/{meshflow.ts → memflow.ts} +15 -15
  21. package/types/meshdata.ts +3 -3
  22. package/types/postgres.ts +9 -0
  23. package/types/stream.ts +4 -0
  24. package/build/modules/enums.d.ts +0 -110
  25. package/build/modules/enums.js +0 -134
  26. package/build/modules/errors.d.ts +0 -124
  27. package/build/modules/errors.js +0 -191
  28. package/build/modules/key.d.ts +0 -66
  29. package/build/modules/key.js +0 -1
  30. package/build/modules/storage.d.ts +0 -3
  31. package/build/modules/storage.js +0 -5
  32. package/build/modules/utils.d.ts +0 -119
  33. package/build/modules/utils.js +0 -1
  34. package/build/services/activities/activity.d.ts +0 -104
  35. package/build/services/activities/activity.js +0 -1
  36. package/build/services/activities/await.d.ts +0 -12
  37. package/build/services/activities/await.js +0 -1
  38. package/build/services/activities/cycle.d.ts +0 -19
  39. package/build/services/activities/cycle.js +0 -1
  40. package/build/services/activities/hook.d.ts +0 -27
  41. package/build/services/activities/hook.js +0 -1
  42. package/build/services/activities/index.d.ts +0 -19
  43. package/build/services/activities/index.js +0 -1
  44. package/build/services/activities/interrupt.d.ts +0 -16
  45. package/build/services/activities/interrupt.js +0 -1
  46. package/build/services/activities/signal.d.ts +0 -20
  47. package/build/services/activities/signal.js +0 -1
  48. package/build/services/activities/trigger.d.ts +0 -37
  49. package/build/services/activities/trigger.js +0 -1
  50. package/build/services/activities/worker.d.ts +0 -12
  51. package/build/services/activities/worker.js +0 -1
  52. package/build/services/collator/index.d.ts +0 -111
  53. package/build/services/collator/index.js +0 -1
  54. package/build/services/compiler/deployer.d.ts +0 -40
  55. package/build/services/compiler/deployer.js +0 -1
  56. package/build/services/compiler/index.d.ts +0 -32
  57. package/build/services/compiler/index.js +0 -1
  58. package/build/services/compiler/validator.d.ts +0 -34
  59. package/build/services/compiler/validator.js +0 -1
  60. package/build/services/connector/factory.d.ts +0 -22
  61. package/build/services/connector/factory.js +0 -99
  62. package/build/services/connector/index.d.ts +0 -30
  63. package/build/services/connector/index.js +0 -54
  64. package/build/services/connector/providers/ioredis.d.ts +0 -9
  65. package/build/services/connector/providers/ioredis.js +0 -26
  66. package/build/services/connector/providers/nats.d.ts +0 -9
  67. package/build/services/connector/providers/nats.js +0 -34
  68. package/build/services/connector/providers/postgres.d.ts +0 -20
  69. package/build/services/connector/providers/postgres.js +0 -102
  70. package/build/services/connector/providers/redis.d.ts +0 -9
  71. package/build/services/connector/providers/redis.js +0 -38
  72. package/build/services/engine/index.d.ts +0 -264
  73. package/build/services/engine/index.js +0 -1
  74. package/build/services/exporter/index.d.ts +0 -44
  75. package/build/services/exporter/index.js +0 -1
  76. package/build/services/hotmesh/index.d.ts +0 -340
  77. package/build/services/hotmesh/index.js +0 -479
  78. package/build/services/logger/index.d.ts +0 -16
  79. package/build/services/logger/index.js +0 -54
  80. package/build/services/mapper/index.d.ts +0 -28
  81. package/build/services/mapper/index.js +0 -1
  82. package/build/services/meshcall/index.d.ts +0 -194
  83. package/build/services/meshcall/index.js +0 -452
  84. package/build/services/meshcall/schemas/factory.d.ts +0 -9
  85. package/build/services/meshcall/schemas/factory.js +0 -189
  86. package/build/services/meshdata/index.d.ts +0 -795
  87. package/build/services/meshdata/index.js +0 -1235
  88. package/build/services/meshflow/client.d.ts +0 -108
  89. package/build/services/meshflow/client.js +0 -371
  90. package/build/services/meshflow/connection.d.ts +0 -23
  91. package/build/services/meshflow/connection.js +0 -33
  92. package/build/services/meshflow/exporter.d.ts +0 -51
  93. package/build/services/meshflow/exporter.js +0 -1
  94. package/build/services/meshflow/handle.d.ts +0 -90
  95. package/build/services/meshflow/handle.js +0 -176
  96. package/build/services/meshflow/index.d.ts +0 -111
  97. package/build/services/meshflow/index.js +0 -117
  98. package/build/services/meshflow/schemas/factory.d.ts +0 -29
  99. package/build/services/meshflow/schemas/factory.js +0 -2492
  100. package/build/services/meshflow/search.d.ts +0 -142
  101. package/build/services/meshflow/search.js +0 -320
  102. package/build/services/meshflow/worker.d.ts +0 -124
  103. package/build/services/meshflow/worker.js +0 -514
  104. package/build/services/meshflow/workflow/all.d.ts +0 -7
  105. package/build/services/meshflow/workflow/all.js +0 -15
  106. package/build/services/meshflow/workflow/common.d.ts +0 -18
  107. package/build/services/meshflow/workflow/common.js +0 -45
  108. package/build/services/meshflow/workflow/context.d.ts +0 -6
  109. package/build/services/meshflow/workflow/context.js +0 -45
  110. package/build/services/meshflow/workflow/didRun.d.ts +0 -7
  111. package/build/services/meshflow/workflow/didRun.js +0 -22
  112. package/build/services/meshflow/workflow/emit.d.ts +0 -11
  113. package/build/services/meshflow/workflow/emit.js +0 -29
  114. package/build/services/meshflow/workflow/enrich.d.ts +0 -9
  115. package/build/services/meshflow/workflow/enrich.js +0 -17
  116. package/build/services/meshflow/workflow/execChild.d.ts +0 -18
  117. package/build/services/meshflow/workflow/execChild.js +0 -102
  118. package/build/services/meshflow/workflow/hook.d.ts +0 -9
  119. package/build/services/meshflow/workflow/hook.js +0 -40
  120. package/build/services/meshflow/workflow/index.d.ts +0 -70
  121. package/build/services/meshflow/workflow/index.js +0 -83
  122. package/build/services/meshflow/workflow/interrupt.d.ts +0 -9
  123. package/build/services/meshflow/workflow/interrupt.js +0 -24
  124. package/build/services/meshflow/workflow/isSideEffectAllowed.d.ts +0 -10
  125. package/build/services/meshflow/workflow/isSideEffectAllowed.js +0 -33
  126. package/build/services/meshflow/workflow/proxyActivities.d.ts +0 -20
  127. package/build/services/meshflow/workflow/proxyActivities.js +0 -97
  128. package/build/services/meshflow/workflow/random.d.ts +0 -6
  129. package/build/services/meshflow/workflow/random.js +0 -16
  130. package/build/services/meshflow/workflow/searchMethods.d.ts +0 -6
  131. package/build/services/meshflow/workflow/searchMethods.js +0 -25
  132. package/build/services/meshflow/workflow/signal.d.ts +0 -7
  133. package/build/services/meshflow/workflow/signal.js +0 -28
  134. package/build/services/meshflow/workflow/sleepFor.d.ts +0 -8
  135. package/build/services/meshflow/workflow/sleepFor.js +0 -35
  136. package/build/services/meshflow/workflow/trace.d.ts +0 -14
  137. package/build/services/meshflow/workflow/trace.js +0 -33
  138. package/build/services/meshflow/workflow/waitFor.d.ts +0 -8
  139. package/build/services/meshflow/workflow/waitFor.js +0 -35
  140. package/build/services/meshos/index.d.ts +0 -293
  141. package/build/services/meshos/index.js +0 -547
  142. package/build/services/pipe/functions/array.d.ts +0 -17
  143. package/build/services/pipe/functions/array.js +0 -1
  144. package/build/services/pipe/functions/bitwise.d.ts +0 -9
  145. package/build/services/pipe/functions/bitwise.js +0 -1
  146. package/build/services/pipe/functions/conditional.d.ts +0 -13
  147. package/build/services/pipe/functions/conditional.js +0 -1
  148. package/build/services/pipe/functions/cron.d.ts +0 -12
  149. package/build/services/pipe/functions/cron.js +0 -1
  150. package/build/services/pipe/functions/date.d.ts +0 -58
  151. package/build/services/pipe/functions/date.js +0 -1
  152. package/build/services/pipe/functions/index.d.ts +0 -29
  153. package/build/services/pipe/functions/index.js +0 -1
  154. package/build/services/pipe/functions/json.d.ts +0 -5
  155. package/build/services/pipe/functions/json.js +0 -1
  156. package/build/services/pipe/functions/logical.d.ts +0 -5
  157. package/build/services/pipe/functions/logical.js +0 -1
  158. package/build/services/pipe/functions/math.d.ts +0 -42
  159. package/build/services/pipe/functions/math.js +0 -1
  160. package/build/services/pipe/functions/number.d.ts +0 -21
  161. package/build/services/pipe/functions/number.js +0 -1
  162. package/build/services/pipe/functions/object.d.ts +0 -25
  163. package/build/services/pipe/functions/object.js +0 -1
  164. package/build/services/pipe/functions/string.d.ts +0 -23
  165. package/build/services/pipe/functions/string.js +0 -1
  166. package/build/services/pipe/functions/symbol.d.ts +0 -12
  167. package/build/services/pipe/functions/symbol.js +0 -1
  168. package/build/services/pipe/functions/unary.d.ts +0 -7
  169. package/build/services/pipe/functions/unary.js +0 -1
  170. package/build/services/pipe/index.d.ts +0 -48
  171. package/build/services/pipe/index.js +0 -1
  172. package/build/services/quorum/index.d.ts +0 -90
  173. package/build/services/quorum/index.js +0 -1
  174. package/build/services/reporter/index.d.ts +0 -50
  175. package/build/services/reporter/index.js +0 -1
  176. package/build/services/router/index.d.ts +0 -60
  177. package/build/services/router/index.js +0 -1
  178. package/build/services/search/factory.d.ts +0 -7
  179. package/build/services/search/factory.js +0 -24
  180. package/build/services/search/index.d.ts +0 -22
  181. package/build/services/search/index.js +0 -10
  182. package/build/services/search/providers/postgres/postgres.d.ts +0 -24
  183. package/build/services/search/providers/postgres/postgres.js +0 -1
  184. package/build/services/search/providers/redis/ioredis.d.ts +0 -18
  185. package/build/services/search/providers/redis/ioredis.js +0 -1
  186. package/build/services/search/providers/redis/redis.d.ts +0 -18
  187. package/build/services/search/providers/redis/redis.js +0 -1
  188. package/build/services/serializer/index.d.ts +0 -42
  189. package/build/services/serializer/index.js +0 -1
  190. package/build/services/store/cache.d.ts +0 -67
  191. package/build/services/store/cache.js +0 -128
  192. package/build/services/store/factory.d.ts +0 -8
  193. package/build/services/store/factory.js +0 -24
  194. package/build/services/store/index.d.ts +0 -89
  195. package/build/services/store/index.js +0 -9
  196. package/build/services/store/providers/postgres/kvsql.d.ts +0 -168
  197. package/build/services/store/providers/postgres/kvsql.js +0 -1
  198. package/build/services/store/providers/postgres/kvtables.d.ts +0 -20
  199. package/build/services/store/providers/postgres/kvtables.js +0 -1
  200. package/build/services/store/providers/postgres/kvtransaction.d.ts +0 -36
  201. package/build/services/store/providers/postgres/kvtransaction.js +0 -1
  202. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
  203. package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1
  204. package/build/services/store/providers/postgres/kvtypes/list.d.ts +0 -33
  205. package/build/services/store/providers/postgres/kvtypes/list.js +0 -1
  206. package/build/services/store/providers/postgres/kvtypes/string.d.ts +0 -20
  207. package/build/services/store/providers/postgres/kvtypes/string.js +0 -1
  208. package/build/services/store/providers/postgres/kvtypes/zset.d.ts +0 -41
  209. package/build/services/store/providers/postgres/kvtypes/zset.js +0 -1
  210. package/build/services/store/providers/postgres/postgres.d.ts +0 -145
  211. package/build/services/store/providers/postgres/postgres.js +0 -1
  212. package/build/services/store/providers/redis/_base.d.ts +0 -137
  213. package/build/services/store/providers/redis/_base.js +0 -1
  214. package/build/services/store/providers/redis/ioredis.d.ts +0 -20
  215. package/build/services/store/providers/redis/ioredis.js +0 -1
  216. package/build/services/store/providers/redis/redis.d.ts +0 -18
  217. package/build/services/store/providers/redis/redis.js +0 -1
  218. package/build/services/store/providers/store-initializable.d.ts +0 -5
  219. package/build/services/store/providers/store-initializable.js +0 -1
  220. package/build/services/stream/factory.d.ts +0 -8
  221. package/build/services/stream/factory.js +0 -37
  222. package/build/services/stream/index.d.ts +0 -64
  223. package/build/services/stream/index.js +0 -11
  224. package/build/services/stream/providers/nats/nats.d.ts +0 -59
  225. package/build/services/stream/providers/nats/nats.js +0 -1
  226. package/build/services/stream/providers/postgres/kvtables.d.ts +0 -2
  227. package/build/services/stream/providers/postgres/kvtables.js +0 -1
  228. package/build/services/stream/providers/postgres/postgres.d.ts +0 -88
  229. package/build/services/stream/providers/postgres/postgres.js +0 -1
  230. package/build/services/stream/providers/redis/ioredis.d.ts +0 -60
  231. package/build/services/stream/providers/redis/ioredis.js +0 -1
  232. package/build/services/stream/providers/redis/redis.d.ts +0 -60
  233. package/build/services/stream/providers/redis/redis.js +0 -1
  234. package/build/services/stream/providers/stream-initializable.d.ts +0 -4
  235. package/build/services/stream/providers/stream-initializable.js +0 -1
  236. package/build/services/sub/factory.d.ts +0 -7
  237. package/build/services/sub/factory.js +0 -29
  238. package/build/services/sub/index.d.ts +0 -22
  239. package/build/services/sub/index.js +0 -10
  240. package/build/services/sub/providers/nats/nats.d.ts +0 -19
  241. package/build/services/sub/providers/nats/nats.js +0 -1
  242. package/build/services/sub/providers/postgres/postgres.d.ts +0 -19
  243. package/build/services/sub/providers/postgres/postgres.js +0 -1
  244. package/build/services/sub/providers/redis/ioredis.d.ts +0 -17
  245. package/build/services/sub/providers/redis/ioredis.js +0 -1
  246. package/build/services/sub/providers/redis/redis.d.ts +0 -17
  247. package/build/services/sub/providers/redis/redis.js +0 -1
  248. package/build/services/task/index.d.ts +0 -36
  249. package/build/services/task/index.js +0 -1
  250. package/build/services/telemetry/index.d.ts +0 -52
  251. package/build/services/telemetry/index.js +0 -1
  252. package/build/services/worker/index.d.ts +0 -77
  253. package/build/services/worker/index.js +0 -1
  254. /package/build/types/{meshflow.js → memflow.js} +0 -0
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.search = void 0;
4
- const common_1 = require("./common");
5
- /**
6
- * Returns a search session handle for interacting with the workflow's HASH storage.
7
- * @returns {Promise<Search>} A search session for workflow data.
8
- */
9
- async function search() {
10
- const store = common_1.asyncLocalStorage.getStore();
11
- const workflowId = store.get('workflowId');
12
- const workflowDimension = store.get('workflowDimension') ?? '';
13
- const workflowTopic = store.get('workflowTopic');
14
- const connection = store.get('connection');
15
- const namespace = store.get('namespace');
16
- const COUNTER = store.get('counter');
17
- const execIndex = COUNTER.counter = COUNTER.counter + 1;
18
- const hotMeshClient = await common_1.WorkerService.getHotMesh(workflowTopic, {
19
- connection,
20
- namespace,
21
- });
22
- const searchSessionId = `-search${workflowDimension}-${execIndex}`;
23
- return new common_1.Search(workflowId, hotMeshClient, searchSessionId);
24
- }
25
- exports.search = search;
@@ -1,7 +0,0 @@
1
- /**
2
- * Sends a signal payload to any paused workflow thread awaiting this signal.
3
- * @param {string} signalId - Unique signal identifier.
4
- * @param {Record<any, any>} data - The payload to send with the signal.
5
- * @returns {Promise<string>} The resulting hook/stream ID.
6
- */
7
- export declare function signal(signalId: string, data: Record<any, any>): Promise<string>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signal = void 0;
4
- const common_1 = require("./common");
5
- const isSideEffectAllowed_1 = require("./isSideEffectAllowed");
6
- /**
7
- * Sends a signal payload to any paused workflow thread awaiting this signal.
8
- * @param {string} signalId - Unique signal identifier.
9
- * @param {Record<any, any>} data - The payload to send with the signal.
10
- * @returns {Promise<string>} The resulting hook/stream ID.
11
- */
12
- async function signal(signalId, data) {
13
- const store = common_1.asyncLocalStorage.getStore();
14
- const workflowTopic = store.get('workflowTopic');
15
- const connection = store.get('connection');
16
- const namespace = store.get('namespace');
17
- const hotMeshClient = await common_1.WorkerService.getHotMesh(workflowTopic, {
18
- connection,
19
- namespace,
20
- });
21
- if (await (0, isSideEffectAllowed_1.isSideEffectAllowed)(hotMeshClient, 'signal')) {
22
- return await hotMeshClient.hook(`${namespace}.wfs.signal`, {
23
- id: signalId,
24
- data,
25
- });
26
- }
27
- }
28
- exports.signal = signal;
@@ -1,8 +0,0 @@
1
- /**
2
- * Sleeps the workflow for a specified duration, deterministically.
3
- * On replay, it will not actually sleep again, but resume after sleep.
4
- *
5
- * @param {string} duration - A human-readable duration string (e.g., '1m', '2 hours').
6
- * @returns {Promise<number>} The resolved duration in seconds.
7
- */
8
- export declare function sleepFor(duration: string): Promise<number>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sleepFor = void 0;
4
- const common_1 = require("./common");
5
- const didRun_1 = require("./didRun");
6
- /**
7
- * Sleeps the workflow for a specified duration, deterministically.
8
- * On replay, it will not actually sleep again, but resume after sleep.
9
- *
10
- * @param {string} duration - A human-readable duration string (e.g., '1m', '2 hours').
11
- * @returns {Promise<number>} The resolved duration in seconds.
12
- */
13
- async function sleepFor(duration) {
14
- const [didRunAlready, execIndex, result] = await (0, didRun_1.didRun)('sleep');
15
- if (didRunAlready) {
16
- return result.duration;
17
- }
18
- const store = common_1.asyncLocalStorage.getStore();
19
- const interruptionRegistry = store.get('interruptionRegistry');
20
- const workflowId = store.get('workflowId');
21
- const workflowDimension = store.get('workflowDimension') ?? '';
22
- const interruptionMessage = {
23
- workflowId,
24
- duration: (0, common_1.s)(duration),
25
- index: execIndex,
26
- workflowDimension,
27
- };
28
- interruptionRegistry.push({
29
- code: common_1.HMSH_CODE_MESHFLOW_SLEEP,
30
- ...interruptionMessage,
31
- });
32
- await (0, common_1.sleepImmediate)();
33
- throw new common_1.MeshFlowSleepError(interruptionMessage);
34
- }
35
- exports.sleepFor = sleepFor;
@@ -1,14 +0,0 @@
1
- import { StringScalarType } from './common';
2
- /**
3
- * Executes a distributed trace, outputting the provided attributes
4
- * to the telemetry sink (e.g. OpenTelemetry).
5
- *
6
- * This trace will only run once per workflow execution by default.
7
- *
8
- * @param {StringScalarType} attributes - Key-value attributes to attach to the trace.
9
- * @param {{ once: boolean }} [config={ once: true }] - If `once` is true, trace only runs once.
10
- * @returns {Promise<boolean>} True if tracing succeeded, otherwise false.
11
- */
12
- export declare function trace(attributes: StringScalarType, config?: {
13
- once: boolean;
14
- }): Promise<boolean>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trace = void 0;
4
- const common_1 = require("./common");
5
- const context_1 = require("./context");
6
- const isSideEffectAllowed_1 = require("./isSideEffectAllowed");
7
- /**
8
- * Executes a distributed trace, outputting the provided attributes
9
- * to the telemetry sink (e.g. OpenTelemetry).
10
- *
11
- * This trace will only run once per workflow execution by default.
12
- *
13
- * @param {StringScalarType} attributes - Key-value attributes to attach to the trace.
14
- * @param {{ once: boolean }} [config={ once: true }] - If `once` is true, trace only runs once.
15
- * @returns {Promise<boolean>} True if tracing succeeded, otherwise false.
16
- */
17
- async function trace(attributes, config = { once: true }) {
18
- const store = common_1.asyncLocalStorage.getStore();
19
- const workflowTopic = store.get('workflowTopic');
20
- const connection = store.get('connection');
21
- const namespace = store.get('namespace');
22
- const hotMeshClient = await common_1.WorkerService.getHotMesh(workflowTopic, {
23
- connection,
24
- namespace,
25
- });
26
- const { raw, COUNTER } = (0, context_1.getContext)();
27
- const { trc: traceId, spn: spanId, aid: activityId } = raw.metadata;
28
- if (!config.once || await (0, isSideEffectAllowed_1.isSideEffectAllowed)(hotMeshClient, 'trace')) {
29
- return await common_1.TelemetryService.traceActivity(namespace, attributes, activityId, traceId, spanId, COUNTER.counter);
30
- }
31
- return true;
32
- }
33
- exports.trace = trace;
@@ -1,8 +0,0 @@
1
- /**
2
- * Pauses the workflow until a signal with the given `signalId` is received.
3
- *
4
- * @template T
5
- * @param {string} signalId - A unique signal identifier shared by the sender and receiver.
6
- * @returns {Promise<T>} The data payload associated with the received signal.
7
- */
8
- export declare function waitFor<T>(signalId: string): Promise<T>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitFor = void 0;
4
- const common_1 = require("./common");
5
- const didRun_1 = require("./didRun");
6
- /**
7
- * Pauses the workflow until a signal with the given `signalId` is received.
8
- *
9
- * @template T
10
- * @param {string} signalId - A unique signal identifier shared by the sender and receiver.
11
- * @returns {Promise<T>} The data payload associated with the received signal.
12
- */
13
- async function waitFor(signalId) {
14
- const [didRunAlready, execIndex, result] = await (0, didRun_1.didRun)('wait');
15
- if (didRunAlready) {
16
- return result.data.data;
17
- }
18
- const store = common_1.asyncLocalStorage.getStore();
19
- const interruptionRegistry = store.get('interruptionRegistry');
20
- const workflowId = store.get('workflowId');
21
- const workflowDimension = store.get('workflowDimension') ?? '';
22
- const interruptionMessage = {
23
- workflowId,
24
- signalId,
25
- index: execIndex,
26
- workflowDimension,
27
- };
28
- interruptionRegistry.push({
29
- code: common_1.HMSH_CODE_MESHFLOW_WAIT,
30
- ...interruptionMessage,
31
- });
32
- await (0, common_1.sleepImmediate)();
33
- throw new common_1.MeshFlowWaitForError(interruptionMessage);
34
- }
35
- exports.waitFor = waitFor;
@@ -1,293 +0,0 @@
1
- import { MeshData } from '../meshdata/index';
2
- import * as Types from '../../types';
3
- import { ProviderConfig, ProvidersConfig } from '../../types/provider';
4
- /**
5
- * MeshOS is an abstract base class for schema-driven entity management within the Mesh network.
6
- * It provides a foundation for defining custom entities.
7
- * By subclassing MeshOS, you can create entities with specific schemas and behaviors, enabling
8
- * structured data storage, retrieval, and transactional workflows.
9
- *
10
- * ### Subclassing MeshOS
11
- *
12
- * Standard CRUD methods are included and use your provided schema to
13
- * fields to return in the response: create, retrieve, update, delete.
14
- *
15
- * Search methods are included and use your provided schema to
16
- * fields to return in the response: count, find, aggregate.
17
- *
18
- * Implement other methods as needed for the entity's
19
- * functionality; For example, subclass/override methods like `create`
20
- * to also spawn a transactional workflow
21
- *
22
- * @example
23
- * ```typescript
24
- * import { MeshOS } from '@hotmeshio/hotmesh';
25
- * import { Types } from '@hotmeshio/hotmesh';
26
- * import { schema } from './schema'; // Import your schema
27
- * import * as workflows from './workflows';
28
- *
29
- * class Widget extends MeshOS {
30
- *
31
- * //Subclass the `connect` method to connect workers and
32
- * // hooks (optional) when the container starts
33
- * async connect() {
34
- * await this.meshData.connect({
35
- * entity: this.getEntity(),
36
- * //the `target widget workflow` runs as a transaction
37
- * target: function() {
38
- * return { hello: 'world' };
39
- * },
40
- * options: {
41
- * namespace: this.getNamespace(),
42
- * taskQueue: this.getTaskQueue(),
43
- * },
44
- * });
45
- * }
46
- *
47
- * // subclass the `create` method to start a transactional
48
- * // workflow; use the options/search field to set default
49
- * // record data `{ ...input}` and invoke the `target widget workflow`
50
- * async create(input: Types.StringAnyType): Promise<Types.StringStringType> {
51
- * return await this.meshData.exec<Types.StringStringType>({
52
- * entity: this.getEntity(),
53
- * args: [{ ...input }],
54
- * options: {
55
- * id: input.id,
56
- * ttl: '6 months',
57
- * taskQueue: this.getTaskQueue(),
58
- * namespace: this.getNamespace(),
59
- * search: { data: { ...input }},
60
- * },
61
- * });
62
- * }
63
- * }
64
- * ```
65
- *
66
- * ### Defining the Schema
67
- *
68
- * The schema defines the data model for your entity and is used for indexing and searching within the mesh network.
69
- * Each field in the schema specifies the data type, whether it's required, and other indexing options.
70
- *
71
- * Here's an example of a schema (`schema.ts`):
72
- *
73
- * ```typescript
74
- * import { Types } from '@hotmeshio/hotmesh';
75
- *
76
- * export const schema: Types.WorkflowSearchSchema = {
77
- * /**
78
- * * Unique identifier for the widget, including the entity prefix.
79
- * *\/
80
- * id: {
81
- * type: 'TAG',
82
- * primitive: 'string',
83
- * required: true,
84
- * examples: ['H56789'],
85
- * },
86
- * /**
87
- * * entity type
88
- * *\/
89
- * $entity: {
90
- * type: 'TAG',
91
- * primitive: 'string',
92
- * required: true,
93
- * examples: ['widget'],
94
- * },
95
- * /**
96
- * * Field indicating whether the widget is active ('y') or pruned ('n').
97
- * *\/
98
- * active: {
99
- * type: 'TAG',
100
- * primitive: 'string',
101
- * required: true,
102
- * examples: ['y', 'n'],
103
- * },
104
- * // ... other fields as needed
105
- * };
106
- * ```
107
- *
108
- * In your entity class (`Widget`), you use this schema in the
109
- * `getSearchOptions` method to define how your entity's data
110
- * is indexed and searched.
111
- */
112
- declare abstract class MeshOS {
113
- meshData: MeshData;
114
- connected: boolean;
115
- entity: string;
116
- namespace: string;
117
- schema: Types.WorkflowSearchSchema;
118
- taskQueue: string;
119
- static databases: Record<string, Types.DB>;
120
- static namespaces: Types.Namespaces;
121
- static entities: Record<string, Types.Entity>;
122
- static schemas: Record<string, Types.WorkflowSearchSchema>;
123
- static profiles: Types.Profiles;
124
- static classes: Record<string, typeof MeshOS>;
125
- static logger: Types.ILogger;
126
- /**
127
- * Instances of MeshOS are typically initialized as a set, using a manifest.json
128
- * file that describes statically the fully set names, passwords, entities, etc.
129
- * The static init method is invoked to start this process (typically at server
130
- * startup).
131
- */
132
- constructor(providerConfig: ProviderConfig | ProvidersConfig, namespace: string, entity: string, taskQueue: string, schema: Types.WorkflowSearchSchema);
133
- /**
134
- * Return entity (e.g, book, library, user)
135
- */
136
- getEntity(): string;
137
- /**
138
- * Get Search options (initializes the search index, specific to the backend provider)
139
- */
140
- getSearchOptions(): Types.WorkflowSearchOptions;
141
- /**
142
- * Speficy a more-specific task queue than the default queue (v1, v1priority, v2, acmecorp, etc)
143
- */
144
- getTaskQueue(): string;
145
- /**
146
- * Initialize MeshData instance (this backs/supports the class
147
- * --the true provider of functionality)
148
- */
149
- private initializeMeshData;
150
- /**
151
- * Default target function
152
- */
153
- protected defaultTargetFn(): Promise<string>;
154
- /**
155
- * Get namespace
156
- */
157
- getNamespace(): string;
158
- /**
159
- * Get schema
160
- */
161
- getSchema(): Types.WorkflowSearchSchema;
162
- /**
163
- * Connect to the database
164
- */
165
- connect(): Promise<void>;
166
- /**
167
- * Create the search index
168
- */
169
- index(): Promise<void>;
170
- /**
171
- * Shutdown all connections
172
- */
173
- static shutdown(): Promise<void>;
174
- /**
175
- * Get index name
176
- */
177
- getIndexName(): string;
178
- /**
179
- * Create the data record
180
- * NOTE: subclasses should override this method (or create
181
- * an alternate method) for invoking a workflow when
182
- * creating the record.
183
- */
184
- create(body: Record<string, any>): Promise<Types.StringStringType>;
185
- /**
186
- * Retrieve the record data
187
- */
188
- retrieve(id: string, sparse?: boolean): Promise<Types.StringStringType>;
189
- /**
190
- * Update the record data
191
- */
192
- update(id: string, body: Record<string, any>): Promise<Types.StringStringType>;
193
- /**
194
- * Delete the record/workflow
195
- */
196
- delete(id: string): Promise<boolean>;
197
- /**
198
- * Find matching records
199
- */
200
- find(query?: {
201
- field: string;
202
- is: '=' | '[]' | '>=' | '<=';
203
- value: string;
204
- }[], start?: number, size?: number): Promise<{
205
- count: number;
206
- query: string;
207
- data: Types.StringStringType[];
208
- }>;
209
- /**
210
- * Count matching entities
211
- */
212
- count(query: {
213
- field: string;
214
- is: '=' | '[]' | '>=' | '<=';
215
- value: string;
216
- }[]): Promise<number>;
217
- /**
218
- * Aggregate matching entities
219
- */
220
- aggregate(filter?: {
221
- field: string;
222
- is: '=' | '[]' | '>=' | '<=';
223
- value: string;
224
- }[], apply?: {
225
- expression: string;
226
- as: string;
227
- }[], rows?: string[], columns?: string[], reduce?: {
228
- operation: string;
229
- as: string;
230
- property?: string;
231
- }[], sort?: {
232
- field: string;
233
- order: 'ASC' | 'DESC';
234
- }[], start?: number, size?: number): Promise<{
235
- count: number;
236
- query: string;
237
- data: Types.StringStringType[];
238
- }>;
239
- /**
240
- * Build aggregate command
241
- */
242
- private buildAggregateCommand;
243
- /**
244
- * Build filter command
245
- */
246
- private buildFilterCommand;
247
- /**
248
- * Instance initializer
249
- */
250
- init(search?: boolean): Promise<void>;
251
- /**
252
- * Register a database
253
- */
254
- static registerDatabase(id: string, config: Types.DB): void;
255
- /**
256
- * Register a namespace
257
- */
258
- static registerNamespace(id: string, config: Types.Namespace): void;
259
- /**
260
- * Register an entity
261
- */
262
- static registerEntity(id: string, config: Types.Entity): void;
263
- /**
264
- * Register a schema
265
- */
266
- static registerSchema(id: string, schema: Types.WorkflowSearchSchema): void;
267
- /**
268
- * Register a profile
269
- */
270
- static registerProfile(id: string, config: Types.Profile): void;
271
- /**
272
- * Register a class
273
- */
274
- static registerClass(id: string, entityClass: typeof MeshOS): void;
275
- /**
276
- * Initialize profiles
277
- */
278
- static init(p?: Types.Profiles): Promise<void>;
279
- /**
280
- * Find entity instance
281
- */
282
- static findEntity(database: string, namespace: string, entity: string): Types.EntityInstanceTypes | undefined;
283
- /**
284
- * Find schemas
285
- */
286
- static findSchemas(database: string, ns: string): Record<string, Types.WorkflowSearchSchema>;
287
- /**
288
- * Serialize profiles to JSON
289
- */
290
- static toJSON(p?: Types.Profiles): any;
291
- workflow: {};
292
- }
293
- export { MeshOS };