@growsalesai/n8n-nodes-datacrazy 1.4.5 → 1.4.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leadMover.handler.d.ts","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/handlers/utils/leadMover.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAsB,MAAM,cAAc,CAAC;AAGrE,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EACf,CAAC,EAAE,MAAM,GACR,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"leadMover.handler.d.ts","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/handlers/utils/leadMover.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAsB,MAAM,cAAc,CAAC;AAGrE,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EACf,CAAC,EAAE,MAAM,GACR,OAAO,CAAC,GAAG,CAAC,CA8Fd"}
|
|
@@ -4,7 +4,7 @@ exports.executeLeadMover = executeLeadMover;
|
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const request_1 = require("../../utils/request");
|
|
6
6
|
async function executeLeadMover(baseUrl, i) {
|
|
7
|
-
var _a, _b
|
|
7
|
+
var _a, _b;
|
|
8
8
|
const leadId = this.getNodeParameter('leadId', i, '');
|
|
9
9
|
const pipelineId = this.getNodeParameter('pipelineId', i, '', { extractValue: true });
|
|
10
10
|
const destinationStageId = this.getNodeParameter('destinationStageId', i, '', { extractValue: true });
|
|
@@ -20,7 +20,7 @@ async function executeLeadMover(baseUrl, i) {
|
|
|
20
20
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Erro ao buscar negócios do lead "${leadId}": ${err.message}`);
|
|
21
21
|
}
|
|
22
22
|
const allDeals = (_b = (_a = businessesResponse === null || businessesResponse === void 0 ? void 0 : businessesResponse.data) !== null && _a !== void 0 ? _a : businessesResponse) !== null && _b !== void 0 ? _b : [];
|
|
23
|
-
//
|
|
23
|
+
// Filter by pipeline using String() comparison to handle type mismatches
|
|
24
24
|
const filteredDeals = allDeals.filter((d) => {
|
|
25
25
|
var _a, _b, _c, _d, _e, _f;
|
|
26
26
|
const dealPipelineId = String((_c = (_b = (_a = d.stage) === null || _a === void 0 ? void 0 : _a.pipeline) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '');
|
|
@@ -44,45 +44,24 @@ async function executeLeadMover(baseUrl, i) {
|
|
|
44
44
|
});
|
|
45
45
|
dealsToMove = [sorted[0]];
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
{ businessIds, stageId: destinationStageId },
|
|
52
|
-
{ businessId: businessIds[0], stageId: destinationStageId },
|
|
53
|
-
{ businessIds, stageId: destinationStageId, pipelineId: sourcePipelineId },
|
|
54
|
-
{ ids: businessIds, stageId: destinationStageId },
|
|
55
|
-
{ business_ids: businessIds, stage_id: destinationStageId },
|
|
56
|
-
];
|
|
57
|
-
let moveResult;
|
|
58
|
-
let lastError;
|
|
59
|
-
let successVariant;
|
|
60
|
-
for (const variant of bodyVariants) {
|
|
47
|
+
// PATCH each business individually: PATCH /api/v1/businesses/:id { stageId }
|
|
48
|
+
// This is more reliable than the batch action endpoint.
|
|
49
|
+
const moveResults = [];
|
|
50
|
+
for (const deal of dealsToMove) {
|
|
61
51
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
lastError = undefined;
|
|
65
|
-
break;
|
|
52
|
+
const result = await request_1.makeRequest.call(this, baseUrl, 'PATCH', `/api/v1/businesses/${deal.id}`, { stageId: destinationStageId });
|
|
53
|
+
moveResults.push({ businessId: deal.id, result });
|
|
66
54
|
}
|
|
67
55
|
catch (err) {
|
|
68
|
-
|
|
56
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Erro ao mover negócio "${deal.id}" para etapa "${destinationStageId}": ${err.message}`);
|
|
69
57
|
}
|
|
70
58
|
}
|
|
71
|
-
if (lastError !== undefined) {
|
|
72
|
-
return {
|
|
73
|
-
success: false,
|
|
74
|
-
_moveError: lastError,
|
|
75
|
-
_triedFormats: bodyVariants,
|
|
76
|
-
_firstDeal: { id: (_g = dealsToMove[0]) === null || _g === void 0 ? void 0 : _g.id, stageId: (_h = dealsToMove[0]) === null || _h === void 0 ? void 0 : _h.stageId, pipelineId: sourcePipelineId },
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
59
|
let noteResult = null;
|
|
80
60
|
if (createNote && noteContent) {
|
|
81
61
|
try {
|
|
82
62
|
noteResult = await request_1.makeRequest.call(this, baseUrl, 'POST', `/api/v1/leads/${leadId}/notes`, { content: noteContent });
|
|
83
63
|
}
|
|
84
64
|
catch (err) {
|
|
85
|
-
// Note creation failure is non-critical; report but don't abort
|
|
86
65
|
noteResult = { error: err.message };
|
|
87
66
|
}
|
|
88
67
|
}
|
|
@@ -91,12 +70,11 @@ async function executeLeadMover(baseUrl, i) {
|
|
|
91
70
|
leadId,
|
|
92
71
|
pipelineId,
|
|
93
72
|
destinationStageId,
|
|
94
|
-
businessIdsMoved:
|
|
95
|
-
totalMoved:
|
|
96
|
-
|
|
73
|
+
businessIdsMoved: dealsToMove.map((d) => d.id),
|
|
74
|
+
totalMoved: dealsToMove.length,
|
|
75
|
+
moveResults,
|
|
97
76
|
noteCreated: createNote && !!noteContent,
|
|
98
77
|
noteResult,
|
|
99
|
-
_usedBodyVariant: successVariant,
|
|
100
78
|
};
|
|
101
79
|
}
|
|
102
80
|
//# sourceMappingURL=leadMover.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leadMover.handler.js","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/handlers/utils/leadMover.handler.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"leadMover.handler.js","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/handlers/utils/leadMover.handler.ts"],"names":[],"mappings":";;AAGA,4CAkGC;AArGD,+CAAqE;AACrE,iDAAkD;AAE3C,KAAK,UAAU,gBAAgB,CAEpC,OAAe,EACf,CAAS;;IAET,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAW,CAAC;IAChE,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAW,CAAC;IAChG,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAW,CAAC;IAChH,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,CAAY,CAAC;IAC3E,MAAM,WAAW,GAAG,UAAU,CAAC,CAAC,CAAE,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,CAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9F,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,EAAE,YAAY,CAAW,CAAC;IAExF,oCAAoC;IACpC,IAAI,kBAAuB,CAAC;IAC5B,IAAI,CAAC;QACH,kBAAkB,GAAG,MAAM,qBAAW,CAAC,IAAI,CACzC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,MAAM,aAAa,CAC3D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,MAAM,IAAI,iCAAkB,CAC1B,IAAI,CAAC,OAAO,EAAE,EACd,oCAAoC,MAAM,MAAM,GAAG,CAAC,OAAO,EA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