@infuro/cms-core 1.0.65 → 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.
- package/dist/admin.cjs +4 -4
- package/dist/admin.js +4 -4
- package/dist/api.cjs +35 -35
- package/dist/api.js +3 -3
- package/dist/{chunk-NIRYYJIJ.cjs → chunk-5MZFQRDW.cjs} +73 -55
- package/dist/{chunk-YEAXE4U2.js → chunk-FLUF2GZH.js} +5 -11
- package/dist/{chunk-ACBN6UWZ.js → chunk-NV5IRHI3.js} +26 -8
- package/dist/{chunk-BXAKL2TF.cjs → chunk-PA6YDMFZ.cjs} +5 -11
- package/dist/{chunk-YHEITFHR.cjs → chunk-QYRXLURF.cjs} +100 -68
- package/dist/{chunk-RDEVZMO5.js → chunk-RCE5SJBA.js} +2 -2
- package/dist/{chunk-SANKKGB3.js → chunk-T33KU5G5.js} +73 -41
- package/dist/{chunk-V6EYAC7X.cjs → chunk-WMMZZRDJ.cjs} +15 -15
- package/dist/{emit-order-notification-trigger-UCKJHDQK.js → emit-order-notification-trigger-EJJZ6XTS.js} +2 -2
- package/dist/{emit-order-notification-trigger-DR74TQXN.cjs → emit-order-notification-trigger-ZD5YN3JM.cjs} +4 -4
- package/dist/index.cjs +220 -220
- package/dist/index.js +6 -6
- package/dist/{order-completion-otp-handlers-CH22ZRAI.js → order-completion-otp-handlers-LFRHXWK4.js} +2 -2
- package/dist/{order-completion-otp-handlers-RW5RSXH3.cjs → order-completion-otp-handlers-NK65LOLV.cjs} +3 -3
- package/dist/{order-notification-dispatcher-3TXUAJ7L.js → order-notification-dispatcher-ECPFI7CD.js} +2 -2
- package/dist/{order-notification-dispatcher-Y7NZAALH.cjs → order-notification-dispatcher-LL7ETKLU.cjs} +7 -7
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var chunkWFMVD567_cjs = require('./chunk-WFMVD567.cjs');
|
|
4
4
|
var chunkTHL5JDWJ_cjs = require('./chunk-THL5JDWJ.cjs');
|
|
5
5
|
var chunkHY3AXLOI_cjs = require('./chunk-HY3AXLOI.cjs');
|
|
6
|
-
var
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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 =
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
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 =
|
|
11692
|
-
console.info(
|
|
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
|
|
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:
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
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 =
|
|
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;
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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 (!
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 &&
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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,32 +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
|
|
31732
|
-
void import('./emit-order-notification-trigger-
|
|
31733
|
-
fireOrderNotificationTrigger("
|
|
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
|
|
31736
31781
|
}, {
|
|
31737
31782
|
source: "storefront"
|
|
31738
31783
|
});
|
|
31739
|
-
if (isPaid) {
|
|
31740
|
-
fireOrderNotificationTrigger("payment_success", orderId, {
|
|
31741
|
-
dataSource,
|
|
31742
|
-
entityMap
|
|
31743
|
-
}, {
|
|
31744
|
-
source: "storefront"
|
|
31745
|
-
});
|
|
31746
|
-
} else {
|
|
31747
|
-
fireOrderNotificationTrigger("payment_failed", orderId, {
|
|
31748
|
-
dataSource,
|
|
31749
|
-
entityMap
|
|
31750
|
-
}, {
|
|
31751
|
-
source: "storefront"
|
|
31752
|
-
});
|
|
31753
|
-
}
|
|
31754
31784
|
}).catch((err) => console.error("[notification-triggers] import failed", err));
|
|
31755
31785
|
}
|
|
31756
|
-
chunkUSNT2KNT_cjs.__name(
|
|
31786
|
+
chunkUSNT2KNT_cjs.__name(fireStorefrontCheckoutNotifications, "fireStorefrontCheckoutNotifications");
|
|
31757
31787
|
const otpAllowPhoneLogin = config.otpAllowPhoneLogin !== false;
|
|
31758
31788
|
function otpOff(key) {
|
|
31759
31789
|
return !otpFlags || otpFlags[key] !== true;
|
|
@@ -34250,6 +34280,7 @@ function createStorefrontApiHandler(config) {
|
|
|
34250
34280
|
}));
|
|
34251
34281
|
}
|
|
34252
34282
|
await linkOrderContactToVendors(contactId, vendorRes.vendorIds);
|
|
34283
|
+
fireStorefrontCheckoutNotifications(oid);
|
|
34253
34284
|
return json({
|
|
34254
34285
|
orderId: oid,
|
|
34255
34286
|
orderNumber: ord.orderNumber,
|
|
@@ -34330,6 +34361,7 @@ function createStorefrontApiHandler(config) {
|
|
|
34330
34361
|
cartId: cart.id
|
|
34331
34362
|
});
|
|
34332
34363
|
await cartRepo().delete(cart.id);
|
|
34364
|
+
fireStorefrontCheckoutNotifications(oid);
|
|
34333
34365
|
return json({
|
|
34334
34366
|
orderId: oid,
|
|
34335
34367
|
orderNumber: ord.orderNumber,
|
|
@@ -34672,7 +34704,7 @@ function createStorefrontApiHandler(config) {
|
|
|
34672
34704
|
} catch {
|
|
34673
34705
|
}
|
|
34674
34706
|
try {
|
|
34675
|
-
void import('./emit-order-notification-trigger-
|
|
34707
|
+
void import('./emit-order-notification-trigger-ZD5YN3JM.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
34676
34708
|
fireOrderNotificationTrigger("order_cancelled", orderId, {
|
|
34677
34709
|
dataSource,
|
|
34678
34710
|
entityMap
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyLog, notificationTriggerEmitter, maskNotifyPhone } from './chunk-
|
|
1
|
+
import { notifyLog, notificationTriggerEmitter, maskNotifyPhone } from './chunk-FLUF2GZH.js';
|
|
2
2
|
import { __name } from './chunk-SHUYVCID.js';
|
|
3
3
|
|
|
4
4
|
// src/lib/emit-order-notification-trigger.ts
|
|
@@ -94,7 +94,7 @@ async function emitOrderNotificationTrigger(triggerKey, orderId, deps, extra) {
|
|
|
94
94
|
orderId
|
|
95
95
|
});
|
|
96
96
|
try {
|
|
97
|
-
const { dispatchOrderNotificationDirectly } = await import('./order-notification-dispatcher-
|
|
97
|
+
const { dispatchOrderNotificationDirectly } = await import('./order-notification-dispatcher-ECPFI7CD.js');
|
|
98
98
|
await dispatchOrderNotificationDirectly(triggerKey, triggerPayload, deps.dataSource, deps.entityMap);
|
|
99
99
|
} catch (err) {
|
|
100
100
|
notifyLog.error("TRIGGER", "direct dispatch failed", {
|