From 39133cbeab379462d3acf61e590d170acda66ff2 Mon Sep 17 00:00:00 2001 From: Marcus Pasell <3690498+rickyrombo@users.noreply.github.com> Date: Thu, 12 Feb 2026 16:31:38 -0800 Subject: [PATCH 1/9] generate --- .../default/.openapi-generator/FILES | 36 +- .../api/generated/default/apis/CoinsApi.ts | 40 +- .../api/generated/default/apis/CommentsApi.ts | 463 +++++++++++ .../default/apis/DeveloperAppsApi.ts | 478 ++++++++++- .../generated/default/apis/PlaylistsApi.ts | 463 +++++++++++ .../api/generated/default/apis/PrizesApi.ts | 14 +- .../api/generated/default/apis/RewardsApi.ts | 40 +- .../api/generated/default/apis/TracksApi.ts | 507 ++++++++++++ .../api/generated/default/apis/UsersApi.ts | 773 +++++++++++++++++- ...sRequest.ts => ClaimRewardsRequestBody.ts} | 22 +- .../default/models/CreateAccessKeyResponse.ts | 67 ++ ...oinRequest.ts => CreateCoinRequestBody.ts} | 38 +- .../models/CreateCommentRequestBody.ts | 101 +++ .../default/models/CreateCommentResponse.ts | 82 ++ .../models/CreateDeveloperAppRequestBody.ts | 101 +++ ...eateDeveloperAppRequestBodyAppSignature.ts | 76 ++ .../models/CreatePlaylistRequestBody.ts | 206 +++++ .../default/models/CreatePlaylistResponse.ts | 82 ++ ...uest.ts => CreateRewardCodeRequestBody.ts} | 22 +- .../default/models/CreateTrackRequestBody.ts | 226 +++++ .../default/models/CreateTrackResponse.ts | 82 ++ .../CreateUserDeveloperAppRequestBody.ts | 67 ++ .../models/CreateUserDeveloperAppResponse.ts | 82 ++ .../default/models/CreateUserRequestBody.ts | 214 +++++ .../default/models/CreateUserResponse.ts | 82 ++ .../models/DeactivateAccessKeyRequestBody.ts | 67 ++ .../models/DeactivateAccessKeyResponse.ts | 66 ++ ...eloperApps.ts => DeveloperAppsResponse.ts} | 18 +- .../sdk/api/generated/default/models/Genre.ts | 88 ++ .../sdk/api/generated/default/models/Mood.ts | 60 ++ .../default/models/PlaylistAddedTimestamp.ts | 25 +- ...aimRequest.ts => PrizeClaimRequestBody.ts} | 20 +- .../models/TrackDownloadRequestBody.ts | 82 ++ ...oinRequest.ts => UpdateCoinRequestBody.ts} | 28 +- .../models/UpdateCommentRequestBody.ts | 67 ++ .../models/UpdateDeveloperAppRequestBody.ts | 85 ++ .../models/UpdatePlaylistRequestBody.ts | 113 +++ .../default/models/UpdateTrackRequestBody.ts | 151 ++++ .../default/models/UpdateUserRequestBody.ts | 212 +++++ .../generated/default/models/WriteResponse.ts | 74 ++ .../sdk/api/generated/default/models/index.ts | 36 +- 41 files changed, 5366 insertions(+), 190 deletions(-) rename packages/sdk/src/sdk/api/generated/default/models/{ClaimRewardsRequest.ts => ClaimRewardsRequestBody.ts} (65%) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateAccessKeyResponse.ts rename packages/sdk/src/sdk/api/generated/default/models/{CreateCoinRequest.ts => CreateCoinRequestBody.ts} (75%) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateCommentResponse.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBodyAppSignature.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistResponse.ts rename packages/sdk/src/sdk/api/generated/default/models/{CreateRewardCodeRequest.ts => CreateRewardCodeRequestBody.ts} (67%) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateTrackResponse.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppResponse.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserResponse.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyResponse.ts rename packages/sdk/src/sdk/api/generated/default/models/{DeveloperApps.ts => DeveloperAppsResponse.ts} (64%) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/Genre.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/Mood.ts rename packages/sdk/src/sdk/api/generated/default/models/{PrizeClaimRequest.ts => PrizeClaimRequestBody.ts} (64%) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/TrackDownloadRequestBody.ts rename packages/sdk/src/sdk/api/generated/default/models/{UpdateCoinRequest.ts => UpdateCoinRequestBody.ts} (71%) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/UpdateDeveloperAppRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/WriteResponse.ts diff --git a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES index aa6d267c67e..eda9d92bfb9 100644 --- a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES +++ b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES @@ -30,7 +30,7 @@ models/BestSellingItem.ts models/BestSellingResponse.ts models/BlobInfo.ts models/ChallengeResponse.ts -models/ClaimRewardsRequest.ts +models/ClaimRewardsRequestBody.ts models/ClaimRewardsResponse.ts models/ClaimRewardsResponseDataInner.ts models/ClaimedPrize.ts @@ -61,17 +61,32 @@ models/CommentResponse.ts models/ConnectedWallets.ts models/ConnectedWalletsResponse.ts models/CoverPhoto.ts -models/CreateCoinRequest.ts +models/CreateAccessKeyResponse.ts +models/CreateCoinRequestBody.ts models/CreateCoinResponse.ts models/CreateCoinResponseData.ts -models/CreateRewardCodeRequest.ts +models/CreateCommentRequestBody.ts +models/CreateCommentResponse.ts +models/CreateDeveloperAppRequestBody.ts +models/CreateDeveloperAppRequestBodyAppSignature.ts +models/CreatePlaylistRequestBody.ts +models/CreatePlaylistResponse.ts +models/CreateRewardCodeRequestBody.ts models/CreateRewardCodeResponse.ts +models/CreateTrackRequestBody.ts +models/CreateTrackResponse.ts +models/CreateUserDeveloperAppRequestBody.ts +models/CreateUserDeveloperAppResponse.ts +models/CreateUserRequestBody.ts +models/CreateUserResponse.ts models/DashboardWalletUser.ts models/DashboardWalletUsersResponse.ts +models/DeactivateAccessKeyRequestBody.ts +models/DeactivateAccessKeyResponse.ts models/DecodedUserToken.ts models/DeveloperApp.ts models/DeveloperAppResponse.ts -models/DeveloperApps.ts +models/DeveloperAppsResponse.ts models/EmailAccess.ts models/EmailAccessResponse.ts models/Event.ts @@ -86,6 +101,7 @@ models/FavoritesResponse.ts models/FollowGate.ts models/FollowersResponse.ts models/FollowingResponse.ts +models/Genre.ts models/GetChallenges.ts models/GetSupportedUsers.ts models/GetSupporters.ts @@ -94,6 +110,7 @@ models/HistoryResponse.ts models/ListenCount.ts models/MediaLink.ts models/MonthlyAggregatePlay.ts +models/Mood.ts models/MutualFollowersResponse.ts models/NftCollection.ts models/NftGate.ts @@ -104,7 +121,7 @@ models/PlaylistResponse.ts models/PlaylistSearchResult.ts models/PlaylistTracksResponse.ts models/PlaylistsResponse.ts -models/PrizeClaimRequest.ts +models/PrizeClaimRequestBody.ts models/PrizeClaimResponse.ts models/PrizePublic.ts models/PrizesResponse.ts @@ -145,6 +162,7 @@ models/TrackArtwork.ts models/TrackCommentCountResponse.ts models/TrackCommentNotificationResponse.ts models/TrackCommentsResponse.ts +models/TrackDownloadRequestBody.ts models/TrackElement.ts models/TrackFavoritesResponse.ts models/TrackId.ts @@ -161,8 +179,13 @@ models/TrendingTimesIds.ts models/UnclaimedIdResponse.ts models/UndisbursedChallenge.ts models/UndisbursedChallenges.ts -models/UpdateCoinRequest.ts +models/UpdateCoinRequestBody.ts models/UpdateCoinResponse.ts +models/UpdateCommentRequestBody.ts +models/UpdateDeveloperAppRequestBody.ts +models/UpdatePlaylistRequestBody.ts +models/UpdateTrackRequestBody.ts +models/UpdateUserRequestBody.ts models/User.ts models/UserCoin.ts models/UserCoinAccount.ts @@ -178,5 +201,6 @@ models/UserTrackListenCountsResponse.ts models/UserTracksRemixedResponse.ts models/UsersResponse.ts models/VerifyToken.ts +models/WriteResponse.ts models/index.ts runtime.ts diff --git a/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts index af966b2c1cd..bd4aaaaa871 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts @@ -23,12 +23,12 @@ import type { CoinResponse, CoinsResponse, CoinsVolumeLeadersResponse, - CreateCoinRequest, + CreateCoinRequestBody, CreateCoinResponse, RedeemAmountResponse, RewardCodeErrorResponse, RewardCodeResponse, - UpdateCoinRequest, + UpdateCoinRequestBody, UpdateCoinResponse, } from '../models'; import { @@ -46,8 +46,8 @@ import { CoinsResponseToJSON, CoinsVolumeLeadersResponseFromJSON, CoinsVolumeLeadersResponseToJSON, - CreateCoinRequestFromJSON, - CreateCoinRequestToJSON, + CreateCoinRequestBodyFromJSON, + CreateCoinRequestBodyToJSON, CreateCoinResponseFromJSON, CreateCoinResponseToJSON, RedeemAmountResponseFromJSON, @@ -56,8 +56,8 @@ import { RewardCodeErrorResponseToJSON, RewardCodeResponseFromJSON, RewardCodeResponseToJSON, - UpdateCoinRequestFromJSON, - UpdateCoinRequestToJSON, + UpdateCoinRequestBodyFromJSON, + UpdateCoinRequestBodyToJSON, UpdateCoinResponseFromJSON, UpdateCoinResponseToJSON, } from '../models'; @@ -73,9 +73,9 @@ export interface ClaimCoinRewardCodeRequest { userId: string; } -export interface CreateCoinOperationRequest { +export interface CreateCoinRequest { userId: string; - createCoinRequest: CreateCoinRequest; + createCoinRequestBody: CreateCoinRequestBody; } export interface GetCoinRequest { @@ -128,10 +128,10 @@ export interface GetVolumeLeadersRequest { limit?: number; } -export interface UpdateCoinOperationRequest { +export interface UpdateCoinRequest { mint: string; userId: string; - updateCoinRequest: UpdateCoinRequest; + updateCoinRequestBody: UpdateCoinRequestBody; } /** @@ -225,13 +225,13 @@ export class CoinsApi extends runtime.BaseAPI { * @hidden * Creates a new artist coin */ - async createCoinRaw(params: CreateCoinOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async createCoinRaw(params: CreateCoinRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createCoin.'); } - if (params.createCoinRequest === null || params.createCoinRequest === undefined) { - throw new runtime.RequiredError('createCoinRequest','Required parameter params.createCoinRequest was null or undefined when calling createCoin.'); + if (params.createCoinRequestBody === null || params.createCoinRequestBody === undefined) { + throw new runtime.RequiredError('createCoinRequestBody','Required parameter params.createCoinRequestBody was null or undefined when calling createCoin.'); } const queryParameters: any = {}; @@ -249,7 +249,7 @@ export class CoinsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateCoinRequestToJSON(params.createCoinRequest), + body: CreateCoinRequestBodyToJSON(params.createCoinRequestBody), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateCoinResponseFromJSON(jsonValue)); @@ -258,7 +258,7 @@ export class CoinsApi extends runtime.BaseAPI { /** * Creates a new artist coin */ - async createCoin(params: CreateCoinOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async createCoin(params: CreateCoinRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createCoinRaw(params, initOverrides); return await response.value(); } @@ -602,7 +602,7 @@ export class CoinsApi extends runtime.BaseAPI { * @hidden * Updates information about a specific coin by its mint address */ - async updateCoinRaw(params: UpdateCoinOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async updateCoinRaw(params: UpdateCoinRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.mint === null || params.mint === undefined) { throw new runtime.RequiredError('mint','Required parameter params.mint was null or undefined when calling updateCoin.'); } @@ -611,8 +611,8 @@ export class CoinsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateCoin.'); } - if (params.updateCoinRequest === null || params.updateCoinRequest === undefined) { - throw new runtime.RequiredError('updateCoinRequest','Required parameter params.updateCoinRequest was null or undefined when calling updateCoin.'); + if (params.updateCoinRequestBody === null || params.updateCoinRequestBody === undefined) { + throw new runtime.RequiredError('updateCoinRequestBody','Required parameter params.updateCoinRequestBody was null or undefined when calling updateCoin.'); } const queryParameters: any = {}; @@ -630,7 +630,7 @@ export class CoinsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UpdateCoinRequestToJSON(params.updateCoinRequest), + body: UpdateCoinRequestBodyToJSON(params.updateCoinRequestBody), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UpdateCoinResponseFromJSON(jsonValue)); @@ -639,7 +639,7 @@ export class CoinsApi extends runtime.BaseAPI { /** * Updates information about a specific coin by its mint address */ - async updateCoin(params: UpdateCoinOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async updateCoin(params: UpdateCoinRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.updateCoinRaw(params, initOverrides); return await response.value(); } diff --git a/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts index 1bf63a31e2d..fcea8fc85c8 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts @@ -18,17 +18,39 @@ import * as runtime from '../runtime'; import type { CommentRepliesResponse, CommentResponse, + CreateCommentRequestBody, + CreateCommentResponse, UnclaimedIdResponse, + UpdateCommentRequestBody, + WriteResponse, } from '../models'; import { CommentRepliesResponseFromJSON, CommentRepliesResponseToJSON, CommentResponseFromJSON, CommentResponseToJSON, + CreateCommentRequestBodyFromJSON, + CreateCommentRequestBodyToJSON, + CreateCommentResponseFromJSON, + CreateCommentResponseToJSON, UnclaimedIdResponseFromJSON, UnclaimedIdResponseToJSON, + UpdateCommentRequestBodyFromJSON, + UpdateCommentRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreateCommentRequest { + userId: string; + createCommentRequestBody: CreateCommentRequestBody; +} + +export interface DeleteCommentRequest { + commentId: string; + userId: string; +} + export interface GetCommentRequest { commentId: string; } @@ -40,11 +62,145 @@ export interface GetCommentRepliesRequest { userId?: string; } +export interface PinCommentRequest { + commentId: string; + userId: string; +} + +export interface ReactToCommentRequest { + commentId: string; + userId: string; +} + +export interface ReportCommentRequest { + commentId: string; + userId: string; +} + +export interface UnpinCommentRequest { + commentId: string; + userId: string; +} + +export interface UnreactToCommentRequest { + commentId: string; + userId: string; +} + +export interface UpdateCommentRequest { + commentId: string; + userId: string; + updateCommentRequestBody: UpdateCommentRequestBody; +} + /** * */ export class CommentsApi extends runtime.BaseAPI { + /** + * @hidden + * Creates a new comment + */ + async createCommentRaw(params: CreateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createComment.'); + } + + if (params.createCommentRequestBody === null || params.createCommentRequestBody === undefined) { + throw new runtime.RequiredError('createCommentRequestBody','Required parameter params.createCommentRequestBody was null or undefined when calling createComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateCommentRequestBodyToJSON(params.createCommentRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateCommentResponseFromJSON(jsonValue)); + } + + /** + * Creates a new comment + */ + async createComment(params: CreateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createCommentRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deletes a comment + */ + async deleteCommentRaw(params: DeleteCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.commentId === null || params.commentId === undefined) { + throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling deleteComment.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling deleteComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments/{comment_id}`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Deletes a comment + */ + async deleteComment(params: DeleteCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deleteCommentRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Gets a comment by ID @@ -146,4 +302,311 @@ export class CommentsApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Pin a comment + */ + async pinCommentRaw(params: PinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.commentId === null || params.commentId === undefined) { + throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling pinComment.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling pinComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments/{comment_id}/pin`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Pin a comment + */ + async pinComment(params: PinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.pinCommentRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * React to a comment + */ + async reactToCommentRaw(params: ReactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.commentId === null || params.commentId === undefined) { + throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling reactToComment.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling reactToComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments/{comment_id}/react`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * React to a comment + */ + async reactToComment(params: ReactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.reactToCommentRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Report a comment + */ + async reportCommentRaw(params: ReportCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.commentId === null || params.commentId === undefined) { + throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling reportComment.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling reportComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments/{comment_id}/report`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Report a comment + */ + async reportComment(params: ReportCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.reportCommentRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unpin a comment + */ + async unpinCommentRaw(params: UnpinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.commentId === null || params.commentId === undefined) { + throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling unpinComment.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unpinComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments/{comment_id}/pin`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unpin a comment + */ + async unpinComment(params: UnpinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unpinCommentRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unreact to a comment + */ + async unreactToCommentRaw(params: UnreactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.commentId === null || params.commentId === undefined) { + throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling unreactToComment.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unreactToComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments/{comment_id}/react`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unreact to a comment + */ + async unreactToComment(params: UnreactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unreactToCommentRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Updates a comment + */ + async updateCommentRaw(params: UpdateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.commentId === null || params.commentId === undefined) { + throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling updateComment.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateComment.'); + } + + if (params.updateCommentRequestBody === null || params.updateCommentRequestBody === undefined) { + throw new runtime.RequiredError('updateCommentRequestBody','Required parameter params.updateCommentRequestBody was null or undefined when calling updateComment.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/comments/{comment_id}`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: UpdateCommentRequestBodyToJSON(params.updateCommentRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Updates a comment + */ + async updateComment(params: UpdateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.updateCommentRaw(params, initOverrides); + return await response.value(); + } + } diff --git a/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts index 30a0d4bae89..82197905aab 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts @@ -16,29 +16,395 @@ import * as runtime from '../runtime'; import type { + CreateAccessKeyResponse, + CreateDeveloperAppRequestBody, + CreateUserDeveloperAppRequestBody, + CreateUserDeveloperAppResponse, + DeactivateAccessKeyRequestBody, + DeactivateAccessKeyResponse, DeveloperAppResponse, + DeveloperAppsResponse, + UpdateDeveloperAppRequestBody, + WriteResponse, } from '../models'; import { + CreateAccessKeyResponseFromJSON, + CreateAccessKeyResponseToJSON, + CreateDeveloperAppRequestBodyFromJSON, + CreateDeveloperAppRequestBodyToJSON, + CreateUserDeveloperAppRequestBodyFromJSON, + CreateUserDeveloperAppRequestBodyToJSON, + CreateUserDeveloperAppResponseFromJSON, + CreateUserDeveloperAppResponseToJSON, + DeactivateAccessKeyRequestBodyFromJSON, + DeactivateAccessKeyRequestBodyToJSON, + DeactivateAccessKeyResponseFromJSON, + DeactivateAccessKeyResponseToJSON, DeveloperAppResponseFromJSON, DeveloperAppResponseToJSON, + DeveloperAppsResponseFromJSON, + DeveloperAppsResponseToJSON, + UpdateDeveloperAppRequestBodyFromJSON, + UpdateDeveloperAppRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; -export interface GetDeveloperAppRequest { +export interface CreateDeveloperAppRequest { + userId: string; + createDeveloperAppRequestBody: CreateDeveloperAppRequestBody; +} + +export interface CreateUserDeveloperAppRequest { + id: string; + createUserDeveloperAppRequestBody: CreateUserDeveloperAppRequestBody; +} + +export interface CreateUserDeveloperAppAccessKeyRequest { + id: string; + address: string; +} + +export interface DeactivateUserDeveloperAppAccessKeyRequest { + id: string; + address: string; + deactivateAccessKeyRequestBody: DeactivateAccessKeyRequestBody; +} + +export interface DeleteDeveloperAppRequest { + address: string; + userId: string; +} + +export interface DeleteUserDeveloperAppRequest { + id: string; + address: string; +} + +export interface GetDeveloperAppByAPIKeyRequest { address: string; } +export interface GetUserDeveloperAppsRequest { + id: string; + include?: GetUserDeveloperAppsIncludeEnum; +} + +export interface UpdateDeveloperAppRequest { + address: string; + userId: string; + updateDeveloperAppRequestBody: UpdateDeveloperAppRequestBody; +} + /** * */ export class DeveloperAppsApi extends runtime.BaseAPI { + /** + * @hidden + * Creates a new developer app + */ + async createDeveloperAppRaw(params: CreateDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createDeveloperApp.'); + } + + if (params.createDeveloperAppRequestBody === null || params.createDeveloperAppRequestBody === undefined) { + throw new runtime.RequiredError('createDeveloperAppRequestBody','Required parameter params.createDeveloperAppRequestBody was null or undefined when calling createDeveloperApp.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/developer-apps`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateDeveloperAppRequestBodyToJSON(params.createDeveloperAppRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Creates a new developer app + */ + async createDeveloperApp(params: CreateDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Create a new developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperAppRaw(params: CreateUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling createUserDeveloperApp.'); + } + + if (params.createUserDeveloperAppRequestBody === null || params.createUserDeveloperAppRequestBody === undefined) { + throw new runtime.RequiredError('createUserDeveloperAppRequestBody','Required parameter params.createUserDeveloperAppRequestBody was null or undefined when calling createUserDeveloperApp.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateUserDeveloperAppRequestBodyToJSON(params.createUserDeveloperAppRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateUserDeveloperAppResponseFromJSON(jsonValue)); + } + + /** + * Create a new developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperApp(params: CreateUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createUserDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Create a new bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperAppAccessKeyRaw(params: CreateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling createUserDeveloperAppAccessKey.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling createUserDeveloperAppAccessKey.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps/{address}/access-keys`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateAccessKeyResponseFromJSON(jsonValue)); + } + + /** + * Create a new bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperAppAccessKey(params: CreateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createUserDeveloperAppAccessKeyRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deactivate a bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. The deactivated token will no longer authenticate requests. + */ + async deactivateUserDeveloperAppAccessKeyRaw(params: DeactivateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); + } + + if (params.deactivateAccessKeyRequestBody === null || params.deactivateAccessKeyRequestBody === undefined) { + throw new runtime.RequiredError('deactivateAccessKeyRequestBody','Required parameter params.deactivateAccessKeyRequestBody was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps/{address}/access-keys/deactivate`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: DeactivateAccessKeyRequestBodyToJSON(params.deactivateAccessKeyRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => DeactivateAccessKeyResponseFromJSON(jsonValue)); + } + + /** + * Deactivate a bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. The deactivated token will no longer authenticate requests. + */ + async deactivateUserDeveloperAppAccessKey(params: DeactivateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deactivateUserDeveloperAppAccessKeyRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deletes a developer app + */ + async deleteDeveloperAppRaw(params: DeleteDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deleteDeveloperApp.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling deleteDeveloperApp.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/developer-apps/{address}`.replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Deletes a developer app + */ + async deleteDeveloperApp(params: DeleteDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deleteDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Delete a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async deleteUserDeveloperAppRaw(params: DeleteUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling deleteUserDeveloperApp.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deleteUserDeveloperApp.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps/{address}`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Delete a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async deleteUserDeveloperApp(params: DeleteUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deleteUserDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Gets developer app matching given address (API key) */ - async getDeveloperAppRaw(params: GetDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async getDeveloperAppByAPIKeyRaw(params: GetDeveloperAppByAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.address === null || params.address === undefined) { - throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling getDeveloperApp.'); + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling getDeveloperAppByAPIKey.'); } const queryParameters: any = {}; @@ -46,7 +412,7 @@ export class DeveloperAppsApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/developer_apps/{address}`.replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + path: `/developer-apps/{address}`.replace(`{${"address"}}`, encodeURIComponent(String(params.address))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -58,9 +424,109 @@ export class DeveloperAppsApi extends runtime.BaseAPI { /** * Gets developer app matching given address (API key) */ - async getDeveloperApp(params: GetDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getDeveloperAppRaw(params, initOverrides); + async getDeveloperAppByAPIKey(params: GetDeveloperAppByAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getDeveloperAppByAPIKeyRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Get developer apps for the user (Plans API). Requires OAuth. + */ + async getUserDeveloperAppsRaw(params: GetUserDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling getUserDeveloperApps.'); + } + + const queryParameters: any = {}; + + if (params.include !== undefined) { + queryParameters['include'] = params.include; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/users/{id}/developer-apps`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => DeveloperAppsResponseFromJSON(jsonValue)); + } + + /** + * Get developer apps for the user (Plans API). Requires OAuth. + */ + async getUserDeveloperApps(params: GetUserDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUserDeveloperAppsRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Updates an existing developer app + */ + async updateDeveloperAppRaw(params: UpdateDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling updateDeveloperApp.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateDeveloperApp.'); + } + + if (params.updateDeveloperAppRequestBody === null || params.updateDeveloperAppRequestBody === undefined) { + throw new runtime.RequiredError('updateDeveloperAppRequestBody','Required parameter params.updateDeveloperAppRequestBody was null or undefined when calling updateDeveloperApp.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/developer-apps/{address}`.replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: UpdateDeveloperAppRequestBodyToJSON(params.updateDeveloperAppRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Updates an existing developer app + */ + async updateDeveloperApp(params: UpdateDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.updateDeveloperAppRaw(params, initOverrides); return await response.value(); } } + +/** + * @export + */ +export const GetUserDeveloperAppsIncludeEnum = { + Metrics: 'metrics' +} as const; +export type GetUserDeveloperAppsIncludeEnum = typeof GetUserDeveloperAppsIncludeEnum[keyof typeof GetUserDeveloperAppsIncludeEnum]; diff --git a/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts index cb10590b0a6..b829d47a5c8 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts @@ -17,14 +17,22 @@ import * as runtime from '../runtime'; import type { AccessInfoResponse, + CreatePlaylistRequestBody, + CreatePlaylistResponse, PlaylistResponse, PlaylistSearchResult, PlaylistTracksResponse, TrendingPlaylistsResponse, + UpdatePlaylistRequestBody, + WriteResponse, } from '../models'; import { AccessInfoResponseFromJSON, AccessInfoResponseToJSON, + CreatePlaylistRequestBodyFromJSON, + CreatePlaylistRequestBodyToJSON, + CreatePlaylistResponseFromJSON, + CreatePlaylistResponseToJSON, PlaylistResponseFromJSON, PlaylistResponseToJSON, PlaylistSearchResultFromJSON, @@ -33,8 +41,27 @@ import { PlaylistTracksResponseToJSON, TrendingPlaylistsResponseFromJSON, TrendingPlaylistsResponseToJSON, + UpdatePlaylistRequestBodyFromJSON, + UpdatePlaylistRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreatePlaylistRequest { + userId: string; + createPlaylistRequestBody: CreatePlaylistRequestBody; +} + +export interface DeletePlaylistRequest { + playlistId: string; + userId: string; +} + +export interface FavoritePlaylistRequest { + playlistId: string; + userId: string; +} + export interface GetBulkPlaylistsRequest { userId?: string; id?: Array; @@ -70,6 +97,11 @@ export interface GetTrendingPlaylistsRequest { omitTracks?: boolean; } +export interface RepostPlaylistRequest { + playlistId: string; + userId: string; +} + export interface SearchPlaylistsRequest { offset?: number; limit?: number; @@ -81,11 +113,185 @@ export interface SearchPlaylistsRequest { hasDownloads?: string; } +export interface SharePlaylistRequest { + playlistId: string; + userId: string; +} + +export interface UnfavoritePlaylistRequest { + playlistId: string; + userId: string; +} + +export interface UnrepostPlaylistRequest { + playlistId: string; + userId: string; +} + +export interface UpdatePlaylistRequest { + playlistId: string; + userId: string; + updatePlaylistRequestBody: UpdatePlaylistRequestBody; +} + /** * */ export class PlaylistsApi extends runtime.BaseAPI { + /** + * @hidden + * Creates a new playlist or album + */ + async createPlaylistRaw(params: CreatePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createPlaylist.'); + } + + if (params.createPlaylistRequestBody === null || params.createPlaylistRequestBody === undefined) { + throw new runtime.RequiredError('createPlaylistRequestBody','Required parameter params.createPlaylistRequestBody was null or undefined when calling createPlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreatePlaylistRequestBodyToJSON(params.createPlaylistRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreatePlaylistResponseFromJSON(jsonValue)); + } + + /** + * Creates a new playlist or album + */ + async createPlaylist(params: CreatePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createPlaylistRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deletes a playlist or album + */ + async deletePlaylistRaw(params: DeletePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.playlistId === null || params.playlistId === undefined) { + throw new runtime.RequiredError('playlistId','Required parameter params.playlistId was null or undefined when calling deletePlaylist.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling deletePlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists/{playlist_id}`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Deletes a playlist or album + */ + async deletePlaylist(params: DeletePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deletePlaylistRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Favorite a playlist + */ + async favoritePlaylistRaw(params: FavoritePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.playlistId === null || params.playlistId === undefined) { + throw new runtime.RequiredError('playlistId','Required parameter params.playlistId was null or undefined when calling favoritePlaylist.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling favoritePlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists/{playlist_id}/favorites`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Favorite a playlist + */ + async favoritePlaylist(params: FavoritePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.favoritePlaylistRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Gets a list of playlists by ID @@ -316,6 +522,56 @@ export class PlaylistsApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Repost a playlist + */ + async repostPlaylistRaw(params: RepostPlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.playlistId === null || params.playlistId === undefined) { + throw new runtime.RequiredError('playlistId','Required parameter params.playlistId was null or undefined when calling repostPlaylist.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling repostPlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists/{playlist_id}/reposts`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Repost a playlist + */ + async repostPlaylist(params: RepostPlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.repostPlaylistRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Search for a playlist @@ -375,6 +631,213 @@ export class PlaylistsApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Record a playlist share event + */ + async sharePlaylistRaw(params: SharePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.playlistId === null || params.playlistId === undefined) { + throw new runtime.RequiredError('playlistId','Required parameter params.playlistId was null or undefined when calling sharePlaylist.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling sharePlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists/{playlist_id}/shares`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Record a playlist share event + */ + async sharePlaylist(params: SharePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.sharePlaylistRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unfavorite a playlist + */ + async unfavoritePlaylistRaw(params: UnfavoritePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.playlistId === null || params.playlistId === undefined) { + throw new runtime.RequiredError('playlistId','Required parameter params.playlistId was null or undefined when calling unfavoritePlaylist.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unfavoritePlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists/{playlist_id}/favorites`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unfavorite a playlist + */ + async unfavoritePlaylist(params: UnfavoritePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unfavoritePlaylistRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unrepost a playlist + */ + async unrepostPlaylistRaw(params: UnrepostPlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.playlistId === null || params.playlistId === undefined) { + throw new runtime.RequiredError('playlistId','Required parameter params.playlistId was null or undefined when calling unrepostPlaylist.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unrepostPlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists/{playlist_id}/reposts`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unrepost a playlist + */ + async unrepostPlaylist(params: UnrepostPlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unrepostPlaylistRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Updates an existing playlist or album + */ + async updatePlaylistRaw(params: UpdatePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.playlistId === null || params.playlistId === undefined) { + throw new runtime.RequiredError('playlistId','Required parameter params.playlistId was null or undefined when calling updatePlaylist.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updatePlaylist.'); + } + + if (params.updatePlaylistRequestBody === null || params.updatePlaylistRequestBody === undefined) { + throw new runtime.RequiredError('updatePlaylistRequestBody','Required parameter params.updatePlaylistRequestBody was null or undefined when calling updatePlaylist.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/playlists/{playlist_id}`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: UpdatePlaylistRequestBodyToJSON(params.updatePlaylistRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Updates an existing playlist or album + */ + async updatePlaylist(params: UpdatePlaylistRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.updatePlaylistRaw(params, initOverrides); + return await response.value(); + } + } /** diff --git a/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts index d547104adef..63adba00ddf 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts @@ -17,15 +17,15 @@ import * as runtime from '../runtime'; import type { ClaimedPrizesResponse, - PrizeClaimRequest, + PrizeClaimRequestBody, PrizeClaimResponse, PrizesResponse, } from '../models'; import { ClaimedPrizesResponseFromJSON, ClaimedPrizesResponseToJSON, - PrizeClaimRequestFromJSON, - PrizeClaimRequestToJSON, + PrizeClaimRequestBodyFromJSON, + PrizeClaimRequestBodyToJSON, PrizeClaimResponseFromJSON, PrizeClaimResponseToJSON, PrizesResponseFromJSON, @@ -33,7 +33,7 @@ import { } from '../models'; export interface ClaimPrizeRequest { - prizeClaimRequest: PrizeClaimRequest; + prizeClaimRequestBody: PrizeClaimRequestBody; } export interface GetWalletPrizesRequest { @@ -50,8 +50,8 @@ export class PrizesApi extends runtime.BaseAPI { * Claims a prize by verifying a Solana transaction. User must send exactly 2 YAK to the prize receiver address. Returns the prize won and any redeem codes/URLs. */ async claimPrizeRaw(params: ClaimPrizeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.prizeClaimRequest === null || params.prizeClaimRequest === undefined) { - throw new runtime.RequiredError('prizeClaimRequest','Required parameter params.prizeClaimRequest was null or undefined when calling claimPrize.'); + if (params.prizeClaimRequestBody === null || params.prizeClaimRequestBody === undefined) { + throw new runtime.RequiredError('prizeClaimRequestBody','Required parameter params.prizeClaimRequestBody was null or undefined when calling claimPrize.'); } const queryParameters: any = {}; @@ -65,7 +65,7 @@ export class PrizesApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PrizeClaimRequestToJSON(params.prizeClaimRequest), + body: PrizeClaimRequestBodyToJSON(params.prizeClaimRequestBody), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PrizeClaimResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts index 000d31d8cfa..924e071f611 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts @@ -16,28 +16,28 @@ import * as runtime from '../runtime'; import type { - ClaimRewardsRequest, + ClaimRewardsRequestBody, ClaimRewardsResponse, - CreateRewardCodeRequest, + CreateRewardCodeRequestBody, CreateRewardCodeResponse, } from '../models'; import { - ClaimRewardsRequestFromJSON, - ClaimRewardsRequestToJSON, + ClaimRewardsRequestBodyFromJSON, + ClaimRewardsRequestBodyToJSON, ClaimRewardsResponseFromJSON, ClaimRewardsResponseToJSON, - CreateRewardCodeRequestFromJSON, - CreateRewardCodeRequestToJSON, + CreateRewardCodeRequestBodyFromJSON, + CreateRewardCodeRequestBodyToJSON, CreateRewardCodeResponseFromJSON, CreateRewardCodeResponseToJSON, } from '../models'; -export interface ClaimRewardsOperationRequest { - claimRewardsRequest: ClaimRewardsRequest; +export interface ClaimRewardsRequest { + claimRewardsRequestBody: ClaimRewardsRequestBody; } -export interface CreateRewardCodeOperationRequest { - createRewardCodeRequest: CreateRewardCodeRequest; +export interface CreateRewardCodeRequest { + createRewardCodeRequestBody: CreateRewardCodeRequestBody; } /** @@ -49,9 +49,9 @@ export class RewardsApi extends runtime.BaseAPI { * @hidden * Claims all the filtered undisbursed rewards for a user */ - async claimRewardsRaw(params: ClaimRewardsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.claimRewardsRequest === null || params.claimRewardsRequest === undefined) { - throw new runtime.RequiredError('claimRewardsRequest','Required parameter params.claimRewardsRequest was null or undefined when calling claimRewards.'); + async claimRewardsRaw(params: ClaimRewardsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.claimRewardsRequestBody === null || params.claimRewardsRequestBody === undefined) { + throw new runtime.RequiredError('claimRewardsRequestBody','Required parameter params.claimRewardsRequestBody was null or undefined when calling claimRewards.'); } const queryParameters: any = {}; @@ -65,7 +65,7 @@ export class RewardsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: ClaimRewardsRequestToJSON(params.claimRewardsRequest), + body: ClaimRewardsRequestBodyToJSON(params.claimRewardsRequestBody), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClaimRewardsResponseFromJSON(jsonValue)); @@ -74,7 +74,7 @@ export class RewardsApi extends runtime.BaseAPI { /** * Claims all the filtered undisbursed rewards for a user */ - async claimRewards(params: ClaimRewardsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async claimRewards(params: ClaimRewardsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.claimRewardsRaw(params, initOverrides); return await response.value(); } @@ -83,9 +83,9 @@ export class RewardsApi extends runtime.BaseAPI { * @hidden * Creates a new reward code with Solana signature verification */ - async createRewardCodeRaw(params: CreateRewardCodeOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.createRewardCodeRequest === null || params.createRewardCodeRequest === undefined) { - throw new runtime.RequiredError('createRewardCodeRequest','Required parameter params.createRewardCodeRequest was null or undefined when calling createRewardCode.'); + async createRewardCodeRaw(params: CreateRewardCodeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.createRewardCodeRequestBody === null || params.createRewardCodeRequestBody === undefined) { + throw new runtime.RequiredError('createRewardCodeRequestBody','Required parameter params.createRewardCodeRequestBody was null or undefined when calling createRewardCode.'); } const queryParameters: any = {}; @@ -99,7 +99,7 @@ export class RewardsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateRewardCodeRequestToJSON(params.createRewardCodeRequest), + body: CreateRewardCodeRequestBodyToJSON(params.createRewardCodeRequestBody), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateRewardCodeResponseFromJSON(jsonValue)); @@ -108,7 +108,7 @@ export class RewardsApi extends runtime.BaseAPI { /** * Creates a new reward code with Solana signature verification */ - async createRewardCode(params: CreateRewardCodeOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async createRewardCode(params: CreateRewardCodeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createRewardCodeRaw(params, initOverrides); return await response.value(); } diff --git a/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts index e3e3067a241..74fe66c180a 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts @@ -17,6 +17,8 @@ import * as runtime from '../runtime'; import type { AccessInfoResponse, + CreateTrackRequestBody, + CreateTrackResponse, RemixesResponse, RemixingResponse, StemsResponse, @@ -25,6 +27,7 @@ import type { TrackCommentCountResponse, TrackCommentNotificationResponse, TrackCommentsResponse, + TrackDownloadRequestBody, TrackFavoritesResponse, TrackInspect, TrackInspectList, @@ -33,10 +36,16 @@ import type { TrackSearch, TracksResponse, TrendingIdsResponse, + UpdateTrackRequestBody, + WriteResponse, } from '../models'; import { AccessInfoResponseFromJSON, AccessInfoResponseToJSON, + CreateTrackRequestBodyFromJSON, + CreateTrackRequestBodyToJSON, + CreateTrackResponseFromJSON, + CreateTrackResponseToJSON, RemixesResponseFromJSON, RemixesResponseToJSON, RemixingResponseFromJSON, @@ -53,6 +62,8 @@ import { TrackCommentNotificationResponseToJSON, TrackCommentsResponseFromJSON, TrackCommentsResponseToJSON, + TrackDownloadRequestBodyFromJSON, + TrackDownloadRequestBodyToJSON, TrackFavoritesResponseFromJSON, TrackFavoritesResponseToJSON, TrackInspectFromJSON, @@ -69,8 +80,22 @@ import { TracksResponseToJSON, TrendingIdsResponseFromJSON, TrendingIdsResponseToJSON, + UpdateTrackRequestBodyFromJSON, + UpdateTrackRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreateTrackRequest { + userId: string; + createTrackRequestBody: CreateTrackRequestBody; +} + +export interface DeleteTrackRequest { + trackId: string; + userId: string; +} + export interface DownloadTrackRequest { trackId: string; userId?: string; @@ -80,6 +105,11 @@ export interface DownloadTrackRequest { filename?: string; } +export interface FavoriteTrackRequest { + trackId: string; + userId: string; +} + export interface GetBulkTracksRequest { permalink?: Array; id?: Array; @@ -270,6 +300,16 @@ export interface InspectTracksRequest { original?: boolean; } +export interface RecordTrackDownloadRequest { + trackId: string; + trackDownloadRequestBody?: TrackDownloadRequestBody; +} + +export interface RepostTrackRequest { + trackId: string; + userId: string; +} + export interface SearchTracksRequest { offset?: number; limit?: number; @@ -286,6 +326,10 @@ export interface SearchTracksRequest { bpmMax?: string; } +export interface ShareTrackRequest { + trackId: string; +} + export interface StreamTrackRequest { trackId: string; userId?: string; @@ -299,11 +343,130 @@ export interface StreamTrackRequest { noRedirect?: boolean; } +export interface UnfavoriteTrackRequest { + trackId: string; + userId: string; +} + +export interface UnrepostTrackRequest { + trackId: string; + userId: string; +} + +export interface UpdateTrackRequest { + trackId: string; + userId: string; + updateTrackRequestBody: UpdateTrackRequestBody; +} + /** * */ export class TracksApi extends runtime.BaseAPI { + /** + * @hidden + * Creates a new track + */ + async createTrackRaw(params: CreateTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createTrack.'); + } + + if (params.createTrackRequestBody === null || params.createTrackRequestBody === undefined) { + throw new runtime.RequiredError('createTrackRequestBody','Required parameter params.createTrackRequestBody was null or undefined when calling createTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateTrackRequestBodyToJSON(params.createTrackRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateTrackResponseFromJSON(jsonValue)); + } + + /** + * Creates a new track + */ + async createTrack(params: CreateTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createTrackRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deletes a track + */ + async deleteTrackRaw(params: DeleteTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling deleteTrack.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling deleteTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Deletes a track + */ + async deleteTrack(params: DeleteTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deleteTrackRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Download an original or mp3 track @@ -356,6 +519,56 @@ export class TracksApi extends runtime.BaseAPI { await this.downloadTrackRaw(params, initOverrides); } + /** + * @hidden + * Favorite a track + */ + async favoriteTrackRaw(params: FavoriteTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling favoriteTrack.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling favoriteTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}/favorites`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Favorite a track + */ + async favoriteTrack(params: FavoriteTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.favoriteTrackRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Gets a list of tracks using their IDs or permalinks @@ -1544,6 +1757,101 @@ export class TracksApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Record a track download event + */ + async recordTrackDownloadRaw(params: RecordTrackDownloadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling recordTrackDownload.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}/downloads`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: TrackDownloadRequestBodyToJSON(params.trackDownloadRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Record a track download event + */ + async recordTrackDownload(params: RecordTrackDownloadRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.recordTrackDownloadRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Repost a track + */ + async repostTrackRaw(params: RepostTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling repostTrack.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling repostTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}/reposts`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Repost a track + */ + async repostTrack(params: RepostTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.repostTrackRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Search for a track or tracks @@ -1623,6 +1931,48 @@ export class TracksApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Record a track share event + */ + async shareTrackRaw(params: ShareTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling shareTrack.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}/shares`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Record a track share event + */ + async shareTrack(params: ShareTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.shareTrackRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Stream an mp3 track This endpoint accepts the Range header for streaming. https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests @@ -1692,6 +2042,163 @@ export class TracksApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Unfavorite a track + */ + async unfavoriteTrackRaw(params: UnfavoriteTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling unfavoriteTrack.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unfavoriteTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}/favorites`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unfavorite a track + */ + async unfavoriteTrack(params: UnfavoriteTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unfavoriteTrackRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unrepost a track + */ + async unrepostTrackRaw(params: UnrepostTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling unrepostTrack.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unrepostTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}/reposts`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unrepost a track + */ + async unrepostTrack(params: UnrepostTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unrepostTrackRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Updates an existing track + */ + async updateTrackRaw(params: UpdateTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.trackId === null || params.trackId === undefined) { + throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling updateTrack.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateTrack.'); + } + + if (params.updateTrackRequestBody === null || params.updateTrackRequestBody === undefined) { + throw new runtime.RequiredError('updateTrackRequestBody','Required parameter params.updateTrackRequestBody was null or undefined when calling updateTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/tracks/{track_id}`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: UpdateTrackRequestBodyToJSON(params.updateTrackRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Updates an existing track + */ + async updateTrack(params: UpdateTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.updateTrackRaw(params, initOverrides); + return await response.value(); + } + } /** diff --git a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts index edbc951196a..96499586e0f 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts @@ -21,7 +21,14 @@ import type { BalanceHistoryResponse, CollectiblesResponse, ConnectedWalletsResponse, - DeveloperApps, + CreateAccessKeyResponse, + CreateUserDeveloperAppRequestBody, + CreateUserDeveloperAppResponse, + CreateUserRequestBody, + CreateUserResponse, + DeactivateAccessKeyRequestBody, + DeactivateAccessKeyResponse, + DeveloperAppsResponse, EmailAccessResponse, FavoritesResponse, FollowersResponse, @@ -42,6 +49,7 @@ import type { TagsResponse, TracksCountResponse, TracksResponse, + UpdateUserRequestBody, UserCoinResponse, UserCoinsResponse, UserCommentsResponse, @@ -52,6 +60,7 @@ import type { UserTracksRemixedResponse, UsersResponse, VerifyToken, + WriteResponse, } from '../models'; import { AlbumsResponseFromJSON, @@ -64,8 +73,22 @@ import { CollectiblesResponseToJSON, ConnectedWalletsResponseFromJSON, ConnectedWalletsResponseToJSON, - DeveloperAppsFromJSON, - DeveloperAppsToJSON, + CreateAccessKeyResponseFromJSON, + CreateAccessKeyResponseToJSON, + CreateUserDeveloperAppRequestBodyFromJSON, + CreateUserDeveloperAppRequestBodyToJSON, + CreateUserDeveloperAppResponseFromJSON, + CreateUserDeveloperAppResponseToJSON, + CreateUserRequestBodyFromJSON, + CreateUserRequestBodyToJSON, + CreateUserResponseFromJSON, + CreateUserResponseToJSON, + DeactivateAccessKeyRequestBodyFromJSON, + DeactivateAccessKeyRequestBodyToJSON, + DeactivateAccessKeyResponseFromJSON, + DeactivateAccessKeyResponseToJSON, + DeveloperAppsResponseFromJSON, + DeveloperAppsResponseToJSON, EmailAccessResponseFromJSON, EmailAccessResponseToJSON, FavoritesResponseFromJSON, @@ -106,6 +129,8 @@ import { TracksCountResponseToJSON, TracksResponseFromJSON, TracksResponseToJSON, + UpdateUserRequestBodyFromJSON, + UpdateUserRequestBodyToJSON, UserCoinResponseFromJSON, UserCoinResponseToJSON, UserCoinsResponseFromJSON, @@ -126,8 +151,36 @@ import { UsersResponseToJSON, VerifyTokenFromJSON, VerifyTokenToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreateUserRequest { + userId: string; + createUserRequestBody: CreateUserRequestBody; +} + +export interface CreateUserDeveloperAppRequest { + id: string; + createUserDeveloperAppRequestBody: CreateUserDeveloperAppRequestBody; +} + +export interface CreateUserDeveloperAppAccessKeyRequest { + id: string; + address: string; +} + +export interface DeactivateUserDeveloperAppAccessKeyRequest { + id: string; + address: string; + deactivateAccessKeyRequestBody: DeactivateAccessKeyRequestBody; +} + +export interface DeleteUserDeveloperAppRequest { + id: string; + address: string; +} + export interface DownloadPurchasesAsCSVRequest { id: string; userId?: string; @@ -157,6 +210,11 @@ export interface DownloadUSDCWithdrawalsAsCSVRequest { encodedDataSignature?: string; } +export interface FollowUserRequest { + id: string; + userId: string; +} + export interface GetAIAttributedTracksByUserHandleRequest { handle: string; offset?: number; @@ -195,10 +253,6 @@ export interface GetConnectedWalletsRequest { id: string; } -export interface GetDeveloperAppsRequest { - id: string; -} - export interface GetFavoritesRequest { id: string; } @@ -394,6 +448,11 @@ export interface GetUserCommentsRequest { userId?: string; } +export interface GetUserDeveloperAppsRequest { + id: string; + include?: GetUserDeveloperAppsIncludeEnum; +} + export interface GetUserEmailKeyRequest { receivingUserId: string; grantorUserId: string; @@ -436,6 +495,11 @@ export interface GetUsersTrackHistoryRequest { encodedDataSignature?: string; } +export interface MuteUserRequest { + id: string; + userId: string; +} + export interface SearchUsersRequest { offset?: number; limit?: number; @@ -445,6 +509,32 @@ export interface SearchUsersRequest { isVerified?: string; } +export interface SubscribeToUserRequest { + id: string; + userId: string; +} + +export interface UnfollowUserRequest { + id: string; + userId: string; +} + +export interface UnmuteUserRequest { + id: string; + userId: string; +} + +export interface UnsubscribeFromUserRequest { + id: string; + userId: string; +} + +export interface UpdateUserRequest { + id: string; + userId: string; + updateUserRequestBody: UpdateUserRequestBody; +} + export interface VerifyIDTokenRequest { token: string; } @@ -454,6 +544,253 @@ export interface VerifyIDTokenRequest { */ export class UsersApi extends runtime.BaseAPI { + /** + * @hidden + * Creates a new user + */ + async createUserRaw(params: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createUser.'); + } + + if (params.createUserRequestBody === null || params.createUserRequestBody === undefined) { + throw new runtime.RequiredError('createUserRequestBody','Required parameter params.createUserRequestBody was null or undefined when calling createUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateUserRequestBodyToJSON(params.createUserRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateUserResponseFromJSON(jsonValue)); + } + + /** + * Creates a new user + */ + async createUser(params: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createUserRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Create a new developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperAppRaw(params: CreateUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling createUserDeveloperApp.'); + } + + if (params.createUserDeveloperAppRequestBody === null || params.createUserDeveloperAppRequestBody === undefined) { + throw new runtime.RequiredError('createUserDeveloperAppRequestBody','Required parameter params.createUserDeveloperAppRequestBody was null or undefined when calling createUserDeveloperApp.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateUserDeveloperAppRequestBodyToJSON(params.createUserDeveloperAppRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateUserDeveloperAppResponseFromJSON(jsonValue)); + } + + /** + * Create a new developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperApp(params: CreateUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createUserDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Create a new bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperAppAccessKeyRaw(params: CreateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling createUserDeveloperAppAccessKey.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling createUserDeveloperAppAccessKey.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps/{address}/access-keys`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateAccessKeyResponseFromJSON(jsonValue)); + } + + /** + * Create a new bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async createUserDeveloperAppAccessKey(params: CreateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createUserDeveloperAppAccessKeyRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deactivate a bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. The deactivated token will no longer authenticate requests. + */ + async deactivateUserDeveloperAppAccessKeyRaw(params: DeactivateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); + } + + if (params.deactivateAccessKeyRequestBody === null || params.deactivateAccessKeyRequestBody === undefined) { + throw new runtime.RequiredError('deactivateAccessKeyRequestBody','Required parameter params.deactivateAccessKeyRequestBody was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps/{address}/access-keys/deactivate`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: DeactivateAccessKeyRequestBodyToJSON(params.deactivateAccessKeyRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => DeactivateAccessKeyResponseFromJSON(jsonValue)); + } + + /** + * Deactivate a bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. The deactivated token will no longer authenticate requests. + */ + async deactivateUserDeveloperAppAccessKey(params: DeactivateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deactivateUserDeveloperAppAccessKeyRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Delete a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async deleteUserDeveloperAppRaw(params: DeleteUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling deleteUserDeveloperApp.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deleteUserDeveloperApp.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/developer-apps/{address}`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Delete a developer app (Plans API). Requires OAuth Bearer token with plans app grant. + */ + async deleteUserDeveloperApp(params: DeleteUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deleteUserDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Downloads the purchases the user has made as a CSV file @@ -627,6 +964,56 @@ export class UsersApi extends runtime.BaseAPI { await this.downloadUSDCWithdrawalsAsCSVRaw(params, initOverrides); } + /** + * @hidden + * Follow a user + */ + async followUserRaw(params: FollowUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling followUser.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling followUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/follow`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Follow a user + */ + async followUser(params: FollowUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.followUserRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Gets the AI generated tracks attributed to a user using the user\'s handle @@ -854,37 +1241,6 @@ export class UsersApi extends runtime.BaseAPI { return await response.value(); } - /** - * @hidden - * Gets the developer apps that the user owns - */ - async getDeveloperAppsRaw(params: GetDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.id === null || params.id === undefined) { - throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling getDeveloperApps.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request({ - path: `/users/{id}/developer_apps`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => DeveloperAppsFromJSON(jsonValue)); - } - - /** - * Gets the developer apps that the user owns - */ - async getDeveloperApps(params: GetDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getDeveloperAppsRaw(params, initOverrides); - return await response.value(); - } - /** * @hidden * Gets a user\'s favorite tracks @@ -2057,6 +2413,41 @@ export class UsersApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Get developer apps for the user (Plans API). Requires OAuth. + */ + async getUserDeveloperAppsRaw(params: GetUserDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling getUserDeveloperApps.'); + } + + const queryParameters: any = {}; + + if (params.include !== undefined) { + queryParameters['include'] = params.include; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/users/{id}/developer-apps`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => DeveloperAppsResponseFromJSON(jsonValue)); + } + + /** + * Get developer apps for the user (Plans API). Requires OAuth. + */ + async getUserDeveloperApps(params: GetUserDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUserDeveloperAppsRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Gets the encrypted key for email access between the receiving user and granting user. @@ -2327,6 +2718,56 @@ export class UsersApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Mute a user + */ + async muteUserRaw(params: MuteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling muteUser.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling muteUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/muted`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Mute a user + */ + async muteUser(params: MuteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.muteUserRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Search for users that match the given query @@ -2378,6 +2819,255 @@ export class UsersApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Subscribe to a user + */ + async subscribeToUserRaw(params: SubscribeToUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling subscribeToUser.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling subscribeToUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/subscribers`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Subscribe to a user + */ + async subscribeToUser(params: SubscribeToUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.subscribeToUserRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unfollow a user + */ + async unfollowUserRaw(params: UnfollowUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling unfollowUser.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unfollowUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/follow`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unfollow a user + */ + async unfollowUser(params: UnfollowUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unfollowUserRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unmute a user + */ + async unmuteUserRaw(params: UnmuteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling unmuteUser.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unmuteUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/muted`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unmute a user + */ + async unmuteUser(params: UnmuteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unmuteUserRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Unsubscribe from a user + */ + async unsubscribeFromUserRaw(params: UnsubscribeFromUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling unsubscribeFromUser.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unsubscribeFromUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("BearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/users/{id}/subscribers`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Unsubscribe from a user + */ + async unsubscribeFromUser(params: UnsubscribeFromUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.unsubscribeFromUserRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Updates an existing user profile + */ + async updateUserRaw(params: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.id === null || params.id === undefined) { + throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling updateUser.'); + } + + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateUser.'); + } + + if (params.updateUserRequestBody === null || params.updateUserRequestBody === undefined) { + throw new runtime.RequiredError('updateUserRequestBody','Required parameter params.updateUserRequestBody was null or undefined when calling updateUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { + headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + } + const response = await this.request({ + path: `/users/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: UpdateUserRequestBodyToJSON(params.updateUserRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Updates an existing user profile + */ + async updateUser(params: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.updateUserRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Verify if the given jwt ID token was signed by the subject (user) in the payload @@ -2588,6 +3278,13 @@ export const GetUserBalanceHistoryGranularityEnum = { Daily: 'daily' } as const; export type GetUserBalanceHistoryGranularityEnum = typeof GetUserBalanceHistoryGranularityEnum[keyof typeof GetUserBalanceHistoryGranularityEnum]; +/** + * @export + */ +export const GetUserDeveloperAppsIncludeEnum = { + Metrics: 'metrics' +} as const; +export type GetUserDeveloperAppsIncludeEnum = typeof GetUserDeveloperAppsIncludeEnum[keyof typeof GetUserDeveloperAppsIncludeEnum]; /** * @export */ diff --git a/packages/sdk/src/sdk/api/generated/default/models/ClaimRewardsRequest.ts b/packages/sdk/src/sdk/api/generated/default/models/ClaimRewardsRequestBody.ts similarity index 65% rename from packages/sdk/src/sdk/api/generated/default/models/ClaimRewardsRequest.ts rename to packages/sdk/src/sdk/api/generated/default/models/ClaimRewardsRequestBody.ts index ec62104bfff..203c1c6d5fa 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/ClaimRewardsRequest.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/ClaimRewardsRequestBody.ts @@ -17,44 +17,44 @@ import { exists, mapValues } from '../runtime'; /** * * @export - * @interface ClaimRewardsRequest + * @interface ClaimRewardsRequestBody */ -export interface ClaimRewardsRequest { +export interface ClaimRewardsRequestBody { /** * The challenge ID to filter rewards (optional) * @type {string} - * @memberof ClaimRewardsRequest + * @memberof ClaimRewardsRequestBody */ challengeId?: string; /** * The specifier to filter rewards (optional) * @type {string} - * @memberof ClaimRewardsRequest + * @memberof ClaimRewardsRequestBody */ specifier?: string; /** * The user ID to claim rewards for * @type {string} - * @memberof ClaimRewardsRequest + * @memberof ClaimRewardsRequestBody */ userId: string; } /** - * Check if a given object implements the ClaimRewardsRequest interface. + * Check if a given object implements the ClaimRewardsRequestBody interface. */ -export function instanceOfClaimRewardsRequest(value: object): value is ClaimRewardsRequest { +export function instanceOfClaimRewardsRequestBody(value: object): value is ClaimRewardsRequestBody { let isInstance = true; isInstance = isInstance && "userId" in value && value["userId"] !== undefined; return isInstance; } -export function ClaimRewardsRequestFromJSON(json: any): ClaimRewardsRequest { - return ClaimRewardsRequestFromJSONTyped(json, false); +export function ClaimRewardsRequestBodyFromJSON(json: any): ClaimRewardsRequestBody { + return ClaimRewardsRequestBodyFromJSONTyped(json, false); } -export function ClaimRewardsRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ClaimRewardsRequest { +export function ClaimRewardsRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ClaimRewardsRequestBody { if ((json === undefined) || (json === null)) { return json; } @@ -66,7 +66,7 @@ export function ClaimRewardsRequestFromJSONTyped(json: any, ignoreDiscriminator: }; } -export function ClaimRewardsRequestToJSON(value?: ClaimRewardsRequest | null): any { +export function ClaimRewardsRequestBodyToJSON(value?: ClaimRewardsRequestBody | null): any { if (value === undefined) { return undefined; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateAccessKeyResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateAccessKeyResponse.ts new file mode 100644 index 00000000000..3d7cf28e3aa --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateAccessKeyResponse.ts @@ -0,0 +1,67 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateAccessKeyResponse + */ +export interface CreateAccessKeyResponse { + /** + * The newly created bearer token (API access key) + * @type {string} + * @memberof CreateAccessKeyResponse + */ + apiAccessKey: string; +} + +/** + * Check if a given object implements the CreateAccessKeyResponse interface. + */ +export function instanceOfCreateAccessKeyResponse(value: object): value is CreateAccessKeyResponse { + let isInstance = true; + isInstance = isInstance && "apiAccessKey" in value && value["apiAccessKey"] !== undefined; + + return isInstance; +} + +export function CreateAccessKeyResponseFromJSON(json: any): CreateAccessKeyResponse { + return CreateAccessKeyResponseFromJSONTyped(json, false); +} + +export function CreateAccessKeyResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateAccessKeyResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'apiAccessKey': json['api_access_key'], + }; +} + +export function CreateAccessKeyResponseToJSON(value?: CreateAccessKeyResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'api_access_key': value.apiAccessKey, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateCoinRequest.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateCoinRequestBody.ts similarity index 75% rename from packages/sdk/src/sdk/api/generated/default/models/CreateCoinRequest.ts rename to packages/sdk/src/sdk/api/generated/default/models/CreateCoinRequestBody.ts index 39817b101dd..53e70836f09 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateCoinRequest.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateCoinRequestBody.ts @@ -17,81 +17,81 @@ import { exists, mapValues } from '../runtime'; /** * * @export - * @interface CreateCoinRequest + * @interface CreateCoinRequestBody */ -export interface CreateCoinRequest { +export interface CreateCoinRequestBody { /** * The mint address of the coin * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ mint: string; /** * The coin symbol/ticker * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ ticker: string; /** * The number of decimals for the coin (0-18) * @type {number} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ decimals: number; /** * The coin name * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ name: string; /** * The URI for the coin's logo image * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ logoUri?: string; /** * The URI for the coin's banner image * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ bannerImageUrl?: string; /** * The description of the coin * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ description?: string; /** * Generic link URL for the coin * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ link1?: string; /** * Generic link URL for the coin * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ link2?: string; /** * Generic link URL for the coin * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ link3?: string; /** * Generic link URL for the coin * @type {string} - * @memberof CreateCoinRequest + * @memberof CreateCoinRequestBody */ link4?: string; } /** - * Check if a given object implements the CreateCoinRequest interface. + * Check if a given object implements the CreateCoinRequestBody interface. */ -export function instanceOfCreateCoinRequest(value: object): value is CreateCoinRequest { +export function instanceOfCreateCoinRequestBody(value: object): value is CreateCoinRequestBody { let isInstance = true; isInstance = isInstance && "mint" in value && value["mint"] !== undefined; isInstance = isInstance && "ticker" in value && value["ticker"] !== undefined; @@ -101,11 +101,11 @@ export function instanceOfCreateCoinRequest(value: object): value is CreateCoinR return isInstance; } -export function CreateCoinRequestFromJSON(json: any): CreateCoinRequest { - return CreateCoinRequestFromJSONTyped(json, false); +export function CreateCoinRequestBodyFromJSON(json: any): CreateCoinRequestBody { + return CreateCoinRequestBodyFromJSONTyped(json, false); } -export function CreateCoinRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateCoinRequest { +export function CreateCoinRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateCoinRequestBody { if ((json === undefined) || (json === null)) { return json; } @@ -125,7 +125,7 @@ export function CreateCoinRequestFromJSONTyped(json: any, ignoreDiscriminator: b }; } -export function CreateCoinRequestToJSON(value?: CreateCoinRequest | null): any { +export function CreateCoinRequestBodyToJSON(value?: CreateCoinRequestBody | null): any { if (value === undefined) { return undefined; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts new file mode 100644 index 00000000000..84d7b9772bf --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts @@ -0,0 +1,101 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateCommentRequestBody + */ +export interface CreateCommentRequestBody { + /** + * Type of entity being commented on + * @type {string} + * @memberof CreateCommentRequestBody + */ + entityType: string; + /** + * ID of the entity being commented on + * @type {string} + * @memberof CreateCommentRequestBody + */ + entityId: string; + /** + * Comment text + * @type {string} + * @memberof CreateCommentRequestBody + */ + body: string; + /** + * Optional comment ID + * @type {number} + * @memberof CreateCommentRequestBody + */ + commentId?: number; + /** + * Parent comment ID if this is a reply + * @type {number} + * @memberof CreateCommentRequestBody + */ + parentId?: number; +} + +/** + * Check if a given object implements the CreateCommentRequestBody interface. + */ +export function instanceOfCreateCommentRequestBody(value: object): value is CreateCommentRequestBody { + let isInstance = true; + isInstance = isInstance && "entityType" in value && value["entityType"] !== undefined; + isInstance = isInstance && "entityId" in value && value["entityId"] !== undefined; + isInstance = isInstance && "body" in value && value["body"] !== undefined; + + return isInstance; +} + +export function CreateCommentRequestBodyFromJSON(json: any): CreateCommentRequestBody { + return CreateCommentRequestBodyFromJSONTyped(json, false); +} + +export function CreateCommentRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateCommentRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'entityType': json['entityType'], + 'entityId': json['entityId'], + 'body': json['body'], + 'commentId': !exists(json, 'commentId') ? undefined : json['commentId'], + 'parentId': !exists(json, 'parentId') ? undefined : json['parentId'], + }; +} + +export function CreateCommentRequestBodyToJSON(value?: CreateCommentRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'entityType': value.entityType, + 'entityId': value.entityId, + 'body': value.body, + 'commentId': value.commentId, + 'parentId': value.parentId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentResponse.ts new file mode 100644 index 00000000000..fe10f559a84 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentResponse.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateCommentResponse + */ +export interface CreateCommentResponse { + /** + * Whether the comment was created successfully + * @type {boolean} + * @memberof CreateCommentResponse + */ + success?: boolean; + /** + * The blockchain transaction hash + * @type {string} + * @memberof CreateCommentResponse + */ + transactionHash?: string; + /** + * The ID of the created comment + * @type {string} + * @memberof CreateCommentResponse + */ + commentId?: string; +} + +/** + * Check if a given object implements the CreateCommentResponse interface. + */ +export function instanceOfCreateCommentResponse(value: object): value is CreateCommentResponse { + let isInstance = true; + + return isInstance; +} + +export function CreateCommentResponseFromJSON(json: any): CreateCommentResponse { + return CreateCommentResponseFromJSONTyped(json, false); +} + +export function CreateCommentResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateCommentResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'success': !exists(json, 'success') ? undefined : json['success'], + 'transactionHash': !exists(json, 'transaction_hash') ? undefined : json['transaction_hash'], + 'commentId': !exists(json, 'comment_id') ? undefined : json['comment_id'], + }; +} + +export function CreateCommentResponseToJSON(value?: CreateCommentResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'success': value.success, + 'transaction_hash': value.transactionHash, + 'comment_id': value.commentId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBody.ts new file mode 100644 index 00000000000..f0140ca917f --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBody.ts @@ -0,0 +1,101 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { CreateDeveloperAppRequestBodyAppSignature } from './CreateDeveloperAppRequestBodyAppSignature'; +import { + CreateDeveloperAppRequestBodyAppSignatureFromJSON, + CreateDeveloperAppRequestBodyAppSignatureFromJSONTyped, + CreateDeveloperAppRequestBodyAppSignatureToJSON, +} from './CreateDeveloperAppRequestBodyAppSignature'; + +/** + * + * @export + * @interface CreateDeveloperAppRequestBody + */ +export interface CreateDeveloperAppRequestBody { + /** + * Developer app name + * @type {string} + * @memberof CreateDeveloperAppRequestBody + */ + name: string; + /** + * App description + * @type {string} + * @memberof CreateDeveloperAppRequestBody + */ + description: string; + /** + * App logo/image URL (camelCase) + * @type {string} + * @memberof CreateDeveloperAppRequestBody + */ + imageUrl: string; + /** + * + * @type {CreateDeveloperAppRequestBodyAppSignature} + * @memberof CreateDeveloperAppRequestBody + */ + appSignature: CreateDeveloperAppRequestBodyAppSignature; +} + +/** + * Check if a given object implements the CreateDeveloperAppRequestBody interface. + */ +export function instanceOfCreateDeveloperAppRequestBody(value: object): value is CreateDeveloperAppRequestBody { + let isInstance = true; + isInstance = isInstance && "name" in value && value["name"] !== undefined; + isInstance = isInstance && "description" in value && value["description"] !== undefined; + isInstance = isInstance && "imageUrl" in value && value["imageUrl"] !== undefined; + isInstance = isInstance && "appSignature" in value && value["appSignature"] !== undefined; + + return isInstance; +} + +export function CreateDeveloperAppRequestBodyFromJSON(json: any): CreateDeveloperAppRequestBody { + return CreateDeveloperAppRequestBodyFromJSONTyped(json, false); +} + +export function CreateDeveloperAppRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateDeveloperAppRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + 'description': json['description'], + 'imageUrl': json['imageUrl'], + 'appSignature': CreateDeveloperAppRequestBodyAppSignatureFromJSON(json['appSignature']), + }; +} + +export function CreateDeveloperAppRequestBodyToJSON(value?: CreateDeveloperAppRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'description': value.description, + 'imageUrl': value.imageUrl, + 'appSignature': CreateDeveloperAppRequestBodyAppSignatureToJSON(value.appSignature), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBodyAppSignature.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBodyAppSignature.ts new file mode 100644 index 00000000000..9d515049580 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBodyAppSignature.ts @@ -0,0 +1,76 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateDeveloperAppRequestBodyAppSignature + */ +export interface CreateDeveloperAppRequestBodyAppSignature { + /** + * Signed message + * @type {string} + * @memberof CreateDeveloperAppRequestBodyAppSignature + */ + message: string; + /** + * Signature + * @type {string} + * @memberof CreateDeveloperAppRequestBodyAppSignature + */ + signature: string; +} + +/** + * Check if a given object implements the CreateDeveloperAppRequestBodyAppSignature interface. + */ +export function instanceOfCreateDeveloperAppRequestBodyAppSignature(value: object): value is CreateDeveloperAppRequestBodyAppSignature { + let isInstance = true; + isInstance = isInstance && "message" in value && value["message"] !== undefined; + isInstance = isInstance && "signature" in value && value["signature"] !== undefined; + + return isInstance; +} + +export function CreateDeveloperAppRequestBodyAppSignatureFromJSON(json: any): CreateDeveloperAppRequestBodyAppSignature { + return CreateDeveloperAppRequestBodyAppSignatureFromJSONTyped(json, false); +} + +export function CreateDeveloperAppRequestBodyAppSignatureFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateDeveloperAppRequestBodyAppSignature { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'message': json['message'], + 'signature': json['signature'], + }; +} + +export function CreateDeveloperAppRequestBodyAppSignatureToJSON(value?: CreateDeveloperAppRequestBodyAppSignature | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'message': value.message, + 'signature': value.signature, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts new file mode 100644 index 00000000000..93e137da69f --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts @@ -0,0 +1,206 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { Genre } from './Genre'; +import { + GenreFromJSON, + GenreFromJSONTyped, + GenreToJSON, +} from './Genre'; +import type { Mood } from './Mood'; +import { + MoodFromJSON, + MoodFromJSONTyped, + MoodToJSON, +} from './Mood'; +import type { PlaylistAddedTimestamp } from './PlaylistAddedTimestamp'; +import { + PlaylistAddedTimestampFromJSON, + PlaylistAddedTimestampFromJSONTyped, + PlaylistAddedTimestampToJSON, +} from './PlaylistAddedTimestamp'; + +/** + * + * @export + * @interface CreatePlaylistRequestBody + */ +export interface CreatePlaylistRequestBody { + /** + * Optional playlist ID (will be generated if not provided) + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + playlistId?: string; + /** + * Playlist or album name + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + playlistName: string; + /** + * Playlist description + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + description?: string; + /** + * Whether the playlist is private + * @type {boolean} + * @memberof CreatePlaylistRequestBody + */ + isPrivate?: boolean; + /** + * Whether this is an album + * @type {boolean} + * @memberof CreatePlaylistRequestBody + */ + isAlbum?: boolean; + /** + * + * @type {Genre} + * @memberof CreatePlaylistRequestBody + */ + genre?: Genre; + /** + * + * @type {Mood} + * @memberof CreatePlaylistRequestBody + */ + mood?: Mood; + /** + * Comma-separated tags + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + tags?: string; + /** + * License type + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + license?: string; + /** + * Universal Product Code (for albums) + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + upc?: string; + /** + * Release date + * @type {Date} + * @memberof CreatePlaylistRequestBody + */ + releaseDate?: Date; + /** + * IPFS CID for cover art + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + coverArtCid?: string; + /** + * Array of tracks in the playlist + * @type {Array} + * @memberof CreatePlaylistRequestBody + */ + playlistContents?: Array; + /** + * DDEX application identifier + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + ddexApp?: string; + /** + * Parental warning type + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + parentalWarningType?: string; + /** + * Whether the image is autogenerated + * @type {boolean} + * @memberof CreatePlaylistRequestBody + */ + isImageAutogenerated?: boolean; +} + +/** + * Check if a given object implements the CreatePlaylistRequestBody interface. + */ +export function instanceOfCreatePlaylistRequestBody(value: object): value is CreatePlaylistRequestBody { + let isInstance = true; + isInstance = isInstance && "playlistName" in value && value["playlistName"] !== undefined; + + return isInstance; +} + +export function CreatePlaylistRequestBodyFromJSON(json: any): CreatePlaylistRequestBody { + return CreatePlaylistRequestBodyFromJSONTyped(json, false); +} + +export function CreatePlaylistRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreatePlaylistRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'playlistId': !exists(json, 'playlist_id') ? undefined : json['playlist_id'], + 'playlistName': json['playlist_name'], + 'description': !exists(json, 'description') ? undefined : json['description'], + 'isPrivate': !exists(json, 'is_private') ? undefined : json['is_private'], + 'isAlbum': !exists(json, 'is_album') ? undefined : json['is_album'], + 'genre': !exists(json, 'genre') ? undefined : GenreFromJSON(json['genre']), + 'mood': !exists(json, 'mood') ? undefined : MoodFromJSON(json['mood']), + 'tags': !exists(json, 'tags') ? undefined : json['tags'], + 'license': !exists(json, 'license') ? undefined : json['license'], + 'upc': !exists(json, 'upc') ? undefined : json['upc'], + 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), + 'coverArtCid': !exists(json, 'cover_art_cid') ? undefined : json['cover_art_cid'], + 'playlistContents': !exists(json, 'playlist_contents') ? undefined : ((json['playlist_contents'] as Array).map(PlaylistAddedTimestampFromJSON)), + 'ddexApp': !exists(json, 'ddex_app') ? undefined : json['ddex_app'], + 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], + 'isImageAutogenerated': !exists(json, 'is_image_autogenerated') ? undefined : json['is_image_autogenerated'], + }; +} + +export function CreatePlaylistRequestBodyToJSON(value?: CreatePlaylistRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'playlist_id': value.playlistId, + 'playlist_name': value.playlistName, + 'description': value.description, + 'is_private': value.isPrivate, + 'is_album': value.isAlbum, + 'genre': GenreToJSON(value.genre), + 'mood': MoodToJSON(value.mood), + 'tags': value.tags, + 'license': value.license, + 'upc': value.upc, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString().substr(0,10)), + 'cover_art_cid': value.coverArtCid, + 'playlist_contents': value.playlistContents === undefined ? undefined : ((value.playlistContents as Array).map(PlaylistAddedTimestampToJSON)), + 'ddex_app': value.ddexApp, + 'parental_warning_type': value.parentalWarningType, + 'is_image_autogenerated': value.isImageAutogenerated, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistResponse.ts new file mode 100644 index 00000000000..e755c8cf65d --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistResponse.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreatePlaylistResponse + */ +export interface CreatePlaylistResponse { + /** + * Whether the playlist was created successfully + * @type {boolean} + * @memberof CreatePlaylistResponse + */ + success?: boolean; + /** + * The blockchain transaction hash + * @type {string} + * @memberof CreatePlaylistResponse + */ + transactionHash?: string; + /** + * The ID of the created playlist + * @type {string} + * @memberof CreatePlaylistResponse + */ + playlistId?: string; +} + +/** + * Check if a given object implements the CreatePlaylistResponse interface. + */ +export function instanceOfCreatePlaylistResponse(value: object): value is CreatePlaylistResponse { + let isInstance = true; + + return isInstance; +} + +export function CreatePlaylistResponseFromJSON(json: any): CreatePlaylistResponse { + return CreatePlaylistResponseFromJSONTyped(json, false); +} + +export function CreatePlaylistResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreatePlaylistResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'success': !exists(json, 'success') ? undefined : json['success'], + 'transactionHash': !exists(json, 'transaction_hash') ? undefined : json['transaction_hash'], + 'playlistId': !exists(json, 'playlist_id') ? undefined : json['playlist_id'], + }; +} + +export function CreatePlaylistResponseToJSON(value?: CreatePlaylistResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'success': value.success, + 'transaction_hash': value.transactionHash, + 'playlist_id': value.playlistId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateRewardCodeRequest.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateRewardCodeRequestBody.ts similarity index 67% rename from packages/sdk/src/sdk/api/generated/default/models/CreateRewardCodeRequest.ts rename to packages/sdk/src/sdk/api/generated/default/models/CreateRewardCodeRequestBody.ts index 44bbad4a730..9712e227d91 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateRewardCodeRequest.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateRewardCodeRequestBody.ts @@ -17,33 +17,33 @@ import { exists, mapValues } from '../runtime'; /** * * @export - * @interface CreateRewardCodeRequest + * @interface CreateRewardCodeRequestBody */ -export interface CreateRewardCodeRequest { +export interface CreateRewardCodeRequestBody { /** * Base64-encoded Solana Ed25519 signature of the string "code" * @type {string} - * @memberof CreateRewardCodeRequest + * @memberof CreateRewardCodeRequestBody */ signature: string; /** * The coin mint address * @type {string} - * @memberof CreateRewardCodeRequest + * @memberof CreateRewardCodeRequestBody */ mint: string; /** * The reward amount (must be greater than 0) * @type {number} - * @memberof CreateRewardCodeRequest + * @memberof CreateRewardCodeRequestBody */ amount: number; } /** - * Check if a given object implements the CreateRewardCodeRequest interface. + * Check if a given object implements the CreateRewardCodeRequestBody interface. */ -export function instanceOfCreateRewardCodeRequest(value: object): value is CreateRewardCodeRequest { +export function instanceOfCreateRewardCodeRequestBody(value: object): value is CreateRewardCodeRequestBody { let isInstance = true; isInstance = isInstance && "signature" in value && value["signature"] !== undefined; isInstance = isInstance && "mint" in value && value["mint"] !== undefined; @@ -52,11 +52,11 @@ export function instanceOfCreateRewardCodeRequest(value: object): value is Creat return isInstance; } -export function CreateRewardCodeRequestFromJSON(json: any): CreateRewardCodeRequest { - return CreateRewardCodeRequestFromJSONTyped(json, false); +export function CreateRewardCodeRequestBodyFromJSON(json: any): CreateRewardCodeRequestBody { + return CreateRewardCodeRequestBodyFromJSONTyped(json, false); } -export function CreateRewardCodeRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateRewardCodeRequest { +export function CreateRewardCodeRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateRewardCodeRequestBody { if ((json === undefined) || (json === null)) { return json; } @@ -68,7 +68,7 @@ export function CreateRewardCodeRequestFromJSONTyped(json: any, ignoreDiscrimina }; } -export function CreateRewardCodeRequestToJSON(value?: CreateRewardCodeRequest | null): any { +export function CreateRewardCodeRequestBodyToJSON(value?: CreateRewardCodeRequestBody | null): any { if (value === undefined) { return undefined; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts new file mode 100644 index 00000000000..efe471919fc --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts @@ -0,0 +1,226 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { Genre } from './Genre'; +import { + GenreFromJSON, + GenreFromJSONTyped, + GenreToJSON, +} from './Genre'; +import type { Mood } from './Mood'; +import { + MoodFromJSON, + MoodFromJSONTyped, + MoodToJSON, +} from './Mood'; + +/** + * + * @export + * @interface CreateTrackRequestBody + */ +export interface CreateTrackRequestBody { + /** + * Optional track ID (will be generated if not provided) + * @type {string} + * @memberof CreateTrackRequestBody + */ + trackId?: string; + /** + * Track title + * @type {string} + * @memberof CreateTrackRequestBody + */ + title: string; + /** + * + * @type {Genre} + * @memberof CreateTrackRequestBody + */ + genre: Genre; + /** + * Track description + * @type {string} + * @memberof CreateTrackRequestBody + */ + description?: string; + /** + * + * @type {Mood} + * @memberof CreateTrackRequestBody + */ + mood?: Mood; + /** + * Comma-separated tags + * @type {string} + * @memberof CreateTrackRequestBody + */ + tags?: string; + /** + * License type + * @type {string} + * @memberof CreateTrackRequestBody + */ + license?: string; + /** + * International Standard Recording Code + * @type {string} + * @memberof CreateTrackRequestBody + */ + isrc?: string; + /** + * International Standard Musical Work Code + * @type {string} + * @memberof CreateTrackRequestBody + */ + iswc?: string; + /** + * Release date + * @type {string} + * @memberof CreateTrackRequestBody + */ + releaseDate?: string; + /** + * IPFS CID for the track audio file (required) + * @type {string} + * @memberof CreateTrackRequestBody + */ + trackCid: string; + /** + * IPFS CID for cover art + * @type {string} + * @memberof CreateTrackRequestBody + */ + coverArtCid?: string; + /** + * IPFS CID for the track preview + * @type {string} + * @memberof CreateTrackRequestBody + */ + previewCid?: string; + /** + * Preview start time in seconds + * @type {number} + * @memberof CreateTrackRequestBody + */ + previewStartSeconds?: number; + /** + * Track duration in seconds + * @type {number} + * @memberof CreateTrackRequestBody + */ + duration?: number; + /** + * Whether the track is downloadable + * @type {boolean} + * @memberof CreateTrackRequestBody + */ + downloadable?: boolean; + /** + * Whether the track is unlisted + * @type {boolean} + * @memberof CreateTrackRequestBody + */ + isUnlisted?: boolean; + /** + * DDEX application identifier + * @type {string} + * @memberof CreateTrackRequestBody + */ + ddexApp?: string; + /** + * Parental warning type + * @type {string} + * @memberof CreateTrackRequestBody + */ + parentalWarningType?: string; +} + +/** + * Check if a given object implements the CreateTrackRequestBody interface. + */ +export function instanceOfCreateTrackRequestBody(value: object): value is CreateTrackRequestBody { + let isInstance = true; + isInstance = isInstance && "title" in value && value["title"] !== undefined; + isInstance = isInstance && "genre" in value && value["genre"] !== undefined; + isInstance = isInstance && "trackCid" in value && value["trackCid"] !== undefined; + + return isInstance; +} + +export function CreateTrackRequestBodyFromJSON(json: any): CreateTrackRequestBody { + return CreateTrackRequestBodyFromJSONTyped(json, false); +} + +export function CreateTrackRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateTrackRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'trackId': !exists(json, 'track_id') ? undefined : json['track_id'], + 'title': json['title'], + 'genre': GenreFromJSON(json['genre']), + 'description': !exists(json, 'description') ? undefined : json['description'], + 'mood': !exists(json, 'mood') ? undefined : MoodFromJSON(json['mood']), + 'tags': !exists(json, 'tags') ? undefined : json['tags'], + 'license': !exists(json, 'license') ? undefined : json['license'], + 'isrc': !exists(json, 'isrc') ? undefined : json['isrc'], + 'iswc': !exists(json, 'iswc') ? undefined : json['iswc'], + 'releaseDate': !exists(json, 'release_date') ? undefined : json['release_date'], + 'trackCid': json['track_cid'], + 'coverArtCid': !exists(json, 'cover_art_cid') ? undefined : json['cover_art_cid'], + 'previewCid': !exists(json, 'preview_cid') ? undefined : json['preview_cid'], + 'previewStartSeconds': !exists(json, 'preview_start_seconds') ? undefined : json['preview_start_seconds'], + 'duration': !exists(json, 'duration') ? undefined : json['duration'], + 'downloadable': !exists(json, 'downloadable') ? undefined : json['downloadable'], + 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], + 'ddexApp': !exists(json, 'ddex_app') ? undefined : json['ddex_app'], + 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], + }; +} + +export function CreateTrackRequestBodyToJSON(value?: CreateTrackRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'track_id': value.trackId, + 'title': value.title, + 'genre': GenreToJSON(value.genre), + 'description': value.description, + 'mood': MoodToJSON(value.mood), + 'tags': value.tags, + 'license': value.license, + 'isrc': value.isrc, + 'iswc': value.iswc, + 'release_date': value.releaseDate, + 'track_cid': value.trackCid, + 'cover_art_cid': value.coverArtCid, + 'preview_cid': value.previewCid, + 'preview_start_seconds': value.previewStartSeconds, + 'duration': value.duration, + 'downloadable': value.downloadable, + 'is_unlisted': value.isUnlisted, + 'ddex_app': value.ddexApp, + 'parental_warning_type': value.parentalWarningType, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateTrackResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackResponse.ts new file mode 100644 index 00000000000..e9588e8cef1 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackResponse.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateTrackResponse + */ +export interface CreateTrackResponse { + /** + * Whether the track was created successfully + * @type {boolean} + * @memberof CreateTrackResponse + */ + success?: boolean; + /** + * The blockchain transaction hash + * @type {string} + * @memberof CreateTrackResponse + */ + transactionHash?: string; + /** + * The ID of the created track + * @type {string} + * @memberof CreateTrackResponse + */ + trackId?: string; +} + +/** + * Check if a given object implements the CreateTrackResponse interface. + */ +export function instanceOfCreateTrackResponse(value: object): value is CreateTrackResponse { + let isInstance = true; + + return isInstance; +} + +export function CreateTrackResponseFromJSON(json: any): CreateTrackResponse { + return CreateTrackResponseFromJSONTyped(json, false); +} + +export function CreateTrackResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateTrackResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'success': !exists(json, 'success') ? undefined : json['success'], + 'transactionHash': !exists(json, 'transaction_hash') ? undefined : json['transaction_hash'], + 'trackId': !exists(json, 'track_id') ? undefined : json['track_id'], + }; +} + +export function CreateTrackResponseToJSON(value?: CreateTrackResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'success': value.success, + 'transaction_hash': value.transactionHash, + 'track_id': value.trackId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppRequestBody.ts new file mode 100644 index 00000000000..8eb3a2af511 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppRequestBody.ts @@ -0,0 +1,67 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateUserDeveloperAppRequestBody + */ +export interface CreateUserDeveloperAppRequestBody { + /** + * Developer app name (Plans API create) + * @type {string} + * @memberof CreateUserDeveloperAppRequestBody + */ + name: string; +} + +/** + * Check if a given object implements the CreateUserDeveloperAppRequestBody interface. + */ +export function instanceOfCreateUserDeveloperAppRequestBody(value: object): value is CreateUserDeveloperAppRequestBody { + let isInstance = true; + isInstance = isInstance && "name" in value && value["name"] !== undefined; + + return isInstance; +} + +export function CreateUserDeveloperAppRequestBodyFromJSON(json: any): CreateUserDeveloperAppRequestBody { + return CreateUserDeveloperAppRequestBodyFromJSONTyped(json, false); +} + +export function CreateUserDeveloperAppRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserDeveloperAppRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + }; +} + +export function CreateUserDeveloperAppRequestBodyToJSON(value?: CreateUserDeveloperAppRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppResponse.ts new file mode 100644 index 00000000000..b7ad26eed83 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppResponse.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateUserDeveloperAppResponse + */ +export interface CreateUserDeveloperAppResponse { + /** + * The API key (address) for the developer app + * @type {string} + * @memberof CreateUserDeveloperAppResponse + */ + apiKey?: string; + /** + * The API secret (access key) for the developer app + * @type {string} + * @memberof CreateUserDeveloperAppResponse + */ + apiSecret?: string; + /** + * Transaction hash of the creation + * @type {string} + * @memberof CreateUserDeveloperAppResponse + */ + transactionHash?: string; +} + +/** + * Check if a given object implements the CreateUserDeveloperAppResponse interface. + */ +export function instanceOfCreateUserDeveloperAppResponse(value: object): value is CreateUserDeveloperAppResponse { + let isInstance = true; + + return isInstance; +} + +export function CreateUserDeveloperAppResponseFromJSON(json: any): CreateUserDeveloperAppResponse { + return CreateUserDeveloperAppResponseFromJSONTyped(json, false); +} + +export function CreateUserDeveloperAppResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserDeveloperAppResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'apiKey': !exists(json, 'api_key') ? undefined : json['api_key'], + 'apiSecret': !exists(json, 'api_secret') ? undefined : json['api_secret'], + 'transactionHash': !exists(json, 'transaction_hash') ? undefined : json['transaction_hash'], + }; +} + +export function CreateUserDeveloperAppResponseToJSON(value?: CreateUserDeveloperAppResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'api_key': value.apiKey, + 'api_secret': value.apiSecret, + 'transaction_hash': value.transactionHash, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts new file mode 100644 index 00000000000..90f081c8d6b --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts @@ -0,0 +1,214 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateUserRequestBody + */ +export interface CreateUserRequestBody { + /** + * Optional user ID (will be generated if not provided) + * @type {string} + * @memberof CreateUserRequestBody + */ + userId?: string; + /** + * User handle (unique username) + * @type {string} + * @memberof CreateUserRequestBody + */ + handle: string; + /** + * Wallet address (required) + * @type {string} + * @memberof CreateUserRequestBody + */ + wallet: string; + /** + * Display name + * @type {string} + * @memberof CreateUserRequestBody + */ + name?: string; + /** + * User bio + * @type {string} + * @memberof CreateUserRequestBody + */ + bio?: string; + /** + * User location + * @type {string} + * @memberof CreateUserRequestBody + */ + location?: string; + /** + * Website URL + * @type {string} + * @memberof CreateUserRequestBody + */ + website?: string; + /** + * Donation link + * @type {string} + * @memberof CreateUserRequestBody + */ + donation?: string; + /** + * Twitter handle (without @) + * @type {string} + * @memberof CreateUserRequestBody + */ + twitterHandle?: string; + /** + * Instagram handle (without @) + * @type {string} + * @memberof CreateUserRequestBody + */ + instagramHandle?: string; + /** + * TikTok handle (without @) + * @type {string} + * @memberof CreateUserRequestBody + */ + tiktokHandle?: string; + /** + * Profile picture CID or URL + * @type {string} + * @memberof CreateUserRequestBody + */ + profilePicture?: string; + /** + * Profile picture sizes metadata + * @type {string} + * @memberof CreateUserRequestBody + */ + profilePictureSizes?: string; + /** + * Cover photo CID or URL + * @type {string} + * @memberof CreateUserRequestBody + */ + coverPhoto?: string; + /** + * Cover photo sizes metadata + * @type {string} + * @memberof CreateUserRequestBody + */ + coverPhotoSizes?: string; + /** + * Type of profile (e.g., 'label' for record labels) + * @type {string} + * @memberof CreateUserRequestBody + */ + profileType?: CreateUserRequestBodyProfileTypeEnum; + /** + * Whether to allow AI attribution + * @type {boolean} + * @memberof CreateUserRequestBody + */ + allowAiAttribution?: boolean; + /** + * Solana USDC payout wallet address + * @type {string} + * @memberof CreateUserRequestBody + */ + splUsdcPayoutWallet?: string; +} + + +/** + * @export + */ +export const CreateUserRequestBodyProfileTypeEnum = { + Label: 'label' +} as const; +export type CreateUserRequestBodyProfileTypeEnum = typeof CreateUserRequestBodyProfileTypeEnum[keyof typeof CreateUserRequestBodyProfileTypeEnum]; + + +/** + * Check if a given object implements the CreateUserRequestBody interface. + */ +export function instanceOfCreateUserRequestBody(value: object): value is CreateUserRequestBody { + let isInstance = true; + isInstance = isInstance && "handle" in value && value["handle"] !== undefined; + isInstance = isInstance && "wallet" in value && value["wallet"] !== undefined; + + return isInstance; +} + +export function CreateUserRequestBodyFromJSON(json: any): CreateUserRequestBody { + return CreateUserRequestBodyFromJSONTyped(json, false); +} + +export function CreateUserRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'userId': !exists(json, 'user_id') ? undefined : json['user_id'], + 'handle': json['handle'], + 'wallet': json['wallet'], + 'name': !exists(json, 'name') ? undefined : json['name'], + 'bio': !exists(json, 'bio') ? undefined : json['bio'], + 'location': !exists(json, 'location') ? undefined : json['location'], + 'website': !exists(json, 'website') ? undefined : json['website'], + 'donation': !exists(json, 'donation') ? undefined : json['donation'], + 'twitterHandle': !exists(json, 'twitter_handle') ? undefined : json['twitter_handle'], + 'instagramHandle': !exists(json, 'instagram_handle') ? undefined : json['instagram_handle'], + 'tiktokHandle': !exists(json, 'tiktok_handle') ? undefined : json['tiktok_handle'], + 'profilePicture': !exists(json, 'profile_picture') ? undefined : json['profile_picture'], + 'profilePictureSizes': !exists(json, 'profile_picture_sizes') ? undefined : json['profile_picture_sizes'], + 'coverPhoto': !exists(json, 'cover_photo') ? undefined : json['cover_photo'], + 'coverPhotoSizes': !exists(json, 'cover_photo_sizes') ? undefined : json['cover_photo_sizes'], + 'profileType': !exists(json, 'profile_type') ? undefined : json['profile_type'], + 'allowAiAttribution': !exists(json, 'allow_ai_attribution') ? undefined : json['allow_ai_attribution'], + 'splUsdcPayoutWallet': !exists(json, 'spl_usdc_payout_wallet') ? undefined : json['spl_usdc_payout_wallet'], + }; +} + +export function CreateUserRequestBodyToJSON(value?: CreateUserRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'user_id': value.userId, + 'handle': value.handle, + 'wallet': value.wallet, + 'name': value.name, + 'bio': value.bio, + 'location': value.location, + 'website': value.website, + 'donation': value.donation, + 'twitter_handle': value.twitterHandle, + 'instagram_handle': value.instagramHandle, + 'tiktok_handle': value.tiktokHandle, + 'profile_picture': value.profilePicture, + 'profile_picture_sizes': value.profilePictureSizes, + 'cover_photo': value.coverPhoto, + 'cover_photo_sizes': value.coverPhotoSizes, + 'profile_type': value.profileType, + 'allow_ai_attribution': value.allowAiAttribution, + 'spl_usdc_payout_wallet': value.splUsdcPayoutWallet, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserResponse.ts new file mode 100644 index 00000000000..fd7dacd1101 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserResponse.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface CreateUserResponse + */ +export interface CreateUserResponse { + /** + * Whether the user was created successfully + * @type {boolean} + * @memberof CreateUserResponse + */ + success?: boolean; + /** + * The blockchain transaction hash + * @type {string} + * @memberof CreateUserResponse + */ + transactionHash?: string; + /** + * The ID of the created user + * @type {string} + * @memberof CreateUserResponse + */ + userId?: string; +} + +/** + * Check if a given object implements the CreateUserResponse interface. + */ +export function instanceOfCreateUserResponse(value: object): value is CreateUserResponse { + let isInstance = true; + + return isInstance; +} + +export function CreateUserResponseFromJSON(json: any): CreateUserResponse { + return CreateUserResponseFromJSONTyped(json, false); +} + +export function CreateUserResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'success': !exists(json, 'success') ? undefined : json['success'], + 'transactionHash': !exists(json, 'transaction_hash') ? undefined : json['transaction_hash'], + 'userId': !exists(json, 'user_id') ? undefined : json['user_id'], + }; +} + +export function CreateUserResponseToJSON(value?: CreateUserResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'success': value.success, + 'transaction_hash': value.transactionHash, + 'user_id': value.userId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyRequestBody.ts new file mode 100644 index 00000000000..f17f20a9e3c --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyRequestBody.ts @@ -0,0 +1,67 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface DeactivateAccessKeyRequestBody + */ +export interface DeactivateAccessKeyRequestBody { + /** + * The bearer token (API access key) to deactivate + * @type {string} + * @memberof DeactivateAccessKeyRequestBody + */ + apiAccessKey: string; +} + +/** + * Check if a given object implements the DeactivateAccessKeyRequestBody interface. + */ +export function instanceOfDeactivateAccessKeyRequestBody(value: object): value is DeactivateAccessKeyRequestBody { + let isInstance = true; + isInstance = isInstance && "apiAccessKey" in value && value["apiAccessKey"] !== undefined; + + return isInstance; +} + +export function DeactivateAccessKeyRequestBodyFromJSON(json: any): DeactivateAccessKeyRequestBody { + return DeactivateAccessKeyRequestBodyFromJSONTyped(json, false); +} + +export function DeactivateAccessKeyRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): DeactivateAccessKeyRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'apiAccessKey': json['api_access_key'], + }; +} + +export function DeactivateAccessKeyRequestBodyToJSON(value?: DeactivateAccessKeyRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'api_access_key': value.apiAccessKey, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyResponse.ts new file mode 100644 index 00000000000..f84110ccc4f --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/DeactivateAccessKeyResponse.ts @@ -0,0 +1,66 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface DeactivateAccessKeyResponse + */ +export interface DeactivateAccessKeyResponse { + /** + * Whether the deactivation was successful + * @type {boolean} + * @memberof DeactivateAccessKeyResponse + */ + success?: boolean; +} + +/** + * Check if a given object implements the DeactivateAccessKeyResponse interface. + */ +export function instanceOfDeactivateAccessKeyResponse(value: object): value is DeactivateAccessKeyResponse { + let isInstance = true; + + return isInstance; +} + +export function DeactivateAccessKeyResponseFromJSON(json: any): DeactivateAccessKeyResponse { + return DeactivateAccessKeyResponseFromJSONTyped(json, false); +} + +export function DeactivateAccessKeyResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): DeactivateAccessKeyResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'success': !exists(json, 'success') ? undefined : json['success'], + }; +} + +export function DeactivateAccessKeyResponseToJSON(value?: DeactivateAccessKeyResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'success': value.success, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/DeveloperApps.ts b/packages/sdk/src/sdk/api/generated/default/models/DeveloperAppsResponse.ts similarity index 64% rename from packages/sdk/src/sdk/api/generated/default/models/DeveloperApps.ts rename to packages/sdk/src/sdk/api/generated/default/models/DeveloperAppsResponse.ts index 7a9b32cae80..efd7e305ef5 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/DeveloperApps.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/DeveloperAppsResponse.ts @@ -24,31 +24,31 @@ import { /** * * @export - * @interface DeveloperApps + * @interface DeveloperAppsResponse */ -export interface DeveloperApps { +export interface DeveloperAppsResponse { /** * * @type {Array} - * @memberof DeveloperApps + * @memberof DeveloperAppsResponse */ data?: Array; } /** - * Check if a given object implements the DeveloperApps interface. + * Check if a given object implements the DeveloperAppsResponse interface. */ -export function instanceOfDeveloperApps(value: object): value is DeveloperApps { +export function instanceOfDeveloperAppsResponse(value: object): value is DeveloperAppsResponse { let isInstance = true; return isInstance; } -export function DeveloperAppsFromJSON(json: any): DeveloperApps { - return DeveloperAppsFromJSONTyped(json, false); +export function DeveloperAppsResponseFromJSON(json: any): DeveloperAppsResponse { + return DeveloperAppsResponseFromJSONTyped(json, false); } -export function DeveloperAppsFromJSONTyped(json: any, ignoreDiscriminator: boolean): DeveloperApps { +export function DeveloperAppsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): DeveloperAppsResponse { if ((json === undefined) || (json === null)) { return json; } @@ -58,7 +58,7 @@ export function DeveloperAppsFromJSONTyped(json: any, ignoreDiscriminator: boole }; } -export function DeveloperAppsToJSON(value?: DeveloperApps | null): any { +export function DeveloperAppsResponseToJSON(value?: DeveloperAppsResponse | null): any { if (value === undefined) { return undefined; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/Genre.ts b/packages/sdk/src/sdk/api/generated/default/models/Genre.ts new file mode 100644 index 00000000000..fd4414aa682 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/Genre.ts @@ -0,0 +1,88 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Music genre + * @export + */ +export const Genre = { + Electronic: 'Electronic', + Rock: 'Rock', + Metal: 'Metal', + Alternative: 'Alternative', + HipHopRap: 'Hip-Hop/Rap', + Experimental: 'Experimental', + Punk: 'Punk', + Folk: 'Folk', + Pop: 'Pop', + Ambient: 'Ambient', + Soundtrack: 'Soundtrack', + World: 'World', + Jazz: 'Jazz', + Acoustic: 'Acoustic', + Funk: 'Funk', + RbSoul: 'R&B/Soul', + Devotional: 'Devotional', + Classical: 'Classical', + Reggae: 'Reggae', + Podcasts: 'Podcasts', + Country: 'Country', + SpokenWord: 'Spoken Word', + Comedy: 'Comedy', + Blues: 'Blues', + Kids: 'Kids', + Audiobooks: 'Audiobooks', + Latin: 'Latin', + LoFi: 'Lo-Fi', + Hyperpop: 'Hyperpop', + Dancehall: 'Dancehall', + Techno: 'Techno', + Trap: 'Trap', + House: 'House', + TechHouse: 'Tech House', + DeepHouse: 'Deep House', + Disco: 'Disco', + Electro: 'Electro', + Jungle: 'Jungle', + ProgressiveHouse: 'Progressive House', + Hardstyle: 'Hardstyle', + GlitchHop: 'Glitch Hop', + Trance: 'Trance', + FutureBass: 'Future Bass', + FutureHouse: 'Future House', + TropicalHouse: 'Tropical House', + Downtempo: 'Downtempo', + DrumBass: 'Drum & Bass', + Dubstep: 'Dubstep', + JerseyClub: 'Jersey Club', + Vaporwave: 'Vaporwave', + Moombahton: 'Moombahton' +} as const; +export type Genre = typeof Genre[keyof typeof Genre]; + + +export function GenreFromJSON(json: any): Genre { + return GenreFromJSONTyped(json, false); +} + +export function GenreFromJSONTyped(json: any, ignoreDiscriminator: boolean): Genre { + return json as Genre; +} + +export function GenreToJSON(value?: Genre | null): any { + return value as any; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/Mood.ts b/packages/sdk/src/sdk/api/generated/default/models/Mood.ts new file mode 100644 index 00000000000..0fe36c425d0 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/Mood.ts @@ -0,0 +1,60 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Music mood + * @export + */ +export const Mood = { + Peaceful: 'Peaceful', + Romantic: 'Romantic', + Sentimental: 'Sentimental', + Tender: 'Tender', + Easygoing: 'Easygoing', + Yearning: 'Yearning', + Sophisticated: 'Sophisticated', + Sensual: 'Sensual', + Cool: 'Cool', + Gritty: 'Gritty', + Melancholy: 'Melancholy', + Serious: 'Serious', + Brooding: 'Brooding', + Fiery: 'Fiery', + Defiant: 'Defiant', + Aggressive: 'Aggressive', + Rowdy: 'Rowdy', + Excited: 'Excited', + Energizing: 'Energizing', + Empowering: 'Empowering', + Stirring: 'Stirring', + Upbeat: 'Upbeat', + Other: 'Other' +} as const; +export type Mood = typeof Mood[keyof typeof Mood]; + + +export function MoodFromJSON(json: any): Mood { + return MoodFromJSONTyped(json, false); +} + +export function MoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): Mood { + return json as Mood; +} + +export function MoodToJSON(value?: Mood | null): any { + return value as any; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/PlaylistAddedTimestamp.ts b/packages/sdk/src/sdk/api/generated/default/models/PlaylistAddedTimestamp.ts index 6a7c21f2856..702afac2f9f 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/PlaylistAddedTimestamp.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/PlaylistAddedTimestamp.ts @@ -21,23 +21,23 @@ import { exists, mapValues } from '../runtime'; */ export interface PlaylistAddedTimestamp { /** - * - * @type {number} + * Track ID + * @type {string} * @memberof PlaylistAddedTimestamp */ - metadataTimestamp: number; + trackId: string; /** - * + * Unix timestamp when track was added * @type {number} * @memberof PlaylistAddedTimestamp */ timestamp: number; /** - * - * @type {string} + * Metadata timestamp + * @type {number} * @memberof PlaylistAddedTimestamp */ - trackId: string; + metadataTimestamp?: number; } /** @@ -45,9 +45,8 @@ export interface PlaylistAddedTimestamp { */ export function instanceOfPlaylistAddedTimestamp(value: object): value is PlaylistAddedTimestamp { let isInstance = true; - isInstance = isInstance && "metadataTimestamp" in value && value["metadataTimestamp"] !== undefined; - isInstance = isInstance && "timestamp" in value && value["timestamp"] !== undefined; isInstance = isInstance && "trackId" in value && value["trackId"] !== undefined; + isInstance = isInstance && "timestamp" in value && value["timestamp"] !== undefined; return isInstance; } @@ -62,9 +61,9 @@ export function PlaylistAddedTimestampFromJSONTyped(json: any, ignoreDiscriminat } return { - 'metadataTimestamp': json['metadata_timestamp'], - 'timestamp': json['timestamp'], 'trackId': json['track_id'], + 'timestamp': json['timestamp'], + 'metadataTimestamp': !exists(json, 'metadata_timestamp') ? undefined : json['metadata_timestamp'], }; } @@ -77,9 +76,9 @@ export function PlaylistAddedTimestampToJSON(value?: PlaylistAddedTimestamp | nu } return { - 'metadata_timestamp': value.metadataTimestamp, - 'timestamp': value.timestamp, 'track_id': value.trackId, + 'timestamp': value.timestamp, + 'metadata_timestamp': value.metadataTimestamp, }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/PrizeClaimRequest.ts b/packages/sdk/src/sdk/api/generated/default/models/PrizeClaimRequestBody.ts similarity index 64% rename from packages/sdk/src/sdk/api/generated/default/models/PrizeClaimRequest.ts rename to packages/sdk/src/sdk/api/generated/default/models/PrizeClaimRequestBody.ts index eba5cc35546..9e4fad05bdb 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/PrizeClaimRequest.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/PrizeClaimRequestBody.ts @@ -17,27 +17,27 @@ import { exists, mapValues } from '../runtime'; /** * * @export - * @interface PrizeClaimRequest + * @interface PrizeClaimRequestBody */ -export interface PrizeClaimRequest { +export interface PrizeClaimRequestBody { /** * The Solana transaction signature for the 2 YAK payment * @type {string} - * @memberof PrizeClaimRequest + * @memberof PrizeClaimRequestBody */ signature: string; /** * The wallet address that sent the transaction * @type {string} - * @memberof PrizeClaimRequest + * @memberof PrizeClaimRequestBody */ wallet: string; } /** - * Check if a given object implements the PrizeClaimRequest interface. + * Check if a given object implements the PrizeClaimRequestBody interface. */ -export function instanceOfPrizeClaimRequest(value: object): value is PrizeClaimRequest { +export function instanceOfPrizeClaimRequestBody(value: object): value is PrizeClaimRequestBody { let isInstance = true; isInstance = isInstance && "signature" in value && value["signature"] !== undefined; isInstance = isInstance && "wallet" in value && value["wallet"] !== undefined; @@ -45,11 +45,11 @@ export function instanceOfPrizeClaimRequest(value: object): value is PrizeClaimR return isInstance; } -export function PrizeClaimRequestFromJSON(json: any): PrizeClaimRequest { - return PrizeClaimRequestFromJSONTyped(json, false); +export function PrizeClaimRequestBodyFromJSON(json: any): PrizeClaimRequestBody { + return PrizeClaimRequestBodyFromJSONTyped(json, false); } -export function PrizeClaimRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): PrizeClaimRequest { +export function PrizeClaimRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PrizeClaimRequestBody { if ((json === undefined) || (json === null)) { return json; } @@ -60,7 +60,7 @@ export function PrizeClaimRequestFromJSONTyped(json: any, ignoreDiscriminator: b }; } -export function PrizeClaimRequestToJSON(value?: PrizeClaimRequest | null): any { +export function PrizeClaimRequestBodyToJSON(value?: PrizeClaimRequestBody | null): any { if (value === undefined) { return undefined; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/TrackDownloadRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/TrackDownloadRequestBody.ts new file mode 100644 index 00000000000..c770d331547 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TrackDownloadRequestBody.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface TrackDownloadRequestBody + */ +export interface TrackDownloadRequestBody { + /** + * City where the download occurred + * @type {string} + * @memberof TrackDownloadRequestBody + */ + city?: string; + /** + * Region where the download occurred + * @type {string} + * @memberof TrackDownloadRequestBody + */ + region?: string; + /** + * Country where the download occurred + * @type {string} + * @memberof TrackDownloadRequestBody + */ + country?: string; +} + +/** + * Check if a given object implements the TrackDownloadRequestBody interface. + */ +export function instanceOfTrackDownloadRequestBody(value: object): value is TrackDownloadRequestBody { + let isInstance = true; + + return isInstance; +} + +export function TrackDownloadRequestBodyFromJSON(json: any): TrackDownloadRequestBody { + return TrackDownloadRequestBodyFromJSONTyped(json, false); +} + +export function TrackDownloadRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrackDownloadRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'city': !exists(json, 'city') ? undefined : json['city'], + 'region': !exists(json, 'region') ? undefined : json['region'], + 'country': !exists(json, 'country') ? undefined : json['country'], + }; +} + +export function TrackDownloadRequestBodyToJSON(value?: TrackDownloadRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'city': value.city, + 'region': value.region, + 'country': value.country, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateCoinRequest.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateCoinRequestBody.ts similarity index 71% rename from packages/sdk/src/sdk/api/generated/default/models/UpdateCoinRequest.ts rename to packages/sdk/src/sdk/api/generated/default/models/UpdateCoinRequestBody.ts index 8da77b0d2e5..b7e984def5c 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdateCoinRequest.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateCoinRequestBody.ts @@ -17,61 +17,61 @@ import { exists, mapValues } from '../runtime'; /** * Request body for updating coin information * @export - * @interface UpdateCoinRequest + * @interface UpdateCoinRequestBody */ -export interface UpdateCoinRequest { +export interface UpdateCoinRequestBody { /** * The description of the coin (max 2500 characters) * @type {string} - * @memberof UpdateCoinRequest + * @memberof UpdateCoinRequestBody */ description?: string; /** * URL for the coin's banner image * @type {string} - * @memberof UpdateCoinRequest + * @memberof UpdateCoinRequestBody */ bannerImageUrl?: string; /** * Generic link URL for the coin * @type {string} - * @memberof UpdateCoinRequest + * @memberof UpdateCoinRequestBody */ link1?: string; /** * Generic link URL for the coin * @type {string} - * @memberof UpdateCoinRequest + * @memberof UpdateCoinRequestBody */ link2?: string; /** * Generic link URL for the coin * @type {string} - * @memberof UpdateCoinRequest + * @memberof UpdateCoinRequestBody */ link3?: string; /** * Generic link URL for the coin * @type {string} - * @memberof UpdateCoinRequest + * @memberof UpdateCoinRequestBody */ link4?: string; } /** - * Check if a given object implements the UpdateCoinRequest interface. + * Check if a given object implements the UpdateCoinRequestBody interface. */ -export function instanceOfUpdateCoinRequest(value: object): value is UpdateCoinRequest { +export function instanceOfUpdateCoinRequestBody(value: object): value is UpdateCoinRequestBody { let isInstance = true; return isInstance; } -export function UpdateCoinRequestFromJSON(json: any): UpdateCoinRequest { - return UpdateCoinRequestFromJSONTyped(json, false); +export function UpdateCoinRequestBodyFromJSON(json: any): UpdateCoinRequestBody { + return UpdateCoinRequestBodyFromJSONTyped(json, false); } -export function UpdateCoinRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateCoinRequest { +export function UpdateCoinRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateCoinRequestBody { if ((json === undefined) || (json === null)) { return json; } @@ -86,7 +86,7 @@ export function UpdateCoinRequestFromJSONTyped(json: any, ignoreDiscriminator: b }; } -export function UpdateCoinRequestToJSON(value?: UpdateCoinRequest | null): any { +export function UpdateCoinRequestBodyToJSON(value?: UpdateCoinRequestBody | null): any { if (value === undefined) { return undefined; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts new file mode 100644 index 00000000000..405fc89e152 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts @@ -0,0 +1,67 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface UpdateCommentRequestBody + */ +export interface UpdateCommentRequestBody { + /** + * The updated comment text + * @type {string} + * @memberof UpdateCommentRequestBody + */ + body: string; +} + +/** + * Check if a given object implements the UpdateCommentRequestBody interface. + */ +export function instanceOfUpdateCommentRequestBody(value: object): value is UpdateCommentRequestBody { + let isInstance = true; + isInstance = isInstance && "body" in value && value["body"] !== undefined; + + return isInstance; +} + +export function UpdateCommentRequestBodyFromJSON(json: any): UpdateCommentRequestBody { + return UpdateCommentRequestBodyFromJSONTyped(json, false); +} + +export function UpdateCommentRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateCommentRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'body': json['body'], + }; +} + +export function UpdateCommentRequestBodyToJSON(value?: UpdateCommentRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'body': value.body, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateDeveloperAppRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateDeveloperAppRequestBody.ts new file mode 100644 index 00000000000..774dc468da7 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateDeveloperAppRequestBody.ts @@ -0,0 +1,85 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface UpdateDeveloperAppRequestBody + */ +export interface UpdateDeveloperAppRequestBody { + /** + * Developer app name + * @type {string} + * @memberof UpdateDeveloperAppRequestBody + */ + name: string; + /** + * App description + * @type {string} + * @memberof UpdateDeveloperAppRequestBody + */ + description: string; + /** + * App logo/image URL (camelCase) + * @type {string} + * @memberof UpdateDeveloperAppRequestBody + */ + imageUrl: string; +} + +/** + * Check if a given object implements the UpdateDeveloperAppRequestBody interface. + */ +export function instanceOfUpdateDeveloperAppRequestBody(value: object): value is UpdateDeveloperAppRequestBody { + let isInstance = true; + isInstance = isInstance && "name" in value && value["name"] !== undefined; + isInstance = isInstance && "description" in value && value["description"] !== undefined; + isInstance = isInstance && "imageUrl" in value && value["imageUrl"] !== undefined; + + return isInstance; +} + +export function UpdateDeveloperAppRequestBodyFromJSON(json: any): UpdateDeveloperAppRequestBody { + return UpdateDeveloperAppRequestBodyFromJSONTyped(json, false); +} + +export function UpdateDeveloperAppRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateDeveloperAppRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + 'description': json['description'], + 'imageUrl': json['imageUrl'], + }; +} + +export function UpdateDeveloperAppRequestBodyToJSON(value?: UpdateDeveloperAppRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'description': value.description, + 'imageUrl': value.imageUrl, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts new file mode 100644 index 00000000000..71294aca650 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts @@ -0,0 +1,113 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { PlaylistAddedTimestamp } from './PlaylistAddedTimestamp'; +import { + PlaylistAddedTimestampFromJSON, + PlaylistAddedTimestampFromJSONTyped, + PlaylistAddedTimestampToJSON, +} from './PlaylistAddedTimestamp'; + +/** + * Request body for updating playlist information. All fields are optional. + * @export + * @interface UpdatePlaylistRequestBody + */ +export interface UpdatePlaylistRequestBody { + /** + * Playlist or album name + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + playlistName?: string; + /** + * Playlist description + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + description?: string; + /** + * Whether the playlist is private + * @type {boolean} + * @memberof UpdatePlaylistRequestBody + */ + isPrivate?: boolean; + /** + * Array of track IDs to include in the playlist + * @type {Array} + * @memberof UpdatePlaylistRequestBody + */ + playlistContents?: Array; + /** + * URL for playlist artwork + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + artworkUrl?: string; + /** + * Universal Product Code (for albums) + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + upc?: string; +} + +/** + * Check if a given object implements the UpdatePlaylistRequestBody interface. + */ +export function instanceOfUpdatePlaylistRequestBody(value: object): value is UpdatePlaylistRequestBody { + let isInstance = true; + + return isInstance; +} + +export function UpdatePlaylistRequestBodyFromJSON(json: any): UpdatePlaylistRequestBody { + return UpdatePlaylistRequestBodyFromJSONTyped(json, false); +} + +export function UpdatePlaylistRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdatePlaylistRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'playlistName': !exists(json, 'playlist_name') ? undefined : json['playlist_name'], + 'description': !exists(json, 'description') ? undefined : json['description'], + 'isPrivate': !exists(json, 'is_private') ? undefined : json['is_private'], + 'playlistContents': !exists(json, 'playlist_contents') ? undefined : ((json['playlist_contents'] as Array).map(PlaylistAddedTimestampFromJSON)), + 'artworkUrl': !exists(json, 'artwork_url') ? undefined : json['artwork_url'], + 'upc': !exists(json, 'upc') ? undefined : json['upc'], + }; +} + +export function UpdatePlaylistRequestBodyToJSON(value?: UpdatePlaylistRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'playlist_name': value.playlistName, + 'description': value.description, + 'is_private': value.isPrivate, + 'playlist_contents': value.playlistContents === undefined ? undefined : ((value.playlistContents as Array).map(PlaylistAddedTimestampToJSON)), + 'artwork_url': value.artworkUrl, + 'upc': value.upc, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts new file mode 100644 index 00000000000..87e447f7839 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts @@ -0,0 +1,151 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { Genre } from './Genre'; +import { + GenreFromJSON, + GenreFromJSONTyped, + GenreToJSON, +} from './Genre'; +import type { Mood } from './Mood'; +import { + MoodFromJSON, + MoodFromJSONTyped, + MoodToJSON, +} from './Mood'; + +/** + * Request body for updating track information. All fields are optional. + * @export + * @interface UpdateTrackRequestBody + */ +export interface UpdateTrackRequestBody { + /** + * Track title + * @type {string} + * @memberof UpdateTrackRequestBody + */ + title?: string; + /** + * Track description + * @type {string} + * @memberof UpdateTrackRequestBody + */ + description?: string; + /** + * + * @type {Genre} + * @memberof UpdateTrackRequestBody + */ + genre?: Genre; + /** + * + * @type {Mood} + * @memberof UpdateTrackRequestBody + */ + mood?: Mood; + /** + * Comma-separated tags + * @type {string} + * @memberof UpdateTrackRequestBody + */ + tags?: string; + /** + * Track release date + * @type {Date} + * @memberof UpdateTrackRequestBody + */ + releaseDate?: Date; + /** + * International Standard Recording Code + * @type {string} + * @memberof UpdateTrackRequestBody + */ + isrc?: string; + /** + * Whether the track is downloadable + * @type {boolean} + * @memberof UpdateTrackRequestBody + */ + isDownloadable?: boolean; + /** + * Whether the original file is available + * @type {boolean} + * @memberof UpdateTrackRequestBody + */ + isOriginalAvailable?: boolean; + /** + * URL for track artwork + * @type {string} + * @memberof UpdateTrackRequestBody + */ + artworkUrl?: string; +} + +/** + * Check if a given object implements the UpdateTrackRequestBody interface. + */ +export function instanceOfUpdateTrackRequestBody(value: object): value is UpdateTrackRequestBody { + let isInstance = true; + + return isInstance; +} + +export function UpdateTrackRequestBodyFromJSON(json: any): UpdateTrackRequestBody { + return UpdateTrackRequestBodyFromJSONTyped(json, false); +} + +export function UpdateTrackRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateTrackRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'title': !exists(json, 'title') ? undefined : json['title'], + 'description': !exists(json, 'description') ? undefined : json['description'], + 'genre': !exists(json, 'genre') ? undefined : GenreFromJSON(json['genre']), + 'mood': !exists(json, 'mood') ? undefined : MoodFromJSON(json['mood']), + 'tags': !exists(json, 'tags') ? undefined : json['tags'], + 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), + 'isrc': !exists(json, 'isrc') ? undefined : json['isrc'], + 'isDownloadable': !exists(json, 'is_downloadable') ? undefined : json['is_downloadable'], + 'isOriginalAvailable': !exists(json, 'is_original_available') ? undefined : json['is_original_available'], + 'artworkUrl': !exists(json, 'artwork_url') ? undefined : json['artwork_url'], + }; +} + +export function UpdateTrackRequestBodyToJSON(value?: UpdateTrackRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'title': value.title, + 'description': value.description, + 'genre': GenreToJSON(value.genre), + 'mood': MoodToJSON(value.mood), + 'tags': value.tags, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString()), + 'isrc': value.isrc, + 'is_downloadable': value.isDownloadable, + 'is_original_available': value.isOriginalAvailable, + 'artwork_url': value.artworkUrl, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts new file mode 100644 index 00000000000..e82ed821d66 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts @@ -0,0 +1,212 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Request body for updating user profile. All fields are optional. + * @export + * @interface UpdateUserRequestBody + */ +export interface UpdateUserRequestBody { + /** + * Display name + * @type {string} + * @memberof UpdateUserRequestBody + */ + name?: string; + /** + * User bio + * @type {string} + * @memberof UpdateUserRequestBody + */ + bio?: string; + /** + * User location + * @type {string} + * @memberof UpdateUserRequestBody + */ + location?: string; + /** + * Website URL + * @type {string} + * @memberof UpdateUserRequestBody + */ + website?: string; + /** + * Donation link + * @type {string} + * @memberof UpdateUserRequestBody + */ + donation?: string; + /** + * Twitter handle (without @) + * @type {string} + * @memberof UpdateUserRequestBody + */ + twitterHandle?: string; + /** + * Instagram handle (without @) + * @type {string} + * @memberof UpdateUserRequestBody + */ + instagramHandle?: string; + /** + * TikTok handle (without @) + * @type {string} + * @memberof UpdateUserRequestBody + */ + tiktokHandle?: string; + /** + * Profile picture CID or URL + * @type {string} + * @memberof UpdateUserRequestBody + */ + profilePicture?: string; + /** + * Profile picture sizes metadata + * @type {string} + * @memberof UpdateUserRequestBody + */ + profilePictureSizes?: string; + /** + * Cover photo CID or URL + * @type {string} + * @memberof UpdateUserRequestBody + */ + coverPhoto?: string; + /** + * Cover photo sizes metadata + * @type {string} + * @memberof UpdateUserRequestBody + */ + coverPhotoSizes?: string; + /** + * Type of profile (e.g., 'label' for record labels) + * @type {string} + * @memberof UpdateUserRequestBody + */ + profileType?: UpdateUserRequestBodyProfileTypeEnum; + /** + * Whether the user is deactivated + * @type {boolean} + * @memberof UpdateUserRequestBody + */ + isDeactivated?: boolean; + /** + * Track ID to feature as artist pick + * @type {string} + * @memberof UpdateUserRequestBody + */ + artistPickTrackId?: string; + /** + * Whether to allow AI attribution + * @type {boolean} + * @memberof UpdateUserRequestBody + */ + allowAiAttribution?: boolean; + /** + * Solana USDC payout wallet address + * @type {string} + * @memberof UpdateUserRequestBody + */ + splUsdcPayoutWallet?: string; + /** + * Coin flair mint address + * @type {string} + * @memberof UpdateUserRequestBody + */ + coinFlairMint?: string; +} + + +/** + * @export + */ +export const UpdateUserRequestBodyProfileTypeEnum = { + Label: 'label' +} as const; +export type UpdateUserRequestBodyProfileTypeEnum = typeof UpdateUserRequestBodyProfileTypeEnum[keyof typeof UpdateUserRequestBodyProfileTypeEnum]; + + +/** + * Check if a given object implements the UpdateUserRequestBody interface. + */ +export function instanceOfUpdateUserRequestBody(value: object): value is UpdateUserRequestBody { + let isInstance = true; + + return isInstance; +} + +export function UpdateUserRequestBodyFromJSON(json: any): UpdateUserRequestBody { + return UpdateUserRequestBodyFromJSONTyped(json, false); +} + +export function UpdateUserRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateUserRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': !exists(json, 'name') ? undefined : json['name'], + 'bio': !exists(json, 'bio') ? undefined : json['bio'], + 'location': !exists(json, 'location') ? undefined : json['location'], + 'website': !exists(json, 'website') ? undefined : json['website'], + 'donation': !exists(json, 'donation') ? undefined : json['donation'], + 'twitterHandle': !exists(json, 'twitter_handle') ? undefined : json['twitter_handle'], + 'instagramHandle': !exists(json, 'instagram_handle') ? undefined : json['instagram_handle'], + 'tiktokHandle': !exists(json, 'tiktok_handle') ? undefined : json['tiktok_handle'], + 'profilePicture': !exists(json, 'profile_picture') ? undefined : json['profile_picture'], + 'profilePictureSizes': !exists(json, 'profile_picture_sizes') ? undefined : json['profile_picture_sizes'], + 'coverPhoto': !exists(json, 'cover_photo') ? undefined : json['cover_photo'], + 'coverPhotoSizes': !exists(json, 'cover_photo_sizes') ? undefined : json['cover_photo_sizes'], + 'profileType': !exists(json, 'profile_type') ? undefined : json['profile_type'], + 'isDeactivated': !exists(json, 'is_deactivated') ? undefined : json['is_deactivated'], + 'artistPickTrackId': !exists(json, 'artist_pick_track_id') ? undefined : json['artist_pick_track_id'], + 'allowAiAttribution': !exists(json, 'allow_ai_attribution') ? undefined : json['allow_ai_attribution'], + 'splUsdcPayoutWallet': !exists(json, 'spl_usdc_payout_wallet') ? undefined : json['spl_usdc_payout_wallet'], + 'coinFlairMint': !exists(json, 'coin_flair_mint') ? undefined : json['coin_flair_mint'], + }; +} + +export function UpdateUserRequestBodyToJSON(value?: UpdateUserRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'bio': value.bio, + 'location': value.location, + 'website': value.website, + 'donation': value.donation, + 'twitter_handle': value.twitterHandle, + 'instagram_handle': value.instagramHandle, + 'tiktok_handle': value.tiktokHandle, + 'profile_picture': value.profilePicture, + 'profile_picture_sizes': value.profilePictureSizes, + 'cover_photo': value.coverPhoto, + 'cover_photo_sizes': value.coverPhotoSizes, + 'profile_type': value.profileType, + 'is_deactivated': value.isDeactivated, + 'artist_pick_track_id': value.artistPickTrackId, + 'allow_ai_attribution': value.allowAiAttribution, + 'spl_usdc_payout_wallet': value.splUsdcPayoutWallet, + 'coin_flair_mint': value.coinFlairMint, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/WriteResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/WriteResponse.ts new file mode 100644 index 00000000000..c1b54d44354 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/WriteResponse.ts @@ -0,0 +1,74 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface WriteResponse + */ +export interface WriteResponse { + /** + * Whether the operation was successful + * @type {boolean} + * @memberof WriteResponse + */ + success?: boolean; + /** + * The blockchain transaction hash + * @type {string} + * @memberof WriteResponse + */ + transactionHash?: string; +} + +/** + * Check if a given object implements the WriteResponse interface. + */ +export function instanceOfWriteResponse(value: object): value is WriteResponse { + let isInstance = true; + + return isInstance; +} + +export function WriteResponseFromJSON(json: any): WriteResponse { + return WriteResponseFromJSONTyped(json, false); +} + +export function WriteResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): WriteResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'success': !exists(json, 'success') ? undefined : json['success'], + 'transactionHash': !exists(json, 'transaction_hash') ? undefined : json['transaction_hash'], + }; +} + +export function WriteResponseToJSON(value?: WriteResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'success': value.success, + 'transaction_hash': value.transactionHash, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/index.ts b/packages/sdk/src/sdk/api/generated/default/models/index.ts index ee2bfd8033b..1e6edfd1f0e 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/index.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/index.ts @@ -14,7 +14,7 @@ export * from './BestSellingItem'; export * from './BestSellingResponse'; export * from './BlobInfo'; export * from './ChallengeResponse'; -export * from './ClaimRewardsRequest'; +export * from './ClaimRewardsRequestBody'; export * from './ClaimRewardsResponse'; export * from './ClaimRewardsResponseDataInner'; export * from './ClaimedPrize'; @@ -45,17 +45,32 @@ export * from './CommentResponse'; export * from './ConnectedWallets'; export * from './ConnectedWalletsResponse'; export * from './CoverPhoto'; -export * from './CreateCoinRequest'; +export * from './CreateAccessKeyResponse'; +export * from './CreateCoinRequestBody'; export * from './CreateCoinResponse'; export * from './CreateCoinResponseData'; -export * from './CreateRewardCodeRequest'; +export * from './CreateCommentRequestBody'; +export * from './CreateCommentResponse'; +export * from './CreateDeveloperAppRequestBody'; +export * from './CreateDeveloperAppRequestBodyAppSignature'; +export * from './CreatePlaylistRequestBody'; +export * from './CreatePlaylistResponse'; +export * from './CreateRewardCodeRequestBody'; export * from './CreateRewardCodeResponse'; +export * from './CreateTrackRequestBody'; +export * from './CreateTrackResponse'; +export * from './CreateUserDeveloperAppRequestBody'; +export * from './CreateUserDeveloperAppResponse'; +export * from './CreateUserRequestBody'; +export * from './CreateUserResponse'; export * from './DashboardWalletUser'; export * from './DashboardWalletUsersResponse'; +export * from './DeactivateAccessKeyRequestBody'; +export * from './DeactivateAccessKeyResponse'; export * from './DecodedUserToken'; export * from './DeveloperApp'; export * from './DeveloperAppResponse'; -export * from './DeveloperApps'; +export * from './DeveloperAppsResponse'; export * from './EmailAccess'; export * from './EmailAccessResponse'; export * from './Event'; @@ -70,6 +85,7 @@ export * from './FavoritesResponse'; export * from './FollowGate'; export * from './FollowersResponse'; export * from './FollowingResponse'; +export * from './Genre'; export * from './GetChallenges'; export * from './GetSupportedUsers'; export * from './GetSupporters'; @@ -78,6 +94,7 @@ export * from './HistoryResponse'; export * from './ListenCount'; export * from './MediaLink'; export * from './MonthlyAggregatePlay'; +export * from './Mood'; export * from './MutualFollowersResponse'; export * from './NftCollection'; export * from './NftGate'; @@ -88,7 +105,7 @@ export * from './PlaylistResponse'; export * from './PlaylistSearchResult'; export * from './PlaylistTracksResponse'; export * from './PlaylistsResponse'; -export * from './PrizeClaimRequest'; +export * from './PrizeClaimRequestBody'; export * from './PrizeClaimResponse'; export * from './PrizePublic'; export * from './PrizesResponse'; @@ -129,6 +146,7 @@ export * from './TrackArtwork'; export * from './TrackCommentCountResponse'; export * from './TrackCommentNotificationResponse'; export * from './TrackCommentsResponse'; +export * from './TrackDownloadRequestBody'; export * from './TrackElement'; export * from './TrackFavoritesResponse'; export * from './TrackId'; @@ -145,8 +163,13 @@ export * from './TrendingTimesIds'; export * from './UnclaimedIdResponse'; export * from './UndisbursedChallenge'; export * from './UndisbursedChallenges'; -export * from './UpdateCoinRequest'; +export * from './UpdateCoinRequestBody'; export * from './UpdateCoinResponse'; +export * from './UpdateCommentRequestBody'; +export * from './UpdateDeveloperAppRequestBody'; +export * from './UpdatePlaylistRequestBody'; +export * from './UpdateTrackRequestBody'; +export * from './UpdateUserRequestBody'; export * from './User'; export * from './UserCoin'; export * from './UserCoinAccount'; @@ -162,3 +185,4 @@ export * from './UserTrackListenCountsResponse'; export * from './UserTracksRemixedResponse'; export * from './UsersResponse'; export * from './VerifyToken'; +export * from './WriteResponse'; From 12f5970f0a557a7336043bc1c5bcd722b2a2a73b Mon Sep 17 00:00:00 2001 From: Marcus Pasell <3690498+rickyrombo@users.noreply.github.com> Date: Thu, 12 Feb 2026 23:07:52 -0800 Subject: [PATCH 2/9] regenerate --- .../default/.openapi-generator/FILES | 8 +- .../default/apis/DeveloperAppsApi.ts | 291 +----------------- .../generated/default/apis/PlaylistsApi.ts | 16 +- .../api/generated/default/apis/TracksApi.ts | 25 +- .../api/generated/default/apis/UsersApi.ts | 16 +- .../generated/default/models/AccessGate.ts | 105 +++---- .../api/generated/default/models/Comment.ts | 14 +- .../default/models/CommentEntityType.ts | 38 +++ .../models/CreateCommentRequestBody.ts | 17 +- .../models/CreatePlaylistRequestBody.ts | 4 +- .../default/models/CreateTrackRequestBody.ts | 124 +++++++- .../default/models/CreateUserRequestBody.ts | 4 +- .../default/models/ExtendedAccessGate.ts | 14 +- .../default/models/FieldVisibility.ts | 106 +++++++ .../generated/default/models/NftCollection.ts | 129 -------- .../api/generated/default/models/NftGate.ts | 74 ----- .../api/generated/default/models/Playlist.ts | 8 +- .../default/models/RemixParentWrite.ts | 74 +++++ .../generated/default/models/ReplyComment.ts | 14 +- .../generated/default/models/StemCategory.ts | 49 +++ .../generated/default/models/StemParent.ts | 83 +++++ .../sdk/api/generated/default/models/Track.ts | 8 +- .../default/models/TrackElementWrite.ts | 67 ++++ .../models/UpdatePlaylistRequestBody.ts | 60 +++- .../default/models/UpdateTrackRequestBody.ts | 226 ++++++++++++-- .../sdk/api/generated/default/models/index.ts | 8 +- 26 files changed, 928 insertions(+), 654 deletions(-) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/FieldVisibility.ts delete mode 100644 packages/sdk/src/sdk/api/generated/default/models/NftCollection.ts delete mode 100644 packages/sdk/src/sdk/api/generated/default/models/NftGate.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/RemixParentWrite.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/StemCategory.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/StemParent.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts diff --git a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES index eda9d92bfb9..0e60311f3de 100644 --- a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES +++ b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES @@ -54,6 +54,7 @@ models/Collectibles.ts models/CollectiblesResponse.ts models/CollectionActivity.ts models/Comment.ts +models/CommentEntityType.ts models/CommentMention.ts models/CommentNotificationSetting.ts models/CommentRepliesResponse.ts @@ -98,6 +99,7 @@ models/ExtendedTokenGate.ts models/ExtendedUsdcGate.ts models/Favorite.ts models/FavoritesResponse.ts +models/FieldVisibility.ts models/FollowGate.ts models/FollowersResponse.ts models/FollowingResponse.ts @@ -112,8 +114,6 @@ models/MediaLink.ts models/MonthlyAggregatePlay.ts models/Mood.ts models/MutualFollowersResponse.ts -models/NftCollection.ts -models/NftGate.ts models/Playlist.ts models/PlaylistAddedTimestamp.ts models/PlaylistArtwork.ts @@ -130,6 +130,7 @@ models/PurchasersResponse.ts models/RedeemAmountResponse.ts models/RelatedArtistResponse.ts models/RemixParent.ts +models/RemixParentWrite.ts models/RemixedTrackAggregate.ts models/RemixersResponse.ts models/RemixesResponse.ts @@ -145,6 +146,8 @@ models/SalesAggregateResponse.ts models/SalesJsonContent.ts models/SalesJsonResponse.ts models/Stem.ts +models/StemCategory.ts +models/StemParent.ts models/StemsResponse.ts models/StreamUrlResponse.ts models/SubscribersResponse.ts @@ -164,6 +167,7 @@ models/TrackCommentNotificationResponse.ts models/TrackCommentsResponse.ts models/TrackDownloadRequestBody.ts models/TrackElement.ts +models/TrackElementWrite.ts models/TrackFavoritesResponse.ts models/TrackId.ts models/TrackInspect.ts diff --git a/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts index 82197905aab..1af0f3ef8c1 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts @@ -16,34 +16,16 @@ import * as runtime from '../runtime'; import type { - CreateAccessKeyResponse, CreateDeveloperAppRequestBody, - CreateUserDeveloperAppRequestBody, - CreateUserDeveloperAppResponse, - DeactivateAccessKeyRequestBody, - DeactivateAccessKeyResponse, DeveloperAppResponse, - DeveloperAppsResponse, UpdateDeveloperAppRequestBody, WriteResponse, } from '../models'; import { - CreateAccessKeyResponseFromJSON, - CreateAccessKeyResponseToJSON, CreateDeveloperAppRequestBodyFromJSON, CreateDeveloperAppRequestBodyToJSON, - CreateUserDeveloperAppRequestBodyFromJSON, - CreateUserDeveloperAppRequestBodyToJSON, - CreateUserDeveloperAppResponseFromJSON, - CreateUserDeveloperAppResponseToJSON, - DeactivateAccessKeyRequestBodyFromJSON, - DeactivateAccessKeyRequestBodyToJSON, - DeactivateAccessKeyResponseFromJSON, - DeactivateAccessKeyResponseToJSON, DeveloperAppResponseFromJSON, DeveloperAppResponseToJSON, - DeveloperAppsResponseFromJSON, - DeveloperAppsResponseToJSON, UpdateDeveloperAppRequestBodyFromJSON, UpdateDeveloperAppRequestBodyToJSON, WriteResponseFromJSON, @@ -55,41 +37,15 @@ export interface CreateDeveloperAppRequest { createDeveloperAppRequestBody: CreateDeveloperAppRequestBody; } -export interface CreateUserDeveloperAppRequest { - id: string; - createUserDeveloperAppRequestBody: CreateUserDeveloperAppRequestBody; -} - -export interface CreateUserDeveloperAppAccessKeyRequest { - id: string; - address: string; -} - -export interface DeactivateUserDeveloperAppAccessKeyRequest { - id: string; - address: string; - deactivateAccessKeyRequestBody: DeactivateAccessKeyRequestBody; -} - export interface DeleteDeveloperAppRequest { address: string; userId: string; } -export interface DeleteUserDeveloperAppRequest { - id: string; - address: string; -} - -export interface GetDeveloperAppByAPIKeyRequest { +export interface GetDeveloperAppRequest { address: string; } -export interface GetUserDeveloperAppsRequest { - id: string; - include?: GetUserDeveloperAppsIncludeEnum; -} - export interface UpdateDeveloperAppRequest { address: string; userId: string; @@ -154,154 +110,6 @@ export class DeveloperAppsApi extends runtime.BaseAPI { return await response.value(); } - /** - * @hidden - * Create a new developer app (Plans API). Requires OAuth Bearer token with plans app grant. - */ - async createUserDeveloperAppRaw(params: CreateUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.id === null || params.id === undefined) { - throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling createUserDeveloperApp.'); - } - - if (params.createUserDeveloperAppRequestBody === null || params.createUserDeveloperAppRequestBody === undefined) { - throw new runtime.RequiredError('createUserDeveloperAppRequestBody','Required parameter params.createUserDeveloperAppRequestBody was null or undefined when calling createUserDeveloperApp.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); - } - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("BearerAuth", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/users/{id}/developer-apps`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: CreateUserDeveloperAppRequestBodyToJSON(params.createUserDeveloperAppRequestBody), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => CreateUserDeveloperAppResponseFromJSON(jsonValue)); - } - - /** - * Create a new developer app (Plans API). Requires OAuth Bearer token with plans app grant. - */ - async createUserDeveloperApp(params: CreateUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.createUserDeveloperAppRaw(params, initOverrides); - return await response.value(); - } - - /** - * @hidden - * Create a new bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. - */ - async createUserDeveloperAppAccessKeyRaw(params: CreateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.id === null || params.id === undefined) { - throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling createUserDeveloperAppAccessKey.'); - } - - if (params.address === null || params.address === undefined) { - throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling createUserDeveloperAppAccessKey.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); - } - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("BearerAuth", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/users/{id}/developer-apps/{address}/access-keys`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), - method: 'POST', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => CreateAccessKeyResponseFromJSON(jsonValue)); - } - - /** - * Create a new bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. - */ - async createUserDeveloperAppAccessKey(params: CreateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.createUserDeveloperAppAccessKeyRaw(params, initOverrides); - return await response.value(); - } - - /** - * @hidden - * Deactivate a bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. The deactivated token will no longer authenticate requests. - */ - async deactivateUserDeveloperAppAccessKeyRaw(params: DeactivateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.id === null || params.id === undefined) { - throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); - } - - if (params.address === null || params.address === undefined) { - throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); - } - - if (params.deactivateAccessKeyRequestBody === null || params.deactivateAccessKeyRequestBody === undefined) { - throw new runtime.RequiredError('deactivateAccessKeyRequestBody','Required parameter params.deactivateAccessKeyRequestBody was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); - } - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("BearerAuth", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/users/{id}/developer-apps/{address}/access-keys/deactivate`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: DeactivateAccessKeyRequestBodyToJSON(params.deactivateAccessKeyRequestBody), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => DeactivateAccessKeyResponseFromJSON(jsonValue)); - } - - /** - * Deactivate a bearer token (API access key) for a developer app (Plans API). Requires OAuth Bearer token with plans app grant. The deactivated token will no longer authenticate requests. - */ - async deactivateUserDeveloperAppAccessKey(params: DeactivateUserDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.deactivateUserDeveloperAppAccessKeyRaw(params, initOverrides); - return await response.value(); - } - /** * @hidden * Deletes a developer app @@ -352,59 +160,13 @@ export class DeveloperAppsApi extends runtime.BaseAPI { return await response.value(); } - /** - * @hidden - * Delete a developer app (Plans API). Requires OAuth Bearer token with plans app grant. - */ - async deleteUserDeveloperAppRaw(params: DeleteUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.id === null || params.id === undefined) { - throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling deleteUserDeveloperApp.'); - } - - if (params.address === null || params.address === undefined) { - throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deleteUserDeveloperApp.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); - } - if (this.configuration && this.configuration.accessToken) { - const token = this.configuration.accessToken; - const tokenString = await token("BearerAuth", []); - - if (tokenString) { - headerParameters["Authorization"] = `Bearer ${tokenString}`; - } - } - const response = await this.request({ - path: `/users/{id}/developer-apps/{address}`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"address"}}`, encodeURIComponent(String(params.address))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); - } - - /** - * Delete a developer app (Plans API). Requires OAuth Bearer token with plans app grant. - */ - async deleteUserDeveloperApp(params: DeleteUserDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.deleteUserDeveloperAppRaw(params, initOverrides); - return await response.value(); - } - /** * @hidden * Gets developer app matching given address (API key) */ - async getDeveloperAppByAPIKeyRaw(params: GetDeveloperAppByAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async getDeveloperAppRaw(params: GetDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.address === null || params.address === undefined) { - throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling getDeveloperAppByAPIKey.'); + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling getDeveloperApp.'); } const queryParameters: any = {}; @@ -424,43 +186,8 @@ export class DeveloperAppsApi extends runtime.BaseAPI { /** * Gets developer app matching given address (API key) */ - async getDeveloperAppByAPIKey(params: GetDeveloperAppByAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getDeveloperAppByAPIKeyRaw(params, initOverrides); - return await response.value(); - } - - /** - * @hidden - * Get developer apps for the user (Plans API). Requires OAuth. - */ - async getUserDeveloperAppsRaw(params: GetUserDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.id === null || params.id === undefined) { - throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling getUserDeveloperApps.'); - } - - const queryParameters: any = {}; - - if (params.include !== undefined) { - queryParameters['include'] = params.include; - } - - const headerParameters: runtime.HTTPHeaders = {}; - - const response = await this.request({ - path: `/users/{id}/developer-apps`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => DeveloperAppsResponseFromJSON(jsonValue)); - } - - /** - * Get developer apps for the user (Plans API). Requires OAuth. - */ - async getUserDeveloperApps(params: GetUserDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getUserDeveloperAppsRaw(params, initOverrides); + async getDeveloperApp(params: GetDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getDeveloperAppRaw(params, initOverrides); return await response.value(); } @@ -522,11 +249,3 @@ export class DeveloperAppsApi extends runtime.BaseAPI { } } - -/** - * @export - */ -export const GetUserDeveloperAppsIncludeEnum = { - Metrics: 'metrics' -} as const; -export type GetUserDeveloperAppsIncludeEnum = typeof GetUserDeveloperAppsIncludeEnum[keyof typeof GetUserDeveloperAppsIncludeEnum]; diff --git a/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts index b829d47a5c8..02a0565204e 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts @@ -49,7 +49,7 @@ import { export interface CreatePlaylistRequest { userId: string; - createPlaylistRequestBody: CreatePlaylistRequestBody; + metadata: CreatePlaylistRequestBody; } export interface DeletePlaylistRequest { @@ -131,7 +131,7 @@ export interface UnrepostPlaylistRequest { export interface UpdatePlaylistRequest { playlistId: string; userId: string; - updatePlaylistRequestBody: UpdatePlaylistRequestBody; + metadata: UpdatePlaylistRequestBody; } /** @@ -148,8 +148,8 @@ export class PlaylistsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createPlaylist.'); } - if (params.createPlaylistRequestBody === null || params.createPlaylistRequestBody === undefined) { - throw new runtime.RequiredError('createPlaylistRequestBody','Required parameter params.createPlaylistRequestBody was null or undefined when calling createPlaylist.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createPlaylist.'); } const queryParameters: any = {}; @@ -178,7 +178,7 @@ export class PlaylistsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreatePlaylistRequestBodyToJSON(params.createPlaylistRequestBody), + body: CreatePlaylistRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreatePlaylistResponseFromJSON(jsonValue)); @@ -794,8 +794,8 @@ export class PlaylistsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updatePlaylist.'); } - if (params.updatePlaylistRequestBody === null || params.updatePlaylistRequestBody === undefined) { - throw new runtime.RequiredError('updatePlaylistRequestBody','Required parameter params.updatePlaylistRequestBody was null or undefined when calling updatePlaylist.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling updatePlaylist.'); } const queryParameters: any = {}; @@ -824,7 +824,7 @@ export class PlaylistsApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: UpdatePlaylistRequestBodyToJSON(params.updatePlaylistRequestBody), + body: UpdatePlaylistRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts index 74fe66c180a..b3e02c3e47e 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts @@ -88,7 +88,7 @@ import { export interface CreateTrackRequest { userId: string; - createTrackRequestBody: CreateTrackRequestBody; + metadata: CreateTrackRequestBody; } export interface DeleteTrackRequest { @@ -328,6 +328,7 @@ export interface SearchTracksRequest { export interface ShareTrackRequest { trackId: string; + userId: string; } export interface StreamTrackRequest { @@ -356,7 +357,7 @@ export interface UnrepostTrackRequest { export interface UpdateTrackRequest { trackId: string; userId: string; - updateTrackRequestBody: UpdateTrackRequestBody; + metadata: UpdateTrackRequestBody; } /** @@ -373,8 +374,8 @@ export class TracksApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createTrack.'); } - if (params.createTrackRequestBody === null || params.createTrackRequestBody === undefined) { - throw new runtime.RequiredError('createTrackRequestBody','Required parameter params.createTrackRequestBody was null or undefined when calling createTrack.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createTrack.'); } const queryParameters: any = {}; @@ -403,7 +404,7 @@ export class TracksApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateTrackRequestBodyToJSON(params.createTrackRequestBody), + body: CreateTrackRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateTrackResponseFromJSON(jsonValue)); @@ -1940,8 +1941,16 @@ export class TracksApi extends runtime.BaseAPI { throw new runtime.RequiredError('trackId','Required parameter params.trackId was null or undefined when calling shareTrack.'); } + if (params.userId === null || params.userId === undefined) { + throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling shareTrack.'); + } + const queryParameters: any = {}; + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { @@ -2155,8 +2164,8 @@ export class TracksApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateTrack.'); } - if (params.updateTrackRequestBody === null || params.updateTrackRequestBody === undefined) { - throw new runtime.RequiredError('updateTrackRequestBody','Required parameter params.updateTrackRequestBody was null or undefined when calling updateTrack.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling updateTrack.'); } const queryParameters: any = {}; @@ -2185,7 +2194,7 @@ export class TracksApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: UpdateTrackRequestBodyToJSON(params.updateTrackRequestBody), + body: UpdateTrackRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts index 96499586e0f..3d865f01bb1 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts @@ -157,7 +157,7 @@ import { export interface CreateUserRequest { userId: string; - createUserRequestBody: CreateUserRequestBody; + metadata: CreateUserRequestBody; } export interface CreateUserDeveloperAppRequest { @@ -532,7 +532,7 @@ export interface UnsubscribeFromUserRequest { export interface UpdateUserRequest { id: string; userId: string; - updateUserRequestBody: UpdateUserRequestBody; + metadata: UpdateUserRequestBody; } export interface VerifyIDTokenRequest { @@ -553,8 +553,8 @@ export class UsersApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createUser.'); } - if (params.createUserRequestBody === null || params.createUserRequestBody === undefined) { - throw new runtime.RequiredError('createUserRequestBody','Required parameter params.createUserRequestBody was null or undefined when calling createUser.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createUser.'); } const queryParameters: any = {}; @@ -583,7 +583,7 @@ export class UsersApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateUserRequestBodyToJSON(params.createUserRequestBody), + body: CreateUserRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateUserResponseFromJSON(jsonValue)); @@ -3032,8 +3032,8 @@ export class UsersApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateUser.'); } - if (params.updateUserRequestBody === null || params.updateUserRequestBody === undefined) { - throw new runtime.RequiredError('updateUserRequestBody','Required parameter params.updateUserRequestBody was null or undefined when calling updateUser.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling updateUser.'); } const queryParameters: any = {}; @@ -3054,7 +3054,7 @@ export class UsersApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: UpdateUserRequestBodyToJSON(params.updateUserRequestBody), + body: UpdateUserRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/models/AccessGate.ts b/packages/sdk/src/sdk/api/generated/default/models/AccessGate.ts index 7d7f6f17403..283722cfa35 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/AccessGate.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/AccessGate.ts @@ -13,66 +13,41 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; -import type { ExtendedPurchaseGate } from './ExtendedPurchaseGate'; import { + ExtendedPurchaseGate, + instanceOfExtendedPurchaseGate, ExtendedPurchaseGateFromJSON, ExtendedPurchaseGateFromJSONTyped, ExtendedPurchaseGateToJSON, } from './ExtendedPurchaseGate'; -import type { ExtendedTokenGate } from './ExtendedTokenGate'; import { - ExtendedTokenGateFromJSON, - ExtendedTokenGateFromJSONTyped, - ExtendedTokenGateToJSON, -} from './ExtendedTokenGate'; + FollowGate, + instanceOfFollowGate, + FollowGateFromJSON, + FollowGateFromJSONTyped, + FollowGateToJSON, +} from './FollowGate'; +import { + TipGate, + instanceOfTipGate, + TipGateFromJSON, + TipGateFromJSONTyped, + TipGateToJSON, +} from './TipGate'; +import { + TokenGate, + instanceOfTokenGate, + TokenGateFromJSON, + TokenGateFromJSONTyped, + TokenGateToJSON, +} from './TokenGate'; /** + * @type AccessGate * * @export - * @interface AccessGate */ -export interface AccessGate { - /** - * - * @type {ExtendedPurchaseGate} - * @memberof AccessGate - */ - usdcPurchase?: ExtendedPurchaseGate; - /** - * - * @type {number} - * @memberof AccessGate - */ - followUserId?: number; - /** - * - * @type {number} - * @memberof AccessGate - */ - tipUserId?: number; - /** - * - * @type {object} - * @memberof AccessGate - */ - nftCollection?: object; - /** - * - * @type {ExtendedTokenGate} - * @memberof AccessGate - */ - tokenGate?: ExtendedTokenGate; -} - -/** - * Check if a given object implements the AccessGate interface. - */ -export function instanceOfAccessGate(value: object): value is AccessGate { - let isInstance = true; - - return isInstance; -} +export type AccessGate = ExtendedPurchaseGate | FollowGate | TipGate | TokenGate; export function AccessGateFromJSON(json: any): AccessGate { return AccessGateFromJSONTyped(json, false); @@ -82,14 +57,7 @@ export function AccessGateFromJSONTyped(json: any, ignoreDiscriminator: boolean) if ((json === undefined) || (json === null)) { return json; } - return { - - 'usdcPurchase': !exists(json, 'usdc_purchase') ? undefined : ExtendedPurchaseGateFromJSON(json['usdc_purchase']), - 'followUserId': !exists(json, 'follow_user_id') ? undefined : json['follow_user_id'], - 'tipUserId': !exists(json, 'tip_user_id') ? undefined : json['tip_user_id'], - 'nftCollection': !exists(json, 'nft_collection') ? undefined : json['nft_collection'], - 'tokenGate': !exists(json, 'token_gate') ? undefined : ExtendedTokenGateFromJSON(json['token_gate']), - }; + return { ...ExtendedPurchaseGateFromJSONTyped(json, true), ...FollowGateFromJSONTyped(json, true), ...TipGateFromJSONTyped(json, true), ...TokenGateFromJSONTyped(json, true) }; } export function AccessGateToJSON(value?: AccessGate | null): any { @@ -99,13 +67,20 @@ export function AccessGateToJSON(value?: AccessGate | null): any { if (value === null) { return null; } - return { - - 'usdc_purchase': ExtendedPurchaseGateToJSON(value.usdcPurchase), - 'follow_user_id': value.followUserId, - 'tip_user_id': value.tipUserId, - 'nft_collection': value.nftCollection, - 'token_gate': ExtendedTokenGateToJSON(value.tokenGate), - }; + + if (instanceOfExtendedPurchaseGate(value)) { + return ExtendedPurchaseGateToJSON(value as ExtendedPurchaseGate); + } + if (instanceOfFollowGate(value)) { + return FollowGateToJSON(value as FollowGate); + } + if (instanceOfTipGate(value)) { + return TipGateToJSON(value as TipGate); + } + if (instanceOfTokenGate(value)) { + return TokenGateToJSON(value as TokenGate); + } + + return {}; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/Comment.ts b/packages/sdk/src/sdk/api/generated/default/models/Comment.ts index d8d97d2748e..bb2296d91ca 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/Comment.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/Comment.ts @@ -14,6 +14,12 @@ */ import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; import type { CommentMention } from './CommentMention'; import { CommentMentionFromJSON, @@ -47,10 +53,10 @@ export interface Comment { entityId: string; /** * - * @type {string} + * @type {CommentEntityType} * @memberof Comment */ - entityType: string; + entityType: CommentEntityType; /** * * @type {string} @@ -172,7 +178,7 @@ export function CommentFromJSONTyped(json: any, ignoreDiscriminator: boolean): C 'id': json['id'], 'entityId': json['entity_id'], - 'entityType': json['entity_type'], + 'entityType': CommentEntityTypeFromJSON(json['entity_type']), 'userId': !exists(json, 'user_id') ? undefined : json['user_id'], 'message': json['message'], 'mentions': !exists(json, 'mentions') ? undefined : ((json['mentions'] as Array).map(CommentMentionFromJSON)), @@ -202,7 +208,7 @@ export function CommentToJSON(value?: Comment | null): any { 'id': value.id, 'entity_id': value.entityId, - 'entity_type': value.entityType, + 'entity_type': CommentEntityTypeToJSON(value.entityType), 'user_id': value.userId, 'message': value.message, 'mentions': value.mentions === undefined ? undefined : ((value.mentions as Array).map(CommentMentionToJSON)), diff --git a/packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts b/packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts new file mode 100644 index 00000000000..de4afdece48 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts @@ -0,0 +1,38 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Type of entity that can be commented on + * @export + */ +export const CommentEntityType = { + Track: 'Track' +} as const; +export type CommentEntityType = typeof CommentEntityType[keyof typeof CommentEntityType]; + + +export function CommentEntityTypeFromJSON(json: any): CommentEntityType { + return CommentEntityTypeFromJSONTyped(json, false); +} + +export function CommentEntityTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): CommentEntityType { + return json as CommentEntityType; +} + +export function CommentEntityTypeToJSON(value?: CommentEntityType | null): any { + return value as any; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts index 84d7b9772bf..810de0a90bd 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts @@ -14,6 +14,13 @@ */ import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; + /** * * @export @@ -21,11 +28,11 @@ import { exists, mapValues } from '../runtime'; */ export interface CreateCommentRequestBody { /** - * Type of entity being commented on - * @type {string} + * + * @type {CommentEntityType} * @memberof CreateCommentRequestBody */ - entityType: string; + entityType: CommentEntityType; /** * ID of the entity being commented on * @type {string} @@ -74,7 +81,7 @@ export function CreateCommentRequestBodyFromJSONTyped(json: any, ignoreDiscrimin } return { - 'entityType': json['entityType'], + 'entityType': CommentEntityTypeFromJSON(json['entityType']), 'entityId': json['entityId'], 'body': json['body'], 'commentId': !exists(json, 'commentId') ? undefined : json['commentId'], @@ -91,7 +98,7 @@ export function CreateCommentRequestBodyToJSON(value?: CreateCommentRequestBody } return { - 'entityType': value.entityType, + 'entityType': CommentEntityTypeToJSON(value.entityType), 'entityId': value.entityId, 'body': value.body, 'commentId': value.commentId, diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts index 93e137da69f..7d785fbb972 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts @@ -41,10 +41,10 @@ import { export interface CreatePlaylistRequestBody { /** * Optional playlist ID (will be generated if not provided) - * @type {string} + * @type {number} * @memberof CreatePlaylistRequestBody */ - playlistId?: string; + playlistId?: number; /** * Playlist or album name * @type {string} diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts index efe471919fc..56464ce5f51 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts @@ -14,6 +14,18 @@ */ import { exists, mapValues } from '../runtime'; +import type { AccessGate } from './AccessGate'; +import { + AccessGateFromJSON, + AccessGateFromJSONTyped, + AccessGateToJSON, +} from './AccessGate'; +import type { FieldVisibility } from './FieldVisibility'; +import { + FieldVisibilityFromJSON, + FieldVisibilityFromJSONTyped, + FieldVisibilityToJSON, +} from './FieldVisibility'; import type { Genre } from './Genre'; import { GenreFromJSON, @@ -26,6 +38,18 @@ import { MoodFromJSONTyped, MoodToJSON, } from './Mood'; +import type { RemixParentWrite } from './RemixParentWrite'; +import { + RemixParentWriteFromJSON, + RemixParentWriteFromJSONTyped, + RemixParentWriteToJSON, +} from './RemixParentWrite'; +import type { StemParent } from './StemParent'; +import { + StemParentFromJSON, + StemParentFromJSONTyped, + StemParentToJSON, +} from './StemParent'; /** * @@ -35,10 +59,10 @@ import { export interface CreateTrackRequestBody { /** * Optional track ID (will be generated if not provided) - * @type {string} + * @type {number} * @memberof CreateTrackRequestBody */ - trackId?: string; + trackId?: number; /** * Track title * @type {string} @@ -63,6 +87,18 @@ export interface CreateTrackRequestBody { * @memberof CreateTrackRequestBody */ mood?: Mood; + /** + * Beats per minute (tempo) + * @type {number} + * @memberof CreateTrackRequestBody + */ + bpm?: number; + /** + * Musical key of the track + * @type {string} + * @memberof CreateTrackRequestBody + */ + musicalKey?: string; /** * Comma-separated tags * @type {string} @@ -89,22 +125,40 @@ export interface CreateTrackRequestBody { iswc?: string; /** * Release date - * @type {string} + * @type {Date} * @memberof CreateTrackRequestBody */ - releaseDate?: string; + releaseDate?: Date; /** * IPFS CID for the track audio file (required) * @type {string} * @memberof CreateTrackRequestBody */ trackCid: string; + /** + * IPFS CID for the original track file + * @type {string} + * @memberof CreateTrackRequestBody + */ + origFileCid?: string; + /** + * Original filename of the track + * @type {string} + * @memberof CreateTrackRequestBody + */ + origFilename?: string; /** * IPFS CID for cover art * @type {string} * @memberof CreateTrackRequestBody */ coverArtCid?: string; + /** + * Cover art sizes metadata + * @type {string} + * @memberof CreateTrackRequestBody + */ + coverArtSizes?: string; /** * IPFS CID for the track preview * @type {string} @@ -135,6 +189,42 @@ export interface CreateTrackRequestBody { * @memberof CreateTrackRequestBody */ isUnlisted?: boolean; + /** + * + * @type {AccessGate} + * @memberof CreateTrackRequestBody + */ + streamConditions?: AccessGate; + /** + * + * @type {AccessGate} + * @memberof CreateTrackRequestBody + */ + downloadConditions?: AccessGate; + /** + * + * @type {FieldVisibility} + * @memberof CreateTrackRequestBody + */ + fieldVisibility?: FieldVisibility; + /** + * Placement hosts for the track + * @type {string} + * @memberof CreateTrackRequestBody + */ + placementHosts?: string; + /** + * + * @type {StemParent} + * @memberof CreateTrackRequestBody + */ + stemOf?: StemParent; + /** + * + * @type {RemixParentWrite} + * @memberof CreateTrackRequestBody + */ + remixOf?: RemixParentWrite; /** * DDEX application identifier * @type {string} @@ -176,18 +266,29 @@ export function CreateTrackRequestBodyFromJSONTyped(json: any, ignoreDiscriminat 'genre': GenreFromJSON(json['genre']), 'description': !exists(json, 'description') ? undefined : json['description'], 'mood': !exists(json, 'mood') ? undefined : MoodFromJSON(json['mood']), + 'bpm': !exists(json, 'bpm') ? undefined : json['bpm'], + 'musicalKey': !exists(json, 'musical_key') ? undefined : json['musical_key'], 'tags': !exists(json, 'tags') ? undefined : json['tags'], 'license': !exists(json, 'license') ? undefined : json['license'], 'isrc': !exists(json, 'isrc') ? undefined : json['isrc'], 'iswc': !exists(json, 'iswc') ? undefined : json['iswc'], - 'releaseDate': !exists(json, 'release_date') ? undefined : json['release_date'], + 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), 'trackCid': json['track_cid'], + 'origFileCid': !exists(json, 'orig_file_cid') ? undefined : json['orig_file_cid'], + 'origFilename': !exists(json, 'orig_filename') ? undefined : json['orig_filename'], 'coverArtCid': !exists(json, 'cover_art_cid') ? undefined : json['cover_art_cid'], + 'coverArtSizes': !exists(json, 'cover_art_sizes') ? undefined : json['cover_art_sizes'], 'previewCid': !exists(json, 'preview_cid') ? undefined : json['preview_cid'], 'previewStartSeconds': !exists(json, 'preview_start_seconds') ? undefined : json['preview_start_seconds'], 'duration': !exists(json, 'duration') ? undefined : json['duration'], 'downloadable': !exists(json, 'downloadable') ? undefined : json['downloadable'], 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], + 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), + 'downloadConditions': !exists(json, 'download_conditions') ? undefined : AccessGateFromJSON(json['download_conditions']), + 'fieldVisibility': !exists(json, 'field_visibility') ? undefined : FieldVisibilityFromJSON(json['field_visibility']), + 'placementHosts': !exists(json, 'placement_hosts') ? undefined : json['placement_hosts'], + 'stemOf': !exists(json, 'stem_of') ? undefined : StemParentFromJSON(json['stem_of']), + 'remixOf': !exists(json, 'remix_of') ? undefined : RemixParentWriteFromJSON(json['remix_of']), 'ddexApp': !exists(json, 'ddex_app') ? undefined : json['ddex_app'], 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], }; @@ -207,18 +308,29 @@ export function CreateTrackRequestBodyToJSON(value?: CreateTrackRequestBody | nu 'genre': GenreToJSON(value.genre), 'description': value.description, 'mood': MoodToJSON(value.mood), + 'bpm': value.bpm, + 'musical_key': value.musicalKey, 'tags': value.tags, 'license': value.license, 'isrc': value.isrc, 'iswc': value.iswc, - 'release_date': value.releaseDate, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString().substr(0,10)), 'track_cid': value.trackCid, + 'orig_file_cid': value.origFileCid, + 'orig_filename': value.origFilename, 'cover_art_cid': value.coverArtCid, + 'cover_art_sizes': value.coverArtSizes, 'preview_cid': value.previewCid, 'preview_start_seconds': value.previewStartSeconds, 'duration': value.duration, 'downloadable': value.downloadable, 'is_unlisted': value.isUnlisted, + 'stream_conditions': AccessGateToJSON(value.streamConditions), + 'download_conditions': AccessGateToJSON(value.downloadConditions), + 'field_visibility': FieldVisibilityToJSON(value.fieldVisibility), + 'placement_hosts': value.placementHosts, + 'stem_of': StemParentToJSON(value.stemOf), + 'remix_of': RemixParentWriteToJSON(value.remixOf), 'ddex_app': value.ddexApp, 'parental_warning_type': value.parentalWarningType, }; diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts index 90f081c8d6b..2f6c6156aba 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts @@ -22,10 +22,10 @@ import { exists, mapValues } from '../runtime'; export interface CreateUserRequestBody { /** * Optional user ID (will be generated if not provided) - * @type {string} + * @type {number} * @memberof CreateUserRequestBody */ - userId?: string; + userId?: number; /** * User handle (unique username) * @type {string} diff --git a/packages/sdk/src/sdk/api/generated/default/models/ExtendedAccessGate.ts b/packages/sdk/src/sdk/api/generated/default/models/ExtendedAccessGate.ts index a8797915fa3..81efdc83724 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/ExtendedAccessGate.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/ExtendedAccessGate.ts @@ -27,13 +27,6 @@ import { FollowGateFromJSONTyped, FollowGateToJSON, } from './FollowGate'; -import { - NftGate, - instanceOfNftGate, - NftGateFromJSON, - NftGateFromJSONTyped, - NftGateToJSON, -} from './NftGate'; import { TipGate, instanceOfTipGate, @@ -54,7 +47,7 @@ import { * * @export */ -export type ExtendedAccessGate = ExtendedPurchaseGate | FollowGate | NftGate | TipGate | TokenGate; +export type ExtendedAccessGate = ExtendedPurchaseGate | FollowGate | TipGate | TokenGate; export function ExtendedAccessGateFromJSON(json: any): ExtendedAccessGate { return ExtendedAccessGateFromJSONTyped(json, false); @@ -64,7 +57,7 @@ export function ExtendedAccessGateFromJSONTyped(json: any, ignoreDiscriminator: if ((json === undefined) || (json === null)) { return json; } - return { ...ExtendedPurchaseGateFromJSONTyped(json, true), ...FollowGateFromJSONTyped(json, true), ...NftGateFromJSONTyped(json, true), ...TipGateFromJSONTyped(json, true), ...TokenGateFromJSONTyped(json, true) }; + return { ...ExtendedPurchaseGateFromJSONTyped(json, true), ...FollowGateFromJSONTyped(json, true), ...TipGateFromJSONTyped(json, true), ...TokenGateFromJSONTyped(json, true) }; } export function ExtendedAccessGateToJSON(value?: ExtendedAccessGate | null): any { @@ -81,9 +74,6 @@ export function ExtendedAccessGateToJSON(value?: ExtendedAccessGate | null): any if (instanceOfFollowGate(value)) { return FollowGateToJSON(value as FollowGate); } - if (instanceOfNftGate(value)) { - return NftGateToJSON(value as NftGate); - } if (instanceOfTipGate(value)) { return TipGateToJSON(value as TipGate); } diff --git a/packages/sdk/src/sdk/api/generated/default/models/FieldVisibility.ts b/packages/sdk/src/sdk/api/generated/default/models/FieldVisibility.ts new file mode 100644 index 00000000000..2802b489b9f --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/FieldVisibility.ts @@ -0,0 +1,106 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface FieldVisibility + */ +export interface FieldVisibility { + /** + * + * @type {boolean} + * @memberof FieldVisibility + */ + mood?: boolean; + /** + * + * @type {boolean} + * @memberof FieldVisibility + */ + tags?: boolean; + /** + * + * @type {boolean} + * @memberof FieldVisibility + */ + genre?: boolean; + /** + * + * @type {boolean} + * @memberof FieldVisibility + */ + share?: boolean; + /** + * + * @type {boolean} + * @memberof FieldVisibility + */ + playCount?: boolean; + /** + * + * @type {boolean} + * @memberof FieldVisibility + */ + remixes?: boolean; +} + +/** + * Check if a given object implements the FieldVisibility interface. + */ +export function instanceOfFieldVisibility(value: object): value is FieldVisibility { + let isInstance = true; + + return isInstance; +} + +export function FieldVisibilityFromJSON(json: any): FieldVisibility { + return FieldVisibilityFromJSONTyped(json, false); +} + +export function FieldVisibilityFromJSONTyped(json: any, ignoreDiscriminator: boolean): FieldVisibility { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'mood': !exists(json, 'mood') ? undefined : json['mood'], + 'tags': !exists(json, 'tags') ? undefined : json['tags'], + 'genre': !exists(json, 'genre') ? undefined : json['genre'], + 'share': !exists(json, 'share') ? undefined : json['share'], + 'playCount': !exists(json, 'play_count') ? undefined : json['play_count'], + 'remixes': !exists(json, 'remixes') ? undefined : json['remixes'], + }; +} + +export function FieldVisibilityToJSON(value?: FieldVisibility | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'mood': value.mood, + 'tags': value.tags, + 'genre': value.genre, + 'share': value.share, + 'play_count': value.playCount, + 'remixes': value.remixes, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/NftCollection.ts b/packages/sdk/src/sdk/api/generated/default/models/NftCollection.ts deleted file mode 100644 index 9a275dcfbb0..00000000000 --- a/packages/sdk/src/sdk/api/generated/default/models/NftCollection.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @ts-nocheck -/** - * API - * Audius V1 API - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface NftCollection - */ -export interface NftCollection { - /** - * - * @type {string} - * @memberof NftCollection - */ - chain: NftCollectionChainEnum; - /** - * - * @type {string} - * @memberof NftCollection - */ - standard?: NftCollectionStandardEnum; - /** - * - * @type {string} - * @memberof NftCollection - */ - address: string; - /** - * - * @type {string} - * @memberof NftCollection - */ - name: string; - /** - * - * @type {string} - * @memberof NftCollection - */ - imageUrl?: string; - /** - * - * @type {string} - * @memberof NftCollection - */ - externalLink?: string; -} - - -/** - * @export - */ -export const NftCollectionChainEnum = { - Eth: 'eth', - Sol: 'sol' -} as const; -export type NftCollectionChainEnum = typeof NftCollectionChainEnum[keyof typeof NftCollectionChainEnum]; - -/** - * @export - */ -export const NftCollectionStandardEnum = { - Erc721: 'ERC721', - Erc1155: 'ERC1155' -} as const; -export type NftCollectionStandardEnum = typeof NftCollectionStandardEnum[keyof typeof NftCollectionStandardEnum]; - - -/** - * Check if a given object implements the NftCollection interface. - */ -export function instanceOfNftCollection(value: object): value is NftCollection { - let isInstance = true; - isInstance = isInstance && "chain" in value && value["chain"] !== undefined; - isInstance = isInstance && "address" in value && value["address"] !== undefined; - isInstance = isInstance && "name" in value && value["name"] !== undefined; - - return isInstance; -} - -export function NftCollectionFromJSON(json: any): NftCollection { - return NftCollectionFromJSONTyped(json, false); -} - -export function NftCollectionFromJSONTyped(json: any, ignoreDiscriminator: boolean): NftCollection { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'chain': json['chain'], - 'standard': !exists(json, 'standard') ? undefined : json['standard'], - 'address': json['address'], - 'name': json['name'], - 'imageUrl': !exists(json, 'imageUrl') ? undefined : json['imageUrl'], - 'externalLink': !exists(json, 'externalLink') ? undefined : json['externalLink'], - }; -} - -export function NftCollectionToJSON(value?: NftCollection | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'chain': value.chain, - 'standard': value.standard, - 'address': value.address, - 'name': value.name, - 'imageUrl': value.imageUrl, - 'externalLink': value.externalLink, - }; -} - diff --git a/packages/sdk/src/sdk/api/generated/default/models/NftGate.ts b/packages/sdk/src/sdk/api/generated/default/models/NftGate.ts deleted file mode 100644 index fc60b56daad..00000000000 --- a/packages/sdk/src/sdk/api/generated/default/models/NftGate.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @ts-nocheck -/** - * API - * Audius V1 API - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { NftCollection } from './NftCollection'; -import { - NftCollectionFromJSON, - NftCollectionFromJSONTyped, - NftCollectionToJSON, -} from './NftCollection'; - -/** - * - * @export - * @interface NftGate - */ -export interface NftGate { - /** - * Must hold an NFT of the given collection to unlock - * @type {NftCollection} - * @memberof NftGate - */ - nftCollection: NftCollection; -} - -/** - * Check if a given object implements the NftGate interface. - */ -export function instanceOfNftGate(value: object): value is NftGate { - let isInstance = true; - isInstance = isInstance && "nftCollection" in value && value["nftCollection"] !== undefined; - - return isInstance; -} - -export function NftGateFromJSON(json: any): NftGate { - return NftGateFromJSONTyped(json, false); -} - -export function NftGateFromJSONTyped(json: any, ignoreDiscriminator: boolean): NftGate { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'nftCollection': NftCollectionFromJSON(json['nft_collection']), - }; -} - -export function NftGateToJSON(value?: NftGate | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'nft_collection': NftCollectionToJSON(value.nftCollection), - }; -} - diff --git a/packages/sdk/src/sdk/api/generated/default/models/Playlist.ts b/packages/sdk/src/sdk/api/generated/default/models/Playlist.ts index b3dfdcb0e42..4f314b8ffd8 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/Playlist.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/Playlist.ts @@ -275,10 +275,10 @@ export interface Playlist { isScheduledRelease: boolean; /** * - * @type {string} + * @type {Date} * @memberof Playlist */ - releaseDate?: string; + releaseDate?: Date; /** * * @type {object} @@ -389,7 +389,7 @@ export function PlaylistFromJSONTyped(json: any, ignoreDiscriminator: boolean): 'isStreamGated': json['is_stream_gated'], 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), 'isScheduledRelease': json['is_scheduled_release'], - 'releaseDate': !exists(json, 'release_date') ? undefined : json['release_date'], + 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), 'ddexReleaseIds': !exists(json, 'ddex_release_ids') ? undefined : json['ddex_release_ids'], 'artists': !exists(json, 'artists') ? undefined : json['artists'], 'copyrightLine': !exists(json, 'copyright_line') ? undefined : json['copyright_line'], @@ -441,7 +441,7 @@ export function PlaylistToJSON(value?: Playlist | null): any { 'is_stream_gated': value.isStreamGated, 'stream_conditions': AccessGateToJSON(value.streamConditions), 'is_scheduled_release': value.isScheduledRelease, - 'release_date': value.releaseDate, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString().substr(0,10)), 'ddex_release_ids': value.ddexReleaseIds, 'artists': value.artists, 'copyright_line': value.copyrightLine, diff --git a/packages/sdk/src/sdk/api/generated/default/models/RemixParentWrite.ts b/packages/sdk/src/sdk/api/generated/default/models/RemixParentWrite.ts new file mode 100644 index 00000000000..0942b855c60 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/RemixParentWrite.ts @@ -0,0 +1,74 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { TrackElementWrite } from './TrackElementWrite'; +import { + TrackElementWriteFromJSON, + TrackElementWriteFromJSONTyped, + TrackElementWriteToJSON, +} from './TrackElementWrite'; + +/** + * + * @export + * @interface RemixParentWrite + */ +export interface RemixParentWrite { + /** + * + * @type {Array} + * @memberof RemixParentWrite + */ + tracks: Array; +} + +/** + * Check if a given object implements the RemixParentWrite interface. + */ +export function instanceOfRemixParentWrite(value: object): value is RemixParentWrite { + let isInstance = true; + isInstance = isInstance && "tracks" in value && value["tracks"] !== undefined; + + return isInstance; +} + +export function RemixParentWriteFromJSON(json: any): RemixParentWrite { + return RemixParentWriteFromJSONTyped(json, false); +} + +export function RemixParentWriteFromJSONTyped(json: any, ignoreDiscriminator: boolean): RemixParentWrite { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'tracks': ((json['tracks'] as Array).map(TrackElementWriteFromJSON)), + }; +} + +export function RemixParentWriteToJSON(value?: RemixParentWrite | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'tracks': ((value.tracks as Array).map(TrackElementWriteToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/ReplyComment.ts b/packages/sdk/src/sdk/api/generated/default/models/ReplyComment.ts index 972e094a0c2..b4fb76173c4 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/ReplyComment.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/ReplyComment.ts @@ -14,6 +14,12 @@ */ import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; import type { CommentMention } from './CommentMention'; import { CommentMentionFromJSON, @@ -41,10 +47,10 @@ export interface ReplyComment { entityId: string; /** * - * @type {string} + * @type {CommentEntityType} * @memberof ReplyComment */ - entityType: string; + entityType: CommentEntityType; /** * * @type {string} @@ -142,7 +148,7 @@ export function ReplyCommentFromJSONTyped(json: any, ignoreDiscriminator: boolea 'id': json['id'], 'entityId': json['entity_id'], - 'entityType': json['entity_type'], + 'entityType': CommentEntityTypeFromJSON(json['entity_type']), 'userId': json['user_id'], 'message': json['message'], 'mentions': !exists(json, 'mentions') ? undefined : ((json['mentions'] as Array).map(CommentMentionFromJSON)), @@ -168,7 +174,7 @@ export function ReplyCommentToJSON(value?: ReplyComment | null): any { 'id': value.id, 'entity_id': value.entityId, - 'entity_type': value.entityType, + 'entity_type': CommentEntityTypeToJSON(value.entityType), 'user_id': value.userId, 'message': value.message, 'mentions': value.mentions === undefined ? undefined : ((value.mentions as Array).map(CommentMentionToJSON)), diff --git a/packages/sdk/src/sdk/api/generated/default/models/StemCategory.ts b/packages/sdk/src/sdk/api/generated/default/models/StemCategory.ts new file mode 100644 index 00000000000..22c02baf21a --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/StemCategory.ts @@ -0,0 +1,49 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const StemCategory = { + Instrumental: 'INSTRUMENTAL', + LeadVocals: 'LEAD_VOCALS', + MelodicLead: 'MELODIC_LEAD', + Pad: 'PAD', + Snare: 'SNARE', + Kick: 'KICK', + Hihat: 'HIHAT', + Percussion: 'PERCUSSION', + Sample: 'SAMPLE', + BackingVox: 'BACKING_VOX', + Bass: 'BASS', + Other: 'OTHER' +} as const; +export type StemCategory = typeof StemCategory[keyof typeof StemCategory]; + + +export function StemCategoryFromJSON(json: any): StemCategory { + return StemCategoryFromJSONTyped(json, false); +} + +export function StemCategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): StemCategory { + return json as StemCategory; +} + +export function StemCategoryToJSON(value?: StemCategory | null): any { + return value as any; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/StemParent.ts b/packages/sdk/src/sdk/api/generated/default/models/StemParent.ts new file mode 100644 index 00000000000..4d844213e42 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/StemParent.ts @@ -0,0 +1,83 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { StemCategory } from './StemCategory'; +import { + StemCategoryFromJSON, + StemCategoryFromJSONTyped, + StemCategoryToJSON, +} from './StemCategory'; + +/** + * + * @export + * @interface StemParent + */ +export interface StemParent { + /** + * + * @type {StemCategory} + * @memberof StemParent + */ + category: StemCategory; + /** + * + * @type {number} + * @memberof StemParent + */ + parentTrackId: number; +} + +/** + * Check if a given object implements the StemParent interface. + */ +export function instanceOfStemParent(value: object): value is StemParent { + let isInstance = true; + isInstance = isInstance && "category" in value && value["category"] !== undefined; + isInstance = isInstance && "parentTrackId" in value && value["parentTrackId"] !== undefined; + + return isInstance; +} + +export function StemParentFromJSON(json: any): StemParent { + return StemParentFromJSONTyped(json, false); +} + +export function StemParentFromJSONTyped(json: any, ignoreDiscriminator: boolean): StemParent { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'category': StemCategoryFromJSON(json['category']), + 'parentTrackId': json['parent_track_id'], + }; +} + +export function StemParentToJSON(value?: StemParent | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'category': StemCategoryToJSON(value.category), + 'parent_track_id': value.parentTrackId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/Track.ts b/packages/sdk/src/sdk/api/generated/default/models/Track.ts index 2916acb1384..c95aa313041 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/Track.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/Track.ts @@ -125,10 +125,10 @@ export interface Track { mood?: string; /** * - * @type {string} + * @type {Date} * @memberof Track */ - releaseDate?: string; + releaseDate?: Date; /** * * @type {string} @@ -587,7 +587,7 @@ export function TrackFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tra 'origFilename': !exists(json, 'orig_filename') ? undefined : json['orig_filename'], 'isOriginalAvailable': json['is_original_available'], 'mood': !exists(json, 'mood') ? undefined : json['mood'], - 'releaseDate': !exists(json, 'release_date') ? undefined : json['release_date'], + 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), 'isrc': !exists(json, 'isrc') ? undefined : json['isrc'], 'remixOf': !exists(json, 'remix_of') ? undefined : RemixParentFromJSON(json['remix_of']), 'repostCount': json['repost_count'], @@ -679,7 +679,7 @@ export function TrackToJSON(value?: Track | null): any { 'orig_filename': value.origFilename, 'is_original_available': value.isOriginalAvailable, 'mood': value.mood, - 'release_date': value.releaseDate, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString().substr(0,10)), 'isrc': value.isrc, 'remix_of': RemixParentToJSON(value.remixOf), 'repost_count': value.repostCount, diff --git a/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts b/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts new file mode 100644 index 00000000000..1becc276367 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts @@ -0,0 +1,67 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface TrackElementWrite + */ +export interface TrackElementWrite { + /** + * + * @type {number} + * @memberof TrackElementWrite + */ + parentTrackId: number; +} + +/** + * Check if a given object implements the TrackElementWrite interface. + */ +export function instanceOfTrackElementWrite(value: object): value is TrackElementWrite { + let isInstance = true; + isInstance = isInstance && "parentTrackId" in value && value["parentTrackId"] !== undefined; + + return isInstance; +} + +export function TrackElementWriteFromJSON(json: any): TrackElementWrite { + return TrackElementWriteFromJSONTyped(json, false); +} + +export function TrackElementWriteFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrackElementWrite { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'parentTrackId': json['parent_track_id'], + }; +} + +export function TrackElementWriteToJSON(value?: TrackElementWrite | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'parent_track_id': value.parentTrackId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts index 71294aca650..077ae8b0d1f 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts @@ -14,6 +14,18 @@ */ import { exists, mapValues } from '../runtime'; +import type { Genre } from './Genre'; +import { + GenreFromJSON, + GenreFromJSONTyped, + GenreToJSON, +} from './Genre'; +import type { Mood } from './Mood'; +import { + MoodFromJSON, + MoodFromJSONTyped, + MoodToJSON, +} from './Mood'; import type { PlaylistAddedTimestamp } from './PlaylistAddedTimestamp'; import { PlaylistAddedTimestampFromJSON, @@ -45,6 +57,36 @@ export interface UpdatePlaylistRequestBody { * @memberof UpdatePlaylistRequestBody */ isPrivate?: boolean; + /** + * + * @type {Genre} + * @memberof UpdatePlaylistRequestBody + */ + genre?: Genre; + /** + * + * @type {Mood} + * @memberof UpdatePlaylistRequestBody + */ + mood?: Mood; + /** + * Comma-separated tags + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + tags?: string; + /** + * License type + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + license?: string; + /** + * Release date + * @type {Date} + * @memberof UpdatePlaylistRequestBody + */ + releaseDate?: Date; /** * Array of track IDs to include in the playlist * @type {Array} @@ -52,11 +94,11 @@ export interface UpdatePlaylistRequestBody { */ playlistContents?: Array; /** - * URL for playlist artwork + * IPFS CID for cover art * @type {string} * @memberof UpdatePlaylistRequestBody */ - artworkUrl?: string; + coverArtCid?: string; /** * Universal Product Code (for albums) * @type {string} @@ -87,8 +129,13 @@ export function UpdatePlaylistRequestBodyFromJSONTyped(json: any, ignoreDiscrimi 'playlistName': !exists(json, 'playlist_name') ? undefined : json['playlist_name'], 'description': !exists(json, 'description') ? undefined : json['description'], 'isPrivate': !exists(json, 'is_private') ? undefined : json['is_private'], + 'genre': !exists(json, 'genre') ? undefined : GenreFromJSON(json['genre']), + 'mood': !exists(json, 'mood') ? undefined : MoodFromJSON(json['mood']), + 'tags': !exists(json, 'tags') ? undefined : json['tags'], + 'license': !exists(json, 'license') ? undefined : json['license'], + 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), 'playlistContents': !exists(json, 'playlist_contents') ? undefined : ((json['playlist_contents'] as Array).map(PlaylistAddedTimestampFromJSON)), - 'artworkUrl': !exists(json, 'artwork_url') ? undefined : json['artwork_url'], + 'coverArtCid': !exists(json, 'cover_art_cid') ? undefined : json['cover_art_cid'], 'upc': !exists(json, 'upc') ? undefined : json['upc'], }; } @@ -105,8 +152,13 @@ export function UpdatePlaylistRequestBodyToJSON(value?: UpdatePlaylistRequestBod 'playlist_name': value.playlistName, 'description': value.description, 'is_private': value.isPrivate, + 'genre': GenreToJSON(value.genre), + 'mood': MoodToJSON(value.mood), + 'tags': value.tags, + 'license': value.license, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString().substr(0,10)), 'playlist_contents': value.playlistContents === undefined ? undefined : ((value.playlistContents as Array).map(PlaylistAddedTimestampToJSON)), - 'artwork_url': value.artworkUrl, + 'cover_art_cid': value.coverArtCid, 'upc': value.upc, }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts index 87e447f7839..310537dee35 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts @@ -14,6 +14,18 @@ */ import { exists, mapValues } from '../runtime'; +import type { AccessGate } from './AccessGate'; +import { + AccessGateFromJSON, + AccessGateFromJSONTyped, + AccessGateToJSON, +} from './AccessGate'; +import type { FieldVisibility } from './FieldVisibility'; +import { + FieldVisibilityFromJSON, + FieldVisibilityFromJSONTyped, + FieldVisibilityToJSON, +} from './FieldVisibility'; import type { Genre } from './Genre'; import { GenreFromJSON, @@ -26,6 +38,18 @@ import { MoodFromJSONTyped, MoodToJSON, } from './Mood'; +import type { RemixParentWrite } from './RemixParentWrite'; +import { + RemixParentWriteFromJSON, + RemixParentWriteFromJSONTyped, + RemixParentWriteToJSON, +} from './RemixParentWrite'; +import type { StemParent } from './StemParent'; +import { + StemParentFromJSON, + StemParentFromJSONTyped, + StemParentToJSON, +} from './StemParent'; /** * Request body for updating track information. All fields are optional. @@ -39,60 +63,174 @@ export interface UpdateTrackRequestBody { * @memberof UpdateTrackRequestBody */ title?: string; + /** + * + * @type {Genre} + * @memberof UpdateTrackRequestBody + */ + genre?: Genre; /** * Track description * @type {string} * @memberof UpdateTrackRequestBody */ - description?: string; + description?: string | null; /** * - * @type {Genre} + * @type {Mood} * @memberof UpdateTrackRequestBody */ - genre?: Genre; + mood?: Mood | null; /** - * - * @type {Mood} + * Beats per minute (tempo) + * @type {number} + * @memberof UpdateTrackRequestBody + */ + bpm?: number | null; + /** + * Musical key of the track + * @type {string} * @memberof UpdateTrackRequestBody */ - mood?: Mood; + musicalKey?: string | null; /** * Comma-separated tags * @type {string} * @memberof UpdateTrackRequestBody */ - tags?: string; + tags?: string | null; + /** + * License type + * @type {string} + * @memberof UpdateTrackRequestBody + */ + license?: string | null; /** - * Track release date + * International Standard Recording Code + * @type {string} + * @memberof UpdateTrackRequestBody + */ + isrc?: string | null; + /** + * International Standard Musical Work Code + * @type {string} + * @memberof UpdateTrackRequestBody + */ + iswc?: string | null; + /** + * Release date * @type {Date} * @memberof UpdateTrackRequestBody */ releaseDate?: Date; /** - * International Standard Recording Code + * IPFS CID for the track audio file * @type {string} * @memberof UpdateTrackRequestBody */ - isrc?: string; + trackCid?: string; + /** + * IPFS CID for the original track file + * @type {string} + * @memberof UpdateTrackRequestBody + */ + origFileCid?: string; + /** + * Original filename of the track + * @type {string} + * @memberof UpdateTrackRequestBody + */ + origFilename?: string; + /** + * IPFS CID for cover art + * @type {string} + * @memberof UpdateTrackRequestBody + */ + coverArtCid?: string; + /** + * Cover art sizes metadata + * @type {string} + * @memberof UpdateTrackRequestBody + */ + coverArtSizes?: string; + /** + * IPFS CID for the track preview + * @type {string} + * @memberof UpdateTrackRequestBody + */ + previewCid?: string; + /** + * Preview start time in seconds + * @type {number} + * @memberof UpdateTrackRequestBody + */ + previewStartSeconds?: number; + /** + * Track duration in seconds + * @type {number} + * @memberof UpdateTrackRequestBody + */ + duration?: number; /** * Whether the track is downloadable * @type {boolean} * @memberof UpdateTrackRequestBody */ - isDownloadable?: boolean; + downloadable?: boolean; /** - * Whether the original file is available + * Whether the track is unlisted * @type {boolean} * @memberof UpdateTrackRequestBody */ - isOriginalAvailable?: boolean; + isUnlisted?: boolean; + /** + * + * @type {AccessGate} + * @memberof UpdateTrackRequestBody + */ + streamConditions?: AccessGate | null; + /** + * + * @type {AccessGate} + * @memberof UpdateTrackRequestBody + */ + downloadConditions?: AccessGate | null; + /** + * + * @type {FieldVisibility} + * @memberof UpdateTrackRequestBody + */ + fieldVisibility?: FieldVisibility; /** - * URL for track artwork + * Placement hosts for the track * @type {string} * @memberof UpdateTrackRequestBody */ - artworkUrl?: string; + placementHosts?: string; + /** + * + * @type {StemParent} + * @memberof UpdateTrackRequestBody + */ + stemOf?: StemParent; + /** + * + * @type {RemixParentWrite} + * @memberof UpdateTrackRequestBody + */ + remixOf?: RemixParentWrite; + /** + * DDEX application identifier + * @type {string} + * @memberof UpdateTrackRequestBody + */ + ddexApp?: string | null; + /** + * Parental warning type + * @type {string} + * @memberof UpdateTrackRequestBody + */ + parentalWarningType?: string | null; } /** @@ -115,15 +253,34 @@ export function UpdateTrackRequestBodyFromJSONTyped(json: any, ignoreDiscriminat return { 'title': !exists(json, 'title') ? undefined : json['title'], - 'description': !exists(json, 'description') ? undefined : json['description'], 'genre': !exists(json, 'genre') ? undefined : GenreFromJSON(json['genre']), + 'description': !exists(json, 'description') ? undefined : json['description'], 'mood': !exists(json, 'mood') ? undefined : MoodFromJSON(json['mood']), + 'bpm': !exists(json, 'bpm') ? undefined : json['bpm'], + 'musicalKey': !exists(json, 'musical_key') ? undefined : json['musical_key'], 'tags': !exists(json, 'tags') ? undefined : json['tags'], - 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), + 'license': !exists(json, 'license') ? undefined : json['license'], 'isrc': !exists(json, 'isrc') ? undefined : json['isrc'], - 'isDownloadable': !exists(json, 'is_downloadable') ? undefined : json['is_downloadable'], - 'isOriginalAvailable': !exists(json, 'is_original_available') ? undefined : json['is_original_available'], - 'artworkUrl': !exists(json, 'artwork_url') ? undefined : json['artwork_url'], + 'iswc': !exists(json, 'iswc') ? undefined : json['iswc'], + 'releaseDate': !exists(json, 'release_date') ? undefined : (new Date(json['release_date'])), + 'trackCid': !exists(json, 'track_cid') ? undefined : json['track_cid'], + 'origFileCid': !exists(json, 'orig_file_cid') ? undefined : json['orig_file_cid'], + 'origFilename': !exists(json, 'orig_filename') ? undefined : json['orig_filename'], + 'coverArtCid': !exists(json, 'cover_art_cid') ? undefined : json['cover_art_cid'], + 'coverArtSizes': !exists(json, 'cover_art_sizes') ? undefined : json['cover_art_sizes'], + 'previewCid': !exists(json, 'preview_cid') ? undefined : json['preview_cid'], + 'previewStartSeconds': !exists(json, 'preview_start_seconds') ? undefined : json['preview_start_seconds'], + 'duration': !exists(json, 'duration') ? undefined : json['duration'], + 'downloadable': !exists(json, 'downloadable') ? undefined : json['downloadable'], + 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], + 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), + 'downloadConditions': !exists(json, 'download_conditions') ? undefined : AccessGateFromJSON(json['download_conditions']), + 'fieldVisibility': !exists(json, 'field_visibility') ? undefined : FieldVisibilityFromJSON(json['field_visibility']), + 'placementHosts': !exists(json, 'placement_hosts') ? undefined : json['placement_hosts'], + 'stemOf': !exists(json, 'stem_of') ? undefined : StemParentFromJSON(json['stem_of']), + 'remixOf': !exists(json, 'remix_of') ? undefined : RemixParentWriteFromJSON(json['remix_of']), + 'ddexApp': !exists(json, 'ddex_app') ? undefined : json['ddex_app'], + 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], }; } @@ -137,15 +294,34 @@ export function UpdateTrackRequestBodyToJSON(value?: UpdateTrackRequestBody | nu return { 'title': value.title, - 'description': value.description, 'genre': GenreToJSON(value.genre), + 'description': value.description, 'mood': MoodToJSON(value.mood), + 'bpm': value.bpm, + 'musical_key': value.musicalKey, 'tags': value.tags, - 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString()), + 'license': value.license, 'isrc': value.isrc, - 'is_downloadable': value.isDownloadable, - 'is_original_available': value.isOriginalAvailable, - 'artwork_url': value.artworkUrl, + 'iswc': value.iswc, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString().substr(0,10)), + 'track_cid': value.trackCid, + 'orig_file_cid': value.origFileCid, + 'orig_filename': value.origFilename, + 'cover_art_cid': value.coverArtCid, + 'cover_art_sizes': value.coverArtSizes, + 'preview_cid': value.previewCid, + 'preview_start_seconds': value.previewStartSeconds, + 'duration': value.duration, + 'downloadable': value.downloadable, + 'is_unlisted': value.isUnlisted, + 'stream_conditions': AccessGateToJSON(value.streamConditions), + 'download_conditions': AccessGateToJSON(value.downloadConditions), + 'field_visibility': FieldVisibilityToJSON(value.fieldVisibility), + 'placement_hosts': value.placementHosts, + 'stem_of': StemParentToJSON(value.stemOf), + 'remix_of': RemixParentWriteToJSON(value.remixOf), + 'ddex_app': value.ddexApp, + 'parental_warning_type': value.parentalWarningType, }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/index.ts b/packages/sdk/src/sdk/api/generated/default/models/index.ts index 1e6edfd1f0e..6b05c354502 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/index.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/index.ts @@ -38,6 +38,7 @@ export * from './Collectibles'; export * from './CollectiblesResponse'; export * from './CollectionActivity'; export * from './Comment'; +export * from './CommentEntityType'; export * from './CommentMention'; export * from './CommentNotificationSetting'; export * from './CommentRepliesResponse'; @@ -82,6 +83,7 @@ export * from './ExtendedTokenGate'; export * from './ExtendedUsdcGate'; export * from './Favorite'; export * from './FavoritesResponse'; +export * from './FieldVisibility'; export * from './FollowGate'; export * from './FollowersResponse'; export * from './FollowingResponse'; @@ -96,8 +98,6 @@ export * from './MediaLink'; export * from './MonthlyAggregatePlay'; export * from './Mood'; export * from './MutualFollowersResponse'; -export * from './NftCollection'; -export * from './NftGate'; export * from './Playlist'; export * from './PlaylistAddedTimestamp'; export * from './PlaylistArtwork'; @@ -114,6 +114,7 @@ export * from './PurchasersResponse'; export * from './RedeemAmountResponse'; export * from './RelatedArtistResponse'; export * from './RemixParent'; +export * from './RemixParentWrite'; export * from './RemixedTrackAggregate'; export * from './RemixersResponse'; export * from './RemixesResponse'; @@ -129,6 +130,8 @@ export * from './SalesAggregateResponse'; export * from './SalesJsonContent'; export * from './SalesJsonResponse'; export * from './Stem'; +export * from './StemCategory'; +export * from './StemParent'; export * from './StemsResponse'; export * from './StreamUrlResponse'; export * from './SubscribersResponse'; @@ -148,6 +151,7 @@ export * from './TrackCommentNotificationResponse'; export * from './TrackCommentsResponse'; export * from './TrackDownloadRequestBody'; export * from './TrackElement'; +export * from './TrackElementWrite'; export * from './TrackFavoritesResponse'; export * from './TrackId'; export * from './TrackInspect'; From cf7c3f84a99958e2e823be8a3e179c1b2c27a886 Mon Sep 17 00:00:00 2001 From: Marcus Pasell <3690498+rickyrombo@users.noreply.github.com> Date: Thu, 12 Feb 2026 23:31:41 -0800 Subject: [PATCH 3/9] refactor all the APIs to make room for post requests --- packages/sdk/src/sdk/api/albums/AlbumsApi.ts | 234 +++++--------- packages/sdk/src/sdk/api/albums/types.ts | 82 ++++- .../sdk/src/sdk/api/comments/CommentsAPI.ts | 285 +++++++++++++++--- packages/sdk/src/sdk/api/comments/types.ts | 84 +++++- .../api/developer-apps/DeveloperAppsApi.ts | 66 +++- .../sdk/src/sdk/api/developer-apps/types.ts | 12 +- .../sdk/api/playlists/PlaylistsApi.test.ts | 35 ++- .../sdk/src/sdk/api/playlists/PlaylistsApi.ts | 282 +++++++++++------ packages/sdk/src/sdk/api/playlists/types.ts | 123 +++++--- .../src/sdk/api/tracks/TrackUploadHelper.ts | 32 +- packages/sdk/src/sdk/api/tracks/TracksApi.ts | 249 +++++++++++---- packages/sdk/src/sdk/api/tracks/types.ts | 72 +++-- packages/sdk/src/sdk/api/users/UsersApi.ts | 120 ++++++-- packages/sdk/src/sdk/api/users/types.ts | 16 +- packages/sdk/src/sdk/index.ts | 3 - .../EntityManager/EntityManagerClient.ts | 3 +- .../src/sdk/services/EntityManager/types.ts | 1 + 17 files changed, 1210 insertions(+), 489 deletions(-) diff --git a/packages/sdk/src/sdk/api/albums/AlbumsApi.ts b/packages/sdk/src/sdk/api/albums/AlbumsApi.ts index a9d7d7b2768..a5762ae65c9 100644 --- a/packages/sdk/src/sdk/api/albums/AlbumsApi.ts +++ b/packages/sdk/src/sdk/api/albums/AlbumsApi.ts @@ -1,6 +1,7 @@ import { USDC } from '@audius/fixed-decimal' import { TransactionInstruction } from '@solana/web3.js' +import type { UploadPlaylistRequest } from '../..' import type { ClaimableTokensClient, PaymentRouterClient, @@ -21,13 +22,8 @@ import { type Configuration } from '../generated/default' import { PlaylistsApi } from '../playlists/PlaylistsApi' -import { PlaylistMetadata } from '../playlists/types' import { - DeleteAlbumRequest, - DeleteAlbumSchema, - FavoriteAlbumRequest, - FavoriteAlbumSchema, getAlbumRequest, getAlbumsRequest, getAlbumTracksRequest, @@ -35,18 +31,16 @@ import { GetPurchaseAlbumInstructionsSchema, PurchaseAlbumRequest, PurchaseAlbumSchema, - RepostAlbumRequest, - RepostAlbumSchema, - UnfavoriteAlbumRequest, - UnfavoriteAlbumSchema, - UnrepostAlbumRequest, - UnrepostAlbumSchema, - UpdateAlbumRequest, - UpdateAlbumSchema, UploadAlbumRequest, UploadAlbumSchema, CreateAlbumRequest, - CreateAlbumSchema + UpdateAlbumRequest, + DeleteAlbumRequest, + FavoriteAlbumRequest, + UnfavoriteAlbumRequest, + RepostAlbumRequest, + UnrepostAlbumRequest, + UpdateAlbumSchema } from './types' export class AlbumsApi { @@ -90,38 +84,25 @@ export class AlbumsApi { /** @hidden * Create an album from existing tracks */ - async createAlbum( - params: CreateAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - // Parse inputs - const { metadata, ...parsedParameters } = await parseParams( - 'createAlbum', - CreateAlbumSchema - )(params) - + async createAlbum(params: CreateAlbumRequest, requestInit?: RequestInit) { + const { metadata, ...rest } = params const { albumName, ...playlistMetadata } = metadata - // Call createPlaylistInternal with parsed inputs - const response = await this.playlistsApi.createPlaylistInternal< - PlaylistMetadata & { isAlbum: boolean } - >( - { - ...parsedParameters, - playlistId: parsedParameters.albumId, - metadata: { - ...playlistMetadata, - playlistName: albumName, - isAlbum: true - } - }, - advancedOptions + // Transform album request to playlist request + const playlistParams = { + ...rest, + metadata: { + ...playlistMetadata, + playlistName: albumName, + isAlbum: true + } + } + const response = await this.playlistsApi.createPlaylist( + playlistParams, + requestInit ) - return { - ...response, - albumId: response.playlistId - } + return response } /** @hidden @@ -132,98 +113,66 @@ export class AlbumsApi { params: UploadAlbumRequest, advancedOptions?: AdvancedOptions ) { - const { metadata, ...parsedParameters } = await parseParams( - 'uploadAlbum', - UploadAlbumSchema - )(params) + await parseParams('uploadAlbum', UploadAlbumSchema)(params) - const { albumName, ...playlistMetadata } = metadata + const { albumName, ...playlistMetadata } = params.metadata - // Call uploadPlaylistInternal with parsed inputs - const response = await this.playlistsApi.uploadPlaylistInternal( - { - ...parsedParameters, - metadata: { - ...playlistMetadata, - playlistName: albumName, - isAlbum: true - } - }, + const playlistParams: UploadPlaylistRequest = { + ...params, + metadata: { + ...playlistMetadata, + playlistName: albumName, + isAlbum: true + } + } + + return await this.playlistsApi.uploadPlaylist( + playlistParams, advancedOptions ) - - return { - blockHash: response.blockHash, - blockNumber: response.blockNumber, - albumId: response.playlistId - } } /** @hidden * Update an album */ - async updateAlbum( - params: UpdateAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - const { albumId, metadata, ...parsedParameters } = await parseParams( - 'updateAlbum', - UpdateAlbumSchema - )(params) - - const { albumName, ...playlistMetadata } = metadata - - // Call updatePlaylistInternal with parsed inputs - return await this.playlistsApi.updatePlaylistInternal( - { - ...parsedParameters, - playlistId: albumId, - metadata: { - ...playlistMetadata, - playlistName: albumName - } - }, - advancedOptions - ) + async updateAlbum(params: UpdateAlbumRequest, requestInit?: RequestInit) { + await parseParams('updateAlbum', UpdateAlbumSchema)(params) + + const { updateAlbumRequestBody, albumId, ...rest } = params + const { albumName, ...playlistMetadata } = updateAlbumRequestBody + + // Transform album request to playlist request + const playlistParams = { + ...rest, + playlistId: albumId, + metadata: { + ...playlistMetadata, + ...(albumName && { playlistName: albumName }) + } + } + return await this.playlistsApi.updatePlaylist(playlistParams, requestInit) } /** @hidden * Delete an album */ - async deleteAlbum( - params: DeleteAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - await parseParams('deleteAlbum', DeleteAlbumSchema)(params) - - return await this.playlistsApi.deletePlaylist( - { - userId: params.userId, - playlistId: params.albumId - }, - advancedOptions - ) + async deleteAlbum(params: DeleteAlbumRequest, requestInit?: RequestInit) { + const playlistParams = { + userId: params.userId, + playlistId: params.albumId + } + return await this.playlistsApi.deletePlaylist(playlistParams, requestInit) } /** @hidden * Favorite an album */ - async favoriteAlbum( - params: FavoriteAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - const { metadata } = await parseParams( - 'favoriteAlbum', - FavoriteAlbumSchema - )(params) - return await this.playlistsApi.favoritePlaylist( - { - userId: params.userId, - playlistId: params.albumId, - metadata - }, - advancedOptions - ) + async favoriteAlbum(params: FavoriteAlbumRequest, requestInit?: RequestInit) { + const playlistParams = { + userId: params.userId, + playlistId: params.albumId + } + return await this.playlistsApi.favoritePlaylist(playlistParams, requestInit) } /** @hidden @@ -231,55 +180,38 @@ export class AlbumsApi { */ async unfavoriteAlbum( params: UnfavoriteAlbumRequest, - advancedOptions?: AdvancedOptions + requestInit?: RequestInit ) { - await parseParams('unfavoriteAlbum', UnfavoriteAlbumSchema)(params) + const playlistParams = { + userId: params.userId, + playlistId: params.albumId + } return await this.playlistsApi.unfavoritePlaylist( - { - userId: params.userId, - playlistId: params.albumId - }, - advancedOptions + playlistParams, + requestInit ) } /** @hidden * Repost an album */ - async repostAlbum( - params: RepostAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - const { metadata } = await parseParams( - 'repostAlbum', - RepostAlbumSchema - )(params) - - return await this.playlistsApi.repostPlaylist( - { - userId: params.userId, - playlistId: params.albumId, - metadata - }, - advancedOptions - ) + async repostAlbum(params: RepostAlbumRequest, requestInit?: RequestInit) { + const playlistParams = { + userId: params.userId, + playlistId: params.albumId + } + return await this.playlistsApi.repostPlaylist(playlistParams, requestInit) } /** @hidden * Unrepost an album */ - async unrepostAlbum( - params: UnrepostAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - await parseParams('unrepostAlbum', UnrepostAlbumSchema)(params) - return await this.playlistsApi.unrepostPlaylist( - { - userId: params.userId, - playlistId: params.albumId - }, - advancedOptions - ) + async unrepostAlbum(params: UnrepostAlbumRequest, requestInit?: RequestInit) { + const playlistParams = { + userId: params.userId, + playlistId: params.albumId + } + return await this.playlistsApi.unrepostPlaylist(playlistParams, requestInit) } /** diff --git a/packages/sdk/src/sdk/api/albums/types.ts b/packages/sdk/src/sdk/api/albums/types.ts index 6e376fae974..66aa8d0fb65 100644 --- a/packages/sdk/src/sdk/api/albums/types.ts +++ b/packages/sdk/src/sdk/api/albums/types.ts @@ -4,14 +4,72 @@ import { z } from 'zod' import { PublicKeySchema } from '../../services/Solana' import { DDEXResourceContributor, DDEXCopyright } from '../../types/DDEX' import { AudioFile, ImageFile } from '../../types/File' -import { Genre } from '../../types/Genre' import { HashId } from '../../types/HashId' -import { Mood } from '../../types/Mood' +import { Mood, Genre } from '../generated/default' +import type { + CreatePlaylistRequestBody, + UpdatePlaylistRequestBody +} from '../generated/default' +import type { UploadPlaylistProgressHandler } from '../playlists/types' import { UploadTrackMetadataSchema, USDCPurchaseConditions } from '../tracks/types' +// Album request body types that wrap playlist types but use album field names +export type CreateAlbumRequestBody = Omit< + CreatePlaylistRequestBody, + 'playlistName' +> & { + albumName: string +} + +export type UpdateAlbumRequestBody = Omit< + UpdatePlaylistRequestBody, + 'playlistName' +> & { + albumName?: string +} + +// Album request types that wrap playlist request types +export type CreateAlbumRequest = { + userId: string + metadata: CreateAlbumRequestBody +} + +export type UpdateAlbumRequest = { + userId: string + albumId: string + updateAlbumRequestBody: UpdateAlbumRequestBody + imageFile?: z.input + onProgress?: UploadPlaylistProgressHandler +} + +export type DeleteAlbumRequest = { + userId: string + albumId: string +} + +export type FavoriteAlbumRequest = { + userId: string + albumId: string +} + +export type UnfavoriteAlbumRequest = { + userId: string + albumId: string +} + +export type RepostAlbumRequest = { + userId: string + albumId: string +} + +export type UnrepostAlbumRequest = { + userId: string + albumId: string +} + export const getAlbumSchema = z.object({ userId: HashId.optional(), albumId: HashId @@ -67,7 +125,7 @@ export const CreateAlbumSchema = z }) .strict() -export type CreateAlbumRequest = z.input +export type EntityManagerCreateAlbumRequest = z.input export const UploadAlbumMetadataSchema = CreateAlbumMetadataSchema.extend({ genre: z.enum(Object.values(Genre) as [Genre, ...Genre[]]), @@ -129,7 +187,7 @@ export const UpdateAlbumSchema = z }) .strict() -export type UpdateAlbumRequest = z.input +export type EntityManagerUpdateAlbumRequest = z.input export const DeleteAlbumSchema = z .object({ @@ -138,7 +196,7 @@ export const DeleteAlbumSchema = z }) .strict() -export type DeleteAlbumRequest = z.input +export type EntityManagerDeleteAlbumRequest = z.input export const FavoriteAlbumSchema = z .object({ @@ -156,7 +214,9 @@ export const FavoriteAlbumSchema = z }) .strict() -export type FavoriteAlbumRequest = z.input +export type EntityManagerFavoriteAlbumRequest = z.input< + typeof FavoriteAlbumSchema +> export const UnfavoriteAlbumSchema = z .object({ @@ -165,7 +225,9 @@ export const UnfavoriteAlbumSchema = z }) .strict() -export type UnfavoriteAlbumRequest = z.input +export type EntityManagerUnfavoriteAlbumRequest = z.input< + typeof UnfavoriteAlbumSchema +> export const RepostAlbumSchema = z .object({ @@ -183,7 +245,7 @@ export const RepostAlbumSchema = z }) .strict() -export type RepostAlbumRequest = z.input +export type EntityManagerRepostAlbumRequest = z.input export const UnrepostAlbumSchema = z .object({ @@ -192,7 +254,9 @@ export const UnrepostAlbumSchema = z }) .strict() -export type UnrepostAlbumRequest = z.input +export type EntityManagerUnrepostAlbumRequest = z.input< + typeof UnrepostAlbumSchema +> const PurchaseAlbumSchemaBase = z.object({ /** The ID of the user purchasing the album. */ diff --git a/packages/sdk/src/sdk/api/comments/CommentsAPI.ts b/packages/sdk/src/sdk/api/comments/CommentsAPI.ts index 3909311123c..61ccdd675ba 100644 --- a/packages/sdk/src/sdk/api/comments/CommentsAPI.ts +++ b/packages/sdk/src/sdk/api/comments/CommentsAPI.ts @@ -1,43 +1,40 @@ import snakecaseKeys from 'snakecase-keys' -import { OverrideProperties } from 'type-fest' import { LoggerService } from '../../services' import { Action, EntityManagerService, - EntityType, - ManageEntityOptions + EntityType } from '../../services/EntityManager/types' import { decodeHashId, encodeHashId } from '../../utils/hashId' +import { parseParams } from '../../utils/parseParams' import { Configuration, - CommentsApi as GeneratedCommentsApi + CommentsApi as GeneratedCommentsApi, + type CreateCommentRequest, + type UpdateCommentRequest, + type DeleteCommentRequest, + type PinCommentRequest, + type UnpinCommentRequest, + type ReactToCommentRequest, + type UnreactToCommentRequest, + type ReportCommentRequest } from '../generated/default' -import { CommentMetadata } from './types' - -type EditCommentMetadata = CommentMetadata & { - trackId: number -} - -type PinCommentMetadata = { - userId: number - entityId: number - trackId: number - isPin: boolean -} - -type ReactCommentMetadata = { - userId: number - commentId: number - isLiked: boolean - trackId: number -} - -type CommentNotificationOptions = OverrideProperties< - Omit, - { action: Action.MUTE | Action.UNMUTE } -> +import { + CreateCommentSchema, + UpdateCommentSchema, + DeleteCommentSchema, + PinCommentSchema, + ReactCommentSchema, + ReportCommentSchema, + EntityManagerCreateCommentRequest, + EntityManagerUpdateCommentRequest, + EntityManagerDeleteCommentRequest, + EntityManagerPinCommentRequest, + EntityManagerReactCommentRequest, + EntityManagerReportCommentRequest +} from './types' export class CommentsApi extends GeneratedCommentsApi { constructor( @@ -57,7 +54,16 @@ export class CommentsApi extends GeneratedCommentsApi { return decodeHashId(unclaimedId)! } - async postComment(metadata: CommentMetadata) { + /** @hidden + * Create a comment using entity manager + */ + async createCommentWithEntityManager( + params: EntityManagerCreateCommentRequest + ) { + const metadata = await parseParams( + 'createComment', + CreateCommentSchema + )(params) const { userId, entityType = EntityType.TRACK, commentId } = metadata const newCommentId = commentId ?? (await this.generateCommentId()) await this.entityManager.manageEntity({ @@ -74,8 +80,40 @@ export class CommentsApi extends GeneratedCommentsApi { return encodeHashId(newCommentId) } - async editComment(metadata: EditCommentMetadata) { - const { userId, entityId, trackId } = metadata + override async createComment( + params: CreateCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const { createCommentRequestBody, userId } = params + const metadata: EntityManagerCreateCommentRequest = { + userId, + entityId: createCommentRequestBody.entityId, + entityType: createCommentRequestBody.entityType, + body: createCommentRequestBody.body, + commentId: createCommentRequestBody.commentId, + parentCommentId: createCommentRequestBody.parentId + } + const commentId = await this.createCommentWithEntityManager(metadata) + return { + success: true, + commentId: commentId ?? undefined + } + } + return super.createComment(params, requestInit) + } + + /** @hidden + * Update a comment using entity manager + */ + async updateCommentWithEntityManager( + params: EntityManagerUpdateCommentRequest + ) { + const metadata = await parseParams( + 'updateComment', + UpdateCommentSchema + )(params) + const { userId, entityId, trackId, body } = metadata const response = await this.entityManager.manageEntity({ userId, entityType: EntityType.COMMENT, @@ -83,13 +121,42 @@ export class CommentsApi extends GeneratedCommentsApi { action: Action.UPDATE, metadata: JSON.stringify({ cid: '', - data: snakecaseKeys({ ...metadata, entityId: trackId }) + data: snakecaseKeys({ body, entityId: trackId }) }) }) return response } - async deleteComment(metadata: CommentMetadata) { + override async updateComment( + params: UpdateCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const { updateCommentRequestBody, userId, commentId } = params + const metadata: EntityManagerUpdateCommentRequest = { + userId, + entityId: commentId, + trackId: commentId, // trackId is used for the entity being commented on + body: updateCommentRequestBody.body + } + await this.updateCommentWithEntityManager(metadata) + return { + success: true + } + } + return super.updateComment(params, requestInit) + } + + /** @hidden + * Delete a comment using entity manager + */ + async deleteCommentWithEntityManager( + params: EntityManagerDeleteCommentRequest + ) { + const metadata = await parseParams( + 'deleteComment', + DeleteCommentSchema + )(params) const { userId, entityId } = metadata const response = await this.entityManager.manageEntity({ userId, @@ -101,7 +168,33 @@ export class CommentsApi extends GeneratedCommentsApi { return response } - async reactComment(metadata: ReactCommentMetadata) { + override async deleteComment( + params: DeleteCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const metadata: EntityManagerDeleteCommentRequest = { + userId: params.userId, + entityId: params.commentId + } + await this.deleteCommentWithEntityManager(metadata) + return { + success: true + } + } + return super.deleteComment(params, requestInit) + } + + /** @hidden + * React to a comment using entity manager + */ + async reactToCommentWithEntityManager( + params: EntityManagerReactCommentRequest + ) { + const metadata = await parseParams( + 'reactComment', + ReactCommentSchema + )(params) const { userId, commentId, isLiked, trackId } = metadata const response = await this.entityManager.manageEntity({ userId, @@ -116,7 +209,49 @@ export class CommentsApi extends GeneratedCommentsApi { return response } - async pinComment(metadata: PinCommentMetadata) { + override async reactToComment( + params: ReactToCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const metadata: EntityManagerReactCommentRequest = { + userId: params.userId, + commentId: params.commentId, + isLiked: true, + trackId: params.commentId // trackId represents the entity being commented on + } + await this.reactToCommentWithEntityManager(metadata) + return { + success: true + } + } + return super.reactToComment(params, requestInit) + } + + override async unreactToComment( + params: UnreactToCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const metadata: EntityManagerReactCommentRequest = { + userId: params.userId, + commentId: params.commentId, + isLiked: false, + trackId: params.commentId + } + await this.reactToCommentWithEntityManager(metadata) + return { + success: true + } + } + return super.unreactToComment(params, requestInit) + } + + /** @hidden + * Pin a comment using entity manager + */ + async pinCommentWithEntityManager(params: EntityManagerPinCommentRequest) { + const metadata = await parseParams('pinComment', PinCommentSchema)(params) const { userId, entityId, trackId, isPin } = metadata const response = await this.entityManager.manageEntity({ userId, @@ -131,7 +266,55 @@ export class CommentsApi extends GeneratedCommentsApi { return response } - async reportComment(userId: number, entityId: number) { + override async pinComment( + params: PinCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const metadata: EntityManagerPinCommentRequest = { + userId: params.userId, + entityId: params.commentId, + trackId: params.commentId, // trackId represents the entity being commented on + isPin: true + } + await this.pinCommentWithEntityManager(metadata) + return { + success: true + } + } + return super.pinComment(params, requestInit) + } + + override async unpinComment( + params: UnpinCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const metadata: EntityManagerPinCommentRequest = { + userId: params.userId, + entityId: params.commentId, + trackId: params.commentId, + isPin: false + } + await this.pinCommentWithEntityManager(metadata) + return { + success: true + } + } + return super.unpinComment(params, requestInit) + } + + /** @hidden + * Report a comment using entity manager + */ + async reportCommentWithEntityManager( + params: EntityManagerReportCommentRequest + ) { + const metadata = await parseParams( + 'reportComment', + ReportCommentSchema + )(params) + const { userId, entityId } = metadata const response = await this.entityManager.manageEntity({ userId, entityType: EntityType.COMMENT, @@ -142,6 +325,26 @@ export class CommentsApi extends GeneratedCommentsApi { return response } + override async reportComment( + params: ReportCommentRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const metadata: EntityManagerReportCommentRequest = { + userId: params.userId, + entityId: params.commentId + } + await this.reportCommentWithEntityManager(metadata) + return { + success: true + } + } + return super.reportComment(params, requestInit) + } + + /** @hidden + * Mute/unmute a user (entity manager only) + */ async muteUser(userId: number, mutedUserId: number, isMuted: boolean) { const response = await this.entityManager.manageEntity({ userId, @@ -153,7 +356,15 @@ export class CommentsApi extends GeneratedCommentsApi { return response } - async updateCommentNotificationSetting(config: CommentNotificationOptions) { + /** @hidden + * Update comment notification settings (entity manager only) + */ + async updateCommentNotificationSetting(config: { + userId: number + entityType: EntityType + entityId: number + action: Action.MUTE | Action.UNMUTE + }) { const response = await this.entityManager.manageEntity({ ...config, metadata: '' diff --git a/packages/sdk/src/sdk/api/comments/types.ts b/packages/sdk/src/sdk/api/comments/types.ts index 4db8f953926..680e24e5e1f 100644 --- a/packages/sdk/src/sdk/api/comments/types.ts +++ b/packages/sdk/src/sdk/api/comments/types.ts @@ -1,12 +1,92 @@ -import { EntityType } from '../../services/EntityManager/types' +import { z } from 'zod' + +import { HashId } from '../../types/HashId' +import type { CommentEntityType } from '../generated/default' export type CommentMetadata = { body?: string commentId?: number userId: number entityId: number - entityType?: EntityType // For now just tracks are supported, but we left the door open for more + entityType?: CommentEntityType // For now just tracks are supported, but we left the door open for more parentCommentId?: number trackTimestampS?: number mentions?: number[] } + +// Zod schemas for dual-auth support +export const CreateCommentSchema = z + .object({ + userId: HashId, + entityId: HashId, + entityType: z.optional(z.string()), + body: z.optional(z.string()), + commentId: z.optional(z.number()), + parentCommentId: z.optional(z.number()), + trackTimestampS: z.optional(z.number()), + mentions: z.optional(z.array(z.number())) + }) + .strict() + +export type EntityManagerCreateCommentRequest = z.input< + typeof CreateCommentSchema +> + +export const UpdateCommentSchema = z + .object({ + userId: HashId, + entityId: HashId, + trackId: HashId, + body: z.string() + }) + .strict() + +export type EntityManagerUpdateCommentRequest = z.input< + typeof UpdateCommentSchema +> + +export const DeleteCommentSchema = z + .object({ + userId: HashId, + entityId: HashId + }) + .strict() + +export type EntityManagerDeleteCommentRequest = z.input< + typeof DeleteCommentSchema +> + +export const PinCommentSchema = z + .object({ + userId: HashId, + entityId: HashId, + trackId: HashId, + isPin: z.boolean() + }) + .strict() + +export type EntityManagerPinCommentRequest = z.input + +export const ReactCommentSchema = z + .object({ + userId: HashId, + commentId: HashId, + isLiked: z.boolean(), + trackId: HashId + }) + .strict() + +export type EntityManagerReactCommentRequest = z.input< + typeof ReactCommentSchema +> + +export const ReportCommentSchema = z + .object({ + userId: HashId, + entityId: HashId + }) + .strict() + +export type EntityManagerReportCommentRequest = z.input< + typeof ReportCommentSchema +> diff --git a/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts b/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts index dfbcb7052df..6548b279708 100644 --- a/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts +++ b/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts @@ -12,15 +12,18 @@ import { import { parseParams } from '../../utils/parseParams' import { Configuration, - DeveloperAppsApi as GeneratedDeveloperAppsApi + DeveloperAppsApi as GeneratedDeveloperAppsApi, + type CreateDeveloperAppRequest, + type DeleteDeveloperAppRequest, + type UpdateDeveloperAppRequest } from '../generated/default' import { - CreateDeveloperAppRequest, + EntityManagerCreateDeveloperAppRequest, CreateDeveloperAppSchema, - UpdateDeveloperAppRequest, + EntityManagerUpdateDeveloperAppRequest, UpdateDeveloperAppSchema, - DeleteDeveloperAppRequest, + EntityManagerDeleteDeveloperAppRequest, DeleteDeveloperAppSchema } from './types' @@ -35,8 +38,8 @@ export class DeveloperAppsApi extends GeneratedDeveloperAppsApi { /** * Create a developer app */ - async createDeveloperApp( - params: CreateDeveloperAppRequest, + async createDeveloperAppWithEntityManager( + params: EntityManagerCreateDeveloperAppRequest, advancedOptions?: AdvancedOptions ) { const { name, userId, description, imageUrl } = await parseParams( @@ -81,11 +84,25 @@ export class DeveloperAppsApi extends GeneratedDeveloperAppsApi { } } + override async createDeveloperApp( + params: CreateDeveloperAppRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.createDeveloperAppWithEntityManager({ + ...params.createDeveloperAppRequestBody, + userId: params.userId + }) + } else { + return await super.createDeveloperApp(params, requestInit) + } + } + /** * Update a developer app */ - async updateDeveloperApp( - params: UpdateDeveloperAppRequest, + async updateDeveloperAppWithEntityManager( + params: EntityManagerUpdateDeveloperAppRequest, advancedOptions?: AdvancedOptions ) { const { appApiKey, name, userId, description, imageUrl } = @@ -110,10 +127,27 @@ export class DeveloperAppsApi extends GeneratedDeveloperAppsApi { } } + override async updateDeveloperApp( + params: UpdateDeveloperAppRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.updateDeveloperAppWithEntityManager({ + ...params.updateDeveloperAppRequestBody, + userId: params.userId, + appApiKey: params.address + }) + } else { + return await super.updateDeveloperApp(params, requestInit) + } + } + /** * Delete a developer app */ - async deleteDeveloperApp(params: DeleteDeveloperAppRequest) { + async deleteDeveloperAppWithEntityManager( + params: EntityManagerDeleteDeveloperAppRequest + ) { const { userId, appApiKey } = await parseParams( 'deleteDeveloperApp', DeleteDeveloperAppSchema @@ -129,4 +163,18 @@ export class DeveloperAppsApi extends GeneratedDeveloperAppsApi { }) }) } + + override async deleteDeveloperApp( + params: DeleteDeveloperAppRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.deleteDeveloperAppWithEntityManager({ + userId: params.userId, + appApiKey: params.address + }) + } else { + return await super.deleteDeveloperApp(params, requestInit) + } + } } diff --git a/packages/sdk/src/sdk/api/developer-apps/types.ts b/packages/sdk/src/sdk/api/developer-apps/types.ts index cf957fa2046..7887ee2269e 100644 --- a/packages/sdk/src/sdk/api/developer-apps/types.ts +++ b/packages/sdk/src/sdk/api/developer-apps/types.ts @@ -21,7 +21,9 @@ export const CreateDeveloperAppSchema = z.object({ userId: HashId }) -export type CreateDeveloperAppRequest = z.input +export type EntityManagerCreateDeveloperAppRequest = z.input< + typeof CreateDeveloperAppSchema +> export const UpdateDeveloperAppSchema = z.object({ appApiKey: z.custom((data: unknown) => { @@ -40,7 +42,9 @@ export const UpdateDeveloperAppSchema = z.object({ userId: HashId }) -export type UpdateDeveloperAppRequest = z.input +export type EntityManagerUpdateDeveloperAppRequest = z.input< + typeof UpdateDeveloperAppSchema +> export const DeleteDeveloperAppSchema = z.object({ userId: HashId, @@ -49,4 +53,6 @@ export const DeleteDeveloperAppSchema = z.object({ }) }) -export type DeleteDeveloperAppRequest = z.input +export type EntityManagerDeleteDeveloperAppRequest = z.input< + typeof DeleteDeveloperAppSchema +> diff --git a/packages/sdk/src/sdk/api/playlists/PlaylistsApi.test.ts b/packages/sdk/src/sdk/api/playlists/PlaylistsApi.test.ts index e0d7e23b30c..921a4f9865c 100644 --- a/packages/sdk/src/sdk/api/playlists/PlaylistsApi.test.ts +++ b/packages/sdk/src/sdk/api/playlists/PlaylistsApi.test.ts @@ -8,9 +8,7 @@ import { EntityManagerClient } from '../../services/EntityManager' import { Logger } from '../../services/Logger' import { Storage } from '../../services/Storage' import { StorageNodeSelector } from '../../services/StorageNodeSelector' -import { Genre } from '../../types/Genre' -import { Mood } from '../../types/Mood' -import { Configuration } from '../generated/default' +import { Configuration, Mood, Genre } from '../generated/default' import { PlaylistsApi as GeneratedPlaylistsApi } from '../generated/default/apis/PlaylistsApi' import { TrackUploadHelper } from '../tracks/TrackUploadHelper' @@ -135,9 +133,14 @@ describe('PlaylistsApi', () => { name: 'coverArt' }, metadata: { - playlistName: 'My Playlist' - }, - trackIds: ['yyNwXq7'] + playlistName: 'My Playlist', + playlistContents: [ + { + trackId: 'yyNwXq7', + timestamp: 1 + } + ] + } }) expect(result).toStrictEqual({ @@ -155,8 +158,14 @@ describe('PlaylistsApi', () => { buffer: pngFile, name: 'coverArt' }, - metadata: {} as any, - trackIds: ['yyNwXq7'] + metadata: { + playlistContents: [ + { + trackId: 'yyNwXq7', + timestamp: 1 + } + ] + } as any }) }).rejects.toThrow() }) @@ -172,8 +181,8 @@ describe('PlaylistsApi', () => { }, metadata: { playlistName: 'My Playlist', - genre: Genre.ACOUSTIC, - mood: Mood.TENDER + genre: Genre.Acoustic, + mood: Mood.Tender }, trackMetadatas: [ { @@ -300,7 +309,7 @@ describe('PlaylistsApi', () => { }, metadata: { playlistName: 'My Playlist edited', - mood: Mood.TENDER, + mood: Mood.Tender, playlistContents: [] } }) @@ -322,8 +331,8 @@ describe('PlaylistsApi', () => { }, metadata: { playlistName: 'My Playlist edited', - playlistMood: Mood.TENDER, - mod: Mood.TENDER + playlistMood: Mood.Tender, + mod: Mood.Tender } as any }) }).rejects.toThrow() diff --git a/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts b/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts index aa7d1a49e90..766e0278756 100644 --- a/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts +++ b/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts @@ -15,37 +15,46 @@ import { parseParams } from '../../utils/parseParams' import { retry3 } from '../../utils/retry' import { Configuration, - PlaylistsApi as GeneratedPlaylistsApi + PlaylistsApi as GeneratedPlaylistsApi, + type DeletePlaylistRequest, + type RepostPlaylistRequest, + type UnrepostPlaylistRequest, + type FavoritePlaylistRequest, + type UnfavoritePlaylistRequest, + type SharePlaylistRequest, + type UpdateTrackRequestBody } from '../generated/default' import { TrackUploadHelper } from '../tracks/TrackUploadHelper' import { AddTrackToPlaylistRequest, AddTrackToPlaylistSchema, - CreatePlaylistRequest, CreatePlaylistSchema, - DeletePlaylistRequest, + EntityManagerDeletePlaylistRequest, DeletePlaylistSchema, PlaylistMetadata, - PlaylistTrackMetadata, PublishPlaylistRequest, PublishPlaylistSchema, RemoveTrackFromPlaylistRequest, RemoveTrackFromPlaylistSchema, - RepostPlaylistRequest, + EntityManagerRepostPlaylistRequest, RepostPlaylistSchema, - FavoritePlaylistRequest, - FavoritePlaylistSchema, + EntityManagerUnrepostPlaylistRequest, UnrepostPlaylistSchema, - UnfavoritePlaylistRequest, + EntityManagerFavoritePlaylistRequest, + FavoritePlaylistSchema, + EntityManagerUnfavoritePlaylistRequest, UnfavoritePlaylistSchema, - UpdatePlaylistRequest, UploadPlaylistRequest, UploadPlaylistSchema, UpdatePlaylistSchema, UpdatePlaylistMetadataSchema, - SharePlaylistRequest, - SharePlaylistSchema + EntityManagerSharePlaylistRequest, + SharePlaylistSchema, + EntityManagerCreatePlaylistRequest, + EntityManagerUpdatePlaylistRequest, + type UpdatePlaylistRequestWithImage, + type CreatePlaylistRequestWithFiles } from './types' // Returns current timestamp in seconds, which is the expected @@ -71,8 +80,8 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { /** @hidden * Create a playlist from existing tracks */ - async createPlaylist( - params: CreatePlaylistRequest, + async createPlaylistWithEntityManager( + params: EntityManagerCreatePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -85,6 +94,24 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { return await this.createPlaylistInternal(parsedParameters, advancedOptions) } + override async createPlaylist( + params: CreatePlaylistRequestWithFiles, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const { metadata } = params + const res = await this.createPlaylistWithEntityManager({ + userId: params.userId, + metadata + }) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.createPlaylist(params, requestInit) + } + /** @hidden * Upload a playlist * Uploads the specified tracks and combines them into a playlist @@ -196,8 +223,8 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { /** @hidden * Update a playlist */ - async updatePlaylist( - params: UpdatePlaylistRequest, + async updatePlaylistWithEntityManager( + params: EntityManagerUpdatePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -206,15 +233,61 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { UpdatePlaylistSchema )(params) - // Call updatePlaylistInternal with parsed inputs - return await this.updatePlaylistInternal(parsedParameters, advancedOptions) + return await this.entityManager.manageEntity({ + userId: parsedParameters.userId, + entityType: EntityType.PLAYLIST, + entityId: parsedParameters.playlistId, + action: Action.UPDATE, + metadata: JSON.stringify({ + cid: '', + data: snakecaseKeys(parsedParameters.metadata) + }), + ...advancedOptions + }) + } + + override async updatePlaylist( + params: UpdatePlaylistRequestWithImage, + requestInit?: RequestInit + ) { + // Upload art + const metadata = params.metadata + if (params.imageFile) { + const res = await this.storage + .uploadFile({ + file: params.imageFile, + onProgress: (event) => + params.onProgress?.(event.loaded / event.total, { + ...event, + key: 'image' + }), + metadata: { + template: 'img_square' + } + }) + .start() + metadata.coverArtCid = res.orig_file_cid + } + + if (this.entityManager) { + const res = await this.updatePlaylistWithEntityManager({ + userId: params.userId, + playlistId: params.playlistId, + metadata + }) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.updatePlaylist(params, requestInit) } /** @hidden * Delete a playlist */ - async deletePlaylist( - params: DeletePlaylistRequest, + async deletePlaylistWithEntityManager( + params: EntityManagerDeletePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -232,11 +305,25 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async deletePlaylist( + params: DeletePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.deletePlaylistWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.deletePlaylist(params, requestInit) + } + /** @hidden * Favorite a playlist */ - async favoritePlaylist( - params: FavoritePlaylistRequest, + async favoritePlaylistWithEntityManager( + params: EntityManagerFavoritePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -255,11 +342,25 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async favoritePlaylist( + params: FavoritePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.favoritePlaylistWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.favoritePlaylist(params, requestInit) + } + /** @hidden * Unfavorite a playlist */ - async unfavoritePlaylist( - params: UnfavoritePlaylistRequest, + async unfavoritePlaylistWithEntityManager( + params: EntityManagerUnfavoritePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -277,11 +378,25 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async unfavoritePlaylist( + params: UnfavoritePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.unfavoritePlaylistWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.unfavoritePlaylist(params, requestInit) + } + /** @hidden * Repost a playlist */ - async repostPlaylist( - params: RepostPlaylistRequest, + async repostPlaylistWithEntityManager( + params: EntityManagerRepostPlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -300,11 +415,25 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async repostPlaylist( + params: RepostPlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.repostPlaylistWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.repostPlaylist(params, requestInit) + } + /** @hidden * Unrepost a playlist */ - async unrepostPlaylist( - params: FavoritePlaylistRequest, + async unrepostPlaylistWithEntityManager( + params: EntityManagerUnrepostPlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -322,11 +451,25 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async unrepostPlaylist( + params: UnrepostPlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.unrepostPlaylistWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.unrepostPlaylist(params, requestInit) + } + /** @hidden * Share a playlist */ - async sharePlaylist( - params: SharePlaylistRequest, + async sharePlaylistWithEntityManager( + params: EntityManagerSharePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -344,12 +487,26 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async sharePlaylist( + params: SharePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.sharePlaylistWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.sharePlaylist(params, requestInit) + } + /** @internal * Combines the metadata for a track and a collection (playlist or album), * taking the metadata from the playlist when the track is missing it. */ private combineMetadata( - trackMetadata: PlaylistTrackMetadata, + trackMetadata: UpdateTrackRequestBody, playlistMetadata: PlaylistMetadata ) { const metadata = trackMetadata @@ -385,8 +542,8 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { userId: string playlistId: string updateMetadata: ( - fetchedMetadata: UpdatePlaylistRequest['metadata'] - ) => UpdatePlaylistRequest['metadata'] + fetchedMetadata: EntityManagerUpdatePlaylistRequest['metadata'] + ) => EntityManagerUpdatePlaylistRequest['metadata'] }, advancedOptions?: AdvancedOptions ) { @@ -409,7 +566,7 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { string, unknown > - const metadataForUpdate: UpdatePlaylistRequest['metadata'] = { + const metadataForUpdate: EntityManagerUpdatePlaylistRequest['metadata'] = { ...picked, ...(picked.releaseDate != null ? { @@ -421,7 +578,7 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { : {}) } - return await this.updatePlaylist( + return await this.updatePlaylistWithEntityManager( { userId, playlistId, @@ -578,63 +735,6 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { } } - /** @internal - * Method to update a playlist with already parsed inputs - * This is used for both playlists and albums - */ - public async updatePlaylistInternal< - Metadata extends Partial - >( - { - userId, - playlistId, - imageFile, - onProgress, - metadata - }: z.infer & { - metadata: Metadata - }, - advancedOptions?: AdvancedOptions - ) { - // Upload cover art to storage node - const coverArtResponse = - imageFile && - (await retry3( - async () => - await this.storage - .uploadFile({ - file: imageFile, - onProgress, - metadata: { - template: 'img_square' - } - }) - .start(), - (e) => { - this.logger.info('Retrying uploadPlaylistCoverArt', e) - } - )) - - const updatedMetadata = { - ...metadata, - ...(coverArtResponse - ? { playlistImageSizesMultihash: coverArtResponse.orig_file_cid } - : {}) - } - - return await this.entityManager.manageEntity({ - userId, - entityType: EntityType.PLAYLIST, - entityId: playlistId, - action: Action.UPDATE, - metadata: JSON.stringify({ - cid: '', - data: snakecaseKeys(updatedMetadata) - }), - ...advancedOptions - }) - } - /** @internal * Method to create a playlist with already parsed inputs * This is used for both playlists and albums diff --git a/packages/sdk/src/sdk/api/playlists/types.ts b/packages/sdk/src/sdk/api/playlists/types.ts index 25e147c85e4..4c720ae0ed8 100644 --- a/packages/sdk/src/sdk/api/playlists/types.ts +++ b/packages/sdk/src/sdk/api/playlists/types.ts @@ -1,14 +1,15 @@ import { z } from 'zod' -import { - ProgressEventHandlerSchema, - ProgressEventSchema -} from '../../services/Storage/types' +import { ProgressEventSchema } from '../../services/Storage/types' import { DDEXResourceContributor, DDEXCopyright } from '../../types/DDEX' import { AudioFile, ImageFile } from '../../types/File' -import { Genre } from '../../types/Genre' import { HashId } from '../../types/HashId' -import { Mood } from '../../types/Mood' +import { + Genre, + Mood, + type CreatePlaylistRequest, + type UpdatePlaylistRequest +} from '../generated/default' import { UploadTrackMetadataSchema } from '../tracks/types' const CreatePlaylistMetadataSchema = z @@ -16,6 +17,7 @@ const CreatePlaylistMetadataSchema = z description: z.optional(z.string().max(1000)), playlistName: z.string(), isPrivate: z.optional(z.boolean()), + isAlbum: z.optional(z.boolean()), coverArtCid: z.optional(z.string()), license: z.optional(z.string()), mood: z.optional(z.enum(Object.values(Mood) as [Mood, ...Mood[]])), @@ -47,7 +49,9 @@ export const CreatePlaylistSchema = z }) .strict() -export type CreatePlaylistRequest = z.input +export type EntityManagerCreatePlaylistRequest = z.input< + typeof CreatePlaylistSchema +> export const UploadPlaylistMetadataSchema = CreatePlaylistMetadataSchema.extend( { @@ -69,35 +73,6 @@ const PlaylistTrackMetadataSchema = UploadTrackMetadataSchema.partial({ */ export type PlaylistTrackMetadata = z.infer -export const UpdatePlaylistMetadataSchema = - UploadPlaylistMetadataSchema.partial() - .merge( - z.object({ - isPrivate: z.optional(z.boolean()), - playlistContents: z.optional( - z.array( - z.object({ - timestamp: z.number(), - metadataTimestamp: z.optional(z.number()), - trackId: HashId - }) - ) - ), - coverArtCid: z.optional(z.string()) - }) - ) - .strict() - -export const UpdatePlaylistSchema = z - .object({ - userId: HashId, - playlistId: HashId, - imageFile: z.optional(ImageFile), - metadata: UpdatePlaylistMetadataSchema, - onProgress: ProgressEventHandlerSchema.optional() - }) - .strict() - export const UploadPlaylistProgressEventSchema = ProgressEventSchema.extend({ /** * Index of the track being uploaded in the playlist tracks array, or 'image' if for the image @@ -142,8 +117,6 @@ export const UploadPlaylistSchema = z }) .strict() -export type UpdatePlaylistRequest = z.input - export type UploadPlaylistRequest = Omit< z.input, 'onProgress' @@ -151,6 +124,56 @@ export type UploadPlaylistRequest = Omit< onProgress?: UploadPlaylistProgressHandler } +export const UpdatePlaylistMetadataSchema = + UploadPlaylistMetadataSchema.partial() + .merge( + z.object({ + isPrivate: z.optional(z.boolean()), + playlistContents: z.optional( + z.array( + z.object({ + timestamp: z.number(), + metadataTimestamp: z.optional(z.number()), + trackId: HashId + }) + ) + ), + coverArtCid: z.optional(z.string()) + }) + ) + .strict() + +export const UpdatePlaylistSchema = z + .object({ + userId: HashId, + playlistId: HashId, + imageFile: z.optional(ImageFile), + metadata: UpdatePlaylistMetadataSchema, + onProgress: UploadPlaylistProgressHandlerSchema.optional() + }) + .strict() + +export type EntityManagerUpdatePlaylistRequest = z.input< + typeof UpdatePlaylistSchema +> + +export type PlaylistImageParameters = { + imageFile?: z.input + onProgress?: UploadPlaylistProgressHandler +} + +export type PlaylistAudioParameters = { + audioFiles?: z.input[] + trackMetadatas?: z.input[] + onProgress?: UploadPlaylistProgressHandler +} + +export type CreatePlaylistRequestWithFiles = CreatePlaylistRequest & + PlaylistImageParameters + +export type UpdatePlaylistRequestWithImage = UpdatePlaylistRequest & + PlaylistImageParameters + export const PublishPlaylistSchema = z .object({ userId: HashId, @@ -189,7 +212,9 @@ export const DeletePlaylistSchema = z }) .strict() -export type DeletePlaylistRequest = z.input +export type EntityManagerDeletePlaylistRequest = z.input< + typeof DeletePlaylistSchema +> export const FavoritePlaylistSchema = z .object({ @@ -209,7 +234,9 @@ export const FavoritePlaylistSchema = z }) .strict() -export type FavoritePlaylistRequest = z.input +export type EntityManagerFavoritePlaylistRequest = z.input< + typeof FavoritePlaylistSchema +> export const UnfavoritePlaylistSchema = z .object({ @@ -218,7 +245,9 @@ export const UnfavoritePlaylistSchema = z }) .strict() -export type UnfavoritePlaylistRequest = z.input +export type EntityManagerUnfavoritePlaylistRequest = z.input< + typeof UnfavoritePlaylistSchema +> export const RepostPlaylistSchema = z .object({ @@ -238,7 +267,9 @@ export const RepostPlaylistSchema = z }) .strict() -export type RepostPlaylistRequest = z.input +export type EntityManagerRepostPlaylistRequest = z.input< + typeof RepostPlaylistSchema +> export const UnrepostPlaylistSchema = z .object({ @@ -247,7 +278,9 @@ export const UnrepostPlaylistSchema = z }) .strict() -export type UnrepostPlaylistRequest = z.input +export type EntityManagerUnrepostPlaylistRequest = z.input< + typeof UnrepostPlaylistSchema +> export const SharePlaylistSchema = z .object({ @@ -256,4 +289,6 @@ export const SharePlaylistSchema = z }) .strict() -export type SharePlaylistRequest = z.input +export type EntityManagerSharePlaylistRequest = z.input< + typeof SharePlaylistSchema +> diff --git a/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts b/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts index 84730603e78..c923f7facce 100644 --- a/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts +++ b/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts @@ -1,6 +1,10 @@ import type { UploadResponse } from '../../services/Storage/types' import { decodeHashId } from '../../utils/hashId' -import { BaseAPI } from '../generated/default' +import { + BaseAPI, + type CreateTrackRequestBody, + type UpdateTrackRequestBody +} from '../generated/default' import type { PlaylistTrackMetadata } from '../playlists/types' export class TrackUploadHelper extends BaseAPI { @@ -20,21 +24,16 @@ export class TrackUploadHelper extends BaseAPI { return id } - public transformTrackUploadMetadata< - // TrackMetadata is a less strict type - // only requiring the fields used in this function. - // This supports both track/playlist uploads and edits - TrackMetadata extends Pick< - PlaylistTrackMetadata, - 'isStreamGated' | 'streamConditions' | 'isUnlisted' | 'fieldVisibility' - > - >(inputMetadata: TrackMetadata, userId: number) { + public transformTrackUploadMetadata( + inputMetadata: CreateTrackRequestBody | UpdateTrackRequestBody, + userId: number + ) { const metadata = { ...inputMetadata, ownerId: userId } - const isStreamGated = metadata.isStreamGated + const isStreamGated = metadata.streamConditions !== undefined const isUsdcGated = 'usdc_purchase' in (metadata.streamConditions ?? {}) const isUnlisted = metadata.isUnlisted @@ -46,6 +45,7 @@ export class TrackUploadHelper extends BaseAPI { // If track is public, set required visibility fields to true if (!isUnlisted) { metadata.fieldVisibility = { + remixes: true, // default, but overwritten ...metadata.fieldVisibility, genre: true, mood: true, @@ -58,11 +58,11 @@ export class TrackUploadHelper extends BaseAPI { } public populateTrackMetadataWithUploadResponse( - trackMetadata: Partial, + trackMetadata: CreateTrackRequestBody | UpdateTrackRequestBody, audioResponse?: UploadResponse, coverArtResponse?: UploadResponse ) { - let updated: Partial & { coverArtSizes?: string } = { + let updated = { ...trackMetadata } if (audioResponse) { @@ -75,18 +75,16 @@ export class TrackUploadHelper extends BaseAPI { ? audioResponse.results[ `320_preview|${trackMetadata.previewStartSeconds}` ] - : trackMetadata.previewCid, + : trackMetadata.previewCid!, origFileCid: audioResponse.orig_file_cid, origFilename: audioResponse.orig_filename || trackMetadata.origFilename, - audioUploadId: audioResponse.id, duration: parseInt(audioResponse?.probe?.format?.duration ?? '0', 10), bpm: audioResponse.audio_analysis_results?.bpm ? audioResponse.audio_analysis_results.bpm : trackMetadata.bpm, musicalKey: audioResponse.audio_analysis_results?.key ? audioResponse.audio_analysis_results.key - : trackMetadata.musicalKey, - audioAnalysisErrorCount: audioResponse.audio_analysis_error_count || 0 + : trackMetadata.musicalKey } } if (coverArtResponse) { diff --git a/packages/sdk/src/sdk/api/tracks/TracksApi.ts b/packages/sdk/src/sdk/api/tracks/TracksApi.ts index 40e18e3a840..ddfd73c8b86 100644 --- a/packages/sdk/src/sdk/api/tracks/TracksApi.ts +++ b/packages/sdk/src/sdk/api/tracks/TracksApi.ts @@ -27,41 +27,49 @@ import { DownloadTrackRequest, TracksApi as GeneratedTracksApi, ExtendedPaymentSplit, - instanceOfExtendedPurchaseGate + instanceOfExtendedPurchaseGate, + type DeleteTrackRequest, + type FavoriteTrackRequest, + type UnfavoriteTrackRequest, + type ShareTrackRequest, + type RepostTrackRequest, + type UnrepostTrackRequest, + type RecordTrackDownloadRequest } from '../generated/default' import { RequiredError } from '../generated/default/runtime' import { TrackUploadHelper } from './TrackUploadHelper' import { - DeleteTrackRequest, + EntityManagerDeleteTrackRequest, DeleteTrackSchema, - RepostTrackRequest, + EntityManagerRepostTrackRequest, RepostTrackSchema, - FavoriteTrackRequest, + EntityManagerFavoriteTrackRequest, FavoriteTrackSchema, - UnrepostTrackRequest, + EntityManagerUnrepostTrackRequest, UnrepostTrackSchema, - UnfavoriteTrackRequest, + EntityManagerUnfavoriteTrackRequest, UnfavoriteTrackSchema, - UpdateTrackRequest, + EntityManagerUpdateTrackRequest, UploadTrackRequest, PurchaseTrackRequest, PurchaseTrackSchema, GetPurchaseTrackInstructionsRequest, GetPurchaseTrackInstructionsSchema, - RecordTrackDownloadRequest, + EntityManagerRecordTrackDownloadRequest, RecordTrackDownloadSchema, UploadTrackFilesRequest, UploadTrackSchema, UpdateTrackSchema, UploadTrackFilesSchema, ShareTrackSchema, - ShareTrackRequest, + EntityManagerShareTrackRequest, type PublishTrackRequest, PublishTrackSchema, type PublishStemRequest, PublishStemSchema, - type UploadTrackFilesTask + type UploadTrackFilesTask, + type UpdateTrackRequestWithFiles } from './types' // Extend that new class @@ -108,8 +116,6 @@ export class TracksApi extends GeneratedTracksApi { if (params.apiKey) queryParams.append('api_key', params.apiKey) if (params.skipCheck !== undefined) queryParams.append('skip_check', String(params.skipCheck)) - if (params.noRedirect !== undefined) - queryParams.append('no_redirect', String(params.noRedirect)) const path = `/tracks/{track_id}/stream`.replace( `{${'track_id'}}`, @@ -241,11 +247,7 @@ export class TracksApi extends GeneratedTracksApi { imageUploadResponse ) - return this.writeTrackToChain( - params.userId, - populatedMetadata, - advancedOptions - ) + return this.writeTrackToChain(userId, populatedMetadata, advancedOptions) } /** @hidden @@ -267,6 +269,7 @@ export class TracksApi extends GeneratedTracksApi { streamConditions: undefined, isUnlisted: false, fieldVisibility: { + remixes: false, genre: false, mood: false, tags: false, @@ -288,18 +291,14 @@ export class TracksApi extends GeneratedTracksApi { audioUploadResponse ) - return this.writeTrackToChain( - params.userId, - populatedMetadata, - advancedOptions - ) + return this.writeTrackToChain(userId, populatedMetadata, advancedOptions) } /** @hidden * Write track upload to chain */ async writeTrackToChain( - userId: string, + userId: number, metadata: ReturnType< typeof this.trackUploadHelper.populateTrackMetadataWithUploadResponse >, @@ -309,16 +308,12 @@ export class TracksApi extends GeneratedTracksApi { this.logger.info('Writing metadata to chain') const entityId = - metadata.trackId || (await this.trackUploadHelper.generateId('track')) - - const decodedUserId = decodeHashId(userId) ?? undefined - - if (!decodedUserId) { - throw new Error('writeTrackToChain: userId could not be decoded') - } + 'trackId' in metadata && metadata.trackId + ? metadata.trackId + : await this.trackUploadHelper.generateId('track') const response = await this.entityManager.manageEntity({ - userId: decodedUserId, + userId, entityType: EntityType.TRACK, entityId, action: Action.CREATE, @@ -326,7 +321,7 @@ export class TracksApi extends GeneratedTracksApi { cid: '', data: { ...snakecaseKeys(metadata), - owner_id: decodedUserId, + owner_id: userId, download_conditions: metadata.downloadConditions && snakecaseKeys(metadata.downloadConditions), @@ -385,10 +380,10 @@ export class TracksApi extends GeneratedTracksApi { } /** @hidden - * Update a track + * Update a track with entity manager */ - async updateTrack( - params: UpdateTrackRequest, + async updateTrackWithEntityManager( + params: EntityManagerUpdateTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -433,9 +428,6 @@ export class TracksApi extends GeneratedTracksApi { if (updatedMetadata.previewStartSeconds === undefined) { throw new Error('No track preview start time specified') } - if (!updatedMetadata.audioUploadId) { - throw new Error('Missing required audio_upload_id') - } const previewCid = await retry3( async () => @@ -475,11 +467,62 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async updateTrack( + params: UpdateTrackRequestWithFiles, + requestInit?: RequestInit + ) { + // Upload files + let metadata = params.metadata + if (params.audioFile || params.imageFile) { + const { audioUploadResponse, imageUploadResponse } = + await this.uploadTrackFiles({ + audioFile: params.audioFile, + imageFile: params.imageFile, + fileMetadata: { + placementHosts: metadata.placementHosts, + previewStartSeconds: metadata.previewStartSeconds + }, + onProgress: params.onProgress + }).start() + + metadata = this.trackUploadHelper.transformTrackUploadMetadata( + metadata, + decodeHashId(params.userId)! + ) + + metadata = this.trackUploadHelper.populateTrackMetadataWithUploadResponse( + metadata, + audioUploadResponse, + imageUploadResponse + ) + } + + if (this.entityManager) { + const res = await this.updateTrackWithEntityManager({ + trackId: params.trackId, + userId: params.userId, + metadata + }) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.updateTrack( + { + trackId: params.trackId, + userId: params.userId, + metadata + }, + requestInit + ) + } + /** @hidden * Delete a track */ - async deleteTrack( - params: DeleteTrackRequest, + async deleteTrackWithEntityManager( + params: EntityManagerDeleteTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -497,11 +540,25 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async deleteTrack( + params: DeleteTrackRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.deleteTrackWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.deleteTrack(params, requestInit) + } + /** @hidden * Favorite a track */ - async favoriteTrack( - params: FavoriteTrackRequest, + async favoriteTrackWithEntityManager( + params: EntityManagerFavoriteTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -520,11 +577,25 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async favoriteTrack( + params: FavoriteTrackRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.favoriteTrackWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.favoriteTrack(params, requestInit) + } + /** @hidden * Unfavorite a track */ - async unfavoriteTrack( - params: UnfavoriteTrackRequest, + async unfavoriteTrackWithEntityManager( + params: EntityManagerUnfavoriteTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -542,11 +613,25 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async unfavoriteTrack( + params: UnfavoriteTrackRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.unfavoriteTrackWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.unfavoriteTrack(params, requestInit) + } + /** @hidden * Share a track */ - async shareTrack( - params: ShareTrackRequest, + async shareTrackWithEntityManager( + params: EntityManagerShareTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -564,11 +649,25 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async shareTrack( + params: ShareTrackRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.shareTrackWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.shareTrack(params, requestInit) + } + /** @hidden * Repost a track */ - async repostTrack( - params: RepostTrackRequest, + async repostTrackWithEntityManager( + params: EntityManagerRepostTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -587,11 +686,25 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async repostTrack( + params: RepostTrackRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.repostTrackWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.repostTrack(params, requestInit) + } + /** @hidden * Unrepost a track */ - async unrepostTrack( - params: UnrepostTrackRequest, + async unrepostTrackWithEntityManager( + params: EntityManagerUnrepostTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -609,13 +722,27 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async unrepostTrack( + params: UnrepostTrackRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.unrepostTrackWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.unrepostTrack(params, requestInit) + } + /** * @hidden * * Records that a track was downloaded. */ - public async recordTrackDownload( - params: RecordTrackDownloadRequest, + public async recordTrackDownloadWithEntityManager( + params: EntityManagerRecordTrackDownloadRequest, advancedOptions?: AdvancedOptions ) { const { userId, trackId } = await parseParams( @@ -642,6 +769,20 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async recordTrackDownload( + params: RecordTrackDownloadRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const res = await this.recordTrackDownloadWithEntityManager(params) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.recordTrackDownload(params, requestInit) + } + /** * Gets the Solana instructions that purchase the track * @@ -666,8 +807,8 @@ export class TracksApi extends GeneratedTracksApi { // Fetch track this.logger.debug('Fetching track purchase info...', { trackId }) const { data: track } = await this.getTrackAccessInfo({ - trackId: params.trackId, // use hashed trackId - userId: params.userId // use hashed userId + trackId: encodeHashId(trackId)!, // use hashed trackId + userId: encodeHashId(userId)! // use hashed userId }) // Validate purchase attempt diff --git a/packages/sdk/src/sdk/api/tracks/types.ts b/packages/sdk/src/sdk/api/tracks/types.ts index b94f66c15f4..4640b5e5d85 100644 --- a/packages/sdk/src/sdk/api/tracks/types.ts +++ b/packages/sdk/src/sdk/api/tracks/types.ts @@ -9,10 +9,13 @@ import { DDEXRightsController } from '../../types/DDEX' import { AudioFile, ImageFile } from '../../types/File' -import { Genre } from '../../types/Genre' import { HashId } from '../../types/HashId' -import { Mood } from '../../types/Mood' -import { StemCategory } from '../../types/StemCategory' +import { + Mood, + Genre, + StemCategory, + type UpdateTrackRequest +} from '../generated/default' import { MAX_DESCRIPTION_LENGTH } from './constants' @@ -78,7 +81,14 @@ export const USDCPurchaseConditions = z .object({ usdcPurchase: z.object({ price: z.number().positive(), - splits: z.any() + splits: z.array( + z.object({ + userId: z.number().optional(), + percentage: z.number().min(0).max(100), + payoutWallet: z.string(), + amount: z.number().positive() + }) + ) }) }) .strict() @@ -86,14 +96,14 @@ export const USDCPurchaseConditions = z export const UploadStemMetadataSchema = z.object({ category: z .enum(Object.values(StemCategory) as [StemCategory, ...StemCategory[]]) - .default(StemCategory.OTHER), - parentTrackId: HashId + .default(StemCategory.Other), + parentTrackId: HashId.or(z.number()) }) export const UploadTrackMetadataSchema = z.object({ trackId: z.optional(HashId), aiAttributionUserId: z.optional(HashId), - description: z.optional(z.string().max(MAX_DESCRIPTION_LENGTH)), + description: z.optional(z.string().max(MAX_DESCRIPTION_LENGTH).nullable()), fieldVisibility: z.optional( z.object({ mood: z.optional(z.boolean()), @@ -104,25 +114,16 @@ export const UploadTrackMetadataSchema = z.object({ remixes: z.optional(z.boolean()) }) ), - genre: z - .enum(Object.values(Genre) as [Genre, ...Genre[]]) - .nullable() - .refine((val) => val !== null, { - message: messages.genreRequiredError - }) - .refine((val) => val !== Genre.ALL, { - message: messages.genreAllError - }), + genre: z.enum(Object.values(Genre) as [Genre, ...Genre[]]), isrc: z.optional(z.string().nullable()), isUnlisted: z.optional(z.boolean()), iswc: z.optional(z.string().nullable()), license: z.optional(z.string().nullable()), - mood: z.optional(z.enum(Object.values(Mood) as [Mood, ...Mood[]])).nullable(), + mood: z.optional(z.enum(Object.values(Mood) as [Mood, ...Mood[]]).nullable()), isStreamGated: z.optional(z.boolean()), streamConditions: z .optional( z.union([ - CollectibleGatedConditions, FollowGatedConditions, TipGatedConditions, USDCPurchaseConditions, @@ -134,7 +135,6 @@ export const UploadTrackMetadataSchema = z.object({ downloadConditions: z .optional( z.union([ - CollectibleGatedConditions, FollowGatedConditions, TipGatedConditions, USDCPurchaseConditions, @@ -149,7 +149,7 @@ export const UploadTrackMetadataSchema = z.object({ tracks: z .array( z.object({ - parentTrackId: HashId + parentTrackId: HashId.or(z.number()) }) ) .min(1) @@ -157,7 +157,7 @@ export const UploadTrackMetadataSchema = z.object({ .strict() ), stemOf: z.optional(UploadStemMetadataSchema.strict()), - tags: z.optional(z.string()), + tags: z.optional(z.string()).nullable(), title: z.string({ required_error: messages.titleRequiredError }), @@ -172,7 +172,7 @@ export const UploadTrackMetadataSchema = z.object({ isDownloadable: z.optional(z.boolean()), isOriginalAvailable: z.optional(z.boolean()), ddexReleaseIds: z.optional(z.record(z.string()).nullable()), - ddexApp: z.optional(z.string()), + ddexApp: z.optional(z.string()).nullable(), artists: z.optional(z.array(DDEXResourceContributor)).nullable(), resourceContributors: z.optional(z.array(DDEXResourceContributor).nullable()), indirectResourceContributors: z.optional( @@ -277,7 +277,7 @@ export const UpdateTrackSchema = z }) .strict() -export type UpdateTrackRequest = Omit< +export type EntityManagerUpdateTrackRequest = Omit< z.input, 'onProgress' > & { @@ -291,7 +291,7 @@ export const DeleteTrackSchema = z }) .strict() -export type DeleteTrackRequest = z.input +export type EntityManagerDeleteTrackRequest = z.input export const FavoriteTrackSchema = z .object({ @@ -311,7 +311,9 @@ export const FavoriteTrackSchema = z }) .strict() -export type FavoriteTrackRequest = z.input +export type EntityManagerFavoriteTrackRequest = z.input< + typeof FavoriteTrackSchema +> export const UnfavoriteTrackSchema = z .object({ @@ -320,7 +322,9 @@ export const UnfavoriteTrackSchema = z }) .strict() -export type UnfavoriteTrackRequest = z.input +export type EntityManagerUnfavoriteTrackRequest = z.input< + typeof UnfavoriteTrackSchema +> export const RepostTrackSchema = z .object({ @@ -340,7 +344,7 @@ export const RepostTrackSchema = z }) .strict() -export type RepostTrackRequest = z.input +export type EntityManagerRepostTrackRequest = z.input export const UnrepostTrackSchema = z .object({ @@ -349,7 +353,9 @@ export const UnrepostTrackSchema = z }) .strict() -export type UnrepostTrackRequest = z.input +export type EntityManagerUnrepostTrackRequest = z.input< + typeof UnrepostTrackSchema +> export const RecordTrackDownloadSchema = z .object({ @@ -365,9 +371,9 @@ export const ShareTrackSchema = z }) .strict() -export type ShareTrackRequest = z.input +export type EntityManagerShareTrackRequest = z.input -export type RecordTrackDownloadRequest = z.input< +export type EntityManagerRecordTrackDownloadRequest = z.input< typeof RecordTrackDownloadSchema > @@ -475,3 +481,9 @@ export type UploadTrackFilesTask = { }> abort: () => void } + +export type UpdateTrackRequestWithFiles = UpdateTrackRequest & { + audioFile?: z.input + imageFile?: z.input + onProgress?: UploadTrackFilesProgressHandler +} diff --git a/packages/sdk/src/sdk/api/users/UsersApi.ts b/packages/sdk/src/sdk/api/users/UsersApi.ts index 01e7231e162..bd917f12894 100644 --- a/packages/sdk/src/sdk/api/users/UsersApi.ts +++ b/packages/sdk/src/sdk/api/users/UsersApi.ts @@ -22,18 +22,18 @@ import { DownloadPurchasesAsCSVRequest, DownloadSalesAsCSVRequest, DownloadUSDCWithdrawalsAsCSVRequest, - UsersApi as GeneratedUsersApi + UsersApi as GeneratedUsersApi, + type CreateUserRequest } from '../generated/default' import * as runtime from '../generated/default/runtime' import { AddAssociatedWalletRequest, AddAssociatedWalletSchema, - CreateUserRequest, CreateUserSchema, EmailRequest, EmailSchema, - FollowUserRequest, + EntityManagerFollowUserRequest, FollowUserSchema, RemoveAssociatedWalletRequest, RemoveAssociatedWalletSchema, @@ -41,16 +41,17 @@ import { SendTipReactionRequestSchema, SendTipRequest, SendTipSchema, - SubscribeToUserRequest, + EntityManagerSubscribeToUserRequest, SubscribeToUserSchema, - UnfollowUserRequest, + EntityManagerUnfollowUserRequest, UnfollowUserSchema, - UnsubscribeFromUserRequest, + EntityManagerUnsubscribeFromUserRequest, UnsubscribeFromUserSchema, UpdateCollectiblesRequest, UpdateCollectiblesSchema, - UpdateProfileRequest, - UpdateProfileSchema + UpdateProfileSchema, + type EntityManagerCreateUserRequest, + type EntityManagerUpdateProfileRequest } from './types' export class UsersApi extends GeneratedUsersApi { @@ -87,8 +88,8 @@ export class UsersApi extends GeneratedUsersApi { /** @hidden * Create a user */ - async createUser( - params: CreateUserRequest, + async createUserWithEntityManager( + params: EntityManagerCreateUserRequest, advancedOptions?: AdvancedOptions ) { const { onProgress, profilePictureFile, coverArtFile, metadata } = @@ -172,6 +173,23 @@ export class UsersApi extends GeneratedUsersApi { return { blockHash, blockNumber, metadata: updatedMetadata } } + override async createUser( + params: CreateUserRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const { metadata } = params + const res = await this.createUserWithEntityManager({ + metadata + }) + return { + success: true, + transactionHash: res.blockHash + } + } + return super.createUser(params, requestInit) + } + /** @hidden * Creates a guest for guest checkout */ @@ -206,7 +224,7 @@ export class UsersApi extends GeneratedUsersApi { * Update a user profile */ async updateProfile( - params: UpdateProfileRequest, + params: EntityManagerUpdateProfileRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -283,8 +301,8 @@ export class UsersApi extends GeneratedUsersApi { /** @hidden * Follow a user */ - async followUser( - params: FollowUserRequest, + async followUserWithEntityManager( + params: EntityManagerFollowUserRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -302,11 +320,27 @@ export class UsersApi extends GeneratedUsersApi { }) } + override async followUser( + params: EntityManagerFollowUserRequest | { id: string }, + requestInit?: RequestInit + ) { + if (this.entityManager && 'userId' in params) { + const res = await this.followUserWithEntityManager( + params as EntityManagerFollowUserRequest + ) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.followUser(params as any, requestInit) + } + /** @hidden * Unfollow a user */ - async unfollowUser( - params: UnfollowUserRequest, + async unfollowUserWithEntityManager( + params: EntityManagerUnfollowUserRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -324,11 +358,27 @@ export class UsersApi extends GeneratedUsersApi { }) } + override async unfollowUser( + params: EntityManagerUnfollowUserRequest | { id: string }, + requestInit?: RequestInit + ) { + if (this.entityManager && 'userId' in params) { + const res = await this.unfollowUserWithEntityManager( + params as EntityManagerUnfollowUserRequest + ) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.unfollowUser(params as any, requestInit) + } + /** @hidden * Subscribe to a user */ - async subscribeToUser( - params: SubscribeToUserRequest, + async subscribeToUserWithEntityManager( + params: EntityManagerSubscribeToUserRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -346,11 +396,27 @@ export class UsersApi extends GeneratedUsersApi { }) } + override async subscribeToUser( + params: EntityManagerSubscribeToUserRequest | { id: string }, + requestInit?: RequestInit + ) { + if (this.entityManager && 'userId' in params) { + const res = await this.subscribeToUserWithEntityManager( + params as EntityManagerSubscribeToUserRequest + ) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.subscribeToUser(params as any, requestInit) + } + /** @hidden * Unsubscribe from a user */ - async unsubscribeFromUser( - params: UnsubscribeFromUserRequest, + async unsubscribeFromUserWithEntityManager( + params: EntityManagerUnsubscribeFromUserRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -368,6 +434,22 @@ export class UsersApi extends GeneratedUsersApi { }) } + override async unsubscribeFromUser( + params: EntityManagerUnsubscribeFromUserRequest | { id: string }, + requestInit?: RequestInit + ) { + if (this.entityManager && 'userId' in params) { + const res = await this.unsubscribeFromUserWithEntityManager( + params as EntityManagerUnsubscribeFromUserRequest + ) + return { + success: true, + transactionHash: res.transactionHash + } + } + return super.unsubscribeFromUser(params as any, requestInit) + } + /** * Downloads the sales the user has made as a CSV file. * Similar to generated raw method, but forced response type as blob diff --git a/packages/sdk/src/sdk/api/users/types.ts b/packages/sdk/src/sdk/api/users/types.ts index 442954ce9bc..93ca50743ad 100644 --- a/packages/sdk/src/sdk/api/users/types.ts +++ b/packages/sdk/src/sdk/api/users/types.ts @@ -34,7 +34,7 @@ export const CreateUserSchema = z.object({ .strict() }) -export type CreateUserRequest = Omit< +export type EntityManagerCreateUserRequest = Omit< z.input, 'onProgress' > & { @@ -132,7 +132,7 @@ export const UpdateProfileSchema = z }) .strict() -export type UpdateProfileRequest = Omit< +export type EntityManagerUpdateProfileRequest = Omit< z.input, 'onProgress' > & { @@ -148,7 +148,7 @@ export const FollowUserSchema = z }) .strict() -export type FollowUserRequest = z.input +export type EntityManagerFollowUserRequest = z.input export const UnfollowUserSchema = z .object({ @@ -157,7 +157,9 @@ export const UnfollowUserSchema = z }) .strict() -export type UnfollowUserRequest = z.input +export type EntityManagerUnfollowUserRequest = z.input< + typeof UnfollowUserSchema +> export const SubscribeToUserSchema = z .object({ @@ -166,7 +168,9 @@ export const SubscribeToUserSchema = z }) .strict() -export type SubscribeToUserRequest = z.input +export type EntityManagerSubscribeToUserRequest = z.input< + typeof SubscribeToUserSchema +> export const UnsubscribeFromUserSchema = z .object({ @@ -175,7 +179,7 @@ export const UnsubscribeFromUserSchema = z }) .strict() -export type UnsubscribeFromUserRequest = z.input< +export type EntityManagerUnsubscribeFromUserRequest = z.input< typeof UnsubscribeFromUserSchema > diff --git a/packages/sdk/src/sdk/index.ts b/packages/sdk/src/sdk/index.ts index 6680447650b..9efa2a632bb 100644 --- a/packages/sdk/src/sdk/index.ts +++ b/packages/sdk/src/sdk/index.ts @@ -29,10 +29,7 @@ export * from './api/tracks/types' export * from './api/users/types' export * from './middleware' export * from './types/File' -export * from './types/Genre' -export * from './types/StemCategory' export * from './types/HashId' -export * from './types/Mood' export * from './types/Timeout' export * from './api/developer-apps/types' export * from './api/dashboard-wallet-users/types' diff --git a/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts b/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts index e360c24b1d9..4477b2616e2 100644 --- a/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts +++ b/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts @@ -127,7 +127,8 @@ export class EntityManagerClient implements EntityManagerService { return { blockHash: jsonResponse.receipt.blockHash, - blockNumber: jsonResponse.receipt.blockNumber + blockNumber: jsonResponse.receipt.blockNumber, + transactionHash: jsonResponse.receipt.transactionHash } } else { if (response.status === 429) { diff --git a/packages/sdk/src/sdk/services/EntityManager/types.ts b/packages/sdk/src/sdk/services/EntityManager/types.ts index aa5ead6b17e..54decce02c9 100644 --- a/packages/sdk/src/sdk/services/EntityManager/types.ts +++ b/packages/sdk/src/sdk/services/EntityManager/types.ts @@ -6,6 +6,7 @@ import type { LoggerService } from '../Logger' export type EntityManagerTransactionReceipt = { blockHash: string blockNumber: number + transactionHash: string } export type EntityManagerConfigInternal = { From 7f165a26487af56afe42fa114afeb9595cf0ac93 Mon Sep 17 00:00:00 2001 From: Marcus Pasell <3690498+rickyrombo@users.noreply.github.com> Date: Fri, 13 Feb 2026 12:43:26 -0800 Subject: [PATCH 4/9] Change usages for updateUserProfile, artist coins, some mood stuff, albumsapi test fixes, changed things to metadata, etc --- packages/common/src/adapters/user.ts | 4 +- .../tan-query/coins/useUpdateArtistCoin.ts | 2 +- packages/common/src/utils/quickSearch.ts | 6 +-- .../sdk/src/sdk/api/albums/AlbumsApi.test.ts | 14 +++---- packages/sdk/src/sdk/api/albums/AlbumsApi.ts | 4 +- packages/sdk/src/sdk/api/albums/types.ts | 2 +- .../api/generated/default/apis/CoinsApi.ts | 16 ++++---- .../api/generated/default/apis/CommentsApi.ts | 16 ++++---- .../default/apis/DeveloperAppsApi.ts | 16 ++++---- .../api/generated/default/apis/PrizesApi.ts | 8 ++-- .../api/generated/default/apis/RewardsApi.ts | 18 ++++----- .../api/generated/default/apis/TracksApi.ts | 4 +- .../api/generated/default/apis/UsersApi.ts | 16 ++++---- .../generated/full/.openapi-generator/FILES | 1 + .../sdk/api/generated/full/models/Comment.ts | 14 +++++-- .../full/models/CommentEntityType.ts | 38 +++++++++++++++++++ .../api/generated/full/models/ReplyComment.ts | 14 +++++-- .../sdk/api/generated/full/models/index.ts | 1 + 18 files changed, 120 insertions(+), 74 deletions(-) create mode 100644 packages/sdk/src/sdk/api/generated/full/models/CommentEntityType.ts diff --git a/packages/common/src/adapters/user.ts b/packages/common/src/adapters/user.ts index 670c0baff43..409dc346643 100644 --- a/packages/common/src/adapters/user.ts +++ b/packages/common/src/adapters/user.ts @@ -4,7 +4,7 @@ import { OptionalId, type full, type User, - type UpdateProfileRequest + type UpdateUserRequest } from '@audius/sdk' import camelcaseKeys from 'camelcase-keys' import { omit, pick } from 'lodash' @@ -220,7 +220,7 @@ export const accountFromSDK = ( export const userMetadataToSdk = ( input: WriteableUserMetadata & Pick -): UpdateProfileRequest['metadata'] => ({ +): UpdateUserRequest['metadata'] => ({ ...camelcaseKeys( pick(input, [ 'name', diff --git a/packages/common/src/api/tan-query/coins/useUpdateArtistCoin.ts b/packages/common/src/api/tan-query/coins/useUpdateArtistCoin.ts index 72648c71b86..44745c0a0f1 100644 --- a/packages/common/src/api/tan-query/coins/useUpdateArtistCoin.ts +++ b/packages/common/src/api/tan-query/coins/useUpdateArtistCoin.ts @@ -71,7 +71,7 @@ export const useUpdateArtistCoin = () => { const response = await sdk.coins.updateCoin({ mint, userId: Id.parse(currentUserId), - updateCoinRequest: { + metadata: { description: updateCoinRequest.description, link1: updateCoinRequest.links?.[0] ?? '', link2: updateCoinRequest.links?.[1] ?? '', diff --git a/packages/common/src/utils/quickSearch.ts b/packages/common/src/utils/quickSearch.ts index 11658d17a63..a5dacac5bbc 100644 --- a/packages/common/src/utils/quickSearch.ts +++ b/packages/common/src/utils/quickSearch.ts @@ -35,14 +35,14 @@ export type QuickSearchPreset = { } export const QUICK_SEARCH_PRESETS: QuickSearchPreset[] = [ - { mood: Mood.FIERY, bpm: bpmDescriptions.UPBEAT }, - { genre: Genre.ELECTRONIC, mood: Mood.AGGRESSIVE }, + { mood: Mood.Fiery, bpm: bpmDescriptions.UPBEAT }, + { genre: Genre.ELECTRONIC, mood: Mood.Aggressive }, { genre: Genre.ALTERNATIVE, key: 'E Minor' }, { genre: Genre.HIP_HOP_RAP, bpm: bpmDescriptions.MEDIUM }, { genre: Genre.TECHNO, bpm: bpmDescriptions.UPBEAT }, { genre: Genre.LOFI, bpm: bpmDescriptions.SLOW }, { genre: Genre.DUBSTEP, bpm: bpmDescriptions._140 }, { genre: Genre.ROCK, isVerified: true }, - { genre: Genre.ALTERNATIVE, mood: Mood.ROMANTIC }, + { genre: Genre.ALTERNATIVE, mood: Mood.Romantic }, { key: 'A Minor', bpm: bpmDescriptions.SLOW } ] diff --git a/packages/sdk/src/sdk/api/albums/AlbumsApi.test.ts b/packages/sdk/src/sdk/api/albums/AlbumsApi.test.ts index 3b5d376831b..502f2dd3d51 100644 --- a/packages/sdk/src/sdk/api/albums/AlbumsApi.test.ts +++ b/packages/sdk/src/sdk/api/albums/AlbumsApi.test.ts @@ -20,9 +20,7 @@ import { import { SolanaClient } from '../../services/Solana/programs/SolanaClient' import { Storage } from '../../services/Storage' import { StorageNodeSelector } from '../../services/StorageNodeSelector' -import { Genre } from '../../types/Genre' -import { Mood } from '../../types/Mood' -import { Configuration } from '../generated/default' +import { Configuration, Genre, Mood } from '../generated/default' import { PlaylistsApi as GeneratedPlaylistsApi } from '../generated/default/apis/PlaylistsApi' import { TrackUploadHelper } from '../tracks/TrackUploadHelper' @@ -171,9 +169,9 @@ describe('AlbumsApi', () => { name: 'coverArt' }, metadata: { - genre: Genre.ACOUSTIC, + genre: Genre.Acoustic, albumName: 'My Album', - mood: Mood.TENDER + mood: Mood.Tender }, trackMetadatas: [ { @@ -230,9 +228,9 @@ describe('AlbumsApi', () => { name: 'coverArt' }, metadata: { - genre: Genre.ACOUSTIC, + genre: Genre.Acoustic, albumName: 'My Album edited', - mood: Mood.TENDER + mood: Mood.Tender } }) @@ -252,7 +250,7 @@ describe('AlbumsApi', () => { name: 'coverArt' }, metadata: { - mod: Mood.TENDER + mod: Mood.Tender } as any }) }).rejects.toThrow() diff --git a/packages/sdk/src/sdk/api/albums/AlbumsApi.ts b/packages/sdk/src/sdk/api/albums/AlbumsApi.ts index a5762ae65c9..3f28b30ca91 100644 --- a/packages/sdk/src/sdk/api/albums/AlbumsApi.ts +++ b/packages/sdk/src/sdk/api/albums/AlbumsApi.ts @@ -138,8 +138,8 @@ export class AlbumsApi { async updateAlbum(params: UpdateAlbumRequest, requestInit?: RequestInit) { await parseParams('updateAlbum', UpdateAlbumSchema)(params) - const { updateAlbumRequestBody, albumId, ...rest } = params - const { albumName, ...playlistMetadata } = updateAlbumRequestBody + const { metadata, albumId, ...rest } = params + const { albumName, ...playlistMetadata } = metadata // Transform album request to playlist request const playlistParams = { diff --git a/packages/sdk/src/sdk/api/albums/types.ts b/packages/sdk/src/sdk/api/albums/types.ts index 66aa8d0fb65..ed25ecf70ec 100644 --- a/packages/sdk/src/sdk/api/albums/types.ts +++ b/packages/sdk/src/sdk/api/albums/types.ts @@ -40,7 +40,7 @@ export type CreateAlbumRequest = { export type UpdateAlbumRequest = { userId: string albumId: string - updateAlbumRequestBody: UpdateAlbumRequestBody + metadata: UpdateAlbumRequestBody imageFile?: z.input onProgress?: UploadPlaylistProgressHandler } diff --git a/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts index bd4aaaaa871..fb26e551c03 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/CoinsApi.ts @@ -75,7 +75,7 @@ export interface ClaimCoinRewardCodeRequest { export interface CreateCoinRequest { userId: string; - createCoinRequestBody: CreateCoinRequestBody; + metadata: CreateCoinRequestBody; } export interface GetCoinRequest { @@ -131,7 +131,7 @@ export interface GetVolumeLeadersRequest { export interface UpdateCoinRequest { mint: string; userId: string; - updateCoinRequestBody: UpdateCoinRequestBody; + metadata: UpdateCoinRequestBody; } /** @@ -230,8 +230,8 @@ export class CoinsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createCoin.'); } - if (params.createCoinRequestBody === null || params.createCoinRequestBody === undefined) { - throw new runtime.RequiredError('createCoinRequestBody','Required parameter params.createCoinRequestBody was null or undefined when calling createCoin.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createCoin.'); } const queryParameters: any = {}; @@ -249,7 +249,7 @@ export class CoinsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateCoinRequestBodyToJSON(params.createCoinRequestBody), + body: CreateCoinRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateCoinResponseFromJSON(jsonValue)); @@ -611,8 +611,8 @@ export class CoinsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateCoin.'); } - if (params.updateCoinRequestBody === null || params.updateCoinRequestBody === undefined) { - throw new runtime.RequiredError('updateCoinRequestBody','Required parameter params.updateCoinRequestBody was null or undefined when calling updateCoin.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling updateCoin.'); } const queryParameters: any = {}; @@ -630,7 +630,7 @@ export class CoinsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UpdateCoinRequestBodyToJSON(params.updateCoinRequestBody), + body: UpdateCoinRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UpdateCoinResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts index fcea8fc85c8..cf97bd90bf3 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts @@ -43,7 +43,7 @@ import { export interface CreateCommentRequest { userId: string; - createCommentRequestBody: CreateCommentRequestBody; + metadata: CreateCommentRequestBody; } export interface DeleteCommentRequest { @@ -90,7 +90,7 @@ export interface UnreactToCommentRequest { export interface UpdateCommentRequest { commentId: string; userId: string; - updateCommentRequestBody: UpdateCommentRequestBody; + metadata: UpdateCommentRequestBody; } /** @@ -107,8 +107,8 @@ export class CommentsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createComment.'); } - if (params.createCommentRequestBody === null || params.createCommentRequestBody === undefined) { - throw new runtime.RequiredError('createCommentRequestBody','Required parameter params.createCommentRequestBody was null or undefined when calling createComment.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createComment.'); } const queryParameters: any = {}; @@ -137,7 +137,7 @@ export class CommentsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateCommentRequestBodyToJSON(params.createCommentRequestBody), + body: CreateCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateCommentResponseFromJSON(jsonValue)); @@ -565,8 +565,8 @@ export class CommentsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateComment.'); } - if (params.updateCommentRequestBody === null || params.updateCommentRequestBody === undefined) { - throw new runtime.RequiredError('updateCommentRequestBody','Required parameter params.updateCommentRequestBody was null or undefined when calling updateComment.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling updateComment.'); } const queryParameters: any = {}; @@ -595,7 +595,7 @@ export class CommentsApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: UpdateCommentRequestBodyToJSON(params.updateCommentRequestBody), + body: UpdateCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts index 1af0f3ef8c1..eb00ffc8304 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts @@ -34,7 +34,7 @@ import { export interface CreateDeveloperAppRequest { userId: string; - createDeveloperAppRequestBody: CreateDeveloperAppRequestBody; + metadata: CreateDeveloperAppRequestBody; } export interface DeleteDeveloperAppRequest { @@ -49,7 +49,7 @@ export interface GetDeveloperAppRequest { export interface UpdateDeveloperAppRequest { address: string; userId: string; - updateDeveloperAppRequestBody: UpdateDeveloperAppRequestBody; + metadata: UpdateDeveloperAppRequestBody; } /** @@ -66,8 +66,8 @@ export class DeveloperAppsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createDeveloperApp.'); } - if (params.createDeveloperAppRequestBody === null || params.createDeveloperAppRequestBody === undefined) { - throw new runtime.RequiredError('createDeveloperAppRequestBody','Required parameter params.createDeveloperAppRequestBody was null or undefined when calling createDeveloperApp.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createDeveloperApp.'); } const queryParameters: any = {}; @@ -96,7 +96,7 @@ export class DeveloperAppsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateDeveloperAppRequestBodyToJSON(params.createDeveloperAppRequestBody), + body: CreateDeveloperAppRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); @@ -204,8 +204,8 @@ export class DeveloperAppsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateDeveloperApp.'); } - if (params.updateDeveloperAppRequestBody === null || params.updateDeveloperAppRequestBody === undefined) { - throw new runtime.RequiredError('updateDeveloperAppRequestBody','Required parameter params.updateDeveloperAppRequestBody was null or undefined when calling updateDeveloperApp.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling updateDeveloperApp.'); } const queryParameters: any = {}; @@ -234,7 +234,7 @@ export class DeveloperAppsApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: UpdateDeveloperAppRequestBodyToJSON(params.updateDeveloperAppRequestBody), + body: UpdateDeveloperAppRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts index 63adba00ddf..10f1d0a8941 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/PrizesApi.ts @@ -33,7 +33,7 @@ import { } from '../models'; export interface ClaimPrizeRequest { - prizeClaimRequestBody: PrizeClaimRequestBody; + claim: PrizeClaimRequestBody; } export interface GetWalletPrizesRequest { @@ -50,8 +50,8 @@ export class PrizesApi extends runtime.BaseAPI { * Claims a prize by verifying a Solana transaction. User must send exactly 2 YAK to the prize receiver address. Returns the prize won and any redeem codes/URLs. */ async claimPrizeRaw(params: ClaimPrizeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.prizeClaimRequestBody === null || params.prizeClaimRequestBody === undefined) { - throw new runtime.RequiredError('prizeClaimRequestBody','Required parameter params.prizeClaimRequestBody was null or undefined when calling claimPrize.'); + if (params.claim === null || params.claim === undefined) { + throw new runtime.RequiredError('claim','Required parameter params.claim was null or undefined when calling claimPrize.'); } const queryParameters: any = {}; @@ -65,7 +65,7 @@ export class PrizesApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PrizeClaimRequestBodyToJSON(params.prizeClaimRequestBody), + body: PrizeClaimRequestBodyToJSON(params.claim), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PrizeClaimResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts index 924e071f611..8b421c67625 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/RewardsApi.ts @@ -33,11 +33,11 @@ import { } from '../models'; export interface ClaimRewardsRequest { - claimRewardsRequestBody: ClaimRewardsRequestBody; + reward: ClaimRewardsRequestBody; } export interface CreateRewardCodeRequest { - createRewardCodeRequestBody: CreateRewardCodeRequestBody; + body?: CreateRewardCodeRequestBody; } /** @@ -50,8 +50,8 @@ export class RewardsApi extends runtime.BaseAPI { * Claims all the filtered undisbursed rewards for a user */ async claimRewardsRaw(params: ClaimRewardsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.claimRewardsRequestBody === null || params.claimRewardsRequestBody === undefined) { - throw new runtime.RequiredError('claimRewardsRequestBody','Required parameter params.claimRewardsRequestBody was null or undefined when calling claimRewards.'); + if (params.reward === null || params.reward === undefined) { + throw new runtime.RequiredError('reward','Required parameter params.reward was null or undefined when calling claimRewards.'); } const queryParameters: any = {}; @@ -65,7 +65,7 @@ export class RewardsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: ClaimRewardsRequestBodyToJSON(params.claimRewardsRequestBody), + body: ClaimRewardsRequestBodyToJSON(params.reward), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClaimRewardsResponseFromJSON(jsonValue)); @@ -84,10 +84,6 @@ export class RewardsApi extends runtime.BaseAPI { * Creates a new reward code with Solana signature verification */ async createRewardCodeRaw(params: CreateRewardCodeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.createRewardCodeRequestBody === null || params.createRewardCodeRequestBody === undefined) { - throw new runtime.RequiredError('createRewardCodeRequestBody','Required parameter params.createRewardCodeRequestBody was null or undefined when calling createRewardCode.'); - } - const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -99,7 +95,7 @@ export class RewardsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateRewardCodeRequestBodyToJSON(params.createRewardCodeRequestBody), + body: CreateRewardCodeRequestBodyToJSON(params.body), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateRewardCodeResponseFromJSON(jsonValue)); @@ -108,7 +104,7 @@ export class RewardsApi extends runtime.BaseAPI { /** * Creates a new reward code with Solana signature verification */ - async createRewardCode(params: CreateRewardCodeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async createRewardCode(params: CreateRewardCodeRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createRewardCodeRaw(params, initOverrides); return await response.value(); } diff --git a/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts index b3e02c3e47e..57398dda538 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts @@ -302,7 +302,7 @@ export interface InspectTracksRequest { export interface RecordTrackDownloadRequest { trackId: string; - trackDownloadRequestBody?: TrackDownloadRequestBody; + location?: TrackDownloadRequestBody; } export interface RepostTrackRequest { @@ -1789,7 +1789,7 @@ export class TracksApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: TrackDownloadRequestBodyToJSON(params.trackDownloadRequestBody), + body: TrackDownloadRequestBodyToJSON(params.location), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts index 3d865f01bb1..3c7cb32c3ee 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts @@ -162,7 +162,7 @@ export interface CreateUserRequest { export interface CreateUserDeveloperAppRequest { id: string; - createUserDeveloperAppRequestBody: CreateUserDeveloperAppRequestBody; + metadata: CreateUserDeveloperAppRequestBody; } export interface CreateUserDeveloperAppAccessKeyRequest { @@ -173,7 +173,7 @@ export interface CreateUserDeveloperAppAccessKeyRequest { export interface DeactivateUserDeveloperAppAccessKeyRequest { id: string; address: string; - deactivateAccessKeyRequestBody: DeactivateAccessKeyRequestBody; + metadata: DeactivateAccessKeyRequestBody; } export interface DeleteUserDeveloperAppRequest { @@ -606,8 +606,8 @@ export class UsersApi extends runtime.BaseAPI { throw new runtime.RequiredError('id','Required parameter params.id was null or undefined when calling createUserDeveloperApp.'); } - if (params.createUserDeveloperAppRequestBody === null || params.createUserDeveloperAppRequestBody === undefined) { - throw new runtime.RequiredError('createUserDeveloperAppRequestBody','Required parameter params.createUserDeveloperAppRequestBody was null or undefined when calling createUserDeveloperApp.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createUserDeveloperApp.'); } const queryParameters: any = {}; @@ -632,7 +632,7 @@ export class UsersApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateUserDeveloperAppRequestBodyToJSON(params.createUserDeveloperAppRequestBody), + body: CreateUserDeveloperAppRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateUserDeveloperAppResponseFromJSON(jsonValue)); @@ -705,8 +705,8 @@ export class UsersApi extends runtime.BaseAPI { throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); } - if (params.deactivateAccessKeyRequestBody === null || params.deactivateAccessKeyRequestBody === undefined) { - throw new runtime.RequiredError('deactivateAccessKeyRequestBody','Required parameter params.deactivateAccessKeyRequestBody was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling deactivateUserDeveloperAppAccessKey.'); } const queryParameters: any = {}; @@ -731,7 +731,7 @@ export class UsersApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: DeactivateAccessKeyRequestBodyToJSON(params.deactivateAccessKeyRequestBody), + body: DeactivateAccessKeyRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DeactivateAccessKeyResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/full/.openapi-generator/FILES b/packages/sdk/src/sdk/api/generated/full/.openapi-generator/FILES index 42dcb4d043a..46828f852e8 100644 --- a/packages/sdk/src/sdk/api/generated/full/.openapi-generator/FILES +++ b/packages/sdk/src/sdk/api/generated/full/.openapi-generator/FILES @@ -62,6 +62,7 @@ models/CollectionActivityFull.ts models/CollectionActivityFullWithoutTracks.ts models/CollectionLibraryResponseFull.ts models/Comment.ts +models/CommentEntityType.ts models/CommentMention.ts models/CommentMentionNotification.ts models/CommentMentionNotificationAction.ts diff --git a/packages/sdk/src/sdk/api/generated/full/models/Comment.ts b/packages/sdk/src/sdk/api/generated/full/models/Comment.ts index aeb0335fd67..f1c108676f3 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/Comment.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/Comment.ts @@ -14,6 +14,12 @@ */ import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; import type { CommentMention } from './CommentMention'; import { CommentMentionFromJSON, @@ -47,10 +53,10 @@ export interface Comment { entityId: string; /** * - * @type {string} + * @type {CommentEntityType} * @memberof Comment */ - entityType: string; + entityType: CommentEntityType; /** * * @type {string} @@ -172,7 +178,7 @@ export function CommentFromJSONTyped(json: any, ignoreDiscriminator: boolean): C 'id': json['id'], 'entityId': json['entity_id'], - 'entityType': json['entity_type'], + 'entityType': CommentEntityTypeFromJSON(json['entity_type']), 'userId': !exists(json, 'user_id') ? undefined : json['user_id'], 'message': json['message'], 'mentions': !exists(json, 'mentions') ? undefined : ((json['mentions'] as Array).map(CommentMentionFromJSON)), @@ -202,7 +208,7 @@ export function CommentToJSON(value?: Comment | null): any { 'id': value.id, 'entity_id': value.entityId, - 'entity_type': value.entityType, + 'entity_type': CommentEntityTypeToJSON(value.entityType), 'user_id': value.userId, 'message': value.message, 'mentions': value.mentions === undefined ? undefined : ((value.mentions as Array).map(CommentMentionToJSON)), diff --git a/packages/sdk/src/sdk/api/generated/full/models/CommentEntityType.ts b/packages/sdk/src/sdk/api/generated/full/models/CommentEntityType.ts new file mode 100644 index 00000000000..1cb0f2ca916 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/full/models/CommentEntityType.ts @@ -0,0 +1,38 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Type of entity that can be commented on + * @export + */ +export const CommentEntityType = { + Track: 'Track' +} as const; +export type CommentEntityType = typeof CommentEntityType[keyof typeof CommentEntityType]; + + +export function CommentEntityTypeFromJSON(json: any): CommentEntityType { + return CommentEntityTypeFromJSONTyped(json, false); +} + +export function CommentEntityTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): CommentEntityType { + return json as CommentEntityType; +} + +export function CommentEntityTypeToJSON(value?: CommentEntityType | null): any { + return value as any; +} + diff --git a/packages/sdk/src/sdk/api/generated/full/models/ReplyComment.ts b/packages/sdk/src/sdk/api/generated/full/models/ReplyComment.ts index 19ba5f7be55..6cdcc0e7014 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/ReplyComment.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/ReplyComment.ts @@ -14,6 +14,12 @@ */ import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; import type { CommentMention } from './CommentMention'; import { CommentMentionFromJSON, @@ -41,10 +47,10 @@ export interface ReplyComment { entityId: string; /** * - * @type {string} + * @type {CommentEntityType} * @memberof ReplyComment */ - entityType: string; + entityType: CommentEntityType; /** * * @type {string} @@ -142,7 +148,7 @@ export function ReplyCommentFromJSONTyped(json: any, ignoreDiscriminator: boolea 'id': json['id'], 'entityId': json['entity_id'], - 'entityType': json['entity_type'], + 'entityType': CommentEntityTypeFromJSON(json['entity_type']), 'userId': json['user_id'], 'message': json['message'], 'mentions': !exists(json, 'mentions') ? undefined : ((json['mentions'] as Array).map(CommentMentionFromJSON)), @@ -168,7 +174,7 @@ export function ReplyCommentToJSON(value?: ReplyComment | null): any { 'id': value.id, 'entity_id': value.entityId, - 'entity_type': value.entityType, + 'entity_type': CommentEntityTypeToJSON(value.entityType), 'user_id': value.userId, 'message': value.message, 'mentions': value.mentions === undefined ? undefined : ((value.mentions as Array).map(CommentMentionToJSON)), diff --git a/packages/sdk/src/sdk/api/generated/full/models/index.ts b/packages/sdk/src/sdk/api/generated/full/models/index.ts index 0c5cc96ca24..2fccf1ba452 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/index.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/index.ts @@ -47,6 +47,7 @@ export * from './CollectionActivityFull'; export * from './CollectionActivityFullWithoutTracks'; export * from './CollectionLibraryResponseFull'; export * from './Comment'; +export * from './CommentEntityType'; export * from './CommentMention'; export * from './CommentMentionNotification'; export * from './CommentMentionNotificationAction'; From 36c570a1d379012b55610174718371fc432d8905 Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Fri, 13 Feb 2026 14:01:27 -0800 Subject: [PATCH 5/9] Fix splits --- .../src/adapters/accessConditionsFromSDK.ts | 36 ++++++++++++---- .../src/adapters/accessConditionsToSDK.ts | 42 ++++++++++++++++--- packages/common/src/adapters/collection.ts | 12 +++--- packages/common/src/adapters/track.ts | 4 +- .../collection/useUpdateCollection.ts | 10 +++-- .../tan-query/upload/usePublishCollection.ts | 6 +-- .../api/tan-query/upload/usePublishTracks.ts | 22 ++++++---- packages/common/src/models/Track.ts | 13 +++++- .../src/schemas/upload/uploadFormSchema.ts | 13 +++++- .../src/common/store/upload/sagaHelpers.ts | 14 +++++-- .../collection/CollectionCard.test.tsx | 4 +- .../priceAndAudienceSchema.ts | 4 +- 12 files changed, 132 insertions(+), 48 deletions(-) diff --git a/packages/common/src/adapters/accessConditionsFromSDK.ts b/packages/common/src/adapters/accessConditionsFromSDK.ts index 1e205eb11db..5b9b976416b 100644 --- a/packages/common/src/adapters/accessConditionsFromSDK.ts +++ b/packages/common/src/adapters/accessConditionsFromSDK.ts @@ -1,20 +1,38 @@ -import type { full } from '@audius/sdk' +import type { AccessGate, full } from '@audius/sdk' import { + instanceOfExtendedPurchaseGate, instanceOfFollowGate, - instanceOfPurchaseGate, - instanceOfTokenGate, - instanceOfNftGate -} from '@audius/sdk/src/sdk/api/generated/full' + instanceOfTokenGate +} from '@audius/sdk' import { AccessConditions } from '~/models' +/** Accepts default API AccessGate or full API AccessGate (e.g. from playlists). */ export const accessConditionsFromSDK = ( - input: full.AccessGate + input: AccessGate | full.AccessGate ): AccessConditions | null => { if (instanceOfFollowGate(input)) { return { follow_user_id: input.followUserId } - } else if (instanceOfPurchaseGate(input)) { - return { usdc_purchase: input.usdcPurchase } + } else if (instanceOfExtendedPurchaseGate(input)) { + const purchase = input.usdcPurchase + const splits = Array.isArray(purchase.splits) + ? purchase.splits.map((s) => ({ + user_id: s.userId, + percentage: s.percentage, + payout_wallet: s.payoutWallet, + amount: s.amount, + ...(s.ethWallet != null && { eth_wallet: s.ethWallet }) + })) + : [] + const albumTrackPrice = (purchase as { albumTrackPrice?: number }) + .albumTrackPrice + return { + usdc_purchase: { + price: purchase.price, + ...(albumTrackPrice != null && { albumTrackPrice }), + splits + } + } } else if (instanceOfTokenGate(input)) { return { token_gate: { @@ -22,7 +40,7 @@ export const accessConditionsFromSDK = ( token_amount: input.tokenGate.tokenAmount } } - } else if (instanceOfNftGate(input)) { + } else if ('nftCollection' in input && input.nftCollection != null) { return null } else { throw new Error(`Unsupported access gate type: ${JSON.stringify(input)}`) diff --git a/packages/common/src/adapters/accessConditionsToSDK.ts b/packages/common/src/adapters/accessConditionsToSDK.ts index 0457c5f22b6..936001bde3a 100644 --- a/packages/common/src/adapters/accessConditionsToSDK.ts +++ b/packages/common/src/adapters/accessConditionsToSDK.ts @@ -1,12 +1,46 @@ -import type { TrackMetadata } from '@audius/sdk' +import type { CreateAlbumMetadata, TrackMetadata } from '@audius/sdk' import { AccessConditions, isContentFollowGated, isContentTokenGated, - isContentUSDCPurchaseGated + isContentUSDCPurchaseGated, + type PaymentSplit, + type USDCPurchaseConditions } from '~/models' +/** Maps common USDC conditions to SDK format. Use for albums (stream conditions are USDC-only). */ +export const usdcPurchaseConditionsToSDK = ( + input: USDCPurchaseConditions +): NonNullable => { + const splits = input.usdc_purchase.splits ?? [] + return { + usdcPurchase: { + price: input.usdc_purchase.price, + ...(input.usdc_purchase.albumTrackPrice != null && { + albumTrackPrice: input.usdc_purchase.albumTrackPrice + }), + splits: splits.map( + ( + s: PaymentSplit & { + userId?: number + payoutWallet?: string + ethWallet?: string + } + ) => ({ + userId: s.user_id ?? s.userId, + percentage: s.percentage, + payoutWallet: s.payout_wallet ?? s.payoutWallet ?? '', + amount: s.amount, + ...((s.eth_wallet ?? s.ethWallet) != null && { + ethWallet: s.eth_wallet ?? s.ethWallet + }) + }) + ) + } + } +} + export const accessConditionsToSDK = ( input: AccessConditions ): TrackMetadata['downloadConditions'] => { @@ -15,9 +49,7 @@ export const accessConditionsToSDK = ( followUserId: input.follow_user_id } } else if (isContentUSDCPurchaseGated(input)) { - return { - usdcPurchase: input.usdc_purchase - } + return usdcPurchaseConditionsToSDK(input) } else if (isContentTokenGated(input)) { return { tokenGate: { diff --git a/packages/common/src/adapters/collection.ts b/packages/common/src/adapters/collection.ts index 3dc756dddcf..a2d1f2ca157 100644 --- a/packages/common/src/adapters/collection.ts +++ b/packages/common/src/adapters/collection.ts @@ -18,10 +18,11 @@ import { UserCollectionMetadata, Variant } from '~/models/Collection' -import { Copyright } from '~/models/Track' +import { Copyright, isContentUSDCPurchaseGated } from '~/models/Track' import type { AlbumValues, PlaylistValues } from '~/schemas' import { accessConditionsFromSDK } from './accessConditionsFromSDK' +import { usdcPurchaseConditionsToSDK } from './accessConditionsToSDK' import { resourceContributorFromSDK } from './attribution' import { favoriteFromSDK } from './favorite' import { coverArtSizesCIDsFromSDK } from './imageSize' @@ -135,7 +136,7 @@ export const userCollectionMetadataFromSDK = ( : null, stream_conditions: 'streamConditions' in input && input.streamConditions - ? accessConditionsFromSDK(input.streamConditions as full.AccessGate) + ? accessConditionsFromSDK(input.streamConditions) : null, tracks: transformAndCleanList( 'tracks' in input ? (input.tracks ?? []) : [], @@ -254,10 +255,9 @@ export const albumMetadataForCreateWithSDK = ( ): CreateAlbumMetadata => { return { streamConditions: - input.stream_conditions && 'usdc_purchase' in input.stream_conditions - ? { - usdcPurchase: input.stream_conditions.usdc_purchase - } + input.stream_conditions != null && + isContentUSDCPurchaseGated(input.stream_conditions) + ? usdcPurchaseConditionsToSDK(input.stream_conditions) : null, isStreamGated: input.is_stream_gated ?? false, isScheduledRelease: input.is_scheduled_release ?? false, diff --git a/packages/common/src/adapters/track.ts b/packages/common/src/adapters/track.ts index ddd9e13549f..575e5864d2b 100644 --- a/packages/common/src/adapters/track.ts +++ b/packages/common/src/adapters/track.ts @@ -177,11 +177,11 @@ export const userTrackMetadataFromSDK = ( permalink: input.permalink, is_stream_gated: input.isStreamGated ?? false, stream_conditions: input.streamConditions - ? accessConditionsFromSDK(input.streamConditions as full.AccessGate) + ? accessConditionsFromSDK(input.streamConditions) : null, is_download_gated: input.isDownloadGated ?? false, download_conditions: input.downloadConditions - ? accessConditionsFromSDK(input.downloadConditions as full.AccessGate) + ? accessConditionsFromSDK(input.downloadConditions) : null, access: { stream: access.stream, download: access.download }, is_available: input.isAvailable ?? true, diff --git a/packages/common/src/api/tan-query/collection/useUpdateCollection.ts b/packages/common/src/api/tan-query/collection/useUpdateCollection.ts index 90affce0749..7470d57ae56 100644 --- a/packages/common/src/api/tan-query/collection/useUpdateCollection.ts +++ b/packages/common/src/api/tan-query/collection/useUpdateCollection.ts @@ -105,9 +105,13 @@ export const useUpdateCollection = () => { collectionUpdate.stream_conditions = { usdc_purchase: { price: priceCents, - splits: { - [userBankStr]: priceWei - } + splits: [ + { + payout_wallet: userBankStr, + percentage: 100, + amount: priceWei + } + ] } } } diff --git a/packages/common/src/api/tan-query/upload/usePublishCollection.ts b/packages/common/src/api/tan-query/upload/usePublishCollection.ts index 1428b9c2da7..2c7e2683bad 100644 --- a/packages/common/src/api/tan-query/upload/usePublishCollection.ts +++ b/packages/common/src/api/tan-query/upload/usePublishCollection.ts @@ -71,7 +71,7 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) => // albumTrackPrice will be parsed out of the collection metadata, so we keep a copy here albumTrackPrice = params.collectionMetadata.stream_conditions?.usdc_purchase - .albumTrackPrice + .albumTrackPrice ?? undefined params.collectionMetadata.stream_conditions = getUSDCMetadata( userBank.toString(), params.collectionMetadata.stream_conditions @@ -249,14 +249,14 @@ function combineMetadata( metadata.download_conditions = { usdc_purchase: { price: albumTrackPrice, - splits: { 0: 0 } + splits: [] } } // Set up initial stream gating values metadata.is_stream_gated = true metadata.preview_start_seconds = 0 metadata.stream_conditions = { - usdc_purchase: { price: albumTrackPrice, splits: { 0: 0 } } + usdc_purchase: { price: albumTrackPrice, splits: [] } } // Add splits to stream & download conditions addPremiumMetadata(userBank, metadata) diff --git a/packages/common/src/api/tan-query/upload/usePublishTracks.ts b/packages/common/src/api/tan-query/upload/usePublishTracks.ts index 0a260dc0774..4fff4340bd8 100644 --- a/packages/common/src/api/tan-query/upload/usePublishTracks.ts +++ b/packages/common/src/api/tan-query/upload/usePublishTracks.ts @@ -230,25 +230,29 @@ export const usePublishTracks = ( /* * Given a user's bank and USDC purchase conditions, - * returns updated conditions with price in WEI and splits added. - * - * TODO: Update this to use the new user ID + percentages format. + * returns updated conditions with price in WEI and splits in the new array format. */ export function getUSDCMetadata( userBank: string, stream_conditions: USDCPurchaseConditions -) { +): USDCPurchaseConditions { const priceCents = stream_conditions.usdc_purchase.price const priceWei = Number(USDC(priceCents / 100).value.toString()) - const conditionsWithMetadata: USDCPurchaseConditions = { + return { usdc_purchase: { price: priceCents, - splits: { - [userBank?.toString() ?? '']: priceWei - } + ...(stream_conditions.usdc_purchase.albumTrackPrice != null && { + albumTrackPrice: stream_conditions.usdc_purchase.albumTrackPrice + }), + splits: [ + { + payout_wallet: userBank?.toString() ?? '', + percentage: 100, + amount: priceWei + } + ] } } - return conditionsWithMetadata } /** diff --git a/packages/common/src/models/Track.ts b/packages/common/src/models/Track.ts index efadc43c471..069f4fc53cf 100644 --- a/packages/common/src/models/Track.ts +++ b/packages/common/src/models/Track.ts @@ -64,11 +64,20 @@ export type NftGatedConditions = { } } +/** Single split in USDC purchase conditions (matches API extended_payment_split). */ +export type PaymentSplit = { + user_id?: number + percentage: number + payout_wallet: string + amount: number + eth_wallet?: string +} + export type USDCPurchaseConditions = { usdc_purchase: { price: number - albumTrackPrice?: number - splits: Record + albumTrackPrice?: number | null + splits?: PaymentSplit[] } } diff --git a/packages/common/src/schemas/upload/uploadFormSchema.ts b/packages/common/src/schemas/upload/uploadFormSchema.ts index a6e249cba62..5d851f1f0cb 100644 --- a/packages/common/src/schemas/upload/uploadFormSchema.ts +++ b/packages/common/src/schemas/upload/uploadFormSchema.ts @@ -35,12 +35,21 @@ const TokenGatedConditionsSchema = z }) .strict() -/** Same as SDK but snake-cased */ +/** Same as API extended_payment_split (snake-cased) */ +const PaymentSplitSchema = z.object({ + user_id: z.optional(z.number()), + percentage: z.number().min(0).max(100), + payout_wallet: z.string(), + amount: z.number().nonnegative(), + eth_wallet: z.optional(z.string()) +}) + +/** Same as SDK but snake-cased for USDC purchase conditions */ const USDCPurchaseConditionsSchema = z .object({ usdc_purchase: z.object({ price: z.number().positive(), - splits: z.any() + splits: z.array(PaymentSplitSchema).default([]) }) }) .strict() diff --git a/packages/web/src/common/store/upload/sagaHelpers.ts b/packages/web/src/common/store/upload/sagaHelpers.ts index 26df30f94ae..d3d9721b848 100644 --- a/packages/web/src/common/store/upload/sagaHelpers.ts +++ b/packages/web/src/common/store/upload/sagaHelpers.ts @@ -101,12 +101,20 @@ export function* getUSDCMetadata(stream_conditions: USDCPurchaseConditions) { const ownerUserbank = yield* call(getOrCreateUSDCUserBank, wallet) const priceCents = stream_conditions.usdc_purchase.price const priceWei = Number(USDC(priceCents / 100).value.toString()) + const payoutWallet = ownerUserbank?.toString() ?? '' const conditionsWithMetadata: USDCPurchaseConditions = { usdc_purchase: { price: priceCents, - splits: { - [ownerUserbank?.toString() ?? '']: priceWei - } + ...(stream_conditions.usdc_purchase.albumTrackPrice != null && { + albumTrackPrice: stream_conditions.usdc_purchase.albumTrackPrice + }), + splits: [ + { + payout_wallet: payoutWallet, + percentage: 100, + amount: priceWei + } + ] } } return conditionsWithMetadata diff --git a/packages/web/src/components/collection/CollectionCard.test.tsx b/packages/web/src/components/collection/CollectionCard.test.tsx index f0491eec45d..ce63f92252c 100644 --- a/packages/web/src/components/collection/CollectionCard.test.tsx +++ b/packages/web/src/components/collection/CollectionCard.test.tsx @@ -109,7 +109,7 @@ describe('CollectionCard', () => { ...testCollection, access: { stream: false }, stream_conditions: { - usdc_purchase: { price: 10, albumTrackPrice: 1, splits: {} } + usdc_purchase: { price: 10, albumTrackPrice: 1, splits: [] } } }) @@ -125,7 +125,7 @@ describe('CollectionCard', () => { ...testCollection, access: { stream: true, download: true }, stream_conditions: { - usdc_purchase: { price: 10, albumTrackPrice: 1, splits: {} } + usdc_purchase: { price: 10, albumTrackPrice: 1, splits: [] } } }) diff --git a/packages/web/src/components/edit/fields/price-and-audience/priceAndAudienceSchema.ts b/packages/web/src/components/edit/fields/price-and-audience/priceAndAudienceSchema.ts index 867c451d34c..65815e6190f 100644 --- a/packages/web/src/components/edit/fields/price-and-audience/priceAndAudienceSchema.ts +++ b/packages/web/src/components/edit/fields/price-and-audience/priceAndAudienceSchema.ts @@ -48,7 +48,7 @@ const refineMinPrice = isContentUSDCPurchaseGated(streamConditions) ) { const price = streamConditions.usdc_purchase[key] - return price !== undefined && price > 0 && price >= minContentPriceCents + return price != null && price > 0 && price >= minContentPriceCents } return true } @@ -62,7 +62,7 @@ const refineMaxPrice = isContentUSDCPurchaseGated(streamConditions) ) { const price = streamConditions.usdc_purchase[key] - return price !== undefined && price <= maxContentPriceCents + return price != null && price <= maxContentPriceCents } return true } From 4c247f5764587fbce61c9c5b47fdf1caf6a9f482 Mon Sep 17 00:00:00 2001 From: Marcus Pasell <3690498+rickyrombo@users.noreply.github.com> Date: Fri, 13 Feb 2026 14:15:32 -0800 Subject: [PATCH 6/9] Fix comments callsites w/ new autogen (#13704) --- .../tan-query/comments/useDeleteComment.ts | 6 +- .../api/tan-query/comments/useEditComment.ts | 24 +++--- .../api/tan-query/comments/usePinComment.ts | 24 ++++-- .../api/tan-query/comments/usePostComment.ts | 18 ++-- .../tan-query/comments/useReactToComment.ts | 15 +++- .../tan-query/comments/useReportComment.ts | 6 +- .../sdk/src/sdk/api/comments/CommentsAPI.ts | 30 +++---- .../api/generated/default/apis/CommentsApi.ts | 38 +++++++++ .../default/models/CommentEntityType.ts | 2 +- .../models/CreateCommentRequestBody.ts | 22 ++++- .../default/models/PinCommentRequestBody.ts | 67 +++++++++++++++ .../default/models/ReactCommentRequestBody.ts | 83 +++++++++++++++++++ .../models/UpdateCommentRequestBody.ts | 33 ++++++++ .../sdk/api/generated/default/models/index.ts | 2 + 14 files changed, 324 insertions(+), 46 deletions(-) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts diff --git a/packages/common/src/api/tan-query/comments/useDeleteComment.ts b/packages/common/src/api/tan-query/comments/useDeleteComment.ts index 0319d0841f9..eaab048aed7 100644 --- a/packages/common/src/api/tan-query/comments/useDeleteComment.ts +++ b/packages/common/src/api/tan-query/comments/useDeleteComment.ts @@ -1,3 +1,4 @@ +import { Id } from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' import { cloneDeep } from 'lodash' import { useDispatch } from 'react-redux' @@ -27,7 +28,10 @@ export const useDeleteComment = () => { const dispatch = useDispatch() return useMutation({ mutationFn: async ({ commentId, userId }: DeleteCommentArgs) => { - const commentData = { userId, entityId: commentId } + const commentData = { + userId: Id.parse(userId), + commentId: Id.parse(commentId) + } const sdk = await audiusSdk() return await sdk.comments.deleteComment(commentData) }, diff --git a/packages/common/src/api/tan-query/comments/useEditComment.ts b/packages/common/src/api/tan-query/comments/useEditComment.ts index 492d448a48c..3d20f0c1886 100644 --- a/packages/common/src/api/tan-query/comments/useEditComment.ts +++ b/packages/common/src/api/tan-query/comments/useEditComment.ts @@ -1,4 +1,4 @@ -import { EntityType, CommentMention } from '@audius/sdk' +import { EntityType, CommentMention, Id } from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' import { useDispatch } from 'react-redux' @@ -29,19 +29,19 @@ export const useEditComment = () => { userId, newMessage, trackId, - mentions, - entityType = EntityType.TRACK + mentions }: EditCommentArgs) => { - const commentData = { - body: newMessage, - userId, - entityId: commentId, - trackId, - entityType, - mentions: mentions?.map((mention) => mention.userId) ?? [] - } const sdk = await audiusSdk() - await sdk.comments.editComment(commentData) + await sdk.comments.updateComment({ + userId: Id.parse(userId)!, + commentId: Id.parse(commentId)!, + metadata: { + body: newMessage, + entityId: trackId, + entityType: 'Track', + mentions: mentions?.map((mention) => mention.userId) ?? [] + } + }) }, onMutate: ({ commentId, newMessage, mentions }) => { const prevComment = queryClient.getQueryData( diff --git a/packages/common/src/api/tan-query/comments/usePinComment.ts b/packages/common/src/api/tan-query/comments/usePinComment.ts index 669605a26a4..b9e25b51133 100644 --- a/packages/common/src/api/tan-query/comments/usePinComment.ts +++ b/packages/common/src/api/tan-query/comments/usePinComment.ts @@ -1,3 +1,4 @@ +import { Id } from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' import { cloneDeep } from 'lodash' import { useDispatch } from 'react-redux' @@ -29,12 +30,23 @@ export const usePinComment = () => { mutationFn: async (args: PinCommentArgs) => { const { userId, commentId, isPinned, trackId } = args const sdk = await audiusSdk() - return await sdk.comments.pinComment({ - userId, - entityId: commentId, - trackId, - isPin: isPinned - }) + if (isPinned) { + return await sdk.comments.pinComment({ + userId: Id.parse(userId)!, + commentId: Id.parse(commentId)!, + metadata: { + entityId: trackId + } + }) + } else { + return await sdk.comments.unpinComment({ + userId: Id.parse(userId)!, + commentId: Id.parse(commentId)!, + metadata: { + entityId: trackId + } + }) + } }, onMutate: ({ commentId, isPinned, trackId, currentSort }) => { if (isPinned) { diff --git a/packages/common/src/api/tan-query/comments/usePostComment.ts b/packages/common/src/api/tan-query/comments/usePostComment.ts index a704b047343..f068348d38a 100644 --- a/packages/common/src/api/tan-query/comments/usePostComment.ts +++ b/packages/common/src/api/tan-query/comments/usePostComment.ts @@ -1,4 +1,4 @@ -import { CommentMention, EntityType } from '@audius/sdk' +import { CommentMention, EntityType, Id } from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' import { cloneDeep } from 'lodash' @@ -32,11 +32,17 @@ export const usePostComment = () => { return useMutation({ mutationFn: async (args: PostCommentArgs) => { const sdk = await audiusSdk() - return await sdk.comments.postComment({ - ...args, - mentions: args.mentions?.map((mention) => mention.userId) ?? [], - entityId: args.trackId, - commentId: args.newId + return await sdk.comments.createComment({ + userId: Id.parse(args.userId)!, + metadata: { + commentId: args.newId, + entityId: args.trackId, + entityType: 'Track', + body: args.body, + trackTimestampS: args.trackTimestampS, + mentions: args.mentions?.map((mention) => mention.userId) ?? [], + parentId: args.parentCommentId + } }) }, onMutate: async (args: PostCommentArgs) => { diff --git a/packages/common/src/api/tan-query/comments/useReactToComment.ts b/packages/common/src/api/tan-query/comments/useReactToComment.ts index 8960d383fba..92862a5cd1b 100644 --- a/packages/common/src/api/tan-query/comments/useReactToComment.ts +++ b/packages/common/src/api/tan-query/comments/useReactToComment.ts @@ -1,3 +1,4 @@ +import { Id } from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' import { useDispatch } from 'react-redux' @@ -29,7 +30,19 @@ export const useReactToComment = () => { trackId }: ReactToCommentArgs) => { const sdk = await audiusSdk() - await sdk.comments.reactComment({ userId, commentId, isLiked, trackId }) + if (isLiked) { + await sdk.comments.reactToComment({ + userId: Id.parse(userId)!, + commentId: Id.parse(commentId)!, + metadata: { entityId: trackId, entityType: 'Track' } + }) + } else { + await sdk.comments.unreactToComment({ + userId: Id.parse(userId)!, + commentId: Id.parse(commentId)!, + metadata: { entityId: trackId, entityType: 'Track' } + }) + } }, mutationKey: ['reactToComment'], onMutate: async ({ diff --git a/packages/common/src/api/tan-query/comments/useReportComment.ts b/packages/common/src/api/tan-query/comments/useReportComment.ts index 8e75b629098..cfe0d94f9d2 100644 --- a/packages/common/src/api/tan-query/comments/useReportComment.ts +++ b/packages/common/src/api/tan-query/comments/useReportComment.ts @@ -1,3 +1,4 @@ +import { Id } from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' import { cloneDeep } from 'lodash' import { useDispatch } from 'react-redux' @@ -28,7 +29,10 @@ export const useReportComment = () => { return useMutation({ mutationFn: async ({ userId, commentId }: ReportCommentArgs) => { const sdk = await audiusSdk() - await sdk.comments.reportComment(userId, commentId) + await sdk.comments.reportComment({ + userId: Id.parse(userId)!, + commentId: Id.parse(commentId)! + }) }, onMutate: ({ trackId, commentId, currentSort, parentCommentId }) => { // Optimistic update - filter out the comment from either the top list or the parent comment's replies diff --git a/packages/sdk/src/sdk/api/comments/CommentsAPI.ts b/packages/sdk/src/sdk/api/comments/CommentsAPI.ts index 61ccdd675ba..3c58fba3d1d 100644 --- a/packages/sdk/src/sdk/api/comments/CommentsAPI.ts +++ b/packages/sdk/src/sdk/api/comments/CommentsAPI.ts @@ -85,16 +85,17 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const { createCommentRequestBody, userId } = params - const metadata: EntityManagerCreateCommentRequest = { + const { metadata, userId } = params + const commentId = await this.createCommentWithEntityManager({ userId, - entityId: createCommentRequestBody.entityId, - entityType: createCommentRequestBody.entityType, - body: createCommentRequestBody.body, - commentId: createCommentRequestBody.commentId, - parentCommentId: createCommentRequestBody.parentId - } - const commentId = await this.createCommentWithEntityManager(metadata) + entityId: encodeHashId(metadata.entityId) ?? '', + entityType: metadata.entityType, + body: metadata.body, + commentId: metadata.commentId, + parentCommentId: metadata.parentId, + trackTimestampS: metadata.trackTimestampS, + mentions: metadata.mentions + }) return { success: true, commentId: commentId ?? undefined @@ -132,14 +133,13 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const { updateCommentRequestBody, userId, commentId } = params - const metadata: EntityManagerUpdateCommentRequest = { + const { metadata, userId, commentId } = params + await this.updateCommentWithEntityManager({ userId, entityId: commentId, - trackId: commentId, // trackId is used for the entity being commented on - body: updateCommentRequestBody.body - } - await this.updateCommentWithEntityManager(metadata) + trackId: encodeHashId(metadata.entityId) ?? '', + body: metadata.body + }) return { success: true } diff --git a/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts index cf97bd90bf3..7c3d8a785e6 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/CommentsApi.ts @@ -20,6 +20,8 @@ import type { CommentResponse, CreateCommentRequestBody, CreateCommentResponse, + PinCommentRequestBody, + ReactCommentRequestBody, UnclaimedIdResponse, UpdateCommentRequestBody, WriteResponse, @@ -33,6 +35,10 @@ import { CreateCommentRequestBodyToJSON, CreateCommentResponseFromJSON, CreateCommentResponseToJSON, + PinCommentRequestBodyFromJSON, + PinCommentRequestBodyToJSON, + ReactCommentRequestBodyFromJSON, + ReactCommentRequestBodyToJSON, UnclaimedIdResponseFromJSON, UnclaimedIdResponseToJSON, UpdateCommentRequestBodyFromJSON, @@ -65,11 +71,13 @@ export interface GetCommentRepliesRequest { export interface PinCommentRequest { commentId: string; userId: string; + metadata: PinCommentRequestBody; } export interface ReactToCommentRequest { commentId: string; userId: string; + metadata: ReactCommentRequestBody; } export interface ReportCommentRequest { @@ -80,11 +88,13 @@ export interface ReportCommentRequest { export interface UnpinCommentRequest { commentId: string; userId: string; + metadata: PinCommentRequestBody; } export interface UnreactToCommentRequest { commentId: string; userId: string; + metadata: ReactCommentRequestBody; } export interface UpdateCommentRequest { @@ -315,6 +325,10 @@ export class CommentsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling pinComment.'); } + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling pinComment.'); + } + const queryParameters: any = {}; if (params.userId !== undefined) { @@ -323,6 +337,8 @@ export class CommentsApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; + headerParameters['Content-Type'] = 'application/json'; + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } @@ -339,6 +355,7 @@ export class CommentsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, + body: PinCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); @@ -365,6 +382,10 @@ export class CommentsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling reactToComment.'); } + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling reactToComment.'); + } + const queryParameters: any = {}; if (params.userId !== undefined) { @@ -373,6 +394,8 @@ export class CommentsApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; + headerParameters['Content-Type'] = 'application/json'; + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } @@ -389,6 +412,7 @@ export class CommentsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, + body: ReactCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); @@ -465,6 +489,10 @@ export class CommentsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unpinComment.'); } + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling unpinComment.'); + } + const queryParameters: any = {}; if (params.userId !== undefined) { @@ -473,6 +501,8 @@ export class CommentsApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; + headerParameters['Content-Type'] = 'application/json'; + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } @@ -489,6 +519,7 @@ export class CommentsApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, query: queryParameters, + body: PinCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); @@ -515,6 +546,10 @@ export class CommentsApi extends runtime.BaseAPI { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unreactToComment.'); } + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling unreactToComment.'); + } + const queryParameters: any = {}; if (params.userId !== undefined) { @@ -523,6 +558,8 @@ export class CommentsApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; + headerParameters['Content-Type'] = 'application/json'; + if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } @@ -539,6 +576,7 @@ export class CommentsApi extends runtime.BaseAPI { method: 'DELETE', headers: headerParameters, query: queryParameters, + body: ReactCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); diff --git a/packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts b/packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts index de4afdece48..02a05fabdf1 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CommentEntityType.ts @@ -15,7 +15,7 @@ /** - * Type of entity that can be commented on + * * @export */ export const CommentEntityType = { diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts index 810de0a90bd..381ab926df6 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts @@ -35,10 +35,10 @@ export interface CreateCommentRequestBody { entityType: CommentEntityType; /** * ID of the entity being commented on - * @type {string} + * @type {number} * @memberof CreateCommentRequestBody */ - entityId: string; + entityId: number; /** * Comment text * @type {string} @@ -46,7 +46,7 @@ export interface CreateCommentRequestBody { */ body: string; /** - * Optional comment ID + * Optional comment ID (will be generated if not provided) * @type {number} * @memberof CreateCommentRequestBody */ @@ -57,6 +57,18 @@ export interface CreateCommentRequestBody { * @memberof CreateCommentRequestBody */ parentId?: number; + /** + * Timestamp in the track where the comment was made (in seconds) + * @type {number} + * @memberof CreateCommentRequestBody + */ + trackTimestampS?: number; + /** + * Array of user IDs mentioned in the comment (max 10) + * @type {Array} + * @memberof CreateCommentRequestBody + */ + mentions?: Array; } /** @@ -86,6 +98,8 @@ export function CreateCommentRequestBodyFromJSONTyped(json: any, ignoreDiscrimin 'body': json['body'], 'commentId': !exists(json, 'commentId') ? undefined : json['commentId'], 'parentId': !exists(json, 'parentId') ? undefined : json['parentId'], + 'trackTimestampS': !exists(json, 'trackTimestampS') ? undefined : json['trackTimestampS'], + 'mentions': !exists(json, 'mentions') ? undefined : json['mentions'], }; } @@ -103,6 +117,8 @@ export function CreateCommentRequestBodyToJSON(value?: CreateCommentRequestBody 'body': value.body, 'commentId': value.commentId, 'parentId': value.parentId, + 'trackTimestampS': value.trackTimestampS, + 'mentions': value.mentions, }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts new file mode 100644 index 00000000000..75e2154e034 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts @@ -0,0 +1,67 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface PinCommentRequestBody + */ +export interface PinCommentRequestBody { + /** + * ID of the entity (track or playlist) the comment is on + * @type {number} + * @memberof PinCommentRequestBody + */ + entityId: number; +} + +/** + * Check if a given object implements the PinCommentRequestBody interface. + */ +export function instanceOfPinCommentRequestBody(value: object): value is PinCommentRequestBody { + let isInstance = true; + isInstance = isInstance && "entityId" in value && value["entityId"] !== undefined; + + return isInstance; +} + +export function PinCommentRequestBodyFromJSON(json: any): PinCommentRequestBody { + return PinCommentRequestBodyFromJSONTyped(json, false); +} + +export function PinCommentRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PinCommentRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'entityId': json['entityId'], + }; +} + +export function PinCommentRequestBodyToJSON(value?: PinCommentRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'entityId': value.entityId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts new file mode 100644 index 00000000000..f206127caa7 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts @@ -0,0 +1,83 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; + +/** + * + * @export + * @interface ReactCommentRequestBody + */ +export interface ReactCommentRequestBody { + /** + * + * @type {CommentEntityType} + * @memberof ReactCommentRequestBody + */ + entityType: CommentEntityType; + /** + * ID of the entity (track or playlist) being commented on + * @type {number} + * @memberof ReactCommentRequestBody + */ + entityId: number; +} + +/** + * Check if a given object implements the ReactCommentRequestBody interface. + */ +export function instanceOfReactCommentRequestBody(value: object): value is ReactCommentRequestBody { + let isInstance = true; + isInstance = isInstance && "entityType" in value && value["entityType"] !== undefined; + isInstance = isInstance && "entityId" in value && value["entityId"] !== undefined; + + return isInstance; +} + +export function ReactCommentRequestBodyFromJSON(json: any): ReactCommentRequestBody { + return ReactCommentRequestBodyFromJSONTyped(json, false); +} + +export function ReactCommentRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ReactCommentRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'entityType': CommentEntityTypeFromJSON(json['entityType']), + 'entityId': json['entityId'], + }; +} + +export function ReactCommentRequestBodyToJSON(value?: ReactCommentRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'entityType': CommentEntityTypeToJSON(value.entityType), + 'entityId': value.entityId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts index 405fc89e152..ad958840bb1 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts @@ -14,18 +14,43 @@ */ import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; + /** * * @export * @interface UpdateCommentRequestBody */ export interface UpdateCommentRequestBody { + /** + * + * @type {CommentEntityType} + * @memberof UpdateCommentRequestBody + */ + entityType: CommentEntityType; + /** + * ID of the entity being commented on + * @type {number} + * @memberof UpdateCommentRequestBody + */ + entityId: number; /** * The updated comment text * @type {string} * @memberof UpdateCommentRequestBody */ body: string; + /** + * Array of user IDs mentioned in the comment (max 10) + * @type {Array} + * @memberof UpdateCommentRequestBody + */ + mentions?: Array; } /** @@ -33,6 +58,8 @@ export interface UpdateCommentRequestBody { */ export function instanceOfUpdateCommentRequestBody(value: object): value is UpdateCommentRequestBody { let isInstance = true; + isInstance = isInstance && "entityType" in value && value["entityType"] !== undefined; + isInstance = isInstance && "entityId" in value && value["entityId"] !== undefined; isInstance = isInstance && "body" in value && value["body"] !== undefined; return isInstance; @@ -48,7 +75,10 @@ export function UpdateCommentRequestBodyFromJSONTyped(json: any, ignoreDiscrimin } return { + 'entityType': CommentEntityTypeFromJSON(json['entityType']), + 'entityId': json['entityId'], 'body': json['body'], + 'mentions': !exists(json, 'mentions') ? undefined : json['mentions'], }; } @@ -61,7 +91,10 @@ export function UpdateCommentRequestBodyToJSON(value?: UpdateCommentRequestBody } return { + 'entityType': CommentEntityTypeToJSON(value.entityType), + 'entityId': value.entityId, 'body': value.body, + 'mentions': value.mentions, }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/index.ts b/packages/sdk/src/sdk/api/generated/default/models/index.ts index 6b05c354502..791c42ad9fd 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/index.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/index.ts @@ -98,6 +98,7 @@ export * from './MediaLink'; export * from './MonthlyAggregatePlay'; export * from './Mood'; export * from './MutualFollowersResponse'; +export * from './PinCommentRequestBody'; export * from './Playlist'; export * from './PlaylistAddedTimestamp'; export * from './PlaylistArtwork'; @@ -111,6 +112,7 @@ export * from './PrizePublic'; export * from './PrizesResponse'; export * from './ProfilePicture'; export * from './PurchasersResponse'; +export * from './ReactCommentRequestBody'; export * from './RedeemAmountResponse'; export * from './RelatedArtistResponse'; export * from './RemixParent'; From fc782879e7bb1f2391949a341d5c180159b9708e Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Fri, 13 Feb 2026 15:43:33 -0800 Subject: [PATCH 7/9] Update genre and mood to use sdk types (#13705) --- packages/common/src/adapters/track.ts | 6 +- .../src/schemas/sign-on/selectGenresSchema.ts | 12 +- .../src/schemas/upload/uploadFormSchema.ts | 3 +- .../src/store/pages/trending/reducer.ts | 8 +- packages/common/src/store/upload/types.ts | 7 +- packages/common/src/utils/genres.ts | 176 +++++++----------- packages/common/src/utils/quickSearch.ts | 16 +- .../now-playing-drawer/NowPlayingDrawer.tsx | 8 +- .../trending-screen/TrendingFilterButton.tsx | 4 +- .../trending-screen/TrendingGenrePill.tsx | 8 +- .../src/components/now-playing/NowPlaying.tsx | 6 +- .../src/components/track/mobile/TrackTile.tsx | 4 +- .../web/src/pages/edit-page/EditTrackPage.tsx | 4 +- 13 files changed, 113 insertions(+), 149 deletions(-) diff --git a/packages/common/src/adapters/track.ts b/packages/common/src/adapters/track.ts index 575e5864d2b..c03ab98e4d6 100644 --- a/packages/common/src/adapters/track.ts +++ b/packages/common/src/adapters/track.ts @@ -1,8 +1,6 @@ import { type full, type CrossPlatformFile, - type Genre, - type Mood, type NativeFile, type Track, HashId, @@ -380,9 +378,9 @@ export const trackMetadataForUploadToSdk = (input: TrackMetadataForUpload) => ({ trackId: OptionalId.parse(input.track_id), title: input.title, description: squashNewLines(input.description) ?? undefined, - mood: input.mood as Mood, + mood: input.mood, tags: input.tags ?? undefined, - genre: (input.genre as Genre) || undefined, + genre: input.genre || undefined, releaseDate: input.release_date ? new Date(input.release_date) : undefined, previewStartSeconds: input.preview_start_seconds ?? undefined, previewCid: input.preview_cid ?? '', diff --git a/packages/common/src/schemas/sign-on/selectGenresSchema.ts b/packages/common/src/schemas/sign-on/selectGenresSchema.ts index 0e0b503def1..4bd504d060b 100644 --- a/packages/common/src/schemas/sign-on/selectGenresSchema.ts +++ b/packages/common/src/schemas/sign-on/selectGenresSchema.ts @@ -3,12 +3,12 @@ import { z } from 'zod' import { GENRES, Genre, convertGenreLabelToValue } from '~/utils/genres' const excludedGenres = new Set([ - Genre.COMEDY, - Genre.KIDS, - Genre.SOUNDTRACK, - Genre.DEVOTIONAL, - Genre.AUDIOBOOKS, - Genre.SPOKEN_WORK + Genre.Comedy, + Genre.Kids, + Genre.Soundtrack, + Genre.Devotional, + Genre.Audiobooks, + Genre.SpokenWord ]) export const selectableGenres = GENRES.filter( diff --git a/packages/common/src/schemas/upload/uploadFormSchema.ts b/packages/common/src/schemas/upload/uploadFormSchema.ts index 5d851f1f0cb..3d52f6cd64d 100644 --- a/packages/common/src/schemas/upload/uploadFormSchema.ts +++ b/packages/common/src/schemas/upload/uploadFormSchema.ts @@ -64,8 +64,9 @@ const GenreSchema = z /** Same as SDK. */ const MoodSchema = z - .optional(z.enum(Object.values(Mood) as [Mood, ...Mood[]])) + .enum(Object.values(Mood) as [Mood, ...Mood[]]) .nullable() + .optional() const DDEXResourceContributor = z .object({ diff --git a/packages/common/src/store/pages/trending/reducer.ts b/packages/common/src/store/pages/trending/reducer.ts index 2a2b6e831c7..17af3e72d31 100644 --- a/packages/common/src/store/pages/trending/reducer.ts +++ b/packages/common/src/store/pages/trending/reducer.ts @@ -17,7 +17,7 @@ import { TRENDING_MONTH_PREFIX, TRENDING_ALL_TIME_PREFIX } from '~/store/pages/trending/lineup/actions' -import { GENRES, Genre } from '~/utils/genres' +import { ALL_GENRES, GENRES, Genre } from '~/utils/genres' import { TimeRange, Track } from '../../../models' @@ -103,7 +103,11 @@ const reducer = ? timeRange : TimeRange.WEEK, trendingGenre: - genre && Object.values(GENRES).includes(genre) ? genre : null + genre === ALL_GENRES + ? null + : genre && GENRES.includes(genre) + ? genre + : null } } diff --git a/packages/common/src/store/upload/types.ts b/packages/common/src/store/upload/types.ts index b73f71d8755..8ca5de6174b 100644 --- a/packages/common/src/store/upload/types.ts +++ b/packages/common/src/store/upload/types.ts @@ -1,4 +1,4 @@ -import { NativeFile } from '@audius/sdk' +import { type Genre, type Mood, NativeFile } from '@audius/sdk' import { CollectionValues } from '~/schemas' @@ -39,9 +39,12 @@ export const isTrackForUpload = ( * Unlike normal Track metadata, TrackMetadataForUpload includes additional * files: artwork and a stems field with StemsForUpload. * This type is used for both Upload and Edit flows. + * Uses SDK Genre/Mood for type safety when passing to SDK. */ export interface TrackMetadataForUpload - extends Omit { + extends Omit { + genre?: Genre | '' + mood?: Mood | null artwork?: | Nullable<{ file?: Blob | NativeFile diff --git a/packages/common/src/utils/genres.ts b/packages/common/src/utils/genres.ts index d55ba9c7b4f..f4de94d1d23 100644 --- a/packages/common/src/utils/genres.ts +++ b/packages/common/src/utils/genres.ts @@ -1,127 +1,83 @@ -export enum Genre { - ALL = 'All Genres', - ELECTRONIC = 'Electronic', - ROCK = 'Rock', - METAL = 'Metal', - ALTERNATIVE = 'Alternative', - HIP_HOP_RAP = 'Hip-Hop/Rap', - EXPERIMENTAL = 'Experimental', - PUNK = 'Punk', - FOLK = 'Folk', - POP = 'Pop', - AMBIENT = 'Ambient', - SOUNDTRACK = 'Soundtrack', - WORLD = 'World', - JAZZ = 'Jazz', - ACOUSTIC = 'Acoustic', - FUNK = 'Funk', - R_AND_B_SOUL = 'R&B/Soul', - DEVOTIONAL = 'Devotional', - CLASSICAL = 'Classical', - REGGAE = 'Reggae', - PODCASTS = 'Podcasts', - COUNTRY = 'Country', - SPOKEN_WORK = 'Spoken Word', - COMEDY = 'Comedy', - BLUES = 'Blues', - KIDS = 'Kids', - AUDIOBOOKS = 'Audiobooks', - LATIN = 'Latin', - LOFI = 'Lo-Fi', - HYPERPOP = 'Hyperpop', - DANCEHALL = 'Dancehall', +import { Genre as SDKGenre } from '@audius/sdk' - // Electronic Subgenres - TECHNO = 'Techno', - TRAP = 'Trap', - HOUSE = 'House', - TECH_HOUSE = 'Tech House', - DEEP_HOUSE = 'Deep House', - DISCO = 'Disco', - ELECTRO = 'Electro', - JUNGLE = 'Jungle', - PROGRESSIVE_HOUSE = 'Progressive House', - HARDSTYLE = 'Hardstyle', - GLITCH_HOP = 'Glitch Hop', - TRANCE = 'Trance', - FUTURE_BASS = 'Future Bass', - FUTURE_HOUSE = 'Future House', - TROPICAL_HOUSE = 'Tropical House', - DOWNTEMPO = 'Downtempo', - DRUM_AND_BASS = 'Drum & Bass', - DUBSTEP = 'Dubstep', - JERSEY_CLUB = 'Jersey Club', - VAPORWAVE = 'Vaporwave', - MOOMBAHTON = 'Moombahton' -} +/** Re-export SDK Genre as the canonical source for track metadata. */ +export { Genre } from '@audius/sdk' + +/** + * UI-only value for "all genres" filter (e.g. trending page). + * Not part of SDK Genre - use for filter state only. + */ +export const ALL_GENRES = 'All Genres' as const +export type AllGenres = typeof ALL_GENRES export const ELECTRONIC_PREFIX = 'Electronic - ' export const ELECTRONIC_SUBGENRES: Partial< - Record + Record > = { - [Genre.TECHNO]: `${ELECTRONIC_PREFIX}${Genre.TECHNO}`, - [Genre.TRAP]: `${ELECTRONIC_PREFIX}${Genre.TRAP}`, - [Genre.HOUSE]: `${ELECTRONIC_PREFIX}${Genre.HOUSE}`, - [Genre.TECH_HOUSE]: `${ELECTRONIC_PREFIX}${Genre.TECH_HOUSE}`, - [Genre.DEEP_HOUSE]: `${ELECTRONIC_PREFIX}${Genre.DEEP_HOUSE}`, - [Genre.DISCO]: `${ELECTRONIC_PREFIX}${Genre.DISCO}`, - [Genre.ELECTRO]: `${ELECTRONIC_PREFIX}${Genre.ELECTRO}`, - [Genre.JUNGLE]: `${ELECTRONIC_PREFIX}${Genre.JUNGLE}`, - [Genre.PROGRESSIVE_HOUSE]: `${ELECTRONIC_PREFIX}${Genre.PROGRESSIVE_HOUSE}`, - [Genre.HARDSTYLE]: `${ELECTRONIC_PREFIX}${Genre.HARDSTYLE}`, - [Genre.GLITCH_HOP]: `${ELECTRONIC_PREFIX}${Genre.GLITCH_HOP}`, - [Genre.TRANCE]: `${ELECTRONIC_PREFIX}${Genre.TRANCE}`, - [Genre.FUTURE_BASS]: `${ELECTRONIC_PREFIX}${Genre.FUTURE_BASS}`, - [Genre.FUTURE_HOUSE]: `${ELECTRONIC_PREFIX}${Genre.FUTURE_HOUSE}`, - [Genre.TROPICAL_HOUSE]: `${ELECTRONIC_PREFIX}${Genre.TROPICAL_HOUSE}`, - [Genre.DOWNTEMPO]: `${ELECTRONIC_PREFIX}${Genre.DOWNTEMPO}`, - [Genre.DRUM_AND_BASS]: `${ELECTRONIC_PREFIX}${Genre.DRUM_AND_BASS}`, - [Genre.DUBSTEP]: `${ELECTRONIC_PREFIX}${Genre.DUBSTEP}`, - [Genre.JERSEY_CLUB]: `${ELECTRONIC_PREFIX}${Genre.JERSEY_CLUB}`, - [Genre.VAPORWAVE]: `${ELECTRONIC_PREFIX}${Genre.VAPORWAVE}`, - [Genre.MOOMBAHTON]: `${ELECTRONIC_PREFIX}${Genre.MOOMBAHTON}` + [SDKGenre.Techno]: `${ELECTRONIC_PREFIX}${SDKGenre.Techno}`, + [SDKGenre.Trap]: `${ELECTRONIC_PREFIX}${SDKGenre.Trap}`, + [SDKGenre.House]: `${ELECTRONIC_PREFIX}${SDKGenre.House}`, + [SDKGenre.TechHouse]: `${ELECTRONIC_PREFIX}${SDKGenre.TechHouse}`, + [SDKGenre.DeepHouse]: `${ELECTRONIC_PREFIX}${SDKGenre.DeepHouse}`, + [SDKGenre.Disco]: `${ELECTRONIC_PREFIX}${SDKGenre.Disco}`, + [SDKGenre.Electro]: `${ELECTRONIC_PREFIX}${SDKGenre.Electro}`, + [SDKGenre.Jungle]: `${ELECTRONIC_PREFIX}${SDKGenre.Jungle}`, + [SDKGenre.ProgressiveHouse]: `${ELECTRONIC_PREFIX}${SDKGenre.ProgressiveHouse}`, + [SDKGenre.Hardstyle]: `${ELECTRONIC_PREFIX}${SDKGenre.Hardstyle}`, + [SDKGenre.GlitchHop]: `${ELECTRONIC_PREFIX}${SDKGenre.GlitchHop}`, + [SDKGenre.Trance]: `${ELECTRONIC_PREFIX}${SDKGenre.Trance}`, + [SDKGenre.FutureBass]: `${ELECTRONIC_PREFIX}${SDKGenre.FutureBass}`, + [SDKGenre.FutureHouse]: `${ELECTRONIC_PREFIX}${SDKGenre.FutureHouse}`, + [SDKGenre.TropicalHouse]: `${ELECTRONIC_PREFIX}${SDKGenre.TropicalHouse}`, + [SDKGenre.Downtempo]: `${ELECTRONIC_PREFIX}${SDKGenre.Downtempo}`, + [SDKGenre.DrumBass]: `${ELECTRONIC_PREFIX}${SDKGenre.DrumBass}`, + [SDKGenre.Dubstep]: `${ELECTRONIC_PREFIX}${SDKGenre.Dubstep}`, + [SDKGenre.JerseyClub]: `${ELECTRONIC_PREFIX}${SDKGenre.JerseyClub}`, + [SDKGenre.Vaporwave]: `${ELECTRONIC_PREFIX}${SDKGenre.Vaporwave}`, + [SDKGenre.Moombahton]: `${ELECTRONIC_PREFIX}${SDKGenre.Moombahton}` } -export const getCanonicalName = (genre: Genre | any) => { - if (genre in ELECTRONIC_SUBGENRES) return ELECTRONIC_SUBGENRES[genre as Genre] +export const getCanonicalName = (genre: SDKGenre | string) => { + if (genre in ELECTRONIC_SUBGENRES) + return ELECTRONIC_SUBGENRES[genre as SDKGenre] return genre } /** User-facing genre labels. Use `convertGenreLabelToValue` to get the correct genre value (to set as the genre in track metadata). */ export const GENRES = [ - Genre.ELECTRONIC, - Genre.ROCK, - Genre.METAL, - Genre.ALTERNATIVE, - Genre.HIP_HOP_RAP, - Genre.EXPERIMENTAL, - Genre.PUNK, - Genre.FOLK, - Genre.POP, - Genre.AMBIENT, - Genre.SOUNDTRACK, - Genre.WORLD, - Genre.JAZZ, - Genre.ACOUSTIC, - Genre.FUNK, - Genre.R_AND_B_SOUL, - Genre.DEVOTIONAL, - Genre.CLASSICAL, - Genre.REGGAE, - Genre.PODCASTS, - Genre.COUNTRY, - Genre.SPOKEN_WORK, - Genre.COMEDY, - Genre.BLUES, - Genre.KIDS, - Genre.AUDIOBOOKS, - Genre.LATIN, - Genre.LOFI, - Genre.HYPERPOP, - Genre.DANCEHALL, + SDKGenre.Electronic, + SDKGenre.Rock, + SDKGenre.Metal, + SDKGenre.Alternative, + SDKGenre.HipHopRap, + SDKGenre.Experimental, + SDKGenre.Punk, + SDKGenre.Folk, + SDKGenre.Pop, + SDKGenre.Ambient, + SDKGenre.Soundtrack, + SDKGenre.World, + SDKGenre.Jazz, + SDKGenre.Acoustic, + SDKGenre.Funk, + SDKGenre.RbSoul, + SDKGenre.Devotional, + SDKGenre.Classical, + SDKGenre.Reggae, + SDKGenre.Podcasts, + SDKGenre.Country, + SDKGenre.SpokenWord, + SDKGenre.Comedy, + SDKGenre.Blues, + SDKGenre.Kids, + SDKGenre.Audiobooks, + SDKGenre.Latin, + SDKGenre.LoFi, + SDKGenre.Hyperpop, + SDKGenre.Dancehall, ...Object.values(ELECTRONIC_SUBGENRES) -] +] as const export const convertGenreLabelToValue = ( genreLabel: (typeof GENRES)[number] diff --git a/packages/common/src/utils/quickSearch.ts b/packages/common/src/utils/quickSearch.ts index a5dacac5bbc..f11c416bcc4 100644 --- a/packages/common/src/utils/quickSearch.ts +++ b/packages/common/src/utils/quickSearch.ts @@ -36,13 +36,13 @@ export type QuickSearchPreset = { export const QUICK_SEARCH_PRESETS: QuickSearchPreset[] = [ { mood: Mood.Fiery, bpm: bpmDescriptions.UPBEAT }, - { genre: Genre.ELECTRONIC, mood: Mood.Aggressive }, - { genre: Genre.ALTERNATIVE, key: 'E Minor' }, - { genre: Genre.HIP_HOP_RAP, bpm: bpmDescriptions.MEDIUM }, - { genre: Genre.TECHNO, bpm: bpmDescriptions.UPBEAT }, - { genre: Genre.LOFI, bpm: bpmDescriptions.SLOW }, - { genre: Genre.DUBSTEP, bpm: bpmDescriptions._140 }, - { genre: Genre.ROCK, isVerified: true }, - { genre: Genre.ALTERNATIVE, mood: Mood.Romantic }, + { genre: Genre.Electronic, mood: Mood.Aggressive }, + { genre: Genre.Alternative, key: 'E Minor' }, + { genre: Genre.HipHopRap, bpm: bpmDescriptions.MEDIUM }, + { genre: Genre.Techno, bpm: bpmDescriptions.UPBEAT }, + { genre: Genre.LoFi, bpm: bpmDescriptions.SLOW }, + { genre: Genre.Dubstep, bpm: bpmDescriptions._140 }, + { genre: Genre.Rock, isVerified: true }, + { genre: Genre.Alternative, mood: Mood.Romantic }, { key: 'A Minor', bpm: bpmDescriptions.SLOW } ] diff --git a/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx b/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx index d1390303f75..0e5e2c83824 100644 --- a/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx +++ b/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx @@ -236,7 +236,7 @@ export const NowPlayingDrawer = memo(function NowPlayingDrawer( const onNext = useCallback(async () => { const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks if (isLongFormContent) { const { position: currentPosition } = await TrackPlayer.getProgress() const newPosition = currentPosition + SKIP_DURATION_SEC @@ -250,7 +250,7 @@ export const NowPlayingDrawer = memo(function NowPlayingDrawer( const onPrevious = useCallback(async () => { const { position: currentPosition } = await TrackPlayer.getProgress() const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks if (isLongFormContent) { const newPosition = currentPosition - SKIP_DURATION_SEC dispatch(seek({ seconds: Math.max(0, newPosition) })) @@ -347,8 +347,8 @@ export const NowPlayingDrawer = memo(function NowPlayingDrawer( onNext={onNext} onPrevious={onPrevious} isLongFormContent={ - track?.genre === Genre.PODCASTS || - track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || + track?.genre === Genre.Audiobooks } /> diff --git a/packages/mobile/src/screens/trending-screen/TrendingFilterButton.tsx b/packages/mobile/src/screens/trending-screen/TrendingFilterButton.tsx index 367127f680b..891b3be7c74 100644 --- a/packages/mobile/src/screens/trending-screen/TrendingFilterButton.tsx +++ b/packages/mobile/src/screens/trending-screen/TrendingFilterButton.tsx @@ -1,7 +1,7 @@ import { useCallback } from 'react' import { modalsActions, trendingPageSelectors } from '@audius/common/store' -import { Genre } from '@audius/common/utils' +import { ALL_GENRES } from '@audius/common/utils' import { useDispatch, useSelector } from 'react-redux' import { FilterButton } from '@audius/harmony-native' @@ -13,7 +13,7 @@ const { setVisibility } = modalsActions export const TrendingFilterButton = () => { const dispatch = useDispatch() - const trendingGenre = useSelector(getTrendingGenre) ?? Genre.ALL + const trendingGenre = useSelector(getTrendingGenre) ?? ALL_GENRES const handlePress = useCallback(() => { dispatch(setVisibility({ modal: MODAL_NAME, visible: true })) diff --git a/packages/mobile/src/screens/trending-screen/TrendingGenrePill.tsx b/packages/mobile/src/screens/trending-screen/TrendingGenrePill.tsx index 424c455ebd1..44c911b16ff 100644 --- a/packages/mobile/src/screens/trending-screen/TrendingGenrePill.tsx +++ b/packages/mobile/src/screens/trending-screen/TrendingGenrePill.tsx @@ -6,7 +6,7 @@ import { trendingPageLineupActions, trendingPageSelectors } from '@audius/common/store' -import { Genre } from '@audius/common/utils' +import { ALL_GENRES, Genre } from '@audius/common/utils' import { useDispatch, useSelector } from 'react-redux' import { IconCloseAlt, SelectablePill } from '@audius/harmony-native' @@ -21,12 +21,12 @@ const { trendingWeekActions, trendingMonthActions, trendingAllTimeActions } = export const TrendingGenrePill = () => { const dispatch = useDispatch() - const genre = useSelector(getTrendingGenre) ?? Genre.ALL + const genre = useSelector(getTrendingGenre) ?? ALL_GENRES - const isSelected = genre !== Genre.ALL + const isSelected = genre !== ALL_GENRES const handlePress = useCallback(() => { - if (genre === Genre.ALL) { + if (genre === ALL_GENRES) { dispatch(setVisibility({ modal: MODAL_NAME, visible: true })) } }, [dispatch, genre]) diff --git a/packages/web/src/components/now-playing/NowPlaying.tsx b/packages/web/src/components/now-playing/NowPlaying.tsx index cdc948e45c3..e08e86142de 100644 --- a/packages/web/src/components/now-playing/NowPlaying.tsx +++ b/packages/web/src/components/now-playing/NowPlaying.tsx @@ -163,7 +163,7 @@ const NowPlaying = g( const playbackRate = useSelector(getPlaybackRate) const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks const startSeeking = useCallback(() => { clearInterval(seekInterval.current) @@ -313,7 +313,7 @@ const NowPlaying = g( const onPrevious = () => { const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks if (isLongFormContent) { const position = timing.position const newPosition = position - SKIP_DURATION_SEC @@ -333,7 +333,7 @@ const NowPlaying = g( const onNext = () => { const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks if (isLongFormContent) { const newPosition = timing.position + SKIP_DURATION_SEC seek(Math.min(newPosition, timing.duration)) diff --git a/packages/web/src/components/track/mobile/TrackTile.tsx b/packages/web/src/components/track/mobile/TrackTile.tsx index 586d1d71d98..24610d989e7 100644 --- a/packages/web/src/components/track/mobile/TrackTile.tsx +++ b/packages/web/src/components/track/mobile/TrackTile.tsx @@ -236,7 +236,7 @@ export const TrackTile = ({ const onClickOverflow = useCallback( (trackId: ID) => { const isLongFormContent = - genre === Genre.PODCASTS || genre === Genre.AUDIOBOOKS + genre === Genre.Podcasts || genre === Genre.Audiobooks const repostAction = !isOwner && hasStreamAccess @@ -395,7 +395,7 @@ export const TrackTile = ({ {duration ? formatLineupTileDuration( duration, - genre === Genre.PODCASTS || genre === Genre.AUDIOBOOKS + genre === Genre.Podcasts || genre === Genre.Audiobooks ) : null} diff --git a/packages/web/src/pages/edit-page/EditTrackPage.tsx b/packages/web/src/pages/edit-page/EditTrackPage.tsx index 80d3be6b81e..fe750a85ba5 100644 --- a/packages/web/src/pages/edit-page/EditTrackPage.tsx +++ b/packages/web/src/pages/edit-page/EditTrackPage.tsx @@ -1,5 +1,6 @@ import { createContext } from 'react' +import type { Genre, Mood } from '@audius/sdk' import { fileToSdk } from '@audius/common/adapters' import { useStems, useTrackByParams, useUpdateTrack } from '@audius/common/api' import { SquareSizes, StemUpload, TrackMetadata } from '@audius/common/models' @@ -110,7 +111,8 @@ export const EditTrackPage = (props: EditPageProps) => { const trackAsMetadataForUpload: TrackMetadataForUpload = { ...(track as TrackMetadata), - mood: track?.mood || null, + genre: (track?.genre as Genre) ?? '', + mood: (track?.mood as Mood) ?? null, artwork: { url: coverArtUrl || '' }, From 404656116b66ee2962b4ad8e1107298e8b5a7ae6 Mon Sep 17 00:00:00 2001 From: Marcus Pasell <3690498+rickyrombo@users.noreply.github.com> Date: Fri, 13 Feb 2026 15:56:31 -0800 Subject: [PATCH 8/9] Some minor fixes and user fixes (#13706) - Add user events - Fix some comment hangovers from previous gen - Minor edits for renamed request names - some wip stuff... more to come for users but getting this up to see where we're at --- packages/common/src/adapters/user.ts | 5 +- .../api/tan-query/comments/usePinComment.ts | 6 +- .../api/developer-apps/DeveloperAppsApi.ts | 4 +- .../default/.openapi-generator/FILES | 9 ++ .../api/generated/default/apis/UsersApi.ts | 9 -- .../default/models/CreateUserRequestBody.ts | 29 +++++ .../models/CreateUserRequestBodyEvents.ts | 74 ++++++++++++ .../CreateUserRequestBodyPlaylistLibrary.ts | 74 ++++++++++++ ...RequestBodyPlaylistLibraryContentsInner.ts | 76 ++++++++++++ .../default/models/PinCommentRequestBody.ts | 16 +++ ...laylistLibraryExplorePlaylistIdentifier.ts | 86 ++++++++++++++ .../default/models/PlaylistLibraryFolder.ts | 111 ++++++++++++++++++ .../PlaylistLibraryPlaylistIdentifier.ts | 86 ++++++++++++++ .../default/models/UpdateUserRequestBody.ts | 33 +++++- .../UpdateUserRequestBodyPlaylistLibrary.ts | 73 ++++++++++++ .../sdk/api/generated/default/models/index.ts | 7 ++ packages/sdk/src/sdk/api/users/UsersApi.ts | 10 +- .../common/store/pages/audio-rewards/sagas.ts | 2 +- .../oauth-login-page/OAuthSignUpPage.tsx | 9 +- 19 files changed, 690 insertions(+), 29 deletions(-) create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryExplorePlaylistIdentifier.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryPlaylistIdentifier.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts diff --git a/packages/common/src/adapters/user.ts b/packages/common/src/adapters/user.ts index 409dc346643..70e344122aa 100644 --- a/packages/common/src/adapters/user.ts +++ b/packages/common/src/adapters/user.ts @@ -1,7 +1,6 @@ import { HashId, OptionalHashId, - OptionalId, type full, type User, type UpdateUserRequest @@ -233,9 +232,9 @@ export const userMetadataToSdk = ( ), bio: input.bio ?? undefined, website: input.website ?? undefined, - artistPickTrackId: OptionalId.parse(input.artist_pick_track_id ?? undefined), + artistPickTrackId: input.artist_pick_track_id ?? undefined, events: { - referrer: OptionalId.parse(input.events?.referrer ?? undefined), + referrer: input.events?.referrer ?? undefined, isMobileUser: input.events?.is_mobile_user ?? undefined }, location: input.location ?? undefined, diff --git a/packages/common/src/api/tan-query/comments/usePinComment.ts b/packages/common/src/api/tan-query/comments/usePinComment.ts index b9e25b51133..b59c8acd111 100644 --- a/packages/common/src/api/tan-query/comments/usePinComment.ts +++ b/packages/common/src/api/tan-query/comments/usePinComment.ts @@ -35,7 +35,8 @@ export const usePinComment = () => { userId: Id.parse(userId)!, commentId: Id.parse(commentId)!, metadata: { - entityId: trackId + entityId: trackId, + entityType: 'Track' } }) } else { @@ -43,7 +44,8 @@ export const usePinComment = () => { userId: Id.parse(userId)!, commentId: Id.parse(commentId)!, metadata: { - entityId: trackId + entityId: trackId, + entityType: 'Track' } }) } diff --git a/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts b/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts index 6548b279708..e9acd907913 100644 --- a/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts +++ b/packages/sdk/src/sdk/api/developer-apps/DeveloperAppsApi.ts @@ -90,7 +90,7 @@ export class DeveloperAppsApi extends GeneratedDeveloperAppsApi { ) { if (this.entityManager) { return await this.createDeveloperAppWithEntityManager({ - ...params.createDeveloperAppRequestBody, + ...params.metadata, userId: params.userId }) } else { @@ -133,7 +133,7 @@ export class DeveloperAppsApi extends GeneratedDeveloperAppsApi { ) { if (this.entityManager) { return await this.updateDeveloperAppWithEntityManager({ - ...params.updateDeveloperAppRequestBody, + ...params.metadata, userId: params.userId, appApiKey: params.address }) diff --git a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES index 0e60311f3de..17978a7a286 100644 --- a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES +++ b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES @@ -79,6 +79,9 @@ models/CreateTrackResponse.ts models/CreateUserDeveloperAppRequestBody.ts models/CreateUserDeveloperAppResponse.ts models/CreateUserRequestBody.ts +models/CreateUserRequestBodyEvents.ts +models/CreateUserRequestBodyPlaylistLibrary.ts +models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts models/CreateUserResponse.ts models/DashboardWalletUser.ts models/DashboardWalletUsersResponse.ts @@ -114,9 +117,13 @@ models/MediaLink.ts models/MonthlyAggregatePlay.ts models/Mood.ts models/MutualFollowersResponse.ts +models/PinCommentRequestBody.ts models/Playlist.ts models/PlaylistAddedTimestamp.ts models/PlaylistArtwork.ts +models/PlaylistLibraryExplorePlaylistIdentifier.ts +models/PlaylistLibraryFolder.ts +models/PlaylistLibraryPlaylistIdentifier.ts models/PlaylistResponse.ts models/PlaylistSearchResult.ts models/PlaylistTracksResponse.ts @@ -127,6 +134,7 @@ models/PrizePublic.ts models/PrizesResponse.ts models/ProfilePicture.ts models/PurchasersResponse.ts +models/ReactCommentRequestBody.ts models/RedeemAmountResponse.ts models/RelatedArtistResponse.ts models/RemixParent.ts @@ -190,6 +198,7 @@ models/UpdateDeveloperAppRequestBody.ts models/UpdatePlaylistRequestBody.ts models/UpdateTrackRequestBody.ts models/UpdateUserRequestBody.ts +models/UpdateUserRequestBodyPlaylistLibrary.ts models/User.ts models/UserCoin.ts models/UserCoinAccount.ts diff --git a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts index 3c7cb32c3ee..2585c251cb1 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts @@ -156,7 +156,6 @@ import { } from '../models'; export interface CreateUserRequest { - userId: string; metadata: CreateUserRequestBody; } @@ -549,20 +548,12 @@ export class UsersApi extends runtime.BaseAPI { * Creates a new user */ async createUserRaw(params: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (params.userId === null || params.userId === undefined) { - throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createUser.'); - } - if (params.metadata === null || params.metadata === undefined) { throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createUser.'); } const queryParameters: any = {}; - if (params.userId !== undefined) { - queryParameters['user_id'] = params.userId; - } - const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts index 2f6c6156aba..8081128a150 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts @@ -14,6 +14,19 @@ */ import { exists, mapValues } from '../runtime'; +import type { CreateUserRequestBodyEvents } from './CreateUserRequestBodyEvents'; +import { + CreateUserRequestBodyEventsFromJSON, + CreateUserRequestBodyEventsFromJSONTyped, + CreateUserRequestBodyEventsToJSON, +} from './CreateUserRequestBodyEvents'; +import type { CreateUserRequestBodyPlaylistLibrary } from './CreateUserRequestBodyPlaylistLibrary'; +import { + CreateUserRequestBodyPlaylistLibraryFromJSON, + CreateUserRequestBodyPlaylistLibraryFromJSONTyped, + CreateUserRequestBodyPlaylistLibraryToJSON, +} from './CreateUserRequestBodyPlaylistLibrary'; + /** * * @export @@ -128,6 +141,18 @@ export interface CreateUserRequestBody { * @memberof CreateUserRequestBody */ splUsdcPayoutWallet?: string; + /** + * + * @type {CreateUserRequestBodyPlaylistLibrary} + * @memberof CreateUserRequestBody + */ + playlistLibrary?: CreateUserRequestBodyPlaylistLibrary; + /** + * + * @type {CreateUserRequestBodyEvents} + * @memberof CreateUserRequestBody + */ + events?: CreateUserRequestBodyEvents; } @@ -179,6 +204,8 @@ export function CreateUserRequestBodyFromJSONTyped(json: any, ignoreDiscriminato 'profileType': !exists(json, 'profile_type') ? undefined : json['profile_type'], 'allowAiAttribution': !exists(json, 'allow_ai_attribution') ? undefined : json['allow_ai_attribution'], 'splUsdcPayoutWallet': !exists(json, 'spl_usdc_payout_wallet') ? undefined : json['spl_usdc_payout_wallet'], + 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : CreateUserRequestBodyPlaylistLibraryFromJSON(json['playlist_library']), + 'events': !exists(json, 'events') ? undefined : CreateUserRequestBodyEventsFromJSON(json['events']), }; } @@ -209,6 +236,8 @@ export function CreateUserRequestBodyToJSON(value?: CreateUserRequestBody | null 'profile_type': value.profileType, 'allow_ai_attribution': value.allowAiAttribution, 'spl_usdc_payout_wallet': value.splUsdcPayoutWallet, + 'playlist_library': CreateUserRequestBodyPlaylistLibraryToJSON(value.playlistLibrary), + 'events': CreateUserRequestBodyEventsToJSON(value.events), }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts new file mode 100644 index 00000000000..8a5ddfd732a --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts @@ -0,0 +1,74 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * User events for tracking referrals and mobile users + * @export + * @interface CreateUserRequestBodyEvents + */ +export interface CreateUserRequestBodyEvents { + /** + * User ID of the referrer + * @type {number} + * @memberof CreateUserRequestBodyEvents + */ + referrer?: number; + /** + * Whether the user is on mobile + * @type {boolean} + * @memberof CreateUserRequestBodyEvents + */ + isMobileUser?: boolean; +} + +/** + * Check if a given object implements the CreateUserRequestBodyEvents interface. + */ +export function instanceOfCreateUserRequestBodyEvents(value: object): value is CreateUserRequestBodyEvents { + let isInstance = true; + + return isInstance; +} + +export function CreateUserRequestBodyEventsFromJSON(json: any): CreateUserRequestBodyEvents { + return CreateUserRequestBodyEventsFromJSONTyped(json, false); +} + +export function CreateUserRequestBodyEventsFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserRequestBodyEvents { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'referrer': !exists(json, 'referrer') ? undefined : json['referrer'], + 'isMobileUser': !exists(json, 'is_mobile_user') ? undefined : json['is_mobile_user'], + }; +} + +export function CreateUserRequestBodyEventsToJSON(value?: CreateUserRequestBodyEvents | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'referrer': value.referrer, + 'is_mobile_user': value.isMobileUser, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts new file mode 100644 index 00000000000..3c9c650152d --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts @@ -0,0 +1,74 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { CreateUserRequestBodyPlaylistLibraryContentsInner } from './CreateUserRequestBodyPlaylistLibraryContentsInner'; +import { + CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON, + CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped, + CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON, +} from './CreateUserRequestBodyPlaylistLibraryContentsInner'; + +/** + * User's playlist library with support for folders and playlists + * @export + * @interface CreateUserRequestBodyPlaylistLibrary + */ +export interface CreateUserRequestBodyPlaylistLibrary { + /** + * Array of folders and playlist identifiers + * @type {Array} + * @memberof CreateUserRequestBodyPlaylistLibrary + */ + contents: Array; +} + +/** + * Check if a given object implements the CreateUserRequestBodyPlaylistLibrary interface. + */ +export function instanceOfCreateUserRequestBodyPlaylistLibrary(value: object): value is CreateUserRequestBodyPlaylistLibrary { + let isInstance = true; + isInstance = isInstance && "contents" in value && value["contents"] !== undefined; + + return isInstance; +} + +export function CreateUserRequestBodyPlaylistLibraryFromJSON(json: any): CreateUserRequestBodyPlaylistLibrary { + return CreateUserRequestBodyPlaylistLibraryFromJSONTyped(json, false); +} + +export function CreateUserRequestBodyPlaylistLibraryFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserRequestBodyPlaylistLibrary { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'contents': ((json['contents'] as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON)), + }; +} + +export function CreateUserRequestBodyPlaylistLibraryToJSON(value?: CreateUserRequestBodyPlaylistLibrary | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'contents': ((value.contents as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts new file mode 100644 index 00000000000..4ba0e0b53b2 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts @@ -0,0 +1,76 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { + PlaylistLibraryExplorePlaylistIdentifier, + instanceOfPlaylistLibraryExplorePlaylistIdentifier, + PlaylistLibraryExplorePlaylistIdentifierFromJSON, + PlaylistLibraryExplorePlaylistIdentifierFromJSONTyped, + PlaylistLibraryExplorePlaylistIdentifierToJSON, +} from './PlaylistLibraryExplorePlaylistIdentifier'; +import { + PlaylistLibraryFolder, + instanceOfPlaylistLibraryFolder, + PlaylistLibraryFolderFromJSON, + PlaylistLibraryFolderFromJSONTyped, + PlaylistLibraryFolderToJSON, +} from './PlaylistLibraryFolder'; +import { + PlaylistLibraryPlaylistIdentifier, + instanceOfPlaylistLibraryPlaylistIdentifier, + PlaylistLibraryPlaylistIdentifierFromJSON, + PlaylistLibraryPlaylistIdentifierFromJSONTyped, + PlaylistLibraryPlaylistIdentifierToJSON, +} from './PlaylistLibraryPlaylistIdentifier'; + +/** + * @type CreateUserRequestBodyPlaylistLibraryContentsInner + * + * @export + */ +export type CreateUserRequestBodyPlaylistLibraryContentsInner = PlaylistLibraryExplorePlaylistIdentifier | PlaylistLibraryFolder | PlaylistLibraryPlaylistIdentifier; + +export function CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON(json: any): CreateUserRequestBodyPlaylistLibraryContentsInner { + return CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped(json, false); +} + +export function CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserRequestBodyPlaylistLibraryContentsInner { + if ((json === undefined) || (json === null)) { + return json; + } + return { ...PlaylistLibraryExplorePlaylistIdentifierFromJSONTyped(json, true), ...PlaylistLibraryFolderFromJSONTyped(json, true), ...PlaylistLibraryPlaylistIdentifierFromJSONTyped(json, true) }; +} + +export function CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON(value?: CreateUserRequestBodyPlaylistLibraryContentsInner | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + + if (instanceOfPlaylistLibraryExplorePlaylistIdentifier(value)) { + return PlaylistLibraryExplorePlaylistIdentifierToJSON(value as PlaylistLibraryExplorePlaylistIdentifier); + } + if (instanceOfPlaylistLibraryFolder(value)) { + return PlaylistLibraryFolderToJSON(value as PlaylistLibraryFolder); + } + if (instanceOfPlaylistLibraryPlaylistIdentifier(value)) { + return PlaylistLibraryPlaylistIdentifierToJSON(value as PlaylistLibraryPlaylistIdentifier); + } + + return {}; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts index 75e2154e034..27171bf5c0b 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts @@ -14,12 +14,25 @@ */ import { exists, mapValues } from '../runtime'; +import type { CommentEntityType } from './CommentEntityType'; +import { + CommentEntityTypeFromJSON, + CommentEntityTypeFromJSONTyped, + CommentEntityTypeToJSON, +} from './CommentEntityType'; + /** * * @export * @interface PinCommentRequestBody */ export interface PinCommentRequestBody { + /** + * + * @type {CommentEntityType} + * @memberof PinCommentRequestBody + */ + entityType: CommentEntityType; /** * ID of the entity (track or playlist) the comment is on * @type {number} @@ -33,6 +46,7 @@ export interface PinCommentRequestBody { */ export function instanceOfPinCommentRequestBody(value: object): value is PinCommentRequestBody { let isInstance = true; + isInstance = isInstance && "entityType" in value && value["entityType"] !== undefined; isInstance = isInstance && "entityId" in value && value["entityId"] !== undefined; return isInstance; @@ -48,6 +62,7 @@ export function PinCommentRequestBodyFromJSONTyped(json: any, ignoreDiscriminato } return { + 'entityType': CommentEntityTypeFromJSON(json['entityType']), 'entityId': json['entityId'], }; } @@ -61,6 +76,7 @@ export function PinCommentRequestBodyToJSON(value?: PinCommentRequestBody | null } return { + 'entityType': CommentEntityTypeToJSON(value.entityType), 'entityId': value.entityId, }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryExplorePlaylistIdentifier.ts b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryExplorePlaylistIdentifier.ts new file mode 100644 index 00000000000..2cbdd0b12a5 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryExplorePlaylistIdentifier.ts @@ -0,0 +1,86 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Reference to an explore playlist + * @export + * @interface PlaylistLibraryExplorePlaylistIdentifier + */ +export interface PlaylistLibraryExplorePlaylistIdentifier { + /** + * + * @type {string} + * @memberof PlaylistLibraryExplorePlaylistIdentifier + */ + type: PlaylistLibraryExplorePlaylistIdentifierTypeEnum; + /** + * Explore playlist identifier + * @type {string} + * @memberof PlaylistLibraryExplorePlaylistIdentifier + */ + playlistId: string; +} + + +/** + * @export + */ +export const PlaylistLibraryExplorePlaylistIdentifierTypeEnum = { + ExplorePlaylist: 'explore_playlist' +} as const; +export type PlaylistLibraryExplorePlaylistIdentifierTypeEnum = typeof PlaylistLibraryExplorePlaylistIdentifierTypeEnum[keyof typeof PlaylistLibraryExplorePlaylistIdentifierTypeEnum]; + + +/** + * Check if a given object implements the PlaylistLibraryExplorePlaylistIdentifier interface. + */ +export function instanceOfPlaylistLibraryExplorePlaylistIdentifier(value: object): value is PlaylistLibraryExplorePlaylistIdentifier { + let isInstance = true; + isInstance = isInstance && "type" in value && value["type"] !== undefined; + isInstance = isInstance && "playlistId" in value && value["playlistId"] !== undefined; + + return isInstance; +} + +export function PlaylistLibraryExplorePlaylistIdentifierFromJSON(json: any): PlaylistLibraryExplorePlaylistIdentifier { + return PlaylistLibraryExplorePlaylistIdentifierFromJSONTyped(json, false); +} + +export function PlaylistLibraryExplorePlaylistIdentifierFromJSONTyped(json: any, ignoreDiscriminator: boolean): PlaylistLibraryExplorePlaylistIdentifier { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'type': json['type'], + 'playlistId': json['playlist_id'], + }; +} + +export function PlaylistLibraryExplorePlaylistIdentifierToJSON(value?: PlaylistLibraryExplorePlaylistIdentifier | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'type': value.type, + 'playlist_id': value.playlistId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts new file mode 100644 index 00000000000..78280c871ab --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts @@ -0,0 +1,111 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { CreateUserRequestBodyPlaylistLibraryContentsInner } from './CreateUserRequestBodyPlaylistLibraryContentsInner'; +import { + CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON, + CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped, + CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON, +} from './CreateUserRequestBodyPlaylistLibraryContentsInner'; + +/** + * Folder containing nested playlists and folders + * @export + * @interface PlaylistLibraryFolder + */ +export interface PlaylistLibraryFolder { + /** + * Unique folder identifier + * @type {string} + * @memberof PlaylistLibraryFolder + */ + id: string; + /** + * + * @type {string} + * @memberof PlaylistLibraryFolder + */ + type: PlaylistLibraryFolderTypeEnum; + /** + * Folder name + * @type {string} + * @memberof PlaylistLibraryFolder + */ + name: string; + /** + * Nested folders and playlist identifiers + * @type {Array} + * @memberof PlaylistLibraryFolder + */ + contents: Array; +} + + +/** + * @export + */ +export const PlaylistLibraryFolderTypeEnum = { + Folder: 'folder' +} as const; +export type PlaylistLibraryFolderTypeEnum = typeof PlaylistLibraryFolderTypeEnum[keyof typeof PlaylistLibraryFolderTypeEnum]; + + +/** + * Check if a given object implements the PlaylistLibraryFolder interface. + */ +export function instanceOfPlaylistLibraryFolder(value: object): value is PlaylistLibraryFolder { + let isInstance = true; + isInstance = isInstance && "id" in value && value["id"] !== undefined; + isInstance = isInstance && "type" in value && value["type"] !== undefined; + isInstance = isInstance && "name" in value && value["name"] !== undefined; + isInstance = isInstance && "contents" in value && value["contents"] !== undefined; + + return isInstance; +} + +export function PlaylistLibraryFolderFromJSON(json: any): PlaylistLibraryFolder { + return PlaylistLibraryFolderFromJSONTyped(json, false); +} + +export function PlaylistLibraryFolderFromJSONTyped(json: any, ignoreDiscriminator: boolean): PlaylistLibraryFolder { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': json['id'], + 'type': json['type'], + 'name': json['name'], + 'contents': ((json['contents'] as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON)), + }; +} + +export function PlaylistLibraryFolderToJSON(value?: PlaylistLibraryFolder | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'type': value.type, + 'name': value.name, + 'contents': ((value.contents as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryPlaylistIdentifier.ts b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryPlaylistIdentifier.ts new file mode 100644 index 00000000000..3711012adb9 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryPlaylistIdentifier.ts @@ -0,0 +1,86 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Reference to a playlist + * @export + * @interface PlaylistLibraryPlaylistIdentifier + */ +export interface PlaylistLibraryPlaylistIdentifier { + /** + * + * @type {string} + * @memberof PlaylistLibraryPlaylistIdentifier + */ + type: PlaylistLibraryPlaylistIdentifierTypeEnum; + /** + * Playlist ID + * @type {number} + * @memberof PlaylistLibraryPlaylistIdentifier + */ + playlistId: number; +} + + +/** + * @export + */ +export const PlaylistLibraryPlaylistIdentifierTypeEnum = { + Playlist: 'playlist' +} as const; +export type PlaylistLibraryPlaylistIdentifierTypeEnum = typeof PlaylistLibraryPlaylistIdentifierTypeEnum[keyof typeof PlaylistLibraryPlaylistIdentifierTypeEnum]; + + +/** + * Check if a given object implements the PlaylistLibraryPlaylistIdentifier interface. + */ +export function instanceOfPlaylistLibraryPlaylistIdentifier(value: object): value is PlaylistLibraryPlaylistIdentifier { + let isInstance = true; + isInstance = isInstance && "type" in value && value["type"] !== undefined; + isInstance = isInstance && "playlistId" in value && value["playlistId"] !== undefined; + + return isInstance; +} + +export function PlaylistLibraryPlaylistIdentifierFromJSON(json: any): PlaylistLibraryPlaylistIdentifier { + return PlaylistLibraryPlaylistIdentifierFromJSONTyped(json, false); +} + +export function PlaylistLibraryPlaylistIdentifierFromJSONTyped(json: any, ignoreDiscriminator: boolean): PlaylistLibraryPlaylistIdentifier { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'type': json['type'], + 'playlistId': json['playlist_id'], + }; +} + +export function PlaylistLibraryPlaylistIdentifierToJSON(value?: PlaylistLibraryPlaylistIdentifier | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'type': value.type, + 'playlist_id': value.playlistId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts index e82ed821d66..524e27e6489 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts @@ -14,6 +14,19 @@ */ import { exists, mapValues } from '../runtime'; +import type { CreateUserRequestBodyEvents } from './CreateUserRequestBodyEvents'; +import { + CreateUserRequestBodyEventsFromJSON, + CreateUserRequestBodyEventsFromJSONTyped, + CreateUserRequestBodyEventsToJSON, +} from './CreateUserRequestBodyEvents'; +import type { UpdateUserRequestBodyPlaylistLibrary } from './UpdateUserRequestBodyPlaylistLibrary'; +import { + UpdateUserRequestBodyPlaylistLibraryFromJSON, + UpdateUserRequestBodyPlaylistLibraryFromJSONTyped, + UpdateUserRequestBodyPlaylistLibraryToJSON, +} from './UpdateUserRequestBodyPlaylistLibrary'; + /** * Request body for updating user profile. All fields are optional. * @export @@ -106,10 +119,10 @@ export interface UpdateUserRequestBody { isDeactivated?: boolean; /** * Track ID to feature as artist pick - * @type {string} + * @type {number} * @memberof UpdateUserRequestBody */ - artistPickTrackId?: string; + artistPickTrackId?: number; /** * Whether to allow AI attribution * @type {boolean} @@ -128,6 +141,18 @@ export interface UpdateUserRequestBody { * @memberof UpdateUserRequestBody */ coinFlairMint?: string; + /** + * + * @type {UpdateUserRequestBodyPlaylistLibrary} + * @memberof UpdateUserRequestBody + */ + playlistLibrary?: UpdateUserRequestBodyPlaylistLibrary; + /** + * + * @type {CreateUserRequestBodyEvents} + * @memberof UpdateUserRequestBody + */ + events?: CreateUserRequestBodyEvents; } @@ -177,6 +202,8 @@ export function UpdateUserRequestBodyFromJSONTyped(json: any, ignoreDiscriminato 'allowAiAttribution': !exists(json, 'allow_ai_attribution') ? undefined : json['allow_ai_attribution'], 'splUsdcPayoutWallet': !exists(json, 'spl_usdc_payout_wallet') ? undefined : json['spl_usdc_payout_wallet'], 'coinFlairMint': !exists(json, 'coin_flair_mint') ? undefined : json['coin_flair_mint'], + 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : UpdateUserRequestBodyPlaylistLibraryFromJSON(json['playlist_library']), + 'events': !exists(json, 'events') ? undefined : CreateUserRequestBodyEventsFromJSON(json['events']), }; } @@ -207,6 +234,8 @@ export function UpdateUserRequestBodyToJSON(value?: UpdateUserRequestBody | null 'allow_ai_attribution': value.allowAiAttribution, 'spl_usdc_payout_wallet': value.splUsdcPayoutWallet, 'coin_flair_mint': value.coinFlairMint, + 'playlist_library': UpdateUserRequestBodyPlaylistLibraryToJSON(value.playlistLibrary), + 'events': CreateUserRequestBodyEventsToJSON(value.events), }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts new file mode 100644 index 00000000000..4cbcdb64750 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { CreateUserRequestBodyPlaylistLibraryContentsInner } from './CreateUserRequestBodyPlaylistLibraryContentsInner'; +import { + CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON, + CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped, + CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON, +} from './CreateUserRequestBodyPlaylistLibraryContentsInner'; + +/** + * User's playlist library with support for folders and playlists + * @export + * @interface UpdateUserRequestBodyPlaylistLibrary + */ +export interface UpdateUserRequestBodyPlaylistLibrary { + /** + * Array of folders and playlist identifiers + * @type {Array} + * @memberof UpdateUserRequestBodyPlaylistLibrary + */ + contents?: Array; +} + +/** + * Check if a given object implements the UpdateUserRequestBodyPlaylistLibrary interface. + */ +export function instanceOfUpdateUserRequestBodyPlaylistLibrary(value: object): value is UpdateUserRequestBodyPlaylistLibrary { + let isInstance = true; + + return isInstance; +} + +export function UpdateUserRequestBodyPlaylistLibraryFromJSON(json: any): UpdateUserRequestBodyPlaylistLibrary { + return UpdateUserRequestBodyPlaylistLibraryFromJSONTyped(json, false); +} + +export function UpdateUserRequestBodyPlaylistLibraryFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateUserRequestBodyPlaylistLibrary { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'contents': !exists(json, 'contents') ? undefined : ((json['contents'] as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON)), + }; +} + +export function UpdateUserRequestBodyPlaylistLibraryToJSON(value?: UpdateUserRequestBodyPlaylistLibrary | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'contents': value.contents === undefined ? undefined : ((value.contents as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/index.ts b/packages/sdk/src/sdk/api/generated/default/models/index.ts index 791c42ad9fd..f6560cc3c36 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/index.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/index.ts @@ -63,6 +63,9 @@ export * from './CreateTrackResponse'; export * from './CreateUserDeveloperAppRequestBody'; export * from './CreateUserDeveloperAppResponse'; export * from './CreateUserRequestBody'; +export * from './CreateUserRequestBodyEvents'; +export * from './CreateUserRequestBodyPlaylistLibrary'; +export * from './CreateUserRequestBodyPlaylistLibraryContentsInner'; export * from './CreateUserResponse'; export * from './DashboardWalletUser'; export * from './DashboardWalletUsersResponse'; @@ -102,6 +105,9 @@ export * from './PinCommentRequestBody'; export * from './Playlist'; export * from './PlaylistAddedTimestamp'; export * from './PlaylistArtwork'; +export * from './PlaylistLibraryExplorePlaylistIdentifier'; +export * from './PlaylistLibraryFolder'; +export * from './PlaylistLibraryPlaylistIdentifier'; export * from './PlaylistResponse'; export * from './PlaylistSearchResult'; export * from './PlaylistTracksResponse'; @@ -176,6 +182,7 @@ export * from './UpdateDeveloperAppRequestBody'; export * from './UpdatePlaylistRequestBody'; export * from './UpdateTrackRequestBody'; export * from './UpdateUserRequestBody'; +export * from './UpdateUserRequestBodyPlaylistLibrary'; export * from './User'; export * from './UserCoin'; export * from './UserCoinAccount'; diff --git a/packages/sdk/src/sdk/api/users/UsersApi.ts b/packages/sdk/src/sdk/api/users/UsersApi.ts index bd917f12894..3b52079b1a2 100644 --- a/packages/sdk/src/sdk/api/users/UsersApi.ts +++ b/packages/sdk/src/sdk/api/users/UsersApi.ts @@ -12,7 +12,7 @@ import { import type { LoggerService } from '../../services/Logger' import type { ClaimableTokensClient } from '../../services/Solana/programs/ClaimableTokensClient/ClaimableTokensClient' import type { SolanaClient } from '../../services/Solana/programs/SolanaClient' -import { HashId } from '../../types/HashId' +import { HashId, Id } from '../../types/HashId' import { generateMetadataCidV1 } from '../../utils/cid' import { decodeHashId, encodeHashId } from '../../utils/hashId' import { parseParams } from '../../utils/parseParams' @@ -180,7 +180,13 @@ export class UsersApi extends GeneratedUsersApi { if (this.entityManager) { const { metadata } = params const res = await this.createUserWithEntityManager({ - metadata + metadata: { + ...metadata, + events: { + ...metadata.events, + referrer: Id.parse(metadata.events?.referrer)! + } + } }) return { success: true, diff --git a/packages/web/src/common/store/pages/audio-rewards/sagas.ts b/packages/web/src/common/store/pages/audio-rewards/sagas.ts index e56d2e7a8f7..5d99a9bbcbb 100644 --- a/packages/web/src/common/store/pages/audio-rewards/sagas.ts +++ b/packages/web/src/common/store/pages/audio-rewards/sagas.ts @@ -248,7 +248,7 @@ async function claimRewardsForChallenge({ ) .then(() => sdk.rewards.claimRewards({ - claimRewardsRequest: { + reward: { challengeId, specifier: specifierWithAmount.specifier, userId diff --git a/packages/web/src/pages/oauth-login-page/OAuthSignUpPage.tsx b/packages/web/src/pages/oauth-login-page/OAuthSignUpPage.tsx index 3a977e42af1..f6ee020bbea 100644 --- a/packages/web/src/pages/oauth-login-page/OAuthSignUpPage.tsx +++ b/packages/web/src/pages/oauth-login-page/OAuthSignUpPage.tsx @@ -120,7 +120,7 @@ export const OAuthSignUpPage = () => { const sdk = await audiusSdk() const [wallet] = await sdk.services.audiusWalletClient.getAddresses() - const { blockHash, blockNumber } = await sdk.users.createUser({ + await sdk.users.createUser({ metadata: { handle: data.handle, name: data.displayName.trim(), @@ -128,13 +128,6 @@ export const OAuthSignUpPage = () => { } }) - if (blockHash && blockNumber) { - await sdk.services.entityManager.confirmWrite({ - blockHash, - blockNumber - }) - } - let accountData let retries = 0 const maxRetries = 15 From e71463e1ab584df3285819df392896a465893980 Mon Sep 17 00:00:00 2001 From: Marcus Pasell <3690498+rickyrombo@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:09:03 -0800 Subject: [PATCH 9/9] attempt to match uploads w/ new post methods --- .../api/tan-query/users/useUpdateProfile.ts | 3 +- packages/sdk/src/sdk/api/albums/types.ts | 40 +- .../sdk/src/sdk/api/comments/CommentsAPI.ts | 195 ++++------ packages/sdk/src/sdk/api/comments/types.ts | 80 ---- .../default/.openapi-generator/FILES | 5 +- .../models/CreateCommentRequestBody.ts | 2 +- .../models/CreatePlaylistRequestBody.ts | 4 +- .../default/models/CreateTrackRequestBody.ts | 10 +- .../default/models/CreateUserRequestBody.ts | 24 +- .../models/CreateUserRequestBodyEvents.ts | 6 +- .../CreateUserRequestBodyPlaylistLibrary.ts | 74 ---- .../default/models/PinCommentRequestBody.ts | 2 +- .../default/models/PlaylistLibraryFolder.ts | 18 +- .../default/models/ReactCommentRequestBody.ts | 2 +- .../generated/default/models/StemParent.ts | 4 +- .../sdk/api/generated/default/models/Track.ts | 4 +- .../default/models/TrackElementWrite.ts | 4 +- .../default/models/UpdateTrackRequestBody.ts | 6 +- .../default/models/UpdateUserRequestBody.ts | 24 +- .../UpdateUserRequestBodyPlaylistLibrary.ts | 73 ---- .../default/models/UserPlaylistLibrary.ts | 74 ++++ ...ts => UserPlaylistLibraryContentsInner.ts} | 12 +- .../sdk/api/generated/default/models/index.ts | 5 +- .../sdk/src/sdk/api/playlists/PlaylistsApi.ts | 360 ++++++++++-------- packages/sdk/src/sdk/api/playlists/types.ts | 42 +- .../src/sdk/api/tracks/TrackUploadHelper.ts | 31 +- packages/sdk/src/sdk/api/tracks/TracksApi.ts | 237 +++++------- packages/sdk/src/sdk/api/tracks/types.ts | 33 +- .../sdk/src/sdk/api/users/UsersApi.test.ts | 13 +- packages/sdk/src/sdk/api/users/UsersApi.ts | 256 +++++++------ packages/sdk/src/sdk/api/users/types.ts | 17 + 31 files changed, 716 insertions(+), 944 deletions(-) delete mode 100644 packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts delete mode 100644 packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts create mode 100644 packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibrary.ts rename packages/sdk/src/sdk/api/generated/default/models/{CreateUserRequestBodyPlaylistLibraryContentsInner.ts => UserPlaylistLibraryContentsInner.ts} (72%) diff --git a/packages/common/src/api/tan-query/users/useUpdateProfile.ts b/packages/common/src/api/tan-query/users/useUpdateProfile.ts index d4939f16441..d37d044f804 100644 --- a/packages/common/src/api/tan-query/users/useUpdateProfile.ts +++ b/packages/common/src/api/tan-query/users/useUpdateProfile.ts @@ -44,8 +44,9 @@ export const useUpdateProfile = () => { } } - const { blockHash, blockNumber } = await sdk.users.updateProfile({ + const { blockHash, blockNumber } = await sdk.users.updateUser({ userId: Id.parse(currentUserId), + id: Id.parse(currentUserId), profilePictureFile: metadata.updatedProfilePicture?.file, coverArtFile: metadata.updatedCoverPhoto?.file, metadata: userMetadataToSdk(metadata) diff --git a/packages/sdk/src/sdk/api/albums/types.ts b/packages/sdk/src/sdk/api/albums/types.ts index ed25ecf70ec..eddc1849b85 100644 --- a/packages/sdk/src/sdk/api/albums/types.ts +++ b/packages/sdk/src/sdk/api/albums/types.ts @@ -8,13 +8,11 @@ import { HashId } from '../../types/HashId' import { Mood, Genre } from '../generated/default' import type { CreatePlaylistRequestBody, + CreateTrackRequestBody, UpdatePlaylistRequestBody } from '../generated/default' import type { UploadPlaylistProgressHandler } from '../playlists/types' -import { - UploadTrackMetadataSchema, - USDCPurchaseConditions -} from '../tracks/types' +import { USDCPurchaseConditions } from '../tracks/types' // Album request body types that wrap playlist types but use album field names export type CreateAlbumRequestBody = Omit< @@ -135,16 +133,6 @@ export const UploadAlbumMetadataSchema = CreateAlbumMetadataSchema.extend({ export type AlbumMetadata = z.input -const AlbumTrackMetadataSchema = UploadTrackMetadataSchema.partial({ - genre: true, - mood: true, - tags: true, - isStreamGated: true, - streamConditions: true, - isDownloadable: true, - downloadConditions: true -}) - export const UpdateAlbumMetadataSchema = UploadAlbumMetadataSchema.partial() .merge( z.object({ @@ -161,21 +149,17 @@ export const UpdateAlbumMetadataSchema = UploadAlbumMetadataSchema.partial() ) .strict() -export const UploadAlbumSchema = z - .object({ - userId: HashId, - imageFile: ImageFile, - metadata: UploadAlbumMetadataSchema, - onProgress: z.optional(z.function()), - /** - * Track metadata is populated from the album if fields are missing - */ - trackMetadatas: z.array(AlbumTrackMetadataSchema), - audioFiles: z.array(AudioFile) - }) - .strict() +export const UploadAlbumSchema = z.object({ + userId: HashId, + imageFile: ImageFile, + onProgress: z.optional(z.function()), + audioFiles: z.array(AudioFile) +}) -export type UploadAlbumRequest = z.input +export type UploadAlbumRequest = z.input & { + metadata: CreateAlbumRequestBody + trackMetadatas: CreateTrackRequestBody[] +} export const UpdateAlbumSchema = z .object({ diff --git a/packages/sdk/src/sdk/api/comments/CommentsAPI.ts b/packages/sdk/src/sdk/api/comments/CommentsAPI.ts index 3c58fba3d1d..2b7dc9fbaf9 100644 --- a/packages/sdk/src/sdk/api/comments/CommentsAPI.ts +++ b/packages/sdk/src/sdk/api/comments/CommentsAPI.ts @@ -1,13 +1,15 @@ import snakecaseKeys from 'snakecase-keys' +import { OverrideProperties } from 'type-fest' import { LoggerService } from '../../services' import { Action, EntityManagerService, - EntityType + EntityType, + type ManageEntityOptions } from '../../services/EntityManager/types' +import { HashId } from '../../types/HashId' import { decodeHashId, encodeHashId } from '../../utils/hashId' -import { parseParams } from '../../utils/parseParams' import { Configuration, CommentsApi as GeneratedCommentsApi, @@ -21,21 +23,30 @@ import { type ReportCommentRequest } from '../generated/default' -import { - CreateCommentSchema, - UpdateCommentSchema, - DeleteCommentSchema, - PinCommentSchema, - ReactCommentSchema, - ReportCommentSchema, - EntityManagerCreateCommentRequest, - EntityManagerUpdateCommentRequest, - EntityManagerDeleteCommentRequest, - EntityManagerPinCommentRequest, - EntityManagerReactCommentRequest, - EntityManagerReportCommentRequest -} from './types' +import type { CommentMetadata } from './types' + +type EditCommentMetadata = CommentMetadata & { + trackId: number +} + +type PinCommentMetadata = { + userId: number + entityId: number + trackId: number + isPin: boolean +} +type ReactCommentMetadata = { + userId: number + commentId: number + isLiked: boolean + trackId: number +} + +type CommentNotificationOptions = OverrideProperties< + Omit, + { action: Action.MUTE | Action.UNMUTE } +> export class CommentsApi extends GeneratedCommentsApi { constructor( configuration: Configuration, @@ -57,13 +68,7 @@ export class CommentsApi extends GeneratedCommentsApi { /** @hidden * Create a comment using entity manager */ - async createCommentWithEntityManager( - params: EntityManagerCreateCommentRequest - ) { - const metadata = await parseParams( - 'createComment', - CreateCommentSchema - )(params) + async createCommentWithEntityManager(metadata: CommentMetadata) { const { userId, entityType = EntityType.TRACK, commentId } = metadata const newCommentId = commentId ?? (await this.generateCommentId()) await this.entityManager.manageEntity({ @@ -87,8 +92,8 @@ export class CommentsApi extends GeneratedCommentsApi { if (this.entityManager) { const { metadata, userId } = params const commentId = await this.createCommentWithEntityManager({ - userId, - entityId: encodeHashId(metadata.entityId) ?? '', + userId: HashId.parse(userId), + entityId: metadata.entityId, entityType: metadata.entityType, body: metadata.body, commentId: metadata.commentId, @@ -107,14 +112,8 @@ export class CommentsApi extends GeneratedCommentsApi { /** @hidden * Update a comment using entity manager */ - async updateCommentWithEntityManager( - params: EntityManagerUpdateCommentRequest - ) { - const metadata = await parseParams( - 'updateComment', - UpdateCommentSchema - )(params) - const { userId, entityId, trackId, body } = metadata + async updateCommentWithEntityManager(metadata: EditCommentMetadata) { + const { userId, entityId, trackId } = metadata const response = await this.entityManager.manageEntity({ userId, entityType: EntityType.COMMENT, @@ -122,7 +121,7 @@ export class CommentsApi extends GeneratedCommentsApi { action: Action.UPDATE, metadata: JSON.stringify({ cid: '', - data: snakecaseKeys({ body, entityId: trackId }) + data: snakecaseKeys({ ...metadata, entityId: trackId }) }) }) return response @@ -134,15 +133,12 @@ export class CommentsApi extends GeneratedCommentsApi { ) { if (this.entityManager) { const { metadata, userId, commentId } = params - await this.updateCommentWithEntityManager({ - userId, - entityId: commentId, - trackId: encodeHashId(metadata.entityId) ?? '', + return await this.updateCommentWithEntityManager({ + userId: HashId.parse(userId), + entityId: HashId.parse(commentId), + trackId: HashId.parse(commentId), body: metadata.body }) - return { - success: true - } } return super.updateComment(params, requestInit) } @@ -150,13 +146,7 @@ export class CommentsApi extends GeneratedCommentsApi { /** @hidden * Delete a comment using entity manager */ - async deleteCommentWithEntityManager( - params: EntityManagerDeleteCommentRequest - ) { - const metadata = await parseParams( - 'deleteComment', - DeleteCommentSchema - )(params) + async deleteCommentWithEntityManager(metadata: CommentMetadata) { const { userId, entityId } = metadata const response = await this.entityManager.manageEntity({ userId, @@ -173,14 +163,10 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const metadata: EntityManagerDeleteCommentRequest = { - userId: params.userId, - entityId: params.commentId - } - await this.deleteCommentWithEntityManager(metadata) - return { - success: true - } + return await this.deleteCommentWithEntityManager({ + userId: HashId.parse(params.userId), + entityId: HashId.parse(params.commentId) + }) } return super.deleteComment(params, requestInit) } @@ -188,13 +174,7 @@ export class CommentsApi extends GeneratedCommentsApi { /** @hidden * React to a comment using entity manager */ - async reactToCommentWithEntityManager( - params: EntityManagerReactCommentRequest - ) { - const metadata = await parseParams( - 'reactComment', - ReactCommentSchema - )(params) + async reactToCommentWithEntityManager(metadata: ReactCommentMetadata) { const { userId, commentId, isLiked, trackId } = metadata const response = await this.entityManager.manageEntity({ userId, @@ -214,16 +194,12 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const metadata: EntityManagerReactCommentRequest = { - userId: params.userId, - commentId: params.commentId, + return await this.reactToCommentWithEntityManager({ + userId: HashId.parse(params.userId), + commentId: HashId.parse(params.commentId), isLiked: true, - trackId: params.commentId // trackId represents the entity being commented on - } - await this.reactToCommentWithEntityManager(metadata) - return { - success: true - } + trackId: HashId.parse(params.commentId) + }) } return super.reactToComment(params, requestInit) } @@ -233,16 +209,12 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const metadata: EntityManagerReactCommentRequest = { - userId: params.userId, - commentId: params.commentId, - isLiked: false, - trackId: params.commentId - } - await this.reactToCommentWithEntityManager(metadata) - return { - success: true - } + return await this.reactToCommentWithEntityManager({ + userId: HashId.parse(params.userId), + commentId: HashId.parse(params.commentId), + isLiked: true, + trackId: HashId.parse(params.commentId) + }) } return super.unreactToComment(params, requestInit) } @@ -250,8 +222,7 @@ export class CommentsApi extends GeneratedCommentsApi { /** @hidden * Pin a comment using entity manager */ - async pinCommentWithEntityManager(params: EntityManagerPinCommentRequest) { - const metadata = await parseParams('pinComment', PinCommentSchema)(params) + async pinCommentWithEntityManager(metadata: PinCommentMetadata) { const { userId, entityId, trackId, isPin } = metadata const response = await this.entityManager.manageEntity({ userId, @@ -271,16 +242,12 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const metadata: EntityManagerPinCommentRequest = { - userId: params.userId, - entityId: params.commentId, - trackId: params.commentId, // trackId represents the entity being commented on + return await this.pinCommentWithEntityManager({ + userId: HashId.parse(params.userId), + entityId: HashId.parse(params.commentId), + trackId: HashId.parse(params.commentId), isPin: true - } - await this.pinCommentWithEntityManager(metadata) - return { - success: true - } + }) } return super.pinComment(params, requestInit) } @@ -290,16 +257,12 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const metadata: EntityManagerPinCommentRequest = { - userId: params.userId, - entityId: params.commentId, - trackId: params.commentId, + return await this.pinCommentWithEntityManager({ + userId: HashId.parse(params.userId), + entityId: HashId.parse(params.commentId), + trackId: HashId.parse(params.commentId), isPin: false - } - await this.pinCommentWithEntityManager(metadata) - return { - success: true - } + }) } return super.unpinComment(params, requestInit) } @@ -307,14 +270,7 @@ export class CommentsApi extends GeneratedCommentsApi { /** @hidden * Report a comment using entity manager */ - async reportCommentWithEntityManager( - params: EntityManagerReportCommentRequest - ) { - const metadata = await parseParams( - 'reportComment', - ReportCommentSchema - )(params) - const { userId, entityId } = metadata + async reportCommentWithEntityManager(userId: number, entityId: number) { const response = await this.entityManager.manageEntity({ userId, entityType: EntityType.COMMENT, @@ -330,14 +286,10 @@ export class CommentsApi extends GeneratedCommentsApi { requestInit?: RequestInit ) { if (this.entityManager) { - const metadata: EntityManagerReportCommentRequest = { - userId: params.userId, - entityId: params.commentId - } - await this.reportCommentWithEntityManager(metadata) - return { - success: true - } + return await this.reportCommentWithEntityManager( + HashId.parse(params.userId), + HashId.parse(params.commentId) + ) } return super.reportComment(params, requestInit) } @@ -359,12 +311,7 @@ export class CommentsApi extends GeneratedCommentsApi { /** @hidden * Update comment notification settings (entity manager only) */ - async updateCommentNotificationSetting(config: { - userId: number - entityType: EntityType - entityId: number - action: Action.MUTE | Action.UNMUTE - }) { + async updateCommentNotificationSetting(config: CommentNotificationOptions) { const response = await this.entityManager.manageEntity({ ...config, metadata: '' diff --git a/packages/sdk/src/sdk/api/comments/types.ts b/packages/sdk/src/sdk/api/comments/types.ts index 680e24e5e1f..3a7d287d57e 100644 --- a/packages/sdk/src/sdk/api/comments/types.ts +++ b/packages/sdk/src/sdk/api/comments/types.ts @@ -1,6 +1,3 @@ -import { z } from 'zod' - -import { HashId } from '../../types/HashId' import type { CommentEntityType } from '../generated/default' export type CommentMetadata = { @@ -13,80 +10,3 @@ export type CommentMetadata = { trackTimestampS?: number mentions?: number[] } - -// Zod schemas for dual-auth support -export const CreateCommentSchema = z - .object({ - userId: HashId, - entityId: HashId, - entityType: z.optional(z.string()), - body: z.optional(z.string()), - commentId: z.optional(z.number()), - parentCommentId: z.optional(z.number()), - trackTimestampS: z.optional(z.number()), - mentions: z.optional(z.array(z.number())) - }) - .strict() - -export type EntityManagerCreateCommentRequest = z.input< - typeof CreateCommentSchema -> - -export const UpdateCommentSchema = z - .object({ - userId: HashId, - entityId: HashId, - trackId: HashId, - body: z.string() - }) - .strict() - -export type EntityManagerUpdateCommentRequest = z.input< - typeof UpdateCommentSchema -> - -export const DeleteCommentSchema = z - .object({ - userId: HashId, - entityId: HashId - }) - .strict() - -export type EntityManagerDeleteCommentRequest = z.input< - typeof DeleteCommentSchema -> - -export const PinCommentSchema = z - .object({ - userId: HashId, - entityId: HashId, - trackId: HashId, - isPin: z.boolean() - }) - .strict() - -export type EntityManagerPinCommentRequest = z.input - -export const ReactCommentSchema = z - .object({ - userId: HashId, - commentId: HashId, - isLiked: z.boolean(), - trackId: HashId - }) - .strict() - -export type EntityManagerReactCommentRequest = z.input< - typeof ReactCommentSchema -> - -export const ReportCommentSchema = z - .object({ - userId: HashId, - entityId: HashId - }) - .strict() - -export type EntityManagerReportCommentRequest = z.input< - typeof ReportCommentSchema -> diff --git a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES index 17978a7a286..e763e312d54 100644 --- a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES +++ b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES @@ -80,8 +80,6 @@ models/CreateUserDeveloperAppRequestBody.ts models/CreateUserDeveloperAppResponse.ts models/CreateUserRequestBody.ts models/CreateUserRequestBodyEvents.ts -models/CreateUserRequestBodyPlaylistLibrary.ts -models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts models/CreateUserResponse.ts models/DashboardWalletUser.ts models/DashboardWalletUsersResponse.ts @@ -198,7 +196,6 @@ models/UpdateDeveloperAppRequestBody.ts models/UpdatePlaylistRequestBody.ts models/UpdateTrackRequestBody.ts models/UpdateUserRequestBody.ts -models/UpdateUserRequestBodyPlaylistLibrary.ts models/User.ts models/UserCoin.ts models/UserCoinAccount.ts @@ -208,6 +205,8 @@ models/UserCoinsResponse.ts models/UserCommentsResponse.ts models/UserIdAddress.ts models/UserIdsAddressesResponse.ts +models/UserPlaylistLibrary.ts +models/UserPlaylistLibraryContentsInner.ts models/UserResponse.ts models/UserSearch.ts models/UserTrackListenCountsResponse.ts diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts index 381ab926df6..604fa946cca 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts @@ -46,7 +46,7 @@ export interface CreateCommentRequestBody { */ body: string; /** - * Optional comment ID (will be generated if not provided) + * Optional ID for the comment (will be generated if not provided) * @type {number} * @memberof CreateCommentRequestBody */ diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts index 7d785fbb972..93e137da69f 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts @@ -41,10 +41,10 @@ import { export interface CreatePlaylistRequestBody { /** * Optional playlist ID (will be generated if not provided) - * @type {number} + * @type {string} * @memberof CreatePlaylistRequestBody */ - playlistId?: number; + playlistId?: string; /** * Playlist or album name * @type {string} diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts index 56464ce5f51..13a078f174a 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts @@ -59,10 +59,10 @@ import { export interface CreateTrackRequestBody { /** * Optional track ID (will be generated if not provided) - * @type {number} + * @type {string} * @memberof CreateTrackRequestBody */ - trackId?: number; + trackId?: string; /** * Track title * @type {string} @@ -182,7 +182,7 @@ export interface CreateTrackRequestBody { * @type {boolean} * @memberof CreateTrackRequestBody */ - downloadable?: boolean; + isDownloadable?: boolean; /** * Whether the track is unlisted * @type {boolean} @@ -281,7 +281,7 @@ export function CreateTrackRequestBodyFromJSONTyped(json: any, ignoreDiscriminat 'previewCid': !exists(json, 'preview_cid') ? undefined : json['preview_cid'], 'previewStartSeconds': !exists(json, 'preview_start_seconds') ? undefined : json['preview_start_seconds'], 'duration': !exists(json, 'duration') ? undefined : json['duration'], - 'downloadable': !exists(json, 'downloadable') ? undefined : json['downloadable'], + 'isDownloadable': !exists(json, 'is_downloadable') ? undefined : json['is_downloadable'], 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), 'downloadConditions': !exists(json, 'download_conditions') ? undefined : AccessGateFromJSON(json['download_conditions']), @@ -323,7 +323,7 @@ export function CreateTrackRequestBodyToJSON(value?: CreateTrackRequestBody | nu 'preview_cid': value.previewCid, 'preview_start_seconds': value.previewStartSeconds, 'duration': value.duration, - 'downloadable': value.downloadable, + 'is_downloadable': value.isDownloadable, 'is_unlisted': value.isUnlisted, 'stream_conditions': AccessGateToJSON(value.streamConditions), 'download_conditions': AccessGateToJSON(value.downloadConditions), diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts index 8081128a150..33a1febb2bb 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts @@ -20,12 +20,12 @@ import { CreateUserRequestBodyEventsFromJSONTyped, CreateUserRequestBodyEventsToJSON, } from './CreateUserRequestBodyEvents'; -import type { CreateUserRequestBodyPlaylistLibrary } from './CreateUserRequestBodyPlaylistLibrary'; +import type { UserPlaylistLibrary } from './UserPlaylistLibrary'; import { - CreateUserRequestBodyPlaylistLibraryFromJSON, - CreateUserRequestBodyPlaylistLibraryFromJSONTyped, - CreateUserRequestBodyPlaylistLibraryToJSON, -} from './CreateUserRequestBodyPlaylistLibrary'; + UserPlaylistLibraryFromJSON, + UserPlaylistLibraryFromJSONTyped, + UserPlaylistLibraryToJSON, +} from './UserPlaylistLibrary'; /** * @@ -34,11 +34,11 @@ import { */ export interface CreateUserRequestBody { /** - * Optional user ID (will be generated if not provided) - * @type {number} + * Optional user hash ID (will be generated if not provided) + * @type {string} * @memberof CreateUserRequestBody */ - userId?: number; + userId?: string; /** * User handle (unique username) * @type {string} @@ -143,10 +143,10 @@ export interface CreateUserRequestBody { splUsdcPayoutWallet?: string; /** * - * @type {CreateUserRequestBodyPlaylistLibrary} + * @type {UserPlaylistLibrary} * @memberof CreateUserRequestBody */ - playlistLibrary?: CreateUserRequestBodyPlaylistLibrary; + playlistLibrary?: UserPlaylistLibrary; /** * * @type {CreateUserRequestBodyEvents} @@ -204,7 +204,7 @@ export function CreateUserRequestBodyFromJSONTyped(json: any, ignoreDiscriminato 'profileType': !exists(json, 'profile_type') ? undefined : json['profile_type'], 'allowAiAttribution': !exists(json, 'allow_ai_attribution') ? undefined : json['allow_ai_attribution'], 'splUsdcPayoutWallet': !exists(json, 'spl_usdc_payout_wallet') ? undefined : json['spl_usdc_payout_wallet'], - 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : CreateUserRequestBodyPlaylistLibraryFromJSON(json['playlist_library']), + 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : UserPlaylistLibraryFromJSON(json['playlist_library']), 'events': !exists(json, 'events') ? undefined : CreateUserRequestBodyEventsFromJSON(json['events']), }; } @@ -236,7 +236,7 @@ export function CreateUserRequestBodyToJSON(value?: CreateUserRequestBody | null 'profile_type': value.profileType, 'allow_ai_attribution': value.allowAiAttribution, 'spl_usdc_payout_wallet': value.splUsdcPayoutWallet, - 'playlist_library': CreateUserRequestBodyPlaylistLibraryToJSON(value.playlistLibrary), + 'playlist_library': UserPlaylistLibraryToJSON(value.playlistLibrary), 'events': CreateUserRequestBodyEventsToJSON(value.events), }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts index 8a5ddfd732a..88a8c3a5a64 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyEvents.ts @@ -21,11 +21,11 @@ import { exists, mapValues } from '../runtime'; */ export interface CreateUserRequestBodyEvents { /** - * User ID of the referrer - * @type {number} + * Hash ID of the user who referred this user + * @type {string} * @memberof CreateUserRequestBodyEvents */ - referrer?: number; + referrer?: string; /** * Whether the user is on mobile * @type {boolean} diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts deleted file mode 100644 index 3c9c650152d..00000000000 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibrary.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @ts-nocheck -/** - * API - * Audius V1 API - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { CreateUserRequestBodyPlaylistLibraryContentsInner } from './CreateUserRequestBodyPlaylistLibraryContentsInner'; -import { - CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON, - CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped, - CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON, -} from './CreateUserRequestBodyPlaylistLibraryContentsInner'; - -/** - * User's playlist library with support for folders and playlists - * @export - * @interface CreateUserRequestBodyPlaylistLibrary - */ -export interface CreateUserRequestBodyPlaylistLibrary { - /** - * Array of folders and playlist identifiers - * @type {Array} - * @memberof CreateUserRequestBodyPlaylistLibrary - */ - contents: Array; -} - -/** - * Check if a given object implements the CreateUserRequestBodyPlaylistLibrary interface. - */ -export function instanceOfCreateUserRequestBodyPlaylistLibrary(value: object): value is CreateUserRequestBodyPlaylistLibrary { - let isInstance = true; - isInstance = isInstance && "contents" in value && value["contents"] !== undefined; - - return isInstance; -} - -export function CreateUserRequestBodyPlaylistLibraryFromJSON(json: any): CreateUserRequestBodyPlaylistLibrary { - return CreateUserRequestBodyPlaylistLibraryFromJSONTyped(json, false); -} - -export function CreateUserRequestBodyPlaylistLibraryFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserRequestBodyPlaylistLibrary { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'contents': ((json['contents'] as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON)), - }; -} - -export function CreateUserRequestBodyPlaylistLibraryToJSON(value?: CreateUserRequestBodyPlaylistLibrary | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'contents': ((value.contents as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON)), - }; -} - diff --git a/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts index 27171bf5c0b..ef43a072a64 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts @@ -34,7 +34,7 @@ export interface PinCommentRequestBody { */ entityType: CommentEntityType; /** - * ID of the entity (track or playlist) the comment is on + * ID of the entity (track) the comment is on * @type {number} * @memberof PinCommentRequestBody */ diff --git a/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts index 78280c871ab..82176824092 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/PlaylistLibraryFolder.ts @@ -14,12 +14,12 @@ */ import { exists, mapValues } from '../runtime'; -import type { CreateUserRequestBodyPlaylistLibraryContentsInner } from './CreateUserRequestBodyPlaylistLibraryContentsInner'; +import type { UserPlaylistLibraryContentsInner } from './UserPlaylistLibraryContentsInner'; import { - CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON, - CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped, - CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON, -} from './CreateUserRequestBodyPlaylistLibraryContentsInner'; + UserPlaylistLibraryContentsInnerFromJSON, + UserPlaylistLibraryContentsInnerFromJSONTyped, + UserPlaylistLibraryContentsInnerToJSON, +} from './UserPlaylistLibraryContentsInner'; /** * Folder containing nested playlists and folders @@ -47,10 +47,10 @@ export interface PlaylistLibraryFolder { name: string; /** * Nested folders and playlist identifiers - * @type {Array} + * @type {Array} * @memberof PlaylistLibraryFolder */ - contents: Array; + contents: Array; } @@ -89,7 +89,7 @@ export function PlaylistLibraryFolderFromJSONTyped(json: any, ignoreDiscriminato 'id': json['id'], 'type': json['type'], 'name': json['name'], - 'contents': ((json['contents'] as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON)), + 'contents': ((json['contents'] as Array).map(UserPlaylistLibraryContentsInnerFromJSON)), }; } @@ -105,7 +105,7 @@ export function PlaylistLibraryFolderToJSON(value?: PlaylistLibraryFolder | null 'id': value.id, 'type': value.type, 'name': value.name, - 'contents': ((value.contents as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON)), + 'contents': ((value.contents as Array).map(UserPlaylistLibraryContentsInnerToJSON)), }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts index f206127caa7..21400696514 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts @@ -34,7 +34,7 @@ export interface ReactCommentRequestBody { */ entityType: CommentEntityType; /** - * ID of the entity (track or playlist) being commented on + * ID of the entity (track) being commented on * @type {number} * @memberof ReactCommentRequestBody */ diff --git a/packages/sdk/src/sdk/api/generated/default/models/StemParent.ts b/packages/sdk/src/sdk/api/generated/default/models/StemParent.ts index 4d844213e42..7a27fca93f6 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/StemParent.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/StemParent.ts @@ -35,10 +35,10 @@ export interface StemParent { category: StemCategory; /** * - * @type {number} + * @type {string} * @memberof StemParent */ - parentTrackId: number; + parentTrackId: string; } /** diff --git a/packages/sdk/src/sdk/api/generated/default/models/Track.ts b/packages/sdk/src/sdk/api/generated/default/models/Track.ts index c95aa313041..55094602de8 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/Track.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/Track.ts @@ -239,10 +239,10 @@ export interface Track { access?: TrackAccessInfo; /** * - * @type {number} + * @type {string} * @memberof Track */ - aiAttributionUserId?: number; + aiAttributionUserId?: string; /** * * @type {Array} diff --git a/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts b/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts index 1becc276367..d7d2d8b9c21 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts @@ -22,10 +22,10 @@ import { exists, mapValues } from '../runtime'; export interface TrackElementWrite { /** * - * @type {number} + * @type {string} * @memberof TrackElementWrite */ - parentTrackId: number; + parentTrackId: string; } /** diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts index 310537dee35..0e3deb068c3 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts @@ -176,7 +176,7 @@ export interface UpdateTrackRequestBody { * @type {boolean} * @memberof UpdateTrackRequestBody */ - downloadable?: boolean; + isDownloadable?: boolean; /** * Whether the track is unlisted * @type {boolean} @@ -271,7 +271,7 @@ export function UpdateTrackRequestBodyFromJSONTyped(json: any, ignoreDiscriminat 'previewCid': !exists(json, 'preview_cid') ? undefined : json['preview_cid'], 'previewStartSeconds': !exists(json, 'preview_start_seconds') ? undefined : json['preview_start_seconds'], 'duration': !exists(json, 'duration') ? undefined : json['duration'], - 'downloadable': !exists(json, 'downloadable') ? undefined : json['downloadable'], + 'isDownloadable': !exists(json, 'is_downloadable') ? undefined : json['is_downloadable'], 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), 'downloadConditions': !exists(json, 'download_conditions') ? undefined : AccessGateFromJSON(json['download_conditions']), @@ -312,7 +312,7 @@ export function UpdateTrackRequestBodyToJSON(value?: UpdateTrackRequestBody | nu 'preview_cid': value.previewCid, 'preview_start_seconds': value.previewStartSeconds, 'duration': value.duration, - 'downloadable': value.downloadable, + 'is_downloadable': value.isDownloadable, 'is_unlisted': value.isUnlisted, 'stream_conditions': AccessGateToJSON(value.streamConditions), 'download_conditions': AccessGateToJSON(value.downloadConditions), diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts index 524e27e6489..e087b36a53c 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts @@ -20,12 +20,12 @@ import { CreateUserRequestBodyEventsFromJSONTyped, CreateUserRequestBodyEventsToJSON, } from './CreateUserRequestBodyEvents'; -import type { UpdateUserRequestBodyPlaylistLibrary } from './UpdateUserRequestBodyPlaylistLibrary'; +import type { UserPlaylistLibrary } from './UserPlaylistLibrary'; import { - UpdateUserRequestBodyPlaylistLibraryFromJSON, - UpdateUserRequestBodyPlaylistLibraryFromJSONTyped, - UpdateUserRequestBodyPlaylistLibraryToJSON, -} from './UpdateUserRequestBodyPlaylistLibrary'; + UserPlaylistLibraryFromJSON, + UserPlaylistLibraryFromJSONTyped, + UserPlaylistLibraryToJSON, +} from './UserPlaylistLibrary'; /** * Request body for updating user profile. All fields are optional. @@ -118,11 +118,11 @@ export interface UpdateUserRequestBody { */ isDeactivated?: boolean; /** - * Track ID to feature as artist pick - * @type {number} + * Track hash ID to feature as artist pick + * @type {string} * @memberof UpdateUserRequestBody */ - artistPickTrackId?: number; + artistPickTrackId?: string; /** * Whether to allow AI attribution * @type {boolean} @@ -143,10 +143,10 @@ export interface UpdateUserRequestBody { coinFlairMint?: string; /** * - * @type {UpdateUserRequestBodyPlaylistLibrary} + * @type {UserPlaylistLibrary} * @memberof UpdateUserRequestBody */ - playlistLibrary?: UpdateUserRequestBodyPlaylistLibrary; + playlistLibrary?: UserPlaylistLibrary; /** * * @type {CreateUserRequestBodyEvents} @@ -202,7 +202,7 @@ export function UpdateUserRequestBodyFromJSONTyped(json: any, ignoreDiscriminato 'allowAiAttribution': !exists(json, 'allow_ai_attribution') ? undefined : json['allow_ai_attribution'], 'splUsdcPayoutWallet': !exists(json, 'spl_usdc_payout_wallet') ? undefined : json['spl_usdc_payout_wallet'], 'coinFlairMint': !exists(json, 'coin_flair_mint') ? undefined : json['coin_flair_mint'], - 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : UpdateUserRequestBodyPlaylistLibraryFromJSON(json['playlist_library']), + 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : UserPlaylistLibraryFromJSON(json['playlist_library']), 'events': !exists(json, 'events') ? undefined : CreateUserRequestBodyEventsFromJSON(json['events']), }; } @@ -234,7 +234,7 @@ export function UpdateUserRequestBodyToJSON(value?: UpdateUserRequestBody | null 'allow_ai_attribution': value.allowAiAttribution, 'spl_usdc_payout_wallet': value.splUsdcPayoutWallet, 'coin_flair_mint': value.coinFlairMint, - 'playlist_library': UpdateUserRequestBodyPlaylistLibraryToJSON(value.playlistLibrary), + 'playlist_library': UserPlaylistLibraryToJSON(value.playlistLibrary), 'events': CreateUserRequestBodyEventsToJSON(value.events), }; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts deleted file mode 100644 index 4cbcdb64750..00000000000 --- a/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBodyPlaylistLibrary.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @ts-nocheck -/** - * API - * Audius V1 API - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { CreateUserRequestBodyPlaylistLibraryContentsInner } from './CreateUserRequestBodyPlaylistLibraryContentsInner'; -import { - CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON, - CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped, - CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON, -} from './CreateUserRequestBodyPlaylistLibraryContentsInner'; - -/** - * User's playlist library with support for folders and playlists - * @export - * @interface UpdateUserRequestBodyPlaylistLibrary - */ -export interface UpdateUserRequestBodyPlaylistLibrary { - /** - * Array of folders and playlist identifiers - * @type {Array} - * @memberof UpdateUserRequestBodyPlaylistLibrary - */ - contents?: Array; -} - -/** - * Check if a given object implements the UpdateUserRequestBodyPlaylistLibrary interface. - */ -export function instanceOfUpdateUserRequestBodyPlaylistLibrary(value: object): value is UpdateUserRequestBodyPlaylistLibrary { - let isInstance = true; - - return isInstance; -} - -export function UpdateUserRequestBodyPlaylistLibraryFromJSON(json: any): UpdateUserRequestBodyPlaylistLibrary { - return UpdateUserRequestBodyPlaylistLibraryFromJSONTyped(json, false); -} - -export function UpdateUserRequestBodyPlaylistLibraryFromJSONTyped(json: any, ignoreDiscriminator: boolean): UpdateUserRequestBodyPlaylistLibrary { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'contents': !exists(json, 'contents') ? undefined : ((json['contents'] as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON)), - }; -} - -export function UpdateUserRequestBodyPlaylistLibraryToJSON(value?: UpdateUserRequestBodyPlaylistLibrary | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'contents': value.contents === undefined ? undefined : ((value.contents as Array).map(CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON)), - }; -} - diff --git a/packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibrary.ts b/packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibrary.ts new file mode 100644 index 00000000000..ef034bd1d8c --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibrary.ts @@ -0,0 +1,74 @@ +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck +/** + * API + * Audius V1 API + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { UserPlaylistLibraryContentsInner } from './UserPlaylistLibraryContentsInner'; +import { + UserPlaylistLibraryContentsInnerFromJSON, + UserPlaylistLibraryContentsInnerFromJSONTyped, + UserPlaylistLibraryContentsInnerToJSON, +} from './UserPlaylistLibraryContentsInner'; + +/** + * User's playlist library with support for folders and playlists + * @export + * @interface UserPlaylistLibrary + */ +export interface UserPlaylistLibrary { + /** + * Array of folders and playlist identifiers + * @type {Array} + * @memberof UserPlaylistLibrary + */ + contents: Array; +} + +/** + * Check if a given object implements the UserPlaylistLibrary interface. + */ +export function instanceOfUserPlaylistLibrary(value: object): value is UserPlaylistLibrary { + let isInstance = true; + isInstance = isInstance && "contents" in value && value["contents"] !== undefined; + + return isInstance; +} + +export function UserPlaylistLibraryFromJSON(json: any): UserPlaylistLibrary { + return UserPlaylistLibraryFromJSONTyped(json, false); +} + +export function UserPlaylistLibraryFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserPlaylistLibrary { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'contents': ((json['contents'] as Array).map(UserPlaylistLibraryContentsInnerFromJSON)), + }; +} + +export function UserPlaylistLibraryToJSON(value?: UserPlaylistLibrary | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'contents': ((value.contents as Array).map(UserPlaylistLibraryContentsInnerToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts b/packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibraryContentsInner.ts similarity index 72% rename from packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts rename to packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibraryContentsInner.ts index 4ba0e0b53b2..f3524c34107 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBodyPlaylistLibraryContentsInner.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibraryContentsInner.ts @@ -36,24 +36,24 @@ import { } from './PlaylistLibraryPlaylistIdentifier'; /** - * @type CreateUserRequestBodyPlaylistLibraryContentsInner + * @type UserPlaylistLibraryContentsInner * * @export */ -export type CreateUserRequestBodyPlaylistLibraryContentsInner = PlaylistLibraryExplorePlaylistIdentifier | PlaylistLibraryFolder | PlaylistLibraryPlaylistIdentifier; +export type UserPlaylistLibraryContentsInner = PlaylistLibraryExplorePlaylistIdentifier | PlaylistLibraryFolder | PlaylistLibraryPlaylistIdentifier; -export function CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSON(json: any): CreateUserRequestBodyPlaylistLibraryContentsInner { - return CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped(json, false); +export function UserPlaylistLibraryContentsInnerFromJSON(json: any): UserPlaylistLibraryContentsInner { + return UserPlaylistLibraryContentsInnerFromJSONTyped(json, false); } -export function CreateUserRequestBodyPlaylistLibraryContentsInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateUserRequestBodyPlaylistLibraryContentsInner { +export function UserPlaylistLibraryContentsInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserPlaylistLibraryContentsInner { if ((json === undefined) || (json === null)) { return json; } return { ...PlaylistLibraryExplorePlaylistIdentifierFromJSONTyped(json, true), ...PlaylistLibraryFolderFromJSONTyped(json, true), ...PlaylistLibraryPlaylistIdentifierFromJSONTyped(json, true) }; } -export function CreateUserRequestBodyPlaylistLibraryContentsInnerToJSON(value?: CreateUserRequestBodyPlaylistLibraryContentsInner | null): any { +export function UserPlaylistLibraryContentsInnerToJSON(value?: UserPlaylistLibraryContentsInner | null): any { if (value === undefined) { return undefined; } diff --git a/packages/sdk/src/sdk/api/generated/default/models/index.ts b/packages/sdk/src/sdk/api/generated/default/models/index.ts index f6560cc3c36..53fa9e609f9 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/index.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/index.ts @@ -64,8 +64,6 @@ export * from './CreateUserDeveloperAppRequestBody'; export * from './CreateUserDeveloperAppResponse'; export * from './CreateUserRequestBody'; export * from './CreateUserRequestBodyEvents'; -export * from './CreateUserRequestBodyPlaylistLibrary'; -export * from './CreateUserRequestBodyPlaylistLibraryContentsInner'; export * from './CreateUserResponse'; export * from './DashboardWalletUser'; export * from './DashboardWalletUsersResponse'; @@ -182,7 +180,6 @@ export * from './UpdateDeveloperAppRequestBody'; export * from './UpdatePlaylistRequestBody'; export * from './UpdateTrackRequestBody'; export * from './UpdateUserRequestBody'; -export * from './UpdateUserRequestBodyPlaylistLibrary'; export * from './User'; export * from './UserCoin'; export * from './UserCoinAccount'; @@ -192,6 +189,8 @@ export * from './UserCoinsResponse'; export * from './UserCommentsResponse'; export * from './UserIdAddress'; export * from './UserIdsAddressesResponse'; +export * from './UserPlaylistLibrary'; +export * from './UserPlaylistLibraryContentsInner'; export * from './UserResponse'; export * from './UserSearch'; export * from './UserTrackListenCountsResponse'; diff --git a/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts b/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts index 766e0278756..c7e92250a96 100644 --- a/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts +++ b/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts @@ -10,7 +10,7 @@ import { AdvancedOptions } from '../../services/EntityManager/types' import type { LoggerService } from '../../services/Logger' -import { encodeHashId } from '../../utils/hashId' +import { decodeHashId, encodeHashId } from '../../utils/hashId' import { parseParams } from '../../utils/parseParams' import { retry3 } from '../../utils/retry' import { @@ -22,9 +22,12 @@ import { type FavoritePlaylistRequest, type UnfavoritePlaylistRequest, type SharePlaylistRequest, - type UpdateTrackRequestBody + TracksApi, + type CreateTrackRequestBody, + type CreatePlaylistRequestBody } from '../generated/default' import { TrackUploadHelper } from '../tracks/TrackUploadHelper' +import { UploadTrackSchema } from '../tracks/types' import { AddTrackToPlaylistRequest, @@ -65,6 +68,7 @@ const getCurrentTimestamp = () => { export class PlaylistsApi extends GeneratedPlaylistsApi { private readonly trackUploadHelper: TrackUploadHelper + private readonly tracksApi: TracksApi constructor( configuration: Configuration, @@ -73,6 +77,7 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { private readonly logger: LoggerService ) { super(configuration) + this.tracksApi = new TracksApi(configuration) this.trackUploadHelper = new TrackUploadHelper(configuration) this.logger = logger.createPrefixedLogger('[playlists-api]') } @@ -85,19 +90,64 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { advancedOptions?: AdvancedOptions ) { // Parse inputs - const parsedParameters = await parseParams( - 'createPlaylist', - CreatePlaylistSchema - )(params) + const { + userId, + playlistId: providedPlaylistId, + metadata, + trackIds + } = await parseParams('createPlaylist', CreatePlaylistSchema)(params) + + const playlistId = providedPlaylistId || (await this.generatePlaylistId()) + const timestamp = getCurrentTimestamp() - // Call createPlaylistInternal with parsed inputs - return await this.createPlaylistInternal(parsedParameters, advancedOptions) + // Update metadata to include track ids + const updatedMetadata = { + ...metadata, + playlistContents: (trackIds ?? []).map((trackId) => ({ + trackId, + timestamp + })) + } + + // Write playlist metadata to chain + const response = await this.entityManager.manageEntity({ + userId, + entityType: EntityType.PLAYLIST, + entityId: playlistId, + action: Action.CREATE, + metadata: JSON.stringify({ + cid: '', + data: snakecaseKeys(updatedMetadata) + }), + ...advancedOptions + }) + + return { + ...response, + playlistId: encodeHashId(playlistId) + } } override async createPlaylist( params: CreatePlaylistRequestWithFiles, requestInit?: RequestInit ) { + if (params.imageFile) { + const imageUploadResponse = await this.storage + .uploadFile({ + file: params.imageFile, + onProgress: (event) => + params.onProgress?.(event.loaded / event.total, { + ...event, + key: 'image' + }), + metadata: { + template: 'img_square' + } + }) + .start() + params.metadata.coverArtCid = imageUploadResponse.orig_file_cid + } if (this.entityManager) { const { metadata } = params const res = await this.createPlaylistWithEntityManager({ @@ -120,14 +170,149 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { params: UploadPlaylistRequest, advancedOptions?: AdvancedOptions ) { - // Parse inputs - const parsedParameters = await parseParams( + const { userId, onProgress, audioFiles, imageFile } = await parseParams( 'uploadPlaylist', UploadPlaylistSchema )(params) - // Call uploadPlaylistInternal with parsed inputs - return await this.uploadPlaylistInternal(parsedParameters, advancedOptions) + const trackMetadatas = params.trackMetadatas + const playlistMetadata = params.metadata + + const progresses = audioFiles.map(() => 0) + const [imageUploadResponse, ...audioUploadResponses] = await Promise.all([ + params.imageFile && + this.storage + .uploadFile({ + file: imageFile, + onProgress: (event) => + onProgress?.(event.loaded / event.total, { + ...event, + key: 'image' + }), + metadata: { + template: 'img_square' + } + }) + .start(), + ...audioFiles.map((trackFile, idx) => + this.storage + .uploadFile({ + file: trackFile, + onProgress: (progress) => { + progresses[idx] = + (progress.loaded / progress.total) * 0.5 + + progress.transcode * 0.5 + const overallProgress = + progresses.reduce((a, b) => a + b, 0) / audioFiles.length + onProgress?.(overallProgress, { + ...progress, + key: idx + }) + }, + metadata: { + template: 'audio', + placementHosts: trackMetadatas[idx]?.placementHosts, + previewStartSeconds: trackMetadatas[idx]?.previewStartSeconds + } + }) + .start() + ) + ]) + + // Write tracks to chain + const trackIds = await Promise.all( + trackMetadatas.map(async (t, i) => { + // Transform track metadata + const trackMetadata = this.combineMetadata( + this.trackUploadHelper.transformTrackUploadMetadata(t, userId), + playlistMetadata + ) + + const audioResponse = audioUploadResponses[i] + + if (!audioResponse) { + throw new Error(`Failed to upload track: ${t.title}`) + } + + // Update metadata to include uploaded CIDs + const updatedMetadata = + this.trackUploadHelper.populateTrackMetadataWithUploadResponse( + trackMetadata, + audioResponse, + imageUploadResponse + ) + + if (this.entityManager) { + const { metadata } = UploadTrackSchema.parse(updatedMetadata) + const trackId = await this.trackUploadHelper.generateId('track') + await this.entityManager.manageEntity({ + userId, + entityType: EntityType.TRACK, + entityId: trackId, + action: Action.CREATE, + metadata: JSON.stringify({ + cid: '', + data: snakecaseKeys(metadata) + }), + ...advancedOptions + }) + + return trackId + } + + const res = await this.tracksApi.createTrack({ + userId: encodeHashId(userId)!, + metadata: updatedMetadata + }) + return decodeHashId(res.trackId!)! + }) + ) + + const timestamp = getCurrentTimestamp() + + if (this.entityManager) { + // Update metadata to include track ids + const updatedMetadata = { + ...params.metadata, + playlistContents: (trackIds ?? []).map((trackId) => ({ + trackId, + timestamp + })), + playlistImageSizesMultihash: imageUploadResponse?.orig_file_cid + } + const playlistId = await this.generatePlaylistId() + // Write playlist metadata to chain + const response = await this.entityManager.manageEntity({ + userId, + entityType: EntityType.PLAYLIST, + entityId: playlistId, + action: Action.CREATE, + metadata: JSON.stringify({ + cid: '', + data: snakecaseKeys(updatedMetadata) + }), + ...advancedOptions + }) + + return { + ...response, + playlistId: encodeHashId(playlistId) + } + } + + // Update metadata to include track ids + const updatedMetadata = { + ...params.metadata, + playlistContents: (trackIds ?? []).map((trackId) => ({ + trackId: encodeHashId(trackId)!, + timestamp + })), + playlistImageSizesMultihash: imageUploadResponse?.orig_file_cid + } + return super.createPlaylist({ + userId: encodeHashId(userId)!, + metadata: updatedMetadata + }) } /** @hidden @@ -506,8 +691,8 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { * taking the metadata from the playlist when the track is missing it. */ private combineMetadata( - trackMetadata: UpdateTrackRequestBody, - playlistMetadata: PlaylistMetadata + trackMetadata: CreateTrackRequestBody, + playlistMetadata: CreatePlaylistRequestBody ) { const metadata = trackMetadata @@ -588,153 +773,6 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { ) } - /** @internal - * Method to upload a playlist with already parsed inputs - * This is used for both playlists and albums - */ - public async uploadPlaylistInternal( - { - userId, - imageFile, - audioFiles, - onProgress, - metadata, - trackMetadatas - }: z.infer & { - metadata: Metadata - }, - advancedOptions?: AdvancedOptions - ) { - const progresses = audioFiles.map(() => 0) - // Upload track audio and cover art to storage node - const [coverArtResponse, ...audioResponses] = await Promise.all([ - retry3( - async () => - await this.storage - .uploadFile({ - file: imageFile, - onProgress: (progress) => - onProgress?.( - progresses.reduce((a, b) => a + b, 0) / audioFiles.length, - { ...progress, key: 'image' } - ), - metadata: { - template: 'img_square' - } - }) - .start(), - (e) => { - this.logger.info('Retrying uploadPlaylistCoverArt', e) - } - ), - ...audioFiles.map( - async (trackFile, idx) => - await retry3( - async () => - await this.storage - .uploadFile({ - file: trackFile, - onProgress: (progress) => { - progresses[idx] = - (progress.loaded / progress.total) * 0.5 + - progress.transcode * 0.5 - const overallProgress = - progresses.reduce((a, b) => a + b, 0) / audioFiles.length - onProgress?.(overallProgress, { - ...progress, - key: idx - }) - }, - metadata: { - template: 'audio', - ...this.trackUploadHelper.extractMediorumUploadOptions( - trackMetadatas[idx]! - ) - } - }) - .start(), - (e) => { - this.logger.info('Retrying uploadTrackAudio', e) - } - ) - ) - ]) - - // Write tracks to chain - const trackIds = await Promise.all( - trackMetadatas.map(async (parsedTrackMetadata, i) => { - // Transform track metadata - const trackMetadata = this.combineMetadata( - this.trackUploadHelper.transformTrackUploadMetadata( - parsedTrackMetadata, - userId - ), - metadata - ) - - const audioResponse = audioResponses[i] - - if (!audioResponse) { - throw new Error(`Failed to upload track: ${trackMetadata.title}`) - } - - // Update metadata to include uploaded CIDs - const updatedMetadata = - this.trackUploadHelper.populateTrackMetadataWithUploadResponse( - trackMetadata, - audioResponse, - coverArtResponse - ) - - const trackId = await this.trackUploadHelper.generateId('track') - await this.entityManager.manageEntity({ - userId, - entityType: EntityType.TRACK, - entityId: trackId, - action: Action.CREATE, - metadata: JSON.stringify({ - cid: '', - data: snakecaseKeys(updatedMetadata) - }), - ...advancedOptions - }) - - return trackId - }) - ) - - const playlistId = await this.trackUploadHelper.generateId('playlist') - const timestamp = getCurrentTimestamp() - - // Update metadata to include track ids and cover art cid - const updatedMetadata = { - ...metadata, - isPrivate: false, - playlistContents: trackIds.map((trackId) => ({ - trackId, - timestamp - })), - playlistImageSizesMultihash: coverArtResponse?.orig_file_cid - } - - // Write playlist metadata to chain - const response = await this.entityManager.manageEntity({ - userId, - entityType: EntityType.PLAYLIST, - entityId: playlistId, - action: Action.CREATE, - metadata: JSON.stringify({ - cid: '', - data: snakecaseKeys(updatedMetadata) - }), - ...advancedOptions - }) - return { - ...response, - playlistId: encodeHashId(playlistId) - } - } - /** @internal * Method to create a playlist with already parsed inputs * This is used for both playlists and albums diff --git a/packages/sdk/src/sdk/api/playlists/types.ts b/packages/sdk/src/sdk/api/playlists/types.ts index 4c720ae0ed8..4de0721bdd0 100644 --- a/packages/sdk/src/sdk/api/playlists/types.ts +++ b/packages/sdk/src/sdk/api/playlists/types.ts @@ -8,9 +8,10 @@ import { Genre, Mood, type CreatePlaylistRequest, + type CreatePlaylistRequestBody, + type CreateTrackRequestBody, type UpdatePlaylistRequest } from '../generated/default' -import { UploadTrackMetadataSchema } from '../tracks/types' const CreatePlaylistMetadataSchema = z .object({ @@ -61,18 +62,6 @@ export const UploadPlaylistMetadataSchema = CreatePlaylistMetadataSchema.extend( export type PlaylistMetadata = z.input -const PlaylistTrackMetadataSchema = UploadTrackMetadataSchema.partial({ - genre: true, - mood: true, - tags: true -}) - -/** - * PlaylistTrackMetadata is less strict than TrackMetadata because - * `genre`, `mood`, and `tags` are optional - */ -export type PlaylistTrackMetadata = z.infer - export const UploadPlaylistProgressEventSchema = ProgressEventSchema.extend({ /** * Index of the track being uploaded in the playlist tracks array, or 'image' if for the image @@ -103,25 +92,20 @@ export type UploadPlaylistProgressHandler = ( event: UploadPlaylistProgressEvent ) => void -export const UploadPlaylistSchema = z - .object({ - userId: HashId, - imageFile: ImageFile, - metadata: UploadPlaylistMetadataSchema, - onProgress: z.optional(UploadPlaylistProgressHandlerSchema), - /** - * Track metadata is populated from the playlist if fields are missing - */ - trackMetadatas: z.array(PlaylistTrackMetadataSchema), - audioFiles: z.array(AudioFile) - }) - .strict() +export const UploadPlaylistSchema = z.object({ + userId: HashId, + imageFile: ImageFile, + onProgress: z.optional(UploadPlaylistProgressHandlerSchema), + audioFiles: z.array(AudioFile) +}) export type UploadPlaylistRequest = Omit< z.input, 'onProgress' > & { onProgress?: UploadPlaylistProgressHandler + metadata: CreatePlaylistRequestBody + trackMetadatas: CreateTrackRequestBody[] } export const UpdatePlaylistMetadataSchema = @@ -162,12 +146,6 @@ export type PlaylistImageParameters = { onProgress?: UploadPlaylistProgressHandler } -export type PlaylistAudioParameters = { - audioFiles?: z.input[] - trackMetadatas?: z.input[] - onProgress?: UploadPlaylistProgressHandler -} - export type CreatePlaylistRequestWithFiles = CreatePlaylistRequest & PlaylistImageParameters diff --git a/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts b/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts index c923f7facce..0e3aa46789a 100644 --- a/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts +++ b/packages/sdk/src/sdk/api/tracks/TrackUploadHelper.ts @@ -5,7 +5,6 @@ import { type CreateTrackRequestBody, type UpdateTrackRequestBody } from '../generated/default' -import type { PlaylistTrackMetadata } from '../playlists/types' export class TrackUploadHelper extends BaseAPI { public async generateId(type: 'track' | 'playlist') { @@ -24,11 +23,10 @@ export class TrackUploadHelper extends BaseAPI { return id } - public transformTrackUploadMetadata( - inputMetadata: CreateTrackRequestBody | UpdateTrackRequestBody, - userId: number - ) { - const metadata = { + public transformTrackUploadMetadata< + T extends CreateTrackRequestBody | UpdateTrackRequestBody + >(inputMetadata: T, userId: number) { + const metadata: T = { ...inputMetadata, ownerId: userId } @@ -57,8 +55,10 @@ export class TrackUploadHelper extends BaseAPI { return metadata } - public populateTrackMetadataWithUploadResponse( - trackMetadata: CreateTrackRequestBody | UpdateTrackRequestBody, + public populateTrackMetadataWithUploadResponse< + T extends CreateTrackRequestBody | UpdateTrackRequestBody + >( + trackMetadata: T, audioResponse?: UploadResponse, coverArtResponse?: UploadResponse ) { @@ -95,19 +95,4 @@ export class TrackUploadHelper extends BaseAPI { } return updated } - - public extractMediorumUploadOptions(metadata: PlaylistTrackMetadata) { - const uploadOptions: { [key: string]: string } = {} - if ( - metadata.previewStartSeconds !== undefined && - metadata.previewStartSeconds !== null - ) { - uploadOptions.previewStartSeconds = - metadata.previewStartSeconds.toString() - } - if (metadata.placementHosts) { - uploadOptions.placement_hosts = metadata.placementHosts - } - return uploadOptions - } } diff --git a/packages/sdk/src/sdk/api/tracks/TracksApi.ts b/packages/sdk/src/sdk/api/tracks/TracksApi.ts index ddfd73c8b86..d95e8608088 100644 --- a/packages/sdk/src/sdk/api/tracks/TracksApi.ts +++ b/packages/sdk/src/sdk/api/tracks/TracksApi.ts @@ -34,7 +34,8 @@ import { type ShareTrackRequest, type RepostTrackRequest, type UnrepostTrackRequest, - type RecordTrackDownloadRequest + type RecordTrackDownloadRequest, + type CreateTrackRequest } from '../generated/default' import { RequiredError } from '../generated/default/runtime' @@ -51,7 +52,6 @@ import { EntityManagerUnfavoriteTrackRequest, UnfavoriteTrackSchema, EntityManagerUpdateTrackRequest, - UploadTrackRequest, PurchaseTrackRequest, PurchaseTrackSchema, GetPurchaseTrackInstructionsRequest, @@ -69,7 +69,8 @@ import { type PublishStemRequest, PublishStemSchema, type UploadTrackFilesTask, - type UpdateTrackRequestWithFiles + type UpdateTrackRequestWithFiles, + type CreateTrackRequestWithFiles } from './types' // Extend that new class @@ -224,30 +225,28 @@ export class TracksApi extends GeneratedTracksApi { /** @hidden * Publishes a track that was uploaded using storage node uploadFileV2 uploads. */ - async publishTrack( - params: PublishTrackRequest, - advancedOptions?: AdvancedOptions - ) { - const { - userId, - metadata: parsedMetadata, - audioUploadResponse, - imageUploadResponse - } = await parseParams('publishTrack', PublishTrackSchema)(params) + async publishTrack(params: PublishTrackRequest, requestInit?: RequestInit) { + const { userId, audioUploadResponse, imageUploadResponse } = + await parseParams('publishTrack', PublishTrackSchema)(params) + const metadata = params.metadata - const metadata = this.trackUploadHelper.transformTrackUploadMetadata( - parsedMetadata, - userId - ) + const transformedMetadata = + this.trackUploadHelper.transformTrackUploadMetadata(metadata, userId) const populatedMetadata = this.trackUploadHelper.populateTrackMetadataWithUploadResponse( - metadata, + transformedMetadata, audioUploadResponse, imageUploadResponse ) - return this.writeTrackToChain(userId, populatedMetadata, advancedOptions) + if (this.entityManager) { + return this.writeTrackToChain(userId, populatedMetadata) + } + return super.createTrack( + { userId: params.userId, metadata: populatedMetadata }, + requestInit + ) } /** @hidden @@ -263,9 +262,8 @@ export class TracksApi extends GeneratedTracksApi { audioUploadResponse } = await parseParams('publishStem', PublishStemSchema)(params) - const trackMetadata = { + const trackMetadata: Partial = { title: audioUploadResponse.orig_filename || 'Untitled Stem', - isStreamGated: false, streamConditions: undefined, isUnlisted: false, fieldVisibility: { @@ -277,7 +275,10 @@ export class TracksApi extends GeneratedTracksApi { playCount: false }, isDownloadable: true, - stemOf: parsedMetadata + stemOf: { + parentTrackId: params.metadata.parentTrackId, + category: parsedMetadata.category + } } const metadata = this.trackUploadHelper.transformTrackUploadMetadata( @@ -299,17 +300,14 @@ export class TracksApi extends GeneratedTracksApi { */ async writeTrackToChain( userId: number, - metadata: ReturnType< - typeof this.trackUploadHelper.populateTrackMetadataWithUploadResponse - >, + metadata: Partial, advancedOptions?: AdvancedOptions ) { - // Write metadata to chain - this.logger.info('Writing metadata to chain') + const { metadata: parsedMetadata } = UploadTrackSchema.parse(metadata) const entityId = - 'trackId' in metadata && metadata.trackId - ? metadata.trackId + 'trackId' in parsedMetadata && parsedMetadata.trackId + ? parsedMetadata.trackId : await this.trackUploadHelper.generateId('track') const response = await this.entityManager.manageEntity({ @@ -320,38 +318,32 @@ export class TracksApi extends GeneratedTracksApi { metadata: JSON.stringify({ cid: '', data: { - ...snakecaseKeys(metadata), + ...snakecaseKeys(parsedMetadata), owner_id: userId, download_conditions: - metadata.downloadConditions && - snakecaseKeys(metadata.downloadConditions), + parsedMetadata.downloadConditions && + snakecaseKeys(parsedMetadata.downloadConditions), stream_conditions: - metadata.streamConditions && - snakecaseKeys(metadata.streamConditions), - stem_of: metadata.stemOf && snakecaseKeys(metadata.stemOf) + parsedMetadata.streamConditions && + snakecaseKeys(parsedMetadata.streamConditions), + stem_of: parsedMetadata.stemOf && snakecaseKeys(parsedMetadata.stemOf) } }), ...advancedOptions }) - this.logger.info('Successfully uploaded track') return { ...response, trackId: encodeHashId(entityId)! } } - /** - * Upload a track - */ - async uploadTrack( - params: UploadTrackRequest, - advancedOptions?: AdvancedOptions + override async createTrack( + params: CreateTrackRequestWithFiles, + requestInit?: RequestInit ) { - // Validate inputs - await parseParams('uploadTrack', UploadTrackSchema)(params) - - // Upload track files + // Upload files + let metadata = params.metadata const { audioUploadResponse, imageUploadResponse } = await this.uploadTrackFiles({ audioFile: params.audioFile, @@ -363,19 +355,26 @@ export class TracksApi extends GeneratedTracksApi { onProgress: params.onProgress }).start() - if (!audioUploadResponse || !imageUploadResponse) { - throw new Error('uploadTrack: Missing upload responses') - } + metadata = this.trackUploadHelper.transformTrackUploadMetadata( + metadata, + decodeHashId(params.userId)! + ) + + metadata = this.trackUploadHelper.populateTrackMetadataWithUploadResponse( + metadata, + audioUploadResponse, + imageUploadResponse + ) - // Write track metadata to chain - return this.publishTrack( + if (this.entityManager) { + return this.writeTrackToChain(decodeHashId(params.userId)!, metadata) + } + return super.createTrack( { userId: params.userId, - metadata: params.metadata, - audioUploadResponse, - imageUploadResponse + metadata }, - advancedOptions + requestInit ) } @@ -387,62 +386,10 @@ export class TracksApi extends GeneratedTracksApi { advancedOptions?: AdvancedOptions ) { // Parse inputs - const { - userId, - trackId, - audioFile, - imageFile, - metadata: parsedMetadata, - onProgress, - generatePreview - } = await parseParams('updateTrack', UpdateTrackSchema)(params) - - // Transform metadata - const metadata = this.trackUploadHelper.transformTrackUploadMetadata( - parsedMetadata, - userId - ) - - const { audioUploadResponse, imageUploadResponse } = - await this.uploadTrackFiles({ - audioFile, - imageFile, - fileMetadata: { - placementHosts: parsedMetadata.placementHosts, - previewStartSeconds: parsedMetadata.previewStartSeconds - }, - onProgress - }).start() - - // Update metadata to include uploaded CIDs - const updatedMetadata = - this.trackUploadHelper.populateTrackMetadataWithUploadResponse( - metadata, - audioUploadResponse, - imageUploadResponse - ) - - // Generate preview if requested and no audio file was uploaded - // (as that would handle the preview generation already) - if (generatePreview && !audioFile) { - if (updatedMetadata.previewStartSeconds === undefined) { - throw new Error('No track preview start time specified') - } - - const previewCid = await retry3( - async () => - await this.storage.generatePreview({ - cid: updatedMetadata.trackCid!, - secondOffset: updatedMetadata.previewStartSeconds! - }), - (e) => { - this.logger.info('Retrying generatePreview', e) - } - ) - - // Update metadata to include updated preview CID - updatedMetadata.previewCid = previewCid - } + const { userId, trackId, metadata } = await parseParams( + 'updateTrack', + UpdateTrackSchema + )(params) // Write metadata to chain return await this.entityManager.manageEntity({ @@ -453,13 +400,13 @@ export class TracksApi extends GeneratedTracksApi { metadata: JSON.stringify({ cid: '', data: { - ...snakecaseKeys(updatedMetadata), + ...snakecaseKeys(metadata), download_conditions: - updatedMetadata.downloadConditions && - snakecaseKeys(updatedMetadata.downloadConditions), + metadata.downloadConditions && + snakecaseKeys(metadata.downloadConditions), stream_conditions: - updatedMetadata.streamConditions && - snakecaseKeys(updatedMetadata.streamConditions), + metadata.streamConditions && + snakecaseKeys(metadata.streamConditions), stem_of: metadata.stemOf && snakecaseKeys(metadata.stemOf) } }), @@ -473,28 +420,44 @@ export class TracksApi extends GeneratedTracksApi { ) { // Upload files let metadata = params.metadata - if (params.audioFile || params.imageFile) { - const { audioUploadResponse, imageUploadResponse } = - await this.uploadTrackFiles({ - audioFile: params.audioFile, - imageFile: params.imageFile, - fileMetadata: { - placementHosts: metadata.placementHosts, - previewStartSeconds: metadata.previewStartSeconds - }, - onProgress: params.onProgress - }).start() - - metadata = this.trackUploadHelper.transformTrackUploadMetadata( - metadata, - decodeHashId(params.userId)! - ) + const { audioUploadResponse, imageUploadResponse } = + await this.uploadTrackFiles({ + audioFile: params.audioFile, + imageFile: params.imageFile, + fileMetadata: { + placementHosts: params.metadata.placementHosts, + previewStartSeconds: params.metadata.previewStartSeconds + }, + onProgress: params.onProgress + }).start() - metadata = this.trackUploadHelper.populateTrackMetadataWithUploadResponse( - metadata, - audioUploadResponse, - imageUploadResponse + metadata = this.trackUploadHelper.transformTrackUploadMetadata( + metadata, + decodeHashId(params.userId)! + ) + + metadata = this.trackUploadHelper.populateTrackMetadataWithUploadResponse( + metadata, + audioUploadResponse, + imageUploadResponse + ) + + // Generate preview if requested and no audio file was uploaded + // (as that would handle the preview generation already) + if (metadata.previewStartSeconds !== undefined && !params.audioFile) { + const previewCid = await retry3( + async () => + await this.storage.generatePreview({ + cid: metadata.trackCid!, + secondOffset: metadata.previewStartSeconds! + }), + (e) => { + this.logger.info('Retrying generatePreview', e) + } ) + + // Update metadata to include updated preview CID + metadata.previewCid = previewCid } if (this.entityManager) { @@ -512,7 +475,7 @@ export class TracksApi extends GeneratedTracksApi { { trackId: params.trackId, userId: params.userId, - metadata + metadata: params.metadata }, requestInit ) diff --git a/packages/sdk/src/sdk/api/tracks/types.ts b/packages/sdk/src/sdk/api/tracks/types.ts index 4640b5e5d85..81714ab4c12 100644 --- a/packages/sdk/src/sdk/api/tracks/types.ts +++ b/packages/sdk/src/sdk/api/tracks/types.ts @@ -14,7 +14,8 @@ import { Mood, Genre, StemCategory, - type UpdateTrackRequest + type UpdateTrackRequest, + type CreateTrackRequest } from '../generated/default' import { MAX_DESCRIPTION_LENGTH } from './constants' @@ -97,7 +98,7 @@ export const UploadStemMetadataSchema = z.object({ category: z .enum(Object.values(StemCategory) as [StemCategory, ...StemCategory[]]) .default(StemCategory.Other), - parentTrackId: HashId.or(z.number()) + parentTrackId: HashId }) export const UploadTrackMetadataSchema = z.object({ @@ -149,7 +150,7 @@ export const UploadTrackMetadataSchema = z.object({ tracks: z .array( z.object({ - parentTrackId: HashId.or(z.number()) + parentTrackId: HashId }) ) .min(1) @@ -453,16 +454,16 @@ const UploadResponseSchema = z.object({ export type UploadResponse = z.input -export const PublishTrackSchema = z - .object({ - userId: HashId, - metadata: UploadTrackMetadataSchema.strict(), - audioUploadResponse: UploadResponseSchema, - imageUploadResponse: UploadResponseSchema - }) - .strict() +export const PublishTrackSchema = z.object({ + userId: HashId, + audioUploadResponse: UploadResponseSchema, + imageUploadResponse: UploadResponseSchema +}) -export type PublishTrackRequest = z.input +export type PublishTrackRequest = CreateTrackRequest & { + audioUploadResponse: UploadResponse + imageUploadResponse: UploadResponse +} export const PublishStemSchema = z .object({ @@ -482,8 +483,14 @@ export type UploadTrackFilesTask = { abort: () => void } -export type UpdateTrackRequestWithFiles = UpdateTrackRequest & { +export type TrackFileUploadParams = { audioFile?: z.input imageFile?: z.input onProgress?: UploadTrackFilesProgressHandler } + +export type CreateTrackRequestWithFiles = CreateTrackRequest & + TrackFileUploadParams + +export type UpdateTrackRequestWithFiles = UpdateTrackRequest & + TrackFileUploadParams diff --git a/packages/sdk/src/sdk/api/users/UsersApi.test.ts b/packages/sdk/src/sdk/api/users/UsersApi.test.ts index cf7df74c39b..be068dd88f8 100644 --- a/packages/sdk/src/sdk/api/users/UsersApi.test.ts +++ b/packages/sdk/src/sdk/api/users/UsersApi.test.ts @@ -117,8 +117,9 @@ describe('UsersApi', () => { describe('updateProfile', () => { it('updates the user profile if valid metadata is provided', async () => { - const result = await users.updateProfile({ + const result = await users.updateUser({ userId: '7eP5n', + id: '7eP5n', profilePictureFile: { buffer: pngFile, name: 'profilePicture' @@ -143,7 +144,8 @@ describe('UsersApi', () => { }) it('updates the user profile if partial valid metadata is provided', async () => { - const result = await users.updateProfile({ + const result = await users.updateUser({ + id: '7eP5n', userId: '7eP5n', metadata: { bio: 'The bio has been updated' @@ -158,8 +160,9 @@ describe('UsersApi', () => { it('throws an error if invalid metadata is provided', async () => { await expect(async () => { - await users.updateProfile({ + await users.updateUser({ userId: '7eP5n', + id: '7eP5n', metadata: { asdf: '123' } as any @@ -169,7 +172,9 @@ describe('UsersApi', () => { it('throws an error if invalid request is sent', async () => { await expect(async () => { - await users.updateProfile({ + await users.updateUser({ + id: '7eP5n', + userId: '7eP5n', metadata: { bio: 'New bio' } } as any) }).rejects.toThrow() diff --git a/packages/sdk/src/sdk/api/users/UsersApi.ts b/packages/sdk/src/sdk/api/users/UsersApi.ts index 3b52079b1a2..8bf5c92d4ec 100644 --- a/packages/sdk/src/sdk/api/users/UsersApi.ts +++ b/packages/sdk/src/sdk/api/users/UsersApi.ts @@ -16,14 +16,13 @@ import { HashId, Id } from '../../types/HashId' import { generateMetadataCidV1 } from '../../utils/cid' import { decodeHashId, encodeHashId } from '../../utils/hashId' import { parseParams } from '../../utils/parseParams' -import { retry3 } from '../../utils/retry' import { Configuration, DownloadPurchasesAsCSVRequest, DownloadSalesAsCSVRequest, DownloadUSDCWithdrawalsAsCSVRequest, UsersApi as GeneratedUsersApi, - type CreateUserRequest + type UserPlaylistLibrary } from '../generated/default' import * as runtime from '../generated/default/runtime' @@ -51,7 +50,11 @@ import { UpdateCollectiblesSchema, UpdateProfileSchema, type EntityManagerCreateUserRequest, - type EntityManagerUpdateProfileRequest + type EntityManagerUpdateProfileRequest, + type UpdateUserRequestWithFiles, + type CreateUserRequestWithFiles, + type UserFileUploadParams, + type EntityManagerPlaylistLibraryContents } from './types' export class UsersApi extends GeneratedUsersApi { @@ -92,8 +95,10 @@ export class UsersApi extends GeneratedUsersApi { params: EntityManagerCreateUserRequest, advancedOptions?: AdvancedOptions ) { - const { onProgress, profilePictureFile, coverArtFile, metadata } = - await parseParams('createUser', CreateUserSchema)(params) + const { metadata } = await parseParams( + 'createUser', + CreateUserSchema + )(params) const { data } = await this.generateUserId() if (!data) { @@ -101,59 +106,7 @@ export class UsersApi extends GeneratedUsersApi { } const userId = HashId.parse(data) - const [profilePictureResp, coverArtResp] = await Promise.all([ - profilePictureFile && - retry3( - async () => - await this.storage - .uploadFile({ - file: profilePictureFile, - onProgress, - metadata: { - template: 'img_square' - } - }) - .start(), - (e) => { - this.logger.info('Retrying uploadProfilePicture', e) - } - ), - coverArtFile && - retry3( - async () => - await this.storage - .uploadFile({ - file: coverArtFile, - onProgress, - metadata: { - template: 'img_backdrop' - } - }) - .start(), - (e) => { - this.logger.info('Retrying uploadProfileCoverArt', e) - } - ) - ]) - - const updatedMetadata = { - ...metadata, - userId, - ...(profilePictureResp - ? { - profilePicture: profilePictureResp?.orig_file_cid, - profilePictureSizes: profilePictureResp?.orig_file_cid - } - : {}), - ...(coverArtResp - ? { - coverPhoto: coverArtResp?.orig_file_cid, - coverPhotoSizes: coverArtResp?.orig_file_cid - } - : {}) - } - - const entityMetadata = snakecaseKeys(updatedMetadata) + const entityMetadata = snakecaseKeys(metadata) const cid = (await generateMetadataCidV1(entityMetadata)).toString() @@ -170,30 +123,29 @@ export class UsersApi extends GeneratedUsersApi { ...advancedOptions }) - return { blockHash, blockNumber, metadata: updatedMetadata } + return { blockHash, blockNumber, metadata } } override async createUser( - params: CreateUserRequest, + params: CreateUserRequestWithFiles, requestInit?: RequestInit ) { + const metadata = await this.updateMetadataWithFiles(params.metadata, params) if (this.entityManager) { - const { metadata } = params const res = await this.createUserWithEntityManager({ - metadata: { - ...metadata, - events: { - ...metadata.events, - referrer: Id.parse(metadata.events?.referrer)! - } - } + metadata }) return { success: true, transactionHash: res.blockHash } } - return super.createUser(params, requestInit) + return super.createUser( + { + metadata + }, + requestInit + ) } /** @hidden @@ -229,66 +181,15 @@ export class UsersApi extends GeneratedUsersApi { /** @hidden * Update a user profile */ - async updateProfile( + async updateUserWithEntityManager( params: EntityManagerUpdateProfileRequest, advancedOptions?: AdvancedOptions ) { - // Parse inputs - const { onProgress, profilePictureFile, coverArtFile, userId, metadata } = - await parseParams('updateProfile', UpdateProfileSchema)(params) - - const [profilePictureResp, coverArtResp] = await Promise.all([ - profilePictureFile && - retry3( - async () => - await this.storage - .uploadFile({ - file: profilePictureFile, - onProgress, - metadata: { - template: 'img_square' - } - }) - .start(), - (e) => { - this.logger.info('Retrying uploadProfilePicture', e) - } - ), - coverArtFile && - retry3( - async () => - await this.storage - .uploadFile({ - file: coverArtFile, - onProgress, - metadata: { - template: 'img_backdrop' - } - }) - .start(), - (e) => { - this.logger.info('Retrying uploadProfileCoverArt', e) - } - ) - ]) - - const updatedMetadata = snakecaseKeys({ - ...metadata, - ...(profilePictureResp - ? { - profilePicture: profilePictureResp?.orig_file_cid, - profilePictureSizes: profilePictureResp?.orig_file_cid - } - : {}), - ...(coverArtResp - ? { - coverPhoto: coverArtResp?.orig_file_cid, - coverPhotoSizes: coverArtResp?.orig_file_cid - } - : {}) - }) - - const cid = (await generateMetadataCidV1(updatedMetadata)).toString() + const { userId, metadata } = await parseParams( + 'updateUser', + UpdateProfileSchema + )(params) + const cid = (await generateMetadataCidV1(metadata)).toString() // Write metadata to chain return await this.entityManager.manageEntity({ @@ -298,12 +199,113 @@ export class UsersApi extends GeneratedUsersApi { action: Action.UPDATE, metadata: JSON.stringify({ cid, - data: updatedMetadata + data: snakecaseKeys(metadata) }), ...advancedOptions }) } + private async updateMetadataWithFiles< + T extends + | CreateUserRequestWithFiles['metadata'] + | UpdateUserRequestWithFiles['metadata'] + >(metadata: T, fileUploadParams: UserFileUploadParams) { + const { onProgress, profilePictureFile, coverArtFile } = fileUploadParams + const [profilePictureResp, coverArtResp] = await Promise.all([ + profilePictureFile + ? await this.storage + .uploadFile({ + file: profilePictureFile, + onProgress, + metadata: { + template: 'img_square' + } + }) + .start() + : null, + coverArtFile + ? await this.storage + .uploadFile({ + file: coverArtFile, + onProgress, + metadata: { + template: 'img_backdrop' + } + }) + .start() + : null + ]) + if (profilePictureResp) { + metadata.profilePicture = profilePictureResp.orig_file_cid + metadata.profilePictureSizes = profilePictureResp.orig_file_cid + } + if (coverArtResp) { + metadata.coverPhoto = coverArtResp.orig_file_cid + metadata.coverPhotoSizes = coverArtResp.orig_file_cid + } + return metadata + } + + private mapLibraryContentsToEntityManagerFormat( + libraryItems: UserPlaylistLibrary['contents'] + ): EntityManagerPlaylistLibraryContents { + const items = [] + for (const item of libraryItems) { + if (item.type === 'folder') { + const folder = { + id: item.id, + type: 'folder' as const, + name: item.name, + contents: this.mapLibraryContentsToEntityManagerFormat(item.contents) + } + items.push(folder) + } + if (item.type === 'playlist') { + items.push({ + playlist_id: item.playlistId, + type: 'playlist' as const + }) + } + if (item.type === 'explore_playlist') { + items.push({ + playlist_id: item.playlistId, + type: 'explore_playlist' as const + }) + } + } + return items + } + + override async updateUser( + params: UpdateUserRequestWithFiles, + requestInit?: RequestInit + ) { + const metadata = await this.updateMetadataWithFiles(params.metadata, params) + if (this.entityManager) { + return await this.updateUserWithEntityManager({ + userId: Id.parse(params.id)!, + metadata: { + ...metadata, + playlistLibrary: metadata.playlistLibrary?.contents + ? { + contents: this.mapLibraryContentsToEntityManagerFormat( + metadata.playlistLibrary?.contents || [] + ) + } + : undefined + } + }) + } + return super.updateUser( + { + id: params.id, + userId: params.userId, + metadata + }, + requestInit + ) + } + /** @hidden * Follow a user */ diff --git a/packages/sdk/src/sdk/api/users/types.ts b/packages/sdk/src/sdk/api/users/types.ts index 93ca50743ad..3fedc4d7af1 100644 --- a/packages/sdk/src/sdk/api/users/types.ts +++ b/packages/sdk/src/sdk/api/users/types.ts @@ -1,5 +1,6 @@ import { z } from 'zod' +import type { CreateUserRequest, UpdateUserRequest } from '../..' import { ProgressHandler } from '../../services/Storage/types' import { EthAddressSchema } from '../../types/EthAddress' import { ImageFile } from '../../types/File' @@ -100,6 +101,10 @@ const PlaylistLibrarySchema = z.object({ ) }) +export type EntityManagerPlaylistLibraryContents = z.input< + typeof PlaylistLibrarySchema +>['contents'] + export const UpdateProfileSchema = z .object({ userId: HashId, @@ -283,3 +288,15 @@ export const UpdateCollectiblesSchema = z.object({ }) export type UpdateCollectiblesRequest = z.input + +export type UserFileUploadParams = { + profilePictureFile?: z.input + coverArtFile?: z.input + onProgress?: ProgressHandler +} + +export type CreateUserRequestWithFiles = CreateUserRequest & + UserFileUploadParams + +export type UpdateUserRequestWithFiles = UpdateUserRequest & + UserFileUploadParams