Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coozzy/cal-dav

Package Overview
Dependencies
Maintainers
3
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coozzy/cal-dav - npm Package Compare versions

Comparing version 2.4.6 to 2.4.7

11

dist/index.d.ts

@@ -5,2 +5,3 @@ import * as ICAL from 'ical.js';

import { Attendee, Alarm } from './lib/types';
import { EventOccurrence, TimeJsonData } from 'ical.js';
import { EventFrequencyCalendarService } from '../types/calendar';

@@ -14,4 +15,4 @@ export interface CalDavClient {

createEvent(eventUrl: string, id: string, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, frequencyInterval?: string, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]): Promise<void>;
updateEvent(eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, occurrenceEventId?: number, frequencyInterval?: string, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]): Promise<void>;
deleteOccurrenceEvent(eventUrl: string, event: ICAL.Event, occurrenceEventId: number, prodid: string): Promise<void>;
updateEvent(eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, occurrenceEventDate?: ICAL.TimeJsonData | undefined, frequencyInterval?: string, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]): Promise<void>;
deleteOccurrenceEvent(eventUrl: string, event: ICAL.Event, occurrenceEventDate: ICAL.TimeJsonData, prodid: string): Promise<void>;
listEventsInTimeRange(startDate: Date, endDate?: Date): Promise<ICAL.EventOccurrence[]>;

@@ -33,6 +34,6 @@ multiGetEvents(eventUrls: string[]): Promise<ICAL.Event[]>;

createEvent: (eventUrl: string, id: string, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]) => Promise<void>;
updateEvent: (eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, occurrenceEventId: number | undefined, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]) => Promise<void>;
updateEvent: (eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, occurrenceEventDate: ICAL.TimeJsonData | undefined, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]) => Promise<void>;
private getDateWithoutTime;
updateEventProperties: (eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]) => string;
deleteOccurrenceEvent: (eventUrl: string, event: ICAL.Event, occurrenceEventId: number, prodid: string) => Promise<void>;
updateEventProperties: (eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[], recurrenceId?: ICAL.Time) => string;
deleteOccurrenceEvent: (eventUrl: string, event: ICAL.Event, occurrenceEventDate: ICAL.TimeJsonData, prodid: string) => Promise<void>;
createEventWithString: (event: string, eventUid: string) => Promise<void>;

@@ -39,0 +40,0 @@ static parseEvent: (eventData: string) => ICAL.Event;

@@ -193,3 +193,3 @@ "use strict";

};
this.updateEvent = async (eventUrl, event, title, description, location, startDate, endDate, attendees, categories, organizerEmail, prodid, privateEvent, occurrenceEventId, frequencyInterval, endDateFrequency, countFrequency, alarms) => {
this.updateEvent = async (eventUrl, event, title, description, location, startDate, endDate, attendees, categories, organizerEmail, prodid, privateEvent, occurrenceEventDate, frequencyInterval, endDateFrequency, countFrequency, alarms) => {
try {

@@ -208,3 +208,3 @@ _logger.default.debug(`Method updateEvent executed for eventUrl: ${eventUrl}`, {

privateEvent,
occurrenceEventId,
occurrenceEventDate,
frequencyInterval,

@@ -217,3 +217,3 @@ endDateFrequency,

let exceptionEventString = '';
if (occurrenceEventId) {
if (occurrenceEventDate && occurrenceEventDate.year && occurrenceEventDate.month && occurrenceEventDate.day) {
eventString = event.toString();

@@ -232,13 +232,24 @@ const exDates = event.component.getAllProperties('exdate');

let occurrenceEventIdIteration = 0;
let checkNextOccurrence = false;
const iterator = event.iterator();
for (let next = iterator.next(); next; next = iterator.next()) {
if (exceptionProcessed === exceptions.length && occurrenceEventIdIteration > occurrenceEventId) {
const occurrenceEventTime = new ICAL.Time(next.toJSON());
occurrenceEventTime.day = occurrenceEventDate.day;
occurrenceEventTime.month = occurrenceEventDate.month;
occurrenceEventTime.year = occurrenceEventDate.year;
if (occurrenceEventDate.hour) {
occurrenceEventTime.hour = occurrenceEventDate.hour;
}
if (occurrenceEventDate.second) {
occurrenceEventTime.second = occurrenceEventDate.second;
}
if (exceptionProcessed === exceptions.length && next.toJSDate().getTime() > occurrenceEventTime.toJSDate().getTime()) {
break;
}
occurrenceEventIdIteration += 1;
if (exDatesValues.find(x => x === new Date(next.toString()).getTime())) {
if (occurrenceEventIdIteration === occurrenceEventId) {
if (exDatesValues.find(x => x === next.toJSDate().getTime())) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
throw new Error('CalDavClient.UpdateEvent: Deleted occurrence can\'t be updated.');
}
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(next.toString()), true));
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(next.toJSDate(), true));
continue;

@@ -253,8 +264,8 @@ }

}
if (new Date(exceptionString).getTime() === new Date(next.toString()).getTime()) {
if (new Date(exceptionString).getTime() === next.toJSDate().getTime()) {
exceptionAdded = true;
exceptionProcessed += 1;
exceptionEventString += '\r\n';
if (occurrenceEventIdIteration === occurrenceEventId) {
_logger.default.debug(`Execute method updateEventProperties for occurrenceEventId: ${occurrenceEventId}`);
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
_logger.default.debug(`Execute method updateEventProperties for occurrenceEventDate: ${occurrenceEventDate}`);
const exceptionEvent = new ICAL.Event(exceptions[exception.toString()].component);

@@ -275,3 +286,3 @@ currentOccurrenceDate = new ICAL.Time(startDate);

// process not deleted and not existing exception occurrence - create new exception
if (occurrenceEventIdIteration === occurrenceEventId && !exceptionAdded) {
if (occurrenceEventTime.toJSDate().getTime() === next.toJSDate().getTime() && !exceptionAdded) {
const calDataOccurrence = ICAL.parse(`BEGIN:VCALENDAR\r\n${eventString}\r\nEND:VCALENDAR`);

@@ -288,3 +299,3 @@ const compOccurrence = new ICAL.Component(calDataOccurrence);

}
if (occurrenceEventIdIteration === occurrenceEventId) {
if (occurrenceEventTime.toJSDate().getTime() === next.toJSDate().getTime()) {
if (previousOccurrenceDate && currentOccurrenceDate) {

@@ -299,3 +310,5 @@ const currentOccurrenceDateTime = this.getDateWithoutTime(currentOccurrenceDate.toJSDate()).getTime();

}
} else if (occurrenceEventIdIteration === occurrenceEventId + 1) {
checkNextOccurrence = true;
} else if (checkNextOccurrence) {
checkNextOccurrence = false;
if (previousOccurrenceDate && currentOccurrenceDate) {

@@ -362,3 +375,4 @@ const currentOccurrenceDateTime = this.getDateWithoutTime(currentOccurrenceDate.toJSDate()).getTime();

event.component = newEventComponent;
event.uid = tempId;
event.uid = tempId; // above line sometimes erasy uid from ocurrence event (when all occurrences are exceptions in recurrence event, then first and last lost uid)
event.component.removeAllProperties('categories');

@@ -424,3 +438,3 @@ event.component.removeAllProperties('attendee');

};
this.deleteOccurrenceEvent = async (eventUrl, event, occurrenceEventId, prodid) => {
this.deleteOccurrenceEvent = async (eventUrl, event, occurrenceEventDate, prodid) => {
let eventString;

@@ -430,5 +444,4 @@ try {

let newExceptionAdded = false;
if (occurrenceEventId) {
const iterator = event.iterator();
let occurrenceEventIdIteration = 0;
if (occurrenceEventDate && occurrenceEventDate.year && occurrenceEventDate.month && occurrenceEventDate.day) {
// get deleted occurrences
const exDates = event.component.getAllProperties('exdate');

@@ -439,2 +452,4 @@ const exDatesValues = [];

}
// get exceptions - changed occurrences
let exceptions = {};

@@ -445,12 +460,18 @@ if (event.exceptions) {

let exceptionProcessed = 0;
let occurrenceEventIdIteration = 0;
const iterator = event.iterator();
for (let next = iterator.next(); next; next = iterator.next()) {
if (exceptionProcessed === exceptions.length && occurrenceEventIdIteration > occurrenceEventId) {
const occurrenceEventTime = new ICAL.Time(next.toJSON());
occurrenceEventTime.day = occurrenceEventDate.day;
occurrenceEventTime.month = occurrenceEventDate.month;
occurrenceEventTime.year = occurrenceEventDate.year;
if (exceptionProcessed === exceptions.length && next.toJSDate().getTime() > occurrenceEventTime.toJSDate().getTime()) {
break;
}
occurrenceEventIdIteration += 1;
if (exDatesValues.find(x => x === new Date(next.toString()).getTime())) {
if (occurrenceEventIdIteration === occurrenceEventId) {
if (exDatesValues.find(x => x === next.toJSDate().getTime())) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
throw new Error('CalDavClient.UpdateEvent: Occurrence has been already deleted!');
}
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(next.toString()), true));
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(next.toJSDate(), true));
continue;

@@ -464,7 +485,7 @@ }

}
if (new Date(exceptionString).getTime() === new Date(next.toString()).getTime()) {
if (new Date(exceptionString).getTime() === next.toJSDate().getTime()) {
exceptionAdded = true;
exceptionProcessed += 1;
exceptionEventString += '\r\n';
if (occurrenceEventIdIteration === occurrenceEventId) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
newExceptionAdded = true;

@@ -481,8 +502,9 @@ event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(exception.toString()), true));

// process not deleted and not existing exception occurrence - create new exception
if (occurrenceEventIdIteration === occurrenceEventId && !exceptionAdded) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime() && !exceptionAdded) {
newExceptionAdded = true;
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(next.toString()), true));
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(next.toJSDate(), true));
}
}
if (occurrenceEventIdIteration === 1) {
// delete last occurrence of recurrence events (all other were deleted earlier)
await this.deleteEvent(eventUrl);

@@ -493,3 +515,3 @@ return;

if (!newExceptionAdded) {
throw new Error(`CalDavClient.UpdateEvent: There is no occurrenceEventId: ${occurrenceEventId}`);
throw new Error(`CalDavClient.UpdateEvent: There is no occurrenceEventDate: ${occurrenceEventDate}`);
}

@@ -537,12 +559,10 @@ eventString = event.toString();

}
let occurrenceEventId = 0;
const iterator = iCalEvent.iterator();
const calDataOccurrence = ICAL.parse(eventData.event);
for (let next = iterator.next(); next; next = iterator.next()) {
if (new Date(next.toString()).getTime() > endDateFilter.getTime()) {
if (next.toJSDate().getTime() > endDateFilter.getTime()) {
// all next occurrences later than endDateFilter
break;
}
occurrenceEventId += 1;
if (exDatesValues.find(x => x === new Date(next.toString()).getTime())) {
if (exDatesValues.find(x => x === next.toJSDate().getTime())) {
// occurrence deleted

@@ -558,7 +578,7 @@ continue;

}
if (new Date(exceptionString).getTime() === new Date(next.toString()).getTime()) {
if (new Date(exceptionString).getTime() === next.toJSDate().getTime()) {
exceptionAdded = true;
const event = new ICAL.Event(exceptions[exception.toString()].component);
if (this.eventIncludedInDates(event.startDate, event.endDate, startDateFilter, endDateFilter)) {
event.occurrenceEventId = occurrenceEventId;
event.occurrenceEventDate = next;
this.extendEventWithRecurrenceDetails(event);

@@ -575,3 +595,3 @@ events.push(event);

const icalEvent = new ICAL.Event(veventOccurrence);
const diffInMs = new Date(next.toString()).getTime() - new Date(iCalEvent.startDate.toString()).getTime();
const diffInMs = next.toJSDate().getTime() - new Date(iCalEvent.startDate.toString()).getTime();
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);

@@ -581,3 +601,3 @@ icalEvent.startDate.adjust(diffInDays, 0, 0, 0);

if (this.eventIncludedInDates(icalEvent.startDate, icalEvent.endDate, startDateFilter, endDateFilter)) {
icalEvent.occurrenceEventId = occurrenceEventId;
icalEvent.occurrenceEventDate = next;
icalEvent.component.addPropertyWithValue('url', urlParts[urlParts.length - 1]);

@@ -584,0 +604,0 @@ this.extendEventWithRecurrenceDetails(icalEvent);

{
"name": "@coozzy/cal-dav",
"version": "2.4.6",
"version": "2.4.7",
"description": "Simple cal dav client.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -6,3 +6,2 @@ import * as ICAL from 'ical.js';

import logger from '@coozzy/logger';
import {EventOccurrence, FrequencyValues, Time, TimeJsonData} from 'ical.js';
import {EventFrequencyCalendarService} from '../types/calendar';

@@ -51,3 +50,3 @@

privateEvent: boolean,
occurrenceEventId?: number,
occurrenceEventDate?: ICAL.TimeJsonData | undefined,
frequencyInterval?: string,

@@ -60,3 +59,3 @@ endDateFrequency?: ICAL.TimeJsonData,

event: ICAL.Event,
occurrenceEventId: number,
occurrenceEventDate: ICAL.TimeJsonData,
prodid: string): Promise<void>;

@@ -278,3 +277,3 @@

updateEvent = async(eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, occurrenceEventId: number | undefined, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]): Promise<void> => {
updateEvent = async(eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, occurrenceEventDate: ICAL.TimeJsonData | undefined, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[]): Promise<void> => {
try{

@@ -294,3 +293,3 @@ logger.debug(`Method updateEvent executed for eventUrl: ${eventUrl}`,

privateEvent,
occurrenceEventId,
occurrenceEventDate,
frequencyInterval,

@@ -303,3 +302,3 @@ endDateFrequency,

let exceptionEventString = '';
if (occurrenceEventId) {
if (occurrenceEventDate && occurrenceEventDate.year && occurrenceEventDate.month && occurrenceEventDate.day) {
eventString = event.toString();

@@ -321,6 +320,17 @@

let occurrenceEventIdIteration = 0;
let checkNextOccurrence = false;
const iterator = event.iterator();
for (let next = iterator.next(); next; next = iterator.next()) {
const occurrenceEventTime = new ICAL.Time(next.toJSON());
occurrenceEventTime.day = occurrenceEventDate.day;
occurrenceEventTime.month = occurrenceEventDate.month;
occurrenceEventTime.year = occurrenceEventDate.year;
if (occurrenceEventDate.hour) {
occurrenceEventTime.hour = occurrenceEventDate.hour;
}
if (occurrenceEventDate.second) {
occurrenceEventTime.second = occurrenceEventDate.second;
}
if (exceptionProcessed === exceptions.length && occurrenceEventIdIteration > occurrenceEventId) {
if (exceptionProcessed === exceptions.length && next.toJSDate().getTime() > occurrenceEventTime.toJSDate().getTime()) {
break;

@@ -330,7 +340,7 @@ }

if (exDatesValues.find(x => x === new Date(next.toString()).getTime())) {
if (occurrenceEventIdIteration === occurrenceEventId) {
if (exDatesValues.find(x => x === next.toJSDate().getTime())) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
throw new Error('CalDavClient.UpdateEvent: Deleted occurrence can\'t be updated.');
}
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(next.toString()), true));
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(next.toJSDate(), true));
continue;

@@ -346,8 +356,8 @@ }

}
if (new Date(exceptionString).getTime() === new Date(next.toString()).getTime()) {
if (new Date(exceptionString).getTime() === next.toJSDate().getTime()) {
exceptionAdded = true;
exceptionProcessed += 1;
exceptionEventString += '\r\n';
if (occurrenceEventIdIteration === occurrenceEventId) {
logger.debug(`Execute method updateEventProperties for occurrenceEventId: ${occurrenceEventId}`);
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
logger.debug(`Execute method updateEventProperties for occurrenceEventDate: ${occurrenceEventDate}`);
const exceptionEvent: ICAL.Event = new ICAL.Event(exceptions[exception.toString()].component);

@@ -368,3 +378,3 @@ currentOccurrenceDate = new ICAL.Time(startDate);

// process not deleted and not existing exception occurrence - create new exception
if (occurrenceEventIdIteration === occurrenceEventId && !exceptionAdded) {
if (occurrenceEventTime.toJSDate().getTime() === next.toJSDate().getTime() && !exceptionAdded) {
const calDataOccurrence = ICAL.parse(`BEGIN:VCALENDAR\r\n${eventString}\r\nEND:VCALENDAR`);

@@ -382,3 +392,3 @@ const compOccurrence = new ICAL.Component(calDataOccurrence);

}
if (occurrenceEventIdIteration === occurrenceEventId) {
if (occurrenceEventTime.toJSDate().getTime() === next.toJSDate().getTime()) {
if (previousOccurrenceDate && currentOccurrenceDate) {

@@ -393,3 +403,5 @@ const currentOccurrenceDateTime = this.getDateWithoutTime(currentOccurrenceDate.toJSDate()).getTime();

}
} else if (occurrenceEventIdIteration === (occurrenceEventId + 1)) {
checkNextOccurrence = true;
} else if (checkNextOccurrence) {
checkNextOccurrence = false;
if (previousOccurrenceDate && currentOccurrenceDate) {

@@ -425,3 +437,3 @@ const currentOccurrenceDateTime = this.getDateWithoutTime(currentOccurrenceDate.toJSDate()).getTime();

updateEventProperties = (eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[], recurrenceId?: Time): string => {
updateEventProperties = (eventUrl: string, event: ICAL.Event, title: string, description: string, location: string, startDate: ICAL.TimeJsonData, endDate: ICAL.TimeJsonData, attendees: Attendee[], categories: string[], organizerEmail: string, prodid: string, privateEvent: boolean, frequencyInterval?: EventFrequencyCalendarService, endDateFrequency?: ICAL.TimeJsonData, countFrequency?: number, alarms?: Alarm[], recurrenceId?: ICAL.Time): string => {
try{

@@ -540,3 +552,3 @@ logger.debug(`Method updateEventProperties executed for eventUrl: ${eventUrl}`,

deleteOccurrenceEvent = async(eventUrl: string, event: ICAL.Event, occurrenceEventId: number, prodid: string): Promise<void> => {
deleteOccurrenceEvent = async(eventUrl: string, event: ICAL.Event, occurrenceEventDate: ICAL.TimeJsonData, prodid: string): Promise<void> => {
let eventString;

@@ -546,7 +558,4 @@ try {

let newExceptionAdded = false;
if (occurrenceEventId) {
const iterator = event.iterator();
let occurrenceEventIdIteration = 0;
if (occurrenceEventDate && occurrenceEventDate.year && occurrenceEventDate.month && occurrenceEventDate.day) {
// get deleted occurrences
const exDates = event.component.getAllProperties('exdate');

@@ -558,2 +567,3 @@ const exDatesValues: number[] = [];

// get exceptions - changed occurrences
let exceptions: any = {};

@@ -565,4 +575,11 @@ if (event.exceptions) {

let exceptionProcessed = 0;
let occurrenceEventIdIteration = 0;
const iterator = event.iterator();
for (let next = iterator.next(); next; next = iterator.next()) {
if (exceptionProcessed === exceptions.length && occurrenceEventIdIteration > occurrenceEventId) {
const occurrenceEventTime = new ICAL.Time(next.toJSON());
occurrenceEventTime.day = occurrenceEventDate.day;
occurrenceEventTime.month = occurrenceEventDate.month;
occurrenceEventTime.year = occurrenceEventDate.year;
if (exceptionProcessed === exceptions.length && next.toJSDate().getTime() > occurrenceEventTime.toJSDate().getTime()) {
break;

@@ -572,7 +589,7 @@ }

if (exDatesValues.find(x => x === new Date(next.toString()).getTime())) {
if (occurrenceEventIdIteration === occurrenceEventId) {
if (exDatesValues.find(x => x === next.toJSDate().getTime())) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
throw new Error('CalDavClient.UpdateEvent: Occurrence has been already deleted!');
}
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(next.toString()), true));
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(next.toJSDate(), true));
continue;

@@ -587,7 +604,7 @@ }

}
if (new Date(exceptionString).getTime() === new Date(next.toString()).getTime()) {
if (new Date(exceptionString).getTime() === next.toJSDate().getTime()) {
exceptionAdded = true;
exceptionProcessed += 1;
exceptionEventString += '\r\n';
if (occurrenceEventIdIteration === occurrenceEventId) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime()) {
newExceptionAdded = true;

@@ -604,9 +621,10 @@ event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(exception.toString()), true));

// process not deleted and not existing exception occurrence - create new exception
if (occurrenceEventIdIteration === occurrenceEventId && !exceptionAdded) {
if (next.toJSDate().getTime() === occurrenceEventTime.toJSDate().getTime() && !exceptionAdded) {
newExceptionAdded = true;
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(new Date(next.toString()), true));
event.component.addPropertyWithValue('EXDATE', ICAL.Time.fromJSDate(next.toJSDate(), true));
}
}
if (occurrenceEventIdIteration === 1) {
// delete last occurrence of recurrence events (all other were deleted earlier)
await this.deleteEvent(eventUrl);

@@ -617,3 +635,3 @@ return;

if (!newExceptionAdded) {
throw new Error(`CalDavClient.UpdateEvent: There is no occurrenceEventId: ${occurrenceEventId}`);
throw new Error(`CalDavClient.UpdateEvent: There is no occurrenceEventDate: ${occurrenceEventDate}`);
}

@@ -676,3 +694,2 @@ eventString = event.toString();

}
let occurrenceEventId = 0;
const iterator = iCalEvent.iterator();

@@ -682,9 +699,8 @@

for (let next = iterator.next(); next; next = iterator.next()) {
if (new Date(next.toString()).getTime() > endDateFilter.getTime()) {
if (next.toJSDate().getTime() > endDateFilter.getTime()) {
// all next occurrences later than endDateFilter
break;
}
occurrenceEventId += 1;
if (exDatesValues.find(x => x === new Date(next.toString()).getTime())) {
if (exDatesValues.find(x => x === next.toJSDate().getTime())) {
// occurrence deleted

@@ -701,3 +717,3 @@ continue;

}
if (new Date(exceptionString).getTime() === new Date(next.toString()).getTime()) {
if (new Date(exceptionString).getTime() === next.toJSDate().getTime()) {
exceptionAdded = true;

@@ -707,3 +723,3 @@ const event: ICAL.EventOccurrence = new ICAL.Event(exceptions[exception.toString()].component);

if (this.eventIncludedInDates(event.startDate, event.endDate, startDateFilter, endDateFilter)) {
event.occurrenceEventId = occurrenceEventId;
event.occurrenceEventDate = next;
this.extendEventWithRecurrenceDetails(event);

@@ -715,3 +731,2 @@ events.push(event);

}
if (!exceptionAdded) {

@@ -722,3 +737,3 @@ // process not deleted and not exception occurrence

const icalEvent: ICAL.EventOccurrence = new ICAL.Event(veventOccurrence);
const diffInMs = new Date(next.toString()).getTime() - new Date(iCalEvent.startDate.toString()).getTime();
const diffInMs = next.toJSDate().getTime() - new Date(iCalEvent.startDate.toString()).getTime();
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);

@@ -728,3 +743,3 @@ icalEvent.startDate.adjust(diffInDays, 0, 0, 0);

if (this.eventIncludedInDates(icalEvent.startDate, icalEvent.endDate, startDateFilter, endDateFilter)) {
icalEvent.occurrenceEventId = occurrenceEventId;
icalEvent.occurrenceEventDate = next;
icalEvent.component.addPropertyWithValue('url', urlParts[urlParts.length - 1]);

@@ -731,0 +746,0 @@ this.extendEventWithRecurrenceDetails(icalEvent);

@@ -37,3 +37,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

class EventOccurrence extends Event {
occurrenceEventId?: number;
occurrenceEventDate?: Time;
frequency?: FrequencyValues;

@@ -40,0 +40,0 @@ endDateRecurrence?: Time;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc