Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ npx prettier --write . # Format all files (respects .prettierignore)
```

Makefile targets (used by CI):

```bash
make test # fmt + test (installs deps if needed)
make build # Rollup build
Expand All @@ -26,7 +27,7 @@ To run a single test file:
npx mocha --require tsx/cjs tests/test_RetrySender.ts
```

Build outputs dual formats via Rollup: `dist/cjs/` (CommonJS), `dist/esm/` (ESM), and `dist/types/` (declarations). Rollup preserves module structure (`preserveModules: true`). Axios and axios-retry are external dependencies (not bundled).
Build outputs dual formats via Rollup: `dist/cjs/` (CommonJS), `dist/esm/` (ESM), and `dist/types/` (declarations). Rollup preserves module structure (`preserveModules: true`). `undici` is the only external dependency (not bundled).

## Architecture

Expand All @@ -41,7 +42,7 @@ CustomQuerySender → LicenseSender → BaseUrlSender → CustomHeaderSender
→ AgentSender → RetrySender → SigningSender → StatusCodeSender → HttpSender
```

Each sender adds specific functionality (authentication, retries, headers, etc.). The `HttpSender` at the end uses Axios for actual HTTP transport.
Each sender adds specific functionality (authentication, retries, headers, etc.). The `HttpSender` at the end uses the Fetch API for HTTP transport (with optional `undici` `ProxyAgent` for proxy support in Node.js).

All senders implement the `Sender` interface from `src/types.ts`, which also defines the core `Request` and `Response` contracts that flow through the chain.

Expand Down
10 changes: 5 additions & 5 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ console.log(response.lookups[0].result);

## Import Patterns

| Style | Syntax |
| --- | --- |
| ESM default import | `import SmartySDK from "smartystreets-javascript-sdk"` |
| ESM named imports | `import { core, usStreet } from "smartystreets-javascript-sdk"` |
| CommonJS | `const SmartySDK = require("smartystreets-javascript-sdk")` |
| Style | Syntax |
| ---------------------- | ------------------------------------------------------------------- |
| ESM default import | `import SmartySDK from "smartystreets-javascript-sdk"` |
| ESM named imports | `import { core, usStreet } from "smartystreets-javascript-sdk"` |
| CommonJS | `const SmartySDK = require("smartystreets-javascript-sdk")` |
| TypeScript type import | `import type { MatchStrategy } from "smartystreets-javascript-sdk"` |

## FAQ
Expand Down
11 changes: 9 additions & 2 deletions examples/international_address_autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ClientBuilder, BasicAuthCredentials, LookupInternationalAddressAutocomplete } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupInternationalAddressAutocomplete,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down Expand Up @@ -41,7 +45,10 @@ function logSuggestions(response: LookupInternationalAddressAutocomplete, messag
console.log("\n");
}

async function handleRequest(lookup: LookupInternationalAddressAutocomplete, lookupType: string): Promise<void> {
async function handleRequest(
lookup: LookupInternationalAddressAutocomplete,
lookupType: string,
): Promise<void> {
try {
const results = await client.send(lookup);
logSuggestions(results, lookupType);
Expand Down
19 changes: 16 additions & 3 deletions examples/international_postal_code.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ClientBuilder, BasicAuthCredentials, LookupInternationalPostalCode } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupInternationalPostalCode,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down Expand Up @@ -43,7 +47,10 @@ function displayResult(lookup: LookupInternationalPostalCode, message: string):
console.log("\n");
}

async function handleResponse(lookup: LookupInternationalPostalCode, lookupType: string): Promise<void> {
async function handleResponse(
lookup: LookupInternationalPostalCode,
lookupType: string,
): Promise<void> {
try {
const result = await client.send(lookup);
displayResult(result, lookupType);
Expand All @@ -59,7 +66,13 @@ async function main(): Promise<void> {
// lookup1.addCustomParameter("input_id", 1234);

// Lookup by locality, administrative area, and country
const lookup2 = new LookupInternationalPostalCode("Brazil", undefined, "SP", "Sao Paulo", "ID-8675309");
const lookup2 = new LookupInternationalPostalCode(
"Brazil",
undefined,
"SP",
"Sao Paulo",
"ID-8675309",
);

await handleResponse(lookup1, "Postal code lookup");
await handleResponse(lookup2, "Locality and administrative area lookup");
Expand Down
6 changes: 5 additions & 1 deletion examples/international_street.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ClientBuilder, BasicAuthCredentials, LookupInternationalStreet } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupInternationalStreet,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down
6 changes: 5 additions & 1 deletion examples/us_autocomplete_pro.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ClientBuilder, BasicAuthCredentials, LookupUSAutocompletePro } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupUSAutocompletePro,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down
6 changes: 5 additions & 1 deletion examples/us_enrichment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ClientBuilder, BasicAuthCredentials, LookupUSEnrichment } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupUSEnrichment,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down
6 changes: 5 additions & 1 deletion examples/us_reverse_geo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ClientBuilder, BasicAuthCredentials, LookupUSReverseGeo } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupUSReverseGeo,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down
7 changes: 6 additions & 1 deletion examples/us_street.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ClientBuilder, BasicAuthCredentials, LookupUSStreet, Batch } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupUSStreet,
Batch,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down
7 changes: 6 additions & 1 deletion examples/us_zipcode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ClientBuilder, BasicAuthCredentials, LookupUSZipcode, Batch } from "smartystreets-javascript-sdk";
import {
ClientBuilder,
BasicAuthCredentials,
LookupUSZipcode,
Batch,
} from "smartystreets-javascript-sdk";

// for client-side requests (browser/mobile), use this code:
// import { SharedCredentials } from "smartystreets-javascript-sdk";
Expand Down
Loading