@infuro/cms-core 1.0.64 → 1.0.66

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 (32) hide show
  1. package/dist/admin.cjs +4 -4
  2. package/dist/admin.js +4 -4
  3. package/dist/api.cjs +36 -36
  4. package/dist/api.js +4 -4
  5. package/dist/{chunk-M25DGZ5J.cjs → chunk-5MZFQRDW.cjs} +242 -45
  6. package/dist/chunk-FLUF2GZH.js +71 -0
  7. package/dist/{chunk-OJAYCNE5.js → chunk-NV5IRHI3.js} +240 -43
  8. package/dist/chunk-PA6YDMFZ.cjs +78 -0
  9. package/dist/{chunk-FF45VZMM.cjs → chunk-QYRXLURF.cjs} +109 -67
  10. package/dist/{chunk-DXERXWBR.js → chunk-RCE5SJBA.js} +36 -20
  11. package/dist/{chunk-K6C3ZSBZ.js → chunk-T33KU5G5.js} +81 -39
  12. package/dist/chunk-THL5JDWJ.cjs +101 -0
  13. package/dist/{chunk-PX3BSCIG.cjs → chunk-WMMZZRDJ.cjs} +38 -22
  14. package/dist/chunk-XJNNOSJR.js +98 -0
  15. package/dist/{emit-order-notification-trigger-MFCBAE7L.js → emit-order-notification-trigger-EJJZ6XTS.js} +2 -2
  16. package/dist/{emit-order-notification-trigger-ZRRGCQGB.cjs → emit-order-notification-trigger-ZD5YN3JM.cjs} +4 -4
  17. package/dist/index.cjs +224 -224
  18. package/dist/index.d.cts +8 -3
  19. package/dist/index.d.ts +8 -3
  20. package/dist/index.js +8 -8
  21. package/dist/{order-completion-otp-handlers-3W5I3LON.js → order-completion-otp-handlers-LFRHXWK4.js} +2 -2
  22. package/dist/{order-completion-otp-handlers-RF3DLNV7.cjs → order-completion-otp-handlers-NK65LOLV.cjs} +3 -3
  23. package/dist/{order-notification-dispatcher-ID2PDEXD.js → order-notification-dispatcher-ECPFI7CD.js} +2 -2
  24. package/dist/{order-notification-dispatcher-RNEQB3V7.cjs → order-notification-dispatcher-LL7ETKLU.cjs} +7 -7
  25. package/dist/{pg-boss-service-L6MTF4EQ.cjs → pg-boss-service-BDGOKM2T.cjs} +3 -3
  26. package/dist/pg-boss-service-WCBJD4JB.js +2 -0
  27. package/package.json +1 -1
  28. package/dist/chunk-AYWDQFJZ.js +0 -27
  29. package/dist/chunk-GO7PPYNU.js +0 -76
  30. package/dist/chunk-UEE4PTTB.cjs +0 -30
  31. package/dist/chunk-XQ3QUHWR.cjs +0 -83
  32. package/dist/pg-boss-service-4XF2TQ2E.js +0 -2
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkWFMVD567_cjs = require('./chunk-WFMVD567.cjs');
4
- var chunkXQ3QUHWR_cjs = require('./chunk-XQ3QUHWR.cjs');
4
+ var chunkTHL5JDWJ_cjs = require('./chunk-THL5JDWJ.cjs');
5
5
  var chunkHY3AXLOI_cjs = require('./chunk-HY3AXLOI.cjs');
6
- var chunkM25DGZ5J_cjs = require('./chunk-M25DGZ5J.cjs');
6
+ var chunk5MZFQRDW_cjs = require('./chunk-5MZFQRDW.cjs');
7
7
  var chunkH3IVLIPR_cjs = require('./chunk-H3IVLIPR.cjs');
8
8
  var chunk7NMT3GBR_cjs = require('./chunk-7NMT3GBR.cjs');
9
9
  var chunkXFDIIVZB_cjs = require('./chunk-XFDIIVZB.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-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
5242
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
5243
5243
  if (finalCreatedStatus === "pending") {
5244
5244
  if (initialPayStatus === "failed") {
5245
5245
  fireOrderNotificationTrigger("payment_failed", orderIdForNotify, {
@@ -6319,7 +6319,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6319
6319
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
6320
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
6321
  if (assigneeUpdated) {
6322
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
6322
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
6323
6323
  fireOrderNotificationTrigger("order_assigned", updatedOrder.id, {
6324
6324
  dataSource,
6325
6325
  entityMap
@@ -6336,7 +6336,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6336
6336
  const payments = Array.isArray(updatedOrder.payments) ? updatedOrder.payments : [];
6337
6337
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
6338
6338
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
6339
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
6339
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
6340
6340
  if (newStatus === "pending") {
6341
6341
  if (curPayStatus === "failed") {
6342
6342
  fireOrderNotificationTrigger("payment_failed", updatedOrder.id, {
@@ -6990,7 +6990,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6990
6990
  });
6991
6991
  }
6992
6992
  if (ordStatus === "pending" || ordStatus === "confirmed") {
6993
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
6993
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
6994
6994
  fireOrderNotificationTrigger("order_placed", pOrder, {
6995
6995
  dataSource,
6996
6996
  entityMap
@@ -7004,7 +7004,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7004
7004
  }
7005
7005
  }
7006
7006
  } else if (newPayStatus === "failed") {
7007
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
7007
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
7008
7008
  fireOrderNotificationTrigger("payment_failed", pOrder, {
7009
7009
  dataSource,
7010
7010
  entityMap
@@ -7012,7 +7012,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7012
7012
  }).catch(() => {
7013
7013
  });
7014
7014
  } else if (newPayStatus === "refunded") {
7015
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
7015
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
7016
7016
  fireOrderNotificationTrigger("payment_refund_initiated", pOrder, {
7017
7017
  dataSource,
7018
7018
  entityMap
@@ -7139,7 +7139,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7139
7139
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
7140
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
7141
  if (assigneeUpdated) {
7142
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
7142
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
7143
7143
  fireOrderNotificationTrigger("order_assigned", ord.id, {
7144
7144
  dataSource,
7145
7145
  entityMap
@@ -7156,7 +7156,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7156
7156
  const payments = Array.isArray(ord.payments) ? ord.payments : [];
7157
7157
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
7158
7158
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
7159
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
7159
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
7160
7160
  if (newStatus === "pending") {
7161
7161
  if (curPayStatus === "failed") {
7162
7162
  fireOrderNotificationTrigger("payment_failed", ord.id, {
@@ -11602,7 +11602,7 @@ function createChatHandlers(config) {
11602
11602
  const notifyEmailAgent = await findLlmAgentByScope(dataSource, entityMap, LLM_AGENT_SCOPE_EMAIL_INTENT_CHATBOT, {
11603
11603
  enabledOnly: false
11604
11604
  });
11605
- const emailTool = chunkM25DGZ5J_cjs.resolveChatEmailToolSettings(llmSettings, {
11605
+ const emailTool = chunk5MZFQRDW_cjs.resolveChatEmailToolSettings(llmSettings, {
11606
11606
  chatbotValidationRules: agentRow?.validationRules ?? null,
11607
11607
  notifyAgent: notifyEmailAgent ? {
11608
11608
  systemInstruction: notifyEmailAgent.systemInstruction,
@@ -11612,7 +11612,7 @@ function createChatHandlers(config) {
11612
11612
  const emailPlugin2 = cms.getPlugin("email");
11613
11613
  const convLeadSent = conv.leadEmailSentAt;
11614
11614
  const chatAgentFn = llm.chatAgent?.bind(llm);
11615
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline check", {
11615
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline check", {
11616
11616
  conversationId,
11617
11617
  enabled: emailTool.enabled,
11618
11618
  intentCount: emailTool.intents.length,
@@ -11626,27 +11626,27 @@ function createChatHandlers(config) {
11626
11626
  mergedPromptIncludesNotify: Boolean(notifyEmailAgent?.systemInstruction?.trim())
11627
11627
  });
11628
11628
  if (!emailTool.enabled) {
11629
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11629
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11630
11630
  conversationId,
11631
11631
  reason: "email_tool_disabled"
11632
11632
  });
11633
11633
  } else if (emailTool.intents.length === 0) {
11634
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11634
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11635
11635
  conversationId,
11636
11636
  reason: "no_intents_configured"
11637
11637
  });
11638
11638
  } else if (!emailPlugin2) {
11639
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11639
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11640
11640
  conversationId,
11641
11641
  reason: "email_plugin_missing"
11642
11642
  });
11643
11643
  } else if (!chatAgentFn) {
11644
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11644
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11645
11645
  conversationId,
11646
11646
  reason: "llm_chat_agent_unavailable"
11647
11647
  });
11648
11648
  } else if (convLeadSent) {
11649
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11649
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11650
11650
  conversationId,
11651
11651
  reason: "lead_email_already_sent",
11652
11652
  leadEmailSentAt: convLeadSent
@@ -11659,7 +11659,7 @@ function createChatHandlers(config) {
11659
11659
  }
11660
11660
  });
11661
11661
  if (!contactRow) {
11662
- console.warn(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11662
+ console.warn(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
11663
11663
  conversationId,
11664
11664
  reason: "contact_not_found",
11665
11665
  contactId
@@ -11667,7 +11667,7 @@ function createChatHandlers(config) {
11667
11667
  } else {
11668
11668
  const c = contactRow;
11669
11669
  try {
11670
- const intent = await chunkM25DGZ5J_cjs.detectChatLeadIntent({
11670
+ const intent = await chunk5MZFQRDW_cjs.detectChatLeadIntent({
11671
11671
  chatAgent: chatAgentFn
11672
11672
  }, {
11673
11673
  settings: emailTool,
@@ -11681,15 +11681,15 @@ function createChatHandlers(config) {
11681
11681
  model: agentRow?.model?.trim() || notifyEmailAgent?.model?.trim() || void 0
11682
11682
  });
11683
11683
  if (!intent.intent || !intent.emailTo) {
11684
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "no email sent", {
11684
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "no email sent", {
11685
11685
  conversationId,
11686
11686
  reason: intent.intent ? "missing_email_to" : "no_intent_match",
11687
11687
  intentLabel: intent.intentLabel,
11688
11688
  classifierReason: intent.reason
11689
11689
  });
11690
11690
  } else {
11691
- const intentRecipients = chunkM25DGZ5J_cjs.parseIntentRecipientEmails(intent.emailTo);
11692
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "intent matched \u2014 sending", {
11691
+ const intentRecipients = chunk5MZFQRDW_cjs.parseIntentRecipientEmails(intent.emailTo);
11692
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "intent matched \u2014 sending", {
11693
11693
  conversationId,
11694
11694
  intent: intent.intent,
11695
11695
  emailTo: intent.emailTo,
@@ -11700,7 +11700,7 @@ function createChatHandlers(config) {
11700
11700
  const brandingSettings = await loadSettingsGroupMap(dataSource, entityMap, "branding");
11701
11701
  const storeSettings = await loadSettingsGroupMap(dataSource, entityMap, "store");
11702
11702
  const companyDetails = chunkTZEMLHSP_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings, storeSettings);
11703
- const leadResult = await chunkM25DGZ5J_cjs.sendChatLeadEmail(cms, emailSettings, brandingSettings, {
11703
+ const leadResult = await chunk5MZFQRDW_cjs.sendChatLeadEmail(cms, emailSettings, brandingSettings, {
11704
11704
  contactName: String(c.name ?? "").trim() || "Visitor",
11705
11705
  contactEmail: String(c.email ?? "").trim(),
11706
11706
  contactPhone: c.phone ?? null,
@@ -11708,7 +11708,7 @@ function createChatHandlers(config) {
11708
11708
  latestMessage: message,
11709
11709
  intentCode: intent.intent,
11710
11710
  intentReason: intent.intentLabel || intent.reason,
11711
- transcript: chunkM25DGZ5J_cjs.buildTranscriptForLeadEmail(history, message),
11711
+ transcript: chunk5MZFQRDW_cjs.buildTranscriptForLeadEmail(history, message),
11712
11712
  companyDetails,
11713
11713
  recipients: intentRecipients.length > 0 ? intentRecipients : void 0
11714
11714
  });
@@ -11716,13 +11716,13 @@ function createChatHandlers(config) {
11716
11716
  await convRepo().update(conversationId, {
11717
11717
  leadEmailSentAt: /* @__PURE__ */ new Date()
11718
11718
  });
11719
- console.info(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "lead email recorded", {
11719
+ console.info(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "lead email recorded", {
11720
11720
  conversationId,
11721
11721
  sent: true,
11722
11722
  recipients: leadResult.recipients
11723
11723
  });
11724
11724
  } else {
11725
- console.warn(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "lead email not sent", {
11725
+ console.warn(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "lead email not sent", {
11726
11726
  conversationId,
11727
11727
  sent: false,
11728
11728
  error: leadResult.error ?? "unknown",
@@ -11731,7 +11731,7 @@ function createChatHandlers(config) {
11731
11731
  }
11732
11732
  }
11733
11733
  } catch (intentErr) {
11734
- console.warn(chunkM25DGZ5J_cjs.CHAT_EMAIL_LOG, "pipeline error", {
11734
+ console.warn(chunk5MZFQRDW_cjs.CHAT_EMAIL_LOG, "pipeline error", {
11735
11735
  conversationId,
11736
11736
  error: intentErr instanceof Error ? intentErr.message : String(intentErr)
11737
11737
  });
@@ -11748,7 +11748,7 @@ function createChatHandlers(config) {
11748
11748
  });
11749
11749
  if (agentRow && llm.chatAgent) {
11750
11750
  const fromAgent = llmAgentToChatAgentOptions(agentRow);
11751
- const systemPrompt = chunkM25DGZ5J_cjs.buildChatbotSystemPromptWithEmailTool(fromAgent.systemPrompt, parsedValidation.guardrailsForPrompt, emailTool);
11751
+ const systemPrompt = chunk5MZFQRDW_cjs.buildChatbotSystemPromptWithEmailTool(fromAgent.systemPrompt, parsedValidation.guardrailsForPrompt, emailTool);
11752
11752
  const res = await llm.chatAgent({
11753
11753
  ...fromAgent,
11754
11754
  systemPrompt: systemPrompt || void 0,
@@ -11769,7 +11769,7 @@ ${contextParts.join("\n\n")}` : "";
11769
11769
  agentRow.systemInstruction?.trim(),
11770
11770
  ragSystem
11771
11771
  ].filter(Boolean).join("\n\n");
11772
- systemContent = chunkM25DGZ5J_cjs.buildChatbotSystemPromptWithEmailTool(mergedBase || defaultSystem, parsedValidation.guardrailsForPrompt, emailTool) || defaultSystem;
11772
+ systemContent = chunk5MZFQRDW_cjs.buildChatbotSystemPromptWithEmailTool(mergedBase || defaultSystem, parsedValidation.guardrailsForPrompt, emailTool) || defaultSystem;
11773
11773
  } else {
11774
11774
  systemContent = ragSystem || defaultSystem;
11775
11775
  }
@@ -13024,7 +13024,7 @@ function createDeviceTokensHandlers(config) {
13024
13024
  const title = body.title?.trim() || "Test Push Notification";
13025
13025
  const msgBody = body.body?.trim() || "Firebase Push Notification setup is working!";
13026
13026
  if (!token || token === "validate" || token === "validate_only") {
13027
- const valRes = await chunkM25DGZ5J_cjs.validateFcmCredentials(dataSource, entityMap);
13027
+ const valRes = await chunk5MZFQRDW_cjs.validateFcmCredentials(dataSource, entityMap);
13028
13028
  if (!valRes.success) {
13029
13029
  return json({
13030
13030
  success: false,
@@ -13041,7 +13041,7 @@ function createDeviceTokensHandlers(config) {
13041
13041
  clientEmail: valRes.clientEmail
13042
13042
  });
13043
13043
  }
13044
- const res = await chunkM25DGZ5J_cjs.sendFcmPushNotification(dataSource, entityMap, {
13044
+ const res = await chunk5MZFQRDW_cjs.sendFcmPushNotification(dataSource, entityMap, {
13045
13045
  token,
13046
13046
  title,
13047
13047
  body: msgBody,
@@ -14037,7 +14037,7 @@ async function sendVendorOnboardEmails(input, deps) {
14037
14037
  getVendorEmails(deps)
14038
14038
  ]);
14039
14039
  const companyDetails = chunkTZEMLHSP_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
14040
- const configuredNotify = chunkM25DGZ5J_cjs.parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
14040
+ const configuredNotify = chunk5MZFQRDW_cjs.parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
14041
14041
  const ownerEmail = input.ownerEmail?.trim() || "";
14042
14042
  const ownerEmailLower = ownerEmail.toLowerCase();
14043
14043
  const sendToOwner = input.sendToOwner !== false;
@@ -27495,7 +27495,7 @@ async function queueJobScheduleNow(cms, scheduleId) {
27495
27495
  if (!boss) {
27496
27496
  throw new Error("pg-boss is not configured (DATABASE_URL required)");
27497
27497
  }
27498
- const { JOB_RUNNER_QUEUE: JOB_RUNNER_QUEUE2 } = await import('./pg-boss-service-L6MTF4EQ.cjs');
27498
+ const { JOB_RUNNER_QUEUE: JOB_RUNNER_QUEUE2 } = await import('./pg-boss-service-BDGOKM2T.cjs');
27499
27499
  await boss.send(JOB_RUNNER_QUEUE2, {
27500
27500
  scheduleId,
27501
27501
  triggeredBy: "manual"
@@ -27749,7 +27749,7 @@ function registerJobRunnerWorker(cms, deps) {
27749
27749
  const registerQueue = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(async (queueName) => {
27750
27750
  await boss.registerWork(queueName, execute);
27751
27751
  }, "registerQueue");
27752
- void boss.registerWork(chunkXQ3QUHWR_cjs.JOB_RUNNER_QUEUE, execute);
27752
+ void boss.registerWork(chunkTHL5JDWJ_cjs.JOB_RUNNER_QUEUE, execute);
27753
27753
  void (async () => {
27754
27754
  try {
27755
27755
  const repo = deps.dataSource.getRepository(exports.JobSchedule);
@@ -28324,7 +28324,7 @@ function slugify2(input) {
28324
28324
  return input.toLowerCase().trim().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 64) || "template";
28325
28325
  }
28326
28326
  chunkUSNT2KNT_cjs.__name(slugify2, "slugify");
28327
- function createEmailMessageTemplatesHandlers(config) {
28327
+ function createTextMessageTemplatesHandlers(config, channel) {
28328
28328
  const { dataSource, entityMap, json, requireAuth, requireEntityPermission } = config;
28329
28329
  const templateRepo = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(() => dataSource.getRepository(entityMap.message_templates), "templateRepo");
28330
28330
  async function requireRead(req, entity) {
@@ -28347,6 +28347,10 @@ function createEmailMessageTemplatesHandlers(config) {
28347
28347
  return null;
28348
28348
  }
28349
28349
  chunkUSNT2KNT_cjs.__name(requireUpdate, "requireUpdate");
28350
+ function isLegacyPushTemplate(row) {
28351
+ return row.channel === "email" && typeof row.name === "string" && row.name.includes("_push_");
28352
+ }
28353
+ chunkUSNT2KNT_cjs.__name(isLegacyPushTemplate, "isLegacyPushTemplate");
28350
28354
  return {
28351
28355
  async listCached(req) {
28352
28356
  const err = await requireRead(req, "settings");
@@ -28354,15 +28358,19 @@ function createEmailMessageTemplatesHandlers(config) {
28354
28358
  try {
28355
28359
  const rows = await templateRepo().find({
28356
28360
  where: {
28357
- channel: "email",
28358
28361
  deleted: false
28359
28362
  },
28360
28363
  order: {
28361
28364
  name: "ASC"
28362
28365
  }
28363
28366
  });
28367
+ const items = rows.filter((row) => {
28368
+ const r = row;
28369
+ if (channel === "email") return r.channel === "email" && !isLegacyPushTemplate(r);
28370
+ return r.channel === "mobile" || isLegacyPushTemplate(r);
28371
+ });
28364
28372
  return json({
28365
- items: rows
28373
+ items
28366
28374
  });
28367
28375
  } catch {
28368
28376
  return json({
@@ -28403,7 +28411,7 @@ function createEmailMessageTemplatesHandlers(config) {
28403
28411
  let suffix = 1;
28404
28412
  while (await templateRepo().findOne({
28405
28413
  where: {
28406
- channel: "email",
28414
+ channel,
28407
28415
  templateKey,
28408
28416
  deleted: false
28409
28417
  }
@@ -28412,7 +28420,7 @@ function createEmailMessageTemplatesHandlers(config) {
28412
28420
  templateKey = `${baseKey}_${suffix}`;
28413
28421
  }
28414
28422
  const row = await templateRepo().save(templateRepo().create({
28415
- channel: "email",
28423
+ channel,
28416
28424
  templateKey,
28417
28425
  name,
28418
28426
  subject,
@@ -28450,7 +28458,6 @@ function createEmailMessageTemplatesHandlers(config) {
28450
28458
  const existing = await templateRepo().findOne({
28451
28459
  where: {
28452
28460
  id: numId,
28453
- channel: "email",
28454
28461
  deleted: false
28455
28462
  }
28456
28463
  });
@@ -28459,9 +28466,25 @@ function createEmailMessageTemplatesHandlers(config) {
28459
28466
  }, {
28460
28467
  status: 404
28461
28468
  });
28469
+ const row = existing;
28470
+ if (channel === "email" && row.channel !== "email") {
28471
+ return json({
28472
+ error: "Template not found"
28473
+ }, {
28474
+ status: 404
28475
+ });
28476
+ }
28477
+ if (channel === "mobile" && row.channel !== "mobile" && !isLegacyPushTemplate(row)) {
28478
+ return json({
28479
+ error: "Template not found"
28480
+ }, {
28481
+ status: 404
28482
+ });
28483
+ }
28462
28484
  const patch = {
28463
28485
  updatedAt: /* @__PURE__ */ new Date()
28464
28486
  };
28487
+ if (channel === "mobile") patch.channel = "mobile";
28465
28488
  if (typeof body.name === "string" && body.name.trim()) patch.name = body.name.trim();
28466
28489
  if (typeof body.subject === "string") patch.subject = body.subject;
28467
28490
  if (typeof body.body === "string") {
@@ -28484,7 +28507,15 @@ function createEmailMessageTemplatesHandlers(config) {
28484
28507
  }
28485
28508
  };
28486
28509
  }
28510
+ chunkUSNT2KNT_cjs.__name(createTextMessageTemplatesHandlers, "createTextMessageTemplatesHandlers");
28511
+ function createEmailMessageTemplatesHandlers(config) {
28512
+ return createTextMessageTemplatesHandlers(config, "email");
28513
+ }
28487
28514
  chunkUSNT2KNT_cjs.__name(createEmailMessageTemplatesHandlers, "createEmailMessageTemplatesHandlers");
28515
+ function createMobileMessageTemplatesHandlers(config) {
28516
+ return createTextMessageTemplatesHandlers(config, "mobile");
28517
+ }
28518
+ chunkUSNT2KNT_cjs.__name(createMobileMessageTemplatesHandlers, "createMobileMessageTemplatesHandlers");
28488
28519
  function connectionFromUrl(redisUrl) {
28489
28520
  const u = new URL(redisUrl);
28490
28521
  return {
@@ -28663,11 +28694,11 @@ function whatsappPlugin(config = {}) {
28663
28694
  db = await settingsLoader?.() ?? {};
28664
28695
  } catch {
28665
28696
  }
28666
- if (!chunkM25DGZ5J_cjs.isWhatsAppPluginEnabled(db)) {
28697
+ if (!chunk5MZFQRDW_cjs.isWhatsAppPluginEnabled(db)) {
28667
28698
  context.logger.warn("WhatsApp plugin skipped: disabled in Plugins \u2192 WhatsApp");
28668
28699
  return null;
28669
28700
  }
28670
- const svc = new chunkM25DGZ5J_cjs.WhatsAppService(env, staticRest, settingsLoader, getMessageTemplateRow);
28701
+ const svc = new chunk5MZFQRDW_cjs.WhatsAppService(env, staticRest, settingsLoader, getMessageTemplateRow);
28671
28702
  return {
28672
28703
  send: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((opts) => svc.send(opts), "send")
28673
28704
  };
@@ -28773,7 +28804,7 @@ async function ensureMessagingPluginsOnCms(base, options) {
28773
28804
  }
28774
28805
  if (!cms.getPlugin("email")) {
28775
28806
  try {
28776
- const instance = await chunkM25DGZ5J_cjs.emailPlugin({
28807
+ const instance = await chunk5MZFQRDW_cjs.emailPlugin({
28777
28808
  type: "SMTP",
28778
28809
  from: config.SMTP_FROM ?? "no-reply@localhost",
28779
28810
  to: config.SMTP_TO ?? ""
@@ -28814,7 +28845,7 @@ function messagingPlugins(options) {
28814
28845
  const config = options.config ?? (typeof process !== "undefined" ? process.env : {});
28815
28846
  return [
28816
28847
  queuePlugin(),
28817
- chunkM25DGZ5J_cjs.emailPlugin({
28848
+ chunk5MZFQRDW_cjs.emailPlugin({
28818
28849
  type: "SMTP",
28819
28850
  from: config.SMTP_FROM ?? "no-reply@localhost",
28820
28851
  to: config.SMTP_TO ?? ""
@@ -28948,7 +28979,7 @@ function createCmsApiHandler(config) {
28948
28979
  } : void 0;
28949
28980
  const entityMap = withLlmKnowledgeEntityFallbacks(rawEntityMap);
28950
28981
  if (getCms) {
28951
- chunkM25DGZ5J_cjs.initWhatsappTriggerDispatcher({
28982
+ chunk5MZFQRDW_cjs.initWhatsappTriggerDispatcher({
28952
28983
  dataSource,
28953
28984
  entityMap,
28954
28985
  getCms
@@ -29244,6 +29275,13 @@ function createCmsApiHandler(config) {
29244
29275
  requireAuth: config.requireAuth,
29245
29276
  requireEntityPermission: requireEntityPermissionEffective
29246
29277
  });
29278
+ const mobileMessageTemplatesHandlers = createMobileMessageTemplatesHandlers({
29279
+ dataSource,
29280
+ entityMap,
29281
+ json: config.json,
29282
+ requireAuth: config.requireAuth,
29283
+ requireEntityPermission: requireEntityPermissionEffective
29284
+ });
29247
29285
  const deviceTokensHandlers = createDeviceTokensHandlers({
29248
29286
  dataSource,
29249
29287
  entityMap,
@@ -30278,9 +30316,16 @@ function createCmsApiHandler(config) {
30278
30316
  if (m === "GET") return emailMessageTemplatesHandlers.listCached(req);
30279
30317
  if (m === "POST") return emailMessageTemplatesHandlers.create(req);
30280
30318
  }
30281
- if (isMsgTemplatesRoute && (path2[1] === "email" || path2.length === 2) && path2.length === 3) {
30319
+ if (isMsgTemplatesRoute && path2[1] === "mobile" && path2.length === 2) {
30320
+ if (m === "GET") return mobileMessageTemplatesHandlers.listCached(req);
30321
+ if (m === "POST") return mobileMessageTemplatesHandlers.create(req);
30322
+ }
30323
+ if (isMsgTemplatesRoute && (path2[1] === "email" || path2.length === 2) && path2.length === 3 && path2[1] !== "mobile") {
30282
30324
  if (m === "PATCH") return emailMessageTemplatesHandlers.update(req, path2[2]);
30283
30325
  }
30326
+ if (isMsgTemplatesRoute && path2[1] === "mobile" && path2.length === 3) {
30327
+ if (m === "PATCH") return mobileMessageTemplatesHandlers.update(req, path2[2]);
30328
+ }
30284
30329
  if (path2[0] === "llm_agents") {
30285
30330
  if (!entityMap.llm_agents) {
30286
30331
  console.error(CMS_API_LOG, "llm_agents route: entity missing after merge", {
@@ -30723,7 +30768,7 @@ function createCmsApiHandler(config) {
30723
30768
  status: 400
30724
30769
  });
30725
30770
  }
30726
- const { resendOrderNotification } = await import('./order-notification-dispatcher-RNEQB3V7.cjs');
30771
+ const { resendOrderNotification } = await import('./order-notification-dispatcher-LL7ETKLU.cjs');
30727
30772
  const result = await resendOrderNotification(triggerKey, orderId, {
30728
30773
  dataSource,
30729
30774
  entityMap,
@@ -30822,7 +30867,7 @@ function createCmsApiHandler(config) {
30822
30867
  status: "cancelled"
30823
30868
  });
30824
30869
  const fireOrderCancelledNotification = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((refundAmount) => {
30825
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
30870
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
30826
30871
  fireOrderNotificationTrigger("order_cancelled", orderId, {
30827
30872
  dataSource,
30828
30873
  entityMap
@@ -31067,7 +31112,7 @@ function createCmsApiHandler(config) {
31067
31112
  }, {
31068
31113
  status: 400
31069
31114
  });
31070
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-RF3DLNV7.cjs');
31115
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-NK65LOLV.cjs');
31071
31116
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31072
31117
  return handlers.getChannels(req, orderId);
31073
31118
  }
@@ -31082,7 +31127,7 @@ function createCmsApiHandler(config) {
31082
31127
  }, {
31083
31128
  status: 400
31084
31129
  });
31085
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-RF3DLNV7.cjs');
31130
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-NK65LOLV.cjs');
31086
31131
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31087
31132
  return handlers.sendOtp(req, orderId);
31088
31133
  }
@@ -31097,7 +31142,7 @@ function createCmsApiHandler(config) {
31097
31142
  }, {
31098
31143
  status: 400
31099
31144
  });
31100
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-RF3DLNV7.cjs');
31145
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-NK65LOLV.cjs');
31101
31146
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
31102
31147
  return handlers.verifyOtp(req, orderId);
31103
31148
  }
@@ -31728,26 +31773,17 @@ function createStorefrontApiHandler(config) {
31728
31773
  const otpFlags = config.otpFlags;
31729
31774
  const otpPepper = config.otpPepper;
31730
31775
  const defaultPhoneCc = config.defaultPhoneCountryCode;
31731
- function fireOrderPlacedNotification(orderId, isPaid) {
31732
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
31733
- fireOrderNotificationTrigger("order_placed", orderId, {
31776
+ function fireStorefrontCheckoutNotifications(orderId) {
31777
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
31778
+ fireOrderNotificationTrigger("order_pending", orderId, {
31734
31779
  dataSource,
31735
31780
  entityMap
31781
+ }, {
31782
+ source: "storefront"
31736
31783
  });
31737
- if (isPaid) {
31738
- fireOrderNotificationTrigger("payment_success", orderId, {
31739
- dataSource,
31740
- entityMap
31741
- });
31742
- } else {
31743
- fireOrderNotificationTrigger("payment_failed", orderId, {
31744
- dataSource,
31745
- entityMap
31746
- });
31747
- }
31748
31784
  }).catch((err) => console.error("[notification-triggers] import failed", err));
31749
31785
  }
31750
- chunkUSNT2KNT_cjs.__name(fireOrderPlacedNotification, "fireOrderPlacedNotification");
31786
+ chunkUSNT2KNT_cjs.__name(fireStorefrontCheckoutNotifications, "fireStorefrontCheckoutNotifications");
31751
31787
  const otpAllowPhoneLogin = config.otpAllowPhoneLogin !== false;
31752
31788
  function otpOff(key) {
31753
31789
  return !otpFlags || otpFlags[key] !== true;
@@ -34244,6 +34280,7 @@ function createStorefrontApiHandler(config) {
34244
34280
  }));
34245
34281
  }
34246
34282
  await linkOrderContactToVendors(contactId, vendorRes.vendorIds);
34283
+ fireStorefrontCheckoutNotifications(oid);
34247
34284
  return json({
34248
34285
  orderId: oid,
34249
34286
  orderNumber: ord.orderNumber,
@@ -34324,6 +34361,7 @@ function createStorefrontApiHandler(config) {
34324
34361
  cartId: cart.id
34325
34362
  });
34326
34363
  await cartRepo().delete(cart.id);
34364
+ fireStorefrontCheckoutNotifications(oid);
34327
34365
  return json({
34328
34366
  orderId: oid,
34329
34367
  orderNumber: ord.orderNumber,
@@ -34666,14 +34704,18 @@ function createStorefrontApiHandler(config) {
34666
34704
  } catch {
34667
34705
  }
34668
34706
  try {
34669
- void import('./emit-order-notification-trigger-ZRRGCQGB.cjs').then(({ fireOrderNotificationTrigger }) => {
34707
+ void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
34670
34708
  fireOrderNotificationTrigger("order_cancelled", orderId, {
34671
34709
  dataSource,
34672
34710
  entityMap
34711
+ }, {
34712
+ source: "storefront"
34673
34713
  });
34674
34714
  fireOrderNotificationTrigger("payment_failed", orderId, {
34675
34715
  dataSource,
34676
34716
  entityMap
34717
+ }, {
34718
+ source: "storefront"
34677
34719
  });
34678
34720
  }).catch(() => {
34679
34721
  });