n8n-nodes-aib 0.4.0 → 0.4.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.
|
@@ -6,14 +6,30 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
6
6
|
async function api(ctx, method, path, body, qs) {
|
|
7
7
|
const cred = (await ctx.getCredentials("aibDigitalApi"));
|
|
8
8
|
const base = String(cred.baseUrl).replace(/\/+$/, "");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
try {
|
|
10
|
+
return await ctx.helpers.httpRequest({
|
|
11
|
+
method,
|
|
12
|
+
url: `${base}${path}`,
|
|
13
|
+
qs,
|
|
14
|
+
body,
|
|
15
|
+
json: true,
|
|
16
|
+
headers: { Authorization: `Bearer ${cred.apiKey}` },
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
// A API responde { error: "..." } com a causa real; o axios do n8n
|
|
21
|
+
// esconde isso atrás de "Request failed with status code 400".
|
|
22
|
+
// Traz a mensagem de verdade para o usuário.
|
|
23
|
+
const corpo = e?.response?.body ?? e?.cause?.response?.body;
|
|
24
|
+
const msg = (corpo && typeof corpo === "object" && (corpo.error || corpo.message)) ||
|
|
25
|
+
(typeof corpo === "string" && corpo) ||
|
|
26
|
+
e?.message;
|
|
27
|
+
const status = e?.httpCode ?? e?.response?.status ?? e?.cause?.response?.status;
|
|
28
|
+
throw new n8n_workflow_1.NodeApiError(ctx.getNode(), e, {
|
|
29
|
+
message: status ? `AIB (${status}): ${msg}` : `AIB: ${msg}`,
|
|
30
|
+
description: "Resposta do Sistema AIB Digital",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
17
33
|
}
|
|
18
34
|
/** A conta escolhida no nó (vazio = a conta da própria chave). */
|
|
19
35
|
function contaQs(ctx, i) {
|
|
@@ -432,6 +448,9 @@ class AibDigital {
|
|
|
432
448
|
res = { id: "", nome: "— a conta da chave —", escopo: ping?.escopo };
|
|
433
449
|
}
|
|
434
450
|
}
|
|
451
|
+
else if (operation === "__CUSTOM_API_CALL__") {
|
|
452
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Escolha o Recurso e a Operação no nó (o n8n perdeu a seleção ao atualizar o pacote).", { description: "Reabra o nó, selecione Recurso → Operação e salve." });
|
|
453
|
+
}
|
|
435
454
|
else {
|
|
436
455
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operação desconhecida: ${operation}`);
|
|
437
456
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-aib",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Nós do Sistema AIB Digital para n8n: gatilho de mensagens do WhatsApp (via AIB Inbox) e ações — enviar mensagem, mover card no funil, pausar IA — escolhendo conta e caixa por dropdown.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AIB Digital",
|