@duvdu-v1/duvdu 1.1.355 → 1.1.359

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 (54) hide show
  1. package/build/errors/pdf-generation-error.d.ts +9 -0
  2. package/build/errors/pdf-generation-error.js +15 -0
  3. package/build/guards/isEmailVerified.guard.d.ts +2 -0
  4. package/build/guards/isEmailVerified.guard.js +15 -0
  5. package/build/guards/isPhoneNumberVerified.guard.d.ts +2 -0
  6. package/build/guards/isPhoneNumberVerified.guard.js +15 -0
  7. package/build/index.d.ts +6 -0
  8. package/build/index.js +6 -0
  9. package/build/mailer/mailer.interface.d.ts +68 -0
  10. package/build/mailer/mailer.interface.js +12 -0
  11. package/build/mailer/mailer.service.d.ts +10 -0
  12. package/build/mailer/mailer.service.js +149 -0
  13. package/build/mailer/strategies/resend.strategy.d.ts +6 -0
  14. package/build/mailer/strategies/resend.strategy.js +48 -0
  15. package/build/mailer/strategies/smtp.strategy.d.ts +6 -0
  16. package/build/mailer/strategies/smtp.strategy.js +50 -0
  17. package/build/mailer/templates/layouts/main.hbs +103 -0
  18. package/build/mailer/templates/partials/footer.hbs +4 -0
  19. package/build/mailer/templates/partials/header.hbs +4 -0
  20. package/build/mailer/templates/views/account-update.hbs +20 -0
  21. package/build/mailer/templates/views/complaint-escalation.hbs +23 -0
  22. package/build/mailer/templates/views/invoice.hbs +29 -0
  23. package/build/mailer/templates/views/new-user.hbs +23 -0
  24. package/build/mailer/templates/views/organization-user-created.hbs +25 -0
  25. package/build/mailer/templates/views/reset-password.hbs +14 -0
  26. package/build/mailer/templates/views/verify-email.hbs +14 -0
  27. package/build/mailer/templates/views/welcome.hbs +22 -0
  28. package/build/middlewares/auth.middleware.js +2 -1
  29. package/build/middlewares/optional-auth.middleware.js +2 -1
  30. package/build/models/User.model.d.ts +2 -2
  31. package/build/models/User.model.js +15 -6
  32. package/build/models/contracts.model.d.ts +7 -0
  33. package/build/models/contracts.model.js +7 -0
  34. package/build/models/settings.model.d.ts +6 -0
  35. package/build/models/settings.model.js +6 -0
  36. package/build/services/pdf-templates/layouts/main.hbs +91 -0
  37. package/build/services/pdf-templates/partials/footer.hbs +4 -0
  38. package/build/services/pdf-templates/partials/header.hbs +4 -0
  39. package/build/services/pdf-templates/views/invoice.hbs +60 -0
  40. package/build/services/pdfGenerator.service.d.ts +16 -0
  41. package/build/services/pdfGenerator.service.js +198 -0
  42. package/build/services/rank.service.d.ts +2 -2
  43. package/build/types/JwtPayload.d.ts +2 -1
  44. package/build/types/User.d.ts +18 -7
  45. package/build/types/User.js +4 -0
  46. package/build/types/model-names.d.ts +1 -0
  47. package/build/types/model-names.js +1 -0
  48. package/build/types/pdf.types.d.ts +30 -0
  49. package/build/types/pdf.types.js +7 -0
  50. package/build/types/systemRoles.d.ts +1 -2
  51. package/build/types/systemRoles.js +3 -2
  52. package/build/utils/mask.d.ts +5 -0
  53. package/build/utils/mask.js +49 -0
  54. package/package.json +10 -2
@@ -1,4 +1,4 @@
1
- import { Types } from 'mongoose';
1
+ import { Document, Types } from 'mongoose';
2
2
  import { Icategory } from './Category';
3
3
  import { Irole } from './Role';
4
4
  export declare enum VerificationReason {
@@ -6,13 +6,18 @@ export declare enum VerificationReason {
6
6
  updateOldPhoneNumberVerified = "update-old-phone-number-verified",
7
7
  updateNewPhoneNumber = "update-new-phone-number",
8
8
  verifyUpdatedPhoneNumber = "verify-updated-phone-number",
9
+ updateOldEmail = "update-old-email",
10
+ updateOldEmailVerified = "update-old-email-verified",
11
+ updateNewEmail = "update-new-email",
9
12
  forgetPassword = "forget-password",
10
13
  forgetPasswordVerified = "forget-password-verified",
11
14
  signup = "signup",
15
+ verifyPhoneNumber = "verify-phone-number",
12
16
  completeSginUp = "complete-sginup",
13
17
  CompleteSginUpVerfied = "complete-sginup-verified"
14
18
  }
15
19
  export interface Iuser {
20
+ _id: Types.ObjectId;
16
21
  id: string;
17
22
  googleId?: string;
18
23
  appleId?: string;
@@ -24,12 +29,7 @@ export interface Iuser {
24
29
  };
25
30
  username: string;
26
31
  password?: string;
27
- verificationCode?: {
28
- code?: string;
29
- expireAt?: string;
30
- reason?: VerificationReason;
31
- };
32
- isVerified: boolean;
32
+ verificationCode: IverificationCode;
33
33
  refreshTokens?: {
34
34
  deviceId: string;
35
35
  token: string;
@@ -46,6 +46,8 @@ export interface Iuser {
46
46
  about?: string;
47
47
  isOnline: boolean;
48
48
  isAvaliableToInstantProjects: boolean;
49
+ isEmailVerified: boolean;
50
+ isPhoneNumberVerified: boolean;
49
51
  pricePerHour: number;
50
52
  role: Types.ObjectId | Irole;
51
53
  hasVerificationBadge: boolean;
@@ -87,3 +89,12 @@ export interface Iuser {
87
89
  isDeleted: boolean;
88
90
  hasFreeTime: boolean;
89
91
  }
92
+ export interface IverificationCode extends Document {
93
+ id: string;
94
+ expireAt: Date | null;
95
+ reason: VerificationReason | null;
96
+ code: string | null;
97
+ isVerified: boolean;
98
+ createdAt: string;
99
+ updatedAt: string;
100
+ }
@@ -7,9 +7,13 @@ var VerificationReason;
7
7
  VerificationReason["updateOldPhoneNumberVerified"] = "update-old-phone-number-verified";
8
8
  VerificationReason["updateNewPhoneNumber"] = "update-new-phone-number";
9
9
  VerificationReason["verifyUpdatedPhoneNumber"] = "verify-updated-phone-number";
10
+ VerificationReason["updateOldEmail"] = "update-old-email";
11
+ VerificationReason["updateOldEmailVerified"] = "update-old-email-verified";
12
+ VerificationReason["updateNewEmail"] = "update-new-email";
10
13
  VerificationReason["forgetPassword"] = "forget-password";
11
14
  VerificationReason["forgetPasswordVerified"] = "forget-password-verified";
12
15
  VerificationReason["signup"] = "signup";
16
+ VerificationReason["verifyPhoneNumber"] = "verify-phone-number";
13
17
  VerificationReason["completeSginUp"] = "complete-sginup";
14
18
  VerificationReason["CompleteSginUpVerfied"] = "complete-sginup-verified";
15
19
  })(VerificationReason || (exports.VerificationReason = VerificationReason = {}));
@@ -1,5 +1,6 @@
1
1
  export declare enum MODELS {
2
2
  user = "users",
3
+ userVerification = "user_verification",
3
4
  category = "categories",
4
5
  plan = "plans",
5
6
  role = "roles",
@@ -4,6 +4,7 @@ exports.MODELS = void 0;
4
4
  var MODELS;
5
5
  (function (MODELS) {
6
6
  MODELS["user"] = "users";
7
+ MODELS["userVerification"] = "user_verification";
7
8
  MODELS["category"] = "categories";
8
9
  MODELS["plan"] = "plans";
9
10
  MODELS["role"] = "roles";
@@ -0,0 +1,30 @@
1
+ export declare enum PdfType {
2
+ INVOICE = "invoice"
3
+ }
4
+ export interface PartyDetails {
5
+ name?: string;
6
+ email?: string;
7
+ phone?: string;
8
+ }
9
+ export interface FeeItem {
10
+ label: string;
11
+ value: number;
12
+ }
13
+ export interface InvoiceBreakdown {
14
+ base: number;
15
+ vat: number;
16
+ fees: FeeItem[];
17
+ }
18
+ export interface InvoiceContext {
19
+ transactionId: string;
20
+ date: Date | string;
21
+ currency?: string;
22
+ breakdown: InvoiceBreakdown;
23
+ total: number;
24
+ sp?: PartyDetails;
25
+ client?: PartyDetails;
26
+ recipient?: 'client' | 'sp';
27
+ }
28
+ export interface PdfContextMap {
29
+ [PdfType.INVOICE]: InvoiceContext;
30
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PdfType = void 0;
4
+ var PdfType;
5
+ (function (PdfType) {
6
+ PdfType["INVOICE"] = "invoice";
7
+ })(PdfType || (exports.PdfType = PdfType = {}));
@@ -1,5 +1,4 @@
1
1
  export declare enum SystemRoles {
2
- verified = "verified",
3
- unverified = "unverified",
2
+ user = "user",
4
3
  admin = "admin"
5
4
  }
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SystemRoles = void 0;
4
4
  var SystemRoles;
5
5
  (function (SystemRoles) {
6
- SystemRoles["verified"] = "verified";
7
- SystemRoles["unverified"] = "unverified";
6
+ // verified = 'verified',
7
+ // unverified = 'unverified',
8
+ SystemRoles["user"] = "user";
8
9
  SystemRoles["admin"] = "admin";
9
10
  })(SystemRoles || (exports.SystemRoles = SystemRoles = {}));
@@ -0,0 +1,5 @@
1
+ import { PartyDetails } from '../types/pdf.types';
2
+ export declare const maskEmail: (email?: string) => string | undefined;
3
+ export declare const maskPhone: (phone?: string) => string | undefined;
4
+ export declare const maskName: (name?: string) => string | undefined;
5
+ export declare const maskParty: (party?: PartyDetails) => PartyDetails | undefined;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maskParty = exports.maskName = exports.maskPhone = exports.maskEmail = void 0;
4
+ const maskEmail = (email) => {
5
+ if (!email)
6
+ return undefined;
7
+ const [local, domain] = email.split('@');
8
+ if (!local || !domain)
9
+ return email;
10
+ const dotIdx = domain.lastIndexOf('.');
11
+ const tld = dotIdx >= 0 ? domain.slice(dotIdx) : '';
12
+ const domainHead = dotIdx >= 0 ? domain.slice(0, dotIdx) : domain;
13
+ const maskedLocal = `${local[0]}${'*'.repeat(Math.max(local.length - 1, 2))}`;
14
+ const maskedDomainHead = `${domainHead[0]}${'*'.repeat(Math.max(domainHead.length - 1, 2))}`;
15
+ return `${maskedLocal}@${maskedDomainHead}${tld}`;
16
+ };
17
+ exports.maskEmail = maskEmail;
18
+ const maskPhone = (phone) => {
19
+ if (!phone)
20
+ return undefined;
21
+ const digits = phone.replace(/\D/g, '');
22
+ if (digits.length < 6)
23
+ return phone;
24
+ const prefix = phone.startsWith('+') ? '+' : '';
25
+ const head = digits.slice(0, 4);
26
+ const tail = digits.slice(-2);
27
+ const maskedMiddle = '*'.repeat(digits.length - 6);
28
+ return `${prefix}${head}${maskedMiddle}${tail}`;
29
+ };
30
+ exports.maskPhone = maskPhone;
31
+ const maskName = (name) => {
32
+ if (!name)
33
+ return undefined;
34
+ const parts = name.trim().split(/\s+/);
35
+ if (parts.length === 1)
36
+ return parts[0];
37
+ return `${parts[0]} ${parts[1][0]}.`;
38
+ };
39
+ exports.maskName = maskName;
40
+ const maskParty = (party) => {
41
+ if (!party)
42
+ return undefined;
43
+ return {
44
+ name: (0, exports.maskName)(party.name),
45
+ email: (0, exports.maskEmail)(party.email),
46
+ phone: (0, exports.maskPhone)(party.phone),
47
+ };
48
+ };
49
+ exports.maskParty = maskParty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duvdu-v1/duvdu",
3
- "version": "1.1.355",
3
+ "version": "1.1.359",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [
@@ -8,7 +8,8 @@
8
8
  ],
9
9
  "scripts": {
10
10
  "clean": "rimraf ./build",
11
- "build": "npm run clean && tsc",
11
+ "build": "npm run clean && tsc && npm run copy-templates",
12
+ "copy-templates": "cp -R src/services/pdf-templates ./build/services/ && cp -R src/mailer/templates ./build/mailer/",
12
13
  "fix:build": "mv ./build/common/src/* ./build && rm -rf ./build/auth ./build/common",
13
14
  "pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
14
15
  "lint": "eslint .",
@@ -33,12 +34,16 @@
33
34
  "express-async-errors": "^3.1.1",
34
35
  "express-session": "^1.18.0",
35
36
  "express-validator": "^7.0.1",
37
+ "handlebars": "^4.7.9",
36
38
  "ioredis": "^5.6.1",
37
39
  "jsonwebtoken": "^9.0.2",
38
40
  "mongoose": "^8.0.4",
39
41
  "multer": "^1.4.5-lts.1",
40
42
  "node-nats-streaming": "^0.3.2",
43
+ "nodemailer": "^8.0.5",
44
+ "puppeteer": "^23.11.1",
41
45
  "redis": "^4.6.13",
46
+ "resend": "^6.12.0",
42
47
  "rimraf": "^5.0.5",
43
48
  "typescript": "^5.3.3",
44
49
  "uuid": "^9.0.1",
@@ -46,12 +51,15 @@
46
51
  "winston-daily-rotate-file": "^5.0.0"
47
52
  },
48
53
  "devDependencies": {
54
+ "@types/nodemailer": "^8.0.0",
49
55
  "@types/uuid": "^9.0.8",
50
56
  "del-cli": "^5.1.0",
51
57
  "eslint": "^8.56.0",
52
58
  "eslint-config-prettier": "^9.1.0",
53
59
  "eslint-plugin-import": "^2.29.1",
54
60
  "eslint-plugin-prettier": "^5.1.3",
61
+ "i": "^0.3.7",
62
+ "npm": "^11.12.1",
55
63
  "prettier": "^3.2.4"
56
64
  },
57
65
  "description": ""