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.
- package/README.md +5091 -0
- package/dist/core/enums/template-part.enum.d.ts +7 -0
- package/dist/core/enums/template-part.enum.d.ts.map +1 -0
- package/dist/core/enums/template-part.enum.js +10 -0
- package/dist/core/enums/theme.enum.d.ts +8 -0
- package/dist/core/enums/theme.enum.d.ts.map +1 -0
- package/dist/core/enums/theme.enum.js +11 -0
- package/dist/core/interfaces/email.interface.d.ts +32 -0
- package/dist/core/interfaces/email.interface.d.ts.map +1 -0
- package/dist/core/interfaces/email.interface.js +2 -0
- package/dist/core/interfaces/template.interface.d.ts +56 -0
- package/dist/core/interfaces/template.interface.d.ts.map +1 -0
- package/dist/core/interfaces/template.interface.js +2 -0
- package/dist/factories/email-factory.d.ts +34 -0
- package/dist/factories/email-factory.d.ts.map +1 -0
- package/dist/factories/email-factory.js +52 -0
- package/dist/factories/template-factory.d.ts +15 -0
- package/dist/factories/template-factory.d.ts.map +1 -0
- package/dist/factories/template-factory.js +96 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +265 -0
- package/dist/services/attachment.service.d.ts +48 -0
- package/dist/services/attachment.service.d.ts.map +1 -0
- package/dist/services/attachment.service.js +93 -0
- package/dist/services/email.service.d.ts +31 -0
- package/dist/services/email.service.d.ts.map +1 -0
- package/dist/services/email.service.js +58 -0
- package/dist/services/template.service.d.ts +180 -0
- package/dist/services/template.service.d.ts.map +1 -0
- package/dist/services/template.service.js +507 -0
- package/dist/templates/base/template-builder.d.ts +23 -0
- package/dist/templates/base/template-builder.d.ts.map +1 -0
- package/dist/templates/base/template-builder.js +676 -0
- package/dist/templates/themes/corporate.theme.d.ts +65 -0
- package/dist/templates/themes/corporate.theme.d.ts.map +1 -0
- package/dist/templates/themes/corporate.theme.js +109 -0
- package/dist/templates/themes/minimal.theme.d.ts +70 -0
- package/dist/templates/themes/minimal.theme.d.ts.map +1 -0
- package/dist/templates/themes/minimal.theme.js +114 -0
- package/dist/templates/themes/modern.theme.d.ts +38 -0
- package/dist/templates/themes/modern.theme.d.ts.map +1 -0
- package/dist/templates/themes/modern.theme.js +81 -0
- package/dist/templates/themes/monokai.theme.d.ts +29 -0
- package/dist/templates/themes/monokai.theme.d.ts.map +1 -0
- package/dist/templates/themes/monokai.theme.js +73 -0
- package/dist/templates/themes/system.theme.d.ts +50 -0
- package/dist/templates/themes/system.theme.d.ts.map +1 -0
- package/dist/templates/themes/system.theme.js +54 -0
- package/dist/templates/themes/theme.interface.d.ts +42 -0
- package/dist/templates/themes/theme.interface.d.ts.map +1 -0
- package/dist/templates/themes/theme.interface.js +2 -0
- package/dist/tests/template.service.test.d.ts +1 -0
- package/dist/tests/template.service.test.d.ts.map +1 -0
- package/dist/tests/template.service.test.js +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IAttachment } from '../core/interfaces/email.interface';
|
|
4
|
+
/**
|
|
5
|
+
* AttachmentService - Gerencia anexos para emails
|
|
6
|
+
*
|
|
7
|
+
* Métodos:
|
|
8
|
+
* - addFromPath(filePath: string, options?: Partial<IAttachment>): Promise<IAttachment>
|
|
9
|
+
* Adiciona um anexo a partir de um caminho de arquivo.
|
|
10
|
+
*
|
|
11
|
+
* - addFromBuffer(buffer: Buffer, filename: string, options?: Partial<IAttachment>): Promise<IAttachment>
|
|
12
|
+
* Adiciona um anexo a partir de um buffer em memória.
|
|
13
|
+
*
|
|
14
|
+
* - addFromUrl(url: string, filename: string): Promise<IAttachment>
|
|
15
|
+
* Adiciona um anexo a partir de uma URL (ainda não implementado).
|
|
16
|
+
*
|
|
17
|
+
* Exemplo de uso:
|
|
18
|
+
*
|
|
19
|
+
* const attachmentService = new AttachmentService();
|
|
20
|
+
* const attachment = await attachmentService.addFromPath('path/to/file.pdf');
|
|
21
|
+
*
|
|
22
|
+
* emailFactory.sendEmail({
|
|
23
|
+
* to: 'user@example.com',
|
|
24
|
+
* subject: 'Assunto do Email',
|
|
25
|
+
* template: myTemplate,
|
|
26
|
+
* attachments: [{...attachment}]
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
export declare class AttachmentService {
|
|
30
|
+
/**
|
|
31
|
+
* addFromPath - Adiciona um anexo a partir de um caminho de arquivo
|
|
32
|
+
* @param filePath - Caminho do arquivo a ser anexado
|
|
33
|
+
* @param options - Opções adicionais para o anexo (filename, contentType, cid)
|
|
34
|
+
* @returns Promise<IAttachment> - Objeto de anexo formatado para Nodemailer
|
|
35
|
+
* @throws Error se o caminho não for um arquivo válido
|
|
36
|
+
*/
|
|
37
|
+
addFromPath(filePath: string, options?: Partial<IAttachment>): Promise<IAttachment>;
|
|
38
|
+
addFromBuffer(buffer: Buffer, filename: string, options?: Partial<IAttachment>): Promise<IAttachment>;
|
|
39
|
+
/**
|
|
40
|
+
* addFromUrl - Adiciona um anexo a partir de uma URL (a ser implementado)
|
|
41
|
+
* @param url - URL do recurso a ser anexado
|
|
42
|
+
* @param filename - Nome do arquivo para o anexo
|
|
43
|
+
* @returns Promise<IAttachment> - Objeto de anexo formatado para Nodemailer
|
|
44
|
+
* @throws Error se o método não for implementado
|
|
45
|
+
*/
|
|
46
|
+
addFromUrl(url: string, filename: string): Promise<IAttachment>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=attachment.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.service.d.ts","sourceRoot":"","sources":["../../src/services/attachment.service.ts"],"names":[],"mappings":";;AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;OAMG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAcnF,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAC7B,OAAO,CAAC,WAAW,CAAC;IASvB;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAGhE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AttachmentService = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
/**
|
|
30
|
+
* AttachmentService - Gerencia anexos para emails
|
|
31
|
+
*
|
|
32
|
+
* Métodos:
|
|
33
|
+
* - addFromPath(filePath: string, options?: Partial<IAttachment>): Promise<IAttachment>
|
|
34
|
+
* Adiciona um anexo a partir de um caminho de arquivo.
|
|
35
|
+
*
|
|
36
|
+
* - addFromBuffer(buffer: Buffer, filename: string, options?: Partial<IAttachment>): Promise<IAttachment>
|
|
37
|
+
* Adiciona um anexo a partir de um buffer em memória.
|
|
38
|
+
*
|
|
39
|
+
* - addFromUrl(url: string, filename: string): Promise<IAttachment>
|
|
40
|
+
* Adiciona um anexo a partir de uma URL (ainda não implementado).
|
|
41
|
+
*
|
|
42
|
+
* Exemplo de uso:
|
|
43
|
+
*
|
|
44
|
+
* const attachmentService = new AttachmentService();
|
|
45
|
+
* const attachment = await attachmentService.addFromPath('path/to/file.pdf');
|
|
46
|
+
*
|
|
47
|
+
* emailFactory.sendEmail({
|
|
48
|
+
* to: 'user@example.com',
|
|
49
|
+
* subject: 'Assunto do Email',
|
|
50
|
+
* template: myTemplate,
|
|
51
|
+
* attachments: [{...attachment}]
|
|
52
|
+
* });
|
|
53
|
+
*/
|
|
54
|
+
class AttachmentService {
|
|
55
|
+
/**
|
|
56
|
+
* addFromPath - Adiciona um anexo a partir de um caminho de arquivo
|
|
57
|
+
* @param filePath - Caminho do arquivo a ser anexado
|
|
58
|
+
* @param options - Opções adicionais para o anexo (filename, contentType, cid)
|
|
59
|
+
* @returns Promise<IAttachment> - Objeto de anexo formatado para Nodemailer
|
|
60
|
+
* @throws Error se o caminho não for um arquivo válido
|
|
61
|
+
*/
|
|
62
|
+
async addFromPath(filePath, options) {
|
|
63
|
+
const stats = await fs.promises.stat(filePath);
|
|
64
|
+
if (!stats.isFile()) {
|
|
65
|
+
throw new Error(`Path is not a file: ${filePath}`);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
filename: (options === null || options === void 0 ? void 0 : options.filename) || path.basename(filePath),
|
|
69
|
+
path: filePath,
|
|
70
|
+
contentType: options === null || options === void 0 ? void 0 : options.contentType,
|
|
71
|
+
cid: options === null || options === void 0 ? void 0 : options.cid
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async addFromBuffer(buffer, filename, options) {
|
|
75
|
+
return {
|
|
76
|
+
filename,
|
|
77
|
+
content: buffer,
|
|
78
|
+
contentType: options === null || options === void 0 ? void 0 : options.contentType,
|
|
79
|
+
cid: options === null || options === void 0 ? void 0 : options.cid
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* addFromUrl - Adiciona um anexo a partir de uma URL (a ser implementado)
|
|
84
|
+
* @param url - URL do recurso a ser anexado
|
|
85
|
+
* @param filename - Nome do arquivo para o anexo
|
|
86
|
+
* @returns Promise<IAttachment> - Objeto de anexo formatado para Nodemailer
|
|
87
|
+
* @throws Error se o método não for implementado
|
|
88
|
+
*/
|
|
89
|
+
addFromUrl(url, filename) {
|
|
90
|
+
throw new Error('Method not implemented yet');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.AttachmentService = AttachmentService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Transporter } from 'nodemailer';
|
|
2
|
+
import { IEmailOptions } from '../core/interfaces/email.interface';
|
|
3
|
+
/**
|
|
4
|
+
* EmailService - Gerencia o envio de emails usando Nodemailer
|
|
5
|
+
*
|
|
6
|
+
* Métodos:
|
|
7
|
+
* - send(options: IEmailOptions): Promise<any>
|
|
8
|
+
* Envia um email com as opções especificadas.
|
|
9
|
+
*
|
|
10
|
+
* Exemplo de uso:
|
|
11
|
+
*
|
|
12
|
+
* const emailService = new EmailService(transporter, 'from@example.com');
|
|
13
|
+
* const result = await emailService.send({
|
|
14
|
+
* to: 'to@example.com',
|
|
15
|
+
* subject: 'Assunto do Email',
|
|
16
|
+
* template: myTemplate
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
export declare class EmailService {
|
|
20
|
+
private transporter;
|
|
21
|
+
private defaultFrom?;
|
|
22
|
+
constructor(transporter: Transporter, defaultFrom?: string | undefined);
|
|
23
|
+
/**
|
|
24
|
+
* send - Envia um email com as opções especificadas
|
|
25
|
+
* @param options - Opções para o email (to, cc, bcc, subject, text, html, template, attachments)
|
|
26
|
+
* @returns Promise<any> - Resultado do envio do email
|
|
27
|
+
* @throws Error se o envio falhar
|
|
28
|
+
*/
|
|
29
|
+
send(options: IEmailOptions): Promise<any>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=email.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.service.d.ts","sourceRoot":"","sources":["../../src/services/email.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW,CAAC;gBADZ,WAAW,EAAE,WAAW,EACxB,WAAW,CAAC,oBAAQ;IAG9B;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;CA0BjD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* EmailService - Gerencia o envio de emails usando Nodemailer
|
|
6
|
+
*
|
|
7
|
+
* Métodos:
|
|
8
|
+
* - send(options: IEmailOptions): Promise<any>
|
|
9
|
+
* Envia um email com as opções especificadas.
|
|
10
|
+
*
|
|
11
|
+
* Exemplo de uso:
|
|
12
|
+
*
|
|
13
|
+
* const emailService = new EmailService(transporter, 'from@example.com');
|
|
14
|
+
* const result = await emailService.send({
|
|
15
|
+
* to: 'to@example.com',
|
|
16
|
+
* subject: 'Assunto do Email',
|
|
17
|
+
* template: myTemplate
|
|
18
|
+
* });
|
|
19
|
+
*/
|
|
20
|
+
class EmailService {
|
|
21
|
+
constructor(transporter, defaultFrom) {
|
|
22
|
+
this.transporter = transporter;
|
|
23
|
+
this.defaultFrom = defaultFrom;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* send - Envia um email com as opções especificadas
|
|
27
|
+
* @param options - Opções para o email (to, cc, bcc, subject, text, html, template, attachments)
|
|
28
|
+
* @returns Promise<any> - Resultado do envio do email
|
|
29
|
+
* @throws Error se o envio falhar
|
|
30
|
+
*/
|
|
31
|
+
async send(options) {
|
|
32
|
+
const mailOptions = {
|
|
33
|
+
from: options.from || this.defaultFrom,
|
|
34
|
+
to: Array.isArray(options.to) ? options.to.join(',') : options.to,
|
|
35
|
+
cc: options.cc,
|
|
36
|
+
bcc: options.bcc,
|
|
37
|
+
subject: options.subject,
|
|
38
|
+
text: options.text,
|
|
39
|
+
html: options.html || (options.template ? await options.template.render(options) : undefined),
|
|
40
|
+
attachments: options.attachments
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
const info = await this.transporter.sendMail(mailOptions);
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
messageId: info.messageId,
|
|
47
|
+
response: info.response
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
error: error
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.EmailService = EmailService;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { ITemplate, ITemplateConfig } from '../core/interfaces/template.interface';
|
|
2
|
+
import { ThemeType } from '../core/enums/theme.enum';
|
|
3
|
+
interface TemplateCache {
|
|
4
|
+
template: ITemplate;
|
|
5
|
+
createdAt: Date;
|
|
6
|
+
expiresAt: Date;
|
|
7
|
+
hits: number;
|
|
8
|
+
}
|
|
9
|
+
interface TemplateOptions {
|
|
10
|
+
cache?: boolean;
|
|
11
|
+
cacheTTL?: number;
|
|
12
|
+
validateConfig?: boolean;
|
|
13
|
+
minify?: boolean;
|
|
14
|
+
preview?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* TemplateService - Gerencia a criação, renderização e gerenciamento de templates de email
|
|
18
|
+
*
|
|
19
|
+
* Métodos:
|
|
20
|
+
* - createTemplate(themeType, variant, config, options): ITemplate
|
|
21
|
+
* Cria um novo template com as configurações especificadas.
|
|
22
|
+
*
|
|
23
|
+
* - cloneTemplate(template, modifications): ITemplate
|
|
24
|
+
* Cria um template a partir de um template existente (clone).
|
|
25
|
+
*
|
|
26
|
+
* - renderTemplate(template, data, options): Promise<string>
|
|
27
|
+
* Renderiza um template com os dados fornecidos.
|
|
28
|
+
*
|
|
29
|
+
* - previewTemplate(themeType, variant, config, data): Promise<string>
|
|
30
|
+
* Pré-visualiza um template sem enviar email.
|
|
31
|
+
*
|
|
32
|
+
* - getThemeInfo(themeType): object
|
|
33
|
+
* Obtém informações sobre um tema específico.
|
|
34
|
+
*
|
|
35
|
+
* - listThemes(): ThemeType[]
|
|
36
|
+
* Lista todos os temas disponíveis.
|
|
37
|
+
*
|
|
38
|
+
* - getTemplateStats(): object
|
|
39
|
+
* Obtém estatísticas de uso dos templates.
|
|
40
|
+
*
|
|
41
|
+
* - clearCache(themeType?): number
|
|
42
|
+
* Limpa o cache de templates, opcionalmente por tema.
|
|
43
|
+
*
|
|
44
|
+
* - getTemplateHistory(templateId): ITemplate[]
|
|
45
|
+
* Obtém histórico de versões de um template.
|
|
46
|
+
*
|
|
47
|
+
* - restoreTemplateVersion(templateId, versionIndex): ITemplate | null
|
|
48
|
+
* Restaura uma versão anterior do template.
|
|
49
|
+
*
|
|
50
|
+
* Exemplo de uso:
|
|
51
|
+
*
|
|
52
|
+
* const templateService = new TemplateService();
|
|
53
|
+
* const myTemplate = templateService.createTemplate(ThemeType.MODERN, 'light', { header: { show: true } });
|
|
54
|
+
* const html = await templateService.renderTemplate(myTemplate, { username: 'John' });
|
|
55
|
+
* console.log(html);
|
|
56
|
+
*/
|
|
57
|
+
export declare class TemplateService {
|
|
58
|
+
private options;
|
|
59
|
+
private templateCache;
|
|
60
|
+
private defaultTTL;
|
|
61
|
+
private templateHistory;
|
|
62
|
+
constructor(options?: TemplateOptions);
|
|
63
|
+
/**
|
|
64
|
+
* Cria um novo template com as configurações especificadas
|
|
65
|
+
*/
|
|
66
|
+
createTemplate(themeType: ThemeType, variant: 'light' | 'dark', config: ITemplateConfig, options?: TemplateOptions): ITemplate;
|
|
67
|
+
/**
|
|
68
|
+
* Cria um template a partir de um template existente (clone)
|
|
69
|
+
*/
|
|
70
|
+
cloneTemplate(template: ITemplate, modifications?: Partial<ITemplateConfig>): ITemplate;
|
|
71
|
+
/**
|
|
72
|
+
* Renderiza um template com os dados fornecidos
|
|
73
|
+
*/
|
|
74
|
+
renderTemplate(template: ITemplate, data: any, options?: {
|
|
75
|
+
preview?: boolean;
|
|
76
|
+
}): Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Pré-visualiza um template sem enviar email
|
|
79
|
+
*/
|
|
80
|
+
previewTemplate(themeType: ThemeType, variant: 'light' | 'dark', config: ITemplateConfig, data: any): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Obtém informações sobre um tema específico
|
|
83
|
+
*/
|
|
84
|
+
getThemeInfo(themeType: ThemeType): {
|
|
85
|
+
name: string;
|
|
86
|
+
description: string;
|
|
87
|
+
features: string[];
|
|
88
|
+
availableVariants: ('light' | 'dark')[];
|
|
89
|
+
defaultConfig: Partial<ITemplateConfig>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Lista todos os temas disponíveis
|
|
93
|
+
*/
|
|
94
|
+
listThemes(): ThemeType[];
|
|
95
|
+
/**
|
|
96
|
+
* Obtém estatísticas de uso dos templates
|
|
97
|
+
*/
|
|
98
|
+
getTemplateStats(): {
|
|
99
|
+
totalTemplates: number;
|
|
100
|
+
cachedTemplates: number;
|
|
101
|
+
totalHits: number;
|
|
102
|
+
templatesByTheme: Record<ThemeType, number>;
|
|
103
|
+
cacheHitRate: number;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Limpa o cache de templates
|
|
107
|
+
*/
|
|
108
|
+
clearCache(themeType?: ThemeType): number;
|
|
109
|
+
/**
|
|
110
|
+
* Obtém histórico de versões de um template
|
|
111
|
+
*/
|
|
112
|
+
getTemplateHistory(templateId: string): ITemplate[];
|
|
113
|
+
/**
|
|
114
|
+
* Restaura uma versão anterior do template
|
|
115
|
+
*/
|
|
116
|
+
restoreTemplateVersion(templateId: string, versionIndex: number): ITemplate | null;
|
|
117
|
+
/**
|
|
118
|
+
* Valida a configuração do template
|
|
119
|
+
*/
|
|
120
|
+
private validateTemplateConfig;
|
|
121
|
+
/**
|
|
122
|
+
* Gera um ID único para o template baseado na configuração
|
|
123
|
+
*/
|
|
124
|
+
private generateTemplateId;
|
|
125
|
+
/**
|
|
126
|
+
* Adiciona funcionalidades extras ao template
|
|
127
|
+
*/
|
|
128
|
+
private enhanceTemplate;
|
|
129
|
+
/**
|
|
130
|
+
* Adiciona template ao histórico
|
|
131
|
+
*/
|
|
132
|
+
private addToHistory;
|
|
133
|
+
/**
|
|
134
|
+
* Remove templates expirados do cache
|
|
135
|
+
*/
|
|
136
|
+
private cleanExpiredCache;
|
|
137
|
+
/**
|
|
138
|
+
* Minifica o HTML para reduzir tamanho
|
|
139
|
+
*/
|
|
140
|
+
private minifyHtml;
|
|
141
|
+
/**
|
|
142
|
+
* Obtém configuração padrão para um tema
|
|
143
|
+
*/
|
|
144
|
+
private getDefaultConfigForTheme;
|
|
145
|
+
/**
|
|
146
|
+
* Pré-carrega templates no cache
|
|
147
|
+
*/
|
|
148
|
+
preloadTemplates(templates: Array<{
|
|
149
|
+
themeType: ThemeType;
|
|
150
|
+
variant: 'light' | 'dark';
|
|
151
|
+
config: ITemplateConfig;
|
|
152
|
+
}>): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Exporta template para formato JSON
|
|
155
|
+
*/
|
|
156
|
+
exportTemplate(template: ITemplate): string;
|
|
157
|
+
/**
|
|
158
|
+
* Importa template de formato JSON
|
|
159
|
+
*/
|
|
160
|
+
importTemplate(jsonData: string): ITemplate;
|
|
161
|
+
/**
|
|
162
|
+
* Gera um template de exemplo para demonstração
|
|
163
|
+
*/
|
|
164
|
+
generateExampleTemplate(themeType?: ThemeType, variant?: 'light' | 'dark'): ITemplate;
|
|
165
|
+
/**
|
|
166
|
+
* Valida se um template é válido
|
|
167
|
+
*/
|
|
168
|
+
isValidTemplate(template: any): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Obtém estatísticas detalhadas de um template específico
|
|
171
|
+
*/
|
|
172
|
+
getTemplateDetails(templateId: string): {
|
|
173
|
+
template: ITemplate | null;
|
|
174
|
+
history: ITemplate[];
|
|
175
|
+
cacheInfo: TemplateCache | null;
|
|
176
|
+
usageCount: number;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export {};
|
|
180
|
+
//# sourceMappingURL=template.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.service.d.ts","sourceRoot":"","sources":["../../src/services/template.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAEnF,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,UAAU,aAAa;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QA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