Skip to content

Commit f7e457b

Browse files
committed
fix(google-calendar): align with live API docs, add calendar/ACL update+delete tools
- remove any types from V2 response typing in get/move/quick_add/instances - add google_calendar_update_calendar (PATCH calendars.patch) - add google_calendar_delete_calendar (DELETE calendars.delete) - add google_calendar_update_acl (PATCH acl.patch) - all new tools covered by existing calendar OAuth scope, no new scopes requested
1 parent a48ecd2 commit f7e457b

10 files changed

Lines changed: 572 additions & 30 deletions

File tree

apps/sim/blocks/blocks/google_calendar.ts

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export const GoogleCalendarBlock: BlockConfig<GoogleCalendarResponse> = {
3737
{ label: 'Invite Attendees', id: 'invite' },
3838
{ label: 'Check Free/Busy', id: 'freebusy' },
3939
{ label: 'Create Calendar', id: 'create_calendar' },
40+
{ label: 'Update Calendar', id: 'update_calendar' },
41+
{ label: 'Delete Calendar', id: 'delete_calendar' },
4042
{ label: 'Share Calendar', id: 'share_calendar' },
43+
{ label: 'Update Sharing', id: 'update_acl' },
4144
{ label: 'List Sharing', id: 'list_acl' },
4245
{ label: 'Remove Sharing', id: 'unshare_calendar' },
4346
],
@@ -621,14 +624,36 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
621624
title: 'Time Zone',
622625
type: 'short-input',
623626
placeholder: 'America/Los_Angeles',
624-
condition: { field: 'operation', value: ['create_calendar', 'freebusy'] },
627+
condition: { field: 'operation', value: ['create_calendar', 'freebusy', 'update_calendar'] },
628+
},
629+
630+
{
631+
id: 'summary',
632+
title: 'New Calendar Name',
633+
type: 'short-input',
634+
placeholder: 'Team Calendar',
635+
condition: { field: 'operation', value: 'update_calendar' },
636+
},
637+
{
638+
id: 'description',
639+
title: 'New Calendar Description',
640+
type: 'long-input',
641+
placeholder: 'Shared team events and milestones',
642+
condition: { field: 'operation', value: 'update_calendar' },
643+
},
644+
{
645+
id: 'location',
646+
title: 'New Calendar Location',
647+
type: 'short-input',
648+
placeholder: 'San Francisco, CA',
649+
condition: { field: 'operation', value: 'update_calendar' },
625650
},
626651

627652
{
628653
id: 'role',
629654
title: 'Access Role',
630655
type: 'dropdown',
631-
condition: { field: 'operation', value: 'share_calendar' },
656+
condition: { field: 'operation', value: ['share_calendar', 'update_acl'] },
632657
required: true,
633658
options: [
634659
{ label: 'See free/busy only', id: 'freeBusyReader' },
@@ -668,7 +693,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
668693
id: 'sendNotifications',
669694
title: 'Send Notification Email',
670695
type: 'dropdown',
671-
condition: { field: 'operation', value: 'share_calendar' },
696+
condition: { field: 'operation', value: ['share_calendar', 'update_acl'] },
672697
mode: 'advanced',
673698
options: [
674699
{ label: 'Yes', id: 'true' },
@@ -682,7 +707,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
682707
title: 'ACL Rule ID',
683708
type: 'short-input',
684709
placeholder: 'user:person@example.com',
685-
condition: { field: 'operation', value: 'unshare_calendar' },
710+
condition: { field: 'operation', value: ['unshare_calendar', 'update_acl'] },
686711
required: true,
687712
},
688713

@@ -716,7 +741,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
716741
'google_calendar_invite',
717742
'google_calendar_freebusy',
718743
'google_calendar_create_calendar',
744+
'google_calendar_update_calendar',
745+
'google_calendar_delete_calendar',
719746
'google_calendar_share_calendar',
747+
'google_calendar_update_acl',
720748
'google_calendar_list_acl',
721749
'google_calendar_unshare_calendar',
722750
],
@@ -747,8 +775,14 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
747775
return 'google_calendar_freebusy'
748776
case 'create_calendar':
749777
return 'google_calendar_create_calendar'
778+
case 'update_calendar':
779+
return 'google_calendar_update_calendar'
780+
case 'delete_calendar':
781+
return 'google_calendar_delete_calendar'
750782
case 'share_calendar':
751783
return 'google_calendar_share_calendar'
784+
case 'update_acl':
785+
return 'google_calendar_update_acl'
752786
case 'list_acl':
753787
return 'google_calendar_list_acl'
754788
case 'unshare_calendar':
@@ -803,7 +837,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
803837
processedParams.addGoogleMeet === 'true' || processedParams.addGoogleMeet === true
804838
}
805839

806-
if (operation === 'share_calendar' && processedParams.sendNotifications !== undefined) {
840+
if (
841+
['share_calendar', 'update_acl'].includes(operation) &&
842+
processedParams.sendNotifications !== undefined
843+
) {
807844
processedParams.sendNotifications =
808845
processedParams.sendNotifications === 'true' ||
809846
processedParams.sendNotifications === true
@@ -907,7 +944,10 @@ export const GoogleCalendarV2Block: BlockConfig<GoogleCalendarResponse> = {
907944
'google_calendar_invite_v2',
908945
'google_calendar_freebusy_v2',
909946
'google_calendar_create_calendar_v2',
947+
'google_calendar_update_calendar_v2',
948+
'google_calendar_delete_calendar_v2',
910949
'google_calendar_share_calendar_v2',
950+
'google_calendar_update_acl_v2',
911951
'google_calendar_list_acl_v2',
912952
'google_calendar_unshare_calendar_v2',
913953
],
@@ -946,6 +986,7 @@ export const GoogleCalendarV2Block: BlockConfig<GoogleCalendarResponse> = {
946986
scope: { type: 'json', description: 'Grantee scope (share operation)' },
947987
rules: { type: 'json', description: 'List of ACL sharing rules (list sharing operation)' },
948988
ruleId: { type: 'string', description: 'Removed ACL rule ID (remove sharing operation)' },
989+
calendarId: { type: 'string', description: 'Deleted calendar ID (delete calendar operation)' },
949990
nextPageToken: { type: 'string', description: 'Next page token' },
950991
timeZone: { type: 'string', description: 'Calendar time zone' },
951992
},
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import { CALENDAR_API_BASE } from '@/tools/google_calendar/types'
2+
import type { ToolConfig } from '@/tools/types'
3+
4+
export interface GoogleCalendarDeleteCalendarParams {
5+
accessToken: string
6+
calendarId: string
7+
}
8+
9+
interface GoogleCalendarDeleteCalendarResponse {
10+
success: boolean
11+
output: {
12+
content: string
13+
metadata: {
14+
calendarId: string
15+
deleted: boolean
16+
}
17+
}
18+
}
19+
20+
const buildDeleteCalendarUrl = (params: GoogleCalendarDeleteCalendarParams) =>
21+
`${CALENDAR_API_BASE}/calendars/${encodeURIComponent(params.calendarId.trim())}`
22+
23+
export const deleteCalendarTool: ToolConfig<
24+
GoogleCalendarDeleteCalendarParams,
25+
GoogleCalendarDeleteCalendarResponse
26+
> = {
27+
id: 'google_calendar_delete_calendar',
28+
name: 'Google Calendar Delete Calendar',
29+
description: 'Permanently delete a secondary calendar (not the primary calendar)',
30+
version: '1.0.0',
31+
32+
oauth: {
33+
required: true,
34+
provider: 'google-calendar',
35+
},
36+
37+
params: {
38+
accessToken: {
39+
type: 'string',
40+
required: true,
41+
visibility: 'hidden',
42+
description: 'Access token for Google Calendar API',
43+
},
44+
calendarId: {
45+
type: 'string',
46+
required: true,
47+
visibility: 'user-or-llm',
48+
description:
49+
'Secondary calendar ID to delete (e.g., calendar@group.calendar.google.com). The primary calendar cannot be deleted.',
50+
},
51+
},
52+
53+
request: {
54+
url: buildDeleteCalendarUrl,
55+
method: 'DELETE',
56+
headers: (params: GoogleCalendarDeleteCalendarParams) => ({
57+
Authorization: `Bearer ${params.accessToken}`,
58+
'Content-Type': 'application/json',
59+
}),
60+
},
61+
62+
transformResponse: async (response: Response, params) => {
63+
if (response.status === 204 || response.ok) {
64+
return {
65+
success: true,
66+
output: {
67+
content: 'Calendar successfully deleted',
68+
metadata: {
69+
calendarId: params?.calendarId || '',
70+
deleted: true,
71+
},
72+
},
73+
}
74+
}
75+
76+
const errorData = await response.json().catch(() => null)
77+
throw new Error(errorData?.error?.message || 'Failed to delete calendar')
78+
},
79+
80+
outputs: {
81+
content: { type: 'string', description: 'Calendar deletion confirmation message' },
82+
metadata: {
83+
type: 'json',
84+
description: 'Deletion details including calendar ID',
85+
},
86+
},
87+
}
88+
89+
interface GoogleCalendarDeleteCalendarV2Response {
90+
success: boolean
91+
output: {
92+
calendarId: string
93+
deleted: boolean
94+
}
95+
}
96+
97+
export const deleteCalendarV2Tool: ToolConfig<
98+
GoogleCalendarDeleteCalendarParams,
99+
GoogleCalendarDeleteCalendarV2Response
100+
> = {
101+
id: 'google_calendar_delete_calendar_v2',
102+
name: 'Google Calendar Delete Calendar',
103+
description: 'Permanently delete a secondary calendar. Returns API-aligned fields only.',
104+
version: '2.0.0',
105+
oauth: deleteCalendarTool.oauth,
106+
params: deleteCalendarTool.params,
107+
request: deleteCalendarTool.request,
108+
transformResponse: async (response: Response, params) => {
109+
if (response.status === 204 || response.ok) {
110+
return {
111+
success: true,
112+
output: {
113+
calendarId: params?.calendarId || '',
114+
deleted: true,
115+
},
116+
}
117+
}
118+
119+
const errorData = await response.json().catch(() => null)
120+
throw new Error(errorData?.error?.message || 'Failed to delete calendar')
121+
},
122+
outputs: {
123+
calendarId: { type: 'string', description: 'Deleted calendar ID' },
124+
deleted: { type: 'boolean', description: 'Whether deletion was successful' },
125+
},
126+
}

apps/sim/tools/google_calendar/get.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ interface GoogleCalendarGetV2Response {
9292
summary: string | null
9393
description: string | null
9494
location: string | null
95-
start: any
96-
end: any
97-
attendees: any | null
98-
creator: any
99-
organizer: any
95+
start: GoogleCalendarApiEventResponse['start']
96+
end: GoogleCalendarApiEventResponse['end']
97+
attendees: GoogleCalendarApiEventResponse['attendees'] | null
98+
creator: GoogleCalendarApiEventResponse['creator']
99+
organizer: GoogleCalendarApiEventResponse['organizer']
100100
}
101101
}
102102

apps/sim/tools/google_calendar/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createTool, createV2Tool } from '@/tools/google_calendar/create'
22
import { createCalendarTool, createCalendarV2Tool } from '@/tools/google_calendar/create_calendar'
33
import { deleteTool, deleteV2Tool } from '@/tools/google_calendar/delete'
4+
import { deleteCalendarTool, deleteCalendarV2Tool } from '@/tools/google_calendar/delete_calendar'
45
import { freebusyTool, freebusyV2Tool } from '@/tools/google_calendar/freebusy'
56
import { getTool, getV2Tool } from '@/tools/google_calendar/get'
67
import { instancesTool, instancesV2Tool } from '@/tools/google_calendar/instances'
@@ -16,10 +17,13 @@ import {
1617
unshareCalendarV2Tool,
1718
} from '@/tools/google_calendar/unshare_calendar'
1819
import { updateTool, updateV2Tool } from '@/tools/google_calendar/update'
20+
import { updateAclTool, updateAclV2Tool } from '@/tools/google_calendar/update_acl'
21+
import { updateCalendarTool, updateCalendarV2Tool } from '@/tools/google_calendar/update_calendar'
1922

2023
export const googleCalendarCreateTool = createTool
2124
export const googleCalendarCreateCalendarTool = createCalendarTool
2225
export const googleCalendarDeleteTool = deleteTool
26+
export const googleCalendarDeleteCalendarTool = deleteCalendarTool
2327
export const googleCalendarFreeBusyTool = freebusyTool
2428
export const googleCalendarGetTool = getTool
2529
export const googleCalendarInstancesTool = instancesTool
@@ -32,10 +36,13 @@ export const googleCalendarQuickAddTool = quickAddTool
3236
export const googleCalendarShareCalendarTool = shareCalendarTool
3337
export const googleCalendarUnshareCalendarTool = unshareCalendarTool
3438
export const googleCalendarUpdateTool = updateTool
39+
export const googleCalendarUpdateAclTool = updateAclTool
40+
export const googleCalendarUpdateCalendarTool = updateCalendarTool
3541

3642
export const googleCalendarCreateV2Tool = createV2Tool
3743
export const googleCalendarCreateCalendarV2Tool = createCalendarV2Tool
3844
export const googleCalendarDeleteV2Tool = deleteV2Tool
45+
export const googleCalendarDeleteCalendarV2Tool = deleteCalendarV2Tool
3946
export const googleCalendarFreeBusyV2Tool = freebusyV2Tool
4047
export const googleCalendarGetV2Tool = getV2Tool
4148
export const googleCalendarInstancesV2Tool = instancesV2Tool
@@ -48,3 +55,5 @@ export const googleCalendarQuickAddV2Tool = quickAddV2Tool
4855
export const googleCalendarShareCalendarV2Tool = shareCalendarV2Tool
4956
export const googleCalendarUnshareCalendarV2Tool = unshareCalendarV2Tool
5057
export const googleCalendarUpdateV2Tool = updateV2Tool
58+
export const googleCalendarUpdateAclV2Tool = updateAclV2Tool
59+
export const googleCalendarUpdateCalendarV2Tool = updateCalendarV2Tool

apps/sim/tools/google_calendar/instances.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,32 @@ export const instancesTool: ToolConfig<
212212
},
213213
}
214214

215+
interface GoogleCalendarInstancesV2Instance {
216+
id: string
217+
htmlLink: string
218+
status: string
219+
summary: string | null
220+
description: string | null
221+
location: string | null
222+
start: GoogleCalendarApiEventResponse['start']
223+
end: GoogleCalendarApiEventResponse['end']
224+
attendees: GoogleCalendarApiEventResponse['attendees'] | null
225+
creator: GoogleCalendarApiEventResponse['creator']
226+
organizer: GoogleCalendarApiEventResponse['organizer']
227+
recurringEventId: string
228+
originalStartTime: {
229+
dateTime?: string
230+
date?: string
231+
timeZone?: string
232+
}
233+
}
234+
215235
interface GoogleCalendarInstancesV2Response {
216236
success: boolean
217237
output: {
218238
nextPageToken: string | null
219239
timeZone: string | null
220-
instances: Array<Record<string, any>>
240+
instances: GoogleCalendarInstancesV2Instance[]
221241
}
222242
}
223243

apps/sim/tools/google_calendar/move.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ interface GoogleCalendarMoveV2Response {
157157
summary: string | null
158158
description: string | null
159159
location: string | null
160-
start: any
161-
end: any
162-
attendees: any | null
163-
creator: any
164-
organizer: any
160+
start: GoogleCalendarApiEventResponse['start']
161+
end: GoogleCalendarApiEventResponse['end']
162+
attendees: GoogleCalendarApiEventResponse['attendees'] | null
163+
creator: GoogleCalendarApiEventResponse['creator']
164+
organizer: GoogleCalendarApiEventResponse['organizer']
165165
}
166166
}
167167

0 commit comments

Comments
 (0)