@htilabs/platform-common-models 0.55.0 → 0.56.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 +42 -0
- package/dist/authz/index.cjs +353 -2
- package/dist/authz/index.cjs.map +1 -1
- package/dist/authz/index.d.cts +320 -1
- package/dist/authz/index.d.ts +320 -1
- package/dist/authz/index.js +339 -1
- package/dist/authz/index.js.map +1 -1
- package/dist/index.cjs +351 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +338 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/authz-resolve.test.ts +5 -0
- package/src/__tests__/authz-viewing-policy.test.ts +685 -0
- package/src/__tests__/authz-viewing-scope.test.ts +1037 -0
- package/src/authz/index.ts +2 -0
- package/src/authz/viewingPolicy.ts +525 -0
- package/src/authz/viewingScope.ts +359 -0
package/README.md
CHANGED
|
@@ -16,6 +16,48 @@ Package exports are organized into a public root API and a small number of
|
|
|
16
16
|
dedicated subpaths (`/validation`, `/cvcs`) — consult `package.json` for the
|
|
17
17
|
authoritative `exports` map.
|
|
18
18
|
|
|
19
|
+
## 0.56.0 — the account's Internal Viewing Policy reader, once: `resolveViewingPolicy` + the Level 3 filter (additive; Kickoff 13 § 5a Lane D)
|
|
20
|
+
|
|
21
|
+
**What changed.** `/authz` (and the root) now export the one reader of the
|
|
22
|
+
account's internal-viewing rule, lifted from PAVE's `@pave/db`
|
|
23
|
+
`readViewingPolicy` with its selection and validation rules unchanged, so
|
|
24
|
+
Thread and PAVE decide "which viewing rule governs this team" the same way:
|
|
25
|
+
|
|
26
|
+
- `resolveViewingPolicy(docs, { accountId, teamId }, scope)` →
|
|
27
|
+
`GoverningViewingPolicy`: `{ source: "team" | "account" | "none" |
|
|
28
|
+
"unavailable", level, visibleGroups, scopeVocab, policy: { id, familyId,
|
|
29
|
+
version } | null, rulePath }` (plus `accountId` / `retiredRowsOnly` /
|
|
30
|
+
`reason` / `policyId` by source). The team's own active row REPLACES the
|
|
31
|
+
account-wide rule, higher or lower; with neither, `"none"` (level `null`:
|
|
32
|
+
the role level alone decides, and Level 3 shows the full record); anything
|
|
33
|
+
malformed or unreadable is `"unavailable"` (level 0), and a malformed team
|
|
34
|
+
row never falls back to the account rule. A governing row with no
|
|
35
|
+
`visibleGroups` reads as `[]`.
|
|
36
|
+
- `teamViewingLevelFromPolicy(result)` → the `teamViewingLevel` argument of
|
|
37
|
+
`viewingLevelFromFunctions` / `resolveEffectiveViewingLevel`: the row's
|
|
38
|
+
level, `null` for `"none"`, `0` for `"unavailable"`.
|
|
39
|
+
- `unavailableViewingPolicy(reason)` for the app's own I/O outcomes
|
|
40
|
+
(`read_error`, `policy_store_absent`, …), `VIEWING_POLICY_SPECIES`,
|
|
41
|
+
`VIEWING_POLICY_VOCABULARIES` / `viewingPolicyVocabulary` (stamps 3, 4, 5).
|
|
42
|
+
- The Level 3 filter, lifted from PAVE `@pave/domain` `viewingScope.ts`:
|
|
43
|
+
`viewingWhitelistFromPolicy`, `caseViewingAccess`, `recordViewing`,
|
|
44
|
+
`caseSurfacesOn`, `caseSurfacesAsStub`, `viewingRowVisible`,
|
|
45
|
+
`viewingComponentOpen` and their types.
|
|
46
|
+
|
|
47
|
+
**Pure.** No database access and no SOT JSON in `./authz`: the app runs its own
|
|
48
|
+
`registry_policies` query and hands the rows in (`null` for a failed read), and
|
|
49
|
+
passes its own binding of the CVC-236 resolver (`scope`) — the one it already
|
|
50
|
+
binds from `coreInformationScopeSot` — so whitelist codes are checked against
|
|
51
|
+
the same tree everywhere. Mongo answers `[]` for a collection that does not
|
|
52
|
+
exist, so on an empty answer the app must check that the policy store exists
|
|
53
|
+
and pass `unavailableViewingPolicy("policy_store_absent")` when it does not
|
|
54
|
+
(PAVE's reader checks with `listCollections`); an empty list from a store that
|
|
55
|
+
exists means "none".
|
|
56
|
+
|
|
57
|
+
**Who needs to act.** Thread (Lane B) calls it next to the seat's functions;
|
|
58
|
+
PAVE swaps its reader and `viewingScope` for these in a follow-up. Nothing
|
|
59
|
+
changes for an app until it adopts it.
|
|
60
|
+
|
|
19
61
|
## 0.55.0 — event-driven sharing's pure half: `ShareEvent` + `fireShareEvent(policies, event)` (additive; Kickoff 13 item 9a)
|
|
20
62
|
|
|
21
63
|
**What changed.** `/sharing-ceiling` (and the root) now export the one answer
|
package/dist/authz/index.cjs
CHANGED
|
@@ -27,15 +27,28 @@ __export(authz_exports, {
|
|
|
27
27
|
DEFAULT_BOUND_STATE_LABELS: () => DEFAULT_BOUND_STATE_LABELS,
|
|
28
28
|
DEFAULT_BOUND_STATE_VALUES: () => DEFAULT_BOUND_STATE_VALUES,
|
|
29
29
|
VIEWING_LEVEL_FUNCTIONS: () => VIEWING_LEVEL_FUNCTIONS,
|
|
30
|
+
VIEWING_POLICY_SPECIES: () => VIEWING_POLICY_SPECIES,
|
|
31
|
+
VIEWING_POLICY_VOCABULARIES: () => VIEWING_POLICY_VOCABULARIES,
|
|
30
32
|
canonicalRoleCode: () => canonicalRoleCode,
|
|
33
|
+
caseSurfacesAsStub: () => caseSurfacesAsStub,
|
|
34
|
+
caseSurfacesOn: () => caseSurfacesOn,
|
|
35
|
+
caseViewingAccess: () => caseViewingAccess,
|
|
31
36
|
codebookDefaultBound: () => codebookDefaultBound,
|
|
32
37
|
explainFunctionRefusal: () => explainFunctionRefusal,
|
|
33
38
|
functionDoor: () => functionDoor,
|
|
34
39
|
isCanonEvaluableFunction: () => isCanonEvaluableFunction,
|
|
40
|
+
recordViewing: () => recordViewing,
|
|
35
41
|
resolveEffectiveFunctions: () => resolveEffectiveFunctions,
|
|
36
42
|
resolveEffectiveViewingLevel: () => resolveEffectiveViewingLevel,
|
|
43
|
+
resolveViewingPolicy: () => resolveViewingPolicy,
|
|
37
44
|
selectActingTeamId: () => selectActingTeamId,
|
|
38
|
-
|
|
45
|
+
teamViewingLevelFromPolicy: () => teamViewingLevelFromPolicy,
|
|
46
|
+
unavailableViewingPolicy: () => unavailableViewingPolicy,
|
|
47
|
+
viewingComponentOpen: () => viewingComponentOpen,
|
|
48
|
+
viewingLevelFromFunctions: () => viewingLevelFromFunctions,
|
|
49
|
+
viewingPolicyVocabulary: () => viewingPolicyVocabulary,
|
|
50
|
+
viewingRowVisible: () => viewingRowVisible,
|
|
51
|
+
viewingWhitelistFromPolicy: () => viewingWhitelistFromPolicy
|
|
39
52
|
});
|
|
40
53
|
module.exports = __toCommonJS(authz_exports);
|
|
41
54
|
|
|
@@ -1022,6 +1035,331 @@ function functionDoor(input) {
|
|
|
1022
1035
|
reason: sentence(refusal, labelFor(functionKey, input.label), roleWords)
|
|
1023
1036
|
};
|
|
1024
1037
|
}
|
|
1038
|
+
|
|
1039
|
+
// src/authz/viewingPolicy.ts
|
|
1040
|
+
var VIEWING_POLICY_SPECIES = "viewing";
|
|
1041
|
+
var VIEWING_POLICY_VOCABULARIES = Object.freeze({
|
|
1042
|
+
3: Object.freeze({ scopeVersion: 3, oneHomeCarry: true, identifyingAlias: true }),
|
|
1043
|
+
4: Object.freeze({ scopeVersion: 3, oneHomeCarry: false, identifyingAlias: true }),
|
|
1044
|
+
5: Object.freeze({ scopeVersion: 4, oneHomeCarry: false, identifyingAlias: false })
|
|
1045
|
+
});
|
|
1046
|
+
function viewingPolicyVocabulary(scopeVocab) {
|
|
1047
|
+
return scopeVocab === 3 || scopeVocab === 4 || scopeVocab === 5 ? VIEWING_POLICY_VOCABULARIES[scopeVocab] : null;
|
|
1048
|
+
}
|
|
1049
|
+
function unavailableViewingPolicy(reason, policyId) {
|
|
1050
|
+
return {
|
|
1051
|
+
source: "unavailable",
|
|
1052
|
+
level: 0,
|
|
1053
|
+
visibleGroups: [],
|
|
1054
|
+
scopeVocab: null,
|
|
1055
|
+
policy: null,
|
|
1056
|
+
reason,
|
|
1057
|
+
policyId: policyId ?? null,
|
|
1058
|
+
rulePath: `viewing policy unavailable: ${reason}` + (policyId ? ` (${policyId})` : "") + " \u2014 no view of other teams' cases"
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
var HEX_OBJECT_ID = /^[0-9a-fA-F]{24}$/;
|
|
1062
|
+
function objectIdHex(v) {
|
|
1063
|
+
if (typeof v === "object" && v !== null && "toHexString" in v) {
|
|
1064
|
+
const toHex = v.toHexString;
|
|
1065
|
+
if (typeof toHex === "function") {
|
|
1066
|
+
const hex = toHex.call(v);
|
|
1067
|
+
if (typeof hex === "string") return hex.toLowerCase();
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
return null;
|
|
1071
|
+
}
|
|
1072
|
+
function idText(v) {
|
|
1073
|
+
if (typeof v === "string") return v === "" ? null : v;
|
|
1074
|
+
return objectIdHex(v);
|
|
1075
|
+
}
|
|
1076
|
+
function normalizedId(id) {
|
|
1077
|
+
return HEX_OBJECT_ID.test(id) ? id.toLowerCase() : id;
|
|
1078
|
+
}
|
|
1079
|
+
function policyIdOf(d) {
|
|
1080
|
+
return idText(d.entity_id) ?? idText(d.id) ?? idText(d._id) ?? "(no id)";
|
|
1081
|
+
}
|
|
1082
|
+
function placementOf(d) {
|
|
1083
|
+
if (!Array.isArray(d.assignments) || d.assignments.length !== 1) {
|
|
1084
|
+
return { kind: "unreadable" };
|
|
1085
|
+
}
|
|
1086
|
+
const [a] = d.assignments;
|
|
1087
|
+
if (typeof a !== "object" || a === null) return { kind: "unreadable" };
|
|
1088
|
+
const { scope, teamId } = a;
|
|
1089
|
+
if (scope === "account") return { kind: "account" };
|
|
1090
|
+
const team = idText(teamId);
|
|
1091
|
+
if (scope === "team" && team !== null) {
|
|
1092
|
+
return { kind: "team", teamId: normalizedId(team) };
|
|
1093
|
+
}
|
|
1094
|
+
return { kind: "unreadable" };
|
|
1095
|
+
}
|
|
1096
|
+
function positiveIntOrNull(v) {
|
|
1097
|
+
if (v === void 0 || v === null) return null;
|
|
1098
|
+
return typeof v === "number" && Number.isInteger(v) && v >= 1 ? v : void 0;
|
|
1099
|
+
}
|
|
1100
|
+
function governingRowOf(rows) {
|
|
1101
|
+
const [only] = rows;
|
|
1102
|
+
if (rows.length === 1 && only !== void 0) return { row: only };
|
|
1103
|
+
const family = idText(rows[0]?.familyId);
|
|
1104
|
+
const versions = rows.map((r) => positiveIntOrNull(r.version));
|
|
1105
|
+
const ordered = family !== null && rows.every((r) => idText(r.familyId) === family) && versions.every((v) => typeof v === "number") && new Set(versions).size === versions.length;
|
|
1106
|
+
if (!ordered) {
|
|
1107
|
+
return unavailableViewingPolicy("ambiguous_rows", policyIdOf(rows[0] ?? {}));
|
|
1108
|
+
}
|
|
1109
|
+
let best = rows[0];
|
|
1110
|
+
for (const r of rows) {
|
|
1111
|
+
if (r.version > best.version) best = r;
|
|
1112
|
+
}
|
|
1113
|
+
return { row: best };
|
|
1114
|
+
}
|
|
1115
|
+
function whitelistProblem(visibleGroups, vocab, scope) {
|
|
1116
|
+
const reading = scope.readSelection(visibleGroups, vocab.scopeVersion, {
|
|
1117
|
+
subject: "policy"
|
|
1118
|
+
});
|
|
1119
|
+
if (reading.unsupportedVersion) return "unsupported_scope_vocab";
|
|
1120
|
+
if (reading.unknown.length > 0 || reading.retired.length > 0) {
|
|
1121
|
+
return "unknown_visible_group";
|
|
1122
|
+
}
|
|
1123
|
+
return null;
|
|
1124
|
+
}
|
|
1125
|
+
function withoutRestRows(visibleGroups, scope) {
|
|
1126
|
+
return visibleGroups.filter((code) => scope.row(code)?.rowType !== "category_rest");
|
|
1127
|
+
}
|
|
1128
|
+
function ruleText(source, ref) {
|
|
1129
|
+
const v = ref.version === null ? "" : ` v${ref.version}`;
|
|
1130
|
+
return source === "team" ? `${ref.id}${v} (the team's own row \u2014 it governs this team in place of the account-wide rule)` : `${ref.id}${v} (the account-wide viewing rule \u2014 no row for this team)`;
|
|
1131
|
+
}
|
|
1132
|
+
function readRow(d, source, accountId, scope) {
|
|
1133
|
+
const policyId = policyIdOf(d);
|
|
1134
|
+
const level = d.level;
|
|
1135
|
+
if (level !== 0 && level !== 1 && level !== 2 && level !== 3) {
|
|
1136
|
+
return unavailableViewingPolicy("malformed_level", policyId);
|
|
1137
|
+
}
|
|
1138
|
+
let visibleGroups = [];
|
|
1139
|
+
if (d.visibleGroups !== void 0 && d.visibleGroups !== null) {
|
|
1140
|
+
if (!Array.isArray(d.visibleGroups) || !d.visibleGroups.every((g) => typeof g === "string")) {
|
|
1141
|
+
return unavailableViewingPolicy("malformed_visible_groups", policyId);
|
|
1142
|
+
}
|
|
1143
|
+
visibleGroups = [...d.visibleGroups];
|
|
1144
|
+
}
|
|
1145
|
+
const scopeVocab = positiveIntOrNull(d.scopeVocab);
|
|
1146
|
+
if (scopeVocab === void 0) {
|
|
1147
|
+
return unavailableViewingPolicy("malformed_scope_vocab", policyId);
|
|
1148
|
+
}
|
|
1149
|
+
const vocab = viewingPolicyVocabulary(scopeVocab);
|
|
1150
|
+
if (scopeVocab === null || vocab === null) {
|
|
1151
|
+
return unavailableViewingPolicy("unsupported_scope_vocab", policyId);
|
|
1152
|
+
}
|
|
1153
|
+
const problem = whitelistProblem(visibleGroups, vocab, scope);
|
|
1154
|
+
if (problem !== null) return unavailableViewingPolicy(problem, policyId);
|
|
1155
|
+
const policy = {
|
|
1156
|
+
id: policyId,
|
|
1157
|
+
familyId: idText(d.familyId),
|
|
1158
|
+
version: positiveIntOrNull(d.version) ?? null
|
|
1159
|
+
};
|
|
1160
|
+
return {
|
|
1161
|
+
source,
|
|
1162
|
+
level,
|
|
1163
|
+
visibleGroups: withoutRestRows(visibleGroups, scope),
|
|
1164
|
+
scopeVocab,
|
|
1165
|
+
policy,
|
|
1166
|
+
accountId,
|
|
1167
|
+
rulePath: ruleText(source, policy)
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
function resolveViewingPolicy(docs, query, scope) {
|
|
1171
|
+
const accountRaw = typeof query.accountId === "string" ? query.accountId.trim() : "";
|
|
1172
|
+
if (accountRaw === "") return unavailableViewingPolicy("account_unresolved");
|
|
1173
|
+
if (!Array.isArray(docs)) return unavailableViewingPolicy("read_error");
|
|
1174
|
+
const accountId = normalizedId(accountRaw);
|
|
1175
|
+
const teamRaw = typeof query.teamId === "string" ? query.teamId.trim() : "";
|
|
1176
|
+
const actingTeamId = teamRaw !== "" ? normalizedId(teamRaw) : null;
|
|
1177
|
+
const rows = [];
|
|
1178
|
+
for (const raw of docs) {
|
|
1179
|
+
if (typeof raw !== "object" || raw === null) {
|
|
1180
|
+
return unavailableViewingPolicy("read_error");
|
|
1181
|
+
}
|
|
1182
|
+
const d = raw;
|
|
1183
|
+
if (d.species !== VIEWING_POLICY_SPECIES) continue;
|
|
1184
|
+
const owner = idText(d.account_id);
|
|
1185
|
+
if (owner === null || normalizedId(owner) !== accountId) continue;
|
|
1186
|
+
rows.push(d);
|
|
1187
|
+
}
|
|
1188
|
+
const teamRows = [];
|
|
1189
|
+
const accountRows = [];
|
|
1190
|
+
for (const d of rows) {
|
|
1191
|
+
if (d.active === false) continue;
|
|
1192
|
+
const placement = placementOf(d);
|
|
1193
|
+
if (placement.kind === "unreadable") {
|
|
1194
|
+
return unavailableViewingPolicy("unreadable_assignment", policyIdOf(d));
|
|
1195
|
+
}
|
|
1196
|
+
const governsHere = placement.kind === "account" || actingTeamId !== null && placement.teamId === actingTeamId;
|
|
1197
|
+
if (!governsHere) continue;
|
|
1198
|
+
if (d.active !== true) {
|
|
1199
|
+
return unavailableViewingPolicy("malformed_active", policyIdOf(d));
|
|
1200
|
+
}
|
|
1201
|
+
if (placement.kind === "account") accountRows.push(d);
|
|
1202
|
+
else teamRows.push(d);
|
|
1203
|
+
}
|
|
1204
|
+
const [source, candidates] = teamRows.length > 0 ? ["team", teamRows] : ["account", accountRows];
|
|
1205
|
+
if (candidates.length === 0) {
|
|
1206
|
+
const retiredRowsOnly = rows.length > 0 && rows.every((d) => d.active === false);
|
|
1207
|
+
return {
|
|
1208
|
+
source: "none",
|
|
1209
|
+
level: null,
|
|
1210
|
+
visibleGroups: null,
|
|
1211
|
+
scopeVocab: null,
|
|
1212
|
+
policy: null,
|
|
1213
|
+
accountId,
|
|
1214
|
+
retiredRowsOnly,
|
|
1215
|
+
rulePath: retiredRowsOnly ? "no viewing policy on file (every viewing row is retired) \u2014 the role level alone decides" : "no viewing policy on file \u2014 the role level alone decides"
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
const governing = governingRowOf(candidates);
|
|
1219
|
+
if (!("row" in governing)) return governing;
|
|
1220
|
+
return readRow(governing.row, source, accountId, scope);
|
|
1221
|
+
}
|
|
1222
|
+
function teamViewingLevelFromPolicy(policy) {
|
|
1223
|
+
switch (policy.source) {
|
|
1224
|
+
case "team":
|
|
1225
|
+
case "account":
|
|
1226
|
+
return policy.level;
|
|
1227
|
+
case "none":
|
|
1228
|
+
return null;
|
|
1229
|
+
default:
|
|
1230
|
+
return 0;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// src/authz/viewingScope.ts
|
|
1235
|
+
var CURRENT_VIEWING_POLICY_VOCAB = 5;
|
|
1236
|
+
var RELATIONSHIPS_HOUSEHOLD = "relationships_household";
|
|
1237
|
+
var RELATIONSHIP_DYNAMICS = "relationship_dynamics";
|
|
1238
|
+
function viewingWhitelistFromPolicy(policy) {
|
|
1239
|
+
switch (policy.source) {
|
|
1240
|
+
case "none":
|
|
1241
|
+
return null;
|
|
1242
|
+
case "team":
|
|
1243
|
+
case "account":
|
|
1244
|
+
return { informationScope: [...policy.visibleGroups], scopeVocab: policy.scopeVocab };
|
|
1245
|
+
default:
|
|
1246
|
+
return { informationScope: [], scopeVocab: null };
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function caseViewingAccess(ctx, scope) {
|
|
1250
|
+
if (ctx.canSeeCase !== true) {
|
|
1251
|
+
return { mode: "none", reason: "cannot_see_case" };
|
|
1252
|
+
}
|
|
1253
|
+
if (ctx.ownedByViewer === true) return { mode: "full", reason: "owned" };
|
|
1254
|
+
if (ctx.level === 1 || ctx.level === 2) {
|
|
1255
|
+
return { mode: "stub", level: ctx.level };
|
|
1256
|
+
}
|
|
1257
|
+
if (ctx.level !== 3) return { mode: "none", reason: "level_0" };
|
|
1258
|
+
if (ctx.whitelist === null) {
|
|
1259
|
+
return { mode: "full", reason: "no_viewing_policy" };
|
|
1260
|
+
}
|
|
1261
|
+
const stored = ctx.whitelist ?? {
|
|
1262
|
+
informationScope: [],
|
|
1263
|
+
scopeVocab: CURRENT_VIEWING_POLICY_VOCAB
|
|
1264
|
+
};
|
|
1265
|
+
const stamp = typeof stored.scopeVocab === "number" ? stored.scopeVocab : null;
|
|
1266
|
+
const vocab = viewingPolicyVocabulary(stamp);
|
|
1267
|
+
const reading = scope.readSelection(
|
|
1268
|
+
stored.informationScope,
|
|
1269
|
+
vocab !== null ? vocab.scopeVersion : stamp,
|
|
1270
|
+
{ subject: "policy" }
|
|
1271
|
+
);
|
|
1272
|
+
const identifyingAlias = vocab !== null && vocab.identifyingAlias && reading.informationScope.includes("identifying");
|
|
1273
|
+
return {
|
|
1274
|
+
mode: "whitelist",
|
|
1275
|
+
reading,
|
|
1276
|
+
visibleScope: identifyingAlias ? [...reading.informationScope, RELATIONSHIPS_HOUSEHOLD] : reading.informationScope,
|
|
1277
|
+
oneHomeCarry: vocab !== null && vocab.oneHomeCarry,
|
|
1278
|
+
relationshipDynamicsCarry: identifyingAlias
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
function caseSurfacesOn(access, surface) {
|
|
1282
|
+
switch (access.mode) {
|
|
1283
|
+
case "none":
|
|
1284
|
+
return false;
|
|
1285
|
+
case "full":
|
|
1286
|
+
case "whitelist":
|
|
1287
|
+
return true;
|
|
1288
|
+
case "stub":
|
|
1289
|
+
if (surface === "search") return true;
|
|
1290
|
+
if (surface === "autocomplete") return access.level === 2;
|
|
1291
|
+
return false;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
function caseSurfacesAsStub(access) {
|
|
1295
|
+
return access.mode === "stub";
|
|
1296
|
+
}
|
|
1297
|
+
var ONE_HOME_CARRY = [
|
|
1298
|
+
{ homeRow: "summary_ida", domains: /* @__PURE__ */ new Set(["ida_determination"]), unlockedBy: "risk" },
|
|
1299
|
+
{
|
|
1300
|
+
homeRow: "summary_needs_assessment",
|
|
1301
|
+
domains: /* @__PURE__ */ new Set(["needs_assessment", "recommended_followup"]),
|
|
1302
|
+
unlockedBy: "services"
|
|
1303
|
+
}
|
|
1304
|
+
];
|
|
1305
|
+
function isClientStubRow(scope, code) {
|
|
1306
|
+
const row = scope.row(code);
|
|
1307
|
+
return row !== void 0 && row.levelFloor === 1 && row.rowType !== "branch" && (row.kindBranch === "client" || row.kindBranch === null);
|
|
1308
|
+
}
|
|
1309
|
+
function recordViewing(access, record, viewerUserId, scope) {
|
|
1310
|
+
if (access.mode === "none" && access.reason === "cannot_see_case") {
|
|
1311
|
+
return { visible: false, reason: "cannot_see_case" };
|
|
1312
|
+
}
|
|
1313
|
+
const author = record.authorUserId;
|
|
1314
|
+
if (typeof author === "string" && author.trim().length > 0 && author === viewerUserId) {
|
|
1315
|
+
return { visible: true, reason: "author" };
|
|
1316
|
+
}
|
|
1317
|
+
switch (access.mode) {
|
|
1318
|
+
case "none":
|
|
1319
|
+
return { visible: false, reason: access.reason };
|
|
1320
|
+
case "full":
|
|
1321
|
+
return { visible: true, reason: "full" };
|
|
1322
|
+
case "stub":
|
|
1323
|
+
return { visible: false, reason: "not_opened" };
|
|
1324
|
+
case "whitelist":
|
|
1325
|
+
return whitelistDecision(access, record, scope);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
function whitelistDecision(access, record, scope) {
|
|
1329
|
+
const home = scope.row(record.homeRow);
|
|
1330
|
+
if (home === void 0 || home.kindRow !== void 0) {
|
|
1331
|
+
return { visible: false, reason: "unknown_row" };
|
|
1332
|
+
}
|
|
1333
|
+
if ((record.subjectKind === "client" || home.kindBranch !== "client") && isClientStubRow(scope, record.homeRow)) {
|
|
1334
|
+
return { visible: true, reason: "stub_row" };
|
|
1335
|
+
}
|
|
1336
|
+
const list = access.visibleScope;
|
|
1337
|
+
if (scope.isCovered(list, record.homeRow)) {
|
|
1338
|
+
return { visible: true, reason: "covered" };
|
|
1339
|
+
}
|
|
1340
|
+
if (access.relationshipDynamicsCarry && record.domain === RELATIONSHIP_DYNAMICS) {
|
|
1341
|
+
return { visible: true, reason: "identifying_alias_carry" };
|
|
1342
|
+
}
|
|
1343
|
+
if (access.oneHomeCarry && !scope.isCovered(list, "instruments") && typeof record.domain === "string") {
|
|
1344
|
+
for (const carry of ONE_HOME_CARRY) {
|
|
1345
|
+
if (record.homeRow === carry.homeRow && carry.domains.has(record.domain) && scope.isCovered(list, carry.unlockedBy)) {
|
|
1346
|
+
return { visible: true, reason: "one_home_carry" };
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
return { visible: false, reason: "not_covered" };
|
|
1351
|
+
}
|
|
1352
|
+
function viewingRowVisible(access, homeRow, scope) {
|
|
1353
|
+
return recordViewing(access, { homeRow, subjectKind: "client" }, null, scope).visible;
|
|
1354
|
+
}
|
|
1355
|
+
function viewingComponentOpen(access, homeRow, scope) {
|
|
1356
|
+
if (access.mode === "full") return true;
|
|
1357
|
+
if (access.mode !== "whitelist") return false;
|
|
1358
|
+
const row = scope.row(homeRow);
|
|
1359
|
+
if (row === void 0 || row.kindRow !== void 0) return false;
|
|
1360
|
+
if (row.status === "retired") return false;
|
|
1361
|
+
return scope.isCovered(access.visibleScope, homeRow);
|
|
1362
|
+
}
|
|
1025
1363
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1026
1364
|
0 && (module.exports = {
|
|
1027
1365
|
CORE_FUNCTION_DEFAULT_BOUNDS,
|
|
@@ -1031,14 +1369,27 @@ function functionDoor(input) {
|
|
|
1031
1369
|
DEFAULT_BOUND_STATE_LABELS,
|
|
1032
1370
|
DEFAULT_BOUND_STATE_VALUES,
|
|
1033
1371
|
VIEWING_LEVEL_FUNCTIONS,
|
|
1372
|
+
VIEWING_POLICY_SPECIES,
|
|
1373
|
+
VIEWING_POLICY_VOCABULARIES,
|
|
1034
1374
|
canonicalRoleCode,
|
|
1375
|
+
caseSurfacesAsStub,
|
|
1376
|
+
caseSurfacesOn,
|
|
1377
|
+
caseViewingAccess,
|
|
1035
1378
|
codebookDefaultBound,
|
|
1036
1379
|
explainFunctionRefusal,
|
|
1037
1380
|
functionDoor,
|
|
1038
1381
|
isCanonEvaluableFunction,
|
|
1382
|
+
recordViewing,
|
|
1039
1383
|
resolveEffectiveFunctions,
|
|
1040
1384
|
resolveEffectiveViewingLevel,
|
|
1385
|
+
resolveViewingPolicy,
|
|
1041
1386
|
selectActingTeamId,
|
|
1042
|
-
|
|
1387
|
+
teamViewingLevelFromPolicy,
|
|
1388
|
+
unavailableViewingPolicy,
|
|
1389
|
+
viewingComponentOpen,
|
|
1390
|
+
viewingLevelFromFunctions,
|
|
1391
|
+
viewingPolicyVocabulary,
|
|
1392
|
+
viewingRowVisible,
|
|
1393
|
+
viewingWhitelistFromPolicy
|
|
1043
1394
|
});
|
|
1044
1395
|
//# sourceMappingURL=index.cjs.map
|