diff --git a/.changeset/purple-suns-reflect.md b/.changeset/purple-suns-reflect.md new file mode 100644 index 00000000000..158b56ee89d --- /dev/null +++ b/.changeset/purple-suns-reflect.md @@ -0,0 +1,18 @@ +--- +'@audius/sdk': major +--- + +Rewrite write endpoints + +Write endpoints have gone an entire overhaul, and now will call the API conditionally to handle writes on behalf of apps if the EntityManager service is not initialized. In order to support this, and moving towards having this be the default path moving forward, the signatures for the writes have all changed to align with the autogenerated code from the API schema of the API write endpoints. + +Non-exhaustive list of changes (see updated dev docs post release for complete breakdown of methods): + +- Creating albums and playlists no longer lets you pass in track IDs separately. They must be part of the `playlistContents` +- No more `advancedOptions` in order to match the required schema for the write endpoints in API. For now there's no replacement. Reach out if you desire these abilities again. +- Most write method parameters now have top level `userId` and (if applicable) entity id (eg. `playlistId` for `updatePlaylist`) and a `metadata` field, to mirror the autogenerated code which separates the request path/query params and body. CommentsAPI for example has been affected greatly by this. +- `updateUserProfile` is now `updateUser` +- `addTrackToPlaylist`, `removeTrackToPlaylist` etc should _not_ be used going forward. +- `updateCoinRequest` is now `metadata` in `updateCoin` method parameters. +- USDC access gates for stream/download conditions now have splits formatted as a list with elements `user_id` and `percentage` +- Authentication can now be done via a Bearer token when using the API routes 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 2fe6df27b68..1cec62adea6 100644 --- a/packages/common/src/adapters/collection.ts +++ b/packages/common/src/adapters/collection.ts @@ -1,11 +1,14 @@ import { - CreateAlbumMetadata, - CreatePlaylistMetadata, + type CreateAlbumRequestBody, + type CreatePlaylistRequestBody, full, Id, OptionalHashId, + type Playlist, + type PlaylistAddedTimestamp, UpdateAlbumRequest, - UpdatePlaylistRequest + type UpdateAlbumRequestBody, + type UpdatePlaylistRequestBody } from '@audius/sdk' import dayjs from 'dayjs' import { omit } from 'lodash' @@ -18,10 +21,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' @@ -34,13 +38,13 @@ const addedTimestampToPlaylistTrackId = ({ timestamp, trackId, metadataTimestamp -}: full.PlaylistAddedTimestamp): PlaylistTrackId | null => { +}: PlaylistAddedTimestamp): PlaylistTrackId | null => { const decoded = OptionalHashId.parse(trackId) if (decoded) { return { track: decoded, time: timestamp, - metadata_time: metadataTimestamp + metadata_time: metadataTimestamp ?? 0 } } return null @@ -51,11 +55,14 @@ export const userCollectionMetadataFromSDK = ( | full.PlaylistFullWithoutTracks | full.SearchPlaylistFull | full.PlaylistFull + | Playlist ): UserCollectionMetadata | undefined => { try { const decodedPlaylistId = OptionalHashId.parse(input.id) - const decodedOwnerId = OptionalHashId.parse(input.userId ?? input.user.id) - const user = userMetadataFromSDK(input.user) + const decodedOwnerId = OptionalHashId.parse( + 'userId' in input && input.userId != null ? input.userId : input.user.id + ) + const user = userMetadataFromSDK(input.user as unknown as full.UserFull) if (!decodedPlaylistId || !decodedOwnerId || !user) { return undefined } @@ -74,7 +81,7 @@ export const userCollectionMetadataFromSDK = ( '150x150': input.artwork._150x150, '480x480': input.artwork._480x480, '1000x1000': input.artwork._1000x1000, - mirrors: input.artwork.mirrors + mirrors: (input.artwork as { mirrors?: string[] }).mirrors ?? [] } : {}, variant: Variant.USER_GENERATED, @@ -98,11 +105,11 @@ export const userCollectionMetadataFromSDK = ( ? coverArtSizesCIDsFromSDK(input.coverArtCids) : null, followee_reposts: transformAndCleanList( - input.followeeReposts, + 'followeeReposts' in input ? (input.followeeReposts ?? []) : [], repostFromSDK ), followee_saves: transformAndCleanList( - input.followeeFavorites, + 'followeeFavorites' in input ? (input.followeeFavorites ?? []) : [], favoriteFromSDK ), playlist_contents: { @@ -111,21 +118,30 @@ export const userCollectionMetadataFromSDK = ( addedTimestampToPlaylistTrackId ) }, - producer_copyright_line: input.producerCopyrightLine - ? (snakecaseKeys(input.producerCopyrightLine) as Copyright) - : null, - stream_conditions: input.streamConditions - ? accessConditionsFromSDK(input.streamConditions) - : null, - tracks: transformAndCleanList(input.tracks, userTrackMetadataFromSDK), + producer_copyright_line: + 'producerCopyrightLine' in input && input.producerCopyrightLine + ? (snakecaseKeys(input.producerCopyrightLine) as Copyright) + : null, + stream_conditions: + 'streamConditions' in input && input.streamConditions + ? accessConditionsFromSDK(input.streamConditions) + : null, + tracks: transformAndCleanList( + ('tracks' in input ? (input.tracks ?? []) : []) as unknown as ( + | full.TrackFull + | full.SearchTrackFull + )[], + userTrackMetadataFromSDK + ), user, // Retypes / Renames save_count: input.favoriteCount, // Nullable fields - cover_art: input.coverArt ?? null, - cover_art_sizes: input.coverArtSizes ?? null, + cover_art: 'coverArt' in input ? (input.coverArt ?? null) : null, + cover_art_sizes: + 'coverArtSizes' in input ? (input.coverArtSizes ?? null) : null, description: input.description ?? null } @@ -159,7 +175,7 @@ export const accountCollectionFromSDK = ( export const playlistMetadataForCreateWithSDK = ( input: Collection | PlaylistValues -): CreatePlaylistMetadata => { +): CreatePlaylistRequestBody => { return { playlistName: input.playlist_name ?? '', description: input.description ?? '', @@ -171,7 +187,7 @@ export const playlistMetadataForCreateWithSDK = ( artists: input.artists ?? null, copyrightLine: input.copyright_line ?? null, producerCopyrightLine: input.producer_copyright_line ?? null, - parentalWarningType: input.parental_warning_type ?? null, + parentalWarningType: input.parental_warning_type ?? undefined, ...('cover_art_sizes' in input ? { coverArtCid: input.cover_art_sizes ?? '', @@ -183,7 +199,7 @@ export const playlistMetadataForCreateWithSDK = ( export const playlistMetadataForUpdateWithSDK = ( input: Collection -): UpdatePlaylistRequest['metadata'] => { +): UpdatePlaylistRequestBody => { return { ...playlistMetadataForCreateWithSDK(input), playlistContents: input.playlist_contents @@ -202,13 +218,12 @@ export const playlistMetadataForUpdateWithSDK = ( export const albumMetadataForCreateWithSDK = ( input: Collection | AlbumValues -): CreateAlbumMetadata => { +): CreateAlbumRequestBody => { 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, @@ -229,7 +244,7 @@ export const albumMetadataForCreateWithSDK = ( export const albumMetadataForUpdateWithSDK = ( input: Collection -): UpdateAlbumRequest['metadata'] => { +): UpdateAlbumRequestBody => { return { ...albumMetadataForCreateWithSDK(input), playlistContents: input.playlist_contents diff --git a/packages/common/src/adapters/track.ts b/packages/common/src/adapters/track.ts index ea2b58a84b5..6cca2f80b0f 100644 --- a/packages/common/src/adapters/track.ts +++ b/packages/common/src/adapters/track.ts @@ -1,9 +1,10 @@ import { type full, type CrossPlatformFile, - type Genre, - type Mood, + Genre, + Mood, type NativeFile, + type TrackMetadata, HashId, Id, OptionalHashId, @@ -34,6 +35,27 @@ import { repostFromSDK } from './repost' import { userMetadataFromSDK } from './user' import { transformAndCleanList } from './utils' +const VALID_GENRES = new Set(Object.values(Genre)) +const VALID_MOODS = new Set(Object.values(Mood)) + +function toSdkGenre( + value: string | undefined | '' +): (typeof Genre)[keyof typeof Genre] | undefined { + if (value === undefined || value === '') return undefined + return VALID_GENRES.has(value) + ? (value as (typeof Genre)[keyof typeof Genre]) + : undefined +} + +function toSdkMood( + value: string | null | undefined +): (typeof Mood)[keyof typeof Mood] | null | undefined { + if (value === undefined || value === null || value === '') return undefined + return VALID_MOODS.has(value) + ? (value as (typeof Mood)[keyof typeof Mood]) + : undefined +} + export const trackSegmentFromSDK = ({ duration, multihash @@ -234,92 +256,100 @@ export const stemTrackMetadataFromSDK = ( } } -export const trackMetadataForUploadToSdk = (input: TrackMetadataForUpload) => ({ - ...camelcaseKeys( - pick(input, [ - 'license', - 'isrc', - 'iswc', - 'is_unlisted', - 'is_premium', - 'premium_conditions', - 'is_stream_gated', - 'stream_conditions', - 'is_download_gated', - 'is_downloadable', - 'is_original_available', - 'is_scheduled_release', - 'bpm', - 'is_custom_bpm', - 'is_custom_musical_key', - 'comments_disabled', - 'ddex_release_ids', - 'parental_warning_type' - ]) - ), - trackId: OptionalId.parse(input.track_id), - title: input.title, - description: squashNewLines(input.description) ?? undefined, - mood: input.mood as Mood, - tags: input.tags ?? undefined, - genre: (input.genre as Genre) || undefined, - releaseDate: input.release_date ? new Date(input.release_date) : undefined, - previewStartSeconds: input.preview_start_seconds ?? undefined, - previewCid: input.preview_cid ?? '', - ddexApp: input.ddex_app ?? '', - audioUploadId: input.audio_upload_id ?? undefined, - duration: input.duration ?? undefined, - musicalKey: input.musical_key - ? formatMusicalKey(input.musical_key) - : undefined, - trackCid: input.track_cid ?? '', - origFileCid: input.orig_file_cid ?? '', - origFilename: input.orig_filename ?? undefined, - fieldVisibility: input.field_visibility - ? mapValues( - camelcaseKeys(input.field_visibility), - (value: Maybe) => (value === null ? undefined : value) - ) - : undefined, - downloadConditions: input.download_conditions - ? accessConditionsToSDK(input.download_conditions) - : null, - streamConditions: input.stream_conditions - ? accessConditionsToSDK(input.stream_conditions) - : null, - remixOf: input.remix_of - ? { - tracks: input.remix_of.tracks.map((track) => ({ - parentTrackId: Id.parse(track.parent_track_id) - })) - } - : undefined, - stemOf: input.stem_of - ? { - category: input.stem_of.category, - parentTrackId: Id.parse(input.stem_of.parent_track_id) - } - : undefined, - copyrightLine: input.copyright_line - ? camelcaseKeys(input.copyright_line) - : undefined, - producerCopyrightLine: input.producer_copyright_line - ? camelcaseKeys(input.producer_copyright_line) - : undefined, - rightsController: input.rights_controller - ? camelcaseKeys(input.rights_controller) - : undefined, - resourceContributors: input.resource_contributors - ? input.resource_contributors.map((contributor) => - camelcaseKeys(contributor) - ) - : undefined, - indirectResourceContributors: input.indirect_resource_contributors - ? input.indirect_resource_contributors.map((contributor) => - camelcaseKeys(contributor) - ) - : undefined -}) +const DEFAULT_GENRE = Genre.Electronic + +export const trackMetadataForUploadToSdk = ( + input: TrackMetadataForUpload +): TrackMetadata => { + const sdkGenre = toSdkGenre(input.genre) + const genre = sdkGenre ?? DEFAULT_GENRE + return { + ...camelcaseKeys( + pick(input, [ + 'license', + 'isrc', + 'iswc', + 'is_unlisted', + 'is_premium', + 'premium_conditions', + 'is_stream_gated', + 'stream_conditions', + 'is_download_gated', + 'is_downloadable', + 'is_original_available', + 'is_scheduled_release', + 'bpm', + 'is_custom_bpm', + 'is_custom_musical_key', + 'comments_disabled', + 'ddex_release_ids', + 'parental_warning_type' + ]) + ), + trackId: OptionalId.parse(input.track_id), + title: input.title, + description: squashNewLines(input.description) ?? undefined, + mood: toSdkMood(input.mood), + tags: input.tags ?? undefined, + genre, + releaseDate: input.release_date ? new Date(input.release_date) : undefined, + previewStartSeconds: input.preview_start_seconds ?? undefined, + previewCid: input.preview_cid ?? '', + ddexApp: input.ddex_app ?? '', + audioUploadId: input.audio_upload_id ?? undefined, + duration: input.duration ?? undefined, + musicalKey: input.musical_key + ? formatMusicalKey(input.musical_key) + : undefined, + trackCid: input.track_cid ?? '', + origFileCid: input.orig_file_cid ?? '', + origFilename: input.orig_filename ?? undefined, + fieldVisibility: input.field_visibility + ? mapValues( + camelcaseKeys(input.field_visibility), + (value: Maybe) => (value === null ? undefined : value) + ) + : undefined, + downloadConditions: input.download_conditions + ? accessConditionsToSDK(input.download_conditions) + : null, + streamConditions: input.stream_conditions + ? accessConditionsToSDK(input.stream_conditions) + : null, + remixOf: input.remix_of + ? { + tracks: input.remix_of.tracks.map((track) => ({ + parentTrackId: Id.parse(track.parent_track_id) + })) + } + : undefined, + stemOf: input.stem_of + ? { + category: input.stem_of.category, + parentTrackId: Id.parse(input.stem_of.parent_track_id) + } + : undefined, + copyrightLine: input.copyright_line + ? camelcaseKeys(input.copyright_line) + : undefined, + producerCopyrightLine: input.producer_copyright_line + ? camelcaseKeys(input.producer_copyright_line) + : undefined, + rightsController: input.rights_controller + ? camelcaseKeys(input.rights_controller) + : undefined, + resourceContributors: input.resource_contributors + ? input.resource_contributors.map((contributor) => + camelcaseKeys(contributor) + ) + : undefined, + indirectResourceContributors: input.indirect_resource_contributors + ? input.indirect_resource_contributors.map((contributor) => + camelcaseKeys(contributor) + ) + : undefined + } as TrackMetadata +} export const fileToSdk = ( file: Blob | File | NativeFile, diff --git a/packages/common/src/adapters/user.ts b/packages/common/src/adapters/user.ts index 8cd12de160b..502c1ef9ed7 100644 --- a/packages/common/src/adapters/user.ts +++ b/packages/common/src/adapters/user.ts @@ -1,14 +1,16 @@ import { HashId, OptionalHashId, - OptionalId, type full, - type UpdateProfileRequest + type UserPlaylistLibrary, + Id, + type UpdateUserRequestBody } from '@audius/sdk' import camelcaseKeys from 'camelcase-keys' import { omit, pick } from 'lodash' import snakecaseKeys from 'snakecase-keys' +import type { PlaylistLibraryItem } from '~/models' import { AccountUserMetadata, ManagedUserMetadata, @@ -164,9 +166,33 @@ export const accountFromSDK = ( } } +function mapLibraryContentsToSdkFormat( + libraryItems: PlaylistLibraryItem[] +): UserPlaylistLibrary['contents'] { + const items: UserPlaylistLibrary['contents'] = [] + for (const item of libraryItems) { + if (item.type === 'folder') { + const folder = { + id: item.id, + type: 'folder' as const, + name: item.name, + contents: mapLibraryContentsToSdkFormat(item.contents) + } + items.push(folder) + } + if (item.type === 'playlist') { + items.push({ + playlistId: item.playlist_id, + type: 'playlist' as const + }) + } + } + return items +} + export const userMetadataToSdk = ( input: WriteableUserMetadata & Pick -): UpdateProfileRequest['metadata'] => ({ +): UpdateUserRequestBody => ({ ...camelcaseKeys( pick(input, [ 'name', @@ -179,14 +205,22 @@ 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 + ? Id.parse(input.artist_pick_track_id) + : undefined, events: { - referrer: OptionalId.parse(input.events?.referrer ?? undefined), + referrer: input.events?.referrer + ? Id.parse(input.events.referrer) + : undefined, isMobileUser: input.events?.is_mobile_user ?? undefined }, location: input.location ?? undefined, twitterHandle: input.twitter_handle ?? undefined, instagramHandle: input.instagram_handle ?? undefined, - playlistLibrary: input.playlist_library ?? undefined, + playlistLibrary: input.playlist_library + ? { + contents: mapLibraryContentsToSdkFormat(input.playlist_library.contents) + } + : undefined, tiktokHandle: input.tiktok_handle ?? undefined }) 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/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/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..b59c8acd111 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,25 @@ 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, + entityType: 'Track' + } + }) + } else { + return await sdk.comments.unpinComment({ + userId: Id.parse(userId)!, + commentId: Id.parse(commentId)!, + metadata: { + entityId: trackId, + entityType: 'Track' + } + }) + } }, 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/common/src/api/tan-query/developer-apps/useAddDeveloperApp.ts b/packages/common/src/api/tan-query/developer-apps/useAddDeveloperApp.ts index 210c7bef9ee..d36b99a16bf 100644 --- a/packages/common/src/api/tan-query/developer-apps/useAddDeveloperApp.ts +++ b/packages/common/src/api/tan-query/developer-apps/useAddDeveloperApp.ts @@ -22,25 +22,40 @@ export const useAddDeveloperApp = () => { const encodedUserId = Id.parse(currentUserId) const sdk = await audiusSdk() - const { apiKey, apiSecret } = await sdk.developerApps.createDeveloperApp({ - name, - description, - imageUrl, + const result = await sdk.developerApps.createDeveloperApp({ + metadata: { + name, + description, + imageUrl + }, userId: encodedUserId }) + const { apiKey, apiSecret } = result + const bearerToken = + 'bearerToken' in result && typeof result.bearerToken === 'string' + ? result.bearerToken + : undefined + + if (!apiKey || !apiSecret) { + throw new Error('Failed to create developer app') + } await sdk.grants.createGrant({ userId: encodedUserId, appApiKey: apiKey }) - return { name, description, imageUrl, apiKey, apiSecret } + return { name, description, imageUrl, apiKey, apiSecret, bearerToken } }, onSuccess: (newApp: DeveloperApp) => { if (!currentUserId) { throw new Error('No current user ID') } - const { apiSecret: apiSecretIgnored, ...restNewApp } = newApp + const { + apiSecret: apiSecretIgnored, + bearerToken: bearerTokenIgnored, + ...restNewApp + } = newApp queryClient.setQueryData( getDeveloperAppsQueryKey(currentUserId), diff --git a/packages/common/src/api/tan-query/developer-apps/useDeleteDeveloperApp.ts b/packages/common/src/api/tan-query/developer-apps/useDeleteDeveloperApp.ts index 5a55c5fc9ee..e82a50fb7b7 100644 --- a/packages/common/src/api/tan-query/developer-apps/useDeleteDeveloperApp.ts +++ b/packages/common/src/api/tan-query/developer-apps/useDeleteDeveloperApp.ts @@ -22,7 +22,7 @@ export const useDeleteDeveloperApp = () => { await sdk.developerApps.deleteDeveloperApp({ userId: Id.parse(currentUserId), - appApiKey: apiKey + address: apiKey }) return {} }, diff --git a/packages/common/src/api/tan-query/developer-apps/useDeveloperApps.ts b/packages/common/src/api/tan-query/developer-apps/useDeveloperApps.ts index d7454f5b7ac..55f0994067a 100644 --- a/packages/common/src/api/tan-query/developer-apps/useDeveloperApps.ts +++ b/packages/common/src/api/tan-query/developer-apps/useDeveloperApps.ts @@ -25,7 +25,7 @@ export const useDeveloperApps = ( queryKey: getDeveloperAppsQueryKey(userId), queryFn: async () => { const sdk = await audiusSdk() - const { data = [] } = await sdk.users.getDeveloperApps({ + const { data = [] } = await sdk.developerApps.getDeveloperApps({ id: Id.parse(userId) }) diff --git a/packages/common/src/api/tan-query/developer-apps/useEditDeveloperApp.ts b/packages/common/src/api/tan-query/developer-apps/useEditDeveloperApp.ts index fee41094030..623bb9a8cca 100644 --- a/packages/common/src/api/tan-query/developer-apps/useEditDeveloperApp.ts +++ b/packages/common/src/api/tan-query/developer-apps/useEditDeveloperApp.ts @@ -22,10 +22,12 @@ export const useEditDeveloperApp = () => { const sdk = await audiusSdk() await sdk.developerApps.updateDeveloperApp({ - appApiKey: apiKey, - name, - description, - imageUrl, + address: apiKey, + metadata: { + name, + description, + imageUrl + }, userId: Id.parse(currentUserId) }) diff --git a/packages/common/src/api/tan-query/tracks/useUpdateTrack.ts b/packages/common/src/api/tan-query/tracks/useUpdateTrack.ts index a0dd5669bac..600304081ab 100644 --- a/packages/common/src/api/tan-query/tracks/useUpdateTrack.ts +++ b/packages/common/src/api/tan-query/tracks/useUpdateTrack.ts @@ -1,4 +1,8 @@ -import { Id, type CrossPlatformFile } from '@audius/sdk' +import { + type UpdateTrackRequestBody, + Id, + type CrossPlatformFile +} from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' import { useDispatch, useStore } from 'react-redux' @@ -63,7 +67,7 @@ export const useUpdateTrack = () => { imageFile, trackId: Id.parse(trackId), userId: Id.parse(userId), - metadata: sdkMetadata, + metadata: sdkMetadata as UpdateTrackRequestBody, onProgress: (_, progress) => { if (progress.key === 'audio') { dispatch( diff --git a/packages/common/src/api/tan-query/upload/usePublishCollection.ts b/packages/common/src/api/tan-query/upload/usePublishCollection.ts index 1428b9c2da7..a3d63e98ad3 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 @@ -105,22 +105,30 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) => ? fileToSdk(artworkBlob, 'cover_art') : undefined if (params.collectionMetadata.is_album) { + const metadata = albumMetadataForCreateWithSDK( + params.collectionMetadata + ) + metadata.playlistContents = publishedTracks.map((t) => ({ + timestamp: Date.now() / 1000, + trackId: Id.parse(t.trackId) + })) return await sdk.albums.createAlbum({ userId: Id.parse(userId), imageFile: coverArtFile, - metadata: albumMetadataForCreateWithSDK(params.collectionMetadata), - trackIds: publishedTracks - .filter((t) => t.trackId && !t.error) - .map((t) => t.trackId!) + metadata }) } else { + const metadata = playlistMetadataForCreateWithSDK( + params.collectionMetadata + ) + metadata.playlistContents = publishedTracks.map((t) => ({ + timestamp: Date.now() / 1000, + trackId: Id.parse(t.trackId) + })) return await sdk.playlists.createPlaylist({ userId: Id.parse(userId), imageFile: coverArtFile, - metadata: playlistMetadataForCreateWithSDK(params.collectionMetadata), - trackIds: publishedTracks - .filter((t) => t.trackId && !t.error) - .map((t) => t.trackId!) + metadata }) } } @@ -249,14 +257,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/usePublishStems.ts b/packages/common/src/api/tan-query/upload/usePublishStems.ts index 56439c46b4f..7437cacad5e 100644 --- a/packages/common/src/api/tan-query/upload/usePublishStems.ts +++ b/packages/common/src/api/tan-query/upload/usePublishStems.ts @@ -1,13 +1,9 @@ import { HashId, Id, type UploadResponse } from '@audius/sdk' import { useMutation, useQueryClient } from '@tanstack/react-query' -import { - StemCategory, - Name, - type StemUpload, - type TrackMetadata -} from '~/models' +import { StemCategory, Name, type StemUpload } from '~/models' import { ProgressStatus, uploadActions } from '~/store' +import type { TrackMetadataForUpload } from '~/store/upload/types' import { getStemsQueryKey } from '../tracks/useStems' import { useCurrentUserId } from '../users/account/useCurrentUserId' @@ -27,7 +23,7 @@ type PublishStemsContext = Pick< type PublishStemsParams = { clientId: string parentTrackId: number - parentMetadata: Omit + parentMetadata: TrackMetadataForUpload stems: { metadata: StemUpload audioUploadResponse: UploadResponse diff --git a/packages/common/src/api/tan-query/upload/usePublishTracks.ts b/packages/common/src/api/tan-query/upload/usePublishTracks.ts index 0a260dc0774..77b1a634e42 100644 --- a/packages/common/src/api/tan-query/upload/usePublishTracks.ts +++ b/packages/common/src/api/tan-query/upload/usePublishTracks.ts @@ -81,7 +81,9 @@ export const publishTracks = async ( try { const res = await sdk.tracks.publishTrack({ userId: Id.parse(userId), - metadata: camelMetadata, + metadata: camelMetadata as Parameters< + typeof sdk.tracks.publishTrack + >[0]['metadata'], audioUploadResponse: param.audioUploadResponse, imageUploadResponse: param.imageUploadResponse }) @@ -230,25 +232,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/api/tan-query/upload/useUpload.ts b/packages/common/src/api/tan-query/upload/useUpload.ts index 6e3927b8126..a05e5ddedc1 100644 --- a/packages/common/src/api/tan-query/upload/useUpload.ts +++ b/packages/common/src/api/tan-query/upload/useUpload.ts @@ -200,7 +200,7 @@ export const useUpload = ( ? (t.metadata.artwork.source as 'unsplash' | 'original') : 'original', trackId: t.metadata.track_id!, - genre: t.metadata.genre, + genre: t.metadata.genre ?? '', mood: t.metadata.mood ?? undefined, size: t.file.size ?? -1, fileType: t.file.type ?? '', diff --git a/packages/common/src/api/tan-query/users/useUpdateProfile.ts b/packages/common/src/api/tan-query/users/useUpdateProfile.ts index df0ebef56c3..29bdee0d88c 100644 --- a/packages/common/src/api/tan-query/users/useUpdateProfile.ts +++ b/packages/common/src/api/tan-query/users/useUpdateProfile.ts @@ -44,25 +44,14 @@ export const useUpdateProfile = () => { } } - const { blockHash, blockNumber } = await sdk.users.updateProfile({ + await sdk.users.updateUser({ + id: Id.parse(currentUserId), userId: Id.parse(currentUserId), profilePictureFile: metadata.updatedProfilePicture?.file, coverArtFile: metadata.updatedCoverPhoto?.file, metadata: userMetadataToSdk(metadata) }) - // Wait for transaction confirmation - const confirmed = await sdk.services.entityManager.confirmWrite({ - blockHash, - blockNumber - }) - - if (!confirmed) { - throw new Error( - `Could not confirm update profile for user id ${currentUserId}` - ) - } - // Fetch updated user data const { data: userData = [] } = await sdk.full.users.getUser({ id: Id.parse(currentUserId), diff --git a/packages/common/src/api/tan-query/users/useUpdateUser.ts b/packages/common/src/api/tan-query/users/useUpdateUser.ts index b9a7c2bb1e4..b66803867e9 100644 --- a/packages/common/src/api/tan-query/users/useUpdateUser.ts +++ b/packages/common/src/api/tan-query/users/useUpdateUser.ts @@ -95,10 +95,11 @@ export async function updateUser( const sdkMetadata = userMetadataToSdk(metadata as UserMetadata) - const response = await sdk.users.updateProfile({ + const response = await sdk.users.updateUser({ coverArtFile, profilePictureFile, userId: encodedUserId, + id: encodedUserId, metadata: sdkMetadata }) diff --git a/packages/common/src/hooks/useTrackMetadata.ts b/packages/common/src/hooks/useTrackMetadata.ts index 78ae4b18cb9..c96b62d4fd3 100644 --- a/packages/common/src/hooks/useTrackMetadata.ts +++ b/packages/common/src/hooks/useTrackMetadata.ts @@ -81,13 +81,13 @@ export const useTrackMetadata = ({ { id: TrackMetadataType.GENRE, label: 'Genre', - value: getCanonicalName(genre), + value: genre ? getCanonicalName(genre) : '', url: searchPage({ category: 'tracks', genre: genre as Genre }) }, { id: TrackMetadataType.MOOD, label: 'Mood', - value: mood, + value: mood ?? '', url: searchPage({ category: 'tracks', mood: mood as Mood }) }, { @@ -111,9 +111,9 @@ export const useTrackMetadata = ({ { id: TrackMetadataType.DURATION, label: 'Duration', - value: formatSecondsAsText(duration) + value: formatSecondsAsText(duration ?? 0) } ].filter(({ isHidden, value }) => !isHidden && !!value) - return labels + return labels as TrackMetadataInfo[] } 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/developerApps.ts b/packages/common/src/schemas/developerApps.ts index 6976c8dda46..b0b045ffc74 100644 --- a/packages/common/src/schemas/developerApps.ts +++ b/packages/common/src/schemas/developerApps.ts @@ -15,6 +15,7 @@ export type DeveloperApp = { imageUrl?: string apiKey: string apiSecret?: string + bearerToken?: string } export const developerAppSchema = z.object({ 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 a6e249cba62..3d52f6cd64d 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() @@ -55,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/services/audius-backend/AudiusBackend.ts b/packages/common/src/services/audius-backend/AudiusBackend.ts index 037a1cd2cd8..3c018951be4 100644 --- a/packages/common/src/services/audius-backend/AudiusBackend.ts +++ b/packages/common/src/services/audius-backend/AudiusBackend.ts @@ -195,13 +195,14 @@ export const audiusBackend = ({ try { newMetadata = schemas.newUserMetadata(newMetadata, true) const userId = newMetadata.user_id - const { blockHash, blockNumber } = await sdk.users.updateProfile({ + await sdk.users.updateUser({ + id: Id.parse(userId), userId: Id.parse(userId), profilePictureFile: metadata.updatedProfilePicture?.file, coverArtFile: metadata.updatedCoverPhoto?.file, metadata: userMetadataToSdk(newMetadata) }) - return { blockHash, blockNumber, userId } + return { userId } } catch (err) { console.error(getErrorMessage(err)) throw err diff --git a/packages/common/src/store/pages/trending/reducer.ts b/packages/common/src/store/pages/trending/reducer.ts index 2a2b6e831c7..4396e80e4db 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 { parseTrendingGenreFromUrl } from '~/utils/genres' import { TimeRange, Track } from '../../../models' @@ -94,7 +94,7 @@ const reducer = if (history) { const urlParams = new URLSearchParams(history.location.search) - const genre = urlParams.get('genre') as Genre | null + const genreParam = urlParams.get('genre') const timeRange = urlParams.get('timeRange') as TimeRange | null return { ...initialState, @@ -102,8 +102,7 @@ const reducer = timeRange && Object.values(TimeRange).includes(timeRange) ? timeRange : TimeRange.WEEK, - trendingGenre: - genre && Object.values(GENRES).includes(genre) ? genre : null + trendingGenre: parseTrendingGenreFromUrl(genreParam) } } diff --git a/packages/common/src/store/upload/types.ts b/packages/common/src/store/upload/types.ts index b73f71d8755..4fbda8899ad 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,14 @@ 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. + * mood accepts string so that Track/TQTrack metadata (Nullable) is assignable. */ export interface TrackMetadataForUpload - extends Omit { + extends Omit { + /** API tracks use genre: string; form empty state is ''. */ + genre?: Genre | '' | string + mood?: Mood | string | null artwork?: | Nullable<{ file?: Blob | NativeFile diff --git a/packages/common/src/utils/genres.ts b/packages/common/src/utils/genres.ts index d55ba9c7b4f..5e779f12a0a 100644 --- a/packages/common/src/utils/genres.ts +++ b/packages/common/src/utils/genres.ts @@ -1,132 +1,115 @@ -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 type GenreLabel = (typeof GENRES)[number] + +export const convertGenreLabelToValue = (genreLabel: GenreLabel): SDKGenre => { + return genreLabel.replace(ELECTRONIC_PREFIX, '') as SDKGenre +} + +/** + * Converts a string from the trending genre UI (e.g. from URL or genre list) + * into Genre | null for Redux state. Returns null for null, empty, or ALL_GENRES. + */ +export const parseTrendingGenreFromUrl = ( + param: string | null +): SDKGenre | null => { + if (param === null || param === '' || param === ALL_GENRES) return null + const genresList = GENRES as readonly string[] + if (!genresList.includes(param)) return null + const trimmed = param.startsWith(ELECTRONIC_PREFIX) + ? param.slice(ELECTRONIC_PREFIX.length) + : param + return trimmed as SDKGenre +} -export const convertGenreLabelToValue = ( - genreLabel: (typeof GENRES)[number] -) => { - return genreLabel.replace(ELECTRONIC_PREFIX, '') +/** + * Converts a genre string from UI (e.g. from GenreSelectionList) to Genre | null + * for setTrendingGenre. Use when the value is known to come from GENRES. + */ +export const toTrendingGenre = (value: string | null): SDKGenre | null => { + if (value === null || value === '' || value === ALL_GENRES) return null + const genresList = GENRES as readonly string[] + if (!genresList.includes(value)) return null + return convertGenreLabelToValue(value as GenreLabel) } const NEWLY_ADDED_GENRES: string[] = [] diff --git a/packages/common/src/utils/isLongFormContent.ts b/packages/common/src/utils/isLongFormContent.ts index 5e3764b1049..84140d0fe64 100644 --- a/packages/common/src/utils/isLongFormContent.ts +++ b/packages/common/src/utils/isLongFormContent.ts @@ -5,4 +5,4 @@ import { Maybe } from './typeUtils' export const isLongFormContent = ( track: Maybe | null> -) => track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS +) => track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks diff --git a/packages/common/src/utils/quickSearch.ts b/packages/common/src/utils/quickSearch.ts index 11658d17a63..f11c416bcc4 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 }, - { 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 }, + { mood: Mood.Fiery, bpm: bpmDescriptions.UPBEAT }, + { 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/common/src/utils/route.ts b/packages/common/src/utils/route.ts index 632ab9dfacd..c2ca6b6bd7f 100644 --- a/packages/common/src/utils/route.ts +++ b/packages/common/src/utils/route.ts @@ -3,7 +3,7 @@ import qs from 'query-string' import { ID, SearchCategory, SearchFilters } from '~/models' import { encodeUrlName, formatTickerForUrl } from './formatUtil' -import { convertGenreLabelToValue, Genre } from './genres' +import { convertGenreLabelToValue, type GenreLabel } from './genres' // External Routes export const PRIVACY_POLICY = '/legal/privacy-policy' @@ -441,7 +441,9 @@ export const searchPage = (searchOptions: SearchOptions) => { const { category, ...searchParams } = searchOptions if (searchParams.genre) { - searchParams.genre = convertGenreLabelToValue(searchParams.genre) as Genre + searchParams.genre = convertGenreLabelToValue( + searchParams.genre as GenreLabel + ) } // Build the search path - category is optional diff --git a/packages/discovery-provider/plugins/pedalboard/apps/relay/src/scripts/sandbox.ts b/packages/discovery-provider/plugins/pedalboard/apps/relay/src/scripts/sandbox.ts index aab871b79d2..ca481f15bfa 100644 --- a/packages/discovery-provider/plugins/pedalboard/apps/relay/src/scripts/sandbox.ts +++ b/packages/discovery-provider/plugins/pedalboard/apps/relay/src/scripts/sandbox.ts @@ -27,7 +27,8 @@ export const main = async () => { handle: 'totallynotalec' }) const userId = data?.id! - const res = await audiusSdk.users.updateProfile({ + const res = await audiusSdk.users.updateUser({ + id: userId, userId, metadata: { bio: `identity has no reigns on me ${new Date().getTime()}` diff --git a/packages/discovery-provider/plugins/pedalboard/apps/trending-challenge-rewards/src/rewards.ts b/packages/discovery-provider/plugins/pedalboard/apps/trending-challenge-rewards/src/rewards.ts index a18f22404bf..4075f2db8d4 100644 --- a/packages/discovery-provider/plugins/pedalboard/apps/trending-challenge-rewards/src/rewards.ts +++ b/packages/discovery-provider/plugins/pedalboard/apps/trending-challenge-rewards/src/rewards.ts @@ -113,7 +113,7 @@ export const onDisburse = async ( challenge.amount ) res = await sdk.rewards.claimRewards({ - claimRewardsRequest: { + reward: { challengeId, userId: challenge.user_id, specifier: challenge.specifier diff --git a/packages/mobile/src/components/audio/AudioPlayer.tsx b/packages/mobile/src/components/audio/AudioPlayer.tsx index cd913ffb736..515c3284b69 100644 --- a/packages/mobile/src/components/audio/AudioPlayer.tsx +++ b/packages/mobile/src/components/audio/AudioPlayer.tsx @@ -489,8 +489,8 @@ export const AudioPlayer = () => { }) const isLongFormContent = - track?.genre === Genre.PODCASTS || - track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || + track?.genre === Genre.Audiobooks const trackPosition = trackPositions?.[track.track_id] if (trackPosition?.status === 'IN_PROGRESS') { dispatch( @@ -513,8 +513,8 @@ export const AudioPlayer = () => { } const isLongFormContent = - queueTracks[playerIndex]?.track?.genre === Genre.PODCASTS || - queueTracks[playerIndex]?.track?.genre === Genre.AUDIOBOOKS + queueTracks[playerIndex]?.track?.genre === Genre.Podcasts || + queueTracks[playerIndex]?.track?.genre === Genre.Audiobooks // Always set the correct playback rate when the active track changes const newRate = isLongFormContent @@ -532,7 +532,7 @@ export const AudioPlayer = () => { if (event?.lastPosition !== undefined && event?.index !== undefined) { const { track } = queueTracks[event.index] ?? {} const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks const isAtEndOfTrack = track?.duration && event.lastPosition >= track.duration - TRACK_END_BUFFER diff --git a/packages/mobile/src/components/lineup-tile/TrackTile.tsx b/packages/mobile/src/components/lineup-tile/TrackTile.tsx index b82251f904f..49f66b42ca8 100644 --- a/packages/mobile/src/components/lineup-tile/TrackTile.tsx +++ b/packages/mobile/src/components/lineup-tile/TrackTile.tsx @@ -194,7 +194,7 @@ const TrackTileComponent = (props: TrackTileProps) => { const handlePressOverflow = useCallback(() => { if (!track) return const isLongFormContent = - track.genre === Genre.PODCASTS || track.genre === Genre.AUDIOBOOKS + track.genre === Genre.Podcasts || track.genre === Genre.Audiobooks const isOwner = currentUserId === track.owner_id const isArtistPick = isOwner && user?.artist_pick_track_id === track.track_id @@ -303,7 +303,7 @@ const TrackTileComponent = (props: TrackTileProps) => { trackId={track.track_id} duration={track.duration} isLongFormContent={ - track.genre === Genre.PODCASTS || track.genre === Genre.AUDIOBOOKS + track.genre === Genre.Podcasts || track.genre === Genre.Audiobooks } isArtistPick={showArtistPick && isArtistPick} /> diff --git a/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx b/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx index e0e7901b4c7..1c4ee617937 100644 --- a/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx +++ b/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx @@ -183,7 +183,7 @@ export const ActionsBar = ({ track }: ActionsBarProps) => { const onPressOverflow = useCallback(() => { if (track) { const isLongFormContent = - track.genre === Genre.PODCASTS || track.genre === Genre.AUDIOBOOKS + track.genre === Genre.Podcasts || track.genre === Genre.Audiobooks const overflowActions = [ OverflowAction.VIEW_COMMENTS, OverflowAction.SHARE, 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/components/now-playing-drawer/TrackingBar.tsx b/packages/mobile/src/components/now-playing-drawer/TrackingBar.tsx index 6b5a2cb926b..26c21ca3849 100644 --- a/packages/mobile/src/components/now-playing-drawer/TrackingBar.tsx +++ b/packages/mobile/src/components/now-playing-drawer/TrackingBar.tsx @@ -68,7 +68,7 @@ export const TrackingBar = (props: TrackingBarProps) => { // Calculate the actual playback rate based on track type const isLongFormContent = - trackGenre === Genre.PODCASTS || trackGenre === Genre.AUDIOBOOKS + trackGenre === Genre.Podcasts || trackGenre === Genre.Audiobooks const actualPlaybackRate = isLongFormContent ? playbackRateValueMap[playbackRate] : 1.0 diff --git a/packages/mobile/src/components/scrubber/Slider.tsx b/packages/mobile/src/components/scrubber/Slider.tsx index b5bde348c10..a5a52537a1e 100644 --- a/packages/mobile/src/components/scrubber/Slider.tsx +++ b/packages/mobile/src/components/scrubber/Slider.tsx @@ -161,7 +161,7 @@ export const Slider = memo(function Slider(props: SliderProps) { // Calculate the actual playback rate based on track type const isLongFormContent = - trackGenre === Genre.PODCASTS || trackGenre === Genre.AUDIOBOOKS + trackGenre === Genre.Podcasts || trackGenre === Genre.Audiobooks const actualPlaybackRate = isLongFormContent ? playbackRateValueMap[playbackRate] : 1.0 diff --git a/packages/mobile/src/components/scrubber/usePosition.ts b/packages/mobile/src/components/scrubber/usePosition.ts index 5f3f5ccffb2..2f30a67db3b 100644 --- a/packages/mobile/src/components/scrubber/usePosition.ts +++ b/packages/mobile/src/components/scrubber/usePosition.ts @@ -41,7 +41,7 @@ export const usePosition = ( // Calculate the actual playback rate based on track type const isLongFormContent = - trackGenre === Genre.PODCASTS || trackGenre === Genre.AUDIOBOOKS + trackGenre === Genre.Podcasts || trackGenre === Genre.Audiobooks const actualPlaybackRate = isLongFormContent ? playbackRateValueMap[playbackRate] : 1.0 diff --git a/packages/mobile/src/components/track-list/TrackListItem.tsx b/packages/mobile/src/components/track-list/TrackListItem.tsx index be048eb0766..5d906f08462 100644 --- a/packages/mobile/src/components/track-list/TrackListItem.tsx +++ b/packages/mobile/src/components/track-list/TrackListItem.tsx @@ -261,7 +261,7 @@ const TrackListItemComponent = (props: TrackListItemComponentProps) => { currentUserId && contextPlaylist?.playlist_owner_id === currentUserId const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks const playbackPositionInfo = useSelector((state) => getTrackPosition(state, { trackId: track_id, userId: currentUserId }) ) diff --git a/packages/mobile/src/screens/sign-on-screen/screens/SelectArtistScreen/SelectedGenresTabBar.tsx b/packages/mobile/src/screens/sign-on-screen/screens/SelectArtistScreen/SelectedGenresTabBar.tsx index 5e37a9798b5..058136db714 100644 --- a/packages/mobile/src/screens/sign-on-screen/screens/SelectArtistScreen/SelectedGenresTabBar.tsx +++ b/packages/mobile/src/screens/sign-on-screen/screens/SelectArtistScreen/SelectedGenresTabBar.tsx @@ -1,6 +1,6 @@ import { useCallback } from 'react' -import type { Genre } from '@audius/common/utils' +import type { GenreLabel } from '@audius/common/utils' import { convertGenreLabelToValue } from '@audius/common/utils' import { css } from '@emotion/native' import { ScrollView } from 'react-native' @@ -50,7 +50,7 @@ export const SelectedGenresTabBar = (props: SelectedGenresTabBarProps) => { { const { spacing } = useTheme() const { data: artists } = useGetTopArtists( - convertGenreLabelToValue(genre as Genre), + convertGenreLabelToValue(genre as GenreLabel), { enabled: isFocused } diff --git a/packages/mobile/src/screens/sign-on-screen/screens/SelectGenresScreen.tsx b/packages/mobile/src/screens/sign-on-screen/screens/SelectGenresScreen.tsx index 0f9e051b68b..2d1c517f7f5 100644 --- a/packages/mobile/src/screens/sign-on-screen/screens/SelectGenresScreen.tsx +++ b/packages/mobile/src/screens/sign-on-screen/screens/SelectGenresScreen.tsx @@ -23,9 +23,11 @@ import type { SignOnScreenParamList } from '../types' import { useTrackScreen } from '../utils/useTrackScreen' type Genre = (typeof GENRES)[number] -type SelectGenresValue = { genres: typeof GENRES } +type SelectGenresValue = { genres: Genre[] } -const initialValues: SelectGenresValue = { genres: [] } +const initialValues: SelectGenresValue = { + genres: [] as Genre[] +} /* Memoized SelectablePill to fix a performance issue. * The code below is arranged so that the pills don't need to re-render, diff --git a/packages/mobile/src/screens/track-screen/TrackScreenDetailsTile.tsx b/packages/mobile/src/screens/track-screen/TrackScreenDetailsTile.tsx index e433d4baf84..0cae222ae8b 100644 --- a/packages/mobile/src/screens/track-screen/TrackScreenDetailsTile.tsx +++ b/packages/mobile/src/screens/track-screen/TrackScreenDetailsTile.tsx @@ -227,7 +227,7 @@ export const TrackScreenDetailsTile = ({ const { open: openCommentDrawer } = useCommentDrawer() const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks const isUSDCPurchaseGated = isContentUSDCPurchaseGated(streamConditions) const { data: remixContest } = useRemixContest(trackId) const isRemixContest = !!remixContest @@ -433,7 +433,7 @@ export const TrackScreenDetailsTile = ({ const handlePressOverflow = () => { const isLongFormContent = - genre === Genre.PODCASTS || genre === Genre.AUDIOBOOKS + genre === Genre.Podcasts || genre === Genre.Audiobooks const addToAlbumAction = isOwner && !ddexApp ? OverflowAction.ADD_TO_ALBUM : null const overflowActions = [ 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/TrendingFilterDrawer.tsx b/packages/mobile/src/screens/trending-screen/TrendingFilterDrawer.tsx index 47a5072e53f..bb76501e1a5 100644 --- a/packages/mobile/src/screens/trending-screen/TrendingFilterDrawer.tsx +++ b/packages/mobile/src/screens/trending-screen/TrendingFilterDrawer.tsx @@ -6,10 +6,11 @@ import { trendingPageSelectors } from '@audius/common/store' import { - Genre, + type Genre, ELECTRONIC_PREFIX, ELECTRONIC_SUBGENRES, - GENRES + GENRES, + ALL_GENRES } from '@audius/common/utils' import { FlatList, Keyboard, View } from 'react-native' import { useDispatch, useSelector } from 'react-redux' @@ -31,7 +32,7 @@ const messages = { searchPlaceholder: 'Search Genres' } -const trendingGenres = [Genre.ALL, ...GENRES] +const trendingGenres = [ALL_GENRES, ...GENRES] const useStyles = makeStyles(({ spacing }) => ({ root: { @@ -49,7 +50,7 @@ const useStyles = makeStyles(({ spacing }) => ({ export const TrendingFilterDrawer = () => { const styles = useStyles() const [searchValue, setSearchValue] = useState('') - const trendingGenre = useSelector(getTrendingGenre) ?? Genre.ALL + const trendingGenre = useSelector(getTrendingGenre) ?? ALL_GENRES const { onClose } = useDrawerState(MODAL_NAME) const dispatch = useDispatch() @@ -63,7 +64,7 @@ export const TrendingFilterDrawer = () => { const handleSelect = useCallback( (genre: string) => { const trimmedGenre = - genre === Genre.ALL + genre === ALL_GENRES ? null : (genre.replace(ELECTRONIC_PREFIX, '') as Genre) diff --git a/packages/mobile/src/screens/trending-screen/TrendingGenrePill.tsx b/packages/mobile/src/screens/trending-screen/TrendingGenrePill.tsx index 424c455ebd1..ed078cc2aa3 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 } 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/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 a9d7d7b2768..bd0ea6d697c 100644 --- a/packages/sdk/src/sdk/api/albums/AlbumsApi.ts +++ b/packages/sdk/src/sdk/api/albums/AlbumsApi.ts @@ -7,10 +7,7 @@ import type { SolanaRelayService, StorageService } from '../../services' -import type { - EntityManagerService, - AdvancedOptions -} from '../../services/EntityManager/types' +import type { EntityManagerService } from '../../services/EntityManager/types' import type { LoggerService } from '../../services/Logger' import type { SolanaClient } from '../../services/Solana/programs/SolanaClient' import { parseParams } from '../../utils/parseParams' @@ -21,13 +18,9 @@ import { type Configuration } from '../generated/default' import { PlaylistsApi } from '../playlists/PlaylistsApi' -import { PlaylistMetadata } from '../playlists/types' +import type { UploadPlaylistRequest } from '../playlists/types' import { - DeleteAlbumRequest, - DeleteAlbumSchema, - FavoriteAlbumRequest, - FavoriteAlbumSchema, getAlbumRequest, getAlbumsRequest, getAlbumTracksRequest, @@ -35,18 +28,16 @@ import { GetPurchaseAlbumInstructionsSchema, PurchaseAlbumRequest, PurchaseAlbumSchema, - RepostAlbumRequest, - RepostAlbumSchema, - UnfavoriteAlbumRequest, - UnfavoriteAlbumSchema, - UnrepostAlbumRequest, - UnrepostAlbumSchema, - UpdateAlbumRequest, - UpdateAlbumSchema, UploadAlbumRequest, UploadAlbumSchema, - CreateAlbumRequest, - CreateAlbumSchema + CreateAlbumRequestWithFiles, + UpdateAlbumRequest, + DeleteAlbumRequest, + FavoriteAlbumRequest, + UnfavoriteAlbumRequest, + RepostAlbumRequest, + UnrepostAlbumRequest, + UpdateAlbumSchema } from './types' export class AlbumsApi { @@ -91,139 +82,92 @@ export class AlbumsApi { * Create an album from existing tracks */ async createAlbum( - params: CreateAlbumRequest, - advancedOptions?: AdvancedOptions + params: CreateAlbumRequestWithFiles, + requestInit?: RequestInit ) { - // Parse inputs - const { metadata, ...parsedParameters } = await parseParams( - 'createAlbum', - CreateAlbumSchema - )(params) - + 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 * Upload an album * Uploads the specified tracks and combines them into an album */ - async uploadAlbum( - params: UploadAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - const { metadata, ...parsedParameters } = await parseParams( - 'uploadAlbum', - UploadAlbumSchema - )(params) + async uploadAlbum(params: UploadAlbumRequest) { + await parseParams('uploadAlbum', UploadAlbumSchema)(params) - const { albumName, ...playlistMetadata } = metadata - - // Call uploadPlaylistInternal with parsed inputs - const response = await this.playlistsApi.uploadPlaylistInternal( - { - ...parsedParameters, - metadata: { - ...playlistMetadata, - playlistName: albumName, - isAlbum: true - } - }, - advancedOptions - ) + const { albumName, ...playlistMetadata } = params.metadata - return { - blockHash: response.blockHash, - blockNumber: response.blockNumber, - albumId: response.playlistId + const playlistParams: UploadPlaylistRequest = { + ...params, + metadata: { + ...playlistMetadata, + playlistName: albumName, + isAlbum: true + } } + + return await this.playlistsApi.uploadPlaylist(playlistParams) } /** @hidden * Update an album */ - async updateAlbum( - params: UpdateAlbumRequest, - advancedOptions?: AdvancedOptions - ) { - const { albumId, metadata, ...parsedParameters } = await parseParams( - 'updateAlbum', - UpdateAlbumSchema - )(params) + async updateAlbum(params: UpdateAlbumRequest, requestInit?: RequestInit) { + await parseParams('updateAlbum', UpdateAlbumSchema)(params) + const { metadata, albumId, ...rest } = params const { albumName, ...playlistMetadata } = metadata - // Call updatePlaylistInternal with parsed inputs - return await this.playlistsApi.updatePlaylistInternal( - { - ...parsedParameters, - playlistId: albumId, - metadata: { - ...playlistMetadata, - playlistName: albumName - } - }, - advancedOptions - ) + // 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, + metadata: params.metadata + } + return await this.playlistsApi.favoritePlaylist(playlistParams, requestInit) } /** @hidden @@ -231,55 +175,39 @@ 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, + repostRequestBody: params.metadata + } + 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..cd442373e44 100644 --- a/packages/sdk/src/sdk/api/albums/types.ts +++ b/packages/sdk/src/sdk/api/albums/types.ts @@ -4,14 +4,84 @@ 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 + albumId?: string + metadata: CreateAlbumRequestBody +} + +export type CreateAlbumRequestWithFiles = CreateAlbumRequest & { + imageFile?: z.input + onProgress?: UploadPlaylistProgressHandler +} + +export type UpdateAlbumRequest = { + userId: string + albumId: string + metadata: UpdateAlbumRequestBody + imageFile?: z.input + onProgress?: UploadPlaylistProgressHandler +} + +export type DeleteAlbumRequest = { + userId: string + albumId: string +} + +export type FavoriteAlbumRequest = { + userId: string + albumId: string + metadata?: { + isSaveOfRepost?: boolean + } +} + +export type UnfavoriteAlbumRequest = { + userId: string + albumId: string +} + +export type RepostAlbumRequest = { + userId: string + albumId: string + metadata?: { + isRepostOfRepost?: boolean + } +} + +export type UnrepostAlbumRequest = { + userId: string + albumId: string +} + export const getAlbumSchema = z.object({ userId: HashId.optional(), albumId: HashId @@ -67,7 +137,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 +199,7 @@ export const UpdateAlbumSchema = z }) .strict() -export type UpdateAlbumRequest = z.input +export type EntityManagerUpdateAlbumRequest = z.input export const DeleteAlbumSchema = z .object({ @@ -138,7 +208,7 @@ export const DeleteAlbumSchema = z }) .strict() -export type DeleteAlbumRequest = z.input +export type EntityManagerDeleteAlbumRequest = z.input export const FavoriteAlbumSchema = z .object({ @@ -150,13 +220,15 @@ export const FavoriteAlbumSchema = z * Is this a save of a repost? Used to dispatch notifications * when a user favorites another user's repost */ - isSaveOfRepost: z.boolean() + isSaveOfRepost: z.optional(z.boolean()) }) ) }) .strict() -export type FavoriteAlbumRequest = z.input +export type EntityManagerFavoriteAlbumRequest = z.input< + typeof FavoriteAlbumSchema +> export const UnfavoriteAlbumSchema = z .object({ @@ -165,7 +237,9 @@ export const UnfavoriteAlbumSchema = z }) .strict() -export type UnfavoriteAlbumRequest = z.input +export type EntityManagerUnfavoriteAlbumRequest = z.input< + typeof UnfavoriteAlbumSchema +> export const RepostAlbumSchema = z .object({ @@ -175,15 +249,15 @@ export const RepostAlbumSchema = z z.object({ /** * Is this a repost of a repost? Used to dispatch notifications - * when a user favorites another user's repost + * when a user reposts content that someone they follow has already reposted */ - isRepostOfRepost: z.boolean() + isRepostOfRepost: z.optional(z.boolean()) }) ) }) .strict() -export type RepostAlbumRequest = z.input +export type EntityManagerRepostAlbumRequest = z.input export const UnrepostAlbumSchema = z .object({ @@ -192,7 +266,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..3c58fba3d1d 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,41 @@ 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 { metadata, userId } = params + const commentId = await this.createCommentWithEntityManager({ + userId, + 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 + } + } + 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 +122,41 @@ 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 { metadata, userId, commentId } = params + await this.updateCommentWithEntityManager({ + userId, + entityId: commentId, + trackId: encodeHashId(metadata.entityId) ?? '', + body: metadata.body + }) + 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..e9acd907913 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.metadata, + 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.metadata, + 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/generated/default/.openapi-generator/FILES b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES index 03c4b835dc7..134ac6d39eb 100644 --- a/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES +++ b/packages/sdk/src/sdk/api/generated/default/.openapi-generator/FILES @@ -17,10 +17,13 @@ apis/WalletApi.ts apis/index.ts index.ts models/Access.ts +models/AccessGate.ts models/AccessInfoResponse.ts models/Activity.ts +models/AddManagerRequestBody.ts models/AlbumBacklink.ts models/AlbumsResponse.ts +models/ApproveGrantRequestBody.ts models/AuthorizedApp.ts models/AuthorizedApps.ts models/BalanceHistoryDataPoint.ts @@ -29,7 +32,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 @@ -53,6 +56,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 @@ -60,17 +64,38 @@ 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/CreateDeveloperAppResponse.ts +models/CreateGrantRequestBody.ts +models/CreatePlaylistRequestBody.ts +models/CreatePlaylistRequestBodyCopyrightLine.ts +models/CreatePlaylistRequestBodyProducerCopyrightLine.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/CreateUserRequestBodyEvents.ts +models/CreateUserResponse.ts models/DashboardWalletUser.ts models/DashboardWalletUsersResponse.ts +models/DdexCopyright.ts +models/DdexResourceContributor.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 @@ -81,39 +106,52 @@ models/ExtendedPurchaseGate.ts models/ExtendedTokenGate.ts models/ExtendedUsdcGate.ts models/Favorite.ts +models/FavoriteRequestBody.ts models/FavoritesResponse.ts +models/FieldVisibility.ts models/FollowGate.ts models/FollowersResponse.ts models/FollowingResponse.ts +models/Genre.ts models/GetChallenges.ts models/GetSupportedUsers.ts models/GetSupporters.ts models/GetTipsResponse.ts models/HistoryResponse.ts models/ListenCount.ts +models/MediaLink.ts models/MonthlyAggregatePlay.ts +models/Mood.ts models/MutualFollowersResponse.ts -models/NftCollection.ts -models/NftGate.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 models/PlaylistsResponse.ts -models/PrizeClaimRequest.ts +models/PrizeClaimRequestBody.ts models/PrizeClaimResponse.ts models/PrizePublic.ts models/PrizesResponse.ts models/ProfilePicture.ts models/PurchasersResponse.ts +models/ReactCommentRequestBody.ts models/RedeemAmountResponse.ts models/RelatedArtistResponse.ts models/RemixParent.ts +models/RemixParentWrite.ts models/RemixedTrackAggregate.ts models/RemixersResponse.ts +models/RemixesResponse.ts +models/RemixingResponse.ts models/ReplyComment.ts +models/Repost.ts +models/RepostRequestBody.ts models/Reposts.ts models/RewardCodeErrorResponse.ts models/RewardCodeResponse.ts @@ -123,6 +161,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 @@ -140,18 +180,31 @@ models/TrackArtwork.ts models/TrackCommentCountResponse.ts models/TrackCommentNotificationResponse.ts models/TrackCommentsResponse.ts +models/TrackDownloadRequestBody.ts models/TrackElement.ts +models/TrackElementWrite.ts +models/TrackFavoritesResponse.ts +models/TrackId.ts models/TrackInspect.ts models/TrackInspectList.ts +models/TrackRepostsResponse.ts models/TrackResponse.ts models/TrackSearch.ts +models/TracksCountResponse.ts models/TracksResponse.ts +models/TrendingIdsResponse.ts models/TrendingPlaylistsResponse.ts +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 @@ -161,11 +214,14 @@ 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 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..fb26e551c03 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; + metadata: 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; + metadata: 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.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: CreateCoinRequestToJSON(params.createCoinRequest), + body: CreateCoinRequestBodyToJSON(params.metadata), }, 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.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: UpdateCoinRequestToJSON(params.updateCoinRequest), + body: UpdateCoinRequestBodyToJSON(params.metadata), }, 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..7c3d8a785e6 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,45 @@ import * as runtime from '../runtime'; import type { CommentRepliesResponse, CommentResponse, + CreateCommentRequestBody, + CreateCommentResponse, + PinCommentRequestBody, + ReactCommentRequestBody, UnclaimedIdResponse, + UpdateCommentRequestBody, + WriteResponse, } from '../models'; import { CommentRepliesResponseFromJSON, CommentRepliesResponseToJSON, CommentResponseFromJSON, CommentResponseToJSON, + CreateCommentRequestBodyFromJSON, + CreateCommentRequestBodyToJSON, + CreateCommentResponseFromJSON, + CreateCommentResponseToJSON, + PinCommentRequestBodyFromJSON, + PinCommentRequestBodyToJSON, + ReactCommentRequestBodyFromJSON, + ReactCommentRequestBodyToJSON, UnclaimedIdResponseFromJSON, UnclaimedIdResponseToJSON, + UpdateCommentRequestBodyFromJSON, + UpdateCommentRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreateCommentRequest { + userId: string; + metadata: CreateCommentRequestBody; +} + +export interface DeleteCommentRequest { + commentId: string; + userId: string; +} + export interface GetCommentRequest { commentId: string; } @@ -40,11 +68,149 @@ export interface GetCommentRepliesRequest { userId?: string; } +export interface PinCommentRequest { + commentId: string; + userId: string; + metadata: PinCommentRequestBody; +} + +export interface ReactToCommentRequest { + commentId: string; + userId: string; + metadata: ReactCommentRequestBody; +} + +export interface ReportCommentRequest { + commentId: string; + userId: string; +} + +export interface UnpinCommentRequest { + commentId: string; + userId: string; + metadata: PinCommentRequestBody; +} + +export interface UnreactToCommentRequest { + commentId: string; + userId: string; + metadata: ReactCommentRequestBody; +} + +export interface UpdateCommentRequest { + commentId: string; + userId: string; + metadata: 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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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.metadata), + }, 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 +312,339 @@ 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.'); + } + + 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) { + 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}/pin`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: PinCommentRequestBodyToJSON(params.metadata), + }, 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.'); + } + + 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) { + 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}/react`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: ReactCommentRequestBodyToJSON(params.metadata), + }, 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.'); + } + + 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) { + 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}/pin`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + body: PinCommentRequestBodyToJSON(params.metadata), + }, 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.'); + } + + 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) { + 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}/react`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + body: ReactCommentRequestBodyToJSON(params.metadata), + }, 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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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.metadata), + }, 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..55c1b45ea4f 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/DeveloperAppsApi.ts @@ -16,22 +16,244 @@ import * as runtime from '../runtime'; import type { + CreateAccessKeyResponse, + CreateDeveloperAppRequestBody, + CreateDeveloperAppResponse, + DeactivateAccessKeyRequestBody, + DeactivateAccessKeyResponse, DeveloperAppResponse, + DeveloperAppsResponse, + UpdateDeveloperAppRequestBody, + WriteResponse, } from '../models'; import { + CreateAccessKeyResponseFromJSON, + CreateAccessKeyResponseToJSON, + CreateDeveloperAppRequestBodyFromJSON, + CreateDeveloperAppRequestBodyToJSON, + CreateDeveloperAppResponseFromJSON, + CreateDeveloperAppResponseToJSON, + DeactivateAccessKeyRequestBodyFromJSON, + DeactivateAccessKeyRequestBodyToJSON, + DeactivateAccessKeyResponseFromJSON, + DeactivateAccessKeyResponseToJSON, DeveloperAppResponseFromJSON, DeveloperAppResponseToJSON, + DeveloperAppsResponseFromJSON, + DeveloperAppsResponseToJSON, + UpdateDeveloperAppRequestBodyFromJSON, + UpdateDeveloperAppRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreateDeveloperAppRequest { + userId: string; + metadata: CreateDeveloperAppRequestBody; +} + +export interface CreateDeveloperAppAccessKeyRequest { + userId: string; + address: string; +} + +export interface DeactivateDeveloperAppAccessKeyRequest { + userId: string; + address: string; + metadata: DeactivateAccessKeyRequestBody; +} + +export interface DeleteDeveloperAppRequest { + userId: string; + address: string; +} + export interface GetDeveloperAppRequest { address: string; } +export interface GetDeveloperAppsRequest { + id: string; + include?: GetDeveloperAppsIncludeEnum; +} + +export interface UpdateDeveloperAppRequest { + userId: string; + address: string; + metadata: UpdateDeveloperAppRequestBody; +} + /** * */ export class DeveloperAppsApi extends runtime.BaseAPI { + /** + * @hidden + * Create a new developer app. Indexer validates grants. + */ + 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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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'; + + const response = await this.request({ + path: `/developer-apps`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateDeveloperAppRequestBodyToJSON(params.metadata), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateDeveloperAppResponseFromJSON(jsonValue)); + } + + /** + * Create a new developer app. Indexer validates grants. + */ + async createDeveloperApp(params: CreateDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Create a new bearer token (API access key) for a developer app. Indexer validates grants. + */ + async createDeveloperAppAccessKeyRaw(params: CreateDeveloperAppAccessKeyRequest, 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 createDeveloperAppAccessKey.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling createDeveloperAppAccessKey.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/developer-apps/{address}/access-keys`.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. Indexer validates grants. + */ + async createDeveloperAppAccessKey(params: CreateDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createDeveloperAppAccessKeyRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deactivate a bearer token (API access key) for a developer app. Indexer validates grants. + */ + async deactivateDeveloperAppAccessKeyRaw(params: DeactivateDeveloperAppAccessKeyRequest, 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 deactivateDeveloperAppAccessKey.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deactivateDeveloperAppAccessKey.'); + } + + if (params.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling deactivateDeveloperAppAccessKey.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/developer-apps/{address}/access-keys/deactivate`.replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: DeactivateAccessKeyRequestBodyToJSON(params.metadata), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => DeactivateAccessKeyResponseFromJSON(jsonValue)); + } + + /** + * Deactivate a bearer token (API access key) for a developer app. Indexer validates grants. + */ + async deactivateDeveloperAppAccessKey(params: DeactivateDeveloperAppAccessKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deactivateDeveloperAppAccessKeyRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Deletes a developer app. Indexer validates grants. + */ + async deleteDeveloperAppRaw(params: DeleteDeveloperAppRequest, 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 deleteDeveloperApp.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling deleteDeveloperApp.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + 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. Indexer validates grants. + */ + async deleteDeveloperApp(params: DeleteDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.deleteDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Gets developer app matching given address (API key) @@ -46,7 +268,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, @@ -63,4 +285,93 @@ export class DeveloperAppsApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Get developer apps for the user. + */ + 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 = {}; + + 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. + */ + async getDeveloperApps(params: GetDeveloperAppsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getDeveloperAppsRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Updates a developer app. Indexer validates grants. + */ + async updateDeveloperAppRaw(params: UpdateDeveloperAppRequest, 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 updateDeveloperApp.'); + } + + 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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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'; + + const response = await this.request({ + path: `/developer-apps/{address}`.replace(`{${"address"}}`, encodeURIComponent(String(params.address))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: UpdateDeveloperAppRequestBodyToJSON(params.metadata), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Updates a developer app. Indexer validates grants. + */ + async updateDeveloperApp(params: UpdateDeveloperAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.updateDeveloperAppRaw(params, initOverrides); + return await response.value(); + } + } + +/** + * @export + */ +export const GetDeveloperAppsIncludeEnum = { + Metrics: 'metrics' +} as const; +export type GetDeveloperAppsIncludeEnum = typeof GetDeveloperAppsIncludeEnum[keyof typeof GetDeveloperAppsIncludeEnum]; 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 bfa99560fc0..b1cfe4d0c37 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts @@ -17,24 +17,58 @@ import * as runtime from '../runtime'; import type { AccessInfoResponse, + CreatePlaylistRequestBody, + CreatePlaylistResponse, + FavoriteRequestBody, PlaylistResponse, PlaylistSearchResult, PlaylistTracksResponse, + RepostRequestBody, TrendingPlaylistsResponse, + UpdatePlaylistRequestBody, + WriteResponse, } from '../models'; import { AccessInfoResponseFromJSON, AccessInfoResponseToJSON, + CreatePlaylistRequestBodyFromJSON, + CreatePlaylistRequestBodyToJSON, + CreatePlaylistResponseFromJSON, + CreatePlaylistResponseToJSON, + FavoriteRequestBodyFromJSON, + FavoriteRequestBodyToJSON, PlaylistResponseFromJSON, PlaylistResponseToJSON, PlaylistSearchResultFromJSON, PlaylistSearchResultToJSON, PlaylistTracksResponseFromJSON, PlaylistTracksResponseToJSON, + RepostRequestBodyFromJSON, + RepostRequestBodyToJSON, TrendingPlaylistsResponseFromJSON, TrendingPlaylistsResponseToJSON, + UpdatePlaylistRequestBodyFromJSON, + UpdatePlaylistRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreatePlaylistRequest { + userId: string; + metadata: CreatePlaylistRequestBody; +} + +export interface DeletePlaylistRequest { + playlistId: string; + userId: string; +} + +export interface FavoritePlaylistRequest { + playlistId: string; + userId: string; + metadata?: FavoriteRequestBody; +} + export interface GetBulkPlaylistsRequest { userId?: string; id?: Array; @@ -64,11 +98,18 @@ export interface GetPlaylistTracksRequest { export interface GetTrendingPlaylistsRequest { offset?: number; limit?: number; + userId?: string; time?: GetTrendingPlaylistsTimeEnum; type?: GetTrendingPlaylistsTypeEnum; omitTracks?: boolean; } +export interface RepostPlaylistRequest { + playlistId: string; + userId: string; + repostRequestBody?: RepostRequestBody; +} + export interface SearchPlaylistsRequest { offset?: number; limit?: number; @@ -80,11 +121,188 @@ 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; + metadata: 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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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.metadata), + }, 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 = {}; + + 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}/favorites`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: FavoriteRequestBodyToJSON(params.metadata), + }, 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 @@ -279,6 +497,10 @@ export class PlaylistsApi extends runtime.BaseAPI { queryParameters['limit'] = params.limit; } + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + if (params.time !== undefined) { queryParameters['time'] = params.time; } @@ -311,6 +533,59 @@ 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 = {}; + + 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}/reposts`.replace(`{${"playlist_id"}}`, encodeURIComponent(String(params.playlistId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RepostRequestBodyToJSON(params.repostRequestBody), + }, 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 @@ -370,6 +645,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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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.metadata), + }, 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..10f1d0a8941 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; + 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.prizeClaimRequest === null || params.prizeClaimRequest === undefined) { - throw new runtime.RequiredError('prizeClaimRequest','Required parameter params.prizeClaimRequest 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: PrizeClaimRequestToJSON(params.prizeClaimRequest), + 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 000d31d8cfa..8b421c67625 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 { + reward: ClaimRewardsRequestBody; } -export interface CreateRewardCodeOperationRequest { - createRewardCodeRequest: CreateRewardCodeRequest; +export interface CreateRewardCodeRequest { + body?: 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.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: ClaimRewardsRequestToJSON(params.claimRewardsRequest), + body: ClaimRewardsRequestBodyToJSON(params.reward), }, 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,11 +83,7 @@ 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> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -99,7 +95,7 @@ export class RewardsApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateRewardCodeRequestToJSON(params.createRewardCodeRequest), + 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: 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 ef1c7417336..d7f6d92dfd8 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/TracksApi.ts @@ -17,21 +17,45 @@ import * as runtime from '../runtime'; import type { AccessInfoResponse, + CreateTrackRequestBody, + CreateTrackResponse, + FavoriteRequestBody, + RemixesResponse, + RemixingResponse, + RepostRequestBody, StemsResponse, StreamUrlResponse, TopListener, TrackCommentCountResponse, TrackCommentNotificationResponse, TrackCommentsResponse, + TrackDownloadRequestBody, + TrackFavoritesResponse, TrackInspect, TrackInspectList, + TrackRepostsResponse, TrackResponse, TrackSearch, TracksResponse, + TrendingIdsResponse, + UpdateTrackRequestBody, + WriteResponse, } from '../models'; import { AccessInfoResponseFromJSON, AccessInfoResponseToJSON, + CreateTrackRequestBodyFromJSON, + CreateTrackRequestBodyToJSON, + CreateTrackResponseFromJSON, + CreateTrackResponseToJSON, + FavoriteRequestBodyFromJSON, + FavoriteRequestBodyToJSON, + RemixesResponseFromJSON, + RemixesResponseToJSON, + RemixingResponseFromJSON, + RemixingResponseToJSON, + RepostRequestBodyFromJSON, + RepostRequestBodyToJSON, StemsResponseFromJSON, StemsResponseToJSON, StreamUrlResponseFromJSON, @@ -44,18 +68,40 @@ import { TrackCommentNotificationResponseToJSON, TrackCommentsResponseFromJSON, TrackCommentsResponseToJSON, + TrackDownloadRequestBodyFromJSON, + TrackDownloadRequestBodyToJSON, + TrackFavoritesResponseFromJSON, + TrackFavoritesResponseToJSON, TrackInspectFromJSON, TrackInspectToJSON, TrackInspectListFromJSON, TrackInspectListToJSON, + TrackRepostsResponseFromJSON, + TrackRepostsResponseToJSON, TrackResponseFromJSON, TrackResponseToJSON, TrackSearchFromJSON, TrackSearchToJSON, TracksResponseFromJSON, TracksResponseToJSON, + TrendingIdsResponseFromJSON, + TrendingIdsResponseToJSON, + UpdateTrackRequestBodyFromJSON, + UpdateTrackRequestBodyToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface CreateTrackRequest { + userId: string; + metadata: CreateTrackRequestBody; +} + +export interface DeleteTrackRequest { + trackId: string; + userId: string; +} + export interface DownloadTrackRequest { trackId: string; userId?: string; @@ -65,15 +111,23 @@ export interface DownloadTrackRequest { filename?: string; } +export interface FavoriteTrackRequest { + trackId: string; + userId: string; + metadata?: FavoriteRequestBody; +} + export interface GetBulkTracksRequest { permalink?: Array; id?: Array; isrc?: Array; + userId?: string; } export interface GetFeelingLuckyTracksRequest { userId?: string; limit?: number; + withUsers?: boolean; minFollowers?: number; } @@ -90,8 +144,26 @@ export interface GetRecentPremiumTracksRequest { userId?: string; } +export interface GetRecommendedTracksRequest { + limit?: number; + genre?: string; + time?: GetRecommendedTracksTimeEnum; + exclusionList?: Array; + userId?: string; +} + +export interface GetRecommendedTracksWithVersionRequest { + version: string; + limit?: number; + genre?: string; + time?: GetRecommendedTracksWithVersionTimeEnum; + exclusionList?: Array; + userId?: string; +} + export interface GetTrackRequest { trackId: string; + userId?: string; } export interface GetTrackAccessInfoRequest { @@ -117,6 +189,23 @@ export interface GetTrackCommentsRequest { sortMethod?: GetTrackCommentsSortMethodEnum; } +export interface GetTrackRemixParentsRequest { + trackId: string; + offset?: number; + limit?: number; + userId?: string; +} + +export interface GetTrackRemixesRequest { + trackId: string; + offset?: number; + limit?: number; + userId?: string; + sortMethod?: GetTrackRemixesSortMethodEnum; + onlyCosigns?: boolean; + onlyContestEntries?: boolean; +} + export interface GetTrackStemsRequest { trackId: string; } @@ -134,16 +223,88 @@ export interface GetTracksWithRecentCommentsRequest { offset?: number; } +export interface GetTrendingTrackIDsRequest { + offset?: number; + limit?: number; + genre?: string; +} + export interface GetTrendingTracksRequest { offset?: number; limit?: number; genre?: string; time?: GetTrendingTracksTimeEnum; + userId?: string; +} + +export interface GetTrendingTracksIDsWithVersionRequest { + version: string; + offset?: number; + limit?: number; + genre?: string; +} + +export interface GetTrendingTracksWithVersionRequest { + version: string; + offset?: number; + limit?: number; + userId?: string; + genre?: string; + time?: GetTrendingTracksWithVersionTimeEnum; +} + +export interface GetTrendingUSDCPurchaseTracksRequest { + offset?: number; + limit?: number; + userId?: string; + genre?: string; + time?: GetTrendingUSDCPurchaseTracksTimeEnum; +} + +export interface GetTrendingUSDCPurchaseTracksWithVersionRequest { + version: string; + offset?: number; + limit?: number; + userId?: string; + genre?: string; + time?: GetTrendingUSDCPurchaseTracksWithVersionTimeEnum; +} + +export interface GetTrendingUndergroundWinnersRequest { + week?: Date; + userId?: string; +} + +export interface GetTrendingWinnersRequest { + week?: Date; + userId?: string; } export interface GetUndergroundTrendingTracksRequest { offset?: number; limit?: number; + userId?: string; +} + +export interface GetUndergroundTrendingTracksWithVersionRequest { + version: string; + offset?: number; + limit?: number; + userId?: string; +} + +export interface GetUsersFromFavoritesRequest { + trackId: string; + offset?: number; + limit?: number; + userId?: string; +} + +export interface GetUsersFromRepostsRequest { + trackId: string; + offset?: number; + limit?: number; + userId?: string; } export interface InspectTrackRequest { @@ -156,6 +317,18 @@ export interface InspectTracksRequest { original?: boolean; } +export interface RecordTrackDownloadRequest { + trackId: string; + userId?: string; + location?: TrackDownloadRequestBody; +} + +export interface RepostTrackRequest { + trackId: string; + userId: string; + repostRequestBody?: RepostRequestBody; +} + export interface SearchTracksRequest { offset?: number; limit?: number; @@ -172,6 +345,11 @@ export interface SearchTracksRequest { bpmMax?: string; } +export interface ShareTrackRequest { + trackId: string; + userId: string; +} + export interface StreamTrackRequest { trackId: string; userId?: string; @@ -185,11 +363,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; + metadata: 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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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.metadata), + }, 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 @@ -242,6 +539,59 @@ 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 = {}; + + 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}/favorites`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: FavoriteRequestBodyToJSON(params.metadata), + }, 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 @@ -261,6 +611,10 @@ export class TracksApi extends runtime.BaseAPI { queryParameters['isrc'] = params.isrc; } + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ @@ -296,6 +650,10 @@ export class TracksApi extends runtime.BaseAPI { queryParameters['limit'] = params.limit; } + if (params.withUsers !== undefined) { + queryParameters['with_users'] = params.withUsers; + } + if (params.minFollowers !== undefined) { queryParameters['min_followers'] = params.minFollowers; } @@ -404,46 +762,78 @@ export class TracksApi extends runtime.BaseAPI { /** * @hidden - * Gets a track by ID + * Get recommended tracks */ - async getTrackRaw(params: GetTrackRequest, 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 getTrack.'); + async getRecommendedTracksRaw(params: GetRecommendedTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; } - const queryParameters: any = {}; + if (params.genre !== undefined) { + queryParameters['genre'] = params.genre; + } + + if (params.time !== undefined) { + queryParameters['time'] = params.time; + } + + if (params.exclusionList) { + queryParameters['exclusion_list'] = params.exclusionList; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/tracks/{track_id}`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + path: `/tracks/recommended`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => TrackResponseFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); } /** - * Gets a track by ID + * Get recommended tracks */ - async getTrack(params: GetTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getTrackRaw(params, initOverrides); + async getRecommendedTracks(params: GetRecommendedTracksRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getRecommendedTracksRaw(params, initOverrides); return await response.value(); } /** * @hidden - * Gets the information necessary to access the track and what access the given user has. + * Get recommended tracks using the given trending strategy version */ - async getTrackAccessInfoRaw(params: GetTrackAccessInfoRequest, 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 getTrackAccessInfo.'); + async getRecommendedTracksWithVersionRaw(params: GetRecommendedTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.version === null || params.version === undefined) { + throw new runtime.RequiredError('version','Required parameter params.version was null or undefined when calling getRecommendedTracksWithVersion.'); } const queryParameters: any = {}; + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.genre !== undefined) { + queryParameters['genre'] = params.genre; + } + + if (params.time !== undefined) { + queryParameters['time'] = params.time; + } + + if (params.exclusionList) { + queryParameters['exclusion_list'] = params.exclusionList; + } + if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } @@ -451,17 +841,87 @@ export class TracksApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/tracks/{track_id}/access-info`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + path: `/tracks/recommended/{version}`.replace(`{${"version"}}`, encodeURIComponent(String(params.version))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => AccessInfoResponseFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); } /** - * Gets the information necessary to access the track and what access the given user has. + * Get recommended tracks using the given trending strategy version + */ + async getRecommendedTracksWithVersion(params: GetRecommendedTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getRecommendedTracksWithVersionRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets a track by ID + */ + async getTrackRaw(params: GetTrackRequest, 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 getTrack.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/{track_id}`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TrackResponseFromJSON(jsonValue)); + } + + /** + * Gets a track by ID + */ + async getTrack(params: GetTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrackRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets the information necessary to access the track and what access the given user has. + */ + async getTrackAccessInfoRaw(params: GetTrackAccessInfoRequest, 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 getTrackAccessInfo.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/{track_id}/access-info`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => AccessInfoResponseFromJSON(jsonValue)); + } + + /** + * Gets the information necessary to access the track and what access the given user has. */ async getTrackAccessInfo(params: GetTrackAccessInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getTrackAccessInfoRaw(params, initOverrides); @@ -585,6 +1045,104 @@ export class TracksApi extends runtime.BaseAPI { return await response.value(); } + /** + * @hidden + * Gets all the tracks that the given track remixes + */ + async getTrackRemixParentsRaw(params: GetTrackRemixParentsRequest, 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 getTrackRemixParents.'); + } + + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/{track_id}/remixing`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => RemixingResponseFromJSON(jsonValue)); + } + + /** + * Gets all the tracks that the given track remixes + */ + async getTrackRemixParents(params: GetTrackRemixParentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrackRemixParentsRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Get all tracks that remix the given track + */ + async getTrackRemixesRaw(params: GetTrackRemixesRequest, 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 getTrackRemixes.'); + } + + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + if (params.sortMethod !== undefined) { + queryParameters['sort_method'] = params.sortMethod; + } + + if (params.onlyCosigns !== undefined) { + queryParameters['only_cosigns'] = params.onlyCosigns; + } + + if (params.onlyContestEntries !== undefined) { + queryParameters['only_contest_entries'] = params.onlyContestEntries; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/{track_id}/remixes`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => RemixesResponseFromJSON(jsonValue)); + } + + /** + * Get all tracks that remix the given track + */ + async getTrackRemixes(params: GetTrackRemixesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrackRemixesRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Get the remixable stems of a track @@ -700,9 +1258,9 @@ export class TracksApi extends runtime.BaseAPI { /** * @hidden - * Gets the top 100 trending (most popular) tracks on Audius + * Gets the track IDs of the top trending tracks on Audius */ - async getTrendingTracksRaw(params: GetTrendingTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async getTrendingTrackIDsRaw(params: GetTrendingTrackIDsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; if (params.offset !== undefined) { @@ -717,35 +1275,31 @@ export class TracksApi extends runtime.BaseAPI { queryParameters['genre'] = params.genre; } - if (params.time !== undefined) { - queryParameters['time'] = params.time; - } - const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/tracks/trending`, + path: `/tracks/trending/ids`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => TrendingIdsResponseFromJSON(jsonValue)); } /** - * Gets the top 100 trending (most popular) tracks on Audius + * Gets the track IDs of the top trending tracks on Audius */ - async getTrendingTracks(params: GetTrendingTracksRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getTrendingTracksRaw(params, initOverrides); + async getTrendingTrackIDs(params: GetTrendingTrackIDsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingTrackIDsRaw(params, initOverrides); return await response.value(); } /** * @hidden - * Gets the top 100 trending underground tracks on Audius + * Gets the top 100 trending (most popular) tracks on Audius */ - async getUndergroundTrendingTracksRaw(params: GetUndergroundTrendingTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async getTrendingTracksRaw(params: GetTrendingTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; if (params.offset !== undefined) { @@ -756,10 +1310,22 @@ export class TracksApi extends runtime.BaseAPI { queryParameters['limit'] = params.limit; } + if (params.genre !== undefined) { + queryParameters['genre'] = params.genre; + } + + if (params.time !== undefined) { + queryParameters['time'] = params.time; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/tracks/trending/underground`, + path: `/tracks/trending`, method: 'GET', headers: headerParameters, query: queryParameters, @@ -769,96 +1335,112 @@ export class TracksApi extends runtime.BaseAPI { } /** - * Gets the top 100 trending underground tracks on Audius + * Gets the top 100 trending (most popular) tracks on Audius */ - async getUndergroundTrendingTracks(params: GetUndergroundTrendingTracksRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.getUndergroundTrendingTracksRaw(params, initOverrides); + async getTrendingTracks(params: GetTrendingTracksRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingTracksRaw(params, initOverrides); return await response.value(); } /** * @hidden - * Inspect a track - * Inspects the details of the file for a track + * Gets the track IDs of the top trending tracks on Audius based on the given trending strategy version */ - async inspectTrackRaw(params: InspectTrackRequest, 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 inspectTrack.'); + async getTrendingTracksIDsWithVersionRaw(params: GetTrendingTracksIDsWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.version === null || params.version === undefined) { + throw new runtime.RequiredError('version','Required parameter params.version was null or undefined when calling getTrendingTracksIDsWithVersion.'); } const queryParameters: any = {}; - if (params.original !== undefined) { - queryParameters['original'] = params.original; + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.genre !== undefined) { + queryParameters['genre'] = params.genre; } const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/tracks/{track_id}/inspect`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + path: `/tracks/trending/ids/{version}`.replace(`{${"version"}}`, encodeURIComponent(String(params.version))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => TrackInspectFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => TrendingIdsResponseFromJSON(jsonValue)); } /** - * Inspect a track - * Inspects the details of the file for a track + * Gets the track IDs of the top trending tracks on Audius based on the given trending strategy version */ - async inspectTrack(params: InspectTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.inspectTrackRaw(params, initOverrides); + async getTrendingTracksIDsWithVersion(params: GetTrendingTracksIDsWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingTracksIDsWithVersionRaw(params, initOverrides); return await response.value(); } /** * @hidden - * Inspect multiple tracks - * Inspects the details of the files for multiple tracks + * Gets the top 100 trending (most popular) tracks on Audius using a given trending strategy version */ - async inspectTracksRaw(params: InspectTracksRequest, 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 inspectTracks.'); + async getTrendingTracksWithVersionRaw(params: GetTrendingTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.version === null || params.version === undefined) { + throw new runtime.RequiredError('version','Required parameter params.version was null or undefined when calling getTrendingTracksWithVersion.'); } const queryParameters: any = {}; - if (params.id) { - queryParameters['id'] = params.id; + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; } - if (params.original !== undefined) { - queryParameters['original'] = params.original; + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + if (params.genre !== undefined) { + queryParameters['genre'] = params.genre; + } + + if (params.time !== undefined) { + queryParameters['time'] = params.time; } const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/tracks/inspect`, + path: `/tracks/trending/{version}`.replace(`{${"version"}}`, encodeURIComponent(String(params.version))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => TrackInspectListFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); } /** - * Inspect multiple tracks - * Inspects the details of the files for multiple tracks + * Gets the top 100 trending (most popular) tracks on Audius using a given trending strategy version */ - async inspectTracks(params: InspectTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.inspectTracksRaw(params, initOverrides); + async getTrendingTracksWithVersion(params: GetTrendingTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingTracksWithVersionRaw(params, initOverrides); return await response.value(); } /** * @hidden - * Search for a track or tracks + * Gets the top trending (most popular) USDC purchase tracks on Audius */ - async searchTracksRaw(params: SearchTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async getTrendingUSDCPurchaseTracksRaw(params: GetTrendingUSDCPurchaseTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; if (params.offset !== undefined) { @@ -869,25 +1451,541 @@ export class TracksApi extends runtime.BaseAPI { queryParameters['limit'] = params.limit; } - if (params.query !== undefined) { - queryParameters['query'] = params.query; + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; } - if (params.genre) { + if (params.genre !== undefined) { queryParameters['genre'] = params.genre; } - if (params.sortMethod !== undefined) { - queryParameters['sort_method'] = params.sortMethod; - } - - if (params.mood) { - queryParameters['mood'] = params.mood; + if (params.time !== undefined) { + queryParameters['time'] = params.time; } - if (params.onlyDownloadable !== undefined) { - queryParameters['only_downloadable'] = params.onlyDownloadable; - } + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/usdc-purchase`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + } + + /** + * Gets the top trending (most popular) USDC purchase tracks on Audius + */ + async getTrendingUSDCPurchaseTracks(params: GetTrendingUSDCPurchaseTracksRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingUSDCPurchaseTracksRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets the top trending (most popular) USDC purchase tracks on Audius using a given trending strategy version + */ + async getTrendingUSDCPurchaseTracksWithVersionRaw(params: GetTrendingUSDCPurchaseTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.version === null || params.version === undefined) { + throw new runtime.RequiredError('version','Required parameter params.version was null or undefined when calling getTrendingUSDCPurchaseTracksWithVersion.'); + } + + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + if (params.genre !== undefined) { + queryParameters['genre'] = params.genre; + } + + if (params.time !== undefined) { + queryParameters['time'] = params.time; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/usdc-purchase/{version}`.replace(`{${"version"}}`, encodeURIComponent(String(params.version))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + } + + /** + * Gets the top trending (most popular) USDC purchase tracks on Audius using a given trending strategy version + */ + async getTrendingUSDCPurchaseTracksWithVersion(params: GetTrendingUSDCPurchaseTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingUSDCPurchaseTracksWithVersionRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets weekly trending underground winners from the trending_results table. Returns full track objects for the specified week. Defaults to the most recent week with data when no week is provided. + */ + async getTrendingUndergroundWinnersRaw(params: GetTrendingUndergroundWinnersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + if (params.week !== undefined) { + queryParameters['week'] = (params.week as any).toISOString().substr(0,10); + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/trending/underground/winners`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + } + + /** + * Gets weekly trending underground winners from the trending_results table. Returns full track objects for the specified week. Defaults to the most recent week with data when no week is provided. + */ + async getTrendingUndergroundWinners(params: GetTrendingUndergroundWinnersRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingUndergroundWinnersRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets weekly trending winners from the trending_results table. Returns full track objects for the specified week. Defaults to the most recent week with data when no week is provided. + */ + async getTrendingWinnersRaw(params: GetTrendingWinnersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + if (params.week !== undefined) { + queryParameters['week'] = (params.week as any).toISOString().substr(0,10); + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/trending/winners`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + } + + /** + * Gets weekly trending winners from the trending_results table. Returns full track objects for the specified week. Defaults to the most recent week with data when no week is provided. + */ + async getTrendingWinners(params: GetTrendingWinnersRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTrendingWinnersRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets the top 100 trending underground tracks on Audius + */ + async getUndergroundTrendingTracksRaw(params: GetUndergroundTrendingTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/trending/underground`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + } + + /** + * Gets the top 100 trending underground tracks on Audius + */ + async getUndergroundTrendingTracks(params: GetUndergroundTrendingTracksRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUndergroundTrendingTracksRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets the top 100 trending underground tracks on Audius using a given trending strategy version + */ + async getUndergroundTrendingTracksWithVersionRaw(params: GetUndergroundTrendingTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.version === null || params.version === undefined) { + throw new runtime.RequiredError('version','Required parameter params.version was null or undefined when calling getUndergroundTrendingTracksWithVersion.'); + } + + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/trending/underground/{version}`.replace(`{${"version"}}`, encodeURIComponent(String(params.version))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + } + + /** + * Gets the top 100 trending underground tracks on Audius using a given trending strategy version + */ + async getUndergroundTrendingTracksWithVersion(params: GetUndergroundTrendingTracksWithVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUndergroundTrendingTracksWithVersionRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Get users that favorited a track + */ + async getUsersFromFavoritesRaw(params: GetUsersFromFavoritesRequest, 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 getUsersFromFavorites.'); + } + + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/{track_id}/favorites`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TrackFavoritesResponseFromJSON(jsonValue)); + } + + /** + * Get users that favorited a track + */ + async getUsersFromFavorites(params: GetUsersFromFavoritesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUsersFromFavoritesRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Get the users that reposted a track + */ + async getUsersFromRepostsRaw(params: GetUsersFromRepostsRequest, 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 getUsersFromReposts.'); + } + + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/{track_id}/reposts`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TrackRepostsResponseFromJSON(jsonValue)); + } + + /** + * Get the users that reposted a track + */ + async getUsersFromReposts(params: GetUsersFromRepostsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUsersFromRepostsRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Inspect a track + * Inspects the details of the file for a track + */ + async inspectTrackRaw(params: InspectTrackRequest, 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 inspectTrack.'); + } + + const queryParameters: any = {}; + + if (params.original !== undefined) { + queryParameters['original'] = params.original; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/{track_id}/inspect`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TrackInspectFromJSON(jsonValue)); + } + + /** + * Inspect a track + * Inspects the details of the file for a track + */ + async inspectTrack(params: InspectTrackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.inspectTrackRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Inspect multiple tracks + * Inspects the details of the files for multiple tracks + */ + async inspectTracksRaw(params: InspectTracksRequest, 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 inspectTracks.'); + } + + const queryParameters: any = {}; + + if (params.id) { + queryParameters['id'] = params.id; + } + + if (params.original !== undefined) { + queryParameters['original'] = params.original; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/tracks/inspect`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TrackInspectListFromJSON(jsonValue)); + } + + /** + * Inspect multiple tracks + * Inspects the details of the files for multiple tracks + */ + async inspectTracks(params: InspectTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.inspectTracksRaw(params, initOverrides); + 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 = {}; + + 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}/downloads`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: TrackDownloadRequestBodyToJSON(params.location), + }, 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 = {}; + + 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}/reposts`.replace(`{${"track_id"}}`, encodeURIComponent(String(params.trackId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RepostRequestBodyToJSON(params.repostRequestBody), + }, 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 + */ + async searchTracksRaw(params: SearchTracksRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } + + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } + + if (params.query !== undefined) { + queryParameters['query'] = params.query; + } + + if (params.genre) { + queryParameters['genre'] = params.genre; + } + + if (params.sortMethod !== undefined) { + queryParameters['sort_method'] = params.sortMethod; + } + + if (params.mood) { + queryParameters['mood'] = params.mood; + } + + if (params.onlyDownloadable !== undefined) { + queryParameters['only_downloadable'] = params.onlyDownloadable; + } if (params.includePurchaseable !== undefined) { queryParameters['includePurchaseable'] = params.includePurchaseable; @@ -933,6 +2031,56 @@ 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.'); + } + + 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)) { + 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 @@ -1002,6 +2150,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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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.metadata), + }, 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(); + } + } /** @@ -1013,6 +2318,26 @@ export const GetMostSharedTracksTimeRangeEnum = { AllTime: 'allTime' } as const; export type GetMostSharedTracksTimeRangeEnum = typeof GetMostSharedTracksTimeRangeEnum[keyof typeof GetMostSharedTracksTimeRangeEnum]; +/** + * @export + */ +export const GetRecommendedTracksTimeEnum = { + Week: 'week', + Month: 'month', + Year: 'year', + AllTime: 'allTime' +} as const; +export type GetRecommendedTracksTimeEnum = typeof GetRecommendedTracksTimeEnum[keyof typeof GetRecommendedTracksTimeEnum]; +/** + * @export + */ +export const GetRecommendedTracksWithVersionTimeEnum = { + Week: 'week', + Month: 'month', + Year: 'year', + AllTime: 'allTime' +} as const; +export type GetRecommendedTracksWithVersionTimeEnum = typeof GetRecommendedTracksWithVersionTimeEnum[keyof typeof GetRecommendedTracksWithVersionTimeEnum]; /** * @export */ @@ -1022,6 +2347,15 @@ export const GetTrackCommentsSortMethodEnum = { Timestamp: 'timestamp' } as const; export type GetTrackCommentsSortMethodEnum = typeof GetTrackCommentsSortMethodEnum[keyof typeof GetTrackCommentsSortMethodEnum]; +/** + * @export + */ +export const GetTrackRemixesSortMethodEnum = { + Likes: 'likes', + Plays: 'plays', + Recent: 'recent' +} as const; +export type GetTrackRemixesSortMethodEnum = typeof GetTrackRemixesSortMethodEnum[keyof typeof GetTrackRemixesSortMethodEnum]; /** * @export */ @@ -1032,6 +2366,36 @@ export const GetTrendingTracksTimeEnum = { AllTime: 'allTime' } as const; export type GetTrendingTracksTimeEnum = typeof GetTrendingTracksTimeEnum[keyof typeof GetTrendingTracksTimeEnum]; +/** + * @export + */ +export const GetTrendingTracksWithVersionTimeEnum = { + Week: 'week', + Month: 'month', + Year: 'year', + AllTime: 'allTime' +} as const; +export type GetTrendingTracksWithVersionTimeEnum = typeof GetTrendingTracksWithVersionTimeEnum[keyof typeof GetTrendingTracksWithVersionTimeEnum]; +/** + * @export + */ +export const GetTrendingUSDCPurchaseTracksTimeEnum = { + Week: 'week', + Month: 'month', + Year: 'year', + AllTime: 'allTime' +} as const; +export type GetTrendingUSDCPurchaseTracksTimeEnum = typeof GetTrendingUSDCPurchaseTracksTimeEnum[keyof typeof GetTrendingUSDCPurchaseTracksTimeEnum]; +/** + * @export + */ +export const GetTrendingUSDCPurchaseTracksWithVersionTimeEnum = { + Week: 'week', + Month: 'month', + Year: 'year', + AllTime: 'allTime' +} as const; +export type GetTrendingUSDCPurchaseTracksWithVersionTimeEnum = typeof GetTrendingUSDCPurchaseTracksWithVersionTimeEnum[keyof typeof GetTrendingUSDCPurchaseTracksWithVersionTimeEnum]; /** * @export */ 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 15cfed14f00..9b1e8507c79 100644 --- a/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts +++ b/packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts @@ -16,12 +16,16 @@ import * as runtime from '../runtime'; import type { + AddManagerRequestBody, AlbumsResponse, + ApproveGrantRequestBody, AuthorizedApps, BalanceHistoryResponse, CollectiblesResponse, ConnectedWalletsResponse, - DeveloperApps, + CreateGrantRequestBody, + CreateUserRequestBody, + CreateUserResponse, EmailAccessResponse, FavoritesResponse, FollowersResponse, @@ -40,7 +44,9 @@ import type { SalesJsonResponse, SubscribersResponse, TagsResponse, + TracksCountResponse, TracksResponse, + UpdateUserRequestBody, UserCoinResponse, UserCoinsResponse, UserCommentsResponse, @@ -51,10 +57,15 @@ import type { UserTracksRemixedResponse, UsersResponse, VerifyToken, + WriteResponse, } from '../models'; import { + AddManagerRequestBodyFromJSON, + AddManagerRequestBodyToJSON, AlbumsResponseFromJSON, AlbumsResponseToJSON, + ApproveGrantRequestBodyFromJSON, + ApproveGrantRequestBodyToJSON, AuthorizedAppsFromJSON, AuthorizedAppsToJSON, BalanceHistoryResponseFromJSON, @@ -63,8 +74,12 @@ import { CollectiblesResponseToJSON, ConnectedWalletsResponseFromJSON, ConnectedWalletsResponseToJSON, - DeveloperAppsFromJSON, - DeveloperAppsToJSON, + CreateGrantRequestBodyFromJSON, + CreateGrantRequestBodyToJSON, + CreateUserRequestBodyFromJSON, + CreateUserRequestBodyToJSON, + CreateUserResponseFromJSON, + CreateUserResponseToJSON, EmailAccessResponseFromJSON, EmailAccessResponseToJSON, FavoritesResponseFromJSON, @@ -101,8 +116,12 @@ import { SubscribersResponseToJSON, TagsResponseFromJSON, TagsResponseToJSON, + TracksCountResponseFromJSON, + TracksCountResponseToJSON, TracksResponseFromJSON, TracksResponseToJSON, + UpdateUserRequestBodyFromJSON, + UpdateUserRequestBodyToJSON, UserCoinResponseFromJSON, UserCoinResponseToJSON, UserCoinsResponseFromJSON, @@ -123,8 +142,29 @@ import { UsersResponseToJSON, VerifyTokenFromJSON, VerifyTokenToJSON, + WriteResponseFromJSON, + WriteResponseToJSON, } from '../models'; +export interface AddManagerRequest { + id: string; + addManagerRequestBody: AddManagerRequestBody; +} + +export interface ApproveGrantRequest { + id: string; + approveGrantRequestBody: ApproveGrantRequestBody; +} + +export interface CreateGrantRequest { + id: string; + createGrantRequestBody: CreateGrantRequestBody; +} + +export interface CreateUserRequest { + metadata: CreateUserRequestBody; +} + export interface DownloadPurchasesAsCSVRequest { id: string; userId?: string; @@ -154,6 +194,11 @@ export interface DownloadUSDCWithdrawalsAsCSVRequest { encodedDataSignature?: string; } +export interface FollowUserRequest { + id: string; + userId: string; +} + export interface GetAIAttributedTracksByUserHandleRequest { handle: string; offset?: number; @@ -192,10 +237,6 @@ export interface GetConnectedWalletsRequest { id: string; } -export interface GetDeveloperAppsRequest { - id: string; -} - export interface GetFavoritesRequest { id: string; } @@ -290,12 +331,14 @@ export interface GetSupportedUsersRequest { id: string; offset?: number; limit?: number; + userId?: string; } export interface GetSupportersRequest { id: string; offset?: number; limit?: number; + userId?: string; } export interface GetTopTrackTagsRequest { @@ -319,8 +362,32 @@ export interface GetTracksByUserRequest { encodedDataSignature?: string; } +export interface GetTracksByUserHandleRequest { + handle: string; + offset?: number; + limit?: number; + userId?: string; + sort?: GetTracksByUserHandleSortEnum; + query?: string; + sortMethod?: GetTracksByUserHandleSortMethodEnum; + sortDirection?: GetTracksByUserHandleSortDirectionEnum; + filterTracks?: GetTracksByUserHandleFilterTracksEnum; + encodedDataMessage?: string; + encodedDataSignature?: string; +} + +export interface GetTracksCountByUserRequest { + id: string; + userId?: string; + filterTracks?: GetTracksCountByUserFilterTracksEnum; + gateCondition?: Array; + encodedDataMessage?: string; + encodedDataSignature?: string; +} + export interface GetUserRequest { id: string; + userId?: string; } export interface GetUserBalanceHistoryRequest { @@ -407,6 +474,21 @@ export interface GetUsersTrackHistoryRequest { encodedDataSignature?: string; } +export interface MuteUserRequest { + id: string; + userId: string; +} + +export interface RemoveManagerRequest { + id: string; + managerUserId: string; +} + +export interface RevokeGrantRequest { + id: string; + address: string; +} + export interface SearchUsersRequest { offset?: number; limit?: number; @@ -416,6 +498,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; + metadata: UpdateUserRequestBody; +} + export interface VerifyIDTokenRequest { token: string; } @@ -425,6 +533,198 @@ export interface VerifyIDTokenRequest { */ export class UsersApi extends runtime.BaseAPI { + /** + * @hidden + * Add a manager (authorize another user to act on your behalf) + */ + async addManagerRaw(params: AddManagerRequest, 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 addManager.'); + } + + if (params.addManagerRequestBody === null || params.addManagerRequestBody === undefined) { + throw new runtime.RequiredError('addManagerRequestBody','Required parameter params.addManagerRequestBody was null or undefined when calling addManager.'); + } + + 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}/managers`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: AddManagerRequestBodyToJSON(params.addManagerRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Add a manager (authorize another user to act on your behalf) + */ + async addManager(params: AddManagerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.addManagerRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Approve a manager request (manager approves being added by the child user) + */ + async approveGrantRaw(params: ApproveGrantRequest, 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 approveGrant.'); + } + + if (params.approveGrantRequestBody === null || params.approveGrantRequestBody === undefined) { + throw new runtime.RequiredError('approveGrantRequestBody','Required parameter params.approveGrantRequestBody was null or undefined when calling approveGrant.'); + } + + 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}/grants/approve`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: ApproveGrantRequestBodyToJSON(params.approveGrantRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Approve a manager request (manager approves being added by the child user) + */ + async approveGrant(params: ApproveGrantRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.approveGrantRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Create a grant (authorize an app to act on the user\'s behalf) + */ + async createGrantRaw(params: CreateGrantRequest, 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 createGrant.'); + } + + if (params.createGrantRequestBody === null || params.createGrantRequestBody === undefined) { + throw new runtime.RequiredError('createGrantRequestBody','Required parameter params.createGrantRequestBody was null or undefined when calling createGrant.'); + } + + 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}/grants`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateGrantRequestBodyToJSON(params.createGrantRequestBody), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Create a grant (authorize an app to act on the user\'s behalf) + */ + async createGrant(params: CreateGrantRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createGrantRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Creates a new user + */ + async createUserRaw(params: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + 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 = {}; + + 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.metadata), + }, 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 * Downloads the purchases the user has made as a CSV file @@ -598,6 +898,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 @@ -825,37 +1175,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 @@ -1415,6 +1734,10 @@ export class UsersApi extends runtime.BaseAPI { queryParameters['limit'] = params.limit; } + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ @@ -1454,6 +1777,10 @@ export class UsersApi extends runtime.BaseAPI { queryParameters['limit'] = params.limit; } + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ @@ -1592,29 +1919,155 @@ export class UsersApi extends runtime.BaseAPI { /** * @hidden - * Gets a single user by their user ID + * Gets the tracks created by a user using the user\'s handle */ - async getUserRaw(params: GetUserRequest, 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 getUser.'); + async getTracksByUserHandleRaw(params: GetTracksByUserHandleRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (params.handle === null || params.handle === undefined) { + throw new runtime.RequiredError('handle','Required parameter params.handle was null or undefined when calling getTracksByUserHandle.'); } const queryParameters: any = {}; - const headerParameters: runtime.HTTPHeaders = {}; + if (params.offset !== undefined) { + queryParameters['offset'] = params.offset; + } - const response = await this.request({ - path: `/users/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); + if (params.limit !== undefined) { + queryParameters['limit'] = params.limit; + } - return new runtime.JSONApiResponse(response, (jsonValue) => UserResponseFromJSON(jsonValue)); - } + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } - /** - * Gets a single user by their user ID + if (params.sort !== undefined) { + queryParameters['sort'] = params.sort; + } + + if (params.query !== undefined) { + queryParameters['query'] = params.query; + } + + if (params.sortMethod !== undefined) { + queryParameters['sort_method'] = params.sortMethod; + } + + if (params.sortDirection !== undefined) { + queryParameters['sort_direction'] = params.sortDirection; + } + + if (params.filterTracks !== undefined) { + queryParameters['filter_tracks'] = params.filterTracks; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (params.encodedDataMessage !== undefined && params.encodedDataMessage !== null) { + headerParameters['Encoded-Data-Message'] = String(params.encodedDataMessage); + } + + if (params.encodedDataSignature !== undefined && params.encodedDataSignature !== null) { + headerParameters['Encoded-Data-Signature'] = String(params.encodedDataSignature); + } + + const response = await this.request({ + path: `/users/handle/{handle}/tracks`.replace(`{${"handle"}}`, encodeURIComponent(String(params.handle))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksResponseFromJSON(jsonValue)); + } + + /** + * Gets the tracks created by a user using the user\'s handle + */ + async getTracksByUserHandle(params: GetTracksByUserHandleRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTracksByUserHandleRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets the count of tracks created by a user + */ + async getTracksCountByUserRaw(params: GetTracksCountByUserRequest, 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 getTracksCountByUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + if (params.filterTracks !== undefined) { + queryParameters['filter_tracks'] = params.filterTracks; + } + + if (params.gateCondition) { + queryParameters['gate_condition'] = params.gateCondition; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (params.encodedDataMessage !== undefined && params.encodedDataMessage !== null) { + headerParameters['Encoded-Data-Message'] = String(params.encodedDataMessage); + } + + if (params.encodedDataSignature !== undefined && params.encodedDataSignature !== null) { + headerParameters['Encoded-Data-Signature'] = String(params.encodedDataSignature); + } + + const response = await this.request({ + path: `/users/{id}/tracks/count`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => TracksCountResponseFromJSON(jsonValue)); + } + + /** + * Gets the count of tracks created by a user + */ + async getTracksCountByUser(params: GetTracksCountByUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTracksCountByUserRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Gets a single user by their user ID + */ + async getUserRaw(params: GetUserRequest, 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 getUser.'); + } + + const queryParameters: any = {}; + + if (params.userId !== undefined) { + queryParameters['user_id'] = params.userId; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/users/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserResponseFromJSON(jsonValue)); + } + + /** + * Gets a single user by their user ID */ async getUser(params: GetUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getUserRaw(params, initOverrides); @@ -2164,6 +2617,148 @@ 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 + * Remove a manager (revoke user-to-user grant). Can be called by the child user or the manager. + */ + async removeManagerRaw(params: RemoveManagerRequest, 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 removeManager.'); + } + + if (params.managerUserId === null || params.managerUserId === undefined) { + throw new runtime.RequiredError('managerUserId','Required parameter params.managerUserId was null or undefined when calling removeManager.'); + } + + 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}/managers/{managerUserId}`.replace(`{${"id"}}`, encodeURIComponent(String(params.id))).replace(`{${"managerUserId"}}`, encodeURIComponent(String(params.managerUserId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); + } + + /** + * Remove a manager (revoke user-to-user grant). Can be called by the child user or the manager. + */ + async removeManager(params: RemoveManagerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.removeManagerRaw(params, initOverrides); + return await response.value(); + } + + /** + * @hidden + * Revoke a grant (remove app authorization) + */ + async revokeGrantRaw(params: RevokeGrantRequest, 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 revokeGrant.'); + } + + if (params.address === null || params.address === undefined) { + throw new runtime.RequiredError('address','Required parameter params.address was null or undefined when calling revokeGrant.'); + } + + 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}/grants/{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)); + } + + /** + * Revoke a grant (remove app authorization) + */ + async revokeGrant(params: RevokeGrantRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.revokeGrantRaw(params, initOverrides); + return await response.value(); + } + /** * @hidden * Search for users that match the given query @@ -2215,6 +2810,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.metadata === null || params.metadata === undefined) { + throw new runtime.RequiredError('metadata','Required parameter params.metadata 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.metadata), + }, 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 @@ -2358,6 +3202,65 @@ export const GetTracksByUserGateConditionEnum = { Token: 'token' } as const; export type GetTracksByUserGateConditionEnum = typeof GetTracksByUserGateConditionEnum[keyof typeof GetTracksByUserGateConditionEnum]; +/** + * @export + */ +export const GetTracksByUserHandleSortEnum = { + Date: 'date', + Plays: 'plays' +} as const; +export type GetTracksByUserHandleSortEnum = typeof GetTracksByUserHandleSortEnum[keyof typeof GetTracksByUserHandleSortEnum]; +/** + * @export + */ +export const GetTracksByUserHandleSortMethodEnum = { + Title: 'title', + ArtistName: 'artist_name', + ReleaseDate: 'release_date', + LastListenDate: 'last_listen_date', + AddedDate: 'added_date', + Plays: 'plays', + Reposts: 'reposts', + Saves: 'saves', + MostListensByUser: 'most_listens_by_user' +} as const; +export type GetTracksByUserHandleSortMethodEnum = typeof GetTracksByUserHandleSortMethodEnum[keyof typeof GetTracksByUserHandleSortMethodEnum]; +/** + * @export + */ +export const GetTracksByUserHandleSortDirectionEnum = { + Asc: 'asc', + Desc: 'desc' +} as const; +export type GetTracksByUserHandleSortDirectionEnum = typeof GetTracksByUserHandleSortDirectionEnum[keyof typeof GetTracksByUserHandleSortDirectionEnum]; +/** + * @export + */ +export const GetTracksByUserHandleFilterTracksEnum = { + All: 'all', + Public: 'public' +} as const; +export type GetTracksByUserHandleFilterTracksEnum = typeof GetTracksByUserHandleFilterTracksEnum[keyof typeof GetTracksByUserHandleFilterTracksEnum]; +/** + * @export + */ +export const GetTracksCountByUserFilterTracksEnum = { + All: 'all', + Public: 'public' +} as const; +export type GetTracksCountByUserFilterTracksEnum = typeof GetTracksCountByUserFilterTracksEnum[keyof typeof GetTracksCountByUserFilterTracksEnum]; +/** + * @export + */ +export const GetTracksCountByUserGateConditionEnum = { + Ungated: 'ungated', + UsdcPurchase: 'usdc_purchase', + Follow: 'follow', + Tip: 'tip', + Nft: 'nft', + Token: 'token' +} as const; +export type GetTracksCountByUserGateConditionEnum = typeof GetTracksCountByUserGateConditionEnum[keyof typeof GetTracksCountByUserGateConditionEnum]; /** * @export */ diff --git a/packages/sdk/src/sdk/api/generated/default/models/AccessGate.ts b/packages/sdk/src/sdk/api/generated/default/models/AccessGate.ts new file mode 100644 index 00000000000..283722cfa35 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/AccessGate.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 { + ExtendedPurchaseGate, + instanceOfExtendedPurchaseGate, + ExtendedPurchaseGateFromJSON, + ExtendedPurchaseGateFromJSONTyped, + ExtendedPurchaseGateToJSON, +} from './ExtendedPurchaseGate'; +import { + 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 + */ +export type AccessGate = ExtendedPurchaseGate | FollowGate | TipGate | TokenGate; + +export function AccessGateFromJSON(json: any): AccessGate { + return AccessGateFromJSONTyped(json, false); +} + +export function AccessGateFromJSONTyped(json: any, ignoreDiscriminator: boolean): AccessGate { + if ((json === undefined) || (json === null)) { + return json; + } + return { ...ExtendedPurchaseGateFromJSONTyped(json, true), ...FollowGateFromJSONTyped(json, true), ...TipGateFromJSONTyped(json, true), ...TokenGateFromJSONTyped(json, true) }; +} + +export function AccessGateToJSON(value?: AccessGate | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + + 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/AddManagerRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/AddManagerRequestBody.ts new file mode 100644 index 00000000000..203822af092 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/AddManagerRequestBody.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 AddManagerRequestBody + */ +export interface AddManagerRequestBody { + /** + * The user ID of the user to add as manager + * @type {string} + * @memberof AddManagerRequestBody + */ + managerUserId: string; +} + +/** + * Check if a given object implements the AddManagerRequestBody interface. + */ +export function instanceOfAddManagerRequestBody(value: object): value is AddManagerRequestBody { + let isInstance = true; + isInstance = isInstance && "managerUserId" in value && value["managerUserId"] !== undefined; + + return isInstance; +} + +export function AddManagerRequestBodyFromJSON(json: any): AddManagerRequestBody { + return AddManagerRequestBodyFromJSONTyped(json, false); +} + +export function AddManagerRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): AddManagerRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'managerUserId': json['manager_user_id'], + }; +} + +export function AddManagerRequestBodyToJSON(value?: AddManagerRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'manager_user_id': value.managerUserId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/ApproveGrantRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/ApproveGrantRequestBody.ts new file mode 100644 index 00000000000..5e67bd3ade6 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/ApproveGrantRequestBody.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 ApproveGrantRequestBody + */ +export interface ApproveGrantRequestBody { + /** + * The user ID of the child user who proposed the manager (grantor) + * @type {string} + * @memberof ApproveGrantRequestBody + */ + grantorUserId: string; +} + +/** + * Check if a given object implements the ApproveGrantRequestBody interface. + */ +export function instanceOfApproveGrantRequestBody(value: object): value is ApproveGrantRequestBody { + let isInstance = true; + isInstance = isInstance && "grantorUserId" in value && value["grantorUserId"] !== undefined; + + return isInstance; +} + +export function ApproveGrantRequestBodyFromJSON(json: any): ApproveGrantRequestBody { + return ApproveGrantRequestBodyFromJSONTyped(json, false); +} + +export function ApproveGrantRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApproveGrantRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'grantorUserId': json['grantor_user_id'], + }; +} + +export function ApproveGrantRequestBodyToJSON(value?: ApproveGrantRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'grantor_user_id': value.grantorUserId, + }; +} + 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/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..02a05fabdf1 --- /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. + */ + + +/** + * + * @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/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..604fa946cca --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateCommentRequestBody.ts @@ -0,0 +1,124 @@ +/* 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 CreateCommentRequestBody + */ +export interface CreateCommentRequestBody { + /** + * + * @type {CommentEntityType} + * @memberof CreateCommentRequestBody + */ + entityType: CommentEntityType; + /** + * ID of the entity being commented on + * @type {number} + * @memberof CreateCommentRequestBody + */ + entityId: number; + /** + * Comment text + * @type {string} + * @memberof CreateCommentRequestBody + */ + body: string; + /** + * Optional ID for the comment (will be generated if not provided) + * @type {number} + * @memberof CreateCommentRequestBody + */ + commentId?: number; + /** + * Parent comment ID if this is a reply + * @type {number} + * @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; +} + +/** + * 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': CommentEntityTypeFromJSON(json['entityType']), + 'entityId': json['entityId'], + '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'], + }; +} + +export function CreateCommentRequestBodyToJSON(value?: CreateCommentRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'entityType': CommentEntityTypeToJSON(value.entityType), + 'entityId': value.entityId, + '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/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..404d87c473c --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppRequestBody.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'; +/** + * + * @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 + * @type {string} + * @memberof CreateDeveloperAppRequestBody + */ + imageUrl?: string; +} + +/** + * 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; + + 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': !exists(json, 'description') ? undefined : json['description'], + 'imageUrl': !exists(json, 'imageUrl') ? undefined : json['imageUrl'], + }; +} + +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, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppResponse.ts new file mode 100644 index 00000000000..f9e25a2e9bb --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateDeveloperAppResponse.ts @@ -0,0 +1,90 @@ +/* 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 CreateDeveloperAppResponse + */ +export interface CreateDeveloperAppResponse { + /** + * The API key (address) for the developer app + * @type {string} + * @memberof CreateDeveloperAppResponse + */ + apiKey?: string; + /** + * The private key for the developer app (for signing) + * @type {string} + * @memberof CreateDeveloperAppResponse + */ + apiSecret?: string; + /** + * The bearer token for API authentication (use in Authorization header) + * @type {string} + * @memberof CreateDeveloperAppResponse + */ + bearerToken?: string; + /** + * Transaction hash of the creation + * @type {string} + * @memberof CreateDeveloperAppResponse + */ + transactionHash?: string; +} + +/** + * Check if a given object implements the CreateDeveloperAppResponse interface. + */ +export function instanceOfCreateDeveloperAppResponse(value: object): value is CreateDeveloperAppResponse { + let isInstance = true; + + return isInstance; +} + +export function CreateDeveloperAppResponseFromJSON(json: any): CreateDeveloperAppResponse { + return CreateDeveloperAppResponseFromJSONTyped(json, false); +} + +export function CreateDeveloperAppResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateDeveloperAppResponse { + 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'], + 'bearerToken': !exists(json, 'bearer_token') ? undefined : json['bearer_token'], + 'transactionHash': !exists(json, 'transaction_hash') ? undefined : json['transaction_hash'], + }; +} + +export function CreateDeveloperAppResponseToJSON(value?: CreateDeveloperAppResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'api_key': value.apiKey, + 'api_secret': value.apiSecret, + 'bearer_token': value.bearerToken, + 'transaction_hash': value.transactionHash, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreateGrantRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/CreateGrantRequestBody.ts new file mode 100644 index 00000000000..8921acfa70a --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateGrantRequestBody.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 CreateGrantRequestBody + */ +export interface CreateGrantRequestBody { + /** + * The developer app address (API key) to grant authorization to + * @type {string} + * @memberof CreateGrantRequestBody + */ + appApiKey: string; +} + +/** + * Check if a given object implements the CreateGrantRequestBody interface. + */ +export function instanceOfCreateGrantRequestBody(value: object): value is CreateGrantRequestBody { + let isInstance = true; + isInstance = isInstance && "appApiKey" in value && value["appApiKey"] !== undefined; + + return isInstance; +} + +export function CreateGrantRequestBodyFromJSON(json: any): CreateGrantRequestBody { + return CreateGrantRequestBodyFromJSONTyped(json, false); +} + +export function CreateGrantRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateGrantRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'appApiKey': json['app_api_key'], + }; +} + +export function CreateGrantRequestBodyToJSON(value?: CreateGrantRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'app_api_key': value.appApiKey, + }; +} + 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..c613727e1a1 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBody.ts @@ -0,0 +1,286 @@ +/* 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 { AccessGate } from './AccessGate'; +import { + AccessGateFromJSON, + AccessGateFromJSONTyped, + AccessGateToJSON, +} from './AccessGate'; +import type { CreatePlaylistRequestBodyCopyrightLine } from './CreatePlaylistRequestBodyCopyrightLine'; +import { + CreatePlaylistRequestBodyCopyrightLineFromJSON, + CreatePlaylistRequestBodyCopyrightLineFromJSONTyped, + CreatePlaylistRequestBodyCopyrightLineToJSON, +} from './CreatePlaylistRequestBodyCopyrightLine'; +import type { CreatePlaylistRequestBodyProducerCopyrightLine } from './CreatePlaylistRequestBodyProducerCopyrightLine'; +import { + CreatePlaylistRequestBodyProducerCopyrightLineFromJSON, + CreatePlaylistRequestBodyProducerCopyrightLineFromJSONTyped, + CreatePlaylistRequestBodyProducerCopyrightLineToJSON, +} from './CreatePlaylistRequestBodyProducerCopyrightLine'; +import type { DdexResourceContributor } from './DdexResourceContributor'; +import { + DdexResourceContributorFromJSON, + DdexResourceContributorFromJSONTyped, + DdexResourceContributorToJSON, +} from './DdexResourceContributor'; +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; + /** + * Whether streaming is restricted behind an access gate + * @type {boolean} + * @memberof CreatePlaylistRequestBody + */ + isStreamGated?: boolean | null; + /** + * Whether the playlist/album is a scheduled release + * @type {boolean} + * @memberof CreatePlaylistRequestBody + */ + isScheduledRelease?: boolean | null; + /** + * + * @type {AccessGate} + * @memberof CreatePlaylistRequestBody + */ + streamConditions?: AccessGate | null; + /** + * DDEX application identifier + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + ddexApp?: string; + /** + * DDEX release identifiers + * @type {{ [key: string]: string; }} + * @memberof CreatePlaylistRequestBody + */ + ddexReleaseIds?: { [key: string]: string; } | null; + /** + * DDEX resource contributors / artists + * @type {Array} + * @memberof CreatePlaylistRequestBody + */ + artists?: Array | null; + /** + * + * @type {CreatePlaylistRequestBodyCopyrightLine} + * @memberof CreatePlaylistRequestBody + */ + copyrightLine?: CreatePlaylistRequestBodyCopyrightLine | null; + /** + * + * @type {CreatePlaylistRequestBodyProducerCopyrightLine} + * @memberof CreatePlaylistRequestBody + */ + producerCopyrightLine?: CreatePlaylistRequestBodyProducerCopyrightLine | null; + /** + * Parental warning type + * @type {string} + * @memberof CreatePlaylistRequestBody + */ + parentalWarningType?: string | null; + /** + * Whether the image is autogenerated + * @type {boolean} + * @memberof CreatePlaylistRequestBody + */ + isImageAutogenerated?: boolean | null; +} + +/** + * 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)), + 'isStreamGated': !exists(json, 'is_stream_gated') ? undefined : json['is_stream_gated'], + 'isScheduledRelease': !exists(json, 'is_scheduled_release') ? undefined : json['is_scheduled_release'], + 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), + 'ddexApp': !exists(json, 'ddex_app') ? undefined : json['ddex_app'], + 'ddexReleaseIds': !exists(json, 'ddex_release_ids') ? undefined : json['ddex_release_ids'], + 'artists': !exists(json, 'artists') ? undefined : (json['artists'] === null ? null : (json['artists'] as Array).map(DdexResourceContributorFromJSON)), + 'copyrightLine': !exists(json, 'copyright_line') ? undefined : CreatePlaylistRequestBodyCopyrightLineFromJSON(json['copyright_line']), + 'producerCopyrightLine': !exists(json, 'producer_copyright_line') ? undefined : CreatePlaylistRequestBodyProducerCopyrightLineFromJSON(json['producer_copyright_line']), + '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)), + 'is_stream_gated': value.isStreamGated, + 'is_scheduled_release': value.isScheduledRelease, + 'stream_conditions': AccessGateToJSON(value.streamConditions), + 'ddex_app': value.ddexApp, + 'ddex_release_ids': value.ddexReleaseIds, + 'artists': value.artists === undefined ? undefined : (value.artists === null ? null : (value.artists as Array).map(DdexResourceContributorToJSON)), + 'copyright_line': CreatePlaylistRequestBodyCopyrightLineToJSON(value.copyrightLine), + 'producer_copyright_line': CreatePlaylistRequestBodyProducerCopyrightLineToJSON(value.producerCopyrightLine), + 'parental_warning_type': value.parentalWarningType, + 'is_image_autogenerated': value.isImageAutogenerated, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBodyCopyrightLine.ts b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBodyCopyrightLine.ts new file mode 100644 index 00000000000..0b12a95deeb --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBodyCopyrightLine.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'; +/** + * DDEX copyright line + * @export + * @interface CreatePlaylistRequestBodyCopyrightLine + */ +export interface CreatePlaylistRequestBodyCopyrightLine { + /** + * Copyright year (4 characters) + * @type {string} + * @memberof CreatePlaylistRequestBodyCopyrightLine + */ + year: string; + /** + * Copyright text + * @type {string} + * @memberof CreatePlaylistRequestBodyCopyrightLine + */ + text: string; +} + +/** + * Check if a given object implements the CreatePlaylistRequestBodyCopyrightLine interface. + */ +export function instanceOfCreatePlaylistRequestBodyCopyrightLine(value: object): value is CreatePlaylistRequestBodyCopyrightLine { + let isInstance = true; + isInstance = isInstance && "year" in value && value["year"] !== undefined; + isInstance = isInstance && "text" in value && value["text"] !== undefined; + + return isInstance; +} + +export function CreatePlaylistRequestBodyCopyrightLineFromJSON(json: any): CreatePlaylistRequestBodyCopyrightLine { + return CreatePlaylistRequestBodyCopyrightLineFromJSONTyped(json, false); +} + +export function CreatePlaylistRequestBodyCopyrightLineFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreatePlaylistRequestBodyCopyrightLine { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'year': json['year'], + 'text': json['text'], + }; +} + +export function CreatePlaylistRequestBodyCopyrightLineToJSON(value?: CreatePlaylistRequestBodyCopyrightLine | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'year': value.year, + 'text': value.text, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBodyProducerCopyrightLine.ts b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBodyProducerCopyrightLine.ts new file mode 100644 index 00000000000..9cdc90e6517 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreatePlaylistRequestBodyProducerCopyrightLine.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'; +/** + * DDEX producer copyright line + * @export + * @interface CreatePlaylistRequestBodyProducerCopyrightLine + */ +export interface CreatePlaylistRequestBodyProducerCopyrightLine { + /** + * Copyright year (4 characters) + * @type {string} + * @memberof CreatePlaylistRequestBodyProducerCopyrightLine + */ + year: string; + /** + * Copyright text + * @type {string} + * @memberof CreatePlaylistRequestBodyProducerCopyrightLine + */ + text: string; +} + +/** + * Check if a given object implements the CreatePlaylistRequestBodyProducerCopyrightLine interface. + */ +export function instanceOfCreatePlaylistRequestBodyProducerCopyrightLine(value: object): value is CreatePlaylistRequestBodyProducerCopyrightLine { + let isInstance = true; + isInstance = isInstance && "year" in value && value["year"] !== undefined; + isInstance = isInstance && "text" in value && value["text"] !== undefined; + + return isInstance; +} + +export function CreatePlaylistRequestBodyProducerCopyrightLineFromJSON(json: any): CreatePlaylistRequestBodyProducerCopyrightLine { + return CreatePlaylistRequestBodyProducerCopyrightLineFromJSONTyped(json, false); +} + +export function CreatePlaylistRequestBodyProducerCopyrightLineFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreatePlaylistRequestBodyProducerCopyrightLine { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'year': json['year'], + 'text': json['text'], + }; +} + +export function CreatePlaylistRequestBodyProducerCopyrightLineToJSON(value?: CreatePlaylistRequestBodyProducerCopyrightLine | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'year': value.year, + 'text': value.text, + }; +} + 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..33945056b88 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateTrackRequestBody.ts @@ -0,0 +1,442 @@ +/* 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 { 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, + GenreFromJSONTyped, + GenreToJSON, +} from './Genre'; +import type { Mood } from './Mood'; +import { + MoodFromJSON, + 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'; + +/** + * + * @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 | null; + /** + * + * @type {Mood} + * @memberof CreateTrackRequestBody + */ + mood?: Mood | null; + /** + * Beats per minute (tempo) + * @type {number} + * @memberof CreateTrackRequestBody + */ + bpm?: number | null; + /** + * Musical key of the track + * @type {string} + * @memberof CreateTrackRequestBody + */ + musicalKey?: string | null; + /** + * Comma-separated tags + * @type {string} + * @memberof CreateTrackRequestBody + */ + tags?: string | null; + /** + * License type + * @type {string} + * @memberof CreateTrackRequestBody + */ + license?: string | null; + /** + * International Standard Recording Code + * @type {string} + * @memberof CreateTrackRequestBody + */ + isrc?: string | null; + /** + * International Standard Musical Work Code + * @type {string} + * @memberof CreateTrackRequestBody + */ + iswc?: string | null; + /** + * Release date + * @type {Date} + * @memberof CreateTrackRequestBody + */ + 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} + * @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 + */ + isDownloadable?: boolean; + /** + * Whether the track is unlisted + * @type {boolean} + * @memberof CreateTrackRequestBody + */ + isUnlisted?: boolean; + /** + * Whether streaming is restricted behind an access gate + * @type {boolean} + * @memberof CreateTrackRequestBody + */ + isStreamGated?: boolean | null; + /** + * + * @type {AccessGate} + * @memberof CreateTrackRequestBody + */ + streamConditions?: AccessGate | null; + /** + * + * @type {AccessGate} + * @memberof CreateTrackRequestBody + */ + downloadConditions?: AccessGate | null; + /** + * + * @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} + * @memberof CreateTrackRequestBody + */ + ddexApp?: string | null; + /** + * DDEX release identifiers + * @type {object} + * @memberof CreateTrackRequestBody + */ + ddexReleaseIds?: object | null; + /** + * DDEX resource contributors / artists + * @type {Array} + * @memberof CreateTrackRequestBody + */ + artists?: Array | null; + /** + * DDEX resource contributors + * @type {Array} + * @memberof CreateTrackRequestBody + */ + resourceContributors?: Array | null; + /** + * DDEX indirect resource contributors + * @type {Array} + * @memberof CreateTrackRequestBody + */ + indirectResourceContributors?: Array | null; + /** + * DDEX rights controller + * @type {object} + * @memberof CreateTrackRequestBody + */ + rightsController?: object | null; + /** + * DDEX copyright line + * @type {object} + * @memberof CreateTrackRequestBody + */ + copyrightLine?: object | null; + /** + * DDEX producer copyright line + * @type {object} + * @memberof CreateTrackRequestBody + */ + producerCopyrightLine?: object | null; + /** + * Parental warning type + * @type {string} + * @memberof CreateTrackRequestBody + */ + parentalWarningType?: string | null; + /** + * Original song title for cover tracks + * @type {string} + * @memberof CreateTrackRequestBody + */ + coverOriginalSongTitle?: string | null; + /** + * Original artist for cover tracks + * @type {string} + * @memberof CreateTrackRequestBody + */ + coverOriginalArtist?: string | null; + /** + * Whether the track is owned by the user + * @type {boolean} + * @memberof CreateTrackRequestBody + */ + isOwnedByUser?: boolean; + /** + * Territory codes for distribution + * @type {Array} + * @memberof CreateTrackRequestBody + */ + territoryCodes?: Array | null; + /** + * Whether AI use is prohibited + * @type {boolean} + * @memberof CreateTrackRequestBody + */ + noAiUse?: boolean; +} + +/** + * 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']), + '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 : (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'], + 'isDownloadable': !exists(json, 'is_downloadable') ? undefined : json['is_downloadable'], + 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], + 'isStreamGated': !exists(json, 'is_stream_gated') ? undefined : json['is_stream_gated'], + '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'], + 'ddexReleaseIds': !exists(json, 'ddex_release_ids') ? undefined : json['ddex_release_ids'], + 'artists': !exists(json, 'artists') ? undefined : json['artists'], + 'resourceContributors': !exists(json, 'resource_contributors') ? undefined : json['resource_contributors'], + 'indirectResourceContributors': !exists(json, 'indirect_resource_contributors') ? undefined : json['indirect_resource_contributors'], + 'rightsController': !exists(json, 'rights_controller') ? undefined : json['rights_controller'], + 'copyrightLine': !exists(json, 'copyright_line') ? undefined : json['copyright_line'], + 'producerCopyrightLine': !exists(json, 'producer_copyright_line') ? undefined : json['producer_copyright_line'], + 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], + 'coverOriginalSongTitle': !exists(json, 'cover_original_song_title') ? undefined : json['cover_original_song_title'], + 'coverOriginalArtist': !exists(json, 'cover_original_artist') ? undefined : json['cover_original_artist'], + 'isOwnedByUser': !exists(json, 'is_owned_by_user') ? undefined : json['is_owned_by_user'], + 'territoryCodes': !exists(json, 'territory_codes') ? undefined : json['territory_codes'], + 'noAiUse': !exists(json, 'no_ai_use') ? undefined : json['no_ai_use'], + }; +} + +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), + 'bpm': value.bpm, + 'musical_key': value.musicalKey, + 'tags': value.tags, + 'license': value.license, + 'isrc': value.isrc, + '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, + 'is_downloadable': value.isDownloadable, + 'is_unlisted': value.isUnlisted, + 'is_stream_gated': value.isStreamGated, + '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, + 'ddex_release_ids': value.ddexReleaseIds, + 'artists': value.artists, + 'resource_contributors': value.resourceContributors, + 'indirect_resource_contributors': value.indirectResourceContributors, + 'rights_controller': value.rightsController, + 'copyright_line': value.copyrightLine, + 'producer_copyright_line': value.producerCopyrightLine, + 'parental_warning_type': value.parentalWarningType, + 'cover_original_song_title': value.coverOriginalSongTitle, + 'cover_original_artist': value.coverOriginalArtist, + 'is_owned_by_user': value.isOwnedByUser, + 'territory_codes': value.territoryCodes, + 'no_ai_use': value.noAiUse, + }; +} + 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..34d42929d73 --- /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 + * @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..c4b6427309c --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserDeveloperAppResponse.ts @@ -0,0 +1,90 @@ +/* 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 private key for the developer app (for signing) + * @type {string} + * @memberof CreateUserDeveloperAppResponse + */ + apiSecret?: string; + /** + * The bearer token for API authentication (use in Authorization header) + * @type {string} + * @memberof CreateUserDeveloperAppResponse + */ + bearerToken?: 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'], + 'bearerToken': !exists(json, 'bearer_token') ? undefined : json['bearer_token'], + '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, + 'bearer_token': value.bearerToken, + '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..33a1febb2bb --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/CreateUserRequestBody.ts @@ -0,0 +1,243 @@ +/* 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 { CreateUserRequestBodyEvents } from './CreateUserRequestBodyEvents'; +import { + CreateUserRequestBodyEventsFromJSON, + CreateUserRequestBodyEventsFromJSONTyped, + CreateUserRequestBodyEventsToJSON, +} from './CreateUserRequestBodyEvents'; +import type { UserPlaylistLibrary } from './UserPlaylistLibrary'; +import { + UserPlaylistLibraryFromJSON, + UserPlaylistLibraryFromJSONTyped, + UserPlaylistLibraryToJSON, +} from './UserPlaylistLibrary'; + +/** + * + * @export + * @interface CreateUserRequestBody + */ +export interface CreateUserRequestBody { + /** + * Optional user hash 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; + /** + * + * @type {UserPlaylistLibrary} + * @memberof CreateUserRequestBody + */ + playlistLibrary?: UserPlaylistLibrary; + /** + * + * @type {CreateUserRequestBodyEvents} + * @memberof CreateUserRequestBody + */ + events?: CreateUserRequestBodyEvents; +} + + +/** + * @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'], + 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : UserPlaylistLibraryFromJSON(json['playlist_library']), + 'events': !exists(json, 'events') ? undefined : CreateUserRequestBodyEventsFromJSON(json['events']), + }; +} + +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, + '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 new file mode 100644 index 00000000000..88a8c3a5a64 --- /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 { + /** + * Hash ID of the user who referred this user + * @type {string} + * @memberof CreateUserRequestBodyEvents + */ + referrer?: string; + /** + * 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/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/DdexCopyright.ts b/packages/sdk/src/sdk/api/generated/default/models/DdexCopyright.ts new file mode 100644 index 00000000000..2cb755e92de --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/DdexCopyright.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 DdexCopyright + */ +export interface DdexCopyright { + /** + * Copyright year (4 characters) + * @type {string} + * @memberof DdexCopyright + */ + year: string; + /** + * Copyright text + * @type {string} + * @memberof DdexCopyright + */ + text: string; +} + +/** + * Check if a given object implements the DdexCopyright interface. + */ +export function instanceOfDdexCopyright(value: object): value is DdexCopyright { + let isInstance = true; + isInstance = isInstance && "year" in value && value["year"] !== undefined; + isInstance = isInstance && "text" in value && value["text"] !== undefined; + + return isInstance; +} + +export function DdexCopyrightFromJSON(json: any): DdexCopyright { + return DdexCopyrightFromJSONTyped(json, false); +} + +export function DdexCopyrightFromJSONTyped(json: any, ignoreDiscriminator: boolean): DdexCopyright { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'year': json['year'], + 'text': json['text'], + }; +} + +export function DdexCopyrightToJSON(value?: DdexCopyright | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'year': value.year, + 'text': value.text, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/DdexResourceContributor.ts b/packages/sdk/src/sdk/api/generated/default/models/DdexResourceContributor.ts new file mode 100644 index 00000000000..fa056f790c9 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/DdexResourceContributor.ts @@ -0,0 +1,84 @@ +/* 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 DdexResourceContributor + */ +export interface DdexResourceContributor { + /** + * Contributor name + * @type {string} + * @memberof DdexResourceContributor + */ + name: string; + /** + * Contributor roles + * @type {Array} + * @memberof DdexResourceContributor + */ + roles: Array; + /** + * Sequence number for ordering + * @type {number} + * @memberof DdexResourceContributor + */ + sequenceNumber?: number; +} + +/** + * Check if a given object implements the DdexResourceContributor interface. + */ +export function instanceOfDdexResourceContributor(value: object): value is DdexResourceContributor { + let isInstance = true; + isInstance = isInstance && "name" in value && value["name"] !== undefined; + isInstance = isInstance && "roles" in value && value["roles"] !== undefined; + + return isInstance; +} + +export function DdexResourceContributorFromJSON(json: any): DdexResourceContributor { + return DdexResourceContributorFromJSONTyped(json, false); +} + +export function DdexResourceContributorFromJSONTyped(json: any, ignoreDiscriminator: boolean): DdexResourceContributor { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + 'roles': json['roles'], + 'sequenceNumber': !exists(json, 'sequence_number') ? undefined : json['sequence_number'], + }; +} + +export function DdexResourceContributorToJSON(value?: DdexResourceContributor | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'roles': value.roles, + 'sequence_number': value.sequenceNumber, + }; +} + 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/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/FavoriteRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/FavoriteRequestBody.ts new file mode 100644 index 00000000000..2f94a62f6c9 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/FavoriteRequestBody.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'; +/** + * Optional metadata for favorite/save operations + * @export + * @interface FavoriteRequestBody + */ +export interface FavoriteRequestBody { + /** + * Set to true when favoriting a reposted item (used for notifications) + * @type {boolean} + * @memberof FavoriteRequestBody + */ + isSaveOfRepost?: boolean; +} + +/** + * Check if a given object implements the FavoriteRequestBody interface. + */ +export function instanceOfFavoriteRequestBody(value: object): value is FavoriteRequestBody { + let isInstance = true; + + return isInstance; +} + +export function FavoriteRequestBodyFromJSON(json: any): FavoriteRequestBody { + return FavoriteRequestBodyFromJSONTyped(json, false); +} + +export function FavoriteRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): FavoriteRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'isSaveOfRepost': !exists(json, 'is_save_of_repost') ? undefined : json['is_save_of_repost'], + }; +} + +export function FavoriteRequestBodyToJSON(value?: FavoriteRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'is_save_of_repost': value.isSaveOfRepost, + }; +} + 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/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/MediaLink.ts b/packages/sdk/src/sdk/api/generated/default/models/MediaLink.ts new file mode 100644 index 00000000000..7f5b4eed8b3 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/MediaLink.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 MediaLink + */ +export interface MediaLink { + /** + * + * @type {string} + * @memberof MediaLink + */ + url?: string; + /** + * + * @type {Array} + * @memberof MediaLink + */ + mirrors?: Array; +} + +/** + * Check if a given object implements the MediaLink interface. + */ +export function instanceOfMediaLink(value: object): value is MediaLink { + let isInstance = true; + + return isInstance; +} + +export function MediaLinkFromJSON(json: any): MediaLink { + return MediaLinkFromJSONTyped(json, false); +} + +export function MediaLinkFromJSONTyped(json: any, ignoreDiscriminator: boolean): MediaLink { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'url': !exists(json, 'url') ? undefined : json['url'], + 'mirrors': !exists(json, 'mirrors') ? undefined : json['mirrors'], + }; +} + +export function MediaLinkToJSON(value?: MediaLink | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'url': value.url, + 'mirrors': value.mirrors, + }; +} + 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/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/PinCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.ts new file mode 100644 index 00000000000..ef43a072a64 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/PinCommentRequestBody.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 PinCommentRequestBody + */ +export interface PinCommentRequestBody { + /** + * + * @type {CommentEntityType} + * @memberof PinCommentRequestBody + */ + entityType: CommentEntityType; + /** + * ID of the entity (track) 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 && "entityType" in value && value["entityType"] !== undefined; + 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 { + + 'entityType': CommentEntityTypeFromJSON(json['entityType']), + 'entityId': json['entityId'], + }; +} + +export function PinCommentRequestBodyToJSON(value?: PinCommentRequestBody | 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/Playlist.ts b/packages/sdk/src/sdk/api/generated/default/models/Playlist.ts index 9ae67a5bbd4..8ea5a93faab 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/Playlist.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/Playlist.ts @@ -20,6 +20,18 @@ import { AccessFromJSONTyped, AccessToJSON, } from './Access'; +import type { AccessGate } from './AccessGate'; +import { + AccessGateFromJSON, + AccessGateFromJSONTyped, + AccessGateToJSON, +} from './AccessGate'; +import type { Favorite } from './Favorite'; +import { + FavoriteFromJSON, + FavoriteFromJSONTyped, + FavoriteToJSON, +} from './Favorite'; import type { PlaylistAddedTimestamp } from './PlaylistAddedTimestamp'; import { PlaylistAddedTimestampFromJSON, @@ -32,6 +44,18 @@ import { PlaylistArtworkFromJSONTyped, PlaylistArtworkToJSON, } from './PlaylistArtwork'; +import type { Repost } from './Repost'; +import { + RepostFromJSON, + RepostFromJSONTyped, + RepostToJSON, +} from './Repost'; +import type { Track } from './Track'; +import { + TrackFromJSON, + TrackFromJSONTyped, + TrackToJSON, +} from './Track'; import type { User } from './User'; import { UserFromJSON, @@ -141,6 +165,150 @@ export interface Playlist { * @memberof Playlist */ trackCount: number; + /** + * + * @type {number} + * @memberof Playlist + */ + blocknumber: number; + /** + * + * @type {string} + * @memberof Playlist + */ + createdAt: string; + /** + * + * @type {Array} + * @memberof Playlist + */ + followeeReposts: Array; + /** + * + * @type {Array} + * @memberof Playlist + */ + followeeFavorites: Array; + /** + * + * @type {boolean} + * @memberof Playlist + */ + hasCurrentUserReposted: boolean; + /** + * + * @type {boolean} + * @memberof Playlist + */ + hasCurrentUserSaved: boolean; + /** + * + * @type {boolean} + * @memberof Playlist + */ + isDelete: boolean; + /** + * + * @type {boolean} + * @memberof Playlist + */ + isPrivate: boolean; + /** + * + * @type {string} + * @memberof Playlist + */ + updatedAt: string; + /** + * DEPRECATED. Use playlist_contents instead. + * @type {Array} + * @memberof Playlist + */ + addedTimestamps: Array; + /** + * + * @type {string} + * @memberof Playlist + */ + userId: string; + /** + * + * @type {Array} + * @memberof Playlist + */ + tracks?: Array; + /** + * + * @type {string} + * @memberof Playlist + */ + coverArt?: string; + /** + * + * @type {string} + * @memberof Playlist + */ + coverArtSizes?: string; + /** + * + * @type {PlaylistArtwork} + * @memberof Playlist + */ + coverArtCids?: PlaylistArtwork; + /** + * + * @type {boolean} + * @memberof Playlist + */ + isStreamGated: boolean; + /** + * How to unlock stream access to the track + * @type {AccessGate} + * @memberof Playlist + */ + streamConditions?: AccessGate; + /** + * + * @type {boolean} + * @memberof Playlist + */ + isScheduledRelease: boolean; + /** + * + * @type {Date} + * @memberof Playlist + */ + releaseDate?: Date; + /** + * + * @type {object} + * @memberof Playlist + */ + ddexReleaseIds?: object; + /** + * + * @type {Array} + * @memberof Playlist + */ + artists?: Array; + /** + * + * @type {object} + * @memberof Playlist + */ + copyrightLine?: object; + /** + * + * @type {object} + * @memberof Playlist + */ + producerCopyrightLine?: object; + /** + * + * @type {string} + * @memberof Playlist + */ + parentalWarningType?: string | null; } /** @@ -160,6 +328,19 @@ export function instanceOfPlaylist(value: object): value is Playlist { isInstance = isInstance && "user" in value && value["user"] !== undefined; isInstance = isInstance && "access" in value && value["access"] !== undefined; isInstance = isInstance && "trackCount" in value && value["trackCount"] !== undefined; + isInstance = isInstance && "blocknumber" in value && value["blocknumber"] !== undefined; + isInstance = isInstance && "createdAt" in value && value["createdAt"] !== undefined; + isInstance = isInstance && "followeeReposts" in value && value["followeeReposts"] !== undefined; + isInstance = isInstance && "followeeFavorites" in value && value["followeeFavorites"] !== undefined; + isInstance = isInstance && "hasCurrentUserReposted" in value && value["hasCurrentUserReposted"] !== undefined; + isInstance = isInstance && "hasCurrentUserSaved" in value && value["hasCurrentUserSaved"] !== undefined; + isInstance = isInstance && "isDelete" in value && value["isDelete"] !== undefined; + isInstance = isInstance && "isPrivate" in value && value["isPrivate"] !== undefined; + isInstance = isInstance && "updatedAt" in value && value["updatedAt"] !== undefined; + isInstance = isInstance && "addedTimestamps" in value && value["addedTimestamps"] !== undefined; + isInstance = isInstance && "userId" in value && value["userId"] !== undefined; + isInstance = isInstance && "isStreamGated" in value && value["isStreamGated"] !== undefined; + isInstance = isInstance && "isScheduledRelease" in value && value["isScheduledRelease"] !== undefined; return isInstance; } @@ -190,6 +371,30 @@ export function PlaylistFromJSONTyped(json: any, ignoreDiscriminator: boolean): 'access': AccessFromJSON(json['access']), 'upc': !exists(json, 'upc') ? undefined : json['upc'], 'trackCount': json['track_count'], + 'blocknumber': json['blocknumber'], + 'createdAt': json['created_at'], + 'followeeReposts': ((json['followee_reposts'] as Array).map(RepostFromJSON)), + 'followeeFavorites': ((json['followee_favorites'] as Array).map(FavoriteFromJSON)), + 'hasCurrentUserReposted': json['has_current_user_reposted'], + 'hasCurrentUserSaved': json['has_current_user_saved'], + 'isDelete': json['is_delete'], + 'isPrivate': json['is_private'], + 'updatedAt': json['updated_at'], + 'addedTimestamps': ((json['added_timestamps'] as Array).map(PlaylistAddedTimestampFromJSON)), + 'userId': json['user_id'], + 'tracks': !exists(json, 'tracks') ? undefined : ((json['tracks'] as Array).map(TrackFromJSON)), + 'coverArt': !exists(json, 'cover_art') ? undefined : json['cover_art'], + 'coverArtSizes': !exists(json, 'cover_art_sizes') ? undefined : json['cover_art_sizes'], + 'coverArtCids': !exists(json, 'cover_art_cids') ? undefined : PlaylistArtworkFromJSON(json['cover_art_cids']), + '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 : (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'], + 'producerCopyrightLine': !exists(json, 'producer_copyright_line') ? undefined : json['producer_copyright_line'], + 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], }; } @@ -218,6 +423,30 @@ export function PlaylistToJSON(value?: Playlist | null): any { 'access': AccessToJSON(value.access), 'upc': value.upc, 'track_count': value.trackCount, + 'blocknumber': value.blocknumber, + 'created_at': value.createdAt, + 'followee_reposts': ((value.followeeReposts as Array).map(RepostToJSON)), + 'followee_favorites': ((value.followeeFavorites as Array).map(FavoriteToJSON)), + 'has_current_user_reposted': value.hasCurrentUserReposted, + 'has_current_user_saved': value.hasCurrentUserSaved, + 'is_delete': value.isDelete, + 'is_private': value.isPrivate, + 'updated_at': value.updatedAt, + 'added_timestamps': ((value.addedTimestamps as Array).map(PlaylistAddedTimestampToJSON)), + 'user_id': value.userId, + 'tracks': value.tracks === undefined ? undefined : ((value.tracks as Array).map(TrackToJSON)), + 'cover_art': value.coverArt, + 'cover_art_sizes': value.coverArtSizes, + 'cover_art_cids': PlaylistArtworkToJSON(value.coverArtCids), + 'is_stream_gated': value.isStreamGated, + 'stream_conditions': AccessGateToJSON(value.streamConditions), + 'is_scheduled_release': value.isScheduledRelease, + 'release_date': value.releaseDate === undefined ? undefined : (value.releaseDate.toISOString().substr(0,10)), + 'ddex_release_ids': value.ddexReleaseIds, + 'artists': value.artists, + 'copyright_line': value.copyrightLine, + 'producer_copyright_line': value.producerCopyrightLine, + 'parental_warning_type': value.parentalWarningType, }; } 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/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..82176824092 --- /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 { UserPlaylistLibraryContentsInner } from './UserPlaylistLibraryContentsInner'; +import { + UserPlaylistLibraryContentsInnerFromJSON, + UserPlaylistLibraryContentsInnerFromJSONTyped, + UserPlaylistLibraryContentsInnerToJSON, +} from './UserPlaylistLibraryContentsInner'; + +/** + * 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(UserPlaylistLibraryContentsInnerFromJSON)), + }; +} + +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(UserPlaylistLibraryContentsInnerToJSON)), + }; +} + 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/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/ReactCommentRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/ReactCommentRequestBody.ts new file mode 100644 index 00000000000..21400696514 --- /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) 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/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/RemixesResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/RemixesResponse.ts new file mode 100644 index 00000000000..7f0e20e298e --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/RemixesResponse.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'; +import type { Track } from './Track'; +import { + TrackFromJSON, + TrackFromJSONTyped, + TrackToJSON, +} from './Track'; + +/** + * + * @export + * @interface RemixesResponse + */ +export interface RemixesResponse { + /** + * + * @type {number} + * @memberof RemixesResponse + */ + count: number; + /** + * + * @type {Array} + * @memberof RemixesResponse + */ + tracks?: Array; +} + +/** + * Check if a given object implements the RemixesResponse interface. + */ +export function instanceOfRemixesResponse(value: object): value is RemixesResponse { + let isInstance = true; + isInstance = isInstance && "count" in value && value["count"] !== undefined; + + return isInstance; +} + +export function RemixesResponseFromJSON(json: any): RemixesResponse { + return RemixesResponseFromJSONTyped(json, false); +} + +export function RemixesResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): RemixesResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'count': json['count'], + 'tracks': !exists(json, 'tracks') ? undefined : ((json['tracks'] as Array).map(TrackFromJSON)), + }; +} + +export function RemixesResponseToJSON(value?: RemixesResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'count': value.count, + 'tracks': value.tracks === undefined ? undefined : ((value.tracks as Array).map(TrackToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/RemixingResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/RemixingResponse.ts new file mode 100644 index 00000000000..42abb4c51cc --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/RemixingResponse.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 { Track } from './Track'; +import { + TrackFromJSON, + TrackFromJSONTyped, + TrackToJSON, +} from './Track'; + +/** + * + * @export + * @interface RemixingResponse + */ +export interface RemixingResponse { + /** + * + * @type {Array} + * @memberof RemixingResponse + */ + data?: Array; +} + +/** + * Check if a given object implements the RemixingResponse interface. + */ +export function instanceOfRemixingResponse(value: object): value is RemixingResponse { + let isInstance = true; + + return isInstance; +} + +export function RemixingResponseFromJSON(json: any): RemixingResponse { + return RemixingResponseFromJSONTyped(json, false); +} + +export function RemixingResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): RemixingResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'data': !exists(json, 'data') ? undefined : ((json['data'] as Array).map(TrackFromJSON)), + }; +} + +export function RemixingResponseToJSON(value?: RemixingResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'data': value.data === undefined ? undefined : ((value.data as Array).map(TrackToJSON)), + }; +} + 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/Repost.ts b/packages/sdk/src/sdk/api/generated/default/models/Repost.ts new file mode 100644 index 00000000000..2b842bb5616 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/Repost.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 Repost + */ +export interface Repost { + /** + * + * @type {string} + * @memberof Repost + */ + repostItemId: string; + /** + * + * @type {string} + * @memberof Repost + */ + repostType: string; + /** + * + * @type {string} + * @memberof Repost + */ + userId: string; +} + +/** + * Check if a given object implements the Repost interface. + */ +export function instanceOfRepost(value: object): value is Repost { + let isInstance = true; + isInstance = isInstance && "repostItemId" in value && value["repostItemId"] !== undefined; + isInstance = isInstance && "repostType" in value && value["repostType"] !== undefined; + isInstance = isInstance && "userId" in value && value["userId"] !== undefined; + + return isInstance; +} + +export function RepostFromJSON(json: any): Repost { + return RepostFromJSONTyped(json, false); +} + +export function RepostFromJSONTyped(json: any, ignoreDiscriminator: boolean): Repost { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'repostItemId': json['repost_item_id'], + 'repostType': json['repost_type'], + 'userId': json['user_id'], + }; +} + +export function RepostToJSON(value?: Repost | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'repost_item_id': value.repostItemId, + 'repost_type': value.repostType, + 'user_id': value.userId, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/RepostRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/RepostRequestBody.ts new file mode 100644 index 00000000000..0543d1cdc07 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/RepostRequestBody.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'; +/** + * Optional metadata for repost operations + * @export + * @interface RepostRequestBody + */ +export interface RepostRequestBody { + /** + * Set to true when reposting an item that was reposted (used for notifications) + * @type {boolean} + * @memberof RepostRequestBody + */ + isRepostOfRepost?: boolean; +} + +/** + * Check if a given object implements the RepostRequestBody interface. + */ +export function instanceOfRepostRequestBody(value: object): value is RepostRequestBody { + let isInstance = true; + + return isInstance; +} + +export function RepostRequestBodyFromJSON(json: any): RepostRequestBody { + return RepostRequestBodyFromJSONTyped(json, false); +} + +export function RepostRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): RepostRequestBody { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'isRepostOfRepost': !exists(json, 'is_repost_of_repost') ? undefined : json['is_repost_of_repost'], + }; +} + +export function RepostRequestBodyToJSON(value?: RepostRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'is_repost_of_repost': value.isRepostOfRepost, + }; +} + 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..7a27fca93f6 --- /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 {string} + * @memberof StemParent + */ + parentTrackId: string; +} + +/** + * 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 b31f12889aa..4181f9359eb 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/Track.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/Track.ts @@ -14,18 +14,36 @@ */ import { exists, mapValues } from '../runtime'; +import type { AccessGate } from './AccessGate'; +import { + AccessGateFromJSON, + AccessGateFromJSONTyped, + AccessGateToJSON, +} from './AccessGate'; import type { AlbumBacklink } from './AlbumBacklink'; import { AlbumBacklinkFromJSON, AlbumBacklinkFromJSONTyped, AlbumBacklinkToJSON, } from './AlbumBacklink'; +import type { MediaLink } from './MediaLink'; +import { + MediaLinkFromJSON, + MediaLinkFromJSONTyped, + MediaLinkToJSON, +} from './MediaLink'; import type { RemixParent } from './RemixParent'; import { RemixParentFromJSON, RemixParentFromJSONTyped, RemixParentToJSON, } from './RemixParent'; +import type { TrackAccessInfo } from './TrackAccessInfo'; +import { + TrackAccessInfoFromJSON, + TrackAccessInfoFromJSONTyped, + TrackAccessInfoToJSON, +} from './TrackAccessInfo'; import type { TrackArtwork } from './TrackArtwork'; import { TrackArtworkFromJSON, @@ -107,10 +125,10 @@ export interface Track { mood?: string; /** * - * @type {string} + * @type {Date} * @memberof Track */ - releaseDate?: string; + releaseDate?: Date; /** * * @type {string} @@ -213,6 +231,318 @@ export interface Track { * @memberof Track */ albumBacklink?: AlbumBacklink; + /** + * + * @type {TrackAccessInfo} + * @memberof Track + */ + access?: TrackAccessInfo; + /** + * + * @type {string} + * @memberof Track + */ + aiAttributionUserId?: string; + /** + * + * @type {Array} + * @memberof Track + */ + allowedApiKeys?: Array; + /** + * + * @type {object} + * @memberof Track + */ + artists?: object; + /** + * + * @type {number} + * @memberof Track + */ + audioAnalysisErrorCount?: number; + /** + * + * @type {string} + * @memberof Track + */ + audioUploadId?: string; + /** + * + * @type {number} + * @memberof Track + */ + blocknumber?: number; + /** + * + * @type {number} + * @memberof Track + */ + bpm?: number; + /** + * + * @type {boolean} + * @memberof Track + */ + commentsDisabled?: boolean; + /** + * + * @type {object} + * @memberof Track + */ + copyrightLine?: object; + /** + * + * @type {string} + * @memberof Track + */ + coverArt?: string; + /** + * + * @type {string} + * @memberof Track + */ + coverArtSizes?: string; + /** + * + * @type {string} + * @memberof Track + */ + coverOriginalArtist?: string; + /** + * + * @type {string} + * @memberof Track + */ + coverOriginalSongTitle?: string; + /** + * + * @type {string} + * @memberof Track + */ + createDate?: string; + /** + * + * @type {Date} + * @memberof Track + */ + createdAt?: Date; + /** + * + * @type {string} + * @memberof Track + */ + creditsSplits?: string; + /** + * + * @type {object} + * @memberof Track + */ + ddexReleaseIds?: object; + /** + * + * @type {MediaLink} + * @memberof Track + */ + download?: MediaLink; + /** + * + * @type {AccessGate} + * @memberof Track + */ + downloadConditions?: AccessGate; + /** + * + * @type {object} + * @memberof Track + */ + fieldVisibility?: object; + /** + * + * @type {Array} + * @memberof Track + */ + followeeFavorites?: Array; + /** + * + * @type {Array} + * @memberof Track + */ + followeeReposts?: Array; + /** + * + * @type {boolean} + * @memberof Track + */ + hasCurrentUserReposted?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + hasCurrentUserSaved?: boolean; + /** + * + * @type {object} + * @memberof Track + */ + indirectResourceContributors?: object; + /** + * + * @type {boolean} + * @memberof Track + */ + isAvailable?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isCustomBpm?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isCustomMusicalKey?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isDelete?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isDownloadGated?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isOwnedByUser?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isScheduledRelease?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isStreamGated?: boolean; + /** + * + * @type {boolean} + * @memberof Track + */ + isUnlisted?: boolean; + /** + * + * @type {string} + * @memberof Track + */ + iswc?: string; + /** + * + * @type {string} + * @memberof Track + */ + license?: string; + /** + * + * @type {string} + * @memberof Track + */ + musicalKey?: string; + /** + * + * @type {string} + * @memberof Track + */ + parentalWarningType?: string | null; + /** + * + * @type {object} + * @memberof Track + */ + playlistsPreviouslyContainingTrack?: object; + /** + * + * @type {MediaLink} + * @memberof Track + */ + preview?: MediaLink; + /** + * + * @type {number} + * @memberof Track + */ + previewStartSeconds?: number; + /** + * + * @type {object} + * @memberof Track + */ + producerCopyrightLine?: object; + /** + * + * @type {object} + * @memberof Track + */ + resourceContributors?: object; + /** + * + * @type {object} + * @memberof Track + */ + rightsController?: object; + /** + * + * @type {string} + * @memberof Track + */ + slug?: string; + /** + * + * @type {Array} + * @memberof Track + */ + stemOf?: Array; + /** + * + * @type {MediaLink} + * @memberof Track + */ + stream?: MediaLink; + /** + * + * @type {AccessGate} + * @memberof Track + */ + streamConditions?: AccessGate; + /** + * + * @type {number} + * @memberof Track + */ + trackId?: number; + /** + * + * @type {object} + * @memberof Track + */ + trackSegments?: object; + /** + * + * @type {Date} + * @memberof Track + */ + updatedAt?: Date; } /** @@ -257,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'], @@ -275,6 +605,58 @@ export function TrackFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tra 'playlistsContainingTrack': !exists(json, 'playlists_containing_track') ? undefined : json['playlists_containing_track'], 'pinnedCommentId': !exists(json, 'pinned_comment_id') ? undefined : json['pinned_comment_id'], 'albumBacklink': !exists(json, 'album_backlink') ? undefined : AlbumBacklinkFromJSON(json['album_backlink']), + 'access': !exists(json, 'access') ? undefined : TrackAccessInfoFromJSON(json['access']), + 'aiAttributionUserId': !exists(json, 'ai_attribution_user_id') ? undefined : json['ai_attribution_user_id'], + 'allowedApiKeys': !exists(json, 'allowed_api_keys') ? undefined : json['allowed_api_keys'], + 'artists': !exists(json, 'artists') ? undefined : json['artists'], + 'audioAnalysisErrorCount': !exists(json, 'audio_analysis_error_count') ? undefined : json['audio_analysis_error_count'], + 'audioUploadId': !exists(json, 'audio_upload_id') ? undefined : json['audio_upload_id'], + 'blocknumber': !exists(json, 'blocknumber') ? undefined : json['blocknumber'], + 'bpm': !exists(json, 'bpm') ? undefined : json['bpm'], + 'commentsDisabled': !exists(json, 'comments_disabled') ? undefined : json['comments_disabled'], + 'copyrightLine': !exists(json, 'copyright_line') ? undefined : json['copyright_line'], + 'coverArt': !exists(json, 'cover_art') ? undefined : json['cover_art'], + 'coverArtSizes': !exists(json, 'cover_art_sizes') ? undefined : json['cover_art_sizes'], + 'coverOriginalArtist': !exists(json, 'cover_original_artist') ? undefined : json['cover_original_artist'], + 'coverOriginalSongTitle': !exists(json, 'cover_original_song_title') ? undefined : json['cover_original_song_title'], + 'createDate': !exists(json, 'create_date') ? undefined : json['create_date'], + 'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), + 'creditsSplits': !exists(json, 'credits_splits') ? undefined : json['credits_splits'], + 'ddexReleaseIds': !exists(json, 'ddex_release_ids') ? undefined : json['ddex_release_ids'], + 'download': !exists(json, 'download') ? undefined : MediaLinkFromJSON(json['download']), + 'downloadConditions': !exists(json, 'download_conditions') ? undefined : AccessGateFromJSON(json['download_conditions']), + 'fieldVisibility': !exists(json, 'field_visibility') ? undefined : json['field_visibility'], + 'followeeFavorites': !exists(json, 'followee_favorites') ? undefined : json['followee_favorites'], + 'followeeReposts': !exists(json, 'followee_reposts') ? undefined : json['followee_reposts'], + 'hasCurrentUserReposted': !exists(json, 'has_current_user_reposted') ? undefined : json['has_current_user_reposted'], + 'hasCurrentUserSaved': !exists(json, 'has_current_user_saved') ? undefined : json['has_current_user_saved'], + 'indirectResourceContributors': !exists(json, 'indirect_resource_contributors') ? undefined : json['indirect_resource_contributors'], + 'isAvailable': !exists(json, 'is_available') ? undefined : json['is_available'], + 'isCustomBpm': !exists(json, 'is_custom_bpm') ? undefined : json['is_custom_bpm'], + 'isCustomMusicalKey': !exists(json, 'is_custom_musical_key') ? undefined : json['is_custom_musical_key'], + 'isDelete': !exists(json, 'is_delete') ? undefined : json['is_delete'], + 'isDownloadGated': !exists(json, 'is_download_gated') ? undefined : json['is_download_gated'], + 'isOwnedByUser': !exists(json, 'is_owned_by_user') ? undefined : json['is_owned_by_user'], + 'isScheduledRelease': !exists(json, 'is_scheduled_release') ? undefined : json['is_scheduled_release'], + 'isStreamGated': !exists(json, 'is_stream_gated') ? undefined : json['is_stream_gated'], + 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], + 'iswc': !exists(json, 'iswc') ? undefined : json['iswc'], + 'license': !exists(json, 'license') ? undefined : json['license'], + 'musicalKey': !exists(json, 'musical_key') ? undefined : json['musical_key'], + 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], + 'playlistsPreviouslyContainingTrack': !exists(json, 'playlists_previously_containing_track') ? undefined : json['playlists_previously_containing_track'], + 'preview': !exists(json, 'preview') ? undefined : MediaLinkFromJSON(json['preview']), + 'previewStartSeconds': !exists(json, 'preview_start_seconds') ? undefined : json['preview_start_seconds'], + 'producerCopyrightLine': !exists(json, 'producer_copyright_line') ? undefined : json['producer_copyright_line'], + 'resourceContributors': !exists(json, 'resource_contributors') ? undefined : json['resource_contributors'], + 'rightsController': !exists(json, 'rights_controller') ? undefined : json['rights_controller'], + 'slug': !exists(json, 'slug') ? undefined : json['slug'], + 'stemOf': !exists(json, 'stem_of') ? undefined : json['stem_of'], + 'stream': !exists(json, 'stream') ? undefined : MediaLinkFromJSON(json['stream']), + 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), + 'trackId': !exists(json, 'track_id') ? undefined : json['track_id'], + 'trackSegments': !exists(json, 'track_segments') ? undefined : json['track_segments'], + 'updatedAt': !exists(json, 'updated_at') ? undefined : (new Date(json['updated_at'])), }; } @@ -297,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, @@ -315,6 +697,58 @@ export function TrackToJSON(value?: Track | null): any { 'playlists_containing_track': value.playlistsContainingTrack, 'pinned_comment_id': value.pinnedCommentId, 'album_backlink': AlbumBacklinkToJSON(value.albumBacklink), + 'access': TrackAccessInfoToJSON(value.access), + 'ai_attribution_user_id': value.aiAttributionUserId, + 'allowed_api_keys': value.allowedApiKeys, + 'artists': value.artists, + 'audio_analysis_error_count': value.audioAnalysisErrorCount, + 'audio_upload_id': value.audioUploadId, + 'blocknumber': value.blocknumber, + 'bpm': value.bpm, + 'comments_disabled': value.commentsDisabled, + 'copyright_line': value.copyrightLine, + 'cover_art': value.coverArt, + 'cover_art_sizes': value.coverArtSizes, + 'cover_original_artist': value.coverOriginalArtist, + 'cover_original_song_title': value.coverOriginalSongTitle, + 'create_date': value.createDate, + 'created_at': value.createdAt === undefined ? undefined : (value.createdAt.toISOString()), + 'credits_splits': value.creditsSplits, + 'ddex_release_ids': value.ddexReleaseIds, + 'download': MediaLinkToJSON(value.download), + 'download_conditions': AccessGateToJSON(value.downloadConditions), + 'field_visibility': value.fieldVisibility, + 'followee_favorites': value.followeeFavorites, + 'followee_reposts': value.followeeReposts, + 'has_current_user_reposted': value.hasCurrentUserReposted, + 'has_current_user_saved': value.hasCurrentUserSaved, + 'indirect_resource_contributors': value.indirectResourceContributors, + 'is_available': value.isAvailable, + 'is_custom_bpm': value.isCustomBpm, + 'is_custom_musical_key': value.isCustomMusicalKey, + 'is_delete': value.isDelete, + 'is_download_gated': value.isDownloadGated, + 'is_owned_by_user': value.isOwnedByUser, + 'is_scheduled_release': value.isScheduledRelease, + 'is_stream_gated': value.isStreamGated, + 'is_unlisted': value.isUnlisted, + 'iswc': value.iswc, + 'license': value.license, + 'musical_key': value.musicalKey, + 'parental_warning_type': value.parentalWarningType, + 'playlists_previously_containing_track': value.playlistsPreviouslyContainingTrack, + 'preview': MediaLinkToJSON(value.preview), + 'preview_start_seconds': value.previewStartSeconds, + 'producer_copyright_line': value.producerCopyrightLine, + 'resource_contributors': value.resourceContributors, + 'rights_controller': value.rightsController, + 'slug': value.slug, + 'stem_of': value.stemOf, + 'stream': MediaLinkToJSON(value.stream), + 'stream_conditions': AccessGateToJSON(value.streamConditions), + 'track_id': value.trackId, + 'track_segments': value.trackSegments, + 'updated_at': value.updatedAt === undefined ? undefined : (value.updatedAt.toISOString()), }; } 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/TrackElementWrite.ts b/packages/sdk/src/sdk/api/generated/default/models/TrackElementWrite.ts new file mode 100644 index 00000000000..d7d2d8b9c21 --- /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 {string} + * @memberof TrackElementWrite + */ + parentTrackId: string; +} + +/** + * 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/TrackFavoritesResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/TrackFavoritesResponse.ts new file mode 100644 index 00000000000..b8d17ae3c2f --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TrackFavoritesResponse.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 { User } from './User'; +import { + UserFromJSON, + UserFromJSONTyped, + UserToJSON, +} from './User'; + +/** + * + * @export + * @interface TrackFavoritesResponse + */ +export interface TrackFavoritesResponse { + /** + * + * @type {Array} + * @memberof TrackFavoritesResponse + */ + data?: Array; +} + +/** + * Check if a given object implements the TrackFavoritesResponse interface. + */ +export function instanceOfTrackFavoritesResponse(value: object): value is TrackFavoritesResponse { + let isInstance = true; + + return isInstance; +} + +export function TrackFavoritesResponseFromJSON(json: any): TrackFavoritesResponse { + return TrackFavoritesResponseFromJSONTyped(json, false); +} + +export function TrackFavoritesResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrackFavoritesResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'data': !exists(json, 'data') ? undefined : ((json['data'] as Array).map(UserFromJSON)), + }; +} + +export function TrackFavoritesResponseToJSON(value?: TrackFavoritesResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'data': value.data === undefined ? undefined : ((value.data as Array).map(UserToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/TrackId.ts b/packages/sdk/src/sdk/api/generated/default/models/TrackId.ts new file mode 100644 index 00000000000..5556dd0cac7 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TrackId.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 TrackId + */ +export interface TrackId { + /** + * + * @type {string} + * @memberof TrackId + */ + id: string; +} + +/** + * Check if a given object implements the TrackId interface. + */ +export function instanceOfTrackId(value: object): value is TrackId { + let isInstance = true; + isInstance = isInstance && "id" in value && value["id"] !== undefined; + + return isInstance; +} + +export function TrackIdFromJSON(json: any): TrackId { + return TrackIdFromJSONTyped(json, false); +} + +export function TrackIdFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrackId { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': json['id'], + }; +} + +export function TrackIdToJSON(value?: TrackId | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/TrackRepostsResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/TrackRepostsResponse.ts new file mode 100644 index 00000000000..1af78ef92ec --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TrackRepostsResponse.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 { User } from './User'; +import { + UserFromJSON, + UserFromJSONTyped, + UserToJSON, +} from './User'; + +/** + * + * @export + * @interface TrackRepostsResponse + */ +export interface TrackRepostsResponse { + /** + * + * @type {Array} + * @memberof TrackRepostsResponse + */ + data?: Array; +} + +/** + * Check if a given object implements the TrackRepostsResponse interface. + */ +export function instanceOfTrackRepostsResponse(value: object): value is TrackRepostsResponse { + let isInstance = true; + + return isInstance; +} + +export function TrackRepostsResponseFromJSON(json: any): TrackRepostsResponse { + return TrackRepostsResponseFromJSONTyped(json, false); +} + +export function TrackRepostsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrackRepostsResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'data': !exists(json, 'data') ? undefined : ((json['data'] as Array).map(UserFromJSON)), + }; +} + +export function TrackRepostsResponseToJSON(value?: TrackRepostsResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'data': value.data === undefined ? undefined : ((value.data as Array).map(UserToJSON)), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/TracksCountResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/TracksCountResponse.ts new file mode 100644 index 00000000000..f69ebd0a498 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TracksCountResponse.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 TracksCountResponse + */ +export interface TracksCountResponse { + /** + * + * @type {number} + * @memberof TracksCountResponse + */ + data?: number; +} + +/** + * Check if a given object implements the TracksCountResponse interface. + */ +export function instanceOfTracksCountResponse(value: object): value is TracksCountResponse { + let isInstance = true; + + return isInstance; +} + +export function TracksCountResponseFromJSON(json: any): TracksCountResponse { + return TracksCountResponseFromJSONTyped(json, false); +} + +export function TracksCountResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TracksCountResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'data': !exists(json, 'data') ? undefined : json['data'], + }; +} + +export function TracksCountResponseToJSON(value?: TracksCountResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'data': value.data, + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/TrendingIdsResponse.ts b/packages/sdk/src/sdk/api/generated/default/models/TrendingIdsResponse.ts new file mode 100644 index 00000000000..6b26c0b56a3 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TrendingIdsResponse.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 { TrendingTimesIds } from './TrendingTimesIds'; +import { + TrendingTimesIdsFromJSON, + TrendingTimesIdsFromJSONTyped, + TrendingTimesIdsToJSON, +} from './TrendingTimesIds'; + +/** + * + * @export + * @interface TrendingIdsResponse + */ +export interface TrendingIdsResponse { + /** + * + * @type {TrendingTimesIds} + * @memberof TrendingIdsResponse + */ + data?: TrendingTimesIds; +} + +/** + * Check if a given object implements the TrendingIdsResponse interface. + */ +export function instanceOfTrendingIdsResponse(value: object): value is TrendingIdsResponse { + let isInstance = true; + + return isInstance; +} + +export function TrendingIdsResponseFromJSON(json: any): TrendingIdsResponse { + return TrendingIdsResponseFromJSONTyped(json, false); +} + +export function TrendingIdsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrendingIdsResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'data': !exists(json, 'data') ? undefined : TrendingTimesIdsFromJSON(json['data']), + }; +} + +export function TrendingIdsResponseToJSON(value?: TrendingIdsResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'data': TrendingTimesIdsToJSON(value.data), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/TrendingTimesIds.ts b/packages/sdk/src/sdk/api/generated/default/models/TrendingTimesIds.ts new file mode 100644 index 00000000000..c90a28244c1 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/TrendingTimesIds.ts @@ -0,0 +1,89 @@ +/* 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 { TrackId } from './TrackId'; +import { + TrackIdFromJSON, + TrackIdFromJSONTyped, + TrackIdToJSON, +} from './TrackId'; + +/** + * + * @export + * @interface TrendingTimesIds + */ +export interface TrendingTimesIds { + /** + * + * @type {Array} + * @memberof TrendingTimesIds + */ + week?: Array; + /** + * + * @type {Array} + * @memberof TrendingTimesIds + */ + month?: Array; + /** + * + * @type {Array} + * @memberof TrendingTimesIds + */ + year?: Array; +} + +/** + * Check if a given object implements the TrendingTimesIds interface. + */ +export function instanceOfTrendingTimesIds(value: object): value is TrendingTimesIds { + let isInstance = true; + + return isInstance; +} + +export function TrendingTimesIdsFromJSON(json: any): TrendingTimesIds { + return TrendingTimesIdsFromJSONTyped(json, false); +} + +export function TrendingTimesIdsFromJSONTyped(json: any, ignoreDiscriminator: boolean): TrendingTimesIds { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'week': !exists(json, 'week') ? undefined : ((json['week'] as Array).map(TrackIdFromJSON)), + 'month': !exists(json, 'month') ? undefined : ((json['month'] as Array).map(TrackIdFromJSON)), + 'year': !exists(json, 'year') ? undefined : ((json['year'] as Array).map(TrackIdFromJSON)), + }; +} + +export function TrendingTimesIdsToJSON(value?: TrendingTimesIds | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'week': value.week === undefined ? undefined : ((value.week as Array).map(TrackIdToJSON)), + 'month': value.month === undefined ? undefined : ((value.month as Array).map(TrackIdToJSON)), + 'year': value.year === undefined ? undefined : ((value.year as Array).map(TrackIdToJSON)), + }; +} + 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..ad958840bb1 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateCommentRequestBody.ts @@ -0,0 +1,100 @@ +/* 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 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; +} + +/** + * Check if a given object implements the UpdateCommentRequestBody interface. + */ +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; +} + +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 { + + 'entityType': CommentEntityTypeFromJSON(json['entityType']), + 'entityId': json['entityId'], + 'body': json['body'], + 'mentions': !exists(json, 'mentions') ? undefined : json['mentions'], + }; +} + +export function UpdateCommentRequestBodyToJSON(value?: UpdateCommentRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + 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/UpdateDeveloperAppRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateDeveloperAppRequestBody.ts new file mode 100644 index 00000000000..a3bcbe4f3ac --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateDeveloperAppRequestBody.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'; +/** + * + * @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; + + 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': !exists(json, 'description') ? undefined : json['description'], + 'imageUrl': !exists(json, 'imageUrl') ? undefined : 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..b365194f1b0 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdatePlaylistRequestBody.ts @@ -0,0 +1,277 @@ +/* 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 { AccessGate } from './AccessGate'; +import { + AccessGateFromJSON, + AccessGateFromJSONTyped, + AccessGateToJSON, +} from './AccessGate'; +import type { CreatePlaylistRequestBodyCopyrightLine } from './CreatePlaylistRequestBodyCopyrightLine'; +import { + CreatePlaylistRequestBodyCopyrightLineFromJSON, + CreatePlaylistRequestBodyCopyrightLineFromJSONTyped, + CreatePlaylistRequestBodyCopyrightLineToJSON, +} from './CreatePlaylistRequestBodyCopyrightLine'; +import type { CreatePlaylistRequestBodyProducerCopyrightLine } from './CreatePlaylistRequestBodyProducerCopyrightLine'; +import { + CreatePlaylistRequestBodyProducerCopyrightLineFromJSON, + CreatePlaylistRequestBodyProducerCopyrightLineFromJSONTyped, + CreatePlaylistRequestBodyProducerCopyrightLineToJSON, +} from './CreatePlaylistRequestBodyProducerCopyrightLine'; +import type { DdexResourceContributor } from './DdexResourceContributor'; +import { + DdexResourceContributorFromJSON, + DdexResourceContributorFromJSONTyped, + DdexResourceContributorToJSON, +} from './DdexResourceContributor'; +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'; + +/** + * 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; + /** + * Whether this is an album + * @type {boolean} + * @memberof UpdatePlaylistRequestBody + */ + isAlbum?: 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; + /** + * Universal Product Code (for albums) + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + upc?: string; + /** + * Release date + * @type {Date} + * @memberof UpdatePlaylistRequestBody + */ + releaseDate?: Date; + /** + * IPFS CID for cover art + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + coverArtCid?: string; + /** + * Array of track IDs to include in the playlist + * @type {Array} + * @memberof UpdatePlaylistRequestBody + */ + playlistContents?: Array; + /** + * Whether streaming is restricted behind an access gate + * @type {boolean} + * @memberof UpdatePlaylistRequestBody + */ + isStreamGated?: boolean | null; + /** + * Whether the playlist/album is a scheduled release + * @type {boolean} + * @memberof UpdatePlaylistRequestBody + */ + isScheduledRelease?: boolean | null; + /** + * + * @type {AccessGate} + * @memberof UpdatePlaylistRequestBody + */ + streamConditions?: AccessGate | null; + /** + * DDEX application identifier + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + ddexApp?: string; + /** + * DDEX release identifiers + * @type {{ [key: string]: string; }} + * @memberof UpdatePlaylistRequestBody + */ + ddexReleaseIds?: { [key: string]: string; } | null; + /** + * DDEX resource contributors / artists + * @type {Array} + * @memberof UpdatePlaylistRequestBody + */ + artists?: Array | null; + /** + * + * @type {CreatePlaylistRequestBodyCopyrightLine} + * @memberof UpdatePlaylistRequestBody + */ + copyrightLine?: CreatePlaylistRequestBodyCopyrightLine | null; + /** + * + * @type {CreatePlaylistRequestBodyProducerCopyrightLine} + * @memberof UpdatePlaylistRequestBody + */ + producerCopyrightLine?: CreatePlaylistRequestBodyProducerCopyrightLine | null; + /** + * Parental warning type + * @type {string} + * @memberof UpdatePlaylistRequestBody + */ + parentalWarningType?: string | null; + /** + * Whether the image is autogenerated + * @type {boolean} + * @memberof UpdatePlaylistRequestBody + */ + isImageAutogenerated?: boolean | null; +} + +/** + * 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'], + '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)), + 'isStreamGated': !exists(json, 'is_stream_gated') ? undefined : json['is_stream_gated'], + 'isScheduledRelease': !exists(json, 'is_scheduled_release') ? undefined : json['is_scheduled_release'], + 'streamConditions': !exists(json, 'stream_conditions') ? undefined : AccessGateFromJSON(json['stream_conditions']), + 'ddexApp': !exists(json, 'ddex_app') ? undefined : json['ddex_app'], + 'ddexReleaseIds': !exists(json, 'ddex_release_ids') ? undefined : json['ddex_release_ids'], + 'artists': !exists(json, 'artists') ? undefined : (json['artists'] === null ? null : (json['artists'] as Array).map(DdexResourceContributorFromJSON)), + 'copyrightLine': !exists(json, 'copyright_line') ? undefined : CreatePlaylistRequestBodyCopyrightLineFromJSON(json['copyright_line']), + 'producerCopyrightLine': !exists(json, 'producer_copyright_line') ? undefined : CreatePlaylistRequestBodyProducerCopyrightLineFromJSON(json['producer_copyright_line']), + 'parentalWarningType': !exists(json, 'parental_warning_type') ? undefined : json['parental_warning_type'], + 'isImageAutogenerated': !exists(json, 'is_image_autogenerated') ? undefined : json['is_image_autogenerated'], + }; +} + +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, + '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)), + 'is_stream_gated': value.isStreamGated, + 'is_scheduled_release': value.isScheduledRelease, + 'stream_conditions': AccessGateToJSON(value.streamConditions), + 'ddex_app': value.ddexApp, + 'ddex_release_ids': value.ddexReleaseIds, + 'artists': value.artists === undefined ? undefined : (value.artists === null ? null : (value.artists as Array).map(DdexResourceContributorToJSON)), + 'copyright_line': CreatePlaylistRequestBodyCopyrightLineToJSON(value.copyrightLine), + 'producer_copyright_line': CreatePlaylistRequestBodyProducerCopyrightLineToJSON(value.producerCopyrightLine), + 'parental_warning_type': value.parentalWarningType, + 'is_image_autogenerated': value.isImageAutogenerated, + }; +} + 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..b205d019d82 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateTrackRequestBody.ts @@ -0,0 +1,335 @@ +/* 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 { 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, + GenreFromJSONTyped, + GenreToJSON, +} from './Genre'; +import type { Mood } from './Mood'; +import { + MoodFromJSON, + 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. + * @export + * @interface UpdateTrackRequestBody + */ +export interface UpdateTrackRequestBody { + /** + * Track title + * @type {string} + * @memberof UpdateTrackRequestBody + */ + title?: string; + /** + * + * @type {Genre} + * @memberof UpdateTrackRequestBody + */ + genre?: Genre; + /** + * Track description + * @type {string} + * @memberof UpdateTrackRequestBody + */ + description?: string | null; + /** + * + * @type {Mood} + * @memberof UpdateTrackRequestBody + */ + mood?: Mood | null; + /** + * Beats per minute (tempo) + * @type {number} + * @memberof UpdateTrackRequestBody + */ + bpm?: number | null; + /** + * Musical key of the track + * @type {string} + * @memberof UpdateTrackRequestBody + */ + musicalKey?: string | null; + /** + * Comma-separated tags + * @type {string} + * @memberof UpdateTrackRequestBody + */ + tags?: string | null; + /** + * License type + * @type {string} + * @memberof UpdateTrackRequestBody + */ + license?: string | null; + /** + * 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; + /** + * IPFS CID for the track audio file + * @type {string} + * @memberof UpdateTrackRequestBody + */ + 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; + /** + * Whether the track is unlisted + * @type {boolean} + * @memberof UpdateTrackRequestBody + */ + isUnlisted?: boolean; + /** + * Whether streaming is restricted behind an access gate + * @type {boolean} + * @memberof UpdateTrackRequestBody + */ + isStreamGated?: boolean; + /** + * + * @type {AccessGate} + * @memberof UpdateTrackRequestBody + */ + streamConditions?: AccessGate | null; + /** + * + * @type {AccessGate} + * @memberof UpdateTrackRequestBody + */ + downloadConditions?: AccessGate | null; + /** + * + * @type {FieldVisibility} + * @memberof UpdateTrackRequestBody + */ + fieldVisibility?: FieldVisibility; + /** + * Placement hosts for the track + * @type {string} + * @memberof UpdateTrackRequestBody + */ + 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; +} + +/** + * 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'], + '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'], + '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 : (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'], + 'isDownloadable': !exists(json, 'is_downloadable') ? undefined : json['is_downloadable'], + 'isUnlisted': !exists(json, 'is_unlisted') ? undefined : json['is_unlisted'], + 'isStreamGated': !exists(json, 'is_stream_gated') ? undefined : json['is_stream_gated'], + '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'], + }; +} + +export function UpdateTrackRequestBodyToJSON(value?: UpdateTrackRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'title': value.title, + '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 === 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, + 'is_downloadable': value.isDownloadable, + 'is_unlisted': value.isUnlisted, + 'is_stream_gated': value.isStreamGated, + '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/UpdateUserRequestBody.ts b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts new file mode 100644 index 00000000000..a79ffb8f04d --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UpdateUserRequestBody.ts @@ -0,0 +1,249 @@ +/* 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 { CreateUserRequestBodyEvents } from './CreateUserRequestBodyEvents'; +import { + CreateUserRequestBodyEventsFromJSON, + CreateUserRequestBodyEventsFromJSONTyped, + CreateUserRequestBodyEventsToJSON, +} from './CreateUserRequestBodyEvents'; +import type { UserPlaylistLibrary } from './UserPlaylistLibrary'; +import { + UserPlaylistLibraryFromJSON, + UserPlaylistLibraryFromJSONTyped, + UserPlaylistLibraryToJSON, +} from './UserPlaylistLibrary'; + +/** + * Request body for updating user profile. All fields are optional. + * @export + * @interface UpdateUserRequestBody + */ +export interface UpdateUserRequestBody { + /** + * User handle. Can only be set if the user does not already have a handle. + * @type {string} + * @memberof UpdateUserRequestBody + */ + handle?: string; + /** + * 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 hash 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; + /** + * + * @type {UserPlaylistLibrary} + * @memberof UpdateUserRequestBody + */ + playlistLibrary?: UserPlaylistLibrary; + /** + * + * @type {CreateUserRequestBodyEvents} + * @memberof UpdateUserRequestBody + */ + events?: CreateUserRequestBodyEvents; +} + + +/** + * @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 { + + 'handle': !exists(json, 'handle') ? undefined : json['handle'], + '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'], + 'playlistLibrary': !exists(json, 'playlist_library') ? undefined : UserPlaylistLibraryFromJSON(json['playlist_library']), + 'events': !exists(json, 'events') ? undefined : CreateUserRequestBodyEventsFromJSON(json['events']), + }; +} + +export function UpdateUserRequestBodyToJSON(value?: UpdateUserRequestBody | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'handle': value.handle, + '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, + 'playlist_library': UserPlaylistLibraryToJSON(value.playlistLibrary), + 'events': CreateUserRequestBodyEventsToJSON(value.events), + }; +} + diff --git a/packages/sdk/src/sdk/api/generated/default/models/User.ts b/packages/sdk/src/sdk/api/generated/default/models/User.ts index 971e2d8be75..e0c0eeff152 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/User.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/User.ts @@ -231,6 +231,174 @@ export interface User { * @memberof User */ wallet: string; + /** + * + * @type {string} + * @memberof User + */ + balance?: string; + /** + * + * @type {string} + * @memberof User + */ + associatedWalletsBalance?: string; + /** + * + * @type {string} + * @memberof User + */ + totalBalance?: string; + /** + * + * @type {string} + * @memberof User + */ + payoutWallet?: string; + /** + * + * @type {string} + * @memberof User + */ + waudioBalance?: string; + /** + * + * @type {string} + * @memberof User + */ + associatedSolWalletsBalance?: string; + /** + * + * @type {number} + * @memberof User + */ + blocknumber?: number; + /** + * + * @type {Date} + * @memberof User + */ + createdAt?: Date; + /** + * + * @type {Date} + * @memberof User + */ + updatedAt?: Date; + /** + * + * @type {boolean} + * @memberof User + */ + isStorageV2?: boolean; + /** + * + * @type {string} + * @memberof User + */ + creatorNodeEndpoint?: string; + /** + * + * @type {number} + * @memberof User + */ + currentUserFolloweeFollowCount?: number; + /** + * + * @type {boolean} + * @memberof User + */ + doesCurrentUserFollow?: boolean; + /** + * + * @type {boolean} + * @memberof User + */ + doesCurrentUserSubscribe?: boolean; + /** + * + * @type {boolean} + * @memberof User + */ + doesFollowCurrentUser?: boolean; + /** + * + * @type {string} + * @memberof User + */ + handleLc?: string; + /** + * + * @type {string} + * @memberof User + */ + profileType?: string; + /** + * + * @type {number} + * @memberof User + */ + userId?: number; + /** + * + * @type {boolean} + * @memberof User + */ + hasCollectibles?: boolean; + /** + * + * @type {boolean} + * @memberof User + */ + allowAiAttribution?: boolean; + /** + * + * @type {string} + * @memberof User + */ + coinFlairMint?: string; + /** + * + * @type {object} + * @memberof User + */ + artistCoinBadge?: object; + /** + * + * @type {string} + * @memberof User + */ + coverPhotoSizes?: string; + /** + * + * @type {object} + * @memberof User + */ + coverPhotoCids?: object; + /** + * + * @type {object} + * @memberof User + */ + coverPhotoLegacy?: object; + /** + * + * @type {string} + * @memberof User + */ + profilePictureSizes?: string; + /** + * + * @type {object} + * @memberof User + */ + profilePictureCids?: object; + /** + * + * @type {object} + * @memberof User + */ + profilePictureLegacy?: object; } /** @@ -307,6 +475,34 @@ export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User 'supportingCount': json['supporting_count'], 'totalAudioBalance': json['total_audio_balance'], 'wallet': json['wallet'], + 'balance': !exists(json, 'balance') ? undefined : json['balance'], + 'associatedWalletsBalance': !exists(json, 'associated_wallets_balance') ? undefined : json['associated_wallets_balance'], + 'totalBalance': !exists(json, 'total_balance') ? undefined : json['total_balance'], + 'payoutWallet': !exists(json, 'payout_wallet') ? undefined : json['payout_wallet'], + 'waudioBalance': !exists(json, 'waudio_balance') ? undefined : json['waudio_balance'], + 'associatedSolWalletsBalance': !exists(json, 'associated_sol_wallets_balance') ? undefined : json['associated_sol_wallets_balance'], + 'blocknumber': !exists(json, 'blocknumber') ? undefined : json['blocknumber'], + 'createdAt': !exists(json, 'created_at') ? undefined : (new Date(json['created_at'])), + 'updatedAt': !exists(json, 'updated_at') ? undefined : (new Date(json['updated_at'])), + 'isStorageV2': !exists(json, 'is_storage_v2') ? undefined : json['is_storage_v2'], + 'creatorNodeEndpoint': !exists(json, 'creator_node_endpoint') ? undefined : json['creator_node_endpoint'], + 'currentUserFolloweeFollowCount': !exists(json, 'current_user_followee_follow_count') ? undefined : json['current_user_followee_follow_count'], + 'doesCurrentUserFollow': !exists(json, 'does_current_user_follow') ? undefined : json['does_current_user_follow'], + 'doesCurrentUserSubscribe': !exists(json, 'does_current_user_subscribe') ? undefined : json['does_current_user_subscribe'], + 'doesFollowCurrentUser': !exists(json, 'does_follow_current_user') ? undefined : json['does_follow_current_user'], + 'handleLc': !exists(json, 'handle_lc') ? undefined : json['handle_lc'], + 'profileType': !exists(json, 'profile_type') ? undefined : json['profile_type'], + 'userId': !exists(json, 'user_id') ? undefined : json['user_id'], + 'hasCollectibles': !exists(json, 'has_collectibles') ? undefined : json['has_collectibles'], + 'allowAiAttribution': !exists(json, 'allow_ai_attribution') ? undefined : json['allow_ai_attribution'], + 'coinFlairMint': !exists(json, 'coin_flair_mint') ? undefined : json['coin_flair_mint'], + 'artistCoinBadge': !exists(json, 'artist_coin_badge') ? undefined : json['artist_coin_badge'], + 'coverPhotoSizes': !exists(json, 'cover_photo_sizes') ? undefined : json['cover_photo_sizes'], + 'coverPhotoCids': !exists(json, 'cover_photo_cids') ? undefined : json['cover_photo_cids'], + 'coverPhotoLegacy': !exists(json, 'cover_photo_legacy') ? undefined : json['cover_photo_legacy'], + 'profilePictureSizes': !exists(json, 'profile_picture_sizes') ? undefined : json['profile_picture_sizes'], + 'profilePictureCids': !exists(json, 'profile_picture_cids') ? undefined : json['profile_picture_cids'], + 'profilePictureLegacy': !exists(json, 'profile_picture_legacy') ? undefined : json['profile_picture_legacy'], }; } @@ -352,6 +548,34 @@ export function UserToJSON(value?: User | null): any { 'supporting_count': value.supportingCount, 'total_audio_balance': value.totalAudioBalance, 'wallet': value.wallet, + 'balance': value.balance, + 'associated_wallets_balance': value.associatedWalletsBalance, + 'total_balance': value.totalBalance, + 'payout_wallet': value.payoutWallet, + 'waudio_balance': value.waudioBalance, + 'associated_sol_wallets_balance': value.associatedSolWalletsBalance, + 'blocknumber': value.blocknumber, + 'created_at': value.createdAt === undefined ? undefined : (value.createdAt.toISOString()), + 'updated_at': value.updatedAt === undefined ? undefined : (value.updatedAt.toISOString()), + 'is_storage_v2': value.isStorageV2, + 'creator_node_endpoint': value.creatorNodeEndpoint, + 'current_user_followee_follow_count': value.currentUserFolloweeFollowCount, + 'does_current_user_follow': value.doesCurrentUserFollow, + 'does_current_user_subscribe': value.doesCurrentUserSubscribe, + 'does_follow_current_user': value.doesFollowCurrentUser, + 'handle_lc': value.handleLc, + 'profile_type': value.profileType, + 'user_id': value.userId, + 'has_collectibles': value.hasCollectibles, + 'allow_ai_attribution': value.allowAiAttribution, + 'coin_flair_mint': value.coinFlairMint, + 'artist_coin_badge': value.artistCoinBadge, + 'cover_photo_sizes': value.coverPhotoSizes, + 'cover_photo_cids': value.coverPhotoCids, + 'cover_photo_legacy': value.coverPhotoLegacy, + 'profile_picture_sizes': value.profilePictureSizes, + 'profile_picture_cids': value.profilePictureCids, + 'profile_picture_legacy': value.profilePictureLegacy, }; } 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/UserPlaylistLibraryContentsInner.ts b/packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibraryContentsInner.ts new file mode 100644 index 00000000000..f3524c34107 --- /dev/null +++ b/packages/sdk/src/sdk/api/generated/default/models/UserPlaylistLibraryContentsInner.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 UserPlaylistLibraryContentsInner + * + * @export + */ +export type UserPlaylistLibraryContentsInner = PlaylistLibraryExplorePlaylistIdentifier | PlaylistLibraryFolder | PlaylistLibraryPlaylistIdentifier; + +export function UserPlaylistLibraryContentsInnerFromJSON(json: any): UserPlaylistLibraryContentsInner { + return UserPlaylistLibraryContentsInnerFromJSONTyped(json, false); +} + +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 UserPlaylistLibraryContentsInnerToJSON(value?: UserPlaylistLibraryContentsInner | 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/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 e3db1f66a54..9f15f71149e 100644 --- a/packages/sdk/src/sdk/api/generated/default/models/index.ts +++ b/packages/sdk/src/sdk/api/generated/default/models/index.ts @@ -1,10 +1,13 @@ /* tslint:disable */ /* eslint-disable */ export * from './Access'; +export * from './AccessGate'; export * from './AccessInfoResponse'; export * from './Activity'; +export * from './AddManagerRequestBody'; export * from './AlbumBacklink'; export * from './AlbumsResponse'; +export * from './ApproveGrantRequestBody'; export * from './AuthorizedApp'; export * from './AuthorizedApps'; export * from './BalanceHistoryDataPoint'; @@ -13,7 +16,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'; @@ -37,6 +40,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'; @@ -44,17 +48,38 @@ 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 './CreateDeveloperAppResponse'; +export * from './CreateGrantRequestBody'; +export * from './CreatePlaylistRequestBody'; +export * from './CreatePlaylistRequestBodyCopyrightLine'; +export * from './CreatePlaylistRequestBodyProducerCopyrightLine'; +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 './CreateUserRequestBodyEvents'; +export * from './CreateUserResponse'; export * from './DashboardWalletUser'; export * from './DashboardWalletUsersResponse'; +export * from './DdexCopyright'; +export * from './DdexResourceContributor'; +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'; @@ -65,39 +90,52 @@ export * from './ExtendedPurchaseGate'; export * from './ExtendedTokenGate'; export * from './ExtendedUsdcGate'; export * from './Favorite'; +export * from './FavoriteRequestBody'; export * from './FavoritesResponse'; +export * from './FieldVisibility'; export * from './FollowGate'; export * from './FollowersResponse'; export * from './FollowingResponse'; +export * from './Genre'; export * from './GetChallenges'; export * from './GetSupportedUsers'; export * from './GetSupporters'; export * from './GetTipsResponse'; export * from './HistoryResponse'; export * from './ListenCount'; +export * from './MediaLink'; export * from './MonthlyAggregatePlay'; +export * from './Mood'; export * from './MutualFollowersResponse'; -export * from './NftCollection'; -export * from './NftGate'; +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'; export * from './PlaylistsResponse'; -export * from './PrizeClaimRequest'; +export * from './PrizeClaimRequestBody'; export * from './PrizeClaimResponse'; export * from './PrizePublic'; export * from './PrizesResponse'; export * from './ProfilePicture'; export * from './PurchasersResponse'; +export * from './ReactCommentRequestBody'; export * from './RedeemAmountResponse'; export * from './RelatedArtistResponse'; export * from './RemixParent'; +export * from './RemixParentWrite'; export * from './RemixedTrackAggregate'; export * from './RemixersResponse'; +export * from './RemixesResponse'; +export * from './RemixingResponse'; export * from './ReplyComment'; +export * from './Repost'; +export * from './RepostRequestBody'; export * from './Reposts'; export * from './RewardCodeErrorResponse'; export * from './RewardCodeResponse'; @@ -107,6 +145,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'; @@ -124,18 +164,31 @@ export * from './TrackArtwork'; export * from './TrackCommentCountResponse'; export * from './TrackCommentNotificationResponse'; export * from './TrackCommentsResponse'; +export * from './TrackDownloadRequestBody'; export * from './TrackElement'; +export * from './TrackElementWrite'; +export * from './TrackFavoritesResponse'; +export * from './TrackId'; export * from './TrackInspect'; export * from './TrackInspectList'; +export * from './TrackRepostsResponse'; export * from './TrackResponse'; export * from './TrackSearch'; +export * from './TracksCountResponse'; export * from './TracksResponse'; +export * from './TrendingIdsResponse'; export * from './TrendingPlaylistsResponse'; +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'; @@ -145,9 +198,12 @@ 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'; export * from './UserTracksRemixedResponse'; export * from './UsersResponse'; export * from './VerifyToken'; +export * from './WriteResponse'; 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/PlaylistFull.ts b/packages/sdk/src/sdk/api/generated/full/models/PlaylistFull.ts index 26422273a84..a2a91186915 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/PlaylistFull.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/PlaylistFull.ts @@ -314,7 +314,7 @@ export interface PlaylistFull { * @type {string} * @memberof PlaylistFull */ - parentalWarningType?: string; + parentalWarningType?: string | null; } /** diff --git a/packages/sdk/src/sdk/api/generated/full/models/PlaylistFullWithoutTracks.ts b/packages/sdk/src/sdk/api/generated/full/models/PlaylistFullWithoutTracks.ts index c9358f1be61..f95067480c5 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/PlaylistFullWithoutTracks.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/PlaylistFullWithoutTracks.ts @@ -314,7 +314,7 @@ export interface PlaylistFullWithoutTracks { * @type {string} * @memberof PlaylistFullWithoutTracks */ - parentalWarningType?: string; + parentalWarningType?: string | null; } /** 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/SearchPlaylistFull.ts b/packages/sdk/src/sdk/api/generated/full/models/SearchPlaylistFull.ts index 68a038cba89..fec116eeba0 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/SearchPlaylistFull.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/SearchPlaylistFull.ts @@ -314,7 +314,7 @@ export interface SearchPlaylistFull { * @type {string} * @memberof SearchPlaylistFull */ - parentalWarningType?: string; + parentalWarningType?: string | null; } /** diff --git a/packages/sdk/src/sdk/api/generated/full/models/SearchTrackFull.ts b/packages/sdk/src/sdk/api/generated/full/models/SearchTrackFull.ts index 115a4150fd5..928cb4700e1 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/SearchTrackFull.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/SearchTrackFull.ts @@ -518,7 +518,7 @@ export interface SearchTrackFull { * @type {string} * @memberof SearchTrackFull */ - parentalWarningType?: string; + parentalWarningType?: string | null; /** * Whether or not the owner has restricted streaming behind an access gate * @type {boolean} diff --git a/packages/sdk/src/sdk/api/generated/full/models/TrackFull.ts b/packages/sdk/src/sdk/api/generated/full/models/TrackFull.ts index e5dcdd01da7..effcff618ac 100644 --- a/packages/sdk/src/sdk/api/generated/full/models/TrackFull.ts +++ b/packages/sdk/src/sdk/api/generated/full/models/TrackFull.ts @@ -518,7 +518,7 @@ export interface TrackFull { * @type {string} * @memberof TrackFull */ - parentalWarningType?: string; + parentalWarningType?: string | null; /** * Whether or not the owner has restricted streaming behind an access gate * @type {boolean} 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'; diff --git a/packages/sdk/src/sdk/api/grants/GrantsApi.ts b/packages/sdk/src/sdk/api/grants/GrantsApi.ts index b40563fb798..fa76a10671b 100644 --- a/packages/sdk/src/sdk/api/grants/GrantsApi.ts +++ b/packages/sdk/src/sdk/api/grants/GrantsApi.ts @@ -1,19 +1,33 @@ -import type { UsersApi, Configuration, User } from '../../api/generated/default' +import type { + AddManagerRequest as GeneratedAddManagerRequest, + ApproveGrantRequest as GeneratedApproveGrantRequest, + Configuration, + CreateGrantRequest as GeneratedCreateGrantRequest, + RemoveManagerRequest as GeneratedRemoveManagerRequest, + RevokeGrantRequest as GeneratedRevokeGrantRequest, + User, + UsersApi +} from '../../api/generated/default' import type { EntityManagerService } from '../../services' -import { Action, EntityType } from '../../services/EntityManager/types' +import { + Action, + AdvancedOptions, + EntityType +} from '../../services/EntityManager/types' import { encodeHashId } from '../../utils/hashId' import { parseParams } from '../../utils/parseParams' import { - ApproveGrantSchema, - ApproveGrantRequest, - AddManagerRequest, AddManagerSchema, - CreateGrantRequest, + ApproveGrantSchema, CreateGrantSchema, - RevokeGrantRequest, + RemoveManagerSchema, RevokeGrantSchema, - RemoveManagerRequest + type EntityManagerAddManagerRequest, + type EntityManagerApproveGrantRequest, + type EntityManagerCreateGrantRequest, + type EntityManagerRemoveManagerRequest, + type EntityManagerRevokeGrantRequest } from './types' export class GrantsApi { @@ -24,11 +38,10 @@ export class GrantsApi { private readonly usersApi: UsersApi ) {} - /** - * When user authorizes app to perform actions on their behalf. - * For user-to-user grants, use `addManager`. - */ - async createGrant(params: CreateGrantRequest) { + async createGrantWithEntityManager( + params: EntityManagerCreateGrantRequest, + advancedOptions?: AdvancedOptions + ) { const { userId, appApiKey } = await parseParams( 'createGrant', CreateGrantSchema @@ -37,89 +50,122 @@ export class GrantsApi { return await this.entityManager.manageEntity({ userId, entityType: EntityType.GRANT, - entityId: 0, // Contract requires uint, but we don't actually need this field for this action. Just use 0. + entityId: 0, action: Action.CREATE, metadata: JSON.stringify({ grantee_address: `0x${appApiKey}` - }) + }), + ...advancedOptions }) } - /** - * When user authorizes another user to perform actions on their behalf. - * The grant has to be approved by the proposed manager. - */ - async addManager(params: AddManagerRequest) { + async createGrant( + params: EntityManagerCreateGrantRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.createGrantWithEntityManager(params) + } + const { userId, appApiKey } = await parseParams( + 'createGrant', + CreateGrantSchema + )(params) + const request: GeneratedCreateGrantRequest = { + id: encodeHashId(userId)!, + createGrantRequestBody: { appApiKey } + } + return await this.usersApi.createGrant(request, requestInit) + } + + async addManagerWithEntityManager( + params: EntityManagerAddManagerRequest, + advancedOptions?: AdvancedOptions + ) { const { userId, managerUserId } = await parseParams( 'addManager', AddManagerSchema )(params) - let managerUser: User | undefined - try { - managerUser = ( - await this.usersApi.getUser({ - id: encodeHashId(managerUserId)! - }) - ).data - if (!managerUser) { - throw new Error() - } - } catch (e) { - throw new Error( - '`managerUserId` passed to `addManager` method is invalid.' - ) - } + const managerUser = await this.getManagerUser(managerUserId, 'addManager') return await this.entityManager.manageEntity({ userId, entityType: EntityType.GRANT, - entityId: 0, // Contract requires uint, but we don't actually need this field for this action. Just use 0. + entityId: 0, action: Action.CREATE, metadata: JSON.stringify({ - grantee_address: managerUser!.ercWallet - }) + grantee_address: managerUser.ercWallet + }), + ...advancedOptions }) } - /** - * Revokes a user's manager access - can either be called by the manager user or the child user - */ - async removeManager(params: RemoveManagerRequest) { + async addManager( + params: EntityManagerAddManagerRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.addManagerWithEntityManager(params) + } const { userId, managerUserId } = await parseParams( 'addManager', AddManagerSchema )(params) - let managerUser: User | undefined - try { - managerUser = ( - await this.usersApi.getUser({ - id: encodeHashId(managerUserId)! - }) - ).data - if (!managerUser) { - throw new Error() + const request: GeneratedAddManagerRequest = { + id: encodeHashId(userId)!, + addManagerRequestBody: { + managerUserId: encodeHashId(managerUserId)! } - } catch (e) { - throw new Error( - '`managerUserId` passed to `removeManager` method is invalid.' - ) } + return await this.usersApi.addManager(request, requestInit) + } + + async removeManagerWithEntityManager( + params: EntityManagerRemoveManagerRequest, + advancedOptions?: AdvancedOptions + ) { + const { userId, managerUserId } = await parseParams( + 'removeManager', + RemoveManagerSchema + )(params) + const managerUser = await this.getManagerUser( + managerUserId, + 'removeManager' + ) return await this.entityManager.manageEntity({ userId, entityType: EntityType.GRANT, - entityId: 0, // Contract requires uint, but we don't actually need this field for this action. Just use 0. + entityId: 0, action: Action.DELETE, metadata: JSON.stringify({ - grantee_address: managerUser!.ercWallet - }) + grantee_address: managerUser.ercWallet + }), + ...advancedOptions }) } - /** - * When user revokes an app's authorization to perform actions on their behalf - */ - async revokeGrant(params: RevokeGrantRequest) { + async removeManager( + params: EntityManagerRemoveManagerRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.removeManagerWithEntityManager(params) + } + const { userId, managerUserId } = await parseParams( + 'removeManager', + RemoveManagerSchema + )(params) + const request: GeneratedRemoveManagerRequest = { + id: encodeHashId(userId)!, + managerUserId: encodeHashId(managerUserId)! + } + return await this.usersApi.removeManager(request, requestInit) + } + + async revokeGrantWithEntityManager( + params: EntityManagerRevokeGrantRequest, + advancedOptions?: AdvancedOptions + ) { const { userId, appApiKey } = await parseParams( 'revokeGrant', RevokeGrantSchema @@ -128,18 +174,37 @@ export class GrantsApi { return await this.entityManager.manageEntity({ userId, entityType: EntityType.GRANT, - entityId: 0, // Contract requires uint, but we don't actually need this field for this action. Just use 0. + entityId: 0, action: Action.DELETE, metadata: JSON.stringify({ grantee_address: `0x${appApiKey}` - }) + }), + ...advancedOptions }) } - /** - * Approve manager request - */ - async approveGrant(params: ApproveGrantRequest) { + async revokeGrant( + params: EntityManagerRevokeGrantRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.revokeGrantWithEntityManager(params) + } + const { userId, appApiKey } = await parseParams( + 'revokeGrant', + RevokeGrantSchema + )(params) + const request: GeneratedRevokeGrantRequest = { + id: encodeHashId(userId)!, + address: appApiKey + } + return await this.usersApi.revokeGrant(request, requestInit) + } + + async approveGrantWithEntityManager( + params: EntityManagerApproveGrantRequest, + advancedOptions?: AdvancedOptions + ) { const { userId, grantorUserId } = await parseParams( 'approveGrant', ApproveGrantSchema @@ -152,7 +217,45 @@ export class GrantsApi { action: Action.APPROVE, metadata: JSON.stringify({ grantor_user_id: grantorUserId - }) + }), + ...advancedOptions }) } + + async approveGrant( + params: EntityManagerApproveGrantRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.approveGrantWithEntityManager(params) + } + const { userId, grantorUserId } = await parseParams( + 'approveGrant', + ApproveGrantSchema + )(params) + const request: GeneratedApproveGrantRequest = { + id: encodeHashId(userId)!, + approveGrantRequestBody: { + grantorUserId: encodeHashId(grantorUserId)! + } + } + return await this.usersApi.approveGrant(request, requestInit) + } + + private async getManagerUser( + managerUserId: number, + operation: string + ): Promise { + const managerUser = ( + await this.usersApi.getUser({ + id: encodeHashId(managerUserId)! + }) + ).data + if (!managerUser?.ercWallet) { + throw new Error( + `\`managerUserId\` passed to \`${operation}\` method is invalid.` + ) + } + return managerUser + } } diff --git a/packages/sdk/src/sdk/api/grants/types.ts b/packages/sdk/src/sdk/api/grants/types.ts index 415170edb31..47bbb2ff45e 100644 --- a/packages/sdk/src/sdk/api/grants/types.ts +++ b/packages/sdk/src/sdk/api/grants/types.ts @@ -10,21 +10,23 @@ export const CreateGrantSchema = z.object({ }) }) -export type CreateGrantRequest = z.input +export type EntityManagerCreateGrantRequest = z.input export const AddManagerSchema = z.object({ userId: HashId, managerUserId: HashId }) -export type AddManagerRequest = z.input +export type EntityManagerAddManagerRequest = z.input export const RemoveManagerSchema = z.object({ userId: HashId, managerUserId: HashId }) -export type RemoveManagerRequest = z.input +export type EntityManagerRemoveManagerRequest = z.input< + typeof RemoveManagerSchema +> export const RevokeGrantSchema = z.object({ userId: HashId, @@ -33,11 +35,19 @@ export const RevokeGrantSchema = z.object({ }) }) -export type RevokeGrantRequest = z.input +export type EntityManagerRevokeGrantRequest = z.input export const ApproveGrantSchema = z.object({ userId: HashId, grantorUserId: HashId }) -export type ApproveGrantRequest = z.input +export type EntityManagerApproveGrantRequest = z.input< + typeof ApproveGrantSchema +> + +export type CreateGrantRequest = EntityManagerCreateGrantRequest +export type AddManagerRequest = EntityManagerAddManagerRequest +export type RemoveManagerRequest = EntityManagerRemoveManagerRequest +export type RevokeGrantRequest = EntityManagerRevokeGrantRequest +export type ApproveGrantRequest = EntityManagerApproveGrantRequest 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 160000c5848..6f8e04fc68f 100644 --- a/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts +++ b/packages/sdk/src/sdk/api/playlists/PlaylistsApi.ts @@ -10,42 +10,53 @@ 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 { Configuration, - PlaylistsApi as GeneratedPlaylistsApi + PlaylistsApi as GeneratedPlaylistsApi, + TracksApi, + type DeletePlaylistRequest, + type RepostPlaylistRequest, + type UnrepostPlaylistRequest, + type FavoritePlaylistRequest, + type UnfavoritePlaylistRequest, + type SharePlaylistRequest, + type UpdateTrackRequestBody, + type CreateTrackRequestBody } 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, + type UploadPlaylistRequest } from './types' // Returns current timestamp in seconds, which is the expected @@ -57,6 +68,7 @@ const getCurrentTimestamp = () => { export class PlaylistsApi extends GeneratedPlaylistsApi { private readonly trackUploadHelper: TrackUploadHelper + private readonly tracksApi: TracksApi constructor( configuration: Configuration, private readonly storage: StorageService, @@ -64,6 +76,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]') } @@ -71,8 +84,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,22 +98,172 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { return await this.createPlaylistInternal(parsedParameters, advancedOptions) } + override async createPlaylist( + params: CreatePlaylistRequestWithFiles, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const { metadata } = params + return await this.createPlaylistWithEntityManager({ + userId: params.userId, + metadata + }) + } + return super.createPlaylist(params, requestInit) + } + /** @hidden * Upload a playlist * Uploads the specified tracks and combines them into a playlist */ async uploadPlaylist( params: UploadPlaylistRequest, - advancedOptions?: AdvancedOptions + requestInit?: RequestInit ) { - // Parse inputs - const parsedParameters = await parseParams( + const { metadata: playlistMetadata, trackMetadatas } = params + const { userId, imageFile, audioFiles, onProgress } = await parseParams( 'uploadPlaylist', UploadPlaylistSchema )(params) - // Call uploadPlaylistInternal with parsed inputs - return await this.uploadPlaylistInternal(parsedParameters, advancedOptions) + 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.transformTrackUploadMetadataV2(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.populateTrackMetadataWithUploadResponseV2( + trackMetadata, + audioResponse, + imageUploadResponse + ) as CreateTrackRequestBody + + if (this.entityManager) { + 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) + }) + }) + + return trackId + } + + const res = await this.tracksApi.createTrack( + { + userId: encodeHashId(userId)!, + metadata: updatedMetadata + }, + requestInit + ) + 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) + }) + }) + + 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 + }, + requestInit + ) } /** @hidden @@ -196,8 +359,8 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { /** @hidden * Update a playlist */ - async updatePlaylist( - params: UpdatePlaylistRequest, + async updatePlaylistWithEntityManager( + params: EntityManagerUpdatePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -206,15 +369,57 @@ 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) { + return await this.updatePlaylistWithEntityManager({ + userId: params.userId, + playlistId: params.playlistId, + metadata + }) + } + return super.updatePlaylist(params, requestInit) } /** @hidden * Delete a playlist */ - async deletePlaylist( - params: DeletePlaylistRequest, + async deletePlaylistWithEntityManager( + params: EntityManagerDeletePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -232,11 +437,21 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async deletePlaylist( + params: DeletePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.deletePlaylistWithEntityManager(params) + } + return super.deletePlaylist(params, requestInit) + } + /** @hidden * Favorite a playlist */ - async favoritePlaylist( - params: FavoritePlaylistRequest, + async favoritePlaylistWithEntityManager( + params: EntityManagerFavoritePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -255,11 +470,21 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async favoritePlaylist( + params: FavoritePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.favoritePlaylistWithEntityManager(params) + } + return super.favoritePlaylist(params, requestInit) + } + /** @hidden * Unfavorite a playlist */ - async unfavoritePlaylist( - params: UnfavoritePlaylistRequest, + async unfavoritePlaylistWithEntityManager( + params: EntityManagerUnfavoritePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -277,16 +502,26 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async unfavoritePlaylist( + params: UnfavoritePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.unfavoritePlaylistWithEntityManager(params) + } + return super.unfavoritePlaylist(params, requestInit) + } + /** @hidden * Repost a playlist */ - async repostPlaylist( - params: RepostPlaylistRequest, + async repostPlaylistWithEntityManager( + params: EntityManagerRepostPlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs const { userId, playlistId, metadata } = await parseParams( - 'respostPlaylist', + 'repostPlaylist', RepostPlaylistSchema )(params) @@ -300,11 +535,27 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async repostPlaylist( + params: RepostPlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + // Map repostRequestBody (generated API) to metadata (entity manager schema) + const entityManagerParams = { + playlistId: params.playlistId, + userId: params.userId, + metadata: params.repostRequestBody + } + return await this.repostPlaylistWithEntityManager(entityManagerParams) + } + return super.repostPlaylist(params, requestInit) + } + /** @hidden * Unrepost a playlist */ - async unrepostPlaylist( - params: FavoritePlaylistRequest, + async unrepostPlaylistWithEntityManager( + params: EntityManagerUnrepostPlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -322,11 +573,21 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async unrepostPlaylist( + params: UnrepostPlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.unrepostPlaylistWithEntityManager(params) + } + return super.unrepostPlaylist(params, requestInit) + } + /** @hidden * Share a playlist */ - async sharePlaylist( - params: SharePlaylistRequest, + async sharePlaylistWithEntityManager( + params: EntityManagerSharePlaylistRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -344,14 +605,23 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { }) } + override async sharePlaylist( + params: SharePlaylistRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + return await this.sharePlaylistWithEntityManager(params) + } + 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, - playlistMetadata: PlaylistMetadata - ) { + private combineMetadata< + T extends CreateTrackRequestBody | UpdateTrackRequestBody + >(trackMetadata: T, playlistMetadata: PlaylistMetadata) { const metadata = trackMetadata if (!metadata.mood) metadata.mood = playlistMetadata.mood @@ -385,8 +655,8 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { userId: string playlistId: string updateMetadata: ( - fetchedMetadata: UpdatePlaylistRequest['metadata'] - ) => UpdatePlaylistRequest['metadata'] + fetchedMetadata: EntityManagerUpdatePlaylistRequest['metadata'] + ) => EntityManagerUpdatePlaylistRequest['metadata'] }, advancedOptions?: AdvancedOptions ) { @@ -405,220 +675,32 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { UpdatePlaylistMetadataSchema.shape ) - return await this.updatePlaylist( + const picked = pick(playlist, supportedUpdateFields) as Record< + string, + unknown + > + const metadataForUpdate: EntityManagerUpdatePlaylistRequest['metadata'] = { + ...picked, + ...(picked.releaseDate != null + ? { + releaseDate: + typeof picked.releaseDate === 'string' + ? new Date(picked.releaseDate) + : (picked.releaseDate as Date) + } + : {}) + } + + return await this.updatePlaylistWithEntityManager( { userId, playlistId, - metadata: updateMetadata(pick(playlist, supportedUpdateFields)) + metadata: updateMetadata(metadataForUpdate) }, advancedOptions ) } - /** @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 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 @@ -681,7 +763,7 @@ export class PlaylistsApi extends GeneratedPlaylistsApi { return { ...response, - playlistId: encodeHashId(playlistId) + playlistId: encodeHashId(playlistId) ?? undefined } } diff --git a/packages/sdk/src/sdk/api/playlists/types.ts b/packages/sdk/src/sdk/api/playlists/types.ts index 25e147c85e4..18e549b79c7 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,50 @@ 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 CreatePlaylistRequestWithFiles = CreatePlaylistRequest & + PlaylistImageParameters + +export type UpdatePlaylistRequestWithImage = UpdatePlaylistRequest & + PlaylistImageParameters + export const PublishPlaylistSchema = z .object({ userId: HashId, @@ -189,7 +206,9 @@ export const DeletePlaylistSchema = z }) .strict() -export type DeletePlaylistRequest = z.input +export type EntityManagerDeletePlaylistRequest = z.input< + typeof DeletePlaylistSchema +> export const FavoritePlaylistSchema = z .object({ @@ -202,14 +221,16 @@ export const FavoritePlaylistSchema = z * Is this a save of a repost? Used to dispatch notifications * when a user favorites another user's repost */ - isSaveOfRepost: z.boolean() + isSaveOfRepost: z.optional(z.boolean()) }) .strict() ) }) .strict() -export type FavoritePlaylistRequest = z.input +export type EntityManagerFavoritePlaylistRequest = z.input< + typeof FavoritePlaylistSchema +> export const UnfavoritePlaylistSchema = z .object({ @@ -218,7 +239,9 @@ export const UnfavoritePlaylistSchema = z }) .strict() -export type UnfavoritePlaylistRequest = z.input +export type EntityManagerUnfavoritePlaylistRequest = z.input< + typeof UnfavoritePlaylistSchema +> export const RepostPlaylistSchema = z .object({ @@ -229,16 +252,18 @@ export const RepostPlaylistSchema = z .object({ /** * Is this a repost of a repost? Used to dispatch notifications - * when a user favorites another user's repost + * when a user reposts content that someone they follow has already reposted */ - isRepostOfRepost: z.boolean() + isRepostOfRepost: z.optional(z.boolean()) }) .strict() ) }) .strict() -export type RepostPlaylistRequest = z.input +export type EntityManagerRepostPlaylistRequest = z.input< + typeof RepostPlaylistSchema +> export const UnrepostPlaylistSchema = z .object({ @@ -247,7 +272,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 +283,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..3fd5f6b3285 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 { @@ -57,6 +61,79 @@ export class TrackUploadHelper extends BaseAPI { return metadata } + public transformTrackUploadMetadataV2< + T extends CreateTrackRequestBody | UpdateTrackRequestBody + >(inputMetadata: T, userId: number): T { + const metadata: T = { + ...inputMetadata, + ownerId: userId + } + + const isStreamGated = metadata.streamConditions !== undefined + const isUsdcGated = 'usdc_purchase' in (metadata.streamConditions ?? {}) + const isUnlisted = metadata.isUnlisted + + // If track is stream gated and not usdc purchase gated, set remixes to false + if (isStreamGated && !isUsdcGated && metadata.fieldVisibility) { + metadata.fieldVisibility.remixes = false + } + + // 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, + tags: true, + share: true, + playCount: true + } + } + return metadata + } + + public populateTrackMetadataWithUploadResponseV2< + T extends CreateTrackRequestBody | UpdateTrackRequestBody + >( + trackMetadata: T, + audioResponse?: UploadResponse, + coverArtResponse?: UploadResponse + ): T { + let updated = { + ...trackMetadata + } + if (audioResponse) { + updated = { + ...updated, + trackCid: audioResponse.results['320'], + previewCid: + trackMetadata.previewStartSeconds !== undefined && + trackMetadata.previewStartSeconds !== null + ? audioResponse.results[ + `320_preview|${trackMetadata.previewStartSeconds}` + ] + : trackMetadata.previewCid, + origFileCid: audioResponse.orig_file_cid, + origFilename: audioResponse.orig_filename || trackMetadata.origFilename, + 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 + } + } + if (coverArtResponse) { + updated = { + ...updated, + coverArtSizes: coverArtResponse.orig_file_cid + } + } + return updated + } + public populateTrackMetadataWithUploadResponse( trackMetadata: Partial, audioResponse?: UploadResponse, @@ -97,19 +174,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.test.ts b/packages/sdk/src/sdk/api/tracks/TracksApi.test.ts index 6110b84e7d7..0d69af4cbda 100644 --- a/packages/sdk/src/sdk/api/tracks/TracksApi.test.ts +++ b/packages/sdk/src/sdk/api/tracks/TracksApi.test.ts @@ -146,13 +146,15 @@ describe('TracksApi', () => { describe('uploadTrack', () => { it('uploads a track if valid metadata is provided', async () => { - const result = await tracks.uploadTrack({ + const result = await tracks.createTrack({ userId: '7eP5n', imageFile: { buffer: pngFile, name: 'coverArt' }, metadata: { + trackCid: + 'bafkreihzvsc5jqhxzdygntlqqd7kqtx3lul77d22v54a47m26n5q426z7i', title: 'BachGavotte', genre: Genre.ELECTRONIC, mood: Mood.TENDER @@ -172,13 +174,14 @@ describe('TracksApi', () => { it('throws an error if invalid metadata is provided', async () => { await expect(async () => { - await tracks.uploadTrack({ + await tracks.createTrack({ userId: '7eP5n', imageFile: { buffer: pngFile, name: 'coverArt' }, metadata: { + // intentionally missing trackCid, genre title: 'BachGavotte' } as any, audioFile: { diff --git a/packages/sdk/src/sdk/api/tracks/TracksApi.ts b/packages/sdk/src/sdk/api/tracks/TracksApi.ts index 40e18e3a840..03e0f022407 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, - UploadTrackRequest, + EntityManagerUpdateTrackRequest, PurchaseTrackRequest, PurchaseTrackSchema, GetPurchaseTrackInstructionsRequest, GetPurchaseTrackInstructionsSchema, - RecordTrackDownloadRequest, + EntityManagerRecordTrackDownloadRequest, RecordTrackDownloadSchema, UploadTrackFilesRequest, - UploadTrackSchema, UpdateTrackSchema, UploadTrackFilesSchema, ShareTrackSchema, - ShareTrackRequest, + EntityManagerShareTrackRequest, type PublishTrackRequest, PublishTrackSchema, type PublishStemRequest, + type UploadTrackFilesTask, + type UpdateTrackRequestWithFiles, + type CreateTrackRequestWithFiles, PublishStemSchema, - type UploadTrackFilesTask + UploadTrackSchema } 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'}}`, @@ -346,17 +352,12 @@ export class TracksApi extends GeneratedTracksApi { } } - /** - * 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, @@ -368,80 +369,109 @@ export class TracksApi extends GeneratedTracksApi { onProgress: params.onProgress }).start() - if (!audioUploadResponse || !imageUploadResponse) { - throw new Error('uploadTrack: Missing upload responses') - } + metadata = this.trackUploadHelper.transformTrackUploadMetadataV2( + metadata, + decodeHashId(params.userId)! + ) + + metadata = this.trackUploadHelper.populateTrackMetadataWithUploadResponseV2( + metadata, + audioUploadResponse, + imageUploadResponse + ) - // Write track metadata to chain - return this.publishTrack( + if (this.entityManager) { + const { metadata } = await parseParams( + 'createTrack', + UploadTrackSchema + )(params) + return this.writeTrackToChain(params.userId, metadata) + } + return super.createTrack( { userId: params.userId, - metadata: params.metadata, - audioUploadResponse, - imageUploadResponse + metadata }, - advancedOptions + requestInit ) } /** @hidden - * Update a track + * Update a track with entity manager */ - async updateTrack( - params: UpdateTrackRequest, + async updateTrackWithEntityManager( + params: EntityManagerUpdateTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs - const { - userId, - trackId, - audioFile, - imageFile, - metadata: parsedMetadata, - onProgress, - generatePreview - } = await parseParams('updateTrack', UpdateTrackSchema)(params) + const { userId, trackId, metadata } = await parseParams( + 'updateTrack', + UpdateTrackSchema + )(params) - // Transform metadata - const metadata = this.trackUploadHelper.transformTrackUploadMetadata( - parsedMetadata, - userId - ) + // Write metadata to chain + return await this.entityManager.manageEntity({ + userId, + entityType: EntityType.TRACK, + entityId: trackId, + action: Action.UPDATE, + metadata: JSON.stringify({ + cid: '', + data: { + ...snakecaseKeys(metadata), + download_conditions: + metadata.downloadConditions && + snakecaseKeys(metadata.downloadConditions), + stream_conditions: + metadata.streamConditions && + snakecaseKeys(metadata.streamConditions), + stem_of: metadata.stemOf && snakecaseKeys(metadata.stemOf) + } + }), + ...advancedOptions + }) + } + override async updateTrack( + params: UpdateTrackRequestWithFiles, + requestInit?: RequestInit + ) { + // Upload files + let metadata = params.metadata const { audioUploadResponse, imageUploadResponse } = await this.uploadTrackFiles({ - audioFile, - imageFile, + audioFile: params.audioFile, + imageFile: params.imageFile, fileMetadata: { - placementHosts: parsedMetadata.placementHosts, - previewStartSeconds: parsedMetadata.previewStartSeconds + placementHosts: params.metadata.placementHosts, + previewStartSeconds: params.metadata.previewStartSeconds }, - onProgress + onProgress: params.onProgress }).start() - // Update metadata to include uploaded CIDs - const updatedMetadata = - this.trackUploadHelper.populateTrackMetadataWithUploadResponse( - metadata, - audioUploadResponse, - imageUploadResponse - ) + metadata = this.trackUploadHelper.transformTrackUploadMetadataV2( + metadata, + decodeHashId(params.userId)! + ) + + metadata = this.trackUploadHelper.populateTrackMetadataWithUploadResponseV2( + 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') - } - if (!updatedMetadata.audioUploadId) { - throw new Error('Missing required audio_upload_id') - } - + if ( + params.generatePreview && + metadata.previewStartSeconds !== undefined && + !params.audioFile + ) { const previewCid = await retry3( async () => await this.storage.generatePreview({ - cid: updatedMetadata.trackCid!, - secondOffset: updatedMetadata.previewStartSeconds! + cid: metadata.trackCid!, + secondOffset: metadata.previewStartSeconds! }), (e) => { this.logger.info('Retrying generatePreview', e) @@ -449,37 +479,35 @@ export class TracksApi extends GeneratedTracksApi { ) // Update metadata to include updated preview CID - updatedMetadata.previewCid = previewCid + metadata.previewCid = previewCid } - // Write metadata to chain - return await this.entityManager.manageEntity({ - userId, - entityType: EntityType.TRACK, - entityId: trackId, - action: Action.UPDATE, - metadata: JSON.stringify({ - cid: '', - data: { - ...snakecaseKeys(updatedMetadata), - download_conditions: - updatedMetadata.downloadConditions && - snakecaseKeys(updatedMetadata.downloadConditions), - stream_conditions: - updatedMetadata.streamConditions && - snakecaseKeys(updatedMetadata.streamConditions), - stem_of: metadata.stemOf && snakecaseKeys(metadata.stemOf) - } - }), - ...advancedOptions - }) + 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: params.metadata + }, + requestInit + ) } /** @hidden * Delete a track */ - async deleteTrack( - params: DeleteTrackRequest, + async deleteTrackWithEntityManager( + params: EntityManagerDeleteTrackRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -497,11 +525,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 +562,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 +598,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 +634,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 +671,30 @@ export class TracksApi extends GeneratedTracksApi { }) } + override async repostTrack( + params: RepostTrackRequest, + requestInit?: RequestInit + ) { + if (this.entityManager) { + const entityManagerParams = { + trackId: params.trackId, + userId: params.userId, + metadata: params.repostRequestBody + } + const res = await this.repostTrackWithEntityManager(entityManagerParams) + 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 +712,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 +759,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 +797,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..94b0625765c 100644 --- a/packages/sdk/src/sdk/api/tracks/types.ts +++ b/packages/sdk/src/sdk/api/tracks/types.ts @@ -9,10 +9,14 @@ 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, + type CreateTrackRequest +} from '../generated/default' import { MAX_DESCRIPTION_LENGTH } from './constants' @@ -78,22 +82,29 @@ 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() export const UploadStemMetadataSchema = z.object({ - category: z - .enum(Object.values(StemCategory) as [StemCategory, ...StemCategory[]]) - .default(StemCategory.OTHER), + category: z.enum( + Object.values(StemCategory) as [StemCategory, ...StemCategory[]] + ), parentTrackId: HashId }) 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 +115,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 +136,6 @@ export const UploadTrackMetadataSchema = z.object({ downloadConditions: z .optional( z.union([ - CollectibleGatedConditions, FollowGatedConditions, TipGatedConditions, USDCPurchaseConditions, @@ -157,7 +158,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 +173,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 +278,7 @@ export const UpdateTrackSchema = z }) .strict() -export type UpdateTrackRequest = Omit< +export type EntityManagerUpdateTrackRequest = Omit< z.input, 'onProgress' > & { @@ -291,7 +292,7 @@ export const DeleteTrackSchema = z }) .strict() -export type DeleteTrackRequest = z.input +export type EntityManagerDeleteTrackRequest = z.input export const FavoriteTrackSchema = z .object({ @@ -304,14 +305,16 @@ export const FavoriteTrackSchema = z * Is this a save of a repost? Used to dispatch notifications * when a user favorites another user's repost */ - isSaveOfRepost: z.boolean() + isSaveOfRepost: z.optional(z.boolean()) }) .strict() ) }) .strict() -export type FavoriteTrackRequest = z.input +export type EntityManagerFavoriteTrackRequest = z.input< + typeof FavoriteTrackSchema +> export const UnfavoriteTrackSchema = z .object({ @@ -320,7 +323,9 @@ export const UnfavoriteTrackSchema = z }) .strict() -export type UnfavoriteTrackRequest = z.input +export type EntityManagerUnfavoriteTrackRequest = z.input< + typeof UnfavoriteTrackSchema +> export const RepostTrackSchema = z .object({ @@ -331,16 +336,16 @@ export const RepostTrackSchema = z .object({ /** * Is this a repost of a repost? Used to dispatch notifications - * when a user favorites another user's repost + * when a user reposts content that someone they follow has already reposted */ - isRepostOfRepost: z.boolean() + isRepostOfRepost: z.optional(z.boolean()) }) .strict() ) }) .strict() -export type RepostTrackRequest = z.input +export type EntityManagerRepostTrackRequest = z.input export const UnrepostTrackSchema = z .object({ @@ -349,7 +354,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 +372,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 +482,17 @@ export type UploadTrackFilesTask = { }> abort: () => void } + +export type TrackFileUploadParams = { + audioFile?: z.input + imageFile?: z.input + onProgress?: UploadTrackFilesProgressHandler + /** When true, regenerate the track preview (e.g. when preview start or track CID changed). Used for update. */ + generatePreview?: boolean +} + +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..39da127b43a 100644 --- a/packages/sdk/src/sdk/api/users/UsersApi.test.ts +++ b/packages/sdk/src/sdk/api/users/UsersApi.test.ts @@ -104,7 +104,6 @@ describe('UsersApi', () => { audiusWalletClient, endpoint: 'https://discoveryprovider.audius.co' }), - new Logger(), claimableTokens, solanaClient, emailEncryption @@ -117,7 +116,8 @@ 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({ + id: '7eP5n', userId: '7eP5n', profilePictureFile: { buffer: pngFile, @@ -143,7 +143,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,7 +159,8 @@ describe('UsersApi', () => { it('throws an error if invalid metadata is provided', async () => { await expect(async () => { - await users.updateProfile({ + await users.updateUser({ + id: '7eP5n', userId: '7eP5n', metadata: { asdf: '123' @@ -169,7 +171,8 @@ describe('UsersApi', () => { it('throws an error if invalid request is sent', async () => { await expect(async () => { - await users.updateProfile({ + await users.updateUser({ + id: '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 01e7231e162..6a880dc609b 100644 --- a/packages/sdk/src/sdk/api/users/UsersApi.ts +++ b/packages/sdk/src/sdk/api/users/UsersApi.ts @@ -9,31 +9,29 @@ import { EntityManagerService, EntityType } from '../../services/EntityManager/types' -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' -import { retry3 } from '../../utils/retry' import { Configuration, DownloadPurchasesAsCSVRequest, DownloadSalesAsCSVRequest, DownloadUSDCWithdrawalsAsCSVRequest, - UsersApi as GeneratedUsersApi + UsersApi as GeneratedUsersApi, + type UserPlaylistLibrary } from '../generated/default' import * as runtime from '../generated/default/runtime' import { AddAssociatedWalletRequest, AddAssociatedWalletSchema, - CreateUserRequest, CreateUserSchema, EmailRequest, EmailSchema, - FollowUserRequest, + EntityManagerFollowUserRequest, FollowUserSchema, RemoveAssociatedWalletRequest, RemoveAssociatedWalletSchema, @@ -41,16 +39,21 @@ import { SendTipReactionRequestSchema, SendTipRequest, SendTipSchema, - SubscribeToUserRequest, + EntityManagerSubscribeToUserRequest, SubscribeToUserSchema, - UnfollowUserRequest, + EntityManagerUnfollowUserRequest, UnfollowUserSchema, - UnsubscribeFromUserRequest, + EntityManagerUnsubscribeFromUserRequest, UnsubscribeFromUserSchema, UpdateCollectiblesRequest, UpdateCollectiblesSchema, - UpdateProfileRequest, - UpdateProfileSchema + UpdateProfileSchema, + type EntityManagerCreateUserRequest, + type EntityManagerUpdateProfileRequest, + type UpdateUserRequestWithFiles, + type CreateUserRequestWithFiles, + type UserFileUploadParams, + type EntityManagerPlaylistLibraryContents } from './types' export class UsersApi extends GeneratedUsersApi { @@ -58,13 +61,11 @@ export class UsersApi extends GeneratedUsersApi { configuration: Configuration, private readonly storage: StorageService, private readonly entityManager: EntityManagerService, - private readonly logger: LoggerService, private readonly claimableTokens: ClaimableTokensClient, private readonly solanaClient: SolanaClient, private readonly emailEncryption: EmailEncryptionService ) { super(configuration) - this.logger = logger.createPrefixedLogger('[users-api]') } /** @hidden @@ -87,12 +88,14 @@ export class UsersApi extends GeneratedUsersApi { /** @hidden * Create a user */ - async createUser( - params: CreateUserRequest, + async createUserWithEntityManager( + 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) { @@ -100,59 +103,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() @@ -169,7 +120,29 @@ export class UsersApi extends GeneratedUsersApi { ...advancedOptions }) - return { blockHash, blockNumber, metadata: updatedMetadata } + return { blockHash, blockNumber, metadata } + } + + override async createUser( + params: CreateUserRequestWithFiles, + requestInit?: RequestInit + ) { + const metadata = await this.updateMetadataWithFiles(params.metadata, params) + if (this.entityManager) { + const res = await this.createUserWithEntityManager({ + metadata + }) + return { + success: true, + transactionHash: res.blockHash + } + } + return super.createUser( + { + metadata + }, + requestInit + ) } /** @hidden @@ -205,66 +178,15 @@ export class UsersApi extends GeneratedUsersApi { /** @hidden * Update a user profile */ - async updateProfile( - params: UpdateProfileRequest, + 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({ @@ -274,17 +196,118 @@ 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: EntityManagerPlaylistLibraryContents = [] + 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 */ - async followUser( - params: FollowUserRequest, + async followUserWithEntityManager( + params: EntityManagerFollowUserRequest, advancedOptions?: AdvancedOptions ) { // Parse inputs @@ -302,11 +325,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 +363,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 +401,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 +439,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..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' @@ -34,7 +35,7 @@ export const CreateUserSchema = z.object({ .strict() }) -export type CreateUserRequest = Omit< +export type EntityManagerCreateUserRequest = Omit< z.input, 'onProgress' > & { @@ -100,6 +101,10 @@ const PlaylistLibrarySchema = z.object({ ) }) +export type EntityManagerPlaylistLibraryContents = z.input< + typeof PlaylistLibrarySchema +>['contents'] + export const UpdateProfileSchema = z .object({ userId: HashId, @@ -132,7 +137,7 @@ export const UpdateProfileSchema = z }) .strict() -export type UpdateProfileRequest = Omit< +export type EntityManagerUpdateProfileRequest = Omit< z.input, 'onProgress' > & { @@ -148,7 +153,7 @@ export const FollowUserSchema = z }) .strict() -export type FollowUserRequest = z.input +export type EntityManagerFollowUserRequest = z.input export const UnfollowUserSchema = z .object({ @@ -157,7 +162,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 +173,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 +184,7 @@ export const UnsubscribeFromUserSchema = z }) .strict() -export type UnsubscribeFromUserRequest = z.input< +export type EntityManagerUnsubscribeFromUserRequest = z.input< typeof UnsubscribeFromUserSchema > @@ -279,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 diff --git a/packages/sdk/src/sdk/index.ts b/packages/sdk/src/sdk/index.ts index 6680447650b..33d7fe50be2 100644 --- a/packages/sdk/src/sdk/index.ts +++ b/packages/sdk/src/sdk/index.ts @@ -29,14 +29,29 @@ 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' -export * from './api/grants/types' +export type { + AddManagerRequest, + ApproveGrantRequest, + CreateGrantRequest, + EntityManagerAddManagerRequest, + EntityManagerApproveGrantRequest, + EntityManagerCreateGrantRequest, + EntityManagerRemoveManagerRequest, + EntityManagerRevokeGrantRequest, + RemoveManagerRequest, + RevokeGrantRequest +} from './api/grants/types' +export { + AddManagerSchema, + ApproveGrantSchema, + CreateGrantSchema, + RemoveManagerSchema, + RevokeGrantSchema +} from './api/grants/types' export * from './services' export { productionConfig } from './config/production' export { developmentConfig } from './config/development' diff --git a/packages/sdk/src/sdk/sdk.ts b/packages/sdk/src/sdk/sdk.ts index 008cbb12b17..9669a1efb6d 100644 --- a/packages/sdk/src/sdk/sdk.ts +++ b/packages/sdk/src/sdk/sdk.ts @@ -455,7 +455,6 @@ const initializeApis = ({ apiClientConfig, services.storage, services.entityManager, - services.logger, services.claimableTokensClient, services.solanaClient, services.emailEncryptionService 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 = { diff --git a/packages/web/src/common/store/cache/collections/createAlbumSaga.ts b/packages/web/src/common/store/cache/collections/createAlbumSaga.ts index 90e7df94136..bca976e522c 100644 --- a/packages/web/src/common/store/cache/collections/createAlbumSaga.ts +++ b/packages/web/src/common/store/cache/collections/createAlbumSaga.ts @@ -168,11 +168,20 @@ function* createAndConfirmAlbum( throw new Error('No userId set, cannot create album') } + const metadata = albumMetadataForCreateWithSDK(formFields) + metadata.playlistContents = initTrack + ? [ + { + trackId: Id.parse(initTrack.track_id), + timestamp: Date.now() / 1000 + } + ] + : undefined + yield* call([sdk.albums, sdk.albums.createAlbum], { userId: Id.parse(userId), albumId: Id.parse(albumId), - trackIds: initTrack ? [Id.parse(initTrack.track_id)] : undefined, - metadata: albumMetadataForCreateWithSDK(formFields) + metadata }) const { data: album } = yield* call( diff --git a/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts b/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts index 44ca8969bb7..71976c8067d 100644 --- a/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts +++ b/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts @@ -191,11 +191,20 @@ function* createAndConfirmPlaylist( throw new Error('No userId set, cannot repost collection') } + const metadata = playlistMetadataForCreateWithSDK(formFields) + metadata.playlistId = Id.parse(playlistId) + metadata.playlistContents = initTrack + ? [ + { + timestamp: Math.round(Date.now() / 1000), // must use seconds + trackId: Id.parse(initTrack.track_id) + } + ] + : [] + yield* call([sdk.playlists, sdk.playlists.createPlaylist], { userId: Id.parse(userId), - playlistId: Id.parse(playlistId), - trackIds: initTrack ? [Id.parse(initTrack.track_id)] : undefined, - metadata: playlistMetadataForCreateWithSDK(formFields) + metadata }) // Merge the confirmed playlist with the optimistic playlist, preferring 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/common/store/pages/deactivate-account/sagas.ts b/packages/web/src/common/store/pages/deactivate-account/sagas.ts index cdf81d012ac..ee69facc4bc 100644 --- a/packages/web/src/common/store/pages/deactivate-account/sagas.ts +++ b/packages/web/src/common/store/pages/deactivate-account/sagas.ts @@ -6,7 +6,6 @@ import { getContext, confirmerActions, confirmerSelectors, - confirmTransaction, getSDK } from '@audius/common/store' import { waitForValue } from '@audius/common/utils' @@ -37,22 +36,10 @@ function* handleDeactivateAccount() { DEACTIVATE_CONFIRMATION_UID, function* () { yield* put(make(Name.DEACTIVATE_ACCOUNT_REQUEST, {})) - const result = yield* call(audiusBackendInstance.updateCreator, { + yield* call(audiusBackendInstance.updateCreator, { metadata: { ...userMetadata, is_deactivated: true }, sdk }) - if (!result) return - const { blockHash, blockNumber } = result - const confirmed = yield* call( - confirmTransaction, - blockHash, - blockNumber - ) - if (!confirmed) { - throw new Error( - `Could not confirm account deactivation for user ${accountUserId}` - ) - } }, // @ts-ignore: confirmer is untyped function* () { diff --git a/packages/web/src/common/store/pages/signon/sagas.ts b/packages/web/src/common/store/pages/signon/sagas.ts index 1fe4fd16fdc..bbb5cd7ffa3 100644 --- a/packages/web/src/common/store/pages/signon/sagas.ts +++ b/packages/web/src/common/store/pages/signon/sagas.ts @@ -51,9 +51,10 @@ import { } from '@audius/common/utils' import { OptionalId, - CreateUserRequest, + CreateUserRequestWithFiles, Id, - UpdateProfileRequest + decodeHashId, + type UpdateUserRequestWithFiles } from '@audius/sdk' import { isEmpty } from 'lodash' import { @@ -491,18 +492,19 @@ function* signUp() { throw new Error('Account user ID does not exist') } userId = account.user.user_id - const completeProfileMetadataRequest: UpdateProfileRequest = { - userId: Id.parse(userId), - profilePictureFile: signOn.profileImage?.file as File, - metadata: { - location: location ?? undefined, - name, - handle + const completeProfileMetadataRequest: UpdateUserRequestWithFiles = + { + id: Id.parse(userId), + userId: Id.parse(userId), + profilePictureFile: signOn.profileImage?.file as File, + metadata: { + location: location ?? undefined, + name, + handle + } } - } - - const { blockHash, blockNumber } = yield* call( - [sdk.users, sdk.users.updateProfile], + yield* call( + [sdk.users, sdk.users.updateUser], completeProfileMetadataRequest ) @@ -516,7 +518,6 @@ function* signUp() { yield* fork(sendPostSignInRecoveryEmail, { handle, email }) - yield* call(confirmTransaction, blockHash, blockNumber) yield* put( make(Name.CREATE_ACCOUNT_COMPLETE_GUEST_PROFILE, { handle, @@ -555,7 +556,8 @@ function* signUp() { sdk.services.audiusWalletClient.getAddresses ]) - const events: CreateUserRequest['metadata']['events'] = {} + const events: CreateUserRequestWithFiles['metadata']['events'] = + {} if (referrer) { events.referrer = OptionalId.parse(referrer) } @@ -563,7 +565,7 @@ function* signUp() { events.isMobileUser = true } - const createUserMetadata: CreateUserRequest = { + const createUserMetadata: CreateUserRequestWithFiles = { profilePictureFile: signOn.profileImage?.file as File, coverArtFile: signOn.coverPhoto?.file as File, metadata: { @@ -575,11 +577,14 @@ function* signUp() { } } - const { metadata } = yield* call( + const { userId: returnedUserId } = yield* call( [sdk.users, sdk.users.createUser], createUserMetadata ) - userId = metadata.userId + if (!returnedUserId) { + throw new Error('User ID not returned from createUser') + } + userId = decodeHashId(returnedUserId)! } yield* put( diff --git a/packages/web/src/common/store/player/sagas.ts b/packages/web/src/common/store/player/sagas.ts index 6fcefe6a2a7..aed5cae9cbf 100644 --- a/packages/web/src/common/store/player/sagas.ts +++ b/packages/web/src/common/store/player/sagas.ts @@ -144,7 +144,7 @@ export function* watchPlay() { ) const isLongFormContent = - track.genre === Genre.PODCASTS || track.genre === Genre.AUDIOBOOKS + track.genre === Genre.Podcasts || track.genre === Genre.Audiobooks const createEndChannel = async (url: string) => { const endChannel = eventChannel((emitter) => { @@ -325,7 +325,7 @@ export function* watchSeek() { const track = yield* queryTrack(trackId) const currentUserId = yield* call(queryCurrentUserId) const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks if (isLongFormContent) { yield* put( diff --git a/packages/web/src/common/store/social/collections/sagas.ts b/packages/web/src/common/store/social/collections/sagas.ts index 9e82372ec95..9f6f8f0da80 100644 --- a/packages/web/src/common/store/social/collections/sagas.ts +++ b/packages/web/src/common/store/social/collections/sagas.ts @@ -138,7 +138,7 @@ export function* confirmRepostCollection( yield* call([sdk.playlists, sdk.playlists.repostPlaylist], { userId: Id.parse(userId), playlistId: Id.parse(collectionId), - metadata: { + repostRequestBody: { isRepostOfRepost: metadata?.is_repost_of_repost ?? false } }) diff --git a/packages/web/src/common/store/social/tracks/sagas.ts b/packages/web/src/common/store/social/tracks/sagas.ts index 3a87f4573e4..8598c49e8c3 100644 --- a/packages/web/src/common/store/social/tracks/sagas.ts +++ b/packages/web/src/common/store/social/tracks/sagas.ts @@ -176,7 +176,10 @@ export function* confirmRepostTrack( function* () { yield* call([sdk.tracks, sdk.tracks.repostTrack], { trackId: Id.parse(trackId), - userId: Id.parse(user.user_id) + userId: Id.parse(user.user_id), + repostRequestBody: metadata + ? { isRepostOfRepost: metadata.is_repost_of_repost } + : undefined }) return trackId diff --git a/packages/web/src/common/store/social/users/sagas.ts b/packages/web/src/common/store/social/users/sagas.ts index b52f2fb811a..fba2fc0a948 100644 --- a/packages/web/src/common/store/social/users/sagas.ts +++ b/packages/web/src/common/store/social/users/sagas.ts @@ -10,8 +10,7 @@ import { Name, Kind, ID, UserMetadata } from '@audius/common/models' import { usersSocialActions as socialActions, getContext, - confirmerActions, - confirmTransaction + confirmerActions } from '@audius/common/store' import { makeKindId, route } from '@audius/common/utils' import { Id } from '@audius/sdk' @@ -113,23 +112,10 @@ function* confirmFollowUser( confirmerActions.requestConfirmation( makeKindId(Kind.USERS, userId), function* () { - const { blockHash, blockNumber } = yield* call( - [sdk.users, sdk.users.followUser], - { - userId: Id.parse(accountId), - followeeUserId: Id.parse(userId) - } - ) - const confirmed = yield* call( - confirmTransaction, - blockHash, - blockNumber - ) - if (!confirmed) { - throw new Error( - `Could not confirm follow user for user id ${userId} and account id ${accountId}` - ) - } + yield* call([sdk.users, sdk.users.followUser], { + userId: Id.parse(accountId), + followeeUserId: Id.parse(userId) + }) return accountId }, function* () { @@ -261,23 +247,10 @@ function* confirmUnfollowUser(userId: ID, accountId: ID) { confirmerActions.requestConfirmation( makeKindId(Kind.USERS, userId), function* () { - const { blockHash, blockNumber } = yield* call( - [sdk.users, sdk.users.unfollowUser], - { - userId: Id.parse(accountId), - followeeUserId: Id.parse(userId) - } - ) - const confirmed = yield* call( - confirmTransaction, - blockHash, - blockNumber - ) - if (!confirmed) { - throw new Error( - `Could not confirm unfollow user for user id ${userId} and account id ${accountId}` - ) - } + yield* call([sdk.users, sdk.users.unfollowUser], { + userId: Id.parse(accountId), + followeeUserId: Id.parse(userId) + }) return accountId }, function* () { @@ -366,23 +339,10 @@ function* confirmSubscribeToUser(userId: ID, accountId: ID) { confirmerActions.requestConfirmation( makeKindId(Kind.USERS, userId), function* () { - const { blockHash, blockNumber } = yield* call( - [sdk.users, sdk.users.subscribeToUser], - { - subscribeeUserId: Id.parse(userId), - userId: Id.parse(accountId) - } - ) - const confirmed = yield* call( - confirmTransaction, - blockHash, - blockNumber - ) - if (!confirmed) { - throw new Error( - `Could not confirm subscribe to user for user id ${userId} and account id ${accountId}` - ) - } + yield* call([sdk.users, sdk.users.subscribeToUser], { + subscribeeUserId: Id.parse(userId), + userId: Id.parse(accountId) + }) return accountId }, function* () {}, @@ -434,23 +394,11 @@ function* confirmUnsubscribeFromUser(userId: ID, accountId: ID) { confirmerActions.requestConfirmation( makeKindId(Kind.USERS, userId), function* () { - const { blockHash, blockNumber } = yield* call( - [sdk.users, sdk.users.unsubscribeFromUser], - { - subscribeeUserId: Id.parse(userId), - userId: Id.parse(accountId) - } - ) - const confirmed = yield* call( - confirmTransaction, - blockHash, - blockNumber - ) - if (!confirmed) { - throw new Error( - `Could not confirm unsubscribe from user for user id ${userId} and account id ${accountId}` - ) - } + yield* call([sdk.users, sdk.users.unsubscribeFromUser], { + subscribeeUserId: Id.parse(userId), + userId: Id.parse(accountId) + }) + return accountId }, function* () {}, 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 } diff --git a/packages/web/src/components/menu/TrackMenu.tsx b/packages/web/src/components/menu/TrackMenu.tsx index ea3e979fd16..c1994ca48c1 100644 --- a/packages/web/src/components/menu/TrackMenu.tsx +++ b/packages/web/src/components/menu/TrackMenu.tsx @@ -186,7 +186,7 @@ const TrackMenu = ({ const albumInfo = partialTrack?.album_backlink const isLongFormContent = - genre === Genre.PODCASTS || genre === Genre.AUDIOBOOKS + genre === Genre.Podcasts || genre === Genre.Audiobooks const shareMenuItem = { text: messages.share, 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/play-bar/desktop/PlayBar.tsx b/packages/web/src/components/play-bar/desktop/PlayBar.tsx index 4ae13dad39a..60f6aa0f3f0 100644 --- a/packages/web/src/components/play-bar/desktop/PlayBar.tsx +++ b/packages/web/src/components/play-bar/desktop/PlayBar.tsx @@ -95,8 +95,8 @@ const PlayBar = () => { const isStreamGated = currentTrack?.is_stream_gated || false const trackPermalink = currentTrack?.permalink || '' const isLongFormContent = - currentTrack?.genre === Genre.PODCASTS || - currentTrack?.genre === Genre.AUDIOBOOKS + currentTrack?.genre === Genre.Podcasts || + currentTrack?.genre === Genre.Audiobooks const playable = !!uid diff --git a/packages/web/src/components/play-bar/next-button/NextButtonProvider.tsx b/packages/web/src/components/play-bar/next-button/NextButtonProvider.tsx index 71a9d64d37d..50acc5a1456 100644 --- a/packages/web/src/components/play-bar/next-button/NextButtonProvider.tsx +++ b/packages/web/src/components/play-bar/next-button/NextButtonProvider.tsx @@ -9,7 +9,7 @@ type NextButtonProviderProps = NextButtonProps | ForwardSkipButtonProps const NextButtonProvider = (props: NextButtonProviderProps) => { const track = useCurrentTrack() const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks return isLongFormContent ? ( ) : ( diff --git a/packages/web/src/components/play-bar/previous-button/PreviousButtonProvider.tsx b/packages/web/src/components/play-bar/previous-button/PreviousButtonProvider.tsx index afe029089a1..4980718686c 100644 --- a/packages/web/src/components/play-bar/previous-button/PreviousButtonProvider.tsx +++ b/packages/web/src/components/play-bar/previous-button/PreviousButtonProvider.tsx @@ -11,7 +11,7 @@ type PreviousButtonProviderProps = PreviousButtonProps | BackwardSkipButtonProps const PreviousButtonProvider = (props: PreviousButtonProviderProps) => { const track = useCurrentTrack() const isLongFormContent = - track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS + track?.genre === Genre.Podcasts || track?.genre === Genre.Audiobooks return isLongFormContent ? ( ) : ( diff --git a/packages/web/src/components/track/GiantTrackTile.tsx b/packages/web/src/components/track/GiantTrackTile.tsx index 3654462830f..abcc9c8bd1c 100644 --- a/packages/web/src/components/track/GiantTrackTile.tsx +++ b/packages/web/src/components/track/GiantTrackTile.tsx @@ -214,7 +214,7 @@ export const GiantTrackTile = ({ const isRemixContest = !!remixContest const isLongFormContent = - genre === Genre.PODCASTS || genre === Genre.AUDIOBOOKS + genre === Genre.Podcasts || genre === Genre.Audiobooks const isUSDCPurchaseGated = isContentUSDCPurchaseGated(streamConditions) const { data: track } = useTrack(trackId, { select: (track) => pick(track, ['is_downloadable', 'preview_cid']) @@ -272,7 +272,7 @@ export const GiantTrackTile = ({ isScheduledRelease={isScheduledRelease} isRemix={isRemix} isStreamGated={isStreamGated} - isPodcast={genre === Genre.PODCASTS} + isPodcast={genre === Genre.Podcasts} streamConditions={streamConditions} isRemixContest={!!isRemixContest} /> diff --git a/packages/web/src/components/track/helpers.ts b/packages/web/src/components/track/helpers.ts index 9802cd0699d..b074fcb2735 100644 --- a/packages/web/src/components/track/helpers.ts +++ b/packages/web/src/components/track/helpers.ts @@ -1,6 +1,5 @@ import { Collection, FieldVisibility, Track, User } from '@audius/common/models' import { TQCollection } from '@audius/common/src/api/tan-query/models' -import { Genre } from '@audius/common/utils' const defaultFieldVisibility: FieldVisibility = { genre: true, @@ -22,7 +21,7 @@ export const getTrackWithFallback = (track: Track | null | undefined) => { followee_saves: [], duration: 0, save_count: 0, - genre: Genre.ALL, + genre: '', field_visibility: defaultFieldVisibility, has_current_user_reposted: false, has_current_user_saved: false, 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/components/trending-genre-selection/TrendingGenreSelectionPage.tsx b/packages/web/src/components/trending-genre-selection/TrendingGenreSelectionPage.tsx index a301b15ae15..88fe13c3533 100644 --- a/packages/web/src/components/trending-genre-selection/TrendingGenreSelectionPage.tsx +++ b/packages/web/src/components/trending-genre-selection/TrendingGenreSelectionPage.tsx @@ -6,8 +6,8 @@ import { } from '@audius/common/store' import { Genre, - ELECTRONIC_PREFIX, TRENDING_GENRES, + toTrendingGenre, route } from '@audius/common/utils' import { connect } from 'react-redux' @@ -37,9 +37,7 @@ const ConnectedTrendingGenreSelectionPage = ({ resetAllTrending }: ConnectedTrendingGenreSelectionPageProps) => { const setTrimmedGenre = (genre: string | null) => { - const trimmedGenre = - genre !== null ? genre.replace(ELECTRONIC_PREFIX, '') : genre - setTrendingGenre(trimmedGenre as Genre | null) + setTrendingGenre(toTrendingGenre(genre)) resetAllTrending() setTrendingTimeRange(timeRange) goToTrending() diff --git a/packages/web/src/components/user-generated-text/UserGeneratedText.tsx b/packages/web/src/components/user-generated-text/UserGeneratedText.tsx index eeecf185c0f..ec3948ec187 100644 --- a/packages/web/src/components/user-generated-text/UserGeneratedText.tsx +++ b/packages/web/src/components/user-generated-text/UserGeneratedText.tsx @@ -69,7 +69,8 @@ const RenderLink = ({ attributes, content }: IntermediateRepresentation) => { } else if (instanceOfPlaylistResponse(res)) { setUnfurledContent(formatCollectionName({ collection: res.data[0] })) } else if (instanceOfUserResponse(res)) { - setUnfurledContent(formatUserName({ user: res.data })) + const user = Array.isArray(res.data) ? res.data[0] : res.data + if (user) setUnfurledContent(formatUserName({ user })) } } } diff --git a/packages/web/src/hooks/useLaunchCoin.ts b/packages/web/src/hooks/useLaunchCoin.ts index 9785ecb858c..a0b26556240 100644 --- a/packages/web/src/hooks/useLaunchCoin.ts +++ b/packages/web/src/hooks/useLaunchCoin.ts @@ -217,7 +217,7 @@ export const useLaunchCoin = () => { // Create coin in Audius database await sdk.coins.createCoin({ userId: Id.parse(userId), - createCoinRequest: { + metadata: { mint: mintPublicKey, ticker: `${symbolUpper}`, decimals: LAUNCHPAD_COIN_DECIMALS, diff --git a/packages/web/src/pages/edit-page/EditTrackPage.tsx b/packages/web/src/pages/edit-page/EditTrackPage.tsx index 80d3be6b81e..efd7e715d86 100644 --- a/packages/web/src/pages/edit-page/EditTrackPage.tsx +++ b/packages/web/src/pages/edit-page/EditTrackPage.tsx @@ -9,6 +9,7 @@ import { useReplaceTrackProgressModal } from '@audius/common/store' import { removeNullable } from '@audius/common/utils' +import type { Genre, Mood } from '@audius/sdk' import { useNavigate, useParams } from 'react-router' import { EditTrackForm } from 'components/edit-track/EditTrackForm' @@ -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 || '' }, 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 diff --git a/packages/web/src/pages/settings-page/components/desktop/DeveloperApps/AppDetailsPage.tsx b/packages/web/src/pages/settings-page/components/desktop/DeveloperApps/AppDetailsPage.tsx index 261298c9488..e9434241217 100644 --- a/packages/web/src/pages/settings-page/components/desktop/DeveloperApps/AppDetailsPage.tsx +++ b/packages/web/src/pages/settings-page/components/desktop/DeveloperApps/AppDetailsPage.tsx @@ -22,12 +22,14 @@ const AUDIUS_SDK_LINK = 'https://docs.audius.co/developers' const messages = { secretReminder: - "Remember to save your API Secret. You won't be able to view it again.", + "Remember to save your API Secret and Bearer Token. You won't be able to view them again.", description: 'Description', apiKey: 'api key', copyApiKeyLabel: 'copy api key', apiSecret: 'api secret', copyApiSecretLabel: 'copy api secret', + bearerToken: 'bearer token', + copyBearerTokenLabel: 'copy bearer token', copied: 'Copied!', readTheDocs: 'Read the Developer Docs', goBack: 'Back to Your Apps' @@ -40,7 +42,7 @@ export const AppDetailsPage = (props: AppDetailsPageProps) => { setPage(CreateAppsPages.YOUR_APPS) }, [setPage]) - const { name, description, apiKey, apiSecret } = params || {} + const { name, description, apiKey, apiSecret, bearerToken } = params ?? {} const copyApiKey = useCallback(() => { if (!apiKey) return copyToClipboard(apiKey) @@ -51,11 +53,16 @@ export const AppDetailsPage = (props: AppDetailsPageProps) => { copyToClipboard(apiSecret) }, [apiSecret]) + const copyBearerToken = useCallback(() => { + if (!bearerToken) return + copyToClipboard(bearerToken) + }, [bearerToken]) + if (!params) return null return (
- {!apiSecret ? null : ( + {!apiSecret && !bearerToken ? null : ( { > + + +
+ )} + {!bearerToken ? null : ( +
+ {messages.bearerToken} + + {bearerToken} + + + + diff --git a/packages/web/src/pages/sign-up-page/pages/SelectArtistsPage.tsx b/packages/web/src/pages/sign-up-page/pages/SelectArtistsPage.tsx index 53c3bbfb708..9d30fd87d74 100644 --- a/packages/web/src/pages/sign-up-page/pages/SelectArtistsPage.tsx +++ b/packages/web/src/pages/sign-up-page/pages/SelectArtistsPage.tsx @@ -5,7 +5,11 @@ import { useSuggestedArtists, useTopArtistsInGenre } from '@audius/common/api' import { selectArtistsPageMessages } from '@audius/common/messages' import { UserMetadata } from '@audius/common/models' import { selectArtistsSchema } from '@audius/common/schemas' -import { Genre, convertGenreLabelToValue, route } from '@audius/common/utils' +import { + type GenreLabel, + convertGenreLabelToValue, + route +} from '@audius/common/utils' import { Flex, Paper, SelectablePill, Text, useTheme } from '@audius/harmony' import { animated, useSpring } from '@react-spring/web' import { Form, Formik, useFormikContext } from 'formik' @@ -210,7 +214,9 @@ export const SelectArtistsPage = () => { disableScroll={!isMobile} > {artistGenres.map((genre) => { - const genreValue = convertGenreLabelToValue(genre as Genre) + const genreValue = convertGenreLabelToValue( + genre as GenreLabel + ) return ( // TODO: max of 6, kebab overflow { key={genre} name='trending-genre-filter' type='radio' - label={getCanonicalName(genre)} + label={getCanonicalName(genre) ?? ''} value={genre} size='large' isSelected={genre === currentGenre} diff --git a/packages/web/src/pages/trending-page/components/desktop/TrendingPageContent.tsx b/packages/web/src/pages/trending-page/components/desktop/TrendingPageContent.tsx index b1e42625e16..3692d83c741 100644 --- a/packages/web/src/pages/trending-page/components/desktop/TrendingPageContent.tsx +++ b/packages/web/src/pages/trending-page/components/desktop/TrendingPageContent.tsx @@ -7,8 +7,8 @@ import { trendingUndergroundPageLineupSelectors } from '@audius/common/store' import { - ELECTRONIC_PREFIX, getCanonicalName, + toTrendingGenre, TRENDING_GENRES } from '@audius/common/utils' import { @@ -188,9 +188,7 @@ const TrendingPageContent = ({ containerRef }: TrendingPageContentProps) => { const setGenreAndRefresh = useCallback( (genre: string | null) => { - const trimmedGenre = - genre !== null ? genre.replace(ELECTRONIC_PREFIX, '') : genre - setTrendingGenre(trimmedGenre) + setTrendingGenre(toTrendingGenre(genre)) // Call reset to change everything everything to skeleton tiles makeResetTrending(TimeRange.WEEK)() diff --git a/packages/web/src/pages/trending-page/components/mobile/TrendingPageContent.tsx b/packages/web/src/pages/trending-page/components/mobile/TrendingPageContent.tsx index 70466487458..8b0228c7268 100644 --- a/packages/web/src/pages/trending-page/components/mobile/TrendingPageContent.tsx +++ b/packages/web/src/pages/trending-page/components/mobile/TrendingPageContent.tsx @@ -312,7 +312,7 @@ const TrendingPageMobileContent = ({