@infuro/cms-core 1.0.68 → 1.0.69
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/{OrderTrackPage-W3J6WIG2.js → OrderTrackPage-VBZUVZOU.js} +1 -1
- package/dist/{OrderTrackPage-Z6FCJQYY.cjs → OrderTrackPage-VFIXWJOW.cjs} +4 -4
- package/dist/admin.cjs +1 -1
- package/dist/admin.js +1 -1
- package/dist/api.cjs +57 -57
- package/dist/api.js +24 -24
- package/dist/auth.cjs +62 -62
- package/dist/auth.js +6 -6
- package/dist/{chunk-XJNNOSJR.js → chunk-2BNVRFUQ.js} +1 -1
- package/dist/chunk-2JHGIWH7.cjs +2700 -0
- package/dist/{chunk-3DZRIZOD.cjs → chunk-3ASNJS2H.cjs} +3 -3
- package/dist/{chunk-7NMT3GBR.cjs → chunk-3LQS4ATQ.cjs} +4 -4
- package/dist/{chunk-GWDI752Q.js → chunk-3XCTGADT.js} +1 -1
- package/dist/{chunk-P6S4XFZO.cjs → chunk-47G65M5Q.cjs} +2 -2
- package/dist/{chunk-UMC7W5G3.cjs → chunk-4MNVIGVJ.cjs} +11 -11
- package/dist/{chunk-OY2YTBMP.cjs → chunk-4WZNRVEZ.cjs} +3 -3
- package/dist/{chunk-OVTOP42W.js → chunk-53AMBXMM.js} +1 -1
- package/dist/chunk-5BKT4CS5.js +28 -0
- package/dist/{chunk-IKTBZJHT.js → chunk-5DSY3GQI.js} +1 -1
- package/dist/{chunk-AYERBA7I.js → chunk-5NVGWJSY.js} +1 -1
- package/dist/{chunk-HF3L2GIT.cjs → chunk-5YMKJ3TH.cjs} +16 -16
- package/dist/{chunk-WFMVD567.cjs → chunk-6MM5OMRL.cjs} +11 -11
- package/dist/{chunk-SMHQV3WL.cjs → chunk-747MJJCZ.cjs} +147 -147
- package/dist/{chunk-SYBOCAWB.js → chunk-7QJI56OL.js} +1 -1
- package/dist/{chunk-DBPSJYLZ.js → chunk-BK5XW5XH.js} +1 -1
- package/dist/{chunk-SUUD7OUG.cjs → chunk-BQQMTQ4C.cjs} +27 -27
- package/dist/{chunk-6YOQ7G5O.js → chunk-CFUSYGSA.js} +1 -1
- package/dist/{chunk-OOTLNH63.cjs → chunk-CIZZX57T.cjs} +2 -2
- package/dist/{chunk-7L6KWI7S.cjs → chunk-CTTV375J.cjs} +13 -13
- package/dist/{chunk-ZY64VJMS.js → chunk-D4LR3S77.js} +2 -2
- package/dist/{chunk-MYUGQHU4.js → chunk-DBBYLSQP.js} +47 -47
- package/dist/{chunk-5NOZSG6J.js → chunk-DWNQTFJ5.js} +2 -2
- package/dist/{chunk-2IAXTKQN.cjs → chunk-DZNWS2MM.cjs} +2 -2
- package/dist/{chunk-M5GPOPGX.cjs → chunk-E62LKM6Z.cjs} +2 -2
- package/dist/{chunk-CRFV5WJK.js → chunk-ECNYZG6T.js} +1 -1
- package/dist/{chunk-TZEMLHSP.cjs → chunk-EYUBL7YH.cjs} +7 -7
- package/dist/{chunk-GN4LKG4V.cjs → chunk-HGR4IA7I.cjs} +18 -18
- package/dist/{chunk-TJ2MIQUT.cjs → chunk-JRW3GQD4.cjs} +4 -4
- package/dist/{chunk-3K5AIEIZ.js → chunk-JYRFSFXH.js} +1 -1
- package/dist/{chunk-WKDBMDUX.js → chunk-K6RXCLD5.js} +1 -1
- package/dist/{chunk-7JCCPQEF.js → chunk-LJ5C4RBF.js} +3 -3
- package/dist/{chunk-O4AFPDQ4.cjs → chunk-LXWF6T7F.cjs} +33 -33
- package/dist/{chunk-EIZKW2PF.js → chunk-LY7CDNC6.js} +1 -1
- package/dist/{chunk-PA6YDMFZ.cjs → chunk-M5QDJOUP.cjs} +12 -12
- package/dist/{chunk-MQBT33IV.js → chunk-MGT4DJ2D.js} +1 -1
- package/dist/{chunk-Z5G54EGD.js → chunk-MJDNS324.js} +5 -5
- package/dist/{chunk-H3IVLIPR.cjs → chunk-OXFC3DAM.cjs} +4 -4
- package/dist/{chunk-ZIT4IP6N.js → chunk-PQJIJ4ZX.js} +6 -6
- package/dist/{chunk-HY3AXLOI.cjs → chunk-PRXVSSIF.cjs} +13 -13
- package/dist/{chunk-TDV6EJHV.js → chunk-PRZOLCFW.js} +2 -2
- package/dist/{chunk-22XKONB5.cjs → chunk-QL44NCZC.cjs} +1089 -1089
- package/dist/{chunk-VM6OVUUM.cjs → chunk-QN6PZLAP.cjs} +40 -40
- package/dist/{chunk-OV5TRZET.cjs → chunk-QXAQ3V7R.cjs} +27 -27
- package/dist/{chunk-N4LBZXBG.js → chunk-RBKVMHBH.js} +9 -9
- package/dist/{chunk-UPLVMVRX.cjs → chunk-RQCXRCYM.cjs} +2 -2
- package/dist/{chunk-WUQAOTHA.js → chunk-SERRQ736.js} +1 -1
- package/dist/{chunk-HBUV73RB.cjs → chunk-SWSTGV4F.cjs} +81 -81
- package/dist/{chunk-SKJH7PX4.js → chunk-T47VP2ZT.js} +3 -3
- package/dist/{chunk-FLUF2GZH.js → chunk-WHMIWJL7.js} +1 -1
- package/dist/{chunk-JC6DLWTE.js → chunk-WQZ4AH2P.js} +1 -1
- package/dist/{chunk-D5FBNKQM.cjs → chunk-WXH3GMCF.cjs} +8 -8
- package/dist/chunk-XHPRD45G.cjs +32 -0
- package/dist/{chunk-THL5JDWJ.cjs → chunk-Y54WDY2O.cjs} +2 -2
- package/dist/{chunk-YRCKEGL2.js → chunk-YDMHG6BA.js} +1 -1
- package/dist/chunk-YHVA5NHI.js +2698 -0
- package/dist/{chunk-JXF23MPG.js → chunk-ZMIMKNSQ.js} +1 -1
- package/dist/cli.cjs +10 -10
- package/dist/cli.js +1 -1
- package/dist/email-queue-BJDH2ID7.cjs +29 -0
- package/dist/email-queue-MWP4R67H.js +8 -0
- package/dist/email-service-6JODEMUA.js +3 -0
- package/dist/email-service-VA4Q4ZRB.cjs +28 -0
- package/dist/emit-order-notification-trigger-X36V4DOH.cjs +16 -0
- package/dist/emit-order-notification-trigger-XKN2TWVF.js +3 -0
- package/dist/erp-config-enabled-32XTHBBT.cjs +11 -0
- package/dist/erp-config-enabled-CASE5YVI.js +2 -0
- package/dist/erp-order-invoice-5O42ZKC5.cjs +28 -0
- package/dist/erp-order-invoice-JEQKFXG4.js +7 -0
- package/dist/{event-order-defaults-DU7V3YND.cjs → event-order-defaults-TR45WAQQ.cjs} +10 -10
- package/dist/{event-order-defaults-H4RT7NMR.js → event-order-defaults-VXYO6NHT.js} +2 -2
- package/dist/generate-local-invoice-pdf-2NCA2WBL.cjs +12 -0
- package/dist/generate-local-invoice-pdf-XUH6GYEJ.js +3 -0
- package/dist/hooks.cjs +24 -24
- package/dist/hooks.js +2 -2
- package/dist/index.cjs +470 -470
- package/dist/index.js +39 -39
- package/dist/interpolate-KD37IRF2.js +2 -0
- package/dist/interpolate-WP6OSJHN.cjs +11 -0
- package/dist/{invoice-templates-RB462AQN.cjs → invoice-templates-2ESQ7K4N.cjs} +5 -5
- package/dist/invoice-templates-3AXTXERZ.js +2 -0
- package/dist/middleware.cjs +4 -4
- package/dist/middleware.js +2 -2
- package/dist/{order-assignees-handlers-L3RVKUBS.js → order-assignees-handlers-F7WOZHOG.js} +1 -1
- package/dist/{order-assignees-handlers-KF7RMTV5.cjs → order-assignees-handlers-JEJ5IDID.cjs} +3 -3
- package/dist/{order-completion-otp-handlers-NROWBGXN.js → order-completion-otp-handlers-FIW7PZ6W.js} +12 -12
- package/dist/{order-completion-otp-handlers-DDQREULW.cjs → order-completion-otp-handlers-LNAZTMTS.cjs} +25 -25
- package/dist/{order-inventory-76V4XIGW.js → order-inventory-R3AU6N4V.js} +2 -2
- package/dist/{order-inventory-2MYRKEPC.cjs → order-inventory-UUFPWLBW.cjs} +10 -10
- package/dist/order-notification-dispatcher-FS54ANAV.js +13 -0
- package/dist/order-notification-dispatcher-GG5C4LKZ.cjs +38 -0
- package/dist/paid-order-erp-GRXR2OG6.js +3 -0
- package/dist/paid-order-erp-X5QHPI23.cjs +12 -0
- package/dist/pg-boss-service-CMW3KQJM.js +2 -0
- package/dist/pg-boss-service-GA6ZVD5G.cjs +15 -0
- package/dist/{razorpay-U23LGY72.cjs → razorpay-GP2DXVP2.cjs} +2 -2
- package/dist/{razorpay-KLO2KNCB.js → razorpay-I3G5LNYH.js} +1 -1
- package/dist/{rbac-debug-db-KWV7D5PQ.cjs → rbac-debug-db-2ZI3XKA4.cjs} +4 -4
- package/dist/{rbac-debug-db-DFZWZ6GV.js → rbac-debug-db-IRKT6G62.js} +2 -2
- package/dist/resolve-invoice-asset-url-64QQUVC3.js +2 -0
- package/dist/resolve-invoice-asset-url-J7WAMD26.cjs +11 -0
- package/dist/retire-soft-deleted-unique-DZALT537.cjs +15 -0
- package/dist/{retire-soft-deleted-unique-NXQIH4BC.js → retire-soft-deleted-unique-F25KZBZK.js} +2 -2
- package/dist/sms-defaults-DSO3M26Y.js +2 -0
- package/dist/{sms-defaults-KCOPKQBA.cjs → sms-defaults-GDFILHHR.cjs} +5 -5
- package/dist/{sms-notification-templates-handlers-SJLO7JGZ.js → sms-notification-templates-handlers-ZGDCVS5Z.js} +1 -1
- package/dist/{sms-notification-templates-handlers-YSB3L2PK.cjs → sms-notification-templates-handlers-ZKLKFRFZ.cjs} +3 -3
- package/dist/{stripe-VU6OEG2D.cjs → stripe-2APRZHKU.cjs} +2 -2
- package/dist/{stripe-4FD27QVJ.js → stripe-7CO2ETTN.js} +1 -1
- package/dist/theme.cjs +10 -10
- package/dist/theme.js +3 -3
- package/dist/vendor-invite-status-45ZCWKCX.js +2 -0
- package/dist/{vendor-invite-status-77O7ZQ3U.cjs → vendor-invite-status-AT2E4FUA.cjs} +5 -5
- package/package.json +2 -1
- package/dist/chunk-SHUYVCID.js +0 -4
- package/dist/chunk-USNT2KNT.cjs +0 -6
- package/dist/chunk-Z5OB5QGN.js +0 -465
- package/dist/chunk-ZX5U3VCB.cjs +0 -471
- package/dist/email-queue-3QBQ63F7.js +0 -8
- package/dist/email-queue-K4E4OFI7.cjs +0 -29
- package/dist/email-service-5O24BSFR.cjs +0 -28
- package/dist/email-service-ADDF52PJ.js +0 -3
- package/dist/emit-order-notification-trigger-ROASTYQP.cjs +0 -16
- package/dist/emit-order-notification-trigger-YUQTPELC.js +0 -3
- package/dist/erp-config-enabled-CUMQ6N2V.cjs +0 -11
- package/dist/erp-config-enabled-T37X7T34.js +0 -2
- package/dist/erp-order-invoice-AZ5MX2JB.cjs +0 -28
- package/dist/erp-order-invoice-XSYHAMBS.js +0 -7
- package/dist/generate-local-invoice-pdf-BQTCL5MW.cjs +0 -12
- package/dist/generate-local-invoice-pdf-OCFG47SE.js +0 -3
- package/dist/interpolate-WAKPN56R.cjs +0 -11
- package/dist/interpolate-WDUWDF3I.js +0 -2
- package/dist/invoice-templates-GZ33OENC.js +0 -2
- package/dist/order-notification-dispatcher-6HCJ6Q75.cjs +0 -38
- package/dist/order-notification-dispatcher-KM2SY7TX.js +0 -13
- package/dist/paid-order-erp-3USEG6WL.js +0 -3
- package/dist/paid-order-erp-FSQ3GSXE.cjs +0 -12
- package/dist/pg-boss-service-BDGOKM2T.cjs +0 -15
- package/dist/pg-boss-service-WCBJD4JB.js +0 -2
- package/dist/resolve-invoice-asset-url-JEZRENJW.cjs +0 -11
- package/dist/resolve-invoice-asset-url-QZ2FRDHI.js +0 -2
- package/dist/retire-soft-deleted-unique-5VXBA5XX.cjs +0 -15
- package/dist/sms-defaults-2NL24H57.js +0 -2
- package/dist/vendor-invite-status-PWJ3DE76.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
3
|
+
var chunkOXFC3DAM_cjs = require('./chunk-OXFC3DAM.cjs');
|
|
4
|
+
var chunkM5QDJOUP_cjs = require('./chunk-M5QDJOUP.cjs');
|
|
5
|
+
var chunkCIZZX57T_cjs = require('./chunk-CIZZX57T.cjs');
|
|
6
|
+
var chunkQN6PZLAP_cjs = require('./chunk-QN6PZLAP.cjs');
|
|
7
|
+
var chunk4MNVIGVJ_cjs = require('./chunk-4MNVIGVJ.cjs');
|
|
8
|
+
var chunkEYUBL7YH_cjs = require('./chunk-EYUBL7YH.cjs');
|
|
9
|
+
var chunkXHPRD45G_cjs = require('./chunk-XHPRD45G.cjs');
|
|
10
10
|
var crypto = require('crypto');
|
|
11
11
|
|
|
12
12
|
function _interopNamespace(e) {
|
|
@@ -39,7 +39,7 @@ function resolvePublicSiteUrl() {
|
|
|
39
39
|
}
|
|
40
40
|
return "";
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
chunkXHPRD45G_cjs.__name(resolvePublicSiteUrl, "resolvePublicSiteUrl");
|
|
43
43
|
function buildOrderTrackUrl(qrToken, siteUrl, orderNumber) {
|
|
44
44
|
const token = qrToken?.trim() || orderNumber?.trim();
|
|
45
45
|
if (!token) return "";
|
|
@@ -47,7 +47,7 @@ function buildOrderTrackUrl(qrToken, siteUrl, orderNumber) {
|
|
|
47
47
|
if (!base) return `/track/${token}`;
|
|
48
48
|
return `${base}/track/${token}`;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
chunkXHPRD45G_cjs.__name(buildOrderTrackUrl, "buildOrderTrackUrl");
|
|
51
51
|
function formatOrderDetailsText(input) {
|
|
52
52
|
const { orderNumber, total, currency, lines } = input;
|
|
53
53
|
const header = `Order: ${orderNumber}
|
|
@@ -59,13 +59,13 @@ Total: ${total} ${currency}`;
|
|
|
59
59
|
Items:
|
|
60
60
|
${items}`;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
chunkXHPRD45G_cjs.__name(formatOrderDetailsText, "formatOrderDetailsText");
|
|
63
63
|
function formatOrderDetailsHtml(input) {
|
|
64
64
|
const text = formatOrderDetailsText(input);
|
|
65
65
|
const escaped = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
66
66
|
return `<pre style="font-family:inherit;white-space:pre-wrap;margin:0">${escaped}</pre>`;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
chunkXHPRD45G_cjs.__name(formatOrderDetailsHtml, "formatOrderDetailsHtml");
|
|
69
69
|
function buildEventOrderTemplateVariables(input) {
|
|
70
70
|
const { event, order, contact, productNames, vendorName = "", orderLines = [], siteUrl } = input;
|
|
71
71
|
const trackUrl = buildOrderTrackUrl(order.qrToken, siteUrl, order.orderNumber);
|
|
@@ -103,7 +103,7 @@ function buildEventOrderTemplateVariables(input) {
|
|
|
103
103
|
orderDetailsHtml: formatOrderDetailsHtml(orderDetailsPayload)
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
chunkXHPRD45G_cjs.__name(buildEventOrderTemplateVariables, "buildEventOrderTemplateVariables");
|
|
107
107
|
function formatEventDate(d) {
|
|
108
108
|
if (!d) return "";
|
|
109
109
|
try {
|
|
@@ -115,7 +115,7 @@ function formatEventDate(d) {
|
|
|
115
115
|
return String(d);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
chunkXHPRD45G_cjs.__name(formatEventDate, "formatEventDate");
|
|
119
119
|
|
|
120
120
|
// src/lib/order-notification-context.ts
|
|
121
121
|
async function loadOrderLines(dataSource, entityMap, orderId, currency) {
|
|
@@ -142,7 +142,7 @@ async function loadOrderLines(dataSource, entityMap, orderId, currency) {
|
|
|
142
142
|
};
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
chunkXHPRD45G_cjs.__name(loadOrderLines, "loadOrderLines");
|
|
146
146
|
async function loadPrimaryEvent(dataSource, entityMap, itemRows) {
|
|
147
147
|
if (!entityMap.event_products || !entityMap.events) {
|
|
148
148
|
return {
|
|
@@ -195,7 +195,7 @@ async function loadPrimaryEvent(dataSource, entityMap, itemRows) {
|
|
|
195
195
|
productNames: first.productNames
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
chunkXHPRD45G_cjs.__name(loadPrimaryEvent, "loadPrimaryEvent");
|
|
199
199
|
async function isFeatureGroupEnabled(dataSource, entityMap, group) {
|
|
200
200
|
if (!entityMap.configs) return true;
|
|
201
201
|
try {
|
|
@@ -214,7 +214,7 @@ async function isFeatureGroupEnabled(dataSource, entityMap, group) {
|
|
|
214
214
|
return true;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
chunkXHPRD45G_cjs.__name(isFeatureGroupEnabled, "isFeatureGroupEnabled");
|
|
218
218
|
async function loadOrderNotificationContexts(orderId, deps) {
|
|
219
219
|
if (!deps.entityMap.orders) return null;
|
|
220
220
|
const order = await deps.dataSource.getRepository(deps.entityMap.orders).findOne({
|
|
@@ -358,7 +358,7 @@ async function loadOrderNotificationContexts(orderId, deps) {
|
|
|
358
358
|
variables
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
-
|
|
361
|
+
chunkXHPRD45G_cjs.__name(loadOrderNotificationContexts, "loadOrderNotificationContexts");
|
|
362
362
|
function formatScheduleDate(val) {
|
|
363
363
|
if (!val || typeof val !== "string" && !(val instanceof Date)) return "";
|
|
364
364
|
const str = String(val).trim();
|
|
@@ -368,14 +368,14 @@ function formatScheduleDate(val) {
|
|
|
368
368
|
dateStyle: "medium"
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
|
-
|
|
371
|
+
chunkXHPRD45G_cjs.__name(formatScheduleDate, "formatScheduleDate");
|
|
372
372
|
|
|
373
373
|
// src/plugins/whatsapp/whatsapp-service.ts
|
|
374
374
|
function norm(v) {
|
|
375
375
|
const t = v?.trim();
|
|
376
376
|
return t || void 0;
|
|
377
377
|
}
|
|
378
|
-
|
|
378
|
+
chunkXHPRD45G_cjs.__name(norm, "norm");
|
|
379
379
|
function pick(plugin, db, env, ...keys) {
|
|
380
380
|
for (const key of keys) {
|
|
381
381
|
const pk = key;
|
|
@@ -388,7 +388,7 @@ function pick(plugin, db, env, ...keys) {
|
|
|
388
388
|
}
|
|
389
389
|
return void 0;
|
|
390
390
|
}
|
|
391
|
-
|
|
391
|
+
chunkXHPRD45G_cjs.__name(pick, "pick");
|
|
392
392
|
function mergeWhatsAppConfigLayers(env, db, plugin) {
|
|
393
393
|
return {
|
|
394
394
|
accessToken: pick(plugin, db, env, "accessToken", "WHATSAPP_ACCESS_TOKEN"),
|
|
@@ -396,21 +396,21 @@ function mergeWhatsAppConfigLayers(env, db, plugin) {
|
|
|
396
396
|
apiVersion: pick(plugin, db, env, "apiVersion", "WHATSAPP_API_VERSION") ?? "v21.0"
|
|
397
397
|
};
|
|
398
398
|
}
|
|
399
|
-
|
|
399
|
+
chunkXHPRD45G_cjs.__name(mergeWhatsAppConfigLayers, "mergeWhatsAppConfigLayers");
|
|
400
400
|
function isWhatsAppPluginEnabled(db) {
|
|
401
401
|
const v = (db.enabled ?? "true").toLowerCase();
|
|
402
402
|
return v !== "false" && v !== "0";
|
|
403
403
|
}
|
|
404
|
-
|
|
404
|
+
chunkXHPRD45G_cjs.__name(isWhatsAppPluginEnabled, "isWhatsAppPluginEnabled");
|
|
405
405
|
function whatsAppConfigured(config) {
|
|
406
406
|
return Boolean(config.accessToken?.trim() && config.phoneNumberId?.trim());
|
|
407
407
|
}
|
|
408
|
-
|
|
408
|
+
chunkXHPRD45G_cjs.__name(whatsAppConfigured, "whatsAppConfigured");
|
|
409
409
|
function normalizeWhatsAppRecipient(to) {
|
|
410
410
|
const digits = to.replace(/\D/g, "");
|
|
411
411
|
return digits;
|
|
412
412
|
}
|
|
413
|
-
|
|
413
|
+
chunkXHPRD45G_cjs.__name(normalizeWhatsAppRecipient, "normalizeWhatsAppRecipient");
|
|
414
414
|
function resolveMetaWhatsAppTemplateName(opts) {
|
|
415
415
|
const ref = opts.externalTemplateRef?.trim();
|
|
416
416
|
const rowName = opts.name?.trim();
|
|
@@ -418,22 +418,22 @@ function resolveMetaWhatsAppTemplateName(opts) {
|
|
|
418
418
|
if (rowName) return rowName;
|
|
419
419
|
return ref || void 0;
|
|
420
420
|
}
|
|
421
|
-
|
|
421
|
+
chunkXHPRD45G_cjs.__name(resolveMetaWhatsAppTemplateName, "resolveMetaWhatsAppTemplateName");
|
|
422
422
|
function maskPhone(digits) {
|
|
423
423
|
if (digits.length <= 4) return "****";
|
|
424
424
|
return `${"*".repeat(Math.max(0, digits.length - 4))}${digits.slice(-4)}`;
|
|
425
425
|
}
|
|
426
|
-
|
|
426
|
+
chunkXHPRD45G_cjs.__name(maskPhone, "maskPhone");
|
|
427
427
|
function logWhatsApp(level, message, extra) {
|
|
428
428
|
const line = extra ? `${message} ${JSON.stringify(extra)}` : message;
|
|
429
429
|
if (level === "info") console.log(`[whatsapp] ${line}`);
|
|
430
430
|
else if (level === "warn") console.warn(`[whatsapp] ${line}`);
|
|
431
431
|
else console.error(`[whatsapp] ${line}`);
|
|
432
432
|
}
|
|
433
|
-
|
|
433
|
+
chunkXHPRD45G_cjs.__name(logWhatsApp, "logWhatsApp");
|
|
434
434
|
var WhatsAppService = class {
|
|
435
435
|
static {
|
|
436
|
-
|
|
436
|
+
chunkXHPRD45G_cjs.__name(this, "WhatsAppService");
|
|
437
437
|
}
|
|
438
438
|
getWhatsAppSettings;
|
|
439
439
|
config;
|
|
@@ -477,7 +477,7 @@ var WhatsAppService = class {
|
|
|
477
477
|
let body = opts.body?.trim() ?? "";
|
|
478
478
|
const variables = opts.variables ?? {};
|
|
479
479
|
if (opts.templateKey?.trim() && this.getMessageTemplateRow) {
|
|
480
|
-
const { resolveEventOrderTemplate, EVENT_ORDER_TEMPLATE_KEY } = await import('./event-order-defaults-
|
|
480
|
+
const { resolveEventOrderTemplate, EVENT_ORDER_TEMPLATE_KEY } = await import('./event-order-defaults-TR45WAQQ.cjs');
|
|
481
481
|
if (opts.templateKey.trim() === EVENT_ORDER_TEMPLATE_KEY) {
|
|
482
482
|
const resolved = await resolveEventOrderTemplate("whatsapp", async (ch, key) => {
|
|
483
483
|
const row = await this.getMessageTemplateRow(ch, key);
|
|
@@ -501,7 +501,7 @@ var WhatsAppService = class {
|
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
const { applyTemplateVars: applyTemplateVars2 } = await import('./interpolate-
|
|
504
|
+
const { applyTemplateVars: applyTemplateVars2 } = await import('./interpolate-WP6OSJHN.cjs');
|
|
505
505
|
if (body) body = applyTemplateVars2(body, variables);
|
|
506
506
|
if (templateName) {
|
|
507
507
|
const paramValues = opts.templateParamOrder?.length ? opts.templateParamOrder.map((key) => String(variables[key] ?? "").slice(0, 1024)) : Object.keys(variables).length ? Object.values(variables) : body ? [
|
|
@@ -629,16 +629,16 @@ function parseEmailRecipientsFromConfig(raw) {
|
|
|
629
629
|
}
|
|
630
630
|
return trimmed.split(/[,;]+/).map((s) => s.trim()).filter(Boolean);
|
|
631
631
|
}
|
|
632
|
-
|
|
632
|
+
chunkXHPRD45G_cjs.__name(parseEmailRecipientsFromConfig, "parseEmailRecipientsFromConfig");
|
|
633
633
|
function serializeEmailRecipients(emails) {
|
|
634
634
|
return JSON.stringify(emails);
|
|
635
635
|
}
|
|
636
|
-
|
|
636
|
+
chunkXHPRD45G_cjs.__name(serializeEmailRecipients, "serializeEmailRecipients");
|
|
637
637
|
function joinRecipientsForSend(emails) {
|
|
638
638
|
if (!emails.length) return null;
|
|
639
639
|
return emails.join(", ");
|
|
640
640
|
}
|
|
641
|
-
|
|
641
|
+
chunkXHPRD45G_cjs.__name(joinRecipientsForSend, "joinRecipientsForSend");
|
|
642
642
|
|
|
643
643
|
// src/plugins/llm/chat-email-intent.ts
|
|
644
644
|
var NONE_INTENT = "NONE";
|
|
@@ -650,11 +650,11 @@ function logChatEmail(step, data) {
|
|
|
650
650
|
console.info(CHAT_EMAIL_LOG, step);
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
|
-
|
|
653
|
+
chunkXHPRD45G_cjs.__name(logChatEmail, "logChatEmail");
|
|
654
654
|
function normalizeIntentKey(raw) {
|
|
655
655
|
return raw.trim().toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
656
656
|
}
|
|
657
|
-
|
|
657
|
+
chunkXHPRD45G_cjs.__name(normalizeIntentKey, "normalizeIntentKey");
|
|
658
658
|
function parseIntentsJson(raw) {
|
|
659
659
|
if (!raw?.trim()) return null;
|
|
660
660
|
try {
|
|
@@ -679,7 +679,7 @@ function parseIntentsJson(raw) {
|
|
|
679
679
|
return null;
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
|
-
|
|
682
|
+
chunkXHPRD45G_cjs.__name(parseIntentsJson, "parseIntentsJson");
|
|
683
683
|
function dedupeIntents(intents) {
|
|
684
684
|
const seen = /* @__PURE__ */ new Set();
|
|
685
685
|
const out = [];
|
|
@@ -695,7 +695,7 @@ function dedupeIntents(intents) {
|
|
|
695
695
|
}
|
|
696
696
|
return out;
|
|
697
697
|
}
|
|
698
|
-
|
|
698
|
+
chunkXHPRD45G_cjs.__name(dedupeIntents, "dedupeIntents");
|
|
699
699
|
function parseChatEmailToolSettings(map) {
|
|
700
700
|
const fromJson = parseIntentsJson(map.emailIntents);
|
|
701
701
|
const intents = dedupeIntents(fromJson ?? []);
|
|
@@ -717,7 +717,7 @@ ${legacyNegative}`);
|
|
|
717
717
|
toolPrompt: map.emailToolPrompt ?? ""
|
|
718
718
|
};
|
|
719
719
|
}
|
|
720
|
-
|
|
720
|
+
chunkXHPRD45G_cjs.__name(parseChatEmailToolSettings, "parseChatEmailToolSettings");
|
|
721
721
|
var EMAIL_TOOL_VALIDATION_KEY = "emailTool";
|
|
722
722
|
function parseEmailToolObject(raw) {
|
|
723
723
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
@@ -735,7 +735,7 @@ function parseEmailToolObject(raw) {
|
|
|
735
735
|
intents
|
|
736
736
|
};
|
|
737
737
|
}
|
|
738
|
-
|
|
738
|
+
chunkXHPRD45G_cjs.__name(parseEmailToolObject, "parseEmailToolObject");
|
|
739
739
|
function parseEmailToolFromAgentValidationRules(validationRulesText) {
|
|
740
740
|
const raw = validationRulesText?.trim();
|
|
741
741
|
if (!raw) return null;
|
|
@@ -748,7 +748,7 @@ function parseEmailToolFromAgentValidationRules(validationRulesText) {
|
|
|
748
748
|
return null;
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
|
-
|
|
751
|
+
chunkXHPRD45G_cjs.__name(parseEmailToolFromAgentValidationRules, "parseEmailToolFromAgentValidationRules");
|
|
752
752
|
function resolveChatEmailToolSettings(configMap, sources) {
|
|
753
753
|
const fromConfig = parseChatEmailToolSettings(configMap);
|
|
754
754
|
const resolved = typeof sources === "string" || sources == null ? {
|
|
@@ -772,17 +772,17 @@ function resolveChatEmailToolSettings(configMap, sources) {
|
|
|
772
772
|
toolPrompt
|
|
773
773
|
};
|
|
774
774
|
}
|
|
775
|
-
|
|
775
|
+
chunkXHPRD45G_cjs.__name(resolveChatEmailToolSettings, "resolveChatEmailToolSettings");
|
|
776
776
|
function intentByKey(intents, key) {
|
|
777
777
|
if (!key) return null;
|
|
778
778
|
const norm2 = normalizeIntentKey(key);
|
|
779
779
|
return intents.find((i) => i.intent === norm2) ?? null;
|
|
780
780
|
}
|
|
781
|
-
|
|
781
|
+
chunkXHPRD45G_cjs.__name(intentByKey, "intentByKey");
|
|
782
782
|
function buildIntentTableForPrompt(intents) {
|
|
783
783
|
return intents.map((i) => `- ${i.intent}: ${i.description} \u2192 notify ${i.emailTo}`).join("\n");
|
|
784
784
|
}
|
|
785
|
-
|
|
785
|
+
chunkXHPRD45G_cjs.__name(buildIntentTableForPrompt, "buildIntentTableForPrompt");
|
|
786
786
|
function buildIntentClassifierSystem(config, agentClassifierInstructions) {
|
|
787
787
|
const table = buildIntentTableForPrompt(config.intents);
|
|
788
788
|
const extra = [
|
|
@@ -806,7 +806,7 @@ Reply with ONLY valid JSON, no markdown:
|
|
|
806
806
|
{"intent":"INTENT_KEY","reason":"short explanation"}
|
|
807
807
|
Use "${NONE_INTENT}" when no intent applies.`;
|
|
808
808
|
}
|
|
809
|
-
|
|
809
|
+
chunkXHPRD45G_cjs.__name(buildIntentClassifierSystem, "buildIntentClassifierSystem");
|
|
810
810
|
function buildChatEmailAgentContext(settings) {
|
|
811
811
|
if (!settings.enabled) return "";
|
|
812
812
|
const classifier = settings.classifierInstructions.trim();
|
|
@@ -826,7 +826,7 @@ ${classifier}`);
|
|
|
826
826
|
${extra}`);
|
|
827
827
|
return parts.join("\n\n");
|
|
828
828
|
}
|
|
829
|
-
|
|
829
|
+
chunkXHPRD45G_cjs.__name(buildChatEmailAgentContext, "buildChatEmailAgentContext");
|
|
830
830
|
function buildChatbotSystemPromptWithEmailTool(baseSystemInstruction, guardrailsForPrompt, emailSettings) {
|
|
831
831
|
let prompt = (baseSystemInstruction ?? "").trim();
|
|
832
832
|
const guard = guardrailsForPrompt?.trim();
|
|
@@ -843,7 +843,7 @@ function buildChatbotSystemPromptWithEmailTool(baseSystemInstruction, guardrails
|
|
|
843
843
|
}
|
|
844
844
|
return prompt;
|
|
845
845
|
}
|
|
846
|
-
|
|
846
|
+
chunkXHPRD45G_cjs.__name(buildChatbotSystemPromptWithEmailTool, "buildChatbotSystemPromptWithEmailTool");
|
|
847
847
|
function formatTranscript(history, latestMessage, maxChars = 4e3) {
|
|
848
848
|
const lines = [];
|
|
849
849
|
for (const m of history) {
|
|
@@ -858,12 +858,12 @@ function formatTranscript(history, latestMessage, maxChars = 4e3) {
|
|
|
858
858
|
if (text.length > maxChars) text = text.slice(-maxChars);
|
|
859
859
|
return text;
|
|
860
860
|
}
|
|
861
|
-
|
|
861
|
+
chunkXHPRD45G_cjs.__name(formatTranscript, "formatTranscript");
|
|
862
862
|
function parseIntentJson(raw, intents) {
|
|
863
863
|
const trimmed = raw.trim();
|
|
864
864
|
const fence = trimmed.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
865
865
|
const candidate = (fence?.[1] ?? trimmed).trim();
|
|
866
|
-
const tryParse = /* @__PURE__ */
|
|
866
|
+
const tryParse = /* @__PURE__ */ chunkXHPRD45G_cjs.__name((s) => {
|
|
867
867
|
const o = JSON.parse(s);
|
|
868
868
|
let intentRaw = null;
|
|
869
869
|
if (typeof o.intent === "string") intentRaw = o.intent;
|
|
@@ -888,7 +888,7 @@ function parseIntentJson(raw, intents) {
|
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
|
-
|
|
891
|
+
chunkXHPRD45G_cjs.__name(parseIntentJson, "parseIntentJson");
|
|
892
892
|
async function detectChatLeadIntent(llm, params) {
|
|
893
893
|
if (!params.settings.intents.length) {
|
|
894
894
|
logChatEmail("classify skipped", {
|
|
@@ -995,15 +995,15 @@ Pick the single best intent for the visitor's latest message.`;
|
|
|
995
995
|
emailTo: matched.emailTo
|
|
996
996
|
};
|
|
997
997
|
}
|
|
998
|
-
|
|
998
|
+
chunkXHPRD45G_cjs.__name(detectChatLeadIntent, "detectChatLeadIntent");
|
|
999
999
|
function buildTranscriptForLeadEmail(history, latestMessage) {
|
|
1000
1000
|
return formatTranscript(history, latestMessage);
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1002
|
+
chunkXHPRD45G_cjs.__name(buildTranscriptForLeadEmail, "buildTranscriptForLeadEmail");
|
|
1003
1003
|
function parseIntentRecipientEmails(emailTo) {
|
|
1004
1004
|
return emailTo.split(/[,;]+/).map((s) => s.trim()).filter((s) => s.length > 0 && s.includes("@"));
|
|
1005
1005
|
}
|
|
1006
|
-
|
|
1006
|
+
chunkXHPRD45G_cjs.__name(parseIntentRecipientEmails, "parseIntentRecipientEmails");
|
|
1007
1007
|
|
|
1008
1008
|
// src/plugins/email/chat-lead-email.ts
|
|
1009
1009
|
function resolveLeadRecipients(emailPlugin2, emailSettings) {
|
|
@@ -1015,7 +1015,7 @@ function resolveLeadRecipients(emailPlugin2, emailSettings) {
|
|
|
1015
1015
|
];
|
|
1016
1016
|
return [];
|
|
1017
1017
|
}
|
|
1018
|
-
|
|
1018
|
+
chunkXHPRD45G_cjs.__name(resolveLeadRecipients, "resolveLeadRecipients");
|
|
1019
1019
|
async function sendChatLeadEmail(cms, emailSettings, brandingSettings, input) {
|
|
1020
1020
|
console.info(CHAT_EMAIL_LOG, "send start", {
|
|
1021
1021
|
conversationId: input.conversationId,
|
|
@@ -1053,14 +1053,14 @@ async function sendChatLeadEmail(cms, emailSettings, brandingSettings, input) {
|
|
|
1053
1053
|
recipients,
|
|
1054
1054
|
source: input.recipients?.length ? "intent_email_to" : "crm_or_smtp_fallback"
|
|
1055
1055
|
});
|
|
1056
|
-
const companyDetails =
|
|
1056
|
+
const companyDetails = chunkEYUBL7YH_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings);
|
|
1057
1057
|
const ctx = {
|
|
1058
1058
|
...input,
|
|
1059
1059
|
companyDetails: input.companyDetails ?? companyDetails
|
|
1060
1060
|
};
|
|
1061
1061
|
let anySent = false;
|
|
1062
1062
|
for (const to of recipients) {
|
|
1063
|
-
await
|
|
1063
|
+
await chunk4MNVIGVJ_cjs.queueEmail(cms, {
|
|
1064
1064
|
to,
|
|
1065
1065
|
templateName: "chatLead",
|
|
1066
1066
|
ctx
|
|
@@ -1082,7 +1082,7 @@ async function sendChatLeadEmail(cms, emailSettings, brandingSettings, input) {
|
|
|
1082
1082
|
recipients
|
|
1083
1083
|
};
|
|
1084
1084
|
}
|
|
1085
|
-
|
|
1085
|
+
chunkXHPRD45G_cjs.__name(sendChatLeadEmail, "sendChatLeadEmail");
|
|
1086
1086
|
|
|
1087
1087
|
// src/plugins/email/index.ts
|
|
1088
1088
|
var EMAIL_TYPES = [
|
|
@@ -1095,13 +1095,13 @@ function normalizeEmailType(raw, fallback) {
|
|
|
1095
1095
|
const v = String(raw ?? fallback).trim().toUpperCase();
|
|
1096
1096
|
return EMAIL_TYPES.includes(v) ? v : fallback;
|
|
1097
1097
|
}
|
|
1098
|
-
|
|
1098
|
+
chunkXHPRD45G_cjs.__name(normalizeEmailType, "normalizeEmailType");
|
|
1099
1099
|
function isLocalSmtpHost(host) {
|
|
1100
1100
|
if (!host) return false;
|
|
1101
1101
|
const h = host.trim().toLowerCase();
|
|
1102
1102
|
return h === "localhost" || h === "127.0.0.1" || h === "::1";
|
|
1103
1103
|
}
|
|
1104
|
-
|
|
1104
|
+
chunkXHPRD45G_cjs.__name(isLocalSmtpHost, "isLocalSmtpHost");
|
|
1105
1105
|
function emailPlugin(config) {
|
|
1106
1106
|
return {
|
|
1107
1107
|
name: "email",
|
|
@@ -1135,7 +1135,7 @@ function emailPlugin(config) {
|
|
|
1135
1135
|
context.logger.warn("Email plugin skipped: AWS SES requires AWS_SES_REGION or AWS_REGION");
|
|
1136
1136
|
return void 0;
|
|
1137
1137
|
}
|
|
1138
|
-
if (type === "AWS" && merged.region && merged.user && merged.password && !
|
|
1138
|
+
if (type === "AWS" && merged.region && merged.user && merged.password && !chunkQN6PZLAP_cjs.sesRegionSupportsSmtp(merged.region)) {
|
|
1139
1139
|
context.logger.warn(`Email plugin: region ${merged.region} has no SES SMTP endpoint (ENOTFOUND). Set AWS_SES_REGION=ap-south-1 and create SMTP credentials in that SES region.`);
|
|
1140
1140
|
}
|
|
1141
1141
|
if (type === "AWS" && !(merged.user && merged.password || merged.accessKeyId && merged.secretAccessKey)) {
|
|
@@ -1150,22 +1150,22 @@ function emailPlugin(config) {
|
|
|
1150
1150
|
context.logger.warn("Email plugin skipped: SMTP_TYPE=SMTP requires SMTP_HOST (or use SMTP_TYPE=AWS with AWS_REGION and SES SMTP credentials)");
|
|
1151
1151
|
return void 0;
|
|
1152
1152
|
}
|
|
1153
|
-
const resolvedHost = type === "AWS" && merged.region ? merged.host ||
|
|
1153
|
+
const resolvedHost = type === "AWS" && merged.region ? merged.host || chunkQN6PZLAP_cjs.sesSmtpHost(merged.region) : merged.host;
|
|
1154
1154
|
context.logger.info("Email plugin initialized", {
|
|
1155
1155
|
type,
|
|
1156
1156
|
host: resolvedHost,
|
|
1157
1157
|
region: merged.region
|
|
1158
1158
|
});
|
|
1159
|
-
return new
|
|
1159
|
+
return new chunkQN6PZLAP_cjs.EmailService(merged);
|
|
1160
1160
|
}
|
|
1161
1161
|
};
|
|
1162
1162
|
}
|
|
1163
|
-
|
|
1163
|
+
chunkXHPRD45G_cjs.__name(emailPlugin, "emailPlugin");
|
|
1164
1164
|
function base64UrlEncode(str) {
|
|
1165
1165
|
const buf = typeof str === "string" ? Buffer.from(str, "utf8") : str;
|
|
1166
1166
|
return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1167
1167
|
}
|
|
1168
|
-
|
|
1168
|
+
chunkXHPRD45G_cjs.__name(base64UrlEncode, "base64UrlEncode");
|
|
1169
1169
|
async function getGoogleAccessToken(clientEmail, privateKey) {
|
|
1170
1170
|
const now = Math.floor(Date.now() / 1e3);
|
|
1171
1171
|
const header = {
|
|
@@ -1207,7 +1207,7 @@ async function getGoogleAccessToken(clientEmail, privateKey) {
|
|
|
1207
1207
|
}
|
|
1208
1208
|
return tokenData.access_token;
|
|
1209
1209
|
}
|
|
1210
|
-
|
|
1210
|
+
chunkXHPRD45G_cjs.__name(getGoogleAccessToken, "getGoogleAccessToken");
|
|
1211
1211
|
async function sendFcmPushNotification(dataSource, entityMap, msg) {
|
|
1212
1212
|
try {
|
|
1213
1213
|
const pushSettings = await getSettingsGroup(dataSource, entityMap, "push");
|
|
@@ -1271,7 +1271,7 @@ async function sendFcmPushNotification(dataSource, entityMap, msg) {
|
|
|
1271
1271
|
};
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
|
-
|
|
1274
|
+
chunkXHPRD45G_cjs.__name(sendFcmPushNotification, "sendFcmPushNotification");
|
|
1275
1275
|
async function validateFcmCredentials(dataSource, entityMap) {
|
|
1276
1276
|
try {
|
|
1277
1277
|
const pushSettings = await getSettingsGroup(dataSource, entityMap, "push");
|
|
@@ -1313,7 +1313,7 @@ async function validateFcmCredentials(dataSource, entityMap) {
|
|
|
1313
1313
|
};
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
|
-
|
|
1316
|
+
chunkXHPRD45G_cjs.__name(validateFcmCredentials, "validateFcmCredentials");
|
|
1317
1317
|
|
|
1318
1318
|
// src/lib/order-notification-defaults.ts
|
|
1319
1319
|
var ORDER_NOTIFICATION_DEFAULTS = {
|
|
@@ -1436,19 +1436,19 @@ async function getSettingsGroup(dataSource, entityMap, group) {
|
|
|
1436
1436
|
r.value
|
|
1437
1437
|
]));
|
|
1438
1438
|
}
|
|
1439
|
-
|
|
1439
|
+
chunkXHPRD45G_cjs.__name(getSettingsGroup, "getSettingsGroup");
|
|
1440
1440
|
async function isEmailNotificationsEnabled(dataSource, entityMap) {
|
|
1441
1441
|
const settings = await getSettingsGroup(dataSource, entityMap, "event_notifications");
|
|
1442
1442
|
if (settings.enabled === "false" || settings.enabled === "0") return false;
|
|
1443
1443
|
return settings.email_enabled !== "false" && settings.email_enabled !== "0";
|
|
1444
1444
|
}
|
|
1445
|
-
|
|
1445
|
+
chunkXHPRD45G_cjs.__name(isEmailNotificationsEnabled, "isEmailNotificationsEnabled");
|
|
1446
1446
|
async function isWhatsappNotificationsEnabled(dataSource, entityMap) {
|
|
1447
1447
|
const settings = await getSettingsGroup(dataSource, entityMap, "event_notifications");
|
|
1448
1448
|
if (settings.enabled === "false" || settings.enabled === "0") return false;
|
|
1449
1449
|
return settings.whatsapp_enabled !== "false" && settings.whatsapp_enabled !== "0";
|
|
1450
1450
|
}
|
|
1451
|
-
|
|
1451
|
+
chunkXHPRD45G_cjs.__name(isWhatsappNotificationsEnabled, "isWhatsappNotificationsEnabled");
|
|
1452
1452
|
async function isTriggerCatalogEnabled(triggerKey, dataSource, entityMap) {
|
|
1453
1453
|
if (!entityMap.order_notification_triggers) {
|
|
1454
1454
|
return true;
|
|
@@ -1467,7 +1467,7 @@ async function isTriggerCatalogEnabled(triggerKey, dataSource, entityMap) {
|
|
|
1467
1467
|
return true;
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
|
-
|
|
1470
|
+
chunkXHPRD45G_cjs.__name(isTriggerCatalogEnabled, "isTriggerCatalogEnabled");
|
|
1471
1471
|
async function loadBoundTemplate(triggerKey, channel, audienceType = "customers", dataSource, entityMap) {
|
|
1472
1472
|
if (!entityMap.order_notification_bindings || !entityMap.message_templates) {
|
|
1473
1473
|
console.warn("[order-notifications] order_notification_bindings or message_templates missing from entityMap");
|
|
@@ -1587,7 +1587,7 @@ async function loadBoundTemplate(triggerKey, channel, audienceType = "customers"
|
|
|
1587
1587
|
return null;
|
|
1588
1588
|
}
|
|
1589
1589
|
}
|
|
1590
|
-
|
|
1590
|
+
chunkXHPRD45G_cjs.__name(loadBoundTemplate, "loadBoundTemplate");
|
|
1591
1591
|
function mergeTriggerVariables(payload, rich) {
|
|
1592
1592
|
const basic = {
|
|
1593
1593
|
orderId: String(payload.orderId ?? ""),
|
|
@@ -1614,7 +1614,7 @@ function mergeTriggerVariables(payload, rich) {
|
|
|
1614
1614
|
...extraVars
|
|
1615
1615
|
};
|
|
1616
1616
|
}
|
|
1617
|
-
|
|
1617
|
+
chunkXHPRD45G_cjs.__name(mergeTriggerVariables, "mergeTriggerVariables");
|
|
1618
1618
|
async function isAudienceEmailEnabled(dataSource, entityMap, audience) {
|
|
1619
1619
|
const settings = await getSettingsGroup(dataSource, entityMap, "event_notifications");
|
|
1620
1620
|
if (settings.enabled === "false" || settings.enabled === "0") return false;
|
|
@@ -1622,13 +1622,13 @@ async function isAudienceEmailEnabled(dataSource, entityMap, audience) {
|
|
|
1622
1622
|
const key = `email_${audience}_enabled`;
|
|
1623
1623
|
return settings[key] !== "false" && settings[key] !== "0";
|
|
1624
1624
|
}
|
|
1625
|
-
|
|
1625
|
+
chunkXHPRD45G_cjs.__name(isAudienceEmailEnabled, "isAudienceEmailEnabled");
|
|
1626
1626
|
async function isPushNotificationsEnabled(dataSource, entityMap) {
|
|
1627
1627
|
const settings = await getSettingsGroup(dataSource, entityMap, "event_notifications");
|
|
1628
1628
|
if (settings.enabled === "false" || settings.enabled === "0") return false;
|
|
1629
1629
|
return settings.push_enabled !== "false" && settings.push_enabled !== "0";
|
|
1630
1630
|
}
|
|
1631
|
-
|
|
1631
|
+
chunkXHPRD45G_cjs.__name(isPushNotificationsEnabled, "isPushNotificationsEnabled");
|
|
1632
1632
|
async function isAudiencePushEnabled(dataSource, entityMap, audience) {
|
|
1633
1633
|
const settings = await getSettingsGroup(dataSource, entityMap, "event_notifications");
|
|
1634
1634
|
if (settings.enabled === "false" || settings.enabled === "0") return false;
|
|
@@ -1636,14 +1636,14 @@ async function isAudiencePushEnabled(dataSource, entityMap, audience) {
|
|
|
1636
1636
|
const key = `push_${audience}_enabled`;
|
|
1637
1637
|
return settings[key] !== "false" && settings[key] !== "0";
|
|
1638
1638
|
}
|
|
1639
|
-
|
|
1639
|
+
chunkXHPRD45G_cjs.__name(isAudiencePushEnabled, "isAudiencePushEnabled");
|
|
1640
1640
|
async function sendPushNotificationForTrigger(triggerKey, orderId, audienceType, targetId, variables, dataSource, entityMap) {
|
|
1641
1641
|
let template = await loadBoundTemplate(triggerKey, "mobile", audienceType, dataSource, entityMap);
|
|
1642
1642
|
if (!template) {
|
|
1643
1643
|
template = await loadBoundTemplate(triggerKey, "push", audienceType, dataSource, entityMap);
|
|
1644
1644
|
}
|
|
1645
1645
|
if (!template || !template.body) {
|
|
1646
|
-
|
|
1646
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("PUSH", "no mobile/push template or empty body", {
|
|
1647
1647
|
triggerKey,
|
|
1648
1648
|
orderId,
|
|
1649
1649
|
audienceType,
|
|
@@ -1652,10 +1652,10 @@ async function sendPushNotificationForTrigger(triggerKey, orderId, audienceType,
|
|
|
1652
1652
|
return;
|
|
1653
1653
|
}
|
|
1654
1654
|
const rawTitle = template.subject?.trim() || "Order Notification";
|
|
1655
|
-
const title =
|
|
1656
|
-
const body =
|
|
1655
|
+
const title = chunkCIZZX57T_cjs.applyTemplateVars(rawTitle, variables);
|
|
1656
|
+
const body = chunkCIZZX57T_cjs.applyTemplateVars(template.body, variables);
|
|
1657
1657
|
if (!entityMap.user_device_tokens) {
|
|
1658
|
-
|
|
1658
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("PUSH", "user_device_tokens entity not registered", {
|
|
1659
1659
|
triggerKey,
|
|
1660
1660
|
orderId,
|
|
1661
1661
|
audienceType
|
|
@@ -1696,7 +1696,7 @@ async function sendPushNotificationForTrigger(triggerKey, orderId, audienceType,
|
|
|
1696
1696
|
});
|
|
1697
1697
|
}
|
|
1698
1698
|
} catch (err) {
|
|
1699
|
-
|
|
1699
|
+
chunkM5QDJOUP_cjs.notifyLog.error("PUSH", "device token query failed", {
|
|
1700
1700
|
triggerKey,
|
|
1701
1701
|
orderId,
|
|
1702
1702
|
audienceType,
|
|
@@ -1706,17 +1706,17 @@ async function sendPushNotificationForTrigger(triggerKey, orderId, audienceType,
|
|
|
1706
1706
|
return;
|
|
1707
1707
|
}
|
|
1708
1708
|
const tokens = targetTokens.map((t) => t.token?.trim()).filter(Boolean);
|
|
1709
|
-
|
|
1709
|
+
chunkM5QDJOUP_cjs.notifyLog.push("sending", {
|
|
1710
1710
|
triggerKey,
|
|
1711
1711
|
orderId,
|
|
1712
1712
|
audienceType,
|
|
1713
1713
|
targetId,
|
|
1714
1714
|
title,
|
|
1715
1715
|
tokenCount: tokens.length,
|
|
1716
|
-
fcmTokens: tokens.map((t) =>
|
|
1716
|
+
fcmTokens: tokens.map((t) => chunkM5QDJOUP_cjs.logFcmToken(t))
|
|
1717
1717
|
});
|
|
1718
1718
|
if (tokens.length === 0) {
|
|
1719
|
-
|
|
1719
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("PUSH", "no active FCM tokens for target", {
|
|
1720
1720
|
triggerKey,
|
|
1721
1721
|
orderId,
|
|
1722
1722
|
audienceType,
|
|
@@ -1726,12 +1726,12 @@ async function sendPushNotificationForTrigger(triggerKey, orderId, audienceType,
|
|
|
1726
1726
|
return;
|
|
1727
1727
|
}
|
|
1728
1728
|
for (const token of tokens) {
|
|
1729
|
-
|
|
1729
|
+
chunkM5QDJOUP_cjs.notifyLog.push("FCM target", {
|
|
1730
1730
|
triggerKey,
|
|
1731
1731
|
orderId,
|
|
1732
1732
|
audienceType,
|
|
1733
1733
|
targetId,
|
|
1734
|
-
fcmToken:
|
|
1734
|
+
fcmToken: chunkM5QDJOUP_cjs.logFcmToken(token)
|
|
1735
1735
|
});
|
|
1736
1736
|
const res = await sendFcmPushNotification(dataSource, entityMap, {
|
|
1737
1737
|
token,
|
|
@@ -1743,25 +1743,25 @@ async function sendPushNotificationForTrigger(triggerKey, orderId, audienceType,
|
|
|
1743
1743
|
}
|
|
1744
1744
|
});
|
|
1745
1745
|
if (res.success) {
|
|
1746
|
-
|
|
1746
|
+
chunkM5QDJOUP_cjs.notifyLog.push("FCM sent", {
|
|
1747
1747
|
triggerKey,
|
|
1748
1748
|
orderId,
|
|
1749
1749
|
audienceType,
|
|
1750
|
-
fcmToken:
|
|
1750
|
+
fcmToken: chunkM5QDJOUP_cjs.logFcmToken(token),
|
|
1751
1751
|
messageId: res.messageId ?? null
|
|
1752
1752
|
});
|
|
1753
1753
|
} else {
|
|
1754
|
-
|
|
1754
|
+
chunkM5QDJOUP_cjs.notifyLog.error("PUSH", "FCM send failed", {
|
|
1755
1755
|
triggerKey,
|
|
1756
1756
|
orderId,
|
|
1757
1757
|
audienceType,
|
|
1758
|
-
fcmToken:
|
|
1758
|
+
fcmToken: chunkM5QDJOUP_cjs.logFcmToken(token),
|
|
1759
1759
|
error: res.error ?? "unknown"
|
|
1760
1760
|
});
|
|
1761
1761
|
}
|
|
1762
1762
|
}
|
|
1763
1763
|
}
|
|
1764
|
-
|
|
1764
|
+
chunkXHPRD45G_cjs.__name(sendPushNotificationForTrigger, "sendPushNotificationForTrigger");
|
|
1765
1765
|
async function getOrderVendorEmails(orderId, orderVendorId, dataSource, entityMap) {
|
|
1766
1766
|
const emails = /* @__PURE__ */ new Set();
|
|
1767
1767
|
if (!entityMap.vendors) return [];
|
|
@@ -1812,7 +1812,7 @@ async function getOrderVendorEmails(orderId, orderVendorId, dataSource, entityMa
|
|
|
1812
1812
|
}
|
|
1813
1813
|
return Array.from(emails);
|
|
1814
1814
|
}
|
|
1815
|
-
|
|
1815
|
+
chunkXHPRD45G_cjs.__name(getOrderVendorEmails, "getOrderVendorEmails");
|
|
1816
1816
|
async function getAdminRecipientEmails(dataSource, entityMap) {
|
|
1817
1817
|
const emails = /* @__PURE__ */ new Set();
|
|
1818
1818
|
const emailSettings = await getSettingsGroup(dataSource, entityMap, "email");
|
|
@@ -1888,7 +1888,7 @@ async function getAdminRecipientEmails(dataSource, entityMap) {
|
|
|
1888
1888
|
}
|
|
1889
1889
|
return Array.from(emails).filter((e) => !vendorEmails.has(e.toLowerCase()));
|
|
1890
1890
|
}
|
|
1891
|
-
|
|
1891
|
+
chunkXHPRD45G_cjs.__name(getAdminRecipientEmails, "getAdminRecipientEmails");
|
|
1892
1892
|
function formatBodyForEmailHtml(body) {
|
|
1893
1893
|
if (!body) return "";
|
|
1894
1894
|
if (/^\s*<(html|body|table|section)[\s>]/i.test(body.trim())) {
|
|
@@ -1897,15 +1897,15 @@ function formatBodyForEmailHtml(body) {
|
|
|
1897
1897
|
const withBreaks = body.replace(/\r\n/g, "\n").replace(/\n/g, "<br />");
|
|
1898
1898
|
return `<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.6; color: #1f2937;">${withBreaks}</div>`;
|
|
1899
1899
|
}
|
|
1900
|
-
|
|
1900
|
+
chunkXHPRD45G_cjs.__name(formatBodyForEmailHtml, "formatBodyForEmailHtml");
|
|
1901
1901
|
async function sendEmailForTrigger(triggerKey, orderId, audienceType, variables, contactEmail, dataSource, entityMap, getCms) {
|
|
1902
1902
|
const template = await loadBoundTemplate(triggerKey, "email", audienceType, dataSource, entityMap);
|
|
1903
1903
|
if (!template) {
|
|
1904
|
-
|
|
1904
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "no bound/default email template", {
|
|
1905
1905
|
triggerKey,
|
|
1906
1906
|
orderId,
|
|
1907
1907
|
audienceType,
|
|
1908
|
-
to:
|
|
1908
|
+
to: chunkM5QDJOUP_cjs.maskNotifyEmail(contactEmail)
|
|
1909
1909
|
});
|
|
1910
1910
|
return;
|
|
1911
1911
|
}
|
|
@@ -1914,7 +1914,7 @@ async function sendEmailForTrigger(triggerKey, orderId, audienceType, variables,
|
|
|
1914
1914
|
getSettingsGroup(dataSource, entityMap, "email"),
|
|
1915
1915
|
getSettingsGroup(dataSource, entityMap, "store")
|
|
1916
1916
|
]);
|
|
1917
|
-
const companyDetails =
|
|
1917
|
+
const companyDetails = chunkEYUBL7YH_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
|
|
1918
1918
|
const templateContent = (template.body ?? "") + (template.subject ?? "");
|
|
1919
1919
|
const shouldAttachInvoice = /\{\{\s*(invoiceAttachment|invoicePdf|invoice|attachInvoice)\s*\}\}/i.test(templateContent);
|
|
1920
1920
|
const cleanVariables = {
|
|
@@ -1925,15 +1925,15 @@ async function sendEmailForTrigger(triggerKey, orderId, audienceType, variables,
|
|
|
1925
1925
|
attachInvoice: "",
|
|
1926
1926
|
invoiceUrl: ""
|
|
1927
1927
|
};
|
|
1928
|
-
const subject =
|
|
1929
|
-
const rawBody =
|
|
1928
|
+
const subject = chunkCIZZX57T_cjs.applyTemplateVars(template.subject ?? "Order update", cleanVariables);
|
|
1929
|
+
const rawBody = chunkCIZZX57T_cjs.applyTemplateVars(template.body, cleanVariables);
|
|
1930
1930
|
const bodyHtml = formatBodyForEmailHtml(rawBody);
|
|
1931
|
-
const html =
|
|
1931
|
+
const html = chunkQN6PZLAP_cjs.renderLayout({
|
|
1932
1932
|
bodyHtml,
|
|
1933
1933
|
companyDetails
|
|
1934
1934
|
});
|
|
1935
1935
|
const cms = await getCms();
|
|
1936
|
-
await
|
|
1936
|
+
await chunk4MNVIGVJ_cjs.queueEmail(cms, {
|
|
1937
1937
|
to: contactEmail,
|
|
1938
1938
|
subject,
|
|
1939
1939
|
html,
|
|
@@ -1943,29 +1943,29 @@ async function sendEmailForTrigger(triggerKey, orderId, audienceType, variables,
|
|
|
1943
1943
|
attachInvoice: true
|
|
1944
1944
|
} : {}
|
|
1945
1945
|
});
|
|
1946
|
-
|
|
1946
|
+
chunkM5QDJOUP_cjs.notifyLog.email("queued", {
|
|
1947
1947
|
triggerKey,
|
|
1948
1948
|
audienceType,
|
|
1949
1949
|
orderId,
|
|
1950
|
-
to:
|
|
1950
|
+
to: chunkM5QDJOUP_cjs.maskNotifyEmail(contactEmail),
|
|
1951
1951
|
subject,
|
|
1952
1952
|
attachInvoice: shouldAttachInvoice
|
|
1953
1953
|
});
|
|
1954
1954
|
}
|
|
1955
|
-
|
|
1955
|
+
chunkXHPRD45G_cjs.__name(sendEmailForTrigger, "sendEmailForTrigger");
|
|
1956
1956
|
async function sendWhatsAppForTrigger(triggerKey, orderId, phone, variables, dataSource, entityMap, getCms) {
|
|
1957
1957
|
const template = await loadBoundTemplate(triggerKey, "whatsapp", "customers", dataSource, entityMap);
|
|
1958
1958
|
if (!template) {
|
|
1959
|
-
|
|
1959
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("WHATSAPP", "no bound/default WhatsApp template", {
|
|
1960
1960
|
triggerKey,
|
|
1961
1961
|
orderId,
|
|
1962
|
-
phone:
|
|
1962
|
+
phone: chunkM5QDJOUP_cjs.maskNotifyPhone(phone)
|
|
1963
1963
|
});
|
|
1964
1964
|
return;
|
|
1965
1965
|
}
|
|
1966
1966
|
const paramOrder = template.providerMeta?.paramOrder ?? [];
|
|
1967
1967
|
if (paramOrder.length === 0) {
|
|
1968
|
-
|
|
1968
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("WHATSAPP", "template has no paramOrder \u2014 variables may send blank/wrong", {
|
|
1969
1969
|
triggerKey,
|
|
1970
1970
|
orderId
|
|
1971
1971
|
});
|
|
@@ -1976,15 +1976,15 @@ async function sendWhatsAppForTrigger(triggerKey, orderId, phone, variables, dat
|
|
|
1976
1976
|
name: template.name
|
|
1977
1977
|
});
|
|
1978
1978
|
if (!metaTemplateName) {
|
|
1979
|
-
|
|
1979
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("WHATSAPP", "template has no Meta template name", {
|
|
1980
1980
|
triggerKey,
|
|
1981
1981
|
orderId,
|
|
1982
|
-
phone:
|
|
1982
|
+
phone: chunkM5QDJOUP_cjs.maskNotifyPhone(phone),
|
|
1983
1983
|
templateId: template.id
|
|
1984
1984
|
});
|
|
1985
1985
|
return;
|
|
1986
1986
|
}
|
|
1987
|
-
const sent = await
|
|
1987
|
+
const sent = await chunkOXFC3DAM_cjs.queueWhatsApp(cms, {
|
|
1988
1988
|
to: phone.trim(),
|
|
1989
1989
|
templateKey: triggerKey,
|
|
1990
1990
|
externalTemplateRef: metaTemplateName,
|
|
@@ -1994,28 +1994,28 @@ async function sendWhatsAppForTrigger(triggerKey, orderId, phone, variables, dat
|
|
|
1994
1994
|
templateParamOrder: paramOrder
|
|
1995
1995
|
});
|
|
1996
1996
|
if (!sent) {
|
|
1997
|
-
|
|
1997
|
+
chunkM5QDJOUP_cjs.notifyLog.error("WHATSAPP", "send failed / not queued", {
|
|
1998
1998
|
triggerKey,
|
|
1999
1999
|
orderId,
|
|
2000
|
-
phone:
|
|
2000
|
+
phone: chunkM5QDJOUP_cjs.maskNotifyPhone(phone),
|
|
2001
2001
|
hint: "Register whatsappPlugin() + queuePlugin() in getCms(), or set WHATSAPP_ACCESS_TOKEN and WHATSAPP_PHONE_NUMBER_ID"
|
|
2002
2002
|
});
|
|
2003
2003
|
} else {
|
|
2004
|
-
|
|
2004
|
+
chunkM5QDJOUP_cjs.notifyLog.whatsapp("queued/sent", {
|
|
2005
2005
|
triggerKey,
|
|
2006
2006
|
orderId,
|
|
2007
|
-
phone:
|
|
2007
|
+
phone: chunkM5QDJOUP_cjs.maskNotifyPhone(phone),
|
|
2008
2008
|
metaTemplateName
|
|
2009
2009
|
});
|
|
2010
2010
|
}
|
|
2011
2011
|
}
|
|
2012
|
-
|
|
2012
|
+
chunkXHPRD45G_cjs.__name(sendWhatsAppForTrigger, "sendWhatsAppForTrigger");
|
|
2013
2013
|
async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms) {
|
|
2014
|
-
|
|
2014
|
+
chunkM5QDJOUP_cjs.notifyLog.trigger("dispatcher received", {
|
|
2015
2015
|
triggerKey,
|
|
2016
2016
|
orderId: payload.orderId,
|
|
2017
2017
|
orderNumber: payload.orderNumber,
|
|
2018
|
-
phone:
|
|
2018
|
+
phone: chunkM5QDJOUP_cjs.maskNotifyPhone(payload.customerPhone),
|
|
2019
2019
|
vendorId: payload.vendorId ?? null
|
|
2020
2020
|
});
|
|
2021
2021
|
const [emailChannelEnabled, whatsappChannelEnabled, pushChannelEnabled] = await Promise.all([
|
|
@@ -2023,7 +2023,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2023
2023
|
isWhatsappNotificationsEnabled(dataSource, entityMap),
|
|
2024
2024
|
isPushNotificationsEnabled(dataSource, entityMap)
|
|
2025
2025
|
]);
|
|
2026
|
-
|
|
2026
|
+
chunkM5QDJOUP_cjs.notifyLog.trigger("channel switches", {
|
|
2027
2027
|
triggerKey,
|
|
2028
2028
|
orderId: payload.orderId,
|
|
2029
2029
|
email: emailChannelEnabled,
|
|
@@ -2031,7 +2031,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2031
2031
|
push: pushChannelEnabled
|
|
2032
2032
|
});
|
|
2033
2033
|
if (!emailChannelEnabled && !whatsappChannelEnabled && !pushChannelEnabled) {
|
|
2034
|
-
|
|
2034
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("ALL", "Email, WhatsApp, and Mobile Push are disabled in event_notifications", {
|
|
2035
2035
|
triggerKey,
|
|
2036
2036
|
orderId: payload.orderId
|
|
2037
2037
|
});
|
|
@@ -2039,7 +2039,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2039
2039
|
}
|
|
2040
2040
|
const triggerEnabled = await isTriggerCatalogEnabled(triggerKey, dataSource, entityMap);
|
|
2041
2041
|
if (!triggerEnabled) {
|
|
2042
|
-
|
|
2042
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("TRIGGER", "trigger catalog disabled", {
|
|
2043
2043
|
triggerKey,
|
|
2044
2044
|
orderId: payload.orderId
|
|
2045
2045
|
});
|
|
@@ -2052,11 +2052,11 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2052
2052
|
const variables = mergeTriggerVariables(payload, context?.variables);
|
|
2053
2053
|
const contactEmail = context?.contact.email?.trim() || "";
|
|
2054
2054
|
const contactPhone = context?.contact.phone?.trim() || payload.customerPhone?.trim() || "";
|
|
2055
|
-
|
|
2055
|
+
chunkM5QDJOUP_cjs.notifyLog.trigger("recipients resolved", {
|
|
2056
2056
|
triggerKey,
|
|
2057
2057
|
orderId: payload.orderId,
|
|
2058
|
-
contactEmail:
|
|
2059
|
-
contactPhone:
|
|
2058
|
+
contactEmail: chunkM5QDJOUP_cjs.maskNotifyEmail(contactEmail),
|
|
2059
|
+
contactPhone: chunkM5QDJOUP_cjs.maskNotifyPhone(contactPhone)
|
|
2060
2060
|
});
|
|
2061
2061
|
if (emailChannelEnabled) {
|
|
2062
2062
|
const [customerEnabled, vendorEnabled, adminEnabled] = await Promise.all([
|
|
@@ -2064,7 +2064,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2064
2064
|
isAudienceEmailEnabled(dataSource, entityMap, "vendor"),
|
|
2065
2065
|
isAudienceEmailEnabled(dataSource, entityMap, "admin")
|
|
2066
2066
|
]);
|
|
2067
|
-
|
|
2067
|
+
chunkM5QDJOUP_cjs.notifyLog.email("audience switches", {
|
|
2068
2068
|
triggerKey,
|
|
2069
2069
|
orderId: payload.orderId,
|
|
2070
2070
|
customer: customerEnabled,
|
|
@@ -2076,7 +2076,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2076
2076
|
if (assigneeEmail) {
|
|
2077
2077
|
await sendEmailForTrigger(triggerKey, payload.orderId, "customers", variables, assigneeEmail, dataSource, entityMap, getCms);
|
|
2078
2078
|
} else {
|
|
2079
|
-
|
|
2079
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "order_assigned_assignee has no assignee email", {
|
|
2080
2080
|
triggerKey,
|
|
2081
2081
|
orderId: payload.orderId
|
|
2082
2082
|
});
|
|
@@ -2084,12 +2084,12 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2084
2084
|
} else if (customerEnabled && contactEmail) {
|
|
2085
2085
|
await sendEmailForTrigger(triggerKey, payload.orderId, "customers", variables, contactEmail, dataSource, entityMap, getCms);
|
|
2086
2086
|
} else if (!customerEnabled) {
|
|
2087
|
-
|
|
2087
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "customer email audience disabled", {
|
|
2088
2088
|
triggerKey,
|
|
2089
2089
|
orderId: payload.orderId
|
|
2090
2090
|
});
|
|
2091
2091
|
} else {
|
|
2092
|
-
|
|
2092
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "no customer email on order contact", {
|
|
2093
2093
|
triggerKey,
|
|
2094
2094
|
orderId: payload.orderId
|
|
2095
2095
|
});
|
|
@@ -2099,7 +2099,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2099
2099
|
if (multiVendorSettings.enabled !== "false" && multiVendorSettings.enabled !== "0") {
|
|
2100
2100
|
const vendorEmails = await getOrderVendorEmails(payload.orderId, payload.vendorId, dataSource, entityMap);
|
|
2101
2101
|
if (vendorEmails.length === 0) {
|
|
2102
|
-
|
|
2102
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "no vendor emails for order", {
|
|
2103
2103
|
triggerKey,
|
|
2104
2104
|
orderId: payload.orderId,
|
|
2105
2105
|
vendorId: payload.vendorId ?? null
|
|
@@ -2109,7 +2109,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2109
2109
|
await sendEmailForTrigger(triggerKey, payload.orderId, "vendors", variables, vEmail, dataSource, entityMap, getCms);
|
|
2110
2110
|
}
|
|
2111
2111
|
} else {
|
|
2112
|
-
|
|
2112
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "multi-vendor off \u2014 skip vendor email", {
|
|
2113
2113
|
triggerKey,
|
|
2114
2114
|
orderId: payload.orderId
|
|
2115
2115
|
});
|
|
@@ -2118,7 +2118,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2118
2118
|
if (adminEnabled && triggerKey !== "order_assigned_assignee") {
|
|
2119
2119
|
const adminEmails = await getAdminRecipientEmails(dataSource, entityMap);
|
|
2120
2120
|
if (adminEmails.length === 0) {
|
|
2121
|
-
|
|
2121
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "no admin recipient emails", {
|
|
2122
2122
|
triggerKey,
|
|
2123
2123
|
orderId: payload.orderId
|
|
2124
2124
|
});
|
|
@@ -2128,7 +2128,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2128
2128
|
}
|
|
2129
2129
|
}
|
|
2130
2130
|
} else {
|
|
2131
|
-
|
|
2131
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("EMAIL", "email channel disabled", {
|
|
2132
2132
|
triggerKey,
|
|
2133
2133
|
orderId: payload.orderId
|
|
2134
2134
|
});
|
|
@@ -2139,7 +2139,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2139
2139
|
isAudiencePushEnabled(dataSource, entityMap, "vendor"),
|
|
2140
2140
|
isAudiencePushEnabled(dataSource, entityMap, "admin")
|
|
2141
2141
|
]);
|
|
2142
|
-
|
|
2142
|
+
chunkM5QDJOUP_cjs.notifyLog.push("audience switches", {
|
|
2143
2143
|
triggerKey,
|
|
2144
2144
|
orderId: payload.orderId,
|
|
2145
2145
|
customer: pushCustomerEnabled,
|
|
@@ -2150,12 +2150,12 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2150
2150
|
if (pushCustomerEnabled && targetCustomerId) {
|
|
2151
2151
|
await sendPushNotificationForTrigger(triggerKey, payload.orderId, "customers", String(targetCustomerId), variables, dataSource, entityMap);
|
|
2152
2152
|
} else if (!pushCustomerEnabled) {
|
|
2153
|
-
|
|
2153
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("PUSH", "customer push audience disabled", {
|
|
2154
2154
|
triggerKey,
|
|
2155
2155
|
orderId: payload.orderId
|
|
2156
2156
|
});
|
|
2157
2157
|
} else {
|
|
2158
|
-
|
|
2158
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("PUSH", "no customer user/contact id for push", {
|
|
2159
2159
|
triggerKey,
|
|
2160
2160
|
orderId: payload.orderId
|
|
2161
2161
|
});
|
|
@@ -2163,7 +2163,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2163
2163
|
if (pushVendorEnabled && payload.vendorId && triggerKey !== "order_assigned_assignee") {
|
|
2164
2164
|
await sendPushNotificationForTrigger(triggerKey, payload.orderId, "vendors", String(payload.vendorId), variables, dataSource, entityMap);
|
|
2165
2165
|
} else if (pushVendorEnabled && triggerKey !== "order_assigned_assignee" && !payload.vendorId) {
|
|
2166
|
-
|
|
2166
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("PUSH", "no vendorId on order \u2014 skip vendor push", {
|
|
2167
2167
|
triggerKey,
|
|
2168
2168
|
orderId: payload.orderId
|
|
2169
2169
|
});
|
|
@@ -2172,7 +2172,7 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2172
2172
|
await sendPushNotificationForTrigger(triggerKey, payload.orderId, "admin", "admin", variables, dataSource, entityMap);
|
|
2173
2173
|
}
|
|
2174
2174
|
} else {
|
|
2175
|
-
|
|
2175
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("PUSH", "push channel disabled", {
|
|
2176
2176
|
triggerKey,
|
|
2177
2177
|
orderId: payload.orderId
|
|
2178
2178
|
});
|
|
@@ -2182,19 +2182,19 @@ async function handleTrigger(triggerKey, payload, dataSource, entityMap, getCms)
|
|
|
2182
2182
|
if (targetPhone) {
|
|
2183
2183
|
await sendWhatsAppForTrigger(triggerKey, payload.orderId, targetPhone, variables, dataSource, entityMap, getCms);
|
|
2184
2184
|
} else {
|
|
2185
|
-
|
|
2185
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("WHATSAPP", "no recipient phone", {
|
|
2186
2186
|
triggerKey,
|
|
2187
2187
|
orderId: payload.orderId
|
|
2188
2188
|
});
|
|
2189
2189
|
}
|
|
2190
2190
|
} else {
|
|
2191
|
-
|
|
2191
|
+
chunkM5QDJOUP_cjs.notifyLog.skip("WHATSAPP", "WhatsApp channel disabled", {
|
|
2192
2192
|
triggerKey,
|
|
2193
2193
|
orderId: payload.orderId
|
|
2194
2194
|
});
|
|
2195
2195
|
}
|
|
2196
2196
|
}
|
|
2197
|
-
|
|
2197
|
+
chunkXHPRD45G_cjs.__name(handleTrigger, "handleTrigger");
|
|
2198
2198
|
var globalGetCms = null;
|
|
2199
2199
|
function initWhatsappTriggerDispatcher(deps) {
|
|
2200
2200
|
if (deps?.getCms) globalGetCms = deps.getCms;
|
|
@@ -2203,9 +2203,9 @@ function initWhatsappTriggerDispatcher(deps) {
|
|
|
2203
2203
|
const { dataSource, entityMap, getCms } = deps;
|
|
2204
2204
|
void dataSource.query(`ALTER TYPE "order_notification_bindings_channel_enum" ADD VALUE IF NOT EXISTS 'mobile'`).catch(() => {
|
|
2205
2205
|
});
|
|
2206
|
-
|
|
2206
|
+
chunkM5QDJOUP_cjs.notificationTriggerEmitter.onAnyTrigger((triggerKey, payload) => {
|
|
2207
2207
|
void handleTrigger(triggerKey, payload, dataSource, entityMap, getCms).catch((err) => {
|
|
2208
|
-
|
|
2208
|
+
chunkM5QDJOUP_cjs.notifyLog.error("TRIGGER", "dispatcher handleTrigger failed", {
|
|
2209
2209
|
triggerKey,
|
|
2210
2210
|
orderId: payload.orderId,
|
|
2211
2211
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -2213,7 +2213,7 @@ function initWhatsappTriggerDispatcher(deps) {
|
|
|
2213
2213
|
});
|
|
2214
2214
|
});
|
|
2215
2215
|
});
|
|
2216
|
-
|
|
2216
|
+
chunkM5QDJOUP_cjs.notifyLog.trigger("dispatcher initialized", {
|
|
2217
2217
|
channels: [
|
|
2218
2218
|
"email",
|
|
2219
2219
|
"whatsapp",
|
|
@@ -2221,14 +2221,14 @@ function initWhatsappTriggerDispatcher(deps) {
|
|
|
2221
2221
|
]
|
|
2222
2222
|
});
|
|
2223
2223
|
}
|
|
2224
|
-
|
|
2224
|
+
chunkXHPRD45G_cjs.__name(initWhatsappTriggerDispatcher, "initWhatsappTriggerDispatcher");
|
|
2225
2225
|
async function dispatchOrderNotificationDirectly(triggerKey, payload, dataSource, entityMap, getCms) {
|
|
2226
2226
|
const cmsResolver = getCms ?? globalGetCms ?? (async () => ({
|
|
2227
|
-
getPlugin: /* @__PURE__ */
|
|
2227
|
+
getPlugin: /* @__PURE__ */ chunkXHPRD45G_cjs.__name(() => null, "getPlugin")
|
|
2228
2228
|
}));
|
|
2229
2229
|
await handleTrigger(triggerKey, payload, dataSource, entityMap, cmsResolver);
|
|
2230
2230
|
}
|
|
2231
|
-
|
|
2231
|
+
chunkXHPRD45G_cjs.__name(dispatchOrderNotificationDirectly, "dispatchOrderNotificationDirectly");
|
|
2232
2232
|
async function resendOrderNotification(triggerKey, orderId, deps) {
|
|
2233
2233
|
if (!deps.entityMap.orders) return {
|
|
2234
2234
|
ok: false,
|
|
@@ -2278,7 +2278,7 @@ async function resendOrderNotification(triggerKey, orderId, deps) {
|
|
|
2278
2278
|
ok: true
|
|
2279
2279
|
};
|
|
2280
2280
|
}
|
|
2281
|
-
|
|
2281
|
+
chunkXHPRD45G_cjs.__name(resendOrderNotification, "resendOrderNotification");
|
|
2282
2282
|
async function emitOrderNotificationTrigger(dataSource, entityMap, triggerKey, payload) {
|
|
2283
2283
|
try {
|
|
2284
2284
|
const settings = await getSettingsGroup(dataSource, entityMap, "event_notifications");
|
|
@@ -2287,7 +2287,7 @@ async function emitOrderNotificationTrigger(dataSource, entityMap, triggerKey, p
|
|
|
2287
2287
|
if (settings.whatsapp_enabled !== "false" && settings.whatsapp_enabled !== "0") enabledChannels.push("whatsapp");
|
|
2288
2288
|
if (settings.sms_enabled !== "false" && settings.sms_enabled !== "0") enabledChannels.push("sms");
|
|
2289
2289
|
if (settings.push_enabled !== "false" && settings.push_enabled !== "0") enabledChannels.push("push");
|
|
2290
|
-
|
|
2290
|
+
chunkM5QDJOUP_cjs.notificationTriggerEmitter.emitTrigger(triggerKey, payload);
|
|
2291
2291
|
return {
|
|
2292
2292
|
ok: true,
|
|
2293
2293
|
channels: enabledChannels
|
|
@@ -2299,7 +2299,7 @@ async function emitOrderNotificationTrigger(dataSource, entityMap, triggerKey, p
|
|
|
2299
2299
|
};
|
|
2300
2300
|
}
|
|
2301
2301
|
}
|
|
2302
|
-
|
|
2302
|
+
chunkXHPRD45G_cjs.__name(emitOrderNotificationTrigger, "emitOrderNotificationTrigger");
|
|
2303
2303
|
|
|
2304
2304
|
exports.CHAT_EMAIL_LOG = CHAT_EMAIL_LOG;
|
|
2305
2305
|
exports.WhatsAppService = WhatsAppService;
|