@htilabs/platform-common-models 0.81.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.
Files changed (36) hide show
  1. package/README.md +10 -0
  2. package/dist/{index-uz57Fic9.d.ts → index-Bh1zO_Vu.d.ts} +1 -1
  3. package/dist/{index-1pWiqEBC.d.cts → index-XWSYon40.d.cts} +1 -1
  4. package/dist/index.cjs +332 -44
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +4 -4
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.js +322 -44
  9. package/dist/index.js.map +1 -1
  10. package/dist/information-scope/index.cjs +290 -2
  11. package/dist/information-scope/index.cjs.map +1 -1
  12. package/dist/information-scope/index.d.cts +84 -1
  13. package/dist/information-scope/index.d.ts +84 -1
  14. package/dist/information-scope/index.js +279 -1
  15. package/dist/information-scope/index.js.map +1 -1
  16. package/dist/models/index.d.cts +2 -2
  17. package/dist/models/index.d.ts +2 -2
  18. package/dist/schemas/index.d.cts +25 -25
  19. package/dist/schemas/index.d.ts +25 -25
  20. package/dist/services/index.cjs +290 -2
  21. package/dist/services/index.cjs.map +1 -1
  22. package/dist/services/index.d.cts +1 -1
  23. package/dist/services/index.d.ts +1 -1
  24. package/dist/services/index.js +279 -1
  25. package/dist/services/index.js.map +1 -1
  26. package/dist/validation/index.d.cts +1 -1
  27. package/dist/validation/index.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/src/generated/informationScopeUiCopy.ts +263 -0
  30. package/src/services/__tests__/informationScopeUiCopy.test.ts +128 -0
  31. package/src/services/informationScope.ts +1 -0
  32. package/src/services/informationScopeUiCopy.ts +98 -0
  33. package/dist/{agency-Djp57S71.d.cts → agency-8ufZJJDH.d.cts} +4 -4
  34. package/dist/{agency-BHv54o79.d.ts → agency-CnVTwLeV.d.ts} +4 -4
  35. package/dist/{cvcEntry-DAuhe0cd.d.cts → cvcEntry-D787utvP.d.cts} +8 -8
  36. package/dist/{cvcEntry-DAuhe0cd.d.ts → cvcEntry-D787utvP.d.ts} +8 -8
@@ -1,4 +1,4 @@
1
- export { A as AgencyOrgTypeFieldsInput, a as AgencyOrgTypeFieldsSchema, b as AgencyTypeKeyInput, c as AgencyTypeKeySchema, C as CvcCode, d as CvcCodeSchema, e as CvcDomain, t as CvcEntry, f as CvcEntrySchema, g as CvcEnvelope, h as CvcEnvelopeSchema, i as CvcKey, j as CvcKeySchema, u as CvcValidationError, O as OrgTypeFieldsSchema, k as OrgTypeSelectableKeyInput, l as OrgTypeSelectableKeySchema, P as PrimaryLanguageEntry, v as PrimaryLanguageEntrySchema, S as ServiceCategoryEntry, m as ServiceCategoryEntrySchema, n as SetOrgTypeInput, o as SetOrgTypeInputSchema, T as TeamApp, p as TeamAppSchema, q as TeamDirectoryFieldsInput, r as TeamDirectoryFieldsSchema, x as getCvcLevel, s as orgTypeFieldsShape, y as validateCvc, w as withOrgTypeFields } from '../agency-Djp57S71.cjs';
1
+ export { A as AgencyOrgTypeFieldsInput, a as AgencyOrgTypeFieldsSchema, b as AgencyTypeKeyInput, c as AgencyTypeKeySchema, C as CvcCode, d as CvcCodeSchema, e as CvcDomain, t as CvcEntry, f as CvcEntrySchema, g as CvcEnvelope, h as CvcEnvelopeSchema, i as CvcKey, j as CvcKeySchema, u as CvcValidationError, O as OrgTypeFieldsSchema, k as OrgTypeSelectableKeyInput, l as OrgTypeSelectableKeySchema, P as PrimaryLanguageEntry, v as PrimaryLanguageEntrySchema, S as ServiceCategoryEntry, m as ServiceCategoryEntrySchema, n as SetOrgTypeInput, o as SetOrgTypeInputSchema, T as TeamApp, p as TeamAppSchema, q as TeamDirectoryFieldsInput, r as TeamDirectoryFieldsSchema, x as getCvcLevel, s as orgTypeFieldsShape, y as validateCvc, w as withOrgTypeFields } from '../agency-8ufZJJDH.cjs';
2
2
  export { V as VSP_TWO_STEP_ISSUE, v as vspTwoStepHolds } from '../agency-BXvE4yWu.cjs';
3
3
  import 'zod';
4
4
  import '../org-type-D_FG4KdN.cjs';
@@ -1,4 +1,4 @@
1
- export { A as AgencyOrgTypeFieldsInput, a as AgencyOrgTypeFieldsSchema, b as AgencyTypeKeyInput, c as AgencyTypeKeySchema, C as CvcCode, d as CvcCodeSchema, e as CvcDomain, t as CvcEntry, f as CvcEntrySchema, g as CvcEnvelope, h as CvcEnvelopeSchema, i as CvcKey, j as CvcKeySchema, u as CvcValidationError, O as OrgTypeFieldsSchema, k as OrgTypeSelectableKeyInput, l as OrgTypeSelectableKeySchema, P as PrimaryLanguageEntry, v as PrimaryLanguageEntrySchema, S as ServiceCategoryEntry, m as ServiceCategoryEntrySchema, n as SetOrgTypeInput, o as SetOrgTypeInputSchema, T as TeamApp, p as TeamAppSchema, q as TeamDirectoryFieldsInput, r as TeamDirectoryFieldsSchema, x as getCvcLevel, s as orgTypeFieldsShape, y as validateCvc, w as withOrgTypeFields } from '../agency-BHv54o79.js';
1
+ export { A as AgencyOrgTypeFieldsInput, a as AgencyOrgTypeFieldsSchema, b as AgencyTypeKeyInput, c as AgencyTypeKeySchema, C as CvcCode, d as CvcCodeSchema, e as CvcDomain, t as CvcEntry, f as CvcEntrySchema, g as CvcEnvelope, h as CvcEnvelopeSchema, i as CvcKey, j as CvcKeySchema, u as CvcValidationError, O as OrgTypeFieldsSchema, k as OrgTypeSelectableKeyInput, l as OrgTypeSelectableKeySchema, P as PrimaryLanguageEntry, v as PrimaryLanguageEntrySchema, S as ServiceCategoryEntry, m as ServiceCategoryEntrySchema, n as SetOrgTypeInput, o as SetOrgTypeInputSchema, T as TeamApp, p as TeamAppSchema, q as TeamDirectoryFieldsInput, r as TeamDirectoryFieldsSchema, x as getCvcLevel, s as orgTypeFieldsShape, y as validateCvc, w as withOrgTypeFields } from '../agency-CnVTwLeV.js';
2
2
  export { V as VSP_TWO_STEP_ISSUE, v as vspTwoStepHolds } from '../agency-NEW6NOGD.js';
3
3
  import 'zod';
4
4
  import '../org-type-BYQb9Qzq.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htilabs/platform-common-models",
3
- "version": "0.81.0",
3
+ "version": "0.82.0",
4
4
  "description": "Shared constants, types, and models for HTI Labs applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -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
+ });
@@ -8,3 +8,4 @@
8
8
 
9
9
  export * from "./informationScopeResolver.js";
10
10
  export * from "./informationScopeSot.js";
11
+ export * from "./informationScopeUiCopy.js";
@@ -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
+ }
@@ -199,8 +199,6 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
199
199
  definition: z.ZodNullable<z.ZodString>;
200
200
  }, z.ZodTypeAny, "passthrough">>, "many">;
201
201
  }, "strip", z.ZodTypeAny, {
202
- name: string;
203
- version: string;
204
202
  entries: z.objectOutputType<{
205
203
  code: z.ZodString;
206
204
  key: z.ZodString;
@@ -210,11 +208,11 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
210
208
  childCodes: z.ZodArray<z.ZodString, "many">;
211
209
  definition: z.ZodNullable<z.ZodString>;
212
210
  }, z.ZodTypeAny, "passthrough">[];
211
+ name: string;
212
+ version: string;
213
213
  domain: string;
214
214
  levels: Record<string, string>;
215
215
  }, {
216
- name: string;
217
- version: string;
218
216
  entries: z.objectInputType<{
219
217
  code: z.ZodString;
220
218
  key: z.ZodString;
@@ -224,6 +222,8 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
224
222
  childCodes: z.ZodArray<z.ZodString, "many">;
225
223
  definition: z.ZodNullable<z.ZodString>;
226
224
  }, z.ZodTypeAny, "passthrough">[];
225
+ name: string;
226
+ version: string;
227
227
  domain: string;
228
228
  levels: Record<string, string>;
229
229
  }>;
@@ -199,8 +199,6 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
199
199
  definition: z.ZodNullable<z.ZodString>;
200
200
  }, z.ZodTypeAny, "passthrough">>, "many">;
201
201
  }, "strip", z.ZodTypeAny, {
202
- name: string;
203
- version: string;
204
202
  entries: z.objectOutputType<{
205
203
  code: z.ZodString;
206
204
  key: z.ZodString;
@@ -210,11 +208,11 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
210
208
  childCodes: z.ZodArray<z.ZodString, "many">;
211
209
  definition: z.ZodNullable<z.ZodString>;
212
210
  }, z.ZodTypeAny, "passthrough">[];
211
+ name: string;
212
+ version: string;
213
213
  domain: string;
214
214
  levels: Record<string, string>;
215
215
  }, {
216
- name: string;
217
- version: string;
218
216
  entries: z.objectInputType<{
219
217
  code: z.ZodString;
220
218
  key: z.ZodString;
@@ -224,6 +222,8 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
224
222
  childCodes: z.ZodArray<z.ZodString, "many">;
225
223
  definition: z.ZodNullable<z.ZodString>;
226
224
  }, z.ZodTypeAny, "passthrough">[];
225
+ name: string;
226
+ version: string;
227
227
  domain: string;
228
228
  levels: Record<string, string>;
229
229
  }>;
@@ -199,20 +199,20 @@ type Form = InferRawDocType<typeof _formSchema>;
199
199
  declare const sectionQuestionRefSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
200
200
  _id: false;
201
201
  }, {
202
- index: number;
203
202
  questionId: string;
203
+ index: number;
204
204
  questionVersion: string;
205
205
  }, mongoose.Document<unknown, {}, {
206
- index: number;
207
206
  questionId: string;
207
+ index: number;
208
208
  questionVersion: string;
209
209
  }, {
210
210
  id: string;
211
211
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
212
212
  _id: false;
213
213
  }>> & Omit<{
214
- index: number;
215
214
  questionId: string;
215
+ index: number;
216
216
  questionVersion: string;
217
217
  } & {
218
218
  _id: mongoose.Types.ObjectId;
@@ -221,8 +221,8 @@ declare const sectionQuestionRefSchema: Schema<any, mongoose.Model<any, any, any
221
221
  }, "id"> & {
222
222
  id: string;
223
223
  }, unknown, {
224
- index: number;
225
224
  questionId: string;
225
+ index: number;
226
226
  questionVersion: string;
227
227
  } & {
228
228
  _id: mongoose.Types.ObjectId;
@@ -326,20 +326,20 @@ declare const sectionSchemaDefinition: {
326
326
  type: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
327
327
  _id: false;
328
328
  }, {
329
- index: number;
330
329
  questionId: string;
330
+ index: number;
331
331
  questionVersion: string;
332
332
  }, mongoose.Document<unknown, {}, {
333
- index: number;
334
333
  questionId: string;
334
+ index: number;
335
335
  questionVersion: string;
336
336
  }, {
337
337
  id: string;
338
338
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
339
339
  _id: false;
340
340
  }>> & Omit<{
341
- index: number;
342
341
  questionId: string;
342
+ index: number;
343
343
  questionVersion: string;
344
344
  } & {
345
345
  _id: mongoose.Types.ObjectId;
@@ -348,8 +348,8 @@ declare const sectionSchemaDefinition: {
348
348
  }, "id"> & {
349
349
  id: string;
350
350
  }, unknown, {
351
- index: number;
352
351
  questionId: string;
352
+ index: number;
353
353
  questionVersion: string;
354
354
  } & {
355
355
  _id: mongoose.Types.ObjectId;