@squidcloud/google-calendar-client 1.0.146-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,131 @@
1
+ /**
2
+ * OAuth2 scopes (ie level of access) required for Google Calendar integration.
3
+ * Use these scopes when requesting the OAuth2 auth code from Google. Provided here for convenience only.
4
+ *
5
+ */
6
+ export declare const GOOGLE_CALENDAR_SCOPES: readonly ["openid", "email", "https://www.googleapis.com/auth/calendar.events"];
7
+ /**
8
+ * Represents an attendee of a calendar event
9
+ */
10
+ export interface CalendarEventAttendee {
11
+ email: string;
12
+ status: string;
13
+ }
14
+ /**
15
+ * Represents a formatted calendar event with all relevant details
16
+ */
17
+ export interface CalendarEvent {
18
+ id: string;
19
+ summary: string;
20
+ description?: string;
21
+ start: string;
22
+ end: string;
23
+ location?: string;
24
+ attendees?: Array<CalendarEventAttendee>;
25
+ htmlLink?: string;
26
+ }
27
+ /**
28
+ * Request parameters for retrieving calendar events
29
+ */
30
+ export interface GetCalendarEventsRequest {
31
+ /** The ID of the Google Calendar integration in the Squid console. */
32
+ integrationId: string;
33
+ /**
34
+ * User-specific identifier to retrieve the correct OAuth tokens.
35
+ */
36
+ identifier: string;
37
+ /** Start date for the event query. Defaults to today. */
38
+ startDate?: Date;
39
+ /** End date for the event query. Defaults to 7 days from start. */
40
+ endDate?: Date;
41
+ /** Maximum number of events to return. Defaults to 50. */
42
+ maxResults?: number;
43
+ /** Calendar ID to query. Defaults to "primary". */
44
+ calendarId?: string;
45
+ }
46
+ /**
47
+ * Attendee information for a calendar event
48
+ */
49
+ export interface EventAttendee {
50
+ /** Email address of the attendee */
51
+ email: string;
52
+ /** Display name of the attendee (optional) */
53
+ displayName?: string;
54
+ }
55
+ /**
56
+ * Event reminder/notification
57
+ */
58
+ export interface EventReminder {
59
+ /** Reminder method: 'email' or 'popup' */
60
+ method: 'email' | 'popup';
61
+ /** Number of minutes before the event when the reminder should trigger */
62
+ minutes: number;
63
+ }
64
+ /**
65
+ * Recurrence rule frequency
66
+ */
67
+ export type RecurrenceFrequency = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
68
+ /**
69
+ * Recurrence rule for repeating events
70
+ */
71
+ export interface RecurrenceRule {
72
+ /** How often the event repeats */
73
+ frequency: RecurrenceFrequency;
74
+ /** Number of occurrences after which to stop repeating. Mutually exclusive with until. */
75
+ count?: number;
76
+ /** Date until which the event repeats. Mutually exclusive with count. */
77
+ until?: Date;
78
+ /** Interval between recurrences (e.g., every 2 weeks). Defaults to 1. */
79
+ interval?: number;
80
+ /** For WEEKLY frequency, which days of the week (e.g., ['MO', 'WE', 'FR']). */
81
+ byDay?: Array<'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA' | 'SU'>;
82
+ }
83
+ /**
84
+ * Event visibility settings
85
+ */
86
+ export type EventVisibility = 'default' | 'public' | 'private';
87
+ /**
88
+ * Request parameters for upserting (creating or updating) a calendar event
89
+ */
90
+ export interface UpsertCalendarEventRequest {
91
+ /** The ID of the Google Calendar integration in the Squid console. */
92
+ integrationId: string;
93
+ /**
94
+ * User-specific identifier to retrieve the correct OAuth tokens.
95
+ */
96
+ identifier: string;
97
+ /** Event ID for updating an existing event. If not provided, creates a new event. */
98
+ eventId?: string;
99
+ /** Calendar ID where the event should be created/updated. Defaults to "primary". */
100
+ calendarId?: string;
101
+ /** Title/summary of the event (required) */
102
+ summary: string;
103
+ /** Detailed description of the event (optional) */
104
+ description?: string;
105
+ /** Event start time. For all-day events, use date without time. */
106
+ start: Date;
107
+ /** Event end time. For all-day events, use date without time. */
108
+ end: Date;
109
+ /** Whether this is an all-day event. If true, start/end are treated as dates only. */
110
+ isAllDay?: boolean;
111
+ /** Geographic location of the event as free-form text (optional) */
112
+ location?: string;
113
+ /** List of attendees to invite to the event (optional) */
114
+ attendees?: Array<EventAttendee>;
115
+ /** Timezone for the event (e.g., "America/Los_Angeles"). Defaults to user's calendar timezone. */
116
+ timeZone?: string;
117
+ /** Add Google Meet video conferencing to the event. If true, creates a Google Meet link. */
118
+ addMeetLink?: boolean;
119
+ /** List of reminders/notifications for the event (optional) */
120
+ reminders?: Array<EventReminder>;
121
+ /** Recurrence rule for repeating events (optional) */
122
+ recurrence?: RecurrenceRule;
123
+ /** Visibility of the event. Defaults to "default". */
124
+ visibility?: EventVisibility;
125
+ /** Whether guests can modify the event. Defaults to false. */
126
+ guestsCanModify?: boolean;
127
+ /** Whether guests can invite others. Defaults to true. */
128
+ guestsCanInviteOthers?: boolean;
129
+ /** Whether guests can see other guests. Defaults to true. */
130
+ guestsCanSeeOtherGuests?: boolean;
131
+ }
@@ -0,0 +1,51 @@
1
+ import { GetAccessTokenResponse, Squid } from '@squidcloud/client';
2
+ import { CalendarEvent, GetCalendarEventsRequest, UpsertCalendarEventRequest } from '../../common/src/google-calendar-types';
3
+ /**
4
+ * Client for interacting with the Google Calendar connector.
5
+ * Provides methods to save OAuth tokens and constants for OAuth setup.
6
+ */
7
+ export declare class SquidGoogleCalendarClient {
8
+ private readonly squid;
9
+ private readonly integrationId;
10
+ /**
11
+ * OAuth2 scopes required for Google Calendar integration.
12
+ * Use these when generating the OAuth authorization URL.
13
+ */
14
+ static readonly SCOPES: readonly ["openid", "email", "https://www.googleapis.com/auth/calendar.events"];
15
+ /**
16
+ * Creates a new Google Calendar client instance.
17
+ *
18
+ * @param squid - Squid client instance
19
+ * @param integrationId - The ID of the Google Calendar integration in the Squid console
20
+ */
21
+ constructor(squid: Squid, integrationId: string);
22
+ /**
23
+ * Save an OAuth authorization code and exchange it for access/refresh tokens.
24
+ * Call this after the user completes the OAuth flow and receives the auth code.
25
+ * Squid will save the access/refresh tokens for future use when requesting Calendar data from Google
26
+
27
+ * This function requires Squid to be initialized with an API key
28
+ *
29
+ * @param authCode - OAuth2 authorization code from Google
30
+ * @param identifier - User-specific identifier (e.g., user ID)
31
+ * @returns Access token and expiration time
32
+ */
33
+ saveAuthCode(authCode: string, identifier: string): Promise<GetAccessTokenResponse>;
34
+ /**
35
+ * Retrieve calendar events within a specified time range.
36
+ * Returns structured event data including details like summary, description, start/end times, location, and attendees.
37
+ *
38
+ * @param request - Request parameters for retrieving calendar events
39
+ * @returns Array of calendar events with detailed information
40
+ */
41
+ getCalendarEvents(request: Omit<GetCalendarEventsRequest, 'integrationId'>): Promise<Array<CalendarEvent>>;
42
+ /**
43
+ * Upsert (create or update) a calendar event.
44
+ * If eventId is provided in the request, updates the existing event. Otherwise, creates a new event.
45
+ * Supports both timed events and all-day events.
46
+ *
47
+ * @param request - Event details and metadata
48
+ * @returns The ID of the created or updated event
49
+ */
50
+ upsertCalendarEvent(request: Omit<UpsertCalendarEventRequest, 'integrationId'>): Promise<string>;
51
+ }
@@ -0,0 +1,2 @@
1
+ export * from '../../common/src/google-calendar-types';
2
+ export * from './google-calendar-client';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={d:(t,n)=>{for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GOOGLE_CALENDAR_SCOPES:()=>n,SquidGoogleCalendarClient:()=>a});const n=["openid","email","https://www.googleapis.com/auth/calendar.events"];class a{static{this.SCOPES=n}constructor(e,t){this.squid=e,this.integrationId=t}async saveAuthCode(e,t){return await this.squid.externalAuth(this.integrationId).saveAuthCode(e,t)}async getCalendarEvents(e){const t={...e,integrationId:this.integrationId};return await this.squid.executeFunction("getCalendarEvents",t)}async upsertCalendarEvent(e){const t={...e,integrationId:this.integrationId};return await this.squid.executeFunction("upsertCalendarEvent",t)}}var r=exports;for(var i in t)r[i]=t[i];t.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();