@peopl-health/nexus 5.56.29 → 5.56.31

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,7 +1,7 @@
1
1
  const { firstOf } = require('../../utils/coercionUtils');
2
2
  const { toIsoInstant } = require('../../utils/dateUtils');
3
3
  const { foldAccents } = require('../../utils/formatUtils');
4
- const { sanitizeInlineText } = require('../../utils/sanitizerUtils');
4
+ const { WHATSAPP_PATIENT_CODE, sanitizeInlineText } = require('../../utils/sanitizerUtils');
5
5
 
6
6
  const PROVENANCE = {
7
7
  auna: { source: 'legacy-clinician', trust: 0.5 },
@@ -40,15 +40,13 @@ const SENTINELS = [
40
40
  /^no (he recibido|tengo) (alguno|ningun[oa])( mas)?$/,
41
41
  ];
42
42
 
43
- const VALID_ID = /^whatsapp:\+\d{10,15}$/;
44
-
45
43
  const clean = (s) => sanitizeInlineText(s, Infinity);
46
44
  const fold = (s) => foldAccents(clean(s)).toLowerCase().replace(/[.;,]+$/, '');
47
45
  const isSentinel = (s) => SENTINELS.some((re) => re.test(fold(s)));
48
46
 
49
47
  const patientIdFrom = (record) => {
50
48
  const id = clean(firstOf(record?.whatsapp_id));
51
- return VALID_ID.test(id) ? id : null;
49
+ return WHATSAPP_PATIENT_CODE.test(id) ? id : null;
52
50
  };
53
51
 
54
52
  function candidatesFor(record) {
@@ -197,7 +197,11 @@ async function sweepUnansweredInbound({
197
197
  // Claimed before filing, like the replay branch above: a ticket filed without its marker is a
198
198
  // ticket the next pass files again.
199
199
  const ticket = await ticketGate.acquire(key, 'alerted');
200
- if (ticket !== 'acquired') { skipped += 1; continue; }
200
+ if (ticket !== 'acquired') {
201
+ skipped += 1;
202
+ if (ticket === 'unavailable') await claims.release(key);
203
+ continue;
204
+ }
201
205
 
202
206
  logger.error('[inboundRecovery] patient was left unanswered', {
203
207
  code, ageMs, recoveryLive: canRecover, reachable,
@@ -1,6 +1,7 @@
1
1
  const { Monitoreo_ID } = require('../config/airtableConfig');
2
2
 
3
3
  const { httpError } = require('../utils/httpErrorUtils');
4
+ const { WHATSAPP_PATIENT_CODE } = require('../utils/sanitizerUtils');
4
5
 
5
6
  const { escapeFormulaValue, fieldEquals, recordIdIn } = require('../helpers/airtableFormulaHelper');
6
7
  const {
@@ -19,7 +20,6 @@ const { clearOpenTaskSummary } = require('../services/patientTaskSummaryService'
19
20
 
20
21
  const MAX_ROWS = 50;
21
22
  const MAX_NOTE_LENGTH = 5000;
22
- const WHATSAPP_ID_RX = /^whatsapp:\+\d{10,15}$/;
23
23
  const RECORD_ID_RX = /^rec[A-Za-z0-9]{14}$/;
24
24
 
25
25
  const REQUEST_STATUSES = [
@@ -130,7 +130,7 @@ const TASK_KINDS = {
130
130
 
131
131
  const validWhatsappId = (code) => {
132
132
  const whatsappId = String(code || '').trim();
133
- if (!WHATSAPP_ID_RX.test(whatsappId)) throw httpError(400, 'A whatsapp:+<digits> patient code is required');
133
+ if (!WHATSAPP_PATIENT_CODE.test(whatsappId)) throw httpError(400, 'A whatsapp:+<digits> patient code is required');
134
134
  return whatsappId;
135
135
  };
136
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.56.29",
3
+ "version": "5.56.31",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",