@htilabs/platform-common-models 0.65.0 → 0.66.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.
@@ -1,6 +1,7 @@
1
- import { b as ProgramReviewStatus } from '../vocabulary-Cxhi9EGt.cjs';
2
- export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, d as PROGRAM_STATUS, e as PROGRAM_STATUS_VALUES, f as ProgramStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus, p as programNameKey } from '../vocabulary-Cxhi9EGt.cjs';
1
+ export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, d as PROGRAM_STATUS, e as PROGRAM_STATUS_VALUES, b as ProgramReviewStatus, f as ProgramStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus, p as programNameKey } from '../vocabulary-Cxhi9EGt.cjs';
3
2
  import { z } from 'zod';
3
+ import { a as OrgReviewStatus } from '../orgRecord-B4-ELaZ_.cjs';
4
+ export { b as ORGANIZATION_BASE_ROW_KEYS, c as ORGANIZATION_ENVELOPE_KEYS, d as ORGANIZATION_ROW_KEYS, e as ORGANIZATION_STATUS, f as ORG_AS_BUILT_FIELD_NAMES, O as ORG_KEY_PATTERN, g as ORG_RECORD_FIELD_NAMES, h as ORG_REVIEW_STATUS, j as ORG_REVIEW_STATUS_VALUES, k as ORG_VSP_TWO_STEP_MESSAGE, l as OrgArrival, n as OrgAsBuiltFieldName, o as OrgIdentityWrite, p as OrgIdentityWriteSchema, q as OrgRecordFieldName, r as OrgVspWrite, s as OrgVspWriteSchema, t as OrganizationRowKey, u as OrganizationStatus, v as isListedOrganization, i as isOrgKey, w as isShortNameOnly, m as mintOrgKey, x as orgArrivalStamp, y as orgCommonName, z as orgDisplayName, A as orgDisplayParts, B as orgLegalName, C as orgParentIssue } from '../orgRecord-B4-ELaZ_.cjs';
4
5
 
5
6
  /**
6
7
  * The stored program row of `organizations.programs[]`, as a Zod schema for
@@ -50,265 +51,6 @@ declare const OrganizationProgramRowSchema: z.ZodObject<{
50
51
  }>;
51
52
  type OrganizationProgramRow = z.infer<typeof OrganizationProgramRowSchema>;
52
53
 
53
- /**
54
- * The Org record: the ONE definition of what an `organizations` row holds
55
- * about an organization, for every app that reads or writes the platform-wide
56
- * registry (Thread, PAVE, the Platform, auth). Pure: no mongoose, no driver.
57
- * The Mongoose twin is `schemas/organization.ts` (`addOrgRecordFields`); a
58
- * package test holds the two key lists equal.
59
- *
60
- * ## Canon
61
- *
62
- * UDD Org Data Object (Notion `7d71ef14abcd832fa3a6816ebe7a5dd9`, § 1 and § 5;
63
- * schema of record hti-features `udd-schemas/org/Org.v1.json`): an Org is one
64
- * real-world organization in the one platform-wide registry. It holds its name
65
- * (legal and common), its acronym, its required type, its parent when it is a
66
- * unit of a larger one, the two HMIS victim-service-provider answers, and how
67
- * it arrived and whether HTI Labs has reviewed it. Crysta, 2026-11-10: "It
68
- * shouldn't be different in thread vs. pave. And the data objects for Org need
69
- * to be the same in both apps."
70
- *
71
- * ## Stored names
72
- *
73
- * The UDD spells these snake_case (`legal_name`, `parent_org_id`, ...). The
74
- * live platform-db writers use camelCase, so the stored names are the UDD's in
75
- * camelCase, as for the org-type fields (`schemas/agency.ts`) and the program
76
- * row (`schemas/organization-program.ts`). Two exceptions. The UDD `acronym` is
77
- * stored as `shortName`: a top-level `acronym` key marks a pre-pl-958 PAVE row
78
- * (`organizationRowShape`), and PAVE 2.0 already writes `shortName`. And the
79
- * UDD `id` (the Org's one identifier, a slug such as `the_spring`) is stored as
80
- * `key`: Mongoose gives every document an `id` of its own (the `_id` as a
81
- * string), and the Admin Hub's curated store already names it `key`.
82
- *
83
- * ## What is NOT here
84
- *
85
- * - `name` and `type`: every writer already stores them. `type` is mid-move
86
- * from the IC-58 number to the CVC-48 key and each app validates the
87
- * transition form itself until the migration has run.
88
- * - The row's tenancy and plumbing (`agencyScope`, `agencyId`, `community`,
89
- * `canonicalKey`, `status`, `programs`, contact fields): unchanged by this
90
- * module. {@link ORGANIZATION_ROW_KEYS} lists them so a model can be checked
91
- * against the whole row.
92
- */
93
-
94
- /**
95
- * Review lifecycle of an organization added from inside an app. The same three
96
- * words, and the same lifecycle, as a program named inside an app (UDD Org
97
- * § 5 "how it arrived"; census item 2: "the same lifecycle a program named
98
- * inside an app has"). Absent on a steward row: nothing to review.
99
- */
100
- declare const ORG_REVIEW_STATUS: {
101
- readonly PENDING: "pending";
102
- readonly CONFIRMED: "confirmed";
103
- readonly REJECTED: "rejected";
104
- };
105
- declare const ORG_REVIEW_STATUS_VALUES: readonly ["pending", "confirmed", "rejected"];
106
- type OrgReviewStatus = ProgramReviewStatus;
107
- /**
108
- * `organizations.status`: 1 active, 2 inactive (soft-deleted; never removed).
109
- * The codes auth, Thread and PAVE already store.
110
- */
111
- declare const ORGANIZATION_STATUS: {
112
- readonly ACTIVE: 1;
113
- readonly INACTIVE: 2;
114
- };
115
- type OrganizationStatus = (typeof ORGANIZATION_STATUS)[keyof typeof ORGANIZATION_STATUS];
116
- /**
117
- * Whether an organization may be OFFERED in a picker: active (an absent
118
- * `status` reads active, as legacy rows carry none) and not declined by HTI
119
- * Labs. A pending organization IS offered: an organization added inside an app
120
- * is available everywhere from the moment it is added (UDD Org § 2 scenario 1).
121
- * A stored reference to an organization that is no longer offered still
122
- * resolves by id.
123
- */
124
- declare function isListedOrganization(row: {
125
- status?: number | null | undefined;
126
- reviewStatus?: string | null | undefined;
127
- }): boolean;
128
- /**
129
- * The Org definition's fields beyond `name` and `type`, in the Mongoose
130
- * fragment's declaration order (`orgRecordSchemaDefinition`).
131
- */
132
- declare const ORG_RECORD_FIELD_NAMES: readonly ["key", "legalName", "commonName", "shortName", "website", "parentOrgId", "vsp", "vspPrivateNonprofit", "reviewStatus", "addedInApp", "addedBy"];
133
- type OrgRecordFieldName = (typeof ORG_RECORD_FIELD_NAMES)[number];
134
- /**
135
- * Stored on the row today and NOT part of the Org definition (UDD Org § 5,
136
- * "As built today, and not part of this definition"; Org.v1's runtime-overlay
137
- * five: `isCustom`, `added_in_session`, `added_by_user_id`, `type_override`,
138
- * `division`). PAVE 2.0 writes them; every model declares
139
- * them so no app silently drops another app's value. `typeKey` is the CVC-48
140
- * key PAVE writes beside a numeric `type` and retires with the type migration.
141
- */
142
- declare const ORG_AS_BUILT_FIELD_NAMES: readonly ["requiresROI", "isCustom", "addedByUserId", "addedInSession", "division", "typeOverride", "typeKey"];
143
- type OrgAsBuiltFieldName = (typeof ORG_AS_BUILT_FIELD_NAMES)[number];
144
- /** The row's keys every writer already stored before this module. */
145
- declare const ORGANIZATION_BASE_ROW_KEYS: readonly ["name", "type", "phones", "emails", "address", "notes", "status", "agencyScope", "agencyId", "community", "canonicalKey", "isAnonymous", "programs"];
146
- /**
147
- * Every top-level key of a shared-shape `organizations` row, the record
148
- * envelope aside. A model that declares exactly these is the same data object
149
- * as every other app's (`organizationSchemaIssues`, `schemas/organization.ts`).
150
- */
151
- declare const ORGANIZATION_ROW_KEYS: readonly ["name", "type", "phones", "emails", "address", "notes", "status", "agencyScope", "agencyId", "community", "canonicalKey", "isAnonymous", "programs", "key", "legalName", "commonName", "shortName", "website", "parentOrgId", "vsp", "vspPrivateNonprofit", "reviewStatus", "addedInApp", "addedBy", "requiresROI", "isCustom", "addedByUserId", "addedInSession", "division", "typeOverride", "typeKey"];
152
- type OrganizationRowKey = (typeof ORGANIZATION_ROW_KEYS)[number];
153
- /** The record envelope each app's base document adds; never Org facts. */
154
- declare const ORGANIZATION_ENVELOPE_KEYS: readonly ["_id", "__v", "_schemaVersion", "createdUser", "createdTime", "updatedUser", "updatedTime"];
155
- /**
156
- * The Org's identifier (UDD Org `id`; stored as `key`): the one value that
157
- * names the same organization in every database, where `_id` is each
158
- * database's own. A lower-case slug: `the_spring`, `ascension_stjohn`,
159
- * `org-custom-8daxtira`, `org-6a1f5dadd0c33a5a149f3413`.
160
- *
161
- * Rules (the curated store's, Kickoff 13 item 3): unique; never changes once
162
- * set; never taken from a request body (`OrgIdentityWriteSchema` is strict and
163
- * does not name it); a new organization's key never encodes its name
164
- * ({@link mintOrgKey}). A row written before 0.65.0 has none until the
165
- * registry fill stamps one from a reviewed sheet.
166
- */
167
- declare const ORG_KEY_PATTERN: RegExp;
168
- /** Whether a value is a well-formed Org identifier. */
169
- declare function isOrgKey(value: unknown): value is string;
170
- /**
171
- * The identifier for an organization created without one (added inside an
172
- * app, or by a steward typing a new organization): `org-<its _id>`. It encodes
173
- * no name, so a later rename never makes it wrong.
174
- */
175
- declare function mintOrgKey(id: string | {
176
- toHexString(): string;
177
- }): string;
178
- /** The two-step message; the same sentence the Mongoose mount throws. */
179
- declare const ORG_VSP_TWO_STEP_MESSAGE = "vspPrivateNonprofit is step 2 of the HMIS VSP two-step and requires vsp: true";
180
- /**
181
- * The identity half of the record, as a request body may carry it. Every key
182
- * is optional (a PATCH names only what it changes); `null` clears a field.
183
- * Strict: an unknown key is refused, so a snake_case spelling never passes as
184
- * a silent no-op.
185
- */
186
- declare const OrgIdentityWriteSchema: z.ZodObject<{
187
- legalName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
188
- commonName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
189
- shortName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
- website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
191
- parentOrgId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
192
- }, "strict", z.ZodTypeAny, {
193
- website?: string | null | undefined;
194
- legalName?: string | null | undefined;
195
- commonName?: string | null | undefined;
196
- shortName?: string | null | undefined;
197
- parentOrgId?: string | null | undefined;
198
- }, {
199
- website?: string | null | undefined;
200
- legalName?: string | null | undefined;
201
- commonName?: string | null | undefined;
202
- shortName?: string | null | undefined;
203
- parentOrgId?: string | null | undefined;
204
- }>;
205
- type OrgIdentityWrite = z.infer<typeof OrgIdentityWriteSchema>;
206
- /**
207
- * The two HMIS victim-service-provider answers. Tri-state: `null` is "not yet
208
- * captured", never a coerced false. Step 2 may be answered only with step 1
209
- * `true` in the same body (an update cannot see the stored row), and a body
210
- * that sets step 1 to `false` or `null` clears step 2 with it. Only HTI Labs
211
- * sets them (UDD Org rulings 2026-10-08 and 2026-10-09); the route decides who
212
- * that is.
213
- */
214
- declare const OrgVspWriteSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
215
- vsp: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
216
- vspPrivateNonprofit: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
217
- }, "strict", z.ZodTypeAny, {
218
- vspPrivateNonprofit?: boolean | null | undefined;
219
- vsp?: boolean | null | undefined;
220
- }, {
221
- vspPrivateNonprofit?: boolean | null | undefined;
222
- vsp?: boolean | null | undefined;
223
- }>, {
224
- vspPrivateNonprofit?: boolean | null | undefined;
225
- vsp?: boolean | null | undefined;
226
- }, {
227
- vspPrivateNonprofit?: boolean | null | undefined;
228
- vsp?: boolean | null | undefined;
229
- }>, {
230
- vspPrivateNonprofit?: boolean | null | undefined;
231
- vsp?: boolean | null | undefined;
232
- }, {
233
- vspPrivateNonprofit?: boolean | null | undefined;
234
- vsp?: boolean | null | undefined;
235
- }>;
236
- type OrgVspWrite = z.infer<typeof OrgVspWriteSchema>;
237
- /**
238
- * How an organization arrived. Never taken from a request body: the server
239
- * stamps it from the authenticated caller ({@link orgArrivalStamp}).
240
- *
241
- * The same three facts, under the same names, as a Program, a Service Listing
242
- * and a Point of contact carry (`added_by` · `added_in_app` · `review_status`;
243
- * UDD ratification request R17, "how an organization arrived"). The older
244
- * runtime-overlay names on the row (`addedByUserId`, `isCustom`) are as-built
245
- * extras; `addedInSession` is carried as on the program row.
246
- */
247
- interface OrgArrival {
248
- reviewStatus: OrgReviewStatus;
249
- /** The app the organization was added in: `thread`, `pave`, `leads`, `platform`. */
250
- addedInApp: string;
251
- /** The adding user's platform `users._id`, as a string. */
252
- addedBy: string;
253
- /** The session it was added in, when there was one. */
254
- addedInSession?: string;
255
- }
256
- /**
257
- * The arrival stamp for an organization a user adds from inside an app: it is
258
- * on the list at once and waits for HTI Labs' review (UDD Org § 2 scenario 5;
259
- * census item 2). A steward's own add carries no stamp.
260
- */
261
- declare function orgArrivalStamp(input: {
262
- app: string;
263
- userId: string;
264
- sessionId?: string | null | undefined;
265
- }): OrgArrival;
266
- interface OrgNames {
267
- name?: string | null | undefined;
268
- commonName?: string | null | undefined;
269
- legalName?: string | null | undefined;
270
- shortName?: string | null | undefined;
271
- }
272
- /**
273
- * The name to use when a sentence or a label names an organization: its common
274
- * name when it has one, else its name. Canon: the prototype's contact-history
275
- * register and referral wording (`org.common_name || org.name`).
276
- */
277
- declare function orgCommonName(org: OrgNames | null | undefined): string;
278
- /**
279
- * The name a report to a funder or HMIS uses: the legal name when captured,
280
- * else the name (Org.v1 `legal_name`: "consumers fall back to name when blank").
281
- */
282
- declare function orgLegalName(org: OrgNames | null | undefined): string;
283
- /** Whether a row's name is nothing but its short name ("ASJS" named "ASJS"). */
284
- declare function isShortNameOnly(org: OrgNames | null | undefined): boolean;
285
- /**
286
- * How a unit of a larger organization reads: its own name, and "<parent> unit"
287
- * beneath it when the unit has no name beyond its short name (Crysta
288
- * 2026-09-03, "No names yet — show the parent"). A row with a real name keeps
289
- * it. Canon: the prototype's one resolver, `orgDisplayParts`.
290
- */
291
- declare function orgDisplayParts(org: OrgNames | null | undefined, parent: OrgNames | null | undefined): {
292
- name: string;
293
- sub: string;
294
- };
295
- /** {@link orgDisplayParts} on one line: "ASJS · Ascension St. John Medical Center unit". */
296
- declare function orgDisplayName(org: OrgNames | null | undefined, parent?: OrgNames | null | undefined): string;
297
- /**
298
- * Why `parentOrgId` may not be set to this value, or null when it may. One
299
- * level only (the picker folds units under their organization): an
300
- * organization is never its own parent, a parent is not itself a unit, and an
301
- * organization that has units cannot become one.
302
- */
303
- declare function orgParentIssue(input: {
304
- orgId: string | null | undefined;
305
- parentOrgId: string | null | undefined;
306
- /** The proposed parent's own `parentOrgId`, when the parent row was read. */
307
- parentsParentOrgId?: string | null | undefined;
308
- /** Whether any organization already names `orgId` as its parent. */
309
- hasUnits?: boolean | undefined;
310
- }): "self" | "parent_is_unit" | "org_has_units" | null;
311
-
312
54
  /**
313
55
  * Read rules for the platform-db org directory: which row shape a document
314
56
  * is, when an organization is an agency's OWN record, and the normalised read
@@ -458,4 +200,4 @@ declare function readDirectoryOrganization(db: OrgDirectoryDbLike, id: string |
458
200
  */
459
201
  declare function readAgencyOwnOrganization(db: OrgDirectoryDbLike, agencyId: string | ObjectIdLike, opts?: OrgDirectoryReadOptions): Promise<DirectoryOrganizationView | null>;
460
202
 
461
- export { AGENCIES_COLLECTION, type DirectoryOrganizationView, type DirectoryProgramView, ORGANIZATIONS_COLLECTION, ORGANIZATION_BASE_ROW_KEYS, ORGANIZATION_ENVELOPE_KEYS, ORGANIZATION_PROGRAM_ROW_KEYS, ORGANIZATION_ROW_KEYS, ORGANIZATION_STATUS, ORG_AS_BUILT_FIELD_NAMES, ORG_KEY_PATTERN, ORG_RECORD_FIELD_NAMES, ORG_REVIEW_STATUS, ORG_REVIEW_STATUS_VALUES, ORG_VSP_TWO_STEP_MESSAGE, type ObjectIdLike, type OrgArrival, type OrgAsBuiltFieldName, type OrgDirectoryDbLike, type OrgDirectoryReadOptions, type OrgIdentityWrite, OrgIdentityWriteSchema, type OrgRecordFieldName, type OrgReviewStatus, type OrgVspWrite, OrgVspWriteSchema, type OrganizationProgramRow, type OrganizationProgramRowKey, OrganizationProgramRowSchema, type OrganizationRowKey, type OrganizationRowShape, type OrganizationStatus, ProgramReviewStatus, directoryIdString, isAgencyOwnOrganization, isListedOrganization, isOrgKey, isShortNameOnly, mintOrgKey, orgArrivalStamp, orgCommonName, orgDisplayName, orgDisplayParts, orgLegalName, orgParentIssue, organizationIdForms, organizationRowShape, readAgencyOwnOrganization, readDirectoryOrganization, sameDirectoryId, toDirectoryOrganizationView, toDirectoryProgramView };
203
+ export { AGENCIES_COLLECTION, type DirectoryOrganizationView, type DirectoryProgramView, ORGANIZATIONS_COLLECTION, ORGANIZATION_PROGRAM_ROW_KEYS, type ObjectIdLike, type OrgDirectoryDbLike, type OrgDirectoryReadOptions, OrgReviewStatus, type OrganizationProgramRow, type OrganizationProgramRowKey, OrganizationProgramRowSchema, type OrganizationRowShape, directoryIdString, isAgencyOwnOrganization, organizationIdForms, organizationRowShape, readAgencyOwnOrganization, readDirectoryOrganization, sameDirectoryId, toDirectoryOrganizationView, toDirectoryProgramView };
@@ -1,6 +1,7 @@
1
- import { b as ProgramReviewStatus } from '../vocabulary-Cxhi9EGt.js';
2
- export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, d as PROGRAM_STATUS, e as PROGRAM_STATUS_VALUES, f as ProgramStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus, p as programNameKey } from '../vocabulary-Cxhi9EGt.js';
1
+ export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, d as PROGRAM_STATUS, e as PROGRAM_STATUS_VALUES, b as ProgramReviewStatus, f as ProgramStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus, p as programNameKey } from '../vocabulary-Cxhi9EGt.js';
3
2
  import { z } from 'zod';
3
+ import { a as OrgReviewStatus } from '../orgRecord-h3Z-V23F.js';
4
+ export { b as ORGANIZATION_BASE_ROW_KEYS, c as ORGANIZATION_ENVELOPE_KEYS, d as ORGANIZATION_ROW_KEYS, e as ORGANIZATION_STATUS, f as ORG_AS_BUILT_FIELD_NAMES, O as ORG_KEY_PATTERN, g as ORG_RECORD_FIELD_NAMES, h as ORG_REVIEW_STATUS, j as ORG_REVIEW_STATUS_VALUES, k as ORG_VSP_TWO_STEP_MESSAGE, l as OrgArrival, n as OrgAsBuiltFieldName, o as OrgIdentityWrite, p as OrgIdentityWriteSchema, q as OrgRecordFieldName, r as OrgVspWrite, s as OrgVspWriteSchema, t as OrganizationRowKey, u as OrganizationStatus, v as isListedOrganization, i as isOrgKey, w as isShortNameOnly, m as mintOrgKey, x as orgArrivalStamp, y as orgCommonName, z as orgDisplayName, A as orgDisplayParts, B as orgLegalName, C as orgParentIssue } from '../orgRecord-h3Z-V23F.js';
4
5
 
5
6
  /**
6
7
  * The stored program row of `organizations.programs[]`, as a Zod schema for
@@ -50,265 +51,6 @@ declare const OrganizationProgramRowSchema: z.ZodObject<{
50
51
  }>;
51
52
  type OrganizationProgramRow = z.infer<typeof OrganizationProgramRowSchema>;
52
53
 
53
- /**
54
- * The Org record: the ONE definition of what an `organizations` row holds
55
- * about an organization, for every app that reads or writes the platform-wide
56
- * registry (Thread, PAVE, the Platform, auth). Pure: no mongoose, no driver.
57
- * The Mongoose twin is `schemas/organization.ts` (`addOrgRecordFields`); a
58
- * package test holds the two key lists equal.
59
- *
60
- * ## Canon
61
- *
62
- * UDD Org Data Object (Notion `7d71ef14abcd832fa3a6816ebe7a5dd9`, § 1 and § 5;
63
- * schema of record hti-features `udd-schemas/org/Org.v1.json`): an Org is one
64
- * real-world organization in the one platform-wide registry. It holds its name
65
- * (legal and common), its acronym, its required type, its parent when it is a
66
- * unit of a larger one, the two HMIS victim-service-provider answers, and how
67
- * it arrived and whether HTI Labs has reviewed it. Crysta, 2026-11-10: "It
68
- * shouldn't be different in thread vs. pave. And the data objects for Org need
69
- * to be the same in both apps."
70
- *
71
- * ## Stored names
72
- *
73
- * The UDD spells these snake_case (`legal_name`, `parent_org_id`, ...). The
74
- * live platform-db writers use camelCase, so the stored names are the UDD's in
75
- * camelCase, as for the org-type fields (`schemas/agency.ts`) and the program
76
- * row (`schemas/organization-program.ts`). Two exceptions. The UDD `acronym` is
77
- * stored as `shortName`: a top-level `acronym` key marks a pre-pl-958 PAVE row
78
- * (`organizationRowShape`), and PAVE 2.0 already writes `shortName`. And the
79
- * UDD `id` (the Org's one identifier, a slug such as `the_spring`) is stored as
80
- * `key`: Mongoose gives every document an `id` of its own (the `_id` as a
81
- * string), and the Admin Hub's curated store already names it `key`.
82
- *
83
- * ## What is NOT here
84
- *
85
- * - `name` and `type`: every writer already stores them. `type` is mid-move
86
- * from the IC-58 number to the CVC-48 key and each app validates the
87
- * transition form itself until the migration has run.
88
- * - The row's tenancy and plumbing (`agencyScope`, `agencyId`, `community`,
89
- * `canonicalKey`, `status`, `programs`, contact fields): unchanged by this
90
- * module. {@link ORGANIZATION_ROW_KEYS} lists them so a model can be checked
91
- * against the whole row.
92
- */
93
-
94
- /**
95
- * Review lifecycle of an organization added from inside an app. The same three
96
- * words, and the same lifecycle, as a program named inside an app (UDD Org
97
- * § 5 "how it arrived"; census item 2: "the same lifecycle a program named
98
- * inside an app has"). Absent on a steward row: nothing to review.
99
- */
100
- declare const ORG_REVIEW_STATUS: {
101
- readonly PENDING: "pending";
102
- readonly CONFIRMED: "confirmed";
103
- readonly REJECTED: "rejected";
104
- };
105
- declare const ORG_REVIEW_STATUS_VALUES: readonly ["pending", "confirmed", "rejected"];
106
- type OrgReviewStatus = ProgramReviewStatus;
107
- /**
108
- * `organizations.status`: 1 active, 2 inactive (soft-deleted; never removed).
109
- * The codes auth, Thread and PAVE already store.
110
- */
111
- declare const ORGANIZATION_STATUS: {
112
- readonly ACTIVE: 1;
113
- readonly INACTIVE: 2;
114
- };
115
- type OrganizationStatus = (typeof ORGANIZATION_STATUS)[keyof typeof ORGANIZATION_STATUS];
116
- /**
117
- * Whether an organization may be OFFERED in a picker: active (an absent
118
- * `status` reads active, as legacy rows carry none) and not declined by HTI
119
- * Labs. A pending organization IS offered: an organization added inside an app
120
- * is available everywhere from the moment it is added (UDD Org § 2 scenario 1).
121
- * A stored reference to an organization that is no longer offered still
122
- * resolves by id.
123
- */
124
- declare function isListedOrganization(row: {
125
- status?: number | null | undefined;
126
- reviewStatus?: string | null | undefined;
127
- }): boolean;
128
- /**
129
- * The Org definition's fields beyond `name` and `type`, in the Mongoose
130
- * fragment's declaration order (`orgRecordSchemaDefinition`).
131
- */
132
- declare const ORG_RECORD_FIELD_NAMES: readonly ["key", "legalName", "commonName", "shortName", "website", "parentOrgId", "vsp", "vspPrivateNonprofit", "reviewStatus", "addedInApp", "addedBy"];
133
- type OrgRecordFieldName = (typeof ORG_RECORD_FIELD_NAMES)[number];
134
- /**
135
- * Stored on the row today and NOT part of the Org definition (UDD Org § 5,
136
- * "As built today, and not part of this definition"; Org.v1's runtime-overlay
137
- * five: `isCustom`, `added_in_session`, `added_by_user_id`, `type_override`,
138
- * `division`). PAVE 2.0 writes them; every model declares
139
- * them so no app silently drops another app's value. `typeKey` is the CVC-48
140
- * key PAVE writes beside a numeric `type` and retires with the type migration.
141
- */
142
- declare const ORG_AS_BUILT_FIELD_NAMES: readonly ["requiresROI", "isCustom", "addedByUserId", "addedInSession", "division", "typeOverride", "typeKey"];
143
- type OrgAsBuiltFieldName = (typeof ORG_AS_BUILT_FIELD_NAMES)[number];
144
- /** The row's keys every writer already stored before this module. */
145
- declare const ORGANIZATION_BASE_ROW_KEYS: readonly ["name", "type", "phones", "emails", "address", "notes", "status", "agencyScope", "agencyId", "community", "canonicalKey", "isAnonymous", "programs"];
146
- /**
147
- * Every top-level key of a shared-shape `organizations` row, the record
148
- * envelope aside. A model that declares exactly these is the same data object
149
- * as every other app's (`organizationSchemaIssues`, `schemas/organization.ts`).
150
- */
151
- declare const ORGANIZATION_ROW_KEYS: readonly ["name", "type", "phones", "emails", "address", "notes", "status", "agencyScope", "agencyId", "community", "canonicalKey", "isAnonymous", "programs", "key", "legalName", "commonName", "shortName", "website", "parentOrgId", "vsp", "vspPrivateNonprofit", "reviewStatus", "addedInApp", "addedBy", "requiresROI", "isCustom", "addedByUserId", "addedInSession", "division", "typeOverride", "typeKey"];
152
- type OrganizationRowKey = (typeof ORGANIZATION_ROW_KEYS)[number];
153
- /** The record envelope each app's base document adds; never Org facts. */
154
- declare const ORGANIZATION_ENVELOPE_KEYS: readonly ["_id", "__v", "_schemaVersion", "createdUser", "createdTime", "updatedUser", "updatedTime"];
155
- /**
156
- * The Org's identifier (UDD Org `id`; stored as `key`): the one value that
157
- * names the same organization in every database, where `_id` is each
158
- * database's own. A lower-case slug: `the_spring`, `ascension_stjohn`,
159
- * `org-custom-8daxtira`, `org-6a1f5dadd0c33a5a149f3413`.
160
- *
161
- * Rules (the curated store's, Kickoff 13 item 3): unique; never changes once
162
- * set; never taken from a request body (`OrgIdentityWriteSchema` is strict and
163
- * does not name it); a new organization's key never encodes its name
164
- * ({@link mintOrgKey}). A row written before 0.65.0 has none until the
165
- * registry fill stamps one from a reviewed sheet.
166
- */
167
- declare const ORG_KEY_PATTERN: RegExp;
168
- /** Whether a value is a well-formed Org identifier. */
169
- declare function isOrgKey(value: unknown): value is string;
170
- /**
171
- * The identifier for an organization created without one (added inside an
172
- * app, or by a steward typing a new organization): `org-<its _id>`. It encodes
173
- * no name, so a later rename never makes it wrong.
174
- */
175
- declare function mintOrgKey(id: string | {
176
- toHexString(): string;
177
- }): string;
178
- /** The two-step message; the same sentence the Mongoose mount throws. */
179
- declare const ORG_VSP_TWO_STEP_MESSAGE = "vspPrivateNonprofit is step 2 of the HMIS VSP two-step and requires vsp: true";
180
- /**
181
- * The identity half of the record, as a request body may carry it. Every key
182
- * is optional (a PATCH names only what it changes); `null` clears a field.
183
- * Strict: an unknown key is refused, so a snake_case spelling never passes as
184
- * a silent no-op.
185
- */
186
- declare const OrgIdentityWriteSchema: z.ZodObject<{
187
- legalName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
188
- commonName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
189
- shortName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
- website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
191
- parentOrgId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
192
- }, "strict", z.ZodTypeAny, {
193
- website?: string | null | undefined;
194
- legalName?: string | null | undefined;
195
- commonName?: string | null | undefined;
196
- shortName?: string | null | undefined;
197
- parentOrgId?: string | null | undefined;
198
- }, {
199
- website?: string | null | undefined;
200
- legalName?: string | null | undefined;
201
- commonName?: string | null | undefined;
202
- shortName?: string | null | undefined;
203
- parentOrgId?: string | null | undefined;
204
- }>;
205
- type OrgIdentityWrite = z.infer<typeof OrgIdentityWriteSchema>;
206
- /**
207
- * The two HMIS victim-service-provider answers. Tri-state: `null` is "not yet
208
- * captured", never a coerced false. Step 2 may be answered only with step 1
209
- * `true` in the same body (an update cannot see the stored row), and a body
210
- * that sets step 1 to `false` or `null` clears step 2 with it. Only HTI Labs
211
- * sets them (UDD Org rulings 2026-10-08 and 2026-10-09); the route decides who
212
- * that is.
213
- */
214
- declare const OrgVspWriteSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
215
- vsp: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
216
- vspPrivateNonprofit: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
217
- }, "strict", z.ZodTypeAny, {
218
- vspPrivateNonprofit?: boolean | null | undefined;
219
- vsp?: boolean | null | undefined;
220
- }, {
221
- vspPrivateNonprofit?: boolean | null | undefined;
222
- vsp?: boolean | null | undefined;
223
- }>, {
224
- vspPrivateNonprofit?: boolean | null | undefined;
225
- vsp?: boolean | null | undefined;
226
- }, {
227
- vspPrivateNonprofit?: boolean | null | undefined;
228
- vsp?: boolean | null | undefined;
229
- }>, {
230
- vspPrivateNonprofit?: boolean | null | undefined;
231
- vsp?: boolean | null | undefined;
232
- }, {
233
- vspPrivateNonprofit?: boolean | null | undefined;
234
- vsp?: boolean | null | undefined;
235
- }>;
236
- type OrgVspWrite = z.infer<typeof OrgVspWriteSchema>;
237
- /**
238
- * How an organization arrived. Never taken from a request body: the server
239
- * stamps it from the authenticated caller ({@link orgArrivalStamp}).
240
- *
241
- * The same three facts, under the same names, as a Program, a Service Listing
242
- * and a Point of contact carry (`added_by` · `added_in_app` · `review_status`;
243
- * UDD ratification request R17, "how an organization arrived"). The older
244
- * runtime-overlay names on the row (`addedByUserId`, `isCustom`) are as-built
245
- * extras; `addedInSession` is carried as on the program row.
246
- */
247
- interface OrgArrival {
248
- reviewStatus: OrgReviewStatus;
249
- /** The app the organization was added in: `thread`, `pave`, `leads`, `platform`. */
250
- addedInApp: string;
251
- /** The adding user's platform `users._id`, as a string. */
252
- addedBy: string;
253
- /** The session it was added in, when there was one. */
254
- addedInSession?: string;
255
- }
256
- /**
257
- * The arrival stamp for an organization a user adds from inside an app: it is
258
- * on the list at once and waits for HTI Labs' review (UDD Org § 2 scenario 5;
259
- * census item 2). A steward's own add carries no stamp.
260
- */
261
- declare function orgArrivalStamp(input: {
262
- app: string;
263
- userId: string;
264
- sessionId?: string | null | undefined;
265
- }): OrgArrival;
266
- interface OrgNames {
267
- name?: string | null | undefined;
268
- commonName?: string | null | undefined;
269
- legalName?: string | null | undefined;
270
- shortName?: string | null | undefined;
271
- }
272
- /**
273
- * The name to use when a sentence or a label names an organization: its common
274
- * name when it has one, else its name. Canon: the prototype's contact-history
275
- * register and referral wording (`org.common_name || org.name`).
276
- */
277
- declare function orgCommonName(org: OrgNames | null | undefined): string;
278
- /**
279
- * The name a report to a funder or HMIS uses: the legal name when captured,
280
- * else the name (Org.v1 `legal_name`: "consumers fall back to name when blank").
281
- */
282
- declare function orgLegalName(org: OrgNames | null | undefined): string;
283
- /** Whether a row's name is nothing but its short name ("ASJS" named "ASJS"). */
284
- declare function isShortNameOnly(org: OrgNames | null | undefined): boolean;
285
- /**
286
- * How a unit of a larger organization reads: its own name, and "<parent> unit"
287
- * beneath it when the unit has no name beyond its short name (Crysta
288
- * 2026-09-03, "No names yet — show the parent"). A row with a real name keeps
289
- * it. Canon: the prototype's one resolver, `orgDisplayParts`.
290
- */
291
- declare function orgDisplayParts(org: OrgNames | null | undefined, parent: OrgNames | null | undefined): {
292
- name: string;
293
- sub: string;
294
- };
295
- /** {@link orgDisplayParts} on one line: "ASJS · Ascension St. John Medical Center unit". */
296
- declare function orgDisplayName(org: OrgNames | null | undefined, parent?: OrgNames | null | undefined): string;
297
- /**
298
- * Why `parentOrgId` may not be set to this value, or null when it may. One
299
- * level only (the picker folds units under their organization): an
300
- * organization is never its own parent, a parent is not itself a unit, and an
301
- * organization that has units cannot become one.
302
- */
303
- declare function orgParentIssue(input: {
304
- orgId: string | null | undefined;
305
- parentOrgId: string | null | undefined;
306
- /** The proposed parent's own `parentOrgId`, when the parent row was read. */
307
- parentsParentOrgId?: string | null | undefined;
308
- /** Whether any organization already names `orgId` as its parent. */
309
- hasUnits?: boolean | undefined;
310
- }): "self" | "parent_is_unit" | "org_has_units" | null;
311
-
312
54
  /**
313
55
  * Read rules for the platform-db org directory: which row shape a document
314
56
  * is, when an organization is an agency's OWN record, and the normalised read
@@ -458,4 +200,4 @@ declare function readDirectoryOrganization(db: OrgDirectoryDbLike, id: string |
458
200
  */
459
201
  declare function readAgencyOwnOrganization(db: OrgDirectoryDbLike, agencyId: string | ObjectIdLike, opts?: OrgDirectoryReadOptions): Promise<DirectoryOrganizationView | null>;
460
202
 
461
- export { AGENCIES_COLLECTION, type DirectoryOrganizationView, type DirectoryProgramView, ORGANIZATIONS_COLLECTION, ORGANIZATION_BASE_ROW_KEYS, ORGANIZATION_ENVELOPE_KEYS, ORGANIZATION_PROGRAM_ROW_KEYS, ORGANIZATION_ROW_KEYS, ORGANIZATION_STATUS, ORG_AS_BUILT_FIELD_NAMES, ORG_KEY_PATTERN, ORG_RECORD_FIELD_NAMES, ORG_REVIEW_STATUS, ORG_REVIEW_STATUS_VALUES, ORG_VSP_TWO_STEP_MESSAGE, type ObjectIdLike, type OrgArrival, type OrgAsBuiltFieldName, type OrgDirectoryDbLike, type OrgDirectoryReadOptions, type OrgIdentityWrite, OrgIdentityWriteSchema, type OrgRecordFieldName, type OrgReviewStatus, type OrgVspWrite, OrgVspWriteSchema, type OrganizationProgramRow, type OrganizationProgramRowKey, OrganizationProgramRowSchema, type OrganizationRowKey, type OrganizationRowShape, type OrganizationStatus, ProgramReviewStatus, directoryIdString, isAgencyOwnOrganization, isListedOrganization, isOrgKey, isShortNameOnly, mintOrgKey, orgArrivalStamp, orgCommonName, orgDisplayName, orgDisplayParts, orgLegalName, orgParentIssue, organizationIdForms, organizationRowShape, readAgencyOwnOrganization, readDirectoryOrganization, sameDirectoryId, toDirectoryOrganizationView, toDirectoryProgramView };
203
+ export { AGENCIES_COLLECTION, type DirectoryOrganizationView, type DirectoryProgramView, ORGANIZATIONS_COLLECTION, ORGANIZATION_PROGRAM_ROW_KEYS, type ObjectIdLike, type OrgDirectoryDbLike, type OrgDirectoryReadOptions, OrgReviewStatus, type OrganizationProgramRow, type OrganizationProgramRowKey, OrganizationProgramRowSchema, type OrganizationRowShape, directoryIdString, isAgencyOwnOrganization, organizationIdForms, organizationRowShape, readAgencyOwnOrganization, readDirectoryOrganization, sameDirectoryId, toDirectoryOrganizationView, toDirectoryProgramView };