docs: Axios to @data-client/rest migration guide, codemod, and skill#3867
docs: Axios to @data-client/rest migration guide, codemod, and skill#3867
Conversation
Co-authored-by: natmaster <natmaster@gmail.com>
Co-authored-by: natmaster <natmaster@gmail.com>
Co-authored-by: natmaster <natmaster@gmail.com>
Co-authored-by: natmaster <natmaster@gmail.com>
Co-authored-by: natmaster <natmaster@gmail.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3867 +/- ##
=======================================
Coverage 98.08% 98.08%
=======================================
Files 152 152
Lines 2876 2876
Branches 564 564
=======================================
Hits 2821 2821
Misses 11 11
Partials 44 44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
…only PR branches now diff against merge-base with master so that website/ and docs/ changes in any commit trigger a preview deploy, not just changes in the tip commit. Co-authored-by: natmaster <natmaster@gmail.com>
ea75ded to
a10ad95
Compare
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
… failure The previous ignoreCommand used 'git fetch origin' which fails on Vercel PR builds because the 'origin' remote doesn't exist. Simplified to: - gh-pages* branches: always skip (exit 0) - master branch: diff HEAD^ HEAD for ./ and ../docs/ (squash merges) - PR branches: always build (exit 1) — avoids the remote issue entirely Co-authored-by: natmaster <natmaster@gmail.com>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
- Remove import type declarations from 'axios' entirely
- Filter out inline type specifiers (import { type X })
- Only add RestEndpoint import when a default import existed
- Avoid adding RestEndpoint for type-only imports with no default
Co-authored-by: natmaster <natmaster@gmail.com>
Cover 13 new scenarios:
- Generic type parameters on axios method calls
- as casts with AxiosResponse
- import type declarations (with/without default import)
- Inline type specifiers (import { type X })
- Inline type + unknown named imports
- typeof axios as type annotation (alone and with method calls)
- Re-exports from 'axios'
- declare module augmentations
- Multiple import statements from 'axios'
- Multiple imports with type references as annotations
Co-authored-by: natmaster <natmaster@gmail.com>
Tests added for 10 real-world axios usage patterns: 1. Chained .then() - preserved after transform 2. await with destructured result - transforms correctly 3. axios() as default function call - left unchanged (no-op) 4. Config object as second arg - left unchanged (no-op, was previously silently dropped) 5. axios.request() - left unchanged (no-op) 6. Template literals in URL - now transformed (was previously skipped) 7. Exported axios.create() instances - produces exported class 8. axios.create() with no arguments - produces empty class 9. Nested/conditional axios calls - all branches transformed 10. axios.all/axios.spread - inner gets transformed, axios.all preserved Codemod fixes: - Skip transform when a config object is passed as second argument (previously the config was silently dropped, producing broken output) - Support template literal URLs in addition to string literals (previously template literals caused the call to be silently skipped) - Return source unchanged (instead of undefined) when no axios import found Co-authored-by: natmaster <natmaster@gmail.com>
- SkillTabs component with link to skills.sh - Skill positioned before 'Why migrate' for easy access - Codemod section references skill as preferred approach Co-authored-by: natmaster <natmaster@gmail.com>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
- New 'Migration Guides' category in left nav between Data Guides and Endpoint API - Add brief migration section to REST Usage page with SkillTabs + link to full guide Co-authored-by: natmaster <natmaster@gmail.com>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6906b2e. Configure here.
Move axios-to-rest-migration from standalone skill into a reference file under data-client-rest-setup. Add migration references for raw fetch, ky, superagent, and got. SKILL.md now handles detection and routes to the relevant reference — agent only loads what it needs. Update SkillTabs to support multiple skills, update docs to reference data-client-rest-setup as the single migration entry point. Made-with: Cursor
Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Co-authored-by: Nathaniel Tucker <me@ntucker.me>

Fixes # .
Motivation
Users migrating from axios to
@data-client/restneed guidance on how to translate axios patterns (instances, interceptors, error handling, cancellation, etc.) into RestEndpoint lifecycle methods. This PR provides documentation, automated tooling, and AI-assisted migration support.Solution
1. Documentation guide (
docs/rest/guides/axios-migration.md)SkillTabs) at the top for easy access — preferred migration pathEndpointPlaygroundexamples for GET, POST, and instance creation2. jscodeshift codemod (
website/static/codemods/axios-to-rest.js)import axios from 'axios'withimport { RestEndpoint } from '@data-client/rest'axios.create({ baseURL, headers })into RestEndpoint subclasses withurlPrefix+getHeaders()axios.get()/.post()/.put()/.patch()/.delete()calls intonew RestEndpoint({ path, method })axios(e.g.isAxiosError,spread) while removing known type-only importsaxiosimported whenever unresolved usages remain (e.g. dynamic URL calls), while still injectingRestEndpointwhen partial conversion occurredimport type, inlinetypespecifiers, generic type parameters on callsaxios.get(`/users/${id}`)CancelTokenandAxiosErrornamed imports when used as runtime values (CancelToken.source(),instanceof AxiosError) even if defaultaxiosimport is removedconst api = createOtherClient()) from being incorrectly rewritten to generated endpoint classes3. Codemod tests (
website/static/codemods/__tests__/axios-to-rest.test.js) — expanded coverage for:CancelTokenandAxiosError)axios.create()(baseURL, headers, spreads, aliased, multiple, empty, exported)import type, inline type specifiers, generics,typeof axios).then(),awaitdestructuring,axios()direct call,axios.all, conditionals)4. Migration skill (
.cursor/skills/axios-to-rest-migration/SKILL.md)SkillTabsand skills.sh linkgetHeaders()/getRequestInit()/parseResponse()/process()NetworkErrorOpen questions
require('axios')(CJS) in addition to ESM imports?HooksPlaygroundexample showing the full flow from axios call touseSuspensehook?