@7365admin1/core 3.64.0 → 3.64.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @iservice365/core
2
2
 
3
+ ## 3.64.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f90c6f0: Return one row per site from `/api/customer-sites`, named by the site.
8
+
9
+ `getAll` grouped by `{ name, site }`. A customer-sites row is an ENGAGEMENT and
10
+ one site can carry more than one, so two rows for the same site with different
11
+ names both survived as "distinct" — a provider's site list showed four entries
12
+ for three sites, and the site switcher ticked two at once.
13
+
14
+ `name` is also a snapshot from when the engagement was created and goes stale
15
+ when the site is renamed; recency is no guide, since the newer row held the
16
+ staler name. The site is now looked up and its live name projected over the
17
+ snapshot, with the stored name kept as a fallback.
18
+
19
+ The search and the sort both run after the rename, so a site is found and
20
+ ordered by the name it actually has, and the count is derived from the same
21
+ pipeline.
22
+
23
+ ## 3.64.1
24
+
25
+ ### Patch Changes
26
+
27
+ - 1d856a3: Stop `/api/roles/v2` minting a role that holds the console's own resources.
28
+
29
+ `role.controller createRole` has carried `requireNoPlatformGrant` for a while;
30
+ `role-v2.controller createRole` did not. It is a separate controller behind a
31
+ separate route and accepts any permission string, so the hole was reachable by
32
+ adding `/v2` to the URL.
33
+
34
+ Measured on production before adding: no site-scoped role holds a platform-only
35
+ string, and this mount requires a `site`, so the check refuses nothing that
36
+ exists today. It only ever refuses a NEW grant regardless.
37
+
3
38
  ## 3.64.0
4
39
 
5
40
  ### Minor Changes
package/dist/index.js CHANGED
@@ -14145,7 +14145,6 @@ function useCustomerSiteRepo() {
14145
14145
  cacheOptions.siteScope = scoped.length ? [...scoped].sort().join(",") : "no-site";
14146
14146
  }
14147
14147
  if (search) {
14148
- query2.$or = [{ name: { $regex: search, $options: "i" } }];
14149
14148
  cacheOptions.search = search;
14150
14149
  }
14151
14150
  const cacheKey = (0, import_node_server_utils26.makeCacheKey)(namespace_collection2, cacheOptions);
@@ -14158,8 +14157,20 @@ function useCustomerSiteRepo() {
14158
14157
  const distinctPipeline = [
14159
14158
  { $match: query2 },
14160
14159
  { $sort: sort },
14161
- { $group: { _id: { name: "$name", site: "$site" }, doc: { $first: "$$ROOT" } } },
14160
+ { $group: { _id: "$site", doc: { $first: "$$ROOT" } } },
14162
14161
  { $replaceRoot: { newRoot: "$doc" } },
14162
+ {
14163
+ $lookup: {
14164
+ from: "sites",
14165
+ localField: "site",
14166
+ foreignField: "_id",
14167
+ as: "_liveSite"
14168
+ }
14169
+ },
14170
+ { $unwind: { path: "$_liveSite", preserveNullAndEmptyArrays: true } },
14171
+ { $set: { name: { $ifNull: ["$_liveSite.name", "$name"] } } },
14172
+ { $unset: "_liveSite" },
14173
+ ...search ? [{ $match: { name: { $regex: search, $options: "i" } } }] : [],
14163
14174
  { $sort: sort }
14164
14175
  ];
14165
14176
  const items = await collection.aggregate(
@@ -14170,14 +14181,7 @@ function useCustomerSiteRepo() {
14170
14181
  ],
14171
14182
  { session }
14172
14183
  ).toArray();
14173
- const countResult = await collection.aggregate(
14174
- [
14175
- { $match: query2 },
14176
- { $group: { _id: { name: "$name", site: "$site" } } },
14177
- { $count: "total" }
14178
- ],
14179
- { session }
14180
- ).toArray();
14184
+ const countResult = await collection.aggregate([...distinctPipeline, { $count: "total" }], { session }).toArray();
14181
14185
  const length = countResult[0]?.total ?? 0;
14182
14186
  const data = (0, import_node_server_utils26.paginate)(items, page, limit, length);
14183
14187
  setCache(cacheKey, data, 15 * 60).then(() => {
@@ -88415,6 +88419,10 @@ function useRoleControllerV2() {
88415
88419
  if (value.org) {
88416
88420
  await requireOrgReach(req, value.org);
88417
88421
  }
88422
+ requireNoPlatformGrant(
88423
+ { type: value.type, org: value.org, permissions: [] },
88424
+ value.permissions
88425
+ );
88418
88426
  requireWithinModules(
88419
88427
  await moduleCeiling(value.org, value.site),
88420
88428
  value.permissions