@7365admin1/core 3.66.0 → 3.67.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@7365admin1/core",
3
3
  "license": "MIT",
4
- "version": "3.66.0",
4
+ "version": "3.67.0",
5
5
  "author": "7365admin1",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -41,21 +41,50 @@ const enforced = (over = {}) =>
41
41
  const WO = { category: "workOrder", siteId: SITE };
42
42
  const on = (fn) => withEnv({ NOTIFY_ACCESS_FILTER: "on", MODULE_LIST_GATE: undefined }, fn);
43
43
 
44
- test("the code default is LOG; anything unrecognised is log", () => {
45
- assert.equal(notifyAccessMode({}), "log");
46
- assert.equal(notifyAccessMode({ NOTIFY_ACCESS_FILTER: "garbage" }), "log");
47
- assert.equal(notifyAccessMode({ NOTIFY_ACCESS_FILTER: "ON" }), "on");
44
+ test("the code default is ON; anything unrecognised falls back to that default", () => {
45
+ // Owner, 2026-09-13: turn the filter on. Unset env => the code default.
46
+ assert.equal(notifyAccessMode({}), "on");
47
+ assert.equal(notifyAccessMode({ NOTIFY_ACCESS_FILTER: "garbage" }), "on");
48
+ assert.equal(notifyAccessMode({ NOTIFY_ACCESS_FILTER: "LOG" }), "log");
48
49
  assert.equal(notifyAccessMode({ NOTIFY_ACCESS_FILTER: "off" }), "off");
49
50
  });
50
51
 
51
- test("LOG never drops: the denied recipient is counted and still sent to", async () => {
52
+ test("the DEFAULT drops, with no env var set at all", async () => {
53
+ // The flip itself: this is the test that fails if the default goes back to
54
+ // `log`. `undefined` means "nothing set on the server", i.e. production.
55
+ const { data } = enforced({ rows: [member()] });
56
+ const sent = await withEnv({ NOTIFY_ACCESS_FILTER: undefined, MODULE_LIST_GATE: undefined }, () =>
57
+ filterByAccess([USER], WO, data),
58
+ );
59
+ assert.deepEqual(sent, [], "the denied recipient is dropped by the default alone");
60
+ });
61
+
62
+ test("LOG still never drops: the denied recipient is counted and still sent to", async () => {
52
63
  const { data } = enforced({ rows: [member()] });
53
64
  const report = await notificationAccessReport([USER], WO, data);
54
65
  assert.deepEqual(report.dropByModule, [USER], "control: the list does deny work orders");
55
- const sent = await withEnv({ NOTIFY_ACCESS_FILTER: undefined }, () => filterByAccess([USER], WO, data));
66
+ // A lead putting it back to `log` must still send to everyone, with no deploy.
67
+ const sent = await withEnv({ NOTIFY_ACCESS_FILTER: "log" }, () => filterByAccess([USER], WO, data));
56
68
  assert.deepEqual(sent, [USER]);
57
69
  });
58
70
 
71
+ test("a client with NO enforced list is untouched by the default being on", async () => {
72
+ // Why the flip is safe on the day it ships: no organisation and no site had an
73
+ // enforced list, so the filter returns early and reads nothing.
74
+ const { data, calls } = fakeGate({
75
+ orgs: { [ORG]: { _id: ORG } },
76
+ sites: { [SITE]: SITE_DOC },
77
+ roles: { r1: { permissions: ["*"] } },
78
+ rows: [member()],
79
+ });
80
+ assert.deepEqual(await filterByAccess([USER], WO, data), [USER]);
81
+ // It does read the org and the site to find out whether a list is enforced.
82
+ // What it must not do is the expensive part: `members.user` has no index to
83
+ // use, so a members/roles read on every send is the cost worth avoiding.
84
+ assert.equal(calls.members, undefined, "no members read while nothing is enforced");
85
+ assert.equal(calls.roles, undefined, "no roles read while nothing is enforced");
86
+ });
87
+
59
88
  test("ON drops only the member whose client list denies the module", async () => {
60
89
  const other = member({ user: USER_2, org: "9".repeat(24), siteId: SITE }); // a provider: own org, no list
61
90
  const { data } = enforced({ rows: [member(), other] });