@7365admin1/core 3.52.10 → 3.52.11-staging.259

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Reconcile the camera site-reach rule with the site-list rule: an organisation-level role reaches every site of its own organisation even when its membership row also names a site.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Scope the visitor-transaction list to the caller's own sites when none is named, and authorise the site the document list is given
package/dist/index.d.ts CHANGED
@@ -5016,7 +5016,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
5016
5016
  declare const visitors_namespace_collection = "visitor.transactions";
5017
5017
  declare function useVisitorTransactionRepo(): {
5018
5018
  add: (value: TVisitorTransaction, session?: ClientSession, returnValue?: boolean) => Promise<any>;
5019
- getAll: ({ search, page, limit, sort, status, org, site, dateTo, dateFrom, type, checkedOut, plateNumber, tab, passOrKey, }: {
5019
+ getAll: ({ search, page, limit, sort, status, org, site, dateTo, dateFrom, type, checkedOut, plateNumber, tab, passOrKey, siteScope, }: {
5020
5020
  search?: string | undefined;
5021
5021
  page?: number | undefined;
5022
5022
  limit?: number | undefined;
@@ -5034,6 +5034,16 @@ declare function useVisitorTransactionRepo(): {
5034
5034
  keyId: string;
5035
5035
  type: string;
5036
5036
  } | undefined;
5037
+ /**
5038
+ * The sites this caller may be shown, or `null` for no restriction. Set
5039
+ * only when the request named NO site - see `entitledSites`. Applied inside
5040
+ * the query so the page counts describe what the caller can actually see.
5041
+ *
5042
+ * An EMPTY array means "this caller reaches no site" and must still be
5043
+ * applied: `$in: []` matches nothing, which is the fail-closed answer. It is
5044
+ * deliberately not collapsed into the falsy branch alongside `null`.
5045
+ */
5046
+ siteScope?: string[] | null | undefined;
5037
5047
  }) => Promise<{
5038
5048
  items: any[];
5039
5049
  pages: number;
package/dist/index.js CHANGED
@@ -20293,7 +20293,8 @@ function useVisitorTransactionRepo() {
20293
20293
  checkedOut,
20294
20294
  plateNumber = "",
20295
20295
  tab = "",
20296
- passOrKey
20296
+ passOrKey,
20297
+ siteScope
20297
20298
  }) {
20298
20299
  page = page > 0 ? page - 1 : 0;
20299
20300
  const skip = page * limit;
@@ -20314,6 +20315,11 @@ function useVisitorTransactionRepo() {
20314
20315
  const query2 = {
20315
20316
  ...import_mongodb40.ObjectId.isValid(org) && { org: new import_mongodb40.ObjectId(org) },
20316
20317
  ...import_mongodb40.ObjectId.isValid(site) && { site: new import_mongodb40.ObjectId(site) },
20318
+ ...siteScope ? {
20319
+ site: {
20320
+ $in: siteScope.filter((id) => import_mongodb40.ObjectId.isValid(id)).map((id) => new import_mongodb40.ObjectId(id))
20321
+ }
20322
+ } : {},
20317
20323
  ...Object.keys(checkInFilter).length > 0 && { checkIn: checkInFilter },
20318
20324
  ...Object.keys(expectedCheckInFilter).length > 0 && {
20319
20325
  expectedCheckIn: expectedCheckInFilter
@@ -52400,7 +52406,7 @@ function useVisitorTransactionService() {
52400
52406
  unitName: unit?.name,
52401
52407
  org: inviter?.org?.toString(),
52402
52408
  site: inviter?.site.toString(),
52403
- status: value?.type === "contractor" ? isAutoApprovedInvitation ? "approved" /* APPROVED */ : "pending" /* PENDING */ : "pending" /* PENDING */,
52409
+ status: value?.type === "contractor" ? isAutoApprovedInvitation ? "approved" /* APPROVED */ : "pending" /* PENDING */ : "approved" /* APPROVED */,
52404
52410
  inviterId: userId
52405
52411
  };
52406
52412
  const leadId = new import_mongodb86.ObjectId();
@@ -57020,12 +57026,16 @@ function useVisitorTransactionController() {
57020
57026
  tab,
57021
57027
  passOrKey
57022
57028
  } = value;
57029
+ const siteScope = site ? null : await entitledSites(req);
57030
+ if (site)
57031
+ await requireSiteReach(req, site);
57023
57032
  const sortObj = {
57024
57033
  [sort ? sort : "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
57025
57034
  };
57026
57035
  const data = await _getAll({
57027
57036
  org,
57028
57037
  site,
57038
+ siteScope,
57029
57039
  search,
57030
57040
  page,
57031
57041
  limit,
@@ -64388,6 +64398,7 @@ function useDocumentManagementController() {
64388
64398
  const site = req.query.site ?? "";
64389
64399
  const parentId = req.query.parentId ?? "";
64390
64400
  try {
64401
+ await requireSiteReach(req, site);
64391
64402
  const data = await _getDocuments({
64392
64403
  search,
64393
64404
  page,