Skip to content

Commit 184f6c8

Browse files
committed
docs: sync CLAUDE.md and SECURITY.md with shipped modules
CLAUDE.md still described soap/ and bulk/ as "Not implemented" stubs and listed only four subpath exports. Document the seven real exports plus the client, scraping, and errors modules, and drop the stub language. Add the resilient and scraping clients to SECURITY.md scope.
1 parent 2811fb4 commit 184f6c8

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

CLAUDE.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ with code in this repository.
88
dgii-ts is a TypeScript library for validating Dominican Republic tax
99
identifiers and integrating with the DGII (Dirección General de
1010
Impuestos 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

SECURITY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ through [GitHub Security Advisories](https://github.com/franklinmdev/dgii-ts/sec
1616
### Scope
1717

1818
- Validators (RNC, cedula, NCF, e-NCF)
19-
- SOAP client
19+
- Resilient client (DgiiClient): circuit breaker and retry
20+
- Scraping client (DGII ASP.NET pages)
21+
- SOAP client (deprecated)
2022
- Bulk downloader/parser
2123

2224
### Response timeline

0 commit comments

Comments
 (0)