@7365admin1/core 3.102.0 → 3.102.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 +12 -0
- package/dist/index.js +30 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/e2e/dashboard-deleted-work-orders.e2e.test.mjs +54 -0
- package/test/e2e/org-and-promo-list-scope.e2e.test.mjs +44 -5
- package/test/org-search.test.mjs +41 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@7365admin1/core",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "3.102.
|
|
4
|
+
"version": "3.102.2",
|
|
5
5
|
"author": "7365admin1",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build": "tsup src/index.ts --format cjs,esm --dts && shx cp -r src/public dist && shx cp -r src/utils/handlebars dist",
|
|
14
14
|
"release": "yarn run build && changeset publish",
|
|
15
15
|
"lint": "tsc",
|
|
16
|
-
"test": "tsup src/config.ts src/utils/building-map.util.ts src/utils/robot-cloud.util.ts src/utils/robot-adapter.util.ts src/utils/png-encoder.util.ts src/services/demo.adapter.ts src/services/ounitech.adapter.ts src/services/open-rmf.adapter.ts src/utils/door-contract.util.ts src/utils/robot-fault.util.ts src/utils/robot-tracking.util.ts src/utils/robot-apps.util.ts src/utils/robot-permission.util.ts src/utils/robot-network.util.ts src/utils/lift-contract.util.ts src/models/robot-building-map.model.ts src/utils/anpr-revoke.util.ts src/utils/anpr-plate.util.ts src/utils/vehicle-request.util.ts src/utils/camera-view.util.ts src/utils/camera-bulk-import.util.ts src/utils/dashboard-metrics.util.ts src/utils/camera-capability.util.ts src/utils/camera-playback.util.ts src/services/camera-device-http.service.ts src/utils/camera-alert.util.ts src/utils/dahua-protocol.util.ts src/utils/site-name.util.ts src/utils/service-provider-invite.util.ts src/utils/notification-category.util.ts src/utils/notification-kind.util.ts src/models/notification.model.ts src/utils/hid-card.util.ts src/utils/hid-json.util.ts src/utils/hid-access.util.ts src/models/customer-site.model.ts src/models/site-camera.model.ts src/models/member.model.ts src/models/subscription.model.ts src/utils/session-id.util.ts src/utils/occurrence-query.util.ts src/utils/occurrence-book-create.util.ts src/utils/update-result.util.ts src/utils/hid-amico-authz.util.ts src/utils/promo-code-currency.util.ts src/utils/console-audit.util.ts src/utils/org-suspension.util.ts src/utils/session-revoke.util.ts src/models/hid-amico.model.ts src/models/patrol-email.model.ts src/utils/patrol-email-pdf.util.ts src/utils/visitor-status.util.ts src/utils/self-service-email.util.ts src/utils/hid-secret.util.ts src/models/visitor-invite.model.ts src/models/guard-invite.model.ts src/utils/site-timezone.util.ts src/utils/bulletin-service-apps.util.ts src/models/bulletin-board.model.ts src/utils/vehicle-import.util.ts src/utils/expired-vehicle-sweep.util.ts src/models/vehicle.model.ts src/controllers/chat.controller.ts src/utils/file-owner.util.ts src/utils/console-permission.util.ts src/utils/role-scope.util.ts src/utils/org-default-roles.util.ts src/utils/org-modules.util.ts src/utils/site-modules.util.ts src/utils/resident-app-modules.util.ts src/utils/resident-default-role.util.ts src/utils/invite-role-scope.util.ts src/models/personal-emergency-chain.model.ts src/utils/self-signup-files.util.ts src/models/person.model.ts src/utils/module-gate.util.ts src/utils/member-lookup.util.ts src/utils/notification-access.util.ts src/utils/module-access.util.ts src/services/module-gate.service.ts src/controllers/site.controller.ts src/controllers/organization.controller.ts src/controllers/member.controller.ts src/utils/org-owner-repair.util.ts src/utils/socket-session.util.ts src/utils/people-create-gate.util.ts src/utils/service-app-type.util.ts src/utils/customer-site-list.util.ts --format esm --out-dir test/.build --no-dts --silent && node --test test/*.test.mjs",
|
|
16
|
+
"test": "tsup src/config.ts src/utils/building-map.util.ts src/utils/robot-cloud.util.ts src/utils/robot-adapter.util.ts src/utils/png-encoder.util.ts src/services/demo.adapter.ts src/services/ounitech.adapter.ts src/services/open-rmf.adapter.ts src/utils/door-contract.util.ts src/utils/robot-fault.util.ts src/utils/robot-tracking.util.ts src/utils/robot-apps.util.ts src/utils/robot-permission.util.ts src/utils/robot-network.util.ts src/utils/lift-contract.util.ts src/models/robot-building-map.model.ts src/utils/anpr-revoke.util.ts src/utils/anpr-plate.util.ts src/utils/vehicle-request.util.ts src/utils/camera-view.util.ts src/utils/camera-bulk-import.util.ts src/utils/dashboard-metrics.util.ts src/utils/camera-capability.util.ts src/utils/camera-playback.util.ts src/services/camera-device-http.service.ts src/utils/camera-alert.util.ts src/utils/dahua-protocol.util.ts src/utils/site-name.util.ts src/utils/service-provider-invite.util.ts src/utils/notification-category.util.ts src/utils/notification-kind.util.ts src/models/notification.model.ts src/utils/hid-card.util.ts src/utils/hid-json.util.ts src/utils/hid-access.util.ts src/models/customer-site.model.ts src/models/site-camera.model.ts src/models/member.model.ts src/models/subscription.model.ts src/utils/session-id.util.ts src/utils/occurrence-query.util.ts src/utils/occurrence-book-create.util.ts src/utils/update-result.util.ts src/utils/hid-amico-authz.util.ts src/utils/promo-code-currency.util.ts src/utils/console-audit.util.ts src/utils/org-suspension.util.ts src/utils/session-revoke.util.ts src/models/hid-amico.model.ts src/models/patrol-email.model.ts src/utils/patrol-email-pdf.util.ts src/utils/visitor-status.util.ts src/utils/self-service-email.util.ts src/utils/hid-secret.util.ts src/models/visitor-invite.model.ts src/models/guard-invite.model.ts src/utils/site-timezone.util.ts src/utils/bulletin-service-apps.util.ts src/models/bulletin-board.model.ts src/utils/vehicle-import.util.ts src/utils/expired-vehicle-sweep.util.ts src/models/vehicle.model.ts src/controllers/chat.controller.ts src/utils/file-owner.util.ts src/utils/console-permission.util.ts src/utils/role-scope.util.ts src/utils/org-default-roles.util.ts src/utils/org-modules.util.ts src/utils/site-modules.util.ts src/utils/resident-app-modules.util.ts src/utils/resident-default-role.util.ts src/utils/invite-role-scope.util.ts src/models/personal-emergency-chain.model.ts src/utils/self-signup-files.util.ts src/models/person.model.ts src/utils/module-gate.util.ts src/utils/member-lookup.util.ts src/utils/notification-access.util.ts src/utils/module-access.util.ts src/services/module-gate.service.ts src/controllers/site.controller.ts src/controllers/organization.controller.ts src/controllers/member.controller.ts src/utils/org-owner-repair.util.ts src/utils/socket-session.util.ts src/utils/people-create-gate.util.ts src/utils/service-app-type.util.ts src/utils/customer-site-list.util.ts src/utils/org-search.util.ts --format esm --out-dir test/.build --no-dts --silent && node --test test/*.test.mjs",
|
|
17
17
|
"test:camera": "yarn test",
|
|
18
18
|
"test:e2e": "yarn build && node --test --test-concurrency=1 --test-timeout=600000 \"test/e2e/*.test.mjs\""
|
|
19
19
|
},
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// A deleted work order is not open.
|
|
2
|
+
//
|
|
3
|
+
// `work-order.repo.ts` deletes a `work-orders2` row by writing
|
|
4
|
+
// `status: "deleted"` (lower case). The dashboard filters listed only
|
|
5
|
+
// "Deleted", so a deleted work order still counted on the Open Work Order
|
|
6
|
+
// tile, its trend, the activity chart, and as "pending" in the Work Order
|
|
7
|
+
// Status bar. The Work Orders module itself hides it.
|
|
8
|
+
import { after, before, describe, it } from "node:test";
|
|
9
|
+
import assert from "node:assert/strict";
|
|
10
|
+
import { ObjectId } from "mongodb";
|
|
11
|
+
|
|
12
|
+
import { startHarness } from "./harness.mjs";
|
|
13
|
+
|
|
14
|
+
describe("dashboard work order counts skip deleted work orders", { concurrency: 1 }, () => {
|
|
15
|
+
let h;
|
|
16
|
+
const site = new ObjectId();
|
|
17
|
+
|
|
18
|
+
before(async () => {
|
|
19
|
+
h = await startHarness();
|
|
20
|
+
const now = new Date();
|
|
21
|
+
const row = (status, service = "Security") => ({ site, service, status, subject: status, createdAt: now, statusUpdates: [] });
|
|
22
|
+
await h.db.collection("work-orders2").insertMany([
|
|
23
|
+
row("To-Do"),
|
|
24
|
+
row("For Review"),
|
|
25
|
+
row("Completed"),
|
|
26
|
+
row("deleted"),
|
|
27
|
+
row("Deleted"),
|
|
28
|
+
row("To-Do", "Cleaning"),
|
|
29
|
+
row("deleted", "Cleaning"),
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
after(async () => {
|
|
34
|
+
await h?.stop();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const repo = () => h.core.useNewDashboardRepo();
|
|
38
|
+
|
|
39
|
+
it("Property Management: open = every service's not-completed, not-deleted rows", async () => {
|
|
40
|
+
const d = await repo().getPropertyManagementDashboard(String(site), "today");
|
|
41
|
+
assert.equal(d.openWorkOrder.count, 3);
|
|
42
|
+
assert.deepEqual(d.workOrderStatus, { pending: 3, inProgress: 0, completed: 1 });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("Security: only its own service, deleted rows excluded", async () => {
|
|
46
|
+
const d = await repo().getSecurityDashboard({ siteId: String(site), period: "today" });
|
|
47
|
+
assert.equal(d.openWorkOrder.count, 2);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("a service app (Cleaning): deleted rows excluded", async () => {
|
|
51
|
+
const d = await repo().getServiceDashboard({ site, serviceType: "cleaning_services", period: "today" });
|
|
52
|
+
assert.equal(d.openWorkOrder.count, 1);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -183,11 +183,8 @@ describe(
|
|
|
183
183
|
// ---- adversarial: can the scope be widened from the request? ----------
|
|
184
184
|
|
|
185
185
|
record("8. `search` cannot reach a client she is not in", async () => {
|
|
186
|
-
// `search` becomes a
|
|
187
|
-
// than replacing it.
|
|
188
|
-
// that the shipped `createIndex()` does NOT build one, so `search=` is a
|
|
189
|
-
// 500 on staging and production today - pre-existing, reported, not
|
|
190
|
-
// touched here.
|
|
186
|
+
// `search` becomes a substring match on name/e-mail, ANDed with the
|
|
187
|
+
// scope rather than replacing it.
|
|
191
188
|
const res = await h.api(
|
|
192
189
|
`/organizations?page=1&limit=50&search=${encodeURIComponent("Estates")}`,
|
|
193
190
|
{ sid: mallorySid },
|
|
@@ -205,6 +202,48 @@ describe(
|
|
|
205
202
|
assert.deepEqual(ids(res.body), [id.orgB.toString()]);
|
|
206
203
|
});
|
|
207
204
|
|
|
205
|
+
record("8c. part of a name, in any case, finds the client (Client details picker)", async () => {
|
|
206
|
+
for (const term of ["estat", "ORG B", " b estates "]) {
|
|
207
|
+
const res = await h.api(
|
|
208
|
+
`/organizations?page=1&limit=50&search=${encodeURIComponent(term)}`,
|
|
209
|
+
{ sid: staffSid },
|
|
210
|
+
);
|
|
211
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
212
|
+
assert.deepEqual(ids(res.body), [id.orgB.toString()], term);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
record("8d. the e-mail is searched, and a partial search still cannot leave the scope", async () => {
|
|
217
|
+
const staff = await h.api(
|
|
218
|
+
`/organizations?page=1&limit=50&search=${encodeURIComponent("pl-orgc@")}`,
|
|
219
|
+
{ sid: staffSid },
|
|
220
|
+
);
|
|
221
|
+
assert.deepEqual(ids(staff.body), [id.orgC.toString()]);
|
|
222
|
+
const res = await h.api(
|
|
223
|
+
`/organizations?page=1&limit=50&search=${encodeURIComponent("estat")}`,
|
|
224
|
+
{ sid: mallorySid },
|
|
225
|
+
);
|
|
226
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
227
|
+
assert.deepEqual(ids(res.body), []);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
record("8e. regex characters are literal, not a pattern that lists everyone", async () => {
|
|
231
|
+
const res = await h.api(
|
|
232
|
+
`/organizations?page=1&limit=50&search=${encodeURIComponent(".*")}`,
|
|
233
|
+
{ sid: staffSid },
|
|
234
|
+
);
|
|
235
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
236
|
+
assert.deepEqual(ids(res.body), []);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
record("8f. the Client List search (v2 subscriptions) treats `(` literally, not as a 500", async () => {
|
|
240
|
+
const res = await h.api(
|
|
241
|
+
`/organizations/v2/orgs/subscriptions?page=1&limit=50&search=${encodeURIComponent("Org (B")}`,
|
|
242
|
+
{ sid: staffSid },
|
|
243
|
+
);
|
|
244
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
245
|
+
});
|
|
246
|
+
|
|
208
247
|
record("9. nor can `nature`", async () => {
|
|
209
248
|
const res = await h.api(
|
|
210
249
|
"/organizations?page=1&limit=50&nature=property_management_agency",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
|
|
4
|
+
import { orgSearchMatch } from "./.build/utils/org-search.util.mjs";
|
|
5
|
+
|
|
6
|
+
const matches = (search, org) => {
|
|
7
|
+
const m = orgSearchMatch(search);
|
|
8
|
+
if (!m) return true;
|
|
9
|
+
return m.$or.some((clause) => {
|
|
10
|
+
const [field, { $regex, $options }] = Object.entries(clause)[0];
|
|
11
|
+
return new RegExp($regex, $options).test(org[field] ?? "");
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const LAKE = { name: "The LakeGarden Residences", email: "ops@lakegarden.example.com" };
|
|
16
|
+
|
|
17
|
+
test("a blank or non-string term is no filter", () => {
|
|
18
|
+
for (const s of ["", " ", undefined, null, 42, ["x"]]) assert.equal(orgSearchMatch(s), null);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("part of a name finds the client, in any case", () => {
|
|
22
|
+
assert.ok(matches("Lake", LAKE));
|
|
23
|
+
assert.ok(matches("lakegar", LAKE));
|
|
24
|
+
assert.ok(matches(" GARDEN res ", { name: "Garden Res" }));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("the e-mail is searched too", () => {
|
|
28
|
+
assert.ok(matches("ops@lake", LAKE));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("a term the client does not contain does not match", () => {
|
|
32
|
+
assert.equal(matches("Wing Tai", LAKE), false);
|
|
33
|
+
// $text ORed words: "The Estates" matched any org with "the". Substring does not.
|
|
34
|
+
assert.equal(matches("The Estates", LAKE), false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("regex characters are literal, not a pattern", () => {
|
|
38
|
+
assert.equal(matches(".*", LAKE), false);
|
|
39
|
+
assert.ok(matches("A.B (Pte)", { name: "A.B (Pte) Ltd" }));
|
|
40
|
+
assert.equal(matches("A.B", { name: "AxB Ltd" }), false);
|
|
41
|
+
});
|