@htilabs/platform-common-models 0.17.0 → 0.18.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 (71) hide show
  1. package/dist/agency-BHv54o79.d.ts +484 -0
  2. package/dist/agency-Ca4pCOOf.d.ts +342 -0
  3. package/dist/agency-DYCv839V.d.cts +342 -0
  4. package/dist/agency-Djp57S71.d.cts +484 -0
  5. package/dist/constants/index.cjs +952 -0
  6. package/dist/constants/index.cjs.map +1 -1
  7. package/dist/constants/index.d.cts +3 -1
  8. package/dist/constants/index.d.ts +3 -1
  9. package/dist/constants/index.js +920 -0
  10. package/dist/constants/index.js.map +1 -1
  11. package/dist/{cvcEntry-ctHTp2df.d.cts → cvcEntry-0BIB9sen.d.cts} +36 -36
  12. package/dist/{cvcEntry-ctHTp2df.d.ts → cvcEntry-0BIB9sen.d.ts} +36 -36
  13. package/dist/cvcs/index.cjs +114 -62
  14. package/dist/cvcs/index.cjs.map +1 -1
  15. package/dist/cvcs/index.d.cts +112 -59
  16. package/dist/cvcs/index.d.ts +112 -59
  17. package/dist/cvcs/index.js +114 -62
  18. package/dist/cvcs/index.js.map +1 -1
  19. package/dist/enums/index.cjs +1 -0
  20. package/dist/enums/index.cjs.map +1 -1
  21. package/dist/enums/index.d.cts +2 -1
  22. package/dist/enums/index.d.ts +2 -1
  23. package/dist/enums/index.js +1 -0
  24. package/dist/enums/index.js.map +1 -1
  25. package/dist/{index-4DiJrn7y.d.ts → index-CDoqrfc1.d.ts} +1 -1
  26. package/dist/{index-qreOzXYS.d.cts → index-Zu_mOJRn.d.cts} +1 -1
  27. package/dist/index.cjs +1654 -1077
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +6 -4
  30. package/dist/index.d.ts +6 -4
  31. package/dist/index.js +1600 -1076
  32. package/dist/index.js.map +1 -1
  33. package/dist/models/index.d.cts +2 -2
  34. package/dist/models/index.d.ts +2 -2
  35. package/dist/org-type-BYQb9Qzq.d.ts +366 -0
  36. package/dist/org-type-D_FG4KdN.d.cts +366 -0
  37. package/dist/{platform-auth-CrF5U_JH.d.cts → platform-auth-CvAYFVhK.d.cts} +39 -0
  38. package/dist/{platform-auth-CrF5U_JH.d.ts → platform-auth-CvAYFVhK.d.ts} +39 -0
  39. package/dist/schemas/index.cjs +977 -2
  40. package/dist/schemas/index.cjs.map +1 -1
  41. package/dist/schemas/index.d.cts +14 -11
  42. package/dist/schemas/index.d.ts +14 -11
  43. package/dist/schemas/index.js +962 -1
  44. package/dist/schemas/index.js.map +1 -1
  45. package/dist/types/index.d.cts +2 -2
  46. package/dist/types/index.d.ts +2 -2
  47. package/dist/validation/index.cjs +894 -2
  48. package/dist/validation/index.cjs.map +1 -1
  49. package/dist/validation/index.d.cts +5 -1
  50. package/dist/validation/index.d.ts +5 -1
  51. package/dist/validation/index.js +884 -1
  52. package/dist/validation/index.js.map +1 -1
  53. package/package.json +26 -27
  54. package/src/__tests__/__snapshots__/cvc-sot.snap +2 -2
  55. package/src/__tests__/cvc-sot-snapshot.test.ts +5 -5
  56. package/src/__tests__/cvc-structural.test.ts +1 -1
  57. package/src/__tests__/org-type-contract.test.ts +1353 -0
  58. package/src/__tests__/referral-entity-category-canon.test.ts +255 -81
  59. package/src/constants/ic.ts +45 -0
  60. package/src/constants/index.ts +1 -0
  61. package/src/constants/org-type.ts +703 -0
  62. package/src/cvcs/index.ts +1 -1
  63. package/src/cvcs/{referralEntityCategory.v1.1.0.json → referralEntityCategory.v1.2.0.json} +111 -59
  64. package/src/generated/cvc-enums.ts +2 -1
  65. package/src/index.ts +23 -0
  66. package/src/schemas/agency.ts +481 -0
  67. package/src/schemas/index.ts +24 -0
  68. package/src/validation/agency.ts +119 -0
  69. package/src/validation/index.ts +1 -0
  70. package/dist/team-C4LJ5Tex.d.cts +0 -333
  71. package/dist/team-C4LJ5Tex.d.ts +0 -333
@@ -4835,10 +4835,964 @@ function buildCvcEntrySchema() {
4835
4835
  return schema;
4836
4836
  }
4837
4837
  var _cvcEntrySchema = buildCvcEntrySchema();
4838
+
4839
+ // src/schemas/agency.ts
4840
+ import { Error as MongooseError } from "mongoose";
4841
+
4842
+ // src/cvcs/referralEntityCategory.v1.2.0.json
4843
+ var referralEntityCategory_v1_2_0_default = {
4844
+ domain: "referral_entity_category",
4845
+ name: "Core Referral Entity Category",
4846
+ version: "1.2.0",
4847
+ _status: "CANONICAL \u2014 Notion CVC-48 `core-referral_entity_category` (IC-58), status Active (full audit 2026-08-20, CVC48_IC58_REFERRAL_ENTITY_CATEGORY_AUDIT; `Date of last audit` 2026-09-01). Re-mirrored from prototype canon yaml v1.3 @ f1321e47 and the live Notion codebook (46 rows, compared row by row 2026-10-05). SUPERSEDES referralEntityCategory v1.0.0 (platform-common <= 0.13.0), which predated the audit. ADDITIVE: no v1.0.0 key is removed and no v1.0.0 positional code changes. ADDED (4): `adult_protective_services` (02-03-06-00), `school_academic_institution` (02-05-01-00), `legal_services_provider` (02-06-04-00), and since 0.18.0 `hotline` (02-02-01-00, canon's selectable Level-2 parent of the two hotline children) at the next free ordinal 048-006-003 with `national_hotline` / `local_other_hotline` RE-PARENTED under it \u2014 their codes are unchanged (a positional code is identity, `parentCode` is hierarchy). SELECTABLE follows canon on two rows: `education` is now a non-selectable heading (its leaf is `school_academic_institution`, which carries the HMIS R1 School rollup \u2014 ruled 2026-08-20) and `law_enforcement` is now selectable (canon Level 2 Required; its five children are optional depth). A stored `education` is still a valid key. `title` and `definition` are canon's, verbatim (yaml `name` / `definition`; the live Notion wording where the two differ: the Adult Protective Services label, the quotation marks in the Victim service provider definition, and the wording of the residual Community-based provider definition); the Level-0 rows keep the package's house missingness titles. `justice_protective_systems` no longer carries the package-authored definition v1.0.0 gave it: canon's heading (02-03-00-00) has none. Every canon-backed row carries canon's 4-segment code as `canonicalCode`; the package's own positional codes are unchanged and are NOT canon's. NOT carried: canon `hmis_r1_code` / `hmis_r1_mapping`, `required`, `voca_ovc_pmt_bucket`, `pave_2025_mapping`, `logic_notes`, `mappings_notes` (v1.0.0 carried none of them). CARRIED since 0.18.0: canon `enum_constant` as `enumConstant` on every canon-backed row (the Sean-spec constant the org registry / `agencies.typeId` spell the type with). Generated by scripts/gen-referral-entity-category.py \u2014 do not hand-edit.",
4848
+ _source: "htilabstech/prototype/data/cvcs/core_referral_entity_category.yaml @ f1321e47 (Notion CVC-48, yaml v1.3; read from origin/main) + Notion codebook collection://3181ef14-abcd-8081-95b5-000bc30a73bd (wording of 3 cells, compared 2026-10-05)",
4849
+ _supersedes: {
4850
+ version: "1.0.0",
4851
+ keyMap: {
4852
+ missingness_root: "missingness_root",
4853
+ unknown: "unknown",
4854
+ anonymous: "anonymous",
4855
+ data_not_collected: "data_not_collected",
4856
+ self_referred: "self_referred",
4857
+ family_guardian_friend: "family_guardian_friend",
4858
+ peer: "peer",
4859
+ other_individual: "other_individual",
4860
+ housing_shelter_continuum: "housing_shelter_continuum",
4861
+ outreach_project: "outreach_project",
4862
+ temporary_shelter: "temporary_shelter",
4863
+ residential_project: "residential_project",
4864
+ hotlines: "hotlines",
4865
+ national_hotline: "national_hotline",
4866
+ local_other_hotline: "local_other_hotline",
4867
+ justice_protective_systems: "justice_protective_systems",
4868
+ child_welfare_cps: "child_welfare_cps",
4869
+ juvenile_justice: "juvenile_justice",
4870
+ law_enforcement: "law_enforcement",
4871
+ local_law_enforcement: "local_law_enforcement",
4872
+ state_law_enforcement: "state_law_enforcement",
4873
+ federal_law_enforcement: "federal_law_enforcement",
4874
+ tribal_law_enforcement: "tribal_law_enforcement",
4875
+ other_law_enforcement: "other_law_enforcement",
4876
+ courts_prosecution: "courts_prosecution",
4877
+ correction_probation: "correction_probation",
4878
+ health_behavioral_health: "health_behavioral_health",
4879
+ inpatient_psychiatric_facility: "inpatient_psychiatric_facility",
4880
+ healthcare_provider: "healthcare_provider",
4881
+ education: "education",
4882
+ victim_community_service_providers: "victim_community_service_providers",
4883
+ child_advocacy_center: "child_advocacy_center",
4884
+ victim_service_provider: "victim_service_provider",
4885
+ community_based_service_provider: "community_based_service_provider",
4886
+ coordination_governance: "coordination_governance",
4887
+ mdt: "mdt",
4888
+ coalition: "coalition",
4889
+ internal: "internal",
4890
+ own_agency_internal: "own_agency_internal",
4891
+ other_entity: "other_entity",
4892
+ employer: "employer",
4893
+ benefits_public_assistance_office: "benefits_public_assistance_office",
4894
+ other_organization: "other_organization"
4895
+ },
4896
+ retiredCodes: [],
4897
+ notes: {
4898
+ education: "v1.0.0 `education` was a selectable leaf. Canon makes Education a heading whose only leaf is School / academic institution. `education` stays a valid stored key (now `selectable: false`); the specific successor for a school is `school_academic_institution`. Not mapped automatically.",
4899
+ law_enforcement: "v1.0.0 `law_enforcement` was a non-selectable heading. Canon makes Law enforcement / Police a selectable leaf with five optional children."
4900
+ }
4901
+ },
4902
+ _notCarried: [],
4903
+ levels: {
4904
+ "0": "Unknown or Missing",
4905
+ "1": "Category",
4906
+ "2": "Entity",
4907
+ "3": "Variant"
4908
+ },
4909
+ entries: [
4910
+ {
4911
+ code: "048-000-000-000-000-000-000",
4912
+ key: "missingness_root",
4913
+ title: "Unknown, Redacted, or Missing",
4914
+ selectable: false,
4915
+ parentCode: null,
4916
+ childCodes: [
4917
+ "048-000-000-000-000-000-001",
4918
+ "048-000-000-000-000-000-002",
4919
+ "048-000-000-000-000-000-003"
4920
+ ],
4921
+ definition: "Root group for values indicating absent, withheld, or uncollected data."
4922
+ },
4923
+ {
4924
+ code: "048-000-000-000-000-000-001",
4925
+ key: "unknown",
4926
+ title: "Unknown",
4927
+ selectable: true,
4928
+ parentCode: "048-000-000-000-000-000-000",
4929
+ childCodes: [],
4930
+ definition: "Referral entity category unknown.",
4931
+ canonicalCode: "00-00-01-00",
4932
+ enumConstant: "EMPTY_RESPONSE_UNKNOWN"
4933
+ },
4934
+ {
4935
+ code: "048-000-000-000-000-000-002",
4936
+ key: "anonymous",
4937
+ title: "Anonymous",
4938
+ selectable: true,
4939
+ parentCode: "048-000-000-000-000-000-000",
4940
+ childCodes: [],
4941
+ definition: "Referral entity category withheld or redacted.",
4942
+ canonicalCode: "00-00-02-00",
4943
+ enumConstant: "EMPTY_RESPONSE_ANONYMOUS"
4944
+ },
4945
+ {
4946
+ code: "048-000-000-000-000-000-003",
4947
+ key: "data_not_collected",
4948
+ title: "Data not collected",
4949
+ selectable: true,
4950
+ parentCode: "048-000-000-000-000-000-000",
4951
+ childCodes: [],
4952
+ definition: "Referral entity category not collected or no signal captured.",
4953
+ canonicalCode: "00-00-03-00",
4954
+ enumConstant: "EMPTY_RESPONSE_NOTCOLLECTED"
4955
+ },
4956
+ {
4957
+ code: "048-001-000-000-000-000-000",
4958
+ key: "self_referred",
4959
+ title: "Self-referred",
4960
+ selectable: true,
4961
+ parentCode: null,
4962
+ childCodes: [],
4963
+ definition: "Client initiated contact or presented for services without a third-party referrer.",
4964
+ canonicalCode: "01-00-01-00",
4965
+ enumConstant: "INDIVIDUAL_PERSON_SELFREFERRED"
4966
+ },
4967
+ {
4968
+ code: "048-002-000-000-000-000-000",
4969
+ key: "family_guardian_friend",
4970
+ title: "Family/guardian/friend/foster parent",
4971
+ selectable: true,
4972
+ parentCode: null,
4973
+ childCodes: [],
4974
+ definition: "A caregiver, family member, or close personal support person initiated the referral.",
4975
+ canonicalCode: "01-00-02-00",
4976
+ enumConstant: "INDIVIDUAL_PERSON_FAMILYGUARDIANFRIEND"
4977
+ },
4978
+ {
4979
+ code: "048-003-000-000-000-000-000",
4980
+ key: "peer",
4981
+ title: "Peer / another client",
4982
+ selectable: true,
4983
+ parentCode: null,
4984
+ childCodes: [],
4985
+ definition: "Another current or former client initiated or encouraged the referral.",
4986
+ canonicalCode: "01-00-03-00",
4987
+ enumConstant: "INDIVIDUAL_PERSON_PEER"
4988
+ },
4989
+ {
4990
+ code: "048-004-000-000-000-000-000",
4991
+ key: "other_individual",
4992
+ title: "Other individual",
4993
+ selectable: true,
4994
+ parentCode: null,
4995
+ childCodes: [],
4996
+ definition: "A non-family individual initiated the referral (e.g., neighbor, community member, clergy).",
4997
+ canonicalCode: "01-00-04-00",
4998
+ enumConstant: "INDIVIDUAL_PERSON_OTHER"
4999
+ },
5000
+ {
5001
+ code: "048-005-000-000-000-000-000",
5002
+ key: "housing_shelter_continuum",
5003
+ title: "Housing / Shelter continuum",
5004
+ selectable: false,
5005
+ parentCode: null,
5006
+ childCodes: [
5007
+ "048-005-001-000-000-000-000",
5008
+ "048-005-002-000-000-000-000",
5009
+ "048-005-003-000-000-000-000"
5010
+ ],
5011
+ definition: "Primary function is outreach engagement, emergency shelter, or residential shelter/housing programs.",
5012
+ canonicalCode: "02-01-00-00",
5013
+ enumConstant: "ORGANIZATION_HOUSING"
5014
+ },
5015
+ {
5016
+ code: "048-005-001-000-000-000-000",
5017
+ key: "outreach_project",
5018
+ title: "Outreach Project",
5019
+ selectable: true,
5020
+ parentCode: "048-005-000-000-000-000-000",
5021
+ childCodes: [],
5022
+ definition: "Street/community outreach program that engaged the client prior to enrollment.",
5023
+ canonicalCode: "02-01-01-00",
5024
+ enumConstant: "ORGANIZATION_HOUSING_OUTREACHPROJECT"
5025
+ },
5026
+ {
5027
+ code: "048-005-002-000-000-000-000",
5028
+ key: "temporary_shelter",
5029
+ title: "Temporary Shelter",
5030
+ selectable: true,
5031
+ parentCode: "048-005-000-000-000-000-000",
5032
+ childCodes: [],
5033
+ definition: "Emergency/crisis shelter or short-term temporary housing program.",
5034
+ canonicalCode: "02-01-02-00",
5035
+ enumConstant: "ORGANIZATION_HOUSING_TEMPORARYSHELTER"
5036
+ },
5037
+ {
5038
+ code: "048-005-003-000-000-000-000",
5039
+ key: "residential_project",
5040
+ title: "Residential Project",
5041
+ selectable: true,
5042
+ parentCode: "048-005-000-000-000-000-000",
5043
+ childCodes: [],
5044
+ definition: "Longer-term residential or transitional living program.",
5045
+ canonicalCode: "02-01-03-00",
5046
+ enumConstant: "ORGANIZATION_HOUSING_RESIDENTIALPROJECT"
5047
+ },
5048
+ {
5049
+ code: "048-006-000-000-000-000-000",
5050
+ key: "hotlines",
5051
+ title: "Hotlines",
5052
+ selectable: false,
5053
+ parentCode: null,
5054
+ childCodes: [
5055
+ "048-006-003-000-000-000-000"
5056
+ ],
5057
+ definition: "Crisis lines or call centers that connect a person to services.",
5058
+ canonicalCode: "02-02-00-00",
5059
+ enumConstant: "ORGANIZATION_CALLCENTERS"
5060
+ },
5061
+ {
5062
+ code: "048-006-001-000-000-000-000",
5063
+ key: "national_hotline",
5064
+ title: "National hotline",
5065
+ selectable: true,
5066
+ parentCode: "048-006-003-000-000-000-000",
5067
+ childCodes: [],
5068
+ definition: "National-level hotline network.",
5069
+ canonicalCode: "02-02-01-01",
5070
+ enumConstant: "ORGANIZATION_CALLCENTERS_HOTLINE_NATIONAL"
5071
+ },
5072
+ {
5073
+ code: "048-006-002-000-000-000-000",
5074
+ key: "local_other_hotline",
5075
+ title: "Local/other hotline",
5076
+ selectable: true,
5077
+ parentCode: "048-006-003-000-000-000-000",
5078
+ childCodes: [],
5079
+ definition: "Local/regional hotline or non-national hotline.",
5080
+ canonicalCode: "02-02-01-02",
5081
+ enumConstant: "ORGANIZATION_CALLCENTERS_HOTLINE_LOCAL"
5082
+ },
5083
+ {
5084
+ code: "048-006-003-000-000-000-000",
5085
+ key: "hotline",
5086
+ title: "Hotline",
5087
+ selectable: true,
5088
+ parentCode: "048-006-000-000-000-000-000",
5089
+ childCodes: [
5090
+ "048-006-001-000-000-000-000",
5091
+ "048-006-002-000-000-000-000"
5092
+ ],
5093
+ definition: "Crisis hotline or call center that connected the client to services.",
5094
+ canonicalCode: "02-02-01-00",
5095
+ enumConstant: "ORGANIZATION_CALLCENTERS_HOTLINE"
5096
+ },
5097
+ {
5098
+ code: "048-007-000-000-000-000-000",
5099
+ key: "justice_protective_systems",
5100
+ title: "Justice & Protective Systems",
5101
+ selectable: false,
5102
+ parentCode: null,
5103
+ childCodes: [
5104
+ "048-007-001-000-000-000-000",
5105
+ "048-007-002-000-000-000-000",
5106
+ "048-007-003-000-000-000-000",
5107
+ "048-007-004-000-000-000-000",
5108
+ "048-007-005-000-000-000-000",
5109
+ "048-007-006-000-000-000-000"
5110
+ ],
5111
+ definition: null,
5112
+ canonicalCode: "02-03-00-00",
5113
+ enumConstant: "ORGANIZATION_JUSTICE"
5114
+ },
5115
+ {
5116
+ code: "048-007-001-000-000-000-000",
5117
+ key: "child_welfare_cps",
5118
+ title: "Child Welfare / CPS",
5119
+ selectable: true,
5120
+ parentCode: "048-007-000-000-000-000-000",
5121
+ childCodes: [],
5122
+ definition: "Government child protection agency responsible for investigating child abuse/neglect and ensuring child safety.",
5123
+ canonicalCode: "02-03-01-00",
5124
+ enumConstant: "ORGANIZATION_JUSTICE_CHILDWELFARE"
5125
+ },
5126
+ {
5127
+ code: "048-007-002-000-000-000-000",
5128
+ key: "juvenile_justice",
5129
+ title: "Juvenile Justice",
5130
+ selectable: true,
5131
+ parentCode: "048-007-000-000-000-000-000",
5132
+ childCodes: [],
5133
+ definition: "Juvenile probation/detention/court-related juvenile justice system initiated the referral.",
5134
+ canonicalCode: "02-03-02-00",
5135
+ enumConstant: "ORGANIZATION_JUSTICE_JUVENILE"
5136
+ },
5137
+ {
5138
+ code: "048-007-003-000-000-000-000",
5139
+ key: "law_enforcement",
5140
+ title: "Law enforcement / Police",
5141
+ selectable: true,
5142
+ parentCode: "048-007-000-000-000-000-000",
5143
+ childCodes: [
5144
+ "048-007-003-001-000-000-000",
5145
+ "048-007-003-002-000-000-000",
5146
+ "048-007-003-003-000-000-000",
5147
+ "048-007-003-004-000-000-000",
5148
+ "048-007-003-005-000-000-000"
5149
+ ],
5150
+ definition: "Law enforcement agency initiated the referral (local/state/federal).",
5151
+ canonicalCode: "02-03-03-00",
5152
+ enumConstant: "ORGANIZATION_JUSTICE_LAWENFORCEMENT"
5153
+ },
5154
+ {
5155
+ code: "048-007-003-001-000-000-000",
5156
+ key: "local_law_enforcement",
5157
+ title: "Local law enforcement",
5158
+ selectable: true,
5159
+ parentCode: "048-007-003-000-000-000-000",
5160
+ childCodes: [],
5161
+ definition: "City/county police or sheriff.",
5162
+ canonicalCode: "02-03-03-01",
5163
+ enumConstant: "ORGANIZATION_JUSTICE_LAWENFORCEMENT_LOCAL"
5164
+ },
5165
+ {
5166
+ code: "048-007-003-002-000-000-000",
5167
+ key: "state_law_enforcement",
5168
+ title: "State law enforcement",
5169
+ selectable: true,
5170
+ parentCode: "048-007-003-000-000-000-000",
5171
+ childCodes: [],
5172
+ definition: "State-level law enforcement agency (e.g., state police/highway patrol/state bureau of investigation) acting in an official capacity.",
5173
+ canonicalCode: "02-03-03-02",
5174
+ enumConstant: "ORGANIZATION_JUSTICE_LAWENFORCEMENT_STATE"
5175
+ },
5176
+ {
5177
+ code: "048-007-003-003-000-000-000",
5178
+ key: "federal_law_enforcement",
5179
+ title: "Federal law enforcement",
5180
+ selectable: true,
5181
+ parentCode: "048-007-003-000-000-000-000",
5182
+ childCodes: [],
5183
+ definition: "Federal law enforcement agency (e.g., FBI, DHS/ICE).",
5184
+ canonicalCode: "02-03-03-03",
5185
+ enumConstant: "ORGANIZATION_JUSTICE_LAWENFORCEMENT_FEDERAL"
5186
+ },
5187
+ {
5188
+ code: "048-007-003-004-000-000-000",
5189
+ key: "tribal_law_enforcement",
5190
+ title: "Tribal law enforcement",
5191
+ selectable: true,
5192
+ parentCode: "048-007-003-000-000-000-000",
5193
+ childCodes: [],
5194
+ definition: "Tribal police.",
5195
+ canonicalCode: "02-03-03-04",
5196
+ enumConstant: "ORGANIZATION_JUSTICE_LAWENFORCEMENT_TRIBAL"
5197
+ },
5198
+ {
5199
+ code: "048-007-003-005-000-000-000",
5200
+ key: "other_law_enforcement",
5201
+ title: "Other/ unknown LE",
5202
+ selectable: true,
5203
+ parentCode: "048-007-003-000-000-000-000",
5204
+ childCodes: [],
5205
+ definition: "Other law enforcement entity, or law enforcement type is unknown.",
5206
+ canonicalCode: "02-03-03-05",
5207
+ enumConstant: "ORGANIZATION_JUSTICE_LAWENFORCEMENT_OTHER"
5208
+ },
5209
+ {
5210
+ code: "048-007-004-000-000-000-000",
5211
+ key: "courts_prosecution",
5212
+ title: "Courts or prosecution",
5213
+ selectable: true,
5214
+ parentCode: "048-007-000-000-000-000-000",
5215
+ childCodes: [],
5216
+ definition: "Court or prosecution entity (not law enforcement).",
5217
+ canonicalCode: "02-03-04-00",
5218
+ enumConstant: "ORGANIZATION_JUSTICE_COURTS"
5219
+ },
5220
+ {
5221
+ code: "048-007-005-000-000-000-000",
5222
+ key: "correction_probation",
5223
+ title: "Correction / probation",
5224
+ selectable: true,
5225
+ parentCode: "048-007-000-000-000-000-000",
5226
+ childCodes: [],
5227
+ definition: "Corrections, probation, parole, or community supervision entity (not law enforcement).",
5228
+ canonicalCode: "02-03-05-00",
5229
+ enumConstant: "ORGANIZATION_JUSTICE_CORRECTIONS"
5230
+ },
5231
+ {
5232
+ code: "048-007-006-000-000-000-000",
5233
+ key: "adult_protective_services",
5234
+ title: "Adult Protective Services (APS)",
5235
+ selectable: true,
5236
+ parentCode: "048-007-000-000-000-000-000",
5237
+ childCodes: [],
5238
+ definition: "Government adult protection agency responsible for investigating abuse, neglect, self-neglect, or exploitation of vulnerable or older adults and ensuring their safety. Adult analog of Child Welfare / CPS.",
5239
+ canonicalCode: "02-03-06-00",
5240
+ enumConstant: "ORGANIZATION_JUSTICE_ADULTPROTECTIVE"
5241
+ },
5242
+ {
5243
+ code: "048-008-000-000-000-000-000",
5244
+ key: "health_behavioral_health",
5245
+ title: "Health / behavioral health",
5246
+ selectable: false,
5247
+ parentCode: null,
5248
+ childCodes: [
5249
+ "048-008-001-000-000-000-000",
5250
+ "048-008-002-000-000-000-000"
5251
+ ],
5252
+ definition: "Hospitals and healthcare providers (including mental health inpatient facilities).",
5253
+ canonicalCode: "02-04-00-00",
5254
+ enumConstant: "ORGANIZATION_HEALTH"
5255
+ },
5256
+ {
5257
+ code: "048-008-001-000-000-000-000",
5258
+ key: "inpatient_psychiatric_facility",
5259
+ title: "Inpatient psychiatric facility",
5260
+ selectable: true,
5261
+ parentCode: "048-008-000-000-000-000-000",
5262
+ childCodes: [],
5263
+ definition: "Inpatient psychiatric hospital or psychiatric facility.",
5264
+ canonicalCode: "02-04-01-00",
5265
+ enumConstant: "ORGANIZATION_HEALTH_PSYCHIATRIC"
5266
+ },
5267
+ {
5268
+ code: "048-008-002-000-000-000-000",
5269
+ key: "healthcare_provider",
5270
+ title: "Healthcare provider (non-inpatient psychiatric)",
5271
+ selectable: true,
5272
+ parentCode: "048-008-000-000-000-000-000",
5273
+ childCodes: [],
5274
+ definition: "Any non-inpatient healthcare provider (clinic, hospital, outpatient provider, behavioral health clinic, SANE program, substance abuse clinic, etc.).",
5275
+ canonicalCode: "02-04-02-00",
5276
+ enumConstant: "ORGANIZATION_HEALTH_HEALTHCARE"
5277
+ },
5278
+ {
5279
+ code: "048-009-000-000-000-000-000",
5280
+ key: "education",
5281
+ title: "Education",
5282
+ selectable: false,
5283
+ parentCode: null,
5284
+ childCodes: [
5285
+ "048-009-001-000-000-000-000"
5286
+ ],
5287
+ definition: "Parent category for education-related institutions.",
5288
+ canonicalCode: "02-05-00-00",
5289
+ enumConstant: "ORGANIZATION_EDUCATION"
5290
+ },
5291
+ {
5292
+ code: "048-009-001-000-000-000-000",
5293
+ key: "school_academic_institution",
5294
+ title: "School / academic institution",
5295
+ selectable: true,
5296
+ parentCode: "048-009-000-000-000-000-000",
5297
+ childCodes: [],
5298
+ definition: "School system or educational institution.",
5299
+ canonicalCode: "02-05-01-00",
5300
+ enumConstant: "ORGANIZATION_EDUCATION_SCHOOL"
5301
+ },
5302
+ {
5303
+ code: "048-010-000-000-000-000-000",
5304
+ key: "victim_community_service_providers",
5305
+ title: "Victim + Community service providers",
5306
+ selectable: false,
5307
+ parentCode: null,
5308
+ childCodes: [
5309
+ "048-010-001-000-000-000-000",
5310
+ "048-010-002-000-000-000-000",
5311
+ "048-010-003-000-000-000-000",
5312
+ "048-010-004-000-000-000-000"
5313
+ ],
5314
+ definition: "Parent category for victim service providers and community-based service providers.",
5315
+ canonicalCode: "02-06-00-00",
5316
+ enumConstant: "ORGANIZATION_COMMUNITY"
5317
+ },
5318
+ {
5319
+ code: "048-010-001-000-000-000-000",
5320
+ key: "child_advocacy_center",
5321
+ title: "Child Advocacy Center (CAC)",
5322
+ selectable: true,
5323
+ parentCode: "048-010-000-000-000-000-000",
5324
+ childCodes: [],
5325
+ definition: "A child-centered multidisciplinary center coordinating investigation and services (forensic interview, coordination, referrals, sometimes medical or therapy) for child victims.",
5326
+ canonicalCode: "02-06-01-00",
5327
+ enumConstant: "ORGANIZATION_COMMUNITY_CHILDADVOCACYCENTER"
5328
+ },
5329
+ {
5330
+ code: "048-010-002-000-000-000-000",
5331
+ key: "victim_service_provider",
5332
+ title: "Victim service provider / advocacy program",
5333
+ selectable: true,
5334
+ parentCode: "048-010-000-000-000-000-000",
5335
+ childCodes: [],
5336
+ definition: "Organization whose primary mission is to provide services to victims/survivors of crime (VOCA-aligned breadth: rape crisis centers, DV/dating-violence/stalking programs, anti-trafficking programs, child victim centers, homicide-survivor organizations, and similar). Whether the organization is specifically a DV/SA victim service provider \u2014 the fact HMIS 2.01 needs (Comparable Database) \u2014 is a separate per-organization attribute, self-attested by the organization at onboarding (Platform survey / Agency Hub \u201CMy agency info\u201D), not part of this category.",
5337
+ canonicalCode: "02-06-02-00",
5338
+ enumConstant: "ORGANIZATION_COMMUNITY_VICTIMSERVICEPROVIDER"
5339
+ },
5340
+ {
5341
+ code: "048-010-003-000-000-000-000",
5342
+ key: "community_based_service_provider",
5343
+ title: "Community-based service provider (general social services)",
5344
+ selectable: true,
5345
+ parentCode: "048-010-000-000-000-000-000",
5346
+ childCodes: [],
5347
+ definition: "The residual community-based provider (\u201Cother community-based service provider\u201D): a non-VSP offering practical support services, navigation, or stabilization resources that is not primarily a VSP, a legal services provider, a housing/shelter project, a government justice agency, a healthcare provider, a school, a hotline, or a public benefits office. (Ex: youth drop-in center; food pantry; reentry program.)",
5348
+ canonicalCode: "02-06-03-00",
5349
+ enumConstant: "ORGANIZATION_COMMUNITY_COMMUNITYSERVICEPROVIDER"
5350
+ },
5351
+ {
5352
+ code: "048-010-004-000-000-000-000",
5353
+ key: "legal_services_provider",
5354
+ title: "Legal services provider",
5355
+ selectable: true,
5356
+ parentCode: "048-010-000-000-000-000-000",
5357
+ childCodes: [],
5358
+ definition: "Civil legal aid organization, immigration attorneys, victim-rights law clinic, or similar provider of legal help to the client. Distinct from Courts or prosecution (the justice-system entity itself): this is getting a lawyer's help, not being referred into proceedings.",
5359
+ canonicalCode: "02-06-04-00",
5360
+ enumConstant: "ORGANIZATION_COMMUNITY_LEGALSERVICES"
5361
+ },
5362
+ {
5363
+ code: "048-011-000-000-000-000-000",
5364
+ key: "coordination_governance",
5365
+ title: "Coordination & Governance",
5366
+ selectable: false,
5367
+ parentCode: null,
5368
+ childCodes: [
5369
+ "048-011-001-000-000-000-000",
5370
+ "048-011-002-000-000-000-000"
5371
+ ],
5372
+ definition: "Parent category for coordination and governance bodies (e.g., MDTs, coalitions).",
5373
+ canonicalCode: "02-07-00-00",
5374
+ enumConstant: "ORGANIZATION_GOVERNANCE"
5375
+ },
5376
+ {
5377
+ code: "048-011-001-000-000-000-000",
5378
+ key: "mdt",
5379
+ title: "Multidisciplinary team (MDT)",
5380
+ selectable: true,
5381
+ parentCode: "048-011-000-000-000-000-000",
5382
+ childCodes: [],
5383
+ definition: "A case-level team: professionals from multiple agencies (law enforcement, child welfare, medical, advocacy) who review and coordinate individual cases together; referrals arise out of case review. (E.g., a county trafficking MDT or a CAC-based team.)",
5384
+ canonicalCode: "02-07-01-00",
5385
+ enumConstant: "ORGANIZATION_GOVERNANCE_MDT"
5386
+ },
5387
+ {
5388
+ code: "048-011-002-000-000-000-000",
5389
+ key: "coalition",
5390
+ title: "Coalition (state/regional coalition)",
5391
+ selectable: true,
5392
+ parentCode: "048-011-000-000-000-000-000",
5393
+ childCodes: [],
5394
+ definition: "A state or regional membership body of organizations coordinating at the system level \u2014 training, standards, policy, funding \u2014 not individual cases; referrals from a coalition are typically warm handoffs to a member organization.",
5395
+ canonicalCode: "02-07-02-00",
5396
+ enumConstant: "ORGANIZATION_GOVERNANCE_COALITION"
5397
+ },
5398
+ {
5399
+ code: "048-012-000-000-000-000-000",
5400
+ key: "internal",
5401
+ title: "Internal",
5402
+ selectable: false,
5403
+ parentCode: null,
5404
+ childCodes: [
5405
+ "048-012-001-000-000-000-000"
5406
+ ],
5407
+ definition: "Parent category for internal referrals within the same umbrella agency.",
5408
+ canonicalCode: "02-08-00-00",
5409
+ enumConstant: "ORGANIZATION_INTERNAL"
5410
+ },
5411
+ {
5412
+ code: "048-012-001-000-000-000-000",
5413
+ key: "own_agency_internal",
5414
+ title: "Own agency / internal referral",
5415
+ selectable: true,
5416
+ parentCode: "048-012-000-000-000-000-000",
5417
+ childCodes: [],
5418
+ definition: "Client was referred from another program or unit within the same umbrella agency.",
5419
+ canonicalCode: "02-08-01-00",
5420
+ enumConstant: "ORGANIZATION_INTERNAL_OWNAGENCY"
5421
+ },
5422
+ {
5423
+ code: "048-013-000-000-000-000-000",
5424
+ key: "other_entity",
5425
+ title: "Other",
5426
+ selectable: false,
5427
+ parentCode: null,
5428
+ childCodes: [
5429
+ "048-013-001-000-000-000-000",
5430
+ "048-013-002-000-000-000-000",
5431
+ "048-013-003-000-000-000-000"
5432
+ ],
5433
+ definition: "Parent category for other organizations not captured by the primary sectors.",
5434
+ canonicalCode: "02-09-00-00",
5435
+ enumConstant: "ORGANIZATION_OTHER"
5436
+ },
5437
+ {
5438
+ code: "048-013-001-000-000-000-000",
5439
+ key: "employer",
5440
+ title: "Employer",
5441
+ selectable: true,
5442
+ parentCode: "048-013-000-000-000-000-000",
5443
+ childCodes: [],
5444
+ definition: "Employer, HR, or employee assistance program initiated the referral.",
5445
+ canonicalCode: "02-09-01-00",
5446
+ enumConstant: "ORGANIZATION_OTHER_EMPLOYER"
5447
+ },
5448
+ {
5449
+ code: "048-013-002-000-000-000-000",
5450
+ key: "benefits_public_assistance_office",
5451
+ title: "Benefits/public assistance office",
5452
+ selectable: true,
5453
+ parentCode: "048-013-000-000-000-000-000",
5454
+ childCodes: [],
5455
+ definition: "Government office administering public benefits or eligibility and enrollment (e.g., SNAP, TANF, Medicaid, SSA).",
5456
+ canonicalCode: "02-09-02-00",
5457
+ enumConstant: "ORGANIZATION_OTHER_PUBLICASSISTANCE"
5458
+ },
5459
+ {
5460
+ code: "048-013-003-000-000-000-000",
5461
+ key: "other_organization",
5462
+ title: "Other Organization",
5463
+ selectable: true,
5464
+ parentCode: "048-013-000-000-000-000-000",
5465
+ childCodes: [],
5466
+ definition: "Other organization not otherwise captured by the listed categories.",
5467
+ canonicalCode: "02-09-03-00",
5468
+ enumConstant: "ORGANIZATION_OTHER_UNSPECIFIED"
5469
+ }
5470
+ ]
5471
+ };
5472
+
5473
+ // src/constants/org-type.ts
5474
+ var ENTRIES = referralEntityCategory_v1_2_0_default.entries;
5475
+ var BY_KEY = new Map(ENTRIES.map((e) => [e.key, e]));
5476
+ var BY_CODE = new Map(ENTRIES.map((e) => [e.code, e]));
5477
+ var BY_CANON = new Map(
5478
+ ENTRIES.filter((e) => e.canonicalCode).map((e) => [
5479
+ e.canonicalCode,
5480
+ e
5481
+ ])
5482
+ );
5483
+ var BY_ENUM_CONSTANT = new Map(
5484
+ ENTRIES.filter((e) => e.enumConstant).map((e) => [
5485
+ e.enumConstant,
5486
+ e
5487
+ ])
5488
+ );
5489
+ var isOrgHalf = (e) => (e.canonicalCode ?? "").startsWith("02-");
5490
+ var ORG_TYPE_HEADING_KEYS = Object.freeze([
5491
+ "housing_shelter_continuum",
5492
+ "hotlines",
5493
+ "justice_protective_systems",
5494
+ "health_behavioral_health",
5495
+ "education",
5496
+ "victim_community_service_providers",
5497
+ "coordination_governance",
5498
+ "internal",
5499
+ "other_entity"
5500
+ ]);
5501
+ var ORG_TYPE_SELECTABLE_KEYS = Object.freeze([
5502
+ "outreach_project",
5503
+ "temporary_shelter",
5504
+ "residential_project",
5505
+ "national_hotline",
5506
+ "local_other_hotline",
5507
+ "hotline",
5508
+ "child_welfare_cps",
5509
+ "juvenile_justice",
5510
+ "law_enforcement",
5511
+ "local_law_enforcement",
5512
+ "state_law_enforcement",
5513
+ "federal_law_enforcement",
5514
+ "tribal_law_enforcement",
5515
+ "other_law_enforcement",
5516
+ "courts_prosecution",
5517
+ "correction_probation",
5518
+ "adult_protective_services",
5519
+ "inpatient_psychiatric_facility",
5520
+ "healthcare_provider",
5521
+ "school_academic_institution",
5522
+ "child_advocacy_center",
5523
+ "victim_service_provider",
5524
+ "community_based_service_provider",
5525
+ "legal_services_provider",
5526
+ "mdt",
5527
+ "coalition",
5528
+ "employer",
5529
+ "benefits_public_assistance_office",
5530
+ "other_organization"
5531
+ ]);
5532
+ var ORG_TYPE_NONPICKABLE_LEAF_KEYS = Object.freeze([
5533
+ "own_agency_internal"
5534
+ ]);
5535
+ var ORG_TYPE_KEYS = Object.freeze([
5536
+ ...ORG_TYPE_HEADING_KEYS,
5537
+ ...ORG_TYPE_SELECTABLE_KEYS,
5538
+ ...ORG_TYPE_NONPICKABLE_LEAF_KEYS
5539
+ ]);
5540
+ var AGENCY_TYPE_KEYS = Object.freeze([
5541
+ ...ORG_TYPE_SELECTABLE_KEYS,
5542
+ ...ORG_TYPE_NONPICKABLE_LEAF_KEYS,
5543
+ "unknown"
5544
+ ]);
5545
+ var ORG_TYPE_KEY_SET = new Set(ORG_TYPE_KEYS);
5546
+ var AGENCY_TYPE_KEY_SET = new Set(AGENCY_TYPE_KEYS);
5547
+ function isAgencyTypeKey(value) {
5548
+ return typeof value === "string" && AGENCY_TYPE_KEY_SET.has(value);
5549
+ }
5550
+ function lookup(value) {
5551
+ if (typeof value !== "string") return null;
5552
+ const v = value.trim();
5553
+ if (!v) return null;
5554
+ return BY_KEY.get(v.toLowerCase()) ?? BY_ENUM_CONSTANT.get(v.toUpperCase()) ?? BY_CANON.get(v) ?? BY_CODE.get(v) ?? null;
5555
+ }
5556
+ function resolveAgencyTypeKey(value) {
5557
+ const hit = lookup(value);
5558
+ return hit && isAgencyTypeKey(hit.key) ? hit.key : null;
5559
+ }
5560
+ var LEGACY_NUMERIC_TO_REFERRAL_ENTITY_KEY = Object.freeze({
5561
+ 0: "unknown",
5562
+ 1: "own_agency_internal",
5563
+ 2: "self_referred",
5564
+ 3: "family_guardian_friend",
5565
+ 4: "peer",
5566
+ 5: "other_individual",
5567
+ 10: "housing_shelter_continuum",
5568
+ 11: "hotline",
5569
+ 12: "justice_protective_systems",
5570
+ 13: "outreach_project",
5571
+ 14: "temporary_shelter",
5572
+ 15: "residential_project",
5573
+ 16: "health_behavioral_health",
5574
+ 17: "education",
5575
+ 18: "law_enforcement",
5576
+ 19: "other_entity",
5577
+ 20: "child_welfare_cps",
5578
+ 21: "juvenile_justice",
5579
+ 22: "courts_prosecution",
5580
+ 23: "correction_probation",
5581
+ 24: "inpatient_psychiatric_facility",
5582
+ 25: "healthcare_provider",
5583
+ 26: "victim_community_service_providers",
5584
+ 27: "child_advocacy_center",
5585
+ 28: "victim_service_provider",
5586
+ 29: "community_based_service_provider",
5587
+ 30: "employer",
5588
+ 31: "benefits_public_assistance_office"
5589
+ });
5590
+ var ORG_TYPE_PARENT_KEY = Object.freeze(
5591
+ Object.fromEntries(
5592
+ ENTRIES.filter(isOrgHalf).map((e) => [
5593
+ e.key,
5594
+ e.parentCode ? BY_CODE.get(e.parentCode)?.key ?? null : null
5595
+ ])
5596
+ )
5597
+ );
5598
+ var VICTIM_SERVING_ORG_TYPE_KEYS = Object.freeze([
5599
+ "victim_service_provider",
5600
+ "child_advocacy_center"
5601
+ ]);
5602
+ var LAW_ENFORCEMENT_ORG_TYPE_KEYS = Object.freeze([
5603
+ "law_enforcement",
5604
+ "local_law_enforcement",
5605
+ "state_law_enforcement",
5606
+ "federal_law_enforcement",
5607
+ "tribal_law_enforcement",
5608
+ "other_law_enforcement"
5609
+ ]);
5610
+ var LEGAL_ORG_TYPE_KEYS = Object.freeze([
5611
+ "courts_prosecution",
5612
+ "legal_services_provider"
5613
+ ]);
5614
+ var HEALTHCARE_ORG_TYPE_KEYS = Object.freeze([
5615
+ "health_behavioral_health",
5616
+ "inpatient_psychiatric_facility",
5617
+ "healthcare_provider"
5618
+ ]);
5619
+ var REPORT_AUTHORITY_ORG_TYPE_KEYS = Object.freeze([
5620
+ "justice_protective_systems",
5621
+ "child_welfare_cps",
5622
+ "juvenile_justice",
5623
+ "law_enforcement",
5624
+ "local_law_enforcement",
5625
+ "state_law_enforcement",
5626
+ "federal_law_enforcement",
5627
+ "tribal_law_enforcement",
5628
+ "other_law_enforcement",
5629
+ "courts_prosecution",
5630
+ "correction_probation",
5631
+ "adult_protective_services"
5632
+ ]);
5633
+ var NO_SECTOR_ORG_TYPE_KEYS = Object.freeze([
5634
+ "internal",
5635
+ "own_agency_internal",
5636
+ "unknown"
5637
+ ]);
5638
+ var asSet = (keys) => new Set(keys);
5639
+ var VICTIM_SERVING = asSet(VICTIM_SERVING_ORG_TYPE_KEYS);
5640
+ var LAW_ENFORCEMENT = asSet(LAW_ENFORCEMENT_ORG_TYPE_KEYS);
5641
+ var LEGAL = asSet(LEGAL_ORG_TYPE_KEYS);
5642
+ var HEALTHCARE = asSet(HEALTHCARE_ORG_TYPE_KEYS);
5643
+ var REPORT_AUTHORITY = asSet(REPORT_AUTHORITY_ORG_TYPE_KEYS);
5644
+ var NO_SECTOR = asSet(NO_SECTOR_ORG_TYPE_KEYS);
5645
+
5646
+ // src/schemas/agency.ts
5647
+ function vspTwoStepHolds(v) {
5648
+ return v.vspPrivateNonprofit == null || v.vsp === true;
5649
+ }
5650
+ var VSP_TWO_STEP_ISSUE = {
5651
+ message: "vspPrivateNonprofit is step 2 of the HMIS VSP two-step and requires vsp: true",
5652
+ path: ["vspPrivateNonprofit"]
5653
+ };
5654
+ function vspTwoStepHoldsOnUpdate(update) {
5655
+ if (!update || typeof update !== "object") return true;
5656
+ const u = update;
5657
+ const set = { ...u, ...u.$set ?? {} };
5658
+ return vspTwoStepHolds({
5659
+ vsp: set.vsp,
5660
+ vspPrivateNonprofit: set.vspPrivateNonprofit
5661
+ });
5662
+ }
5663
+ var orgTypeSchemaDefinition = {
5664
+ /**
5665
+ * The agency's organization type: a CVC-48 key from
5666
+ * {@link AGENCY_TYPE_KEYS} (a selectable org-type leaf, or the pre-backfill
5667
+ * `unknown`). Set once in the Admin Hub; carried from the Org. Never free
5668
+ * text — a value outside the enum fails validation on `save()` and, when
5669
+ * the fragment is added with {@link addAgencyOrgTypeFields} (default
5670
+ * options), on `updateOne` / `updateMany` / `findOneAndUpdate` too.
5671
+ *
5672
+ * ORDER OF ADOPTION (review MG2, pinned in org-type-contract.test.ts):
5673
+ * Mongoose validates `init`-ed paths on `save()`, not only modified ones,
5674
+ * so once a consumer adds this fragment, an agency document that carries a
5675
+ * NON-KEY `type` (free text, "UNKNOWN", "multi_service", a number) fails
5676
+ * its next save of ANY field. A document with no `type` at all saves fine.
5677
+ * Backfill first (every stored value → a key or `unknown`), then adopt.
5678
+ */
5679
+ type: {
5680
+ type: String,
5681
+ enum: [...AGENCY_TYPE_KEYS],
5682
+ index: true
5683
+ },
5684
+ /**
5685
+ * Is this organization a DV/SA victim service provider — the HMIS 2.01
5686
+ * (Comparable Database) fact. Captured in the Admin Hub (never inferred
5687
+ * from the type; the type only PROPOSES it — `orgTypeDefaultVsp`, the
5688
+ * Hub's pre-fill — and HTI Labs affirms or changes it there). Tri-state:
5689
+ * `true` / `false` / absent (not yet captured — a reader falls back to the
5690
+ * proposal).
5691
+ */
5692
+ vsp: {
5693
+ type: Boolean
5694
+ },
5695
+ /**
5696
+ * Step 2 of the two-step: private non-profit VSP (VOCA/OVC PMT
5697
+ * distinction). Captured; tri-state; may only be `true`/`false` when
5698
+ * `vsp === true` ({@link vspTwoStepHolds}, enforced at the mount).
5699
+ */
5700
+ vspPrivateNonprofit: {
5701
+ type: Boolean
5702
+ }
5703
+ };
5704
+ var agencyOrgTypeSchemaDefinition = orgTypeSchemaDefinition;
5705
+ var ORG_TYPE_FIELD_NAMES = Object.freeze([
5706
+ "type",
5707
+ "vsp",
5708
+ "vspPrivateNonprofit"
5709
+ ]);
5710
+ var AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS = Object.freeze([
5711
+ "updateOne",
5712
+ "updateMany",
5713
+ "findOneAndUpdate"
5714
+ ]);
5715
+ function applyRunValidatorsIfUnset(query) {
5716
+ if (query.getOptions().runValidators === void 0) {
5717
+ query.setOptions({ runValidators: true });
5718
+ }
5719
+ }
5720
+ function mountOrgTypeFields(schema, options) {
5721
+ schema.add(orgTypeSchemaDefinition);
5722
+ schema.pre("validate", function() {
5723
+ const doc = this;
5724
+ if (!vspTwoStepHolds(doc)) {
5725
+ const err = new MongooseError.ValidationError();
5726
+ err.addError(
5727
+ "vspPrivateNonprofit",
5728
+ new MongooseError.ValidatorError({
5729
+ path: "vspPrivateNonprofit",
5730
+ message: VSP_TWO_STEP_ISSUE.message,
5731
+ value: doc.vspPrivateNonprofit
5732
+ })
5733
+ );
5734
+ throw err;
5735
+ }
5736
+ });
5737
+ const validateOnUpdate = options.validateOnUpdate ?? true;
5738
+ schema.pre(
5739
+ [...AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS],
5740
+ function() {
5741
+ if (!vspTwoStepHoldsOnUpdate(this.getUpdate())) {
5742
+ throw new Error(VSP_TWO_STEP_ISSUE.message);
5743
+ }
5744
+ if (validateOnUpdate) applyRunValidatorsIfUnset(this);
5745
+ }
5746
+ );
5747
+ return schema;
5748
+ }
5749
+ function addOrgTypeFields(schema, options = {}) {
5750
+ return mountOrgTypeFields(schema, options);
5751
+ }
5752
+ function addAgencyOrgTypeFields(schema, options = {}) {
5753
+ return mountOrgTypeFields(schema, options);
5754
+ }
5755
+ function pickOrgTypeFields(src) {
5756
+ const out = {};
5757
+ if (src) {
5758
+ for (const k of ORG_TYPE_FIELD_NAMES) {
5759
+ const v = src[k];
5760
+ if (v != null) out[k] = v;
5761
+ }
5762
+ }
5763
+ return out;
5764
+ }
5765
+ function mirrorOrgTypeFields(org) {
5766
+ const out = pickOrgTypeFields(org);
5767
+ if (!vspTwoStepHolds(out)) {
5768
+ throw new Error(`mirrorOrgTypeFields: ${VSP_TWO_STEP_ISSUE.message}`);
5769
+ }
5770
+ return out;
5771
+ }
5772
+ function resolveEffectiveOrgTypeFields(org, agency) {
5773
+ const linked = agency != null && agency.organizationId != null;
5774
+ if (linked && org) return pickOrgTypeFields(org);
5775
+ return pickOrgTypeFields(agency);
5776
+ }
5777
+ function resolveEffectiveOrgType(org, agency) {
5778
+ return resolveAgencyTypeKey(resolveEffectiveOrgTypeFields(org, agency).type);
5779
+ }
5780
+ function orgTypeFieldsDiffer(org, agency) {
5781
+ const a = pickOrgTypeFields(org);
5782
+ const b = pickOrgTypeFields(agency);
5783
+ return ORG_TYPE_FIELD_NAMES.filter((k) => a[k] !== b[k]);
5784
+ }
4838
5785
  export {
5786
+ AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS,
5787
+ ORG_TYPE_FIELD_NAMES,
4839
5788
  TEAM_MODEL_NAME,
5789
+ VSP_TWO_STEP_ISSUE,
5790
+ addAgencyOrgTypeFields,
5791
+ addOrgTypeFields,
4840
5792
  addTeamDirectoryFields,
4841
5793
  addressSchema,
5794
+ agencyOrgTypeSchemaDefinition,
5795
+ applyRunValidatorsIfUnset,
4842
5796
  buildCvcEntrySchema,
4843
5797
  buildCvcRegistrySchema,
4844
5798
  buildFormSchema,
@@ -4859,6 +5813,9 @@ export {
4859
5813
  formSectionRefSchema,
4860
5814
  guidanceSchema,
4861
5815
  layoutSchema,
5816
+ mirrorOrgTypeFields,
5817
+ orgTypeFieldsDiffer,
5818
+ orgTypeSchemaDefinition,
4862
5819
  personNameSchema,
4863
5820
  phoneSchema,
4864
5821
  platformFunctionSchemaDefinition,
@@ -4867,6 +5824,8 @@ export {
4867
5824
  platformRoleSchemaOptions,
4868
5825
  questionSchemaDefinition,
4869
5826
  questionSchemaOptions,
5827
+ resolveEffectiveOrgType,
5828
+ resolveEffectiveOrgTypeFields,
4870
5829
  scoringConditionSchema,
4871
5830
  scoringRecommendationSchema,
4872
5831
  scoringRuleSchemaDefinition,
@@ -4876,6 +5835,8 @@ export {
4876
5835
  sectionSchemaDefinition,
4877
5836
  sectionSchemaOptions,
4878
5837
  teamDirectorySchemaDefinition,
4879
- visibilityRuleSchema
5838
+ visibilityRuleSchema,
5839
+ vspTwoStepHolds,
5840
+ vspTwoStepHoldsOnUpdate
4880
5841
  };
4881
5842
  //# sourceMappingURL=index.js.map