@infuro/cms-core 1.0.73 → 1.0.74
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 +37 -12
- package/dist/admin.js +37 -12
- package/dist/api.cjs +37 -37
- package/dist/api.js +5 -5
- package/dist/{chunk-BQQMTQ4C.cjs → chunk-25T6HP5T.cjs} +2 -2
- package/dist/{chunk-TTOEY7AH.cjs → chunk-2JV4EDY3.cjs} +3 -3
- package/dist/{chunk-LJ5C4RBF.js → chunk-6TRH3VY7.js} +1 -1
- package/dist/{chunk-4MNVIGVJ.cjs → chunk-D3SR6CYU.cjs} +3 -3
- package/dist/{chunk-PQJIJ4ZX.js → chunk-DAUBLBTP.js} +1 -1
- package/dist/{chunk-HQ3A43HO.cjs → chunk-H4UIIBFD.cjs} +139 -84
- package/dist/{chunk-YHVA5NHI.js → chunk-LUSJITTI.js} +43 -6
- package/dist/{chunk-4LF5OGBF.js → chunk-OQOO2JMB.js} +96 -41
- package/dist/{chunk-HZZTDM5J.js → chunk-R5HLPH6P.js} +1 -1
- package/dist/{chunk-3LF4RYAJ.js → chunk-X3IJG25M.js} +1 -1
- package/dist/{chunk-2JHGIWH7.cjs → chunk-X5ILLSTD.cjs} +43 -6
- package/dist/{chunk-NIBEGDD4.cjs → chunk-ZBSH4GWB.cjs} +1 -1
- package/dist/{email-queue-MWP4R67H.js → email-queue-5TOJJT3P.js} +3 -3
- package/dist/{email-queue-BJDH2ID7.cjs → email-queue-X2A46VD3.cjs} +7 -7
- package/dist/{emit-order-notification-trigger-TBXAZAPS.js → emit-order-notification-trigger-3RAVWKLG.js} +1 -1
- package/dist/{emit-order-notification-trigger-I4HQSTEN.cjs → emit-order-notification-trigger-MY3KP7CD.cjs} +3 -3
- package/dist/{erp-order-invoice-5O42ZKC5.cjs → erp-order-invoice-23BDWC2H.cjs} +6 -6
- package/dist/{erp-order-invoice-JEQKFXG4.js → erp-order-invoice-SEZZUDMW.js} +2 -2
- package/dist/generate-local-invoice-pdf-V5FHS23Z.js +3 -0
- package/dist/{generate-local-invoice-pdf-2NCA2WBL.cjs → generate-local-invoice-pdf-XYBVKHNP.cjs} +2 -2
- package/dist/index.cjs +232 -232
- package/dist/index.js +9 -9
- package/dist/{order-completion-otp-handlers-KHLZQQJX.js → order-completion-otp-handlers-2WOFSORP.js} +4 -4
- package/dist/{order-completion-otp-handlers-2ZKRK5SN.cjs → order-completion-otp-handlers-EWY47XUA.cjs} +6 -6
- package/dist/{order-notification-dispatcher-Z3MXNF4U.js → order-notification-dispatcher-COR2ZHM3.js} +4 -4
- package/dist/{order-notification-dispatcher-37KDVHBM.cjs → order-notification-dispatcher-KTOAMMSD.cjs} +9 -9
- package/package.json +1 -1
- package/dist/generate-local-invoice-pdf-XUH6GYEJ.js +0 -3
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2JV4EDY3_cjs = require('./chunk-2JV4EDY3.cjs');
|
|
4
4
|
var chunkKB7EBYPR_cjs = require('./chunk-KB7EBYPR.cjs');
|
|
5
5
|
var chunkKJB5LBFQ_cjs = require('./chunk-KJB5LBFQ.cjs');
|
|
6
6
|
var chunk3LQS4ATQ_cjs = require('./chunk-3LQS4ATQ.cjs');
|
|
7
7
|
var chunkJRW3GQD4_cjs = require('./chunk-JRW3GQD4.cjs');
|
|
8
8
|
var chunkY54WDY2O_cjs = require('./chunk-Y54WDY2O.cjs');
|
|
9
9
|
var chunkPRXVSSIF_cjs = require('./chunk-PRXVSSIF.cjs');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var chunkD3SR6CYU_cjs = require('./chunk-D3SR6CYU.cjs');
|
|
11
|
+
var chunk25T6HP5T_cjs = require('./chunk-25T6HP5T.cjs');
|
|
12
12
|
var chunkRQCXRCYM_cjs = require('./chunk-RQCXRCYM.cjs');
|
|
13
13
|
var chunkEYUBL7YH_cjs = require('./chunk-EYUBL7YH.cjs');
|
|
14
14
|
var chunk3ASNJS2H_cjs = require('./chunk-3ASNJS2H.cjs');
|
|
@@ -3596,6 +3596,15 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
3596
3596
|
if (resource === "discounts") {
|
|
3597
3597
|
const scope = await resolveScope();
|
|
3598
3598
|
const repo2 = dataSource.getRepository(entity);
|
|
3599
|
+
try {
|
|
3600
|
+
await repo2.createQueryBuilder().update(entity).set({
|
|
3601
|
+
status: "INACTIVE"
|
|
3602
|
+
}).where("status = :activeStatus AND validUntil IS NOT NULL AND validUntil < :currentDate", {
|
|
3603
|
+
activeStatus: "ACTIVE",
|
|
3604
|
+
currentDate: /* @__PURE__ */ new Date()
|
|
3605
|
+
}).execute();
|
|
3606
|
+
} catch {
|
|
3607
|
+
}
|
|
3599
3608
|
const allowedSort = [
|
|
3600
3609
|
"id",
|
|
3601
3610
|
"name",
|
|
@@ -3910,9 +3919,14 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
3910
3919
|
...orderWithoutPayments,
|
|
3911
3920
|
contact: contact ? {
|
|
3912
3921
|
id: contact.id,
|
|
3913
|
-
name: contact.name,
|
|
3914
|
-
email: contact.email,
|
|
3915
|
-
phone: contact.phone
|
|
3922
|
+
name: order.metadata?.customerName || contact.name,
|
|
3923
|
+
email: order.metadata?.customerEmail || contact.email,
|
|
3924
|
+
phone: order.metadata?.customerPhone || contact.phone
|
|
3925
|
+
} : order.metadata?.customerName || order.metadata?.customerEmail ? {
|
|
3926
|
+
id: 0,
|
|
3927
|
+
name: order.metadata?.customerName || "Customer",
|
|
3928
|
+
email: order.metadata?.customerEmail || "",
|
|
3929
|
+
phone: order.metadata?.customerPhone || null
|
|
3916
3930
|
} : null,
|
|
3917
3931
|
assignedUser: assignedUserObj ? {
|
|
3918
3932
|
id: assignedUserObj.id,
|
|
@@ -4076,6 +4090,8 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
4076
4090
|
const contact = row.contact;
|
|
4077
4091
|
return {
|
|
4078
4092
|
...row,
|
|
4093
|
+
contactId: contact?.id ?? row.contactId ?? null,
|
|
4094
|
+
customerId: customer?.id ?? row.customerId ?? null,
|
|
4079
4095
|
name: customer?.name ?? contact?.name ?? null,
|
|
4080
4096
|
email: customer?.email ?? contact?.email ?? null,
|
|
4081
4097
|
phone: customer?.phone ?? contact?.phone ?? null,
|
|
@@ -5221,6 +5237,15 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5221
5237
|
deleted: false
|
|
5222
5238
|
}
|
|
5223
5239
|
});
|
|
5240
|
+
if (contact && emailRaw && contact.email?.toLowerCase() !== emailRaw.toLowerCase()) {
|
|
5241
|
+
const contactByEmail = await contactRepo.findOne({
|
|
5242
|
+
where: {
|
|
5243
|
+
email: emailRaw,
|
|
5244
|
+
deleted: false
|
|
5245
|
+
}
|
|
5246
|
+
});
|
|
5247
|
+
contact = contactByEmail ?? null;
|
|
5248
|
+
}
|
|
5224
5249
|
}
|
|
5225
5250
|
if (!contact) {
|
|
5226
5251
|
if (!emailRaw) {
|
|
@@ -5238,16 +5263,15 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5238
5263
|
});
|
|
5239
5264
|
}
|
|
5240
5265
|
if (!contact) {
|
|
5241
|
-
const
|
|
5266
|
+
const nameRaw = String(body["contact.name"] ?? "").trim();
|
|
5242
5267
|
const phoneRaw2 = body["contact.phone"];
|
|
5243
5268
|
contact = await contactRepo.save(contactRepo.create({
|
|
5244
|
-
name:
|
|
5269
|
+
name: nameRaw || emailRaw.split("@")[0] || "Customer",
|
|
5245
5270
|
email: emailRaw,
|
|
5246
5271
|
phone: phoneRaw2 == null || phoneRaw2 === "" ? null : String(phoneRaw2),
|
|
5247
5272
|
type: "customer"
|
|
5248
5273
|
}));
|
|
5249
5274
|
}
|
|
5250
|
-
const nameRaw = String(body["contact.name"] ?? contact.name ?? "").trim();
|
|
5251
5275
|
const phoneRaw = body["contact.phone"] ?? contact.phone;
|
|
5252
5276
|
const emailForVc = (emailRaw || String(contact.email ?? "")).trim().toLowerCase();
|
|
5253
5277
|
const phoneToSave = phoneRaw == null || phoneRaw === "" ? null : String(phoneRaw).trim();
|
|
@@ -5257,6 +5281,13 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5257
5281
|
});
|
|
5258
5282
|
contact.phone = phoneToSave;
|
|
5259
5283
|
}
|
|
5284
|
+
const nameToSave = String(body["contact.name"] ?? "").trim();
|
|
5285
|
+
if (nameToSave && contact.name !== nameToSave) {
|
|
5286
|
+
await contactRepo.update(contact.id, {
|
|
5287
|
+
name: nameToSave
|
|
5288
|
+
});
|
|
5289
|
+
contact.name = nameToSave;
|
|
5290
|
+
}
|
|
5260
5291
|
const vendorIdForCustomer = resolveVendorIdForContactCheck(scopeCreate, persistBody);
|
|
5261
5292
|
const orderLinesForVendors = normalizeOrderLinesInput(body.orderLines);
|
|
5262
5293
|
const vendorIdsForVc = [];
|
|
@@ -5268,33 +5299,36 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5268
5299
|
if (!Number.isFinite(pid)) continue;
|
|
5269
5300
|
const product = await productRepoForVc.findOne({
|
|
5270
5301
|
where: {
|
|
5271
|
-
id: pid
|
|
5302
|
+
id: pid,
|
|
5303
|
+
deleted: false
|
|
5272
5304
|
}
|
|
5273
5305
|
});
|
|
5274
|
-
const
|
|
5275
|
-
if (Number.isFinite(
|
|
5306
|
+
const vId = Number(product?.vendorId);
|
|
5307
|
+
if (Number.isFinite(vId) && vId > 0 && !vendorIdsForVc.includes(vId)) {
|
|
5308
|
+
vendorIdsForVc.push(vId);
|
|
5309
|
+
}
|
|
5276
5310
|
}
|
|
5277
5311
|
}
|
|
5278
5312
|
if (vendorIdsForVc.length > 0 && emailForVc) {
|
|
5279
|
-
await ensureVendorCustomersForOrder(dataSource, entityMap, vendorIdsForVc, contact.id, {
|
|
5280
|
-
name:
|
|
5313
|
+
await ensureVendorCustomersForOrder(dataSource, entityMap, vendorIdsForVc, Number(contact.id), {
|
|
5314
|
+
name: contact.name ?? "Customer",
|
|
5281
5315
|
email: emailForVc,
|
|
5282
|
-
phone:
|
|
5316
|
+
phone: phoneToSave
|
|
5283
5317
|
});
|
|
5284
5318
|
}
|
|
5285
|
-
const
|
|
5286
|
-
if (
|
|
5319
|
+
const accountCustomerIdRaw = Number(body.accountCustomerId);
|
|
5320
|
+
if (Number.isFinite(accountCustomerIdRaw) && accountCustomerIdRaw > 0 && entityMap.customer_contacts) {
|
|
5287
5321
|
const ccRepo = dataSource.getRepository(entityMap.customer_contacts);
|
|
5288
|
-
const orderContactId = contact.id;
|
|
5289
|
-
const
|
|
5322
|
+
const orderContactId = Number(contact.id);
|
|
5323
|
+
const existingCc = await ccRepo.findOne({
|
|
5290
5324
|
where: {
|
|
5291
|
-
customerId:
|
|
5325
|
+
customerId: accountCustomerIdRaw,
|
|
5292
5326
|
contactId: orderContactId
|
|
5293
5327
|
}
|
|
5294
5328
|
});
|
|
5295
|
-
if (!
|
|
5329
|
+
if (!existingCc) {
|
|
5296
5330
|
await ccRepo.save(ccRepo.create({
|
|
5297
|
-
customerId:
|
|
5331
|
+
customerId: accountCustomerIdRaw,
|
|
5298
5332
|
contactId: orderContactId
|
|
5299
5333
|
}));
|
|
5300
5334
|
}
|
|
@@ -5303,6 +5337,13 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5303
5337
|
persistBody.contactId = contact.id;
|
|
5304
5338
|
persistBody.orderNumber = `ORD00${randomPart}`;
|
|
5305
5339
|
persistBody.qrToken = crypto2__default.default.randomBytes(16).toString("hex");
|
|
5340
|
+
const metaSnapshot = typeof persistBody.metadata === "object" && persistBody.metadata !== null ? persistBody.metadata : {};
|
|
5341
|
+
persistBody.metadata = {
|
|
5342
|
+
...metaSnapshot,
|
|
5343
|
+
customerName: metaSnapshot.customerName || nameToSave || contact.name || void 0,
|
|
5344
|
+
customerEmail: metaSnapshot.customerEmail || emailForVc || contact.email || void 0,
|
|
5345
|
+
customerPhone: metaSnapshot.customerPhone || phoneToSave || contact.phone || void 0
|
|
5346
|
+
};
|
|
5306
5347
|
}
|
|
5307
5348
|
if (resource === "orders" && persistBody.assignedUserId) {
|
|
5308
5349
|
const assignCheck = await validateAssigneeOrderPermission(dataSource, entityMap, Number(persistBody.assignedUserId));
|
|
@@ -5528,7 +5569,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5528
5569
|
const orderIdForNotify = created.id;
|
|
5529
5570
|
const finalCreatedStatus = String(created.status ?? createdStatus ?? "pending").toLowerCase();
|
|
5530
5571
|
const initialPayStatus = String(persistBody.paymentStatus ?? body.paymentStatus ?? "unpaid").toLowerCase();
|
|
5531
|
-
void import('./emit-order-notification-trigger-
|
|
5572
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
5532
5573
|
if (finalCreatedStatus === "pending") {
|
|
5533
5574
|
if (initialPayStatus === "failed") {
|
|
5534
5575
|
fireOrderNotificationTrigger("payment_failed", orderIdForNotify, {
|
|
@@ -6050,8 +6091,22 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
6050
6091
|
id: "ASC"
|
|
6051
6092
|
}
|
|
6052
6093
|
});
|
|
6094
|
+
const orderMeta = order?.metadata;
|
|
6095
|
+
const ordContact = order?.contact;
|
|
6096
|
+
const mappedContact = ordContact ? {
|
|
6097
|
+
...ordContact,
|
|
6098
|
+
name: orderMeta?.customerName || ordContact.name,
|
|
6099
|
+
email: orderMeta?.customerEmail || ordContact.email,
|
|
6100
|
+
phone: orderMeta?.customerPhone || ordContact.phone
|
|
6101
|
+
} : orderMeta?.customerName || orderMeta?.customerEmail ? {
|
|
6102
|
+
id: 0,
|
|
6103
|
+
name: orderMeta?.customerName || "Customer",
|
|
6104
|
+
email: orderMeta?.customerEmail || "",
|
|
6105
|
+
phone: orderMeta?.customerPhone || null
|
|
6106
|
+
} : null;
|
|
6053
6107
|
return json({
|
|
6054
6108
|
...order,
|
|
6109
|
+
contact: mappedContact,
|
|
6055
6110
|
relatedOrders
|
|
6056
6111
|
});
|
|
6057
6112
|
}
|
|
@@ -6749,7 +6804,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
6749
6804
|
const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
|
|
6750
6805
|
const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
|
|
6751
6806
|
if (assigneeUpdated) {
|
|
6752
|
-
void import('./emit-order-notification-trigger-
|
|
6807
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
6753
6808
|
fireOrderNotificationTrigger("order_assigned", updatedOrder.id, {
|
|
6754
6809
|
dataSource,
|
|
6755
6810
|
entityMap
|
|
@@ -6766,7 +6821,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
6766
6821
|
const payments = Array.isArray(updatedOrder.payments) ? updatedOrder.payments : [];
|
|
6767
6822
|
const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
|
|
6768
6823
|
const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
|
|
6769
|
-
void import('./emit-order-notification-trigger-
|
|
6824
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
6770
6825
|
if (newStatus === "pending") {
|
|
6771
6826
|
if (curPayStatus === "failed") {
|
|
6772
6827
|
fireOrderNotificationTrigger("payment_failed", updatedOrder.id, {
|
|
@@ -7485,7 +7540,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
7485
7540
|
});
|
|
7486
7541
|
}
|
|
7487
7542
|
if (ordStatus === "pending" || ordStatus === "confirmed") {
|
|
7488
|
-
void import('./emit-order-notification-trigger-
|
|
7543
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
7489
7544
|
fireOrderNotificationTrigger("order_placed", pOrder, {
|
|
7490
7545
|
dataSource,
|
|
7491
7546
|
entityMap
|
|
@@ -7499,7 +7554,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
7499
7554
|
}
|
|
7500
7555
|
}
|
|
7501
7556
|
} else if (newPayStatus === "failed") {
|
|
7502
|
-
void import('./emit-order-notification-trigger-
|
|
7557
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
7503
7558
|
fireOrderNotificationTrigger("payment_failed", pOrder, {
|
|
7504
7559
|
dataSource,
|
|
7505
7560
|
entityMap
|
|
@@ -7507,7 +7562,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
7507
7562
|
}).catch(() => {
|
|
7508
7563
|
});
|
|
7509
7564
|
} else if (newPayStatus === "refunded") {
|
|
7510
|
-
void import('./emit-order-notification-trigger-
|
|
7565
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
7511
7566
|
fireOrderNotificationTrigger("payment_refund_initiated", pOrder, {
|
|
7512
7567
|
dataSource,
|
|
7513
7568
|
entityMap
|
|
@@ -7634,7 +7689,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
7634
7689
|
const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
|
|
7635
7690
|
const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
|
|
7636
7691
|
if (assigneeUpdated) {
|
|
7637
|
-
void import('./emit-order-notification-trigger-
|
|
7692
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
7638
7693
|
fireOrderNotificationTrigger("order_assigned", ord.id, {
|
|
7639
7694
|
dataSource,
|
|
7640
7695
|
entityMap
|
|
@@ -7651,7 +7706,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
7651
7706
|
const payments = Array.isArray(ord.payments) ? ord.payments : [];
|
|
7652
7707
|
const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
|
|
7653
7708
|
const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
|
|
7654
|
-
void import('./emit-order-notification-trigger-
|
|
7709
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
7655
7710
|
if (newStatus === "pending") {
|
|
7656
7711
|
if (curPayStatus === "failed") {
|
|
7657
7712
|
fireOrderNotificationTrigger("payment_failed", ord.id, {
|
|
@@ -10770,7 +10825,7 @@ function createFormSubmissionHandler(config) {
|
|
|
10770
10825
|
label: f.label && String(f.label).trim() || `Field ${f.id}`,
|
|
10771
10826
|
value: formatSubmissionFieldValue(data[String(f.id)])
|
|
10772
10827
|
}));
|
|
10773
|
-
await
|
|
10828
|
+
await chunkD3SR6CYU_cjs.queueEmail(cms, {
|
|
10774
10829
|
to,
|
|
10775
10830
|
templateName: "formSubmission",
|
|
10776
10831
|
ctx: {
|
|
@@ -10824,7 +10879,7 @@ function createUsersApiHandlers(config) {
|
|
|
10824
10879
|
try {
|
|
10825
10880
|
const cms = await getCms();
|
|
10826
10881
|
const companyDetails = getCompanyDetails ? await getCompanyDetails() : {};
|
|
10827
|
-
await
|
|
10882
|
+
await chunkD3SR6CYU_cjs.queueEmail(cms, {
|
|
10828
10883
|
to: toEmail,
|
|
10829
10884
|
templateName: "invite",
|
|
10830
10885
|
ctx: {
|
|
@@ -12097,7 +12152,7 @@ function createChatHandlers(config) {
|
|
|
12097
12152
|
const notifyEmailAgent = await findLlmAgentByScope(dataSource, entityMap, LLM_AGENT_SCOPE_EMAIL_INTENT_CHATBOT, {
|
|
12098
12153
|
enabledOnly: false
|
|
12099
12154
|
});
|
|
12100
|
-
const emailTool =
|
|
12155
|
+
const emailTool = chunk2JV4EDY3_cjs.resolveChatEmailToolSettings(llmSettings, {
|
|
12101
12156
|
chatbotValidationRules: agentRow?.validationRules ?? null,
|
|
12102
12157
|
notifyAgent: notifyEmailAgent ? {
|
|
12103
12158
|
systemInstruction: notifyEmailAgent.systemInstruction,
|
|
@@ -12107,7 +12162,7 @@ function createChatHandlers(config) {
|
|
|
12107
12162
|
const emailPlugin2 = cms.getPlugin("email");
|
|
12108
12163
|
const convLeadSent = conv.leadEmailSentAt;
|
|
12109
12164
|
const chatAgentFn = llm.chatAgent?.bind(llm);
|
|
12110
|
-
console.info(
|
|
12165
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline check", {
|
|
12111
12166
|
conversationId,
|
|
12112
12167
|
enabled: emailTool.enabled,
|
|
12113
12168
|
intentCount: emailTool.intents.length,
|
|
@@ -12121,27 +12176,27 @@ function createChatHandlers(config) {
|
|
|
12121
12176
|
mergedPromptIncludesNotify: Boolean(notifyEmailAgent?.systemInstruction?.trim())
|
|
12122
12177
|
});
|
|
12123
12178
|
if (!emailTool.enabled) {
|
|
12124
|
-
console.info(
|
|
12179
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
12125
12180
|
conversationId,
|
|
12126
12181
|
reason: "email_tool_disabled"
|
|
12127
12182
|
});
|
|
12128
12183
|
} else if (emailTool.intents.length === 0) {
|
|
12129
|
-
console.info(
|
|
12184
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
12130
12185
|
conversationId,
|
|
12131
12186
|
reason: "no_intents_configured"
|
|
12132
12187
|
});
|
|
12133
12188
|
} else if (!emailPlugin2) {
|
|
12134
|
-
console.info(
|
|
12189
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
12135
12190
|
conversationId,
|
|
12136
12191
|
reason: "email_plugin_missing"
|
|
12137
12192
|
});
|
|
12138
12193
|
} else if (!chatAgentFn) {
|
|
12139
|
-
console.info(
|
|
12194
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
12140
12195
|
conversationId,
|
|
12141
12196
|
reason: "llm_chat_agent_unavailable"
|
|
12142
12197
|
});
|
|
12143
12198
|
} else if (convLeadSent) {
|
|
12144
|
-
console.info(
|
|
12199
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
12145
12200
|
conversationId,
|
|
12146
12201
|
reason: "lead_email_already_sent",
|
|
12147
12202
|
leadEmailSentAt: convLeadSent
|
|
@@ -12154,7 +12209,7 @@ function createChatHandlers(config) {
|
|
|
12154
12209
|
}
|
|
12155
12210
|
});
|
|
12156
12211
|
if (!contactRow) {
|
|
12157
|
-
console.warn(
|
|
12212
|
+
console.warn(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline skipped", {
|
|
12158
12213
|
conversationId,
|
|
12159
12214
|
reason: "contact_not_found",
|
|
12160
12215
|
contactId
|
|
@@ -12162,7 +12217,7 @@ function createChatHandlers(config) {
|
|
|
12162
12217
|
} else {
|
|
12163
12218
|
const c = contactRow;
|
|
12164
12219
|
try {
|
|
12165
|
-
const intent = await
|
|
12220
|
+
const intent = await chunk2JV4EDY3_cjs.detectChatLeadIntent({
|
|
12166
12221
|
chatAgent: chatAgentFn
|
|
12167
12222
|
}, {
|
|
12168
12223
|
settings: emailTool,
|
|
@@ -12176,15 +12231,15 @@ function createChatHandlers(config) {
|
|
|
12176
12231
|
model: agentRow?.model?.trim() || notifyEmailAgent?.model?.trim() || void 0
|
|
12177
12232
|
});
|
|
12178
12233
|
if (!intent.intent || !intent.emailTo) {
|
|
12179
|
-
console.info(
|
|
12234
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "no email sent", {
|
|
12180
12235
|
conversationId,
|
|
12181
12236
|
reason: intent.intent ? "missing_email_to" : "no_intent_match",
|
|
12182
12237
|
intentLabel: intent.intentLabel,
|
|
12183
12238
|
classifierReason: intent.reason
|
|
12184
12239
|
});
|
|
12185
12240
|
} else {
|
|
12186
|
-
const intentRecipients =
|
|
12187
|
-
console.info(
|
|
12241
|
+
const intentRecipients = chunk2JV4EDY3_cjs.parseIntentRecipientEmails(intent.emailTo);
|
|
12242
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "intent matched \u2014 sending", {
|
|
12188
12243
|
conversationId,
|
|
12189
12244
|
intent: intent.intent,
|
|
12190
12245
|
emailTo: intent.emailTo,
|
|
@@ -12195,7 +12250,7 @@ function createChatHandlers(config) {
|
|
|
12195
12250
|
const brandingSettings = await loadSettingsGroupMap(dataSource, entityMap, "branding");
|
|
12196
12251
|
const storeSettings = await loadSettingsGroupMap(dataSource, entityMap, "store");
|
|
12197
12252
|
const companyDetails = chunkEYUBL7YH_cjs.mergeEmailLayoutCompanyDetails(brandingSettings, emailSettings, storeSettings);
|
|
12198
|
-
const leadResult = await
|
|
12253
|
+
const leadResult = await chunk2JV4EDY3_cjs.sendChatLeadEmail(cms, emailSettings, brandingSettings, {
|
|
12199
12254
|
contactName: String(c.name ?? "").trim() || "Visitor",
|
|
12200
12255
|
contactEmail: String(c.email ?? "").trim(),
|
|
12201
12256
|
contactPhone: c.phone ?? null,
|
|
@@ -12203,7 +12258,7 @@ function createChatHandlers(config) {
|
|
|
12203
12258
|
latestMessage: message,
|
|
12204
12259
|
intentCode: intent.intent,
|
|
12205
12260
|
intentReason: intent.intentLabel || intent.reason,
|
|
12206
|
-
transcript:
|
|
12261
|
+
transcript: chunk2JV4EDY3_cjs.buildTranscriptForLeadEmail(history, message),
|
|
12207
12262
|
companyDetails,
|
|
12208
12263
|
recipients: intentRecipients.length > 0 ? intentRecipients : void 0
|
|
12209
12264
|
});
|
|
@@ -12211,13 +12266,13 @@ function createChatHandlers(config) {
|
|
|
12211
12266
|
await convRepo().update(conversationId, {
|
|
12212
12267
|
leadEmailSentAt: /* @__PURE__ */ new Date()
|
|
12213
12268
|
});
|
|
12214
|
-
console.info(
|
|
12269
|
+
console.info(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "lead email recorded", {
|
|
12215
12270
|
conversationId,
|
|
12216
12271
|
sent: true,
|
|
12217
12272
|
recipients: leadResult.recipients
|
|
12218
12273
|
});
|
|
12219
12274
|
} else {
|
|
12220
|
-
console.warn(
|
|
12275
|
+
console.warn(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "lead email not sent", {
|
|
12221
12276
|
conversationId,
|
|
12222
12277
|
sent: false,
|
|
12223
12278
|
error: leadResult.error ?? "unknown",
|
|
@@ -12226,7 +12281,7 @@ function createChatHandlers(config) {
|
|
|
12226
12281
|
}
|
|
12227
12282
|
}
|
|
12228
12283
|
} catch (intentErr) {
|
|
12229
|
-
console.warn(
|
|
12284
|
+
console.warn(chunk2JV4EDY3_cjs.CHAT_EMAIL_LOG, "pipeline error", {
|
|
12230
12285
|
conversationId,
|
|
12231
12286
|
error: intentErr instanceof Error ? intentErr.message : String(intentErr)
|
|
12232
12287
|
});
|
|
@@ -12243,7 +12298,7 @@ function createChatHandlers(config) {
|
|
|
12243
12298
|
});
|
|
12244
12299
|
if (agentRow && llm.chatAgent) {
|
|
12245
12300
|
const fromAgent = llmAgentToChatAgentOptions(agentRow);
|
|
12246
|
-
const systemPrompt =
|
|
12301
|
+
const systemPrompt = chunk2JV4EDY3_cjs.buildChatbotSystemPromptWithEmailTool(fromAgent.systemPrompt, parsedValidation.guardrailsForPrompt, emailTool);
|
|
12247
12302
|
const res = await llm.chatAgent({
|
|
12248
12303
|
...fromAgent,
|
|
12249
12304
|
systemPrompt: systemPrompt || void 0,
|
|
@@ -12264,7 +12319,7 @@ ${contextParts.join("\n\n")}` : "";
|
|
|
12264
12319
|
agentRow.systemInstruction?.trim(),
|
|
12265
12320
|
ragSystem
|
|
12266
12321
|
].filter(Boolean).join("\n\n");
|
|
12267
|
-
systemContent =
|
|
12322
|
+
systemContent = chunk2JV4EDY3_cjs.buildChatbotSystemPromptWithEmailTool(mergedBase || defaultSystem, parsedValidation.guardrailsForPrompt, emailTool) || defaultSystem;
|
|
12268
12323
|
} else {
|
|
12269
12324
|
systemContent = ragSystem || defaultSystem;
|
|
12270
12325
|
}
|
|
@@ -13519,7 +13574,7 @@ function createDeviceTokensHandlers(config) {
|
|
|
13519
13574
|
const title = body.title?.trim() || "Test Push Notification";
|
|
13520
13575
|
const msgBody = body.body?.trim() || "Firebase Push Notification setup is working!";
|
|
13521
13576
|
if (!token || token === "validate" || token === "validate_only") {
|
|
13522
|
-
const valRes = await
|
|
13577
|
+
const valRes = await chunk2JV4EDY3_cjs.validateFcmCredentials(dataSource, entityMap);
|
|
13523
13578
|
if (!valRes.success) {
|
|
13524
13579
|
return json({
|
|
13525
13580
|
success: false,
|
|
@@ -13536,7 +13591,7 @@ function createDeviceTokensHandlers(config) {
|
|
|
13536
13591
|
clientEmail: valRes.clientEmail
|
|
13537
13592
|
});
|
|
13538
13593
|
}
|
|
13539
|
-
const res = await
|
|
13594
|
+
const res = await chunk2JV4EDY3_cjs.sendFcmPushNotification(dataSource, entityMap, {
|
|
13540
13595
|
token,
|
|
13541
13596
|
title,
|
|
13542
13597
|
body: msgBody,
|
|
@@ -14678,7 +14733,7 @@ async function sendVendorOnboardEmails(input, deps) {
|
|
|
14678
14733
|
getVendorEmails(deps)
|
|
14679
14734
|
]);
|
|
14680
14735
|
const companyDetails = chunkEYUBL7YH_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
|
|
14681
|
-
const configuredNotify =
|
|
14736
|
+
const configuredNotify = chunk2JV4EDY3_cjs.parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
|
|
14682
14737
|
const ownerEmail = input.ownerEmail?.trim() || "";
|
|
14683
14738
|
const ownerEmailLower = ownerEmail.toLowerCase();
|
|
14684
14739
|
const sendToOwner = input.sendToOwner !== false;
|
|
@@ -14688,7 +14743,7 @@ async function sendVendorOnboardEmails(input, deps) {
|
|
|
14688
14743
|
];
|
|
14689
14744
|
const notifyEmails = Array.from(new Set(combined.map((e) => e.trim().toLowerCase()).filter((e) => e && e !== ownerEmailLower && !vendorEmailSet.has(e))));
|
|
14690
14745
|
const cms = await deps.getCms();
|
|
14691
|
-
await
|
|
14746
|
+
await chunkD3SR6CYU_cjs.queueVendorOnboardEmails(cms, {
|
|
14692
14747
|
vendorName: input.vendorName,
|
|
14693
14748
|
vendorSlug: input.vendorSlug,
|
|
14694
14749
|
ownerName: input.ownerName,
|
|
@@ -29653,11 +29708,11 @@ function whatsappPlugin(config = {}) {
|
|
|
29653
29708
|
db = await settingsLoader?.() ?? {};
|
|
29654
29709
|
} catch {
|
|
29655
29710
|
}
|
|
29656
|
-
if (!
|
|
29711
|
+
if (!chunk2JV4EDY3_cjs.isWhatsAppPluginEnabled(db)) {
|
|
29657
29712
|
context.logger.warn("WhatsApp plugin skipped: disabled in Plugins \u2192 WhatsApp");
|
|
29658
29713
|
return null;
|
|
29659
29714
|
}
|
|
29660
|
-
const svc = new
|
|
29715
|
+
const svc = new chunk2JV4EDY3_cjs.WhatsAppService(env, staticRest, settingsLoader, getMessageTemplateRow);
|
|
29661
29716
|
return {
|
|
29662
29717
|
send: /* @__PURE__ */ chunkXHPRD45G_cjs.__name((opts) => svc.send(opts), "send")
|
|
29663
29718
|
};
|
|
@@ -29730,7 +29785,7 @@ function createMessageTemplateRowLoader(dataSource, entityMap) {
|
|
|
29730
29785
|
}
|
|
29731
29786
|
chunkXHPRD45G_cjs.__name(createMessageTemplateRowLoader, "createMessageTemplateRowLoader");
|
|
29732
29787
|
function registerMessagingQueueProcessors(cms, entityMap) {
|
|
29733
|
-
|
|
29788
|
+
chunkD3SR6CYU_cjs.registerEmailQueueProcessor(cms, {
|
|
29734
29789
|
getDataSource: /* @__PURE__ */ chunkXHPRD45G_cjs.__name(async () => cms.dataSource, "getDataSource"),
|
|
29735
29790
|
entityMap
|
|
29736
29791
|
});
|
|
@@ -29763,7 +29818,7 @@ async function ensureMessagingPluginsOnCms(base, options) {
|
|
|
29763
29818
|
}
|
|
29764
29819
|
if (!cms.getPlugin("email")) {
|
|
29765
29820
|
try {
|
|
29766
|
-
const instance = await
|
|
29821
|
+
const instance = await chunk2JV4EDY3_cjs.emailPlugin({
|
|
29767
29822
|
type: "SMTP",
|
|
29768
29823
|
from: config.SMTP_FROM ?? "no-reply@localhost",
|
|
29769
29824
|
to: config.SMTP_TO ?? ""
|
|
@@ -29804,7 +29859,7 @@ function messagingPlugins(options) {
|
|
|
29804
29859
|
const config = options.config ?? (typeof process !== "undefined" ? process.env : {});
|
|
29805
29860
|
return [
|
|
29806
29861
|
queuePlugin(),
|
|
29807
|
-
|
|
29862
|
+
chunk2JV4EDY3_cjs.emailPlugin({
|
|
29808
29863
|
type: "SMTP",
|
|
29809
29864
|
from: config.SMTP_FROM ?? "no-reply@localhost",
|
|
29810
29865
|
to: config.SMTP_TO ?? ""
|
|
@@ -29957,7 +30012,7 @@ function createCmsApiHandler(config) {
|
|
|
29957
30012
|
} : void 0;
|
|
29958
30013
|
const entityMap = withLlmKnowledgeEntityFallbacks(rawEntityMap);
|
|
29959
30014
|
if (getCms) {
|
|
29960
|
-
|
|
30015
|
+
chunk2JV4EDY3_cjs.initWhatsappTriggerDispatcher({
|
|
29961
30016
|
dataSource,
|
|
29962
30017
|
entityMap,
|
|
29963
30018
|
getCms
|
|
@@ -30051,7 +30106,7 @@ function createCmsApiHandler(config) {
|
|
|
30051
30106
|
companyDetails
|
|
30052
30107
|
};
|
|
30053
30108
|
if (queue) {
|
|
30054
|
-
const { queueEmail: queueEmail2 } = await import('./email-queue-
|
|
30109
|
+
const { queueEmail: queueEmail2 } = await import('./email-queue-X2A46VD3.cjs');
|
|
30055
30110
|
await queueEmail2(cms, {
|
|
30056
30111
|
to: opts.to,
|
|
30057
30112
|
templateName: "passwordReset",
|
|
@@ -31090,7 +31145,7 @@ function createCmsApiHandler(config) {
|
|
|
31090
31145
|
storeMap[r.key] = r.value;
|
|
31091
31146
|
}
|
|
31092
31147
|
const { normalizeInvoiceTemplateId } = await import('./invoice-templates-2ESQ7K4N.cjs');
|
|
31093
|
-
const { generateLocalInvoicePdf } = await import('./generate-local-invoice-pdf-
|
|
31148
|
+
const { generateLocalInvoicePdf } = await import('./generate-local-invoice-pdf-XYBVKHNP.cjs');
|
|
31094
31149
|
const { resolveInvoiceAssetUrl } = await import('./resolve-invoice-asset-url-J7WAMD26.cjs');
|
|
31095
31150
|
const templateId = normalizeInvoiceTemplateId(templateParam);
|
|
31096
31151
|
const includeQr = qrParam != null ? qrParam === "1" || qrParam === "true" : storeMap.invoice_include_qr === "true";
|
|
@@ -31478,7 +31533,7 @@ function createCmsApiHandler(config) {
|
|
|
31478
31533
|
const pe = await requireEntityPermissionEffective(req, "orders", "read");
|
|
31479
31534
|
if (pe) return pe;
|
|
31480
31535
|
const cms = await getCms();
|
|
31481
|
-
const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-
|
|
31536
|
+
const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-23BDWC2H.cjs');
|
|
31482
31537
|
const oid = Number(path2[1]);
|
|
31483
31538
|
if (!Number.isFinite(oid)) return config.json({
|
|
31484
31539
|
error: "Invalid id"
|
|
@@ -31564,7 +31619,7 @@ function createCmsApiHandler(config) {
|
|
|
31564
31619
|
}
|
|
31565
31620
|
const result = await validateCoupon(dataSource, entityMap, couponCode, orderLinesNorm, currency, contactId, isAutomatic, discountId ?? void 0, vendorId);
|
|
31566
31621
|
return config.json(result, {
|
|
31567
|
-
status:
|
|
31622
|
+
status: 200
|
|
31568
31623
|
});
|
|
31569
31624
|
} catch (err) {
|
|
31570
31625
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -31860,7 +31915,7 @@ function createCmsApiHandler(config) {
|
|
|
31860
31915
|
status: 400
|
|
31861
31916
|
});
|
|
31862
31917
|
}
|
|
31863
|
-
const { resendOrderNotification } = await import('./order-notification-dispatcher-
|
|
31918
|
+
const { resendOrderNotification } = await import('./order-notification-dispatcher-KTOAMMSD.cjs');
|
|
31864
31919
|
const result = await resendOrderNotification(triggerKey, orderId, {
|
|
31865
31920
|
dataSource,
|
|
31866
31921
|
entityMap,
|
|
@@ -32117,7 +32172,7 @@ function createCmsApiHandler(config) {
|
|
|
32117
32172
|
console.error("[cancel-order] refund_request save failed", err);
|
|
32118
32173
|
}
|
|
32119
32174
|
}
|
|
32120
|
-
void import('./emit-order-notification-trigger-
|
|
32175
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
32121
32176
|
fireOrderNotificationTrigger("order_cancelled", orderId, {
|
|
32122
32177
|
dataSource,
|
|
32123
32178
|
entityMap
|
|
@@ -32152,7 +32207,7 @@ function createCmsApiHandler(config) {
|
|
|
32152
32207
|
}, {
|
|
32153
32208
|
status: 400
|
|
32154
32209
|
});
|
|
32155
|
-
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-
|
|
32210
|
+
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-EWY47XUA.cjs');
|
|
32156
32211
|
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
|
|
32157
32212
|
return handlers.getChannels(req, orderId);
|
|
32158
32213
|
}
|
|
@@ -32167,7 +32222,7 @@ function createCmsApiHandler(config) {
|
|
|
32167
32222
|
}, {
|
|
32168
32223
|
status: 400
|
|
32169
32224
|
});
|
|
32170
|
-
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-
|
|
32225
|
+
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-EWY47XUA.cjs');
|
|
32171
32226
|
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
|
|
32172
32227
|
return handlers.sendOtp(req, orderId);
|
|
32173
32228
|
}
|
|
@@ -32182,7 +32237,7 @@ function createCmsApiHandler(config) {
|
|
|
32182
32237
|
}, {
|
|
32183
32238
|
status: 400
|
|
32184
32239
|
});
|
|
32185
|
-
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-
|
|
32240
|
+
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-EWY47XUA.cjs');
|
|
32186
32241
|
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
|
|
32187
32242
|
return handlers.verifyOtp(req, orderId);
|
|
32188
32243
|
}
|
|
@@ -32637,12 +32692,12 @@ async function refreshOrderFromErp(cms, dataSource, entityMap, submission, order
|
|
|
32637
32692
|
const r1 = await submission.postErpReadAction("get-order-status", {
|
|
32638
32693
|
platformOrderId: refId
|
|
32639
32694
|
});
|
|
32640
|
-
const d1 = r1.ok ?
|
|
32695
|
+
const d1 = r1.ok ? chunk25T6HP5T_cjs.unwrapErpReadData(r1.json) : null;
|
|
32641
32696
|
if (d1) {
|
|
32642
32697
|
const mapped = mapErpSaleStatusToOrderStatus(typeof d1.status === "string" ? d1.status : typeof d1.orderStatus === "string" ? d1.orderStatus : typeof d1.state === "string" ? d1.state : void 0);
|
|
32643
32698
|
if (mapped) newStatus = mapped;
|
|
32644
|
-
fulfillment =
|
|
32645
|
-
const refs =
|
|
32699
|
+
fulfillment = chunk25T6HP5T_cjs.mapErpPayloadToFulfillment(d1);
|
|
32700
|
+
const refs = chunk25T6HP5T_cjs.extractChildOrderRefsFromSalePayload(d1);
|
|
32646
32701
|
if (refs.length) {
|
|
32647
32702
|
await ensureChildOrdersFromRefs(orderRepo, order, refs, order.contactId, String(order.currency || "INR"));
|
|
32648
32703
|
}
|
|
@@ -32650,16 +32705,16 @@ async function refreshOrderFromErp(cms, dataSource, entityMap, submission, order
|
|
|
32650
32705
|
const r2 = await submission.postErpReadAction("get-fulfillment-status", {
|
|
32651
32706
|
platformOrderId: refId
|
|
32652
32707
|
});
|
|
32653
|
-
const d2 = r2.ok ?
|
|
32708
|
+
const d2 = r2.ok ? chunk25T6HP5T_cjs.unwrapErpReadData(r2.json) : null;
|
|
32654
32709
|
if (d2) {
|
|
32655
|
-
fulfillment = deepMergeFulfillment(fulfillment,
|
|
32710
|
+
fulfillment = deepMergeFulfillment(fulfillment, chunk25T6HP5T_cjs.mapErpPayloadToFulfillment(d2));
|
|
32656
32711
|
}
|
|
32657
32712
|
const r3 = await submission.postErpReadAction("get-invoice", {
|
|
32658
32713
|
platformOrderId: refId
|
|
32659
32714
|
});
|
|
32660
|
-
const d3 = r3.ok ?
|
|
32715
|
+
const d3 = r3.ok ? chunk25T6HP5T_cjs.unwrapErpReadData(r3.json) : null;
|
|
32661
32716
|
if (d3) {
|
|
32662
|
-
invoiceNumber =
|
|
32717
|
+
invoiceNumber = chunk25T6HP5T_cjs.mapErpPayloadToInvoiceNumber(d3);
|
|
32663
32718
|
invoiceId = pickInvoiceId(d3);
|
|
32664
32719
|
}
|
|
32665
32720
|
const oid = order.id;
|
|
@@ -32695,10 +32750,10 @@ async function refreshOrderFromErp(cms, dataSource, entityMap, submission, order
|
|
|
32695
32750
|
const r = await submission.postErpReadAction("get-return-status", {
|
|
32696
32751
|
platformReturnId
|
|
32697
32752
|
});
|
|
32698
|
-
const d = r.ok ?
|
|
32753
|
+
const d = r.ok ? chunk25T6HP5T_cjs.unwrapErpReadData(r.json) : null;
|
|
32699
32754
|
if (!d) return;
|
|
32700
32755
|
const mapped = mapErpSaleStatusToOrderStatus(typeof d.status === "string" ? d.status : typeof d.returnStatus === "string" ? d.returnStatus : void 0);
|
|
32701
|
-
const fulfillment =
|
|
32756
|
+
const fulfillment = chunk25T6HP5T_cjs.mapErpPayloadToFulfillment(d);
|
|
32702
32757
|
const patch = {};
|
|
32703
32758
|
if (fulfillment !== void 0) patch.fulfillment = fulfillment;
|
|
32704
32759
|
const nextMeta = Object.keys(patch).length ? mergeOrderMetadataPatch(meta, patch) : meta;
|
|
@@ -32821,7 +32876,7 @@ function createStorefrontApiHandler(config) {
|
|
|
32821
32876
|
const otpPepper = config.otpPepper;
|
|
32822
32877
|
const defaultPhoneCc = config.defaultPhoneCountryCode;
|
|
32823
32878
|
function fireStorefrontCheckoutNotifications(orderId) {
|
|
32824
|
-
void import('./emit-order-notification-trigger-
|
|
32879
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
32825
32880
|
fireOrderNotificationTrigger("order_pending", orderId, {
|
|
32826
32881
|
dataSource,
|
|
32827
32882
|
entityMap
|
|
@@ -34505,7 +34560,7 @@ function createStorefrontApiHandler(config) {
|
|
|
34505
34560
|
status: 503
|
|
34506
34561
|
});
|
|
34507
34562
|
const companyDetails = getCompanyDetails ? await getCompanyDetails() : {};
|
|
34508
|
-
await
|
|
34563
|
+
await chunkD3SR6CYU_cjs.queueEmail(cms, {
|
|
34509
34564
|
to: identifier,
|
|
34510
34565
|
templateName: "otp",
|
|
34511
34566
|
ctx: {
|
|
@@ -34730,7 +34785,7 @@ function createStorefrontApiHandler(config) {
|
|
|
34730
34785
|
const companyDetails = getCompanyDetails ? await getCompanyDetails() : {};
|
|
34731
34786
|
const base = (publicSiteUrl || "").replace(/\/$/, "").trim() || "http://localhost:3000";
|
|
34732
34787
|
const verifyEmailUrl = `${base}/verify-email?token=${encodeURIComponent(rawToken)}`;
|
|
34733
|
-
await
|
|
34788
|
+
await chunkD3SR6CYU_cjs.queueEmail(cms, {
|
|
34734
34789
|
to: email,
|
|
34735
34790
|
templateName: "signup",
|
|
34736
34791
|
ctx: {
|
|
@@ -35544,7 +35599,7 @@ function createStorefrontApiHandler(config) {
|
|
|
35544
35599
|
status: 400
|
|
35545
35600
|
});
|
|
35546
35601
|
const cms = await getCms();
|
|
35547
|
-
return
|
|
35602
|
+
return chunk25T6HP5T_cjs.streamOrderInvoicePdf(cms, dataSource, entityMap, orderId, {
|
|
35548
35603
|
ownerContactId: contact.id
|
|
35549
35604
|
});
|
|
35550
35605
|
}
|
|
@@ -35766,7 +35821,7 @@ function createStorefrontApiHandler(config) {
|
|
|
35766
35821
|
} catch {
|
|
35767
35822
|
}
|
|
35768
35823
|
try {
|
|
35769
|
-
void import('./emit-order-notification-trigger-
|
|
35824
|
+
void import('./emit-order-notification-trigger-MY3KP7CD.cjs').then(({ fireOrderNotificationTrigger }) => {
|
|
35770
35825
|
fireOrderNotificationTrigger("order_cancelled", orderId, {
|
|
35771
35826
|
dataSource,
|
|
35772
35827
|
entityMap
|