@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
@@ -175,4 +175,91 @@ declare function sortScopeRows<T extends string>(category: string, rows: readonl
175
175
  /** `categories` (either spelling, returned as given) in canon's order; unknown last. */
176
176
  declare function sortScopeCategories<T extends string>(categories: readonly T[]): T[];
177
177
 
178
- export { type CoreInformationScopeSot, type CoreInformationScopeSotEntry, type CoreInformationScopeSotMigrationLine, INFORMATION_SCOPE_CATEGORY_ORDER, INFORMATION_SCOPE_CATEGORY_SUB, INFORMATION_SCOPE_ROW_HINT, INFORMATION_SCOPE_ROW_ORDER, INFORMATION_SCOPE_UI_COPY_SOURCE, ScopeMigration, ScopeRow, scopeCategorySub, scopeMigrationsFromSot, scopeRowDisplayOrder, scopeRowHint, scopeRowsFromSot, sortScopeCategories, sortScopeRows };
178
+ /**
179
+ * @htilabs/platform-common-models — the release (ROI) wizard's quick-fill scope presets
180
+ *
181
+ * ONE home for the three presets the ROI wizard offers staff when they record what a
182
+ * survivor authorizes — "Full case collaboration" / "Name + risk information" /
183
+ * "Identifying info only" — and that the Admin Hub's Information scope tab lists under
184
+ * "Default scope presets". Every app reads this export; no app keeps its own list
185
+ * (Crysta, 2026-11-16: one vocabulary, one source, never hand-copied).
186
+ *
187
+ * Source of truth: the prototype monolith's `HTI_ROI_SCOPE_PRESETS` (ids, item lists and
188
+ * their order, stamped `HTI_ROI_SCOPE_PRESETS_VERSION`) and the wizard's pill words
189
+ * (`presetChip(...)`), at the commit in `ROI_SCOPE_PRESETS_SOURCE`. The monolith carries no
190
+ * description and no on/off for a preset; `description` and `enabled` are the Admin Hub
191
+ * prototype's (`data.sharing.scopePresets`). `src/__sot__/roiScopePresets.pin.json` is the
192
+ * independently derived snapshot (`npm run sot:pins -- --only=roiScopePresets`);
193
+ * `roi-scope-presets-canon.test.ts` holds this module equal to it and resolves every item
194
+ * against the published CVC-236 v4 tree.
195
+ *
196
+ * Item ids are CVC-236 `core-information_scope` row codes on tree version 4 (canon's dotted
197
+ * spelling — every preset row today is a plain key). A code covers every row beneath it,
198
+ * so `family` is the whole Eligible-family-member kind. Instrument Summary rows are
199
+ * `selectable: false` in the tree — no picker offers one alone — but canon lists the
200
+ * presets per row on purpose, and the presets keep them.
201
+ *
202
+ * `enabled` is display-only in the prototype (the Admin Hub's "Enabled" chip; no control in
203
+ * either prototype changes it), so it is the default here and nothing stores it per account.
204
+ *
205
+ * Pure: no mongoose, no I/O. Browser-safe through `./information-scope`.
206
+ */
207
+ /** The three fixed preset ids, in the wizard's pill order. */
208
+ declare const ROI_SCOPE_PRESET_IDS: readonly ["full_collab", "risk_only", "identifying"];
209
+ type RoiScopePresetId = (typeof ROI_SCOPE_PRESET_IDS)[number];
210
+ /** The CVC-236 tree version every preset list is authored on (canon `HTI_ROI_SCOPE_PRESETS_VERSION`). */
211
+ declare const ROI_SCOPE_PRESETS_SCOPE_VERSION: 4;
212
+ /** Where the presets were copied from (the pin restates it). */
213
+ declare const ROI_SCOPE_PRESETS_SOURCE: {
214
+ readonly repo: "htilabstech/prototype";
215
+ readonly file: "HTI-LEADS-PAVE-Thread-prototype.html";
216
+ readonly commit: "ba5ded6de6affdb11054a18a8a8a561be987a403";
217
+ readonly mirror: {
218
+ readonly repo: "htilabstech/platform-prototype";
219
+ readonly file: "src/data.js";
220
+ readonly commit: "398fb24";
221
+ };
222
+ };
223
+ interface RoiScopePresetDefinition {
224
+ readonly id: RoiScopePresetId;
225
+ /** The wizard's pill word. */
226
+ readonly label: string;
227
+ /** The Admin Hub's one-line description. */
228
+ readonly description: string;
229
+ /** Whether the preset is offered by default (display-only in the prototype). */
230
+ readonly enabled: boolean;
231
+ /** CVC-236 v4 row codes, in canon's order; `system_info` included. */
232
+ readonly itemIds: readonly string[];
233
+ }
234
+ /** The three ROI scope presets, canon's lists verbatim, in pill order. */
235
+ declare const ROI_SCOPE_PRESETS: readonly RoiScopePresetDefinition[];
236
+ /** Each preset's pill word, by id. */
237
+ declare const ROI_SCOPE_PRESET_LABELS: Readonly<Record<RoiScopePresetId, string>>;
238
+ /** Each preset's item list, by id. */
239
+ declare const ROI_SCOPE_PRESET_ITEM_IDS: Readonly<Record<RoiScopePresetId, readonly string[]>>;
240
+ /** Whether `id` names one of the three presets. */
241
+ declare function isRoiScopePresetId(id: unknown): id is RoiScopePresetId;
242
+ /** The preset with this id, or `undefined`. */
243
+ declare function roiScopePresetById(id: string): RoiScopePresetDefinition | undefined;
244
+ /** The CVC-236 row fields this module reads. */
245
+ interface RoiScopePresetRowLike {
246
+ readonly scopeCode: string;
247
+ readonly status: string;
248
+ }
249
+ /** The slice of the CVC-236 resolver this module reads (`createInformationScopeResolver`). */
250
+ interface RoiScopePresetRowSource<R extends RoiScopePresetRowLike> {
251
+ row(code: string): R | undefined;
252
+ }
253
+ /**
254
+ * A preset's rows, resolved against the CVC-236 tree, in the preset's order. Throws when
255
+ * the id is not a preset, or when an item does not resolve to a live row — a preset never
256
+ * silently selects less than canon says.
257
+ *
258
+ * ```ts
259
+ * const scope = createInformationScopeResolver({ rows: scopeRowsFromSot(sot), migrations: scopeMigrationsFromSot(sot) });
260
+ * roiScopePresetRows("risk_only", scope); // ScopeRow[]
261
+ * ```
262
+ */
263
+ declare function roiScopePresetRows<R extends RoiScopePresetRowLike>(id: string, scope: RoiScopePresetRowSource<R>): R[];
264
+
265
+ export { type CoreInformationScopeSot, type CoreInformationScopeSotEntry, type CoreInformationScopeSotMigrationLine, INFORMATION_SCOPE_CATEGORY_ORDER, INFORMATION_SCOPE_CATEGORY_SUB, INFORMATION_SCOPE_ROW_HINT, INFORMATION_SCOPE_ROW_ORDER, INFORMATION_SCOPE_UI_COPY_SOURCE, ROI_SCOPE_PRESETS, ROI_SCOPE_PRESETS_SCOPE_VERSION, ROI_SCOPE_PRESETS_SOURCE, ROI_SCOPE_PRESET_IDS, ROI_SCOPE_PRESET_ITEM_IDS, ROI_SCOPE_PRESET_LABELS, type RoiScopePresetDefinition, type RoiScopePresetId, type RoiScopePresetRowLike, type RoiScopePresetRowSource, ScopeMigration, ScopeRow, isRoiScopePresetId, roiScopePresetById, roiScopePresetRows, scopeCategorySub, scopeMigrationsFromSot, scopeRowDisplayOrder, scopeRowHint, scopeRowsFromSot, sortScopeCategories, sortScopeRows };
@@ -175,4 +175,91 @@ declare function sortScopeRows<T extends string>(category: string, rows: readonl
175
175
  /** `categories` (either spelling, returned as given) in canon's order; unknown last. */
176
176
  declare function sortScopeCategories<T extends string>(categories: readonly T[]): T[];
177
177
 
178
- export { type CoreInformationScopeSot, type CoreInformationScopeSotEntry, type CoreInformationScopeSotMigrationLine, INFORMATION_SCOPE_CATEGORY_ORDER, INFORMATION_SCOPE_CATEGORY_SUB, INFORMATION_SCOPE_ROW_HINT, INFORMATION_SCOPE_ROW_ORDER, INFORMATION_SCOPE_UI_COPY_SOURCE, ScopeMigration, ScopeRow, scopeCategorySub, scopeMigrationsFromSot, scopeRowDisplayOrder, scopeRowHint, scopeRowsFromSot, sortScopeCategories, sortScopeRows };
178
+ /**
179
+ * @htilabs/platform-common-models — the release (ROI) wizard's quick-fill scope presets
180
+ *
181
+ * ONE home for the three presets the ROI wizard offers staff when they record what a
182
+ * survivor authorizes — "Full case collaboration" / "Name + risk information" /
183
+ * "Identifying info only" — and that the Admin Hub's Information scope tab lists under
184
+ * "Default scope presets". Every app reads this export; no app keeps its own list
185
+ * (Crysta, 2026-11-16: one vocabulary, one source, never hand-copied).
186
+ *
187
+ * Source of truth: the prototype monolith's `HTI_ROI_SCOPE_PRESETS` (ids, item lists and
188
+ * their order, stamped `HTI_ROI_SCOPE_PRESETS_VERSION`) and the wizard's pill words
189
+ * (`presetChip(...)`), at the commit in `ROI_SCOPE_PRESETS_SOURCE`. The monolith carries no
190
+ * description and no on/off for a preset; `description` and `enabled` are the Admin Hub
191
+ * prototype's (`data.sharing.scopePresets`). `src/__sot__/roiScopePresets.pin.json` is the
192
+ * independently derived snapshot (`npm run sot:pins -- --only=roiScopePresets`);
193
+ * `roi-scope-presets-canon.test.ts` holds this module equal to it and resolves every item
194
+ * against the published CVC-236 v4 tree.
195
+ *
196
+ * Item ids are CVC-236 `core-information_scope` row codes on tree version 4 (canon's dotted
197
+ * spelling — every preset row today is a plain key). A code covers every row beneath it,
198
+ * so `family` is the whole Eligible-family-member kind. Instrument Summary rows are
199
+ * `selectable: false` in the tree — no picker offers one alone — but canon lists the
200
+ * presets per row on purpose, and the presets keep them.
201
+ *
202
+ * `enabled` is display-only in the prototype (the Admin Hub's "Enabled" chip; no control in
203
+ * either prototype changes it), so it is the default here and nothing stores it per account.
204
+ *
205
+ * Pure: no mongoose, no I/O. Browser-safe through `./information-scope`.
206
+ */
207
+ /** The three fixed preset ids, in the wizard's pill order. */
208
+ declare const ROI_SCOPE_PRESET_IDS: readonly ["full_collab", "risk_only", "identifying"];
209
+ type RoiScopePresetId = (typeof ROI_SCOPE_PRESET_IDS)[number];
210
+ /** The CVC-236 tree version every preset list is authored on (canon `HTI_ROI_SCOPE_PRESETS_VERSION`). */
211
+ declare const ROI_SCOPE_PRESETS_SCOPE_VERSION: 4;
212
+ /** Where the presets were copied from (the pin restates it). */
213
+ declare const ROI_SCOPE_PRESETS_SOURCE: {
214
+ readonly repo: "htilabstech/prototype";
215
+ readonly file: "HTI-LEADS-PAVE-Thread-prototype.html";
216
+ readonly commit: "ba5ded6de6affdb11054a18a8a8a561be987a403";
217
+ readonly mirror: {
218
+ readonly repo: "htilabstech/platform-prototype";
219
+ readonly file: "src/data.js";
220
+ readonly commit: "398fb24";
221
+ };
222
+ };
223
+ interface RoiScopePresetDefinition {
224
+ readonly id: RoiScopePresetId;
225
+ /** The wizard's pill word. */
226
+ readonly label: string;
227
+ /** The Admin Hub's one-line description. */
228
+ readonly description: string;
229
+ /** Whether the preset is offered by default (display-only in the prototype). */
230
+ readonly enabled: boolean;
231
+ /** CVC-236 v4 row codes, in canon's order; `system_info` included. */
232
+ readonly itemIds: readonly string[];
233
+ }
234
+ /** The three ROI scope presets, canon's lists verbatim, in pill order. */
235
+ declare const ROI_SCOPE_PRESETS: readonly RoiScopePresetDefinition[];
236
+ /** Each preset's pill word, by id. */
237
+ declare const ROI_SCOPE_PRESET_LABELS: Readonly<Record<RoiScopePresetId, string>>;
238
+ /** Each preset's item list, by id. */
239
+ declare const ROI_SCOPE_PRESET_ITEM_IDS: Readonly<Record<RoiScopePresetId, readonly string[]>>;
240
+ /** Whether `id` names one of the three presets. */
241
+ declare function isRoiScopePresetId(id: unknown): id is RoiScopePresetId;
242
+ /** The preset with this id, or `undefined`. */
243
+ declare function roiScopePresetById(id: string): RoiScopePresetDefinition | undefined;
244
+ /** The CVC-236 row fields this module reads. */
245
+ interface RoiScopePresetRowLike {
246
+ readonly scopeCode: string;
247
+ readonly status: string;
248
+ }
249
+ /** The slice of the CVC-236 resolver this module reads (`createInformationScopeResolver`). */
250
+ interface RoiScopePresetRowSource<R extends RoiScopePresetRowLike> {
251
+ row(code: string): R | undefined;
252
+ }
253
+ /**
254
+ * A preset's rows, resolved against the CVC-236 tree, in the preset's order. Throws when
255
+ * the id is not a preset, or when an item does not resolve to a live row — a preset never
256
+ * silently selects less than canon says.
257
+ *
258
+ * ```ts
259
+ * const scope = createInformationScopeResolver({ rows: scopeRowsFromSot(sot), migrations: scopeMigrationsFromSot(sot) });
260
+ * roiScopePresetRows("risk_only", scope); // ScopeRow[]
261
+ * ```
262
+ */
263
+ declare function roiScopePresetRows<R extends RoiScopePresetRowLike>(id: string, scope: RoiScopePresetRowSource<R>): R[];
264
+
265
+ export { type CoreInformationScopeSot, type CoreInformationScopeSotEntry, type CoreInformationScopeSotMigrationLine, INFORMATION_SCOPE_CATEGORY_ORDER, INFORMATION_SCOPE_CATEGORY_SUB, INFORMATION_SCOPE_ROW_HINT, INFORMATION_SCOPE_ROW_ORDER, INFORMATION_SCOPE_UI_COPY_SOURCE, ROI_SCOPE_PRESETS, ROI_SCOPE_PRESETS_SCOPE_VERSION, ROI_SCOPE_PRESETS_SOURCE, ROI_SCOPE_PRESET_IDS, ROI_SCOPE_PRESET_ITEM_IDS, ROI_SCOPE_PRESET_LABELS, type RoiScopePresetDefinition, type RoiScopePresetId, type RoiScopePresetRowLike, type RoiScopePresetRowSource, ScopeMigration, ScopeRow, isRoiScopePresetId, roiScopePresetById, roiScopePresetRows, scopeCategorySub, scopeMigrationsFromSot, scopeRowDisplayOrder, scopeRowHint, scopeRowsFromSot, sortScopeCategories, sortScopeRows };
@@ -736,6 +736,106 @@ function sortScopeCategories(categories) {
736
736
  const n = INFORMATION_SCOPE_CATEGORY_ORDER.length;
737
737
  return categories.map((c, i) => ({ c, i, at: rank.get(toKey(c)) ?? n })).sort((a, b) => a.at - b.at || a.i - b.i).map((x) => x.c);
738
738
  }
739
+
740
+ // src/roiScopePresets/index.ts
741
+ var ROI_SCOPE_PRESET_IDS = ["full_collab", "risk_only", "identifying"];
742
+ var ROI_SCOPE_PRESETS_SCOPE_VERSION = 4;
743
+ var ROI_SCOPE_PRESETS_SOURCE = {
744
+ repo: "htilabstech/prototype",
745
+ file: "HTI-LEADS-PAVE-Thread-prototype.html",
746
+ commit: "ba5ded6de6affdb11054a18a8a8a561be987a403",
747
+ mirror: { repo: "htilabstech/platform-prototype", file: "src/data.js", commit: "398fb24" }
748
+ };
749
+ var freeze = (p) => Object.freeze({ ...p, itemIds: Object.freeze([...p.itemIds]) });
750
+ var ROI_SCOPE_PRESETS = Object.freeze([
751
+ freeze({
752
+ id: "full_collab",
753
+ label: "Full case collaboration",
754
+ description: "Broad packet for coordinated providers working the case together.",
755
+ enabled: true,
756
+ itemIds: [
757
+ "names",
758
+ "dob",
759
+ "addresses",
760
+ "demographics",
761
+ "screen_indicators",
762
+ "victimization",
763
+ "summary_initial_screen",
764
+ "summary_ae_intake",
765
+ "summary_ida",
766
+ "summary_lap",
767
+ "summary_danger_assessment",
768
+ "summary_stalking_assessment",
769
+ "summary_injury_and_strangulation",
770
+ "summary_tra",
771
+ "summary_hope_scale",
772
+ "summary_needs_assessment",
773
+ "full_ida",
774
+ "contact_info",
775
+ "priorities_safety",
776
+ "encounter_location",
777
+ "contact_history",
778
+ "service_history",
779
+ "plans_goals",
780
+ "session_summary",
781
+ "case_notes",
782
+ "relationships_household",
783
+ "family",
784
+ "system_info"
785
+ ]
786
+ }),
787
+ freeze({
788
+ id: "risk_only",
789
+ label: "Name + risk information",
790
+ description: "Minimal identifying info \u2014 risk + screening for a coordinated handoff.",
791
+ enabled: true,
792
+ itemIds: [
793
+ "names",
794
+ "screen_indicators",
795
+ "victimization",
796
+ "summary_initial_screen",
797
+ "summary_ae_intake",
798
+ "summary_ida",
799
+ "summary_lap",
800
+ "summary_danger_assessment",
801
+ "summary_stalking_assessment",
802
+ "summary_injury_and_strangulation",
803
+ "system_info"
804
+ ]
805
+ }),
806
+ freeze({
807
+ id: "identifying",
808
+ label: "Identifying info only",
809
+ description: "Used for verification with law enforcement / medical partners.",
810
+ enabled: true,
811
+ itemIds: ["names", "dob", "addresses", "additional_ids", "demographics", "system_info"]
812
+ })
813
+ ]);
814
+ var ROI_SCOPE_PRESET_LABELS = Object.freeze(
815
+ Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.label]))
816
+ );
817
+ var ROI_SCOPE_PRESET_ITEM_IDS = Object.freeze(
818
+ Object.fromEntries(ROI_SCOPE_PRESETS.map((p) => [p.id, p.itemIds]))
819
+ );
820
+ function isRoiScopePresetId(id) {
821
+ return typeof id === "string" && ROI_SCOPE_PRESET_IDS.includes(id);
822
+ }
823
+ function roiScopePresetById(id) {
824
+ return ROI_SCOPE_PRESETS.find((p) => p.id === id);
825
+ }
826
+ function roiScopePresetRows(id, scope) {
827
+ const preset = roiScopePresetById(id);
828
+ if (!preset) throw new Error(`roiScopePresetRows: "${id}" is not an ROI scope preset`);
829
+ return preset.itemIds.map((code) => {
830
+ const row = scope.row(code);
831
+ if (!row || row.status === "retired") {
832
+ throw new Error(
833
+ `roiScopePresetRows: preset "${id}" names "${code}", which is not a live CVC-236 row`
834
+ );
835
+ }
836
+ return row;
837
+ });
838
+ }
739
839
  export {
740
840
  INFORMATION_SCOPE_CATEGORY_ORDER,
741
841
  INFORMATION_SCOPE_CATEGORY_SUB,
@@ -746,11 +846,20 @@ export {
746
846
  INFORMATION_SCOPE_SYSTEM_INFO,
747
847
  INFORMATION_SCOPE_UI_COPY_SOURCE,
748
848
  INFORMATION_SCOPE_VERSION,
849
+ ROI_SCOPE_PRESETS,
850
+ ROI_SCOPE_PRESETS_SCOPE_VERSION,
851
+ ROI_SCOPE_PRESETS_SOURCE,
852
+ ROI_SCOPE_PRESET_IDS,
853
+ ROI_SCOPE_PRESET_ITEM_IDS,
854
+ ROI_SCOPE_PRESET_LABELS,
749
855
  createInformationScopeResolver,
856
+ isRoiScopePresetId,
750
857
  isScopeInstrumentRow,
751
858
  isScopeRestRow,
752
859
  isSelectableScopeRow,
753
860
  kindForPerson,
861
+ roiScopePresetById,
862
+ roiScopePresetRows,
754
863
  scopeCategorySub,
755
864
  scopeMigrationsFromSot,
756
865
  scopeRowDisplayOrder,