tzmail 1.0.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 (56) hide show
  1. package/README.md +5091 -0
  2. package/dist/core/enums/template-part.enum.d.ts +7 -0
  3. package/dist/core/enums/template-part.enum.d.ts.map +1 -0
  4. package/dist/core/enums/template-part.enum.js +10 -0
  5. package/dist/core/enums/theme.enum.d.ts +8 -0
  6. package/dist/core/enums/theme.enum.d.ts.map +1 -0
  7. package/dist/core/enums/theme.enum.js +11 -0
  8. package/dist/core/interfaces/email.interface.d.ts +32 -0
  9. package/dist/core/interfaces/email.interface.d.ts.map +1 -0
  10. package/dist/core/interfaces/email.interface.js +2 -0
  11. package/dist/core/interfaces/template.interface.d.ts +56 -0
  12. package/dist/core/interfaces/template.interface.d.ts.map +1 -0
  13. package/dist/core/interfaces/template.interface.js +2 -0
  14. package/dist/factories/email-factory.d.ts +34 -0
  15. package/dist/factories/email-factory.d.ts.map +1 -0
  16. package/dist/factories/email-factory.js +52 -0
  17. package/dist/factories/template-factory.d.ts +15 -0
  18. package/dist/factories/template-factory.d.ts.map +1 -0
  19. package/dist/factories/template-factory.js +96 -0
  20. package/dist/index.d.ts +15 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +265 -0
  23. package/dist/services/attachment.service.d.ts +48 -0
  24. package/dist/services/attachment.service.d.ts.map +1 -0
  25. package/dist/services/attachment.service.js +93 -0
  26. package/dist/services/email.service.d.ts +31 -0
  27. package/dist/services/email.service.d.ts.map +1 -0
  28. package/dist/services/email.service.js +58 -0
  29. package/dist/services/template.service.d.ts +180 -0
  30. package/dist/services/template.service.d.ts.map +1 -0
  31. package/dist/services/template.service.js +507 -0
  32. package/dist/templates/base/template-builder.d.ts +23 -0
  33. package/dist/templates/base/template-builder.d.ts.map +1 -0
  34. package/dist/templates/base/template-builder.js +676 -0
  35. package/dist/templates/themes/corporate.theme.d.ts +65 -0
  36. package/dist/templates/themes/corporate.theme.d.ts.map +1 -0
  37. package/dist/templates/themes/corporate.theme.js +109 -0
  38. package/dist/templates/themes/minimal.theme.d.ts +70 -0
  39. package/dist/templates/themes/minimal.theme.d.ts.map +1 -0
  40. package/dist/templates/themes/minimal.theme.js +114 -0
  41. package/dist/templates/themes/modern.theme.d.ts +38 -0
  42. package/dist/templates/themes/modern.theme.d.ts.map +1 -0
  43. package/dist/templates/themes/modern.theme.js +81 -0
  44. package/dist/templates/themes/monokai.theme.d.ts +29 -0
  45. package/dist/templates/themes/monokai.theme.d.ts.map +1 -0
  46. package/dist/templates/themes/monokai.theme.js +73 -0
  47. package/dist/templates/themes/system.theme.d.ts +50 -0
  48. package/dist/templates/themes/system.theme.d.ts.map +1 -0
  49. package/dist/templates/themes/system.theme.js +54 -0
  50. package/dist/templates/themes/theme.interface.d.ts +42 -0
  51. package/dist/templates/themes/theme.interface.d.ts.map +1 -0
  52. package/dist/templates/themes/theme.interface.js +2 -0
  53. package/dist/tests/template.service.test.d.ts +1 -0
  54. package/dist/tests/template.service.test.d.ts.map +1 -0
  55. package/dist/tests/template.service.test.js +1 -0
  56. package/package.json +46 -0
@@ -0,0 +1,7 @@
1
+ export declare enum TemplatePart {
2
+ HEADER = "header",
3
+ BODY = "body",
4
+ FOOTER = "footer",
5
+ BUTTON = "button"
6
+ }
7
+ //# sourceMappingURL=template-part.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-part.enum.d.ts","sourceRoot":"","sources":["../../../src/core/enums/template-part.enum.ts"],"names":[],"mappings":"AACA,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TemplatePart = void 0;
4
+ var TemplatePart;
5
+ (function (TemplatePart) {
6
+ TemplatePart["HEADER"] = "header";
7
+ TemplatePart["BODY"] = "body";
8
+ TemplatePart["FOOTER"] = "footer";
9
+ TemplatePart["BUTTON"] = "button";
10
+ })(TemplatePart = exports.TemplatePart || (exports.TemplatePart = {}));
@@ -0,0 +1,8 @@
1
+ export declare enum ThemeType {
2
+ SYSTEM = "system",
3
+ MONOKAI = "monokai",
4
+ MODERN = "modern",
5
+ CORPORATE = "corporate",
6
+ MINIMAL = "minimal"
7
+ }
8
+ //# sourceMappingURL=theme.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.enum.d.ts","sourceRoot":"","sources":["../../../src/core/enums/theme.enum.ts"],"names":[],"mappings":"AACA,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThemeType = void 0;
4
+ var ThemeType;
5
+ (function (ThemeType) {
6
+ ThemeType["SYSTEM"] = "system";
7
+ ThemeType["MONOKAI"] = "monokai";
8
+ ThemeType["MODERN"] = "modern";
9
+ ThemeType["CORPORATE"] = "corporate";
10
+ ThemeType["MINIMAL"] = "minimal";
11
+ })(ThemeType = exports.ThemeType || (exports.ThemeType = {}));
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { ITemplate } from "./template.interface";
4
+ export interface IEmailOptions {
5
+ to: string | string[];
6
+ subject: string;
7
+ from?: string;
8
+ cc?: string | string[];
9
+ bcc?: string | string[];
10
+ attachments?: IAttachment[];
11
+ template?: ITemplate;
12
+ text?: string;
13
+ html?: string;
14
+ }
15
+ export interface IAttachment {
16
+ filename: string;
17
+ content?: string | Buffer;
18
+ path?: string;
19
+ contentType?: string;
20
+ cid?: string;
21
+ }
22
+ export interface IEmailConfig {
23
+ host: string;
24
+ port: number;
25
+ secure: boolean;
26
+ auth: {
27
+ user: string;
28
+ pass: string;
29
+ };
30
+ defaultFrom?: string;
31
+ }
32
+ //# sourceMappingURL=email.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.interface.d.ts","sourceRoot":"","sources":["../../../src/core/interfaces/email.interface.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,56 @@
1
+ import { ThemeType } from "../enums/theme.enum";
2
+ export interface ITemplate {
3
+ name: string;
4
+ theme: ThemeType;
5
+ variant: 'light' | 'dark';
6
+ config: ITemplateConfig;
7
+ render(data: any): Promise<string>;
8
+ }
9
+ export interface ITemplateConfig {
10
+ header?: IHeaderConfig;
11
+ body?: IBodyConfig;
12
+ footer?: IFooterConfig;
13
+ layout?: 'full' | 'minimal';
14
+ spacing?: 'compact' | 'normal' | 'relaxed';
15
+ borderRadius?: 'none' | 'small' | 'medium' | 'large';
16
+ }
17
+ export interface IBodyConfig {
18
+ title?: string;
19
+ message?: string;
20
+ content?: string;
21
+ buttonText?: string;
22
+ buttonUrl?: string;
23
+ buttonVariant?: 'primary' | 'secondary' | 'success' | 'danger';
24
+ alignment?: 'left' | 'center' | 'right';
25
+ backgroundColor?: string;
26
+ textColor?: string;
27
+ fontSize?: number;
28
+ }
29
+ export interface IHeaderConfig {
30
+ show: boolean;
31
+ logo?: {
32
+ type: 'text' | 'image';
33
+ text?: string;
34
+ imageUrl?: string;
35
+ alt?: string;
36
+ size?: 'small' | 'medium' | 'large';
37
+ };
38
+ backgroundColor?: string;
39
+ textColor?: string;
40
+ }
41
+ export interface IFooterConfig {
42
+ show: boolean;
43
+ links?: Array<{
44
+ text: string;
45
+ url: string;
46
+ }>;
47
+ socialLinks?: Array<{
48
+ platform: 'facebook' | 'twitter' | 'linkedin' | 'github';
49
+ url: string;
50
+ }>;
51
+ copyrightText?: string;
52
+ unsubscribeText?: string;
53
+ backgroundColor?: string;
54
+ textColor?: string;
55
+ }
56
+ //# sourceMappingURL=template.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.interface.d.ts","sourceRoot":"","sources":["../../../src/core/interfaces/template.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACtD;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC/D,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;KACrC,CAAC;IACF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;IACH,WAAW,CAAC,EAAE,KAAK,CAAC;QAClB,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;QACzD,GAAG,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ import { IEmailConfig, IEmailOptions } from '../core/interfaces/email.interface';
2
+ import { TemplateService } from '../services/template.service';
3
+ import { AttachmentService } from '../services/attachment.service';
4
+ import { ThemeType } from '../core/enums/theme.enum';
5
+ import { ITemplateConfig } from '../core/interfaces/template.interface';
6
+ export declare class EmailFactory {
7
+ private static instance;
8
+ private emailService;
9
+ private templateService;
10
+ private attachmentService;
11
+ private constructor();
12
+ static initialize(config: IEmailConfig, templateOptions?: any): EmailFactory;
13
+ static getInstance(): EmailFactory;
14
+ sendEmail(options: IEmailOptions): Promise<any>;
15
+ getTemplateService(): TemplateService;
16
+ getAttachmentService(): AttachmentService;
17
+ previewTemplate(themeType: ThemeType, variant: 'light' | 'dark', config: ITemplateConfig, data: any): Promise<string>;
18
+ getThemeInfo(themeType: ThemeType): {
19
+ name: string;
20
+ description: string;
21
+ features: string[];
22
+ availableVariants: ("light" | "dark")[];
23
+ defaultConfig: Partial<ITemplateConfig>;
24
+ };
25
+ listThemes(): ThemeType[];
26
+ getTemplateStats(): {
27
+ totalTemplates: number;
28
+ cachedTemplates: number;
29
+ totalHits: number;
30
+ templatesByTheme: Record<ThemeType, number>;
31
+ cacheHitRate: number;
32
+ };
33
+ }
34
+ //# sourceMappingURL=email-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-factory.d.ts","sourceRoot":"","sources":["../../src/factories/email-factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO;IAOP,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,eAAe,CAAC,EAAE,GAAG,GAAG,YAAY;IAO5E,MAAM,CAAC,WAAW,IAAI,YAAY;IAO5B,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;IAIrD,kBAAkB,IAAI,eAAe;IAIrC,oBAAoB,IAAI,iBAAiB;IAInC,eAAe,CACnB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,MAAM,CAAC;IAIlB,YAAY,CAAC,SAAS,EAAE,SAAS;;;;;;;IAIjC,UAAU;IAIV,gBAAgB;;;;;;;CAGjB"}
@@ -0,0 +1,52 @@
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.EmailFactory = void 0;
7
+ const nodemailer_1 = __importDefault(require("nodemailer"));
8
+ const email_service_1 = require("../services/email.service");
9
+ const template_service_1 = require("../services/template.service");
10
+ const attachment_service_1 = require("../services/attachment.service");
11
+ class EmailFactory {
12
+ constructor(config, templateOptions) {
13
+ const transporter = nodemailer_1.default.createTransport(config);
14
+ this.emailService = new email_service_1.EmailService(transporter, config.defaultFrom);
15
+ this.templateService = new template_service_1.TemplateService(templateOptions);
16
+ this.attachmentService = new attachment_service_1.AttachmentService();
17
+ }
18
+ static initialize(config, templateOptions) {
19
+ if (!this.instance) {
20
+ this.instance = new EmailFactory(config, templateOptions);
21
+ }
22
+ return this.instance;
23
+ }
24
+ static getInstance() {
25
+ if (!this.instance) {
26
+ throw new Error('EmailFactory not initialized. Call initialize() first.');
27
+ }
28
+ return this.instance;
29
+ }
30
+ async sendEmail(options) {
31
+ return this.emailService.send(options);
32
+ }
33
+ getTemplateService() {
34
+ return this.templateService;
35
+ }
36
+ getAttachmentService() {
37
+ return this.attachmentService;
38
+ }
39
+ async previewTemplate(themeType, variant, config, data) {
40
+ return this.templateService.previewTemplate(themeType, variant, config, data);
41
+ }
42
+ getThemeInfo(themeType) {
43
+ return this.templateService.getThemeInfo(themeType);
44
+ }
45
+ listThemes() {
46
+ return this.templateService.listThemes();
47
+ }
48
+ getTemplateStats() {
49
+ return this.templateService.getTemplateStats();
50
+ }
51
+ }
52
+ exports.EmailFactory = EmailFactory;
@@ -0,0 +1,15 @@
1
+ import { ThemeType } from '../core/enums/theme.enum';
2
+ import { ITemplate, ITemplateConfig } from '../core/interfaces/template.interface';
3
+ import { ITheme } from '../templates/themes/theme.interface';
4
+ export declare class TemplateFactory {
5
+ private static themes;
6
+ static createTemplate(themeType: ThemeType, variant: 'light' | 'dark', config: ITemplateConfig): ITemplate;
7
+ static getTheme(themeType: ThemeType): ITheme | undefined;
8
+ static listThemes(): ThemeType[];
9
+ static getThemeInfo(themeType: ThemeType): {
10
+ name: string;
11
+ description: string;
12
+ features: string[];
13
+ };
14
+ }
15
+ //# sourceMappingURL=template-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-factory.d.ts","sourceRoot":"","sources":["../../src/factories/template-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,CAMlB;IAEH,MAAM,CAAC,cAAc,CACnB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,MAAM,EAAE,eAAe,GACtB,SAAS;IA+CZ,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS;IAIzD,MAAM,CAAC,UAAU,IAAI,SAAS,EAAE;IAIhC,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG;QACzC,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;CA+BF"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TemplateFactory = void 0;
4
+ const theme_enum_1 = require("../core/enums/theme.enum");
5
+ const system_theme_1 = require("../templates/themes/system.theme");
6
+ const monokai_theme_1 = require("../templates/themes/monokai.theme");
7
+ const modern_theme_1 = require("../templates/themes/modern.theme");
8
+ const corporate_theme_1 = require("../templates/themes/corporate.theme");
9
+ const minimal_theme_1 = require("../templates/themes/minimal.theme");
10
+ const template_builder_1 = require("../templates/base/template-builder");
11
+ class TemplateFactory {
12
+ static createTemplate(themeType, variant, config) {
13
+ const theme = this.themes.get(themeType);
14
+ if (!theme) {
15
+ throw new Error(`Theme ${themeType} not found`);
16
+ }
17
+ return {
18
+ name: `${themeType}_${variant}`,
19
+ theme: themeType,
20
+ variant,
21
+ config,
22
+ render: async (data) => {
23
+ const builder = new template_builder_1.TemplateBuilder(theme, config, variant);
24
+ const body = data.template.config.body || {};
25
+ let bodyContent = body.content || `
26
+ <table width="100%" cellpadding="0" cellspacing="0" role="presentation">
27
+ <tr>
28
+ <td style="padding: 20px; text-align: ${body.alignment || 'left'}; background-color: ${body.backgroundColor || 'transparent'}; color: ${body.textColor || 'inherit'}; font-size: ${body.fontSize || 14}px;">
29
+
30
+ <h2 style="margin: 0 0 16px 0; font-size: ${(body.fontSize + 7) || 21}px; line-height: 1.3;">
31
+ ${body.title || 'Hello!'}
32
+ </h2>
33
+
34
+ <p style="margin: 0; line-height: 1.6;">
35
+ ${body.message || 'This is an email generated with tzMail.'}
36
+ </p>
37
+
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ `;
42
+ builder.buildHeader(data.headerContent).buildBody(bodyContent);
43
+ if (body.buttonText && body.buttonUrl) {
44
+ builder.buildButton(body.buttonText, body.buttonUrl, body.buttonVariant);
45
+ }
46
+ return builder
47
+ .buildFooter()
48
+ .build();
49
+ }
50
+ };
51
+ }
52
+ static getTheme(themeType) {
53
+ return this.themes.get(themeType);
54
+ }
55
+ static listThemes() {
56
+ return Array.from(this.themes.keys());
57
+ }
58
+ static getThemeInfo(themeType) {
59
+ const themeInfo = {
60
+ [theme_enum_1.ThemeType.SYSTEM]: {
61
+ name: 'System',
62
+ description: 'Tema limpo e profissional com cores adaptativas',
63
+ features: ['Design minimalista', 'Alta acessibilidade', 'Compatibilidade total']
64
+ },
65
+ [theme_enum_1.ThemeType.MONOKAI]: {
66
+ name: 'Monokai',
67
+ description: 'Inspirado no famoso tema de código, ideal para conteúdo técnico',
68
+ features: ['Cores vibrantes', 'Destaque de sintaxe', 'Efeitos glow']
69
+ },
70
+ [theme_enum_1.ThemeType.MODERN]: {
71
+ name: 'Modern',
72
+ description: 'Design contemporâneo com gradientes e efeitos modernos',
73
+ features: ['Gradientes elegantes', 'Glassmorphism', 'Animações suaves']
74
+ },
75
+ [theme_enum_1.ThemeType.CORPORATE]: {
76
+ name: 'Corporate',
77
+ description: 'Design profissional e elegante para empresas',
78
+ features: ['Tipografia serifada', 'Detalhes em dourado', 'Layout estruturado']
79
+ },
80
+ [theme_enum_1.ThemeType.MINIMAL]: {
81
+ name: 'Minimal',
82
+ description: 'Design clean e focado no conteúdo',
83
+ features: ['Sem distrações', 'Espaçamento generoso', 'Tipografia limpa']
84
+ }
85
+ };
86
+ return themeInfo[themeType];
87
+ }
88
+ }
89
+ exports.TemplateFactory = TemplateFactory;
90
+ TemplateFactory.themes = new Map([
91
+ [theme_enum_1.ThemeType.SYSTEM, new system_theme_1.SystemTheme()],
92
+ [theme_enum_1.ThemeType.MONOKAI, new monokai_theme_1.MonokaiTheme()],
93
+ [theme_enum_1.ThemeType.MODERN, new modern_theme_1.ModernTheme()],
94
+ [theme_enum_1.ThemeType.CORPORATE, new corporate_theme_1.CorporateTheme()],
95
+ [theme_enum_1.ThemeType.MINIMAL, new minimal_theme_1.MinimalTheme()]
96
+ ]);
@@ -0,0 +1,15 @@
1
+ export { EmailFactory } from './factories/email-factory';
2
+ export { TemplateFactory } from './factories/template-factory';
3
+ export { ITemplate, ITemplateConfig } from './core/interfaces/template.interface';
4
+ export { ThemeType } from './core/enums/theme.enum';
5
+ export { ITheme } from './templates/themes/theme.interface';
6
+ export { TemplateService } from './services/template.service';
7
+ export { EmailService } from './services/email.service';
8
+ export { AttachmentService } from './services/attachment.service';
9
+ export { TemplateBuilder } from './templates/base/template-builder';
10
+ export { CorporateTheme } from './templates/themes/corporate.theme';
11
+ export { MinimalTheme } from './templates/themes/minimal.theme';
12
+ export { ModernTheme } from './templates/themes/modern.theme';
13
+ export { MonokaiTheme } from './templates/themes/monokai.theme';
14
+ export { SystemTheme } from './templates/themes/system.theme';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,265 @@
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.SystemTheme = exports.MonokaiTheme = exports.ModernTheme = exports.MinimalTheme = exports.CorporateTheme = exports.TemplateBuilder = exports.AttachmentService = exports.EmailService = exports.TemplateService = exports.ThemeType = exports.TemplateFactory = exports.EmailFactory = void 0;
7
+ const express_1 = __importDefault(require("express"));
8
+ const theme_enum_1 = require("./core/enums/theme.enum");
9
+ const email_factory_1 = require("./factories/email-factory");
10
+ const dotenv_1 = __importDefault(require("dotenv"));
11
+ const attachment_service_1 = require("./services/attachment.service");
12
+ dotenv_1.default.config();
13
+ var email_factory_2 = require("./factories/email-factory");
14
+ Object.defineProperty(exports, "EmailFactory", { enumerable: true, get: function () { return email_factory_2.EmailFactory; } });
15
+ var template_factory_1 = require("./factories/template-factory");
16
+ Object.defineProperty(exports, "TemplateFactory", { enumerable: true, get: function () { return template_factory_1.TemplateFactory; } });
17
+ var theme_enum_2 = require("./core/enums/theme.enum");
18
+ Object.defineProperty(exports, "ThemeType", { enumerable: true, get: function () { return theme_enum_2.ThemeType; } });
19
+ var template_service_1 = require("./services/template.service");
20
+ Object.defineProperty(exports, "TemplateService", { enumerable: true, get: function () { return template_service_1.TemplateService; } });
21
+ var email_service_1 = require("./services/email.service");
22
+ Object.defineProperty(exports, "EmailService", { enumerable: true, get: function () { return email_service_1.EmailService; } });
23
+ var attachment_service_2 = require("./services/attachment.service");
24
+ Object.defineProperty(exports, "AttachmentService", { enumerable: true, get: function () { return attachment_service_2.AttachmentService; } });
25
+ var template_builder_1 = require("./templates/base/template-builder");
26
+ Object.defineProperty(exports, "TemplateBuilder", { enumerable: true, get: function () { return template_builder_1.TemplateBuilder; } });
27
+ var corporate_theme_1 = require("./templates/themes/corporate.theme");
28
+ Object.defineProperty(exports, "CorporateTheme", { enumerable: true, get: function () { return corporate_theme_1.CorporateTheme; } });
29
+ var minimal_theme_1 = require("./templates/themes/minimal.theme");
30
+ Object.defineProperty(exports, "MinimalTheme", { enumerable: true, get: function () { return minimal_theme_1.MinimalTheme; } });
31
+ var modern_theme_1 = require("./templates/themes/modern.theme");
32
+ Object.defineProperty(exports, "ModernTheme", { enumerable: true, get: function () { return modern_theme_1.ModernTheme; } });
33
+ var monokai_theme_1 = require("./templates/themes/monokai.theme");
34
+ Object.defineProperty(exports, "MonokaiTheme", { enumerable: true, get: function () { return monokai_theme_1.MonokaiTheme; } });
35
+ var system_theme_1 = require("./templates/themes/system.theme");
36
+ Object.defineProperty(exports, "SystemTheme", { enumerable: true, get: function () { return system_theme_1.SystemTheme; } });
37
+ /*
38
+ *
39
+ *
40
+ * *
41
+ * *
42
+ * * tzMail - Servidor de Teste
43
+ */
44
+ const app = (0, express_1.default)();
45
+ const PORT = 3001;
46
+ app.use(express_1.default.json());
47
+ app.use(express_1.default.urlencoded({ extended: true }));
48
+ const SMTP_CONFIG = {
49
+ host: 'smtp.gmail.com',
50
+ port: 587,
51
+ secure: false,
52
+ auth: {
53
+ user: process.env.SMTP_USER,
54
+ pass: process.env.SMTP_PASS
55
+ },
56
+ defaultFrom: 'LyraX Corp <lyrax.com@gmail.com>'
57
+ };
58
+ // init EmailFactory
59
+ const emailFactory = email_factory_1.EmailFactory.initialize(SMTP_CONFIG);
60
+ const templateService = emailFactory.getTemplateService();
61
+ // modern
62
+ const modernTemplate = templateService.createTemplate(theme_enum_1.ThemeType.MODERN, 'light', {
63
+ header: {
64
+ show: true,
65
+ logo: {
66
+ type: 'image',
67
+ imageUrl: 'https://talkspace-ten.vercel.app/_next/image?url=%2Flogo%2Ftalkspace-banner.png&w=640&q=75',
68
+ size: 'large'
69
+ }
70
+ },
71
+ body: {
72
+ title: 'Bem-vindo ao LyraX!',
73
+ message: 'Estamos felizes em tê-lo conosco. Explore nossos recursos e aproveite ao máximo a experiência.',
74
+ buttonText: 'Começar Agora',
75
+ buttonUrl: 'https://meuapp.com/get-started',
76
+ buttonVariant: 'primary',
77
+ alignment: 'center',
78
+ fontSize: 16
79
+ },
80
+ footer: {
81
+ show: true,
82
+ links: [
83
+ { text: 'Política', url: 'https://meuapp.com/politica' },
84
+ { text: 'Termos', url: 'https://meuapp.com/termos' }
85
+ ],
86
+ socialLinks: [
87
+ { platform: 'facebook', url: 'https://facebook.com/meuapp' },
88
+ { platform: 'twitter', url: 'https://twitter.com/meuapp' },
89
+ { platform: 'linkedin', url: 'https://linkedin.com/company/meuapp' }
90
+ ],
91
+ copyrightText: '© 2024 Meu App',
92
+ unsubscribeText: 'Cancelar inscrição'
93
+ },
94
+ layout: 'full',
95
+ spacing: 'normal',
96
+ borderRadius: 'medium'
97
+ });
98
+ // monokai
99
+ const monokaiTemplate = templateService.createTemplate(theme_enum_1.ThemeType.MONOKAI, 'light', {
100
+ header: {
101
+ show: true,
102
+ logo: {
103
+ type: 'text',
104
+ text: 'DevHub',
105
+ size: 'medium'
106
+ }
107
+ },
108
+ body: {
109
+ title: 'DevHub Newsletter - Novidades da Semana',
110
+ message: 'Olá DevHubbers!\n\nConfira as últimas novidades, tutoriais e eventos da comunidade DevHub. Fique por dentro de tudo que está acontecendo no mundo do desenvolvimento! \n <code>console.log("Stay Dev!");</code>',
111
+ buttonText: 'Visitar DevHub',
112
+ buttonUrl: 'https://devhub.com',
113
+ buttonVariant: 'primary',
114
+ alignment: 'center',
115
+ fontSize: 16
116
+ },
117
+ footer: {
118
+ show: true,
119
+ links: [
120
+ { text: 'GitHub', url: 'https://github.com' },
121
+ { text: 'Docs', url: 'https://docs.com' }
122
+ ],
123
+ socialLinks: [
124
+ { platform: 'twitter', url: 'https://twitter.com' },
125
+ { platform: 'linkedin', url: 'https://linkedin.com' }
126
+ ],
127
+ copyrightText: '© 2024 DevHub'
128
+ },
129
+ layout: 'full',
130
+ spacing: 'normal',
131
+ borderRadius: 'small'
132
+ });
133
+ // corporate
134
+ const corporateTemplate = templateService.createTemplate(theme_enum_1.ThemeType.CORPORATE, 'dark', {
135
+ header: {
136
+ show: true,
137
+ logo: {
138
+ type: 'image',
139
+ imageUrl: 'https://talkspace-ten.vercel.app/_next/image?url=%2Flogo%2Ftalkspace-banner.png&w=640&q=75',
140
+ size: 'large'
141
+ }
142
+ },
143
+ body: {
144
+ title: 'Relatório Trimestral - Q4 2024',
145
+ message: 'Prezado(a) colaborador(a),\n\nSegue o relatório trimestral com os principais indicadores e resultados alcançados no último trimestre. Agradecemos a dedicação de todos e seguimos juntos rumo ao sucesso!',
146
+ buttonText: 'Ver Relatório Completo',
147
+ buttonUrl: 'https://lyrax.com/relatorio-q4-2024',
148
+ buttonVariant: 'primary'
149
+ },
150
+ footer: {
151
+ show: true,
152
+ links: [
153
+ { text: 'Sobre', url: 'https://empresa.com/sobre' },
154
+ { text: 'Imprensa', url: 'https://empresa.com/imprensa' },
155
+ { text: 'Carreiras', url: 'https://empresa.com/carreiras' },
156
+ { text: 'Contato', url: 'https://empresa.com/contato' }
157
+ ],
158
+ copyrightText: '© 2024 Empresa Ltda'
159
+ },
160
+ layout: 'full',
161
+ spacing: 'normal',
162
+ borderRadius: 'small'
163
+ });
164
+ // minimal
165
+ const minimalTemplate = templateService.createTemplate(theme_enum_1.ThemeType.MINIMAL, 'dark', {
166
+ header: {
167
+ show: true,
168
+ logo: {
169
+ type: 'text',
170
+ text: 'TalkSpace',
171
+ size: 'medium'
172
+ }
173
+ },
174
+ body: {
175
+ title: 'Pensamentos sobre design',
176
+ message: 'Design é mais do que estética - é sobre criar experiências significativas. Em um mundo saturado de informações, o design minimalista nos lembra que menos é mais. Ao eliminar o excesso, podemos destacar o essencial e criar conexões mais profundas com nosso público. Menos distrações, mais impacto.',
177
+ buttonText: 'Explorar Mais',
178
+ buttonUrl: 'https://talkspace.com/design-thoughts',
179
+ buttonVariant: 'primary',
180
+ alignment: 'center',
181
+ fontSize: 16
182
+ },
183
+ footer: {
184
+ show: true,
185
+ links: [
186
+ { text: 'Sobre', url: 'https://empresa.com/sobre' },
187
+ { text: 'Imprensa', url: 'https://empresa.com/imprensa' },
188
+ { text: 'Carreiras', url: 'https://empresa.com/carreiras' },
189
+ { text: 'Contato', url: 'https://empresa.com/contato' }
190
+ ],
191
+ socialLinks: [
192
+ { platform: 'facebook', url: 'https://facebook.com' },
193
+ { platform: 'twitter', url: 'https://twitter.com' },
194
+ { platform: 'linkedin', url: 'https://linkedin.com' }
195
+ ],
196
+ copyrightText: 'TalkSpace'
197
+ },
198
+ layout: 'minimal',
199
+ spacing: 'relaxed',
200
+ borderRadius: 'none'
201
+ });
202
+ async function sendWelcomeEmail(to) {
203
+ console.log(`\n📧 Enviando email de boas-vindas para ${to}...`);
204
+ const result = await emailFactory.sendEmail({
205
+ to,
206
+ subject: 'Bem-vindo ao Meu App!',
207
+ template: modernTemplate
208
+ });
209
+ console.log('Resultado:', result);
210
+ return result;
211
+ }
212
+ async function sendTechNewsletter(to) {
213
+ console.log(`\n📧 Enviando newsletter técnica para ${to}...`);
214
+ const result = await emailFactory.sendEmail({
215
+ to,
216
+ subject: 'DevHub Newsletter - Novidades da Semana',
217
+ template: monokaiTemplate
218
+ });
219
+ console.log('Resultado:', result);
220
+ return result;
221
+ }
222
+ async function sendCorporateReport(to) {
223
+ console.log(`\n📧 Enviando relatório corporativo para ${to}...`);
224
+ const result = await emailFactory.sendEmail({
225
+ to,
226
+ subject: 'Relatório Trimestral - Q4 2024',
227
+ template: corporateTemplate,
228
+ });
229
+ console.log('Resultado:', result);
230
+ return result;
231
+ }
232
+ async function sendMinimalNewsletter(to) {
233
+ console.log(`\n📧 Enviando newsletter minimalista para ${to}...`);
234
+ const attachmentService = new attachment_service_1.AttachmentService();
235
+ const attachment = await attachmentService.addFromPath('uploads/PHOTO.jpg');
236
+ const result = await emailFactory.sendEmail({
237
+ to,
238
+ subject: 'Pensamentos sobre design',
239
+ template: minimalTemplate,
240
+ attachments: [
241
+ {
242
+ ...attachment
243
+ }
244
+ ]
245
+ });
246
+ console.log('Resultado:', result);
247
+ return result;
248
+ }
249
+ app.get('/test', async (req, res) => {
250
+ const result = await sendMinimalNewsletter('antiquesclub007@gmail.com');
251
+ res.json(result);
252
+ });
253
+ app.listen(PORT, () => {
254
+ console.log(`
255
+ ╔═══════════════════════════════════════════════════╗
256
+ ║ ║
257
+ ║ 📧 tzMail - Servidor de Teste ║
258
+ ║ ║
259
+ ║ 🚀 Servidor rodando em: http://localhost:${PORT} ║
260
+ ║ ║
261
+ ║ ⚠️ Configure seu SMTP no arquivo src/index.ts ║
262
+ ║ ║
263
+ ╚═══════════════════════════════════════════════════╝
264
+ `);
265
+ });