@htilabs/platform-common-models 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/agency-BHv54o79.d.ts +484 -0
  2. package/dist/agency-Ca4pCOOf.d.ts +342 -0
  3. package/dist/agency-DYCv839V.d.cts +342 -0
  4. package/dist/agency-Djp57S71.d.cts +484 -0
  5. package/dist/constants/index.cjs +952 -0
  6. package/dist/constants/index.cjs.map +1 -1
  7. package/dist/constants/index.d.cts +3 -1
  8. package/dist/constants/index.d.ts +3 -1
  9. package/dist/constants/index.js +920 -0
  10. package/dist/constants/index.js.map +1 -1
  11. package/dist/{cvcEntry-ctHTp2df.d.cts → cvcEntry-0BIB9sen.d.cts} +36 -36
  12. package/dist/{cvcEntry-ctHTp2df.d.ts → cvcEntry-0BIB9sen.d.ts} +36 -36
  13. package/dist/cvcs/index.cjs +114 -62
  14. package/dist/cvcs/index.cjs.map +1 -1
  15. package/dist/cvcs/index.d.cts +112 -59
  16. package/dist/cvcs/index.d.ts +112 -59
  17. package/dist/cvcs/index.js +114 -62
  18. package/dist/cvcs/index.js.map +1 -1
  19. package/dist/enums/index.cjs +1 -0
  20. package/dist/enums/index.cjs.map +1 -1
  21. package/dist/enums/index.d.cts +2 -1
  22. package/dist/enums/index.d.ts +2 -1
  23. package/dist/enums/index.js +1 -0
  24. package/dist/enums/index.js.map +1 -1
  25. package/dist/{index-4DiJrn7y.d.ts → index-CDoqrfc1.d.ts} +1 -1
  26. package/dist/{index-qreOzXYS.d.cts → index-Zu_mOJRn.d.cts} +1 -1
  27. package/dist/index.cjs +1654 -1077
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +6 -4
  30. package/dist/index.d.ts +6 -4
  31. package/dist/index.js +1600 -1076
  32. package/dist/index.js.map +1 -1
  33. package/dist/models/index.d.cts +2 -2
  34. package/dist/models/index.d.ts +2 -2
  35. package/dist/org-type-BYQb9Qzq.d.ts +366 -0
  36. package/dist/org-type-D_FG4KdN.d.cts +366 -0
  37. package/dist/{platform-auth-CrF5U_JH.d.cts → platform-auth-CvAYFVhK.d.cts} +39 -0
  38. package/dist/{platform-auth-CrF5U_JH.d.ts → platform-auth-CvAYFVhK.d.ts} +39 -0
  39. package/dist/schemas/index.cjs +977 -2
  40. package/dist/schemas/index.cjs.map +1 -1
  41. package/dist/schemas/index.d.cts +14 -11
  42. package/dist/schemas/index.d.ts +14 -11
  43. package/dist/schemas/index.js +962 -1
  44. package/dist/schemas/index.js.map +1 -1
  45. package/dist/types/index.d.cts +2 -2
  46. package/dist/types/index.d.ts +2 -2
  47. package/dist/validation/index.cjs +894 -2
  48. package/dist/validation/index.cjs.map +1 -1
  49. package/dist/validation/index.d.cts +5 -1
  50. package/dist/validation/index.d.ts +5 -1
  51. package/dist/validation/index.js +884 -1
  52. package/dist/validation/index.js.map +1 -1
  53. package/package.json +26 -27
  54. package/src/__tests__/__snapshots__/cvc-sot.snap +2 -2
  55. package/src/__tests__/cvc-sot-snapshot.test.ts +5 -5
  56. package/src/__tests__/cvc-structural.test.ts +1 -1
  57. package/src/__tests__/org-type-contract.test.ts +1353 -0
  58. package/src/__tests__/referral-entity-category-canon.test.ts +255 -81
  59. package/src/constants/ic.ts +45 -0
  60. package/src/constants/index.ts +1 -0
  61. package/src/constants/org-type.ts +703 -0
  62. package/src/cvcs/index.ts +1 -1
  63. package/src/cvcs/{referralEntityCategory.v1.1.0.json → referralEntityCategory.v1.2.0.json} +111 -59
  64. package/src/generated/cvc-enums.ts +2 -1
  65. package/src/index.ts +23 -0
  66. package/src/schemas/agency.ts +481 -0
  67. package/src/schemas/index.ts +24 -0
  68. package/src/validation/agency.ts +119 -0
  69. package/src/validation/index.ts +1 -0
  70. package/dist/team-C4LJ5Tex.d.cts +0 -333
  71. package/dist/team-C4LJ5Tex.d.ts +0 -333
@@ -0,0 +1,342 @@
1
+ import { InferRawDocType, Schema, Query } from 'mongoose';
2
+ import { a as AgencyTypeKey } from './org-type-D_FG4KdN.cjs';
3
+
4
+ /**
5
+ * @htilabs/platform-common-models — organization-type fields: Org home, Agency mirror
6
+ *
7
+ * Shared, additive fields for the kind of organization something is, with
8
+ * the ONE vocabulary (`constants/org-type.ts`), and where they live.
9
+ *
10
+ * ## The three objects (UDD, ruled 2026-10-02; Org `vsp` ruled 2026-10-05)
11
+ *
12
+ * - **Org** — "who is this, out in the world": the platform-wide registry
13
+ * row (platform-db `organizations`). It HOLDS the type and the two HMIS
14
+ * victim-service-provider answers: `type`, `vsp`, `vspPrivateNonprofit`.
15
+ * One Org per real-world organization, with or without any account. The
16
+ * Admin Hub edits it here, once. (`requires_roi` stays on the org row AS
17
+ * BUILT and is NOT one of these fields: the Org Data Object lists it under
18
+ * "as built today, and not part of this definition" and GDR § 5.17 clause 2
19
+ * makes it informational — the release check reads the sender's `vsp`,
20
+ * never `requires_roi`. Review round ORG-TYPE-REVIEW-ROUND-2026-10-08, Crysta decision 1.)
21
+ * - **Account** — "who signed, and whose rules govern": the tenancy
22
+ * (`agencies` rows with `isAccount: true` today). Carries none of these
23
+ * fields; points at its holding Org.
24
+ * - **Agency** — "how does this Org take part in that Account": an Org with
25
+ * an Account IS an Agency — one row per (Org, Account), keyed by
26
+ * `organizationId` (→ `organizations._id`) and the account. The UDD Agency
27
+ * carries NO type and NO flags of its own; it reads them off its Org.
28
+ *
29
+ * ## Why the Agency gets a copy anyway (the mirror)
30
+ *
31
+ * Every live gate reads `agencies.type` (`/me`, the ROI gate, the authority
32
+ * set, the session-role default, recipient labels) and production's Org
33
+ * link is nearly empty (6 of 124 prod agencies carry an `organizationId`,
34
+ * #187). So the Agency row carries a **declared mirror** of the Org's four
35
+ * fields: same definition, stamped FROM the Org — by provisioning when the
36
+ * agency is created, by the backfill when it links the agency to its Org —
37
+ * and never edited on the agency directly. {@link mirrorOrgTypeFields} is
38
+ * the one way to produce the copy. The home is the Org; the mirror exists so
39
+ * readers do not have to join until `organizationId` is populated
40
+ * everywhere. A consumer that CAN join reads the Org through
41
+ * {@link resolveEffectiveOrgTypeFields} / {@link resolveEffectiveOrgType}
42
+ * ("the Org wins once linked"); {@link orgTypeFieldsDiffer} surfaces drift.
43
+ *
44
+ * **The mirror is TRANSITIONAL and has a sunset** (Crysta, 2026-10-08,
45
+ * platform-common #187): the agency copy is dropped the day every agency row
46
+ * carries `organizationId` (6 of 124 production rows today). The UDD Agency
47
+ * carries no type and no flags — this copy is a production crutch, not an
48
+ * Agency field, and nothing is ever "aligned" to it.
49
+ *
50
+ * **Re-stamp invariant** (Kirby, review of `9538e2e`): every write of these
51
+ * fields on an Org re-stamps the copy on EVERY agency row linked to it
52
+ * (`organizationId`), in the same operation as the Org write — the Admin Hub
53
+ * and the backfill are the two writers, and both go Org first, then
54
+ * `mirrorOrgTypeFields(org)` onto each linked agency. A reader that finds
55
+ * `orgTypeFieldsDiffer(org, agency)` non-empty has found a broken writer,
56
+ * not a legitimate state; it should read the Org and log the drift.
57
+ *
58
+ * ## This is a FRAGMENT, not an Org / Agency model
59
+ *
60
+ * No canonical Org or Agency schema exists in this package (same posture as
61
+ * `schemas/team.ts`). `organizations` is written by PAVE 2.0 (`type` a
62
+ * NUMBER 10–31 today — the IC-58 positional list; the Org mount replaces it
63
+ * with the key), `agencies` by the auth service at provisioning (`au-q3p`)
64
+ * and the platform Admin Hub, mirrored by Thread (`type: String` free text)
65
+ * and legacy PAVE. Declaring the whole shapes here is out of scope; this
66
+ * module declares ONLY the organization-type fields and mounts them on
67
+ * either schema: {@link addOrgTypeFields} (home) /
68
+ * {@link addAgencyOrgTypeFields} (mirror).
69
+ *
70
+ * ## Ruling of record (Crysta, 2026-10-05 — platform-common #187)
71
+ *
72
+ * Agency type = CVC-48 `core-referral_entity_category`, set ONCE on the Org
73
+ * in the Admin Hub; the Agency carries it from the Org; every reader joins on
74
+ * the key. `vsp` and `vspPrivateNonprofit` are captured on the org record in
75
+ * the Admin Hub (Directory tab; Network add / edit forms — UDD Org Data
76
+ * Object ruling 2026-10-05; the 2026-08-13 onboarding derivation
77
+ * `isVspEntityType` is retired by that ruling) and never inferred from the
78
+ * type. Refined 2026-10-08 (Crysta): the type PROPOSES the answer
79
+ * (`orgTypeDefaultVsp` is what the Admin Hub pre-fills, and what a reader
80
+ * falls back to while nothing is attested); the answer is SET only when HTI
81
+ * Labs affirms or changes it in the Admin Hub. A proposal is never written
82
+ * as an answer — not by onboarding, not by the backfill.
83
+ *
84
+ * ## Field names
85
+ *
86
+ * Canon's org registry spells these `type`, `vsp`, `vsp_private_nonprofit`
87
+ * (snake_case CSV columns). The live platform-db writers use camelCase on
88
+ * agencies (`isHTIAdminAgency`, `serviceLocation`, `apps`), so the second
89
+ * boolean is carried camelCase here; `type` and `vsp` are spelled the same
90
+ * in both.
91
+ *
92
+ * ## Backfill posture
93
+ *
94
+ * `type` is NOT `required` at the schema level yet: most production agencies
95
+ * were provisioned with no type at all, and a required enum would make every
96
+ * one of them fail validation on its next unrelated save. Not-required keeps
97
+ * those rows saving; it does NOT protect a row that already carries a non-key
98
+ * value (see the `type` field doc) — those are the backfill's first job. The
99
+ * backfill (HTI Labs confirms each agency against the org registry; #187)
100
+ * sets a key on every row; the minor that follows it flips `required: true`.
101
+ * Until then a stored `unknown` is the ONE admitted placeholder, and readers
102
+ * treat an absent / unresolvable type exactly like `unknown`
103
+ * (`resolveAgencyTypeKey` → `null`).
104
+ *
105
+ * ## Order of adoption (review MG2) — BOTH collections
106
+ *
107
+ * Mongoose validates every loaded path on `save()`, so once a consumer mounts
108
+ * these fields, a document carrying a NON-KEY `type` fails its next save of
109
+ * any field. That is the intended fail-closed, and it means the data goes
110
+ * first: (1) `agencies` — the handful of free-text rows (prod 3, dev 3) are
111
+ * normalised to `unknown`, no HTI confirmation needed; (2) `organizations` —
112
+ * EVERY row carries a numeric IC-58 type today (10–31, PAVE's writer), so the
113
+ * numeric → key migration (proposed by `resolveOrgTypeKeyFromLegacyNumeric`,
114
+ * confirmed by HTI Labs on the backfill sheet) runs BEFORE any consumer calls
115
+ * {@link addOrgTypeFields} on `organizations`; (3) mount; (4) after the
116
+ * backfill, `required: true` and the recognisers are deleted.
117
+ * (ORG-TYPE-REVIEW-ROUND-2026-10-08)
118
+ */
119
+
120
+ /**
121
+ * Step 2 (`vspPrivateNonprofit`) is asked only when step 1 (`vsp`) is `true`.
122
+ * A record (or a write) that answers step 2 without `vsp: true` is MALFORMED
123
+ * — never "false by default". Tri-state is preserved: an absent / `null`
124
+ * step 2 always holds, whatever step 1 says (GDR § 1.2: never-captured is
125
+ * never coerced). One predicate, enforced in three places: the Zod write
126
+ * shapes (`validation/agency.ts`), the Mongoose mount (`pre('validate')` on
127
+ * save and the update-op hook) and {@link mirrorOrgTypeFields}.
128
+ */
129
+ declare function vspTwoStepHolds(v: {
130
+ vsp?: boolean | null;
131
+ vspPrivateNonprofit?: boolean | null;
132
+ }): boolean;
133
+ declare const VSP_TWO_STEP_ISSUE: {
134
+ message: string;
135
+ path: (string | number)[];
136
+ };
137
+ /**
138
+ * The two-step on an UPDATE payload (`updateOne` / `updateMany` /
139
+ * `findOneAndUpdate`): an update cannot see the stored document, so the rule
140
+ * it can enforce is "step 2 is only ever written together with step 1" — a
141
+ * payload that sets `vspPrivateNonprofit` to a boolean must set `vsp: true`
142
+ * in the same payload (top level or `$set`). Clearing step 2 (`null` /
143
+ * `$unset`) always holds. Exported so it can be unit-tested without a
144
+ * connection; the mount installs it on {@link AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS}.
145
+ */
146
+ declare function vspTwoStepHoldsOnUpdate(update: unknown): boolean;
147
+ /**
148
+ * The organization-type fields. ONE definition, mounted on the Org (home)
149
+ * and on the Agency (mirror) — see the module doc.
150
+ *
151
+ * All three are OPTIONAL and default to `undefined`. A document written
152
+ * before these fields existed hydrates and re-saves without gaining them, so
153
+ * "not attested" (absent) stays distinct from "attested false".
154
+ */
155
+ declare const orgTypeSchemaDefinition: {
156
+ /**
157
+ * The agency's organization type: a CVC-48 key from
158
+ * {@link AGENCY_TYPE_KEYS} (a selectable org-type leaf, or the pre-backfill
159
+ * `unknown`). Set once in the Admin Hub; carried from the Org. Never free
160
+ * text — a value outside the enum fails validation on `save()` and, when
161
+ * the fragment is added with {@link addAgencyOrgTypeFields} (default
162
+ * options), on `updateOne` / `updateMany` / `findOneAndUpdate` too.
163
+ *
164
+ * ORDER OF ADOPTION (review MG2, pinned in org-type-contract.test.ts):
165
+ * Mongoose validates `init`-ed paths on `save()`, not only modified ones,
166
+ * so once a consumer adds this fragment, an agency document that carries a
167
+ * NON-KEY `type` (free text, "UNKNOWN", "multi_service", a number) fails
168
+ * its next save of ANY field. A document with no `type` at all saves fine.
169
+ * Backfill first (every stored value → a key or `unknown`), then adopt.
170
+ */
171
+ type: {
172
+ type: StringConstructor;
173
+ enum: ("unknown" | "outreach_project" | "temporary_shelter" | "residential_project" | "national_hotline" | "local_other_hotline" | "child_welfare_cps" | "juvenile_justice" | "law_enforcement" | "local_law_enforcement" | "state_law_enforcement" | "federal_law_enforcement" | "tribal_law_enforcement" | "other_law_enforcement" | "courts_prosecution" | "correction_probation" | "inpatient_psychiatric_facility" | "healthcare_provider" | "child_advocacy_center" | "victim_service_provider" | "community_based_service_provider" | "mdt" | "coalition" | "own_agency_internal" | "employer" | "benefits_public_assistance_office" | "other_organization" | "hotline" | "adult_protective_services" | "school_academic_institution" | "legal_services_provider")[];
174
+ index: boolean;
175
+ };
176
+ /**
177
+ * Is this organization a DV/SA victim service provider — the HMIS 2.01
178
+ * (Comparable Database) fact. Captured in the Admin Hub (never inferred
179
+ * from the type; the type only PROPOSES it — `orgTypeDefaultVsp`, the
180
+ * Hub's pre-fill — and HTI Labs affirms or changes it there). Tri-state:
181
+ * `true` / `false` / absent (not yet captured — a reader falls back to the
182
+ * proposal).
183
+ */
184
+ vsp: {
185
+ type: BooleanConstructor;
186
+ };
187
+ /**
188
+ * Step 2 of the two-step: private non-profit VSP (VOCA/OVC PMT
189
+ * distinction). Captured; tri-state; may only be `true`/`false` when
190
+ * `vsp === true` ({@link vspTwoStepHolds}, enforced at the mount).
191
+ */
192
+ vspPrivateNonprofit: {
193
+ type: BooleanConstructor;
194
+ };
195
+ };
196
+ /** @deprecated Same object as {@link orgTypeSchemaDefinition}; kept for 0.14-era callers. */
197
+ declare const agencyOrgTypeSchemaDefinition: {
198
+ /**
199
+ * The agency's organization type: a CVC-48 key from
200
+ * {@link AGENCY_TYPE_KEYS} (a selectable org-type leaf, or the pre-backfill
201
+ * `unknown`). Set once in the Admin Hub; carried from the Org. Never free
202
+ * text — a value outside the enum fails validation on `save()` and, when
203
+ * the fragment is added with {@link addAgencyOrgTypeFields} (default
204
+ * options), on `updateOne` / `updateMany` / `findOneAndUpdate` too.
205
+ *
206
+ * ORDER OF ADOPTION (review MG2, pinned in org-type-contract.test.ts):
207
+ * Mongoose validates `init`-ed paths on `save()`, not only modified ones,
208
+ * so once a consumer adds this fragment, an agency document that carries a
209
+ * NON-KEY `type` (free text, "UNKNOWN", "multi_service", a number) fails
210
+ * its next save of ANY field. A document with no `type` at all saves fine.
211
+ * Backfill first (every stored value → a key or `unknown`), then adopt.
212
+ */
213
+ type: {
214
+ type: StringConstructor;
215
+ enum: ("unknown" | "outreach_project" | "temporary_shelter" | "residential_project" | "national_hotline" | "local_other_hotline" | "child_welfare_cps" | "juvenile_justice" | "law_enforcement" | "local_law_enforcement" | "state_law_enforcement" | "federal_law_enforcement" | "tribal_law_enforcement" | "other_law_enforcement" | "courts_prosecution" | "correction_probation" | "inpatient_psychiatric_facility" | "healthcare_provider" | "child_advocacy_center" | "victim_service_provider" | "community_based_service_provider" | "mdt" | "coalition" | "own_agency_internal" | "employer" | "benefits_public_assistance_office" | "other_organization" | "hotline" | "adult_protective_services" | "school_academic_institution" | "legal_services_provider")[];
216
+ index: boolean;
217
+ };
218
+ /**
219
+ * Is this organization a DV/SA victim service provider — the HMIS 2.01
220
+ * (Comparable Database) fact. Captured in the Admin Hub (never inferred
221
+ * from the type; the type only PROPOSES it — `orgTypeDefaultVsp`, the
222
+ * Hub's pre-fill — and HTI Labs affirms or changes it there). Tri-state:
223
+ * `true` / `false` / absent (not yet captured — a reader falls back to the
224
+ * proposal).
225
+ */
226
+ vsp: {
227
+ type: BooleanConstructor;
228
+ };
229
+ /**
230
+ * Step 2 of the two-step: private non-profit VSP (VOCA/OVC PMT
231
+ * distinction). Captured; tri-state; may only be `true`/`false` when
232
+ * `vsp === true` ({@link vspTwoStepHolds}, enforced at the mount).
233
+ */
234
+ vspPrivateNonprofit: {
235
+ type: BooleanConstructor;
236
+ };
237
+ };
238
+ /**
239
+ * The field names, in one place (the mirror copies exactly these). The
240
+ * `satisfies` ties the tuple to {@link OrgTypeFields} at compile time: a field
241
+ * added to the definition without being listed here fails `tsc`, so the
242
+ * mirror can never silently stop copying it (review nit).
243
+ */
244
+ declare const ORG_TYPE_FIELD_NAMES: readonly ["type", "vsp", "vspPrivateNonprofit"];
245
+ type OrgTypeFieldName = (typeof ORG_TYPE_FIELD_NAMES)[number];
246
+ /** Update operations on which the enum is enforced by {@link addAgencyOrgTypeFields}. */
247
+ declare const AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS: readonly ["updateOne", "updateMany", "findOneAndUpdate"];
248
+ interface AddAgencyOrgTypeFieldsOptions {
249
+ /**
250
+ * Turn `runValidators` on (unless the caller set it explicitly) in the
251
+ * `pre` hook the mount installs on {@link AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS},
252
+ * so the enum holds on the update paths the auth service and the Admin Hub
253
+ * actually write through — Mongoose skips enum validators on update
254
+ * operations by default. Default `true`. The hook itself is ALWAYS
255
+ * installed: it also enforces the VSP two-step on the update payload
256
+ * ({@link vspTwoStepHoldsOnUpdate}), which is a shape rule, not a
257
+ * validator option, and cannot be opted out of.
258
+ */
259
+ validateOnUpdate?: boolean;
260
+ }
261
+ /**
262
+ * The hook body, exported so it can be unit-tested without a connection:
263
+ * sets `runValidators: true` on a query that has not said otherwise.
264
+ */
265
+ declare function applyRunValidatorsIfUnset(query: Pick<Query<unknown, unknown>, "getOptions" | "setOptions">): void;
266
+ /**
267
+ * Add the organization-type fields to an **Org** (registry) schema — the
268
+ * HOME of the type and the attested HMIS facts (UDD Org Data Object). This
269
+ * is the mount the Admin Hub writes through.
270
+ *
271
+ * @param schema - The consumer's organization schema (platform-db `organizations`)
272
+ * @param options - See {@link AddAgencyOrgTypeFieldsOptions}
273
+ * @returns The same schema, for chaining
274
+ */
275
+ declare function addOrgTypeFields<S extends Schema>(schema: S, options?: AddAgencyOrgTypeFieldsOptions): S;
276
+ /**
277
+ * Add the organization-type fields to an **Agency** schema as a MIRROR of
278
+ * its Org's (same definition, same enum, same hook). The copy is stamped
279
+ * from the Org via {@link mirrorOrgTypeFields} — at provisioning, and by the
280
+ * backfill — and is never edited on the agency directly. An agency that has
281
+ * no `organizationId` yet carries the backfill's confirmed value until it is
282
+ * linked; once linked, the Org wins.
283
+ *
284
+ * @param schema - The consumer's agency schema (platform-db `agencies`)
285
+ * @param options - See {@link AddAgencyOrgTypeFieldsOptions}
286
+ * @returns The same schema, for chaining
287
+ */
288
+ declare function addAgencyOrgTypeFields<S extends Schema>(schema: S, options?: AddAgencyOrgTypeFieldsOptions): S;
289
+ /** Anything that may carry the fields: an Org document, an Agency document, a plain object. */
290
+ type OrgTypeFieldsHolder = Partial<Record<OrgTypeFieldName, unknown>>;
291
+ /**
292
+ * The one way to produce the Agency's copy: the Org's fields, exactly, with
293
+ * absent values kept absent (an Org that never attested `vsp` yields an
294
+ * agency that never attested it — a copy never coerces a `false`; a `null`
295
+ * is treated as absent, not copied). Any other key on the Org document is
296
+ * ignored. Use it wherever an agency is created from, or re-linked to, its
297
+ * Org, and on EVERY Org write of these fields (the re-stamp invariant in the
298
+ * module doc).
299
+ *
300
+ * The copy ASSERTS the two-step (review Blocker 2): a malformed Org
301
+ * (`vspPrivateNonprofit` answered without `vsp: true`) throws here rather
302
+ * than being laundered onto the agency.
303
+ */
304
+ declare function mirrorOrgTypeFields(org: OrgTypeFieldsHolder | null | undefined): AgencyOrgTypeFields;
305
+ /**
306
+ * The effective organization-type fields for an agency: the Org's when the
307
+ * agency is LINKED (`organizationId` set) and the Org was loaded; otherwise
308
+ * the agency's own copy (the backfill's confirmed value, until the link
309
+ * exists); `{}` when neither carries anything. No guessing: an unlinked
310
+ * agency with no copy answers nothing, in line with the 2026-10-07 rule that
311
+ * an org → agency read with no clear answer "answers nobody rather than
312
+ * guessing". Every consumer (Thread, PAVE, tooling) goes through this during
313
+ * the interim so the precedence cannot diverge between apps.
314
+ *
315
+ * @param org - The agency's Org document, if the caller joined it (`null` when not loaded / not linked)
316
+ * @param agency - The agency document (its `organizationId` decides "linked")
317
+ */
318
+ declare function resolveEffectiveOrgTypeFields(org: OrgTypeFieldsHolder | null | undefined, agency: (OrgTypeFieldsHolder & {
319
+ organizationId?: unknown;
320
+ }) | null | undefined): AgencyOrgTypeFields;
321
+ /** {@link resolveEffectiveOrgTypeFields}, reduced to the one key readers join on (`null` = un-typed / unresolvable, read as `unknown`). */
322
+ declare function resolveEffectiveOrgType(org: OrgTypeFieldsHolder | null | undefined, agency: (OrgTypeFieldsHolder & {
323
+ organizationId?: unknown;
324
+ }) | null | undefined): AgencyTypeKey | null;
325
+ /**
326
+ * The fields on which the agency's copy differs from its Org — empty when the
327
+ * mirror is faithful. Absent and `null` compare equal to each other (both
328
+ * are "not captured"); any other difference is drift from a writer that
329
+ * skipped the re-stamp. A reader should log it and read the Org.
330
+ */
331
+ declare function orgTypeFieldsDiffer(org: OrgTypeFieldsHolder | null | undefined, agency: OrgTypeFieldsHolder | null | undefined): OrgTypeFieldName[];
332
+ /**
333
+ * Raw (persistence) shape of the organization-type fields. Inferred from the
334
+ * DEFINITION, not from a compiled `Schema` (see `schemas/team.ts` for why),
335
+ * and wrapped in `Partial` because every field is absent on documents that
336
+ * predate them.
337
+ */
338
+ type OrgTypeFields = Partial<InferRawDocType<typeof orgTypeSchemaDefinition>>;
339
+ /** The Agency's mirror has the Org's exact shape. */
340
+ type AgencyOrgTypeFields = OrgTypeFields;
341
+
342
+ export { AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS as A, ORG_TYPE_FIELD_NAMES as O, VSP_TWO_STEP_ISSUE as V, type AddAgencyOrgTypeFieldsOptions as a, type AgencyOrgTypeFields as b, type OrgTypeFieldName as c, type OrgTypeFields as d, type OrgTypeFieldsHolder as e, addAgencyOrgTypeFields as f, addOrgTypeFields as g, agencyOrgTypeSchemaDefinition as h, applyRunValidatorsIfUnset as i, orgTypeSchemaDefinition as j, resolveEffectiveOrgTypeFields as k, vspTwoStepHoldsOnUpdate as l, mirrorOrgTypeFields as m, orgTypeFieldsDiffer as o, resolveEffectiveOrgType as r, vspTwoStepHolds as v };