@liftitapp/wa-conversations 0.9.0 → 0.10.1
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/dist/element/index.js +12 -12
- package/dist/react/index.d.ts +14 -0
- package/dist/react/index.js +92 -35
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -371,7 +371,13 @@ interface ThreadRequest {
|
|
|
371
371
|
/** Qué trozo de la lista de inbox se pide. Todo opcional: sin filtros es "la primera página". */
|
|
372
372
|
interface ConversationsRequest {
|
|
373
373
|
phone?: string;
|
|
374
|
+
/**
|
|
375
|
+
* Cota inferior INCLUSIVA sobre `last_message_at`: un instante ISO 8601 en UTC (`…Z`). Desde
|
|
376
|
+
* DEV-6425 la lista manda el inicio del primer día LOCAL del operador (00:00:00.000), no la
|
|
377
|
+
* fecha sola — el servicio leería `YYYY-MM-DD` como 00:00 UTC.
|
|
378
|
+
*/
|
|
374
379
|
from?: string;
|
|
380
|
+
/** Cota superior INCLUSIVA: el fin del último día local (23:59:59.999), en ISO 8601 UTC. */
|
|
375
381
|
to?: string;
|
|
376
382
|
cursor?: string;
|
|
377
383
|
limit?: number;
|
|
@@ -382,6 +388,14 @@ interface ConversationsRequest {
|
|
|
382
388
|
*/
|
|
383
389
|
interface MediaRequest {
|
|
384
390
|
mediaId: string;
|
|
391
|
+
/**
|
|
392
|
+
* DEV-7528: `true` pide la variante de DESCARGA — el host agrega `?download=1` y el servicio
|
|
393
|
+
* firma la url como `attachment` con el nombre del archivo (DEV-7527). Sólo la usa la flecha /
|
|
394
|
+
* el link de descarga; la miniatura y la imagen ampliada la omiten y siguen en `inline`.
|
|
395
|
+
* Opcional y semántico como el resto: un host o un servicio que no lo conozcan lo ignoran y
|
|
396
|
+
* queda el comportamiento de siempre.
|
|
397
|
+
*/
|
|
398
|
+
download?: boolean;
|
|
385
399
|
}
|
|
386
400
|
/**
|
|
387
401
|
* Qué mensaje se envía (DEV-4995). Sigue siendo semántico: el `phone` identifica la conversación,
|
package/dist/react/index.js
CHANGED
|
@@ -899,10 +899,10 @@ function readSendError(cause) {
|
|
|
899
899
|
function sendFailureCopy(failure) {
|
|
900
900
|
switch (failure.errorCode) {
|
|
901
901
|
case "window_closed": return "La ventana de 24 h se cerró: no podemos escribirle hasta que la persona vuelva a escribir.";
|
|
902
|
-
case "window_unverified": return "No pudimos verificar la ventana de 24 h, así que no se envió nada.
|
|
903
|
-
case "takeover_unavailable": return "No se pudo pausar el bot, así que el mensaje no se envió.
|
|
902
|
+
case "window_unverified": return "No pudimos verificar la ventana de 24 h, así que no se envió nada. Reintenta: reintentar no envía ningún mensaje cobrado.";
|
|
903
|
+
case "takeover_unavailable": return "No se pudo pausar el bot, así que el mensaje no se envió. Reintenta en un momento.";
|
|
904
904
|
case "send_failed": return "WhatsApp rechazó el envío. El mensaje quedó registrado en el hilo como no entregado.";
|
|
905
|
-
case "write_forbidden": return "No
|
|
905
|
+
case "write_forbidden": return "No tienes permiso para responder en esta conversación.";
|
|
906
906
|
default: return failure.serverMessage ?? "No se pudo enviar el mensaje.";
|
|
907
907
|
}
|
|
908
908
|
}
|
|
@@ -1443,8 +1443,8 @@ const NO_FILTERS = {};
|
|
|
1443
1443
|
* El rango local `YYYY-MM-DD` de un preset: `to` = hoy, `from` = hoy − (days − 1) — el rango
|
|
1444
1444
|
* INCLUYE hoy («7 días» son siete fechas contando la de hoy). Fechas locales con
|
|
1445
1445
|
* `getFullYear/getMonth/getDate` + padStart, sin Intl (coherente con DEC-K/DEC-O). El formato es
|
|
1446
|
-
* el MISMO que
|
|
1447
|
-
*
|
|
1446
|
+
* el MISMO que producen los `<input type="date">`: es el estado del FORMULARIO. Lo que viaja al
|
|
1447
|
+
* descriptor es otra cosa — ver `dayBound`.
|
|
1448
1448
|
*/
|
|
1449
1449
|
function presetRange(days) {
|
|
1450
1450
|
const format = (date) => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
@@ -1454,6 +1454,48 @@ function presetRange(days) {
|
|
|
1454
1454
|
to: format(now)
|
|
1455
1455
|
};
|
|
1456
1456
|
}
|
|
1457
|
+
const LOCAL_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
1458
|
+
/**
|
|
1459
|
+
* Una fecha local `YYYY-MM-DD` convertida al INSTANTE que la limita, en ISO 8601 UTC (DEV-6425).
|
|
1460
|
+
*
|
|
1461
|
+
* El servicio filtra `from <= last_message_at <= to` sobre `timestamptz` y a una fecha sola la lee
|
|
1462
|
+
* como las 00:00 **UTC** de ese día (`_assume_utc` de `app/routes/conversations.py`). Mandar
|
|
1463
|
+
* `to=2026-09-25` dejaba afuera TODO lo de hoy, y el corte ni siquiera era la medianoche del
|
|
1464
|
+
* operador. Por eso el día local se traduce acá a sus dos bordes:
|
|
1465
|
+
*
|
|
1466
|
+
* - `'start'` ⇒ 00:00:00.000 local de ese día;
|
|
1467
|
+
* - `'end'` ⇒ 23:59:59.999 local de ese día (el rango del servicio es INCLUSIVO).
|
|
1468
|
+
*
|
|
1469
|
+
* Sale con `Z` (vía `toISOString`) y no con el offset local a propósito: un `-05:00` viaja bien,
|
|
1470
|
+
* pero un `+01:00` armado a mano en una query string se decodifica como espacio y el servicio
|
|
1471
|
+
* responde 422. Con `Z` no hay signo que codificar, cualquiera sea el fetcher del host.
|
|
1472
|
+
*
|
|
1473
|
+
* Los componentes se pasan al constructor de `Date` en hora local, así que un día de 23 o 25 horas
|
|
1474
|
+
* (cambio de horario) queda bien sin aritmética de milisegundos. Algo que no sea `YYYY-MM-DD` viaja
|
|
1475
|
+
* tal cual: no se adivina un formato que no es el del formulario.
|
|
1476
|
+
*/
|
|
1477
|
+
function dayBound(value, edge) {
|
|
1478
|
+
const match = LOCAL_DATE.exec(value);
|
|
1479
|
+
if (match === null) return value;
|
|
1480
|
+
const [year, month, day] = [
|
|
1481
|
+
Number(match[1]),
|
|
1482
|
+
Number(match[2]) - 1,
|
|
1483
|
+
Number(match[3])
|
|
1484
|
+
];
|
|
1485
|
+
return (edge === "start" ? new Date(year, month, day, 0, 0, 0, 0) : new Date(year, month, day, 23, 59, 59, 999)).toISOString();
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* La consulta que sale del formulario — UN solo lugar para los tres caminos (submit, presets y
|
|
1489
|
+
* «Rango…»). El teléfono viaja tal cual; lo vacío se omite, para que el descriptor no lleve claves
|
|
1490
|
+
* que el host tendría que aprender a ignorar; las fechas pasan por `dayBound`.
|
|
1491
|
+
*/
|
|
1492
|
+
function buildFilters(phone, from, to) {
|
|
1493
|
+
const next = {};
|
|
1494
|
+
if (phone.trim() !== "") next.phone = phone;
|
|
1495
|
+
if (from !== "") next.from = dayBound(from, "start");
|
|
1496
|
+
if (to !== "") next.to = dayBound(to, "end");
|
|
1497
|
+
return next;
|
|
1498
|
+
}
|
|
1457
1499
|
function ConversationList({ fetcher, selectedPhone, onSelect, refreshIntervalMs, className }) {
|
|
1458
1500
|
const fieldId = useId();
|
|
1459
1501
|
/**
|
|
@@ -1484,11 +1526,7 @@ function ConversationList({ fetcher, selectedPhone, onSelect, refreshIntervalMs,
|
|
|
1484
1526
|
}, [onSelect]);
|
|
1485
1527
|
const applyFilters = (event) => {
|
|
1486
1528
|
event.preventDefault();
|
|
1487
|
-
|
|
1488
|
-
if (phone.trim() !== "") next.phone = phone;
|
|
1489
|
-
if (from !== "") next.from = from;
|
|
1490
|
-
if (to !== "") next.to = to;
|
|
1491
|
-
setFilters(next);
|
|
1529
|
+
setFilters(buildFilters(phone, from, to));
|
|
1492
1530
|
};
|
|
1493
1531
|
/**
|
|
1494
1532
|
* Un preset ≠ «Rango…» aplica AL CLIC: calcula el rango, sincroniza los date inputs (por si el
|
|
@@ -1500,11 +1538,7 @@ function ConversationList({ fetcher, selectedPhone, onSelect, refreshIntervalMs,
|
|
|
1500
1538
|
const range = presetRange(days);
|
|
1501
1539
|
setFrom(range.from);
|
|
1502
1540
|
setTo(range.to);
|
|
1503
|
-
|
|
1504
|
-
if (phone.trim() !== "") next.phone = phone;
|
|
1505
|
-
next.from = range.from;
|
|
1506
|
-
next.to = range.to;
|
|
1507
|
-
setFilters(next);
|
|
1541
|
+
setFilters(buildFilters(phone, range.from, range.to));
|
|
1508
1542
|
};
|
|
1509
1543
|
/**
|
|
1510
1544
|
* El rango aplica al cambiar cualquiera de las dos fechas, sin botón de confirmación. Recibe los
|
|
@@ -1518,11 +1552,7 @@ function ConversationList({ fetcher, selectedPhone, onSelect, refreshIntervalMs,
|
|
|
1518
1552
|
setDatePreset("range");
|
|
1519
1553
|
setFrom(nextFrom);
|
|
1520
1554
|
setTo(nextTo);
|
|
1521
|
-
|
|
1522
|
-
if (phone.trim() !== "") next.phone = phone;
|
|
1523
|
-
if (nextFrom !== "") next.from = nextFrom;
|
|
1524
|
-
if (nextTo !== "") next.to = nextTo;
|
|
1525
|
-
setFilters(next);
|
|
1555
|
+
setFilters(buildFilters(phone, nextFrom, nextTo));
|
|
1526
1556
|
};
|
|
1527
1557
|
const clearFilters = () => {
|
|
1528
1558
|
setPhone("");
|
|
@@ -1745,7 +1775,8 @@ function ConversationList({ fetcher, selectedPhone, onSelect, refreshIntervalMs,
|
|
|
1745
1775
|
*
|
|
1746
1776
|
* El relanzamiento **en frío con plantilla** existe, pero **no en este visor**: vive en el
|
|
1747
1777
|
* header del drawer del embudo de `lms-mf-lifters`, que es donde el MF ya tiene cargado el
|
|
1748
|
-
* detalle del embudo.
|
|
1778
|
+
* detalle del embudo. Este visor no lo menciona (DEV-6309: también monta en la pantalla 13
|
|
1779
|
+
* del caso, que no tiene embudo) — ni lo nombra ni lo ejecuta.
|
|
1749
1780
|
*/
|
|
1750
1781
|
/**
|
|
1751
1782
|
* El aviso de los envíos que no salieron.
|
|
@@ -1789,14 +1820,15 @@ function FailureNotice({ composer }) {
|
|
|
1789
1820
|
* conversación» rompe COMP-06 aunque el código siga funcionando — y ahora además sería falso: el
|
|
1790
1821
|
* endpoint ya no reactiva nada.
|
|
1791
1822
|
*
|
|
1792
|
-
*
|
|
1793
|
-
* el
|
|
1823
|
+
* No menciona plantillas ni cómo retomarla en frío (DEV-6309, decisión de David): el visor monta en
|
|
1824
|
+
* hosts distintos, «el header del drawer del embudo» mandaba al analista de la pantalla 13 a un
|
|
1825
|
+
* lugar que ahí no existe, y hablar de plantillas sugería construir algo que no se va a hacer.
|
|
1794
1826
|
*/
|
|
1795
1827
|
function ReleaseToBot({ composer }) {
|
|
1796
1828
|
if (composer.releaseState === "released") return /* @__PURE__ */ jsx("p", {
|
|
1797
1829
|
className: "wa-composer__released",
|
|
1798
1830
|
role: "status",
|
|
1799
|
-
children: "Listo: la conversación volvió al bot. La ventana sigue cerrada — se abre cuando la persona responda.
|
|
1831
|
+
children: "Listo: la conversación volvió al bot. La ventana sigue cerrada — se abre cuando la persona responda."
|
|
1800
1832
|
});
|
|
1801
1833
|
return /* @__PURE__ */ jsxs("div", {
|
|
1802
1834
|
className: "wa-composer__release",
|
|
@@ -1804,10 +1836,10 @@ function ReleaseToBot({ composer }) {
|
|
|
1804
1836
|
/* @__PURE__ */ jsxs("p", {
|
|
1805
1837
|
className: "wa-composer__release-explain",
|
|
1806
1838
|
children: [
|
|
1807
|
-
"
|
|
1839
|
+
"Puedes devolver la conversación al bot: se suelta el control y el bot vuelve a manejarla.",
|
|
1808
1840
|
" ",
|
|
1809
|
-
/* @__PURE__ */ jsx("strong", { children: "No se le manda ningún mensaje a la persona y no te habilita
|
|
1810
|
-
" — si responde, la ventana se abre y el composer vuelve solo.
|
|
1841
|
+
/* @__PURE__ */ jsx("strong", { children: "No se le manda ningún mensaje a la persona y no te habilita para seguir escribiendo" }),
|
|
1842
|
+
" — si responde, la ventana se abre y el composer vuelve solo."
|
|
1811
1843
|
]
|
|
1812
1844
|
}),
|
|
1813
1845
|
composer.releaseState === "error" && composer.releaseFailure !== null && /* @__PURE__ */ jsx("p", {
|
|
@@ -1954,10 +1986,10 @@ function Composer({ canReply, composer, onRetryWindow, prefill, locked = false,
|
|
|
1954
1986
|
maxLength: REPLY_TEXT_MAX_LENGTH,
|
|
1955
1987
|
rows: 2,
|
|
1956
1988
|
value: draft,
|
|
1957
|
-
placeholder: "
|
|
1989
|
+
placeholder: "Escribe tu respuesta…",
|
|
1958
1990
|
"aria-label": "Mensaje para la persona",
|
|
1959
1991
|
disabled: locked,
|
|
1960
|
-
"aria-describedby": takeoverNotice !== null ? noticeId : void 0,
|
|
1992
|
+
"aria-describedby": takeoverNotice !== null || locked ? noticeId : void 0,
|
|
1961
1993
|
onChange: (event) => setDraft(event.target.value),
|
|
1962
1994
|
onKeyDown: (event) => {
|
|
1963
1995
|
if (event.key !== "Enter" || event.shiftKey || event.nativeEvent.isComposing) return;
|
|
@@ -1972,6 +2004,11 @@ function Composer({ canReply, composer, onRetryWindow, prefill, locked = false,
|
|
|
1972
2004
|
"data-takeover": "true",
|
|
1973
2005
|
id: noticeId,
|
|
1974
2006
|
children: takeoverNotice
|
|
2007
|
+
}) : locked ? /* @__PURE__ */ jsx("span", {
|
|
2008
|
+
className: "wa-composer__hint",
|
|
2009
|
+
"data-locked": "true",
|
|
2010
|
+
id: noticeId,
|
|
2011
|
+
children: "Pulsa «Escribir igual» para responder"
|
|
1975
2012
|
}) : /* @__PURE__ */ jsx("span", {
|
|
1976
2013
|
className: "wa-composer__hint",
|
|
1977
2014
|
children: "Al enviar, el bot se pausa y la conversación queda tomada por ti"
|
|
@@ -2214,10 +2251,12 @@ function ImageAttachment({ message, fetcher, mediaId }) {
|
|
|
2214
2251
|
useEffect(() => {
|
|
2215
2252
|
if (!open) return;
|
|
2216
2253
|
const handleKeyDown = (event) => {
|
|
2217
|
-
if (event.key
|
|
2254
|
+
if (event.key !== "Escape") return;
|
|
2255
|
+
event.stopPropagation();
|
|
2256
|
+
setOpen(false);
|
|
2218
2257
|
};
|
|
2219
|
-
|
|
2220
|
-
return () =>
|
|
2258
|
+
window.addEventListener("keydown", handleKeyDown, true);
|
|
2259
|
+
return () => window.removeEventListener("keydown", handleKeyDown, true);
|
|
2221
2260
|
}, [open]);
|
|
2222
2261
|
const handleImageError = () => {
|
|
2223
2262
|
if (retriedRef.current) {
|
|
@@ -2308,7 +2347,10 @@ function DownloadAttachment({ message, fetcher, mediaId, variant = "label" }) {
|
|
|
2308
2347
|
return;
|
|
2309
2348
|
}
|
|
2310
2349
|
event.preventDefault();
|
|
2311
|
-
loadMedia(fetcher, {
|
|
2350
|
+
loadMedia(fetcher, {
|
|
2351
|
+
mediaId,
|
|
2352
|
+
download: true
|
|
2353
|
+
}).then((descriptor) => {
|
|
2312
2354
|
if (!mountedRef.current) return;
|
|
2313
2355
|
const anchor = anchorRef.current;
|
|
2314
2356
|
if (anchor === null) return;
|
|
@@ -4595,14 +4637,29 @@ function ConversationThread({ fetcher, phone, displayName, refreshIntervalMs, cl
|
|
|
4595
4637
|
* volver a preguntarlo en cada latido sería un botón que se enciende solo cada 10 s.
|
|
4596
4638
|
*
|
|
4597
4639
|
* `focus` es una caja nueva por clic: el disparador del foco del composer (ver `focusRequest`).
|
|
4640
|
+
*
|
|
4641
|
+
* DEV-6419: además de la conversación, el desbloqueo guarda **a qué toma** se le dijo que sí —
|
|
4642
|
+
* `taken_by` + `taken_at`—. El operador aceptó escribir encima de Paula, no de quien venga
|
|
4643
|
+
* después: si en la misma sesión la toma pasa de Paula a Carlos, el sobre trae otra identidad y
|
|
4644
|
+
* el composer vuelve a bloquearse hasta un nuevo «Escribir igual». Un latido que renueva la
|
|
4645
|
+
* misma toma no la cambia: el servicio no mueve `taken_at` cuando quien escribe es quien ya la
|
|
4646
|
+
* tiene (`record_takeover`), así que la comparación es estable entre refetches. Si la toma se
|
|
4647
|
+
* libera o pasa a ser mía, `foreignLive` se apaga y mandan esos estados, no este.
|
|
4598
4648
|
*/
|
|
4599
4649
|
const [writeAnyway, setWriteAnyway] = useState(null);
|
|
4600
|
-
const unlocked = writeAnyway !== null && writeAnyway.fetcher === fetcher && writeAnyway.phone === phone;
|
|
4650
|
+
const unlocked = writeAnyway !== null && writeAnyway.fetcher === fetcher && writeAnyway.phone === phone && writeAnyway.takenBy === takenBy && writeAnyway.takenAt === takenAt;
|
|
4601
4651
|
const handleWriteAnyway = useCallback(() => setWriteAnyway({
|
|
4602
4652
|
fetcher,
|
|
4603
4653
|
phone,
|
|
4654
|
+
takenBy,
|
|
4655
|
+
takenAt,
|
|
4604
4656
|
focus: {}
|
|
4605
|
-
}), [
|
|
4657
|
+
}), [
|
|
4658
|
+
fetcher,
|
|
4659
|
+
phone,
|
|
4660
|
+
takenBy,
|
|
4661
|
+
takenAt
|
|
4662
|
+
]);
|
|
4606
4663
|
/**
|
|
4607
4664
|
* ¿Hay una toma AJENA vigente? (DEV-6309) De esto dependen a la vez la barra ámbar, el bloqueo
|
|
4608
4665
|
* del composer y el aviso del pie — por eso se decide una sola vez, acá.
|
package/package.json
CHANGED