@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
@@ -3,13 +3,13 @@
3
3
  var chunkWFMVD567_cjs = require('./chunk-WFMVD567.cjs');
4
4
  var chunkXQ3QUHWR_cjs = require('./chunk-XQ3QUHWR.cjs');
5
5
  var chunkHY3AXLOI_cjs = require('./chunk-HY3AXLOI.cjs');
6
- var chunkEWXG4E74_cjs = require('./chunk-EWXG4E74.cjs');
6
+ var chunkM25DGZ5J_cjs = require('./chunk-M25DGZ5J.cjs');
7
7
  var chunkH3IVLIPR_cjs = require('./chunk-H3IVLIPR.cjs');
8
8
  var chunk7NMT3GBR_cjs = require('./chunk-7NMT3GBR.cjs');
9
- var chunkMXABMVF7_cjs = require('./chunk-MXABMVF7.cjs');
10
- var chunk7L556RGL_cjs = require('./chunk-7L556RGL.cjs');
9
+ var chunkXFDIIVZB_cjs = require('./chunk-XFDIIVZB.cjs');
10
+ var chunkGLD263KW_cjs = require('./chunk-GLD263KW.cjs');
11
11
  var chunkUPLVMVRX_cjs = require('./chunk-UPLVMVRX.cjs');
12
- var chunkJLDHK2QE_cjs = require('./chunk-JLDHK2QE.cjs');
12
+ var chunkTZEMLHSP_cjs = require('./chunk-TZEMLHSP.cjs');
13
13
  var chunk3DZRIZOD_cjs = require('./chunk-3DZRIZOD.cjs');
14
14
  var chunkTJ2MIQUT_cjs = require('./chunk-TJ2MIQUT.cjs');
15
15
  var chunk4U6DATGZ_cjs = require('./chunk-4U6DATGZ.cjs');
@@ -5239,7 +5239,7 @@ function createCrudHandler(dataSource, entityMap, options) {
5239
5239
  const orderIdForNotify = created.id;
5240
5240
  const finalCreatedStatus = String(created.status ?? createdStatus ?? "pending").toLowerCase();
5241
5241
  const initialPayStatus = String(persistBody.paymentStatus ?? body.paymentStatus ?? "unpaid").toLowerCase();
5242
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
5242
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
5243
5243
  if (finalCreatedStatus === "pending") {
5244
5244
  if (initialPayStatus === "failed") {
5245
5245
  fireOrderNotificationTrigger("payment_failed", orderIdForNotify, {
@@ -5895,6 +5895,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
5895
5895
  const repo = dataSource.getRepository(entity);
5896
5896
  const numericId = Number(id);
5897
5897
  let orderInvPrev = null;
5898
+ let existingOrderRow = null;
5898
5899
  if (resource === "blogs" && rawBody && typeof rawBody === "object" && entityMap.categories && entityMap.seos && entityMap.tags) {
5899
5900
  const existing = await repo.findOne({
5900
5901
  where: {
@@ -6031,6 +6032,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6031
6032
  status: 404
6032
6033
  });
6033
6034
  if (resource === "orders") {
6035
+ existingOrderRow = cur;
6034
6036
  orderInvPrev = chunkHY3AXLOI_cjs.orderInventorySnapshotFromRow(cur);
6035
6037
  }
6036
6038
  }
@@ -6062,16 +6064,13 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6062
6064
  if (Number.isFinite(aId) && aId > 0) {
6063
6065
  scalarUpdate.assignedUserId = aId;
6064
6066
  scalarUpdate.assignedAt = /* @__PURE__ */ new Date();
6065
- if (!scalarUpdate.status && (orderInvPrev?.status === "confirmed" || orderInvPrev?.status === "pending")) {
6066
- scalarUpdate.status = "processing";
6067
- }
6068
6067
  } else {
6069
6068
  scalarUpdate.assignedUserId = null;
6070
6069
  scalarUpdate.assignedAt = null;
6071
6070
  }
6072
6071
  }
6073
6072
  if (scalarUpdate.status === "processing") {
6074
- const effectiveAssignee = scalarUpdate.assignedUserId !== void 0 ? scalarUpdate.assignedUserId : orderInvPrev?.assignedUserId;
6073
+ const effectiveAssignee = scalarUpdate.assignedUserId !== void 0 ? scalarUpdate.assignedUserId : existingOrderRow?.assignedUserId ?? null;
6075
6074
  if (!effectiveAssignee) {
6076
6075
  return json({
6077
6076
  error: "Cannot start processing without assigning a teammate. Please assign a teammate first."
@@ -6318,12 +6317,26 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6318
6317
  }
6319
6318
  const statusUpdated = Boolean(scalarUpdate.status || rawBody.status);
6320
6319
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
6320
+ const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
6321
+ if (assigneeUpdated) {
6322
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
6323
+ fireOrderNotificationTrigger("order_assigned", updatedOrder.id, {
6324
+ dataSource,
6325
+ entityMap
6326
+ });
6327
+ fireOrderNotificationTrigger("order_assigned_assignee", updatedOrder.id, {
6328
+ dataSource,
6329
+ entityMap
6330
+ });
6331
+ }).catch(() => {
6332
+ });
6333
+ }
6321
6334
  if (statusUpdated || paymentUpdated) {
6322
6335
  const newStatus = scalarUpdate.status ? String(scalarUpdate.status).toLowerCase() : rawBody.status ? String(rawBody.status).toLowerCase() : String(updatedOrder.status || "pending").toLowerCase();
6323
6336
  const payments = Array.isArray(updatedOrder.payments) ? updatedOrder.payments : [];
6324
6337
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
6325
6338
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
6326
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
6339
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
6327
6340
  if (newStatus === "pending") {
6328
6341
  if (curPayStatus === "failed") {
6329
6342
  fireOrderNotificationTrigger("payment_failed", updatedOrder.id, {
@@ -6878,16 +6891,13 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6878
6891
  if (Number.isFinite(aId) && aId > 0) {
6879
6892
  updatePayload.assignedUserId = aId;
6880
6893
  updatePayload.assignedAt = /* @__PURE__ */ new Date();
6881
- if (!updatePayload.status && (orderInvPrev.status === "confirmed" || orderInvPrev.status === "pending")) {
6882
- updatePayload.status = "processing";
6883
- }
6884
6894
  } else {
6885
6895
  updatePayload.assignedUserId = null;
6886
6896
  updatePayload.assignedAt = null;
6887
6897
  }
6888
6898
  }
6889
6899
  if (updatePayload.status === "processing") {
6890
- const effectiveAssignee = updatePayload.assignedUserId !== void 0 ? updatePayload.assignedUserId : orderInvPrev?.assignedUserId;
6900
+ const effectiveAssignee = updatePayload.assignedUserId !== void 0 ? updatePayload.assignedUserId : existingOrderRow?.assignedUserId ?? null;
6891
6901
  if (!effectiveAssignee) {
6892
6902
  return json({
6893
6903
  error: "Cannot start processing without assigning a teammate. Please assign a teammate first."
@@ -6980,7 +6990,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6980
6990
  });
6981
6991
  }
6982
6992
  if (ordStatus === "pending" || ordStatus === "confirmed") {
6983
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
6993
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
6984
6994
  fireOrderNotificationTrigger("order_placed", pOrder, {
6985
6995
  dataSource,
6986
6996
  entityMap
@@ -6994,7 +7004,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6994
7004
  }
6995
7005
  }
6996
7006
  } else if (newPayStatus === "failed") {
6997
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
7007
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
6998
7008
  fireOrderNotificationTrigger("payment_failed", pOrder, {
6999
7009
  dataSource,
7000
7010
  entityMap
@@ -7002,7 +7012,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7002
7012
  }).catch(() => {
7003
7013
  });
7004
7014
  } else if (newPayStatus === "refunded") {
7005
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
7015
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
7006
7016
  fireOrderNotificationTrigger("payment_refund_initiated", pOrder, {
7007
7017
  dataSource,
7008
7018
  entityMap
@@ -7127,12 +7137,26 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7127
7137
  const ord = updated;
7128
7138
  const statusUpdated = Boolean(updatePayload.status);
7129
7139
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
7140
+ const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
7141
+ if (assigneeUpdated) {
7142
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
7143
+ fireOrderNotificationTrigger("order_assigned", ord.id, {
7144
+ dataSource,
7145
+ entityMap
7146
+ });
7147
+ fireOrderNotificationTrigger("order_assigned_assignee", ord.id, {
7148
+ dataSource,
7149
+ entityMap
7150
+ });
7151
+ }).catch(() => {
7152
+ });
7153
+ }
7130
7154
  if (statusUpdated || paymentUpdated) {
7131
7155
  const newStatus = updatePayload.status ? String(updatePayload.status).toLowerCase() : String(ord.status || "pending").toLowerCase();
7132
7156
  const payments = Array.isArray(ord.payments) ? ord.payments : [];
7133
7157
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
7134
7158
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
7135
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
7159
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
7136
7160
  if (newStatus === "pending") {
7137
7161
  if (curPayStatus === "failed") {
7138
7162
  fireOrderNotificationTrigger("payment_failed", ord.id, {
@@ -10251,7 +10275,7 @@ function createFormSubmissionHandler(config) {
10251
10275
  label: f.label && String(f.label).trim() || `Field ${f.id}`,
10252
10276
  value: formatSubmissionFieldValue(data[String(f.id)])
10253
10277
  }));
10254
- await chunkMXABMVF7_cjs.queueEmail(cms, {
10278
+ await chunkXFDIIVZB_cjs.queueEmail(cms, {
10255
10279
  to,
10256
10280
  templateName: "formSubmission",
10257
10281
  ctx: {
@@ -10305,7 +10329,7 @@ function createUsersApiHandlers(config) {
10305
10329
  try {
10306
10330
  const cms = await getCms();
10307
10331
  const companyDetails = getCompanyDetails ? await getCompanyDetails() : {};
10308
- await chunkMXABMVF7_cjs.queueEmail(cms, {
10332
+ await chunkXFDIIVZB_cjs.queueEmail(cms, {
10309
10333
  to: toEmail,
10310
10334
  templateName: "invite",
10311
10335
  ctx: {
@@ -11578,7 +11602,7 @@ function createChatHandlers(config) {
11578
11602
  const notifyEmailAgent = await findLlmAgentByScope(dataSource, entityMap, LLM_AGENT_SCOPE_EMAIL_INTENT_CHATBOT, {
11579
11603
  enabledOnly: false
11580
11604
  });
11581
- const emailTool = chunkEWXG4E74_cjs.resolveChatEmailToolSettings(llmSettings, {
11605
+ const emailTool = chunkM25DGZ5J_cjs.resolveChatEmailToolSettings(llmSettings, {
11582
11606
  chatbotValidationRules: agentRow?.validationRules ?? null,
11583
11607
  notifyAgent: notifyEmailAgent ? {
11584
11608
  systemInstruction: notifyEmailAgent.systemInstruction,
@@ -11588,7 +11612,7 @@ function createChatHandlers(config) {
11588
11612
  const emailPlugin2 = cms.getPlugin("email");
11589
11613
  const convLeadSent = conv.leadEmailSentAt;
11590
11614
  const chatAgentFn = llm.chatAgent?.bind(llm);
11591
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline check", {
11615
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline check", {
11592
11616
  conversationId,
11593
11617
  enabled: emailTool.enabled,
11594
11618
  intentCount: emailTool.intents.length,
@@ -11602,27 +11626,27 @@ function createChatHandlers(config) {
11602
11626
  mergedPromptIncludesNotify: Boolean(notifyEmailAgent?.systemInstruction?.trim())
11603
11627
  });
11604
11628
  if (!emailTool.enabled) {
11605
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11629
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11606
11630
  conversationId,
11607
11631
  reason: "email_tool_disabled"
11608
11632
  });
11609
11633
  } else if (emailTool.intents.length === 0) {
11610
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11634
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11611
11635
  conversationId,
11612
11636
  reason: "no_intents_configured"
11613
11637
  });
11614
11638
  } else if (!emailPlugin2) {
11615
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11639
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11616
11640
  conversationId,
11617
11641
  reason: "email_plugin_missing"
11618
11642
  });
11619
11643
  } else if (!chatAgentFn) {
11620
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11644
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11621
11645
  conversationId,
11622
11646
  reason: "llm_chat_agent_unavailable"
11623
11647
  });
11624
11648
  } else if (convLeadSent) {
11625
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11649
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11626
11650
  conversationId,
11627
11651
  reason: "lead_email_already_sent",
11628
11652
  leadEmailSentAt: convLeadSent
@@ -11635,7 +11659,7 @@ function createChatHandlers(config) {
11635
11659
  }
11636
11660
  });
11637
11661
  if (!contactRow) {
11638
- console.warn(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11662
+ console.warn(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11639
11663
  conversationId,
11640
11664
  reason: "contact_not_found",
11641
11665
  contactId
@@ -11643,7 +11667,7 @@ function createChatHandlers(config) {
11643
11667
  } else {
11644
11668
  const c = contactRow;
11645
11669
  try {
11646
- const intent = await chunkEWXG4E74_cjs.detectChatLeadIntent({
11670
+ const intent = await chunkM25DGZ5J_cjs.detectChatLeadIntent({
11647
11671
  chatAgent: chatAgentFn
11648
11672
  }, {
11649
11673
  settings: emailTool,
@@ -11657,15 +11681,15 @@ function createChatHandlers(config) {
11657
11681
  model: agentRow?.model?.trim() || notifyEmailAgent?.model?.trim() || void 0
11658
11682
  });
11659
11683
  if (!intent.intent || !intent.emailTo) {
11660
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "no email sent", {
11684
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "no email sent", {
11661
11685
  conversationId,
11662
11686
  reason: intent.intent ? "missing_email_to" : "no_intent_match",
11663
11687
  intentLabel: intent.intentLabel,
11664
11688
  classifierReason: intent.reason
11665
11689
  });
11666
11690
  } else {
11667
- const intentRecipients = chunkEWXG4E74_cjs.parseIntentRecipientEmails(intent.emailTo);
11668
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "intent matched \u2014 sending", {
11691
+ const intentRecipients = chunkM25DGZ5J_cjs.parseIntentRecipientEmails(intent.emailTo);
11692
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "intent matched \u2014 sending", {
11669
11693
  conversationId,
11670
11694
  intent: intent.intent,
11671
11695
  emailTo: intent.emailTo,
@@ -11674,8 +11698,9 @@ function createChatHandlers(config) {
11674
11698
  });
11675
11699
  const emailSettings = await loadSettingsGroupMap(dataSource, entityMap, "email");
11676
11700
  const brandingSettings = await loadSettingsGroupMap(dataSource, entityMap, "branding");
11677
- const companyDetails = chunkJLDHK2QE_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings);
11678
- const leadResult = await chunkEWXG4E74_cjs.sendChatLeadEmail(cms, emailSettings, brandingSettings, {
11701
+ const storeSettings = await loadSettingsGroupMap(dataSource, entityMap, "store");
11702
+ const companyDetails = chunkTZEMLHSP_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings, storeSettings);
11703
+ const leadResult = await chunkM25DGZ5J_cjs.sendChatLeadEmail(cms, emailSettings, brandingSettings, {
11679
11704
  contactName: String(c.name ?? "").trim() || "Visitor",
11680
11705
  contactEmail: String(c.email ?? "").trim(),
11681
11706
  contactPhone: c.phone ?? null,
@@ -11683,7 +11708,7 @@ function createChatHandlers(config) {
11683
11708
  latestMessage: message,
11684
11709
  intentCode: intent.intent,
11685
11710
  intentReason: intent.intentLabel || intent.reason,
11686
- transcript: chunkEWXG4E74_cjs.buildTranscriptForLeadEmail(history, message),
11711
+ transcript: chunkM25DGZ5J_cjs.buildTranscriptForLeadEmail(history, message),
11687
11712
  companyDetails,
11688
11713
  recipients: intentRecipients.length > 0 ? intentRecipients : void 0
11689
11714
  });
@@ -11691,13 +11716,13 @@ function createChatHandlers(config) {
11691
11716
  await convRepo().update(conversationId, {
11692
11717
  leadEmailSentAt: /* @__PURE__ */ new Date()
11693
11718
  });
11694
- console.info(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "lead email recorded", {
11719
+ console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "lead email recorded", {
11695
11720
  conversationId,
11696
11721
  sent: true,
11697
11722
  recipients: leadResult.recipients
11698
11723
  });
11699
11724
  } else {
11700
- console.warn(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "lead email not sent", {
11725
+ console.warn(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "lead email not sent", {
11701
11726
  conversationId,
11702
11727
  sent: false,
11703
11728
  error: leadResult.error ?? "unknown",
@@ -11706,7 +11731,7 @@ function createChatHandlers(config) {
11706
11731
  }
11707
11732
  }
11708
11733
  } catch (intentErr) {
11709
- console.warn(chunkEWXG4E74_cjs.CHAT_EMAIL_LOG, "pipeline error", {
11734
+ console.warn(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline error", {
11710
11735
  conversationId,
11711
11736
  error: intentErr instanceof Error ? intentErr.message : String(intentErr)
11712
11737
  });
@@ -11723,7 +11748,7 @@ function createChatHandlers(config) {
11723
11748
  });
11724
11749
  if (agentRow && llm.chatAgent) {
11725
11750
  const fromAgent = llmAgentToChatAgentOptions(agentRow);
11726
- const systemPrompt = chunkEWXG4E74_cjs.buildChatbotSystemPromptWithEmailTool(fromAgent.systemPrompt, parsedValidation.guardrailsForPrompt, emailTool);
11751
+ const systemPrompt = chunkM25DGZ5J_cjs.buildChatbotSystemPromptWithEmailTool(fromAgent.systemPrompt, parsedValidation.guardrailsForPrompt, emailTool);
11727
11752
  const res = await llm.chatAgent({
11728
11753
  ...fromAgent,
11729
11754
  systemPrompt: systemPrompt || void 0,
@@ -11744,7 +11769,7 @@ ${contextParts.join("\n\n")}` : "";
11744
11769
  agentRow.systemInstruction?.trim(),
11745
11770
  ragSystem
11746
11771
  ].filter(Boolean).join("\n\n");
11747
- systemContent = chunkEWXG4E74_cjs.buildChatbotSystemPromptWithEmailTool(mergedBase || defaultSystem, parsedValidation.guardrailsForPrompt, emailTool) || defaultSystem;
11772
+ systemContent = chunkM25DGZ5J_cjs.buildChatbotSystemPromptWithEmailTool(mergedBase || defaultSystem, parsedValidation.guardrailsForPrompt, emailTool) || defaultSystem;
11748
11773
  } else {
11749
11774
  systemContent = ragSystem || defaultSystem;
11750
11775
  }
@@ -12999,7 +13024,7 @@ function createDeviceTokensHandlers(config) {
12999
13024
  const title = body.title?.trim() || "Test Push Notification";
13000
13025
  const msgBody = body.body?.trim() || "Firebase Push Notification setup is working!";
13001
13026
  if (!token || token === "validate" || token === "validate_only") {
13002
- const valRes = await chunkEWXG4E74_cjs.validateFcmCredentials(dataSource, entityMap);
13027
+ const valRes = await chunkM25DGZ5J_cjs.validateFcmCredentials(dataSource, entityMap);
13003
13028
  if (!valRes.success) {
13004
13029
  return json({
13005
13030
  success: false,
@@ -13016,7 +13041,7 @@ function createDeviceTokensHandlers(config) {
13016
13041
  clientEmail: valRes.clientEmail
13017
13042
  });
13018
13043
  }
13019
- const res = await chunkEWXG4E74_cjs.sendFcmPushNotification(dataSource, entityMap, {
13044
+ const res = await chunkM25DGZ5J_cjs.sendFcmPushNotification(dataSource, entityMap, {
13020
13045
  token,
13021
13046
  title,
13022
13047
  body: msgBody,
@@ -14004,14 +14029,15 @@ chunkUSNT2KNT_cjs.__name(getVendorEmails, "getVendorEmails");
14004
14029
  async function sendVendorOnboardEmails(input, deps) {
14005
14030
  let ownerEmailSent = false;
14006
14031
  try {
14007
- const [branding, emailSettings, superAdminEmails, vendorEmailSet] = await Promise.all([
14032
+ const [branding, emailSettings, storeSettings, superAdminEmails, vendorEmailSet] = await Promise.all([
14008
14033
  getSettingsGroup(deps, "branding"),
14009
14034
  getSettingsGroup(deps, "email"),
14035
+ getSettingsGroup(deps, "store"),
14010
14036
  getSuperAdminEmails(deps),
14011
14037
  getVendorEmails(deps)
14012
14038
  ]);
14013
- const companyDetails = chunkJLDHK2QE_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings);
14014
- const configuredNotify = chunkEWXG4E74_cjs.parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
14039
+ const companyDetails = chunkTZEMLHSP_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
14040
+ const configuredNotify = chunkM25DGZ5J_cjs.parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
14015
14041
  const ownerEmail = input.ownerEmail?.trim() || "";
14016
14042
  const ownerEmailLower = ownerEmail.toLowerCase();
14017
14043
  const sendToOwner = input.sendToOwner !== false;
@@ -14021,7 +14047,7 @@ async function sendVendorOnboardEmails(input, deps) {
14021
14047
  ];
14022
14048
  const notifyEmails = Array.from(new Set(combined.map((e) => e.trim().toLowerCase()).filter((e) => e && e !== ownerEmailLower && !vendorEmailSet.has(e))));
14023
14049
  const cms = await deps.getCms();
14024
- await chunkMXABMVF7_cjs.queueVendorOnboardEmails(cms, {
14050
+ await chunkXFDIIVZB_cjs.queueVendorOnboardEmails(cms, {
14025
14051
  vendorName: input.vendorName,
14026
14052
  vendorSlug: input.vendorSlug,
14027
14053
  ownerName: input.ownerName,
@@ -28637,11 +28663,11 @@ function whatsappPlugin(config = {}) {
28637
28663
  db = await settingsLoader?.() ?? {};
28638
28664
  } catch {
28639
28665
  }
28640
- if (!chunkEWXG4E74_cjs.isWhatsAppPluginEnabled(db)) {
28666
+ if (!chunkM25DGZ5J_cjs.isWhatsAppPluginEnabled(db)) {
28641
28667
  context.logger.warn("WhatsApp plugin skipped: disabled in Plugins \u2192 WhatsApp");
28642
28668
  return null;
28643
28669
  }
28644
- const svc = new chunkEWXG4E74_cjs.WhatsAppService(env, staticRest, settingsLoader, getMessageTemplateRow);
28670
+ const svc = new chunkM25DGZ5J_cjs.WhatsAppService(env, staticRest, settingsLoader, getMessageTemplateRow);
28645
28671
  return {
28646
28672
  send: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((opts) => svc.send(opts), "send")
28647
28673
  };
@@ -28714,7 +28740,7 @@ function createMessageTemplateRowLoader(dataSource, entityMap) {
28714
28740
  }
28715
28741
  chunkUSNT2KNT_cjs.__name(createMessageTemplateRowLoader, "createMessageTemplateRowLoader");
28716
28742
  function registerMessagingQueueProcessors(cms, entityMap) {
28717
- chunkMXABMVF7_cjs.registerEmailQueueProcessor(cms, {
28743
+ chunkXFDIIVZB_cjs.registerEmailQueueProcessor(cms, {
28718
28744
  getDataSource: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(async () => cms.dataSource, "getDataSource"),
28719
28745
  entityMap
28720
28746
  });
@@ -28747,7 +28773,7 @@ async function ensureMessagingPluginsOnCms(base, options) {
28747
28773
  }
28748
28774
  if (!cms.getPlugin("email")) {
28749
28775
  try {
28750
- const instance = await chunkEWXG4E74_cjs.emailPlugin({
28776
+ const instance = await chunkM25DGZ5J_cjs.emailPlugin({
28751
28777
  type: "SMTP",
28752
28778
  from: config.SMTP_FROM ?? "no-reply@localhost",
28753
28779
  to: config.SMTP_TO ?? ""
@@ -28788,7 +28814,7 @@ function messagingPlugins(options) {
28788
28814
  const config = options.config ?? (typeof process !== "undefined" ? process.env : {});
28789
28815
  return [
28790
28816
  queuePlugin(),
28791
- chunkEWXG4E74_cjs.emailPlugin({
28817
+ chunkM25DGZ5J_cjs.emailPlugin({
28792
28818
  type: "SMTP",
28793
28819
  from: config.SMTP_FROM ?? "no-reply@localhost",
28794
28820
  to: config.SMTP_TO ?? ""
@@ -28922,7 +28948,7 @@ function createCmsApiHandler(config) {
28922
28948
  } : void 0;
28923
28949
  const entityMap = withLlmKnowledgeEntityFallbacks(rawEntityMap);
28924
28950
  if (getCms) {
28925
- chunkEWXG4E74_cjs.initWhatsappTriggerDispatcher({
28951
+ chunkM25DGZ5J_cjs.initWhatsappTriggerDispatcher({
28926
28952
  dataSource,
28927
28953
  entityMap,
28928
28954
  getCms
@@ -29015,7 +29041,7 @@ function createCmsApiHandler(config) {
29015
29041
  companyDetails
29016
29042
  };
29017
29043
  if (queue) {
29018
- const { queueEmail: queueEmail2 } = await import('./email-queue-VTYL2KFA.cjs');
29044
+ const { queueEmail: queueEmail2 } = await import('./email-queue-4OY45JIU.cjs');
29019
29045
  await queueEmail2(cms, {
29020
29046
  to: opts.to,
29021
29047
  templateName: "passwordReset",
@@ -30315,7 +30341,7 @@ function createCmsApiHandler(config) {
30315
30341
  const pe = await requireEntityPermissionEffective(req, "orders", "read");
30316
30342
  if (pe) return pe;
30317
30343
  const cms = await getCms();
30318
- const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-KJYJNWMG.cjs');
30344
+ const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-YUSPZ7CE.cjs');
30319
30345
  const oid = Number(path2[1]);
30320
30346
  if (!Number.isFinite(oid)) return config.json({
30321
30347
  error: "Invalid id"
@@ -30697,7 +30723,7 @@ function createCmsApiHandler(config) {
30697
30723
  status: 400
30698
30724
  });
30699
30725
  }
30700
- const { resendOrderNotification } = await import('./order-notification-dispatcher-5TUFCDU7.cjs');
30726
+ const { resendOrderNotification } = await import('./order-notification-dispatcher-RNEQB3V7.cjs');
30701
30727
  const result = await resendOrderNotification(triggerKey, orderId, {
30702
30728
  dataSource,
30703
30729
  entityMap,
@@ -30796,7 +30822,7 @@ function createCmsApiHandler(config) {
30796
30822
  status: "cancelled"
30797
30823
  });
30798
30824
  const fireOrderCancelledNotification = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((refundAmount) => {
30799
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
30825
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
30800
30826
  fireOrderNotificationTrigger("order_cancelled", orderId, {
30801
30827
  dataSource,
30802
30828
  entityMap
@@ -31041,7 +31067,7 @@ function createCmsApiHandler(config) {
31041
31067
  }, {
31042
31068
  status: 400
31043
31069
  });
31044
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-IMMQGHDR.cjs');
31070
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-RF3DLNV7.cjs');
31045
31071
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31046
31072
  return handlers.getChannels(req, orderId);
31047
31073
  }
@@ -31056,7 +31082,7 @@ function createCmsApiHandler(config) {
31056
31082
  }, {
31057
31083
  status: 400
31058
31084
  });
31059
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-IMMQGHDR.cjs');
31085
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-RF3DLNV7.cjs');
31060
31086
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31061
31087
  return handlers.sendOtp(req, orderId);
31062
31088
  }
@@ -31071,7 +31097,7 @@ function createCmsApiHandler(config) {
31071
31097
  }, {
31072
31098
  status: 400
31073
31099
  });
31074
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-IMMQGHDR.cjs');
31100
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-RF3DLNV7.cjs');
31075
31101
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31076
31102
  return handlers.verifyOtp(req, orderId);
31077
31103
  }
@@ -31519,12 +31545,12 @@ async function refreshOrderFromErp(cms, dataSource, entityMap, submission, order
31519
31545
  const r1 = await submission.postErpReadAction("get-order-status", {
31520
31546
  platformOrderId: refId
31521
31547
  });
31522
- const d1 = r1.ok ? chunk7L556RGL_cjs.unwrapErpReadData(r1.json) : null;
31548
+ const d1 = r1.ok ? chunkGLD263KW_cjs.unwrapErpReadData(r1.json) : null;
31523
31549
  if (d1) {
31524
31550
  const mapped = mapErpSaleStatusToOrderStatus(typeof d1.status === "string" ? d1.status : typeof d1.orderStatus === "string" ? d1.orderStatus : typeof d1.state === "string" ? d1.state : void 0);
31525
31551
  if (mapped) newStatus = mapped;
31526
- fulfillment = chunk7L556RGL_cjs.mapErpPayloadToFulfillment(d1);
31527
- const refs = chunk7L556RGL_cjs.extractChildOrderRefsFromSalePayload(d1);
31552
+ fulfillment = chunkGLD263KW_cjs.mapErpPayloadToFulfillment(d1);
31553
+ const refs = chunkGLD263KW_cjs.extractChildOrderRefsFromSalePayload(d1);
31528
31554
  if (refs.length) {
31529
31555
  await ensureChildOrdersFromRefs(orderRepo, order, refs, order.contactId, String(order.currency || "INR"));
31530
31556
  }
@@ -31532,16 +31558,16 @@ async function refreshOrderFromErp(cms, dataSource, entityMap, submission, order
31532
31558
  const r2 = await submission.postErpReadAction("get-fulfillment-status", {
31533
31559
  platformOrderId: refId
31534
31560
  });
31535
- const d2 = r2.ok ? chunk7L556RGL_cjs.unwrapErpReadData(r2.json) : null;
31561
+ const d2 = r2.ok ? chunkGLD263KW_cjs.unwrapErpReadData(r2.json) : null;
31536
31562
  if (d2) {
31537
- fulfillment = deepMergeFulfillment(fulfillment, chunk7L556RGL_cjs.mapErpPayloadToFulfillment(d2));
31563
+ fulfillment = deepMergeFulfillment(fulfillment, chunkGLD263KW_cjs.mapErpPayloadToFulfillment(d2));
31538
31564
  }
31539
31565
  const r3 = await submission.postErpReadAction("get-invoice", {
31540
31566
  platformOrderId: refId
31541
31567
  });
31542
- const d3 = r3.ok ? chunk7L556RGL_cjs.unwrapErpReadData(r3.json) : null;
31568
+ const d3 = r3.ok ? chunkGLD263KW_cjs.unwrapErpReadData(r3.json) : null;
31543
31569
  if (d3) {
31544
- invoiceNumber = chunk7L556RGL_cjs.mapErpPayloadToInvoiceNumber(d3);
31570
+ invoiceNumber = chunkGLD263KW_cjs.mapErpPayloadToInvoiceNumber(d3);
31545
31571
  invoiceId = pickInvoiceId(d3);
31546
31572
  }
31547
31573
  const oid = order.id;
@@ -31577,10 +31603,10 @@ async function refreshOrderFromErp(cms, dataSource, entityMap, submission, order
31577
31603
  const r = await submission.postErpReadAction("get-return-status", {
31578
31604
  platformReturnId
31579
31605
  });
31580
- const d = r.ok ? chunk7L556RGL_cjs.unwrapErpReadData(r.json) : null;
31606
+ const d = r.ok ? chunkGLD263KW_cjs.unwrapErpReadData(r.json) : null;
31581
31607
  if (!d) return;
31582
31608
  const mapped = mapErpSaleStatusToOrderStatus(typeof d.status === "string" ? d.status : typeof d.returnStatus === "string" ? d.returnStatus : void 0);
31583
- const fulfillment = chunk7L556RGL_cjs.mapErpPayloadToFulfillment(d);
31609
+ const fulfillment = chunkGLD263KW_cjs.mapErpPayloadToFulfillment(d);
31584
31610
  const patch = {};
31585
31611
  if (fulfillment !== void 0) patch.fulfillment = fulfillment;
31586
31612
  const nextMeta = Object.keys(patch).length ? mergeOrderMetadataPatch(meta, patch) : meta;
@@ -31703,7 +31729,7 @@ function createStorefrontApiHandler(config) {
31703
31729
  const otpPepper = config.otpPepper;
31704
31730
  const defaultPhoneCc = config.defaultPhoneCountryCode;
31705
31731
  function fireOrderPlacedNotification(orderId, isPaid) {
31706
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
31732
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
31707
31733
  fireOrderNotificationTrigger("order_placed", orderId, {
31708
31734
  dataSource,
31709
31735
  entityMap
@@ -33396,7 +33422,7 @@ function createStorefrontApiHandler(config) {
33396
33422
  status: 503
33397
33423
  });
33398
33424
  const companyDetails = getCompanyDetails ? await getCompanyDetails() : {};
33399
- await chunkMXABMVF7_cjs.queueEmail(cms, {
33425
+ await chunkXFDIIVZB_cjs.queueEmail(cms, {
33400
33426
  to: identifier,
33401
33427
  templateName: "otp",
33402
33428
  ctx: {
@@ -33621,7 +33647,7 @@ function createStorefrontApiHandler(config) {
33621
33647
  const companyDetails = getCompanyDetails ? await getCompanyDetails() : {};
33622
33648
  const base = (publicSiteUrl || "").replace(/\/$/, "").trim() || "http://localhost:3000";
33623
33649
  const verifyEmailUrl = `${base}/verify-email?token=${encodeURIComponent(rawToken)}`;
33624
- await chunkMXABMVF7_cjs.queueEmail(cms, {
33650
+ await chunkXFDIIVZB_cjs.queueEmail(cms, {
33625
33651
  to: email,
33626
33652
  templateName: "signup",
33627
33653
  ctx: {
@@ -34433,7 +34459,7 @@ function createStorefrontApiHandler(config) {
34433
34459
  status: 400
34434
34460
  });
34435
34461
  const cms = await getCms();
34436
- return chunk7L556RGL_cjs.streamOrderInvoicePdf(cms, dataSource, entityMap, orderId, {
34462
+ return chunkGLD263KW_cjs.streamOrderInvoicePdf(cms, dataSource, entityMap, orderId, {
34437
34463
  ownerContactId: contact.id
34438
34464
  });
34439
34465
  }
@@ -34640,7 +34666,7 @@ function createStorefrontApiHandler(config) {
34640
34666
  } catch {
34641
34667
  }
34642
34668
  try {
34643
- void import('./emit-order-notification-trigger-WI4HGMKH.cjs').then(({ fireOrderNotificationTrigger }) => {
34669
+ void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
34644
34670
  fireOrderNotificationTrigger("order_cancelled", orderId, {
34645
34671
  dataSource,
34646
34672
  entityMap
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkUPLVMVRX_cjs = require('./chunk-UPLVMVRX.cjs');
4
- var chunkJLDHK2QE_cjs = require('./chunk-JLDHK2QE.cjs');
4
+ var chunkTZEMLHSP_cjs = require('./chunk-TZEMLHSP.cjs');
5
5
  var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
6
6
  var pdfLib = require('pdf-lib');
7
7
 
@@ -666,8 +666,8 @@ async function buildLocalInvoicePdfForOrder(ds, entityMap, orderId) {
666
666
  loadSettingsGroup(ds, entityMap, "branding"),
667
667
  loadSettingsGroup(ds, entityMap, "email")
668
668
  ]);
669
- const companyDetails = chunkJLDHK2QE_cjs.mergeEmailLayoutCompanyDetails(branding, email);
670
- const fromBranding = chunkJLDHK2QE_cjs.getCompanyDetailsFromSettings(branding);
669
+ const companyDetails = chunkTZEMLHSP_cjs.mergeEmailLayoutCompanyDetails(branding, email, store);
670
+ const fromBranding = chunkTZEMLHSP_cjs.getCompanyDetailsFromSettings(branding);
671
671
  const rawLogo = store.invoiceLogoUrl || store.companyLogo || store.logo || companyDetails.logoUrl || fromBranding.logoUrl || null;
672
672
  const logoUrl = resolveInvoiceAssetUrl(rawLogo);
673
673
  const companyName = store.companyName || store.invoiceCompanyName || store.name || companyDetails.companyName || fromBranding.companyName || "Store";