diff --git a/apps/sim/blocks/blocks/google_books.ts b/apps/sim/blocks/blocks/google_books.ts index 5b7e31aae..764ee0290 100644 --- a/apps/sim/blocks/blocks/google_books.ts +++ b/apps/sim/blocks/blocks/google_books.ts @@ -1,10 +1,12 @@ import { GoogleBooksIcon } from '@/components/icons' import type { BlockConfig } from '@/blocks/types' +import { AuthMode } from '@/blocks/types' export const GoogleBooksBlock: BlockConfig = { type: 'google_books', name: 'Google Books', description: 'Search and retrieve book information', + authMode: AuthMode.ApiKey, longDescription: 'Search for books using the Google Books API. Find volumes by title, author, ISBN, or keywords, and retrieve detailed information about specific books including descriptions, ratings, and publication details.', docsLink: 'https://docs.sim.ai/tools/google_books', @@ -120,6 +122,7 @@ export const GoogleBooksBlock: BlockConfig = { { label: 'Lite', id: 'lite' }, ], value: () => 'full', + condition: { field: 'operation', value: 'volume_details' }, mode: 'advanced', }, ], diff --git a/apps/sim/tools/google_books/volume_details.ts b/apps/sim/tools/google_books/volume_details.ts index f50e23986..114a78361 100644 --- a/apps/sim/tools/google_books/volume_details.ts +++ b/apps/sim/tools/google_books/volume_details.ts @@ -29,6 +29,9 @@ interface GoogleBooksVolumeResponse { identifier: string }> } + error?: { + message?: string + } } export const googleBooksVolumeDetailsTool: ToolConfig< @@ -81,6 +84,10 @@ export const googleBooksVolumeDetailsTool: ToolConfig< transformResponse: async (response: Response) => { const data: GoogleBooksVolumeResponse = await response.json() + if (data.error) { + throw new Error(`Google Books API error: ${data.error.message || 'Unknown error'}`) + } + if (!data.volumeInfo) { throw new Error('Volume not found') } diff --git a/apps/sim/tools/google_books/volume_search.ts b/apps/sim/tools/google_books/volume_search.ts index 1f643c599..72ca1a783 100644 --- a/apps/sim/tools/google_books/volume_search.ts +++ b/apps/sim/tools/google_books/volume_search.ts @@ -155,6 +155,10 @@ export const googleBooksVolumeSearchTool: ToolConfig< transformResponse: async (response: Response) => { const data = await response.json() + if (data.error) { + throw new Error(`Google Books API error: ${data.error.message || 'Unknown error'}`) + } + const items: GoogleBooksVolumeItem[] = data.items ?? [] const volumes = items.map(extractVolumeInfo)