@7365admin1/core 3.52.11 → 3.52.12
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 +18 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.js +64 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/building-estate-site-scope.test.mjs +157 -0
package/dist/index.mjs
CHANGED
|
@@ -34468,7 +34468,17 @@ function useBuildingUnitRepo() {
|
|
|
34468
34468
|
sort = {},
|
|
34469
34469
|
site = "",
|
|
34470
34470
|
building = "",
|
|
34471
|
-
status = "active"
|
|
34471
|
+
status = "active",
|
|
34472
|
+
/**
|
|
34473
|
+
* The sites this caller may be shown, or `null` for no restriction. Set only
|
|
34474
|
+
* when the request named NO site — see `entitledSites`. Applied inside the
|
|
34475
|
+
* query so the page counts describe what the caller can actually see, and
|
|
34476
|
+
* folded into the cache key so one caller's page is never served to another.
|
|
34477
|
+
*
|
|
34478
|
+
* An EMPTY array means "this caller reaches no site" and must still be
|
|
34479
|
+
* applied: `$in: []` matches nothing, which is the fail-closed answer.
|
|
34480
|
+
*/
|
|
34481
|
+
siteScope = null
|
|
34472
34482
|
} = {}) {
|
|
34473
34483
|
page = page > 0 ? page - 1 : 0;
|
|
34474
34484
|
const searchText = search.trim();
|
|
@@ -34493,6 +34503,11 @@ function useBuildingUnitRepo() {
|
|
|
34493
34503
|
building_units_namespace_collection,
|
|
34494
34504
|
cacheParams
|
|
34495
34505
|
);
|
|
34506
|
+
if (siteScope) {
|
|
34507
|
+
const scoped = siteScope.filter((id) => ObjectId67.isValid(id));
|
|
34508
|
+
query2.site = { $in: scoped.map((id) => new ObjectId67(id)) };
|
|
34509
|
+
cacheParams.siteScope = scoped.length ? [...scoped].sort().join(",") : "no-site";
|
|
34510
|
+
}
|
|
34496
34511
|
logger62.log({
|
|
34497
34512
|
level: "info",
|
|
34498
34513
|
message: `Cache key for getAll building units: ${cacheKey}`
|
|
@@ -37286,7 +37301,17 @@ function useBuildingRepo() {
|
|
|
37286
37301
|
limit = 10,
|
|
37287
37302
|
sort = {},
|
|
37288
37303
|
site = "",
|
|
37289
|
-
status = "active" /* ACTIVE
|
|
37304
|
+
status = "active" /* ACTIVE */,
|
|
37305
|
+
/**
|
|
37306
|
+
* The sites this caller may be shown, or `null` for no restriction. Set only
|
|
37307
|
+
* when the request named NO site — see `entitledSites`. Applied inside the
|
|
37308
|
+
* query so the page counts describe what the caller can actually see, and
|
|
37309
|
+
* folded into the cache key so one caller's page is never served to another.
|
|
37310
|
+
*
|
|
37311
|
+
* An EMPTY array means "this caller reaches no site" and must still be
|
|
37312
|
+
* applied: `$in: []` matches nothing, which is the fail-closed answer.
|
|
37313
|
+
*/
|
|
37314
|
+
siteScope = null
|
|
37290
37315
|
} = {}) {
|
|
37291
37316
|
page = page > 0 ? page - 1 : 0;
|
|
37292
37317
|
let siteId;
|
|
@@ -37320,6 +37345,11 @@ function useBuildingRepo() {
|
|
|
37320
37345
|
...status && { status }
|
|
37321
37346
|
};
|
|
37322
37347
|
const cacheKey = makeCacheKey27(buildings_namespace_collection, cacheParams);
|
|
37348
|
+
if (siteScope) {
|
|
37349
|
+
const scoped = siteScope.filter((id) => ObjectId70.isValid(id));
|
|
37350
|
+
query2.site = { $in: scoped.map((id) => new ObjectId70(id)) };
|
|
37351
|
+
cacheParams.siteScope = scoped.length ? [...scoped].sort().join(",") : "no-site";
|
|
37352
|
+
}
|
|
37323
37353
|
logger69.log({
|
|
37324
37354
|
level: "info",
|
|
37325
37355
|
message: `Cache key for getAll buildings: ${cacheKey}`
|
|
@@ -37994,7 +38024,17 @@ function useBuildingLevelRepo() {
|
|
|
37994
38024
|
limit = 10,
|
|
37995
38025
|
sort = {},
|
|
37996
38026
|
site = "",
|
|
37997
|
-
status = "active"
|
|
38027
|
+
status = "active",
|
|
38028
|
+
/**
|
|
38029
|
+
* The sites this caller may be shown, or `null` for no restriction. Set only
|
|
38030
|
+
* when the request named NO site — see `entitledSites`. Applied inside the
|
|
38031
|
+
* query so the page counts describe what the caller can actually see, and
|
|
38032
|
+
* folded into the cache key so one caller's page is never served to another.
|
|
38033
|
+
*
|
|
38034
|
+
* An EMPTY array means "this caller reaches no site" and must still be
|
|
38035
|
+
* applied: `$in: []` matches nothing, which is the fail-closed answer.
|
|
38036
|
+
*/
|
|
38037
|
+
siteScope = null
|
|
37998
38038
|
} = {}) {
|
|
37999
38039
|
page = page > 0 ? page - 1 : 0;
|
|
38000
38040
|
const query2 = {
|
|
@@ -38014,6 +38054,11 @@ function useBuildingLevelRepo() {
|
|
|
38014
38054
|
building_level_namespace_collection,
|
|
38015
38055
|
cacheParams
|
|
38016
38056
|
);
|
|
38057
|
+
if (siteScope) {
|
|
38058
|
+
const scoped = siteScope.filter((id) => ObjectId72.isValid(id));
|
|
38059
|
+
query2.site = { $in: scoped.map((id) => new ObjectId72(id)) };
|
|
38060
|
+
cacheParams.siteScope = scoped.length ? [...scoped].sort().join(",") : "no-site";
|
|
38061
|
+
}
|
|
38017
38062
|
logger71.log({
|
|
38018
38063
|
level: "info",
|
|
38019
38064
|
message: `Cache key for getAll building levels: ${cacheKey}`
|
|
@@ -38991,13 +39036,17 @@ function useBuildingController() {
|
|
|
38991
39036
|
const search = value.search ?? "";
|
|
38992
39037
|
const sortObj = sort ? { [sort]: order === "asc" /* ASC */ ? 1 : -1 } : {};
|
|
38993
39038
|
try {
|
|
39039
|
+
const siteScope = site ? null : await entitledSites(req);
|
|
39040
|
+
if (site)
|
|
39041
|
+
await requireSiteReach(req, site);
|
|
38994
39042
|
const buildings = await _getAll({
|
|
38995
39043
|
page,
|
|
38996
39044
|
limit,
|
|
38997
39045
|
sort: sortObj,
|
|
38998
39046
|
status,
|
|
38999
39047
|
site,
|
|
39000
|
-
search
|
|
39048
|
+
search,
|
|
39049
|
+
siteScope
|
|
39001
39050
|
});
|
|
39002
39051
|
res.json(buildings);
|
|
39003
39052
|
return;
|
|
@@ -39634,6 +39683,9 @@ function useBuildingUnitController() {
|
|
|
39634
39683
|
const site = value.site;
|
|
39635
39684
|
const building = value.building;
|
|
39636
39685
|
const search = value.search;
|
|
39686
|
+
const siteScope = site ? null : await entitledSites(req);
|
|
39687
|
+
if (site)
|
|
39688
|
+
await requireSiteReach(req, site);
|
|
39637
39689
|
const buildings = await _getAll({
|
|
39638
39690
|
page,
|
|
39639
39691
|
limit,
|
|
@@ -39641,7 +39693,8 @@ function useBuildingUnitController() {
|
|
|
39641
39693
|
status,
|
|
39642
39694
|
site,
|
|
39643
39695
|
search,
|
|
39644
|
-
building
|
|
39696
|
+
building,
|
|
39697
|
+
siteScope
|
|
39645
39698
|
});
|
|
39646
39699
|
res.json(buildings);
|
|
39647
39700
|
return;
|
|
@@ -39755,6 +39808,7 @@ function useBuildingUnitController() {
|
|
|
39755
39808
|
}
|
|
39756
39809
|
const site = req.params.site;
|
|
39757
39810
|
try {
|
|
39811
|
+
await requireSiteReach(req, site);
|
|
39758
39812
|
const data = await _getBuildingUnitsWithOwner(site);
|
|
39759
39813
|
res.json(data);
|
|
39760
39814
|
return;
|
|
@@ -90093,12 +90147,16 @@ function useBuildingLevelController() {
|
|
|
90093
90147
|
return;
|
|
90094
90148
|
}
|
|
90095
90149
|
const { page, limit, status, site, search } = value;
|
|
90150
|
+
const siteScope = site ? null : await entitledSites(req);
|
|
90151
|
+
if (site)
|
|
90152
|
+
await requireSiteReach(req, site);
|
|
90096
90153
|
const result = await _getAll({
|
|
90097
90154
|
page,
|
|
90098
90155
|
limit,
|
|
90099
90156
|
status,
|
|
90100
90157
|
site,
|
|
90101
|
-
search
|
|
90158
|
+
search,
|
|
90159
|
+
siteScope
|
|
90102
90160
|
});
|
|
90103
90161
|
res.json(result);
|
|
90104
90162
|
return;
|