biz-email-builder-shared 1.6.9 → 1.6.11
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/entity/emailConfiguration.entity.d.ts +32 -0
- package/dist/entity/emailConfiguration.entity.d.ts.map +1 -0
- package/dist/entity/emailConfiguration.entity.js +29 -0
- package/dist/entity/index.d.ts +3 -1
- package/dist/entity/index.d.ts.map +1 -1
- package/dist/entity/index.js +3 -1
- package/dist/entity/planHistory.entity.d.ts +59 -0
- package/dist/entity/planHistory.entity.d.ts.map +1 -0
- package/dist/entity/planHistory.entity.js +30 -0
- package/dist/entity/subscriptionPlan.entity.d.ts +18 -0
- package/dist/entity/subscriptionPlan.entity.d.ts.map +1 -0
- package/dist/entity/subscriptionPlan.entity.js +49 -0
- package/dist/entity/user.entity.d.ts +1 -0
- package/dist/entity/user.entity.d.ts.map +1 -1
- package/dist/entity/user.entity.js +2 -1
- package/dist/middleware/authentication.d.ts.map +1 -1
- package/dist/middleware/authentication.js +5 -1
- package/dist/types/IRequest.d.ts +1 -0
- package/dist/types/IRequest.d.ts.map +1 -1
- package/dist/utilities/cryptoUtils.d.ts +3 -0
- package/dist/utilities/cryptoUtils.d.ts.map +1 -0
- package/dist/utilities/cryptoUtils.js +26 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Types } from "mongoose";
|
|
2
|
+
export declare enum CONFIG_METHOD {
|
|
3
|
+
SMTP = "SMTP",
|
|
4
|
+
GMAIL = "GMAIL"
|
|
5
|
+
}
|
|
6
|
+
export interface ISMTPConfig {
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
secure: boolean;
|
|
10
|
+
userName: string;
|
|
11
|
+
encryptedPassword: string;
|
|
12
|
+
}
|
|
13
|
+
export interface IGmailConfig {
|
|
14
|
+
email: string;
|
|
15
|
+
password: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IEmailConfiguration extends Document {
|
|
18
|
+
userId: Types.ObjectId;
|
|
19
|
+
method: CONFIG_METHOD;
|
|
20
|
+
smtpConfig?: ISMTPConfig;
|
|
21
|
+
gmailConfig?: IGmailConfig;
|
|
22
|
+
isDeleted: boolean;
|
|
23
|
+
updatedBy: Types.ObjectId;
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
updatedAt: Date;
|
|
26
|
+
}
|
|
27
|
+
export declare const EmailConfigurationModel: import("mongoose").Model<IEmailConfiguration, {}, {}, {}, import("mongoose").Document<unknown, {}, IEmailConfiguration> & IEmailConfiguration & {
|
|
28
|
+
_id: Types.ObjectId;
|
|
29
|
+
} & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}, any>;
|
|
32
|
+
//# sourceMappingURL=emailConfiguration.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emailConfiguration.entity.d.ts","sourceRoot":"","sources":["../../src/entity/emailConfiguration.entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;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,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,QAAQ;IACnD,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAiCD,eAAO,MAAM,uBAAuB;SAA+yG,MAAO,QAAQ;;;OAAhvG,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailConfigurationModel = exports.CONFIG_METHOD = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
var CONFIG_METHOD;
|
|
6
|
+
(function (CONFIG_METHOD) {
|
|
7
|
+
CONFIG_METHOD["SMTP"] = "SMTP";
|
|
8
|
+
CONFIG_METHOD["GMAIL"] = "GMAIL";
|
|
9
|
+
})(CONFIG_METHOD || (exports.CONFIG_METHOD = CONFIG_METHOD = {}));
|
|
10
|
+
const smtpConfigSchema = new mongoose_1.Schema({
|
|
11
|
+
host: { type: String, required: true },
|
|
12
|
+
port: { type: Number, required: true },
|
|
13
|
+
secure: { type: Boolean, required: true },
|
|
14
|
+
userName: { type: String, required: true },
|
|
15
|
+
encryptedPassword: { type: String, required: true },
|
|
16
|
+
}, { _id: false });
|
|
17
|
+
const gmailConfigSchema = new mongoose_1.Schema({
|
|
18
|
+
email: { type: String, required: true },
|
|
19
|
+
password: { type: String, required: true }
|
|
20
|
+
}, { _id: false });
|
|
21
|
+
const EmailConfigurationSchema = new mongoose_1.Schema({
|
|
22
|
+
userId: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true, unique: true },
|
|
23
|
+
method: { type: String, enum: Object.values(CONFIG_METHOD), required: true },
|
|
24
|
+
smtpConfig: { type: smtpConfigSchema, required: false },
|
|
25
|
+
gmailConfig: { type: gmailConfigSchema, required: false },
|
|
26
|
+
isDeleted: { type: Boolean, default: false },
|
|
27
|
+
updatedBy: { type: mongoose_1.Schema.Types.ObjectId, ref: "user" },
|
|
28
|
+
}, { timestamps: true });
|
|
29
|
+
exports.EmailConfigurationModel = (0, mongoose_1.model)("email-configuration", EmailConfigurationSchema);
|
package/dist/entity/index.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export * from "./template.entity";
|
|
|
3
3
|
export * from "./user-group.entitty";
|
|
4
4
|
export * from "./feature.entitiy";
|
|
5
5
|
export * from "./templateShare.entity";
|
|
6
|
-
export * from "./
|
|
6
|
+
export * from "./subscriptionPlan.entity";
|
|
7
|
+
export * from "./planHistory.entity";
|
|
8
|
+
export * from "./emailConfiguration.entity";
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAA"}
|
package/dist/entity/index.js
CHANGED
|
@@ -19,4 +19,6 @@ __exportStar(require("./template.entity"), exports);
|
|
|
19
19
|
__exportStar(require("./user-group.entitty"), exports);
|
|
20
20
|
__exportStar(require("./feature.entitiy"), exports);
|
|
21
21
|
__exportStar(require("./templateShare.entity"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./subscriptionPlan.entity"), exports);
|
|
23
|
+
__exportStar(require("./planHistory.entity"), exports);
|
|
24
|
+
__exportStar(require("./emailConfiguration.entity"), exports);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Schema, Types, Document } from "mongoose";
|
|
2
|
+
export interface ITransactionHistory {
|
|
3
|
+
subscriptionPlanId: Types.ObjectId;
|
|
4
|
+
transactionId: string;
|
|
5
|
+
isSuccessful: boolean;
|
|
6
|
+
transactionDate: Date;
|
|
7
|
+
}
|
|
8
|
+
export interface ISubscriptionQuota {
|
|
9
|
+
emailSentCount: number;
|
|
10
|
+
privateTemplateCount: number;
|
|
11
|
+
publicTemplateCount: number;
|
|
12
|
+
smtpConfigAllowed: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface IPlanHistory extends Document {
|
|
15
|
+
userId: Types.ObjectId;
|
|
16
|
+
subscriptionPlanId: Types.ObjectId;
|
|
17
|
+
purchaseDate: Date;
|
|
18
|
+
renewalDate: Date;
|
|
19
|
+
notifyRenewalDate: Date;
|
|
20
|
+
notifyRenewalCount: number;
|
|
21
|
+
quotaResetDate: Date;
|
|
22
|
+
isTransactionSuccessful: boolean;
|
|
23
|
+
updatedBy: Types.ObjectId;
|
|
24
|
+
transactionHistory: ITransactionHistory[];
|
|
25
|
+
subscriptionQuota: ISubscriptionQuota;
|
|
26
|
+
}
|
|
27
|
+
export declare const TransactionHistorySchema: Schema<ITransactionHistory, import("mongoose").Model<ITransactionHistory, any, any, any, Document<unknown, any, ITransactionHistory> & ITransactionHistory & {
|
|
28
|
+
_id: Types.ObjectId;
|
|
29
|
+
} & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ITransactionHistory, Document<unknown, {}, import("mongoose").FlatRecord<ITransactionHistory>> & import("mongoose").FlatRecord<ITransactionHistory> & {
|
|
32
|
+
_id: Types.ObjectId;
|
|
33
|
+
} & {
|
|
34
|
+
__v: number;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const SubscriptionQuotaSchema: Schema<ISubscriptionQuota, import("mongoose").Model<ISubscriptionQuota, any, any, any, Document<unknown, any, ISubscriptionQuota> & ISubscriptionQuota & {
|
|
37
|
+
_id: Types.ObjectId;
|
|
38
|
+
} & {
|
|
39
|
+
__v: number;
|
|
40
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ISubscriptionQuota, Document<unknown, {}, import("mongoose").FlatRecord<ISubscriptionQuota>> & import("mongoose").FlatRecord<ISubscriptionQuota> & {
|
|
41
|
+
_id: Types.ObjectId;
|
|
42
|
+
} & {
|
|
43
|
+
__v: number;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const PlanHistorySchema: Schema<IPlanHistory, import("mongoose").Model<IPlanHistory, any, any, any, Document<unknown, any, IPlanHistory> & IPlanHistory & Required<{
|
|
46
|
+
_id: unknown;
|
|
47
|
+
}> & {
|
|
48
|
+
__v: number;
|
|
49
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IPlanHistory, Document<unknown, {}, import("mongoose").FlatRecord<IPlanHistory>> & import("mongoose").FlatRecord<IPlanHistory> & Required<{
|
|
50
|
+
_id: unknown;
|
|
51
|
+
}> & {
|
|
52
|
+
__v: number;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const PlanHistoryModel: import("mongoose").Model<IPlanHistory, {}, {}, {}, Document<unknown, {}, IPlanHistory> & IPlanHistory & Required<{
|
|
55
|
+
_id: unknown;
|
|
56
|
+
}> & {
|
|
57
|
+
__v: number;
|
|
58
|
+
}, any>;
|
|
59
|
+
//# sourceMappingURL=planHistory.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planHistory.entity.d.ts","sourceRoot":"","sources":["../../src/entity/planHistory.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;IACvB,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC;IACnC,YAAY,EAAE,IAAI,CAAC;IACnB,WAAW,EAAE,IAAI,CAAC;IAClB,iBAAiB,EAAE,IAAI,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,IAAI,CAAC;IACrB,uBAAuB,EAAE,OAAO,CAAC;IACjC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC1B,kBAAkB,EAAE,mBAAmB,EAAE,CAAC;IAC1C,iBAAiB,EAAE,kBAAkB,CAAC;CACvC;AAED,eAAO,MAAM,wBAAwB;SA6BsnF,MAAO,QAAQ;;;;SAAf,MAAO,QAAQ;;;EAxBxpF,CAAC;AAEnB,eAAO,MAAM,uBAAuB;SAsBunF,MAAO,QAAQ;;;;SAAf,MAAO,QAAQ;;;EAjBxpF,CAAC;AAEnB,eAAO,MAAM,iBAAiB;;;;;;;;EAYN,CAAC;AAEzB,eAAO,MAAM,gBAAgB;;;;OAAyD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlanHistoryModel = exports.PlanHistorySchema = exports.SubscriptionQuotaSchema = exports.TransactionHistorySchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
exports.TransactionHistorySchema = new mongoose_1.Schema({
|
|
6
|
+
subscriptionPlanId: { type: mongoose_1.Schema.Types.ObjectId, ref: "subscription-plan", required: true },
|
|
7
|
+
transactionId: { type: String, required: true },
|
|
8
|
+
isSuccessful: { type: Boolean, default: false },
|
|
9
|
+
transactionDate: { type: Date, required: true }
|
|
10
|
+
}, { _id: false });
|
|
11
|
+
exports.SubscriptionQuotaSchema = new mongoose_1.Schema({
|
|
12
|
+
emailSentCount: { type: Number, required: true },
|
|
13
|
+
publicTemplateCount: { type: Number, required: true },
|
|
14
|
+
privateTemplateCount: { type: Number, required: true },
|
|
15
|
+
smtpConfigAllowed: { type: Boolean, default: false }
|
|
16
|
+
}, { _id: false });
|
|
17
|
+
exports.PlanHistorySchema = new mongoose_1.Schema({
|
|
18
|
+
userId: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true },
|
|
19
|
+
subscriptionPlanId: { type: mongoose_1.Schema.Types.ObjectId, ref: "subscription-plan", required: true },
|
|
20
|
+
purchaseDate: { type: Date, required: true },
|
|
21
|
+
renewalDate: { type: Date, required: true },
|
|
22
|
+
notifyRenewalDate: { type: Date, required: true },
|
|
23
|
+
notifyRenewalCount: { type: Number, required: true },
|
|
24
|
+
quotaResetDate: { type: Date, required: true },
|
|
25
|
+
isTransactionSuccessful: { type: Boolean, required: true },
|
|
26
|
+
updatedBy: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true },
|
|
27
|
+
transactionHistory: { type: [exports.TransactionHistorySchema], required: true },
|
|
28
|
+
subscriptionQuota: { type: exports.SubscriptionQuotaSchema, required: true }
|
|
29
|
+
}, { timestamps: true });
|
|
30
|
+
exports.PlanHistoryModel = (0, mongoose_1.model)("plan-history", exports.PlanHistorySchema);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
export interface ISubscriptionPlan extends Document {
|
|
3
|
+
planName: string;
|
|
4
|
+
sendEmailLimit: number;
|
|
5
|
+
privateTemplateLimit: number;
|
|
6
|
+
publicTemplateLimit: number;
|
|
7
|
+
smtpConfigAllowed: boolean;
|
|
8
|
+
isDeleted: boolean;
|
|
9
|
+
updatedBy: mongoose.Types.ObjectId;
|
|
10
|
+
deletedAt: Date;
|
|
11
|
+
isDefault: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const SubscriptionPlanModel: mongoose.Model<ISubscriptionPlan, {}, {}, {}, mongoose.Document<unknown, {}, ISubscriptionPlan> & ISubscriptionPlan & {
|
|
14
|
+
_id: mongoose.Types.ObjectId;
|
|
15
|
+
} & {
|
|
16
|
+
__v: number;
|
|
17
|
+
}, any>;
|
|
18
|
+
//# sourceMappingURL=subscriptionPlan.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptionPlan.entity.d.ts","sourceRoot":"","sources":["../../src/entity/subscriptionPlan.entity.ts"],"names":[],"mappings":"AAAA,OAAO,QAA2B,MAAM,UAAU,CAAC;AAEnD,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAgBD,eAAO,MAAM,qBAAqB;;;;OAAwE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SubscriptionPlanModel = void 0;
|
|
37
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
38
|
+
const SubscriptionPlanSchema = new mongoose_1.Schema({
|
|
39
|
+
planName: { type: String, required: true },
|
|
40
|
+
sendEmailLimit: { type: Number, required: true },
|
|
41
|
+
privateTemplateLimit: { type: Number, required: true },
|
|
42
|
+
publicTemplateLimit: { type: Number, required: true },
|
|
43
|
+
smtpConfigAllowed: { type: Boolean, required: true },
|
|
44
|
+
isDeleted: { type: Boolean, default: false },
|
|
45
|
+
updatedBy: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "User", required: true },
|
|
46
|
+
deletedAt: { type: Date, default: null },
|
|
47
|
+
isDefault: { type: Boolean, default: false, index: { unique: true, partialFilterExpression: { isDefault: true } } }
|
|
48
|
+
}, { timestamps: true, });
|
|
49
|
+
exports.SubscriptionPlanModel = (0, mongoose_1.model)("subscription-plan", SubscriptionPlanSchema);
|
|
@@ -13,6 +13,7 @@ interface IUser {
|
|
|
13
13
|
deletedAt: Date;
|
|
14
14
|
isDeleted: boolean;
|
|
15
15
|
updateBy: Types.ObjectId;
|
|
16
|
+
currentPlanId: Types.ObjectId;
|
|
16
17
|
}
|
|
17
18
|
export declare const UserModel: import("mongoose").Model<IUser, {}, {}, {}, import("mongoose").Document<unknown, {}, IUser> & IUser & {
|
|
18
19
|
_id: Types.ObjectId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.entity.d.ts","sourceRoot":"","sources":["../../src/entity/user.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"user.entity.d.ts","sourceRoot":"","sources":["../../src/entity/user.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;IACzB,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC;CAC/B;AAqBD,eAAO,MAAM,SAAS;SACktH,MAAO,QAAQ;;;OAD9rH,CAAC"}
|
|
@@ -13,7 +13,8 @@ const UserSchema = new mongoose_1.Schema({
|
|
|
13
13
|
deletedAt: { type: Date, default: null },
|
|
14
14
|
isDeleted: { type: Boolean, default: false },
|
|
15
15
|
groups: { type: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'user-group' }], default: [], _id: false },
|
|
16
|
-
updateBy: { type: mongoose_1.Schema.Types.ObjectId, ref: 'user' }
|
|
16
|
+
updateBy: { type: mongoose_1.Schema.Types.ObjectId, ref: 'user' },
|
|
17
|
+
currentPlanId: { type: mongoose_1.Schema.Types.ObjectId, ref: "subscription-plan" }
|
|
17
18
|
}, {
|
|
18
19
|
timestamps: true,
|
|
19
20
|
});
|
|
@@ -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,
|
|
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,kBA8CxE,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"}
|
|
@@ -31,6 +31,10 @@ const authorize = () => {
|
|
|
31
31
|
.populate({
|
|
32
32
|
path: "groups",
|
|
33
33
|
populate: { path: "features", select: "name" },
|
|
34
|
+
})
|
|
35
|
+
.populate({
|
|
36
|
+
path: "currentPlanId",
|
|
37
|
+
select: "_id planName"
|
|
34
38
|
})
|
|
35
39
|
.lean();
|
|
36
40
|
if (!user) {
|
|
@@ -40,7 +44,7 @@ const authorize = () => {
|
|
|
40
44
|
throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_NO_ROLE_ASSIGNED_ROLE_INVALID);
|
|
41
45
|
}
|
|
42
46
|
const { createdAt, updatedAt, deletedAt, password } = user, rest = __rest(user, ["createdAt", "updatedAt", "deletedAt", "password"]);
|
|
43
|
-
req.user = rest;
|
|
47
|
+
req.user = Object.assign({}, rest);
|
|
44
48
|
if (req.user && user.role === email_builder_utils_1.ROLES.ADMIN) {
|
|
45
49
|
req.user.isAdmin = true;
|
|
46
50
|
req.user.groups.push({ name: "DEFAULT", features: Object.values(email_builder_utils_1.FEATURE_TYPE).map((value) => ({ name: value })) });
|
package/dist/types/IRequest.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IRequest.d.ts","sourceRoot":"","sources":["../../src/types/IRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE1E,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,EAAE,KAAK,CAAC;QACV,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,YAAY,CAAA;SAAE,CAAC,CAAA;KAC1C,CAAC,CAAA;IACF,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"IRequest.d.ts","sourceRoot":"","sources":["../../src/types/IRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE1E,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,EAAE,KAAK,CAAC;QACV,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,YAAY,CAAA;SAAE,CAAC,CAAA;KAC1C,CAAC,CAAA;IACF,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,QAAS,SAAQ,OAAO;IACrC,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoUtils.d.ts","sourceRoot":"","sources":["../../src/utilities/cryptoUtils.ts"],"names":[],"mappings":"AAKA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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.encrypt = encrypt;
|
|
7
|
+
exports.decrypt = decrypt;
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY || '2c6ee24b09816a6f14f95d2838a429d8e5e8b028fbd421d24fc43b96b4a9f3c0'; // Must be 32 bytes (256 bits)
|
|
10
|
+
const IV_LENGTH = 16;
|
|
11
|
+
function encrypt(text) {
|
|
12
|
+
const iv = crypto_1.default.randomBytes(IV_LENGTH);
|
|
13
|
+
const cipher = crypto_1.default.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
|
|
14
|
+
let encrypted = cipher.update(text, 'utf8', 'hex');
|
|
15
|
+
encrypted += cipher.final('hex');
|
|
16
|
+
return iv.toString('hex') + ':' + encrypted;
|
|
17
|
+
}
|
|
18
|
+
function decrypt(text) {
|
|
19
|
+
const parts = text.split(':');
|
|
20
|
+
const iv = Buffer.from(parts.shift(), 'hex');
|
|
21
|
+
const encryptedText = parts.join(':');
|
|
22
|
+
const decipher = crypto_1.default.createDecipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
|
|
23
|
+
let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
|
|
24
|
+
decrypted += decipher.final('utf8');
|
|
25
|
+
return decrypted;
|
|
26
|
+
}
|