@htilabs/platform-common-models 0.24.0 → 0.25.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 (38) hide show
  1. package/README.md +65 -0
  2. package/dist/{index-Dr6GBCoY.d.ts → index-ClTjjJ_S.d.ts} +1 -1
  3. package/dist/{index-BTqHP4DM.d.cts → index-Pt82NxQg.d.cts} +1 -1
  4. package/dist/index.cjs +457 -2
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +5 -3
  7. package/dist/index.d.ts +5 -3
  8. package/dist/index.js +437 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/information-scope/index.d.cts +3 -350
  11. package/dist/information-scope/index.d.ts +3 -350
  12. package/dist/informationScopeResolver-BzYu97DE.d.cts +351 -0
  13. package/dist/informationScopeResolver-BzYu97DE.d.ts +351 -0
  14. package/dist/models/index.d.cts +2 -2
  15. package/dist/models/index.d.ts +2 -2
  16. package/dist/schemas/index.d.cts +25 -25
  17. package/dist/schemas/index.d.ts +25 -25
  18. package/dist/services/index.d.cts +2 -1
  19. package/dist/services/index.d.ts +2 -1
  20. package/dist/sharing-ceiling/index.cjs +497 -0
  21. package/dist/sharing-ceiling/index.cjs.map +1 -0
  22. package/dist/sharing-ceiling/index.d.cts +318 -0
  23. package/dist/sharing-ceiling/index.d.ts +318 -0
  24. package/dist/sharing-ceiling/index.js +451 -0
  25. package/dist/sharing-ceiling/index.js.map +1 -0
  26. package/package.json +7 -1
  27. package/src/__sot__/README.md +1 -0
  28. package/src/__sot__/sharingStarter.pin.json +229 -0
  29. package/src/__tests__/sharing-starter-canon.test.ts +178 -0
  30. package/src/generated/sharingPlatformStarter.ts +165 -0
  31. package/src/index.ts +5 -0
  32. package/src/sharingCeiling/__tests__/sharingCeiling.test.ts +678 -0
  33. package/src/sharingCeiling/chain.ts +269 -0
  34. package/src/sharingCeiling/coverage.ts +346 -0
  35. package/src/sharingCeiling/index.ts +14 -0
  36. package/src/sharingCeiling/starter.ts +89 -0
  37. package/dist/{cvcEntry-BqAGctqK.d.cts → cvcEntry-Asg7mxjB.d.cts} +8 -8
  38. package/dist/{cvcEntry-BqAGctqK.d.ts → cvcEntry-Asg7mxjB.d.ts} +8 -8
package/dist/index.cjs CHANGED
@@ -268,6 +268,9 @@ __export(src_exports, {
268
268
  GoalStatusKeys: () => GoalStatusKeys,
269
269
  GoalWithdrawalReasonKeys: () => GoalWithdrawalReasonKeys,
270
270
  HEALTHCARE_ORG_TYPE_KEYS: () => HEALTHCARE_ORG_TYPE_KEYS,
271
+ HTI_SHARE_PLATFORM_PURPOSE_ENABLED: () => HTI_SHARE_PLATFORM_PURPOSE_ENABLED,
272
+ HTI_SHARE_PLATFORM_STARTER: () => HTI_SHARE_PLATFORM_STARTER,
273
+ HTI_SHARE_PLATFORM_STARTER_SOURCE: () => HTI_SHARE_PLATFORM_STARTER_SOURCE,
271
274
  HairColorKeys: () => HairColorKeys,
272
275
  HasTattoosKeys: () => HasTattoosKeys,
273
276
  HighestEducationLevelCompletedKeys: () => HighestEducationLevelCompletedKeys,
@@ -336,6 +339,7 @@ __export(src_exports, {
336
339
  INCIDENT_PARTICIPATION_ROLE_LABELS: () => INCIDENT_PARTICIPATION_ROLE_LABELS,
337
340
  INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY: () => INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY,
338
341
  INCIDENT_PARTICIPATION_ROLE_VALUES: () => INCIDENT_PARTICIPATION_ROLE_VALUES,
342
+ INFORMATION_SCOPE_FIELD_HOME_ROWS: () => INFORMATION_SCOPE_FIELD_HOME_ROWS,
339
343
  INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE: () => INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE,
340
344
  INFORMATION_SCOPE_READABLE_VERSIONS: () => INFORMATION_SCOPE_READABLE_VERSIONS,
341
345
  INFORMATION_SCOPE_SYSTEM_INFO: () => INFORMATION_SCOPE_SYSTEM_INFO,
@@ -458,6 +462,9 @@ __export(src_exports, {
458
462
  SHARE_VIEW: () => SHARE_VIEW,
459
463
  SHARE_VIEW_LABELS: () => SHARE_VIEW_LABELS,
460
464
  SHARE_VIEW_VALUES: () => SHARE_VIEW_VALUES,
465
+ SHARING_CEILING_DEFAULT_ROW_KEY: () => SHARING_CEILING_DEFAULT_ROW_KEY,
466
+ SHARING_CEILING_EXTERNAL_ROW_KEY: () => SHARING_CEILING_EXTERNAL_ROW_KEY,
467
+ SHARING_CEILING_SCOPE_VERSION: () => SHARING_CEILING_SCOPE_VERSION,
461
468
  SUBMISSION_STATES: () => SUBMISSION_STATES,
462
469
  SUBMISSION_STATE_LABELS: () => SUBMISSION_STATE_LABELS,
463
470
  ServiceAudienceKeys: () => ServiceAudienceKeys,
@@ -551,6 +558,7 @@ __export(src_exports, {
551
558
  carCorrectionReasonSot: () => carCorrectionReason_v1_0_0_default,
552
559
  cascadeExclusions: () => cascadeExclusions,
553
560
  caseShareStateSot: () => caseShareState_v1_0_0_default,
561
+ ceilingCoverage: () => ceilingCoverage,
554
562
  checkInActivitySot: () => checkInActivity_v1_0_0_default,
555
563
  checkInPhaseSot: () => checkInPhase_v1_1_0_default,
556
564
  childBehavioralConcernsSot: () => childBehavioralConcerns_v1_0_0_default,
@@ -593,6 +601,7 @@ __export(src_exports, {
593
601
  determinationLevelSot: () => determinationLevel_v1_0_0_default,
594
602
  disabilitySubtypeSot: () => disabilitySubtype_v1_0_0_default,
595
603
  discretionLevelSot: () => discretionLevel_v1_0_0_default,
604
+ effectiveCeiling: () => effectiveCeiling,
596
605
  emailSchema: () => emailSchema,
597
606
  emergencyContactCallReasonSot: () => emergencyContactCallReason_v1_0_0_default,
598
607
  emergencyContactPermissionsSot: () => emergencyContactPermissions_v1_0_0_default,
@@ -632,6 +641,7 @@ __export(src_exports, {
632
641
  goalWithdrawalReasonSot: () => goalWithdrawalReason_v1_0_0_default,
633
642
  guidanceSchema: () => guidanceSchema,
634
643
  hairColorSot: () => hairColor_v1_0_0_default,
644
+ hasOwnScopeContent: () => hasOwnScopeContent,
635
645
  hasTattoosSot: () => hasTattoos_v1_0_0_default,
636
646
  highestEducationLevelCompletedSot: () => highestEducationLevelCompleted_v1_1_0_default,
637
647
  hivStatusSot: () => hivStatus_v1_0_0_default,
@@ -655,6 +665,7 @@ __export(src_exports, {
655
665
  investigativeRequestTypeSot: () => investigativeRequestType_v1_0_0_default,
656
666
  isAgencyTypeKey: () => isAgencyTypeKey,
657
667
  isCanonEvaluableFunction: () => isCanonEvaluableFunction,
668
+ isCeilingCoverageRow: () => isCeilingCoverageRow,
658
669
  isDeprecatedCoreIndicator: () => isDeprecatedCoreIndicator,
659
670
  isDeprecatedIncidentParticipationRole: () => isDeprecatedIncidentParticipationRole,
660
671
  isHealthcareOrgType: () => isHealthcareOrgType,
@@ -671,6 +682,7 @@ __export(src_exports, {
671
682
  isScopeInstrumentRow: () => isScopeInstrumentRow,
672
683
  isScopeRestRow: () => isScopeRestRow,
673
684
  isSelectableScopeRow: () => isSelectableScopeRow,
685
+ isSharingPurposeDisabled: () => isSharingPurposeDisabled,
674
686
  isStructuredNameType: () => isStructuredNameType,
675
687
  isTransgenderGenderIdentity: () => isTransgenderGenderIdentity,
676
688
  isVictimServingOrgType: () => isVictimServingOrgType,
@@ -684,6 +696,7 @@ __export(src_exports, {
684
696
  livingSituationSot: () => livingSituation_v1_0_0_default,
685
697
  locationTypeSot: () => locationType_v1_0_0_default,
686
698
  maritalStatusLegalSot: () => maritalStatusLegal_v1_0_0_default,
699
+ maskSelectionToCeiling: () => maskSelectionToCeiling,
687
700
  mentalHealthStatusSot: () => mentalHealthStatus_v1_0_0_default,
688
701
  messageReportReasonSot: () => messageReportReason_v1_0_0_default,
689
702
  midStayEventTypeSot: () => midStayEventType_v1_0_0_default,
@@ -763,8 +776,12 @@ __export(src_exports, {
763
776
  roiStatusSot: () => roiStatus_v1_0_0_default,
764
777
  roleContextSot: () => roleContext_v1_0_0_default,
765
778
  romanticRelationshipChangeTypeSot: () => romanticRelationshipChangeType_v1_0_0_default,
779
+ rowsExpandedByCeiling: () => rowsExpandedByCeiling,
780
+ rowsOutsideCeiling: () => rowsOutsideCeiling,
781
+ rowsOverCeiling: () => rowsOverCeiling,
766
782
  rsvpResponseSot: () => rsvpResponse_v1_0_0_default,
767
783
  scopeMigrationsFromSot: () => scopeMigrationsFromSot,
784
+ scopeRowWithinCeiling: () => scopeRowWithinCeiling,
768
785
  scopeRowsFromSot: () => scopeRowsFromSot,
769
786
  scoringConditionSchema: () => scoringConditionSchema,
770
787
  scoringRecommendationSchema: () => scoringRecommendationSchema,
@@ -792,6 +809,9 @@ __export(src_exports, {
792
809
  sexProviderSubroleSot: () => sexProviderSubrole_v1_0_0_default,
793
810
  sharePurposeSot: () => sharePurpose_v1_0_0_default,
794
811
  shareResponseReasonSot: () => shareResponseReason_v1_0_0_default,
812
+ sharingCeilingCellList: () => sharingCeilingCellList,
813
+ sharingCeilingRowKey: () => sharingCeilingRowKey,
814
+ sharingScopeEditsFromCells: () => sharingScopeEditsFromCells,
795
815
  signatureMethodSot: () => signatureMethod_v1_0_0_default,
796
816
  signatureTypeSot: () => signatureType_v1_0_0_default,
797
817
  smtBodyLocationSot: () => smtBodyLocation_v1_0_0_default,
@@ -13914,11 +13934,11 @@ function createInformationScopeResolver(input) {
13914
13934
  });
13915
13935
  migrations.set(m.from, perCode);
13916
13936
  }
13917
- const normalize = (codes, withSystemInfo = true) => {
13937
+ const normalize = (codes, withSystemInfo2 = true) => {
13918
13938
  const seen = /* @__PURE__ */ new Set();
13919
13939
  const known = [];
13920
13940
  const unknown = [];
13921
- const all = withSystemInfo ? [INFORMATION_SCOPE_SYSTEM_INFO, ...codes] : [...codes];
13941
+ const all = withSystemInfo2 ? [INFORMATION_SCOPE_SYSTEM_INFO, ...codes] : [...codes];
13922
13942
  for (const c of all) {
13923
13943
  if (seen.has(c)) continue;
13924
13944
  seen.add(c);
@@ -14547,6 +14567,421 @@ function codebookDefaultBound(functionCode, roleCode) {
14547
14567
  return Object.hasOwn(roles, roleCode) ? roles[roleCode] : null;
14548
14568
  }
14549
14569
 
14570
+ // src/generated/sharingPlatformStarter.ts
14571
+ var SHARING_PLATFORM_STARTER_SOURCE = {
14572
+ "monolith": {
14573
+ "repo": "htilabstech/prototype",
14574
+ "file": "HTI-LEADS-PAVE-Thread-prototype.html",
14575
+ "sha": "d85f05b7",
14576
+ "lines": [
14577
+ 326475,
14578
+ 326543
14579
+ ]
14580
+ },
14581
+ "mirror": {
14582
+ "repo": "htilabstech/platform-prototype",
14583
+ "file": "src/data.js",
14584
+ "sha": "a6f1f3a5",
14585
+ "starterLines": [
14586
+ 38170,
14587
+ 38190
14588
+ ],
14589
+ "purposeLines": [
14590
+ 32450,
14591
+ 32531
14592
+ ]
14593
+ },
14594
+ "fieldPlacements": {
14595
+ "repo": "htilabstech/prototype",
14596
+ "file": "docs/share-roi/information_scope_v4.fields.csv",
14597
+ "sha": "d85f05b7"
14598
+ }
14599
+ };
14600
+ var SHARING_PLATFORM_STARTER_DATA = {
14601
+ scopeVersion: 4,
14602
+ scopeByPurpose: {
14603
+ "referral": ["identifying", "contact", "services", "system", "summary_needs_assessment"],
14604
+ "case_collaboration": ["identifying", "risk", "contact", "services", "notes", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_needs_assessment"],
14605
+ "deconfliction": ["identifying", "system"],
14606
+ "mandatory_reporting": ["identifying", "risk", "contact", "services", "notes", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_needs_assessment", "offenders.identifying", "offenders.risk", "relationships_household", "family"],
14607
+ "discretionary_share": ["identifying", "system"],
14608
+ "authority_reporting": ["identifying", "risk", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "offenders.identifying", "offenders.risk", "relationships_household", "family"],
14609
+ "automatic_account_share": ["identifying", "system"],
14610
+ "records_request": ["identifying", "system"]
14611
+ },
14612
+ counterpartyOverrides: {
14613
+ "palomar": {
14614
+ "case_collaboration": ["identifying", "risk", "contact", "services", "notes", "health_accommodation", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_mental_health_screen", "summary_behavioral_health_intake", "summary_trauma_and_coping_screen", "summary_needs_assessment"]
14615
+ },
14616
+ "okcpd": {
14617
+ "mandatory_reporting": ["identifying", "risk", "contact", "services", "notes", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_needs_assessment", "offenders.identifying", "offenders.risk", "relationships_household", "family"],
14618
+ "referral": ["identifying", "contact", "services", "system", "summary_needs_assessment"]
14619
+ },
14620
+ "legal_aid_ok": {
14621
+ "referral": ["identifying", "contact", "services", "notes", "system", "summary_needs_assessment"]
14622
+ }
14623
+ },
14624
+ purposeEnabled: {
14625
+ "referral": true,
14626
+ "case_collaboration": true,
14627
+ "deconfliction": true,
14628
+ "mandatory_reporting": true,
14629
+ "discretionary_share": true,
14630
+ "authority_reporting": true,
14631
+ "automatic_account_share": true,
14632
+ "records_request": false
14633
+ },
14634
+ fieldHomeRows: [
14635
+ "accommodation_needs",
14636
+ "ad_content",
14637
+ "additional_ids",
14638
+ "addresses",
14639
+ "case_attachments",
14640
+ "case_determinations",
14641
+ "case_lifecycle",
14642
+ "case_notes",
14643
+ "commercial_activity",
14644
+ "contact_info",
14645
+ "demographics",
14646
+ "derived_risk_signals",
14647
+ "dob",
14648
+ "encounter_location",
14649
+ "family.health_accommodation",
14650
+ "family.identifying",
14651
+ "family.risk",
14652
+ "full_ae_intake",
14653
+ "full_behavioral_health_intake",
14654
+ "full_danger_assessment",
14655
+ "full_findings",
14656
+ "full_hope_scale",
14657
+ "full_ida",
14658
+ "full_initial_screen",
14659
+ "full_injury_and_strangulation",
14660
+ "full_lap",
14661
+ "full_mental_health_screen",
14662
+ "full_needs_assessment",
14663
+ "full_stalking_assessment",
14664
+ "full_tra",
14665
+ "full_trauma_and_coping_screen",
14666
+ "health_status",
14667
+ "identifying",
14668
+ "immigration_applications",
14669
+ "immigration_status",
14670
+ "instruments",
14671
+ "names",
14672
+ "network_membership",
14673
+ "object_identity_attributes",
14674
+ "offenders.risk",
14675
+ "others.risk",
14676
+ "persona_links",
14677
+ "phone_identifiers",
14678
+ "plans_goals",
14679
+ "priorities_safety",
14680
+ "relationships_household",
14681
+ "screen_indicators",
14682
+ "service_history",
14683
+ "session_summary",
14684
+ "summary_ae_intake",
14685
+ "summary_behavioral_health_intake",
14686
+ "summary_danger_assessment",
14687
+ "summary_findings",
14688
+ "summary_hope_scale",
14689
+ "summary_ida",
14690
+ "summary_initial_screen",
14691
+ "summary_injury_and_strangulation",
14692
+ "summary_lap",
14693
+ "summary_mental_health_screen",
14694
+ "summary_needs_assessment",
14695
+ "summary_stalking_assessment",
14696
+ "summary_tra",
14697
+ "summary_trauma_and_coping_screen",
14698
+ "system",
14699
+ "system_involvement",
14700
+ "victimization"
14701
+ ]
14702
+ };
14703
+
14704
+ // src/sharingCeiling/starter.ts
14705
+ var SHARING_CEILING_SCOPE_VERSION = 4;
14706
+ function freezeLists(lists) {
14707
+ const out = {};
14708
+ for (const [purpose, codes] of Object.entries(lists)) out[purpose] = Object.freeze([...codes]);
14709
+ return Object.freeze(out);
14710
+ }
14711
+ var HTI_SHARE_PLATFORM_STARTER = Object.freeze({
14712
+ scopeVersion: SHARING_CEILING_SCOPE_VERSION,
14713
+ scopeByPurpose: freezeLists(SHARING_PLATFORM_STARTER_DATA.scopeByPurpose),
14714
+ counterpartyOverrides: Object.freeze(
14715
+ Object.fromEntries(
14716
+ Object.entries(SHARING_PLATFORM_STARTER_DATA.counterpartyOverrides).map(([cp, lists]) => [
14717
+ cp,
14718
+ freezeLists(lists)
14719
+ ])
14720
+ )
14721
+ )
14722
+ });
14723
+ var HTI_SHARE_PLATFORM_PURPOSE_ENABLED = Object.freeze({
14724
+ ...SHARING_PLATFORM_STARTER_DATA.purposeEnabled
14725
+ });
14726
+ var INFORMATION_SCOPE_FIELD_HOME_ROWS = new Set(
14727
+ SHARING_PLATFORM_STARTER_DATA.fieldHomeRows
14728
+ );
14729
+ var HTI_SHARE_PLATFORM_STARTER_SOURCE = SHARING_PLATFORM_STARTER_SOURCE;
14730
+
14731
+ // src/sharingCeiling/chain.ts
14732
+ var SHARING_CEILING_DEFAULT_ROW_KEY = "__default__";
14733
+ var SHARING_CEILING_EXTERNAL_ROW_KEY = "__external__";
14734
+ var own2 = (record, key) => record !== null && typeof record === "object" && Object.prototype.hasOwnProperty.call(record, key) ? record[key] : void 0;
14735
+ var isStringList = (v) => Array.isArray(v) && v.every((c) => typeof c === "string");
14736
+ function sharingCeilingCellList(cell) {
14737
+ if (cell.scopeVersion === SHARING_CEILING_SCOPE_VERSION && isStringList(cell.informationScope)) {
14738
+ return [...cell.informationScope];
14739
+ }
14740
+ return [];
14741
+ }
14742
+ var sameSet = (a, b) => {
14743
+ const sa = new Set(a);
14744
+ const sb = new Set(b);
14745
+ return sa.size === sb.size && [...sa].every((c) => sb.has(c));
14746
+ };
14747
+ function sharingScopeEditsFromCells(cells) {
14748
+ const byRow = /* @__PURE__ */ new Map();
14749
+ if (cells === null || cells === void 0 || typeof cells[Symbol.iterator] !== "function") {
14750
+ return {};
14751
+ }
14752
+ for (const cell of cells) {
14753
+ if (cell === null || typeof cell !== "object") continue;
14754
+ const { rowKey, purpose } = cell;
14755
+ if (typeof rowKey !== "string" || rowKey === "" || typeof purpose !== "string" || purpose === "") continue;
14756
+ const list = sharingCeilingCellList(cell);
14757
+ const row = byRow.get(rowKey) ?? /* @__PURE__ */ new Map();
14758
+ const prior = row.get(purpose);
14759
+ row.set(purpose, prior === void 0 || sameSet(prior, list) ? list : []);
14760
+ byRow.set(rowKey, row);
14761
+ }
14762
+ return Object.fromEntries([...byRow].map(([k, row]) => [k, Object.fromEntries(row)]));
14763
+ }
14764
+ function rungList(value) {
14765
+ if (value === void 0 || value === null) return void 0;
14766
+ return isStringList(value) ? [...value] : [];
14767
+ }
14768
+ function isSharingPurposeDisabled(purpose, purposeOverrides, purposeEnabled) {
14769
+ const override = own2(purposeOverrides, purpose);
14770
+ if (override === false) return true;
14771
+ const callerRow = own2(purposeEnabled, purpose);
14772
+ const enabled = typeof callerRow === "boolean" ? callerRow : own2(HTI_SHARE_PLATFORM_PURPOSE_ENABLED, purpose);
14773
+ return enabled === false && override !== true;
14774
+ }
14775
+ function sharingCeilingRowKey(recipient) {
14776
+ if (recipient.external === true) return SHARING_CEILING_EXTERNAL_ROW_KEY;
14777
+ const id = recipient.id;
14778
+ if (typeof id !== "string" || id === "") {
14779
+ throw new TypeError("sharing ceiling: an on-platform recipient needs a partner id");
14780
+ }
14781
+ if (id === SHARING_CEILING_DEFAULT_ROW_KEY || id === SHARING_CEILING_EXTERNAL_ROW_KEY) {
14782
+ throw new RangeError(`sharing ceiling: "${id}" is a reserved row key, not a partner id`);
14783
+ }
14784
+ return id;
14785
+ }
14786
+ function effectiveCeiling(rowKey, purpose, inputs) {
14787
+ if (typeof rowKey !== "string" || rowKey === "") {
14788
+ throw new TypeError("sharing ceiling: rowKey must be a partner id or __external__");
14789
+ }
14790
+ if (rowKey === SHARING_CEILING_DEFAULT_ROW_KEY) {
14791
+ throw new RangeError("sharing ceiling: __default__ is the account default, not a recipient row key");
14792
+ }
14793
+ if (typeof purpose !== "string" || purpose === "") {
14794
+ throw new TypeError("sharing ceiling: purpose must be a share purpose code");
14795
+ }
14796
+ const starter = inputs.starter ?? HTI_SHARE_PLATFORM_STARTER;
14797
+ if (isSharingPurposeDisabled(purpose, inputs.purposeOverrides, inputs.purposeEnabled)) {
14798
+ return { allowed: [], rung: "purpose_disabled", disabled: true };
14799
+ }
14800
+ const edits = inputs.edits;
14801
+ const rungs = [
14802
+ ["partner_rule", own2(own2(edits, rowKey), purpose)],
14803
+ ["seeded_partner_rule", own2(own2(starter.counterpartyOverrides, rowKey), purpose)],
14804
+ ["account_default", own2(own2(edits, SHARING_CEILING_DEFAULT_ROW_KEY), purpose)],
14805
+ ["platform_default", own2(starter.scopeByPurpose, purpose)]
14806
+ ];
14807
+ for (const [rung, value] of rungs) {
14808
+ const allowed = rungList(value);
14809
+ if (allowed !== void 0) return { allowed, rung, disabled: false };
14810
+ }
14811
+ return { allowed: [], rung: "none", disabled: false };
14812
+ }
14813
+
14814
+ // src/sharingCeiling/coverage.ts
14815
+ var factsCache = /* @__PURE__ */ new WeakMap();
14816
+ function memoize(fn) {
14817
+ const memo = /* @__PURE__ */ new Map();
14818
+ return (code) => {
14819
+ if (memo.has(code)) return memo.get(code);
14820
+ const out = fn(code);
14821
+ memo.set(code, out);
14822
+ return out;
14823
+ };
14824
+ }
14825
+ function treeFacts(scope) {
14826
+ const hit = factsCache.get(scope);
14827
+ if (hit) return hit;
14828
+ const systemPath = scope.ancestorsOf(INFORMATION_SCOPE_SYSTEM_INFO);
14829
+ const systemRoot = systemPath.length > 0 ? systemPath[systemPath.length - 1] : void 0;
14830
+ const isLive = memoize(
14831
+ (code) => scope.row(code) !== void 0 && scope.ancestorsOf(code).every((c) => scope.row(c)?.status !== "retired")
14832
+ );
14833
+ const isSystem = memoize(
14834
+ (code) => systemRoot !== void 0 && scope.ancestorsOf(code).includes(systemRoot)
14835
+ );
14836
+ const underFloor = memoize(
14837
+ (code) => scope.ancestorsOf(code).some((c) => scope.row(c)?.platformFloor === true)
14838
+ );
14839
+ const isCoverageRow = memoize((code) => isLive(code) && !isSystem(code) && !underFloor(code));
14840
+ const coverageChildren = memoize(
14841
+ (code) => Object.freeze(scope.childrenOf(code).filter(isCoverageRow))
14842
+ );
14843
+ const hasOwnContent = memoize((code) => {
14844
+ const row = scope.row(code);
14845
+ if (row === void 0) return false;
14846
+ const homed = INFORMATION_SCOPE_FIELD_HOME_ROWS.has(code) || row.kindRow !== void 0 && INFORMATION_SCOPE_FIELD_HOME_ROWS.has(row.kindRow);
14847
+ if (!homed) return false;
14848
+ return !scope.childrenOf(code).some((c) => scope.row(c)?.rowType === "category_rest" && isLive(c));
14849
+ });
14850
+ const facts = {
14851
+ isLive,
14852
+ isSystem,
14853
+ underFloor,
14854
+ isCoverageRow,
14855
+ coverageChildren,
14856
+ hasOwnContent
14857
+ };
14858
+ factsCache.set(scope, facts);
14859
+ return facts;
14860
+ }
14861
+ function asCeilingSet(allowed) {
14862
+ if (allowed === null) return null;
14863
+ if (allowed instanceof Set) return allowed;
14864
+ if (Array.isArray(allowed)) {
14865
+ return new Set(allowed.filter((c) => typeof c === "string"));
14866
+ }
14867
+ return /* @__PURE__ */ new Set();
14868
+ }
14869
+ function isCeilingCoverageRow(scope, code) {
14870
+ return treeFacts(scope).isCoverageRow(code);
14871
+ }
14872
+ function hasOwnScopeContent(scope, code) {
14873
+ return treeFacts(scope).hasOwnContent(code);
14874
+ }
14875
+ function ceilingCoverage(scope, allowed) {
14876
+ const facts = treeFacts(scope);
14877
+ const set = asCeilingSet(allowed);
14878
+ const memo = /* @__PURE__ */ new Map();
14879
+ const within = (code) => {
14880
+ const hit = memo.get(code);
14881
+ if (hit !== void 0) return hit;
14882
+ let out;
14883
+ if (!facts.isLive(code)) out = false;
14884
+ else if (set === null) out = true;
14885
+ else if (scope.ancestorsOf(code).some((c) => set.has(c))) out = true;
14886
+ else if (facts.hasOwnContent(code)) out = false;
14887
+ else {
14888
+ const kids = facts.coverageChildren(code);
14889
+ out = kids.length > 0 && kids.every(within);
14890
+ }
14891
+ memo.set(code, out);
14892
+ return out;
14893
+ };
14894
+ return within;
14895
+ }
14896
+ function scopeRowWithinCeiling(scope, allowed, code) {
14897
+ return ceilingCoverage(scope, allowed)(code);
14898
+ }
14899
+ function rowsOverCeiling(scope, declared, allowed) {
14900
+ const facts = treeFacts(scope);
14901
+ const within = ceilingCoverage(scope, allowed);
14902
+ const out = [];
14903
+ for (const code of new Set(Array.isArray(declared) ? declared : [])) {
14904
+ if (code === INFORMATION_SCOPE_SYSTEM_INFO) continue;
14905
+ if (!facts.isLive(code)) {
14906
+ out.push(code);
14907
+ continue;
14908
+ }
14909
+ if (facts.isSystem(code) || facts.underFloor(code)) continue;
14910
+ if (!within(code)) out.push(code);
14911
+ }
14912
+ return out;
14913
+ }
14914
+ function walkCeiling(scope, allowed) {
14915
+ const facts = treeFacts(scope);
14916
+ if (asCeilingSet(allowed) === null) return { outside: [], expanded: [] };
14917
+ const within = ceilingCoverage(scope, allowed);
14918
+ const holdsMemo = /* @__PURE__ */ new Map();
14919
+ const holdsWithin = (code) => {
14920
+ const hit = holdsMemo.get(code);
14921
+ if (hit !== void 0) return hit;
14922
+ const out = scope.childrenOf(code).some((c) => facts.isCoverageRow(c) && within(c) || holdsWithin(c));
14923
+ holdsMemo.set(code, out);
14924
+ return out;
14925
+ };
14926
+ const outside = [];
14927
+ const expanded = [];
14928
+ const visit = (code) => {
14929
+ if (!facts.isLive(code) || within(code)) return;
14930
+ if (!holdsWithin(code)) {
14931
+ outside.push(code);
14932
+ return;
14933
+ }
14934
+ if (facts.hasOwnContent(code)) expanded.push(code);
14935
+ for (const child of scope.childrenOf(code)) visit(child);
14936
+ };
14937
+ for (const r of scope.rows) {
14938
+ if (r.parentScopeCode !== null && r.parentScopeCode !== "") continue;
14939
+ if (facts.isSystem(r.scopeCode)) continue;
14940
+ visit(r.scopeCode);
14941
+ }
14942
+ return { outside, expanded };
14943
+ }
14944
+ function rowsOutsideCeiling(scope, allowed) {
14945
+ return walkCeiling(scope, allowed).outside;
14946
+ }
14947
+ function rowsExpandedByCeiling(scope, allowed) {
14948
+ return walkCeiling(scope, allowed).expanded;
14949
+ }
14950
+ function withSystemInfo(codes) {
14951
+ return [.../* @__PURE__ */ new Set([INFORMATION_SCOPE_SYSTEM_INFO, ...codes])];
14952
+ }
14953
+ function subtractRow(scope, selection, code) {
14954
+ const path = scope.ancestorsOf(code);
14955
+ let sel = selection.filter((c) => !scope.ancestorsOf(c).includes(code));
14956
+ for (; ; ) {
14957
+ const coverAt = path.findIndex((c, i) => i > 0 && sel.includes(c));
14958
+ if (coverAt === -1) break;
14959
+ sel = sel.filter((c) => c !== path[coverAt]);
14960
+ for (let i = coverAt; i >= 1; i -= 1) {
14961
+ const parent = path[i];
14962
+ const onPath = path[i - 1];
14963
+ for (const child of scope.childrenOf(parent)) {
14964
+ if (child !== onPath && !sel.includes(child)) sel.push(child);
14965
+ }
14966
+ }
14967
+ }
14968
+ return sel;
14969
+ }
14970
+ function maskSelectionToCeiling(scope, selection, allowed) {
14971
+ const facts = treeFacts(scope);
14972
+ const { outside, expanded } = walkCeiling(scope, allowed);
14973
+ let sel = (Array.isArray(selection) ? selection : []).filter(
14974
+ (c) => typeof c === "string" && facts.isLive(c)
14975
+ );
14976
+ for (const code of expanded) {
14977
+ if (!scope.ancestorsOf(code).some((c) => sel.includes(c))) continue;
14978
+ sel = subtractRow(scope, sel, code);
14979
+ for (const child of scope.childrenOf(code)) if (!sel.includes(child)) sel.push(child);
14980
+ }
14981
+ for (const code of outside) sel = subtractRow(scope, sel, code);
14982
+ return withSystemInfo(sel.filter((c) => facts.isLive(c)));
14983
+ }
14984
+
14550
14985
  // src/validation/cvc.ts
14551
14986
  var import_zod = require("zod");
14552
14987
  var CvcCodeSchema = import_zod.z.string().regex(/^\d{3}(-\d{3}){6}$/);
@@ -64032,6 +64467,9 @@ var CVC_197_VALUES = selectableCodes(
64032
64467
  GoalStatusKeys,
64033
64468
  GoalWithdrawalReasonKeys,
64034
64469
  HEALTHCARE_ORG_TYPE_KEYS,
64470
+ HTI_SHARE_PLATFORM_PURPOSE_ENABLED,
64471
+ HTI_SHARE_PLATFORM_STARTER,
64472
+ HTI_SHARE_PLATFORM_STARTER_SOURCE,
64035
64473
  HairColorKeys,
64036
64474
  HasTattoosKeys,
64037
64475
  HighestEducationLevelCompletedKeys,
@@ -64100,6 +64538,7 @@ var CVC_197_VALUES = selectableCodes(
64100
64538
  INCIDENT_PARTICIPATION_ROLE_LABELS,
64101
64539
  INCIDENT_PARTICIPATION_ROLE_SUPERSEDED_BY,
64102
64540
  INCIDENT_PARTICIPATION_ROLE_VALUES,
64541
+ INFORMATION_SCOPE_FIELD_HOME_ROWS,
64103
64542
  INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE,
64104
64543
  INFORMATION_SCOPE_READABLE_VERSIONS,
64105
64544
  INFORMATION_SCOPE_SYSTEM_INFO,
@@ -64222,6 +64661,9 @@ var CVC_197_VALUES = selectableCodes(
64222
64661
  SHARE_VIEW,
64223
64662
  SHARE_VIEW_LABELS,
64224
64663
  SHARE_VIEW_VALUES,
64664
+ SHARING_CEILING_DEFAULT_ROW_KEY,
64665
+ SHARING_CEILING_EXTERNAL_ROW_KEY,
64666
+ SHARING_CEILING_SCOPE_VERSION,
64225
64667
  SUBMISSION_STATES,
64226
64668
  SUBMISSION_STATE_LABELS,
64227
64669
  ServiceAudienceKeys,
@@ -64315,6 +64757,7 @@ var CVC_197_VALUES = selectableCodes(
64315
64757
  carCorrectionReasonSot,
64316
64758
  cascadeExclusions,
64317
64759
  caseShareStateSot,
64760
+ ceilingCoverage,
64318
64761
  checkInActivitySot,
64319
64762
  checkInPhaseSot,
64320
64763
  childBehavioralConcernsSot,
@@ -64357,6 +64800,7 @@ var CVC_197_VALUES = selectableCodes(
64357
64800
  determinationLevelSot,
64358
64801
  disabilitySubtypeSot,
64359
64802
  discretionLevelSot,
64803
+ effectiveCeiling,
64360
64804
  emailSchema,
64361
64805
  emergencyContactCallReasonSot,
64362
64806
  emergencyContactPermissionsSot,
@@ -64396,6 +64840,7 @@ var CVC_197_VALUES = selectableCodes(
64396
64840
  goalWithdrawalReasonSot,
64397
64841
  guidanceSchema,
64398
64842
  hairColorSot,
64843
+ hasOwnScopeContent,
64399
64844
  hasTattoosSot,
64400
64845
  highestEducationLevelCompletedSot,
64401
64846
  hivStatusSot,
@@ -64419,6 +64864,7 @@ var CVC_197_VALUES = selectableCodes(
64419
64864
  investigativeRequestTypeSot,
64420
64865
  isAgencyTypeKey,
64421
64866
  isCanonEvaluableFunction,
64867
+ isCeilingCoverageRow,
64422
64868
  isDeprecatedCoreIndicator,
64423
64869
  isDeprecatedIncidentParticipationRole,
64424
64870
  isHealthcareOrgType,
@@ -64435,6 +64881,7 @@ var CVC_197_VALUES = selectableCodes(
64435
64881
  isScopeInstrumentRow,
64436
64882
  isScopeRestRow,
64437
64883
  isSelectableScopeRow,
64884
+ isSharingPurposeDisabled,
64438
64885
  isStructuredNameType,
64439
64886
  isTransgenderGenderIdentity,
64440
64887
  isVictimServingOrgType,
@@ -64448,6 +64895,7 @@ var CVC_197_VALUES = selectableCodes(
64448
64895
  livingSituationSot,
64449
64896
  locationTypeSot,
64450
64897
  maritalStatusLegalSot,
64898
+ maskSelectionToCeiling,
64451
64899
  mentalHealthStatusSot,
64452
64900
  messageReportReasonSot,
64453
64901
  midStayEventTypeSot,
@@ -64527,8 +64975,12 @@ var CVC_197_VALUES = selectableCodes(
64527
64975
  roiStatusSot,
64528
64976
  roleContextSot,
64529
64977
  romanticRelationshipChangeTypeSot,
64978
+ rowsExpandedByCeiling,
64979
+ rowsOutsideCeiling,
64980
+ rowsOverCeiling,
64530
64981
  rsvpResponseSot,
64531
64982
  scopeMigrationsFromSot,
64983
+ scopeRowWithinCeiling,
64532
64984
  scopeRowsFromSot,
64533
64985
  scoringConditionSchema,
64534
64986
  scoringRecommendationSchema,
@@ -64556,6 +65008,9 @@ var CVC_197_VALUES = selectableCodes(
64556
65008
  sexProviderSubroleSot,
64557
65009
  sharePurposeSot,
64558
65010
  shareResponseReasonSot,
65011
+ sharingCeilingCellList,
65012
+ sharingCeilingRowKey,
65013
+ sharingScopeEditsFromCells,
64559
65014
  signatureMethodSot,
64560
65015
  signatureTypeSot,
64561
65016
  smtBodyLocationSot,