@infuro/cms-core 1.0.33 → 1.0.34

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 (38) hide show
  1. package/README.md +9 -6
  2. package/dist/admin.cjs +980 -801
  3. package/dist/admin.cjs.map +1 -1
  4. package/dist/admin.d.cts +7 -2
  5. package/dist/admin.d.ts +7 -2
  6. package/dist/admin.js +1021 -842
  7. package/dist/admin.js.map +1 -1
  8. package/dist/api.cjs +1858 -848
  9. package/dist/api.cjs.map +1 -1
  10. package/dist/api.d.cts +1 -1
  11. package/dist/api.d.ts +1 -1
  12. package/dist/api.js +1824 -815
  13. package/dist/api.js.map +1 -1
  14. package/dist/auth.cjs +94 -11
  15. package/dist/auth.cjs.map +1 -1
  16. package/dist/auth.d.cts +17 -1
  17. package/dist/auth.d.ts +17 -1
  18. package/dist/auth.js +89 -11
  19. package/dist/auth.js.map +1 -1
  20. package/dist/cli.cjs +39 -0
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +39 -0
  23. package/dist/cli.js.map +1 -1
  24. package/dist/{index-rZTnpK7y.d.cts → index-Bf5GO8fu.d.cts} +3 -2
  25. package/dist/{index-DWd5Gjc4.d.ts → index-DOiJuMQA.d.ts} +3 -2
  26. package/dist/index.cjs +2078 -841
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +83 -8
  29. package/dist/index.d.ts +83 -8
  30. package/dist/index.js +2013 -786
  31. package/dist/index.js.map +1 -1
  32. package/dist/migrations/1778660000004-CreateCustomerAndCustomerContacts.ts +99 -0
  33. package/dist/migrations/1778660000005-AddCustomerIdToVendorCustomers.ts +39 -0
  34. package/dist/migrations/1778660000006-UpdateVendorCustomersContactNullable.ts +36 -0
  35. package/dist/migrations/1778660000007-VendorOwnerCustomerContactsPermission.ts +39 -0
  36. package/dist/migrations/1779300000000-VendorOwnerContactsPermission.ts +39 -0
  37. package/dist/migrations/1779400000000-AddCustomerContactIdToOrders.ts +33 -0
  38. package/package.json +4 -3
package/dist/index.js CHANGED
@@ -414,6 +414,7 @@ var email_queue_exports = {};
414
414
  __export(email_queue_exports, {
415
415
  queueEmail: () => queueEmail,
416
416
  queueOrderPlacedEmails: () => queueOrderPlacedEmails,
417
+ queueVendorOnboardEmails: () => queueVendorOnboardEmails,
417
418
  registerEmailQueueProcessor: () => registerEmailQueueProcessor
418
419
  });
419
420
  function registerEmailQueueProcessor(cms) {
@@ -506,6 +507,60 @@ async function queueOrderPlacedEmails(cms, payload) {
506
507
  }
507
508
  await Promise.all(jobs);
508
509
  }
510
+ async function queueVendorOnboardEmails(cms, payload) {
511
+ const {
512
+ vendorName,
513
+ vendorSlug,
514
+ ownerName,
515
+ ownerEmail,
516
+ activation,
517
+ inviteLink,
518
+ signInLink,
519
+ kind = "vendor_onboard",
520
+ notifyEmails,
521
+ companyDetails,
522
+ sendToOwner = true
523
+ } = payload;
524
+ const base = {
525
+ vendorName,
526
+ vendorSlug,
527
+ ownerName,
528
+ ownerEmail,
529
+ activation,
530
+ inviteLink,
531
+ signInLink,
532
+ kind,
533
+ companyDetails: companyDetails ?? {}
534
+ };
535
+ const ownerLower = ownerEmail?.trim().toLowerCase() ?? "";
536
+ const jobs = [];
537
+ if (sendToOwner && ownerEmail?.trim()) {
538
+ jobs.push(
539
+ queueEmail(cms, {
540
+ to: ownerEmail.trim(),
541
+ templateName: "vendorOnboarded",
542
+ ctx: { ...base, audience: "owner" }
543
+ })
544
+ );
545
+ }
546
+ const seen = /* @__PURE__ */ new Set();
547
+ for (const raw of notifyEmails) {
548
+ const to = raw.trim();
549
+ if (!to) continue;
550
+ const key = to.toLowerCase();
551
+ if (seen.has(key)) continue;
552
+ seen.add(key);
553
+ if (ownerLower && key === ownerLower) continue;
554
+ jobs.push(
555
+ queueEmail(cms, {
556
+ to,
557
+ templateName: "vendorOnboarded",
558
+ ctx: { ...base, audience: "internal" }
559
+ })
560
+ );
561
+ }
562
+ await Promise.all(jobs);
563
+ }
509
564
  var EMAIL_QUEUE_NAME;
510
565
  var init_email_queue = __esm({
511
566
  "src/plugins/email/email-queue.ts"() {
@@ -855,6 +910,30 @@ var init_permission_entities = __esm({
855
910
  }
856
911
  });
857
912
 
913
+ // src/auth/role-helpers.ts
914
+ function isSuperAdmin(user) {
915
+ if (!user) return false;
916
+ if (user.groupId === SUPER_ADMIN_GROUP_ID) return true;
917
+ if (user.isRBACAdmin === true) return true;
918
+ return isSuperAdminGroupName(user.groupName);
919
+ }
920
+ function isVendorAdmin(user) {
921
+ if (!user?.email || isSuperAdmin(user)) return false;
922
+ if (user.groupId === VENDOR_ADMIN_GROUP_ID) return true;
923
+ if ((user.vendorIds?.length ?? 0) > 0) return true;
924
+ return isVendorGroupName(user.groupName);
925
+ }
926
+ var SUPER_ADMIN_GROUP_ID, VENDOR_ADMIN_GROUP_ID;
927
+ var init_role_helpers = __esm({
928
+ "src/auth/role-helpers.ts"() {
929
+ "use strict";
930
+ init_permission_entities();
931
+ init_vendor_scope();
932
+ SUPER_ADMIN_GROUP_ID = 1;
933
+ VENDOR_ADMIN_GROUP_ID = 5;
934
+ }
935
+ });
936
+
858
937
  // src/auth/vendor-scope.ts
859
938
  function isVendorGroupName(name) {
860
939
  if (!name?.trim()) return false;
@@ -863,12 +942,12 @@ function isVendorGroupName(name) {
863
942
  }
864
943
  function isPlatformAdministrator(user) {
865
944
  if (!user?.email) return false;
866
- return !!(user.isRBACAdmin || isSuperAdminGroupName(user.groupName));
945
+ return isSuperAdmin(user);
867
946
  }
868
947
  function isVendorPortalUser(user) {
869
948
  if (user?.isVendorPortal === true) return true;
870
949
  if (!user?.email || isPlatformAdministrator(user)) return false;
871
- if ((user.vendorIds?.length ?? 0) > 0) return true;
950
+ if (isVendorAdmin(user)) return true;
872
951
  return isVendorGroupName(user.groupName);
873
952
  }
874
953
  function isVendorStaff(user) {
@@ -910,7 +989,7 @@ var VENDOR_SCOPED_STORE_ENTITIES, VENDOR_STORE_RBAC_ENTITIES, VENDOR_OWNER_GROUP
910
989
  var init_vendor_scope = __esm({
911
990
  "src/auth/vendor-scope.ts"() {
912
991
  "use strict";
913
- init_permission_entities();
992
+ init_role_helpers();
914
993
  VENDOR_SCOPED_STORE_ENTITIES = /* @__PURE__ */ new Set([
915
994
  "products",
916
995
  "collections",
@@ -1124,6 +1203,399 @@ var init_rbac_debug = __esm({
1124
1203
  }
1125
1204
  });
1126
1205
 
1206
+ // src/admin/pages/OrderTrackPage.ts
1207
+ var OrderTrackPage_exports = {};
1208
+ __export(OrderTrackPage_exports, {
1209
+ renderOrderTrackingPage: () => renderOrderTrackingPage
1210
+ });
1211
+ function renderOrderTrackingPage(order) {
1212
+ const contact = order.contact;
1213
+ const items = order.items ?? [];
1214
+ const currency = String(order.currency ?? "INR");
1215
+ function formatMoney2(amount) {
1216
+ return new Intl.NumberFormat("en-IN", {
1217
+ style: "currency",
1218
+ currency,
1219
+ minimumFractionDigits: 2
1220
+ }).format(Number(amount));
1221
+ }
1222
+ function formatDate2(dateStr) {
1223
+ return new Date(dateStr).toLocaleDateString("en-IN", {
1224
+ year: "numeric",
1225
+ month: "long",
1226
+ day: "numeric"
1227
+ });
1228
+ }
1229
+ const statusConfig = {
1230
+ pending: { label: "Order Placed", color: "#f59e0b", step: 1 },
1231
+ confirmed: { label: "Confirmed", color: "#3b82f6", step: 2 },
1232
+ processing: { label: "Processing", color: "#8b5cf6", step: 3 },
1233
+ completed: { label: "Completed", color: "#10b981", step: 4 },
1234
+ cancelled: { label: "Cancelled", color: "#ef4444", step: 0 }
1235
+ };
1236
+ const status = String(order.status ?? "pending");
1237
+ const sc = statusConfig[status] ?? { label: status, color: "#6b7280", step: 1 };
1238
+ const isCancelled = status === "cancelled";
1239
+ const steps = [
1240
+ { label: "Order Placed", icon: "\u{1F4CB}" },
1241
+ { label: "Confirmed", icon: "\u2705" },
1242
+ { label: "Processing", icon: "\u2699\uFE0F" },
1243
+ { label: "Completed", icon: "\u{1F389}" }
1244
+ ];
1245
+ const stepsHtml = isCancelled ? `<div class="cancelled-banner">Order Cancelled</div>` : steps.map((s, i) => {
1246
+ const stepNum = i + 1;
1247
+ const isActive = sc.step === stepNum;
1248
+ const isDone = sc.step > stepNum;
1249
+ return `
1250
+ <div class="step ${isDone ? "done" : ""} ${isActive ? "active" : ""}">
1251
+ <div class="step-circle">${isDone ? "\u2713" : s.icon}</div>
1252
+ <div class="step-label">${s.label}</div>
1253
+ </div>
1254
+ ${stepNum < 4 ? `<div class="step-line ${sc.step > stepNum ? "done" : ""}"></div>` : ""}
1255
+ `;
1256
+ }).join("");
1257
+ const itemsHtml = items.map((item) => {
1258
+ const name = item.product?.collection?.name ?? item.product?.name ?? `Product #${item.id}`;
1259
+ const sku = item.product?.sku ?? "\u2014";
1260
+ return `
1261
+ <div class="item-row">
1262
+ <div class="item-avatar">${name.charAt(0).toUpperCase()}</div>
1263
+ <div class="item-info">
1264
+ <div class="item-name">${name}</div>
1265
+ <div class="item-sku">SKU: ${sku}</div>
1266
+ </div>
1267
+ <div class="item-qty">\xD7${item.quantity}</div>
1268
+ <div class="item-price">${formatMoney2(Number(item.unitPrice))}</div>
1269
+ </div>
1270
+ `;
1271
+ }).join("");
1272
+ const discountRow = Number(order.discount) > 0 ? `<div class="summary-row discount"><span>Discount</span><span>\u2212${formatMoney2(Number(order.discount))}</span></div>` : "";
1273
+ const taxRow = Number(order.tax) > 0 ? `<div class="summary-row"><span>Tax</span><span>${formatMoney2(Number(order.tax))}</span></div>` : "";
1274
+ return `<!DOCTYPE html>
1275
+ <html lang="en">
1276
+ <head>
1277
+ <meta charset="UTF-8">
1278
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1279
+ <title>Order ${order.orderNumber} \u2014 Tracking</title>
1280
+ <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=DM+Sans:wght@400;500;600&display=swap" rel="stylesheet">
1281
+ <style>
1282
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
1283
+
1284
+ :root {
1285
+ --accent: ${sc.color};
1286
+ --bg: #f8f7f4;
1287
+ --card: #ffffff;
1288
+ --text: #1a1a2e;
1289
+ --muted: #6b7280;
1290
+ --border: #e5e7eb;
1291
+ --radius: 16px;
1292
+ }
1293
+
1294
+ body {
1295
+ font-family: 'DM Sans', sans-serif;
1296
+ background: var(--bg);
1297
+ color: var(--text);
1298
+ min-height: 100vh;
1299
+ padding: 24px 16px 48px;
1300
+ }
1301
+
1302
+ .container { max-width: 640px; margin: 0 auto; }
1303
+
1304
+ /* Header */
1305
+ .header {
1306
+ text-align: center;
1307
+ margin-bottom: 32px;
1308
+ animation: fadeDown 0.5s ease both;
1309
+ }
1310
+ .header-eyebrow {
1311
+ font-size: 12px;
1312
+ font-weight: 600;
1313
+ letter-spacing: 0.15em;
1314
+ text-transform: uppercase;
1315
+ color: var(--accent);
1316
+ margin-bottom: 8px;
1317
+ }
1318
+ .header h1 {
1319
+ font-family: 'Playfair Display', serif;
1320
+ font-size: clamp(26px, 6vw, 36px);
1321
+ color: var(--text);
1322
+ line-height: 1.2;
1323
+ }
1324
+ .header-meta {
1325
+ font-size: 13px;
1326
+ color: var(--muted);
1327
+ margin-top: 6px;
1328
+ }
1329
+
1330
+ /* Status badge */
1331
+ .status-badge {
1332
+ display: inline-flex;
1333
+ align-items: center;
1334
+ gap: 6px;
1335
+ background: color-mix(in srgb, var(--accent) 12%, transparent);
1336
+ color: var(--accent);
1337
+ border: 1.5px solid color-mix(in srgb, var(--accent) 30%, transparent);
1338
+ border-radius: 100px;
1339
+ padding: 5px 14px;
1340
+ font-size: 13px;
1341
+ font-weight: 600;
1342
+ margin-top: 14px;
1343
+ }
1344
+ .status-dot {
1345
+ width: 7px; height: 7px;
1346
+ border-radius: 50%;
1347
+ background: var(--accent);
1348
+ animation: pulse 2s ease infinite;
1349
+ }
1350
+
1351
+ /* Card */
1352
+ .card {
1353
+ background: var(--card);
1354
+ border-radius: var(--radius);
1355
+ border: 1px solid var(--border);
1356
+ overflow: hidden;
1357
+ margin-bottom: 16px;
1358
+ animation: fadeUp 0.5s ease both;
1359
+ }
1360
+ .card:nth-child(2) { animation-delay: 0.08s; }
1361
+ .card:nth-child(3) { animation-delay: 0.16s; }
1362
+ .card:nth-child(4) { animation-delay: 0.24s; }
1363
+
1364
+ .card-header {
1365
+ display: flex; align-items: center; gap: 10px;
1366
+ padding: 16px 20px;
1367
+ border-bottom: 1px solid var(--border);
1368
+ background: #fafafa;
1369
+ }
1370
+ .card-header-icon {
1371
+ width: 32px; height: 32px;
1372
+ border-radius: 8px;
1373
+ background: color-mix(in srgb, var(--accent) 12%, transparent);
1374
+ display: flex; align-items: center; justify-content: center;
1375
+ font-size: 15px;
1376
+ }
1377
+ .card-title {
1378
+ font-size: 13px;
1379
+ font-weight: 600;
1380
+ letter-spacing: 0.05em;
1381
+ text-transform: uppercase;
1382
+ color: var(--muted);
1383
+ }
1384
+ .card-body { padding: 20px; }
1385
+
1386
+ /* Progress tracker */
1387
+ .progress-track {
1388
+ display: flex;
1389
+ align-items: flex-start;
1390
+ justify-content: space-between;
1391
+ padding: 8px 0;
1392
+ overflow-x: auto;
1393
+ }
1394
+ .step {
1395
+ display: flex; flex-direction: column; align-items: center;
1396
+ gap: 8px; min-width: 60px;
1397
+ }
1398
+ .step-circle {
1399
+ width: 44px; height: 44px;
1400
+ border-radius: 50%;
1401
+ border: 2px solid var(--border);
1402
+ background: white;
1403
+ display: flex; align-items: center; justify-content: center;
1404
+ font-size: 18px;
1405
+ color: var(--muted);
1406
+ transition: all 0.3s;
1407
+ }
1408
+ .step.done .step-circle {
1409
+ background: color-mix(in srgb, var(--accent) 15%, white);
1410
+ border-color: var(--accent);
1411
+ color: var(--accent);
1412
+ font-size: 16px;
1413
+ font-weight: 700;
1414
+ }
1415
+ .step.active .step-circle {
1416
+ background: var(--accent);
1417
+ border-color: var(--accent);
1418
+ color: white;
1419
+ box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 20%, transparent);
1420
+ }
1421
+ .step-label {
1422
+ font-size: 11px; font-weight: 500; color: var(--muted);
1423
+ text-align: center; line-height: 1.3;
1424
+ }
1425
+ .step.active .step-label, .step.done .step-label { color: var(--accent); font-weight: 600; }
1426
+ .step-line {
1427
+ flex: 1; height: 2px;
1428
+ background: var(--border);
1429
+ margin-top: 22px; min-width: 20px;
1430
+ transition: background 0.3s;
1431
+ }
1432
+ .step-line.done { background: var(--accent); }
1433
+ .cancelled-banner {
1434
+ text-align: center; padding: 16px;
1435
+ background: #fef2f2; color: #ef4444;
1436
+ border-radius: 10px;
1437
+ font-weight: 600; font-size: 15px;
1438
+ }
1439
+
1440
+ /* Info grid */
1441
+ .info-grid {
1442
+ display: grid;
1443
+ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
1444
+ gap: 16px;
1445
+ }
1446
+ .info-item dt {
1447
+ font-size: 11px; font-weight: 600;
1448
+ text-transform: uppercase; letter-spacing: 0.08em;
1449
+ color: var(--muted); margin-bottom: 4px;
1450
+ }
1451
+ .info-item dd { font-size: 14px; font-weight: 500; color: var(--text); }
1452
+
1453
+ /* Customer */
1454
+ .customer-row {
1455
+ display: flex; align-items: center; gap: 14px;
1456
+ }
1457
+ .customer-avatar {
1458
+ width: 46px; height: 46px; border-radius: 50%;
1459
+ background: color-mix(in srgb, var(--accent) 15%, #f3f4f6);
1460
+ color: var(--accent);
1461
+ display: flex; align-items: center; justify-content: center;
1462
+ font-family: 'Playfair Display', serif;
1463
+ font-size: 18px; font-weight: 700; flex-shrink: 0;
1464
+ }
1465
+ .customer-name { font-size: 15px; font-weight: 600; }
1466
+ .customer-email { font-size: 13px; color: var(--muted); margin-top: 2px; }
1467
+
1468
+ /* Items */
1469
+ .item-row {
1470
+ display: flex; align-items: center; gap: 12px;
1471
+ padding: 12px 0;
1472
+ border-bottom: 1px solid var(--border);
1473
+ }
1474
+ .item-row:last-child { border-bottom: none; padding-bottom: 0; }
1475
+ .item-row:first-child { padding-top: 0; }
1476
+ .item-avatar {
1477
+ width: 40px; height: 40px; border-radius: 10px;
1478
+ background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 20%, #e5e7eb), color-mix(in srgb, var(--accent) 5%, #f9fafb));
1479
+ color: var(--accent);
1480
+ display: flex; align-items: center; justify-content: center;
1481
+ font-size: 16px; font-weight: 700; flex-shrink: 0;
1482
+ }
1483
+ .item-info { flex: 1; min-width: 0; }
1484
+ .item-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1485
+ .item-sku { font-size: 12px; color: var(--muted); margin-top: 2px; }
1486
+ .item-qty { font-size: 13px; color: var(--muted); min-width: 28px; text-align: center; }
1487
+ .item-price { font-size: 14px; font-weight: 600; min-width: 80px; text-align: right; }
1488
+
1489
+ /* Summary */
1490
+ .summary-row {
1491
+ display: flex; justify-content: space-between;
1492
+ font-size: 14px; padding: 7px 0; color: var(--muted);
1493
+ }
1494
+ .summary-row.discount { color: #10b981; }
1495
+ .summary-row.total {
1496
+ font-size: 17px; font-weight: 700; color: var(--text);
1497
+ border-top: 2px solid var(--border); margin-top: 6px; padding-top: 14px;
1498
+ }
1499
+
1500
+ /* Footer */
1501
+ .footer {
1502
+ text-align: center; margin-top: 32px;
1503
+ font-size: 12px; color: #9ca3af;
1504
+ animation: fadeUp 0.5s ease 0.4s both;
1505
+ }
1506
+
1507
+ /* Animations */
1508
+ @keyframes fadeDown {
1509
+ from { opacity: 0; transform: translateY(-16px); }
1510
+ to { opacity: 1; transform: translateY(0); }
1511
+ }
1512
+ @keyframes fadeUp {
1513
+ from { opacity: 0; transform: translateY(16px); }
1514
+ to { opacity: 1; transform: translateY(0); }
1515
+ }
1516
+ @keyframes pulse {
1517
+ 0%, 100% { opacity: 1; }
1518
+ 50% { opacity: 0.4; }
1519
+ }
1520
+ </style>
1521
+ </head>
1522
+ <body>
1523
+ <div class="container">
1524
+
1525
+ <!-- Header -->
1526
+ <div class="header">
1527
+ <div class="header-eyebrow">Order Tracking</div>
1528
+ <h1>${String(order.orderNumber)}</h1>
1529
+ <div class="header-meta">Placed on ${formatDate2(String(order.createdAt))}</div>
1530
+ <div><span class="status-badge"><span class="status-dot"></span>${sc.label}</span></div>
1531
+ </div>
1532
+
1533
+ <!-- Progress -->
1534
+ <div class="card">
1535
+ <div class="card-header">
1536
+ <div class="card-header-icon">\u{1F69A}</div>
1537
+ <div class="card-title">Order Progress</div>
1538
+ </div>
1539
+ <div class="card-body">
1540
+ <div class="progress-track">${stepsHtml}</div>
1541
+ </div>
1542
+ </div>
1543
+
1544
+ ${contact ? `
1545
+ <!-- Customer -->
1546
+ <div class="card">
1547
+ <div class="card-header">
1548
+ <div class="card-header-icon">\u{1F464}</div>
1549
+ <div class="card-title">Customer</div>
1550
+ </div>
1551
+ <div class="card-body">
1552
+ <div class="customer-row">
1553
+ <div class="customer-avatar">${String(contact.name ?? "?").charAt(0).toUpperCase()}</div>
1554
+ <div>
1555
+ <div class="customer-name">${String(contact.name ?? "\u2014")}</div>
1556
+ <div class="customer-email">${String(contact.email ?? "\u2014")}</div>
1557
+ ${contact.phone ? `<div class="customer-email">${String(contact.phone)}</div>` : ""}
1558
+ </div>
1559
+ </div>
1560
+ </div>
1561
+ </div>` : ""}
1562
+
1563
+ <!-- Items -->
1564
+ <div class="card">
1565
+ <div class="card-header">
1566
+ <div class="card-header-icon">\u{1F4E6}</div>
1567
+ <div class="card-title">Items (${items.length})</div>
1568
+ </div>
1569
+ <div class="card-body">
1570
+ ${items.length === 0 ? '<p style="color:var(--muted);font-size:14px;">No items</p>' : itemsHtml}
1571
+ </div>
1572
+ </div>
1573
+
1574
+ <!-- Summary -->
1575
+ <div class="card">
1576
+ <div class="card-header">
1577
+ <div class="card-header-icon">\u{1F9FE}</div>
1578
+ <div class="card-title">Order Summary</div>
1579
+ </div>
1580
+ <div class="card-body">
1581
+ <div class="summary-row"><span>Subtotal</span><span>${formatMoney2(Number(order.subtotal))}</span></div>
1582
+ ${discountRow}
1583
+ ${taxRow}
1584
+ <div class="summary-row total"><span>Total</span><span>${formatMoney2(Number(order.total))}</span></div>
1585
+ </div>
1586
+ </div>
1587
+
1588
+ <div class="footer">Scan the QR code on your receipt to return to this page.</div>
1589
+ </div>
1590
+ </body>
1591
+ </html>`;
1592
+ }
1593
+ var init_OrderTrackPage = __esm({
1594
+ "src/admin/pages/OrderTrackPage.ts"() {
1595
+ "use strict";
1596
+ }
1597
+ });
1598
+
1127
1599
  // src/plugins/registry.ts
1128
1600
  var noopLogger = {
1129
1601
  info: () => {
@@ -2289,6 +2761,89 @@ function escapeHtml8(s) {
2289
2761
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2290
2762
  }
2291
2763
 
2764
+ // src/plugins/email/templates/vendorOnboarded.ts
2765
+ function render11(ctx) {
2766
+ const {
2767
+ audience,
2768
+ activation,
2769
+ kind = "vendor_onboard",
2770
+ vendorName,
2771
+ vendorSlug,
2772
+ ownerName,
2773
+ ownerEmail,
2774
+ inviteLink,
2775
+ signInLink,
2776
+ companyDetails
2777
+ } = ctx;
2778
+ const storeLabel = vendorName.trim() || "your store";
2779
+ const greeting = ownerName && ownerName.trim() ? `Hello ${escapeHtml2(ownerName.trim())},` : "Hello,";
2780
+ const slugNote = vendorSlug && vendorSlug.trim() ? `<p style="margin:0 0 8px 0;font-size:14px;line-height:1.5;color:#555;"><strong>Store URL slug:</strong> ${escapeHtml2(vendorSlug.trim())}</p>` : "";
2781
+ let subject;
2782
+ let bodyHtml;
2783
+ let text;
2784
+ if (audience === "internal") {
2785
+ const action = kind === "team_invite" ? "A team member was invited to a vendor store." : activation === "invite" ? "A new vendor store was created and the owner was invited." : "A new vendor store was created with an active owner account.";
2786
+ subject = kind === "team_invite" ? `Team invite: ${storeLabel}` : `New vendor: ${storeLabel}`;
2787
+ bodyHtml = `<p style="margin:0 0 12px 0;font-size:15px;line-height:1.5;color:#333;">${action}</p>
2788
+ <p style="margin:0 0 8px 0;font-size:15px;line-height:1.5;color:#333;"><strong>Store:</strong> ${escapeHtml2(storeLabel)}</p>
2789
+ ${slugNote}
2790
+ <p style="margin:0 0 8px 0;font-size:15px;line-height:1.5;color:#333;"><strong>Owner / invitee:</strong> ${escapeHtml2(ownerName?.trim() || "\u2014")} <span style="color:#555;">(${escapeHtml2(ownerEmail)})</span></p>
2791
+ <p style="margin:0 0 0 0;font-size:14px;line-height:1.5;color:#555;"><strong>Activation:</strong> ${escapeHtml2(activation === "invite" ? "Invitation" : "Password set")}</p>`;
2792
+ text = [
2793
+ subject,
2794
+ "",
2795
+ action,
2796
+ `Store: ${storeLabel}`,
2797
+ vendorSlug ? `Slug: ${vendorSlug}` : "",
2798
+ `Owner / invitee: ${ownerName?.trim() || "\u2014"} (${ownerEmail})`,
2799
+ `Activation: ${activation === "invite" ? "Invitation" : "Password set"}`
2800
+ ].filter(Boolean).join("\n");
2801
+ } else if (kind === "team_invite" && activation === "invite" && inviteLink) {
2802
+ subject = `You're invited to ${storeLabel}`;
2803
+ bodyHtml = `<p style="margin:0 0 12px 0;font-size:15px;line-height:1.5;color:#333;">${greeting}</p>
2804
+ <p style="margin:0 0 12px 0;font-size:15px;line-height:1.5;color:#333;">You have been invited to join the vendor team for <strong>${escapeHtml2(storeLabel)}</strong>. Use the secure link below to set your password and activate your account.</p>
2805
+ ${primaryCtaButton(inviteLink, "Accept invitation & set password")}
2806
+ <p style="margin:16px 0 0 0;font-size:12px;line-height:1.5;color:#888;">If the button does not work, copy and paste this URL into your browser:<br/><span style="word-break:break-all;">${escapeHtml2(inviteLink)}</span></p>`;
2807
+ text = [
2808
+ ownerName?.trim() ? `Hello ${ownerName.trim()},` : "Hello,",
2809
+ "",
2810
+ `You have been invited to join ${storeLabel}.`,
2811
+ "Open this link to set your password:",
2812
+ inviteLink
2813
+ ].join("\n");
2814
+ } else if (activation === "invite" && inviteLink) {
2815
+ subject = `Your vendor store "${storeLabel}" is ready`;
2816
+ bodyHtml = `<p style="margin:0 0 12px 0;font-size:15px;line-height:1.5;color:#333;">${greeting}</p>
2817
+ <p style="margin:0 0 12px 0;font-size:15px;line-height:1.5;color:#333;">Your vendor store <strong>${escapeHtml2(storeLabel)}</strong> has been created. Accept the invitation below to set your password and access the admin dashboard.</p>
2818
+ ${slugNote}
2819
+ ${primaryCtaButton(inviteLink, "Accept invitation & set password")}
2820
+ <p style="margin:16px 0 0 0;font-size:12px;line-height:1.5;color:#888;">If the button does not work, copy and paste this URL into your browser:<br/><span style="word-break:break-all;">${escapeHtml2(inviteLink)}</span></p>`;
2821
+ text = [
2822
+ ownerName?.trim() ? `Hello ${ownerName.trim()},` : "Hello,",
2823
+ "",
2824
+ `Your vendor store "${storeLabel}" has been created.`,
2825
+ "Open this link to set your password:",
2826
+ inviteLink
2827
+ ].join("\n");
2828
+ } else {
2829
+ subject = `Welcome to ${storeLabel}`;
2830
+ const loginUrl = signInLink?.trim() || inviteLink?.trim() || "";
2831
+ bodyHtml = `<p style="margin:0 0 12px 0;font-size:15px;line-height:1.5;color:#333;">${greeting}</p>
2832
+ <p style="margin:0 0 12px 0;font-size:15px;line-height:1.5;color:#333;">Your vendor store <strong>${escapeHtml2(storeLabel)}</strong> has been created and your owner account is ready. Sign in to the admin dashboard to manage your store.</p>
2833
+ ${slugNote}
2834
+ ${loginUrl ? primaryCtaButton(loginUrl, "Sign in to admin") : ""}
2835
+ ${loginUrl ? `<p style="margin:16px 0 0 0;font-size:12px;line-height:1.5;color:#888;">Sign-in URL:<br/><span style="word-break:break-all;">${escapeHtml2(loginUrl)}</span></p>` : ""}`;
2836
+ text = [
2837
+ ownerName?.trim() ? `Hello ${ownerName.trim()},` : "Hello,",
2838
+ "",
2839
+ `Your vendor store "${storeLabel}" has been created.`,
2840
+ loginUrl ? `Sign in: ${loginUrl}` : ""
2841
+ ].filter(Boolean).join("\n");
2842
+ }
2843
+ const html = renderLayout({ bodyHtml, companyDetails });
2844
+ return { subject, html, text };
2845
+ }
2846
+
2292
2847
  // src/plugins/email/templates/index.ts
2293
2848
  var templateRenderMap = {
2294
2849
  signup: render,
@@ -2300,7 +2855,8 @@ var templateRenderMap = {
2300
2855
  invite: render7,
2301
2856
  formSubmission: render8,
2302
2857
  otp: render9,
2303
- chatLead: render10
2858
+ chatLead: render10,
2859
+ vendorOnboarded: render11
2304
2860
  };
2305
2861
  function getTemplateRenderer(name) {
2306
2862
  return templateRenderMap[name];
@@ -2317,37 +2873,79 @@ function renderEmail(templateName, ctx, options) {
2317
2873
  return { subject: custom.subject, html, text: custom.text };
2318
2874
  }
2319
2875
  }
2320
- const render11 = getTemplateRenderer(templateName);
2321
- if (!render11) {
2876
+ const render12 = getTemplateRenderer(templateName);
2877
+ if (!render12) {
2322
2878
  throw new Error(`Unknown email template: ${templateName}`);
2323
2879
  }
2324
- return render11(ctx);
2880
+ return render12(ctx);
2325
2881
  }
2326
2882
 
2327
2883
  // src/plugins/email/email-service.ts
2884
+ var SES_REGIONS_WITHOUT_SMTP = /* @__PURE__ */ new Set([
2885
+ "af-south-1",
2886
+ "ap-south-2",
2887
+ "ap-southeast-3",
2888
+ "ap-southeast-5",
2889
+ "ca-west-1",
2890
+ "eu-central-2",
2891
+ "eu-south-1",
2892
+ "il-central-1",
2893
+ "me-central-1",
2894
+ "me-south-1"
2895
+ ]);
2896
+ function sesSmtpHost(region) {
2897
+ return `email-smtp.${region}.amazonaws.com`;
2898
+ }
2899
+ function sesRegionSupportsSmtp(region) {
2900
+ return !SES_REGIONS_WITHOUT_SMTP.has(region.trim());
2901
+ }
2328
2902
  var EmailService = class {
2329
2903
  config;
2330
2904
  templateOptions;
2331
2905
  sesClient;
2332
2906
  transporter;
2907
+ /** AWS via SMTP (nodemailer) vs SES API SDK. */
2908
+ awsViaSmtp = false;
2333
2909
  constructor(config) {
2334
2910
  this.config = config;
2335
2911
  this.templateOptions = config.templateOptions;
2336
2912
  if (config.type === "AWS") {
2337
- if (!config.region || !config.accessKeyId || !config.secretAccessKey) {
2338
- throw new Error("AWS SES configuration incomplete");
2913
+ if (!config.region) {
2914
+ throw new Error("AWS SES configuration incomplete: AWS_REGION is required");
2915
+ }
2916
+ if (config.user && config.password) {
2917
+ this.awsViaSmtp = true;
2918
+ const host = config.host || sesSmtpHost(config.region);
2919
+ const port = config.port ?? 587;
2920
+ const secure = config.secure ?? false;
2921
+ this.transporter = nodemailer.createTransport({
2922
+ host,
2923
+ port,
2924
+ secure,
2925
+ auth: { user: config.user, pass: config.password }
2926
+ });
2927
+ } else if (config.accessKeyId && config.secretAccessKey) {
2928
+ this.sesClient = new SESClient({
2929
+ region: config.region,
2930
+ credentials: { accessKeyId: config.accessKeyId, secretAccessKey: config.secretAccessKey }
2931
+ });
2932
+ } else {
2933
+ throw new Error(
2934
+ "AWS SES configuration incomplete: set SMTP_USER and SMTP_PASSWORD (SES SMTP) or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (SES API)"
2935
+ );
2339
2936
  }
2340
- this.sesClient = new SESClient({
2341
- region: config.region,
2342
- credentials: { accessKeyId: config.accessKeyId, secretAccessKey: config.secretAccessKey }
2343
- });
2344
2937
  } else if (config.type === "SMTP" || config.type === "GMAIL") {
2345
2938
  if (!config.user || !config.password) throw new Error("SMTP configuration incomplete");
2346
- const host = config.type === "GMAIL" ? "smtp.gmail.com" : config.host || void 0;
2939
+ const host = config.type === "GMAIL" ? "smtp.gmail.com" : config.host;
2940
+ if (!host) {
2941
+ throw new Error(
2942
+ "SMTP configuration incomplete: SMTP_HOST is required when SMTP_TYPE=SMTP (nodemailer otherwise connects to 127.0.0.1)"
2943
+ );
2944
+ }
2347
2945
  const port = config.port ?? 587;
2348
2946
  const secure = config.secure ?? false;
2349
2947
  this.transporter = nodemailer.createTransport({
2350
- ...host ? { host } : {},
2948
+ host,
2351
2949
  port,
2352
2950
  secure,
2353
2951
  auth: { user: config.user, pass: config.password }
@@ -2374,7 +2972,7 @@ var EmailService = class {
2374
2972
  );
2375
2973
  return true;
2376
2974
  }
2377
- if ((this.config.type === "SMTP" || this.config.type === "GMAIL") && this.transporter) {
2975
+ if (this.transporter && (this.config.type === "SMTP" || this.config.type === "GMAIL" || this.config.type === "AWS" && this.awsViaSmtp)) {
2378
2976
  await this.transporter.sendMail({
2379
2977
  from: emailData.from || this.config.from,
2380
2978
  to: emailData.to || this.config.to,
@@ -2855,6 +3453,16 @@ async function sendChatLeadEmail(cms, emailSettings, brandingSettings, input) {
2855
3453
  }
2856
3454
 
2857
3455
  // src/plugins/email/index.ts
3456
+ var EMAIL_TYPES = ["AWS", "SMTP", "GMAIL", "SENDGRID"];
3457
+ function normalizeEmailType(raw, fallback) {
3458
+ const v = String(raw ?? fallback).trim().toUpperCase();
3459
+ return EMAIL_TYPES.includes(v) ? v : fallback;
3460
+ }
3461
+ function isLocalSmtpHost(host) {
3462
+ if (!host) return false;
3463
+ const h = host.trim().toLowerCase();
3464
+ return h === "localhost" || h === "127.0.0.1" || h === "::1";
3465
+ }
2858
3466
  function emailPlugin(config) {
2859
3467
  return {
2860
3468
  name: "email",
@@ -2862,31 +3470,57 @@ function emailPlugin(config) {
2862
3470
  async init(context) {
2863
3471
  const from = config.from || context.config.SMTP_FROM || "no-reply@example.com";
2864
3472
  const to = config.to || context.config.SMTP_TO || "info@example.com";
2865
- const type = config.type || context.config.SMTP_TYPE || "SMTP";
3473
+ const type = normalizeEmailType(context.config.SMTP_TYPE ?? config.type, "SMTP");
2866
3474
  const portEnv = context.config.SMTP_PORT;
2867
3475
  const portParsed = portEnv ? parseInt(portEnv, 10) : void 0;
3476
+ const region = config.region ?? context.config.AWS_SES_REGION ?? context.config.AWS_REGION;
3477
+ let host = config.host ?? context.config.SMTP_HOST;
3478
+ if (type === "AWS" && isLocalSmtpHost(host)) {
3479
+ host = void 0;
3480
+ }
2868
3481
  const merged = {
2869
3482
  ...config,
2870
3483
  from,
2871
3484
  to,
2872
3485
  type,
2873
3486
  user: config.user ?? context.config.SMTP_USER,
2874
- password: config.password ?? context.config.SMTP_PASSWORD,
2875
- host: config.host ?? context.config.SMTP_HOST,
3487
+ password: config.password ?? context.config.SMTP_PASSWORD ?? context.config.SMTP_PASS,
3488
+ host,
2876
3489
  port: config.port ?? (Number.isFinite(portParsed) ? portParsed : void 0),
2877
3490
  secure: config.secure ?? context.config.SMTP_SECURE === "true",
2878
- region: config.region ?? context.config.AWS_REGION,
3491
+ region,
2879
3492
  accessKeyId: config.accessKeyId ?? context.config.AWS_ACCESS_KEY_ID,
2880
3493
  secretAccessKey: config.secretAccessKey ?? context.config.AWS_SECRET_ACCESS_KEY
2881
3494
  };
2882
- if (type === "AWS" && (!merged.region || !merged.accessKeyId || !merged.secretAccessKey)) {
2883
- context.logger.warn("Email plugin skipped: AWS SES configuration incomplete");
3495
+ if (type === "AWS" && !merged.region) {
3496
+ context.logger.warn(
3497
+ "Email plugin skipped: AWS SES requires AWS_SES_REGION or AWS_REGION"
3498
+ );
3499
+ return void 0;
3500
+ }
3501
+ if (type === "AWS" && merged.region && merged.user && merged.password && !sesRegionSupportsSmtp(merged.region)) {
3502
+ context.logger.warn(
3503
+ `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.`
3504
+ );
3505
+ }
3506
+ if (type === "AWS" && !(merged.user && merged.password || merged.accessKeyId && merged.secretAccessKey)) {
3507
+ context.logger.warn(
3508
+ "Email plugin skipped: AWS SES requires SMTP_USER and SMTP_PASSWORD (SES SMTP) or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (SES API)"
3509
+ );
2884
3510
  return void 0;
2885
3511
  }
2886
3512
  if ((type === "SMTP" || type === "GMAIL") && (!merged.user || !merged.password)) {
2887
3513
  context.logger.warn("Email plugin skipped: SMTP credentials not configured");
2888
3514
  return void 0;
2889
3515
  }
3516
+ if (type === "SMTP" && !merged.host) {
3517
+ context.logger.warn(
3518
+ "Email plugin skipped: SMTP_TYPE=SMTP requires SMTP_HOST (or use SMTP_TYPE=AWS with AWS_REGION and SES SMTP credentials)"
3519
+ );
3520
+ return void 0;
3521
+ }
3522
+ const resolvedHost = type === "AWS" && merged.region ? merged.host || sesSmtpHost(merged.region) : merged.host;
3523
+ context.logger.info("Email plugin initialized", { type, host: resolvedHost, region: merged.region });
2890
3524
  return new EmailService(merged);
2891
3525
  }
2892
3526
  };
@@ -9513,6 +10147,50 @@ async function sendOrderPlacedEmailsAfterConfirmation(orderId, deps) {
9513
10147
  }
9514
10148
  }
9515
10149
 
10150
+ // src/lib/send-vendor-onboard-emails.ts
10151
+ init_email_queue();
10152
+ async function getSettingsGroup2(deps, group) {
10153
+ const ds = await deps.getDataSource();
10154
+ const rows = await ds.getRepository(deps.entityMap.configs).find({
10155
+ where: { settings: group, deleted: false }
10156
+ });
10157
+ return Object.fromEntries(
10158
+ rows.map((r) => [r.key, r.value])
10159
+ );
10160
+ }
10161
+ async function sendVendorOnboardEmails(input, deps) {
10162
+ let ownerEmailSent = false;
10163
+ try {
10164
+ const [branding, emailSettings] = await Promise.all([
10165
+ getSettingsGroup2(deps, "branding"),
10166
+ getSettingsGroup2(deps, "email")
10167
+ ]);
10168
+ const companyDetails = mergeEmailLayoutCompanyDetails(branding, emailSettings);
10169
+ const notifyEmails = parseEmailRecipientsFromConfig(
10170
+ emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail
10171
+ );
10172
+ const sendToOwner = input.sendToOwner !== false;
10173
+ const ownerEmail = input.ownerEmail?.trim() || "";
10174
+ const cms = await deps.getCms();
10175
+ await queueVendorOnboardEmails(cms, {
10176
+ vendorName: input.vendorName,
10177
+ vendorSlug: input.vendorSlug,
10178
+ ownerName: input.ownerName,
10179
+ ownerEmail,
10180
+ activation: input.activation,
10181
+ inviteLink: input.inviteLink,
10182
+ signInLink: input.signInLink,
10183
+ kind: input.kind ?? "vendor_onboard",
10184
+ notifyEmails,
10185
+ companyDetails,
10186
+ sendToOwner: sendToOwner && Boolean(ownerEmail)
10187
+ });
10188
+ ownerEmailSent = sendToOwner && Boolean(ownerEmail);
10189
+ } catch {
10190
+ }
10191
+ return { ownerEmailSent };
10192
+ }
10193
+
9516
10194
  // src/lib/data-source.ts
9517
10195
  import "reflect-metadata";
9518
10196
  import { DataSource } from "typeorm";
@@ -9631,7 +10309,7 @@ async function enrichUserWithVendorContext(dataSource, user) {
9631
10309
 
9632
10310
  // src/lib/hydrate-vendor-session-user.ts
9633
10311
  init_rbac_debug();
9634
- init_permission_entities();
10312
+ init_role_helpers();
9635
10313
  init_vendor_scope();
9636
10314
  async function hydrateVendorSessionUser(dataSource, user) {
9637
10315
  if (!user?.email) return user;
@@ -9639,7 +10317,7 @@ async function hydrateVendorSessionUser(dataSource, user) {
9639
10317
  if (!Number.isFinite(id)) {
9640
10318
  const byEmailRows = await dataSource.query(
9641
10319
  `
9642
- SELECT u.id AS id, u."adminAccess" AS "adminAccess", g.name AS "groupName"
10320
+ SELECT u.id AS id, u."adminAccess" AS "adminAccess", u."groupId" AS "groupId", g.name AS "groupName"
9643
10321
  FROM users u
9644
10322
  LEFT JOIN user_groups g ON g.id = u."groupId" AND g.deleted = false
9645
10323
  WHERE LOWER(TRIM(u.email)) = LOWER(TRIM($1)) AND u.deleted = false
@@ -9659,7 +10337,7 @@ async function hydrateVendorSessionUser(dataSource, user) {
9659
10337
  }
9660
10338
  const rows = await dataSource.query(
9661
10339
  `
9662
- SELECT u."adminAccess" AS "adminAccess", g.name AS "groupName"
10340
+ SELECT u."adminAccess" AS "adminAccess", u."groupId" AS "groupId", g.name AS "groupName"
9663
10341
  FROM users u
9664
10342
  LEFT JOIN user_groups g ON g.id = u."groupId" AND g.deleted = false
9665
10343
  WHERE u.id = $1
@@ -9668,8 +10346,9 @@ async function hydrateVendorSessionUser(dataSource, user) {
9668
10346
  [id]
9669
10347
  );
9670
10348
  const groupName = rows[0]?.groupName ?? user.groupName ?? null;
10349
+ const groupId = rows[0]?.groupId ?? user.groupId ?? void 0;
9671
10350
  const adminAccess = rows[0]?.adminAccess ?? user.adminAccess;
9672
- const isRBACAdmin = user.isRBACAdmin ?? isSuperAdminGroupName(groupName);
10351
+ const isRBACAdmin = user.isRBACAdmin ?? isSuperAdmin({ groupId, groupName, isRBACAdmin: user.isRBACAdmin });
9673
10352
  const ctx = await loadUserVendorContext(dataSource, id, user.activeVendorId);
9674
10353
  const flags = vendorPortalFlagsFromUser({
9675
10354
  email: user.email,
@@ -9680,6 +10359,7 @@ async function hydrateVendorSessionUser(dataSource, user) {
9680
10359
  });
9681
10360
  const hydrated = {
9682
10361
  ...user,
10362
+ groupId,
9683
10363
  groupName: groupName ?? void 0,
9684
10364
  adminAccess,
9685
10365
  isRBACAdmin,
@@ -9790,17 +10470,37 @@ async function contactIsVendorCustomer(dataSource, entityMap, vendorId, contactI
9790
10470
  const contactEntity = entityMap.contacts;
9791
10471
  if (!vcEntity || !contactEntity) return false;
9792
10472
  const vcRepo = dataSource.getRepository(vcEntity);
9793
- const link = await vcRepo.findOne({
9794
- where: { vendorId, contactId }
9795
- });
9796
- if (!link) return false;
9797
10473
  const contactRepo = dataSource.getRepository(contactEntity);
9798
10474
  const contact = await contactRepo.findOne({
9799
10475
  where: { id: contactId, deleted: false }
9800
10476
  });
9801
10477
  if (!contact) return false;
9802
- const t = contact.type;
9803
- return t == null || t === "" || isCustomerTypeContact(t);
10478
+ const email = contact.email;
10479
+ if (entityMap.customer && email) {
10480
+ const customerRepo = dataSource.getRepository(entityMap.customer);
10481
+ const customer = await customerRepo.findOne({
10482
+ where: { email, deleted: false }
10483
+ });
10484
+ if (customer) {
10485
+ const customerId = Number(customer.id);
10486
+ const customerLink = await vcRepo.findOne({
10487
+ where: { vendorId, customerId }
10488
+ });
10489
+ if (customerLink != null) return true;
10490
+ }
10491
+ }
10492
+ const vcMeta = dataSource.getRepository(vcEntity).metadata;
10493
+ const hasContactIdCol = vcMeta.columns.some((c) => c.propertyName === "contactId");
10494
+ if (hasContactIdCol) {
10495
+ const directLink = await vcRepo.findOne({
10496
+ where: { vendorId, contactId }
10497
+ });
10498
+ if (directLink) {
10499
+ const t = contact.type;
10500
+ return t == null || t == "" || isCustomerTypeContact(t);
10501
+ }
10502
+ }
10503
+ return false;
9804
10504
  }
9805
10505
  async function assertContactAllowedForVendorOrder(dataSource, entityMap, vendorId, contactId) {
9806
10506
  if (!Number.isFinite(contactId)) {
@@ -10446,7 +11146,7 @@ Blog = __decorateClass([
10446
11146
  ], Blog);
10447
11147
 
10448
11148
  // src/entities/contact.entity.ts
10449
- import { Entity as Entity24, PrimaryGeneratedColumn as PrimaryGeneratedColumn24, Column as Column24, OneToMany as OneToMany11, ManyToOne as ManyToOne14, JoinColumn as JoinColumn14 } from "typeorm";
11149
+ import { Entity as Entity26, PrimaryGeneratedColumn as PrimaryGeneratedColumn26, Column as Column26, OneToMany as OneToMany11, ManyToOne as ManyToOne16, JoinColumn as JoinColumn16 } from "typeorm";
10450
11150
 
10451
11151
  // src/entities/form-submission.entity.ts
10452
11152
  import { Entity as Entity16, PrimaryGeneratedColumn as PrimaryGeneratedColumn16, Column as Column16, ManyToOne as ManyToOne7, JoinColumn as JoinColumn7 } from "typeorm";
@@ -10713,7 +11413,7 @@ Address = __decorateClass([
10713
11413
  ], Address);
10714
11414
 
10715
11415
  // src/entities/order.entity.ts
10716
- import { Entity as Entity20, PrimaryGeneratedColumn as PrimaryGeneratedColumn20, Column as Column20, ManyToOne as ManyToOne10, OneToMany as OneToMany9, JoinColumn as JoinColumn10, Unique } from "typeorm";
11416
+ import { Entity as Entity22, PrimaryGeneratedColumn as PrimaryGeneratedColumn22, Column as Column22, ManyToOne as ManyToOne12, OneToMany as OneToMany9, JoinColumn as JoinColumn12, Unique } from "typeorm";
10717
11417
 
10718
11418
  // src/entities/vendor.entity.ts
10719
11419
  import { Entity as Entity18, PrimaryGeneratedColumn as PrimaryGeneratedColumn18, Column as Column18, OneToMany as OneToMany7 } from "typeorm";
@@ -10873,6 +11573,99 @@ OrderAddresses = __decorateClass([
10873
11573
  Entity19("order_addresses")
10874
11574
  ], OrderAddresses);
10875
11575
 
11576
+ // src/entities/customer_contacts.entity.ts
11577
+ import { Column as Column21, Entity as Entity21, PrimaryGeneratedColumn as PrimaryGeneratedColumn21, ManyToOne as ManyToOne11, JoinColumn as JoinColumn11 } from "typeorm";
11578
+
11579
+ // src/entities/customer.entity.ts
11580
+ import { Entity as Entity20, PrimaryGeneratedColumn as PrimaryGeneratedColumn20, Column as Column20, ManyToOne as ManyToOne10, JoinColumn as JoinColumn10 } from "typeorm";
11581
+ var Customer = class {
11582
+ id;
11583
+ userId;
11584
+ user;
11585
+ name;
11586
+ email;
11587
+ phone;
11588
+ createdAt;
11589
+ updatedAt;
11590
+ deletedAt;
11591
+ deleted;
11592
+ createdBy;
11593
+ updatedBy;
11594
+ deletedBy;
11595
+ };
11596
+ __decorateClass([
11597
+ PrimaryGeneratedColumn20()
11598
+ ], Customer.prototype, "id", 2);
11599
+ __decorateClass([
11600
+ Column20("int")
11601
+ ], Customer.prototype, "userId", 2);
11602
+ __decorateClass([
11603
+ ManyToOne10(() => User, { onDelete: "SET NULL" }),
11604
+ JoinColumn10({ name: "userId" })
11605
+ ], Customer.prototype, "user", 2);
11606
+ __decorateClass([
11607
+ Column20("varchar")
11608
+ ], Customer.prototype, "name", 2);
11609
+ __decorateClass([
11610
+ Column20("varchar", { unique: true })
11611
+ ], Customer.prototype, "email", 2);
11612
+ __decorateClass([
11613
+ Column20("varchar", { unique: true })
11614
+ ], Customer.prototype, "phone", 2);
11615
+ __decorateClass([
11616
+ Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11617
+ ], Customer.prototype, "createdAt", 2);
11618
+ __decorateClass([
11619
+ Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11620
+ ], Customer.prototype, "updatedAt", 2);
11621
+ __decorateClass([
11622
+ Column20({ type: "timestamp", nullable: true })
11623
+ ], Customer.prototype, "deletedAt", 2);
11624
+ __decorateClass([
11625
+ Column20("boolean", { default: false })
11626
+ ], Customer.prototype, "deleted", 2);
11627
+ __decorateClass([
11628
+ Column20("int", { nullable: true })
11629
+ ], Customer.prototype, "createdBy", 2);
11630
+ __decorateClass([
11631
+ Column20("int", { nullable: true })
11632
+ ], Customer.prototype, "updatedBy", 2);
11633
+ __decorateClass([
11634
+ Column20("int", { nullable: true })
11635
+ ], Customer.prototype, "deletedBy", 2);
11636
+ Customer = __decorateClass([
11637
+ Entity20("customer")
11638
+ ], Customer);
11639
+
11640
+ // src/entities/customer_contacts.entity.ts
11641
+ var Customer_Contacts = class {
11642
+ id;
11643
+ customerId;
11644
+ customer;
11645
+ contactId;
11646
+ contact;
11647
+ };
11648
+ __decorateClass([
11649
+ PrimaryGeneratedColumn21()
11650
+ ], Customer_Contacts.prototype, "id", 2);
11651
+ __decorateClass([
11652
+ Column21("int")
11653
+ ], Customer_Contacts.prototype, "customerId", 2);
11654
+ __decorateClass([
11655
+ ManyToOne11(() => Customer, { onDelete: "CASCADE" }),
11656
+ JoinColumn11({ name: "customerId" })
11657
+ ], Customer_Contacts.prototype, "customer", 2);
11658
+ __decorateClass([
11659
+ Column21("int")
11660
+ ], Customer_Contacts.prototype, "contactId", 2);
11661
+ __decorateClass([
11662
+ ManyToOne11(() => Contact, { onDelete: "CASCADE" }),
11663
+ JoinColumn11({ name: "contactId" })
11664
+ ], Customer_Contacts.prototype, "contact", 2);
11665
+ Customer_Contacts = __decorateClass([
11666
+ Entity21("customer_contacts")
11667
+ ], Customer_Contacts);
11668
+
10876
11669
  // src/entities/order.entity.ts
10877
11670
  var Order = class {
10878
11671
  id;
@@ -10882,6 +11675,7 @@ var Order = class {
10882
11675
  orderKind;
10883
11676
  parentOrderId;
10884
11677
  contactId;
11678
+ customerContactId;
10885
11679
  billingAddressId;
10886
11680
  shippingAddressId;
10887
11681
  status;
@@ -10902,102 +11696,110 @@ var Order = class {
10902
11696
  parentOrder;
10903
11697
  children;
10904
11698
  contact;
11699
+ customerContact;
10905
11700
  billingAddress;
10906
11701
  shippingAddress;
10907
11702
  items;
10908
11703
  payments;
10909
11704
  };
10910
11705
  __decorateClass([
10911
- PrimaryGeneratedColumn20()
11706
+ PrimaryGeneratedColumn22()
10912
11707
  ], Order.prototype, "id", 2);
10913
11708
  __decorateClass([
10914
- Column20("int")
11709
+ Column22("int")
10915
11710
  ], Order.prototype, "vendorId", 2);
10916
11711
  __decorateClass([
10917
- Column20("varchar")
11712
+ Column22("varchar")
10918
11713
  ], Order.prototype, "orderNumber", 2);
10919
11714
  __decorateClass([
10920
- Column20("varchar", { unique: true, nullable: true })
11715
+ Column22("varchar", { unique: true, nullable: true })
10921
11716
  ], Order.prototype, "qrToken", 2);
10922
11717
  __decorateClass([
10923
- Column20("varchar", { default: "sale" })
11718
+ Column22("varchar", { default: "sale" })
10924
11719
  ], Order.prototype, "orderKind", 2);
10925
11720
  __decorateClass([
10926
- Column20("int", { nullable: true })
11721
+ Column22("int", { nullable: true })
10927
11722
  ], Order.prototype, "parentOrderId", 2);
10928
11723
  __decorateClass([
10929
- Column20("int")
11724
+ Column22("int")
10930
11725
  ], Order.prototype, "contactId", 2);
10931
11726
  __decorateClass([
10932
- Column20("int", { nullable: true })
11727
+ Column22("int", { nullable: true })
11728
+ ], Order.prototype, "customerContactId", 2);
11729
+ __decorateClass([
11730
+ Column22("int", { nullable: true })
10933
11731
  ], Order.prototype, "billingAddressId", 2);
10934
11732
  __decorateClass([
10935
- Column20("int", { nullable: true })
11733
+ Column22("int", { nullable: true })
10936
11734
  ], Order.prototype, "shippingAddressId", 2);
10937
11735
  __decorateClass([
10938
- Column20("varchar", { default: "pending" })
11736
+ Column22("varchar", { default: "pending" })
10939
11737
  ], Order.prototype, "status", 2);
10940
11738
  __decorateClass([
10941
- Column20("decimal", { precision: 12, scale: 2, default: 0 })
11739
+ Column22("decimal", { precision: 12, scale: 2, default: 0 })
10942
11740
  ], Order.prototype, "subtotal", 2);
10943
11741
  __decorateClass([
10944
- Column20("decimal", { precision: 12, scale: 2, default: 0 })
11742
+ Column22("decimal", { precision: 12, scale: 2, default: 0 })
10945
11743
  ], Order.prototype, "tax", 2);
10946
11744
  __decorateClass([
10947
- Column20("decimal", { precision: 12, scale: 2, default: 0 })
11745
+ Column22("decimal", { precision: 12, scale: 2, default: 0 })
10948
11746
  ], Order.prototype, "discount", 2);
10949
11747
  __decorateClass([
10950
- Column20("decimal", { precision: 12, scale: 2, default: 0 })
11748
+ Column22("decimal", { precision: 12, scale: 2, default: 0 })
10951
11749
  ], Order.prototype, "total", 2);
10952
11750
  __decorateClass([
10953
- Column20("varchar", { default: "INR" })
11751
+ Column22("varchar", { default: "INR" })
10954
11752
  ], Order.prototype, "currency", 2);
10955
11753
  __decorateClass([
10956
- Column20("jsonb", { nullable: true })
11754
+ Column22("jsonb", { nullable: true })
10957
11755
  ], Order.prototype, "metadata", 2);
10958
11756
  __decorateClass([
10959
- Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11757
+ Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
10960
11758
  ], Order.prototype, "createdAt", 2);
10961
11759
  __decorateClass([
10962
- Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11760
+ Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
10963
11761
  ], Order.prototype, "updatedAt", 2);
10964
11762
  __decorateClass([
10965
- Column20({ type: "timestamp", nullable: true })
11763
+ Column22({ type: "timestamp", nullable: true })
10966
11764
  ], Order.prototype, "deletedAt", 2);
10967
11765
  __decorateClass([
10968
- Column20("boolean", { default: false })
11766
+ Column22("boolean", { default: false })
10969
11767
  ], Order.prototype, "deleted", 2);
10970
11768
  __decorateClass([
10971
- Column20("int", { nullable: true })
11769
+ Column22("int", { nullable: true })
10972
11770
  ], Order.prototype, "createdBy", 2);
10973
11771
  __decorateClass([
10974
- Column20("int", { nullable: true })
11772
+ Column22("int", { nullable: true })
10975
11773
  ], Order.prototype, "updatedBy", 2);
10976
11774
  __decorateClass([
10977
- Column20("int", { nullable: true })
11775
+ Column22("int", { nullable: true })
10978
11776
  ], Order.prototype, "deletedBy", 2);
10979
11777
  __decorateClass([
10980
- ManyToOne10(() => Vendor, { onDelete: "RESTRICT" }),
10981
- JoinColumn10({ name: "vendorId" })
11778
+ ManyToOne12(() => Vendor, { onDelete: "RESTRICT" }),
11779
+ JoinColumn12({ name: "vendorId" })
10982
11780
  ], Order.prototype, "vendor", 2);
10983
11781
  __decorateClass([
10984
- ManyToOne10(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
10985
- JoinColumn10({ name: "parentOrderId" })
11782
+ ManyToOne12(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
11783
+ JoinColumn12({ name: "parentOrderId" })
10986
11784
  ], Order.prototype, "parentOrder", 2);
10987
11785
  __decorateClass([
10988
11786
  OneToMany9(() => Order, (o) => o.parentOrder)
10989
11787
  ], Order.prototype, "children", 2);
10990
11788
  __decorateClass([
10991
- ManyToOne10(() => Contact, { onDelete: "CASCADE" }),
10992
- JoinColumn10({ name: "contactId" })
11789
+ ManyToOne12(() => Contact, { onDelete: "CASCADE" }),
11790
+ JoinColumn12({ name: "contactId" })
10993
11791
  ], Order.prototype, "contact", 2);
10994
11792
  __decorateClass([
10995
- ManyToOne10(() => OrderAddresses, { onDelete: "SET NULL" }),
10996
- JoinColumn10({ name: "billingAddressId" })
11793
+ ManyToOne12(() => Customer_Contacts, { onDelete: "SET NULL" }),
11794
+ JoinColumn12({ name: "customerContactId" })
11795
+ ], Order.prototype, "customerContact", 2);
11796
+ __decorateClass([
11797
+ ManyToOne12(() => OrderAddresses, { onDelete: "SET NULL" }),
11798
+ JoinColumn12({ name: "billingAddressId" })
10997
11799
  ], Order.prototype, "billingAddress", 2);
10998
11800
  __decorateClass([
10999
- ManyToOne10(() => OrderAddresses, { onDelete: "SET NULL" }),
11000
- JoinColumn10({ name: "shippingAddressId" })
11801
+ ManyToOne12(() => OrderAddresses, { onDelete: "SET NULL" }),
11802
+ JoinColumn12({ name: "shippingAddressId" })
11001
11803
  ], Order.prototype, "shippingAddress", 2);
11002
11804
  __decorateClass([
11003
11805
  OneToMany9("OrderItem", "order")
@@ -11006,12 +11808,12 @@ __decorateClass([
11006
11808
  OneToMany9("Payment", "order")
11007
11809
  ], Order.prototype, "payments", 2);
11008
11810
  Order = __decorateClass([
11009
- Entity20("orders"),
11811
+ Entity22("orders"),
11010
11812
  Unique("UQ_orders_vendor_orderNumber", ["vendorId", "orderNumber"])
11011
11813
  ], Order);
11012
11814
 
11013
11815
  // src/entities/payment.entity.ts
11014
- import { Entity as Entity21, PrimaryGeneratedColumn as PrimaryGeneratedColumn21, Column as Column21, ManyToOne as ManyToOne11, JoinColumn as JoinColumn11 } from "typeorm";
11816
+ import { Entity as Entity23, PrimaryGeneratedColumn as PrimaryGeneratedColumn23, Column as Column23, ManyToOne as ManyToOne13, JoinColumn as JoinColumn13 } from "typeorm";
11015
11817
  var Payment = class {
11016
11818
  id;
11017
11819
  vendorId;
@@ -11036,80 +11838,80 @@ var Payment = class {
11036
11838
  contact;
11037
11839
  };
11038
11840
  __decorateClass([
11039
- PrimaryGeneratedColumn21()
11841
+ PrimaryGeneratedColumn23()
11040
11842
  ], Payment.prototype, "id", 2);
11041
11843
  __decorateClass([
11042
- Column21("int")
11844
+ Column23("int")
11043
11845
  ], Payment.prototype, "vendorId", 2);
11044
11846
  __decorateClass([
11045
- Column21("int")
11847
+ Column23("int")
11046
11848
  ], Payment.prototype, "orderId", 2);
11047
11849
  __decorateClass([
11048
- Column21("int", { nullable: true })
11850
+ Column23("int", { nullable: true })
11049
11851
  ], Payment.prototype, "contactId", 2);
11050
11852
  __decorateClass([
11051
- Column21("decimal", { precision: 12, scale: 2 })
11853
+ Column23("decimal", { precision: 12, scale: 2 })
11052
11854
  ], Payment.prototype, "amount", 2);
11053
11855
  __decorateClass([
11054
- Column21("varchar", { default: "INR" })
11856
+ Column23("varchar", { default: "INR" })
11055
11857
  ], Payment.prototype, "currency", 2);
11056
11858
  __decorateClass([
11057
- Column21("varchar", { default: "pending" })
11859
+ Column23("varchar", { default: "pending" })
11058
11860
  ], Payment.prototype, "status", 2);
11059
11861
  __decorateClass([
11060
- Column21("varchar", { nullable: true })
11862
+ Column23("varchar", { nullable: true })
11061
11863
  ], Payment.prototype, "method", 2);
11062
11864
  __decorateClass([
11063
- Column21("varchar", { nullable: true })
11865
+ Column23("varchar", { nullable: true })
11064
11866
  ], Payment.prototype, "externalReference", 2);
11065
11867
  __decorateClass([
11066
- Column21("jsonb", { nullable: true })
11868
+ Column23("jsonb", { nullable: true })
11067
11869
  ], Payment.prototype, "metadata", 2);
11068
11870
  __decorateClass([
11069
- Column21({ type: "timestamp", nullable: true })
11871
+ Column23({ type: "timestamp", nullable: true })
11070
11872
  ], Payment.prototype, "paidAt", 2);
11071
11873
  __decorateClass([
11072
- Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11874
+ Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11073
11875
  ], Payment.prototype, "createdAt", 2);
11074
11876
  __decorateClass([
11075
- Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11877
+ Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11076
11878
  ], Payment.prototype, "updatedAt", 2);
11077
11879
  __decorateClass([
11078
- Column21({ type: "timestamp", nullable: true })
11880
+ Column23({ type: "timestamp", nullable: true })
11079
11881
  ], Payment.prototype, "deletedAt", 2);
11080
11882
  __decorateClass([
11081
- Column21("boolean", { default: false })
11883
+ Column23("boolean", { default: false })
11082
11884
  ], Payment.prototype, "deleted", 2);
11083
11885
  __decorateClass([
11084
- Column21("int", { nullable: true })
11886
+ Column23("int", { nullable: true })
11085
11887
  ], Payment.prototype, "createdBy", 2);
11086
11888
  __decorateClass([
11087
- Column21("int", { nullable: true })
11889
+ Column23("int", { nullable: true })
11088
11890
  ], Payment.prototype, "updatedBy", 2);
11089
11891
  __decorateClass([
11090
- Column21("int", { nullable: true })
11892
+ Column23("int", { nullable: true })
11091
11893
  ], Payment.prototype, "deletedBy", 2);
11092
11894
  __decorateClass([
11093
- ManyToOne11(() => Vendor, { onDelete: "RESTRICT" }),
11094
- JoinColumn11({ name: "vendorId" })
11895
+ ManyToOne13(() => Vendor, { onDelete: "RESTRICT" }),
11896
+ JoinColumn13({ name: "vendorId" })
11095
11897
  ], Payment.prototype, "vendor", 2);
11096
11898
  __decorateClass([
11097
- ManyToOne11(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
11098
- JoinColumn11({ name: "orderId" })
11899
+ ManyToOne13(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
11900
+ JoinColumn13({ name: "orderId" })
11099
11901
  ], Payment.prototype, "order", 2);
11100
11902
  __decorateClass([
11101
- ManyToOne11(() => Contact, { onDelete: "SET NULL" }),
11102
- JoinColumn11({ name: "contactId" })
11903
+ ManyToOne13(() => Contact, { onDelete: "SET NULL" }),
11904
+ JoinColumn13({ name: "contactId" })
11103
11905
  ], Payment.prototype, "contact", 2);
11104
11906
  Payment = __decorateClass([
11105
- Entity21("payments")
11907
+ Entity23("payments")
11106
11908
  ], Payment);
11107
11909
 
11108
11910
  // src/entities/chat-conversation.entity.ts
11109
- import { Entity as Entity23, PrimaryGeneratedColumn as PrimaryGeneratedColumn23, Column as Column23, ManyToOne as ManyToOne13, OneToMany as OneToMany10, JoinColumn as JoinColumn13 } from "typeorm";
11911
+ import { Entity as Entity25, PrimaryGeneratedColumn as PrimaryGeneratedColumn25, Column as Column25, ManyToOne as ManyToOne15, OneToMany as OneToMany10, JoinColumn as JoinColumn15 } from "typeorm";
11110
11912
 
11111
11913
  // src/entities/chat-message.entity.ts
11112
- import { Entity as Entity22, PrimaryGeneratedColumn as PrimaryGeneratedColumn22, Column as Column22, ManyToOne as ManyToOne12, JoinColumn as JoinColumn12 } from "typeorm";
11914
+ import { Entity as Entity24, PrimaryGeneratedColumn as PrimaryGeneratedColumn24, Column as Column24, ManyToOne as ManyToOne14, JoinColumn as JoinColumn14 } from "typeorm";
11113
11915
  var ChatMessage = class {
11114
11916
  id;
11115
11917
  conversationId;
@@ -11119,26 +11921,26 @@ var ChatMessage = class {
11119
11921
  conversation;
11120
11922
  };
11121
11923
  __decorateClass([
11122
- PrimaryGeneratedColumn22()
11924
+ PrimaryGeneratedColumn24()
11123
11925
  ], ChatMessage.prototype, "id", 2);
11124
11926
  __decorateClass([
11125
- Column22("int")
11927
+ Column24("int")
11126
11928
  ], ChatMessage.prototype, "conversationId", 2);
11127
11929
  __decorateClass([
11128
- Column22("varchar")
11930
+ Column24("varchar")
11129
11931
  ], ChatMessage.prototype, "role", 2);
11130
11932
  __decorateClass([
11131
- Column22("text")
11933
+ Column24("text")
11132
11934
  ], ChatMessage.prototype, "content", 2);
11133
11935
  __decorateClass([
11134
- Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11936
+ Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11135
11937
  ], ChatMessage.prototype, "createdAt", 2);
11136
11938
  __decorateClass([
11137
- ManyToOne12(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
11138
- JoinColumn12({ name: "conversationId" })
11939
+ ManyToOne14(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
11940
+ JoinColumn14({ name: "conversationId" })
11139
11941
  ], ChatMessage.prototype, "conversation", 2);
11140
11942
  ChatMessage = __decorateClass([
11141
- Entity22("chat_messages")
11943
+ Entity24("chat_messages")
11142
11944
  ], ChatMessage);
11143
11945
 
11144
11946
  // src/entities/chat-conversation.entity.ts
@@ -11152,29 +11954,29 @@ var ChatConversation = class {
11152
11954
  messages;
11153
11955
  };
11154
11956
  __decorateClass([
11155
- PrimaryGeneratedColumn23()
11957
+ PrimaryGeneratedColumn25()
11156
11958
  ], ChatConversation.prototype, "id", 2);
11157
11959
  __decorateClass([
11158
- Column23("int")
11960
+ Column25("int")
11159
11961
  ], ChatConversation.prototype, "contactId", 2);
11160
11962
  __decorateClass([
11161
- Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11963
+ Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11162
11964
  ], ChatConversation.prototype, "createdAt", 2);
11163
11965
  __decorateClass([
11164
- Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11966
+ Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11165
11967
  ], ChatConversation.prototype, "updatedAt", 2);
11166
11968
  __decorateClass([
11167
- Column23({ type: "timestamp", nullable: true })
11969
+ Column25({ type: "timestamp", nullable: true })
11168
11970
  ], ChatConversation.prototype, "leadEmailSentAt", 2);
11169
11971
  __decorateClass([
11170
- ManyToOne13(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
11171
- JoinColumn13({ name: "contactId" })
11972
+ ManyToOne15(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
11973
+ JoinColumn15({ name: "contactId" })
11172
11974
  ], ChatConversation.prototype, "contact", 2);
11173
11975
  __decorateClass([
11174
11976
  OneToMany10(() => ChatMessage, (m) => m.conversation)
11175
11977
  ], ChatConversation.prototype, "messages", 2);
11176
11978
  ChatConversation = __decorateClass([
11177
- Entity23("chat_conversations")
11979
+ Entity25("chat_conversations")
11178
11980
  ], ChatConversation);
11179
11981
 
11180
11982
  // src/entities/contact.entity.ts
@@ -11204,56 +12006,56 @@ var Contact = class {
11204
12006
  orderAddresses;
11205
12007
  };
11206
12008
  __decorateClass([
11207
- PrimaryGeneratedColumn24()
12009
+ PrimaryGeneratedColumn26()
11208
12010
  ], Contact.prototype, "id", 2);
11209
12011
  __decorateClass([
11210
- Column24("varchar")
12012
+ Column26("varchar")
11211
12013
  ], Contact.prototype, "name", 2);
11212
12014
  __decorateClass([
11213
- Column24("varchar", { unique: true })
12015
+ Column26("varchar", { unique: true })
11214
12016
  ], Contact.prototype, "email", 2);
11215
12017
  __decorateClass([
11216
- Column24("varchar", { nullable: true })
12018
+ Column26("varchar", { nullable: true })
11217
12019
  ], Contact.prototype, "phone", 2);
11218
12020
  __decorateClass([
11219
- Column24("varchar", { nullable: true })
12021
+ Column26("varchar", { nullable: true })
11220
12022
  ], Contact.prototype, "type", 2);
11221
12023
  __decorateClass([
11222
- Column24("varchar", { nullable: true })
12024
+ Column26("varchar", { nullable: true })
11223
12025
  ], Contact.prototype, "company", 2);
11224
12026
  __decorateClass([
11225
- Column24("varchar", { nullable: true })
12027
+ Column26("varchar", { nullable: true })
11226
12028
  ], Contact.prototype, "taxId", 2);
11227
12029
  __decorateClass([
11228
- Column24("text", { nullable: true })
12030
+ Column26("text", { nullable: true })
11229
12031
  ], Contact.prototype, "notes", 2);
11230
12032
  __decorateClass([
11231
- Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12033
+ Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11232
12034
  ], Contact.prototype, "createdAt", 2);
11233
12035
  __decorateClass([
11234
- Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12036
+ Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11235
12037
  ], Contact.prototype, "updatedAt", 2);
11236
12038
  __decorateClass([
11237
- Column24({ type: "timestamp", nullable: true })
12039
+ Column26({ type: "timestamp", nullable: true })
11238
12040
  ], Contact.prototype, "deletedAt", 2);
11239
12041
  __decorateClass([
11240
- Column24("boolean", { default: false })
12042
+ Column26("boolean", { default: false })
11241
12043
  ], Contact.prototype, "deleted", 2);
11242
12044
  __decorateClass([
11243
- Column24("int", { nullable: true })
12045
+ Column26("int", { nullable: true })
11244
12046
  ], Contact.prototype, "createdBy", 2);
11245
12047
  __decorateClass([
11246
- Column24("int", { nullable: true })
12048
+ Column26("int", { nullable: true })
11247
12049
  ], Contact.prototype, "updatedBy", 2);
11248
12050
  __decorateClass([
11249
- Column24("int", { nullable: true })
12051
+ Column26("int", { nullable: true })
11250
12052
  ], Contact.prototype, "deletedBy", 2);
11251
12053
  __decorateClass([
11252
- Column24("int", { nullable: true })
12054
+ Column26("int", { nullable: true })
11253
12055
  ], Contact.prototype, "userId", 2);
11254
12056
  __decorateClass([
11255
- ManyToOne14(() => User, { onDelete: "SET NULL" }),
11256
- JoinColumn14({ name: "userId" })
12057
+ ManyToOne16(() => User, { onDelete: "SET NULL" }),
12058
+ JoinColumn16({ name: "userId" })
11257
12059
  ], Contact.prototype, "user", 2);
11258
12060
  __decorateClass([
11259
12061
  OneToMany11(() => FormSubmission, (fs2) => fs2.contact)
@@ -11274,11 +12076,11 @@ __decorateClass([
11274
12076
  OneToMany11(() => OrderAddresses, (orderAddresses) => orderAddresses.contact)
11275
12077
  ], Contact.prototype, "orderAddresses", 2);
11276
12078
  Contact = __decorateClass([
11277
- Entity24("contacts")
12079
+ Entity26("contacts")
11278
12080
  ], Contact);
11279
12081
 
11280
12082
  // src/entities/config.entity.ts
11281
- import { Entity as Entity25, PrimaryGeneratedColumn as PrimaryGeneratedColumn25, Column as Column25, Unique as Unique2 } from "typeorm";
12083
+ import { Entity as Entity27, PrimaryGeneratedColumn as PrimaryGeneratedColumn27, Column as Column27, Unique as Unique2 } from "typeorm";
11282
12084
  var Config = class {
11283
12085
  id;
11284
12086
  settings;
@@ -11295,51 +12097,51 @@ var Config = class {
11295
12097
  deletedBy;
11296
12098
  };
11297
12099
  __decorateClass([
11298
- PrimaryGeneratedColumn25()
12100
+ PrimaryGeneratedColumn27()
11299
12101
  ], Config.prototype, "id", 2);
11300
12102
  __decorateClass([
11301
- Column25("varchar")
12103
+ Column27("varchar")
11302
12104
  ], Config.prototype, "settings", 2);
11303
12105
  __decorateClass([
11304
- Column25("varchar")
12106
+ Column27("varchar")
11305
12107
  ], Config.prototype, "key", 2);
11306
12108
  __decorateClass([
11307
- Column25("varchar")
12109
+ Column27("varchar")
11308
12110
  ], Config.prototype, "value", 2);
11309
12111
  __decorateClass([
11310
- Column25("varchar", { default: "private" })
12112
+ Column27("varchar", { default: "private" })
11311
12113
  ], Config.prototype, "type", 2);
11312
12114
  __decorateClass([
11313
- Column25("boolean", { default: false })
12115
+ Column27("boolean", { default: false })
11314
12116
  ], Config.prototype, "encrypted", 2);
11315
12117
  __decorateClass([
11316
- Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12118
+ Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11317
12119
  ], Config.prototype, "createdAt", 2);
11318
12120
  __decorateClass([
11319
- Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12121
+ Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11320
12122
  ], Config.prototype, "updatedAt", 2);
11321
12123
  __decorateClass([
11322
- Column25({ type: "timestamp", nullable: true })
12124
+ Column27({ type: "timestamp", nullable: true })
11323
12125
  ], Config.prototype, "deletedAt", 2);
11324
12126
  __decorateClass([
11325
- Column25("boolean", { default: false })
12127
+ Column27("boolean", { default: false })
11326
12128
  ], Config.prototype, "deleted", 2);
11327
12129
  __decorateClass([
11328
- Column25("int", { nullable: true })
12130
+ Column27("int", { nullable: true })
11329
12131
  ], Config.prototype, "createdBy", 2);
11330
12132
  __decorateClass([
11331
- Column25("int", { nullable: true })
12133
+ Column27("int", { nullable: true })
11332
12134
  ], Config.prototype, "updatedBy", 2);
11333
12135
  __decorateClass([
11334
- Column25("int", { nullable: true })
12136
+ Column27("int", { nullable: true })
11335
12137
  ], Config.prototype, "deletedBy", 2);
11336
12138
  Config = __decorateClass([
11337
- Entity25("configs"),
12139
+ Entity27("configs"),
11338
12140
  Unique2(["settings", "key"])
11339
12141
  ], Config);
11340
12142
 
11341
12143
  // src/entities/message-template.entity.ts
11342
- import { Entity as Entity26, PrimaryGeneratedColumn as PrimaryGeneratedColumn26, Column as Column26 } from "typeorm";
12144
+ import { Entity as Entity28, PrimaryGeneratedColumn as PrimaryGeneratedColumn28, Column as Column28 } from "typeorm";
11343
12145
  var MessageTemplate = class {
11344
12146
  id;
11345
12147
  channel;
@@ -11359,59 +12161,59 @@ var MessageTemplate = class {
11359
12161
  deletedBy;
11360
12162
  };
11361
12163
  __decorateClass([
11362
- PrimaryGeneratedColumn26()
12164
+ PrimaryGeneratedColumn28()
11363
12165
  ], MessageTemplate.prototype, "id", 2);
11364
12166
  __decorateClass([
11365
- Column26("varchar")
12167
+ Column28("varchar")
11366
12168
  ], MessageTemplate.prototype, "channel", 2);
11367
12169
  __decorateClass([
11368
- Column26("varchar", { name: "template_key" })
12170
+ Column28("varchar", { name: "template_key" })
11369
12171
  ], MessageTemplate.prototype, "templateKey", 2);
11370
12172
  __decorateClass([
11371
- Column26("varchar", { nullable: true })
12173
+ Column28("varchar", { nullable: true })
11372
12174
  ], MessageTemplate.prototype, "name", 2);
11373
12175
  __decorateClass([
11374
- Column26("varchar", { nullable: true })
12176
+ Column28("varchar", { nullable: true })
11375
12177
  ], MessageTemplate.prototype, "subject", 2);
11376
12178
  __decorateClass([
11377
- Column26("text", { default: "" })
12179
+ Column28("text", { default: "" })
11378
12180
  ], MessageTemplate.prototype, "body", 2);
11379
12181
  __decorateClass([
11380
- Column26("varchar", { name: "external_template_ref", nullable: true })
12182
+ Column28("varchar", { name: "external_template_ref", nullable: true })
11381
12183
  ], MessageTemplate.prototype, "externalTemplateRef", 2);
11382
12184
  __decorateClass([
11383
- Column26({ type: "jsonb", nullable: true })
12185
+ Column28({ type: "jsonb", nullable: true })
11384
12186
  ], MessageTemplate.prototype, "providerMeta", 2);
11385
12187
  __decorateClass([
11386
- Column26("boolean", { default: true })
12188
+ Column28("boolean", { default: true })
11387
12189
  ], MessageTemplate.prototype, "enabled", 2);
11388
12190
  __decorateClass([
11389
- Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12191
+ Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11390
12192
  ], MessageTemplate.prototype, "createdAt", 2);
11391
12193
  __decorateClass([
11392
- Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12194
+ Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11393
12195
  ], MessageTemplate.prototype, "updatedAt", 2);
11394
12196
  __decorateClass([
11395
- Column26({ type: "timestamp", nullable: true })
12197
+ Column28({ type: "timestamp", nullable: true })
11396
12198
  ], MessageTemplate.prototype, "deletedAt", 2);
11397
12199
  __decorateClass([
11398
- Column26("boolean", { default: false })
12200
+ Column28("boolean", { default: false })
11399
12201
  ], MessageTemplate.prototype, "deleted", 2);
11400
12202
  __decorateClass([
11401
- Column26("int", { nullable: true })
12203
+ Column28("int", { nullable: true })
11402
12204
  ], MessageTemplate.prototype, "createdBy", 2);
11403
12205
  __decorateClass([
11404
- Column26("int", { nullable: true })
12206
+ Column28("int", { nullable: true })
11405
12207
  ], MessageTemplate.prototype, "updatedBy", 2);
11406
12208
  __decorateClass([
11407
- Column26("int", { nullable: true })
12209
+ Column28("int", { nullable: true })
11408
12210
  ], MessageTemplate.prototype, "deletedBy", 2);
11409
12211
  MessageTemplate = __decorateClass([
11410
- Entity26("message_templates")
12212
+ Entity28("message_templates")
11411
12213
  ], MessageTemplate);
11412
12214
 
11413
12215
  // src/entities/media.entity.ts
11414
- import { Entity as Entity27, PrimaryGeneratedColumn as PrimaryGeneratedColumn27, Column as Column27, ManyToOne as ManyToOne15, OneToMany as OneToMany12, JoinColumn as JoinColumn15 } from "typeorm";
12216
+ import { Entity as Entity29, PrimaryGeneratedColumn as PrimaryGeneratedColumn29, Column as Column29, ManyToOne as ManyToOne17, OneToMany as OneToMany12, JoinColumn as JoinColumn17 } from "typeorm";
11415
12217
  var Media = class {
11416
12218
  id;
11417
12219
  kind;
@@ -11430,57 +12232,57 @@ var Media = class {
11430
12232
  deleted;
11431
12233
  };
11432
12234
  __decorateClass([
11433
- PrimaryGeneratedColumn27()
12235
+ PrimaryGeneratedColumn29()
11434
12236
  ], Media.prototype, "id", 2);
11435
12237
  __decorateClass([
11436
- Column27({ type: "varchar", length: 16, default: "file" })
12238
+ Column29({ type: "varchar", length: 16, default: "file" })
11437
12239
  ], Media.prototype, "kind", 2);
11438
12240
  __decorateClass([
11439
- Column27({ type: "int", nullable: true })
12241
+ Column29({ type: "int", nullable: true })
11440
12242
  ], Media.prototype, "parentId", 2);
11441
12243
  __decorateClass([
11442
- ManyToOne15(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
11443
- JoinColumn15({ name: "parentId" })
12244
+ ManyToOne17(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
12245
+ JoinColumn17({ name: "parentId" })
11444
12246
  ], Media.prototype, "parent", 2);
11445
12247
  __decorateClass([
11446
12248
  OneToMany12(() => Media, (m) => m.parent)
11447
12249
  ], Media.prototype, "children", 2);
11448
12250
  __decorateClass([
11449
- Column27("varchar")
12251
+ Column29("varchar")
11450
12252
  ], Media.prototype, "filename", 2);
11451
12253
  __decorateClass([
11452
- Column27("varchar", { nullable: true })
12254
+ Column29("varchar", { nullable: true })
11453
12255
  ], Media.prototype, "url", 2);
11454
12256
  __decorateClass([
11455
- Column27("varchar", { nullable: true })
12257
+ Column29("varchar", { nullable: true })
11456
12258
  ], Media.prototype, "mimeType", 2);
11457
12259
  __decorateClass([
11458
- Column27("int", { default: 0 })
12260
+ Column29("int", { default: 0 })
11459
12261
  ], Media.prototype, "size", 2);
11460
12262
  __decorateClass([
11461
- Column27("varchar", { nullable: true })
12263
+ Column29("varchar", { nullable: true })
11462
12264
  ], Media.prototype, "alt", 2);
11463
12265
  __decorateClass([
11464
- Column27("boolean", { default: false })
12266
+ Column29("boolean", { default: false })
11465
12267
  ], Media.prototype, "isPublic", 2);
11466
12268
  __decorateClass([
11467
- Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12269
+ Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11468
12270
  ], Media.prototype, "createdAt", 2);
11469
12271
  __decorateClass([
11470
- Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12272
+ Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11471
12273
  ], Media.prototype, "updatedAt", 2);
11472
12274
  __decorateClass([
11473
- Column27({ type: "timestamp", nullable: true })
12275
+ Column29({ type: "timestamp", nullable: true })
11474
12276
  ], Media.prototype, "deletedAt", 2);
11475
12277
  __decorateClass([
11476
- Column27("boolean", { default: false })
12278
+ Column29("boolean", { default: false })
11477
12279
  ], Media.prototype, "deleted", 2);
11478
12280
  Media = __decorateClass([
11479
- Entity27("media")
12281
+ Entity29("media")
11480
12282
  ], Media);
11481
12283
 
11482
12284
  // src/entities/page.entity.ts
11483
- import { Entity as Entity28, PrimaryGeneratedColumn as PrimaryGeneratedColumn28, Column as Column28, ManyToOne as ManyToOne16, JoinColumn as JoinColumn16 } from "typeorm";
12285
+ import { Entity as Entity30, PrimaryGeneratedColumn as PrimaryGeneratedColumn30, Column as Column30, ManyToOne as ManyToOne18, JoinColumn as JoinColumn18 } from "typeorm";
11484
12286
  var Page = class {
11485
12287
  id;
11486
12288
  title;
@@ -11501,64 +12303,64 @@ var Page = class {
11501
12303
  deletedBy;
11502
12304
  };
11503
12305
  __decorateClass([
11504
- PrimaryGeneratedColumn28()
12306
+ PrimaryGeneratedColumn30()
11505
12307
  ], Page.prototype, "id", 2);
11506
12308
  __decorateClass([
11507
- Column28("varchar")
12309
+ Column30("varchar")
11508
12310
  ], Page.prototype, "title", 2);
11509
12311
  __decorateClass([
11510
- Column28("varchar", { unique: true })
12312
+ Column30("varchar", { unique: true })
11511
12313
  ], Page.prototype, "slug", 2);
11512
12314
  __decorateClass([
11513
- Column28({ type: "jsonb", default: {} })
12315
+ Column30({ type: "jsonb", default: {} })
11514
12316
  ], Page.prototype, "content", 2);
11515
12317
  __decorateClass([
11516
- Column28("boolean", { default: false })
12318
+ Column30("boolean", { default: false })
11517
12319
  ], Page.prototype, "published", 2);
11518
12320
  __decorateClass([
11519
- Column28("varchar", { default: "default" })
12321
+ Column30("varchar", { default: "default" })
11520
12322
  ], Page.prototype, "theme", 2);
11521
12323
  __decorateClass([
11522
- Column28("int", { nullable: true })
12324
+ Column30("int", { nullable: true })
11523
12325
  ], Page.prototype, "parentId", 2);
11524
12326
  __decorateClass([
11525
- ManyToOne16(() => Page, { onDelete: "SET NULL" }),
11526
- JoinColumn16({ name: "parentId" })
12327
+ ManyToOne18(() => Page, { onDelete: "SET NULL" }),
12328
+ JoinColumn18({ name: "parentId" })
11527
12329
  ], Page.prototype, "parent", 2);
11528
12330
  __decorateClass([
11529
- Column28("int", { nullable: true })
12331
+ Column30("int", { nullable: true })
11530
12332
  ], Page.prototype, "seoId", 2);
11531
12333
  __decorateClass([
11532
- ManyToOne16(() => Seo, { onDelete: "SET NULL" }),
11533
- JoinColumn16({ name: "seoId" })
12334
+ ManyToOne18(() => Seo, { onDelete: "SET NULL" }),
12335
+ JoinColumn18({ name: "seoId" })
11534
12336
  ], Page.prototype, "seo", 2);
11535
12337
  __decorateClass([
11536
- Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12338
+ Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11537
12339
  ], Page.prototype, "createdAt", 2);
11538
12340
  __decorateClass([
11539
- Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12341
+ Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11540
12342
  ], Page.prototype, "updatedAt", 2);
11541
12343
  __decorateClass([
11542
- Column28({ type: "timestamp", nullable: true })
12344
+ Column30({ type: "timestamp", nullable: true })
11543
12345
  ], Page.prototype, "deletedAt", 2);
11544
12346
  __decorateClass([
11545
- Column28("boolean", { default: false })
12347
+ Column30("boolean", { default: false })
11546
12348
  ], Page.prototype, "deleted", 2);
11547
12349
  __decorateClass([
11548
- Column28("int", { nullable: true })
12350
+ Column30("int", { nullable: true })
11549
12351
  ], Page.prototype, "createdBy", 2);
11550
12352
  __decorateClass([
11551
- Column28("int", { nullable: true })
12353
+ Column30("int", { nullable: true })
11552
12354
  ], Page.prototype, "updatedBy", 2);
11553
12355
  __decorateClass([
11554
- Column28("int", { nullable: true })
12356
+ Column30("int", { nullable: true })
11555
12357
  ], Page.prototype, "deletedBy", 2);
11556
12358
  Page = __decorateClass([
11557
- Entity28("pages")
12359
+ Entity30("pages")
11558
12360
  ], Page);
11559
12361
 
11560
12362
  // src/entities/product-category.entity.ts
11561
- import { Entity as Entity29, PrimaryGeneratedColumn as PrimaryGeneratedColumn29, Column as Column29, ManyToOne as ManyToOne17, OneToMany as OneToMany13, JoinColumn as JoinColumn17, Unique as Unique3 } from "typeorm";
12363
+ import { Entity as Entity31, PrimaryGeneratedColumn as PrimaryGeneratedColumn31, Column as Column31, ManyToOne as ManyToOne19, OneToMany as OneToMany13, JoinColumn as JoinColumn19, Unique as Unique3 } from "typeorm";
11562
12364
  var ProductCategory = class {
11563
12365
  id;
11564
12366
  vendorId;
@@ -11584,63 +12386,63 @@ var ProductCategory = class {
11584
12386
  collections;
11585
12387
  };
11586
12388
  __decorateClass([
11587
- PrimaryGeneratedColumn29()
12389
+ PrimaryGeneratedColumn31()
11588
12390
  ], ProductCategory.prototype, "id", 2);
11589
12391
  __decorateClass([
11590
- Column29("int")
12392
+ Column31("int")
11591
12393
  ], ProductCategory.prototype, "vendorId", 2);
11592
12394
  __decorateClass([
11593
- Column29("varchar")
12395
+ Column31("varchar")
11594
12396
  ], ProductCategory.prototype, "name", 2);
11595
12397
  __decorateClass([
11596
- Column29("varchar")
12398
+ Column31("varchar")
11597
12399
  ], ProductCategory.prototype, "slug", 2);
11598
12400
  __decorateClass([
11599
- Column29("int", { nullable: true })
12401
+ Column31("int", { nullable: true })
11600
12402
  ], ProductCategory.prototype, "parentId", 2);
11601
12403
  __decorateClass([
11602
- Column29("varchar", { nullable: true })
12404
+ Column31("varchar", { nullable: true })
11603
12405
  ], ProductCategory.prototype, "image", 2);
11604
12406
  __decorateClass([
11605
- Column29("text", { nullable: true })
12407
+ Column31("text", { nullable: true })
11606
12408
  ], ProductCategory.prototype, "description", 2);
11607
12409
  __decorateClass([
11608
- Column29("jsonb", { nullable: true })
12410
+ Column31("jsonb", { nullable: true })
11609
12411
  ], ProductCategory.prototype, "metadata", 2);
11610
12412
  __decorateClass([
11611
- Column29("boolean", { default: true })
12413
+ Column31("boolean", { default: true })
11612
12414
  ], ProductCategory.prototype, "active", 2);
11613
12415
  __decorateClass([
11614
- Column29("int", { default: 0 })
12416
+ Column31("int", { default: 0 })
11615
12417
  ], ProductCategory.prototype, "sortOrder", 2);
11616
12418
  __decorateClass([
11617
- Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12419
+ Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11618
12420
  ], ProductCategory.prototype, "createdAt", 2);
11619
12421
  __decorateClass([
11620
- Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12422
+ Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11621
12423
  ], ProductCategory.prototype, "updatedAt", 2);
11622
12424
  __decorateClass([
11623
- Column29({ type: "timestamp", nullable: true })
12425
+ Column31({ type: "timestamp", nullable: true })
11624
12426
  ], ProductCategory.prototype, "deletedAt", 2);
11625
12427
  __decorateClass([
11626
- Column29("boolean", { default: false })
12428
+ Column31("boolean", { default: false })
11627
12429
  ], ProductCategory.prototype, "deleted", 2);
11628
12430
  __decorateClass([
11629
- Column29("int", { nullable: true })
12431
+ Column31("int", { nullable: true })
11630
12432
  ], ProductCategory.prototype, "createdBy", 2);
11631
12433
  __decorateClass([
11632
- Column29("int", { nullable: true })
12434
+ Column31("int", { nullable: true })
11633
12435
  ], ProductCategory.prototype, "updatedBy", 2);
11634
12436
  __decorateClass([
11635
- Column29("int", { nullable: true })
12437
+ Column31("int", { nullable: true })
11636
12438
  ], ProductCategory.prototype, "deletedBy", 2);
11637
12439
  __decorateClass([
11638
- ManyToOne17(() => Vendor, { onDelete: "RESTRICT" }),
11639
- JoinColumn17({ name: "vendorId" })
12440
+ ManyToOne19(() => Vendor, { onDelete: "RESTRICT" }),
12441
+ JoinColumn19({ name: "vendorId" })
11640
12442
  ], ProductCategory.prototype, "vendor", 2);
11641
12443
  __decorateClass([
11642
- ManyToOne17(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
11643
- JoinColumn17({ name: "parentId" })
12444
+ ManyToOne19(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
12445
+ JoinColumn19({ name: "parentId" })
11644
12446
  ], ProductCategory.prototype, "parent", 2);
11645
12447
  __decorateClass([
11646
12448
  OneToMany13(() => ProductCategory, (c) => c.parent)
@@ -11652,15 +12454,15 @@ __decorateClass([
11652
12454
  OneToMany13("Collection", "category")
11653
12455
  ], ProductCategory.prototype, "collections", 2);
11654
12456
  ProductCategory = __decorateClass([
11655
- Entity29("product_categories"),
12457
+ Entity31("product_categories"),
11656
12458
  Unique3("UQ_product_categories_vendor_slug", ["vendorId", "slug"])
11657
12459
  ], ProductCategory);
11658
12460
 
11659
12461
  // src/entities/collection.entity.ts
11660
- import { Entity as Entity31, PrimaryGeneratedColumn as PrimaryGeneratedColumn31, Column as Column31, ManyToOne as ManyToOne19, OneToMany as OneToMany15, JoinColumn as JoinColumn19, Unique as Unique5 } from "typeorm";
12462
+ import { Entity as Entity33, PrimaryGeneratedColumn as PrimaryGeneratedColumn33, Column as Column33, ManyToOne as ManyToOne21, OneToMany as OneToMany15, JoinColumn as JoinColumn21, Unique as Unique5 } from "typeorm";
11661
12463
 
11662
12464
  // src/entities/brand.entity.ts
11663
- import { Entity as Entity30, PrimaryGeneratedColumn as PrimaryGeneratedColumn30, Column as Column30, OneToMany as OneToMany14, ManyToOne as ManyToOne18, JoinColumn as JoinColumn18, Unique as Unique4 } from "typeorm";
12465
+ import { Entity as Entity32, PrimaryGeneratedColumn as PrimaryGeneratedColumn32, Column as Column32, OneToMany as OneToMany14, ManyToOne as ManyToOne20, JoinColumn as JoinColumn20, Unique as Unique4 } from "typeorm";
11664
12466
  var Brand = class {
11665
12467
  id;
11666
12468
  vendorId;
@@ -11685,63 +12487,63 @@ var Brand = class {
11685
12487
  collections;
11686
12488
  };
11687
12489
  __decorateClass([
11688
- PrimaryGeneratedColumn30()
12490
+ PrimaryGeneratedColumn32()
11689
12491
  ], Brand.prototype, "id", 2);
11690
12492
  __decorateClass([
11691
- Column30("int")
12493
+ Column32("int")
11692
12494
  ], Brand.prototype, "vendorId", 2);
11693
12495
  __decorateClass([
11694
- Column30("varchar")
12496
+ Column32("varchar")
11695
12497
  ], Brand.prototype, "name", 2);
11696
12498
  __decorateClass([
11697
- Column30("varchar")
12499
+ Column32("varchar")
11698
12500
  ], Brand.prototype, "slug", 2);
11699
12501
  __decorateClass([
11700
- Column30("varchar", { nullable: true })
12502
+ Column32("varchar", { nullable: true })
11701
12503
  ], Brand.prototype, "logo", 2);
11702
12504
  __decorateClass([
11703
- Column30("jsonb", { nullable: true })
12505
+ Column32("jsonb", { nullable: true })
11704
12506
  ], Brand.prototype, "metadata", 2);
11705
12507
  __decorateClass([
11706
- Column30("text", { nullable: true })
12508
+ Column32("text", { nullable: true })
11707
12509
  ], Brand.prototype, "description", 2);
11708
12510
  __decorateClass([
11709
- Column30("boolean", { default: true })
12511
+ Column32("boolean", { default: true })
11710
12512
  ], Brand.prototype, "active", 2);
11711
12513
  __decorateClass([
11712
- Column30("int", { default: 0 })
12514
+ Column32("int", { default: 0 })
11713
12515
  ], Brand.prototype, "sortOrder", 2);
11714
12516
  __decorateClass([
11715
- Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12517
+ Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11716
12518
  ], Brand.prototype, "createdAt", 2);
11717
12519
  __decorateClass([
11718
- Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12520
+ Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11719
12521
  ], Brand.prototype, "updatedAt", 2);
11720
12522
  __decorateClass([
11721
- Column30({ type: "timestamp", nullable: true })
12523
+ Column32({ type: "timestamp", nullable: true })
11722
12524
  ], Brand.prototype, "deletedAt", 2);
11723
12525
  __decorateClass([
11724
- Column30("boolean", { default: false })
12526
+ Column32("boolean", { default: false })
11725
12527
  ], Brand.prototype, "deleted", 2);
11726
12528
  __decorateClass([
11727
- Column30("int", { nullable: true })
12529
+ Column32("int", { nullable: true })
11728
12530
  ], Brand.prototype, "createdBy", 2);
11729
12531
  __decorateClass([
11730
- Column30("int", { nullable: true })
12532
+ Column32("int", { nullable: true })
11731
12533
  ], Brand.prototype, "updatedBy", 2);
11732
12534
  __decorateClass([
11733
- Column30("int", { nullable: true })
12535
+ Column32("int", { nullable: true })
11734
12536
  ], Brand.prototype, "deletedBy", 2);
11735
12537
  __decorateClass([
11736
- Column30("int", { nullable: true })
12538
+ Column32("int", { nullable: true })
11737
12539
  ], Brand.prototype, "seoId", 2);
11738
12540
  __decorateClass([
11739
- ManyToOne18(() => Vendor, { onDelete: "RESTRICT" }),
11740
- JoinColumn18({ name: "vendorId" })
12541
+ ManyToOne20(() => Vendor, { onDelete: "RESTRICT" }),
12542
+ JoinColumn20({ name: "vendorId" })
11741
12543
  ], Brand.prototype, "vendor", 2);
11742
12544
  __decorateClass([
11743
- ManyToOne18(() => Seo, { onDelete: "SET NULL" }),
11744
- JoinColumn18({ name: "seoId" })
12545
+ ManyToOne20(() => Seo, { onDelete: "SET NULL" }),
12546
+ JoinColumn20({ name: "seoId" })
11745
12547
  ], Brand.prototype, "seo", 2);
11746
12548
  __decorateClass([
11747
12549
  OneToMany14("Product", "brand")
@@ -11750,7 +12552,7 @@ __decorateClass([
11750
12552
  OneToMany14("Collection", "brand")
11751
12553
  ], Brand.prototype, "collections", 2);
11752
12554
  Brand = __decorateClass([
11753
- Entity30("brands"),
12555
+ Entity32("brands"),
11754
12556
  Unique4("UQ_brands_vendor_slug", ["vendorId", "slug"])
11755
12557
  ], Brand);
11756
12558
 
@@ -11784,94 +12586,94 @@ var Collection = class {
11784
12586
  products;
11785
12587
  };
11786
12588
  __decorateClass([
11787
- PrimaryGeneratedColumn31()
12589
+ PrimaryGeneratedColumn33()
11788
12590
  ], Collection.prototype, "id", 2);
11789
12591
  __decorateClass([
11790
- Column31("int")
12592
+ Column33("int")
11791
12593
  ], Collection.prototype, "vendorId", 2);
11792
12594
  __decorateClass([
11793
- Column31("int", { nullable: true })
12595
+ Column33("int", { nullable: true })
11794
12596
  ], Collection.prototype, "categoryId", 2);
11795
12597
  __decorateClass([
11796
- Column31("int", { nullable: true })
12598
+ Column33("int", { nullable: true })
11797
12599
  ], Collection.prototype, "brandId", 2);
11798
12600
  __decorateClass([
11799
- Column31("varchar")
12601
+ Column33("varchar")
11800
12602
  ], Collection.prototype, "name", 2);
11801
12603
  __decorateClass([
11802
- Column31("varchar")
12604
+ Column33("varchar")
11803
12605
  ], Collection.prototype, "slug", 2);
11804
12606
  __decorateClass([
11805
- Column31("varchar", { nullable: true })
12607
+ Column33("varchar", { nullable: true })
11806
12608
  ], Collection.prototype, "hsn", 2);
11807
12609
  __decorateClass([
11808
- Column31("text", { nullable: true })
12610
+ Column33("text", { nullable: true })
11809
12611
  ], Collection.prototype, "description", 2);
11810
12612
  __decorateClass([
11811
- Column31("varchar", { nullable: true })
12613
+ Column33("varchar", { nullable: true })
11812
12614
  ], Collection.prototype, "image", 2);
11813
12615
  __decorateClass([
11814
- Column31("jsonb", { nullable: true })
12616
+ Column33("jsonb", { nullable: true })
11815
12617
  ], Collection.prototype, "metadata", 2);
11816
12618
  __decorateClass([
11817
- Column31("jsonb", { nullable: true })
12619
+ Column33("jsonb", { nullable: true })
11818
12620
  ], Collection.prototype, "variants", 2);
11819
12621
  __decorateClass([
11820
- Column31("boolean", { default: true })
12622
+ Column33("boolean", { default: true })
11821
12623
  ], Collection.prototype, "active", 2);
11822
12624
  __decorateClass([
11823
- Column31("int", { default: 0 })
12625
+ Column33("int", { default: 0 })
11824
12626
  ], Collection.prototype, "sortOrder", 2);
11825
12627
  __decorateClass([
11826
- Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12628
+ Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11827
12629
  ], Collection.prototype, "createdAt", 2);
11828
12630
  __decorateClass([
11829
- Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12631
+ Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11830
12632
  ], Collection.prototype, "updatedAt", 2);
11831
12633
  __decorateClass([
11832
- Column31({ type: "timestamp", nullable: true })
12634
+ Column33({ type: "timestamp", nullable: true })
11833
12635
  ], Collection.prototype, "deletedAt", 2);
11834
12636
  __decorateClass([
11835
- Column31("boolean", { default: false })
12637
+ Column33("boolean", { default: false })
11836
12638
  ], Collection.prototype, "deleted", 2);
11837
12639
  __decorateClass([
11838
- Column31("int", { nullable: true })
12640
+ Column33("int", { nullable: true })
11839
12641
  ], Collection.prototype, "createdBy", 2);
11840
12642
  __decorateClass([
11841
- Column31("int", { nullable: true })
12643
+ Column33("int", { nullable: true })
11842
12644
  ], Collection.prototype, "updatedBy", 2);
11843
12645
  __decorateClass([
11844
- Column31("int", { nullable: true })
12646
+ Column33("int", { nullable: true })
11845
12647
  ], Collection.prototype, "deletedBy", 2);
11846
12648
  __decorateClass([
11847
- Column31("int", { nullable: true })
12649
+ Column33("int", { nullable: true })
11848
12650
  ], Collection.prototype, "seoId", 2);
11849
12651
  __decorateClass([
11850
- ManyToOne19(() => Vendor, { onDelete: "RESTRICT" }),
11851
- JoinColumn19({ name: "vendorId" })
12652
+ ManyToOne21(() => Vendor, { onDelete: "RESTRICT" }),
12653
+ JoinColumn21({ name: "vendorId" })
11852
12654
  ], Collection.prototype, "vendor", 2);
11853
12655
  __decorateClass([
11854
- ManyToOne19(() => Seo, { onDelete: "SET NULL" }),
11855
- JoinColumn19({ name: "seoId" })
12656
+ ManyToOne21(() => Seo, { onDelete: "SET NULL" }),
12657
+ JoinColumn21({ name: "seoId" })
11856
12658
  ], Collection.prototype, "seo", 2);
11857
12659
  __decorateClass([
11858
- ManyToOne19(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
11859
- JoinColumn19({ name: "categoryId" })
12660
+ ManyToOne21(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
12661
+ JoinColumn21({ name: "categoryId" })
11860
12662
  ], Collection.prototype, "category", 2);
11861
12663
  __decorateClass([
11862
- ManyToOne19(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
11863
- JoinColumn19({ name: "brandId" })
12664
+ ManyToOne21(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
12665
+ JoinColumn21({ name: "brandId" })
11864
12666
  ], Collection.prototype, "brand", 2);
11865
12667
  __decorateClass([
11866
12668
  OneToMany15("Product", "collection")
11867
12669
  ], Collection.prototype, "products", 2);
11868
12670
  Collection = __decorateClass([
11869
- Entity31("collections"),
12671
+ Entity33("collections"),
11870
12672
  Unique5("UQ_collections_vendor_slug", ["vendorId", "slug"])
11871
12673
  ], Collection);
11872
12674
 
11873
12675
  // src/entities/product.entity.ts
11874
- import { Entity as Entity32, PrimaryGeneratedColumn as PrimaryGeneratedColumn32, Column as Column32, ManyToOne as ManyToOne20, OneToMany as OneToMany16, JoinColumn as JoinColumn20, Unique as Unique6 } from "typeorm";
12676
+ import { Entity as Entity34, PrimaryGeneratedColumn as PrimaryGeneratedColumn34, Column as Column34, ManyToOne as ManyToOne22, OneToMany as OneToMany16, JoinColumn as JoinColumn22, Unique as Unique6 } from "typeorm";
11875
12677
  var Product = class {
11876
12678
  id;
11877
12679
  vendorId;
@@ -11907,99 +12709,99 @@ var Product = class {
11907
12709
  taxes;
11908
12710
  };
11909
12711
  __decorateClass([
11910
- PrimaryGeneratedColumn32()
12712
+ PrimaryGeneratedColumn34()
11911
12713
  ], Product.prototype, "id", 2);
11912
12714
  __decorateClass([
11913
- Column32("int")
12715
+ Column34("int")
11914
12716
  ], Product.prototype, "vendorId", 2);
11915
12717
  __decorateClass([
11916
- Column32("int", { nullable: true })
12718
+ Column34("int", { nullable: true })
11917
12719
  ], Product.prototype, "collectionId", 2);
11918
12720
  __decorateClass([
11919
- Column32("int", { nullable: true })
12721
+ Column34("int", { nullable: true })
11920
12722
  ], Product.prototype, "brandId", 2);
11921
12723
  __decorateClass([
11922
- Column32("int", { nullable: true })
12724
+ Column34("int", { nullable: true })
11923
12725
  ], Product.prototype, "categoryId", 2);
11924
12726
  __decorateClass([
11925
- Column32("varchar", { nullable: true })
12727
+ Column34("varchar", { nullable: true })
11926
12728
  ], Product.prototype, "sku", 2);
11927
12729
  __decorateClass([
11928
- Column32("varchar", { nullable: true })
12730
+ Column34("varchar", { nullable: true })
11929
12731
  ], Product.prototype, "hsn", 2);
11930
12732
  __decorateClass([
11931
- Column32("varchar", { nullable: true })
12733
+ Column34("varchar", { nullable: true })
11932
12734
  ], Product.prototype, "uom", 2);
11933
12735
  __decorateClass([
11934
- Column32("varchar", { default: "product" })
12736
+ Column34("varchar", { default: "product" })
11935
12737
  ], Product.prototype, "type", 2);
11936
12738
  __decorateClass([
11937
- Column32("varchar", { nullable: true })
12739
+ Column34("varchar", { nullable: true })
11938
12740
  ], Product.prototype, "slug", 2);
11939
12741
  __decorateClass([
11940
- Column32("varchar", { nullable: true })
12742
+ Column34("varchar", { nullable: true })
11941
12743
  ], Product.prototype, "name", 2);
11942
12744
  __decorateClass([
11943
- Column32("decimal", { precision: 12, scale: 2 })
12745
+ Column34("decimal", { precision: 12, scale: 2 })
11944
12746
  ], Product.prototype, "price", 2);
11945
12747
  __decorateClass([
11946
- Column32("decimal", { precision: 12, scale: 2, nullable: true })
12748
+ Column34("decimal", { precision: 12, scale: 2, nullable: true })
11947
12749
  ], Product.prototype, "compareAtPrice", 2);
11948
12750
  __decorateClass([
11949
- Column32("int", { default: 0 })
12751
+ Column34("int", { default: 0 })
11950
12752
  ], Product.prototype, "quantity", 2);
11951
12753
  __decorateClass([
11952
- Column32("varchar", { default: "draft" })
12754
+ Column34("varchar", { default: "draft" })
11953
12755
  ], Product.prototype, "status", 2);
11954
12756
  __decorateClass([
11955
- Column32("boolean", { default: false })
12757
+ Column34("boolean", { default: false })
11956
12758
  ], Product.prototype, "featured", 2);
11957
12759
  __decorateClass([
11958
- Column32("jsonb", { nullable: true })
12760
+ Column34("jsonb", { nullable: true })
11959
12761
  ], Product.prototype, "metadata", 2);
11960
12762
  __decorateClass([
11961
- Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12763
+ Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11962
12764
  ], Product.prototype, "createdAt", 2);
11963
12765
  __decorateClass([
11964
- Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12766
+ Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
11965
12767
  ], Product.prototype, "updatedAt", 2);
11966
12768
  __decorateClass([
11967
- Column32({ type: "timestamp", nullable: true })
12769
+ Column34({ type: "timestamp", nullable: true })
11968
12770
  ], Product.prototype, "deletedAt", 2);
11969
12771
  __decorateClass([
11970
- Column32("boolean", { default: false })
12772
+ Column34("boolean", { default: false })
11971
12773
  ], Product.prototype, "deleted", 2);
11972
12774
  __decorateClass([
11973
- Column32("int", { nullable: true })
12775
+ Column34("int", { nullable: true })
11974
12776
  ], Product.prototype, "createdBy", 2);
11975
12777
  __decorateClass([
11976
- Column32("int", { nullable: true })
12778
+ Column34("int", { nullable: true })
11977
12779
  ], Product.prototype, "updatedBy", 2);
11978
12780
  __decorateClass([
11979
- Column32("int", { nullable: true })
12781
+ Column34("int", { nullable: true })
11980
12782
  ], Product.prototype, "deletedBy", 2);
11981
12783
  __decorateClass([
11982
- Column32("int", { nullable: true })
12784
+ Column34("int", { nullable: true })
11983
12785
  ], Product.prototype, "seoId", 2);
11984
12786
  __decorateClass([
11985
- ManyToOne20(() => Vendor, { onDelete: "RESTRICT" }),
11986
- JoinColumn20({ name: "vendorId" })
12787
+ ManyToOne22(() => Vendor, { onDelete: "RESTRICT" }),
12788
+ JoinColumn22({ name: "vendorId" })
11987
12789
  ], Product.prototype, "vendor", 2);
11988
12790
  __decorateClass([
11989
- ManyToOne20(() => Seo, { onDelete: "SET NULL" }),
11990
- JoinColumn20({ name: "seoId" })
12791
+ ManyToOne22(() => Seo, { onDelete: "SET NULL" }),
12792
+ JoinColumn22({ name: "seoId" })
11991
12793
  ], Product.prototype, "seo", 2);
11992
12794
  __decorateClass([
11993
- ManyToOne20(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
11994
- JoinColumn20({ name: "collectionId" })
12795
+ ManyToOne22(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
12796
+ JoinColumn22({ name: "collectionId" })
11995
12797
  ], Product.prototype, "collection", 2);
11996
12798
  __decorateClass([
11997
- ManyToOne20(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
11998
- JoinColumn20({ name: "brandId" })
12799
+ ManyToOne22(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
12800
+ JoinColumn22({ name: "brandId" })
11999
12801
  ], Product.prototype, "brand", 2);
12000
12802
  __decorateClass([
12001
- ManyToOne20(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
12002
- JoinColumn20({ name: "categoryId" })
12803
+ ManyToOne22(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
12804
+ JoinColumn22({ name: "categoryId" })
12003
12805
  ], Product.prototype, "category", 2);
12004
12806
  __decorateClass([
12005
12807
  OneToMany16("ProductAttribute", "product")
@@ -12008,12 +12810,12 @@ __decorateClass([
12008
12810
  OneToMany16("ProductTax", "product")
12009
12811
  ], Product.prototype, "taxes", 2);
12010
12812
  Product = __decorateClass([
12011
- Entity32("products"),
12813
+ Entity34("products"),
12012
12814
  Unique6("UQ_products_vendor_slug", ["vendorId", "slug"])
12013
12815
  ], Product);
12014
12816
 
12015
12817
  // src/entities/attribute.entity.ts
12016
- import { Entity as Entity33, PrimaryGeneratedColumn as PrimaryGeneratedColumn33, Column as Column33, ManyToOne as ManyToOne21, JoinColumn as JoinColumn21, Unique as Unique7 } from "typeorm";
12818
+ import { Entity as Entity35, PrimaryGeneratedColumn as PrimaryGeneratedColumn35, Column as Column35, ManyToOne as ManyToOne23, JoinColumn as JoinColumn23, Unique as Unique7 } from "typeorm";
12017
12819
  var Attribute = class {
12018
12820
  id;
12019
12821
  vendorId;
@@ -12034,64 +12836,64 @@ var Attribute = class {
12034
12836
  vendor;
12035
12837
  };
12036
12838
  __decorateClass([
12037
- PrimaryGeneratedColumn33()
12839
+ PrimaryGeneratedColumn35()
12038
12840
  ], Attribute.prototype, "id", 2);
12039
12841
  __decorateClass([
12040
- Column33("int")
12842
+ Column35("int")
12041
12843
  ], Attribute.prototype, "vendorId", 2);
12042
12844
  __decorateClass([
12043
- Column33("varchar")
12845
+ Column35("varchar")
12044
12846
  ], Attribute.prototype, "name", 2);
12045
12847
  __decorateClass([
12046
- Column33("varchar")
12848
+ Column35("varchar")
12047
12849
  ], Attribute.prototype, "slug", 2);
12048
12850
  __decorateClass([
12049
- Column33("varchar", { default: "text" })
12851
+ Column35("varchar", { default: "text" })
12050
12852
  ], Attribute.prototype, "type", 2);
12051
12853
  __decorateClass([
12052
- Column33("jsonb", { nullable: true })
12854
+ Column35("jsonb", { nullable: true })
12053
12855
  ], Attribute.prototype, "options", 2);
12054
12856
  __decorateClass([
12055
- Column33("jsonb", { nullable: true })
12857
+ Column35("jsonb", { nullable: true })
12056
12858
  ], Attribute.prototype, "metadata", 2);
12057
12859
  __decorateClass([
12058
- Column33("boolean", { default: true })
12860
+ Column35("boolean", { default: true })
12059
12861
  ], Attribute.prototype, "active", 2);
12060
12862
  __decorateClass([
12061
- Column33("int", { default: 0 })
12863
+ Column35("int", { default: 0 })
12062
12864
  ], Attribute.prototype, "sortOrder", 2);
12063
12865
  __decorateClass([
12064
- Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12866
+ Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12065
12867
  ], Attribute.prototype, "createdAt", 2);
12066
12868
  __decorateClass([
12067
- Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12869
+ Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12068
12870
  ], Attribute.prototype, "updatedAt", 2);
12069
12871
  __decorateClass([
12070
- Column33({ type: "timestamp", nullable: true })
12872
+ Column35({ type: "timestamp", nullable: true })
12071
12873
  ], Attribute.prototype, "deletedAt", 2);
12072
12874
  __decorateClass([
12073
- Column33("boolean", { default: false })
12875
+ Column35("boolean", { default: false })
12074
12876
  ], Attribute.prototype, "deleted", 2);
12075
12877
  __decorateClass([
12076
- Column33("int", { nullable: true })
12878
+ Column35("int", { nullable: true })
12077
12879
  ], Attribute.prototype, "createdBy", 2);
12078
12880
  __decorateClass([
12079
- Column33("int", { nullable: true })
12881
+ Column35("int", { nullable: true })
12080
12882
  ], Attribute.prototype, "updatedBy", 2);
12081
12883
  __decorateClass([
12082
- Column33("int", { nullable: true })
12884
+ Column35("int", { nullable: true })
12083
12885
  ], Attribute.prototype, "deletedBy", 2);
12084
12886
  __decorateClass([
12085
- ManyToOne21(() => Vendor, { onDelete: "RESTRICT" }),
12086
- JoinColumn21({ name: "vendorId" })
12887
+ ManyToOne23(() => Vendor, { onDelete: "RESTRICT" }),
12888
+ JoinColumn23({ name: "vendorId" })
12087
12889
  ], Attribute.prototype, "vendor", 2);
12088
12890
  Attribute = __decorateClass([
12089
- Entity33("attributes"),
12891
+ Entity35("attributes"),
12090
12892
  Unique7("UQ_attributes_vendor_slug", ["vendorId", "slug"])
12091
12893
  ], Attribute);
12092
12894
 
12093
12895
  // src/entities/product-attribute.entity.ts
12094
- import { Entity as Entity34, PrimaryGeneratedColumn as PrimaryGeneratedColumn34, Column as Column34, ManyToOne as ManyToOne22, JoinColumn as JoinColumn22 } from "typeorm";
12896
+ import { Entity as Entity36, PrimaryGeneratedColumn as PrimaryGeneratedColumn36, Column as Column36, ManyToOne as ManyToOne24, JoinColumn as JoinColumn24 } from "typeorm";
12095
12897
  var ProductAttribute = class {
12096
12898
  id;
12097
12899
  productId;
@@ -12104,40 +12906,40 @@ var ProductAttribute = class {
12104
12906
  attribute;
12105
12907
  };
12106
12908
  __decorateClass([
12107
- PrimaryGeneratedColumn34()
12909
+ PrimaryGeneratedColumn36()
12108
12910
  ], ProductAttribute.prototype, "id", 2);
12109
12911
  __decorateClass([
12110
- Column34("int")
12912
+ Column36("int")
12111
12913
  ], ProductAttribute.prototype, "productId", 2);
12112
12914
  __decorateClass([
12113
- Column34("int")
12915
+ Column36("int")
12114
12916
  ], ProductAttribute.prototype, "attributeId", 2);
12115
12917
  __decorateClass([
12116
- Column34("varchar")
12918
+ Column36("varchar")
12117
12919
  ], ProductAttribute.prototype, "value", 2);
12118
12920
  __decorateClass([
12119
- Column34("jsonb", { nullable: true })
12921
+ Column36("jsonb", { nullable: true })
12120
12922
  ], ProductAttribute.prototype, "metadata", 2);
12121
12923
  __decorateClass([
12122
- Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12924
+ Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12123
12925
  ], ProductAttribute.prototype, "createdAt", 2);
12124
12926
  __decorateClass([
12125
- Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12927
+ Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12126
12928
  ], ProductAttribute.prototype, "updatedAt", 2);
12127
12929
  __decorateClass([
12128
- ManyToOne22(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
12129
- JoinColumn22({ name: "productId" })
12930
+ ManyToOne24(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
12931
+ JoinColumn24({ name: "productId" })
12130
12932
  ], ProductAttribute.prototype, "product", 2);
12131
12933
  __decorateClass([
12132
- ManyToOne22(() => Attribute, { onDelete: "CASCADE" }),
12133
- JoinColumn22({ name: "attributeId" })
12934
+ ManyToOne24(() => Attribute, { onDelete: "CASCADE" }),
12935
+ JoinColumn24({ name: "attributeId" })
12134
12936
  ], ProductAttribute.prototype, "attribute", 2);
12135
12937
  ProductAttribute = __decorateClass([
12136
- Entity34("product_attributes")
12938
+ Entity36("product_attributes")
12137
12939
  ], ProductAttribute);
12138
12940
 
12139
12941
  // src/entities/tax.entity.ts
12140
- import { Entity as Entity35, PrimaryGeneratedColumn as PrimaryGeneratedColumn35, Column as Column35, ManyToOne as ManyToOne23, JoinColumn as JoinColumn23, Unique as Unique8 } from "typeorm";
12942
+ import { Entity as Entity37, PrimaryGeneratedColumn as PrimaryGeneratedColumn37, Column as Column37, ManyToOne as ManyToOne25, JoinColumn as JoinColumn25, Unique as Unique8 } from "typeorm";
12141
12943
  var Tax = class {
12142
12944
  id;
12143
12945
  vendorId;
@@ -12158,64 +12960,64 @@ var Tax = class {
12158
12960
  vendor;
12159
12961
  };
12160
12962
  __decorateClass([
12161
- PrimaryGeneratedColumn35()
12963
+ PrimaryGeneratedColumn37()
12162
12964
  ], Tax.prototype, "id", 2);
12163
12965
  __decorateClass([
12164
- Column35("int")
12966
+ Column37("int")
12165
12967
  ], Tax.prototype, "vendorId", 2);
12166
12968
  __decorateClass([
12167
- Column35("varchar")
12969
+ Column37("varchar")
12168
12970
  ], Tax.prototype, "name", 2);
12169
12971
  __decorateClass([
12170
- Column35("varchar")
12972
+ Column37("varchar")
12171
12973
  ], Tax.prototype, "slug", 2);
12172
12974
  __decorateClass([
12173
- Column35("decimal", { precision: 5, scale: 2 })
12975
+ Column37("decimal", { precision: 5, scale: 2 })
12174
12976
  ], Tax.prototype, "rate", 2);
12175
12977
  __decorateClass([
12176
- Column35("boolean", { default: false })
12978
+ Column37("boolean", { default: false })
12177
12979
  ], Tax.prototype, "isDefault", 2);
12178
12980
  __decorateClass([
12179
- Column35("text", { nullable: true })
12981
+ Column37("text", { nullable: true })
12180
12982
  ], Tax.prototype, "description", 2);
12181
12983
  __decorateClass([
12182
- Column35("boolean", { default: true })
12984
+ Column37("boolean", { default: true })
12183
12985
  ], Tax.prototype, "active", 2);
12184
12986
  __decorateClass([
12185
- Column35("jsonb", { nullable: true })
12987
+ Column37("jsonb", { nullable: true })
12186
12988
  ], Tax.prototype, "metadata", 2);
12187
12989
  __decorateClass([
12188
- Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12990
+ Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12189
12991
  ], Tax.prototype, "createdAt", 2);
12190
12992
  __decorateClass([
12191
- Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12993
+ Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12192
12994
  ], Tax.prototype, "updatedAt", 2);
12193
12995
  __decorateClass([
12194
- Column35({ type: "timestamp", nullable: true })
12996
+ Column37({ type: "timestamp", nullable: true })
12195
12997
  ], Tax.prototype, "deletedAt", 2);
12196
12998
  __decorateClass([
12197
- Column35("boolean", { default: false })
12999
+ Column37("boolean", { default: false })
12198
13000
  ], Tax.prototype, "deleted", 2);
12199
13001
  __decorateClass([
12200
- Column35("int", { nullable: true })
13002
+ Column37("int", { nullable: true })
12201
13003
  ], Tax.prototype, "createdBy", 2);
12202
13004
  __decorateClass([
12203
- Column35("int", { nullable: true })
13005
+ Column37("int", { nullable: true })
12204
13006
  ], Tax.prototype, "updatedBy", 2);
12205
13007
  __decorateClass([
12206
- Column35("int", { nullable: true })
13008
+ Column37("int", { nullable: true })
12207
13009
  ], Tax.prototype, "deletedBy", 2);
12208
13010
  __decorateClass([
12209
- ManyToOne23(() => Vendor, { onDelete: "RESTRICT" }),
12210
- JoinColumn23({ name: "vendorId" })
13011
+ ManyToOne25(() => Vendor, { onDelete: "RESTRICT" }),
13012
+ JoinColumn25({ name: "vendorId" })
12211
13013
  ], Tax.prototype, "vendor", 2);
12212
13014
  Tax = __decorateClass([
12213
- Entity35("taxes"),
13015
+ Entity37("taxes"),
12214
13016
  Unique8("UQ_taxes_vendor_slug", ["vendorId", "slug"])
12215
13017
  ], Tax);
12216
13018
 
12217
13019
  // src/entities/product-tax.entity.ts
12218
- import { Entity as Entity36, PrimaryGeneratedColumn as PrimaryGeneratedColumn36, Column as Column36, ManyToOne as ManyToOne24, JoinColumn as JoinColumn24 } from "typeorm";
13020
+ import { Entity as Entity38, PrimaryGeneratedColumn as PrimaryGeneratedColumn38, Column as Column38, ManyToOne as ManyToOne26, JoinColumn as JoinColumn26 } from "typeorm";
12219
13021
  var ProductTax = class {
12220
13022
  id;
12221
13023
  productId;
@@ -12227,37 +13029,37 @@ var ProductTax = class {
12227
13029
  tax;
12228
13030
  };
12229
13031
  __decorateClass([
12230
- PrimaryGeneratedColumn36()
13032
+ PrimaryGeneratedColumn38()
12231
13033
  ], ProductTax.prototype, "id", 2);
12232
13034
  __decorateClass([
12233
- Column36("int")
13035
+ Column38("int")
12234
13036
  ], ProductTax.prototype, "productId", 2);
12235
13037
  __decorateClass([
12236
- Column36("int")
13038
+ Column38("int")
12237
13039
  ], ProductTax.prototype, "taxId", 2);
12238
13040
  __decorateClass([
12239
- Column36("decimal", { precision: 5, scale: 2, nullable: true })
13041
+ Column38("decimal", { precision: 5, scale: 2, nullable: true })
12240
13042
  ], ProductTax.prototype, "rate", 2);
12241
13043
  __decorateClass([
12242
- Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13044
+ Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12243
13045
  ], ProductTax.prototype, "createdAt", 2);
12244
13046
  __decorateClass([
12245
- Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13047
+ Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12246
13048
  ], ProductTax.prototype, "updatedAt", 2);
12247
13049
  __decorateClass([
12248
- ManyToOne24(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
12249
- JoinColumn24({ name: "productId" })
13050
+ ManyToOne26(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
13051
+ JoinColumn26({ name: "productId" })
12250
13052
  ], ProductTax.prototype, "product", 2);
12251
13053
  __decorateClass([
12252
- ManyToOne24(() => Tax, { onDelete: "CASCADE" }),
12253
- JoinColumn24({ name: "taxId" })
13054
+ ManyToOne26(() => Tax, { onDelete: "CASCADE" }),
13055
+ JoinColumn26({ name: "taxId" })
12254
13056
  ], ProductTax.prototype, "tax", 2);
12255
13057
  ProductTax = __decorateClass([
12256
- Entity36("product_taxes")
13058
+ Entity38("product_taxes")
12257
13059
  ], ProductTax);
12258
13060
 
12259
13061
  // src/entities/order-item.entity.ts
12260
- import { Entity as Entity37, PrimaryGeneratedColumn as PrimaryGeneratedColumn37, Column as Column37, ManyToOne as ManyToOne25, JoinColumn as JoinColumn25 } from "typeorm";
13062
+ import { Entity as Entity39, PrimaryGeneratedColumn as PrimaryGeneratedColumn39, Column as Column39, ManyToOne as ManyToOne27, JoinColumn as JoinColumn27 } from "typeorm";
12261
13063
  var OrderItem = class {
12262
13064
  id;
12263
13065
  orderId;
@@ -12282,79 +13084,79 @@ var OrderItem = class {
12282
13084
  product;
12283
13085
  };
12284
13086
  __decorateClass([
12285
- PrimaryGeneratedColumn37()
13087
+ PrimaryGeneratedColumn39()
12286
13088
  ], OrderItem.prototype, "id", 2);
12287
13089
  __decorateClass([
12288
- Column37("int")
13090
+ Column39("int")
12289
13091
  ], OrderItem.prototype, "orderId", 2);
12290
13092
  __decorateClass([
12291
- Column37("int")
13093
+ Column39("int")
12292
13094
  ], OrderItem.prototype, "productId", 2);
12293
13095
  __decorateClass([
12294
- Column37({ type: "int", array: true, nullable: true, default: () => "ARRAY[]::INTEGER[]" })
13096
+ Column39({ type: "int", array: true, nullable: true, default: () => "ARRAY[]::INTEGER[]" })
12295
13097
  ], OrderItem.prototype, "discountIds", 2);
12296
13098
  __decorateClass([
12297
- Column37("int", { default: 1 })
13099
+ Column39("int", { default: 1 })
12298
13100
  ], OrderItem.prototype, "quantity", 2);
12299
13101
  __decorateClass([
12300
- Column37({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13102
+ Column39({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12301
13103
  ], OrderItem.prototype, "unitPrice", 2);
12302
13104
  __decorateClass([
12303
- Column37({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13105
+ Column39({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12304
13106
  ], OrderItem.prototype, "subTotal", 2);
12305
13107
  __decorateClass([
12306
- Column37({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13108
+ Column39({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12307
13109
  ], OrderItem.prototype, "discount", 2);
12308
13110
  __decorateClass([
12309
- Column37({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13111
+ Column39({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12310
13112
  ], OrderItem.prototype, "discountedAmount", 2);
12311
13113
  __decorateClass([
12312
- Column37("decimal", { precision: 12, scale: 2, default: 0 })
13114
+ Column39("decimal", { precision: 12, scale: 2, default: 0 })
12313
13115
  ], OrderItem.prototype, "tax", 2);
12314
13116
  __decorateClass([
12315
- Column37("decimal", { precision: 12, scale: 2 })
13117
+ Column39("decimal", { precision: 12, scale: 2 })
12316
13118
  ], OrderItem.prototype, "total", 2);
12317
13119
  __decorateClass([
12318
- Column37("varchar", { nullable: true })
13120
+ Column39("varchar", { nullable: true })
12319
13121
  ], OrderItem.prototype, "hsn", 2);
12320
13122
  __decorateClass([
12321
- Column37("varchar", { nullable: true })
13123
+ Column39("varchar", { nullable: true })
12322
13124
  ], OrderItem.prototype, "uom", 2);
12323
13125
  __decorateClass([
12324
- Column37("varchar", { nullable: true })
13126
+ Column39("varchar", { nullable: true })
12325
13127
  ], OrderItem.prototype, "productType", 2);
12326
13128
  __decorateClass([
12327
- Column37("decimal", { precision: 5, scale: 2, nullable: true })
13129
+ Column39("decimal", { precision: 5, scale: 2, nullable: true })
12328
13130
  ], OrderItem.prototype, "taxRate", 2);
12329
13131
  __decorateClass([
12330
- Column37("varchar", { nullable: true })
13132
+ Column39("varchar", { nullable: true })
12331
13133
  ], OrderItem.prototype, "taxCode", 2);
12332
13134
  __decorateClass([
12333
- Column37("jsonb", { nullable: true })
13135
+ Column39("jsonb", { nullable: true })
12334
13136
  ], OrderItem.prototype, "metadata", 2);
12335
13137
  __decorateClass([
12336
- Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13138
+ Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12337
13139
  ], OrderItem.prototype, "createdAt", 2);
12338
13140
  __decorateClass([
12339
- Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13141
+ Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12340
13142
  ], OrderItem.prototype, "updatedAt", 2);
12341
13143
  __decorateClass([
12342
- ManyToOne25(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
12343
- JoinColumn25({ name: "orderId" })
13144
+ ManyToOne27(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
13145
+ JoinColumn27({ name: "orderId" })
12344
13146
  ], OrderItem.prototype, "order", 2);
12345
13147
  __decorateClass([
12346
- ManyToOne25(() => Product, { onDelete: "CASCADE" }),
12347
- JoinColumn25({ name: "productId" })
13148
+ ManyToOne27(() => Product, { onDelete: "CASCADE" }),
13149
+ JoinColumn27({ name: "productId" })
12348
13150
  ], OrderItem.prototype, "product", 2);
12349
13151
  OrderItem = __decorateClass([
12350
- Entity37("order_items")
13152
+ Entity39("order_items")
12351
13153
  ], OrderItem);
12352
13154
 
12353
13155
  // src/entities/knowledge-base-document.entity.ts
12354
- import { Entity as Entity39, PrimaryGeneratedColumn as PrimaryGeneratedColumn39, Column as Column39, OneToMany as OneToMany17 } from "typeorm";
13156
+ import { Entity as Entity41, PrimaryGeneratedColumn as PrimaryGeneratedColumn41, Column as Column41, OneToMany as OneToMany17 } from "typeorm";
12355
13157
 
12356
13158
  // src/entities/knowledge-base-chunk.entity.ts
12357
- import { Entity as Entity38, PrimaryGeneratedColumn as PrimaryGeneratedColumn38, Column as Column38, ManyToOne as ManyToOne26, JoinColumn as JoinColumn26 } from "typeorm";
13159
+ import { Entity as Entity40, PrimaryGeneratedColumn as PrimaryGeneratedColumn40, Column as Column40, ManyToOne as ManyToOne28, JoinColumn as JoinColumn28 } from "typeorm";
12358
13160
  var KnowledgeBaseChunk = class {
12359
13161
  id;
12360
13162
  documentId;
@@ -12364,26 +13166,26 @@ var KnowledgeBaseChunk = class {
12364
13166
  document;
12365
13167
  };
12366
13168
  __decorateClass([
12367
- PrimaryGeneratedColumn38()
13169
+ PrimaryGeneratedColumn40()
12368
13170
  ], KnowledgeBaseChunk.prototype, "id", 2);
12369
13171
  __decorateClass([
12370
- Column38("int")
13172
+ Column40("int")
12371
13173
  ], KnowledgeBaseChunk.prototype, "documentId", 2);
12372
13174
  __decorateClass([
12373
- Column38("text")
13175
+ Column40("text")
12374
13176
  ], KnowledgeBaseChunk.prototype, "content", 2);
12375
13177
  __decorateClass([
12376
- Column38("int", { default: 0 })
13178
+ Column40("int", { default: 0 })
12377
13179
  ], KnowledgeBaseChunk.prototype, "chunkIndex", 2);
12378
13180
  __decorateClass([
12379
- Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13181
+ Column40({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12380
13182
  ], KnowledgeBaseChunk.prototype, "createdAt", 2);
12381
13183
  __decorateClass([
12382
- ManyToOne26(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
12383
- JoinColumn26({ name: "documentId" })
13184
+ ManyToOne28(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
13185
+ JoinColumn28({ name: "documentId" })
12384
13186
  ], KnowledgeBaseChunk.prototype, "document", 2);
12385
13187
  KnowledgeBaseChunk = __decorateClass([
12386
- Entity38("knowledge_base_chunks")
13188
+ Entity40("knowledge_base_chunks")
12387
13189
  ], KnowledgeBaseChunk);
12388
13190
 
12389
13191
  // src/entities/knowledge-base-document.entity.ts
@@ -12397,32 +13199,32 @@ var KnowledgeBaseDocument = class {
12397
13199
  chunks;
12398
13200
  };
12399
13201
  __decorateClass([
12400
- PrimaryGeneratedColumn39()
13202
+ PrimaryGeneratedColumn41()
12401
13203
  ], KnowledgeBaseDocument.prototype, "id", 2);
12402
13204
  __decorateClass([
12403
- Column39("varchar")
13205
+ Column41("varchar")
12404
13206
  ], KnowledgeBaseDocument.prototype, "name", 2);
12405
13207
  __decorateClass([
12406
- Column39("varchar", { nullable: true })
13208
+ Column41("varchar", { nullable: true })
12407
13209
  ], KnowledgeBaseDocument.prototype, "sourceUrl", 2);
12408
13210
  __decorateClass([
12409
- Column39("text")
13211
+ Column41("text")
12410
13212
  ], KnowledgeBaseDocument.prototype, "content", 2);
12411
13213
  __decorateClass([
12412
- Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13214
+ Column41({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12413
13215
  ], KnowledgeBaseDocument.prototype, "createdAt", 2);
12414
13216
  __decorateClass([
12415
- Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13217
+ Column41({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12416
13218
  ], KnowledgeBaseDocument.prototype, "updatedAt", 2);
12417
13219
  __decorateClass([
12418
13220
  OneToMany17(() => KnowledgeBaseChunk, (c) => c.document)
12419
13221
  ], KnowledgeBaseDocument.prototype, "chunks", 2);
12420
13222
  KnowledgeBaseDocument = __decorateClass([
12421
- Entity39("knowledge_base_documents")
13223
+ Entity41("knowledge_base_documents")
12422
13224
  ], KnowledgeBaseDocument);
12423
13225
 
12424
13226
  // src/entities/cart.entity.ts
12425
- import { Entity as Entity40, PrimaryGeneratedColumn as PrimaryGeneratedColumn40, Column as Column40, ManyToOne as ManyToOne27, OneToMany as OneToMany18, JoinColumn as JoinColumn27 } from "typeorm";
13227
+ import { Entity as Entity42, PrimaryGeneratedColumn as PrimaryGeneratedColumn42, Column as Column42, ManyToOne as ManyToOne29, OneToMany as OneToMany18, JoinColumn as JoinColumn29 } from "typeorm";
12426
13228
  var Cart = class {
12427
13229
  id;
12428
13230
  guestToken;
@@ -12435,39 +13237,39 @@ var Cart = class {
12435
13237
  items;
12436
13238
  };
12437
13239
  __decorateClass([
12438
- PrimaryGeneratedColumn40()
13240
+ PrimaryGeneratedColumn42()
12439
13241
  ], Cart.prototype, "id", 2);
12440
13242
  __decorateClass([
12441
- Column40("varchar", { nullable: true })
13243
+ Column42("varchar", { nullable: true })
12442
13244
  ], Cart.prototype, "guestToken", 2);
12443
13245
  __decorateClass([
12444
- Column40("int", { nullable: true })
13246
+ Column42("int", { nullable: true })
12445
13247
  ], Cart.prototype, "contactId", 2);
12446
13248
  __decorateClass([
12447
- Column40("varchar", { default: "INR" })
13249
+ Column42("varchar", { default: "INR" })
12448
13250
  ], Cart.prototype, "currency", 2);
12449
13251
  __decorateClass([
12450
- Column40({ type: "timestamp", nullable: true })
13252
+ Column42({ type: "timestamp", nullable: true })
12451
13253
  ], Cart.prototype, "expiresAt", 2);
12452
13254
  __decorateClass([
12453
- Column40({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13255
+ Column42({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12454
13256
  ], Cart.prototype, "createdAt", 2);
12455
13257
  __decorateClass([
12456
- Column40({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13258
+ Column42({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12457
13259
  ], Cart.prototype, "updatedAt", 2);
12458
13260
  __decorateClass([
12459
- ManyToOne27(() => Contact, { onDelete: "CASCADE" }),
12460
- JoinColumn27({ name: "contactId" })
13261
+ ManyToOne29(() => Contact, { onDelete: "CASCADE" }),
13262
+ JoinColumn29({ name: "contactId" })
12461
13263
  ], Cart.prototype, "contact", 2);
12462
13264
  __decorateClass([
12463
13265
  OneToMany18("CartItem", "cart")
12464
13266
  ], Cart.prototype, "items", 2);
12465
13267
  Cart = __decorateClass([
12466
- Entity40("carts")
13268
+ Entity42("carts")
12467
13269
  ], Cart);
12468
13270
 
12469
13271
  // src/entities/cart-item.entity.ts
12470
- import { Entity as Entity41, PrimaryGeneratedColumn as PrimaryGeneratedColumn41, Column as Column41, ManyToOne as ManyToOne28, JoinColumn as JoinColumn28 } from "typeorm";
13272
+ import { Entity as Entity43, PrimaryGeneratedColumn as PrimaryGeneratedColumn43, Column as Column43, ManyToOne as ManyToOne30, JoinColumn as JoinColumn30 } from "typeorm";
12471
13273
  var CartItem = class {
12472
13274
  id;
12473
13275
  cartId;
@@ -12480,40 +13282,40 @@ var CartItem = class {
12480
13282
  product;
12481
13283
  };
12482
13284
  __decorateClass([
12483
- PrimaryGeneratedColumn41()
13285
+ PrimaryGeneratedColumn43()
12484
13286
  ], CartItem.prototype, "id", 2);
12485
13287
  __decorateClass([
12486
- Column41("int")
13288
+ Column43("int")
12487
13289
  ], CartItem.prototype, "cartId", 2);
12488
13290
  __decorateClass([
12489
- Column41("int")
13291
+ Column43("int")
12490
13292
  ], CartItem.prototype, "productId", 2);
12491
13293
  __decorateClass([
12492
- Column41("int", { default: 1 })
13294
+ Column43("int", { default: 1 })
12493
13295
  ], CartItem.prototype, "quantity", 2);
12494
13296
  __decorateClass([
12495
- Column41("jsonb", { nullable: true })
13297
+ Column43("jsonb", { nullable: true })
12496
13298
  ], CartItem.prototype, "metadata", 2);
12497
13299
  __decorateClass([
12498
- Column41({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13300
+ Column43({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12499
13301
  ], CartItem.prototype, "createdAt", 2);
12500
13302
  __decorateClass([
12501
- Column41({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13303
+ Column43({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12502
13304
  ], CartItem.prototype, "updatedAt", 2);
12503
13305
  __decorateClass([
12504
- ManyToOne28(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
12505
- JoinColumn28({ name: "cartId" })
13306
+ ManyToOne30(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
13307
+ JoinColumn30({ name: "cartId" })
12506
13308
  ], CartItem.prototype, "cart", 2);
12507
13309
  __decorateClass([
12508
- ManyToOne28(() => Product, { onDelete: "CASCADE" }),
12509
- JoinColumn28({ name: "productId" })
13310
+ ManyToOne30(() => Product, { onDelete: "CASCADE" }),
13311
+ JoinColumn30({ name: "productId" })
12510
13312
  ], CartItem.prototype, "product", 2);
12511
13313
  CartItem = __decorateClass([
12512
- Entity41("cart_items")
13314
+ Entity43("cart_items")
12513
13315
  ], CartItem);
12514
13316
 
12515
13317
  // src/entities/wishlist.entity.ts
12516
- import { Entity as Entity42, PrimaryGeneratedColumn as PrimaryGeneratedColumn42, Column as Column42, ManyToOne as ManyToOne29, OneToMany as OneToMany19, JoinColumn as JoinColumn29 } from "typeorm";
13318
+ import { Entity as Entity44, PrimaryGeneratedColumn as PrimaryGeneratedColumn44, Column as Column44, ManyToOne as ManyToOne31, OneToMany as OneToMany19, JoinColumn as JoinColumn31 } from "typeorm";
12517
13319
  var Wishlist = class {
12518
13320
  id;
12519
13321
  guestId;
@@ -12525,36 +13327,36 @@ var Wishlist = class {
12525
13327
  items;
12526
13328
  };
12527
13329
  __decorateClass([
12528
- PrimaryGeneratedColumn42()
13330
+ PrimaryGeneratedColumn44()
12529
13331
  ], Wishlist.prototype, "id", 2);
12530
13332
  __decorateClass([
12531
- Column42("varchar", { nullable: true })
13333
+ Column44("varchar", { nullable: true })
12532
13334
  ], Wishlist.prototype, "guestId", 2);
12533
13335
  __decorateClass([
12534
- Column42("int", { nullable: true })
13336
+ Column44("int", { nullable: true })
12535
13337
  ], Wishlist.prototype, "contactId", 2);
12536
13338
  __decorateClass([
12537
- Column42("varchar", { default: "default" })
13339
+ Column44("varchar", { default: "default" })
12538
13340
  ], Wishlist.prototype, "name", 2);
12539
13341
  __decorateClass([
12540
- Column42({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13342
+ Column44({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12541
13343
  ], Wishlist.prototype, "createdAt", 2);
12542
13344
  __decorateClass([
12543
- Column42({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13345
+ Column44({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12544
13346
  ], Wishlist.prototype, "updatedAt", 2);
12545
13347
  __decorateClass([
12546
- ManyToOne29(() => Contact, { onDelete: "CASCADE" }),
12547
- JoinColumn29({ name: "contactId" })
13348
+ ManyToOne31(() => Contact, { onDelete: "CASCADE" }),
13349
+ JoinColumn31({ name: "contactId" })
12548
13350
  ], Wishlist.prototype, "contact", 2);
12549
13351
  __decorateClass([
12550
13352
  OneToMany19("WishlistItem", "wishlist")
12551
13353
  ], Wishlist.prototype, "items", 2);
12552
13354
  Wishlist = __decorateClass([
12553
- Entity42("wishlists")
13355
+ Entity44("wishlists")
12554
13356
  ], Wishlist);
12555
13357
 
12556
13358
  // src/entities/wishlist-item.entity.ts
12557
- import { Entity as Entity43, PrimaryGeneratedColumn as PrimaryGeneratedColumn43, Column as Column43, ManyToOne as ManyToOne30, JoinColumn as JoinColumn30 } from "typeorm";
13359
+ import { Entity as Entity45, PrimaryGeneratedColumn as PrimaryGeneratedColumn45, Column as Column45, ManyToOne as ManyToOne32, JoinColumn as JoinColumn32 } from "typeorm";
12558
13360
  var WishlistItem = class {
12559
13361
  id;
12560
13362
  wishlistId;
@@ -12566,37 +13368,37 @@ var WishlistItem = class {
12566
13368
  product;
12567
13369
  };
12568
13370
  __decorateClass([
12569
- PrimaryGeneratedColumn43()
13371
+ PrimaryGeneratedColumn45()
12570
13372
  ], WishlistItem.prototype, "id", 2);
12571
13373
  __decorateClass([
12572
- Column43("int")
13374
+ Column45("int")
12573
13375
  ], WishlistItem.prototype, "wishlistId", 2);
12574
13376
  __decorateClass([
12575
- Column43("int")
13377
+ Column45("int")
12576
13378
  ], WishlistItem.prototype, "productId", 2);
12577
13379
  __decorateClass([
12578
- Column43("jsonb", { nullable: true })
13380
+ Column45("jsonb", { nullable: true })
12579
13381
  ], WishlistItem.prototype, "metadata", 2);
12580
13382
  __decorateClass([
12581
- Column43({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13383
+ Column45({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12582
13384
  ], WishlistItem.prototype, "createdAt", 2);
12583
13385
  __decorateClass([
12584
- Column43({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13386
+ Column45({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12585
13387
  ], WishlistItem.prototype, "updatedAt", 2);
12586
13388
  __decorateClass([
12587
- ManyToOne30(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
12588
- JoinColumn30({ name: "wishlistId" })
13389
+ ManyToOne32(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
13390
+ JoinColumn32({ name: "wishlistId" })
12589
13391
  ], WishlistItem.prototype, "wishlist", 2);
12590
13392
  __decorateClass([
12591
- ManyToOne30(() => Product, { onDelete: "CASCADE" }),
12592
- JoinColumn30({ name: "productId" })
13393
+ ManyToOne32(() => Product, { onDelete: "CASCADE" }),
13394
+ JoinColumn32({ name: "productId" })
12593
13395
  ], WishlistItem.prototype, "product", 2);
12594
13396
  WishlistItem = __decorateClass([
12595
- Entity43("wishlist_items")
13397
+ Entity45("wishlist_items")
12596
13398
  ], WishlistItem);
12597
13399
 
12598
13400
  // src/entities/llm-agent-knowledge-document.entity.ts
12599
- import { Entity as Entity44, PrimaryGeneratedColumn as PrimaryGeneratedColumn44, Column as Column44, ManyToOne as ManyToOne31, JoinColumn as JoinColumn31, Index as Index2, Unique as Unique9 } from "typeorm";
13401
+ import { Entity as Entity46, PrimaryGeneratedColumn as PrimaryGeneratedColumn46, Column as Column46, ManyToOne as ManyToOne33, JoinColumn as JoinColumn33, Index as Index2, Unique as Unique9 } from "typeorm";
12600
13402
  var LlmAgentKnowledgeDocument = class {
12601
13403
  id;
12602
13404
  agentId;
@@ -12606,33 +13408,33 @@ var LlmAgentKnowledgeDocument = class {
12606
13408
  document;
12607
13409
  };
12608
13410
  __decorateClass([
12609
- PrimaryGeneratedColumn44()
13411
+ PrimaryGeneratedColumn46()
12610
13412
  ], LlmAgentKnowledgeDocument.prototype, "id", 2);
12611
13413
  __decorateClass([
12612
- Column44("int")
13414
+ Column46("int")
12613
13415
  ], LlmAgentKnowledgeDocument.prototype, "agentId", 2);
12614
13416
  __decorateClass([
12615
- Column44("int")
13417
+ Column46("int")
12616
13418
  ], LlmAgentKnowledgeDocument.prototype, "documentId", 2);
12617
13419
  __decorateClass([
12618
- Column44({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13420
+ Column46({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
12619
13421
  ], LlmAgentKnowledgeDocument.prototype, "createdAt", 2);
12620
13422
  __decorateClass([
12621
- ManyToOne31(() => LlmAgent, { onDelete: "CASCADE" }),
12622
- JoinColumn31({ name: "agentId" })
13423
+ ManyToOne33(() => LlmAgent, { onDelete: "CASCADE" }),
13424
+ JoinColumn33({ name: "agentId" })
12623
13425
  ], LlmAgentKnowledgeDocument.prototype, "agent", 2);
12624
13426
  __decorateClass([
12625
- ManyToOne31(() => KnowledgeBaseDocument, { onDelete: "CASCADE" }),
12626
- JoinColumn31({ name: "documentId" })
13427
+ ManyToOne33(() => KnowledgeBaseDocument, { onDelete: "CASCADE" }),
13428
+ JoinColumn33({ name: "documentId" })
12627
13429
  ], LlmAgentKnowledgeDocument.prototype, "document", 2);
12628
13430
  LlmAgentKnowledgeDocument = __decorateClass([
12629
- Entity44("llm_agent_knowledge_documents"),
13431
+ Entity46("llm_agent_knowledge_documents"),
12630
13432
  Unique9("UQ_llm_agent_knowledge_agent_document", ["agentId", "documentId"]),
12631
13433
  Index2("IDX_llm_agent_knowledge_agent", ["agentId"])
12632
13434
  ], LlmAgentKnowledgeDocument);
12633
13435
 
12634
13436
  // src/entities/currency.entity.ts
12635
- import { Entity as Entity45, Column as Column45, PrimaryGeneratedColumn as PrimaryGeneratedColumn45 } from "typeorm";
13437
+ import { Entity as Entity47, Column as Column47, PrimaryGeneratedColumn as PrimaryGeneratedColumn47 } from "typeorm";
12636
13438
  var Currency = class {
12637
13439
  id;
12638
13440
  code;
@@ -12642,29 +13444,29 @@ var Currency = class {
12642
13444
  isBaseCurrency;
12643
13445
  };
12644
13446
  __decorateClass([
12645
- PrimaryGeneratedColumn45()
13447
+ PrimaryGeneratedColumn47()
12646
13448
  ], Currency.prototype, "id", 2);
12647
13449
  __decorateClass([
12648
- Column45({ type: "varchar", unique: true })
13450
+ Column47({ type: "varchar", unique: true })
12649
13451
  ], Currency.prototype, "code", 2);
12650
13452
  __decorateClass([
12651
- Column45({ type: "varchar" })
13453
+ Column47({ type: "varchar" })
12652
13454
  ], Currency.prototype, "name", 2);
12653
13455
  __decorateClass([
12654
- Column45({ type: "varchar" })
13456
+ Column47({ type: "varchar" })
12655
13457
  ], Currency.prototype, "symbol", 2);
12656
13458
  __decorateClass([
12657
- Column45({ type: "boolean", default: true })
13459
+ Column47({ type: "boolean", default: true })
12658
13460
  ], Currency.prototype, "isActive", 2);
12659
13461
  __decorateClass([
12660
- Column45({ type: "boolean", default: false })
13462
+ Column47({ type: "boolean", default: false })
12661
13463
  ], Currency.prototype, "isBaseCurrency", 2);
12662
13464
  Currency = __decorateClass([
12663
- Entity45("currency")
13465
+ Entity47("currency")
12664
13466
  ], Currency);
12665
13467
 
12666
13468
  // src/entities/currency_exchange.entity.ts
12667
- import { Entity as Entity46, Column as Column46, PrimaryGeneratedColumn as PrimaryGeneratedColumn46 } from "typeorm";
13469
+ import { Entity as Entity48, Column as Column48, PrimaryGeneratedColumn as PrimaryGeneratedColumn48 } from "typeorm";
12668
13470
  var CurrencyExchange = class {
12669
13471
  id;
12670
13472
  fromCurrency;
@@ -12672,26 +13474,26 @@ var CurrencyExchange = class {
12672
13474
  rate;
12673
13475
  };
12674
13476
  __decorateClass([
12675
- PrimaryGeneratedColumn46()
13477
+ PrimaryGeneratedColumn48()
12676
13478
  ], CurrencyExchange.prototype, "id", 2);
12677
13479
  __decorateClass([
12678
- Column46({ type: "varchar" })
13480
+ Column48({ type: "varchar" })
12679
13481
  ], CurrencyExchange.prototype, "fromCurrency", 2);
12680
13482
  __decorateClass([
12681
- Column46({ type: "varchar" })
13483
+ Column48({ type: "varchar" })
12682
13484
  ], CurrencyExchange.prototype, "toCurrency", 2);
12683
13485
  __decorateClass([
12684
- Column46("decimal", { precision: 12, scale: 6, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13486
+ Column48("decimal", { precision: 12, scale: 6, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12685
13487
  ], CurrencyExchange.prototype, "rate", 2);
12686
13488
  CurrencyExchange = __decorateClass([
12687
- Entity46("currency_exchange")
13489
+ Entity48("currency_exchange")
12688
13490
  ], CurrencyExchange);
12689
13491
 
12690
13492
  // src/entities/discount.entity.ts
12691
- import { Entity as Entity48, PrimaryGeneratedColumn as PrimaryGeneratedColumn48, Column as Column48, OneToMany as OneToMany21, ManyToOne as ManyToOne33, JoinColumn as JoinColumn33 } from "typeorm";
13493
+ import { Entity as Entity50, PrimaryGeneratedColumn as PrimaryGeneratedColumn50, Column as Column50, OneToMany as OneToMany21, ManyToOne as ManyToOne35, JoinColumn as JoinColumn35 } from "typeorm";
12692
13494
 
12693
13495
  // src/entities/discount_rules.entity.ts
12694
- import { Entity as Entity47, PrimaryGeneratedColumn as PrimaryGeneratedColumn47, Column as Column47, ManyToOne as ManyToOne32, JoinColumn as JoinColumn32, OneToMany as OneToMany20 } from "typeorm";
13496
+ import { Entity as Entity49, PrimaryGeneratedColumn as PrimaryGeneratedColumn49, Column as Column49, ManyToOne as ManyToOne34, JoinColumn as JoinColumn34, OneToMany as OneToMany20 } from "typeorm";
12695
13497
  var Type = /* @__PURE__ */ ((Type2) => {
12696
13498
  Type2["MIN_AMOUNT"] = "minAmount";
12697
13499
  Type2["USER"] = "user";
@@ -12758,45 +13560,45 @@ var DiscountRules = class {
12758
13560
  value;
12759
13561
  };
12760
13562
  __decorateClass([
12761
- PrimaryGeneratedColumn47()
13563
+ PrimaryGeneratedColumn49()
12762
13564
  ], DiscountRules.prototype, "id", 2);
12763
13565
  __decorateClass([
12764
- ManyToOne32(() => Discount, (discount) => discount.rules, { onDelete: "CASCADE" }),
12765
- JoinColumn32({ name: "discountId" })
13566
+ ManyToOne34(() => Discount, (discount) => discount.rules, { onDelete: "CASCADE" }),
13567
+ JoinColumn34({ name: "discountId" })
12766
13568
  ], DiscountRules.prototype, "discount", 2);
12767
13569
  __decorateClass([
12768
- Column47({ type: "int" })
13570
+ Column49({ type: "int" })
12769
13571
  ], DiscountRules.prototype, "discountId", 2);
12770
13572
  __decorateClass([
12771
- ManyToOne32(() => DiscountRules, (rule) => rule.children, { nullable: true, onDelete: "CASCADE" }),
12772
- JoinColumn32({ name: "parentId" })
13573
+ ManyToOne34(() => DiscountRules, (rule) => rule.children, { nullable: true, onDelete: "CASCADE" }),
13574
+ JoinColumn34({ name: "parentId" })
12773
13575
  ], DiscountRules.prototype, "parent", 2);
12774
13576
  __decorateClass([
12775
13577
  OneToMany20(() => DiscountRules, (rule) => rule.parent)
12776
13578
  ], DiscountRules.prototype, "children", 2);
12777
13579
  __decorateClass([
12778
- Column47({ type: "int", nullable: true })
13580
+ Column49({ type: "int", nullable: true })
12779
13581
  ], DiscountRules.prototype, "parentId", 2);
12780
13582
  __decorateClass([
12781
- Column47({ type: "enum", enum: ConditionType })
13583
+ Column49({ type: "enum", enum: ConditionType })
12782
13584
  ], DiscountRules.prototype, "conditionType", 2);
12783
13585
  __decorateClass([
12784
- Column47({ type: "enum", enum: ConditionOperator, nullable: true })
13586
+ Column49({ type: "enum", enum: ConditionOperator, nullable: true })
12785
13587
  ], DiscountRules.prototype, "conditionOperator", 2);
12786
13588
  __decorateClass([
12787
- Column47({ type: "enum", enum: Type, nullable: true })
13589
+ Column49({ type: "enum", enum: Type, nullable: true })
12788
13590
  ], DiscountRules.prototype, "type", 2);
12789
13591
  __decorateClass([
12790
- Column47({ type: "enum", enum: SubType, nullable: true })
13592
+ Column49({ type: "enum", enum: SubType, nullable: true })
12791
13593
  ], DiscountRules.prototype, "subType", 2);
12792
13594
  __decorateClass([
12793
- Column47({ type: "enum", enum: ComparisonOperator, nullable: true })
13595
+ Column49({ type: "enum", enum: ComparisonOperator, nullable: true })
12794
13596
  ], DiscountRules.prototype, "comparisonOperator", 2);
12795
13597
  __decorateClass([
12796
- Column47({ type: "jsonb" })
13598
+ Column49({ type: "jsonb" })
12797
13599
  ], DiscountRules.prototype, "value", 2);
12798
13600
  DiscountRules = __decorateClass([
12799
- Entity47("discount_rules")
13601
+ Entity49("discount_rules")
12800
13602
  ], DiscountRules);
12801
13603
 
12802
13604
  // src/entities/discount.entity.ts
@@ -12833,59 +13635,59 @@ var Discount = class {
12833
13635
  rules;
12834
13636
  };
12835
13637
  __decorateClass([
12836
- PrimaryGeneratedColumn48()
13638
+ PrimaryGeneratedColumn50()
12837
13639
  ], Discount.prototype, "id", 2);
12838
13640
  __decorateClass([
12839
- Column48("int")
13641
+ Column50("int")
12840
13642
  ], Discount.prototype, "vendorId", 2);
12841
13643
  __decorateClass([
12842
- ManyToOne33(() => Vendor, { onDelete: "RESTRICT" }),
12843
- JoinColumn33({ name: "vendorId" })
13644
+ ManyToOne35(() => Vendor, { onDelete: "RESTRICT" }),
13645
+ JoinColumn35({ name: "vendorId" })
12844
13646
  ], Discount.prototype, "vendor", 2);
12845
13647
  __decorateClass([
12846
- Column48({ type: "varchar" })
13648
+ Column50({ type: "varchar" })
12847
13649
  ], Discount.prototype, "name", 2);
12848
13650
  __decorateClass([
12849
- Column48({ type: "varchar", nullable: true })
13651
+ Column50({ type: "varchar", nullable: true })
12850
13652
  ], Discount.prototype, "couponCode", 2);
12851
13653
  __decorateClass([
12852
- Column48({ type: "varchar", nullable: true })
13654
+ Column50({ type: "varchar", nullable: true })
12853
13655
  ], Discount.prototype, "description", 2);
12854
13656
  __decorateClass([
12855
- Column48({ type: "enum", enum: DiscountType })
13657
+ Column50({ type: "enum", enum: DiscountType })
12856
13658
  ], Discount.prototype, "discountType", 2);
12857
13659
  __decorateClass([
12858
- Column48({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13660
+ Column50({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12859
13661
  ], Discount.prototype, "value", 2);
12860
13662
  __decorateClass([
12861
- Column48({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13663
+ Column50({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12862
13664
  ], Discount.prototype, "maxDiscountAmount", 2);
12863
13665
  __decorateClass([
12864
- Column48({ type: "int", nullable: true })
13666
+ Column50({ type: "int", nullable: true })
12865
13667
  ], Discount.prototype, "maxTotalUsage", 2);
12866
13668
  __decorateClass([
12867
- Column48({ type: "int", nullable: true })
13669
+ Column50({ type: "int", nullable: true })
12868
13670
  ], Discount.prototype, "maxUsagePerUser", 2);
12869
13671
  __decorateClass([
12870
- Column48({ type: "int", default: 0 })
13672
+ Column50({ type: "int", default: 0 })
12871
13673
  ], Discount.prototype, "usedCount", 2);
12872
13674
  __decorateClass([
12873
- Column48({ type: "timestamp" })
13675
+ Column50({ type: "timestamp" })
12874
13676
  ], Discount.prototype, "validFrom", 2);
12875
13677
  __decorateClass([
12876
- Column48({ type: "timestamp" })
13678
+ Column50({ type: "timestamp" })
12877
13679
  ], Discount.prototype, "validUntil", 2);
12878
13680
  __decorateClass([
12879
- Column48({ type: "enum", enum: DiscountStatus, default: "ACTIVE" /* ACTIVE */ })
13681
+ Column50({ type: "enum", enum: DiscountStatus, default: "ACTIVE" /* ACTIVE */ })
12880
13682
  ], Discount.prototype, "status", 2);
12881
13683
  __decorateClass([
12882
- Column48({ type: "boolean" })
13684
+ Column50({ type: "boolean" })
12883
13685
  ], Discount.prototype, "canCombineWithOtherDiscounts", 2);
12884
13686
  __decorateClass([
12885
- Column48({ type: "boolean", default: false })
13687
+ Column50({ type: "boolean", default: false })
12886
13688
  ], Discount.prototype, "isAutomatic", 2);
12887
13689
  __decorateClass([
12888
- Column48({ type: "varchar", default: "INR" })
13690
+ Column50({ type: "varchar", default: "INR" })
12889
13691
  ], Discount.prototype, "currency", 2);
12890
13692
  __decorateClass([
12891
13693
  OneToMany21(() => DiscountRules, (rule) => rule.discount, {
@@ -12893,11 +13695,11 @@ __decorateClass([
12893
13695
  })
12894
13696
  ], Discount.prototype, "rules", 2);
12895
13697
  Discount = __decorateClass([
12896
- Entity48("discounts")
13698
+ Entity50("discounts")
12897
13699
  ], Discount);
12898
13700
 
12899
13701
  // src/entities/order_discounts.entity.ts
12900
- import { Column as Column49, Entity as Entity49, PrimaryGeneratedColumn as PrimaryGeneratedColumn49, ManyToOne as ManyToOne34, JoinColumn as JoinColumn34 } from "typeorm";
13702
+ import { Column as Column51, Entity as Entity51, PrimaryGeneratedColumn as PrimaryGeneratedColumn51, ManyToOne as ManyToOne36, JoinColumn as JoinColumn36 } from "typeorm";
12901
13703
  var OrderDiscounts = class {
12902
13704
  id;
12903
13705
  order;
@@ -12912,50 +13714,50 @@ var OrderDiscounts = class {
12912
13714
  metaData;
12913
13715
  };
12914
13716
  __decorateClass([
12915
- PrimaryGeneratedColumn49()
13717
+ PrimaryGeneratedColumn51()
12916
13718
  ], OrderDiscounts.prototype, "id", 2);
12917
13719
  __decorateClass([
12918
- ManyToOne34(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
12919
- JoinColumn34({ name: "orderId" })
13720
+ ManyToOne36(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
13721
+ JoinColumn36({ name: "orderId" })
12920
13722
  ], OrderDiscounts.prototype, "order", 2);
12921
13723
  __decorateClass([
12922
- Column49({ type: "int" })
13724
+ Column51({ type: "int" })
12923
13725
  ], OrderDiscounts.prototype, "orderId", 2);
12924
13726
  __decorateClass([
12925
- ManyToOne34(() => OrderItem, { onDelete: "CASCADE" }),
12926
- JoinColumn34({ name: "orderItemId" })
13727
+ ManyToOne36(() => OrderItem, { onDelete: "CASCADE" }),
13728
+ JoinColumn36({ name: "orderItemId" })
12927
13729
  ], OrderDiscounts.prototype, "orderItem", 2);
12928
13730
  __decorateClass([
12929
- Column49({ type: "int" })
13731
+ Column51({ type: "int" })
12930
13732
  ], OrderDiscounts.prototype, "orderItemId", 2);
12931
13733
  __decorateClass([
12932
- Column49({ type: "int" })
13734
+ Column51({ type: "int" })
12933
13735
  ], OrderDiscounts.prototype, "userId", 2);
12934
13736
  __decorateClass([
12935
- ManyToOne34(() => Discount, { onDelete: "CASCADE" }),
12936
- JoinColumn34({ name: "discountId" })
13737
+ ManyToOne36(() => Discount, { onDelete: "CASCADE" }),
13738
+ JoinColumn36({ name: "discountId" })
12937
13739
  ], OrderDiscounts.prototype, "discount", 2);
12938
13740
  __decorateClass([
12939
- Column49({ type: "int" })
13741
+ Column51({ type: "int" })
12940
13742
  ], OrderDiscounts.prototype, "discountId", 2);
12941
13743
  __decorateClass([
12942
- Column49({ type: "varchar" })
13744
+ Column51({ type: "varchar" })
12943
13745
  ], OrderDiscounts.prototype, "discountCode", 2);
12944
13746
  __decorateClass([
12945
- Column49({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
13747
+ Column51({ type: "decimal", precision: 10, scale: 2, transformer: { to: (value) => value, from: (value) => parseFloat(value) } })
12946
13748
  ], OrderDiscounts.prototype, "discountAmount", 2);
12947
13749
  __decorateClass([
12948
- Column49({ type: "jsonb", nullable: true })
13750
+ Column51({ type: "jsonb", nullable: true })
12949
13751
  ], OrderDiscounts.prototype, "metaData", 2);
12950
13752
  OrderDiscounts = __decorateClass([
12951
- Entity49("order_discounts")
13753
+ Entity51("order_discounts")
12952
13754
  ], OrderDiscounts);
12953
13755
 
12954
13756
  // src/entities/rss-feed.entity.ts
12955
13757
  import {
12956
- Entity as Entity51,
12957
- PrimaryGeneratedColumn as PrimaryGeneratedColumn51,
12958
- Column as Column51,
13758
+ Entity as Entity53,
13759
+ PrimaryGeneratedColumn as PrimaryGeneratedColumn53,
13760
+ Column as Column53,
12959
13761
  CreateDateColumn as CreateDateColumn4,
12960
13762
  UpdateDateColumn as UpdateDateColumn2,
12961
13763
  OneToMany as OneToMany22
@@ -12963,11 +13765,11 @@ import {
12963
13765
 
12964
13766
  // src/entities/rss-article.entity.ts
12965
13767
  import {
12966
- Entity as Entity50,
12967
- PrimaryGeneratedColumn as PrimaryGeneratedColumn50,
12968
- Column as Column50,
12969
- ManyToOne as ManyToOne35,
12970
- JoinColumn as JoinColumn35,
13768
+ Entity as Entity52,
13769
+ PrimaryGeneratedColumn as PrimaryGeneratedColumn52,
13770
+ Column as Column52,
13771
+ ManyToOne as ManyToOne37,
13772
+ JoinColumn as JoinColumn37,
12971
13773
  CreateDateColumn as CreateDateColumn3,
12972
13774
  Unique as Unique10
12973
13775
  } from "typeorm";
@@ -12989,53 +13791,53 @@ var RssArticle = class {
12989
13791
  createdAt;
12990
13792
  };
12991
13793
  __decorateClass([
12992
- PrimaryGeneratedColumn50("uuid")
13794
+ PrimaryGeneratedColumn52("uuid")
12993
13795
  ], RssArticle.prototype, "id", 2);
12994
13796
  __decorateClass([
12995
- Column50("uuid")
13797
+ Column52("uuid")
12996
13798
  ], RssArticle.prototype, "rssFeedId", 2);
12997
13799
  __decorateClass([
12998
- ManyToOne35(() => RssFeed, (f) => f.articles, { onDelete: "CASCADE" }),
12999
- JoinColumn35({ name: "rssFeedId" })
13800
+ ManyToOne37(() => RssFeed, (f) => f.articles, { onDelete: "CASCADE" }),
13801
+ JoinColumn37({ name: "rssFeedId" })
13000
13802
  ], RssArticle.prototype, "rssFeed", 2);
13001
13803
  __decorateClass([
13002
- Column50({ type: "text", nullable: true })
13804
+ Column52({ type: "text", nullable: true })
13003
13805
  ], RssArticle.prototype, "externalId", 2);
13004
13806
  __decorateClass([
13005
- Column50({ type: "text" })
13807
+ Column52({ type: "text" })
13006
13808
  ], RssArticle.prototype, "title", 2);
13007
13809
  __decorateClass([
13008
- Column50({ type: "text" })
13810
+ Column52({ type: "text" })
13009
13811
  ], RssArticle.prototype, "articleUrl", 2);
13010
13812
  __decorateClass([
13011
- Column50({ type: "text", nullable: true })
13813
+ Column52({ type: "text", nullable: true })
13012
13814
  ], RssArticle.prototype, "summary", 2);
13013
13815
  __decorateClass([
13014
- Column50({ type: "text", nullable: true })
13816
+ Column52({ type: "text", nullable: true })
13015
13817
  ], RssArticle.prototype, "content", 2);
13016
13818
  __decorateClass([
13017
- Column50({ type: "text", nullable: true })
13819
+ Column52({ type: "text", nullable: true })
13018
13820
  ], RssArticle.prototype, "author", 2);
13019
13821
  __decorateClass([
13020
- Column50({ type: "timestamp", nullable: true })
13822
+ Column52({ type: "timestamp", nullable: true })
13021
13823
  ], RssArticle.prototype, "publishedAt", 2);
13022
13824
  __decorateClass([
13023
- Column50({ type: "text", nullable: true })
13825
+ Column52({ type: "text", nullable: true })
13024
13826
  ], RssArticle.prototype, "imageUrl", 2);
13025
13827
  __decorateClass([
13026
- Column50({ type: "jsonb", nullable: true })
13828
+ Column52({ type: "jsonb", nullable: true })
13027
13829
  ], RssArticle.prototype, "rawData", 2);
13028
13830
  __decorateClass([
13029
- Column50({ type: "text", nullable: true })
13831
+ Column52({ type: "text", nullable: true })
13030
13832
  ], RssArticle.prototype, "contentHash", 2);
13031
13833
  __decorateClass([
13032
- Column50({ type: "boolean", default: false })
13834
+ Column52({ type: "boolean", default: false })
13033
13835
  ], RssArticle.prototype, "isProcessed", 2);
13034
13836
  __decorateClass([
13035
13837
  CreateDateColumn3()
13036
13838
  ], RssArticle.prototype, "createdAt", 2);
13037
13839
  RssArticle = __decorateClass([
13038
- Entity50("rss_articles"),
13840
+ Entity52("rss_articles"),
13039
13841
  Unique10("UQ_rss_articles_feed_article_url", ["rssFeedId", "articleUrl"])
13040
13842
  ], RssArticle);
13041
13843
 
@@ -13054,28 +13856,28 @@ var RssFeed = class {
13054
13856
  updatedAt;
13055
13857
  };
13056
13858
  __decorateClass([
13057
- PrimaryGeneratedColumn51("uuid")
13859
+ PrimaryGeneratedColumn53("uuid")
13058
13860
  ], RssFeed.prototype, "id", 2);
13059
13861
  __decorateClass([
13060
- Column51({ type: "text" })
13862
+ Column53({ type: "text" })
13061
13863
  ], RssFeed.prototype, "name", 2);
13062
13864
  __decorateClass([
13063
- Column51({ type: "text", unique: true })
13865
+ Column53({ type: "text", unique: true })
13064
13866
  ], RssFeed.prototype, "rssUrl", 2);
13065
13867
  __decorateClass([
13066
- Column51({ type: "text", nullable: true })
13868
+ Column53({ type: "text", nullable: true })
13067
13869
  ], RssFeed.prototype, "websiteUrl", 2);
13068
13870
  __decorateClass([
13069
- Column51({ type: "boolean", default: true })
13871
+ Column53({ type: "boolean", default: true })
13070
13872
  ], RssFeed.prototype, "isActive", 2);
13071
13873
  __decorateClass([
13072
- Column51({ type: "int", default: 60 })
13874
+ Column53({ type: "int", default: 60 })
13073
13875
  ], RssFeed.prototype, "fetchFrequencyMinutes", 2);
13074
13876
  __decorateClass([
13075
- Column51({ type: "timestamp", nullable: true })
13877
+ Column53({ type: "timestamp", nullable: true })
13076
13878
  ], RssFeed.prototype, "lastFetchedAt", 2);
13077
13879
  __decorateClass([
13078
- Column51({ type: "timestamp", nullable: true })
13880
+ Column53({ type: "timestamp", nullable: true })
13079
13881
  ], RssFeed.prototype, "lastArticleDate", 2);
13080
13882
  __decorateClass([
13081
13883
  OneToMany22(() => RssArticle, (article) => article.rssFeed)
@@ -13087,11 +13889,11 @@ __decorateClass([
13087
13889
  UpdateDateColumn2()
13088
13890
  ], RssFeed.prototype, "updatedAt", 2);
13089
13891
  RssFeed = __decorateClass([
13090
- Entity51("rss_feeds")
13892
+ Entity53("rss_feeds")
13091
13893
  ], RssFeed);
13092
13894
 
13093
13895
  // src/entities/vendor-user.entity.ts
13094
- import { Entity as Entity52, PrimaryGeneratedColumn as PrimaryGeneratedColumn52, Column as Column52, ManyToOne as ManyToOne36, JoinColumn as JoinColumn36, Unique as Unique11, Index as Index3 } from "typeorm";
13896
+ import { Entity as Entity54, PrimaryGeneratedColumn as PrimaryGeneratedColumn54, Column as Column54, ManyToOne as ManyToOne38, JoinColumn as JoinColumn38, Unique as Unique11, Index as Index3 } from "typeorm";
13095
13897
  var VendorUser = class {
13096
13898
  id;
13097
13899
  vendorId;
@@ -13103,33 +13905,33 @@ var VendorUser = class {
13103
13905
  user;
13104
13906
  };
13105
13907
  __decorateClass([
13106
- PrimaryGeneratedColumn52()
13908
+ PrimaryGeneratedColumn54()
13107
13909
  ], VendorUser.prototype, "id", 2);
13108
13910
  __decorateClass([
13109
- Column52("int")
13911
+ Column54("int")
13110
13912
  ], VendorUser.prototype, "vendorId", 2);
13111
13913
  __decorateClass([
13112
- Column52("int")
13914
+ Column54("int")
13113
13915
  ], VendorUser.prototype, "userId", 2);
13114
13916
  __decorateClass([
13115
- Column52("varchar", { default: "staff" })
13917
+ Column54("varchar", { default: "staff" })
13116
13918
  ], VendorUser.prototype, "role", 2);
13117
13919
  __decorateClass([
13118
- Column52({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13920
+ Column54({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13119
13921
  ], VendorUser.prototype, "createdAt", 2);
13120
13922
  __decorateClass([
13121
- Column52({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13923
+ Column54({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13122
13924
  ], VendorUser.prototype, "updatedAt", 2);
13123
13925
  __decorateClass([
13124
- ManyToOne36(() => Vendor, (v) => v.vendorUsers, { onDelete: "CASCADE" }),
13125
- JoinColumn36({ name: "vendorId" })
13926
+ ManyToOne38(() => Vendor, (v) => v.vendorUsers, { onDelete: "CASCADE" }),
13927
+ JoinColumn38({ name: "vendorId" })
13126
13928
  ], VendorUser.prototype, "vendor", 2);
13127
13929
  __decorateClass([
13128
- ManyToOne36(() => User, { onDelete: "CASCADE" }),
13129
- JoinColumn36({ name: "userId" })
13930
+ ManyToOne38(() => User, { onDelete: "CASCADE" }),
13931
+ JoinColumn38({ name: "userId" })
13130
13932
  ], VendorUser.prototype, "user", 2);
13131
13933
  VendorUser = __decorateClass([
13132
- Entity52("vendor_users"),
13934
+ Entity54("vendor_users"),
13133
13935
  Unique11("UQ_vendor_users_vendor_user", ["vendorId", "userId"]),
13134
13936
  Index3("IDX_vendor_users_vendor", ["vendorId"]),
13135
13937
  Index3("IDX_vendor_users_user", ["userId"])
@@ -13137,57 +13939,64 @@ VendorUser = __decorateClass([
13137
13939
 
13138
13940
  // src/entities/vendor-customer.entity.ts
13139
13941
  import {
13140
- Entity as Entity53,
13141
- PrimaryGeneratedColumn as PrimaryGeneratedColumn53,
13142
- Column as Column53,
13143
- ManyToOne as ManyToOne37,
13144
- JoinColumn as JoinColumn37,
13145
- Unique as Unique12,
13942
+ Entity as Entity55,
13943
+ PrimaryGeneratedColumn as PrimaryGeneratedColumn55,
13944
+ Column as Column55,
13945
+ ManyToOne as ManyToOne39,
13946
+ JoinColumn as JoinColumn39,
13146
13947
  Index as Index4
13147
13948
  } from "typeorm";
13148
13949
  var VendorCustomer = class {
13149
13950
  id;
13150
13951
  vendorId;
13151
13952
  contactId;
13953
+ customerId;
13152
13954
  notes;
13153
13955
  tags;
13154
13956
  createdAt;
13155
13957
  updatedAt;
13156
13958
  vendor;
13157
13959
  contact;
13960
+ customer;
13158
13961
  };
13159
13962
  __decorateClass([
13160
- PrimaryGeneratedColumn53()
13963
+ PrimaryGeneratedColumn55()
13161
13964
  ], VendorCustomer.prototype, "id", 2);
13162
13965
  __decorateClass([
13163
- Column53("int")
13966
+ Column55("int")
13164
13967
  ], VendorCustomer.prototype, "vendorId", 2);
13165
13968
  __decorateClass([
13166
- Column53("int")
13969
+ Column55("int", { nullable: true })
13167
13970
  ], VendorCustomer.prototype, "contactId", 2);
13168
13971
  __decorateClass([
13169
- Column53("text", { nullable: true })
13972
+ Column55("int")
13973
+ ], VendorCustomer.prototype, "customerId", 2);
13974
+ __decorateClass([
13975
+ Column55("text", { nullable: true })
13170
13976
  ], VendorCustomer.prototype, "notes", 2);
13171
13977
  __decorateClass([
13172
- Column53("simple-array", { nullable: true })
13978
+ Column55("simple-array", { nullable: true })
13173
13979
  ], VendorCustomer.prototype, "tags", 2);
13174
13980
  __decorateClass([
13175
- Column53({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13981
+ Column55({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13176
13982
  ], VendorCustomer.prototype, "createdAt", 2);
13177
13983
  __decorateClass([
13178
- Column53({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13984
+ Column55({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
13179
13985
  ], VendorCustomer.prototype, "updatedAt", 2);
13180
13986
  __decorateClass([
13181
- ManyToOne37(() => Vendor, { onDelete: "CASCADE" }),
13182
- JoinColumn37({ name: "vendorId" })
13987
+ ManyToOne39(() => Vendor, { onDelete: "CASCADE" }),
13988
+ JoinColumn39({ name: "vendorId" })
13183
13989
  ], VendorCustomer.prototype, "vendor", 2);
13184
13990
  __decorateClass([
13185
- ManyToOne37(() => Contact, { onDelete: "CASCADE" }),
13186
- JoinColumn37({ name: "contactId" })
13991
+ ManyToOne39(() => Contact, { onDelete: "CASCADE" }),
13992
+ JoinColumn39({ name: "contactId" })
13187
13993
  ], VendorCustomer.prototype, "contact", 2);
13994
+ __decorateClass([
13995
+ ManyToOne39(() => Customer, { onDelete: "CASCADE" }),
13996
+ JoinColumn39({ name: "customerId" })
13997
+ ], VendorCustomer.prototype, "customer", 2);
13188
13998
  VendorCustomer = __decorateClass([
13189
- Entity53("vendor_customers"),
13190
- Unique12("UQ_vendor_customers_vendor_contact", ["vendorId", "contactId"]),
13999
+ Entity55("vendor_customers"),
13191
14000
  Index4("IDX_vendor_customers_vendor", ["vendorId"]),
13192
14001
  Index4("IDX_vendor_customers_contact", ["contactId"])
13193
14002
  ], VendorCustomer);
@@ -13246,7 +14055,9 @@ var CMS_ENTITY_MAP = {
13246
14055
  job_schedule_runs: JobScheduleRun,
13247
14056
  vendors: Vendor,
13248
14057
  vendor_users: VendorUser,
13249
- vendor_customers: VendorCustomer
14058
+ vendor_customers: VendorCustomer,
14059
+ customer: Customer,
14060
+ customer_contacts: Customer_Contacts
13250
14061
  };
13251
14062
 
13252
14063
  // src/auth/helpers.ts
@@ -13363,6 +14174,7 @@ function createAuthHelpersFromGetSession(getSession, NextResponse2) {
13363
14174
 
13364
14175
  // src/auth/index.ts
13365
14176
  init_rbac_debug();
14177
+ init_role_helpers();
13366
14178
  init_vendor_scope();
13367
14179
  init_permission_entities();
13368
14180
 
@@ -13548,12 +14360,17 @@ function createCmsMiddleware(config = {}) {
13548
14360
 
13549
14361
  // src/auth/nextauth-options.ts
13550
14362
  init_permission_entities();
14363
+ init_role_helpers();
13551
14364
  init_vendor_scope();
13552
14365
  import _CredentialsProvider from "next-auth/providers/credentials";
13553
14366
  var CredentialsProvider = _CredentialsProvider.default ?? _CredentialsProvider;
13554
14367
  function sessionUserFromNextAuthUser(user) {
13555
14368
  const g = user.group;
13556
- const isRBACAdmin = isSuperAdminGroupName(g?.name);
14369
+ const isRBACAdmin = isSuperAdmin({
14370
+ groupId: user.groupId ?? void 0,
14371
+ groupName: g?.name,
14372
+ isRBACAdmin: false
14373
+ });
13557
14374
  const entityPerms = permissionRowsToRecord(g?.permissions);
13558
14375
  const rawAdminAccess = user.adminAccess;
13559
14376
  const adminAccess = rawAdminAccess === true ? true : rawAdminAccess === false ? false : void 0;
@@ -13582,6 +14399,26 @@ function sessionUserFromNextAuthUser(user) {
13582
14399
  isVendorOwner: isVendorOwner2
13583
14400
  };
13584
14401
  }
14402
+ function isCustomerGroupUser(user) {
14403
+ return user.group?.name?.toLocaleLowerCase().trim() === "customer";
14404
+ }
14405
+ function callbackUrlTargetsAdmin(callbackUrl) {
14406
+ const raw = callbackUrl.trim();
14407
+ if (!raw) return false;
14408
+ if (raw.startsWith("/admin")) return true;
14409
+ try {
14410
+ const path2 = raw.startsWith("http") ? new URL(raw).pathname : raw.split("?")[0] ?? raw;
14411
+ return path2.startsWith("/admin");
14412
+ } catch {
14413
+ return raw.includes("/admin");
14414
+ }
14415
+ }
14416
+ function permitsCustomerLogin(allowCustomerLogin, credentials) {
14417
+ if (allowCustomerLogin === true) return true;
14418
+ if (allowCustomerLogin === false) return false;
14419
+ const callbackUrl = typeof credentials?.callbackUrl === "string" ? credentials.callbackUrl : "";
14420
+ return !callbackUrlTargetsAdmin(callbackUrl);
14421
+ }
13585
14422
  function getNextAuthOptions(config) {
13586
14423
  const {
13587
14424
  getUserByEmail,
@@ -13591,7 +14428,8 @@ function getNextAuthOptions(config) {
13591
14428
  extend,
13592
14429
  enablePasswordLogin = true,
13593
14430
  enableOtpLogin = false,
13594
- authorizeOtp
14431
+ authorizeOtp,
14432
+ allowCustomerLogin
13595
14433
  } = config;
13596
14434
  logAuth("getNextAuthOptions init", nextAuthCookieDebugInfo());
13597
14435
  const providers = [];
@@ -13604,8 +14442,9 @@ function getNextAuthOptions(config) {
13604
14442
  password: { label: "Password", type: "password" }
13605
14443
  },
13606
14444
  async authorize(credentials) {
13607
- const email = credentials?.email?.trim() ?? "";
13608
- if (!email || !credentials?.password) {
14445
+ const creds = credentials;
14446
+ const email = creds?.email?.trim() ?? "";
14447
+ if (!email || !creds?.password) {
13609
14448
  logAuth("authorize(credentials) rejected", { reason: "missing_email_or_password" });
13610
14449
  return null;
13611
14450
  }
@@ -13627,11 +14466,20 @@ function getNextAuthOptions(config) {
13627
14466
  logAuth("authorize(credentials) rejected", { reason: "no_password", email, userId: user.id });
13628
14467
  return null;
13629
14468
  }
13630
- const valid = await comparePassword(credentials.password, user.password);
14469
+ const valid = await comparePassword(creds.password, user.password);
13631
14470
  if (!valid) {
13632
14471
  logAuth("authorize(credentials) rejected", { reason: "invalid_password", email, userId: user.id });
13633
14472
  return null;
13634
14473
  }
14474
+ if (isCustomerGroupUser(user) && !permitsCustomerLogin(allowCustomerLogin, creds)) {
14475
+ logAuth("authorize(credentials) rejected", {
14476
+ reason: "customer_group",
14477
+ email,
14478
+ userId: user.id,
14479
+ callbackUrl: creds?.callbackUrl ?? null
14480
+ });
14481
+ return null;
14482
+ }
13635
14483
  const sessionUser = sessionUserFromNextAuthUser(user);
13636
14484
  logAuth("authorize(credentials) ok", summarizeSessionUserForLog(sessionUser));
13637
14485
  return sessionUser;
@@ -13658,13 +14506,22 @@ function getNextAuthOptions(config) {
13658
14506
  channel: { label: "Channel", type: "text" }
13659
14507
  },
13660
14508
  async authorize(credentials) {
13661
- const identifier = typeof credentials?.identifier === "string" ? credentials.identifier.trim() : "";
13662
- const code = typeof credentials?.code === "string" ? credentials.code.trim() : "";
13663
- const ch = credentials?.channel === "sms" ? "sms" : "email";
14509
+ const creds = credentials;
14510
+ const identifier = typeof creds?.identifier === "string" ? creds.identifier.trim() : "";
14511
+ const code = typeof creds?.code === "string" ? creds.code.trim() : "";
14512
+ const ch = creds?.channel === "sms" ? "sms" : "email";
13664
14513
  if (!identifier || !code) return null;
13665
14514
  try {
13666
14515
  const user = await authorizeOtp({ identifier, channel: ch, code });
13667
14516
  if (!user || user.blocked || user.deleted) return null;
14517
+ if (isCustomerGroupUser(user) && !permitsCustomerLogin(allowCustomerLogin, creds)) {
14518
+ logAuth("authorize(otp) rejected", {
14519
+ reason: "customer_group",
14520
+ identifier,
14521
+ callbackUrl: creds?.callbackUrl ?? null
14522
+ });
14523
+ return null;
14524
+ }
13668
14525
  return sessionUserFromNextAuthUser(user);
13669
14526
  } catch (err) {
13670
14527
  console.error("[cms-auth] authorize error (otp):", err instanceof Error ? err.message : err);
@@ -13748,6 +14605,9 @@ function getNextAuthOptions(config) {
13748
14605
  };
13749
14606
  return extend ? extend(options) : options;
13750
14607
  }
14608
+ function getStorefrontNextAuthOptions(config) {
14609
+ return getNextAuthOptions({ ...config, allowCustomerLogin: true });
14610
+ }
13751
14611
 
13752
14612
  // src/api/crud.ts
13753
14613
  import { Between, ILike as ILike2, LessThanOrEqual, MoreThan as MoreThan2, MoreThanOrEqual as MoreThanOrEqual2, Not } from "typeorm";
@@ -13755,6 +14615,18 @@ import { Between, ILike as ILike2, LessThanOrEqual, MoreThan as MoreThan2, MoreT
13755
14615
  // src/api/vendor-scope-crud.ts
13756
14616
  init_vendor_scope();
13757
14617
  import { In as In3 } from "typeorm";
14618
+
14619
+ // src/lib/default-vendor-id.ts
14620
+ function getDefaultVendorId() {
14621
+ const raw = process.env.DEFAULT_VENDOR_ID;
14622
+ if (raw != null && String(raw).trim() !== "") {
14623
+ const n = Number(raw);
14624
+ if (Number.isFinite(n) && n > 0) return Math.floor(n);
14625
+ }
14626
+ return 1;
14627
+ }
14628
+
14629
+ // src/api/vendor-scope-crud.ts
13758
14630
  function repoHasVendorIdColumn(repo) {
13759
14631
  return repo.metadata.columns.some((c) => c.propertyName === "vendorId");
13760
14632
  }
@@ -13801,26 +14673,39 @@ function rowMatchesVendorScope(row, scope, resource) {
13801
14673
  }
13802
14674
  return Number(row.vendorId) === scope.vendorId;
13803
14675
  }
14676
+ function vendorScopeRowAccess(row, scope, resource) {
14677
+ if (!row) return "not_found";
14678
+ if (rowMatchesVendorScope(row, scope, resource)) return "ok";
14679
+ return scope.type === "vendor" ? "forbidden" : "not_found";
14680
+ }
13804
14681
  function enforceVendorIdOnCreateBody(body, scope, repo) {
13805
14682
  if (!repoHasVendorIdColumn(repo)) return;
13806
14683
  if (scope.type === "vendor") {
14684
+ delete body.vendorId;
13807
14685
  body.vendorId = scope.vendorId;
13808
14686
  }
13809
14687
  }
13810
- function requireVendorIdForScopedCreate(resource, persistBody, scope, repo, rawBody) {
14688
+ function resolveVendorIdForWrite(scope, session, rawBody) {
14689
+ if (scope.type === "vendor") return scope.vendorId;
14690
+ if (scope.type === "deny") return null;
14691
+ if (rawBody) {
14692
+ const fromBody = Number(rawBody.vendorId);
14693
+ if (Number.isFinite(fromBody) && fromBody > 0) return fromBody;
14694
+ }
14695
+ const active = session?.activeVendorId;
14696
+ if (active != null && Number.isFinite(Number(active)) && Number(active) > 0) {
14697
+ return Number(active);
14698
+ }
14699
+ return getDefaultVendorId();
14700
+ }
14701
+ function requireVendorIdForScopedCreate(resource, persistBody, scope, repo, context) {
13811
14702
  if (!resourceUsesVendorScope(resource) || !repoHasVendorIdColumn(repo)) {
13812
14703
  return { ok: true };
13813
14704
  }
14705
+ const ctx = context && ("session" in context || "rawBody" in context) ? context : { rawBody: context };
13814
14706
  enforceVendorIdOnCreateBody(persistBody, scope, repo);
13815
- const vid = Number(persistBody.vendorId);
13816
- if (Number.isFinite(vid) && vid > 0) return { ok: true };
13817
- if (scope.type === "all" && rawBody) {
13818
- const n = Number(rawBody.vendorId);
13819
- if (Number.isFinite(n) && n > 0) {
13820
- persistBody.vendorId = n;
13821
- return { ok: true };
13822
- }
13823
- return { ok: false, error: "vendorId is required", status: 400 };
14707
+ if (scope.type === "vendor") {
14708
+ return { ok: true };
13824
14709
  }
13825
14710
  if (scope.type === "deny") {
13826
14711
  return {
@@ -13829,6 +14714,13 @@ function requireVendorIdForScopedCreate(resource, persistBody, scope, repo, rawB
13829
14714
  status: 403
13830
14715
  };
13831
14716
  }
14717
+ const vid = Number(persistBody.vendorId);
14718
+ if (Number.isFinite(vid) && vid > 0) return { ok: true };
14719
+ const resolved = resolveVendorIdForWrite(scope, ctx.session ?? null, ctx.rawBody ?? persistBody);
14720
+ if (resolved != null && resolved > 0) {
14721
+ persistBody.vendorId = resolved;
14722
+ return { ok: true };
14723
+ }
13832
14724
  return { ok: false, error: "vendorId is required", status: 400 };
13833
14725
  }
13834
14726
 
@@ -15141,9 +16033,13 @@ async function calculateOrderTotals(dataSource, entityMap, itemsSummary, discoun
15141
16033
  };
15142
16034
  }
15143
16035
  function createCrudHandler(dataSource, entityMap, options) {
15144
- const { requireAuth, json, requireEntityPermission: reqPerm, getCms, getVendorScope } = options;
16036
+ const { requireAuth, json, requireEntityPermission: reqPerm, getCms, getVendorScope, getHydratedSessionUser } = options;
15145
16037
  const syncContactRowToErp = makeContactErpSync(dataSource, entityMap, getCms);
15146
16038
  const resolveScope = getVendorScope ?? (async () => ({ type: "all" }));
16039
+ async function vendorCreateContext(rawBody) {
16040
+ const session = await getHydratedSessionUser?.() ?? null;
16041
+ return { rawBody, session };
16042
+ }
15147
16043
  async function authz(req, resource, action) {
15148
16044
  const authError = await requireAuth(req);
15149
16045
  if (authError) return authError;
@@ -15407,34 +16303,27 @@ function createCrudHandler(dataSource, entityMap, options) {
15407
16303
  });
15408
16304
  return json({ total: total2, page, limit, totalPages: Math.ceil(total2 / limit), data: data2 });
15409
16305
  }
15410
- if (resource === "vendor_customers" && entityMap.contacts) {
16306
+ if (resource === "vendor_customers" && entityMap["customer"]) {
15411
16307
  const scope = await resolveScope();
15412
16308
  const repo2 = dataSource.getRepository(entity);
15413
- const qb = repo2.createQueryBuilder("vc").leftJoinAndSelect("vc.contact", "contact").andWhere("contact.deleted = :contactDel", { contactDel: false }).orderBy("vc.createdAt", sortOrder === "DESC" ? "DESC" : "ASC").skip(skip).take(limit);
16309
+ const qb = repo2.createQueryBuilder("vc").leftJoinAndSelect("vc.customer", "customer").leftJoinAndSelect("customer.user", "user").orderBy("vc.createdAt", sortOrder === "DESC" ? "DESC" : "ASC").skip(skip).take(limit);
15414
16310
  applyVendorScopeToQueryBuilder(qb, "vc", scope);
15415
16311
  if (search && typeof search === "string" && search.trim()) {
15416
16312
  const term = `%${search.trim()}%`;
15417
16313
  qb.andWhere(
15418
- "(contact.name ILIKE :term OR contact.email ILIKE :term OR contact.phone ILIKE :term OR contact.company ILIKE :term)",
16314
+ "(customer.name ILIKE :term OR customer.email ILIKE :term OR customer.phone ILIKE :term)",
15419
16315
  { term }
15420
16316
  );
15421
16317
  }
15422
16318
  const [rows, total2] = await qb.getManyAndCount();
15423
16319
  const data2 = rows.map((row) => {
15424
- const contact = row.contact;
16320
+ const customer = row.customer;
15425
16321
  return {
15426
16322
  ...row,
15427
- name: contact?.name ?? null,
15428
- email: contact?.email ?? null,
15429
- phone: contact?.phone ?? null,
15430
- company: contact?.company ?? null,
15431
- contact: contact ? {
15432
- id: contact.id,
15433
- name: contact.name,
15434
- email: contact.email,
15435
- phone: contact.phone,
15436
- company: contact.company
15437
- } : null
16323
+ name: customer?.name ?? null,
16324
+ email: customer?.email ?? null,
16325
+ phone: customer?.phone ?? null,
16326
+ company: customer?.company ?? null
15438
16327
  };
15439
16328
  });
15440
16329
  return json({ total: total2, page, limit, totalPages: Math.ceil(total2 / limit), data: data2 });
@@ -15694,7 +16583,7 @@ function createCrudHandler(dataSource, entityMap, options) {
15694
16583
  persistBody2,
15695
16584
  scopeDiscount,
15696
16585
  repo2,
15697
- body
16586
+ await vendorCreateContext(body)
15698
16587
  );
15699
16588
  if (!vendorIdCheck2.ok) {
15700
16589
  return json({ error: vendorIdCheck2.error }, { status: vendorIdCheck2.status });
@@ -15722,6 +16611,135 @@ function createCrudHandler(dataSource, entityMap, options) {
15722
16611
  });
15723
16612
  return json(reloaded ?? created2, { status: 201 });
15724
16613
  }
16614
+ if (resource === "vendor_customers") {
16615
+ if (!entityMap["customer"]) {
16616
+ return json({ error: "Customer entity not configured" }, { status: 503 });
16617
+ }
16618
+ if (!entityMap["users"]) {
16619
+ return json({ error: "Users entity not configured" }, { status: 503 });
16620
+ }
16621
+ let customerGroupId = null;
16622
+ if (entityMap["user_groups"]) {
16623
+ const userGroupRepo = dataSource.getRepository(entityMap["user_groups"]);
16624
+ const customerGroup = await userGroupRepo.findOne({
16625
+ where: { name: "Customer", deleted: false }
16626
+ });
16627
+ if (!customerGroup) {
16628
+ return json({ error: "User group 'customer' not found" }, { status: 500 });
16629
+ }
16630
+ customerGroupId = Number(customerGroup.id);
16631
+ } else {
16632
+ return json({ error: "user_groups entity not configured" }, { status: 503 });
16633
+ }
16634
+ const name = String(body.name ?? "").trim();
16635
+ const email = String(body.email ?? "").trim();
16636
+ const phone = String(body.phone ?? "").trim();
16637
+ const rawPw = String(body._password ?? "").trim();
16638
+ if (!name) return json({ error: "name is required" }, { status: 400 });
16639
+ if (!email) return json({ error: "email is required" }, { status: 400 });
16640
+ if (!phone) return json({ error: "phone is required" }, { status: 400 });
16641
+ if (!rawPw) return json({ error: "password is required" }, { status: 400 });
16642
+ if (rawPw.length < 6) {
16643
+ return json({ error: "Password must be at least 6 characters" }, { status: 400 });
16644
+ }
16645
+ const customerRepo = dataSource.getRepository(entityMap["customer"]);
16646
+ const userRepo = dataSource.getRepository(entityMap["users"]);
16647
+ const dupCustEmail = await customerRepo.findOne({
16648
+ where: { email, deleted: false }
16649
+ });
16650
+ if (dupCustEmail) {
16651
+ return json({ error: "A customer with this email already exists" }, { status: 409 });
16652
+ }
16653
+ const dupCustPhone = await customerRepo.findOne({
16654
+ where: { phone, deleted: false }
16655
+ });
16656
+ if (dupCustPhone) {
16657
+ return json({ error: "A customer with this phone number already exists" }, { status: 409 });
16658
+ }
16659
+ let userId;
16660
+ const dupUser = await userRepo.findOne({
16661
+ where: { email, deleted: false }
16662
+ });
16663
+ if (dupUser) {
16664
+ userId = Number(dupUser.id);
16665
+ } else {
16666
+ const bcrypt2 = await import("bcryptjs");
16667
+ const hashedPassword = await bcrypt2.hash(rawPw, 10);
16668
+ const savedUser = await userRepo.save(
16669
+ userRepo.create({
16670
+ name,
16671
+ email,
16672
+ phone,
16673
+ password: hashedPassword,
16674
+ groupId: customerGroupId,
16675
+ adminAccess: false,
16676
+ blocked: false
16677
+ })
16678
+ );
16679
+ userId = Number(savedUser.id);
16680
+ }
16681
+ const { _password, ...customerFields } = body;
16682
+ const customerRepo2 = dataSource.getRepository(entityMap["customer"]);
16683
+ const persistCustomer = pickColumnUpdates(customerRepo2, {
16684
+ ...customerFields,
16685
+ name,
16686
+ email,
16687
+ phone,
16688
+ userId
16689
+ });
16690
+ sanitizeBodyForEntity(customerRepo2, persistCustomer);
16691
+ const savedCustomer = await customerRepo2.save(
16692
+ customerRepo2.create(persistCustomer)
16693
+ );
16694
+ if (entityMap["contacts"]) {
16695
+ const contactRepo = dataSource.getRepository(entityMap["contacts"]);
16696
+ const existingContact = await contactRepo.findOne({
16697
+ where: { email, deleted: false }
16698
+ });
16699
+ if (!existingContact) {
16700
+ await contactRepo.save(
16701
+ contactRepo.create({
16702
+ name,
16703
+ email,
16704
+ phone: phone || null,
16705
+ type: "customer"
16706
+ })
16707
+ );
16708
+ } else {
16709
+ const t = existingContact.type;
16710
+ if (t == null || t === "" || String(t).toLowerCase() !== "customer") {
16711
+ await contactRepo.update(
16712
+ existingContact.id,
16713
+ { type: "customer" }
16714
+ );
16715
+ }
16716
+ }
16717
+ }
16718
+ const scope = await resolveScope();
16719
+ let vendorId = null;
16720
+ if (scope.type === "vendor") {
16721
+ vendorId = scope.vendorId;
16722
+ } else if (scope.type === "all") {
16723
+ const n = Number(body.vendorId);
16724
+ if (Number.isFinite(n)) vendorId = n;
16725
+ }
16726
+ if (vendorId == null) {
16727
+ return json({ error: "Vendor scope required to link customer" }, { status: 400 });
16728
+ }
16729
+ const vcRepo = dataSource.getRepository(entity);
16730
+ const existingLink = await vcRepo.findOne({
16731
+ where: { customerId: savedCustomer.id }
16732
+ });
16733
+ if (!existingLink) {
16734
+ await vcRepo.save(
16735
+ vcRepo.create({
16736
+ customerId: savedCustomer.id,
16737
+ vendorId
16738
+ })
16739
+ );
16740
+ }
16741
+ return json(savedCustomer, { status: 201 });
16742
+ }
15725
16743
  if (resource === "media") {
15726
16744
  const b = body;
15727
16745
  const kind = b.kind === "folder" ? "folder" : "file";
@@ -15792,12 +16810,23 @@ function createCrudHandler(dataSource, entityMap, options) {
15792
16810
  if ((resource === "orders" || resource === "payments") && persistBody.contactId != null && entityMap.vendor_customers) {
15793
16811
  const scopeOrder = await resolveScope();
15794
16812
  const vendorId = resolveVendorIdForContactCheck(scopeOrder, persistBody);
16813
+ console.log("[ORDER CREATE] vendor check", {
16814
+ resource,
16815
+ contactId: persistBody.contactId,
16816
+ vendorId,
16817
+ scopeType: scopeOrder.type,
16818
+ persistBodyVendorId: persistBody.vendorId,
16819
+ hasVendorCustomers: !!entityMap.vendor_customers,
16820
+ hasCustomer: !!entityMap.customer,
16821
+ hasContacts: !!entityMap.contacts
16822
+ });
15795
16823
  const contactErr = await assertContactAllowedForVendorOrder(
15796
16824
  dataSource,
15797
16825
  entityMap,
15798
16826
  vendorId ?? NaN,
15799
16827
  Number(persistBody.contactId)
15800
16828
  );
16829
+ console.log("[ORDER CREATE] vendor check result:", contactErr);
15801
16830
  if (contactErr) {
15802
16831
  return json({ error: contactErr }, { status: 400 });
15803
16832
  }
@@ -15886,7 +16915,13 @@ function createCrudHandler(dataSource, entityMap, options) {
15886
16915
  }
15887
16916
  const scopeCreate = await resolveScope();
15888
16917
  await tryAssignSingleVendorOnAdminCreate(resource, scopeCreate, persistBody);
15889
- const vendorIdCheck = requireVendorIdForScopedCreate(resource, persistBody, scopeCreate, repo, body);
16918
+ const vendorIdCheck = requireVendorIdForScopedCreate(
16919
+ resource,
16920
+ persistBody,
16921
+ scopeCreate,
16922
+ repo,
16923
+ await vendorCreateContext(body)
16924
+ );
15890
16925
  if (!vendorIdCheck.ok) {
15891
16926
  return json({ error: vendorIdCheck.error }, { status: vendorIdCheck.status });
15892
16927
  }
@@ -16216,6 +17251,12 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16216
17251
  const { requireAuth, json, requireEntityPermission: reqPerm, getCms, getDeletedByUserId, getVendorScope } = options;
16217
17252
  const syncContactRowToErp = makeContactErpSync(dataSource, entityMap, getCms);
16218
17253
  const resolveScopeById = getVendorScope ?? (async () => ({ type: "all" }));
17254
+ function vendorScopeAccessJson(row, scope, resource) {
17255
+ const access = vendorScopeRowAccess(row, scope, resource);
17256
+ if (access === "ok") return null;
17257
+ if (access === "forbidden") return json({ error: "Forbidden" }, { status: 403 });
17258
+ return json({ message: "Not found" }, { status: 404 });
17259
+ }
16219
17260
  async function authz(req, resource, action) {
16220
17261
  const authError = await requireAuth(req);
16221
17262
  if (authError) return authError;
@@ -16259,9 +17300,8 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16259
17300
  where: { id: Number(id) },
16260
17301
  relations: ["rules"]
16261
17302
  });
16262
- if (!discount || !rowMatchesVendorScope(discount, scope2, resource)) {
16263
- return json({ message: "Not found" }, { status: 404 });
16264
- }
17303
+ const discountDenied = vendorScopeAccessJson(discount, scope2, resource);
17304
+ if (discountDenied) return discountDenied;
16265
17305
  const flatRules = discount.rules ?? [];
16266
17306
  const nestedRules = nestDiscountRules2(flatRules);
16267
17307
  let storeCurrency = "INR";
@@ -16299,9 +17339,8 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16299
17339
  where: { id: Number(id), deleted: false },
16300
17340
  relations: ["contact", "billingAddress", "shippingAddress", "items", "items.product", "items.product.collection", "payments"]
16301
17341
  });
16302
- if (!order || !rowMatchesVendorScope(order, scope2, resource)) {
16303
- return json({ message: "Not found" }, { status: 404 });
16304
- }
17342
+ const orderDenied = vendorScopeAccessJson(order, scope2, resource);
17343
+ if (orderDenied) return orderDenied;
16305
17344
  const relatedOrders = await repo.find({
16306
17345
  where: { parentOrderId: Number(id), deleted: false },
16307
17346
  order: { id: "ASC" }
@@ -16336,9 +17375,8 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16336
17375
  where: { id: Number(id), deleted: false },
16337
17376
  relations: ["order", "order.contact", "contact"]
16338
17377
  });
16339
- if (!payment || !rowMatchesVendorScope(payment, scope2, resource)) {
16340
- return json({ message: "Not found" }, { status: 404 });
16341
- }
17378
+ const paymentDenied = vendorScopeAccessJson(payment, scope2, resource);
17379
+ if (paymentDenied) return paymentDenied;
16342
17380
  const p = payment;
16343
17381
  const order = p.order;
16344
17382
  const orderContact = order?.contact;
@@ -16351,10 +17389,13 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16351
17389
  });
16352
17390
  }
16353
17391
  if (resource === "products") {
17392
+ const scope2 = await resolveScopeById();
16354
17393
  const product = await repo.findOne({
16355
17394
  where: { id: Number(id), deleted: false },
16356
17395
  relations: ["collection", "brand", "category", "attributes", "attributes.attribute"]
16357
17396
  });
17397
+ const productDenied = vendorScopeAccessJson(product, scope2, resource);
17398
+ if (productDenied) return productDenied;
16358
17399
  return product ? json(product) : json({ message: "Not found" }, { status: 404 });
16359
17400
  }
16360
17401
  if (resource === "vendor_customers" && entityMap.contacts) {
@@ -16363,9 +17404,8 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16363
17404
  where: { id: Number(id) },
16364
17405
  relations: ["contact"]
16365
17406
  });
16366
- if (!row || !rowMatchesVendorScope(row, scope2, resource)) {
16367
- return json({ message: "Not found" }, { status: 404 });
16368
- }
17407
+ const vcDenied = vendorScopeAccessJson(row, scope2, resource);
17408
+ if (vcDenied) return vcDenied;
16369
17409
  const contact = row.contact;
16370
17410
  return json({
16371
17411
  ...row,
@@ -16385,7 +17425,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16385
17425
  const scope = await resolveScopeById();
16386
17426
  const idWhere = entityHasSoftDelete(repo) ? { id: Number(id), deleted: false } : { id: Number(id) };
16387
17427
  const item = await repo.findOne({ where: idWhere });
16388
- if (!item || resourceUsesVendorScope(resource) && !rowMatchesVendorScope(item, scope, resource)) {
17428
+ if (resourceUsesVendorScope(resource)) {
17429
+ const itemDenied = vendorScopeAccessJson(item, scope, resource);
17430
+ if (itemDenied) return itemDenied;
17431
+ } else if (!item) {
16389
17432
  return json({ message: "Not found" }, { status: 404 });
16390
17433
  }
16391
17434
  return json(item);
@@ -16649,9 +17692,8 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16649
17692
  const existing = await repo.findOne({
16650
17693
  where: { id: numericId }
16651
17694
  });
16652
- if (!existing || !rowMatchesVendorScope(existing, scopePut2, resource)) {
16653
- return json({ message: "Not found" }, { status: 404 });
16654
- }
17695
+ const discountPutDenied = vendorScopeAccessJson(existing, scopePut2, resource);
17696
+ if (discountPutDenied) return discountPutDenied;
16655
17697
  const updatePayload2 = pickColumnUpdates(repo, rawBody);
16656
17698
  delete updatePayload2.vendorId;
16657
17699
  if (!rawBody.isAutomatic && rawBody.couponCode != null && String(rawBody.couponCode).trim() !== "") {
@@ -16685,9 +17727,12 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16685
17727
  if (resourceUsesVendorScope(resource)) {
16686
17728
  const idWhereCheck = entityHasSoftDelete(repo) ? { id: numericId, deleted: false } : { id: numericId };
16687
17729
  const existingScope = await repo.findOne({ where: idWhereCheck });
16688
- if (!existingScope || !rowMatchesVendorScope(existingScope, scopePut, resource)) {
16689
- return json({ message: "Not found" }, { status: 404 });
16690
- }
17730
+ const scopePutDenied = vendorScopeAccessJson(
17731
+ existingScope,
17732
+ scopePut,
17733
+ resource
17734
+ );
17735
+ if (scopePutDenied) return scopePutDenied;
16691
17736
  }
16692
17737
  const updatePayload = rawBody && typeof rawBody === "object" ? pickColumnUpdates(repo, rawBody) : {};
16693
17738
  if (resourceUsesVendorScope(resource)) {
@@ -16847,11 +17892,17 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16847
17892
  }
16848
17893
  const repo = dataSource.getRepository(entity);
16849
17894
  const numericId = Number(id);
17895
+ const scopeDelete = await resolveScopeById();
16850
17896
  if (entityHasSoftDelete(repo)) {
16851
17897
  const existing = await repo.findOne({
16852
17898
  where: { id: numericId, deleted: false }
16853
17899
  });
16854
- if (!existing) return json({ message: "Not found" }, { status: 404 });
17900
+ if (resourceUsesVendorScope(resource)) {
17901
+ const deleteDenied = vendorScopeAccessJson(existing, scopeDelete, resource);
17902
+ if (deleteDenied) return deleteDenied;
17903
+ } else if (!existing) {
17904
+ return json({ message: "Not found" }, { status: 404 });
17905
+ }
16855
17906
  if (resource === "contacts") {
16856
17907
  const result2 = await repo.delete(numericId);
16857
17908
  if (result2.affected === 0) return json({ message: "Not found" }, { status: 404 });
@@ -16886,6 +17937,17 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
16886
17937
  await repo.update(numericId, buildSoftDeletePayload(repo.metadata, deletedBy));
16887
17938
  return json({ message: "Deleted successfully" }, { status: 200 });
16888
17939
  }
17940
+ if (resourceUsesVendorScope(resource)) {
17941
+ const existingHard = await repo.findOne({
17942
+ where: { id: numericId }
17943
+ });
17944
+ const hardDeleteDenied = vendorScopeAccessJson(
17945
+ existingHard,
17946
+ scopeDelete,
17947
+ resource
17948
+ );
17949
+ if (hardDeleteDenied) return hardDeleteDenied;
17950
+ }
16889
17951
  const result = await repo.delete(numericId);
16890
17952
  if (result.affected === 0) return json({ message: "Not found" }, { status: 404 });
16891
17953
  return json({ message: "Deleted successfully" }, { status: 200 });
@@ -17882,7 +18944,6 @@ function createAdminRolesHandlers(config) {
17882
18944
 
17883
18945
  // src/api/vendor-handlers.ts
17884
18946
  init_vendor_scope();
17885
- init_email_queue();
17886
18947
  init_vendor_invite_status();
17887
18948
  import { In as In5 } from "typeorm";
17888
18949
  function slugify(input) {
@@ -17896,7 +18957,6 @@ function createVendorOnboardHandlers(config) {
17896
18957
  getSessionUser,
17897
18958
  baseUrl,
17898
18959
  getCms,
17899
- getCompanyDetails,
17900
18960
  hashPassword,
17901
18961
  minPasswordLength = 6
17902
18962
  } = config;
@@ -17925,22 +18985,30 @@ function createVendorOnboardHandlers(config) {
17925
18985
  }
17926
18986
  return { user: u, vendorId };
17927
18987
  }
17928
- async function trySendInviteEmail(toEmail, inviteLink, inviteeName) {
17929
- if (!getCms) return;
18988
+ async function trySendVendorOnboardEmails(input) {
18989
+ if (!getCms) return false;
17930
18990
  try {
17931
- const cms = await getCms();
17932
- const companyDetails = getCompanyDetails ? await getCompanyDetails() : {};
17933
- await queueEmail(cms, {
17934
- to: toEmail,
17935
- templateName: "invite",
17936
- ctx: {
17937
- inviteLink,
17938
- email: toEmail,
17939
- inviteeName: inviteeName.trim(),
17940
- companyDetails: companyDetails ?? {}
18991
+ const { ownerEmailSent } = await sendVendorOnboardEmails(
18992
+ {
18993
+ vendorName: input.vendorName,
18994
+ vendorSlug: input.vendorSlug,
18995
+ ownerName: input.ownerName,
18996
+ ownerEmail: input.ownerEmail,
18997
+ activation: input.activation,
18998
+ inviteLink: input.inviteLink,
18999
+ signInLink: `${baseUrl.replace(/\/$/, "")}/admin`,
19000
+ kind: input.kind ?? "vendor_onboard",
19001
+ sendToOwner: input.sendToOwner
19002
+ },
19003
+ {
19004
+ getDataSource: async () => dataSource,
19005
+ entityMap: { configs: entityMap.configs },
19006
+ getCms
17941
19007
  }
17942
- });
19008
+ );
19009
+ return ownerEmailSent;
17943
19010
  } catch {
19011
+ return false;
17944
19012
  }
17945
19013
  }
17946
19014
  return {
@@ -17960,7 +19028,7 @@ function createVendorOnboardHandlers(config) {
17960
19028
  return json({ error: "vendor.name, user.name, and user.email are required" }, { status: 400 });
17961
19029
  }
17962
19030
  const activation = body.activation === "password" ? "password" : "invite";
17963
- const sendInviteEmail = body.sendInviteEmail !== false;
19031
+ const sendOwnerEmail = body.sendOwnerEmail !== false && body.sendInviteEmail !== false;
17964
19032
  let ownerPasswordHash = null;
17965
19033
  if (activation === "password") {
17966
19034
  const plain = body.user?.password?.trim();
@@ -18048,12 +19116,29 @@ function createVendorOnboardHandlers(config) {
18048
19116
  if (activation === "invite") {
18049
19117
  const emailToken = Buffer.from(result.user.email).toString("base64");
18050
19118
  inviteLink = `${baseUrl}/admin/invite?token=${emailToken}`;
18051
- if (sendInviteEmail) {
18052
- await trySendInviteEmail(result.user.email, inviteLink, result.user.name ?? "");
18053
- emailSent = true;
18054
- }
18055
19119
  }
18056
- const message = activation === "password" ? "Vendor onboarded successfully. Owner can sign in with the password you set." : emailSent ? "Vendor onboarded successfully. Invite email sent." : sendInviteEmail ? "Vendor onboarded successfully. Invite link created (email may not have been sent \u2014 check email plugin)." : "Vendor onboarded successfully. Share the invite link with the owner.";
19120
+ if (sendOwnerEmail) {
19121
+ emailSent = await trySendVendorOnboardEmails({
19122
+ vendorName,
19123
+ vendorSlug: slug,
19124
+ ownerName: userName,
19125
+ ownerEmail: userEmail,
19126
+ activation,
19127
+ inviteLink,
19128
+ sendToOwner: true
19129
+ });
19130
+ } else if (getCms) {
19131
+ await trySendVendorOnboardEmails({
19132
+ vendorName,
19133
+ vendorSlug: slug,
19134
+ ownerName: userName,
19135
+ ownerEmail: userEmail,
19136
+ activation,
19137
+ inviteLink,
19138
+ sendToOwner: false
19139
+ });
19140
+ }
19141
+ const message = activation === "password" ? emailSent ? "Vendor onboarded successfully. Welcome email sent to the owner." : sendOwnerEmail ? "Vendor onboarded successfully. Owner can sign in with the password you set (welcome email may not have been sent \u2014 check email plugin)." : "Vendor onboarded successfully. Owner can sign in with the password you set." : emailSent ? "Vendor onboarded successfully. Invite email sent." : sendOwnerEmail ? "Vendor onboarded successfully. Invite link created (email may not have been sent \u2014 check email plugin)." : "Vendor onboarded successfully. Share the invite link with the owner.";
18057
19142
  return json(
18058
19143
  {
18059
19144
  message,
@@ -18125,7 +19210,7 @@ function createVendorOnboardHandlers(config) {
18125
19210
  const gated = await gateVendorTeam();
18126
19211
  if (gated instanceof Response) return gated;
18127
19212
  const { vendorId, user: actor } = gated;
18128
- if (!entityMap.users || !entityMap.vendor_users || !entityMap.user_groups) {
19213
+ if (!entityMap.users || !entityMap.vendor_users || !entityMap.user_groups || !entityMap.vendors) {
18129
19214
  return json({ error: "Vendor entities not configured" }, { status: 500 });
18130
19215
  }
18131
19216
  try {
@@ -18136,7 +19221,7 @@ function createVendorOnboardHandlers(config) {
18136
19221
  return json({ error: "name and email are required" }, { status: 400 });
18137
19222
  }
18138
19223
  const activation = body.activation === "password" ? "password" : "invite";
18139
- const sendInviteEmail = body.sendInviteEmail !== false;
19224
+ const sendOwnerEmail = body.sendOwnerEmail !== false && body.sendInviteEmail !== false;
18140
19225
  let ownerPasswordHash = null;
18141
19226
  if (activation === "password") {
18142
19227
  const plain = body.user?.password?.trim();
@@ -18222,17 +19307,33 @@ function createVendorOnboardHandlers(config) {
18222
19307
  }
18223
19308
  return newUser;
18224
19309
  });
19310
+ const vendorRow = await dataSource.getRepository(entityMap.vendors).findOne({
19311
+ where: { id: vendorId, deleted: false }
19312
+ });
19313
+ const vendorName = String(vendorRow?.name ?? "Vendor store");
19314
+ const vendorSlug = String(vendorRow?.slug ?? "");
18225
19315
  let inviteLink;
19316
+ let emailSent = false;
18226
19317
  if (activation === "invite") {
18227
19318
  const emailToken = Buffer.from(result.email).toString("base64");
18228
19319
  inviteLink = `${baseUrl}/admin/invite?token=${emailToken}`;
18229
- if (sendInviteEmail) {
18230
- await trySendInviteEmail(result.email, inviteLink, result.name ?? "");
18231
- }
19320
+ }
19321
+ if (sendOwnerEmail || getCms) {
19322
+ emailSent = await trySendVendorOnboardEmails({
19323
+ vendorName,
19324
+ vendorSlug,
19325
+ ownerName: userName,
19326
+ ownerEmail: userEmail,
19327
+ activation,
19328
+ inviteLink,
19329
+ kind: "team_invite",
19330
+ sendToOwner: sendOwnerEmail
19331
+ });
18232
19332
  }
18233
19333
  return json(
18234
19334
  {
18235
- message: "Team member added",
19335
+ message: emailSent ? "Team member added. Invitation email sent." : sendOwnerEmail ? "Team member added (email may not have been sent \u2014 check email plugin)." : "Team member added",
19336
+ emailSent,
18236
19337
  user: { id: result.id, name: result.name, email: result.email },
18237
19338
  inviteLink
18238
19339
  },
@@ -18456,6 +19557,10 @@ function createCmsApiHandler(config) {
18456
19557
  getVendorScope: async () => {
18457
19558
  const u = await hydrateVendorSessionUser(dataSource, await resolveSessionUser());
18458
19559
  return resolveVendorScopeFromSessionUser(u ?? null);
19560
+ },
19561
+ getHydratedSessionUser: async () => {
19562
+ const u = await hydrateVendorSessionUser(dataSource, await resolveSessionUser());
19563
+ return u ?? null;
18459
19564
  }
18460
19565
  } : {}
18461
19566
  };
@@ -18476,7 +19581,6 @@ function createCmsApiHandler(config) {
18476
19581
  getSessionUser,
18477
19582
  baseUrl: vendorOnboardBaseUrl,
18478
19583
  getCms,
18479
- getCompanyDetails: config.getCompanyDetails,
18480
19584
  hashPassword: userAuth?.hashPassword,
18481
19585
  minPasswordLength: 6
18482
19586
  });
@@ -19402,14 +20506,72 @@ function createCmsApiHandler(config) {
19402
20506
  const orderRepo = dataSource.getRepository(entityMap.orders);
19403
20507
  const order = await orderRepo.findOne({
19404
20508
  where: { qrToken: token, deleted: false },
19405
- relations: ["contact", "items", "items.product"]
20509
+ relations: ["contact", "items", "items.product", "items.product.collection"]
20510
+ });
20511
+ if (!order) return new Response(
20512
+ `<html><body style="font-family:sans-serif;text-align:center;padding:60px"><h2>Order not found</h2><p style="color:#6b7280">This QR code is invalid or the order has been removed.</p></body></html>`,
20513
+ { status: 404, headers: { "Content-Type": "text/html; charset=utf-8" } }
20514
+ );
20515
+ const { renderOrderTrackingPage: renderOrderTrackingPage2 } = await Promise.resolve().then(() => (init_OrderTrackPage(), OrderTrackPage_exports));
20516
+ const html = renderOrderTrackingPage2(order);
20517
+ return new Response(html, {
20518
+ status: 200,
20519
+ headers: { "Content-Type": "text/html; charset=utf-8" }
19406
20520
  });
19407
- if (!order) return config.json({ error: "Order not found" }, { status: 404 });
19408
- return config.json(order);
19409
20521
  } catch (err) {
19410
20522
  const message = err instanceof Error ? err.message : String(err);
19411
- return config.json({ error: message }, { status: 500 });
20523
+ return new Response(
20524
+ `<html><body style="font-family:sans-serif;text-align:center;padding:60px"><h2>Something went wrong</h2><p style="color:#6b7280">${message}</p></body></html>`,
20525
+ { status: 500, headers: { "Content-Type": "text/html; charset=utf-8" } }
20526
+ );
20527
+ }
20528
+ }
20529
+ if (path2[0] === "customer_contacts" && entityMap["customer_contacts"]) {
20530
+ const a = await config.requireAuth(req);
20531
+ if (a) return a;
20532
+ const pe = await requireEntityPermissionEffective(req, "vendor_customers", "read");
20533
+ if (pe) return pe;
20534
+ if (path2.length === 1 && m === "GET") {
20535
+ const { searchParams } = new URL(req.url);
20536
+ const customerId = searchParams.get("customerId");
20537
+ const limit = Math.min(Number(searchParams.get("limit") || "200"), 500);
20538
+ if (!customerId || !Number.isFinite(Number(customerId))) {
20539
+ return config.json({ error: "customerId is required" }, { status: 400 });
20540
+ }
20541
+ const repo = dataSource.getRepository(entityMap["customer_contacts"]);
20542
+ const rows = await repo.find({
20543
+ where: { customerId: Number(customerId) },
20544
+ relations: ["contact"],
20545
+ take: limit,
20546
+ order: { id: "ASC" }
20547
+ });
20548
+ return config.json({ data: rows, total: rows.length });
20549
+ }
20550
+ if (path2.length === 1 && m === "POST") {
20551
+ const pe2 = await requireEntityPermissionEffective(req, "vendor_customers", "create");
20552
+ if (pe2) return pe2;
20553
+ const body = await req.json();
20554
+ const customerId = Number(body.customerId);
20555
+ const contactId = Number(body.contactId);
20556
+ if (!Number.isFinite(customerId) || customerId <= 0) {
20557
+ return config.json({ error: "customerId is required" }, { status: 400 });
20558
+ }
20559
+ if (!Number.isFinite(contactId) || contactId <= 0) {
20560
+ return config.json({ error: "contactId is required" }, { status: 400 });
20561
+ }
20562
+ const repo = dataSource.getRepository(entityMap["customer_contacts"]);
20563
+ const existing = await repo.findOne({
20564
+ where: { customerId, contactId }
20565
+ });
20566
+ if (existing) {
20567
+ return config.json(existing, { status: 200 });
20568
+ }
20569
+ const created = await repo.save(
20570
+ repo.create({ customerId, contactId })
20571
+ );
20572
+ return config.json(created, { status: 201 });
19412
20573
  }
20574
+ return config.json({ error: "Method not allowed" }, { status: 405 });
19413
20575
  }
19414
20576
  if (path2.length === 0) return config.json({ error: "Not found" }, { status: 404 });
19415
20577
  const resource = resolveResource(path2[0]);
@@ -19519,6 +20681,8 @@ function createStorefrontApiHandler(config) {
19519
20681
  const collectionRepo = () => dataSource.getRepository(entityMap.collections);
19520
20682
  const groupRepo = () => dataSource.getRepository(entityMap.user_groups);
19521
20683
  const configRepo = () => dataSource.getRepository(entityMap.configs);
20684
+ const customerRepo = () => dataSource.getRepository(entityMap.customer);
20685
+ const customerContactsRepo = () => dataSource.getRepository(entityMap.customer_contacts);
19522
20686
  const CART_CHECKOUT_RELATIONS = ["items", "items.product", "items.product.taxes", "items.product.taxes.tax"];
19523
20687
  function resolveSingleVendorIdFromCart(cart) {
19524
20688
  const vendorIds = /* @__PURE__ */ new Set();
@@ -19720,6 +20884,142 @@ function createStorefrontApiHandler(config) {
19720
20884
  await syncContactToErp(created);
19721
20885
  return { id: created.id };
19722
20886
  }
20887
+ function parseCheckoutContactDetails(b) {
20888
+ const src = b.contact && typeof b.contact === "object" && !Array.isArray(b.contact) ? b.contact : b;
20889
+ const name = String(src.name ?? "").trim();
20890
+ const email = String(src.email ?? "").trim().toLowerCase();
20891
+ const phone = src.phone != null && src.phone !== "" ? String(src.phone).trim() : null;
20892
+ if (!name || !email) return null;
20893
+ return { name, email, phone };
20894
+ }
20895
+ async function ensureCustomerContactLink(customerId, contactId) {
20896
+ if (!entityMap.customer_contacts) return;
20897
+ const existing = await customerContactsRepo().findOne({
20898
+ where: { customerId, contactId }
20899
+ });
20900
+ if (!existing) {
20901
+ await customerContactsRepo().save(
20902
+ customerContactsRepo().create({ customerId, contactId })
20903
+ );
20904
+ }
20905
+ }
20906
+ async function resolveCustomerCheckoutContact(b, sessionUserId) {
20907
+ if (!entityMap.customer) {
20908
+ return { ok: false, status: 503, message: "Customer not configured" };
20909
+ }
20910
+ const payloadUserId = intFromBody(b.userId) ?? sessionUserId;
20911
+ if (payloadUserId !== sessionUserId) {
20912
+ return { ok: false, status: 401, message: "Unauthorized" };
20913
+ }
20914
+ const details = parseCheckoutContactDetails(b);
20915
+ if (!details) {
20916
+ return { ok: false, status: 400, message: "contact name and email required" };
20917
+ }
20918
+ const customer = await customerRepo().findOne({
20919
+ where: { userId: payloadUserId, deleted: false }
20920
+ });
20921
+ if (!customer) {
20922
+ return { ok: false, status: 404, message: "Customer not found" };
20923
+ }
20924
+ const customerId = customer.id;
20925
+ let contact = await contactRepo().findOne({
20926
+ where: { email: details.email, deleted: false }
20927
+ });
20928
+ if (!contact) {
20929
+ contact = await contactRepo().save(
20930
+ contactRepo().create({
20931
+ name: details.name,
20932
+ email: details.email,
20933
+ phone: details.phone,
20934
+ type: "customer",
20935
+ userId: null,
20936
+ deleted: false
20937
+ })
20938
+ );
20939
+ await syncContactToErp(contact);
20940
+ } else {
20941
+ await contactRepo().update(contact.id, {
20942
+ name: details.name,
20943
+ phone: details.phone ?? contact.phone
20944
+ });
20945
+ }
20946
+ const contactId = contact.id;
20947
+ await ensureCustomerContactLink(customerId, contactId);
20948
+ return { ok: true, contactId, customerId };
20949
+ }
20950
+ async function loadBuyerCart(sessionUserId) {
20951
+ const buyerContact = await ensureContactForUser(sessionUserId);
20952
+ if (!buyerContact) return null;
20953
+ return cartRepo().findOne({
20954
+ where: { contactId: buyerContact.id },
20955
+ relations: [...CART_CHECKOUT_RELATIONS]
20956
+ });
20957
+ }
20958
+ async function resolveCheckoutContactAndCart(b, req, sessionUid) {
20959
+ if (Number.isFinite(sessionUid)) {
20960
+ const useCustomerFlow = Boolean(entityMap.customer && entityMap.customer_contacts) && parseCheckoutContactDetails(b) != null;
20961
+ if (useCustomerFlow) {
20962
+ const resolved = await resolveCustomerCheckoutContact(b, sessionUid);
20963
+ if (!resolved.ok) {
20964
+ return { ok: false, response: json({ error: resolved.message }, { status: resolved.status }) };
20965
+ }
20966
+ const cart3 = await loadBuyerCart(sessionUid);
20967
+ return { ok: true, contactId: resolved.contactId, cart: cart3 };
20968
+ }
20969
+ const contact2 = await ensureContactForUser(sessionUid);
20970
+ if (!contact2) {
20971
+ return { ok: false, response: json({ error: "Contact required" }, { status: 400 }) };
20972
+ }
20973
+ const cart2 = await cartRepo().findOne({
20974
+ where: { contactId: contact2.id },
20975
+ relations: [...CART_CHECKOUT_RELATIONS]
20976
+ });
20977
+ return { ok: true, contactId: contact2.id, cart: cart2 };
20978
+ }
20979
+ const details = parseCheckoutContactDetails(b);
20980
+ const email = details?.email ?? String(b.email ?? "").trim().toLowerCase();
20981
+ const name = details?.name ?? String(b.name ?? "").trim();
20982
+ const phone = details?.phone ?? (b.phone != null && b.phone !== "" ? String(b.phone).trim() : null);
20983
+ if (!email || !name) {
20984
+ return {
20985
+ ok: false,
20986
+ response: json({ error: "name and email required for guest checkout" }, { status: 400 })
20987
+ };
20988
+ }
20989
+ let contact = await contactRepo().findOne({ where: { email, deleted: false } });
20990
+ if (contact && contact.userId != null) {
20991
+ return { ok: false, response: json({ error: "Please sign in to complete checkout" }, { status: 400 }) };
20992
+ }
20993
+ if (!contact) {
20994
+ contact = await contactRepo().save(
20995
+ contactRepo().create({
20996
+ name,
20997
+ email,
20998
+ phone,
20999
+ userId: null,
21000
+ deleted: false
21001
+ })
21002
+ );
21003
+ } else {
21004
+ await contactRepo().update(contact.id, {
21005
+ name,
21006
+ phone: phone ?? contact.phone
21007
+ });
21008
+ }
21009
+ const contactId = contact.id;
21010
+ const guestForErp = await contactRepo().findOne({ where: { id: contactId } });
21011
+ if (guestForErp) await syncContactToErp(guestForErp);
21012
+ const cookies = parseCookies(req.headers.get("cookie"));
21013
+ const guestToken = cookies[cookieName];
21014
+ if (!guestToken) {
21015
+ return { ok: false, response: json({ error: "Cart not found" }, { status: 400 }) };
21016
+ }
21017
+ const cart = await cartRepo().findOne({
21018
+ where: { guestToken },
21019
+ relations: [...CART_CHECKOUT_RELATIONS]
21020
+ });
21021
+ return { ok: true, contactId, cart };
21022
+ }
19723
21023
  async function getOrCreateCart(req) {
19724
21024
  const u = await getSessionUser();
19725
21025
  const uid = u?.id ? parseInt(String(u.id), 10) : NaN;
@@ -20539,50 +21839,9 @@ function createStorefrontApiHandler(config) {
20539
21839
  if (capOrd) return capOrd;
20540
21840
  const u = await getSessionUser();
20541
21841
  const uid = u?.id ? parseInt(String(u.id), 10) : NaN;
20542
- let contactId;
20543
- let cart;
20544
- if (Number.isFinite(uid)) {
20545
- const contact = await ensureContactForUser(uid);
20546
- if (!contact) return json({ error: "Contact required" }, { status: 400 });
20547
- contactId = contact.id;
20548
- cart = await cartRepo().findOne({
20549
- where: { contactId },
20550
- relations: [...CART_CHECKOUT_RELATIONS]
20551
- });
20552
- } else {
20553
- const email = String(b.email ?? "").trim();
20554
- const name = String(b.name ?? "").trim();
20555
- if (!email || !name) return json({ error: "name and email required for guest checkout" }, { status: 400 });
20556
- let contact = await contactRepo().findOne({ where: { email, deleted: false } });
20557
- if (contact && contact.userId != null) {
20558
- return json({ error: "Please sign in to complete checkout" }, { status: 400 });
20559
- }
20560
- if (!contact) {
20561
- contact = await contactRepo().save(
20562
- contactRepo().create({
20563
- name,
20564
- email,
20565
- phone: b.phone != null && b.phone !== "" ? String(b.phone) : null,
20566
- userId: null,
20567
- deleted: false
20568
- })
20569
- );
20570
- } else if (name)
20571
- await contactRepo().update(contact.id, {
20572
- name,
20573
- phone: b.phone != null && b.phone !== "" ? String(b.phone) : contact.phone
20574
- });
20575
- contactId = contact.id;
20576
- const guestForErp = await contactRepo().findOne({ where: { id: contactId } });
20577
- if (guestForErp) await syncContactToErp(guestForErp);
20578
- const cookies = parseCookies(req.headers.get("cookie"));
20579
- const guestToken = cookies[cookieName];
20580
- if (!guestToken) return json({ error: "Cart not found" }, { status: 400 });
20581
- cart = await cartRepo().findOne({
20582
- where: { guestToken },
20583
- relations: [...CART_CHECKOUT_RELATIONS]
20584
- });
20585
- }
21842
+ const checkoutIdentity = await resolveCheckoutContactAndCart(b, req, uid);
21843
+ if (!checkoutIdentity.ok) return checkoutIdentity.response;
21844
+ const { contactId, cart } = checkoutIdentity;
20586
21845
  if (!cart || !(cart.items || []).length) {
20587
21846
  return json({ error: "Cart is empty" }, { status: 400 });
20588
21847
  }
@@ -20645,50 +21904,9 @@ function createStorefrontApiHandler(config) {
20645
21904
  if (capChk) return capChk;
20646
21905
  const u = await getSessionUser();
20647
21906
  const uid = u?.id ? parseInt(String(u.id), 10) : NaN;
20648
- let contactId;
20649
- let cart;
20650
- if (Number.isFinite(uid)) {
20651
- const contact = await ensureContactForUser(uid);
20652
- if (!contact) return json({ error: "Contact required" }, { status: 400 });
20653
- contactId = contact.id;
20654
- cart = await cartRepo().findOne({
20655
- where: { contactId },
20656
- relations: [...CART_CHECKOUT_RELATIONS]
20657
- });
20658
- } else {
20659
- const email = String(b.email ?? "").trim();
20660
- const name = String(b.name ?? "").trim();
20661
- if (!email || !name) return json({ error: "name and email required for guest checkout" }, { status: 400 });
20662
- let contact = await contactRepo().findOne({ where: { email, deleted: false } });
20663
- if (contact && contact.userId != null) {
20664
- return json({ error: "Please sign in to complete checkout" }, { status: 400 });
20665
- }
20666
- if (!contact) {
20667
- contact = await contactRepo().save(
20668
- contactRepo().create({
20669
- name,
20670
- email,
20671
- phone: b.phone != null && b.phone !== "" ? String(b.phone) : null,
20672
- userId: null,
20673
- deleted: false
20674
- })
20675
- );
20676
- } else if (name)
20677
- await contactRepo().update(contact.id, {
20678
- name,
20679
- phone: b.phone != null && b.phone !== "" ? String(b.phone) : contact.phone
20680
- });
20681
- contactId = contact.id;
20682
- const guestForErp2 = await contactRepo().findOne({ where: { id: contactId } });
20683
- if (guestForErp2) await syncContactToErp(guestForErp2);
20684
- const cookies = parseCookies(req.headers.get("cookie"));
20685
- const guestToken = cookies[cookieName];
20686
- if (!guestToken) return json({ error: "Cart not found" }, { status: 400 });
20687
- cart = await cartRepo().findOne({
20688
- where: { guestToken },
20689
- relations: [...CART_CHECKOUT_RELATIONS]
20690
- });
20691
- }
21907
+ const checkoutIdentity = await resolveCheckoutContactAndCart(b, req, uid);
21908
+ if (!checkoutIdentity.ok) return checkoutIdentity.response;
21909
+ const { contactId, cart } = checkoutIdentity;
20692
21910
  if (!cart || !(cart.items || []).length) {
20693
21911
  return json({ error: "Cart is empty" }, { status: 400 });
20694
21912
  }
@@ -20928,6 +22146,8 @@ export {
20928
22146
  Contact,
20929
22147
  Currency,
20930
22148
  CurrencyExchange,
22149
+ Customer,
22150
+ Customer_Contacts,
20931
22151
  DEFAULT_ADMIN_NAV,
20932
22152
  Discount,
20933
22153
  DiscountRules,
@@ -20963,11 +22183,13 @@ export {
20963
22183
  RBAC_ADMIN_ONLY_ENTITIES,
20964
22184
  RssArticle,
20965
22185
  RssFeed,
22186
+ SUPER_ADMIN_GROUP_ID,
20966
22187
  Seo,
20967
22188
  Tag,
20968
22189
  Tax,
20969
22190
  User,
20970
22191
  UserGroup,
22192
+ VENDOR_ADMIN_GROUP_ID,
20971
22193
  VENDOR_OWNER_GROUP_NAME,
20972
22194
  VENDOR_SCOPED_STORE_ENTITIES,
20973
22195
  VENDOR_STORE_RBAC_ENTITIES,
@@ -21045,6 +22267,7 @@ export {
21045
22267
  getPublicSettingsGroup,
21046
22268
  getRequiredPermission,
21047
22269
  getRssArticleSummaryFromItem,
22270
+ getStorefrontNextAuthOptions,
21048
22271
  hasEntityPermission,
21049
22272
  hashOtpCode,
21050
22273
  hydrateVendorSessionUser,
@@ -21055,7 +22278,9 @@ export {
21055
22278
  isPlatformAdministrator,
21056
22279
  isPublicMethod,
21057
22280
  isRbacDebugEnabled,
22281
+ isSuperAdmin,
21058
22282
  isSuperAdminGroupName,
22283
+ isVendorAdmin,
21059
22284
  isVendorGroupName,
21060
22285
  isVendorOwner,
21061
22286
  isVendorPortalUser,
@@ -21099,6 +22324,7 @@ export {
21099
22324
  queueOrderPlacedEmails,
21100
22325
  queuePlugin,
21101
22326
  queueSms,
22327
+ queueVendorOnboardEmails,
21102
22328
  rateLimitCheckoutPost,
21103
22329
  rateLimitKeyForApiRequest,
21104
22330
  rateLimitPublicApiIfNeeded,
@@ -21119,6 +22345,7 @@ export {
21119
22345
  seedAdministratorPermissions,
21120
22346
  seedDefaultAdmin,
21121
22347
  sendOrderPlacedEmailsAfterConfirmation,
22348
+ sendVendorOnboardEmails,
21122
22349
  serializeEmailRecipients,
21123
22350
  sessionHasEntityAccess,
21124
22351
  shouldRateLimitPublicWrite,