biz-email-builder-shared 1.6.56 → 1.6.59

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.
@@ -31,6 +31,7 @@ export interface IEmailConfiguration extends Document {
31
31
  updatedBy: Types.ObjectId;
32
32
  createdAt: Date;
33
33
  updatedAt: Date;
34
+ defaultMethod?: CONFIG_METHOD | null;
34
35
  }
35
36
  export declare const EmailConfigurationModel: import("mongoose").Model<IEmailConfiguration, {}, {}, {}, import("mongoose").Document<unknown, {}, IEmailConfiguration> & IEmailConfiguration & {
36
37
  _id: Types.ObjectId;
@@ -1 +1 @@
1
- {"version":3,"file":"emailConfiguration.entity.d.ts","sourceRoot":"","sources":["../../src/entity/emailConfiguration.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,iBAAiB;IAC3B,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,QAAQ;IACnD,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,WAAW,CAAC,EAAE,YAAY,CAAC;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ACtC;AAqCD,eAAO,MAAM,uBAAuB;SAAq0F,MAAO,QAAQ;;;OAAtwF,CAAC"}
@@ -34,5 +34,6 @@ const EmailConfigurationSchema = new mongoose_1.Schema({
34
34
  gmailConfig: { type: gmailConfigSchema, required: false },
35
35
  isDeleted: { type: Boolean, default: false },
36
36
  updatedBy: { type: mongoose_1.Schema.Types.ObjectId, ref: "user" },
37
+ defaultMethod: { type: String, enum: Object.values(CONFIG_METHOD), default: null },
37
38
  }, { timestamps: true });
38
39
  exports.EmailConfigurationModel = (0, mongoose_1.model)("email-configuration", EmailConfigurationSchema);
@@ -1 +1 @@
1
- {"version":3,"file":"organisationTeams.entity.d.ts","sourceRoot":"","sources":["../../src/entity/organisationTeams.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,uBAAwB,SAAQ,QAAQ;IACvD,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC/B,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC3B,YAAY,EAAE,aAAa,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;CAC3B;AAaD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SACgvH,MAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAf,MAAO,QAAQ;;;GAD1sH,CAAC"}
1
+ {"version":3,"file":"organisationTeams.entity.d.ts","sourceRoot":"","sources":["../../src/entity/organisationTeams.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAW,uBAAwB,SAAQ,QAAQ;IACvD,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC/B,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC3B,YAAY,EAAE,aAAa,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;CAC3B;AAaD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SACixH,MAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAf,MAAO,QAAQ;;;GAD3uH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../src/middleware/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE1D,QAAA,MAAM,SAAS,cACe,QAAQ,OAAO,QAAQ,QAAQ,YAAY,kBAmDxE,CAAC;AAEF,QAAA,MAAM,eAAe,UAAW,KAAK,EAAE,WACT,QAAQ,OAAO,QAAQ,QAAQ,YAAY,kBAaxE,CAAC;AAEF,QAAA,MAAM,kBAAkB,aAAc,YAAY,EAAE,WACtB,QAAQ,OAAO,QAAQ,QAAQ,YAAY,kBAgBxE,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../src/middleware/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE1D,QAAA,MAAM,SAAS,cACe,QAAQ,OAAO,QAAQ,QAAQ,YAAY,kBAyDxE,CAAC;AAEF,QAAA,MAAM,eAAe,UAAW,KAAK,EAAE,WACT,QAAQ,OAAO,QAAQ,QAAQ,YAAY,kBAaxE,CAAC;AAEF,QAAA,MAAM,kBAAkB,aAAc,YAAY,EAAE,WACtB,QAAQ,OAAO,QAAQ,QAAQ,YAAY,kBAgBxE,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
@@ -22,41 +22,49 @@ const authorize = () => {
22
22
  if (!req.headers.authorization) {
23
23
  throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_UNAUTHORIZED);
24
24
  }
25
- if (req.headers.authorization) {
26
- const token = await (0, utilities_1.verifyUid)(req.headers.authorization);
25
+ let token;
26
+ try {
27
+ token = await (0, utilities_1.verifyUid)(req.headers.authorization);
27
28
  if (!token) {
28
29
  throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_SESSION_EXPIRED);
29
30
  }
30
- let user = await entity_1.UserModel.findById(token.value.id)
31
- .populate({
32
- path: "groups",
33
- populate: { path: "features", select: "name" },
34
- }).lean();
35
- if (!user) {
36
- throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_USER_NOT_FOUND);
37
- }
38
- if (user.role === undefined || user.role === null || !Object.values(email_builder_utils_1.ROLES).includes(user.role)) {
39
- throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_NO_ROLE_ASSIGNED_ROLE_INVALID);
40
- }
41
- const { createdAt, updatedAt, deletedAt, password, verificationToken, __v, updateBy } = user, rest = __rest(user, ["createdAt", "updatedAt", "deletedAt", "password", "verificationToken", "__v", "updateBy"]);
42
- req.user = Object.assign({}, rest);
43
- if (req.user && user.role === email_builder_utils_1.ROLES.ADMIN) {
44
- req.user.isAdmin = true;
45
- req.user.groups.push({ name: "ADMIN_GROUP", features: Object.values(email_builder_utils_1.FEATURE_TYPE).map((value) => ({ name: value })) });
46
- }
47
- let currentPlanDetail = await entity_1.PlanHistoryModel.find({ user: user._id.toString(), isTransactionSuccessfull: true }).populate({ path: "subscriptionPlanId", select: "_id planName" }).lean().exec();
48
- if (currentPlanDetail && currentPlanDetail.length) {
49
- req.userSubsciptionQuota = currentPlanDetail[0].subscriptionQuota;
50
- req.currentPlan = currentPlanDetail[0].subscriptionPlanId;
51
- if (currentPlanDetail[0].renewalDate) {
52
- req.isSubscriptionActive = !(currentPlanDetail[0].renewalDate < new Date());
53
- }
31
+ }
32
+ catch (err) {
33
+ return next(new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_INVALID_TOKEN));
34
+ }
35
+ let user = await entity_1.UserModel.findById(token.value.id)
36
+ .populate({
37
+ path: "groups",
38
+ populate: { path: "features", select: "name" },
39
+ })
40
+ .lean();
41
+ if (!user) {
42
+ throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_USER_NOT_FOUND);
43
+ }
44
+ if (user.role === undefined || user.role === null || !Object.values(email_builder_utils_1.ROLES).includes(user.role)) {
45
+ throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_NO_ROLE_ASSIGNED_ROLE_INVALID);
46
+ }
47
+ const { createdAt, updatedAt, deletedAt, password, verificationToken, __v, updateBy } = user, rest = __rest(user, ["createdAt", "updatedAt", "deletedAt", "password", "verificationToken", "__v", "updateBy"]);
48
+ req.user = Object.assign({}, rest);
49
+ if (req.user && user.role === email_builder_utils_1.ROLES.ADMIN) {
50
+ req.user.isAdmin = true;
51
+ req.user.groups.push({ name: "ADMIN_GROUP", features: Object.values(email_builder_utils_1.FEATURE_TYPE).map((value) => ({ name: value })) });
52
+ }
53
+ let currentPlanDetail = await entity_1.PlanHistoryModel.find({ user: user._id.toString(), isTransactionSuccessfull: true })
54
+ .populate({ path: "subscriptionPlanId", select: "_id planName" })
55
+ .lean()
56
+ .exec();
57
+ if (currentPlanDetail && currentPlanDetail.length) {
58
+ req.userSubsciptionQuota = currentPlanDetail[0].subscriptionQuota;
59
+ req.currentPlan = currentPlanDetail[0].subscriptionPlanId;
60
+ if (currentPlanDetail[0].renewalDate) {
61
+ req.isSubscriptionActive = !(currentPlanDetail[0].renewalDate < new Date());
54
62
  }
55
- next();
56
63
  }
64
+ next();
57
65
  }
58
- catch (err) {
59
- next(err);
66
+ catch (error) {
67
+ next(error);
60
68
  }
61
69
  };
62
70
  };
@@ -5,6 +5,7 @@ export declare enum SERVER_MESSAGES {
5
5
  SE_USER_NOT_FOUND = "SE_USER_NOT_FOUND",
6
6
  SE_FORBIDDEN_ROLE_ACCESS_DENIED = "SE_FORBIDDEN_ROLE_ACCESS_DENIED",
7
7
  SE_FORBIDDEN_FEATURE_ACCESS_DENIED = "SE_FORBIDDEN_FEATURE_ACCESS_DENIED",
8
- SE_NO_ROLE_ASSIGNED_ROLE_INVALID = "SE_NO_ROLE_ASSIGNED_ROLE_INVALID"
8
+ SE_NO_ROLE_ASSIGNED_ROLE_INVALID = "SE_NO_ROLE_ASSIGNED_ROLE_INVALID",
9
+ SE_INVALID_TOKEN = "SE_INVALID_TOKEN"
9
10
  }
10
11
  //# sourceMappingURL=serverMessages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverMessages.d.ts","sourceRoot":"","sources":["../../src/utilities/serverMessages.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,+BAA+B,oCAAoC;IACnE,kCAAkC,uCAAuC;IACzE,gCAAgC,qCAAqC;CACtE"}
1
+ {"version":3,"file":"serverMessages.d.ts","sourceRoot":"","sources":["../../src/utilities/serverMessages.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,+BAA+B,oCAAoC;IACnE,kCAAkC,uCAAuC;IACzE,gCAAgC,qCAAqC;IACrE,gBAAgB,qBAAqB;CACtC"}
@@ -10,4 +10,5 @@ var SERVER_MESSAGES;
10
10
  SERVER_MESSAGES["SE_FORBIDDEN_ROLE_ACCESS_DENIED"] = "SE_FORBIDDEN_ROLE_ACCESS_DENIED";
11
11
  SERVER_MESSAGES["SE_FORBIDDEN_FEATURE_ACCESS_DENIED"] = "SE_FORBIDDEN_FEATURE_ACCESS_DENIED";
12
12
  SERVER_MESSAGES["SE_NO_ROLE_ASSIGNED_ROLE_INVALID"] = "SE_NO_ROLE_ASSIGNED_ROLE_INVALID";
13
+ SERVER_MESSAGES["SE_INVALID_TOKEN"] = "SE_INVALID_TOKEN";
13
14
  })(SERVER_MESSAGES || (exports.SERVER_MESSAGES = SERVER_MESSAGES = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz-email-builder-shared",
3
- "version": "1.6.56",
3
+ "version": "1.6.59",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,4 +0,0 @@
1
- import { Attachment, Recipient } from "./types";
2
- import { IGmailConfig } from "../entity";
3
- export declare function sendViaGmail(creds: IGmailConfig, recipient: Recipient, subject: string, text: string, attachments: Attachment[], isHtml: boolean): Promise<import("nodemailer/lib/smtp-transport").SentMessageInfo>;
4
- //# sourceMappingURL=sendviaGmail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendviaGmail.d.ts","sourceRoot":"","sources":["../../src/utilities/sendviaGmail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAsB,YAAY,CAChC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,UAAU,EAAE,EACzB,MAAM,EAAE,OAAO,oEAqBhB"}
@@ -1,19 +0,0 @@
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
- exports.sendViaGmail = sendViaGmail;
7
- const nodemailer_1 = __importDefault(require("nodemailer"));
8
- async function sendViaGmail(creds, recipient, subject, text, attachments, isHtml) {
9
- const transporter = nodemailer_1.default.createTransport({
10
- service: "gmail",
11
- auth: {
12
- user: creds.email,
13
- pass: creds.password,
14
- },
15
- });
16
- const mailOptions = Object.assign({ from: creds.email, to: recipient.to, cc: recipient.cc, bcc: recipient.bcc, subject,
17
- attachments }, (isHtml ? { html: text } : { text }));
18
- return transporter.sendMail(mailOptions);
19
- }