@htilabs/platform-common-models 0.24.0 → 0.25.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/README.md +65 -0
- package/dist/{index-Dr6GBCoY.d.ts → index-ClTjjJ_S.d.ts} +1 -1
- package/dist/{index-BTqHP4DM.d.cts → index-Pt82NxQg.d.cts} +1 -1
- package/dist/index.cjs +457 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +437 -2
- package/dist/index.js.map +1 -1
- package/dist/information-scope/index.d.cts +3 -350
- package/dist/information-scope/index.d.ts +3 -350
- package/dist/informationScopeResolver-BzYu97DE.d.cts +351 -0
- package/dist/informationScopeResolver-BzYu97DE.d.ts +351 -0
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/dist/services/index.d.cts +2 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/sharing-ceiling/index.cjs +497 -0
- package/dist/sharing-ceiling/index.cjs.map +1 -0
- package/dist/sharing-ceiling/index.d.cts +318 -0
- package/dist/sharing-ceiling/index.d.ts +318 -0
- package/dist/sharing-ceiling/index.js +451 -0
- package/dist/sharing-ceiling/index.js.map +1 -0
- package/package.json +7 -1
- package/src/__sot__/README.md +1 -0
- package/src/__sot__/sharingStarter.pin.json +229 -0
- package/src/__tests__/sharing-starter-canon.test.ts +178 -0
- package/src/generated/sharingPlatformStarter.ts +165 -0
- package/src/index.ts +5 -0
- package/src/sharingCeiling/__tests__/sharingCeiling.test.ts +678 -0
- package/src/sharingCeiling/chain.ts +269 -0
- package/src/sharingCeiling/coverage.ts +346 -0
- package/src/sharingCeiling/index.ts +14 -0
- package/src/sharingCeiling/starter.ts +89 -0
- package/dist/{cvcEntry-BqAGctqK.d.cts → cvcEntry-Asg7mxjB.d.cts} +8 -8
- package/dist/{cvcEntry-BqAGctqK.d.ts → cvcEntry-Asg7mxjB.d.ts} +8 -8
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Inter-Agency Sharing ceiling (co-2sx): the cell fold, the read chain
|
|
3
|
+
* and THE coverage rule.
|
|
4
|
+
*
|
|
5
|
+
* Canon: prototype `HTI-LEADS-PAVE-Thread-prototype.html` @ d85f05b7
|
|
6
|
+
* (`shareEffectiveCeiling` L327966-L328090, the chain L328053-L328058,
|
|
7
|
+
* `scopeListCovers` L327953-L327964, `shareItemsWithinCeiling` L328204);
|
|
8
|
+
* platform-prototype `src/data.js` @ a6f1f3a (`effectiveCeiling` clamp 1
|
|
9
|
+
* L51352-L51354, clamp 5 L51516-L51525, `EXTERNAL_RECIPIENT_KEY` L50434).
|
|
10
|
+
*/
|
|
11
|
+
import { describe, expect, it } from "vitest";
|
|
12
|
+
|
|
13
|
+
import { coreInformationScopeSot } from "../../cvcs/index.js";
|
|
14
|
+
import {
|
|
15
|
+
INFORMATION_SCOPE_SYSTEM_INFO,
|
|
16
|
+
createInformationScopeResolver,
|
|
17
|
+
isSelectableScopeRow,
|
|
18
|
+
scopeMigrationsFromSot,
|
|
19
|
+
scopeRowsFromSot,
|
|
20
|
+
type CoreInformationScopeSot,
|
|
21
|
+
} from "../../services/informationScope.js";
|
|
22
|
+
import {
|
|
23
|
+
HTI_SHARE_PLATFORM_STARTER,
|
|
24
|
+
SHARING_CEILING_DEFAULT_ROW_KEY,
|
|
25
|
+
SHARING_CEILING_EXTERNAL_ROW_KEY,
|
|
26
|
+
ceilingCoverage,
|
|
27
|
+
effectiveCeiling,
|
|
28
|
+
isCeilingCoverageRow,
|
|
29
|
+
isSharingPurposeDisabled,
|
|
30
|
+
INFORMATION_SCOPE_FIELD_HOME_ROWS,
|
|
31
|
+
hasOwnScopeContent,
|
|
32
|
+
maskSelectionToCeiling,
|
|
33
|
+
rowsExpandedByCeiling,
|
|
34
|
+
rowsOutsideCeiling,
|
|
35
|
+
rowsOverCeiling,
|
|
36
|
+
scopeRowWithinCeiling,
|
|
37
|
+
sharingCeilingCellList,
|
|
38
|
+
sharingCeilingRowKey,
|
|
39
|
+
sharingScopeEditsFromCells,
|
|
40
|
+
type SharingCeilingCellLike,
|
|
41
|
+
} from "../index.js";
|
|
42
|
+
|
|
43
|
+
const sot = coreInformationScopeSot as CoreInformationScopeSot;
|
|
44
|
+
const scope = createInformationScopeResolver({
|
|
45
|
+
rows: scopeRowsFromSot(sot),
|
|
46
|
+
migrations: scopeMigrationsFromSot(sot),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** A cell; pass `UNSTAMPED` to leave `scopeVersion` off. */
|
|
50
|
+
const UNSTAMPED = Symbol("unstamped");
|
|
51
|
+
const cell = (
|
|
52
|
+
rowKey: string,
|
|
53
|
+
purpose: string,
|
|
54
|
+
informationScope: unknown,
|
|
55
|
+
scopeVersion: unknown = 4,
|
|
56
|
+
): SharingCeilingCellLike =>
|
|
57
|
+
scopeVersion === UNSTAMPED
|
|
58
|
+
? { rowKey, purpose, informationScope }
|
|
59
|
+
: { rowKey, purpose, informationScope, scopeVersion };
|
|
60
|
+
|
|
61
|
+
const PARTNER = "agency-partner-1";
|
|
62
|
+
|
|
63
|
+
// ─── The cell fold ──────────────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
describe("sharingScopeEditsFromCells — the platform contract's read rules", () => {
|
|
66
|
+
it("a stamped-4 list of strings is the rule (copied)", () => {
|
|
67
|
+
const list = ["identifying", "contact"];
|
|
68
|
+
const edits = sharingScopeEditsFromCells([cell(PARTNER, "referral", list)]);
|
|
69
|
+
expect(edits[PARTNER]?.["referral"]).toEqual(["identifying", "contact"]);
|
|
70
|
+
expect(edits[PARTNER]?.["referral"]).not.toBe(list);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("[] binds: it is a rule, not an absence", () => {
|
|
74
|
+
const edits = sharingScopeEditsFromCells([cell(PARTNER, "referral", [])]);
|
|
75
|
+
expect(edits[PARTNER]?.["referral"]).toEqual([]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it.each([
|
|
79
|
+
["unstamped", cell(PARTNER, "referral", ["identifying"], UNSTAMPED)],
|
|
80
|
+
["v3-stamped", cell(PARTNER, "referral", ["identifying"], 3)],
|
|
81
|
+
["stamped as a string", cell(PARTNER, "referral", ["identifying"], "4")],
|
|
82
|
+
["a v3 tri-state map", cell(PARTNER, "referral", { identifying: "include" })],
|
|
83
|
+
["a non-string entry", cell(PARTNER, "referral", ["identifying", 7])],
|
|
84
|
+
["no list at all", { rowKey: PARTNER, purpose: "referral", scopeVersion: 4 }],
|
|
85
|
+
["a null list", cell(PARTNER, "referral", null)],
|
|
86
|
+
])("a present cell that is %s reads as [] (binds, covers nothing)", (_, c) => {
|
|
87
|
+
expect(sharingCeilingCellList(c)).toEqual([]);
|
|
88
|
+
expect(sharingScopeEditsFromCells([c])[PARTNER]?.["referral"]).toEqual([]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("cells carry no status: a status field is ignored", () => {
|
|
92
|
+
const edits = sharingScopeEditsFromCells([{ ...cell(PARTNER, "referral", ["names"]), status: 2 } as SharingCeilingCellLike]);
|
|
93
|
+
expect(edits[PARTNER]?.["referral"]).toEqual(["names"]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("an absent cell is no rule; an unattributable cell is skipped", () => {
|
|
97
|
+
const edits = sharingScopeEditsFromCells([
|
|
98
|
+
cell(PARTNER, "referral", ["names"]),
|
|
99
|
+
{ purpose: "referral", scopeVersion: 4, informationScope: ["names"] },
|
|
100
|
+
{ rowKey: PARTNER, scopeVersion: 4, informationScope: ["names"] },
|
|
101
|
+
null,
|
|
102
|
+
undefined,
|
|
103
|
+
]);
|
|
104
|
+
expect(Object.keys(edits)).toEqual([PARTNER]);
|
|
105
|
+
expect(Object.keys(edits[PARTNER] ?? {})).toEqual(["referral"]);
|
|
106
|
+
expect(sharingScopeEditsFromCells(null)).toEqual({});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("two cells for one key: kept when they agree as sets, else [] (fail closed)", () => {
|
|
110
|
+
expect(
|
|
111
|
+
sharingScopeEditsFromCells([cell(PARTNER, "referral", ["a", "b"]), cell(PARTNER, "referral", ["b", "a"])])[
|
|
112
|
+
PARTNER
|
|
113
|
+
]?.["referral"],
|
|
114
|
+
).toEqual(["b", "a"]);
|
|
115
|
+
expect(
|
|
116
|
+
sharingScopeEditsFromCells([cell(PARTNER, "referral", ["a"]), cell(PARTNER, "referral", ["a", "b"])])[PARTNER]?.[
|
|
117
|
+
"referral"
|
|
118
|
+
],
|
|
119
|
+
).toEqual([]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("a row key such as __proto__ is an own key, never the prototype", () => {
|
|
123
|
+
const edits = sharingScopeEditsFromCells([cell("__proto__", "referral", ["names"])]);
|
|
124
|
+
expect(Object.prototype.hasOwnProperty.call(edits, "__proto__")).toBe(true);
|
|
125
|
+
expect(Object.getPrototypeOf(edits)).toBe(Object.prototype);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// ─── The read chain ─────────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
describe("effectiveCeiling — canon's chain, rung by rung", () => {
|
|
132
|
+
const edits = sharingScopeEditsFromCells([
|
|
133
|
+
cell(PARTNER, "referral", ["names"]),
|
|
134
|
+
cell("okcpd", "referral", ["dob"]),
|
|
135
|
+
cell(SHARING_CEILING_DEFAULT_ROW_KEY, "referral", ["addresses"]),
|
|
136
|
+
cell(SHARING_CEILING_DEFAULT_ROW_KEY, "case_collaboration", ["contact"]),
|
|
137
|
+
]);
|
|
138
|
+
|
|
139
|
+
it("the account's partner rule comes first", () => {
|
|
140
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits })).toEqual({
|
|
141
|
+
allowed: ["names"],
|
|
142
|
+
rung: "partner_rule",
|
|
143
|
+
disabled: false,
|
|
144
|
+
});
|
|
145
|
+
expect(effectiveCeiling("okcpd", "referral", { edits }).rung).toBe("partner_rule");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("then the platform-seeded partner rule — it beats the account default", () => {
|
|
149
|
+
const r = effectiveCeiling("okcpd", "mandatory_reporting", { edits: {} });
|
|
150
|
+
expect(r.rung).toBe("seeded_partner_rule");
|
|
151
|
+
expect(r.allowed).toEqual([...(HTI_SHARE_PLATFORM_STARTER.counterpartyOverrides["okcpd"]?.["mandatory_reporting"] ?? [])]);
|
|
152
|
+
const withDefault = sharingScopeEditsFromCells([cell(SHARING_CEILING_DEFAULT_ROW_KEY, "referral", ["names"])]);
|
|
153
|
+
expect(effectiveCeiling("legal_aid_ok", "referral", { edits: withDefault }).rung).toBe("seeded_partner_rule");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("then the account default", () => {
|
|
157
|
+
expect(effectiveCeiling("agency-unseeded", "referral", { edits })).toEqual({
|
|
158
|
+
allowed: ["addresses"],
|
|
159
|
+
rung: "account_default",
|
|
160
|
+
disabled: false,
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("then the platform per-purpose default", () => {
|
|
165
|
+
const r = effectiveCeiling("agency-unseeded", "deconfliction", { edits });
|
|
166
|
+
expect(r).toEqual({ allowed: ["identifying", "system"], rung: "platform_default", disabled: false });
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("a purpose with no rung at all FAILS CLOSED ([], rung none) — stricter than canon's `|| null`", () => {
|
|
170
|
+
// All eight core CVC-84 purposes have platform rows, so `none` can only be
|
|
171
|
+
// a caller error (a LEADS-wing or misspelled purpose).
|
|
172
|
+
for (const purpose of ["investigation_support", "referal"]) {
|
|
173
|
+
expect(effectiveCeiling(PARTNER, purpose, { edits: {} })).toEqual({
|
|
174
|
+
allowed: [],
|
|
175
|
+
rung: "none",
|
|
176
|
+
disabled: false,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const starter = { scopeVersion: 4 as const, scopeByPurpose: {}, counterpartyOverrides: {} };
|
|
180
|
+
const r = effectiveCeiling(PARTNER, "referral", { edits: {}, starter });
|
|
181
|
+
expect(r).toEqual({ allowed: [], rung: "none", disabled: false });
|
|
182
|
+
expect(rowsOverCeiling(scope, ["names", INFORMATION_SCOPE_SYSTEM_INFO], r.allowed)).toEqual([
|
|
183
|
+
"names",
|
|
184
|
+
]);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("[] binds at the partner rung: it never falls through to a broader one", () => {
|
|
188
|
+
const e = sharingScopeEditsFromCells([cell(PARTNER, "referral", [])]);
|
|
189
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits: e })).toEqual({
|
|
190
|
+
allowed: [],
|
|
191
|
+
rung: "partner_rule",
|
|
192
|
+
disabled: false,
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it.each([
|
|
197
|
+
["unstamped", UNSTAMPED],
|
|
198
|
+
["v3-stamped", 3],
|
|
199
|
+
])("a %s cell reads [] and binds at its rung", (_, v) => {
|
|
200
|
+
const e = sharingScopeEditsFromCells([cell(SHARING_CEILING_DEFAULT_ROW_KEY, "referral", ["identifying"], v)]);
|
|
201
|
+
expect(effectiveCeiling("agency-unseeded", "referral", { edits: e })).toEqual({
|
|
202
|
+
allowed: [],
|
|
203
|
+
rung: "account_default",
|
|
204
|
+
disabled: false,
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("hand-built edits: null / undefined fall through, a non-list binds as []", () => {
|
|
209
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits: { [PARTNER]: { referral: null as never } } }).rung).toBe(
|
|
210
|
+
"platform_default",
|
|
211
|
+
);
|
|
212
|
+
expect(
|
|
213
|
+
effectiveCeiling(PARTNER, "referral", { edits: { [PARTNER]: { referral: "identifying" as never } } }),
|
|
214
|
+
).toEqual({ allowed: [], rung: "partner_rule", disabled: false });
|
|
215
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits: null }).rung).toBe("platform_default");
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("never reads an inherited property as a rule", () => {
|
|
219
|
+
expect(effectiveCeiling("constructor", "referral", { edits: {} }).rung).toBe("platform_default");
|
|
220
|
+
expect(effectiveCeiling(PARTNER, "toString", { edits: {} }).rung).toBe("none");
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("returns a copy: mutating it cannot reach the starter", () => {
|
|
224
|
+
const r = effectiveCeiling(PARTNER, "referral", { edits: {} });
|
|
225
|
+
r.allowed?.push("health_accommodation");
|
|
226
|
+
expect(HTI_SHARE_PLATFORM_STARTER.scopeByPurpose["referral"]).not.toContain("health_accommodation");
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("takes a caller's starter", () => {
|
|
230
|
+
const starter = { scopeVersion: 4 as const, scopeByPurpose: { referral: ["names"] }, counterpartyOverrides: {} };
|
|
231
|
+
expect(effectiveCeiling("okcpd", "referral", { edits: {}, starter })).toEqual({
|
|
232
|
+
allowed: ["names"],
|
|
233
|
+
rung: "platform_default",
|
|
234
|
+
disabled: false,
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
describe("effectiveCeiling — __external__ (off-platform / unspecified recipients)", () => {
|
|
240
|
+
it("sharingCeilingRowKey: an off-platform recipient is __external__, a partner is its id", () => {
|
|
241
|
+
expect(sharingCeilingRowKey({ external: true })).toBe(SHARING_CEILING_EXTERNAL_ROW_KEY);
|
|
242
|
+
expect(sharingCeilingRowKey({ external: true, id: PARTNER })).toBe(
|
|
243
|
+
SHARING_CEILING_EXTERNAL_ROW_KEY,
|
|
244
|
+
);
|
|
245
|
+
expect(sharingCeilingRowKey({ id: PARTNER })).toBe(PARTNER);
|
|
246
|
+
expect(() => sharingCeilingRowKey({})).toThrow(TypeError);
|
|
247
|
+
expect(() => sharingCeilingRowKey({ id: "__default__" })).toThrow(RangeError);
|
|
248
|
+
expect(() => sharingCeilingRowKey({ id: "__external__" })).toThrow(RangeError);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("an authored __external__ row is the partner rule for off-platform recipients", () => {
|
|
252
|
+
const edits = sharingScopeEditsFromCells([cell(SHARING_CEILING_EXTERNAL_ROW_KEY, "referral", ["names"])]);
|
|
253
|
+
expect(effectiveCeiling(SHARING_CEILING_EXTERNAL_ROW_KEY, "referral", { edits })).toEqual({
|
|
254
|
+
allowed: ["names"],
|
|
255
|
+
rung: "partner_rule",
|
|
256
|
+
disabled: false,
|
|
257
|
+
});
|
|
258
|
+
// …and never governs an on-platform partner.
|
|
259
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits }).rung).toBe("platform_default");
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("un-authored, it follows the account default, then the platform default (data.js L50427-L50430)", () => {
|
|
263
|
+
const edits = sharingScopeEditsFromCells([cell(SHARING_CEILING_DEFAULT_ROW_KEY, "referral", ["dob"])]);
|
|
264
|
+
expect(effectiveCeiling(SHARING_CEILING_EXTERNAL_ROW_KEY, "referral", { edits }).rung).toBe("account_default");
|
|
265
|
+
expect(effectiveCeiling(SHARING_CEILING_EXTERNAL_ROW_KEY, "deconfliction", { edits }).rung).toBe(
|
|
266
|
+
"platform_default",
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("__default__ is not a recipient row key; an empty key or purpose is refused", () => {
|
|
271
|
+
expect(() => effectiveCeiling(SHARING_CEILING_DEFAULT_ROW_KEY, "referral", { edits: {} })).toThrow(RangeError);
|
|
272
|
+
expect(() => effectiveCeiling("", "referral", { edits: {} })).toThrow(TypeError);
|
|
273
|
+
expect(() => effectiveCeiling(PARTNER, "", { edits: {} })).toThrow(TypeError);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe("effectiveCeiling — purpose enablement (data.js clamp 1, L51352-L51354)", () => {
|
|
278
|
+
const edits = sharingScopeEditsFromCells([cell(PARTNER, "referral", ["names"])]);
|
|
279
|
+
|
|
280
|
+
it("purposeOverrides[purpose] === false disables, above every rung", () => {
|
|
281
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits, purposeOverrides: { referral: false } })).toEqual({
|
|
282
|
+
allowed: [],
|
|
283
|
+
rung: "purpose_disabled",
|
|
284
|
+
disabled: true,
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("records_request ships disabled by the platform row (data.js L32527)", () => {
|
|
289
|
+
expect(effectiveCeiling(PARTNER, "records_request", { edits: {} })).toEqual({
|
|
290
|
+
allowed: [],
|
|
291
|
+
rung: "purpose_disabled",
|
|
292
|
+
disabled: true,
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("…unless the account switches it on with an explicit true", () => {
|
|
297
|
+
expect(effectiveCeiling(PARTNER, "records_request", { edits: {}, purposeOverrides: { records_request: true } })).toEqual(
|
|
298
|
+
{ allowed: ["identifying", "system"], rung: "platform_default", disabled: false },
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it("a caller's purposeEnabled is merged OVER the platform rows", () => {
|
|
303
|
+
expect(
|
|
304
|
+
effectiveCeiling(PARTNER, "records_request", { edits: {}, purposeEnabled: { records_request: true } }).rung,
|
|
305
|
+
).toBe("platform_default");
|
|
306
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits, purposeEnabled: { referral: false } }).disabled).toBe(true);
|
|
307
|
+
// A map that does not name records_request keeps the platform row (disabled).
|
|
308
|
+
expect(effectiveCeiling(PARTNER, "records_request", { edits: {}, purposeEnabled: { referral: true } }).disabled)
|
|
309
|
+
.toBe(true);
|
|
310
|
+
// A non-boolean entry is no row: the platform row stands.
|
|
311
|
+
expect(
|
|
312
|
+
effectiveCeiling(PARTNER, "records_request", {
|
|
313
|
+
edits: {},
|
|
314
|
+
purposeEnabled: { records_request: "yes" as never },
|
|
315
|
+
}).disabled,
|
|
316
|
+
).toBe(true);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it.each([
|
|
320
|
+
["null", null],
|
|
321
|
+
["{}", {}],
|
|
322
|
+
["undefined", undefined],
|
|
323
|
+
])("purposeEnabled %s reads the platform rows: records_request stays disabled", (_, purposeEnabled) => {
|
|
324
|
+
expect(effectiveCeiling(PARTNER, "records_request", { edits: {}, purposeEnabled })).toEqual({
|
|
325
|
+
allowed: [],
|
|
326
|
+
rung: "purpose_disabled",
|
|
327
|
+
disabled: true,
|
|
328
|
+
});
|
|
329
|
+
expect(effectiveCeiling(PARTNER, "referral", { edits: {}, purposeEnabled }).disabled).toBe(false);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it("an explicit false still disables a platform-enabled purpose; anything but a boolean is no switch", () => {
|
|
333
|
+
expect(isSharingPurposeDisabled("referral", { referral: false })).toBe(true);
|
|
334
|
+
expect(isSharingPurposeDisabled("referral", { referral: "false" as never })).toBe(false);
|
|
335
|
+
expect(isSharingPurposeDisabled("records_request", { records_request: "true" as never })).toBe(true);
|
|
336
|
+
expect(isSharingPurposeDisabled("referral", null)).toBe(false);
|
|
337
|
+
expect(isSharingPurposeDisabled("investigation_support")).toBe(false);
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// ─── The coverage rule ──────────────────────────────────────────────────────
|
|
342
|
+
|
|
343
|
+
const LIVE = scope.rows.filter((r) => r.status !== "retired").map((r) => r.scopeCode);
|
|
344
|
+
const isSystem = (c: string): boolean => scope.ancestorsOf(c).includes("system");
|
|
345
|
+
const underFloor = (c: string): boolean =>
|
|
346
|
+
scope.ancestorsOf(c).some((a) => scope.row(a)?.platformFloor === true);
|
|
347
|
+
const coverageChildren = (c: string): string[] =>
|
|
348
|
+
scope.childrenOf(c).filter((k) => isCeilingCoverageRow(scope, k));
|
|
349
|
+
|
|
350
|
+
describe("scopeRowWithinCeiling — THE coverage rule", () => {
|
|
351
|
+
it("self or ancestor listed (canon scopeListCovers)", () => {
|
|
352
|
+
expect(scopeRowWithinCeiling(scope, ["identifying"], "identifying")).toBe(true);
|
|
353
|
+
expect(scopeRowWithinCeiling(scope, ["identifying"], "names")).toBe(true);
|
|
354
|
+
expect(scopeRowWithinCeiling(scope, ["primary_client"], "summary_lap")).toBe(true);
|
|
355
|
+
expect(scopeRowWithinCeiling(scope, ["names"], "identifying")).toBe(false);
|
|
356
|
+
expect(scopeRowWithinCeiling(scope, ["names"], "dob")).toBe(false);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it.each(["identifying", "notes", "offenders", "primary_client"])(
|
|
360
|
+
"every coverage child of %s listed, the parent not: within (the door's expand-to-grain)",
|
|
361
|
+
(parent) => {
|
|
362
|
+
const list = coverageChildren(parent);
|
|
363
|
+
expect(list.length).toBeGreaterThan(0);
|
|
364
|
+
expect(list).not.toContain(parent);
|
|
365
|
+
expect(scopeRowWithinCeiling(scope, list, parent)).toBe(true);
|
|
366
|
+
expect(rowsOverCeiling(scope, [INFORMATION_SCOPE_SYSTEM_INFO, parent], list)).toEqual([]);
|
|
367
|
+
expect(rowsOutsideCeiling(scope, list)).not.toContain(parent);
|
|
368
|
+
},
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
it("one child missing: the parent is refused, the listed children are not", () => {
|
|
372
|
+
const [missing, ...rest] = coverageChildren("identifying");
|
|
373
|
+
expect(scopeRowWithinCeiling(scope, rest, "identifying")).toBe(false);
|
|
374
|
+
expect(rowsOverCeiling(scope, ["identifying"], rest)).toEqual(["identifying"]);
|
|
375
|
+
expect(rowsOutsideCeiling(scope, rest)).toContain(missing);
|
|
376
|
+
for (const c of rest) expect(scopeRowWithinCeiling(scope, rest, c)).toBe(true);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("a listed rest row does not cover its category (not the resolver's isCovered)", () => {
|
|
380
|
+
expect(scopeRowWithinCeiling(scope, ["identifying.other"], "identifying")).toBe(false);
|
|
381
|
+
expect(scopeRowWithinCeiling(scope, ["identifying.other"], "names")).toBe(false);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it("the floor is not required of a parent; a floor-only branch must be listed itself", () => {
|
|
385
|
+
expect(scope.childrenOf("contact")).toContain("safe_locations");
|
|
386
|
+
expect(scopeRowWithinCeiling(scope, coverageChildren("contact"), "contact")).toBe(true);
|
|
387
|
+
expect(coverageChildren("offenders.contact")).toEqual([]);
|
|
388
|
+
expect(scopeRowWithinCeiling(scope, ["offenders.safe_locations"], "offenders.contact")).toBe(false);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it.each(["instruments", "offenders.instruments", "family.instruments", "commercial_activity"])(
|
|
392
|
+
"STRICT rule 2 — %s homes fields directly and has no rest row: children-only does not carry it",
|
|
393
|
+
(parent) => {
|
|
394
|
+
expect(hasOwnScopeContent(scope, parent)).toBe(true);
|
|
395
|
+
const list = coverageChildren(parent);
|
|
396
|
+
expect(list.length).toBeGreaterThan(0);
|
|
397
|
+
expect(scopeRowWithinCeiling(scope, list, parent)).toBe(false);
|
|
398
|
+
expect(rowsOverCeiling(scope, [parent], list)).toEqual([parent]);
|
|
399
|
+
for (const c of list) expect(scopeRowWithinCeiling(scope, list, c)).toBe(true);
|
|
400
|
+
// The mask does not lock it (its children are permitted) — it expands it.
|
|
401
|
+
expect(rowsOutsideCeiling(scope, list)).not.toContain(parent);
|
|
402
|
+
expect(rowsExpandedByCeiling(scope, list)).toContain(parent);
|
|
403
|
+
const masked = maskSelectionToCeiling(scope, [INFORMATION_SCOPE_SYSTEM_INFO, parent], list);
|
|
404
|
+
expect(masked).not.toContain(parent);
|
|
405
|
+
expect(masked.slice(1).sort()).toEqual([...scope.childrenOf(parent)].sort());
|
|
406
|
+
expect(rowsOverCeiling(scope, masked, list)).toEqual([]);
|
|
407
|
+
// Listed itself, or under a listed ancestor, it is within.
|
|
408
|
+
expect(scopeRowWithinCeiling(scope, [parent], parent)).toBe(true);
|
|
409
|
+
},
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
it("strict rule 2 is read off canon's field placements; a rest row keeps the all-children rule", () => {
|
|
413
|
+
// `identifying` homes fields directly but has `identifying.other`.
|
|
414
|
+
expect(INFORMATION_SCOPE_FIELD_HOME_ROWS.has("identifying")).toBe(true);
|
|
415
|
+
expect(hasOwnScopeContent(scope, "identifying")).toBe(false);
|
|
416
|
+
expect(INFORMATION_SCOPE_FIELD_HOME_ROWS.has("instruments")).toBe(true);
|
|
417
|
+
expect(INFORMATION_SCOPE_FIELD_HOME_ROWS.has("commercial_activity")).toBe(true);
|
|
418
|
+
// Branches, kinds and notes home nothing directly: rule 2 applies.
|
|
419
|
+
for (const c of ["primary_client", "other_named_persons", "offenders", "notes", "contact"]) {
|
|
420
|
+
expect(hasOwnScopeContent(scope, c), c).toBe(false);
|
|
421
|
+
}
|
|
422
|
+
// A per-kind row reads its kindRow.
|
|
423
|
+
expect(scope.row("offenders.instruments")?.kindRow).toBe("instruments");
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it("a code outside the tree is never within, and the door refuses it", () => {
|
|
427
|
+
expect(scopeRowWithinCeiling(scope, ["hiv_status"], "hiv_status")).toBe(false);
|
|
428
|
+
expect(scopeRowWithinCeiling(scope, null, "offenders__risk")).toBe(false);
|
|
429
|
+
expect(rowsOverCeiling(scope, ["offenders__risk", "names"], ["names"])).toEqual(["offenders__risk"]);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it("System metadata and floor rows ride the door regardless; a disabled ([]) ceiling refuses the rest", () => {
|
|
433
|
+
expect(rowsOverCeiling(scope, [INFORMATION_SCOPE_SYSTEM_INFO, "system", "safe_locations", "names"], [])).toEqual([
|
|
434
|
+
"names",
|
|
435
|
+
]);
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it("null is no ceiling: every live row is within, nothing is restricted", () => {
|
|
439
|
+
for (const c of LIVE) expect(scopeRowWithinCeiling(scope, null, c)).toBe(true);
|
|
440
|
+
expect(rowsOutsideCeiling(scope, null)).toEqual([]);
|
|
441
|
+
expect(rowsOverCeiling(scope, ["names", "identifying"], null)).toEqual([]);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it("a row under a RETIRED ancestor is not live: never within, refused by the door, dropped by the mask", () => {
|
|
445
|
+
const base = {
|
|
446
|
+
kindBranch: null,
|
|
447
|
+
apps: { pave: true, thread: true, leads: false },
|
|
448
|
+
selectable: true,
|
|
449
|
+
shareableDefault: true,
|
|
450
|
+
platformFloor: false,
|
|
451
|
+
levelFloor: 3 as const,
|
|
452
|
+
specialDataType: "none" as const,
|
|
453
|
+
status: "as_today" as const,
|
|
454
|
+
};
|
|
455
|
+
const synthetic = createInformationScopeResolver({
|
|
456
|
+
rows: [
|
|
457
|
+
{ ...base, scopeCode: "system", parentScopeCode: null, rowType: "category" },
|
|
458
|
+
{ ...base, scopeCode: "system_info", parentScopeCode: "system", rowType: "subcategory" },
|
|
459
|
+
{ ...base, scopeCode: "client", parentScopeCode: null, rowType: "branch" },
|
|
460
|
+
{ ...base, scopeCode: "cat_live", parentScopeCode: "client", rowType: "category" },
|
|
461
|
+
{ ...base, scopeCode: "leaf_ok", parentScopeCode: "cat_live", rowType: "subcategory" },
|
|
462
|
+
{ ...base, scopeCode: "cat_gone", parentScopeCode: "client", rowType: "category", status: "retired" },
|
|
463
|
+
{ ...base, scopeCode: "leaf_orphan", parentScopeCode: "cat_gone", rowType: "subcategory" },
|
|
464
|
+
],
|
|
465
|
+
});
|
|
466
|
+
for (const list of [["client"], ["client", "leaf_orphan"], ["cat_gone"], null]) {
|
|
467
|
+
expect(scopeRowWithinCeiling(synthetic, list, "leaf_orphan")).toBe(false);
|
|
468
|
+
expect(rowsOverCeiling(synthetic, ["leaf_orphan", "leaf_ok"], list)).toContain("leaf_orphan");
|
|
469
|
+
const masked = maskSelectionToCeiling(synthetic, ["leaf_orphan", "leaf_ok"], list);
|
|
470
|
+
expect(masked).not.toContain("leaf_orphan");
|
|
471
|
+
expect(rowsOverCeiling(synthetic, masked, list)).toEqual([]);
|
|
472
|
+
}
|
|
473
|
+
expect(scopeRowWithinCeiling(synthetic, ["client"], "leaf_ok")).toBe(true);
|
|
474
|
+
// The retired category does not count toward its parent's children-only coverage.
|
|
475
|
+
expect(scopeRowWithinCeiling(synthetic, ["cat_live"], "client")).toBe(true);
|
|
476
|
+
expect(isCeilingCoverageRow(synthetic, "leaf_orphan")).toBe(false);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
it("the mask never puts back a retired sibling, even when a caller's childrenOf lists it", () => {
|
|
480
|
+
const base = {
|
|
481
|
+
kindBranch: null,
|
|
482
|
+
apps: { pave: true, thread: true, leads: false },
|
|
483
|
+
selectable: true,
|
|
484
|
+
shareableDefault: true,
|
|
485
|
+
platformFloor: false,
|
|
486
|
+
levelFloor: 3 as const,
|
|
487
|
+
specialDataType: "none" as const,
|
|
488
|
+
status: "as_today" as const,
|
|
489
|
+
};
|
|
490
|
+
const rows = [
|
|
491
|
+
{ ...base, scopeCode: "system", parentScopeCode: null, rowType: "category" as const },
|
|
492
|
+
{ ...base, scopeCode: "system_info", parentScopeCode: "system", rowType: "subcategory" as const },
|
|
493
|
+
{ ...base, scopeCode: "cat", parentScopeCode: null, rowType: "category" as const },
|
|
494
|
+
{ ...base, scopeCode: "a", parentScopeCode: "cat", rowType: "subcategory" as const },
|
|
495
|
+
{ ...base, scopeCode: "b", parentScopeCode: "cat", rowType: "subcategory" as const },
|
|
496
|
+
{
|
|
497
|
+
...base,
|
|
498
|
+
scopeCode: "old",
|
|
499
|
+
parentScopeCode: "cat",
|
|
500
|
+
rowType: "subcategory" as const,
|
|
501
|
+
status: "retired" as const,
|
|
502
|
+
},
|
|
503
|
+
];
|
|
504
|
+
const resolved = createInformationScopeResolver({ rows });
|
|
505
|
+
const loose = {
|
|
506
|
+
...resolved,
|
|
507
|
+
childrenOf: (code: string) =>
|
|
508
|
+
rows.filter((r) => r.parentScopeCode === code).map((r) => r.scopeCode),
|
|
509
|
+
};
|
|
510
|
+
const masked = maskSelectionToCeiling(loose, ["cat"], ["a"]);
|
|
511
|
+
expect(masked).not.toContain("old");
|
|
512
|
+
expect(rowsOverCeiling(loose, masked, ["a"])).toEqual([]);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
it("a malformed ceiling covers nothing (fail closed)", () => {
|
|
516
|
+
expect(scopeRowWithinCeiling(scope, "identifying" as never, "identifying")).toBe(false);
|
|
517
|
+
expect(scopeRowWithinCeiling(scope, new Set(["identifying"]), "names")).toBe(true);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it("the door reports each code once, in list order", () => {
|
|
521
|
+
expect(rowsOverCeiling(scope, ["dob", "names", "dob", "contact"], ["names"])).toEqual(["dob", "contact"]);
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// ─── The property: composer mask ⇔ door ─────────────────────────────────────
|
|
526
|
+
|
|
527
|
+
/** A small deterministic PRNG (mulberry32) — the generated set is stable. */
|
|
528
|
+
function rng(seed: number): () => number {
|
|
529
|
+
let a = seed;
|
|
530
|
+
return () => {
|
|
531
|
+
a |= 0;
|
|
532
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
533
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
534
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
535
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function generatedCeilings(): { name: string; list: string[] }[] {
|
|
540
|
+
const out: { name: string; list: string[] }[] = [{ name: "empty", list: [] }];
|
|
541
|
+
for (const [p, codes] of Object.entries(HTI_SHARE_PLATFORM_STARTER.scopeByPurpose)) {
|
|
542
|
+
out.push({ name: `starter ${p}`, list: [...codes] });
|
|
543
|
+
}
|
|
544
|
+
for (const [cp, lists] of Object.entries(HTI_SHARE_PLATFORM_STARTER.counterpartyOverrides)) {
|
|
545
|
+
for (const [p, codes] of Object.entries(lists)) out.push({ name: `seeded ${cp}.${p}`, list: [...codes] });
|
|
546
|
+
}
|
|
547
|
+
for (const p of LIVE.filter((c) => !isSystem(c) && coverageChildren(c).length > 0)) {
|
|
548
|
+
out.push({ name: `only ${p}`, list: [p] });
|
|
549
|
+
const kids = coverageChildren(p);
|
|
550
|
+
out.push({ name: `children-only of ${p}`, list: kids });
|
|
551
|
+
if (kids.length > 1) out.push({ name: `children-only of ${p} minus one`, list: kids.slice(1) });
|
|
552
|
+
const leaves: string[] = [];
|
|
553
|
+
const walk = (c: string): void => {
|
|
554
|
+
const ks = coverageChildren(c);
|
|
555
|
+
if (ks.length === 0) leaves.push(c);
|
|
556
|
+
else ks.forEach(walk);
|
|
557
|
+
};
|
|
558
|
+
walk(p);
|
|
559
|
+
out.push({ name: `leaves-only of ${p}`, list: leaves });
|
|
560
|
+
}
|
|
561
|
+
const pool = LIVE.filter((c) => !isSystem(c));
|
|
562
|
+
const next = rng(0x5eed);
|
|
563
|
+
for (let i = 0; i < 60; i += 1) {
|
|
564
|
+
const n = 1 + Math.floor(next() * 8);
|
|
565
|
+
const list = new Set<string>();
|
|
566
|
+
while (list.size < n) list.add(pool[Math.floor(next() * pool.length)] as string);
|
|
567
|
+
out.push({ name: `random #${i}`, list: [...list] });
|
|
568
|
+
}
|
|
569
|
+
return out;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const CEILINGS = generatedCeilings();
|
|
573
|
+
/** What a picker writes for one row: select-all at a choice, the code itself otherwise. */
|
|
574
|
+
const pick = (code: string): string[] =>
|
|
575
|
+
isSelectableScopeRow(scope.row(code))
|
|
576
|
+
? scope.selectAll([INFORMATION_SCOPE_SYSTEM_INFO], code)
|
|
577
|
+
: [INFORMATION_SCOPE_SYSTEM_INFO, code];
|
|
578
|
+
|
|
579
|
+
describe(`property: the composer mask and the door agree (${LIVE.length} live rows × ${CEILINGS.length} ceilings)`, () => {
|
|
580
|
+
it("the door accepts a row alone ⇔ the row is within", () => {
|
|
581
|
+
for (const { name, list } of CEILINGS) {
|
|
582
|
+
const within = ceilingCoverage(scope, list);
|
|
583
|
+
for (const r of LIVE) {
|
|
584
|
+
if (isSystem(r) || underFloor(r)) continue;
|
|
585
|
+
expect(rowsOverCeiling(scope, [r], list).length === 0, `${name}: ${r}`).toBe(within(r));
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it("a row within is never mask-restricted; a mask-restricted row is never within", () => {
|
|
591
|
+
for (const { name, list } of CEILINGS) {
|
|
592
|
+
const within = ceilingCoverage(scope, list);
|
|
593
|
+
const outside = new Set(rowsOutsideCeiling(scope, list));
|
|
594
|
+
for (const r of LIVE) {
|
|
595
|
+
if (isSystem(r) || underFloor(r)) continue;
|
|
596
|
+
const locked = scope.ancestorsOf(r).some((a) => outside.has(a));
|
|
597
|
+
if (within(r)) expect(locked, `${name}: ${r} is within yet restricted`).toBe(false);
|
|
598
|
+
if (locked) expect(within(r), `${name}: ${r} is restricted yet within`).toBe(false);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it("picking any live row, then masking, never yields a row the door refuses — and keeps a within row", () => {
|
|
604
|
+
for (const { name, list } of CEILINGS) {
|
|
605
|
+
const within = ceilingCoverage(scope, list);
|
|
606
|
+
for (const r of LIVE) {
|
|
607
|
+
const masked = maskSelectionToCeiling(scope, pick(r), list);
|
|
608
|
+
expect(rowsOverCeiling(scope, masked, list), `${name}: picking ${r} masked to ${masked.join(",")}`).toEqual(
|
|
609
|
+
[],
|
|
610
|
+
);
|
|
611
|
+
if (!isSystem(r) && !underFloor(r) && within(r)) {
|
|
612
|
+
expect(masked, `${name}: ${r} is within yet masked away`).toContain(r);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it("an expanded (own-content) row is never within, and never survives the mask", () => {
|
|
619
|
+
for (const { name, list } of CEILINGS) {
|
|
620
|
+
const within = ceilingCoverage(scope, list);
|
|
621
|
+
for (const r of rowsExpandedByCeiling(scope, list)) {
|
|
622
|
+
expect(hasOwnScopeContent(scope, r), `${name}: ${r}`).toBe(true);
|
|
623
|
+
expect(within(r), `${name}: ${r} expanded yet within`).toBe(false);
|
|
624
|
+
expect(maskSelectionToCeiling(scope, pick(r), list), `${name}: ${r}`).not.toContain(r);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
it("picking several rows at once, then masking, is accepted and keeps every within pick", () => {
|
|
630
|
+
const next = rng(0xc0ffee);
|
|
631
|
+
const pickable = LIVE.filter((c) => !isSystem(c));
|
|
632
|
+
for (const { name, list } of CEILINGS) {
|
|
633
|
+
const within = ceilingCoverage(scope, list);
|
|
634
|
+
for (let i = 0; i < 25; i += 1) {
|
|
635
|
+
const picks = Array.from(
|
|
636
|
+
{ length: 2 + Math.floor(next() * 4) },
|
|
637
|
+
() => pickable[Math.floor(next() * pickable.length)] as string,
|
|
638
|
+
);
|
|
639
|
+
const sel = picks.reduce<string[]>(
|
|
640
|
+
(acc, c) =>
|
|
641
|
+
isSelectableScopeRow(scope.row(c)) ? scope.selectAll(acc, c) : [...acc, c],
|
|
642
|
+
[INFORMATION_SCOPE_SYSTEM_INFO],
|
|
643
|
+
);
|
|
644
|
+
const masked = maskSelectionToCeiling(scope, sel, list);
|
|
645
|
+
expect(rowsOverCeiling(scope, masked, list), `${name}: ${sel.join(",")}`).toEqual([]);
|
|
646
|
+
for (const c of sel) {
|
|
647
|
+
// A within pick stays COVERED (it, or a row above it, is still sent).
|
|
648
|
+
if (c !== INFORMATION_SCOPE_SYSTEM_INFO && !underFloor(c) && within(c)) {
|
|
649
|
+
expect(
|
|
650
|
+
scope.ancestorsOf(c).some((a) => masked.includes(a)),
|
|
651
|
+
`${name}: ${c} within yet masked from ${sel.join(",")} -> ${masked.join(",")}`,
|
|
652
|
+
).toBe(true);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
it("picking EVERYTHING, then masking, is accepted; with no ceiling nothing is masked", () => {
|
|
660
|
+
const roots = scope.rows.filter((r) => r.parentScopeCode === null).map((r) => r.scopeCode);
|
|
661
|
+
for (const { name, list } of CEILINGS) {
|
|
662
|
+
const masked = maskSelectionToCeiling(scope, roots, list);
|
|
663
|
+
expect(rowsOverCeiling(scope, masked, list), name).toEqual([]);
|
|
664
|
+
}
|
|
665
|
+
expect(maskSelectionToCeiling(scope, roots, null)).toEqual([
|
|
666
|
+
INFORMATION_SCOPE_SYSTEM_INFO,
|
|
667
|
+
...roots,
|
|
668
|
+
]);
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
it("the starter's own lists, read through the chain, are accepted by the door", () => {
|
|
672
|
+
for (const purpose of Object.keys(HTI_SHARE_PLATFORM_STARTER.scopeByPurpose)) {
|
|
673
|
+
const c = effectiveCeiling("agency-unseeded", purpose, { edits: {}, purposeOverrides: { [purpose]: true } });
|
|
674
|
+
expect(c.rung).toBe("platform_default");
|
|
675
|
+
expect(rowsOverCeiling(scope, c.allowed, c.allowed), purpose).toEqual([]);
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
});
|