@@ -8,7 +8,9 @@ with code in this repository.
88dgii-ts is a TypeScript library for validating Dominican Republic tax
99identifiers and integrating with the DGII (Dirección General de
1010Impuestos Internos). It provides offline validators for RNC, cédula,
11- NCF, and e-NCF, plus stubs for a SOAP client and bulk file operations.
11+ NCF, and e-NCF; a resilient client (web scraping with SOAP fallback,
12+ circuit breaker, retry); a deprecated SOAP client; and a bulk
13+ DGII_RNC.zip downloader/parser.
1214
1315## Commands
1416
@@ -25,9 +27,9 @@ npx vitest run --coverage
2527
2628## Architecture
2729
28- The library has four subpath exports (` ./ ` , ` ./validators ` , ` ./soap ` ,
29- ` ./bulk ` ) built via tsup with code splitting. ` src/index.ts ` re-exports
30- everything.
30+ The library has seven subpath exports (` ./ ` , ` ./validators ` ,
31+ ` ./client ` , ` ./scraping ` , ` ./soap ` , ` ./bulk ` , ` ./errors ` ) built via
32+ tsup with code splitting. ` src/index.ts ` re-exports everything.
3133
3234- ** ` src/validators/ ` ** — Pure offline validators, no network calls.
3335 Each validator returns a typed result (` ValidationResult ` or
@@ -36,12 +38,30 @@ everything.
3638 (series E) are format-only checks with known type code mappings.
3739 Whitelists in ` rnc-whitelist.ts ` and ` cedula-whitelist.ts ` bypass
3840 algorithmic checks for known-valid identifiers.
39- - ** ` src/soap/ ` ** — SOAP client skeleton for DGII's WSMovilDGII
40- service. Currently stub implementations that throw "Not implemented".
41- - ** ` src/bulk/ ` ** — Bulk file download/parse skeleton. Currently stubs.
41+ - ** ` src/client/ ` ** — ` DgiiClient ` , the recommended entry point for
42+ live queries. Runs scraping as the primary strategy with SOAP
43+ fallback, wrapped in a consecutive-failure circuit breaker
44+ (` circuit-breaker.ts ` ) and exponential-backoff retry (` retry.ts ` ).
45+ - ** ` src/scraping/ ` ** — ` ScrapingClient ` for DGII's ASP.NET WebForms
46+ pages: extracts ViewState tokens (` endpoints.ts ` , ` FORM_FIELDS ` ) and
47+ parses response HTML (` html-parser.ts ` ). Primary live strategy since
48+ DGII blocked the SOAP endpoint in January 2025.
49+ - ** ` src/soap/ ` ** — ` DgiiSoapClient ` for the WSMovilDGII SOAP service
50+ (hand-rolled envelopes in ` envelopes.ts ` , XML parsing in ` xml.ts ` ).
51+ Deprecated: DGII blocked this endpoint in January 2025; kept only as
52+ the client's internal fallback.
53+ - ** ` src/bulk/ ` ** — Downloads (` downloader.ts ` ) and parses
54+ (` parser.ts ` ) DGII's daily ` DGII_RNC.zip ` . The parser maps a fixed
55+ 11-column layout via a named COLUMN index table and throws
56+ ` BulkFormatError ` on column-count or ` estado ` drift. Accepts an
57+ ` encoding ` option (` latin1 ` default).
58+ - ** ` src/errors/ ` ** — ` DgiiError ` base plus ` DgiiConnectionError ` ,
59+ ` DgiiNotFoundError ` , ` DgiiServiceError ` , ` AllStrategiesFailedError ` ,
60+ and ` BulkFormatError ` , each with a stable ` code ` .
4261- ** ` src/types/ ` ** — Shared interfaces (` ValidationResult ` ,
4362 ` NcfValidationResult ` , ` Contribuyente ` , etc.).
44- - ** ` src/utils/ ` ** — ` stripNonDigits() ` helper used by validators.
63+ - ** ` src/utils/ ` ** — ` stripNonDigits() ` and ` collapseSpaces() ` string
64+ helpers.
4565
4666## Code conventions
4767
0 commit comments