Mirror of https://github.com/roostorg/coop
github.com/roostorg/coop
1import type { ColumnType, GeneratedAlways } from 'kysely';
2
3import type { UserRole } from '../../models/types/permissioning.js';
4import type {
5 DecisionCountsInput,
6 JobCreationsInput,
7} from '../manualReviewToolService/modules/DecisionAnalytics.js';
8import { type OrgSettingsPg } from '../orgSettingsService/index.js';
9
10export type MrtChartConfig = {
11 title: string;
12} & (
13 | ({
14 metric: 'DECISIONS';
15 } & Omit<DecisionCountsInput, 'orgId' | 'timeZone'>)
16 | (
17 | {
18 metric: 'JOBS';
19 }
20 | Omit<JobCreationsInput, 'orgId' | 'timeZone'>
21 )
22);
23
24export type UserManagementPg = {
25 'user_management_service.user_interface_settings': {
26 user_id: string;
27 moderator_safety_mute_video: boolean | null;
28 moderator_safety_grayscale: boolean | null;
29 moderator_safety_blur_level: number | null;
30 mrt_chart_configurations: MrtChartConfig[] | null;
31 };
32 // We use ColumnType in this table because all the moderator_safety columns
33 // are non-null and have default values, so we can provide null values on
34 // INSERT and UPDATE operations, but not on SELECT queries.
35 'user_management_service.org_default_user_interface_settings': {
36 org_id: string;
37 moderator_safety_mute_video: ColumnType<
38 boolean,
39 boolean | undefined,
40 boolean | undefined
41 >;
42 moderator_safety_grayscale: ColumnType<
43 boolean,
44 boolean | undefined,
45 boolean | undefined
46 >;
47 moderator_safety_blur_level: ColumnType<
48 number,
49 number | undefined,
50 number | undefined
51 >;
52 };
53 'user_management_service.password_reset_tokens': {
54 hashed_token: string;
55 user_id: string;
56 org_id: string;
57 created_at: Date;
58 };
59 'public.users': {
60 id: GeneratedAlways<string>;
61 email: string;
62 password: string;
63 first_name: string;
64 last_name: string;
65 role: UserRole;
66 approved_by_admin: boolean;
67 rejected_by_admin: boolean;
68 created_at: GeneratedAlways<Date>;
69 updated_at: GeneratedAlways<Date>;
70 org_id: string;
71 };
72 'public.invite_user_tokens': {
73 id: GeneratedAlways<string>;
74 token: string;
75 email: string;
76 role: UserRole;
77 created_at: GeneratedAlways<Date>;
78 updated_at: GeneratedAlways<Date>;
79 org_id: string;
80 };
81 'public.org_settings': Pick<
82 OrgSettingsPg['public.org_settings'],
83 'org_id' | 'saml_enabled'
84 >;
85};