@infuro/cms-core 1.0.66 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.cjs +94 -21
- package/dist/admin.js +94 -21
- package/dist/api.cjs +36 -36
- package/dist/api.js +3 -3
- package/dist/auth.cjs +51 -51
- package/dist/auth.js +3 -3
- package/dist/{chunk-6DBDJ4VD.js → chunk-2ISSXYBZ.js} +2 -2
- package/dist/{chunk-MVHDC3XF.js → chunk-5NOZSG6J.js} +22 -11
- package/dist/{chunk-QYRXLURF.cjs → chunk-BVLN75LP.cjs} +443 -78
- package/dist/{chunk-T33KU5G5.js → chunk-GLLCLRCQ.js} +394 -29
- package/dist/{chunk-J7FMZK66.cjs → chunk-O4AFPDQ4.cjs} +22 -11
- package/dist/{chunk-4U6DATGZ.cjs → chunk-OV5TRZET.cjs} +7 -7
- package/dist/{chunk-KM2I6AFP.cjs → chunk-SS3K7OIM.cjs} +9 -9
- package/dist/{chunk-NR44CK5E.js → chunk-ZY64VJMS.js} +1 -1
- package/dist/index.cjs +269 -265
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +6 -6
- package/dist/migrations/1783300000000-CreateOrderAssigneesTable.ts +43 -0
- package/dist/{order-assignees-handlers-NPKD64P6.cjs → order-assignees-handlers-KF7RMTV5.cjs} +77 -8
- package/dist/{order-assignees-handlers-LKMAGLG6.js → order-assignees-handlers-L3RVKUBS.js} +77 -8
- package/dist/{order-completion-otp-handlers-NK65LOLV.cjs → order-completion-otp-handlers-DZAXK4GQ.cjs} +67 -13
- package/dist/{order-completion-otp-handlers-LFRHXWK4.js → order-completion-otp-handlers-HFGCPC4O.js} +67 -13
- package/dist/{rbac-debug-db-5R6XFPSV.js → rbac-debug-db-DFZWZ6GV.js} +1 -1
- package/dist/{rbac-debug-db-JKK2MCWF.cjs → rbac-debug-db-KWV7D5PQ.cjs} +2 -2
- package/package.json +1 -1
|
@@ -10,9 +10,9 @@ import { isErpIntegrationEnabled } from './chunk-JC6DLWTE.js';
|
|
|
10
10
|
import { mergeEmailLayoutCompanyDetails } from './chunk-YRCKEGL2.js';
|
|
11
11
|
import { getSmsTemplateDefault, SMS_MESSAGE_TEMPLATE_DEFAULTS } from './chunk-MQBT33IV.js';
|
|
12
12
|
import { EVENT_ORDER_MESSAGE_TEMPLATE_DEFAULTS, EVENT_ORDER_TEMPLATE_KEY, EVENT_ORDER_TEMPLATE_VARIABLES } from './chunk-AYERBA7I.js';
|
|
13
|
-
import { ensureCustomerRecord, linkUnclaimedContactToUser, ensureCustomerForUser, canManageRoles, sessionHasEntityAccess } from './chunk-
|
|
13
|
+
import { ensureCustomerRecord, linkUnclaimedContactToUser, ensureCustomerForUser, canManageRoles, sessionHasEntityAccess } from './chunk-ZY64VJMS.js';
|
|
14
14
|
import { retireSoftDeletedUniqueValue, activeUniqueValueExists } from './chunk-DBPSJYLZ.js';
|
|
15
|
-
import { permissionRowsToRecord, logRbac, isSuperAdmin, vendorPortalFlagsFromUser, VENDOR_SCOPED_STORE_ENTITIES, isVendorPortalUser, getPermissionableEntityKeys, VENDOR_STORE_RBAC_ENTITIES, isSuperAdminGroupName, VENDOR_RBAC_ENTITIES, VENDOR_VIEWER_ROLE_NAME, DEFAULT_VENDOR_ROLE_DEFS, VENDOR_GROUP_NAME, resolveVendorScopeFromSessionUser, canManageVendorRoles, isPlatformAdministrator, canManageVendorTeam, resolveDisabledMultiVendorScope, logEntityAccessDecision, explainSessionEntityAccess } from './chunk-
|
|
15
|
+
import { permissionRowsToRecord, logRbac, isSuperAdmin, vendorPortalFlagsFromUser, VENDOR_SCOPED_STORE_ENTITIES, isVendorPortalUser, getPermissionableEntityKeys, VENDOR_STORE_RBAC_ENTITIES, isSuperAdminGroupName, VENDOR_RBAC_ENTITIES, VENDOR_VIEWER_ROLE_NAME, DEFAULT_VENDOR_ROLE_DEFS, VENDOR_GROUP_NAME, resolveVendorScopeFromSessionUser, canManageVendorRoles, isPlatformAdministrator, canManageVendorTeam, resolveDisabledMultiVendorScope, logEntityAccessDecision, explainSessionEntityAccess } from './chunk-5NOZSG6J.js';
|
|
16
16
|
import { queueErp } from './chunk-SYBOCAWB.js';
|
|
17
17
|
import { __name } from './chunk-SHUYVCID.js';
|
|
18
18
|
import { PrimaryGeneratedColumn, Column, Entity, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn, Unique, OneToMany, Index, ManyToMany, JoinTable, In, ILike, Between, MoreThanOrEqual, LessThanOrEqual, Not, MoreThan, IsNull } from 'typeorm';
|
|
@@ -1674,6 +1674,30 @@ function entityHasSoftDelete(repo) {
|
|
|
1674
1674
|
return repo.metadata.columns.some((c) => c.propertyName === "deleted");
|
|
1675
1675
|
}
|
|
1676
1676
|
__name(entityHasSoftDelete, "entityHasSoftDelete");
|
|
1677
|
+
async function recordOrderAssigneeHistory(dataSource, entityMap, orderId, userId, vendorId) {
|
|
1678
|
+
if (!entityMap.order_assignees) return 1;
|
|
1679
|
+
const assigneeRepo = dataSource.getRepository(entityMap.order_assignees);
|
|
1680
|
+
const maxRow = await assigneeRepo.findOne({
|
|
1681
|
+
where: {
|
|
1682
|
+
orderId
|
|
1683
|
+
},
|
|
1684
|
+
order: {
|
|
1685
|
+
sortOrder: "DESC"
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
const currentMax = Number(maxRow?.sortOrder ?? 0);
|
|
1689
|
+
const nextSortOrder = currentMax + 1;
|
|
1690
|
+
await assigneeRepo.save({
|
|
1691
|
+
orderId,
|
|
1692
|
+
userId,
|
|
1693
|
+
vendorId,
|
|
1694
|
+
sortOrder: nextSortOrder,
|
|
1695
|
+
assignedAt: /* @__PURE__ */ new Date()
|
|
1696
|
+
});
|
|
1697
|
+
console.log(`[ORDERS-DEBUG][ASSIGNEE_HISTORY] Recorded assignment for order ${orderId}: user ${userId}, vendor ${vendorId}, sortOrder ${nextSortOrder}`);
|
|
1698
|
+
return nextSortOrder;
|
|
1699
|
+
}
|
|
1700
|
+
__name(recordOrderAssigneeHistory, "recordOrderAssigneeHistory");
|
|
1677
1701
|
var LIST_QUERY_RESERVED = /* @__PURE__ */ new Set([
|
|
1678
1702
|
"page",
|
|
1679
1703
|
"limit",
|
|
@@ -3556,10 +3580,38 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
3556
3580
|
});
|
|
3557
3581
|
}
|
|
3558
3582
|
}
|
|
3559
|
-
const qb = repo2.createQueryBuilder("order").leftJoinAndSelect("order.contact", "contact").leftJoinAndSelect("order.items", "items").leftJoinAndSelect("items.product", "product").leftJoinAndSelect("product.collection", "collection").leftJoinAndSelect("order.payments", "payments").leftJoinAndSelect("order.assignedUser", "assignedUser").andWhere("order.deleted = :orderDel", {
|
|
3583
|
+
const qb = repo2.createQueryBuilder("order").leftJoinAndSelect("order.contact", "contact").leftJoinAndSelect("order.items", "items").leftJoinAndSelect("items.product", "product").leftJoinAndSelect("product.collection", "collection").leftJoinAndSelect("order.payments", "payments").leftJoinAndSelect("order.assignedUser", "assignedUser").leftJoinAndSelect("order.vendor", "vendor").andWhere("order.deleted = :orderDel", {
|
|
3560
3584
|
orderDel: false
|
|
3561
3585
|
}).orderBy(`order.${sortField2}`, sortOrderOrders).skip(skip).take(limit);
|
|
3562
|
-
|
|
3586
|
+
const session = await getHydratedSessionUser?.() ?? null;
|
|
3587
|
+
console.log("[ORDERS-DEBUG][LIST] Querying orders. Session:", {
|
|
3588
|
+
id: session?.id,
|
|
3589
|
+
email: session?.email,
|
|
3590
|
+
role: session?.role,
|
|
3591
|
+
isRBACAdmin: session?.isRBACAdmin,
|
|
3592
|
+
isVendorPortal: session?.isVendorPortal,
|
|
3593
|
+
isVendorOwner: session?.isVendorOwner,
|
|
3594
|
+
isVendorRoleOwner: session?.isVendorRoleOwner,
|
|
3595
|
+
vendorIds: session?.vendorIds,
|
|
3596
|
+
activeVendorId: session?.activeVendorId
|
|
3597
|
+
}, "Scope:", scope);
|
|
3598
|
+
if (scope.type === "deny") {
|
|
3599
|
+
qb.andWhere("1 = 0");
|
|
3600
|
+
} else if (scope.type === "vendor") {
|
|
3601
|
+
const isOwner = Boolean(session?.isVendorOwner || session?.isVendorRoleOwner || session?.isRBACAdmin);
|
|
3602
|
+
console.log("[ORDERS-DEBUG][LIST] Vendor scope applied. isOwner:", isOwner, "vendorId:", scope.vendorId);
|
|
3603
|
+
if (isOwner) {
|
|
3604
|
+
qb.andWhere('(order.vendorId = :vendorScopeId OR order.assignedUserId IN (SELECT vu."userId" FROM vendor_users vu WHERE vu."vendorId" = :vendorScopeId))', {
|
|
3605
|
+
vendorScopeId: scope.vendorId
|
|
3606
|
+
});
|
|
3607
|
+
} else {
|
|
3608
|
+
const teamMemberId = Number(session?.id);
|
|
3609
|
+
console.log("[ORDERS-DEBUG][LIST] Team member scoping to teamMemberId:", teamMemberId);
|
|
3610
|
+
qb.andWhere("order.assignedUserId = :teamMemberId", {
|
|
3611
|
+
teamMemberId
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3563
3615
|
const vendorIdFilter = searchParams.get("vendorId")?.trim();
|
|
3564
3616
|
if (vendorIdFilter) {
|
|
3565
3617
|
const n = Number(vendorIdFilter);
|
|
@@ -3612,7 +3664,15 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
3612
3664
|
});
|
|
3613
3665
|
}
|
|
3614
3666
|
}
|
|
3667
|
+
console.log("[ORDERS-DEBUG][LIST] Executing SQL:", qb.getSql(), "Params:", qb.getParameters());
|
|
3615
3668
|
const [rows, total2] = await qb.getManyAndCount();
|
|
3669
|
+
console.log("[ORDERS-DEBUG][LIST] Query result: total =", total2, "rows length =", rows.length, "Orders:", rows.map((r) => ({
|
|
3670
|
+
id: r.id,
|
|
3671
|
+
orderNumber: r.orderNumber,
|
|
3672
|
+
vendorId: r.vendorId,
|
|
3673
|
+
assignedUserId: r.assignedUserId,
|
|
3674
|
+
status: r.status
|
|
3675
|
+
})));
|
|
3616
3676
|
const data2 = await Promise.all(rows.map(async (order) => {
|
|
3617
3677
|
await autoExpireOrderIfPaymentTimeExceeded(dataSource, entityMap, order);
|
|
3618
3678
|
const contact = order.contact;
|
|
@@ -3656,6 +3716,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
3656
3716
|
if (orderStatus === "cancelled" && rawPayStatus !== "paid" && rawPayStatus !== "captured" && rawPayStatus !== "refunded") {
|
|
3657
3717
|
paymentStatus2 = "unpaid";
|
|
3658
3718
|
}
|
|
3719
|
+
const vendorObj = order.vendor;
|
|
3659
3720
|
return {
|
|
3660
3721
|
...orderWithoutPayments,
|
|
3661
3722
|
contact: contact ? {
|
|
@@ -3669,6 +3730,11 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
3669
3730
|
name: assignedUserObj.name || assignedUserObj.email,
|
|
3670
3731
|
email: assignedUserObj.email
|
|
3671
3732
|
} : null,
|
|
3733
|
+
vendor: vendorObj ? {
|
|
3734
|
+
id: vendorObj.id,
|
|
3735
|
+
name: vendorObj.name || vendorObj.slug || `Vendor #${vendorObj.id}`,
|
|
3736
|
+
slug: vendorObj.slug
|
|
3737
|
+
} : null,
|
|
3672
3738
|
itemsSummary,
|
|
3673
3739
|
paymentStatus: paymentStatus2
|
|
3674
3740
|
};
|
|
@@ -4201,6 +4267,18 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
4201
4267
|
isCatalog: true
|
|
4202
4268
|
});
|
|
4203
4269
|
}
|
|
4270
|
+
} else if (resource === "orders" && scope.type === "vendor") {
|
|
4271
|
+
const session = await getHydratedSessionUser?.() ?? null;
|
|
4272
|
+
const isOwner = Boolean(session?.isVendorOwner || session?.isVendorRoleOwner || session?.isRBACAdmin);
|
|
4273
|
+
if (!isOwner) {
|
|
4274
|
+
const teamMemberId = Number(session?.id);
|
|
4275
|
+
where = mergeListWhereAnd(where, {
|
|
4276
|
+
vendorId: scope.vendorId,
|
|
4277
|
+
assignedUserId: teamMemberId
|
|
4278
|
+
});
|
|
4279
|
+
} else {
|
|
4280
|
+
where = mergeVendorScopeIntoWhere(where, scope, resource, catalogFlags);
|
|
4281
|
+
}
|
|
4204
4282
|
} else {
|
|
4205
4283
|
where = mergeVendorScopeIntoWhere(where, scope, resource, catalogFlags);
|
|
4206
4284
|
}
|
|
@@ -5165,6 +5243,12 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5165
5243
|
shippingAddressId: savedShipping?.id ?? null
|
|
5166
5244
|
});
|
|
5167
5245
|
}
|
|
5246
|
+
if (persistBody.assignedUserId) {
|
|
5247
|
+
const initAssignee = Number(persistBody.assignedUserId);
|
|
5248
|
+
if (Number.isFinite(initAssignee) && initAssignee > 0) {
|
|
5249
|
+
await recordOrderAssigneeHistory(dataSource, entityMap, created.id, initAssignee, Number(created.vendorId) || null);
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5168
5252
|
const reloadedOrder = await repo.findOne({
|
|
5169
5253
|
where: {
|
|
5170
5254
|
id: created.id,
|
|
@@ -5484,7 +5568,16 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
5484
5568
|
const scope = await resolveScope();
|
|
5485
5569
|
const flags = await getVendorCatalogCreateFlags(dataSource);
|
|
5486
5570
|
if (scope.type !== "all") {
|
|
5487
|
-
|
|
5571
|
+
const session = await getHydratedSessionUser?.() ?? null;
|
|
5572
|
+
const isOwner = Boolean(session?.isVendorOwner || session?.isVendorRoleOwner || session?.isRBACAdmin);
|
|
5573
|
+
const teamMemberId = Number(session?.id);
|
|
5574
|
+
data = data.filter((row) => {
|
|
5575
|
+
if (vendorScopeRowAccess(row, scope, resource, flags) !== "ok") return false;
|
|
5576
|
+
if (resource === "orders" && scope.type === "vendor" && !isOwner) {
|
|
5577
|
+
return Number(row?.assignedUserId) === teamMemberId;
|
|
5578
|
+
}
|
|
5579
|
+
return true;
|
|
5580
|
+
});
|
|
5488
5581
|
}
|
|
5489
5582
|
const excludeCols = /* @__PURE__ */ new Set([
|
|
5490
5583
|
"deletedAt",
|
|
@@ -5522,6 +5615,51 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
5522
5615
|
type: "all"
|
|
5523
5616
|
}));
|
|
5524
5617
|
async function vendorScopeAccessJson(row, scope, resource) {
|
|
5618
|
+
if (!row) return json({
|
|
5619
|
+
message: "Not found"
|
|
5620
|
+
}, {
|
|
5621
|
+
status: 404
|
|
5622
|
+
});
|
|
5623
|
+
if (resource === "orders" && scope.type === "vendor") {
|
|
5624
|
+
const rowVendorId = Number(row?.vendorId);
|
|
5625
|
+
let orderBelongsToVendorScope = rowVendorId === scope.vendorId;
|
|
5626
|
+
if (!orderBelongsToVendorScope) {
|
|
5627
|
+
const aId = Number(row?.assignedUserId);
|
|
5628
|
+
if (Number.isFinite(aId) && aId > 0 && entityMap["vendor_users"]) {
|
|
5629
|
+
const vuRepo = dataSource.getRepository(entityMap["vendor_users"]);
|
|
5630
|
+
const isTeamMember = await vuRepo.count({
|
|
5631
|
+
where: {
|
|
5632
|
+
vendorId: scope.vendorId,
|
|
5633
|
+
userId: aId
|
|
5634
|
+
}
|
|
5635
|
+
});
|
|
5636
|
+
if (isTeamMember > 0) {
|
|
5637
|
+
orderBelongsToVendorScope = true;
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
if (!orderBelongsToVendorScope) {
|
|
5642
|
+
return json({
|
|
5643
|
+
error: "Forbidden"
|
|
5644
|
+
}, {
|
|
5645
|
+
status: 403
|
|
5646
|
+
});
|
|
5647
|
+
}
|
|
5648
|
+
const session = await getHydratedSessionUser?.() ?? null;
|
|
5649
|
+
const isOwner = Boolean(session?.isVendorOwner || session?.isVendorRoleOwner || session?.isRBACAdmin);
|
|
5650
|
+
if (!isOwner) {
|
|
5651
|
+
const sessionUserId = Number(session?.id);
|
|
5652
|
+
const orderAssignee = Number(row?.assignedUserId);
|
|
5653
|
+
if (!Number.isFinite(orderAssignee) || orderAssignee !== sessionUserId) {
|
|
5654
|
+
return json({
|
|
5655
|
+
error: "Forbidden: You can only access orders assigned directly to you"
|
|
5656
|
+
}, {
|
|
5657
|
+
status: 403
|
|
5658
|
+
});
|
|
5659
|
+
}
|
|
5660
|
+
}
|
|
5661
|
+
return null;
|
|
5662
|
+
}
|
|
5525
5663
|
const flags = await getVendorCatalogCreateFlags(dataSource);
|
|
5526
5664
|
const access = vendorScopeRowAccess(row, scope, resource, flags);
|
|
5527
5665
|
if (access === "ok") return null;
|
|
@@ -5646,6 +5784,17 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
5646
5784
|
}
|
|
5647
5785
|
if (resource === "orders") {
|
|
5648
5786
|
const scope2 = await resolveScopeById();
|
|
5787
|
+
const session = await getHydratedSessionUser?.() ?? null;
|
|
5788
|
+
console.log("[ORDERS-DEBUG][GET_BY_ID] Fetching order id:", id, "Scope:", scope2, "Session:", {
|
|
5789
|
+
id: session?.id,
|
|
5790
|
+
email: session?.email,
|
|
5791
|
+
role: session?.role,
|
|
5792
|
+
isRBACAdmin: session?.isRBACAdmin,
|
|
5793
|
+
isVendorOwner: session?.isVendorOwner,
|
|
5794
|
+
isVendorRoleOwner: session?.isVendorRoleOwner,
|
|
5795
|
+
activeVendorId: session?.activeVendorId,
|
|
5796
|
+
vendorIds: session?.vendorIds
|
|
5797
|
+
});
|
|
5649
5798
|
const order = await repo.findOne({
|
|
5650
5799
|
where: {
|
|
5651
5800
|
id: Number(id)
|
|
@@ -5658,14 +5807,26 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
5658
5807
|
"items.product",
|
|
5659
5808
|
"items.product.collection",
|
|
5660
5809
|
"payments",
|
|
5661
|
-
"assignedUser"
|
|
5810
|
+
"assignedUser",
|
|
5811
|
+
"vendor"
|
|
5662
5812
|
]
|
|
5663
5813
|
});
|
|
5814
|
+
console.log("[ORDERS-DEBUG][GET_BY_ID] Order found in DB:", order ? {
|
|
5815
|
+
id: order.id,
|
|
5816
|
+
orderNumber: order.orderNumber,
|
|
5817
|
+
vendorId: order.vendorId,
|
|
5818
|
+
assignedUserId: order.assignedUserId,
|
|
5819
|
+
status: order.status
|
|
5820
|
+
} : null);
|
|
5664
5821
|
if (order) {
|
|
5665
5822
|
await autoExpireOrderIfPaymentTimeExceeded(dataSource, entityMap, order);
|
|
5666
5823
|
}
|
|
5667
5824
|
const orderDenied = await vendorScopeAccessJson(order, scope2, resource);
|
|
5668
|
-
if (orderDenied)
|
|
5825
|
+
if (orderDenied) {
|
|
5826
|
+
console.log("[ORDERS-DEBUG][GET_BY_ID] Access DENIED for order id:", id);
|
|
5827
|
+
return orderDenied;
|
|
5828
|
+
}
|
|
5829
|
+
console.log("[ORDERS-DEBUG][GET_BY_ID] Access GRANTED for order id:", id);
|
|
5669
5830
|
const relatedOrders = await repo.find({
|
|
5670
5831
|
where: {
|
|
5671
5832
|
parentOrderId: Number(id)
|
|
@@ -6049,21 +6210,67 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
6049
6210
|
lines: []
|
|
6050
6211
|
} : await calculateOrderTotalsFromLines(dataSource, entityMap, orderLinesNorm, effectiveCurrency, putDiscountId, Number.isFinite(putOrderVendorId) ? putOrderVendorId : null);
|
|
6051
6212
|
const scalarUpdate = pickColumnUpdates(repo, rawBody);
|
|
6052
|
-
if (rawBody && typeof rawBody === "object"
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6213
|
+
if (rawBody && typeof rawBody === "object") {
|
|
6214
|
+
if (scopePutEarly.type === "all" && "vendorId" in rawBody && rawBody.vendorId !== void 0) {
|
|
6215
|
+
const vId = Number(rawBody.vendorId);
|
|
6216
|
+
if (Number.isFinite(vId) && vId > 0) {
|
|
6217
|
+
scalarUpdate.vendorId = vId;
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
if ("assignedUserId" in rawBody && rawBody.assignedUserId !== void 0) {
|
|
6221
|
+
const aId = Number(rawBody.assignedUserId);
|
|
6222
|
+
if (Number.isFinite(aId) && aId > 0) {
|
|
6223
|
+
if (scopePutEarly.type === "vendor" && entityMap.vendor_users) {
|
|
6224
|
+
const vuRepo = dataSource.getRepository(entityMap.vendor_users);
|
|
6225
|
+
const vuLink = await vuRepo.findOne({
|
|
6226
|
+
where: {
|
|
6227
|
+
vendorId: scopePutEarly.vendorId,
|
|
6228
|
+
userId: aId
|
|
6229
|
+
}
|
|
6230
|
+
});
|
|
6231
|
+
if (!vuLink) {
|
|
6232
|
+
return json({
|
|
6233
|
+
error: "Cannot assign order to a user outside your vendor team."
|
|
6234
|
+
}, {
|
|
6235
|
+
status: 403
|
|
6236
|
+
});
|
|
6237
|
+
}
|
|
6238
|
+
scalarUpdate.vendorId = scopePutEarly.vendorId;
|
|
6239
|
+
} else if (scopePutEarly.type === "all" && entityMap.vendor_users) {
|
|
6240
|
+
if (entityMap.vendors) {
|
|
6241
|
+
const activeVu = await dataSource.query(`SELECT vu."vendorId"
|
|
6242
|
+
FROM vendor_users vu
|
|
6243
|
+
JOIN vendors v ON v.id = vu."vendorId"
|
|
6244
|
+
WHERE vu."userId" = $1 AND v.deleted = false
|
|
6245
|
+
ORDER BY vu.id DESC
|
|
6246
|
+
LIMIT 1`, [
|
|
6247
|
+
aId
|
|
6248
|
+
]);
|
|
6249
|
+
if (activeVu.length > 0 && activeVu[0].vendorId) {
|
|
6250
|
+
scalarUpdate.vendorId = Number(activeVu[0].vendorId);
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6254
|
+
const prevAssigned = Number(existingOrderRow?.assignedUserId);
|
|
6255
|
+
const prevVendor = Number(existingOrderRow?.vendorId);
|
|
6256
|
+
const targetVendor = Number.isFinite(Number(scalarUpdate.vendorId)) ? Number(scalarUpdate.vendorId) : Number(existingOrderRow?.vendorId) || null;
|
|
6257
|
+
if (aId !== prevAssigned || targetVendor && targetVendor !== prevVendor) {
|
|
6258
|
+
await recordOrderAssigneeHistory(dataSource, entityMap, numericId, aId, targetVendor);
|
|
6259
|
+
}
|
|
6260
|
+
scalarUpdate.assignedUserId = aId;
|
|
6261
|
+
scalarUpdate.assignedAt = /* @__PURE__ */ new Date();
|
|
6262
|
+
} else {
|
|
6263
|
+
scalarUpdate.assignedUserId = null;
|
|
6264
|
+
scalarUpdate.assignedAt = null;
|
|
6265
|
+
}
|
|
6060
6266
|
}
|
|
6061
6267
|
}
|
|
6062
6268
|
if (scalarUpdate.status === "processing") {
|
|
6063
6269
|
const effectiveAssignee = scalarUpdate.assignedUserId !== void 0 ? scalarUpdate.assignedUserId : existingOrderRow?.assignedUserId ?? null;
|
|
6064
|
-
|
|
6270
|
+
const effectiveVendor = scalarUpdate.vendorId !== void 0 ? Number(scalarUpdate.vendorId) : Number(existingOrderRow?.vendorId);
|
|
6271
|
+
if (!effectiveAssignee && (!Number.isFinite(effectiveVendor) || effectiveVendor <= 0)) {
|
|
6065
6272
|
return json({
|
|
6066
|
-
error: "Cannot start processing without assigning a teammate. Please assign
|
|
6273
|
+
error: "Cannot start processing without assigning a vendor or teammate. Please assign first."
|
|
6067
6274
|
}, {
|
|
6068
6275
|
status: 400
|
|
6069
6276
|
});
|
|
@@ -6480,7 +6687,9 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
6480
6687
|
}
|
|
6481
6688
|
const updatePayload = rawBody && typeof rawBody === "object" ? pickColumnUpdates(repo, rawBody) : {};
|
|
6482
6689
|
if (resourceUsesVendorScope(resource)) {
|
|
6483
|
-
|
|
6690
|
+
if (!(resource === "orders" && scopePut.type === "all")) {
|
|
6691
|
+
delete updatePayload.vendorId;
|
|
6692
|
+
}
|
|
6484
6693
|
}
|
|
6485
6694
|
if (resource === "contacts" && "type" in updatePayload) {
|
|
6486
6695
|
const t = updatePayload.type;
|
|
@@ -6876,9 +7085,59 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
6876
7085
|
}
|
|
6877
7086
|
}
|
|
6878
7087
|
if (resource === "orders" && orderInvPrev && rawBody && typeof rawBody === "object") {
|
|
7088
|
+
console.log("[ORDERS-DEBUG][UPDATE] PUT /api/orders/" + numericId, "Scope:", scopePut, "rawBody:", rawBody, "existingOrder:", {
|
|
7089
|
+
id: existingOrderRow?.id,
|
|
7090
|
+
vendorId: existingOrderRow?.vendorId,
|
|
7091
|
+
assignedUserId: existingOrderRow?.assignedUserId,
|
|
7092
|
+
status: existingOrderRow?.status
|
|
7093
|
+
});
|
|
7094
|
+
if (scopePut.type === "all" && "vendorId" in rawBody && rawBody.vendorId !== void 0) {
|
|
7095
|
+
const vId = Number(rawBody.vendorId);
|
|
7096
|
+
if (Number.isFinite(vId) && vId > 0) {
|
|
7097
|
+
updatePayload.vendorId = vId;
|
|
7098
|
+
}
|
|
7099
|
+
}
|
|
6879
7100
|
if ("assignedUserId" in rawBody && rawBody.assignedUserId !== void 0) {
|
|
6880
7101
|
const aId = Number(rawBody.assignedUserId);
|
|
7102
|
+
console.log("[ORDERS-DEBUG][UPDATE] Updating assignedUserId to:", aId);
|
|
6881
7103
|
if (Number.isFinite(aId) && aId > 0) {
|
|
7104
|
+
if (scopePut.type === "vendor" && entityMap.vendor_users) {
|
|
7105
|
+
const vuRepo = dataSource.getRepository(entityMap.vendor_users);
|
|
7106
|
+
const vuLink = await vuRepo.findOne({
|
|
7107
|
+
where: {
|
|
7108
|
+
vendorId: scopePut.vendorId,
|
|
7109
|
+
userId: aId
|
|
7110
|
+
}
|
|
7111
|
+
});
|
|
7112
|
+
if (!vuLink) {
|
|
7113
|
+
return json({
|
|
7114
|
+
error: "Cannot assign order to a user outside your vendor team."
|
|
7115
|
+
}, {
|
|
7116
|
+
status: 403
|
|
7117
|
+
});
|
|
7118
|
+
}
|
|
7119
|
+
updatePayload.vendorId = scopePut.vendorId;
|
|
7120
|
+
} else if (scopePut.type === "all" && entityMap.vendor_users) {
|
|
7121
|
+
if (entityMap.vendors) {
|
|
7122
|
+
const activeVu = await dataSource.query(`SELECT vu."vendorId"
|
|
7123
|
+
FROM vendor_users vu
|
|
7124
|
+
JOIN vendors v ON v.id = vu."vendorId"
|
|
7125
|
+
WHERE vu."userId" = $1 AND v.deleted = false
|
|
7126
|
+
ORDER BY vu.id DESC
|
|
7127
|
+
LIMIT 1`, [
|
|
7128
|
+
aId
|
|
7129
|
+
]);
|
|
7130
|
+
if (activeVu.length > 0 && activeVu[0].vendorId) {
|
|
7131
|
+
updatePayload.vendorId = Number(activeVu[0].vendorId);
|
|
7132
|
+
}
|
|
7133
|
+
}
|
|
7134
|
+
}
|
|
7135
|
+
const prevAssigned = Number(existingOrderRow?.assignedUserId);
|
|
7136
|
+
const prevVendor = Number(existingOrderRow?.vendorId);
|
|
7137
|
+
const targetVendor = Number.isFinite(Number(updatePayload.vendorId)) ? Number(updatePayload.vendorId) : Number(existingOrderRow?.vendorId) || null;
|
|
7138
|
+
if (aId !== prevAssigned || targetVendor && targetVendor !== prevVendor) {
|
|
7139
|
+
await recordOrderAssigneeHistory(dataSource, entityMap, numericId, aId, targetVendor);
|
|
7140
|
+
}
|
|
6882
7141
|
updatePayload.assignedUserId = aId;
|
|
6883
7142
|
updatePayload.assignedAt = /* @__PURE__ */ new Date();
|
|
6884
7143
|
} else {
|
|
@@ -6886,11 +7145,13 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
6886
7145
|
updatePayload.assignedAt = null;
|
|
6887
7146
|
}
|
|
6888
7147
|
}
|
|
7148
|
+
console.log("[ORDERS-DEBUG][UPDATE] Final updatePayload for order:", updatePayload);
|
|
6889
7149
|
if (updatePayload.status === "processing") {
|
|
6890
7150
|
const effectiveAssignee = updatePayload.assignedUserId !== void 0 ? updatePayload.assignedUserId : existingOrderRow?.assignedUserId ?? null;
|
|
6891
|
-
|
|
7151
|
+
const effectiveVendor = updatePayload.vendorId !== void 0 ? Number(updatePayload.vendorId) : Number(existingOrderRow?.vendorId);
|
|
7152
|
+
if (!effectiveAssignee && (!Number.isFinite(effectiveVendor) || effectiveVendor <= 0)) {
|
|
6892
7153
|
return json({
|
|
6893
|
-
error: "Cannot start processing without assigning a teammate. Please assign
|
|
7154
|
+
error: "Cannot start processing without assigning a vendor or teammate. Please assign first."
|
|
6894
7155
|
}, {
|
|
6895
7156
|
status: 400
|
|
6896
7157
|
});
|
|
@@ -25135,6 +25396,109 @@ _ts_decorate69([
|
|
|
25135
25396
|
OrderNotificationTrigger = _ts_decorate69([
|
|
25136
25397
|
Entity("order_notification_triggers")
|
|
25137
25398
|
], OrderNotificationTrigger);
|
|
25399
|
+
function _ts_decorate70(decorators, target, key, desc) {
|
|
25400
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25401
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25402
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
25403
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25404
|
+
}
|
|
25405
|
+
__name(_ts_decorate70, "_ts_decorate");
|
|
25406
|
+
function _ts_metadata70(k, v) {
|
|
25407
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25408
|
+
}
|
|
25409
|
+
__name(_ts_metadata70, "_ts_metadata");
|
|
25410
|
+
var OrderAssignee = class {
|
|
25411
|
+
static {
|
|
25412
|
+
__name(this, "OrderAssignee");
|
|
25413
|
+
}
|
|
25414
|
+
id;
|
|
25415
|
+
orderId;
|
|
25416
|
+
userId;
|
|
25417
|
+
vendorId;
|
|
25418
|
+
sortOrder;
|
|
25419
|
+
assignedAt;
|
|
25420
|
+
createdAt;
|
|
25421
|
+
order;
|
|
25422
|
+
user;
|
|
25423
|
+
vendor;
|
|
25424
|
+
};
|
|
25425
|
+
_ts_decorate70([
|
|
25426
|
+
PrimaryGeneratedColumn(),
|
|
25427
|
+
_ts_metadata70("design:type", Number)
|
|
25428
|
+
], OrderAssignee.prototype, "id", void 0);
|
|
25429
|
+
_ts_decorate70([
|
|
25430
|
+
Column("int"),
|
|
25431
|
+
_ts_metadata70("design:type", Number)
|
|
25432
|
+
], OrderAssignee.prototype, "orderId", void 0);
|
|
25433
|
+
_ts_decorate70([
|
|
25434
|
+
Column("int"),
|
|
25435
|
+
_ts_metadata70("design:type", Number)
|
|
25436
|
+
], OrderAssignee.prototype, "userId", void 0);
|
|
25437
|
+
_ts_decorate70([
|
|
25438
|
+
Column("int", {
|
|
25439
|
+
nullable: true
|
|
25440
|
+
}),
|
|
25441
|
+
_ts_metadata70("design:type", Object)
|
|
25442
|
+
], OrderAssignee.prototype, "vendorId", void 0);
|
|
25443
|
+
_ts_decorate70([
|
|
25444
|
+
Column("int", {
|
|
25445
|
+
default: 1
|
|
25446
|
+
}),
|
|
25447
|
+
_ts_metadata70("design:type", Number)
|
|
25448
|
+
], OrderAssignee.prototype, "sortOrder", void 0);
|
|
25449
|
+
_ts_decorate70([
|
|
25450
|
+
Column({
|
|
25451
|
+
type: "timestamp with time zone",
|
|
25452
|
+
default: /* @__PURE__ */ __name(() => "CURRENT_TIMESTAMP", "default")
|
|
25453
|
+
}),
|
|
25454
|
+
_ts_metadata70("design:type", typeof Date === "undefined" ? Object : Date)
|
|
25455
|
+
], OrderAssignee.prototype, "assignedAt", void 0);
|
|
25456
|
+
_ts_decorate70([
|
|
25457
|
+
CreateDateColumn({
|
|
25458
|
+
type: "timestamp with time zone"
|
|
25459
|
+
}),
|
|
25460
|
+
_ts_metadata70("design:type", typeof Date === "undefined" ? Object : Date)
|
|
25461
|
+
], OrderAssignee.prototype, "createdAt", void 0);
|
|
25462
|
+
_ts_decorate70([
|
|
25463
|
+
ManyToOne(() => Order, {
|
|
25464
|
+
onDelete: "CASCADE"
|
|
25465
|
+
}),
|
|
25466
|
+
JoinColumn({
|
|
25467
|
+
name: "orderId"
|
|
25468
|
+
}),
|
|
25469
|
+
_ts_metadata70("design:type", typeof Order === "undefined" ? Object : Order)
|
|
25470
|
+
], OrderAssignee.prototype, "order", void 0);
|
|
25471
|
+
_ts_decorate70([
|
|
25472
|
+
ManyToOne(() => User, {
|
|
25473
|
+
onDelete: "CASCADE"
|
|
25474
|
+
}),
|
|
25475
|
+
JoinColumn({
|
|
25476
|
+
name: "userId"
|
|
25477
|
+
}),
|
|
25478
|
+
_ts_metadata70("design:type", typeof User === "undefined" ? Object : User)
|
|
25479
|
+
], OrderAssignee.prototype, "user", void 0);
|
|
25480
|
+
_ts_decorate70([
|
|
25481
|
+
ManyToOne(() => Vendor, {
|
|
25482
|
+
nullable: true,
|
|
25483
|
+
onDelete: "SET NULL"
|
|
25484
|
+
}),
|
|
25485
|
+
JoinColumn({
|
|
25486
|
+
name: "vendorId"
|
|
25487
|
+
}),
|
|
25488
|
+
_ts_metadata70("design:type", Object)
|
|
25489
|
+
], OrderAssignee.prototype, "vendor", void 0);
|
|
25490
|
+
OrderAssignee = _ts_decorate70([
|
|
25491
|
+
Entity("order_assignees"),
|
|
25492
|
+
Index("idx_order_assignees_order", [
|
|
25493
|
+
"orderId"
|
|
25494
|
+
]),
|
|
25495
|
+
Index("idx_order_assignees_user", [
|
|
25496
|
+
"userId"
|
|
25497
|
+
]),
|
|
25498
|
+
Index("idx_order_assignees_vendor", [
|
|
25499
|
+
"vendorId"
|
|
25500
|
+
])
|
|
25501
|
+
], OrderAssignee);
|
|
25138
25502
|
|
|
25139
25503
|
// src/entities/index.ts
|
|
25140
25504
|
var CMS_ENTITY_MAP = {
|
|
@@ -25206,7 +25570,8 @@ var CMS_ENTITY_MAP = {
|
|
|
25206
25570
|
attendees: Attendee,
|
|
25207
25571
|
order_notification_bindings: OrderNotificationBinding,
|
|
25208
25572
|
order_notification_triggers: OrderNotificationTrigger,
|
|
25209
|
-
user_device_tokens: UserDeviceToken
|
|
25573
|
+
user_device_tokens: UserDeviceToken,
|
|
25574
|
+
order_assignees: OrderAssignee
|
|
25210
25575
|
};
|
|
25211
25576
|
|
|
25212
25577
|
// src/plugins/blog-generator/blog-generator-agent-defaults.ts
|
|
@@ -31102,8 +31467,8 @@ function createCmsApiHandler(config) {
|
|
|
31102
31467
|
}, {
|
|
31103
31468
|
status: 400
|
|
31104
31469
|
});
|
|
31105
|
-
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-
|
|
31106
|
-
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
|
|
31470
|
+
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-HFGCPC4O.js');
|
|
31471
|
+
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
|
|
31107
31472
|
return handlers.getChannels(req, orderId);
|
|
31108
31473
|
}
|
|
31109
31474
|
if (path2[0] === "orders" && path2.length === 4 && path2[2] === "completion-otp" && path2[3] === "send" && m === "POST" && getCms) {
|
|
@@ -31117,8 +31482,8 @@ function createCmsApiHandler(config) {
|
|
|
31117
31482
|
}, {
|
|
31118
31483
|
status: 400
|
|
31119
31484
|
});
|
|
31120
|
-
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-
|
|
31121
|
-
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
|
|
31485
|
+
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-HFGCPC4O.js');
|
|
31486
|
+
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
|
|
31122
31487
|
return handlers.sendOtp(req, orderId);
|
|
31123
31488
|
}
|
|
31124
31489
|
if (path2[0] === "orders" && path2.length === 4 && path2[2] === "completion-otp" && path2[3] === "verify" && m === "POST" && getCms) {
|
|
@@ -31132,8 +31497,8 @@ function createCmsApiHandler(config) {
|
|
|
31132
31497
|
}, {
|
|
31133
31498
|
status: 400
|
|
31134
31499
|
});
|
|
31135
|
-
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-
|
|
31136
|
-
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms);
|
|
31500
|
+
const { createOrderCompletionOtpHandlers } = await import('./order-completion-otp-handlers-HFGCPC4O.js');
|
|
31501
|
+
const handlers = createOrderCompletionOtpHandlers(dataSource, entityMap, getCms, getHydratedSessionUser);
|
|
31137
31502
|
return handlers.verifyOtp(req, orderId);
|
|
31138
31503
|
}
|
|
31139
31504
|
if (path2[0] === "orders" && path2.length === 3 && path2[2] === "eligible-assignees" && m === "GET") {
|
|
@@ -31147,7 +31512,7 @@ function createCmsApiHandler(config) {
|
|
|
31147
31512
|
}, {
|
|
31148
31513
|
status: 400
|
|
31149
31514
|
});
|
|
31150
|
-
const { createOrderAssigneesHandlers } = await import('./order-assignees-handlers-
|
|
31515
|
+
const { createOrderAssigneesHandlers } = await import('./order-assignees-handlers-L3RVKUBS.js');
|
|
31151
31516
|
const handlers = createOrderAssigneesHandlers(dataSource, entityMap, getHydratedSessionUser);
|
|
31152
31517
|
return handlers.listEligibleAssignees(req, orderId);
|
|
31153
31518
|
}
|
|
@@ -34735,4 +35100,4 @@ function createStorefrontApiHandler(config) {
|
|
|
34735
35100
|
}
|
|
34736
35101
|
__name(createStorefrontApiHandler, "createStorefrontApiHandler");
|
|
34737
35102
|
|
|
34738
|
-
export { Address, Attendee, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, BlogGeneratorService, Brand, CMS_ENTITY_MAP, Cart, CartItem, Category, ChatConversation, ChatMessage, Collection, Combo, ComboItem, Comment, Config, Contact, Currency, CurrencyExchange, Customer, Customer_Contacts, Discount, DiscountRules, Event, EventProduct, Form, FormField, FormSubmission, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, LlmAgent, LlmAgentKnowledgeDocument, Media, MessageTemplate, Order, OrderAddresses, OrderDiscounts, OrderItem, OrderNotificationBinding, OrderNotificationTrigger, OtpChallenge, Page, PasswordResetToken, Payment, Permission, Product, ProductAttribute, ProductCategory, ProductConfig, ProductVariant, RefundPolicy, RefundRequest, RssArticle, RssFeed, Seo, Tag, Tax, User, UserDeviceToken, UserGroup, Vendor, VendorCustomer, VendorRole, VendorRolePermission, VendorUser, VendorUserProfile, Wishlist, WishlistItem, ZIP_MIME_TYPES, applyApprovalStatusSideEffects, applyEventApprovalStatusSideEffects, applyRotatingVendorInvite, applyVendorCustomersContactFilter, applyVendorEventCreateApproval, applyVendorProductCreateApproval, assertCaptchaOk, assertContactAllowedForVendorOrder, assertEventApprovalUpdate, assertProductApprovalUpdate, autoExpireOrderIfPaymentTimeExceeded, buildBlogMetadataUserPrompt, buildCronFromSchedule, buildRssUserPromptFromFeeds, buildUserInviteLink, buildVendorInviteLink, calculateOrderRefundPreview, calculateRefundFromPolicy, checkAndIncrementDiscountUsage, checkEventsEnabled, checkMultiVendorEnabled, completeUserInviteAccept, consumeAppliedDiscountUsages, contactIsVendorCustomer, countDiscountOrdersForContact, createAnalyticsHandlers, createBlogBySlugHandler, createChangePasswordHandler, createCmsApiHandler, createCmsApp, createCmsAppWithMessaging, createCrudByIdHandler, createCrudHandler, createDashboardStatsHandler, createEcommerceAnalyticsHandler, createEventOrderMessageTemplateHandlers, createForgotPasswordHandler, createFormBySlugHandler, createInviteAcceptHandler, createJobScheduleHandlers, createLlmAgentKnowledgeHandlers, createMediaZipExtractHandler, createMessageTemplateRowLoader, createSetPasswordHandler, createSettingsApiHandlers, createSocialMediaHandlers, createStorefrontApiHandler, createUploadHandler, createUserAuthApiRouter, createUserAvatarHandler, createUserProfileHandler, createUsersApiHandlers, createVendorDashboardHandler, createVendorOnboardHandlers, daysBeforeEventStart, decrementDiscountUsage, describeEventTierPolicy, ensureMessagingPluginsOnCms, ensureScheduleQueueWorker, ensureVendorCustomerForOrderContact, ensureVendorCustomersForOrder, findActiveRefundPolicyForVendor, findUserByInviteToken, findVendorByInviteToken, formatTierRange, getPublicSettingsGroup, getRequireEventApproval, getRequireProductApproval, getRssArticleSummaryFromItem, getVendorCatalogCreateFlags, hydrateVendorSessionUser, invalidateEventsCache, invalidateMultiVendorCache, invalidateRequireEventApprovalCache, invalidateRequireProductApprovalCache, invalidateVendorCatalogCreateFlagsCache, isCustomerTypeContact, isMaxPerUserUsageReached, isMaxTotalUsageReached, isZipMedia, llmAgentToChatAgentOptions, loadSettingsGroupFromDb, loadUserVendorContext, mergeGuardrailsIntoSystemPrompt, messagingPlugins, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, newUserInviteToken, normalizeRefundTiers, overlayCmsPlugins, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseLlmAgentValidationRules, pgBossScheduleNameForId, queueErpCreateContactIfEnabled, queueJobScheduleNow, queuePlugin, recordDiscountUsage, registerJobRunnerWorker, registerMessagingQueueProcessors, relativePathFromMediaParentId, resolveBlogCategoryIdByName, resolveSettingsEncryptionKey, resolveVendorIdForContactCheck, sanitizeMediaFolderPath, sanitizeStorageSegment, sendVendorOnboardEmails, simpleDecrypt, simpleEncrypt, syncJobScheduleToPgBoss, validateRefundTiers, validateScheduleInput, validateUserMessageAgainstAgentRules, validateUserMessageAgainstStructuredRules, whatsappPlugin, wrapGetCmsWithMessaging };
|
|
35103
|
+
export { Address, Attendee, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, BlogGeneratorService, Brand, CMS_ENTITY_MAP, Cart, CartItem, Category, ChatConversation, ChatMessage, Collection, Combo, ComboItem, Comment, Config, Contact, Currency, CurrencyExchange, Customer, Customer_Contacts, Discount, DiscountRules, Event, EventProduct, Form, FormField, FormSubmission, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, LlmAgent, LlmAgentKnowledgeDocument, Media, MessageTemplate, Order, OrderAddresses, OrderAssignee, OrderDiscounts, OrderItem, OrderNotificationBinding, OrderNotificationTrigger, OtpChallenge, Page, PasswordResetToken, Payment, Permission, Product, ProductAttribute, ProductCategory, ProductConfig, ProductVariant, RefundPolicy, RefundRequest, RssArticle, RssFeed, Seo, Tag, Tax, User, UserDeviceToken, UserGroup, Vendor, VendorCustomer, VendorRole, VendorRolePermission, VendorUser, VendorUserProfile, Wishlist, WishlistItem, ZIP_MIME_TYPES, applyApprovalStatusSideEffects, applyEventApprovalStatusSideEffects, applyRotatingVendorInvite, applyVendorCustomersContactFilter, applyVendorEventCreateApproval, applyVendorProductCreateApproval, assertCaptchaOk, assertContactAllowedForVendorOrder, assertEventApprovalUpdate, assertProductApprovalUpdate, autoExpireOrderIfPaymentTimeExceeded, buildBlogMetadataUserPrompt, buildCronFromSchedule, buildRssUserPromptFromFeeds, buildUserInviteLink, buildVendorInviteLink, calculateOrderRefundPreview, calculateRefundFromPolicy, checkAndIncrementDiscountUsage, checkEventsEnabled, checkMultiVendorEnabled, completeUserInviteAccept, consumeAppliedDiscountUsages, contactIsVendorCustomer, countDiscountOrdersForContact, createAnalyticsHandlers, createBlogBySlugHandler, createChangePasswordHandler, createCmsApiHandler, createCmsApp, createCmsAppWithMessaging, createCrudByIdHandler, createCrudHandler, createDashboardStatsHandler, createEcommerceAnalyticsHandler, createEventOrderMessageTemplateHandlers, createForgotPasswordHandler, createFormBySlugHandler, createInviteAcceptHandler, createJobScheduleHandlers, createLlmAgentKnowledgeHandlers, createMediaZipExtractHandler, createMessageTemplateRowLoader, createSetPasswordHandler, createSettingsApiHandlers, createSocialMediaHandlers, createStorefrontApiHandler, createUploadHandler, createUserAuthApiRouter, createUserAvatarHandler, createUserProfileHandler, createUsersApiHandlers, createVendorDashboardHandler, createVendorOnboardHandlers, daysBeforeEventStart, decrementDiscountUsage, describeEventTierPolicy, ensureMessagingPluginsOnCms, ensureScheduleQueueWorker, ensureVendorCustomerForOrderContact, ensureVendorCustomersForOrder, findActiveRefundPolicyForVendor, findUserByInviteToken, findVendorByInviteToken, formatTierRange, getPublicSettingsGroup, getRequireEventApproval, getRequireProductApproval, getRssArticleSummaryFromItem, getVendorCatalogCreateFlags, hydrateVendorSessionUser, invalidateEventsCache, invalidateMultiVendorCache, invalidateRequireEventApprovalCache, invalidateRequireProductApprovalCache, invalidateVendorCatalogCreateFlagsCache, isCustomerTypeContact, isMaxPerUserUsageReached, isMaxTotalUsageReached, isZipMedia, llmAgentToChatAgentOptions, loadSettingsGroupFromDb, loadUserVendorContext, mergeGuardrailsIntoSystemPrompt, messagingPlugins, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, newUserInviteToken, normalizeRefundTiers, overlayCmsPlugins, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseLlmAgentValidationRules, pgBossScheduleNameForId, queueErpCreateContactIfEnabled, queueJobScheduleNow, queuePlugin, recordDiscountUsage, registerJobRunnerWorker, registerMessagingQueueProcessors, relativePathFromMediaParentId, resolveBlogCategoryIdByName, resolveSettingsEncryptionKey, resolveVendorIdForContactCheck, sanitizeMediaFolderPath, sanitizeStorageSegment, sendVendorOnboardEmails, simpleDecrypt, simpleEncrypt, syncJobScheduleToPgBoss, validateRefundTiers, validateScheduleInput, validateUserMessageAgainstAgentRules, validateUserMessageAgainstStructuredRules, whatsappPlugin, wrapGetCmsWithMessaging };
|
|
@@ -192,23 +192,34 @@ function canOnboardVendors(user) {
|
|
|
192
192
|
}
|
|
193
193
|
chunkUSNT2KNT_cjs.__name(canOnboardVendors, "canOnboardVendors");
|
|
194
194
|
function resolveVendorScopeFromSessionUser(user) {
|
|
195
|
-
if (!user?.email)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
195
|
+
if (!user?.email) {
|
|
196
|
+
console.log("[ORDERS-DEBUG][RESOLVE_VENDOR_SCOPE] No user email -> deny");
|
|
197
|
+
return {
|
|
198
|
+
type: "deny"
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (isPlatformAdministrator(user)) {
|
|
202
|
+
console.log("[ORDERS-DEBUG][RESOLVE_VENDOR_SCOPE] User is Platform Admin -> all");
|
|
203
|
+
return {
|
|
204
|
+
type: "all"
|
|
205
|
+
};
|
|
206
|
+
}
|
|
201
207
|
const vendorIds = user.vendorIds ?? [];
|
|
202
|
-
if (vendorIds.length === 0)
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
if (vendorIds.length === 0) {
|
|
209
|
+
console.log("[ORDERS-DEBUG][RESOLVE_VENDOR_SCOPE] User has 0 vendorIds -> deny. User:", user.email);
|
|
210
|
+
return {
|
|
211
|
+
type: "deny"
|
|
212
|
+
};
|
|
213
|
+
}
|
|
205
214
|
const preferred = user.activeVendorId ?? vendorIds[0];
|
|
206
215
|
const vendorId = vendorIds.includes(preferred) ? preferred : vendorIds[0];
|
|
207
|
-
|
|
216
|
+
const res = {
|
|
208
217
|
type: "vendor",
|
|
209
218
|
vendorId,
|
|
210
219
|
vendorIds
|
|
211
220
|
};
|
|
221
|
+
console.log("[ORDERS-DEBUG][RESOLVE_VENDOR_SCOPE] User:", user.email, "-> scope:", res);
|
|
222
|
+
return res;
|
|
212
223
|
}
|
|
213
224
|
chunkUSNT2KNT_cjs.__name(resolveVendorScopeFromSessionUser, "resolveVendorScopeFromSessionUser");
|
|
214
225
|
function vendorPortalFlagsFromUser(input) {
|
|
@@ -614,7 +625,7 @@ async function logEntityAccessDecision(dataSource, context, user, entity, action
|
|
|
614
625
|
const id = Number(user.id);
|
|
615
626
|
if (Number.isFinite(id)) {
|
|
616
627
|
try {
|
|
617
|
-
const { loadDbPermissionsForUser } = await import('./rbac-debug-db-
|
|
628
|
+
const { loadDbPermissionsForUser } = await import('./rbac-debug-db-KWV7D5PQ.cjs');
|
|
618
629
|
dbPermissions = await loadDbPermissionsForUser(dataSource, id);
|
|
619
630
|
} catch (e) {
|
|
620
631
|
dbPermissions = {
|