@infuro/cms-core 1.0.54 → 1.0.55
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 +1 -1
- package/dist/admin.js +1 -1
- package/dist/api.cjs +32 -32
- package/dist/api.js +1 -1
- package/dist/{chunk-CJ2YAVCO.cjs → chunk-JGR4ZUON.cjs} +63 -8
- package/dist/{chunk-PDA4L2LS.js → chunk-LI3CUI54.js} +63 -8
- package/dist/index.cjs +264 -226
- package/dist/index.js +53 -15
- package/package.json +1 -1
package/dist/admin.cjs
CHANGED
|
@@ -887,7 +887,7 @@ var init_admin_config_context = __esm({
|
|
|
887
887
|
var CMS_VERSION;
|
|
888
888
|
var init_cms_version = __esm({
|
|
889
889
|
"src/lib/cms-version.ts"() {
|
|
890
|
-
CMS_VERSION = "1.0.
|
|
890
|
+
CMS_VERSION = "1.0.55" ;
|
|
891
891
|
}
|
|
892
892
|
});
|
|
893
893
|
function useCatalogCategories(enabled = true) {
|
package/dist/admin.js
CHANGED
|
@@ -853,7 +853,7 @@ var init_admin_config_context = __esm({
|
|
|
853
853
|
var CMS_VERSION;
|
|
854
854
|
var init_cms_version = __esm({
|
|
855
855
|
"src/lib/cms-version.ts"() {
|
|
856
|
-
CMS_VERSION = "1.0.
|
|
856
|
+
CMS_VERSION = "1.0.55" ;
|
|
857
857
|
}
|
|
858
858
|
});
|
|
859
859
|
function useCatalogCategories(enabled = true) {
|
package/dist/api.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJGR4ZUON_cjs = require('./chunk-JGR4ZUON.cjs');
|
|
4
4
|
require('./chunk-XQ3QUHWR.cjs');
|
|
5
5
|
require('./chunk-HY3AXLOI.cjs');
|
|
6
6
|
require('./chunk-JN4AFHZ4.cjs');
|
|
@@ -22,127 +22,127 @@ require('./chunk-USNT2KNT.cjs');
|
|
|
22
22
|
|
|
23
23
|
Object.defineProperty(exports, "createAnalyticsHandlers", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkJGR4ZUON_cjs.createAnalyticsHandlers; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "createBlogBySlugHandler", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkJGR4ZUON_cjs.createBlogBySlugHandler; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "createChangePasswordHandler", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkJGR4ZUON_cjs.createChangePasswordHandler; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "createCmsApiHandler", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkJGR4ZUON_cjs.createCmsApiHandler; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "createCrudByIdHandler", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkJGR4ZUON_cjs.createCrudByIdHandler; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "createCrudHandler", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkJGR4ZUON_cjs.createCrudHandler; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, "createDashboardStatsHandler", {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkJGR4ZUON_cjs.createDashboardStatsHandler; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, "createEcommerceAnalyticsHandler", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkJGR4ZUON_cjs.createEcommerceAnalyticsHandler; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "createForgotPasswordHandler", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkJGR4ZUON_cjs.createForgotPasswordHandler; }
|
|
58
58
|
});
|
|
59
59
|
Object.defineProperty(exports, "createFormBySlugHandler", {
|
|
60
60
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkJGR4ZUON_cjs.createFormBySlugHandler; }
|
|
62
62
|
});
|
|
63
63
|
Object.defineProperty(exports, "createInviteAcceptHandler", {
|
|
64
64
|
enumerable: true,
|
|
65
|
-
get: function () { return
|
|
65
|
+
get: function () { return chunkJGR4ZUON_cjs.createInviteAcceptHandler; }
|
|
66
66
|
});
|
|
67
67
|
Object.defineProperty(exports, "createJobScheduleHandlers", {
|
|
68
68
|
enumerable: true,
|
|
69
|
-
get: function () { return
|
|
69
|
+
get: function () { return chunkJGR4ZUON_cjs.createJobScheduleHandlers; }
|
|
70
70
|
});
|
|
71
71
|
Object.defineProperty(exports, "createLlmAgentKnowledgeHandlers", {
|
|
72
72
|
enumerable: true,
|
|
73
|
-
get: function () { return
|
|
73
|
+
get: function () { return chunkJGR4ZUON_cjs.createLlmAgentKnowledgeHandlers; }
|
|
74
74
|
});
|
|
75
75
|
Object.defineProperty(exports, "createMediaZipExtractHandler", {
|
|
76
76
|
enumerable: true,
|
|
77
|
-
get: function () { return
|
|
77
|
+
get: function () { return chunkJGR4ZUON_cjs.createMediaZipExtractHandler; }
|
|
78
78
|
});
|
|
79
79
|
Object.defineProperty(exports, "createSetPasswordHandler", {
|
|
80
80
|
enumerable: true,
|
|
81
|
-
get: function () { return
|
|
81
|
+
get: function () { return chunkJGR4ZUON_cjs.createSetPasswordHandler; }
|
|
82
82
|
});
|
|
83
83
|
Object.defineProperty(exports, "createSettingsApiHandlers", {
|
|
84
84
|
enumerable: true,
|
|
85
|
-
get: function () { return
|
|
85
|
+
get: function () { return chunkJGR4ZUON_cjs.createSettingsApiHandlers; }
|
|
86
86
|
});
|
|
87
87
|
Object.defineProperty(exports, "createStorefrontApiHandler", {
|
|
88
88
|
enumerable: true,
|
|
89
|
-
get: function () { return
|
|
89
|
+
get: function () { return chunkJGR4ZUON_cjs.createStorefrontApiHandler; }
|
|
90
90
|
});
|
|
91
91
|
Object.defineProperty(exports, "createUploadHandler", {
|
|
92
92
|
enumerable: true,
|
|
93
|
-
get: function () { return
|
|
93
|
+
get: function () { return chunkJGR4ZUON_cjs.createUploadHandler; }
|
|
94
94
|
});
|
|
95
95
|
Object.defineProperty(exports, "createUserAuthApiRouter", {
|
|
96
96
|
enumerable: true,
|
|
97
|
-
get: function () { return
|
|
97
|
+
get: function () { return chunkJGR4ZUON_cjs.createUserAuthApiRouter; }
|
|
98
98
|
});
|
|
99
99
|
Object.defineProperty(exports, "createUserAvatarHandler", {
|
|
100
100
|
enumerable: true,
|
|
101
|
-
get: function () { return
|
|
101
|
+
get: function () { return chunkJGR4ZUON_cjs.createUserAvatarHandler; }
|
|
102
102
|
});
|
|
103
103
|
Object.defineProperty(exports, "createUserProfileHandler", {
|
|
104
104
|
enumerable: true,
|
|
105
|
-
get: function () { return
|
|
105
|
+
get: function () { return chunkJGR4ZUON_cjs.createUserProfileHandler; }
|
|
106
106
|
});
|
|
107
107
|
Object.defineProperty(exports, "createUsersApiHandlers", {
|
|
108
108
|
enumerable: true,
|
|
109
|
-
get: function () { return
|
|
109
|
+
get: function () { return chunkJGR4ZUON_cjs.createUsersApiHandlers; }
|
|
110
110
|
});
|
|
111
111
|
Object.defineProperty(exports, "createVendorDashboardHandler", {
|
|
112
112
|
enumerable: true,
|
|
113
|
-
get: function () { return
|
|
113
|
+
get: function () { return chunkJGR4ZUON_cjs.createVendorDashboardHandler; }
|
|
114
114
|
});
|
|
115
115
|
Object.defineProperty(exports, "createVendorOnboardHandlers", {
|
|
116
116
|
enumerable: true,
|
|
117
|
-
get: function () { return
|
|
117
|
+
get: function () { return chunkJGR4ZUON_cjs.createVendorOnboardHandlers; }
|
|
118
118
|
});
|
|
119
119
|
Object.defineProperty(exports, "getPublicSettingsGroup", {
|
|
120
120
|
enumerable: true,
|
|
121
|
-
get: function () { return
|
|
121
|
+
get: function () { return chunkJGR4ZUON_cjs.getPublicSettingsGroup; }
|
|
122
122
|
});
|
|
123
123
|
Object.defineProperty(exports, "mergeGuardrailsIntoSystemPrompt", {
|
|
124
124
|
enumerable: true,
|
|
125
|
-
get: function () { return
|
|
125
|
+
get: function () { return chunkJGR4ZUON_cjs.mergeGuardrailsIntoSystemPrompt; }
|
|
126
126
|
});
|
|
127
127
|
Object.defineProperty(exports, "parseLlmAgentValidationRules", {
|
|
128
128
|
enumerable: true,
|
|
129
|
-
get: function () { return
|
|
129
|
+
get: function () { return chunkJGR4ZUON_cjs.parseLlmAgentValidationRules; }
|
|
130
130
|
});
|
|
131
131
|
Object.defineProperty(exports, "simpleDecrypt", {
|
|
132
132
|
enumerable: true,
|
|
133
|
-
get: function () { return
|
|
133
|
+
get: function () { return chunkJGR4ZUON_cjs.simpleDecrypt; }
|
|
134
134
|
});
|
|
135
135
|
Object.defineProperty(exports, "simpleEncrypt", {
|
|
136
136
|
enumerable: true,
|
|
137
|
-
get: function () { return
|
|
137
|
+
get: function () { return chunkJGR4ZUON_cjs.simpleEncrypt; }
|
|
138
138
|
});
|
|
139
139
|
Object.defineProperty(exports, "validateUserMessageAgainstAgentRules", {
|
|
140
140
|
enumerable: true,
|
|
141
|
-
get: function () { return
|
|
141
|
+
get: function () { return chunkJGR4ZUON_cjs.validateUserMessageAgainstAgentRules; }
|
|
142
142
|
});
|
|
143
143
|
Object.defineProperty(exports, "validateUserMessageAgainstStructuredRules", {
|
|
144
144
|
enumerable: true,
|
|
145
|
-
get: function () { return
|
|
145
|
+
get: function () { return chunkJGR4ZUON_cjs.validateUserMessageAgainstStructuredRules; }
|
|
146
146
|
});
|
|
147
147
|
Object.defineProperty(exports, "createCmsAuthBundle", {
|
|
148
148
|
enumerable: true,
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createAnalyticsHandlers, createBlogBySlugHandler, createChangePasswordHandler, createCmsApiHandler, createCrudByIdHandler, createCrudHandler, createDashboardStatsHandler, createEcommerceAnalyticsHandler, createForgotPasswordHandler, createFormBySlugHandler, createInviteAcceptHandler, createJobScheduleHandlers, createLlmAgentKnowledgeHandlers, createMediaZipExtractHandler, createSetPasswordHandler, createSettingsApiHandlers, createStorefrontApiHandler, createUploadHandler, createUserAuthApiRouter, createUserAvatarHandler, createUserProfileHandler, createUsersApiHandlers, createVendorDashboardHandler, createVendorOnboardHandlers, getPublicSettingsGroup, mergeGuardrailsIntoSystemPrompt, parseLlmAgentValidationRules, simpleDecrypt, simpleEncrypt, validateUserMessageAgainstAgentRules, validateUserMessageAgainstStructuredRules } from './chunk-
|
|
1
|
+
export { createAnalyticsHandlers, createBlogBySlugHandler, createChangePasswordHandler, createCmsApiHandler, createCrudByIdHandler, createCrudHandler, createDashboardStatsHandler, createEcommerceAnalyticsHandler, createForgotPasswordHandler, createFormBySlugHandler, createInviteAcceptHandler, createJobScheduleHandlers, createLlmAgentKnowledgeHandlers, createMediaZipExtractHandler, createSetPasswordHandler, createSettingsApiHandlers, createStorefrontApiHandler, createUploadHandler, createUserAuthApiRouter, createUserAvatarHandler, createUserProfileHandler, createUsersApiHandlers, createVendorDashboardHandler, createVendorOnboardHandlers, getPublicSettingsGroup, mergeGuardrailsIntoSystemPrompt, parseLlmAgentValidationRules, simpleDecrypt, simpleEncrypt, validateUserMessageAgainstAgentRules, validateUserMessageAgainstStructuredRules } from './chunk-LI3CUI54.js';
|
|
2
2
|
import './chunk-GO7PPYNU.js';
|
|
3
3
|
import './chunk-3K5AIEIZ.js';
|
|
4
4
|
import './chunk-CTXBYO2J.js';
|
|
@@ -33465,17 +33465,48 @@ function createStorefrontApiHandler(config) {
|
|
|
33465
33465
|
if (!contact) return json({
|
|
33466
33466
|
orders: []
|
|
33467
33467
|
});
|
|
33468
|
-
|
|
33469
|
-
|
|
33470
|
-
|
|
33471
|
-
|
|
33472
|
-
|
|
33473
|
-
|
|
33468
|
+
let linkedCustomerContactIds = [];
|
|
33469
|
+
if (entityMap.customer && entityMap.customer_contacts) {
|
|
33470
|
+
const rows = await dataSource.query(`SELECT cc.id
|
|
33471
|
+
FROM customer_contacts cc
|
|
33472
|
+
JOIN customer c ON c.id = cc."customerId"
|
|
33473
|
+
WHERE c."userId" = $1`, [
|
|
33474
|
+
uid
|
|
33475
|
+
]);
|
|
33476
|
+
linkedCustomerContactIds = rows.map((row) => Number(row.id)).filter((id) => Number.isFinite(id) && id > 0);
|
|
33477
|
+
}
|
|
33478
|
+
const visibleOrders = await orderRepo().find({
|
|
33479
|
+
where: [
|
|
33480
|
+
{
|
|
33481
|
+
contactId: contact.id,
|
|
33482
|
+
deleted: false,
|
|
33483
|
+
orderKind: "sale"
|
|
33484
|
+
},
|
|
33485
|
+
...linkedCustomerContactIds.length ? [
|
|
33486
|
+
{
|
|
33487
|
+
customerContactId: typeorm.In(linkedCustomerContactIds),
|
|
33488
|
+
deleted: false,
|
|
33489
|
+
orderKind: "sale"
|
|
33490
|
+
}
|
|
33491
|
+
] : []
|
|
33492
|
+
],
|
|
33474
33493
|
order: {
|
|
33475
33494
|
createdAt: "DESC"
|
|
33476
33495
|
},
|
|
33477
33496
|
take: 50
|
|
33478
33497
|
});
|
|
33498
|
+
const orders = visibleOrders.filter((o) => {
|
|
33499
|
+
const row = o;
|
|
33500
|
+
const orderContactId = Number(row.contactId);
|
|
33501
|
+
const customerContactId = Number(row.customerContactId);
|
|
33502
|
+
if (Number.isFinite(orderContactId) && orderContactId > 0 && orderContactId === Number(contact.id)) {
|
|
33503
|
+
return true;
|
|
33504
|
+
}
|
|
33505
|
+
if (Number.isFinite(customerContactId) && customerContactId > 0) {
|
|
33506
|
+
return linkedCustomerContactIds.includes(customerContactId);
|
|
33507
|
+
}
|
|
33508
|
+
return false;
|
|
33509
|
+
});
|
|
33479
33510
|
const orderIds = orders.map((o) => o.id);
|
|
33480
33511
|
const previewByOrder = {};
|
|
33481
33512
|
if (orderIds.length) {
|
|
@@ -33568,10 +33599,19 @@ function createStorefrontApiHandler(config) {
|
|
|
33568
33599
|
status: 404
|
|
33569
33600
|
});
|
|
33570
33601
|
const orderId = parseInt(path2[1], 10);
|
|
33602
|
+
let linkedCustomerContactIds = [];
|
|
33603
|
+
if (entityMap.customer && entityMap.customer_contacts) {
|
|
33604
|
+
const rows = await dataSource.query(`SELECT cc.id
|
|
33605
|
+
FROM customer_contacts cc
|
|
33606
|
+
JOIN customer c ON c.id = cc."customerId"
|
|
33607
|
+
WHERE c."userId" = $1`, [
|
|
33608
|
+
uid
|
|
33609
|
+
]);
|
|
33610
|
+
linkedCustomerContactIds = rows.map((row) => Number(row.id)).filter((id) => Number.isFinite(id) && id > 0);
|
|
33611
|
+
}
|
|
33571
33612
|
let order = await orderRepo().findOne({
|
|
33572
33613
|
where: {
|
|
33573
33614
|
id: orderId,
|
|
33574
|
-
contactId: contact.id,
|
|
33575
33615
|
deleted: false
|
|
33576
33616
|
},
|
|
33577
33617
|
relations: [
|
|
@@ -33584,13 +33624,20 @@ function createStorefrontApiHandler(config) {
|
|
|
33584
33624
|
}, {
|
|
33585
33625
|
status: 404
|
|
33586
33626
|
});
|
|
33627
|
+
const orderContactId = Number(order.contactId);
|
|
33628
|
+
const orderCustomerContactId = Number(order.customerContactId);
|
|
33629
|
+
const isOwner = Number.isFinite(orderContactId) && orderContactId > 0 && orderContactId === Number(contact.id) || Number.isFinite(orderCustomerContactId) && orderCustomerContactId > 0 && linkedCustomerContactIds.includes(orderCustomerContactId);
|
|
33630
|
+
if (!isOwner) return json({
|
|
33631
|
+
error: "Not found"
|
|
33632
|
+
}, {
|
|
33633
|
+
status: 404
|
|
33634
|
+
});
|
|
33587
33635
|
if (getCms) {
|
|
33588
33636
|
const cms = await getCms();
|
|
33589
33637
|
await tryRefreshOrderFromErpForStorefront(cms, dataSource, entityMap, order);
|
|
33590
33638
|
order = await orderRepo().findOne({
|
|
33591
33639
|
where: {
|
|
33592
33640
|
id: orderId,
|
|
33593
|
-
contactId: contact.id,
|
|
33594
33641
|
deleted: false
|
|
33595
33642
|
},
|
|
33596
33643
|
relations: [
|
|
@@ -33604,6 +33651,14 @@ function createStorefrontApiHandler(config) {
|
|
|
33604
33651
|
}, {
|
|
33605
33652
|
status: 404
|
|
33606
33653
|
});
|
|
33654
|
+
const refreshedOrderContactId = Number(order.contactId);
|
|
33655
|
+
const refreshedCustomerContactId = Number(order.customerContactId);
|
|
33656
|
+
const isOwnerAfterRefresh = Number.isFinite(refreshedOrderContactId) && refreshedOrderContactId > 0 && refreshedOrderContactId === Number(contact.id) || Number.isFinite(refreshedCustomerContactId) && refreshedCustomerContactId > 0 && linkedCustomerContactIds.includes(refreshedCustomerContactId);
|
|
33657
|
+
if (!isOwnerAfterRefresh) return json({
|
|
33658
|
+
error: "Not found"
|
|
33659
|
+
}, {
|
|
33660
|
+
status: 404
|
|
33661
|
+
});
|
|
33607
33662
|
const o = order;
|
|
33608
33663
|
const lines = (o.items || []).map((line) => {
|
|
33609
33664
|
const p = line.product;
|
|
@@ -33455,17 +33455,48 @@ function createStorefrontApiHandler(config) {
|
|
|
33455
33455
|
if (!contact) return json({
|
|
33456
33456
|
orders: []
|
|
33457
33457
|
});
|
|
33458
|
-
|
|
33459
|
-
|
|
33460
|
-
|
|
33461
|
-
|
|
33462
|
-
|
|
33463
|
-
|
|
33458
|
+
let linkedCustomerContactIds = [];
|
|
33459
|
+
if (entityMap.customer && entityMap.customer_contacts) {
|
|
33460
|
+
const rows = await dataSource.query(`SELECT cc.id
|
|
33461
|
+
FROM customer_contacts cc
|
|
33462
|
+
JOIN customer c ON c.id = cc."customerId"
|
|
33463
|
+
WHERE c."userId" = $1`, [
|
|
33464
|
+
uid
|
|
33465
|
+
]);
|
|
33466
|
+
linkedCustomerContactIds = rows.map((row) => Number(row.id)).filter((id) => Number.isFinite(id) && id > 0);
|
|
33467
|
+
}
|
|
33468
|
+
const visibleOrders = await orderRepo().find({
|
|
33469
|
+
where: [
|
|
33470
|
+
{
|
|
33471
|
+
contactId: contact.id,
|
|
33472
|
+
deleted: false,
|
|
33473
|
+
orderKind: "sale"
|
|
33474
|
+
},
|
|
33475
|
+
...linkedCustomerContactIds.length ? [
|
|
33476
|
+
{
|
|
33477
|
+
customerContactId: In(linkedCustomerContactIds),
|
|
33478
|
+
deleted: false,
|
|
33479
|
+
orderKind: "sale"
|
|
33480
|
+
}
|
|
33481
|
+
] : []
|
|
33482
|
+
],
|
|
33464
33483
|
order: {
|
|
33465
33484
|
createdAt: "DESC"
|
|
33466
33485
|
},
|
|
33467
33486
|
take: 50
|
|
33468
33487
|
});
|
|
33488
|
+
const orders = visibleOrders.filter((o) => {
|
|
33489
|
+
const row = o;
|
|
33490
|
+
const orderContactId = Number(row.contactId);
|
|
33491
|
+
const customerContactId = Number(row.customerContactId);
|
|
33492
|
+
if (Number.isFinite(orderContactId) && orderContactId > 0 && orderContactId === Number(contact.id)) {
|
|
33493
|
+
return true;
|
|
33494
|
+
}
|
|
33495
|
+
if (Number.isFinite(customerContactId) && customerContactId > 0) {
|
|
33496
|
+
return linkedCustomerContactIds.includes(customerContactId);
|
|
33497
|
+
}
|
|
33498
|
+
return false;
|
|
33499
|
+
});
|
|
33469
33500
|
const orderIds = orders.map((o) => o.id);
|
|
33470
33501
|
const previewByOrder = {};
|
|
33471
33502
|
if (orderIds.length) {
|
|
@@ -33558,10 +33589,19 @@ function createStorefrontApiHandler(config) {
|
|
|
33558
33589
|
status: 404
|
|
33559
33590
|
});
|
|
33560
33591
|
const orderId = parseInt(path2[1], 10);
|
|
33592
|
+
let linkedCustomerContactIds = [];
|
|
33593
|
+
if (entityMap.customer && entityMap.customer_contacts) {
|
|
33594
|
+
const rows = await dataSource.query(`SELECT cc.id
|
|
33595
|
+
FROM customer_contacts cc
|
|
33596
|
+
JOIN customer c ON c.id = cc."customerId"
|
|
33597
|
+
WHERE c."userId" = $1`, [
|
|
33598
|
+
uid
|
|
33599
|
+
]);
|
|
33600
|
+
linkedCustomerContactIds = rows.map((row) => Number(row.id)).filter((id) => Number.isFinite(id) && id > 0);
|
|
33601
|
+
}
|
|
33561
33602
|
let order = await orderRepo().findOne({
|
|
33562
33603
|
where: {
|
|
33563
33604
|
id: orderId,
|
|
33564
|
-
contactId: contact.id,
|
|
33565
33605
|
deleted: false
|
|
33566
33606
|
},
|
|
33567
33607
|
relations: [
|
|
@@ -33574,13 +33614,20 @@ function createStorefrontApiHandler(config) {
|
|
|
33574
33614
|
}, {
|
|
33575
33615
|
status: 404
|
|
33576
33616
|
});
|
|
33617
|
+
const orderContactId = Number(order.contactId);
|
|
33618
|
+
const orderCustomerContactId = Number(order.customerContactId);
|
|
33619
|
+
const isOwner = Number.isFinite(orderContactId) && orderContactId > 0 && orderContactId === Number(contact.id) || Number.isFinite(orderCustomerContactId) && orderCustomerContactId > 0 && linkedCustomerContactIds.includes(orderCustomerContactId);
|
|
33620
|
+
if (!isOwner) return json({
|
|
33621
|
+
error: "Not found"
|
|
33622
|
+
}, {
|
|
33623
|
+
status: 404
|
|
33624
|
+
});
|
|
33577
33625
|
if (getCms) {
|
|
33578
33626
|
const cms = await getCms();
|
|
33579
33627
|
await tryRefreshOrderFromErpForStorefront(cms, dataSource, entityMap, order);
|
|
33580
33628
|
order = await orderRepo().findOne({
|
|
33581
33629
|
where: {
|
|
33582
33630
|
id: orderId,
|
|
33583
|
-
contactId: contact.id,
|
|
33584
33631
|
deleted: false
|
|
33585
33632
|
},
|
|
33586
33633
|
relations: [
|
|
@@ -33594,6 +33641,14 @@ function createStorefrontApiHandler(config) {
|
|
|
33594
33641
|
}, {
|
|
33595
33642
|
status: 404
|
|
33596
33643
|
});
|
|
33644
|
+
const refreshedOrderContactId = Number(order.contactId);
|
|
33645
|
+
const refreshedCustomerContactId = Number(order.customerContactId);
|
|
33646
|
+
const isOwnerAfterRefresh = Number.isFinite(refreshedOrderContactId) && refreshedOrderContactId > 0 && refreshedOrderContactId === Number(contact.id) || Number.isFinite(refreshedCustomerContactId) && refreshedCustomerContactId > 0 && linkedCustomerContactIds.includes(refreshedCustomerContactId);
|
|
33647
|
+
if (!isOwnerAfterRefresh) return json({
|
|
33648
|
+
error: "Not found"
|
|
33649
|
+
}, {
|
|
33650
|
+
status: 404
|
|
33651
|
+
});
|
|
33597
33652
|
const o = order;
|
|
33598
33653
|
const lines = (o.items || []).map((line) => {
|
|
33599
33654
|
const p = line.product;
|