@bernierllc/email-template-service 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.
@@ -0,0 +1,574 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.EmailTemplateService = void 0;
11
+ const errors_1 = require("./errors");
12
+ /**
13
+ * Email Template Service
14
+ *
15
+ * Orchestrates email template management with provider synchronization,
16
+ * variable context validation, and base template support.
17
+ */
18
+ class EmailTemplateService {
19
+ constructor(config) {
20
+ this.database = config.database;
21
+ this.templateEngine = config.templateEngine;
22
+ this.variableRegistry = config.variableRegistry;
23
+ this.syncConfig = config.syncConfig;
24
+ this.logger = config.logger;
25
+ // Initialize provider map
26
+ this.providers = new Map();
27
+ for (const provider of config.providers) {
28
+ this.providers.set(provider.providerId, provider);
29
+ }
30
+ this.log('info', 'Email template service initialized', {
31
+ providerCount: this.providers.size,
32
+ syncEnabled: this.syncConfig.enabled
33
+ });
34
+ }
35
+ // ========================================
36
+ // Template CRUD Operations
37
+ // ========================================
38
+ /**
39
+ * Create a new template
40
+ */
41
+ async createTemplate(definition) {
42
+ this.log('info', 'Creating template', { name: definition.name });
43
+ // Build template object
44
+ const template = {
45
+ id: this.generateId(),
46
+ name: definition.name,
47
+ description: definition.description,
48
+ subject: definition.subject,
49
+ htmlContent: definition.htmlContent,
50
+ textContent: definition.textContent,
51
+ category: definition.category,
52
+ tags: definition.tags || [],
53
+ version: '1.0.0',
54
+ isActive: true,
55
+ context: definition.context,
56
+ variables: [],
57
+ requiredVariables: [],
58
+ baseTemplateId: definition.baseTemplateId,
59
+ contentOnly: definition.contentOnly,
60
+ providerTemplateIds: {},
61
+ lastSyncedAt: {},
62
+ syncStatus: {},
63
+ senderId: definition.senderId,
64
+ senderOverride: definition.senderOverride,
65
+ createdAt: new Date(),
66
+ updatedAt: new Date(),
67
+ createdBy: definition.createdBy,
68
+ lastModifiedBy: definition.createdBy
69
+ };
70
+ // Validate template structure
71
+ const validation = await this.validateTemplateStructure(template);
72
+ if (!validation.isValid) {
73
+ throw new errors_1.TemplateValidationError(validation.errors);
74
+ }
75
+ // Extract variables
76
+ template.variables = await this.templateEngine.extractVariables(template.htmlContent);
77
+ template.requiredVariables = template.variables
78
+ .filter(v => v.required)
79
+ .map(v => v.name);
80
+ // Save to database
81
+ const savedTemplate = await this.database.createTemplate(template);
82
+ // Sync to providers if enabled
83
+ if (this.syncConfig.enabled && this.syncConfig.defaultStrategy === 'auto') {
84
+ await this.syncToAllProviders(savedTemplate.id);
85
+ }
86
+ this.log('info', 'Template created', { id: savedTemplate.id, name: savedTemplate.name });
87
+ return savedTemplate;
88
+ }
89
+ /**
90
+ * Update an existing template
91
+ */
92
+ async updateTemplate(id, updates) {
93
+ this.log('info', 'Updating template', { id, updates: Object.keys(updates) });
94
+ const existing = await this.database.getTemplate(id);
95
+ if (!existing) {
96
+ throw new errors_1.TemplateNotFoundError(id);
97
+ }
98
+ // Check for conflicts with provider versions
99
+ if (this.syncConfig.enabled) {
100
+ const conflicts = await this.detectSyncConflicts(id);
101
+ if (conflicts.length > 0) {
102
+ throw new errors_1.SyncConflictError(conflicts);
103
+ }
104
+ }
105
+ // Apply updates
106
+ const updatedData = {
107
+ ...updates,
108
+ updatedAt: new Date()
109
+ };
110
+ // Re-extract variables if content changed
111
+ if (updates.htmlContent) {
112
+ updatedData.variables = await this.templateEngine.extractVariables(updates.htmlContent);
113
+ updatedData.requiredVariables = updatedData.variables
114
+ .filter(v => v.required)
115
+ .map(v => v.name);
116
+ }
117
+ // Validate if content changed
118
+ if (updates.htmlContent || updates.subject) {
119
+ const mergedTemplate = { ...existing, ...updatedData };
120
+ const validation = await this.validateTemplateStructure(mergedTemplate);
121
+ if (!validation.isValid) {
122
+ throw new errors_1.TemplateValidationError(validation.errors);
123
+ }
124
+ }
125
+ // Save to database
126
+ const savedTemplate = await this.database.updateTemplate(id, updatedData);
127
+ // Sync to providers if enabled
128
+ if (this.syncConfig.enabled && this.syncConfig.defaultStrategy === 'auto') {
129
+ await this.syncToAllProviders(id);
130
+ }
131
+ this.log('info', 'Template updated', { id });
132
+ return savedTemplate;
133
+ }
134
+ /**
135
+ * Delete a template
136
+ */
137
+ async deleteTemplate(id) {
138
+ this.log('info', 'Deleting template', { id });
139
+ const template = await this.database.getTemplate(id);
140
+ if (!template) {
141
+ throw new errors_1.TemplateNotFoundError(id);
142
+ }
143
+ // Delete from providers first
144
+ if (this.syncConfig.enabled) {
145
+ for (const [providerId, providerTemplateId] of Object.entries(template.providerTemplateIds)) {
146
+ const plugin = this.providers.get(providerId);
147
+ if (plugin) {
148
+ try {
149
+ await plugin.deleteTemplate(providerTemplateId);
150
+ }
151
+ catch (error) {
152
+ this.log('warn', 'Failed to delete template from provider', {
153
+ providerId,
154
+ error: error instanceof Error ? error.message : 'Unknown error'
155
+ });
156
+ }
157
+ }
158
+ }
159
+ }
160
+ // Delete from database
161
+ await this.database.deleteTemplate(id);
162
+ this.log('info', 'Template deleted', { id });
163
+ }
164
+ /**
165
+ * Get a template by ID
166
+ */
167
+ async getTemplate(id) {
168
+ return this.database.getTemplate(id);
169
+ }
170
+ /**
171
+ * List templates with filtering and pagination
172
+ */
173
+ async listTemplates(options = {}) {
174
+ return this.database.listTemplates(options);
175
+ }
176
+ // ========================================
177
+ // Provider Synchronization
178
+ // ========================================
179
+ /**
180
+ * Sync template to a specific provider
181
+ */
182
+ async syncToProvider(templateId, providerId) {
183
+ this.log('info', 'Syncing template to provider', { templateId, providerId });
184
+ const template = await this.database.getTemplate(templateId);
185
+ if (!template) {
186
+ throw new errors_1.TemplateNotFoundError(templateId);
187
+ }
188
+ const plugin = this.providers.get(providerId);
189
+ if (!plugin) {
190
+ throw new errors_1.ProviderNotFoundError(providerId);
191
+ }
192
+ try {
193
+ const providerTemplateId = template.providerTemplateIds[providerId];
194
+ let result;
195
+ if (providerTemplateId) {
196
+ // Update existing
197
+ await plugin.updateTemplate(providerTemplateId, template);
198
+ result = {
199
+ success: true,
200
+ action: 'updated',
201
+ providerTemplateId,
202
+ localTemplateId: templateId
203
+ };
204
+ }
205
+ else {
206
+ // Create new
207
+ const newProviderTemplateId = await plugin.createTemplate(template);
208
+ result = {
209
+ success: true,
210
+ action: 'created',
211
+ providerTemplateId: newProviderTemplateId,
212
+ localTemplateId: templateId
213
+ };
214
+ // Update local template with provider ID
215
+ await this.database.updateTemplate(templateId, {
216
+ providerTemplateIds: {
217
+ ...template.providerTemplateIds,
218
+ [providerId]: newProviderTemplateId
219
+ },
220
+ lastSyncedAt: {
221
+ ...template.lastSyncedAt,
222
+ [providerId]: new Date()
223
+ },
224
+ syncStatus: {
225
+ ...template.syncStatus,
226
+ [providerId]: 'success'
227
+ }
228
+ });
229
+ }
230
+ this.log('info', 'Template synced to provider', {
231
+ templateId,
232
+ providerId,
233
+ action: result.action
234
+ });
235
+ return result;
236
+ }
237
+ catch (error) {
238
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
239
+ await this.updateSyncStatus(templateId, providerId, 'error');
240
+ this.log('error', 'Failed to sync template to provider', {
241
+ templateId,
242
+ providerId,
243
+ error: errorMessage
244
+ });
245
+ throw new errors_1.SyncError(`Failed to sync template ${templateId} to ${providerId}: ${errorMessage}`);
246
+ }
247
+ }
248
+ /**
249
+ * Sync template from a provider
250
+ */
251
+ async syncFromProvider(providerTemplateId, providerId) {
252
+ this.log('info', 'Syncing template from provider', { providerTemplateId, providerId });
253
+ const plugin = this.providers.get(providerId);
254
+ if (!plugin) {
255
+ throw new errors_1.ProviderNotFoundError(providerId);
256
+ }
257
+ // Get template from provider
258
+ const providerTemplate = await plugin.getTemplate(providerTemplateId);
259
+ // Check if we have this template locally
260
+ const localTemplate = await this.database.findTemplateByProviderId(providerId, providerTemplateId);
261
+ if (localTemplate) {
262
+ // Update existing
263
+ const updates = {
264
+ name: providerTemplate.name,
265
+ subject: providerTemplate.subject || localTemplate.subject,
266
+ htmlContent: providerTemplate.htmlContent || localTemplate.htmlContent,
267
+ textContent: providerTemplate.textContent,
268
+ lastModifiedBy: 'sync'
269
+ };
270
+ return this.updateTemplate(localTemplate.id, updates);
271
+ }
272
+ else {
273
+ // Create new
274
+ const definition = {
275
+ name: providerTemplate.name,
276
+ subject: providerTemplate.subject || 'No subject',
277
+ htmlContent: providerTemplate.htmlContent || '',
278
+ textContent: providerTemplate.textContent,
279
+ tags: [],
280
+ createdBy: 'sync'
281
+ };
282
+ const newTemplate = await this.createTemplate(definition);
283
+ // Update with provider ID
284
+ await this.database.updateTemplate(newTemplate.id, {
285
+ providerTemplateIds: { [providerId]: providerTemplateId },
286
+ lastSyncedAt: { [providerId]: new Date() },
287
+ syncStatus: { [providerId]: 'success' }
288
+ });
289
+ this.log('info', 'Template created from provider', {
290
+ templateId: newTemplate.id,
291
+ providerId
292
+ });
293
+ // Fetch and return the updated template
294
+ const updatedTemplate = await this.database.getTemplate(newTemplate.id);
295
+ if (!updatedTemplate) {
296
+ throw new Error(`Failed to retrieve updated template: ${newTemplate.id}`);
297
+ }
298
+ return updatedTemplate;
299
+ }
300
+ }
301
+ /**
302
+ * Sync all templates to a provider
303
+ */
304
+ async syncAllTemplates(providerId) {
305
+ this.log('info', 'Syncing all templates to provider', { providerId });
306
+ const allTemplates = await this.database.listTemplates({ limit: 1000 });
307
+ const results = [];
308
+ const errors = [];
309
+ for (const template of allTemplates.items) {
310
+ try {
311
+ const result = await this.syncToProvider(template.id, providerId);
312
+ results.push(result);
313
+ }
314
+ catch (error) {
315
+ errors.push({
316
+ templateId: template.id,
317
+ error: error instanceof Error ? error.message : 'Unknown error'
318
+ });
319
+ }
320
+ }
321
+ const batchResult = {
322
+ total: allTemplates.items.length,
323
+ successful: results.filter(r => r.success).length,
324
+ failed: errors.length,
325
+ results,
326
+ errors
327
+ };
328
+ this.log('info', 'Batch sync completed', {
329
+ providerId,
330
+ total: batchResult.total,
331
+ successful: batchResult.successful,
332
+ failed: batchResult.failed
333
+ });
334
+ return batchResult;
335
+ }
336
+ // ========================================
337
+ // Base Template Management
338
+ // ========================================
339
+ /**
340
+ * Create a base template
341
+ */
342
+ async createBaseTemplate(definition) {
343
+ this.log('info', 'Creating base template', { name: definition.name });
344
+ const baseTemplate = {
345
+ id: this.generateId(),
346
+ name: definition.name,
347
+ description: definition.description,
348
+ headerHtml: definition.headerHtml,
349
+ footerHtml: definition.footerHtml,
350
+ headerCss: definition.headerCss,
351
+ footerCss: definition.footerCss,
352
+ theme: definition.theme || 'default',
353
+ brandingElements: definition.brandingElements || [],
354
+ defaultSenderId: definition.defaultSenderId,
355
+ createdAt: new Date(),
356
+ updatedAt: new Date(),
357
+ version: '1.0.0'
358
+ };
359
+ // Validate base template
360
+ const validation = await this.validateBaseTemplate(baseTemplate);
361
+ if (!validation.isValid) {
362
+ throw new errors_1.BaseTemplateValidationError(validation.errors);
363
+ }
364
+ const saved = await this.database.createBaseTemplate(baseTemplate);
365
+ this.log('info', 'Base template created', { id: saved.id });
366
+ return saved;
367
+ }
368
+ /**
369
+ * Build complete template from base template and content
370
+ */
371
+ async buildTemplate(baseTemplateId, content, variables) {
372
+ this.log('info', 'Building template from base', { baseTemplateId });
373
+ const baseTemplate = await this.database.getBaseTemplate(baseTemplateId);
374
+ if (!baseTemplate) {
375
+ throw new errors_1.BaseTemplateNotFoundError(baseTemplateId);
376
+ }
377
+ const builtHtml = await this.templateEngine.buildCompleteTemplate({
378
+ headerHtml: baseTemplate.headerHtml,
379
+ footerHtml: baseTemplate.footerHtml,
380
+ headerCss: baseTemplate.headerCss,
381
+ footerCss: baseTemplate.footerCss
382
+ }, content, variables);
383
+ const builtText = await this.templateEngine.generateTextVersion(builtHtml);
384
+ const templateVariables = await this.templateEngine.extractVariables(builtHtml);
385
+ return {
386
+ html: builtHtml,
387
+ text: builtText,
388
+ variables: templateVariables,
389
+ baseTemplateId,
390
+ contentHtml: content,
391
+ metadata: {
392
+ buildTime: Date.now(),
393
+ variableCount: templateVariables.length,
394
+ contentLength: content.length
395
+ }
396
+ };
397
+ }
398
+ // ========================================
399
+ // Variable Context Integration
400
+ // ========================================
401
+ /**
402
+ * Register a variable context
403
+ */
404
+ async registerContext(name, context) {
405
+ this.log('info', 'Registering variable context', { name });
406
+ await this.variableRegistry.registerContext(name, context);
407
+ await this.database.createOrUpdateVariableContext({
408
+ name,
409
+ description: context.description,
410
+ variables: context.variables,
411
+ extends: context.extends,
412
+ createdAt: new Date(),
413
+ updatedAt: new Date()
414
+ });
415
+ // Revalidate templates using this context
416
+ const templates = await this.database.getTemplatesByContext(name);
417
+ for (const template of templates) {
418
+ await this.revalidateTemplate(template.id);
419
+ }
420
+ this.log('info', 'Variable context registered', { name, templateCount: templates.length });
421
+ }
422
+ /**
423
+ * Validate a template against its variable context
424
+ */
425
+ async validateTemplate(templateId, contextOverride) {
426
+ const template = await this.database.getTemplate(templateId);
427
+ if (!template) {
428
+ throw new errors_1.TemplateNotFoundError(templateId);
429
+ }
430
+ const context = contextOverride || template.context;
431
+ if (!context) {
432
+ return { isValid: true, errors: [], warnings: [] };
433
+ }
434
+ const htmlValidation = await this.variableRegistry.validateTemplate(context, template.htmlContent);
435
+ let textValidation = { isValid: true, errors: [], warnings: [] };
436
+ if (template.textContent) {
437
+ textValidation = await this.variableRegistry.validateTemplate(context, template.textContent);
438
+ }
439
+ const subjectValidation = await this.variableRegistry.validateTemplate(context, template.subject);
440
+ return {
441
+ isValid: htmlValidation.isValid && textValidation.isValid && subjectValidation.isValid,
442
+ errors: [...htmlValidation.errors, ...textValidation.errors, ...subjectValidation.errors],
443
+ warnings: [...htmlValidation.warnings, ...textValidation.warnings, ...subjectValidation.warnings],
444
+ unusedVariables: this.deduplicateArray([
445
+ ...(htmlValidation.unusedVariables || []),
446
+ ...(textValidation.unusedVariables || []),
447
+ ...(subjectValidation.unusedVariables || [])
448
+ ]),
449
+ undefinedVariables: [
450
+ ...(htmlValidation.undefinedVariables || []),
451
+ ...(textValidation.undefinedVariables || []),
452
+ ...(subjectValidation.undefinedVariables || [])
453
+ ]
454
+ };
455
+ }
456
+ /**
457
+ * Get variable suggestions for a context
458
+ */
459
+ async getVariableSuggestions(context, prefix) {
460
+ return this.variableRegistry.getSuggestions(context, prefix);
461
+ }
462
+ // ========================================
463
+ // Private Helper Methods
464
+ // ========================================
465
+ async validateTemplateStructure(template) {
466
+ const errors = [];
467
+ if (!template.name || template.name.trim() === '') {
468
+ errors.push('Template name is required');
469
+ }
470
+ if (!template.subject || template.subject.trim() === '') {
471
+ errors.push('Template subject is required');
472
+ }
473
+ if (!template.htmlContent || template.htmlContent.trim() === '') {
474
+ errors.push('Template HTML content is required');
475
+ }
476
+ // Validate HTML content
477
+ const htmlValidation = await this.templateEngine.validateTemplate(template.htmlContent);
478
+ errors.push(...htmlValidation.errors);
479
+ return {
480
+ isValid: errors.length === 0,
481
+ errors,
482
+ warnings: []
483
+ };
484
+ }
485
+ async validateBaseTemplate(baseTemplate) {
486
+ const errors = [];
487
+ if (!baseTemplate.name || baseTemplate.name.trim() === '') {
488
+ errors.push('Base template name is required');
489
+ }
490
+ if (!baseTemplate.headerHtml || baseTemplate.headerHtml.trim() === '') {
491
+ errors.push('Base template header HTML is required');
492
+ }
493
+ if (!baseTemplate.footerHtml || baseTemplate.footerHtml.trim() === '') {
494
+ errors.push('Base template footer HTML is required');
495
+ }
496
+ return {
497
+ isValid: errors.length === 0,
498
+ errors,
499
+ warnings: []
500
+ };
501
+ }
502
+ async syncToAllProviders(templateId) {
503
+ const enabledProviders = Object.entries(this.syncConfig.providers)
504
+ .filter(([_, config]) => config.enabled)
505
+ .map(([providerId]) => providerId);
506
+ for (const providerId of enabledProviders) {
507
+ try {
508
+ await this.syncToProvider(templateId, providerId);
509
+ }
510
+ catch (error) {
511
+ this.log('error', 'Failed to sync to provider', {
512
+ templateId,
513
+ providerId,
514
+ error: error instanceof Error ? error.message : 'Unknown error'
515
+ });
516
+ }
517
+ }
518
+ }
519
+ async detectSyncConflicts(_templateId) {
520
+ // Simplified implementation - would check if provider versions differ from local
521
+ return [];
522
+ }
523
+ async updateSyncStatus(_templateId, _providerId, _status) {
524
+ const template = await this.database.getTemplate(_templateId);
525
+ if (!template)
526
+ return;
527
+ await this.database.updateTemplate(_templateId, {
528
+ syncStatus: {
529
+ ...template.syncStatus,
530
+ [_providerId]: _status
531
+ },
532
+ lastSyncedAt: {
533
+ ...template.lastSyncedAt,
534
+ [_providerId]: new Date()
535
+ }
536
+ });
537
+ }
538
+ async revalidateTemplate(_templateId) {
539
+ try {
540
+ await this.validateTemplate(_templateId);
541
+ }
542
+ catch (error) {
543
+ this.log('warn', 'Template revalidation failed', {
544
+ templateId: _templateId,
545
+ error: error instanceof Error ? error.message : 'Unknown error'
546
+ });
547
+ }
548
+ }
549
+ generateId() {
550
+ return `tpl_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
551
+ }
552
+ deduplicateArray(arr) {
553
+ return Array.from(new Set(arr));
554
+ }
555
+ log(level, message, meta) {
556
+ if (this.logger) {
557
+ this.logger[level](message, meta);
558
+ }
559
+ }
560
+ /**
561
+ * Get plugin by provider ID
562
+ */
563
+ getPlugin(providerId) {
564
+ return this.providers.get(providerId);
565
+ }
566
+ /**
567
+ * Find template by provider ID and template ID
568
+ */
569
+ async findTemplateByProviderId(providerId, providerTemplateId) {
570
+ return this.database.findTemplateByProviderId(providerId, providerTemplateId);
571
+ }
572
+ }
573
+ exports.EmailTemplateService = EmailTemplateService;
574
+ //# sourceMappingURL=email-template-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-template-service.js","sourceRoot":"","sources":["../src/email-template-service.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAyBF,qCAQkB;AAqDlB;;;;;GAKG;AACH,MAAa,oBAAoB;IAQ/B,YAAY,MAAkC;QAC5C,IA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AAC,WAAW,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,8BAA8B,EAAE;gBAC/C,UAAU,EAAE,WAAW;gBACvB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEO,UAAU;QAChB,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACxE,CAAC;IAEO,gBAAgB,CAAC,GAAa;QACpC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAClC,CAAC;IAEO,GAAG,CAAC,KAA0C,EAAE,OAAe,EAAE,IAA8B;QACrG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,UAAkB;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,wBAAwB,CAAC,UAAkB,EAAE,kBAA0B;QAC3E,OAAO,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;IAChF,CAAC;CACF;AAzpBD,oDAypBC"}
@@ -0,0 +1,69 @@
1
+ import { Conflict } from './types';
2
+ /**
3
+ * Base error class for email template service
4
+ */
5
+ export declare class EmailTemplateServiceError extends Error {
6
+ readonly code: string;
7
+ constructor(message: string, code: string);
8
+ }
9
+ /**
10
+ * Template not found error
11
+ */
12
+ export declare class TemplateNotFoundError extends EmailTemplateServiceError {
13
+ constructor(templateId: string);
14
+ }
15
+ /**
16
+ * Base template not found error
17
+ */
18
+ export declare class BaseTemplateNotFoundError extends EmailTemplateServiceError {
19
+ constructor(baseTemplateId: string);
20
+ }
21
+ /**
22
+ * Template validation error
23
+ */
24
+ export declare class TemplateValidationError extends EmailTemplateServiceError {
25
+ readonly errors: string[];
26
+ constructor(errors: string[]);
27
+ }
28
+ /**
29
+ * Base template validation error
30
+ */
31
+ export declare class BaseTemplateValidationError extends EmailTemplateServiceError {
32
+ readonly errors: string[];
33
+ constructor(errors: string[]);
34
+ }
35
+ /**
36
+ * Provider not found error
37
+ */
38
+ export declare class ProviderNotFoundError extends EmailTemplateServiceError {
39
+ constructor(providerId: string);
40
+ }
41
+ /**
42
+ * Sync error
43
+ */
44
+ export declare class SyncError extends EmailTemplateServiceError {
45
+ constructor(message: string);
46
+ }
47
+ /**
48
+ * Sync conflict error
49
+ */
50
+ export declare class SyncConflictError extends EmailTemplateServiceError {
51
+ readonly conflicts: Conflict[];
52
+ constructor(conflicts: Conflict[]);
53
+ }
54
+ /**
55
+ * Conflict requires manual resolution error
56
+ */
57
+ export declare class ConflictRequiresManualResolutionError extends EmailTemplateServiceError {
58
+ readonly templateId: string;
59
+ readonly conflicts: Conflict[];
60
+ constructor(templateId: string, conflicts: Conflict[]);
61
+ }
62
+ /**
63
+ * Database error
64
+ */
65
+ export declare class DatabaseError extends EmailTemplateServiceError {
66
+ readonly originalError?: Error | undefined;
67
+ constructor(message: string, originalError?: Error | undefined);
68
+ }
69
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;aAGhC,IAAI,EAAE,MAA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