@htilabs/platform-common-models 0.3.0-beta.5 → 0.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cvcs/index.cjs +633 -467
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +570 -505
- package/dist/cvcs/index.d.ts +570 -505
- package/dist/cvcs/index.js +633 -466
- package/dist/cvcs/index.js.map +1 -1
- package/dist/index.cjs +811 -641
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -178
- package/dist/index.d.ts +178 -178
- package/dist/index.js +811 -639
- package/dist/index.js.map +1 -1
- package/dist/models/index.cjs +4 -3
- package/dist/models/index.cjs.map +1 -1
- package/dist/models/index.js +4 -3
- package/dist/models/index.js.map +1 -1
- package/dist/schemas/index.cjs +4 -3
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.js +4 -3
- package/dist/schemas/index.js.map +1 -1
- package/dist/services/index.cjs +4 -3
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.js +4 -3
- package/dist/services/index.js.map +1 -1
- package/dist/validation/index.cjs +5 -12
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +31 -30
- package/dist/validation/index.d.ts +31 -30
- package/dist/validation/index.js +5 -12
- package/dist/validation/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/cvc-sot.snap +6 -10
- package/src/__tests__/cvc-sot-snapshot.test.ts +8 -8
- package/src/__tests__/cvc-structural.test.ts +0 -1
- package/src/cvcs/index.ts +5 -6
- package/src/cvcs/serviceCategories.v1.0.0.json +560 -430
- package/src/cvcs/serviceMechanisms.v1.0.0.json +45 -5
- package/src/cvcs/serviceStates.v1.0.0.json +57 -17
- package/src/generated/cvc-enums.ts +176 -178
- package/src/schemas/cvcEntry.ts +3 -2
- package/src/schemas/cvcRegistry.ts +3 -2
- package/src/validation/cvc.ts +36 -50
- package/src/cvcs/missingness.v1.0.0.json +0 -50
|
@@ -12,156 +12,160 @@
|
|
|
12
12
|
/**
|
|
13
13
|
* Key → positional code map for the `service_categories` CVC domain.
|
|
14
14
|
*
|
|
15
|
-
* Domain: `service_categories` · Version: 1.0.0 · Entries:
|
|
15
|
+
* Domain: `service_categories` · Version: 1.0.0 · Entries: 151
|
|
16
16
|
*/
|
|
17
17
|
export const ServiceCategoryKeys = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
18
|
+
missingness_root: "022-000-000-000-000-000-000",
|
|
19
|
+
unknown: "022-000-000-000-000-000-001",
|
|
20
|
+
anonymous: "022-000-000-000-000-000-002",
|
|
21
|
+
data_not_collected: "022-000-000-000-000-000-003",
|
|
22
|
+
social_support_community_engagement: "022-002-000-000-000-000-000",
|
|
23
|
+
cultural_needs_support: "022-002-001-000-000-000-000",
|
|
24
|
+
gift_holiday_resources: "022-002-002-000-000-000-000",
|
|
25
|
+
peer_facilitated_supportive_group: "022-002-003-000-000-000-000",
|
|
26
|
+
community_service_learning: "022-002-004-000-000-000-000",
|
|
27
|
+
survivor_support_psychoeducation: "022-002-005-000-000-000-000",
|
|
28
|
+
financial_and_employment: "022-003-000-000-000-000-000",
|
|
29
|
+
financial_support: "022-003-001-000-000-000-000",
|
|
30
|
+
emergency_financial_assistance: "022-003-001-001-000-000-000",
|
|
31
|
+
employment_support: "022-003-002-000-000-000-000",
|
|
32
|
+
supported_employment: "022-003-002-001-000-000-000",
|
|
33
|
+
employment_assistance_job_search: "022-003-002-002-000-000-000",
|
|
34
|
+
job_vocation_training: "022-003-002-003-000-000-000",
|
|
35
|
+
healthcare: "022-004-000-000-000-000-000",
|
|
36
|
+
medical: "022-004-001-000-000-000-000",
|
|
37
|
+
emergency_medical_care: "022-004-001-001-000-000-000",
|
|
38
|
+
forensic_exam_interview: "022-004-001-002-000-000-000",
|
|
39
|
+
dv_exam: "022-004-001-002-001-000-000",
|
|
40
|
+
sane_exam: "022-004-001-002-002-000-000",
|
|
41
|
+
std_testing: "022-004-001-002-003-000-000",
|
|
42
|
+
specialized_assessments: "022-004-001-002-004-000-000",
|
|
43
|
+
counseling_evaluation_assessment: "022-004-001-002-004-001-000",
|
|
44
|
+
stalking_assessment: "022-004-001-002-004-002-000",
|
|
45
|
+
danger_assessment: "022-004-001-002-004-003-000",
|
|
46
|
+
indepth_assessment: "022-004-001-002-004-004-000",
|
|
47
|
+
outpatient_medical: "022-004-001-003-000-000-000",
|
|
48
|
+
dental: "022-004-001-003-001-000-000",
|
|
49
|
+
vision: "022-004-001-003-002-000-000",
|
|
50
|
+
tattoo_removal: "022-004-001-003-003-000-000",
|
|
51
|
+
pet_medical: "022-004-001-003-004-000-000",
|
|
52
|
+
pregnancy_care: "022-004-001-004-000-000-000",
|
|
53
|
+
prenatal_care: "022-004-001-004-001-000-000",
|
|
54
|
+
postnatal_care_client: "022-004-001-004-002-000-000",
|
|
55
|
+
postnatal_care_newborn: "022-004-001-004-003-000-000",
|
|
56
|
+
emotional_support_mental_health: "022-004-002-000-000-000-000",
|
|
57
|
+
individual_counseling: "022-004-002-001-000-000-000",
|
|
58
|
+
group_counseling: "022-004-002-002-000-000-000",
|
|
59
|
+
family_counseling: "022-004-002-003-000-000-000",
|
|
60
|
+
counseling_treatment_planning: "022-004-002-004-000-000-000",
|
|
61
|
+
counseling_treatment_plan_review: "022-004-002-005-000-000-000",
|
|
62
|
+
behavioral_occupational_support: "022-004-002-006-000-000-000",
|
|
63
|
+
substance_abuse_treatment: "022-004-002-006-001-000-000",
|
|
64
|
+
coping_strategy_support: "022-004-002-006-002-000-000",
|
|
65
|
+
other_therapy: "022-004-002-007-000-000-000",
|
|
66
|
+
housing_services: "022-005-000-000-000-000-000",
|
|
67
|
+
emergency_shelter: "022-005-001-000-000-000-000",
|
|
68
|
+
day_shelter_dropin: "022-005-001-001-000-000-000",
|
|
69
|
+
host_homes_safe_homes: "022-005-001-002-000-000-000",
|
|
70
|
+
congregate_shelter_bednight: "022-005-001-003-000-000-000",
|
|
71
|
+
emergency_hotel_motel: "022-005-001-004-000-000-000",
|
|
72
|
+
night_by_night_shelter: "022-005-001-005-000-000-000",
|
|
73
|
+
transitional_housing: "022-005-002-000-000-000-000",
|
|
74
|
+
housing_renovation_modification: "022-005-003-000-000-000-000",
|
|
75
|
+
household_setup_goods: "022-005-003-001-000-000-000",
|
|
76
|
+
housing_navigation_placement: "022-005-004-000-000-000-000",
|
|
77
|
+
housing_financial_assistance: "022-005-004-001-000-000-000",
|
|
78
|
+
rental_payment_assistance: "022-005-004-001-001-000-000",
|
|
79
|
+
security_deposit_allowance: "022-005-004-001-001-001-000",
|
|
80
|
+
utility_assistance: "022-005-004-001-001-002-000",
|
|
81
|
+
relocation_moving_assistance: "022-005-004-002-000-000-000",
|
|
82
|
+
housing_stabilization_eviction_prevention: "022-005-005-000-000-000-000",
|
|
83
|
+
tenant_based_scattered_site: "022-005-006-000-000-000-000",
|
|
84
|
+
legal_services: "022-006-000-000-000-000-000",
|
|
85
|
+
immigration_relief: "022-006-001-000-000-000-000",
|
|
86
|
+
repatriation: "022-006-001-001-000-000-000",
|
|
87
|
+
family_law: "022-006-002-000-000-000-000",
|
|
88
|
+
criminal_support: "022-006-003-000-000-000-000",
|
|
89
|
+
victim_impact_statement: "022-006-003-001-000-000-000",
|
|
90
|
+
perpetrator_accountability: "022-006-003-002-000-000-000",
|
|
91
|
+
victim_compensation: "022-006-003-003-000-000-000",
|
|
92
|
+
victims_rights_representation: "022-006-003-004-000-000-000",
|
|
93
|
+
criminal_record_relief: "022-006-003-005-000-000-000",
|
|
94
|
+
civil_support: "022-006-004-000-000-000-000",
|
|
95
|
+
protection_restraining_orders: "022-006-004-001-000-000-000",
|
|
96
|
+
public_benefits_law: "022-006-004-002-000-000-000",
|
|
97
|
+
emergency_safety_assistance: "022-006-005-000-000-000-000",
|
|
98
|
+
basic_needs: "022-007-000-000-000-000-000",
|
|
99
|
+
clothing_shoes_accessories: "022-007-001-000-000-000-000",
|
|
100
|
+
elder_assistance: "022-007-001-001-000-000-000",
|
|
101
|
+
food: "022-007-002-000-000-000-000",
|
|
102
|
+
over_the_counter_medications: "022-007-003-000-000-000-000",
|
|
103
|
+
immediate_safety_planning: "022-007-004-000-000-000-000",
|
|
104
|
+
emergency_crisis_safety_support: "022-007-004-001-000-000-000",
|
|
105
|
+
hygiene_items_personal_care: "022-007-005-000-000-000-000",
|
|
106
|
+
communications_connectivity: "022-007-006-000-000-000-000",
|
|
107
|
+
interpreter_services: "022-007-007-000-000-000-000",
|
|
108
|
+
informal_education_life_skills: "022-008-000-000-000-000-000",
|
|
109
|
+
basic_life_skills_self_care: "022-008-001-000-000-000-000",
|
|
110
|
+
accessibility_disability_support: "022-008-002-000-000-000-000",
|
|
111
|
+
parenting_education: "022-008-003-000-000-000-000",
|
|
112
|
+
learning_language_classes: "022-008-004-000-000-000-000",
|
|
113
|
+
transportation: "022-009-000-000-000-000-000",
|
|
114
|
+
transportation_assistance_direct: "022-009-001-000-000-000-000",
|
|
115
|
+
transportation_direct_emergency: "022-009-001-001-000-000-000",
|
|
116
|
+
taxi_rideshare_voucher: "022-009-002-000-000-000-000",
|
|
117
|
+
taxi_rideshare_emergency: "022-009-002-001-000-000-000",
|
|
118
|
+
bus_fare_pass: "022-009-003-000-000-000-000",
|
|
119
|
+
bus_fare_pass_emergency: "022-009-003-001-000-000-000",
|
|
120
|
+
gift_card_gas_card: "022-009-004-000-000-000-000",
|
|
121
|
+
gift_card_gas_card_emergency: "022-009-004-001-000-000-000",
|
|
122
|
+
airline_tickets: "022-009-005-000-000-000-000",
|
|
123
|
+
airline_tickets_emergency: "022-009-005-001-000-000-000",
|
|
124
|
+
dependents: "022-010-000-000-000-000-000",
|
|
125
|
+
pet_care: "022-010-001-000-000-000-000",
|
|
126
|
+
child_care: "022-010-002-000-000-000-000",
|
|
127
|
+
childrens_activities: "022-010-002-001-000-000-000",
|
|
128
|
+
children_youth_baby_supplies: "022-010-002-001-001-000-000",
|
|
129
|
+
case_coordination: "022-011-000-000-000-000-000",
|
|
130
|
+
advocacy: "022-011-001-000-000-000-000",
|
|
131
|
+
medical_advocacy: "022-011-001-001-000-000-000",
|
|
132
|
+
advocacy_emergency_medical: "022-011-001-001-001-000-000",
|
|
133
|
+
advocacy_forensic_exam: "022-011-001-001-002-000-000",
|
|
134
|
+
court_advocacy: "022-011-001-002-000-000-000",
|
|
135
|
+
crime_scene_clean_up: "022-011-001-002-001-000-000",
|
|
136
|
+
family_reunification: "022-011-001-002-002-000-000",
|
|
137
|
+
law_enforcement_interview_support: "022-011-001-002-003-000-000",
|
|
138
|
+
prosecution_interview_advocacy: "022-011-001-002-004-000-000",
|
|
139
|
+
immigration_advocacy_support: "022-011-001-002-005-000-000",
|
|
140
|
+
documentation_records_retrieval: "022-011-001-003-000-000-000",
|
|
141
|
+
obtaining_insurance: "022-011-001-003-001-000-000",
|
|
142
|
+
drivers_car_insurance: "022-011-001-003-001-001-000",
|
|
143
|
+
medical_insurance: "022-011-001-003-001-002-000",
|
|
144
|
+
obtaining_drivers_license: "022-011-001-003-002-000-000",
|
|
145
|
+
faith_resource: "022-011-001-004-000-000-000",
|
|
146
|
+
banking_notary: "022-011-001-005-000-000-000",
|
|
147
|
+
income_benefits_navigation: "022-011-001-006-000-000-000",
|
|
148
|
+
government_services_special_programs: "022-011-001-006-001-000-000",
|
|
149
|
+
intervention_employer_creditor_academic: "022-011-001-007-000-000-000",
|
|
150
|
+
formal_education_academic_support: "022-011-001-007-001-000-000",
|
|
151
|
+
adult_school_ged: "022-011-001-007-001-001-000",
|
|
152
|
+
child_school_enrollment: "022-011-001-007-001-002-000",
|
|
153
|
+
intake: "022-011-002-000-000-000-000",
|
|
154
|
+
screening: "022-011-002-001-000-000-000",
|
|
155
|
+
housing_eligibility_determination: "022-011-002-001-001-000-000",
|
|
156
|
+
coordinated_entry: "022-011-002-001-001-001-000",
|
|
157
|
+
behavioral_issues_screen: "022-011-002-001-002-000-000",
|
|
158
|
+
initial_screen: "022-011-002-001-003-000-000",
|
|
159
|
+
needs_assessment: "022-011-002-001-004-000-000",
|
|
160
|
+
tvap: "022-011-002-001-005-000-000",
|
|
161
|
+
case_management_supportive_services: "022-011-003-000-000-000-000",
|
|
162
|
+
intra_agency_provider_coordination: "022-011-003-001-000-000-000",
|
|
163
|
+
inter_agency_consultation: "022-011-003-002-000-000-000",
|
|
164
|
+
service_plan: "022-011-003-003-000-000-000",
|
|
165
|
+
hope_scale_and_plan: "022-011-003-003-001-000-000",
|
|
166
|
+
post_exit_plan: "022-011-003-004-000-000-000",
|
|
167
|
+
advanced_directives: "022-011-003-005-000-000-000",
|
|
168
|
+
other_services: "022-012-000-000-000-000-000",
|
|
165
169
|
} as const;
|
|
166
170
|
|
|
167
171
|
export type ServiceCategoryKey = keyof typeof ServiceCategoryKeys;
|
|
@@ -169,19 +173,23 @@ export type ServiceCategoryKey = keyof typeof ServiceCategoryKeys;
|
|
|
169
173
|
/**
|
|
170
174
|
* Key → positional code map for the `service_states` CVC domain.
|
|
171
175
|
*
|
|
172
|
-
* Domain: `service_states` · Version: 1.0.0 · Entries:
|
|
176
|
+
* Domain: `service_states` · Version: 1.0.0 · Entries: 14
|
|
173
177
|
*/
|
|
174
178
|
export const ServiceStateKeys = {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
missingness_root: "049-000-000-000-000-000-000",
|
|
180
|
+
unknown: "049-000-000-000-000-000-001",
|
|
181
|
+
anonymous: "049-000-000-000-000-000-002",
|
|
182
|
+
data_not_collected: "049-000-000-000-000-000-003",
|
|
183
|
+
need_identified: "049-001-000-000-000-000-000",
|
|
184
|
+
offered: "049-002-000-000-000-000-000",
|
|
185
|
+
scheduled_in_progress: "049-003-000-000-000-000-000",
|
|
186
|
+
delivered: "049-004-000-000-000-000-000",
|
|
187
|
+
completed: "049-005-000-000-000-000-000",
|
|
188
|
+
declined_by_client: "049-006-000-000-000-000-000",
|
|
189
|
+
unable_to_provide: "049-007-000-000-000-000-000",
|
|
190
|
+
unable_to_provide_eligibility: "049-007-001-000-000-000-000",
|
|
191
|
+
unable_to_provide_capacity: "049-007-002-000-000-000-000",
|
|
192
|
+
unable_to_provide_resources: "049-007-003-000-000-000-000",
|
|
185
193
|
} as const;
|
|
186
194
|
|
|
187
195
|
export type ServiceStateKey = keyof typeof ServiceStateKeys;
|
|
@@ -189,27 +197,17 @@ export type ServiceStateKey = keyof typeof ServiceStateKeys;
|
|
|
189
197
|
/**
|
|
190
198
|
* Key → positional code map for the `service_mechanisms` CVC domain.
|
|
191
199
|
*
|
|
192
|
-
* Domain: `service_mechanisms` · Version: 1.0.0 · Entries:
|
|
200
|
+
* Domain: `service_mechanisms` · Version: 1.0.0 · Entries: 8
|
|
193
201
|
*/
|
|
194
202
|
export const ServiceMechanismKeys = {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
203
|
+
missingness_root: "025-000-000-000-000-000-000",
|
|
204
|
+
unknown: "025-000-000-000-000-000-001",
|
|
205
|
+
anonymous: "025-000-000-000-000-000-002",
|
|
206
|
+
data_not_collected: "025-000-000-000-000-000-003",
|
|
207
|
+
support_via_referral: "025-001-000-000-000-000-000",
|
|
208
|
+
informational_support: "025-002-000-000-000-000-000",
|
|
209
|
+
direct_staff_contractor: "025-003-000-000-000-000-000",
|
|
210
|
+
financial_material_assistance: "025-004-000-000-000-000-000",
|
|
199
211
|
} as const;
|
|
200
212
|
|
|
201
213
|
export type ServiceMechanismKey = keyof typeof ServiceMechanismKeys;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Key → positional code map for the `missingness` CVC domain.
|
|
205
|
-
*
|
|
206
|
-
* Domain: `missingness` · Version: 1.0.0 · Entries: 4
|
|
207
|
-
*/
|
|
208
|
-
export const MissingnessKeys = {
|
|
209
|
-
missingness_root: "00-00-00-00-00-00-00",
|
|
210
|
-
unknown: "00-00-00-00-00-00-01",
|
|
211
|
-
anonymous: "00-00-00-00-00-00-02",
|
|
212
|
-
data_not_collected: "00-00-00-00-00-00-03",
|
|
213
|
-
} as const;
|
|
214
|
-
|
|
215
|
-
export type MissingnessKey = keyof typeof MissingnessKeys;
|
package/src/schemas/cvcEntry.ts
CHANGED
|
@@ -24,10 +24,11 @@ import type { InferRawDocType } from "mongoose";
|
|
|
24
24
|
// ─── Shared validators ───────────────────────────────────────────────────────
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Positional 7-segment CVC code: `
|
|
27
|
+
* Positional 7-segment CVC code: `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (format v2,
|
|
28
|
+
* 3-digit segments with a Notion-aligned domain prefix). Mirrors
|
|
28
29
|
* `CvcCodeSchema` in `validation/cvc.ts`. See locked spec §3.
|
|
29
30
|
*/
|
|
30
|
-
const CVC_CODE_PATTERN = /^\d{
|
|
31
|
+
const CVC_CODE_PATTERN = /^\d{3}(-\d{3}){6}$/;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Stable machine key for a CVC entry. Mirrors `CvcKeySchema` in
|
|
@@ -76,8 +76,9 @@ export const cvcRegistrySchemaDefinition = {
|
|
|
76
76
|
},
|
|
77
77
|
|
|
78
78
|
// Selective inclusion/exclusion lists. Both contain CVC entry codes
|
|
79
|
-
// (positional 7-segment, e.g. "
|
|
80
|
-
// applies excludes after includes when resolving the effective
|
|
79
|
+
// (positional 7-segment, format v2: e.g. "022-002-000-000-000-000-000").
|
|
80
|
+
// The runtime applies excludes after includes when resolving the effective
|
|
81
|
+
// set.
|
|
81
82
|
excludedEntries: {
|
|
82
83
|
type: [String],
|
|
83
84
|
default: [],
|
package/src/validation/cvc.ts
CHANGED
|
@@ -12,13 +12,18 @@
|
|
|
12
12
|
* Canonical spec:
|
|
13
13
|
* /gt/docs/data/cvcs/CVC Implementation Spec 2780449faf8045258c67daab0f1c5569.md
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* - Positional 7-segment codes `
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* Format v2 (2026-04-15):
|
|
16
|
+
* - Positional 7-segment codes `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (3 digits per
|
|
17
|
+
* segment). Segment 1 is the Notion-aligned domain prefix:
|
|
18
|
+
* `022` service_categories (CVC-22)
|
|
19
|
+
* `025` service_mechanisms (CVC-25)
|
|
20
|
+
* `049` service_states (CVC-49)
|
|
21
|
+
* - Missingness entries are embedded per-domain (synthetic `missingness_root`
|
|
22
|
+
* at `<prefix>-000-000-000-000-000-000` plus three values at segment 7 =
|
|
23
|
+
* `001`/`002`/`003`). The shared `missingness.v1.0.0.json` file was
|
|
24
|
+
* retired in favor of per-domain missingness.
|
|
25
|
+
* - Envelope `missingness` field and the C7 invariant have been removed; the
|
|
26
|
+
* shared-merge pathway no longer exists.
|
|
22
27
|
*/
|
|
23
28
|
|
|
24
29
|
import { z } from "zod";
|
|
@@ -26,11 +31,12 @@ import { z } from "zod";
|
|
|
26
31
|
// ─── Primitive schemas ───────────────────────────────────────────────────────
|
|
27
32
|
|
|
28
33
|
/**
|
|
29
|
-
* 7-segment positional CVC code: `
|
|
30
|
-
* segment).
|
|
31
|
-
* segments
|
|
34
|
+
* 7-segment positional CVC code: `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (three digits
|
|
35
|
+
* per segment). Segment 1 is the Notion-aligned domain prefix. Remaining
|
|
36
|
+
* hierarchy segments are filled left-to-right as levels deepen; unused
|
|
37
|
+
* segments remain `000`. See locked spec §3 (format v2).
|
|
32
38
|
*/
|
|
33
|
-
export const CvcCodeSchema = z.string().regex(/^\d{
|
|
39
|
+
export const CvcCodeSchema = z.string().regex(/^\d{3}(-\d{3}){6}$/);
|
|
34
40
|
|
|
35
41
|
/**
|
|
36
42
|
* Stable machine key for a CVC entry. Must start with a lowercase letter and
|
|
@@ -79,21 +85,15 @@ export const ServiceCategoryEntrySchema = CvcEntrySchema.extend({
|
|
|
79
85
|
/**
|
|
80
86
|
* Top-level SOT JSON envelope. One envelope per (domain, version) pair.
|
|
81
87
|
*
|
|
82
|
-
* `missingness` is an optional array of missingness keys to merge into this
|
|
83
|
-
* CVC at seed time. `["all"]` is the sentinel meaning "merge the missingness
|
|
84
|
-
* root plus all three value entries". Individual keys merge only those.
|
|
85
|
-
* Absent, empty, or null means "skip missingness merge". The missingness CVC
|
|
86
|
-
* file itself omits this field because merging missingness into itself is
|
|
87
|
-
* nonsensical. See locked spec §2.1 and §5.2.
|
|
88
|
-
*
|
|
89
88
|
* `levels` is a positional map from level number (`"0"`, `"1"`, …) to a human
|
|
90
|
-
* label describing the level.
|
|
89
|
+
* label describing the level. Missingness entries are embedded in `entries`
|
|
90
|
+
* (per-domain) rather than merged in from a shared SOT file; see module
|
|
91
|
+
* header for the v2 format summary.
|
|
91
92
|
*/
|
|
92
93
|
export const CvcEnvelopeSchema = z.object({
|
|
93
94
|
domain: z.string().min(1),
|
|
94
95
|
name: z.string().min(1),
|
|
95
96
|
version: z.string().min(1),
|
|
96
|
-
missingness: z.array(z.string()).optional(),
|
|
97
97
|
levels: z.record(z.string(), z.string()),
|
|
98
98
|
entries: z.array(CvcEntrySchema),
|
|
99
99
|
});
|
|
@@ -122,28 +122,30 @@ export type CvcDomain = string;
|
|
|
122
122
|
*
|
|
123
123
|
* - Segment 7 non-zero → level 0 (missingness value entry, e.g. `unknown`).
|
|
124
124
|
* - Otherwise return the index (1..5) of the last non-zero hierarchy segment.
|
|
125
|
-
* -
|
|
125
|
+
* - Hierarchy segments 2..7 all zero → level 0 (per-domain missingness root,
|
|
126
|
+
* e.g. `022-000-000-000-000-000-000`). Segment 1 carries the domain prefix
|
|
127
|
+
* and is intentionally not consulted by the level derivation.
|
|
126
128
|
*/
|
|
127
129
|
export function getCvcLevel(code: string): number {
|
|
128
130
|
const segments = code.split("-");
|
|
129
131
|
// segments[6] is the missingness slot (positional segment 7).
|
|
130
|
-
if (segments[6] !== "
|
|
132
|
+
if (segments[6] !== "000") return 0;
|
|
131
133
|
// Walk hierarchy segments 6..2 (indices 5..1) looking for the deepest
|
|
132
134
|
// populated level.
|
|
133
135
|
for (let i = 5; i >= 1; i -= 1) {
|
|
134
|
-
if (segments[i] !== "
|
|
136
|
+
if (segments[i] !== "000") return i;
|
|
135
137
|
}
|
|
136
138
|
return 0;
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
/**
|
|
140
142
|
* Error collected by {@link validateCvc}. Each error names the invariant it
|
|
141
|
-
* violates (`C1`..`C8`) so CI output points
|
|
142
|
-
* that failed. `code` or `key` narrow the
|
|
143
|
-
* violation is entry-scoped.
|
|
143
|
+
* violates (`C1`..`C8`, skipping the retired `C7`) so CI output points
|
|
144
|
+
* straight at the locked spec rule that failed. `code` or `key` narrow the
|
|
145
|
+
* error to a specific entry when the violation is entry-scoped.
|
|
144
146
|
*/
|
|
145
147
|
export interface CvcValidationError {
|
|
146
|
-
invariant: "C1" | "C2" | "C3" | "C4" | "C5" | "C6" | "
|
|
148
|
+
invariant: "C1" | "C2" | "C3" | "C4" | "C5" | "C6" | "C8";
|
|
147
149
|
message: string;
|
|
148
150
|
code?: string;
|
|
149
151
|
key?: string;
|
|
@@ -155,7 +157,7 @@ export interface CvcValidationError {
|
|
|
155
157
|
* function enforces the cross-entry *semantics* that Zod cannot express.
|
|
156
158
|
*
|
|
157
159
|
* Invariants (locked spec §4):
|
|
158
|
-
* - **C1** Code format + uniqueness (§4.1).
|
|
160
|
+
* - **C1** Code format + uniqueness (§4.1). Format v2 uses 3-digit segments.
|
|
159
161
|
* - **C2** Key format + uniqueness (§4.2).
|
|
160
162
|
* - **C3** Tree: every `parentCode` resolves to an existing entry or null; no
|
|
161
163
|
* cycles (§4.3).
|
|
@@ -165,9 +167,10 @@ export interface CvcValidationError {
|
|
|
165
167
|
* - **C6** Cross-CVC `relevantMechanisms` references resolve against a
|
|
166
168
|
* provided `service_mechanisms` key set (§4.5, §7). Only checked when the
|
|
167
169
|
* caller supplies `options.mechanismKeys`.
|
|
168
|
-
* - **C7**
|
|
169
|
-
* `missingness
|
|
170
|
-
* `
|
|
170
|
+
* - **C7** _Retired in format v2_ (envelope no longer carries the shared
|
|
171
|
+
* `missingness` field; missingness is per-domain and embedded in
|
|
172
|
+
* `entries`). The invariant slot is intentionally left empty to preserve
|
|
173
|
+
* the numbering of C1/C2/C3/C4/C5/C6/C8 in historical references.
|
|
171
174
|
* - **C8** No entry anywhere contains a key `'provided'` (legacy Thread UI
|
|
172
175
|
* label guard; not a canonical state).
|
|
173
176
|
*
|
|
@@ -184,31 +187,14 @@ export function validateCvc(
|
|
|
184
187
|
const errors: CvcValidationError[] = [];
|
|
185
188
|
const { entries } = envelope;
|
|
186
189
|
|
|
187
|
-
// C7: envelope-level required fields. Zod already rejects missing `domain`,
|
|
188
|
-
// `name`, `version`, `levels`, and `entries`. We additionally require
|
|
189
|
-
// `missingness` to be present (even as an empty array) at CI time so the
|
|
190
|
-
// seed CLI sees an explicit "opt-out" rather than an undefined field.
|
|
191
|
-
//
|
|
192
|
-
// Exemption: the `missingness` CVC file itself legitimately omits this
|
|
193
|
-
// field because merging missingness into itself is nonsensical (locked spec
|
|
194
|
-
// §9.2). This is the one sanctioned omission.
|
|
195
|
-
if (envelope.domain !== "missingness" && envelope.missingness === undefined) {
|
|
196
|
-
errors.push({
|
|
197
|
-
invariant: "C7",
|
|
198
|
-
message:
|
|
199
|
-
"envelope is missing required field `missingness` (must be an array, " +
|
|
200
|
-
"use `[]` to opt out of the missingness merge)",
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
190
|
// ── C1: code format + uniqueness ──────────────────────────────────────────
|
|
205
|
-
const codeRe = /^\d{
|
|
191
|
+
const codeRe = /^\d{3}(-\d{3}){6}$/;
|
|
206
192
|
const seenCodes = new Set<string>();
|
|
207
193
|
for (const entry of entries) {
|
|
208
194
|
if (!codeRe.test(entry.code)) {
|
|
209
195
|
errors.push({
|
|
210
196
|
invariant: "C1",
|
|
211
|
-
message: `code does not match /^\\d{
|
|
197
|
+
message: `code does not match /^\\d{3}(-\\d{3}){6}$/`,
|
|
212
198
|
code: entry.code,
|
|
213
199
|
key: entry.key,
|
|
214
200
|
});
|