n8n-nodes-conversor-plataformas 0.1.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/README.md +66 -0
- package/dist/nodes/ConversorPlataformas/ConversorPlataformas.node.d.ts +5 -0
- package/dist/nodes/ConversorPlataformas/ConversorPlataformas.node.js +79 -0
- package/dist/nodes/ConversorPlataformas/ConversorPlataformas.node.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/conversorPlataformas.svg +6 -0
- package/dist/nodes/ConversorPlataformas/mappers/base.d.ts +21 -0
- package/dist/nodes/ConversorPlataformas/mappers/base.js +34 -0
- package/dist/nodes/ConversorPlataformas/mappers/base.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/mappers/eduzz.d.ts +2 -0
- package/dist/nodes/ConversorPlataformas/mappers/eduzz.js +58 -0
- package/dist/nodes/ConversorPlataformas/mappers/eduzz.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/mappers/guru.d.ts +2 -0
- package/dist/nodes/ConversorPlataformas/mappers/guru.js +72 -0
- package/dist/nodes/ConversorPlataformas/mappers/guru.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/mappers/hotmart.d.ts +2 -0
- package/dist/nodes/ConversorPlataformas/mappers/hotmart.js +76 -0
- package/dist/nodes/ConversorPlataformas/mappers/hotmart.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/mappers/index.d.ts +6 -0
- package/dist/nodes/ConversorPlataformas/mappers/index.js +28 -0
- package/dist/nodes/ConversorPlataformas/mappers/index.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/mappers/tmb.d.ts +2 -0
- package/dist/nodes/ConversorPlataformas/mappers/tmb.js +59 -0
- package/dist/nodes/ConversorPlataformas/mappers/tmb.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/normalizers.d.ts +24 -0
- package/dist/nodes/ConversorPlataformas/normalizers.js +83 -0
- package/dist/nodes/ConversorPlataformas/normalizers.js.map +1 -0
- package/dist/nodes/ConversorPlataformas/types.d.ts +26 -0
- package/dist/nodes/ConversorPlataformas/types.js +23 -0
- package/dist/nodes/ConversorPlataformas/types.js.map +1 -0
- package/index.js +3 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# n8n-nodes-conversor-plataformas
|
|
2
|
+
|
|
3
|
+
Community node para n8n que **normaliza payloads de webhooks de plataformas de venda**
|
|
4
|
+
(Hotmart, Guru, Eduzz, TMB) para um **schema canonico de compra** unico β pronto para
|
|
5
|
+
alimentar `upsert_purchase_data()` sem remapear campos a cada plataforma.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
π’ **4 plataformas implementadas e testadas**: Hotmart, Guru, Eduzz e TMB β
|
|
10
|
+
todas com compra aprovada e reembolso/estorno cobertos. Auto-deteccao por
|
|
11
|
+
user-agent + assinatura do body. Os mapas de `status` seguem o enum oficial de
|
|
12
|
+
cada plataforma (developers.hotmart.com Webhook 2.0.0; docs.digitalmanager.guru).
|
|
13
|
+
Kiwify e PagTrust entram quando houver payload real.
|
|
14
|
+
|
|
15
|
+
Convencao de `status`: reembolso/chargeback consumado -> `rejected`; contestacao
|
|
16
|
+
ainda em aberto (Hotmart `DISPUTE`/protesto, Guru `dispute`/"Reembolso Sol.") -> `pending`.
|
|
17
|
+
|
|
18
|
+
## Schema canonico (saida)
|
|
19
|
+
|
|
20
|
+
| campo | tipo | observacao |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| `nome` | string \| null | |
|
|
23
|
+
| `email` | string \| null | lowercase/trim |
|
|
24
|
+
| `telefone` | string \| null | so digitos |
|
|
25
|
+
| `valor` | number \| null | total da compra, na moeda de `moeda` |
|
|
26
|
+
| `moeda` | string \| null | BRL/EUR/USD (Hotmart internacional pode vir EUR/USD) |
|
|
27
|
+
| `id_transacao` | string \| null | id de dedup/upsert |
|
|
28
|
+
| `status` | `pending` \| `approved` \| `rejected` \| null | |
|
|
29
|
+
| `nome_produto` | string \| null | produto principal |
|
|
30
|
+
| `id_produto` | string \| null | id do produto principal |
|
|
31
|
+
| `plataforma` | enum | hotmart\|guru\|eduzz\|tmb |
|
|
32
|
+
| `itens` | ItemCompra[] | detalhamento por produto |
|
|
33
|
+
|
|
34
|
+
`ItemCompra`: `{ nome, id, valor, quantidade, tipo }`, onde `tipo` β `principal` \|
|
|
35
|
+
`order_bump` \| `desconhecido`. Heuristica atual: 1ΒΊ item = `principal`, demais =
|
|
36
|
+
`order_bump` (calibravel com payload real rotulado).
|
|
37
|
+
|
|
38
|
+
> **Moeda:** o `valor` permanece na moeda original da transacao; quem soma receita
|
|
39
|
+
> downstream deve agrupar/converter por `moeda`. Sem alteracao de banco.
|
|
40
|
+
|
|
41
|
+
## Parametros do node
|
|
42
|
+
|
|
43
|
+
- **Plataforma** β `Auto-detectar` (pela estrutura do JSON) ou plataforma fixa.
|
|
44
|
+
- **Manter Payload Original** β anexa o JSON bruto em `_original`.
|
|
45
|
+
|
|
46
|
+
## Desenvolvimento
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install
|
|
50
|
+
npm run dev # n8n-node dev: sobe n8n com o node + hot-reload
|
|
51
|
+
npm test # vitest (fixtures sanitizadas)
|
|
52
|
+
npm run smoke -- caminho.json # roda os mappers contra um export real do n8n
|
|
53
|
+
npm run lint
|
|
54
|
+
npm run build
|
|
55
|
+
npm run release # publica no npm
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Instalacao (instancia unica self-hosted)
|
|
59
|
+
|
|
60
|
+
1. `Settings` β `Community Nodes` β `Install`
|
|
61
|
+
2. Digitar `n8n-nodes-conversor-plataformas`
|
|
62
|
+
3. Aceitar o aviso de risco β `Install`
|
|
63
|
+
|
|
64
|
+
## Licenca
|
|
65
|
+
|
|
66
|
+
MIT
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type IExecuteFunctions, type INodeExecutionData, type INodeType, type INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class ConversorPlataformas implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversorPlataformas = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const mappers_1 = require("./mappers");
|
|
6
|
+
class ConversorPlataformas {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'Conversor Plataformas',
|
|
10
|
+
name: 'conversorPlataformas',
|
|
11
|
+
icon: 'file:conversorPlataformas.svg',
|
|
12
|
+
group: ['transform'],
|
|
13
|
+
version: 1,
|
|
14
|
+
subtitle: '={{ $parameter["plataforma"] }}',
|
|
15
|
+
description: 'Normaliza payloads de webhooks de plataformas de venda (Hotmart, Guru, Eduzz, TMB) para o schema canonico de compra.',
|
|
16
|
+
defaults: {
|
|
17
|
+
name: 'Conversor Plataformas',
|
|
18
|
+
},
|
|
19
|
+
inputs: ['main'],
|
|
20
|
+
outputs: ['main'],
|
|
21
|
+
properties: [
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Plataforma',
|
|
24
|
+
name: 'plataforma',
|
|
25
|
+
type: 'options',
|
|
26
|
+
options: [
|
|
27
|
+
{ name: 'Auto-detectar', value: 'auto' },
|
|
28
|
+
{ name: 'Hotmart', value: 'hotmart' },
|
|
29
|
+
{ name: 'Guru', value: 'guru' },
|
|
30
|
+
{ name: 'Eduzz', value: 'eduzz' },
|
|
31
|
+
{ name: 'TMB', value: 'tmb' },
|
|
32
|
+
],
|
|
33
|
+
default: 'auto',
|
|
34
|
+
description: 'Plataforma de origem do payload. "Auto-detectar" identifica pela estrutura do JSON.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
displayName: 'Manter Payload Original',
|
|
38
|
+
name: 'keepOriginal',
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
default: false,
|
|
41
|
+
description: 'Whether to incluir o payload bruto no campo "_original" alem do schema canonico',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async execute() {
|
|
47
|
+
const items = this.getInputData();
|
|
48
|
+
const out = [];
|
|
49
|
+
for (let i = 0; i < items.length; i++) {
|
|
50
|
+
try {
|
|
51
|
+
const plataformaParam = this.getNodeParameter('plataforma', i);
|
|
52
|
+
const keepOriginal = this.getNodeParameter('keepOriginal', i);
|
|
53
|
+
const payload = (items[i].json ?? {});
|
|
54
|
+
const mapper = plataformaParam === 'auto' ? (0, mappers_1.autoDetect)(payload) : (0, mappers_1.getMapper)(plataformaParam);
|
|
55
|
+
if (!mapper) {
|
|
56
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Nao foi possivel auto-detectar a plataforma. Selecione a plataforma manualmente.', { itemIndex: i });
|
|
57
|
+
}
|
|
58
|
+
const canonical = mapper.map(payload);
|
|
59
|
+
const json = { ...canonical };
|
|
60
|
+
if (keepOriginal)
|
|
61
|
+
json._original = payload;
|
|
62
|
+
out.push({ json, pairedItem: { item: i } });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (this.continueOnFail()) {
|
|
66
|
+
out.push({
|
|
67
|
+
json: { error: error.message },
|
|
68
|
+
pairedItem: { item: i },
|
|
69
|
+
});
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return [out];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.ConversorPlataformas = ConversorPlataformas;
|
|
79
|
+
//# sourceMappingURL=ConversorPlataformas.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversorPlataformas.node.js","sourceRoot":"","sources":["../../../nodes/ConversorPlataformas/Conversor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,CAAC;gBACD,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,CAAC;IACd,CAAC;CACD;AAlFD,oDAkFC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
|
2
|
+
<rect width="64" height="64" rx="12" fill="#0E1726"/>
|
|
3
|
+
<path d="M20 22h13a9 9 0 0 1 0 18h-5" fill="none" stroke="#37C8AB" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M24 34l-6 6 6 6" fill="none" stroke="#37C8AB" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<circle cx="44" cy="22" r="4" fill="#FF6D5A"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Plataforma, PurchaseData, TipoItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Classifica o tipo do item. Heuristica: primeiro item = principal, demais =
|
|
4
|
+
* order_bump. `orderBumpFlag` (quando a plataforma marca a transacao inteira
|
|
5
|
+
* como bump) sobrescreve. Calibravel quando houver payload real rotulado.
|
|
6
|
+
*/
|
|
7
|
+
export declare function tipoItem(index: number, orderBumpFlag?: boolean): TipoItem;
|
|
8
|
+
export interface PlatformMapper {
|
|
9
|
+
readonly platform: Plataforma;
|
|
10
|
+
/** Reconhece se o item pertence a esta plataforma (auto-deteccao). */
|
|
11
|
+
detect(item: Record<string, unknown>): boolean;
|
|
12
|
+
/** Converte o item bruto no schema canonico. */
|
|
13
|
+
map(item: Record<string, unknown>): PurchaseData;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* O Webhook node do n8n entrega { headers, params, query, body, ... }.
|
|
17
|
+
* Desembrulha para o payload real da plataforma; aceita tambem o body cru.
|
|
18
|
+
*/
|
|
19
|
+
export declare function unwrapBody(item: Record<string, unknown>): Record<string, unknown>;
|
|
20
|
+
/** Le um header (case-insensitive) do item do n8n; '' se ausente. */
|
|
21
|
+
export declare function getHeader(item: Record<string, unknown>, name: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tipoItem = tipoItem;
|
|
4
|
+
exports.unwrapBody = unwrapBody;
|
|
5
|
+
exports.getHeader = getHeader;
|
|
6
|
+
/**
|
|
7
|
+
* Classifica o tipo do item. Heuristica: primeiro item = principal, demais =
|
|
8
|
+
* order_bump. `orderBumpFlag` (quando a plataforma marca a transacao inteira
|
|
9
|
+
* como bump) sobrescreve. Calibravel quando houver payload real rotulado.
|
|
10
|
+
*/
|
|
11
|
+
function tipoItem(index, orderBumpFlag = false) {
|
|
12
|
+
if (orderBumpFlag)
|
|
13
|
+
return 'order_bump';
|
|
14
|
+
return index === 0 ? 'principal' : 'order_bump';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* O Webhook node do n8n entrega { headers, params, query, body, ... }.
|
|
18
|
+
* Desembrulha para o payload real da plataforma; aceita tambem o body cru.
|
|
19
|
+
*/
|
|
20
|
+
function unwrapBody(item) {
|
|
21
|
+
if (item && typeof item === 'object') {
|
|
22
|
+
const body = item.body;
|
|
23
|
+
if (body && typeof body === 'object')
|
|
24
|
+
return body;
|
|
25
|
+
}
|
|
26
|
+
return (item ?? {});
|
|
27
|
+
}
|
|
28
|
+
/** Le um header (case-insensitive) do item do n8n; '' se ausente. */
|
|
29
|
+
function getHeader(item, name) {
|
|
30
|
+
const headers = (item?.headers ?? {});
|
|
31
|
+
const v = headers[name.toLowerCase()];
|
|
32
|
+
return v === null || v === undefined ? '' : String(v);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../nodes/ConversorPlataformas/mappers/base.ts"],"names":[],"mappings":";;AAOA,4BAGC;AAcD,gCAMC;AAGD,8BAIC;AAnCD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,KAAa,EAAE,aAAa,GAAG,KAAK;IAC5D,IAAI,aAAa;QAAE,OAAO,YAAY,CAAC;IACvC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;AACjD,CAAC;AAUD;;;GAGG;AACH,SAAgB,UAAU,CAAC,IAA6B;IACvD,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,GAAI,IAAgC,CAAC,IAAI,CAAC;QACpD,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,IAA+B,CAAC;IAC9E,CAAC;IACD,OAAO,CAAC,IAAI,IAAI,EAAE,CAA4B,CAAC;AAChD,CAAC;AAED,qEAAqE;AACrE,SAAgB,SAAS,CAAC,IAA6B,EAAE,IAAY;IACpE,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAA4B,CAAC;IACjE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACtC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eduzzMapper = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const normalizers_1 = require("../normalizers");
|
|
6
|
+
const base_1 = require("./base");
|
|
7
|
+
// Eduzz β eventos "myeduzz.invoice_*" com data.{buyer,price,items,transaction}.
|
|
8
|
+
// Fatura pode ter varios items; pegamos o primeiro (ver README sobre multi-item).
|
|
9
|
+
const STATUS = {
|
|
10
|
+
paid: 'approved',
|
|
11
|
+
approved: 'approved',
|
|
12
|
+
open: 'pending',
|
|
13
|
+
waiting_payment: 'pending',
|
|
14
|
+
pending: 'pending',
|
|
15
|
+
recovery: 'pending',
|
|
16
|
+
generated: 'pending',
|
|
17
|
+
refunded: 'rejected',
|
|
18
|
+
canceled: 'rejected',
|
|
19
|
+
cancelled: 'rejected',
|
|
20
|
+
chargeback: 'rejected',
|
|
21
|
+
expired: 'rejected',
|
|
22
|
+
dispute: 'rejected',
|
|
23
|
+
blocked: 'rejected',
|
|
24
|
+
};
|
|
25
|
+
exports.eduzzMapper = {
|
|
26
|
+
platform: 'eduzz',
|
|
27
|
+
detect(item) {
|
|
28
|
+
if ((0, base_1.getHeader)(item, 'user-agent').toLowerCase().includes('eduzz'))
|
|
29
|
+
return true;
|
|
30
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
31
|
+
return typeof b.event === 'string' && b.event.startsWith('myeduzz');
|
|
32
|
+
},
|
|
33
|
+
map(item) {
|
|
34
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
35
|
+
const data = b.data ?? {};
|
|
36
|
+
const buyer = data.buyer ?? {};
|
|
37
|
+
const rawItems = Array.isArray(data.items) ? data.items : [];
|
|
38
|
+
const out = (0, types_1.emptyPurchase)('eduzz');
|
|
39
|
+
out.nome = (0, normalizers_1.normalizeTexto)(buyer.name);
|
|
40
|
+
out.email = (0, normalizers_1.normalizeEmail)(buyer.email);
|
|
41
|
+
out.telefone = (0, normalizers_1.normalizeTelefone)(buyer.cellphone ?? buyer.phone);
|
|
42
|
+
out.valor = (0, normalizers_1.normalizeValor)(data.price?.value ?? data.price?.paid?.value);
|
|
43
|
+
out.moeda = (0, normalizers_1.normalizeMoeda)(data.price?.currency ?? data.price?.paid?.currency);
|
|
44
|
+
out.id_transacao = (0, normalizers_1.normalizeTexto)(data.id);
|
|
45
|
+
out.status = (0, normalizers_1.normalizeStatus)(data.status, STATUS);
|
|
46
|
+
out.itens = rawItems.map((it, i) => ({
|
|
47
|
+
nome: (0, normalizers_1.normalizeTexto)(it.name),
|
|
48
|
+
id: (0, normalizers_1.normalizeTexto)(it.productId),
|
|
49
|
+
valor: (0, normalizers_1.normalizeValor)(it.price?.value),
|
|
50
|
+
quantidade: (0, normalizers_1.normalizeQuantidade)(it.quantity),
|
|
51
|
+
tipo: (0, base_1.tipoItem)(i),
|
|
52
|
+
}));
|
|
53
|
+
out.nome_produto = out.itens[0]?.nome ?? null;
|
|
54
|
+
out.id_produto = out.itens[0]?.id ?? null;
|
|
55
|
+
return out;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=eduzz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eduzz.js","sourceRoot":"","sources":["../../../../nodes/ConversorPlataformas/mappers/eduzz.ts"],"names":[],"mappings":";;;AAAA,oCAA4D;AAC5D,gDAQwB;AACxB,iCAA8E;AAE9E,gFAAgF;AAChF,kFAAkF;AAClF,MAAM,MAAM,GAAiC;IAC5C,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,SAAS;IACf,eAAe,EAAE,SAAS;IAC1B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,UAAU;IACtB,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,UAAU;CACnB,CAAC;AAEW,QAAA,WAAW,GAAmB;IAC1C,QAAQ,EAAE,OAAO;IACjB,MAAM,CAAC,IAAI;QACV,IAAI,IAAA,gBAAS,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC;QAC/E,MAAM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M,GAAG,IAAA,6BAAe,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClD,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACpC,IAAI,EAAE,IAAA,4BAAc,EAAC,EAAE,CAAC,IAAI,CAAC;YAC7B,EAAE,EAAE,IAAA,4BAAc,EAAC,EAAE,CAAC,SAAS,CAAC;YAChC,KAAK,EAAE,IAAA,4BAAc,EAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;YACtC,UAAU,EAAE,IAAA,iCAAmB,EAAC,EAAE,CAAC,QAAQ,CAAC;YAC5C,IAAI,EAAE,IAAA,eAAQ,EAAC,CAAC,CAAC;SACjB,CAAC,CAAC,CAAC;QACJ,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC;QAC9C,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC;QAC1C,OAAO,GAAG,CAAC;IACZ,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guruMapper = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const normalizers_1 = require("../normalizers");
|
|
6
|
+
const base_1 = require("./base");
|
|
7
|
+
// Digital Manager Guru β webhook_type "transaction".
|
|
8
|
+
// Status de transacao oficial (docs.digitalmanager.guru, snake_case minusculo).
|
|
9
|
+
// `dispute` = "Reembolso Sol." (solicitado, nao consumado) -> pending.
|
|
10
|
+
const STATUS = {
|
|
11
|
+
approved: 'approved',
|
|
12
|
+
paid: 'approved',
|
|
13
|
+
completed: 'approved',
|
|
14
|
+
waiting_payment: 'pending',
|
|
15
|
+
billet_printed: 'pending',
|
|
16
|
+
pending: 'pending',
|
|
17
|
+
analysis: 'pending',
|
|
18
|
+
processing: 'pending',
|
|
19
|
+
charging: 'pending',
|
|
20
|
+
scheduled: 'pending',
|
|
21
|
+
in_recovery: 'pending',
|
|
22
|
+
delayed: 'pending',
|
|
23
|
+
trial: 'pending',
|
|
24
|
+
started: 'pending',
|
|
25
|
+
dispute: 'pending',
|
|
26
|
+
canceled: 'rejected',
|
|
27
|
+
cancelled: 'rejected',
|
|
28
|
+
refunded: 'rejected',
|
|
29
|
+
chargeback: 'rejected',
|
|
30
|
+
refused: 'rejected',
|
|
31
|
+
rejected: 'rejected',
|
|
32
|
+
failed: 'rejected',
|
|
33
|
+
expired: 'rejected',
|
|
34
|
+
abandoned: 'rejected',
|
|
35
|
+
blocked: 'rejected',
|
|
36
|
+
};
|
|
37
|
+
exports.guruMapper = {
|
|
38
|
+
platform: 'guru',
|
|
39
|
+
detect(item) {
|
|
40
|
+
if ((0, base_1.getHeader)(item, 'user-agent').toLowerCase().includes('guru'))
|
|
41
|
+
return true;
|
|
42
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
43
|
+
return b.webhook_type !== undefined && typeof b.contact === 'object';
|
|
44
|
+
},
|
|
45
|
+
map(item) {
|
|
46
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
47
|
+
const contact = b.contact ?? {};
|
|
48
|
+
const payment = b.payment ?? {};
|
|
49
|
+
const product = b.product ?? {};
|
|
50
|
+
const rawItems = Array.isArray(b.items) && b.items.length > 0 ? b.items : product.id ? [product] : [];
|
|
51
|
+
const isBumpTx = Boolean(Number(b.is_order_bump));
|
|
52
|
+
const out = (0, types_1.emptyPurchase)('guru');
|
|
53
|
+
out.nome = (0, normalizers_1.normalizeTexto)(contact.name);
|
|
54
|
+
out.email = (0, normalizers_1.normalizeEmail)(contact.email);
|
|
55
|
+
out.telefone = (0, normalizers_1.normalizeTelefone)(`${contact.phone_local_code ?? ''}${contact.phone_number ?? ''}`);
|
|
56
|
+
out.valor = (0, normalizers_1.normalizeValor)(payment.total ?? payment.gross ?? payment.net);
|
|
57
|
+
out.moeda = (0, normalizers_1.normalizeMoeda)(payment.currency);
|
|
58
|
+
out.id_transacao = (0, normalizers_1.normalizeTexto)(b.id);
|
|
59
|
+
out.status = (0, normalizers_1.normalizeStatus)(b.status, STATUS);
|
|
60
|
+
out.itens = rawItems.map((it, i) => ({
|
|
61
|
+
nome: (0, normalizers_1.normalizeTexto)(it.name),
|
|
62
|
+
id: (0, normalizers_1.normalizeTexto)(it.id ?? it.marketplace_id),
|
|
63
|
+
valor: (0, normalizers_1.normalizeValor)(it.total_value ?? it.unit_value),
|
|
64
|
+
quantidade: (0, normalizers_1.normalizeQuantidade)(it.qty),
|
|
65
|
+
tipo: (0, base_1.tipoItem)(i, rawItems.length === 1 && isBumpTx),
|
|
66
|
+
}));
|
|
67
|
+
out.nome_produto = out.itens[0]?.nome ?? (0, normalizers_1.normalizeTexto)(product.name);
|
|
68
|
+
out.id_produto = out.itens[0]?.id ?? (0, normalizers_1.normalizeTexto)(product.id ?? product.marketplace_id);
|
|
69
|
+
return out;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=guru.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guru.js","sourceRoot":"","sources":["../../../../nodes/ConversorPlataformas/mappers/guru.ts"],"names":[],"mappings":";;;AAAA,oCAA4D;AAC5D,gDAQwB;AACxB,iCAA8E;AAE9E,qDAAqD;AACrD,gFAAgF;AAChF,uEAAuE;AACvE,MAAM,MAAM,GAAiC;IAC5C,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,UAAU;IAChB,SAAS,EAAE,UAAU;IACrB,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,SAAS;IACzB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,SAAS;IACnB,UAAU,EAAE,SAAS;IACrB,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE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AAE,IAAA,iCAAmB,EAAC,EAAE,CAAC,GAAG,CAAC;YACvC,IAAI,EAAE,IAAA,eAAQ,EAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC;SACpD,CAAC,CAAC,CAAC;QACJ,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,IAAA,4BAAc,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,IAAA,4BAAc,EAAC,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1F,OAAO,GAAG,CAAC;IACZ,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hotmartMapper = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const normalizers_1 = require("../normalizers");
|
|
6
|
+
const base_1 = require("./base");
|
|
7
|
+
// Hotmart β webhook v2.0.0, evento PURCHASE_* com data.purchase.
|
|
8
|
+
// ATENCAO: vendas internacionais vem em moeda estrangeira (price.currency_value
|
|
9
|
+
// pode ser EUR/USD). O schema canonico nao tem coluna de moeda β ver README.
|
|
10
|
+
// Enum oficial de data.purchase.status (developers.hotmart.com, Webhook 2.0.0),
|
|
11
|
+
// em minuscula (normalizeStatus faz lowercase). `dispute`/protesto = contestacao
|
|
12
|
+
// ainda nao consumada -> pending; reversoes consumadas -> rejected.
|
|
13
|
+
const STATUS = {
|
|
14
|
+
approved: 'approved',
|
|
15
|
+
complete: 'approved',
|
|
16
|
+
completed: 'approved',
|
|
17
|
+
waiting_payment: 'pending',
|
|
18
|
+
printed_billet: 'pending',
|
|
19
|
+
pre_order: 'pending',
|
|
20
|
+
processing_transaction: 'pending',
|
|
21
|
+
started: 'pending',
|
|
22
|
+
delayed: 'pending',
|
|
23
|
+
overdue: 'pending',
|
|
24
|
+
under_analisys: 'pending', // grafia oficial (sic)
|
|
25
|
+
under_analysis: 'pending', // grafia correta, por seguranca
|
|
26
|
+
analysis: 'pending',
|
|
27
|
+
dispute: 'pending',
|
|
28
|
+
protested: 'pending',
|
|
29
|
+
no_funds: 'rejected',
|
|
30
|
+
blocked: 'rejected',
|
|
31
|
+
cancelled: 'rejected',
|
|
32
|
+
canceled: 'rejected',
|
|
33
|
+
refunded: 'rejected',
|
|
34
|
+
partially_refunded: 'rejected',
|
|
35
|
+
chargeback: 'rejected',
|
|
36
|
+
expired: 'rejected',
|
|
37
|
+
};
|
|
38
|
+
exports.hotmartMapper = {
|
|
39
|
+
platform: 'hotmart',
|
|
40
|
+
detect(item) {
|
|
41
|
+
if ((0, base_1.getHeader)(item, 'x-hotmart-hottok'))
|
|
42
|
+
return true;
|
|
43
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
44
|
+
return typeof b.data === 'object' && typeof b.data?.purchase === 'object';
|
|
45
|
+
},
|
|
46
|
+
map(item) {
|
|
47
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
48
|
+
const data = b.data ?? {};
|
|
49
|
+
const buyer = data.buyer ?? {};
|
|
50
|
+
const purchase = data.purchase ?? {};
|
|
51
|
+
const product = data.product ?? {};
|
|
52
|
+
const isBump = purchase.order_bump?.is_order_bump === true;
|
|
53
|
+
const out = (0, types_1.emptyPurchase)('hotmart');
|
|
54
|
+
out.nome = (0, normalizers_1.normalizeTexto)(buyer.name);
|
|
55
|
+
out.email = (0, normalizers_1.normalizeEmail)(buyer.email);
|
|
56
|
+
out.telefone = (0, normalizers_1.normalizeTelefone)(buyer.checkout_phone);
|
|
57
|
+
out.valor = (0, normalizers_1.normalizeValor)(purchase.price?.value ?? purchase.full_price?.value);
|
|
58
|
+
out.moeda = (0, normalizers_1.normalizeMoeda)(purchase.price?.currency_value ?? purchase.full_price?.currency_value);
|
|
59
|
+
out.id_transacao = (0, normalizers_1.normalizeTexto)(purchase.transaction);
|
|
60
|
+
out.status = (0, normalizers_1.normalizeStatus)(purchase.status, STATUS);
|
|
61
|
+
out.nome_produto = (0, normalizers_1.normalizeTexto)(product.name);
|
|
62
|
+
out.id_produto = (0, normalizers_1.normalizeTexto)(product.id);
|
|
63
|
+
// Hotmart entrega um produto por webhook (bumps vem em eventos separados).
|
|
64
|
+
out.itens = [
|
|
65
|
+
{
|
|
66
|
+
nome: out.nome_produto,
|
|
67
|
+
id: out.id_produto,
|
|
68
|
+
valor: out.valor,
|
|
69
|
+
quantidade: 1,
|
|
70
|
+
tipo: isBump ? 'order_bump' : 'principal',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
return out;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=hotmart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotmart.js","sourceRoot":"","sources":["../../../../nodes/ConversorPlataformas/mappers/hotmart.ts"],"names":[],"mappings":";;;AAAA,oCAA4D;AAC5D,gDAOwB;AACxB,iCAAoE;AAEpE,iEAAiE;AACjE,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,iFAAiF;AACjF,oEAAoE;AACpE,MAAM,MAAM,GAAiC;IAC5C,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,UAAU;IACrB,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,SAAS;IACzB,SAAS,EAAE,SAAS;IACpB,sBAAsB,EAAE,SAAS;IACjC,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,SAAS,EAAE,uBAAuB;IAClD,cAAc,EAAE,SAAS,EAAE,gCAAgC;IAC3D,QAAQ,EAAE,SAAS;IACnB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,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EAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACvD,GAAG,CAAC,KAAK,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,IAAI,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAChF,GAAG,CAAC,KAAK,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,IAAI,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAClG,GAAG,CAAC,YAAY,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACxD,GAAG,CAAC,MAAM,GAAG,IAAA,6BAAe,EAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,GAAG,CAAC,YAAY,GAAG,IAAA,4BAAc,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChD,GAAG,CAAC,UAAU,GAAG,IAAA,4BAAc,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5C,2EAA2E;QAC3E,GAAG,CAAC,KAAK,GAAG;YACX;gBACC,IAAI,EAAE,GAAG,CAAC,YAAY;gBACtB,EAAE,EAAE,GAAG,CAAC,UAAU;gBAClB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,UAAU,EAAE,CAAC;gBACb,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW;aACzC;SACD,CAAC;QACF,OAAO,GAAG,CAAC;IACZ,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Plataforma } from '../types';
|
|
2
|
+
import type { PlatformMapper } from './base';
|
|
3
|
+
export type { PlatformMapper } from './base';
|
|
4
|
+
export declare const mappers: PlatformMapper[];
|
|
5
|
+
export declare function getMapper(platform: Plataforma): PlatformMapper;
|
|
6
|
+
export declare function autoDetect(item: Record<string, unknown>): PlatformMapper | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mappers = void 0;
|
|
4
|
+
exports.getMapper = getMapper;
|
|
5
|
+
exports.autoDetect = autoDetect;
|
|
6
|
+
const guru_1 = require("./guru");
|
|
7
|
+
const hotmart_1 = require("./hotmart");
|
|
8
|
+
const eduzz_1 = require("./eduzz");
|
|
9
|
+
const tmb_1 = require("./tmb");
|
|
10
|
+
// Ordem nao importa: as assinaturas de detect() sao disjuntas entre plataformas.
|
|
11
|
+
exports.mappers = [hotmart_1.hotmartMapper, guru_1.guruMapper, eduzz_1.eduzzMapper, tmb_1.tmbMapper];
|
|
12
|
+
function getMapper(platform) {
|
|
13
|
+
const m = exports.mappers.find((x) => x.platform === platform);
|
|
14
|
+
if (!m)
|
|
15
|
+
throw new Error(`Plataforma desconhecida: ${platform}`);
|
|
16
|
+
return m;
|
|
17
|
+
}
|
|
18
|
+
function autoDetect(item) {
|
|
19
|
+
return (exports.mappers.find((m) => {
|
|
20
|
+
try {
|
|
21
|
+
return m.detect(item);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}) ?? null);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/ConversorPlataformas/mappers/index.ts"],"names":[],"mappings":";;;AAYA,8BAIC;AAED,gCAUC;AA1BD,iCAAoC;AACpC,uCAA0C;AAC1C,mCAAsC;AACtC,+BAAkC;AAIlC,iFAAiF;AACpE,QAAA,OAAO,GAAqB,CAAC,uBAAa,EAAE,iBAAU,EAAE,mBAAW,EAAE,eAAS,CAAC,CAAC;AAE7F,SAAgB,SAAS,CAAC,QAAoB;IAC7C,MAAM,CAAC,GAAG,eAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAgB,UAAU,CAAC,IAA6B;IACvD,OAAO,CACN,eAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QAClB,IAAI,CAAC;YACJ,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC,CAAC,IAAI,IAAI,CACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tmbMapper = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const normalizers_1 = require("../normalizers");
|
|
6
|
+
const base_1 = require("./base");
|
|
7
|
+
// TMB β payload flat (consorcio/financiamento: parcelas, valor_entrada,
|
|
8
|
+
// taxa_administracao). Campos em pt-BR no proprio body.
|
|
9
|
+
const STATUS = {
|
|
10
|
+
efetivado: 'approved',
|
|
11
|
+
aprovado: 'approved',
|
|
12
|
+
pago: 'approved',
|
|
13
|
+
confirmado: 'approved',
|
|
14
|
+
pendente: 'pending',
|
|
15
|
+
aguardando: 'pending',
|
|
16
|
+
'aguardando pagamento': 'pending',
|
|
17
|
+
processando: 'pending',
|
|
18
|
+
em_analise: 'pending',
|
|
19
|
+
cancelado: 'rejected',
|
|
20
|
+
estornado: 'rejected',
|
|
21
|
+
reembolsado: 'rejected',
|
|
22
|
+
recusado: 'rejected',
|
|
23
|
+
reprovado: 'rejected',
|
|
24
|
+
expirado: 'rejected',
|
|
25
|
+
};
|
|
26
|
+
exports.tmbMapper = {
|
|
27
|
+
platform: 'tmb',
|
|
28
|
+
detect(item) {
|
|
29
|
+
if ((0, base_1.getHeader)(item, 'user-agent').toLowerCase().includes('tmb'))
|
|
30
|
+
return true;
|
|
31
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
32
|
+
return b.status_pedido !== undefined && b.lancamento !== undefined;
|
|
33
|
+
},
|
|
34
|
+
map(item) {
|
|
35
|
+
const b = (0, base_1.unwrapBody)(item);
|
|
36
|
+
const out = (0, types_1.emptyPurchase)('tmb');
|
|
37
|
+
out.nome = (0, normalizers_1.normalizeTexto)(b.cliente);
|
|
38
|
+
out.email = (0, normalizers_1.normalizeEmail)(b.email);
|
|
39
|
+
out.telefone = (0, normalizers_1.normalizeTelefone)(b.telefone_ativo ?? b.telefones);
|
|
40
|
+
out.valor = (0, normalizers_1.normalizeValor)(b.valor_total ?? b.valor_principal);
|
|
41
|
+
// TMB (consorcio BR) nao envia moeda no payload; assumimos BRL.
|
|
42
|
+
out.moeda = 'BRL';
|
|
43
|
+
out.id_transacao = (0, normalizers_1.normalizeTexto)(b.code ?? b.pedido ?? b.id);
|
|
44
|
+
out.status = (0, normalizers_1.normalizeStatus)(b.status_pedido, STATUS);
|
|
45
|
+
out.nome_produto = (0, normalizers_1.normalizeTexto)(b.lancamento ?? b.titulo);
|
|
46
|
+
out.id_produto = (0, normalizers_1.normalizeTexto)(b.lancamento_id);
|
|
47
|
+
out.itens = [
|
|
48
|
+
{
|
|
49
|
+
nome: out.nome_produto,
|
|
50
|
+
id: out.id_produto,
|
|
51
|
+
valor: out.valor,
|
|
52
|
+
quantidade: 1,
|
|
53
|
+
tipo: 'principal',
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
return out;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=tmb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmb.js","sourceRoot":"","sources":["../../../../nodes/ConversorPlataformas/mappers/tmb.ts"],"names":[],"mappings":";;;AAAA,oCAA4D;AAC5D,gDAMwB;AACx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AAC,KAAK,GAAG,IAAA,4BAAc,EAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,eAAe,CAAC,CAAC;QAC/D,gEAAgE;QAChE,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;QAClB,GAAG,CAAC,YAAY,GAAG,IAAA,4BAAc,EAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9D,GAAG,CAAC,MAAM,GAAG,IAAA,6BAAe,EAAC,CAAC,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACtD,GAAG,CAAC,YAAY,GAAG,IAAA,4BAAc,EAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;QAC5D,GAAG,CAAC,UAAU,GAAG,IAAA,4BAAc,EAAC,CAAC,CAAC,aAAa,CAAC,CAAC;QACjD,GAAG,CAAC,KAAK,GAAG;YACX;gBACC,IAAI,EAAE,GAAG,CAAC,YAAY;gBACtB,EAAE,EAAE,GAAG,CAAC,UAAU;gBAClB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,UAAU,EAAE,CAAC;gBACb,IAAI,EAAE,WAAW;aACjB;SACD,CAAC;QACF,OAAO,GAAG,CAAC;IACZ,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StatusCompra } from './types';
|
|
2
|
+
/** Mantem apenas digitos (DDI + DDD + numero). Retorna null se vazio. */
|
|
3
|
+
export declare function normalizeTelefone(raw: unknown): string | null;
|
|
4
|
+
/** Email em lowercase e trimmed. */
|
|
5
|
+
export declare function normalizeEmail(raw: unknown): string | null;
|
|
6
|
+
/** Texto trimmed; null se vazio. */
|
|
7
|
+
export declare function normalizeTexto(raw: unknown): string | null;
|
|
8
|
+
/** Codigo de moeda em UPPERCASE (BRL, EUR, USD). */
|
|
9
|
+
export declare function normalizeMoeda(raw: unknown): string | null;
|
|
10
|
+
/** Quantidade numerica; default 1 quando ausente/invalida. */
|
|
11
|
+
export declare function normalizeQuantidade(raw: unknown): number;
|
|
12
|
+
/**
|
|
13
|
+
* Converte valor monetario para number.
|
|
14
|
+
* Aceita number, "1.234,56" (BR), "1234.56" (US) ou centavos inteiros.
|
|
15
|
+
* @param opts.cents quando true, divide por 100 (plataformas que mandam centavos).
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeValor(raw: unknown, opts?: {
|
|
18
|
+
cents?: boolean;
|
|
19
|
+
}): number | null;
|
|
20
|
+
/**
|
|
21
|
+
* Mapeia o status bruto da plataforma para o enum canonico.
|
|
22
|
+
* @param map dicionario lowercase -> StatusCompra, definido por cada mapper.
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeStatus(raw: unknown, map: Record<string, StatusCompra>): StatusCompra | null;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Normalizadores reutilizaveis entre todas as plataformas.
|
|
3
|
+
// Sao independentes de payload: a logica abaixo ja e definitiva.
|
|
4
|
+
// Cada mapper extrai o campo bruto e passa por aqui.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.normalizeTelefone = normalizeTelefone;
|
|
7
|
+
exports.normalizeEmail = normalizeEmail;
|
|
8
|
+
exports.normalizeTexto = normalizeTexto;
|
|
9
|
+
exports.normalizeMoeda = normalizeMoeda;
|
|
10
|
+
exports.normalizeQuantidade = normalizeQuantidade;
|
|
11
|
+
exports.normalizeValor = normalizeValor;
|
|
12
|
+
exports.normalizeStatus = normalizeStatus;
|
|
13
|
+
/** Mantem apenas digitos (DDI + DDD + numero). Retorna null se vazio. */
|
|
14
|
+
function normalizeTelefone(raw) {
|
|
15
|
+
if (raw === null || raw === undefined)
|
|
16
|
+
return null;
|
|
17
|
+
const digits = String(raw).replace(/\D+/g, '');
|
|
18
|
+
return digits.length > 0 ? digits : null;
|
|
19
|
+
}
|
|
20
|
+
/** Email em lowercase e trimmed. */
|
|
21
|
+
function normalizeEmail(raw) {
|
|
22
|
+
if (raw === null || raw === undefined)
|
|
23
|
+
return null;
|
|
24
|
+
const e = String(raw).trim().toLowerCase();
|
|
25
|
+
return e.length > 0 ? e : null;
|
|
26
|
+
}
|
|
27
|
+
/** Texto trimmed; null se vazio. */
|
|
28
|
+
function normalizeTexto(raw) {
|
|
29
|
+
if (raw === null || raw === undefined)
|
|
30
|
+
return null;
|
|
31
|
+
const s = String(raw).trim();
|
|
32
|
+
return s.length > 0 ? s : null;
|
|
33
|
+
}
|
|
34
|
+
/** Codigo de moeda em UPPERCASE (BRL, EUR, USD). */
|
|
35
|
+
function normalizeMoeda(raw) {
|
|
36
|
+
if (raw === null || raw === undefined)
|
|
37
|
+
return null;
|
|
38
|
+
const s = String(raw).trim().toUpperCase();
|
|
39
|
+
return s.length > 0 ? s : null;
|
|
40
|
+
}
|
|
41
|
+
/** Quantidade numerica; default 1 quando ausente/invalida. */
|
|
42
|
+
function normalizeQuantidade(raw) {
|
|
43
|
+
const n = typeof raw === 'number' ? raw : Number(raw);
|
|
44
|
+
return Number.isFinite(n) && n > 0 ? n : 1;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converte valor monetario para number.
|
|
48
|
+
* Aceita number, "1.234,56" (BR), "1234.56" (US) ou centavos inteiros.
|
|
49
|
+
* @param opts.cents quando true, divide por 100 (plataformas que mandam centavos).
|
|
50
|
+
*/
|
|
51
|
+
function normalizeValor(raw, opts = {}) {
|
|
52
|
+
if (raw === null || raw === undefined || raw === '')
|
|
53
|
+
return null;
|
|
54
|
+
if (typeof raw === 'number') {
|
|
55
|
+
return opts.cents ? raw / 100 : raw;
|
|
56
|
+
}
|
|
57
|
+
let s = String(raw).trim().replace(/[^\d.,-]/g, '');
|
|
58
|
+
if (!s)
|
|
59
|
+
return null;
|
|
60
|
+
if (s.includes(',') && s.includes('.')) {
|
|
61
|
+
// "1.234,56" -> remove separador de milhar e troca virgula decimal
|
|
62
|
+
s = s.replace(/\./g, '').replace(',', '.');
|
|
63
|
+
}
|
|
64
|
+
else if (s.includes(',')) {
|
|
65
|
+
// "12,90" -> "12.90"
|
|
66
|
+
s = s.replace(',', '.');
|
|
67
|
+
}
|
|
68
|
+
const n = Number(s);
|
|
69
|
+
if (Number.isNaN(n))
|
|
70
|
+
return null;
|
|
71
|
+
return opts.cents ? n / 100 : n;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Mapeia o status bruto da plataforma para o enum canonico.
|
|
75
|
+
* @param map dicionario lowercase -> StatusCompra, definido por cada mapper.
|
|
76
|
+
*/
|
|
77
|
+
function normalizeStatus(raw, map) {
|
|
78
|
+
if (raw === null || raw === undefined)
|
|
79
|
+
return null;
|
|
80
|
+
const key = String(raw).trim().toLowerCase();
|
|
81
|
+
return map[key] ?? null;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=normalizers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizers.js","sourceRoot":"","sources":["../../../nodes/ConversorPlataformas/normalizers.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,iEAAiE;AACjE,qDAAqD;;AAKrD,8CAIC;AAGD,wCAIC;AAGD,wCAIC;AAGD,wCAIC;AAGD,kDAGC;AAOD,wCAqBC;AAMD,0CAOC;AAzED,yEAAyE;AACzE,SAAgB,iBAAiB,CAAC,GAAY;IAC7C,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,oCAAoC;AACpC,SAAgB,cAAc,CAAC,GAAY;IAC1C,IAAI,GAAG,KAAK,IAAI,IAAI,GAA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,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7C,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type Plataforma = 'hotmart' | 'guru' | 'eduzz' | 'tmb';
|
|
2
|
+
export type StatusCompra = 'pending' | 'approved' | 'rejected';
|
|
3
|
+
export type TipoItem = 'principal' | 'order_bump' | 'desconhecido';
|
|
4
|
+
export interface ItemCompra {
|
|
5
|
+
nome: string | null;
|
|
6
|
+
id: string | null;
|
|
7
|
+
valor: number | null;
|
|
8
|
+
quantidade: number | null;
|
|
9
|
+
tipo: TipoItem;
|
|
10
|
+
}
|
|
11
|
+
export interface PurchaseData {
|
|
12
|
+
nome: string | null;
|
|
13
|
+
email: string | null;
|
|
14
|
+
telefone: string | null;
|
|
15
|
+
valor: number | null;
|
|
16
|
+
moeda: string | null;
|
|
17
|
+
id_transacao: string | null;
|
|
18
|
+
status: StatusCompra | null;
|
|
19
|
+
nome_produto: string | null;
|
|
20
|
+
id_produto: string | null;
|
|
21
|
+
plataforma: Plataforma;
|
|
22
|
+
/** Detalhamento por produto (principal, order bumps, upsells). */
|
|
23
|
+
itens: ItemCompra[];
|
|
24
|
+
}
|
|
25
|
+
/** Schema canonico vazio β base para os mappers preencherem. */
|
|
26
|
+
export declare function emptyPurchase(plataforma: Plataforma): PurchaseData;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Contrato canonico de saida do node. Os campos planos (nome..plataforma)
|
|
3
|
+
// espelham public.purchase_data; `moeda` e `itens` sao extensoes da SAIDA do
|
|
4
|
+
// node (nao exigem alteracao de banco β o consumo downstream decide o que gravar).
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.emptyPurchase = emptyPurchase;
|
|
7
|
+
/** Schema canonico vazio β base para os mappers preencherem. */
|
|
8
|
+
function emptyPurchase(plataforma) {
|
|
9
|
+
return {
|
|
10
|
+
nome: null,
|
|
11
|
+
email: null,
|
|
12
|
+
telefone: null,
|
|
13
|
+
valor: null,
|
|
14
|
+
moeda: null,
|
|
15
|
+
id_transacao: null,
|
|
16
|
+
status: null,
|
|
17
|
+
nome_produto: null,
|
|
18
|
+
id_produto: null,
|
|
19
|
+
plataforma,
|
|
20
|
+
itens: [],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../nodes/ConversorPlataformas/types.ts"],"names":[],"mappings":";AAAA,0EAA0E;AAC1E,6EAA6E;AAC7E,mFAAmF;;AAgCnF,sCAcC;AAfD,gEAAgE;AAChE,SAAgB,aAAa,CAAC,UAAsB;IACnD,OAAO;QACN,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,UAAU;QACV,KAAK,EAAE,EAAE;KACT,CAAC;AACH,CAAC"}
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-conversor-plataformas",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Community node n8n que normaliza payloads de webhooks de plataformas de venda (Hotmart, Guru, Eduzz, TMB) para um schema canonico de compra.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"n8n",
|
|
8
|
+
"hotmart",
|
|
9
|
+
"eduzz",
|
|
10
|
+
"guru",
|
|
11
|
+
"tmb",
|
|
12
|
+
"webhook",
|
|
13
|
+
"checkout"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Caio (Advanced Tracking)",
|
|
17
|
+
"homepage": "",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": ""
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.0.0"
|
|
24
|
+
},
|
|
25
|
+
"main": "index.js",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "n8n-node build",
|
|
28
|
+
"dev": "n8n-node dev",
|
|
29
|
+
"lint": "n8n-node lint",
|
|
30
|
+
"lint:fix": "n8n-node lint --fix",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"smoke": "tsx scripts/smoke.ts",
|
|
34
|
+
"release": "n8n-node release",
|
|
35
|
+
"prepublishOnly": "n8n-node prerelease"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"n8n": {
|
|
41
|
+
"n8nNodesApiVersion": 1,
|
|
42
|
+
"strict": true,
|
|
43
|
+
"nodes": [
|
|
44
|
+
"dist/nodes/ConversorPlataformas/ConversorPlataformas.node.js"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"n8n-workflow": "*"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@n8n/node-cli": "*",
|
|
52
|
+
"n8n-workflow": "*",
|
|
53
|
+
"tsx": "^4.19.0",
|
|
54
|
+
"typescript": "^5.5.0",
|
|
55
|
+
"vitest": "^2.1.0"
|
|
56
|
+
}
|
|
57
|
+
}
|