sysone-api-mapper 1.0.84 → 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"
|
|
592
|
+
responseType: "arraybuffer", // Recibe PDF binario directo
|
|
593
|
+
headers: {
|
|
594
|
+
'Accept': 'application/pdf',
|
|
595
|
+
}
|
|
593
596
|
}),
|
|
594
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)
|
|
595
616
|
if (response?.data instanceof ArrayBuffer) {
|
|
617
|
+
console.log("✅ Retornando response.data (ArrayBuffer)");
|
|
596
618
|
return response.data;
|
|
597
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,8 +631,10 @@ const quotationModule = {
|
|
|
606
631
|
method: methods.GET,
|
|
607
632
|
requestMapper: (request) => ({
|
|
608
633
|
mappedParams: request,
|
|
634
|
+
// Sin responseType = axios maneja como JSON automáticamente
|
|
609
635
|
}),
|
|
610
636
|
responseMapper: (response) => {
|
|
637
|
+
// Para CNP: devolver objeto JSON { content: "base64...", fileName: "..." }
|
|
611
638
|
if (response?.data) {
|
|
612
639
|
return response.data;
|
|
613
640
|
}
|