Skip to content

Commit 233045e

Browse files
authored
Merge pull request #49 from plotday/fix/rename-call
Several references to call() renamed to callCallback()
2 parents 1f07bfd + 2405588 commit 233045e

File tree

5 files changed

+54
-45
lines changed

5 files changed

+54
-45
lines changed

.changeset/witty-dots-bathe.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@plotday/tool-outlook-calendar": patch
3+
"@plotday/tool-google-calendar": patch
4+
"@plotday/tool-google-contacts": patch
5+
"@plotday/sdk": patch
6+
---
7+
8+
Fixed: Several references to call() renamed to callCallback()

sdk/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ await this.plot.createActivity({
161161
Activities are grouped within nested contexts called Priorities (e.g. Work, Project X).
162162

163163
**Type References:**
164+
164165
- [ActivityType enum](https://github.com/plotday/plot/blob/main/sdk/src/plot.ts#L35-L42) - Note, Task, Event
165166
- [ActivityLinkType enum](https://github.com/plotday/plot/blob/main/sdk/src/plot.ts#L65-L74) - external, auth, hidden, callback
166167
- [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) {
254255
```
255256

256257
**Type References:**
258+
257259
- [AuthProvider enum](https://github.com/plotday/plot/blob/main/sdk/src/tools/auth.ts#L78-L83) - Google, Microsoft
258260
- [AuthLevel enum](https://github.com/plotday/plot/blob/main/sdk/src/tools/auth.ts#L90-L95) - Priority, User
259261

@@ -300,12 +302,12 @@ Create persistent function references for webhooks and auth flows. Callback meth
300302

301303
```typescript
302304
// Create callback (no import needed - available directly)
303-
const token = await this.callback("handleEvent", {
305+
const callback = await this.callback("handleEvent", {
304306
eventType: "calendar_sync",
305307
});
306308

307309
// Execute callback
308-
const result = await this.call(token, {
310+
const result = await this.callCallback(callback, {
309311
data: eventData,
310312
});
311313

@@ -398,6 +400,7 @@ response.output.email; // string | undefined
398400
**Model Selection:**
399401

400402
Use `ModelPreferences` to specify your requirements based on speed and cost tiers:
403+
401404
- **Speed**: `"fast"`, `"balanced"`, or `"capable"`
402405
- **Cost**: `"low"`, `"medium"`, or `"high"`
403406

tools/google-calendar/src/google-calendar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ export class GoogleCalendar extends Tool implements CalendarTool {
377377
source: activityData.source || null,
378378
};
379379

380-
await this.call(callbackToken, activity);
380+
await this.callCallback(callbackToken, activity);
381381
}
382382
}
383383
} catch (error) {
@@ -423,7 +423,7 @@ export class GoogleCalendar extends Tool implements CalendarTool {
423423
source: activityData.source || null,
424424
};
425425

426-
await this.call(callbackToken, activity);
426+
await this.callCallback(callbackToken, activity);
427427
}
428428
}
429429

@@ -502,7 +502,7 @@ export class GoogleCalendar extends Tool implements CalendarTool {
502502
const authSuccessResult: CalendarAuth = {
503503
authToken: context.authToken,
504504
};
505-
await this.call(context.callbackToken, authSuccessResult);
505+
await this.callCallback(context.callbackToken, authSuccessResult);
506506

507507
// Clean up the callback token
508508
await this.clear(`auth_callback_token:${context.authToken}`);

tools/google-contacts/src/google-contacts.ts

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
type AuthToken,
77
} from "@plotday/sdk/tools/auth";
88
import { type Callback } from "@plotday/sdk/tools/callback";
9+
910
import type { Contact, ContactAuth, GoogleContacts } from "./types";
1011

1112
type ContactTokens = {
@@ -59,7 +60,7 @@ class GoogleApi {
5960
method: string,
6061
url: string,
6162
params?: { [key: string]: any },
62-
body?: { [key: string]: any },
63+
body?: { [key: string]: any }
6364
) {
6465
const query = params ? `?${new URLSearchParams(params)}` : "";
6566
const headers = {
@@ -95,15 +96,15 @@ function parseContact(contact: GoogleContact) {
9596
const name = contact.names?.[0]?.displayName;
9697
const avatar = contact.photos?.filter(
9798
(p: NonNullable<GoogleContact["photos"]>[number]) =>
98-
!p.default && p.metadata?.primary,
99+
!p.default && p.metadata?.primary
99100
)?.[0]?.url;
100101
return { name, avatar };
101102
}
102103

103104
async function getGoogleContacts(
104105
api: GoogleApi,
105106
scopes: string[],
106-
state: ContactSyncState,
107+
state: ContactSyncState
107108
): Promise<{
108109
contacts: Contact[];
109110
state: ContactSyncState;
@@ -115,8 +116,7 @@ async function getGoogleContacts(
115116
if (!state.more || tokens.connections?.nextPageToken) {
116117
if (
117118
scopes?.some?.(
118-
(scope) =>
119-
scope === "https://www.googleapis.com/auth/contacts.readonly",
119+
(scope) => scope === "https://www.googleapis.com/auth/contacts.readonly"
120120
)
121121
) {
122122
let response: ListResponse | undefined;
@@ -131,12 +131,12 @@ async function getGoogleContacts(
131131
pageToken: tokens.connections?.nextPageToken,
132132
}
133133
: tokens.connections?.nextSyncToken
134-
? {
135-
syncToken: tokens.connections?.nextSyncToken,
136-
}
137-
: {}),
134+
? {
135+
syncToken: tokens.connections?.nextSyncToken,
136+
}
137+
: {}),
138138
personFields: "names,emailAddresses,photos",
139-
},
139+
}
140140
)) as ListResponse;
141141
if (response !== null) break;
142142
if (!tokens.connections) break;
@@ -176,7 +176,7 @@ async function getGoogleContacts(
176176
if (
177177
scopes?.some?.(
178178
(scope) =>
179-
scope === "https://www.googleapis.com/auth/contacts.other.readonly",
179+
scope === "https://www.googleapis.com/auth/contacts.other.readonly"
180180
)
181181
) {
182182
let response: ListOtherResponse | undefined;
@@ -191,12 +191,12 @@ async function getGoogleContacts(
191191
pageToken: tokens.other?.nextPageToken,
192192
}
193193
: tokens.other?.nextSyncToken
194-
? {
195-
syncToken: tokens.other?.nextSyncToken,
196-
}
197-
: {}),
194+
? {
195+
syncToken: tokens.other?.nextSyncToken,
196+
}
197+
: {}),
198198
readMask: "names,emailAddresses,photos",
199-
},
199+
}
200200
)) as ListOtherResponse;
201201
if (response !== null) break;
202202
if (!tokens.other) break;
@@ -255,7 +255,7 @@ export default class extends Tool implements GoogleContacts {
255255

256256
async requestAuth(
257257
callbackFunctionName: string,
258-
callbackContext?: any,
258+
callbackContext?: any
259259
): Promise<any> {
260260
const contactsScopes = [
261261
"https://www.googleapis.com/auth/contacts.readonly",
@@ -268,7 +268,7 @@ export default class extends Tool implements GoogleContacts {
268268
// Register the callback for auth completion with opaque token
269269
const callbackToken = await this.callback(
270270
callbackFunctionName,
271-
callbackContext,
271+
callbackContext
272272
);
273273
await this.set(`auth_callback_token:${opaqueToken}`, callbackToken);
274274

@@ -285,17 +285,17 @@ export default class extends Tool implements GoogleContacts {
285285
level: AuthLevel.User,
286286
scopes: contactsScopes,
287287
},
288-
authCallback,
288+
authCallback
289289
);
290290
}
291291

292292
async getContacts(authToken: string): Promise<Contact[]> {
293293
const storedAuthToken = await this.get<AuthToken>(
294-
`auth_token:${authToken}`,
294+
`auth_token:${authToken}`
295295
);
296296
if (!storedAuthToken) {
297297
throw new Error(
298-
"No Google authentication token available for the provided authToken",
298+
"No Google authentication token available for the provided authToken"
299299
);
300300
}
301301

@@ -312,21 +312,21 @@ export default class extends Tool implements GoogleContacts {
312312
callbackFunctionName: string,
313313
options?: {
314314
context?: any;
315-
},
315+
}
316316
): Promise<void> {
317317
const storedAuthToken = await this.get<AuthToken>(
318-
`auth_token:${authToken}`,
318+
`auth_token:${authToken}`
319319
);
320320
if (!storedAuthToken) {
321321
throw new Error(
322-
"No Google authentication token available for the provided authToken",
322+
"No Google authentication token available for the provided authToken"
323323
);
324324
}
325325

326326
// Register the callback
327327
const callbackToken = await this.callback(
328328
callbackFunctionName,
329-
options?.context,
329+
options?.context
330330
);
331331
await this.set(`contacts_callback_token:${authToken}`, callbackToken);
332332

@@ -360,17 +360,15 @@ export default class extends Tool implements GoogleContacts {
360360

361361
try {
362362
const storedAuthToken = await this.get<AuthToken>(
363-
`auth_token:${authToken}`,
363+
`auth_token:${authToken}`
364364
);
365365
if (!storedAuthToken) {
366366
throw new Error(
367-
"No authentication token available for the provided authToken",
367+
"No authentication token available for the provided authToken"
368368
);
369369
}
370370

371-
const state = await this.get<ContactSyncState>(
372-
`sync_state:${authToken}`,
373-
);
371+
const state = await this.get<ContactSyncState>(`sync_state:${authToken}`);
374372
if (!state) {
375373
throw new Error("No sync state found");
376374
}
@@ -379,13 +377,13 @@ export default class extends Tool implements GoogleContacts {
379377
const result = await getGoogleContacts(
380378
api,
381379
storedAuthToken.scopes,
382-
state,
380+
state
383381
);
384382

385383
if (result.contacts.length > 0) {
386384
await this.processContacts(result.contacts, authToken);
387385
console.log(
388-
`Synced ${result.contacts.length} contacts in batch ${batchNumber}`,
386+
`Synced ${result.contacts.length} contacts in batch ${batchNumber}`
389387
);
390388
}
391389

@@ -399,7 +397,7 @@ export default class extends Tool implements GoogleContacts {
399397
await this.run(callback);
400398
} else {
401399
console.log(
402-
`Google Contacts sync completed after ${batchNumber} batches`,
400+
`Google Contacts sync completed after ${batchNumber} batches`
403401
);
404402
await this.clear(`sync_state:${authToken}`);
405403
}
@@ -412,13 +410,13 @@ export default class extends Tool implements GoogleContacts {
412410

413411
private async processContacts(
414412
contacts: Contact[],
415-
authToken: string,
413+
authToken: string
416414
): Promise<void> {
417415
const callbackToken = await this.get<Callback>(
418-
`contacts_callback_token:${authToken}`,
416+
`contacts_callback_token:${authToken}`
419417
);
420418
if (callbackToken) {
421-
await this.call(callbackToken, contacts);
419+
await this.callCallback(callbackToken, contacts);
422420
}
423421
}
424422

@@ -437,14 +435,14 @@ export default class extends Tool implements GoogleContacts {
437435

438436
// Retrieve and call the stored callback
439437
const callbackToken = await this.get<Callback>(
440-
`auth_callback_token:${opaqueToken}`,
438+
`auth_callback_token:${opaqueToken}`
441439
);
442440
if (callbackToken) {
443441
const authSuccessResult: ContactAuth = {
444442
authToken: opaqueToken,
445443
};
446444

447-
await this.call(callbackToken, authSuccessResult);
445+
await this.callCallback(callbackToken, authSuccessResult);
448446

449447
// Clean up the callback token
450448
await this.clear(`auth_callback_token:${opaqueToken}`);

tools/outlook-calendar/src/outlook-calendar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ export class OutlookCalendar extends Tool implements CalendarTool {
564564
// Call the event callback
565565
const callbackToken = await this.get<Callback>("event_callback_token");
566566
if (callbackToken) {
567-
await this.call(callbackToken, activity);
567+
await this.callCallback(callbackToken, activity);
568568
}
569569
}
570570

@@ -653,7 +653,7 @@ export class OutlookCalendar extends Tool implements CalendarTool {
653653
authToken: context.token,
654654
};
655655

656-
await this.call(callbackToken, authSuccessResult);
656+
await this.callCallback(callbackToken, authSuccessResult);
657657

658658
// Clean up the callback token
659659
await this.clear(`auth_callback_token:${context.token}`);

0 commit comments

Comments
 (0)