diff --git a/.changeset/witty-dots-bathe.md b/.changeset/witty-dots-bathe.md new file mode 100644 index 0000000..50de020 --- /dev/null +++ b/.changeset/witty-dots-bathe.md @@ -0,0 +1,8 @@ +--- +"@plotday/tool-outlook-calendar": patch +"@plotday/tool-google-calendar": patch +"@plotday/tool-google-contacts": patch +"@plotday/sdk": patch +--- + +Fixed: Several references to call() renamed to callCallback() diff --git a/sdk/README.md b/sdk/README.md index 5d1275a..c9c04c8 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -161,6 +161,7 @@ await this.plot.createActivity({ Activities are grouped within nested contexts called Priorities (e.g. Work, Project X). **Type References:** + - [ActivityType enum](https://github.com/plotday/plot/blob/main/sdk/src/plot.ts#L35-L42) - Note, Task, Event - [ActivityLinkType enum](https://github.com/plotday/plot/blob/main/sdk/src/plot.ts#L65-L74) - external, auth, hidden, callback - [Activity type](https://github.com/plotday/plot/blob/main/sdk/src/plot.ts#L216-L288) - Full activity structure @@ -254,6 +255,7 @@ async onAuthComplete(authorization: Authorization, context: any) { ``` **Type References:** + - [AuthProvider enum](https://github.com/plotday/plot/blob/main/sdk/src/tools/auth.ts#L78-L83) - Google, Microsoft - [AuthLevel enum](https://github.com/plotday/plot/blob/main/sdk/src/tools/auth.ts#L90-L95) - Priority, User @@ -300,12 +302,12 @@ Create persistent function references for webhooks and auth flows. Callback meth ```typescript // Create callback (no import needed - available directly) -const token = await this.callback("handleEvent", { +const callback = await this.callback("handleEvent", { eventType: "calendar_sync", }); // Execute callback -const result = await this.call(token, { +const result = await this.callCallback(callback, { data: eventData, }); @@ -398,6 +400,7 @@ response.output.email; // string | undefined **Model Selection:** Use `ModelPreferences` to specify your requirements based on speed and cost tiers: + - **Speed**: `"fast"`, `"balanced"`, or `"capable"` - **Cost**: `"low"`, `"medium"`, or `"high"` diff --git a/tools/google-calendar/src/google-calendar.ts b/tools/google-calendar/src/google-calendar.ts index a3d5875..b69d3cd 100644 --- a/tools/google-calendar/src/google-calendar.ts +++ b/tools/google-calendar/src/google-calendar.ts @@ -377,7 +377,7 @@ export class GoogleCalendar extends Tool implements CalendarTool { source: activityData.source || null, }; - await this.call(callbackToken, activity); + await this.callCallback(callbackToken, activity); } } } catch (error) { @@ -423,7 +423,7 @@ export class GoogleCalendar extends Tool implements CalendarTool { source: activityData.source || null, }; - await this.call(callbackToken, activity); + await this.callCallback(callbackToken, activity); } } @@ -502,7 +502,7 @@ export class GoogleCalendar extends Tool implements CalendarTool { const authSuccessResult: CalendarAuth = { authToken: context.authToken, }; - await this.call(context.callbackToken, authSuccessResult); + await this.callCallback(context.callbackToken, authSuccessResult); // Clean up the callback token await this.clear(`auth_callback_token:${context.authToken}`); diff --git a/tools/google-contacts/src/google-contacts.ts b/tools/google-contacts/src/google-contacts.ts index a3abefd..334dc39 100644 --- a/tools/google-contacts/src/google-contacts.ts +++ b/tools/google-contacts/src/google-contacts.ts @@ -6,6 +6,7 @@ import { type AuthToken, } from "@plotday/sdk/tools/auth"; import { type Callback } from "@plotday/sdk/tools/callback"; + import type { Contact, ContactAuth, GoogleContacts } from "./types"; type ContactTokens = { @@ -59,7 +60,7 @@ class GoogleApi { method: string, url: string, params?: { [key: string]: any }, - body?: { [key: string]: any }, + body?: { [key: string]: any } ) { const query = params ? `?${new URLSearchParams(params)}` : ""; const headers = { @@ -95,7 +96,7 @@ function parseContact(contact: GoogleContact) { const name = contact.names?.[0]?.displayName; const avatar = contact.photos?.filter( (p: NonNullable[number]) => - !p.default && p.metadata?.primary, + !p.default && p.metadata?.primary )?.[0]?.url; return { name, avatar }; } @@ -103,7 +104,7 @@ function parseContact(contact: GoogleContact) { async function getGoogleContacts( api: GoogleApi, scopes: string[], - state: ContactSyncState, + state: ContactSyncState ): Promise<{ contacts: Contact[]; state: ContactSyncState; @@ -115,8 +116,7 @@ async function getGoogleContacts( if (!state.more || tokens.connections?.nextPageToken) { if ( scopes?.some?.( - (scope) => - scope === "https://www.googleapis.com/auth/contacts.readonly", + (scope) => scope === "https://www.googleapis.com/auth/contacts.readonly" ) ) { let response: ListResponse | undefined; @@ -131,12 +131,12 @@ async function getGoogleContacts( pageToken: tokens.connections?.nextPageToken, } : tokens.connections?.nextSyncToken - ? { - syncToken: tokens.connections?.nextSyncToken, - } - : {}), + ? { + syncToken: tokens.connections?.nextSyncToken, + } + : {}), personFields: "names,emailAddresses,photos", - }, + } )) as ListResponse; if (response !== null) break; if (!tokens.connections) break; @@ -176,7 +176,7 @@ async function getGoogleContacts( if ( scopes?.some?.( (scope) => - scope === "https://www.googleapis.com/auth/contacts.other.readonly", + scope === "https://www.googleapis.com/auth/contacts.other.readonly" ) ) { let response: ListOtherResponse | undefined; @@ -191,12 +191,12 @@ async function getGoogleContacts( pageToken: tokens.other?.nextPageToken, } : tokens.other?.nextSyncToken - ? { - syncToken: tokens.other?.nextSyncToken, - } - : {}), + ? { + syncToken: tokens.other?.nextSyncToken, + } + : {}), readMask: "names,emailAddresses,photos", - }, + } )) as ListOtherResponse; if (response !== null) break; if (!tokens.other) break; @@ -255,7 +255,7 @@ export default class extends Tool implements GoogleContacts { async requestAuth( callbackFunctionName: string, - callbackContext?: any, + callbackContext?: any ): Promise { const contactsScopes = [ "https://www.googleapis.com/auth/contacts.readonly", @@ -268,7 +268,7 @@ export default class extends Tool implements GoogleContacts { // Register the callback for auth completion with opaque token const callbackToken = await this.callback( callbackFunctionName, - callbackContext, + callbackContext ); await this.set(`auth_callback_token:${opaqueToken}`, callbackToken); @@ -285,17 +285,17 @@ export default class extends Tool implements GoogleContacts { level: AuthLevel.User, scopes: contactsScopes, }, - authCallback, + authCallback ); } async getContacts(authToken: string): Promise { const storedAuthToken = await this.get( - `auth_token:${authToken}`, + `auth_token:${authToken}` ); if (!storedAuthToken) { throw new Error( - "No Google authentication token available for the provided authToken", + "No Google authentication token available for the provided authToken" ); } @@ -312,21 +312,21 @@ export default class extends Tool implements GoogleContacts { callbackFunctionName: string, options?: { context?: any; - }, + } ): Promise { const storedAuthToken = await this.get( - `auth_token:${authToken}`, + `auth_token:${authToken}` ); if (!storedAuthToken) { throw new Error( - "No Google authentication token available for the provided authToken", + "No Google authentication token available for the provided authToken" ); } // Register the callback const callbackToken = await this.callback( callbackFunctionName, - options?.context, + options?.context ); await this.set(`contacts_callback_token:${authToken}`, callbackToken); @@ -360,17 +360,15 @@ export default class extends Tool implements GoogleContacts { try { const storedAuthToken = await this.get( - `auth_token:${authToken}`, + `auth_token:${authToken}` ); if (!storedAuthToken) { throw new Error( - "No authentication token available for the provided authToken", + "No authentication token available for the provided authToken" ); } - const state = await this.get( - `sync_state:${authToken}`, - ); + const state = await this.get(`sync_state:${authToken}`); if (!state) { throw new Error("No sync state found"); } @@ -379,13 +377,13 @@ export default class extends Tool implements GoogleContacts { const result = await getGoogleContacts( api, storedAuthToken.scopes, - state, + state ); if (result.contacts.length > 0) { await this.processContacts(result.contacts, authToken); console.log( - `Synced ${result.contacts.length} contacts in batch ${batchNumber}`, + `Synced ${result.contacts.length} contacts in batch ${batchNumber}` ); } @@ -399,7 +397,7 @@ export default class extends Tool implements GoogleContacts { await this.run(callback); } else { console.log( - `Google Contacts sync completed after ${batchNumber} batches`, + `Google Contacts sync completed after ${batchNumber} batches` ); await this.clear(`sync_state:${authToken}`); } @@ -412,13 +410,13 @@ export default class extends Tool implements GoogleContacts { private async processContacts( contacts: Contact[], - authToken: string, + authToken: string ): Promise { const callbackToken = await this.get( - `contacts_callback_token:${authToken}`, + `contacts_callback_token:${authToken}` ); if (callbackToken) { - await this.call(callbackToken, contacts); + await this.callCallback(callbackToken, contacts); } } @@ -437,14 +435,14 @@ export default class extends Tool implements GoogleContacts { // Retrieve and call the stored callback const callbackToken = await this.get( - `auth_callback_token:${opaqueToken}`, + `auth_callback_token:${opaqueToken}` ); if (callbackToken) { const authSuccessResult: ContactAuth = { authToken: opaqueToken, }; - await this.call(callbackToken, authSuccessResult); + await this.callCallback(callbackToken, authSuccessResult); // Clean up the callback token await this.clear(`auth_callback_token:${opaqueToken}`); diff --git a/tools/outlook-calendar/src/outlook-calendar.ts b/tools/outlook-calendar/src/outlook-calendar.ts index a787e80..ade00ad 100644 --- a/tools/outlook-calendar/src/outlook-calendar.ts +++ b/tools/outlook-calendar/src/outlook-calendar.ts @@ -564,7 +564,7 @@ export class OutlookCalendar extends Tool implements CalendarTool { // Call the event callback const callbackToken = await this.get("event_callback_token"); if (callbackToken) { - await this.call(callbackToken, activity); + await this.callCallback(callbackToken, activity); } } @@ -653,7 +653,7 @@ export class OutlookCalendar extends Tool implements CalendarTool { authToken: context.token, }; - await this.call(callbackToken, authSuccessResult); + await this.callCallback(callbackToken, authSuccessResult); // Clean up the callback token await this.clear(`auth_callback_token:${context.token}`);