@htilabs/platform-common-models 0.85.0 → 0.87.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 (64) hide show
  1. package/README.md +30 -0
  2. package/dist/{index-XWSYon40.d.cts → index-1pWiqEBC.d.cts} +1 -1
  3. package/dist/{index-Bh1zO_Vu.d.ts → index-uz57Fic9.d.ts} +1 -1
  4. package/dist/index.cjs +12 -1
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +3 -3
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +12 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/models/index.d.cts +2 -2
  11. package/dist/models/index.d.ts +2 -2
  12. package/dist/org-directory/index.cjs +8 -2
  13. package/dist/org-directory/index.cjs.map +1 -1
  14. package/dist/org-directory/index.d.cts +11 -2
  15. package/dist/org-directory/index.d.ts +11 -2
  16. package/dist/org-directory/index.js +8 -2
  17. package/dist/org-directory/index.js.map +1 -1
  18. package/dist/org-merge/index.cjs +8 -2
  19. package/dist/org-merge/index.cjs.map +1 -1
  20. package/dist/org-merge/index.js +8 -2
  21. package/dist/org-merge/index.js.map +1 -1
  22. package/dist/points-of-contact/index.cjs +229 -24
  23. package/dist/points-of-contact/index.cjs.map +1 -1
  24. package/dist/points-of-contact/index.d.cts +50 -5
  25. package/dist/points-of-contact/index.d.ts +50 -5
  26. package/dist/points-of-contact/index.js +226 -23
  27. package/dist/points-of-contact/index.js.map +1 -1
  28. package/dist/reader-BmhzOis-.d.ts +273 -0
  29. package/dist/reader-DfQtdw6n.d.cts +273 -0
  30. package/dist/schemas/index.cjs +12 -1
  31. package/dist/schemas/index.cjs.map +1 -1
  32. package/dist/schemas/index.d.cts +57 -27
  33. package/dist/schemas/index.d.ts +57 -27
  34. package/dist/schemas/index.js +12 -1
  35. package/dist/schemas/index.js.map +1 -1
  36. package/dist/seat-logs/index.cjs +815 -0
  37. package/dist/seat-logs/index.cjs.map +1 -0
  38. package/dist/seat-logs/index.d.cts +274 -0
  39. package/dist/seat-logs/index.d.ts +274 -0
  40. package/dist/seat-logs/index.js +742 -0
  41. package/dist/seat-logs/index.js.map +1 -0
  42. package/dist/validation/index.d.cts +1 -1
  43. package/dist/validation/index.d.ts +1 -1
  44. package/package.json +6 -1
  45. package/src/orgDirectory/__tests__/programDetails.test.ts +2 -1
  46. package/src/orgDirectory/__tests__/programTeamLink.test.ts +107 -0
  47. package/src/orgDirectory/schemas.ts +8 -1
  48. package/src/pointsOfContact/__tests__/seatContactLog.test.ts +170 -0
  49. package/src/pointsOfContact/readRules.ts +22 -4
  50. package/src/pointsOfContact/reader.ts +95 -1
  51. package/src/pointsOfContact/schemas.ts +4 -3
  52. package/src/schemas/organization-program.ts +25 -2
  53. package/src/seatLogs/__tests__/seatLogs.review.test.ts +222 -0
  54. package/src/seatLogs/__tests__/seatLogs.test.ts +335 -0
  55. package/src/seatLogs/index.ts +15 -0
  56. package/src/seatLogs/log.ts +700 -0
  57. package/src/seatLogs/personId.ts +100 -0
  58. package/src/seatLogs/personSlugWordlists.ts +40 -0
  59. package/src/seatLogs/reader.ts +143 -0
  60. package/src/seatLogs/schemas.ts +118 -0
  61. package/dist/{agency-CnVTwLeV.d.ts → agency-BHv54o79.d.ts} +4 -4
  62. package/dist/{agency-8ufZJJDH.d.cts → agency-Djp57S71.d.cts} +4 -4
  63. package/dist/{cvcEntry-D787utvP.d.cts → cvcEntry-DAuhe0cd.d.cts} +8 -8
  64. package/dist/{cvcEntry-D787utvP.d.ts → cvcEntry-DAuhe0cd.d.ts} +8 -8
package/README.md CHANGED
@@ -16,6 +16,36 @@ Package exports are organized into a public root API and a small number of
16
16
  dedicated subpaths (`/validation`, `/cvcs`) — consult `package.json` for the
17
17
  authoritative `exports` map.
18
18
 
19
+ ## 0.87.0 — a seat's name log and contact log, the Person id minter (`./seat-logs`), and seat-linked contacts read the seat's contact log (pl-9h4) (additive; a new subpath)
20
+
21
+ **What a person gets.** Nothing on screen yet: this is the shared half of the member profile's "Names" and "Ways to reach them" (platform-prototype `src/screens.jsx` @ 398fb24 `SeatNamesLedger`, `SeatMethodsLedger`). The Platform's profile, and the email correction that goes through auth, build on it.
22
+
23
+ **What is in `@htilabs/platform-common-models/seat-logs`.**
24
+ - `SeatNameEntry` / `SeatContactEntry` (Zod schemas + types): the prototype's stored fields — `entry_id`, `subject_id`, `subject_type` (`user` = a seat, the record's "a seat's name and contact rails stay keyed by the seat"; `person` = a registry person), `name_type` (CVC-1 keys) · `raw` · `is_display` · `is_preferred` for a name; `contact_type` (`email` | `phone`) · `value` · `use` · `is_preferred` · `safety_status` · `digits` (phone) for a contact; `period_start` / `period_end` (`""` open, `YYYY-MM-DD` closed), `source`, `method`, `notes`, `events[]`. Collection names `seat_names`, `seat_contacts`.
25
+ - The acts, pure (each returns the next log plus the rows to insert and to update): `addSeatName`, `setSeatDisplayName`, `correctSeatName`, `retireSeatName`, `seedSeatNameLog`; `addSeatContact`, `setPreferredSeatContact`, `correctSeatContact`, `retireSeatContact`. One live display name per subject (it carries the preferred mark too, as the profile moves both); one live preferred contact per subject and type; the first live entry takes the mark. A correction inserts the new entry ("Corrects “old”"), carries the mark onto it and archives the old one — nothing is edited in place; correcting into a value already live hands it the mark. A seat with no name log shows its flat name as a `__flat__` row (`seatNameRows`) and the log is seeded from it on the first act. The display name can't be retired; a preferred contact can't while another of its type is live (`canRetireSeatContact`).
26
+ - Values: `canonSeatContactValue` (a phone is stored in canon's `(AAA) BBB-CCCC` form), `seatContactKey` (a phone's digits with a leading US `1` dropped; an email lowercased) for "same contact?", `formatSeatPhone`; guards `seatPhoneRefusal` / `seatEmailRefusal` with the profile's words.
27
+ - Projections: `seatNameProjection` (the display name → `users.name`), `seatEmailProjection` (the preferred email → the login email).
28
+ - `readSeatNameLogs` / `readSeatContactLogs`: raw-driver reads by subject, each log in `entry_id` order (the prototype store's order), keyed by the id as asked and matched case-insensitively (a seat's log is stored under `String(users._id)`, lower-case). A malformed row throws by default; `{ invalid: "skip", onInvalidRow }` leaves it out instead.
29
+ - Every act targets a live entry: a retired entry id is refused (`entry_not_live`) with nothing changed. Correcting a name to the same text is a no-op. `events[]` is stamped as the prototype store stamps it (`cascade` on every row whose marks or `period_end` moved, then the act).
30
+ - **Indexes the store needs:** a unique index on `entry_id` in `seat_names` and in `seat_contacts` (the default minter never collides within one act; the index catches the rest), and a unique index on the person id wherever it is stored (`users.personId` and the registry rows that carry one).
31
+ - `mintPersonId(wordlists?, taken)` / `mintNewPersonId(taken)`: `per-<first>-<second>`, name-free, `null` only when there are no wordlists. After 200 random draws the two-word space is scanned for a free pair; when every pair is taken (45 × 45 = 2,025 with the vendored lists) it follows the records generator's full-pool rule (`generatePersonSlug`: `<first>-<second>-<number 0-999>`) and mints `per-<first>-<second>-<n>` — random suffixes first, then a deterministic scan, so a mint always ends. `isPersonId` / `PERSON_ID_PATTERN` accept both forms. `taken` is a snapshot: two concurrent mints can return the same id, so the caller needs the unique index above and retries the mint on a duplicate-key error. The wordlists default to `PERSON_SLUG_WORDLISTS` (`PERSON_SLUG_FIRST` / `PERSON_SLUG_SECOND`, 45 words each), vendored unchanged from the records monolith's `PERSON_FIRST` / `PERSON_SECOND` @ 1be43ed5 (equal to the Platform prototype's `person_slug_wordlists`); a directory build's lists may still be passed.
32
+
33
+ **Points of contact (pl-9h4).** `SeatReach` gains optional `emails` / `phones` lists. Wrap a seat resolver in `withSeatContactLogs(db, resolve)` and a seat-linked contact reads every live email and phone on the seat's contact log, with the log's preferred mark. Per type: a log with no live email keeps the seat's `users` email (likewise phones). Only seats `resolve` returned are enriched, so a seat it leaves out (an ended seat in the network read, an unknown id) is never published from its log. A malformed log row is skipped for its seat (`onInvalidRow`), never failing the read. Without the wrapper nothing changes.
34
+
35
+ **For a consumer that bumps to this version.** No change is needed.
36
+
37
+ ## 0.86.0 — a program can record which team or teams work for it (`teamId`, `teamIds` on `organizations.programs[]`; additive)
38
+
39
+ **What a person gets.** Nothing on screen yet: this lets a program carry its link to the team (or teams) that work for it, so the Admin Hub can build the prototype's "Set up as a team", the Add-team "Which program does this team work for?" and the team profile's "Link" (platform-prototype `src/agencyhub.jsx` `roElevateProgramToTeam`, `linkTeamToProgramH`). Until now the program fragment did not declare the link, so the Platform's program writer (which keeps only the fragment's keys) erased a link at the next program edit.
40
+
41
+ **What is stored.** Two optional keys on a program row, the UDD Program object's `team_id` · `team_ids`, stored camelCase like the rest of the row:
42
+ - `teamId`: the first team linked (a `teams._id` as a string);
43
+ - `teamIds`: every team linked, in the order they were linked (one program may have several teams, Crysta 2026-10-18).
44
+
45
+ Both absent means no team is linked, which is every row stored today. The Mongoose fragment declares `teamIds` with `default: undefined`, so a row with no link stores nothing (never an empty list). `OrganizationProgramRowSchema` reads both; a value of the wrong kind reads as not on record and never fails the row; `ORGANIZATION_PROGRAM_ROW_KEYS` lists both, last. A snake_case `team_ids` is still dropped.
46
+
47
+ **For a consumer that bumps to this version.** No change is needed: nothing reads the link yet. Thread and PAVE keep the stored rows as they are; the Platform's program writer starts keeping the link once it bumps.
48
+
19
49
  ## 0.84.0 — the organization merge is judged against the one registry and moves the duplicate's programs; the caller says who is merging (`./org-merge`; one new required argument)
20
50
 
21
51
  **What a person gets.** An HTI Labs steward can now merge the pairs that matter: an organization added in the Admin Hub (as the copy or as the one kept), and a copy in one agency's list into another agency's or a member's own organization. Until now the shared rules refused all of these, because they asked whether the agency whose list the copy is in could see the kept row. "Organizations should never sit inside one agency's own list" (Crysta, 2026-11-11): the registry is one platform-wide list, and an agency's list never blocks a registry action.
@@ -1,4 +1,4 @@
1
- import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-D787utvP.cjs';
1
+ import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-DAuhe0cd.cjs';
2
2
  import * as mongoose from 'mongoose';
3
3
  import { HydratedDocument, Connection, Model } from 'mongoose';
4
4
 
@@ -1,4 +1,4 @@
1
- import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-D787utvP.js';
1
+ import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-DAuhe0cd.js';
2
2
  import * as mongoose from 'mongoose';
3
3
  import { HydratedDocument, Connection, Model } from 'mongoose';
4
4
 
package/dist/index.cjs CHANGED
@@ -21216,7 +21216,18 @@ var organizationProgramSchemaDefinition = {
21216
21216
  */
21217
21217
  locationId: { type: String, required: false },
21218
21218
  /** The editor's notes. */
21219
- notes: { type: String, required: false }
21219
+ notes: { type: String, required: false },
21220
+ /**
21221
+ * The first team that works for the program (`teams._id` as a string;
21222
+ * canon `team_id`). Equal to `teamIds[0]` when both are written.
21223
+ */
21224
+ teamId: { type: String, required: false },
21225
+ /**
21226
+ * Every team that works for the program (canon `team_ids`; one program may
21227
+ * have several teams). `default: undefined`, so a row with no link stores
21228
+ * nothing and reads as absent, never as an empty list.
21229
+ */
21230
+ teamIds: { type: [String], required: false, default: void 0 }
21220
21231
  };
21221
21232
  function buildOrganizationProgramSchema() {
21222
21233
  return new import_mongoose13.Schema(organizationProgramSchemaDefinition, { _id: false });