@ebarooni/capacitor-calendar 8.10.0 → 8.12.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/README.md +372 -156
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +55 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +4 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CalendarChangeObserver.kt +181 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +184 -8
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventDeleteInfo.kt +6 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventRecurrenceRule.kt +4 -3
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/GetEventByIdInput.kt +13 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ListEventsInRangeInput.kt +5 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/StartListeningInput.kt +20 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/GetEventByIdResult.kt +15 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListEventsInRangeResult.kt +47 -43
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +123 -69
- package/dist/docs.json +1594 -989
- package/dist/esm/definitions.d.ts +2 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +15 -2
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.d.ts +2 -2
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.js +2 -2
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-changed-event.d.ts +52 -0
- package/dist/esm/schemas/interfaces/calendar-changed-event.js +2 -0
- package/dist/esm/schemas/interfaces/calendar-changed-event.js.map +1 -0
- package/dist/esm/schemas/interfaces/calendar-links.d.ts +32 -0
- package/dist/esm/schemas/interfaces/calendar-links.js +2 -0
- package/dist/esm/schemas/interfaces/calendar-links.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-event-options.d.ts +18 -0
- package/dist/esm/schemas/interfaces/create-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.d.ts +9 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-ics-file-options.d.ts +20 -0
- package/dist/esm/schemas/interfaces/create-ics-file-options.js +2 -0
- package/dist/esm/schemas/interfaces/create-ics-file-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-event-options.d.ts +2 -1
- package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +2 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/get-event-by-id-options.d.ts +11 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-options.js +2 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.d.ts +8 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-event-options.d.ts +11 -0
- package/dist/esm/schemas/interfaces/modify-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.d.ts +10 -0
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/open-calendar-options.d.ts +9 -0
- package/dist/esm/schemas/interfaces/open-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/share-ics-file-options.d.ts +17 -0
- package/dist/esm/schemas/interfaces/share-ics-file-options.js +2 -0
- package/dist/esm/schemas/interfaces/share-ics-file-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/start-listening-options.d.ts +46 -0
- package/dist/esm/schemas/interfaces/start-listening-options.js +2 -0
- package/dist/esm/schemas/interfaces/start-listening-options.js.map +1 -0
- package/dist/esm/schemas/types/calendar-day-view-provider.d.ts +7 -0
- package/dist/esm/schemas/types/calendar-day-view-provider.js +2 -0
- package/dist/esm/schemas/types/calendar-day-view-provider.js.map +1 -0
- package/dist/esm/schemas/types/calendar-link-provider.d.ts +6 -0
- package/dist/esm/schemas/types/calendar-link-provider.js +2 -0
- package/dist/esm/schemas/types/calendar-link-provider.js.map +1 -0
- package/dist/esm/sub-definitions/calendar-listening.d.ts +49 -0
- package/dist/esm/sub-definitions/calendar-listening.js +2 -0
- package/dist/esm/sub-definitions/calendar-listening.js.map +1 -0
- package/dist/esm/sub-definitions/calendar-operations.d.ts +2 -1
- package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
- package/dist/esm/sub-definitions/event-operations.d.ts +33 -0
- package/dist/esm/sub-definitions/event-operations.js.map +1 -1
- package/dist/esm/web/calendar-links.d.ts +26 -0
- package/dist/esm/web/calendar-links.js +114 -0
- package/dist/esm/web/calendar-links.js.map +1 -0
- package/dist/esm/web/create-ics-file.d.ts +21 -0
- package/dist/esm/web/create-ics-file.js +30 -0
- package/dist/esm/web/create-ics-file.js.map +1 -0
- package/dist/esm/web/ics.d.ts +11 -0
- package/dist/esm/web/ics.js +48 -32
- package/dist/esm/web/ics.js.map +1 -1
- package/dist/esm/web/share-ics-file.d.ts +21 -0
- package/dist/esm/web/share-ics-file.js +46 -0
- package/dist/esm/web/share-ics-file.js.map +1 -0
- package/dist/esm/web.d.ts +7 -1
- package/dist/esm/web.js +21 -4
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +295 -72
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +295 -72
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendarPlugin.swift +36 -1
- package/ios/Plugin/Implementation/CalendarChangeObserver.swift +259 -0
- package/ios/Plugin/Implementation/CapacitorCalendar.swift +56 -8
- package/ios/Plugin/Models/Inputs/CreateEventInput.swift +1 -1
- package/ios/Plugin/Models/Inputs/CreateEventWithPromptInput.swift +61 -70
- package/ios/Plugin/Models/Inputs/DeleteEventInput.swift +7 -0
- package/ios/Plugin/Models/Inputs/DeleteEventWithPromptInput.swift +7 -0
- package/ios/Plugin/Models/Inputs/DeleteReminderInput.swift +1 -1
- package/ios/Plugin/Models/Inputs/DeleteReminderWithPromptInput.swift +1 -1
- package/ios/Plugin/Models/Inputs/DeleteRemindersListInput.swift +1 -1
- package/ios/Plugin/Models/Inputs/GetEventByIdInput.swift +16 -0
- package/ios/Plugin/Models/Inputs/GetReminderByIdInput.swift +1 -1
- package/ios/Plugin/Models/Inputs/ListEventsInRangeInput.swift +20 -0
- package/ios/Plugin/Models/Inputs/ModifyEventInput.swift +13 -23
- package/ios/Plugin/Models/Inputs/ModifyEventWithPromptInput.swift +10 -5
- package/ios/Plugin/Models/Inputs/ModifyReminderInput.swift +1 -1
- package/ios/Plugin/Models/Inputs/StartListeningInput.swift +26 -0
- package/ios/Plugin/Models/Inputs/UpdateRemindersListInput.swift +1 -1
- package/ios/Plugin/Models/Results/GetEventByIdResult.swift +27 -0
- package/ios/Plugin/Models/Structs/RecurrenceInput.swift +14 -0
- package/ios/Plugin/PluginConfig.swift +3 -0
- package/ios/Plugin/PluginError.swift +32 -3
- package/ios/Plugin/Utils/ImplementationHelper.swift +49 -32
- package/ios/Plugin/Utils/PluginCallRejecter.swift +13 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-event-with-prompt-options.js","sourceRoot":"","sources":["../../../../src/schemas/interfaces/modify-event-with-prompt-options.ts"],"names":[],"mappings":"","sourcesContent":["import type { EventAvailability } from '../enums/event-availability';\n\nimport type { EventRecurrenceRule } from './event-recurrence-rule';\n\n/**\n * @since 7.1.0\n */\nexport interface ModifyEventWithPromptOptions {\n /**\n * Alert times in minutes relative to the event start.\n * Use negative numbers for reminders before the start, and positive numbers for reminders after the start.\n * On iOS only 2 alerts are supported.\n *\n * @example\n * // -1440 -> 1 day before\n * // -60 -> 1 hour before\n * // 30 -> 30 minutes after\n * [-1440, -60, 30]\n *\n * @platform iOS\n * @since 7.1.0\n */\n alerts?: number[];\n /**\n * @platform Android, iOS\n * @since 7.1.0\n */\n availability?: EventAvailability;\n /**\n * @platform iOS\n * @since 0.1.0\n */\n calendarId?: string;\n /**\n * @platform Android, iOS\n * @since 7.1.0\n */\n description?: string;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n endDate?: number;\n /**\n * The ID of the event to be modified.\n *\n * @platform Android, iOS\n * @since 7.1.0\n */\n id: string;\n /**\n * An array of emails to invite.\n *\n * @platform Android\n * @since 7.1.0\n */\n invitees?: string[];\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n isAllDay?: boolean;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n location?: string;\n /**\n * Rules for creating a recurring event.\n *\n * @platform Android, iOS\n * @since 7.3.0\n */\n recurrence?: EventRecurrenceRule;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n startDate?: number;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n title?: string;\n /**\n * @platform iOS\n * @since 0.1.0\n */\n url?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modify-event-with-prompt-options.js","sourceRoot":"","sources":["../../../../src/schemas/interfaces/modify-event-with-prompt-options.ts"],"names":[],"mappings":"","sourcesContent":["import type { EventAvailability } from '../enums/event-availability';\n\nimport type { EventRecurrenceRule } from './event-recurrence-rule';\n\n/**\n * @since 7.1.0\n */\nexport interface ModifyEventWithPromptOptions {\n /**\n * Alert times in minutes relative to the event start.\n * Use negative numbers for reminders before the start, and positive numbers for reminders after the start.\n * On iOS only 2 alerts are supported.\n *\n * @example\n * // -1440 -> 1 day before\n * // -60 -> 1 hour before\n * // 30 -> 30 minutes after\n * [-1440, -60, 30]\n *\n * @platform iOS\n * @since 7.1.0\n */\n alerts?: number[];\n /**\n * @platform Android, iOS\n * @since 7.1.0\n */\n availability?: EventAvailability;\n /**\n * @platform iOS\n * @since 0.1.0\n */\n calendarId?: string;\n /**\n * @platform Android, iOS\n * @since 7.1.0\n */\n description?: string;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n endDate?: number;\n /**\n * The ID of the event to be modified.\n *\n * @platform Android, iOS\n * @since 7.1.0\n */\n id: string;\n /**\n * The start time of the occurrence to modify, in milliseconds since the epoch.\n * Use `startDate` from `listEventsInRange`.\n * If omitted, the first occurrence of a recurring series is the target.\n *\n * @example 1716153600000\n * @platform iOS\n * @since 8.11.0\n */\n instanceDate?: number;\n /**\n * An array of emails to invite.\n *\n * @platform Android\n * @since 7.1.0\n */\n invitees?: string[];\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n isAllDay?: boolean;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n location?: string;\n /**\n * Rules for creating a recurring event.\n *\n * @platform Android, iOS\n * @since 7.3.0\n */\n recurrence?: EventRecurrenceRule;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n startDate?: number;\n /**\n * @platform Android, iOS\n * @since 0.1.0\n */\n title?: string;\n /**\n * @platform iOS\n * @since 0.1.0\n */\n url?: string;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CalendarDayViewProvider } from '../types/calendar-day-view-provider';
|
|
1
2
|
/**
|
|
2
3
|
* @since 7.1.0
|
|
3
4
|
*/
|
|
@@ -11,4 +12,12 @@ export interface OpenCalendarOptions {
|
|
|
11
12
|
* @since 7.1.0
|
|
12
13
|
*/
|
|
13
14
|
date?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Web calendar to open in a new browser tab, at the day of `date`.
|
|
17
|
+
* Without it, `openCalendar` rejects on Web, because browsers cannot open a calendar app.
|
|
18
|
+
*
|
|
19
|
+
* @platform Web
|
|
20
|
+
* @since 8.12.0
|
|
21
|
+
*/
|
|
22
|
+
provider?: CalendarDayViewProvider;
|
|
14
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-calendar-options.js","sourceRoot":"","sources":["../../../../src/schemas/interfaces/open-calendar-options.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @since 7.1.0\n */\nexport interface OpenCalendarOptions {\n /**\n * The date to open the calendar at, in milliseconds since the epoch.\n *\n * @example Date.now()\n * @default Date.now()\n * @platform Android, iOS\n * @since 7.1.0\n */\n date?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"open-calendar-options.js","sourceRoot":"","sources":["../../../../src/schemas/interfaces/open-calendar-options.ts"],"names":[],"mappings":"","sourcesContent":["import type { CalendarDayViewProvider } from '../types/calendar-day-view-provider';\n\n/**\n * @since 7.1.0\n */\nexport interface OpenCalendarOptions {\n /**\n * The date to open the calendar at, in milliseconds since the epoch.\n *\n * @example Date.now()\n * @default Date.now()\n * @platform Android, iOS\n * @since 7.1.0\n */\n date?: number;\n /**\n * Web calendar to open in a new browser tab, at the day of `date`.\n * Without it, `openCalendar` rejects on Web, because browsers cannot open a calendar app.\n *\n * @platform Web\n * @since 8.12.0\n */\n provider?: CalendarDayViewProvider;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-ics-file-options.js","sourceRoot":"","sources":["../../../../src/schemas/interfaces/share-ics-file-options.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @since 8.12.0\n */\nexport interface ShareIcsFileOptions {\n /**\n * Text for the share sheet.\n *\n * @since 8.12.0\n */\n text?: string;\n /**\n * Title for the share sheet.\n *\n * @since 8.12.0\n */\n title?: string;\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 8.12.0
|
|
3
|
+
*/
|
|
4
|
+
export interface StartListeningOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The start of the window to watch, in milliseconds since the epoch.
|
|
7
|
+
* Events still in progress at this time are watched.
|
|
8
|
+
*
|
|
9
|
+
* @example 1719792000000
|
|
10
|
+
* @since 8.12.0
|
|
11
|
+
*/
|
|
12
|
+
from: number;
|
|
13
|
+
/**
|
|
14
|
+
* The end of the window to watch, in milliseconds since the epoch.
|
|
15
|
+
* Use a window of a few months. A large window makes each check slower.
|
|
16
|
+
*
|
|
17
|
+
* @example 1722470400000
|
|
18
|
+
* @since 8.12.0
|
|
19
|
+
*/
|
|
20
|
+
to: number;
|
|
21
|
+
/**
|
|
22
|
+
* Ids of the calendars whose events are watched. When omitted or empty, all calendars are watched.
|
|
23
|
+
* Rejects if an id does not match a calendar.
|
|
24
|
+
*
|
|
25
|
+
* @example ["1", "2"]
|
|
26
|
+
* @since 8.12.0
|
|
27
|
+
*/
|
|
28
|
+
calendarIds?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Whether `created` and `updated` hold the full events. Defaults to `true`.
|
|
31
|
+
* When `false`, those fields are omitted. `precise` is then `false` when events were created or updated.
|
|
32
|
+
*
|
|
33
|
+
* @default true
|
|
34
|
+
* @since 8.12.0
|
|
35
|
+
*/
|
|
36
|
+
includeEvents?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to report reminder changes with `remindersChanged`. Defaults to `false`.
|
|
39
|
+
* Needs reminders access. No reminders are sent, only a signal.
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
* @platform iOS
|
|
43
|
+
* @since 8.12.0
|
|
44
|
+
*/
|
|
45
|
+
includeReminders?: boolean;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-listening-options.js","sourceRoot":"","sources":["../../../../src/schemas/interfaces/start-listening-options.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @since 8.12.0\n */\nexport interface StartListeningOptions {\n /**\n * The start of the window to watch, in milliseconds since the epoch.\n * Events still in progress at this time are watched.\n *\n * @example 1719792000000\n * @since 8.12.0\n */\n from: number;\n /**\n * The end of the window to watch, in milliseconds since the epoch.\n * Use a window of a few months. A large window makes each check slower.\n *\n * @example 1722470400000\n * @since 8.12.0\n */\n to: number;\n /**\n * Ids of the calendars whose events are watched. When omitted or empty, all calendars are watched.\n * Rejects if an id does not match a calendar.\n *\n * @example [\"1\", \"2\"]\n * @since 8.12.0\n */\n calendarIds?: string[];\n /**\n * Whether `created` and `updated` hold the full events. Defaults to `true`.\n * When `false`, those fields are omitted. `precise` is then `false` when events were created or updated.\n *\n * @default true\n * @since 8.12.0\n */\n includeEvents?: boolean;\n /**\n * Whether to report reminder changes with `remindersChanged`. Defaults to `false`.\n * Needs reminders access. No reminders are sent, only a signal.\n *\n * @default false\n * @platform iOS\n * @since 8.12.0\n */\n includeReminders?: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-day-view-provider.js","sourceRoot":"","sources":["../../../../src/schemas/types/calendar-day-view-provider.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Web calendar services that `openCalendar` can open at a day view.\n * Yahoo Calendar has no day view link.\n *\n * @since 8.12.0\n */\nexport type CalendarDayViewProvider = 'google' | 'outlook' | 'office365';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-link-provider.js","sourceRoot":"","sources":["../../../../src/schemas/types/calendar-link-provider.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Web calendar services that `getCalendarLinks` can build a link for.\n *\n * @since 8.12.0\n */\nexport type CalendarLinkProvider = 'google' | 'outlook' | 'office365' | 'yahoo';\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
import type { CalendarChangedEvent } from '../schemas/interfaces/calendar-changed-event';
|
|
3
|
+
import type { StartListeningOptions } from '../schemas/interfaces/start-listening-options';
|
|
4
|
+
export interface CalendarListening {
|
|
5
|
+
/**
|
|
6
|
+
* Starts to watch the calendar for changes in a time window.
|
|
7
|
+
* Call `addListener('calendarChanged', ...)` to receive them.
|
|
8
|
+
* A new call replaces the previous window.
|
|
9
|
+
* The plugin reads the window once as a baseline. It then compares the window after each change.
|
|
10
|
+
* Changes made by this plugin also trigger the listener.
|
|
11
|
+
* Changes made while the app is stopped are not sent.
|
|
12
|
+
* Needs calendar read access.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const handle = await CapacitorCalendar.addListener('calendarChanged', (change) => {
|
|
16
|
+
* console.log(change.created, change.updated, change.deletedIds);
|
|
17
|
+
* });
|
|
18
|
+
* await CapacitorCalendar.startListening({ from: Date.now(), to: Date.now() + 30 * 24 * 60 * 60 * 1000 });
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} `From date must be provided.` — when `from` is missing.
|
|
21
|
+
* @throws {Error} `To date must be provided.` — when `to` is missing.
|
|
22
|
+
* @throws {Error} `Calendar not found.` — when a `calendarIds` entry does not match a calendar.
|
|
23
|
+
*
|
|
24
|
+
* @platform Android, iOS
|
|
25
|
+
* @since 8.12.0
|
|
26
|
+
*/
|
|
27
|
+
startListening(options: StartListeningOptions): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Stops to watch the calendar. Does nothing when no watch is active.
|
|
30
|
+
* Listeners stay registered. Remove them with their handle or `removeAllListeners`.
|
|
31
|
+
*
|
|
32
|
+
* @platform Android, iOS
|
|
33
|
+
* @since 8.12.0
|
|
34
|
+
*/
|
|
35
|
+
stopListening(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Adds a listener for calendar changes. Call `startListening` to start the events.
|
|
38
|
+
*
|
|
39
|
+
* @platform Android, iOS
|
|
40
|
+
* @since 8.12.0
|
|
41
|
+
*/
|
|
42
|
+
addListener(eventName: 'calendarChanged', listenerFunc: (event: CalendarChangedEvent) => void): Promise<PluginListenerHandle>;
|
|
43
|
+
/**
|
|
44
|
+
* Removes all listeners of this plugin.
|
|
45
|
+
*
|
|
46
|
+
* @since 8.12.0
|
|
47
|
+
*/
|
|
48
|
+
removeAllListeners(): Promise<void>;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-listening.js","sourceRoot":"","sources":["../../../src/sub-definitions/calendar-listening.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nimport type { CalendarChangedEvent } from '../schemas/interfaces/calendar-changed-event';\nimport type { StartListeningOptions } from '../schemas/interfaces/start-listening-options';\n\nexport interface CalendarListening {\n /**\n * Starts to watch the calendar for changes in a time window.\n * Call `addListener('calendarChanged', ...)` to receive them.\n * A new call replaces the previous window.\n * The plugin reads the window once as a baseline. It then compares the window after each change.\n * Changes made by this plugin also trigger the listener.\n * Changes made while the app is stopped are not sent.\n * Needs calendar read access.\n *\n * @example\n * const handle = await CapacitorCalendar.addListener('calendarChanged', (change) => {\n * console.log(change.created, change.updated, change.deletedIds);\n * });\n * await CapacitorCalendar.startListening({ from: Date.now(), to: Date.now() + 30 * 24 * 60 * 60 * 1000 });\n *\n * @throws {Error} `From date must be provided.` — when `from` is missing.\n * @throws {Error} `To date must be provided.` — when `to` is missing.\n * @throws {Error} `Calendar not found.` — when a `calendarIds` entry does not match a calendar.\n *\n * @platform Android, iOS\n * @since 8.12.0\n */\n startListening(options: StartListeningOptions): Promise<void>;\n /**\n * Stops to watch the calendar. Does nothing when no watch is active.\n * Listeners stay registered. Remove them with their handle or `removeAllListeners`.\n *\n * @platform Android, iOS\n * @since 8.12.0\n */\n stopListening(): Promise<void>;\n /**\n * Adds a listener for calendar changes. Call `startListening` to start the events.\n *\n * @platform Android, iOS\n * @since 8.12.0\n */\n addListener(\n eventName: 'calendarChanged',\n listenerFunc: (event: CalendarChangedEvent) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Removes all listeners of this plugin.\n *\n * @since 8.12.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}
|
|
@@ -72,11 +72,12 @@ export interface CalendarOperations {
|
|
|
72
72
|
}>;
|
|
73
73
|
/**
|
|
74
74
|
* Opens the calendar app.
|
|
75
|
+
* On Web, opens a web calendar in a new tab when `provider` is set, and rejects otherwise.
|
|
75
76
|
*
|
|
76
77
|
* @example
|
|
77
78
|
* CapacitorCalendar.openCalendar({ date: Date.now() });
|
|
78
79
|
*
|
|
79
|
-
* @platform Android, iOS
|
|
80
|
+
* @platform Android, iOS, Web
|
|
80
81
|
* @since 7.1.0
|
|
81
82
|
*/
|
|
82
83
|
openCalendar(options?: OpenCalendarOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-operations.js","sourceRoot":"","sources":["../../../src/sub-definitions/calendar-operations.ts"],"names":[],"mappings":"","sourcesContent":["import type { Calendar } from '../schemas/interfaces/calendar';\nimport type { CreateCalendarOptions } from '../schemas/interfaces/create-calendar-options';\nimport type { CreateCalendarResult } from '../schemas/interfaces/create-calendar-result';\nimport type { DeleteCalendarOptions } from '../schemas/interfaces/delete-calendar-options';\nimport type { FetchAllCalendarSourcesResult } from '../schemas/interfaces/fetch-all-calendar-sources-result';\nimport type { GetDefaultCalendarOptions } from '../schemas/interfaces/get-default-calendar-options';\nimport type { ListCalendarsResult } from '../schemas/interfaces/list-calendars-result';\nimport type { ModifyCalendarOptions } from '../schemas/interfaces/modify-calendar-options';\nimport type { OpenCalendarOptions } from '../schemas/interfaces/open-calendar-options';\nimport type { SelectCalendarsWithPromptOptions } from '../schemas/interfaces/select-calendars-with-prompt-options';\nimport type { SelectCalendarsWithPromptResult } from '../schemas/interfaces/select-calendars-with-prompt-result';\n\nexport interface CalendarOperations {\n /**\n * Saves pending calendar changes.\n *\n * @platform iOS\n * @since 7.1.0\n */\n commit(): Promise<void>;\n /**\n * Opens a system interface to choose one or multiple calendars.\n *\n * Calendar access is expected. Call `requestFullCalendarAccess()` first.\n * Without authorization the chooser can look empty.\n *\n * On confirm, `result` contains the calendars the user selected.\n * On cancel, `result` is an empty array.\n *\n * If a chooser is already presented, a new call is rejected; the in-flight\n * call continues until the user confirms or cancels.\n *\n * @platform iOS\n * @since 0.2.0\n */\n selectCalendarsWithPrompt(options?: SelectCalendarsWithPromptOptions): Promise<SelectCalendarsWithPromptResult>;\n /**\n * Retrieves a list of calendar sources.\n *\n * Requires calendar access. Without authorization, `result` is typically\n * an empty array. This method does not reject solely for missing permission.\n *\n * @platform iOS\n * @since 6.6.0\n */\n fetchAllCalendarSources(): Promise<FetchAllCalendarSourcesResult>;\n /**\n * Retrieves a list of all available calendars.\n *\n * Requires calendar read access. On Android, missing permission typically\n * rejects. On iOS, missing authorization typically returns an empty `result`.\n *\n * @platform Android, iOS\n * @since 7.1.0\n */\n listCalendars(): Promise<ListCalendarsResult>;\n /**\n * Retrieves the default calendar.\n *\n * Requires calendar read access. On Android, missing permission typically\n * rejects. On iOS, missing authorization typically yields `result: null`.\n *\n * The system default is the primary calendar on Android and\n * `defaultCalendarForNewEvents` on iOS. When neither exists and\n * `useFallbackCalendar` is true, the first available calendar is returned.\n * Otherwise the method returns `null` when there is no system default.\n *\n * @platform Android, iOS\n * @since 0.3.0\n */\n getDefaultCalendar(options?: GetDefaultCalendarOptions): Promise<{ result: Calendar | null }>;\n /**\n * Opens the calendar app.\n *\n * @example\n * CapacitorCalendar.openCalendar({ date: Date.now() });\n *\n * @platform Android, iOS\n * @since 7.1.0\n */\n openCalendar(options?: OpenCalendarOptions): Promise<void>;\n /**\n * Creates a calendar.\n *\n * `title` is required. `color` is optional and defaults to `#007AFF`.\n * On Android, `accountName` and `ownerAccount` are required at runtime.\n *\n * @example\n * CapacitorCalendar.createCalendar({\n * title: 'Work',\n * accountName: 'plugin@example.com',\n * ownerAccount: 'plugin@example.com',\n * });\n *\n * @throws {Error} `Title must be provided.` — when `title` is missing.\n * @throws {Error} `Invalid color format.` — when `color` is present but invalid.\n * @throws {Error} `Account name must be provided.` — when `accountName` is missing on Android.\n * @throws {Error} `Owner account must be provided.` — when `ownerAccount` is missing on Android.\n * @throws {Error} `Calendar source not found.` — when `sourceId` is set and no EventKit source matches (iOS).\n * @throws {Error} `Failed to retrieve calendar ID.` — when the calendar is created but no id is returned.\n *\n * @platform Android, iOS\n * @since 5.2.0\n */\n createCalendar(options: CreateCalendarOptions): Promise<CreateCalendarResult>;\n /**\n * Deletes a calendar by id.\n *\n * @throws {Error} `Calendar ID must be provided.` — when `id` is missing.\n * @throws {Error} `Invalid calendar ID.` — when `id` is not a numeric Android calendar id.\n * @throws {Error} `Calendar not found.` — when no calendar exists for `id`.\n *\n * @platform Android, iOS\n * @since 5.2.0\n */\n deleteCalendar(options: DeleteCalendarOptions): Promise<void>;\n /**\n * Modifies a calendar with options.\n *\n * @throws {Error} `Calendar ID must be provided.` — when `id` is missing.\n * @throws {Error} `Invalid calendar ID.` — when `id` is not a numeric Android calendar id.\n * @throws {Error} `At least one of title or color must be provided.` — when both are omitted.\n * @throws {Error} `Invalid color format.` — when `color` is present but invalid.\n * @throws {Error} `Calendar not found.` — when no calendar exists for `id`.\n * @throws {Error} `Calendar is not modifiable.` — when the calendar cannot be modified (iOS).\n *\n * @platform Android, iOS\n * @since 7.2.0\n */\n modifyCalendar(options: ModifyCalendarOptions): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"calendar-operations.js","sourceRoot":"","sources":["../../../src/sub-definitions/calendar-operations.ts"],"names":[],"mappings":"","sourcesContent":["import type { Calendar } from '../schemas/interfaces/calendar';\nimport type { CreateCalendarOptions } from '../schemas/interfaces/create-calendar-options';\nimport type { CreateCalendarResult } from '../schemas/interfaces/create-calendar-result';\nimport type { DeleteCalendarOptions } from '../schemas/interfaces/delete-calendar-options';\nimport type { FetchAllCalendarSourcesResult } from '../schemas/interfaces/fetch-all-calendar-sources-result';\nimport type { GetDefaultCalendarOptions } from '../schemas/interfaces/get-default-calendar-options';\nimport type { ListCalendarsResult } from '../schemas/interfaces/list-calendars-result';\nimport type { ModifyCalendarOptions } from '../schemas/interfaces/modify-calendar-options';\nimport type { OpenCalendarOptions } from '../schemas/interfaces/open-calendar-options';\nimport type { SelectCalendarsWithPromptOptions } from '../schemas/interfaces/select-calendars-with-prompt-options';\nimport type { SelectCalendarsWithPromptResult } from '../schemas/interfaces/select-calendars-with-prompt-result';\n\nexport interface CalendarOperations {\n /**\n * Saves pending calendar changes.\n *\n * @platform iOS\n * @since 7.1.0\n */\n commit(): Promise<void>;\n /**\n * Opens a system interface to choose one or multiple calendars.\n *\n * Calendar access is expected. Call `requestFullCalendarAccess()` first.\n * Without authorization the chooser can look empty.\n *\n * On confirm, `result` contains the calendars the user selected.\n * On cancel, `result` is an empty array.\n *\n * If a chooser is already presented, a new call is rejected; the in-flight\n * call continues until the user confirms or cancels.\n *\n * @platform iOS\n * @since 0.2.0\n */\n selectCalendarsWithPrompt(options?: SelectCalendarsWithPromptOptions): Promise<SelectCalendarsWithPromptResult>;\n /**\n * Retrieves a list of calendar sources.\n *\n * Requires calendar access. Without authorization, `result` is typically\n * an empty array. This method does not reject solely for missing permission.\n *\n * @platform iOS\n * @since 6.6.0\n */\n fetchAllCalendarSources(): Promise<FetchAllCalendarSourcesResult>;\n /**\n * Retrieves a list of all available calendars.\n *\n * Requires calendar read access. On Android, missing permission typically\n * rejects. On iOS, missing authorization typically returns an empty `result`.\n *\n * @platform Android, iOS\n * @since 7.1.0\n */\n listCalendars(): Promise<ListCalendarsResult>;\n /**\n * Retrieves the default calendar.\n *\n * Requires calendar read access. On Android, missing permission typically\n * rejects. On iOS, missing authorization typically yields `result: null`.\n *\n * The system default is the primary calendar on Android and\n * `defaultCalendarForNewEvents` on iOS. When neither exists and\n * `useFallbackCalendar` is true, the first available calendar is returned.\n * Otherwise the method returns `null` when there is no system default.\n *\n * @platform Android, iOS\n * @since 0.3.0\n */\n getDefaultCalendar(options?: GetDefaultCalendarOptions): Promise<{ result: Calendar | null }>;\n /**\n * Opens the calendar app.\n * On Web, opens a web calendar in a new tab when `provider` is set, and rejects otherwise.\n *\n * @example\n * CapacitorCalendar.openCalendar({ date: Date.now() });\n *\n * @platform Android, iOS, Web\n * @since 7.1.0\n */\n openCalendar(options?: OpenCalendarOptions): Promise<void>;\n /**\n * Creates a calendar.\n *\n * `title` is required. `color` is optional and defaults to `#007AFF`.\n * On Android, `accountName` and `ownerAccount` are required at runtime.\n *\n * @example\n * CapacitorCalendar.createCalendar({\n * title: 'Work',\n * accountName: 'plugin@example.com',\n * ownerAccount: 'plugin@example.com',\n * });\n *\n * @throws {Error} `Title must be provided.` — when `title` is missing.\n * @throws {Error} `Invalid color format.` — when `color` is present but invalid.\n * @throws {Error} `Account name must be provided.` — when `accountName` is missing on Android.\n * @throws {Error} `Owner account must be provided.` — when `ownerAccount` is missing on Android.\n * @throws {Error} `Calendar source not found.` — when `sourceId` is set and no EventKit source matches (iOS).\n * @throws {Error} `Failed to retrieve calendar ID.` — when the calendar is created but no id is returned.\n *\n * @platform Android, iOS\n * @since 5.2.0\n */\n createCalendar(options: CreateCalendarOptions): Promise<CreateCalendarResult>;\n /**\n * Deletes a calendar by id.\n *\n * @throws {Error} `Calendar ID must be provided.` — when `id` is missing.\n * @throws {Error} `Invalid calendar ID.` — when `id` is not a numeric Android calendar id.\n * @throws {Error} `Calendar not found.` — when no calendar exists for `id`.\n *\n * @platform Android, iOS\n * @since 5.2.0\n */\n deleteCalendar(options: DeleteCalendarOptions): Promise<void>;\n /**\n * Modifies a calendar with options.\n *\n * @throws {Error} `Calendar ID must be provided.` — when `id` is missing.\n * @throws {Error} `Invalid calendar ID.` — when `id` is not a numeric Android calendar id.\n * @throws {Error} `At least one of title or color must be provided.` — when both are omitted.\n * @throws {Error} `Invalid color format.` — when `color` is present but invalid.\n * @throws {Error} `Calendar not found.` — when no calendar exists for `id`.\n * @throws {Error} `Calendar is not modifiable.` — when the calendar cannot be modified (iOS).\n *\n * @platform Android, iOS\n * @since 7.2.0\n */\n modifyCalendar(options: ModifyCalendarOptions): Promise<void>;\n}\n"]}
|
|
@@ -5,6 +5,8 @@ import type { CreateEventWithPromptResult } from '../schemas/interfaces/create-e
|
|
|
5
5
|
import type { DeleteEventOptions } from '../schemas/interfaces/delete-event-options';
|
|
6
6
|
import type { DeleteEventWithPromptOptions } from '../schemas/interfaces/delete-event-with-prompt-options';
|
|
7
7
|
import type { DeleteEventsByIdOptions } from '../schemas/interfaces/delete-events-by-id-options';
|
|
8
|
+
import type { GetEventByIdOptions } from '../schemas/interfaces/get-event-by-id-options';
|
|
9
|
+
import type { GetEventByIdResult } from '../schemas/interfaces/get-event-by-id-result';
|
|
8
10
|
import type { ListEventsInRangeOptions } from '../schemas/interfaces/list-events-in-range-options';
|
|
9
11
|
import type { ListEventsInRangeResult } from '../schemas/interfaces/list-events-in-range-result';
|
|
10
12
|
import type { ModifyEventOptions } from '../schemas/interfaces/modify-event-options';
|
|
@@ -24,6 +26,9 @@ export interface EventOperations {
|
|
|
24
26
|
* }
|
|
25
27
|
* await CapacitorCalendar.createEventWithPrompt(options)
|
|
26
28
|
*
|
|
29
|
+
* @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency` (Android, iOS).
|
|
30
|
+
* @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value (Android, iOS).
|
|
31
|
+
*
|
|
27
32
|
* @platform Android, iOS, Web
|
|
28
33
|
* @since 0.1.0
|
|
29
34
|
*/
|
|
@@ -39,6 +44,10 @@ export interface EventOperations {
|
|
|
39
44
|
* }
|
|
40
45
|
* await CapacitorCalendar.modifyEventWithPrompt(options);
|
|
41
46
|
*
|
|
47
|
+
* @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).
|
|
48
|
+
* @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency`.
|
|
49
|
+
* @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value.
|
|
50
|
+
*
|
|
42
51
|
* @platform Android, iOS
|
|
43
52
|
* @since 6.6.0
|
|
44
53
|
*/
|
|
@@ -58,12 +67,21 @@ export interface EventOperations {
|
|
|
58
67
|
* autoDownloadIcsFile: true,
|
|
59
68
|
* });
|
|
60
69
|
*
|
|
70
|
+
* @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency` (Android, iOS).
|
|
71
|
+
* @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value (Android, iOS).
|
|
72
|
+
*
|
|
61
73
|
* @platform Android, iOS, Web
|
|
62
74
|
* @since 0.4.0
|
|
63
75
|
*/
|
|
64
76
|
createEvent(options: CreateEventOptions): Promise<CreateEventResult>;
|
|
65
77
|
/**
|
|
66
78
|
* Modifies an event.
|
|
79
|
+
* Fields that you omit keep their current values.
|
|
80
|
+
*
|
|
81
|
+
* @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).
|
|
82
|
+
* @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency`.
|
|
83
|
+
* @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value.
|
|
84
|
+
* @throws {Error} `Recurrence cannot be changed for a single occurrence. Use THIS_AND_FUTURE_EVENTS.` — when `recurrence` is set with `instanceDate` and `THIS_EVENT` on a recurring event (iOS).
|
|
67
85
|
*
|
|
68
86
|
* @platform Android, iOS
|
|
69
87
|
* @since 6.6.0
|
|
@@ -82,6 +100,7 @@ export interface EventOperations {
|
|
|
82
100
|
/**
|
|
83
101
|
* Deletes an event.
|
|
84
102
|
*
|
|
103
|
+
* @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).
|
|
85
104
|
* @platform Android, iOS
|
|
86
105
|
* @since 7.1.0
|
|
87
106
|
*/
|
|
@@ -89,6 +108,7 @@ export interface EventOperations {
|
|
|
89
108
|
/**
|
|
90
109
|
* Opens a dialog to delete an event.
|
|
91
110
|
*
|
|
111
|
+
* @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).
|
|
92
112
|
* @platform Android, iOS
|
|
93
113
|
* @since 7.1.0
|
|
94
114
|
*/
|
|
@@ -100,6 +120,7 @@ export interface EventOperations {
|
|
|
100
120
|
*
|
|
101
121
|
* An event is included when its time interval intersects `[from, to]`, including
|
|
102
122
|
* multi-day events that span the range without starting or ending inside it.
|
|
123
|
+
* Pass `calendarIds` to search only some calendars.
|
|
103
124
|
*
|
|
104
125
|
* @example
|
|
105
126
|
* const startOfDay = new Date();
|
|
@@ -116,6 +137,18 @@ export interface EventOperations {
|
|
|
116
137
|
* @since 0.10.0
|
|
117
138
|
*/
|
|
118
139
|
listEventsInRange(options: ListEventsInRangeOptions): Promise<ListEventsInRangeResult>;
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves an event by id.
|
|
142
|
+
*
|
|
143
|
+
* For a recurring event, the result is the first occurrence on iOS and the series master on Android.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* const { event } = await CapacitorCalendar.getEventById({ id: eventId });
|
|
147
|
+
*
|
|
148
|
+
* @platform Android, iOS
|
|
149
|
+
* @since 8.11.0
|
|
150
|
+
*/
|
|
151
|
+
getEventById(options: GetEventByIdOptions): Promise<GetEventByIdResult>;
|
|
119
152
|
}
|
|
120
153
|
/**
|
|
121
154
|
* @since 7.1.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-operations.js","sourceRoot":"","sources":["../../../src/sub-definitions/event-operations.ts"],"names":[],"mappings":"","sourcesContent":["import type { CreateEventOptions } from '../schemas/interfaces/create-event-options';\nimport type { CreateEventResult } from '../schemas/interfaces/create-event-result';\nimport type { CreateEventWithPromptOptions } from '../schemas/interfaces/create-event-with-prompt-options';\nimport type { CreateEventWithPromptResult } from '../schemas/interfaces/create-event-with-prompt-result';\nimport type { DeleteEventOptions } from '../schemas/interfaces/delete-event-options';\nimport type { DeleteEventWithPromptOptions } from '../schemas/interfaces/delete-event-with-prompt-options';\nimport type { DeleteEventsByIdOptions } from '../schemas/interfaces/delete-events-by-id-options';\nimport type { ListEventsInRangeOptions } from '../schemas/interfaces/list-events-in-range-options';\nimport type { ListEventsInRangeResult } from '../schemas/interfaces/list-events-in-range-result';\nimport type { ModifyEventOptions } from '../schemas/interfaces/modify-event-options';\nimport type { ModifyEventWithPromptOptions } from '../schemas/interfaces/modify-event-with-prompt-options';\nimport type { EventEditAction } from '../schemas/types/event-edit-action';\n\nexport interface EventOperations {\n /**\n * Opens a calendar UI to create an event.\n * On Android and iOS, opens the system editor. On Android, `id` is always `null`.\n * On Web, shows a confirm dialog, then builds an `.ics` `File` when the user confirms.\n * See MCP `docs://web-behavior` for Web details.\n *\n * @example\n * const options = {\n * title: 'Test event',\n * startDate: Date.now(),\n * }\n * await CapacitorCalendar.createEventWithPrompt(options)\n *\n * @platform Android, iOS, Web\n * @since 0.1.0\n */\n createEventWithPrompt(options?: CreateEventWithPromptOptions): Promise<CreateEventWithPromptResult>;\n /**\n * Opens a system calendar interface to modify an event.\n * On Android always returns `null`.\n *\n * @example\n * const options = {\n * id: 'EVENT_ID',\n * title: 'New title',\n * }\n * await CapacitorCalendar.modifyEventWithPrompt(options);\n *\n * @platform Android, iOS\n * @since 6.6.0\n */\n modifyEventWithPrompt(options: ModifyEventWithPromptOptions): Promise<{ result: EventEditAction | null }>;\n /**\n * Creates an event in the calendar.\n * On Android and iOS, inserts into the system calendar and returns its `id`.\n * On Web, builds an `.ics` `File` as `ics` (no calendar store). See MCP `docs://web-behavior`.\n *\n * @example\n * const { id, ics } = await CapacitorCalendar.createEvent({\n * title: 'Team standup',\n * startDate: Date.now(),\n * icsFileName: 'team-standup.ics',\n * autoDownloadIcsFile: true,\n * });\n *\n * @platform Android, iOS, Web\n * @since 0.4.0\n */\n createEvent(options: CreateEventOptions): Promise<CreateEventResult>;\n /**\n * Modifies an event.\n *\n * @platform Android, iOS\n * @since 6.6.0\n */\n modifyEvent(options: ModifyEventOptions): Promise<void>;\n /**\n * Deletes multiple events.\n *\n * @deprecated Use `deleteEvent(...)`.\n * @platform Android, iOS\n * @since 0.11.0\n */\n deleteEventsById(options: DeleteEventsByIdOptions): Promise<{ result: DeleteEventsByIdResult }>;\n /**\n * Deletes an event.\n *\n * @platform Android, iOS\n * @since 7.1.0\n */\n deleteEvent(options: DeleteEventOptions): Promise<void>;\n /**\n * Opens a dialog to delete an event.\n *\n * @platform Android, iOS\n * @since 7.1.0\n */\n deleteEventWithPrompt(options: DeleteEventWithPromptOptions): Promise<{ deleted: boolean }>;\n /**\n * Retrieves events that overlap a date range.\n *\n * An event is included when its time interval intersects `[from, to]`, including\n * multi-day events that span the range without starting or ending inside it.\n *\n * @example\n * const startOfDay = new Date();\n * startOfDay.setHours(0, 0, 0, 0);\n * const startOfNextDay = new Date(startOfDay);\n * startOfNextDay.setDate(startOfNextDay.getDate() + 1);\n *\n * const { result } = await CapacitorCalendar.listEventsInRange({\n * from: startOfDay.getTime(),\n * to: startOfNextDay.getTime(),\n * });\n *\n * @platform Android, iOS\n * @since 0.10.0\n */\n listEventsInRange(options: ListEventsInRangeOptions): Promise<ListEventsInRangeResult>;\n}\n\n/**\n * @since 7.1.0\n */\nexport interface DeleteEventsByIdResult {\n /**\n * @since 7.1.0\n */\n deleted: string[];\n /**\n * @since 7.1.0\n */\n failed: string[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"event-operations.js","sourceRoot":"","sources":["../../../src/sub-definitions/event-operations.ts"],"names":[],"mappings":"","sourcesContent":["import type { CreateEventOptions } from '../schemas/interfaces/create-event-options';\nimport type { CreateEventResult } from '../schemas/interfaces/create-event-result';\nimport type { CreateEventWithPromptOptions } from '../schemas/interfaces/create-event-with-prompt-options';\nimport type { CreateEventWithPromptResult } from '../schemas/interfaces/create-event-with-prompt-result';\nimport type { DeleteEventOptions } from '../schemas/interfaces/delete-event-options';\nimport type { DeleteEventWithPromptOptions } from '../schemas/interfaces/delete-event-with-prompt-options';\nimport type { DeleteEventsByIdOptions } from '../schemas/interfaces/delete-events-by-id-options';\nimport type { GetEventByIdOptions } from '../schemas/interfaces/get-event-by-id-options';\nimport type { GetEventByIdResult } from '../schemas/interfaces/get-event-by-id-result';\nimport type { ListEventsInRangeOptions } from '../schemas/interfaces/list-events-in-range-options';\nimport type { ListEventsInRangeResult } from '../schemas/interfaces/list-events-in-range-result';\nimport type { ModifyEventOptions } from '../schemas/interfaces/modify-event-options';\nimport type { ModifyEventWithPromptOptions } from '../schemas/interfaces/modify-event-with-prompt-options';\nimport type { EventEditAction } from '../schemas/types/event-edit-action';\n\nexport interface EventOperations {\n /**\n * Opens a calendar UI to create an event.\n * On Android and iOS, opens the system editor. On Android, `id` is always `null`.\n * On Web, shows a confirm dialog, then builds an `.ics` `File` when the user confirms.\n * See MCP `docs://web-behavior` for Web details.\n *\n * @example\n * const options = {\n * title: 'Test event',\n * startDate: Date.now(),\n * }\n * await CapacitorCalendar.createEventWithPrompt(options)\n *\n * @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency` (Android, iOS).\n * @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value (Android, iOS).\n *\n * @platform Android, iOS, Web\n * @since 0.1.0\n */\n createEventWithPrompt(options?: CreateEventWithPromptOptions): Promise<CreateEventWithPromptResult>;\n /**\n * Opens a system calendar interface to modify an event.\n * On Android always returns `null`.\n *\n * @example\n * const options = {\n * id: 'EVENT_ID',\n * title: 'New title',\n * }\n * await CapacitorCalendar.modifyEventWithPrompt(options);\n *\n * @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).\n * @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency`.\n * @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value.\n *\n * @platform Android, iOS\n * @since 6.6.0\n */\n modifyEventWithPrompt(options: ModifyEventWithPromptOptions): Promise<{ result: EventEditAction | null }>;\n /**\n * Creates an event in the calendar.\n * On Android and iOS, inserts into the system calendar and returns its `id`.\n * On Web, builds an `.ics` `File` as `ics` (no calendar store). See MCP `docs://web-behavior`.\n *\n * @example\n * const { id, ics } = await CapacitorCalendar.createEvent({\n * title: 'Team standup',\n * startDate: Date.now(),\n * icsFileName: 'team-standup.ics',\n * autoDownloadIcsFile: true,\n * });\n *\n * @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency` (Android, iOS).\n * @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value (Android, iOS).\n *\n * @platform Android, iOS, Web\n * @since 0.4.0\n */\n createEvent(options: CreateEventOptions): Promise<CreateEventResult>;\n /**\n * Modifies an event.\n * Fields that you omit keep their current values.\n *\n * @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).\n * @throws {Error} `Frequency must be provided.` — when `recurrence` is set without `frequency`.\n * @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is not a supported value.\n * @throws {Error} `Recurrence cannot be changed for a single occurrence. Use THIS_AND_FUTURE_EVENTS.` — when `recurrence` is set with `instanceDate` and `THIS_EVENT` on a recurring event (iOS).\n *\n * @platform Android, iOS\n * @since 6.6.0\n */\n modifyEvent(options: ModifyEventOptions): Promise<void>;\n /**\n * Deletes multiple events.\n *\n * @deprecated Use `deleteEvent(...)`.\n * @platform Android, iOS\n * @since 0.11.0\n */\n deleteEventsById(options: DeleteEventsByIdOptions): Promise<{ result: DeleteEventsByIdResult }>;\n /**\n * Deletes an event.\n *\n * @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).\n * @platform Android, iOS\n * @since 7.1.0\n */\n deleteEvent(options: DeleteEventOptions): Promise<void>;\n /**\n * Opens a dialog to delete an event.\n *\n * @throws {Error} `Event not found.` — when no event exists for `id`, or no occurrence starts at `instanceDate` (iOS).\n * @platform Android, iOS\n * @since 7.1.0\n */\n deleteEventWithPrompt(options: DeleteEventWithPromptOptions): Promise<{ deleted: boolean }>;\n /**\n * Retrieves events that overlap a date range.\n *\n * An event is included when its time interval intersects `[from, to]`, including\n * multi-day events that span the range without starting or ending inside it.\n * Pass `calendarIds` to search only some calendars.\n *\n * @example\n * const startOfDay = new Date();\n * startOfDay.setHours(0, 0, 0, 0);\n * const startOfNextDay = new Date(startOfDay);\n * startOfNextDay.setDate(startOfNextDay.getDate() + 1);\n *\n * const { result } = await CapacitorCalendar.listEventsInRange({\n * from: startOfDay.getTime(),\n * to: startOfNextDay.getTime(),\n * });\n *\n * @platform Android, iOS\n * @since 0.10.0\n */\n listEventsInRange(options: ListEventsInRangeOptions): Promise<ListEventsInRangeResult>;\n /**\n * Retrieves an event by id.\n *\n * For a recurring event, the result is the first occurrence on iOS and the series master on Android.\n *\n * @example\n * const { event } = await CapacitorCalendar.getEventById({ id: eventId });\n *\n * @platform Android, iOS\n * @since 8.11.0\n */\n getEventById(options: GetEventByIdOptions): Promise<GetEventByIdResult>;\n}\n\n/**\n * @since 7.1.0\n */\nexport interface DeleteEventsByIdResult {\n /**\n * @since 7.1.0\n */\n deleted: string[];\n /**\n * @since 7.1.0\n */\n failed: string[];\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CalendarLinks } from '../schemas/interfaces/calendar-links';
|
|
2
|
+
import type { CreateEventOptions } from '../schemas/interfaces/create-event-options';
|
|
3
|
+
import type { CalendarDayViewProvider } from '../schemas/types/calendar-day-view-provider';
|
|
4
|
+
/**
|
|
5
|
+
* Builds links that open a web calendar with the event already filled in.
|
|
6
|
+
* The user must confirm in the web calendar. Nothing is saved without that step.
|
|
7
|
+
*
|
|
8
|
+
* Supported fields: `title`, `startDate`, `endDate`, `duration`, `isAllDay`, `description`, `location`.
|
|
9
|
+
* Google Calendar also gets `recurrence` and `attendees`. Alerts and `availability` are not part of any link.
|
|
10
|
+
* Outlook and Yahoo links ignore `recurrence`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const { google, outlook } = getCalendarLinks({ title: 'Team standup', startDate: Date.now() });
|
|
14
|
+
* window.open(google, '_blank', 'noopener');
|
|
15
|
+
*
|
|
16
|
+
* @since 8.12.0
|
|
17
|
+
*/
|
|
18
|
+
export declare function getCalendarLinks(options: CreateEventOptions): CalendarLinks;
|
|
19
|
+
/**
|
|
20
|
+
* Builds the link that opens the day view of a web calendar.
|
|
21
|
+
*
|
|
22
|
+
* @throws If `provider` is not `google`, `outlook`, or `office365`.
|
|
23
|
+
*
|
|
24
|
+
* @since 8.12.0
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCalendarDayLink(provider: CalendarDayViewProvider, date: number): string;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { formatDateOnlyLocal, formatDateTimeUtc, resolveEndDate, toRRule } from './ics';
|
|
2
|
+
/**
|
|
3
|
+
* Builds links that open a web calendar with the event already filled in.
|
|
4
|
+
* The user must confirm in the web calendar. Nothing is saved without that step.
|
|
5
|
+
*
|
|
6
|
+
* Supported fields: `title`, `startDate`, `endDate`, `duration`, `isAllDay`, `description`, `location`.
|
|
7
|
+
* Google Calendar also gets `recurrence` and `attendees`. Alerts and `availability` are not part of any link.
|
|
8
|
+
* Outlook and Yahoo links ignore `recurrence`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const { google, outlook } = getCalendarLinks({ title: 'Team standup', startDate: Date.now() });
|
|
12
|
+
* window.open(google, '_blank', 'noopener');
|
|
13
|
+
*
|
|
14
|
+
* @since 8.12.0
|
|
15
|
+
*/
|
|
16
|
+
export function getCalendarLinks(options) {
|
|
17
|
+
var _a;
|
|
18
|
+
const startDate = (_a = options.startDate) !== null && _a !== void 0 ? _a : Date.now();
|
|
19
|
+
const isAllDay = options.isAllDay === true;
|
|
20
|
+
const endDate = resolveEndDate(startDate, options.endDate, options.duration, isAllDay);
|
|
21
|
+
return {
|
|
22
|
+
google: buildGoogleLink(options, startDate, endDate, isAllDay),
|
|
23
|
+
outlook: buildOutlookLink('https://outlook.live.com', options, startDate, endDate, isAllDay),
|
|
24
|
+
office365: buildOutlookLink('https://outlook.office.com', options, startDate, endDate, isAllDay),
|
|
25
|
+
yahoo: buildYahooLink(options, startDate, endDate, isAllDay),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Builds the link that opens the day view of a web calendar.
|
|
30
|
+
*
|
|
31
|
+
* @throws If `provider` is not `google`, `outlook`, or `office365`.
|
|
32
|
+
*
|
|
33
|
+
* @since 8.12.0
|
|
34
|
+
*/
|
|
35
|
+
export function getCalendarDayLink(provider, date) {
|
|
36
|
+
const day = new Date(date);
|
|
37
|
+
const datePath = `${day.getFullYear()}/${day.getMonth() + 1}/${day.getDate()}`;
|
|
38
|
+
switch (provider) {
|
|
39
|
+
case 'google':
|
|
40
|
+
return `https://calendar.google.com/calendar/r/day/${datePath}`;
|
|
41
|
+
case 'outlook':
|
|
42
|
+
return `https://outlook.live.com/calendar/0/view/day/${datePath}`;
|
|
43
|
+
case 'office365':
|
|
44
|
+
return `https://outlook.office.com/calendar/0/view/day/${datePath}`;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unsupported calendar provider: ${String(provider)}. Use google, outlook, or office365.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function buildGoogleLink(options, startDate, endDate, isAllDay) {
|
|
50
|
+
var _a;
|
|
51
|
+
const params = new URLSearchParams();
|
|
52
|
+
params.set('action', 'TEMPLATE');
|
|
53
|
+
params.set('text', options.title);
|
|
54
|
+
params.set('dates', `${formatCompactDate(startDate, isAllDay)}/${formatCompactDate(endDate, isAllDay)}`);
|
|
55
|
+
setIfPresent(params, 'details', options.description);
|
|
56
|
+
setIfPresent(params, 'location', options.location);
|
|
57
|
+
if (options.recurrence != null) {
|
|
58
|
+
params.set('recur', `RRULE:${toRRule(options.recurrence, isAllDay)}`);
|
|
59
|
+
}
|
|
60
|
+
const emails = ((_a = options.attendees) !== null && _a !== void 0 ? _a : []).map((guest) => guest.email).filter((email) => email.length > 0);
|
|
61
|
+
if (emails.length > 0) {
|
|
62
|
+
params.set('add', emails.join(','));
|
|
63
|
+
}
|
|
64
|
+
return `https://calendar.google.com/calendar/render?${toQuery(params)}`;
|
|
65
|
+
}
|
|
66
|
+
function buildOutlookLink(host, options, startDate, endDate, isAllDay) {
|
|
67
|
+
const params = new URLSearchParams();
|
|
68
|
+
params.set('path', '/calendar/action/compose');
|
|
69
|
+
params.set('rru', 'addevent');
|
|
70
|
+
params.set('subject', options.title);
|
|
71
|
+
params.set('startdt', isAllDay ? formatIsoDate(startDate) : new Date(startDate).toISOString());
|
|
72
|
+
params.set('enddt', isAllDay ? formatIsoDate(endDate) : new Date(endDate).toISOString());
|
|
73
|
+
if (isAllDay) {
|
|
74
|
+
params.set('allday', 'true');
|
|
75
|
+
}
|
|
76
|
+
setIfPresent(params, 'body', options.description);
|
|
77
|
+
setIfPresent(params, 'location', options.location);
|
|
78
|
+
return `${host}/calendar/0/deeplink/compose?${toQuery(params)}`;
|
|
79
|
+
}
|
|
80
|
+
function buildYahooLink(options, startDate, endDate, isAllDay) {
|
|
81
|
+
const params = new URLSearchParams();
|
|
82
|
+
params.set('v', '60');
|
|
83
|
+
params.set('title', options.title);
|
|
84
|
+
params.set('st', formatCompactDate(startDate, isAllDay));
|
|
85
|
+
if (isAllDay) {
|
|
86
|
+
params.set('dur', 'allday');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
params.set('et', formatCompactDate(endDate, false));
|
|
90
|
+
}
|
|
91
|
+
setIfPresent(params, 'desc', options.description);
|
|
92
|
+
setIfPresent(params, 'in_loc', options.location);
|
|
93
|
+
return `https://calendar.yahoo.com/?${toQuery(params)}`;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Encodes spaces as `%20`, not `+`.
|
|
97
|
+
* Outlook shows a literal `+` when the link goes through its sign-in redirect.
|
|
98
|
+
*/
|
|
99
|
+
function toQuery(params) {
|
|
100
|
+
return [...params].map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join('&');
|
|
101
|
+
}
|
|
102
|
+
function setIfPresent(params, key, value) {
|
|
103
|
+
if (value != null && value.length > 0) {
|
|
104
|
+
params.set(key, value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function formatCompactDate(ms, isAllDay) {
|
|
108
|
+
return isAllDay ? formatDateOnlyLocal(ms) : formatDateTimeUtc(ms);
|
|
109
|
+
}
|
|
110
|
+
function formatIsoDate(ms) {
|
|
111
|
+
const compact = formatDateOnlyLocal(ms);
|
|
112
|
+
return `${compact.slice(0, 4)}-${compact.slice(4, 6)}-${compact.slice(6, 8)}`;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=calendar-links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-links.js","sourceRoot":"","sources":["../../../src/web/calendar-links.ts"],"names":[],"mappings":"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","sourcesContent":["import type { CalendarLinks } from '../schemas/interfaces/calendar-links';\nimport type { CreateEventOptions } from '../schemas/interfaces/create-event-options';\nimport type { CalendarDayViewProvider } from '../schemas/types/calendar-day-view-provider';\n\nimport { formatDateOnlyLocal, formatDateTimeUtc, resolveEndDate, toRRule } from './ics';\n\n/**\n * Builds links that open a web calendar with the event already filled in.\n * The user must confirm in the web calendar. Nothing is saved without that step.\n *\n * Supported fields: `title`, `startDate`, `endDate`, `duration`, `isAllDay`, `description`, `location`.\n * Google Calendar also gets `recurrence` and `attendees`. Alerts and `availability` are not part of any link.\n * Outlook and Yahoo links ignore `recurrence`.\n *\n * @example\n * const { google, outlook } = getCalendarLinks({ title: 'Team standup', startDate: Date.now() });\n * window.open(google, '_blank', 'noopener');\n *\n * @since 8.12.0\n */\nexport function getCalendarLinks(options: CreateEventOptions): CalendarLinks {\n const startDate = options.startDate ?? Date.now();\n const isAllDay = options.isAllDay === true;\n const endDate = resolveEndDate(startDate, options.endDate, options.duration, isAllDay);\n\n return {\n google: buildGoogleLink(options, startDate, endDate, isAllDay),\n outlook: buildOutlookLink('https://outlook.live.com', options, startDate, endDate, isAllDay),\n office365: buildOutlookLink('https://outlook.office.com', options, startDate, endDate, isAllDay),\n yahoo: buildYahooLink(options, startDate, endDate, isAllDay),\n };\n}\n\n/**\n * Builds the link that opens the day view of a web calendar.\n *\n * @throws If `provider` is not `google`, `outlook`, or `office365`.\n *\n * @since 8.12.0\n */\nexport function getCalendarDayLink(provider: CalendarDayViewProvider, date: number): string {\n const day = new Date(date);\n const datePath = `${day.getFullYear()}/${day.getMonth() + 1}/${day.getDate()}`;\n switch (provider) {\n case 'google':\n return `https://calendar.google.com/calendar/r/day/${datePath}`;\n case 'outlook':\n return `https://outlook.live.com/calendar/0/view/day/${datePath}`;\n case 'office365':\n return `https://outlook.office.com/calendar/0/view/day/${datePath}`;\n default:\n throw new Error(`Unsupported calendar provider: ${String(provider)}. Use google, outlook, or office365.`);\n }\n}\n\nfunction buildGoogleLink(options: CreateEventOptions, startDate: number, endDate: number, isAllDay: boolean): string {\n const params = new URLSearchParams();\n params.set('action', 'TEMPLATE');\n params.set('text', options.title);\n params.set('dates', `${formatCompactDate(startDate, isAllDay)}/${formatCompactDate(endDate, isAllDay)}`);\n setIfPresent(params, 'details', options.description);\n setIfPresent(params, 'location', options.location);\n if (options.recurrence != null) {\n params.set('recur', `RRULE:${toRRule(options.recurrence, isAllDay)}`);\n }\n const emails = (options.attendees ?? []).map((guest) => guest.email).filter((email) => email.length > 0);\n if (emails.length > 0) {\n params.set('add', emails.join(','));\n }\n return `https://calendar.google.com/calendar/render?${toQuery(params)}`;\n}\n\nfunction buildOutlookLink(\n host: string,\n options: CreateEventOptions,\n startDate: number,\n endDate: number,\n isAllDay: boolean,\n): string {\n const params = new URLSearchParams();\n params.set('path', '/calendar/action/compose');\n params.set('rru', 'addevent');\n params.set('subject', options.title);\n params.set('startdt', isAllDay ? formatIsoDate(startDate) : new Date(startDate).toISOString());\n params.set('enddt', isAllDay ? formatIsoDate(endDate) : new Date(endDate).toISOString());\n if (isAllDay) {\n params.set('allday', 'true');\n }\n setIfPresent(params, 'body', options.description);\n setIfPresent(params, 'location', options.location);\n return `${host}/calendar/0/deeplink/compose?${toQuery(params)}`;\n}\n\nfunction buildYahooLink(options: CreateEventOptions, startDate: number, endDate: number, isAllDay: boolean): string {\n const params = new URLSearchParams();\n params.set('v', '60');\n params.set('title', options.title);\n params.set('st', formatCompactDate(startDate, isAllDay));\n if (isAllDay) {\n params.set('dur', 'allday');\n } else {\n params.set('et', formatCompactDate(endDate, false));\n }\n setIfPresent(params, 'desc', options.description);\n setIfPresent(params, 'in_loc', options.location);\n return `https://calendar.yahoo.com/?${toQuery(params)}`;\n}\n\n/**\n * Encodes spaces as `%20`, not `+`.\n * Outlook shows a literal `+` when the link goes through its sign-in redirect.\n */\nfunction toQuery(params: URLSearchParams): string {\n return [...params].map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join('&');\n}\n\nfunction setIfPresent(params: URLSearchParams, key: string, value: string | undefined): void {\n if (value != null && value.length > 0) {\n params.set(key, value);\n }\n}\n\nfunction formatCompactDate(ms: number, isAllDay: boolean): string {\n return isAllDay ? formatDateOnlyLocal(ms) : formatDateTimeUtc(ms);\n}\n\nfunction formatIsoDate(ms: number): string {\n const compact = formatDateOnlyLocal(ms);\n return `${compact.slice(0, 4)}-${compact.slice(4, 6)}-${compact.slice(6, 8)}`;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CreateEventOptions } from '../schemas/interfaces/create-event-options';
|
|
2
|
+
import type { CreateIcsFileOptions } from '../schemas/interfaces/create-ics-file-options';
|
|
3
|
+
/**
|
|
4
|
+
* Builds an `.ics` `File` with one `VEVENT` for each event.
|
|
5
|
+
* Use it to export many events in one file, or to cancel events you exported before.
|
|
6
|
+
*
|
|
7
|
+
* @throws If `events` is empty.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const file = createIcsFile([
|
|
11
|
+
* { title: 'Kickoff', startDate: Date.now(), uid: 'kickoff-1' },
|
|
12
|
+
* { title: 'Review', startDate: Date.now() + 86400000, uid: 'review-1' },
|
|
13
|
+
* ], { fileName: 'project.ics' });
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Ask calendar apps to remove an event that was imported before
|
|
17
|
+
* const file = createIcsFile({ title: 'Kickoff', uid: 'kickoff-1', sequence: 1 }, { method: 'CANCEL' });
|
|
18
|
+
*
|
|
19
|
+
* @since 8.12.0
|
|
20
|
+
*/
|
|
21
|
+
export declare function createIcsFile(events: CreateEventOptions | CreateEventOptions[], options?: CreateIcsFileOptions): File;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { buildCalendarIcs, resolveIcsFileName } from './ics';
|
|
2
|
+
/**
|
|
3
|
+
* Builds an `.ics` `File` with one `VEVENT` for each event.
|
|
4
|
+
* Use it to export many events in one file, or to cancel events you exported before.
|
|
5
|
+
*
|
|
6
|
+
* @throws If `events` is empty.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const file = createIcsFile([
|
|
10
|
+
* { title: 'Kickoff', startDate: Date.now(), uid: 'kickoff-1' },
|
|
11
|
+
* { title: 'Review', startDate: Date.now() + 86400000, uid: 'review-1' },
|
|
12
|
+
* ], { fileName: 'project.ics' });
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Ask calendar apps to remove an event that was imported before
|
|
16
|
+
* const file = createIcsFile({ title: 'Kickoff', uid: 'kickoff-1', sequence: 1 }, { method: 'CANCEL' });
|
|
17
|
+
*
|
|
18
|
+
* @since 8.12.0
|
|
19
|
+
*/
|
|
20
|
+
export function createIcsFile(events, options = {}) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const list = Array.isArray(events) ? events : [events];
|
|
23
|
+
if (list.length === 0) {
|
|
24
|
+
throw new Error('createIcsFile requires at least one event.');
|
|
25
|
+
}
|
|
26
|
+
const content = buildCalendarIcs(list, (_a = options.method) !== null && _a !== void 0 ? _a : 'PUBLISH');
|
|
27
|
+
const name = resolveIcsFileName({ icsFileName: (_b = options.fileName) !== null && _b !== void 0 ? _b : list[0].icsFileName, title: list[0].title });
|
|
28
|
+
return new File([content], name, { type: 'text/calendar;charset=utf-8' });
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=create-ics-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ics-file.js","sourceRoot":"","sources":["../../../src/web/create-ics-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE7D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAiD,EACjD,UAAgC,EAAE;;IAElC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACvD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,EAAE,MAAA,OAAO,CAAC,MAAM,mCAAI,SAAS,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,kBAAkB,CAAC,EAAE,WAAW,EAAE,MAAA,OAAO,CAAC,QAAQ,mCAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAChH,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import type { CreateEventOptions } from '../schemas/interfaces/create-event-options';\nimport type { CreateIcsFileOptions } from '../schemas/interfaces/create-ics-file-options';\n\nimport { buildCalendarIcs, resolveIcsFileName } from './ics';\n\n/**\n * Builds an `.ics` `File` with one `VEVENT` for each event.\n * Use it to export many events in one file, or to cancel events you exported before.\n *\n * @throws If `events` is empty.\n *\n * @example\n * const file = createIcsFile([\n * { title: 'Kickoff', startDate: Date.now(), uid: 'kickoff-1' },\n * { title: 'Review', startDate: Date.now() + 86400000, uid: 'review-1' },\n * ], { fileName: 'project.ics' });\n *\n * @example\n * // Ask calendar apps to remove an event that was imported before\n * const file = createIcsFile({ title: 'Kickoff', uid: 'kickoff-1', sequence: 1 }, { method: 'CANCEL' });\n *\n * @since 8.12.0\n */\nexport function createIcsFile(\n events: CreateEventOptions | CreateEventOptions[],\n options: CreateIcsFileOptions = {},\n): File {\n const list = Array.isArray(events) ? events : [events];\n if (list.length === 0) {\n throw new Error('createIcsFile requires at least one event.');\n }\n const content = buildCalendarIcs(list, options.method ?? 'PUBLISH');\n const name = resolveIcsFileName({ icsFileName: options.fileName ?? list[0].icsFileName, title: list[0].title });\n return new File([content], name, { type: 'text/calendar;charset=utf-8' });\n}\n"]}
|