@leadcms/sdk 3.3.5 → 3.3.8

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 (131) hide show
  1. package/README.md +3 -0
  2. package/dist/cli/bin/pull-all.js +10 -2
  3. package/dist/cli/bin/pull-all.js.map +1 -1
  4. package/dist/cli/bin/pull-comments.js +9 -2
  5. package/dist/cli/bin/pull-comments.js.map +1 -1
  6. package/dist/cli/bin/pull-content.js +10 -2
  7. package/dist/cli/bin/pull-content.js.map +1 -1
  8. package/dist/cli/bin/pull-email-templates.d.ts +6 -0
  9. package/dist/cli/bin/pull-email-templates.d.ts.map +1 -0
  10. package/dist/cli/bin/pull-email-templates.js +24 -0
  11. package/dist/cli/bin/pull-email-templates.js.map +1 -0
  12. package/dist/cli/bin/pull-media.js +9 -2
  13. package/dist/cli/bin/pull-media.js.map +1 -1
  14. package/dist/cli/bin/push-all.js +17 -4
  15. package/dist/cli/bin/push-all.js.map +1 -1
  16. package/dist/cli/bin/push-content.js +9 -2
  17. package/dist/cli/bin/push-content.js.map +1 -1
  18. package/dist/cli/bin/push-email-templates.d.ts +6 -0
  19. package/dist/cli/bin/push-email-templates.d.ts.map +1 -0
  20. package/dist/cli/bin/push-email-templates.js +21 -0
  21. package/dist/cli/bin/push-email-templates.js.map +1 -0
  22. package/dist/cli/bin/push-media.js +9 -2
  23. package/dist/cli/bin/push-media.js.map +1 -1
  24. package/dist/cli/bin/push.js +2 -0
  25. package/dist/cli/bin/push.js.map +1 -1
  26. package/dist/cli/bin/status-all.d.ts +1 -1
  27. package/dist/cli/bin/status-all.js +255 -31
  28. package/dist/cli/bin/status-all.js.map +1 -1
  29. package/dist/cli/bin/status-content.js +9 -2
  30. package/dist/cli/bin/status-content.js.map +1 -1
  31. package/dist/cli/bin/status-email-templates.d.ts +6 -0
  32. package/dist/cli/bin/status-email-templates.d.ts.map +1 -0
  33. package/dist/cli/bin/status-email-templates.js +29 -0
  34. package/dist/cli/bin/status-email-templates.js.map +1 -0
  35. package/dist/cli/bin/status-media.js +9 -2
  36. package/dist/cli/bin/status-media.js.map +1 -1
  37. package/dist/cli/bin/status.js +2 -0
  38. package/dist/cli/bin/status.js.map +1 -1
  39. package/dist/cli/bin/watch.js +2 -0
  40. package/dist/cli/bin/watch.js.map +1 -1
  41. package/dist/cli/index.js +29 -2
  42. package/dist/cli/index.js.map +1 -1
  43. package/dist/lib/cms-config-types.d.ts +4 -0
  44. package/dist/lib/cms-config-types.d.ts.map +1 -1
  45. package/dist/lib/cms-config-types.js +6 -0
  46. package/dist/lib/cms-config-types.js.map +1 -1
  47. package/dist/lib/cms.d.ts.map +1 -1
  48. package/dist/lib/cms.js +1 -0
  49. package/dist/lib/cms.js.map +1 -1
  50. package/dist/lib/config.d.ts +2 -0
  51. package/dist/lib/config.d.ts.map +1 -1
  52. package/dist/lib/config.js +5 -0
  53. package/dist/lib/config.js.map +1 -1
  54. package/dist/lib/content-merge.d.ts +2 -2
  55. package/dist/lib/content-merge.d.ts.map +1 -1
  56. package/dist/lib/content-merge.js +39 -35
  57. package/dist/lib/content-merge.js.map +1 -1
  58. package/dist/lib/content-transformation.d.ts +1 -1
  59. package/dist/lib/content-transformation.d.ts.map +1 -1
  60. package/dist/lib/content-transformation.js +8 -2
  61. package/dist/lib/content-transformation.js.map +1 -1
  62. package/dist/lib/data-service.d.ts +56 -0
  63. package/dist/lib/data-service.d.ts.map +1 -1
  64. package/dist/lib/data-service.js +246 -36
  65. package/dist/lib/data-service.js.map +1 -1
  66. package/dist/lib/email-template-transformation.d.ts +36 -0
  67. package/dist/lib/email-template-transformation.d.ts.map +1 -0
  68. package/dist/lib/email-template-transformation.js +88 -0
  69. package/dist/lib/email-template-transformation.js.map +1 -0
  70. package/dist/lib/logger.d.ts +63 -0
  71. package/dist/lib/logger.d.ts.map +1 -0
  72. package/dist/lib/logger.js +87 -0
  73. package/dist/lib/logger.js.map +1 -0
  74. package/dist/lib/spinner.d.ts +25 -0
  75. package/dist/lib/spinner.d.ts.map +1 -0
  76. package/dist/lib/spinner.js +80 -0
  77. package/dist/lib/spinner.js.map +1 -0
  78. package/dist/scripts/fetch-leadcms-comments.d.ts.map +1 -1
  79. package/dist/scripts/fetch-leadcms-comments.js +22 -21
  80. package/dist/scripts/fetch-leadcms-comments.js.map +1 -1
  81. package/dist/scripts/fetch-leadcms-content.d.ts +12 -1
  82. package/dist/scripts/fetch-leadcms-content.d.ts.map +1 -1
  83. package/dist/scripts/fetch-leadcms-content.js +51 -48
  84. package/dist/scripts/fetch-leadcms-content.js.map +1 -1
  85. package/dist/scripts/fetch-leadcms-email-templates.d.ts +15 -0
  86. package/dist/scripts/fetch-leadcms-email-templates.d.ts.map +1 -0
  87. package/dist/scripts/fetch-leadcms-email-templates.js +272 -0
  88. package/dist/scripts/fetch-leadcms-email-templates.js.map +1 -0
  89. package/dist/scripts/init-leadcms.d.ts.map +1 -1
  90. package/dist/scripts/init-leadcms.js +22 -3
  91. package/dist/scripts/init-leadcms.js.map +1 -1
  92. package/dist/scripts/leadcms-helpers.d.ts +1 -0
  93. package/dist/scripts/leadcms-helpers.d.ts.map +1 -1
  94. package/dist/scripts/leadcms-helpers.js +7 -5
  95. package/dist/scripts/leadcms-helpers.js.map +1 -1
  96. package/dist/scripts/pull-all.d.ts +7 -1
  97. package/dist/scripts/pull-all.d.ts.map +1 -1
  98. package/dist/scripts/pull-all.js +40 -19
  99. package/dist/scripts/pull-all.js.map +1 -1
  100. package/dist/scripts/pull-comments.d.ts.map +1 -1
  101. package/dist/scripts/pull-comments.js +3 -2
  102. package/dist/scripts/pull-comments.js.map +1 -1
  103. package/dist/scripts/pull-content.d.ts +2 -0
  104. package/dist/scripts/pull-content.d.ts.map +1 -1
  105. package/dist/scripts/pull-content.js +5 -4
  106. package/dist/scripts/pull-content.js.map +1 -1
  107. package/dist/scripts/pull-email-templates.d.ts +13 -0
  108. package/dist/scripts/pull-email-templates.d.ts.map +1 -0
  109. package/dist/scripts/pull-email-templates.js +79 -0
  110. package/dist/scripts/pull-email-templates.js.map +1 -0
  111. package/dist/scripts/pull-media.d.ts.map +1 -1
  112. package/dist/scripts/pull-media.js +3 -2
  113. package/dist/scripts/pull-media.js.map +1 -1
  114. package/dist/scripts/push-email-templates.d.ts +50 -0
  115. package/dist/scripts/push-email-templates.d.ts.map +1 -0
  116. package/dist/scripts/push-email-templates.js +687 -0
  117. package/dist/scripts/push-email-templates.js.map +1 -0
  118. package/dist/scripts/push-leadcms-content.d.ts +18 -1
  119. package/dist/scripts/push-leadcms-content.d.ts.map +1 -1
  120. package/dist/scripts/push-leadcms-content.js +39 -13
  121. package/dist/scripts/push-leadcms-content.js.map +1 -1
  122. package/dist/scripts/push-media.d.ts +2 -0
  123. package/dist/scripts/push-media.d.ts.map +1 -1
  124. package/dist/scripts/push-media.js +8 -5
  125. package/dist/scripts/push-media.js.map +1 -1
  126. package/dist/scripts/sse-watcher.d.ts +16 -0
  127. package/dist/scripts/sse-watcher.d.ts.map +1 -1
  128. package/dist/scripts/sse-watcher.js +134 -74
  129. package/dist/scripts/sse-watcher.js.map +1 -1
  130. package/leadcms.config.json.sample +2 -0
  131. package/package.json +1 -1
@@ -19,6 +19,30 @@ interface ContentType {
19
19
  format: string;
20
20
  name: string;
21
21
  }
22
+ interface EmailTemplateItem {
23
+ id?: number;
24
+ name?: string;
25
+ subject?: string;
26
+ bodyTemplate?: string;
27
+ fromEmail?: string;
28
+ fromName?: string;
29
+ language?: string;
30
+ translationKey?: string | null;
31
+ emailGroupId?: number | null;
32
+ createdAt?: string;
33
+ updatedAt?: string | null;
34
+ emailGroup?: Record<string, any> | null;
35
+ [key: string]: any;
36
+ }
37
+ interface EmailGroupItem {
38
+ id?: number;
39
+ name?: string;
40
+ language?: string;
41
+ translationKey?: string | null;
42
+ createdAt?: string;
43
+ updatedAt?: string | null;
44
+ [key: string]: any;
45
+ }
22
46
  export interface MediaItem {
23
47
  id: number;
24
48
  location: string;
@@ -37,11 +61,15 @@ interface MockScenario {
37
61
  remoteContent: ContentItem[];
38
62
  contentTypes: Record<string, string>;
39
63
  remoteMedia: MediaItem[];
64
+ emailTemplates?: EmailTemplateItem[];
65
+ emailGroups?: EmailGroupItem[];
40
66
  }
41
67
  interface MockData {
42
68
  remoteContent: ContentItem[];
43
69
  contentTypes: Record<string, string>;
44
70
  remoteMedia: MediaItem[];
71
+ emailTemplates: EmailTemplateItem[];
72
+ emailGroups: EmailGroupItem[];
45
73
  scenario: string;
46
74
  }
47
75
  /**
@@ -92,6 +120,34 @@ declare class LeadCMSDataService {
92
120
  * Delete content from LeadCMS
93
121
  */
94
122
  deleteContent(id: number): Promise<void>;
123
+ /**
124
+ * Get all email templates from LeadCMS or mock data
125
+ */
126
+ getAllEmailTemplates(): Promise<EmailTemplateItem[]>;
127
+ /**
128
+ * Get all email groups from LeadCMS or mock data
129
+ */
130
+ getAllEmailGroups(): Promise<EmailGroupItem[]>;
131
+ /**
132
+ * Create a new email group in LeadCMS or mock
133
+ */
134
+ createEmailGroup(group: {
135
+ name: string;
136
+ language: string;
137
+ translationKey?: string | null;
138
+ }): Promise<EmailGroupItem>;
139
+ /**
140
+ * Create new email template in LeadCMS or mock
141
+ */
142
+ createEmailTemplate(template: Partial<EmailTemplateItem>): Promise<EmailTemplateItem>;
143
+ /**
144
+ * Update existing email template in LeadCMS or mock
145
+ */
146
+ updateEmailTemplate(id: number, template: Partial<EmailTemplateItem>): Promise<EmailTemplateItem>;
147
+ /**
148
+ * Delete email template from LeadCMS
149
+ */
150
+ deleteEmailTemplate(id: number): Promise<void>;
95
151
  /**
96
152
  * Create content type in LeadCMS or mock
97
153
  */
@@ -1 +1 @@
1
- {"version":3,"file":"data-service.d.ts","sourceRoot":"","sources":["../../src/lib/data-service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2CH,UAAU,WAAW;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,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,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;IA+DpD;;OAEG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDpD;;OAEG;IACH,UAAU,IAAI,OAAO;IAKrB;;OAEG;IACH,eAAe,IAAI,MAAM,GAAG,IAAI;IAKhC;;OAEG;IACH,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ;IA6BjD;;OAEG;IACH,YAAY,IAAI,QAAQ,GAAG,IAAI;IAiB/B;;OAEG;IACH,aAAa,IAAI,IAAI;CAOtB;AAGD,eAAO,MAAM,kBAAkB,oBAA2B,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAG9B,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC"}
@@ -3,6 +3,7 @@
3
3
  * Handles API calls vs mock data internally using dependency injection pattern
4
4
  */
5
5
  import axios from 'axios';
6
+ import { logger } from './logger.js';
6
7
  /**
7
8
  * Formats API validation errors in a user-friendly way
8
9
  */
@@ -184,10 +185,10 @@ class LeadCMSDataService {
184
185
  // Initialize mock data if needed
185
186
  if (this.useMock) {
186
187
  this.initializeMockData();
187
- console.log(`[DATA SERVICE] Using mock mode with scenario: ${this.currentScenario?.name}`);
188
+ logger.verbose(`[DATA SERVICE] Using mock mode with scenario: ${this.currentScenario?.name}`);
188
189
  }
189
190
  else {
190
- console.log(`[DATA SERVICE] Using real API mode: ${this.baseURL}`);
191
+ logger.verbose(`[DATA SERVICE] Using real API mode: ${this.baseURL}`);
191
192
  }
192
193
  this.initialized = true;
193
194
  }
@@ -202,6 +203,8 @@ class LeadCMSDataService {
202
203
  remoteContent: JSON.parse(JSON.stringify(scenario.remoteContent)),
203
204
  contentTypes: { ...scenario.contentTypes },
204
205
  remoteMedia: JSON.parse(JSON.stringify(scenario.remoteMedia)),
206
+ emailTemplates: JSON.parse(JSON.stringify(scenario.emailTemplates || [])),
207
+ emailGroups: JSON.parse(JSON.stringify(scenario.emailGroups || [])),
205
208
  scenario: scenario.name
206
209
  };
207
210
  }
@@ -221,13 +224,13 @@ class LeadCMSDataService {
221
224
  async getAllContent() {
222
225
  this._initialize();
223
226
  if (this.useMock && this.mockData) {
224
- console.log('[MOCK] Returning mock content data');
227
+ logger.verbose('[MOCK] Returning mock content data');
225
228
  // Simulate network delay
226
229
  await new Promise(resolve => setTimeout(resolve, 50));
227
230
  return [...this.mockData.remoteContent];
228
231
  }
229
232
  try {
230
- console.log('[API] Fetching content from LeadCMS...');
233
+ logger.verbose('[API] Fetching content from LeadCMS...');
231
234
  if (!this.baseURL) {
232
235
  throw new Error('LeadCMS URL is not configured. Please set LEADCMS_URL or NEXT_PUBLIC_LEADCMS_URL in your .env file.');
233
236
  }
@@ -237,29 +240,29 @@ class LeadCMSDataService {
237
240
  });
238
241
  // Ensure we always return an array
239
242
  if (response.status === 204) {
240
- console.log('[API DEBUG] Status 204 - No Content');
243
+ logger.verbose('[API DEBUG] Status 204 - No Content');
241
244
  return [];
242
245
  }
243
246
  const data = response.data;
244
247
  if (!data) {
245
- console.log('[API DEBUG] No content data returned from API (data is falsy)');
248
+ logger.verbose('[API DEBUG] No content data returned from API (data is falsy)');
246
249
  return [];
247
250
  }
248
251
  // Check if response has 'items' property (API wrapper format)
249
252
  let items;
250
253
  if (data.items && Array.isArray(data.items)) {
251
- console.log(`[API] Found items array in response wrapper with ${data.items.length} items`);
254
+ logger.verbose(`[API] Found items array in response wrapper with ${data.items.length} items`);
252
255
  items = data.items;
253
256
  }
254
257
  else if (Array.isArray(data)) {
255
- console.log(`[API] Response data is direct array with ${data.length} items`);
258
+ logger.verbose(`[API] Response data is direct array with ${data.length} items`);
256
259
  items = data;
257
260
  }
258
261
  else {
259
262
  console.warn('[API] API returned unexpected data format:', typeof data, data);
260
263
  return [];
261
264
  }
262
- console.log(`[API DEBUG] Successfully parsed ${items.length} content items`);
265
+ logger.verbose(`[API DEBUG] Successfully parsed ${items.length} content items`);
263
266
  return items;
264
267
  }
265
268
  catch (error) {
@@ -273,7 +276,7 @@ class LeadCMSDataService {
273
276
  async getContentTypes() {
274
277
  this._initialize();
275
278
  if (this.useMock && this.mockData) {
276
- console.log('[MOCK] Returning mock content types');
279
+ logger.verbose('[MOCK] Returning mock content types');
277
280
  await new Promise(resolve => setTimeout(resolve, 30));
278
281
  return Object.entries(this.mockData.contentTypes).map(([uid, format]) => ({
279
282
  uid,
@@ -282,7 +285,7 @@ class LeadCMSDataService {
282
285
  }));
283
286
  }
284
287
  try {
285
- console.log('[API] Fetching content types from LeadCMS...');
288
+ logger.verbose('[API] Fetching content types from LeadCMS...');
286
289
  if (!this.baseURL) {
287
290
  throw new Error('LeadCMS URL is not configured. Please set LEADCMS_URL or NEXT_PUBLIC_LEADCMS_URL in your .env file.');
288
291
  }
@@ -302,13 +305,13 @@ class LeadCMSDataService {
302
305
  async getContentById(id) {
303
306
  this._initialize();
304
307
  if (this.useMock && this.mockData) {
305
- console.log(`[MOCK] Getting content with ID: ${id}`);
308
+ logger.verbose(`[MOCK] Getting content with ID: ${id}`);
306
309
  await new Promise(resolve => setTimeout(resolve, 50));
307
310
  const content = this.mockData.remoteContent.find(c => c.id === id);
308
311
  return content || null;
309
312
  }
310
313
  try {
311
- console.log(`[API] Fetching content with ID: ${id}`);
314
+ logger.verbose(`[API] Fetching content with ID: ${id}`);
312
315
  if (!this.baseURL) {
313
316
  throw new Error('LeadCMS URL is not configured.');
314
317
  }
@@ -319,7 +322,7 @@ class LeadCMSDataService {
319
322
  }
320
323
  catch (error) {
321
324
  if (error.response?.status === 404) {
322
- console.log(`[API] Content with ID ${id} not found`);
325
+ logger.verbose(`[API] Content with ID ${id} not found`);
323
326
  return null;
324
327
  }
325
328
  if (error.response?.status === 401) {
@@ -344,7 +347,7 @@ class LeadCMSDataService {
344
347
  async createContent(content) {
345
348
  this._initialize();
346
349
  if (this.useMock && this.mockData) {
347
- console.log(`[MOCK] Creating content: ${content.title}`);
350
+ logger.verbose(`[MOCK] Creating content: ${content.title}`);
348
351
  await new Promise(resolve => setTimeout(resolve, 100));
349
352
  const newContent = {
350
353
  ...content,
@@ -356,7 +359,7 @@ class LeadCMSDataService {
356
359
  return newContent;
357
360
  }
358
361
  try {
359
- console.log(`[API] Creating content: ${content.title}`);
362
+ logger.verbose(`[API] Creating content: ${content.title}`);
360
363
  const response = await axios.post(`${this.baseURL}/api/content`, content, {
361
364
  headers: this.getApiHeaders()
362
365
  });
@@ -392,7 +395,7 @@ class LeadCMSDataService {
392
395
  async updateContent(id, content) {
393
396
  this._initialize();
394
397
  if (this.useMock && this.mockData) {
395
- console.log(`[MOCK] Updating content ID ${id}: ${content.title}`);
398
+ logger.verbose(`[MOCK] Updating content ID ${id}: ${content.title}`);
396
399
  await new Promise(resolve => setTimeout(resolve, 80));
397
400
  const existingIndex = this.mockData.remoteContent.findIndex(c => c.id === id);
398
401
  if (existingIndex === -1) {
@@ -407,7 +410,7 @@ class LeadCMSDataService {
407
410
  return updatedContent;
408
411
  }
409
412
  try {
410
- console.log(`[API] Updating content ID ${id}: ${content.title}`);
413
+ logger.verbose(`[API] Updating content ID ${id}: ${content.title}`);
411
414
  const response = await axios.put(`${this.baseURL}/api/content/${id}`, content, {
412
415
  headers: this.getApiHeaders()
413
416
  });
@@ -443,7 +446,7 @@ class LeadCMSDataService {
443
446
  async deleteContent(id) {
444
447
  this._initialize();
445
448
  if (this.useMock && this.mockData) {
446
- console.log(`[MOCK] Deleting content with ID: ${id}`);
449
+ logger.verbose(`[MOCK] Deleting content with ID: ${id}`);
447
450
  await new Promise(resolve => setTimeout(resolve, 80));
448
451
  // Remove from mock data
449
452
  const index = this.mockData.remoteContent.findIndex(c => c.id === id);
@@ -453,14 +456,14 @@ class LeadCMSDataService {
453
456
  return;
454
457
  }
455
458
  try {
456
- console.log(`[API] Deleting content with ID: ${id}`);
459
+ logger.verbose(`[API] Deleting content with ID: ${id}`);
457
460
  if (!this.baseURL) {
458
461
  throw new Error('LeadCMS URL is not configured.');
459
462
  }
460
463
  await axios.delete(`${this.baseURL}/api/content/${id}`, {
461
464
  headers: this.getApiHeaders()
462
465
  });
463
- console.log('[API] Content deleted successfully');
466
+ logger.verbose('[API] Content deleted successfully');
464
467
  }
465
468
  catch (error) {
466
469
  if (error.response?.status === 401) {
@@ -476,13 +479,213 @@ class LeadCMSDataService {
476
479
  throw error;
477
480
  }
478
481
  }
482
+ /**
483
+ * Get all email templates from LeadCMS or mock data
484
+ */
485
+ async getAllEmailTemplates() {
486
+ this._initialize();
487
+ if (this.useMock && this.mockData) {
488
+ logger.verbose('[MOCK] Returning mock email templates');
489
+ await new Promise(resolve => setTimeout(resolve, 30));
490
+ return [...this.mockData.emailTemplates];
491
+ }
492
+ try {
493
+ logger.verbose('[API] Fetching email templates from LeadCMS...');
494
+ if (!this.baseURL) {
495
+ throw new Error('LeadCMS URL is not configured.');
496
+ }
497
+ const response = await axios.get(`${this.baseURL}/api/email-templates`, { headers: this.getApiHeaders() });
498
+ return Array.isArray(response.data) ? response.data : [];
499
+ }
500
+ catch (error) {
501
+ if (error.response?.status === 401) {
502
+ throw formatAuthenticationError(error);
503
+ }
504
+ console.error('[API] Failed to fetch email templates:', error.message);
505
+ throw error;
506
+ }
507
+ }
508
+ /**
509
+ * Get all email groups from LeadCMS or mock data
510
+ */
511
+ async getAllEmailGroups() {
512
+ this._initialize();
513
+ if (this.useMock && this.mockData) {
514
+ logger.verbose('[MOCK] Returning mock email groups');
515
+ await new Promise(resolve => setTimeout(resolve, 30));
516
+ return [...this.mockData.emailGroups];
517
+ }
518
+ try {
519
+ logger.verbose('[API] Fetching email groups from LeadCMS...');
520
+ if (!this.baseURL) {
521
+ throw new Error('LeadCMS URL is not configured.');
522
+ }
523
+ const response = await axios.get(`${this.baseURL}/api/email-groups`, { headers: this.getApiHeaders() });
524
+ return Array.isArray(response.data) ? response.data : [];
525
+ }
526
+ catch (error) {
527
+ if (error.response?.status === 401) {
528
+ throw formatAuthenticationError(error);
529
+ }
530
+ console.error('[API] Failed to fetch email groups:', error.message);
531
+ throw error;
532
+ }
533
+ }
534
+ /**
535
+ * Create a new email group in LeadCMS or mock
536
+ */
537
+ async createEmailGroup(group) {
538
+ this._initialize();
539
+ if (this.useMock && this.mockData) {
540
+ logger.verbose(`[MOCK] Creating email group: ${group.name}`);
541
+ await new Promise(resolve => setTimeout(resolve, 60));
542
+ const newGroup = {
543
+ ...group,
544
+ id: Math.floor(Math.random() * 1000) + 100,
545
+ createdAt: new Date().toISOString(),
546
+ updatedAt: null,
547
+ };
548
+ this.mockData.emailGroups.push(newGroup);
549
+ return newGroup;
550
+ }
551
+ try {
552
+ logger.verbose(`[API] Creating email group: ${group.name}`);
553
+ if (!this.baseURL) {
554
+ throw new Error('LeadCMS URL is not configured.');
555
+ }
556
+ const response = await axios.post(`${this.baseURL}/api/email-groups`, group, { headers: this.getApiHeaders() });
557
+ return response.data;
558
+ }
559
+ catch (error) {
560
+ if (error.response?.status === 401) {
561
+ throw formatAuthenticationError(error);
562
+ }
563
+ console.error(`[API] Failed to create email group '${group.name}':`, error.message);
564
+ throw error;
565
+ }
566
+ }
567
+ /**
568
+ * Create new email template in LeadCMS or mock
569
+ */
570
+ async createEmailTemplate(template) {
571
+ this._initialize();
572
+ if (this.useMock && this.mockData) {
573
+ logger.verbose(`[MOCK] Creating email template: ${template.name}`);
574
+ await new Promise(resolve => setTimeout(resolve, 60));
575
+ const newTemplate = {
576
+ ...template,
577
+ id: Math.floor(Math.random() * 1000) + 100,
578
+ createdAt: new Date().toISOString(),
579
+ updatedAt: new Date().toISOString(),
580
+ };
581
+ this.mockData.emailTemplates.push(newTemplate);
582
+ return newTemplate;
583
+ }
584
+ try {
585
+ logger.verbose(`[API] Creating email template: ${template.name}`);
586
+ const response = await axios.post(`${this.baseURL}/api/email-templates`, template, { headers: this.getApiHeaders() });
587
+ return response.data;
588
+ }
589
+ catch (error) {
590
+ if (error.response?.status === 401) {
591
+ throw formatAuthenticationError(error);
592
+ }
593
+ if (error.response?.status === 422 && error.response?.data?.errors) {
594
+ const validationMessage = formatApiValidationErrors(error.response);
595
+ const enhancedError = new Error(`Validation failed${validationMessage}`);
596
+ enhancedError.status = 422;
597
+ enhancedError.validationErrors = error.response.data.errors;
598
+ throw enhancedError;
599
+ }
600
+ console.error('[API] Failed to create email template:', error.message);
601
+ throw error;
602
+ }
603
+ }
604
+ /**
605
+ * Update existing email template in LeadCMS or mock
606
+ */
607
+ async updateEmailTemplate(id, template) {
608
+ this._initialize();
609
+ if (this.useMock && this.mockData) {
610
+ logger.verbose(`[MOCK] Updating email template ID ${id}: ${template.name}`);
611
+ await new Promise(resolve => setTimeout(resolve, 60));
612
+ const existingIndex = this.mockData.emailTemplates.findIndex(t => t.id === id);
613
+ if (existingIndex === -1) {
614
+ throw new Error(`Email template with id ${id} not found`);
615
+ }
616
+ const updatedTemplate = {
617
+ ...this.mockData.emailTemplates[existingIndex],
618
+ ...template,
619
+ updatedAt: new Date().toISOString(),
620
+ };
621
+ this.mockData.emailTemplates[existingIndex] = updatedTemplate;
622
+ return updatedTemplate;
623
+ }
624
+ try {
625
+ logger.verbose(`[API] Updating email template ID ${id}: ${template.name}`);
626
+ const response = await axios.patch(`${this.baseURL}/api/email-templates/${id}`, template, { headers: this.getApiHeaders() });
627
+ return response.data;
628
+ }
629
+ catch (error) {
630
+ if (error.response?.status === 401) {
631
+ throw formatAuthenticationError(error);
632
+ }
633
+ if (error.response?.status === 422 && error.response?.data?.errors) {
634
+ const validationMessage = formatApiValidationErrors(error.response);
635
+ const enhancedError = new Error(`Validation failed${validationMessage}`);
636
+ enhancedError.status = 422;
637
+ enhancedError.validationErrors = error.response.data.errors;
638
+ throw enhancedError;
639
+ }
640
+ console.error('[API] Failed to update email template:', error.message);
641
+ throw error;
642
+ }
643
+ }
644
+ /**
645
+ * Delete email template from LeadCMS
646
+ */
647
+ async deleteEmailTemplate(id) {
648
+ this._initialize();
649
+ if (this.useMock && this.mockData) {
650
+ logger.verbose(`[MOCK] Deleting email template with ID: ${id}`);
651
+ await new Promise(resolve => setTimeout(resolve, 50));
652
+ const index = this.mockData.emailTemplates.findIndex(t => t.id === id);
653
+ if (index !== -1) {
654
+ this.mockData.emailTemplates.splice(index, 1);
655
+ }
656
+ return;
657
+ }
658
+ try {
659
+ logger.verbose(`[API] Deleting email template with ID: ${id}`);
660
+ if (!this.baseURL) {
661
+ throw new Error('LeadCMS URL is not configured.');
662
+ }
663
+ await axios.delete(`${this.baseURL}/api/email-templates/${id}`, {
664
+ headers: this.getApiHeaders(),
665
+ });
666
+ logger.verbose('[API] Email template deleted successfully');
667
+ }
668
+ catch (error) {
669
+ if (error.response?.status === 401) {
670
+ throw formatAuthenticationError(error);
671
+ }
672
+ if (error.response?.status === 422) {
673
+ const enhancedError = new Error(`Email template validation failed: ${formatApiValidationErrors(error.response)}`);
674
+ enhancedError.status = 422;
675
+ enhancedError.validationErrors = error.response.data.errors;
676
+ throw enhancedError;
677
+ }
678
+ console.error('[API] Failed to delete email template:', error.message);
679
+ throw error;
680
+ }
681
+ }
479
682
  /**
480
683
  * Create content type in LeadCMS or mock
481
684
  */
482
685
  async createContentType(contentType) {
483
686
  this._initialize();
484
687
  if (this.useMock && this.mockData && contentType.uid && contentType.format) {
485
- console.log(`[MOCK] Creating content type: ${contentType.uid}`);
688
+ logger.verbose(`[MOCK] Creating content type: ${contentType.uid}`);
486
689
  await new Promise(resolve => setTimeout(resolve, 60));
487
690
  this.mockData.contentTypes[contentType.uid] = contentType.format;
488
691
  return {
@@ -492,7 +695,7 @@ class LeadCMSDataService {
492
695
  };
493
696
  }
494
697
  try {
495
- console.log(`[API] Creating content type: ${contentType.uid}`);
698
+ logger.verbose(`[API] Creating content type: ${contentType.uid}`);
496
699
  const response = await axios.post(`${this.baseURL}/api/content-types`, contentType, {
497
700
  headers: this.getApiHeaders()
498
701
  });
@@ -509,7 +712,7 @@ class LeadCMSDataService {
509
712
  async getAllMedia(scopeUid) {
510
713
  this._initialize();
511
714
  if (this.useMock && this.mockData) {
512
- console.log('[MOCK] Returning mock media data');
715
+ logger.verbose('[MOCK] Returning mock media data');
513
716
  await new Promise(resolve => setTimeout(resolve, 50));
514
717
  let media = [...this.mockData.remoteMedia];
515
718
  if (scopeUid) {
@@ -518,7 +721,7 @@ class LeadCMSDataService {
518
721
  return media;
519
722
  }
520
723
  try {
521
- console.log('[API] Fetching media from LeadCMS using sync API...');
724
+ logger.verbose('[API] Fetching media from LeadCMS using sync API...');
522
725
  if (!this.baseURL) {
523
726
  throw new Error('LeadCMS URL is not configured.');
524
727
  }
@@ -548,7 +751,7 @@ class LeadCMSDataService {
548
751
  syncToken = nextToken;
549
752
  page++;
550
753
  }
551
- console.log(`[API] Fetched ${allMedia.length} media items`);
754
+ logger.verbose(`[API] Fetched ${allMedia.length} media items`);
552
755
  return allMedia;
553
756
  }
554
757
  catch (error) {
@@ -562,7 +765,7 @@ class LeadCMSDataService {
562
765
  async uploadMedia(formData) {
563
766
  this._initialize();
564
767
  if (this.useMock && this.mockData) {
565
- console.log('[MOCK] Uploading media file');
768
+ logger.verbose('[MOCK] Uploading media file');
566
769
  await new Promise(resolve => setTimeout(resolve, 100));
567
770
  // Extract data from FormData for mock
568
771
  const scopeUid = formData.get('ScopeUid');
@@ -584,7 +787,7 @@ class LeadCMSDataService {
584
787
  return newMedia;
585
788
  }
586
789
  try {
587
- console.log('[API] Uploading media file...');
790
+ logger.verbose('[API] Uploading media file...');
588
791
  if (!this.baseURL) {
589
792
  throw new Error('LeadCMS URL is not configured.');
590
793
  }
@@ -594,7 +797,7 @@ class LeadCMSDataService {
594
797
  // Don't set Content-Type, let axios set it with boundary for multipart
595
798
  }
596
799
  });
597
- console.log('[API] Media uploaded successfully');
800
+ logger.verbose('[API] Media uploaded successfully');
598
801
  return response.data;
599
802
  }
600
803
  catch (error) {
@@ -617,7 +820,7 @@ class LeadCMSDataService {
617
820
  async updateMedia(formData) {
618
821
  this._initialize();
619
822
  if (this.useMock && this.mockData) {
620
- console.log('[MOCK] Updating media file');
823
+ logger.verbose('[MOCK] Updating media file');
621
824
  await new Promise(resolve => setTimeout(resolve, 100));
622
825
  const scopeUid = formData.get('ScopeUid');
623
826
  const fileName = formData.get('FileName');
@@ -633,7 +836,7 @@ class LeadCMSDataService {
633
836
  return updatedMedia;
634
837
  }
635
838
  try {
636
- console.log('[API] Updating media file...');
839
+ logger.verbose('[API] Updating media file...');
637
840
  if (!this.baseURL) {
638
841
  throw new Error('LeadCMS URL is not configured.');
639
842
  }
@@ -642,7 +845,7 @@ class LeadCMSDataService {
642
845
  'Authorization': `Bearer ${this.apiKey}`,
643
846
  }
644
847
  });
645
- console.log('[API] Media updated successfully');
848
+ logger.verbose('[API] Media updated successfully');
646
849
  return response.data;
647
850
  }
648
851
  catch (error) {
@@ -665,7 +868,7 @@ class LeadCMSDataService {
665
868
  async deleteMedia(pathToFile) {
666
869
  this._initialize();
667
870
  if (this.useMock && this.mockData) {
668
- console.log(`[MOCK] Deleting media file: ${pathToFile}`);
871
+ logger.verbose(`[MOCK] Deleting media file: ${pathToFile}`);
669
872
  await new Promise(resolve => setTimeout(resolve, 80));
670
873
  // Parse path to extract scopeUid and name
671
874
  // Path format: /api/media/scopeUid/filename or scopeUid/filename
@@ -680,14 +883,14 @@ class LeadCMSDataService {
680
883
  return;
681
884
  }
682
885
  try {
683
- console.log(`[API] Deleting media file: ${pathToFile}`);
886
+ logger.verbose(`[API] Deleting media file: ${pathToFile}`);
684
887
  if (!this.baseURL) {
685
888
  throw new Error('LeadCMS URL is not configured.');
686
889
  }
687
890
  await axios.delete(`${this.baseURL}/api/media/${pathToFile}`, {
688
891
  headers: this.getApiHeaders()
689
892
  });
690
- console.log('[API] Media deleted successfully');
893
+ logger.verbose('[API] Media deleted successfully');
691
894
  }
692
895
  catch (error) {
693
896
  if (error.response?.status === 401) {
@@ -728,9 +931,14 @@ class LeadCMSDataService {
728
931
  remoteContent: JSON.parse(JSON.stringify(scenario.remoteContent)),
729
932
  contentTypes: { ...scenario.contentTypes },
730
933
  remoteMedia: JSON.parse(JSON.stringify(scenario.remoteMedia)),
934
+ emailTemplates: JSON.parse(JSON.stringify(scenario.emailTemplates || [])),
935
+ emailGroups: JSON.parse(JSON.stringify(scenario.emailGroups || [])),
731
936
  scenario: scenario.name
732
937
  };
733
- console.log(`[MOCK] Switched to scenario: ${scenario.name}`);
938
+ logger.verbose(`[MOCK] Switched to scenario: ${scenario.name}`);
939
+ if (!this.mockData) {
940
+ throw new Error('Mock data not initialized');
941
+ }
734
942
  return this.mockData;
735
943
  }
736
944
  /**
@@ -745,6 +953,8 @@ class LeadCMSDataService {
745
953
  remoteContent: [...this.mockData.remoteContent],
746
954
  contentTypes: { ...this.mockData.contentTypes },
747
955
  remoteMedia: [...this.mockData.remoteMedia],
956
+ emailTemplates: [...this.mockData.emailTemplates],
957
+ emailGroups: [...this.mockData.emailGroups],
748
958
  scenario: this.currentScenario?.name || ''
749
959
  };
750
960
  }