Skip to content

v7: options-object API, request cancellation, strict TypeScript#325

Merged
laurentpellegrino merged 2 commits into
mainfrom
v7
Jul 5, 2026
Merged

v7: options-object API, request cancellation, strict TypeScript#325
laurentpellegrino merged 2 commits into
mainfrom
v7

Conversation

@laurentpellegrino

Copy link
Copy Markdown
Collaborator

Summary

The v7 modernization: reshapes the public API to idiomatic TypeScript while keeping every 6.x call form working as a deprecated alias with identical behavior.

  • Options-object construction: new IpregistryClient({ apiKey, baseUrl: 'eu', cache, maxRetries, timeout, ... }) replaces the IpregistryConfigBuilder pattern (builder still works, marked deprecated). The plain API-key-string form remains non-deprecated.
  • Per-call LookupOptions: client.lookupIp(ip, { fields, hostname, params, signal }) replaces variadic IpregistryOptions.filter(...) style options (also still working, deprecated). Cache keys are identical between the two forms, so mixed usage shares the cache.
  • Request cancellation: every lookup accepts { signal: AbortSignal }. Aborting cancels the in-flight fetch, pending retries and their backoff waits (with AbortSignal.any and a fallback for Node < 20.3), and pending batch chunks. Error messages mirror the Go client (Request cancelled, Request cancelled during retry backoff).
  • parseUserAgents accepts an array; the variadic form is deprecated.
  • Full strict TypeScript: noImplicitAny enabled; IpregistryCache<V> is generic with a new IpregistryCacheValue type; @types/chai added for the test suite.
  • README examples migrated to the new API; CHANGELOG carries a migration table.

Compatibility

All 46 pre-existing tests pass unchanged against this branch, plus 8 new tests for the v7 surface (54 total). Runtime smoke tests pass on Node and workerd; @arethetypeswrong/cli reports no problems.

Version is bumped to 7.0.0 on the branch; releasing stays a manual gh workflow run release.yaml -f version=7.0.0 after merge.

@laurentpellegrino laurentpellegrino merged commit 68eebe7 into main Jul 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant