@fayz-ai/plugin-conversations 0.28.0 → 0.30.0
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/{CampaignsSurface-75POQIRI.js → CampaignsSurface-DK7JSM3Y.js} +32 -14
- package/dist/CampaignsSurface-DK7JSM3Y.js.map +1 -0
- package/dist/{ConversationsPage-2D343Q5P.js → ConversationsPage-VXGZBHZG.js} +305 -99
- package/dist/ConversationsPage-VXGZBHZG.js.map +1 -0
- package/dist/{TemplatesSurface-QNTRYYTX.js → TemplatesSurface-6ICY3LS7.js} +54 -8
- package/dist/TemplatesSurface-6ICY3LS7.js.map +1 -0
- package/dist/{chunk-4OWC3V53.js → chunk-GDB5UCPB.js} +43 -7
- package/dist/chunk-GDB5UCPB.js.map +1 -0
- package/dist/components/Composer.d.ts +14 -0
- package/dist/components/Composer.d.ts.map +1 -0
- package/dist/components/InboxWatcher.d.ts.map +1 -1
- package/dist/data/journeys.d.ts +16 -1
- package/dist/data/journeys.d.ts.map +1 -1
- package/dist/data/media.d.ts +13 -0
- package/dist/data/media.d.ts.map +1 -0
- package/dist/index.js +76 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/media-cache.d.ts +6 -0
- package/dist/lib/media-cache.d.ts.map +1 -0
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/main.browser.js +3 -1
- package/dist/migrations/main.browser.js.map +1 -1
- package/dist/migrations/main.js +32 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/store.d.ts +7 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/views/MediaBubble.d.ts.map +1 -1
- package/dist/views/MessageThread.d.ts.map +1 -1
- package/dist/views/campaigns/CampaignWizard.d.ts.map +1 -1
- package/dist/views/campaigns/TemplatesSurface.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/CampaignsSurface-75POQIRI.js.map +0 -1
- package/dist/ConversationsPage-2D343Q5P.js.map +0 -1
- package/dist/TemplatesSurface-QNTRYYTX.js.map +0 -1
- package/dist/chunk-4OWC3V53.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { T, listMessagingChannels, findDedicatedChannel, findFallbackChannel, is
|
|
|
4
4
|
export { listMessagingChannels } from './chunk-W5VV6G35.js';
|
|
5
5
|
import { providersApi } from './chunk-HMWUU5O7.js';
|
|
6
6
|
export { providersApi } from './chunk-HMWUU5O7.js';
|
|
7
|
-
export { journeysApi, previewBody, templateWarnings } from './chunk-
|
|
7
|
+
export { journeysApi, previewBody, templateWarnings } from './chunk-GDB5UCPB.js';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import React__default, { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
10
10
|
import { Loader2, Check, ShieldCheck, ShieldAlert, RefreshCw, QrCode, Zap, ExternalLink } from 'lucide-react';
|
|
@@ -346,12 +346,14 @@ function InboxWatcher({ label, route = "/conversations", section = "main", posit
|
|
|
346
346
|
const contar = React.useCallback(async () => {
|
|
347
347
|
const supabase = getSupabaseClientOptional();
|
|
348
348
|
if (!supabase) return;
|
|
349
|
-
const { data } = await supabase.from(T.conversations).select("id, status, last_message_direction, unread_count").eq("status", "open");
|
|
349
|
+
const { data } = await supabase.from(T.conversations).select("id, status, last_message_direction, unread_count, acknowledged_at, last_message_at").eq("status", "open");
|
|
350
350
|
if (!data) return;
|
|
351
351
|
const n = data.filter((r) => isWaitingOnUs({
|
|
352
352
|
status: r.status,
|
|
353
353
|
lastMessageDirection: r.last_message_direction ?? void 0,
|
|
354
|
-
unreadCount: r.unread_count ?? 0
|
|
354
|
+
unreadCount: r.unread_count ?? 0,
|
|
355
|
+
acknowledgedAt: r.acknowledged_at ?? void 0,
|
|
356
|
+
lastMessageAt: r.last_message_at ?? void 0
|
|
355
357
|
})).length;
|
|
356
358
|
setNaoLidas(n);
|
|
357
359
|
}, []);
|
|
@@ -893,6 +895,44 @@ function createSupabaseConversationsProvider(config) {
|
|
|
893
895
|
}
|
|
894
896
|
};
|
|
895
897
|
}
|
|
898
|
+
var MEDIA_LIMIT_MB = { media: 16, document: 100 };
|
|
899
|
+
function toBase64(blob) {
|
|
900
|
+
return new Promise((resolve, reject) => {
|
|
901
|
+
const reader = new FileReader();
|
|
902
|
+
reader.onload = () => resolve(String(reader.result ?? "").replace(/^data:[^;]*;base64,/u, ""));
|
|
903
|
+
reader.onerror = () => reject(reader.error ?? new Error("N\xE3o foi poss\xEDvel ler o arquivo"));
|
|
904
|
+
reader.readAsDataURL(blob);
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
async function sendMedia(input) {
|
|
908
|
+
const client3 = getSupabaseClientOptional();
|
|
909
|
+
const tenantId = getActiveTenantId();
|
|
910
|
+
if (!client3 || !tenantId) throw new Error("Sem conex\xE3o com a casa");
|
|
911
|
+
const mimetype = input.file.type || "application/octet-stream";
|
|
912
|
+
const isDoc = !/^(image|video|audio)\//u.test(mimetype);
|
|
913
|
+
const limit = (isDoc ? MEDIA_LIMIT_MB.document : MEDIA_LIMIT_MB.media) * 1024 * 1024;
|
|
914
|
+
if (input.file.size > limit) throw new Error(`Arquivo maior que ${isDoc ? MEDIA_LIMIT_MB.document : MEDIA_LIMIT_MB.media} MB, o limite do WhatsApp`);
|
|
915
|
+
const data = await toBase64(input.file);
|
|
916
|
+
const { data: out, error } = await client3.functions.invoke("conversations-provider", {
|
|
917
|
+
body: {
|
|
918
|
+
tenantId,
|
|
919
|
+
action: "send_media",
|
|
920
|
+
conversationId: input.conversationId,
|
|
921
|
+
data,
|
|
922
|
+
mimetype,
|
|
923
|
+
fileName: input.fileName ?? input.file.name ?? null,
|
|
924
|
+
caption: input.caption ?? "",
|
|
925
|
+
ptt: input.ptt === true
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
if (error) {
|
|
929
|
+
const detail = await error.context?.json?.().catch(() => null);
|
|
930
|
+
throw new Error(detail?.message ?? error.message);
|
|
931
|
+
}
|
|
932
|
+
if (out?.error) throw new Error(out.message ?? out.error);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// src/store.ts
|
|
896
936
|
function handleKey(h) {
|
|
897
937
|
const v = (h ?? "").trim();
|
|
898
938
|
if (!v) return "";
|
|
@@ -1016,6 +1056,17 @@ function createConversationsStore(provider) {
|
|
|
1016
1056
|
channel
|
|
1017
1057
|
});
|
|
1018
1058
|
},
|
|
1059
|
+
async sendMedia(input) {
|
|
1060
|
+
const id = get().selectedId;
|
|
1061
|
+
if (!id) return;
|
|
1062
|
+
set({ sending: true });
|
|
1063
|
+
try {
|
|
1064
|
+
await sendMedia({ conversationId: id, ...input });
|
|
1065
|
+
} finally {
|
|
1066
|
+
set({ sending: false });
|
|
1067
|
+
await get().refreshMessages();
|
|
1068
|
+
}
|
|
1069
|
+
},
|
|
1019
1070
|
async send(body) {
|
|
1020
1071
|
const id = get().selectedId;
|
|
1021
1072
|
if (!id || !body.trim()) return;
|
|
@@ -1055,6 +1106,15 @@ function createConversationsStore(provider) {
|
|
|
1055
1106
|
|
|
1056
1107
|
// src/locales/en.ts
|
|
1057
1108
|
var en = {
|
|
1109
|
+
"conversations.composer.attach": "Attach photo, video or document",
|
|
1110
|
+
"conversations.composer.record": "Record audio",
|
|
1111
|
+
"conversations.composer.recording": "Recording\u2026 click the square to send",
|
|
1112
|
+
"conversations.composer.discard": "Discard audio",
|
|
1113
|
+
"conversations.composer.caption": "Add a caption (optional)",
|
|
1114
|
+
"conversations.composer.captionHint": "the text becomes the caption",
|
|
1115
|
+
"conversations.composer.removeFile": "Remove file",
|
|
1116
|
+
"conversations.composer.noMic": "This browser cannot record audio.",
|
|
1117
|
+
"conversations.composer.micDenied": "No microphone access. Allow it in the browser permissions.",
|
|
1058
1118
|
"conversations.bubble.forwarded": "Forwarded",
|
|
1059
1119
|
"conversations.bubble.forwardedMany": "Forwarded many times",
|
|
1060
1120
|
"conversations.bubble.poll": "Poll",
|
|
@@ -1210,6 +1270,15 @@ var en = {
|
|
|
1210
1270
|
|
|
1211
1271
|
// src/locales/pt-BR.ts
|
|
1212
1272
|
var ptBR = {
|
|
1273
|
+
"conversations.composer.attach": "Anexar foto, v\xEDdeo ou documento",
|
|
1274
|
+
"conversations.composer.record": "Gravar \xE1udio",
|
|
1275
|
+
"conversations.composer.recording": "Gravando\u2026 clique no quadrado para enviar",
|
|
1276
|
+
"conversations.composer.discard": "Descartar \xE1udio",
|
|
1277
|
+
"conversations.composer.caption": "Adicione uma legenda (opcional)",
|
|
1278
|
+
"conversations.composer.captionHint": "o texto vira a legenda",
|
|
1279
|
+
"conversations.composer.removeFile": "Remover arquivo",
|
|
1280
|
+
"conversations.composer.noMic": "Este navegador n\xE3o grava \xE1udio.",
|
|
1281
|
+
"conversations.composer.micDenied": "Sem acesso ao microfone. Libere nas permiss\xF5es do navegador.",
|
|
1213
1282
|
"conversations.bubble.forwarded": "Encaminhada",
|
|
1214
1283
|
"conversations.bubble.forwardedMany": "Encaminhada com frequ\xEAncia",
|
|
1215
1284
|
"conversations.bubble.poll": "Enquete",
|
|
@@ -2376,12 +2445,12 @@ function createConversationsPlugin(options) {
|
|
|
2376
2445
|
locales: conversationsLocales
|
|
2377
2446
|
};
|
|
2378
2447
|
}
|
|
2379
|
-
var ConversationsPage = React__default.lazy(() => import('./ConversationsPage-
|
|
2448
|
+
var ConversationsPage = React__default.lazy(() => import('./ConversationsPage-VXGZBHZG.js').then((m) => ({ default: m.ConversationsPage })));
|
|
2380
2449
|
var AtendeAIPage = React__default.lazy(() => import('./AtendeAIPage-PBBMWIDW.js').then((m) => ({ default: m.AtendeAIPage })));
|
|
2381
2450
|
var ConversationsSettingsTab = lazyComponent(() => import('./ConversationsSettings-GORCWUHD.js').then((m) => m.ConversationsSettingsTab));
|
|
2382
|
-
var CampaignsSurface = React__default.lazy(() => import('./CampaignsSurface-
|
|
2383
|
-
var SendHistorySurface = React__default.lazy(() => import('./CampaignsSurface-
|
|
2384
|
-
var TemplatesSurface = React__default.lazy(() => import('./TemplatesSurface-
|
|
2451
|
+
var CampaignsSurface = React__default.lazy(() => import('./CampaignsSurface-DK7JSM3Y.js').then((m) => ({ default: m.CampaignsSurface })));
|
|
2452
|
+
var SendHistorySurface = React__default.lazy(() => import('./CampaignsSurface-DK7JSM3Y.js').then((m) => ({ default: m.SendHistorySurface })));
|
|
2453
|
+
var TemplatesSurface = React__default.lazy(() => import('./TemplatesSurface-6ICY3LS7.js').then((m) => ({ default: m.TemplatesSurface })));
|
|
2385
2454
|
|
|
2386
2455
|
export { CampaignsSurface, PAYMENT_PREFLIGHT_FUNCTION, SendHistorySurface, TYXTER_CONNECTOR_ID, TYXTER_LATENCY_BUDGET_MS, TemplatesSurface, WhatsAppProviders, campaignsApi, canOfferPayment, createConversationsPlugin, createMockConversationsProvider, createSupabaseConversationsProvider, openPaymentSetupSession, readPaymentReadiness, tyxterConnectorDef };
|
|
2387
2456
|
//# sourceMappingURL=index.js.map
|