Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 24x 24x 24x | import { Doc } from "@/objects/Doc";
/** An access area (svc-core's `AccessArea`): agents, knowledge, governance,
* dashboards. The catalogue (`GET /access/catalogue`) names and describes
* them; nothing here lists them. */
export type AccessArea = string;
export type AccessLevel = "reader" | "writer" | "editor";
/** A member's level in each area. */
export type AccessMap = Record<AccessArea, AccessLevel>;
export const LEVEL_RANK: Record<AccessLevel, number> = {
reader: 1,
writer: 2,
editor: 3,
};
export interface AccessCatalogue {
areas: { key: AccessArea; label: string; description: string; kinds: string[] }[];
levels: { key: AccessLevel; label: string; description: string }[];
presets: { key: string; label: string; description: string; access: AccessMap }[];
/** Kinds whose creation or change needs an editor (rules). */
editor_only: string[];
}
export interface Organisation extends Doc {
name: string;
auth0_org_id?: string;
/** The code finance files its spend under (svc-core migration 100). */
cost_centre?: string | null;
created_at?: string;
/** The caller's role in it, on the list (null: a superuser who isn't in it). */
role?: OrganisationRole | null;
/** What the caller may do in each area there. */
access?: AccessMap | null;
}
/** svc-core's `MemberRole`: admins manage the organisation, members use and
* edit what it owns. */
export type OrganisationRole = "admin" | "member";
export const ORGANISATION_ROLES: readonly OrganisationRole[] = [
"admin",
"member",
];
export const ROLE_LABELS: Record<OrganisationRole, string> = {
admin: "Admin",
member: "Member",
};
export interface OrganisationMember {
user_id: string;
name: string | null;
email: string;
picture: string | null;
role: OrganisationRole;
/** Every area editor for an admin. */
access: AccessMap;
joined_at: string | null;
/** The signed-in user. */
is_you: boolean;
/** A project's admin by position, not by being added: the owning
* organisation's name for its admins, "owner" for a personal project's
* owner. Can't be changed or removed from the project's page. */
via?: string | null;
}
export type InviteStatus = "pending" | "accepted" | "revoked" | "expired";
export interface OrganisationInvite {
id: string;
email: string;
role: OrganisationRole;
access: AccessMap;
status: InviteStatus;
created_by_user_id: string | null;
created_at: string | null;
expires_at: string;
accepted_at: string | null;
revoked_at: string | null;
}
export interface CreatedInvite {
invite: OrganisationInvite;
/** Shown once: only its hash is stored. */
token: string;
}
export type MembershipKind = "organisation" | "project";
export interface InvitePreview {
/** What the invite admits you to. */
kind: MembershipKind;
target_id: string;
target_name: string;
role: OrganisationRole;
/** Masked, e.g. `a***@example.com`. */
email: string;
for_you: boolean;
access: AccessMap;
invited_by: string | null;
status: InviteStatus;
expires_at: string;
}
export interface InviteAccepted {
kind: MembershipKind;
target_id: string;
role: OrganisationRole;
already_member: boolean;
}
/** What the Members view needs: organisations and projects both provide it. */
export interface MembershipApi {
members: (id: string) => Promise<OrganisationMember[]>;
updateMember: (
id: string,
userId: string,
change: { role?: OrganisationRole; access?: AccessMap },
) => Promise<OrganisationMember>;
removeMember: (id: string, userId: string) => Promise<void>;
invites: (id: string) => Promise<OrganisationInvite[]>;
createInvite: (
id: string,
body: { email: string; role: OrganisationRole; access?: AccessMap },
) => Promise<CreatedInvite>;
revokeInvite: (id: string, inviteId: string) => Promise<void>;
}
|