Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces the initial public API for @ciscode/api-kit, a typed Axios-backed HTTP client, and updates package metadata/docs for the v0.1.0 release.
Changes:
- Add
createApiClient+ApiErrorimplementation with typed request/response/error interceptor support and retry/backoff behavior. - Add Vitest coverage for the API client and error class.
- Update README/package metadata and add a Changesets entry for the initial release.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.ts | Exposes the new api surface from the package root exports. |
| src/api/index.ts | Defines the public exports for the new API module. |
| src/api/createApiClient.types.ts | Introduces the public types for the API client and interceptors. |
| src/api/createApiClient.ts | Implements the Axios wrapper, normalization to ApiError, interceptors, and retry logic. |
| src/api/createApiClient.test.ts | Adds unit tests for HTTP methods, interceptors, error mapping, and retry behavior. |
| src/api/ApiError.ts | Adds the ApiError class used as the normalized error type. |
| src/api/ApiError.test.ts | Adds unit tests for the ApiError class. |
| README.md | Replaces template README with package documentation and usage examples. |
| package.json | Bumps version/description and adds Axios as a dependency. |
| package-lock.json | Updates lockfile to include Axios and related dependencies. |
| .changeset/release-v0.1.0.md | Adds a changeset describing the initial minor release. |
| "name": "@ciscode/api-kit", | ||
| "version": "0.0.0", | ||
| "description": "Typed HTTP client factory on Axios.", | ||
| "version": "0.1.0", | ||
| "description": "Typed HTTP client for TypeScript — wraps Axios with zero leaky abstractions.", |
There was a problem hiding this comment.
package.json version is bumped to 0.1.0 while a changeset in this PR also declares a minor release. With the documented Changesets flow (run changeset version to update versions), keeping both will cause the next versioning step to bump again (e.g., to 0.2.0) or create inconsistent release state. Consider either (a) reverting the manual version change and relying on the changeset + version-packages, or (b) if this is the post-versioning release PR, remove the changeset file (it should have been consumed by changeset version).
| for (const interceptor of responseInterceptors) { | ||
| intercepted = interceptor(intercepted); | ||
| } | ||
|
|
There was a problem hiding this comment.
ResponseInterceptor returns an InterceptedResponse (including status and headers), but the implementation only applies intercepted.data back onto the Axios response. This means any interceptor changes to status/headers are silently ignored by the underlying response object, which is surprising given the type signature. Either apply status/headers back onto axiosResponse, or narrow the interceptor contract/docs to indicate that only data mutations are honored.
| axiosResponse.status = intercepted.status; | |
| axiosResponse.headers = intercepted.headers; |
| await tokenClient.get('/secure'); | ||
|
|
||
| const requestCall = mockState.instance.get.mock.calls[0]; | ||
| expect(requestCall).toBeDefined(); | ||
| }); |
There was a problem hiding this comment.
This token-injection test doesn’t assert the expected behavior: it only checks that the request call exists. To meaningfully cover getToken, assert that the request interceptor actually injects Authorization: Bearer <token> into the outgoing request config/headers (and ideally also verify it’s absent when getToken returns null).
* chore: scaffolding the repo * Release/v0.1.0 readme changeset (#1) * feat: add createApiClient factory with typed HTTP methods wrapping axios * feat: add composable interceptor system and built-in auth token injector to ApiClient * feat: add ApiError class and configurable retry with exponential backoff * Revert "feat: add ApiError class and configurable retry with exponential backoff" This reverts commit 2d7c8f3. * Reapply "feat: add ApiError class and configurable retry with exponential backoff" This reverts commit db3568d. * feat: add ApiError class and configurable retry with exponential backoff * test: add comprehensive test suite for ApiClient with ApiError, retry backoff, and interceptor coverag * docs: add README with full API documentation and changeset for v0.1.0 * fix(api-kit): resolve CI failures and sonar issues in develop→master PR (#3) --------- Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>
Summary
Why
Checklist
npm run lintpassesnpm run typecheckpassesnpm testpassesnpm run buildpassesnpx changeset) if this affects consumersNotes