@peopl-health/nexus 5.56.33 → 5.56.34

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.
package/lib/index.js CHANGED
@@ -34,7 +34,6 @@ const { startRecommendationRecoverySweep } = require('./clinical/services/recomm
34
34
  const { startInboundRecoverySweep } = require('./services/inboundRecoveryService');
35
35
  const { requestIdMiddleware, getRequestId } = require('./middleware/requestId');
36
36
  const { QueueAdapter, LocalQueueAdapter, RedisQueueAdapter, createQueueAdapter, registerQueueAdapter } = require('./queue');
37
- const { createWorkflowRunner } = require('./core/workflowRunner');
38
37
  const { DrainingError } = require('./core/BatchingManager');
39
38
  const routes = require('./routes');
40
39
  const { resetAll, stopAllSweeps } = require('./config/lifecycle');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.56.33",
3
+ "version": "5.56.34",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",
@@ -1,35 +0,0 @@
1
- function createWorkflowRunner({ queueAdapter } = {}) {
2
- if (!queueAdapter) throw new Error('createWorkflowRunner requires a queueAdapter');
3
- const workflows = new Map();
4
-
5
- async function register(workflow = {}) {
6
- if (!workflow.kind || typeof workflow.kind !== 'string') throw new Error('workflow requires a kind');
7
- if (workflow.kind.includes('__')) throw new Error(`workflow '${workflow.kind}' must not contain '__' (reserved as the jobId delimiter)`);
8
- if (typeof workflow.dedupeKey !== 'function') throw new Error(`workflow '${workflow.kind}' requires a dedupeKey function`);
9
- if (typeof workflow.prepare !== 'function') throw new Error(`workflow '${workflow.kind}' requires a prepare function`);
10
- if (workflows.has(workflow.kind)) throw new Error(`workflow '${workflow.kind}' is already registered`);
11
- workflows.set(workflow.kind, workflow);
12
- try {
13
- await queueAdapter.process(workflow.kind, (trigger) => workflow.prepare(trigger));
14
- } catch (error) {
15
- workflows.delete(workflow.kind);
16
- throw error;
17
- }
18
- return workflow;
19
- }
20
-
21
- function enqueue(kind, trigger, options = {}) {
22
- const workflow = workflows.get(kind);
23
- if (!workflow) throw new Error(`no workflow registered for '${kind}'`);
24
- const dedupeKey = workflow.dedupeKey(trigger);
25
- if (dedupeKey == null || (typeof dedupeKey === 'string' && !dedupeKey.trim())) {
26
- throw new Error(`workflow '${kind}' produced an empty dedupe key`);
27
- }
28
- if (typeof dedupeKey !== 'string') throw new Error(`workflow '${kind}' produced a non-string dedupe key`);
29
- return queueAdapter.enqueue(kind, trigger, { ...options, jobId: `${kind}__${dedupeKey}` });
30
- }
31
-
32
- return { register, enqueue };
33
- }
34
-
35
- module.exports = { createWorkflowRunner };