@htilabs/platform-common-models 0.29.0 → 0.30.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 +268 -1
- package/dist/{index-Dr6GBCoY.d.ts → index-ClTjjJ_S.d.ts} +1 -1
- package/dist/{index-BTqHP4DM.d.cts → index-Pt82NxQg.d.cts} +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/points-of-contact/index.cjs +826 -21
- package/dist/points-of-contact/index.cjs.map +1 -1
- package/dist/points-of-contact/index.d.cts +936 -87
- package/dist/points-of-contact/index.d.ts +936 -87
- package/dist/points-of-contact/index.js +799 -21
- package/dist/points-of-contact/index.js.map +1 -1
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/package.json +1 -1
- package/src/pointsOfContact/__tests__/mongoDouble.ts +194 -0
- package/src/pointsOfContact/__tests__/pointsOfContact.test.ts +379 -26
- package/src/pointsOfContact/__tests__/writer.mongo.test.ts +190 -0
- package/src/pointsOfContact/__tests__/writer.test.ts +782 -0
- package/src/pointsOfContact/index.ts +12 -7
- package/src/pointsOfContact/readRules.ts +73 -12
- package/src/pointsOfContact/reader.ts +75 -9
- package/src/pointsOfContact/schemas.ts +304 -34
- package/src/pointsOfContact/vocabulary.ts +40 -5
- package/src/pointsOfContact/writer.ts +967 -0
- package/dist/{cvcEntry-BqAGctqK.d.cts → cvcEntry-Asg7mxjB.d.cts} +8 -8
- package/dist/{cvcEntry-BqAGctqK.d.ts → cvcEntry-Asg7mxjB.d.ts} +8 -8
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-Asg7mxjB.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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
145
145
|
}, {
|
|
146
146
|
id: string;
|
|
147
147
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
@@ -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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
227
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
228
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
229
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
230
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
251
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
252
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
253
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
254
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
255
255
|
}, {
|
|
256
256
|
id: string;
|
|
257
257
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
@@ -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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
279
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
280
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
281
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
282
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
309
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
310
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
311
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
312
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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-Asg7mxjB.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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
145
145
|
}, {
|
|
146
146
|
id: string;
|
|
147
147
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
@@ -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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
227
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
228
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
229
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
230
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
251
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
252
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
253
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
254
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
255
255
|
}, {
|
|
256
256
|
id: string;
|
|
257
257
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
@@ -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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
279
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
280
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
281
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
282
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | 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?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
309
|
+
sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
310
|
+
genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
311
|
+
raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
312
|
+
ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
|
|
313
313
|
} & {
|
|
314
314
|
_id: mongoose.Types.ObjectId;
|
|
315
315
|
} & {
|
package/package.json
CHANGED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An in-memory MongoDB double for the points-of-contact writer tests. It
|
|
3
|
+
* ENFORCES the unique indexes the store declares, partial filters included
|
|
4
|
+
* (a dotted path through an array is treated as multikey, as Mongo does; the
|
|
5
|
+
* in-app pending index is a scalar `identity_key` key), the way the platform's
|
|
6
|
+
* own store test does (platform `test/lib/points-of-contact/repository.test.ts`),
|
|
7
|
+
* and throws the driver's E11000 shape (`code: 11000`, `keyPattern`, the index
|
|
8
|
+
* name in the message). `indexes()` on a collection that was never created
|
|
9
|
+
* throws NamespaceNotFound (26), as `listIndexes` does; reads never create
|
|
10
|
+
* one. Each operation is atomic and the interleaving is the event loop's, so
|
|
11
|
+
* a parallel test here shows a rule holds for THESE interleavings only, not
|
|
12
|
+
* that it is race-safe on a server (the real-MongoDB suite is that check).
|
|
13
|
+
* Not a test file itself (no `.test.ts`).
|
|
14
|
+
*/
|
|
15
|
+
import mongoose from "mongoose";
|
|
16
|
+
|
|
17
|
+
const { ObjectId } = mongoose.mongo;
|
|
18
|
+
|
|
19
|
+
export type Doc = Record<string, unknown>;
|
|
20
|
+
export interface Index {
|
|
21
|
+
key: Record<string, number>;
|
|
22
|
+
name?: string;
|
|
23
|
+
unique?: boolean;
|
|
24
|
+
partialFilterExpression?: Doc;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function same(a: unknown, b: unknown): boolean {
|
|
28
|
+
if (a instanceof ObjectId || b instanceof ObjectId) return String(a) === String(b);
|
|
29
|
+
if ((a === null || a === undefined) && (b === null || b === undefined)) return true;
|
|
30
|
+
return a === b;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function fieldMatches(v: unknown, cond: unknown): boolean {
|
|
34
|
+
if (cond && typeof cond === "object" && !(cond instanceof ObjectId) && !Array.isArray(cond)) {
|
|
35
|
+
const c = cond as Doc;
|
|
36
|
+
if ("$in" in c) {
|
|
37
|
+
return (c.$in as unknown[]).some((x) =>
|
|
38
|
+
Array.isArray(v) ? v.some((y) => same(x, y)) : same(x, v),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if ("$ne" in c) return !same(v, c.$ne);
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(v)) return v.some((x) => same(x, cond));
|
|
44
|
+
return same(v, cond);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A field, or a dotted path through an array of sub-documents (every value it reaches). */
|
|
48
|
+
function valueAt(d: Doc, k: string): unknown {
|
|
49
|
+
if (!k.includes(".")) return d[k];
|
|
50
|
+
const [head, ...rest] = k.split(".");
|
|
51
|
+
const v = d[head];
|
|
52
|
+
if (Array.isArray(v)) {
|
|
53
|
+
return v.flatMap((x) => (x && typeof x === "object" ? [valueAt(x as Doc, rest.join("."))] : []));
|
|
54
|
+
}
|
|
55
|
+
return v && typeof v === "object" ? valueAt(v as Doc, rest.join(".")) : undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function matches(d: Doc, f: Doc): boolean {
|
|
59
|
+
return Object.entries(f).every(([k, c]) =>
|
|
60
|
+
k === "$or" ? (c as Doc[]).some((alt) => matches(d, alt)) : fieldMatches(valueAt(d, k), c),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function mongoDouble() {
|
|
65
|
+
const store = new Map<string, Doc[]>();
|
|
66
|
+
const indexes = new Map<string, Index[]>();
|
|
67
|
+
const writes: { op: string; collection: string }[] = [];
|
|
68
|
+
let failNextInsert: { error: unknown } | null = null;
|
|
69
|
+
|
|
70
|
+
function uniqueViolation(name: string, docs: Doc[], candidate: Doc): Index | null {
|
|
71
|
+
for (const ix of indexes.get(name) ?? []) {
|
|
72
|
+
if (!ix.unique) continue;
|
|
73
|
+
if (ix.partialFilterExpression && !matches(candidate, ix.partialFilterExpression)) continue;
|
|
74
|
+
// Each key field's indexed values: a dotted path through an array is multikey, so two
|
|
75
|
+
// rows clash when every field shares at least one value (Mongo's rule).
|
|
76
|
+
const valuesOf = (d: Doc, k: string): string[] => {
|
|
77
|
+
const v = valueAt(d, k);
|
|
78
|
+
const list = Array.isArray(v) ? v : [v];
|
|
79
|
+
return (list.length ? list : [null]).map((x) => JSON.stringify(x ?? null));
|
|
80
|
+
};
|
|
81
|
+
const clashes = (d: Doc) =>
|
|
82
|
+
Object.keys(ix.key).every((k) =>
|
|
83
|
+
valuesOf(d, k).some((x) => valuesOf(candidate, k).includes(x)),
|
|
84
|
+
);
|
|
85
|
+
const clash = docs.some(
|
|
86
|
+
(d) =>
|
|
87
|
+
(!ix.partialFilterExpression || matches(d, ix.partialFilterExpression)) && clashes(d),
|
|
88
|
+
);
|
|
89
|
+
if (clash) return ix;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function collection(name: string) {
|
|
95
|
+
const docs = () => store.get(name) ?? [];
|
|
96
|
+
const created = () => store.get(name) ?? (store.set(name, []), store.get(name)!);
|
|
97
|
+
return {
|
|
98
|
+
find(f: Doc = {}) {
|
|
99
|
+
let order: Record<string, number> | null = null;
|
|
100
|
+
let cap = 0;
|
|
101
|
+
const cursor = {
|
|
102
|
+
sort: (o: Record<string, number>) => ((order = o), cursor),
|
|
103
|
+
limit: (n: number) => ((cap = n), cursor),
|
|
104
|
+
toArray: async () => {
|
|
105
|
+
await Promise.resolve();
|
|
106
|
+
let out = docs().filter((d) => matches(d, f));
|
|
107
|
+
if (order) {
|
|
108
|
+
const keys = Object.entries(order);
|
|
109
|
+
out = [...out].sort((a, b) => {
|
|
110
|
+
for (const [k, dir] of keys) {
|
|
111
|
+
const x = String(a[k] ?? "");
|
|
112
|
+
const y = String(b[k] ?? "");
|
|
113
|
+
if (x !== y) return (x < y ? -1 : 1) * dir;
|
|
114
|
+
}
|
|
115
|
+
return 0;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return (cap ? out.slice(0, cap) : out).map((d) => ({ ...d }));
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
return cursor;
|
|
122
|
+
},
|
|
123
|
+
async findOne(f: Doc) {
|
|
124
|
+
await Promise.resolve();
|
|
125
|
+
const d = docs().find((x) => matches(x, f));
|
|
126
|
+
return d ? { ...d } : null;
|
|
127
|
+
},
|
|
128
|
+
async countDocuments(f: Doc) {
|
|
129
|
+
await Promise.resolve();
|
|
130
|
+
return docs().filter((d) => matches(d, f)).length;
|
|
131
|
+
},
|
|
132
|
+
async insertOne(d: Doc) {
|
|
133
|
+
writes.push({ op: "insertOne", collection: name });
|
|
134
|
+
if (failNextInsert) {
|
|
135
|
+
const { error } = failNextInsert;
|
|
136
|
+
failNextInsert = null;
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
const ix = uniqueViolation(name, docs(), d);
|
|
140
|
+
if (ix) {
|
|
141
|
+
throw Object.assign(
|
|
142
|
+
new Error(`E11000 duplicate key error collection: platform.${name} index: ${ix.name} dup key`),
|
|
143
|
+
{ code: 11000, keyPattern: ix.key },
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
created().push({ ...d });
|
|
147
|
+
return { acknowledged: true as const };
|
|
148
|
+
},
|
|
149
|
+
async deleteOne(f: Doc) {
|
|
150
|
+
writes.push({ op: "deleteOne", collection: name });
|
|
151
|
+
const i = docs().findIndex((x) => matches(x, f));
|
|
152
|
+
if (i >= 0) docs().splice(i, 1);
|
|
153
|
+
return { deletedCount: i >= 0 ? 1 : 0 };
|
|
154
|
+
},
|
|
155
|
+
async createIndex(key: Record<string, number>, opts: Omit<Index, "key"> = {}) {
|
|
156
|
+
const list = indexes.get(name) ?? (indexes.set(name, []), indexes.get(name)!);
|
|
157
|
+
const same = list.find((x) => x.name === opts.name);
|
|
158
|
+
if (same && JSON.stringify(same.key) !== JSON.stringify(key)) {
|
|
159
|
+
throw Object.assign(new Error(`An existing index has the same name as the requested index`), {
|
|
160
|
+
code: 86,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (!same) list.push({ key, ...opts });
|
|
164
|
+
return opts.name ?? "ix";
|
|
165
|
+
},
|
|
166
|
+
async indexes() {
|
|
167
|
+
if (!store.has(name) && !indexes.has(name)) {
|
|
168
|
+
throw Object.assign(new Error(`ns does not exist: platform.${name}`), { code: 26 });
|
|
169
|
+
}
|
|
170
|
+
return indexes.get(name) ?? [];
|
|
171
|
+
},
|
|
172
|
+
async dropIndex(ixName: string) {
|
|
173
|
+
const list = indexes.get(name) ?? [];
|
|
174
|
+
const i = list.findIndex((x) => x.name === ixName);
|
|
175
|
+
if (i < 0) throw Object.assign(new Error(`index not found with name [${ixName}]`), { code: 27 });
|
|
176
|
+
list.splice(i, 1);
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
store,
|
|
183
|
+
indexes,
|
|
184
|
+
writes,
|
|
185
|
+
/** Throw `error` from the next `insertOne` instead of inserting. */
|
|
186
|
+
failNextInsert(error: unknown) {
|
|
187
|
+
failNextInsert = { error };
|
|
188
|
+
},
|
|
189
|
+
/** A handle over the store; each call is a new object (the writer memoizes indexes per handle). */
|
|
190
|
+
handle: () => ({ collection }),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type MongoDouble = ReturnType<typeof mongoDouble>;
|