@ebarooni/capacitor-calendar 7.1.0 → 8.0.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 (149) hide show
  1. package/EbarooniCapacitorCalendar.podspec +2 -2
  2. package/Package.swift +4 -4
  3. package/README.md +238 -162
  4. package/android/build.gradle +20 -18
  5. package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +17 -0
  6. package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +2 -0
  7. package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +105 -61
  8. package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventRecurrenceRule.kt +135 -0
  9. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventInput.kt +1 -0
  10. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventWithPromptInput.kt +5 -0
  11. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyCalendarInput.kt +13 -0
  12. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEvent.kt +2 -0
  13. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEventWithPromptInput.kt +3 -0
  14. package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +48 -4
  15. package/dist/docs.json +792 -330
  16. package/dist/esm/definitions.d.ts +5 -5
  17. package/dist/esm/definitions.js.map +1 -1
  18. package/dist/esm/index.d.ts +47 -45
  19. package/dist/esm/index.js +16 -17
  20. package/dist/esm/index.js.map +1 -1
  21. package/dist/esm/schemas/enums/attendee-role.js.map +1 -1
  22. package/dist/esm/schemas/enums/attendee-status.js.map +1 -1
  23. package/dist/esm/schemas/enums/attendee-type.js.map +1 -1
  24. package/dist/esm/schemas/enums/calendar-permission-scope.js.map +1 -1
  25. package/dist/esm/schemas/enums/event-status.js.map +1 -1
  26. package/dist/esm/schemas/interfaces/calendar-event.d.ts +7 -5
  27. package/dist/esm/schemas/interfaces/calendar-event.js.map +1 -1
  28. package/dist/esm/schemas/interfaces/calendar-source.d.ts +1 -1
  29. package/dist/esm/schemas/interfaces/calendar-source.js.map +1 -1
  30. package/dist/esm/schemas/interfaces/calendar.d.ts +2 -2
  31. package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
  32. package/dist/esm/schemas/interfaces/create-event-options.d.ts +63 -46
  33. package/dist/esm/schemas/interfaces/create-event-options.js.map +1 -1
  34. package/dist/esm/schemas/interfaces/create-event-with-prompt-options.d.ts +42 -31
  35. package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js.map +1 -1
  36. package/dist/esm/schemas/interfaces/create-reminder-options.d.ts +10 -1
  37. package/dist/esm/schemas/interfaces/create-reminder-options.js.map +1 -1
  38. package/dist/esm/schemas/interfaces/delete-event-options.d.ts +1 -1
  39. package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
  40. package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +1 -1
  41. package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
  42. package/dist/esm/schemas/interfaces/delete-events-by-id-options.d.ts +1 -1
  43. package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -1
  44. package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.d.ts +35 -0
  45. package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.js +2 -0
  46. package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.js.map +1 -0
  47. package/dist/esm/schemas/interfaces/event-recurrence-rule.d.ts +96 -0
  48. package/dist/esm/schemas/interfaces/event-recurrence-rule.js +2 -0
  49. package/dist/esm/schemas/interfaces/event-recurrence-rule.js.map +1 -0
  50. package/dist/esm/schemas/interfaces/modify-calendar-options.d.ts +21 -0
  51. package/dist/esm/schemas/interfaces/modify-calendar-options.js +2 -0
  52. package/dist/esm/schemas/interfaces/modify-calendar-options.js.map +1 -0
  53. package/dist/esm/schemas/interfaces/modify-event-options.d.ts +61 -44
  54. package/dist/esm/schemas/interfaces/modify-event-options.js.map +1 -1
  55. package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.d.ts +1 -1
  56. package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -1
  57. package/dist/esm/schemas/interfaces/modify-reminder-options.d.ts +12 -1
  58. package/dist/esm/schemas/interfaces/modify-reminder-options.js.map +1 -1
  59. package/dist/esm/schemas/interfaces/recurrence-rule.d.ts +1 -1
  60. package/dist/esm/schemas/interfaces/recurrence-rule.js.map +1 -1
  61. package/dist/esm/schemas/interfaces/reminder-recurrence-rule.d.ts +1 -1
  62. package/dist/esm/schemas/interfaces/reminder-recurrence-rule.js.map +1 -1
  63. package/dist/esm/schemas/interfaces/reminder.d.ts +1 -1
  64. package/dist/esm/schemas/interfaces/reminder.js.map +1 -1
  65. package/dist/esm/schemas/interfaces/reminders-list.d.ts +2 -2
  66. package/dist/esm/schemas/interfaces/reminders-list.js.map +1 -1
  67. package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.d.ts +1 -1
  68. package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.js.map +1 -1
  69. package/dist/esm/schemas/types/event-edit-action.d.ts +1 -1
  70. package/dist/esm/schemas/types/event-edit-action.js.map +1 -1
  71. package/dist/esm/schemas/types/recurrence-frequency.d.ts +4 -0
  72. package/dist/esm/schemas/types/recurrence-frequency.js +2 -0
  73. package/dist/esm/schemas/types/recurrence-frequency.js.map +1 -0
  74. package/dist/esm/sub-definitions/calendar-access.d.ts +4 -4
  75. package/dist/esm/sub-definitions/calendar-access.js.map +1 -1
  76. package/dist/esm/sub-definitions/calendar-operations.d.ts +14 -6
  77. package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
  78. package/dist/esm/sub-definitions/event-operations.d.ts +10 -10
  79. package/dist/esm/sub-definitions/event-operations.js.map +1 -1
  80. package/dist/esm/sub-definitions/reminders-access.d.ts +1 -1
  81. package/dist/esm/sub-definitions/reminders-access.js.map +1 -1
  82. package/dist/esm/sub-definitions/reminders-operations.d.ts +19 -9
  83. package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
  84. package/dist/esm/web.d.ts +37 -30
  85. package/dist/esm/web.js +7 -1
  86. package/dist/esm/web.js.map +1 -1
  87. package/dist/plugin.cjs.js +7 -24
  88. package/dist/plugin.cjs.js.map +1 -1
  89. package/dist/plugin.js +7 -24
  90. package/dist/plugin.js.map +1 -1
  91. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/CapacitorCalendarPlugin.swift +110 -65
  92. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Implementation/CapacitorCalendar.swift +83 -59
  93. package/ios/Plugin/Info.plist +24 -0
  94. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateEventInput.swift +25 -21
  95. package/ios/Plugin/Models/Inputs/CreateEventWithPromptInput.swift +171 -0
  96. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateReminderInput.swift +2 -2
  97. package/ios/Plugin/Models/Inputs/DeleteReminderWithPromptInput.swift +46 -0
  98. package/ios/Plugin/Models/Inputs/ModifyCalendarInput.swift +32 -0
  99. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventInput.swift +63 -41
  100. package/ios/Plugin/Models/Structs/RecurrenceInput.swift +31 -0
  101. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginConfig.swift +3 -1
  102. package/package.json +37 -45
  103. package/dist/esm/schemas/enums/recurrence-frequency.d.ts +0 -21
  104. package/dist/esm/schemas/enums/recurrence-frequency.js +0 -23
  105. package/dist/esm/schemas/enums/recurrence-frequency.js.map +0 -1
  106. package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateEventWithPromptInput.swift +0 -89
  107. package/ios/Tests/CapacitorCalendarPluginTests/CapacitorCalendarPluginTests.swift +0 -15
  108. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CAPPermissionState.swift +0 -0
  109. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CalendarPermissionScope.swift +0 -0
  110. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/EventEditAction.swift +0 -0
  111. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CheckPermissionInput.swift +0 -0
  112. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateCalendarInput.swift +0 -0
  113. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteCalendarInput.swift +0 -0
  114. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventInput.swift +0 -0
  115. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventWithPromptInput.swift +0 -0
  116. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventsByIdInput.swift +0 -0
  117. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteReminderInput.swift +0 -0
  118. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteRemindersByIdInput.swift +0 -0
  119. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetReminderByIdInput.swift +0 -0
  120. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetRemindersFromListsInput.swift +0 -0
  121. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ListEventsInRangeInput.swift +0 -0
  122. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventWithPromptInput.swift +0 -0
  123. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyReminderInput.swift +0 -0
  124. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/OpenCalendarInput.swift +0 -0
  125. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/RequestPermissionInput.swift +0 -0
  126. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/SelectCalendarsWithPromptInput.swift +0 -0
  127. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckAllPermissionsResult.swift +0 -0
  128. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckPermissionResult.swift +0 -0
  129. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateCalendarResult.swift +0 -0
  130. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventResult.swift +0 -0
  131. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventWithPromptResult.swift +0 -0
  132. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateReminderResult.swift +0 -0
  133. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventWithPromptResult.swift +0 -0
  134. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventsByIdResult.swift +0 -0
  135. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteRemindersByIdResult.swift +0 -0
  136. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/FetchAllCalendarSourcesResult.swift +0 -0
  137. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetDefaultCalendarResult.swift +0 -0
  138. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetReminderByIdResult.swift +0 -0
  139. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetRemindersFromListsResult.swift +0 -0
  140. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ListCalendarsResult.swift +0 -0
  141. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ListEventsInRangeResult.swift +0 -0
  142. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ModifyEventWithPromptResult.swift +0 -0
  143. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestAllPermissionsResult.swift +0 -0
  144. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestPermissionResult.swift +0 -0
  145. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/SelectCalendarsWithPromptResult.swift +0 -0
  146. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Templates/JSResult.swift +0 -0
  147. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginError.swift +0 -0
  148. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/ImplementationHelper.swift +0 -0
  149. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/UIColorFromHexExtension.swift +0 -0
@@ -7,55 +7,59 @@ struct CreateEventInput {
7
7
  private let commit: Bool
8
8
 
9
9
  init(call: CAPPluginCall) throws {
10
+ self.commit = call.getBool("commit", true)
10
11
  self.input = CreateEventWithPromptInput(call: call)
11
12
  guard let title = call.getString("title") else {
12
13
  throw PluginError.titleMissing
13
14
  }
14
15
  self.title = title
15
- self.commit = call.getBool("commit", true)
16
- }
17
-
18
- func getTitle() -> String {
19
- return title
20
- }
21
-
22
- func getIsAllDay() -> Bool {
23
- return input.getIsAllDay()
24
16
  }
25
17
 
26
18
  func getAlerts() -> [EKAlarm] {
27
19
  return input.getAlerts()
28
20
  }
29
21
 
22
+ func getAvailability() -> EKEventAvailability? {
23
+ return input.getAvailability()
24
+ }
25
+
30
26
  func getCalendar(from eventStore: EKEventStore) -> EKCalendar? {
31
27
  return input.getCalendar(from: eventStore)
32
28
  }
33
29
 
34
- func getLocation() -> String? {
35
- return input.getLocation()
30
+ func getCommit() -> Bool {
31
+ return commit
36
32
  }
37
33
 
38
- func getStartDate() -> Date? {
39
- return input.getStartDate()
34
+ func getDescription() -> String? {
35
+ return input.getDescription()
40
36
  }
41
37
 
42
38
  func getEndDate() -> Date? {
43
39
  return input.getEndDate()
44
40
  }
45
41
 
46
- func getUrl() -> URL? {
47
- return input.getUrl()
42
+ func getIsAllDay() -> Bool {
43
+ return input.getIsAllDay()
48
44
  }
49
45
 
50
- func getDescription() -> String? {
51
- return input.getDescription()
46
+ func getLocation() -> String? {
47
+ return input.getLocation()
52
48
  }
53
49
 
54
- func getAvailability() -> EKEventAvailability? {
55
- return input.getAvailability()
50
+ func getRecurrenceRule() -> [EKRecurrenceRule] {
51
+ return input.getRecurrenceRule()
56
52
  }
57
53
 
58
- func getCommit() -> Bool {
59
- return commit
54
+ func getStartDate() -> Date? {
55
+ return input.getStartDate()
56
+ }
57
+
58
+ func getTitle() -> String {
59
+ return title
60
+ }
61
+
62
+ func getUrl() -> URL? {
63
+ return input.getUrl()
60
64
  }
61
65
  }
@@ -0,0 +1,171 @@
1
+ import Capacitor
2
+ import EventKit
3
+
4
+ struct CreateEventWithPromptInput {
5
+ private var alerts: [Double]
6
+ private var availability: EKEventAvailability?
7
+ private var calendarId: String?
8
+ private var description: String?
9
+ private var endDate: Double?
10
+ private let isAllDay: Bool
11
+ private var location: String?
12
+ private let recurrence: RecurrenceInput?
13
+ private var startDate: Double?
14
+ private let title: String
15
+ private var url: String?
16
+
17
+ init(call: CAPPluginCall) {
18
+ if let alerts = call.getArray("alerts", []) as? [Double] {
19
+ self.alerts = alerts
20
+ } else {
21
+ self.alerts = []
22
+ }
23
+ if let availability = call.getInt("availability") {
24
+ self.availability = EKEventAvailability(rawValue: availability)
25
+ }
26
+ if let calendarId = call.getString("calendarId") {
27
+ self.calendarId = calendarId
28
+ }
29
+ if let description = call.getString("description") {
30
+ self.description = description
31
+ }
32
+ if let endDate = call.getDouble("endDate") as Double? {
33
+ self.endDate = endDate
34
+ }
35
+ self.isAllDay = call.getBool("isAllDay", false)
36
+ if let location = call.getString("location") {
37
+ self.location = location
38
+ }
39
+ self.recurrence = CreateEventWithPromptInput.getRecurrence(from: call)
40
+ if let startDate = call.getDouble("startDate") as Double? {
41
+ self.startDate = startDate
42
+ }
43
+ self.title = call.getString("title", "")
44
+ if let url = call.getString("url") {
45
+ self.url = url
46
+ }
47
+ }
48
+
49
+ func getAlerts() -> [EKAlarm] {
50
+ return alerts.map { EKAlarm(relativeOffset: $0 * 60) }
51
+ }
52
+
53
+ func getAvailability() -> EKEventAvailability? {
54
+ return availability
55
+ }
56
+
57
+ func getCalendar(from eventStore: EKEventStore) -> EKCalendar? {
58
+ return ImplementationHelper.getCalendarFromId(eventStore: eventStore, calendarId: calendarId, fallback: true)
59
+ }
60
+
61
+ func getDescription() -> String? {
62
+ return description
63
+ }
64
+
65
+ func getEndDate() -> Date? {
66
+ guard let endDate = endDate else { return nil }
67
+ return ImplementationHelper.dateFromTimestamp(endDate)
68
+ }
69
+
70
+ func getIsAllDay() -> Bool {
71
+ return isAllDay
72
+ }
73
+
74
+ func getLocation() -> String? {
75
+ return location
76
+ }
77
+
78
+ func getRecurrenceRule() -> [EKRecurrenceRule] {
79
+ guard let recurrence = recurrence else {
80
+ return []
81
+ }
82
+
83
+ let rule = EKRecurrenceRule(
84
+ recurrenceWith: recurrence.frequency.toEKFrequency(),
85
+ interval: recurrence.interval,
86
+ daysOfTheWeek: recurrence.byWeekDay,
87
+ daysOfTheMonth: recurrence.byMonthDay,
88
+ monthsOfTheYear: recurrence.byMonth,
89
+ weeksOfTheYear: recurrence.weeksOfTheYear,
90
+ daysOfTheYear: recurrence.daysOfTheYear,
91
+ setPositions: nil,
92
+ end: recurrence.end
93
+ )
94
+
95
+ return [rule]
96
+ }
97
+
98
+ func getStartDate() -> Date? {
99
+ guard let startDate = startDate else { return nil }
100
+ return ImplementationHelper.dateFromTimestamp(startDate)
101
+ }
102
+
103
+ func getTitle() -> String {
104
+ return title
105
+ }
106
+
107
+ func getUrl() -> URL? {
108
+ guard let url = url else { return nil }
109
+ return URL(string: url)
110
+ }
111
+
112
+ static func getRecurrence(from call: CAPPluginCall) -> RecurrenceInput? {
113
+ if let recurrenceObject = call.getObject("recurrence") {
114
+ if let frequencyString = recurrenceObject["frequency"] as? String, let frequency = RecurrenceInput.Frequency(rawValue: frequencyString) {
115
+ let interval = recurrenceObject["interval"] as? Int ?? 1
116
+ let count = recurrenceObject["count"] as? Int
117
+
118
+ var endDate: Date?
119
+ if let endMs = recurrenceObject["end"] as? Double {
120
+ endDate = ImplementationHelper.dateFromTimestamp(endMs)
121
+ }
122
+
123
+ var end: EKRecurrenceEnd?
124
+ if let count = count {
125
+ end = EKRecurrenceEnd(occurrenceCount: count)
126
+ } else if let endDate = endDate {
127
+ end = EKRecurrenceEnd(end: endDate)
128
+ } else {
129
+ end = nil
130
+ }
131
+
132
+ var byWeekDay: [EKRecurrenceDayOfWeek]?
133
+ if let days = recurrenceObject["byWeekDay"] as? [Int] {
134
+ byWeekDay = days.compactMap { day in
135
+ switch day {
136
+ case 1: return EKRecurrenceDayOfWeek(.monday)
137
+ case 2: return EKRecurrenceDayOfWeek(.tuesday)
138
+ case 3: return EKRecurrenceDayOfWeek(.wednesday)
139
+ case 4: return EKRecurrenceDayOfWeek(.thursday)
140
+ case 5: return EKRecurrenceDayOfWeek(.friday)
141
+ case 6: return EKRecurrenceDayOfWeek(.saturday)
142
+ case 7: return EKRecurrenceDayOfWeek(.sunday)
143
+ default: return nil
144
+ }
145
+ }
146
+ }
147
+
148
+ let byMonthDay = (recurrenceObject["byMonthDay"] as? [Int])?.map { NSNumber(value: $0) }
149
+ let byMonth = (recurrenceObject["byMonth"] as? [Int])?.map { NSNumber(value: $0) }
150
+ let weeksOfTheYear = (recurrenceObject["weeksOfTheYear"] as? [Int])?.map { NSNumber(value: $0) }
151
+ let daysOfTheYear = (recurrenceObject["daysOfTheYear"] as? [Int])?.map { NSNumber(value: $0) }
152
+
153
+ return RecurrenceInput(
154
+ frequency: frequency,
155
+ interval: max(1, interval),
156
+ count: count,
157
+ end: end,
158
+ byWeekDay: byWeekDay,
159
+ byMonthDay: byMonthDay,
160
+ byMonth: byMonth,
161
+ weeksOfTheYear: weeksOfTheYear,
162
+ daysOfTheYear: daysOfTheYear
163
+ )
164
+ } else {
165
+ return nil
166
+ }
167
+ } else {
168
+ return nil
169
+ }
170
+ }
171
+ }
@@ -32,10 +32,10 @@ struct CreateReminderInput {
32
32
  self.url = call.getString("url")
33
33
  self.location = call.getString("location")
34
34
  if let recurrence = call.getObject("recurrence") {
35
- guard let frequency = recurrence["frequency"] as? Int else {
35
+ guard let frequency = recurrence["frequency"] as? String else {
36
36
  throw PluginError.missingFrequency
37
37
  }
38
- self.frequency = EKRecurrenceFrequency(rawValue: frequency)
38
+ self.frequency = RecurrenceInput.Frequency(rawValue: frequency)?.toEKFrequency()
39
39
  guard let interval = recurrence["interval"] as? Int else {
40
40
  throw PluginError.missingInterval
41
41
  }
@@ -0,0 +1,46 @@
1
+ import Capacitor
2
+
3
+ struct DeleteReminderWithPromptInput {
4
+ private let id: String
5
+ private let title: String
6
+ private let message: String
7
+ private let confirmButtonText: String
8
+ private let cancelButtonText: String
9
+
10
+ init(call: CAPPluginCall) throws {
11
+ guard let id = call.getString("id") else {
12
+ throw PluginError.idMissing
13
+ }
14
+ self.id = id
15
+ guard let title = call.getString("title") else {
16
+ throw PluginError.titleMissing
17
+ }
18
+ self.title = title
19
+ guard let message = call.getString("message") else {
20
+ throw PluginError.messageMissing
21
+ }
22
+ self.message = message
23
+ self.confirmButtonText = call.getString("confirmButtonText", "Delete")
24
+ self.cancelButtonText = call.getString("cancelButtonText", "Cancel")
25
+ }
26
+
27
+ func getId() -> String {
28
+ return id
29
+ }
30
+
31
+ func getTitle() -> String {
32
+ return title
33
+ }
34
+
35
+ func getMessage() -> String {
36
+ return message
37
+ }
38
+
39
+ func getConfirmButtonText() -> String {
40
+ return confirmButtonText
41
+ }
42
+
43
+ func getCancelButtonText() -> String {
44
+ return cancelButtonText
45
+ }
46
+ }
@@ -0,0 +1,32 @@
1
+ import Capacitor
2
+
3
+ struct ModifyCalendarInput {
4
+ private let id: String
5
+ private let title: String?
6
+ private let color: CGColor?
7
+
8
+ init(call: CAPPluginCall) throws {
9
+ guard let id = call.getString("id") else {
10
+ throw PluginError.idMissing
11
+ }
12
+ self.id = id
13
+ self.title = call.getString("title")
14
+ if let color = call.getString("color") {
15
+ self.color = try UIColor.fromHex(color).cgColor
16
+ } else {
17
+ self.color = nil
18
+ }
19
+ }
20
+
21
+ func getId() -> String {
22
+ return id
23
+ }
24
+
25
+ func getTitle() -> String? {
26
+ return title
27
+ }
28
+
29
+ func getColor() -> CGColor? {
30
+ return color
31
+ }
32
+ }
@@ -2,59 +2,73 @@ import Capacitor
2
2
  import EventKit
3
3
 
4
4
  struct ModifyEventInput {
5
- private let id: String
6
- private var title: String?
5
+ private var alerts: [Double]?
6
+ private var availability: EKEventAvailability?
7
7
  private var calendarId: String?
8
- private var location: String?
9
- private var startDate: Double?
8
+ private var description: String?
10
9
  private var endDate: Double?
10
+ private let id: String
11
11
  private var isAllDay: Bool?
12
- private var alerts: [Double]?
13
- private var url: String?
14
- private var description: String?
15
- private var availability: EKEventAvailability?
12
+ private var location: String?
13
+ private let recurrence: RecurrenceInput?
16
14
  private var span: EKSpan
15
+ private var startDate: Double?
16
+ private var title: String?
17
+ private var url: String?
17
18
 
18
19
  init(call: CAPPluginCall) throws {
19
- guard let id = call.getString("id") else {
20
- throw PluginError.idMissing
20
+ if let alerts = call.getArray("alerts") as? [Double] {
21
+ self.alerts = alerts
21
22
  }
22
- self.id = id
23
- if let title = call.getString("title") {
24
- self.title = title
23
+ if let availability = call.getInt("availability") {
24
+ self.availability = EKEventAvailability(rawValue: availability)
25
25
  }
26
26
  if let calendarId = call.getString("calendarId") {
27
27
  self.calendarId = calendarId
28
28
  }
29
- if let location = call.getString("location") {
30
- self.location = location
31
- }
32
- if let startDate = call.getDouble("startDate") as Double? {
33
- self.startDate = startDate
29
+ if let description = call.getString("description") {
30
+ self.description = description
34
31
  }
35
32
  if let endDate = call.getDouble("endDate") as Double? {
36
33
  self.endDate = endDate
37
34
  }
35
+ guard let id = call.getString("id") else {
36
+ throw PluginError.idMissing
37
+ }
38
+ self.id = id
38
39
  if let isAllDay = call.getBool("isAllDay") as Bool? {
39
40
  self.isAllDay = isAllDay
40
41
  }
41
- if let alerts = call.getArray("alerts") as? [Double] {
42
- self.alerts = alerts
43
- }
44
- if let url = call.getString("url") {
45
- self.url = url
46
- }
47
- if let description = call.getString("description") {
48
- self.description = description
49
- }
50
- if let availability = call.getInt("availability") {
51
- self.availability = EKEventAvailability(rawValue: availability)
42
+ if let location = call.getString("location") {
43
+ self.location = location
52
44
  }
45
+ self.recurrence = CreateEventWithPromptInput.getRecurrence(from: call)
53
46
  if let spanInt = call.getInt("span"), let span = EKSpan(rawValue: spanInt) {
54
47
  self.span = span
55
48
  } else {
56
49
  self.span = .thisEvent
57
50
  }
51
+ if let startDate = call.getDouble("startDate") as Double? {
52
+ self.startDate = startDate
53
+ }
54
+ if let title = call.getString("title") {
55
+ self.title = title
56
+ }
57
+ if let url = call.getString("url") {
58
+ self.url = url
59
+ }
60
+ }
61
+
62
+ func getAlerts() -> [EKAlarm]? {
63
+ if let alerts = self.alerts {
64
+ return alerts.map { EKAlarm(relativeOffset: $0 * 60) }
65
+ } else {
66
+ return nil
67
+ }
68
+ }
69
+
70
+ func getIsAllDay() -> Bool? {
71
+ return isAllDay
58
72
  }
59
73
 
60
74
  func getEvent(from eventStore: EKEventStore) throws -> EKEvent {
@@ -76,6 +90,26 @@ struct ModifyEventInput {
76
90
  return location
77
91
  }
78
92
 
93
+ func getRecurrenceRule() -> [EKRecurrenceRule] {
94
+ guard let recurrence = recurrence else {
95
+ return []
96
+ }
97
+
98
+ let rule = EKRecurrenceRule(
99
+ recurrenceWith: recurrence.frequency.toEKFrequency(),
100
+ interval: recurrence.interval,
101
+ daysOfTheWeek: recurrence.byWeekDay,
102
+ daysOfTheMonth: recurrence.byMonthDay,
103
+ monthsOfTheYear: recurrence.byMonth,
104
+ weeksOfTheYear: recurrence.weeksOfTheYear,
105
+ daysOfTheYear: recurrence.daysOfTheYear,
106
+ setPositions: nil,
107
+ end: recurrence.end
108
+ )
109
+
110
+ return [rule]
111
+ }
112
+
79
113
  func getStartDate() -> Date? {
80
114
  guard let startDate = startDate else { return nil }
81
115
  return ImplementationHelper.dateFromTimestamp(startDate)
@@ -86,18 +120,6 @@ struct ModifyEventInput {
86
120
  return ImplementationHelper.dateFromTimestamp(endDate)
87
121
  }
88
122
 
89
- func getIsAllDay() -> Bool? {
90
- return isAllDay
91
- }
92
-
93
- func getAlerts() -> [EKAlarm]? {
94
- if let alerts = self.alerts {
95
- return alerts.map { EKAlarm(relativeOffset: $0 * 60) }
96
- } else {
97
- return nil
98
- }
99
- }
100
-
101
123
  func getUrl() -> URL? {
102
124
  guard let url = url else { return nil }
103
125
  return URL(string: url)
@@ -0,0 +1,31 @@
1
+ import EventKit
2
+
3
+ struct RecurrenceInput {
4
+ enum Frequency: String {
5
+ case daily
6
+ case weekly
7
+ case monthly
8
+ case yearly
9
+
10
+ func toEKFrequency() -> EKRecurrenceFrequency {
11
+ switch self {
12
+ case .daily: return .daily
13
+ case .weekly: return .weekly
14
+ case .monthly: return .monthly
15
+ case .yearly: return .yearly
16
+ }
17
+ }
18
+ }
19
+
20
+ let frequency: Frequency
21
+ let interval: Int
22
+ let count: Int?
23
+ let end: EKRecurrenceEnd?
24
+
25
+ let byWeekDay: [EKRecurrenceDayOfWeek]?
26
+ let byMonthDay: [NSNumber]?
27
+ let byMonth: [NSNumber]?
28
+
29
+ let weeksOfTheYear: [NSNumber]?
30
+ let daysOfTheYear: [NSNumber]?
31
+ }
@@ -37,6 +37,8 @@ struct PluginConfig {
37
37
  CAPPluginMethod(name: "deleteReminder", returnType: CAPPluginReturnPromise),
38
38
  CAPPluginMethod(name: "getReminderById", returnType: CAPPluginReturnPromise),
39
39
  CAPPluginMethod(name: "deleteEvent", returnType: CAPPluginReturnPromise),
40
- CAPPluginMethod(name: "deleteEventWithPrompt", returnType: CAPPluginReturnPromise)
40
+ CAPPluginMethod(name: "deleteEventWithPrompt", returnType: CAPPluginReturnPromise),
41
+ CAPPluginMethod(name: "modifyCalendar", returnType: CAPPluginReturnPromise),
42
+ CAPPluginMethod(name: "deleteReminderWithPrompt", returnType: CAPPluginReturnPromise)
41
43
  ]
42
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebarooni/capacitor-calendar",
3
- "version": "7.1.0",
3
+ "version": "8.0.0",
4
4
  "description": "A capacitor plugin for managing calendar events on iOS and Android, with reminders support on iOS.",
5
5
  "author": "Ehsan Barooni",
6
6
  "license": "MIT",
@@ -21,9 +21,6 @@
21
21
  "eventkit",
22
22
  "ionic"
23
23
  ],
24
- "engines": {
25
- "node": ">=20.12.2"
26
- },
27
24
  "publishConfig": {
28
25
  "access": "public"
29
26
  },
@@ -35,72 +32,67 @@
35
32
  "dist/",
36
33
  "android/src/main/",
37
34
  "android/build.gradle",
38
- "ios/Sources",
39
- "ios/Tests",
35
+ "ios/Plugin",
40
36
  "Package.swift",
41
37
  "EbarooniCapacitorCalendar.podspec",
42
38
  "LICENSE"
43
39
  ],
44
40
  "scripts": {
41
+ "bootstrap:app": "npm run build && npm run install:app && npm run build:app && npm run sync:app",
45
42
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
46
43
  "build:app": "cd example-app && npm run build",
47
- "bootstrap:app": "npm run build && npm run install:app && npm run build:app && npm run sync:app",
48
44
  "clean": "rimraf ./dist",
45
+ "docgen": "docgen --api CapacitorCalendarPlugin --output-readme README.md --output-json dist/docs.json",
46
+ "eslint": "eslint . --ext ts",
47
+ "fmt": "npm run eslint -- --fix && npm run prettier:fix && npm run swiftlint -- --fix --format && npm run fmt:android",
48
+ "fmt:android": "npm run ktlint -- -F",
49
+ "install:app": "cd example-app && npm i",
50
+ "ktlint": "ktlint",
51
+ "lint": "npm run eslint && npm run prettier:check && npm run swiftlint -- lint && npm run lint:android",
52
+ "lint:android": "npm run ktlint",
53
+ "pod:install": "cd ios && pod install --repo-update",
54
+ "prepublishOnly": "npm run build",
49
55
  "prettier": "npx prettier",
50
56
  "prettier:check": "npm run prettier -- . --check",
51
57
  "prettier:fix": "npm run prettier -- . --write",
52
- "eslint": "npx eslint",
53
- "eslint:fix": "npm run eslint -- --fix",
54
- "fmt": "npm run fmt:web && npm run fmt:android && npm run fmt:ios",
55
- "fmt:android": "ktlint -F",
56
- "fmt:ios": "npx swiftlint --fix --format",
57
- "fmt:web": "npm run eslint:fix && npm run prettier:fix",
58
- "install:app": "cd example-app && npm i",
59
- "lint": "npm run lint:web && npm run lint:android && npm run lint:ios",
60
- "lint:android": "npx ktlint",
61
- "lint:ios": "npx swiftlint lint",
62
- "lint:web": "npm run eslint && npm run prettier:check",
63
58
  "spm:install": "swift package resolve",
59
+ "swiftlint": "node-swiftlint",
64
60
  "sync:app": "cd example-app && npx cap sync",
65
61
  "typedoc": "npx typedoc",
66
- "docgen": "docgen --api CapacitorCalendarPlugin --output-readme README.md --output-json dist/docs.json",
67
62
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
68
- "verify:ios": "xcodebuild build -scheme EbarooniCapacitorCalendar -destination generic/platform=iOS",
69
63
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
64
+ "verify:ios": "xcodebuild build -scheme EbarooniCapacitorCalendar -destination generic/platform=iOS",
70
65
  "verify:web": "npm run build",
71
- "prepublishOnly": "npm run build",
72
- "version:patch": "npm version patch --git-tag-version false",
66
+ "version:major": "npm version major --git-tag-version false",
73
67
  "version:minor": "npm version minor --git-tag-version false",
74
- "version:major": "npm version major --git-tag-version false"
68
+ "version:patch": "npm version patch --git-tag-version false"
75
69
  },
76
70
  "devDependencies": {
77
- "@capacitor/android": "^7.0.0",
78
- "@capacitor/core": "^7.0.0",
79
- "@capacitor/ios": "^7.0.0",
80
- "@ebarooni/capacitor-docgen": "^0.0.2",
81
- "@ebarooni/eslint-config": "^1.3.0",
82
- "@ebarooni/prettier-config": "^1.4.0",
83
- "@ebarooni/swiftlint-config": "^1.2.1",
84
- "@eslint/js": "^9.19.0",
85
- "@eslint/json": "^0.10.0",
86
- "@eslint/markdown": "^6.2.2",
87
- "angular-eslint": "^19.0.2",
88
- "eslint": "^9.19.0",
89
- "eslint-config-prettier": "^10.0.1",
90
- "eslint-plugin-promise": "^7.2.1",
71
+ "@capacitor/android": "^8.0.0",
72
+ "@capacitor/core": "^8.0.0",
73
+ "@capacitor/ios": "^8.0.0",
74
+ "@ebarooni/capacitor-docgen": "^0.1.0",
75
+ "@ionic/eslint-config": "0.4.0",
76
+ "@ionic/prettier-config": "^4.0.0",
77
+ "@ionic/swiftlint-config": "2.0.0",
78
+ "@types/node": "^25.0.3",
79
+ "eslint": "8.57.0",
91
80
  "prettier": "^3.3.2",
92
- "rimraf": "^6.0.1",
93
- "rollup": "^4.30.1",
81
+ "prettier-plugin-java": "^2.7.7",
82
+ "rimraf": "^6.1.0",
83
+ "rollup": "^4.53.3",
94
84
  "swiftlint": "^2.0.0",
95
- "typedoc": "^0.26.5",
96
- "typescript": "~4.8.4",
97
- "typescript-eslint": "^8.22.0"
85
+ "typedoc": "^0.28.15",
86
+ "typescript": "^5.9.3"
98
87
  },
99
88
  "peerDependencies": {
100
- "@capacitor/core": ">=7.0.0"
89
+ "@capacitor/core": ">=8.0.0"
90
+ },
91
+ "eslintConfig": {
92
+ "extends": "@ionic/eslint-config/recommended"
101
93
  },
102
- "prettier": "@ebarooni/prettier-config",
103
- "swiftlint": "@ebarooni/swiftlint-config",
94
+ "prettier": "@ionic/prettier-config",
95
+ "swiftlint": "@ionic/swiftlint-config",
104
96
  "capacitor": {
105
97
  "ios": {
106
98
  "src": "ios"