@infuro/cms-core 1.0.63 → 1.0.64

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 (39) hide show
  1. package/dist/admin.cjs +183 -65
  2. package/dist/admin.js +183 -65
  3. package/dist/api.cjs +38 -38
  4. package/dist/api.d.cts +2 -0
  5. package/dist/api.d.ts +2 -0
  6. package/dist/api.js +6 -6
  7. package/dist/{chunk-KAOHOHCA.js → chunk-6YOQ7G5O.js} +92 -51
  8. package/dist/{chunk-DTUL3Q5L.js → chunk-DXERXWBR.js} +1 -1
  9. package/dist/{chunk-CJEOH6QC.cjs → chunk-FF45VZMM.cjs} +99 -73
  10. package/dist/{chunk-7L556RGL.cjs → chunk-GLD263KW.cjs} +3 -3
  11. package/dist/{chunk-77YWLP4X.js → chunk-K6C3ZSBZ.js} +56 -30
  12. package/dist/{chunk-EWXG4E74.cjs → chunk-M25DGZ5J.cjs} +111 -51
  13. package/dist/{chunk-BWOITUNI.js → chunk-OJAYCNE5.js} +103 -43
  14. package/dist/{chunk-MWEK7N3F.js → chunk-OPJEV44S.js} +2 -2
  15. package/dist/{chunk-RHYVNRYG.cjs → chunk-PX3BSCIG.cjs} +1 -1
  16. package/dist/{chunk-RXTUSF3R.js → chunk-TU23GJPJ.js} +2 -2
  17. package/dist/{chunk-JLDHK2QE.cjs → chunk-TZEMLHSP.cjs} +20 -14
  18. package/dist/{chunk-YVP4NQII.cjs → chunk-VM6OVUUM.cjs} +93 -52
  19. package/dist/{chunk-MXABMVF7.cjs → chunk-XFDIIVZB.cjs} +4 -4
  20. package/dist/{chunk-3VZAAQUV.js → chunk-YRCKEGL2.js} +20 -14
  21. package/dist/{email-queue-VTYL2KFA.cjs → email-queue-4OY45JIU.cjs} +7 -7
  22. package/dist/{email-queue-YPRSVG56.js → email-queue-HGXB2FIS.js} +3 -3
  23. package/dist/{email-service-ATCPJFWG.cjs → email-service-5O24BSFR.cjs} +7 -7
  24. package/dist/{email-service-DPKVQOKP.js → email-service-ADDF52PJ.js} +2 -2
  25. package/dist/{emit-order-notification-trigger-XVG2B5ZF.js → emit-order-notification-trigger-MFCBAE7L.js} +1 -1
  26. package/dist/{emit-order-notification-trigger-WI4HGMKH.cjs → emit-order-notification-trigger-ZRRGCQGB.cjs} +3 -3
  27. package/dist/{erp-order-invoice-3UGWLICU.js → erp-order-invoice-H6HCJ7YS.js} +2 -2
  28. package/dist/{erp-order-invoice-KJYJNWMG.cjs → erp-order-invoice-YUSPZ7CE.cjs} +6 -6
  29. package/dist/index.cjs +272 -258
  30. package/dist/index.d.cts +38 -19
  31. package/dist/index.d.ts +38 -19
  32. package/dist/index.js +40 -26
  33. package/dist/migrations/1783000000000-AddOrderPendingProcessingCompletedTriggers.ts +15 -39
  34. package/dist/migrations/1783300000000-SeedOrderNotificationTriggersAndTemplates.ts +155 -0
  35. package/dist/{order-completion-otp-handlers-WGM7HWG4.js → order-completion-otp-handlers-3W5I3LON.js} +4 -4
  36. package/dist/{order-completion-otp-handlers-IMMQGHDR.cjs → order-completion-otp-handlers-RF3DLNV7.cjs} +6 -6
  37. package/dist/{order-notification-dispatcher-JKFQJYGG.js → order-notification-dispatcher-ID2PDEXD.js} +5 -5
  38. package/dist/{order-notification-dispatcher-5TUFCDU7.cjs → order-notification-dispatcher-RNEQB3V7.cjs} +10 -10
  39. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
1
  import { normalizePhoneE164, generateNumericOtp, createOtpChallenge, queueSms, verifyAndConsumeOtpChallenge } from './chunk-OVTOP42W.js';
2
2
  import { JOB_RUNNER_QUEUE } from './chunk-GO7PPYNU.js';
3
3
  import { validateInventoryForConfirmedOrderLines, orderStatusHoldsStock, reconcileOrderInventoryBetweenSnapshots, orderInventorySnapshotFromRow, validateInventoryForOrderBecomingConfirmed } from './chunk-3K5AIEIZ.js';
4
- import { resolveChatEmailToolSettings, CHAT_EMAIL_LOG, detectChatLeadIntent, parseIntentRecipientEmails, sendChatLeadEmail, buildTranscriptForLeadEmail, buildChatbotSystemPromptWithEmailTool, validateFcmCredentials, sendFcmPushNotification, parseEmailRecipientsFromConfig, isWhatsAppPluginEnabled, WhatsAppService, emailPlugin, initWhatsappTriggerDispatcher } from './chunk-BWOITUNI.js';
4
+ import { resolveChatEmailToolSettings, CHAT_EMAIL_LOG, detectChatLeadIntent, parseIntentRecipientEmails, sendChatLeadEmail, buildTranscriptForLeadEmail, buildChatbotSystemPromptWithEmailTool, validateFcmCredentials, sendFcmPushNotification, parseEmailRecipientsFromConfig, isWhatsAppPluginEnabled, WhatsAppService, emailPlugin, initWhatsappTriggerDispatcher } from './chunk-OJAYCNE5.js';
5
5
  import { registerWhatsAppQueueProcessor } from './chunk-GWDI752Q.js';
6
6
  import { inviteStatusForActivation } from './chunk-JXF23MPG.js';
7
- import { queueEmail, queueVendorOnboardEmails, registerEmailQueueProcessor } from './chunk-RXTUSF3R.js';
8
- import { unwrapErpReadData, mapErpPayloadToFulfillment, extractChildOrderRefsFromSalePayload, mapErpPayloadToInvoiceNumber, streamOrderInvoicePdf } from './chunk-MWEK7N3F.js';
7
+ import { queueEmail, queueVendorOnboardEmails, registerEmailQueueProcessor } from './chunk-TU23GJPJ.js';
8
+ import { unwrapErpReadData, mapErpPayloadToFulfillment, extractChildOrderRefsFromSalePayload, mapErpPayloadToInvoiceNumber, streamOrderInvoicePdf } from './chunk-OPJEV44S.js';
9
9
  import { isErpIntegrationEnabled } from './chunk-JC6DLWTE.js';
10
- import { mergeEmailLayoutCompanyDetails } from './chunk-3VZAAQUV.js';
10
+ import { mergeEmailLayoutCompanyDetails } from './chunk-YRCKEGL2.js';
11
11
  import { getSmsTemplateDefault, SMS_MESSAGE_TEMPLATE_DEFAULTS } from './chunk-MQBT33IV.js';
12
12
  import { EVENT_ORDER_MESSAGE_TEMPLATE_DEFAULTS, EVENT_ORDER_TEMPLATE_KEY, EVENT_ORDER_TEMPLATE_VARIABLES } from './chunk-AYERBA7I.js';
13
13
  import { ensureCustomerRecord, linkUnclaimedContactToUser, ensureCustomerForUser, canManageRoles, sessionHasEntityAccess } from './chunk-NR44CK5E.js';
@@ -5229,7 +5229,7 @@ function createCrudHandler(dataSource, entityMap, options) {
5229
5229
  const orderIdForNotify = created.id;
5230
5230
  const finalCreatedStatus = String(created.status ?? createdStatus ?? "pending").toLowerCase();
5231
5231
  const initialPayStatus = String(persistBody.paymentStatus ?? body.paymentStatus ?? "unpaid").toLowerCase();
5232
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
5232
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
5233
5233
  if (finalCreatedStatus === "pending") {
5234
5234
  if (initialPayStatus === "failed") {
5235
5235
  fireOrderNotificationTrigger("payment_failed", orderIdForNotify, {
@@ -5885,6 +5885,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
5885
5885
  const repo = dataSource.getRepository(entity);
5886
5886
  const numericId = Number(id);
5887
5887
  let orderInvPrev = null;
5888
+ let existingOrderRow = null;
5888
5889
  if (resource === "blogs" && rawBody && typeof rawBody === "object" && entityMap.categories && entityMap.seos && entityMap.tags) {
5889
5890
  const existing = await repo.findOne({
5890
5891
  where: {
@@ -6021,6 +6022,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6021
6022
  status: 404
6022
6023
  });
6023
6024
  if (resource === "orders") {
6025
+ existingOrderRow = cur;
6024
6026
  orderInvPrev = orderInventorySnapshotFromRow(cur);
6025
6027
  }
6026
6028
  }
@@ -6052,16 +6054,13 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6052
6054
  if (Number.isFinite(aId) && aId > 0) {
6053
6055
  scalarUpdate.assignedUserId = aId;
6054
6056
  scalarUpdate.assignedAt = /* @__PURE__ */ new Date();
6055
- if (!scalarUpdate.status && (orderInvPrev?.status === "confirmed" || orderInvPrev?.status === "pending")) {
6056
- scalarUpdate.status = "processing";
6057
- }
6058
6057
  } else {
6059
6058
  scalarUpdate.assignedUserId = null;
6060
6059
  scalarUpdate.assignedAt = null;
6061
6060
  }
6062
6061
  }
6063
6062
  if (scalarUpdate.status === "processing") {
6064
- const effectiveAssignee = scalarUpdate.assignedUserId !== void 0 ? scalarUpdate.assignedUserId : orderInvPrev?.assignedUserId;
6063
+ const effectiveAssignee = scalarUpdate.assignedUserId !== void 0 ? scalarUpdate.assignedUserId : existingOrderRow?.assignedUserId ?? null;
6065
6064
  if (!effectiveAssignee) {
6066
6065
  return json({
6067
6066
  error: "Cannot start processing without assigning a teammate. Please assign a teammate first."
@@ -6308,12 +6307,26 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6308
6307
  }
6309
6308
  const statusUpdated = Boolean(scalarUpdate.status || rawBody.status);
6310
6309
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
6310
+ const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
6311
+ if (assigneeUpdated) {
6312
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
6313
+ fireOrderNotificationTrigger("order_assigned", updatedOrder.id, {
6314
+ dataSource,
6315
+ entityMap
6316
+ });
6317
+ fireOrderNotificationTrigger("order_assigned_assignee", updatedOrder.id, {
6318
+ dataSource,
6319
+ entityMap
6320
+ });
6321
+ }).catch(() => {
6322
+ });
6323
+ }
6311
6324
  if (statusUpdated || paymentUpdated) {
6312
6325
  const newStatus = scalarUpdate.status ? String(scalarUpdate.status).toLowerCase() : rawBody.status ? String(rawBody.status).toLowerCase() : String(updatedOrder.status || "pending").toLowerCase();
6313
6326
  const payments = Array.isArray(updatedOrder.payments) ? updatedOrder.payments : [];
6314
6327
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
6315
6328
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
6316
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
6329
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
6317
6330
  if (newStatus === "pending") {
6318
6331
  if (curPayStatus === "failed") {
6319
6332
  fireOrderNotificationTrigger("payment_failed", updatedOrder.id, {
@@ -6868,16 +6881,13 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6868
6881
  if (Number.isFinite(aId) && aId > 0) {
6869
6882
  updatePayload.assignedUserId = aId;
6870
6883
  updatePayload.assignedAt = /* @__PURE__ */ new Date();
6871
- if (!updatePayload.status && (orderInvPrev.status === "confirmed" || orderInvPrev.status === "pending")) {
6872
- updatePayload.status = "processing";
6873
- }
6874
6884
  } else {
6875
6885
  updatePayload.assignedUserId = null;
6876
6886
  updatePayload.assignedAt = null;
6877
6887
  }
6878
6888
  }
6879
6889
  if (updatePayload.status === "processing") {
6880
- const effectiveAssignee = updatePayload.assignedUserId !== void 0 ? updatePayload.assignedUserId : orderInvPrev?.assignedUserId;
6890
+ const effectiveAssignee = updatePayload.assignedUserId !== void 0 ? updatePayload.assignedUserId : existingOrderRow?.assignedUserId ?? null;
6881
6891
  if (!effectiveAssignee) {
6882
6892
  return json({
6883
6893
  error: "Cannot start processing without assigning a teammate. Please assign a teammate first."
@@ -6970,7 +6980,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6970
6980
  });
6971
6981
  }
6972
6982
  if (ordStatus === "pending" || ordStatus === "confirmed") {
6973
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
6983
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
6974
6984
  fireOrderNotificationTrigger("order_placed", pOrder, {
6975
6985
  dataSource,
6976
6986
  entityMap
@@ -6984,7 +6994,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6984
6994
  }
6985
6995
  }
6986
6996
  } else if (newPayStatus === "failed") {
6987
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
6997
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
6988
6998
  fireOrderNotificationTrigger("payment_failed", pOrder, {
6989
6999
  dataSource,
6990
7000
  entityMap
@@ -6992,7 +7002,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6992
7002
  }).catch(() => {
6993
7003
  });
6994
7004
  } else if (newPayStatus === "refunded") {
6995
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
7005
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
6996
7006
  fireOrderNotificationTrigger("payment_refund_initiated", pOrder, {
6997
7007
  dataSource,
6998
7008
  entityMap
@@ -7117,12 +7127,26 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7117
7127
  const ord = updated;
7118
7128
  const statusUpdated = Boolean(updatePayload.status);
7119
7129
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
7130
+ const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
7131
+ if (assigneeUpdated) {
7132
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
7133
+ fireOrderNotificationTrigger("order_assigned", ord.id, {
7134
+ dataSource,
7135
+ entityMap
7136
+ });
7137
+ fireOrderNotificationTrigger("order_assigned_assignee", ord.id, {
7138
+ dataSource,
7139
+ entityMap
7140
+ });
7141
+ }).catch(() => {
7142
+ });
7143
+ }
7120
7144
  if (statusUpdated || paymentUpdated) {
7121
7145
  const newStatus = updatePayload.status ? String(updatePayload.status).toLowerCase() : String(ord.status || "pending").toLowerCase();
7122
7146
  const payments = Array.isArray(ord.payments) ? ord.payments : [];
7123
7147
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
7124
7148
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
7125
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
7149
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
7126
7150
  if (newStatus === "pending") {
7127
7151
  if (curPayStatus === "failed") {
7128
7152
  fireOrderNotificationTrigger("payment_failed", ord.id, {
@@ -11664,7 +11688,8 @@ function createChatHandlers(config) {
11664
11688
  });
11665
11689
  const emailSettings = await loadSettingsGroupMap(dataSource, entityMap, "email");
11666
11690
  const brandingSettings = await loadSettingsGroupMap(dataSource, entityMap, "branding");
11667
- const companyDetails = mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings);
11691
+ const storeSettings = await loadSettingsGroupMap(dataSource, entityMap, "store");
11692
+ const companyDetails = mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings, storeSettings);
11668
11693
  const leadResult = await sendChatLeadEmail(cms, emailSettings, brandingSettings, {
11669
11694
  contactName: String(c.name ?? "").trim() || "Visitor",
11670
11695
  contactEmail: String(c.email ?? "").trim(),
@@ -13994,13 +14019,14 @@ __name(getVendorEmails, "getVendorEmails");
13994
14019
  async function sendVendorOnboardEmails(input, deps) {
13995
14020
  let ownerEmailSent = false;
13996
14021
  try {
13997
- const [branding, emailSettings, superAdminEmails, vendorEmailSet] = await Promise.all([
14022
+ const [branding, emailSettings, storeSettings, superAdminEmails, vendorEmailSet] = await Promise.all([
13998
14023
  getSettingsGroup(deps, "branding"),
13999
14024
  getSettingsGroup(deps, "email"),
14025
+ getSettingsGroup(deps, "store"),
14000
14026
  getSuperAdminEmails(deps),
14001
14027
  getVendorEmails(deps)
14002
14028
  ]);
14003
- const companyDetails = mergeEmailLayoutCompanyDetails(branding, emailSettings);
14029
+ const companyDetails = mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
14004
14030
  const configuredNotify = parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
14005
14031
  const ownerEmail = input.ownerEmail?.trim() || "";
14006
14032
  const ownerEmailLower = ownerEmail.toLowerCase();
@@ -29005,7 +29031,7 @@ function createCmsApiHandler(config) {
29005
29031
  companyDetails
29006
29032
  };
29007
29033
  if (queue) {
29008
- const { queueEmail: queueEmail2 } = await import('./email-queue-YPRSVG56.js');
29034
+ const { queueEmail: queueEmail2 } = await import('./email-queue-HGXB2FIS.js');
29009
29035
  await queueEmail2(cms, {
29010
29036
  to: opts.to,
29011
29037
  templateName: "passwordReset",
@@ -30305,7 +30331,7 @@ function createCmsApiHandler(config) {
30305
30331
  const pe = await requireEntityPermissionEffective(req, "orders", "read");
30306
30332
  if (pe) return pe;
30307
30333
  const cms = await getCms();
30308
- const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-3UGWLICU.js');
30334
+ const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-H6HCJ7YS.js');
30309
30335
  const oid = Number(path2[1]);
30310
30336
  if (!Number.isFinite(oid)) return config.json({
30311
30337
  error: "Invalid id"
@@ -30687,7 +30713,7 @@ function createCmsApiHandler(config) {
30687
30713
  status: 400
30688
30714
  });
30689
30715
  }
30690
- const { resendOrderNotification } = await import('./order-notification-dispatcher-JKFQJYGG.js');
30716
+ const { resendOrderNotification } = await import('./order-notification-dispatcher-ID2PDEXD.js');
30691
30717
  const result = await resendOrderNotification(triggerKey, orderId, {
30692
30718
  dataSource,
30693
30719
  entityMap,
@@ -30786,7 +30812,7 @@ function createCmsApiHandler(config) {
30786
30812
  status: "cancelled"
30787
30813
  });
30788
30814
  const fireOrderCancelledNotification = /* @__PURE__ */ __name((refundAmount) => {
30789
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
30815
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
30790
30816
  fireOrderNotificationTrigger("order_cancelled", orderId, {
30791
30817
  dataSource,
30792
30818
  entityMap
@@ -31031,7 +31057,7 @@ function createCmsApiHandler(config) {
31031
31057
  }, {
31032
31058
  status: 400
31033
31059
  });
31034
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-WGM7HWG4.js');
31060
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-3W5I3LON.js');
31035
31061
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31036
31062
  return handlers.getChannels(req, orderId);
31037
31063
  }
@@ -31046,7 +31072,7 @@ function createCmsApiHandler(config) {
31046
31072
  }, {
31047
31073
  status: 400
31048
31074
  });
31049
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-WGM7HWG4.js');
31075
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-3W5I3LON.js');
31050
31076
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31051
31077
  return handlers.sendOtp(req, orderId);
31052
31078
  }
@@ -31061,7 +31087,7 @@ function createCmsApiHandler(config) {
31061
31087
  }, {
31062
31088
  status: 400
31063
31089
  });
31064
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-WGM7HWG4.js');
31090
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-3W5I3LON.js');
31065
31091
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31066
31092
  return handlers.verifyOtp(req, orderId);
31067
31093
  }
@@ -31693,7 +31719,7 @@ function createStorefrontApiHandler(config) {
31693
31719
  const otpPepper = config.otpPepper;
31694
31720
  const defaultPhoneCc = config.defaultPhoneCountryCode;
31695
31721
  function fireOrderPlacedNotification(orderId, isPaid) {
31696
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
31722
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
31697
31723
  fireOrderNotificationTrigger("order_placed", orderId, {
31698
31724
  dataSource,
31699
31725
  entityMap
@@ -34630,7 +34656,7 @@ function createStorefrontApiHandler(config) {
34630
34656
  } catch {
34631
34657
  }
34632
34658
  try {
34633
- void import('./emit-order-notification-trigger-XVG2B5ZF.js').then(({ fireOrderNotificationTrigger }) => {
34659
+ void import('./emit-order-notification-trigger-MFCBAE7L.js').then(({ fireOrderNotificationTrigger }) => {
34634
34660
  fireOrderNotificationTrigger("order_cancelled", orderId, {
34635
34661
  dataSource,
34636
34662
  entityMap
@@ -2,9 +2,9 @@
2
2
 
3
3
  var chunkH3IVLIPR_cjs = require('./chunk-H3IVLIPR.cjs');
4
4
  var chunkUEE4PTTB_cjs = require('./chunk-UEE4PTTB.cjs');
5
- var chunkYVP4NQII_cjs = require('./chunk-YVP4NQII.cjs');
6
- var chunkMXABMVF7_cjs = require('./chunk-MXABMVF7.cjs');
7
- var chunkJLDHK2QE_cjs = require('./chunk-JLDHK2QE.cjs');
5
+ var chunkVM6OVUUM_cjs = require('./chunk-VM6OVUUM.cjs');
6
+ var chunkXFDIIVZB_cjs = require('./chunk-XFDIIVZB.cjs');
7
+ var chunkTZEMLHSP_cjs = require('./chunk-TZEMLHSP.cjs');
8
8
  var chunkOOTLNH63_cjs = require('./chunk-OOTLNH63.cjs');
9
9
  var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
10
10
  var crypto = require('crypto');
@@ -223,7 +223,10 @@ async function loadOrderNotificationContexts(orderId, deps) {
223
223
  deleted: false
224
224
  },
225
225
  relations: [
226
- "contact"
226
+ "contact",
227
+ "assignedUser",
228
+ "shippingAddress",
229
+ "billingAddress"
227
230
  ]
228
231
  });
229
232
  if (!order) return null;
@@ -278,7 +281,7 @@ async function loadOrderNotificationContexts(orderId, deps) {
278
281
  }
279
282
  }
280
283
  const effectiveEvent = eventsEnabled ? event : void 0;
281
- const variables = effectiveEvent ? buildEventOrderTemplateVariables({
284
+ const baseVariables = effectiveEvent ? buildEventOrderTemplateVariables({
282
285
  event: effectiveEvent,
283
286
  order: {
284
287
  orderNumber: o.orderNumber,
@@ -310,13 +313,42 @@ async function loadOrderNotificationContexts(orderId, deps) {
310
313
  orderLines,
311
314
  siteUrl
312
315
  });
316
+ const assignedUser = o.assignedUser ?? null;
317
+ const assigneeName = assignedUser?.name?.trim() || "";
318
+ const assigneePhone = assignedUser?.phone?.trim() || "";
319
+ const assigneeEmail = assignedUser?.email?.trim() || "";
320
+ const timeSlot = String(meta.timeSlot || meta.slot || meta.serviceSlot || "").trim();
321
+ const rawServiceDate = meta.bookingDate || meta.serviceDate || meta.orderDate || o.createdAt;
322
+ const serviceDate = rawServiceDate ? formatScheduleDate(rawServiceDate) : "";
323
+ const addr = o.shippingAddress || o.billingAddress;
324
+ const customerAddress = addr ? [
325
+ addr.line1,
326
+ addr.line2,
327
+ addr.city,
328
+ addr.state,
329
+ addr.postalCode,
330
+ addr.country
331
+ ].map((p) => String(p ?? "").trim()).filter(Boolean).join(", ") : "";
332
+ const taskDescription = productNames || (orderLines.length > 0 ? orderLines.map((l) => `${l.quantity}x ${l.name}`).join(", ") : "Order service");
333
+ const variables = {
334
+ ...baseVariables,
335
+ assigneeName,
336
+ assigneePhone,
337
+ assigneeEmail,
338
+ timeSlot,
339
+ serviceDate,
340
+ customerAddress,
341
+ taskDescription
342
+ };
313
343
  return {
314
344
  order: {
315
345
  id: o.id,
316
346
  orderNumber: String(o.orderNumber ?? ""),
317
347
  total: o.total,
318
348
  currency,
319
- qrToken: o.qrToken
349
+ qrToken: o.qrToken,
350
+ assignedUserId: o.assignedUserId ?? null,
351
+ assignedUser
320
352
  },
321
353
  contact,
322
354
  orderLines,
@@ -326,6 +358,16 @@ async function loadOrderNotificationContexts(orderId, deps) {
326
358
  };
327
359
  }
328
360
  chunkUSNT2KNT_cjs.__name(loadOrderNotificationContexts, "loadOrderNotificationContexts");
361
+ function formatScheduleDate(val) {
362
+ if (!val || typeof val !== "string" && !(val instanceof Date)) return "";
363
+ const str = String(val).trim();
364
+ if (!str) return "";
365
+ const d = new Date(str.includes("T") ? str : `${str}T00:00:00`);
366
+ return isNaN(d.getTime()) ? str : d.toLocaleDateString(void 0, {
367
+ dateStyle: "medium"
368
+ });
369
+ }
370
+ chunkUSNT2KNT_cjs.__name(formatScheduleDate, "formatScheduleDate");
329
371
 
330
372
  // src/plugins/whatsapp/whatsapp-service.ts
331
373
  function norm(v) {
@@ -1010,14 +1052,14 @@ async function sendChatLeadEmail(cms, emailSettings, brandingSettings, input) {
1010
1052
  recipients,
1011
1053
  source: input.recipients?.length ? "intent_email_to" : "crm_or_smtp_fallback"
1012
1054
  });
1013
- const companyDetails = chunkJLDHK2QE_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings);
1055
+ const companyDetails = chunkTZEMLHSP_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings);
1014
1056
  const ctx = {
1015
1057
  ...input,
1016
1058
  companyDetails: input.companyDetails ?? companyDetails
1017
1059
  };
1018
1060
  let anySent = false;
1019
1061
  for (const to of recipients) {
1020
- await chunkMXABMVF7_cjs.queueEmail(cms, {
1062
+ await chunkXFDIIVZB_cjs.queueEmail(cms, {
1021
1063
  to,
1022
1064
  templateName: "chatLead",
1023
1065
  ctx
@@ -1092,7 +1134,7 @@ function emailPlugin(config) {
1092
1134
  context.logger.warn("Email plugin skipped: AWS SES requires AWS_SES_REGION or AWS_REGION");
1093
1135
  return void 0;
1094
1136
  }
1095
- if (type === "AWS" && merged.region && merged.user && merged.password && !chunkYVP4NQII_cjs.sesRegionSupportsSmtp(merged.region)) {
1137
+ if (type === "AWS" && merged.region && merged.user && merged.password && !chunkVM6OVUUM_cjs.sesRegionSupportsSmtp(merged.region)) {
1096
1138
  context.logger.warn(`Email plugin: region ${merged.region} has no SES SMTP endpoint (ENOTFOUND). Set AWS_SES_REGION=ap-south-1 and create SMTP credentials in that SES region.`);
1097
1139
  }
1098
1140
  if (type === "AWS" && !(merged.user && merged.password || merged.accessKeyId && merged.secretAccessKey)) {
@@ -1107,13 +1149,13 @@ function emailPlugin(config) {
1107
1149
  context.logger.warn("Email plugin skipped: SMTP_TYPE=SMTP requires SMTP_HOST (or use SMTP_TYPE=AWS with AWS_REGION and SES SMTP credentials)");
1108
1150
  return void 0;
1109
1151
  }
1110
- const resolvedHost = type === "AWS" && merged.region ? merged.host || chunkYVP4NQII_cjs.sesSmtpHost(merged.region) : merged.host;
1152
+ const resolvedHost = type === "AWS" && merged.region ? merged.host || chunkVM6OVUUM_cjs.sesSmtpHost(merged.region) : merged.host;
1111
1153
  context.logger.info("Email plugin initialized", {
1112
1154
  type,
1113
1155
  host: resolvedHost,
1114
1156
  region: merged.region
1115
1157
  });
1116
- return new chunkYVP4NQII_cjs.EmailService(merged);
1158
+ return new chunkVM6OVUUM_cjs.EmailService(merged);
1117
1159
  }
1118
1160
  };
1119
1161
  }
@@ -1276,60 +1318,68 @@ chunkUSNT2KNT_cjs.__name(validateFcmCredentials, "validateFcmCredentials");
1276
1318
  var ORDER_NOTIFICATION_DEFAULTS = {
1277
1319
  email: {
1278
1320
  pending: {
1279
- subject: "Your Order #{{orderNumber}} is Pending",
1280
- body: "<p>Thank you for your order! It is currently pending.</p>"
1321
+ subject: "Your order {{orderNumber}} is Pending",
1322
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} is currently pending.\n\nOrder Details:\n{{orderDetails}}\n\nWe will update you as soon as your order status changes.\n\nThank you!"
1281
1323
  },
1282
1324
  order_pending: {
1283
- subject: "Your Order #{{orderNumber}} is Pending",
1284
- body: "<p>Thank you for your order! It is currently pending.</p>"
1325
+ subject: "Your order {{orderNumber}} is Pending",
1326
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} is currently pending.\n\nOrder Details:\n{{orderDetails}}\n\nWe will update you as soon as your order status changes.\n\nThank you!"
1285
1327
  },
1286
1328
  confirmed: {
1287
- subject: "Your Order #{{orderNumber}} is Confirmed",
1288
- body: "<p>Your order has been confirmed!</p>"
1329
+ subject: "Your order {{orderNumber}} is confirmed",
1330
+ body: "Hi {{customerName}},\n\nThank you for your order! Your order {{orderNumber}} for {{total}} {{currency}} has been confirmed.\n\nOrder Details:\n{{orderDetails}}\n\nYour Tax Invoice PDF is attached to this email for your records.\n\nThank you!"
1289
1331
  },
1290
1332
  order_confirmed: {
1291
- subject: "Your Order #{{orderNumber}} is Confirmed",
1292
- body: "<p>Your order has been confirmed!</p>"
1333
+ subject: "Your order {{orderNumber}} is confirmed",
1334
+ body: "Hi {{customerName}},\n\nThank you for your order! Your order {{orderNumber}} for {{total}} {{currency}} has been confirmed.\n\nOrder Details:\n{{orderDetails}}\n\nYour Tax Invoice PDF is attached to this email for your records.\n\nThank you!"
1293
1335
  },
1294
1336
  order_placed: {
1295
- subject: "Your Order #{{orderNumber}} is Placed",
1296
- body: "<p>Thank you for your order! Your order #{{orderNumber}} has been placed.</p>"
1337
+ subject: "Your order {{orderNumber}} is confirmed",
1338
+ body: "Hi {{customerName}},\n\nThank you for your order! Your order {{orderNumber}} for {{total}} {{currency}} has been confirmed.\n\nOrder Details:\n{{orderDetails}}\n\nYour Tax Invoice PDF is attached to this email for your records.\n\nThank you!"
1297
1339
  },
1298
1340
  processing: {
1299
- subject: "Your Order #{{orderNumber}} is Processing",
1300
- body: "<p>Your order is now being processed by our team.</p>"
1341
+ subject: "Your order {{orderNumber}} is now Processing",
1342
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} is currently being processed.\n\nOrder Details:\n{{orderDetails}}\n\nWe will notify you once it is completed.\n\nThank you!"
1301
1343
  },
1302
1344
  order_processing: {
1303
- subject: "Your Order #{{orderNumber}} is Processing",
1304
- body: "<p>Your order is now being processed by our team.</p>"
1345
+ subject: "Your order {{orderNumber}} is now Processing",
1346
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} is currently being processed.\n\nOrder Details:\n{{orderDetails}}\n\nWe will notify you once it is completed.\n\nThank you!"
1305
1347
  },
1306
1348
  completed: {
1307
- subject: "Your Order #{{orderNumber}} is Completed",
1308
- body: "<p>Your order has been completed. Thank you!</p>"
1349
+ subject: "Your order {{orderNumber}} is Completed",
1350
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} has been completed.\n\nOrder Details:\n{{orderDetails}}\n\nThank you for choosing us!"
1309
1351
  },
1310
1352
  order_completed: {
1311
- subject: "Your Order #{{orderNumber}} is Completed",
1312
- body: "<p>Your order has been completed. Thank you!</p>"
1353
+ subject: "Your order {{orderNumber}} is Completed",
1354
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} has been completed.\n\nOrder Details:\n{{orderDetails}}\n\nThank you for choosing us!"
1313
1355
  },
1314
1356
  cancelled: {
1315
- subject: "Your Order #{{orderNumber}} is Cancelled",
1316
- body: "<p>Your order has been cancelled.</p>"
1357
+ subject: "Your order {{orderNumber}} has been cancelled",
1358
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} has been cancelled.\n\nIf a refund is due, you will receive {{refundAmount}} {{currency}} back to your original payment method.\n\nIf you have any questions, please contact us.\n\nThank you!"
1317
1359
  },
1318
1360
  order_cancelled: {
1319
- subject: "Your Order #{{orderNumber}} is Cancelled",
1320
- body: "<p>Your order has been cancelled.</p>"
1361
+ subject: "Your order {{orderNumber}} has been cancelled",
1362
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} has been cancelled.\n\nIf a refund is due, you will receive {{refundAmount}} {{currency}} back to your original payment method.\n\nIf you have any questions, please contact us.\n\nThank you!"
1321
1363
  },
1322
1364
  payment_success: {
1323
- subject: "Payment Received for Order #{{orderNumber}}",
1324
- body: "<p>Payment of {{currency}} {{total}} has been successfully received for order #{{orderNumber}}.</p>"
1365
+ subject: "Payment Successful for Order {{orderNumber}}",
1366
+ body: "Hi {{customerName}},\n\nWe have received your payment for order {{orderNumber}} of {{total}} {{currency}}.\n\nOrder Details:\n{{orderDetails}}\n\nThank you!"
1325
1367
  },
1326
1368
  payment_failed: {
1327
- subject: "Payment Failed for Order #{{orderNumber}}",
1328
- body: "<p>Payment for order #{{orderNumber}} could not be completed.</p>"
1369
+ subject: "Payment Failed for Order {{orderNumber}}",
1370
+ body: "Hi {{customerName}},\n\nYour payment for order {{orderNumber}} of {{total}} {{currency}} could not be completed or remains unpaid.\n\nIf you were charged, please contact us with your order number {{orderNumber}}.\n\nThank you!"
1329
1371
  },
1330
1372
  payment_refund_initiated: {
1331
- subject: "Refund Initiated for Order #{{orderNumber}}",
1332
- body: "<p>A refund of {{currency}} {{refundAmount}} has been initiated for order #{{orderNumber}}.</p>"
1373
+ subject: "Refund Initiated for Order {{orderNumber}}",
1374
+ body: "Hi {{customerName}},\n\nYour order {{orderNumber}} has been cancelled and a refund of {{refundAmount}} {{currency}} has been initiated.\n\nThe amount will be credited back to your original payment method.\n\nThank you!"
1375
+ },
1376
+ order_assigned: {
1377
+ subject: "Your service expert has been assigned for order {{orderNumber}}",
1378
+ body: "Hi {{customerName}},\n\nA service expert has been assigned to your order {{orderNumber}}.\n\nAssignee Details:\n\u2022 Name: {{assigneeName}}\n\u2022 Phone: {{assigneePhone}}\n\nYour expert will reach you by your scheduled time slot:\n\u2022 Date: {{serviceDate}}\n\u2022 Slot: {{timeSlot}}\n\nOrder Details:\n{{orderDetails}}\n\nThank you!"
1379
+ },
1380
+ order_assigned_assignee: {
1381
+ subject: "New task assigned: Order {{orderNumber}}",
1382
+ body: "Hi {{assigneeName}},\n\nA new task has been assigned to you for order {{orderNumber}}.\n\nTask Details:\n{{taskDescription}}\n\nCustomer Details:\n\u2022 Name: {{customerName}}\n\u2022 Phone: {{customerPhone}}\n\u2022 Address: {{customerAddress}}\n\nSchedule:\n\u2022 Date: {{serviceDate}}\n\u2022 Slot: {{timeSlot}}\n\nPlease arrive promptly within the scheduled time slot."
1333
1383
  }
1334
1384
  },
1335
1385
  sms: {
@@ -1338,6 +1388,8 @@ var ORDER_NOTIFICATION_DEFAULTS = {
1338
1388
  confirmed: "Your Order #{{orderNumber}} is confirmed. Total: {{total}}.",
1339
1389
  order_confirmed: "Your Order #{{orderNumber}} is confirmed. Total: {{total}}.",
1340
1390
  order_placed: "Your Order #{{orderNumber}} is placed. Total: {{total}}.",
1391
+ order_assigned: "Hi {{customerName}}, your service expert {{assigneeName}} ({{assigneePhone}}) has been assigned for order {{orderNumber}}. Arrival slot: {{timeSlot}}.",
1392
+ order_assigned_assignee: "Hi {{assigneeName}}, new task assigned: Order {{orderNumber}}. Customer: {{customerName}}, Phone: {{customerPhone}}, Address: {{customerAddress}}, Slot: {{timeSlot}}.",
1341
1393
  processing: "Your Order #{{orderNumber}} is now processing.",
1342
1394
  order_processing: "Your Order #{{orderNumber}} is now processing.",
1343
1395
  completed: "Your Order #{{orderNumber}} has been completed. Thank you!",
@@ -1354,6 +1406,8 @@ var ORDER_NOTIFICATION_DEFAULTS = {
1354
1406
  confirmed: "Hi {{customerName}}, your Order #{{orderNumber}} is confirmed.",
1355
1407
  order_confirmed: "Hi {{customerName}}, your Order #{{orderNumber}} is confirmed.",
1356
1408
  order_placed: "Hi {{customerName}}, your Order #{{orderNumber}} is placed.",
1409
+ order_assigned: "Hi {{customerName}}, expert {{assigneeName}} ({{assigneePhone}}) has been assigned to your order #{{orderNumber}}. Scheduled slot: {{timeSlot}} on {{serviceDate}}.",
1410
+ order_assigned_assignee: "Hi {{assigneeName}}, you have been assigned to order #{{orderNumber}}. Customer: {{customerName}} ({{customerPhone}}), Address: {{customerAddress}}, Slot: {{timeSlot}} on {{serviceDate}}.",
1357
1411
  processing: "Hi {{customerName}}, your Order #{{orderNumber}} is now being processed.",
1358
1412
  order_processing: "Hi {{customerName}}, your Order #{{orderNumber}} is now being processed.",
1359
1413
  completed: "Hi {{customerName}}, your Order #{{orderNumber}} is completed.",
@@ -1784,7 +1838,7 @@ async function sendEmailForTrigger(triggerKey, orderId, audienceType, variables,
1784
1838
  getSettingsGroup(dataSource, entityMap, "email"),
1785
1839
  getSettingsGroup(dataSource, entityMap, "store")
1786
1840
  ]);
1787
- const companyDetails = chunkJLDHK2QE_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
1841
+ const companyDetails = chunkTZEMLHSP_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
1788
1842
  const templateContent = (template.body ?? "") + (template.subject ?? "");
1789
1843
  const shouldAttachInvoice = /\{\{\s*(invoiceAttachment|invoicePdf|invoice|attachInvoice)\s*\}\}/i.test(templateContent);
1790
1844
  const cleanVariables = {
@@ -1798,12 +1852,12 @@ async function sendEmailForTrigger(triggerKey, orderId, audienceType, variables,
1798
1852
  const subject = chunkOOTLNH63_cjs.applyTemplateVars(template.subject ?? "Order update", cleanVariables);
1799
1853
  const rawBody = chunkOOTLNH63_cjs.applyTemplateVars(template.body, cleanVariables);
1800
1854
  const bodyHtml = formatBodyForEmailHtml(rawBody);
1801
- const html = chunkYVP4NQII_cjs.renderLayout({
1855
+ const html = chunkVM6OVUUM_cjs.renderLayout({
1802
1856
  bodyHtml,
1803
1857
  companyDetails
1804
1858
  });
1805
1859
  const cms = await getCms();
1806
- await chunkMXABMVF7_cjs.queueEmail(cms, {
1860
+ await chunkXFDIIVZB_cjs.queueEmail(cms, {
1807
1861
  to: contactEmail,
1808
1862
  subject,
1809
1863
  html,
@@ -1897,10 +1951,15 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
1897
1951
  isAudienceEmailEnabled(dataSource, entityMap, "vendor"),
1898
1952
  isAudienceEmailEnabled(dataSource, entityMap, "admin")
1899
1953
  ]);
1900
- if (customerEnabled && contactEmail) {
1954
+ if (triggerKey === "order_assigned_assignee") {
1955
+ const assigneeEmail = context?.order?.assignedUser?.email?.trim();
1956
+ if (assigneeEmail) {
1957
+ await sendEmailForTrigger(triggerKey, payload.orderId, "customers", variables, assigneeEmail, dataSource, entityMap, getCms);
1958
+ }
1959
+ } else if (customerEnabled && contactEmail) {
1901
1960
  await sendEmailForTrigger(triggerKey, payload.orderId, "customers", variables, contactEmail, dataSource, entityMap, getCms);
1902
1961
  }
1903
- if (vendorEnabled) {
1962
+ if (vendorEnabled && triggerKey !== "order_assigned_assignee") {
1904
1963
  const multiVendorSettings = await getSettingsGroup(dataSource, entityMap, "multi_vendor");
1905
1964
  if (multiVendorSettings.enabled !== "false" && multiVendorSettings.enabled !== "0") {
1906
1965
  const vendorEmails = await getOrderVendorEmails(payload.orderId, payload.vendorId, dataSource, entityMap);
@@ -1909,7 +1968,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
1909
1968
  }
1910
1969
  }
1911
1970
  }
1912
- if (adminEnabled) {
1971
+ if (adminEnabled && triggerKey !== "order_assigned_assignee") {
1913
1972
  const adminEmails = await getAdminRecipientEmails(dataSource, entityMap);
1914
1973
  for (const aEmail of adminEmails) {
1915
1974
  await sendEmailForTrigger(triggerKey, payload.orderId, "admin", variables, aEmail, dataSource, entityMap, getCms);
@@ -1924,22 +1983,23 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
1924
1983
  isAudiencePushEnabled(dataSource, entityMap, "vendor"),
1925
1984
  isAudiencePushEnabled(dataSource, entityMap, "admin")
1926
1985
  ]);
1927
- const targetCustomerId = context?.order?.customerContactId || context?.order?.contactId || context?.order?.userId || context?.order?.id;
1986
+ const targetCustomerId = triggerKey === "order_assigned_assignee" ? context?.order?.assignedUser?.id : context?.order?.customerContactId || context?.order?.contactId || context?.order?.userId || context?.order?.id;
1928
1987
  if (pushCustomerEnabled && targetCustomerId) {
1929
1988
  await sendPushNotificationForTrigger(triggerKey, payload.orderId, "customers", String(targetCustomerId), variables, dataSource, entityMap);
1930
1989
  }
1931
- if (pushVendorEnabled && payload.vendorId) {
1990
+ if (pushVendorEnabled && payload.vendorId && triggerKey !== "order_assigned_assignee") {
1932
1991
  await sendPushNotificationForTrigger(triggerKey, payload.orderId, "vendors", String(payload.vendorId), variables, dataSource, entityMap);
1933
1992
  }
1934
- if (pushAdminEnabled) {
1993
+ if (pushAdminEnabled && triggerKey !== "order_assigned_assignee") {
1935
1994
  await sendPushNotificationForTrigger(triggerKey, payload.orderId, "admin", "admin", variables, dataSource, entityMap);
1936
1995
  }
1937
1996
  }
1938
1997
  if (whatsappChannelEnabled) {
1939
- if (contactPhone) {
1940
- await sendWhatsAppForTrigger(triggerKey, payload.orderId, contactPhone, variables, dataSource, entityMap, getCms);
1998
+ const targetPhone = triggerKey === "order_assigned_assignee" ? context?.order?.assignedUser?.phone?.trim() : contactPhone;
1999
+ if (targetPhone) {
2000
+ await sendWhatsAppForTrigger(triggerKey, payload.orderId, targetPhone, variables, dataSource, entityMap, getCms);
1941
2001
  } else {
1942
- console.warn("[order-notifications] skip WhatsApp: no customer phone", {
2002
+ console.warn("[order-notifications] skip WhatsApp: no recipient phone", {
1943
2003
  triggerKey,
1944
2004
  orderId: payload.orderId
1945
2005
  });