@peopl-health/nexus 5.56.28 → 5.56.30

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) {
@@ -1,7 +1,7 @@
1
1
  const axios = require('axios');
2
2
 
3
3
  const { logger } = require('../utils/logger');
4
- const { isAllowedUrl, redactDirectIdentifiers } = require('../utils/sanitizerUtils');
4
+ const { WHATSAPP_PATIENT_CODE, isAllowedUrl, redactDirectIdentifiers } = require('../utils/sanitizerUtils');
5
5
 
6
6
  const { getPatientInformation, updatePatientInformation, logPatientChange } = require('../services/patientService');
7
7
  const { getTriageHistory } = require('../services/triageHistoryService');
@@ -79,6 +79,7 @@ const reviewPatientCarePlanCardController = async (req, res) => {
79
79
  const recommendationId = String(req.params.cardId || '').trim();
80
80
  try {
81
81
  if (!code) return res.status(400).json({ success: false, error: 'WhatsApp ID is required' });
82
+ if (!WHATSAPP_PATIENT_CODE.test(code)) return res.status(400).json({ success: false, error: 'A whatsapp:+<digits> patient code is required' });
82
83
  if (!recommendationId) return res.status(400).json({ success: false, error: 'cardId is required' });
83
84
 
84
85
  const { verdict, note = null, correctedText = null, reviewedBy, eventKey = null } = req.body || {};
@@ -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
 
@@ -26,6 +26,7 @@ function maskSensitiveValue(value) {
26
26
  }
27
27
 
28
28
  const PATIENT_CODE = /^(?:whatsapp:)?\+\d{10,15}$/;
29
+ const WHATSAPP_PATIENT_CODE = /^whatsapp:\+\d{10,15}$/;
29
30
  // Match the complete contiguous digit run. Although valid E.164 numbers stop at
30
31
  // 15 digits, malformed or concatenated identifiers must not leave a visible
31
32
  // suffix in logs.
@@ -150,6 +151,7 @@ function redactDirectIdentifiers(value) {
150
151
 
151
152
  module.exports = {
152
153
  PATIENT_CODE,
154
+ WHATSAPP_PATIENT_CODE,
153
155
  decodeUnicodeEscapes,
154
156
  decodeUnicodeEscapesDeep,
155
157
  collectStringsDeep,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.56.28",
3
+ "version": "5.56.30",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",