Skip to content

Commit db05a26

Browse files
authored
fix(integrations): validate google maps, google translate, google bigquery, google books, google appsheet and google pagespeed (#10165)
* fix(integrations): validate google maps, google translate, google bigquery, google books, google appsheet and google pagespeed * fix(integrations): trim the BigQuery project id in request bodies and type the Low solar quality * fix(integrations): accept a numeric BigQuery project id in request bodies
1 parent e85d2f2 commit db05a26

28 files changed

Lines changed: 134 additions & 52 deletions

‎apps/docs/content/docs/integrations/google_maps.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ Get solar potential and panel insights for the building nearest a location
472472
| `apiKey` | string | Yes | Google Maps API key with Solar API enabled |
473473
| `lat` | number | Yes | Latitude coordinate |
474474
| `lng` | number | Yes | Longitude coordinate |
475-
| `requiredQuality` | string | No | Minimum imagery quality to accept \(HIGH, MEDIUM, or BASE\) |
475+
| `requiredQuality` | string | No | Minimum imagery quality to accept \(HIGH, MEDIUM, LOW, or BASE\) |
476476

477477
#### Output
478478

‎apps/docs/content/docs/integrations/google_translate.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Translate text between languages using the Google Cloud Translation API. Support
3333
| `text` | string | Yes | The text to translate |
3434
| `target` | string | Yes | Target language code \(e.g., "es", "fr", "de", "ja"\) |
3535
| `source` | string | No | Source language code. If omitted, the API will auto-detect the source language. |
36-
| `format` | string | No | Format of the text: "text" for plain text, "html" for HTML content |
36+
| `format` | string | No | Format of the text: "text" for plain text, "html" for HTML content. Defaults to "html", which returns characters such as apostrophes as HTML entities |
3737

3838
#### Output
3939

‎apps/sim/blocks/blocks/google_maps.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,19 @@ describe('GoogleMapsBlock agent tool calls', () => {
1717
expect({ ...inputs, ...mapped }).toMatchObject(inputs)
1818
})
1919
})
20+
21+
/**
22+
* Every operation's coordinate fields serialize with the block, so a value left in another
23+
* operation's latitude/longitude must not replace the coordinates of the selected operation.
24+
*/
25+
describe('GoogleMapsBlock coordinate fields', () => {
26+
const stored = { latitude: '40.7128', longitude: '-74.006', aqLatitude: '1', aqLongitude: '2' }
27+
28+
it.each([
29+
['reverse_geocode', { lat: 40.7128, lng: -74.006 }],
30+
['air_quality', { lat: 1, lng: 2 }],
31+
])('sends the %s coordinates when the other fields hold stale values', (operation, expected) => {
32+
const mapped = GoogleMapsBlock.tools.config?.params?.({ operation, ...stored })
33+
expect(mapped).toMatchObject(expected)
34+
})
35+
})

‎apps/sim/blocks/blocks/google_maps.ts‎

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import type { BlockConfig, BlockMeta } from '@/blocks/types'
33
import { AuthMode, IntegrationType } from '@/blocks/types'
44
import { mapperOperation, toolCallArg } from '@/blocks/utils'
55

6+
/** Operations whose coordinates come from the `aqLatitude`/`aqLongitude` fields. */
7+
const AQ_COORDINATE_OPERATIONS = ['air_quality', 'pollen', 'solar', 'places_nearby']
8+
69
export const GoogleMapsBlock: BlockConfig = {
710
type: 'google_maps',
811
name: 'Google Maps',
@@ -483,16 +486,16 @@ export const GoogleMapsBlock: BlockConfig = {
483486
title: 'Latitude',
484487
type: 'short-input',
485488
placeholder: '37.4224764',
486-
condition: { field: 'operation', value: ['air_quality', 'pollen', 'solar', 'places_nearby'] },
487-
required: { field: 'operation', value: ['air_quality', 'pollen', 'solar', 'places_nearby'] },
489+
condition: { field: 'operation', value: AQ_COORDINATE_OPERATIONS },
490+
required: { field: 'operation', value: AQ_COORDINATE_OPERATIONS },
488491
},
489492
{
490493
id: 'aqLongitude',
491494
title: 'Longitude',
492495
type: 'short-input',
493496
placeholder: '-122.0842499',
494-
condition: { field: 'operation', value: ['air_quality', 'pollen', 'solar', 'places_nearby'] },
495-
required: { field: 'operation', value: ['air_quality', 'pollen', 'solar', 'places_nearby'] },
497+
condition: { field: 'operation', value: AQ_COORDINATE_OPERATIONS },
498+
required: { field: 'operation', value: AQ_COORDINATE_OPERATIONS },
496499
},
497500
{
498501
id: 'languageCode',
@@ -524,9 +527,10 @@ export const GoogleMapsBlock: BlockConfig = {
524527
title: 'Minimum Imagery Quality',
525528
type: 'dropdown',
526529
options: [
527-
{ label: 'Any', id: '' },
530+
{ label: 'Default (High only)', id: '' },
528531
{ label: 'High', id: 'HIGH' },
529532
{ label: 'Medium', id: 'MEDIUM' },
533+
{ label: 'Low', id: 'LOW' },
530534
{ label: 'Base', id: 'BASE' },
531535
],
532536
condition: { field: 'operation', value: 'solar' },
@@ -595,21 +599,11 @@ export const GoogleMapsBlock: BlockConfig = {
595599
}
596600
}
597601

598-
let lat: number | undefined
599-
let lng: number | undefined
600-
if (params.latitude) {
601-
lat = Number.parseFloat(params.latitude)
602-
}
603-
if (params.longitude) {
604-
lng = Number.parseFloat(params.longitude)
605-
}
606-
607-
if (params.aqLatitude) {
608-
lat = Number.parseFloat(params.aqLatitude)
609-
}
610-
if (params.aqLongitude) {
611-
lng = Number.parseFloat(params.aqLongitude)
612-
}
602+
const usesAqCoordinates = AQ_COORDINATE_OPERATIONS.includes(operation)
603+
const latInput = usesAqCoordinates ? params.aqLatitude : params.latitude
604+
const lngInput = usesAqCoordinates ? params.aqLongitude : params.longitude
605+
const lat = latInput ? Number.parseFloat(latInput) : undefined
606+
const lng = lngInput ? Number.parseFloat(lngInput) : undefined
613607

614608
let timestamp: number | undefined
615609
if (params.timestamp) {

‎apps/sim/blocks/blocks/google_translate.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@ export const GoogleTranslateBlock: BlockConfig = {
199199
options: [{ label: 'Auto-detect', id: '' }, ...SUPPORTED_LANGUAGES],
200200
value: () => '',
201201
},
202+
{
203+
id: 'format',
204+
title: 'Text Format',
205+
type: 'dropdown',
206+
condition: { field: 'operation', value: 'text' },
207+
options: [
208+
{ label: 'Default (HTML)', id: '' },
209+
{ label: 'Plain text', id: 'text' },
210+
{ label: 'HTML', id: 'html' },
211+
],
212+
value: () => '',
213+
mode: 'advanced',
214+
},
202215
{
203216
id: 'apiKey',
204217
title: 'API Key',
@@ -219,6 +232,7 @@ export const GoogleTranslateBlock: BlockConfig = {
219232
text: { type: 'string', description: 'Text to translate or detect language of' },
220233
target: { type: 'string', description: 'Target language code' },
221234
source: { type: 'string', description: 'Source language code (optional, auto-detected)' },
235+
format: { type: 'string', description: 'Text format: text (plain) or html (default)' },
222236
apiKey: { type: 'string', description: 'Google Cloud API key' },
223237
},
224238
outputs: {

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

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

‎apps/sim/tools/google_appsheet/add_rows.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import type {
22
GoogleAppsheetAddParams,
33
GoogleAppsheetAddResponse,
44
} from '@/tools/google_appsheet/types'
5-
import { buildAppsheetActionUrl, readAppsheetResponseBody } from '@/tools/google_appsheet/utils'
5+
import {
6+
appsheetResponseRows,
7+
buildAppsheetActionUrl,
8+
readAppsheetResponseBody,
9+
} from '@/tools/google_appsheet/utils'
610
import type { ToolConfig } from '@/tools/types'
711

812
export const googleAppsheetAddRowsTool: ToolConfig<
@@ -70,7 +74,7 @@ export const googleAppsheetAddRowsTool: ToolConfig<
7074
throw new Error(data.error?.message || data.message || 'Failed to add AppSheet rows')
7175
}
7276

73-
const rows = data.Rows ?? data.rows ?? []
77+
const rows = appsheetResponseRows(data)
7478

7579
return {
7680
success: true,

‎apps/sim/tools/google_appsheet/delete_rows.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import type {
22
GoogleAppsheetDeleteParams,
33
GoogleAppsheetDeleteResponse,
44
} from '@/tools/google_appsheet/types'
5-
import { buildAppsheetActionUrl, readAppsheetResponseBody } from '@/tools/google_appsheet/utils'
5+
import {
6+
appsheetResponseRows,
7+
buildAppsheetActionUrl,
8+
readAppsheetResponseBody,
9+
} from '@/tools/google_appsheet/utils'
610
import type { ToolConfig } from '@/tools/types'
711

812
export const googleAppsheetDeleteRowsTool: ToolConfig<
@@ -70,7 +74,7 @@ export const googleAppsheetDeleteRowsTool: ToolConfig<
7074
throw new Error(data.error?.message || data.message || 'Failed to delete AppSheet rows')
7175
}
7276

73-
const rows = data.Rows ?? data.rows ?? []
77+
const rows = appsheetResponseRows(data)
7478

7579
return {
7680
success: true,

‎apps/sim/tools/google_appsheet/edit_rows.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import type {
22
GoogleAppsheetEditParams,
33
GoogleAppsheetEditResponse,
44
} from '@/tools/google_appsheet/types'
5-
import { buildAppsheetActionUrl, readAppsheetResponseBody } from '@/tools/google_appsheet/utils'
5+
import {
6+
appsheetResponseRows,
7+
buildAppsheetActionUrl,
8+
readAppsheetResponseBody,
9+
} from '@/tools/google_appsheet/utils'
610
import type { ToolConfig } from '@/tools/types'
711

812
export const googleAppsheetEditRowsTool: ToolConfig<
@@ -70,7 +74,7 @@ export const googleAppsheetEditRowsTool: ToolConfig<
7074
throw new Error(data.error?.message || data.message || 'Failed to edit AppSheet rows')
7175
}
7276

73-
const rows = data.Rows ?? data.rows ?? []
77+
const rows = appsheetResponseRows(data)
7478

7579
return {
7680
success: true,

‎apps/sim/tools/google_appsheet/find_rows.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import type {
22
GoogleAppsheetFindParams,
33
GoogleAppsheetFindResponse,
44
} from '@/tools/google_appsheet/types'
5-
import { buildAppsheetActionUrl, readAppsheetResponseBody } from '@/tools/google_appsheet/utils'
5+
import {
6+
appsheetResponseRows,
7+
buildAppsheetActionUrl,
8+
readAppsheetResponseBody,
9+
} from '@/tools/google_appsheet/utils'
610
import type { ToolConfig } from '@/tools/types'
711

812
export const googleAppsheetFindRowsTool: ToolConfig<
@@ -70,7 +74,7 @@ export const googleAppsheetFindRowsTool: ToolConfig<
7074
throw new Error(data.error?.message || data.message || 'Failed to find AppSheet rows')
7175
}
7276

73-
const rows = data.Rows ?? data.rows ?? []
77+
const rows = appsheetResponseRows(data)
7478

7579
return {
7680
success: true,

0 commit comments

Comments
 (0)