@htilabs/platform-common-models 0.12.2 → 0.12.4

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 (54) hide show
  1. package/dist/cvcs/index.cjs +170 -21
  2. package/dist/cvcs/index.cjs.map +1 -1
  3. package/dist/cvcs/index.d.cts +182 -27
  4. package/dist/cvcs/index.d.ts +182 -27
  5. package/dist/cvcs/index.js +170 -21
  6. package/dist/cvcs/index.js.map +1 -1
  7. package/dist/enums/index.cjs +2 -0
  8. package/dist/enums/index.cjs.map +1 -1
  9. package/dist/enums/index.d.cts +5 -3
  10. package/dist/enums/index.d.ts +5 -3
  11. package/dist/enums/index.js +2 -0
  12. package/dist/enums/index.js.map +1 -1
  13. package/dist/{index-4DiJrn7y.d.ts → index-C0J3f169.d.ts} +1 -1
  14. package/dist/{index-qreOzXYS.d.cts → index-EPjPjR0z.d.cts} +1 -1
  15. package/dist/index.cjs +227 -28
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +4 -4
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +222 -28
  20. package/dist/index.js.map +1 -1
  21. package/dist/models/index.d.cts +2 -2
  22. package/dist/models/index.d.ts +2 -2
  23. package/dist/schemas/index.cjs +41 -7
  24. package/dist/schemas/index.cjs.map +1 -1
  25. package/dist/schemas/index.d.cts +130 -26
  26. package/dist/schemas/index.d.ts +130 -26
  27. package/dist/schemas/index.js +38 -7
  28. package/dist/schemas/index.js.map +1 -1
  29. package/dist/{cvc-Cp4uWnAa.d.cts → team-C4LJ5Tex.d.cts} +36 -1
  30. package/dist/{cvc-Cp4uWnAa.d.ts → team-C4LJ5Tex.d.ts} +36 -1
  31. package/dist/validation/index.cjs +155 -0
  32. package/dist/validation/index.cjs.map +1 -1
  33. package/dist/validation/index.d.cts +1 -1
  34. package/dist/validation/index.d.ts +1 -1
  35. package/dist/validation/index.js +153 -0
  36. package/dist/validation/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/__tests__/__snapshots__/cvc-sot.snap +5 -1
  39. package/src/__tests__/core-information-scope-invariant.test.ts +179 -2
  40. package/src/__tests__/cvc-sot-snapshot.test.ts +10 -0
  41. package/src/__tests__/cvc-structural.test.ts +3 -0
  42. package/src/__tests__/location-type-routing-invariant.test.ts +202 -0
  43. package/src/__tests__/team-directory-fields.test.ts +252 -0
  44. package/src/cvcs/coreInformationScope.v1.0.0.json +39 -5
  45. package/src/cvcs/index.ts +3 -0
  46. package/src/cvcs/locationType.v1.0.0.json +131 -16
  47. package/src/generated/cvc-enums.ts +5 -3
  48. package/src/index.ts +7 -0
  49. package/src/schemas/index.ts +8 -0
  50. package/src/schemas/team.ts +118 -0
  51. package/src/validation/index.ts +1 -0
  52. package/src/validation/team.ts +48 -0
  53. package/dist/{cvcEntry-ctHTp2df.d.cts → cvcEntry-DaDrEuTa.d.cts} +8 -8
  54. package/dist/{cvcEntry-ctHTp2df.d.ts → cvcEntry-DaDrEuTa.d.ts} +8 -8
@@ -1,6 +1,6 @@
1
1
  import * as mongoose from 'mongoose';
2
2
  import { InferRawDocType, Schema } from 'mongoose';
3
- export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-ctHTp2df.cjs';
3
+ export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DaDrEuTa.cjs';
4
4
 
5
5
  declare const addressSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
6
6
  _id: false;
@@ -132,12 +132,12 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
132
132
  number?: string | null | undefined;
133
133
  type?: string | null | undefined;
134
134
  safeToContact?: boolean | null | undefined;
135
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
135
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
136
136
  }, mongoose.Document<unknown, {}, {
137
137
  number?: string | null | undefined;
138
138
  type?: string | null | undefined;
139
139
  safeToContact?: boolean | null | undefined;
140
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
140
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
141
141
  }, {
142
142
  id: string;
143
143
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -146,7 +146,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
146
146
  number?: string | null | undefined;
147
147
  type?: string | null | undefined;
148
148
  safeToContact?: boolean | null | undefined;
149
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
149
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
150
150
  } & {
151
151
  _id: mongoose.Types.ObjectId;
152
152
  } & {
@@ -157,7 +157,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
157
157
  number?: string | null | undefined;
158
158
  type?: string | null | undefined;
159
159
  safeToContact?: boolean | null | undefined;
160
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
160
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
161
161
  } & {
162
162
  _id: mongoose.Types.ObjectId;
163
163
  } & {
@@ -219,11 +219,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
219
219
  raceOtherText?: string | null | undefined;
220
220
  genderOtherText?: string | null | undefined;
221
221
  accommodationOtherText?: string | null | undefined;
222
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
223
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
224
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
225
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
226
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
222
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
223
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
224
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
225
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
226
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
227
227
  }, mongoose.Document<unknown, {}, {
228
228
  race: number[];
229
229
  ethnicity: number[];
@@ -243,11 +243,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
243
243
  raceOtherText?: string | null | undefined;
244
244
  genderOtherText?: string | null | undefined;
245
245
  accommodationOtherText?: string | null | undefined;
246
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
247
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
248
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
249
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
250
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
246
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
247
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
248
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
249
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
250
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
251
251
  }, {
252
252
  id: string;
253
253
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -271,11 +271,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
271
271
  raceOtherText?: string | null | undefined;
272
272
  genderOtherText?: string | null | undefined;
273
273
  accommodationOtherText?: string | null | undefined;
274
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
275
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
276
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
277
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
278
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
274
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
275
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
276
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
277
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
278
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
279
279
  } & {
280
280
  _id: mongoose.Types.ObjectId;
281
281
  } & {
@@ -301,11 +301,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
301
301
  raceOtherText?: string | null | undefined;
302
302
  genderOtherText?: string | null | undefined;
303
303
  accommodationOtherText?: string | null | undefined;
304
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
305
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
306
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
307
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
308
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
304
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
305
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
306
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
307
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
308
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
309
309
  } & {
310
310
  _id: mongoose.Types.ObjectId;
311
311
  } & {
@@ -313,4 +313,108 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
313
313
  }>;
314
314
  type Demographics = InferRawDocType<typeof demographicsSchema>;
315
315
 
316
- export { type Address, type Demographics, type Email, type PersonName, type Phone, addressSchema, demographicsSchema, emailSchema, personNameSchema, phoneSchema };
316
+ /**
317
+ * @htilabs/platform-common-models — Team directory fields
318
+ *
319
+ * Shared, additive fields for the platform-db `teams` collection that the
320
+ * Thread→PAVE "Refer to intake" preset reads to resolve the own-agency PAVE
321
+ * intake team.
322
+ *
323
+ * ## This is a FRAGMENT, not a Team model
324
+ *
325
+ * No canonical Team schema exists in this package. The `teams` collection is
326
+ * defined by legacy PAVE (`screening-tools` `models/teamModel.js`,
327
+ * `agencyManagementDb`), mirrored by Thread
328
+ * (`packages/db/src/models/platform/Team.ts`), written by the platform Admin
329
+ * Hub and identity sync, and read raw by pave-2.0 (`lookups/teamGraph.ts`).
330
+ * Declaring the whole Team contract here would mean resolving those shapes,
331
+ * which is out of scope. This module only declares the fields the referral
332
+ * preset needs. Each consumer adds them to its own team schema with
333
+ * {@link addTeamDirectoryFields}, or spreads {@link teamDirectorySchemaDefinition}.
334
+ *
335
+ * ## Canon
336
+ *
337
+ * Prototype `origin/main` @ `c658d6f7`:
338
+ * - `KICKOFF_SHARE_EDGE_CONVERGENCE_2026-09-29.md` § 2.8 L254-257: the intake
339
+ * team is resolved from the sending program's `can_refer_to` targets
340
+ * first, then from the default-share-team ladder restricted to PAVE teams.
341
+ * A referral to intake never routes back to the sender.
342
+ * - Monolith `HTI-LEADS-PAVE-Thread-prototype.html` L323796-323832
343
+ * (`resolveIntakeTeamMono`), directory `programs[]` L142246-142431 and
344
+ * `teams[]` from L142584.
345
+ *
346
+ * Thread ADR: `docs/ADR-THREAD-PAVE-CASESHARE-CONVERGENCE.md` D1 and staging
347
+ * row .2 (consumer th-ng838.2). PAVE consumer: pv-p6share-thread-ingest-v4.
348
+ *
349
+ * ## Divergences from canon (deliberate)
350
+ *
351
+ * 1. **`apps`, not `apps_used`.** Canon's team rows carry lowercase
352
+ * `apps_used` (`"pave"`). The live platform-db writers already stamp
353
+ * `apps` with the uppercase {@link PLATFORM_TOOL} codes on agencies,
354
+ * accounts, users and teams (platform `lib/sync/upserts.ts`,
355
+ * `$addToSet: { apps: APP }` with `APP = source.toUpperCase()`). This
356
+ * field matches that convention exactly.
357
+ * 2. **`canReferTo` lives on the team.** Canon carries `can_refer_to` on a
358
+ * first-class PROGRAM row (`programs[]`, one `team_id` per program), and
359
+ * its targets are PROGRAM ids. No Program model exists in this package or
360
+ * in platform-db, so the targets are carried here as TEAM ids on the
361
+ * sending team. Canon's resolver maps each target program to its single
362
+ * team before using it, so the resolved team is the same. If a Program
363
+ * model lands later, `canReferTo` should move onto it.
364
+ */
365
+
366
+ /** Mongoose model name every app registers the `teams` collection under. */
367
+ declare const TEAM_MODEL_NAME: "Team";
368
+ /**
369
+ * The directory fields to add to a team schema.
370
+ *
371
+ * Both are OPTIONAL and default to `undefined`, not `[]`. A team document
372
+ * written before these fields existed hydrates and re-saves without gaining
373
+ * an `apps` or `canReferTo` key. That keeps "not declared" (absent) distinct
374
+ * from "declared empty" (`[]`).
375
+ */
376
+ declare const teamDirectorySchemaDefinition: {
377
+ /**
378
+ * The platform apps this team works in, as {@link PLATFORM_TOOL} codes
379
+ * (`"PAVE"`, `"THREAD"`, `"LEADS"`, ...). The referral preset only resolves
380
+ * to a team whose `apps` includes `"PAVE"`.
381
+ */
382
+ apps: {
383
+ type: StringConstructor[];
384
+ enum: ("THREAD" | "PAVE" | "ECHO" | "LEADS" | "TRAIL" | "PLATFORM")[];
385
+ default: undefined;
386
+ };
387
+ /**
388
+ * The teams this team refers to, in priority order. The resolver takes the
389
+ * first active target that works in PAVE and is not the sending team itself.
390
+ */
391
+ canReferTo: {
392
+ type: {
393
+ type: typeof Schema.Types.ObjectId;
394
+ ref: "Team";
395
+ }[];
396
+ default: undefined;
397
+ };
398
+ };
399
+ /**
400
+ * Add the team directory fields to an existing team schema.
401
+ *
402
+ * Adds no indexes and no hooks. Indexes on the shared `teams` collection
403
+ * stay with the collection's owner.
404
+ *
405
+ * @param schema - The consumer's team schema
406
+ * @returns The same schema, for chaining
407
+ */
408
+ declare function addTeamDirectoryFields<S extends Schema>(schema: S): S;
409
+ /**
410
+ * Raw (persistence) shape of the team directory fields: `apps` as
411
+ * `PlatformToolValue[]`, `canReferTo` as `ObjectId[]`.
412
+ *
413
+ * Inferred from the DEFINITION, not from a compiled `Schema`: given a
414
+ * `Schema` instance, `InferRawDocType` resolves to the Schema object's own
415
+ * members rather than the document fields. Wrapped in `Partial` because both
416
+ * fields are absent on documents that predate them.
417
+ */
418
+ type TeamDirectoryFields = Partial<InferRawDocType<typeof teamDirectorySchemaDefinition>>;
419
+
420
+ export { type Address, type Demographics, type Email, type PersonName, type Phone, TEAM_MODEL_NAME, type TeamDirectoryFields, addTeamDirectoryFields, addressSchema, demographicsSchema, emailSchema, personNameSchema, phoneSchema, teamDirectorySchemaDefinition };
@@ -1,6 +1,6 @@
1
1
  import * as mongoose from 'mongoose';
2
2
  import { InferRawDocType, Schema } from 'mongoose';
3
- export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-ctHTp2df.js';
3
+ export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DaDrEuTa.js';
4
4
 
5
5
  declare const addressSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
6
6
  _id: false;
@@ -132,12 +132,12 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
132
132
  number?: string | null | undefined;
133
133
  type?: string | null | undefined;
134
134
  safeToContact?: boolean | null | undefined;
135
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
135
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
136
136
  }, mongoose.Document<unknown, {}, {
137
137
  number?: string | null | undefined;
138
138
  type?: string | null | undefined;
139
139
  safeToContact?: boolean | null | undefined;
140
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
140
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
141
141
  }, {
142
142
  id: string;
143
143
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -146,7 +146,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
146
146
  number?: string | null | undefined;
147
147
  type?: string | null | undefined;
148
148
  safeToContact?: boolean | null | undefined;
149
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
149
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
150
150
  } & {
151
151
  _id: mongoose.Types.ObjectId;
152
152
  } & {
@@ -157,7 +157,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
157
157
  number?: string | null | undefined;
158
158
  type?: string | null | undefined;
159
159
  safeToContact?: boolean | null | undefined;
160
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
160
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
161
161
  } & {
162
162
  _id: mongoose.Types.ObjectId;
163
163
  } & {
@@ -219,11 +219,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
219
219
  raceOtherText?: string | null | undefined;
220
220
  genderOtherText?: string | null | undefined;
221
221
  accommodationOtherText?: string | null | undefined;
222
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
223
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
224
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
225
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
226
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
222
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
223
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
224
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
225
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
226
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
227
227
  }, mongoose.Document<unknown, {}, {
228
228
  race: number[];
229
229
  ethnicity: number[];
@@ -243,11 +243,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
243
243
  raceOtherText?: string | null | undefined;
244
244
  genderOtherText?: string | null | undefined;
245
245
  accommodationOtherText?: string | null | undefined;
246
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
247
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
248
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
249
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
250
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
246
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
247
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
248
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
249
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
250
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
251
251
  }, {
252
252
  id: string;
253
253
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -271,11 +271,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
271
271
  raceOtherText?: string | null | undefined;
272
272
  genderOtherText?: string | null | undefined;
273
273
  accommodationOtherText?: string | null | undefined;
274
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
275
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
276
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
277
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
278
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
274
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
275
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
276
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
277
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
278
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
279
279
  } & {
280
280
  _id: mongoose.Types.ObjectId;
281
281
  } & {
@@ -301,11 +301,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
301
301
  raceOtherText?: string | null | undefined;
302
302
  genderOtherText?: string | null | undefined;
303
303
  accommodationOtherText?: string | null | undefined;
304
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
305
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
306
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
307
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
308
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
304
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
305
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
306
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
307
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
308
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
309
309
  } & {
310
310
  _id: mongoose.Types.ObjectId;
311
311
  } & {
@@ -313,4 +313,108 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
313
313
  }>;
314
314
  type Demographics = InferRawDocType<typeof demographicsSchema>;
315
315
 
316
- export { type Address, type Demographics, type Email, type PersonName, type Phone, addressSchema, demographicsSchema, emailSchema, personNameSchema, phoneSchema };
316
+ /**
317
+ * @htilabs/platform-common-models — Team directory fields
318
+ *
319
+ * Shared, additive fields for the platform-db `teams` collection that the
320
+ * Thread→PAVE "Refer to intake" preset reads to resolve the own-agency PAVE
321
+ * intake team.
322
+ *
323
+ * ## This is a FRAGMENT, not a Team model
324
+ *
325
+ * No canonical Team schema exists in this package. The `teams` collection is
326
+ * defined by legacy PAVE (`screening-tools` `models/teamModel.js`,
327
+ * `agencyManagementDb`), mirrored by Thread
328
+ * (`packages/db/src/models/platform/Team.ts`), written by the platform Admin
329
+ * Hub and identity sync, and read raw by pave-2.0 (`lookups/teamGraph.ts`).
330
+ * Declaring the whole Team contract here would mean resolving those shapes,
331
+ * which is out of scope. This module only declares the fields the referral
332
+ * preset needs. Each consumer adds them to its own team schema with
333
+ * {@link addTeamDirectoryFields}, or spreads {@link teamDirectorySchemaDefinition}.
334
+ *
335
+ * ## Canon
336
+ *
337
+ * Prototype `origin/main` @ `c658d6f7`:
338
+ * - `KICKOFF_SHARE_EDGE_CONVERGENCE_2026-09-29.md` § 2.8 L254-257: the intake
339
+ * team is resolved from the sending program's `can_refer_to` targets
340
+ * first, then from the default-share-team ladder restricted to PAVE teams.
341
+ * A referral to intake never routes back to the sender.
342
+ * - Monolith `HTI-LEADS-PAVE-Thread-prototype.html` L323796-323832
343
+ * (`resolveIntakeTeamMono`), directory `programs[]` L142246-142431 and
344
+ * `teams[]` from L142584.
345
+ *
346
+ * Thread ADR: `docs/ADR-THREAD-PAVE-CASESHARE-CONVERGENCE.md` D1 and staging
347
+ * row .2 (consumer th-ng838.2). PAVE consumer: pv-p6share-thread-ingest-v4.
348
+ *
349
+ * ## Divergences from canon (deliberate)
350
+ *
351
+ * 1. **`apps`, not `apps_used`.** Canon's team rows carry lowercase
352
+ * `apps_used` (`"pave"`). The live platform-db writers already stamp
353
+ * `apps` with the uppercase {@link PLATFORM_TOOL} codes on agencies,
354
+ * accounts, users and teams (platform `lib/sync/upserts.ts`,
355
+ * `$addToSet: { apps: APP }` with `APP = source.toUpperCase()`). This
356
+ * field matches that convention exactly.
357
+ * 2. **`canReferTo` lives on the team.** Canon carries `can_refer_to` on a
358
+ * first-class PROGRAM row (`programs[]`, one `team_id` per program), and
359
+ * its targets are PROGRAM ids. No Program model exists in this package or
360
+ * in platform-db, so the targets are carried here as TEAM ids on the
361
+ * sending team. Canon's resolver maps each target program to its single
362
+ * team before using it, so the resolved team is the same. If a Program
363
+ * model lands later, `canReferTo` should move onto it.
364
+ */
365
+
366
+ /** Mongoose model name every app registers the `teams` collection under. */
367
+ declare const TEAM_MODEL_NAME: "Team";
368
+ /**
369
+ * The directory fields to add to a team schema.
370
+ *
371
+ * Both are OPTIONAL and default to `undefined`, not `[]`. A team document
372
+ * written before these fields existed hydrates and re-saves without gaining
373
+ * an `apps` or `canReferTo` key. That keeps "not declared" (absent) distinct
374
+ * from "declared empty" (`[]`).
375
+ */
376
+ declare const teamDirectorySchemaDefinition: {
377
+ /**
378
+ * The platform apps this team works in, as {@link PLATFORM_TOOL} codes
379
+ * (`"PAVE"`, `"THREAD"`, `"LEADS"`, ...). The referral preset only resolves
380
+ * to a team whose `apps` includes `"PAVE"`.
381
+ */
382
+ apps: {
383
+ type: StringConstructor[];
384
+ enum: ("THREAD" | "PAVE" | "ECHO" | "LEADS" | "TRAIL" | "PLATFORM")[];
385
+ default: undefined;
386
+ };
387
+ /**
388
+ * The teams this team refers to, in priority order. The resolver takes the
389
+ * first active target that works in PAVE and is not the sending team itself.
390
+ */
391
+ canReferTo: {
392
+ type: {
393
+ type: typeof Schema.Types.ObjectId;
394
+ ref: "Team";
395
+ }[];
396
+ default: undefined;
397
+ };
398
+ };
399
+ /**
400
+ * Add the team directory fields to an existing team schema.
401
+ *
402
+ * Adds no indexes and no hooks. Indexes on the shared `teams` collection
403
+ * stay with the collection's owner.
404
+ *
405
+ * @param schema - The consumer's team schema
406
+ * @returns The same schema, for chaining
407
+ */
408
+ declare function addTeamDirectoryFields<S extends Schema>(schema: S): S;
409
+ /**
410
+ * Raw (persistence) shape of the team directory fields: `apps` as
411
+ * `PlatformToolValue[]`, `canReferTo` as `ObjectId[]`.
412
+ *
413
+ * Inferred from the DEFINITION, not from a compiled `Schema`: given a
414
+ * `Schema` instance, `InferRawDocType` resolves to the Schema object's own
415
+ * members rather than the document fields. Wrapped in `Partial` because both
416
+ * fields are absent on documents that predate them.
417
+ */
418
+ type TeamDirectoryFields = Partial<InferRawDocType<typeof teamDirectorySchemaDefinition>>;
419
+
420
+ export { type Address, type Demographics, type Email, type PersonName, type Phone, TEAM_MODEL_NAME, type TeamDirectoryFields, addTeamDirectoryFields, addressSchema, demographicsSchema, emailSchema, personNameSchema, phoneSchema, teamDirectorySchemaDefinition };
@@ -4328,8 +4328,36 @@ function buildPlatformRoleSchema() {
4328
4328
  }
4329
4329
  var _platformRoleSchema = buildPlatformRoleSchema();
4330
4330
 
4331
- // src/schemas/cvcRegistry.ts
4331
+ // src/schemas/team.ts
4332
4332
  import { Schema as Schema8 } from "mongoose";
4333
+ var TEAM_MODEL_NAME = "Team";
4334
+ var teamDirectorySchemaDefinition = {
4335
+ /**
4336
+ * The platform apps this team works in, as {@link PLATFORM_TOOL} codes
4337
+ * (`"PAVE"`, `"THREAD"`, `"LEADS"`, ...). The referral preset only resolves
4338
+ * to a team whose `apps` includes `"PAVE"`.
4339
+ */
4340
+ apps: {
4341
+ type: [String],
4342
+ enum: [...PLATFORM_TOOL_VALUES],
4343
+ default: void 0
4344
+ },
4345
+ /**
4346
+ * The teams this team refers to, in priority order. The resolver takes the
4347
+ * first active target that works in PAVE and is not the sending team itself.
4348
+ */
4349
+ canReferTo: {
4350
+ type: [{ type: Schema8.Types.ObjectId, ref: TEAM_MODEL_NAME }],
4351
+ default: void 0
4352
+ }
4353
+ };
4354
+ function addTeamDirectoryFields(schema) {
4355
+ schema.add(teamDirectorySchemaDefinition);
4356
+ return schema;
4357
+ }
4358
+
4359
+ // src/schemas/cvcRegistry.ts
4360
+ import { Schema as Schema9 } from "mongoose";
4333
4361
  var cvcRegistrySchemaDefinition = {
4334
4362
  // Versioning — semantic version of this registry bundle
4335
4363
  version: {
@@ -4349,7 +4377,7 @@ var cvcRegistrySchemaDefinition = {
4349
4377
  default: null
4350
4378
  },
4351
4379
  agencyId: {
4352
- type: Schema8.Types.ObjectId,
4380
+ type: Schema9.Types.ObjectId,
4353
4381
  default: null
4354
4382
  },
4355
4383
  // Lifecycle
@@ -4391,7 +4419,7 @@ var cvcRegistrySchemaDefinition = {
4391
4419
  // include / exclude lists from its base before applying its own overrides.
4392
4420
  // Indexed below so a base-version bump can find every dependent registry.
4393
4421
  basedOn: {
4394
- type: Schema8.Types.ObjectId,
4422
+ type: Schema9.Types.ObjectId,
4395
4423
  default: null
4396
4424
  }
4397
4425
  };
@@ -4400,7 +4428,7 @@ var cvcRegistrySchemaOptions = {
4400
4428
  collection: "cvc_registries"
4401
4429
  };
4402
4430
  function buildCvcRegistrySchema() {
4403
- const schema = new Schema8(
4431
+ const schema = new Schema9(
4404
4432
  cvcRegistrySchemaDefinition,
4405
4433
  cvcRegistrySchemaOptions
4406
4434
  );
@@ -4421,7 +4449,7 @@ function buildCvcRegistrySchema() {
4421
4449
  var _cvcRegistrySchema = buildCvcRegistrySchema();
4422
4450
 
4423
4451
  // src/schemas/cvcEntry.ts
4424
- import { Schema as Schema9 } from "mongoose";
4452
+ import { Schema as Schema10 } from "mongoose";
4425
4453
  var CVC_CODE_PATTERN = /^\d{3}(-\d{3}){6}$/;
4426
4454
  var CVC_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;
4427
4455
  var cvcEntrySchemaDefinition = {
@@ -4487,7 +4515,7 @@ var cvcEntrySchemaDefinition = {
4487
4515
  // particular CVC family — e.g. `relevantMechanisms` on service_categories
4488
4516
  // entries (a cross-CVC reference into service_mechanisms by key).
4489
4517
  meta: {
4490
- type: Schema9.Types.Mixed
4518
+ type: Schema10.Types.Mixed
4491
4519
  }
4492
4520
  };
4493
4521
  var cvcEntrySchemaOptions = {
@@ -4498,7 +4526,7 @@ var cvcEntrySchemaOptions = {
4498
4526
  minimize: false
4499
4527
  };
4500
4528
  function buildCvcEntrySchema() {
4501
- const schema = new Schema9(cvcEntrySchemaDefinition, cvcEntrySchemaOptions);
4529
+ const schema = new Schema10(cvcEntrySchemaDefinition, cvcEntrySchemaOptions);
4502
4530
  schema.index(
4503
4531
  { domain: 1, version: 1, code: 1 },
4504
4532
  { unique: true }
@@ -4512,6 +4540,8 @@ function buildCvcEntrySchema() {
4512
4540
  }
4513
4541
  var _cvcEntrySchema = buildCvcEntrySchema();
4514
4542
  export {
4543
+ TEAM_MODEL_NAME,
4544
+ addTeamDirectoryFields,
4515
4545
  addressSchema,
4516
4546
  buildCvcEntrySchema,
4517
4547
  buildCvcRegistrySchema,
@@ -4549,6 +4579,7 @@ export {
4549
4579
  sectionQuestionRefSchema,
4550
4580
  sectionSchemaDefinition,
4551
4581
  sectionSchemaOptions,
4582
+ teamDirectorySchemaDefinition,
4552
4583
  visibilityRuleSchema
4553
4584
  };
4554
4585
  //# sourceMappingURL=index.js.map