@coozzy/cal-dav
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -48,2 +48,3 @@ "use strict"; | ||
event.component.addPropertyWithValue('url', urlParts[urlParts.length - 1]); | ||
this.extendEventWithRecurrenceDetails(event); | ||
_logger.default.info(`CalDavClient.GetEvent: Successfully got event ${event.uid}. `); | ||
@@ -121,3 +122,3 @@ return event; | ||
const calendar = new ICAL.Component('vcalendar'); | ||
const event = new ICAL.Event(calendar); | ||
let event = new ICAL.Event(calendar); | ||
event.component.addPropertyWithValue('PRODID', prodid); | ||
@@ -380,4 +381,2 @@ event.component.addPropertyWithValue('BEGIN', 'VEVENT'); | ||
const calDataOccurrence = ICAL.parse(eventData.event); | ||
const compOccurrence = new ICAL.Component(calDataOccurrence); | ||
const veventOccurrence = compOccurrence.getFirstSubcomponent('vevent'); | ||
for (let next = iterator.next(); next; next = iterator.next()) { | ||
@@ -400,4 +399,4 @@ if (new Date(next.toString()).getTime() > endDateFilter.getTime()) { | ||
exceptionEventId += 1; | ||
const copiediCalEvent = this.extendEventWithRecurrenceDetails(event); | ||
events.push(copiediCalEvent); | ||
this.extendEventWithRecurrenceDetails(event); | ||
events.push(event); | ||
} | ||
@@ -407,2 +406,4 @@ } | ||
if (!isException) { | ||
const compOccurrence = new ICAL.Component(calDataOccurrence); | ||
const veventOccurrence = compOccurrence.getFirstSubcomponent('vevent'); | ||
const icalEvent = new ICAL.Event(veventOccurrence); | ||
@@ -415,4 +416,4 @@ const diffInMs = new Date(next.toString()).getTime() - new Date(iCalEvent.startDate.toString()).getTime(); | ||
icalEvent.component.addPropertyWithValue('url', urlParts[urlParts.length - 1]); | ||
const copiediCalEvent = this.extendEventWithRecurrenceDetails(icalEvent); | ||
events.push(copiediCalEvent); | ||
this.extendEventWithRecurrenceDetails(icalEvent); | ||
events.push(icalEvent); | ||
} | ||
@@ -439,2 +440,20 @@ } | ||
} | ||
// private extendEventWithRecurrenceDetails(iCalEvent: EventWithExceptions, frequency: EventFrequencyCalendarService, until?: TimeJsonData, count?: number): ICAL.EventWithExceptions { | ||
// const frequencyValue = this.EventFrequencyCalendarServiceToFrequencyValues(frequency); | ||
// console.log('ok1 ' + frequencyValue); | ||
// if (!frequencyValue) { | ||
// return iCalEvent; | ||
// } | ||
// iCalEvent.frequency = frequencyValue; | ||
// if (count) { | ||
// iCalEvent.countRecurrence = count; | ||
// } | ||
// if (until) { | ||
// iCalEvent.endDateRecurrence = new ICAL.Time(until); | ||
// } | ||
// console.log('ok2 ' + JSON.stringify(iCalEvent)); | ||
// return iCalEvent; | ||
// } | ||
setOrganizer(email, event) { | ||
@@ -496,18 +515,23 @@ const organizerValue = `RSVP=TRUE;PARTSTAT=ACCEPTED;CN=${email}:mailto:${email}`; | ||
} | ||
addFrequency(event, freq, endDate, count) { | ||
if (endDate && count) { | ||
throw new Error('CalDavClient.addFrequency: It is allowed to use endDate or count, not both at the same time.'); | ||
} | ||
let freqValue; | ||
EventFrequencyCalendarServiceToFrequencyValues(freq) { | ||
if (freq === 'EVENT_FREQUENCY_DAILY') { | ||
freqValue = 'DAILY'; | ||
return 'DAILY'; | ||
} else if (freq === 'EVENT_FREQUENCY_WEEKLY') { | ||
freqValue = 'WEEKLY'; | ||
return 'WEEKLY'; | ||
} else if (freq === 'EVENT_FREQUENCY_MONTHLY') { | ||
freqValue = 'MONTHLY'; | ||
return 'MONTHLY'; | ||
} else if (freq === 'EVENT_FREQUENCY_YEARLY') { | ||
freqValue = 'YEARLY'; | ||
return 'YEARLY'; | ||
} else { | ||
return; | ||
return undefined; | ||
} | ||
} | ||
addFrequency(event, freq, endDate, count) { | ||
if (endDate && count) { | ||
throw new Error('CalDavClient.addFrequency: It is allowed to use endDate or count, not both at the same time.'); | ||
} | ||
const freqValue = this.EventFrequencyCalendarServiceToFrequencyValues(freq); | ||
if (!freqValue) { | ||
return event; | ||
} | ||
if (freqValue) { | ||
@@ -528,2 +552,3 @@ // We have switched using RecurData to object {FREQ: FrequencyValues, COUNT?: number, UNTIL?: string} | ||
} | ||
return event; | ||
} | ||
@@ -530,0 +555,0 @@ eventIncludedInDates(startDateEvent, endDateEvent, startDateFilter, endDateFilter) { |
{ | ||
"name": "@coozzy/cal-dav", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"description": "Simple cal dav client.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,3 +7,3 @@ import * as ICAL from 'ical.js'; | ||
import {EventWithExceptions, FrequencyValues, TimeJsonData} from 'ical.js'; | ||
import {EventFrequencyCalendarService} from "../types/calendar"; | ||
import {EventFrequencyCalendarService} from '../types/calendar'; | ||
@@ -108,2 +108,3 @@ export interface CalDavClient { | ||
event.component.addPropertyWithValue('url', urlParts[urlParts.length - 1]); | ||
this.extendEventWithRecurrenceDetails(event); | ||
logger.info(`CalDavClient.GetEvent: Successfully got event ${event.uid}. `); | ||
@@ -236,3 +237,2 @@ return event; | ||
} | ||
if (frequencyInterval) { | ||
@@ -242,4 +242,4 @@ this.validateRecurrence(startDate, frequencyInterval, endDateFrequency, countFrequency); | ||
} | ||
event.component.addPropertyWithValue('END', 'VEVENT'); | ||
event.component.addPropertyWithValue('END', 'VEVENT'); | ||
let eventString = event.toString(); | ||
@@ -492,4 +492,2 @@ | ||
const calDataOccurrence = ICAL.parse(eventData.event); | ||
const compOccurrence = new ICAL.Component(calDataOccurrence); | ||
const veventOccurrence = compOccurrence.getFirstSubcomponent('vevent'); | ||
for (let next = iterator.next(); next; next = iterator.next()) { | ||
@@ -516,4 +514,4 @@ if (new Date(next.toString()).getTime() > endDateFilter.getTime()) { | ||
exceptionEventId += 1; | ||
const copiediCalEvent = this.extendEventWithRecurrenceDetails(event); | ||
events.push(copiediCalEvent); | ||
this.extendEventWithRecurrenceDetails(event); | ||
events.push(event); | ||
} | ||
@@ -524,2 +522,4 @@ } | ||
if (!isException) { | ||
const compOccurrence = new ICAL.Component(calDataOccurrence); | ||
const veventOccurrence = compOccurrence.getFirstSubcomponent('vevent'); | ||
const icalEvent = new ICAL.Event(veventOccurrence); | ||
@@ -532,4 +532,4 @@ const diffInMs = new Date(next.toString()).getTime() - new Date(iCalEvent.startDate.toString()).getTime(); | ||
icalEvent.component.addPropertyWithValue('url', urlParts[urlParts.length - 1]); | ||
const copiediCalEvent = this.extendEventWithRecurrenceDetails(icalEvent); | ||
events.push(copiediCalEvent); | ||
this.extendEventWithRecurrenceDetails(icalEvent); | ||
events.push(icalEvent); | ||
} | ||
@@ -546,3 +546,3 @@ } | ||
private extendEventWithRecurrenceDetails(iCalEvent: EventWithExceptions) { | ||
private extendEventWithRecurrenceDetails(iCalEvent: EventWithExceptions): ICAL.EventWithExceptions { | ||
const rrule = iCalEvent.component.getFirstPropertyValue('rrule'); | ||
@@ -624,18 +624,25 @@ if (rrule) { | ||
private addFrequency(event: ICAL.Event, freq?: EventFrequencyCalendarService, endDate?: TimeJsonData, count?: number): void { | ||
if (endDate && count) { | ||
throw new Error('CalDavClient.addFrequency: It is allowed to use endDate or count, not both at the same time.'); | ||
} | ||
let freqValue: FrequencyValues; | ||
private EventFrequencyCalendarServiceToFrequencyValues(freq?: EventFrequencyCalendarService): FrequencyValues | undefined { | ||
if (freq === 'EVENT_FREQUENCY_DAILY') { | ||
freqValue = 'DAILY'; | ||
return 'DAILY'; | ||
} else if (freq === 'EVENT_FREQUENCY_WEEKLY') { | ||
freqValue = 'WEEKLY'; | ||
return 'WEEKLY'; | ||
} else if (freq === 'EVENT_FREQUENCY_MONTHLY') { | ||
freqValue = 'MONTHLY'; | ||
return 'MONTHLY'; | ||
} else if (freq === 'EVENT_FREQUENCY_YEARLY') { | ||
freqValue = 'YEARLY'; | ||
return 'YEARLY'; | ||
} else { | ||
return; | ||
return undefined; | ||
} | ||
} | ||
private addFrequency(event: ICAL.Event, freq?: EventFrequencyCalendarService, endDate?: TimeJsonData, count?: number): ICAL.EventWithExceptions { | ||
if (endDate && count) { | ||
throw new Error('CalDavClient.addFrequency: It is allowed to use endDate or count, not both at the same time.'); | ||
} | ||
const freqValue: FrequencyValues | undefined = this.EventFrequencyCalendarServiceToFrequencyValues(freq); | ||
if (!freqValue) { | ||
return event; | ||
} | ||
if (freqValue!) { | ||
@@ -657,3 +664,3 @@ // We have switched using RecurData to object {FREQ: FrequencyValues, COUNT?: number, UNTIL?: string} | ||
} | ||
return event; | ||
} | ||
@@ -660,0 +667,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101401
2111