dgii-ts 0.1.0 → 0.1.1
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 +64 -26
- package/README.md +64 -25
- package/package.json +25 -7
package/README.en.md
CHANGED
|
@@ -19,11 +19,13 @@ basic RNC or NCF lookups. Dominican developers rely on fragile scrapers that
|
|
|
19
19
|
parse ASP.NET WebForms pages with ViewState — and those pages have changed URLs
|
|
20
20
|
at least three times, breaking every existing integration.
|
|
21
21
|
|
|
22
|
-
**dgii-ts** solves this with a
|
|
22
|
+
**dgii-ts** solves this with a four-layer approach designed for resilience:
|
|
23
23
|
|
|
24
24
|
1. **Offline validation** — never fails, zero network calls
|
|
25
|
-
2. **
|
|
26
|
-
3. **
|
|
25
|
+
2. **Web scraping** — real-time queries against DGII's ASP.NET pages
|
|
26
|
+
3. **SOAP client** *(deprecated)* — WSMovilDGII wrapper, blocked by
|
|
27
|
+
DGII since January 2025
|
|
28
|
+
4. **Bulk data** — import DGII's daily bulk RNC file (DGII\_RNC.zip)
|
|
27
29
|
|
|
28
30
|
## Features
|
|
29
31
|
|
|
@@ -35,11 +37,23 @@ points of failure. Includes whitelists of 578 Cedulas and 23 RNCs
|
|
|
35
37
|
(source: [python-stdnum](https://github.com/arthurdejong/python-stdnum))
|
|
36
38
|
that pass validation despite failing the check-digit algorithm.
|
|
37
39
|
|
|
38
|
-
###
|
|
40
|
+
### Resilient client (DgiiClient)
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
`DgiiClient` is the recommended entry point for real-time queries. It uses
|
|
43
|
+
web scraping as its primary strategy with SOAP fallback, a circuit breaker
|
|
44
|
+
to prevent cascading failures, and retry with exponential backoff.
|
|
45
|
+
|
|
46
|
+
### Web scraping
|
|
47
|
+
|
|
48
|
+
Queries DGII's ASP.NET pages by extracting ViewState tokens and parsing
|
|
49
|
+
response HTML. This is the primary strategy since DGII blocked the SOAP
|
|
50
|
+
endpoint in January 2025.
|
|
51
|
+
|
|
52
|
+
### SOAP client (WSMovilDGII) — deprecated
|
|
53
|
+
|
|
54
|
+
Typed wrapper around DGII's SOAP service. **Permanently blocked by DGII
|
|
55
|
+
since January 2025.** Kept as an internal fallback but not recommended
|
|
56
|
+
for direct use.
|
|
43
57
|
|
|
44
58
|
### Bulk data importer
|
|
45
59
|
|
|
@@ -104,22 +118,26 @@ const result = validateEcf('E310000000001');
|
|
|
104
118
|
import { validateRnc } from 'dgii-ts/validators';
|
|
105
119
|
```
|
|
106
120
|
|
|
107
|
-
Available submodules: `dgii-ts/validators`, `dgii-ts/
|
|
108
|
-
`dgii-ts/bulk`.
|
|
109
|
-
|
|
110
|
-
### Look up a taxpayer (SOAP) — *coming soon*
|
|
121
|
+
Available submodules: `dgii-ts/validators`, `dgii-ts/client`,
|
|
122
|
+
`dgii-ts/scraping`, `dgii-ts/soap`, `dgii-ts/bulk`, and `dgii-ts/errors`.
|
|
111
123
|
|
|
112
|
-
|
|
113
|
-
> and will be available in a future release.
|
|
124
|
+
### Look up a taxpayer
|
|
114
125
|
|
|
115
126
|
```typescript
|
|
116
|
-
import {
|
|
127
|
+
import { DgiiClient } from 'dgii-ts/client';
|
|
117
128
|
|
|
118
|
-
const client = new
|
|
129
|
+
const client = new DgiiClient();
|
|
119
130
|
const result = await client.getContribuyente('131098193');
|
|
120
131
|
// { rnc: '131098193', nombre: '...', estado: '...', ... }
|
|
121
132
|
```
|
|
122
133
|
|
|
134
|
+
### Validate an NCF online
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
138
|
+
// { rnc: '131098193', ncf: 'B0100000001', estado: '...', ... }
|
|
139
|
+
```
|
|
140
|
+
|
|
123
141
|
## API reference
|
|
124
142
|
|
|
125
143
|
### Validators
|
|
@@ -131,20 +149,36 @@ const result = await client.getContribuyente('131098193');
|
|
|
131
149
|
| `validateNcf(value)` | Validates NCF format and type (B-series) |
|
|
132
150
|
| `validateEcf(value)` | Validates e-NCF format and type (E-series) |
|
|
133
151
|
|
|
134
|
-
###
|
|
152
|
+
### Resilient client
|
|
135
153
|
|
|
136
154
|
| Class/Method | Description |
|
|
137
155
|
| --- | --- |
|
|
138
|
-
| `
|
|
156
|
+
| `DgiiClient` | Scraping + SOAP fallback, circuit breaker, retry |
|
|
139
157
|
| `client.getContribuyente(rnc)` | Looks up taxpayer data by RNC |
|
|
140
158
|
| `client.getNCF(rnc, ncf)` | Validates a fiscal receipt against DGII |
|
|
141
159
|
|
|
160
|
+
### Scraping
|
|
161
|
+
|
|
162
|
+
| Class/Method | Description |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `ScrapingClient` | Queries DGII's ASP.NET pages |
|
|
165
|
+
| `client.getContribuyente(rnc)` | Looks up taxpayer data by RNC |
|
|
166
|
+
| `client.getNCF(rnc, ncf)` | Validates a fiscal receipt |
|
|
167
|
+
|
|
168
|
+
### SOAP client (deprecated)
|
|
169
|
+
|
|
170
|
+
| Class/Method | Description |
|
|
171
|
+
| --- | --- |
|
|
172
|
+
| `DgiiSoapClient` | WSMovilDGII client (blocked) |
|
|
173
|
+
| `client.getContribuyente(rnc)` | Looks up taxpayer data by RNC |
|
|
174
|
+
| `client.getNCF(rnc, ncf)` | Validates a fiscal receipt |
|
|
175
|
+
|
|
142
176
|
### Bulk data
|
|
143
177
|
|
|
144
178
|
| Class/Method | Description |
|
|
145
179
|
| --- | --- |
|
|
146
|
-
| `downloadBulkFile(
|
|
147
|
-
| `parseBulkFile(
|
|
180
|
+
| `downloadBulkFile(options)` | Downloads DGII\_RNC.zip to the given directory |
|
|
181
|
+
| `parseBulkFile(options)` | Parses the taxpayer TXT file |
|
|
148
182
|
|
|
149
183
|
## Architecture
|
|
150
184
|
|
|
@@ -155,8 +189,9 @@ const result = await client.getContribuyente('131098193');
|
|
|
155
189
|
│ Layer 1: Offline validation │
|
|
156
190
|
│ ✓ RNC/Cedula check-digit ✓ NCF/e-NCF format │
|
|
157
191
|
├─────────────────────────────────────────────────┤
|
|
158
|
-
│ Layer 2:
|
|
159
|
-
│ ✓
|
|
192
|
+
│ Layer 2: DgiiClient (resilient) │
|
|
193
|
+
│ ✓ Web scraping (primary) │
|
|
194
|
+
│ ✓ SOAP fallback ✓ Circuit breaker ✓ Retry │
|
|
160
195
|
├─────────────────────────────────────────────────┤
|
|
161
196
|
│ Layer 3: Bulk data (DGII_RNC.zip) │
|
|
162
197
|
│ ✓ Daily download ✓ TXT parsing │
|
|
@@ -164,15 +199,18 @@ const result = await client.getContribuyente('131098193');
|
|
|
164
199
|
```
|
|
165
200
|
|
|
166
201
|
**Layer 1** is instant and works offline. **Layer 2** provides real-time data
|
|
167
|
-
|
|
168
|
-
|
|
202
|
+
using web scraping as the primary strategy, with SOAP fallback, circuit
|
|
203
|
+
breaker, and retry with exponential backoff. **Layer 3** is ideal for batch
|
|
204
|
+
operations where you need to look up thousands of RNCs quickly.
|
|
169
205
|
|
|
170
206
|
## Project status
|
|
171
207
|
|
|
172
208
|
- [x] Offline validation (RNC, Cedula, NCF, e-NCF)
|
|
173
|
-
- [
|
|
174
|
-
- [
|
|
175
|
-
- [
|
|
209
|
+
- [x] Web scraping of DGII's ASP.NET pages
|
|
210
|
+
- [x] SOAP client WSMovilDGII (deprecated — blocked by DGII)
|
|
211
|
+
- [x] Resilient client with circuit breaker and retry
|
|
212
|
+
- [x] Bulk data importer (download + parsing)
|
|
213
|
+
- [x] Published on npm
|
|
176
214
|
|
|
177
215
|
## Security
|
|
178
216
|
|
package/README.md
CHANGED
|
@@ -20,12 +20,15 @@ dependen de scrapers frágiles que parsean páginas ASP.NET con ViewState — y
|
|
|
20
20
|
esas páginas han cambiado de URL al menos tres veces, rompiendo cada integración
|
|
21
21
|
existente.
|
|
22
22
|
|
|
23
|
-
**dgii-ts** resuelve esto con un enfoque de
|
|
23
|
+
**dgii-ts** resuelve esto con un enfoque de cuatro capas diseñado para
|
|
24
24
|
resiliencia:
|
|
25
25
|
|
|
26
26
|
1. **Validación offline** — nunca falla, cero llamadas de red
|
|
27
|
-
2. **
|
|
28
|
-
|
|
27
|
+
2. **Web scraping** — consultas en tiempo real contra las páginas
|
|
28
|
+
ASP.NET de la DGII
|
|
29
|
+
3. **Cliente SOAP** *(deprecated)* — wrapper del servicio WSMovilDGII,
|
|
30
|
+
bloqueado por la DGII en enero 2025
|
|
31
|
+
4. **Datos masivos** — importación del archivo diario DGII\_RNC.zip
|
|
29
32
|
|
|
30
33
|
## Características
|
|
31
34
|
|
|
@@ -37,11 +40,23 @@ puntos de fallo externos. Incluye whitelists de 578 cédulas y 23 RNCs
|
|
|
37
40
|
(fuente: [python-stdnum](https://github.com/arthurdejong/python-stdnum)) que
|
|
38
41
|
pasan validación aunque no cumplan el algoritmo de dígito verificador.
|
|
39
42
|
|
|
40
|
-
### Cliente
|
|
43
|
+
### Cliente resiliente (DgiiClient)
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
`DgiiClient` es el punto de entrada recomendado para consultas en tiempo real.
|
|
46
|
+
Usa web scraping como estrategia primaria con fallback a SOAP, circuit breaker
|
|
47
|
+
para evitar cascadas de errores, y retry con backoff exponencial.
|
|
48
|
+
|
|
49
|
+
### Web scraping
|
|
50
|
+
|
|
51
|
+
Consulta las páginas ASP.NET de la DGII extrayendo tokens ViewState y
|
|
52
|
+
parseando el HTML de respuesta. Es la estrategia principal desde que la DGII
|
|
53
|
+
bloqueó el endpoint SOAP en enero 2025.
|
|
54
|
+
|
|
55
|
+
### Cliente SOAP (WSMovilDGII) — deprecated
|
|
56
|
+
|
|
57
|
+
Wrapper tipado alrededor del servicio SOAP de la DGII. **Bloqueado
|
|
58
|
+
permanentemente por la DGII en enero 2025.** Se mantiene como fallback
|
|
59
|
+
interno pero no se recomienda su uso directo.
|
|
45
60
|
|
|
46
61
|
### Importador de datos masivos
|
|
47
62
|
|
|
@@ -106,22 +121,26 @@ const result = validateEcf('E310000000001');
|
|
|
106
121
|
import { validateRnc } from 'dgii-ts/validators';
|
|
107
122
|
```
|
|
108
123
|
|
|
109
|
-
Los submódulos disponibles son `dgii-ts/validators`, `dgii-ts/
|
|
110
|
-
`dgii-ts/bulk`.
|
|
111
|
-
|
|
112
|
-
### Consultar contribuyente (SOAP) — *pendiente*
|
|
124
|
+
Los submódulos disponibles son `dgii-ts/validators`, `dgii-ts/client`,
|
|
125
|
+
`dgii-ts/scraping`, `dgii-ts/soap`, `dgii-ts/bulk` y `dgii-ts/errors`.
|
|
113
126
|
|
|
114
|
-
|
|
115
|
-
> y estará disponible en una futura versión.
|
|
127
|
+
### Consultar contribuyente
|
|
116
128
|
|
|
117
129
|
```typescript
|
|
118
|
-
import {
|
|
130
|
+
import { DgiiClient } from 'dgii-ts/client';
|
|
119
131
|
|
|
120
|
-
const client = new
|
|
132
|
+
const client = new DgiiClient();
|
|
121
133
|
const result = await client.getContribuyente('131098193');
|
|
122
134
|
// { rnc: '131098193', nombre: '...', estado: '...', ... }
|
|
123
135
|
```
|
|
124
136
|
|
|
137
|
+
### Validar NCF en línea
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
141
|
+
// { rnc: '131098193', ncf: 'B0100000001', estado: '...', ... }
|
|
142
|
+
```
|
|
143
|
+
|
|
125
144
|
## Referencia del API
|
|
126
145
|
|
|
127
146
|
### Validadores
|
|
@@ -133,20 +152,36 @@ const result = await client.getContribuyente('131098193');
|
|
|
133
152
|
| `validateNcf(value)` | Valida formato y tipo de NCF (serie B) |
|
|
134
153
|
| `validateEcf(value)` | Valida formato y tipo de e-NCF (serie E) |
|
|
135
154
|
|
|
136
|
-
### Cliente
|
|
155
|
+
### Cliente resiliente
|
|
137
156
|
|
|
138
157
|
| Clase/Método | Descripción |
|
|
139
158
|
| --- | --- |
|
|
140
|
-
| `
|
|
159
|
+
| `DgiiClient` | Cliente con scraping + SOAP fallback, circuit breaker y retry |
|
|
141
160
|
| `client.getContribuyente(rnc)` | Consulta datos de un contribuyente por RNC |
|
|
142
161
|
| `client.getNCF(rnc, ncf)` | Valida un comprobante fiscal contra la DGII |
|
|
143
162
|
|
|
163
|
+
### Scraping
|
|
164
|
+
|
|
165
|
+
| Clase/Método | Descripción |
|
|
166
|
+
| --- | --- |
|
|
167
|
+
| `ScrapingClient` | Consulta páginas ASP.NET de la DGII |
|
|
168
|
+
| `client.getContribuyente(rnc)` | Consulta contribuyente por RNC |
|
|
169
|
+
| `client.getNCF(rnc, ncf)` | Valida comprobante fiscal |
|
|
170
|
+
|
|
171
|
+
### Cliente SOAP (deprecated)
|
|
172
|
+
|
|
173
|
+
| Clase/Método | Descripción |
|
|
174
|
+
| --- | --- |
|
|
175
|
+
| `DgiiSoapClient` | Cliente para WSMovilDGII (bloqueado) |
|
|
176
|
+
| `client.getContribuyente(rnc)` | Consulta contribuyente por RNC |
|
|
177
|
+
| `client.getNCF(rnc, ncf)` | Valida comprobante fiscal |
|
|
178
|
+
|
|
144
179
|
### Datos masivos
|
|
145
180
|
|
|
146
181
|
| Clase/Método | Descripción |
|
|
147
182
|
| --- | --- |
|
|
148
|
-
| `downloadBulkFile(
|
|
149
|
-
| `parseBulkFile(
|
|
183
|
+
| `downloadBulkFile(options)` | Descarga DGII\_RNC.zip |
|
|
184
|
+
| `parseBulkFile(options)` | Parsea el archivo TXT |
|
|
150
185
|
|
|
151
186
|
## Arquitectura
|
|
152
187
|
|
|
@@ -157,8 +192,9 @@ const result = await client.getContribuyente('131098193');
|
|
|
157
192
|
│ Capa 1: Validación offline │
|
|
158
193
|
│ ✓ Check-digit RNC/Cédula ✓ Formato NCF/e-NCF │
|
|
159
194
|
├─────────────────────────────────────────────────┤
|
|
160
|
-
│ Capa 2:
|
|
161
|
-
│ ✓
|
|
195
|
+
│ Capa 2: DgiiClient (resiliente) │
|
|
196
|
+
│ ✓ Web scraping (primario) │
|
|
197
|
+
│ ✓ SOAP fallback ✓ Circuit breaker ✓ Retry │
|
|
162
198
|
├─────────────────────────────────────────────────┤
|
|
163
199
|
│ Capa 3: Datos masivos (DGII_RNC.zip) │
|
|
164
200
|
│ ✓ Descarga diaria ✓ Parseo TXT │
|
|
@@ -166,15 +202,18 @@ const result = await client.getContribuyente('131098193');
|
|
|
166
202
|
```
|
|
167
203
|
|
|
168
204
|
La **capa 1** es instantánea y funciona sin conexión. La **capa 2** ofrece
|
|
169
|
-
datos en tiempo real
|
|
205
|
+
datos en tiempo real con web scraping como estrategia primaria, fallback a
|
|
206
|
+
SOAP, circuit breaker y retry con backoff exponencial. La **capa 3** es
|
|
170
207
|
ideal para operaciones en lote donde necesitas buscar miles de RNC rápidamente.
|
|
171
208
|
|
|
172
209
|
## Estado del proyecto
|
|
173
210
|
|
|
174
211
|
- [x] Validación offline (RNC, cédula, NCF, e-NCF)
|
|
175
|
-
- [
|
|
176
|
-
- [
|
|
177
|
-
- [
|
|
212
|
+
- [x] Web scraping de las páginas ASP.NET de la DGII
|
|
213
|
+
- [x] Cliente SOAP WSMovilDGII (deprecated — bloqueado por la DGII)
|
|
214
|
+
- [x] Cliente resiliente con circuit breaker y retry
|
|
215
|
+
- [x] Importador DGII\_RNC.zip (descarga + parseo)
|
|
216
|
+
- [x] Publicado en npm
|
|
178
217
|
|
|
179
218
|
## Seguridad
|
|
180
219
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dgii-ts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Librería TypeScript para validación e integración con la DGII de República Dominicana — RNC, Cédula, NCF, e-NCF",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -48,16 +48,34 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"./scraping": {
|
|
51
|
-
"import": {
|
|
52
|
-
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/scraping.d.ts",
|
|
53
|
+
"default": "./dist/scraping.js"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/scraping.d.cts",
|
|
57
|
+
"default": "./dist/scraping.cjs"
|
|
58
|
+
}
|
|
53
59
|
},
|
|
54
60
|
"./client": {
|
|
55
|
-
"import": {
|
|
56
|
-
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/client.d.ts",
|
|
63
|
+
"default": "./dist/client.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/client.d.cts",
|
|
67
|
+
"default": "./dist/client.cjs"
|
|
68
|
+
}
|
|
57
69
|
},
|
|
58
70
|
"./errors": {
|
|
59
|
-
"import": {
|
|
60
|
-
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./dist/errors.d.ts",
|
|
73
|
+
"default": "./dist/errors.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./dist/errors.d.cts",
|
|
77
|
+
"default": "./dist/errors.cjs"
|
|
78
|
+
}
|
|
61
79
|
}
|
|
62
80
|
},
|
|
63
81
|
"sideEffects": false,
|