dgii-ts 0.1.2 → 0.2.0
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.en.md +39 -3
- package/README.md +40 -3
- package/dist/bulk.cjs +8 -2
- package/dist/bulk.d.cts +48 -5
- package/dist/bulk.d.ts +48 -5
- package/dist/bulk.js +7 -1
- package/dist/{chunk-5FZ4F5UR.cjs → chunk-6ZRPVQPP.cjs} +20 -15
- package/dist/{chunk-HRRYZUKI.js → chunk-7ILLRYE4.js} +114 -11
- package/dist/{chunk-JBKAE66C.cjs → chunk-DLB5RJ7E.cjs} +16 -16
- package/dist/{chunk-BQPH3JDZ.cjs → chunk-FRM5XREF.cjs} +124 -21
- package/dist/chunk-H42U4GI5.js +49 -0
- package/dist/{chunk-DMGDJEUY.js → chunk-IRQX4WNQ.js} +8 -1
- package/dist/{chunk-ROJUYPIK.js → chunk-JV4HWHYP.js} +11 -6
- package/dist/{chunk-53A7IG4Y.js → chunk-KW4ZV6FJ.js} +1 -1
- package/dist/{chunk-7RJWFPCZ.cjs → chunk-NASWEFHN.cjs} +8 -1
- package/dist/chunk-OSGHCQFA.cjs +49 -0
- package/dist/{chunk-43LGK4YP.js → chunk-QTN5ZT4P.js} +2 -2
- package/dist/{chunk-TZC6RSWL.js → chunk-RTI3CLHV.js} +1 -48
- package/dist/{chunk-SUSDEKID.cjs → chunk-UW6W2JHW.cjs} +1 -48
- package/dist/{chunk-FZ6QDTC4.cjs → chunk-VIZWYFHP.cjs} +62 -11
- package/dist/{chunk-WY6V4Y7S.cjs → chunk-WMFHPNFP.cjs} +3 -3
- package/dist/{chunk-KIS7MVIW.js → chunk-Z72T6CZG.js} +61 -10
- package/dist/client.cjs +7 -6
- package/dist/client.d.cts +8 -3
- package/dist/client.d.ts +8 -3
- package/dist/client.js +6 -5
- package/dist/errors.cjs +4 -2
- package/dist/errors.d.cts +10 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.js +3 -1
- package/dist/index-BPvMDXya.d.cts +101 -0
- package/dist/index-BPvMDXya.d.ts +101 -0
- package/dist/index.cjs +16 -10
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -9
- package/dist/scraping.cjs +5 -4
- package/dist/scraping.d.cts +14 -3
- package/dist/scraping.d.ts +14 -3
- package/dist/scraping.js +4 -3
- package/dist/soap.cjs +4 -4
- package/dist/soap.d.cts +1 -1
- package/dist/soap.d.ts +1 -1
- package/dist/soap.js +3 -3
- package/dist/validators.cjs +4 -2
- package/dist/validators.d.cts +1 -1
- package/dist/validators.d.ts +1 -1
- package/dist/validators.js +5 -3
- package/package.json +2 -2
- package/dist/index-BE6Wfozd.d.cts +0 -63
- package/dist/index-BE6Wfozd.d.ts +0 -63
|
@@ -729,56 +729,9 @@ function validateNcf(value) {
|
|
|
729
729
|
};
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
// src/validators/ecf.ts
|
|
733
|
-
var ECF_TYPES = /* @__PURE__ */ Object.freeze({
|
|
734
|
-
"31": "CREDITO_FISCAL_ELECTRONICA",
|
|
735
|
-
"32": "CONSUMO_ELECTRONICA",
|
|
736
|
-
"33": "NOTA_DE_DEBITO_ELECTRONICA",
|
|
737
|
-
"34": "NOTA_DE_CREDITO_ELECTRONICA",
|
|
738
|
-
"41": "COMPRAS_ELECTRONICO",
|
|
739
|
-
"43": "GASTOS_MENORES_ELECTRONICO",
|
|
740
|
-
"44": "REGIMENES_ESPECIALES_ELECTRONICO",
|
|
741
|
-
"45": "GUBERNAMENTAL_ELECTRONICO",
|
|
742
|
-
"46": "EXPORTACIONES_ELECTRONICO",
|
|
743
|
-
"47": "PAGOS_AL_EXTERIOR_ELECTRONICO"
|
|
744
|
-
});
|
|
745
|
-
var ECF_TYPE_NAMES = /* @__PURE__ */ Object.freeze({
|
|
746
|
-
"31": "Factura de cr\xE9dito fiscal electr\xF3nica",
|
|
747
|
-
"32": "Factura de consumo electr\xF3nica",
|
|
748
|
-
"33": "Nota de d\xE9bito electr\xF3nica",
|
|
749
|
-
"34": "Nota de cr\xE9dito electr\xF3nica",
|
|
750
|
-
"41": "Comprobante electr\xF3nico de compras",
|
|
751
|
-
"43": "Comprobante electr\xF3nico para gastos menores",
|
|
752
|
-
"44": "Comprobante electr\xF3nico para reg\xEDmenes especiales",
|
|
753
|
-
"45": "Comprobante electr\xF3nico gubernamental",
|
|
754
|
-
"46": "Comprobante electr\xF3nico para exportaciones",
|
|
755
|
-
"47": "Comprobante electr\xF3nico para pagos al exterior"
|
|
756
|
-
});
|
|
757
|
-
var ECF_PATTERN = /^E(\d{2})(\d{10})$/;
|
|
758
|
-
function validateEcf(value) {
|
|
759
|
-
if (typeof value !== "string") return { valid: false };
|
|
760
|
-
const normalized = value.toUpperCase().trim();
|
|
761
|
-
const match = ECF_PATTERN.exec(normalized);
|
|
762
|
-
if (!match) {
|
|
763
|
-
return { valid: false };
|
|
764
|
-
}
|
|
765
|
-
const typeCode = match[1];
|
|
766
|
-
const type = ECF_TYPES[typeCode];
|
|
767
|
-
if (!type) {
|
|
768
|
-
return { valid: false };
|
|
769
|
-
}
|
|
770
|
-
return {
|
|
771
|
-
valid: true,
|
|
772
|
-
type,
|
|
773
|
-
serie: `E${typeCode}`
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
732
|
|
|
780
733
|
|
|
781
734
|
|
|
782
735
|
|
|
783
736
|
|
|
784
|
-
exports.validateRnc = validateRnc; exports.validateCedula = validateCedula; exports.NCF_TYPE_NAMES = NCF_TYPE_NAMES; exports.validateNcf = validateNcf;
|
|
737
|
+
exports.validateRnc = validateRnc; exports.validateCedula = validateCedula; exports.NCF_TYPE_NAMES = NCF_TYPE_NAMES; exports.validateNcf = validateNcf;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _chunkQH4BK5X3cjs = require('./chunk-QH4BK5X3.cjs');
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
|
|
7
|
+
|
|
5
8
|
// src/bulk/downloader.ts
|
|
6
9
|
var _https = require('https');
|
|
7
10
|
var _fs = require('fs');
|
|
@@ -10,6 +13,14 @@ var _path = require('path');
|
|
|
10
13
|
|
|
11
14
|
// src/bulk/types.ts
|
|
12
15
|
var DGII_BULK_URL = "https://dgii.gov.do/app/WebApps/Consultas/RNC/DGII_RNC.zip";
|
|
16
|
+
var DGII_ESTADOS = /* @__PURE__ */ Object.freeze([
|
|
17
|
+
"ACTIVO",
|
|
18
|
+
"SUSPENDIDO",
|
|
19
|
+
"DADO DE BAJA",
|
|
20
|
+
"CESE TEMPORAL",
|
|
21
|
+
"ANULADO",
|
|
22
|
+
"RECHAZADO"
|
|
23
|
+
]);
|
|
13
24
|
|
|
14
25
|
// src/bulk/downloader.ts
|
|
15
26
|
async function downloadBulkFile(options) {
|
|
@@ -68,26 +79,65 @@ function handleResponse(response, destPath, resolve, reject) {
|
|
|
68
79
|
// src/bulk/parser.ts
|
|
69
80
|
|
|
70
81
|
var _readline = require('readline');
|
|
82
|
+
var KNOWN_ESTADOS = new Set(DGII_ESTADOS);
|
|
83
|
+
var EXPECTED_COLUMNS = 11;
|
|
84
|
+
var COLUMN = {
|
|
85
|
+
rnc: 0,
|
|
86
|
+
nombre: 1,
|
|
87
|
+
nombreComercial: 2,
|
|
88
|
+
actividad: 3,
|
|
89
|
+
fechaConstitucion: 8,
|
|
90
|
+
estado: 9,
|
|
91
|
+
regimen: 10
|
|
92
|
+
};
|
|
93
|
+
var ESTADO_SAMPLE_SIZE = 1e3;
|
|
94
|
+
var ESTADO_MIN_RECOGNIZED_RATIO = 0.5;
|
|
95
|
+
var UTF8_BOM = "\uFEFF";
|
|
96
|
+
var UTF8_BOM_AS_LATIN1 = "\xEF\xBB\xBF";
|
|
97
|
+
function stripBom(line) {
|
|
98
|
+
if (line.startsWith(UTF8_BOM)) return line.slice(UTF8_BOM.length);
|
|
99
|
+
if (line.startsWith(UTF8_BOM_AS_LATIN1)) {
|
|
100
|
+
return line.slice(UTF8_BOM_AS_LATIN1.length);
|
|
101
|
+
}
|
|
102
|
+
return line;
|
|
103
|
+
}
|
|
71
104
|
async function parseBulkFile(options) {
|
|
72
105
|
const results = [];
|
|
106
|
+
let dataLines = 0;
|
|
107
|
+
let firstLine = true;
|
|
73
108
|
const rl = _readline.createInterface.call(void 0, {
|
|
74
|
-
input: _fs.createReadStream.call(void 0, options.filePath, {
|
|
109
|
+
input: _fs.createReadStream.call(void 0, options.filePath, {
|
|
110
|
+
encoding: _nullishCoalesce(options.encoding, () => ( "latin1"))
|
|
111
|
+
}),
|
|
75
112
|
crlfDelay: Infinity
|
|
76
113
|
});
|
|
77
|
-
for await (const
|
|
114
|
+
for await (const rawLine of rl) {
|
|
115
|
+
const line = firstLine ? stripBom(rawLine) : rawLine;
|
|
116
|
+
firstLine = false;
|
|
78
117
|
if (line.trim() === "") continue;
|
|
118
|
+
dataLines += 1;
|
|
79
119
|
const fields = line.split("|");
|
|
80
|
-
if (fields.length
|
|
120
|
+
if (fields.length !== EXPECTED_COLUMNS) continue;
|
|
81
121
|
results.push({
|
|
82
|
-
rnc: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0,
|
|
83
|
-
nombre: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0,
|
|
84
|
-
nombreComercial: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0,
|
|
85
|
-
actividad: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
122
|
+
rnc: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, fields[COLUMN.rnc]),
|
|
123
|
+
nombre: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, fields[COLUMN.nombre]),
|
|
124
|
+
nombreComercial: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, fields[COLUMN.nombreComercial]),
|
|
125
|
+
actividad: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, fields[COLUMN.actividad]),
|
|
126
|
+
fechaConstitucion: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, fields[COLUMN.fechaConstitucion]),
|
|
127
|
+
estado: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, fields[COLUMN.estado]).toUpperCase(),
|
|
128
|
+
regimen: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, fields[COLUMN.regimen])
|
|
89
129
|
});
|
|
90
130
|
}
|
|
131
|
+
if (dataLines > 0) {
|
|
132
|
+
const sample = results.slice(0, ESTADO_SAMPLE_SIZE);
|
|
133
|
+
const reconocidos = sample.filter((r) => KNOWN_ESTADOS.has(r.estado));
|
|
134
|
+
const ratio = sample.length === 0 ? 0 : reconocidos.length / sample.length;
|
|
135
|
+
if (ratio < ESTADO_MIN_RECOGNIZED_RATIO) {
|
|
136
|
+
throw new (0, _chunkNASWEFHNcjs.BulkFormatError)(
|
|
137
|
+
`El archivo masivo de la DGII no coincide con el layout esperado de 11 columnas: la mayor\xEDa de las filas muestreadas no trae un \`estado\` reconocido (${DGII_ESTADOS.join(", ")}). \xBFCambi\xF3 el formato del archivo?`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
91
141
|
return results;
|
|
92
142
|
}
|
|
93
143
|
|
|
@@ -95,4 +145,5 @@ async function parseBulkFile(options) {
|
|
|
95
145
|
|
|
96
146
|
|
|
97
147
|
|
|
98
|
-
|
|
148
|
+
|
|
149
|
+
exports.DGII_BULK_URL = DGII_BULK_URL; exports.DGII_ESTADOS = DGII_ESTADOS; exports.downloadBulkFile = downloadBulkFile; exports.parseBulkFile = parseBulkFile;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
|
3
|
+
var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
|
|
4
4
|
|
|
5
5
|
// src/utils/fetch-error.ts
|
|
6
6
|
function wrapFetchError(error, timeoutMs) {
|
|
7
7
|
const name = error.name;
|
|
8
8
|
const causeName = _optionalChain([error, 'access', _ => _.cause, 'optionalAccess', _2 => _2.name]);
|
|
9
9
|
if (name === "TimeoutError" || causeName === "TimeoutError" || name === "AbortError" || causeName === "AbortError") {
|
|
10
|
-
return new (0,
|
|
10
|
+
return new (0, _chunkNASWEFHNcjs.DgiiConnectionError)(
|
|
11
11
|
`Timeout de ${timeoutMs}ms excedido al conectar con la DGII`,
|
|
12
12
|
{ cause: error }
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
|
-
return new (0,
|
|
15
|
+
return new (0, _chunkNASWEFHNcjs.DgiiConnectionError)(
|
|
16
16
|
"Error de conexi\xF3n con el servicio de la DGII",
|
|
17
17
|
{ cause: error }
|
|
18
18
|
);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collapseSpaces
|
|
3
3
|
} from "./chunk-D26S6EXD.js";
|
|
4
|
+
import {
|
|
5
|
+
BulkFormatError
|
|
6
|
+
} from "./chunk-IRQX4WNQ.js";
|
|
4
7
|
|
|
5
8
|
// src/bulk/downloader.ts
|
|
6
9
|
import { get } from "https";
|
|
@@ -10,6 +13,14 @@ import { join } from "path";
|
|
|
10
13
|
|
|
11
14
|
// src/bulk/types.ts
|
|
12
15
|
var DGII_BULK_URL = "https://dgii.gov.do/app/WebApps/Consultas/RNC/DGII_RNC.zip";
|
|
16
|
+
var DGII_ESTADOS = /* @__PURE__ */ Object.freeze([
|
|
17
|
+
"ACTIVO",
|
|
18
|
+
"SUSPENDIDO",
|
|
19
|
+
"DADO DE BAJA",
|
|
20
|
+
"CESE TEMPORAL",
|
|
21
|
+
"ANULADO",
|
|
22
|
+
"RECHAZADO"
|
|
23
|
+
]);
|
|
13
24
|
|
|
14
25
|
// src/bulk/downloader.ts
|
|
15
26
|
async function downloadBulkFile(options) {
|
|
@@ -68,31 +79,71 @@ function handleResponse(response, destPath, resolve, reject) {
|
|
|
68
79
|
// src/bulk/parser.ts
|
|
69
80
|
import { createReadStream } from "fs";
|
|
70
81
|
import { createInterface } from "readline";
|
|
82
|
+
var KNOWN_ESTADOS = new Set(DGII_ESTADOS);
|
|
83
|
+
var EXPECTED_COLUMNS = 11;
|
|
84
|
+
var COLUMN = {
|
|
85
|
+
rnc: 0,
|
|
86
|
+
nombre: 1,
|
|
87
|
+
nombreComercial: 2,
|
|
88
|
+
actividad: 3,
|
|
89
|
+
fechaConstitucion: 8,
|
|
90
|
+
estado: 9,
|
|
91
|
+
regimen: 10
|
|
92
|
+
};
|
|
93
|
+
var ESTADO_SAMPLE_SIZE = 1e3;
|
|
94
|
+
var ESTADO_MIN_RECOGNIZED_RATIO = 0.5;
|
|
95
|
+
var UTF8_BOM = "\uFEFF";
|
|
96
|
+
var UTF8_BOM_AS_LATIN1 = "\xEF\xBB\xBF";
|
|
97
|
+
function stripBom(line) {
|
|
98
|
+
if (line.startsWith(UTF8_BOM)) return line.slice(UTF8_BOM.length);
|
|
99
|
+
if (line.startsWith(UTF8_BOM_AS_LATIN1)) {
|
|
100
|
+
return line.slice(UTF8_BOM_AS_LATIN1.length);
|
|
101
|
+
}
|
|
102
|
+
return line;
|
|
103
|
+
}
|
|
71
104
|
async function parseBulkFile(options) {
|
|
72
105
|
const results = [];
|
|
106
|
+
let dataLines = 0;
|
|
107
|
+
let firstLine = true;
|
|
73
108
|
const rl = createInterface({
|
|
74
|
-
input: createReadStream(options.filePath, {
|
|
109
|
+
input: createReadStream(options.filePath, {
|
|
110
|
+
encoding: options.encoding ?? "latin1"
|
|
111
|
+
}),
|
|
75
112
|
crlfDelay: Infinity
|
|
76
113
|
});
|
|
77
|
-
for await (const
|
|
114
|
+
for await (const rawLine of rl) {
|
|
115
|
+
const line = firstLine ? stripBom(rawLine) : rawLine;
|
|
116
|
+
firstLine = false;
|
|
78
117
|
if (line.trim() === "") continue;
|
|
118
|
+
dataLines += 1;
|
|
79
119
|
const fields = line.split("|");
|
|
80
|
-
if (fields.length
|
|
120
|
+
if (fields.length !== EXPECTED_COLUMNS) continue;
|
|
81
121
|
results.push({
|
|
82
|
-
rnc: collapseSpaces(fields[
|
|
83
|
-
nombre: collapseSpaces(fields[
|
|
84
|
-
nombreComercial: collapseSpaces(fields[
|
|
85
|
-
actividad: collapseSpaces(fields[
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
122
|
+
rnc: collapseSpaces(fields[COLUMN.rnc]),
|
|
123
|
+
nombre: collapseSpaces(fields[COLUMN.nombre]),
|
|
124
|
+
nombreComercial: collapseSpaces(fields[COLUMN.nombreComercial]),
|
|
125
|
+
actividad: collapseSpaces(fields[COLUMN.actividad]),
|
|
126
|
+
fechaConstitucion: collapseSpaces(fields[COLUMN.fechaConstitucion]),
|
|
127
|
+
estado: collapseSpaces(fields[COLUMN.estado]).toUpperCase(),
|
|
128
|
+
regimen: collapseSpaces(fields[COLUMN.regimen])
|
|
89
129
|
});
|
|
90
130
|
}
|
|
131
|
+
if (dataLines > 0) {
|
|
132
|
+
const sample = results.slice(0, ESTADO_SAMPLE_SIZE);
|
|
133
|
+
const reconocidos = sample.filter((r) => KNOWN_ESTADOS.has(r.estado));
|
|
134
|
+
const ratio = sample.length === 0 ? 0 : reconocidos.length / sample.length;
|
|
135
|
+
if (ratio < ESTADO_MIN_RECOGNIZED_RATIO) {
|
|
136
|
+
throw new BulkFormatError(
|
|
137
|
+
`El archivo masivo de la DGII no coincide con el layout esperado de 11 columnas: la mayor\xEDa de las filas muestreadas no trae un \`estado\` reconocido (${DGII_ESTADOS.join(", ")}). \xBFCambi\xF3 el formato del archivo?`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
91
141
|
return results;
|
|
92
142
|
}
|
|
93
143
|
|
|
94
144
|
export {
|
|
95
145
|
DGII_BULK_URL,
|
|
146
|
+
DGII_ESTADOS,
|
|
96
147
|
downloadBulkFile,
|
|
97
148
|
parseBulkFile
|
|
98
149
|
};
|
package/dist/client.cjs
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
require('./chunk-
|
|
8
|
-
require('./chunk-
|
|
9
|
-
require('./chunk-
|
|
6
|
+
var _chunk6ZRPVQPPcjs = require('./chunk-6ZRPVQPP.cjs');
|
|
7
|
+
require('./chunk-DLB5RJ7E.cjs');
|
|
8
|
+
require('./chunk-FRM5XREF.cjs');
|
|
9
|
+
require('./chunk-OSGHCQFA.cjs');
|
|
10
|
+
require('./chunk-WMFHPNFP.cjs');
|
|
10
11
|
require('./chunk-QH4BK5X3.cjs');
|
|
11
|
-
require('./chunk-
|
|
12
|
+
require('./chunk-NASWEFHN.cjs');
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
exports.ConsecutiveBreaker =
|
|
18
|
+
exports.ConsecutiveBreaker = _chunk6ZRPVQPPcjs.ConsecutiveBreaker; exports.DgiiClient = _chunk6ZRPVQPPcjs.DgiiClient; exports.isRetryableError = _chunk6ZRPVQPPcjs.isRetryableError; exports.withRetry = _chunk6ZRPVQPPcjs.withRetry;
|
package/dist/client.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente, N as NcfQueryResult } from './index-
|
|
1
|
+
import { C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult } from './index-BPvMDXya.cjs';
|
|
2
2
|
|
|
3
3
|
interface RetryOptions {
|
|
4
4
|
/** Número máximo de reintentos (por defecto: 2) */
|
|
@@ -86,9 +86,14 @@ declare class DgiiClient {
|
|
|
86
86
|
*/
|
|
87
87
|
getContribuyente(rnc: string): Promise<Contribuyente>;
|
|
88
88
|
/**
|
|
89
|
-
* Valida un comprobante fiscal
|
|
89
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
90
|
+
*
|
|
91
|
+
* @param rnc - RNC del emisor
|
|
92
|
+
* @param ncf - NCF o e-NCF a validar
|
|
93
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
94
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
90
95
|
*/
|
|
91
|
-
getNCF(rnc: string, ncf: string): Promise<NcfQueryResult>;
|
|
96
|
+
getNCF(rnc: string, ncf: string, options?: NcfQueryOptions): Promise<NcfQueryResult>;
|
|
92
97
|
private _executeWithFallback;
|
|
93
98
|
}
|
|
94
99
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente, N as NcfQueryResult } from './index-
|
|
1
|
+
import { C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult } from './index-BPvMDXya.js';
|
|
2
2
|
|
|
3
3
|
interface RetryOptions {
|
|
4
4
|
/** Número máximo de reintentos (por defecto: 2) */
|
|
@@ -86,9 +86,14 @@ declare class DgiiClient {
|
|
|
86
86
|
*/
|
|
87
87
|
getContribuyente(rnc: string): Promise<Contribuyente>;
|
|
88
88
|
/**
|
|
89
|
-
* Valida un comprobante fiscal
|
|
89
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
90
|
+
*
|
|
91
|
+
* @param rnc - RNC del emisor
|
|
92
|
+
* @param ncf - NCF o e-NCF a validar
|
|
93
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
94
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
90
95
|
*/
|
|
91
|
-
getNCF(rnc: string, ncf: string): Promise<NcfQueryResult>;
|
|
96
|
+
getNCF(rnc: string, ncf: string, options?: NcfQueryOptions): Promise<NcfQueryResult>;
|
|
92
97
|
private _executeWithFallback;
|
|
93
98
|
}
|
|
94
99
|
|
package/dist/client.js
CHANGED
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
DgiiClient,
|
|
4
4
|
isRetryableError,
|
|
5
5
|
withRetry
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-JV4HWHYP.js";
|
|
7
|
+
import "./chunk-QTN5ZT4P.js";
|
|
8
|
+
import "./chunk-7ILLRYE4.js";
|
|
9
|
+
import "./chunk-H42U4GI5.js";
|
|
10
|
+
import "./chunk-KW4ZV6FJ.js";
|
|
10
11
|
import "./chunk-D26S6EXD.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-IRQX4WNQ.js";
|
|
12
13
|
export {
|
|
13
14
|
ConsecutiveBreaker,
|
|
14
15
|
DgiiClient,
|
package/dist/errors.cjs
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunk7RJWFPCZcjs = require('./chunk-7RJWFPCZ.cjs');
|
|
8
7
|
|
|
8
|
+
var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.AllStrategiesFailedError = _chunkNASWEFHNcjs.AllStrategiesFailedError; exports.BulkFormatError = _chunkNASWEFHNcjs.BulkFormatError; exports.DgiiConnectionError = _chunkNASWEFHNcjs.DgiiConnectionError; exports.DgiiError = _chunkNASWEFHNcjs.DgiiError; exports.DgiiNotFoundError = _chunkNASWEFHNcjs.DgiiNotFoundError; exports.DgiiServiceError = _chunkNASWEFHNcjs.DgiiServiceError;
|
package/dist/errors.d.cts
CHANGED
|
@@ -36,5 +36,14 @@ declare class AllStrategiesFailedError extends DgiiError {
|
|
|
36
36
|
readonly errors: ReadonlyArray<Error>;
|
|
37
37
|
constructor(message: string, errors: ReadonlyArray<Error>);
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* El archivo masivo (DGII_RNC.zip) no coincide con el layout esperado:
|
|
41
|
+
* cambió el número de columnas o la columna `estado` dejó de traer
|
|
42
|
+
* valores reconocidos. Se lanza para que un cambio de formato de la DGII
|
|
43
|
+
* falle de forma ruidosa en vez de devolver `estado` vacío en silencio.
|
|
44
|
+
*/
|
|
45
|
+
declare class BulkFormatError extends DgiiError {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
39
48
|
|
|
40
|
-
export { AllStrategiesFailedError, DgiiConnectionError, DgiiError, DgiiNotFoundError, DgiiServiceError };
|
|
49
|
+
export { AllStrategiesFailedError, BulkFormatError, DgiiConnectionError, DgiiError, DgiiNotFoundError, DgiiServiceError };
|
package/dist/errors.d.ts
CHANGED
|
@@ -36,5 +36,14 @@ declare class AllStrategiesFailedError extends DgiiError {
|
|
|
36
36
|
readonly errors: ReadonlyArray<Error>;
|
|
37
37
|
constructor(message: string, errors: ReadonlyArray<Error>);
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* El archivo masivo (DGII_RNC.zip) no coincide con el layout esperado:
|
|
41
|
+
* cambió el número de columnas o la columna `estado` dejó de traer
|
|
42
|
+
* valores reconocidos. Se lanza para que un cambio de formato de la DGII
|
|
43
|
+
* falle de forma ruidosa en vez de devolver `estado` vacío en silencio.
|
|
44
|
+
*/
|
|
45
|
+
declare class BulkFormatError extends DgiiError {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
39
48
|
|
|
40
|
-
export { AllStrategiesFailedError, DgiiConnectionError, DgiiError, DgiiNotFoundError, DgiiServiceError };
|
|
49
|
+
export { AllStrategiesFailedError, BulkFormatError, DgiiConnectionError, DgiiError, DgiiNotFoundError, DgiiServiceError };
|
package/dist/errors.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AllStrategiesFailedError,
|
|
3
|
+
BulkFormatError,
|
|
3
4
|
DgiiConnectionError,
|
|
4
5
|
DgiiError,
|
|
5
6
|
DgiiNotFoundError,
|
|
6
7
|
DgiiServiceError
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IRQX4WNQ.js";
|
|
8
9
|
export {
|
|
9
10
|
AllStrategiesFailedError,
|
|
11
|
+
BulkFormatError,
|
|
10
12
|
DgiiConnectionError,
|
|
11
13
|
DgiiError,
|
|
12
14
|
DgiiNotFoundError,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resultado de validación para RNC y cédula.
|
|
3
|
+
*/
|
|
4
|
+
type ValidationResult = {
|
|
5
|
+
valid: true;
|
|
6
|
+
formatted: string;
|
|
7
|
+
} | {
|
|
8
|
+
valid: false;
|
|
9
|
+
formatted?: undefined;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resultado de validación para NCF (serie B) y e-NCF (serie E).
|
|
13
|
+
*/
|
|
14
|
+
type NcfValidationResult = {
|
|
15
|
+
valid: true;
|
|
16
|
+
type: string;
|
|
17
|
+
serie: string;
|
|
18
|
+
} | {
|
|
19
|
+
valid: false;
|
|
20
|
+
type?: undefined;
|
|
21
|
+
serie?: undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Datos de un contribuyente registrado en la DGII.
|
|
25
|
+
*
|
|
26
|
+
* `esFacturadorElectronico` indica si la DGII certificó al RNC como
|
|
27
|
+
* emisor de e-CF. Hoy solo el parser de scraping deriva el valor real;
|
|
28
|
+
* el parser SOAP retorna `false` hasta que la DGII restaure el endpoint.
|
|
29
|
+
*/
|
|
30
|
+
interface Contribuyente {
|
|
31
|
+
rnc: string;
|
|
32
|
+
nombre: string;
|
|
33
|
+
nombreComercial: string;
|
|
34
|
+
estado: string;
|
|
35
|
+
categoria: string;
|
|
36
|
+
esFacturadorElectronico: boolean;
|
|
37
|
+
actividadEconomica?: string;
|
|
38
|
+
regimenDePagos?: string;
|
|
39
|
+
administracionLocal?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Datos adicionales para consultar un e-NCF (serie E) en la DGII.
|
|
43
|
+
*
|
|
44
|
+
* La DGII exige el RNC del comprador (o el ID extranjero) para
|
|
45
|
+
* responder el estado de un e-NCF. Se ignoran al consultar un NCF
|
|
46
|
+
* de serie B.
|
|
47
|
+
*/
|
|
48
|
+
interface NcfQueryOptions {
|
|
49
|
+
/** RNC del comprador tal como aparece en la factura. */
|
|
50
|
+
rncComprador?: string;
|
|
51
|
+
/** Código de seguridad de 6 caracteres impreso en la factura. */
|
|
52
|
+
codigoSeguridad?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Resultado de validación de un comprobante fiscal contra la DGII.
|
|
56
|
+
*
|
|
57
|
+
* `valid` significa que la DGII encontró el comprobante, no que esté
|
|
58
|
+
* aceptado: para un e-NCF hay que revisar `estado` (por ejemplo
|
|
59
|
+
* `Aceptado`).
|
|
60
|
+
*
|
|
61
|
+
* Los campos de la sección e-NCF (`rncComprador`, `codigoSeguridad`,
|
|
62
|
+
* `estado`, `montoTotal`, `totalItbis`, `fechaEmision`, `fechaFirma`)
|
|
63
|
+
* solo se llenan cuando el comprobante es un e-NCF (serie E).
|
|
64
|
+
* `nombreComercial` no se llena para la serie E porque la DGII no lo
|
|
65
|
+
* muestra en esa consulta. `fechaEmision` y `fechaFirma` son strings
|
|
66
|
+
* exactamente como la DGII los renderiza.
|
|
67
|
+
*/
|
|
68
|
+
interface NcfQueryResult {
|
|
69
|
+
valid: boolean;
|
|
70
|
+
rnc: string;
|
|
71
|
+
ncf: string;
|
|
72
|
+
nombreComercial?: string;
|
|
73
|
+
rncComprador?: string;
|
|
74
|
+
codigoSeguridad?: string;
|
|
75
|
+
estado?: string;
|
|
76
|
+
montoTotal?: number;
|
|
77
|
+
totalItbis?: number;
|
|
78
|
+
fechaEmision?: string;
|
|
79
|
+
fechaFirma?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Registro del archivo masivo de contribuyentes (DGII_RNC.zip).
|
|
83
|
+
*/
|
|
84
|
+
interface BulkContribuyente {
|
|
85
|
+
rnc: string;
|
|
86
|
+
nombre: string;
|
|
87
|
+
nombreComercial: string;
|
|
88
|
+
actividad: string;
|
|
89
|
+
/**
|
|
90
|
+
* Estado tal como lo trae el archivo masivo, normalizado a mayúsculas:
|
|
91
|
+
* uno de los valores de `DGII_ESTADOS` (ACTIVO, SUSPENDIDO, DADO DE
|
|
92
|
+
* BAJA, ...). Es un vocabulario más amplio que el `estado` binario
|
|
93
|
+
* (ACTIVO/INACTIVO) de {@link Contribuyente}, así que no son
|
|
94
|
+
* intercambiables al comparar entre fuentes.
|
|
95
|
+
*/
|
|
96
|
+
estado: string;
|
|
97
|
+
regimen: string;
|
|
98
|
+
fechaConstitucion: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type { BulkContribuyente as B, Contribuyente as C, NcfQueryOptions as N, ValidationResult as V, NcfQueryResult as a, NcfValidationResult as b };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resultado de validación para RNC y cédula.
|
|
3
|
+
*/
|
|
4
|
+
type ValidationResult = {
|
|
5
|
+
valid: true;
|
|
6
|
+
formatted: string;
|
|
7
|
+
} | {
|
|
8
|
+
valid: false;
|
|
9
|
+
formatted?: undefined;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resultado de validación para NCF (serie B) y e-NCF (serie E).
|
|
13
|
+
*/
|
|
14
|
+
type NcfValidationResult = {
|
|
15
|
+
valid: true;
|
|
16
|
+
type: string;
|
|
17
|
+
serie: string;
|
|
18
|
+
} | {
|
|
19
|
+
valid: false;
|
|
20
|
+
type?: undefined;
|
|
21
|
+
serie?: undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Datos de un contribuyente registrado en la DGII.
|
|
25
|
+
*
|
|
26
|
+
* `esFacturadorElectronico` indica si la DGII certificó al RNC como
|
|
27
|
+
* emisor de e-CF. Hoy solo el parser de scraping deriva el valor real;
|
|
28
|
+
* el parser SOAP retorna `false` hasta que la DGII restaure el endpoint.
|
|
29
|
+
*/
|
|
30
|
+
interface Contribuyente {
|
|
31
|
+
rnc: string;
|
|
32
|
+
nombre: string;
|
|
33
|
+
nombreComercial: string;
|
|
34
|
+
estado: string;
|
|
35
|
+
categoria: string;
|
|
36
|
+
esFacturadorElectronico: boolean;
|
|
37
|
+
actividadEconomica?: string;
|
|
38
|
+
regimenDePagos?: string;
|
|
39
|
+
administracionLocal?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Datos adicionales para consultar un e-NCF (serie E) en la DGII.
|
|
43
|
+
*
|
|
44
|
+
* La DGII exige el RNC del comprador (o el ID extranjero) para
|
|
45
|
+
* responder el estado de un e-NCF. Se ignoran al consultar un NCF
|
|
46
|
+
* de serie B.
|
|
47
|
+
*/
|
|
48
|
+
interface NcfQueryOptions {
|
|
49
|
+
/** RNC del comprador tal como aparece en la factura. */
|
|
50
|
+
rncComprador?: string;
|
|
51
|
+
/** Código de seguridad de 6 caracteres impreso en la factura. */
|
|
52
|
+
codigoSeguridad?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Resultado de validación de un comprobante fiscal contra la DGII.
|
|
56
|
+
*
|
|
57
|
+
* `valid` significa que la DGII encontró el comprobante, no que esté
|
|
58
|
+
* aceptado: para un e-NCF hay que revisar `estado` (por ejemplo
|
|
59
|
+
* `Aceptado`).
|
|
60
|
+
*
|
|
61
|
+
* Los campos de la sección e-NCF (`rncComprador`, `codigoSeguridad`,
|
|
62
|
+
* `estado`, `montoTotal`, `totalItbis`, `fechaEmision`, `fechaFirma`)
|
|
63
|
+
* solo se llenan cuando el comprobante es un e-NCF (serie E).
|
|
64
|
+
* `nombreComercial` no se llena para la serie E porque la DGII no lo
|
|
65
|
+
* muestra en esa consulta. `fechaEmision` y `fechaFirma` son strings
|
|
66
|
+
* exactamente como la DGII los renderiza.
|
|
67
|
+
*/
|
|
68
|
+
interface NcfQueryResult {
|
|
69
|
+
valid: boolean;
|
|
70
|
+
rnc: string;
|
|
71
|
+
ncf: string;
|
|
72
|
+
nombreComercial?: string;
|
|
73
|
+
rncComprador?: string;
|
|
74
|
+
codigoSeguridad?: string;
|
|
75
|
+
estado?: string;
|
|
76
|
+
montoTotal?: number;
|
|
77
|
+
totalItbis?: number;
|
|
78
|
+
fechaEmision?: string;
|
|
79
|
+
fechaFirma?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Registro del archivo masivo de contribuyentes (DGII_RNC.zip).
|
|
83
|
+
*/
|
|
84
|
+
interface BulkContribuyente {
|
|
85
|
+
rnc: string;
|
|
86
|
+
nombre: string;
|
|
87
|
+
nombreComercial: string;
|
|
88
|
+
actividad: string;
|
|
89
|
+
/**
|
|
90
|
+
* Estado tal como lo trae el archivo masivo, normalizado a mayúsculas:
|
|
91
|
+
* uno de los valores de `DGII_ESTADOS` (ACTIVO, SUSPENDIDO, DADO DE
|
|
92
|
+
* BAJA, ...). Es un vocabulario más amplio que el `estado` binario
|
|
93
|
+
* (ACTIVO/INACTIVO) de {@link Contribuyente}, así que no son
|
|
94
|
+
* intercambiables al comparar entre fuentes.
|
|
95
|
+
*/
|
|
96
|
+
estado: string;
|
|
97
|
+
regimen: string;
|
|
98
|
+
fechaConstitucion: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type { BulkContribuyente as B, Contribuyente as C, NcfQueryOptions as N, ValidationResult as V, NcfQueryResult as a, NcfValidationResult as b };
|