@ebarooni/capacitor-calendar 8.1.0 → 8.3.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.
Files changed (59) hide show
  1. package/README.md +108 -23
  2. package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +10 -0
  3. package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +4 -0
  4. package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +29 -6
  5. package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventDeleteInfo.kt +8 -0
  6. package/android/src/main/java/dev/barooni/capacitor/calendar/models/enums/EventSpan.kt +13 -0
  7. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventInput.kt +4 -1
  8. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventWithPromptInput.kt +4 -1
  9. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventsByIdInput.kt +2 -0
  10. package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +272 -4
  11. package/dist/docs.json +414 -45
  12. package/dist/esm/index.d.ts +4 -1
  13. package/dist/esm/index.js.map +1 -1
  14. package/dist/esm/schemas/enums/event-span.d.ts +4 -0
  15. package/dist/esm/schemas/enums/event-span.js +4 -0
  16. package/dist/esm/schemas/enums/event-span.js.map +1 -1
  17. package/dist/esm/schemas/interfaces/create-reminders-list-options.d.ts +0 -1
  18. package/dist/esm/schemas/interfaces/create-reminders-list-options.js.map +1 -1
  19. package/dist/esm/schemas/interfaces/create-reminders-list-result.d.ts +0 -1
  20. package/dist/esm/schemas/interfaces/create-reminders-list-result.js.map +1 -1
  21. package/dist/esm/schemas/interfaces/delete-event-options.d.ts +28 -3
  22. package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
  23. package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +38 -13
  24. package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
  25. package/dist/esm/schemas/interfaces/delete-events-by-id-options.d.ts +15 -3
  26. package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -1
  27. package/dist/esm/schemas/interfaces/delete-reminders-list-options.d.ts +23 -0
  28. package/dist/esm/schemas/interfaces/delete-reminders-list-options.js +2 -0
  29. package/dist/esm/schemas/interfaces/delete-reminders-list-options.js.map +1 -0
  30. package/dist/esm/schemas/interfaces/update-reminders-list-options.d.ts +40 -0
  31. package/dist/esm/schemas/interfaces/update-reminders-list-options.js +2 -0
  32. package/dist/esm/schemas/interfaces/update-reminders-list-options.js.map +1 -0
  33. package/dist/esm/schemas/interfaces/update-reminders-list-result.d.ts +12 -0
  34. package/dist/esm/schemas/interfaces/update-reminders-list-result.js +2 -0
  35. package/dist/esm/schemas/interfaces/update-reminders-list-result.js.map +1 -0
  36. package/dist/esm/sub-definitions/calendar-operations.d.ts +1 -1
  37. package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
  38. package/dist/esm/sub-definitions/reminders-operations.d.ts +17 -0
  39. package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
  40. package/dist/esm/web.d.ts +5 -0
  41. package/dist/esm/web.js +6 -0
  42. package/dist/esm/web.js.map +1 -1
  43. package/dist/plugin.cjs.js +10 -0
  44. package/dist/plugin.cjs.js.map +1 -1
  45. package/dist/plugin.js +10 -0
  46. package/dist/plugin.js.map +1 -1
  47. package/ios/Plugin/CapacitorCalendarPlugin.swift +30 -0
  48. package/ios/Plugin/Implementation/CapacitorCalendar.swift +42 -3
  49. package/ios/Plugin/Models/Enums/EventSpan.swift +8 -0
  50. package/ios/Plugin/Models/Inputs/DeleteEventInput.swift +9 -4
  51. package/ios/Plugin/Models/Inputs/DeleteEventWithPromptInput.swift +9 -4
  52. package/ios/Plugin/Models/Inputs/DeleteEventsByIdInput.swift +9 -4
  53. package/ios/Plugin/Models/Inputs/DeleteRemindersListInput.swift +22 -0
  54. package/ios/Plugin/Models/Inputs/UpdateRemindersListInput.swift +55 -0
  55. package/ios/Plugin/Models/Results/UpdateRemindersListResult.swift +15 -0
  56. package/ios/Plugin/PluginConfig.swift +3 -1
  57. package/ios/Plugin/PluginError.swift +3 -0
  58. package/ios/Plugin/Utils/ImplementationHelper.swift +7 -2
  59. package/package.json +1 -1
package/README.md CHANGED
@@ -14,6 +14,9 @@
14
14
  <a href="https://capacitorjs.com/">
15
15
  <img src="https://img.shields.io/badge/Capacitor-8.x-119EFF.svg?style=flat-square" />
16
16
  </a>
17
+ <a href="mcp/README.md">
18
+ <img src="https://img.shields.io/badge/MCP-161b22?style=flat&logo=modelcontextprotocol&logoColor=5FB8AF" />
19
+ </a>
17
20
  </p>
18
21
 
19
22
  ![capacitor-calendar-logo](assets/images/text-logo.png)
@@ -43,6 +46,16 @@ Full-featured Capacitor plugin for native calendar and reminders access. Manage
43
46
  - **Fast support.** Questions, bug reports, and integration help are handled promptly.
44
47
  - **Reduced vendor risk.** Relying on a single plugin provider for all your needs is a liability. Choosing specialized, independent maintainers keeps your stack resilient.
45
48
 
49
+ ## MCP Server
50
+
51
+ `@ebarooni/capacitor-calendar` ships an official [MCP](https://modelcontextprotocol.io) server so AI coding assistants can work with the plugin accurately.
52
+
53
+ ```bash
54
+ docker run --rm -d --name capacitor-calendar-mcp -p 8080:8080 ghcr.io/ebarooni/capacitor-calendar-mcp:1.0.0
55
+ ```
56
+
57
+ See [`mcp/README.md`](mcp/README.md) for client configuration and full details.
58
+
46
59
  ## Table of Contents
47
60
 
48
61
  - [Installation](#installation)
@@ -65,7 +78,7 @@ npx cap sync
65
78
 
66
79
  ## Demo
67
80
 
68
- | iOS 26 | Android 16 |
81
+ | iOS 26 | Android 17 |
69
82
  | :-----------------------------: | :---------------------------------: |
70
83
  | ![](./assets/demo/ios-demo.gif) | ![](./assets/demo/android-demo.gif) |
71
84
 
@@ -154,7 +167,7 @@ Use the system calendar UI to let users create or edit events:
154
167
  await CapacitorCalendar.createEventWithPrompt({
155
168
  title: 'Planning session',
156
169
  location: 'Office',
157
- startDate: Date.now() + 24 * 60 * 60 * 1000, // tomorrow
170
+ startDate: Date.now() + 24 * 60 * 60 * 1000,
158
171
  endDate: Date.now() + 25 * 60 * 60 * 1000,
159
172
  });
160
173
  ```
@@ -245,6 +258,7 @@ See [CHANGELOG.md](CHANGELOG.md) for the latest updates and release history.
245
258
  * [`deleteCalendar(...)`](#deletecalendar)
246
259
  * [`modifyCalendar(...)`](#modifycalendar)
247
260
  * [`createRemindersList(...)`](#createreminderslist)
261
+ * [`deleteRemindersList(...)`](#deletereminderslist)
248
262
  * [`fetchAllRemindersSources()`](#fetchallreminderssources)
249
263
  * [`openReminders()`](#openreminders)
250
264
  * [`getDefaultRemindersList()`](#getdefaultreminderslist)
@@ -256,6 +270,7 @@ See [CHANGELOG.md](CHANGELOG.md) for the latest updates and release history.
256
270
  * [`getReminderById(...)`](#getreminderbyid)
257
271
  * [`getRemindersFromLists(...)`](#getremindersfromlists)
258
272
  * [`deleteReminderWithPrompt(...)`](#deletereminderwithprompt)
273
+ * [`updateRemindersList(...)`](#updatereminderslist)
259
274
  * [Interfaces](#interfaces)
260
275
  * [Type Aliases](#type-aliases)
261
276
  * [Enums](#enums)
@@ -582,7 +597,7 @@ Retrieves the events within a date range.
582
597
  commit() => Promise<void>
583
598
  ```
584
599
 
585
- Save the changes to the calendar.
600
+ Saves pending calendar changes.
586
601
 
587
602
  **Since:** 7.1.0
588
603
 
@@ -762,6 +777,25 @@ Creates a new reminders list.
762
777
  --------------------
763
778
 
764
779
 
780
+ ### deleteRemindersList(...)
781
+
782
+ ```typescript
783
+ deleteRemindersList(options: DeleteRemindersListOptions) => Promise<void>
784
+ ```
785
+
786
+ Deletes a reminders list.
787
+
788
+ | Param | Type |
789
+ | ------------- | --------------------------------------------------------------------------------- |
790
+ | **`options`** | <code><a href="#deletereminderslistoptions">DeleteRemindersListOptions</a></code> |
791
+
792
+ **Since:** 8.2.0
793
+
794
+ **Platform:** iOS
795
+
796
+ --------------------
797
+
798
+
765
799
  ### fetchAllRemindersSources()
766
800
 
767
801
  ```typescript
@@ -971,6 +1005,27 @@ Opens a dialog to delete a reminder.
971
1005
  --------------------
972
1006
 
973
1007
 
1008
+ ### updateRemindersList(...)
1009
+
1010
+ ```typescript
1011
+ updateRemindersList(options: UpdateRemindersListOptions) => Promise<UpdateRemindersListResult>
1012
+ ```
1013
+
1014
+ Update a reminders list with options.
1015
+
1016
+ | Param | Type |
1017
+ | ------------- | --------------------------------------------------------------------------------- |
1018
+ | **`options`** | <code><a href="#updatereminderslistoptions">UpdateRemindersListOptions</a></code> |
1019
+
1020
+ **Returns:** <code>Promise&lt;<a href="#updatereminderslistresult">UpdateRemindersListResult</a>&gt;</code>
1021
+
1022
+ **Since:** 8.2.0
1023
+
1024
+ **Platform:** iOS
1025
+
1026
+ --------------------
1027
+
1028
+
974
1029
  ### Interfaces
975
1030
 
976
1031
 
@@ -1089,30 +1144,35 @@ Opens a dialog to delete a reminder.
1089
1144
 
1090
1145
  #### DeleteEventsByIdOptions
1091
1146
 
1092
- | Prop | Type | Description | Default | Since | Platform |
1093
- | ---------- | ----------------------------------------------- | --------------------- | --------------------------------- | ----- | -------- |
1094
- | **`ids`** | <code>string[]</code> | | | 7.1.0 | |
1095
- | **`span`** | <code><a href="#eventspan">EventSpan</a></code> | The span of deletion. | <code>EventSpan.THIS_EVENT</code> | | iOS |
1147
+ | Prop | Type | Description | Default | Since | Platform |
1148
+ | ------------ | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----- | ------------ |
1149
+ | **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually. | <code>true</code> | 8.3.0 | iOS |
1150
+ | **`ids`** | <code>string[]</code> | | | 7.1.0 | |
1151
+ | **`span`** | <code><a href="#eventspan">EventSpan</a></code> | How much of a recurring series to delete. On Android, `THIS_EVENT` cannot target a single recurring occurrence here — use `deleteEvent` with `instanceDate`. Those ids are reported in `failed`. | <code>EventSpan.THIS_EVENT</code> | 7.1.0 | Android, iOS |
1096
1152
 
1097
1153
 
1098
1154
  #### DeleteEventOptions
1099
1155
 
1100
- | Prop | Type | Description | Default | Since | Platform |
1101
- | ---------- | ----------------------------------------------- | --------------------- | --------------------------------- | ----- | -------- |
1102
- | **`id`** | <code>string</code> | | | 7.1.0 | |
1103
- | **`span`** | <code><a href="#eventspan">EventSpan</a></code> | The span of deletion. | <code>EventSpan.THIS_EVENT</code> | | iOS |
1156
+ | Prop | Type | Description | Default | Since | Platform |
1157
+ | ------------------ | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----- | ------------ |
1158
+ | **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually. | <code>true</code> | 8.3.0 | iOS |
1159
+ | **`id`** | <code>string</code> | The ID of the event to delete. | | 7.1.0 | Android, iOS |
1160
+ | **`instanceDate`** | <code>number</code> | The start time of the occurrence to delete, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. On Android, required for `THIS_EVENT` on recurring events. If omitted with `THIS_AND_FUTURE_EVENTS`, the whole series is deleted. | | 8.3.0 | Android |
1161
+ | **`span`** | <code><a href="#eventspan">EventSpan</a></code> | How much of a recurring series to delete. | <code>EventSpan.THIS_EVENT</code> | 7.1.0 | Android, iOS |
1104
1162
 
1105
1163
 
1106
1164
  #### DeleteEventWithPromptOptions
1107
1165
 
1108
- | Prop | Type | Description | Default | Since | Platform |
1109
- | ----------------------- | ----------------------------------------------- | ----------------------------------- | --------------------------------- | ----- | ------------ |
1110
- | **`id`** | <code>string</code> | | | 7.1.0 | |
1111
- | **`span`** | <code><a href="#eventspan">EventSpan</a></code> | The span of deletion. | <code>EventSpan.THIS_EVENT</code> | | iOS |
1112
- | **`title`** | <code>string</code> | Title of the dialog. | | 7.1.0 | Android, iOS |
1113
- | **`message`** | <code>string</code> | Message of the dialog. | | 7.1.0 | Android, iOS |
1114
- | **`confirmButtonText`** | <code>string</code> | Text to show on the confirm button. | <code>'Delete'</code> | 7.1.0 | Android, iOS |
1115
- | **`cancelButtonText`** | <code>string</code> | Text to show on the cancel button. | <code>'Cancel'</code> | 7.1.0 | Android, iOS |
1166
+ | Prop | Type | Description | Default | Since | Platform |
1167
+ | ----------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----- | ------------ |
1168
+ | **`cancelButtonText`** | <code>string</code> | Text to show on the cancel button. | <code>'Cancel'</code> | 7.1.0 | Android, iOS |
1169
+ | **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually. | <code>true</code> | 8.3.0 | iOS |
1170
+ | **`confirmButtonText`** | <code>string</code> | Text to show on the confirm button. | <code>'Delete'</code> | 7.1.0 | Android, iOS |
1171
+ | **`id`** | <code>string</code> | The ID of the event to delete. | | 7.1.0 | Android, iOS |
1172
+ | **`instanceDate`** | <code>number</code> | The start time of the occurrence to delete, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. On Android, required for `THIS_EVENT` on recurring events. If omitted with `THIS_AND_FUTURE_EVENTS`, the whole series is deleted. | | 8.3.0 | Android |
1173
+ | **`message`** | <code>string</code> | Message of the dialog. | | 7.1.0 | Android, iOS |
1174
+ | **`span`** | <code><a href="#eventspan">EventSpan</a></code> | How much of a recurring series to delete. | <code>EventSpan.THIS_EVENT</code> | 7.1.0 | Android, iOS |
1175
+ | **`title`** | <code>string</code> | Title of the dialog. | | 7.1.0 | Android, iOS |
1116
1176
 
1117
1177
 
1118
1178
  #### CalendarEvent
@@ -1238,6 +1298,14 @@ Opens a dialog to delete a reminder.
1238
1298
  | **`title`** | <code>string</code> | The title of the list. | | 8.1.0 | iOS |
1239
1299
 
1240
1300
 
1301
+ #### DeleteRemindersListOptions
1302
+
1303
+ | Prop | Type | Description | Default | Since | Platform |
1304
+ | ------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- | -------- |
1305
+ | **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually. | <code>true</code> | 8.2.0 | iOS |
1306
+ | **`id`** | <code>string</code> | Identifier of the reminders list to delete. | | 8.2.0 | iOS |
1307
+
1308
+
1241
1309
  #### CreateReminderOptions
1242
1310
 
1243
1311
  | Prop | Type | Description | Since |
@@ -1350,6 +1418,23 @@ Opens a dialog to delete a reminder.
1350
1418
  | **`cancelButtonText`** | <code>string</code> | Text to show on the cancel button. | <code>'Cancel'</code> | 7.2.0 |
1351
1419
 
1352
1420
 
1421
+ #### UpdateRemindersListResult
1422
+
1423
+ | Prop | Type | Description | Since | Platform |
1424
+ | -------- | ------------------- | ----------------------------------------- | ----- | -------- |
1425
+ | **`id`** | <code>string</code> | Identifier of the updated reminders list. | 8.2.0 | iOS |
1426
+
1427
+
1428
+ #### UpdateRemindersListOptions
1429
+
1430
+ | Prop | Type | Description | Default | Since | Platform |
1431
+ | ------------ | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- | -------- |
1432
+ | **`color`** | <code>'blue' \| 'brown' \| 'gray' \| 'green' \| 'indigo' \| 'orange' \| 'pink' \| 'purple' \| 'red' \| 'teal' \| 'yellow'</code> | The new color of the list. If omitted, the color is left unchanged. | | 8.1.0 | iOS |
1433
+ | **`commit`** | <code>boolean</code> | Whether to save the update to the event store immediately. Pass `false` to batch multiple changes and commit them together using `eventStore.commit()`, which is more efficient than committing each save individually. | <code>true</code> | 8.2.0 | iOS |
1434
+ | **`id`** | <code>string</code> | The identifier of the list to update. | | 8.2.0 | iOS |
1435
+ | **`title`** | <code>string</code> | The new title of the list. If omitted, the title is left unchanged. | | 8.2.0 | iOS |
1436
+
1437
+
1353
1438
  ### Type Aliases
1354
1439
 
1355
1440
 
@@ -1416,10 +1501,10 @@ Construct a type with a set of properties K of type T
1416
1501
 
1417
1502
  #### EventSpan
1418
1503
 
1419
- | Members | Since |
1420
- | ---------------------------- | ----- |
1421
- | **`THIS_EVENT`** | 7.1.0 |
1422
- | **`THIS_AND_FUTURE_EVENTS`** | 7.1.0 |
1504
+ | Members | Description | Since |
1505
+ | ---------------------------- | --------------------------------------------------------------- | ----- |
1506
+ | **`THIS_EVENT`** | Only the identified event or occurrence. | 7.1.0 |
1507
+ | **`THIS_AND_FUTURE_EVENTS`** | The identified occurrence and future occurrences in the series. | 7.1.0 |
1423
1508
 
1424
1509
 
1425
1510
  #### EventStatus
@@ -85,6 +85,11 @@ class CapacitorCalendarPlugin : Plugin() {
85
85
  call.unimplemented(PluginError.Unimplemented(::createRemindersList.name).message)
86
86
  }
87
87
 
88
+ @PluginMethod
89
+ fun deleteRemindersList(call: PluginCall) {
90
+ call.unimplemented(PluginError.Unimplemented(::deleteRemindersList.name).message)
91
+ }
92
+
88
93
  @PluginMethod
89
94
  fun requestPermission(call: PluginCall) {
90
95
  try {
@@ -445,4 +450,9 @@ class CapacitorCalendarPlugin : Plugin() {
445
450
  fun deleteReminderWithPrompt(call: PluginCall) {
446
451
  call.unimplemented(PluginError.Unimplemented(::deleteReminderWithPrompt.name).message)
447
452
  }
453
+
454
+ @PluginMethod
455
+ fun updateRemindersList(call: PluginCall) {
456
+ call.unimplemented(PluginError.Unimplemented(::updateRemindersList.name).message)
457
+ }
448
458
  }
@@ -13,6 +13,10 @@ sealed class PluginError(
13
13
 
14
14
  data object MissingId : PluginError("Event ID must be provided.")
15
15
 
16
+ data object InstanceDateMissing : PluginError(
17
+ "Instance date must be provided for this span on recurring events.",
18
+ )
19
+
16
20
  data object TitleMissing : PluginError("Title must be provided.")
17
21
 
18
22
  data object FailedToRetrieveEventId : PluginError("Failed to retrieve event ID.")
@@ -201,10 +201,18 @@ class CapacitorCalendar(
201
201
  val cr = plugin.context.contentResolver
202
202
  val result = DeleteEventsByIdResult()
203
203
  input.ids.forEach { id ->
204
- val deleted = ImplementationHelper.deleteEvent(cr, id)
205
- if (deleted) {
206
- result.deleted(id)
207
- } else {
204
+ try {
205
+ if (ImplementationHelper.requiresInstanceDateForDelete(cr, id, input.span)) {
206
+ result.failed(id)
207
+ return@forEach
208
+ }
209
+ val deleted = ImplementationHelper.deleteEvent(cr, id, input.span, null)
210
+ if (deleted) {
211
+ result.deleted(id)
212
+ } else {
213
+ result.failed(id)
214
+ }
215
+ } catch (_: Exception) {
208
216
  result.failed(id)
209
217
  }
210
218
  }
@@ -213,7 +221,13 @@ class CapacitorCalendar(
213
221
 
214
222
  fun deleteEvent(input: DeleteEventInput) {
215
223
  val cr = plugin.context.contentResolver
216
- val deleted = ImplementationHelper.deleteEvent(cr, input.id)
224
+ ImplementationHelper.ensureInstanceDatePresentIfRequired(
225
+ cr,
226
+ input.id,
227
+ input.span,
228
+ input.instanceDate,
229
+ )
230
+ val deleted = ImplementationHelper.deleteEvent(cr, input.id, input.span, input.instanceDate)
217
231
  if (!deleted) {
218
232
  throw PluginError.FailedToDelete
219
233
  }
@@ -224,6 +238,12 @@ class CapacitorCalendar(
224
238
  onComplete: (DeleteEventWithPromptResult) -> Unit,
225
239
  ) {
226
240
  val cr = plugin.context.contentResolver
241
+ ImplementationHelper.ensureInstanceDatePresentIfRequired(
242
+ cr,
243
+ input.id,
244
+ input.span,
245
+ input.instanceDate,
246
+ )
227
247
  val builder =
228
248
  AlertDialog
229
249
  .Builder(plugin.context)
@@ -234,7 +254,10 @@ class CapacitorCalendar(
234
254
  val result = DeleteEventWithPromptResult(false)
235
255
  onComplete(result)
236
256
  }.setPositiveButton(input.confirmButtonText) { _, _ ->
237
- val result = DeleteEventWithPromptResult(ImplementationHelper.deleteEvent(cr, input.id))
257
+ val result =
258
+ DeleteEventWithPromptResult(
259
+ ImplementationHelper.deleteEvent(cr, input.id, input.span, input.instanceDate),
260
+ )
238
261
  onComplete(result)
239
262
  }
240
263
 
@@ -0,0 +1,8 @@
1
+ package dev.barooni.capacitor.calendar.models.data
2
+
3
+ data class EventDeleteInfo(
4
+ val dtStart: Long?,
5
+ val originalId: Long?,
6
+ val originalInstanceTime: Long?,
7
+ val rrule: String?,
8
+ )
@@ -0,0 +1,13 @@
1
+ package dev.barooni.capacitor.calendar.models.enums
2
+
3
+ enum class EventSpan(
4
+ val value: Int,
5
+ ) {
6
+ THIS_EVENT(0),
7
+ THIS_AND_FUTURE_EVENTS(1),
8
+ ;
9
+
10
+ companion object {
11
+ fun fromInt(value: Int): EventSpan? = entries.find { it.value == value }
12
+ }
13
+ }
@@ -2,9 +2,12 @@ package dev.barooni.capacitor.calendar.models.inputs
2
2
 
3
3
  import com.getcapacitor.PluginCall
4
4
  import dev.barooni.capacitor.calendar.PluginError
5
+ import dev.barooni.capacitor.calendar.models.enums.EventSpan
5
6
 
6
7
  data class DeleteEventInput(
7
8
  private val call: PluginCall,
8
9
  ) {
9
- val id = call.getString("id")?.toLong() ?: throw PluginError.MissingId
10
+ val id = call.getString("id")?.toLongOrNull() ?: throw PluginError.MissingId
11
+ val instanceDate: Long? = call.getLong("instanceDate")
12
+ val span: EventSpan = call.getInt("span")?.let { EventSpan.fromInt(it) } ?: EventSpan.THIS_EVENT
10
13
  }
@@ -2,13 +2,16 @@ package dev.barooni.capacitor.calendar.models.inputs
2
2
 
3
3
  import com.getcapacitor.PluginCall
4
4
  import dev.barooni.capacitor.calendar.PluginError
5
+ import dev.barooni.capacitor.calendar.models.enums.EventSpan
5
6
 
6
7
  data class DeleteEventWithPromptInput(
7
8
  private val call: PluginCall,
8
9
  ) {
9
- val id: Long = call.getString("id")?.toLong() ?: throw PluginError.MissingId
10
+ val id: Long = call.getString("id")?.toLongOrNull() ?: throw PluginError.MissingId
10
11
  val title: String = call.getString("title") ?: throw PluginError.TitleMissing
11
12
  val message: String = call.getString("message") ?: throw PluginError.MessageMissing
12
13
  val confirmButtonText: String = call.getString("confirmButtonText") ?: "Delete"
13
14
  val cancelButtonText: String = call.getString("cancelButtonText") ?: "Cancel"
15
+ val instanceDate: Long? = call.getLong("instanceDate")
16
+ val span: EventSpan = call.getInt("span")?.let { EventSpan.fromInt(it) } ?: EventSpan.THIS_EVENT
14
17
  }
@@ -2,10 +2,12 @@ package dev.barooni.capacitor.calendar.models.inputs
2
2
 
3
3
  import com.getcapacitor.PluginCall
4
4
  import dev.barooni.capacitor.calendar.PluginError
5
+ import dev.barooni.capacitor.calendar.models.enums.EventSpan
5
6
  import dev.barooni.capacitor.calendar.utils.ImplementationHelper
6
7
 
7
8
  data class DeleteEventsByIdInput(
8
9
  private val call: PluginCall,
9
10
  ) {
10
11
  var ids = call.getArray("ids")?.let { ImplementationHelper.jsArrayToLongArray(it) } ?: throw PluginError.MissingId
12
+ val span: EventSpan = call.getInt("span")?.let { EventSpan.fromInt(it) } ?: EventSpan.THIS_EVENT
11
13
  }