feat(sdk): add OAuth /me endpoint types and update getUser() return type#13945
feat(sdk): add OAuth /me endpoint types and update getUser() return type#13945rickyrombo merged 6 commits intomainfrom
Conversation
The SDK package has "type": "module" in package.json, which causes Node to treat .js files as ESM. The generator script uses require() (CJS syntax), so rename it to gen.cjs to fix the runtime error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Regenerated SDK types from updated swagger spec that adds /oauth/me as a documented endpoint. This adds the new OauthApi class and updates other generated API files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The /oauth/me endpoint now returns a standard { data: User } response
(matching all other API endpoints) instead of a custom JWT-shaped object.
Update getUser() to parse the response with UserFromJSON and return the
full User profile instead of DecodedUserToken.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 608f817 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| "gen": "npm run gen:prod", | ||
| "gen:dev": "node ./src/sdk/api/generator/gen.js --env dev", | ||
| "gen:prod": "node ./src/sdk/api/generator/gen.js", | ||
| "gen:dev": "node ./src/sdk/api/generator/gen.cjs --env dev", |
There was a problem hiding this comment.
Pull request overview
This PR updates the SDK’s generated OpenAPI client and OAuth wrapper to support the /oauth/me “current user” endpoint, while also fixing the local type-generation script for ESM packages.
Changes:
- Renames the API generator entrypoint to
gen.cjsand updatespackages/sdkscripts to avoid ESM/require()incompatibility. - Regenerates OpenAPI types/clients, including a new
OauthApifor/oauth/meand additional auth header logic across many endpoints. - Updates
OAuth.getUser()to return the standardUsermodel parsed viaUserFromJSONfrom the new{ data: User }response shape.
Reviewed changes
Copilot reviewed 2 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/src/sdk/oauth/OAuth.ts | Changes getUser() to return User and parse { data: User } via UserFromJSON. |
| packages/sdk/src/sdk/api/generator/gen.cjs | Adds CommonJS generator script to work under "type": "module". |
| packages/sdk/src/sdk/api/generated/default/runtime.ts | Changes generated default BASE_PATH to "/v1". |
| packages/sdk/src/sdk/api/generated/default/apis/index.ts | Exports the newly generated OauthApi. |
| packages/sdk/src/sdk/api/generated/default/apis/OauthApi.ts | Adds generated API client for /oauth/me. |
| packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts | Regenerated; adds OAuth2 auth header blocks in many methods. |
| packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts | Regenerated; adds OAuth2 auth header blocks in many methods. |
| packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts | Regenerated; adds OAuth2 auth header blocks in many methods. |
| packages/sdk/src/sdk/api/generated/default/apis/SearchApi.ts | Regenerated; adds OAuth2 auth header blocks. |
| packages/sdk/src/sdk/api/generated/default/apis/TipsApi.ts | Regenerated; adds OAuth2 auth header blocks. |
| packages/sdk/src/sdk/api/generated/default/apis/ExploreApi.ts | Regenerated; adds OAuth2 auth header blocks. |
| packages/sdk/src/sdk/api/generated/default/apis/EventsApi.ts | Regenerated; adds OAuth2 auth header blocks. |
| packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts | Regenerated; adds OAuth2 auth header blocks. |
| packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts | Regenerated; adds OAuth2 auth header blocks in many methods. |
| packages/sdk/src/sdk/api/generated/default/apis/ChallengesApi.ts | Regenerated; adds OAuth2 auth header blocks. |
| packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES | Updates generator manifest to include OauthApi.ts. |
| packages/sdk/package.json | Updates gen:* scripts to execute gen.cjs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-13945.audius.workers.dev Unique preview for this PR (deployed from this branch). |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
gen.js→gen.cjsto fix ESM compatibility (package has"type": "module", so.jsfiles are treated as ESM but the script usesrequire())OauthApiclass for the/oauth/meendpointOAuth.getUser()to return the standardUsertype (parsed viaUserFromJSON) instead of the oldDecodedUserToken, matching the updated/oauth/meresponse shape ({ data: User })Test plan
npm run geninpackages/sdk— should succeed without ESM errorsOAuth.getUser()return type isPromise<User>🤖 Generated with Claude Code