@openworkspace/calendar
v0.1.1
Published
Google Calendar API client for events, calendars, and freebusy
Maintainers
Readme
@openworkspace/calendar
Google Calendar API client for OpenWorkspace -- events, create, free/busy.
Part of the OpenWorkspace monorepo.
Install
npm install @openworkspace/calendar @openworkspace/coreUsage
import { createHttpClient } from '@openworkspace/core';
import { listEvents, createEvent, queryFreeBusy } from '@openworkspace/calendar';
const http = createHttpClient({ auth: { accessToken: 'token' } });
// List upcoming events
const result = await listEvents(http, {
timeMin: new Date().toISOString(),
maxResults: 10,
});
if (result.ok) {
for (const event of result.value.items ?? []) {
console.log(event.summary, event.start?.dateTime);
}
}
// Create an event
await createEvent(http, {
summary: 'Team Standup',
start: { dateTime: '2025-01-15T09:00:00Z' },
end: { dateTime: '2025-01-15T09:30:00Z' },
attendees: [{ email: '[email protected]' }],
});
// Check free/busy
const busy = await queryFreeBusy(http, {
timeMin: '2025-01-15T00:00:00Z',
timeMax: '2025-01-15T23:59:59Z',
items: [{ id: 'primary' }],
});API
All functions take an HttpClient as the first parameter and return Result<T, E>.
listEvents(http, options)-- List calendar eventsgetEvent(http, eventId)-- Get event by IDcreateEvent(http, options)-- Create a new eventupdateEvent(http, options)-- Update an existing eventdeleteEvent(http, eventId)-- Delete an eventsearchEvents(http, query)-- Search events by textlistCalendars(http)-- List calendarsgetAcl(http, options)-- Get calendar ACL rulesgetColors(http)-- Get calendar color definitionsqueryFreeBusy(http, options)-- Query free/busy informationfindConflicts(http, options)-- Find scheduling conflicts
