@infuro/cms-core 1.0.57 → 1.0.58
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 +1 -1
- package/dist/admin.js +1 -1
- package/dist/api.cjs +33 -33
- package/dist/api.js +2 -2
- package/dist/{chunk-BAUV5FZQ.js → chunk-AGU3B5JW.js} +68 -16
- package/dist/{chunk-CMXNHMHP.cjs → chunk-BHUEXLD2.cjs} +98 -46
- package/dist/{chunk-JN4AFHZ4.cjs → chunk-HXLC56ZK.cjs} +44 -1
- package/dist/{chunk-CTXBYO2J.js → chunk-HYW3MUXT.js} +43 -1
- package/dist/index.cjs +228 -228
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -4
- package/dist/migrations/1782700000000-NullableUserDeviceTokenVendorId.ts +28 -0
- package/dist/{order-notification-dispatcher-YBAWDOIO.cjs → order-notification-dispatcher-2FCZFZUD.cjs} +4 -4
- package/dist/{order-notification-dispatcher-AT4IFAGL.js → order-notification-dispatcher-64WDCHHG.js} +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkXQ3QUHWR_cjs = require('./chunk-XQ3QUHWR.cjs');
|
|
4
4
|
var chunkHY3AXLOI_cjs = require('./chunk-HY3AXLOI.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkHXLC56ZK_cjs = require('./chunk-HXLC56ZK.cjs');
|
|
6
6
|
var chunk7NMT3GBR_cjs = require('./chunk-7NMT3GBR.cjs');
|
|
7
7
|
var chunkV25RDUOU_cjs = require('./chunk-V25RDUOU.cjs');
|
|
8
8
|
var chunkBXYZDMTZ_cjs = require('./chunk-BXYZDMTZ.cjs');
|
|
@@ -10798,7 +10798,7 @@ function createChatHandlers(config) {
|
|
|
10798
10798
|
const notifyEmailAgent = await findLlmAgentByScope(dataSource, entityMap, LLM_AGENT_SCOPE_EMAIL_INTENT_CHATBOT, {
|
|
10799
10799
|
enabledOnly: false
|
|
10800
10800
|
});
|
|
10801
|
-
const emailTool =
|
|
10801
|
+
const emailTool = chunkHXLC56ZK_cjs.resolveChatEmailToolSettings(llmSettings, {
|
|
10802
10802
|
chatbotValidationRules: agentRow?.validationRules ?? null,
|
|
10803
10803
|
notifyAgent: notifyEmailAgent ? {
|
|
10804
10804
|
systemInstruction: notifyEmailAgent.systemInstruction,
|
|
@@ -10808,7 +10808,7 @@ function createChatHandlers(config) {
|
|
|
10808
10808
|
const emailPlugin2 = cms.getPlugin("email");
|
|
10809
10809
|
const convLeadSent = conv.leadEmailSentAt;
|
|
10810
10810
|
const chatAgentFn = llm.chatAgent?.bind(llm);
|
|
10811
|
-
console.info(
|
|
10811
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline check", {
|
|
10812
10812
|
conversationId,
|
|
10813
10813
|
enabled: emailTool.enabled,
|
|
10814
10814
|
intentCount: emailTool.intents.length,
|
|
@@ -10822,27 +10822,27 @@ function createChatHandlers(config) {
|
|
|
10822
10822
|
mergedPromptIncludesNotify: Boolean(notifyEmailAgent?.systemInstruction?.trim())
|
|
10823
10823
|
});
|
|
10824
10824
|
if (!emailTool.enabled) {
|
|
10825
|
-
console.info(
|
|
10825
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
10826
10826
|
conversationId,
|
|
10827
10827
|
reason: "email_tool_disabled"
|
|
10828
10828
|
});
|
|
10829
10829
|
} else if (emailTool.intents.length === 0) {
|
|
10830
|
-
console.info(
|
|
10830
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
10831
10831
|
conversationId,
|
|
10832
10832
|
reason: "no_intents_configured"
|
|
10833
10833
|
});
|
|
10834
10834
|
} else if (!emailPlugin2) {
|
|
10835
|
-
console.info(
|
|
10835
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
10836
10836
|
conversationId,
|
|
10837
10837
|
reason: "email_plugin_missing"
|
|
10838
10838
|
});
|
|
10839
10839
|
} else if (!chatAgentFn) {
|
|
10840
|
-
console.info(
|
|
10840
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
10841
10841
|
conversationId,
|
|
10842
10842
|
reason: "llm_chat_agent_unavailable"
|
|
10843
10843
|
});
|
|
10844
10844
|
} else if (convLeadSent) {
|
|
10845
|
-
console.info(
|
|
10845
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
10846
10846
|
conversationId,
|
|
10847
10847
|
reason: "lead_email_already_sent",
|
|
10848
10848
|
leadEmailSentAt: convLeadSent
|
|
@@ -10855,7 +10855,7 @@ function createChatHandlers(config) {
|
|
|
10855
10855
|
}
|
|
10856
10856
|
});
|
|
10857
10857
|
if (!contactRow) {
|
|
10858
|
-
console.warn(
|
|
10858
|
+
console.warn(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
10859
10859
|
conversationId,
|
|
10860
10860
|
reason: "contact_not_found",
|
|
10861
10861
|
contactId
|
|
@@ -10863,7 +10863,7 @@ function createChatHandlers(config) {
|
|
|
10863
10863
|
} else {
|
|
10864
10864
|
const c = contactRow;
|
|
10865
10865
|
try {
|
|
10866
|
-
const intent = await
|
|
10866
|
+
const intent = await chunkHXLC56ZK_cjs.detectChatLeadIntent({
|
|
10867
10867
|
chatAgent: chatAgentFn
|
|
10868
10868
|
}, {
|
|
10869
10869
|
settings: emailTool,
|
|
@@ -10877,15 +10877,15 @@ function createChatHandlers(config) {
|
|
|
10877
10877
|
model: agentRow?.model?.trim() || notifyEmailAgent?.model?.trim() || void 0
|
|
10878
10878
|
});
|
|
10879
10879
|
if (!intent.intent || !intent.emailTo) {
|
|
10880
|
-
console.info(
|
|
10880
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "no email sent", {
|
|
10881
10881
|
conversationId,
|
|
10882
10882
|
reason: intent.intent ? "missing_email_to" : "no_intent_match",
|
|
10883
10883
|
intentLabel: intent.intentLabel,
|
|
10884
10884
|
classifierReason: intent.reason
|
|
10885
10885
|
});
|
|
10886
10886
|
} else {
|
|
10887
|
-
const intentRecipients =
|
|
10888
|
-
console.info(
|
|
10887
|
+
const intentRecipients = chunkHXLC56ZK_cjs.parseIntentRecipientEmails(intent.emailTo);
|
|
10888
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "intent matched \u2014 sending", {
|
|
10889
10889
|
conversationId,
|
|
10890
10890
|
intent: intent.intent,
|
|
10891
10891
|
emailTo: intent.emailTo,
|
|
@@ -10895,7 +10895,7 @@ function createChatHandlers(config) {
|
|
|
10895
10895
|
const emailSettings = await loadSettingsGroupMap(dataSource, entityMap, "email");
|
|
10896
10896
|
const brandingSettings = await loadSettingsGroupMap(dataSource, entityMap, "branding");
|
|
10897
10897
|
const companyDetails = chunkBXYZDMTZ_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings);
|
|
10898
|
-
const leadResult = await
|
|
10898
|
+
const leadResult = await chunkHXLC56ZK_cjs.sendChatLeadEmail(cms, emailSettings, brandingSettings, {
|
|
10899
10899
|
contactName: String(c.name ?? "").trim() || "Visitor",
|
|
10900
10900
|
contactEmail: String(c.email ?? "").trim(),
|
|
10901
10901
|
contactPhone: c.phone ?? null,
|
|
@@ -10903,7 +10903,7 @@ function createChatHandlers(config) {
|
|
|
10903
10903
|
latestMessage: message,
|
|
10904
10904
|
intentCode: intent.intent,
|
|
10905
10905
|
intentReason: intent.intentLabel || intent.reason,
|
|
10906
|
-
transcript:
|
|
10906
|
+
transcript: chunkHXLC56ZK_cjs.buildTranscriptForLeadEmail(history, message),
|
|
10907
10907
|
companyDetails,
|
|
10908
10908
|
recipients: intentRecipients.length > 0 ? intentRecipients : void 0
|
|
10909
10909
|
});
|
|
@@ -10911,13 +10911,13 @@ function createChatHandlers(config) {
|
|
|
10911
10911
|
await convRepo().update(conversationId, {
|
|
10912
10912
|
leadEmailSentAt: /* @__PURE__ */ new Date()
|
|
10913
10913
|
});
|
|
10914
|
-
console.info(
|
|
10914
|
+
console.info(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "lead email recorded", {
|
|
10915
10915
|
conversationId,
|
|
10916
10916
|
sent: true,
|
|
10917
10917
|
recipients: leadResult.recipients
|
|
10918
10918
|
});
|
|
10919
10919
|
} else {
|
|
10920
|
-
console.warn(
|
|
10920
|
+
console.warn(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "lead email not sent", {
|
|
10921
10921
|
conversationId,
|
|
10922
10922
|
sent: false,
|
|
10923
10923
|
error: leadResult.error ?? "unknown",
|
|
@@ -10926,7 +10926,7 @@ function createChatHandlers(config) {
|
|
|
10926
10926
|
}
|
|
10927
10927
|
}
|
|
10928
10928
|
} catch (intentErr) {
|
|
10929
|
-
console.warn(
|
|
10929
|
+
console.warn(chunkHXLC56ZK_cjs.CHAT_EMAIL_LOG, "pipeline error", {
|
|
10930
10930
|
conversationId,
|
|
10931
10931
|
error: intentErr instanceof Error ? intentErr.message : String(intentErr)
|
|
10932
10932
|
});
|
|
@@ -10943,7 +10943,7 @@ function createChatHandlers(config) {
|
|
|
10943
10943
|
});
|
|
10944
10944
|
if (agentRow && llm.chatAgent) {
|
|
10945
10945
|
const fromAgent = llmAgentToChatAgentOptions(agentRow);
|
|
10946
|
-
const systemPrompt =
|
|
10946
|
+
const systemPrompt = chunkHXLC56ZK_cjs.buildChatbotSystemPromptWithEmailTool(fromAgent.systemPrompt, parsedValidation.guardrailsForPrompt, emailTool);
|
|
10947
10947
|
const res = await llm.chatAgent({
|
|
10948
10948
|
...fromAgent,
|
|
10949
10949
|
systemPrompt: systemPrompt || void 0,
|
|
@@ -10964,7 +10964,7 @@ ${contextParts.join("\n\n")}` : "";
|
|
|
10964
10964
|
agentRow.systemInstruction?.trim(),
|
|
10965
10965
|
ragSystem
|
|
10966
10966
|
].filter(Boolean).join("\n\n");
|
|
10967
|
-
systemContent =
|
|
10967
|
+
systemContent = chunkHXLC56ZK_cjs.buildChatbotSystemPromptWithEmailTool(mergedBase || defaultSystem, parsedValidation.guardrailsForPrompt, emailTool) || defaultSystem;
|
|
10968
10968
|
} else {
|
|
10969
10969
|
systemContent = ragSystem || defaultSystem;
|
|
10970
10970
|
}
|
|
@@ -12066,6 +12066,7 @@ exports.UserDeviceToken = class UserDeviceToken {
|
|
|
12066
12066
|
chunkUSNT2KNT_cjs.__name(this, "UserDeviceToken");
|
|
12067
12067
|
}
|
|
12068
12068
|
id;
|
|
12069
|
+
/** Staff/vendor app store. Null for customer/marketplace tokens (membership is `vendor_customers`). */
|
|
12069
12070
|
vendorId;
|
|
12070
12071
|
vendor;
|
|
12071
12072
|
userId;
|
|
@@ -12086,13 +12087,15 @@ _ts_decorate2([
|
|
|
12086
12087
|
_ts_decorate2([
|
|
12087
12088
|
typeorm.Column({
|
|
12088
12089
|
type: "integer",
|
|
12089
|
-
name: "vendor_id"
|
|
12090
|
+
name: "vendor_id",
|
|
12091
|
+
nullable: true
|
|
12090
12092
|
}),
|
|
12091
|
-
_ts_metadata2("design:type",
|
|
12093
|
+
_ts_metadata2("design:type", Object)
|
|
12092
12094
|
], exports.UserDeviceToken.prototype, "vendorId", void 0);
|
|
12093
12095
|
_ts_decorate2([
|
|
12094
12096
|
typeorm.ManyToOne("Vendor", {
|
|
12095
|
-
onDelete: "CASCADE"
|
|
12097
|
+
onDelete: "CASCADE",
|
|
12098
|
+
nullable: true
|
|
12096
12099
|
}),
|
|
12097
12100
|
typeorm.JoinColumn({
|
|
12098
12101
|
name: "vendor_id"
|
|
@@ -12189,6 +12192,22 @@ exports.UserDeviceToken = _ts_decorate2([
|
|
|
12189
12192
|
], exports.UserDeviceToken);
|
|
12190
12193
|
|
|
12191
12194
|
// src/api/device-tokens-handlers.ts
|
|
12195
|
+
function parseRequiredPositiveInt(value, field) {
|
|
12196
|
+
const n = parseInt(String(value ?? "").trim(), 10);
|
|
12197
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
12198
|
+
return {
|
|
12199
|
+
error: `${field} must be a positive integer`
|
|
12200
|
+
};
|
|
12201
|
+
}
|
|
12202
|
+
return n;
|
|
12203
|
+
}
|
|
12204
|
+
chunkUSNT2KNT_cjs.__name(parseRequiredPositiveInt, "parseRequiredPositiveInt");
|
|
12205
|
+
function parseOptionalVendorId(value) {
|
|
12206
|
+
if (value == null) return null;
|
|
12207
|
+
if (typeof value === "string" && value.trim() === "") return null;
|
|
12208
|
+
return parseRequiredPositiveInt(value, "vendor_id");
|
|
12209
|
+
}
|
|
12210
|
+
chunkUSNT2KNT_cjs.__name(parseOptionalVendorId, "parseOptionalVendorId");
|
|
12192
12211
|
function createDeviceTokensHandlers(config) {
|
|
12193
12212
|
const { dataSource, entityMap, json } = config;
|
|
12194
12213
|
return /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(async function handleDeviceTokensApi(req, pathSegments) {
|
|
@@ -12200,7 +12219,7 @@ function createDeviceTokensHandlers(config) {
|
|
|
12200
12219
|
const title = body.title?.trim() || "Test Push Notification";
|
|
12201
12220
|
const msgBody = body.body?.trim() || "Firebase Push Notification setup is working!";
|
|
12202
12221
|
if (!token || token === "validate" || token === "validate_only") {
|
|
12203
|
-
const valRes = await validateFcmCredentials(dataSource, entityMap);
|
|
12222
|
+
const valRes = await chunkHXLC56ZK_cjs.validateFcmCredentials(dataSource, entityMap);
|
|
12204
12223
|
if (!valRes.success) {
|
|
12205
12224
|
return json({
|
|
12206
12225
|
success: false,
|
|
@@ -12217,7 +12236,7 @@ function createDeviceTokensHandlers(config) {
|
|
|
12217
12236
|
clientEmail: valRes.clientEmail
|
|
12218
12237
|
});
|
|
12219
12238
|
}
|
|
12220
|
-
const res = await
|
|
12239
|
+
const res = await chunkHXLC56ZK_cjs.sendFcmPushNotification(dataSource, entityMap, {
|
|
12221
12240
|
token,
|
|
12222
12241
|
title,
|
|
12223
12242
|
body: msgBody,
|
|
@@ -12260,18 +12279,28 @@ function createDeviceTokensHandlers(config) {
|
|
|
12260
12279
|
if (method === "POST") {
|
|
12261
12280
|
try {
|
|
12262
12281
|
const body = await req.json().catch(() => ({}));
|
|
12263
|
-
const
|
|
12264
|
-
const
|
|
12282
|
+
const vendorParsed = parseOptionalVendorId(body.vendor_id);
|
|
12283
|
+
const userParsed = parseRequiredPositiveInt(body.user_id, "user_id");
|
|
12265
12284
|
const token = body.token?.trim();
|
|
12266
12285
|
const platformRaw = body.platform?.trim().toLowerCase();
|
|
12267
|
-
if (
|
|
12286
|
+
if (vendorParsed !== null && typeof vendorParsed === "object") {
|
|
12268
12287
|
return json({
|
|
12269
12288
|
success: false,
|
|
12270
|
-
error:
|
|
12289
|
+
error: vendorParsed.error
|
|
12271
12290
|
}, {
|
|
12272
12291
|
status: 400
|
|
12273
12292
|
});
|
|
12274
12293
|
}
|
|
12294
|
+
if (typeof userParsed === "object" || !token || !platformRaw) {
|
|
12295
|
+
return json({
|
|
12296
|
+
success: false,
|
|
12297
|
+
error: (typeof userParsed === "object" ? userParsed.error : null) || "user_id, token, and platform (android|ios) are required"
|
|
12298
|
+
}, {
|
|
12299
|
+
status: 400
|
|
12300
|
+
});
|
|
12301
|
+
}
|
|
12302
|
+
const vendorId = vendorParsed;
|
|
12303
|
+
const userId = userParsed;
|
|
12275
12304
|
if (platformRaw !== "android" && platformRaw !== "ios") {
|
|
12276
12305
|
return json({
|
|
12277
12306
|
success: false,
|
|
@@ -12337,13 +12366,35 @@ function createDeviceTokensHandlers(config) {
|
|
|
12337
12366
|
if (method === "GET") {
|
|
12338
12367
|
try {
|
|
12339
12368
|
const url = new URL(req.url);
|
|
12340
|
-
const
|
|
12341
|
-
const
|
|
12369
|
+
const userIdRaw = url.searchParams.get("userId")?.trim();
|
|
12370
|
+
const vendorIdRaw = url.searchParams.get("vendorId")?.trim();
|
|
12342
12371
|
const whereCondition = {
|
|
12343
12372
|
isActive: true
|
|
12344
12373
|
};
|
|
12345
|
-
if (
|
|
12346
|
-
|
|
12374
|
+
if (userIdRaw) {
|
|
12375
|
+
const userId = parseRequiredPositiveInt(userIdRaw, "userId");
|
|
12376
|
+
if (typeof userId === "object") {
|
|
12377
|
+
return json({
|
|
12378
|
+
success: false,
|
|
12379
|
+
error: userId.error
|
|
12380
|
+
}, {
|
|
12381
|
+
status: 400
|
|
12382
|
+
});
|
|
12383
|
+
}
|
|
12384
|
+
whereCondition.userId = userId;
|
|
12385
|
+
}
|
|
12386
|
+
if (vendorIdRaw) {
|
|
12387
|
+
const vendorId = parseRequiredPositiveInt(vendorIdRaw, "vendorId");
|
|
12388
|
+
if (typeof vendorId === "object") {
|
|
12389
|
+
return json({
|
|
12390
|
+
success: false,
|
|
12391
|
+
error: vendorId.error
|
|
12392
|
+
}, {
|
|
12393
|
+
status: 400
|
|
12394
|
+
});
|
|
12395
|
+
}
|
|
12396
|
+
whereCondition.vendorId = vendorId;
|
|
12397
|
+
}
|
|
12347
12398
|
const tokens = await tokenRepo.find({
|
|
12348
12399
|
where: whereCondition,
|
|
12349
12400
|
order: {
|
|
@@ -12370,16 +12421,17 @@ function createDeviceTokensHandlers(config) {
|
|
|
12370
12421
|
if (method === "DELETE") {
|
|
12371
12422
|
try {
|
|
12372
12423
|
const body = await req.json().catch(() => ({}));
|
|
12373
|
-
const
|
|
12424
|
+
const userParsed = parseRequiredPositiveInt(body.user_id, "user_id");
|
|
12374
12425
|
const token = body.token?.trim();
|
|
12375
|
-
if (
|
|
12426
|
+
if (typeof userParsed === "object" || !token) {
|
|
12376
12427
|
return json({
|
|
12377
12428
|
success: false,
|
|
12378
|
-
error: "user_id and token are required to deactivate"
|
|
12429
|
+
error: (typeof userParsed === "object" ? userParsed.error : null) || "user_id and token are required to deactivate"
|
|
12379
12430
|
}, {
|
|
12380
12431
|
status: 400
|
|
12381
12432
|
});
|
|
12382
12433
|
}
|
|
12434
|
+
const userId = userParsed;
|
|
12383
12435
|
await tokenRepo.update({
|
|
12384
12436
|
userId,
|
|
12385
12437
|
token
|
|
@@ -13179,7 +13231,7 @@ async function sendVendorOnboardEmails(input, deps) {
|
|
|
13179
13231
|
getVendorEmails(deps)
|
|
13180
13232
|
]);
|
|
13181
13233
|
const companyDetails = chunkBXYZDMTZ_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings);
|
|
13182
|
-
const configuredNotify =
|
|
13234
|
+
const configuredNotify = chunkHXLC56ZK_cjs.parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
|
|
13183
13235
|
const ownerEmail = input.ownerEmail?.trim() || "";
|
|
13184
13236
|
const ownerEmailLower = ownerEmail.toLowerCase();
|
|
13185
13237
|
const sendToOwner = input.sendToOwner !== false;
|
|
@@ -27748,16 +27800,16 @@ function whatsappPlugin(config = {}) {
|
|
|
27748
27800
|
db = await getWhatsAppSettings?.() ?? {};
|
|
27749
27801
|
} catch {
|
|
27750
27802
|
}
|
|
27751
|
-
if (!
|
|
27803
|
+
if (!chunkHXLC56ZK_cjs.isWhatsAppPluginEnabled(db)) {
|
|
27752
27804
|
context.logger.warn("WhatsApp plugin skipped: disabled in Plugins \u2192 WhatsApp");
|
|
27753
27805
|
return null;
|
|
27754
27806
|
}
|
|
27755
|
-
const merged =
|
|
27756
|
-
if (!getWhatsAppSettings && !
|
|
27807
|
+
const merged = chunkHXLC56ZK_cjs.mergeWhatsAppConfigLayers(env, db, staticRest);
|
|
27808
|
+
if (!getWhatsAppSettings && !chunkHXLC56ZK_cjs.whatsAppConfigured(merged)) {
|
|
27757
27809
|
context.logger.warn("WhatsApp plugin skipped: set WHATSAPP_ACCESS_TOKEN and WHATSAPP_PHONE_NUMBER_ID, or pass getWhatsAppSettings");
|
|
27758
27810
|
return null;
|
|
27759
27811
|
}
|
|
27760
|
-
const svc = new
|
|
27812
|
+
const svc = new chunkHXLC56ZK_cjs.WhatsAppService(env, staticRest, getWhatsAppSettings, getMessageTemplateRow);
|
|
27761
27813
|
return {
|
|
27762
27814
|
send: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((opts) => svc.send(opts), "send")
|
|
27763
27815
|
};
|
|
@@ -27834,7 +27886,7 @@ function registerMessagingQueueProcessors(cms, entityMap) {
|
|
|
27834
27886
|
getDataSource: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(async () => cms.dataSource, "getDataSource"),
|
|
27835
27887
|
entityMap
|
|
27836
27888
|
});
|
|
27837
|
-
|
|
27889
|
+
chunkHXLC56ZK_cjs.registerWhatsAppQueueProcessor(cms);
|
|
27838
27890
|
}
|
|
27839
27891
|
chunkUSNT2KNT_cjs.__name(registerMessagingQueueProcessors, "registerMessagingQueueProcessors");
|
|
27840
27892
|
async function ensureMessagingPluginsOnCms(base, options) {
|
|
@@ -27863,7 +27915,7 @@ async function ensureMessagingPluginsOnCms(base, options) {
|
|
|
27863
27915
|
}
|
|
27864
27916
|
if (!cms.getPlugin("email")) {
|
|
27865
27917
|
try {
|
|
27866
|
-
const instance = await
|
|
27918
|
+
const instance = await chunkHXLC56ZK_cjs.emailPlugin({
|
|
27867
27919
|
type: "SMTP",
|
|
27868
27920
|
from: config.SMTP_FROM ?? "no-reply@localhost",
|
|
27869
27921
|
to: config.SMTP_TO ?? ""
|
|
@@ -27904,7 +27956,7 @@ function messagingPlugins(options) {
|
|
|
27904
27956
|
const config = options.config ?? (typeof process !== "undefined" ? process.env : {});
|
|
27905
27957
|
return [
|
|
27906
27958
|
queuePlugin(),
|
|
27907
|
-
|
|
27959
|
+
chunkHXLC56ZK_cjs.emailPlugin({
|
|
27908
27960
|
type: "SMTP",
|
|
27909
27961
|
from: config.SMTP_FROM ?? "no-reply@localhost",
|
|
27910
27962
|
to: config.SMTP_TO ?? ""
|
|
@@ -28038,7 +28090,7 @@ function createCmsApiHandler(config) {
|
|
|
28038
28090
|
} : void 0;
|
|
28039
28091
|
const entityMap = withLlmKnowledgeEntityFallbacks(rawEntityMap);
|
|
28040
28092
|
if (getCms) {
|
|
28041
|
-
|
|
28093
|
+
chunkHXLC56ZK_cjs.initWhatsappTriggerDispatcher({
|
|
28042
28094
|
dataSource,
|
|
28043
28095
|
entityMap,
|
|
28044
28096
|
getCms
|
|
@@ -29801,7 +29853,7 @@ function createCmsApiHandler(config) {
|
|
|
29801
29853
|
status: 400
|
|
29802
29854
|
});
|
|
29803
29855
|
}
|
|
29804
|
-
const { resendOrderNotification } = await import('./order-notification-dispatcher-
|
|
29856
|
+
const { resendOrderNotification } = await import('./order-notification-dispatcher-2FCZFZUD.cjs');
|
|
29805
29857
|
const result = await resendOrderNotification(triggerKey, orderId, {
|
|
29806
29858
|
dataSource,
|
|
29807
29859
|
entityMap,
|
|
@@ -1331,7 +1331,7 @@ function renderEmail(templateName, ctx, options) {
|
|
|
1331
1331
|
chunkUSNT2KNT_cjs.__name(renderEmail, "renderEmail");
|
|
1332
1332
|
|
|
1333
1333
|
// src/plugins/email/email-service.ts
|
|
1334
|
-
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
1334
|
+
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-HXLC56ZK.cjs', document.baseURI).href)));
|
|
1335
1335
|
var MailComposer = require2("nodemailer/lib/mail-composer");
|
|
1336
1336
|
var SES_REGIONS_WITHOUT_SMTP = /* @__PURE__ */ new Set([
|
|
1337
1337
|
"af-south-1",
|
|
@@ -2194,6 +2194,48 @@ async function sendFcmPushNotification(dataSource, entityMap, msg) {
|
|
|
2194
2194
|
}
|
|
2195
2195
|
}
|
|
2196
2196
|
chunkUSNT2KNT_cjs.__name(sendFcmPushNotification, "sendFcmPushNotification");
|
|
2197
|
+
async function validateFcmCredentials(dataSource, entityMap) {
|
|
2198
|
+
try {
|
|
2199
|
+
const pushSettings = await getSettingsGroup(dataSource, entityMap, "push");
|
|
2200
|
+
let projectId = pushSettings.firebase_project_id?.trim();
|
|
2201
|
+
let clientEmail = pushSettings.firebase_client_email?.trim();
|
|
2202
|
+
let privateKey = pushSettings.firebase_private_key?.trim();
|
|
2203
|
+
if (pushSettings.firebase_service_account_json?.trim()) {
|
|
2204
|
+
try {
|
|
2205
|
+
const parsed = JSON.parse(pushSettings.firebase_service_account_json.trim());
|
|
2206
|
+
if (parsed.project_id) projectId = parsed.project_id;
|
|
2207
|
+
if (parsed.client_email) clientEmail = parsed.client_email;
|
|
2208
|
+
if (parsed.private_key) privateKey = parsed.private_key;
|
|
2209
|
+
} catch {
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
if (!projectId || !clientEmail || !privateKey) {
|
|
2213
|
+
return {
|
|
2214
|
+
success: false,
|
|
2215
|
+
error: "Firebase Service Account JSON / credentials are not configured in settings"
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
const token = await getGoogleAccessToken(clientEmail, privateKey);
|
|
2219
|
+
if (!token) {
|
|
2220
|
+
return {
|
|
2221
|
+
success: false,
|
|
2222
|
+
error: "Failed to obtain Google OAuth access token"
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
return {
|
|
2226
|
+
success: true,
|
|
2227
|
+
projectId,
|
|
2228
|
+
clientEmail
|
|
2229
|
+
};
|
|
2230
|
+
} catch (err) {
|
|
2231
|
+
const msg = err instanceof Error ? err.message : "Credential validation failed";
|
|
2232
|
+
return {
|
|
2233
|
+
success: false,
|
|
2234
|
+
error: msg
|
|
2235
|
+
};
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
chunkUSNT2KNT_cjs.__name(validateFcmCredentials, "validateFcmCredentials");
|
|
2197
2239
|
|
|
2198
2240
|
// src/lib/order-notification-dispatcher.ts
|
|
2199
2241
|
var initialized = false;
|
|
@@ -2876,4 +2918,5 @@ exports.resolveChatEmailToolSettings = resolveChatEmailToolSettings;
|
|
|
2876
2918
|
exports.sendChatLeadEmail = sendChatLeadEmail;
|
|
2877
2919
|
exports.sendFcmPushNotification = sendFcmPushNotification;
|
|
2878
2920
|
exports.serializeEmailRecipients = serializeEmailRecipients;
|
|
2921
|
+
exports.validateFcmCredentials = validateFcmCredentials;
|
|
2879
2922
|
exports.whatsAppConfigured = whatsAppConfigured;
|
|
@@ -2168,6 +2168,48 @@ async function sendFcmPushNotification(dataSource, entityMap, msg) {
|
|
|
2168
2168
|
}
|
|
2169
2169
|
}
|
|
2170
2170
|
__name(sendFcmPushNotification, "sendFcmPushNotification");
|
|
2171
|
+
async function validateFcmCredentials(dataSource, entityMap) {
|
|
2172
|
+
try {
|
|
2173
|
+
const pushSettings = await getSettingsGroup(dataSource, entityMap, "push");
|
|
2174
|
+
let projectId = pushSettings.firebase_project_id?.trim();
|
|
2175
|
+
let clientEmail = pushSettings.firebase_client_email?.trim();
|
|
2176
|
+
let privateKey = pushSettings.firebase_private_key?.trim();
|
|
2177
|
+
if (pushSettings.firebase_service_account_json?.trim()) {
|
|
2178
|
+
try {
|
|
2179
|
+
const parsed = JSON.parse(pushSettings.firebase_service_account_json.trim());
|
|
2180
|
+
if (parsed.project_id) projectId = parsed.project_id;
|
|
2181
|
+
if (parsed.client_email) clientEmail = parsed.client_email;
|
|
2182
|
+
if (parsed.private_key) privateKey = parsed.private_key;
|
|
2183
|
+
} catch {
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
if (!projectId || !clientEmail || !privateKey) {
|
|
2187
|
+
return {
|
|
2188
|
+
success: false,
|
|
2189
|
+
error: "Firebase Service Account JSON / credentials are not configured in settings"
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
const token = await getGoogleAccessToken(clientEmail, privateKey);
|
|
2193
|
+
if (!token) {
|
|
2194
|
+
return {
|
|
2195
|
+
success: false,
|
|
2196
|
+
error: "Failed to obtain Google OAuth access token"
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
return {
|
|
2200
|
+
success: true,
|
|
2201
|
+
projectId,
|
|
2202
|
+
clientEmail
|
|
2203
|
+
};
|
|
2204
|
+
} catch (err) {
|
|
2205
|
+
const msg = err instanceof Error ? err.message : "Credential validation failed";
|
|
2206
|
+
return {
|
|
2207
|
+
success: false,
|
|
2208
|
+
error: msg
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
__name(validateFcmCredentials, "validateFcmCredentials");
|
|
2171
2213
|
|
|
2172
2214
|
// src/lib/order-notification-dispatcher.ts
|
|
2173
2215
|
var initialized = false;
|
|
@@ -2825,4 +2867,4 @@ async function resendOrderNotification(triggerKey, orderId, deps) {
|
|
|
2825
2867
|
}
|
|
2826
2868
|
__name(resendOrderNotification, "resendOrderNotification");
|
|
2827
2869
|
|
|
2828
|
-
export { CHAT_EMAIL_LOG, EmailService, WhatsAppService, buildChatbotSystemPromptWithEmailTool, buildEventOrderTemplateVariables, buildTranscriptForLeadEmail, detectChatLeadIntent, emailPlugin, emailTemplates, getSettingsGroup, initWhatsappTriggerDispatcher, isWhatsAppPluginEnabled, joinRecipientsForSend, mergeWhatsAppConfigLayers, parseEmailRecipientsFromConfig, parseIntentRecipientEmails, queueWhatsApp, registerWhatsAppQueueProcessor, renderEmail, renderLayout, resendOrderNotification, resolveChatEmailToolSettings, sendChatLeadEmail, sendFcmPushNotification, serializeEmailRecipients, whatsAppConfigured };
|
|
2870
|
+
export { CHAT_EMAIL_LOG, EmailService, WhatsAppService, buildChatbotSystemPromptWithEmailTool, buildEventOrderTemplateVariables, buildTranscriptForLeadEmail, detectChatLeadIntent, emailPlugin, emailTemplates, getSettingsGroup, initWhatsappTriggerDispatcher, isWhatsAppPluginEnabled, joinRecipientsForSend, mergeWhatsAppConfigLayers, parseEmailRecipientsFromConfig, parseIntentRecipientEmails, queueWhatsApp, registerWhatsAppQueueProcessor, renderEmail, renderLayout, resendOrderNotification, resolveChatEmailToolSettings, sendChatLeadEmail, sendFcmPushNotification, serializeEmailRecipients, validateFcmCredentials, whatsAppConfigured };
|