@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.
package/dist/errors.js ADDED
@@ -0,0 +1,128 @@
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.DatabaseError = exports.ConflictRequiresManualResolutionError = exports.SyncConflictError = exports.SyncError = exports.ProviderNotFoundError = exports.BaseTemplateValidationError = exports.TemplateValidationError = exports.BaseTemplateNotFoundError = exports.TemplateNotFoundError = exports.EmailTemplateServiceError = void 0;
11
+ /**
12
+ * Base error class for email template service
13
+ */
14
+ class EmailTemplateServiceError extends Error {
15
+ constructor(message, code) {
16
+ super(message);
17
+ this.code = code;
18
+ this.name = 'EmailTemplateServiceError';
19
+ Object.setPrototypeOf(this, EmailTemplateServiceError.prototype);
20
+ }
21
+ }
22
+ exports.EmailTemplateServiceError = EmailTemplateServiceError;
23
+ /**
24
+ * Template not found error
25
+ */
26
+ class TemplateNotFoundError extends EmailTemplateServiceError {
27
+ constructor(templateId) {
28
+ super(`Template not found: ${templateId}`, 'TEMPLATE_NOT_FOUND');
29
+ this.name = 'TemplateNotFoundError';
30
+ Object.setPrototypeOf(this, TemplateNotFoundError.prototype);
31
+ }
32
+ }
33
+ exports.TemplateNotFoundError = TemplateNotFoundError;
34
+ /**
35
+ * Base template not found error
36
+ */
37
+ class BaseTemplateNotFoundError extends EmailTemplateServiceError {
38
+ constructor(baseTemplateId) {
39
+ super(`Base template not found: ${baseTemplateId}`, 'BASE_TEMPLATE_NOT_FOUND');
40
+ this.name = 'BaseTemplateNotFoundError';
41
+ Object.setPrototypeOf(this, BaseTemplateNotFoundError.prototype);
42
+ }
43
+ }
44
+ exports.BaseTemplateNotFoundError = BaseTemplateNotFoundError;
45
+ /**
46
+ * Template validation error
47
+ */
48
+ class TemplateValidationError extends EmailTemplateServiceError {
49
+ constructor(errors) {
50
+ super(`Template validation failed: ${errors.join(', ')}`, 'TEMPLATE_VALIDATION_ERROR');
51
+ this.errors = errors;
52
+ this.name = 'TemplateValidationError';
53
+ Object.setPrototypeOf(this, TemplateValidationError.prototype);
54
+ }
55
+ }
56
+ exports.TemplateValidationError = TemplateValidationError;
57
+ /**
58
+ * Base template validation error
59
+ */
60
+ class BaseTemplateValidationError extends EmailTemplateServiceError {
61
+ constructor(errors) {
62
+ super(`Base template validation failed: ${errors.join(', ')}`, 'BASE_TEMPLATE_VALIDATION_ERROR');
63
+ this.errors = errors;
64
+ this.name = 'BaseTemplateValidationError';
65
+ Object.setPrototypeOf(this, BaseTemplateValidationError.prototype);
66
+ }
67
+ }
68
+ exports.BaseTemplateValidationError = BaseTemplateValidationError;
69
+ /**
70
+ * Provider not found error
71
+ */
72
+ class ProviderNotFoundError extends EmailTemplateServiceError {
73
+ constructor(providerId) {
74
+ super(`Provider not found: ${providerId}`, 'PROVIDER_NOT_FOUND');
75
+ this.name = 'ProviderNotFoundError';
76
+ Object.setPrototypeOf(this, ProviderNotFoundError.prototype);
77
+ }
78
+ }
79
+ exports.ProviderNotFoundError = ProviderNotFoundError;
80
+ /**
81
+ * Sync error
82
+ */
83
+ class SyncError extends EmailTemplateServiceError {
84
+ constructor(message) {
85
+ super(message, 'SYNC_ERROR');
86
+ this.name = 'SyncError';
87
+ Object.setPrototypeOf(this, SyncError.prototype);
88
+ }
89
+ }
90
+ exports.SyncError = SyncError;
91
+ /**
92
+ * Sync conflict error
93
+ */
94
+ class SyncConflictError extends EmailTemplateServiceError {
95
+ constructor(conflicts) {
96
+ super(`Sync conflicts detected: ${conflicts.length} conflicts`, 'SYNC_CONFLICT');
97
+ this.conflicts = conflicts;
98
+ this.name = 'SyncConflictError';
99
+ Object.setPrototypeOf(this, SyncConflictError.prototype);
100
+ }
101
+ }
102
+ exports.SyncConflictError = SyncConflictError;
103
+ /**
104
+ * Conflict requires manual resolution error
105
+ */
106
+ class ConflictRequiresManualResolutionError extends EmailTemplateServiceError {
107
+ constructor(templateId, conflicts) {
108
+ super(`Template ${templateId} has conflicts requiring manual resolution: ${conflicts.length} conflicts`, 'MANUAL_RESOLUTION_REQUIRED');
109
+ this.templateId = templateId;
110
+ this.conflicts = conflicts;
111
+ this.name = 'ConflictRequiresManualResolutionError';
112
+ Object.setPrototypeOf(this, ConflictRequiresManualResolutionError.prototype);
113
+ }
114
+ }
115
+ exports.ConflictRequiresManualResolutionError = ConflictRequiresManualResolutionError;
116
+ /**
117
+ * Database error
118
+ */
119
+ class DatabaseError extends EmailTemplateServiceError {
120
+ constructor(message, originalError) {
121
+ super(`Database operation failed: ${message}`, 'DATABASE_ERROR');
122
+ this.originalError = originalError;
123
+ this.name = 'DatabaseError';
124
+ Object.setPrototypeOf(this, DatabaseError.prototype);
125
+ }
126
+ }
127
+ exports.DatabaseError = DatabaseError;
128
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAIF;;GAEG;AACH,MAAa,yBAA0B,SAAQ,KAAK;IAClD,YACE,OAAe,EACC,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC;CACF;AATD,8DASC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,yBAAyB;IAClE,YAAY,UAAkB;QAC5B,KAAK,CAAC,uBAAuB,UAAU,EAAE,EAAE,oBAAoB,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,GA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AC,CAAC;QADtB,kBAAa,GAAb,aAAa,CAAQ;QAEhE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AAND,sCAMC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @bernierllc/email-template-service
3
+ *
4
+ * Email template management service with provider synchronization,
5
+ * variable context validation, and base template support.
6
+ */
7
+ export { EmailTemplateService, EmailTemplateServiceConfig, TemplateEngine, VariableRegistry, Logger } from './email-template-service';
8
+ export { TemplateProviderPlugin, BaseProviderPlugin, MockProviderPlugin } from './provider-plugin';
9
+ export { DatabaseAdapter, InMemoryDatabaseAdapter } from './database-adapter';
10
+ export { EmailTemplateServiceError, TemplateNotFoundError, BaseTemplateNotFoundError, TemplateValidationError, BaseTemplateValidationError, ProviderNotFoundError, SyncError, SyncConflictError, ConflictRequiresManualResolutionError, DatabaseError } from './errors';
11
+ export type { Template, TemplateDefinition, TemplateUpdate, BaseTemplate, BaseTemplateDefinition, BuiltTemplate, TemplateVariable, VariableContext, VariableContextVariable, ValidationResult, VariableSuggestion, ListOptions, PaginatedResult, SyncConfiguration, ProviderSyncConfig, SyncResult, BatchSyncResult, Conflict, ConflictResolution, ConflictResolutionStrategy, ProviderTemplate, ProviderCapability, FeatureConfig, ProviderStatus, PluginConfig, BrandingElement, SenderConfiguration, CacheConfiguration, VariableType, SyncStatus, SyncStrategy, SyncDirection, SyncAction, ConflictAction } from './types';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AAEH,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,EAChB,MAAM,EACP,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,SAAS,EACT,iBAAiB,EACjB,qCAAqC,EACrC,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,QAAQ,EACR,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACf,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
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.DatabaseError = exports.ConflictRequiresManualResolutionError = exports.SyncConflictError = exports.SyncError = exports.ProviderNotFoundError = exports.BaseTemplateValidationError = exports.TemplateValidationError = exports.BaseTemplateNotFoundError = exports.TemplateNotFoundError = exports.EmailTemplateServiceError = exports.InMemoryDatabaseAdapter = exports.MockProviderPlugin = exports.BaseProviderPlugin = exports.EmailTemplateService = void 0;
11
+ /**
12
+ * @bernierllc/email-template-service
13
+ *
14
+ * Email template management service with provider synchronization,
15
+ * variable context validation, and base template support.
16
+ */
17
+ var email_template_service_1 = require("./email-template-service");
18
+ Object.defineProperty(exports, "EmailTemplateService", { enumerable: true, get: function () { return email_template_service_1.EmailTemplateService; } });
19
+ var provider_plugin_1 = require("./provider-plugin");
20
+ Object.defineProperty(exports, "BaseProviderPlugin", { enumerable: true, get: function () { return provider_plugin_1.BaseProviderPlugin; } });
21
+ Object.defineProperty(exports, "MockProviderPlugin", { enumerable: true, get: function () { return provider_plugin_1.MockProviderPlugin; } });
22
+ var database_adapter_1 = require("./database-adapter");
23
+ Object.defineProperty(exports, "InMemoryDatabaseAdapter", { enumerable: true, get: function () { return database_adapter_1.InMemoryDatabaseAdapter; } });
24
+ var errors_1 = require("./errors");
25
+ Object.defineProperty(exports, "EmailTemplateServiceError", { enumerable: true, get: function () { return errors_1.EmailTemplateServiceError; } });
26
+ Object.defineProperty(exports, "TemplateNotFoundError", { enumerable: true, get: function () { return errors_1.TemplateNotFoundError; } });
27
+ Object.defineProperty(exports, "BaseTemplateNotFoundError", { enumerable: true, get: function () { return errors_1.BaseTemplateNotFoundError; } });
28
+ Object.defineProperty(exports, "TemplateValidationError", { enumerable: true, get: function () { return errors_1.TemplateValidationError; } });
29
+ Object.defineProperty(exports, "BaseTemplateValidationError", { enumerable: true, get: function () { return errors_1.BaseTemplateValidationError; } });
30
+ Object.defineProperty(exports, "ProviderNotFoundError", { enumerable: true, get: function () { return errors_1.ProviderNotFoundError; } });
31
+ Object.defineProperty(exports, "SyncError", { enumerable: true, get: function () { return errors_1.SyncError; } });
32
+ Object.defineProperty(exports, "SyncConflictError", { enumerable: true, get: function () { return errors_1.SyncConflictError; } });
33
+ Object.defineProperty(exports, "ConflictRequiresManualResolutionError", { enumerable: true, get: function () { return errors_1.ConflictRequiresManualResolutionError; } });
34
+ Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_1.DatabaseError; } });
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF;;;;;GAKG;AAEH,mEAMkC;AALhC,8HAAA,oBAAoB,OAAA;AAOtB,qDAI2B;AAFzB,qHAAA,kBAAkB,OAAA;AAClB,qHAAA,kBAAkB,OAAA;AAGpB,uDAG4B;AAD1B,2HAAA,uBAAuB,OAAA;AAGzB,mCAWkB;AAVhB,mHAAA,yBAAyB,OAAA;AACzB,+GAAA,qBAAqB,OAAA;AACrB,mHAAA,yBAAyB,OAAA;AACzB,iHAAA,uBAAuB,OAAA;AACvB,qHAAA,2BAA2B,OAAA;AAC3B,+GAAA,qBAAqB,OAAA;AACrB,mGAAA,SAAS,OAAA;AACT,2GAAA,iBAAiB,OAAA;AACjB,+HAAA,qCAAqC,OAAA;AACrC,uGAAA,aAAa,OAAA"}
@@ -0,0 +1,91 @@
1
+ import { Template, ProviderTemplate, ProviderCapability, FeatureConfig, ProviderStatus, PluginConfig, SyncResult } from './types';
2
+ /**
3
+ * Template provider plugin interface
4
+ *
5
+ * Defines the contract for provider-specific template management implementations.
6
+ * Each provider (SendGrid, Mailgun, etc.) should implement this interface.
7
+ */
8
+ export interface TemplateProviderPlugin {
9
+ /**
10
+ * Plugin identification
11
+ */
12
+ readonly name: string;
13
+ readonly version: string;
14
+ readonly providerId: string;
15
+ readonly capabilities: ProviderCapability[];
16
+ /**
17
+ * Plugin lifecycle management
18
+ */
19
+ initialize(config: PluginConfig): Promise<void>;
20
+ destroy(): Promise<void>;
21
+ /**
22
+ * Template operations
23
+ */
24
+ createTemplate(template: Template): Promise<string>;
25
+ updateTemplate(providerTemplateId: string, template: Template): Promise<void>;
26
+ deleteTemplate(providerTemplateId: string): Promise<void>;
27
+ getTemplate(providerTemplateId: string): Promise<ProviderTemplate>;
28
+ listTemplates(): Promise<ProviderTemplate[]>;
29
+ /**
30
+ * Synchronization
31
+ */
32
+ syncToProvider(template: Template): Promise<SyncResult>;
33
+ syncFromProvider(providerTemplateId: string): Promise<Template>;
34
+ /**
35
+ * Capabilities
36
+ */
37
+ supportsFeature(feature: string): boolean;
38
+ getFeatureConfig(feature: string): FeatureConfig | null;
39
+ /**
40
+ * Health and status
41
+ */
42
+ testConnection(): Promise<boolean>;
43
+ getStatus(): Promise<ProviderStatus>;
44
+ }
45
+ /**
46
+ * Base abstract class for provider plugins with common functionality
47
+ */
48
+ export declare abstract class BaseProviderPlugin implements TemplateProviderPlugin {
49
+ abstract readonly name: string;
50
+ abstract readonly version: string;
51
+ abstract readonly providerId: string;
52
+ abstract readonly capabilities: ProviderCapability[];
53
+ protected config: PluginConfig;
54
+ protected initialized: boolean;
55
+ initialize(config: PluginConfig): Promise<void>;
56
+ destroy(): Promise<void>;
57
+ protected ensureInitialized(): void;
58
+ supportsFeature(feature: string): boolean;
59
+ getFeatureConfig(feature: string): FeatureConfig | null;
60
+ abstract createTemplate(template: Template): Promise<string>;
61
+ abstract updateTemplate(providerTemplateId: string, template: Template): Promise<void>;
62
+ abstract deleteTemplate(providerTemplateId: string): Promise<void>;
63
+ abstract getTemplate(providerTemplateId: string): Promise<ProviderTemplate>;
64
+ abstract listTemplates(): Promise<ProviderTemplate[]>;
65
+ abstract syncToProvider(template: Template): Promise<SyncResult>;
66
+ abstract syncFromProvider(providerTemplateId: string): Promise<Template>;
67
+ abstract testConnection(): Promise<boolean>;
68
+ abstract getStatus(): Promise<ProviderStatus>;
69
+ }
70
+ /**
71
+ * Mock provider plugin for testing
72
+ */
73
+ export declare class MockProviderPlugin extends BaseProviderPlugin {
74
+ readonly name = "MockProvider";
75
+ readonly version = "1.0.0";
76
+ readonly providerId = "mock";
77
+ readonly capabilities: ProviderCapability[];
78
+ private templates;
79
+ private idCounter;
80
+ createTemplate(template: Template): Promise<string>;
81
+ updateTemplate(providerTemplateId: string, template: Template): Promise<void>;
82
+ deleteTemplate(providerTemplateId: string): Promise<void>;
83
+ getTemplate(providerTemplateId: string): Promise<ProviderTemplate>;
84
+ listTemplates(): Promise<ProviderTemplate[]>;
85
+ syncToProvider(template: Template): Promise<SyncResult>;
86
+ syncFromProvider(providerTemplateId: string): Promise<Template>;
87
+ testConnection(): Promise<boolean>;
88
+ getStatus(): Promise<ProviderStatus>;
89
+ clear(): void;
90
+ }
91
+ //# sourceMappingURL=provider-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-plugin.d.ts","sourceRoot":"","sources":["../src/provider-plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,kBAAkB,EAAE,CAAC;IAE5C;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,WAAW,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACnE,aAAa,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAE7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EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IA2B/D,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC;IAW1C,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,166 @@
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.MockProviderPlugin = exports.BaseProviderPlugin = void 0;
11
+ /**
12
+ * Base abstract class for provider plugins with common functionality
13
+ */
14
+ class BaseProviderPlugin {
15
+ constructor() {
16
+ this.config = {};
17
+ this.initialized = false;
18
+ }
19
+ async initialize(config) {
20
+ this.config = config;
21
+ this.initialized = true;
22
+ }
23
+ async destroy() {
24
+ this.initialized = false;
25
+ }
26
+ ensureInitialized() {
27
+ if (!this.initialized) {
28
+ throw new Error(`Plugin ${this.name} is not initialized`);
29
+ }
30
+ }
31
+ supportsFeature(feature) {
32
+ return this.capabilities.some(cap => cap.feature === feature);
33
+ }
34
+ getFeatureConfig(feature) {
35
+ const capability = this.capabilities.find(cap => cap.feature === feature);
36
+ if (!capability) {
37
+ return null;
38
+ }
39
+ return {
40
+ enabled: true,
41
+ options: capability.config
42
+ };
43
+ }
44
+ }
45
+ exports.BaseProviderPlugin = BaseProviderPlugin;
46
+ /**
47
+ * Mock provider plugin for testing
48
+ */
49
+ class MockProviderPlugin extends BaseProviderPlugin {
50
+ constructor() {
51
+ super(...arguments);
52
+ this.name = 'MockProvider';
53
+ this.version = '1.0.0';
54
+ this.providerId = 'mock';
55
+ this.capabilities = [
56
+ {
57
+ feature: 'template-versioning',
58
+ description: 'Supports template versions',
59
+ methods: ['createTemplate', 'updateTemplate']
60
+ }
61
+ ];
62
+ this.templates = new Map();
63
+ this.idCounter = 1;
64
+ }
65
+ async createTemplate(template) {
66
+ this.ensureInitialized();
67
+ const id = `mock_${this.idCounter++}`;
68
+ this.templates.set(id, {
69
+ id,
70
+ name: template.name,
71
+ subject: template.subject,
72
+ htmlContent: template.htmlContent,
73
+ textContent: template.textContent,
74
+ updatedAt: new Date()
75
+ });
76
+ return id;
77
+ }
78
+ async updateTemplate(providerTemplateId, template) {
79
+ this.ensureInitialized();
80
+ const existing = this.templates.get(providerTemplateId);
81
+ if (!existing) {
82
+ throw new Error(`Template not found: ${providerTemplateId}`);
83
+ }
84
+ this.templates.set(providerTemplateId, {
85
+ ...existing,
86
+ name: template.name,
87
+ subject: template.subject,
88
+ htmlContent: template.htmlContent,
89
+ textContent: template.textContent,
90
+ updatedAt: new Date()
91
+ });
92
+ }
93
+ async deleteTemplate(providerTemplateId) {
94
+ this.ensureInitialized();
95
+ if (!this.templates.has(providerTemplateId)) {
96
+ throw new Error(`Template not found: ${providerTemplateId}`);
97
+ }
98
+ this.templates.delete(providerTemplateId);
99
+ }
100
+ async getTemplate(providerTemplateId) {
101
+ this.ensureInitialized();
102
+ const template = this.templates.get(providerTemplateId);
103
+ if (!template) {
104
+ throw new Error(`Template not found: ${providerTemplateId}`);
105
+ }
106
+ return template;
107
+ }
108
+ async listTemplates() {
109
+ this.ensureInitialized();
110
+ return Array.from(this.templates.values());
111
+ }
112
+ async syncToProvider(template) {
113
+ this.ensureInitialized();
114
+ const id = await this.createTemplate(template);
115
+ return {
116
+ success: true,
117
+ action: 'created',
118
+ providerTemplateId: id,
119
+ localTemplateId: template.id
120
+ };
121
+ }
122
+ async syncFromProvider(providerTemplateId) {
123
+ this.ensureInitialized();
124
+ const providerTemplate = await this.getTemplate(providerTemplateId);
125
+ return {
126
+ id: `local_${providerTemplateId}`,
127
+ name: providerTemplate.name,
128
+ subject: providerTemplate.subject || '',
129
+ htmlContent: providerTemplate.htmlContent || '',
130
+ textContent: providerTemplate.textContent,
131
+ category: undefined,
132
+ tags: [],
133
+ version: '1.0.0',
134
+ isActive: true,
135
+ context: undefined,
136
+ variables: [],
137
+ requiredVariables: [],
138
+ providerTemplateIds: { [this.providerId]: providerTemplateId },
139
+ lastSyncedAt: {},
140
+ syncStatus: {},
141
+ createdAt: new Date(),
142
+ updatedAt: new Date(),
143
+ createdBy: 'system',
144
+ lastModifiedBy: 'system'
145
+ };
146
+ }
147
+ async testConnection() {
148
+ return this.initialized;
149
+ }
150
+ async getStatus() {
151
+ return {
152
+ connected: this.initialized,
153
+ lastCheck: new Date(),
154
+ metrics: {
155
+ templateCount: this.templates.size
156
+ }
157
+ };
158
+ }
159
+ // Helper for testing
160
+ clear() {
161
+ this.templates.clear();
162
+ this.idCounter = 1;
163
+ }
164
+ }
165
+ exports.MockProviderPlugin = MockProviderPlugin;
166
+ //# sourceMappingURL=provider-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-plugin.js","sourceRoot":"","sources":["../src/provider-plugin.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AA6DF;;GAEG;AACH,MAAsB,kBAAkB;IAAxC;QAMY,WAAM,GAAiB,EAAE,CAAC;QAC1B,gBAAW,GAAG,KAAK,CAAC;IA0ChC,CAAC;IAxCC,KAAK,CAAC,UAAU,CAAC,MAAoB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAES,iBAAiB;QACzB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,IAAI,qBAAqB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,eAAe,CAAC,OAAe;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GA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