@zyther/tzmail 0.1.3 → 0.5.0

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 (132) hide show
  1. package/README.md +412 -79
  2. package/dist/core/enums/theme.enum.d.ts +11 -1
  3. package/dist/core/enums/theme.enum.d.ts.map +1 -1
  4. package/dist/core/enums/theme.enum.js +10 -0
  5. package/dist/core/interfaces/email.interface.d.ts +95 -5
  6. package/dist/core/interfaces/email.interface.d.ts.map +1 -1
  7. package/dist/core/interfaces/template.interface.d.ts +12 -1
  8. package/dist/core/interfaces/template.interface.d.ts.map +1 -1
  9. package/dist/factories/email-factory.d.ts +32 -6
  10. package/dist/factories/email-factory.d.ts.map +1 -1
  11. package/dist/factories/email-factory.js +110 -6
  12. package/dist/factories/template-factory.d.ts.map +1 -1
  13. package/dist/factories/template-factory.js +170 -60
  14. package/dist/index.d.ts +16 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +23 -1
  17. package/dist/providers/mailgun.transport.d.ts +10 -0
  18. package/dist/providers/mailgun.transport.d.ts.map +1 -0
  19. package/dist/providers/mailgun.transport.js +85 -0
  20. package/dist/providers/nodemailer.transport.d.ts +11 -0
  21. package/dist/providers/nodemailer.transport.d.ts.map +1 -0
  22. package/dist/providers/nodemailer.transport.js +23 -0
  23. package/dist/providers/provider-utils.d.ts +17 -0
  24. package/dist/providers/provider-utils.d.ts.map +1 -0
  25. package/dist/providers/provider-utils.js +89 -0
  26. package/dist/providers/provider.interface.d.ts +30 -0
  27. package/dist/providers/provider.interface.d.ts.map +1 -0
  28. package/dist/providers/provider.interface.js +2 -0
  29. package/dist/providers/sendgrid.transport.d.ts +10 -0
  30. package/dist/providers/sendgrid.transport.d.ts.map +1 -0
  31. package/dist/providers/sendgrid.transport.js +76 -0
  32. package/dist/queues/bullmq-email-queue.d.ts +153 -0
  33. package/dist/queues/bullmq-email-queue.d.ts.map +1 -0
  34. package/dist/queues/bullmq-email-queue.js +292 -0
  35. package/dist/services/attachment.service.d.ts +15 -37
  36. package/dist/services/attachment.service.d.ts.map +1 -1
  37. package/dist/services/attachment.service.js +58 -46
  38. package/dist/services/email.service.d.ts +22 -22
  39. package/dist/services/email.service.d.ts.map +1 -1
  40. package/dist/services/email.service.js +117 -33
  41. package/dist/services/template.service.d.ts +24 -111
  42. package/dist/services/template.service.d.ts.map +1 -1
  43. package/dist/services/template.service.js +273 -362
  44. package/dist/templates/base/color-accessibility.d.ts +4 -0
  45. package/dist/templates/base/color-accessibility.d.ts.map +1 -0
  46. package/dist/templates/base/color-accessibility.js +38 -0
  47. package/dist/templates/base/template-builder.d.ts +4 -1
  48. package/dist/templates/base/template-builder.d.ts.map +1 -1
  49. package/dist/templates/base/template-builder.js +276 -527
  50. package/dist/templates/themes/aurora.theme.d.ts +12 -0
  51. package/dist/templates/themes/aurora.theme.d.ts.map +1 -0
  52. package/dist/templates/themes/aurora.theme.js +88 -0
  53. package/dist/templates/themes/corporate.theme.d.ts +2 -1
  54. package/dist/templates/themes/corporate.theme.d.ts.map +1 -1
  55. package/dist/templates/themes/corporate.theme.js +139 -102
  56. package/dist/templates/themes/editorial.theme.d.ts +12 -0
  57. package/dist/templates/themes/editorial.theme.d.ts.map +1 -0
  58. package/dist/templates/themes/editorial.theme.js +90 -0
  59. package/dist/templates/themes/forest.theme.d.ts +12 -0
  60. package/dist/templates/themes/forest.theme.d.ts.map +1 -0
  61. package/dist/templates/themes/forest.theme.js +89 -0
  62. package/dist/templates/themes/glass.theme.d.ts +12 -0
  63. package/dist/templates/themes/glass.theme.d.ts.map +1 -0
  64. package/dist/templates/themes/glass.theme.js +88 -0
  65. package/dist/templates/themes/lavender.theme.d.ts +12 -0
  66. package/dist/templates/themes/lavender.theme.d.ts.map +1 -0
  67. package/dist/templates/themes/lavender.theme.js +91 -0
  68. package/dist/templates/themes/midnight.theme.d.ts +12 -0
  69. package/dist/templates/themes/midnight.theme.d.ts.map +1 -0
  70. package/dist/templates/themes/midnight.theme.js +91 -0
  71. package/dist/templates/themes/minimal.theme.d.ts +2 -1
  72. package/dist/templates/themes/minimal.theme.d.ts.map +1 -1
  73. package/dist/templates/themes/minimal.theme.js +142 -107
  74. package/dist/templates/themes/modern.theme.d.ts +2 -1
  75. package/dist/templates/themes/modern.theme.d.ts.map +1 -1
  76. package/dist/templates/themes/modern.theme.js +109 -74
  77. package/dist/templates/themes/monokai.theme.d.ts +2 -1
  78. package/dist/templates/themes/monokai.theme.d.ts.map +1 -1
  79. package/dist/templates/themes/monokai.theme.js +102 -66
  80. package/dist/templates/themes/neobrutal.theme.d.ts +12 -0
  81. package/dist/templates/themes/neobrutal.theme.d.ts.map +1 -0
  82. package/dist/templates/themes/neobrutal.theme.js +91 -0
  83. package/dist/templates/themes/ocean.theme.d.ts +12 -0
  84. package/dist/templates/themes/ocean.theme.d.ts.map +1 -0
  85. package/dist/templates/themes/ocean.theme.js +90 -0
  86. package/dist/templates/themes/pastel.theme.d.ts +12 -0
  87. package/dist/templates/themes/pastel.theme.d.ts.map +1 -0
  88. package/dist/templates/themes/pastel.theme.js +89 -0
  89. package/dist/templates/themes/sunset.theme.d.ts +12 -0
  90. package/dist/templates/themes/sunset.theme.d.ts.map +1 -0
  91. package/dist/templates/themes/sunset.theme.js +90 -0
  92. package/dist/templates/themes/system.theme.d.ts +2 -1
  93. package/dist/templates/themes/system.theme.d.ts.map +1 -1
  94. package/dist/templates/themes/system.theme.js +81 -47
  95. package/dist/templates/themes/theme.interface.d.ts +48 -0
  96. package/dist/templates/themes/theme.interface.d.ts.map +1 -1
  97. package/package.json +36 -14
  98. package/src/core/enums/template-part.enum.ts +7 -0
  99. package/src/core/enums/theme.enum.ts +18 -0
  100. package/src/core/interfaces/email.interface.ts +116 -0
  101. package/src/core/interfaces/template.interface.ts +71 -0
  102. package/src/factories/email-factory.ts +208 -0
  103. package/src/factories/template-factory.ts +201 -0
  104. package/src/index.ts +53 -0
  105. package/src/providers/mailgun.transport.ts +80 -0
  106. package/src/providers/nodemailer.transport.ts +20 -0
  107. package/src/providers/provider-utils.ts +91 -0
  108. package/src/providers/provider.interface.ts +26 -0
  109. package/src/providers/sendgrid.transport.ts +80 -0
  110. package/src/queues/bullmq-email-queue.ts +418 -0
  111. package/src/services/attachment.service.ts +98 -0
  112. package/src/services/email.service.ts +151 -0
  113. package/src/services/template.service.ts +431 -0
  114. package/src/templates/base/color-accessibility.ts +31 -0
  115. package/src/templates/base/template-builder.ts +438 -0
  116. package/src/templates/themes/aurora.theme.ts +91 -0
  117. package/src/templates/themes/corporate.theme.ts +156 -0
  118. package/src/templates/themes/editorial.theme.ts +93 -0
  119. package/src/templates/themes/forest.theme.ts +92 -0
  120. package/src/templates/themes/glass.theme.ts +91 -0
  121. package/src/templates/themes/lavender.theme.ts +94 -0
  122. package/src/templates/themes/midnight.theme.ts +94 -0
  123. package/src/templates/themes/minimal.theme.ts +158 -0
  124. package/src/templates/themes/modern.theme.ts +124 -0
  125. package/src/templates/themes/monokai.theme.ts +117 -0
  126. package/src/templates/themes/neobrutal.theme.ts +94 -0
  127. package/src/templates/themes/ocean.theme.ts +93 -0
  128. package/src/templates/themes/pastel.theme.ts +92 -0
  129. package/src/templates/themes/sunset.theme.ts +93 -0
  130. package/src/templates/themes/system.theme.ts +92 -0
  131. package/src/templates/themes/theme.interface.ts +95 -0
  132. package/src/tests/template.service.test.ts +1 -0
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PastelTheme = void 0;
4
+ const theme_enum_1 = require("../../core/enums/theme.enum");
5
+ class PastelTheme {
6
+ id = theme_enum_1.ThemeType.PASTEL;
7
+ name = 'Pastel';
8
+ light = {
9
+ primary: '#76536B',
10
+ secondary: '#796C78',
11
+ background: '#FFFAF4',
12
+ text: '#352D36',
13
+ textMuted: '#655B65',
14
+ border: '#E8DCD9',
15
+ success: '#356B56',
16
+ error: '#9B4148',
17
+ warning: '#80551F'
18
+ };
19
+ dark = {
20
+ primary: '#765A80',
21
+ secondary: '#C7B7CB',
22
+ background: '#211D27',
23
+ text: '#F7F0F5',
24
+ textMuted: '#C9BEC9',
25
+ border: '#49404D',
26
+ success: '#8FCBAA',
27
+ error: '#F0A0A4',
28
+ warning: '#E8C17B'
29
+ };
30
+ typography = {
31
+ fontFamily: 'Arial, Helvetica, sans-serif',
32
+ fontSizes: {
33
+ small: '14px',
34
+ medium: '16px',
35
+ large: '18px',
36
+ xlarge: '26px'
37
+ },
38
+ fontWeights: {
39
+ normal: 400,
40
+ medium: 500,
41
+ bold: 700
42
+ }
43
+ };
44
+ spacing = {
45
+ xs: '6px',
46
+ sm: '12px',
47
+ md: '20px',
48
+ lg: '30px',
49
+ xl: '44px'
50
+ };
51
+ emailStyles = {
52
+ maxWidthPx: 600,
53
+ container: {
54
+ borderColor: 'border',
55
+ borderWidth: '1px',
56
+ borderRadius: '14px',
57
+ boxShadow: '0 2px 10px rgba(53, 45, 54, 0.08)'
58
+ },
59
+ header: {
60
+ accentColor: 'primary',
61
+ accentWidth: '3px',
62
+ horizontalPadding: '28px',
63
+ logoColor: 'primary',
64
+ logoFontFamily: 'Georgia, "Times New Roman", serif',
65
+ logoLetterSpacing: '0.03em',
66
+ imageBorderRadius: '10px'
67
+ },
68
+ body: {
69
+ accentColor: 'secondary',
70
+ accentWidth: '2px',
71
+ borderRadius: '10px',
72
+ boxShadow: 'none',
73
+ horizontalPadding: '28px',
74
+ lineHeight: 1.6
75
+ },
76
+ button: {
77
+ appearance: 'solid',
78
+ borderRadius: '18px',
79
+ borderWidth: '1px',
80
+ boxShadow: 'none',
81
+ letterSpacing: '0.01em'
82
+ },
83
+ footer: {
84
+ accentColor: 'border',
85
+ accentWidth: '1px'
86
+ }
87
+ };
88
+ }
89
+ exports.PastelTheme = PastelTheme;
@@ -0,0 +1,12 @@
1
+ import { ThemeType } from '../../core/enums/theme.enum';
2
+ import { ITheme, IThemeColors, ITypography, ISpacing, IThemeEmailStyles } from './theme.interface';
3
+ export declare class SunsetTheme implements ITheme {
4
+ id: ThemeType;
5
+ name: string;
6
+ light: IThemeColors;
7
+ dark: IThemeColors;
8
+ typography: ITypography;
9
+ spacing: ISpacing;
10
+ emailStyles: IThemeEmailStyles;
11
+ }
12
+ //# sourceMappingURL=sunset.theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sunset.theme.d.ts","sourceRoot":"","sources":["../../../src/templates/themes/sunset.theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEnG,qBAAa,WAAY,YAAW,MAAM;IACxC,EAAE,YAAoB;IACtB,IAAI,SAAY;IAEhB,KAAK,EAAE,YAAY,CAUjB;IAEF,IAAI,EAAE,YAAY,CAUhB;IAEF,UAAU,EAAE,WAAW,CAarB;IAEF,OAAO,EAAE,QAAQ,CAMf;IAEF,WAAW,EAAE,iBAAiB,CAqC5B;CACH"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SunsetTheme = void 0;
4
+ const theme_enum_1 = require("../../core/enums/theme.enum");
5
+ class SunsetTheme {
6
+ id = theme_enum_1.ThemeType.SUNSET;
7
+ name = 'Sunset';
8
+ light = {
9
+ primary: '#A63F32',
10
+ secondary: '#8A5548',
11
+ background: '#FFF7F0',
12
+ text: '#38242E',
13
+ textMuted: '#755B60',
14
+ border: '#E8CFC4',
15
+ success: '#286B4D',
16
+ error: '#A52E35',
17
+ warning: '#81500A'
18
+ };
19
+ dark = {
20
+ primary: '#FF927A',
21
+ secondary: '#E8B077',
22
+ background: '#211923',
23
+ text: '#FFF1E8',
24
+ textMuted: '#C8B3B8',
25
+ border: '#503842',
26
+ success: '#81D0A4',
27
+ error: '#FF8A91',
28
+ warning: '#F5C36B'
29
+ };
30
+ typography = {
31
+ fontFamily: 'Arial, Helvetica, sans-serif',
32
+ fontSizes: {
33
+ small: '14px',
34
+ medium: '16px',
35
+ large: '18px',
36
+ xlarge: '26px'
37
+ },
38
+ fontWeights: {
39
+ normal: 400,
40
+ medium: 500,
41
+ bold: 700
42
+ }
43
+ };
44
+ spacing = {
45
+ xs: '6px',
46
+ sm: '12px',
47
+ md: '20px',
48
+ lg: '30px',
49
+ xl: '44px'
50
+ };
51
+ emailStyles = {
52
+ maxWidthPx: 600,
53
+ container: {
54
+ borderColor: 'border',
55
+ borderWidth: '1px',
56
+ borderRadius: '12px',
57
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.08)'
58
+ },
59
+ header: {
60
+ accentColor: 'primary',
61
+ accentWidth: '3px',
62
+ horizontalPadding: '30px',
63
+ logoColor: 'primary',
64
+ logoFontFamily: 'Georgia, "Times New Roman", serif',
65
+ logoTextTransform: 'uppercase',
66
+ logoLetterSpacing: '1.2px',
67
+ imageBorderRadius: '6px'
68
+ },
69
+ body: {
70
+ accentColor: 'secondary',
71
+ accentWidth: '2px',
72
+ borderRadius: '8px',
73
+ boxShadow: 'none',
74
+ horizontalPadding: '30px',
75
+ lineHeight: 1.6
76
+ },
77
+ button: {
78
+ appearance: 'solid',
79
+ borderRadius: '6px',
80
+ borderWidth: '1px',
81
+ boxShadow: 'none',
82
+ letterSpacing: '0.4px'
83
+ },
84
+ footer: {
85
+ accentColor: 'border',
86
+ accentWidth: '1px'
87
+ }
88
+ };
89
+ }
90
+ exports.SunsetTheme = SunsetTheme;
@@ -1,5 +1,5 @@
1
1
  import { ThemeType } from '../../core/enums/theme.enum';
2
- import { ITheme } from './theme.interface';
2
+ import { ITheme, IThemeEmailStyles } from './theme.interface';
3
3
  export declare class SystemTheme implements ITheme {
4
4
  id: ThemeType;
5
5
  name: string;
@@ -46,5 +46,6 @@ export declare class SystemTheme implements ITheme {
46
46
  lg: string;
47
47
  xl: string;
48
48
  };
49
+ emailStyles: IThemeEmailStyles;
49
50
  }
50
51
  //# sourceMappingURL=system.theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.theme.d.ts","sourceRoot":"","sources":["../../../src/templates/themes/system.theme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,qBAAa,WAAY,YAAW,MAAM;IACxC,EAAE,YAAoB;IACtB,IAAI,SAAY;IAEhB,KAAK;;;;;;;;;;MAUH;IAEF,IAAI;;;;;;;;;;MAUF;IAEF,UAAU;;;;;;;;;;;;;MAaR;IAEF,OAAO;;;;;;MAML;CACH"}
1
+ {"version":3,"file":"system.theme.d.ts","sourceRoot":"","sources":["../../../src/templates/themes/system.theme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,qBAAa,WAAY,YAAW,MAAM;IACxC,EAAE,YAAoB;IACtB,IAAI,SAAY;IAEhB,KAAK;;;;;;;;;;MAUH;IAEF,IAAI;;;;;;;;;;MAUF;IAEF,UAAU;;;;;;;;;;;;;MAaR;IAEF,OAAO;;;;;;MAML;IAEF,WAAW,EAAE,iBAAiB,CAmC5B;CACH"}
@@ -3,52 +3,86 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SystemTheme = void 0;
4
4
  const theme_enum_1 = require("../../core/enums/theme.enum");
5
5
  class SystemTheme {
6
- constructor() {
7
- this.id = theme_enum_1.ThemeType.SYSTEM;
8
- this.name = 'System';
9
- this.light = {
10
- primary: '#3b82f6',
11
- secondary: '#6b7280',
12
- background: '#ffffff',
13
- text: '#111827',
14
- textMuted: '#6b7280',
15
- border: '#e5e7eb',
16
- success: '#10b981',
17
- error: '#ef4444',
18
- warning: '#f59e0b'
19
- };
20
- this.dark = {
21
- primary: '#3b82f6',
22
- secondary: '#9ca3af',
23
- background: '#111827',
24
- text: '#f9fafb',
25
- textMuted: '#9ca3af',
26
- border: '#374151',
27
- success: '#10b981',
28
- error: '#ef4444',
29
- warning: '#f59e0b'
30
- };
31
- this.typography = {
32
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
33
- fontSizes: {
34
- small: '12px',
35
- medium: '14px',
36
- large: '16px',
37
- xlarge: '20px'
38
- },
39
- fontWeights: {
40
- normal: 400,
41
- medium: 500,
42
- bold: 700
43
- }
44
- };
45
- this.spacing = {
46
- xs: '4px',
47
- sm: '8px',
48
- md: '16px',
49
- lg: '24px',
50
- xl: '32px'
51
- };
52
- }
6
+ id = theme_enum_1.ThemeType.SYSTEM;
7
+ name = 'System';
8
+ light = {
9
+ primary: '#3b82f6',
10
+ secondary: '#6b7280',
11
+ background: '#ffffff',
12
+ text: '#111827',
13
+ textMuted: '#6b7280',
14
+ border: '#e5e7eb',
15
+ success: '#10b981',
16
+ error: '#ef4444',
17
+ warning: '#f59e0b'
18
+ };
19
+ dark = {
20
+ primary: '#3b82f6',
21
+ secondary: '#9ca3af',
22
+ background: '#111827',
23
+ text: '#f9fafb',
24
+ textMuted: '#9ca3af',
25
+ border: '#374151',
26
+ success: '#10b981',
27
+ error: '#ef4444',
28
+ warning: '#f59e0b'
29
+ };
30
+ typography = {
31
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
32
+ fontSizes: {
33
+ small: '12px',
34
+ medium: '14px',
35
+ large: '16px',
36
+ xlarge: '20px'
37
+ },
38
+ fontWeights: {
39
+ normal: 400,
40
+ medium: 500,
41
+ bold: 700
42
+ }
43
+ };
44
+ spacing = {
45
+ xs: '4px',
46
+ sm: '8px',
47
+ md: '16px',
48
+ lg: '24px',
49
+ xl: '32px'
50
+ };
51
+ emailStyles = {
52
+ maxWidthPx: 600,
53
+ container: {
54
+ borderColor: 'border',
55
+ borderWidth: '1px',
56
+ borderRadius: '8px',
57
+ boxShadow: '0 1px 3px rgba(0, 0, 0, 0.08)'
58
+ },
59
+ header: {
60
+ accentColor: 'primary',
61
+ accentWidth: '3px',
62
+ horizontalPadding: '24px',
63
+ logoColor: 'primary',
64
+ logoLetterSpacing: '0.01em',
65
+ imageBorderRadius: '4px'
66
+ },
67
+ body: {
68
+ accentColor: 'primary',
69
+ accentWidth: '2px',
70
+ borderRadius: '4px',
71
+ boxShadow: 'none',
72
+ horizontalPadding: '24px',
73
+ lineHeight: 1.6
74
+ },
75
+ button: {
76
+ appearance: 'solid',
77
+ borderRadius: '6px',
78
+ borderWidth: '0px',
79
+ boxShadow: 'none',
80
+ letterSpacing: '0.01em'
81
+ },
82
+ footer: {
83
+ accentColor: 'secondary',
84
+ accentWidth: '1px'
85
+ }
86
+ };
53
87
  }
54
88
  exports.SystemTheme = SystemTheme;
@@ -1,4 +1,50 @@
1
1
  import { ThemeType } from "../../core/enums/theme.enum";
2
+ export type IThemeColorToken = 'primary' | 'secondary' | 'border' | 'none';
3
+ export type IThemeTextTransform = 'none' | 'uppercase' | 'capitalize';
4
+ /**
5
+ * Optional, email-client-conscious visual tokens used by TemplateBuilder.
6
+ * Existing custom ITheme implementations remain compatible when this is omitted.
7
+ */
8
+ export interface IThemeEmailStyles {
9
+ /** Fixed-width fallback for desktop email clients; the renderer also emits fluid width styles. */
10
+ maxWidthPx: number;
11
+ container: {
12
+ borderColor: IThemeColorToken;
13
+ borderWidth: string;
14
+ borderRadius: string;
15
+ boxShadow: string;
16
+ };
17
+ header: {
18
+ accentColor: IThemeColorToken;
19
+ accentWidth: string;
20
+ horizontalPadding: string;
21
+ logoColor: 'text' | 'primary' | 'secondary';
22
+ logoFontFamily?: string;
23
+ logoTextTransform?: IThemeTextTransform;
24
+ logoLetterSpacing?: string;
25
+ imageBorderRadius: string;
26
+ };
27
+ body: {
28
+ accentColor: IThemeColorToken;
29
+ accentWidth: string;
30
+ borderRadius: string;
31
+ boxShadow: string;
32
+ horizontalPadding: string;
33
+ lineHeight: number;
34
+ };
35
+ button: {
36
+ appearance: 'solid' | 'outline';
37
+ borderRadius: string;
38
+ borderWidth: string;
39
+ boxShadow: string;
40
+ textTransform?: IThemeTextTransform;
41
+ letterSpacing?: string;
42
+ };
43
+ footer: {
44
+ accentColor: IThemeColorToken;
45
+ accentWidth: string;
46
+ };
47
+ }
2
48
  export interface ITheme {
3
49
  id: ThemeType;
4
50
  name: string;
@@ -6,6 +52,8 @@ export interface ITheme {
6
52
  dark: IThemeColors;
7
53
  typography: ITypography;
8
54
  spacing: ISpacing;
55
+ /** Optional structural style tokens; omitted tokens fall back to conservative email-safe defaults. */
56
+ emailStyles?: IThemeEmailStyles;
9
57
  }
10
58
  export interface IThemeColors {
11
59
  primary: string;
@@ -1 +1 @@
1
- {"version":3,"file":"theme.interface.d.ts","sourceRoot":"","sources":["../../../src/templates/themes/theme.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,SAAS,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ"}
1
+ {"version":3,"file":"theme.interface.d.ts","sourceRoot":"","sources":["../../../src/templates/themes/theme.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,kGAAkG;IAClG,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE;QACT,WAAW,EAAE,gBAAgB,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,MAAM,EAAE;QACN,WAAW,EAAE,gBAAgB,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;QAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,iBAAiB,CAAC,EAAE,mBAAmB,CAAC;QACxC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,IAAI,EAAE;QACJ,WAAW,EAAE,gBAAgB,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,MAAM,EAAE;QACN,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;QAChC,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,mBAAmB,CAAC;QACpC,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,MAAM,EAAE;QACN,WAAW,EAAE,gBAAgB,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,SAAS,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;IAClB,sGAAsG;IACtG,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ"}
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@zyther/tzmail",
3
- "version": "0.1.3",
4
- "description": "A powerful and flexible TypeScript/Node.js email package built on top of Nodemailer, featuring a robust templating system with built-in themes, caching, and easy attachment management.",
3
+ "version": "0.5.0",
4
+ "description": "TypeScript email templates, multi-provider delivery and optional BullMQ asynchronous queues.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
- "dist"
8
+ "dist",
9
+ "src"
9
10
  ],
10
11
  "scripts": {
11
12
  "build": "tsc",
12
13
  "dev": "ts-node src/index.ts",
13
14
  "start": "node dist/index.js",
14
- "lint": "eslint src --ext .ts"
15
+ "lint": "eslint . --max-warnings=0",
16
+ "typecheck": "tsc --noEmit",
17
+ "test": "npm run build && node --test test/*.test.cjs",
18
+ "gallery:build": "npm run build && node scripts/generate-theme-gallery.cjs"
15
19
  },
16
20
  "author": "zytherdev <zyther.dev@outlook.com>",
17
21
  "homepage": "https://github.com/zytherdev/tzmail#readme",
@@ -22,6 +26,9 @@
22
26
  "type": "git",
23
27
  "url": "git+https://github.com/zytherdev/tzmail.git"
24
28
  },
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
25
32
  "license": "ISC",
26
33
  "keywords": [
27
34
  "email",
@@ -29,25 +36,40 @@
29
36
  "typescript",
30
37
  "nodejs",
31
38
  "smtp",
39
+ "sendgrid",
40
+ "amazon-ses",
41
+ "mailgun",
42
+ "bullmq",
43
+ "redis-queue",
32
44
  "mail",
33
45
  "nodemailer",
34
46
  "templates",
35
47
  "themes"
36
48
  ],
37
-
38
49
  "peerDependencies": {
39
- "nodemailer": "^6.9.0 || ^7 || ^8"
50
+ "nodemailer": "^6.9.0 || ^7 || ^8",
51
+ "@aws-sdk/client-sesv2": "^3.0.0",
52
+ "bullmq": "^5.0.0 || ^6.0.0"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "@aws-sdk/client-sesv2": {
56
+ "optional": true
57
+ },
58
+ "bullmq": {
59
+ "optional": true
60
+ }
61
+ },
62
+ "dependencies": {
63
+ "@types/nodemailer": "^7.0.11"
40
64
  },
41
-
42
65
  "devDependencies": {
43
- "@types/jest": "^29.5.11",
66
+ "@eslint/js": "^10.0.1",
44
67
  "@types/node": "^25.5.0",
45
- "@types/nodemailer": "^7.0.11",
46
- "jest": "^29.7.0",
68
+ "eslint": "^10.14.0",
69
+ "globals": "^17.14.0",
47
70
  "nodemailer": "^8.0.3",
48
71
  "ts-node": "^10.9.2",
49
- "typescript": "^5.0.0"
50
- },
51
-
52
- "dependencies": {}
72
+ "typescript": "^5.0.0",
73
+ "typescript-eslint": "^8.72.1"
74
+ }
53
75
  }
@@ -0,0 +1,7 @@
1
+
2
+ export enum TemplatePart {
3
+ HEADER = 'header',
4
+ BODY = 'body',
5
+ FOOTER = 'footer',
6
+ BUTTON = 'button'
7
+ }
@@ -0,0 +1,18 @@
1
+
2
+ export enum ThemeType {
3
+ SYSTEM = 'system',
4
+ MONOKAI = 'monokai',
5
+ MODERN = 'modern',
6
+ CORPORATE = 'corporate',
7
+ MINIMAL = 'minimal',
8
+ AURORA = 'aurora',
9
+ OCEAN = 'ocean',
10
+ SUNSET = 'sunset',
11
+ LAVENDER = 'lavender',
12
+ FOREST = 'forest',
13
+ EDITORIAL = 'editorial',
14
+ PASTEL = 'pastel',
15
+ NEOBRUTAL = 'neobrutal',
16
+ GLASS = 'glass',
17
+ MIDNIGHT = 'midnight'
18
+ }
@@ -0,0 +1,116 @@
1
+ import { ITemplate } from './template.interface';
2
+
3
+ export interface IEmailOptions {
4
+ to: string | string[];
5
+ subject: string;
6
+ from?: string;
7
+ cc?: string | string[];
8
+ bcc?: string | string[];
9
+ attachments?: IAttachment[];
10
+ template?: ITemplate;
11
+ /** Primitive named values interpolated into `{{variable}}` placeholders. */
12
+ templateData?: Record<string, unknown>;
13
+ text?: string;
14
+ html?: string;
15
+ }
16
+
17
+ export interface IAttachment {
18
+ filename: string;
19
+ content?: string | Buffer;
20
+ path?: string;
21
+ contentType?: string;
22
+ cid?: string;
23
+ }
24
+
25
+ /**
26
+ * Typed outcome of an email attempt. `success` is true only when the transport
27
+ * did not report rejected recipients. `partial` means that at least one
28
+ * recipient was accepted and at least one rejected; a failure result must not
29
+ * be interpreted as successful delivery. `error` retains the original thrown
30
+ * validation, rendering or transport error, when present.
31
+ */
32
+ export interface IEmailSendResult {
33
+ success: boolean;
34
+ status: 'success' | 'partial' | 'failure';
35
+ messageId?: string;
36
+ response?: string;
37
+ accepted?: Array<string | { address: string; name: string }>;
38
+ rejected?: Array<string | { address: string; name: string }>;
39
+ error?: unknown;
40
+ errorStage?: 'validation' | 'render' | 'smtp' | 'provider';
41
+ }
42
+
43
+ export type IEmailAuth =
44
+ | { user: string; pass: string; type?: 'login' | 'Login' | 'LOGIN' }
45
+ | {
46
+ user: string;
47
+ type: 'oauth2' | 'OAuth2' | 'OAUTH2';
48
+ clientId?: string;
49
+ clientSecret?: string;
50
+ refreshToken?: string;
51
+ accessToken?: string;
52
+ accessUrl?: string;
53
+ expires?: number;
54
+ timeout?: number;
55
+ privateKey?: string | { key: string; passphrase: string };
56
+ serviceClient?: string;
57
+ provisionCallback?: (
58
+ user: string,
59
+ renew: boolean,
60
+ callback: (error: Error | null, accessToken: string, expires: number) => void
61
+ ) => void;
62
+ }
63
+ | { user: string; pass: string; type: 'custom' | 'Custom' | 'CUSTOM'; method: string };
64
+
65
+ export interface IEmailConfig {
66
+ host: string;
67
+ port: number;
68
+ secure: boolean;
69
+ /** Reuse SMTP connections; set true with pool sizing for sustained throughput. */
70
+ pool?: boolean;
71
+ maxConnections?: number;
72
+ maxMessages?: number;
73
+ /** Shared rate limiter window and message limit (requires pool: true). */
74
+ rateDelta?: number;
75
+ rateLimit?: number;
76
+ connectionTimeout?: number;
77
+ greetingTimeout?: number;
78
+ socketTimeout?: number;
79
+ auth: IEmailAuth;
80
+ defaultFrom?: string;
81
+ }
82
+
83
+ /** SendGrid Web API v3 settings. API keys should come from a secret manager. */
84
+ export interface ISendGridConfig {
85
+ apiKey: string;
86
+ defaultFrom: string;
87
+ /** Optional API base URL, for example the regional EU API endpoint. */
88
+ apiUrl?: string;
89
+ requestTimeoutMs?: number;
90
+ /** Optional per-attachment memory guard; API attachments are encoded in memory. */
91
+ maxAttachmentBytes?: number;
92
+ }
93
+
94
+ /** Mailgun Messages API settings. */
95
+ export interface IMailgunConfig {
96
+ apiKey: string;
97
+ domain: string;
98
+ defaultFrom: string;
99
+ region?: 'us' | 'eu';
100
+ /** Optional custom API base URL, useful for regional or controlled endpoints. */
101
+ apiUrl?: string;
102
+ requestTimeoutMs?: number;
103
+ /** Optional per-attachment memory guard; API attachments are uploaded in memory. */
104
+ maxAttachmentBytes?: number;
105
+ }
106
+
107
+ /** Amazon SES v2 settings; when credentials are omitted, the AWS SDK default credential chain is used. */
108
+ export interface IAmazonSesConfig {
109
+ region: string;
110
+ defaultFrom?: string;
111
+ credentials?: {
112
+ accessKeyId: string;
113
+ secretAccessKey: string;
114
+ sessionToken?: string;
115
+ };
116
+ }