Skip to content

Commit bc9cd0b

Browse files
committed
fix(integrations): batch spotify library requests up to each tool's old id limit, restore playlist tracks limit, list new buffer channel actions
1 parent e6bb8d4 commit bc9cd0b

24 files changed

Lines changed: 323 additions & 98 deletions

‎apps/sim/blocks/blocks/spotify.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ export const SpotifyBlock: BlockConfig = {
894894
id: 'limit',
895895
title: 'Limit',
896896
type: 'short-input',
897-
placeholder: 'Number of results (1-50, default: 20)',
897+
placeholder: 'Number of results (leave empty for the default)',
898898
condition: {
899899
field: 'operation',
900900
value: [

‎apps/sim/tools/buffer/schema.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,13 @@ const BUFFER_SCHEMA: Record<string, BufferSchemaType> = {
405405
},
406406
ChannelAction: {
407407
values: [
408+
'approvePosts',
408409
'backfillChannel',
410+
'cleanQueue',
411+
'deleteDrafts',
412+
'emptyQueue',
409413
'exportInsights',
414+
'interactWithTakeaways',
410415
'manageCapabilities',
411416
'manageChannelSettings',
412417
'manageComments',
@@ -419,6 +424,7 @@ const BUFFER_SCHEMA: Record<string, BufferSchemaType> = {
419424
'reconnectChannel',
420425
'removeChannel',
421426
'scheduleUpdates',
427+
'shuffleQueue',
422428
'viewCapabilities',
423429
'viewChannel',
424430
'viewComments',

‎apps/sim/tools/generated/tool-metadata.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/spotify/check_following.ts‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spotifyLibraryUrl } from '@/tools/spotify/utils'
1+
import { sendRemainingSpotifyLibraryChunks, spotifyLibraryUrl } from '@/tools/spotify/utils'
22
import type { ToolConfig, ToolResponse } from '@/tools/types'
33

44
interface SpotifyCheckFollowingParams {
@@ -37,21 +37,35 @@ export const spotifyCheckFollowingTool: ToolConfig<
3737
type: 'string',
3838
required: true,
3939
visibility: 'user-or-llm',
40-
description: 'Comma-separated artist or user IDs (max 40)',
40+
description: 'Comma-separated artist or user IDs (max 50)',
4141
},
4242
},
4343

4444
request: {
4545
url: (params) =>
46-
spotifyLibraryUrl(params.ids, params.type === 'user' ? 'user' : 'artist', { contains: true }),
46+
spotifyLibraryUrl(params.ids, params.type === 'user' ? 'user' : 'artist', {
47+
contains: true,
48+
maxIds: 50,
49+
}),
4750
method: 'GET',
4851
headers: (params) => ({
4952
Authorization: `Bearer ${params.accessToken}`,
5053
}),
5154
},
5255

53-
transformResponse: async (response): Promise<SpotifyCheckFollowingResponse> => {
54-
const results = await response.json()
56+
transformResponse: async (response, params): Promise<SpotifyCheckFollowingResponse> => {
57+
const results: boolean[] = [
58+
...(await response.json()),
59+
...(params
60+
? await sendRemainingSpotifyLibraryChunks(
61+
params,
62+
params.ids,
63+
params.type === 'user' ? 'user' : 'artist',
64+
'GET',
65+
{ contains: true, maxIds: 50 }
66+
)
67+
: []),
68+
]
5569
return { success: true, output: { results } }
5670
},
5771

‎apps/sim/tools/spotify/check_saved_albums.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spotifyLibraryUrl } from '@/tools/spotify/utils'
1+
import { sendRemainingSpotifyLibraryChunks, spotifyLibraryUrl } from '@/tools/spotify/utils'
22
import type { ToolConfig, ToolResponse } from '@/tools/types'
33

44
interface SpotifyCheckSavedAlbumsParams {
@@ -30,20 +30,28 @@ export const spotifyCheckSavedAlbumsTool: ToolConfig<
3030
type: 'string',
3131
required: true,
3232
visibility: 'user-or-llm',
33-
description: 'Comma-separated album IDs (max 40)',
33+
description: 'Comma-separated album IDs (max 20)',
3434
},
3535
},
3636

3737
request: {
38-
url: (params) => spotifyLibraryUrl(params.albumIds, 'album', { contains: true }),
38+
url: (params) => spotifyLibraryUrl(params.albumIds, 'album', { contains: true, maxIds: 20 }),
3939
method: 'GET',
4040
headers: (params) => ({
4141
Authorization: `Bearer ${params.accessToken}`,
4242
}),
4343
},
4444

45-
transformResponse: async (response): Promise<SpotifyCheckSavedAlbumsResponse> => {
46-
const results = await response.json()
45+
transformResponse: async (response, params): Promise<SpotifyCheckSavedAlbumsResponse> => {
46+
const results: boolean[] = [
47+
...(await response.json()),
48+
...(params
49+
? await sendRemainingSpotifyLibraryChunks(params, params.albumIds, 'album', 'GET', {
50+
contains: true,
51+
maxIds: 20,
52+
})
53+
: []),
54+
]
4755
return { success: true, output: { results } }
4856
},
4957

‎apps/sim/tools/spotify/check_saved_audiobooks.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spotifyLibraryUrl } from '@/tools/spotify/utils'
1+
import { sendRemainingSpotifyLibraryChunks, spotifyLibraryUrl } from '@/tools/spotify/utils'
22
import type { ToolConfig, ToolResponse } from '@/tools/types'
33

44
interface SpotifyCheckSavedAudiobooksParams {
@@ -30,20 +30,29 @@ export const spotifyCheckSavedAudiobooksTool: ToolConfig<
3030
type: 'string',
3131
required: true,
3232
visibility: 'user-or-llm',
33-
description: 'Comma-separated audiobook IDs (max 40)',
33+
description: 'Comma-separated audiobook IDs (max 50)',
3434
},
3535
},
3636

3737
request: {
38-
url: (params) => spotifyLibraryUrl(params.audiobookIds, 'audiobook', { contains: true }),
38+
url: (params) =>
39+
spotifyLibraryUrl(params.audiobookIds, 'audiobook', { contains: true, maxIds: 50 }),
3940
method: 'GET',
4041
headers: (params) => ({
4142
Authorization: `Bearer ${params.accessToken}`,
4243
}),
4344
},
4445

45-
transformResponse: async (response): Promise<SpotifyCheckSavedAudiobooksResponse> => {
46-
const results = await response.json()
46+
transformResponse: async (response, params): Promise<SpotifyCheckSavedAudiobooksResponse> => {
47+
const results: boolean[] = [
48+
...(await response.json()),
49+
...(params
50+
? await sendRemainingSpotifyLibraryChunks(params, params.audiobookIds, 'audiobook', 'GET', {
51+
contains: true,
52+
maxIds: 50,
53+
})
54+
: []),
55+
]
4756
return { success: true, output: { results } }
4857
},
4958

‎apps/sim/tools/spotify/check_saved_episodes.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spotifyLibraryUrl } from '@/tools/spotify/utils'
1+
import { sendRemainingSpotifyLibraryChunks, spotifyLibraryUrl } from '@/tools/spotify/utils'
22
import type { ToolConfig, ToolResponse } from '@/tools/types'
33

44
interface SpotifyCheckSavedEpisodesParams {
@@ -30,20 +30,29 @@ export const spotifyCheckSavedEpisodesTool: ToolConfig<
3030
type: 'string',
3131
required: true,
3232
visibility: 'user-or-llm',
33-
description: 'Comma-separated episode IDs (max 40)',
33+
description: 'Comma-separated episode IDs (max 50)',
3434
},
3535
},
3636

3737
request: {
38-
url: (params) => spotifyLibraryUrl(params.episodeIds, 'episode', { contains: true }),
38+
url: (params) =>
39+
spotifyLibraryUrl(params.episodeIds, 'episode', { contains: true, maxIds: 50 }),
3940
method: 'GET',
4041
headers: (params) => ({
4142
Authorization: `Bearer ${params.accessToken}`,
4243
}),
4344
},
4445

45-
transformResponse: async (response): Promise<SpotifyCheckSavedEpisodesResponse> => {
46-
const results = await response.json()
46+
transformResponse: async (response, params): Promise<SpotifyCheckSavedEpisodesResponse> => {
47+
const results: boolean[] = [
48+
...(await response.json()),
49+
...(params
50+
? await sendRemainingSpotifyLibraryChunks(params, params.episodeIds, 'episode', 'GET', {
51+
contains: true,
52+
maxIds: 50,
53+
})
54+
: []),
55+
]
4756
return { success: true, output: { results } }
4857
},
4958

‎apps/sim/tools/spotify/check_saved_shows.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spotifyLibraryUrl } from '@/tools/spotify/utils'
1+
import { sendRemainingSpotifyLibraryChunks, spotifyLibraryUrl } from '@/tools/spotify/utils'
22
import type { ToolConfig, ToolResponse } from '@/tools/types'
33

44
interface SpotifyCheckSavedShowsParams {
@@ -30,20 +30,28 @@ export const spotifyCheckSavedShowsTool: ToolConfig<
3030
type: 'string',
3131
required: true,
3232
visibility: 'user-or-llm',
33-
description: 'Comma-separated show IDs (max 40)',
33+
description: 'Comma-separated show IDs (max 50)',
3434
},
3535
},
3636

3737
request: {
38-
url: (params) => spotifyLibraryUrl(params.showIds, 'show', { contains: true }),
38+
url: (params) => spotifyLibraryUrl(params.showIds, 'show', { contains: true, maxIds: 50 }),
3939
method: 'GET',
4040
headers: (params) => ({
4141
Authorization: `Bearer ${params.accessToken}`,
4242
}),
4343
},
4444

45-
transformResponse: async (response): Promise<SpotifyCheckSavedShowsResponse> => {
46-
const results = await response.json()
45+
transformResponse: async (response, params): Promise<SpotifyCheckSavedShowsResponse> => {
46+
const results: boolean[] = [
47+
...(await response.json()),
48+
...(params
49+
? await sendRemainingSpotifyLibraryChunks(params, params.showIds, 'show', 'GET', {
50+
contains: true,
51+
maxIds: 50,
52+
})
53+
: []),
54+
]
4755
return { success: true, output: { results } }
4856
},
4957

‎apps/sim/tools/spotify/check_saved_tracks.ts‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import type {
22
SpotifyCheckSavedTracksParams,
33
SpotifyCheckSavedTracksResponse,
44
} from '@/tools/spotify/types'
5-
import { splitSpotifyLibraryIds, spotifyLibraryUrl } from '@/tools/spotify/utils'
5+
import {
6+
sendRemainingSpotifyLibraryChunks,
7+
splitSpotifyLibraryIds,
8+
spotifyLibraryUrl,
9+
} from '@/tools/spotify/utils'
610
import type { ToolConfig } from '@/tools/types'
711

812
export const spotifyCheckSavedTracksTool: ToolConfig<
@@ -25,21 +29,29 @@ export const spotifyCheckSavedTracksTool: ToolConfig<
2529
type: 'string',
2630
required: true,
2731
visibility: 'user-or-llm',
28-
description: 'Comma-separated track IDs to check (max 40)',
32+
description: 'Comma-separated track IDs to check (max 50)',
2933
},
3034
},
3135

3236
request: {
33-
url: (params) => spotifyLibraryUrl(params.trackIds, 'track', { contains: true }),
37+
url: (params) => spotifyLibraryUrl(params.trackIds, 'track', { contains: true, maxIds: 50 }),
3438
method: 'GET',
3539
headers: (params) => ({
3640
Authorization: `Bearer ${params.accessToken}`,
3741
}),
3842
},
3943

4044
transformResponse: async (response, params): Promise<SpotifyCheckSavedTracksResponse> => {
41-
const data = await response.json()
42-
const ids = splitSpotifyLibraryIds(params?.trackIds || '')
45+
const data: boolean[] = [
46+
...(await response.json()),
47+
...(params
48+
? await sendRemainingSpotifyLibraryChunks(params, params.trackIds, 'track', 'GET', {
49+
contains: true,
50+
maxIds: 50,
51+
})
52+
: []),
53+
]
54+
const ids = splitSpotifyLibraryIds(params?.trackIds || '', 50)
4355

4456
const results = ids.map((id, index) => ({
4557
id,

‎apps/sim/tools/spotify/follow_artists.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spotifyLibraryUrl } from '@/tools/spotify/utils'
1+
import { sendRemainingSpotifyLibraryChunks, spotifyLibraryUrl } from '@/tools/spotify/utils'
22
import type { ToolConfig, ToolResponse } from '@/tools/types'
33

44
interface SpotifyFollowArtistsParams {
@@ -32,19 +32,23 @@ export const spotifyFollowArtistsTool: ToolConfig<
3232
type: 'string',
3333
required: true,
3434
visibility: 'user-or-llm',
35-
description: 'Comma-separated artist IDs to follow (max 40)',
35+
description: 'Comma-separated artist IDs to follow (max 50)',
3636
},
3737
},
3838

3939
request: {
40-
url: (params) => spotifyLibraryUrl(params.artistIds, 'artist'),
40+
url: (params) => spotifyLibraryUrl(params.artistIds, 'artist', { maxIds: 50 }),
4141
method: 'PUT',
4242
headers: (params) => ({
4343
Authorization: `Bearer ${params.accessToken}`,
4444
}),
4545
},
4646

47-
transformResponse: async (): Promise<SpotifyFollowArtistsResponse> => {
47+
transformResponse: async (_response, params): Promise<SpotifyFollowArtistsResponse> => {
48+
if (params)
49+
await sendRemainingSpotifyLibraryChunks(params, params.artistIds, 'artist', 'PUT', {
50+
maxIds: 50,
51+
})
4852
return {
4953
success: true,
5054
output: { success: true },

0 commit comments

Comments
 (0)