@htilabs/platform-common-models 0.22.0 → 0.23.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/dist/authz/index.cjs +539 -0
- package/dist/authz/index.cjs.map +1 -0
- package/dist/authz/index.d.cts +210 -0
- package/dist/authz/index.d.ts +210 -0
- package/dist/authz/index.js +507 -0
- package/dist/authz/index.js.map +1 -0
- package/dist/constants/index.d.cts +2 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/cvcs/index.cjs +647 -353
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +658 -362
- package/dist/cvcs/index.d.ts +658 -362
- package/dist/cvcs/index.js +647 -353
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs +1 -9
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +7 -15
- package/dist/enums/index.d.ts +7 -15
- package/dist/enums/index.js +1 -9
- package/dist/enums/index.js.map +1 -1
- package/dist/{platform-auth-CvAYFVhK.d.cts → ic-DpKrdgQP.d.cts} +1 -78
- package/dist/{platform-auth-CvAYFVhK.d.ts → ic-DpKrdgQP.d.ts} +1 -78
- package/dist/index.cjs +899 -362
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +893 -362
- package/dist/index.js.map +1 -1
- package/dist/platform-auth-B49Ly57B.d.cts +78 -0
- package/dist/platform-auth-B49Ly57B.d.ts +78 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +6 -1
- package/src/__sot__/README.md +3 -1
- package/src/__sot__/adminRoles.pin.json +122 -0
- package/src/__sot__/adminRoles.published.json +77 -0
- package/src/__sot__/coreFunctionFields.ts +16 -0
- package/src/__sot__/coreFunctions.pin.json +114 -1
- package/src/__sot__/roleFields.ts +137 -0
- package/src/__sot__/userRoles.pin.json +174 -0
- package/src/__sot__/userRoles.published.json +103 -0
- package/src/__tests__/__snapshots__/cvc-sot.snap +5 -5
- package/src/__tests__/admin-roles-canon.test.ts +80 -0
- package/src/__tests__/authz-resolve.test.ts +712 -0
- package/src/__tests__/core-functions-canon.test.ts +62 -12
- package/src/__tests__/cvc-sot-snapshot.test.ts +12 -4
- package/src/__tests__/cvc-status-parser.test.ts +1 -1
- package/src/__tests__/cvc-structural.test.ts +3 -3
- package/src/__tests__/role-vocab-gate.ts +279 -0
- package/src/__tests__/user-roles-canon.test.ts +104 -0
- package/src/authz/index.ts +9 -0
- package/src/authz/resolveEffectiveFunctions.ts +454 -0
- package/src/cvcs/adminRoles.v2.0.0.json +197 -0
- package/src/cvcs/{coreFunctions.v1.2.0.json → coreFunctions.v1.3.0.json} +357 -200
- package/src/cvcs/index.ts +3 -3
- package/src/cvcs/userRoles.v2.0.0.json +296 -0
- package/src/generated/coreFunctionsEvaluable.ts +101 -0
- package/src/generated/cvc-enums.ts +7 -15
- package/src/index.ts +4 -0
- package/src/cvcs/adminRoles.v1.0.0.json +0 -153
- package/src/cvcs/userRoles.v1.0.0.json +0 -203
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE FIELD HALF OF THE ROLE PINS (userRoles + adminRoles)
|
|
3
|
+
* ========================================================
|
|
4
|
+
*
|
|
5
|
+
* `userRoles.pin.json` and `adminRoles.pin.json` snapshot the two canonical
|
|
6
|
+
* role vocabularies in `htilabstech/prototype`:
|
|
7
|
+
*
|
|
8
|
+
* - CVC-135 `data/cvcs/core_user_role.yaml` — "THE SSOT for the platform's
|
|
9
|
+
* OPERATIONAL user role bundles" (the casework-capability axis);
|
|
10
|
+
* - CVC-134 `data/cvcs/core_admin_role.yaml` — the ADMINISTRATIVE /
|
|
11
|
+
* control-plane axis ("admin ≠ content visibility").
|
|
12
|
+
*
|
|
13
|
+
* The package's `src/cvcs/userRoles.v*.json` / `adminRoles.v*.json` are
|
|
14
|
+
* downstream of them: regenerated by `scripts/gen-user-roles.py` /
|
|
15
|
+
* `scripts/gen-admin-roles.py` (both thin configs of `scripts/role_vocab.py`),
|
|
16
|
+
* never hand-edited.
|
|
17
|
+
*
|
|
18
|
+
* Why a pin at all: both 1.0.0 files were hand-imported in 0.8.13 from the June
|
|
19
|
+
* Notion export and validated against themselves. They drifted the way CVC-133
|
|
20
|
+
* did (`coreFunctions.pin.json`, #202): canon re-keyed `hotline_op` to
|
|
21
|
+
* `crisis_response`, retitled PLT-ADM, rewrote most definitions and grew
|
|
22
|
+
* per-role fields (`reach`, `display_label`, …), and nothing failed. With these
|
|
23
|
+
* pins, GATE J (`user-roles-canon.test.ts`) and GATE K
|
|
24
|
+
* (`admin-roles-canon.test.ts`) assert on every PR that the shipped SOT restates
|
|
25
|
+
* every canon role and every projected field, and nothing canon does not carry;
|
|
26
|
+
* `sot:pins:check` detects when canon moves.
|
|
27
|
+
*
|
|
28
|
+
* The PROJECTION is every per-role field canon carries — the pin derivation
|
|
29
|
+
* REFUSES a canon field outside it, so a new canon field cannot be dropped
|
|
30
|
+
* silently (the same refusal the generators make). An absent field projects
|
|
31
|
+
* as `null`; the SOT omits it.
|
|
32
|
+
*
|
|
33
|
+
* Lives in `src/` (not `scripts/`) for the same tsconfig `rootDir` reason as
|
|
34
|
+
* `coreIndicatorFields.ts`.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
type FieldKind = "string" | "boolean" | "string[]";
|
|
38
|
+
|
|
39
|
+
/** What each projected canon field must be. `label` / `definition` are required; the rest are optional. */
|
|
40
|
+
const USER_ROLE_FIELD_KINDS = {
|
|
41
|
+
label: "string",
|
|
42
|
+
definition: "string",
|
|
43
|
+
display_label: "string",
|
|
44
|
+
platform_tools: "string[]",
|
|
45
|
+
flags: "string[]",
|
|
46
|
+
} as const satisfies Record<string, FieldKind>;
|
|
47
|
+
|
|
48
|
+
const ADMIN_ROLE_FIELD_KINDS = {
|
|
49
|
+
label: "string",
|
|
50
|
+
definition: "string",
|
|
51
|
+
display_label: "string",
|
|
52
|
+
required: "boolean",
|
|
53
|
+
required_when: "string",
|
|
54
|
+
reach: "string",
|
|
55
|
+
scope: "string",
|
|
56
|
+
plain_language: "string",
|
|
57
|
+
} as const satisfies Record<string, FieldKind>;
|
|
58
|
+
|
|
59
|
+
type Projected<K extends Record<string, FieldKind>> = {
|
|
60
|
+
readonly [F in keyof K]: F extends "label" | "definition"
|
|
61
|
+
? string
|
|
62
|
+
: K[F] extends "boolean"
|
|
63
|
+
? boolean | null
|
|
64
|
+
: K[F] extends "string[]"
|
|
65
|
+
? readonly string[] | null
|
|
66
|
+
: string | null;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type ProjectedUserRoleFields = Projected<typeof USER_ROLE_FIELD_KINDS>;
|
|
70
|
+
export type ProjectedAdminRoleFields = Projected<typeof ADMIN_ROLE_FIELD_KINDS>;
|
|
71
|
+
export type ProjectedRoleFields = ProjectedUserRoleFields | ProjectedAdminRoleFields;
|
|
72
|
+
|
|
73
|
+
export const PROJECTED_USER_ROLE_FIELDS = Object.keys(
|
|
74
|
+
USER_ROLE_FIELD_KINDS,
|
|
75
|
+
) as readonly (keyof ProjectedUserRoleFields)[];
|
|
76
|
+
export const PROJECTED_ADMIN_ROLE_FIELDS = Object.keys(
|
|
77
|
+
ADMIN_ROLE_FIELD_KINDS,
|
|
78
|
+
) as readonly (keyof ProjectedAdminRoleFields)[];
|
|
79
|
+
|
|
80
|
+
/** Collapse a yaml block scalar to one line — the generator's `flat()`. */
|
|
81
|
+
export function flattenDefinition(s: string): string {
|
|
82
|
+
return s.split(/\s+/).filter(Boolean).join(" ");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** snake_case canon field -> the SOT entry's camelCase field (the generator's `camel()`). */
|
|
86
|
+
export function sotFieldName(canonField: string): string {
|
|
87
|
+
return canonField.replace(/_([a-z])/g, (_, c: string) => c.toUpperCase());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function project<K extends Record<string, FieldKind>>(
|
|
91
|
+
kinds: K,
|
|
92
|
+
file: string,
|
|
93
|
+
row: Readonly<Record<string, unknown>>,
|
|
94
|
+
): Projected<K> {
|
|
95
|
+
const code = String(row["code"]);
|
|
96
|
+
const unknown = Object.keys(row).filter((k) => k !== "code" && !(k in kinds));
|
|
97
|
+
if (unknown.length > 0) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
`${file} row ${code}: unrecognized field(s) ${unknown.join(", ")} — extend the projection in ` +
|
|
100
|
+
"src/__sot__/roleFields.ts AND the generator config together (never drop a canon field silently).",
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const out: Record<string, unknown> = {};
|
|
104
|
+
for (const [field, kind] of Object.entries(kinds)) {
|
|
105
|
+
const v = row[field];
|
|
106
|
+
if (v === undefined || v === null) {
|
|
107
|
+
if (field === "label" || field === "definition") {
|
|
108
|
+
throw new Error(`${file} row ${code}: ${field} is missing`);
|
|
109
|
+
}
|
|
110
|
+
out[field] = null;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const ok =
|
|
114
|
+
kind === "string"
|
|
115
|
+
? typeof v === "string"
|
|
116
|
+
: kind === "boolean"
|
|
117
|
+
? typeof v === "boolean"
|
|
118
|
+
: Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
119
|
+
if (!ok) throw new Error(`${file} row ${code}: ${field} is not a ${kind}`);
|
|
120
|
+
out[field] = field === "definition" ? flattenDefinition(v as string) : v;
|
|
121
|
+
}
|
|
122
|
+
return out as Projected<K>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Project one canon CVC-135 row (a parsed `entries[]` item of core_user_role.yaml). */
|
|
126
|
+
export function projectUserRoleRow(
|
|
127
|
+
row: Readonly<Record<string, unknown>>,
|
|
128
|
+
): ProjectedUserRoleFields {
|
|
129
|
+
return project(USER_ROLE_FIELD_KINDS, "core_user_role.yaml", row);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Project one canon CVC-134 row (a parsed `entries[]` item of core_admin_role.yaml). */
|
|
133
|
+
export function projectAdminRoleRow(
|
|
134
|
+
row: Readonly<Record<string, unknown>>,
|
|
135
|
+
): ProjectedAdminRoleFields {
|
|
136
|
+
return project(ADMIN_ROLE_FIELD_KINDS, "core_admin_role.yaml", row);
|
|
137
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sourceRepo": "htilabstech/prototype",
|
|
3
|
+
"sourceFile": "data/cvcs/core_user_role.yaml",
|
|
4
|
+
"sourceSha": "d85f05b",
|
|
5
|
+
"codes": [
|
|
6
|
+
"behavioral_health_provider",
|
|
7
|
+
"case_nav",
|
|
8
|
+
"crisis_response",
|
|
9
|
+
"healthcare_provider_medical",
|
|
10
|
+
"intel_analyst",
|
|
11
|
+
"investigator",
|
|
12
|
+
"le_liaison_vsp",
|
|
13
|
+
"legal_advocate",
|
|
14
|
+
"mandatory_reporter",
|
|
15
|
+
"mdt_participant",
|
|
16
|
+
"prosecutor_review",
|
|
17
|
+
"public_reporter",
|
|
18
|
+
"research_analytics",
|
|
19
|
+
"screener",
|
|
20
|
+
"volunteer"
|
|
21
|
+
],
|
|
22
|
+
"roleFields": {
|
|
23
|
+
"behavioral_health_provider": {
|
|
24
|
+
"label": "Certified Mental/Behavioral Health Provider",
|
|
25
|
+
"definition": "Provides mental and behavioral healthcare services and documents therapeutic progress as part of the survivor's care plan (therapy / counselling). Scope access to clinically relevant information only.",
|
|
26
|
+
"display_label": "Behavioral Health Provider",
|
|
27
|
+
"platform_tools": [
|
|
28
|
+
"PAVE"
|
|
29
|
+
],
|
|
30
|
+
"flags": null
|
|
31
|
+
},
|
|
32
|
+
"case_nav": {
|
|
33
|
+
"label": "Case Navigator/Advocate",
|
|
34
|
+
"definition": "Provides ongoing service coordination, referrals, and case documentation within survivor-services workflows.",
|
|
35
|
+
"display_label": null,
|
|
36
|
+
"platform_tools": [
|
|
37
|
+
"PAVE"
|
|
38
|
+
],
|
|
39
|
+
"flags": null
|
|
40
|
+
},
|
|
41
|
+
"crisis_response": {
|
|
42
|
+
"label": "Crisis Response",
|
|
43
|
+
"definition": "Top-of-funnel intake role for hotline staff. Supports intake and routing workflows with tightly constrained visibility.",
|
|
44
|
+
"display_label": null,
|
|
45
|
+
"platform_tools": [
|
|
46
|
+
"Thread",
|
|
47
|
+
"PAVE"
|
|
48
|
+
],
|
|
49
|
+
"flags": null
|
|
50
|
+
},
|
|
51
|
+
"healthcare_provider_medical": {
|
|
52
|
+
"label": "Certified Healthcare Provider (Medical)",
|
|
53
|
+
"definition": "Provides medical evaluation and treatment and may document clinical observations supporting identification and care coordination, within MDT and sector constraints. Combines SANE/forensic nursing and general medical clinicians to avoid proliferating medical sub-roles.",
|
|
54
|
+
"display_label": "Healthcare Provider",
|
|
55
|
+
"platform_tools": [
|
|
56
|
+
"PAVE"
|
|
57
|
+
],
|
|
58
|
+
"flags": null
|
|
59
|
+
},
|
|
60
|
+
"intel_analyst": {
|
|
61
|
+
"label": "Intelligence Analyst",
|
|
62
|
+
"definition": "Analyzes intelligence, creates intelligence artifacts, and supports network mapping and risk scoring within CI governance rules.",
|
|
63
|
+
"display_label": null,
|
|
64
|
+
"platform_tools": [
|
|
65
|
+
"LEADS"
|
|
66
|
+
],
|
|
67
|
+
"flags": null
|
|
68
|
+
},
|
|
69
|
+
"investigator": {
|
|
70
|
+
"label": "Investigator",
|
|
71
|
+
"definition": "Law-enforcement investigator who triages leads, creates/claims investigations, collaborates, and performs deconfliction within policy constraints.",
|
|
72
|
+
"display_label": null,
|
|
73
|
+
"platform_tools": [
|
|
74
|
+
"LEADS"
|
|
75
|
+
],
|
|
76
|
+
"flags": null
|
|
77
|
+
},
|
|
78
|
+
"le_liaison_vsp": {
|
|
79
|
+
"label": "VSP LE Liaison",
|
|
80
|
+
"definition": "VSP-side liaison who coordinates communication with law enforcement only under survivor consent, statutory mandate, or documented legal exception. Distinct from MDT Participant (collaboration within a defined case context) and from Case Navigator/Advocate (services and documentation).",
|
|
81
|
+
"display_label": null,
|
|
82
|
+
"platform_tools": [
|
|
83
|
+
"PAVE",
|
|
84
|
+
"Thread"
|
|
85
|
+
],
|
|
86
|
+
"flags": null
|
|
87
|
+
},
|
|
88
|
+
"legal_advocate": {
|
|
89
|
+
"label": "Legal Advocate",
|
|
90
|
+
"definition": "Provides civil, criminal, and/or immigration legal support and documents legal strategy and case-related filings. Survivor-facing legal services, NOT a prosecutor role.",
|
|
91
|
+
"display_label": null,
|
|
92
|
+
"platform_tools": [
|
|
93
|
+
"PAVE"
|
|
94
|
+
],
|
|
95
|
+
"flags": null
|
|
96
|
+
},
|
|
97
|
+
"mandatory_reporter": {
|
|
98
|
+
"label": "Mandatory Reporter User",
|
|
99
|
+
"definition": "Authenticated external partner who submits mandatory reports/referrals with minimal follow-up visibility. Strictly submit-only.",
|
|
100
|
+
"display_label": null,
|
|
101
|
+
"platform_tools": [
|
|
102
|
+
"Thread",
|
|
103
|
+
"PAVE"
|
|
104
|
+
],
|
|
105
|
+
"flags": null
|
|
106
|
+
},
|
|
107
|
+
"mdt_participant": {
|
|
108
|
+
"label": "MDT Participant",
|
|
109
|
+
"definition": "Cross-sector collaboration participant who can coordinate on a defined case context without broad case browsing. Intentionally narrow: participation in a defined collaboration space, not a sector override.",
|
|
110
|
+
"display_label": null,
|
|
111
|
+
"platform_tools": [
|
|
112
|
+
"PAVE",
|
|
113
|
+
"LEADS",
|
|
114
|
+
"Thread"
|
|
115
|
+
],
|
|
116
|
+
"flags": null
|
|
117
|
+
},
|
|
118
|
+
"prosecutor_review": {
|
|
119
|
+
"label": "Prosecutorial Reviewer",
|
|
120
|
+
"definition": "Reviews authorized export packages and prosecution-ready materials; updates prosecutorial milestones when permitted. Package-scoped.",
|
|
121
|
+
"display_label": null,
|
|
122
|
+
"platform_tools": [
|
|
123
|
+
"LEADS"
|
|
124
|
+
],
|
|
125
|
+
"flags": null
|
|
126
|
+
},
|
|
127
|
+
"public_reporter": {
|
|
128
|
+
"label": "Public Reporter",
|
|
129
|
+
"definition": "Uncredentialed public reporter who submits a tip/referral with minimal follow-up visibility. Un-authenticated and one-way by default. Not to be conflated with Mandatory Reporter, which is an authenticated partner role.",
|
|
130
|
+
"display_label": null,
|
|
131
|
+
"platform_tools": [
|
|
132
|
+
"Thread"
|
|
133
|
+
],
|
|
134
|
+
"flags": null
|
|
135
|
+
},
|
|
136
|
+
"research_analytics": {
|
|
137
|
+
"label": "Research/Analytics",
|
|
138
|
+
"definition": "Uses de-identified datasets and approved aggregate views for analytics and reporting. HTI-only platform-set role; strictly de-identified / aggregate-only by default. Not a member agency role.",
|
|
139
|
+
"display_label": null,
|
|
140
|
+
"platform_tools": [
|
|
141
|
+
"Platform",
|
|
142
|
+
"Echo"
|
|
143
|
+
],
|
|
144
|
+
"flags": [
|
|
145
|
+
"HTI-only"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"screener": {
|
|
149
|
+
"label": "Screener (Initial Screen)",
|
|
150
|
+
"definition": "Performs intake and initial screening and records indicators/risk flags. Does not perform formal determinations — NEVER-bound for that function — unless the person also holds a second role that grants it.",
|
|
151
|
+
"display_label": null,
|
|
152
|
+
"platform_tools": [
|
|
153
|
+
"PAVE",
|
|
154
|
+
"Thread"
|
|
155
|
+
],
|
|
156
|
+
"flags": null
|
|
157
|
+
},
|
|
158
|
+
"volunteer": {
|
|
159
|
+
"label": "Volunteer",
|
|
160
|
+
"definition": "Volunteer performing hotline/intake support work under supervision. Modelled as \"hotline volunteer\", not \"general volunteer\": intake creation + routing only, with no downstream casework authority.",
|
|
161
|
+
"display_label": null,
|
|
162
|
+
"platform_tools": [
|
|
163
|
+
"Thread",
|
|
164
|
+
"PAVE"
|
|
165
|
+
],
|
|
166
|
+
"flags": null
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"legacyCodes": {
|
|
170
|
+
"case_advocate": "case_nav",
|
|
171
|
+
"hotline_op": "crisis_response",
|
|
172
|
+
"leads_investigator": "investigator"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_note": "Every key @htilabs/platform-common-models has ever published for user_roles (CVC-135), with its segment-1 prefix. APPEND-ONLY: a published code never moves or changes meaning. A canon re-key (legacy_codes, old key published) moves the KEY onto the same prefix and is recorded under `renamed`; a canon legacy code this package never published is recorded under `aliases`; a withdrawn code is recorded under `retired` and never reused. Written by scripts/gen-user-roles.py; read by it and by GATE J (src/__tests__/user-roles-canon.test.ts). Do not hand-edit.",
|
|
3
|
+
"prefixes": {
|
|
4
|
+
"case_nav": 1,
|
|
5
|
+
"healthcare_provider_medical": 2,
|
|
6
|
+
"behavioral_health_provider": 3,
|
|
7
|
+
"crisis_response": 4,
|
|
8
|
+
"intel_analyst": 5,
|
|
9
|
+
"investigator": 6,
|
|
10
|
+
"le_liaison_vsp": 7,
|
|
11
|
+
"legal_advocate": 8,
|
|
12
|
+
"mandatory_reporter": 9,
|
|
13
|
+
"mdt_participant": 10,
|
|
14
|
+
"prosecutor_review": 11,
|
|
15
|
+
"public_reporter": 12,
|
|
16
|
+
"research_analytics": 13,
|
|
17
|
+
"screener": 14,
|
|
18
|
+
"volunteer": 15
|
|
19
|
+
},
|
|
20
|
+
"since": {
|
|
21
|
+
"case_nav": "1.0.0",
|
|
22
|
+
"healthcare_provider_medical": "1.0.0",
|
|
23
|
+
"behavioral_health_provider": "1.0.0",
|
|
24
|
+
"crisis_response": "2.0.0",
|
|
25
|
+
"intel_analyst": "1.0.0",
|
|
26
|
+
"investigator": "1.0.0",
|
|
27
|
+
"le_liaison_vsp": "1.0.0",
|
|
28
|
+
"legal_advocate": "1.0.0",
|
|
29
|
+
"mandatory_reporter": "1.0.0",
|
|
30
|
+
"mdt_participant": "1.0.0",
|
|
31
|
+
"prosecutor_review": "1.0.0",
|
|
32
|
+
"public_reporter": "1.0.0",
|
|
33
|
+
"research_analytics": "1.0.0",
|
|
34
|
+
"screener": "1.0.0",
|
|
35
|
+
"volunteer": "1.0.0"
|
|
36
|
+
},
|
|
37
|
+
"renamed": {
|
|
38
|
+
"hotline_op": {
|
|
39
|
+
"to": "crisis_response",
|
|
40
|
+
"prefix": 4,
|
|
41
|
+
"version": "2.0.0"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"aliases": {
|
|
45
|
+
"case_advocate": {
|
|
46
|
+
"to": "case_nav",
|
|
47
|
+
"canonical": "case_advocate",
|
|
48
|
+
"version": "2.0.0"
|
|
49
|
+
},
|
|
50
|
+
"leads_investigator": {
|
|
51
|
+
"to": "investigator",
|
|
52
|
+
"canonical": "leads_investigator",
|
|
53
|
+
"version": "2.0.0"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"retired": {
|
|
57
|
+
"missingness_root": {
|
|
58
|
+
"code": "135-000-000-000-000-000-000",
|
|
59
|
+
"successor": null,
|
|
60
|
+
"reason": "missingness (canon G3)",
|
|
61
|
+
"version": "2.0.0"
|
|
62
|
+
},
|
|
63
|
+
"unknown": {
|
|
64
|
+
"code": "135-000-000-000-000-000-001",
|
|
65
|
+
"successor": null,
|
|
66
|
+
"reason": "missingness (canon G3)",
|
|
67
|
+
"version": "2.0.0"
|
|
68
|
+
},
|
|
69
|
+
"anonymous": {
|
|
70
|
+
"code": "135-000-000-000-000-000-002",
|
|
71
|
+
"successor": null,
|
|
72
|
+
"reason": "missingness (canon G3)",
|
|
73
|
+
"version": "2.0.0"
|
|
74
|
+
},
|
|
75
|
+
"data_not_collected": {
|
|
76
|
+
"code": "135-000-000-000-000-000-003",
|
|
77
|
+
"successor": null,
|
|
78
|
+
"reason": "missingness (canon G3)",
|
|
79
|
+
"version": "2.0.0"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"supersededKeys": [
|
|
83
|
+
"missingness_root",
|
|
84
|
+
"unknown",
|
|
85
|
+
"anonymous",
|
|
86
|
+
"data_not_collected",
|
|
87
|
+
"case_nav",
|
|
88
|
+
"healthcare_provider_medical",
|
|
89
|
+
"behavioral_health_provider",
|
|
90
|
+
"hotline_op",
|
|
91
|
+
"intel_analyst",
|
|
92
|
+
"investigator",
|
|
93
|
+
"le_liaison_vsp",
|
|
94
|
+
"legal_advocate",
|
|
95
|
+
"mandatory_reporter",
|
|
96
|
+
"mdt_participant",
|
|
97
|
+
"prosecutor_review",
|
|
98
|
+
"public_reporter",
|
|
99
|
+
"research_analytics",
|
|
100
|
+
"screener",
|
|
101
|
+
"volunteer"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
@@ -576,7 +576,7 @@
|
|
|
576
576
|
},
|
|
577
577
|
"core_functions": {
|
|
578
578
|
"count": 117,
|
|
579
|
-
"hash": "
|
|
579
|
+
"hash": "1f932b9b4900bc3870dee8c64fbd4cb4850ef5cbbcebaff4b330936e494f17c5"
|
|
580
580
|
},
|
|
581
581
|
"needs_assessment_change_type": {
|
|
582
582
|
"count": 13,
|
|
@@ -607,12 +607,12 @@
|
|
|
607
607
|
"hash": "fc28328eb2b77e69c2a0d3a64add6de290687376506b053363756564d510448d"
|
|
608
608
|
},
|
|
609
609
|
"admin_roles": {
|
|
610
|
-
"count":
|
|
611
|
-
"hash": "
|
|
610
|
+
"count": 10,
|
|
611
|
+
"hash": "f3000985fe507e64491dacb7a25fdfa7045843ace63e01c0b7a4e74e1629ab72"
|
|
612
612
|
},
|
|
613
613
|
"user_roles": {
|
|
614
|
-
"count":
|
|
615
|
-
"hash": "
|
|
614
|
+
"count": 15,
|
|
615
|
+
"hash": "ee89f996112d450e5b766b582b7279b8860db62a6278b54e44f351748ed2194d"
|
|
616
616
|
},
|
|
617
617
|
"hmis_current_living_situation": {
|
|
618
618
|
"count": 33,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADMIN ROLES (CVC-134) — GATE K: the SOT restates canon, whole
|
|
3
|
+
* ==============================================================
|
|
4
|
+
*
|
|
5
|
+
* `src/cvcs/adminRoles.v2.0.0.json` is GENERATED from the canonical CVC-134
|
|
6
|
+
* codeset (`htilabstech/prototype` `data/cvcs/core_admin_role.yaml`) by
|
|
7
|
+
* `scripts/gen-admin-roles.py`. Hermetic enforcer against
|
|
8
|
+
* `src/__sot__/adminRoles.pin.json`; `npm run sot:pins:check` detects when
|
|
9
|
+
* canon moves. The shared contract lives in `role-vocab-gate.ts` (GATE J,
|
|
10
|
+
* CVC-135, asserts the same one); this file adds the CVC-134 specifics.
|
|
11
|
+
*
|
|
12
|
+
* History it closes: the 1.0.0 file was hand-imported in 0.8.13 from the June
|
|
13
|
+
* Notion export and validated against itself. Against canon it carried a stale
|
|
14
|
+
* PLT-ADM title, a stale definition on all 10 roles, a null TRAIN-ADM
|
|
15
|
+
* definition, none of canon's per-role fields (`reach`, `display_label`, …) and
|
|
16
|
+
* no reading for canon's legacy code ACCT-ADM.
|
|
17
|
+
*/
|
|
18
|
+
import { describe, it, expect } from "vitest";
|
|
19
|
+
|
|
20
|
+
import { AdminRoleKeys } from "../generated/cvc-enums.js";
|
|
21
|
+
import { adminRolesSot } from "../cvcs/index.js";
|
|
22
|
+
import { describeRoleVocabGate, loadRoleVocab, resolveStoredKey, type RoleGateConfig } from "./role-vocab-gate.js";
|
|
23
|
+
|
|
24
|
+
const cfg: RoleGateConfig = {
|
|
25
|
+
gate: "GATE K",
|
|
26
|
+
domain: "admin_roles",
|
|
27
|
+
prefix: "134",
|
|
28
|
+
stem: "adminRoles",
|
|
29
|
+
version: "2.0.0",
|
|
30
|
+
supersededVersion: "1.0.0",
|
|
31
|
+
canonFile: "data/cvcs/core_admin_role.yaml",
|
|
32
|
+
roleCount: 10,
|
|
33
|
+
keyOf: (code) => code.toLowerCase().replace(/-/g, "_"),
|
|
34
|
+
keys: AdminRoleKeys,
|
|
35
|
+
barrel: adminRolesSot,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describeRoleVocabGate(cfg);
|
|
39
|
+
|
|
40
|
+
describe("admin_roles — GATE K: CVC-134 specifics", () => {
|
|
41
|
+
const { sot, ledger } = loadRoleVocab(cfg);
|
|
42
|
+
const byKey = new Map(sot.entries.map((e) => [e.key, e] as const));
|
|
43
|
+
|
|
44
|
+
it("every 1.0.0 role key and code is unchanged (no re-key)", () => {
|
|
45
|
+
expect(ledger.renamed).toEqual({});
|
|
46
|
+
expect(Object.entries(AdminRoleKeys)).toEqual(
|
|
47
|
+
["plt_adm", "plt_sup", "mem_adm", "team_adm", "aud", "data_adm", "gov_aud", "ciro", "sup", "train_adm"].map(
|
|
48
|
+
(k, i) => [k, `134-${String(i + 1).padStart(3, "0")}-000-000-000-000-000`],
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("aliases canon's legacy ACCT-ADM to mem_adm (never a CVC-134 code nor a key of this package)", () => {
|
|
54
|
+
expect(ledger.aliases).toEqual({ acct_adm: { to: "mem_adm", canonical: "ACCT-ADM", version: "2.0.0" } });
|
|
55
|
+
// keyMap is key-space (the package convention); canon's spelling resolves after the key rule.
|
|
56
|
+
expect(sot._supersedes.keyMap["acct_adm"]).toBe("mem_adm");
|
|
57
|
+
expect(resolveStoredKey(cfg, "acct_adm")).toBe(AdminRoleKeys.mem_adm);
|
|
58
|
+
expect(resolveStoredKey(cfg, "ACCT-ADM")).toBe(AdminRoleKeys.mem_adm);
|
|
59
|
+
expect(resolveStoredKey(cfg, "MEM-ADM")).toBe(AdminRoleKeys.mem_adm);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("ships TRAIN-ADM's drafted definition verbatim and keeps canon's ⚑ marker in definitionNote", () => {
|
|
63
|
+
const train = byKey.get("train_adm")!;
|
|
64
|
+
expect(train.definition).toMatch(/^Agency-set role that configures training\/certification requirements/);
|
|
65
|
+
expect(train.definition).not.toContain("⚑");
|
|
66
|
+
expect(train.definitionNote).toMatch(/⚑ Crysta to confirm\.$/);
|
|
67
|
+
expect(sot.entries.filter((e) => e.definitionNote !== undefined).map((e) => e.key)).toEqual(["train_adm"]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("carries canon's reach on every admin role, from canon's own value set", () => {
|
|
71
|
+
const reachValues = ["platform", "account", "team", "supervised_people"];
|
|
72
|
+
for (const e of sot.entries) expect(reachValues, e.key).toContain(e["reach"]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("retitles PLT-ADM to canon's live label and refreshes every role", () => {
|
|
76
|
+
expect(byKey.get("plt_adm")?.title).toBe("Platform Owner & Admin");
|
|
77
|
+
if (sot._supersedes.version !== "1.0.0") return; // `refreshed` is a per-bump record
|
|
78
|
+
expect(sot._supersedes.refreshed).toEqual(Object.keys(AdminRoleKeys));
|
|
79
|
+
});
|
|
80
|
+
});
|