Loggest thy stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
905 B

import type { ScopeEntry, ScopeInput } from "$lib/models/scope";
import type Scope from "$lib/models/scope";
import type { StatEntry } from "$lib/models/stat";
import type Stat from "$lib/models/stat";
export class NotFoundError extends Error {
constructor(subject: string) {
super(`${subject} not found`);
}
}
export interface Database {
userId: string
scopes(): ScopeRepo
stats(scopeId: number): StatRepo
withUser(userId: string): Database
}
export interface ScopeRepo {
userId: string
find(id: number): Promise<Scope>
list(): Promise<ScopeEntry[]>
create(input: ScopeInput): Promise<Scope>
update(id: number, input: Partial<ScopeInput>): Promise<Scope>
delete(id: number): Promise<void>
}
export interface StatRepo {
userId: string
scopeId: number
find(id: number): Promise<Stat>
findEntries(...ids: number[]): Promise<StatEntry[]>
list(): Promise<Stat[]>
}