@adatechnology/conversations-ui 0.1.1 → 0.2.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/{ConversationSimulatorPanel--5fIzXWY.d.ts → ConversationSimulatorPanel-ikgmlciE.d.ts} +103 -1
- package/dist/{chunk-BJNRLLDO.js → chunk-NHQDQJL2.js} +769 -244
- package/dist/index.d.ts +304 -9
- package/dist/index.js +2166 -509
- package/dist/preview/index.d.ts +2 -2
- package/dist/preview/index.js +147 -1
- package/dist/styles.css +135 -0
- package/package.json +1 -1
- package/src/MessageComposer.test.tsx +14 -0
- package/src/MessageComposer.tsx +327 -73
- package/src/RichMessageComposer.test.tsx +22 -4
- package/src/RichMessageComposer.tsx +674 -370
- package/src/index.ts +28 -1
- package/src/preview/createMockConversationsApi.ts +184 -0
- package/src/providers/types.ts +34 -0
- package/src/quickReplies/AttachmentsFormSection.tsx +160 -0
- package/src/quickReplies/QuickRepliesPicker.test.tsx +114 -0
- package/src/quickReplies/QuickRepliesPicker.tsx +188 -0
- package/src/quickReplies/QuickRepliesWorkspace.test.tsx +32 -0
- package/src/quickReplies/QuickRepliesWorkspace.tsx +395 -0
- package/src/quickReplies/createUploadQueue.test.ts +106 -0
- package/src/quickReplies/createUploadQueue.ts +69 -0
- package/src/quickReplies/index.ts +5 -0
- package/src/quickReplies/labels.ts +124 -0
- package/src/quickReplies/quickReply.types.ts +74 -0
- package/src/quickReplies/quickReplyAttachmentUpload.test.ts +76 -0
- package/src/quickReplies/quickReplyAttachmentUpload.ts +81 -0
- package/src/quickReplies/quickReplyAttachments.test.ts +396 -0
- package/src/quickReplies/quickReplyAttachments.ts +289 -0
- package/src/quickReplies/quickReplySearch.test.ts +88 -0
- package/src/quickReplies/quickReplySearch.ts +104 -0
- package/src/quickReplies/quickReplyShortcut.test.ts +38 -0
- package/src/quickReplies/quickReplyShortcut.ts +46 -0
- package/src/quickReplies/resolveConversationVariables.test.ts +63 -0
- package/src/quickReplies/resolveConversationVariables.ts +41 -0
- package/src/quickReplies/useQuickRepliesPicker.test.ts +20 -0
- package/src/quickReplies/useQuickRepliesPicker.ts +121 -0
- package/src/quickReplies/useQuickRepliesWorkspace.test.ts +222 -0
- package/src/quickReplies/useQuickRepliesWorkspace.ts +426 -0
- package/src/quickReplies/useQuickReplyAttachmentUploads.ts +159 -0
- package/src/styles.css +87 -0
- package/src/workspace/ConversationPane.tsx +137 -73
- package/src/workspace/ConversationsWorkspace.tsx +16 -1
- package/src/workspace/QueuedAttachmentsList.test.ts +27 -0
- package/src/workspace/QueuedAttachmentsList.tsx +198 -0
- package/src/workspace/index.ts +1 -0
- package/src/workspace/labels.ts +14 -0
- package/src/workspace/useComposerAttachmentRetry.ts +155 -0
- package/src/workspace/useComposerQueue.ts +220 -0
package/dist/{ConversationSimulatorPanel--5fIzXWY.d.ts → ConversationSimulatorPanel-ikgmlciE.d.ts}
RENAMED
|
@@ -136,6 +136,77 @@ interface MediaRendererProps {
|
|
|
136
136
|
}
|
|
137
137
|
declare function MediaRenderer({ message, onLightbox, onResolveUrl, onTranscribeAudio, className, }: MediaRendererProps): react.JSX.Element | null;
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Mensagem pronta cadastrada pelo produto e oferecida no composer.
|
|
141
|
+
*
|
|
142
|
+
* Difere do `QuickReply` dos chips (`MessageComposer`): aquela vive em código no host; esta vem da
|
|
143
|
+
* API, tem atalho para o `/` e é editada pela tela de cadastro.
|
|
144
|
+
*/
|
|
145
|
+
type QuickReply = {
|
|
146
|
+
readonly id: string;
|
|
147
|
+
/** Até 40 caracteres — é o que o atendente lê na lista. */
|
|
148
|
+
readonly title: string;
|
|
149
|
+
/** Casa `^[a-z0-9-]{1,20}$`: é digitado depois do `/`, sem acento nem espaço. */
|
|
150
|
+
readonly shortcut: string;
|
|
151
|
+
/** Até 1000 caracteres, com `{{marcador}}` onde entra o dado da conversa. */
|
|
152
|
+
readonly body: string;
|
|
153
|
+
/** Ausente em host sem anexos: o contrato continua o mesmo para quem não os oferece. */
|
|
154
|
+
readonly attachments?: readonly QuickReplyAttachment[];
|
|
155
|
+
};
|
|
156
|
+
/** Teto de anexos por mensagem pronta — o mesmo que a API aplica, para a tela recusar antes. */
|
|
157
|
+
declare const QUICK_REPLY_ATTACHMENT_LIMIT = 10;
|
|
158
|
+
/** Arquivo já guardado pelo host; o `uploadId` é a única chave que o pacote devolve ao servidor. */
|
|
159
|
+
type QuickReplyAttachment = {
|
|
160
|
+
readonly uploadId: string;
|
|
161
|
+
readonly filename: string;
|
|
162
|
+
readonly mimeType: string;
|
|
163
|
+
readonly sizeBytes: number;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Item da fila do composer. `local` ainda não subiu (veio do clipe); `stored` já está no servidor
|
|
167
|
+
* (veio de uma mensagem pronta) e é enviado por referência, sem baixar e subir de novo.
|
|
168
|
+
*/
|
|
169
|
+
type QueuedAttachment = {
|
|
170
|
+
readonly kind: 'local';
|
|
171
|
+
readonly localId: string;
|
|
172
|
+
readonly file: File;
|
|
173
|
+
} | {
|
|
174
|
+
readonly kind: 'stored';
|
|
175
|
+
readonly uploadId: string;
|
|
176
|
+
readonly filename: string;
|
|
177
|
+
readonly mimeType: string;
|
|
178
|
+
readonly sizeBytes: number;
|
|
179
|
+
/** Carregada sob demanda só para imagem — a lista não pode abrir N URLs assinadas de uma vez. */
|
|
180
|
+
readonly previewUrl?: string;
|
|
181
|
+
};
|
|
182
|
+
/** Resultado por arquivo: o envio em lote falha parcialmente, e só o que falhou fica na fila. */
|
|
183
|
+
type StoredAttachmentSendResult = {
|
|
184
|
+
readonly uploadId: string;
|
|
185
|
+
readonly status: 'sent' | 'failed' | 'skipped';
|
|
186
|
+
readonly errorCode?: string;
|
|
187
|
+
};
|
|
188
|
+
/** O que a tela de cadastro manda para criar ou atualizar; o `id` é do servidor. */
|
|
189
|
+
type QuickReplyInput = {
|
|
190
|
+
readonly title: string;
|
|
191
|
+
readonly shortcut: string;
|
|
192
|
+
readonly body: string;
|
|
193
|
+
/** Ordem do cadastro é a ordem de envio; ausente não mexe nos anexos já gravados. */
|
|
194
|
+
readonly attachmentUploadIds?: readonly string[];
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Dado da conversa que um texto pode citar. Uma lista só alimenta a prévia, a inserção e o botão de
|
|
198
|
+
* variáveis — antes eram duas props de formato diferente, e as telas divergiam por isso.
|
|
199
|
+
*/
|
|
200
|
+
type ConversationVariable = {
|
|
201
|
+
readonly id: string;
|
|
202
|
+
/** Rótulo do botão "Inserir variável" (ex.: "Nome do cliente"). */
|
|
203
|
+
readonly label: string;
|
|
204
|
+
/** Como aparece no texto: `{{nome}}`. */
|
|
205
|
+
readonly marker: string;
|
|
206
|
+
/** Vazio quando a conversa não tem o dado: a variável não é oferecida. */
|
|
207
|
+
readonly value: string;
|
|
208
|
+
};
|
|
209
|
+
|
|
139
210
|
/**
|
|
140
211
|
* Gravação de áudio no simulador, pelo microfone do próprio navegador.
|
|
141
212
|
*
|
|
@@ -426,6 +497,37 @@ interface ConversationsApi {
|
|
|
426
497
|
finalize?(conversationId: string): Promise<void>;
|
|
427
498
|
markAllRead?(): Promise<void>;
|
|
428
499
|
listTemplates?(): Promise<ConversationTemplate[]>;
|
|
500
|
+
/**
|
|
501
|
+
* Mensagens prontas do produto. Ausente, nada de mensagens prontas aparece; sem `create`,
|
|
502
|
+
* `update` e `delete` a tela de cadastro fica só leitura — a presença da função é a capacidade.
|
|
503
|
+
*/
|
|
504
|
+
listQuickReplies?(params?: {
|
|
505
|
+
search?: string;
|
|
506
|
+
}): Promise<QuickReply[]>;
|
|
507
|
+
createQuickReply?(input: QuickReplyInput): Promise<QuickReply>;
|
|
508
|
+
updateQuickReply?(id: string, input: QuickReplyInput): Promise<QuickReply>;
|
|
509
|
+
deleteQuickReply?(id: string): Promise<void>;
|
|
510
|
+
/**
|
|
511
|
+
* Sobe um anexo de mensagem pronta. O pacote não sabe COMO o host sobe (URL assinada, multipart):
|
|
512
|
+
* só precisa de progresso e cancelamento. Ausente, a tela de cadastro não oferece anexos.
|
|
513
|
+
* A miniatura de imagem reusa `getDocumentUrl(uploadId, 'inline')` — não há porta própria.
|
|
514
|
+
*/
|
|
515
|
+
uploadQuickReplyAttachment?(file: File, options?: {
|
|
516
|
+
onProgress?: (fraction: number) => void;
|
|
517
|
+
signal?: AbortSignal;
|
|
518
|
+
}): Promise<QuickReplyAttachment>;
|
|
519
|
+
/**
|
|
520
|
+
* Envia por referência anexos já guardados. A chave de idempotência protege o reenvio depois de
|
|
521
|
+
* queda de rede; o resultado vem por arquivo porque a falha é parcial. Ausente, mensagem pronta
|
|
522
|
+
* com anexo insere só o texto.
|
|
523
|
+
*/
|
|
524
|
+
sendStoredAttachments?(params: {
|
|
525
|
+
conversationId: string;
|
|
526
|
+
uploadIds: readonly string[];
|
|
527
|
+
idempotencyKey: string;
|
|
528
|
+
}): Promise<{
|
|
529
|
+
results: readonly StoredAttachmentSendResult[];
|
|
530
|
+
}>;
|
|
429
531
|
/**
|
|
430
532
|
* Transcrição completa gerada pelo servidor. Existe ao lado de `buildTranscriptText`, que monta
|
|
431
533
|
* a partir das mensagens já em memória: a tela costuma ter só a última página carregada, e
|
|
@@ -801,4 +903,4 @@ type ConversationSimulatorPanelProps = Omit<ConversationPreviewProps, 'placehold
|
|
|
801
903
|
};
|
|
802
904
|
declare function ConversationSimulatorPanel({ onClose, channel, displayHandle, displayNumber, labels, headerActions, ...previewProps }: ConversationSimulatorPanelProps): react.JSX.Element;
|
|
803
905
|
|
|
804
|
-
export { type
|
|
906
|
+
export { type PreviewUploadedMedia as $, AudioRecorderButton as A, type ConversationsUIConfig as B, CHANNEL_CAPABILITIES as C, type CreatePreviewMediaUploaderParams as D, type CreatePreviewWebhookClientParams as E, DEFAULT_AUDIO_RECORDER_BUTTON_LABELS as F, DEFAULT_CONVERSATION_CHANNEL as G, DEFAULT_CONVERSATION_SIMULATOR_PANEL_LABELS as H, DEFAULT_MAX_RECORDING_MILLISECONDS as I, DEFAULT_MEDIA_UPLOAD_PATH as J, type FormatContactHandleParams as K, HANDLE_KIND as L, type HandleKind as M, type InteractiveOption as N, type InteractivePayload as O, type InteractiveSection as P, type InteractiveSelection as Q, type ListConversationsParams as R, type ListDocumentsParams as S, MediaRenderer as T, type MediaRendererProps as U, type MessagePayload as V, type MessageTranscription as W, PreviewInProductionError as X, PreviewMediaUploadRejectedError as Y, type PreviewMediaUploadRequest as Z, type PreviewUploadedMedia$1 as _, type AudioRecorderButtonLabels as a, type PreviewWebhookClient as a0, PreviewWebhookRejectedError as a1, QUICK_REPLY_ATTACHMENT_LIMIT as a2, type QueuedAttachment as a3, type QuickReply as a4, type QuickReplyAttachment as a5, type QuickReplyInput as a6, REOPEN_MECHANISM as a7, type ReopenMechanism as a8, type ResolveMediaUrl as a9, SIMULATOR_FILE_MEDIA_KINDS as aa, type SSEProvider as ab, type SendPreviewMediaParams as ac, type SendSimulatorMediaParams as ad, type SimulatorMediaKind as ae, type StoredAttachmentSendResult as af, type ToSimulatorClientParams as ag, type TranscriptionMode as ah, type TranscriptionStatus as ai, acceptsMediaKind as aj, assertPreviewEnvironment as ak, capabilitiesOf as al, channelFiltersFor as am, contactFlag as an, createPreviewMediaPoster as ao, createPreviewMediaUploader as ap, createPreviewWebhookClient as aq, formatContactHandle as ar, isConversationSimulatorClient as as, mediaKindOf as at, mediaTypeOf as au, signPreviewPayload as av, simulatorPanelLabelsOf as aw, toConversationSimulatorClient as ax, type AudioRecorderButtonProps as b, CHANNEL_FILTER_ALL as c, CONVERSATION_CHANNEL as d, type ChannelCapabilities as e, type ChannelFilter as f, type ChannelFilterOption as g, type CompanyDocument as h, type CompanyDocumentPage as i, type ConversationChannel as j, type ConversationDocument as k, type ConversationDocumentPage as l, type ConversationEventSource as m, type ConversationPage as n, ConversationPreview as o, type ConversationPreviewProps as p, type ConversationSimulatorClient as q, ConversationSimulatorPanel as r, type ConversationSimulatorPanelLabels as s, type ConversationSimulatorPanelProps as t, type ConversationSummary as u, type ConversationTemplate as v, type ConversationVariable as w, type ConversationsApi as x, type ConversationsFeatures as y, type ConversationsTheme as z };
|