@blackcode_sa/metaestetics-api 1.14.65 → 1.14.71

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.
@@ -232,6 +232,7 @@ __export(index_exports, {
232
232
  CLINIC_ANALYTICS_SUBCOLLECTION: () => CLINIC_ANALYTICS_SUBCOLLECTION,
233
233
  CalendarAdminService: () => CalendarAdminService,
234
234
  ClinicAggregationService: () => ClinicAggregationService,
235
+ ClinicWelcomeMailingService: () => ClinicWelcomeMailingService,
235
236
  DASHBOARD_ANALYTICS_SUBCOLLECTION: () => DASHBOARD_ANALYTICS_SUBCOLLECTION,
236
237
  DocumentManagerAdminService: () => DocumentManagerAdminService,
237
238
  ExistingPractitionerInviteMailingService: () => ExistingPractitionerInviteMailingService,
@@ -3131,6 +3132,11 @@ var AppointmentMailingService = class extends BaseMailingService {
3131
3132
  };
3132
3133
 
3133
3134
  // src/admin/aggregation/appointment/appointment.aggregation.service.ts
3135
+ function sanitizeCancellationReason(reason) {
3136
+ if (!reason) return void 0;
3137
+ const isLikelyId = !reason.includes(" ") && /^[a-zA-Z0-9_-]+$/.test(reason) && reason.length > 15;
3138
+ return isLikelyId ? void 0 : reason;
3139
+ }
3134
3140
  var AppointmentAggregationService = class {
3135
3141
  /**
3136
3142
  * Constructor for AppointmentAggregationService.
@@ -3412,7 +3418,7 @@ var AppointmentAggregationService = class {
3412
3418
  appointment: after,
3413
3419
  recipientProfile: after.patientInfo,
3414
3420
  recipientRole: "patient",
3415
- cancellationReason: after.cancellationReason
3421
+ cancellationReason: sanitizeCancellationReason(after.cancellationReason)
3416
3422
  };
3417
3423
  await this.appointmentMailingService.sendAppointmentCancelledEmail(
3418
3424
  patientCancellationData
@@ -3426,7 +3432,7 @@ var AppointmentAggregationService = class {
3426
3432
  appointment: after,
3427
3433
  recipientProfile: after.practitionerInfo,
3428
3434
  recipientRole: "practitioner",
3429
- cancellationReason: after.cancellationReason
3435
+ cancellationReason: sanitizeCancellationReason(after.cancellationReason)
3430
3436
  };
3431
3437
  await this.appointmentMailingService.sendAppointmentCancelledEmail(
3432
3438
  practitionerCancellationData
@@ -14088,6 +14094,405 @@ var PatientInviteMailingService = class extends BaseMailingService {
14088
14094
  }
14089
14095
  };
14090
14096
 
14097
+ // src/admin/mailing/clinicWelcome/templates/welcome.template.ts
14098
+ var clinicWelcomeTemplate = `
14099
+ <!DOCTYPE html>
14100
+ <html lang="en">
14101
+ <head>
14102
+ <meta charset="UTF-8">
14103
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
14104
+ <title>Welcome to MetaEsthetics</title>
14105
+ <!--[if mso]>
14106
+ <noscript>
14107
+ <xml>
14108
+ <o:OfficeDocumentSettings>
14109
+ <o:PixelsPerInch>96</o:PixelsPerInch>
14110
+ </o:OfficeDocumentSettings>
14111
+ </xml>
14112
+ </noscript>
14113
+ <![endif]-->
14114
+ </head>
14115
+ <body style="margin: 0; padding: 0; background-color: #f8f6f5; font-family: Georgia, 'Times New Roman', serif;">
14116
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f8f6f5;">
14117
+ <tr>
14118
+ <td align="center" style="padding: 40px 20px;">
14119
+ <table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; background-color: #ffffff; border-radius: 2px; box-shadow: 0 1px 3px rgba(103, 87, 74, 0.08);">
14120
+
14121
+ <!-- Header -->
14122
+ <tr>
14123
+ <td style="padding: 48px 48px 32px 48px; border-bottom: 1px solid #f0ebe6;">
14124
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
14125
+ <tr>
14126
+ <td>
14127
+ <h1 style="margin: 0; font-size: 24px; font-weight: 400; color: #67574A; letter-spacing: 2px; text-transform: uppercase; font-family: Georgia, 'Times New Roman', serif;">MetaEsthetics</h1>
14128
+ </td>
14129
+ </tr>
14130
+ </table>
14131
+ </td>
14132
+ </tr>
14133
+
14134
+ <!-- Welcome Banner -->
14135
+ <tr>
14136
+ <td style="padding: 0;">
14137
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #00BB38;">
14138
+ <tr>
14139
+ <td style="padding: 20px 48px;">
14140
+ <p style="margin: 0; font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: 1.5px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Welcome to MetaEsthetics</p>
14141
+ </td>
14142
+ </tr>
14143
+ </table>
14144
+ </td>
14145
+ </tr>
14146
+
14147
+ <!-- Main Content -->
14148
+ <tr>
14149
+ <td style="padding: 40px 48px;">
14150
+
14151
+ <!-- Greeting -->
14152
+ <p style="margin: 0 0 24px 0; font-size: 17px; color: #333333; line-height: 1.6; font-family: Georgia, 'Times New Roman', serif;">
14153
+ Dear {{adminName}},
14154
+ </p>
14155
+
14156
+ <p style="margin: 0 0 32px 0; font-size: 16px; color: #555555; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
14157
+ Thank you for registering <strong style="color: #67574A;">{{clinicGroupName}}</strong> with MetaEsthetics. Your account has been successfully created and you're now ready to start managing your aesthetic practice.
14158
+ </p>
14159
+
14160
+ <!-- Account Details Card -->
14161
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #faf9f7; border-left: 3px solid #00BB38;">
14162
+ <tr>
14163
+ <td style="padding: 24px;">
14164
+ <p style="margin: 0 0 16px 0; font-size: 12px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Account Details</p>
14165
+
14166
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
14167
+ <tr>
14168
+ <td style="padding-bottom: 12px;">
14169
+ <p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Clinic Group</p>
14170
+ <p style="margin: 0; font-size: 15px; color: #67574A; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicGroupName}}</p>
14171
+ </td>
14172
+ </tr>
14173
+ <tr>
14174
+ <td style="padding-bottom: 12px;">
14175
+ <p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Admin Email</p>
14176
+ <p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{adminEmail}}</p>
14177
+ </td>
14178
+ </tr>
14179
+ <tr>
14180
+ <td>
14181
+ <p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Registration Date</p>
14182
+ <p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{registrationDate}}</p>
14183
+ </td>
14184
+ </tr>
14185
+ </table>
14186
+ </td>
14187
+ </tr>
14188
+ </table>
14189
+
14190
+ <!-- Divider -->
14191
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
14192
+ <tr>
14193
+ <td style="height: 1px; background-color: #e8e4df;"></td>
14194
+ </tr>
14195
+ </table>
14196
+
14197
+ <!-- Getting Started Section -->
14198
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
14199
+ <tr>
14200
+ <td>
14201
+ <p style="margin: 0 0 20px 0; font-size: 14px; font-weight: 600; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Getting Started</p>
14202
+ </td>
14203
+ </tr>
14204
+ </table>
14205
+
14206
+ <!-- Step 1 -->
14207
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 16px;">
14208
+ <tr>
14209
+ <td style="padding: 16px 20px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
14210
+ <p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #a48a76; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Step 1</p>
14211
+ <p style="margin: 0 0 4px 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Complete Your Profile</p>
14212
+ <p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Add your clinic details, working hours, and upload photos to attract patients.</p>
14213
+ </td>
14214
+ </tr>
14215
+ </table>
14216
+
14217
+ <!-- Step 2 -->
14218
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 16px;">
14219
+ <tr>
14220
+ <td style="padding: 16px 20px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
14221
+ <p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #a48a76; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Step 2</p>
14222
+ <p style="margin: 0 0 4px 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Add Your Team</p>
14223
+ <p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Invite practitioners and staff members to join your clinic.</p>
14224
+ </td>
14225
+ </tr>
14226
+ </table>
14227
+
14228
+ <!-- Step 3 -->
14229
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 16px;">
14230
+ <tr>
14231
+ <td style="padding: 16px 20px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
14232
+ <p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #a48a76; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Step 3</p>
14233
+ <p style="margin: 0 0 4px 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Set Up Services</p>
14234
+ <p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Configure your procedures, pricing, and availability for bookings.</p>
14235
+ </td>
14236
+ </tr>
14237
+ </table>
14238
+
14239
+ <!-- Step 4 -->
14240
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
14241
+ <tr>
14242
+ <td style="padding: 16px 20px; background-color: #f0faf4; border-left: 3px solid #00BB38;">
14243
+ <p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #00BB38; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Step 4</p>
14244
+ <p style="margin: 0 0 4px 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Start Accepting Patients</p>
14245
+ <p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Begin managing appointments and growing your practice.</p>
14246
+ </td>
14247
+ </tr>
14248
+ </table>
14249
+
14250
+ <!-- CTA Button -->
14251
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
14252
+ <tr>
14253
+ <td align="center">
14254
+ <a href="{{dashboardUrl}}" style="display: inline-block; background-color: #67574A; color: #ffffff; text-decoration: none; padding: 14px 32px; border-radius: 4px; font-size: 14px; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; letter-spacing: 0.5px;">Go to Dashboard</a>
14255
+ </td>
14256
+ </tr>
14257
+ </table>
14258
+
14259
+ <!-- Divider -->
14260
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
14261
+ <tr>
14262
+ <td style="height: 1px; background-color: #e8e4df;"></td>
14263
+ </tr>
14264
+ </table>
14265
+
14266
+ <!-- Support Info -->
14267
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 24px;">
14268
+ <tr>
14269
+ <td style="padding: 20px 24px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
14270
+ <p style="margin: 0 0 8px 0; font-size: 13px; font-weight: 600; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Need Help?</p>
14271
+ <p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
14272
+ Our support team is here to help you get started. Contact us at <a href="mailto:{{supportEmail}}" style="color: #a48a76; text-decoration: none;">{{supportEmail}}</a>
14273
+ </p>
14274
+ </td>
14275
+ </tr>
14276
+ </table>
14277
+
14278
+ <!-- Thank You -->
14279
+ <p style="margin: 0; font-size: 14px; color: #868686; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
14280
+ Thank you for choosing MetaEsthetics. We look forward to supporting your practice.
14281
+ </p>
14282
+
14283
+ </td>
14284
+ </tr>
14285
+
14286
+ <!-- Footer -->
14287
+ <tr>
14288
+ <td style="padding: 32px 48px; background-color: #faf9f7; border-top: 1px solid #f0ebe6;">
14289
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
14290
+ <tr>
14291
+ <td>
14292
+ <p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 500; color: #67574A; font-family: Georgia, 'Times New Roman', serif;">MetaEsthetics</p>
14293
+ <p style="margin: 0 0 16px 0; font-size: 13px; color: #868686; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Premium Aesthetic Services Platform</p>
14294
+ <p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">This is an automated message from MetaEsthetics. Please do not reply directly to this email.</p>
14295
+ </td>
14296
+ </tr>
14297
+ </table>
14298
+ </td>
14299
+ </tr>
14300
+
14301
+ </table>
14302
+
14303
+ <!-- Copyright -->
14304
+ <table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px;">
14305
+ <tr>
14306
+ <td style="padding: 24px 48px; text-align: center;">
14307
+ <p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">&copy; {{currentYear}} MetaEsthetics. All rights reserved.</p>
14308
+ </td>
14309
+ </tr>
14310
+ </table>
14311
+
14312
+ </td>
14313
+ </tr>
14314
+ </table>
14315
+ </body>
14316
+ </html>
14317
+ `;
14318
+
14319
+ // src/admin/mailing/clinicWelcome/clinicWelcome.mailing.ts
14320
+ var ClinicWelcomeMailingService = class extends BaseMailingService {
14321
+ /**
14322
+ * Constructor for ClinicWelcomeMailingService
14323
+ * @param firestore - Firestore instance provided by the caller
14324
+ * @param mailgunClient - Mailgun client instance (mailgun.js v10+) provided by the caller
14325
+ */
14326
+ constructor(firestore19, mailgunClient) {
14327
+ super(firestore19, mailgunClient);
14328
+ this.DEFAULT_DASHBOARD_URL = "https://clinic.metaesthetics.net/dashboard";
14329
+ this.DEFAULT_SUPPORT_EMAIL = "support@metaesthetics.net";
14330
+ this.DEFAULT_SUBJECT = "Welcome to MetaEsthetics - Your Clinic Registration is Complete";
14331
+ this.DEFAULT_MAILGUN_DOMAIN = "mg.metaesthetics.net";
14332
+ }
14333
+ /**
14334
+ * Sends a clinic welcome email
14335
+ * @param data - The clinic welcome email data
14336
+ * @returns Promise resolved when email is sent
14337
+ */
14338
+ async sendWelcomeEmail(data) {
14339
+ var _a, _b, _c, _d, _e, _f, _g;
14340
+ try {
14341
+ Logger.info(
14342
+ "[ClinicWelcomeMailingService] Sending welcome email to",
14343
+ data.admin.email
14344
+ );
14345
+ const registrationDate = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
14346
+ weekday: "long",
14347
+ year: "numeric",
14348
+ month: "long",
14349
+ day: "numeric"
14350
+ });
14351
+ const dashboardUrl = ((_a = data.options) == null ? void 0 : _a.dashboardUrl) || this.DEFAULT_DASHBOARD_URL;
14352
+ const supportEmail = ((_b = data.options) == null ? void 0 : _b.supportEmail) || this.DEFAULT_SUPPORT_EMAIL;
14353
+ const subject = ((_c = data.options) == null ? void 0 : _c.customSubject) || this.DEFAULT_SUBJECT;
14354
+ const fromAddress = ((_d = data.options) == null ? void 0 : _d.fromAddress) || `MetaEsthetics <no-reply@${((_e = data.options) == null ? void 0 : _e.mailgunDomain) || this.DEFAULT_MAILGUN_DOMAIN}>`;
14355
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear().toString();
14356
+ const templateVariables = {
14357
+ adminName: data.admin.name,
14358
+ adminEmail: data.admin.email,
14359
+ clinicGroupName: data.clinicGroup.name,
14360
+ registrationDate,
14361
+ dashboardUrl,
14362
+ supportEmail,
14363
+ currentYear
14364
+ };
14365
+ Logger.info("[ClinicWelcomeMailingService] Template variables:", {
14366
+ adminName: templateVariables.adminName,
14367
+ adminEmail: templateVariables.adminEmail,
14368
+ clinicGroupName: templateVariables.clinicGroupName,
14369
+ dashboardUrl: templateVariables.dashboardUrl
14370
+ });
14371
+ const html = this.renderTemplate(clinicWelcomeTemplate, templateVariables);
14372
+ const mailgunSendData = {
14373
+ to: data.admin.email,
14374
+ from: fromAddress,
14375
+ subject,
14376
+ html
14377
+ };
14378
+ const domainToSendFrom = ((_f = data.options) == null ? void 0 : _f.mailgunDomain) || this.DEFAULT_MAILGUN_DOMAIN;
14379
+ Logger.info("[ClinicWelcomeMailingService] Sending email with data:", {
14380
+ domain: domainToSendFrom,
14381
+ to: mailgunSendData.to,
14382
+ from: mailgunSendData.from,
14383
+ subject: mailgunSendData.subject,
14384
+ hasHtml: !!mailgunSendData.html
14385
+ });
14386
+ const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
14387
+ await this.logEmailAttempt(
14388
+ {
14389
+ to: data.admin.email,
14390
+ subject,
14391
+ templateName: "clinic_welcome"
14392
+ },
14393
+ true
14394
+ );
14395
+ return result;
14396
+ } catch (error) {
14397
+ Logger.error(
14398
+ "[ClinicWelcomeMailingService] Error sending welcome email:",
14399
+ {
14400
+ errorMessage: error.message,
14401
+ errorDetails: error.details,
14402
+ errorStatus: error.status,
14403
+ stack: error.stack
14404
+ }
14405
+ );
14406
+ await this.logEmailAttempt(
14407
+ {
14408
+ to: data.admin.email,
14409
+ subject: ((_g = data.options) == null ? void 0 : _g.customSubject) || this.DEFAULT_SUBJECT,
14410
+ templateName: "clinic_welcome"
14411
+ },
14412
+ false,
14413
+ error
14414
+ );
14415
+ throw error;
14416
+ }
14417
+ }
14418
+ /**
14419
+ * Handles the clinic group creation event from Cloud Functions.
14420
+ * Fetches necessary data and sends the welcome email to the admin.
14421
+ * @param clinicGroupData - The clinic group data including id
14422
+ * @param mailgunConfig - Mailgun configuration (from, domain)
14423
+ * @returns Promise resolved when the email is sent
14424
+ */
14425
+ async handleClinicGroupCreationEvent(clinicGroupData, mailgunConfig) {
14426
+ try {
14427
+ Logger.info(
14428
+ "[ClinicWelcomeMailingService] Handling clinic group creation event for:",
14429
+ clinicGroupData.id
14430
+ );
14431
+ if (!clinicGroupData || !clinicGroupData.id) {
14432
+ throw new Error(
14433
+ `Invalid clinic group data: Missing required properties.`
14434
+ );
14435
+ }
14436
+ if (!clinicGroupData.contactPerson) {
14437
+ throw new Error(
14438
+ `Clinic group ${clinicGroupData.id} is missing contactPerson`
14439
+ );
14440
+ }
14441
+ if (!clinicGroupData.contactPerson.email) {
14442
+ throw new Error(
14443
+ `Clinic group ${clinicGroupData.id} is missing admin email`
14444
+ );
14445
+ }
14446
+ const adminName = `${clinicGroupData.contactPerson.firstName || ""} ${clinicGroupData.contactPerson.lastName || ""}`.trim() || "Clinic Admin";
14447
+ const adminEmail = clinicGroupData.contactPerson.email;
14448
+ Logger.info(
14449
+ `[ClinicWelcomeMailingService] Sending welcome email to admin: ${adminName} (${adminEmail})`
14450
+ );
14451
+ if (!mailgunConfig.fromAddress) {
14452
+ Logger.warn(
14453
+ "[ClinicWelcomeMailingService] No fromAddress provided, using default"
14454
+ );
14455
+ mailgunConfig.fromAddress = `MetaEsthetics <no-reply@${this.DEFAULT_MAILGUN_DOMAIN}>`;
14456
+ }
14457
+ const emailData = {
14458
+ admin: {
14459
+ name: adminName,
14460
+ email: adminEmail
14461
+ },
14462
+ clinicGroup: {
14463
+ id: clinicGroupData.id,
14464
+ name: clinicGroupData.name || "Your Clinic"
14465
+ },
14466
+ options: {
14467
+ fromAddress: mailgunConfig.fromAddress,
14468
+ mailgunDomain: mailgunConfig.domain,
14469
+ dashboardUrl: mailgunConfig.dashboardUrl,
14470
+ supportEmail: mailgunConfig.supportEmail
14471
+ }
14472
+ };
14473
+ Logger.info(
14474
+ "[ClinicWelcomeMailingService] Email data prepared, sending welcome email"
14475
+ );
14476
+ await this.sendWelcomeEmail(emailData);
14477
+ Logger.info(
14478
+ "[ClinicWelcomeMailingService] Welcome email sent successfully"
14479
+ );
14480
+ } catch (error) {
14481
+ Logger.error(
14482
+ "[ClinicWelcomeMailingService] Error handling clinic group creation event:",
14483
+ {
14484
+ errorMessage: error.message,
14485
+ errorDetails: error.details,
14486
+ errorStatus: error.status,
14487
+ stack: error.stack,
14488
+ clinicGroupId: clinicGroupData == null ? void 0 : clinicGroupData.id
14489
+ }
14490
+ );
14491
+ throw error;
14492
+ }
14493
+ }
14494
+ };
14495
+
14091
14496
  // src/admin/users/user-profile.admin.ts
14092
14497
  var admin18 = __toESM(require("firebase-admin"));
14093
14498
  var UserProfileAdminService = class {
@@ -14390,6 +14795,7 @@ TimestampUtils.enableServerMode();
14390
14795
  CLINIC_ANALYTICS_SUBCOLLECTION,
14391
14796
  CalendarAdminService,
14392
14797
  ClinicAggregationService,
14798
+ ClinicWelcomeMailingService,
14393
14799
  DASHBOARD_ANALYTICS_SUBCOLLECTION,
14394
14800
  DocumentManagerAdminService,
14395
14801
  ExistingPractitionerInviteMailingService,