|
1 | 1 | ## 1. Types & Generated Code |
2 | 2 |
|
3 | | -- [ ] 1.1 Generate TypeScript types from `openapi/spec/consulta-endereco.yaml` using openapi-typescript |
4 | | -- [ ] 1.2 Create `src/generated/consulta-endereco.ts` with generated types |
5 | | -- [ ] 1.3 Export Address-related types from `src/generated/index.ts` |
| 3 | +- [x] 1.1 Generate TypeScript types from `openapi/spec/consulta-endereco.yaml` using openapi-typescript |
| 4 | + - Note: Swagger 2.0 not supported by openapi-typescript v6+, types created manually |
| 5 | +- [x] 1.2 Create `src/generated/consulta-endereco.ts` with generated types |
| 6 | +- [x] 1.3 Export Address-related types from `src/generated/index.ts` |
6 | 7 |
|
7 | 8 | ## 2. Core Types Extension |
8 | 9 |
|
9 | | -- [ ] 2.1 Add `addressApiKey?: string` to `NfeConfig` interface in `src/core/types.ts` |
10 | | -- [ ] 2.2 Add `Address` and `AddressLookupResponse` types to `src/core/types.ts` |
11 | | -- [ ] 2.3 Add `AddressSearchOptions` type with `filter` field |
| 10 | +- [x] 2.1 Add `addressApiKey?: string` to `NfeConfig` interface in `src/core/types.ts` |
| 11 | +- [x] 2.2 Add `Address` and `AddressLookupResponse` types to `src/core/types.ts` |
| 12 | +- [x] 2.3 Add `AddressSearchOptions` type with `filter` field |
12 | 13 |
|
13 | 14 | ## 3. Multi-API Support Infrastructure |
14 | 15 |
|
15 | | -- [ ] 3.1 Refactor `NfeClient` constructor to not require `apiKey` (make it optional) |
16 | | -- [ ] 3.2 Add `resolveAddressApiKey()` private method with fallback chain logic |
17 | | -- [ ] 3.3 Add `resolveMainApiKey()` private method for existing resources |
18 | | -- [ ] 3.4 Add `getEnvironmentVariable()` helper method for reading `NFE_ADDRESS_API_KEY` |
19 | | -- [ ] 3.5 Convert `serviceInvoices`, `companies`, `legalPeople`, `naturalPeople`, `webhooks` to lazy getters with validation |
| 16 | +- [x] 3.1 Refactor `NfeClient` constructor to not require `apiKey` (make it optional) |
| 17 | +- [x] 3.2 Add `resolveAddressApiKey()` private method with fallback chain logic |
| 18 | +- [x] 3.3 Add `resolveMainApiKey()` private method for existing resources |
| 19 | +- [x] 3.4 Add `getEnvironmentVariable()` helper method for reading `NFE_ADDRESS_API_KEY` |
| 20 | +- [x] 3.5 Convert `serviceInvoices`, `companies`, `legalPeople`, `naturalPeople`, `webhooks` to lazy getters with validation |
20 | 21 |
|
21 | 22 | ## 4. Addresses Resource Implementation |
22 | 23 |
|
23 | | -- [ ] 4.1 Create `src/core/resources/addresses.ts` with `AddressesResource` class |
24 | | -- [ ] 4.2 Implement `lookupByPostalCode(postalCode: string)` method |
25 | | -- [ ] 4.3 Implement `search(options: AddressSearchOptions)` method with `$filter` query param |
26 | | -- [ ] 4.4 Implement `lookupByTerm(term: string)` method |
27 | | -- [ ] 4.5 Add input validation for postal code format (8 digits, with or without hyphen) |
28 | | -- [ ] 4.6 Add input validation for empty term |
29 | | -- [ ] 4.7 Export `AddressesResource` from `src/core/resources/index.ts` |
| 24 | +- [x] 4.1 Create `src/core/resources/addresses.ts` with `AddressesResource` class |
| 25 | +- [x] 4.2 Implement `lookupByPostalCode(postalCode: string)` method |
| 26 | +- [x] 4.3 Implement `search(options: AddressSearchOptions)` method with `$filter` query param |
| 27 | +- [x] 4.4 Implement `lookupByTerm(term: string)` method |
| 28 | +- [x] 4.5 Add input validation for postal code format (8 digits, with or without hyphen) |
| 29 | +- [x] 4.6 Add input validation for empty term |
| 30 | +- [x] 4.7 Export `AddressesResource` from `src/core/resources/index.ts` |
30 | 31 |
|
31 | 32 | ## 5. Client Integration |
32 | 33 |
|
33 | | -- [ ] 5.1 Add lazy `addresses` getter to `NfeClient` class |
34 | | -- [ ] 5.2 Create separate `HttpClient` instance for addresses with `https://address.api.nfe.io/v2` base URL |
35 | | -- [ ] 5.3 Throw `ConfigurationError` with descriptive message when no API key available |
36 | | -- [ ] 5.4 Export Address types from `src/index.ts` |
| 34 | +- [x] 5.1 Add lazy `addresses` getter to `NfeClient` class |
| 35 | +- [x] 5.2 Create separate `HttpClient` instance for addresses with `https://address.api.nfe.io/v2` base URL |
| 36 | +- [x] 5.3 Throw `ConfigurationError` with descriptive message when no API key available |
| 37 | +- [x] 5.4 Export Address types from `src/index.ts` |
37 | 38 |
|
38 | 39 | ## 6. Unit Tests |
39 | 40 |
|
40 | | -- [ ] 6.1 Create `tests/unit/resources/addresses.test.ts` |
41 | | -- [ ] 6.2 Test `lookupByPostalCode()` with valid CEP returns correct response |
42 | | -- [ ] 6.3 Test `lookupByPostalCode()` with invalid CEP throws `ValidationError` |
43 | | -- [ ] 6.4 Test `lookupByTerm()` with empty term throws `ValidationError` |
44 | | -- [ ] 6.5 Test `search()` passes filter to query params correctly |
45 | | -- [ ] 6.6 Create `tests/unit/client-multikey.test.ts` for multi-API key tests |
46 | | -- [ ] 6.7 Test lazy getter throws when no key available |
47 | | -- [ ] 6.8 Test fallback chain: `addressApiKey` → `apiKey` → env vars |
48 | | -- [ ] 6.9 Test isolated resource usage (only addresses, no apiKey) |
| 41 | +- [x] 6.1 Create `tests/unit/resources/addresses.test.ts` |
| 42 | +- [x] 6.2 Test `lookupByPostalCode()` with valid CEP returns correct response |
| 43 | +- [x] 6.3 Test `lookupByPostalCode()` with invalid CEP throws `ValidationError` |
| 44 | +- [x] 6.4 Test `lookupByTerm()` with empty term throws `ValidationError` |
| 45 | +- [x] 6.5 Test `search()` passes filter to query params correctly |
| 46 | +- [x] 6.6 Create `tests/unit/client-multikey.test.ts` for multi-API key tests |
| 47 | +- [x] 6.7 Test lazy getter throws when no key available |
| 48 | +- [x] 6.8 Test fallback chain: `addressApiKey` → `apiKey` → env vars |
| 49 | +- [x] 6.9 Test isolated resource usage (only addresses, no apiKey) |
49 | 50 |
|
50 | 51 | ## 7. Integration Tests |
51 | 52 |
|
52 | | -- [ ] 7.1 Create `tests/integration/addresses.integration.test.ts` |
53 | | -- [ ] 7.2 Test real API call to lookup by postal code (requires test API key) |
54 | | -- [ ] 7.3 Test real API call to search by term |
55 | | -- [ ] 7.4 Test 404 response handling for non-existent CEP |
| 53 | +- [x] 7.1 Create `tests/integration/addresses.integration.test.ts` |
| 54 | +- [x] 7.2 Test real API call to lookup by postal code (requires test API key) |
| 55 | +- [x] 7.3 Test real API call to search by term |
| 56 | +- [x] 7.4 Test 404 response handling for non-existent CEP |
56 | 57 |
|
57 | 58 | ## 8. Documentation & Examples |
58 | 59 |
|
59 | | -- [ ] 8.1 Create `examples/address-lookup.js` with usage examples |
60 | | -- [ ] 8.2 Update `README.md` with Addresses resource documentation |
61 | | -- [ ] 8.3 Document `addressApiKey` configuration option |
62 | | -- [ ] 8.4 Document environment variables `NFE_ADDRESS_API_KEY` |
63 | | -- [ ] 8.5 Add JSDoc comments to all public methods in `AddressesResource` |
| 60 | +- [x] 8.1 Create `examples/address-lookup.js` with usage examples |
| 61 | +- [x] 8.2 Update `README.md` with Addresses resource documentation |
| 62 | +- [x] 8.3 Document `addressApiKey` configuration option |
| 63 | +- [x] 8.4 Document environment variables `NFE_ADDRESS_API_KEY` |
| 64 | +- [x] 8.5 Add JSDoc comments to all public methods in `AddressesResource` |
64 | 65 |
|
65 | 66 | ## 9. Final Validation |
66 | 67 |
|
67 | | -- [ ] 9.1 Run `npm run typecheck` - ensure zero errors |
68 | | -- [ ] 9.2 Run `npm run lint` - ensure zero warnings |
69 | | -- [ ] 9.3 Run `npm test` - ensure all tests pass |
70 | | -- [ ] 9.4 Run `npm run build` - ensure successful build |
| 68 | +- [x] 9.1 Run `npm run typecheck` - ensure zero errors |
| 69 | +- [x] 9.2 Run `npm run lint` - ensure zero warnings (only pre-existing `any` warnings) |
| 70 | +- [x] 9.3 Run `npm test` - ensure all tests pass (322 passing, 47 skipped) |
| 71 | +- [x] 9.4 Run `npm run build` - ensure successful build |
71 | 72 | - [ ] 9.5 Test examples manually against sandbox/production API |
0 commit comments