herramientaenvioestupendo 1.1.2 → 1.1.4
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 +1 -1
- package/package.json +2 -1
- package/src/index.js +1 -1
- package/src/services.js +15 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Para instalar el aplicativo CLI, deben realizar el siguiente procedimiento :
|
|
|
14
14
|
```npm i -g herramientaenvioestupendo```
|
|
15
15
|
|
|
16
16
|
- Luego de esto deben validar la version de la herramienta :
|
|
17
|
-
```estupendo --version```, si esta indica que es la 1.1.
|
|
17
|
+
```estupendo --version```, si esta indica que es la 1.1.4 es la correcta.
|
|
18
18
|
|
|
19
19
|
- Para conocer que opciones tienen de comandos solo deben ingresar en su CMD :
|
|
20
20
|
```estupendo --help```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "herramientaenvioestupendo",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Proyecto para envio documentos masivos",
|
|
6
6
|
"keywords": [],
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"axios": "^1.6.2",
|
|
24
24
|
"commander": "^11.1.0",
|
|
25
25
|
"form-data": "^4.0.0",
|
|
26
|
+
"xml-formatter": "^3.6.6",
|
|
26
27
|
"xml2js": "^0.6.2"
|
|
27
28
|
},
|
|
28
29
|
"publishConfig": {
|
package/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { program } from "commander"
|
|
|
3
3
|
import { sendTxt, sendXml, sendAttached, sendJson, requestDocumentRace, sendTxtCYP } from "./services.js"
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
program.name("estupendo").version("1.1.
|
|
6
|
+
program.name("estupendo").version("1.1.4")
|
|
7
7
|
|
|
8
8
|
program.command("send_xml")
|
|
9
9
|
.requiredOption("-d, --directory <char>", "Directorio donde se encuentran los documentos XML")
|
package/src/services.js
CHANGED
|
@@ -3,6 +3,7 @@ import path from "path"
|
|
|
3
3
|
import FormData from "form-data"
|
|
4
4
|
import axios from "axios"
|
|
5
5
|
import xml2js from "xml2js";
|
|
6
|
+
import xmlFormatter from "xml-formatter";
|
|
6
7
|
import { fileURLToPath } from "url"
|
|
7
8
|
import { request, requestFile, requestGet } from "./request_api.js"
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url)
|
|
@@ -548,9 +549,21 @@ const requestDocumentRace = async (options) => {
|
|
|
548
549
|
}
|
|
549
550
|
|
|
550
551
|
if (extractedValue) {
|
|
552
|
+
|
|
553
|
+
let cleanXML = extractedValue.replace("<![CDATA[", "").replace("]]>", "").trim();
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
let formattedXML = xmlFormatter(cleanXML, {
|
|
557
|
+
indentation: " ",
|
|
558
|
+
collapseContent: false,
|
|
559
|
+
lineSeparator: "\n",
|
|
560
|
+
whiteSpaceAtEndOfSelfclosingTag: true
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
|
|
551
564
|
const extraFilePath = path.join(documentXMLDir, `${baseName}.xml`);
|
|
552
|
-
fs.writeFileSync(extraFilePath,
|
|
553
|
-
console.log(`
|
|
565
|
+
fs.writeFileSync(extraFilePath, formattedXML, "utf-8");
|
|
566
|
+
console.log(`XML extraído y formateado guardado en: ${extraFilePath}`);
|
|
554
567
|
}
|
|
555
568
|
} catch (error) {
|
|
556
569
|
console.error(`Error descargando XML: ${baseName}`, error.message);
|