mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-06 05:26:54 +08:00
chore: move withobjectid to backend types
This commit is contained in:
parent
763aecad93
commit
b7594ab684
4 changed files with 48 additions and 48 deletions
|
@ -2,7 +2,9 @@ import * as ResultDal from "../../src/dal/result";
|
|||
import { ObjectId } from "mongodb";
|
||||
import * as UserDal from "../../src/dal/user";
|
||||
|
||||
type MonkeyTypesResult = SharedTypes.DBResult<SharedTypes.Config.Mode>;
|
||||
type MonkeyTypesResult = MonkeyTypes.WithObjectId<
|
||||
SharedTypes.DBResult<SharedTypes.Config.Mode>
|
||||
>;
|
||||
|
||||
let uid: string = "";
|
||||
const timestamp = Date.now() - 60000;
|
||||
|
|
|
@ -5,7 +5,9 @@ import * as db from "../init/db";
|
|||
|
||||
import { getUser, getTags } from "./user";
|
||||
|
||||
type DBResult = SharedTypes.DBResult<SharedTypes.Config.Mode>;
|
||||
type DBResult = MonkeyTypes.WithObjectId<
|
||||
SharedTypes.DBResult<SharedTypes.Config.Mode>
|
||||
>;
|
||||
|
||||
export async function addResult(
|
||||
uid: string,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { ObjectId } from "mongodb";
|
||||
|
||||
type Result = SharedTypes.DBResult<SharedTypes.Config.Mode>;
|
||||
type Result = MonkeyTypes.WithObjectId<
|
||||
SharedTypes.DBResult<SharedTypes.Config.Mode>
|
||||
>;
|
||||
|
||||
export function buildDbResult(
|
||||
completedEvent: SharedTypes.CompletedEvent,
|
||||
|
|
84
shared-types/types.d.ts
vendored
84
shared-types/types.d.ts
vendored
|
@ -189,53 +189,47 @@ declare namespace SharedTypes {
|
|||
textLen?: number;
|
||||
}
|
||||
|
||||
type WithObjectId<T extends { _id: string }> = Omit<T, "_id"> & {
|
||||
_id: ObjectId;
|
||||
type DBResult<T extends SharedTypes.Config.Mode> = Omit<
|
||||
SharedTypes.Result<T>,
|
||||
| "bailedOut"
|
||||
| "blindMode"
|
||||
| "lazyMode"
|
||||
| "difficulty"
|
||||
| "funbox"
|
||||
| "language"
|
||||
| "numbers"
|
||||
| "punctuation"
|
||||
| "restartCount"
|
||||
| "incompleteTestSeconds"
|
||||
| "afkDuration"
|
||||
| "tags"
|
||||
| "incompleteTests"
|
||||
| "customText"
|
||||
| "quoteLength"
|
||||
| "isPb"
|
||||
> & {
|
||||
correctChars?: number; // --------------
|
||||
incorrectChars?: number; // legacy results
|
||||
// --------------
|
||||
name: string;
|
||||
// -------------- fields that might be removed to save space
|
||||
bailedOut?: boolean;
|
||||
blindMode?: boolean;
|
||||
lazyMode?: boolean;
|
||||
difficulty?: SharedTypes.Config.Difficulty;
|
||||
funbox?: string;
|
||||
language?: string;
|
||||
numbers?: boolean;
|
||||
punctuation?: boolean;
|
||||
restartCount?: number;
|
||||
incompleteTestSeconds?: number;
|
||||
afkDuration?: number;
|
||||
tags?: string[];
|
||||
customText?: CustomText;
|
||||
quoteLength?: number;
|
||||
isPb?: boolean;
|
||||
};
|
||||
|
||||
type DBResult<T extends SharedTypes.Config.Mode> = WithObjectId<
|
||||
Omit<
|
||||
SharedTypes.Result<T>,
|
||||
| "bailedOut"
|
||||
| "blindMode"
|
||||
| "lazyMode"
|
||||
| "difficulty"
|
||||
| "funbox"
|
||||
| "language"
|
||||
| "numbers"
|
||||
| "punctuation"
|
||||
| "restartCount"
|
||||
| "incompleteTestSeconds"
|
||||
| "afkDuration"
|
||||
| "tags"
|
||||
| "incompleteTests"
|
||||
| "customText"
|
||||
| "quoteLength"
|
||||
| "isPb"
|
||||
> & {
|
||||
correctChars?: number; // --------------
|
||||
incorrectChars?: number; // legacy results
|
||||
// --------------
|
||||
name: string;
|
||||
// -------------- fields that might be removed to save space
|
||||
bailedOut?: boolean;
|
||||
blindMode?: boolean;
|
||||
lazyMode?: boolean;
|
||||
difficulty?: SharedTypes.Config.Difficulty;
|
||||
funbox?: string;
|
||||
language?: string;
|
||||
numbers?: boolean;
|
||||
punctuation?: boolean;
|
||||
restartCount?: number;
|
||||
incompleteTestSeconds?: number;
|
||||
afkDuration?: number;
|
||||
tags?: string[];
|
||||
customText?: CustomText;
|
||||
quoteLength?: number;
|
||||
isPb?: boolean;
|
||||
}
|
||||
>;
|
||||
|
||||
interface CompletedEvent extends Result<SharedTypes.Config.Mode> {
|
||||
keySpacing: number[] | "toolong";
|
||||
keyDuration: number[] | "toolong";
|
||||
|
|
Loading…
Add table
Reference in a new issue