mblabs-roccato-backend-commons 1.0.55 → 1.0.57

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.
@@ -64,6 +64,35 @@ export declare namespace AzureApplicationInsights {
64
64
  }
65
65
  }
66
66
  }
67
+ export declare namespace AzureCalendar {
68
+ namespace GetEvents {
69
+ interface Request {
70
+ data: {
71
+ account: string;
72
+ accessToken: string;
73
+ refreshToken: string;
74
+ startDate?: Date;
75
+ endDate?: Date;
76
+ };
77
+ credentials: Credentials;
78
+ }
79
+ interface Response {
80
+ events: {
81
+ title?: string;
82
+ description?: string;
83
+ type?: string;
84
+ status?: string;
85
+ createdAt?: string | Date;
86
+ startAt?: string | Date;
87
+ endAt?: string | Date;
88
+ organizer?: {
89
+ name?: string;
90
+ email?: string;
91
+ } | null;
92
+ }[];
93
+ }
94
+ }
95
+ }
67
96
  export declare namespace AzureCommunication {
68
97
  namespace SendMail {
69
98
  interface Request {
@@ -168,6 +197,9 @@ export interface IAzureApplicationInsightsService {
168
197
  trackException(req: AzureApplicationInsights.TrackException.Request): Promise<void>;
169
198
  trackMetric(req: AzureApplicationInsights.TrackMetric.Request): Promise<void>;
170
199
  }
200
+ export interface IAzureCalendarService {
201
+ getEvents(req: AzureCalendar.GetEvents.Request): Promise<AzureCalendar.GetEvents.Response>;
202
+ }
171
203
  export interface IAzureCommunicationService {
172
204
  sendMail(req: AzureCommunication.SendMail.Request): Promise<void>;
173
205
  sendSMS(req: AzureCommunication.SendSMS.Request): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import 'isomorphic-fetch';
2
+ import { AzureCalendar, IAzureCalendarService } from '../../interfaces';
3
+ declare class AzuerCalendarService implements IAzureCalendarService {
4
+ getEvents({ credentials, data, }: AzureCalendar.GetEvents.Request): Promise<AzureCalendar.GetEvents.Response>;
5
+ }
6
+ declare const _default: AzuerCalendarService;
7
+ export default _default;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ require("isomorphic-fetch");
7
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
8
+ const date_1 = __importDefault(require("../date"));
9
+ class AzuerCalendarService {
10
+ async getEvents({ credentials, data, }) {
11
+ const client = microsoft_graph_client_1.Client.init({
12
+ authProvider: (done) => { done(null, data.accessToken); },
13
+ });
14
+ const { startDate: startDateDefault, endDate: endDateDefault, } = date_1.default.getStartAndEndOfYear();
15
+ const { value: items } = await client
16
+ .api(`/users/${data.account}/calendarview`)
17
+ .query({
18
+ 'startDateTime': data.startDate ? date_1.default.toISO(data.startDate) : startDateDefault,
19
+ 'endDateTime': data.endDate ? date_1.default.toISO(data.endDate) : endDateDefault,
20
+ '$select': 'subject,start,end,location,organizer,type,responseStatus',
21
+ '$orderby': 'start/dateTime',
22
+ })
23
+ .get();
24
+ return {
25
+ events: items.map((item) => ({
26
+ title: item.subject,
27
+ description: '',
28
+ type: item.type,
29
+ status: item.responseStatus?.response,
30
+ createdAt: item.createdDateTime,
31
+ startAt: item.start.dateTime,
32
+ endAt: item.end?.dateTime,
33
+ organizer: {
34
+ name: item.organizer?.emailAddress?.name,
35
+ email: item.organizer?.emailAddress?.address,
36
+ },
37
+ })),
38
+ };
39
+ }
40
+ }
41
+ exports.default = new AzuerCalendarService();
@@ -1,6 +1,7 @@
1
1
  import AzureApplicationInsightsService from './application-insights';
2
2
  import AzureAuthService from './auth';
3
+ import AzureCalendarService from './calendar';
3
4
  import AzureCommunicationService from './communication';
4
5
  import AzureKeyVaultService from './keyvault';
5
6
  import AzureStorageBlobService from './storage-blob';
6
- export { AzureAuthService, AzureApplicationInsightsService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService, };
7
+ export { AzureAuthService, AzureApplicationInsightsService, AzureCalendarService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService, };
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AzureStorageBlobService = exports.AzureKeyVaultService = exports.AzureCommunicationService = exports.AzureApplicationInsightsService = exports.AzureAuthService = void 0;
6
+ exports.AzureStorageBlobService = exports.AzureKeyVaultService = exports.AzureCommunicationService = exports.AzureCalendarService = exports.AzureApplicationInsightsService = exports.AzureAuthService = void 0;
7
7
  const application_insights_1 = __importDefault(require("./application-insights"));
8
8
  exports.AzureApplicationInsightsService = application_insights_1.default;
9
9
  const auth_1 = __importDefault(require("./auth"));
10
10
  exports.AzureAuthService = auth_1.default;
11
+ const calendar_1 = __importDefault(require("./calendar"));
12
+ exports.AzureCalendarService = calendar_1.default;
11
13
  const communication_1 = __importDefault(require("./communication"));
12
14
  exports.AzureCommunicationService = communication_1.default;
13
15
  const keyvault_1 = __importDefault(require("./keyvault"));
@@ -1,6 +1,7 @@
1
1
  declare class DateService {
2
- toDate(inp: Date | string, format?: string): Date;
3
- toFormat(inp: Date | string, format?: string): string;
2
+ toDate(inp: string | Date, format?: string): Date;
3
+ toFormat(inp: string | Date, format?: string): string;
4
+ toISO(inp: string | Date): string;
4
5
  convertTimestampToDate(inp: string | number): Date;
5
6
  getCurrent(): string;
6
7
  getCurrentDate(): Date;
@@ -11,20 +12,24 @@ declare class DateService {
11
12
  minusHours(start: Date, toRemove: number): Date;
12
13
  minusMinutes(start: Date, toRemove: number): Date;
13
14
  isValidDate(inp: string, format?: string): boolean;
14
- getStartAndEndOfDay(inp?: Date | string, useUTC?: boolean): {
15
+ getStartAndEndOfDay(inp?: string | Date, useUTC?: boolean): {
15
16
  startOfDay: Date;
16
17
  endOfDay: Date;
17
18
  };
18
19
  getStartOfDay(inp: string, format?: string): string;
19
20
  getEndOfDay(inp: string, format?: string): string;
20
- getStartAndEndOfMonth(inp?: string): {
21
+ getStartAndEndOfMonth(inp?: string | Date): {
22
+ startDate: string;
23
+ endDate: string;
24
+ };
25
+ getStartAndEndOfYear(inp?: string | Date): {
21
26
  startDate: string;
22
27
  endDate: string;
23
28
  };
24
29
  getCurrentTimestamp(): number;
25
30
  getMillisFromFormattedDate(date: string, format?: string): number;
26
31
  getMonthsInRange(startDate: Date, endDate: Date): string[];
27
- isSameDay(inp: Date | string, compare?: Date): boolean;
32
+ isSameDay(inp: string | Date, compare?: Date): boolean;
28
33
  isToday(date: Date): boolean;
29
34
  }
30
35
  declare const _default: DateService;
@@ -21,6 +21,12 @@ class DateService {
21
21
  }
22
22
  return luxon_1.DateTime.fromISO(inp).toFormat(format);
23
23
  }
24
+ toISO(inp) {
25
+ if (inp instanceof Date) {
26
+ return luxon_1.DateTime.fromJSDate(inp).toISO();
27
+ }
28
+ return luxon_1.DateTime.fromISO(inp).toISO();
29
+ }
24
30
  convertTimestampToDate(inp) {
25
31
  const timestamp = typeof inp === 'string' ? parseInt(inp, 10) : inp;
26
32
  return luxon_1.DateTime.fromMillis(timestamp).toJSDate();
@@ -81,14 +87,23 @@ class DateService {
81
87
  const date = luxon_1.DateTime.fromISO(inp);
82
88
  return date.endOf('day').toFormat(format);
83
89
  }
84
- getStartAndEndOfMonth(inp) {
85
- const date = luxon_1.DateTime.fromISO(inp || this.getCurrent());
86
- const startDate = date.startOf('month').toISODate();
87
- const endDate = date
88
- .plus({ months: 1 })
89
- .startOf('month')
90
- .minus({ days: 1 }).toISODate();
91
- return { startDate, endDate };
90
+ getStartAndEndOfMonth(inp = this.getCurrentDate()) {
91
+ const date = inp instanceof Date
92
+ ? luxon_1.DateTime.fromJSDate(inp)
93
+ : luxon_1.DateTime.fromISO(inp);
94
+ return {
95
+ startDate: date.startOf('month').toISODate(),
96
+ endDate: date.plus({ months: 1 }).startOf('month').minus({ days: 1 }).toISODate(),
97
+ };
98
+ }
99
+ getStartAndEndOfYear(inp = this.getCurrentDate()) {
100
+ const date = inp instanceof Date
101
+ ? luxon_1.DateTime.fromJSDate(inp)
102
+ : luxon_1.DateTime.fromISO(inp);
103
+ return {
104
+ startDate: date.startOf('year').toISODate(),
105
+ endDate: date.endOf('year').toISODate(),
106
+ };
92
107
  }
93
108
  getCurrentTimestamp() {
94
109
  return luxon_1.DateTime.now().toMillis();
@@ -12,21 +12,20 @@ class GoogleCalendarService {
12
12
  .calendar({ version: 'v3', auth: client })
13
13
  .events
14
14
  .list();
15
- const events = items.map(item => ({
16
- title: item.summary,
17
- description: item.description,
18
- type: item.eventType,
19
- status: item.status,
20
- createdAt: item.created,
21
- startAt: item.start?.dateTime,
22
- endAt: item.end?.dateTime,
23
- organizer: {
24
- name: item.organizer?.displayName,
25
- email: item.organizer?.email,
26
- },
27
- }));
28
15
  return {
29
- events,
16
+ events: items.map(item => ({
17
+ title: item.summary,
18
+ description: item.description,
19
+ type: item.eventType,
20
+ status: item.status,
21
+ createdAt: item.created,
22
+ startAt: item.start?.dateTime,
23
+ endAt: item.end?.dateTime,
24
+ organizer: {
25
+ name: item.organizer?.displayName,
26
+ email: item.organizer?.email,
27
+ },
28
+ })),
30
29
  };
31
30
  }
32
31
  }
@@ -1,5 +1,5 @@
1
1
  import { AmazonCloudwatchService, AmazonPinpointService, AmazonS3Service, AmazonSecretManagerService, AmazonSQSService } from './aws';
2
- import { AzureApplicationInsightsService, AzureAuthService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService } from './azure';
2
+ import { AzureApplicationInsightsService, AzureAuthService, AzureCalendarService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService } from './azure';
3
3
  import DateService from './date';
4
4
  import FileService from './file';
5
5
  import FirebaseService from './firebase';
@@ -12,4 +12,4 @@ import NodeMailerService from './nodemailer';
12
12
  import RabbitMQService from './rabbit';
13
13
  import RedisService from './redis';
14
14
  import SendgridService from './sendgrid';
15
- export { AmazonCloudwatchService, AmazonPinpointService, AmazonS3Service, AmazonSecretManagerService, AmazonSQSService, AzureApplicationInsightsService, AzureAuthService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService, DateService, FileService, FirebaseService, GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, GrafanaService, I18nService, KafkaService, KeycloakService, NodeMailerService, RabbitMQService, RedisService, SendgridService, };
15
+ export { AmazonCloudwatchService, AmazonPinpointService, AmazonS3Service, AmazonSecretManagerService, AmazonSQSService, AzureApplicationInsightsService, AzureAuthService, AzureCalendarService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService, DateService, FileService, FirebaseService, GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, GrafanaService, I18nService, KafkaService, KeycloakService, NodeMailerService, RabbitMQService, RedisService, SendgridService, };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SendgridService = exports.RedisService = exports.RabbitMQService = exports.NodeMailerService = exports.KeycloakService = exports.KafkaService = exports.I18nService = exports.GrafanaService = exports.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleCalendarService = exports.GoogleAuthService = exports.FirebaseService = exports.FileService = exports.DateService = exports.AzureStorageBlobService = exports.AzureKeyVaultService = exports.AzureCommunicationService = exports.AzureAuthService = exports.AzureApplicationInsightsService = exports.AmazonSQSService = exports.AmazonSecretManagerService = exports.AmazonS3Service = exports.AmazonPinpointService = exports.AmazonCloudwatchService = void 0;
6
+ exports.SendgridService = exports.RedisService = exports.RabbitMQService = exports.NodeMailerService = exports.KeycloakService = exports.KafkaService = exports.I18nService = exports.GrafanaService = exports.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleCalendarService = exports.GoogleAuthService = exports.FirebaseService = exports.FileService = exports.DateService = exports.AzureStorageBlobService = exports.AzureKeyVaultService = exports.AzureCommunicationService = exports.AzureCalendarService = exports.AzureAuthService = exports.AzureApplicationInsightsService = exports.AmazonSQSService = exports.AmazonSecretManagerService = exports.AmazonS3Service = exports.AmazonPinpointService = exports.AmazonCloudwatchService = void 0;
7
7
  const aws_1 = require("./aws");
8
8
  Object.defineProperty(exports, "AmazonCloudwatchService", { enumerable: true, get: function () { return aws_1.AmazonCloudwatchService; } });
9
9
  Object.defineProperty(exports, "AmazonPinpointService", { enumerable: true, get: function () { return aws_1.AmazonPinpointService; } });
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "AmazonSQSService", { enumerable: true, get: func
13
13
  const azure_1 = require("./azure");
14
14
  Object.defineProperty(exports, "AzureApplicationInsightsService", { enumerable: true, get: function () { return azure_1.AzureApplicationInsightsService; } });
15
15
  Object.defineProperty(exports, "AzureAuthService", { enumerable: true, get: function () { return azure_1.AzureAuthService; } });
16
+ Object.defineProperty(exports, "AzureCalendarService", { enumerable: true, get: function () { return azure_1.AzureCalendarService; } });
16
17
  Object.defineProperty(exports, "AzureCommunicationService", { enumerable: true, get: function () { return azure_1.AzureCommunicationService; } });
17
18
  Object.defineProperty(exports, "AzureKeyVaultService", { enumerable: true, get: function () { return azure_1.AzureKeyVaultService; } });
18
19
  Object.defineProperty(exports, "AzureStorageBlobService", { enumerable: true, get: function () { return azure_1.AzureStorageBlobService; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mblabs-roccato-backend-commons",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -67,6 +67,7 @@
67
67
  "google-auth-library": "^10.3.0",
68
68
  "googleapis": "^148.0.0",
69
69
  "i18next": "^25.3.6",
70
+ "isomorphic-fetch": "^3.0.0",
70
71
  "kafkajs": "^2.2.4",
71
72
  "luxon": "^3.6.1",
72
73
  "nodemailer": "^7.0.3",
@@ -77,6 +78,7 @@
77
78
  "devDependencies": {
78
79
  "@commitlint/cli": "^19.8.0",
79
80
  "@commitlint/config-conventional": "^19.8.0",
81
+ "@microsoft/microsoft-graph-types": "^2.40.0",
80
82
  "@types/amqplib": "^0.10.7",
81
83
  "@types/express": "^5.0.1",
82
84
  "@types/luxon": "^3.6.2",
@@ -43,7 +43,9 @@ export namespace AzureApplicationInsights {
43
43
  export interface Request {
44
44
  data: {
45
45
  name: string;
46
- properties?: { [key: string]: string };
46
+ properties?: {
47
+ [key: string]: string;
48
+ };
47
49
  };
48
50
  credentials: Credentials;
49
51
  }
@@ -69,6 +71,37 @@ export namespace AzureApplicationInsights {
69
71
  }
70
72
  }
71
73
 
74
+ export namespace AzureCalendar {
75
+ export namespace GetEvents {
76
+ export interface Request {
77
+ data: {
78
+ account: string;
79
+ accessToken: string;
80
+ refreshToken: string;
81
+ startDate?: Date;
82
+ endDate?: Date;
83
+ };
84
+ credentials: Credentials;
85
+ }
86
+
87
+ export interface Response {
88
+ events: {
89
+ title?: string;
90
+ description?: string;
91
+ type?: string;
92
+ status?: string;
93
+ createdAt?: string | Date;
94
+ startAt?: string | Date;
95
+ endAt?: string | Date;
96
+ organizer?: {
97
+ name?: string;
98
+ email?: string;
99
+ } | null;
100
+ }[];
101
+ }
102
+ }
103
+ }
104
+
72
105
  export namespace AzureCommunication {
73
106
  export namespace SendMail {
74
107
  export interface Request {
@@ -185,6 +218,10 @@ export interface IAzureApplicationInsightsService {
185
218
  trackMetric(req: AzureApplicationInsights.TrackMetric.Request): Promise<void>;
186
219
  }
187
220
 
221
+ export interface IAzureCalendarService {
222
+ getEvents(req: AzureCalendar.GetEvents.Request): Promise<AzureCalendar.GetEvents.Response>;
223
+ }
224
+
188
225
  export interface IAzureCommunicationService {
189
226
  sendMail(req: AzureCommunication.SendMail.Request): Promise<void>;
190
227
  sendSMS(req: AzureCommunication.SendSMS.Request): Promise<void>;
@@ -0,0 +1,51 @@
1
+ import 'isomorphic-fetch';
2
+
3
+ import { Client } from '@microsoft/microsoft-graph-client';
4
+ import { Event } from '@microsoft/microsoft-graph-types';
5
+
6
+ import { AzureCalendar, IAzureCalendarService } from '../../interfaces';
7
+ import DateService from '../date';
8
+
9
+ class AzuerCalendarService implements IAzureCalendarService {
10
+ async getEvents ({
11
+ credentials,
12
+ data,
13
+ }: AzureCalendar.GetEvents.Request): Promise<AzureCalendar.GetEvents.Response> {
14
+ const client = Client.init({
15
+ authProvider: (done) => { done(null, data.accessToken); },
16
+ });
17
+
18
+ const {
19
+ startDate: startDateDefault,
20
+ endDate: endDateDefault,
21
+ } = DateService.getStartAndEndOfYear();
22
+
23
+ const { value: items } = await client
24
+ .api(`/users/${data.account}/calendarview`)
25
+ .query({
26
+ 'startDateTime': data.startDate ? DateService.toISO(data.startDate) : startDateDefault,
27
+ 'endDateTime': data.endDate ? DateService.toISO(data.endDate) : endDateDefault,
28
+ '$select': 'subject,start,end,location,organizer,type,responseStatus',
29
+ '$orderby': 'start/dateTime',
30
+ })
31
+ .get();
32
+
33
+ return {
34
+ events: (items as Event[]).map((item) => ({
35
+ title: item.subject,
36
+ description: '',
37
+ type: item.type,
38
+ status: item.responseStatus?.response,
39
+ createdAt: item.createdDateTime,
40
+ startAt: item.start.dateTime,
41
+ endAt: item.end?.dateTime,
42
+ organizer: {
43
+ name: item.organizer?.emailAddress?.name,
44
+ email: item.organizer?.emailAddress?.address,
45
+ },
46
+ })),
47
+ };
48
+ }
49
+ }
50
+
51
+ export default new AzuerCalendarService();
@@ -1,5 +1,6 @@
1
1
  import AzureApplicationInsightsService from './application-insights';
2
2
  import AzureAuthService from './auth';
3
+ import AzureCalendarService from './calendar';
3
4
  import AzureCommunicationService from './communication';
4
5
  import AzureKeyVaultService from './keyvault';
5
6
  import AzureStorageBlobService from './storage-blob';
@@ -7,6 +8,7 @@ import AzureStorageBlobService from './storage-blob';
7
8
  export {
8
9
  AzureAuthService,
9
10
  AzureApplicationInsightsService,
11
+ AzureCalendarService,
10
12
  AzureCommunicationService,
11
13
  AzureKeyVaultService,
12
14
  AzureStorageBlobService,
@@ -3,7 +3,7 @@ import { DateTime } from 'luxon';
3
3
  import { DATE } from '../constants';
4
4
 
5
5
  class DateService {
6
- public toDate (inp: Date | string, format = DATE.SYSTEM.COMMON_DATE): Date {
6
+ public toDate (inp: string | Date, format = DATE.SYSTEM.COMMON_DATE): Date {
7
7
  if (inp instanceof Date) {
8
8
  return inp;
9
9
  }
@@ -19,7 +19,7 @@ class DateService {
19
19
  return DateTime.local().toJSDate();
20
20
  }
21
21
 
22
- public toFormat (inp: Date | string, format = DATE.SYSTEM.COMMON_DATE): string {
22
+ public toFormat (inp: string | Date, format = DATE.SYSTEM.COMMON_DATE): string {
23
23
  if (inp instanceof Date) {
24
24
  return DateTime.fromJSDate(inp).toFormat(format);
25
25
  }
@@ -27,6 +27,14 @@ class DateService {
27
27
  return DateTime.fromISO(inp).toFormat(format);
28
28
  }
29
29
 
30
+ public toISO (inp: string | Date) {
31
+ if (inp instanceof Date) {
32
+ return DateTime.fromJSDate(inp).toISO();
33
+ }
34
+
35
+ return DateTime.fromISO(inp).toISO();
36
+ }
37
+
30
38
  public convertTimestampToDate (inp: string | number): Date {
31
39
  const timestamp = typeof inp === 'string' ? parseInt(inp, 10) : inp;
32
40
  return DateTime.fromMillis(timestamp).toJSDate();
@@ -69,7 +77,7 @@ class DateService {
69
77
  }
70
78
 
71
79
  public getStartAndEndOfDay (
72
- inp: Date | string = this.getCurrentDate(),
80
+ inp: string | Date = this.getCurrentDate(),
73
81
  useUTC = false
74
82
  ) {
75
83
  const date = inp instanceof Date
@@ -106,17 +114,26 @@ class DateService {
106
114
  return date.endOf('day').toFormat(format);
107
115
  }
108
116
 
109
- public getStartAndEndOfMonth (inp?: string) {
110
- const date = DateTime.fromISO(inp || this.getCurrent());
117
+ public getStartAndEndOfMonth (inp: string |Date = this.getCurrentDate()) {
118
+ const date = inp instanceof Date
119
+ ? DateTime.fromJSDate(inp)
120
+ : DateTime.fromISO(inp);
111
121
 
112
- const startDate = date.startOf('month').toISODate();
122
+ return {
123
+ startDate: date.startOf('month').toISODate(),
124
+ endDate: date.plus({ months: 1 }).startOf('month').minus({ days: 1 }).toISODate(),
125
+ };
126
+ }
113
127
 
114
- const endDate = date
115
- .plus({ months: 1 })
116
- .startOf('month')
117
- .minus({ days: 1 }).toISODate();
128
+ public getStartAndEndOfYear (inp: string | Date = this.getCurrentDate()) {
129
+ const date = inp instanceof Date
130
+ ? DateTime.fromJSDate(inp)
131
+ : DateTime.fromISO(inp);
118
132
 
119
- return { startDate, endDate };
133
+ return {
134
+ startDate: date.startOf('year').toISODate(),
135
+ endDate: date.endOf('year').toISODate(),
136
+ };
120
137
  }
121
138
 
122
139
  public getCurrentTimestamp (): number {
@@ -143,7 +160,7 @@ class DateService {
143
160
  return months;
144
161
  }
145
162
 
146
- public isSameDay (inp: Date | string, compare = this.getCurrentDate()): boolean {
163
+ public isSameDay (inp: string | Date, compare = this.getCurrentDate()): boolean {
147
164
  const startDate = DateTime.fromJSDate(this.toDate(inp)).startOf('day');
148
165
  const endDate = DateTime.fromJSDate(this.toDate(compare)).startOf('day');
149
166
 
@@ -23,22 +23,20 @@ class GoogleCalendarService implements IGoogleCalendarService {
23
23
  .events
24
24
  .list();
25
25
 
26
- const events = items.map(item => ({
27
- title: item.summary,
28
- description: item.description,
29
- type: item.eventType,
30
- status: item.status,
31
- createdAt: item.created,
32
- startAt: item.start?.dateTime,
33
- endAt: item.end?.dateTime,
34
- organizer: {
35
- name: item.organizer?.displayName,
36
- email: item.organizer?.email,
37
- },
38
- }));
39
-
40
26
  return {
41
- events,
27
+ events: items.map(item => ({
28
+ title: item.summary,
29
+ description: item.description,
30
+ type: item.eventType,
31
+ status: item.status,
32
+ createdAt: item.created,
33
+ startAt: item.start?.dateTime,
34
+ endAt: item.end?.dateTime,
35
+ organizer: {
36
+ name: item.organizer?.displayName,
37
+ email: item.organizer?.email,
38
+ },
39
+ })),
42
40
  };
43
41
  }
44
42
  }
@@ -8,6 +8,7 @@ import {
8
8
  import {
9
9
  AzureApplicationInsightsService,
10
10
  AzureAuthService,
11
+ AzureCalendarService,
11
12
  AzureCommunicationService,
12
13
  AzureKeyVaultService,
13
14
  AzureStorageBlobService,
@@ -39,6 +40,7 @@ export {
39
40
  AmazonSQSService,
40
41
  AzureApplicationInsightsService,
41
42
  AzureAuthService,
43
+ AzureCalendarService,
42
44
  AzureCommunicationService,
43
45
  AzureKeyVaultService,
44
46
  AzureStorageBlobService,
package/yarn.lock CHANGED
@@ -2107,6 +2107,11 @@
2107
2107
  "@babel/runtime" "^7.12.5"
2108
2108
  tslib "^2.2.0"
2109
2109
 
2110
+ "@microsoft/microsoft-graph-types@^2.40.0":
2111
+ version "2.40.0"
2112
+ resolved "https://registry.yarnpkg.com/@microsoft/microsoft-graph-types/-/microsoft-graph-types-2.40.0.tgz#65f51600ab45ace97d7b1368c47f9e0f835fddca"
2113
+ integrity sha512-1fcPVrB/NkbNcGNfCy+Cgnvwxt6/sbIEEFgZHFBJ670zYLegENYJF8qMo7x3LqBjWX2/Eneq5BVVRCLTmlJN+g==
2114
+
2110
2115
  "@nodelib/fs.scandir@2.1.5":
2111
2116
  version "2.1.5"
2112
2117
  resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -5657,6 +5662,14 @@ isexe@^2.0.0:
5657
5662
  resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
5658
5663
  integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
5659
5664
 
5665
+ isomorphic-fetch@^3.0.0:
5666
+ version "3.0.0"
5667
+ resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz#0267b005049046d2421207215d45d6a262b8b8b4"
5668
+ integrity sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==
5669
+ dependencies:
5670
+ node-fetch "^2.6.1"
5671
+ whatwg-fetch "^3.4.1"
5672
+
5660
5673
  jackspeak@^3.1.2:
5661
5674
  version "3.4.3"
5662
5675
  resolved "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a"
@@ -6110,7 +6123,7 @@ node-domexception@^1.0.0:
6110
6123
  resolved "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5"
6111
6124
  integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==
6112
6125
 
6113
- node-fetch@^2.6.9, node-fetch@^2.7.0:
6126
+ node-fetch@^2.6.1, node-fetch@^2.6.9, node-fetch@^2.7.0:
6114
6127
  version "2.7.0"
6115
6128
  resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
6116
6129
  integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
@@ -7396,6 +7409,11 @@ websocket-extensions@>=0.1.1:
7396
7409
  resolved "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42"
7397
7410
  integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==
7398
7411
 
7412
+ whatwg-fetch@^3.4.1:
7413
+ version "3.6.20"
7414
+ resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70"
7415
+ integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==
7416
+
7399
7417
  whatwg-url@^5.0.0:
7400
7418
  version "5.0.0"
7401
7419
  resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"