Skip to content

Commit 52948d1

Browse files
committed
fix(google-slides): address PR review — explicit videoId mapping, fast base64 export, remove dead utility
1 parent dc712e5 commit 52948d1

3 files changed

Lines changed: 3 additions & 20 deletions

File tree

apps/sim/blocks/blocks/google_slides.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,7 @@ Return ONLY the text content - no explanations, no markdown formatting markers,
29772977
if (params.operation === 'create_video') {
29782978
result.pageObjectId = params.videoPageObjectId
29792979
if (params.videoSource) result.source = params.videoSource
2980+
if (params.videoId) result.videoId = params.videoId
29802981
const vw = toNum(params.videoWidth)
29812982
const vh = toNum(params.videoHeight)
29822983
const vpx = toNum(params.videoPositionX)

apps/sim/tools/google_slides/export_presentation.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,7 @@ export const exportPresentationTool: ToolConfig<
9393
}
9494

9595
const buffer = await response.arrayBuffer()
96-
const bytes = new Uint8Array(buffer)
97-
let binary = ''
98-
for (let i = 0; i < bytes.length; i += 1) {
99-
binary += String.fromCharCode(bytes[i])
100-
}
101-
const contentBase64 =
102-
typeof btoa === 'function' ? btoa(binary) : Buffer.from(buffer).toString('base64')
96+
const contentBase64 = Buffer.from(buffer).toString('base64')
10397

10498
const presentationId = params?.presentationId?.trim() || ''
10599
const format = (params?.exportFormat || 'PDF').toUpperCase()
@@ -110,7 +104,7 @@ export const exportPresentationTool: ToolConfig<
110104
output: {
111105
contentBase64,
112106
mimeType: mime,
113-
sizeBytes: bytes.length,
107+
sizeBytes: buffer.byteLength,
114108
metadata: {
115109
presentationId,
116110
url: presentationUrl(presentationId),

apps/sim/tools/google_slides/utils.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,3 @@ export function batchUpdateUrl(presentationId: string | undefined): string {
134134
if (!id) throw new Error('Presentation ID is required')
135135
return `https://slides.googleapis.com/v1/presentations/${id}:batchUpdate`
136136
}
137-
138-
/**
139-
* Build a FieldMask string from a record of set/unset fields. Keys with
140-
* defined (non-undefined) values are included; others are omitted. Useful
141-
* for UpdateXxxProperties requests where only changed fields should be sent.
142-
*/
143-
export function buildFieldMask(fields: Record<string, unknown>): string {
144-
return Object.entries(fields)
145-
.filter(([, v]) => v !== undefined && v !== null && v !== '')
146-
.map(([k]) => k)
147-
.join(',')
148-
}

0 commit comments

Comments
 (0)