pangea-server 3.3.155 → 3.3.156
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type GetEventsOptions = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
maxResults?: number;
|
|
3
|
+
timeMin?: Date;
|
|
4
|
+
timeMax?: Date;
|
|
5
5
|
query?: string;
|
|
6
6
|
};
|
|
7
7
|
type CreateEventOptions = {
|
|
@@ -13,24 +13,17 @@ type CreateEventOptions = {
|
|
|
13
13
|
attendees?: string[];
|
|
14
14
|
meet?: boolean;
|
|
15
15
|
};
|
|
16
|
-
type UpdateEventOptions =
|
|
17
|
-
title?: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
location?: string;
|
|
20
|
-
start?: Date;
|
|
21
|
-
end?: Date;
|
|
22
|
-
attendees?: string[];
|
|
23
|
-
};
|
|
16
|
+
type UpdateEventOptions = Partial<Omit<CreateEventOptions, 'meet'>>;
|
|
24
17
|
export declare class GoogleCalendar {
|
|
25
18
|
private __calendar;
|
|
26
|
-
constructor({
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
constructor({ accessToken, refreshToken }: {
|
|
20
|
+
accessToken: string;
|
|
21
|
+
refreshToken: string;
|
|
29
22
|
});
|
|
30
|
-
static GetAuthUrl(redirectTo: string):
|
|
23
|
+
static GetAuthUrl(redirectTo: string): string;
|
|
31
24
|
static GetTokens(code: string, redirectTo: string): Promise<{
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
accessToken: string;
|
|
26
|
+
refreshToken: string;
|
|
34
27
|
}>;
|
|
35
28
|
getEvent(eventId: string): Promise<{
|
|
36
29
|
id: string;
|
|
@@ -6,20 +6,20 @@ const googleapis_1 = require("googleapis");
|
|
|
6
6
|
const helpers_1 = require("../helpers");
|
|
7
7
|
const scopes = ['https://www.googleapis.com/auth/calendar.events'];
|
|
8
8
|
class GoogleCalendar {
|
|
9
|
-
constructor({
|
|
9
|
+
constructor({ accessToken, refreshToken }) {
|
|
10
10
|
const auth = getOAuth2();
|
|
11
|
-
auth.setCredentials({ access_token:
|
|
11
|
+
auth.setCredentials({ access_token: accessToken, refresh_token: refreshToken });
|
|
12
12
|
this.__calendar = googleapis_1.google.calendar({ version: 'v3', auth });
|
|
13
13
|
}
|
|
14
14
|
// class methods
|
|
15
|
-
static
|
|
15
|
+
static GetAuthUrl(redirectTo) {
|
|
16
16
|
const auth = getOAuth2();
|
|
17
17
|
return auth.generateAuthUrl({ access_type: 'offline', prompt: 'consent', scope: scopes, redirect_uri: redirectTo });
|
|
18
18
|
}
|
|
19
19
|
static async GetTokens(code, redirectTo) {
|
|
20
20
|
const auth = getOAuth2();
|
|
21
21
|
const { tokens } = await auth.getToken({ code, redirect_uri: redirectTo });
|
|
22
|
-
return {
|
|
22
|
+
return { accessToken: tokens.access_token, refreshToken: tokens.refresh_token };
|
|
23
23
|
}
|
|
24
24
|
// methods
|
|
25
25
|
async getEvent(eventId) {
|
|
@@ -29,9 +29,9 @@ class GoogleCalendar {
|
|
|
29
29
|
async getEvents(options = {}) {
|
|
30
30
|
const response = await this.__calendar.events.list({
|
|
31
31
|
calendarId: 'primary',
|
|
32
|
-
maxResults: options.
|
|
33
|
-
timeMin: options.
|
|
34
|
-
timeMax: options.
|
|
32
|
+
maxResults: options.maxResults || 10,
|
|
33
|
+
timeMin: options.timeMin?.toISOString(),
|
|
34
|
+
timeMax: options.timeMax?.toISOString(),
|
|
35
35
|
q: options.query,
|
|
36
36
|
singleEvents: true,
|
|
37
37
|
orderBy: 'startTime',
|