@adatechnology/conversations-ui 0.1.0-rc.4 → 0.1.0-rc.6
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/chunk-LITPZCWW.js +1465 -0
- package/dist/index.d.ts +223 -29
- package/dist/index.js +316 -366
- package/dist/preview/index.d.ts +92 -3
- package/dist/preview/index.js +627 -103
- package/dist/types-CeixG2Z9.d.ts +324 -0
- package/package.json +2 -2
- package/src/Avatar.tsx +13 -2
- package/src/ConversationDocumentsPanel.tsx +342 -24
- package/src/ConversationListItem.tsx +18 -2
- package/src/DocumentsLibrary.tsx +322 -0
- package/src/FileIcon.test.ts +83 -0
- package/src/FileIcon.tsx +88 -11
- package/src/Lightbox.tsx +18 -3
- package/src/MediaRenderer.tsx +5 -2
- package/src/MessageBubble.tsx +18 -2
- package/src/MessageComposer.tsx +20 -3
- package/src/WhatsAppMessageEditor.tsx +28 -4
- package/src/hooks/useConversationActions.ts +56 -0
- package/src/hooks/useConversationDocuments.ts +11 -7
- package/src/hooks/useConversationList.ts +15 -9
- package/src/hooks/useConversationMessages.ts +2 -2
- package/src/index.ts +32 -11
- package/src/lib/cn.test.ts +29 -0
- package/src/lib/createMediaUrlResolver.ts +33 -0
- package/src/lib/paginated.test.ts +33 -0
- package/src/lib/paginated.ts +26 -0
- package/src/preview/MediaTypesPreview.tsx +87 -0
- package/src/preview/createMockConversationsApi.ts +175 -15
- package/src/preview/index.ts +6 -1
- package/src/preview/mockDocumentsSearch.test.ts +57 -0
- package/src/preview/preview.test.ts +5 -3
- package/src/preview/previewFileSamples.test.ts +151 -0
- package/src/preview/previewFileSamples.ts +74 -0
- package/src/preview/previewFixtures.ts +288 -1
- package/src/preview/previewMediaSource.test.ts +62 -0
- package/src/preview/previewMediaSource.ts +91 -0
- package/src/providers/types.ts +127 -9
- package/src/settings/WhatsAppCreateTemplateForm.tsx +3 -1
- package/src/useWaitingNotifications.ts +74 -29
- package/dist/chunk-4R6Y43DQ.js +0 -726
- package/dist/types-C0PtaO7S.d.ts +0 -207
package/dist/preview/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as MessagePayload, m as ConversationSummary, k as ConversationEventSource, o as ConversationsApi, L as ListConversationsParams, l as ConversationPage, S as SSEProvider, i as ConversationDocument, x as ResolveMediaUrl } from '../types-CeixG2Z9.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { InteractiveReplyOption } from '@adatechnology/meta-whatsapp-contracts/testing';
|
|
4
4
|
|
|
@@ -81,7 +81,15 @@ type CreateMockConversationsApiParams = {
|
|
|
81
81
|
readonly latencyMs?: number;
|
|
82
82
|
readonly agentName?: string;
|
|
83
83
|
};
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
|
+
* O mock satisfaz `ConversationsApi`, mas com o retorno de `fetchConversations` ESTREITADO para a
|
|
86
|
+
* forma paginada. Sem isto o contrato — que aceita array ou página — obrigaria todo consumidor do
|
|
87
|
+
* preview a desempacotar uma união que aqui nunca varia.
|
|
88
|
+
*/
|
|
89
|
+
type MockConversationsApi = Omit<ConversationsApi, 'fetchConversations'> & {
|
|
90
|
+
fetchConversations(params?: ListConversationsParams): Promise<ConversationPage>;
|
|
91
|
+
};
|
|
92
|
+
declare function createMockConversationsApi(params: CreateMockConversationsApiParams): MockConversationsApi;
|
|
85
93
|
|
|
86
94
|
/**
|
|
87
95
|
* `SSEProvider` servido pelo store em memória. Mesmo mapeamento de canal do servidor
|
|
@@ -101,6 +109,7 @@ declare function createMockSSEProvider(params: CreateMockSSEProviderParams): SSE
|
|
|
101
109
|
|
|
102
110
|
declare const PREVIEW_CONVERSATIONS: readonly ConversationSummary[];
|
|
103
111
|
declare const PREVIEW_MESSAGES: Readonly<Record<string, readonly MessagePayload[]>>;
|
|
112
|
+
declare const PREVIEW_DOCUMENTS: Readonly<Record<string, readonly ConversationDocument[]>>;
|
|
104
113
|
|
|
105
114
|
/**
|
|
106
115
|
* Cliente que entrega mensagens do preview no webhook real, assinadas com HMAC — a mesma validação
|
|
@@ -169,4 +178,84 @@ type StartPreviewScriptParams = {
|
|
|
169
178
|
};
|
|
170
179
|
declare function startPreviewScript(params: StartPreviewScriptParams): () => void;
|
|
171
180
|
|
|
172
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Bytes de verdade para o preview abrir.
|
|
183
|
+
*
|
|
184
|
+
* O mock antes devolvia a MESMA imagem PNG para qualquer documento, então clicar em "visualizar" num
|
|
185
|
+
* PDF entregava um PNG rotulado `application/pdf` e o leitor dizia que o arquivo era inválido. Cada
|
|
186
|
+
* amostra aqui é um arquivo mínimo porém legítimo do seu tipo: as de mídia foram geradas com ffmpeg
|
|
187
|
+
* e conferidas com ffprobe, o PDF tem xref/startxref/%%EOF, e os pacotes Office são zips com as
|
|
188
|
+
* partes obrigatórias (`[Content_Types].xml`, `_rels/.rels`, o documento).
|
|
189
|
+
*
|
|
190
|
+
* Não há amostra de `audio/amr`, `video/3gp` nem dos formatos binários legados do Office
|
|
191
|
+
* (`application/msword`, `application/vnd.ms-excel`, `application/vnd.ms-powerpoint`): não há
|
|
192
|
+
* encoder para eles nesta máquina e forjar OLE2 à mão daria arquivo corrompido — exatamente o que
|
|
193
|
+
* este módulo existe para evitar. Esses caem no texto explicativo de `resolvePreviewFileSample`,
|
|
194
|
+
* que abre sem erro e diz o que é.
|
|
195
|
+
*
|
|
196
|
+
* GERADO — não editar à mão.
|
|
197
|
+
*/
|
|
198
|
+
declare const PREVIEW_FILE_SAMPLES: Readonly<Record<string, string>>;
|
|
199
|
+
/**
|
|
200
|
+
* A data URL que o preview abre para um documento.
|
|
201
|
+
*
|
|
202
|
+
* Ordem: tipo exato → família (`audio/amr` toca como mp3, `video/3gp` como mp4) → nota em texto.
|
|
203
|
+
* A nota fecha o caso dos tipos sem amostra: abre num leitor de texto e explica, em vez de baixar
|
|
204
|
+
* um binário quebrado com extensão de Word.
|
|
205
|
+
*/
|
|
206
|
+
declare function resolvePreviewFileSample(mimeType: string | undefined, filename?: string): string;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Como o preview entrega mídia para a UI abrir.
|
|
210
|
+
*
|
|
211
|
+
* Separado de `previewFileSamples` (que é gerado) porque aqui está a parte que depende do navegador:
|
|
212
|
+
* **blob URL, não data URL**. O Chrome bloqueia navegação de topo para `data:` desde a v60, então
|
|
213
|
+
* `window.open(dataUrl)` — que é o que os botões "visualizar" e "baixar" fazem — abre aba em branco
|
|
214
|
+
* mesmo com bytes perfeitamente válidos. Em `src` de `<img>`/`<video>` a data URL funcionaria; no
|
|
215
|
+
* `window.open` não, e o mesmo `getDocumentUrl` alimenta os dois.
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
/** URL que o preview pode abrir em aba nova. Cai na data URL fora do navegador (teste, SSR). */
|
|
219
|
+
declare function previewFileUrl(mimeType: string | undefined, filename?: string): string;
|
|
220
|
+
/**
|
|
221
|
+
* A mesma amostra em base64 cru, como o proxy de mídia do backend a devolveria.
|
|
222
|
+
*
|
|
223
|
+
* Existe porque `getMediaProxyUrl` é o caminho da mídia AINDA NÃO ingerida (só existe o id na Meta),
|
|
224
|
+
* e o contrato pede `{ mimeType, data }` — não URL. Sem isto o mock devolvia o PNG 1x1 para
|
|
225
|
+
* qualquer id, e vídeo e áudio da thread apareciam quebrados apesar de haver amostra válida.
|
|
226
|
+
*/
|
|
227
|
+
declare function previewFileBase64(mimeType: string | undefined, filename?: string): {
|
|
228
|
+
mimeType: string;
|
|
229
|
+
data: string;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* O `onResolveMediaUrl` que o `MessageBubble` espera.
|
|
233
|
+
*
|
|
234
|
+
* Sem ele, foto, vídeo e áudio da thread ficam parados no placeholder para sempre — o
|
|
235
|
+
* `MediaRenderer` só resolve `uploadId`/`mediaId` por esta porta, de propósito, para o pacote nunca
|
|
236
|
+
* chamar endpoint fixo. O preview não tinha resolvedor nenhum, então nenhuma mídia carregava.
|
|
237
|
+
*/
|
|
238
|
+
declare function createPreviewMediaResolver(): ResolveMediaUrl;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Bancada de teste manual de mídia — montável em uma linha por qualquer projeto que adote o SDK.
|
|
242
|
+
*
|
|
243
|
+
* Existe porque o defeito que ela pega não é pegável por teste automatizado: "o PDF abre?" depende
|
|
244
|
+
* do leitor do navegador, "o vídeo toca?" do decodificador, e "a aba abre?" da política do Chrome
|
|
245
|
+
* sobre `data:` URL. Teste unitário confere bytes; só o olho confere que o arquivo abre. Sem uma
|
|
246
|
+
* superfície pronta no pacote, cada projeto teria de montar a sua — e, na prática, nenhum montava.
|
|
247
|
+
*
|
|
248
|
+
* Traz o próprio store, o próprio mock e o próprio provider: o host não injeta nada. E não passa
|
|
249
|
+
* `onResolveMediaUrl` em lugar nenhum de propósito — é o `MessageBubble` resolvendo mídia pelo
|
|
250
|
+
* `ConversationsApi` do contexto, então se essa resolução automática quebrar, esta tela mostra.
|
|
251
|
+
*/
|
|
252
|
+
/** A conversa do fixture que carrega uma mensagem de cada tipo aceito. */
|
|
253
|
+
declare const MEDIA_TYPES_CONVERSATION_ID = "5511944443333";
|
|
254
|
+
type MediaTypesPreviewProps = {
|
|
255
|
+
/** Outra conversa do fixture, se o projeto tiver acrescentado a sua. */
|
|
256
|
+
conversationId?: string;
|
|
257
|
+
className?: string;
|
|
258
|
+
};
|
|
259
|
+
declare function MediaTypesPreview({ conversationId, className, }: MediaTypesPreviewProps): react.JSX.Element;
|
|
260
|
+
|
|
261
|
+
export { type AppendMessageParams, ConversationPreview, type ConversationPreviewProps, type CreateMockConversationsApiParams, type CreateMockSSEProviderParams, type CreatePreviewStoreParams, type CreatePreviewWebhookClientParams, DEFAULT_PREVIEW_SCRIPT, GLOBAL_CHANNEL, type ListConversationsFilters, MEDIA_TYPES_CONVERSATION_ID, MediaTypesPreview, type MediaTypesPreviewProps, type MockEventSource, PREVIEW_CONVERSATIONS, PREVIEW_DOCUMENTS, PREVIEW_FILE_SAMPLES, PREVIEW_MESSAGES, type PreviewEmission, PreviewInProductionError, type PreviewScriptStep, type PreviewStore, type PreviewStoreListener, type PreviewWebhookClient, PreviewWebhookRejectedError, type SetModeParams, type StartPreviewScriptParams, assertPreviewEnvironment, conversationChannel, createMockConversationsApi, createMockEventSource, createMockSSEProvider, createPreviewMediaResolver, createPreviewStore, createPreviewWebhookClient, previewFileBase64, previewFileUrl, resolvePreviewFileSample, startPreviewScript };
|