Skip to content

Commit 069323c

Browse files
authored
Merge pull request #130 from smarty/ryan/hello_types
Ryan/hello types
2 parents 6fa6613 + 831f0ec commit 069323c

File tree

153 files changed

+7045
-4917
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+7045
-4917
lines changed

.claude/settings.json

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
{
2-
"permissions": {
3-
"allow": [
4-
"Edit",
5-
"Write",
6-
"Bash(rm:./*)",
7-
"Bash(git *)",
8-
"Bash(make *)",
9-
"Bash(npm *)"
10-
]
11-
},
12-
"attribution": {
13-
"commit": "",
14-
"pr": ""
15-
}
2+
"permissions": {
3+
"allow": ["Edit", "Write", "Bash(rm:./*)", "Bash(git *)", "Bash(make *)", "Bash(npm *)"]
4+
},
5+
"attribution": {
6+
"commit": "",
7+
"pr": ""
8+
}
169
}

.github/workflows/node-tests.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@ name: Node Tests
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
strategy:
1514
matrix:
1615
node-version: [20.x, 22.x, 24.x]
1716

1817
steps:
19-
- uses: actions/checkout@v6
20-
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v6
22-
with:
23-
node-version: ${{ matrix.node-version }}
24-
- run: npm ci
25-
- run: npm run build
26-
- run: npm test
27-
env:
28-
CI: true
18+
- uses: actions/checkout@v6
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v6
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: npm ci
24+
- run: npm run build
25+
- run: npm test
26+
env:
27+
CI: true

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Publish to npm
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
77

88
permissions:
9-
id-token: write # Required for OIDC
9+
id-token: write # Required for OIDC
1010
contents: read
1111

1212
jobs:
@@ -19,8 +19,8 @@ jobs:
1919
- name: Setup Node.js
2020
uses: actions/setup-node@v6
2121
with:
22-
node-version: '20.x'
23-
registry-url: 'https://registry.npmjs.org'
22+
node-version: "20.x"
23+
registry-url: "https://registry.npmjs.org"
2424

2525
- name: Update npm
2626
run: npm install -g npm@'>=11.5.1'
@@ -44,4 +44,4 @@ jobs:
4444
run: npm publish
4545
env:
4646
NPM_CONFIG_PROVENANCE: true
47-
NPM_TOKEN: ''
47+
NPM_TOKEN: ""

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
See the changelog repository:
44

5-
github.com/smartystreets/changelog/blob/master/sdk/javascript.md
5+
github.com/smartystreets/changelog/blob/master/sdk/javascript.md

CLAUDE.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
```bash
88
npm install # Install dependencies
9-
npm test # Run all tests (JS + TS)
10-
npm run test:js # Run JavaScript tests only
11-
npm run test:ts # Run TypeScript tests only
9+
npm test # Run all tests
1210
npm run build # Build the library (outputs to dist/)
1311
npx tsc --noEmit # Type-check without emitting
1412
npx prettier --write . # Format all files (respects .prettierignore)
@@ -23,16 +21,16 @@ make integrate # Run all example files against built dist/
2321
```
2422

2523
To run a single test file:
24+
2625
```bash
27-
npx mocha tests/us_street/test_Client.js # JS test
28-
npx mocha --require tsx/cjs tests/test_RetrySender.ts # TS test
26+
npx mocha --require tsx/cjs tests/test_RetrySender.ts
2927
```
3028

3129
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).
3230

3331
## Architecture
3432

35-
This is the official JavaScript SDK for Smarty address validation APIs. It supports both Node.js (CommonJS/ESM) and browser environments.
33+
This is the official JavaScript SDK for Smarty address validation APIs. It supports both Node.js (CommonJS/ESM) and browser environments. The entire codebase is TypeScript.
3634

3735
### Sender Chain Pattern
3836

@@ -51,46 +49,49 @@ All senders implement the `Sender` interface from `src/types.ts`, which also def
5149

5250
- **ClientBuilder**: Fluent API for configuring and building API-specific clients. Accepts either `StaticCredentials` (server-side: auth-id + auth-token) or `SharedCredentials` (client-side: embedded key).
5351

54-
- **Lookup classes**: Each API has a `Lookup` that holds both input parameters and results after the API call. Located in `src/<api_name>/Lookup.js`.
52+
- **Lookup classes**: Each API has a `Lookup` that holds both input parameters and results after the API call. Located in `src/<api_name>/Lookup.ts`.
5553

5654
- **Batch**: Container for up to 100 lookups. Single lookups use GET requests; batches with 2+ lookups use POST.
5755

58-
- **Client classes**: Each API has a `Client` in `src/<api_name>/Client.js` that handles domain-specific request building and response parsing.
56+
- **Client classes**: Each API has a `Client` in `src/<api_name>/Client.ts` that handles domain-specific request building and response parsing.
5957

6058
### API Modules
6159

6260
Each API follows the same structure in `src/<api_name>/`:
63-
- `Lookup.js` - Input/output container
64-
- `Client.js` - Request/response handling
65-
- `Candidate.js`, `Result.js`, or `Suggestion.js` - Response data structures
61+
62+
- `Lookup.ts` - Input/output container
63+
- `Client.ts` - Request/response handling
64+
- `Candidate.ts`, `Result.ts`, or `Suggestion.ts` - Response data structures
6665

6766
Supported APIs: `us_street`, `us_zipcode`, `us_autocomplete_pro`, `us_extract`, `us_enrichment`, `us_reverse_geo`, `international_street`, `international_address_autocomplete`, `international_postal_code`
6867

6968
### Credentials
7069

7170
Three credential types, each implementing a `sign(request)` method used by `SigningSender`:
72-
- **StaticCredentials** (TS) - Server-side: adds `auth-id` + `auth-token` query params
73-
- **SharedCredentials** (TS) - Client-side/browser: adds embedded `key` param + `Referer` header. Cannot be used with POST (batch) requests.
74-
- **BasicAuthCredentials** (TS) - Adds HTTP Basic Auth `Authorization` header
71+
72+
- **StaticCredentials** - Server-side: adds `auth-id` + `auth-token` query params
73+
- **SharedCredentials** - Client-side/browser: adds embedded `key` param + `Referer` header. Cannot be used with POST (batch) requests.
74+
- **BasicAuthCredentials** - Adds HTTP Basic Auth `Authorization` header
7575

7676
### Entry Point
7777

78-
`index.mjs` exports all public classes organized by API namespace (e.g., `core`, `usStreet`, `usZipcode`).
78+
`index.ts` exports all public classes organized by API namespace (e.g., `core`, `usStreet`, `usZipcode`).
7979

8080
### Test Infrastructure
8181

8282
Tests use Mocha + Chai (`expect` style). Test files are prefixed with `test_` and mirror the source structure under `tests/`.
8383

84-
`tests/fixtures/mock_senders.js` provides reusable mocks:
84+
`tests/fixtures/mock_senders.ts` provides reusable mocks:
85+
8586
- `MockSender` - Captures the request for inspection
8687
- `MockSenderWithResponse` - Returns a fixed payload/error
8788
- `MockSenderWithStatusCodesAndHeaders` - Iterates through status codes (useful for retry tests)
8889

8990
## Code Style
9091

9192
- Uses Prettier: tabs, double quotes, 100 char line width, trailing commas
92-
- Mixed JS/TS: Business logic (clients, lookups, results) in JS; infrastructure (credentials, senders, types) in TS
93+
- All source and test files are TypeScript with ES module syntax (`import`/`export`)
94+
- Import paths use `.js` extensions (TypeScript resolves `.js` to `.ts`)
9395
- TypeScript is configured with `strict: true`, `exactOptionalPropertyTypes`, and `noPropertyAccessFromIndexSignature`
94-
- `allowJs: true` in tsconfig enables type-checking of JS files alongside TS
9596
- Tests use Mocha + Chai with `expect` style assertions
9697
- Test files are prefixed with `test_` and mirror the source structure

0 commit comments

Comments
 (0)