Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion packages/commands/src/album/get-album.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getAlbumCommand = new Command('get')
.action(async (albumId, { from }) => {
const audiusSdk = await initializeAudiusSdk({ handle: from })
const userId = await getCurrentUserId()
const { data: playlist } = await audiusSdk.full.playlists.getPlaylist({
const { data: playlist } = await audiusSdk.playlists.getPlaylist({
userId,
playlistId: albumId
})
Expand Down
2 changes: 1 addition & 1 deletion packages/commands/src/playlist/get-playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getPlaylistCommand = new Command('get')
.action(async (playlistId, { from }) => {
const audiusSdk = await initializeAudiusSdk({ handle: from })
const userId = await getCurrentUserId()
const { data: playlist } = await audiusSdk.full.playlists.getPlaylist({
const { data: playlist } = await audiusSdk.playlists.getPlaylist({
userId,
playlistId
})
Expand Down
2 changes: 1 addition & 1 deletion packages/commands/src/track/get-track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getTrackCommand = new Command('get')
.action(async (trackId, { from }) => {
const audiusSdk = await initializeAudiusSdk({ handle: from })
const userId = await getCurrentUserId()
const { data: track } = await audiusSdk.full.tracks.getTrack({
const { data: track } = await audiusSdk.tracks.getTrack({
userId,
trackId
})
Expand Down
2 changes: 1 addition & 1 deletion packages/commands/src/user/get-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const getUserCommand = new Command('get')
.action(async (id, { from }) => {
const audiusSdk = await initializeAudiusSdk({ handle: from })
const userId = await getCurrentUserId()
const { data: track } = await audiusSdk.full.users.getUser({ userId, id })
const { data: track } = await audiusSdk.users.getUser({ userId, id })
console.info(track)
})
4 changes: 2 additions & 2 deletions packages/commands/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const getCurrentUserId = async () => {
throw new Error('sdk not initialized')
}
const [address] = await audiusSdk.services.audiusWalletClient.getAddresses()
const { data } = await audiusSdk.full.users.getUserAccount({
const { data } = await audiusSdk.users.getUserAccount({
wallet: address
})
if (!data?.user) {
Expand All @@ -224,7 +224,7 @@ export const getCurrentUserHandle = async () => {
return currentHandle
}
const [address] = await audiusSdk.services.audiusWalletClient.getAddresses()
const { data } = await audiusSdk.full.users.getUserAccount({
const { data } = await audiusSdk.users.getUserAccount({
wallet: address
})
if (!data?.user) {
Expand Down
6 changes: 5 additions & 1 deletion packages/common/src/adapters/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Id,
OptionalHashId,
type Playlist,
type PlaylistFullWithoutTracks as DefaultPlaylistFullWithoutTracks,
UpdateAlbumRequest,
UpdatePlaylistRequest
} from '@audius/sdk'
Expand Down Expand Up @@ -52,6 +53,7 @@ type CollectionFromSDK =
| full.PlaylistFullWithoutTracks
| full.SearchPlaylistFull
| full.PlaylistFull
| DefaultPlaylistFullWithoutTracks

function collectionArtworkFromSDK(
art: CollectionFromSDK['artwork']
Expand Down Expand Up @@ -138,7 +140,9 @@ export const userCollectionMetadataFromSDK = (
? accessConditionsFromSDK(input.streamConditions as full.AccessGate)
: null,
tracks: transformAndCleanList(
'tracks' in input ? (input.tracks ?? []) : [],
('tracks' in input ? (input.tracks ?? []) : []) as Parameters<
Copy link
Contributor

Choose a reason for hiding this comment

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

any way to eliminate the cast?

typeof userTrackMetadataFromSDK
>[0][],
userTrackMetadataFromSDK
),
cover_art: 'coverArt' in input ? (input.coverArt ?? null) : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('getUsersBatcher', () => {
const results = await Promise.all(ids.map((id) => batcher.fetch(id)))

// Verify single bulk request was made
expect(mockSdk.full.users.getBulkUsers).toHaveBeenCalledTimes(1)
expect(mockSdk.users.getBulkUsers).toHaveBeenCalledTimes(1)
expect(mockSdk.users.getBulkUsers).toHaveBeenCalledWith({
id: ids.map((id) => Id.parse(id)),
userId: OptionalId.parse(null)
Expand Down Expand Up @@ -142,12 +142,12 @@ describe('getUsersBatcher', () => {
)

// Verify two separate bulk requests were made
expect(mockSdk.full.users.getBulkUsers).toHaveBeenCalledTimes(2)
expect(mockSdk.full.users.getBulkUsers).toHaveBeenNthCalledWith(1, {
expect(mockSdk.users.getBulkUsers).toHaveBeenCalledTimes(2)
expect(mockSdk.users.getBulkUsers).toHaveBeenNthCalledWith(1, {
id: firstBatchIds.map((id) => Id.parse(id)),
userId: OptionalId.parse(null)
})
expect(mockSdk.full.users.getBulkUsers).toHaveBeenNthCalledWith(2, {
expect(mockSdk.users.getBulkUsers).toHaveBeenNthCalledWith(2, {
id: secondBatchIds.map((id) => Id.parse(id)),
userId: OptionalId.parse(null)
})
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('getUsersBatcher', () => {
expect(missingResult).toBeNull()

// Verify single batch request was made with both IDs
expect(mockSdk.full.users.getBulkUsers).toHaveBeenCalledTimes(1)
expect(mockSdk.users.getBulkUsers).toHaveBeenCalledTimes(1)
expect(mockSdk.users.getBulkUsers).toHaveBeenCalledWith({
id: [missingId, existingId].map((id) => Id.parse(id)),
userId: OptionalId.parse(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const useCollectionFavorites = (
},
queryFn: async ({ pageParam }) => {
const sdk = await audiusSdk()
const { data } = await sdk.full.playlists.getUsersFromPlaylistFavorites({
const { data } = await sdk.playlists.getUsersFromPlaylistFavorites({
playlistId: Id.parse(collectionId),
limit: pageSize,
offset: pageParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const useCollectionReposts = (
},
queryFn: async ({ pageParam }) => {
const sdk = await audiusSdk()
const { data } = await sdk.full.playlists.getUsersFromPlaylistReposts({
const { data } = await sdk.playlists.getUsersFromPlaylistReposts({
playlistId: Id.parse(collectionId),
limit: pageSize,
offset: pageParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export const useLibraryCollections = (

const { data: activities = [] } =
collectionType === 'albums'
? await sdk.full.users.getUserLibraryAlbums(requestParams)
: await sdk.full.users.getUserLibraryPlaylists(requestParams)
? await sdk.users.getUserLibraryAlbums(requestParams)
: await sdk.users.getUserLibraryPlaylists(requestParams)

const collections = transformAndCleanList(activities, ({ item }) =>
userCollectionMetadataFromSDK(item)
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/api/tan-query/comments/useComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useComment = (commentId: ID | null | undefined) => {
enabled: !!commentId,
queryFn: async () => {
const sdk = await audiusSdk()
const { data: commentRes } = await sdk.full.comments.getComment({
const { data: commentRes } = await sdk.comments.getComment({
commentId: Id.parse(commentId)
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from 'react'

import { Id } from '@audius/sdk'
import { full, Id } from '@audius/sdk'
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query'
import { useDispatch } from 'react-redux'

Expand Down Expand Up @@ -42,7 +42,7 @@ export const useCommentReplies = (
},
queryFn: async ({ pageParam }): Promise<ID[]> => {
const sdk = await audiusSdk()
const response = await sdk.full.comments.getCommentReplies({
const response = await sdk.comments.getCommentReplies({
commentId: Id.parse(commentId),
userId: currentUserId?.toString(),
limit: pageSize,
Expand All @@ -51,7 +51,10 @@ export const useCommentReplies = (

const replies = transformAndCleanList(response.data, replyCommentFromSDK)

primeRelatedData({ related: response.related, queryClient })
primeRelatedData({
related: (response as { related?: full.Related }).related,
Copy link
Contributor

Choose a reason for hiding this comment

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

these casts feel scary

queryClient
})

// Update the parent comment with the new replies and prime the reply data
// Add the replies to our parent comment replies list
Expand Down
9 changes: 6 additions & 3 deletions packages/common/src/api/tan-query/comments/useUserComments.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from 'react'

import { Id, OptionalId } from '@audius/sdk'
import { full, Id, OptionalId } from '@audius/sdk'
import {
useInfiniteQuery,
useIsMutating,
Expand Down Expand Up @@ -46,7 +46,7 @@ export const useUserComments = (
queryKey: ['userCommentList', userId, pageSize],
queryFn: async ({ pageParam }): Promise<ID[]> => {
const sdk = await audiusSdk()
const commentsRes = await sdk.full.users.getUserComments({
const commentsRes = await sdk.users.getUserComments({
id: Id.parse(userId),
userId: OptionalId.parse(currentUserId),
offset: pageParam,
Expand All @@ -58,7 +58,10 @@ export const useUserComments = (
commentFromSDK
)

primeRelatedData({ related: commentsRes.related, queryClient })
primeRelatedData({
related: (commentsRes as { related?: full.Related }).related,
Copy link
Contributor

Choose a reason for hiding this comment

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

same here..

queryClient
})

// Prime comment data in the cache
primeCommentData({ comments: commentList, queryClient })
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/api/tan-query/lineups/useFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const useFeed = (
const isFirstPage = pageParam === 0
const currentPageSize = isFirstPage ? initialPageSize : loadMorePageSize
const sdk = await audiusSdk()
const { data = [] } = await sdk.full.users.getUserFeed({
const { data = [] } = await sdk.users.getUserFeed({
id: Id.parse(currentUserId),
userId: Id.parse(currentUserId),
filter: filterMap[filter],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const useLibraryTracks = (
queryFn: async ({ pageParam = 0 }) => {
if (!currentUserId) return []
const sdk = await audiusSdk()
const { data = [] } = await sdk.full.users.getUserLibraryTracks({
const { data = [] } = await sdk.users.getUserLibraryTracks({
id: Id.parse(currentUserId),
offset: pageParam,
limit: pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const useProfileReposts = (

// If the @ is still at the beginning of the handle, trim it off
const handleNoAt = handle.startsWith('@') ? handle.substring(1) : handle
const { data: repostsSDKData } = await sdk.full.users.getRepostsByHandle({
const { data: repostsSDKData } = await sdk.users.getRepostsByHandle({
handle: handleNoAt,
userId: OptionalId.parse(currentUserId),
limit: pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const useNotificationUnreadCount = () => {
queryKey: getNotificationUnreadCountQueryKey(currentUserId),
queryFn: async () => {
const sdk = await audiusSdk()
const { data } = await sdk.full.notifications.getNotifications({
const { data } = await sdk.notifications.getNotifications({
userId: Id.parse(currentUserId),
limit: 0
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export const useNotifications = (options?: QueryOptions) => {
initialPageParam: null as PageParam,
queryFn: async ({ pageParam = null }) => {
const sdk = await audiusSdk()
const { data } = await sdk.full.notifications.getNotifications({
const { data } = await sdk.notifications.getNotifications({
userId: Id.parse(currentUserId),
limit: DEFAULT_LIMIT,
timestamp: pageParam?.timestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const useAudioTransactions = (
if (!userId) return []

const sdk = await audiusSdk()
const response = await sdk.full.users.getAudioTransactions({
const response = await sdk.users.getAudioTransactions({
id: Id.parse(userId),
offset: page * pageSize,
limit: pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const useAudioTransactionsCount = <TResult = number>(
if (!userId) return 0

const sdk = await audiusSdk()
const response = await sdk.full.users.getAudioTransactionCount({
const response = await sdk.users.getAudioTransactionCount({
id: Id.parse(userId)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const usePurchasers = (
queryFn: async ({ pageParam }) => {
const sdk = await audiusSdk()
if (!currentUserId) return []
const { data = [] } = await sdk.full.users.getPurchasers({
const { data = [] } = await sdk.users.getPurchasers({
id: Id.parse(currentUserId),
limit: pageSize,
offset: pageParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const usePurchasersCount = (
queryFn: async () => {
const sdk = await audiusSdk()
if (!currentUserId) return 0
const { data = 0 } = await sdk.full.users.getPurchasersCount({
const { data = 0 } = await sdk.users.getPurchasersCount({
id: Id.parse(currentUserId),
userId: Id.parse(currentUserId),
contentId: OptionalId.parse(contentId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const usePurchases = (
},
queryFn: async ({ pageParam }) => {
const sdk = await audiusSdk()
const { data = [] } = await sdk.full.users.getPurchases({
const { data = [] } = await sdk.users.getPurchases({
id: Id.parse(userId),
userId: Id.parse(userId),
limit: pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const usePurchasesCount = (
queryKey: getPurchasesCountQueryKey({ userId }),
queryFn: async () => {
const sdk = await audiusSdk()
const { data = 0 } = await sdk.full.users.getPurchasesCount({
const { data = 0 } = await sdk.users.getPurchasesCount({
id: Id.parse(userId),
userId: Id.parse(userId)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/api/tan-query/purchases/useSales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const useSales = (args: GetSalesListArgs, options?: QueryOptions) => {
},
queryFn: async ({ pageParam }) => {
const sdk = await audiusSdk()
const { data = [] } = await sdk.full.users.getSales({
const { data = [] } = await sdk.users.getSales({
id: Id.parse(userId!),
userId: Id.parse(userId!),
limit: pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const useSalesCount = (
queryKey: getSalesCountQueryKey(userId),
queryFn: async () => {
const sdk = await audiusSdk()
const { data = 0 } = await sdk.full.users.getSalesCount({
const { data = 0 } = await sdk.users.getSalesCount({
id: Id.parse(userId),
userId: Id.parse(userId)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const useUSDCTransactions = (
queryFn: async ({ pageParam }) => {
if (!currentUserId) return []
const sdk = await audiusSdk()
const { data = [] } = await sdk.full.users.getUSDCTransactions({
const { data = [] } = await sdk.users.getUSDCTransactions({
id: Id.parse(currentUserId),
limit: pageSize,
offset: pageParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useUSDCTransactionsCount = (
queryFn: async () => {
if (!currentUserId) return 0
const sdk = await audiusSdk()
const { data } = await sdk.full.users.getUSDCTransactionCount({
const { data } = await sdk.users.getUSDCTransactionCount({
id: Id.parse(currentUserId),
type: args?.type,
method: args?.method
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/api/tan-query/remixes/useRemixers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useRemixers = (
},
queryFn: async ({ pageParam }) => {
const sdk = await audiusSdk()
const { data = [] } = await sdk.full.users.getRemixers({
const { data = [] } = await sdk.users.getRemixers({
id: Id.parse(userId),
limit: pageSize,
offset: pageParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useRemixersCount = (
queryFn: async () => {
const sdk = await audiusSdk()
if (!currentUserId) return 0
const { data = 0 } = await sdk.full.users.getRemixersCount({
const { data = 0 } = await sdk.users.getRemixersCount({
id: Id.parse(currentUserId),
userId: Id.parse(currentUserId),
trackId: OptionalId.parse(trackId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const useSearchAutocomplete = (
queryKey: getSearchAutocompleteQueryKey(currentUserId, { query, limit }),
queryFn: async () => {
const sdk = await audiusSdk()
const { data } = await sdk.full.search.searchAutocomplete({
const { data } = await sdk.search.searchAutocomplete({
userId: OptionalId.parse(currentUserId),
query,
limit,
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/api/tan-query/search/useSearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ const useSearchQueryProps = <T>(
}

const { data } = isTagsSearch
? await sdk.full.search.searchTags(searchParams)
: await sdk.full.search.search(searchParams)
? await sdk.search.searchTags(searchParams)
: await sdk.search.search(searchParams)

const { tracks, playlists, albums, users } = searchResultsFromSDK(
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useRecentlyPlayedTracks = (
if (!currentUserId) return []
const sdk = await audiusSdk()
const id = Id.parse(currentUserId)
const { data = [] } = await sdk.full.users.getUsersTrackHistory({
const { data = [] } = await sdk.users.getUsersTrackHistory({
...args,
id,
userId: id,
Expand Down
Loading
Loading