@aldb2b/common 1.0.32 → 1.0.36

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.
@@ -0,0 +1,12 @@
1
+ import { Subjects } from './subjects';
2
+ export declare namespace GroupsByCompany {
3
+ interface Context {
4
+ subject: Subjects.GroupsByCompany;
5
+ data: Data;
6
+ }
7
+ interface Data {
8
+ companyId: string;
9
+ startDate: string;
10
+ endDate: string;
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=groups-by-company.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups-by-company.interface.js","sourceRoot":"","sources":["../../src/events/groups-by-company.interface.ts"],"names":[],"mappings":""}
@@ -9,6 +9,9 @@ export declare namespace MeetingRequestCreated {
9
9
  contactEmail: string;
10
10
  guestCompanyId: string;
11
11
  hostId: string;
12
+ hostCompanyId: string;
13
+ place: string;
14
+ type: string;
12
15
  requestedTimes: Date[];
13
16
  stepId: string;
14
17
  }
@@ -3,6 +3,7 @@ export declare enum Subjects {
3
3
  SendEmail = "sendEmail",
4
4
  CampaignUsers = "campaign:users",
5
5
  GetEvent = "getEvent",
6
+ GroupsByCompany = "groupsByCompany",
6
7
  EditListUsers = "editList:users",
7
8
  AuthorizeUser = "authorize:user",
8
9
  AttendeeContact = "attendee:contact",
@@ -7,6 +7,7 @@ var Subjects;
7
7
  Subjects["SendEmail"] = "sendEmail";
8
8
  Subjects["CampaignUsers"] = "campaign:users";
9
9
  Subjects["GetEvent"] = "getEvent";
10
+ Subjects["GroupsByCompany"] = "groupsByCompany";
10
11
  Subjects["EditListUsers"] = "editList:users";
11
12
  Subjects["AuthorizeUser"] = "authorize:user";
12
13
  Subjects["AttendeeContact"] = "attendee:contact";
@@ -1 +1 @@
1
- {"version":3,"file":"subjects.js","sourceRoot":"","sources":["../../src/events/subjects.ts"],"names":[],"mappings":";;;AAAA,IAAY,QASX;AATD,WAAY,QAAQ;IAClB,yCAA6B,CAAA;IAC7B,mCAAuB,CAAA;IACvB,4CAAgC,CAAA;IAChC,iCAAqB,CAAA;IACrB,4CAAgC,CAAA;IAChC,4CAAgC,CAAA;IAChC,gDAAoC,CAAA;IACpC,4DAAgD,CAAA;AAClD,CAAC,EATW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QASnB"}
1
+ {"version":3,"file":"subjects.js","sourceRoot":"","sources":["../../src/events/subjects.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB,yCAA6B,CAAA;IAC7B,mCAAuB,CAAA;IACvB,4CAAgC,CAAA;IAChC,iCAAqB,CAAA;IACrB,+CAAmC,CAAA;IACnC,4CAAgC,CAAA;IAChC,4CAAgC,CAAA;IAChC,gDAAoC,CAAA;IACpC,4DAAgD,CAAA;AAClD,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB"}
package/build/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './events/edit-lit-users.interface';
7
7
  export * from './events/authorize-user.interface';
8
8
  export * from './events/attendee-contact.interface';
9
9
  export * from './events/meeting-request-created.interface';
10
+ export * from './events/groups-by-company.interface';
10
11
  export * from './validators/conditional-required';
11
12
  export * from './validators/date-validator';
12
13
  export * from './validators/validateNewItem';
@@ -32,6 +33,8 @@ export * from './types/user-role.enum';
32
33
  export * from './types/header-user.interface';
33
34
  export * from './types/upload-presigned-url.interface';
34
35
  export * from './types/download-presigned-url.interface';
36
+ export * from './types/meeting-type.enum';
37
+ export * from './types/meeting-request-token.interface';
35
38
  export * from './middlewares/app.middleware';
36
39
  export * from './middlewares/authorizer.middleware';
37
40
  export * from './utils/create-default-directories';
package/build/index.js CHANGED
@@ -19,6 +19,7 @@ __exportStar(require("./events/edit-lit-users.interface"), exports);
19
19
  __exportStar(require("./events/authorize-user.interface"), exports);
20
20
  __exportStar(require("./events/attendee-contact.interface"), exports);
21
21
  __exportStar(require("./events/meeting-request-created.interface"), exports);
22
+ __exportStar(require("./events/groups-by-company.interface"), exports);
22
23
  __exportStar(require("./validators/conditional-required"), exports);
23
24
  __exportStar(require("./validators/date-validator"), exports);
24
25
  __exportStar(require("./validators/validateNewItem"), exports);
@@ -44,6 +45,8 @@ __exportStar(require("./types/user-role.enum"), exports);
44
45
  __exportStar(require("./types/header-user.interface"), exports);
45
46
  __exportStar(require("./types/upload-presigned-url.interface"), exports);
46
47
  __exportStar(require("./types/download-presigned-url.interface"), exports);
48
+ __exportStar(require("./types/meeting-type.enum"), exports);
49
+ __exportStar(require("./types/meeting-request-token.interface"), exports);
47
50
  __exportStar(require("./middlewares/app.middleware"), exports);
48
51
  __exportStar(require("./middlewares/authorizer.middleware"), exports);
49
52
  __exportStar(require("./utils/create-default-directories"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,iEAA8C;AAC9C,mEAAgD;AAChD,+DAA4C;AAC5C,oEAAiD;AACjD,oEAAiD;AACjD,oEAAiD;AACjD,sEAAmD;AACnD,6EAA0D;AAE1D,oEAAiD;AACjD,8DAA2C;AAC3C,+DAA4C;AAC5C,kEAA+C;AAC/C,wEAAqD;AACrD,kEAA+C;AAC/C,gFAA6D;AAC7D,+DAA4C;AAC5C,yEAAsD;AACtD,mFAAgE;AAChE,iFAA8D;AAC9D,iEAA8C;AAC9C,2EAAwD;AAExD,kEAA+C;AAE/C,sEAAmD;AACnD,uEAAoD;AAEpD,mDAAgC;AAChC,oDAAiC;AACjC,6DAA0C;AAE1C,gEAA6C;AAC7C,sEAAmD;AACnD,yDAAsC;AACtC,gEAA6C;AAC7C,yEAAsD;AACtD,2EAAwD;AAExD,+DAA4C;AAC5C,sEAAmD;AAEnD,qEAAkD;AAClD,6DAA0C;AAC1C,uDAAoC;AACpC,sDAAmC;AACnC,qDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,iEAA8C;AAC9C,mEAAgD;AAChD,+DAA4C;AAC5C,oEAAiD;AACjD,oEAAiD;AACjD,oEAAiD;AACjD,sEAAmD;AACnD,6EAA0D;AAC1D,uEAAoD;AAEpD,oEAAiD;AACjD,8DAA2C;AAC3C,+DAA4C;AAC5C,kEAA+C;AAC/C,wEAAqD;AACrD,kEAA+C;AAC/C,gFAA6D;AAC7D,+DAA4C;AAC5C,yEAAsD;AACtD,mFAAgE;AAChE,iFAA8D;AAC9D,iEAA8C;AAC9C,2EAAwD;AAExD,kEAA+C;AAE/C,sEAAmD;AACnD,uEAAoD;AAEpD,mDAAgC;AAChC,oDAAiC;AACjC,6DAA0C;AAE1C,gEAA6C;AAC7C,sEAAmD;AACnD,yDAAsC;AACtC,gEAA6C;AAC7C,yEAAsD;AACtD,2EAAwD;AACxD,4DAAyC;AACzC,0EAAuD;AAEvD,+DAA4C;AAC5C,sEAAmD;AAEnD,qEAAkD;AAClD,6DAA0C;AAC1C,uDAAoC;AACpC,sDAAmC;AACnC,qDAAkC"}
@@ -3,6 +3,7 @@ import { ClientProxy } from '@nestjs/microservices';
3
3
  import { Request, Response, NextFunction } from 'express';
4
4
  export declare class AuthorizerMiddleware implements NestMiddleware {
5
5
  private readonly client;
6
+ private cachManager;
6
7
  constructor(client: ClientProxy);
7
8
  use(request: Request, response: Response, next: NextFunction): Promise<void>;
8
9
  }
@@ -16,10 +16,33 @@ exports.AuthorizerMiddleware = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const microservices_1 = require("@nestjs/microservices");
18
18
  const rxjs_1 = require("rxjs");
19
+ const redis_1 = require("redis");
19
20
  const subjects_1 = require("../events/subjects");
21
+ class RedisClient {
22
+ constructor() {
23
+ this.redisClient = redis_1.createClient({
24
+ url: process.env.REDIS_URI,
25
+ });
26
+ }
27
+ async connectToRedis() {
28
+ try {
29
+ await this.redisClient.connect();
30
+ }
31
+ catch (err) { }
32
+ }
33
+ async getData(key) {
34
+ await this.connectToRedis();
35
+ return this.redisClient.get(key);
36
+ }
37
+ async setData(key, value) {
38
+ await this.connectToRedis();
39
+ return this.redisClient.set(key, value, { EX: 10 * 60 });
40
+ }
41
+ }
20
42
  let AuthorizerMiddleware = class AuthorizerMiddleware {
21
43
  constructor(client) {
22
44
  this.client = client;
45
+ this.cachManager = new RedisClient();
23
46
  }
24
47
  async use(request, response, next) {
25
48
  const campaignUser = {
@@ -32,7 +55,17 @@ let AuthorizerMiddleware = class AuthorizerMiddleware {
32
55
  : request.headers['x-cognito-userid'],
33
56
  },
34
57
  };
35
- const resp = await rxjs_1.firstValueFrom(this.client.send(campaignUser.subject, campaignUser.data));
58
+ const redisResponse = await this.cachManager.getData(JSON.stringify(campaignUser.data));
59
+ let resp;
60
+ if (redisResponse) {
61
+ resp = JSON.parse(redisResponse);
62
+ console.log('FROM REDIS--------------------');
63
+ }
64
+ else {
65
+ resp = await rxjs_1.firstValueFrom(this.client.send(campaignUser.subject, campaignUser.data));
66
+ console.log('FROM MESSAGE BROKER--------------------');
67
+ await this.cachManager.setData(JSON.stringify(campaignUser.data), JSON.stringify(resp));
68
+ }
36
69
  if (resp.isAuthorized === false) {
37
70
  throw new common_1.UnauthorizedException();
38
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authorizer.middleware.js","sourceRoot":"","sources":["../../src/middlewares/authorizer.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAKuB;AACvB,yDAAmD;AAEnD,+BAAqC;AAErC,iDAA6C;AAG7C,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAC/B,YAAqD,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAE5E,KAAK,CAAC,GAAG,CACP,OAAgB,EAChB,QAAkB,EAClB,IAAkB;QAElB,MAAM,YAAY,GAA0B;YAC1C,OAAO,EAAE,mBAAQ,C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