@botozap/sdk 0.4.0 → 0.5.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 +21 -2
- package/README.md +19 -3
- package/dist/index.cjs +6 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -78
- package/dist/index.d.ts +74 -78
- package/dist/index.js +6 -82
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
# @botozap/sdk
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- eda9708: `AiAgent` gains `lifecycle`, `serving`, `serving_via` and `channel_account_id`, returned by `ai.agents.list` and `ai.agents.get`.
|
|
8
|
+
- 4127500: **Breaking:** remove WhatsApp Flows (`client.flows`, the `Flow`/`FlowVersion` types and the `CreateFlowParams`/`ListFlowsParams`/`FlowPhoneParams`/`CreateFlowVersionParams`/`SetFlowDataEndpointParams` exports). The API no longer serves `/v1/flows/*`; every call already failed with 404. AI follow-up flows (`ai.followupFlows`) are unaffected.
|
|
9
|
+
|
|
10
|
+
Align three types with the API:
|
|
11
|
+
|
|
12
|
+
- `CreateWebhookParams`/`UpdateWebhookParams` accept `customer_id` (limits deliveries to one Customer of the account; `null` on update removes the filter) and `Webhook` declares `customer_id`.
|
|
13
|
+
- **Breaking (types only):** `broadcasts.addRecipients` takes `BroadcastRecipientInput[]` (`{ to_recipient, components? }`) instead of `unknown[]`; plain strings were always rejected per item by the API. `AddRecipientsResult.errors` is typed as `AddRecipientsError[]` (`{ index, to_recipient?, reason }`).
|
|
14
|
+
- **Breaking (types only):** `BotoZapEvent.message_id` is `string | null` (the WhatsApp `wamid`, `null` outside WhatsApp) and the event declares `external_id` (channel message id: `wamid` on WhatsApp, `mid` on Instagram).
|
|
4
15
|
|
|
5
|
-
|
|
16
|
+
- 3b79628: `webhooks.update` accepts `secret` to rotate the signing secret (`PATCH /v1/webhooks/:id`).
|
|
17
|
+
|
|
18
|
+
## 0.4.1
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Fix types that diverged from the API, found by the core's SDK contract matrix: `ai.routers.activateMember` now takes `expected_agent_revision` (the typed call used to send `expected_revision` and always got 422; CLI/MCP were not affected); `JourneyConfig`/`Journey` accept `appointment_service_id` for appointment-triggered journeys; `StageRule.account_id` is optional because `radar.configureStageRule` does not return it; `ConversationNote` declares `author_agent_id` for notes written by an AI agent. No runtime change.
|
|
23
|
+
|
|
24
|
+
## 0.4.0
|
|
6
25
|
|
|
7
26
|
### Minor Changes
|
|
8
27
|
|
package/README.md
CHANGED
|
@@ -174,7 +174,7 @@ if (page.paging.next) {
|
|
|
174
174
|
page = await boto.contacts.list({ limit: 50, after: page.paging.next });
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
// Offset/página (customers, templates, broadcasts, phoneNumbers, users,
|
|
177
|
+
// Offset/página (customers, templates, broadcasts, phoneNumbers, users,
|
|
178
178
|
// conversations.listAssignments): params { page, per_page }.
|
|
179
179
|
const { data, meta } = await boto.templates.list({ page: 2, per_page: 20 });
|
|
180
180
|
console.log(meta.total_count, meta.total_pages);
|
|
@@ -233,9 +233,8 @@ O SDK cobre os recursos da API `/v1`:
|
|
|
233
233
|
- `broadcasts` — criar, destinatários, agendar, enviar, cancelar
|
|
234
234
|
- `contacts` — listar, buscar, criar, atualizar, remover
|
|
235
235
|
- `conversations` — listar, buscar, atualizar, atribuições
|
|
236
|
-
- `webhooks` — CRUD e teste
|
|
236
|
+
- `webhooks` — CRUD e teste; `customer_id` opcional limita as entregas a um Cliente da Conta (`null` no update remove o filtro)
|
|
237
237
|
- `phoneNumbers` — listar, buscar, remover, saúde (a rota de update não expõe campos editáveis, então o SDK não tem `phoneNumbers.update`)
|
|
238
|
-
- `flows` — criar, versionar, publicar, data endpoint (as operações por flow exigem `phone_number_id`, que amarra o flow à sua WABA)
|
|
239
238
|
- `media` — subir arquivo (obter um media_id) e **buscar metadados + URL de download** de uma mídia recebida
|
|
240
239
|
- `events` — reler inbound e mudanças de status pelo cursor durável da Conta/ambiente
|
|
241
240
|
- `users`, `apiLogs`, `webhookDeliveries` — leitura
|
|
@@ -254,6 +253,11 @@ for (const event of page.data) {
|
|
|
254
253
|
ultimoCursor = page.paging.cursor;
|
|
255
254
|
```
|
|
256
255
|
|
|
256
|
+
Cada Evento traz `message_id` (o `wamid`, só no WhatsApp; `null` em outros
|
|
257
|
+
canais) e `external_id` (o id da mensagem no canal de origem: `wamid` no
|
|
258
|
+
WhatsApp, `mid` no Instagram). Para correlacionar mensagens de qualquer canal,
|
|
259
|
+
use `external_id`; ambos podem ser `null` em Eventos sem mensagem.
|
|
260
|
+
|
|
257
261
|
Passe um `AbortSignal` quando a leitura fizer parte de um tail cancelável:
|
|
258
262
|
|
|
259
263
|
```ts
|
|
@@ -274,6 +278,17 @@ await boto.broadcasts.create({
|
|
|
274
278
|
template_language: "pt_BR",
|
|
275
279
|
});
|
|
276
280
|
|
|
281
|
+
// Destinatários: objetos { to_recipient, components? } (até 1000 por chamada,
|
|
282
|
+
// só em draft). Strings soltas NÃO são aceitas. Itens inválidos voltam em
|
|
283
|
+
// `errors` ({ index, to_recipient?, reason }) sem derrubar o lote.
|
|
284
|
+
const { added, duplicates, errors } = await boto.broadcasts.addRecipients(broadcastId, [
|
|
285
|
+
{ to_recipient: "5592999990000" },
|
|
286
|
+
{
|
|
287
|
+
to_recipient: "5592988880000",
|
|
288
|
+
components: [{ type: "body", parameters: [{ type: "text", text: "Ana" }] }],
|
|
289
|
+
},
|
|
290
|
+
]);
|
|
291
|
+
|
|
277
292
|
// Criar um template (submetido à Meta para análise).
|
|
278
293
|
await boto.templates.create({
|
|
279
294
|
name: "boas_vindas",
|
|
@@ -295,6 +310,7 @@ const link = await boto.customers.createSetupLink(customerId, {
|
|
|
295
310
|
await boto.webhooks.create({
|
|
296
311
|
url: "https://seu-app.com/hooks",
|
|
297
312
|
events: ["messages", "statuses"], // categorias aceitas pela API (a rota rejeita nomes finos)
|
|
313
|
+
customer_id, // opcional: só entregas deste Cliente (omitido = todos da Conta)
|
|
298
314
|
});
|
|
299
315
|
const { data: numeros } = await boto.phoneNumbers.list({ customer_id });
|
|
300
316
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -5364,7 +5364,12 @@ var Broadcasts = class {
|
|
|
5364
5364
|
}
|
|
5365
5365
|
);
|
|
5366
5366
|
}
|
|
5367
|
-
/**
|
|
5367
|
+
/**
|
|
5368
|
+
* Adiciona destinatários a uma transmissão em `draft` (até 1000 por chamada).
|
|
5369
|
+
* Cada item é um objeto `{ to_recipient, components? }` — strings soltas não
|
|
5370
|
+
* são aceitas. Itens inválidos não derrubam o lote: voltam em `errors`.
|
|
5371
|
+
* Duplicatas (no lote ou já cadastradas) contam em `duplicates`.
|
|
5372
|
+
*/
|
|
5368
5373
|
addRecipients(id, recipients) {
|
|
5369
5374
|
return this.client.requestItem(
|
|
5370
5375
|
"POST",
|
|
@@ -5642,85 +5647,6 @@ function enc6(id) {
|
|
|
5642
5647
|
return encodeURIComponent(id);
|
|
5643
5648
|
}
|
|
5644
5649
|
|
|
5645
|
-
// src/resources/flows.ts
|
|
5646
|
-
var Flows = class {
|
|
5647
|
-
constructor(client) {
|
|
5648
|
-
this.client = client;
|
|
5649
|
-
}
|
|
5650
|
-
client;
|
|
5651
|
-
/**
|
|
5652
|
-
* Lista os flows de uma WABA (paginação por offset/página). Informe
|
|
5653
|
-
* `phone_number_id` OU `waba_connection_id` — a rota exige um deles.
|
|
5654
|
-
*/
|
|
5655
|
-
list(params = {}) {
|
|
5656
|
-
return this.client.requestOffsetList("GET", "/flows", {
|
|
5657
|
-
query: {
|
|
5658
|
-
page: params.page,
|
|
5659
|
-
per_page: params.per_page,
|
|
5660
|
-
phone_number_id: params.phone_number_id,
|
|
5661
|
-
waba_connection_id: params.waba_connection_id
|
|
5662
|
-
}
|
|
5663
|
-
});
|
|
5664
|
-
}
|
|
5665
|
-
get(id, params) {
|
|
5666
|
-
return this.client.requestItem("GET", `/flows/${enc7(id)}`, {
|
|
5667
|
-
query: { phone_number_id: params.phone_number_id }
|
|
5668
|
-
});
|
|
5669
|
-
}
|
|
5670
|
-
create(params) {
|
|
5671
|
-
return this.client.requestItem("POST", "/flows", { body: params });
|
|
5672
|
-
}
|
|
5673
|
-
/** Remove um flow (só DRAFT, regra da Meta). Responde 204 (sem corpo). */
|
|
5674
|
-
delete(id, params) {
|
|
5675
|
-
return this.client.request("DELETE", `/flows/${enc7(id)}`, {
|
|
5676
|
-
query: { phone_number_id: params.phone_number_id }
|
|
5677
|
-
});
|
|
5678
|
-
}
|
|
5679
|
-
publish(id, params) {
|
|
5680
|
-
return this.client.requestItem("POST", `/flows/${enc7(id)}/publish`, {
|
|
5681
|
-
body: { phone_number_id: params.phone_number_id }
|
|
5682
|
-
});
|
|
5683
|
-
}
|
|
5684
|
-
/** Lista as versões de um flow (paginação por offset/página). */
|
|
5685
|
-
listVersions(id, params = {}) {
|
|
5686
|
-
return this.client.requestOffsetList(
|
|
5687
|
-
"GET",
|
|
5688
|
-
`/flows/${enc7(id)}/versions`,
|
|
5689
|
-
{ query: { page: params.page, per_page: params.per_page } }
|
|
5690
|
-
);
|
|
5691
|
-
}
|
|
5692
|
-
createVersion(id, params) {
|
|
5693
|
-
return this.client.requestItem(
|
|
5694
|
-
"POST",
|
|
5695
|
-
`/flows/${enc7(id)}/versions`,
|
|
5696
|
-
{ body: params }
|
|
5697
|
-
);
|
|
5698
|
-
}
|
|
5699
|
-
setupEncryption(id, params) {
|
|
5700
|
-
return this.client.requestItem(
|
|
5701
|
-
"POST",
|
|
5702
|
-
`/flows/${enc7(id)}/setup_encryption`,
|
|
5703
|
-
{ body: { phone_number_id: params.phone_number_id } }
|
|
5704
|
-
);
|
|
5705
|
-
}
|
|
5706
|
-
getDataEndpoint(id) {
|
|
5707
|
-
return this.client.requestItem(
|
|
5708
|
-
"GET",
|
|
5709
|
-
`/flows/${enc7(id)}/data_endpoint`
|
|
5710
|
-
);
|
|
5711
|
-
}
|
|
5712
|
-
setDataEndpoint(id, params) {
|
|
5713
|
-
return this.client.requestItem(
|
|
5714
|
-
"POST",
|
|
5715
|
-
`/flows/${enc7(id)}/data_endpoint`,
|
|
5716
|
-
{ body: params }
|
|
5717
|
-
);
|
|
5718
|
-
}
|
|
5719
|
-
};
|
|
5720
|
-
function enc7(id) {
|
|
5721
|
-
return encodeURIComponent(id);
|
|
5722
|
-
}
|
|
5723
|
-
|
|
5724
5650
|
// src/resources/media.ts
|
|
5725
5651
|
var Media = class {
|
|
5726
5652
|
constructor(client) {
|
|
@@ -5856,7 +5782,6 @@ var BotoZap = class {
|
|
|
5856
5782
|
opportunities;
|
|
5857
5783
|
demands;
|
|
5858
5784
|
radar;
|
|
5859
|
-
flows;
|
|
5860
5785
|
media;
|
|
5861
5786
|
events;
|
|
5862
5787
|
users;
|
|
@@ -5897,7 +5822,6 @@ var BotoZap = class {
|
|
|
5897
5822
|
this.conversations = new Conversations(this);
|
|
5898
5823
|
this.webhooks = new Webhooks(this);
|
|
5899
5824
|
this.phoneNumbers = new PhoneNumbers(this);
|
|
5900
|
-
this.flows = new Flows(this);
|
|
5901
5825
|
this.media = new Media(this);
|
|
5902
5826
|
this.events = new Events(this);
|
|
5903
5827
|
this.users = new Users(this);
|