@htilabs/platform-common-models 0.8.17 → 0.8.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/constants/index.cjs.map +1 -1
  2. package/dist/constants/index.js.map +1 -1
  3. package/dist/cvcs/index.cjs +4346 -21
  4. package/dist/cvcs/index.cjs.map +1 -1
  5. package/dist/cvcs/index.d.cts +6683 -2020
  6. package/dist/cvcs/index.d.ts +6683 -2020
  7. package/dist/cvcs/index.js +4344 -21
  8. package/dist/cvcs/index.js.map +1 -1
  9. package/dist/{index-C0J3f169.d.ts → index-4DiJrn7y.d.ts} +1 -1
  10. package/dist/{index-EPjPjR0z.d.cts → index-qreOzXYS.d.cts} +1 -1
  11. package/dist/index.cjs +4681 -32
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +350 -18
  14. package/dist/index.d.ts +350 -18
  15. package/dist/index.js +4677 -32
  16. package/dist/index.js.map +1 -1
  17. package/dist/models/index.d.cts +2 -2
  18. package/dist/models/index.d.ts +2 -2
  19. package/dist/schemas/index.cjs.map +1 -1
  20. package/dist/schemas/index.d.cts +25 -25
  21. package/dist/schemas/index.d.ts +25 -25
  22. package/dist/schemas/index.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/__sot__/README.md +36 -1
  25. package/src/__sot__/coreIndicatorFields.ts +331 -0
  26. package/src/__sot__/coreIndicators.pin.json +1929 -1
  27. package/src/__sot__/cvcIndex.pin.json +8 -4
  28. package/src/__tests__/__snapshots__/cvc-sot.snap +11 -3
  29. package/src/__tests__/cvc-181-182-country-parity.test.ts +163 -0
  30. package/src/__tests__/cvc-drift-gate.test.ts +407 -12
  31. package/src/__tests__/cvc-sot-snapshot.test.ts +31 -3
  32. package/src/__tests__/cvc-structural.test.ts +8 -0
  33. package/src/constants/ic.ts +14 -0
  34. package/src/cvcs/countries.v1.0.0.json +3077 -0
  35. package/src/cvcs/determinationHelperCategories.v1.0.0.json +1166 -0
  36. package/src/cvcs/index.ts +4 -0
  37. package/src/cvcs/personRelationships.v1.0.0.json +67 -2
  38. package/src/cvcs/relationshipConcern.v1.0.0.json +28 -19
  39. package/src/generated/cvc-enums.ts +350 -14
  40. package/dist/{cvcEntry-DaDrEuTa.d.cts → cvcEntry-ctHTp2df.d.cts} +8 -8
  41. package/dist/{cvcEntry-DaDrEuTa.d.ts → cvcEntry-ctHTp2df.d.ts} +8 -8
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sourceRepo": "htilabstech/prototype",
3
3
  "sourceFile": "Final CVCs/CVC_INDEX.md",
4
- "sourceSha": "a596eb9",
4
+ "sourceSha": "622410b",
5
5
  "numbers": {
6
6
  "1": [
7
7
  "core - name_type"
@@ -59,6 +59,12 @@
59
59
  "85": [
60
60
  "core - share_cadence"
61
61
  ],
62
+ "93": [
63
+ "core - child_welfare_involvement_status"
64
+ ],
65
+ "95": [
66
+ "core - juvenile_justice_involvement_status"
67
+ ],
62
68
  "96": [
63
69
  "core - homeless_status"
64
70
  ],
@@ -187,7 +193,6 @@
187
193
  "core - frequency : cadence"
188
194
  ],
189
195
  "177": [
190
- "core - administering jurisdiction",
191
196
  "core - administering_jurisdiction"
192
197
  ],
193
198
  "179": [
@@ -219,8 +224,7 @@
219
224
  "core collection context"
220
225
  ],
221
226
  "196": [
222
- "core child welfare cvc",
223
- "core child welfare episode type CVC"
227
+ "core - child_welfare_episode_type"
224
228
  ],
225
229
  "197": [
226
230
  "core - juvenile_justice_episode_type"
@@ -147,8 +147,8 @@
147
147
  "hash": "29fb041c4d1b40260e4a448a0501eb580d29606479628a6807a833b52212f3c3"
148
148
  },
149
149
  "person_relationships": {
150
- "count": 89,
151
- "hash": "f901a60ec1f275e2f003d1f1f2f94f2a3ae07d7badee227d650c28c00a1510bb"
150
+ "count": 94,
151
+ "hash": "15b9d1989b897723881cdb489026fab9c42eb9fe0b809f349ec027e42ca7b154"
152
152
  },
153
153
  "employment_status": {
154
154
  "count": 29,
@@ -500,7 +500,7 @@
500
500
  },
501
501
  "relationship_concern": {
502
502
  "count": 11,
503
- "hash": "03e18352e1ffb13a4e9b63e1f4043923f1da7e0153649db6940d0bb2653917d8"
503
+ "hash": "48e882447e87dd4342afc4c9b56aff3925f10177e7ea214dca5d5f66c09e5668"
504
504
  },
505
505
  "recency_band": {
506
506
  "count": 12,
@@ -666,6 +666,14 @@
666
666
  "count": 253,
667
667
  "hash": "83962425a6a987b46bd89f596feefe5758f25993137010bb417823b83c4ae31f"
668
668
  },
669
+ "countries": {
670
+ "count": 254,
671
+ "hash": "21525c56d5bac7f218bcb9a5dc048eea4b9132cfaf4a6a7439ebbf7dd34ebcde"
672
+ },
673
+ "determination_helper_categories": {
674
+ "count": 57,
675
+ "hash": "9e296ba8ae3a187171eb8facfd13a5e6824daa0ed7f963e41e31672104aa16c0"
676
+ },
669
677
  "trafficking_relevant_role": {
670
678
  "count": 8,
671
679
  "hash": "1a4ea2992cc501179adafd192d7a2f1733ffe48c1ba26e1e61a3c757b2d62b32"
@@ -0,0 +1,163 @@
1
+ /**
2
+ * CVC-181 `countries` <-> CVC-182 `citizenship` — the country-set parity lock
3
+ * ==========================================================================
4
+ *
5
+ * Two canonical codebooks enumerate the SAME 249 ISO 3166-1 countries:
6
+ *
7
+ * `core - countries` (CVC-181) the neutral entity list. Its own `.md` says it is
8
+ * "designed for use across multiple contexts (e.g.
9
+ * country of citizenship, country of origin, or
10
+ * country of residence)".
11
+ * `core - citizenship` (CVC-182) the citizenship-flavoured list, authored first
12
+ * (0.8.13) because CVC-181 was unpublished.
13
+ *
14
+ * Consumers bound to CVC-182 as a DRAFT stand-in for birth country must be able to
15
+ * re-point at CVC-181 as an import swap with **zero key renames** — that is the whole
16
+ * reason CVC-181 was minted from a key derivation identical to CVC-182's rather than a
17
+ * fresh one. This test is that promise, made falsifiable. If it fails, the re-point is
18
+ * a data migration, not an import swap, and every stored birth-country key is suspect.
19
+ *
20
+ * What it does NOT assert: positional-code parity. `181-NNN` and `182-NNN` disagree on
21
+ * 20 countries because the two upstream exports sort under different collations, and
22
+ * each domain is deliberately minted in ITS OWN codebook's row order so each stays
23
+ * reproducible from its own source. The KEY is the reconciliation axis (consumers
24
+ * persist keys, not wire codes). The last assertion below pins that divergence in place
25
+ * so nobody "fixes" it into a silent renumber, and so nobody writes
26
+ * `"181-" + code.slice(4)` believing the two are interchangeable.
27
+ */
28
+
29
+ import { readFileSync } from "node:fs";
30
+ import path from "node:path";
31
+ import { fileURLToPath } from "node:url";
32
+
33
+ import { describe, it, expect } from "vitest";
34
+
35
+ const here = path.dirname(fileURLToPath(import.meta.url));
36
+ const cvcDir = path.join(here, "..", "cvcs");
37
+
38
+ interface Entry {
39
+ code: string;
40
+ key: string;
41
+ title: string;
42
+ selectable: boolean;
43
+ definition: string | null;
44
+ iso31661Alpha2?: string | null;
45
+ priority?: boolean;
46
+ canonicalLabel?: string | null;
47
+ localExtension?: boolean;
48
+ }
49
+
50
+ const read = (f: string): { domain: string; entries: Entry[] } =>
51
+ JSON.parse(readFileSync(path.join(cvcDir, f), "utf8")) as {
52
+ domain: string;
53
+ entries: Entry[];
54
+ };
55
+
56
+ const countries = read("countries.v1.0.0.json");
57
+ const citizenship = read("citizenship.v1.0.0.json");
58
+
59
+ const isMissingness = (e: Entry): boolean => e.code.split("-")[1] === "000";
60
+ const substantive = (d: { entries: Entry[] }): Entry[] =>
61
+ d.entries.filter((e) => !isMissingness(e));
62
+
63
+ /** The 10 PRIORITY_COUNTRIES of the canonical prototype HTML, by ISO alpha-2. */
64
+ const PRIORITY_ISO = ["CN", "CU", "DO", "GT", "IN", "KR", "MX", "PH", "SV", "VN"];
65
+
66
+ describe("CVC-181 / CVC-182 country parity", () => {
67
+ it("both domains carry the identical 249 country key -> ISO map", () => {
68
+ const map = (d: { entries: Entry[] }): Record<string, string> =>
69
+ Object.fromEntries(
70
+ d.entries
71
+ .filter((e) => e.iso31661Alpha2)
72
+ .map((e) => [e.key, e.iso31661Alpha2!]),
73
+ );
74
+ const a = map(countries);
75
+ const b = map(citizenship);
76
+ expect(Object.keys(a).length, "CVC-181 ISO-coded leaves").toBe(249);
77
+ expect(Object.keys(b).length, "CVC-182 ISO-coded leaves").toBe(249);
78
+ expect(a).toEqual(b);
79
+ });
80
+
81
+ it("CVC-181 adds EXACTLY ONE substantive leaf over CVC-182: non_us_unspecified", () => {
82
+ const a = new Set(substantive(countries).map((e) => e.key));
83
+ const b = new Set(substantive(citizenship).map((e) => e.key));
84
+ const added = [...a].filter((k) => !b.has(k)).sort();
85
+ const dropped = [...b].filter((k) => !a.has(k)).sort();
86
+ expect(added, "substantive keys CVC-181 has that CVC-182 does not").toEqual([
87
+ "non_us_unspecified",
88
+ ]);
89
+ expect(dropped, "substantive keys CVC-182 has that CVC-181 does not").toEqual([]);
90
+ });
91
+
92
+ it("non_us_unspecified is a FLAGGED local extension, not a smuggled canonical value", () => {
93
+ // The escape hatch is guarded the way GATE B guards SCORING_AHEAD_OF_CATALOG:
94
+ // a codebook-absent leaf must announce itself, or the next verification run
95
+ // cannot tell an upstream gap from a platform-common invention.
96
+ const e = countries.entries.find((x) => x.key === "non_us_unspecified");
97
+ expect(e, "non_us_unspecified must exist").toBeDefined();
98
+ expect(e!.localExtension, "must carry localExtension: true").toBe(true);
99
+ expect(e!.definition ?? "").toMatch(/^LOCAL EXTENSION \(not in canonical CVC-181\)\./);
100
+ expect(e!.selectable).toBe(true);
101
+ expect(e!.iso31661Alpha2 ?? null, "a non-country leaf carries no ISO code").toBeNull();
102
+ // It is the ONLY local extension in this domain.
103
+ expect(countries.entries.filter((x) => x.localExtension).map((x) => x.key)).toEqual([
104
+ "non_us_unspecified",
105
+ ]);
106
+ });
107
+
108
+ it("CVC-181 priority flags are EXACTLY the canonical PRIORITY_COUNTRIES, and no sentinel", () => {
109
+ const flagged = countries.entries.filter((e) => e.priority);
110
+ expect(flagged.map((e) => e.iso31661Alpha2).sort()).toEqual([...PRIORITY_ISO].sort());
111
+ // CVC-182 additionally flags `unknown` + `anonymous` because ITS codebook has a
112
+ // Priority column that says Yes on those rows. CVC-181's codebook has no Priority
113
+ // column at all, and PRIORITY_COUNTRIES contains countries only — so flagging a
114
+ // sentinel here would be an invention. The COUNTRY flags must still agree.
115
+ expect(flagged.every((e) => !isMissingness(e)), "no missingness sentinel is priority").toBe(
116
+ true,
117
+ );
118
+ const flaggedCountryKeys = (d: { entries: Entry[] }): string[] =>
119
+ d.entries
120
+ .filter((e) => e.priority && e.iso31661Alpha2)
121
+ .map((e) => e.key)
122
+ .sort();
123
+ expect(flaggedCountryKeys(countries)).toEqual(flaggedCountryKeys(citizenship));
124
+ });
125
+
126
+ it("positional ordinals deliberately DIVERGE on 20 countries — reconcile by key, not by code", () => {
127
+ const ordinals = (d: { entries: Entry[] }): Map<string, string> =>
128
+ new Map(
129
+ d.entries.filter((e) => e.iso31661Alpha2).map((e) => [e.key, e.code.split("-")[1]!]),
130
+ );
131
+ const a = ordinals(countries);
132
+ const b = ordinals(citizenship);
133
+ const divergent = [...a.keys()].filter((k) => a.get(k) !== b.get(k)).sort();
134
+ expect(
135
+ divergent.length,
136
+ "if this changes, one of the two domains was renumbered — that is a wire-format " +
137
+ "change and needs its own decision, not a silent regeneration",
138
+ ).toBe(20);
139
+ // All 20 are adjacent-pair swaps between the two upstream sort collations.
140
+ expect(divergent).toEqual([
141
+ "germany",
142
+ "ghana",
143
+ "isle_of_man",
144
+ "israel",
145
+ "japan",
146
+ "jersey",
147
+ "lao_people_s_democratic_republic",
148
+ "latvia",
149
+ "rwanda",
150
+ "saint_barthelemy",
151
+ "seychelles",
152
+ "sierra_leone",
153
+ "south_sudan",
154
+ "spain",
155
+ "sweden",
156
+ "switzerland",
157
+ "tanzania_united_republic_of",
158
+ "thailand",
159
+ "tuvalu",
160
+ "uganda",
161
+ ]);
162
+ });
163
+ });