@htilabs/platform-common-models 0.2.0-beta.3 → 0.3.0-beta.5

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 (75) hide show
  1. package/README.md +38 -0
  2. package/dist/constants/index.cjs +0 -140
  3. package/dist/constants/index.cjs.map +1 -1
  4. package/dist/constants/index.d.cts +146 -5
  5. package/dist/constants/index.d.ts +146 -5
  6. package/dist/constants/index.js +0 -128
  7. package/dist/constants/index.js.map +1 -1
  8. package/dist/{platform-role-AHv1l5Og.d.cts → cvcEntry-wqktWfzE.d.cts} +231 -37
  9. package/dist/{platform-role-AHv1l5Og.d.ts → cvcEntry-wqktWfzE.d.ts} +231 -37
  10. package/dist/cvcs/index.cjs +2184 -0
  11. package/dist/cvcs/index.cjs.map +1 -0
  12. package/dist/cvcs/index.d.cts +2384 -0
  13. package/dist/cvcs/index.d.ts +2384 -0
  14. package/dist/cvcs/index.js +2154 -0
  15. package/dist/cvcs/index.js.map +1 -0
  16. package/dist/index--NCIPluF.d.cts +378 -0
  17. package/dist/index-CFOrHA8l.d.ts +378 -0
  18. package/dist/index.cjs +2962 -140
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +217 -3
  21. package/dist/index.d.ts +217 -3
  22. package/dist/index.js +2934 -128
  23. package/dist/index.js.map +1 -1
  24. package/dist/models/index.cjs +211 -0
  25. package/dist/models/index.cjs.map +1 -1
  26. package/dist/models/index.d.cts +3 -292
  27. package/dist/models/index.d.ts +3 -292
  28. package/dist/models/index.js +209 -0
  29. package/dist/models/index.js.map +1 -1
  30. package/dist/{platform-auth-DHSJP7XP.d.cts → platform-auth-C-G2qeGM.d.cts} +1 -36
  31. package/dist/{platform-auth-DHSJP7XP.d.ts → platform-auth-C-G2qeGM.d.ts} +1 -36
  32. package/dist/schemas/index.cjs +195 -116
  33. package/dist/schemas/index.cjs.map +1 -1
  34. package/dist/schemas/index.d.cts +11 -11
  35. package/dist/schemas/index.d.ts +11 -11
  36. package/dist/schemas/index.js +189 -116
  37. package/dist/schemas/index.js.map +1 -1
  38. package/dist/services/index.cjs +1442 -0
  39. package/dist/services/index.cjs.map +1 -0
  40. package/dist/services/index.d.cts +305 -0
  41. package/dist/services/index.d.ts +305 -0
  42. package/dist/services/index.js +1417 -0
  43. package/dist/services/index.js.map +1 -0
  44. package/dist/types/index.d.cts +2 -2
  45. package/dist/types/index.d.ts +2 -2
  46. package/dist/validation/index.cjs +261 -0
  47. package/dist/validation/index.cjs.map +1 -0
  48. package/dist/validation/index.d.cts +251 -0
  49. package/dist/validation/index.d.ts +251 -0
  50. package/dist/validation/index.js +228 -0
  51. package/dist/validation/index.js.map +1 -0
  52. package/package.json +36 -12
  53. package/src/__tests__/__snapshots__/cvc-sot.snap +22 -0
  54. package/src/__tests__/cvc-sot-snapshot.test.ts +184 -0
  55. package/src/__tests__/cvc-structural.test.ts +130 -0
  56. package/src/constants/ic.ts +0 -154
  57. package/src/constants/service-catalog.ts +146 -4
  58. package/src/cvcs/index.ts +31 -0
  59. package/src/cvcs/missingness.v1.0.0.json +50 -0
  60. package/src/cvcs/serviceCategories.v1.0.0.json +1947 -0
  61. package/src/cvcs/serviceMechanisms.v1.0.0.json +47 -0
  62. package/src/cvcs/serviceStates.v1.0.0.json +106 -0
  63. package/src/generated/cvc-enums.ts +215 -0
  64. package/src/index.ts +61 -1
  65. package/src/models/cvcEntryModel.ts +32 -0
  66. package/src/models/cvcRegistryModel.ts +35 -0
  67. package/src/models/index.ts +8 -0
  68. package/src/schemas/cvcEntry.ts +158 -0
  69. package/src/schemas/cvcRegistry.ts +149 -0
  70. package/src/schemas/index.ts +16 -0
  71. package/src/services/__tests__/cvcRegistryService.test.ts +614 -0
  72. package/src/services/cvcRegistryService.ts +729 -0
  73. package/src/services/index.ts +21 -0
  74. package/src/validation/cvc.ts +414 -0
  75. package/src/validation/index.ts +15 -0
@@ -0,0 +1,47 @@
1
+ {
2
+ "domain": "service_mechanisms",
3
+ "name": "Core Service Mechanisms",
4
+ "version": "1.0.0",
5
+ "missingness": ["all"],
6
+ "levels": {
7
+ "1": "Service Mechanism"
8
+ },
9
+ "entries": [
10
+ {
11
+ "code": "03-01-00-00-00-00-00",
12
+ "key": "support_via_referral",
13
+ "title": "Support via Referral",
14
+ "selectable": true,
15
+ "parentCode": null,
16
+ "childCodes": [],
17
+ "definition": "Connecting the client to an external provider or resource, and documenting the referral action and follow-up if applicable."
18
+ },
19
+ {
20
+ "code": "03-02-00-00-00-00-00",
21
+ "key": "informational_support",
22
+ "title": "Informational Support",
23
+ "selectable": true,
24
+ "parentCode": null,
25
+ "childCodes": [],
26
+ "definition": "Education, informational materials, guidance, navigation, instructions, or resource lists where the primary delivery is information."
27
+ },
28
+ {
29
+ "code": "03-03-00-00-00-00-00",
30
+ "key": "direct_staff_contractor",
31
+ "title": "Direct Staff/Contractor Service",
32
+ "selectable": true,
33
+ "parentCode": null,
34
+ "childCodes": [],
35
+ "definition": "Support delivered via personnel time and effort (advocacy, case management, counseling/clinician services, accompaniment, coordination, etc.)."
36
+ },
37
+ {
38
+ "code": "03-04-00-00-00-00-00",
39
+ "key": "financial_material_assistance",
40
+ "title": "Financial/Material Assistance",
41
+ "selectable": true,
42
+ "parentCode": null,
43
+ "childCodes": [],
44
+ "definition": "Cash, vouchers, goods, payments, or anything with monetary value transferred or provided on behalf of the client."
45
+ }
46
+ ]
47
+ }
@@ -0,0 +1,106 @@
1
+ {
2
+ "domain": "service_states",
3
+ "name": "Core Service State",
4
+ "version": "1.0.0",
5
+ "missingness": ["all"],
6
+ "levels": {
7
+ "1": "Primary State",
8
+ "2": "Sub-State"
9
+ },
10
+ "entries": [
11
+ {
12
+ "code": "02-01-00-00-00-00-00",
13
+ "key": "need_identified",
14
+ "title": "Need identified",
15
+ "selectable": true,
16
+ "parentCode": null,
17
+ "childCodes": [],
18
+ "definition": "A service need was identified/recorded; no commitment to deliver has been made yet."
19
+ },
20
+ {
21
+ "code": "02-02-00-00-00-00-00",
22
+ "key": "offered",
23
+ "title": "Offered",
24
+ "selectable": true,
25
+ "parentCode": null,
26
+ "childCodes": [],
27
+ "definition": "A service option was offered, but not yet delivered."
28
+ },
29
+ {
30
+ "code": "02-03-00-00-00-00-00",
31
+ "key": "scheduled_in_progress",
32
+ "title": "Scheduled / in progress",
33
+ "selectable": true,
34
+ "parentCode": null,
35
+ "childCodes": [],
36
+ "definition": "Service is scheduled or actively underway as a multi-step process."
37
+ },
38
+ {
39
+ "code": "02-04-00-00-00-00-00",
40
+ "key": "delivered",
41
+ "title": "Delivered",
42
+ "selectable": true,
43
+ "parentCode": null,
44
+ "childCodes": [],
45
+ "definition": "A unit of service was delivered/provided or confirmed received."
46
+ },
47
+ {
48
+ "code": "02-05-00-00-00-00-00",
49
+ "key": "completed",
50
+ "title": "Completed",
51
+ "selectable": true,
52
+ "parentCode": null,
53
+ "childCodes": [],
54
+ "definition": "Service episode/plan is finished and closed."
55
+ },
56
+ {
57
+ "code": "02-06-00-00-00-00-00",
58
+ "key": "declined_by_client",
59
+ "title": "Declined by client",
60
+ "selectable": true,
61
+ "parentCode": null,
62
+ "childCodes": [],
63
+ "definition": "Client declined the offered service."
64
+ },
65
+ {
66
+ "code": "02-07-00-00-00-00-00",
67
+ "key": "unable_to_provide",
68
+ "title": "Unable to provide",
69
+ "selectable": true,
70
+ "parentCode": null,
71
+ "childCodes": [
72
+ "02-07-01-00-00-00-00",
73
+ "02-07-02-00-00-00-00",
74
+ "02-07-03-00-00-00-00"
75
+ ],
76
+ "definition": "Program could not provide the service."
77
+ },
78
+ {
79
+ "code": "02-07-01-00-00-00-00",
80
+ "key": "unable_to_provide_eligibility",
81
+ "title": "Unable due to eligibility",
82
+ "selectable": true,
83
+ "parentCode": "02-07-00-00-00-00-00",
84
+ "childCodes": [],
85
+ "definition": "Client did not have eligibility for the Service."
86
+ },
87
+ {
88
+ "code": "02-07-02-00-00-00-00",
89
+ "key": "unable_to_provide_capacity",
90
+ "title": "Unable due to capacity",
91
+ "selectable": true,
92
+ "parentCode": "02-07-00-00-00-00-00",
93
+ "childCodes": [],
94
+ "definition": "Program did not have capacity to provide the Service."
95
+ },
96
+ {
97
+ "code": "02-07-03-00-00-00-00",
98
+ "key": "unable_to_provide_resources",
99
+ "title": "Unable due to resource",
100
+ "selectable": true,
101
+ "parentCode": "02-07-00-00-00-00-00",
102
+ "childCodes": [],
103
+ "definition": "Program did not have sufficient resources to provide the Service."
104
+ }
105
+ ]
106
+ }
@@ -0,0 +1,215 @@
1
+ /**
2
+ * @htilabs/platform-common-models — Generated CVC Key Enums
3
+ *
4
+ * AUTO-GENERATED FILE — DO NOT EDIT BY HAND.
5
+ * Regenerate with: `npm run codegen:cvc` (see scripts/codegen-cvc-enums.ts).
6
+ *
7
+ * Provides compile-time `key → code` maps for each CVC domain so TypeScript
8
+ * consumers get autocompletion and type safety on CVC keys. The runtime
9
+ * equivalent is `CvcRegistryService.getEntryByKey()`. Locked spec §9.4.
10
+ */
11
+
12
+ /**
13
+ * Key → positional code map for the `service_categories` CVC domain.
14
+ *
15
+ * Domain: `service_categories` · Version: 1.0.0 · Entries: 147
16
+ */
17
+ export const ServiceCategoryKeys = {
18
+ social_support_community_engagement: "01-02-00-00-00-00-00",
19
+ cultural_needs_support: "01-02-01-00-00-00-00",
20
+ gift_holiday_resources: "01-02-02-00-00-00-00",
21
+ peer_facilitated_supportive_group: "01-02-03-00-00-00-00",
22
+ community_service_learning: "01-02-04-00-00-00-00",
23
+ survivor_support_psychoeducation: "01-02-05-00-00-00-00",
24
+ financial_and_employment: "01-03-00-00-00-00-00",
25
+ financial_support: "01-03-01-00-00-00-00",
26
+ emergency_financial_assistance: "01-03-01-01-00-00-00",
27
+ employment_support: "01-03-02-00-00-00-00",
28
+ supported_employment: "01-03-02-01-00-00-00",
29
+ employment_assistance_job_search: "01-03-02-02-00-00-00",
30
+ job_vocation_training: "01-03-02-03-00-00-00",
31
+ healthcare: "01-04-00-00-00-00-00",
32
+ medical: "01-04-01-00-00-00-00",
33
+ emergency_medical_care: "01-04-01-01-00-00-00",
34
+ forensic_exam_interview: "01-04-01-02-00-00-00",
35
+ dv_exam: "01-04-01-02-01-00-00",
36
+ sane_exam: "01-04-01-02-02-00-00",
37
+ std_testing: "01-04-01-02-03-00-00",
38
+ specialized_assessments: "01-04-01-02-04-00-00",
39
+ counseling_evaluation_assessment: "01-04-01-02-04-01-00",
40
+ stalking_assessment: "01-04-01-02-04-02-00",
41
+ danger_assessment: "01-04-01-02-04-03-00",
42
+ indepth_assessment: "01-04-01-02-04-04-00",
43
+ outpatient_medical: "01-04-01-03-00-00-00",
44
+ dental: "01-04-01-03-01-00-00",
45
+ vision: "01-04-01-03-02-00-00",
46
+ tattoo_removal: "01-04-01-03-03-00-00",
47
+ pet_medical: "01-04-01-03-04-00-00",
48
+ pregnancy_care: "01-04-01-04-00-00-00",
49
+ prenatal_care: "01-04-01-04-01-00-00",
50
+ postnatal_care_client: "01-04-01-04-02-00-00",
51
+ postnatal_care_newborn: "01-04-01-04-03-00-00",
52
+ emotional_support_mental_health: "01-04-02-00-00-00-00",
53
+ individual_counseling: "01-04-02-01-00-00-00",
54
+ group_counseling: "01-04-02-02-00-00-00",
55
+ family_counseling: "01-04-02-03-00-00-00",
56
+ counseling_treatment_planning: "01-04-02-04-00-00-00",
57
+ counseling_treatment_plan_review: "01-04-02-05-00-00-00",
58
+ behavioral_occupational_support: "01-04-02-06-00-00-00",
59
+ substance_abuse_treatment: "01-04-02-06-01-00-00",
60
+ coping_strategy_support: "01-04-02-06-02-00-00",
61
+ other_therapy: "01-04-02-07-00-00-00",
62
+ housing_services: "01-05-00-00-00-00-00",
63
+ emergency_shelter: "01-05-01-00-00-00-00",
64
+ day_shelter_dropin: "01-05-01-01-00-00-00",
65
+ host_homes_safe_homes: "01-05-01-02-00-00-00",
66
+ congregate_shelter_bednight: "01-05-01-03-00-00-00",
67
+ emergency_hotel_motel: "01-05-01-04-00-00-00",
68
+ night_by_night_shelter: "01-05-01-05-00-00-00",
69
+ transitional_housing: "01-05-02-00-00-00-00",
70
+ housing_renovation_modification: "01-05-03-00-00-00-00",
71
+ household_setup_goods: "01-05-03-01-00-00-00",
72
+ housing_navigation_placement: "01-05-04-00-00-00-00",
73
+ housing_financial_assistance: "01-05-04-01-00-00-00",
74
+ rental_payment_assistance: "01-05-04-01-01-00-00",
75
+ security_deposit_allowance: "01-05-04-01-01-01-00",
76
+ utility_assistance: "01-05-04-01-01-02-00",
77
+ relocation_moving_assistance: "01-05-04-02-00-00-00",
78
+ housing_stabilization_eviction_prevention: "01-05-05-00-00-00-00",
79
+ tenant_based_scattered_site: "01-05-06-00-00-00-00",
80
+ legal_services: "01-06-00-00-00-00-00",
81
+ immigration_relief: "01-06-01-00-00-00-00",
82
+ repatriation: "01-06-01-01-00-00-00",
83
+ family_law: "01-06-02-00-00-00-00",
84
+ criminal_support: "01-06-03-00-00-00-00",
85
+ victim_impact_statement: "01-06-03-01-00-00-00",
86
+ perpetrator_accountability: "01-06-03-02-00-00-00",
87
+ victim_compensation: "01-06-03-03-00-00-00",
88
+ victims_rights_representation: "01-06-03-04-00-00-00",
89
+ criminal_record_relief: "01-06-03-05-00-00-00",
90
+ civil_support: "01-06-04-00-00-00-00",
91
+ protection_restraining_orders: "01-06-04-01-00-00-00",
92
+ public_benefits_law: "01-06-04-02-00-00-00",
93
+ emergency_safety_assistance: "01-06-05-00-00-00-00",
94
+ basic_needs: "01-07-00-00-00-00-00",
95
+ clothing_shoes_accessories: "01-07-01-00-00-00-00",
96
+ elder_assistance: "01-07-01-01-00-00-00",
97
+ food: "01-07-02-00-00-00-00",
98
+ over_the_counter_medications: "01-07-03-00-00-00-00",
99
+ immediate_safety_planning: "01-07-04-00-00-00-00",
100
+ emergency_crisis_safety_support: "01-07-04-01-00-00-00",
101
+ hygiene_items_personal_care: "01-07-05-00-00-00-00",
102
+ communications_connectivity: "01-07-06-00-00-00-00",
103
+ interpreter_services: "01-07-07-00-00-00-00",
104
+ informal_education_life_skills: "01-08-00-00-00-00-00",
105
+ basic_life_skills_self_care: "01-08-01-00-00-00-00",
106
+ accessibility_disability_support: "01-08-02-00-00-00-00",
107
+ parenting_education: "01-08-03-00-00-00-00",
108
+ learning_language_classes: "01-08-04-00-00-00-00",
109
+ transportation: "01-09-00-00-00-00-00",
110
+ transportation_assistance_direct: "01-09-01-00-00-00-00",
111
+ transportation_direct_emergency: "01-09-01-01-00-00-00",
112
+ taxi_rideshare_voucher: "01-09-02-00-00-00-00",
113
+ taxi_rideshare_emergency: "01-09-02-01-00-00-00",
114
+ bus_fare_pass: "01-09-03-00-00-00-00",
115
+ bus_fare_pass_emergency: "01-09-03-01-00-00-00",
116
+ gift_card_gas_card: "01-09-04-00-00-00-00",
117
+ gift_card_gas_card_emergency: "01-09-04-01-00-00-00",
118
+ airline_tickets: "01-09-05-00-00-00-00",
119
+ airline_tickets_emergency: "01-09-05-01-00-00-00",
120
+ dependents: "01-10-00-00-00-00-00",
121
+ pet_care: "01-10-01-00-00-00-00",
122
+ child_care: "01-10-02-00-00-00-00",
123
+ childrens_activities: "01-10-02-01-00-00-00",
124
+ children_youth_baby_supplies: "01-10-02-01-01-00-00",
125
+ case_coordination: "01-11-00-00-00-00-00",
126
+ advocacy: "01-11-01-00-00-00-00",
127
+ medical_advocacy: "01-11-01-01-00-00-00",
128
+ advocacy_emergency_medical: "01-11-01-01-01-00-00",
129
+ advocacy_forensic_exam: "01-11-01-01-02-00-00",
130
+ court_advocacy: "01-11-01-02-00-00-00",
131
+ crime_scene_clean_up: "01-11-01-02-01-00-00",
132
+ family_reunification: "01-11-01-02-02-00-00",
133
+ law_enforcement_interview_support: "01-11-01-02-03-00-00",
134
+ prosecution_interview_advocacy: "01-11-01-02-04-00-00",
135
+ immigration_advocacy_support: "01-11-01-02-05-00-00",
136
+ documentation_records_retrieval: "01-11-01-03-00-00-00",
137
+ obtaining_insurance: "01-11-01-03-01-00-00",
138
+ drivers_car_insurance: "01-11-01-03-01-01-00",
139
+ medical_insurance: "01-11-01-03-01-02-00",
140
+ obtaining_drivers_license: "01-11-01-03-02-00-00",
141
+ faith_resource: "01-11-01-04-00-00-00",
142
+ banking_notary: "01-11-01-05-00-00-00",
143
+ income_benefits_navigation: "01-11-01-06-00-00-00",
144
+ government_services_special_programs: "01-11-01-06-01-00-00",
145
+ intervention_employer_creditor_academic: "01-11-01-07-00-00-00",
146
+ formal_education_academic_support: "01-11-01-07-01-00-00",
147
+ adult_school_ged: "01-11-01-07-01-01-00",
148
+ child_school_enrollment: "01-11-01-07-01-02-00",
149
+ intake: "01-11-02-00-00-00-00",
150
+ screening: "01-11-02-01-00-00-00",
151
+ housing_eligibility_determination: "01-11-02-01-01-00-00",
152
+ coordinated_entry: "01-11-02-01-01-01-00",
153
+ behavioral_issues_screen: "01-11-02-01-02-00-00",
154
+ initial_screen: "01-11-02-01-03-00-00",
155
+ needs_assessment: "01-11-02-01-04-00-00",
156
+ tvap: "01-11-02-01-05-00-00",
157
+ case_management_supportive_services: "01-11-03-00-00-00-00",
158
+ intra_agency_provider_coordination: "01-11-03-01-00-00-00",
159
+ inter_agency_consultation: "01-11-03-02-00-00-00",
160
+ service_plan: "01-11-03-03-00-00-00",
161
+ hope_scale_and_plan: "01-11-03-03-01-00-00",
162
+ post_exit_plan: "01-11-03-04-00-00-00",
163
+ advanced_directives: "01-11-03-05-00-00-00",
164
+ other_services: "01-12-00-00-00-00-00",
165
+ } as const;
166
+
167
+ export type ServiceCategoryKey = keyof typeof ServiceCategoryKeys;
168
+
169
+ /**
170
+ * Key → positional code map for the `service_states` CVC domain.
171
+ *
172
+ * Domain: `service_states` · Version: 1.0.0 · Entries: 10
173
+ */
174
+ export const ServiceStateKeys = {
175
+ need_identified: "02-01-00-00-00-00-00",
176
+ offered: "02-02-00-00-00-00-00",
177
+ scheduled_in_progress: "02-03-00-00-00-00-00",
178
+ delivered: "02-04-00-00-00-00-00",
179
+ completed: "02-05-00-00-00-00-00",
180
+ declined_by_client: "02-06-00-00-00-00-00",
181
+ unable_to_provide: "02-07-00-00-00-00-00",
182
+ unable_to_provide_eligibility: "02-07-01-00-00-00-00",
183
+ unable_to_provide_capacity: "02-07-02-00-00-00-00",
184
+ unable_to_provide_resources: "02-07-03-00-00-00-00",
185
+ } as const;
186
+
187
+ export type ServiceStateKey = keyof typeof ServiceStateKeys;
188
+
189
+ /**
190
+ * Key → positional code map for the `service_mechanisms` CVC domain.
191
+ *
192
+ * Domain: `service_mechanisms` · Version: 1.0.0 · Entries: 4
193
+ */
194
+ export const ServiceMechanismKeys = {
195
+ support_via_referral: "03-01-00-00-00-00-00",
196
+ informational_support: "03-02-00-00-00-00-00",
197
+ direct_staff_contractor: "03-03-00-00-00-00-00",
198
+ financial_material_assistance: "03-04-00-00-00-00-00",
199
+ } as const;
200
+
201
+ 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/index.ts CHANGED
@@ -18,13 +18,73 @@
18
18
  * const platformDb = mongoose.createConnection(PLATFORM_DB_URI);
19
19
  * const { FormModel, SectionModel, QuestionModel } = createPlatformModels(platformDb);
20
20
  * ```
21
+ *
22
+ * @example CVC data layer (mongoose required)
23
+ * ```typescript
24
+ * import {
25
+ * CvcRegistryService,
26
+ * buildCvcRegistrySchema,
27
+ * buildCvcEntrySchema,
28
+ * compileCvcRegistryModel,
29
+ * compileCvcEntryModel,
30
+ * CvcEnvelopeSchema,
31
+ * serviceCategoriesSot,
32
+ * } from '@htilabs/platform-common-models';
33
+ * ```
21
34
  */
22
35
 
23
36
  // Export all constants
24
37
  export * from "./constants/index.js";
25
38
 
26
- // Export schemas (requires mongoose peer dependency)
39
+ // Export schemas (requires mongoose peer dependency).
40
+ // Note: this re-exports the Mongoose-derived `CvcEntry` and `CvcRegistry`
41
+ // types (the persistence shapes). Consumers wanting the Zod-validated entry
42
+ // shape should import from `@htilabs/platform-common-models/validation`.
27
43
  export * from "./schemas/index.js";
28
44
 
29
45
  // Export model factories (requires mongoose peer dependency)
30
46
  export * from "./models/index.js";
47
+
48
+ // Export generated CVC key enums (compile-time `key → code` maps).
49
+ // Generated from src/cvcs/*.json via `npm run codegen:cvc`. See locked spec §9.4.
50
+ export * from "./generated/cvc-enums.js";
51
+
52
+ // Export services (requires mongoose peer dependency)
53
+ export * from "./services/index.js";
54
+
55
+ // ─── CVC validation surface (Zod schemas + inferred types) ──────────────────
56
+ // Per co-am3.7 (Phase 1.7) bead: re-export the Zod schemas, plus the inferred
57
+ // scalar types and `CvcDomain`. The Zod-inferred entry shape is exposed via
58
+ // the `/validation` subpath under its natural `CvcEntry` name; here it would
59
+ // collide with the Mongoose-derived `CvcEntry` already re-exported above.
60
+
61
+ export {
62
+ CvcCodeSchema,
63
+ CvcKeySchema,
64
+ CvcEntrySchema,
65
+ ServiceCategoryEntrySchema,
66
+ CvcEnvelopeSchema,
67
+ } from "./validation/cvc.js";
68
+
69
+ export type {
70
+ CvcCode,
71
+ CvcKey,
72
+ CvcEnvelope,
73
+ ServiceCategoryEntry,
74
+ CvcDomain,
75
+ } from "./validation/cvc.js";
76
+
77
+ // ─── CVC factory model named aliases ────────────────────────────────────────
78
+ // Per co-am3.7 bead: surface the model factories under explicit
79
+ // `compileCvcRegistryModel` / `compileCvcEntryModel` names. The underlying
80
+ // `compileModel` is also reachable via the `cvcRegistryModel` /
81
+ // `cvcEntryModel` namespaces re-exported from `./models/index.js`.
82
+
83
+ export { compileModel as compileCvcRegistryModel } from "./models/cvcRegistryModel.js";
84
+ export { compileModel as compileCvcEntryModel } from "./models/cvcEntryModel.js";
85
+
86
+ // ─── CVC Source-of-Truth JSON re-exports ────────────────────────────────────
87
+ // Pre-parsed envelope objects so consumers can load the SOTs without
88
+ // filesystem access. See `./cvcs/index.ts` for the full list and naming.
89
+
90
+ export * from "./cvcs/index.js";
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @htilabs/platform-common-models — CvcEntry Model
3
+ *
4
+ * Factory for creating the CvcEntry model bound to a specific connection.
5
+ * Mirrors the buildSchema/compileModel pattern used by the other platform
6
+ * models in this package (see `formModel.ts`, `questionModel.ts`).
7
+ */
8
+
9
+ import type { Connection, Model, HydratedDocument } from "mongoose";
10
+ import { buildCvcEntrySchema, type CvcEntry } from "../schemas/cvcEntry.js";
11
+
12
+ export type CvcEntryDoc = HydratedDocument<CvcEntry>;
13
+
14
+ /**
15
+ * Build the CvcEntry schema.
16
+ * @returns Mongoose Schema for CvcEntry
17
+ */
18
+ export { buildCvcEntrySchema as buildSchema };
19
+
20
+ /**
21
+ * Compile the CvcEntry model on a specific connection.
22
+ * @param connection - Mongoose connection to bind the model to
23
+ * @param schema - Optional pre-built schema (uses buildCvcEntrySchema() if not provided)
24
+ * @returns Mongoose Model for CvcEntry
25
+ */
26
+ export function compileModel(
27
+ connection: Connection,
28
+ schema = buildCvcEntrySchema(),
29
+ ): Model<CvcEntry> {
30
+ return connection.models?.CvcEntry as Model<CvcEntry>
31
+ ?? connection.model<CvcEntry>("CvcEntry", schema);
32
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @htilabs/platform-common-models — CvcRegistry Model
3
+ *
4
+ * Factory for creating the CvcRegistry model bound to a specific connection.
5
+ * Mirrors the buildSchema/compileModel pattern used by the other platform
6
+ * models in this package (see `formModel.ts`, `questionModel.ts`).
7
+ */
8
+
9
+ import type { Connection, Model, HydratedDocument } from "mongoose";
10
+ import {
11
+ buildCvcRegistrySchema,
12
+ type CvcRegistry,
13
+ } from "../schemas/cvcRegistry.js";
14
+
15
+ export type CvcRegistryDoc = HydratedDocument<CvcRegistry>;
16
+
17
+ /**
18
+ * Build the CvcRegistry schema.
19
+ * @returns Mongoose Schema for CvcRegistry
20
+ */
21
+ export { buildCvcRegistrySchema as buildSchema };
22
+
23
+ /**
24
+ * Compile the CvcRegistry model on a specific connection.
25
+ * @param connection - Mongoose connection to bind the model to
26
+ * @param schema - Optional pre-built schema (uses buildCvcRegistrySchema() if not provided)
27
+ * @returns Mongoose Model for CvcRegistry
28
+ */
29
+ export function compileModel(
30
+ connection: Connection,
31
+ schema = buildCvcRegistrySchema(),
32
+ ): Model<CvcRegistry> {
33
+ return connection.models?.CvcRegistry as Model<CvcRegistry>
34
+ ?? connection.model<CvcRegistry>("CvcRegistry", schema);
35
+ }
@@ -23,6 +23,8 @@ import * as questionModel from "./questionModel.js";
23
23
  import * as scoringRuleModel from "./scoringRuleModel.js";
24
24
  import * as platformFunctionModel from "./platformFunctionModel.js";
25
25
  import * as platformRoleModel from "./platformRoleModel.js";
26
+ import * as cvcRegistryModel from "./cvcRegistryModel.js";
27
+ import * as cvcEntryModel from "./cvcEntryModel.js";
26
28
 
27
29
  // Re-export individual model factories
28
30
  export {
@@ -32,6 +34,8 @@ export {
32
34
  scoringRuleModel,
33
35
  platformFunctionModel,
34
36
  platformRoleModel,
37
+ cvcRegistryModel,
38
+ cvcEntryModel,
35
39
  };
36
40
 
37
41
  // Re-export types
@@ -41,6 +45,8 @@ export type { QuestionDoc } from "./questionModel.js";
41
45
  export type { ScoringRuleDoc } from "./scoringRuleModel.js";
42
46
  export type { PlatformFunctionDoc } from "./platformFunctionModel.js";
43
47
  export type { PlatformRoleDoc } from "./platformRoleModel.js";
48
+ export type { CvcRegistryDoc } from "./cvcRegistryModel.js";
49
+ export type { CvcEntryDoc } from "./cvcEntryModel.js";
44
50
 
45
51
  // Re-export schema types
46
52
  export type { Form } from "../schemas/form.js";
@@ -49,6 +55,8 @@ export type { Question } from "../schemas/question.js";
49
55
  export type { ScoringRule } from "../schemas/scoring-rule.js";
50
56
  export type { PlatformFunction } from "../schemas/platform-function.js";
51
57
  export type { PlatformRole } from "../schemas/platform-role.js";
58
+ export type { CvcRegistry } from "../schemas/cvcRegistry.js";
59
+ export type { CvcEntry } from "../schemas/cvcEntry.js";
52
60
 
53
61
  /**
54
62
  * Platform models interface returned by createPlatformModels.