Skip to content

feat(sdk): add OAuth /me endpoint types and update getUser() return type#13945

Merged
rickyrombo merged 6 commits intomainfrom
mjp-sdk-oauth
Mar 18, 2026
Merged

feat(sdk): add OAuth /me endpoint types and update getUser() return type#13945
rickyrombo merged 6 commits intomainfrom
mjp-sdk-oauth

Conversation

@rickyrombo
Copy link
Contributor

@rickyrombo rickyrombo commented Mar 17, 2026

Summary

  • Renames gen.jsgen.cjs to fix ESM compatibility (package has "type": "module", so .js files are treated as ESM but the script uses require())
  • Regenerates SDK API types from updated swagger spec — adds new OauthApi class for the /oauth/me endpoint
  • Updates OAuth.getUser() to return the standard User type (parsed via UserFromJSON) instead of the old DecodedUserToken, matching the updated /oauth/me response shape ({ data: User })

Test plan

  • Run npm run gen in packages/sdk — should succeed without ESM errors
  • Verify OAuth.getUser() return type is Promise<User>
  • Confirm existing OAuth login flow works end-to-end

🤖 Generated with Claude Code

rickyrombo and others added 3 commits March 17, 2026 13:43
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-bot
Copy link

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: 608f817

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@audius/sdk Minor
@audius/sdk-legacy Patch
@audius/protocol-dashboard Patch
@audius/sp-actions Patch

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yuk

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cjs and updates packages/sdk scripts to avoid ESM/require() incompatibility.
  • Regenerates OpenAPI types/clients, including a new OauthApi for /oauth/me and additional auth header logic across many endpoints.
  • Updates OAuth.getUser() to return the standard User model parsed via UserFromJSON from 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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-13945.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

rickyrombo and others added 2 commits March 17, 2026 13:59
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rickyrombo rickyrombo merged commit f79f7df into main Mar 18, 2026
9 checks passed
@rickyrombo rickyrombo deleted the mjp-sdk-oauth branch March 18, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants