Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 175 lines 6.0 kB view raw
1import { type ItemTypeKind } from '@roostorg/types'; 2import { type Generated, type GeneratedAlways } from 'kysely'; 3import { type JsonObject, type JsonValue } from 'type-fest'; 4 5import { type TaggedUnionFromCases } from '../../utils/typescript-types.js'; 6import { type ActionType } from './types/actions.js'; 7import { type ItemSchema } from './types/itemTypes.js'; 8import type { PolicyType } from './types/policies.js'; 9import { 10 type ConditionSet, 11 type RuleAlarmStatus, 12 type RuleStatus, 13 type RuleType, 14} from './types/rules.js'; 15import { type UserPenaltySeverity } from './types/shared.js'; 16 17export type ModerationConfigServicePg = { 18 'public.item_types': { 19 id: Generated<string>; 20 name: string; 21 description: string | null; 22 org_id: string; 23 created_at: GeneratedAlways<Date>; 24 kind: ItemTypeKind; 25 fields: ItemSchema; 26 is_default_user: Generated<boolean>; 27 display_name_field: string | null; 28 creator_id_field: string | null; 29 thread_id_field: string | null; 30 parent_id_field: string | null; 31 created_at_field: string | null; 32 profile_icon_field: string | null; 33 background_image_field: string | null; 34 is_deleted_field: string | null; 35 }; 36 // TODO: redefine as a union to capture the correlation of the nulls, 37 // then leverage FixKyselyRowCorrelation in the ItemTypesDbResult type. 38 // This'll make the typing (including for our tests) a bit more accurate. 39 'public.item_type_versions': { 40 id: GeneratedAlways<string>; 41 name: GeneratedAlways<string>; 42 description: GeneratedAlways<string | null>; 43 org_id: GeneratedAlways<string>; 44 created_at: GeneratedAlways<Date>; 45 kind: GeneratedAlways<ItemTypeKind>; 46 fields: GeneratedAlways<ItemSchema>; 47 is_default_user: GeneratedAlways<boolean>; 48 display_name_field: GeneratedAlways<string | null>; 49 creator_id_field: GeneratedAlways<string | null>; 50 thread_id_field: GeneratedAlways<string | null>; 51 parent_id_field: GeneratedAlways<string | null>; 52 created_at_field: GeneratedAlways<string | null>; 53 profile_icon_field: GeneratedAlways<string | null>; 54 background_image_field: GeneratedAlways<string | null>; 55 is_deleted_field: GeneratedAlways<string | null>; 56 version: GeneratedAlways<string>; 57 is_current: GeneratedAlways<boolean>; 58 }; 59 'public.rules_and_item_types': { 60 rule_id: string; 61 item_type_id: string; 62 created_at: GeneratedAlways<Date>; 63 updated_at: GeneratedAlways<Date>; 64 }; 65 'public.rules_and_actions': { 66 action_id: string; 67 rule_id: string; 68 created_at: GeneratedAlways<Date>; 69 updated_at: GeneratedAlways<Date>; 70 sys_period: GeneratedAlways<unknown>; 71 }; 72 'public.rules_and_policies': { 73 policy_id: string; 74 rule_id: string; 75 created_at: Date; 76 updated_at: Date; 77 sys_period: GeneratedAlways<unknown>; 78 }; 79 'public.actions_and_item_types': { 80 action_id: string; 81 item_type_id: string; 82 created_at: GeneratedAlways<Date>; 83 updated_at: GeneratedAlways<Date>; 84 sys_period: GeneratedAlways<unknown>; 85 }; 86 'public.actions': { 87 id: string; 88 org_id: string; 89 name: string; 90 description: string | null; 91 penalty: UserPenaltySeverity; 92 // TODO: while we expect these to be null if the action type is not 93 // CUSTOM_ACTION, and won't return them from the moderation config 94 // service, the db doesn't actually enforce that. 95 callback_url_headers: JsonObject | null; 96 callback_url_body: JsonObject | null; 97 // TODO: when we move updates to the moderation config service, figure out 98 // whether to set `updated_at` on update or whether to just drop the column, 99 // given the challenge of inerpreting the `updated_at` column on an entity 100 // that has part of its data in other tables (e.g., should we update the 101 // action's updated_at when we update its set of item types?) 102 created_at: GeneratedAlways<Date>; 103 updated_at: Generated<Date>; 104 applies_to_all_items_of_kind: Generated<ItemTypeKind[]>; 105 apply_user_strikes: boolean; 106 custom_mrt_api_params: JsonValue[] | null; 107 } & TaggedUnionFromCases< 108 { action_type: ActionType }, 109 { 110 CUSTOM_ACTION: { callback_url: string }; 111 ENQUEUE_TO_NCMEC: { callback_url: null }; 112 ENQUEUE_TO_MRT: { callback_url: null }; 113 ENQUEUE_AUTHOR_TO_MRT: { callback_url: null }; 114 REJECT_APPEAL: { callback_url: null }; 115 ACCEPT_APPEAL: { callback_url: null }; 116 } 117 >; 118 'public.rules_latest_versions': { 119 rule_id: string; 120 version: string; 121 }; 122 'public.rules': { 123 id: string; 124 name: string; 125 description: string | null; 126 status_if_unexpired: RuleStatus; 127 tags: string[]; 128 max_daily_actions: number | null; 129 daily_actions_run: number; 130 last_action_date: string | null; 131 created_at: GeneratedAlways<Date>; 132 updated_at: GeneratedAlways<Date>; 133 org_id: string; 134 creator_id: string; 135 expiration_time: Date | null; 136 condition_set: ConditionSet; 137 alarm_status: Generated<RuleAlarmStatus>; 138 alarm_status_set_at: Generated<Date>; 139 rule_type: RuleType; 140 parent_id: string | null; 141 }; 142 'public.policies': { 143 id: string; 144 name: string; 145 org_id: string; 146 parent_id: string | null; 147 created_at: GeneratedAlways<Date>; 148 updated_at: Date; 149 policy_text: string | null; 150 enforcement_guidelines: string | null; 151 penalty: UserPenaltySeverity; 152 sys_period: GeneratedAlways<unknown>; 153 semantic_version: number; 154 policy_type: PolicyType | null; 155 user_strike_count: Generated<number>; 156 apply_user_strike_count_config_to_children: Generated<boolean>; 157 }; 158 'public.user_strike_thresholds': { 159 id: GeneratedAlways<string>; 160 org_id: string; 161 threshold: number; 162 actions: string[]; 163 }; 164 'public.text_banks': { 165 id: string; 166 name: string; 167 description: string | null; 168 org_id: string; 169 created_at: GeneratedAlways<Date>; 170 updated_at: Date; 171 owner_id: string | null; 172 type: 'STRING' | 'REGEX'; 173 strings: string[]; 174 }; 175};