dgii-ts 0.1.2 → 0.1.3

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.
Files changed (43) hide show
  1. package/README.en.md +4 -0
  2. package/README.md +4 -0
  3. package/dist/bulk.cjs +8 -2
  4. package/dist/bulk.d.cts +48 -5
  5. package/dist/bulk.d.ts +48 -5
  6. package/dist/bulk.js +7 -1
  7. package/dist/{chunk-BQPH3JDZ.cjs → chunk-AML7LZBU.cjs} +12 -12
  8. package/dist/{chunk-JBKAE66C.cjs → chunk-DLB5RJ7E.cjs} +16 -16
  9. package/dist/{chunk-DMGDJEUY.js → chunk-IRQX4WNQ.js} +8 -1
  10. package/dist/{chunk-ROJUYPIK.js → chunk-KJXLES3I.js} +3 -3
  11. package/dist/{chunk-53A7IG4Y.js → chunk-KW4ZV6FJ.js} +1 -1
  12. package/dist/{chunk-5FZ4F5UR.cjs → chunk-MUAPXS3H.cjs} +12 -12
  13. package/dist/{chunk-7RJWFPCZ.cjs → chunk-NASWEFHN.cjs} +8 -1
  14. package/dist/{chunk-43LGK4YP.js → chunk-QTN5ZT4P.js} +2 -2
  15. package/dist/{chunk-FZ6QDTC4.cjs → chunk-VIZWYFHP.cjs} +62 -11
  16. package/dist/{chunk-WY6V4Y7S.cjs → chunk-WMFHPNFP.cjs} +3 -3
  17. package/dist/{chunk-HRRYZUKI.js → chunk-YTX4QOLE.js} +2 -2
  18. package/dist/{chunk-KIS7MVIW.js → chunk-Z72T6CZG.js} +61 -10
  19. package/dist/client.cjs +6 -6
  20. package/dist/client.d.cts +1 -1
  21. package/dist/client.d.ts +1 -1
  22. package/dist/client.js +5 -5
  23. package/dist/errors.cjs +4 -2
  24. package/dist/errors.d.cts +10 -1
  25. package/dist/errors.d.ts +10 -1
  26. package/dist/errors.js +3 -1
  27. package/dist/{index-BE6Wfozd.d.ts → index-KNOaUG34.d.cts} +7 -0
  28. package/dist/{index-BE6Wfozd.d.cts → index-KNOaUG34.d.ts} +7 -0
  29. package/dist/index.cjs +11 -7
  30. package/dist/index.d.cts +3 -3
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.js +10 -6
  33. package/dist/scraping.cjs +4 -4
  34. package/dist/scraping.d.cts +1 -1
  35. package/dist/scraping.d.ts +1 -1
  36. package/dist/scraping.js +3 -3
  37. package/dist/soap.cjs +4 -4
  38. package/dist/soap.d.cts +1 -1
  39. package/dist/soap.d.ts +1 -1
  40. package/dist/soap.js +3 -3
  41. package/dist/validators.d.cts +1 -1
  42. package/dist/validators.d.ts +1 -1
  43. package/package.json +1 -1
package/README.en.md CHANGED
@@ -180,6 +180,10 @@ const ncfResult = await client.getNCF('131098193', 'B0100000001');
180
180
  | `downloadBulkFile(options)` | Downloads DGII\_RNC.zip to the given directory |
181
181
  | `parseBulkFile(options)` | Parses the taxpayer TXT file |
182
182
 
183
+ `parseBulkFile` throws `BulkFormatError` if the file doesn't match the
184
+ expected 11-column layout (for example, if DGII changes the format). It
185
+ accepts an `encoding` option (defaults to `latin1`).
186
+
183
187
  ## Architecture
184
188
 
185
189
  ```text
package/README.md CHANGED
@@ -183,6 +183,10 @@ const ncfResult = await client.getNCF('131098193', 'B0100000001');
183
183
  | `downloadBulkFile(options)` | Descarga DGII\_RNC.zip |
184
184
  | `parseBulkFile(options)` | Parsea el archivo TXT |
185
185
 
186
+ `parseBulkFile` lanza `BulkFormatError` si el archivo no coincide con el
187
+ layout de 11 columnas esperado (por ejemplo, si la DGII cambia el formato).
188
+ Acepta `encoding` en las opciones (`latin1` por defecto).
189
+
186
190
  ## Arquitectura
187
191
 
188
192
  ```text
package/dist/bulk.cjs CHANGED
@@ -2,10 +2,16 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkFZ6QDTC4cjs = require('./chunk-FZ6QDTC4.cjs');
5
+
6
+ var _chunkVIZWYFHPcjs = require('./chunk-VIZWYFHP.cjs');
6
7
  require('./chunk-QH4BK5X3.cjs');
7
8
 
8
9
 
10
+ var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
11
+
12
+
13
+
14
+
9
15
 
10
16
 
11
- exports.DGII_BULK_URL = _chunkFZ6QDTC4cjs.DGII_BULK_URL; exports.downloadBulkFile = _chunkFZ6QDTC4cjs.downloadBulkFile; exports.parseBulkFile = _chunkFZ6QDTC4cjs.parseBulkFile;
17
+ exports.BulkFormatError = _chunkNASWEFHNcjs.BulkFormatError; exports.DGII_BULK_URL = _chunkVIZWYFHPcjs.DGII_BULK_URL; exports.DGII_ESTADOS = _chunkVIZWYFHPcjs.DGII_ESTADOS; exports.downloadBulkFile = _chunkVIZWYFHPcjs.downloadBulkFile; exports.parseBulkFile = _chunkVIZWYFHPcjs.parseBulkFile;
package/dist/bulk.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { B as BulkContribuyente } from './index-BE6Wfozd.cjs';
1
+ import { B as BulkContribuyente } from './index-KNOaUG34.cjs';
2
+ export { BulkFormatError } from './errors.cjs';
2
3
 
3
4
  interface DownloadOptions {
4
5
  /** Directorio de destino para el archivo ZIP */
@@ -9,8 +10,27 @@ interface DownloadOptions {
9
10
  interface ParseOptions {
10
11
  /** Ruta al archivo TXT extraído del ZIP */
11
12
  filePath: string;
13
+ /**
14
+ * Codificación del archivo. La DGII publica el TXT en latin-1
15
+ * (ISO-8859-1), que es el valor por defecto. Permite anularla si una
16
+ * futura versión del archivo llega en otra codificación (p. ej. UTF-8).
17
+ */
18
+ encoding?: BufferEncoding;
12
19
  }
13
20
  declare const DGII_BULK_URL: string;
21
+ /**
22
+ * Valores conocidos de la columna `estado` (col 9) en el archivo masivo,
23
+ * verificados contra ~778k filas en producción. El parser usa este
24
+ * vocabulario para detectar un cambio de layout: si ninguna fila de una
25
+ * muestra trae un `estado` reconocido, el formato de la DGII cambió.
26
+ */
27
+ declare const DGII_ESTADOS: readonly ["ACTIVO", "SUSPENDIDO", "DADO DE BAJA", "CESE TEMPORAL", "ANULADO", "RECHAZADO"];
28
+ /**
29
+ * Valor de la columna `estado` del archivo masivo: uno de
30
+ * {@link DGII_ESTADOS}. Vocabulario completo de la DGII, distinto del
31
+ * `estado` binario (ACTIVO/INACTIVO) que exponen el scraping y el SOAP.
32
+ */
33
+ type DgiiEstado = (typeof DGII_ESTADOS)[number];
14
34
 
15
35
  /**
16
36
  * Descarga el archivo masivo DGII_RNC.zip desde el portal de la DGII.
@@ -20,11 +40,34 @@ declare const DGII_BULK_URL: string;
20
40
  declare function downloadBulkFile(options: DownloadOptions): Promise<string>;
21
41
 
22
42
  /**
23
- * Parsea el archivo TXT de contribuyentes extraido de DGII_RNC.zip.
43
+ * Parsea el archivo TXT de contribuyentes extraído de DGII_RNC.zip.
44
+ *
45
+ * El archivo usa delimitador pipe (|) con 11 columnas y viene codificado
46
+ * en latin-1 (ISO-8859-1); leerlo como UTF-8 corrompe los nombres con
47
+ * ñ/acentos (p. ej. MUÑOZ, PEÑA). Usa {@link ParseOptions.encoding} para
48
+ * anular la codificación si una futura versión del archivo cambia.
49
+ *
50
+ * Layout verificado contra el archivo en producción (~778k filas):
51
+ *
52
+ * col 0 rnc (100% dígitos)
53
+ * col 1 nombre (razón social)
54
+ * col 2 nombreComercial
55
+ * col 3 actividad
56
+ * col 4-7 reservadas/vacías en el archivo actual
57
+ * col 8 fechaConstitucion (dd/mm/yyyy)
58
+ * col 9 estado (ACTIVO / SUSPENDIDO / DADO DE BAJA / ...)
59
+ * col 10 regimen (NORMAL / RST / PST)
60
+ *
61
+ * `estado` se normaliza a mayúsculas para que coincida con
62
+ * {@link DGII_ESTADOS} sin importar la capitalización de la fuente.
24
63
  *
25
- * El archivo usa delimitador pipe (|) con 9 columnas.
26
- * Los registros pueden tener espacios dobles que se limpian.
64
+ * Las filas cuyo número de columnas no sea exactamente 11 se descartan por
65
+ * malformadas (formato viejo más corto, o una columna añadida/insertada).
66
+ * Si el archivo trae filas pero la mayoría de la muestra no trae un
67
+ * `estado` reconocido, se lanza {@link BulkFormatError}: un cambio de
68
+ * layout de la DGII debe fallar ruidosamente en vez de devolver `estado`
69
+ * vacío o mapeado a la columna equivocada en silencio.
27
70
  */
28
71
  declare function parseBulkFile(options: ParseOptions): Promise<BulkContribuyente[]>;
29
72
 
30
- export { BulkContribuyente, DGII_BULK_URL, type DownloadOptions, type ParseOptions, downloadBulkFile, parseBulkFile };
73
+ export { BulkContribuyente, DGII_BULK_URL, DGII_ESTADOS, type DgiiEstado, type DownloadOptions, type ParseOptions, downloadBulkFile, parseBulkFile };
package/dist/bulk.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { B as BulkContribuyente } from './index-BE6Wfozd.js';
1
+ import { B as BulkContribuyente } from './index-KNOaUG34.js';
2
+ export { BulkFormatError } from './errors.js';
2
3
 
3
4
  interface DownloadOptions {
4
5
  /** Directorio de destino para el archivo ZIP */
@@ -9,8 +10,27 @@ interface DownloadOptions {
9
10
  interface ParseOptions {
10
11
  /** Ruta al archivo TXT extraído del ZIP */
11
12
  filePath: string;
13
+ /**
14
+ * Codificación del archivo. La DGII publica el TXT en latin-1
15
+ * (ISO-8859-1), que es el valor por defecto. Permite anularla si una
16
+ * futura versión del archivo llega en otra codificación (p. ej. UTF-8).
17
+ */
18
+ encoding?: BufferEncoding;
12
19
  }
13
20
  declare const DGII_BULK_URL: string;
21
+ /**
22
+ * Valores conocidos de la columna `estado` (col 9) en el archivo masivo,
23
+ * verificados contra ~778k filas en producción. El parser usa este
24
+ * vocabulario para detectar un cambio de layout: si ninguna fila de una
25
+ * muestra trae un `estado` reconocido, el formato de la DGII cambió.
26
+ */
27
+ declare const DGII_ESTADOS: readonly ["ACTIVO", "SUSPENDIDO", "DADO DE BAJA", "CESE TEMPORAL", "ANULADO", "RECHAZADO"];
28
+ /**
29
+ * Valor de la columna `estado` del archivo masivo: uno de
30
+ * {@link DGII_ESTADOS}. Vocabulario completo de la DGII, distinto del
31
+ * `estado` binario (ACTIVO/INACTIVO) que exponen el scraping y el SOAP.
32
+ */
33
+ type DgiiEstado = (typeof DGII_ESTADOS)[number];
14
34
 
15
35
  /**
16
36
  * Descarga el archivo masivo DGII_RNC.zip desde el portal de la DGII.
@@ -20,11 +40,34 @@ declare const DGII_BULK_URL: string;
20
40
  declare function downloadBulkFile(options: DownloadOptions): Promise<string>;
21
41
 
22
42
  /**
23
- * Parsea el archivo TXT de contribuyentes extraido de DGII_RNC.zip.
43
+ * Parsea el archivo TXT de contribuyentes extraído de DGII_RNC.zip.
44
+ *
45
+ * El archivo usa delimitador pipe (|) con 11 columnas y viene codificado
46
+ * en latin-1 (ISO-8859-1); leerlo como UTF-8 corrompe los nombres con
47
+ * ñ/acentos (p. ej. MUÑOZ, PEÑA). Usa {@link ParseOptions.encoding} para
48
+ * anular la codificación si una futura versión del archivo cambia.
49
+ *
50
+ * Layout verificado contra el archivo en producción (~778k filas):
51
+ *
52
+ * col 0 rnc (100% dígitos)
53
+ * col 1 nombre (razón social)
54
+ * col 2 nombreComercial
55
+ * col 3 actividad
56
+ * col 4-7 reservadas/vacías en el archivo actual
57
+ * col 8 fechaConstitucion (dd/mm/yyyy)
58
+ * col 9 estado (ACTIVO / SUSPENDIDO / DADO DE BAJA / ...)
59
+ * col 10 regimen (NORMAL / RST / PST)
60
+ *
61
+ * `estado` se normaliza a mayúsculas para que coincida con
62
+ * {@link DGII_ESTADOS} sin importar la capitalización de la fuente.
24
63
  *
25
- * El archivo usa delimitador pipe (|) con 9 columnas.
26
- * Los registros pueden tener espacios dobles que se limpian.
64
+ * Las filas cuyo número de columnas no sea exactamente 11 se descartan por
65
+ * malformadas (formato viejo más corto, o una columna añadida/insertada).
66
+ * Si el archivo trae filas pero la mayoría de la muestra no trae un
67
+ * `estado` reconocido, se lanza {@link BulkFormatError}: un cambio de
68
+ * layout de la DGII debe fallar ruidosamente en vez de devolver `estado`
69
+ * vacío o mapeado a la columna equivocada en silencio.
27
70
  */
28
71
  declare function parseBulkFile(options: ParseOptions): Promise<BulkContribuyente[]>;
29
72
 
30
- export { BulkContribuyente, DGII_BULK_URL, type DownloadOptions, type ParseOptions, downloadBulkFile, parseBulkFile };
73
+ export { BulkContribuyente, DGII_BULK_URL, DGII_ESTADOS, type DgiiEstado, type DownloadOptions, type ParseOptions, downloadBulkFile, parseBulkFile };
package/dist/bulk.js CHANGED
@@ -1,11 +1,17 @@
1
1
  import {
2
2
  DGII_BULK_URL,
3
+ DGII_ESTADOS,
3
4
  downloadBulkFile,
4
5
  parseBulkFile
5
- } from "./chunk-KIS7MVIW.js";
6
+ } from "./chunk-Z72T6CZG.js";
6
7
  import "./chunk-D26S6EXD.js";
8
+ import {
9
+ BulkFormatError
10
+ } from "./chunk-IRQX4WNQ.js";
7
11
  export {
12
+ BulkFormatError,
8
13
  DGII_BULK_URL,
14
+ DGII_ESTADOS,
9
15
  downloadBulkFile,
10
16
  parseBulkFile
11
17
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkWY6V4Y7Scjs = require('./chunk-WY6V4Y7S.cjs');
3
+ var _chunkWMFHPNFPcjs = require('./chunk-WMFHPNFP.cjs');
4
4
 
5
5
 
6
6
 
@@ -8,7 +8,7 @@ var _chunkQH4BK5X3cjs = require('./chunk-QH4BK5X3.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunk7RJWFPCZcjs = require('./chunk-7RJWFPCZ.cjs');
11
+ var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
12
12
 
13
13
  // src/scraping/endpoints.ts
14
14
  var DGII_RNC_URL = "https://dgii.gov.do/app/WebApps/ConsultasWeb2/ConsultasWeb/consultas/rnc.aspx";
@@ -30,7 +30,7 @@ function extractViewStateTokens(html) {
30
30
  const viewStateGenerator = extractInputValue(html, "__VIEWSTATEGENERATOR");
31
31
  const eventValidation = extractInputValue(html, "__EVENTVALIDATION");
32
32
  if (!viewState || !eventValidation) {
33
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
33
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
34
34
  "No se encontraron tokens ViewState en la p\xE1gina de la DGII"
35
35
  );
36
36
  }
@@ -43,7 +43,7 @@ function parseContribuyenteHtml(html) {
43
43
  if (infoEnd !== -1) {
44
44
  const infoBlock = html.slice(infoStart, infoEnd);
45
45
  if (infoBlock.includes("no se encuentra")) {
46
- throw new (0, _chunk7RJWFPCZcjs.DgiiNotFoundError)(
46
+ throw new (0, _chunkNASWEFHNcjs.DgiiNotFoundError)(
47
47
  "RNC o c\xE9dula no encontrado en el registro de la DGII"
48
48
  );
49
49
  }
@@ -52,13 +52,13 @@ function parseContribuyenteHtml(html) {
52
52
  const tableId = "cphMain_dvDatosContribuyentes";
53
53
  const tableStart = html.indexOf(tableId);
54
54
  if (tableStart === -1) {
55
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
55
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
56
56
  "Formato de respuesta HTML inesperado: tabla de resultados no encontrada"
57
57
  );
58
58
  }
59
59
  const tableEnd = html.indexOf("</table>", tableStart);
60
60
  if (tableEnd === -1) {
61
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
61
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
62
62
  "Formato de respuesta HTML inesperado: tabla incompleta"
63
63
  );
64
64
  }
@@ -183,7 +183,7 @@ var ScrapingClient = class {
183
183
  */
184
184
  async getContribuyente(rnc) {
185
185
  if (typeof rnc !== "string" || rnc.trim() === "") {
186
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
186
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
187
187
  }
188
188
  const tokens = await this._fetchTokens(this._rncUrl);
189
189
  const body = buildFormBody([
@@ -205,10 +205,10 @@ var ScrapingClient = class {
205
205
  */
206
206
  async getNCF(rnc, ncf) {
207
207
  if (typeof rnc !== "string" || rnc.trim() === "") {
208
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
208
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
209
209
  }
210
210
  if (typeof ncf !== "string" || ncf.trim() === "") {
211
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)("El par\xE1metro ncf es requerido");
211
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro ncf es requerido");
212
212
  }
213
213
  const tokens = await this._fetchTokens(this._ncfUrl);
214
214
  const body = buildFormBody([
@@ -233,7 +233,7 @@ var ScrapingClient = class {
233
233
  throw this._wrapFetchError(error);
234
234
  }
235
235
  if (!response.ok) {
236
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
236
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
237
237
  `La DGII respondi\xF3 con HTTP ${response.status} al obtener la p\xE1gina`,
238
238
  { statusCode: response.status }
239
239
  );
@@ -258,7 +258,7 @@ var ScrapingClient = class {
258
258
  throw this._wrapFetchError(error);
259
259
  }
260
260
  if (!response.ok) {
261
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
261
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
262
262
  `La DGII respondi\xF3 con HTTP ${response.status}`,
263
263
  { statusCode: response.status }
264
264
  );
@@ -266,7 +266,7 @@ var ScrapingClient = class {
266
266
  return response.text();
267
267
  }
268
268
  _wrapFetchError(error) {
269
- return _chunkWY6V4Y7Scjs.wrapFetchError.call(void 0, error, this._timeout);
269
+ return _chunkWMFHPNFPcjs.wrapFetchError.call(void 0, error, this._timeout);
270
270
  }
271
271
  };
272
272
  function buildFormBody(fields) {
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkWY6V4Y7Scjs = require('./chunk-WY6V4Y7S.cjs');
3
+ var _chunkWMFHPNFPcjs = require('./chunk-WMFHPNFP.cjs');
4
4
 
5
5
 
6
6
 
@@ -8,7 +8,7 @@ var _chunkQH4BK5X3cjs = require('./chunk-QH4BK5X3.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunk7RJWFPCZcjs = require('./chunk-7RJWFPCZ.cjs');
11
+ var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
12
12
 
13
13
  // src/soap/endpoints.ts
14
14
  var DGII_SOAP_BASE_URL = "https://dgii.gov.do/wsMovilDGII/WSMovilDGII.asmx";
@@ -49,13 +49,13 @@ function sanitizeJson(raw) {
49
49
  function parseContribuyenteResponse(responseXml) {
50
50
  const raw = extractTagContent(responseXml, "GetContribuyentesResult");
51
51
  if (raw === void 0) {
52
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
52
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
53
53
  "Respuesta SOAP sin GetContribuyentesResult"
54
54
  );
55
55
  }
56
56
  const trimmed = raw.trim();
57
57
  if (trimmed === "0" || trimmed === "") {
58
- throw new (0, _chunk7RJWFPCZcjs.DgiiNotFoundError)(
58
+ throw new (0, _chunkNASWEFHNcjs.DgiiNotFoundError)(
59
59
  "RNC o c\xE9dula no encontrado en el registro de la DGII"
60
60
  );
61
61
  }
@@ -65,12 +65,12 @@ function parseContribuyenteResponse(responseXml) {
65
65
  try {
66
66
  parsed = JSON.parse(sanitized);
67
67
  } catch (e) {
68
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
68
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
69
69
  "Respuesta de la DGII no es JSON v\xE1lido"
70
70
  );
71
71
  }
72
72
  if (typeof parsed !== "object" || parsed === null || typeof parsed["RGE_RUC"] !== "string") {
73
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
73
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
74
74
  "Formato de respuesta de la DGII inesperado"
75
75
  );
76
76
  }
@@ -88,7 +88,7 @@ function parseContribuyenteResponse(responseXml) {
88
88
  function parseNcfResponse(responseXml) {
89
89
  const raw = extractTagContent(responseXml, "GetNCFResult");
90
90
  if (raw === void 0) {
91
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)("Respuesta SOAP sin GetNCFResult");
91
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("Respuesta SOAP sin GetNCFResult");
92
92
  }
93
93
  const trimmed = raw.trim();
94
94
  if (trimmed === "0" || trimmed === "") {
@@ -99,12 +99,12 @@ function parseNcfResponse(responseXml) {
99
99
  try {
100
100
  parsed = JSON.parse(sanitized);
101
101
  } catch (e2) {
102
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
102
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
103
103
  "Respuesta de la DGII no es JSON v\xE1lido"
104
104
  );
105
105
  }
106
106
  if (typeof parsed !== "object" || parsed === null) {
107
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
107
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
108
108
  "Formato de respuesta de la DGII inesperado"
109
109
  );
110
110
  }
@@ -144,22 +144,22 @@ var DgiiSoapClient = class {
144
144
  signal: AbortSignal.timeout(timeout)
145
145
  });
146
146
  } catch (error) {
147
- throw _chunkWY6V4Y7Scjs.wrapFetchError.call(void 0, error, timeout);
147
+ throw _chunkWMFHPNFPcjs.wrapFetchError.call(void 0, error, timeout);
148
148
  }
149
149
  const contentLength = response.headers.get("content-length");
150
150
  if (contentLength && parseInt(contentLength, 10) > 1048576) {
151
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
151
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
152
152
  "Respuesta de la DGII excede el tama\xF1o m\xE1ximo permitido"
153
153
  );
154
154
  }
155
155
  if (response.status === 403) {
156
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
156
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
157
157
  "Acceso denegado por la DGII (HTTP 403). El servicio puede estar restringido por ubicaci\xF3n geogr\xE1fica.",
158
158
  { statusCode: 403 }
159
159
  );
160
160
  }
161
161
  if (!response.ok) {
162
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
162
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
163
163
  `El servicio de la DGII respondi\xF3 con HTTP ${response.status}`,
164
164
  { statusCode: response.status }
165
165
  );
@@ -171,7 +171,7 @@ var DgiiSoapClient = class {
171
171
  */
172
172
  async getContribuyente(rnc) {
173
173
  if (typeof rnc !== "string" || rnc.trim() === "") {
174
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
174
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
175
175
  }
176
176
  const envelope = buildGetContribuyentesEnvelope(rnc.trim());
177
177
  const responseXml = await this._fetch(
@@ -185,10 +185,10 @@ var DgiiSoapClient = class {
185
185
  */
186
186
  async getNCF(rnc, ncf) {
187
187
  if (typeof rnc !== "string" || rnc.trim() === "") {
188
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
188
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
189
189
  }
190
190
  if (typeof ncf !== "string" || ncf.trim() === "") {
191
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)("El par\xE1metro ncf es requerido");
191
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro ncf es requerido");
192
192
  }
193
193
  const envelope = buildGetNcfEnvelope(rnc.trim(), ncf.trim());
194
194
  const responseXml = await this._fetch(SOAP_ACTIONS.getNCF, envelope);
@@ -34,11 +34,18 @@ var AllStrategiesFailedError = class extends DgiiError {
34
34
  this.errors = errors;
35
35
  }
36
36
  };
37
+ var BulkFormatError = class extends DgiiError {
38
+ constructor(message) {
39
+ super(message, "DGII_BULK_FORMAT_ERROR");
40
+ this.name = "BulkFormatError";
41
+ }
42
+ };
37
43
 
38
44
  export {
39
45
  DgiiError,
40
46
  DgiiConnectionError,
41
47
  DgiiNotFoundError,
42
48
  DgiiServiceError,
43
- AllStrategiesFailedError
49
+ AllStrategiesFailedError,
50
+ BulkFormatError
44
51
  };
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  DgiiSoapClient
3
- } from "./chunk-43LGK4YP.js";
3
+ } from "./chunk-QTN5ZT4P.js";
4
4
  import {
5
5
  ScrapingClient
6
- } from "./chunk-HRRYZUKI.js";
6
+ } from "./chunk-YTX4QOLE.js";
7
7
  import {
8
8
  AllStrategiesFailedError,
9
9
  DgiiConnectionError,
10
10
  DgiiNotFoundError,
11
11
  DgiiServiceError
12
- } from "./chunk-DMGDJEUY.js";
12
+ } from "./chunk-IRQX4WNQ.js";
13
13
 
14
14
  // src/client/circuit-breaker.ts
15
15
  var DEFAULT_CIRCUIT_BREAKER_OPTIONS = /* @__PURE__ */ Object.freeze({
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DgiiConnectionError
3
- } from "./chunk-DMGDJEUY.js";
3
+ } from "./chunk-IRQX4WNQ.js";
4
4
 
5
5
  // src/utils/fetch-error.ts
6
6
  function wrapFetchError(error, timeoutMs) {
@@ -1,15 +1,15 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkJBKAE66Ccjs = require('./chunk-JBKAE66C.cjs');
3
+ var _chunkDLB5RJ7Ecjs = require('./chunk-DLB5RJ7E.cjs');
4
4
 
5
5
 
6
- var _chunkBQPH3JDZcjs = require('./chunk-BQPH3JDZ.cjs');
6
+ var _chunkAML7LZBUcjs = require('./chunk-AML7LZBU.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
- var _chunk7RJWFPCZcjs = require('./chunk-7RJWFPCZ.cjs');
12
+ var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
13
13
 
14
14
  // src/client/circuit-breaker.ts
15
15
  var DEFAULT_CIRCUIT_BREAKER_OPTIONS = /* @__PURE__ */ Object.freeze({
@@ -39,7 +39,7 @@ var ConsecutiveBreaker = class {
39
39
  async execute(fn) {
40
40
  const currentState = this.state;
41
41
  if (currentState === "OPEN") {
42
- throw new (0, _chunk7RJWFPCZcjs.DgiiServiceError)(
42
+ throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
43
43
  "Circuito abierto: estrategia deshabilitada temporalmente"
44
44
  );
45
45
  }
@@ -89,9 +89,9 @@ var DEFAULT_RETRY_OPTIONS = /* @__PURE__ */ Object.freeze({
89
89
  maxDelayMs: 1e4
90
90
  });
91
91
  function isRetryableError(error) {
92
- if (error instanceof _chunk7RJWFPCZcjs.DgiiNotFoundError) return false;
93
- if (error instanceof _chunk7RJWFPCZcjs.DgiiConnectionError) return true;
94
- if (error instanceof _chunk7RJWFPCZcjs.DgiiServiceError) {
92
+ if (error instanceof _chunkNASWEFHNcjs.DgiiNotFoundError) return false;
93
+ if (error instanceof _chunkNASWEFHNcjs.DgiiConnectionError) return true;
94
+ if (error instanceof _chunkNASWEFHNcjs.DgiiServiceError) {
95
95
  const code = error.statusCode;
96
96
  if (code !== void 0 && code >= 500) return true;
97
97
  return false;
@@ -123,10 +123,10 @@ async function withRetry(fn, options = DEFAULT_RETRY_OPTIONS) {
123
123
  var DgiiClient = class {
124
124
  constructor(options) {
125
125
  const timeout = _optionalChain([options, 'optionalAccess', _ => _.timeout]);
126
- this._scraping = new (0, _chunkBQPH3JDZcjs.ScrapingClient)(
126
+ this._scraping = new (0, _chunkAML7LZBUcjs.ScrapingClient)(
127
127
  timeout ? { timeout } : void 0
128
128
  );
129
- this._soap = new (0, _chunkJBKAE66Ccjs.DgiiSoapClient)(
129
+ this._soap = new (0, _chunkDLB5RJ7Ecjs.DgiiSoapClient)(
130
130
  timeout ? { timeout } : void 0
131
131
  );
132
132
  this._scrapingBreaker = new ConsecutiveBreaker(
@@ -167,7 +167,7 @@ var DgiiClient = class {
167
167
  )
168
168
  );
169
169
  } catch (error) {
170
- if (error instanceof _chunk7RJWFPCZcjs.DgiiNotFoundError) throw error;
170
+ if (error instanceof _chunkNASWEFHNcjs.DgiiNotFoundError) throw error;
171
171
  errors.push(error instanceof Error ? error : new Error(String(error)));
172
172
  }
173
173
  if (this._soapFallback) {
@@ -179,11 +179,11 @@ var DgiiClient = class {
179
179
  )
180
180
  );
181
181
  } catch (error) {
182
- if (error instanceof _chunk7RJWFPCZcjs.DgiiNotFoundError) throw error;
182
+ if (error instanceof _chunkNASWEFHNcjs.DgiiNotFoundError) throw error;
183
183
  errors.push(error instanceof Error ? error : new Error(String(error)));
184
184
  }
185
185
  }
186
- throw new (0, _chunk7RJWFPCZcjs.AllStrategiesFailedError)(
186
+ throw new (0, _chunkNASWEFHNcjs.AllStrategiesFailedError)(
187
187
  `Todas las estrategias de consulta fallaron. \xDAltimo error: ${_nullishCoalesce(_optionalChain([errors, 'access', _6 => _6[errors.length - 1], 'optionalAccess', _7 => _7.message]), () => ( "desconocido"))}`,
188
188
  errors
189
189
  );
@@ -34,6 +34,13 @@ var AllStrategiesFailedError = class extends DgiiError {
34
34
  this.errors = errors;
35
35
  }
36
36
  };
37
+ var BulkFormatError = class extends DgiiError {
38
+ constructor(message) {
39
+ super(message, "DGII_BULK_FORMAT_ERROR");
40
+ this.name = "BulkFormatError";
41
+ }
42
+ };
43
+
37
44
 
38
45
 
39
46
 
@@ -41,4 +48,4 @@ var AllStrategiesFailedError = class extends DgiiError {
41
48
 
42
49
 
43
50
 
44
- exports.DgiiError = DgiiError; exports.DgiiConnectionError = DgiiConnectionError; exports.DgiiNotFoundError = DgiiNotFoundError; exports.DgiiServiceError = DgiiServiceError; exports.AllStrategiesFailedError = AllStrategiesFailedError;
51
+ exports.DgiiError = DgiiError; exports.DgiiConnectionError = DgiiConnectionError; exports.DgiiNotFoundError = DgiiNotFoundError; exports.DgiiServiceError = DgiiServiceError; exports.AllStrategiesFailedError = AllStrategiesFailedError; exports.BulkFormatError = BulkFormatError;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  wrapFetchError
3
- } from "./chunk-53A7IG4Y.js";
3
+ } from "./chunk-KW4ZV6FJ.js";
4
4
  import {
5
5
  collapseSpaces,
6
6
  stripNonDigits
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  DgiiNotFoundError,
10
10
  DgiiServiceError
11
- } from "./chunk-DMGDJEUY.js";
11
+ } from "./chunk-IRQX4WNQ.js";
12
12
 
13
13
  // src/soap/endpoints.ts
14
14
  var DGII_SOAP_BASE_URL = "https://dgii.gov.do/wsMovilDGII/WSMovilDGII.asmx";