@7365admin1/core 3.52.3-staging.242 → 3.52.3-staging.243
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/plates-hidden-on-all-person-reads.md +16 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/vehicle-plate-read-paths.e2e.test.mjs +67 -11
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@7365admin1/core": patch
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Hide deleted plates on every person read, not only on the two browse paths.
|
|
6
|
+
|
|
7
|
+
A vehicle's plate number is copied onto the resident's record as `site.people.plates[]`. Deleting the vehicle is meant to take it back out, and where that copy had already drifted the read paths filter it against the vehicle record. That filter was only on `GET /api/people` and `GET /api/people/unit/:unit`, so four other endpoints still handed back a plate whose only vehicle is deleted:
|
|
8
|
+
|
|
9
|
+
- `GET /api/people/plateNumber/:plateNumber`
|
|
10
|
+
- `GET /api/people/nric/:nric` (the MA app's NRIC lookup, and layer-common's `findPersonByNRIC`)
|
|
11
|
+
- `GET /api/people/contact/:contact`
|
|
12
|
+
- `GET /api/people/all-nric` (the MA app's NRIC search)
|
|
13
|
+
|
|
14
|
+
Each of the four now applies the same filter. `status: { $ne: "deleted" }` on three of those queries is the PERSON's status and has nothing to do with the vehicle — reading it as "deleted plates are excluded" is how they were missed. The filter runs on the way out, after the Redis read, so a plate deleted inside the 15-minute cache window disappears immediately rather than at the next expiry.
|
|
15
|
+
|
|
16
|
+
Unchanged: a plate the resident merely declared, with no vehicle record at all, is still listed; a plate a second live vehicle still holds is still listed.
|
package/dist/index.d.ts
CHANGED
|
@@ -5056,7 +5056,13 @@ declare function usePersonRepo(): {
|
|
|
5056
5056
|
nric?: string | undefined;
|
|
5057
5057
|
sort?: Record<string, any> | undefined;
|
|
5058
5058
|
site: string;
|
|
5059
|
-
}) => Promise<{
|
|
5059
|
+
}) => Promise<{
|
|
5060
|
+
items: any[];
|
|
5061
|
+
pages: number;
|
|
5062
|
+
pageRange: string;
|
|
5063
|
+
} | {
|
|
5064
|
+
items: TPerson[];
|
|
5065
|
+
}>;
|
|
5060
5066
|
pushVehicleById: (id: string | ObjectId, plate: {
|
|
5061
5067
|
plateNumber: string;
|
|
5062
5068
|
recNo: string;
|
package/dist/index.js
CHANGED
|
@@ -17606,6 +17606,12 @@ function usePersonRepo() {
|
|
|
17606
17606
|
return plates.length === person.plates.length ? person : { ...person, plates };
|
|
17607
17607
|
});
|
|
17608
17608
|
}
|
|
17609
|
+
async function withoutDeletedPlatesOne(person) {
|
|
17610
|
+
if (!person)
|
|
17611
|
+
return person;
|
|
17612
|
+
const [clean] = await withoutDeletedPlates([person]);
|
|
17613
|
+
return clean ?? person;
|
|
17614
|
+
}
|
|
17609
17615
|
async function createIndexes() {
|
|
17610
17616
|
try {
|
|
17611
17617
|
await collection.createIndexes([
|
|
@@ -17907,7 +17913,7 @@ function usePersonRepo() {
|
|
|
17907
17913
|
const cacheData = await getCache(cacheKey);
|
|
17908
17914
|
if (cacheData) {
|
|
17909
17915
|
import_node_server_utils41.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
17910
|
-
return cacheData;
|
|
17916
|
+
return await withoutDeletedPlatesOne(cacheData);
|
|
17911
17917
|
}
|
|
17912
17918
|
const data = await collection.findOne(
|
|
17913
17919
|
{ "plates.plateNumber": plateNumber, status: { $ne: "deleted" } },
|
|
@@ -17918,7 +17924,7 @@ function usePersonRepo() {
|
|
|
17918
17924
|
}).catch((err) => {
|
|
17919
17925
|
import_node_server_utils41.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
17920
17926
|
});
|
|
17921
|
-
return data;
|
|
17927
|
+
return await withoutDeletedPlatesOne(data);
|
|
17922
17928
|
} catch (error) {
|
|
17923
17929
|
throw new import_node_server_utils41.InternalServerError(
|
|
17924
17930
|
"Failed to fetch individual by plate number."
|
|
@@ -17953,7 +17959,7 @@ function usePersonRepo() {
|
|
|
17953
17959
|
const cachedData = await getCache(cacheKey);
|
|
17954
17960
|
if (cachedData) {
|
|
17955
17961
|
import_node_server_utils41.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
17956
|
-
return cachedData;
|
|
17962
|
+
return await withoutDeletedPlatesOne(cachedData);
|
|
17957
17963
|
}
|
|
17958
17964
|
const data = await collection.findOne({ nric: value });
|
|
17959
17965
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
@@ -17961,7 +17967,7 @@ function usePersonRepo() {
|
|
|
17961
17967
|
}).catch((err) => {
|
|
17962
17968
|
import_node_server_utils41.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
17963
17969
|
});
|
|
17964
|
-
return data;
|
|
17970
|
+
return await withoutDeletedPlatesOne(data);
|
|
17965
17971
|
} catch (error) {
|
|
17966
17972
|
throw new import_node_server_utils41.InternalServerError("Failed to retrieve person by NRIC.");
|
|
17967
17973
|
}
|
|
@@ -17974,7 +17980,7 @@ function usePersonRepo() {
|
|
|
17974
17980
|
const cachedData = await getCache(cacheKey);
|
|
17975
17981
|
if (cachedData) {
|
|
17976
17982
|
import_node_server_utils41.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
17977
|
-
return cachedData;
|
|
17983
|
+
return await withoutDeletedPlatesOne(cachedData);
|
|
17978
17984
|
}
|
|
17979
17985
|
const data = await collection.findOne({ contact: value });
|
|
17980
17986
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
@@ -17982,7 +17988,7 @@ function usePersonRepo() {
|
|
|
17982
17988
|
}).catch((err) => {
|
|
17983
17989
|
import_node_server_utils41.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
17984
17990
|
});
|
|
17985
|
-
return data;
|
|
17991
|
+
return await withoutDeletedPlatesOne(data);
|
|
17986
17992
|
} catch (error) {
|
|
17987
17993
|
throw new import_node_server_utils41.InternalServerError(
|
|
17988
17994
|
"Failed to retrieve person by Phone Number."
|
|
@@ -18175,11 +18181,20 @@ function usePersonRepo() {
|
|
|
18175
18181
|
const cachedData = await getCache(cacheKey);
|
|
18176
18182
|
if (cachedData) {
|
|
18177
18183
|
import_node_server_utils41.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
18178
|
-
|
|
18184
|
+
const cachedPage = cachedData;
|
|
18185
|
+
return {
|
|
18186
|
+
...cachedPage,
|
|
18187
|
+
items: await withoutDeletedPlates(cachedPage.items ?? [])
|
|
18188
|
+
};
|
|
18179
18189
|
}
|
|
18180
18190
|
const items = await collection.find(query2).sort(sort).skip(page * limit).limit(limit).toArray();
|
|
18181
18191
|
const length = await collection.countDocuments(query2);
|
|
18182
|
-
const data = (0, import_node_server_utils41.paginate)(
|
|
18192
|
+
const data = (0, import_node_server_utils41.paginate)(
|
|
18193
|
+
await withoutDeletedPlates(items),
|
|
18194
|
+
page,
|
|
18195
|
+
limit,
|
|
18196
|
+
length
|
|
18197
|
+
);
|
|
18183
18198
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
18184
18199
|
import_node_server_utils41.logger.info(`Cache set for key: ${cacheKey}`);
|
|
18185
18200
|
}).catch((err) => {
|