@hotmeshio/hotmesh 0.22.4 → 0.22.6

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.22.4",
3
+ "version": "0.22.6",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  import { HotMesh } from '../hotmesh';
2
2
  import { ClientConfig, ClientWorkflow, Connection, WorkflowOptions } from '../../types/durable';
3
3
  import { EscalationClientService } from '../escalations/client';
4
+ import { EventsConfig } from '../../types/system_events';
4
5
  /**
5
6
  * Workflow client. Starts workflows, sends signals, and reads results.
6
7
  *
@@ -53,6 +54,10 @@ export declare class ClientService {
53
54
  * @private
54
55
  */
55
56
  options: WorkflowOptions;
57
+ /**
58
+ * @private
59
+ */
60
+ events?: EventsConfig;
56
61
  /**
57
62
  * @private
58
63
  */
@@ -85,6 +85,7 @@ class ClientService {
85
85
  readonly,
86
86
  connection: this.connection,
87
87
  },
88
+ events: this.events,
88
89
  });
89
90
  //synchronously cache the promise (before awaiting)
90
91
  ClientService.instances.set(connectionNS, hotMeshClient);
@@ -298,6 +299,7 @@ class ClientService {
298
299
  },
299
300
  };
300
301
  this.connection = config.connection;
302
+ this.events = config.events;
301
303
  this.escalations = new client_1.EscalationClientService({
302
304
  getHotMeshClient: this.getHotMeshClient.bind(this),
303
305
  events: config.events,
@@ -363,7 +365,10 @@ class ClientService {
363
365
  throw error;
364
366
  }
365
367
  }
366
- else if (isNaN(Number(appVersion)) || appVersion < version) {
368
+ else if (isNaN(Number(appVersion)) ||
369
+ Number(appVersion) < Number(version)) {
370
+ // Numeric compare: string `<` mis-orders at digit boundaries (e.g. '9' < '16'
371
+ // is false as strings). Redeploy + hot-swap when an older schema is deployed.
367
372
  try {
368
373
  await hotMesh.deploy((0, factory_1.getWorkflowYAML)(appId, version));
369
374
  await hotMesh.activate(version);
@@ -1,4 +1,4 @@
1
- declare const APP_VERSION = "15";
1
+ declare const APP_VERSION = "16";
2
2
  declare const APP_ID = "durable";
3
3
  /**
4
4
  * returns a new durable workflow schema
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.APP_ID = exports.APP_VERSION = exports.getWorkflowYAML = void 0;
4
- const APP_VERSION = '15';
4
+ // Schema content version for the generated durable app YAML below. BUMP THIS
5
+ // whenever `getWorkflowYAML` changes — it is how existing deployments detect a
6
+ // schema upgrade and hot-swap to it (see WorkerService.activateWorkflow and
7
+ // ClientService.deployAndActivate). Changing the YAML without a bump leaves
8
+ // every already-deployed database on the old schema forever. Numeric string —
9
+ // compared with `Number()` for ordering. (v16: condition() escalation hook.)
10
+ const APP_VERSION = '16';
5
11
  exports.APP_VERSION = APP_VERSION;
6
12
  const APP_ID = 'durable';
7
13
  exports.APP_ID = APP_ID;
@@ -128,7 +128,16 @@ class WorkerService {
128
128
  static async activateWorkflow(hotMesh) {
129
129
  const app = await hotMesh.engine.store.getApp(hotMesh.engine.appId);
130
130
  const appVersion = app?.version;
131
- if (!appVersion) {
131
+ if (!appVersion ||
132
+ isNaN(Number(appVersion)) ||
133
+ Number(appVersion) < Number(factory_1.APP_VERSION)) {
134
+ // Not deployed, or an OLDER schema version is deployed (the SDK was
135
+ // upgraded). Deploy this SDK's schema and hot-swap to it. HotMesh keeps
136
+ // the prior version deployed, so in-flight jobs drain on the old schema
137
+ // while new jobs use APP_VERSION. Without this branch an existing, active
138
+ // app would never pick up a new schema — atomic-escalation hooks and any
139
+ // other schema-encoded feature would silently never activate after an
140
+ // upgrade. Mirrors ClientService.deployAndActivate.
132
141
  try {
133
142
  await hotMesh.deploy((0, factory_1.getWorkflowYAML)(hotMesh.engine.appId, factory_1.APP_VERSION));
134
143
  await hotMesh.activate(factory_1.APP_VERSION);
@@ -309,6 +318,7 @@ class WorkerService {
309
318
  appId: targetNamespace,
310
319
  engine: { connection: config.connection },
311
320
  workers: [workerEntry],
321
+ events: config.events,
312
322
  });
313
323
  WorkerService.instances.set(targetTopic, hotMeshWorker);
314
324
  return hotMeshWorker;
@@ -564,6 +574,7 @@ class WorkerService {
564
574
  appId: targetNamespace,
565
575
  engine: { connection: providerConfig },
566
576
  workers: [workerEntry],
577
+ events: config.events,
567
578
  });
568
579
  WorkerService.instances.set(targetTopic, hotMeshWorker);
569
580
  return hotMeshWorker;
@@ -693,6 +704,7 @@ class WorkerService {
693
704
  appId: config.namespace ?? factory_1.APP_ID,
694
705
  engine: { connection: providerConfig },
695
706
  workers: [workerEntry],
707
+ events: config.events,
696
708
  });
697
709
  WorkerService.instances.set(targetTopic, hotMeshWorker);
698
710
  return hotMeshWorker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.22.4",
3
+ "version": "0.22.6",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",