@peopl-health/nexus 5.57.0-dev.10111 → 5.57.0-dev.10121
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,4 +1,5 @@
|
|
|
1
1
|
const runtimeConfig = require('../../config/runtimeConfig');
|
|
2
|
+
const { escapeRegExp } = require('../../utils/textMatchUtils');
|
|
2
3
|
|
|
3
4
|
const MAX_CARRIER_TEXT_LENGTH = 600;
|
|
4
5
|
const MAX_HYDRATED_BODY_LENGTH = 1024;
|
|
@@ -30,10 +31,6 @@ function templateSidForType(reminderType, config = {}) {
|
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
function escapeRegExp(value) {
|
|
34
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
34
|
function sanitizeVariable(value) {
|
|
38
35
|
return String(value ?? '').replace(/[\t\r\n]+/g, ' ').replace(/ {2,}/g, ' ').trim();
|
|
39
36
|
}
|
|
@@ -5,6 +5,7 @@ const { getRegisteredToolNames } = require('../../services/toolRegistryService')
|
|
|
5
5
|
|
|
6
6
|
const { logger } = require('../../utils/logger');
|
|
7
7
|
const { MapCache } = require('../../utils/MapCache');
|
|
8
|
+
const { escapeRegExp } = require('../../utils/textMatchUtils');
|
|
8
9
|
|
|
9
10
|
const SKILLS_TABLE = 'skills';
|
|
10
11
|
const TOOLS_TABLE = 'tools';
|
|
@@ -45,10 +46,6 @@ async function unavailableToolNames() {
|
|
|
45
46
|
return catalog.filter((id) => !registered.has(id));
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function escapeRegExp(value) {
|
|
49
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
49
|
function mentionedToolNames(text) {
|
|
53
50
|
const names = new Set();
|
|
54
51
|
for (const [, span] of text.matchAll(BACKTICK_SPAN_RX)) {
|
|
@@ -2,6 +2,7 @@ const { Estado_General_ID, Monitoreo_ID } = require('../config/airtableConfig');
|
|
|
2
2
|
|
|
3
3
|
const { httpError, requiredText } = require('../utils/httpErrorUtils');
|
|
4
4
|
const { inlineOf } = require('../utils/coercionUtils');
|
|
5
|
+
const { escapeRegExp } = require('../utils/textMatchUtils');
|
|
5
6
|
const { logger } = require('../utils/logger');
|
|
6
7
|
const { PATIENT_CODE, redactDirectIdentifiers } = require('../utils/sanitizerUtils');
|
|
7
8
|
const { escapeFormulaValue, fieldEquals } = require('../helpers/airtableFormulaHelper');
|
|
@@ -64,8 +65,6 @@ async function listOfficePatients({ requestedBy }) {
|
|
|
64
65
|
.sort((a, b) => String(a.name ?? '').localeCompare(String(b.name ?? ''), 'es'));
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
const escapeRegex = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
68
|
-
|
|
69
68
|
const officeVisibleQuery = (patientCode, assistant) => ({
|
|
70
69
|
numero: patientCode,
|
|
71
70
|
group_id: null,
|
|
@@ -73,7 +72,7 @@ const officeVisibleQuery = (patientCode, assistant) => ({
|
|
|
73
72
|
$or: [
|
|
74
73
|
{ from_me: false },
|
|
75
74
|
{ from_me: true, triggeredBy: assistant.email },
|
|
76
|
-
{ from_me: true, plainBody: { $regex: `^${
|
|
75
|
+
{ from_me: true, origin: 'whatsapp_platform', plainBody: { $regex: `^${escapeRegExp(assistant.label)}:` } },
|
|
77
76
|
],
|
|
78
77
|
});
|
|
79
78
|
|
|
@@ -95,6 +94,7 @@ async function readOfficeMessages({ requestedBy, code, limit }) {
|
|
|
95
94
|
body: message.plainBody ?? '',
|
|
96
95
|
mediaType: message.media?.mediaType ?? null,
|
|
97
96
|
sender: message.from_me ? 'office' : 'patient',
|
|
97
|
+
status: message.statusInfo?.status ?? null,
|
|
98
98
|
createdAt: message.createdAt,
|
|
99
99
|
})),
|
|
100
100
|
};
|
|
@@ -67,6 +67,9 @@ function isQuoteAnchored(quote, source, { strict = false } = {}) {
|
|
|
67
67
|
return matched / tokens.length >= QUOTE_ANCHOR_MIN_OVERLAP;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
const escapeRegExp = (value) => String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
71
|
+
|
|
70
72
|
module.exports = {
|
|
73
|
+
escapeRegExp,
|
|
71
74
|
isQuoteAnchored,
|
|
72
75
|
};
|