Almost MVP

This commit is contained in:
2022-11-22 04:03:32 +01:00
parent ea3b7aeecf
commit dcaa052f30
19 changed files with 430 additions and 134 deletions
+13 -4
View File
@@ -4,8 +4,8 @@
export type MetadataProps = 'id' | 'createdAt'
type Opaque<T, K, L extends string = 'opaque'> = T & { _: K; __: L }
type Id<T> = Opaque<string, T, 'id'>
export type Opaque<T, K, L extends string = 'opaque'> = T & { _: K; __: L }
export type Id<T> = Opaque<string, T, 'id'>
//
// Users
@@ -20,6 +20,7 @@ export type UserId = Id<User>
export type User = {
id: UserId
role: UserRole
}
@@ -39,9 +40,10 @@ export type ProblemId = Id<Problem>
export type Problem = {
id: ProblemId
createdAt: string
content: string
createdBy: UserId
createdAt: string
}
//
@@ -50,12 +52,19 @@ export type Problem = {
export type SolutionStatus = 'pending' | 'correct' | 'wrong'
export type SolutionId = string
export type SolutionId = Id<Solution>
export type Solution = {
id: SolutionId
createdAt: string
sentBy: UserId
forProblem: ProblemId
content: string
status: SolutionStatus
/**
* The _visibility status_ only applies when `status` is not "pending"
*/
visible: boolean
}
+6
View File
@@ -0,0 +1,6 @@
export function validateObjectKeys<K extends string>(obj: any, keys: K[]): boolean {
const keySet = new Set(keys)
// @ts-ignore
return Object.keys(obj).every(key => keySet.has(key))
}