Create SDK without services by default in all cases#13906
Conversation
🦋 Changeset detectedLatest commit: 767fb20 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
There was a problem hiding this comment.
Pull request overview
This PR updates the @audius/sdk public constructor behavior so that sdk() always creates the “without legacy services” SDK (consistent API surface across configs), while exposing createSdkWithServices() as an explicit opt-in for legacy/service-backed functionality. It also updates internal consumers to call createSdkWithServices() where legacy services are still required and adds Uploads API wiring and improved OAuth logger plumbing.
Changes:
- Make
sdkan alias of the newcreateSdk(service-less by default), and exportcreateSdk/createSdkWithServicesfrom the SDK entrypoint. - Update internal call sites (web, mobile, commands, discovery-provider plugins, scripts) to use
createSdkWithServices()where they still need legacy services. - Add/align
UploadsApiconstruction across service-less and service-backed SDKs; adjust Uploads API service config shape and pass logger to OAuth.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/web/src/test/mocks/audiusSdk.ts | Update test mock to instantiate SDK via createSdkWithServices() instead of sdk(). |
| packages/web/src/services/audius-sdk/audiusSdk.ts | Update web SDK initialization to call createSdkWithServices(). |
| packages/sdk/src/sdk/types.ts | Rename/privatize config schemas and define SdkConfigSchema union + SdkConfig type. |
| packages/sdk/src/sdk/sdk.ts | Replace overloaded sdk() implementation with sdk = createSdk alias. |
| packages/sdk/src/sdk/scripts/verifyUser.ts | Update script to construct SDK via createSdkWithServices(). |
| packages/sdk/src/sdk/scripts/manageRewardsLookupTable.ts | Update script to use createSdkWithServices() and adjust imports. |
| packages/sdk/src/sdk/index.ts | Export createSdk and createSdkWithServices from SDK entrypoint. |
| packages/sdk/src/sdk/createSdkWithServices.ts | Add schema parse, add Uploads API, and pass logger into OAuth. |
| packages/sdk/src/sdk/createSdk.ts | Rename service-less constructor to createSdk, add schema parse, bind resolve, wire Uploads API, and pass logger into OAuth. |
| packages/sdk/src/sdk/api/uploads/types.ts | Rename Uploads API services config prop from storageService to storage. |
| packages/sdk/src/sdk/api/uploads/UploadsApi.ts | Update Uploads API constructor to use services.storage. |
| packages/mobile/src/services/sdk/audius-sdk.ts | Update mobile SDK initialization to call createSdkWithServices(). |
| packages/discovery-provider/plugins/pedalboard/apps/trending-challenge-rewards/src/sdk.ts | Update plugin SDK initialization to call createSdkWithServices(). |
| packages/discovery-provider/plugins/pedalboard/apps/relay/src/index.ts | Update relay plugin SDK initialization to call createSdkWithServices(). |
| packages/commands/src/utils.ts | Update commands SDK initialization to call createSdkWithServices(). |
| .changeset/real-rabbits-pretend.md | Add major-version changeset describing the constructor behavior change and migration path. |
Comments suppressed due to low confidence (1)
packages/sdk/src/sdk/createSdk.ts:39
- This call to
SdkConfigSchema.parse(config)relies on the union schema for validation, but the union members are non-strict()objects, so configs that include extra auth fields can pass validation via the wrong branch (e.g. bearerToken present but empty). To avoid accepting partially-specified write-auth configs, consider tighteningSdkConfigSchema(e.g. strict/discriminated union) or re-validating based on the presence ofbearerToken/apiSecretlike the previous constructor did.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-13906.audius.workers.dev Unique preview for this PR (deployed from this branch). |
See changeset.
Motivation is to make the SDK types the same regardless of which config you pass in, and use the API endpoints by default.
To keep the existing "services" version of SDK, call
createSdkWithServicesexplicitly. This is not recommended - writes and other services won't work without tedious and proper integration with the user's wallet.Also:
UploadsApito services SDKstorageServicetostorageinUploadsApiconfig