mblabs-roccato-backend-commons 1.0.51 → 1.0.53

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.
@@ -22,6 +22,32 @@ export declare namespace GoogleAuth {
22
22
  }
23
23
  }
24
24
  }
25
+ export declare namespace GoogleCalendar {
26
+ namespace GetEvents {
27
+ interface Request {
28
+ data: {
29
+ accessToken: string;
30
+ refreshToken: string;
31
+ };
32
+ credentials: Credentials;
33
+ }
34
+ interface Response {
35
+ events: {
36
+ title?: string;
37
+ description?: string;
38
+ type?: string;
39
+ status?: string;
40
+ createdAt?: string | Date;
41
+ startAt?: string | Date;
42
+ endAt?: string | Date;
43
+ organizer?: {
44
+ name?: string;
45
+ email?: string;
46
+ } | null;
47
+ }[];
48
+ }
49
+ }
50
+ }
25
51
  export declare namespace GoogleStorage {
26
52
  namespace GetSignedUrl {
27
53
  interface Request {
@@ -80,3 +106,6 @@ export interface IGoogleStorageService {
80
106
  export interface IGoogleAuthService {
81
107
  refreshAccess(req: GoogleAuth.RefreshAccess.Request): Promise<GoogleAuth.RefreshAccess.Response>;
82
108
  }
109
+ export interface IGoogleCalendarService {
110
+ getEvents(req: GoogleCalendar.GetEvents.Request): Promise<GoogleCalendar.GetEvents.Response>;
111
+ }
@@ -1,10 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleStorage = void 0;
4
- var GoogleStorage;
5
- (function (GoogleStorage) {
6
- let GetSignedUrl;
7
- (function (GetSignedUrl) {
8
- ;
9
- })(GetSignedUrl = GoogleStorage.GetSignedUrl || (GoogleStorage.GetSignedUrl = {}));
10
- })(GoogleStorage || (exports.GoogleStorage = GoogleStorage = {}));
@@ -0,0 +1,6 @@
1
+ import { GoogleCalendar, IGoogleCalendarService } from '../../interfaces';
2
+ declare class GoogleCalendarService implements IGoogleCalendarService {
3
+ getEvents({ credentials, data, }: GoogleCalendar.GetEvents.Request): Promise<GoogleCalendar.GetEvents.Response>;
4
+ }
5
+ declare const _default: GoogleCalendarService;
6
+ export default _default;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const googleapis_1 = require("googleapis");
4
+ class GoogleCalendarService {
5
+ async getEvents({ credentials, data, }) {
6
+ const client = new googleapis_1.google.auth.OAuth2(credentials.clientId, credentials.clientSecret, credentials.redirectUri);
7
+ client.setCredentials({
8
+ access_token: data.accessToken,
9
+ refresh_token: data.refreshToken,
10
+ });
11
+ const { data: { items } } = await googleapis_1.google
12
+ .calendar({ version: 'v3', auth: client })
13
+ .events
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
+ return {
29
+ events,
30
+ };
31
+ }
32
+ }
33
+ exports.default = new GoogleCalendarService();
@@ -1,5 +1,6 @@
1
1
  import GoogleAuthService from './auth';
2
+ import GoogleCalendarService from './calendar';
2
3
  import GoogleSecretsService from './secrets';
3
4
  import GoogleSheetsService from './sheets';
4
5
  import GoogleStorageService from './storage';
5
- export { GoogleAuthService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, };
6
+ export { GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, };
@@ -3,9 +3,11 @@ 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.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleAuthService = void 0;
6
+ exports.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleCalendarService = exports.GoogleAuthService = void 0;
7
7
  const auth_1 = __importDefault(require("./auth"));
8
8
  exports.GoogleAuthService = auth_1.default;
9
+ const calendar_1 = __importDefault(require("./calendar"));
10
+ exports.GoogleCalendarService = calendar_1.default;
9
11
  const secrets_1 = __importDefault(require("./secrets"));
10
12
  exports.GoogleSecretsService = secrets_1.default;
11
13
  const sheets_1 = __importDefault(require("./sheets"));
@@ -3,7 +3,7 @@ import { AzureApplicationInsightsService, AzureCommunicationService, AzureKeyVau
3
3
  import DateService from './date';
4
4
  import FileService from './file';
5
5
  import FirebaseService from './firebase';
6
- import { GoogleAuthService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService } from './gcp';
6
+ import { GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService } from './gcp';
7
7
  import GrafanaService from './grafana';
8
8
  import I18nService from './i18n';
9
9
  import KafkaService from './kafka';
@@ -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, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService, DateService, FileService, FirebaseService, GoogleAuthService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, GrafanaService, I18nService, KafkaService, KeycloakService, NodeMailerService, RabbitMQService, RedisService, SendgridService, };
15
+ export { AmazonCloudwatchService, AmazonPinpointService, AmazonS3Service, AmazonSecretManagerService, AmazonSQSService, AzureApplicationInsightsService, 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.GoogleAuthService = exports.FirebaseService = exports.FileService = exports.DateService = exports.AzureStorageBlobService = exports.AzureKeyVaultService = exports.AzureCommunicationService = 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.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; } });
@@ -23,6 +23,7 @@ const firebase_1 = __importDefault(require("./firebase"));
23
23
  exports.FirebaseService = firebase_1.default;
24
24
  const gcp_1 = require("./gcp");
25
25
  Object.defineProperty(exports, "GoogleAuthService", { enumerable: true, get: function () { return gcp_1.GoogleAuthService; } });
26
+ Object.defineProperty(exports, "GoogleCalendarService", { enumerable: true, get: function () { return gcp_1.GoogleCalendarService; } });
26
27
  Object.defineProperty(exports, "GoogleSecretsService", { enumerable: true, get: function () { return gcp_1.GoogleSecretsService; } });
27
28
  Object.defineProperty(exports, "GoogleSheetsService", { enumerable: true, get: function () { return gcp_1.GoogleSheetsService; } });
28
29
  Object.defineProperty(exports, "GoogleStorageService", { enumerable: true, get: function () { return gcp_1.GoogleStorageService; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mblabs-roccato-backend-commons",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -55,6 +55,7 @@
55
55
  "@google-cloud/secret-manager": "^6.0.1",
56
56
  "@google-cloud/storage": "^7.16.0",
57
57
  "@keycloak/keycloak-admin-client": "^26.3.1",
58
+ "@microsoft/microsoft-graph-client": "^3.0.7",
58
59
  "@sendgrid/client": "^8.1.5",
59
60
  "@sendgrid/mail": "^8.1.5",
60
61
  "amqplib": "^0.10.8",
@@ -26,6 +26,34 @@ export namespace GoogleAuth {
26
26
  }
27
27
  }
28
28
 
29
+ export namespace GoogleCalendar {
30
+ export namespace GetEvents {
31
+ export interface Request {
32
+ data: {
33
+ accessToken: string;
34
+ refreshToken: string;
35
+ };
36
+ credentials: Credentials;
37
+ }
38
+
39
+ export interface Response {
40
+ events: {
41
+ title?: string;
42
+ description?: string;
43
+ type?: string;
44
+ status?: string;
45
+ createdAt?: string | Date;
46
+ startAt?: string | Date;
47
+ endAt?: string | Date;
48
+ organizer?: {
49
+ name?: string;
50
+ email?: string;
51
+ } | null;
52
+ }[];
53
+ }
54
+ }
55
+ }
56
+
29
57
  export namespace GoogleStorage {
30
58
  export namespace GetSignedUrl {
31
59
  export interface Request {
@@ -34,11 +62,11 @@ export namespace GoogleStorage {
34
62
  bucket: string;
35
63
  folder?: string;
36
64
  isUpload?: boolean;
37
- expirationSeconds?: number
38
- contentType?: string
65
+ expirationSeconds?: number;
66
+ contentType?: string;
39
67
  };
40
- credentials: Credentials
41
- };
68
+ credentials: Credentials;
69
+ }
42
70
 
43
71
  export interface Response {
44
72
  url: string;
@@ -93,3 +121,7 @@ export interface IGoogleStorageService {
93
121
  export interface IGoogleAuthService {
94
122
  refreshAccess(req: GoogleAuth.RefreshAccess.Request): Promise<GoogleAuth.RefreshAccess.Response>;
95
123
  }
124
+
125
+ export interface IGoogleCalendarService {
126
+ getEvents(req: GoogleCalendar.GetEvents.Request): Promise<GoogleCalendar.GetEvents.Response>;
127
+ }
@@ -0,0 +1,46 @@
1
+ import { google as GoogleSDK } from 'googleapis';
2
+
3
+ import { GoogleCalendar, IGoogleCalendarService } from '../../interfaces';
4
+
5
+ class GoogleCalendarService implements IGoogleCalendarService {
6
+ async getEvents ({
7
+ credentials,
8
+ data,
9
+ }: GoogleCalendar.GetEvents.Request): Promise<GoogleCalendar.GetEvents.Response> {
10
+ const client = new GoogleSDK.auth.OAuth2(
11
+ credentials.clientId,
12
+ credentials.clientSecret,
13
+ credentials.redirectUri
14
+ );
15
+
16
+ client.setCredentials({
17
+ access_token: data.accessToken,
18
+ refresh_token: data.refreshToken,
19
+ });
20
+
21
+ const { data: { items } } = await GoogleSDK
22
+ .calendar({ version: 'v3', auth: client })
23
+ .events
24
+ .list();
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
+ return {
41
+ events,
42
+ };
43
+ }
44
+ }
45
+
46
+ export default new GoogleCalendarService();
@@ -1,10 +1,12 @@
1
1
  import GoogleAuthService from './auth';
2
+ import GoogleCalendarService from './calendar';
2
3
  import GoogleSecretsService from './secrets';
3
4
  import GoogleSheetsService from './sheets';
4
5
  import GoogleStorageService from './storage';
5
6
 
6
7
  export {
7
8
  GoogleAuthService,
9
+ GoogleCalendarService,
8
10
  GoogleSecretsService,
9
11
  GoogleSheetsService,
10
12
  GoogleStorageService,
@@ -1,4 +1,4 @@
1
- import { google } from 'googleapis';
1
+ import { google as GoogleSDK } from 'googleapis';
2
2
 
3
3
  import { GoogleSheets, IGoogleSheetsService } from '../../interfaces';
4
4
 
@@ -7,7 +7,7 @@ class GoogleSheetsService implements IGoogleSheetsService {
7
7
  credentials,
8
8
  data,
9
9
  }: GoogleSheets.ReadSheet.Request): Promise<GoogleSheets.ReadSheet.Response> {
10
- const instance = google.sheets({
10
+ const instance = GoogleSDK.sheets({
11
11
  version: 'v4',
12
12
  auth: credentials.apiKey,
13
13
  });
@@ -16,6 +16,7 @@ import FileService from './file';
16
16
  import FirebaseService from './firebase';
17
17
  import {
18
18
  GoogleAuthService,
19
+ GoogleCalendarService,
19
20
  GoogleSecretsService,
20
21
  GoogleSheetsService,
21
22
  GoogleStorageService,
@@ -43,6 +44,7 @@ export {
43
44
  FileService,
44
45
  FirebaseService,
45
46
  GoogleAuthService,
47
+ GoogleCalendarService,
46
48
  GoogleSecretsService,
47
49
  GoogleSheetsService,
48
50
  GoogleStorageService,
package/yarn.lock CHANGED
@@ -1463,6 +1463,11 @@
1463
1463
  resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz#a7054dcc145a967dd4dc8fee845a57c1316c9df8"
1464
1464
  integrity sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==
1465
1465
 
1466
+ "@babel/runtime@^7.12.5":
1467
+ version "7.28.4"
1468
+ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.4.tgz#a70226016fabe25c5783b2f22d3e1c9bc5ca3326"
1469
+ integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==
1470
+
1466
1471
  "@babel/runtime@^7.27.6":
1467
1472
  version "7.28.3"
1468
1473
  resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.3.tgz#75c5034b55ba868121668be5d5bb31cc64e6e61a"
@@ -2080,6 +2085,14 @@
2080
2085
  resolved "https://registry.npmjs.org/@microsoft/applicationinsights-web-snippet/-/applicationinsights-web-snippet-1.2.1.tgz#c158081f8c40ea9ad94475abac15f67182768882"
2081
2086
  integrity sha512-+Cy9zFqdQgdAbMK1dpm7B+3DUnrByai0Tq6XG9v737HJpW6G1EiNNbTuFeXdPWyGaq6FIx9jxm/SUcxA6/Rxxg==
2082
2087
 
2088
+ "@microsoft/microsoft-graph-client@^3.0.7":
2089
+ version "3.0.7"
2090
+ resolved "https://registry.yarnpkg.com/@microsoft/microsoft-graph-client/-/microsoft-graph-client-3.0.7.tgz#535507df2db40bd7ed24a670dc68c87c628177a4"
2091
+ integrity sha512-/AazAV/F+HK4LIywF9C+NYHcJo038zEnWkteilcxC1FM/uK/4NVGDKGrxx7nNq1ybspAroRKT4I1FHfxQzxkUw==
2092
+ dependencies:
2093
+ "@babel/runtime" "^7.12.5"
2094
+ tslib "^2.2.0"
2095
+
2083
2096
  "@nodelib/fs.scandir@2.1.5":
2084
2097
  version "2.1.5"
2085
2098
  resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"