@7365admin1/core 3.128.0 → 3.129.1
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 +12 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +64 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/console-audit.test.mjs +13 -0
- package/test/e2e/visitor-search.e2e.test.mjs +27 -0
- package/test/visitor-search.test.mjs +4 -1
package/package.json
CHANGED
|
@@ -369,3 +369,16 @@ test("inventory store-type repair: its row keeps only the type and the store nam
|
|
|
369
369
|
assert.ok(CONSOLE_AUDIT_LABELS[action]);
|
|
370
370
|
assert.deepEqual(pickAuditFields(action, { ownerType: "service_provider", name: "Main Store", createdBy: "x", email: "a@b.c" }), { ownerType: "service_provider", name: "Main Store" });
|
|
371
371
|
});
|
|
372
|
+
|
|
373
|
+
test("inventory item archive/restore: the row keeps status, item name, store and reason only", async () => {
|
|
374
|
+
const { ConsoleAuditAction, pickAuditFields, CONSOLE_AUDIT_LABELS, ConsoleAuditTarget } = await import("./.build/utils/console-audit.util.mjs");
|
|
375
|
+
for (const action of [ConsoleAuditAction.INVENTORY_ITEM_ARCHIVED, ConsoleAuditAction.INVENTORY_ITEM_RESTORED]) {
|
|
376
|
+
assert.ok(CONSOLE_AUDIT_LABELS[action]);
|
|
377
|
+
assert.deepEqual(
|
|
378
|
+
pickAuditFields(action, { status: "archived", name: "Bulb", store: "Main Store", reason: "old", onHand: 0, createdBy: "x" }),
|
|
379
|
+
{ status: "archived", name: "Bulb", store: "Main Store", reason: "old" },
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
assert.equal(ConsoleAuditAction.INVENTORY_ITEM_ARCHIVED, "inventory.item-archived");
|
|
383
|
+
if (ConsoleAuditTarget) assert.equal(ConsoleAuditTarget.INVENTORY_ITEM, "inventory-item");
|
|
384
|
+
});
|
|
@@ -19,6 +19,9 @@ const blockB = new ObjectId();
|
|
|
19
19
|
const level03 = new ObjectId();
|
|
20
20
|
const unit06 = new ObjectId();
|
|
21
21
|
const now = new Date("2026-09-28T08:00:00Z");
|
|
22
|
+
const passTpl = new ObjectId();
|
|
23
|
+
const passKey = new ObjectId();
|
|
24
|
+
const plainKey = new ObjectId();
|
|
22
25
|
|
|
23
26
|
test.before(async () => {
|
|
24
27
|
mongo = await MongoMemoryServer.create();
|
|
@@ -32,6 +35,12 @@ test.before(async () => {
|
|
|
32
35
|
await db.collection("building-levels").insertOne({ _id: level03, site: siteA, name: "03" });
|
|
33
36
|
await db.collection("building-units").insertOne({ _id: unit06, site: siteA, name: "06", level: level03, building: blockA });
|
|
34
37
|
|
|
38
|
+
await db.collection("qr-code-templates").insertOne({ _id: passTpl, prefixPass: "VP-C" });
|
|
39
|
+
await db.collection("keys").insertMany([
|
|
40
|
+
{ _id: passKey, name: "02", template: passTpl },
|
|
41
|
+
{ _id: plainKey, name: "X02" },
|
|
42
|
+
]);
|
|
43
|
+
|
|
35
44
|
const v = (o) => ({ status: "registered", type: "contractor", checkIn: now, expectedCheckIn: now, createdAt: now, ...o });
|
|
36
45
|
await db.collection("visitor.transactions").insertMany([
|
|
37
46
|
v({ site: siteA, name: "Dion", contact: "+6591177963", plateNumber: "SLM1189Y", company: "Asia", nric: "S1234963A", block: blockA, level: level03, unit: unit06 }),
|
|
@@ -40,6 +49,8 @@ test.before(async () => {
|
|
|
40
49
|
v({ site: siteA, name: "Dion Pending", status: "pending" }),
|
|
41
50
|
// Another customer's site: same name, same plate, same block name.
|
|
42
51
|
v({ site: siteB, name: "Dion", plateNumber: "SLM1189Y", block: blockB }),
|
|
52
|
+
v({ site: siteA, name: "Pass Holder", visitorPass: [{ keyId: passKey }] }),
|
|
53
|
+
v({ site: siteA, name: "Key Holder", passKeys: [{ keyId: plainKey }] }),
|
|
43
54
|
...Array.from({ length: 12 }, (_, i) => v({ site: siteA, name: `Bulk ${i}`, company: "Bulkco" })),
|
|
44
55
|
]);
|
|
45
56
|
|
|
@@ -105,3 +116,19 @@ test("paging is bounded and counts describe the search", async () => {
|
|
|
105
116
|
assert.equal(p2.items.length, 2);
|
|
106
117
|
assert.equal(p1.pages, 2);
|
|
107
118
|
});
|
|
119
|
+
|
|
120
|
+
test("pass / key by template prefix + name, across the join, any case", async () => {
|
|
121
|
+
// "VP-C" + "02": whole, spanning the prefix/name boundary, prefix only, name only.
|
|
122
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "vp-c02" })), ["Pass Holder"]);
|
|
123
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "C02" })), ["Pass Holder"]);
|
|
124
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "vp-c" })), ["Pass Holder"]);
|
|
125
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "02" })), ["Key Holder", "Pass Holder"]);
|
|
126
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "x02" })), ["Key Holder"]);
|
|
127
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "C03" })), []);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("block / level / unit names and the combined form", async () => {
|
|
131
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "3/03" })), ["Dion"]);
|
|
132
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "3/3" })), []);
|
|
133
|
+
assert.deepEqual(names(await repo.getAll({ ...base, search: "4/03/06" })), []);
|
|
134
|
+
});
|
|
@@ -118,5 +118,8 @@ test("repository wiring: the search box goes through the util, after the site/da
|
|
|
118
118
|
assert.ok(!/name: \{ \$regex: search/.test(repo), "raw name-only regex is gone");
|
|
119
119
|
assert.match(repo, /const text = normaliseVisitorSearch\(search\);/);
|
|
120
120
|
assert.match(repo, /\.\.\.visitorRowSearchOr\(text\),/);
|
|
121
|
-
assert.match(repo, /\{ \$match: query \},\s
|
|
121
|
+
assert.match(repo, /\{ \$match: query \},\s*\.\.\.\(await buildSearchStages\(search, searchSiteIds\)\),/);
|
|
122
|
+
// No per-row joins in the search: block/level/unit and keys are resolved to ids first.
|
|
123
|
+
const stages = repo.slice(repo.indexOf("async function buildSearchStages"), repo.indexOf("async function createTextIndex"));
|
|
124
|
+
assert.ok(!stages.includes("$lookup"), "search stages must not $lookup per visitor row");
|
|
122
125
|
});
|