@htilabs/platform-common-models 0.55.0 → 0.56.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.
- package/README.md +42 -0
- package/dist/authz/index.cjs +353 -2
- package/dist/authz/index.cjs.map +1 -1
- package/dist/authz/index.d.cts +320 -1
- package/dist/authz/index.d.ts +320 -1
- package/dist/authz/index.js +339 -1
- package/dist/authz/index.js.map +1 -1
- package/dist/index.cjs +351 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +338 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/authz-resolve.test.ts +5 -0
- package/src/__tests__/authz-viewing-policy.test.ts +685 -0
- package/src/__tests__/authz-viewing-scope.test.ts +1037 -0
- package/src/authz/index.ts +2 -0
- package/src/authz/viewingPolicy.ts +525 -0
- package/src/authz/viewingScope.ts +359 -0
package/dist/authz/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as PermissionStateValue, d as DefaultBoundStateValue } from '../platform-auth-DJO-r9Pf.cjs';
|
|
2
2
|
export { D as DEFAULT_BOUND_STATE, a as DEFAULT_BOUND_STATE_DISPLAY, b as DEFAULT_BOUND_STATE_LABELS, c as DEFAULT_BOUND_STATE_VALUES } from '../platform-auth-DJO-r9Pf.cjs';
|
|
3
|
+
import { d as InformationScopeResolver, l as ScopeReading, w as ScopeSubjectKind } from '../informationScopeResolver-BzYu97DE.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @htilabs/platform-common-models — the shared CVC-133 authorization resolver
|
|
@@ -601,4 +602,322 @@ declare function functionDoor(input: FunctionDoorInput): FunctionDoorState;
|
|
|
601
602
|
*/
|
|
602
603
|
declare function canonicalRoleCode(code: unknown): string | null;
|
|
603
604
|
|
|
604
|
-
|
|
605
|
+
/**
|
|
606
|
+
* @htilabs/platform-common-models/authz — the account's Internal Viewing Policy
|
|
607
|
+
* reader: which stored viewing rule governs one acting team.
|
|
608
|
+
*
|
|
609
|
+
* Contract of record: "Contract — the account's Internal Viewing Policy: stored
|
|
610
|
+
* shape and delivery to Thread and PAVE (Kickoff 13 § 5a)", §§ 1–4. Lifted from
|
|
611
|
+
* PAVE's `@pave/db` `readViewingPolicy` (pave-2.0 develop 41f5f916,
|
|
612
|
+
* `packages/db/src/lookups/viewingPolicy.ts`) so Thread and PAVE run ONE reader
|
|
613
|
+
* (GDR § 5.79, one resolver per runtime). The selection and validation rules are
|
|
614
|
+
* PAVE's, unchanged; only the I/O is left to the app.
|
|
615
|
+
*
|
|
616
|
+
* ## Pure: each app does its own query
|
|
617
|
+
*
|
|
618
|
+
* No database access. The app reads the candidate rows itself — the account's
|
|
619
|
+
* `registry_policies` documents (`species: "viewing"`, `account_id` = the acting
|
|
620
|
+
* agency's Account; passing every policy of the account is fine, other species are
|
|
621
|
+
* skipped here) — and hands them in with `{ accountId, teamId }`. A failed read is
|
|
622
|
+
* passed as `docs: null` (or answered with {@link unavailableViewingPolicy}); it is
|
|
623
|
+
* never an empty list, because an empty list means "nothing on file".
|
|
624
|
+
*
|
|
625
|
+
* ## Which row governs (Crysta 2026-10-06, ruling (a))
|
|
626
|
+
*
|
|
627
|
+
* The acting team's OWN active row governs that team IN PLACE OF the account-wide
|
|
628
|
+
* rule — higher or lower; the two are never combined. With no team row, the
|
|
629
|
+
* account-wide rule governs. With neither, nothing governs: `source: "none"`, and
|
|
630
|
+
* the role level alone decides (Level 3 shows the full record; Crysta 2026-11-03,
|
|
631
|
+
* "Match the prototype"). The role clamps afterwards:
|
|
632
|
+
* `viewingLevelFromFunctions(effectiveFunctions, teamViewingLevelFromPolicy(result))`.
|
|
633
|
+
* Prototype: `viewingPolicyFor`, platform-prototype `src/data.js` (aa2c63a).
|
|
634
|
+
*
|
|
635
|
+
* ## Fail closed, never throw (contract § 4)
|
|
636
|
+
*
|
|
637
|
+
* Anything that stops the policy being READ answers `source: "unavailable"`
|
|
638
|
+
* (level 0 for that request) with a coded reason — never `"none"`: the account
|
|
639
|
+
* cannot be resolved; the read failed; a live viewing row whose assignment is not
|
|
640
|
+
* exactly one account-or-team entry (it might be this team's narrowing); a row in
|
|
641
|
+
* this team's or the account's place whose `active` is neither `true` nor `false`;
|
|
642
|
+
* two live rows in one place without distinct versions of one family; and, on the
|
|
643
|
+
* governing row, a `level` that is not exactly 0–3, a `visibleGroups` that is
|
|
644
|
+
* present but not a list of strings or names a code that is not live at its stamp,
|
|
645
|
+
* a `scopeVocab` that is missing or not 3, 4 or 5. A malformed team row never falls
|
|
646
|
+
* back to the account rule (that fallback could widen).
|
|
647
|
+
*
|
|
648
|
+
* A governing row with no `visibleGroups` reads as an EMPTY list (contract § 4;
|
|
649
|
+
* PAVE `caseViewing.ts` `accessFromResolution`): only "no row at all" shows the
|
|
650
|
+
* full record. System information is always shown — that is the Level 3 filter's
|
|
651
|
+
* job ({@link caseViewingAccess}), not this reader's.
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
/** The stored `species` of an internal-viewing policy (UDD Policy.v1). */
|
|
655
|
+
declare const VIEWING_POLICY_SPECIES: "viewing";
|
|
656
|
+
/** What one of the prototype's viewing-policy vocabulary stamps means to a reader. */
|
|
657
|
+
interface ViewingPolicyVocabulary {
|
|
658
|
+
/** The CVC-236 tree version the resolver reads the list at (3 through the v3 → v4 table, or 4). */
|
|
659
|
+
readonly scopeVersion: 3 | 4;
|
|
660
|
+
/** The prototype's ONE-HOME domain carry applies (`scopeVocab < 4`). */
|
|
661
|
+
readonly oneHomeCarry: boolean;
|
|
662
|
+
/** The prototype's v4 alias on `identifying` applies (`scopeVocab < 5`). */
|
|
663
|
+
readonly identifyingAlias: boolean;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* The stamps a stored viewing policy's `scopeVocab` may carry and still be read.
|
|
667
|
+
*
|
|
668
|
+
* The stamp is the Internal Viewing tab's own counter, NOT the CVC-236 tree
|
|
669
|
+
* version: the hub stamps every save `5` for the four-level v4 tree
|
|
670
|
+
* (platform-prototype `src/screens.jsx` `setLevel` / `toggleGroup` /
|
|
671
|
+
* `setAcctLevel`). Earlier saves stamped 4 (ONE-HOME) and 3 (the Instruments
|
|
672
|
+
* catalog), both authored against the v3 tree. Stamps 1 and 2 and every future
|
|
673
|
+
* stamp (6 and up) are not read: they fail closed. Lifted from PAVE
|
|
674
|
+
* `@pave/domain` `VIEWING_POLICY_VOCABULARIES`.
|
|
675
|
+
*/
|
|
676
|
+
declare const VIEWING_POLICY_VOCABULARIES: Readonly<Record<3 | 4 | 5, ViewingPolicyVocabulary>>;
|
|
677
|
+
/** A stamp this reader reads. */
|
|
678
|
+
type ViewingPolicyScopeVocab = 3 | 4 | 5;
|
|
679
|
+
/** The reading of a stored `scopeVocab`, or `null` when it cannot be read (fail closed). */
|
|
680
|
+
declare function viewingPolicyVocabulary(scopeVocab: unknown): ViewingPolicyVocabulary | null;
|
|
681
|
+
/**
|
|
682
|
+
* The bound CVC-236 resolver the reader validates a whitelist with — the app's
|
|
683
|
+
* own binding of `createInformationScopeResolver` to `coreInformationScopeSot`
|
|
684
|
+
* (PAVE `INFORMATION_SCOPE_V4`, Thread `INFORMATION_SCOPE_RESOLVER`). Passed in
|
|
685
|
+
* so the browser-safe `./authz` entry never inlines the SOT JSON.
|
|
686
|
+
*/
|
|
687
|
+
type ViewingPolicyScopeResolver = Pick<InformationScopeResolver, "row" | "readSelection">;
|
|
688
|
+
/** Who is asking. */
|
|
689
|
+
interface ViewingPolicyQuery {
|
|
690
|
+
/**
|
|
691
|
+
* The Account that owns the policy — the acting agency's Account, which the
|
|
692
|
+
* caller resolved. Empty / null = the account could not be resolved
|
|
693
|
+
* (`unavailable`, `account_unresolved`).
|
|
694
|
+
*/
|
|
695
|
+
accountId: string | null | undefined;
|
|
696
|
+
/**
|
|
697
|
+
* The ONE acting team, already bound by the caller to the acting agency
|
|
698
|
+
* (Thread `resolveSeatActingTeamId`, PAVE `viewingTeamOfAgency`). `null` = no
|
|
699
|
+
* acting team, so only the account-wide rule can govern. A 24-hex id is
|
|
700
|
+
* compared case-insensitively.
|
|
701
|
+
*/
|
|
702
|
+
teamId: string | null | undefined;
|
|
703
|
+
}
|
|
704
|
+
/** Why the policy could not be read. The first four are the app's I/O outcomes. */
|
|
705
|
+
type ViewingPolicyUnavailableReason = "no_acting_agency" | "account_unresolved" | "policy_store_absent" | "read_error" | "unreadable_assignment" | "malformed_active" | "ambiguous_rows" | "malformed_level" | "malformed_visible_groups" | "unknown_visible_group" | "malformed_scope_vocab" | "unsupported_scope_vocab";
|
|
706
|
+
/** The governing row's identity (prototype `viewingPolicyFor` `policy`). */
|
|
707
|
+
interface ViewingPolicyRef {
|
|
708
|
+
/** The row's `entity_id`, else `id`, else `_id`. */
|
|
709
|
+
readonly id: string;
|
|
710
|
+
readonly familyId: string | null;
|
|
711
|
+
/** A positive integer, or `null` when the row carries none (or a malformed one). */
|
|
712
|
+
readonly version: number | null;
|
|
713
|
+
}
|
|
714
|
+
/** A team's own row, or the account-wide rule, governs. */
|
|
715
|
+
interface ViewingPolicyGoverning {
|
|
716
|
+
readonly source: "team" | "account";
|
|
717
|
+
/** The level the policy grants (before the role clamp). */
|
|
718
|
+
readonly level: ViewingLevel;
|
|
719
|
+
/**
|
|
720
|
+
* The categories still shown at Level 3, as stored (a copy), minus any
|
|
721
|
+
* `category_rest` row. A row with no list reads `[]` (only the stub and system
|
|
722
|
+
* information show). Every code is live at the tree version `scopeVocab` reads.
|
|
723
|
+
*/
|
|
724
|
+
readonly visibleGroups: readonly string[];
|
|
725
|
+
readonly scopeVocab: ViewingPolicyScopeVocab;
|
|
726
|
+
readonly policy: ViewingPolicyRef;
|
|
727
|
+
readonly accountId: string;
|
|
728
|
+
/** A short, value-free trace of the decision, for logs (ids and versions only). */
|
|
729
|
+
readonly rulePath: string;
|
|
730
|
+
}
|
|
731
|
+
/** No row governs: the account set nothing for this team. The role level alone decides. */
|
|
732
|
+
interface ViewingPolicyNone {
|
|
733
|
+
readonly source: "none";
|
|
734
|
+
readonly level: null;
|
|
735
|
+
/** `null`: no row, so Level 3 shows the full record. */
|
|
736
|
+
readonly visibleGroups: null;
|
|
737
|
+
readonly scopeVocab: null;
|
|
738
|
+
readonly policy: null;
|
|
739
|
+
readonly accountId: string;
|
|
740
|
+
/** The account holds viewing rows and every one is retired (`active: false`): log it. */
|
|
741
|
+
readonly retiredRowsOnly: boolean;
|
|
742
|
+
readonly rulePath: string;
|
|
743
|
+
}
|
|
744
|
+
/** The policy could not be read: no view of other teams' cases for this request. */
|
|
745
|
+
interface ViewingPolicyUnavailable {
|
|
746
|
+
readonly source: "unavailable";
|
|
747
|
+
readonly level: 0;
|
|
748
|
+
readonly visibleGroups: readonly string[];
|
|
749
|
+
readonly scopeVocab: null;
|
|
750
|
+
readonly policy: null;
|
|
751
|
+
readonly reason: ViewingPolicyUnavailableReason;
|
|
752
|
+
/** The offending row's id, when one row caused it. */
|
|
753
|
+
readonly policyId: string | null;
|
|
754
|
+
readonly rulePath: string;
|
|
755
|
+
}
|
|
756
|
+
type GoverningViewingPolicy = ViewingPolicyGoverning | ViewingPolicyNone | ViewingPolicyUnavailable;
|
|
757
|
+
/**
|
|
758
|
+
* The policy could not be read — the shape every fail-closed answer takes. Apps
|
|
759
|
+
* use it for their own I/O outcomes (`read_error`, `policy_store_absent`, …).
|
|
760
|
+
*/
|
|
761
|
+
declare function unavailableViewingPolicy(reason: ViewingPolicyUnavailableReason, policyId?: string | null): ViewingPolicyUnavailable;
|
|
762
|
+
/**
|
|
763
|
+
* The internal-viewing policy that governs `query.teamId` on `query.accountId`,
|
|
764
|
+
* chosen from the candidate rows the app read. NEVER throws; see the module
|
|
765
|
+
* header for every outcome.
|
|
766
|
+
*
|
|
767
|
+
* `docs`: the account's policy documents (`registry_policies`), or `null` /
|
|
768
|
+
* `undefined` when the read failed (`read_error`). Rows of another species or
|
|
769
|
+
* another account are skipped, as the app's own query would have left them out.
|
|
770
|
+
* Mongo answers `[]` for a collection that does not exist, so on an empty answer
|
|
771
|
+
* the app must check that the policy store exists and pass
|
|
772
|
+
* `unavailableViewingPolicy("policy_store_absent")` when it does not (PAVE's
|
|
773
|
+
* reader checks with `listCollections`); an empty list from a store that exists
|
|
774
|
+
* means "none".
|
|
775
|
+
*/
|
|
776
|
+
declare function resolveViewingPolicy(docs: readonly unknown[] | null | undefined, query: ViewingPolicyQuery, scope: ViewingPolicyScopeResolver): GoverningViewingPolicy;
|
|
777
|
+
/**
|
|
778
|
+
* The `teamViewingLevel` argument of `viewingLevelFromFunctions` /
|
|
779
|
+
* `resolveEffectiveViewingLevel` (contract § 3): the row's level when a row
|
|
780
|
+
* governs; `null` when none does (the role level alone decides); `0` when the
|
|
781
|
+
* policy could not be read (fail closed).
|
|
782
|
+
*/
|
|
783
|
+
declare function teamViewingLevelFromPolicy(policy: GoverningViewingPolicy): ViewingLevel | null;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* @htilabs/platform-common-models/authz — the Level 3 category filter of internal
|
|
787
|
+
* viewing: what of a case a viewer who does not own it may see, given the
|
|
788
|
+
* effective level and the governing policy's `visibleGroups` / `scopeVocab`.
|
|
789
|
+
*
|
|
790
|
+
* Lifted from PAVE `@pave/domain` `viewingScope.ts` (pave-2.0 develop 41f5f916:
|
|
791
|
+
* `caseViewingAccess`, `recordViewing`, `caseSurfacesOn`, `caseSurfacesAsStub`)
|
|
792
|
+
* and `viewingProjection.ts` (`viewingComponentOpen`), unchanged in behaviour.
|
|
793
|
+
* The only difference: PAVE reads its module-level resolver binding; here the
|
|
794
|
+
* app passes its own binding of the CVC-236 v4 resolver (`scope`), so the
|
|
795
|
+
* browser-safe `./authz` entry never inlines the SOT JSON. PAVE's wire
|
|
796
|
+
* projections (`viewingProjection` field lists, route homes) and the stub
|
|
797
|
+
* projection stay in the app.
|
|
798
|
+
*
|
|
799
|
+
* Pure and I/O-free: the caller resolves every fact about the viewer (effective
|
|
800
|
+
* level, whether the case passes its agency / team row filter, ownership, the
|
|
801
|
+
* governing policy) and this module only decides.
|
|
802
|
+
*
|
|
803
|
+
* Rules (contract § 2; Crysta 2026-11-03; prototype `recordOpenAccess`,
|
|
804
|
+
* `carVisibleUnderAccess`, `applyViewingPolicy`):
|
|
805
|
+
* - a case the viewer cannot see: nothing; an owned case: the full record;
|
|
806
|
+
* - level 1: the stub in search; level 2: the stub in search and pickers;
|
|
807
|
+
* neither opens the record; level 0: nothing;
|
|
808
|
+
* - level 3 with NO policy on file (`whitelist: null`): the full record;
|
|
809
|
+
* - level 3 with a policy: the client's stub rows and system information
|
|
810
|
+
* always, plus whatever the whitelist COVERS on the record's kind-tree home
|
|
811
|
+
* row (a category covers that category under every person on the record).
|
|
812
|
+
* Unmapped or uncovered is hidden; an empty list hides everything else;
|
|
813
|
+
* - the author always sees their own record on a case they can see.
|
|
814
|
+
*/
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* The bound CVC-236 resolver the Level 3 filter reads (the app's binding of
|
|
818
|
+
* `createInformationScopeResolver` to `coreInformationScopeSot`).
|
|
819
|
+
*/
|
|
820
|
+
type ViewingScopeResolver = Pick<InformationScopeResolver, "row" | "readSelection" | "isCovered">;
|
|
821
|
+
/** Where a non-owned case can surface (prototype `applyViewingPolicy` context + record open). */
|
|
822
|
+
type ViewingSurface = "search" | "autocomplete" | "open";
|
|
823
|
+
/** A stored viewing whitelist (the admin-set by-category selection). */
|
|
824
|
+
interface StoredViewingWhitelist {
|
|
825
|
+
/** Flat list of scope codes (the policy's `visibleGroups`). */
|
|
826
|
+
informationScope: readonly string[] | null | undefined;
|
|
827
|
+
/**
|
|
828
|
+
* The policy's vocabulary stamp as the hub wrote it (`scopeVocab`: 3, 4 or 5) —
|
|
829
|
+
* never the CVC-236 tree version. Any other value reads nothing.
|
|
830
|
+
*/
|
|
831
|
+
scopeVocab: number | null | undefined;
|
|
832
|
+
}
|
|
833
|
+
/** Everything the caller resolved about the viewer and the case. */
|
|
834
|
+
interface ViewingContext {
|
|
835
|
+
/** The case passes the caller's agency / team row filter. `false` ⇒ nothing on it. */
|
|
836
|
+
canSeeCase: boolean;
|
|
837
|
+
/** The case is owned / claimed by the viewer or their team: always fully visible. */
|
|
838
|
+
ownedByViewer: boolean;
|
|
839
|
+
/** The effective viewing level (`viewingLevelFromFunctions`). */
|
|
840
|
+
level: ViewingLevel;
|
|
841
|
+
/**
|
|
842
|
+
* The governing policy's whitelist ({@link viewingWhitelistFromPolicy}). `null`
|
|
843
|
+
* means exactly one thing: NO viewing policy is on file, so Level 3 renders every
|
|
844
|
+
* component. A row with no list is an empty list, not `null`.
|
|
845
|
+
*/
|
|
846
|
+
whitelist: StoredViewingWhitelist | null;
|
|
847
|
+
}
|
|
848
|
+
/** The decision for one case. */
|
|
849
|
+
type CaseViewingAccess = {
|
|
850
|
+
readonly mode: "full";
|
|
851
|
+
readonly reason: "owned" | "no_viewing_policy";
|
|
852
|
+
} | {
|
|
853
|
+
readonly mode: "none";
|
|
854
|
+
readonly reason: "cannot_see_case" | "level_0";
|
|
855
|
+
} | {
|
|
856
|
+
readonly mode: "stub";
|
|
857
|
+
readonly level: 1 | 2;
|
|
858
|
+
} | {
|
|
859
|
+
readonly mode: "whitelist";
|
|
860
|
+
/** The whitelist's v4 reading (`readSelection`, subject `policy`), untouched. */
|
|
861
|
+
readonly reading: ScopeReading;
|
|
862
|
+
/**
|
|
863
|
+
* The list coverage is read on: the reading, plus `relationships_household`
|
|
864
|
+
* when the prototype's v4 alias on `identifying` applies (a stamp below 5).
|
|
865
|
+
*/
|
|
866
|
+
readonly visibleScope: readonly string[];
|
|
867
|
+
/** The prototype's ONE-HOME domain carry applies (stamp 3). */
|
|
868
|
+
readonly oneHomeCarry: boolean;
|
|
869
|
+
/** The v4 alias carries `relationship_dynamics` at domain grain (stamp < 5 naming `identifying`). */
|
|
870
|
+
readonly relationshipDynamicsCarry: boolean;
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* The whitelist {@link caseViewingAccess} reads for a governing-policy result:
|
|
874
|
+
* `null` when nothing governs (the full record at Level 3); the row's list and
|
|
875
|
+
* stamp when a row governs; an unreadable empty list when the policy is
|
|
876
|
+
* unavailable (whose level 0 already shows nothing — never widens).
|
|
877
|
+
*/
|
|
878
|
+
declare function viewingWhitelistFromPolicy(policy: GoverningViewingPolicy): StoredViewingWhitelist | null;
|
|
879
|
+
/** Resolve a viewer's access to one case. */
|
|
880
|
+
declare function caseViewingAccess(ctx: ViewingContext, scope: ViewingScopeResolver): CaseViewingAccess;
|
|
881
|
+
/**
|
|
882
|
+
* Does the case surface on `surface`? Level 1 — search only; level 2 — search and
|
|
883
|
+
* autocomplete; neither opens the record. Level 3 and full open it.
|
|
884
|
+
*/
|
|
885
|
+
declare function caseSurfacesOn(access: CaseViewingAccess, surface: ViewingSurface): boolean;
|
|
886
|
+
/** Does the case surface as the stub projection (levels 1 and 2 only)? */
|
|
887
|
+
declare function caseSurfacesAsStub(access: CaseViewingAccess): boolean;
|
|
888
|
+
/** One record on a case, as the viewing decision reads it. */
|
|
889
|
+
interface ViewingRecord {
|
|
890
|
+
/** The v4 kind-tree row the record's field is homed on (never a per-kind code). */
|
|
891
|
+
homeRow: string;
|
|
892
|
+
/** Whose record it is: the client, or another named person's kind. */
|
|
893
|
+
subjectKind: ScopeSubjectKind;
|
|
894
|
+
/** The author's user id. The author always sees their own record. */
|
|
895
|
+
authorUserId?: string | null | undefined;
|
|
896
|
+
/** The record's assertion domain, read ONLY by the pre-v4 carries. */
|
|
897
|
+
domain?: string | null | undefined;
|
|
898
|
+
}
|
|
899
|
+
/** Why a record is (not) visible. */
|
|
900
|
+
type RecordViewingReason = "author" | "full" | "stub_row" | "covered" | "one_home_carry" | "identifying_alias_carry" | "cannot_see_case" | "level_0" | "not_opened" | "not_covered" | "unknown_row";
|
|
901
|
+
interface RecordViewingDecision {
|
|
902
|
+
readonly visible: boolean;
|
|
903
|
+
readonly reason: RecordViewingReason;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* May the viewer see this record on the case? A case the viewer cannot see:
|
|
907
|
+
* nothing (checked first, even for the author); the author: their own record;
|
|
908
|
+
* level 0: nothing; an owned case or no policy: all; level 1 / 2: the record never
|
|
909
|
+
* opens; level 3: the client's stub rows always, otherwise the whitelist must
|
|
910
|
+
* COVER the record's kind-tree home row.
|
|
911
|
+
*/
|
|
912
|
+
declare function recordViewing(access: CaseViewingAccess, record: ViewingRecord, viewerUserId: string | null | undefined, scope: ViewingScopeResolver): RecordViewingDecision;
|
|
913
|
+
/** Is this kind-tree row visible under `access` (for the client)? */
|
|
914
|
+
declare function viewingRowVisible(access: CaseViewingAccess, homeRow: string, scope: ViewingScopeResolver): boolean;
|
|
915
|
+
/**
|
|
916
|
+
* Is this home row OPEN as a whole component under `access`: does the whitelist
|
|
917
|
+
* itself cover it? Stricter than {@link viewingRowVisible}: the stub (a name and a
|
|
918
|
+
* date of birth) does not open a whole component such as the name history behind
|
|
919
|
+
* it. System information is on every list, so it opens.
|
|
920
|
+
*/
|
|
921
|
+
declare function viewingComponentOpen(access: CaseViewingAccess, homeRow: string, scope: ViewingScopeResolver): boolean;
|
|
922
|
+
|
|
923
|
+
export { type AuthzFunctionRow, type AuthzRoleOverrides, type AuthzRoleRow, type AuthzStateMap, type AuthzTeamPolicy, type AuthzTier1StateMap, CORE_FUNCTION_DEFAULT_BOUNDS, CORE_FUNCTION_DEFAULT_BOUNDS_SOT_VERSION, type CaseViewingAccess, DefaultBoundStateValue, type FunctionDoorInput, type FunctionDoorState, type FunctionLabelLookup, type FunctionRefusal, type GoverningViewingPolicy, type RecordViewingDecision, type RecordViewingReason, type ResolveEffectiveFunctionsInput, type StoredViewingWhitelist, VIEWING_LEVEL_FUNCTIONS, VIEWING_POLICY_SPECIES, VIEWING_POLICY_VOCABULARIES, type ViewingContext, type ViewingLevel, type ViewingPolicyGoverning, type ViewingPolicyNone, type ViewingPolicyQuery, type ViewingPolicyRef, type ViewingPolicyScopeResolver, type ViewingPolicyScopeVocab, type ViewingPolicyUnavailable, type ViewingPolicyUnavailableReason, type ViewingPolicyVocabulary, type ViewingRecord, type ViewingScopeResolver, type ViewingSurface, canonicalRoleCode, caseSurfacesAsStub, caseSurfacesOn, caseViewingAccess, codebookDefaultBound, explainFunctionRefusal, functionDoor, isCanonEvaluableFunction, recordViewing, resolveEffectiveFunctions, resolveEffectiveViewingLevel, resolveViewingPolicy, selectActingTeamId, teamViewingLevelFromPolicy, unavailableViewingPolicy, viewingComponentOpen, viewingLevelFromFunctions, viewingPolicyVocabulary, viewingRowVisible, viewingWhitelistFromPolicy };
|
package/dist/authz/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as PermissionStateValue, d as DefaultBoundStateValue } from '../platform-auth-DJO-r9Pf.js';
|
|
2
2
|
export { D as DEFAULT_BOUND_STATE, a as DEFAULT_BOUND_STATE_DISPLAY, b as DEFAULT_BOUND_STATE_LABELS, c as DEFAULT_BOUND_STATE_VALUES } from '../platform-auth-DJO-r9Pf.js';
|
|
3
|
+
import { d as InformationScopeResolver, l as ScopeReading, w as ScopeSubjectKind } from '../informationScopeResolver-BzYu97DE.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @htilabs/platform-common-models — the shared CVC-133 authorization resolver
|
|
@@ -601,4 +602,322 @@ declare function functionDoor(input: FunctionDoorInput): FunctionDoorState;
|
|
|
601
602
|
*/
|
|
602
603
|
declare function canonicalRoleCode(code: unknown): string | null;
|
|
603
604
|
|
|
604
|
-
|
|
605
|
+
/**
|
|
606
|
+
* @htilabs/platform-common-models/authz — the account's Internal Viewing Policy
|
|
607
|
+
* reader: which stored viewing rule governs one acting team.
|
|
608
|
+
*
|
|
609
|
+
* Contract of record: "Contract — the account's Internal Viewing Policy: stored
|
|
610
|
+
* shape and delivery to Thread and PAVE (Kickoff 13 § 5a)", §§ 1–4. Lifted from
|
|
611
|
+
* PAVE's `@pave/db` `readViewingPolicy` (pave-2.0 develop 41f5f916,
|
|
612
|
+
* `packages/db/src/lookups/viewingPolicy.ts`) so Thread and PAVE run ONE reader
|
|
613
|
+
* (GDR § 5.79, one resolver per runtime). The selection and validation rules are
|
|
614
|
+
* PAVE's, unchanged; only the I/O is left to the app.
|
|
615
|
+
*
|
|
616
|
+
* ## Pure: each app does its own query
|
|
617
|
+
*
|
|
618
|
+
* No database access. The app reads the candidate rows itself — the account's
|
|
619
|
+
* `registry_policies` documents (`species: "viewing"`, `account_id` = the acting
|
|
620
|
+
* agency's Account; passing every policy of the account is fine, other species are
|
|
621
|
+
* skipped here) — and hands them in with `{ accountId, teamId }`. A failed read is
|
|
622
|
+
* passed as `docs: null` (or answered with {@link unavailableViewingPolicy}); it is
|
|
623
|
+
* never an empty list, because an empty list means "nothing on file".
|
|
624
|
+
*
|
|
625
|
+
* ## Which row governs (Crysta 2026-10-06, ruling (a))
|
|
626
|
+
*
|
|
627
|
+
* The acting team's OWN active row governs that team IN PLACE OF the account-wide
|
|
628
|
+
* rule — higher or lower; the two are never combined. With no team row, the
|
|
629
|
+
* account-wide rule governs. With neither, nothing governs: `source: "none"`, and
|
|
630
|
+
* the role level alone decides (Level 3 shows the full record; Crysta 2026-11-03,
|
|
631
|
+
* "Match the prototype"). The role clamps afterwards:
|
|
632
|
+
* `viewingLevelFromFunctions(effectiveFunctions, teamViewingLevelFromPolicy(result))`.
|
|
633
|
+
* Prototype: `viewingPolicyFor`, platform-prototype `src/data.js` (aa2c63a).
|
|
634
|
+
*
|
|
635
|
+
* ## Fail closed, never throw (contract § 4)
|
|
636
|
+
*
|
|
637
|
+
* Anything that stops the policy being READ answers `source: "unavailable"`
|
|
638
|
+
* (level 0 for that request) with a coded reason — never `"none"`: the account
|
|
639
|
+
* cannot be resolved; the read failed; a live viewing row whose assignment is not
|
|
640
|
+
* exactly one account-or-team entry (it might be this team's narrowing); a row in
|
|
641
|
+
* this team's or the account's place whose `active` is neither `true` nor `false`;
|
|
642
|
+
* two live rows in one place without distinct versions of one family; and, on the
|
|
643
|
+
* governing row, a `level` that is not exactly 0–3, a `visibleGroups` that is
|
|
644
|
+
* present but not a list of strings or names a code that is not live at its stamp,
|
|
645
|
+
* a `scopeVocab` that is missing or not 3, 4 or 5. A malformed team row never falls
|
|
646
|
+
* back to the account rule (that fallback could widen).
|
|
647
|
+
*
|
|
648
|
+
* A governing row with no `visibleGroups` reads as an EMPTY list (contract § 4;
|
|
649
|
+
* PAVE `caseViewing.ts` `accessFromResolution`): only "no row at all" shows the
|
|
650
|
+
* full record. System information is always shown — that is the Level 3 filter's
|
|
651
|
+
* job ({@link caseViewingAccess}), not this reader's.
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
/** The stored `species` of an internal-viewing policy (UDD Policy.v1). */
|
|
655
|
+
declare const VIEWING_POLICY_SPECIES: "viewing";
|
|
656
|
+
/** What one of the prototype's viewing-policy vocabulary stamps means to a reader. */
|
|
657
|
+
interface ViewingPolicyVocabulary {
|
|
658
|
+
/** The CVC-236 tree version the resolver reads the list at (3 through the v3 → v4 table, or 4). */
|
|
659
|
+
readonly scopeVersion: 3 | 4;
|
|
660
|
+
/** The prototype's ONE-HOME domain carry applies (`scopeVocab < 4`). */
|
|
661
|
+
readonly oneHomeCarry: boolean;
|
|
662
|
+
/** The prototype's v4 alias on `identifying` applies (`scopeVocab < 5`). */
|
|
663
|
+
readonly identifyingAlias: boolean;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* The stamps a stored viewing policy's `scopeVocab` may carry and still be read.
|
|
667
|
+
*
|
|
668
|
+
* The stamp is the Internal Viewing tab's own counter, NOT the CVC-236 tree
|
|
669
|
+
* version: the hub stamps every save `5` for the four-level v4 tree
|
|
670
|
+
* (platform-prototype `src/screens.jsx` `setLevel` / `toggleGroup` /
|
|
671
|
+
* `setAcctLevel`). Earlier saves stamped 4 (ONE-HOME) and 3 (the Instruments
|
|
672
|
+
* catalog), both authored against the v3 tree. Stamps 1 and 2 and every future
|
|
673
|
+
* stamp (6 and up) are not read: they fail closed. Lifted from PAVE
|
|
674
|
+
* `@pave/domain` `VIEWING_POLICY_VOCABULARIES`.
|
|
675
|
+
*/
|
|
676
|
+
declare const VIEWING_POLICY_VOCABULARIES: Readonly<Record<3 | 4 | 5, ViewingPolicyVocabulary>>;
|
|
677
|
+
/** A stamp this reader reads. */
|
|
678
|
+
type ViewingPolicyScopeVocab = 3 | 4 | 5;
|
|
679
|
+
/** The reading of a stored `scopeVocab`, or `null` when it cannot be read (fail closed). */
|
|
680
|
+
declare function viewingPolicyVocabulary(scopeVocab: unknown): ViewingPolicyVocabulary | null;
|
|
681
|
+
/**
|
|
682
|
+
* The bound CVC-236 resolver the reader validates a whitelist with — the app's
|
|
683
|
+
* own binding of `createInformationScopeResolver` to `coreInformationScopeSot`
|
|
684
|
+
* (PAVE `INFORMATION_SCOPE_V4`, Thread `INFORMATION_SCOPE_RESOLVER`). Passed in
|
|
685
|
+
* so the browser-safe `./authz` entry never inlines the SOT JSON.
|
|
686
|
+
*/
|
|
687
|
+
type ViewingPolicyScopeResolver = Pick<InformationScopeResolver, "row" | "readSelection">;
|
|
688
|
+
/** Who is asking. */
|
|
689
|
+
interface ViewingPolicyQuery {
|
|
690
|
+
/**
|
|
691
|
+
* The Account that owns the policy — the acting agency's Account, which the
|
|
692
|
+
* caller resolved. Empty / null = the account could not be resolved
|
|
693
|
+
* (`unavailable`, `account_unresolved`).
|
|
694
|
+
*/
|
|
695
|
+
accountId: string | null | undefined;
|
|
696
|
+
/**
|
|
697
|
+
* The ONE acting team, already bound by the caller to the acting agency
|
|
698
|
+
* (Thread `resolveSeatActingTeamId`, PAVE `viewingTeamOfAgency`). `null` = no
|
|
699
|
+
* acting team, so only the account-wide rule can govern. A 24-hex id is
|
|
700
|
+
* compared case-insensitively.
|
|
701
|
+
*/
|
|
702
|
+
teamId: string | null | undefined;
|
|
703
|
+
}
|
|
704
|
+
/** Why the policy could not be read. The first four are the app's I/O outcomes. */
|
|
705
|
+
type ViewingPolicyUnavailableReason = "no_acting_agency" | "account_unresolved" | "policy_store_absent" | "read_error" | "unreadable_assignment" | "malformed_active" | "ambiguous_rows" | "malformed_level" | "malformed_visible_groups" | "unknown_visible_group" | "malformed_scope_vocab" | "unsupported_scope_vocab";
|
|
706
|
+
/** The governing row's identity (prototype `viewingPolicyFor` `policy`). */
|
|
707
|
+
interface ViewingPolicyRef {
|
|
708
|
+
/** The row's `entity_id`, else `id`, else `_id`. */
|
|
709
|
+
readonly id: string;
|
|
710
|
+
readonly familyId: string | null;
|
|
711
|
+
/** A positive integer, or `null` when the row carries none (or a malformed one). */
|
|
712
|
+
readonly version: number | null;
|
|
713
|
+
}
|
|
714
|
+
/** A team's own row, or the account-wide rule, governs. */
|
|
715
|
+
interface ViewingPolicyGoverning {
|
|
716
|
+
readonly source: "team" | "account";
|
|
717
|
+
/** The level the policy grants (before the role clamp). */
|
|
718
|
+
readonly level: ViewingLevel;
|
|
719
|
+
/**
|
|
720
|
+
* The categories still shown at Level 3, as stored (a copy), minus any
|
|
721
|
+
* `category_rest` row. A row with no list reads `[]` (only the stub and system
|
|
722
|
+
* information show). Every code is live at the tree version `scopeVocab` reads.
|
|
723
|
+
*/
|
|
724
|
+
readonly visibleGroups: readonly string[];
|
|
725
|
+
readonly scopeVocab: ViewingPolicyScopeVocab;
|
|
726
|
+
readonly policy: ViewingPolicyRef;
|
|
727
|
+
readonly accountId: string;
|
|
728
|
+
/** A short, value-free trace of the decision, for logs (ids and versions only). */
|
|
729
|
+
readonly rulePath: string;
|
|
730
|
+
}
|
|
731
|
+
/** No row governs: the account set nothing for this team. The role level alone decides. */
|
|
732
|
+
interface ViewingPolicyNone {
|
|
733
|
+
readonly source: "none";
|
|
734
|
+
readonly level: null;
|
|
735
|
+
/** `null`: no row, so Level 3 shows the full record. */
|
|
736
|
+
readonly visibleGroups: null;
|
|
737
|
+
readonly scopeVocab: null;
|
|
738
|
+
readonly policy: null;
|
|
739
|
+
readonly accountId: string;
|
|
740
|
+
/** The account holds viewing rows and every one is retired (`active: false`): log it. */
|
|
741
|
+
readonly retiredRowsOnly: boolean;
|
|
742
|
+
readonly rulePath: string;
|
|
743
|
+
}
|
|
744
|
+
/** The policy could not be read: no view of other teams' cases for this request. */
|
|
745
|
+
interface ViewingPolicyUnavailable {
|
|
746
|
+
readonly source: "unavailable";
|
|
747
|
+
readonly level: 0;
|
|
748
|
+
readonly visibleGroups: readonly string[];
|
|
749
|
+
readonly scopeVocab: null;
|
|
750
|
+
readonly policy: null;
|
|
751
|
+
readonly reason: ViewingPolicyUnavailableReason;
|
|
752
|
+
/** The offending row's id, when one row caused it. */
|
|
753
|
+
readonly policyId: string | null;
|
|
754
|
+
readonly rulePath: string;
|
|
755
|
+
}
|
|
756
|
+
type GoverningViewingPolicy = ViewingPolicyGoverning | ViewingPolicyNone | ViewingPolicyUnavailable;
|
|
757
|
+
/**
|
|
758
|
+
* The policy could not be read — the shape every fail-closed answer takes. Apps
|
|
759
|
+
* use it for their own I/O outcomes (`read_error`, `policy_store_absent`, …).
|
|
760
|
+
*/
|
|
761
|
+
declare function unavailableViewingPolicy(reason: ViewingPolicyUnavailableReason, policyId?: string | null): ViewingPolicyUnavailable;
|
|
762
|
+
/**
|
|
763
|
+
* The internal-viewing policy that governs `query.teamId` on `query.accountId`,
|
|
764
|
+
* chosen from the candidate rows the app read. NEVER throws; see the module
|
|
765
|
+
* header for every outcome.
|
|
766
|
+
*
|
|
767
|
+
* `docs`: the account's policy documents (`registry_policies`), or `null` /
|
|
768
|
+
* `undefined` when the read failed (`read_error`). Rows of another species or
|
|
769
|
+
* another account are skipped, as the app's own query would have left them out.
|
|
770
|
+
* Mongo answers `[]` for a collection that does not exist, so on an empty answer
|
|
771
|
+
* the app must check that the policy store exists and pass
|
|
772
|
+
* `unavailableViewingPolicy("policy_store_absent")` when it does not (PAVE's
|
|
773
|
+
* reader checks with `listCollections`); an empty list from a store that exists
|
|
774
|
+
* means "none".
|
|
775
|
+
*/
|
|
776
|
+
declare function resolveViewingPolicy(docs: readonly unknown[] | null | undefined, query: ViewingPolicyQuery, scope: ViewingPolicyScopeResolver): GoverningViewingPolicy;
|
|
777
|
+
/**
|
|
778
|
+
* The `teamViewingLevel` argument of `viewingLevelFromFunctions` /
|
|
779
|
+
* `resolveEffectiveViewingLevel` (contract § 3): the row's level when a row
|
|
780
|
+
* governs; `null` when none does (the role level alone decides); `0` when the
|
|
781
|
+
* policy could not be read (fail closed).
|
|
782
|
+
*/
|
|
783
|
+
declare function teamViewingLevelFromPolicy(policy: GoverningViewingPolicy): ViewingLevel | null;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* @htilabs/platform-common-models/authz — the Level 3 category filter of internal
|
|
787
|
+
* viewing: what of a case a viewer who does not own it may see, given the
|
|
788
|
+
* effective level and the governing policy's `visibleGroups` / `scopeVocab`.
|
|
789
|
+
*
|
|
790
|
+
* Lifted from PAVE `@pave/domain` `viewingScope.ts` (pave-2.0 develop 41f5f916:
|
|
791
|
+
* `caseViewingAccess`, `recordViewing`, `caseSurfacesOn`, `caseSurfacesAsStub`)
|
|
792
|
+
* and `viewingProjection.ts` (`viewingComponentOpen`), unchanged in behaviour.
|
|
793
|
+
* The only difference: PAVE reads its module-level resolver binding; here the
|
|
794
|
+
* app passes its own binding of the CVC-236 v4 resolver (`scope`), so the
|
|
795
|
+
* browser-safe `./authz` entry never inlines the SOT JSON. PAVE's wire
|
|
796
|
+
* projections (`viewingProjection` field lists, route homes) and the stub
|
|
797
|
+
* projection stay in the app.
|
|
798
|
+
*
|
|
799
|
+
* Pure and I/O-free: the caller resolves every fact about the viewer (effective
|
|
800
|
+
* level, whether the case passes its agency / team row filter, ownership, the
|
|
801
|
+
* governing policy) and this module only decides.
|
|
802
|
+
*
|
|
803
|
+
* Rules (contract § 2; Crysta 2026-11-03; prototype `recordOpenAccess`,
|
|
804
|
+
* `carVisibleUnderAccess`, `applyViewingPolicy`):
|
|
805
|
+
* - a case the viewer cannot see: nothing; an owned case: the full record;
|
|
806
|
+
* - level 1: the stub in search; level 2: the stub in search and pickers;
|
|
807
|
+
* neither opens the record; level 0: nothing;
|
|
808
|
+
* - level 3 with NO policy on file (`whitelist: null`): the full record;
|
|
809
|
+
* - level 3 with a policy: the client's stub rows and system information
|
|
810
|
+
* always, plus whatever the whitelist COVERS on the record's kind-tree home
|
|
811
|
+
* row (a category covers that category under every person on the record).
|
|
812
|
+
* Unmapped or uncovered is hidden; an empty list hides everything else;
|
|
813
|
+
* - the author always sees their own record on a case they can see.
|
|
814
|
+
*/
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* The bound CVC-236 resolver the Level 3 filter reads (the app's binding of
|
|
818
|
+
* `createInformationScopeResolver` to `coreInformationScopeSot`).
|
|
819
|
+
*/
|
|
820
|
+
type ViewingScopeResolver = Pick<InformationScopeResolver, "row" | "readSelection" | "isCovered">;
|
|
821
|
+
/** Where a non-owned case can surface (prototype `applyViewingPolicy` context + record open). */
|
|
822
|
+
type ViewingSurface = "search" | "autocomplete" | "open";
|
|
823
|
+
/** A stored viewing whitelist (the admin-set by-category selection). */
|
|
824
|
+
interface StoredViewingWhitelist {
|
|
825
|
+
/** Flat list of scope codes (the policy's `visibleGroups`). */
|
|
826
|
+
informationScope: readonly string[] | null | undefined;
|
|
827
|
+
/**
|
|
828
|
+
* The policy's vocabulary stamp as the hub wrote it (`scopeVocab`: 3, 4 or 5) —
|
|
829
|
+
* never the CVC-236 tree version. Any other value reads nothing.
|
|
830
|
+
*/
|
|
831
|
+
scopeVocab: number | null | undefined;
|
|
832
|
+
}
|
|
833
|
+
/** Everything the caller resolved about the viewer and the case. */
|
|
834
|
+
interface ViewingContext {
|
|
835
|
+
/** The case passes the caller's agency / team row filter. `false` ⇒ nothing on it. */
|
|
836
|
+
canSeeCase: boolean;
|
|
837
|
+
/** The case is owned / claimed by the viewer or their team: always fully visible. */
|
|
838
|
+
ownedByViewer: boolean;
|
|
839
|
+
/** The effective viewing level (`viewingLevelFromFunctions`). */
|
|
840
|
+
level: ViewingLevel;
|
|
841
|
+
/**
|
|
842
|
+
* The governing policy's whitelist ({@link viewingWhitelistFromPolicy}). `null`
|
|
843
|
+
* means exactly one thing: NO viewing policy is on file, so Level 3 renders every
|
|
844
|
+
* component. A row with no list is an empty list, not `null`.
|
|
845
|
+
*/
|
|
846
|
+
whitelist: StoredViewingWhitelist | null;
|
|
847
|
+
}
|
|
848
|
+
/** The decision for one case. */
|
|
849
|
+
type CaseViewingAccess = {
|
|
850
|
+
readonly mode: "full";
|
|
851
|
+
readonly reason: "owned" | "no_viewing_policy";
|
|
852
|
+
} | {
|
|
853
|
+
readonly mode: "none";
|
|
854
|
+
readonly reason: "cannot_see_case" | "level_0";
|
|
855
|
+
} | {
|
|
856
|
+
readonly mode: "stub";
|
|
857
|
+
readonly level: 1 | 2;
|
|
858
|
+
} | {
|
|
859
|
+
readonly mode: "whitelist";
|
|
860
|
+
/** The whitelist's v4 reading (`readSelection`, subject `policy`), untouched. */
|
|
861
|
+
readonly reading: ScopeReading;
|
|
862
|
+
/**
|
|
863
|
+
* The list coverage is read on: the reading, plus `relationships_household`
|
|
864
|
+
* when the prototype's v4 alias on `identifying` applies (a stamp below 5).
|
|
865
|
+
*/
|
|
866
|
+
readonly visibleScope: readonly string[];
|
|
867
|
+
/** The prototype's ONE-HOME domain carry applies (stamp 3). */
|
|
868
|
+
readonly oneHomeCarry: boolean;
|
|
869
|
+
/** The v4 alias carries `relationship_dynamics` at domain grain (stamp < 5 naming `identifying`). */
|
|
870
|
+
readonly relationshipDynamicsCarry: boolean;
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* The whitelist {@link caseViewingAccess} reads for a governing-policy result:
|
|
874
|
+
* `null` when nothing governs (the full record at Level 3); the row's list and
|
|
875
|
+
* stamp when a row governs; an unreadable empty list when the policy is
|
|
876
|
+
* unavailable (whose level 0 already shows nothing — never widens).
|
|
877
|
+
*/
|
|
878
|
+
declare function viewingWhitelistFromPolicy(policy: GoverningViewingPolicy): StoredViewingWhitelist | null;
|
|
879
|
+
/** Resolve a viewer's access to one case. */
|
|
880
|
+
declare function caseViewingAccess(ctx: ViewingContext, scope: ViewingScopeResolver): CaseViewingAccess;
|
|
881
|
+
/**
|
|
882
|
+
* Does the case surface on `surface`? Level 1 — search only; level 2 — search and
|
|
883
|
+
* autocomplete; neither opens the record. Level 3 and full open it.
|
|
884
|
+
*/
|
|
885
|
+
declare function caseSurfacesOn(access: CaseViewingAccess, surface: ViewingSurface): boolean;
|
|
886
|
+
/** Does the case surface as the stub projection (levels 1 and 2 only)? */
|
|
887
|
+
declare function caseSurfacesAsStub(access: CaseViewingAccess): boolean;
|
|
888
|
+
/** One record on a case, as the viewing decision reads it. */
|
|
889
|
+
interface ViewingRecord {
|
|
890
|
+
/** The v4 kind-tree row the record's field is homed on (never a per-kind code). */
|
|
891
|
+
homeRow: string;
|
|
892
|
+
/** Whose record it is: the client, or another named person's kind. */
|
|
893
|
+
subjectKind: ScopeSubjectKind;
|
|
894
|
+
/** The author's user id. The author always sees their own record. */
|
|
895
|
+
authorUserId?: string | null | undefined;
|
|
896
|
+
/** The record's assertion domain, read ONLY by the pre-v4 carries. */
|
|
897
|
+
domain?: string | null | undefined;
|
|
898
|
+
}
|
|
899
|
+
/** Why a record is (not) visible. */
|
|
900
|
+
type RecordViewingReason = "author" | "full" | "stub_row" | "covered" | "one_home_carry" | "identifying_alias_carry" | "cannot_see_case" | "level_0" | "not_opened" | "not_covered" | "unknown_row";
|
|
901
|
+
interface RecordViewingDecision {
|
|
902
|
+
readonly visible: boolean;
|
|
903
|
+
readonly reason: RecordViewingReason;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* May the viewer see this record on the case? A case the viewer cannot see:
|
|
907
|
+
* nothing (checked first, even for the author); the author: their own record;
|
|
908
|
+
* level 0: nothing; an owned case or no policy: all; level 1 / 2: the record never
|
|
909
|
+
* opens; level 3: the client's stub rows always, otherwise the whitelist must
|
|
910
|
+
* COVER the record's kind-tree home row.
|
|
911
|
+
*/
|
|
912
|
+
declare function recordViewing(access: CaseViewingAccess, record: ViewingRecord, viewerUserId: string | null | undefined, scope: ViewingScopeResolver): RecordViewingDecision;
|
|
913
|
+
/** Is this kind-tree row visible under `access` (for the client)? */
|
|
914
|
+
declare function viewingRowVisible(access: CaseViewingAccess, homeRow: string, scope: ViewingScopeResolver): boolean;
|
|
915
|
+
/**
|
|
916
|
+
* Is this home row OPEN as a whole component under `access`: does the whitelist
|
|
917
|
+
* itself cover it? Stricter than {@link viewingRowVisible}: the stub (a name and a
|
|
918
|
+
* date of birth) does not open a whole component such as the name history behind
|
|
919
|
+
* it. System information is on every list, so it opens.
|
|
920
|
+
*/
|
|
921
|
+
declare function viewingComponentOpen(access: CaseViewingAccess, homeRow: string, scope: ViewingScopeResolver): boolean;
|
|
922
|
+
|
|
923
|
+
export { type AuthzFunctionRow, type AuthzRoleOverrides, type AuthzRoleRow, type AuthzStateMap, type AuthzTeamPolicy, type AuthzTier1StateMap, CORE_FUNCTION_DEFAULT_BOUNDS, CORE_FUNCTION_DEFAULT_BOUNDS_SOT_VERSION, type CaseViewingAccess, DefaultBoundStateValue, type FunctionDoorInput, type FunctionDoorState, type FunctionLabelLookup, type FunctionRefusal, type GoverningViewingPolicy, type RecordViewingDecision, type RecordViewingReason, type ResolveEffectiveFunctionsInput, type StoredViewingWhitelist, VIEWING_LEVEL_FUNCTIONS, VIEWING_POLICY_SPECIES, VIEWING_POLICY_VOCABULARIES, type ViewingContext, type ViewingLevel, type ViewingPolicyGoverning, type ViewingPolicyNone, type ViewingPolicyQuery, type ViewingPolicyRef, type ViewingPolicyScopeResolver, type ViewingPolicyScopeVocab, type ViewingPolicyUnavailable, type ViewingPolicyUnavailableReason, type ViewingPolicyVocabulary, type ViewingRecord, type ViewingScopeResolver, type ViewingSurface, canonicalRoleCode, caseSurfacesAsStub, caseSurfacesOn, caseViewingAccess, codebookDefaultBound, explainFunctionRefusal, functionDoor, isCanonEvaluableFunction, recordViewing, resolveEffectiveFunctions, resolveEffectiveViewingLevel, resolveViewingPolicy, selectActingTeamId, teamViewingLevelFromPolicy, unavailableViewingPolicy, viewingComponentOpen, viewingLevelFromFunctions, viewingPolicyVocabulary, viewingRowVisible, viewingWhitelistFromPolicy };
|