@frogbotai/piece-google-calendar 0.29.0 → 0.31.0
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.
- package/dist/actions/customApiCall.d.ts +1 -1
- package/dist/actions/customApiCall.d.ts.map +1 -1
- package/dist/actions/customApiCall.js +90 -62
- package/dist/actions/customApiCall.js.map +1 -1
- package/dist/actions/events.d.ts +5 -5
- package/dist/actions/events.d.ts.map +1 -1
- package/dist/actions/events.js +115 -63
- package/dist/actions/events.js.map +1 -1
- package/dist/actions/options.d.ts.map +1 -1
- package/dist/actions/options.js +25 -20
- package/dist/actions/options.js.map +1 -1
- package/dist/actions/read.d.ts.map +1 -1
- package/dist/actions/read.js +71 -51
- package/dist/actions/read.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +10 -3
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +47 -43
- package/dist/config.js.map +1 -1
- package/dist/define.js +1 -0
- package/dist/define.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +14 -10
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/actions/events.js
CHANGED
|
@@ -1,51 +1,63 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { requestOptions } from '../client.js';
|
|
4
|
-
import { calendarId, dateTime, eventFields, eventOutput, eventReference, sendUpdates, validRange
|
|
4
|
+
import { calendarId, dateTime, eventFields, eventOutput, eventReference, sendUpdates, validRange } from '../config.js';
|
|
5
5
|
import { defineAction } from '../define.js';
|
|
6
6
|
import { calendars, colors } from './options.js';
|
|
7
7
|
function eventBody(input) {
|
|
8
8
|
const body = {};
|
|
9
|
-
if (input.title !== undefined)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (input.endDateTime !== undefined)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
if (input.title !== undefined) body.summary = input.title;
|
|
10
|
+
if (input.startDateTime !== undefined) body.start = {
|
|
11
|
+
dateTime: input.startDateTime
|
|
12
|
+
};
|
|
13
|
+
if (input.endDateTime !== undefined) body.end = {
|
|
14
|
+
dateTime: input.endDateTime
|
|
15
|
+
};
|
|
16
|
+
if (input.attendees !== undefined) body.attendees = input.attendees.map((email)=>({
|
|
17
|
+
email
|
|
18
|
+
}));
|
|
19
|
+
for (const field of [
|
|
20
|
+
'location',
|
|
21
|
+
'description',
|
|
22
|
+
'colorId'
|
|
23
|
+
]){
|
|
24
|
+
if (input[field] !== undefined) body[field] = input[field];
|
|
20
25
|
}
|
|
21
26
|
for (const field of [
|
|
22
27
|
'guestsCanModify',
|
|
23
28
|
'guestsCanInviteOthers',
|
|
24
|
-
'guestsCanSeeOtherGuests'
|
|
25
|
-
])
|
|
26
|
-
if (input[field] !== undefined)
|
|
27
|
-
body[field] = input[field];
|
|
29
|
+
'guestsCanSeeOtherGuests'
|
|
30
|
+
]){
|
|
31
|
+
if (input[field] !== undefined) body[field] = input[field];
|
|
28
32
|
}
|
|
29
33
|
if (input.createMeetLink) {
|
|
30
34
|
body.conferenceData = {
|
|
31
|
-
createRequest: {
|
|
35
|
+
createRequest: {
|
|
36
|
+
requestId: randomUUID(),
|
|
37
|
+
conferenceSolutionKey: {
|
|
38
|
+
type: 'hangoutsMeet'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
32
41
|
};
|
|
33
42
|
}
|
|
34
43
|
return body;
|
|
35
44
|
}
|
|
36
|
-
const createInput = eventFields
|
|
37
|
-
.extend({
|
|
45
|
+
const createInput = eventFields.extend({
|
|
38
46
|
calendarId,
|
|
39
47
|
title: z.string().min(1),
|
|
40
48
|
startDateTime: dateTime,
|
|
41
49
|
sendUpdates: sendUpdates.default('all'),
|
|
42
50
|
guestsCanModify: z.boolean().default(false),
|
|
43
51
|
guestsCanInviteOthers: z.boolean().default(false),
|
|
44
|
-
guestsCanSeeOtherGuests: z.boolean().default(false)
|
|
45
|
-
})
|
|
46
|
-
|
|
52
|
+
guestsCanSeeOtherGuests: z.boolean().default(false)
|
|
53
|
+
}).refine((input)=>validRange({
|
|
54
|
+
start: input.startDateTime,
|
|
55
|
+
end: input.endDateTime
|
|
56
|
+
}), {
|
|
47
57
|
message: 'End date must be after start date.',
|
|
48
|
-
path: [
|
|
58
|
+
path: [
|
|
59
|
+
'endDateTime'
|
|
60
|
+
]
|
|
49
61
|
});
|
|
50
62
|
export const createEvent = defineAction({
|
|
51
63
|
slug: 'createEvent',
|
|
@@ -53,25 +65,31 @@ export const createEvent = defineAction({
|
|
|
53
65
|
input: createInput,
|
|
54
66
|
output: eventOutput,
|
|
55
67
|
idempotent: false,
|
|
56
|
-
options: {
|
|
57
|
-
|
|
68
|
+
options: {
|
|
69
|
+
calendarId: calendars('writer'),
|
|
70
|
+
colorId: colors
|
|
71
|
+
},
|
|
72
|
+
async run ({ client, input, req }) {
|
|
58
73
|
const body = eventBody(input);
|
|
59
74
|
body.end ??= {
|
|
60
|
-
dateTime: new Date(Date.parse(input.startDateTime) + 30 * 60_000).toISOString()
|
|
75
|
+
dateTime: new Date(Date.parse(input.startDateTime) + 30 * 60_000).toISOString()
|
|
61
76
|
};
|
|
62
77
|
return (await client.events.insert({
|
|
63
78
|
calendarId: input.calendarId,
|
|
64
79
|
sendUpdates: input.sendUpdates,
|
|
65
80
|
conferenceDataVersion: input.createMeetLink ? 1 : 0,
|
|
66
|
-
requestBody: body
|
|
81
|
+
requestBody: body
|
|
67
82
|
}, requestOptions(req))).data;
|
|
68
|
-
}
|
|
83
|
+
}
|
|
69
84
|
});
|
|
70
|
-
const updateInput = eventReference
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
const updateInput = eventReference.extend(eventFields.shape).refine((input)=>validRange({
|
|
86
|
+
start: input.startDateTime,
|
|
87
|
+
end: input.endDateTime
|
|
88
|
+
}), {
|
|
73
89
|
message: 'End date must be after start date.',
|
|
74
|
-
path: [
|
|
90
|
+
path: [
|
|
91
|
+
'endDateTime'
|
|
92
|
+
]
|
|
75
93
|
});
|
|
76
94
|
export const updateEvent = defineAction({
|
|
77
95
|
slug: 'updateEvent',
|
|
@@ -79,18 +97,30 @@ export const updateEvent = defineAction({
|
|
|
79
97
|
input: updateInput,
|
|
80
98
|
output: eventOutput,
|
|
81
99
|
idempotent: false,
|
|
82
|
-
options: {
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
options: {
|
|
101
|
+
calendarId: calendars('writer'),
|
|
102
|
+
colorId: colors
|
|
103
|
+
},
|
|
104
|
+
async run ({ client, input, req }) {
|
|
105
|
+
const reference = {
|
|
106
|
+
calendarId: input.calendarId,
|
|
107
|
+
eventId: input.eventId
|
|
108
|
+
};
|
|
85
109
|
const { data: existing } = await client.events.get(reference, requestOptions(req));
|
|
86
110
|
const body = eventBody(input);
|
|
87
|
-
if (body.start)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
111
|
+
if (body.start) body.start = {
|
|
112
|
+
date: null,
|
|
113
|
+
timeZone: existing.start?.timeZone,
|
|
114
|
+
...body.start
|
|
115
|
+
};
|
|
116
|
+
if (body.end) body.end = {
|
|
117
|
+
date: null,
|
|
118
|
+
timeZone: existing.end?.timeZone,
|
|
119
|
+
...body.end
|
|
120
|
+
};
|
|
91
121
|
if (!validRange({
|
|
92
122
|
start: body.start?.dateTime ?? existing.start?.dateTime,
|
|
93
|
-
end: body.end?.dateTime ?? existing.end?.dateTime
|
|
123
|
+
end: body.end?.dateTime ?? existing.end?.dateTime
|
|
94
124
|
})) {
|
|
95
125
|
throw new Error('End date must be after start date.');
|
|
96
126
|
}
|
|
@@ -98,16 +128,18 @@ export const updateEvent = defineAction({
|
|
|
98
128
|
...reference,
|
|
99
129
|
sendUpdates: input.sendUpdates,
|
|
100
130
|
conferenceDataVersion: input.createMeetLink ? 1 : undefined,
|
|
101
|
-
requestBody: body
|
|
131
|
+
requestBody: body
|
|
102
132
|
}, {
|
|
103
133
|
...requestOptions(req),
|
|
104
|
-
headers: existing.etag ? {
|
|
134
|
+
headers: existing.etag ? {
|
|
135
|
+
'If-Match': existing.etag
|
|
136
|
+
} : undefined
|
|
105
137
|
})).data;
|
|
106
|
-
}
|
|
138
|
+
}
|
|
107
139
|
});
|
|
108
140
|
const attendeesInput = eventReference.extend({
|
|
109
141
|
attendees: z.array(z.email()).min(1),
|
|
110
|
-
sendUpdates: sendUpdates.optional()
|
|
142
|
+
sendUpdates: sendUpdates.optional()
|
|
111
143
|
});
|
|
112
144
|
export const addAttendees = defineAction({
|
|
113
145
|
slug: 'addAttendees',
|
|
@@ -115,29 +147,38 @@ export const addAttendees = defineAction({
|
|
|
115
147
|
input: attendeesInput,
|
|
116
148
|
output: eventOutput,
|
|
117
149
|
idempotent: false,
|
|
118
|
-
options: {
|
|
119
|
-
|
|
120
|
-
|
|
150
|
+
options: {
|
|
151
|
+
calendarId: calendars('writer')
|
|
152
|
+
},
|
|
153
|
+
async run ({ client, input, req }) {
|
|
154
|
+
const reference = {
|
|
155
|
+
calendarId: input.calendarId,
|
|
156
|
+
eventId: input.eventId
|
|
157
|
+
};
|
|
121
158
|
const { data: existing } = await client.events.get(reference, requestOptions(req));
|
|
122
159
|
return (await client.events.patch({
|
|
123
160
|
...reference,
|
|
124
161
|
sendUpdates: input.sendUpdates,
|
|
125
162
|
requestBody: {
|
|
126
163
|
attendees: [
|
|
127
|
-
...
|
|
128
|
-
...input.attendees.map((email)
|
|
129
|
-
|
|
130
|
-
|
|
164
|
+
...existing.attendees ?? [],
|
|
165
|
+
...input.attendees.map((email)=>({
|
|
166
|
+
email
|
|
167
|
+
}))
|
|
168
|
+
]
|
|
169
|
+
}
|
|
131
170
|
}, {
|
|
132
171
|
...requestOptions(req),
|
|
133
|
-
headers: existing.etag ? {
|
|
172
|
+
headers: existing.etag ? {
|
|
173
|
+
'If-Match': existing.etag
|
|
174
|
+
} : undefined
|
|
134
175
|
})).data;
|
|
135
|
-
}
|
|
176
|
+
}
|
|
136
177
|
});
|
|
137
178
|
const quickInput = z.object({
|
|
138
179
|
calendarId,
|
|
139
180
|
text: z.string().trim().min(1),
|
|
140
|
-
sendUpdates: sendUpdates.default('none')
|
|
181
|
+
sendUpdates: sendUpdates.default('none')
|
|
141
182
|
});
|
|
142
183
|
export const createQuickEvent = defineAction({
|
|
143
184
|
slug: 'createQuickEvent',
|
|
@@ -145,23 +186,34 @@ export const createQuickEvent = defineAction({
|
|
|
145
186
|
input: quickInput,
|
|
146
187
|
output: eventOutput,
|
|
147
188
|
idempotent: false,
|
|
148
|
-
options: {
|
|
149
|
-
|
|
189
|
+
options: {
|
|
190
|
+
calendarId: calendars('writer')
|
|
191
|
+
},
|
|
192
|
+
async run ({ client, input, req }) {
|
|
150
193
|
const { data } = await client.events.quickAdd(input, requestOptions(req));
|
|
151
194
|
return data;
|
|
152
|
-
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
const deleteInput = eventReference.extend({
|
|
198
|
+
sendUpdates: sendUpdates.optional()
|
|
153
199
|
});
|
|
154
|
-
const deleteInput = eventReference.extend({ sendUpdates: sendUpdates.optional() });
|
|
155
200
|
export const deleteEvent = defineAction({
|
|
156
201
|
slug: 'deleteEvent',
|
|
157
202
|
description: 'Delete an event, optionally notifying guests.',
|
|
158
203
|
input: deleteInput,
|
|
159
|
-
output: z.object({
|
|
204
|
+
output: z.object({
|
|
205
|
+
deleted: z.literal(true)
|
|
206
|
+
}),
|
|
160
207
|
idempotent: true,
|
|
161
|
-
options: {
|
|
162
|
-
|
|
163
|
-
await client.events.delete(input, requestOptions(req));
|
|
164
|
-
return { deleted: true };
|
|
208
|
+
options: {
|
|
209
|
+
calendarId: calendars('writer')
|
|
165
210
|
},
|
|
211
|
+
async run ({ client, input, req }) {
|
|
212
|
+
await client.events.delete(input, requestOptions(req));
|
|
213
|
+
return {
|
|
214
|
+
deleted: true
|
|
215
|
+
};
|
|
216
|
+
}
|
|
166
217
|
});
|
|
218
|
+
|
|
167
219
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/events.ts"],"names":["randomUUID","z","requestOptions","calendarId","dateTime","eventFields","eventOutput","eventReference","sendUpdates","validRange","defineAction","calendars","colors","eventBody","input","body","title","undefined","summary","startDateTime","start","endDateTime","end","attendees","map","email","field","createMeetLink","conferenceData","createRequest","requestId","conferenceSolutionKey","type","createInput","extend","string","min","default","guestsCanModify","boolean","guestsCanInviteOthers","guestsCanSeeOtherGuests","refine","message","path","createEvent","slug","description","output","idempotent","options","colorId","run","client","req","Date","parse","toISOString","events","insert","conferenceDataVersion","requestBody","data","updateInput","shape","updateEvent","reference","eventId","existing","get","date","timeZone","Error","patch","headers","etag","attendeesInput","array","optional","addAttendees","quickInput","object","text","trim","createQuickEvent","quickAdd","deleteInput","deleteEvent","deleted","literal","delete"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAGzC,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,QAAQ,eAAe;AAC9C,SACEC,UAAU,EACVC,QAAQ,EACRC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,WAAW,EACXC,UAAU,QACL,eAAe;AACtB,SAASC,YAAY,QAAQ,eAAe;AAC5C,SAASC,SAAS,EAAEC,MAAM,QAAQ,eAAe;AAEjD,SAASC,UAAUC,KAAmC;IACpD,MAAMC,OAAiC,CAAC;IACxC,IAAID,MAAME,KAAK,KAAKC,WAAWF,KAAKG,OAAO,GAAGJ,MAAME,KAAK;IACzD,IAAIF,MAAMK,aAAa,KAAKF,WAAWF,KAAKK,KAAK,GAAG;QAAEhB,UAAUU,MAAMK,aAAa;IAAC;IACpF,IAAIL,MAAMO,WAAW,KAAKJ,WAAWF,KAAKO,GAAG,GAAG;QAAElB,UAAUU,MAAMO,WAAW;IAAC;IAC9E,IAAIP,MAAMS,SAAS,KAAKN,WAAWF,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AAEwC,GAAG,EAAE;QAC9B,MAAMD,OAAOK,MAAM,CAACgC,MAAM,CAAC5E,OAAOZ,eAAeoD;QAEjD,OAAO;YAAEkC,SAAS;QAAc;IAClC;AACF,GAAG","file":"events.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/actions/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,cAAc,CAAC;AAEnE,KAAK,mBAAmB,GAAG;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,GAAG,EAAE,cAAc,CAAA;CAAE,CAAC;AAE3E,eAAO,MAAM,SAAS,mBACH,QAAQ,uBACD,mBAAmB;WACX,MAAM;WAAS,MAAM;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/actions/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,cAAc,CAAC;AAEnE,KAAK,mBAAmB,GAAG;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,GAAG,EAAE,cAAc,CAAA;CAAE,CAAC;AAE3E,eAAO,MAAM,SAAS,mBACH,QAAQ,uBACD,mBAAmB;WACX,MAAM;WAAS,MAAM;IAsBpD,CAAC;AAEJ,wBAAsB,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,mBAAmB;;;KAOhE"}
|
package/dist/actions/options.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import { requestOptions } from '../client.js';
|
|
2
|
-
export const calendars = (minAccessRole)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
export const calendars = (minAccessRole)=>async ({ client, req })=>{
|
|
3
|
+
const options = [];
|
|
4
|
+
let pageToken;
|
|
5
|
+
do {
|
|
6
|
+
const { data } = await client.calendarList.list({
|
|
7
|
+
maxResults: 250,
|
|
8
|
+
minAccessRole,
|
|
9
|
+
pageToken
|
|
10
|
+
}, requestOptions(req));
|
|
11
|
+
for (const calendar of data.items ?? []){
|
|
12
|
+
if (calendar.id) {
|
|
13
|
+
options.push({
|
|
14
|
+
label: calendar.summaryOverride ?? calendar.summary ?? calendar.id,
|
|
15
|
+
value: calendar.id
|
|
16
|
+
});
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
|
-
|
|
15
|
-
pageToken
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
+
pageToken = data.nextPageToken ?? undefined;
|
|
20
|
+
}while (pageToken)
|
|
21
|
+
return options;
|
|
22
|
+
};
|
|
19
23
|
export async function colors({ client, req }) {
|
|
20
24
|
const { data } = await client.colors.get({}, requestOptions(req));
|
|
21
|
-
return Object.entries(data.event ?? {}).map(([value, color])
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
return Object.entries(data.event ?? {}).map(([value, color])=>({
|
|
26
|
+
label: color.background ?? value,
|
|
27
|
+
value
|
|
28
|
+
}));
|
|
25
29
|
}
|
|
30
|
+
|
|
26
31
|
//# sourceMappingURL=options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/options.ts"],"names":["requestOptions","calendars","minAccessRole","client","req","options","pageToken","data","calendarList","list","maxResults","calendar","items","id","push","label","summaryOverride","summary","value","nextPageToken","undefined","colors","get","Object","entries","event","map","color","background"],"mappings":"AAEA,SAA8BA,cAAc,QAAQ,eAAe;AAInE,OAAO,MAAMC,YACX,CAACC,gBACD,OAAO,EAAEC,MAAM,EAAEC,GAAG,EAAuB;QACzC,MAAMC,UAAmD,EAAE;QAC3D,IAAIC;QA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BrB,CAAC;
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/actions/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAanB,CAAC;AAkCH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BrB,CAAC;AA0CH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsB9B,CAAC"}
|
package/dist/actions/read.js
CHANGED
|
@@ -5,7 +5,7 @@ import { defineAction } from '../define.js';
|
|
|
5
5
|
import { calendars } from './options.js';
|
|
6
6
|
const getInput = eventReference.extend({
|
|
7
7
|
maxAttendees: z.number().int().positive().optional(),
|
|
8
|
-
timeZone: z.string().trim().min(1).optional()
|
|
8
|
+
timeZone: z.string().trim().min(1).optional()
|
|
9
9
|
});
|
|
10
10
|
export const getEvent = defineAction({
|
|
11
11
|
slug: 'getEvent',
|
|
@@ -13,48 +13,62 @@ export const getEvent = defineAction({
|
|
|
13
13
|
input: getInput,
|
|
14
14
|
output: eventOutput,
|
|
15
15
|
idempotent: true,
|
|
16
|
-
options: {
|
|
17
|
-
|
|
16
|
+
options: {
|
|
17
|
+
calendarId: calendars()
|
|
18
|
+
},
|
|
19
|
+
async run ({ client, input, req }) {
|
|
18
20
|
const { data } = await client.events.get(input, requestOptions(req));
|
|
19
21
|
return data;
|
|
20
|
-
}
|
|
22
|
+
}
|
|
21
23
|
});
|
|
22
|
-
const listInput = z
|
|
23
|
-
.object({
|
|
24
|
+
const listInput = z.object({
|
|
24
25
|
calendarId,
|
|
25
|
-
eventTypes: z
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
eventTypes: z.array(z.enum([
|
|
27
|
+
'default',
|
|
28
|
+
'focusTime',
|
|
29
|
+
'outOfOffice',
|
|
30
|
+
'workingLocation',
|
|
31
|
+
'birthday',
|
|
32
|
+
'fromGmail'
|
|
33
|
+
])).default([
|
|
34
|
+
'default',
|
|
35
|
+
'focusTime',
|
|
36
|
+
'outOfOffice'
|
|
37
|
+
]),
|
|
28
38
|
search: z.string().optional(),
|
|
29
39
|
startDate: dateTime.optional(),
|
|
30
40
|
endDate: dateTime.optional(),
|
|
31
41
|
singleEvents: z.boolean().default(false),
|
|
32
42
|
maxResults: z.number().int().min(1).max(2500).optional(),
|
|
33
|
-
pageToken: z.string().min(1).optional()
|
|
34
|
-
})
|
|
35
|
-
|
|
43
|
+
pageToken: z.string().min(1).optional()
|
|
44
|
+
}).refine((input)=>validRange({
|
|
45
|
+
start: input.startDate,
|
|
46
|
+
end: input.endDate
|
|
47
|
+
}), {
|
|
36
48
|
message: 'End date must be after start date.',
|
|
37
|
-
path: [
|
|
49
|
+
path: [
|
|
50
|
+
'endDate'
|
|
51
|
+
]
|
|
38
52
|
});
|
|
39
|
-
const listOutput = z
|
|
40
|
-
.object({
|
|
53
|
+
const listOutput = z.object({
|
|
41
54
|
kind: z.string().nullish(),
|
|
42
55
|
etag: z.string().nullish(),
|
|
43
56
|
summary: z.string().nullish(),
|
|
44
57
|
timeZone: z.string().nullish(),
|
|
45
58
|
nextPageToken: z.string().nullish(),
|
|
46
59
|
nextSyncToken: z.string().nullish(),
|
|
47
|
-
items: z.array(eventOutput).optional()
|
|
48
|
-
})
|
|
49
|
-
.passthrough();
|
|
60
|
+
items: z.array(eventOutput).optional()
|
|
61
|
+
}).passthrough();
|
|
50
62
|
export const listEvents = defineAction({
|
|
51
63
|
slug: 'listEvents',
|
|
52
64
|
description: 'List a page of events, filtering by type, search, and dates, with optional recurring-event expansion.',
|
|
53
65
|
input: listInput,
|
|
54
66
|
output: listOutput,
|
|
55
67
|
idempotent: true,
|
|
56
|
-
options: {
|
|
57
|
-
|
|
68
|
+
options: {
|
|
69
|
+
calendarId: calendars()
|
|
70
|
+
},
|
|
71
|
+
async run ({ client, input, req }) {
|
|
58
72
|
return (await client.events.list({
|
|
59
73
|
calendarId: input.calendarId,
|
|
60
74
|
eventTypes: input.eventTypes.length ? input.eventTypes : undefined,
|
|
@@ -64,57 +78,63 @@ export const listEvents = defineAction({
|
|
|
64
78
|
singleEvents: input.singleEvents,
|
|
65
79
|
showDeleted: false,
|
|
66
80
|
maxResults: input.maxResults,
|
|
67
|
-
pageToken: input.pageToken
|
|
81
|
+
pageToken: input.pageToken
|
|
68
82
|
}, requestOptions(req))).data;
|
|
69
|
-
}
|
|
83
|
+
}
|
|
70
84
|
});
|
|
71
|
-
const freeBusyInput = z
|
|
72
|
-
.object({
|
|
85
|
+
const freeBusyInput = z.object({
|
|
73
86
|
calendarIds: z.array(calendarId).min(1).max(50),
|
|
74
87
|
startDate: dateTime,
|
|
75
|
-
endDate: dateTime
|
|
76
|
-
})
|
|
77
|
-
|
|
88
|
+
endDate: dateTime
|
|
89
|
+
}).refine((input)=>validRange({
|
|
90
|
+
start: input.startDate,
|
|
91
|
+
end: input.endDate
|
|
92
|
+
}), {
|
|
78
93
|
message: 'End date must be after start date.',
|
|
79
|
-
path: [
|
|
94
|
+
path: [
|
|
95
|
+
'endDate'
|
|
96
|
+
]
|
|
80
97
|
});
|
|
81
|
-
const freeBusyError = z.object({
|
|
82
|
-
|
|
83
|
-
.
|
|
98
|
+
const freeBusyError = z.object({
|
|
99
|
+
domain: z.string().nullish(),
|
|
100
|
+
reason: z.string().nullish()
|
|
101
|
+
});
|
|
102
|
+
const freeBusyOutput = z.object({
|
|
84
103
|
kind: z.string().nullish(),
|
|
85
104
|
timeMin: z.string().nullish(),
|
|
86
105
|
timeMax: z.string().nullish(),
|
|
87
|
-
calendars: z
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
errors: z.array(freeBusyError).optional()
|
|
93
|
-
}))
|
|
94
|
-
|
|
95
|
-
groups: z
|
|
96
|
-
.record(z.string(), z.object({
|
|
106
|
+
calendars: z.record(z.string(), z.object({
|
|
107
|
+
busy: z.array(z.object({
|
|
108
|
+
start: z.string().nullish(),
|
|
109
|
+
end: z.string().nullish()
|
|
110
|
+
})).optional(),
|
|
111
|
+
errors: z.array(freeBusyError).optional()
|
|
112
|
+
})).optional(),
|
|
113
|
+
groups: z.record(z.string(), z.object({
|
|
97
114
|
calendars: z.array(z.string()).optional(),
|
|
98
|
-
errors: z.array(freeBusyError).optional()
|
|
99
|
-
}))
|
|
100
|
-
|
|
101
|
-
})
|
|
102
|
-
.passthrough();
|
|
115
|
+
errors: z.array(freeBusyError).optional()
|
|
116
|
+
})).optional()
|
|
117
|
+
}).passthrough();
|
|
103
118
|
export const findFreeBusyPeriods = defineAction({
|
|
104
119
|
slug: 'findFreeBusyPeriods',
|
|
105
120
|
description: 'Find busy intervals and per-calendar errors within a time range. Gaps between busy intervals are free.',
|
|
106
121
|
input: freeBusyInput,
|
|
107
122
|
output: freeBusyOutput,
|
|
108
123
|
idempotent: true,
|
|
109
|
-
options: {
|
|
110
|
-
|
|
124
|
+
options: {
|
|
125
|
+
calendarIds: calendars()
|
|
126
|
+
},
|
|
127
|
+
async run ({ client, input, req }) {
|
|
111
128
|
return (await client.freebusy.query({
|
|
112
129
|
requestBody: {
|
|
113
130
|
timeMin: input.startDate,
|
|
114
131
|
timeMax: input.endDate,
|
|
115
|
-
items: input.calendarIds.map((id)
|
|
116
|
-
|
|
132
|
+
items: input.calendarIds.map((id)=>({
|
|
133
|
+
id
|
|
134
|
+
}))
|
|
135
|
+
}
|
|
117
136
|
}, requestOptions(req))).data;
|
|
118
|
-
}
|
|
137
|
+
}
|
|
119
138
|
});
|
|
139
|
+
|
|
120
140
|
//# sourceMappingURL=read.js.map
|