@htilabs/platform-common-models 0.8.13 → 0.8.14
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 +44 -0
- package/dist/config/index.cjs +4 -0
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +16 -1
- package/dist/config/index.d.ts +16 -1
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -1
- package/dist/constants/index.cjs +10 -0
- 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 +10 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/cvcs/index.cjs +505 -2
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +2642 -2084
- package/dist/cvcs/index.d.ts +2642 -2084
- package/dist/cvcs/index.js +500 -2
- package/dist/cvcs/index.js.map +1 -1
- package/dist/{index-I-DiX9eQ.d.ts → index-CDoqrfc1.d.ts} +1 -1
- package/dist/{index-CoVr1jIV.d.cts → index-Zu_mOJRn.d.cts} +1 -1
- package/dist/index.cjs +582 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -7
- package/dist/index.d.ts +111 -7
- package/dist/index.js +571 -4
- 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 +383 -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 +351 -0
- package/dist/mongo/index.js.map +1 -0
- package/dist/{platform-auth-BfCMuAlC.d.cts → platform-auth-AsfnIXfK.d.cts} +2 -2
- package/dist/{platform-auth-BfCMuAlC.d.ts → platform-auth-AsfnIXfK.d.ts} +2 -2
- package/dist/schemas/index.cjs +5 -1
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +29 -25
- package/dist/schemas/index.d.ts +29 -25
- package/dist/schemas/index.js +5 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +10 -1
- package/src/__sot__/coreIndicators.pin.json +6 -1
- package/src/__tests__/__snapshots__/cvc-sot.snap +18 -2
- package/src/__tests__/cvc-136-scoring-invariant.test.ts +6 -3
- package/src/__tests__/cvc-drift-gate.test.ts +14 -3
- package/src/__tests__/cvc-sot-snapshot.test.ts +13 -1
- package/src/__tests__/cvc-structural.test.ts +6 -0
- package/src/__tests__/mongo-verifier.test.ts +502 -0
- package/src/config/index.ts +8 -2
- package/src/constants/ic.ts +31 -2
- package/src/cvcs/assertionStatus.v1.0.0.json +80 -0
- package/src/cvcs/coreIndicators.v1.0.0.json +67 -2
- package/src/cvcs/createdBySystem.v1.0.0.json +89 -0
- package/src/cvcs/hmisSex.v1.0.0.json +89 -0
- package/src/cvcs/index.ts +18 -0
- package/src/cvcs/minorAdultStatus.v1.0.0.json +80 -0
- package/src/cvcs/subjectType.v1.0.0.json +80 -0
- package/src/generated/cvc-enums.ts +76 -2
- package/src/index.ts +20 -0
- 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/schemas/common.ts +4 -0
- package/dist/{cvcEntry-BCj1OWqL.d.cts → cvcEntry-0BIB9sen.d.cts} +8 -8
- package/dist/{cvcEntry-BCj1OWqL.d.ts → cvcEntry-0BIB9sen.d.ts} +8 -8
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
// src/config/index.ts
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
function loadContract(runtimeYamlPath) {
|
|
5
|
+
let raw;
|
|
6
|
+
try {
|
|
7
|
+
raw = readFileSync(runtimeYamlPath, "utf8");
|
|
8
|
+
} catch (err) {
|
|
9
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
10
|
+
throw new Error(
|
|
11
|
+
`[platform-common/config] Cannot read ${runtimeYamlPath}: ${msg}`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
const parsed = parse(raw);
|
|
15
|
+
if (!parsed || typeof parsed !== "object") {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`[platform-common/config] ${runtimeYamlPath}: not a YAML mapping`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
if (parsed.version !== 1) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`[platform-common/config] ${runtimeYamlPath}: unsupported contract version ${parsed.version} (expected 1)`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (!parsed.variables || typeof parsed.variables !== "object") {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`[platform-common/config] ${runtimeYamlPath}: missing "variables" map`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return parsed;
|
|
31
|
+
}
|
|
32
|
+
function resolveDefault(spec, env) {
|
|
33
|
+
if (!spec.default) return void 0;
|
|
34
|
+
const v = spec.default[env];
|
|
35
|
+
if (v === void 0) return void 0;
|
|
36
|
+
return String(v);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/mongo/contract.ts
|
|
40
|
+
var TAG = "[platform-common/mongo]";
|
|
41
|
+
function parseMongoBlock(raw, contractPath) {
|
|
42
|
+
if (raw === void 0 || raw === null) return null;
|
|
43
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
44
|
+
throw new Error(`${TAG} ${contractPath}: "mongo" must be a mapping`);
|
|
45
|
+
}
|
|
46
|
+
const block = raw;
|
|
47
|
+
if (!Array.isArray(block.databases) || block.databases.length === 0) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`${TAG} ${contractPath}: "mongo.databases" must be a non-empty list`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
block.databases.forEach((db, i) => {
|
|
53
|
+
const where = `${contractPath}: mongo.databases[${i}]`;
|
|
54
|
+
if (!db || typeof db !== "object") {
|
|
55
|
+
throw new Error(`${TAG} ${where} must be a mapping`);
|
|
56
|
+
}
|
|
57
|
+
if (typeof db.db_var !== "string" || db.db_var.length === 0) {
|
|
58
|
+
throw new Error(`${TAG} ${where}.db_var must be a non-empty string`);
|
|
59
|
+
}
|
|
60
|
+
if (typeof db.uri_var !== "string" || db.uri_var.length === 0) {
|
|
61
|
+
throw new Error(`${TAG} ${where}.uri_var must be a non-empty string`);
|
|
62
|
+
}
|
|
63
|
+
if (!Array.isArray(db.collections)) {
|
|
64
|
+
throw new Error(`${TAG} ${where}.collections must be a list`);
|
|
65
|
+
}
|
|
66
|
+
db.collections.forEach((c, j) => {
|
|
67
|
+
if (typeof c !== "string" || c.length === 0) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`${TAG} ${where}.collections[${j}] must be a non-empty string`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
if (block.env_affinity !== void 0) {
|
|
75
|
+
if (typeof block.env_affinity !== "object" || Array.isArray(block.env_affinity)) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`${TAG} ${contractPath}: "mongo.env_affinity" must be a mapping of env -> suffix`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
for (const [env, suffix] of Object.entries(block.env_affinity)) {
|
|
81
|
+
if (typeof suffix !== "string" || suffix.length === 0) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`${TAG} ${contractPath}: mongo.env_affinity.${env} must be a non-empty string`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
env_affinity: block.env_affinity,
|
|
90
|
+
databases: block.databases
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function checkEnvAffinity(dbName, dbVar, env, affinity) {
|
|
94
|
+
const suffix = affinity?.[env];
|
|
95
|
+
if (!suffix) return null;
|
|
96
|
+
if (dbName.endsWith(suffix)) return null;
|
|
97
|
+
return `${dbVar}="${dbName}" is not valid in environment "${env}": database names must end with "${suffix}". Refusing to run against a database outside this environment.`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/mongo/similarity.ts
|
|
101
|
+
var TYPO_DISTANCE_THRESHOLD = 2;
|
|
102
|
+
function editDistance(a, b, max = Infinity) {
|
|
103
|
+
if (a === b) return 0;
|
|
104
|
+
if (Math.abs(a.length - b.length) > max) return max + 1;
|
|
105
|
+
let prev2 = new Array(b.length + 1).fill(0);
|
|
106
|
+
let prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
107
|
+
let curr = new Array(b.length + 1);
|
|
108
|
+
for (let i = 1; i <= a.length; i++) {
|
|
109
|
+
curr[0] = i;
|
|
110
|
+
let rowMin = curr[0];
|
|
111
|
+
for (let j = 1; j <= b.length; j++) {
|
|
112
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
113
|
+
let d = Math.min(
|
|
114
|
+
prev[j] + 1,
|
|
115
|
+
// deletion
|
|
116
|
+
curr[j - 1] + 1,
|
|
117
|
+
// insertion
|
|
118
|
+
prev[j - 1] + cost
|
|
119
|
+
// substitution
|
|
120
|
+
);
|
|
121
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
122
|
+
d = Math.min(d, prev2[j - 2] + 1);
|
|
123
|
+
}
|
|
124
|
+
curr[j] = d;
|
|
125
|
+
if (d < rowMin) rowMin = d;
|
|
126
|
+
}
|
|
127
|
+
if (rowMin > max) return max + 1;
|
|
128
|
+
[prev2, prev, curr] = [prev, curr, prev2];
|
|
129
|
+
}
|
|
130
|
+
return prev[b.length];
|
|
131
|
+
}
|
|
132
|
+
function stripOrdinal(name) {
|
|
133
|
+
return name.replace(/[-_]?\d+$/, "");
|
|
134
|
+
}
|
|
135
|
+
function isOrdinalSibling(a, b) {
|
|
136
|
+
if (a === b) return false;
|
|
137
|
+
const baseA = stripOrdinal(a);
|
|
138
|
+
const baseB = stripOrdinal(b);
|
|
139
|
+
return baseA === baseB && (baseA !== a || baseB !== b);
|
|
140
|
+
}
|
|
141
|
+
function nearestNames(name, candidates) {
|
|
142
|
+
let best = [];
|
|
143
|
+
let bestDistance = TYPO_DISTANCE_THRESHOLD + 1;
|
|
144
|
+
for (const candidate of candidates) {
|
|
145
|
+
if (candidate === name) return [];
|
|
146
|
+
if (isOrdinalSibling(name, candidate)) continue;
|
|
147
|
+
const d = editDistance(name, candidate, TYPO_DISTANCE_THRESHOLD);
|
|
148
|
+
if (d > TYPO_DISTANCE_THRESHOLD) continue;
|
|
149
|
+
if (d < bestDistance) {
|
|
150
|
+
bestDistance = d;
|
|
151
|
+
best = [candidate];
|
|
152
|
+
} else if (d === bestDistance) {
|
|
153
|
+
best.push(candidate);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return best.sort();
|
|
157
|
+
}
|
|
158
|
+
function formatSuggestions(names) {
|
|
159
|
+
const quoted = names.map((n) => `"${n}"`);
|
|
160
|
+
if (quoted.length <= 1) return quoted[0] ?? "";
|
|
161
|
+
return `${quoted.slice(0, -1).join(", ")} or ${quoted[quoted.length - 1]}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/mongo/uri.ts
|
|
165
|
+
var TEST_DB_SUFFIX = "-test";
|
|
166
|
+
function parseDbName(uri) {
|
|
167
|
+
const schemeMatch = /^mongodb(\+srv)?:\/\//i.exec(uri);
|
|
168
|
+
if (!schemeMatch) return null;
|
|
169
|
+
let rest = uri.slice(schemeMatch[0].length);
|
|
170
|
+
const qIdx = rest.search(/[?#]/);
|
|
171
|
+
if (qIdx !== -1) rest = rest.slice(0, qIdx);
|
|
172
|
+
const slashIdx = rest.indexOf("/");
|
|
173
|
+
if (slashIdx === -1) return null;
|
|
174
|
+
const dbName = rest.slice(slashIdx + 1).trim();
|
|
175
|
+
return dbName.length > 0 ? dbName : null;
|
|
176
|
+
}
|
|
177
|
+
function isTestDb(dbName) {
|
|
178
|
+
return dbName !== null && dbName.endsWith(TEST_DB_SUFFIX);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/mongo/catalog.ts
|
|
182
|
+
function catalogFromClient(client) {
|
|
183
|
+
return {
|
|
184
|
+
async listDatabases() {
|
|
185
|
+
const { databases } = await client.db().admin().listDatabases();
|
|
186
|
+
return databases.map((d) => d.name);
|
|
187
|
+
},
|
|
188
|
+
async listCollections(database) {
|
|
189
|
+
const infos = await client.db(database).listCollections({}, { nameOnly: true }).toArray();
|
|
190
|
+
return infos.map((c) => c.name);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function catalogFromMongoose(connection) {
|
|
195
|
+
return catalogFromClient(connection.getClient());
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/mongo/index.ts
|
|
199
|
+
var TAG2 = "[platform-common/mongo]";
|
|
200
|
+
function resolveDbName(spec, contract, env, processEnv) {
|
|
201
|
+
const varSpec = contract.variables[spec.db_var];
|
|
202
|
+
const raw = processEnv[spec.db_var] ?? (varSpec ? resolveDefault(varSpec, env) : void 0);
|
|
203
|
+
if (raw === void 0 || raw === "") {
|
|
204
|
+
if (varSpec && varSpec.required === false) return { skip: true };
|
|
205
|
+
return { error: `${spec.db_var}: required by mongo contract but not set` };
|
|
206
|
+
}
|
|
207
|
+
if (spec.db_var !== spec.uri_var) return { name: raw };
|
|
208
|
+
const parsed = parseDbName(raw);
|
|
209
|
+
if (parsed === null) {
|
|
210
|
+
return {
|
|
211
|
+
error: `${spec.db_var}: connection string carries no database name. Either embed one (mongodb://host/<db>) or declare a separate db_var.`
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return { name: parsed };
|
|
215
|
+
}
|
|
216
|
+
async function verifyDatabase(spec, dbName, block, env, catalog, existingDatabases) {
|
|
217
|
+
const findings = [];
|
|
218
|
+
const violation = checkEnvAffinity(dbName, spec.db_var, env, block.env_affinity);
|
|
219
|
+
if (violation) {
|
|
220
|
+
findings.push({
|
|
221
|
+
severity: "fatal",
|
|
222
|
+
kind: "db_shape_violation",
|
|
223
|
+
message: violation,
|
|
224
|
+
dbVar: spec.db_var,
|
|
225
|
+
database: dbName
|
|
226
|
+
});
|
|
227
|
+
return findings;
|
|
228
|
+
}
|
|
229
|
+
if (!existingDatabases.includes(dbName)) {
|
|
230
|
+
const suggestions = nearestNames(dbName, existingDatabases);
|
|
231
|
+
if (suggestions.length > 0) {
|
|
232
|
+
findings.push({
|
|
233
|
+
severity: "fatal",
|
|
234
|
+
kind: "db_absent_typo",
|
|
235
|
+
message: `${spec.db_var}="${dbName}" does not exist. Did you mean ${formatSuggestions(suggestions)}?`,
|
|
236
|
+
dbVar: spec.db_var,
|
|
237
|
+
database: dbName,
|
|
238
|
+
suggestions
|
|
239
|
+
});
|
|
240
|
+
} else {
|
|
241
|
+
findings.push({
|
|
242
|
+
severity: "warn",
|
|
243
|
+
kind: "db_absent_unseeded",
|
|
244
|
+
message: `${spec.db_var}="${dbName}" does not exist yet. Treating as an unseeded environment; MongoDB will create it on first write.`,
|
|
245
|
+
dbVar: spec.db_var,
|
|
246
|
+
database: dbName
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return findings;
|
|
250
|
+
}
|
|
251
|
+
if (spec.collections.length === 0) return findings;
|
|
252
|
+
const actual = await catalog.listCollections(dbName);
|
|
253
|
+
for (const declared of spec.collections) {
|
|
254
|
+
if (actual.includes(declared)) continue;
|
|
255
|
+
const suggestions = nearestNames(declared, actual);
|
|
256
|
+
if (suggestions.length > 0) {
|
|
257
|
+
findings.push({
|
|
258
|
+
severity: "fatal",
|
|
259
|
+
kind: "collection_absent_typo",
|
|
260
|
+
message: `${dbName}: declared collection "${declared}" does not exist. Did you mean ${formatSuggestions(suggestions)}?`,
|
|
261
|
+
dbVar: spec.db_var,
|
|
262
|
+
database: dbName,
|
|
263
|
+
collection: declared,
|
|
264
|
+
suggestions
|
|
265
|
+
});
|
|
266
|
+
} else {
|
|
267
|
+
findings.push({
|
|
268
|
+
severity: "warn",
|
|
269
|
+
kind: "collection_absent_unseeded",
|
|
270
|
+
message: `${dbName}: declared collection "${declared}" does not exist yet (no documents written). MongoDB creates collections lazily.`,
|
|
271
|
+
dbVar: spec.db_var,
|
|
272
|
+
database: dbName,
|
|
273
|
+
collection: declared
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const declaredSet = new Set(spec.collections);
|
|
278
|
+
for (const present of actual) {
|
|
279
|
+
if (declaredSet.has(present)) continue;
|
|
280
|
+
findings.push({
|
|
281
|
+
severity: "warn",
|
|
282
|
+
kind: "collection_undeclared",
|
|
283
|
+
message: `${dbName}: collection "${present}" exists but is not declared in the mongo contract.`,
|
|
284
|
+
dbVar: spec.db_var,
|
|
285
|
+
database: dbName,
|
|
286
|
+
collection: present
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return findings;
|
|
290
|
+
}
|
|
291
|
+
async function verifyMongo(runtimeYamlPath, opts) {
|
|
292
|
+
const processEnv = opts.processEnv ?? process.env;
|
|
293
|
+
const logger = opts.logger ?? console;
|
|
294
|
+
const exit = opts.exit ?? ((code) => process.exit(code));
|
|
295
|
+
const env = opts.env ?? processEnv.NODE_ENV ?? "local";
|
|
296
|
+
const contract = loadContract(runtimeYamlPath);
|
|
297
|
+
const block = parseMongoBlock(contract.mongo, runtimeYamlPath);
|
|
298
|
+
if (block === null) return { ok: true, findings: [] };
|
|
299
|
+
const findings = [];
|
|
300
|
+
const resolved = [];
|
|
301
|
+
for (const spec of block.databases) {
|
|
302
|
+
const { name, error, skip } = resolveDbName(spec, contract, env, processEnv);
|
|
303
|
+
if (skip) continue;
|
|
304
|
+
if (error !== void 0 || name === void 0) {
|
|
305
|
+
findings.push({
|
|
306
|
+
severity: "fatal",
|
|
307
|
+
kind: "env_var_missing",
|
|
308
|
+
message: error ?? `${spec.db_var}: unresolved`,
|
|
309
|
+
dbVar: spec.db_var
|
|
310
|
+
});
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
resolved.push({ spec, name });
|
|
314
|
+
}
|
|
315
|
+
const existingDatabases = resolved.length > 0 ? await opts.catalog.listDatabases() : [];
|
|
316
|
+
for (const { spec, name } of resolved) {
|
|
317
|
+
findings.push(
|
|
318
|
+
...await verifyDatabase(
|
|
319
|
+
spec,
|
|
320
|
+
name,
|
|
321
|
+
block,
|
|
322
|
+
env,
|
|
323
|
+
opts.catalog,
|
|
324
|
+
existingDatabases
|
|
325
|
+
)
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
const fatals = findings.filter((f) => f.severity === "fatal");
|
|
329
|
+
const warns = findings.filter((f) => f.severity === "warn");
|
|
330
|
+
for (const w of warns) logger.warn(`${TAG2} ${w.message}`);
|
|
331
|
+
if (fatals.length > 0) {
|
|
332
|
+
const message = [
|
|
333
|
+
`${TAG2} verifyMongo failed for ${runtimeYamlPath} (env "${env}")`,
|
|
334
|
+
`${fatals.length} fatal finding(s):`,
|
|
335
|
+
...fatals.map((f) => ` - ${f.message}`)
|
|
336
|
+
].join("\n");
|
|
337
|
+
if (opts.throwOnFailure) throw new Error(message);
|
|
338
|
+
logger.error(message);
|
|
339
|
+
exit(1);
|
|
340
|
+
}
|
|
341
|
+
return { ok: fatals.length === 0, findings };
|
|
342
|
+
}
|
|
343
|
+
export {
|
|
344
|
+
TEST_DB_SUFFIX,
|
|
345
|
+
catalogFromClient,
|
|
346
|
+
catalogFromMongoose,
|
|
347
|
+
isTestDb,
|
|
348
|
+
parseDbName,
|
|
349
|
+
verifyMongo
|
|
350
|
+
};
|
|
351
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/index.ts","../../src/mongo/contract.ts","../../src/mongo/similarity.ts","../../src/mongo/uri.ts","../../src/mongo/catalog.ts","../../src/mongo/index.ts"],"sourcesContent":["/**\n * @htilabs/platform-common-models — Runtime Config Contract Validator\n *\n * Implements contract R12.1 (platform-common home):\n * - validateAgainstContract(runtimeYamlPath, opts?) — startup validator (R3.2)\n * - createConfigEndpoint(runtimeYamlPath, opts?) — /api/config factory (R7)\n *\n * Consumers MUST call validateAgainstContract once at process startup, before\n * any other initialization that reads env vars. Build-phase variables\n * (phase: build) are NOT checked at runtime per R3.4.\n *\n * No secret VALUES are read, stored, or returned here. Secret env vars are\n * validated for presence but their values are never logged or exposed.\n *\n * Dual ESM + CJS via tsup. Plain JS consumers (pave, leads) use require():\n * const { validateAgainstContract } = require('@htilabs/platform-common-models/config');\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { parse } from \"yaml\";\n\n// ─── Schema types (mirrors thread's runtime-config-lib.ts VariableSpec) ──────\n\nexport interface VariableSpec {\n type: \"string\" | \"boolean\" | \"number\" | \"enum\" | \"url\" | \"json\";\n required: boolean;\n secret: boolean;\n description: string;\n phase?: \"runtime\" | \"build\";\n values?: string[];\n default?: Record<string, unknown>;\n provider?: string;\n name?: string;\n client_visible?: boolean;\n deprecated?: { since: string; remove_after?: string; replacement?: string };\n}\n\nexport interface ServiceContract {\n service: string;\n version: number;\n environments: string[];\n // Thread extensions (tolerated, not required — R1.1 note)\n port?: number;\n build_secrets?: string[];\n variables: Record<string, VariableSpec>;\n /**\n * Optional MongoDB declaration consumed by `@htilabs/platform-common-models/mongo`.\n * Left untyped here to keep `config` free of a dependency on `mongo`; the\n * verifier validates its shape via `parseMongoBlock`.\n */\n mongo?: unknown;\n}\n\n/** Typed config accessor returned by validateAgainstContract. */\nexport type TypedConfig = Record<string, string | boolean | number | unknown>;\n\nexport interface ValidateOptions {\n /**\n * Environment name used to select per-env defaults (e.g. \"local\", \"test\").\n * Defaults to process.env.NODE_ENV, then \"local\".\n */\n env?: string;\n /**\n * If true, do not call process.exit(1) on failure; throw instead.\n * Useful for tests. Defaults to false (production mode exits).\n */\n throwOnFailure?: boolean;\n}\n\nexport interface EndpointOptions {\n /** Cache-Control header value. Defaults to \"private, no-store\". */\n cacheControl?: string;\n}\n\n/**\n * A framework-agnostic route handler that returns a JSON response.\n * Compatible with:\n * - Next.js App Router: export const GET = createConfigEndpoint(...)\n * - Fastify: instance.get('/api/config', createConfigEndpoint(...))\n * - Express: app.get('/api/config', createConfigEndpoint(...))\n */\nexport type RouteHandler = (\n req?: unknown,\n res?: unknown,\n) => Promise<Response | void> | Response | void;\n\n// ─── YAML parser ──────────────────────────────────────────────────────────────\n\nexport function loadContract(runtimeYamlPath: string): ServiceContract {\n let raw: string;\n try {\n raw = readFileSync(runtimeYamlPath, \"utf8\");\n } catch (err) {\n const msg =\n err instanceof Error ? err.message : String(err);\n throw new Error(\n `[platform-common/config] Cannot read ${runtimeYamlPath}: ${msg}`,\n );\n }\n const parsed = parse(raw) as ServiceContract | null;\n if (!parsed || typeof parsed !== \"object\") {\n throw new Error(\n `[platform-common/config] ${runtimeYamlPath}: not a YAML mapping`,\n );\n }\n if (parsed.version !== 1) {\n throw new Error(\n `[platform-common/config] ${runtimeYamlPath}: unsupported contract version ${parsed.version} (expected 1)`,\n );\n }\n if (!parsed.variables || typeof parsed.variables !== \"object\") {\n throw new Error(\n `[platform-common/config] ${runtimeYamlPath}: missing \"variables\" map`,\n );\n }\n return parsed;\n}\n\n// ─── Coercion ────────────────────────────────────────────────────────────────\n\n/**\n * Coerce a raw environment string value to the declared type.\n * Returns [ok, coerced] or [false, errorMessage].\n */\nfunction coerce(\n key: string,\n raw: string,\n spec: VariableSpec,\n): [true, unknown] | [false, string] {\n switch (spec.type) {\n case \"boolean\": {\n if (raw === \"true\" || raw === \"1\") return [true, true];\n if (raw === \"false\" || raw === \"0\") return [true, false];\n return [false, `${key}: expected boolean (\"true\"/\"false\"/\"1\"/\"0\"), got \"${raw}\"`];\n }\n case \"number\": {\n const n = Number(raw);\n if (!Number.isFinite(n)) {\n return [false, `${key}: expected number, got \"${raw}\"`];\n }\n return [true, n];\n }\n case \"enum\": {\n const vals = spec.values ?? [];\n if (!vals.includes(raw)) {\n return [false, `${key}: expected one of [${vals.join(\", \")}], got \"${raw}\"`];\n }\n return [true, raw];\n }\n case \"url\": {\n try {\n new URL(raw);\n return [true, raw];\n } catch {\n return [false, `${key}: expected a valid URL, got \"${raw}\"`];\n }\n }\n case \"json\": {\n try {\n const parsed = JSON.parse(raw) as unknown;\n return [true, parsed];\n } catch {\n return [false, `${key}: expected valid JSON, got \"${raw}\"`];\n }\n }\n default:\n // string\n return [true, raw];\n }\n}\n\n// ─── Default application ─────────────────────────────────────────────────────\n\n/**\n * Returns the default value for a variable in the given environment,\n * or undefined if no default applies.\n *\n * Exact env match only — defaults are per-environment and MUST NOT bleed\n * across envs. (A local default stays local; it does not fall back into prod.)\n */\nexport function resolveDefault(\n spec: VariableSpec,\n env: string,\n): string | undefined {\n if (!spec.default) return undefined;\n const v = spec.default[env];\n if (v === undefined) return undefined;\n return String(v);\n}\n\n// ─── validateAgainstContract ─────────────────────────────────────────────────\n\n/**\n * Parse `runtimeYamlPath`, coerce every runtime-phase variable from\n * `process.env` (with per-env defaults applied), and fail fast on any\n * missing or invalid required variable (R3.2).\n *\n * Build-phase variables (phase: build) are skipped per R3.4.\n *\n * Returns a typed config object keyed by variable name.\n */\nexport function validateAgainstContract(\n runtimeYamlPath: string,\n opts: ValidateOptions = {},\n): TypedConfig {\n const contract = loadContract(runtimeYamlPath);\n const env =\n opts.env ??\n (process.env.NODE_ENV as string | undefined) ??\n \"local\";\n\n const errors: string[] = [];\n const result: TypedConfig = {};\n\n for (const [key, spec] of Object.entries(contract.variables)) {\n // R3.4: skip build-phase variables entirely at runtime.\n if (spec.phase === \"build\") continue;\n\n const rawFromEnv = process.env[key];\n const defaultValue = resolveDefault(spec, env);\n const effective = rawFromEnv ?? defaultValue;\n\n if (effective === undefined || effective === \"\") {\n if (spec.required) {\n errors.push(\n `${key}: required but not set (no value in process.env and no default for env \"${env}\")`,\n );\n }\n // Not required and not set — omit from result.\n continue;\n }\n\n const [ok, coerced] = coerce(key, effective, spec);\n if (!ok) {\n errors.push(coerced as string);\n continue;\n }\n result[key] = coerced;\n }\n\n if (errors.length > 0) {\n const message = [\n `[platform-common/config] validateAgainstContract failed for ${runtimeYamlPath}`,\n `${errors.length} variable(s) missing or invalid:`,\n ...errors.map((e) => ` - ${e}`),\n ].join(\"\\n\");\n\n if (opts.throwOnFailure) {\n throw new Error(message);\n }\n console.error(message);\n process.exit(1);\n }\n\n return result;\n}\n\n// ─── createConfigEndpoint ────────────────────────────────────────────────────\n\n/**\n * Build a static JSON payload containing only variables that are\n * client_visible: true AND secret: false (R7.2, R7.3). Reads process.env\n * once at factory call time.\n */\nfunction buildClientPayload(\n contract: ServiceContract,\n env: string,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n\n for (const [key, spec] of Object.entries(contract.variables)) {\n // R7.3: never expose secrets.\n if (spec.secret) continue;\n // R7.2: only expose client_visible vars.\n if (!spec.client_visible) continue;\n // R3.4: build-phase vars are not available at runtime.\n if (spec.phase === \"build\") continue;\n\n const raw = process.env[key] ?? resolveDefault(spec, env);\n if (raw === undefined) continue;\n\n const [ok, coerced] = coerce(key, raw, spec);\n payload[key] = ok ? coerced : raw;\n }\n\n return payload;\n}\n\n/**\n * Route-handler factory for GET /api/config (R7.1).\n *\n * Reads the contract and process.env once at factory-call time and caches\n * the JSON payload. The returned handler is compatible with:\n *\n * Next.js App Router:\n * export const GET = createConfigEndpoint(path);\n *\n * Fastify:\n * instance.get('/api/config', createConfigEndpoint(path));\n *\n * Express:\n * app.get('/api/config', createConfigEndpoint(path));\n *\n * The handler detects the calling convention at runtime:\n * - Next.js / fetch-native: called with no arguments; returns a Response.\n * - Express: called with (req, res); calls res.json() and returns void.\n * - Fastify: called with (req, reply); calls reply.send() and returns void.\n */\nexport function createConfigEndpoint(\n runtimeYamlPath: string,\n opts: EndpointOptions = {},\n): RouteHandler {\n const contract = loadContract(runtimeYamlPath);\n const env =\n (process.env.NODE_ENV as string | undefined) ?? \"local\";\n const payload = buildClientPayload(contract, env);\n const cacheControl = opts.cacheControl ?? \"private, no-store\";\n const body = JSON.stringify(payload);\n\n return function configHandler(\n _req?: unknown,\n res?: unknown,\n ): Promise<Response | void> | Response | void {\n // Express-shaped: res has .json()\n if (res && typeof (res as Record<string, unknown>)[\"json\"] === \"function\") {\n const r = res as {\n setHeader: (k: string, v: string) => void;\n json: (data: unknown) => void;\n };\n r.setHeader(\"Cache-Control\", cacheControl);\n r.setHeader(\"Content-Type\", \"application/json\");\n r.json(payload);\n return;\n }\n\n // Fastify-shaped: res has .send()\n if (res && typeof (res as Record<string, unknown>)[\"send\"] === \"function\") {\n const r = res as {\n header: (k: string, v: string) => void;\n type: (ct: string) => void;\n send: (data: string) => void;\n };\n r.header(\"Cache-Control\", cacheControl);\n r.type(\"application/json\");\n r.send(body);\n return;\n }\n\n // Next.js / fetch-native (no res argument, or unrecognised res)\n return new Response(body, {\n status: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Cache-Control\": cacheControl,\n },\n });\n };\n}\n","/**\n * @htilabs/platform-common-models — `mongo:` contract block\n *\n * Extends the HTI Runtime Config Contract (`config/runtime/<service>.yaml`)\n * with a declaration of the databases and collections a service expects.\n *\n * The declaration is deliberately data, not code: `expansion` is Python and\n * parses the same YAML. Nothing here may depend on a TypeScript-only construct.\n *\n * ## Why declared rather than introspected\n *\n * Reading collection names off registered Mongoose models would cover only the\n * Mongoose apps (thread, leads, pave) and would report false findings: thread\n * registers `AgencyInfo` (collection `agencyinfos`), which exists in NO\n * database because nothing has ever written to it. Mongo creates collections\n * lazily. A declaration states intent; introspection only restates the code.\n */\n\n/** One database a service connects to, and the collections it uses. */\nexport interface MongoDbSpec {\n /** Contract variable holding the database NAME (e.g. `THREAD_DB`). */\n db_var: string;\n /**\n * Contract variable holding the connection URI or cluster prefix\n * (e.g. `MONGODB_CLUSTER`). When the URI already embeds a database name and\n * no `db_var` applies, set `db_var` to the same variable — the name is then\n * parsed out of the URI.\n */\n uri_var: string;\n /**\n * Collections the service reads or writes. Declare only what the service\n * USES — not everything present in the database. An undeclared collection\n * present in Mongo is reported, never fatal.\n *\n * An EMPTY list opts out of collection checking entirely: only the database\n * name is verified, and `listCollections` is never called. Use it when a\n * service reaches a database whose collections it cannot practically\n * enumerate. Declaring even one collection opts back in.\n */\n collections: string[];\n}\n\n/**\n * Per-environment database-name affinity. When the deploy environment has an\n * entry here, every resolved database name must end with the given suffix.\n *\n * This generalizes thread's `assertTestDb` (packages/db/src/connections.ts):\n * it is the only check that catches a test run pointed at a production\n * database, and it needs no connection to MongoDB.\n */\nexport type EnvAffinity = Record<string, string>;\n\nexport interface MongoContractBlock {\n /** e.g. `{ test: \"-test\", dev: \"-dev\" }`. Environments omitted are unconstrained. */\n env_affinity?: EnvAffinity;\n databases: MongoDbSpec[];\n}\n\n/** Prefix for every diagnostic this module emits. */\nconst TAG = \"[platform-common/mongo]\";\n\n/**\n * Validate and normalize the `mongo:` block of a parsed contract.\n *\n * Returns `null` when the contract declares no `mongo:` block — a service that\n * does not use MongoDB is not an error.\n *\n * Throws on a malformed block: a contract that lies about its shape is a\n * programming error, not a runtime finding.\n */\nexport function parseMongoBlock(\n raw: unknown,\n contractPath: string,\n): MongoContractBlock | null {\n if (raw === undefined || raw === null) return null;\n\n if (typeof raw !== \"object\" || Array.isArray(raw)) {\n throw new Error(`${TAG} ${contractPath}: \"mongo\" must be a mapping`);\n }\n\n const block = raw as Partial<MongoContractBlock>;\n\n if (!Array.isArray(block.databases) || block.databases.length === 0) {\n throw new Error(\n `${TAG} ${contractPath}: \"mongo.databases\" must be a non-empty list`,\n );\n }\n\n block.databases.forEach((db, i) => {\n const where = `${contractPath}: mongo.databases[${i}]`;\n if (!db || typeof db !== \"object\") {\n throw new Error(`${TAG} ${where} must be a mapping`);\n }\n if (typeof db.db_var !== \"string\" || db.db_var.length === 0) {\n throw new Error(`${TAG} ${where}.db_var must be a non-empty string`);\n }\n if (typeof db.uri_var !== \"string\" || db.uri_var.length === 0) {\n throw new Error(`${TAG} ${where}.uri_var must be a non-empty string`);\n }\n if (!Array.isArray(db.collections)) {\n throw new Error(`${TAG} ${where}.collections must be a list`);\n }\n db.collections.forEach((c, j) => {\n if (typeof c !== \"string\" || c.length === 0) {\n throw new Error(\n `${TAG} ${where}.collections[${j}] must be a non-empty string`,\n );\n }\n });\n });\n\n if (block.env_affinity !== undefined) {\n if (typeof block.env_affinity !== \"object\" || Array.isArray(block.env_affinity)) {\n throw new Error(\n `${TAG} ${contractPath}: \"mongo.env_affinity\" must be a mapping of env -> suffix`,\n );\n }\n for (const [env, suffix] of Object.entries(block.env_affinity)) {\n if (typeof suffix !== \"string\" || suffix.length === 0) {\n throw new Error(\n `${TAG} ${contractPath}: mongo.env_affinity.${env} must be a non-empty string`,\n );\n }\n }\n }\n\n return {\n env_affinity: block.env_affinity,\n databases: block.databases as MongoDbSpec[],\n };\n}\n\n/**\n * Check a resolved database name against the environment's affinity suffix.\n *\n * Returns `null` when the name is acceptable (or the environment declares no\n * affinity), otherwise a human-readable violation message.\n *\n * Requires NO MongoDB connection. This is the check that catches\n * `NODE_ENV=test` pointed at `platform-db`.\n */\nexport function checkEnvAffinity(\n dbName: string,\n dbVar: string,\n env: string,\n affinity: EnvAffinity | undefined,\n): string | null {\n const suffix = affinity?.[env];\n if (!suffix) return null;\n if (dbName.endsWith(suffix)) return null;\n\n return (\n `${dbVar}=\"${dbName}\" is not valid in environment \"${env}\": ` +\n `database names must end with \"${suffix}\". ` +\n `Refusing to run against a database outside this environment.`\n );\n}\n","/**\n * @htilabs/platform-common-models — name-similarity heuristic\n *\n * A missing database or collection is AMBIGUOUS. MongoDB creates namespaces\n * lazily, on first write, so \"absent\" means either:\n *\n * (a) a typo — the name is wrong and the real one exists nearby, or\n * (b) unseeded — the environment is new and nothing has been written yet.\n *\n * Guessing wrong in direction (b) is expensive: a fatal check would ground\n * every cold-start ephemeral deploy. So absence alone is never fatal. Only\n * absence WITH a plausible near-neighbour is treated as a typo.\n */\n\n/** Maximum edit distance at which a neighbouring name is considered a typo. */\nexport const TYPO_DISTANCE_THRESHOLD = 2;\n\n/**\n * Optimal String Alignment distance (Damerau-Levenshtein restricted to\n * adjacent transpositions), bounded: returns `max + 1` as soon as the true\n * distance is known to exceed `max`. Bounding keeps this cheap across the\n * ~90-database catalogue scanned on each lookup.\n *\n * A transposition MUST cost 1, not 2. `platform-dve` is a transposition of\n * `platform-dev`, but plain Levenshtein scores it 2 -- tying it with the\n * unrelated PRODUCTION name `platform-db` and letting iteration order pick.\n * Steering an operator toward a production database because they typo'd a dev\n * one is a worse failure than suggesting nothing at all.\n */\nexport function editDistance(a: string, b: string, max = Infinity): number {\n if (a === b) return 0;\n if (Math.abs(a.length - b.length) > max) return max + 1;\n\n // Three rows: prev2 carries i-2 so an adjacent transposition costs 1.\n let prev2 = new Array<number>(b.length + 1).fill(0);\n let prev = Array.from({ length: b.length + 1 }, (_, i) => i);\n let curr = new Array<number>(b.length + 1);\n\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i;\n let rowMin = curr[0];\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n let d = Math.min(\n prev[j] + 1, // deletion\n curr[j - 1] + 1, // insertion\n prev[j - 1] + cost, // substitution\n );\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n d = Math.min(d, prev2[j - 2] + 1); // adjacent transposition\n }\n curr[j] = d;\n if (d < rowMin) rowMin = d;\n }\n // Every remaining row can only grow: bail out early.\n if (rowMin > max) return max + 1;\n [prev2, prev, curr] = [prev, curr, prev2];\n }\n\n return prev[b.length];\n}\n\n/** Strip a trailing ordinal token: `demo2` -> `demo`, `cypress-tests-3` -> `cypress-tests`. */\nfunction stripOrdinal(name: string): string {\n return name.replace(/[-_]?\\d+$/, \"\");\n}\n\n/**\n * True when two names look like sibling environments rather than a typo of\n * each other — that is, they differ ONLY in a trailing ordinal.\n *\n * This guard is mandatory, not cosmetic. The live cluster contains\n * `leads-platform-demo` beside `leads-platform-demo2` (edit distance 1) and\n * `cypress-tests-1/2/3`. Without it, provisioning `leads-platform-demo3` would\n * find `demo2` one edit away, be branded a typo, and hard-fail a healthy new\n * environment — reintroducing exactly the cold-start breakage the severity\n * model exists to prevent.\n *\n * The guard is deliberately biased toward WARN: a genuine typo that happens to\n * differ only in a trailing digit is downgraded to a warning rather than\n * risking a false fatal.\n */\nexport function isOrdinalSibling(a: string, b: string): boolean {\n if (a === b) return false;\n const baseA = stripOrdinal(a);\n const baseB = stripOrdinal(b);\n // Both must reduce to the same base, and at least one must have carried an\n // ordinal (otherwise stripping changed nothing and this is a real edit).\n return baseA === baseB && (baseA !== a || baseB !== b);\n}\n\n/**\n * Find the existing names most likely to be what `name` was meant to be.\n *\n * Returns EVERY candidate at the minimal distance, not one arbitrary winner.\n * `thread-dv` is one edit from both `thread-dev` and `thread-db`; picking\n * between them by iteration order could point an operator at production. When\n * the evidence is ambiguous, say so.\n *\n * Returns an empty array when nothing is close enough, or when the only close\n * matches are sibling environments (see {@link isOrdinalSibling}). Empty means\n * \"absent, but no evidence of a typo\" — the caller warns rather than fails.\n *\n * Results are sorted for deterministic messages.\n */\nexport function nearestNames(name: string, candidates: readonly string[]): string[] {\n let best: string[] = [];\n let bestDistance = TYPO_DISTANCE_THRESHOLD + 1;\n\n for (const candidate of candidates) {\n if (candidate === name) return []; // exact match: not missing at all\n if (isOrdinalSibling(name, candidate)) continue;\n\n const d = editDistance(name, candidate, TYPO_DISTANCE_THRESHOLD);\n if (d > TYPO_DISTANCE_THRESHOLD) continue;\n\n if (d < bestDistance) {\n bestDistance = d;\n best = [candidate];\n } else if (d === bestDistance) {\n best.push(candidate);\n }\n }\n\n return best.sort();\n}\n\n/** Render one or more suggestions as `\"a\"`, or `\"a\" or \"b\"`, or `\"a\", \"b\" or \"c\"`. */\nexport function formatSuggestions(names: readonly string[]): string {\n const quoted = names.map((n) => `\"${n}\"`);\n if (quoted.length <= 1) return quoted[0] ?? \"\";\n return `${quoted.slice(0, -1).join(\", \")} or ${quoted[quoted.length - 1]}`;\n}\n","/**\n * @htilabs/platform-common-models — MongoDB URI parsing\n *\n * Home of the connection-string parsing shared by the seed guard\n * (`scripts/lib/confirmTargetDb.ts`) and the runtime verifier\n * (`src/mongo/index.ts`). It lives in `src/` so both can import one\n * implementation; `scripts/` cannot be imported from `src/` at build time.\n */\n\n/** Suffix that marks a database as a non-production scratch/test database. */\nexport const TEST_DB_SUFFIX = \"-test\";\n\n/**\n * Parse the target database name out of a MongoDB connection URI.\n *\n * The database name is the path segment after the host(s), before any query\n * string (`?...`). Handles both `mongodb://` and `mongodb+srv://` URIs and any\n * userinfo / multi-host / option components. Returns `null` when the URI\n * carries no database name (e.g. `mongodb://localhost:27017` or a trailing\n * slash with nothing after it) — callers must treat a `null` name as\n * prod-shaped and never silently default to a production database.\n *\n * Implemented as manual string parsing rather than `new URL()` because Node's\n * URL parser rejects multi-host `mongodb+srv` authorities and mishandles the\n * comma-separated seed-list form that real connection strings use.\n */\nexport function parseDbName(uri: string): string | null {\n // Strip the scheme.\n const schemeMatch = /^mongodb(\\+srv)?:\\/\\//i.exec(uri);\n if (!schemeMatch) return null;\n let rest = uri.slice(schemeMatch[0].length);\n\n // Drop query string and fragment — the DB name precedes both.\n const qIdx = rest.search(/[?#]/);\n if (qIdx !== -1) rest = rest.slice(0, qIdx);\n\n // The path begins at the first '/' after the authority. Everything before\n // that first slash is userinfo + host(s); everything after is the DB name.\n const slashIdx = rest.indexOf(\"/\");\n if (slashIdx === -1) return null;\n\n const dbName = rest.slice(slashIdx + 1).trim();\n return dbName.length > 0 ? dbName : null;\n}\n\n/**\n * Classify a database name. A name is a \"test\" database (no confirmation\n * required) only when it is non-null and ends in {@link TEST_DB_SUFFIX}.\n * Everything else — including a `null` name — is prod-shaped.\n */\nexport function isTestDb(dbName: string | null): boolean {\n return dbName !== null && dbName.endsWith(TEST_DB_SUFFIX);\n}\n","/**\n * @htilabs/platform-common-models — read-only MongoDB catalogue\n *\n * The verifier reaches MongoDB ONLY through this interface. It exposes two\n * read operations and nothing else: there is no method here that can create,\n * write, or drop anything. The read-only guarantee is enforced by the type,\n * not by convention.\n *\n * Injecting the catalogue also keeps the package's test suite free of a real\n * MongoDB, matching how `runCvcBootCheck` injects `exit` and `logger`.\n */\n\nexport interface MongoCatalog {\n /** Names of databases that physically exist (i.e. hold data). */\n listDatabases(): Promise<string[]>;\n /** Names of collections that physically exist in `database`. */\n listCollections(database: string): Promise<string[]>;\n}\n\n/**\n * Minimal structural view of a `mongodb` MongoClient. Declared structurally so\n * this package takes no dependency on the `mongodb` driver — apps pass their\n * own client, whatever major version they are on.\n */\nexport interface MongoClientLike {\n db(name?: string): {\n admin(): {\n listDatabases(): Promise<{ databases: Array<{ name: string }> }>;\n };\n listCollections(\n filter?: Record<string, unknown>,\n options?: Record<string, unknown>,\n ): { toArray(): Promise<Array<{ name: string }>> };\n };\n}\n\n/** Minimal structural view of a Mongoose Connection. */\nexport interface MongooseConnectionLike {\n getClient(): MongoClientLike;\n}\n\n/** Build a catalogue from a native `mongodb` client. */\nexport function catalogFromClient(client: MongoClientLike): MongoCatalog {\n return {\n async listDatabases(): Promise<string[]> {\n const { databases } = await client.db().admin().listDatabases();\n return databases.map((d) => d.name);\n },\n async listCollections(database: string): Promise<string[]> {\n // `nameOnly` keeps the server from materializing collection options.\n const infos = await client\n .db(database)\n .listCollections({}, { nameOnly: true })\n .toArray();\n return infos.map((c) => c.name);\n },\n };\n}\n\n/** Build a catalogue from an open Mongoose connection. */\nexport function catalogFromMongoose(\n connection: MongooseConnectionLike,\n): MongoCatalog {\n return catalogFromClient(connection.getClient());\n}\n","/**\n * @htilabs/platform-common-models — MongoDB connection/collection verifier\n *\n * Sibling to `./config`. Where `validateAgainstContract` proves the env vars\n * are present and well-typed, `verifyMongo` proves they point somewhere real.\n *\n * ## What this catches\n * - a database name that does not exist and looks like a typo of one that does\n * - a collection name that does not exist and looks like a typo of one that does\n * - a database name that does not belong to the current environment\n * (env-affinity; needs no connection — generalizes thread's `assertTestDb`)\n * - collections present in MongoDB but undeclared by the service (reported)\n *\n * ## What this CANNOT catch\n * A plausible-but-wrong POPULATED database. `leads-platform-prod-test` exists\n * and carries the same collection names as `leads-platform-test`; every\n * name-existence check passes. Detecting that needs an identity marker\n * written inside the database, which is outside this utility's read-only\n * remit. Do not claim otherwise in adoption docs.\n *\n * ## Read-only\n * Reaches MongoDB solely through {@link MongoCatalog}: listDatabases and\n * listCollections. It never creates, writes, or drops anything.\n *\n * ## Severity\n * MongoDB creates namespaces lazily, so ABSENCE IS AMBIGUOUS (typo vs\n * unseeded environment). Absence alone warns; absence with a plausible\n * near-neighbour is fatal. See `similarity.ts`.\n *\n * FACT (verified 2026-07-10, read-only): thread registers the Mongoose model\n * `AgencyInfo` (collection `agencyinfos`), and that collection exists in\n * neither `platform-test` (15 collections) nor `platform-dev` (41). A\n * registered model with zero documents has no collection. The warn-on-absence\n * rule exists because of this; do not \"tighten\" it to fatal.\n */\n\nimport {\n loadContract,\n resolveDefault,\n type ServiceContract,\n} from \"../config/index.js\";\nimport {\n parseMongoBlock,\n checkEnvAffinity,\n type MongoContractBlock,\n type MongoDbSpec,\n} from \"./contract.js\";\nimport { nearestNames, formatSuggestions } from \"./similarity.js\";\nimport { parseDbName } from \"./uri.js\";\nimport type { MongoCatalog } from \"./catalog.js\";\n\nexport type { MongoCatalog, MongoClientLike, MongooseConnectionLike } from \"./catalog.js\";\nexport { catalogFromClient, catalogFromMongoose } from \"./catalog.js\";\nexport type { MongoContractBlock, MongoDbSpec, EnvAffinity } from \"./contract.js\";\nexport { parseDbName, isTestDb, TEST_DB_SUFFIX } from \"./uri.js\";\n\nconst TAG = \"[platform-common/mongo]\";\n\nexport type Severity = \"fatal\" | \"warn\";\n\nexport type FindingKind =\n | \"env_var_missing\"\n | \"db_shape_violation\"\n | \"db_absent_typo\"\n | \"db_absent_unseeded\"\n | \"collection_absent_typo\"\n | \"collection_absent_unseeded\"\n | \"collection_undeclared\";\n\nexport interface Finding {\n severity: Severity;\n kind: FindingKind;\n message: string;\n dbVar?: string;\n database?: string;\n collection?: string;\n /**\n * Existing names this looks like a typo of. More than one means the evidence\n * is ambiguous — the message lists them all rather than guessing.\n */\n suggestions?: string[];\n}\n\nexport interface MongoVerifyReport {\n /** True when no fatal finding was produced. Warnings do not clear `ok`. */\n ok: boolean;\n findings: Finding[];\n}\n\nexport interface VerifyMongoOptions {\n /** Read-only catalogue. Required — this package takes no driver dependency. */\n catalog: MongoCatalog;\n /** Environment name for affinity checks. Defaults to NODE_ENV, then \"local\". */\n env?: string;\n /** Env source. Defaults to `process.env`. */\n processEnv?: NodeJS.ProcessEnv;\n /** If true, throw instead of `exit(1)`. Defaults to false (production exits). */\n throwOnFailure?: boolean;\n /** Injected for tests. Defaults to `process.exit`. */\n exit?: (code: number) => never;\n /** Injected for tests. Defaults to `console`. */\n logger?: Pick<Console, \"error\" | \"warn\">;\n}\n\n/**\n * Resolve the database name for a spec, applying the same per-environment\n * defaults that `validateAgainstContract` applies. Reading `process.env` alone\n * would miss a value the contract supplies as a default (thread declares\n * `PLATFORM_DB.default.prod: platform-prod`) and report a false fatal.\n *\n * When `db_var` and `uri_var` name the same variable, the database is embedded\n * in the connection string (auth does this for `LEADS_MONGODB_URI` and\n * friends) and must be parsed out of it.\n *\n * A variable the contract marks `required: false` and that carries no value is\n * SKIPPED, not failed: thread's `PAVE_DB` is optional and its absence simply\n * means the read-only pave connection is not configured. Required-ness comes\n * from the contract so there is no second place to declare it.\n */\nfunction resolveDbName(\n spec: MongoDbSpec,\n contract: ServiceContract,\n env: string,\n processEnv: NodeJS.ProcessEnv,\n): { name?: string; error?: string; skip?: boolean } {\n const varSpec = contract.variables[spec.db_var];\n const raw =\n processEnv[spec.db_var] ??\n (varSpec ? resolveDefault(varSpec, env) : undefined);\n\n if (raw === undefined || raw === \"\") {\n // A variable absent from `variables` is treated as required: the mongo\n // block references something the contract never declared.\n if (varSpec && varSpec.required === false) return { skip: true };\n return { error: `${spec.db_var}: required by mongo contract but not set` };\n }\n\n if (spec.db_var !== spec.uri_var) return { name: raw };\n\n const parsed = parseDbName(raw);\n if (parsed === null) {\n return {\n error:\n `${spec.db_var}: connection string carries no database name. ` +\n `Either embed one (mongodb://host/<db>) or declare a separate db_var.`,\n };\n }\n return { name: parsed };\n}\n\nasync function verifyDatabase(\n spec: MongoDbSpec,\n dbName: string,\n block: MongoContractBlock,\n env: string,\n catalog: MongoCatalog,\n existingDatabases: readonly string[],\n): Promise<Finding[]> {\n const findings: Finding[] = [];\n\n // 1. Env affinity — no connection required, and the only check that catches\n // a test run pointed at production.\n const violation = checkEnvAffinity(dbName, spec.db_var, env, block.env_affinity);\n if (violation) {\n findings.push({\n severity: \"fatal\",\n kind: \"db_shape_violation\",\n message: violation,\n dbVar: spec.db_var,\n database: dbName,\n });\n // A database in the wrong environment must not be probed further.\n return findings;\n }\n\n // 2. Existence.\n if (!existingDatabases.includes(dbName)) {\n const suggestions = nearestNames(dbName, existingDatabases);\n if (suggestions.length > 0) {\n findings.push({\n severity: \"fatal\",\n kind: \"db_absent_typo\",\n message:\n `${spec.db_var}=\"${dbName}\" does not exist. ` +\n `Did you mean ${formatSuggestions(suggestions)}?`,\n dbVar: spec.db_var,\n database: dbName,\n suggestions,\n });\n } else {\n findings.push({\n severity: \"warn\",\n kind: \"db_absent_unseeded\",\n message:\n `${spec.db_var}=\"${dbName}\" does not exist yet. Treating as an ` +\n `unseeded environment; MongoDB will create it on first write.`,\n dbVar: spec.db_var,\n database: dbName,\n });\n }\n // Nothing to compare collections against.\n return findings;\n }\n\n // 3. An empty `collections` list opts out of collection checking: verify the\n // database NAME only. This lets a service adopt incrementally — expansion\n // reaches the leads databases but enumerating their collections is not\n // tractable, and sweeping a 467MB database would emit a warning per\n // collection. Declaring even one collection opts back in.\n if (spec.collections.length === 0) return findings;\n\n // 4. Collections, both directions.\n const actual = await catalog.listCollections(dbName);\n\n for (const declared of spec.collections) {\n if (actual.includes(declared)) continue;\n\n const suggestions = nearestNames(declared, actual);\n if (suggestions.length > 0) {\n findings.push({\n severity: \"fatal\",\n kind: \"collection_absent_typo\",\n message:\n `${dbName}: declared collection \"${declared}\" does not exist. ` +\n `Did you mean ${formatSuggestions(suggestions)}?`,\n dbVar: spec.db_var,\n database: dbName,\n collection: declared,\n suggestions,\n });\n } else {\n findings.push({\n severity: \"warn\",\n kind: \"collection_absent_unseeded\",\n message:\n `${dbName}: declared collection \"${declared}\" does not exist yet ` +\n `(no documents written). MongoDB creates collections lazily.`,\n dbVar: spec.db_var,\n database: dbName,\n collection: declared,\n });\n }\n }\n\n const declaredSet = new Set(spec.collections);\n for (const present of actual) {\n if (declaredSet.has(present)) continue;\n findings.push({\n severity: \"warn\",\n kind: \"collection_undeclared\",\n message:\n `${dbName}: collection \"${present}\" exists but is not declared in the ` +\n `mongo contract.`,\n dbVar: spec.db_var,\n database: dbName,\n collection: present,\n });\n }\n\n return findings;\n}\n\n/**\n * Verify every database and collection declared in `runtimeYamlPath` against a\n * live MongoDB catalogue.\n *\n * Collects ALL findings before deciding, exactly as `validateAgainstContract`\n * does — an operator fixing a misconfiguration should see every problem at\n * once, not one per restart.\n *\n * Resolves to the report when no fatal finding is produced. On a fatal finding\n * it prints every finding and calls `exit(1)`, or throws when\n * `throwOnFailure` is set.\n *\n * A contract with no `mongo:` block is a no-op success.\n */\nexport async function verifyMongo(\n runtimeYamlPath: string,\n opts: VerifyMongoOptions,\n): Promise<MongoVerifyReport> {\n const processEnv = opts.processEnv ?? process.env;\n const logger = opts.logger ?? console;\n const exit = opts.exit ?? ((code: number) => process.exit(code));\n const env = opts.env ?? processEnv.NODE_ENV ?? \"local\";\n\n const contract = loadContract(runtimeYamlPath);\n const block = parseMongoBlock(contract.mongo, runtimeYamlPath);\n if (block === null) return { ok: true, findings: [] };\n\n const findings: Finding[] = [];\n const resolved: Array<{ spec: MongoDbSpec; name: string }> = [];\n\n for (const spec of block.databases) {\n const { name, error, skip } = resolveDbName(spec, contract, env, processEnv);\n if (skip) continue; // optional database, not configured in this environment\n if (error !== undefined || name === undefined) {\n findings.push({\n severity: \"fatal\",\n kind: \"env_var_missing\",\n message: error ?? `${spec.db_var}: unresolved`,\n dbVar: spec.db_var,\n });\n continue;\n }\n resolved.push({ spec, name });\n }\n\n // One catalogue read shared across every database in the contract.\n const existingDatabases =\n resolved.length > 0 ? await opts.catalog.listDatabases() : [];\n\n for (const { spec, name } of resolved) {\n findings.push(\n ...(await verifyDatabase(\n spec,\n name,\n block,\n env,\n opts.catalog,\n existingDatabases,\n )),\n );\n }\n\n const fatals = findings.filter((f) => f.severity === \"fatal\");\n const warns = findings.filter((f) => f.severity === \"warn\");\n\n for (const w of warns) logger.warn(`${TAG} ${w.message}`);\n\n if (fatals.length > 0) {\n const message = [\n `${TAG} verifyMongo failed for ${runtimeYamlPath} (env \"${env}\")`,\n `${fatals.length} fatal finding(s):`,\n ...fatals.map((f) => ` - ${f.message}`),\n ].join(\"\\n\");\n\n if (opts.throwOnFailure) throw new Error(message);\n logger.error(message);\n exit(1);\n }\n\n return { ok: fatals.length === 0, findings };\n}\n"],"mappings":";AAkBA,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AAqEf,SAAS,aAAa,iBAA0C;AACrE,MAAI;AACJ,MAAI;AACF,UAAM,aAAa,iBAAiB,MAAM;AAAA,EAC5C,SAAS,KAAK;AACZ,UAAM,MACJ,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AACjD,UAAM,IAAI;AAAA,MACR,wCAAwC,eAAe,KAAK,GAAG;AAAA,IACjE;AAAA,EACF;AACA,QAAM,SAAS,MAAM,GAAG;AACxB,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,IAAI;AAAA,MACR,4BAA4B,eAAe;AAAA,IAC7C;AAAA,EACF;AACA,MAAI,OAAO,YAAY,GAAG;AACxB,UAAM,IAAI;AAAA,MACR,4BAA4B,eAAe,kCAAkC,OAAO,OAAO;AAAA,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KAAK;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,SAAS,OAAO,CAAC,MAAM,EAAE,aAAa,OAAO;AAC5D,QAAM,QAAQ,SAAS,OAAO,CAAC,MAAM,EAAE,aAAa,MAAM;AAE1D,aAAW,KAAK,MAAO,QAAO,KAAK,GAAGA,IAAG,IAAI,EAAE,OAAO,EAAE;AAExD,MAAI,OAAO,SAAS,GAAG;AACrB,UAAM,UAAU;AAAA,MACd,GAAGA,IAAG,2BAA2B,eAAe,UAAU,GAAG;AAAA,MAC7D,GAAG,OAAO,MAAM;AAAA,MAChB,GAAG,OAAO,IAAI,CAAC,MAAM,OAAO,EAAE,OAAO,EAAE;AAAA,IACzC,EAAE,KAAK,IAAI;AAEX,QAAI,KAAK,eAAgB,OAAM,IAAI,MAAM,OAAO;AAChD,WAAO,MAAM,OAAO;AACpB,SAAK,CAAC;AAAA,EACR;AAEA,SAAO,EAAE,IAAI,OAAO,WAAW,GAAG,SAAS;AAC7C;","names":["TAG"]}
|
|
@@ -1674,7 +1674,7 @@ type CVC136Option = {
|
|
|
1674
1674
|
categoryLabel: string;
|
|
1675
1675
|
};
|
|
1676
1676
|
declare const CVC_136_OPTIONS: readonly CVC136Option[];
|
|
1677
|
-
declare const CVC_136_CORE_INDICATOR_VALUES: readonly ["abuser_evading_legal_consequences", "abuser_has_weapon", "abuser_substance_use", "abuser_threatened_suicide", "abuser_unemployed", "access_to_vulnerable_individuals", "acknowledgement_or_report_of_human_trafficking", "ads_available_247", "ads_imply_multiple_workers", "ads_prost_slang", "adverse_childhood_household_challenges", "advertised_new_to_area", "appears_controlling_relationship", "appears_turned_out_or_trained_ad_patterns", "association_commercial_sex", "atypical_or_high_risk_payment_method", "autonomy_access_healthcare_without_fear", "autonomy_choice_in_clients", "autonomy_choice_in_services", "autonomy_controls_own_docs", "autonomy_controls_own_finances", "autonomy_organizes_own_travel", "autonomy_posts_own_ads", "autonomy_sets_own_schedule", "autonomy_sets_up_own_dates", "battered_while_pregnant_history", "branding_or_unusual_tattoos_tied_to_control", "cannot_stop_working_or_freely_leave", "child_not_abusers_in_household", "child_welfare_system_involvement", "coerced_to_misrepresent_identity_or_activity", "coercive_debt_pressure", "coercive_debt_pressure_youth", "coercive_migration_or_forced_travel", "cognitive_or_functional_impairment_affecting_consent", "commercial_sex_association_words_or_places", "concerning_mannerisms_anxious_fearful_depressed", "concerning_sexual_behavior_pattern", "constraints_due_to_legal_status", "control_quota_required", "cs_activity_criminal_org_connection", "cs_industry_related_criminal_history", "current_injuries_from_abuser", "current_mental_health_services", "currently_minor_in_commercial_sex", "dangerous_services_no_protection", "dangerous_services_requires_protection", "dangerous_services_willing_anything", "debt_terms_deceptive", "debt_terms_deceptive_youth", "denied_basic_needs", "depends_on_employer_for_immigration_status", "does_not_control_finances_or_earnings", "does_not_control_identity_documents", "elevated_lethality_risk_signal", "employer_keeps_pay_or_pays_less_than_expected", "engages_in_commercial_sex_act", "entered_commercial_sex_industry_as_minor", "entered_cs_due_to_survival_needs", "entered_into_network_of_sex_providers_early", "exploitative_pricing_tier_low", "exploitative_working_conditions", "fled_conflict_violence_or_persecution", "forced_to_commit_crimes", "forced_to_use_false_documents", "foreign_born_or_recently_arrived", "foreign_born_risk_factors", "frequent_changes_in_residence", "frequent_travel_or_location_changes", "frequently_at_hotels_or_many_hotel_keys", "harmful_coping_behaviors", "has_ads_on_commercial_sex_site", "has_facilitators_involved", "has_management_or_representation", "has_no_personal_items_or_possessions", "head_injury_history", "head_injury_loss_of_consciousness", "health_related_vulnerability", "hierarchical_management_structure_identified", "high_risk_sexual_behavior", "high_security_measures_at_work_or_living_location", "highly_irregular_school_attendance", "history_emotional_abuse", "history_of_head_injury", "history_of_mental_health_issues", "history_of_running_away_or_missing_from_care", "history_of_strangulation", "history_physical_or_sexual_abuse_or_dv", "homeless_or_unstably_housed", "immigration_related_exploitation_risk", "in_commercial_sex_industry_recorded", "inability_to_account_for_self", "intimate_partner_violence_reported_to_law_enforcement", "juvenile_justice_or_child_welfare_involvement", "juvenile_justice_system_involvement", "labor_services_activity_recorded", "lgbtq_individual", "limited_english_proficiency", "limited_independence", "lives_or_sleeps_at_place_of_work", "living_with_abuser", "macro_level_economic_duress_entry_exit", "meets_or_has_sex_with_internet_contacts", "monitored_or_isolated_by_controlling_party", "much_older_intimate_partner", "nervous_about_immigration_documentation", "network_aggregate_risk_score_high", "network_multiple_sex_providers_named", "network_stable_size_large", "network_trafficker_present", "network_violent_person_present", "new_to_commercial_sex_industry", "non_consensual_photography_or_recording", "not_in_control_of_immigration_documentation", "other_instability_or_vulnerability_factors", "owes_money_and_cannot_pay_off", "paid_or_owes_fee_to_arrange_travel_to_us", "paid_or_owes_recruitment_fee_to_employer", "parent_or_guardian_of_minor_subject_named", "past_phases_prior_trafficking_or_risk", "payment_routed_through_third_party", "pending_federal_protection", "performing_different_work_than_promised", "physical_violence_increasing", "poverty_or_severe_financial_strain", "precarious_immigration_status", "pressured_or_forced_sex_act", "prior_medical_attention_from_abuse", "prior_tvap_disconnection", "prior_victimization_or_abuse_history", "promise_of_work_different_than_current_work", "received_things_of_value_while_missing_from_care", "recent_le_engagement", "recruited_by_third_party_into_cs_industry", "regular_alcohol_use", "relies_on_temporary_resources_for_basic_needs", "reports_physical_harm_by_employer_or_partner", "reports_physical_harm_to_others_by_employer_or_partner", "restrictive_living_or_working_conditions", "restrictive_or_not_understood_contract", "risk_factors_commercial_sex", "serious_substance_use_or_introduced_to_drugs", "several_cell_phones_or_frequent_number_changes", "sex_acts_in_own_residence", "sexual_exploitation", "sexualized_content_performance_activity", "shared_contact_network", "signs_of_physical_abuse_confinement_or_neglect", "signs_of_physical_harm_or_abuse", "sleep_disturbance", "social_isolation_or_no_supportive_relationships", "stalking_property_intrusion", "stalking_surveillance", "stalking_unwanted_contact", "strangulation_acute_symptoms", "strangulation_choking_assault_detail", "strangulation_loss_of_consciousness", "strangulation_repeated", "subject_affiliated_org_trafficking_activity", "subject_arrested_dv_sv_cs", "subject_gang_org_affiliation", "subject_has_illegal_weapons", "subject_is_sex_offender", "subject_legally_barred_weapons", "subject_perpetrated_abuse_history", "subject_perpetrated_emotional_stalking_current", "subject_perpetrated_emotional_stalking_past", "subject_perpetrated_ipv_current", "subject_perpetrated_ipv_past", "subject_perpetrated_physical_abuse_current", "subject_perpetrated_physical_abuse_past", "subject_perpetrated_sexual_abuse_current", "subject_perpetrated_sexual_abuse_past", "subject_violent_felony", "substance_use_while_working", "suicidal_ideation_history", "suicidal_ideation_recent", "suicide_attempt_history", "third_party_advertises_or_posts_for_person", "third_party_arranged_commercial_sex_acts", "threats_by_employer_or_partner", "threats_of_harm", "threats_of_legal_trouble_or_deportation", "threats_related_to_migration_debt", "threats_to_family_friends_or_close_associates", "threats_to_kill_victim_or_children", "trafficking_experience_current", "trafficking_experience_past_10plusy", "trafficking_experience_past_3to10y", "trafficking_experience_past_lt3y", "travel_organized_by_third_party", "tricked_or_pressured_into_unwanted_acts", "under_18_advertised_age", "under_18_appears_underage", "under_18_known_age", "unexplained_frequent_travel_or_migration", "unsafe_working_conditions_long_hours_inadequate_breaks", "unusual_cash_or_unexplained_gifts", "unusual_work_circumstances", "urgent_medical_referral_needed", "victim_believes_abuser_capable_of_killing", "victimization_history_composite", "violence_or_threats_at_work_site", "weapon_used_or_threatened_against_victim", "work_frequency_high_volume", "working_while_pregnant", "workplace_emotional_climate_of_fear", "works_across_multiple_cities_or_locations", "works_for_little_or_no_pay", "youth_watched_filmed_or_photographed_sexually_explicit"];
|
|
1677
|
+
declare const CVC_136_CORE_INDICATOR_VALUES: readonly ["abuser_evading_legal_consequences", "abuser_has_weapon", "abuser_substance_use", "abuser_threatened_suicide", "abuser_unemployed", "access_to_vulnerable_individuals", "acknowledgement_or_report_of_human_trafficking", "ads_available_247", "ads_imply_multiple_workers", "ads_prost_slang", "adverse_childhood_household_challenges", "advertised_new_to_area", "appears_controlling_relationship", "appears_turned_out_or_trained_ad_patterns", "association_commercial_sex", "atypical_or_high_risk_payment_method", "autonomy_access_healthcare_without_fear", "autonomy_choice_in_clients", "autonomy_choice_in_services", "autonomy_controls_own_docs", "autonomy_controls_own_finances", "autonomy_organizes_own_travel", "autonomy_posts_own_ads", "autonomy_sets_own_schedule", "autonomy_sets_up_own_dates", "battered_while_pregnant_history", "branding_or_unusual_tattoos_tied_to_control", "cannot_stop_working_or_freely_leave", "child_not_abusers_in_household", "child_welfare_system_involvement", "clients_unaware_of_third_party_coordination", "coerced_to_misrepresent_identity_or_activity", "coercive_debt_pressure", "coercive_debt_pressure_youth", "coercive_migration_or_forced_travel", "cognitive_or_functional_impairment_affecting_consent", "commercial_sex_association_words_or_places", "concerning_mannerisms_anxious_fearful_depressed", "concerning_sexual_behavior_pattern", "constraints_due_to_legal_status", "control_quota_required", "cs_activity_criminal_org_connection", "cs_industry_related_criminal_history", "current_injuries_from_abuser", "current_mental_health_services", "currently_minor_in_commercial_sex", "dangerous_services_no_protection", "dangerous_services_requires_protection", "dangerous_services_willing_anything", "debt_terms_deceptive", "debt_terms_deceptive_youth", "denied_basic_needs", "depends_on_employer_for_immigration_status", "depends_on_spouse_or_family_for_immigration_status", "does_not_control_finances_or_earnings", "does_not_control_identity_documents", "elevated_lethality_risk_signal", "employer_keeps_pay_or_pays_less_than_expected", "engages_in_commercial_sex_act", "entered_commercial_sex_industry_as_minor", "entered_cs_due_to_survival_needs", "entered_into_network_of_sex_providers_early", "exploitative_pricing_tier_low", "exploitative_working_conditions", "fled_conflict_violence_or_persecution", "forced_to_commit_crimes", "forced_to_use_false_documents", "foreign_born_or_recently_arrived", "foreign_born_risk_factors", "frequent_changes_in_residence", "frequent_travel_or_location_changes", "frequently_at_hotels_or_many_hotel_keys", "harmful_coping_behaviors", "has_ads_on_commercial_sex_site", "has_facilitators_involved", "has_management_or_representation", "has_no_personal_items_or_possessions", "head_injury_history", "head_injury_loss_of_consciousness", "health_related_vulnerability", "hierarchical_management_structure_identified", "high_risk_sexual_behavior", "high_security_measures_at_work_or_living_location", "highly_irregular_school_attendance", "history_emotional_abuse", "history_of_head_injury", "history_of_mental_health_issues", "history_of_running_away_or_missing_from_care", "history_of_strangulation", "history_physical_or_sexual_abuse_or_dv", "homeless_or_unstably_housed", "immigration_related_exploitation_risk", "in_commercial_sex_industry_recorded", "inability_to_account_for_self", "intimate_partner_violence_reported_to_law_enforcement", "juvenile_justice_or_child_welfare_involvement", "juvenile_justice_system_involvement", "labor_services_activity_recorded", "lgbtq_individual", "limited_english_proficiency", "limited_independence", "lives_or_sleeps_at_place_of_work", "living_with_abuser", "macro_level_economic_duress_entry_exit", "meets_or_has_sex_with_internet_contacts", "monitored_or_isolated_by_controlling_party", "much_older_intimate_partner", "nervous_about_immigration_documentation", "network_aggregate_risk_score_high", "network_multiple_sex_providers_named", "network_stable_size_large", "network_trafficker_present", "network_violent_person_present", "new_to_commercial_sex_industry", "non_consensual_photography_or_recording", "not_in_control_of_immigration_documentation", "other_instability_or_vulnerability_factors", "owes_money_and_cannot_pay_off", "paid_or_owes_fee_to_arrange_travel_to_us", "paid_or_owes_recruitment_fee_to_employer", "parent_or_guardian_of_minor_subject_named", "past_phases_prior_trafficking_or_risk", "payment_routed_through_third_party", "pending_federal_protection", "performing_different_work_than_promised", "physical_violence_increasing", "poverty_or_severe_financial_strain", "precarious_immigration_status", "pressured_or_forced_sex_act", "prior_medical_attention_from_abuse", "prior_tvap_disconnection", "prior_victimization_or_abuse_history", "promise_of_work_different_than_current_work", "received_things_of_value_while_missing_from_care", "recent_le_engagement", "recruited_by_third_party_into_cs_industry", "regular_alcohol_use", "relies_on_temporary_resources_for_basic_needs", "reports_physical_harm_by_employer_or_partner", "reports_physical_harm_to_others_by_employer_or_partner", "restrictive_living_or_working_conditions", "restrictive_or_not_understood_contract", "risk_factors_commercial_sex", "serious_substance_use_or_introduced_to_drugs", "several_cell_phones_or_frequent_number_changes", "sex_acts_in_own_residence", "sexual_exploitation", "sexualized_content_in_person_performance_activity", "sexualized_content_online_performance_activity", "sexualized_content_performance_activity", "shared_contact_network", "signs_of_physical_abuse_confinement_or_neglect", "signs_of_physical_harm_or_abuse", "sleep_disturbance", "social_isolation_or_no_supportive_relationships", "stalking_property_intrusion", "stalking_surveillance", "stalking_unwanted_contact", "strangulation_acute_symptoms", "strangulation_choking_assault_detail", "strangulation_loss_of_consciousness", "strangulation_repeated", "subject_affiliated_org_trafficking_activity", "subject_arrested_dv_sv_cs", "subject_gang_org_affiliation", "subject_has_illegal_weapons", "subject_is_sex_offender", "subject_legally_barred_weapons", "subject_perpetrated_abuse_history", "subject_perpetrated_emotional_stalking_current", "subject_perpetrated_emotional_stalking_past", "subject_perpetrated_ipv_current", "subject_perpetrated_ipv_past", "subject_perpetrated_physical_abuse_current", "subject_perpetrated_physical_abuse_past", "subject_perpetrated_sexual_abuse_current", "subject_perpetrated_sexual_abuse_past", "subject_violent_felony", "substance_use_while_working", "suicidal_ideation_history", "suicidal_ideation_recent", "suicide_attempt_history", "third_party_advertises_or_posts_for_person", "third_party_arranged_commercial_sex_acts", "threats_by_employer_or_partner", "threats_of_harm", "threats_of_legal_trouble_or_deportation", "threats_related_to_migration_debt", "threats_to_family_friends_or_close_associates", "threats_to_kill_victim_or_children", "trafficking_experience_current", "trafficking_experience_past_10plusy", "trafficking_experience_past_3to10y", "trafficking_experience_past_lt3y", "trauma_perpetrator_is_current_manager", "travel_organized_by_third_party", "tricked_or_pressured_into_unwanted_acts", "under_18_advertised_age", "under_18_appears_underage", "under_18_known_age", "unexplained_frequent_travel_or_migration", "unsafe_working_conditions_long_hours_inadequate_breaks", "unusual_cash_or_unexplained_gifts", "unusual_work_circumstances", "urgent_medical_referral_needed", "victim_believes_abuser_capable_of_killing", "victimization_history_composite", "violence_or_threats_at_work_site", "weapon_used_or_threatened_against_victim", "work_frequency_high_volume", "working_while_pregnant", "workplace_emotional_climate_of_fear", "works_across_multiple_cities_or_locations", "works_for_little_or_no_pay", "youth_watched_filmed_or_photographed_sexually_explicit"];
|
|
1678
1678
|
type CVC136CoreIndicator = (typeof CVC_136_CORE_INDICATOR_VALUES)[number];
|
|
1679
1679
|
declare const CVC_136_CORE_INDICATOR_LABELS: Record<CVC136CoreIndicator, string>;
|
|
1680
1680
|
declare const CVC_67_HMIS_SEX: {
|
|
@@ -1766,4 +1766,4 @@ type FunctionStatusValue = (typeof FUNCTION_STATUS)[keyof typeof FUNCTION_STATUS
|
|
|
1766
1766
|
declare const FUNCTION_STATUS_VALUES: readonly ["Not started", "Defined; new function", "Defined; existing PAVE function", "Functional on all apps", "Future function (not v1)"];
|
|
1767
1767
|
declare const FUNCTION_STATUS_LABELS: Record<FunctionStatusValue, string>;
|
|
1768
1768
|
|
|
1769
|
-
export { type
|
|
1769
|
+
export { type BirthLocationValue as $, type AccommodationValue as A, type QuickStartTemplateId as B, type RecordStateValue as C, type DataQualityValue as D, type RelationshipConcernValue as E, type FunctionStatusValue as F, type RelationshipDynamicValue as G, type SessionStateValue as H, type IC13Category as I, type SubmissionStateValue as J, ACCOMMODATION_LABELS as K, ACCOMMODATION_OPTIONS as L, type MinorAdultStatusValue as M, AGE_BIN_REPORTING as N, AGE_BIN_REPORTING_IS_MINOR as O, type PlatformToolValue as P, type QuestionFormatValue as Q, type RoleLevelValue as R, type ShareViewValue as S, AGE_BIN_REPORTING_LABELS as T, type UserStatusValue as U, APPARENT_AGE as V, APPARENT_AGE_LABELS as W, APP_SCOPE as X, BIRTH_LOCATION as Y, BIRTH_LOCATION_LABELS as Z, BIRTH_LOCATION_VALUES as _, type PermissionStateValue as a, CVC_126_LABELS as a$, CALLER_IS_VICTIM_ROLES as a0, type CVC100Value as a1, type CVC115Value as a2, type CVC120Value as a3, type CVC121Value as a4, type CVC122Value as a5, type CVC126Category as a6, type CVC126Option as a7, type CVC126Value as a8, type CVC136Category as a9, type CVC1Value as aA, type CVC67Value as aB, type CVC72Value as aC, type CVC76Value as aD, type CVC93Value as aE, type CVC95Value as aF, type CVC96Value as aG, type CVC97Value as aH, type CVC98Value as aI, type CVC99Value as aJ, CVC_100_LABELS as aK, CVC_100_LIVES_RURAL as aL, CVC_100_VALUES as aM, CVC_115_LABELS as aN, CVC_115_SERVICE_PLANNING as aO, CVC_115_VALUES as aP, CVC_120_LABELS as aQ, CVC_120_MILITARY_BRANCH as aR, CVC_120_VALUES as aS, CVC_121_LABELS as aT, CVC_121_MILITARY_STATUS as aU, CVC_121_VALUES as aV, CVC_122_LABELS as aW, CVC_122_PRIMARY_LANGUAGE as aX, CVC_122_VALUES as aY, CVC_126_CATEGORY as aZ, CVC_126_CATEGORY_LABELS as a_, type CVC136CoreIndicator as aa, type CVC136Option as ab, type CVC136Value as ac, type CVC145Category as ad, type CVC145Option as ae, type CVC145Value as af, type CVC147Value as ag, type CVC148Value as ah, type CVC150Value as ai, type CVC151Value as aj, type CVC152Value as ak, type CVC153Value as al, type CVC156Value as am, type CVC157Value as an, type CVC15Value as ao, type CVC16Value as ap, type CVC171Category as aq, type CVC171Option as ar, type CVC171Value as as, type CVC179HierarchicalCategory as at, type CVC179HierarchicalValue as au, type CVC179Value as av, type CVC17Value as aw, type CVC180Value as ax, type CVC181Value as ay, type CVC196Value as az, type AgeBinReportingValue as b, CVC_179_CHILD_TO_PARENT as b$, CVC_126_OPTIONS as b0, CVC_126_PERSON_RELATIONSHIP as b1, CVC_126_PROTECTED_CATEGORIES as b2, CVC_126_TYPE_TO_CATEGORY as b3, CVC_126_VALUES as b4, CVC_136_ALERT_INDICATOR as b5, CVC_136_CATEGORY_LABELS as b6, CVC_136_CORE_INDICATOR_LABELS as b7, CVC_136_CORE_INDICATOR_VALUES as b8, CVC_136_INDICATOR_CATEGORY as b9, CVC_152_LABELS as bA, CVC_152_VALUES as bB, CVC_153_LABELS as bC, CVC_153_SMT_TYPE as bD, CVC_153_VALUES as bE, CVC_156_LABELS as bF, CVC_156_MARITAL_STATUS as bG, CVC_156_VALUES as bH, CVC_157_LABELS as bI, CVC_157_RELATIONSHIP_STATUS as bJ, CVC_157_VALUES as bK, CVC_15_CORE_SEX as bL, CVC_15_LABELS as bM, CVC_15_SELECTABLE_VALUES as bN, CVC_16_CORE_ORIENTATION as bO, CVC_16_LABELS as bP, CVC_16_LGBTQ_VALUES as bQ, CVC_171_CATEGORY as bR, CVC_171_CATEGORY_LABELS as bS, CVC_171_CHILD_TO_PARENT as bT, CVC_171_INCOME_BENEFITS as bU, CVC_171_INCOME_SOURCES as bV, CVC_171_LABELS as bW, CVC_171_PARENT_CHILDREN as bX, CVC_171_SELECTABLE_OPTIONS as bY, CVC_171_VALUES as bZ, CVC_171_VALUE_TO_CATEGORY as b_, CVC_136_LABELS as ba, CVC_136_OPTIONS as bb, CVC_136_TYPE_TO_CATEGORY as bc, CVC_136_VALUES as bd, CVC_145_CATEGORY as be, CVC_145_CATEGORY_LABELS as bf, CVC_145_CATEGORY_ORDER as bg, CVC_145_LABELS as bh, CVC_145_OPTIONS as bi, CVC_145_RELATIONSHIP_DYNAMICS as bj, CVC_145_SELECTABLE_OPTIONS as bk, CVC_145_TYPE_TO_CATEGORY as bl, CVC_145_VALUES as bm, CVC_147_LABELS as bn, CVC_147_PRONOUNS as bo, CVC_147_VALUES as bp, CVC_148_LABELS as bq, CVC_148_TRIBES as br, CVC_148_VALUES as bs, CVC_150_EYE_COLOR as bt, CVC_150_LABELS as bu, CVC_150_VALUES as bv, CVC_151_HAIR_COLOR as bw, CVC_151_LABELS as bx, CVC_151_VALUES as by, CVC_152_HAS_TATTOOS as bz, type AppScopeValue as c, DATA_QUALITY_VALUES as c$, CVC_179_EMPLOYMENT_STATUS as c0, CVC_179_HIERARCHICAL_CATEGORY as c1, CVC_179_HIERARCHICAL_CATEGORY_LABELS as c2, CVC_179_HIERARCHICAL_CATEGORY_ORDER as c3, CVC_179_HIERARCHICAL_LABELS as c4, CVC_179_HIERARCHICAL_VALUES as c5, CVC_179_LABELS as c6, CVC_179_PARENT_CHILDREN as c7, CVC_179_PRIMARY_CATEGORY as c8, CVC_179_SELECTABLE_OPTIONS as c9, CVC_72_HT_TYPE as cA, CVC_72_LABELS as cB, CVC_72_VALUES as cC, CVC_76_LABELS as cD, CVC_76_RACE_ETHNICITY as cE, CVC_76_VALUES as cF, CVC_93_CHILD_WELFARE_INVOLVEMENT as cG, CVC_93_LABELS as cH, CVC_93_VALUES as cI, CVC_95_JUVENILE_JUSTICE_INVOLVEMENT as cJ, CVC_95_LABELS as cK, CVC_95_VALUES as cL, CVC_96_HOMELESS_STATUS as cM, CVC_96_LABELS as cN, CVC_96_VALUES as cO, CVC_97_IMMIGRANT_REFUGEE as cP, CVC_97_LABELS as cQ, CVC_97_VALUES as cR, CVC_98_LABELS as cS, CVC_98_US_VETERAN as cT, CVC_98_VALUES as cU, CVC_99_ENGLISH_PROFICIENCY as cV, CVC_99_LABELS as cW, CVC_99_VALUES as cX, DATA_QUALITY as cY, DATA_QUALITY_DESCRIPTIONS as cZ, DATA_QUALITY_LABELS as c_, CVC_179_VALUES as ca, CVC_179_VALUE_TO_CATEGORY as cb, CVC_17_CORE_GENDER_IDENTITY as cc, CVC_17_LABELS as cd, CVC_17_LEVEL_0_MISSINGNESS_OPTIONS as ce, CVC_17_LEVEL_1_OPTIONS as cf, CVC_17_LEVEL_2_TRANSGENDER_OPTIONS as cg, CVC_17_TRANSGENDER_VALUES as ch, CVC_180_EDUCATION_LEVEL as ci, CVC_180_LABELS as cj, CVC_180_ORDINAL as ck, CVC_180_VALUES as cl, CVC_181_COUNTRIES as cm, CVC_181_LABELS as cn, CVC_196_CHILD_WELFARE_EPISODE_TYPE as co, CVC_196_LABELS as cp, CVC_196_VALUES as cq, CVC_1_LABELS as cr, CVC_1_NAME_TYPE as cs, CVC_1_STRUCTURED_NAME_TYPES as ct, CVC_1_UNSTRUCTURED_NAME_TYPES as cu, CVC_1_VALUES as cv, CVC_67_HMIS_SEX as cw, CVC_67_LABELS as cx, CVC_67_MISSINGNESS_VALUES as cy, CVC_67_SELECTABLE_VALUES as cz, type ApparentAgeValue as d, MINOR_ADULT_STATUS as d$, DEFAULT_PARTICIPATION_ROLE_BY_CATEGORY as d0, FORM_STATUS as d1, FORM_STATUS_LABELS as d2, FORM_TYPE as d3, FORM_TYPE_LABELS as d4, FUNCTION_STATUS as d5, FUNCTION_STATUS_LABELS as d6, FUNCTION_STATUS_VALUES as d7, type IC13PriorityGroup as d8, type IC56ChannelValue as d9, IC_4_LABELS as dA, IC_56_DESCRIPTIONS as dB, IC_56_LABELS as dC, IC_56_OPTIONS as dD, IC_56_PROVISIONAL_CHANNELS as dE, IC_56_SERVICE_DELIVERY_CHANNEL as dF, IC_57_LABELS as dG, IC_57_SERVICE_AUDIENCE as dH, IC_58_EXTERNAL_TIERED as dI, IC_58_LABELS as dJ, IC_58_ORG_TYPE_GROUPS as dK, IC_58_PRIMARY_BRANCHES as dL, IC_58_REFERRAL_ENTITY as dM, IC_59_LABELS as dN, IC_59_SERVICE_STATE as dO, IC_5_FULL_LABELS as dP, IC_5_LABELS as dQ, IC_5_VICTIMIZATION as dR, INCIDENT_INVOLVEMENT_ROLE as dS, INCIDENT_INVOLVEMENT_ROLE_LABELS as dT, INCIDENT_INVOLVEMENT_ROLE_TO_PERSON_ROLE as dU, INCIDENT_PARTICIPATION_ROLE as dV, INCIDENT_PARTICIPATION_ROLE_LABELS as dW, INCIDENT_PARTICIPATION_ROLE_VALUES as dX, INTERACTION_TYPES as dY, INTERACTION_TYPE_LABELS as dZ, INVOLVEMENT_ROLE_TO_PERSON_TYPE as d_, type IC58ExternalCategory as da, IC_13_CATEGORIES as db, IC_13_CATEGORY_ORDER as dc, IC_13_LABELS as dd, IC_13_PRIORITY_GROUPS as de, IC_13_RELATIONSHIP_ABBREV as df, IC_13_RELATIONSHIP_TYPE as dg, IC_13_REVERSE_CONTEXT_LABELS as dh, IC_22_CORE_SEX as di, IC_22_LABELS as dj, IC_23_CORE_GENDER_IDENTITY as dk, IC_23_LABELS as dl, IC_24_LABELS as dm, IC_24_RACE as dn, IC_25_ETHNICITY as dp, IC_25_LABELS as dq, IC_48_SERVICE_CATEGORIES as dr, IC_49_DESCRIPTIONS as ds, IC_49_LABELS as dt, IC_49_REFERRAL_OUTCOME as du, IC_49_REFERRAL_OUTCOME_LABELS as dv, IC_49_REFERRAL_VERIFICATION as dw, IC_49_REFERRAL_VERIFICATION_LABELS as dx, IC_49_SERVICE_MECHANISM as dy, IC_4_AGE_TYPE as dz, type FormStatusValue as e, MINOR_ADULT_STATUS_LABELS as e0, type OrgTypeGroup as e1, PARTICIPATION_ROLE_CATEGORIES as e2, PERMISSION_STATE as e3, PERMISSION_STATE_DISPLAY as e4, PERMISSION_STATE_LABELS as e5, PERMISSION_STATE_VALUES as e6, PERSON_DISPLAY_CATEGORY as e7, PERSON_DISPLAY_CATEGORY_LABELS as e8, PERSON_ROLES as e9, SHARE_VIEW_VALUES as eA, SUBMISSION_STATES as eB, SUBMISSION_STATE_LABELS as eC, type ServiceCategory as eD, type ServiceCategoryChild as eE, THREAD_INVOLVEMENT_ROLES as eF, USER_STATUS as eG, USER_STATUS_LABELS as eH, VALID_INTERACTION_TYPES as eI, VALID_RECORD_STATES as eJ, deriveAgeBinFromAge as eK, getDisplayCategoryForRole as eL, getPersonTypeForRole as eM, getRelationshipCategory as eN, isIC56Missingness as eO, isIC56ValidChannel as eP, isLgbtqOrientation as eQ, isProtectedRelationship as eR, isStructuredNameType as eS, isTransgenderGenderIdentity as eT, sortRelationshipsByPriority as eU, PERSON_TYPE as ea, PERSON_TYPE_VALUES as eb, PLATFORM_TOOL as ec, PLATFORM_TOOL_LABELS as ed, PLATFORM_TOOL_VALUES as ee, QUESTION_FORMAT as ef, QUESTION_FORMAT_LABELS as eg, QUICK_START_CONFIG as eh, QUICK_START_LABELS as ei, QUICK_START_TEMPLATES as ej, RECORD_STATES as ek, RECORD_STATE_LABELS as el, RELATIONSHIP_CONCERNS as em, RELATIONSHIP_CONCERNS_LABELS as en, RELATIONSHIP_CONCERNS_VALUES as eo, RELATIONSHIP_DYNAMICS as ep, RELATIONSHIP_DYNAMICS_LABELS as eq, RELATIONSHIP_DYNAMICS_VALUES as er, ROLE_LEVEL as es, ROLE_LEVEL_LABELS as et, ROLE_LEVEL_VALUES as eu, type ReferralBranch as ev, SESSION_STATES as ew, SESSION_STATE_LABELS as ex, SHARE_VIEW as ey, SHARE_VIEW_LABELS as ez, type FormTypeValue as f, type IC13Value as g, type IC22Value as h, type IC23Value as i, type IC24Value as j, type IC25Value as k, type IC49ReferralOutcomeValue as l, type IC49ReferralVerificationValue as m, type IC49Value as n, type IC4Value as o, type IC56Value as p, type IC57Value as q, type IC58Value as r, type IC59Value as s, type IC5Value as t, type IncidentInvolvementRoleValue as u, type IncidentParticipationRoleValue as v, type InteractionTypeValue as w, type PersonDisplayCategoryValue as x, type PersonRoleValue as y, type PersonTypeValue as z };
|