diff options
author | Miodec <[email protected]> | 2024-02-17 18:42:51 +0100 |
---|---|---|
committer | Miodec <[email protected]> | 2024-02-17 18:42:51 +0100 |
commit | b7594ab68462a7465863b2b32f092b7b1c6d7290 (patch) | |
tree | c12f0aec8593d6bd7e0ea74399bea2d9cf05a0d6 | |
parent | 763aecad93e4c987fbdccb9cc5c4cda457645f6a (diff) | |
download | monkeytype-b7594ab68462a7465863b2b32f092b7b1c6d7290.tar.gz monkeytype-b7594ab68462a7465863b2b32f092b7b1c6d7290.zip |
chore: move withobjectid to backend types
-rw-r--r-- | backend/__tests__/dal/result.spec.ts | 4 | ||||
-rw-r--r-- | backend/src/dal/result.ts | 4 | ||||
-rw-r--r-- | backend/src/utils/result.ts | 4 | ||||
-rw-r--r-- | shared-types/types.d.ts | 84 |
4 files changed, 48 insertions, 48 deletions
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<SharedTypes.Config.Mode>; +type MonkeyTypesResult = MonkeyTypes.WithObjectId< + SharedTypes.DBResult<SharedTypes.Config.Mode> +>; 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<SharedTypes.Config.Mode>; +type DBResult = MonkeyTypes.WithObjectId< + SharedTypes.DBResult<SharedTypes.Config.Mode> +>; 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<SharedTypes.Config.Mode>; +type Result = MonkeyTypes.WithObjectId< + SharedTypes.DBResult<SharedTypes.Config.Mode> +>; 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<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"; |