@infuro/cms-core 1.0.67 → 1.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/admin.cjs +121 -12
  2. package/dist/admin.js +121 -12
  3. package/dist/api.cjs +43 -40
  4. package/dist/api.js +11 -8
  5. package/dist/auth.cjs +12 -12
  6. package/dist/auth.js +2 -2
  7. package/dist/{chunk-BVLN75LP.cjs → chunk-22XKONB5.cjs} +201 -71
  8. package/dist/{chunk-TU23GJPJ.js → chunk-7JCCPQEF.js} +1 -1
  9. package/dist/{chunk-WMMZZRDJ.cjs → chunk-GN4LKG4V.cjs} +1 -1
  10. package/dist/chunk-IKTBZJHT.js +16 -0
  11. package/dist/chunk-M5GPOPGX.cjs +49 -0
  12. package/dist/{chunk-GLLCLRCQ.js → chunk-MYUGQHU4.js} +158 -28
  13. package/dist/{chunk-NV5IRHI3.js → chunk-N4LBZXBG.js} +2 -2
  14. package/dist/chunk-P6S4XFZO.cjs +18 -0
  15. package/dist/{chunk-RCE5SJBA.js → chunk-SKJH7PX4.js} +1 -1
  16. package/dist/{chunk-5MZFQRDW.cjs → chunk-SMHQV3WL.cjs} +4 -4
  17. package/dist/chunk-SUUD7OUG.cjs +455 -0
  18. package/dist/{chunk-XFDIIVZB.cjs → chunk-UMC7W5G3.cjs} +3 -3
  19. package/dist/chunk-WKDBMDUX.js +45 -0
  20. package/dist/chunk-Z5OB5QGN.js +465 -0
  21. package/dist/chunk-ZIT4IP6N.js +445 -0
  22. package/dist/chunk-ZX5U3VCB.cjs +471 -0
  23. package/dist/email-queue-3QBQ63F7.js +8 -0
  24. package/dist/{email-queue-4OY45JIU.cjs → email-queue-K4E4OFI7.cjs} +9 -6
  25. package/dist/{emit-order-notification-trigger-ZD5YN3JM.cjs → emit-order-notification-trigger-ROASTYQP.cjs} +3 -3
  26. package/dist/{emit-order-notification-trigger-EJJZ6XTS.js → emit-order-notification-trigger-YUQTPELC.js} +1 -1
  27. package/dist/{erp-order-invoice-YUSPZ7CE.cjs → erp-order-invoice-AZ5MX2JB.cjs} +8 -5
  28. package/dist/{erp-order-invoice-H6HCJ7YS.js → erp-order-invoice-XSYHAMBS.js} +4 -1
  29. package/dist/generate-local-invoice-pdf-BQTCL5MW.cjs +12 -0
  30. package/dist/generate-local-invoice-pdf-OCFG47SE.js +3 -0
  31. package/dist/index.cjs +286 -283
  32. package/dist/index.d.cts +7 -1
  33. package/dist/index.d.ts +7 -1
  34. package/dist/index.js +16 -13
  35. package/dist/invoice-templates-GZ33OENC.js +2 -0
  36. package/dist/invoice-templates-RB462AQN.cjs +19 -0
  37. package/dist/{order-completion-otp-handlers-DZAXK4GQ.cjs → order-completion-otp-handlers-DDQREULW.cjs} +8 -5
  38. package/dist/{order-completion-otp-handlers-HFGCPC4O.js → order-completion-otp-handlers-NROWBGXN.js} +6 -3
  39. package/dist/{order-notification-dispatcher-LL7ETKLU.cjs → order-notification-dispatcher-6HCJ6Q75.cjs} +12 -9
  40. package/dist/{order-notification-dispatcher-ECPFI7CD.js → order-notification-dispatcher-KM2SY7TX.js} +7 -4
  41. package/dist/resolve-invoice-asset-url-JEZRENJW.cjs +11 -0
  42. package/dist/resolve-invoice-asset-url-QZ2FRDHI.js +2 -0
  43. package/package.json +1 -1
  44. package/dist/chunk-GLD263KW.cjs +0 -862
  45. package/dist/chunk-OPJEV44S.js +0 -847
  46. package/dist/email-queue-HGXB2FIS.js +0 -5
  47. package/dist/{chunk-SS3K7OIM.cjs → chunk-HBUV73RB.cjs} +1 -1
  48. package/dist/{chunk-2ISSXYBZ.js → chunk-Z5G54EGD.js} +1 -1
@@ -1,4 +1,4 @@
1
- import { isOrderEligibleForInvoiceEmail, resolveOrderInvoicePdfBytes } from './chunk-OPJEV44S.js';
1
+ import { isOrderEligibleForInvoiceEmail, resolveOrderInvoicePdfBytes } from './chunk-ZIT4IP6N.js';
2
2
  import { __name } from './chunk-SHUYVCID.js';
3
3
 
4
4
  // src/plugins/email/email-queue.ts
@@ -96,7 +96,7 @@ async function emitOrderNotificationTrigger(triggerKey, orderId, deps, extra) {
96
96
  orderId
97
97
  });
98
98
  try {
99
- const { dispatchOrderNotificationDirectly } = await import('./order-notification-dispatcher-LL7ETKLU.cjs');
99
+ const { dispatchOrderNotificationDirectly } = await import('./order-notification-dispatcher-6HCJ6Q75.cjs');
100
100
  await dispatchOrderNotificationDirectly(triggerKey, triggerPayload, deps.dataSource, deps.entityMap);
101
101
  } catch (err) {
102
102
  chunkPA6YDMFZ_cjs.notifyLog.error("TRIGGER", "direct dispatch failed", {
@@ -0,0 +1,16 @@
1
+ import { __name } from './chunk-SHUYVCID.js';
2
+
3
+ // src/lib/invoice/resolve-invoice-asset-url.ts
4
+ function resolveInvoiceAssetUrl(raw) {
5
+ const t = String(raw ?? "").trim();
6
+ if (!t) return null;
7
+ if (/^https?:\/\//i.test(t)) return t;
8
+ if (t.startsWith("//")) return `https:${t}`;
9
+ const base = (process.env.CMS_PUBLIC_URL || process.env.NEXT_PUBLIC_SITE_URL || process.env.NEXTAUTH_URL || "").trim().replace(/\/+$/, "");
10
+ if (!base) return null;
11
+ if (t.startsWith("/")) return `${base}${t}`;
12
+ return `${base}/${t}`;
13
+ }
14
+ __name(resolveInvoiceAssetUrl, "resolveInvoiceAssetUrl");
15
+
16
+ export { resolveInvoiceAssetUrl };
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
+
5
+ // src/lib/invoice/invoice-templates.ts
6
+ var INVOICE_TEMPLATE_IDS = [
7
+ "classic",
8
+ "modern",
9
+ "compact",
10
+ "bold",
11
+ "service_detailed"
12
+ ];
13
+ var INVOICE_TEMPLATE_OPTIONS = [
14
+ {
15
+ id: "classic",
16
+ label: "Classic",
17
+ description: "Traditional invoice with header, lined items, and totals footer."
18
+ },
19
+ {
20
+ id: "modern",
21
+ label: "Modern",
22
+ description: "Clean layout with accent bar and spacious typography."
23
+ },
24
+ {
25
+ id: "compact",
26
+ label: "Compact",
27
+ description: "Dense single-page layout for high line-item counts."
28
+ },
29
+ {
30
+ id: "bold",
31
+ label: "Bold",
32
+ description: "Strong header band and clear payment summary block."
33
+ },
34
+ {
35
+ id: "service_detailed",
36
+ label: "Service Detailed",
37
+ description: "Detailed service invoice with order date, service date, time slot, and assigned technician."
38
+ }
39
+ ];
40
+ function normalizeInvoiceTemplateId(raw) {
41
+ const v = String(raw ?? "").trim().toLowerCase();
42
+ if (v === "service_qr") return "service_detailed";
43
+ return INVOICE_TEMPLATE_IDS.includes(v) ? v : "classic";
44
+ }
45
+ chunkUSNT2KNT_cjs.__name(normalizeInvoiceTemplateId, "normalizeInvoiceTemplateId");
46
+
47
+ exports.INVOICE_TEMPLATE_IDS = INVOICE_TEMPLATE_IDS;
48
+ exports.INVOICE_TEMPLATE_OPTIONS = INVOICE_TEMPLATE_OPTIONS;
49
+ exports.normalizeInvoiceTemplateId = normalizeInvoiceTemplateId;
@@ -1,18 +1,18 @@
1
+ import { inviteStatusForActivation } from './chunk-JXF23MPG.js';
1
2
  import { normalizePhoneE164, generateNumericOtp, createOtpChallenge, queueSms, verifyAndConsumeOtpChallenge } from './chunk-OVTOP42W.js';
3
+ import { EVENT_ORDER_MESSAGE_TEMPLATE_DEFAULTS, EVENT_ORDER_TEMPLATE_KEY, EVENT_ORDER_TEMPLATE_VARIABLES } from './chunk-AYERBA7I.js';
2
4
  import { JOB_RUNNER_QUEUE } from './chunk-XJNNOSJR.js';
3
5
  import { validateInventoryForConfirmedOrderLines, orderStatusHoldsStock, reconcileOrderInventoryBetweenSnapshots, orderInventorySnapshotFromRow, validateInventoryForOrderBecomingConfirmed } from './chunk-3K5AIEIZ.js';
4
- import { resolveChatEmailToolSettings, CHAT_EMAIL_LOG, detectChatLeadIntent, parseIntentRecipientEmails, sendChatLeadEmail, buildTranscriptForLeadEmail, buildChatbotSystemPromptWithEmailTool, validateFcmCredentials, sendFcmPushNotification, parseEmailRecipientsFromConfig, isWhatsAppPluginEnabled, WhatsAppService, emailPlugin, initWhatsappTriggerDispatcher } from './chunk-NV5IRHI3.js';
6
+ import { resolveChatEmailToolSettings, CHAT_EMAIL_LOG, detectChatLeadIntent, parseIntentRecipientEmails, sendChatLeadEmail, buildTranscriptForLeadEmail, buildChatbotSystemPromptWithEmailTool, validateFcmCredentials, sendFcmPushNotification, parseEmailRecipientsFromConfig, isWhatsAppPluginEnabled, WhatsAppService, emailPlugin, initWhatsappTriggerDispatcher } from './chunk-N4LBZXBG.js';
5
7
  import { registerWhatsAppQueueProcessor } from './chunk-GWDI752Q.js';
6
- import { inviteStatusForActivation } from './chunk-JXF23MPG.js';
7
- import { queueEmail, queueVendorOnboardEmails, registerEmailQueueProcessor } from './chunk-TU23GJPJ.js';
8
- import { unwrapErpReadData, mapErpPayloadToFulfillment, extractChildOrderRefsFromSalePayload, mapErpPayloadToInvoiceNumber, streamOrderInvoicePdf } from './chunk-OPJEV44S.js';
8
+ import { queueEmail, queueVendorOnboardEmails, registerEmailQueueProcessor } from './chunk-7JCCPQEF.js';
9
+ import { unwrapErpReadData, mapErpPayloadToFulfillment, extractChildOrderRefsFromSalePayload, mapErpPayloadToInvoiceNumber, streamOrderInvoicePdf } from './chunk-ZIT4IP6N.js';
9
10
  import { isErpIntegrationEnabled } from './chunk-JC6DLWTE.js';
10
11
  import { mergeEmailLayoutCompanyDetails } from './chunk-YRCKEGL2.js';
11
12
  import { getSmsTemplateDefault, SMS_MESSAGE_TEMPLATE_DEFAULTS } from './chunk-MQBT33IV.js';
12
- import { EVENT_ORDER_MESSAGE_TEMPLATE_DEFAULTS, EVENT_ORDER_TEMPLATE_KEY, EVENT_ORDER_TEMPLATE_VARIABLES } from './chunk-AYERBA7I.js';
13
13
  import { ensureCustomerRecord, linkUnclaimedContactToUser, ensureCustomerForUser, canManageRoles, sessionHasEntityAccess } from './chunk-ZY64VJMS.js';
14
- import { retireSoftDeletedUniqueValue, activeUniqueValueExists } from './chunk-DBPSJYLZ.js';
15
14
  import { permissionRowsToRecord, logRbac, isSuperAdmin, vendorPortalFlagsFromUser, VENDOR_SCOPED_STORE_ENTITIES, isVendorPortalUser, getPermissionableEntityKeys, VENDOR_STORE_RBAC_ENTITIES, isSuperAdminGroupName, VENDOR_RBAC_ENTITIES, VENDOR_VIEWER_ROLE_NAME, DEFAULT_VENDOR_ROLE_DEFS, VENDOR_GROUP_NAME, resolveVendorScopeFromSessionUser, canManageVendorRoles, isPlatformAdministrator, canManageVendorTeam, resolveDisabledMultiVendorScope, logEntityAccessDecision, explainSessionEntityAccess } from './chunk-5NOZSG6J.js';
15
+ import { retireSoftDeletedUniqueValue, activeUniqueValueExists } from './chunk-DBPSJYLZ.js';
16
16
  import { queueErp } from './chunk-SYBOCAWB.js';
17
17
  import { __name } from './chunk-SHUYVCID.js';
18
18
  import { PrimaryGeneratedColumn, Column, Entity, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn, Unique, OneToMany, Index, ManyToMany, JoinTable, In, ILike, Between, MoreThanOrEqual, LessThanOrEqual, Not, MoreThan, IsNull } from 'typeorm';
@@ -5313,7 +5313,7 @@ function createCrudHandler(dataSource, entityMap, options) {
5313
5313
  const orderIdForNotify = created.id;
5314
5314
  const finalCreatedStatus = String(created.status ?? createdStatus ?? "pending").toLowerCase();
5315
5315
  const initialPayStatus = String(persistBody.paymentStatus ?? body.paymentStatus ?? "unpaid").toLowerCase();
5316
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
5316
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
5317
5317
  if (finalCreatedStatus === "pending") {
5318
5318
  if (initialPayStatus === "failed") {
5319
5319
  fireOrderNotificationTrigger("payment_failed", orderIdForNotify, {
@@ -6516,7 +6516,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6516
6516
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
6517
6517
  const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
6518
6518
  if (assigneeUpdated) {
6519
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
6519
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
6520
6520
  fireOrderNotificationTrigger("order_assigned", updatedOrder.id, {
6521
6521
  dataSource,
6522
6522
  entityMap
@@ -6533,7 +6533,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
6533
6533
  const payments = Array.isArray(updatedOrder.payments) ? updatedOrder.payments : [];
6534
6534
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
6535
6535
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
6536
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
6536
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
6537
6537
  if (newStatus === "pending") {
6538
6538
  if (curPayStatus === "failed") {
6539
6539
  fireOrderNotificationTrigger("payment_failed", updatedOrder.id, {
@@ -7241,7 +7241,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7241
7241
  });
7242
7242
  }
7243
7243
  if (ordStatus === "pending" || ordStatus === "confirmed") {
7244
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
7244
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
7245
7245
  fireOrderNotificationTrigger("order_placed", pOrder, {
7246
7246
  dataSource,
7247
7247
  entityMap
@@ -7255,7 +7255,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7255
7255
  }
7256
7256
  }
7257
7257
  } else if (newPayStatus === "failed") {
7258
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
7258
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
7259
7259
  fireOrderNotificationTrigger("payment_failed", pOrder, {
7260
7260
  dataSource,
7261
7261
  entityMap
@@ -7263,7 +7263,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7263
7263
  }).catch(() => {
7264
7264
  });
7265
7265
  } else if (newPayStatus === "refunded") {
7266
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
7266
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
7267
7267
  fireOrderNotificationTrigger("payment_refund_initiated", pOrder, {
7268
7268
  dataSource,
7269
7269
  entityMap
@@ -7390,7 +7390,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7390
7390
  const paymentUpdated = Boolean(rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null);
7391
7391
  const assigneeUpdated = Boolean(rawBody && typeof rawBody === "object" && "assignedUserId" in rawBody && rawBody.assignedUserId !== void 0 && Number(rawBody.assignedUserId) > 0 && Number(rawBody.assignedUserId) !== Number(existingOrderRow?.assignedUserId));
7392
7392
  if (assigneeUpdated) {
7393
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
7393
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
7394
7394
  fireOrderNotificationTrigger("order_assigned", ord.id, {
7395
7395
  dataSource,
7396
7396
  entityMap
@@ -7407,7 +7407,7 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
7407
7407
  const payments = Array.isArray(ord.payments) ? ord.payments : [];
7408
7408
  const bodyPayStatus = rawBody && typeof rawBody === "object" && rawBody.paymentStatus != null ? String(rawBody.paymentStatus).toLowerCase() : null;
7409
7409
  const curPayStatus = bodyPayStatus || String(payments[0]?.status || "unpaid").toLowerCase();
7410
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
7410
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
7411
7411
  if (newStatus === "pending") {
7412
7412
  if (curPayStatus === "failed") {
7413
7413
  fireOrderNotificationTrigger("payment_failed", ord.id, {
@@ -15542,6 +15542,7 @@ function createVendorOnboardHandlers(config) {
15542
15542
  state: vp?.state ?? null,
15543
15543
  postalCode: vp?.postalCode ?? null,
15544
15544
  blocked: u?.blocked ?? false,
15545
+ inviteStatus: u?.inviteStatus ?? (u?.password ? "active" : "pending"),
15545
15546
  groupName: u?.group?.name ?? null
15546
15547
  };
15547
15548
  });
@@ -16015,14 +16016,24 @@ function createVendorOnboardHandlers(config) {
16015
16016
  });
16016
16017
  }
16017
16018
  }
16018
- const token = String(user.inviteToken ?? "").trim();
16019
- if (!token || user.inviteStatus !== "pending") {
16019
+ const hasPassword = !!(user.password && String(user.password).trim());
16020
+ const isPending = user.inviteStatus === "pending" || !hasPassword;
16021
+ if (!isPending) {
16020
16022
  return json({
16021
- error: "No pending invite for this user"
16023
+ error: "User has already accepted the invite"
16022
16024
  }, {
16023
16025
  status: 400
16024
16026
  });
16025
16027
  }
16028
+ let token = String(user.inviteToken ?? "").trim();
16029
+ if (!token) {
16030
+ token = newUserInviteToken();
16031
+ await dataSource.getRepository(entityMap.users).update(user.id, {
16032
+ inviteToken: token,
16033
+ inviteStatus: "pending",
16034
+ password: null
16035
+ });
16036
+ }
16026
16037
  const inviteLink = buildUserInviteLink(baseUrl, token);
16027
16038
  const emailSent = await trySendVendorOnboardEmails({
16028
16039
  vendorName,
@@ -29427,7 +29438,7 @@ function createCmsApiHandler(config) {
29427
29438
  companyDetails
29428
29439
  };
29429
29440
  if (queue) {
29430
- const { queueEmail: queueEmail2 } = await import('./email-queue-HGXB2FIS.js');
29441
+ const { queueEmail: queueEmail2 } = await import('./email-queue-3QBQ63F7.js');
29431
29442
  await queueEmail2(cms, {
29432
29443
  to: opts.to,
29433
29444
  templateName: "passwordReset",
@@ -30437,6 +30448,110 @@ function createCmsApiHandler(config) {
30437
30448
  return socialMediaHandlers.publishBlogToFacebook(req, id);
30438
30449
  }
30439
30450
  }
30451
+ if (path2[0] === "settings" && path2.length === 2 && path2[1] === "invoice-preview" && m === "GET") {
30452
+ const a = await config.requireAuth(req);
30453
+ if (a) return a;
30454
+ const pe = await requireEntityPermissionEffective(req, "settings", "read");
30455
+ if (pe) return pe;
30456
+ const url = new URL(req.url);
30457
+ const templateParam = url.searchParams.get("template") || "classic";
30458
+ const qrParam = url.searchParams.get("qr");
30459
+ const configRepo = dataSource.getRepository(entityMap.configs);
30460
+ const rows = await configRepo.find({
30461
+ where: {
30462
+ settings: "store",
30463
+ deleted: false
30464
+ }
30465
+ });
30466
+ const storeMap = {};
30467
+ for (const r of rows) {
30468
+ storeMap[r.key] = r.value;
30469
+ }
30470
+ const { normalizeInvoiceTemplateId } = await import('./invoice-templates-GZ33OENC.js');
30471
+ const { generateLocalInvoicePdf } = await import('./generate-local-invoice-pdf-OCFG47SE.js');
30472
+ const { resolveInvoiceAssetUrl } = await import('./resolve-invoice-asset-url-QZ2FRDHI.js');
30473
+ const templateId = normalizeInvoiceTemplateId(templateParam);
30474
+ const includeQr = qrParam != null ? qrParam === "1" || qrParam === "true" : storeMap.invoice_include_qr === "true";
30475
+ const sampleInput = {
30476
+ templateId,
30477
+ orderNumber: "SAMPLE-10024",
30478
+ orderDate: (/* @__PURE__ */ new Date()).toISOString(),
30479
+ currency: storeMap.currency || "INR",
30480
+ company: {
30481
+ name: storeMap.companyName || storeMap.invoiceCompanyName || "ETOE Services",
30482
+ supportEmail: storeMap.companyEmail || storeMap.invoiceEmail || "support@example.com",
30483
+ supportPhone: storeMap.companyPhone || storeMap.invoicePhone || "+91 98765 43210",
30484
+ address: storeMap.companyAddress || storeMap.invoiceAddress || "65 Sanjay Nagar B, Kalwar Road, Jhotwara, Jaipur, Rajasthan, 302012, India",
30485
+ logoUrl: resolveInvoiceAssetUrl(storeMap.invoiceLogoUrl || storeMap.companyLogo || storeMap.logo)
30486
+ },
30487
+ customerName: "Sahil Sharma",
30488
+ customerEmail: "sahil@example.com",
30489
+ customerPhone: "+91 98875 51178",
30490
+ billingAddress: {
30491
+ line1: "65 Sanjay Nagar B, Kalwar Road",
30492
+ city: "Jaipur",
30493
+ state: "Rajasthan",
30494
+ postalCode: "302012",
30495
+ country: "India"
30496
+ },
30497
+ shippingAddress: {
30498
+ line1: "65 Sanjay Nagar B, Kalwar Road",
30499
+ city: "Jaipur",
30500
+ state: "Rajasthan",
30501
+ postalCode: "302012",
30502
+ country: "India"
30503
+ },
30504
+ serviceDate: (/* @__PURE__ */ new Date()).toISOString(),
30505
+ timeSlot: "6:00 PM",
30506
+ assignedTo: "Raaj Sharma",
30507
+ qrToken: "sample-track-token-12345",
30508
+ qrData: "https://etoe.in/track/sample-track-token-12345",
30509
+ includeQrCode: includeQr,
30510
+ lineItems: [
30511
+ {
30512
+ name: "Complete Home Deep Cleaning Service",
30513
+ sku: "ETOE-HDC-001",
30514
+ quantity: 1,
30515
+ unitPrice: 3499,
30516
+ tax: 0,
30517
+ total: 3499
30518
+ },
30519
+ {
30520
+ name: "Kitchen & Bathroom Sanitization Add-on",
30521
+ sku: "ETOE-SAN-002",
30522
+ quantity: 1,
30523
+ unitPrice: 999,
30524
+ tax: 0,
30525
+ total: 999
30526
+ }
30527
+ ],
30528
+ subtotal: 4498,
30529
+ discount: 499,
30530
+ tax: 0,
30531
+ total: 3999
30532
+ };
30533
+ try {
30534
+ const bytes = await generateLocalInvoicePdf(sampleInput);
30535
+ return new Response(Buffer.from(bytes), {
30536
+ status: 200,
30537
+ headers: {
30538
+ "Content-Type": "application/pdf",
30539
+ "Content-Disposition": `inline; filename="preview-invoice-${templateId}.pdf"`
30540
+ }
30541
+ });
30542
+ } catch (err) {
30543
+ const msg = err instanceof Error ? err.message : String(err);
30544
+ console.error("[invoice-preview] failed", {
30545
+ templateId,
30546
+ error: msg
30547
+ });
30548
+ return config.json({
30549
+ error: `Preview generation failed: ${msg}`
30550
+ }, {
30551
+ status: 500
30552
+ });
30553
+ }
30554
+ }
30440
30555
  if (path2[0] === "settings" && path2.length === 2 && settingsHandlers) {
30441
30556
  const group = path2[1];
30442
30557
  const isPublic = group === "multi_vendor" || group === "turnstile" || group === "auth_providers" || settingsConfig?.publicGetGroups?.includes(group);
@@ -30741,7 +30856,7 @@ function createCmsApiHandler(config) {
30741
30856
  const pe = await requireEntityPermissionEffective(req, "orders", "read");
30742
30857
  if (pe) return pe;
30743
30858
  const cms = await getCms();
30744
- const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-H6HCJ7YS.js');
30859
+ const { streamOrderInvoicePdf: streamOrderInvoicePdf2 } = await import('./erp-order-invoice-XSYHAMBS.js');
30745
30860
  const oid = Number(path2[1]);
30746
30861
  if (!Number.isFinite(oid)) return config.json({
30747
30862
  error: "Invalid id"
@@ -31123,7 +31238,7 @@ function createCmsApiHandler(config) {
31123
31238
  status: 400
31124
31239
  });
31125
31240
  }
31126
- const { resendOrderNotification } = await import('./order-notification-dispatcher-ECPFI7CD.js');
31241
+ const { resendOrderNotification } = await import('./order-notification-dispatcher-KM2SY7TX.js');
31127
31242
  const result = await resendOrderNotification(triggerKey, orderId, {
31128
31243
  dataSource,
31129
31244
  entityMap,
@@ -31222,7 +31337,7 @@ function createCmsApiHandler(config) {
31222
31337
  status: "cancelled"
31223
31338
  });
31224
31339
  const fireOrderCancelledNotification = /* @__PURE__ */ __name((refundAmount) => {
31225
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
31340
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
31226
31341
  fireOrderNotificationTrigger("order_cancelled", orderId, {
31227
31342
  dataSource,
31228
31343
  entityMap
@@ -31467,7 +31582,7 @@ function createCmsApiHandler(config) {
31467
31582
  }, {
31468
31583
  status: 400
31469
31584
  });
31470
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-HFGCPC4O.js');
31585
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-NROWBGXN.js');
31471
31586
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
31472
31587
  return handlers.getChannels(req, orderId);
31473
31588
  }
@@ -31482,7 +31597,7 @@ function createCmsApiHandler(config) {
31482
31597
  }, {
31483
31598
  status: 400
31484
31599
  });
31485
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-HFGCPC4O.js');
31600
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-NROWBGXN.js');
31486
31601
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
31487
31602
  return handlers.sendOtp(req, orderId);
31488
31603
  }
@@ -31497,7 +31612,7 @@ function createCmsApiHandler(config) {
31497
31612
  }, {
31498
31613
  status: 400
31499
31614
  });
31500
- const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-HFGCPC4O.js');
31615
+ const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-NROWBGXN.js');
31501
31616
  const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
31502
31617
  return handlers.verifyOtp(req, orderId);
31503
31618
  }
@@ -32129,7 +32244,7 @@ function createStorefrontApiHandler(config) {
32129
32244
  const otpPepper = config.otpPepper;
32130
32245
  const defaultPhoneCc = config.defaultPhoneCountryCode;
32131
32246
  function fireStorefrontCheckoutNotifications(orderId) {
32132
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
32247
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
32133
32248
  fireOrderNotificationTrigger("order_pending", orderId, {
32134
32249
  dataSource,
32135
32250
  entityMap
@@ -34893,7 +35008,9 @@ function createStorefrontApiHandler(config) {
34893
35008
  },
34894
35009
  relations: [
34895
35010
  "items",
34896
- "items.product"
35011
+ "items.product",
35012
+ "assignedUser",
35013
+ "payments"
34897
35014
  ]
34898
35015
  });
34899
35016
  if (!order) return json({
@@ -34919,7 +35036,9 @@ function createStorefrontApiHandler(config) {
34919
35036
  },
34920
35037
  relations: [
34921
35038
  "items",
34922
- "items.product"
35039
+ "items.product",
35040
+ "assignedUser",
35041
+ "payments"
34923
35042
  ]
34924
35043
  });
34925
35044
  }
@@ -34985,6 +35104,17 @@ function createStorefrontApiHandler(config) {
34985
35104
  currency: o.currency,
34986
35105
  createdAt: o.createdAt,
34987
35106
  metadata: o.metadata ?? null,
35107
+ assignedUser: o.assignedUser ? {
35108
+ id: o.assignedUser.id,
35109
+ name: o.assignedUser.name,
35110
+ phone: o.assignedUser.phone
35111
+ } : null,
35112
+ payments: Array.isArray(o.payments) ? o.payments.map((pm) => ({
35113
+ id: pm.id,
35114
+ amount: pm.amount,
35115
+ method: pm.method,
35116
+ status: pm.status
35117
+ })) : [],
34988
35118
  items: lines
34989
35119
  },
34990
35120
  relatedOrders: relatedOrders.map((r) => ({
@@ -35059,7 +35189,7 @@ function createStorefrontApiHandler(config) {
35059
35189
  } catch {
35060
35190
  }
35061
35191
  try {
35062
- void import('./emit-order-notification-trigger-EJJZ6XTS.js').then(({ fireOrderNotificationTrigger }) => {
35192
+ void import('./emit-order-notification-trigger-YUQTPELC.js').then(({ fireOrderNotificationTrigger }) => {
35063
35193
  fireOrderNotificationTrigger("order_cancelled", orderId, {
35064
35194
  dataSource,
35065
35195
  entityMap
@@ -1,9 +1,9 @@
1
1
  import { queueWhatsApp } from './chunk-GWDI752Q.js';
2
2
  import { notifyLog, logFcmToken, maskNotifyEmail, maskNotifyPhone, notificationTriggerEmitter } from './chunk-FLUF2GZH.js';
3
+ import { applyTemplateVars } from './chunk-CRFV5WJK.js';
3
4
  import { sesRegionSupportsSmtp, sesSmtpHost, EmailService, renderLayout } from './chunk-6YOQ7G5O.js';
4
- import { queueEmail } from './chunk-TU23GJPJ.js';
5
+ import { queueEmail } from './chunk-7JCCPQEF.js';
5
6
  import { mergeEmailLayoutCompanyDetails } from './chunk-YRCKEGL2.js';
6
- import { applyTemplateVars } from './chunk-CRFV5WJK.js';
7
7
  import { __name } from './chunk-SHUYVCID.js';
8
8
  import * as crypto from 'crypto';
9
9
 
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
+
5
+ // src/lib/invoice/resolve-invoice-asset-url.ts
6
+ function resolveInvoiceAssetUrl(raw) {
7
+ const t = String(raw ?? "").trim();
8
+ if (!t) return null;
9
+ if (/^https?:\/\//i.test(t)) return t;
10
+ if (t.startsWith("//")) return `https:${t}`;
11
+ const base = (process.env.CMS_PUBLIC_URL || process.env.NEXT_PUBLIC_SITE_URL || process.env.NEXTAUTH_URL || "").trim().replace(/\/+$/, "");
12
+ if (!base) return null;
13
+ if (t.startsWith("/")) return `${base}${t}`;
14
+ return `${base}/${t}`;
15
+ }
16
+ chunkUSNT2KNT_cjs.__name(resolveInvoiceAssetUrl, "resolveInvoiceAssetUrl");
17
+
18
+ exports.resolveInvoiceAssetUrl = resolveInvoiceAssetUrl;
@@ -94,7 +94,7 @@ async function emitOrderNotificationTrigger(triggerKey, orderId, deps, extra) {
94
94
  orderId
95
95
  });
96
96
  try {
97
- const { dispatchOrderNotificationDirectly } = await import('./order-notification-dispatcher-ECPFI7CD.js');
97
+ const { dispatchOrderNotificationDirectly } = await import('./order-notification-dispatcher-KM2SY7TX.js');
98
98
  await dispatchOrderNotificationDirectly(triggerKey, triggerPayload, deps.dataSource, deps.entityMap);
99
99
  } catch (err) {
100
100
  notifyLog.error("TRIGGER", "direct dispatch failed", {
@@ -2,10 +2,10 @@
2
2
 
3
3
  var chunkH3IVLIPR_cjs = require('./chunk-H3IVLIPR.cjs');
4
4
  var chunkPA6YDMFZ_cjs = require('./chunk-PA6YDMFZ.cjs');
5
+ var chunkOOTLNH63_cjs = require('./chunk-OOTLNH63.cjs');
5
6
  var chunkVM6OVUUM_cjs = require('./chunk-VM6OVUUM.cjs');
6
- var chunkXFDIIVZB_cjs = require('./chunk-XFDIIVZB.cjs');
7
+ var chunkUMC7W5G3_cjs = require('./chunk-UMC7W5G3.cjs');
7
8
  var chunkTZEMLHSP_cjs = require('./chunk-TZEMLHSP.cjs');
8
- var chunkOOTLNH63_cjs = require('./chunk-OOTLNH63.cjs');
9
9
  var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
10
10
  var crypto = require('crypto');
11
11
 
@@ -1060,7 +1060,7 @@ async function sendChatLeadEmail(cms, emailSettings, brandingSettings, input) {
1060
1060
  };
1061
1061
  let anySent = false;
1062
1062
  for (const to of recipients) {
1063
- await chunkXFDIIVZB_cjs.queueEmail(cms, {
1063
+ await chunkUMC7W5G3_cjs.queueEmail(cms, {
1064
1064
  to,
1065
1065
  templateName: "chatLead",
1066
1066
  ctx
@@ -1933,7 +1933,7 @@ async function sendEmailForTrigger(triggerKey, orderId, audienceType, variables,
1933
1933
  companyDetails
1934
1934
  });
1935
1935
  const cms = await getCms();
1936
- await chunkXFDIIVZB_cjs.queueEmail(cms, {
1936
+ await chunkUMC7W5G3_cjs.queueEmail(cms, {
1937
1937
  to: contactEmail,
1938
1938
  subject,
1939
1939
  html,