@htilabs/platform-common-models 0.9.0 → 0.12.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/dist/config/index.cjs +85 -0
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +94 -4
- package/dist/config/index.d.ts +94 -4
- package/dist/config/index.js +81 -1
- package/dist/config/index.js.map +1 -1
- package/dist/constants/index.cjs +456 -181
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +453 -169
- package/dist/constants/index.js.map +1 -1
- package/dist/cvcs/index.cjs +15331 -801
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +18167 -2208
- package/dist/cvcs/index.d.ts +18167 -2208
- package/dist/cvcs/index.js +15282 -801
- package/dist/cvcs/index.js.map +1 -1
- package/dist/{index-Zu_mOJRn.d.cts → index-CoVr1jIV.d.cts} +1 -1
- package/dist/{index-CDoqrfc1.d.ts → index-I-DiX9eQ.d.ts} +1 -1
- package/dist/index.cjs +17070 -1056
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1638 -12
- package/dist/index.d.ts +1638 -12
- package/dist/index.js +16969 -1043
- 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/mongo/index.cjs +384 -0
- package/dist/mongo/index.cjs.map +1 -0
- package/dist/mongo/index.d.cts +221 -0
- package/dist/mongo/index.d.ts +221 -0
- package/dist/mongo/index.js +352 -0
- package/dist/mongo/index.js.map +1 -0
- package/dist/{platform-auth-XVB9aHqR.d.cts → platform-auth-v53r3BhN.d.cts} +19 -75
- package/dist/{platform-auth-XVB9aHqR.d.ts → platform-auth-v53r3BhN.d.ts} +19 -75
- package/dist/schemas/index.cjs +25 -156
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/dist/schemas/index.js +25 -156
- package/dist/schemas/index.js.map +1 -1
- package/dist/services/index.cjs +0 -3
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.js +0 -3
- package/dist/services/index.js.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +9 -1
- package/src/__sot__/README.md +56 -0
- package/src/__sot__/coreIndicators.pin.json +215 -0
- package/src/__sot__/cvcIndex.pin.json +268 -0
- package/src/__sot__/scoringEmits.pin.json +176 -0
- package/src/__tests__/__snapshots__/cvc-sot.snap +227 -35
- package/src/__tests__/cvc-136-scoring-invariant.test.ts +323 -0
- package/src/__tests__/cvc-drift-gate.test.ts +603 -0
- package/src/__tests__/cvc-sot-snapshot.test.ts +122 -11
- package/src/__tests__/cvc-structural.test.ts +56 -1
- package/src/__tests__/mongo-verifier.test.ts +502 -0
- package/src/__tests__/runtime-contract-validator.test.ts +325 -1
- package/src/config/index.ts +197 -6
- package/src/constants/ic.ts +512 -206
- package/src/constants/service-catalog.ts +4 -2
- package/src/cvcs/activityType.v1.0.0.json +143 -0
- package/src/cvcs/adminRoles.v1.0.0.json +153 -0
- package/src/cvcs/administeringJurisdiction.v1.0.0.json +40 -40
- package/src/cvcs/ageBinReporting.v1.0.0.json +40 -40
- package/src/cvcs/assertionDomain.v1.1.0.json +629 -0
- package/src/cvcs/{checkInPhase.v1.0.0.json → checkInPhase.v1.1.0.json} +20 -2
- package/src/cvcs/childChangeType.v1.0.0.json +152 -0
- package/src/cvcs/citizenship.v1.0.0.json +3062 -0
- package/src/cvcs/contactInfoTypes.v1.0.0.json +40 -40
- package/src/cvcs/contactLinkType.v1.0.0.json +89 -0
- package/src/cvcs/coreDhState.v1.0.0.json +113 -0
- package/src/cvcs/coreFunctions.v1.0.0.json +746 -0
- package/src/cvcs/coreIndicators.v1.0.0.json +2840 -0
- package/src/cvcs/coreReferralOutcome.v1.0.0.json +71 -0
- package/src/cvcs/employmentStatus.v1.0.0.json +60 -60
- package/src/cvcs/exploitationType.v1.0.0.json +106 -0
- package/src/cvcs/facilitatorEntityType.v1.0.0.json +40 -40
- package/src/cvcs/highestEducationLevelCompleted.v1.0.0.json +55 -46
- package/src/cvcs/hivStatus.v1.0.0.json +71 -0
- package/src/cvcs/hmisCurrentLivingSituation.v1.0.0.json +409 -0
- package/src/cvcs/hmisRelationshipToHoh.v1.0.0.json +104 -0
- package/src/cvcs/homelessStatus.v1.0.0.json +27 -27
- package/src/cvcs/housingSubsidyTypes.v1.0.0.json +161 -0
- package/src/cvcs/htType.v1.0.0.json +87 -0
- package/src/cvcs/identificationStatus.v1.0.0.json +18 -0
- package/src/cvcs/immigrationLegalStatusChangeType.v1.0.0.json +143 -0
- package/src/cvcs/incarcerationEpisodeType.v1.0.0.json +106 -0
- package/src/cvcs/incidentInvolvementRoles.v1.0.0.json +40 -40
- package/src/cvcs/incidentParticipationRoles.v1.0.0.json +40 -40
- package/src/cvcs/incomeBenefitsSources.v1.0.0.json +31 -2
- package/src/cvcs/index.ts +106 -1
- package/src/cvcs/juvenileJusticeEpisodeType.v1.0.0.json +28 -18
- package/src/cvcs/juvenileJusticeInvolvementStatus.v1.0.0.json +32 -32
- package/src/cvcs/livingSituation.v1.0.0.json +213 -0
- package/src/cvcs/mentalHealthStatus.v1.0.0.json +71 -0
- package/src/cvcs/militaryBranch.v1.0.0.json +20 -20
- package/src/cvcs/militaryStatus.v1.0.0.json +20 -20
- package/src/cvcs/nameType.v1.0.0.json +40 -40
- package/src/cvcs/needsAssessmentChangeType.v1.0.0.json +134 -0
- package/src/cvcs/offenderStatus.v1.0.0.json +40 -40
- package/src/cvcs/offenderStatusFamily.v1.0.0.json +36 -36
- package/src/cvcs/poPetitionBasis.v1.0.0.json +96 -0
- package/src/cvcs/poStatus.v1.0.0.json +144 -0
- package/src/cvcs/poViolationStatus.v1.0.0.json +76 -0
- package/src/cvcs/programEnrollmentChangeType.v1.0.0.json +134 -0
- package/src/cvcs/provenanceSourceId.v1.0.0.json +134 -0
- package/src/cvcs/radiusBucket.v1.0.0.json +110 -0
- package/src/cvcs/recencyBand.v1.0.0.json +104 -39
- package/src/cvcs/referralEntityCategory.v1.0.0.json +40 -40
- package/src/cvcs/relationshipConcern.v1.0.0.json +114 -0
- package/src/cvcs/riskCategory.v1.0.0.json +134 -0
- package/src/cvcs/riskSeverityBand.v1.0.0.json +139 -0
- package/src/cvcs/roiMethod.v1.0.0.json +107 -0
- package/src/cvcs/roiScope.v1.0.0.json +296 -0
- package/src/cvcs/roiStatus.v1.0.0.json +106 -0
- package/src/cvcs/romanticRelationshipChangeType.v1.0.0.json +162 -0
- package/src/cvcs/serviceAudience.v1.0.0.json +96 -0
- package/src/cvcs/serviceCategories.v1.0.0.json +44 -44
- package/src/cvcs/serviceDeliveryChannel.v1.0.0.json +147 -0
- package/src/cvcs/serviceMechanisms.v1.0.0.json +36 -36
- package/src/cvcs/serviceStates.v1.0.0.json +55 -33
- package/src/cvcs/sessionNoteVisibility.v1.0.0.json +80 -0
- package/src/cvcs/sessionTemplate.v1.0.0.json +261 -0
- package/src/cvcs/sexProviderSubrole.v1.0.0.json +35 -28
- package/src/cvcs/smtType.v1.0.0.json +40 -40
- package/src/cvcs/sourceCategory.v1.1.0.json +8 -1
- package/src/cvcs/sourceInstrument.v1.0.0.json +458 -0
- package/src/cvcs/sourceSubtype.v1.1.0.json +36 -0
- package/src/cvcs/sourceSystem.v1.0.0.json +203 -0
- package/src/cvcs/specialNeedsDisabilities.v1.0.0.json +143 -0
- package/src/cvcs/suggestionSource.v1.0.0.json +71 -0
- package/src/cvcs/traffickingRelevantRole.v1.0.0.json +104 -0
- package/src/cvcs/userRoles.v1.0.0.json +203 -0
- package/src/cvcs/verificationMethod.v1.0.0.json +18 -0
- package/src/cvcs/victimAbuseTypes.v1.0.0.json +276 -0
- package/src/cvcs/victimStatusFamily.v1.0.0.json +40 -40
- package/src/cvcs/whyNots.v1.0.0.json +385 -0
- package/src/generated/cvc-enums.ts +1729 -7
- package/src/mongo/catalog.ts +65 -0
- package/src/mongo/contract.ts +157 -0
- package/src/mongo/index.ts +343 -0
- package/src/mongo/similarity.ts +133 -0
- package/src/mongo/uri.ts +53 -0
- package/src/services/cvcRegistryService.ts +1 -1
- package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-BCj1OWqL.d.cts} +8 -8
- package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-BCj1OWqL.d.ts} +8 -8
package/src/mongo/uri.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @htilabs/platform-common-models — MongoDB URI parsing
|
|
3
|
+
*
|
|
4
|
+
* Home of the connection-string parsing shared by the seed guard
|
|
5
|
+
* (`scripts/lib/confirmTargetDb.ts`) and the runtime verifier
|
|
6
|
+
* (`src/mongo/index.ts`). It lives in `src/` so both can import one
|
|
7
|
+
* implementation; `scripts/` cannot be imported from `src/` at build time.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Suffix that marks a database as a non-production scratch/test database. */
|
|
11
|
+
export const TEST_DB_SUFFIX = "-test";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Parse the target database name out of a MongoDB connection URI.
|
|
15
|
+
*
|
|
16
|
+
* The database name is the path segment after the host(s), before any query
|
|
17
|
+
* string (`?...`). Handles both `mongodb://` and `mongodb+srv://` URIs and any
|
|
18
|
+
* userinfo / multi-host / option components. Returns `null` when the URI
|
|
19
|
+
* carries no database name (e.g. `mongodb://localhost:27017` or a trailing
|
|
20
|
+
* slash with nothing after it) — callers must treat a `null` name as
|
|
21
|
+
* prod-shaped and never silently default to a production database.
|
|
22
|
+
*
|
|
23
|
+
* Implemented as manual string parsing rather than `new URL()` because Node's
|
|
24
|
+
* URL parser rejects multi-host `mongodb+srv` authorities and mishandles the
|
|
25
|
+
* comma-separated seed-list form that real connection strings use.
|
|
26
|
+
*/
|
|
27
|
+
export function parseDbName(uri: string): string | null {
|
|
28
|
+
// Strip the scheme.
|
|
29
|
+
const schemeMatch = /^mongodb(\+srv)?:\/\//i.exec(uri);
|
|
30
|
+
if (!schemeMatch) return null;
|
|
31
|
+
let rest = uri.slice(schemeMatch[0].length);
|
|
32
|
+
|
|
33
|
+
// Drop query string and fragment — the DB name precedes both.
|
|
34
|
+
const qIdx = rest.search(/[?#]/);
|
|
35
|
+
if (qIdx !== -1) rest = rest.slice(0, qIdx);
|
|
36
|
+
|
|
37
|
+
// The path begins at the first '/' after the authority. Everything before
|
|
38
|
+
// that first slash is userinfo + host(s); everything after is the DB name.
|
|
39
|
+
const slashIdx = rest.indexOf("/");
|
|
40
|
+
if (slashIdx === -1) return null;
|
|
41
|
+
|
|
42
|
+
const dbName = rest.slice(slashIdx + 1).trim();
|
|
43
|
+
return dbName.length > 0 ? dbName : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Classify a database name. A name is a "test" database (no confirmation
|
|
48
|
+
* required) only when it is non-null and ends in {@link TEST_DB_SUFFIX}.
|
|
49
|
+
* Everything else — including a `null` name — is prod-shaped.
|
|
50
|
+
*/
|
|
51
|
+
export function isTestDb(dbName: string | null): boolean {
|
|
52
|
+
return dbName !== null && dbName.endsWith(TEST_DB_SUFFIX);
|
|
53
|
+
}
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* they can be unit-tested without a Mongoose connection.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
import { Types } from "mongoose";
|
|
31
|
+
import type { Types } from "mongoose";
|
|
32
32
|
import type { Connection, Model } from "mongoose";
|
|
33
33
|
|
|
34
34
|
import { cvcRegistryModel, cvcEntryModel } from "../models/index.js";
|
|
@@ -233,18 +233,18 @@ type SectionQuestionRef = InferRawDocType<typeof sectionQuestionRefSchema>;
|
|
|
233
233
|
declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
234
234
|
_id: false;
|
|
235
235
|
}, {
|
|
236
|
-
type: "tip" | "warning" | "prompt";
|
|
237
236
|
text: string;
|
|
238
|
-
}, mongoose.Document<unknown, {}, {
|
|
239
237
|
type: "tip" | "warning" | "prompt";
|
|
238
|
+
}, mongoose.Document<unknown, {}, {
|
|
240
239
|
text: string;
|
|
240
|
+
type: "tip" | "warning" | "prompt";
|
|
241
241
|
}, {
|
|
242
242
|
id: string;
|
|
243
243
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
244
244
|
_id: false;
|
|
245
245
|
}> & Omit<{
|
|
246
|
-
type: "tip" | "warning" | "prompt";
|
|
247
246
|
text: string;
|
|
247
|
+
type: "tip" | "warning" | "prompt";
|
|
248
248
|
} & {
|
|
249
249
|
_id: mongoose.Types.ObjectId;
|
|
250
250
|
} & {
|
|
@@ -252,8 +252,8 @@ declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any
|
|
|
252
252
|
}, "id"> & {
|
|
253
253
|
id: string;
|
|
254
254
|
}, unknown, {
|
|
255
|
-
type: "tip" | "warning" | "prompt";
|
|
256
255
|
text: string;
|
|
256
|
+
type: "tip" | "warning" | "prompt";
|
|
257
257
|
} & {
|
|
258
258
|
_id: mongoose.Types.ObjectId;
|
|
259
259
|
} & {
|
|
@@ -294,18 +294,18 @@ declare const sectionSchemaDefinition: {
|
|
|
294
294
|
type: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
295
295
|
_id: false;
|
|
296
296
|
}, {
|
|
297
|
-
type: "tip" | "warning" | "prompt";
|
|
298
297
|
text: string;
|
|
299
|
-
}, mongoose.Document<unknown, {}, {
|
|
300
298
|
type: "tip" | "warning" | "prompt";
|
|
299
|
+
}, mongoose.Document<unknown, {}, {
|
|
301
300
|
text: string;
|
|
301
|
+
type: "tip" | "warning" | "prompt";
|
|
302
302
|
}, {
|
|
303
303
|
id: string;
|
|
304
304
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
305
305
|
_id: false;
|
|
306
306
|
}> & Omit<{
|
|
307
|
-
type: "tip" | "warning" | "prompt";
|
|
308
307
|
text: string;
|
|
308
|
+
type: "tip" | "warning" | "prompt";
|
|
309
309
|
} & {
|
|
310
310
|
_id: mongoose.Types.ObjectId;
|
|
311
311
|
} & {
|
|
@@ -313,8 +313,8 @@ declare const sectionSchemaDefinition: {
|
|
|
313
313
|
}, "id"> & {
|
|
314
314
|
id: string;
|
|
315
315
|
}, unknown, {
|
|
316
|
-
type: "tip" | "warning" | "prompt";
|
|
317
316
|
text: string;
|
|
317
|
+
type: "tip" | "warning" | "prompt";
|
|
318
318
|
} & {
|
|
319
319
|
_id: mongoose.Types.ObjectId;
|
|
320
320
|
} & {
|
|
@@ -233,18 +233,18 @@ type SectionQuestionRef = InferRawDocType<typeof sectionQuestionRefSchema>;
|
|
|
233
233
|
declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
234
234
|
_id: false;
|
|
235
235
|
}, {
|
|
236
|
-
type: "tip" | "warning" | "prompt";
|
|
237
236
|
text: string;
|
|
238
|
-
}, mongoose.Document<unknown, {}, {
|
|
239
237
|
type: "tip" | "warning" | "prompt";
|
|
238
|
+
}, mongoose.Document<unknown, {}, {
|
|
240
239
|
text: string;
|
|
240
|
+
type: "tip" | "warning" | "prompt";
|
|
241
241
|
}, {
|
|
242
242
|
id: string;
|
|
243
243
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
244
244
|
_id: false;
|
|
245
245
|
}> & Omit<{
|
|
246
|
-
type: "tip" | "warning" | "prompt";
|
|
247
246
|
text: string;
|
|
247
|
+
type: "tip" | "warning" | "prompt";
|
|
248
248
|
} & {
|
|
249
249
|
_id: mongoose.Types.ObjectId;
|
|
250
250
|
} & {
|
|
@@ -252,8 +252,8 @@ declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any
|
|
|
252
252
|
}, "id"> & {
|
|
253
253
|
id: string;
|
|
254
254
|
}, unknown, {
|
|
255
|
-
type: "tip" | "warning" | "prompt";
|
|
256
255
|
text: string;
|
|
256
|
+
type: "tip" | "warning" | "prompt";
|
|
257
257
|
} & {
|
|
258
258
|
_id: mongoose.Types.ObjectId;
|
|
259
259
|
} & {
|
|
@@ -294,18 +294,18 @@ declare const sectionSchemaDefinition: {
|
|
|
294
294
|
type: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
295
295
|
_id: false;
|
|
296
296
|
}, {
|
|
297
|
-
type: "tip" | "warning" | "prompt";
|
|
298
297
|
text: string;
|
|
299
|
-
}, mongoose.Document<unknown, {}, {
|
|
300
298
|
type: "tip" | "warning" | "prompt";
|
|
299
|
+
}, mongoose.Document<unknown, {}, {
|
|
301
300
|
text: string;
|
|
301
|
+
type: "tip" | "warning" | "prompt";
|
|
302
302
|
}, {
|
|
303
303
|
id: string;
|
|
304
304
|
}, Omit<mongoose.DefaultSchemaOptions, "_id"> & {
|
|
305
305
|
_id: false;
|
|
306
306
|
}> & Omit<{
|
|
307
|
-
type: "tip" | "warning" | "prompt";
|
|
308
307
|
text: string;
|
|
308
|
+
type: "tip" | "warning" | "prompt";
|
|
309
309
|
} & {
|
|
310
310
|
_id: mongoose.Types.ObjectId;
|
|
311
311
|
} & {
|
|
@@ -313,8 +313,8 @@ declare const sectionSchemaDefinition: {
|
|
|
313
313
|
}, "id"> & {
|
|
314
314
|
id: string;
|
|
315
315
|
}, unknown, {
|
|
316
|
-
type: "tip" | "warning" | "prompt";
|
|
317
316
|
text: string;
|
|
317
|
+
type: "tip" | "warning" | "prompt";
|
|
318
318
|
} & {
|
|
319
319
|
_id: mongoose.Types.ObjectId;
|
|
320
320
|
} & {
|