@htilabs/platform-common-models 0.80.0 → 0.82.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 +27 -0
- package/dist/{index-DvAypMJV.d.ts → index-Bh1zO_Vu.d.ts} +1 -1
- package/dist/{index-Bj-s0nZy.d.cts → index-XWSYon40.d.cts} +1 -1
- package/dist/index.cjs +365 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +355 -47
- package/dist/index.js.map +1 -1
- package/dist/information-scope/index.cjs +290 -2
- package/dist/information-scope/index.cjs.map +1 -1
- package/dist/information-scope/index.d.cts +84 -1
- package/dist/information-scope/index.d.ts +84 -1
- package/dist/information-scope/index.js +279 -1
- package/dist/information-scope/index.js.map +1 -1
- 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.cjs +290 -2
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +279 -1
- package/dist/services/index.js.map +1 -1
- package/dist/sharing-ceiling/index.cjs +33 -3
- package/dist/sharing-ceiling/index.cjs.map +1 -1
- package/dist/sharing-ceiling/index.d.cts +11 -7
- package/dist/sharing-ceiling/index.d.ts +11 -7
- package/dist/sharing-ceiling/index.js +33 -3
- package/dist/sharing-ceiling/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generated/informationScopeUiCopy.ts +263 -0
- package/src/services/__tests__/informationScopeUiCopy.test.ts +128 -0
- package/src/services/informationScope.ts +1 -0
- package/src/services/informationScopeUiCopy.ts +98 -0
- package/src/sharingCeiling/__tests__/fixtures_starterVerdicts.json +1727 -0
- package/src/sharingCeiling/__tests__/personContactRows.test.ts +185 -0
- package/src/sharingCeiling/coverage.ts +55 -6
- package/src/sharingCeiling/resolve.ts +31 -8
- package/dist/{cvcEntry-BLeRivoF.d.cts → cvcEntry-D787utvP.d.cts} +8 -8
- package/dist/{cvcEntry-BLeRivoF.d.ts → cvcEntry-D787utvP.d.ts} +8 -8
package/package.json
CHANGED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @htilabs/platform-common-models — CVC-236 Information Scope page: UI copy + row order
|
|
3
|
+
*
|
|
4
|
+
* AUTO-GENERATED FILE — DO NOT EDIT BY HAND.
|
|
5
|
+
* Regenerate with:
|
|
6
|
+
* `python3 scripts/gen-information-scope-ui-copy.py <prototype root> <platform-prototype root>`.
|
|
7
|
+
*
|
|
8
|
+
* Canon (read from git objects at origin/main):
|
|
9
|
+
* - ORDER: htilabstech/prototype data/cvcs/core_information_scope.yaml (the CVC-236 tree;
|
|
10
|
+
* a category's `units:`, or its `groupings:`' units in grouping order).
|
|
11
|
+
* - WORDS: htilabstech/platform-prototype src/data.js `sharing.scopeCatalog`
|
|
12
|
+
* `sub` (per category) and `hint` (per row) — presentation text authored there and
|
|
13
|
+
* preserved by id by the records repo's tools/build_information_scope_registry.py.
|
|
14
|
+
* The two copies agree on every category, row and order (the generator refuses otherwise).
|
|
15
|
+
* Keys are package keys (canon `.` spelled `__`), as in `coreInformationScopeSot`.
|
|
16
|
+
* `src/services/__tests__/informationScopeUiCopy.test.ts` holds every key to a live SOT row.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Where this data was taken from (provenance, not compared by `--check`). */
|
|
20
|
+
export const INFORMATION_SCOPE_UI_COPY_SOURCE = {
|
|
21
|
+
"order": {
|
|
22
|
+
"repo": "htilabstech/prototype",
|
|
23
|
+
"file": "data/cvcs/core_information_scope.yaml",
|
|
24
|
+
"sha": "395bb7aa"
|
|
25
|
+
},
|
|
26
|
+
"words": {
|
|
27
|
+
"repo": "htilabstech/platform-prototype",
|
|
28
|
+
"file": "src/data.js",
|
|
29
|
+
"sha": "c324f715",
|
|
30
|
+
"line": 33875
|
|
31
|
+
}
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
34
|
+
// <data>
|
|
35
|
+
/** Every category, in canon's order (package keys). */
|
|
36
|
+
export const INFORMATION_SCOPE_CATEGORY_ORDER: readonly string[] = [
|
|
37
|
+
"system",
|
|
38
|
+
"notes",
|
|
39
|
+
"identifying",
|
|
40
|
+
"contact",
|
|
41
|
+
"health_accommodation",
|
|
42
|
+
"immigration_legal_status",
|
|
43
|
+
"risk",
|
|
44
|
+
"services",
|
|
45
|
+
"instruments",
|
|
46
|
+
"relationships_household",
|
|
47
|
+
"offenders__identifying",
|
|
48
|
+
"offenders__contact",
|
|
49
|
+
"offenders__health_accommodation",
|
|
50
|
+
"offenders__immigration_legal_status",
|
|
51
|
+
"offenders__risk",
|
|
52
|
+
"offenders__services",
|
|
53
|
+
"offenders__instruments",
|
|
54
|
+
"offenders__relationships_household",
|
|
55
|
+
"family__identifying",
|
|
56
|
+
"family__contact",
|
|
57
|
+
"family__health_accommodation",
|
|
58
|
+
"family__immigration_legal_status",
|
|
59
|
+
"family__risk",
|
|
60
|
+
"family__services",
|
|
61
|
+
"family__instruments",
|
|
62
|
+
"family__relationships_household",
|
|
63
|
+
"others__identifying",
|
|
64
|
+
"others__contact",
|
|
65
|
+
"others__health_accommodation",
|
|
66
|
+
"others__immigration_legal_status",
|
|
67
|
+
"others__risk",
|
|
68
|
+
"others__services",
|
|
69
|
+
"others__instruments",
|
|
70
|
+
"others__relationships_household",
|
|
71
|
+
"network_associations",
|
|
72
|
+
"commercial_activity",
|
|
73
|
+
"investigative_work_product",
|
|
74
|
+
"object_identifiers",
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
/** Per category: the one-line description drawn under its title. */
|
|
78
|
+
export const INFORMATION_SCOPE_CATEGORY_SUB: Readonly<Record<string, string>> = {
|
|
79
|
+
"system": "Session timestamps, source info — always shared",
|
|
80
|
+
"notes": "The session summary, and notes written in a session or on the case",
|
|
81
|
+
"identifying": "Names, DOB, addresses, identifiers, demographics",
|
|
82
|
+
"contact": "How to reach the person safely: contact info + safety preferences, the Priorities & Safety triage",
|
|
83
|
+
"health_accommodation": "Health status, accommodation needs",
|
|
84
|
+
"immigration_legal_status": "Immigration status, immigration applications",
|
|
85
|
+
"risk": "Indicators, screening outcomes, per-instrument assessment responses, determinations, system involvement — the people who caused harm are their own branch",
|
|
86
|
+
"services": "Contact history with this agency, service records, service plans + goals — three tiers of sensitivity",
|
|
87
|
+
"instruments": "Initial Screen, intake screens, assessments, Findings — a Summary & outcome row and a Full questions, narratives & notes row per instrument",
|
|
88
|
+
"relationships_household": "The client's account of the people around them — each relationship record, the household roster, pets; each entry names the other person as name + kind and carries nothing else about them",
|
|
89
|
+
"offenders__identifying": "People who caused harm — the person's own record, grouped by kind (identifying information)",
|
|
90
|
+
"offenders__contact": "People who caused harm — the person's own record, grouped by kind (contact & safety)",
|
|
91
|
+
"offenders__health_accommodation": "People who caused harm — the person's own record, grouped by kind (health & accommodation)",
|
|
92
|
+
"offenders__immigration_legal_status": "People who caused harm — the person's own record, grouped by kind (immigration & legal status)",
|
|
93
|
+
"offenders__risk": "People who caused harm — the person's own record, grouped by kind (risk-related)",
|
|
94
|
+
"offenders__services": "People who caused harm — the person's own record, grouped by kind (services & case history)",
|
|
95
|
+
"offenders__instruments": "People who caused harm — the person's own record, grouped by kind (screens & assessments)",
|
|
96
|
+
"offenders__relationships_household": "People who caused harm — the person's own record, grouped by kind (relationships & household)",
|
|
97
|
+
"family__identifying": "Eligible family members — the person's own record, grouped by kind (identifying information)",
|
|
98
|
+
"family__contact": "Eligible family members — the person's own record, grouped by kind (contact & safety)",
|
|
99
|
+
"family__health_accommodation": "Eligible family members — the person's own record, grouped by kind (health & accommodation)",
|
|
100
|
+
"family__immigration_legal_status": "Eligible family members — the person's own record, grouped by kind (immigration & legal status)",
|
|
101
|
+
"family__risk": "Eligible family members — the person's own record, grouped by kind (risk-related)",
|
|
102
|
+
"family__services": "Eligible family members — the person's own record, grouped by kind (services & case history)",
|
|
103
|
+
"family__instruments": "Eligible family members — the person's own record, grouped by kind (screens & assessments)",
|
|
104
|
+
"family__relationships_household": "Eligible family members — the person's own record, grouped by kind (relationships & household)",
|
|
105
|
+
"others__identifying": "Other people on the case — the person's own record, grouped by kind (identifying information)",
|
|
106
|
+
"others__contact": "Other people on the case — the person's own record, grouped by kind (contact & safety)",
|
|
107
|
+
"others__health_accommodation": "Other people on the case — the person's own record, grouped by kind (health & accommodation)",
|
|
108
|
+
"others__immigration_legal_status": "Other people on the case — the person's own record, grouped by kind (immigration & legal status)",
|
|
109
|
+
"others__risk": "Other people on the case — the person's own record, grouped by kind (risk-related)",
|
|
110
|
+
"others__services": "Other people on the case — the person's own record, grouped by kind (services & case history)",
|
|
111
|
+
"others__instruments": "Other people on the case — the person's own record, grouped by kind (screens & assessments)",
|
|
112
|
+
"others__relationships_household": "Other people on the case — the person's own record, grouped by kind (relationships & household)",
|
|
113
|
+
"network_associations": "Personas, network membership, relationships, criminal-org links",
|
|
114
|
+
"commercial_activity": "Ads, listings, posting activity, pricing, business fronts",
|
|
115
|
+
"investigative_work_product": "Analyst determinations, dispositions, case briefs",
|
|
116
|
+
"object_identifiers": "Phone numbers, vehicle identifiers, image hashes, account handles",
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** Per category: its live rows in canon's order (package keys; empty when it has none). */
|
|
120
|
+
export const INFORMATION_SCOPE_ROW_ORDER: Readonly<Record<string, readonly string[]>> = {
|
|
121
|
+
"system": [
|
|
122
|
+
"system_info",
|
|
123
|
+
],
|
|
124
|
+
"notes": [
|
|
125
|
+
"session_summary",
|
|
126
|
+
"case_notes",
|
|
127
|
+
],
|
|
128
|
+
"identifying": [
|
|
129
|
+
"names",
|
|
130
|
+
"dob",
|
|
131
|
+
"addresses",
|
|
132
|
+
"additional_ids",
|
|
133
|
+
"demographics",
|
|
134
|
+
"identifying__other",
|
|
135
|
+
],
|
|
136
|
+
"contact": [
|
|
137
|
+
"contact_info",
|
|
138
|
+
"safe_locations",
|
|
139
|
+
"priorities_safety",
|
|
140
|
+
"encounter_location",
|
|
141
|
+
],
|
|
142
|
+
"health_accommodation": [
|
|
143
|
+
"health_status",
|
|
144
|
+
"accommodation_needs",
|
|
145
|
+
],
|
|
146
|
+
"immigration_legal_status": [
|
|
147
|
+
"immigration_status",
|
|
148
|
+
"immigration_applications",
|
|
149
|
+
],
|
|
150
|
+
"risk": [
|
|
151
|
+
"screen_indicators",
|
|
152
|
+
"victimization",
|
|
153
|
+
"system_involvement",
|
|
154
|
+
"derived_risk_signals",
|
|
155
|
+
],
|
|
156
|
+
"services": [
|
|
157
|
+
"contact_history",
|
|
158
|
+
"service_history",
|
|
159
|
+
"plans_goals",
|
|
160
|
+
],
|
|
161
|
+
"instruments": [
|
|
162
|
+
"summary_initial_screen",
|
|
163
|
+
"summary_mental_health_screen",
|
|
164
|
+
"summary_behavioral_health_intake",
|
|
165
|
+
"summary_trauma_and_coping_screen",
|
|
166
|
+
"summary_ae_intake",
|
|
167
|
+
"summary_ida",
|
|
168
|
+
"summary_lap",
|
|
169
|
+
"summary_danger_assessment",
|
|
170
|
+
"summary_stalking_assessment",
|
|
171
|
+
"summary_injury_and_strangulation",
|
|
172
|
+
"summary_hope_scale",
|
|
173
|
+
"summary_needs_assessment",
|
|
174
|
+
"summary_tra",
|
|
175
|
+
"summary_findings",
|
|
176
|
+
"full_initial_screen",
|
|
177
|
+
"full_mental_health_screen",
|
|
178
|
+
"full_behavioral_health_intake",
|
|
179
|
+
"full_trauma_and_coping_screen",
|
|
180
|
+
"full_ae_intake",
|
|
181
|
+
"full_ida",
|
|
182
|
+
"full_lap",
|
|
183
|
+
"full_danger_assessment",
|
|
184
|
+
"full_stalking_assessment",
|
|
185
|
+
"full_injury_and_strangulation",
|
|
186
|
+
"full_hope_scale",
|
|
187
|
+
"full_needs_assessment",
|
|
188
|
+
"full_tra",
|
|
189
|
+
"full_findings",
|
|
190
|
+
],
|
|
191
|
+
"relationships_household": [],
|
|
192
|
+
"offenders__identifying": [],
|
|
193
|
+
"offenders__contact": [
|
|
194
|
+
"offenders__safe_locations",
|
|
195
|
+
],
|
|
196
|
+
"offenders__health_accommodation": [],
|
|
197
|
+
"offenders__immigration_legal_status": [],
|
|
198
|
+
"offenders__risk": [],
|
|
199
|
+
"offenders__services": [],
|
|
200
|
+
"offenders__instruments": [
|
|
201
|
+
"offenders__instrument_summary",
|
|
202
|
+
"offenders__instrument_full",
|
|
203
|
+
],
|
|
204
|
+
"offenders__relationships_household": [],
|
|
205
|
+
"family__identifying": [],
|
|
206
|
+
"family__contact": [
|
|
207
|
+
"family__safe_locations",
|
|
208
|
+
],
|
|
209
|
+
"family__health_accommodation": [],
|
|
210
|
+
"family__immigration_legal_status": [],
|
|
211
|
+
"family__risk": [],
|
|
212
|
+
"family__services": [],
|
|
213
|
+
"family__instruments": [
|
|
214
|
+
"family__instrument_summary",
|
|
215
|
+
"family__instrument_full",
|
|
216
|
+
],
|
|
217
|
+
"family__relationships_household": [],
|
|
218
|
+
"others__identifying": [],
|
|
219
|
+
"others__contact": [
|
|
220
|
+
"others__safe_locations",
|
|
221
|
+
],
|
|
222
|
+
"others__health_accommodation": [],
|
|
223
|
+
"others__immigration_legal_status": [],
|
|
224
|
+
"others__risk": [],
|
|
225
|
+
"others__services": [],
|
|
226
|
+
"others__instruments": [
|
|
227
|
+
"others__instrument_summary",
|
|
228
|
+
"others__instrument_full",
|
|
229
|
+
],
|
|
230
|
+
"others__relationships_household": [],
|
|
231
|
+
"network_associations": [
|
|
232
|
+
"network_membership",
|
|
233
|
+
"persona_links",
|
|
234
|
+
],
|
|
235
|
+
"commercial_activity": [
|
|
236
|
+
"ad_content",
|
|
237
|
+
"commercial_patterns",
|
|
238
|
+
],
|
|
239
|
+
"investigative_work_product": [
|
|
240
|
+
"case_determinations",
|
|
241
|
+
"case_lifecycle",
|
|
242
|
+
"case_attachments",
|
|
243
|
+
],
|
|
244
|
+
"object_identifiers": [
|
|
245
|
+
"phone_identifiers",
|
|
246
|
+
"object_identity_attributes",
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/** Per row (only rows that have one): the hint line drawn under it. */
|
|
251
|
+
export const INFORMATION_SCOPE_ROW_HINT: Readonly<Record<string, string>> = {
|
|
252
|
+
"system_info": "Always included",
|
|
253
|
+
"names": "All logged name entries",
|
|
254
|
+
"additional_ids": "Other IDs entered separately",
|
|
255
|
+
"identifying__other": "Living situation · work & income · education · languages · citizenship · physical description · vehicle",
|
|
256
|
+
"safe_locations": "Shelter placements + confidential program addresses",
|
|
257
|
+
"encounter_location": "The session's meetup / incident location — not the survivor's own addresses (CVC-191 reasons Meet / contact + Incident)",
|
|
258
|
+
"immigration_status": "Visa type + birth country + relevant flags",
|
|
259
|
+
"commercial_patterns": "Pricing, schedule, venues",
|
|
260
|
+
"case_attachments": "Content-dependent — attachment handling flags govern",
|
|
261
|
+
"object_identity_attributes": "Names, trade names, ages",
|
|
262
|
+
};
|
|
263
|
+
// </data>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CVC-236 Information Scope page UI copy + row order
|
|
3
|
+
* (`src/generated/informationScopeUiCopy.ts`, `../informationScopeUiCopy.ts`).
|
|
4
|
+
*
|
|
5
|
+
* The copy is keyed by CVC-236 row: these tests hold every key to a LIVE row of
|
|
6
|
+
* the package SOT, so a codebook change (a row retired, renamed or re-parented)
|
|
7
|
+
* fails the build instead of silently orphaning copy.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
|
|
12
|
+
import { coreInformationScopeSot } from "../../cvcs/index.js";
|
|
13
|
+
import {
|
|
14
|
+
INFORMATION_SCOPE_CATEGORY_ORDER,
|
|
15
|
+
INFORMATION_SCOPE_CATEGORY_SUB,
|
|
16
|
+
INFORMATION_SCOPE_ROW_HINT,
|
|
17
|
+
INFORMATION_SCOPE_ROW_ORDER,
|
|
18
|
+
scopeCategorySub,
|
|
19
|
+
scopeRowDisplayOrder,
|
|
20
|
+
scopeRowHint,
|
|
21
|
+
sortScopeCategories,
|
|
22
|
+
sortScopeRows,
|
|
23
|
+
} from "../informationScope.js";
|
|
24
|
+
|
|
25
|
+
interface Entry {
|
|
26
|
+
key: string;
|
|
27
|
+
rowType?: string;
|
|
28
|
+
status?: string;
|
|
29
|
+
parentKey?: string | null;
|
|
30
|
+
childKeys?: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
const entries = (coreInformationScopeSot as unknown as { entries: readonly Entry[] }).entries;
|
|
33
|
+
const byKey = new Map(entries.map((e) => [e.key, e]));
|
|
34
|
+
const isLive = (k: string): boolean => {
|
|
35
|
+
const s = byKey.get(k)?.status;
|
|
36
|
+
return s === "as_today" || s === "new";
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A category's live rows from the SOT, through Screens & assessments' groupings. */
|
|
40
|
+
function liveRowsOf(category: string): string[] {
|
|
41
|
+
const out: string[] = [];
|
|
42
|
+
for (const c of byKey.get(category)?.childKeys ?? []) {
|
|
43
|
+
if (!isLive(c)) continue;
|
|
44
|
+
const e = byKey.get(c)!;
|
|
45
|
+
if (category === "instruments" && (e.childKeys?.length ?? 0) > 0) out.push(...liveRowsOf(c));
|
|
46
|
+
else out.push(c);
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const liveCategories = entries
|
|
52
|
+
.filter((e) => e.rowType === "category" && isLive(e.key))
|
|
53
|
+
.map((e) => e.key);
|
|
54
|
+
|
|
55
|
+
describe("information-scope UI copy — keys are live CVC-236 rows", () => {
|
|
56
|
+
it("lists every live category exactly once", () => {
|
|
57
|
+
const order = INFORMATION_SCOPE_CATEGORY_ORDER;
|
|
58
|
+
expect(new Set(order).size).toBe(order.length);
|
|
59
|
+
expect([...INFORMATION_SCOPE_CATEGORY_ORDER].sort()).toEqual([...liveCategories].sort());
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("gives every category a description and nothing else one", () => {
|
|
63
|
+
expect(Object.keys(INFORMATION_SCOPE_CATEGORY_SUB).sort()).toEqual([...liveCategories].sort());
|
|
64
|
+
for (const s of Object.values(INFORMATION_SCOPE_CATEGORY_SUB)) expect(s.trim()).not.toBe("");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("orders exactly each category's live rows", () => {
|
|
68
|
+
expect(Object.keys(INFORMATION_SCOPE_ROW_ORDER).sort()).toEqual([...liveCategories].sort());
|
|
69
|
+
for (const c of liveCategories) {
|
|
70
|
+
expect([...INFORMATION_SCOPE_ROW_ORDER[c]].sort(), c).toEqual(liveRowsOf(c).sort());
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("puts a hint only on a live row that a category orders", () => {
|
|
75
|
+
const ordered = new Set(Object.values(INFORMATION_SCOPE_ROW_ORDER).flat());
|
|
76
|
+
for (const [k, h] of Object.entries(INFORMATION_SCOPE_ROW_HINT)) {
|
|
77
|
+
expect(isLive(k), k).toBe(true);
|
|
78
|
+
expect(ordered.has(k), k).toBe(true);
|
|
79
|
+
expect(h.trim()).not.toBe("");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("information-scope UI copy — the prototype's words and order", () => {
|
|
85
|
+
it("carries the prototype's text", () => {
|
|
86
|
+
expect(scopeCategorySub("system")).toBe("Session timestamps, source info — always shared");
|
|
87
|
+
expect(scopeCategorySub("identifying")).toBe("Names, DOB, addresses, identifiers, demographics");
|
|
88
|
+
expect(scopeRowHint("system_info")).toBe("Always included");
|
|
89
|
+
expect(scopeRowHint("dob")).toBeUndefined();
|
|
90
|
+
expect(scopeCategorySub("no_such_category")).toBeUndefined();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("reads either spelling of a dotted row", () => {
|
|
94
|
+
expect(scopeRowHint("identifying.other")).toBe(scopeRowHint("identifying__other"));
|
|
95
|
+
expect(scopeRowHint("identifying.other")).toMatch(/^Living situation/);
|
|
96
|
+
expect(scopeCategorySub("offenders.contact")).toBe(scopeCategorySub("offenders__contact"));
|
|
97
|
+
expect(scopeRowDisplayOrder("offenders.contact")).toEqual(["offenders.safe_locations"]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("orders Narrative notes and Health & accommodation as canon does", () => {
|
|
101
|
+
expect(scopeRowDisplayOrder("notes")).toEqual(["session_summary", "case_notes"]);
|
|
102
|
+
expect(scopeRowDisplayOrder("health_accommodation")).toEqual(["health_status", "accommodation_needs"]);
|
|
103
|
+
expect(sortScopeRows("notes", ["case_notes", "session_summary"])).toEqual(["session_summary", "case_notes"]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("keeps unknown rows and categories last, in their own order", () => {
|
|
107
|
+
expect(sortScopeRows("notes", ["zz", "case_notes", "aa", "session_summary"])).toEqual([
|
|
108
|
+
"session_summary",
|
|
109
|
+
"case_notes",
|
|
110
|
+
"zz",
|
|
111
|
+
"aa",
|
|
112
|
+
]);
|
|
113
|
+
expect(sortScopeCategories(["object_identifiers", "zz", "offenders.risk", "system"])).toEqual([
|
|
114
|
+
"system",
|
|
115
|
+
"offenders.risk",
|
|
116
|
+
"object_identifiers",
|
|
117
|
+
"zz",
|
|
118
|
+
]);
|
|
119
|
+
expect(scopeRowDisplayOrder("no_such_category")).toEqual([]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("lists Screens & assessments as Summary rows then Full rows", () => {
|
|
123
|
+
const order = scopeRowDisplayOrder("instruments");
|
|
124
|
+
expect(order).toHaveLength(28);
|
|
125
|
+
expect(order.slice(0, 14).every((r) => r.startsWith("summary_"))).toBe(true);
|
|
126
|
+
expect(order.slice(14).every((r) => r.startsWith("full_"))).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @htilabs/platform-common-models — CVC-236 Information Scope page: UI copy + row order
|
|
3
|
+
*
|
|
4
|
+
* The words and order the prototype's Information scope page draws that the
|
|
5
|
+
* CVC-236 SOT (`coreInformationScopeSot`) does not carry:
|
|
6
|
+
*
|
|
7
|
+
* - a category's one-line description under its title (`scopeCategorySub`),
|
|
8
|
+
* - the hint line under some rows (`scopeRowHint`),
|
|
9
|
+
* - the rows of a category in canon's order (`scopeRowDisplayOrder`,
|
|
10
|
+
* `sortScopeRows`) — the SOT lists a category's children in code order,
|
|
11
|
+
* which differs from canon's tree order in Narrative notes and Health &
|
|
12
|
+
* accommodation.
|
|
13
|
+
*
|
|
14
|
+
* The data is GENERATED (`src/generated/informationScopeUiCopy.ts`, by
|
|
15
|
+
* `scripts/gen-information-scope-ui-copy.py`): order from the records
|
|
16
|
+
* repo's CVC-236 tree, words from the Platform prototype's
|
|
17
|
+
* `sharing.scopeCatalog` (`sub` / `hint`). Text is carried as written there.
|
|
18
|
+
*
|
|
19
|
+
* Every function takes either spelling of a row: the package key
|
|
20
|
+
* (`offenders__contact`) or the selection code (`offenders.contact`).
|
|
21
|
+
* Additive: nothing that reads the SOT changes.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
INFORMATION_SCOPE_CATEGORY_ORDER,
|
|
26
|
+
INFORMATION_SCOPE_CATEGORY_SUB,
|
|
27
|
+
INFORMATION_SCOPE_ROW_HINT,
|
|
28
|
+
INFORMATION_SCOPE_ROW_ORDER,
|
|
29
|
+
INFORMATION_SCOPE_UI_COPY_SOURCE,
|
|
30
|
+
} from "../generated/informationScopeUiCopy.js";
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
INFORMATION_SCOPE_CATEGORY_ORDER,
|
|
34
|
+
INFORMATION_SCOPE_CATEGORY_SUB,
|
|
35
|
+
INFORMATION_SCOPE_ROW_HINT,
|
|
36
|
+
INFORMATION_SCOPE_ROW_ORDER,
|
|
37
|
+
INFORMATION_SCOPE_UI_COPY_SOURCE,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const own = (o: object, k: string): boolean => Object.prototype.hasOwnProperty.call(o, k);
|
|
41
|
+
|
|
42
|
+
/** A selection code or package key → its package key (`.` spelled `__`). */
|
|
43
|
+
function toKey(codeOrKey: string): string {
|
|
44
|
+
return codeOrKey.replace(/\./g, "__");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A package key → its selection code (`__` read as `.`). */
|
|
48
|
+
function toCode(key: string): string {
|
|
49
|
+
return key.replace(/__/g, ".");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The one-line description under a category's title, or `undefined`. */
|
|
53
|
+
export function scopeCategorySub(category: string): string | undefined {
|
|
54
|
+
const k = toKey(category);
|
|
55
|
+
return own(INFORMATION_SCOPE_CATEGORY_SUB, k) ? INFORMATION_SCOPE_CATEGORY_SUB[k] : undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The hint line under a row, or `undefined` when the row has none. */
|
|
59
|
+
export function scopeRowHint(row: string): string | undefined {
|
|
60
|
+
const k = toKey(row);
|
|
61
|
+
return own(INFORMATION_SCOPE_ROW_HINT, k) ? INFORMATION_SCOPE_ROW_HINT[k] : undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A category's live rows in canon's order, as selection codes
|
|
66
|
+
* (`identifying.other`, `offenders.safe_locations`). Empty for an unknown
|
|
67
|
+
* category or one with no rows. For Screens & assessments: the Summary &
|
|
68
|
+
* outcome rows, then the Full rows, each in instrument order.
|
|
69
|
+
*/
|
|
70
|
+
export function scopeRowDisplayOrder(category: string): readonly string[] {
|
|
71
|
+
const k = toKey(category);
|
|
72
|
+
return own(INFORMATION_SCOPE_ROW_ORDER, k) ? INFORMATION_SCOPE_ROW_ORDER[k].map(toCode) : [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* `rows` (either spelling, returned as given) sorted into canon's order for
|
|
77
|
+
* `category`. Rows the order does not name keep their relative order and
|
|
78
|
+
* come last. Does not modify `rows`.
|
|
79
|
+
*/
|
|
80
|
+
export function sortScopeRows<T extends string>(category: string, rows: readonly T[]): T[] {
|
|
81
|
+
const k = toKey(category);
|
|
82
|
+
const order = own(INFORMATION_SCOPE_ROW_ORDER, k) ? INFORMATION_SCOPE_ROW_ORDER[k] : [];
|
|
83
|
+
const rank = new Map(order.map((r, i) => [r, i]));
|
|
84
|
+
return rows
|
|
85
|
+
.map((r, i) => ({ r, i, at: rank.get(toKey(r)) ?? order.length }))
|
|
86
|
+
.sort((a, b) => a.at - b.at || a.i - b.i)
|
|
87
|
+
.map((x) => x.r);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** `categories` (either spelling, returned as given) in canon's order; unknown last. */
|
|
91
|
+
export function sortScopeCategories<T extends string>(categories: readonly T[]): T[] {
|
|
92
|
+
const rank = new Map(INFORMATION_SCOPE_CATEGORY_ORDER.map((c, i) => [c, i]));
|
|
93
|
+
const n = INFORMATION_SCOPE_CATEGORY_ORDER.length;
|
|
94
|
+
return categories
|
|
95
|
+
.map((c, i) => ({ c, i, at: rank.get(toKey(c)) ?? n }))
|
|
96
|
+
.sort((a, b) => a.at - b.at || a.i - b.i)
|
|
97
|
+
.map((x) => x.c);
|
|
98
|
+
}
|