@particle-academy/google-calendar-js 0.1.0 → 0.2.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/flow.cjs CHANGED
@@ -21,6 +21,43 @@ function fakeChannelWatch({ config, fake }) {
21
21
  "expiration": "1789430400000"
22
22
  };
23
23
  }
24
+ function fakeEventCreate({ config, fake }) {
25
+ return {
26
+ "kind": "calendar#event",
27
+ "etag": '"3456789012345679"',
28
+ "id": fake.id("evt"),
29
+ "status": config.status !== void 0 && config.status !== null && config.status !== "" ? String(config.status) : "confirmed",
30
+ "htmlLink": "https://www.google.com/calendar/event?eid=ZmFrZQ",
31
+ "created": "2026-09-30T09:00:00.000Z",
32
+ "updated": "2026-09-30T09:00:00.000Z",
33
+ "summary": config.summary !== void 0 && config.summary !== null && config.summary !== "" ? String(config.summary) : "Design review",
34
+ "description": config.description !== void 0 && config.description !== null && config.description !== "" ? String(config.description) : "",
35
+ "location": config.location !== void 0 && config.location !== null && config.location !== "" ? String(config.location) : "",
36
+ "creator": {
37
+ "email": "ada@example.test"
38
+ },
39
+ "organizer": {
40
+ "email": "ada@example.test"
41
+ },
42
+ "start": {
43
+ "dateTime": config.startDateTime !== void 0 && config.startDateTime !== null && config.startDateTime !== "" ? String(config.startDateTime) : "2026-10-01T14:00:00Z",
44
+ "timeZone": config.startTimeZone !== void 0 && config.startTimeZone !== null && config.startTimeZone !== "" ? String(config.startTimeZone) : "UTC"
45
+ },
46
+ "end": {
47
+ "dateTime": config.endDateTime !== void 0 && config.endDateTime !== null && config.endDateTime !== "" ? String(config.endDateTime) : "2026-10-01T15:00:00Z",
48
+ "timeZone": config.endTimeZone !== void 0 && config.endTimeZone !== null && config.endTimeZone !== "" ? String(config.endTimeZone) : "UTC"
49
+ },
50
+ "iCalUID": `${fake.hex(8)}-${fake.hex(4)}-${fake.hex(4)}-${fake.hex(4)}-${fake.hex(12)}`,
51
+ "sequence": 0,
52
+ "reminders": {
53
+ "useDefault": true
54
+ },
55
+ "eventType": "default"
56
+ };
57
+ }
58
+ function fakeEventDelete({ config, fake }) {
59
+ return {};
60
+ }
24
61
  function fakeEventGet({ config, fake }) {
25
62
  const boundEventid = config.eventId !== void 0 && config.eventId !== null && config.eventId !== "" ? String(config.eventId) : fake.id("evt");
26
63
  return {
@@ -115,6 +152,40 @@ function fakeEventList({ config, fake }) {
115
152
  ]
116
153
  };
117
154
  }
155
+ function fakeEventUpdate({ config, fake }) {
156
+ return {
157
+ "kind": "calendar#event",
158
+ "etag": '"3456789012345680"',
159
+ "id": config.eventId !== void 0 && config.eventId !== null && config.eventId !== "" ? String(config.eventId) : fake.id("evt"),
160
+ "status": config.status !== void 0 && config.status !== null && config.status !== "" ? String(config.status) : "confirmed",
161
+ "htmlLink": "https://www.google.com/calendar/event?eid=ZmFrZQ",
162
+ "created": "2026-09-01T09:00:00.000Z",
163
+ "updated": "2026-09-30T09:15:00.000Z",
164
+ "summary": config.summary !== void 0 && config.summary !== null && config.summary !== "" ? String(config.summary) : "Design review",
165
+ "description": config.description !== void 0 && config.description !== null && config.description !== "" ? String(config.description) : "",
166
+ "location": config.location !== void 0 && config.location !== null && config.location !== "" ? String(config.location) : "",
167
+ "creator": {
168
+ "email": "ada@example.test"
169
+ },
170
+ "organizer": {
171
+ "email": "ada@example.test"
172
+ },
173
+ "start": {
174
+ "dateTime": config.startDateTime !== void 0 && config.startDateTime !== null && config.startDateTime !== "" ? String(config.startDateTime) : "2026-10-01T14:00:00Z",
175
+ "timeZone": config.startTimeZone !== void 0 && config.startTimeZone !== null && config.startTimeZone !== "" ? String(config.startTimeZone) : "UTC"
176
+ },
177
+ "end": {
178
+ "dateTime": config.endDateTime !== void 0 && config.endDateTime !== null && config.endDateTime !== "" ? String(config.endDateTime) : "2026-10-01T15:00:00Z",
179
+ "timeZone": config.endTimeZone !== void 0 && config.endTimeZone !== null && config.endTimeZone !== "" ? String(config.endTimeZone) : "UTC"
180
+ },
181
+ "iCalUID": `${fake.hex(8)}-${fake.hex(4)}-${fake.hex(4)}-${fake.hex(4)}-${fake.hex(12)}`,
182
+ "sequence": 1,
183
+ "reminders": {
184
+ "useDefault": true
185
+ },
186
+ "eventType": "default"
187
+ };
188
+ }
118
189
  function fakeEventsChanged({ config, fake }) {
119
190
  const boundChannelid = `${fake.hex(8)}-${fake.hex(4)}-${fake.hex(4)}-${fake.hex(4)}-${fake.hex(12)}`;
120
191
  return {
@@ -132,10 +203,16 @@ var googleCalendarFaker = (operation, request) => {
132
203
  return fakeChannelStop(request);
133
204
  case "channel_watch":
134
205
  return fakeChannelWatch(request);
206
+ case "event_create":
207
+ return fakeEventCreate(request);
208
+ case "event_delete":
209
+ return fakeEventDelete(request);
135
210
  case "event_get":
136
211
  return fakeEventGet(request);
137
212
  case "event_list":
138
213
  return fakeEventList(request);
214
+ case "event_update":
215
+ return fakeEventUpdate(request);
139
216
  case "events_changed":
140
217
  return fakeEventsChanged(request);
141
218
  default:
@@ -250,6 +327,89 @@ function nestFields(flat) {
250
327
  }
251
328
  return out;
252
329
  }
330
+ var EVENT_CREATE_OPERATION = "event_create";
331
+ async function googleCalendarEventCreate(options) {
332
+ const config = options.config ?? {};
333
+ if (config.calendarId === void 0 || config.calendarId === null || config.calendarId === "") {
334
+ throw new Error(`event_create: "calendarId" is required (Calendar ID).`);
335
+ }
336
+ if (config.summary === void 0 || config.summary === null || config.summary === "") {
337
+ throw new Error(`event_create: "summary" is required (Title).`);
338
+ }
339
+ if (config.startDateTime === void 0 || config.startDateTime === null || config.startDateTime === "") {
340
+ throw new Error(`event_create: "startDateTime" is required (Start).`);
341
+ }
342
+ if (config.endDateTime === void 0 || config.endDateTime === null || config.endDateTime === "") {
343
+ throw new Error(`event_create: "endDateTime" is required (End).`);
344
+ }
345
+ return fancyConnectorCore.callConnector(GOOGLE_CALENDAR, {
346
+ operation: EVENT_CREATE_OPERATION,
347
+ config,
348
+ input: options.input,
349
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
350
+ ...options.mode === void 0 ? {} : { mode: options.mode },
351
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
352
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
353
+ ...options.transport === void 0 ? {} : { transport: options.transport },
354
+ request: {
355
+ method: "POST",
356
+ path: `/calendar/v3/calendars/${encodeURIComponent(String(config.calendarId))}/events`,
357
+ json: nestFields2({
358
+ "summary": String(config.summary),
359
+ ...config.description !== void 0 && config.description !== null && config.description !== "" ? { "description": String(config.description) } : {},
360
+ ...config.location !== void 0 && config.location !== null && config.location !== "" ? { "location": String(config.location) } : {},
361
+ "start.dateTime": String(config.startDateTime),
362
+ ...config.startTimeZone !== void 0 && config.startTimeZone !== null && config.startTimeZone !== "" ? { "start.timeZone": String(config.startTimeZone) } : {},
363
+ "end.dateTime": String(config.endDateTime),
364
+ ...config.endTimeZone !== void 0 && config.endTimeZone !== null && config.endTimeZone !== "" ? { "end.timeZone": String(config.endTimeZone) } : {},
365
+ ...config.status !== void 0 && config.status !== null && config.status !== "" ? { "status": String(config.status) } : {},
366
+ ...config.visibility !== void 0 && config.visibility !== null && config.visibility !== "" ? { "visibility": String(config.visibility) } : {},
367
+ ...config.transparency !== void 0 && config.transparency !== null && config.transparency !== "" ? { "transparency": String(config.transparency) } : {},
368
+ ...config.colorId !== void 0 && config.colorId !== null && config.colorId !== "" ? { "colorId": String(config.colorId) } : {}
369
+ })
370
+ }
371
+ });
372
+ }
373
+ function nestFields2(flat) {
374
+ const out = {};
375
+ for (const [path, value] of Object.entries(flat)) {
376
+ const parts = path.split(".");
377
+ let node = out;
378
+ while (parts.length > 1) {
379
+ const key = parts.shift();
380
+ const wantsArray = /^\d+$/.test(parts[0] ?? "");
381
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
382
+ node = node[key];
383
+ }
384
+ node[parts[0]] = value;
385
+ }
386
+ return out;
387
+ }
388
+ var EVENT_DELETE_OPERATION = "event_delete";
389
+ async function googleCalendarEventDelete(options) {
390
+ const config = options.config ?? {};
391
+ if (config.calendarId === void 0 || config.calendarId === null || config.calendarId === "") {
392
+ throw new Error(`event_delete: "calendarId" is required (Calendar ID).`);
393
+ }
394
+ if (config.eventId === void 0 || config.eventId === null || config.eventId === "") {
395
+ throw new Error(`event_delete: "eventId" is required (Event ID).`);
396
+ }
397
+ return fancyConnectorCore.callConnector(GOOGLE_CALENDAR, {
398
+ operation: EVENT_DELETE_OPERATION,
399
+ config,
400
+ input: options.input,
401
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
402
+ ...options.mode === void 0 ? {} : { mode: options.mode },
403
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
404
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
405
+ ...options.transport === void 0 ? {} : { transport: options.transport },
406
+ request: {
407
+ method: "DELETE",
408
+ path: `/calendar/v3/calendars/${encodeURIComponent(String(config.calendarId))}/events/${encodeURIComponent(String(config.eventId))}`,
409
+ query: {}
410
+ }
411
+ });
412
+ }
253
413
  var EVENT_GET_OPERATION = "event_get";
254
414
  async function googleCalendarEventGet(options) {
255
415
  const config = options.config ?? {};
@@ -313,6 +473,58 @@ async function googleCalendarEventList(options) {
313
473
  }
314
474
  });
315
475
  }
476
+ var EVENT_UPDATE_OPERATION = "event_update";
477
+ async function googleCalendarEventUpdate(options) {
478
+ const config = options.config ?? {};
479
+ if (config.calendarId === void 0 || config.calendarId === null || config.calendarId === "") {
480
+ throw new Error(`event_update: "calendarId" is required (Calendar ID).`);
481
+ }
482
+ if (config.eventId === void 0 || config.eventId === null || config.eventId === "") {
483
+ throw new Error(`event_update: "eventId" is required (Event ID).`);
484
+ }
485
+ return fancyConnectorCore.callConnector(GOOGLE_CALENDAR, {
486
+ operation: EVENT_UPDATE_OPERATION,
487
+ config,
488
+ input: options.input,
489
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
490
+ ...options.mode === void 0 ? {} : { mode: options.mode },
491
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
492
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
493
+ ...options.transport === void 0 ? {} : { transport: options.transport },
494
+ request: {
495
+ method: "PATCH",
496
+ path: `/calendar/v3/calendars/${encodeURIComponent(String(config.calendarId))}/events/${encodeURIComponent(String(config.eventId))}`,
497
+ json: nestFields3({
498
+ ...config.summary !== void 0 && config.summary !== null && config.summary !== "" ? { "summary": String(config.summary) } : {},
499
+ ...config.description !== void 0 && config.description !== null && config.description !== "" ? { "description": String(config.description) } : {},
500
+ ...config.location !== void 0 && config.location !== null && config.location !== "" ? { "location": String(config.location) } : {},
501
+ ...config.startDateTime !== void 0 && config.startDateTime !== null && config.startDateTime !== "" ? { "start.dateTime": String(config.startDateTime) } : {},
502
+ ...config.startTimeZone !== void 0 && config.startTimeZone !== null && config.startTimeZone !== "" ? { "start.timeZone": String(config.startTimeZone) } : {},
503
+ ...config.endDateTime !== void 0 && config.endDateTime !== null && config.endDateTime !== "" ? { "end.dateTime": String(config.endDateTime) } : {},
504
+ ...config.endTimeZone !== void 0 && config.endTimeZone !== null && config.endTimeZone !== "" ? { "end.timeZone": String(config.endTimeZone) } : {},
505
+ ...config.status !== void 0 && config.status !== null && config.status !== "" ? { "status": String(config.status) } : {},
506
+ ...config.visibility !== void 0 && config.visibility !== null && config.visibility !== "" ? { "visibility": String(config.visibility) } : {},
507
+ ...config.transparency !== void 0 && config.transparency !== null && config.transparency !== "" ? { "transparency": String(config.transparency) } : {},
508
+ ...config.colorId !== void 0 && config.colorId !== null && config.colorId !== "" ? { "colorId": String(config.colorId) } : {}
509
+ })
510
+ }
511
+ });
512
+ }
513
+ function nestFields3(flat) {
514
+ const out = {};
515
+ for (const [path, value] of Object.entries(flat)) {
516
+ const parts = path.split(".");
517
+ let node = out;
518
+ while (parts.length > 1) {
519
+ const key = parts.shift();
520
+ const wantsArray = /^\d+$/.test(parts[0] ?? "");
521
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
522
+ node = node[key];
523
+ }
524
+ node[parts[0]] = value;
525
+ }
526
+ return out;
527
+ }
316
528
  var GOOGLE_CALENDAR_EVENTS_CHANGED_TOKEN_SCHEME = { kind: "shared-token", in: "header", name: "X-Goog-Channel-Token" };
317
529
  var GOOGLE_CALENDAR_EVENTS_CHANGED_LEASE = {
318
530
  expiresAtFrom: "expiration",
@@ -362,6 +574,34 @@ var googleCalendarChannelWatchExecutor = async (ctx) => {
362
574
  });
363
575
  return { __port: "out", value: result };
364
576
  };
577
+ var googleCalendarEventCreateExecutor = async (ctx) => {
578
+ const config = ctx.node.data?.config ?? {};
579
+ const result = await googleCalendarEventCreate({
580
+ config,
581
+ input: ctx.inputs?.in
582
+ });
583
+ ctx.emit({
584
+ type: "log",
585
+ level: "info",
586
+ nodeId: ctx.node.id,
587
+ message: `google_calendar event_create ${result.data?.id} (${result.mode})`
588
+ });
589
+ return { __port: "out", value: result };
590
+ };
591
+ var googleCalendarEventDeleteExecutor = async (ctx) => {
592
+ const config = ctx.node.data?.config ?? {};
593
+ const result = await googleCalendarEventDelete({
594
+ config,
595
+ input: ctx.inputs?.in
596
+ });
597
+ ctx.emit({
598
+ type: "log",
599
+ level: "info",
600
+ nodeId: ctx.node.id,
601
+ message: `google_calendar event_delete ${result.data?.id} (${result.mode})`
602
+ });
603
+ return { __port: "out", value: result };
604
+ };
365
605
  var googleCalendarEventGetExecutor = async (ctx) => {
366
606
  const config = ctx.node.data?.config ?? {};
367
607
  const result = await googleCalendarEventGet({
@@ -390,6 +630,20 @@ var googleCalendarEventListExecutor = async (ctx) => {
390
630
  });
391
631
  return { __port: "out", value: result };
392
632
  };
633
+ var googleCalendarEventUpdateExecutor = async (ctx) => {
634
+ const config = ctx.node.data?.config ?? {};
635
+ const result = await googleCalendarEventUpdate({
636
+ config,
637
+ input: ctx.inputs?.in
638
+ });
639
+ ctx.emit({
640
+ type: "log",
641
+ level: "info",
642
+ nodeId: ctx.node.id,
643
+ message: `google_calendar event_update ${result.data?.id} (${result.mode})`
644
+ });
645
+ return { __port: "out", value: result };
646
+ };
393
647
  var googleCalendarEventsChangedTriggerExecutor = async (ctx) => {
394
648
  const config = ctx.node.data?.config ?? {};
395
649
  const connection = fancyConnectorCore.resolveConnection({
@@ -407,16 +661,22 @@ var googleCalendarEventsChangedTriggerExecutor = async (ctx) => {
407
661
  var GOOGLE_CALENDAR_RUNNABLE_KINDS = [
408
662
  { ...googleCalendarUi.googleCalendarChannelStopKind, executor: googleCalendarChannelStopExecutor },
409
663
  { ...googleCalendarUi.googleCalendarChannelWatchKind, executor: googleCalendarChannelWatchExecutor },
664
+ { ...googleCalendarUi.googleCalendarEventCreateKind, executor: googleCalendarEventCreateExecutor },
665
+ { ...googleCalendarUi.googleCalendarEventDeleteKind, executor: googleCalendarEventDeleteExecutor },
410
666
  { ...googleCalendarUi.googleCalendarEventGetKind, executor: googleCalendarEventGetExecutor },
411
667
  { ...googleCalendarUi.googleCalendarEventListKind, executor: googleCalendarEventListExecutor },
668
+ { ...googleCalendarUi.googleCalendarEventUpdateKind, executor: googleCalendarEventUpdateExecutor },
412
669
  { ...googleCalendarUi.googleCalendarEventsChangedTriggerKind, executor: googleCalendarEventsChangedTriggerExecutor }
413
670
  ];
414
671
 
415
672
  exports.GOOGLE_CALENDAR_RUNNABLE_KINDS = GOOGLE_CALENDAR_RUNNABLE_KINDS;
416
673
  exports.googleCalendarChannelStopExecutor = googleCalendarChannelStopExecutor;
417
674
  exports.googleCalendarChannelWatchExecutor = googleCalendarChannelWatchExecutor;
675
+ exports.googleCalendarEventCreateExecutor = googleCalendarEventCreateExecutor;
676
+ exports.googleCalendarEventDeleteExecutor = googleCalendarEventDeleteExecutor;
418
677
  exports.googleCalendarEventGetExecutor = googleCalendarEventGetExecutor;
419
678
  exports.googleCalendarEventListExecutor = googleCalendarEventListExecutor;
679
+ exports.googleCalendarEventUpdateExecutor = googleCalendarEventUpdateExecutor;
420
680
  exports.googleCalendarEventsChangedTriggerExecutor = googleCalendarEventsChangedTriggerExecutor;
421
681
  //# sourceMappingURL=flow.cjs.map
422
682
  //# sourceMappingURL=flow.cjs.map