@frogbotai/piece-google-calendar 0.28.0 → 0.30.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.js +90 -62
- package/dist/actions/customApiCall.js.map +1 -1
- package/dist/actions/events.d.ts +5 -5
- package/dist/actions/events.js +115 -63
- package/dist/actions/events.js.map +1 -1
- package/dist/actions/options.js +25 -20
- package/dist/actions/options.js.map +1 -1
- package/dist/actions/read.js +71 -51
- package/dist/actions/read.js.map +1 -1
- package/dist/client.js +10 -3
- package/dist/client.js.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
|
@@ -13,9 +13,9 @@ export declare const customApiCall: import("frogbot").PieceActionDefinition<z.Zo
|
|
|
13
13
|
headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
14
14
|
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
|
|
15
15
|
bodyType: z.ZodDefault<z.ZodEnum<{
|
|
16
|
-
none: "none";
|
|
17
16
|
formData: "formData";
|
|
18
17
|
json: "json";
|
|
18
|
+
none: "none";
|
|
19
19
|
raw: "raw";
|
|
20
20
|
}>>;
|
|
21
21
|
body: z.ZodOptional<z.ZodJSONSchema>;
|
|
@@ -2,100 +2,127 @@ import { z } from 'zod';
|
|
|
2
2
|
import { requestOptions } from '../client.js';
|
|
3
3
|
import { defineAction } from '../define.js';
|
|
4
4
|
const baseUrl = 'https://www.googleapis.com/calendar/v3';
|
|
5
|
-
const scalar = z.union([
|
|
5
|
+
const scalar = z.union([
|
|
6
|
+
z.string(),
|
|
7
|
+
z.number(),
|
|
8
|
+
z.boolean()
|
|
9
|
+
]);
|
|
6
10
|
const formField = z.discriminatedUnion('type', [
|
|
7
|
-
z.object({
|
|
11
|
+
z.object({
|
|
12
|
+
name: z.string().min(1),
|
|
13
|
+
type: z.literal('text'),
|
|
14
|
+
value: z.string()
|
|
15
|
+
}),
|
|
8
16
|
z.object({
|
|
9
17
|
name: z.string().min(1),
|
|
10
18
|
type: z.literal('file'),
|
|
11
19
|
filename: z.string().min(1),
|
|
12
20
|
contentType: z.string().min(1).default('application/octet-stream'),
|
|
13
|
-
base64: z.base64()
|
|
14
|
-
})
|
|
21
|
+
base64: z.base64()
|
|
22
|
+
})
|
|
15
23
|
]);
|
|
16
24
|
function providerUrl(path) {
|
|
17
25
|
if (/[\s\\\p{Cc}]/u.test(path) || path.startsWith('//')) {
|
|
18
26
|
throw new Error('URL must target the Google Calendar v3 API.');
|
|
19
27
|
}
|
|
20
28
|
const url = new URL(path.startsWith('/') ? `${baseUrl}${path}` : path);
|
|
21
|
-
if (url.origin !== 'https://www.googleapis.com' ||
|
|
22
|
-
url.username ||
|
|
23
|
-
url.password ||
|
|
24
|
-
url.hash ||
|
|
25
|
-
(url.pathname !== '/calendar/v3' && !url.pathname.startsWith('/calendar/v3/'))) {
|
|
29
|
+
if (url.origin !== 'https://www.googleapis.com' || url.username || url.password || url.hash || url.pathname !== '/calendar/v3' && !url.pathname.startsWith('/calendar/v3/')) {
|
|
26
30
|
throw new Error('URL must target the Google Calendar v3 API.');
|
|
27
31
|
}
|
|
28
32
|
let decoded = url.pathname;
|
|
29
|
-
for
|
|
33
|
+
for(let index = 0; index < 3; index++){
|
|
30
34
|
decoded = decodeURIComponent(decoded);
|
|
31
|
-
if (decoded.split('/').some((part)
|
|
32
|
-
/[\\\p{Cc}]/u.test(decoded)) {
|
|
35
|
+
if (decoded.split('/').some((part)=>part === '.' || part === '..') || /[\\\p{Cc}]/u.test(decoded)) {
|
|
33
36
|
throw new Error('URL must target the Google Calendar v3 API.');
|
|
34
37
|
}
|
|
35
|
-
if (!/%[\da-f]{2}/i.test(decoded))
|
|
36
|
-
break;
|
|
38
|
+
if (!/%[\da-f]{2}/i.test(decoded)) break;
|
|
37
39
|
}
|
|
38
40
|
return url.toString();
|
|
39
41
|
}
|
|
40
|
-
const inputSchema = z
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const inputSchema = z.object({
|
|
43
|
+
method: z.enum([
|
|
44
|
+
'GET',
|
|
45
|
+
'POST',
|
|
46
|
+
'PATCH',
|
|
47
|
+
'PUT',
|
|
48
|
+
'DELETE',
|
|
49
|
+
'HEAD',
|
|
50
|
+
'OPTIONS'
|
|
51
|
+
]),
|
|
52
|
+
path: z.string().min(1).refine((path)=>{
|
|
47
53
|
try {
|
|
48
54
|
providerUrl(path);
|
|
49
55
|
return true;
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
56
|
+
} catch {
|
|
52
57
|
return false;
|
|
53
58
|
}
|
|
54
59
|
}, 'URL must target the Google Calendar v3 API.'),
|
|
55
|
-
headers: z
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
bodyType: z.enum([
|
|
60
|
+
headers: z.record(z.string(), z.string()).default({}).refine((headers)=>Object.keys(headers).every((name)=>![
|
|
61
|
+
'authorization',
|
|
62
|
+
'proxy-authorization',
|
|
63
|
+
'host',
|
|
64
|
+
'cookie',
|
|
65
|
+
'content-length',
|
|
66
|
+
'transfer-encoding'
|
|
67
|
+
].includes(name.toLowerCase())), 'Authentication and transport headers cannot be overridden.'),
|
|
68
|
+
query: z.record(z.string(), z.union([
|
|
69
|
+
scalar,
|
|
70
|
+
z.array(scalar)
|
|
71
|
+
])).optional(),
|
|
72
|
+
bodyType: z.enum([
|
|
73
|
+
'none',
|
|
74
|
+
'json',
|
|
75
|
+
'raw',
|
|
76
|
+
'formData'
|
|
77
|
+
]).default('json'),
|
|
68
78
|
body: z.json().optional(),
|
|
69
79
|
formData: z.array(formField).optional(),
|
|
70
80
|
responseIsBinary: z.boolean().default(false),
|
|
71
81
|
failsafe: z.boolean().default(false),
|
|
72
82
|
timeout: z.number().positive().optional().describe('Request timeout in seconds.'),
|
|
73
|
-
followRedirects: z.literal(false).default(false)
|
|
74
|
-
})
|
|
75
|
-
.superRefine((input, context) => {
|
|
83
|
+
followRedirects: z.literal(false).default(false)
|
|
84
|
+
}).superRefine((input, context)=>{
|
|
76
85
|
if (input.bodyType === 'raw' && typeof input.body !== 'string') {
|
|
77
|
-
context.addIssue({
|
|
86
|
+
context.addIssue({
|
|
87
|
+
code: 'custom',
|
|
88
|
+
path: [
|
|
89
|
+
'body'
|
|
90
|
+
],
|
|
91
|
+
message: 'Raw body must be a string.'
|
|
92
|
+
});
|
|
78
93
|
}
|
|
79
94
|
if (input.bodyType === 'formData' && !input.formData) {
|
|
80
95
|
context.addIssue({
|
|
81
96
|
code: 'custom',
|
|
82
|
-
path: [
|
|
83
|
-
|
|
97
|
+
path: [
|
|
98
|
+
'formData'
|
|
99
|
+
],
|
|
100
|
+
message: 'Form data fields are required.'
|
|
84
101
|
});
|
|
85
102
|
}
|
|
86
|
-
if ([
|
|
87
|
-
|
|
103
|
+
if ([
|
|
104
|
+
'GET',
|
|
105
|
+
'HEAD'
|
|
106
|
+
].includes(input.method) && (input.body !== undefined || input.formData !== undefined)) {
|
|
88
107
|
context.addIssue({
|
|
89
108
|
code: 'custom',
|
|
90
|
-
path: [
|
|
91
|
-
|
|
109
|
+
path: [
|
|
110
|
+
'body'
|
|
111
|
+
],
|
|
112
|
+
message: 'GET and HEAD requests cannot have a body.'
|
|
92
113
|
});
|
|
93
114
|
}
|
|
94
115
|
});
|
|
95
116
|
const output = z.object({
|
|
96
117
|
status: z.number().int(),
|
|
97
118
|
headers: z.record(z.string(), z.string()),
|
|
98
|
-
body: z.union([
|
|
119
|
+
body: z.union([
|
|
120
|
+
z.json(),
|
|
121
|
+
z.object({
|
|
122
|
+
base64: z.string(),
|
|
123
|
+
contentType: z.string()
|
|
124
|
+
})
|
|
125
|
+
])
|
|
99
126
|
});
|
|
100
127
|
export const customApiCall = defineAction({
|
|
101
128
|
slug: 'customApiCall',
|
|
@@ -103,7 +130,7 @@ export const customApiCall = defineAction({
|
|
|
103
130
|
input: inputSchema,
|
|
104
131
|
output,
|
|
105
132
|
idempotent: false,
|
|
106
|
-
async run({ client, input, req }) {
|
|
133
|
+
async run ({ client, input, req }) {
|
|
107
134
|
const transport = client.context._options.auth;
|
|
108
135
|
if (!transport || typeof transport === 'string' || !('request' in transport)) {
|
|
109
136
|
throw new Error('Google Calendar client is missing authenticated transport.');
|
|
@@ -112,19 +139,21 @@ export const customApiCall = defineAction({
|
|
|
112
139
|
let data = input.bodyType === 'none' ? undefined : input.body;
|
|
113
140
|
if (input.bodyType === 'json' && data !== undefined) {
|
|
114
141
|
data = JSON.stringify(data);
|
|
115
|
-
if (!headers.has('content-type'))
|
|
116
|
-
headers.set('content-type', 'application/json');
|
|
142
|
+
if (!headers.has('content-type')) headers.set('content-type', 'application/json');
|
|
117
143
|
}
|
|
118
144
|
if (input.bodyType === 'raw' && !headers.has('content-type')) {
|
|
119
145
|
headers.set('content-type', 'text/plain');
|
|
120
146
|
}
|
|
121
147
|
if (input.bodyType === 'formData') {
|
|
122
148
|
const form = new FormData();
|
|
123
|
-
for (const field of input.formData ?? [])
|
|
124
|
-
if (field.type === 'text')
|
|
125
|
-
form.append(field.name, field.value);
|
|
149
|
+
for (const field of input.formData ?? []){
|
|
150
|
+
if (field.type === 'text') form.append(field.name, field.value);
|
|
126
151
|
else {
|
|
127
|
-
form.append(field.name, new Blob([
|
|
152
|
+
form.append(field.name, new Blob([
|
|
153
|
+
Buffer.from(field.base64, 'base64')
|
|
154
|
+
], {
|
|
155
|
+
type: field.contentType
|
|
156
|
+
}), field.filename);
|
|
128
157
|
}
|
|
129
158
|
}
|
|
130
159
|
headers.delete('content-type');
|
|
@@ -141,7 +170,7 @@ export const customApiCall = defineAction({
|
|
|
141
170
|
responseType: input.responseIsBinary ? 'arraybuffer' : 'json',
|
|
142
171
|
redirect: 'manual',
|
|
143
172
|
maxRedirects: 0,
|
|
144
|
-
validateStatus: (status)
|
|
173
|
+
validateStatus: (status)=>status >= 200 && status < 300 || input.failsafe
|
|
145
174
|
});
|
|
146
175
|
if (response.status >= 300 && response.status < 400) {
|
|
147
176
|
throw new Error('Google Calendar API redirects are not allowed.');
|
|
@@ -149,13 +178,12 @@ export const customApiCall = defineAction({
|
|
|
149
178
|
return {
|
|
150
179
|
status: response.status,
|
|
151
180
|
headers: Object.fromEntries(response.headers.entries()),
|
|
152
|
-
body: input.responseIsBinary
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
: (response.data ?? null),
|
|
181
|
+
body: input.responseIsBinary ? {
|
|
182
|
+
base64: Buffer.from(response.data).toString('base64'),
|
|
183
|
+
contentType: response.headers.get('content-type') ?? 'application/octet-stream'
|
|
184
|
+
} : response.data ?? null
|
|
158
185
|
};
|
|
159
|
-
}
|
|
186
|
+
}
|
|
160
187
|
});
|
|
188
|
+
|
|
161
189
|
//# sourceMappingURL=customApiCall.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/customApiCall.ts"],"names":["z","requestOptions","defineAction","baseUrl","scalar","union","string","number","boolean","formField","discriminatedUnion","object","name","min","type","literal","value","filename","contentType","default","base64","providerUrl","path","test","startsWith","Error","url","URL","origin","username","password","hash","pathname","decoded","index","decodeURIComponent","split","some","part","toString","inputSchema","method","enum","refine","headers","record","Object","keys","every","includes","toLowerCase","query","array","optional","bodyType","body","json","formData","responseIsBinary","failsafe","timeout","positive","describe","followRedirects","superRefine","input","context","addIssue","code","message","undefined","output","status","int","customApiCall","slug","description","idempotent","run","client","req","transport","_options","auth","Headers","data","JSON","stringify","has","set","form","FormData","field","append","Blob","Buffer","from","delete","response","request","params","responseType","redirect","maxRedirects","validateStatus","fromEntries","entries","get"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,YAAY,QAAQ,eAAe;AAE5C,MAAMC,UAAU;AAChB,MAAMC,SAASJ,EAAEK,KAAK,CAAC;IAACL,EAAEM,MAAM;IAAIN,EAAEO,MAAM;IAAIP,EAAEQ,OAAO;CAAG;AAC5D,MAAMC,YAAYT,EAAEU,kBAAkB,CAAC,QAAQ;IAC7CV,EAAEW,MAAM,CAAC;QAAEC,MAAMZ,EAAEM,MAAM,GAAGO,GAAG,CAAC;QAAIC,MAAMd,EAAEe,OAAO,CAAC;QAASC,OAAOhB,EAAEM,MAAM;IAAG;IAC/EN,EAAEW,MAAM,CAAC;QACPC,MAAMZ,EAAEM,MAAM,GAAGO,GAAG,CAAC;QACrBC,MAAMd,EAAEe,OAAO,CAAC;QAChBE,UAAUjB,EAAEM,MAAM,GAAGO,GAAG,CAAC;QACzBK,aAAalB,EAAEM,MAAM,GAAGO,GAAG,CAAC,GAAGM,OAAO,CAAC;QACvCC,QAAQpB,EAAEoB,MAAM;IAClB;CACD;AAED,SAASC,YAAYC,IAAY;IAC/B,IAAI,gBAAgBC,IAAI,CAACD,SAASA,KAAKE,UAAU,CAAC,OAAO;QACvD,MAAM,IAAIC,MAAM;IAClB;IACA,MAAMC,MAAM,IAAIC,IAAIL,KAAKE,UAAU,CAAC,OAAO,GAAGrB,UAAUmB,MAAM,GAAGA;IACjE,IACEI,IAAIE,MAAM,KAAK,gCACfF,IAAIG,QAAQ,IACZH,IAAII,QAAQ,IACZJ,IAAIK,IAAI,IACPL,IAAIM,QAAQ,KAAK,kBAAkB,CAACN,IAAIM,QAAQ,CAACR,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,OAAO,CAAC;YACvC,GAAGlG,eAAe+E,IAAI;YACtBtD,KAAKL,YAAY4C,MAAM3C,IAAI;YAC3BmB,QAAQwB,MAAMxB,MAAM;YACpBG;YACAwD,QAAQnC,MAAMd,KAAK;YACnBkC;YACAzB,SAASK,MAAML,OAAO,KAAKU,YAAYA,YAAYL,MAAML,OAAO,GAAG;YACnEyC,cAAcpC,MAAMP,gBAAgB,GAAG,gBAAgB;YACvD4C,UAAU;YACVC,cAAc;YACdC,gBAAgB,CAAChC,SAAW,AAACA,UAAU,OAAOA,SAAS,OAAQP,MAAMN,QAAQ;QAC/E;QACA,IAAIuC,SAAS1B,MAAM,IAAI,OAAO0B,SAAS1B,MAAM,GAAG,KAAK;YACnD,MAAM,IAAI/C,MAAM;QAClB;QACA,OAAO;YACL+C,QAAQ0B,SAAS1B,MAAM;YACvB5B,SAASE,OAAO2D,WAAW,CAACP,SAAStD,OAAO,CAAC8D,OAAO;YACpDnD,MAAMU,MAAMP,gBAAgB,GACxB;gBACEtC,QAAQ2E,OAAOC,IAAI,CAACE,SAASb,IAAI,EAAiB9C,QAAQ,CAAC;gBAC3DrB,aAAagF,SAAStD,OAAO,CAAC+D,GAAG,CAAC,mBAAmB;YACvD,IACET,SAASb,IAAI,IAAI;QACzB;IACF;AACF,GAAG","file":"customApiCall.js"}
|
package/dist/actions/events.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ export declare const createEvent: import("frogbot").PieceActionDefinition<z.ZodO
|
|
|
11
11
|
title: z.ZodString;
|
|
12
12
|
startDateTime: z.ZodISODateTime;
|
|
13
13
|
sendUpdates: z.ZodDefault<z.ZodEnum<{
|
|
14
|
+
none: "none";
|
|
14
15
|
all: "all";
|
|
15
16
|
externalOnly: "externalOnly";
|
|
16
|
-
none: "none";
|
|
17
17
|
}>>;
|
|
18
18
|
guestsCanModify: z.ZodDefault<z.ZodBoolean>;
|
|
19
19
|
guestsCanInviteOthers: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -139,9 +139,9 @@ export declare const updateEvent: import("frogbot").PieceActionDefinition<z.ZodO
|
|
|
139
139
|
guestsCanInviteOthers: z.ZodOptional<z.ZodBoolean>;
|
|
140
140
|
guestsCanSeeOtherGuests: z.ZodOptional<z.ZodBoolean>;
|
|
141
141
|
sendUpdates: z.ZodOptional<z.ZodEnum<{
|
|
142
|
+
none: "none";
|
|
142
143
|
all: "all";
|
|
143
144
|
externalOnly: "externalOnly";
|
|
144
|
-
none: "none";
|
|
145
145
|
}>>;
|
|
146
146
|
createMeetLink: z.ZodOptional<z.ZodBoolean>;
|
|
147
147
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -256,9 +256,9 @@ export declare const addAttendees: import("frogbot").PieceActionDefinition<z.Zod
|
|
|
256
256
|
eventId: z.ZodString;
|
|
257
257
|
attendees: z.ZodArray<z.ZodEmail>;
|
|
258
258
|
sendUpdates: z.ZodOptional<z.ZodEnum<{
|
|
259
|
+
none: "none";
|
|
259
260
|
all: "all";
|
|
260
261
|
externalOnly: "externalOnly";
|
|
261
|
-
none: "none";
|
|
262
262
|
}>>;
|
|
263
263
|
}, z.core.$strip>, z.ZodObject<{
|
|
264
264
|
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -371,9 +371,9 @@ export declare const createQuickEvent: import("frogbot").PieceActionDefinition<z
|
|
|
371
371
|
calendarId: z.ZodString;
|
|
372
372
|
text: z.ZodString;
|
|
373
373
|
sendUpdates: z.ZodDefault<z.ZodEnum<{
|
|
374
|
+
none: "none";
|
|
374
375
|
all: "all";
|
|
375
376
|
externalOnly: "externalOnly";
|
|
376
|
-
none: "none";
|
|
377
377
|
}>>;
|
|
378
378
|
}, z.core.$strip>, z.ZodObject<{
|
|
379
379
|
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -486,9 +486,9 @@ export declare const deleteEvent: import("frogbot").PieceActionDefinition<z.ZodO
|
|
|
486
486
|
calendarId: z.ZodString;
|
|
487
487
|
eventId: z.ZodString;
|
|
488
488
|
sendUpdates: z.ZodOptional<z.ZodEnum<{
|
|
489
|
+
none: "none";
|
|
489
490
|
all: "all";
|
|
490
491
|
externalOnly: "externalOnly";
|
|
491
|
-
none: "none";
|
|
492
492
|
}>>;
|
|
493
493
|
}, z.core.$strip>, z.ZodObject<{
|
|
494
494
|
deleted: z.ZodLiteral<true>;
|
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
|