@htilabs/platform-common-models 0.23.0 → 0.25.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 (82) hide show
  1. package/README.md +104 -0
  2. package/dist/authz/index.cjs +143 -12
  3. package/dist/authz/index.cjs.map +1 -1
  4. package/dist/authz/index.d.cts +121 -12
  5. package/dist/authz/index.d.ts +121 -12
  6. package/dist/authz/index.js +136 -12
  7. package/dist/authz/index.js.map +1 -1
  8. package/dist/constants/index.cjs +30 -0
  9. package/dist/constants/index.cjs.map +1 -1
  10. package/dist/constants/index.d.cts +1 -1
  11. package/dist/constants/index.d.ts +1 -1
  12. package/dist/constants/index.js +26 -0
  13. package/dist/constants/index.js.map +1 -1
  14. package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-Asg7mxjB.d.cts} +12 -9
  15. package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-Asg7mxjB.d.ts} +12 -9
  16. package/dist/{index-CDoqrfc1.d.ts → index-ClTjjJ_S.d.ts} +1 -1
  17. package/dist/{index-Zu_mOJRn.d.cts → index-Pt82NxQg.d.cts} +1 -1
  18. package/dist/index.cjs +604 -15
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +7 -5
  21. package/dist/index.d.ts +7 -5
  22. package/dist/index.js +577 -15
  23. package/dist/index.js.map +1 -1
  24. package/dist/information-scope/index.d.cts +3 -350
  25. package/dist/information-scope/index.d.ts +3 -350
  26. package/dist/informationScopeResolver-BzYu97DE.d.cts +351 -0
  27. package/dist/informationScopeResolver-BzYu97DE.d.ts +351 -0
  28. package/dist/models/index.cjs +26 -1
  29. package/dist/models/index.cjs.map +1 -1
  30. package/dist/models/index.d.cts +2 -2
  31. package/dist/models/index.d.ts +2 -2
  32. package/dist/models/index.js +26 -1
  33. package/dist/models/index.js.map +1 -1
  34. package/dist/{platform-auth-B49Ly57B.d.cts → platform-auth-DJO-r9Pf.d.cts} +48 -1
  35. package/dist/{platform-auth-B49Ly57B.d.ts → platform-auth-DJO-r9Pf.d.ts} +48 -1
  36. package/dist/schemas/index.cjs +26 -1
  37. package/dist/schemas/index.cjs.map +1 -1
  38. package/dist/schemas/index.d.cts +25 -25
  39. package/dist/schemas/index.d.ts +25 -25
  40. package/dist/schemas/index.js +26 -1
  41. package/dist/schemas/index.js.map +1 -1
  42. package/dist/services/index.cjs +26 -1
  43. package/dist/services/index.cjs.map +1 -1
  44. package/dist/services/index.d.cts +2 -1
  45. package/dist/services/index.d.ts +2 -1
  46. package/dist/services/index.js +26 -1
  47. package/dist/services/index.js.map +1 -1
  48. package/dist/sharing-ceiling/index.cjs +497 -0
  49. package/dist/sharing-ceiling/index.cjs.map +1 -0
  50. package/dist/sharing-ceiling/index.d.cts +318 -0
  51. package/dist/sharing-ceiling/index.d.ts +318 -0
  52. package/dist/sharing-ceiling/index.js +451 -0
  53. package/dist/sharing-ceiling/index.js.map +1 -0
  54. package/dist/types/index.d.cts +11 -3
  55. package/dist/types/index.d.ts +11 -3
  56. package/dist/validation/index.cjs +22 -0
  57. package/dist/validation/index.cjs.map +1 -1
  58. package/dist/validation/index.js +22 -0
  59. package/dist/validation/index.js.map +1 -1
  60. package/package.json +7 -1
  61. package/src/__sot__/README.md +2 -1
  62. package/src/__sot__/coreFunctionFields.ts +88 -4
  63. package/src/__sot__/coreFunctions.pin.json +1040 -113
  64. package/src/__sot__/sharingStarter.pin.json +229 -0
  65. package/src/__tests__/authz-resolve.test.ts +115 -31
  66. package/src/__tests__/core-function-default-bounds.test.ts +374 -0
  67. package/src/__tests__/core-functions-case-close.test.ts +82 -0
  68. package/src/__tests__/sharing-starter-canon.test.ts +178 -0
  69. package/src/authz/defaultBounds.ts +69 -0
  70. package/src/authz/index.ts +12 -3
  71. package/src/authz/resolveEffectiveFunctions.ts +69 -29
  72. package/src/constants/platform-auth.ts +60 -0
  73. package/src/generated/coreFunctionDefaultBounds.ts +109 -0
  74. package/src/generated/sharingPlatformStarter.ts +165 -0
  75. package/src/index.ts +5 -0
  76. package/src/schemas/platform-role.ts +4 -1
  77. package/src/sharingCeiling/__tests__/sharingCeiling.test.ts +678 -0
  78. package/src/sharingCeiling/chain.ts +269 -0
  79. package/src/sharingCeiling/coverage.ts +346 -0
  80. package/src/sharingCeiling/index.ts +14 -0
  81. package/src/sharingCeiling/starter.ts +89 -0
  82. package/src/types/platform-auth.ts +9 -2
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The platform sharing starter — what governs a share before an account has
3
+ * authored anything (co-2sx).
4
+ *
5
+ * The data is GENERATED from canon (`scripts/gen-sharing-starter.py` →
6
+ * `src/generated/sharingPlatformStarter.ts`) and held equal to canon by GATE M
7
+ * (`src/__tests__/sharing-starter-canon.test.ts`, against
8
+ * `src/__sot__/sharingStarter.pin.json`). This module types it and freezes it.
9
+ *
10
+ * Canon: prototype `HTI-LEADS-PAVE-Thread-prototype.html` @ d85f05b7
11
+ * `HTI_SHARE_PLATFORM_STARTER` L326475-L326543 (scopeVersion ·
12
+ * scopeByPurpose · counterpartyOverrides); platform-prototype `src/data.js`
13
+ * @ a6f1f3a `data.sharing.scopeByPurpose` / `counterpartyOverrides`
14
+ * L38170-L38190 (the contract of record, GDR § 5.79) and the platform
15
+ * purpose rows `sharing.purposes[].enabled` L32450-L32531 (`records_request`
16
+ * ships `enabled: false`, L32527); prototype
17
+ * `docs/share-roi/information_scope_v4.fields.csv` @ d85f05b7 (where each
18
+ * field is homed, `row_v4`).
19
+ */
20
+
21
+ import {
22
+ SHARING_PLATFORM_STARTER_DATA,
23
+ SHARING_PLATFORM_STARTER_SOURCE,
24
+ } from "../generated/sharingPlatformStarter.js";
25
+
26
+ /** The tree version every starter list and every stored ceiling list is stamped with. */
27
+ export const SHARING_CEILING_SCOPE_VERSION = 4 as const;
28
+
29
+ /** purpose code (CVC-84 key) → v4 information-scope row codes. */
30
+ export type SharingPurposeLists = Readonly<Record<string, readonly string[]>>;
31
+
32
+ export interface SharingPlatformStarter {
33
+ readonly scopeVersion: typeof SHARING_CEILING_SCOPE_VERSION;
34
+ /** The platform per-purpose default — canon's last rung. A purpose with no row has no platform ceiling. */
35
+ readonly scopeByPurpose: SharingPurposeLists;
36
+ /** Platform-seeded partner rules: partner id → purpose → v4 row codes. */
37
+ readonly counterpartyOverrides: Readonly<Record<string, SharingPurposeLists>>;
38
+ }
39
+
40
+ function freezeLists(lists: Readonly<Record<string, readonly string[]>>): SharingPurposeLists {
41
+ const out: Record<string, readonly string[]> = {};
42
+ for (const [purpose, codes] of Object.entries(lists)) out[purpose] = Object.freeze([...codes]);
43
+ return Object.freeze(out);
44
+ }
45
+
46
+ /**
47
+ * The platform's own sharing rules (canon's `HTI_SHARE_PLATFORM_STARTER`,
48
+ * minus the demo-agency relationship / policy seeds). Deep-frozen.
49
+ *
50
+ * CANON GAP: `counterpartyOverrides` is keyed by canon's DEMONSTRATION partner
51
+ * ids (`palomar`, `okcpd`, `legal_aid_ok`). No registry agency carries them,
52
+ * so the seeded-partner rung binds on no real data until the platform maps
53
+ * them. They ship as canon has them.
54
+ */
55
+ export const HTI_SHARE_PLATFORM_STARTER: SharingPlatformStarter = Object.freeze({
56
+ scopeVersion: SHARING_CEILING_SCOPE_VERSION,
57
+ scopeByPurpose: freezeLists(SHARING_PLATFORM_STARTER_DATA.scopeByPurpose),
58
+ counterpartyOverrides: Object.freeze(
59
+ Object.fromEntries(
60
+ Object.entries(SHARING_PLATFORM_STARTER_DATA.counterpartyOverrides).map(([cp, lists]) => [
61
+ cp,
62
+ freezeLists(lists),
63
+ ]),
64
+ ),
65
+ ),
66
+ });
67
+
68
+ /**
69
+ * The platform purpose rows' `enabled` flag (data.js `sharing.purposes`). The
70
+ * contract of record disables a purpose whose platform row is `enabled:
71
+ * false` unless the account overrides it `true` (data.js clamp 1,
72
+ * L51352-L51354). `records_request` ships disabled.
73
+ */
74
+ export const HTI_SHARE_PLATFORM_PURPOSE_ENABLED: Readonly<Record<string, boolean>> = Object.freeze({
75
+ ...SHARING_PLATFORM_STARTER_DATA.purposeEnabled,
76
+ });
77
+
78
+ /**
79
+ * The v4 rows at least one field is HOMED on (canon's field placements,
80
+ * `information_scope_v4.fields.csv` `row_v4`). The ceiling coverage rule
81
+ * reads it: a row with fields homed directly on it and no rest row is within
82
+ * a ceiling only when it or an ancestor is listed.
83
+ */
84
+ export const INFORMATION_SCOPE_FIELD_HOME_ROWS: ReadonlySet<string> = new Set(
85
+ SHARING_PLATFORM_STARTER_DATA.fieldHomeRows,
86
+ );
87
+
88
+ /** Where the starter data was taken from (canon repo, file, SHA, line ranges). */
89
+ export const HTI_SHARE_PLATFORM_STARTER_SOURCE = SHARING_PLATFORM_STARTER_SOURCE;
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type {
10
- PermissionStateValue,
10
+ DefaultBoundStateValue,
11
11
  PlatformToolValue,
12
12
  RoleLevelValue,
13
13
  ShareViewValue,
@@ -44,6 +44,13 @@ export interface PlatformRoleDef {
44
44
  shareView: ShareViewValue | null;
45
45
  trainingRequirements: string | null;
46
46
  isHtiOnly: boolean;
47
- functions: Record<string, PermissionStateValue>;
47
+ /**
48
+ * Tier-1 state per function code. A PERMISSION_STATE value, or the codebook's
49
+ * `NA` ("Not relevant", since 0.24.0 — seeded from
50
+ * `CORE_FUNCTION_DEFAULT_BOUNDS`). An unlisted function is UNBOUND: the
51
+ * shared resolver treats the role as ineligible for it, and reads `NA` as
52
+ * NEVER. Label it with `DEFAULT_BOUND_STATE_LABELS` / `_DISPLAY`.
53
+ */
54
+ functions: Record<string, DefaultBoundStateValue>;
48
55
  sortOrder: number;
49
56
  }