File tree Expand file tree Collapse file tree 3 files changed +31
-38
lines changed
apps/sim/tools/google_books Expand file tree Collapse file tree 3 files changed +31
-38
lines changed Original file line number Diff line number Diff line change 11import type { ToolResponse } from '@/tools/types'
22
3+ /**
4+ * Raw volume item from Google Books API response
5+ */
6+ export interface GoogleBooksVolumeItem {
7+ id : string
8+ volumeInfo : {
9+ title ?: string
10+ subtitle ?: string
11+ authors ?: string [ ]
12+ publisher ?: string
13+ publishedDate ?: string
14+ description ?: string
15+ pageCount ?: number
16+ categories ?: string [ ]
17+ averageRating ?: number
18+ ratingsCount ?: number
19+ language ?: string
20+ previewLink ?: string
21+ infoLink ?: string
22+ imageLinks ?: {
23+ thumbnail ?: string
24+ smallThumbnail ?: string
25+ }
26+ industryIdentifiers ?: Array < {
27+ type : string
28+ identifier : string
29+ } >
30+ }
31+ }
32+
333/**
434 * Volume information structure shared between search and details responses
535 */
Original file line number Diff line number Diff line change @@ -29,9 +29,6 @@ interface GoogleBooksVolumeResponse {
2929 identifier : string
3030 } >
3131 }
32- error ?: {
33- message ?: string
34- }
3532}
3633
3734export const googleBooksVolumeDetailsTool : ToolConfig <
@@ -84,10 +81,6 @@ export const googleBooksVolumeDetailsTool: ToolConfig<
8481 transformResponse : async ( response : Response ) => {
8582 const data : GoogleBooksVolumeResponse = await response . json ( )
8683
87- if ( data . error ) {
88- throw new Error ( `Google Books API error: ${ data . error . message || 'Unknown error' } ` )
89- }
90-
9184 if ( ! data . volumeInfo ) {
9285 throw new Error ( 'Volume not found' )
9386 }
Original file line number Diff line number Diff line change 11import type {
2+ GoogleBooksVolumeItem ,
23 GoogleBooksVolumeSearchParams ,
34 GoogleBooksVolumeSearchResponse ,
45 VolumeInfo ,
56} from '@/tools/google_books/types'
67import type { ToolConfig } from '@/tools/types'
78
8- interface GoogleBooksVolumeItem {
9- id : string
10- volumeInfo : {
11- title ?: string
12- subtitle ?: string
13- authors ?: string [ ]
14- publisher ?: string
15- publishedDate ?: string
16- description ?: string
17- pageCount ?: number
18- categories ?: string [ ]
19- averageRating ?: number
20- ratingsCount ?: number
21- language ?: string
22- previewLink ?: string
23- infoLink ?: string
24- imageLinks ?: {
25- thumbnail ?: string
26- smallThumbnail ?: string
27- }
28- industryIdentifiers ?: Array < {
29- type : string
30- identifier : string
31- } >
32- }
33- }
34-
359function extractVolumeInfo ( item : GoogleBooksVolumeItem ) : VolumeInfo {
3610 const info = item . volumeInfo
3711 const identifiers = info . industryIdentifiers ?? [ ]
@@ -155,10 +129,6 @@ export const googleBooksVolumeSearchTool: ToolConfig<
155129 transformResponse : async ( response : Response ) => {
156130 const data = await response . json ( )
157131
158- if ( data . error ) {
159- throw new Error ( `Google Books API error: ${ data . error . message || 'Unknown error' } ` )
160- }
161-
162132 const items : GoogleBooksVolumeItem [ ] = data . items ?? [ ]
163133 const volumes = items . map ( extractVolumeInfo )
164134
You can’t perform that action at this time.
0 commit comments