@hotmeshio/hotmesh 0.12.1 → 0.14.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 (202) hide show
  1. package/README.md +18 -22
  2. package/build/modules/enums.d.ts +60 -5
  3. package/build/modules/enums.js +62 -7
  4. package/build/modules/errors.d.ts +15 -2
  5. package/build/modules/errors.js +17 -1
  6. package/build/modules/storage.d.ts +1 -0
  7. package/build/modules/storage.js +2 -1
  8. package/build/package.json +8 -2
  9. package/build/services/activities/activity/context.d.ts +22 -0
  10. package/build/services/activities/activity/context.js +76 -0
  11. package/build/services/activities/activity/index.d.ts +116 -0
  12. package/build/services/activities/activity/index.js +299 -0
  13. package/build/services/activities/activity/mapping.d.ts +12 -0
  14. package/build/services/activities/activity/mapping.js +63 -0
  15. package/build/services/activities/activity/process.d.ts +28 -0
  16. package/build/services/activities/activity/process.js +100 -0
  17. package/build/services/activities/activity/protocol.d.ts +39 -0
  18. package/build/services/activities/activity/protocol.js +151 -0
  19. package/build/services/activities/activity/state.d.ts +40 -0
  20. package/build/services/activities/activity/state.js +143 -0
  21. package/build/services/activities/activity/transition.d.ts +23 -0
  22. package/build/services/activities/activity/transition.js +71 -0
  23. package/build/services/activities/activity/verify.d.ts +22 -0
  24. package/build/services/activities/activity/verify.js +85 -0
  25. package/build/services/activities/await.d.ts +1 -4
  26. package/build/services/activities/await.js +2 -36
  27. package/build/services/activities/cycle.d.ts +1 -11
  28. package/build/services/activities/cycle.js +3 -46
  29. package/build/services/activities/hook.d.ts +2 -11
  30. package/build/services/activities/hook.js +30 -50
  31. package/build/services/activities/interrupt.d.ts +2 -4
  32. package/build/services/activities/interrupt.js +4 -38
  33. package/build/services/activities/signal.d.ts +1 -11
  34. package/build/services/activities/signal.js +3 -48
  35. package/build/services/activities/trigger.d.ts +1 -3
  36. package/build/services/activities/trigger.js +0 -3
  37. package/build/services/activities/worker.d.ts +3 -6
  38. package/build/services/activities/worker.js +4 -40
  39. package/build/services/connector/factory.d.ts +6 -0
  40. package/build/services/connector/factory.js +24 -0
  41. package/build/services/dba/index.d.ts +14 -4
  42. package/build/services/dba/index.js +57 -18
  43. package/build/services/durable/activity.d.ts +30 -0
  44. package/build/services/durable/activity.js +46 -0
  45. package/build/services/durable/client.d.ts +26 -31
  46. package/build/services/durable/client.js +26 -31
  47. package/build/services/durable/connection.d.ts +13 -7
  48. package/build/services/durable/connection.js +13 -7
  49. package/build/services/durable/exporter.d.ts +2 -2
  50. package/build/services/durable/exporter.js +27 -12
  51. package/build/services/durable/handle.d.ts +59 -41
  52. package/build/services/durable/handle.js +61 -41
  53. package/build/services/durable/index.d.ts +152 -283
  54. package/build/services/durable/index.js +161 -289
  55. package/build/services/durable/interceptor.d.ts +43 -33
  56. package/build/services/durable/interceptor.js +59 -39
  57. package/build/services/durable/schemas/factory.d.ts +2 -3
  58. package/build/services/durable/schemas/factory.js +180 -30
  59. package/build/services/durable/telemetry.d.ts +80 -0
  60. package/build/services/durable/telemetry.js +137 -0
  61. package/build/services/durable/worker.d.ts +100 -21
  62. package/build/services/durable/worker.js +314 -60
  63. package/build/services/durable/workflow/all.d.ts +1 -1
  64. package/build/services/durable/workflow/all.js +1 -1
  65. package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
  66. package/build/services/durable/workflow/cancellationScope.js +139 -0
  67. package/build/services/durable/workflow/common.d.ts +5 -4
  68. package/build/services/durable/workflow/common.js +6 -1
  69. package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
  70. package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
  71. package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
  72. package/build/services/durable/workflow/continueAsNew.js +92 -0
  73. package/build/services/durable/workflow/didRun.d.ts +2 -2
  74. package/build/services/durable/workflow/didRun.js +4 -4
  75. package/build/services/durable/workflow/enrich.d.ts +5 -0
  76. package/build/services/durable/workflow/enrich.js +5 -0
  77. package/build/services/durable/workflow/entityMethods.d.ts +7 -0
  78. package/build/services/durable/workflow/entityMethods.js +7 -0
  79. package/build/services/durable/workflow/execHook.js +3 -3
  80. package/build/services/durable/workflow/execHookBatch.js +2 -2
  81. package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
  82. package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
  83. package/build/services/durable/workflow/hook.d.ts +1 -1
  84. package/build/services/durable/workflow/hook.js +4 -3
  85. package/build/services/durable/workflow/index.d.ts +45 -50
  86. package/build/services/durable/workflow/index.js +46 -51
  87. package/build/services/durable/workflow/interruption.d.ts +7 -6
  88. package/build/services/durable/workflow/interruption.js +11 -7
  89. package/build/services/durable/workflow/patched.d.ts +72 -0
  90. package/build/services/durable/workflow/patched.js +110 -0
  91. package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
  92. package/build/services/durable/workflow/proxyActivities.js +51 -15
  93. package/build/services/durable/workflow/searchMethods.d.ts +7 -0
  94. package/build/services/durable/workflow/searchMethods.js +7 -0
  95. package/build/services/durable/workflow/signal.d.ts +4 -4
  96. package/build/services/durable/workflow/signal.js +4 -4
  97. package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
  98. package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
  99. package/build/services/durable/workflow/terminate.d.ts +55 -0
  100. package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
  101. package/build/services/durable/workflow/trace.js +2 -2
  102. package/build/services/durable/workflow/uuid4.d.ts +14 -0
  103. package/build/services/durable/workflow/uuid4.js +39 -0
  104. package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
  105. package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
  106. package/build/services/engine/compiler.d.ts +19 -0
  107. package/build/services/engine/compiler.js +20 -0
  108. package/build/services/engine/completion.d.ts +46 -0
  109. package/build/services/engine/completion.js +145 -0
  110. package/build/services/engine/dispatch.d.ts +24 -0
  111. package/build/services/engine/dispatch.js +98 -0
  112. package/build/services/engine/index.d.ts +49 -81
  113. package/build/services/engine/index.js +175 -573
  114. package/build/services/engine/init.d.ts +42 -0
  115. package/build/services/engine/init.js +74 -0
  116. package/build/services/engine/pubsub.d.ts +50 -0
  117. package/build/services/engine/pubsub.js +118 -0
  118. package/build/services/engine/reporting.d.ts +20 -0
  119. package/build/services/engine/reporting.js +38 -0
  120. package/build/services/engine/schema.d.ts +23 -0
  121. package/build/services/engine/schema.js +62 -0
  122. package/build/services/engine/signal.d.ts +57 -0
  123. package/build/services/engine/signal.js +117 -0
  124. package/build/services/engine/state.d.ts +35 -0
  125. package/build/services/engine/state.js +61 -0
  126. package/build/services/engine/version.d.ts +31 -0
  127. package/build/services/engine/version.js +73 -0
  128. package/build/services/hotmesh/deployment.d.ts +21 -0
  129. package/build/services/hotmesh/deployment.js +25 -0
  130. package/build/services/hotmesh/index.d.ts +142 -533
  131. package/build/services/hotmesh/index.js +223 -674
  132. package/build/services/hotmesh/init.d.ts +42 -0
  133. package/build/services/hotmesh/init.js +93 -0
  134. package/build/services/hotmesh/jobs.d.ts +67 -0
  135. package/build/services/hotmesh/jobs.js +99 -0
  136. package/build/services/hotmesh/pubsub.d.ts +38 -0
  137. package/build/services/hotmesh/pubsub.js +54 -0
  138. package/build/services/hotmesh/quorum.d.ts +30 -0
  139. package/build/services/hotmesh/quorum.js +62 -0
  140. package/build/services/hotmesh/validation.d.ts +6 -0
  141. package/build/services/hotmesh/validation.js +28 -0
  142. package/build/services/quorum/index.js +1 -0
  143. package/build/services/router/consumption/index.d.ts +11 -5
  144. package/build/services/router/consumption/index.js +24 -17
  145. package/build/services/router/error-handling/index.d.ts +2 -2
  146. package/build/services/router/error-handling/index.js +14 -14
  147. package/build/services/router/index.d.ts +1 -1
  148. package/build/services/router/index.js +2 -2
  149. package/build/services/serializer/index.d.ts +22 -0
  150. package/build/services/serializer/index.js +39 -1
  151. package/build/services/store/index.d.ts +1 -0
  152. package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
  153. package/build/services/store/providers/postgres/exporter-sql.js +4 -4
  154. package/build/services/store/providers/postgres/kvtables.js +7 -6
  155. package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
  156. package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
  157. package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
  158. package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
  159. package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
  160. package/build/services/store/providers/postgres/postgres.d.ts +1 -0
  161. package/build/services/store/providers/postgres/postgres.js +14 -4
  162. package/build/services/stream/factory.d.ts +3 -1
  163. package/build/services/stream/factory.js +2 -2
  164. package/build/services/stream/index.d.ts +1 -0
  165. package/build/services/stream/providers/nats/nats.d.ts +1 -0
  166. package/build/services/stream/providers/nats/nats.js +1 -0
  167. package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
  168. package/build/services/stream/providers/postgres/credentials.js +129 -0
  169. package/build/services/stream/providers/postgres/kvtables.js +18 -0
  170. package/build/services/stream/providers/postgres/messages.js +7 -7
  171. package/build/services/stream/providers/postgres/notifications.js +16 -2
  172. package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
  173. package/build/services/stream/providers/postgres/postgres.js +35 -4
  174. package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
  175. package/build/services/stream/providers/postgres/procedures.js +213 -0
  176. package/build/services/stream/providers/postgres/secured.d.ts +34 -0
  177. package/build/services/stream/providers/postgres/secured.js +146 -0
  178. package/build/services/stream/providers/postgres/stats.d.ts +1 -0
  179. package/build/services/stream/providers/postgres/stats.js +1 -0
  180. package/build/services/stream/registry.d.ts +1 -1
  181. package/build/services/stream/registry.js +5 -2
  182. package/build/services/telemetry/index.d.ts +10 -1
  183. package/build/services/telemetry/index.js +40 -7
  184. package/build/services/worker/credentials.d.ts +51 -0
  185. package/build/services/worker/credentials.js +87 -0
  186. package/build/services/worker/index.d.ts +2 -2
  187. package/build/services/worker/index.js +7 -6
  188. package/build/types/codec.d.ts +84 -0
  189. package/build/types/codec.js +2 -0
  190. package/build/types/dba.d.ts +39 -3
  191. package/build/types/durable.d.ts +123 -25
  192. package/build/types/error.d.ts +10 -0
  193. package/build/types/exporter.d.ts +1 -1
  194. package/build/types/hotmesh.d.ts +67 -4
  195. package/build/types/index.d.ts +2 -1
  196. package/build/types/provider.d.ts +2 -2
  197. package/build/types/quorum.d.ts +35 -1
  198. package/build/types/stream.d.ts +12 -6
  199. package/package.json +8 -2
  200. package/build/services/activities/activity.d.ts +0 -192
  201. package/build/services/activities/activity.js +0 -786
  202. package/build/services/durable/workflow/interrupt.d.ts +0 -55
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Job state retrieval, export, and symbol compression.
4
+ *
5
+ * Provides read access to job data at various granularities:
6
+ * - `getState()` → full hydrated job tree
7
+ * - `getQueryState()` → specific fields only
8
+ * - `getRaw()` → raw hash data (no hydration)
9
+ * - `getStatus()` → job status code only
10
+ * - `export()` → full export via ExporterService
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.compress = exports.getQueryState = exports.getState = exports.getStatus = exports.getRaw = exports.exportJob = void 0;
14
+ const utils_1 = require("../../modules/utils");
15
+ const serializer_1 = require("../serializer");
16
+ async function exportJob(instance, jobId, options = {}) {
17
+ return await instance.exporter.export(jobId, options);
18
+ }
19
+ exports.exportJob = exportJob;
20
+ async function getRaw(instance, jobId) {
21
+ return await instance.store.getRaw(jobId);
22
+ }
23
+ exports.getRaw = getRaw;
24
+ async function getStatus(instance, jobId) {
25
+ const { id: appId } = await instance.getVID();
26
+ return await instance.store.getStatus(jobId, appId);
27
+ }
28
+ exports.getStatus = getStatus;
29
+ async function getState(instance, topic, jobId) {
30
+ const jobSymbols = await instance.store.getSymbols(`$${topic}`);
31
+ const consumes = {
32
+ [`$${topic}`]: Object.keys(jobSymbols),
33
+ };
34
+ const dIds = {};
35
+ const output = await instance.store.getState(jobId, consumes, dIds);
36
+ if (!output) {
37
+ throw new Error(`not found ${jobId}`);
38
+ }
39
+ const [state, status] = output;
40
+ const stateTree = (0, utils_1.restoreHierarchy)(state);
41
+ if (status != null && stateTree.metadata) {
42
+ stateTree.metadata.js = status;
43
+ }
44
+ return stateTree;
45
+ }
46
+ exports.getState = getState;
47
+ async function getQueryState(instance, jobId, fields) {
48
+ return await instance.store.getQueryState(jobId, fields);
49
+ }
50
+ exports.getQueryState = getQueryState;
51
+ /**
52
+ * @deprecated
53
+ */
54
+ async function compress(instance, terms) {
55
+ const existingSymbols = await instance.store.getSymbolValues();
56
+ const startIndex = Object.keys(existingSymbols).length;
57
+ const maxIndex = Math.pow(52, 2) - 1;
58
+ const newSymbols = serializer_1.SerializerService.filterSymVals(startIndex, maxIndex, existingSymbols, new Set(terms));
59
+ return await instance.store.addSymbolValues(newSymbols);
60
+ }
61
+ exports.compress = compress;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * App version resolution and distributed cache management.
3
+ *
4
+ * The engine caches the deployed app version locally to avoid
5
+ * hitting the store on every message. During hot-deploys the cache
6
+ * switches to `nocache` mode until the target version appears,
7
+ * then resumes caching.
8
+ */
9
+ import { ILogger } from '../logger';
10
+ import { StoreService } from '../store';
11
+ import { AppVID } from '../../types/app';
12
+ import { CacheMode } from '../../types/cache';
13
+ import { HotMeshApps } from '../../types/hotmesh';
14
+ import { ProviderClient, ProviderTransaction } from '../../types/provider';
15
+ interface VersionContext {
16
+ appId: string;
17
+ guid: string;
18
+ apps: HotMeshApps | null;
19
+ cacheMode: CacheMode;
20
+ untilVersion: string | null;
21
+ store: StoreService<ProviderClient, ProviderTransaction>;
22
+ logger: ILogger;
23
+ }
24
+ /**
25
+ * Resolves the distributed executable version, retrying with a delay
26
+ * to allow deployment race conditions to settle.
27
+ */
28
+ export declare function fetchAndVerifyVID(instance: VersionContext, vid: AppVID, count?: number): Promise<AppVID>;
29
+ export declare function getVID(instance: VersionContext, vid?: AppVID): Promise<AppVID>;
30
+ export declare function setCacheMode(instance: VersionContext, cacheMode: CacheMode, untilVersion: string): void;
31
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /**
3
+ * App version resolution and distributed cache management.
4
+ *
5
+ * The engine caches the deployed app version locally to avoid
6
+ * hitting the store on every message. During hot-deploys the cache
7
+ * switches to `nocache` mode until the target version appears,
8
+ * then resumes caching.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.setCacheMode = exports.getVID = exports.fetchAndVerifyVID = void 0;
12
+ const enums_1 = require("../../modules/enums");
13
+ const utils_1 = require("../../modules/utils");
14
+ /**
15
+ * Resolves the distributed executable version, retrying with a delay
16
+ * to allow deployment race conditions to settle.
17
+ */
18
+ async function fetchAndVerifyVID(instance, vid, count = 0) {
19
+ if (isNaN(Number(vid.version))) {
20
+ const app = await instance.store.getApp(vid.id, true);
21
+ if (!isNaN(Number(app.version))) {
22
+ if (!instance.apps)
23
+ instance.apps = {};
24
+ instance.apps[vid.id] = app;
25
+ return { id: vid.id, version: app.version };
26
+ }
27
+ else if (count < 10) {
28
+ await (0, utils_1.sleepFor)(enums_1.HMSH_QUORUM_DELAY_MS * 2);
29
+ return await fetchAndVerifyVID(instance, vid, count + 1);
30
+ }
31
+ else {
32
+ instance.logger.error('engine-vid-resolution-error', {
33
+ id: vid.id,
34
+ guid: instance.guid,
35
+ });
36
+ }
37
+ }
38
+ return vid;
39
+ }
40
+ exports.fetchAndVerifyVID = fetchAndVerifyVID;
41
+ async function getVID(instance, vid) {
42
+ if (instance.cacheMode === 'nocache') {
43
+ const app = await instance.store.getApp(instance.appId, true);
44
+ if (app.version.toString() === instance.untilVersion.toString()) {
45
+ if (!instance.apps)
46
+ instance.apps = {};
47
+ instance.apps[instance.appId] = app;
48
+ setCacheMode(instance, 'cache', app.version.toString());
49
+ }
50
+ return { id: instance.appId, version: app.version };
51
+ }
52
+ else if (!instance.apps && vid) {
53
+ instance.apps = {};
54
+ instance.apps[instance.appId] = vid;
55
+ return vid;
56
+ }
57
+ else {
58
+ return await fetchAndVerifyVID(instance, {
59
+ id: instance.appId,
60
+ version: instance.apps?.[instance.appId].version,
61
+ });
62
+ }
63
+ }
64
+ exports.getVID = getVID;
65
+ function setCacheMode(instance, cacheMode, untilVersion) {
66
+ instance.logger.info(`engine-executable-cache`, {
67
+ mode: cacheMode,
68
+ [cacheMode === 'cache' ? 'target' : 'until']: untilVersion,
69
+ });
70
+ instance.cacheMode = cacheMode;
71
+ instance.untilVersion = untilVersion;
72
+ }
73
+ exports.setCacheMode = setCacheMode;
@@ -0,0 +1,21 @@
1
+ import { EngineService } from '../engine';
2
+ import { QuorumService } from '../quorum';
3
+ import { HotMeshManifest } from '../../types/hotmesh';
4
+ interface DeploymentContext {
5
+ engine: EngineService | null;
6
+ quorum: QuorumService | null;
7
+ }
8
+ /**
9
+ * Preview changes and provide an analysis of risk prior to deployment.
10
+ * @private
11
+ */
12
+ export declare function plan(instance: DeploymentContext, path: string): Promise<HotMeshManifest>;
13
+ /**
14
+ * Deploys a YAML workflow graph to Postgres.
15
+ */
16
+ export declare function deploy(instance: DeploymentContext, pathOrYAML: string): Promise<HotMeshManifest>;
17
+ /**
18
+ * Activates a deployed version across the entire mesh.
19
+ */
20
+ export declare function activate(instance: DeploymentContext, version: string, delay?: number): Promise<boolean>;
21
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.activate = exports.deploy = exports.plan = void 0;
4
+ /**
5
+ * Preview changes and provide an analysis of risk prior to deployment.
6
+ * @private
7
+ */
8
+ async function plan(instance, path) {
9
+ return await instance.engine?.plan(path);
10
+ }
11
+ exports.plan = plan;
12
+ /**
13
+ * Deploys a YAML workflow graph to Postgres.
14
+ */
15
+ async function deploy(instance, pathOrYAML) {
16
+ return await instance.engine?.deploy(pathOrYAML);
17
+ }
18
+ exports.deploy = deploy;
19
+ /**
20
+ * Activates a deployed version across the entire mesh.
21
+ */
22
+ async function activate(instance, version, delay) {
23
+ return await instance.quorum?.activate(version, delay);
24
+ }
25
+ exports.activate = activate;