@htilabs/platform-common-models 0.39.0 → 0.40.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.
- package/README.md +35 -0
- package/dist/age/index.cjs +136 -0
- package/dist/age/index.cjs.map +1 -0
- package/dist/age/index.d.cts +136 -0
- package/dist/age/index.d.ts +136 -0
- package/dist/age/index.js +105 -0
- package/dist/age/index.js.map +1 -0
- package/dist/{index-DF469Qgd.d.cts → index-1pWiqEBC.d.cts} +1 -1
- package/dist/{index-BHSRMJvd.d.ts → index-uz57Fic9.d.ts} +1 -1
- package/dist/index.cjs +108 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/package.json +7 -1
- package/src/age/__tests__/ageFromDob.test.ts +192 -0
- package/src/age/ageFromDob.ts +269 -0
- package/src/age/index.ts +8 -0
- package/src/index.ts +4 -0
- package/dist/{cvcEntry-DQEoFVL2.d.cts → cvcEntry-DAuhe0cd.d.cts} +8 -8
- package/dist/{cvcEntry-DQEoFVL2.d.ts → cvcEntry-DAuhe0cd.d.ts} +8 -8
package/dist/models/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-
|
|
1
|
+
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-DAuhe0cd.cjs';
|
|
2
2
|
import 'mongoose';
|
|
3
|
-
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-
|
|
3
|
+
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-1pWiqEBC.cjs';
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-
|
|
1
|
+
export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-DAuhe0cd.js';
|
|
2
2
|
import 'mongoose';
|
|
3
|
-
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-
|
|
3
|
+
export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-uz57Fic9.js';
|
package/dist/schemas/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as mongoose from 'mongoose';
|
|
2
2
|
import { InferRawDocType, Schema } from 'mongoose';
|
|
3
|
-
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-
|
|
3
|
+
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DAuhe0cd.cjs';
|
|
4
4
|
export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, a as AddAgencyOrgTypeFieldsOptions, b as AgencyOrgTypeFields, O as ORG_TYPE_FIELD_NAMES, c as OrgTypeFieldName, d as OrgTypeFields, e as OrgTypeFieldsHolder, V as VSP_TWO_STEP_ISSUE, f as addAgencyOrgTypeFields, g as addOrgTypeFields, h as agencyOrgTypeSchemaDefinition, i as applyRunValidatorsIfUnset, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, j as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, k as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, l as vspTwoStepHoldsOnUpdate } from '../agency-DYCv839V.cjs';
|
|
5
5
|
export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, b as ProgramReviewStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus } from '../vocabulary-Cxhi9EGt.cjs';
|
|
6
6
|
import '../org-type-D_FG4KdN.cjs';
|
|
@@ -136,12 +136,12 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
|
|
|
136
136
|
number?: string | null | undefined;
|
|
137
137
|
type?: string | null | undefined;
|
|
138
138
|
safeToContact?: boolean | null | undefined;
|
|
139
|
-
dataQuality?: "
|
|
139
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
140
140
|
}, mongoose.Document<unknown, {}, {
|
|
141
141
|
number?: string | null | undefined;
|
|
142
142
|
type?: string | null | undefined;
|
|
143
143
|
safeToContact?: boolean | null | undefined;
|
|
144
|
-
dataQuality?: "
|
|
144
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
145
145
|
}, {
|
|
146
146
|
id: string;
|
|
147
147
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
@@ -150,7 +150,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
|
|
|
150
150
|
number?: string | null | undefined;
|
|
151
151
|
type?: string | null | undefined;
|
|
152
152
|
safeToContact?: boolean | null | undefined;
|
|
153
|
-
dataQuality?: "
|
|
153
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
154
154
|
} & {
|
|
155
155
|
_id: mongoose.Types.ObjectId;
|
|
156
156
|
} & {
|
|
@@ -161,7 +161,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
|
|
|
161
161
|
number?: string | null | undefined;
|
|
162
162
|
type?: string | null | undefined;
|
|
163
163
|
safeToContact?: boolean | null | undefined;
|
|
164
|
-
dataQuality?: "
|
|
164
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
165
165
|
} & {
|
|
166
166
|
_id: mongoose.Types.ObjectId;
|
|
167
167
|
} & {
|
|
@@ -223,11 +223,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
223
223
|
raceOtherText?: string | null | undefined;
|
|
224
224
|
genderOtherText?: string | null | undefined;
|
|
225
225
|
accommodationOtherText?: string | null | undefined;
|
|
226
|
-
ageDataQuality?: "
|
|
227
|
-
sexDataQuality?: "
|
|
228
|
-
genderDataQuality?: "
|
|
229
|
-
raceDataQuality?: "
|
|
230
|
-
ethnicityDataQuality?: "
|
|
226
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
227
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
228
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
229
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
230
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
231
231
|
}, mongoose.Document<unknown, {}, {
|
|
232
232
|
race: number[];
|
|
233
233
|
ethnicity: number[];
|
|
@@ -247,11 +247,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
247
247
|
raceOtherText?: string | null | undefined;
|
|
248
248
|
genderOtherText?: string | null | undefined;
|
|
249
249
|
accommodationOtherText?: string | null | undefined;
|
|
250
|
-
ageDataQuality?: "
|
|
251
|
-
sexDataQuality?: "
|
|
252
|
-
genderDataQuality?: "
|
|
253
|
-
raceDataQuality?: "
|
|
254
|
-
ethnicityDataQuality?: "
|
|
250
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
251
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
252
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
253
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
254
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
255
255
|
}, {
|
|
256
256
|
id: string;
|
|
257
257
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
@@ -275,11 +275,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
275
275
|
raceOtherText?: string | null | undefined;
|
|
276
276
|
genderOtherText?: string | null | undefined;
|
|
277
277
|
accommodationOtherText?: string | null | undefined;
|
|
278
|
-
ageDataQuality?: "
|
|
279
|
-
sexDataQuality?: "
|
|
280
|
-
genderDataQuality?: "
|
|
281
|
-
raceDataQuality?: "
|
|
282
|
-
ethnicityDataQuality?: "
|
|
278
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
279
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
280
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
281
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
282
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
283
283
|
} & {
|
|
284
284
|
_id: mongoose.Types.ObjectId;
|
|
285
285
|
} & {
|
|
@@ -305,11 +305,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
305
305
|
raceOtherText?: string | null | undefined;
|
|
306
306
|
genderOtherText?: string | null | undefined;
|
|
307
307
|
accommodationOtherText?: string | null | undefined;
|
|
308
|
-
ageDataQuality?: "
|
|
309
|
-
sexDataQuality?: "
|
|
310
|
-
genderDataQuality?: "
|
|
311
|
-
raceDataQuality?: "
|
|
312
|
-
ethnicityDataQuality?: "
|
|
308
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
309
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
310
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
311
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
312
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
313
313
|
} & {
|
|
314
314
|
_id: mongoose.Types.ObjectId;
|
|
315
315
|
} & {
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as mongoose from 'mongoose';
|
|
2
2
|
import { InferRawDocType, Schema } from 'mongoose';
|
|
3
|
-
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-
|
|
3
|
+
export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DAuhe0cd.js';
|
|
4
4
|
export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, a as AddAgencyOrgTypeFieldsOptions, b as AgencyOrgTypeFields, O as ORG_TYPE_FIELD_NAMES, c as OrgTypeFieldName, d as OrgTypeFields, e as OrgTypeFieldsHolder, V as VSP_TWO_STEP_ISSUE, f as addAgencyOrgTypeFields, g as addOrgTypeFields, h as agencyOrgTypeSchemaDefinition, i as applyRunValidatorsIfUnset, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, j as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, k as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, l as vspTwoStepHoldsOnUpdate } from '../agency-Ca4pCOOf.js';
|
|
5
5
|
export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, b as ProgramReviewStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus } from '../vocabulary-Cxhi9EGt.js';
|
|
6
6
|
import '../org-type-BYQb9Qzq.js';
|
|
@@ -136,12 +136,12 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
|
|
|
136
136
|
number?: string | null | undefined;
|
|
137
137
|
type?: string | null | undefined;
|
|
138
138
|
safeToContact?: boolean | null | undefined;
|
|
139
|
-
dataQuality?: "
|
|
139
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
140
140
|
}, mongoose.Document<unknown, {}, {
|
|
141
141
|
number?: string | null | undefined;
|
|
142
142
|
type?: string | null | undefined;
|
|
143
143
|
safeToContact?: boolean | null | undefined;
|
|
144
|
-
dataQuality?: "
|
|
144
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
145
145
|
}, {
|
|
146
146
|
id: string;
|
|
147
147
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
@@ -150,7 +150,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
|
|
|
150
150
|
number?: string | null | undefined;
|
|
151
151
|
type?: string | null | undefined;
|
|
152
152
|
safeToContact?: boolean | null | undefined;
|
|
153
|
-
dataQuality?: "
|
|
153
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
154
154
|
} & {
|
|
155
155
|
_id: mongoose.Types.ObjectId;
|
|
156
156
|
} & {
|
|
@@ -161,7 +161,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
|
|
|
161
161
|
number?: string | null | undefined;
|
|
162
162
|
type?: string | null | undefined;
|
|
163
163
|
safeToContact?: boolean | null | undefined;
|
|
164
|
-
dataQuality?: "
|
|
164
|
+
dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
165
165
|
} & {
|
|
166
166
|
_id: mongoose.Types.ObjectId;
|
|
167
167
|
} & {
|
|
@@ -223,11 +223,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
223
223
|
raceOtherText?: string | null | undefined;
|
|
224
224
|
genderOtherText?: string | null | undefined;
|
|
225
225
|
accommodationOtherText?: string | null | undefined;
|
|
226
|
-
ageDataQuality?: "
|
|
227
|
-
sexDataQuality?: "
|
|
228
|
-
genderDataQuality?: "
|
|
229
|
-
raceDataQuality?: "
|
|
230
|
-
ethnicityDataQuality?: "
|
|
226
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
227
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
228
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
229
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
230
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
231
231
|
}, mongoose.Document<unknown, {}, {
|
|
232
232
|
race: number[];
|
|
233
233
|
ethnicity: number[];
|
|
@@ -247,11 +247,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
247
247
|
raceOtherText?: string | null | undefined;
|
|
248
248
|
genderOtherText?: string | null | undefined;
|
|
249
249
|
accommodationOtherText?: string | null | undefined;
|
|
250
|
-
ageDataQuality?: "
|
|
251
|
-
sexDataQuality?: "
|
|
252
|
-
genderDataQuality?: "
|
|
253
|
-
raceDataQuality?: "
|
|
254
|
-
ethnicityDataQuality?: "
|
|
250
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
251
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
252
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
253
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
254
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
255
255
|
}, {
|
|
256
256
|
id: string;
|
|
257
257
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
@@ -275,11 +275,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
275
275
|
raceOtherText?: string | null | undefined;
|
|
276
276
|
genderOtherText?: string | null | undefined;
|
|
277
277
|
accommodationOtherText?: string | null | undefined;
|
|
278
|
-
ageDataQuality?: "
|
|
279
|
-
sexDataQuality?: "
|
|
280
|
-
genderDataQuality?: "
|
|
281
|
-
raceDataQuality?: "
|
|
282
|
-
ethnicityDataQuality?: "
|
|
278
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
279
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
280
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
281
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
282
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
283
283
|
} & {
|
|
284
284
|
_id: mongoose.Types.ObjectId;
|
|
285
285
|
} & {
|
|
@@ -305,11 +305,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
|
|
|
305
305
|
raceOtherText?: string | null | undefined;
|
|
306
306
|
genderOtherText?: string | null | undefined;
|
|
307
307
|
accommodationOtherText?: string | null | undefined;
|
|
308
|
-
ageDataQuality?: "
|
|
309
|
-
sexDataQuality?: "
|
|
310
|
-
genderDataQuality?: "
|
|
311
|
-
raceDataQuality?: "
|
|
312
|
-
ethnicityDataQuality?: "
|
|
308
|
+
ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
309
|
+
sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
310
|
+
genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
311
|
+
raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
312
|
+
ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
|
|
313
313
|
} & {
|
|
314
314
|
_id: mongoose.Types.ObjectId;
|
|
315
315
|
} & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htilabs/platform-common-models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "Shared constants, types, and models for HTI Labs applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -96,6 +96,11 @@
|
|
|
96
96
|
"types": "./dist/share-review/index.d.ts",
|
|
97
97
|
"import": "./dist/share-review/index.js",
|
|
98
98
|
"require": "./dist/share-review/index.cjs"
|
|
99
|
+
},
|
|
100
|
+
"./age": {
|
|
101
|
+
"types": "./dist/age/index.d.ts",
|
|
102
|
+
"import": "./dist/age/index.js",
|
|
103
|
+
"require": "./dist/age/index.cjs"
|
|
99
104
|
}
|
|
100
105
|
},
|
|
101
106
|
"files": [
|
|
@@ -110,6 +115,7 @@
|
|
|
110
115
|
"lint:fix": "eslint src --ext .ts --fix",
|
|
111
116
|
"test": "vitest run",
|
|
112
117
|
"test:watch": "vitest",
|
|
118
|
+
"test:age:tz": "TZ=America/Los_Angeles vitest run src/age",
|
|
113
119
|
"test:snapshot": "UPDATE_SNAPSHOT=1 vitest run",
|
|
114
120
|
"clean": "rm -rf dist",
|
|
115
121
|
"codegen:cvc": "tsx scripts/codegen-cvc-enums.ts",
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ageFromDob,
|
|
5
|
+
ageInputFromStoredDob,
|
|
6
|
+
calendarDateOf,
|
|
7
|
+
normalizeDob,
|
|
8
|
+
} from "../ageFromDob.js";
|
|
9
|
+
|
|
10
|
+
/** Local calendar day — the rule reads `today`'s local year / month / day. */
|
|
11
|
+
const day = (y: number, m: number, d: number): Date => new Date(y, m - 1, d, 12);
|
|
12
|
+
|
|
13
|
+
const TODAY = day(2026, 10, 24);
|
|
14
|
+
|
|
15
|
+
describe("ageFromDob — the card's case", () => {
|
|
16
|
+
it("birth year 2008 with no month is 17 on 2026-10-24 (counted younger), not 18", () => {
|
|
17
|
+
expect(ageFromDob({ y: 2008 }, TODAY)).toBe(17);
|
|
18
|
+
expect(ageFromDob({ y: "2008", m: "", d: "" }, TODAY)).toBe(17);
|
|
19
|
+
expect(ageFromDob("//2008", TODAY)).toBe(17);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("ageFromDob — the partial-date rule", () => {
|
|
24
|
+
it("month unknown: always counts younger, even late in the year", () => {
|
|
25
|
+
expect(ageFromDob({ y: 2000 }, day(2026, 12, 31))).toBe(25);
|
|
26
|
+
expect(ageFromDob({ y: 2000, d: 1 }, day(2026, 12, 31))).toBe(25);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("birth month already past: birthday has happened", () => {
|
|
30
|
+
expect(ageFromDob({ y: 2008, m: 9 }, TODAY)).toBe(18);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("birth month still ahead: birthday has not happened", () => {
|
|
34
|
+
expect(ageFromDob({ y: 2008, m: 11 }, TODAY)).toBe(17);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("birth month is this month and the day is unknown: counts younger", () => {
|
|
38
|
+
expect(ageFromDob({ y: 2008, m: 10 }, TODAY)).toBe(17);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("birth month is this month and the day is known", () => {
|
|
42
|
+
expect(ageFromDob({ y: 2008, m: 10, d: 23 }, TODAY)).toBe(18);
|
|
43
|
+
expect(ageFromDob({ y: 2008, m: 10, d: 24 }, TODAY)).toBe(18);
|
|
44
|
+
expect(ageFromDob({ y: 2008, m: 10, d: 25 }, TODAY)).toBe(17);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("a full date of birth gives exact whole years", () => {
|
|
48
|
+
expect(ageFromDob({ y: 1987, m: 5, d: 21 }, TODAY)).toBe(39);
|
|
49
|
+
expect(ageFromDob({ y: 2014, m: 1, d: 1 }, day(2026, 12, 31))).toBe(12);
|
|
50
|
+
expect(ageFromDob({ y: 2014, m: 1, d: 1 }, day(2027, 1, 1))).toBe(13);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("born on 29 February", () => {
|
|
54
|
+
expect(ageFromDob({ y: 2008, m: 2, d: 29 }, day(2026, 2, 28))).toBe(17);
|
|
55
|
+
expect(ageFromDob({ y: 2008, m: 2, d: 29 }, day(2026, 3, 1))).toBe(18);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("ageFromDob — no age", () => {
|
|
60
|
+
it("no year, or nothing at all", () => {
|
|
61
|
+
expect(ageFromDob({ m: 5, d: 21 }, TODAY)).toBeNull();
|
|
62
|
+
expect(ageFromDob(null, TODAY)).toBeNull();
|
|
63
|
+
expect(ageFromDob(undefined, TODAY)).toBeNull();
|
|
64
|
+
expect(ageFromDob("", TODAY)).toBeNull();
|
|
65
|
+
expect(ageFromDob({}, TODAY)).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("a year out of range, or a birth after today", () => {
|
|
69
|
+
expect(ageFromDob({ y: 1849 }, TODAY)).toBeNull();
|
|
70
|
+
expect(ageFromDob({ y: 2028 }, TODAY)).toBeNull();
|
|
71
|
+
expect(ageFromDob({ y: 2026, m: 11, d: 1 }, TODAY)).toBeNull();
|
|
72
|
+
expect(ageFromDob({ y: 2027 }, TODAY)).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("born earlier today's year: 0", () => {
|
|
76
|
+
expect(ageFromDob({ y: 2026, m: 1, d: 5 }, TODAY)).toBe(0);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("an invalid today object", () => {
|
|
80
|
+
expect(ageFromDob("2008-03-01", { y: 2026, m: 13, d: 1 })).toBeNull();
|
|
81
|
+
expect(ageFromDob("2008-03-01", { y: 2026, m: 10, d: 0 })).toBeNull();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("an unreadable string or an invalid today", () => {
|
|
85
|
+
expect(ageFromDob("March 1990", TODAY)).toBeNull();
|
|
86
|
+
expect(ageFromDob("2008-03-01", new Date(Number.NaN))).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("normalizeDob", () => {
|
|
91
|
+
it("reads ISO by parts — no time-zone shift", () => {
|
|
92
|
+
expect(normalizeDob("2008-03-01")).toEqual({ y: 2008, m: 3, d: 1 });
|
|
93
|
+
expect(normalizeDob("2008-03-01T00:00:00.000Z")).toEqual({ y: 2008, m: 3, d: 1 });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("reads MM/DD/YYYY with any part blank, padded or not", () => {
|
|
97
|
+
expect(normalizeDob("03/1/2006")).toEqual({ m: 3, d: 1, y: 2006 });
|
|
98
|
+
expect(normalizeDob("/05/1990")).toEqual({ m: null, d: 5, y: 1990 });
|
|
99
|
+
expect(normalizeDob("//")).toBeNull();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("drops parts that are not a real month, day or year", () => {
|
|
103
|
+
expect(normalizeDob({ y: 2008, m: 13, d: 0 })).toEqual({ y: 2008, m: null, d: null });
|
|
104
|
+
expect(normalizeDob({ y: "", m: " ", d: null })).toBeNull();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe("ageFromDob — born this year (a known-born person always has an age)", () => {
|
|
109
|
+
it("birth year is this year, month unknown: 0, not null", () => {
|
|
110
|
+
expect(ageFromDob({ y: 2026 }, TODAY)).toBe(0);
|
|
111
|
+
expect(ageFromDob("2026", TODAY)).toBe(0);
|
|
112
|
+
expect(ageFromDob("//2026", TODAY)).toBe(0);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("birth month is this month, day unknown: 0, not null", () => {
|
|
116
|
+
expect(ageFromDob({ y: 2026, m: 10 }, TODAY)).toBe(0);
|
|
117
|
+
expect(ageFromDob("2026-10", TODAY)).toBe(0);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("born today: 0", () => {
|
|
121
|
+
expect(ageFromDob({ y: 2026, m: 10, d: 24 }, TODAY)).toBe(0);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("only a date of birth after today has no age", () => {
|
|
125
|
+
expect(ageFromDob({ y: 2026, m: 10, d: 25 }, TODAY)).toBeNull(); // tomorrow
|
|
126
|
+
expect(ageFromDob("2026-10-25", TODAY)).toBeNull();
|
|
127
|
+
expect(ageFromDob({ y: 2026, m: 11 }, TODAY)).toBeNull(); // a later month
|
|
128
|
+
expect(ageFromDob({ y: 2027 }, TODAY)).toBeNull(); // a later year
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("ageFromDob — a JS Date or a partial ISO string as the date of birth", () => {
|
|
133
|
+
it("a Date is a full date (local-constructed or stored as UTC midnight)", () => {
|
|
134
|
+
expect(ageFromDob(new Date(2008, 2, 1), TODAY)).toBe(18);
|
|
135
|
+
expect(ageFromDob(new Date(2008, 9, 25), TODAY)).toBe(17);
|
|
136
|
+
expect(ageFromDob(new Date("2008-10-24T00:00:00.000Z"), TODAY)).toBe(18);
|
|
137
|
+
expect(normalizeDob(new Date("2008-03-01T00:00:00.000Z"))).toEqual({ y: 2008, m: 3, d: 1 });
|
|
138
|
+
expect(normalizeDob(new Date(2008, 2, 1))).toEqual({ y: 2008, m: 3, d: 1 });
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("an invalid Date has no age", () => {
|
|
142
|
+
expect(ageFromDob(new Date(Number.NaN), TODAY)).toBeNull();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('"YYYY" is year only; "YYYY-MM" is day unknown; "YYYY-MM-DD" is full', () => {
|
|
146
|
+
expect(normalizeDob("2008")).toEqual({ y: 2008, m: null, d: null });
|
|
147
|
+
expect(normalizeDob("2008-05")).toEqual({ y: 2008, m: 5, d: null });
|
|
148
|
+
expect(normalizeDob("2008-13")).toEqual({ y: 2008, m: null, d: null });
|
|
149
|
+
expect(ageFromDob("2008", TODAY)).toBe(17);
|
|
150
|
+
expect(ageFromDob("2008-10", TODAY)).toBe(17);
|
|
151
|
+
expect(ageFromDob("2008-09", TODAY)).toBe(18);
|
|
152
|
+
expect(ageFromDob("2008-10-24", TODAY)).toBe(18);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("an untyped record (any) carrying a Date keeps its age", () => {
|
|
156
|
+
const record: any = { dob: new Date(2008, 2, 1) };
|
|
157
|
+
expect(ageFromDob(record.dob, TODAY)).toBe(18);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe("ageFromDob — today is a calendar date the caller chooses", () => {
|
|
162
|
+
it("{ y, m, d } and a local Date for the same day agree", () => {
|
|
163
|
+
const dob = { y: 2008, m: 10, d: 24 };
|
|
164
|
+
expect(ageFromDob(dob, { y: 2026, m: 10, d: 24 })).toBe(18);
|
|
165
|
+
expect(ageFromDob(dob, { y: 2026, m: 10, d: 23 })).toBe(17);
|
|
166
|
+
expect(ageFromDob(dob, new Date(2026, 9, 24))).toBe(18);
|
|
167
|
+
expect(ageFromDob(dob, new Date(2026, 9, 24, 23, 59))).toBe(18);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("the answer does not depend on the process time zone", () => {
|
|
171
|
+
// The auditor's instant: 2026-10-24T03:00Z. With { y, m, d } the caller
|
|
172
|
+
// decides the day, so TZ=UTC and TZ=America/Los_Angeles cannot split.
|
|
173
|
+
expect(ageFromDob("2008-10-24", { y: 2026, m: 10, d: 24 })).toBe(18);
|
|
174
|
+
expect(ageFromDob("2008-10-24", { y: 2026, m: 10, d: 23 })).toBe(17);
|
|
175
|
+
// A calendar date stored as UTC midnight reads as that day in every zone.
|
|
176
|
+
expect(calendarDateOf(new Date("2026-10-24T00:00:00.000Z"))).toEqual({ y: 2026, m: 10, d: 24 });
|
|
177
|
+
expect(ageFromDob("2008-10-24", new Date("2026-10-24T00:00:00.000Z"))).toBe(18);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe("ageInputFromStoredDob", () => {
|
|
182
|
+
it("maps the stored dobYear / dobMonth / dobDay strings to the ageFromDob input", () => {
|
|
183
|
+
expect(ageInputFromStoredDob({ dobYear: "2008", dobMonth: "10", dobDay: "" })).toEqual({
|
|
184
|
+
y: "2008",
|
|
185
|
+
m: "10",
|
|
186
|
+
d: "",
|
|
187
|
+
});
|
|
188
|
+
expect(ageFromDob(ageInputFromStoredDob({ dobYear: "2008" }), TODAY)).toBe(17);
|
|
189
|
+
expect(ageFromDob(ageInputFromStoredDob({ dobYear: "2008", dobMonth: "10", dobDay: "24" }), TODAY)).toBe(18);
|
|
190
|
+
expect(ageFromDob(ageInputFromStoredDob(null), TODAY)).toBeNull();
|
|
191
|
+
});
|
|
192
|
+
});
|