sysone-api-mapper 1.0.83 → 1.0.85
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/package.json
CHANGED
|
@@ -589,15 +589,40 @@ const quotationModule = {
|
|
|
589
589
|
method: methods.GET,
|
|
590
590
|
requestMapper: (request) => ({
|
|
591
591
|
mappedParams: request,
|
|
592
|
+
responseType: "arraybuffer", // Recibe PDF binario directo
|
|
592
593
|
headers: {
|
|
593
|
-
|
|
594
|
-
}
|
|
595
|
-
responseType: "arraybuffer"
|
|
594
|
+
'Accept': 'application/pdf',
|
|
595
|
+
}
|
|
596
596
|
}),
|
|
597
597
|
responseMapper: (response) => {
|
|
598
|
+
console.log("🔧 ResponseMapper DEFAULT ejecutado");
|
|
599
|
+
console.log("📦 Response recibido:", response);
|
|
600
|
+
console.log("📊 Tipo:", typeof response);
|
|
601
|
+
console.log("🔍 Tiene .data?", !!response?.data);
|
|
602
|
+
console.log("🔍 Tipo de .data:", typeof response?.data);
|
|
603
|
+
|
|
604
|
+
// Si response.data es string, convertir a ArrayBuffer
|
|
605
|
+
if (typeof response?.data === 'string') {
|
|
606
|
+
console.log("⚠️ Convirtiendo string a ArrayBuffer");
|
|
607
|
+
const binaryString = response.data;
|
|
608
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
609
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
610
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
611
|
+
}
|
|
612
|
+
return bytes.buffer;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// Para default: devolver ArrayBuffer directo (PDF binario)
|
|
616
|
+
if (response?.data instanceof ArrayBuffer) {
|
|
617
|
+
console.log("✅ Retornando response.data (ArrayBuffer)");
|
|
618
|
+
return response.data;
|
|
619
|
+
}
|
|
598
620
|
if (response instanceof ArrayBuffer) {
|
|
621
|
+
console.log("✅ Retornando response directo (ArrayBuffer)");
|
|
599
622
|
return response;
|
|
600
623
|
}
|
|
624
|
+
|
|
625
|
+
console.log("⚠️ Retornando response sin modificar");
|
|
601
626
|
return response;
|
|
602
627
|
}
|
|
603
628
|
},
|
|
@@ -606,11 +631,15 @@ const quotationModule = {
|
|
|
606
631
|
method: methods.GET,
|
|
607
632
|
requestMapper: (request) => ({
|
|
608
633
|
mappedParams: request,
|
|
609
|
-
|
|
610
|
-
"Content-Type": "application/json", // CNP devuelve JSON con base64
|
|
611
|
-
},
|
|
634
|
+
// Sin responseType = axios maneja como JSON automáticamente
|
|
612
635
|
}),
|
|
613
|
-
responseMapper: (response) =>
|
|
636
|
+
responseMapper: (response) => {
|
|
637
|
+
// Para CNP: devolver objeto JSON { content: "base64...", fileName: "..." }
|
|
638
|
+
if (response?.data) {
|
|
639
|
+
return response.data;
|
|
640
|
+
}
|
|
641
|
+
return response;
|
|
642
|
+
}
|
|
614
643
|
}
|
|
615
644
|
},
|
|
616
645
|
|