@wondai/n8n-nodes-nucleo 0.4.3 → 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.
@@ -234,6 +234,12 @@ class Nucleo {
234
234
  action: "Cancelar pedido",
235
235
  description: "Cancela o pedido inteiro (idempotente)",
236
236
  },
237
+ {
238
+ name: "Anexar Imagem",
239
+ value: "anexar",
240
+ action: "Anexar foto-referência ao pedido",
241
+ description: "Anexa a FOTO que o cliente mandou no WhatsApp (a decoração que ele quer) ao pedido — a imagem literal, não uma descrição. Recebe base64 (data-URL ou puro + mime). Idempotente pelo messageID.",
242
+ },
237
243
  ],
238
244
  default: "criar",
239
245
  },
@@ -469,9 +475,11 @@ class Nucleo {
469
475
  type: "string",
470
476
  default: "",
471
477
  description: "Opcional. Para criar: vazio = gerada automaticamente. Para alterar/cancelar: use a MESMA chave (ex.: messageID do WhatsApp) num retry para não reaplicar a operação.",
472
- displayOptions: { show: { resource: ["pedido"], operation: ["criar", "alterar", "cancelar"] } },
478
+ displayOptions: {
479
+ show: { resource: ["pedido"], operation: ["criar", "alterar", "cancelar", "anexar"] },
480
+ },
473
481
  },
474
- // ----------------------------------------------------------------- pedido:alterar / cancelar
482
+ // ----------------------------------------------------------------- pedido:alterar / cancelar / anexar
475
483
  {
476
484
  displayName: "Pedido ID",
477
485
  name: "pedidoId",
@@ -479,7 +487,7 @@ class Nucleo {
479
487
  default: "",
480
488
  required: true,
481
489
  description: "Id do pedido (do tenant). Pedido de outra padaria → 404.",
482
- displayOptions: { show: { resource: ["pedido"], operation: ["alterar", "cancelar"] } },
490
+ displayOptions: { show: { resource: ["pedido"], operation: ["alterar", "cancelar", "anexar"] } },
483
491
  },
484
492
  {
485
493
  displayName: "Observações",
@@ -612,6 +620,39 @@ class Nucleo {
612
620
  description: "Motivo do cancelamento (opcional).",
613
621
  displayOptions: { show: { resource: ["pedido"], operation: ["cancelar"] } },
614
622
  },
623
+ // ----------------------------------------------------------------- pedido:anexar
624
+ {
625
+ displayName: "Imagem (base64)",
626
+ name: "imagemBase64",
627
+ type: "string",
628
+ typeOptions: { rows: 2 },
629
+ default: "",
630
+ required: true,
631
+ description: "A imagem que o cliente mandou, em base64. Aceita data-URL (data:image/jpeg;base64,...) — de onde o mime é lido — OU base64 puro (então preencha 'MIME'). Limite 5 MB; PNG/JPG/WEBP.",
632
+ displayOptions: { show: { resource: ["pedido"], operation: ["anexar"] } },
633
+ },
634
+ {
635
+ displayName: "MIME (se base64 puro)",
636
+ name: "imagemMime",
637
+ type: "options",
638
+ options: [
639
+ { name: "(data-URL traz o mime)", value: "" },
640
+ { name: "image/jpeg", value: "image/jpeg" },
641
+ { name: "image/png", value: "image/png" },
642
+ { name: "image/webp", value: "image/webp" },
643
+ ],
644
+ default: "",
645
+ description: "Obrigatório só quando a imagem for base64 PURO (sem o prefixo data:). Com data-URL, deixe vazio.",
646
+ displayOptions: { show: { resource: ["pedido"], operation: ["anexar"] } },
647
+ },
648
+ {
649
+ displayName: "Legenda",
650
+ name: "imagemLegenda",
651
+ type: "string",
652
+ default: "",
653
+ description: "Opcional. Texto curto sobre a foto (ex.: a legenda que veio com a imagem).",
654
+ displayOptions: { show: { resource: ["pedido"], operation: ["anexar"] } },
655
+ },
615
656
  // ----------------------------------------------------------------- conversa:registrar
616
657
  {
617
658
  displayName: "Resumo",
@@ -950,6 +991,24 @@ class Nucleo {
950
991
  path = `/api/v1/agent/pedido/${encodeURIComponent(pedidoId)}/cancelar`;
951
992
  bodyObj = motivo ? { motivo } : {};
952
993
  }
994
+ else if (resource === "pedido" && operation === "anexar") {
995
+ const pedidoId = this.getNodeParameter("pedidoId", i).trim();
996
+ const imagemBase64 = this.getNodeParameter("imagemBase64", i).trim();
997
+ const mime = this.getNodeParameter("imagemMime", i, "").trim();
998
+ const legenda = this.getNodeParameter("imagemLegenda", i, "").trim();
999
+ const b = { imagem_base64: imagemBase64 };
1000
+ // mime só é necessário quando a imagem é base64 PURO; data-URL já carrega o mime.
1001
+ if (mime && !imagemBase64.startsWith("data:"))
1002
+ b.mime = mime;
1003
+ if (legenda)
1004
+ b.legenda = legenda;
1005
+ // Idempotência: mesma chave (messageID do WhatsApp) num retry → não duplica a foto.
1006
+ idempotencyKey =
1007
+ this.getNodeParameter("idempotencyKey", i, "").trim() || undefined;
1008
+ method = "POST";
1009
+ path = `/api/v1/agent/pedido/${encodeURIComponent(pedidoId)}/anexo`;
1010
+ bodyObj = b;
1011
+ }
953
1012
  else if (resource === "conversa" && operation === "registrar") {
954
1013
  const resumo = this.getNodeParameter("resumo", i).trim();
955
1014
  const resultado = this.getNodeParameter("resultado", i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wondai/n8n-nodes-nucleo",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Node n8n para o Núcleo Wondai — atendimento de IA (gate liga/desliga, cliente, catálogo fuzzy, disponibilidade em rede, pedidos, contexto operacional, telemetria) com assinatura HMAC v1. Tenant vem do token (a parede, ADR-013).",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",