@botzetta/sdk 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +143 -2
- package/dist/catalogos.cjs +32 -0
- package/dist/catalogos.d.cts +139 -0
- package/dist/catalogos.d.ts +139 -0
- package/dist/catalogos.js +33 -0
- package/dist/catalogos.js.map +1 -0
- package/dist/chunk-3ER6OFAH.cjs +238 -0
- package/dist/chunk-HCG5JNQ4.cjs +8 -0
- package/dist/chunk-JCEWZRVN.js +239 -0
- package/dist/chunk-JCEWZRVN.js.map +1 -0
- package/dist/chunk-LBFC3YOJ.cjs +80 -0
- package/dist/chunk-PTMCHNMK.js +81 -0
- package/dist/chunk-PTMCHNMK.js.map +1 -0
- package/dist/chunk-W5QWZZZY.js +9 -0
- package/dist/chunk-W5QWZZZY.js.map +1 -0
- package/dist/express/index.cjs +96 -0
- package/dist/express/index.d.cts +52 -0
- package/dist/express/index.d.ts +52 -0
- package/dist/express/index.js +97 -0
- package/dist/express/index.js.map +1 -0
- package/dist/index.cjs +485 -0
- package/dist/index.d.cts +867 -0
- package/dist/index.d.ts +867 -0
- package/dist/index.js +486 -0
- package/dist/index.js.map +1 -0
- package/dist/usuario-DXfSUh6y.d.cts +152 -0
- package/dist/usuario-DXfSUh6y.d.ts +152 -0
- package/package.json +103 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,867 @@
|
|
|
1
|
+
import { a as CredenciaisApp, C as ChaveApp } from './usuario-DXfSUh6y.cjs';
|
|
2
|
+
export { A as ASSERTION_TTL_MAX_SEGUNDOS, b as AlgoritmoChave, c as AppError, J as JwkPublica, N as NivelBloqueio, d as OpcoesChaveApp, O as OpcoesVerificarUsuario, R as RespostaHttp, S as SessaoUsuario, T as TIPO_CLIENT_ASSERTION, U as UsuarioVerificado, e as camposAssertion, f as criarChaveApp, g as criarVerificadorUsuario, h as escritaBloqueada, i as gerarChaveApp, l as limparCacheSessao, s as servirJwks, t as tokenDoCabecalho, u as urlTokenEndpoint, v as verificarUsuario } from './usuario-DXfSUh6y.cjs';
|
|
3
|
+
import { EventoWebhook } from './catalogos.cjs';
|
|
4
|
+
export { CABECALHO_ASSINATURA, CABECALHO_ENTREGA, CABECALHO_EVENTO, CATALOGO_ESCOPOS, CATALOGO_EVENTOS, ESCOPOS, EVENTOS, EVENTOS_APP, EVENTO_TESTE_WEBHOOK, Escopo, Evento, PLATAFORMA_ISS, PREFIXO_API, RiscoEscopo, TOLERANCIA_WEBHOOK_SEGUNDOS, TYP_ASSINATURA_WEBHOOK } from './catalogos.cjs';
|
|
5
|
+
import 'node:crypto';
|
|
6
|
+
|
|
7
|
+
/** Códigos de bloqueio por assinatura (empresa com pagamento pendente) devolvidos em escrita/envio. */
|
|
8
|
+
declare const ERROS_ASSINATURA: readonly ["ERR_ASSINATURA_VENCIDA", "ERR_ASSINATURA_BLOQUEADA"];
|
|
9
|
+
/** Erro devolvido pela API de Plataforma do núcleo (ou falha de rede/timeout ao chamá-la). */
|
|
10
|
+
declare class NucleoErro extends Error {
|
|
11
|
+
readonly codigo: string;
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly requestId: string | null;
|
|
14
|
+
constructor(codigo: string, mensagem: string, status: number, requestId?: string | null);
|
|
15
|
+
/** Vale tentar de novo mais tarde? (409 conexão desconectada / em andamento, 429, 5xx, rede). */
|
|
16
|
+
get tentarDeNovo(): boolean;
|
|
17
|
+
/** Resultado definitivo: não adianta tentar de novo (ex.: opt-out, assinatura vencida, canal não suportado). */
|
|
18
|
+
get final(): boolean;
|
|
19
|
+
/** Bloqueio por assinatura (paywall/total): escrita e envio recusados até regularizar. */
|
|
20
|
+
get assinaturaBloqueada(): boolean;
|
|
21
|
+
toJSON(): {
|
|
22
|
+
error: string;
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* OAuth por instalação para apps de parceiro:
|
|
29
|
+
* link de instalação (PKCE S256) → o admin consente no host → o app troca o código
|
|
30
|
+
* por tokens daquela empresa → renova com o refresh rotativo.
|
|
31
|
+
*/
|
|
32
|
+
/** Tokens de UMA instalação (uma empresa). O app guarda; o SDK não decide onde. */
|
|
33
|
+
interface TokensInstalacao {
|
|
34
|
+
accessToken: string;
|
|
35
|
+
refreshToken: string;
|
|
36
|
+
/** Quando o access token expira. */
|
|
37
|
+
expiraEm: Date;
|
|
38
|
+
escopos: string[];
|
|
39
|
+
companyId: number;
|
|
40
|
+
instalacaoId: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Onde o app guarda os tokens de cada empresa (banco do app, cifrado).
|
|
44
|
+
* O refresh é rotativo: SEMPRE salve o par novo antes de usar o access token novo.
|
|
45
|
+
*/
|
|
46
|
+
interface ArmazenamentoTokens {
|
|
47
|
+
obter(companyId: number): Promise<TokensInstalacao | null>;
|
|
48
|
+
salvar(companyId: number, tokens: TokensInstalacao): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/** O app se autentica com a própria chave (client_assertion, private_key_jwt). */
|
|
51
|
+
interface CredenciaisOAuth extends CredenciaisApp {
|
|
52
|
+
timeoutMs?: number;
|
|
53
|
+
fetch?: typeof fetch;
|
|
54
|
+
}
|
|
55
|
+
/** Par PKCE S256. Guarde o `verifier` (ex.: na sessão) até a troca do código. */
|
|
56
|
+
declare function gerarPkce(): {
|
|
57
|
+
verifier: string;
|
|
58
|
+
challenge: string;
|
|
59
|
+
metodo: "S256";
|
|
60
|
+
};
|
|
61
|
+
/** Valor aleatório para o `state` (anti-CSRF do callback). Confira no retorno. */
|
|
62
|
+
declare const gerarState: () => string;
|
|
63
|
+
/** Link que o admin da empresa abre para instalar o app (tela de consentimento do host). */
|
|
64
|
+
declare function montarUrlInstalacao(p: {
|
|
65
|
+
/** URL do Botzetta (host), ex.: https://app.botzetta.com.br */
|
|
66
|
+
urlHost: string;
|
|
67
|
+
clientId: string;
|
|
68
|
+
redirectUri: string;
|
|
69
|
+
state: string;
|
|
70
|
+
codeChallenge: string;
|
|
71
|
+
}): string;
|
|
72
|
+
/** Callback do link de instalação: troca o `code` (uso único, 10 min) pelos tokens da empresa. */
|
|
73
|
+
declare function trocarCodigo(c: CredenciaisOAuth, p: {
|
|
74
|
+
code: string;
|
|
75
|
+
redirectUri: string;
|
|
76
|
+
codeVerifier: string;
|
|
77
|
+
}): Promise<TokensInstalacao>;
|
|
78
|
+
/**
|
|
79
|
+
* Renova o par. O refresh antigo deixa de valer; reusar um refresh já usado revoga
|
|
80
|
+
* a instalação inteira (ERR_OAUTH_REFRESH_INVALIDO) e o admin precisa reinstalar.
|
|
81
|
+
*/
|
|
82
|
+
declare function renovarToken(c: CredenciaisOAuth, refreshToken: string): Promise<TokensInstalacao>;
|
|
83
|
+
/**
|
|
84
|
+
* Revoga o refresh (e os que vieram dele). Nunca lança: devolve `true` quando o Botzetta aceitou o
|
|
85
|
+
* pedido (a resposta não revela se o token existia) e `false` em falha de rede ou de assinatura; tente de novo.
|
|
86
|
+
*/
|
|
87
|
+
declare function revogarToken(c: CredenciaisOAuth, refreshToken: string): Promise<boolean>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Webhook assinado pelo Botzetta: `Botzetta-Assinatura` é um JWT RS256
|
|
91
|
+
* com a chave da Plataforma (JWKS público do núcleo) que liga o corpo pelo hash:
|
|
92
|
+
* `{ iss: "botzetta-nucleo", aud: "app:<slug>", tipo: "webhook", iat, exp, jti, entrega, evento, sha256 }`
|
|
93
|
+
* e cabeçalho `typ: "botzetta-webhook+jwt"`. Nenhum segredo por app.
|
|
94
|
+
*/
|
|
95
|
+
interface OpcoesVerificarWebhook {
|
|
96
|
+
/** Corpo CRU da requisição (os mesmos bytes que chegaram; não use o JSON re-serializado). */
|
|
97
|
+
corpo: string | Buffer;
|
|
98
|
+
/** Valor do cabeçalho Botzetta-Assinatura. */
|
|
99
|
+
assinatura: string | string[] | undefined | null;
|
|
100
|
+
/** Valor do cabeçalho Botzetta-Entrega (opcional): se vier, precisa ser o mesmo assinado. */
|
|
101
|
+
entrega?: string | string[] | undefined | null;
|
|
102
|
+
/** Slug do app (o `aud` esperado é `app:<slug>`). */
|
|
103
|
+
slug: string;
|
|
104
|
+
/** JWKS do núcleo: <núcleo>/plataforma/v1/.well-known/jwks.json (cache de 10 min). */
|
|
105
|
+
jwksUrl: string;
|
|
106
|
+
/** Idade máxima da assinatura (padrão 300 s). */
|
|
107
|
+
toleranciaSegundos?: number;
|
|
108
|
+
}
|
|
109
|
+
/** base64url(SHA-256(corpo)) — o claim `sha256` da assinatura. */
|
|
110
|
+
declare const hashCorpoWebhook: (corpo: string | Buffer) => string;
|
|
111
|
+
/** Evento conferido + dados da assinatura. Deduplique por `id` (evento) ou `entrega`; `jti` muda a cada tentativa. */
|
|
112
|
+
type WebhookVerificado = EventoWebhook & {
|
|
113
|
+
entrega: string;
|
|
114
|
+
jti: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Confere a assinatura de um webhook do Botzetta e devolve o evento.
|
|
118
|
+
* Recusa (AppError ERR_WEBHOOK_ASSINATURA_INVALIDA, 401) cabeçalho ausente, chave fora do JWKS do núcleo,
|
|
119
|
+
* `iss`/`aud`/`typ`/`tipo` errados, assinatura expirada ou fora da tolerância corpo que não bate com o hash e
|
|
120
|
+
* Botzetta-Entrega diferente da assinada (quando informado em `entrega`).
|
|
121
|
+
*/
|
|
122
|
+
declare function verificarWebhook(o: OpcoesVerificarWebhook): Promise<WebhookVerificado>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* DTOs da API de Plataforma 1.x.
|
|
126
|
+
* Mudança incompatível aqui só em versão major do pacote.
|
|
127
|
+
*/
|
|
128
|
+
interface Paginado<T> {
|
|
129
|
+
dados: T[];
|
|
130
|
+
pagina: number;
|
|
131
|
+
porPagina: number;
|
|
132
|
+
total: number;
|
|
133
|
+
}
|
|
134
|
+
interface ListarPessoasParams {
|
|
135
|
+
ids?: number[];
|
|
136
|
+
busca?: string;
|
|
137
|
+
tags?: number[];
|
|
138
|
+
pagina?: number;
|
|
139
|
+
porPagina?: number;
|
|
140
|
+
}
|
|
141
|
+
interface PessoaResumo {
|
|
142
|
+
id: number;
|
|
143
|
+
nome: string;
|
|
144
|
+
nomeFantasia: string | null;
|
|
145
|
+
dataNascimento: string | null;
|
|
146
|
+
sexo: string | null;
|
|
147
|
+
ativo: boolean;
|
|
148
|
+
optOut: boolean;
|
|
149
|
+
}
|
|
150
|
+
interface Pessoa extends PessoaResumo {
|
|
151
|
+
contatosWhatsapp: {
|
|
152
|
+
numero: string;
|
|
153
|
+
origem: "crm" | "atendimento";
|
|
154
|
+
}[];
|
|
155
|
+
}
|
|
156
|
+
interface FiltrosAniversariante {
|
|
157
|
+
tagIds?: number[];
|
|
158
|
+
sexo?: string[];
|
|
159
|
+
idadeMin?: number | null;
|
|
160
|
+
idadeMax?: number | null;
|
|
161
|
+
estado?: string | null;
|
|
162
|
+
cidade?: string | null;
|
|
163
|
+
pessoasIncluir?: number[];
|
|
164
|
+
pessoasExcluir?: number[];
|
|
165
|
+
}
|
|
166
|
+
interface BuscaAniversariantes {
|
|
167
|
+
dia: number;
|
|
168
|
+
mes: number;
|
|
169
|
+
filtros?: FiltrosAniversariante;
|
|
170
|
+
}
|
|
171
|
+
interface Aniversariante {
|
|
172
|
+
id: number;
|
|
173
|
+
nome: string;
|
|
174
|
+
dataNascimento: string;
|
|
175
|
+
contatoWhatsapp: string;
|
|
176
|
+
/** Pediu para não receber mensagens: o envio será recusado com ERR_DESTINO_OPT_OUT. */
|
|
177
|
+
optOut?: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface PreviaAniversariantes {
|
|
180
|
+
total: number;
|
|
181
|
+
/** Quantas das pessoas do total têm opt-out e não vão receber. */
|
|
182
|
+
totalOptOut?: number;
|
|
183
|
+
amostra: {
|
|
184
|
+
id: number;
|
|
185
|
+
nome: string;
|
|
186
|
+
}[];
|
|
187
|
+
}
|
|
188
|
+
interface Whatsapp {
|
|
189
|
+
id: number;
|
|
190
|
+
nome: string;
|
|
191
|
+
tipo: "baileys" | "meta" | string;
|
|
192
|
+
status: string;
|
|
193
|
+
canal: string | null;
|
|
194
|
+
padrao: boolean;
|
|
195
|
+
}
|
|
196
|
+
/** Tag de pessoa (GET /tags, escopo pessoas:ler). */
|
|
197
|
+
interface Tag {
|
|
198
|
+
id: number;
|
|
199
|
+
nome: string;
|
|
200
|
+
cor: string | null;
|
|
201
|
+
}
|
|
202
|
+
interface Fila {
|
|
203
|
+
id: number;
|
|
204
|
+
nome: string;
|
|
205
|
+
cor: string | null;
|
|
206
|
+
}
|
|
207
|
+
interface Template {
|
|
208
|
+
id: number;
|
|
209
|
+
whatsappId: number;
|
|
210
|
+
nome: string;
|
|
211
|
+
idioma: string;
|
|
212
|
+
categoria: string | null;
|
|
213
|
+
status: string;
|
|
214
|
+
componentes: unknown[];
|
|
215
|
+
}
|
|
216
|
+
/** Contato do atendimento (GET /contatos, escopo contatos:ler). Inclui grupos. */
|
|
217
|
+
interface Contato {
|
|
218
|
+
id: number;
|
|
219
|
+
nome: string;
|
|
220
|
+
/** Só dígitos; em grupo é o id do grupo (JID sem @g.us). */
|
|
221
|
+
numero: string;
|
|
222
|
+
grupo: boolean;
|
|
223
|
+
pessoaId: number | null;
|
|
224
|
+
/** A pessoa vinculada pediu para não receber mensagens (o envio será recusado). Grupo: sempre false. */
|
|
225
|
+
optOut: boolean;
|
|
226
|
+
fotoUrl: string | null;
|
|
227
|
+
}
|
|
228
|
+
interface ListarContatosParams {
|
|
229
|
+
ids?: number[];
|
|
230
|
+
busca?: string;
|
|
231
|
+
pagina?: number;
|
|
232
|
+
porPagina?: number;
|
|
233
|
+
}
|
|
234
|
+
interface Usuario {
|
|
235
|
+
id: number;
|
|
236
|
+
nome: string;
|
|
237
|
+
perfil: string;
|
|
238
|
+
}
|
|
239
|
+
interface EnviarMensagem {
|
|
240
|
+
whatsappId: number;
|
|
241
|
+
/** { contatoId }: contato do atendimento, inclusive grupo; único destino que aceita `ticket`. */
|
|
242
|
+
destino: {
|
|
243
|
+
pessoaId: number;
|
|
244
|
+
} | {
|
|
245
|
+
numero: string;
|
|
246
|
+
} | {
|
|
247
|
+
contatoId: number;
|
|
248
|
+
};
|
|
249
|
+
conteudo: {
|
|
250
|
+
texto?: string | null;
|
|
251
|
+
templateId?: number | null;
|
|
252
|
+
parametros?: Record<string, string | number> | null;
|
|
253
|
+
/** No máximo 1 mídia. */
|
|
254
|
+
midiaIds?: number[] | null;
|
|
255
|
+
};
|
|
256
|
+
usuarioId?: number | null;
|
|
257
|
+
/**
|
|
258
|
+
* 1.1, só com destino { contatoId }: abre (ou reaproveita o aberto/pendente) o ticket do contato na conexão,
|
|
259
|
+
* aplica as variáveis do ticket ({{firstName}}, {{ms}}, {{queue}}...) e registra a mensagem na conversa.
|
|
260
|
+
*/
|
|
261
|
+
ticket?: {
|
|
262
|
+
abrir: boolean;
|
|
263
|
+
filaId?: number | null;
|
|
264
|
+
usuarioId?: number | null;
|
|
265
|
+
status?: "open" | "closed" | "pending";
|
|
266
|
+
} | null;
|
|
267
|
+
/** 1.1: prefixa "*Nome do usuário:*" (assinatura do v1). Só com `ticket.abrir`. */
|
|
268
|
+
assinarComoUsuarioId?: number | null;
|
|
269
|
+
}
|
|
270
|
+
interface MensagemEnviada {
|
|
271
|
+
whatsappMensagemId: string;
|
|
272
|
+
status: "enviada";
|
|
273
|
+
/** 1.1: ticket usado quando `ticket.abrir`. */
|
|
274
|
+
ticketId?: number | null;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Mídia do núcleo. `id` é a referência oficial (envio, exclusão, LGPD, checagem de empresa).
|
|
278
|
+
* `url` é permanente: o app guarda `id` + cópia de url/nome/tipo/tamanho para exibir sem chamar o
|
|
279
|
+
* núcleo, mas nunca usa a URL como referência.
|
|
280
|
+
*/
|
|
281
|
+
interface Midia {
|
|
282
|
+
id: number;
|
|
283
|
+
nomeOriginal: string;
|
|
284
|
+
tipoMime: string;
|
|
285
|
+
tamanho: number;
|
|
286
|
+
/** URL permanente. */
|
|
287
|
+
url: string;
|
|
288
|
+
/** @deprecated Sempre `null` (a URL não expira). Sai na próxima versão major. */
|
|
289
|
+
urlExpiraEm: string | null;
|
|
290
|
+
}
|
|
291
|
+
interface EnviarMidia {
|
|
292
|
+
conteudo: Blob | Uint8Array;
|
|
293
|
+
nome: string;
|
|
294
|
+
tipoMime: string;
|
|
295
|
+
entidadeId?: number;
|
|
296
|
+
}
|
|
297
|
+
interface Notificacao {
|
|
298
|
+
titulo: string;
|
|
299
|
+
mensagem: string;
|
|
300
|
+
referencia?: Record<string, unknown>;
|
|
301
|
+
}
|
|
302
|
+
/** Valor de campo personalizado (GET /pessoas/:id, PUT /pessoas/:id/campos). */
|
|
303
|
+
interface CampoValor {
|
|
304
|
+
campoId: number;
|
|
305
|
+
nome: string;
|
|
306
|
+
valor: unknown;
|
|
307
|
+
}
|
|
308
|
+
/** GET /pessoas/:id traz também tags, campos e status do cadastro. */
|
|
309
|
+
interface PessoaDetalhe extends Pessoa {
|
|
310
|
+
statusCadastro: "rascunho" | "incompleto" | "completo";
|
|
311
|
+
tags: Tag[];
|
|
312
|
+
campos: CampoValor[];
|
|
313
|
+
}
|
|
314
|
+
interface DadosPessoa {
|
|
315
|
+
natureza?: "PF" | "PJ";
|
|
316
|
+
nome?: string;
|
|
317
|
+
nomeFantasia?: string | null;
|
|
318
|
+
/** AAAA-MM-DD */
|
|
319
|
+
dataNascimento?: string | null;
|
|
320
|
+
sexo?: "M" | "F" | "O" | null;
|
|
321
|
+
observacao?: string | null;
|
|
322
|
+
}
|
|
323
|
+
interface CriarPessoa extends DadosPessoa {
|
|
324
|
+
natureza: "PF" | "PJ";
|
|
325
|
+
nome: string;
|
|
326
|
+
/** WhatsApp já usado por outra pessoa → 409 ERR_CONTATO_EXISTENTE (nunca deduplica). */
|
|
327
|
+
contatos?: {
|
|
328
|
+
tipo: "whatsapp" | "celular" | "telefone_residencial" | "telefone_comercial" | "email";
|
|
329
|
+
valor: string;
|
|
330
|
+
}[];
|
|
331
|
+
tags?: number[];
|
|
332
|
+
campos?: {
|
|
333
|
+
campoId: number;
|
|
334
|
+
valor: unknown;
|
|
335
|
+
}[];
|
|
336
|
+
}
|
|
337
|
+
interface CampoPersonalizado {
|
|
338
|
+
id: number;
|
|
339
|
+
nome: string;
|
|
340
|
+
rotulo: string;
|
|
341
|
+
tipo: string;
|
|
342
|
+
obrigatorio: boolean;
|
|
343
|
+
opcoes: unknown[] | null;
|
|
344
|
+
}
|
|
345
|
+
interface EstagioPipeline {
|
|
346
|
+
id: number;
|
|
347
|
+
nome: string;
|
|
348
|
+
ordem: number;
|
|
349
|
+
cor: string | null;
|
|
350
|
+
tipo: "padrao" | "ganho" | "perda";
|
|
351
|
+
ativo: boolean;
|
|
352
|
+
}
|
|
353
|
+
interface Pipeline {
|
|
354
|
+
id: number;
|
|
355
|
+
nome: string;
|
|
356
|
+
descricao: string | null;
|
|
357
|
+
estagios: EstagioPipeline[];
|
|
358
|
+
}
|
|
359
|
+
type ResultadoOportunidade = "aberta" | "ganha" | "perdida";
|
|
360
|
+
interface Oportunidade {
|
|
361
|
+
id: number;
|
|
362
|
+
titulo: string;
|
|
363
|
+
descricao: string | null;
|
|
364
|
+
pessoaId: number;
|
|
365
|
+
pipelineId: number;
|
|
366
|
+
estagioId: number;
|
|
367
|
+
tipoId: number | null;
|
|
368
|
+
responsavelId: number | null;
|
|
369
|
+
valor: number | null;
|
|
370
|
+
probabilidade: number | null;
|
|
371
|
+
prioridade: string | null;
|
|
372
|
+
resultado: ResultadoOportunidade;
|
|
373
|
+
ganhaEm: string | null;
|
|
374
|
+
perdidaEm: string | null;
|
|
375
|
+
motivoPerdaId: number | null;
|
|
376
|
+
perdaObservacao: string | null;
|
|
377
|
+
ativo: boolean;
|
|
378
|
+
criadoEm: string;
|
|
379
|
+
atualizadoEm: string;
|
|
380
|
+
}
|
|
381
|
+
interface ListarOportunidadesParams {
|
|
382
|
+
pipelineId?: number;
|
|
383
|
+
estagioId?: number;
|
|
384
|
+
pessoaId?: number;
|
|
385
|
+
resultado?: ResultadoOportunidade;
|
|
386
|
+
/** ISO 8601 */
|
|
387
|
+
atualizadoDesde?: string;
|
|
388
|
+
pagina?: number;
|
|
389
|
+
porPagina?: number;
|
|
390
|
+
}
|
|
391
|
+
interface DadosOportunidade {
|
|
392
|
+
titulo?: string;
|
|
393
|
+
descricao?: string | null;
|
|
394
|
+
valor?: number | null;
|
|
395
|
+
probabilidade?: number | null;
|
|
396
|
+
prioridade?: string | null;
|
|
397
|
+
responsavelId?: number | null;
|
|
398
|
+
tipoId?: number;
|
|
399
|
+
}
|
|
400
|
+
interface CriarOportunidade extends DadosOportunidade {
|
|
401
|
+
pessoaId: number;
|
|
402
|
+
pipelineId: number;
|
|
403
|
+
estagioId: number;
|
|
404
|
+
tipoId: number;
|
|
405
|
+
titulo: string;
|
|
406
|
+
}
|
|
407
|
+
interface ItemSimples {
|
|
408
|
+
id: number;
|
|
409
|
+
nome: string;
|
|
410
|
+
}
|
|
411
|
+
type StatusTicket = "open" | "pending" | "closed";
|
|
412
|
+
/** Ticket sem a última mensagem (conteúdo de conversa é mensagens:ler). */
|
|
413
|
+
interface Ticket {
|
|
414
|
+
id: number;
|
|
415
|
+
uuid: string;
|
|
416
|
+
status: string;
|
|
417
|
+
contatoId: number | null;
|
|
418
|
+
pessoaId: number | null;
|
|
419
|
+
filaId: number | null;
|
|
420
|
+
usuarioId: number | null;
|
|
421
|
+
whatsappId: number | null;
|
|
422
|
+
canal: string | null;
|
|
423
|
+
naoLidas: number;
|
|
424
|
+
criadoEm: string;
|
|
425
|
+
atualizadoEm: string;
|
|
426
|
+
}
|
|
427
|
+
interface ListarTicketsParams {
|
|
428
|
+
status?: StatusTicket;
|
|
429
|
+
filaId?: number;
|
|
430
|
+
contatoId?: number;
|
|
431
|
+
pessoaId?: number;
|
|
432
|
+
usuarioId?: number;
|
|
433
|
+
whatsappId?: number;
|
|
434
|
+
atualizadoDesde?: string;
|
|
435
|
+
pagina?: number;
|
|
436
|
+
porPagina?: number;
|
|
437
|
+
}
|
|
438
|
+
interface NotaTicket {
|
|
439
|
+
id: number;
|
|
440
|
+
ticketId: number;
|
|
441
|
+
texto: string;
|
|
442
|
+
/** `chave`: nota feita por uma chave de integração da empresa. */
|
|
443
|
+
autor: {
|
|
444
|
+
tipo: "app";
|
|
445
|
+
slug: string;
|
|
446
|
+
} | {
|
|
447
|
+
tipo: "usuario";
|
|
448
|
+
usuarioId: number;
|
|
449
|
+
} | {
|
|
450
|
+
tipo: "chave";
|
|
451
|
+
chaveId: number;
|
|
452
|
+
nome: string;
|
|
453
|
+
};
|
|
454
|
+
criadoEm: string;
|
|
455
|
+
}
|
|
456
|
+
interface TransferirTicket {
|
|
457
|
+
filaId?: number;
|
|
458
|
+
usuarioId?: number;
|
|
459
|
+
/** Sem `mensagem`, nada é enviado ao cliente. */
|
|
460
|
+
mensagem?: string;
|
|
461
|
+
}
|
|
462
|
+
interface Mensagem {
|
|
463
|
+
id: number;
|
|
464
|
+
ticketId: number;
|
|
465
|
+
contatoId: number | null;
|
|
466
|
+
deMim: boolean;
|
|
467
|
+
tipo: string;
|
|
468
|
+
texto: string | null;
|
|
469
|
+
transcricao: string | null;
|
|
470
|
+
midiaId: number | null;
|
|
471
|
+
ack: number | null;
|
|
472
|
+
interna: boolean;
|
|
473
|
+
editada: boolean;
|
|
474
|
+
encaminhada: boolean;
|
|
475
|
+
citadaId: number | null;
|
|
476
|
+
criadoEm: string;
|
|
477
|
+
}
|
|
478
|
+
/** Página por cursor (histórico de mensagens): o cursor é opaco, só repasse. */
|
|
479
|
+
interface PaginaCursor<T> {
|
|
480
|
+
dados: T[];
|
|
481
|
+
proximoCursor: string | null;
|
|
482
|
+
}
|
|
483
|
+
interface HistoricoParams {
|
|
484
|
+
cursor?: string;
|
|
485
|
+
/** Padrão 50, máximo 200. */
|
|
486
|
+
limite?: number;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
interface LoggerCliente {
|
|
490
|
+
debug?: (obj: object, msg?: string) => void;
|
|
491
|
+
warn?: (obj: object, msg?: string) => void;
|
|
492
|
+
}
|
|
493
|
+
/** Contexto de uma chamada: a empresa e, opcionalmente, o id de correlação (X-Request-Id). */
|
|
494
|
+
interface ContextoChamada {
|
|
495
|
+
companyId: number;
|
|
496
|
+
requestId?: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Opções do cliente base (avançado). Para um app de parceiro use `criarCliente`, que já liga o
|
|
500
|
+
* token da instalação. O cliente base serve para quem precisa trocar a origem do token (ex.: testes
|
|
501
|
+
* ou um cofre de tokens próprio) sem reescrever as chamadas da API.
|
|
502
|
+
*/
|
|
503
|
+
interface OpcoesClienteBase<C extends ContextoChamada = ContextoChamada> {
|
|
504
|
+
/** Base do Botzetta, sem /plataforma/v1 (ex.: https://api.botzetta.com.br). */
|
|
505
|
+
url: string;
|
|
506
|
+
/**
|
|
507
|
+
* Access token para a chamada. `forcarRenovacao` = o Botzetta acabou de recusar o token anterior
|
|
508
|
+
* (401 ERR_TOKEN_INVALIDO): obtenha um novo em vez de devolver o mesmo.
|
|
509
|
+
*/
|
|
510
|
+
obterToken(ctx: C, forcarRenovacao: boolean): Promise<string>;
|
|
511
|
+
/** Cabeçalhos extras de cada chamada (não sobrescrevem Authorization, X-Request-Id nem Idempotency-Key). */
|
|
512
|
+
cabecalhos?(ctx: C): Record<string, string>;
|
|
513
|
+
/** Timeout por tentativa (padrão 10 s). */
|
|
514
|
+
timeoutMs?: number;
|
|
515
|
+
/** Novas tentativas em 5xx/timeout/rede (padrão 2). */
|
|
516
|
+
novasTentativas?: number;
|
|
517
|
+
logger?: LoggerCliente;
|
|
518
|
+
/** Injetável nos testes. */
|
|
519
|
+
fetch?: typeof fetch;
|
|
520
|
+
}
|
|
521
|
+
type ClienteBase<C extends ContextoChamada = ContextoChamada> = ReturnType<typeof criarClienteBase<C>>;
|
|
522
|
+
/** Chamadas da API de Plataforma em nome de uma empresa. */
|
|
523
|
+
type ClienteEmpresa = ReturnType<ClienteBase["empresa"]>;
|
|
524
|
+
/**
|
|
525
|
+
* Cliente da API de Plataforma com a origem do token injetada (avançado; veja `criarCliente`).
|
|
526
|
+
*
|
|
527
|
+
* const pessoa = await cliente.empresa(companyId).pessoas.obter(id);
|
|
528
|
+
*/
|
|
529
|
+
declare function criarClienteBase<C extends ContextoChamada = ContextoChamada>(opcoes: OpcoesClienteBase<C>): {
|
|
530
|
+
/** Todas as chamadas de dados são feitas em nome de uma empresa. */
|
|
531
|
+
empresa(companyId: number, extra?: Omit<C, "companyId">): {
|
|
532
|
+
pessoas: {
|
|
533
|
+
listar: (p?: ListarPessoasParams) => Promise<Paginado<PessoaResumo>>;
|
|
534
|
+
/** Inclui tags, campos e statusCadastro. */
|
|
535
|
+
obter: (id: number) => Promise<PessoaDetalhe>;
|
|
536
|
+
/** pessoas:escrever. Sempre cria (nunca deduplica). */
|
|
537
|
+
criar: (dados: CriarPessoa, o: {
|
|
538
|
+
idempotencyKey: string;
|
|
539
|
+
}) => Promise<PessoaDetalhe>;
|
|
540
|
+
atualizar: (id: number, dados: DadosPessoa) => Promise<PessoaDetalhe>;
|
|
541
|
+
/** Substitui as tags da pessoa. */
|
|
542
|
+
definirTags: (id: number, tags: number[]) => Promise<{
|
|
543
|
+
tags: Tag[];
|
|
544
|
+
}>;
|
|
545
|
+
salvarCampos: (id: number, campos: {
|
|
546
|
+
campoId: number;
|
|
547
|
+
valor: unknown;
|
|
548
|
+
}[]) => Promise<{
|
|
549
|
+
campos: CampoValor[];
|
|
550
|
+
}>;
|
|
551
|
+
/** Só liga o opt-out (desfazer é da própria pessoa ou da tela do núcleo). */
|
|
552
|
+
optOut: (id: number) => Promise<PessoaDetalhe>;
|
|
553
|
+
aniversariantes: (b: BuscaAniversariantes) => Promise<{
|
|
554
|
+
dados: Aniversariante[];
|
|
555
|
+
total: number;
|
|
556
|
+
}>;
|
|
557
|
+
previaAniversariantes: (b?: {
|
|
558
|
+
filtros?: FiltrosAniversariante;
|
|
559
|
+
}) => Promise<PreviaAniversariantes>;
|
|
560
|
+
};
|
|
561
|
+
contatos: {
|
|
562
|
+
listar: (p?: ListarContatosParams) => Promise<Paginado<Contato>>;
|
|
563
|
+
obter: (id: number) => Promise<Contato>;
|
|
564
|
+
};
|
|
565
|
+
whatsapps: {
|
|
566
|
+
listar: () => Promise<{
|
|
567
|
+
dados: Whatsapp[];
|
|
568
|
+
}>;
|
|
569
|
+
obter: (id: number) => Promise<Whatsapp>;
|
|
570
|
+
};
|
|
571
|
+
filas: {
|
|
572
|
+
listar: () => Promise<{
|
|
573
|
+
dados: Fila[];
|
|
574
|
+
}>;
|
|
575
|
+
};
|
|
576
|
+
tags: {
|
|
577
|
+
listar: () => Promise<{
|
|
578
|
+
dados: Tag[];
|
|
579
|
+
}>;
|
|
580
|
+
};
|
|
581
|
+
templates: {
|
|
582
|
+
listar: (p?: {
|
|
583
|
+
whatsappId?: number;
|
|
584
|
+
}) => Promise<{
|
|
585
|
+
dados: Template[];
|
|
586
|
+
}>;
|
|
587
|
+
obter: (id: number) => Promise<Template>;
|
|
588
|
+
};
|
|
589
|
+
usuarios: {
|
|
590
|
+
obter: (id: number) => Promise<Usuario>;
|
|
591
|
+
listar: (p?: {
|
|
592
|
+
busca?: string;
|
|
593
|
+
}) => Promise<{
|
|
594
|
+
dados: Usuario[];
|
|
595
|
+
}>;
|
|
596
|
+
};
|
|
597
|
+
mensagens: {
|
|
598
|
+
/** idempotencyKey é obrigatório: repetir a chave nunca reenvia. */
|
|
599
|
+
enviar: (p: EnviarMensagem, o: {
|
|
600
|
+
idempotencyKey: string;
|
|
601
|
+
}) => Promise<MensagemEnviada>;
|
|
602
|
+
};
|
|
603
|
+
midias: {
|
|
604
|
+
obter: (id: number) => Promise<Midia>;
|
|
605
|
+
enviar: (a: EnviarMidia) => Promise<Midia>;
|
|
606
|
+
excluir: (id: number) => Promise<void>;
|
|
607
|
+
};
|
|
608
|
+
realtime: {
|
|
609
|
+
emitir: (evento: string, dados: unknown, o?: {
|
|
610
|
+
usuarioId?: number;
|
|
611
|
+
}) => Promise<{
|
|
612
|
+
evento: string;
|
|
613
|
+
}>;
|
|
614
|
+
};
|
|
615
|
+
notificacoes: {
|
|
616
|
+
enviar: (n: Notificacao) => Promise<{
|
|
617
|
+
enfileirada: boolean;
|
|
618
|
+
}>;
|
|
619
|
+
};
|
|
620
|
+
/** pessoas:ler (entidade pessoa) ou crm:ler (oportunidade). */
|
|
621
|
+
camposPersonalizados: {
|
|
622
|
+
listar: (p: {
|
|
623
|
+
entidade: "pessoa" | "oportunidade";
|
|
624
|
+
}) => Promise<{
|
|
625
|
+
dados: CampoPersonalizado[];
|
|
626
|
+
}>;
|
|
627
|
+
};
|
|
628
|
+
/** crm:ler / crm:escrever. */
|
|
629
|
+
crm: {
|
|
630
|
+
pipelines: {
|
|
631
|
+
listar: () => Promise<{
|
|
632
|
+
dados: Pipeline[];
|
|
633
|
+
}>;
|
|
634
|
+
obter: (id: number) => Promise<Pipeline>;
|
|
635
|
+
};
|
|
636
|
+
oportunidades: {
|
|
637
|
+
listar: (p?: ListarOportunidadesParams) => Promise<Paginado<Oportunidade>>;
|
|
638
|
+
obter: (id: number) => Promise<Oportunidade>;
|
|
639
|
+
tipos: () => Promise<{
|
|
640
|
+
dados: ItemSimples[];
|
|
641
|
+
}>;
|
|
642
|
+
motivosPerda: () => Promise<{
|
|
643
|
+
dados: ItemSimples[];
|
|
644
|
+
}>;
|
|
645
|
+
criar: (dados: CriarOportunidade, o: {
|
|
646
|
+
idempotencyKey: string;
|
|
647
|
+
}) => Promise<Oportunidade>;
|
|
648
|
+
atualizar: (id: number, dados: DadosOportunidade) => Promise<Oportunidade>;
|
|
649
|
+
/** Estágio de ganho/perda aplica o resultado. */
|
|
650
|
+
mover: (id: number, p: {
|
|
651
|
+
estagioId: number;
|
|
652
|
+
pipelineId?: number;
|
|
653
|
+
}) => Promise<Oportunidade>;
|
|
654
|
+
ganhar: (id: number) => Promise<Oportunidade>;
|
|
655
|
+
perder: (id: number, p: {
|
|
656
|
+
motivoPerdaId: number;
|
|
657
|
+
observacao?: string;
|
|
658
|
+
}) => Promise<Oportunidade>;
|
|
659
|
+
reabrir: (id: number) => Promise<Oportunidade>;
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
/** tickets:ler / tickets:escrever. */
|
|
663
|
+
tickets: {
|
|
664
|
+
listar: (p?: ListarTicketsParams) => Promise<Paginado<Ticket>>;
|
|
665
|
+
obter: (id: number) => Promise<Ticket>;
|
|
666
|
+
anotar: (id: number, texto: string, o: {
|
|
667
|
+
idempotencyKey: string;
|
|
668
|
+
}) => Promise<NotaTicket>;
|
|
669
|
+
transferir: (id: number, p: TransferirTicket, o: {
|
|
670
|
+
idempotencyKey: string;
|
|
671
|
+
}) => Promise<Ticket>;
|
|
672
|
+
/** Sem `enviarDespedida: true`, não manda mensagem ao cliente. */
|
|
673
|
+
fechar: (id: number, p: {
|
|
674
|
+
enviarDespedida?: boolean;
|
|
675
|
+
}, o: {
|
|
676
|
+
idempotencyKey: string;
|
|
677
|
+
}) => Promise<Ticket>;
|
|
678
|
+
};
|
|
679
|
+
/** mensagens:ler — histórico por cursor (mais novas primeiro). */
|
|
680
|
+
historico: {
|
|
681
|
+
doTicket: (ticketId: number, p?: HistoricoParams) => Promise<PaginaCursor<Mensagem>>;
|
|
682
|
+
doContato: (contatoId: number, p?: HistoricoParams) => Promise<PaginaCursor<Mensagem>>;
|
|
683
|
+
percorrerTicket: (ticketId: number, p?: Omit<HistoricoParams, "cursor">) => AsyncGenerator<Mensagem, any, any>;
|
|
684
|
+
percorrerContato: (contatoId: number, p?: Omit<HistoricoParams, "cursor">) => AsyncGenerator<Mensagem, any, any>;
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
interface OpcoesCliente {
|
|
690
|
+
/** Base do Botzetta, sem /plataforma/v1 (ex.: https://api.botzetta.com.br). */
|
|
691
|
+
url: string;
|
|
692
|
+
/** client_id = slug do app. */
|
|
693
|
+
clientId: string;
|
|
694
|
+
/** Chave do app (criarChaveApp): assina o client_assertion de cada renovação de token. */
|
|
695
|
+
chave: ChaveApp;
|
|
696
|
+
/** `aud` da assertion; padrão = token endpoint de `url`. */
|
|
697
|
+
audienciaAssertion?: string;
|
|
698
|
+
/**
|
|
699
|
+
* Onde o app guarda o par de tokens de cada empresa (seu banco, cifrado). O cliente renova sozinho
|
|
700
|
+
* 60 s antes de expirar (refresh rotativo) e salva o par novo aqui ANTES de usá-lo.
|
|
701
|
+
*/
|
|
702
|
+
tokensInstalacao: ArmazenamentoTokens;
|
|
703
|
+
/** Timeout por tentativa (padrão 10 s). */
|
|
704
|
+
timeoutMs?: number;
|
|
705
|
+
/** Novas tentativas em 5xx/timeout/rede (padrão 2). */
|
|
706
|
+
novasTentativas?: number;
|
|
707
|
+
logger?: LoggerCliente;
|
|
708
|
+
/** Injetável nos testes. */
|
|
709
|
+
fetch?: typeof fetch;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Cliente da API de Plataforma para o app de parceiro: cada chamada usa o token da instalação da
|
|
713
|
+
* empresa (o token já carrega a empresa), renovado sozinho com o refresh rotativo.
|
|
714
|
+
*
|
|
715
|
+
* const botzetta = criarCliente({ url, clientId: "meuapp", chave, tokensInstalacao: meuBanco });
|
|
716
|
+
* const pessoa = await botzetta.empresa(companyId).pessoas.obter(42);
|
|
717
|
+
*/
|
|
718
|
+
declare function criarCliente(opcoes: OpcoesCliente): {
|
|
719
|
+
empresa(companyId: number, extra?: Omit<ContextoChamada, "companyId">): {
|
|
720
|
+
pessoas: {
|
|
721
|
+
listar: (p?: ListarPessoasParams) => Promise<Paginado<PessoaResumo>>;
|
|
722
|
+
obter: (id: number) => Promise<PessoaDetalhe>;
|
|
723
|
+
criar: (dados: CriarPessoa, o: {
|
|
724
|
+
idempotencyKey: string;
|
|
725
|
+
}) => Promise<PessoaDetalhe>;
|
|
726
|
+
atualizar: (id: number, dados: DadosPessoa) => Promise<PessoaDetalhe>;
|
|
727
|
+
definirTags: (id: number, tags: number[]) => Promise<{
|
|
728
|
+
tags: Tag[];
|
|
729
|
+
}>;
|
|
730
|
+
salvarCampos: (id: number, campos: {
|
|
731
|
+
campoId: number;
|
|
732
|
+
valor: unknown;
|
|
733
|
+
}[]) => Promise<{
|
|
734
|
+
campos: CampoValor[];
|
|
735
|
+
}>;
|
|
736
|
+
optOut: (id: number) => Promise<PessoaDetalhe>;
|
|
737
|
+
aniversariantes: (b: BuscaAniversariantes) => Promise<{
|
|
738
|
+
dados: Aniversariante[];
|
|
739
|
+
total: number;
|
|
740
|
+
}>;
|
|
741
|
+
previaAniversariantes: (b?: {
|
|
742
|
+
filtros?: FiltrosAniversariante;
|
|
743
|
+
}) => Promise<PreviaAniversariantes>;
|
|
744
|
+
};
|
|
745
|
+
contatos: {
|
|
746
|
+
listar: (p?: ListarContatosParams) => Promise<Paginado<Contato>>;
|
|
747
|
+
obter: (id: number) => Promise<Contato>;
|
|
748
|
+
};
|
|
749
|
+
whatsapps: {
|
|
750
|
+
listar: () => Promise<{
|
|
751
|
+
dados: Whatsapp[];
|
|
752
|
+
}>;
|
|
753
|
+
obter: (id: number) => Promise<Whatsapp>;
|
|
754
|
+
};
|
|
755
|
+
filas: {
|
|
756
|
+
listar: () => Promise<{
|
|
757
|
+
dados: Fila[];
|
|
758
|
+
}>;
|
|
759
|
+
};
|
|
760
|
+
tags: {
|
|
761
|
+
listar: () => Promise<{
|
|
762
|
+
dados: Tag[];
|
|
763
|
+
}>;
|
|
764
|
+
};
|
|
765
|
+
templates: {
|
|
766
|
+
listar: (p?: {
|
|
767
|
+
whatsappId?: number;
|
|
768
|
+
}) => Promise<{
|
|
769
|
+
dados: Template[];
|
|
770
|
+
}>;
|
|
771
|
+
obter: (id: number) => Promise<Template>;
|
|
772
|
+
};
|
|
773
|
+
usuarios: {
|
|
774
|
+
obter: (id: number) => Promise<Usuario>;
|
|
775
|
+
listar: (p?: {
|
|
776
|
+
busca?: string;
|
|
777
|
+
}) => Promise<{
|
|
778
|
+
dados: Usuario[];
|
|
779
|
+
}>;
|
|
780
|
+
};
|
|
781
|
+
mensagens: {
|
|
782
|
+
enviar: (p: EnviarMensagem, o: {
|
|
783
|
+
idempotencyKey: string;
|
|
784
|
+
}) => Promise<MensagemEnviada>;
|
|
785
|
+
};
|
|
786
|
+
midias: {
|
|
787
|
+
obter: (id: number) => Promise<Midia>;
|
|
788
|
+
enviar: (a: EnviarMidia) => Promise<Midia>;
|
|
789
|
+
excluir: (id: number) => Promise<void>;
|
|
790
|
+
};
|
|
791
|
+
realtime: {
|
|
792
|
+
emitir: (evento: string, dados: unknown, o?: {
|
|
793
|
+
usuarioId?: number;
|
|
794
|
+
}) => Promise<{
|
|
795
|
+
evento: string;
|
|
796
|
+
}>;
|
|
797
|
+
};
|
|
798
|
+
notificacoes: {
|
|
799
|
+
enviar: (n: Notificacao) => Promise<{
|
|
800
|
+
enfileirada: boolean;
|
|
801
|
+
}>;
|
|
802
|
+
};
|
|
803
|
+
camposPersonalizados: {
|
|
804
|
+
listar: (p: {
|
|
805
|
+
entidade: "pessoa" | "oportunidade";
|
|
806
|
+
}) => Promise<{
|
|
807
|
+
dados: CampoPersonalizado[];
|
|
808
|
+
}>;
|
|
809
|
+
};
|
|
810
|
+
crm: {
|
|
811
|
+
pipelines: {
|
|
812
|
+
listar: () => Promise<{
|
|
813
|
+
dados: Pipeline[];
|
|
814
|
+
}>;
|
|
815
|
+
obter: (id: number) => Promise<Pipeline>;
|
|
816
|
+
};
|
|
817
|
+
oportunidades: {
|
|
818
|
+
listar: (p?: ListarOportunidadesParams) => Promise<Paginado<Oportunidade>>;
|
|
819
|
+
obter: (id: number) => Promise<Oportunidade>;
|
|
820
|
+
tipos: () => Promise<{
|
|
821
|
+
dados: ItemSimples[];
|
|
822
|
+
}>;
|
|
823
|
+
motivosPerda: () => Promise<{
|
|
824
|
+
dados: ItemSimples[];
|
|
825
|
+
}>;
|
|
826
|
+
criar: (dados: CriarOportunidade, o: {
|
|
827
|
+
idempotencyKey: string;
|
|
828
|
+
}) => Promise<Oportunidade>;
|
|
829
|
+
atualizar: (id: number, dados: DadosOportunidade) => Promise<Oportunidade>;
|
|
830
|
+
mover: (id: number, p: {
|
|
831
|
+
estagioId: number;
|
|
832
|
+
pipelineId?: number;
|
|
833
|
+
}) => Promise<Oportunidade>;
|
|
834
|
+
ganhar: (id: number) => Promise<Oportunidade>;
|
|
835
|
+
perder: (id: number, p: {
|
|
836
|
+
motivoPerdaId: number;
|
|
837
|
+
observacao?: string;
|
|
838
|
+
}) => Promise<Oportunidade>;
|
|
839
|
+
reabrir: (id: number) => Promise<Oportunidade>;
|
|
840
|
+
};
|
|
841
|
+
};
|
|
842
|
+
tickets: {
|
|
843
|
+
listar: (p?: ListarTicketsParams) => Promise<Paginado<Ticket>>;
|
|
844
|
+
obter: (id: number) => Promise<Ticket>;
|
|
845
|
+
anotar: (id: number, texto: string, o: {
|
|
846
|
+
idempotencyKey: string;
|
|
847
|
+
}) => Promise<NotaTicket>;
|
|
848
|
+
transferir: (id: number, p: TransferirTicket, o: {
|
|
849
|
+
idempotencyKey: string;
|
|
850
|
+
}) => Promise<Ticket>;
|
|
851
|
+
fechar: (id: number, p: {
|
|
852
|
+
enviarDespedida?: boolean;
|
|
853
|
+
}, o: {
|
|
854
|
+
idempotencyKey: string;
|
|
855
|
+
}) => Promise<Ticket>;
|
|
856
|
+
};
|
|
857
|
+
historico: {
|
|
858
|
+
doTicket: (ticketId: number, p?: HistoricoParams) => Promise<PaginaCursor<Mensagem>>;
|
|
859
|
+
doContato: (contatoId: number, p?: HistoricoParams) => Promise<PaginaCursor<Mensagem>>;
|
|
860
|
+
percorrerTicket: (ticketId: number, p?: Omit<HistoricoParams, "cursor">) => AsyncGenerator<Mensagem, any, any>;
|
|
861
|
+
percorrerContato: (contatoId: number, p?: Omit<HistoricoParams, "cursor">) => AsyncGenerator<Mensagem, any, any>;
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
};
|
|
865
|
+
type Cliente = ReturnType<typeof criarCliente>;
|
|
866
|
+
|
|
867
|
+
export { type Aniversariante, type ArmazenamentoTokens, type BuscaAniversariantes, type CampoPersonalizado, type CampoValor, ChaveApp, type Cliente, type ClienteBase, type ClienteEmpresa, type Contato, type ContextoChamada, CredenciaisApp, type CredenciaisOAuth, type CriarOportunidade, type CriarPessoa, type DadosOportunidade, type DadosPessoa, ERROS_ASSINATURA, type EnviarMensagem, type EnviarMidia, type EstagioPipeline, EventoWebhook, type Fila, type FiltrosAniversariante, type HistoricoParams, type ItemSimples, type ListarContatosParams, type ListarOportunidadesParams, type ListarPessoasParams, type ListarTicketsParams, type LoggerCliente, type Mensagem, type MensagemEnviada, type Midia, type NotaTicket, type Notificacao, NucleoErro, type OpcoesCliente, type OpcoesClienteBase, type OpcoesVerificarWebhook, type Oportunidade, type PaginaCursor, type Paginado, type Pessoa, type PessoaDetalhe, type PessoaResumo, type Pipeline, type PreviaAniversariantes, type ResultadoOportunidade, type StatusTicket, type Tag, type Template, type Ticket, type TokensInstalacao, type TransferirTicket, type Usuario, type WebhookVerificado, type Whatsapp, criarCliente, criarClienteBase, gerarPkce, gerarState, hashCorpoWebhook, montarUrlInstalacao, renovarToken, revogarToken, trocarCodigo, verificarWebhook };
|