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 CoreAppTablesPg } from '../coreAppTables.js';
5import type {
6 DecisionCountsInput,
7 JobCreationsInput,
8} from '../manualReviewToolService/modules/DecisionAnalytics.js';
9import { type OrgSettingsPg } from '../orgSettingsService/index.js';
10
11export type MrtChartConfig = {
12 title: string;
13} & (
14 | ({
15 metric: 'DECISIONS';
16 } & Omit<DecisionCountsInput, 'orgId' | 'timeZone'>)
17 | (
18 | {
19 metric: 'JOBS';
20 }
21 | Omit<JobCreationsInput, 'orgId' | 'timeZone'>
22 )
23);
24
25export type UserManagementPg = {
26 'user_management_service.user_interface_settings': {
27 user_id: string;
28 moderator_safety_mute_video: boolean | null;
29 moderator_safety_grayscale: boolean | null;
30 moderator_safety_blur_level: number | null;
31 mrt_chart_configurations: MrtChartConfig[] | null;
32 };
33 // We use ColumnType in this table because all the moderator_safety columns
34 // are non-null and have default values, so we can provide null values on
35 // INSERT and UPDATE operations, but not on SELECT queries.
36 'user_management_service.org_default_user_interface_settings': {
37 org_id: string;
38 moderator_safety_mute_video: ColumnType<
39 boolean,
40 boolean | undefined,
41 boolean | undefined
42 >;
43 moderator_safety_grayscale: ColumnType<
44 boolean,
45 boolean | undefined,
46 boolean | undefined
47 >;
48 moderator_safety_blur_level: ColumnType<
49 number,
50 number | undefined,
51 number | undefined
52 >;
53 };
54 'user_management_service.password_reset_tokens': {
55 hashed_token: string;
56 user_id: string;
57 org_id: string;
58 created_at: Date;
59 };
60 // Shared definition lives in `services/coreAppTables.ts` so Kysely instances
61 // typed on either `UserManagementPg` or `CombinedPg` see the same columns.
62 'public.users': CoreAppTablesPg['public.users'];
63 'public.invite_user_tokens': {
64 id: GeneratedAlways<string>;
65 token: string;
66 email: string;
67 role: UserRole;
68 created_at: GeneratedAlways<Date>;
69 updated_at: GeneratedAlways<Date>;
70 org_id: string;
71 };
72 'public.org_settings': Pick<
73 OrgSettingsPg['public.org_settings'],
74 'org_id' | 'saml_enabled'
75 >;
76};