diff --git a/backend/__tests__/dal/result.spec.ts b/backend/__tests__/dal/result.spec.ts index efc7e0693..3e35b090b 100644 --- a/backend/__tests__/dal/result.spec.ts +++ b/backend/__tests__/dal/result.spec.ts @@ -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; +type MonkeyTypesResult = MonkeyTypes.WithObjectId< + SharedTypes.DBResult +>; let uid: string = ""; const timestamp = Date.now() - 60000; diff --git a/backend/src/dal/result.ts b/backend/src/dal/result.ts index 7ebbe181c..e96f306eb 100644 --- a/backend/src/dal/result.ts +++ b/backend/src/dal/result.ts @@ -5,7 +5,9 @@ import * as db from "../init/db"; import { getUser, getTags } from "./user"; -type DBResult = SharedTypes.DBResult; +type DBResult = MonkeyTypes.WithObjectId< + SharedTypes.DBResult +>; export async function addResult( uid: string, diff --git a/backend/src/utils/result.ts b/backend/src/utils/result.ts index 4891e502e..b3487a78c 100644 --- a/backend/src/utils/result.ts +++ b/backend/src/utils/result.ts @@ -1,6 +1,8 @@ import { ObjectId } from "mongodb"; -type Result = SharedTypes.DBResult; +type Result = MonkeyTypes.WithObjectId< + SharedTypes.DBResult +>; export function buildDbResult( completedEvent: SharedTypes.CompletedEvent, diff --git a/shared-types/types.d.ts b/shared-types/types.d.ts index f54e0e662..68d258354 100644 --- a/shared-types/types.d.ts +++ b/shared-types/types.d.ts @@ -189,53 +189,47 @@ declare namespace SharedTypes { textLen?: number; } - type WithObjectId = Omit & { - _id: ObjectId; + type DBResult = Omit< + SharedTypes.Result, + | "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 = WithObjectId< - Omit< - SharedTypes.Result, - | "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 { keySpacing: number[] | "toolong"; keyDuration: number[] | "toolong";