@htilabs/platform-common-models 0.12.2 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cvcs/index.cjs +21 -4
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +22 -4
- package/dist/cvcs/index.d.ts +22 -4
- package/dist/cvcs/index.js +21 -4
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs +1 -0
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +3 -2
- package/dist/enums/index.d.ts +3 -2
- package/dist/enums/index.js +1 -0
- package/dist/enums/index.js.map +1 -1
- package/dist/index.cjs +77 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +72 -11
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +41 -7
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +105 -1
- package/dist/schemas/index.d.ts +105 -1
- package/dist/schemas/index.js +38 -7
- package/dist/schemas/index.js.map +1 -1
- package/dist/{cvc-Cp4uWnAa.d.cts → team-C4LJ5Tex.d.cts} +36 -1
- package/dist/{cvc-Cp4uWnAa.d.ts → team-C4LJ5Tex.d.ts} +36 -1
- package/dist/validation/index.cjs +155 -0
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +1 -1
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +153 -0
- package/dist/validation/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/cvc-sot.snap +4 -0
- package/src/__tests__/core-information-scope-invariant.test.ts +125 -2
- package/src/__tests__/cvc-sot-snapshot.test.ts +9 -0
- package/src/__tests__/cvc-structural.test.ts +3 -0
- package/src/__tests__/team-directory-fields.test.ts +252 -0
- package/src/cvcs/coreInformationScope.v1.0.0.json +21 -4
- package/src/generated/cvc-enums.ts +3 -2
- package/src/index.ts +7 -0
- package/src/schemas/index.ts +8 -0
- package/src/schemas/team.ts +118 -0
- package/src/validation/index.ts +1 -0
- package/src/validation/team.ts +48 -0
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"domain": "core_information_scope",
|
|
3
3
|
"name": "Core Information Scope",
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
-
"_status": "DRAFT: canonical number 236, self-declared by the source YAML (`cvc_id: CVC-236`); CVC_INDEX.md carries no row for it yet, so the drift gate classifies it INDEX_ABSENT. Sourced from canonical CVC-236 `core_information_scope` v2 (authored 2026-08-13, restructured 2026-08-14): 12 categories /
|
|
6
|
-
"_source": "htilabstech/prototype
|
|
5
|
+
"_status": "DRAFT: canonical number 236, self-declared by the source YAML (`cvc_id: CVC-236`); CVC_INDEX.md carries no row for it yet, so the drift gate classifies it INDEX_ABSENT. Sourced from canonical CVC-236 `core_information_scope` v2 (authored 2026-08-13, restructured 2026-08-14): 12 categories / 55 units. TWO GRAINS, deliberately modelled as hierarchy: L1 categories are the POLICY grain and are NOT selectable; L2 units are the AUTHORIZATION grain and are what an ROI or a share actually authorizes. This is the axis the sibling `roi_scope` domain deliberately omits — `roi_scope` is the flat item vocabulary, and its 27 substantive keys are a strict SUBSET of the 55 units here, with no renames and no collisions. That subset relationship is what makes adopting this domain additive: every stored ROI keeps its exact recorded meaning. `safe_locations` is PROVISIONAL and may be re-keyed by the Notion steward batch — pin the id with the product owner before any consumer treats it as stable. PENDING canonical Notion authoring + steward ratification.",
|
|
6
|
+
"_source": "htilabstech/prototype/data/cvcs/core_information_scope.yaml @ 285a9f1d (CVC-236 v2, restructured 2026-08-14, amended 2026-09-29; read from origin/main; structural columns cross-checked against htilabstech/prototype/Final CVCs/System Roles, Permissions, & Account Management (IC-66)/core-information_scope — codebook.csv @ 285a9f1d)",
|
|
7
7
|
"levels": {
|
|
8
8
|
"0": "Unknown or Missing",
|
|
9
9
|
"1": "Category (policy grain, not selectable)",
|
|
@@ -470,9 +470,10 @@
|
|
|
470
470
|
"parentCode": null,
|
|
471
471
|
"childCodes": [
|
|
472
472
|
"236-003-001-000-000-000-000",
|
|
473
|
-
"236-003-002-000-000-000-000"
|
|
473
|
+
"236-003-002-000-000-000-000",
|
|
474
|
+
"236-003-003-000-000-000-000"
|
|
474
475
|
],
|
|
475
|
-
"definition": "Contact & safety — policy-grain category. Units under it are the authorization grain. NARROWED 2026-08-14 (restructure ruling 2): contact/service history moved to the NEW services category. SUPERSEDES the 2026-08-13 deliberate-merge note; legacy `contact` grants resolve via the alias layer (CVC-69 precedent). LEADS flag dropped (no LEADS units — was an empty shell).",
|
|
476
|
+
"definition": "Contact & safety — policy-grain category. Units under it are the authorization grain. NARROWED 2026-08-14 (restructure ruling 2): contact/service history moved to the NEW services category. SUPERSEDES the 2026-08-13 deliberate-merge note; legacy `contact` grants resolve via the alias layer (CVC-69 precedent). LEADS flag dropped (no LEADS units — was an empty shell). | 2026-09-29 (PRIORITIES-SAFETY-SCOPE-UNIT, Crysta R1): third unit priorities_safety — the immediate-needs triage answers, one disclosure decision.",
|
|
476
477
|
"levelFloor": 3,
|
|
477
478
|
"appRelevance": [
|
|
478
479
|
"PAVE",
|
|
@@ -514,6 +515,22 @@
|
|
|
514
515
|
"specialDataType": "survivor_confidential",
|
|
515
516
|
"platformFloor": true
|
|
516
517
|
},
|
|
518
|
+
{
|
|
519
|
+
"code": "236-003-003-000-000-000-000",
|
|
520
|
+
"key": "priorities_safety",
|
|
521
|
+
"title": "Priorities & Safety (immediate needs triage)",
|
|
522
|
+
"selectable": true,
|
|
523
|
+
"parentCode": "236-003-000-000-000-000-000",
|
|
524
|
+
"childCodes": [],
|
|
525
|
+
"definition": "Priorities & Safety (immediate needs triage). Category `contact`. NEW 2026-09-29 (PRIORITIES-SAFETY-SCOPE-UNIT, Crysta R1): the completed Immediate Priorities / Priorities & Safety triage, authorized as ONE disclosure decision — Q1 immediate danger + source of the danger + harm-doer nearby + safe place to go · Q2 health needs · Q3 interpreter · Q4 urgent basic needs · Q5 transportation (method / time / pickup location) · Q6 emergency shelter · Q7 dependents at risk · Q8 other. Instrument-grain unit on the initial_screen / lap precedent (ruling 1, 2026-08-13), homed under Contact & safety because the answers that had no home are safety facts; the service instances the step derives ride services/service_history on their own. Bidirectional Thread Signal ↔ PAVE mirror on Q1 (GDR § 6.9.7) — one unit, both apps. domain_map: priorities_safety → this unit (R3 EXECUTED later the same day, PRIORITIES-SAFETY-RECORD): CVC-159 domain priorities_safety (Level 1) + monolith emitter emitPrioritiesAnswerCAR (one CAR per answered question) + UDD row capture.priorities_safety; production persistence of the answers stays with Nate under RWT-NEW-priorities-safety-record-and-udd-2026-09-29. Minted in the Notion codebook the same day; codebook row re-synced to the record 2026-09-29.",
|
|
526
|
+
"levelFloor": 3,
|
|
527
|
+
"appRelevance": [
|
|
528
|
+
"PAVE",
|
|
529
|
+
"Thread"
|
|
530
|
+
],
|
|
531
|
+
"shareableDefault": true,
|
|
532
|
+
"specialDataType": "survivor_confidential"
|
|
533
|
+
},
|
|
517
534
|
{
|
|
518
535
|
"code": "236-004-000-000-000-000-000",
|
|
519
536
|
"key": "services",
|
|
@@ -4085,9 +4085,9 @@ export const NeedsAssessmentChangeTypeKeys = {
|
|
|
4085
4085
|
export type NeedsAssessmentChangeTypeKey = keyof typeof NeedsAssessmentChangeTypeKeys;
|
|
4086
4086
|
|
|
4087
4087
|
/**
|
|
4088
|
-
* Key → positional code map for the `core_information_scope` CVC domain (DRAFT-TEMPORARY; canonical CVC-236, 12 policy-grain CATEGORIES +
|
|
4088
|
+
* Key → positional code map for the `core_information_scope` CVC domain (DRAFT-TEMPORARY; canonical CVC-236, 12 policy-grain CATEGORIES + 55 authorization-grain UNITS. Categories are level 1 and NOT selectable; units are level 2 and are what an ROI or a share authorizes. Distinct from the sibling `roi_scope` domain, which is the FLAT item vocabulary and deliberately omits the category axis — roi_scope's 27 substantive keys are a strict SUBSET of these 55 units, with no renames, so adoption is additive and no stored ROI changes meaning).
|
|
4089
4089
|
*
|
|
4090
|
-
* Domain: `core_information_scope` · Version: 1.0.0 · Entries:
|
|
4090
|
+
* Domain: `core_information_scope` · Version: 1.0.0 · Entries: 71
|
|
4091
4091
|
*/
|
|
4092
4092
|
export const CoreInformationScopeKeys = {
|
|
4093
4093
|
missingness_root: "236-000-000-000-000-000-000",
|
|
@@ -4121,6 +4121,7 @@ export const CoreInformationScopeKeys = {
|
|
|
4121
4121
|
contact: "236-003-000-000-000-000-000",
|
|
4122
4122
|
contact_info: "236-003-001-000-000-000-000",
|
|
4123
4123
|
safe_locations: "236-003-002-000-000-000-000",
|
|
4124
|
+
priorities_safety: "236-003-003-000-000-000-000",
|
|
4124
4125
|
services: "236-004-000-000-000-000-000",
|
|
4125
4126
|
contact_history: "236-004-001-000-000-000-000",
|
|
4126
4127
|
service_history: "236-004-002-000-000-000-000",
|
package/src/index.ts
CHANGED
|
@@ -74,6 +74,13 @@ export type {
|
|
|
74
74
|
CvcDomain,
|
|
75
75
|
} from "./validation/cvc.js";
|
|
76
76
|
|
|
77
|
+
// ─── Team directory field validation (Zod) ──────────────────────────────────
|
|
78
|
+
// The Mongoose fragment (`teamDirectorySchemaDefinition`,
|
|
79
|
+
// `addTeamDirectoryFields`) comes in through `./schemas/index.js` above.
|
|
80
|
+
|
|
81
|
+
export { TeamAppSchema, TeamDirectoryFieldsSchema } from "./validation/team.js";
|
|
82
|
+
export type { TeamApp, TeamDirectoryFieldsInput } from "./validation/team.js";
|
|
83
|
+
|
|
77
84
|
// ─── CVC factory model named aliases ────────────────────────────────────────
|
|
78
85
|
// Per co-am3.7 bead: surface the model factories under explicit
|
|
79
86
|
// `compileCvcRegistryModel` / `compileCvcEntryModel` names. The underlying
|
package/src/schemas/index.ts
CHANGED
|
@@ -85,6 +85,14 @@ export {
|
|
|
85
85
|
type PlatformRole,
|
|
86
86
|
} from "./platform-role.js";
|
|
87
87
|
|
|
88
|
+
// Team directory fields (fragment added to each app's team schema)
|
|
89
|
+
export {
|
|
90
|
+
TEAM_MODEL_NAME,
|
|
91
|
+
teamDirectorySchemaDefinition,
|
|
92
|
+
addTeamDirectoryFields,
|
|
93
|
+
type TeamDirectoryFields,
|
|
94
|
+
} from "./team.js";
|
|
95
|
+
|
|
88
96
|
// CVC Registry schema
|
|
89
97
|
export {
|
|
90
98
|
buildCvcRegistrySchema,
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @htilabs/platform-common-models — Team directory fields
|
|
3
|
+
*
|
|
4
|
+
* Shared, additive fields for the platform-db `teams` collection that the
|
|
5
|
+
* Thread→PAVE "Refer to intake" preset reads to resolve the own-agency PAVE
|
|
6
|
+
* intake team.
|
|
7
|
+
*
|
|
8
|
+
* ## This is a FRAGMENT, not a Team model
|
|
9
|
+
*
|
|
10
|
+
* No canonical Team schema exists in this package. The `teams` collection is
|
|
11
|
+
* defined by legacy PAVE (`screening-tools` `models/teamModel.js`,
|
|
12
|
+
* `agencyManagementDb`), mirrored by Thread
|
|
13
|
+
* (`packages/db/src/models/platform/Team.ts`), written by the platform Admin
|
|
14
|
+
* Hub and identity sync, and read raw by pave-2.0 (`lookups/teamGraph.ts`).
|
|
15
|
+
* Declaring the whole Team contract here would mean resolving those shapes,
|
|
16
|
+
* which is out of scope. This module only declares the fields the referral
|
|
17
|
+
* preset needs. Each consumer adds them to its own team schema with
|
|
18
|
+
* {@link addTeamDirectoryFields}, or spreads {@link teamDirectorySchemaDefinition}.
|
|
19
|
+
*
|
|
20
|
+
* ## Canon
|
|
21
|
+
*
|
|
22
|
+
* Prototype `origin/main` @ `c658d6f7`:
|
|
23
|
+
* - `KICKOFF_SHARE_EDGE_CONVERGENCE_2026-09-29.md` § 2.8 L254-257: the intake
|
|
24
|
+
* team is resolved from the sending program's `can_refer_to` targets
|
|
25
|
+
* first, then from the default-share-team ladder restricted to PAVE teams.
|
|
26
|
+
* A referral to intake never routes back to the sender.
|
|
27
|
+
* - Monolith `HTI-LEADS-PAVE-Thread-prototype.html` L323796-323832
|
|
28
|
+
* (`resolveIntakeTeamMono`), directory `programs[]` L142246-142431 and
|
|
29
|
+
* `teams[]` from L142584.
|
|
30
|
+
*
|
|
31
|
+
* Thread ADR: `docs/ADR-THREAD-PAVE-CASESHARE-CONVERGENCE.md` D1 and staging
|
|
32
|
+
* row .2 (consumer th-ng838.2). PAVE consumer: pv-p6share-thread-ingest-v4.
|
|
33
|
+
*
|
|
34
|
+
* ## Divergences from canon (deliberate)
|
|
35
|
+
*
|
|
36
|
+
* 1. **`apps`, not `apps_used`.** Canon's team rows carry lowercase
|
|
37
|
+
* `apps_used` (`"pave"`). The live platform-db writers already stamp
|
|
38
|
+
* `apps` with the uppercase {@link PLATFORM_TOOL} codes on agencies,
|
|
39
|
+
* accounts, users and teams (platform `lib/sync/upserts.ts`,
|
|
40
|
+
* `$addToSet: { apps: APP }` with `APP = source.toUpperCase()`). This
|
|
41
|
+
* field matches that convention exactly.
|
|
42
|
+
* 2. **`canReferTo` lives on the team.** Canon carries `can_refer_to` on a
|
|
43
|
+
* first-class PROGRAM row (`programs[]`, one `team_id` per program), and
|
|
44
|
+
* its targets are PROGRAM ids. No Program model exists in this package or
|
|
45
|
+
* in platform-db, so the targets are carried here as TEAM ids on the
|
|
46
|
+
* sending team. Canon's resolver maps each target program to its single
|
|
47
|
+
* team before using it, so the resolved team is the same. If a Program
|
|
48
|
+
* model lands later, `canReferTo` should move onto it.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
import { Schema } from "mongoose";
|
|
52
|
+
import type { InferRawDocType } from "mongoose";
|
|
53
|
+
import { PLATFORM_TOOL_VALUES } from "../constants/platform-auth.js";
|
|
54
|
+
|
|
55
|
+
/** Mongoose model name every app registers the `teams` collection under. */
|
|
56
|
+
export const TEAM_MODEL_NAME = "Team" as const;
|
|
57
|
+
|
|
58
|
+
// ─── Schema Definition ──────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The directory fields to add to a team schema.
|
|
62
|
+
*
|
|
63
|
+
* Both are OPTIONAL and default to `undefined`, not `[]`. A team document
|
|
64
|
+
* written before these fields existed hydrates and re-saves without gaining
|
|
65
|
+
* an `apps` or `canReferTo` key. That keeps "not declared" (absent) distinct
|
|
66
|
+
* from "declared empty" (`[]`).
|
|
67
|
+
*/
|
|
68
|
+
export const teamDirectorySchemaDefinition = {
|
|
69
|
+
/**
|
|
70
|
+
* The platform apps this team works in, as {@link PLATFORM_TOOL} codes
|
|
71
|
+
* (`"PAVE"`, `"THREAD"`, `"LEADS"`, ...). The referral preset only resolves
|
|
72
|
+
* to a team whose `apps` includes `"PAVE"`.
|
|
73
|
+
*/
|
|
74
|
+
apps: {
|
|
75
|
+
type: [String],
|
|
76
|
+
enum: [...PLATFORM_TOOL_VALUES],
|
|
77
|
+
default: undefined,
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* The teams this team refers to, in priority order. The resolver takes the
|
|
81
|
+
* first active target that works in PAVE and is not the sending team itself.
|
|
82
|
+
*/
|
|
83
|
+
canReferTo: {
|
|
84
|
+
type: [{ type: Schema.Types.ObjectId, ref: TEAM_MODEL_NAME }],
|
|
85
|
+
default: undefined,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// ─── Schema Helper ──────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Add the team directory fields to an existing team schema.
|
|
93
|
+
*
|
|
94
|
+
* Adds no indexes and no hooks. Indexes on the shared `teams` collection
|
|
95
|
+
* stay with the collection's owner.
|
|
96
|
+
*
|
|
97
|
+
* @param schema - The consumer's team schema
|
|
98
|
+
* @returns The same schema, for chaining
|
|
99
|
+
*/
|
|
100
|
+
export function addTeamDirectoryFields<S extends Schema>(schema: S): S {
|
|
101
|
+
schema.add(teamDirectorySchemaDefinition);
|
|
102
|
+
return schema;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ─── Type Inference ─────────────────────────────────────────────────
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Raw (persistence) shape of the team directory fields: `apps` as
|
|
109
|
+
* `PlatformToolValue[]`, `canReferTo` as `ObjectId[]`.
|
|
110
|
+
*
|
|
111
|
+
* Inferred from the DEFINITION, not from a compiled `Schema`: given a
|
|
112
|
+
* `Schema` instance, `InferRawDocType` resolves to the Schema object's own
|
|
113
|
+
* members rather than the document fields. Wrapped in `Partial` because both
|
|
114
|
+
* fields are absent on documents that predate them.
|
|
115
|
+
*/
|
|
116
|
+
export type TeamDirectoryFields = Partial<
|
|
117
|
+
InferRawDocType<typeof teamDirectorySchemaDefinition>
|
|
118
|
+
>;
|
package/src/validation/index.ts
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @htilabs/platform-common-models — Team directory field validation
|
|
3
|
+
*
|
|
4
|
+
* Zod schemas for the team directory fields declared in
|
|
5
|
+
* `../schemas/team.ts`, the fields the Thread→PAVE "Refer to intake" preset
|
|
6
|
+
* reads. See that module for canon citations and the two deliberate
|
|
7
|
+
* divergences (`apps` uses the {@link PLATFORM_TOOL} codes, and `canReferTo`
|
|
8
|
+
* sits on the team because there is no Program model).
|
|
9
|
+
*
|
|
10
|
+
* This is the wire / API shape: ids are 24-hex strings, not ObjectIds. Merge
|
|
11
|
+
* {@link TeamDirectoryFieldsSchema} into a consumer's team schema with
|
|
12
|
+
* `.merge()` or `.extend(TeamDirectoryFieldsSchema.shape)`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { PLATFORM_TOOL_VALUES } from "../constants/platform-auth.js";
|
|
17
|
+
|
|
18
|
+
/** A Mongo ObjectId serialized as a 24-character hex string. */
|
|
19
|
+
const ObjectIdHexSchema = z
|
|
20
|
+
.string()
|
|
21
|
+
.regex(/^[0-9a-fA-F]{24}$/, "must be a 24-character hex ObjectId");
|
|
22
|
+
|
|
23
|
+
const hasNoDuplicates = (values: readonly string[]): boolean =>
|
|
24
|
+
new Set(values.map((v) => v.toLowerCase())).size === values.length;
|
|
25
|
+
|
|
26
|
+
/** One platform app a team works in: a {@link PLATFORM_TOOL} code. */
|
|
27
|
+
export const TeamAppSchema = z.enum(PLATFORM_TOOL_VALUES);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The team directory fields. Both are optional, so a team payload without
|
|
31
|
+
* them validates unchanged. When present, neither list may repeat a value.
|
|
32
|
+
*/
|
|
33
|
+
export const TeamDirectoryFieldsSchema = z.object({
|
|
34
|
+
apps: z
|
|
35
|
+
.array(TeamAppSchema)
|
|
36
|
+
.refine(hasNoDuplicates, "apps must not repeat an app")
|
|
37
|
+
.optional(),
|
|
38
|
+
canReferTo: z
|
|
39
|
+
.array(ObjectIdHexSchema)
|
|
40
|
+
.refine(hasNoDuplicates, "canReferTo must not repeat a team")
|
|
41
|
+
.optional(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/** A platform app code accepted on a team. */
|
|
45
|
+
export type TeamApp = z.infer<typeof TeamAppSchema>;
|
|
46
|
+
|
|
47
|
+
/** Wire shape of the team directory fields (ids as hex strings). */
|
|
48
|
+
export type TeamDirectoryFieldsInput = z.infer<typeof TeamDirectoryFieldsSchema>;
|