@htilabs/platform-common-models 0.87.1 → 0.88.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 (37) hide show
  1. package/README.md +11 -1
  2. package/dist/{index-Bj-s0nZy.d.cts → index-1pWiqEBC.d.cts} +1 -1
  3. package/dist/{index-DvAypMJV.d.ts → index-uz57Fic9.d.ts} +1 -1
  4. package/dist/index.cjs +118 -0
  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 +109 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/information-scope/index.cjs +118 -0
  11. package/dist/information-scope/index.cjs.map +1 -1
  12. package/dist/information-scope/index.d.cts +88 -1
  13. package/dist/information-scope/index.d.ts +88 -1
  14. package/dist/information-scope/index.js +109 -0
  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 +1 -1
  19. package/dist/schemas/index.d.ts +1 -1
  20. package/dist/services/index.cjs +118 -0
  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 +109 -0
  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/__sot__/README.md +1 -0
  30. package/src/__sot__/roiScopePresets.pin.json +82 -0
  31. package/src/__tests__/roi-scope-presets-canon.test.ts +106 -0
  32. package/src/roiScopePresets/index.ts +190 -0
  33. package/src/services/informationScope.ts +2 -0
  34. package/dist/{agency-CnVTwLeV.d.ts → agency-BHv54o79.d.ts} +4 -4
  35. package/dist/{agency-8ufZJJDH.d.cts → agency-Djp57S71.d.cts} +4 -4
  36. package/dist/{cvcEntry-BLeRivoF.d.cts → cvcEntry-DAuhe0cd.d.cts} +16 -16
  37. package/dist/{cvcEntry-BLeRivoF.d.ts → cvcEntry-DAuhe0cd.d.ts} +16 -16
@@ -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-8ufZJJDH.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-Djp57S71.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-CnVTwLeV.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-BHv54o79.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.87.1",
3
+ "version": "0.88.0",
4
4
  "description": "Shared constants, types, and models for HTI Labs applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -19,6 +19,7 @@ live in other repos:
19
19
  | `captureConflictSemantics.pin.json` | `htilabstech/hti-features` · `src/hti_features/field_mapping/registry.json` → `capture_conflict_semantics` on `captured` rows | The per-field **capture-conflict semantics** the `share-review` kernel resolves (th-hbo9t.2): registry field id → `additive_log` · `log_end_date_current` · `single_value_keep_replace` · `no_conflict_derived`, plus the captured-row denominator. Derived here by `sot:pins` (set `HTI_FEATURES_DIR`; derivation in `scripts/lib/captureConflictSemantics.ts`, which refuses an illegal or `null` value, the key on a non-captured row, and a duplicate field id). **Refreshing this pin is half a step:** re-emit `src/generated/captureConflictSemantics.ts` with `npm run gen:capture-conflict-semantics` in the same change — `gen:capture-conflict-semantics:check` (ci.yml) holds the module byte-equal to the pin. Equal, key for key, to the prototype's generated `HTI_CAPTURE_CONFLICT_SEMANTICS` block at c2b0b8b0 (141). |
20
20
  | `grantAward.pin.json` | `htilabstech/hti-features` · `udd-schemas/grant/Grant.v2.json` + `udd-schemas/award/Award.v1.json` + `udd-schemas/award/AwardProgramLink.v1.json` | The shared **Grant / Award / Award–Program link** records (Kickoff 18c; shape confirmed by Crysta 2026-11-10): per schema, the required list, the field names, every `pattern` and `enum` (top level and inside array items), the conditional rule (`allOf`, the Award's SUBRECIPIENT pass-through rule) and every `x-scenarios` example **verbatim**. Derived by `scripts/lib/grantAwardSchemas.ts` (set `HTI_FEATURES_DIR`). `src/grantRegistry/__tests__/grantAwardPin.test.ts` asserts the `./grant-registry` subpath restates each list and that every example passes its write check. When hti-features moves the three schemas, refresh this pin and update `src/grantRegistry/` in the same change. |
21
21
  | `coreFunctions.pin.json` | `htilabstech/prototype` · `data/cvcs/core_functions.yaml` | The CVC-133 **function registry** — which permissionable functions exist, **and what canon says about each one** (label · status · category · platform relevance · user/admin relevance · v1 · retired, verbatim; since SOT 1.3.0 `v1` / `retired` are also structured booleans on every SOT entry, read by the shared authorization resolver) **and its per-role bounds** (since 0.24.0, co-p1x: `projectBounds` normalizes canon's `bounds:` to role code → ALWAYS / PREF_YES / PREF_NO / NEVER / NA; `GATE L` (`core-function-default-bounds.test.ts`) asserts the generated `src/generated/coreFunctionDefaultBounds.ts` equals it for every evaluable function and that every role code is a CVC-134 / CVC-135 `canonicalCode` — these are codebook DEFAULTS, the live bounds are platform policy state). The yaml is itself generated there from the Notion export ("the export wins"). `GATE I` (`core-functions-canon.test.ts`) asserts `coreFunctions.v*.json` restates every one; `coreFunctionFields.ts` holds the shared projection + the posture-suffix composition. **Refreshing this pin is half a step:** the SOT JSON is generated from the same yaml by `scripts/gen-core-functions.py <prototype root>` — run it in the same change **against the same prototype checkout at the same SHA** (the pin reads the working tree; the generator reads `origin/main` after a fetch — keep them equal), bumping the SOT version per `CLAUDE.md`, or GATE I fails (correctly). The generator also maintains `coreFunctions.published.json`, the append-only ledger of every published key → code that GATE I asserts pair by pair. |
22
+ | `roiScopePresets.pin.json` | `htilabstech/prototype` · `HTI-LEADS-PAVE-Thread-prototype.html` `HTI_ROI_SCOPE_PRESETS` (+ `HTI_ROI_SCOPE_PRESETS_VERSION`, the wizard's `presetChip(...)` words) **and** `htilabstech/platform-prototype` · `src/data.js` `data.sharing.scopePresets` (`description` / `enabled` only) | The release (ROI) wizard's three **quick-fill scope presets** — ids, pill words and item lists in canon's order. The monolith carries no description or on/off; those two come from the Admin Hub prototype, whose own labels and lists are a stale hand-kept copy and are never read. `roi-scope-presets-canon.test.ts` asserts `src/roiScopePresets/index.ts` equals the pin and that every item is a live CVC-236 v4 row. Set `PLATFORM_PROTOTYPE_DIR` for the pin. |
22
23
  | `informationScopeV2V3Categories.pin.json` | `htilabstech/prototype` · `data/cvcs/core_information_scope.yaml` → `migrations_history` (the 2 → 3 step, `categories`) | CVC-236's v2 → v3 **category lines** — what an old category name adds when a category-grain list is carried forward. `readStoredPolicyScope` reads an unmarked stored sharing policy through them; `storedPolicyScope.test.ts` asserts `UNMARKED_POLICY_CATEGORY_LINES` equals the pin. |
23
24
 
24
25
  (Notion is the fourth SOT: **ratification**. It has no pin because it is a human
@@ -0,0 +1,82 @@
1
+ {
2
+ "sourceRepo": "htilabstech/prototype",
3
+ "sourceFile": "HTI-LEADS-PAVE-Thread-prototype.html",
4
+ "sourceSha": "ba5ded6",
5
+ "mirror": {
6
+ "sourceRepo": "htilabstech/platform-prototype",
7
+ "sourceFile": "src/data.js",
8
+ "sourceSha": "398fb24"
9
+ },
10
+ "scopeVersion": 4,
11
+ "presets": [
12
+ {
13
+ "id": "full_collab",
14
+ "label": "Full case collaboration",
15
+ "description": "Broad packet for coordinated providers working the case together.",
16
+ "enabled": true,
17
+ "itemIds": [
18
+ "names",
19
+ "dob",
20
+ "addresses",
21
+ "demographics",
22
+ "screen_indicators",
23
+ "victimization",
24
+ "summary_initial_screen",
25
+ "summary_ae_intake",
26
+ "summary_ida",
27
+ "summary_lap",
28
+ "summary_danger_assessment",
29
+ "summary_stalking_assessment",
30
+ "summary_injury_and_strangulation",
31
+ "summary_tra",
32
+ "summary_hope_scale",
33
+ "summary_needs_assessment",
34
+ "full_ida",
35
+ "contact_info",
36
+ "priorities_safety",
37
+ "encounter_location",
38
+ "contact_history",
39
+ "service_history",
40
+ "plans_goals",
41
+ "session_summary",
42
+ "case_notes",
43
+ "relationships_household",
44
+ "family",
45
+ "system_info"
46
+ ]
47
+ },
48
+ {
49
+ "id": "risk_only",
50
+ "label": "Name + risk information",
51
+ "description": "Minimal identifying info — risk + screening for a coordinated handoff.",
52
+ "enabled": true,
53
+ "itemIds": [
54
+ "names",
55
+ "screen_indicators",
56
+ "victimization",
57
+ "summary_initial_screen",
58
+ "summary_ae_intake",
59
+ "summary_ida",
60
+ "summary_lap",
61
+ "summary_danger_assessment",
62
+ "summary_stalking_assessment",
63
+ "summary_injury_and_strangulation",
64
+ "system_info"
65
+ ]
66
+ },
67
+ {
68
+ "id": "identifying",
69
+ "label": "Identifying info only",
70
+ "description": "Used for verification with law enforcement / medical partners.",
71
+ "enabled": true,
72
+ "itemIds": [
73
+ "names",
74
+ "dob",
75
+ "addresses",
76
+ "additional_ids",
77
+ "demographics",
78
+ "system_info"
79
+ ]
80
+ }
81
+ ]
82
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * ROI SCOPE PRESETS — the shipped presets restate canon (@ the pin)
3
+ * ================================================================
4
+ *
5
+ * `src/roiScopePresets/index.ts` is the one home of the release (ROI) wizard's
6
+ * quick-fill presets. `src/__sot__/roiScopePresets.pin.json` is derived
7
+ * INDEPENDENTLY from the monolith's `HTI_ROI_SCOPE_PRESETS` (+ the Admin Hub
8
+ * prototype's description / on-off) by `scripts/sot-pins.ts`. This test is the
9
+ * hermetic enforcer: ids, labels, descriptions, `enabled` and every item list
10
+ * (order included) equal the pin, and every item is a live CVC-236 v4 row.
11
+ * `sot:pins:check` is the detector for canon moving.
12
+ */
13
+ import { readFileSync } from "node:fs";
14
+ import path from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ import { describe, expect, it } from "vitest";
17
+
18
+ import { coreInformationScopeSot } from "../cvcs/index.js";
19
+ import {
20
+ ROI_SCOPE_PRESETS,
21
+ ROI_SCOPE_PRESETS_SCOPE_VERSION,
22
+ ROI_SCOPE_PRESETS_SOURCE,
23
+ ROI_SCOPE_PRESET_IDS,
24
+ ROI_SCOPE_PRESET_ITEM_IDS,
25
+ ROI_SCOPE_PRESET_LABELS,
26
+ createInformationScopeResolver,
27
+ isRoiScopePresetId,
28
+ roiScopePresetById,
29
+ roiScopePresetRows,
30
+ scopeMigrationsFromSot,
31
+ scopeRowsFromSot,
32
+ type CoreInformationScopeSot,
33
+ } from "../services/informationScope.js";
34
+ import * as root from "../index.js";
35
+
36
+ const here = path.dirname(fileURLToPath(import.meta.url));
37
+ const pin = JSON.parse(
38
+ readFileSync(path.join(here, "..", "__sot__", "roiScopePresets.pin.json"), "utf8"),
39
+ ) as {
40
+ sourceSha: string;
41
+ mirror: { sourceSha: string };
42
+ scopeVersion: number;
43
+ presets: {
44
+ id: string;
45
+ label: string;
46
+ description: string;
47
+ enabled: boolean;
48
+ itemIds: string[];
49
+ }[];
50
+ };
51
+
52
+ const sot = coreInformationScopeSot as CoreInformationScopeSot;
53
+ const scope = createInformationScopeResolver({
54
+ rows: scopeRowsFromSot(sot),
55
+ migrations: scopeMigrationsFromSot(sot),
56
+ });
57
+
58
+ describe("ROI scope presets — the shipped presets restate canon (@ the pin)", () => {
59
+ it("equals the independently derived pin, order included", () => {
60
+ expect(ROI_SCOPE_PRESETS_SCOPE_VERSION).toBe(pin.scopeVersion);
61
+ expect(JSON.stringify(ROI_SCOPE_PRESETS)).toBe(JSON.stringify(pin.presets));
62
+ expect(ROI_SCOPE_PRESETS_SOURCE.commit.startsWith(pin.sourceSha)).toBe(true);
63
+ expect(ROI_SCOPE_PRESETS_SOURCE.mirror.commit).toBe(pin.mirror.sourceSha);
64
+ });
65
+
66
+ it("names the three presets in the wizard's pill order, with the wizard's words", () => {
67
+ expect(ROI_SCOPE_PRESETS.map((p) => p.id)).toEqual([...ROI_SCOPE_PRESET_IDS]);
68
+ expect(ROI_SCOPE_PRESET_LABELS).toEqual({
69
+ full_collab: "Full case collaboration",
70
+ risk_only: "Name + risk information",
71
+ identifying: "Identifying info only",
72
+ });
73
+ for (const p of ROI_SCOPE_PRESETS) expect(ROI_SCOPE_PRESET_ITEM_IDS[p.id]).toBe(p.itemIds);
74
+ });
75
+
76
+ it("every item is a live CVC-236 v4 row, and every preset carries system_info", () => {
77
+ for (const p of ROI_SCOPE_PRESETS) {
78
+ expect(new Set(p.itemIds).size).toBe(p.itemIds.length);
79
+ expect(p.itemIds).toContain("system_info");
80
+ const rows = roiScopePresetRows(p.id, scope);
81
+ expect(rows.map((r) => r.scopeCode)).toEqual([...p.itemIds]);
82
+ for (const r of rows) expect(r.status).not.toBe("retired");
83
+ }
84
+ });
85
+
86
+ it("lookups and refusals", () => {
87
+ expect(roiScopePresetById("identifying")?.label).toBe("Identifying info only");
88
+ expect(roiScopePresetById("custom")).toBeUndefined();
89
+ expect(isRoiScopePresetId("risk_only")).toBe(true);
90
+ expect(isRoiScopePresetId("account_default")).toBe(false);
91
+ expect(() => roiScopePresetRows("custom", scope)).toThrow(/not an ROI scope preset/);
92
+ expect(() =>
93
+ roiScopePresetRows("identifying", { row: (c: string) => (c === "names" ? scope.row(c) : undefined) }),
94
+ ).toThrow(/not a live CVC-236 row/);
95
+ });
96
+
97
+ it("the presets are frozen", () => {
98
+ expect(Object.isFrozen(ROI_SCOPE_PRESETS)).toBe(true);
99
+ expect(Object.isFrozen(ROI_SCOPE_PRESETS[0]?.itemIds)).toBe(true);
100
+ });
101
+
102
+ it("is exported from the package root too", () => {
103
+ expect(root.ROI_SCOPE_PRESETS).toBe(ROI_SCOPE_PRESETS);
104
+ expect(root.roiScopePresetRows).toBe(roiScopePresetRows);
105
+ });
106
+ });
@@ -0,0 +1,190 @@
1
+ /**
2
+ * @htilabs/platform-common-models — the release (ROI) wizard's quick-fill scope presets
3
+ *
4
+ * ONE home for the three presets the ROI wizard offers staff when they record what a
5
+ * survivor authorizes — "Full case collaboration" / "Name + risk information" /
6
+ * "Identifying info only" — and that the Admin Hub's Information scope tab lists under
7
+ * "Default scope presets". Every app reads this export; no app keeps its own list
8
+ * (Crysta, 2026-11-16: one vocabulary, one source, never hand-copied).
9
+ *
10
+ * Source of truth: the prototype monolith's `HTI_ROI_SCOPE_PRESETS` (ids, item lists and
11
+ * their order, stamped `HTI_ROI_SCOPE_PRESETS_VERSION`) and the wizard's pill words
12
+ * (`presetChip(...)`), at the commit in `ROI_SCOPE_PRESETS_SOURCE`. The monolith carries no
13
+ * description and no on/off for a preset; `description` and `enabled` are the Admin Hub
14
+ * prototype's (`data.sharing.scopePresets`). `src/__sot__/roiScopePresets.pin.json` is the
15
+ * independently derived snapshot (`npm run sot:pins -- --only=roiScopePresets`);
16
+ * `roi-scope-presets-canon.test.ts` holds this module equal to it and resolves every item
17
+ * against the published CVC-236 v4 tree.
18
+ *
19
+ * Item ids are CVC-236 `core-information_scope` row codes on tree version 4 (canon's dotted
20
+ * spelling — every preset row today is a plain key). A code covers every row beneath it,
21
+ * so `family` is the whole Eligible-family-member kind. Instrument Summary rows are
22
+ * `selectable: false` in the tree — no picker offers one alone — but canon lists the
23
+ * presets per row on purpose, and the presets keep them.
24
+ *
25
+ * `enabled` is display-only in the prototype (the Admin Hub's "Enabled" chip; no control in
26
+ * either prototype changes it), so it is the default here and nothing stores it per account.
27
+ *
28
+ * Pure: no mongoose, no I/O. Browser-safe through `./information-scope`.
29
+ */
30
+
31
+ /** The three fixed preset ids, in the wizard's pill order. */
32
+ export const ROI_SCOPE_PRESET_IDS = ["full_collab", "risk_only", "identifying"] as const;
33
+ export type RoiScopePresetId = (typeof ROI_SCOPE_PRESET_IDS)[number];
34
+
35
+ /** The CVC-236 tree version every preset list is authored on (canon `HTI_ROI_SCOPE_PRESETS_VERSION`). */
36
+ export const ROI_SCOPE_PRESETS_SCOPE_VERSION = 4 as const;
37
+
38
+ /** Where the presets were copied from (the pin restates it). */
39
+ export const ROI_SCOPE_PRESETS_SOURCE = {
40
+ repo: "htilabstech/prototype",
41
+ file: "HTI-LEADS-PAVE-Thread-prototype.html",
42
+ commit: "ba5ded6de6affdb11054a18a8a8a561be987a403",
43
+ mirror: { repo: "htilabstech/platform-prototype", file: "src/data.js", commit: "398fb24" },
44
+ } as const;
45
+
46
+ export interface RoiScopePresetDefinition {
47
+ readonly id: RoiScopePresetId;
48
+ /** The wizard's pill word. */
49
+ readonly label: string;
50
+ /** The Admin Hub's one-line description. */
51
+ readonly description: string;
52
+ /** Whether the preset is offered by default (display-only in the prototype). */
53
+ readonly enabled: boolean;
54
+ /** CVC-236 v4 row codes, in canon's order; `system_info` included. */
55
+ readonly itemIds: readonly string[];
56
+ }
57
+
58
+ const freeze = (p: RoiScopePresetDefinition): RoiScopePresetDefinition =>
59
+ Object.freeze({ ...p, itemIds: Object.freeze([...p.itemIds]) });
60
+
61
+ /** The three ROI scope presets, canon's lists verbatim, in pill order. */
62
+ export const ROI_SCOPE_PRESETS: readonly RoiScopePresetDefinition[] = Object.freeze([
63
+ freeze({
64
+ id: "full_collab",
65
+ label: "Full case collaboration",
66
+ description: "Broad packet for coordinated providers working the case together.",
67
+ enabled: true,
68
+ itemIds: [
69
+ "names",
70
+ "dob",
71
+ "addresses",
72
+ "demographics",
73
+ "screen_indicators",
74
+ "victimization",
75
+ "summary_initial_screen",
76
+ "summary_ae_intake",
77
+ "summary_ida",
78
+ "summary_lap",
79
+ "summary_danger_assessment",
80
+ "summary_stalking_assessment",
81
+ "summary_injury_and_strangulation",
82
+ "summary_tra",
83
+ "summary_hope_scale",
84
+ "summary_needs_assessment",
85
+ "full_ida",
86
+ "contact_info",
87
+ "priorities_safety",
88
+ "encounter_location",
89
+ "contact_history",
90
+ "service_history",
91
+ "plans_goals",
92
+ "session_summary",
93
+ "case_notes",
94
+ "relationships_household",
95
+ "family",
96
+ "system_info",
97
+ ],
98
+ }),
99
+ freeze({
100
+ id: "risk_only",
101
+ label: "Name + risk information",
102
+ description: "Minimal identifying info — risk + screening for a coordinated handoff.",
103
+ enabled: true,
104
+ itemIds: [
105
+ "names",
106
+ "screen_indicators",
107
+ "victimization",
108
+ "summary_initial_screen",
109
+ "summary_ae_intake",
110
+ "summary_ida",
111
+ "summary_lap",
112
+ "summary_danger_assessment",
113
+ "summary_stalking_assessment",
114
+ "summary_injury_and_strangulation",
115
+ "system_info",
116
+ ],
117
+ }),
118
+ freeze({
119
+ id: "identifying",
120
+ label: "Identifying info only",
121
+ description: "Used for verification with law enforcement / medical partners.",
122
+ enabled: true,
123
+ itemIds: ["names", "dob", "addresses", "additional_ids", "demographics", "system_info"],
124
+ }),
125
+ ]);
126
+
127
+ /** Each preset's pill word, by id. */
128
+ export const ROI_SCOPE_PRESET_LABELS: Readonly<Record<RoiScopePresetId, string>> = Object.freeze(
129
+ Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.label])) as Record<
130
+ RoiScopePresetId,
131
+ string
132
+ >,
133
+ );
134
+
135
+ /** Each preset's item list, by id. */
136
+ export const ROI_SCOPE_PRESET_ITEM_IDS: Readonly<Record<RoiScopePresetId, readonly string[]>> =
137
+ Object.freeze(
138
+ Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.itemIds])) as Record<
139
+ RoiScopePresetId,
140
+ readonly string[]
141
+ >,
142
+ );
143
+
144
+ /** Whether `id` names one of the three presets. */
145
+ export function isRoiScopePresetId(id: unknown): id is RoiScopePresetId {
146
+ return typeof id === "string" && (ROI_SCOPE_PRESET_IDS as readonly string[]).includes(id);
147
+ }
148
+
149
+ /** The preset with this id, or `undefined`. */
150
+ export function roiScopePresetById(id: string): RoiScopePresetDefinition | undefined {
151
+ return ROI_SCOPE_PRESETS.find((p) => p.id === id);
152
+ }
153
+
154
+ /** The CVC-236 row fields this module reads. */
155
+ export interface RoiScopePresetRowLike {
156
+ readonly scopeCode: string;
157
+ readonly status: string;
158
+ }
159
+
160
+ /** The slice of the CVC-236 resolver this module reads (`createInformationScopeResolver`). */
161
+ export interface RoiScopePresetRowSource<R extends RoiScopePresetRowLike> {
162
+ row(code: string): R | undefined;
163
+ }
164
+
165
+ /**
166
+ * A preset's rows, resolved against the CVC-236 tree, in the preset's order. Throws when
167
+ * the id is not a preset, or when an item does not resolve to a live row — a preset never
168
+ * silently selects less than canon says.
169
+ *
170
+ * ```ts
171
+ * const scope = createInformationScopeResolver({ rows: scopeRowsFromSot(sot), migrations: scopeMigrationsFromSot(sot) });
172
+ * roiScopePresetRows("risk_only", scope); // ScopeRow[]
173
+ * ```
174
+ */
175
+ export function roiScopePresetRows<R extends RoiScopePresetRowLike>(
176
+ id: string,
177
+ scope: RoiScopePresetRowSource<R>,
178
+ ): R[] {
179
+ const preset = roiScopePresetById(id);
180
+ if (!preset) throw new Error(`roiScopePresetRows: "${id}" is not an ROI scope preset`);
181
+ return preset.itemIds.map((code) => {
182
+ const row = scope.row(code);
183
+ if (!row || row.status === "retired") {
184
+ throw new Error(
185
+ `roiScopePresetRows: preset "${id}" names "${code}", which is not a live CVC-236 row`,
186
+ );
187
+ }
188
+ return row;
189
+ });
190
+ }
@@ -9,3 +9,5 @@
9
9
  export * from "./informationScopeResolver.js";
10
10
  export * from "./informationScopeSot.js";
11
11
  export * from "./informationScopeUiCopy.js";
12
+ // The release (ROI) wizard's three quick-fill scope presets (CVC-236 row codes).
13
+ export * from "../roiScopePresets/index.js";
@@ -199,6 +199,8 @@ 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;
202
204
  entries: z.objectOutputType<{
203
205
  code: z.ZodString;
204
206
  key: z.ZodString;
@@ -208,11 +210,11 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
208
210
  childCodes: z.ZodArray<z.ZodString, "many">;
209
211
  definition: z.ZodNullable<z.ZodString>;
210
212
  }, 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;
216
218
  entries: z.objectInputType<{
217
219
  code: z.ZodString;
218
220
  key: z.ZodString;
@@ -222,8 +224,6 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
222
224
  childCodes: z.ZodArray<z.ZodString, "many">;
223
225
  definition: z.ZodNullable<z.ZodString>;
224
226
  }, z.ZodTypeAny, "passthrough">[];
225
- name: string;
226
- version: string;
227
227
  domain: string;
228
228
  levels: Record<string, string>;
229
229
  }>;
@@ -199,6 +199,8 @@ 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;
202
204
  entries: z.objectOutputType<{
203
205
  code: z.ZodString;
204
206
  key: z.ZodString;
@@ -208,11 +210,11 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
208
210
  childCodes: z.ZodArray<z.ZodString, "many">;
209
211
  definition: z.ZodNullable<z.ZodString>;
210
212
  }, 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;
216
218
  entries: z.objectInputType<{
217
219
  code: z.ZodString;
218
220
  key: z.ZodString;
@@ -222,8 +224,6 @@ declare const CvcEnvelopeSchema: z.ZodObject<{
222
224
  childCodes: z.ZodArray<z.ZodString, "many">;
223
225
  definition: z.ZodNullable<z.ZodString>;
224
226
  }, 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
- questionId: string;
203
202
  index: number;
203
+ questionId: string;
204
204
  questionVersion: string;
205
205
  }, mongoose.Document<unknown, {}, {
206
- questionId: string;
207
206
  index: number;
207
+ questionId: string;
208
208
  questionVersion: string;
209
209
  }, {
210
210
  id: string;
211
211
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
212
212
  _id: false;
213
213
  }>> & Omit<{
214
- questionId: string;
215
214
  index: number;
215
+ questionId: string;
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
- questionId: string;
225
224
  index: number;
225
+ questionId: string;
226
226
  questionVersion: string;
227
227
  } & {
228
228
  _id: mongoose.Types.ObjectId;
@@ -233,18 +233,18 @@ type SectionQuestionRef = InferRawDocType<typeof sectionQuestionRefSchema>;
233
233
  declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
234
234
  _id: false;
235
235
  }, {
236
- text: string;
237
236
  type: "tip" | "warning" | "prompt";
238
- }, mongoose.Document<unknown, {}, {
239
237
  text: string;
238
+ }, mongoose.Document<unknown, {}, {
240
239
  type: "tip" | "warning" | "prompt";
240
+ text: string;
241
241
  }, {
242
242
  id: string;
243
243
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
244
244
  _id: false;
245
245
  }>> & Omit<{
246
- text: string;
247
246
  type: "tip" | "warning" | "prompt";
247
+ text: string;
248
248
  } & {
249
249
  _id: mongoose.Types.ObjectId;
250
250
  } & {
@@ -252,8 +252,8 @@ declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any
252
252
  }, "id"> & {
253
253
  id: string;
254
254
  }, unknown, {
255
- text: string;
256
255
  type: "tip" | "warning" | "prompt";
256
+ text: string;
257
257
  } & {
258
258
  _id: mongoose.Types.ObjectId;
259
259
  } & {
@@ -294,18 +294,18 @@ declare const sectionSchemaDefinition: {
294
294
  type: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
295
295
  _id: false;
296
296
  }, {
297
- text: string;
298
297
  type: "tip" | "warning" | "prompt";
299
- }, mongoose.Document<unknown, {}, {
300
298
  text: string;
299
+ }, mongoose.Document<unknown, {}, {
301
300
  type: "tip" | "warning" | "prompt";
301
+ text: string;
302
302
  }, {
303
303
  id: string;
304
304
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
305
305
  _id: false;
306
306
  }>> & Omit<{
307
- text: string;
308
307
  type: "tip" | "warning" | "prompt";
308
+ text: string;
309
309
  } & {
310
310
  _id: mongoose.Types.ObjectId;
311
311
  } & {
@@ -313,8 +313,8 @@ declare const sectionSchemaDefinition: {
313
313
  }, "id"> & {
314
314
  id: string;
315
315
  }, unknown, {
316
- text: string;
317
316
  type: "tip" | "warning" | "prompt";
317
+ text: string;
318
318
  } & {
319
319
  _id: mongoose.Types.ObjectId;
320
320
  } & {
@@ -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
- questionId: string;
330
329
  index: number;
330
+ questionId: string;
331
331
  questionVersion: string;
332
332
  }, mongoose.Document<unknown, {}, {
333
- questionId: string;
334
333
  index: number;
334
+ questionId: string;
335
335
  questionVersion: string;
336
336
  }, {
337
337
  id: string;
338
338
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
339
339
  _id: false;
340
340
  }>> & Omit<{
341
- questionId: string;
342
341
  index: number;
342
+ questionId: string;
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
- questionId: string;
352
351
  index: number;
352
+ questionId: string;
353
353
  questionVersion: string;
354
354
  } & {
355
355
  _id: mongoose.Types.ObjectId;