@botozap/sdk 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/CHANGELOG.md +32 -0
- package/README.md +7 -0
- package/dist/index.cjs +198 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +181 -20
- package/dist/index.d.ts +181 -20
- package/dist/index.js +197 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -100,7 +100,12 @@ async function uploadArtifact(client, input) {
|
|
|
100
100
|
pdf: "application/pdf",
|
|
101
101
|
txt: "text/plain",
|
|
102
102
|
md: "text/markdown",
|
|
103
|
-
csv: "text/csv"
|
|
103
|
+
csv: "text/csv",
|
|
104
|
+
jpg: "image/jpeg",
|
|
105
|
+
jpeg: "image/jpeg",
|
|
106
|
+
png: "image/png",
|
|
107
|
+
mp4: "video/mp4",
|
|
108
|
+
mov: "video/quicktime"
|
|
104
109
|
}[ext] || file.type || "application/octet-stream";
|
|
105
110
|
const metadata = {
|
|
106
111
|
customer_id: String(input.customer_id),
|
|
@@ -109,7 +114,12 @@ async function uploadArtifact(client, input) {
|
|
|
109
114
|
mime_type: mime,
|
|
110
115
|
byte_size: file.size,
|
|
111
116
|
sha256,
|
|
112
|
-
...kind === "
|
|
117
|
+
...kind === "file" ? {
|
|
118
|
+
name: String(input.name ?? ""),
|
|
119
|
+
description: String(input.description ?? ""),
|
|
120
|
+
...input.caption ? { caption: String(input.caption) } : {}
|
|
121
|
+
} : {},
|
|
122
|
+
...kind === "knowledge" ? { name: String(input.name ?? "") } : kind === "file" ? {} : {
|
|
113
123
|
...input.id ? {
|
|
114
124
|
skill_id: String(input.id),
|
|
115
125
|
expected_revision: String(input.expected_revision ?? "")
|
|
@@ -1884,6 +1894,10 @@ var AI_OPERATIONS = [
|
|
|
1884
1894
|
sticky_intent: {
|
|
1885
1895
|
type: "nullableString",
|
|
1886
1896
|
optional: true
|
|
1897
|
+
},
|
|
1898
|
+
last_sent_message: {
|
|
1899
|
+
type: "nullableString",
|
|
1900
|
+
optional: true
|
|
1887
1901
|
}
|
|
1888
1902
|
}
|
|
1889
1903
|
},
|
|
@@ -2758,14 +2772,14 @@ var AI_OPERATIONS = [
|
|
|
2758
2772
|
method: "POST",
|
|
2759
2773
|
path: "/ai/uploads",
|
|
2760
2774
|
shape: "item",
|
|
2761
|
-
description: "Prepara upload direto. Envie bytes por PUT na URL assinada com os headers retornados, sem Authorization BotoZap. Guarde upload_id para finalizar a mesma importa\xE7\xE3o.",
|
|
2775
|
+
description: "Prepara upload direto. Envie bytes por PUT na URL assinada com os headers retornados, sem Authorization BotoZap. Guarde upload_id para finalizar a mesma importa\xE7\xE3o. kind=file (foto JPG/PNG, v\xEDdeo MP4/MOV ou PDF at\xE9 25 MiB, para o agente mandar na conversa) exige name (at\xE9 80) e description (quando o agente deve mandar, at\xE9 500); caption \xE9 opcional (at\xE9 1.024 caracteres e 1.000 bytes).",
|
|
2762
2776
|
fields: {
|
|
2763
2777
|
customer_id: {
|
|
2764
2778
|
type: "uuid",
|
|
2765
2779
|
optional: false
|
|
2766
2780
|
},
|
|
2767
2781
|
kind: {
|
|
2768
|
-
type: "knowledge|skill",
|
|
2782
|
+
type: "knowledge|skill|file",
|
|
2769
2783
|
optional: false
|
|
2770
2784
|
},
|
|
2771
2785
|
file_name: {
|
|
@@ -2788,6 +2802,14 @@ var AI_OPERATIONS = [
|
|
|
2788
2802
|
type: "string",
|
|
2789
2803
|
optional: true
|
|
2790
2804
|
},
|
|
2805
|
+
description: {
|
|
2806
|
+
type: "string",
|
|
2807
|
+
optional: true
|
|
2808
|
+
},
|
|
2809
|
+
caption: {
|
|
2810
|
+
type: "string",
|
|
2811
|
+
optional: true
|
|
2812
|
+
},
|
|
2791
2813
|
skill_id: {
|
|
2792
2814
|
type: "uuid",
|
|
2793
2815
|
optional: true
|
|
@@ -3861,6 +3883,99 @@ var AI_OPERATIONS = [
|
|
|
3861
3883
|
optional: false
|
|
3862
3884
|
}
|
|
3863
3885
|
}
|
|
3886
|
+
},
|
|
3887
|
+
// #1447 arquivos do agente: appended so existing indexes stay stable.
|
|
3888
|
+
{
|
|
3889
|
+
group: "files",
|
|
3890
|
+
name: "list",
|
|
3891
|
+
method: "GET",
|
|
3892
|
+
path: "/ai/files",
|
|
3893
|
+
shape: "item",
|
|
3894
|
+
description: "Biblioteca de fotos, v\xEDdeos e PDFs que o agente pode mandar na conversa, do mais novo ao mais antigo, com status (processing enquanto converte, ready, failed com last_error).",
|
|
3895
|
+
fields: {
|
|
3896
|
+
customer_id: {
|
|
3897
|
+
type: "uuid",
|
|
3898
|
+
optional: false
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
},
|
|
3902
|
+
{
|
|
3903
|
+
group: "files",
|
|
3904
|
+
name: "get",
|
|
3905
|
+
method: "GET",
|
|
3906
|
+
path: "/ai/files/:id",
|
|
3907
|
+
shape: "item",
|
|
3908
|
+
description: "Um arquivo da biblioteca, as vers\xF5es de agente que o usam (usages) e um link curto para ver (preview_url, vence em preview_expires_at; n\xE3o guarde nem registre).",
|
|
3909
|
+
fields: {
|
|
3910
|
+
customer_id: {
|
|
3911
|
+
type: "uuid",
|
|
3912
|
+
optional: false
|
|
3913
|
+
},
|
|
3914
|
+
id: {
|
|
3915
|
+
type: "uuid",
|
|
3916
|
+
optional: false
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
},
|
|
3920
|
+
{
|
|
3921
|
+
group: "files",
|
|
3922
|
+
name: "update",
|
|
3923
|
+
method: "PATCH",
|
|
3924
|
+
path: "/ai/files/:id",
|
|
3925
|
+
shape: "item",
|
|
3926
|
+
description: "Edita nome, description (quando o agente deve mandar), caption e active (false arquiva) com expected_revision. Vale na hora para os agentes publicados que usam o arquivo. Arquivar o que est\xE1 numa vers\xE3o publicada \xE9 recusado (409 in_use).",
|
|
3927
|
+
fields: {
|
|
3928
|
+
customer_id: {
|
|
3929
|
+
type: "uuid",
|
|
3930
|
+
optional: false
|
|
3931
|
+
},
|
|
3932
|
+
id: {
|
|
3933
|
+
type: "uuid",
|
|
3934
|
+
optional: false
|
|
3935
|
+
},
|
|
3936
|
+
expected_revision: {
|
|
3937
|
+
type: "revision",
|
|
3938
|
+
optional: false
|
|
3939
|
+
},
|
|
3940
|
+
name: {
|
|
3941
|
+
type: "string",
|
|
3942
|
+
optional: true
|
|
3943
|
+
},
|
|
3944
|
+
description: {
|
|
3945
|
+
type: "string",
|
|
3946
|
+
optional: true
|
|
3947
|
+
},
|
|
3948
|
+
caption: {
|
|
3949
|
+
type: "string",
|
|
3950
|
+
optional: true
|
|
3951
|
+
},
|
|
3952
|
+
active: {
|
|
3953
|
+
type: "boolean",
|
|
3954
|
+
optional: true
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3957
|
+
},
|
|
3958
|
+
{
|
|
3959
|
+
group: "files",
|
|
3960
|
+
name: "remove",
|
|
3961
|
+
method: "DELETE",
|
|
3962
|
+
path: "/ai/files/:id",
|
|
3963
|
+
shape: "empty",
|
|
3964
|
+
description: "Apaga de vez (pelo OAuth, s\xF3 Administrador). Arquivo numa vers\xE3o publicada de agente \xE9 recusado (409 in_use); as mensagens que j\xE1 o mandaram continuam com a m\xEDdia.",
|
|
3965
|
+
fields: {
|
|
3966
|
+
customer_id: {
|
|
3967
|
+
type: "uuid",
|
|
3968
|
+
optional: false
|
|
3969
|
+
},
|
|
3970
|
+
id: {
|
|
3971
|
+
type: "uuid",
|
|
3972
|
+
optional: false
|
|
3973
|
+
},
|
|
3974
|
+
expected_revision: {
|
|
3975
|
+
type: "revision",
|
|
3976
|
+
optional: false
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3864
3979
|
}
|
|
3865
3980
|
];
|
|
3866
3981
|
|
|
@@ -4657,10 +4772,42 @@ var AiStyleAdjustmentsResource = class {
|
|
|
4657
4772
|
return request(this.client, named("styleAdjustments", "save"), input);
|
|
4658
4773
|
}
|
|
4659
4774
|
};
|
|
4775
|
+
var AiFilesResource = class {
|
|
4776
|
+
constructor(client) {
|
|
4777
|
+
this.client = client;
|
|
4778
|
+
}
|
|
4779
|
+
client;
|
|
4780
|
+
/** GET /ai/files */
|
|
4781
|
+
list(input) {
|
|
4782
|
+
return request(this.client, named("files", "list"), input);
|
|
4783
|
+
}
|
|
4784
|
+
/** GET /ai/files/:id — com quem usa e o link curto de prévia. */
|
|
4785
|
+
get(input) {
|
|
4786
|
+
return request(this.client, named("files", "get"), input);
|
|
4787
|
+
}
|
|
4788
|
+
/** PATCH /ai/files/:id — vale na hora para os agentes publicados que usam o arquivo. */
|
|
4789
|
+
update(input) {
|
|
4790
|
+
return request(this.client, named("files", "update"), input);
|
|
4791
|
+
}
|
|
4792
|
+
/** DELETE /ai/files/:id — 409 in_use se o arquivo está numa versão publicada. */
|
|
4793
|
+
remove(input) {
|
|
4794
|
+
return request(this.client, named("files", "remove"), input);
|
|
4795
|
+
}
|
|
4796
|
+
/**
|
|
4797
|
+
* Sobe foto (JPG/PNG), vídeo (MP4/MOV) ou PDF de até 25 MiB pelo upload direto (prepare, PUT na URL
|
|
4798
|
+
* assinada, complete). Repetir com os mesmos bytes e dados reaproveita o envio. Vídeo do iPhone e foto
|
|
4799
|
+
* grande voltam `processing` e ficam `ready` depois da conversão.
|
|
4800
|
+
*/
|
|
4801
|
+
upload(input) {
|
|
4802
|
+
if (!input.file.size || input.file.size > 25 * 1024 * 1024) throw new Error("Arquivo vazio ou maior que 25 MiB.");
|
|
4803
|
+
return uploadArtifact(this.client, { ...input, kind: "file" });
|
|
4804
|
+
}
|
|
4805
|
+
};
|
|
4660
4806
|
var Ai = class {
|
|
4661
4807
|
constructor(client) {
|
|
4662
4808
|
this.client = client;
|
|
4663
4809
|
this.uploads = new AiUploadsResource(client);
|
|
4810
|
+
this.files = new AiFilesResource(client);
|
|
4664
4811
|
this.agents = new AiAgentsResource(client);
|
|
4665
4812
|
this.credentials = new AiCredentialsResource(client);
|
|
4666
4813
|
this.providers = new AiProvidersResource(client);
|
|
@@ -4685,6 +4832,7 @@ var Ai = class {
|
|
|
4685
4832
|
}
|
|
4686
4833
|
client;
|
|
4687
4834
|
uploads;
|
|
4835
|
+
files;
|
|
4688
4836
|
agents;
|
|
4689
4837
|
credentials;
|
|
4690
4838
|
providers;
|
|
@@ -5207,7 +5355,11 @@ var Messages = class {
|
|
|
5207
5355
|
}
|
|
5208
5356
|
/** Envia mídia por URL pública. */
|
|
5209
5357
|
async sendMedia(params, options = {}) {
|
|
5210
|
-
const
|
|
5358
|
+
const fileId = "file_id" in params ? params.file_id : void 0;
|
|
5359
|
+
if (fileId === void 0 === (params.link === void 0)) {
|
|
5360
|
+
throw new Error("Informe link ou file_id (um dos dois).");
|
|
5361
|
+
}
|
|
5362
|
+
const media = fileId !== void 0 ? { file_id: fileId } : { link: params.link };
|
|
5211
5363
|
if ("caption" in params && params.caption !== void 0) {
|
|
5212
5364
|
media.caption = params.caption;
|
|
5213
5365
|
}
|
|
@@ -5432,10 +5584,11 @@ var Templates = class {
|
|
|
5432
5584
|
});
|
|
5433
5585
|
}
|
|
5434
5586
|
/**
|
|
5435
|
-
*
|
|
5436
|
-
*
|
|
5437
|
-
*
|
|
5438
|
-
*
|
|
5587
|
+
* Com `components` (e `category`), edita o template e o devolve à análise da
|
|
5588
|
+
* Meta, como o Editar do painel: em análise responde 409 `template_in_review`;
|
|
5589
|
+
* sem id da Meta, 409 `template_not_synced`. Só com `opt_out_buttons`, marca
|
|
5590
|
+
* quais botões de resposta rápida são de saída, sem alterar o template na
|
|
5591
|
+
* Meta. Scope `templates:write`.
|
|
5439
5592
|
*/
|
|
5440
5593
|
update(id, params) {
|
|
5441
5594
|
return this.client.requestItem(
|
|
@@ -5454,6 +5607,14 @@ var Templates = class {
|
|
|
5454
5607
|
sync(params = {}) {
|
|
5455
5608
|
return this.client.requestItem("POST", "/templates/sync", { body: params });
|
|
5456
5609
|
}
|
|
5610
|
+
/**
|
|
5611
|
+
* Exclui o template na Meta e aqui, como o Excluir do painel. Com o id da Meta
|
|
5612
|
+
* apaga só aquela versão de idioma; sem ele, a Meta apaga todas as do mesmo
|
|
5613
|
+
* nome. Não dá para desfazer. Só chave de produção. Scope `templates:write`.
|
|
5614
|
+
*/
|
|
5615
|
+
delete(id) {
|
|
5616
|
+
return this.client.requestItem("DELETE", `/templates/${encodeURIComponent(id)}`);
|
|
5617
|
+
}
|
|
5457
5618
|
};
|
|
5458
5619
|
|
|
5459
5620
|
// src/resources/broadcasts.ts
|
|
@@ -5766,6 +5927,27 @@ var Conversations = class {
|
|
|
5766
5927
|
`/conversations/${enc4(id)}/read`
|
|
5767
5928
|
);
|
|
5768
5929
|
}
|
|
5930
|
+
/**
|
|
5931
|
+
* Envios manuais do WhatsApp da conversa que a Meta não confirmou em cerca de 5 minutos, como o
|
|
5932
|
+
* aviso na conversa no painel. Quando a Meta confirma, a mensagem entra no histórico sozinha.
|
|
5933
|
+
* Envios da IA, respostas automáticas, transmissões, réguas e Instagram têm conciliação própria
|
|
5934
|
+
* e não aparecem. Conversa de outra Conta: 404. Scope `conversations:read`.
|
|
5935
|
+
*/
|
|
5936
|
+
listPendingSends(id) {
|
|
5937
|
+
return this.client.requestItem("GET", `/conversations/${enc4(id)}/pending-sends`);
|
|
5938
|
+
}
|
|
5939
|
+
/**
|
|
5940
|
+
* Diz se o envio sem confirmação chegou ao contato, como "Saiu" e "Não saiu" no painel:
|
|
5941
|
+
* `sent` põe a mensagem no histórico (sem o id da Meta); `not_sent` libera para enviar de novo.
|
|
5942
|
+
* Nada é reenviado. Envio já resolvido: 409 `send_not_pending`. Scope `messages:send`.
|
|
5943
|
+
*/
|
|
5944
|
+
markPendingSend(id, sendId, outcome) {
|
|
5945
|
+
return this.client.requestItem(
|
|
5946
|
+
"POST",
|
|
5947
|
+
`/conversations/${enc4(id)}/pending-sends/${enc4(sendId)}`,
|
|
5948
|
+
{ body: { outcome } }
|
|
5949
|
+
);
|
|
5950
|
+
}
|
|
5769
5951
|
/**
|
|
5770
5952
|
* Exclui a conversa, com efeito imediato e sem volta: mensagens, notas,
|
|
5771
5953
|
* atribuições, vínculos com oportunidades e demandas e o que a IA guardou
|
|
@@ -6104,8 +6286,11 @@ var PhoneNumbers = class {
|
|
|
6104
6286
|
/**
|
|
6105
6287
|
* Inscreve o BotoZap de novo para receber as mensagens do número, com a
|
|
6106
6288
|
* autorização já guardada, sem refazer a conexão. Resolve a prontidão
|
|
6107
|
-
* `webhooks_lost
|
|
6108
|
-
*
|
|
6289
|
+
* `webhooks_lost` quando o app saiu da conta do WhatsApp. Se a conta mudou de
|
|
6290
|
+
* portfólio na Meta, devolve `missing`, e autorização recusada pela Meta
|
|
6291
|
+
* responde 409 `reconnect_required`: nos dois casos, só o link de setup
|
|
6292
|
+
* resolve. `unknown` = a Meta não confirmou agora; confira com `health` em
|
|
6293
|
+
* instantes. Scope `numbers:write`.
|
|
6109
6294
|
*/
|
|
6110
6295
|
resubscribeWebhooks(id) {
|
|
6111
6296
|
return this.client.requestItem("POST", `/phone_numbers/${enc6(id)}/webhook-subscription`);
|
|
@@ -6840,6 +7025,7 @@ export {
|
|
|
6840
7025
|
AiEligibilityResource,
|
|
6841
7026
|
AiEvolutionResource,
|
|
6842
7027
|
AiExecutionsResource,
|
|
7028
|
+
AiFilesResource,
|
|
6843
7029
|
AiFollowupFlowsResource,
|
|
6844
7030
|
AiFollowupsResource,
|
|
6845
7031
|
AiInferencesResource,
|