@checkfirst/nestjs-outlook 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/recurrence.interfaces.d.ts +57 -0
- package/dist/interfaces/recurrence.interfaces.js +3 -0
- package/dist/interfaces/recurrence.interfaces.js.map +1 -0
- package/dist/microsoft-outlook.module.js +3 -0
- package/dist/microsoft-outlook.module.js.map +1 -1
- package/dist/services/calendar/index.d.ts +1 -0
- package/dist/services/calendar/index.js +1 -0
- package/dist/services/calendar/index.js.map +1 -1
- package/dist/services/calendar/recurrence.service.d.ts +14 -0
- package/dist/services/calendar/recurrence.service.js +165 -0
- package/dist/services/calendar/recurrence.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export * from './services/auth/microsoft-auth.service';
|
|
2
2
|
export * from './services/calendar/calendar.service';
|
|
3
|
+
export * from './services/calendar/recurrence.service';
|
|
3
4
|
export * from './services/email/email.service';
|
|
4
5
|
export * from './services/shared/user-id-converter.service';
|
|
5
6
|
export * from './services/subscription/microsoft-subscription.service';
|
|
6
7
|
export * from './microsoft-outlook.module';
|
|
7
8
|
export * from './interfaces/outlook/token-response.interface';
|
|
8
9
|
export * from './interfaces/config/outlook-config.interface';
|
|
10
|
+
export * from './interfaces/recurrence.interfaces';
|
|
9
11
|
export * from './enums/permission-scope.enum';
|
|
10
12
|
export * from './enums/event-types.enum';
|
|
11
13
|
export * from './enums/show-as-type.enum';
|
package/dist/index.js
CHANGED
|
@@ -16,12 +16,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./services/auth/microsoft-auth.service"), exports);
|
|
18
18
|
__exportStar(require("./services/calendar/calendar.service"), exports);
|
|
19
|
+
__exportStar(require("./services/calendar/recurrence.service"), exports);
|
|
19
20
|
__exportStar(require("./services/email/email.service"), exports);
|
|
20
21
|
__exportStar(require("./services/shared/user-id-converter.service"), exports);
|
|
21
22
|
__exportStar(require("./services/subscription/microsoft-subscription.service"), exports);
|
|
22
23
|
__exportStar(require("./microsoft-outlook.module"), exports);
|
|
23
24
|
__exportStar(require("./interfaces/outlook/token-response.interface"), exports);
|
|
24
25
|
__exportStar(require("./interfaces/config/outlook-config.interface"), exports);
|
|
26
|
+
__exportStar(require("./interfaces/recurrence.interfaces"), exports);
|
|
25
27
|
__exportStar(require("./enums/permission-scope.enum"), exports);
|
|
26
28
|
__exportStar(require("./enums/event-types.enum"), exports);
|
|
27
29
|
__exportStar(require("./enums/show-as-type.enum"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,yEAAuD;AACvD,uEAAqD;AACrD,iEAA+C;AAC/C,8EAA4D;AAC5D,yFAAuE;AAGvE,6DAA2C;AAG3C,gFAA8D;AAC9D,+EAA6D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,yEAAuD;AACvD,uEAAqD;AACrD,yEAAuD;AACvD,iEAA+C;AAC/C,8EAA4D;AAC5D,yFAAuE;AAGvE,6DAA2C;AAG3C,gFAA8D;AAC9D,+EAA6D;AAC7D,qEAAmD;AAGnD,gEAA8C;AAC9C,2DAAyC;AACzC,4DAA0C;AAG1C,8CAA4B;AAG5B,oEAAkD;AAClD,0EAAwD;AACxD,iEAA+C;AAG/C,yEAAuD;AAGvD,iFAA+D;AAC/D,mEAAiD;AAGjD,yFAAuE;AAGvE,0CAAwB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface RecurrenceRule {
|
|
2
|
+
pattern: {
|
|
3
|
+
type: 'daily' | 'weekly' | 'absoluteMonthly' | 'relativeMonthly' | 'absoluteYearly' | 'relativeYearly';
|
|
4
|
+
interval: number;
|
|
5
|
+
daysOfWeek?: string[];
|
|
6
|
+
dayOfMonth?: number;
|
|
7
|
+
month?: number;
|
|
8
|
+
firstDayOfWeek?: string;
|
|
9
|
+
index?: string;
|
|
10
|
+
};
|
|
11
|
+
range: {
|
|
12
|
+
type: 'endDate' | 'noEnd' | 'numbered';
|
|
13
|
+
startDate: string;
|
|
14
|
+
endDate?: string;
|
|
15
|
+
numberOfOccurrences?: number;
|
|
16
|
+
recurrenceTimeZone?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export type OutlookEventType = 'singleInstance' | 'seriesMaster' | 'occurrence' | 'exception';
|
|
20
|
+
export interface ProcessedOutlookEvent {
|
|
21
|
+
externalId: string;
|
|
22
|
+
eventType: OutlookEventType;
|
|
23
|
+
start: {
|
|
24
|
+
dateTime: string;
|
|
25
|
+
timeZone: string;
|
|
26
|
+
};
|
|
27
|
+
end: {
|
|
28
|
+
dateTime: string;
|
|
29
|
+
timeZone: string;
|
|
30
|
+
};
|
|
31
|
+
subject: string;
|
|
32
|
+
bodyPreview: string;
|
|
33
|
+
location?: string;
|
|
34
|
+
showAs?: string;
|
|
35
|
+
changeKey?: string;
|
|
36
|
+
seriesMasterId?: string;
|
|
37
|
+
transactionId?: string;
|
|
38
|
+
recurrenceRule?: RecurrenceRule;
|
|
39
|
+
originalStart?: {
|
|
40
|
+
dateTime: string;
|
|
41
|
+
timeZone: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface ExpansionWindow {
|
|
45
|
+
startDate: Date;
|
|
46
|
+
endDate: Date;
|
|
47
|
+
}
|
|
48
|
+
export interface ExpandRecurringSeriesOptions {
|
|
49
|
+
existingExternalIds?: string[];
|
|
50
|
+
existingWindowEnd?: Date;
|
|
51
|
+
}
|
|
52
|
+
export interface RecurringEventExpansionResult {
|
|
53
|
+
seriesMaster: ProcessedOutlookEvent;
|
|
54
|
+
instances: ProcessedOutlookEvent[];
|
|
55
|
+
expansionWindow: ExpansionWindow;
|
|
56
|
+
staleExternalIds: string[];
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recurrence.interfaces.js","sourceRoot":"","sources":["../../src/interfaces/recurrence.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -29,6 +29,7 @@ const outlook_delta_link_repository_1 = require("./repositories/outlook-delta-li
|
|
|
29
29
|
const delta_sync_service_1 = require("./services/shared/delta-sync.service");
|
|
30
30
|
const user_id_converter_service_1 = require("./services/shared/user-id-converter.service");
|
|
31
31
|
const lifecycle_event_handler_service_1 = require("./services/calendar/lifecycle-event-handler.service");
|
|
32
|
+
const recurrence_service_1 = require("./services/calendar/recurrence.service");
|
|
32
33
|
const microsoft_subscription_service_1 = require("./services/subscription/microsoft-subscription.service");
|
|
33
34
|
_a = new common_1.ConfigurableModuleBuilder()
|
|
34
35
|
.setClassMethodName("forRoot")
|
|
@@ -64,10 +65,12 @@ exports.MicrosoftOutlookModule = MicrosoftOutlookModule = __decorate([
|
|
|
64
65
|
delta_sync_service_1.DeltaSyncService,
|
|
65
66
|
user_id_converter_service_1.UserIdConverterService,
|
|
66
67
|
lifecycle_event_handler_service_1.LifecycleEventHandlerService,
|
|
68
|
+
recurrence_service_1.RecurrenceService,
|
|
67
69
|
microsoft_subscription_service_1.MicrosoftSubscriptionService,
|
|
68
70
|
],
|
|
69
71
|
exports: [
|
|
70
72
|
calendar_service_1.CalendarService,
|
|
73
|
+
recurrence_service_1.RecurrenceService,
|
|
71
74
|
email_service_1.EmailService,
|
|
72
75
|
microsoft_auth_service_1.MicrosoftAuthService,
|
|
73
76
|
outlook_delta_link_repository_1.OutlookDeltaLinkRepository,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"microsoft-outlook.module.js","sourceRoot":"","sources":["../src/microsoft-outlook.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAmE;AACnE,6CAAgD;AAChD,+CAAkD;AAClD,yDAA2D;AAC3D,mFAA8E;AAC9E,uFAAkF;AAClF,2EAAuE;AACvE,qEAAiE;AACjE,wGAA4F;AAC5F,oHAA8G;AAC9G,2CAA+C;AAE/C,oEAAkE;AAClE,oGAA8F;AAC9F,2EAAuE;AACvE,kEAA8D;AAC9D,4EAAiE;AACjE,oEAAgE;AAChE,gGAA0F;AAC1F,6EAAwE;AACxE,2FAAqF;AACrF,yGAAmG;AACnG,2GAAsG;AAEzF,KACX,IAAI,kCAAyB,EAA0B;KACpD,kBAAkB,CAAC,SAAS,CAAC;KAC7B,KAAK,EAAE,EAHG,+BAAuB,+BAAE,4BAAoB,2BAG/C;
|
|
1
|
+
{"version":3,"file":"microsoft-outlook.module.js","sourceRoot":"","sources":["../src/microsoft-outlook.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAmE;AACnE,6CAAgD;AAChD,+CAAkD;AAClD,yDAA2D;AAC3D,mFAA8E;AAC9E,uFAAkF;AAClF,2EAAuE;AACvE,qEAAiE;AACjE,wGAA4F;AAC5F,oHAA8G;AAC9G,2CAA+C;AAE/C,oEAAkE;AAClE,oGAA8F;AAC9F,2EAAuE;AACvE,kEAA8D;AAC9D,4EAAiE;AACjE,oEAAgE;AAChE,gGAA0F;AAC1F,6EAAwE;AACxE,2FAAqF;AACrF,yGAAmG;AACnG,+EAA2E;AAC3E,2GAAsG;AAEzF,KACX,IAAI,kCAAyB,EAA0B;KACpD,kBAAkB,CAAC,SAAS,CAAC;KAC7B,KAAK,EAAE,EAHG,+BAAuB,+BAAE,4BAAoB,2BAG/C;AA+CN,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,+BAAuB;CAAG,CAAA;AAAzD,wDAAsB;iCAAtB,sBAAsB;IAzClC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,yBAAc,CAAC,OAAO,EAAE;YACxB,uBAAa,CAAC,UAAU,CAAC;gBACvB,gEAA0B;gBAC1B,sCAAkB;gBAClB,qCAAa;gBACb,oCAAgB;aACjB,CAAC;YACF,kCAAkB,CAAC,OAAO,EAAE;SAC7B;QACD,WAAW,EAAE,CAAC,mDAAuB,EAAE,wCAAkB,EAAE,kCAAe,CAAC;QAC3E,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,4BAAgB;gBACzB,UAAU,EAAE,CAAC,OAA+B,EAAE,EAAE,CAAC,OAAO;gBACxD,MAAM,EAAE,CAAC,4BAAoB,CAAC;aAC/B;YACD,8EAAoC;YACpC,8DAA4B;YAC5B,kCAAe;YACf,4BAAY;YACZ,6CAAoB;YACpB,0DAA0B;YAC1B,qCAAgB;YAChB,kDAAsB;YACtB,8DAA4B;YAC5B,sCAAiB;YACjB,6DAA4B;SAC7B;QACD,OAAO,EAAE;YACP,kCAAe;YACf,sCAAiB;YACjB,4BAAY;YACZ,6CAAoB;YACpB,0DAA0B;YAC1B,qCAAgB;YAChB,kDAAsB;YACtB,6DAA4B;SAC7B;KACF,CAAC;GACW,sBAAsB,CAAmC"}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./calendar.service"), exports);
|
|
18
|
+
__exportStar(require("./recurrence.service"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/calendar/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/calendar/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,uDAAqC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Event } from '../../types';
|
|
2
|
+
import { CalendarService } from './calendar.service';
|
|
3
|
+
import { RecurrenceRule, ProcessedOutlookEvent, ExpansionWindow, ExpandRecurringSeriesOptions, RecurringEventExpansionResult } from '../../interfaces/recurrence.interfaces';
|
|
4
|
+
export declare class RecurrenceService {
|
|
5
|
+
private readonly calendarService;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(calendarService: CalendarService);
|
|
8
|
+
processEvent(event: Event): ProcessedOutlookEvent;
|
|
9
|
+
expandRecurringSeries(seriesMasterId: string, externalUserId: string, options?: ExpandRecurringSeriesOptions): Promise<RecurringEventExpansionResult>;
|
|
10
|
+
calculateExpansionWindow(recurrenceRule?: RecurrenceRule, existingWindowEnd?: Date): ExpansionWindow;
|
|
11
|
+
detectStaleOccurrences(fetchedExternalIds: string[], existingExternalIds: string[]): string[];
|
|
12
|
+
isSeriesMaster(event: Event): boolean;
|
|
13
|
+
private extractRecurrenceRule;
|
|
14
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
var RecurrenceService_1;
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.RecurrenceService = void 0;
|
|
21
|
+
const common_1 = require("@nestjs/common");
|
|
22
|
+
const calendar_service_1 = require("./calendar.service");
|
|
23
|
+
let RecurrenceService = RecurrenceService_1 = class RecurrenceService {
|
|
24
|
+
constructor(calendarService) {
|
|
25
|
+
this.calendarService = calendarService;
|
|
26
|
+
this.logger = new common_1.Logger(RecurrenceService_1.name);
|
|
27
|
+
}
|
|
28
|
+
processEvent(event) {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
30
|
+
const eventType = (_a = event.type) !== null && _a !== void 0 ? _a : 'singleInstance';
|
|
31
|
+
const processed = {
|
|
32
|
+
externalId: (_b = event.id) !== null && _b !== void 0 ? _b : '',
|
|
33
|
+
eventType,
|
|
34
|
+
start: {
|
|
35
|
+
dateTime: (_d = (_c = event.start) === null || _c === void 0 ? void 0 : _c.dateTime) !== null && _d !== void 0 ? _d : '',
|
|
36
|
+
timeZone: (_f = (_e = event.start) === null || _e === void 0 ? void 0 : _e.timeZone) !== null && _f !== void 0 ? _f : '',
|
|
37
|
+
},
|
|
38
|
+
end: {
|
|
39
|
+
dateTime: (_h = (_g = event.end) === null || _g === void 0 ? void 0 : _g.dateTime) !== null && _h !== void 0 ? _h : '',
|
|
40
|
+
timeZone: (_k = (_j = event.end) === null || _j === void 0 ? void 0 : _j.timeZone) !== null && _k !== void 0 ? _k : '',
|
|
41
|
+
},
|
|
42
|
+
subject: (_l = event.subject) !== null && _l !== void 0 ? _l : '',
|
|
43
|
+
bodyPreview: (_m = event.bodyPreview) !== null && _m !== void 0 ? _m : '',
|
|
44
|
+
location: (_p = (_o = event.location) === null || _o === void 0 ? void 0 : _o.displayName) !== null && _p !== void 0 ? _p : undefined,
|
|
45
|
+
showAs: (_q = event.showAs) !== null && _q !== void 0 ? _q : undefined,
|
|
46
|
+
changeKey: (_r = event.changeKey) !== null && _r !== void 0 ? _r : undefined,
|
|
47
|
+
seriesMasterId: (_s = event.seriesMasterId) !== null && _s !== void 0 ? _s : undefined,
|
|
48
|
+
transactionId: (_t = event.transactionId) !== null && _t !== void 0 ? _t : undefined,
|
|
49
|
+
};
|
|
50
|
+
if (eventType === 'seriesMaster' && event.recurrence) {
|
|
51
|
+
processed.recurrenceRule = this.extractRecurrenceRule(event.recurrence);
|
|
52
|
+
}
|
|
53
|
+
if (eventType === 'exception' && event.originalStart) {
|
|
54
|
+
processed.originalStart = {
|
|
55
|
+
dateTime: event.originalStart,
|
|
56
|
+
timeZone: (_w = (_u = event.originalStartTimeZone) !== null && _u !== void 0 ? _u : (_v = event.start) === null || _v === void 0 ? void 0 : _v.timeZone) !== null && _w !== void 0 ? _w : '',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return processed;
|
|
60
|
+
}
|
|
61
|
+
async expandRecurringSeries(seriesMasterId, externalUserId, options) {
|
|
62
|
+
var _a, e_1, _b, _c;
|
|
63
|
+
this.logger.log(`[expandRecurringSeries] Expanding series ${seriesMasterId} for user ${externalUserId}`);
|
|
64
|
+
const masterEvents = await this.calendarService.getEventsBatch([seriesMasterId], externalUserId);
|
|
65
|
+
if (masterEvents.length === 0) {
|
|
66
|
+
throw new Error(`Series master ${seriesMasterId} not found in Outlook for user ${externalUserId}`);
|
|
67
|
+
}
|
|
68
|
+
const seriesMaster = this.processEvent(masterEvents[0]);
|
|
69
|
+
const expansionWindow = this.calculateExpansionWindow(seriesMaster.recurrenceRule, options === null || options === void 0 ? void 0 : options.existingWindowEnd);
|
|
70
|
+
this.logger.log(`[expandRecurringSeries] Window: ${expansionWindow.startDate.toISOString()} → ${expansionWindow.endDate.toISOString()}`);
|
|
71
|
+
const instances = [];
|
|
72
|
+
try {
|
|
73
|
+
for (var _d = true, _e = __asyncValues(this.calendarService.getRecurringEventInstances(seriesMasterId, externalUserId, {
|
|
74
|
+
startDate: expansionWindow.startDate,
|
|
75
|
+
endDate: expansionWindow.endDate,
|
|
76
|
+
batchSize: 100,
|
|
77
|
+
})), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
|
78
|
+
_c = _f.value;
|
|
79
|
+
_d = false;
|
|
80
|
+
const batch = _c;
|
|
81
|
+
for (const event of batch) {
|
|
82
|
+
instances.push(this.processEvent(event));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
87
|
+
finally {
|
|
88
|
+
try {
|
|
89
|
+
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
|
|
90
|
+
}
|
|
91
|
+
finally { if (e_1) throw e_1.error; }
|
|
92
|
+
}
|
|
93
|
+
this.logger.log(`[expandRecurringSeries] Fetched ${instances.length} instances for series ${seriesMasterId}`);
|
|
94
|
+
const staleExternalIds = (options === null || options === void 0 ? void 0 : options.existingExternalIds)
|
|
95
|
+
? this.detectStaleOccurrences(instances.map((i) => i.externalId), options.existingExternalIds)
|
|
96
|
+
: [];
|
|
97
|
+
if (staleExternalIds.length > 0) {
|
|
98
|
+
this.logger.log(`[expandRecurringSeries] Detected ${staleExternalIds.length} stale occurrences`);
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
seriesMaster,
|
|
102
|
+
instances,
|
|
103
|
+
expansionWindow,
|
|
104
|
+
staleExternalIds,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
calculateExpansionWindow(recurrenceRule, existingWindowEnd) {
|
|
108
|
+
const now = new Date();
|
|
109
|
+
const startDate = new Date(now);
|
|
110
|
+
startDate.setMonth(startDate.getMonth() - 1);
|
|
111
|
+
let endDate;
|
|
112
|
+
if ((recurrenceRule === null || recurrenceRule === void 0 ? void 0 : recurrenceRule.range.type) === 'endDate' &&
|
|
113
|
+
recurrenceRule.range.endDate) {
|
|
114
|
+
const seriesEnd = new Date(recurrenceRule.range.endDate);
|
|
115
|
+
const maxEnd = new Date(now);
|
|
116
|
+
maxEnd.setFullYear(maxEnd.getFullYear() + 5);
|
|
117
|
+
endDate = seriesEnd < maxEnd ? seriesEnd : maxEnd;
|
|
118
|
+
}
|
|
119
|
+
else if (existingWindowEnd) {
|
|
120
|
+
endDate = new Date(existingWindowEnd);
|
|
121
|
+
endDate.setMonth(endDate.getMonth() + 6);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
endDate = new Date(now);
|
|
125
|
+
endDate.setMonth(endDate.getMonth() + 6);
|
|
126
|
+
}
|
|
127
|
+
return { startDate, endDate };
|
|
128
|
+
}
|
|
129
|
+
detectStaleOccurrences(fetchedExternalIds, existingExternalIds) {
|
|
130
|
+
const fetchedSet = new Set(fetchedExternalIds);
|
|
131
|
+
return existingExternalIds.filter((id) => !fetchedSet.has(id));
|
|
132
|
+
}
|
|
133
|
+
isSeriesMaster(event) {
|
|
134
|
+
return event.type === 'seriesMaster' || event.recurrence != null;
|
|
135
|
+
}
|
|
136
|
+
extractRecurrenceRule(recurrence) {
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
138
|
+
const pattern = recurrence.pattern;
|
|
139
|
+
const range = recurrence.range;
|
|
140
|
+
return {
|
|
141
|
+
pattern: {
|
|
142
|
+
type: (_a = pattern === null || pattern === void 0 ? void 0 : pattern.type) !== null && _a !== void 0 ? _a : 'daily',
|
|
143
|
+
interval: (_b = pattern === null || pattern === void 0 ? void 0 : pattern.interval) !== null && _b !== void 0 ? _b : 1,
|
|
144
|
+
daysOfWeek: (_c = pattern === null || pattern === void 0 ? void 0 : pattern.daysOfWeek) !== null && _c !== void 0 ? _c : undefined,
|
|
145
|
+
dayOfMonth: (_d = pattern === null || pattern === void 0 ? void 0 : pattern.dayOfMonth) !== null && _d !== void 0 ? _d : undefined,
|
|
146
|
+
month: (_e = pattern === null || pattern === void 0 ? void 0 : pattern.month) !== null && _e !== void 0 ? _e : undefined,
|
|
147
|
+
firstDayOfWeek: (_f = pattern === null || pattern === void 0 ? void 0 : pattern.firstDayOfWeek) !== null && _f !== void 0 ? _f : undefined,
|
|
148
|
+
index: (_g = pattern === null || pattern === void 0 ? void 0 : pattern.index) !== null && _g !== void 0 ? _g : undefined,
|
|
149
|
+
},
|
|
150
|
+
range: {
|
|
151
|
+
type: (_h = range === null || range === void 0 ? void 0 : range.type) !== null && _h !== void 0 ? _h : 'noEnd',
|
|
152
|
+
startDate: (_j = range === null || range === void 0 ? void 0 : range.startDate) !== null && _j !== void 0 ? _j : '',
|
|
153
|
+
endDate: (_k = range === null || range === void 0 ? void 0 : range.endDate) !== null && _k !== void 0 ? _k : undefined,
|
|
154
|
+
numberOfOccurrences: (_l = range === null || range === void 0 ? void 0 : range.numberOfOccurrences) !== null && _l !== void 0 ? _l : undefined,
|
|
155
|
+
recurrenceTimeZone: (_m = range === null || range === void 0 ? void 0 : range.recurrenceTimeZone) !== null && _m !== void 0 ? _m : undefined,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
exports.RecurrenceService = RecurrenceService;
|
|
161
|
+
exports.RecurrenceService = RecurrenceService = RecurrenceService_1 = __decorate([
|
|
162
|
+
(0, common_1.Injectable)(),
|
|
163
|
+
__metadata("design:paramtypes", [calendar_service_1.CalendarService])
|
|
164
|
+
], RecurrenceService);
|
|
165
|
+
//# sourceMappingURL=recurrence.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recurrence.service.js","sourceRoot":"","sources":["../../../src/services/calendar/recurrence.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AAGpD,yDAAqD;AAW9C,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAG5B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAF5C,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAEG,CAAC;IAQjE,YAAY,CAAC,KAAY;;QACvB,MAAM,SAAS,GAAqB,MAAA,KAAK,CAAC,IAAI,mCAAI,gBAAgB,CAAC;QAEnE,MAAM,SAAS,GAA0B;YACvC,UAAU,EAAE,MAAA,KAAK,CAAC,EAAE,mCAAI,EAAE;YAC1B,SAAS;YACT,KAAK,EAAE;gBACL,QAAQ,EAAE,MAAA,MAAA,KAAK,CAAC,KAAK,0CAAE,QAAQ,mCAAI,EAAE;gBACrC,QAAQ,EAAE,MAAA,MAAA,KAAK,CAAC,KAAK,0CAAE,QAAQ,mCAAI,EAAE;aACtC;YACD,GAAG,EAAE;gBACH,QAAQ,EAAE,MAAA,MAAA,KAAK,CAAC,GAAG,0CAAE,QAAQ,mCAAI,EAAE;gBACnC,QAAQ,EAAE,MAAA,MAAA,KAAK,CAAC,GAAG,0CAAE,QAAQ,mCAAI,EAAE;aACpC;YACD,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE;YAC5B,WAAW,EAAE,MAAA,KAAK,CAAC,WAAW,mCAAI,EAAE;YACpC,QAAQ,EAAE,MAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,WAAW,mCAAI,SAAS;YAClD,MAAM,EAAE,MAAA,KAAK,CAAC,MAAM,mCAAI,SAAS;YACjC,SAAS,EAAE,MAAA,KAAK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