@7365admin1/core 3.48.1-staging.151 → 3.48.1-staging.152
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/service-provider-record-scope.md +39 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/harness.mjs +7 -0
- package/test/e2e/service-provider-record-scope.e2e.test.mjs +281 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@7365admin1/core": minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Scope the service provider record routes to the site the engagement works on.
|
|
6
|
+
|
|
7
|
+
A `site.service-providers` row is an ENGAGEMENT: a provider organisation attached
|
|
8
|
+
to one client's site. Two routes took its id straight out of the URL with
|
|
9
|
+
`requireAuth` and nothing more, so any signed-in account could use them against
|
|
10
|
+
any client:
|
|
11
|
+
|
|
12
|
+
- `GET /api/service-providers/:id` returned any client's engagement — provider
|
|
13
|
+
name, category, contact email and the site it works on.
|
|
14
|
+
- `PATCH /api/service-providers/:id/status` suspended or reactivated it.
|
|
15
|
+
Suspending an engagement stops that provider's guards and cleaners reaching the
|
|
16
|
+
estate; reactivating one puts them back.
|
|
17
|
+
|
|
18
|
+
Both now decide from the **site stored on the row**, through the existing
|
|
19
|
+
`requireSiteReach` rule that `/api/vehicles` and `/api/documents` already use.
|
|
20
|
+
That rule admits both sides of the engagement: the client, and the contracted
|
|
21
|
+
provider whose reach comes from `customer.sites` rather than from a membership in
|
|
22
|
+
the client's organisation.
|
|
23
|
+
|
|
24
|
+
An engagement the caller cannot reach answers exactly as one that does not exist
|
|
25
|
+
(404), so ids cannot be enumerated from the difference. A row carrying no site at
|
|
26
|
+
all is refused, not waved through. Guards sit after each handler's Joi
|
|
27
|
+
validation, so a malformed id or status still answers 400 exactly as today.
|
|
28
|
+
|
|
29
|
+
Scope note — deliberately NOT changed here: the four list routes
|
|
30
|
+
(`GET /api/service-providers`, `/name`, `/category`,
|
|
31
|
+
`/org/:serviceProviderOrgId/type/:type`) and `GET /provider/:provider/org/:org`.
|
|
32
|
+
Their `orgId`, `siteId` and `serviceProviderOrgId` are optional filters the
|
|
33
|
+
caller sends, and `layer-common useServiceProvider.ts` defaults every one of them
|
|
34
|
+
to an empty string, so it is not yet established which callers depend on the
|
|
35
|
+
unfiltered list. That is the same open question as the site-less
|
|
36
|
+
`GET /api/vehicles` and needs a product decision rather than a guess.
|
|
37
|
+
|
|
38
|
+
Nothing changes for a permitted caller: same response shape, same fields, same
|
|
39
|
+
status.
|
package/dist/index.js
CHANGED
|
@@ -32562,6 +32562,7 @@ function useServiceProviderController() {
|
|
|
32562
32562
|
}
|
|
32563
32563
|
try {
|
|
32564
32564
|
const data = await _getServiceProviderById(_id);
|
|
32565
|
+
await requireSiteReach(req, data?.siteId?.toString());
|
|
32565
32566
|
res.json(data);
|
|
32566
32567
|
return;
|
|
32567
32568
|
} catch (error2) {
|
|
@@ -32625,6 +32626,8 @@ function useServiceProviderController() {
|
|
|
32625
32626
|
return;
|
|
32626
32627
|
}
|
|
32627
32628
|
try {
|
|
32629
|
+
const existing = await _getServiceProviderById(value.id);
|
|
32630
|
+
await requireSiteReach(req, existing?.siteId?.toString());
|
|
32628
32631
|
await _updateStatusById(value.id, value.status);
|
|
32629
32632
|
res.json({ message: "Service provider status updated successfully." });
|
|
32630
32633
|
return;
|