@devlas/dte-sii 2.5.13 → 2.5.14

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.
@@ -0,0 +1,78 @@
1
+ // Copyright (c) 2026 Devlas SpA
2
+ // Sistema de progreso estructurado para el runner de certificacion SII.
3
+ // El runner y la libreria emiten lineas [PROGRESS]{...json...} que la API
4
+ // parsea sin regex frágiles sobre texto libre.
5
+
6
+ const STEPS = {
7
+ // Autenticacion
8
+ AUTH_INIT: 'AUTH_INIT',
9
+ AUTH_OK: 'AUTH_OK',
10
+ // Sets
11
+ SETS_DOWNLOADING: 'SETS_DOWNLOADING',
12
+ SETS_LOADED: 'SETS_LOADED',
13
+ // CAFs
14
+ CAF_REQUESTING: 'CAF_REQUESTING', // data: { tipo }
15
+ CAF_OK: 'CAF_OK', // data: { tipo }
16
+ // Ejecucion de sets
17
+ SET_START: 'SET_START', // data: { set }
18
+ SET_SIGNING: 'SET_SIGNING', // data: { set }
19
+ SET_SENDING: 'SET_SENDING', // data: { set }
20
+ SET_OK: 'SET_OK', // data: { set, trackId }
21
+ SET_ERROR: 'SET_ERROR', // data: { set, error }
22
+ // Declaracion
23
+ SETS_DECLARING: 'SETS_DECLARING',
24
+ SETS_DECLARED: 'SETS_DECLARED',
25
+ // Polling aprobacion sets
26
+ POLLING: 'POLLING', // data: { intento, max }
27
+ SET_APPROVED: 'SET_APPROVED', // data: { set }
28
+ SETS_APPROVED: 'SETS_APPROVED',
29
+ SETS_REJECTED: 'SETS_REJECTED',
30
+ // Libros (Fase 4)
31
+ BOOKS_START: 'BOOKS_START',
32
+ BOOK_SENDING: 'BOOK_SENDING', // data: { book }
33
+ BOOK_OK: 'BOOK_OK', // data: { book, trackId }
34
+ BOOK_SKIPPED: 'BOOK_SKIPPED', // data: { book }
35
+ BOOK_ERROR: 'BOOK_ERROR', // data: { book, error }
36
+ BOOKS_DECLARING: 'BOOKS_DECLARING',
37
+ BOOKS_DONE: 'BOOKS_DONE',
38
+ // Avance (Fase 5)
39
+ ADVANCE_WAITING: 'ADVANCE_WAITING',
40
+ ADVANCE_DONE: 'ADVANCE_DONE',
41
+ // Simulacion (Fase 6)
42
+ SIM_START: 'SIM_START',
43
+ SIM_SENDING: 'SIM_SENDING',
44
+ SIM_OK: 'SIM_OK', // data: { trackId }
45
+ SIM_DECLARING: 'SIM_DECLARING',
46
+ SIM_POLLING: 'SIM_POLLING', // data: { intento, max }
47
+ SIM_DONE: 'SIM_DONE',
48
+ // Intercambio (Fase 7)
49
+ INTERCAMBIO_START: 'INTERCAMBIO_START',
50
+ INTERCAMBIO_DONE: 'INTERCAMBIO_DONE',
51
+ // Muestras impresas (Fase 8)
52
+ MUESTRAS_START: 'MUESTRAS_START',
53
+ MUESTRAS_PDFS: 'MUESTRAS_PDFS',
54
+ MUESTRAS_UPLOADING: 'MUESTRAS_UPLOADING',
55
+ MUESTRAS_DONE: 'MUESTRAS_DONE',
56
+ // Boleta electronica
57
+ BOLETA_START: 'BOLETA_START',
58
+ BOLETA_SENDING: 'BOLETA_SENDING',
59
+ BOLETA_OK: 'BOLETA_OK',
60
+ BOLETA_DECLARING: 'BOLETA_DECLARING',
61
+ BOLETA_DONE: 'BOLETA_DONE',
62
+ // Fin
63
+ CERT_DONE: 'CERT_DONE',
64
+ CERT_ERROR: 'CERT_ERROR', // data: { error }
65
+ };
66
+
67
+ /**
68
+ * Emite una linea de progreso estructurada a stdout.
69
+ * Formato: [PROGRESS]{"step":"...","clave":"valor",...}
70
+ *
71
+ * @param {string} step - Una de las constantes STEPS
72
+ * @param {Object} [data] - Datos adicionales opcionales
73
+ */
74
+ function emitProgress(step, data = {}) {
75
+ process.stdout.write(`[PROGRESS]${JSON.stringify({ step, ...data })}\n`);
76
+ }
77
+
78
+ module.exports = { STEPS, emitProgress };
package/utils/xml.js CHANGED
@@ -54,7 +54,7 @@ const prettyBuilder = new XMLBuilder({
54
54
  ignoreAttributes: false,
55
55
  attributeNamePrefix: '@_',
56
56
  format: true,
57
- indentBy: ' ',
57
+ indentBy: ' ',
58
58
  suppressEmptyNode: true,
59
59
  });
60
60
 
@@ -326,7 +326,7 @@ function saveEnvioArtifacts({
326
326
  fs.writeFileSync(path.join(debugDir, `respuesta-${debugPrefix}.xml`), responseText, 'utf-8');
327
327
  }
328
328
  } catch (saveError) {
329
- console.warn('⚠️ No se pudo guardar histórico/debug:', saveError.message || saveError);
329
+ console.warn('[!] No se pudo guardar histórico/debug:', saveError.message || saveError);
330
330
  }
331
331
  }
332
332