@7365admin1/core 3.48.1-staging.189 → 3.48.1-staging.190
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/.changeset/site-facility-site-scope.md +12 -0
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -103
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/harness.mjs +22 -0
- package/test/e2e/site-facility-scope.e2e.test.mjs +479 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@7365admin1/core": patch
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Scope the site facility routes to the estate. `/api/site-facilities` carried
|
|
6
|
+
`requireAuth` and nothing else on all six routes: any signed-in account could add a
|
|
7
|
+
facility to another estate, list another client's facilities — or, by omitting the
|
|
8
|
+
optional `site` filter, every estate's facilities at once — and read, rewrite or
|
|
9
|
+
archive any facility by id alone, including its opening hours, booking fees, deposit
|
|
10
|
+
and policies. Reach is now checked on the site named in the request, and on the
|
|
11
|
+
stored row where the request names only an id; the unfiltered cross-estate list is
|
|
12
|
+
left to platform staff.
|
package/dist/index.js
CHANGED
|
@@ -54721,6 +54721,14 @@ function useSiteFacilityController() {
|
|
|
54721
54721
|
getSiteFacilityById: _getSiteFacilityById,
|
|
54722
54722
|
deleteSiteFacilityById: _deleteSiteFacilityById
|
|
54723
54723
|
} = useSiteFacilityRepo();
|
|
54724
|
+
async function requireFacilityReach(req, id) {
|
|
54725
|
+
const facility = await _getSiteFacilityById(id);
|
|
54726
|
+
const { canReach } = await siteReachOf(req);
|
|
54727
|
+
if (!await canReach(facility)) {
|
|
54728
|
+
throw new import_node_server_utils162.NotFoundError("Site facility not found.");
|
|
54729
|
+
}
|
|
54730
|
+
return facility;
|
|
54731
|
+
}
|
|
54724
54732
|
async function add(req, res, next) {
|
|
54725
54733
|
const payload = { ...req.body };
|
|
54726
54734
|
const { error } = schemaSiteFacility.validate(payload, {
|
|
@@ -54733,6 +54741,7 @@ function useSiteFacilityController() {
|
|
|
54733
54741
|
return;
|
|
54734
54742
|
}
|
|
54735
54743
|
try {
|
|
54744
|
+
await requireSiteReach(req, payload.site);
|
|
54736
54745
|
const data = await _add(payload);
|
|
54737
54746
|
res.status(201).json(data);
|
|
54738
54747
|
return;
|
|
@@ -54779,6 +54788,13 @@ function useSiteFacilityController() {
|
|
|
54779
54788
|
}
|
|
54780
54789
|
});
|
|
54781
54790
|
try {
|
|
54791
|
+
if (site) {
|
|
54792
|
+
await requireSiteReach(req, site);
|
|
54793
|
+
} else {
|
|
54794
|
+
const { actor } = await siteReachOf(req);
|
|
54795
|
+
if (!actor.isSuperAdmin)
|
|
54796
|
+
throw new import_node_server_utils162.UnauthorizedError("Not authorized.");
|
|
54797
|
+
}
|
|
54782
54798
|
const data = await _getAll({
|
|
54783
54799
|
search,
|
|
54784
54800
|
page,
|
|
@@ -54805,7 +54821,7 @@ function useSiteFacilityController() {
|
|
|
54805
54821
|
return;
|
|
54806
54822
|
}
|
|
54807
54823
|
try {
|
|
54808
|
-
const data = await
|
|
54824
|
+
const data = await requireFacilityReach(req, _id);
|
|
54809
54825
|
res.status(200).json(data);
|
|
54810
54826
|
return;
|
|
54811
54827
|
} catch (error2) {
|
|
@@ -54827,6 +54843,7 @@ function useSiteFacilityController() {
|
|
|
54827
54843
|
return;
|
|
54828
54844
|
}
|
|
54829
54845
|
try {
|
|
54846
|
+
await requireFacilityReach(req, _id);
|
|
54830
54847
|
const result = await _updateSiteFacilityById(_id, req.body);
|
|
54831
54848
|
res.status(200).json({ message: result });
|
|
54832
54849
|
return;
|
|
@@ -54846,6 +54863,7 @@ function useSiteFacilityController() {
|
|
|
54846
54863
|
return;
|
|
54847
54864
|
}
|
|
54848
54865
|
try {
|
|
54866
|
+
await requireFacilityReach(req, _id);
|
|
54849
54867
|
await _deleteSiteFacilityById(_id);
|
|
54850
54868
|
res.status(200).json({ message: "Successfully deleted site facility." });
|
|
54851
54869
|
return;
|
|
@@ -54872,6 +54890,7 @@ function useSiteFacilityController() {
|
|
|
54872
54890
|
return next(new import_node_server_utils162.BadRequestError(error.message));
|
|
54873
54891
|
}
|
|
54874
54892
|
try {
|
|
54893
|
+
await requireSiteReach(req, value.site);
|
|
54875
54894
|
const data = await _getSiteFacilityTimeSlotById(
|
|
54876
54895
|
payload._id,
|
|
54877
54896
|
value.date,
|