Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 46 additions & 5 deletions apps/sim/blocks/blocks/google_calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const GoogleCalendarBlock: BlockConfig<GoogleCalendarResponse> = {
{ label: 'Invite Attendees', id: 'invite' },
{ label: 'Check Free/Busy', id: 'freebusy' },
{ label: 'Create Calendar', id: 'create_calendar' },
{ label: 'Update Calendar', id: 'update_calendar' },
{ label: 'Delete Calendar', id: 'delete_calendar' },
{ label: 'Share Calendar', id: 'share_calendar' },
{ label: 'Update Sharing', id: 'update_acl' },
{ label: 'List Sharing', id: 'list_acl' },
{ label: 'Remove Sharing', id: 'unshare_calendar' },
],
Expand Down Expand Up @@ -621,14 +624,36 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
title: 'Time Zone',
type: 'short-input',
placeholder: 'America/Los_Angeles',
condition: { field: 'operation', value: ['create_calendar', 'freebusy'] },
condition: { field: 'operation', value: ['create_calendar', 'freebusy', 'update_calendar'] },
},

{
id: 'summary',
title: 'New Calendar Name',
type: 'short-input',
placeholder: 'Team Calendar',
condition: { field: 'operation', value: 'update_calendar' },
},
{
id: 'description',
title: 'New Calendar Description',
type: 'long-input',
placeholder: 'Shared team events and milestones',
condition: { field: 'operation', value: 'update_calendar' },
},
{
id: 'location',
title: 'New Calendar Location',
type: 'short-input',
placeholder: 'San Francisco, CA',
condition: { field: 'operation', value: 'update_calendar' },
},

{
id: 'role',
title: 'Access Role',
type: 'dropdown',
condition: { field: 'operation', value: 'share_calendar' },
condition: { field: 'operation', value: ['share_calendar', 'update_acl'] },
required: true,
options: [
{ label: 'See free/busy only', id: 'freeBusyReader' },
Expand Down Expand Up @@ -668,7 +693,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
id: 'sendNotifications',
title: 'Send Notification Email',
type: 'dropdown',
condition: { field: 'operation', value: 'share_calendar' },
condition: { field: 'operation', value: ['share_calendar', 'update_acl'] },
mode: 'advanced',
options: [
{ label: 'Yes', id: 'true' },
Expand All @@ -682,7 +707,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
title: 'ACL Rule ID',
type: 'short-input',
placeholder: 'user:person@example.com',
condition: { field: 'operation', value: 'unshare_calendar' },
condition: { field: 'operation', value: ['unshare_calendar', 'update_acl'] },
required: true,
},

Expand Down Expand Up @@ -716,7 +741,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
'google_calendar_invite',
'google_calendar_freebusy',
'google_calendar_create_calendar',
'google_calendar_update_calendar',
'google_calendar_delete_calendar',
'google_calendar_share_calendar',
'google_calendar_update_acl',
'google_calendar_list_acl',
'google_calendar_unshare_calendar',
],
Expand Down Expand Up @@ -747,8 +775,14 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
return 'google_calendar_freebusy'
case 'create_calendar':
return 'google_calendar_create_calendar'
case 'update_calendar':
return 'google_calendar_update_calendar'
case 'delete_calendar':
return 'google_calendar_delete_calendar'
case 'share_calendar':
return 'google_calendar_share_calendar'
case 'update_acl':
return 'google_calendar_update_acl'
case 'list_acl':
return 'google_calendar_list_acl'
case 'unshare_calendar':
Expand Down Expand Up @@ -803,7 +837,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
processedParams.addGoogleMeet === 'true' || processedParams.addGoogleMeet === true
}

if (operation === 'share_calendar' && processedParams.sendNotifications !== undefined) {
if (
['share_calendar', 'update_acl'].includes(operation) &&
processedParams.sendNotifications !== undefined
) {
processedParams.sendNotifications =
processedParams.sendNotifications === 'true' ||
processedParams.sendNotifications === true
Expand Down Expand Up @@ -907,7 +944,10 @@ export const GoogleCalendarV2Block: BlockConfig<GoogleCalendarResponse> = {
'google_calendar_invite_v2',
'google_calendar_freebusy_v2',
'google_calendar_create_calendar_v2',
'google_calendar_update_calendar_v2',
'google_calendar_delete_calendar_v2',
'google_calendar_share_calendar_v2',
'google_calendar_update_acl_v2',
'google_calendar_list_acl_v2',
'google_calendar_unshare_calendar_v2',
],
Expand Down Expand Up @@ -946,6 +986,7 @@ export const GoogleCalendarV2Block: BlockConfig<GoogleCalendarResponse> = {
scope: { type: 'json', description: 'Grantee scope (share operation)' },
rules: { type: 'json', description: 'List of ACL sharing rules (list sharing operation)' },
ruleId: { type: 'string', description: 'Removed ACL rule ID (remove sharing operation)' },
calendarId: { type: 'string', description: 'Deleted calendar ID (delete calendar operation)' },
nextPageToken: { type: 'string', description: 'Next page token' },
timeZone: { type: 'string', description: 'Calendar time zone' },
},
Expand Down
126 changes: 126 additions & 0 deletions apps/sim/tools/google_calendar/delete_calendar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { CALENDAR_API_BASE } from '@/tools/google_calendar/types'
import type { ToolConfig } from '@/tools/types'

export interface GoogleCalendarDeleteCalendarParams {
accessToken: string
calendarId: string
}

interface GoogleCalendarDeleteCalendarResponse {
success: boolean
output: {
content: string
metadata: {
calendarId: string
deleted: boolean
}
}
}

const buildDeleteCalendarUrl = (params: GoogleCalendarDeleteCalendarParams) =>
`${CALENDAR_API_BASE}/calendars/${encodeURIComponent(params.calendarId.trim())}`

export const deleteCalendarTool: ToolConfig<
GoogleCalendarDeleteCalendarParams,
GoogleCalendarDeleteCalendarResponse
> = {
id: 'google_calendar_delete_calendar',
name: 'Google Calendar Delete Calendar',
description: 'Permanently delete a secondary calendar (not the primary calendar)',
version: '1.0.0',

oauth: {
required: true,
provider: 'google-calendar',
},

params: {
accessToken: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Access token for Google Calendar API',
},
calendarId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Secondary calendar ID to delete (e.g., calendar@group.calendar.google.com). The primary calendar cannot be deleted.',
},
},

request: {
url: buildDeleteCalendarUrl,
method: 'DELETE',
headers: (params: GoogleCalendarDeleteCalendarParams) => ({
Authorization: `Bearer ${params.accessToken}`,
'Content-Type': 'application/json',
}),
},

transformResponse: async (response: Response, params) => {
if (response.status === 204 || response.ok) {
return {
success: true,
output: {
content: 'Calendar successfully deleted',
metadata: {
calendarId: params?.calendarId || '',
deleted: true,
},
},
}
}

const errorData = await response.json().catch(() => null)
throw new Error(errorData?.error?.message || 'Failed to delete calendar')
},

outputs: {
content: { type: 'string', description: 'Calendar deletion confirmation message' },
metadata: {
type: 'json',
description: 'Deletion details including calendar ID',
},
},
}

interface GoogleCalendarDeleteCalendarV2Response {
success: boolean
output: {
calendarId: string
deleted: boolean
}
}

export const deleteCalendarV2Tool: ToolConfig<
GoogleCalendarDeleteCalendarParams,
GoogleCalendarDeleteCalendarV2Response
> = {
id: 'google_calendar_delete_calendar_v2',
name: 'Google Calendar Delete Calendar',
description: 'Permanently delete a secondary calendar. Returns API-aligned fields only.',
version: '2.0.0',
oauth: deleteCalendarTool.oauth,
params: deleteCalendarTool.params,
request: deleteCalendarTool.request,
transformResponse: async (response: Response, params) => {
if (response.status === 204 || response.ok) {
return {
success: true,
output: {
calendarId: params?.calendarId || '',
deleted: true,
},
}
}

const errorData = await response.json().catch(() => null)
throw new Error(errorData?.error?.message || 'Failed to delete calendar')
},
outputs: {
calendarId: { type: 'string', description: 'Deleted calendar ID' },
deleted: { type: 'boolean', description: 'Whether deletion was successful' },
},
}
10 changes: 5 additions & 5 deletions apps/sim/tools/google_calendar/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ interface GoogleCalendarGetV2Response {
summary: string | null
description: string | null
location: string | null
start: any
end: any
attendees: any | null
creator: any
organizer: any
start: GoogleCalendarApiEventResponse['start']
end: GoogleCalendarApiEventResponse['end']
attendees: GoogleCalendarApiEventResponse['attendees'] | null
creator: GoogleCalendarApiEventResponse['creator']
organizer: GoogleCalendarApiEventResponse['organizer']
}
}

Expand Down
9 changes: 9 additions & 0 deletions apps/sim/tools/google_calendar/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createTool, createV2Tool } from '@/tools/google_calendar/create'
import { createCalendarTool, createCalendarV2Tool } from '@/tools/google_calendar/create_calendar'
import { deleteTool, deleteV2Tool } from '@/tools/google_calendar/delete'
import { deleteCalendarTool, deleteCalendarV2Tool } from '@/tools/google_calendar/delete_calendar'
import { freebusyTool, freebusyV2Tool } from '@/tools/google_calendar/freebusy'
import { getTool, getV2Tool } from '@/tools/google_calendar/get'
import { instancesTool, instancesV2Tool } from '@/tools/google_calendar/instances'
Expand All @@ -16,10 +17,13 @@ import {
unshareCalendarV2Tool,
} from '@/tools/google_calendar/unshare_calendar'
import { updateTool, updateV2Tool } from '@/tools/google_calendar/update'
import { updateAclTool, updateAclV2Tool } from '@/tools/google_calendar/update_acl'
import { updateCalendarTool, updateCalendarV2Tool } from '@/tools/google_calendar/update_calendar'

export const googleCalendarCreateTool = createTool
export const googleCalendarCreateCalendarTool = createCalendarTool
export const googleCalendarDeleteTool = deleteTool
export const googleCalendarDeleteCalendarTool = deleteCalendarTool
export const googleCalendarFreeBusyTool = freebusyTool
export const googleCalendarGetTool = getTool
export const googleCalendarInstancesTool = instancesTool
Expand All @@ -32,10 +36,13 @@ export const googleCalendarQuickAddTool = quickAddTool
export const googleCalendarShareCalendarTool = shareCalendarTool
export const googleCalendarUnshareCalendarTool = unshareCalendarTool
export const googleCalendarUpdateTool = updateTool
export const googleCalendarUpdateAclTool = updateAclTool
export const googleCalendarUpdateCalendarTool = updateCalendarTool

export const googleCalendarCreateV2Tool = createV2Tool
export const googleCalendarCreateCalendarV2Tool = createCalendarV2Tool
export const googleCalendarDeleteV2Tool = deleteV2Tool
export const googleCalendarDeleteCalendarV2Tool = deleteCalendarV2Tool
export const googleCalendarFreeBusyV2Tool = freebusyV2Tool
export const googleCalendarGetV2Tool = getV2Tool
export const googleCalendarInstancesV2Tool = instancesV2Tool
Expand All @@ -48,3 +55,5 @@ export const googleCalendarQuickAddV2Tool = quickAddV2Tool
export const googleCalendarShareCalendarV2Tool = shareCalendarV2Tool
export const googleCalendarUnshareCalendarV2Tool = unshareCalendarV2Tool
export const googleCalendarUpdateV2Tool = updateV2Tool
export const googleCalendarUpdateAclV2Tool = updateAclV2Tool
export const googleCalendarUpdateCalendarV2Tool = updateCalendarV2Tool
22 changes: 21 additions & 1 deletion apps/sim/tools/google_calendar/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,32 @@ export const instancesTool: ToolConfig<
},
}

interface GoogleCalendarInstancesV2Instance {
id: string
htmlLink: string
status: string
summary: string | null
description: string | null
location: string | null
start: GoogleCalendarApiEventResponse['start']
end: GoogleCalendarApiEventResponse['end']
attendees: GoogleCalendarApiEventResponse['attendees'] | null
creator: GoogleCalendarApiEventResponse['creator']
organizer: GoogleCalendarApiEventResponse['organizer']
recurringEventId: string
originalStartTime: {
dateTime?: string
date?: string
timeZone?: string
}
}

interface GoogleCalendarInstancesV2Response {
success: boolean
output: {
nextPageToken: string | null
timeZone: string | null
instances: Array<Record<string, any>>
instances: GoogleCalendarInstancesV2Instance[]
}
}

Expand Down
10 changes: 5 additions & 5 deletions apps/sim/tools/google_calendar/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ interface GoogleCalendarMoveV2Response {
summary: string | null
description: string | null
location: string | null
start: any
end: any
attendees: any | null
creator: any
organizer: any
start: GoogleCalendarApiEventResponse['start']
end: GoogleCalendarApiEventResponse['end']
attendees: GoogleCalendarApiEventResponse['attendees'] | null
creator: GoogleCalendarApiEventResponse['creator']
organizer: GoogleCalendarApiEventResponse['organizer']
}
}

Expand Down
Loading
Loading