From 9b0f9994f692247f09a0d8203c0224b6d0937a2b Mon Sep 17 00:00:00 2001 From: DecDuck Date: Fri, 6 Feb 2026 23:12:03 +1100 Subject: [PATCH] API optimisations (#343) * feat: api optimisation * feat: emulator rename --- ...{ExecutorWidget.vue => EmulatorWidget.vue} | 14 ++--- components/GameEditor/VersionConfig.vue | 18 +++--- components/ImportVersionLaunchRow.vue | 60 +++++++++---------- components/Modal/SelectLaunch.vue | 6 +- composables/frontend.d.ts | 2 +- i18n/locales/en_us.json | 12 ++-- package.json | 1 + pages/admin/library/[id]/import.vue | 7 +-- pages/admin/library/import.vue | 12 ++-- pages/store/[id]/index.vue | 17 ++---- pnpm-lock.yaml | 26 ++++++++ .../migration.sql | 31 ++++++++++ .../migration.sql | 30 ++++++++++ prisma/models/content.prisma | 15 ++--- server/api/v1/admin/game/[id]/index.get.ts | 8 +-- .../api/v1/admin/import/version/index.post.ts | 2 +- .../[id]/version/[versionid]/index.get.ts | 8 +-- .../api/v1/client/game/[id]/versions.get.ts | 22 +++---- server/api/v1/games/[id]/index.get.ts | 33 +++++++++- server/internal/library/index.ts | 56 ++++++++--------- 20 files changed, 246 insertions(+), 134 deletions(-) rename components/{ExecutorWidget.vue => EmulatorWidget.vue} (71%) create mode 100644 prisma/migrations/20260206064926_rename_gametypes/migration.sql create mode 100644 prisma/migrations/20260206065642_rename_more_executor_fields/migration.sql diff --git a/components/ExecutorWidget.vue b/components/EmulatorWidget.vue similarity index 71% rename from components/ExecutorWidget.vue rename to components/EmulatorWidget.vue index 85fa8693..10fff4a1 100644 --- a/components/ExecutorWidget.vue +++ b/components/EmulatorWidget.vue @@ -1,11 +1,11 @@ diff --git a/components/GameEditor/VersionConfig.vue b/components/GameEditor/VersionConfig.vue index e3d70415..a9d4a753 100644 --- a/components/GameEditor/VersionConfig.vue +++ b/components/GameEditor/VersionConfig.vue @@ -23,16 +23,16 @@ >

{{ props.config.command }}

- diff --git a/components/ImportVersionLaunchRow.vue b/components/ImportVersionLaunchRow.vue index a123eccb..a4a366aa 100644 --- a/components/ImportVersionLaunchRow.vue +++ b/components/ImportVersionLaunchRow.vue @@ -87,7 +87,7 @@ class="size-5" /> @@ -142,7 +142,7 @@
@@ -155,16 +155,16 @@

- @@ -234,7 +234,7 @@ import { } from "@headlessui/vue"; import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid"; import { InformationCircleIcon, TrashIcon } from "@heroicons/vue/24/outline"; -import type { ExecutorLaunchObject } from "~/composables/frontend"; +import type { EmulatorLaunchObject } from "~/composables/frontend"; import type { GameType, Platform } from "~/prisma/client/enums"; import type { ImportVersion } from "~/server/api/v1/admin/import/version/index.post"; @@ -247,17 +247,17 @@ const launchConfiguration = defineModel< name?: string; } >({ required: true }); -const _executorMetadata = ref(undefined); -const executor = computed({ +const _emulatorMetadata = ref(undefined); +const emulator = computed({ get() { - return _executorMetadata.value; + return _emulatorMetadata.value; }, set(v) { - _executorMetadata.value = v; + _emulatorMetadata.value = v; if (v) { - launchConfiguration.value.executorId = v.launchId; + launchConfiguration.value.emulatorId = v.launchId; } else { - launchConfiguration.value.executorId = undefined; + launchConfiguration.value.emulatorId = undefined; } }, }); @@ -265,9 +265,9 @@ const executor = computed({ function updatePlatform(v: Platform | undefined) { if (!v) return; launchConfiguration.value.platform = v; - if (executor.value) { - if (executor.value.platform !== v) { - executor.value = undefined; + if (emulator.value) { + if (emulator.value.platform !== v) { + emulator.value = undefined; } } } @@ -275,11 +275,11 @@ function updatePlatform(v: Platform | undefined) { const props = defineProps<{ versionGuesses: Array | undefined; needsName: boolean; - allowExecutor?: boolean; + allowEmulator?: boolean; type?: GameType; }>(); -if (props.type && props.type === "Executor") +if (props.type && props.type === "Emulator") launchConfiguration.value.suggestions ??= []; const selectLaunchOpen = ref(false); @@ -299,15 +299,15 @@ function updateLaunchCommand(command: string) { if (autosetGuess) { if (autosetGuess.type === "platform") { launchConfiguration.value.platform = autosetGuess.platform; - } else if (autosetGuess.type === "executor") { - executor.value = { - launchId: autosetGuess.executorId, + } else if (autosetGuess.type === "emulator") { + emulator.value = { + launchId: autosetGuess.emulatorId, gameName: autosetGuess.gameName, gameIcon: autosetGuess.icon, versionName: autosetGuess.launchName, launchName: autosetGuess.launchName, platform: autosetGuess.platform, - } satisfies ExecutorLaunchObject; + } satisfies EmulatorLaunchObject; launchConfiguration.value.platform = autosetGuess.platform; } } diff --git a/components/Modal/SelectLaunch.vue b/components/Modal/SelectLaunch.vue index 37243733..185c4b3c 100644 --- a/components/Modal/SelectLaunch.vue +++ b/components/Modal/SelectLaunch.vue @@ -141,7 +141,7 @@