biz-email-builder-shared 1.6.20 → 1.6.22

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.
Files changed (31) hide show
  1. package/dist/entity/emailConfiguration.entity.d.ts +1 -1
  2. package/dist/entity/emailConfiguration.entity.d.ts.map +1 -1
  3. package/dist/entity/emailConfiguration.entity.js +1 -1
  4. package/dist/entity/organisation.entity.d.ts +1 -1
  5. package/dist/entity/organisation.entity.d.ts.map +1 -1
  6. package/dist/entity/organisation.entity.js +2 -1
  7. package/dist/entity/organisationTeams.entity.d.ts +41 -39
  8. package/dist/entity/organisationTeams.entity.d.ts.map +1 -1
  9. package/dist/entity/organisationTeams.entity.js +4 -4
  10. package/dist/entity/planHistory.entity.d.ts +2 -9
  11. package/dist/entity/planHistory.entity.d.ts.map +1 -1
  12. package/dist/entity/planHistory.entity.js +4 -10
  13. package/dist/entity/subscriptionPlan.entity.d.ts +1 -1
  14. package/dist/entity/subscriptionPlan.entity.d.ts.map +1 -1
  15. package/dist/entity/subscriptionPlan.entity.js +1 -1
  16. package/dist/entity/user.entity.d.ts +0 -2
  17. package/dist/entity/user.entity.d.ts.map +1 -1
  18. package/dist/entity/user.entity.js +1 -3
  19. package/dist/middleware/authentication.d.ts.map +1 -1
  20. package/dist/middleware/authentication.js +5 -9
  21. package/dist/types/IRequest.d.ts +2 -2
  22. package/dist/types/IRequest.d.ts.map +1 -1
  23. package/dist/utilities/cryptoUtils.d.ts.map +1 -1
  24. package/dist/utilities/cryptoUtils.js +16 -9
  25. package/dist/utilities/enums.d.ts +5 -0
  26. package/dist/utilities/enums.d.ts.map +1 -0
  27. package/dist/utilities/enums.js +8 -0
  28. package/dist/utilities/index.d.ts +1 -0
  29. package/dist/utilities/index.d.ts.map +1 -1
  30. package/dist/utilities/index.js +1 -0
  31. package/package.json +1 -1
@@ -15,7 +15,7 @@ export interface IGmailConfig {
15
15
  password: string;
16
16
  }
17
17
  export interface IEmailConfiguration extends Document {
18
- userId: Types.ObjectId;
18
+ user: Types.ObjectId;
19
19
  method: CONFIG_METHOD;
20
20
  smtpConfig?: ISMTPConfig;
21
21
  gmailConfig?: IGmailConfig;
@@ -1 +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;SAAgvG,MAAO,QAAQ;;;OAAjrG,CAAC"}
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,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,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;SAAovG,MAAO,QAAQ;;;OAArrG,CAAC"}
@@ -19,7 +19,7 @@ const gmailConfigSchema = new mongoose_1.Schema({
19
19
  password: { type: String, required: true }
20
20
  }, { _id: false });
21
21
  const EmailConfigurationSchema = new mongoose_1.Schema({
22
- userId: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true, unique: true },
22
+ user: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true, unique: true },
23
23
  method: { type: String, enum: Object.values(CONFIG_METHOD), required: true },
24
24
  smtpConfig: { type: smtpConfigSchema, required: false },
25
25
  gmailConfig: { type: gmailConfigSchema, required: false },
@@ -1,7 +1,7 @@
1
1
  import { Types } from "mongoose";
2
2
  export interface IOrganisation extends Document {
3
3
  name: string;
4
- owner: Types.ObjectId;
4
+ user: Types.ObjectId;
5
5
  isDisable: boolean;
6
6
  deletedAt: Date;
7
7
  updatedBy: Types.ObjectId;
@@ -1 +1 @@
1
- {"version":3,"file":"organisation.entity.d.ts","sourceRoot":"","sources":["../../src/entity/organisation.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAWD,eAAO,MAAM,iBAAiB;SAC4oI,MAAO,QAAQ;;;OADhmI,CAAC"}
1
+ {"version":3,"file":"organisation.entity.d.ts","sourceRoot":"","sources":["../../src/entity/organisation.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAYD,eAAO,MAAM,iBAAiB;SACimI,MAAO,QAAQ;;;OADrjI,CAAC"}
@@ -4,10 +4,11 @@ exports.OrganisationModel = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const OrganisationSchema = new mongoose_1.Schema({
6
6
  name: { type: String, required: true },
7
- owner: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true },
7
+ user: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true },
8
8
  isDisable: { type: Boolean, default: false },
9
9
  deletedAt: { type: Date, default: null },
10
10
  createdAt: { type: Date, default: null },
11
+ updatedAt: { type: Date, default: null },
11
12
  updatedBy: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true },
12
13
  }, { timestamps: true });
13
14
  exports.OrganisationModel = (0, mongoose_1.model)("organisation", OrganisationSchema);
@@ -1,21 +1,21 @@
1
- import { OWNERSHIP_TYPE } from "email-builder-utils";
2
1
  import { Schema, Types } from "mongoose";
2
+ import { INVITE_STATUS } from "../utilities";
3
3
  export interface IOrganisationTeamSchema extends Document {
4
4
  organisationId: Types.ObjectId;
5
- userId: Types.ObjectId;
6
- inviteStatus: string;
5
+ user: Types.ObjectId;
6
+ features: Types.ObjectId[];
7
+ inviteStatus: INVITE_STATUS;
7
8
  isDeleted: boolean;
8
9
  deletedAt: Date;
9
10
  createdAt: Date;
10
11
  updatedAt: Date;
12
+ updatedBy: Types.ObjectId;
11
13
  }
12
14
  export declare const OrganisationTeamModel: import("mongoose").Model<{
13
15
  createdAt: NativeDate;
14
16
  updatedAt: NativeDate;
15
17
  } & {
16
- deletedAt: NativeDate;
17
- isDeleted: boolean;
18
- organisationId: {
18
+ user: {
19
19
  prototype?: Types.ObjectId | null | undefined;
20
20
  cacheHexString?: unknown;
21
21
  generate?: {} | null | undefined;
@@ -24,9 +24,11 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
24
24
  createFromBase64?: {} | null | undefined;
25
25
  isValid?: {} | null | undefined;
26
26
  };
27
- accessType: OWNERSHIP_TYPE;
27
+ deletedAt: NativeDate;
28
+ isDeleted: boolean;
29
+ features: Types.ObjectId[];
28
30
  updatedBy: Types.ObjectId;
29
- userId: {
31
+ organisationId: {
30
32
  prototype?: Types.ObjectId | null | undefined;
31
33
  cacheHexString?: unknown;
32
34
  generate?: {} | null | undefined;
@@ -35,14 +37,12 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
35
37
  createFromBase64?: {} | null | undefined;
36
38
  isValid?: {} | null | undefined;
37
39
  };
38
- inviteStatus: "Pending" | "Accepted";
40
+ inviteStatus: INVITE_STATUS;
39
41
  }, {}, {}, {}, import("mongoose").Document<unknown, {}, {
40
42
  createdAt: NativeDate;
41
43
  updatedAt: NativeDate;
42
44
  } & {
43
- deletedAt: NativeDate;
44
- isDeleted: boolean;
45
- organisationId: {
45
+ user: {
46
46
  prototype?: Types.ObjectId | null | undefined;
47
47
  cacheHexString?: unknown;
48
48
  generate?: {} | null | undefined;
@@ -51,9 +51,11 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
51
51
  createFromBase64?: {} | null | undefined;
52
52
  isValid?: {} | null | undefined;
53
53
  };
54
- accessType: OWNERSHIP_TYPE;
54
+ deletedAt: NativeDate;
55
+ isDeleted: boolean;
56
+ features: Types.ObjectId[];
55
57
  updatedBy: Types.ObjectId;
56
- userId: {
58
+ organisationId: {
57
59
  prototype?: Types.ObjectId | null | undefined;
58
60
  cacheHexString?: unknown;
59
61
  generate?: {} | null | undefined;
@@ -62,14 +64,12 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
62
64
  createFromBase64?: {} | null | undefined;
63
65
  isValid?: {} | null | undefined;
64
66
  };
65
- inviteStatus: "Pending" | "Accepted";
67
+ inviteStatus: INVITE_STATUS;
66
68
  }> & {
67
69
  createdAt: NativeDate;
68
70
  updatedAt: NativeDate;
69
71
  } & {
70
- deletedAt: NativeDate;
71
- isDeleted: boolean;
72
- organisationId: {
72
+ user: {
73
73
  prototype?: Types.ObjectId | null | undefined;
74
74
  cacheHexString?: unknown;
75
75
  generate?: {} | null | undefined;
@@ -78,9 +78,11 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
78
78
  createFromBase64?: {} | null | undefined;
79
79
  isValid?: {} | null | undefined;
80
80
  };
81
- accessType: OWNERSHIP_TYPE;
81
+ deletedAt: NativeDate;
82
+ isDeleted: boolean;
83
+ features: Types.ObjectId[];
82
84
  updatedBy: Types.ObjectId;
83
- userId: {
85
+ organisationId: {
84
86
  prototype?: Types.ObjectId | null | undefined;
85
87
  cacheHexString?: unknown;
86
88
  generate?: {} | null | undefined;
@@ -89,7 +91,7 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
89
91
  createFromBase64?: {} | null | undefined;
90
92
  isValid?: {} | null | undefined;
91
93
  };
92
- inviteStatus: "Pending" | "Accepted";
94
+ inviteStatus: INVITE_STATUS;
93
95
  } & {
94
96
  _id: Types.ObjectId;
95
97
  } & {
@@ -100,9 +102,7 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
100
102
  createdAt: NativeDate;
101
103
  updatedAt: NativeDate;
102
104
  } & {
103
- deletedAt: NativeDate;
104
- isDeleted: boolean;
105
- organisationId: {
105
+ user: {
106
106
  prototype?: Types.ObjectId | null | undefined;
107
107
  cacheHexString?: unknown;
108
108
  generate?: {} | null | undefined;
@@ -111,9 +111,11 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
111
111
  createFromBase64?: {} | null | undefined;
112
112
  isValid?: {} | null | undefined;
113
113
  };
114
- accessType: OWNERSHIP_TYPE;
114
+ deletedAt: NativeDate;
115
+ isDeleted: boolean;
116
+ features: Types.ObjectId[];
115
117
  updatedBy: Types.ObjectId;
116
- userId: {
118
+ organisationId: {
117
119
  prototype?: Types.ObjectId | null | undefined;
118
120
  cacheHexString?: unknown;
119
121
  generate?: {} | null | undefined;
@@ -122,14 +124,12 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
122
124
  createFromBase64?: {} | null | undefined;
123
125
  isValid?: {} | null | undefined;
124
126
  };
125
- inviteStatus: "Pending" | "Accepted";
127
+ inviteStatus: INVITE_STATUS;
126
128
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
127
129
  createdAt: NativeDate;
128
130
  updatedAt: NativeDate;
129
131
  } & {
130
- deletedAt: NativeDate;
131
- isDeleted: boolean;
132
- organisationId: {
132
+ user: {
133
133
  prototype?: Types.ObjectId | null | undefined;
134
134
  cacheHexString?: unknown;
135
135
  generate?: {} | null | undefined;
@@ -138,9 +138,11 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
138
138
  createFromBase64?: {} | null | undefined;
139
139
  isValid?: {} | null | undefined;
140
140
  };
141
- accessType: OWNERSHIP_TYPE;
141
+ deletedAt: NativeDate;
142
+ isDeleted: boolean;
143
+ features: Types.ObjectId[];
142
144
  updatedBy: Types.ObjectId;
143
- userId: {
145
+ organisationId: {
144
146
  prototype?: Types.ObjectId | null | undefined;
145
147
  cacheHexString?: unknown;
146
148
  generate?: {} | null | undefined;
@@ -149,14 +151,12 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
149
151
  createFromBase64?: {} | null | undefined;
150
152
  isValid?: {} | null | undefined;
151
153
  };
152
- inviteStatus: "Pending" | "Accepted";
154
+ inviteStatus: INVITE_STATUS;
153
155
  }>> & import("mongoose").FlatRecord<{
154
156
  createdAt: NativeDate;
155
157
  updatedAt: NativeDate;
156
158
  } & {
157
- deletedAt: NativeDate;
158
- isDeleted: boolean;
159
- organisationId: {
159
+ user: {
160
160
  prototype?: Types.ObjectId | null | undefined;
161
161
  cacheHexString?: unknown;
162
162
  generate?: {} | null | undefined;
@@ -165,9 +165,11 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
165
165
  createFromBase64?: {} | null | undefined;
166
166
  isValid?: {} | null | undefined;
167
167
  };
168
- accessType: OWNERSHIP_TYPE;
168
+ deletedAt: NativeDate;
169
+ isDeleted: boolean;
170
+ features: Types.ObjectId[];
169
171
  updatedBy: Types.ObjectId;
170
- userId: {
172
+ organisationId: {
171
173
  prototype?: Types.ObjectId | null | undefined;
172
174
  cacheHexString?: unknown;
173
175
  generate?: {} | null | undefined;
@@ -176,7 +178,7 @@ export declare const OrganisationTeamModel: import("mongoose").Model<{
176
178
  createFromBase64?: {} | null | undefined;
177
179
  isValid?: {} | null | undefined;
178
180
  };
179
- inviteStatus: "Pending" | "Accepted";
181
+ inviteStatus: INVITE_STATUS;
180
182
  }> & {
181
183
  _id: Types.ObjectId;
182
184
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"organisationTeams.entity.d.ts","sourceRoot":"","sources":["../../src/entity/organisationTeams.entity.ts"],"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AAS,EAAE,KAAK,CAAC,QAAQ,CAAC;CAC3B;AAYD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAC80H,MAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAf,MAAO,QAAQ;;;GADxyH,CAAC"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrganisationTeamModel = void 0;
4
- const email_builder_utils_1 = require("email-builder-utils");
5
4
  const mongoose_1 = require("mongoose");
5
+ const utilities_1 = require("../utilities");
6
6
  const OrganisationTeamSchema = new mongoose_1.Schema({
7
7
  organisationId: { type: mongoose_1.Types.ObjectId, ref: "organisation", required: true },
8
- userId: { type: mongoose_1.Types.ObjectId, ref: "user", required: true },
9
- accessType: { type: String, enum: Object.values([email_builder_utils_1.OWNERSHIP_TYPE.CO_OWNER, email_builder_utils_1.OWNERSHIP_TYPE.EDITOR, email_builder_utils_1.OWNERSHIP_TYPE.VIEWER]), default: email_builder_utils_1.OWNERSHIP_TYPE.EDITOR },
10
- inviteStatus: { type: String, enum: ["Pending", "Accepted"], default: "Accepted" },
8
+ user: { type: mongoose_1.Types.ObjectId, ref: "user", required: true },
9
+ features: { type: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'feature' }], default: [], _id: false },
10
+ inviteStatus: { type: String, enum: Object.values(utilities_1.INVITE_STATUS), default: utilities_1.INVITE_STATUS.PENDING },
11
11
  isDeleted: { type: Boolean, default: false },
12
12
  deletedAt: { type: Date, default: null },
13
13
  updatedBy: { type: mongoose_1.Schema.Types.ObjectId, required: true },
@@ -1,10 +1,4 @@
1
1
  import { Schema, Types, Document } from "mongoose";
2
- export declare enum PLAN_DURATIONS {
3
- ONE = 1,
4
- THREE = 3,
5
- SIX = 6,
6
- TWELVE = 12
7
- }
8
2
  export interface ITransactionHistory {
9
3
  subscriptionPlanId: Types.ObjectId;
10
4
  transactionId: string;
@@ -16,9 +10,10 @@ export interface ISubscriptionQuota {
16
10
  privateTemplateCount: number;
17
11
  publicTemplateCount: number;
18
12
  smtpConfigAllowed: boolean;
13
+ canCreateOrganisation: boolean;
19
14
  }
20
15
  export interface IPlanHistory extends Document {
21
- userId: Types.ObjectId;
16
+ user: Types.ObjectId;
22
17
  subscriptionPlanId: Types.ObjectId;
23
18
  purchaseDate: Date;
24
19
  renewalDate: Date | null;
@@ -29,8 +24,6 @@ export interface IPlanHistory extends Document {
29
24
  updatedBy: Types.ObjectId;
30
25
  transactionHistory: ITransactionHistory[];
31
26
  subscriptionQuota: ISubscriptionQuota;
32
- durationInMonths: PLAN_DURATIONS;
33
- planPrice: string;
34
27
  }
35
28
  export declare const TransactionHistorySchema: Schema<ITransactionHistory, import("mongoose").Model<ITransactionHistory, any, any, any, Document<unknown, any, ITransactionHistory> & ITransactionHistory & {
36
29
  _id: Types.ObjectId;
@@ -1 +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,oBAAY,cAAc;IACxB,GAAG,IAAI;IACP,KAAK,IAAI;IACT,GAAG,IAAI;IACP,MAAM,KAAK;CACZ;AAED,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,M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M,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC;IACnC,YAAY,EAAE,IAAI,CAAC;IACnB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,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;SA8Bq9E,MAAO,QAAQ;;;;SAAf,MAAO,QAAQ;;;EAzBv/E,CAAC;AAEnB,eAAO,MAAM,uBAAuB;SAuBs9E,MAAO,QAAQ;;;;SAAf,MAAO,QAAQ;;;EAjBv/E,CAAC;AAEnB,eAAO,MAAM,iBAAiB;;;;;;;;EAYN,CAAC;AAEzB,eAAO,MAAM,gBAAgB;;;;OAAyD,CAAC"}
@@ -1,14 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlanHistoryModel = exports.PlanHistorySchema = exports.SubscriptionQuotaSchema = exports.TransactionHistorySchema = exports.PLAN_DURATIONS = void 0;
3
+ exports.PlanHistoryModel = exports.PlanHistorySchema = exports.SubscriptionQuotaSchema = exports.TransactionHistorySchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
- var PLAN_DURATIONS;
6
- (function (PLAN_DURATIONS) {
7
- PLAN_DURATIONS[PLAN_DURATIONS["ONE"] = 1] = "ONE";
8
- PLAN_DURATIONS[PLAN_DURATIONS["THREE"] = 3] = "THREE";
9
- PLAN_DURATIONS[PLAN_DURATIONS["SIX"] = 6] = "SIX";
10
- PLAN_DURATIONS[PLAN_DURATIONS["TWELVE"] = 12] = "TWELVE";
11
- })(PLAN_DURATIONS || (exports.PLAN_DURATIONS = PLAN_DURATIONS = {}));
12
5
  exports.TransactionHistorySchema = new mongoose_1.Schema({
13
6
  subscriptionPlanId: { type: mongoose_1.Schema.Types.ObjectId, ref: "subscription-plan", required: true },
14
7
  transactionId: { type: String, required: true },
@@ -19,10 +12,11 @@ exports.SubscriptionQuotaSchema = new mongoose_1.Schema({
19
12
  emailSentCount: { type: Number, required: true },
20
13
  publicTemplateCount: { type: Number, required: true },
21
14
  privateTemplateCount: { type: Number, required: true },
22
- smtpConfigAllowed: { type: Boolean, default: false }
15
+ smtpConfigAllowed: { type: Boolean, default: false },
16
+ canCreateOrganisation: { type: Boolean, default: false }
23
17
  }, { _id: false });
24
18
  exports.PlanHistorySchema = new mongoose_1.Schema({
25
- userId: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true },
19
+ user: { type: mongoose_1.Schema.Types.ObjectId, ref: "user", required: true },
26
20
  subscriptionPlanId: { type: mongoose_1.Schema.Types.ObjectId, ref: "subscription-plan", required: true },
27
21
  purchaseDate: { type: Date, required: true },
28
22
  renewalDate: { type: Date, default: null },
@@ -5,11 +5,11 @@ export interface ISubscriptionPlan extends Document {
5
5
  privateTemplateLimit: number;
6
6
  publicTemplateLimit: number;
7
7
  smtpConfigAllowed: boolean;
8
+ canCreateOrganisation: boolean;
8
9
  isDeleted: boolean;
9
10
  updatedBy: mongoose.Types.ObjectId;
10
11
  deletedAt: Date;
11
12
  isDefault: boolean;
12
- canCreateOrganisation: boolean;
13
13
  }
14
14
  export declare const SubscriptionPlanModel: mongoose.Model<ISubscriptionPlan, {}, {}, {}, mongoose.Document<unknown, {}, ISubscriptionPlan> & ISubscriptionPlan & {
15
15
  _id: mongoose.Types.ObjectId;
@@ -1 +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;IACnB,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAiBD,eAAO,MAAM,qBAAqB;;;;OAAwE,CAAC"}
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,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAiBD,eAAO,MAAM,qBAAqB;;;;OAAwE,CAAC"}
@@ -41,10 +41,10 @@ const SubscriptionPlanSchema = new mongoose_1.Schema({
41
41
  privateTemplateLimit: { type: Number, required: true },
42
42
  publicTemplateLimit: { type: Number, required: true },
43
43
  smtpConfigAllowed: { type: Boolean, required: true },
44
+ canCreateOrganisation: { type: Boolean, default: false },
44
45
  isDeleted: { type: Boolean, default: false },
45
46
  updatedBy: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "user", required: true },
46
47
  deletedAt: { type: Date, default: null },
47
48
  isDefault: { type: Boolean, default: false, index: { unique: true, partialFilterExpression: { isDefault: true } } },
48
- canCreateOrganisation: { type: Boolean, default: false },
49
49
  }, { timestamps: true, });
50
50
  exports.SubscriptionPlanModel = (0, mongoose_1.model)("subscription-plan", SubscriptionPlanSchema);
@@ -13,8 +13,6 @@ interface IUser {
13
13
  deletedAt: Date;
14
14
  isDeleted: boolean;
15
15
  updateBy: Types.ObjectId;
16
- currentPlanId: Types.ObjectId;
17
- organisationId: Types.ObjectId[];
18
16
  }
19
17
  export declare const UserModel: import("mongoose").Model<IUser, {}, {}, {}, import("mongoose").Document<unknown, {}, IUser> & IUser & {
20
18
  _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,CAAC;IACzB,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC9B,cAAc,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;CAClC;AAmBD,eAAO,MAAM,SAAS;SACujH,MAAO,QAAQ;;;OADniH,CAAC"}
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;CAC1B;AAiBD,eAAO,MAAM,SAAS;SACuyH,MAAO,QAAQ;;;OADnxH,CAAC"}
@@ -13,8 +13,6 @@ 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' },
17
- currentPlanId: { type: mongoose_1.Schema.Types.ObjectId, ref: "subscription-plan" },
18
- organisationId: [{ type: mongoose_1.Schema.Types.ObjectId, ref: "organisation", default: [] }]
16
+ updateBy: { type: mongoose_1.Schema.Types.ObjectId, ref: 'user' }
19
17
  }, { timestamps: true, });
20
18
  exports.UserModel = (0, mongoose_1.model)("user", UserSchema);
@@ -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,kBAiDxE,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,kBA+CxE,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,15 +31,7 @@ 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"
38
- }).populate({
39
- path: "organisationId",
40
- select: "_id name"
41
- })
42
- .lean();
34
+ }).lean();
43
35
  if (!user) {
44
36
  throw new resHandler_1.UnauthorizedRequestError(utilities_1.SERVER_MESSAGES.SE_USER_NOT_FOUND);
45
37
  }
@@ -52,6 +44,10 @@ const authorize = () => {
52
44
  req.user.isAdmin = true;
53
45
  req.user.groups.push({ name: "DEFAULT", features: Object.values(email_builder_utils_1.FEATURE_TYPE).map((value) => ({ name: value })) });
54
46
  }
47
+ let currentPlanDetail = await entity_1.PlanHistoryModel.find({ user: user._id.toString() }).lean();
48
+ if (currentPlanDetail.length) {
49
+ req.userSubsciptionQuota = currentPlanDetail[0].subscriptionQuota;
50
+ }
55
51
  next();
56
52
  }
57
53
  }
@@ -1,5 +1,6 @@
1
1
  import { Request } from "express";
2
2
  import { FEATURE_TYPE, OWNERSHIP_TYPE, ROLES } from "email-builder-utils";
3
+ import { ISubscriptionQuota } from "../entity";
3
4
  export interface IRequestUser {
4
5
  name: string;
5
6
  email: string | null;
@@ -16,11 +17,10 @@ export interface IRequestUser {
16
17
  isDeleted: boolean;
17
18
  isAdmin: boolean;
18
19
  _id: string;
19
- currentPlanId: string;
20
- organisationId: string[];
21
20
  }
22
21
  export interface IRequest extends Request {
23
22
  user?: IRequestUser;
23
+ userSubsciptionQuota?: ISubscriptionQuota;
24
24
  file?: any;
25
25
  }
26
26
  //# sourceMappingURL=IRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IRequest.d.ts","sourceRoot":"","sources":["../../src/types/IRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM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AAC;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;CACf;AAED,MAAM,WAAW,QAAS,SAAQ,OAAO;IACrC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;IAC1C,IAAI,CAAC,EAAE,GAAG,CAAC;CACd"}
@@ -1 +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"}
1
+ {"version":3,"file":"cryptoUtils.d.ts","sourceRoot":"","sources":["../../src/utilities/cryptoUtils.ts"],"names":[],"mappings":"AAcA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C"}
@@ -6,20 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.encrypt = encrypt;
7
7
  exports.decrypt = decrypt;
8
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;
9
+ // Ensure the encryption key is 32 bytes (256 bits)
10
+ const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY || '2c6ee24b09816a6f14f95d2838a429d8e5e8b028fbd421d24fc43b96b4a9f3c0';
11
+ const IV_LENGTH = 16; // AES block size (128 bits)
12
+ // Validate key length and make sure it's 32 bytes
13
+ function getEncryptionKey(key) {
14
+ const hashedKey = crypto_1.default.createHash('sha256').update(key).digest(); // Ensures a 32-byte key
15
+ return hashedKey;
16
+ }
17
+ const encryptionKey = getEncryptionKey(ENCRYPTION_KEY);
11
18
  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);
19
+ const iv = crypto_1.default.randomBytes(IV_LENGTH); // Generate random IV
20
+ const cipher = crypto_1.default.createCipheriv('aes-256-cbc', encryptionKey, iv); // Use the correct 32-byte key and 16-byte IV
14
21
  let encrypted = cipher.update(text, 'utf8', 'hex');
15
22
  encrypted += cipher.final('hex');
16
- return iv.toString('hex') + ':' + encrypted;
23
+ return iv.toString('hex') + ':' + encrypted; // Return the IV and encrypted text
17
24
  }
18
25
  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);
26
+ const parts = text.split(':'); // Split the IV and encrypted text
27
+ const iv = Buffer.from(parts.shift(), 'hex'); // Convert IV from hex to buffer
28
+ const encryptedText = parts.join(':'); // Get the encrypted text
29
+ const decipher = crypto_1.default.createDecipheriv('aes-256-cbc', encryptionKey, iv); // Use the correct 32-byte key and 16-byte IV
23
30
  let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
24
31
  decrypted += decipher.final('utf8');
25
32
  return decrypted;
@@ -0,0 +1,5 @@
1
+ export declare enum INVITE_STATUS {
2
+ PENDING = "PENDING",
3
+ ACCEPTED = "ACCEPTED"
4
+ }
5
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/utilities/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INVITE_STATUS = void 0;
4
+ var INVITE_STATUS;
5
+ (function (INVITE_STATUS) {
6
+ INVITE_STATUS["PENDING"] = "PENDING";
7
+ INVITE_STATUS["ACCEPTED"] = "ACCEPTED";
8
+ })(INVITE_STATUS || (exports.INVITE_STATUS = INVITE_STATUS = {}));
@@ -4,4 +4,5 @@ export * from "./encryptionUtils";
4
4
  export * from "./sendMailViaGmail";
5
5
  export * from "./serverMessages";
6
6
  export * from "./cryptoUtils";
7
+ export * from "./enums";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
@@ -20,3 +20,4 @@ __exportStar(require("./encryptionUtils"), exports);
20
20
  __exportStar(require("./sendMailViaGmail"), exports);
21
21
  __exportStar(require("./serverMessages"), exports);
22
22
  __exportStar(require("./cryptoUtils"), exports);
23
+ __exportStar(require("./enums"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz-email-builder-shared",
3
- "version": "1.6.20",
3
+ "version": "1.6.22",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [