mirror of
https://github.com/BillyOutlast/drop.git
synced 2026-02-04 00:31:17 +01:00
Game specialisation & delta versions (#323)
* feat: game specialisation, auto-guess extensions * fix: enforce specialisation specific schema at API level * fix: lint * feat: partial work on depot endpoints * feat: bump torrential * feat: dummy version creation for depot uploads * fix: lint * fix: types * fix: lint * feat: depot version import * fix: lint * fix: remove any type * fix: lint * fix: push update interval * fix: cpu usage calculation * feat: delta version support * feat: style tweaks for selectlaunch.vue * fix: lint
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -33,7 +33,7 @@
|
||||
"username": "drop"
|
||||
}
|
||||
],
|
||||
"typescript.experimental.useTsgo": false,
|
||||
"typescript.experimental.useTsgo": true,
|
||||
// prioritize ArkType's "type" for autoimports
|
||||
"typescript.preferences.autoImportSpecifierExcludeRegexes": ["^(node:)?os$"]
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
class="flex space-x-4 rounded-md bg-zinc-900/50 px-6 outline -outline-offset-1 outline-white/10 w-fit text-xs font-bold text-zinc-100"
|
||||
>
|
||||
<div class="inline-flex gap-x-2 items-center">
|
||||
<img :src="executor.gameIcon" class="size-6" />
|
||||
<img :src="useObject(executor.gameIcon)" class="size-6" />
|
||||
<span>{{ executor.gameName }}</span>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
|
||||
@@ -28,12 +28,9 @@
|
||||
:executor="{
|
||||
launchId: props.config.launchId,
|
||||
gameName: props.config.executor.gameVersion.game.mName,
|
||||
gameIcon: useObject(
|
||||
props.config.executor.gameVersion.game.mIconObjectId,
|
||||
),
|
||||
versionName:
|
||||
props.config.executor.gameVersion.displayName ??
|
||||
props.config.executor.gameVersion.versionPath,
|
||||
gameIcon: props.config.executor.gameVersion.game.mIconObjectId,
|
||||
versionName: (props.config.executor.gameVersion.displayName ??
|
||||
props.config.executor.gameVersion.versionPath)!,
|
||||
launchName: props.config.executor.name,
|
||||
platform: props.config.executor.platform,
|
||||
}"
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<template>
|
||||
<div class="flex flex-row items-center gap-x-2">
|
||||
<img :src="game.icon" class="w-12 h-12 rounded-sm object-cover" />
|
||||
<img
|
||||
:src="rawIcon ? game.icon : useObject(game.icon)"
|
||||
class="w-12 h-12 rounded-sm object-cover"
|
||||
/>
|
||||
<div class="flex flex-col items-left">
|
||||
<h1 class="font-semibold font-display text-lg text-zinc-100">
|
||||
{{ game.name }}
|
||||
@@ -18,7 +21,8 @@
|
||||
<script setup lang="ts">
|
||||
import type { GameMetadataSearchResult } from "~/server/internal/metadata/types";
|
||||
|
||||
const { game } = defineProps<{
|
||||
const { game, rawIcon = true } = defineProps<{
|
||||
game: Omit<GameMetadataSearchResult, "year"> & { sourceName?: string };
|
||||
rawIcon?: boolean;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
@@ -87,6 +87,11 @@
|
||||
:is="PLATFORM_ICONS[guess.platform]"
|
||||
class="size-5"
|
||||
/>
|
||||
<img
|
||||
v-if="guess.type === 'executor'"
|
||||
:src="useObject(guess.icon)"
|
||||
class="size-5"
|
||||
/>
|
||||
</span>
|
||||
|
||||
<span
|
||||
@@ -119,7 +124,7 @@
|
||||
<span
|
||||
:class="['block truncate', selected && 'font-semibold']"
|
||||
>
|
||||
{{ launchProcessQuery }}
|
||||
'{{ launchProcessQuery }}'
|
||||
</span>
|
||||
|
||||
<span
|
||||
@@ -137,6 +142,28 @@
|
||||
</div>
|
||||
</Combobox>
|
||||
</div>
|
||||
<div
|
||||
v-if="props.type && props.type === 'Executor'"
|
||||
class="ml-1 mt-2 rounded-lg bg-blue-900/10 p-1 outline outline-blue-900"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<div class="shrink-0">
|
||||
<InformationCircleIcon
|
||||
class="size-5 text-blue-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
<div class="ml-2 inline-flex items-center">
|
||||
<p class="text-sm text-blue-200">
|
||||
<span
|
||||
class="font-mono bg-zinc-950 text-zinc-100 py-1 px-0.5 rounded-xl"
|
||||
>{executor}</span
|
||||
>
|
||||
is replaced with the game's launch command for executors.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<SelectorPlatform
|
||||
:model-value="launchConfiguration.platform"
|
||||
@@ -145,7 +172,7 @@
|
||||
>
|
||||
{{ $t("library.admin.import.version.platform") }}
|
||||
</SelectorPlatform>
|
||||
<div>
|
||||
<div v-if="props.type && props.type === 'Game' && props.allowExecutor">
|
||||
<h1 class="block text-sm font-medium leading-6 text-zinc-100">
|
||||
Executor
|
||||
</h1>
|
||||
@@ -170,6 +197,15 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="props.type && props.type === 'Executor'">
|
||||
<p class="block text-sm font-medium leading-6 text-zinc-100">
|
||||
Auto-suggest extensions
|
||||
</p>
|
||||
<SelectorFileExtension
|
||||
v-model="launchConfiguration.suggestions!"
|
||||
class="mt-2"
|
||||
/>
|
||||
</div>
|
||||
<ModalSelectLaunch
|
||||
v-model="selectLaunchOpen"
|
||||
class="-mt-2"
|
||||
@@ -190,9 +226,10 @@ import {
|
||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
||||
import { InformationCircleIcon, TrashIcon } from "@heroicons/vue/24/outline";
|
||||
import type { ExecutorLaunchObject } from "~/composables/frontend";
|
||||
import type { Platform } from "~/prisma/client/enums";
|
||||
import type { GameType, Platform } from "~/prisma/client/enums";
|
||||
|
||||
import type { ImportVersion } from "~/server/api/v1/admin/import/version/index.post";
|
||||
import type { VersionGuess } from "~/server/internal/library";
|
||||
|
||||
const launchProcessQuery = ref("");
|
||||
|
||||
@@ -227,10 +264,15 @@ function updatePlatform(v: Platform | undefined) {
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
versionGuesses: Array<{ platform: Platform; filename: string }> | undefined;
|
||||
versionGuesses: Array<VersionGuess> | undefined;
|
||||
needsName: boolean;
|
||||
allowExecutor?: boolean;
|
||||
type?: GameType;
|
||||
}>();
|
||||
|
||||
if (props.type && props.type === "Executor")
|
||||
launchConfiguration.value.suggestions ??= [];
|
||||
|
||||
const selectLaunchOpen = ref(false);
|
||||
|
||||
const launchFilteredVersionGuesses = computed(() =>
|
||||
@@ -246,8 +288,21 @@ function updateLaunchCommand(command: string) {
|
||||
(v) => v.filename == command,
|
||||
);
|
||||
if (autosetGuess) {
|
||||
if (autosetGuess.type === "platform") {
|
||||
launchConfiguration.value.platform = autosetGuess.platform;
|
||||
} else if (autosetGuess.type === "executor") {
|
||||
console.log(autosetGuess.executorId);
|
||||
executor.value = {
|
||||
launchId: autosetGuess.executorId,
|
||||
gameName: autosetGuess.gameName,
|
||||
gameIcon: autosetGuess.icon,
|
||||
versionName: autosetGuess.launchName,
|
||||
launchName: autosetGuess.launchName,
|
||||
platform: autosetGuess.platform,
|
||||
} satisfies ExecutorLaunchObject;
|
||||
launchConfiguration.value.platform = autosetGuess.platform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -164,6 +164,8 @@ async function addGame() {
|
||||
}
|
||||
|
||||
async function search(query: string) {
|
||||
return await $dropFetch("/api/v1/admin/search/game", { query: { q: query } });
|
||||
return await $dropFetch("/api/v1/admin/search/game?type=Game", {
|
||||
query: { q: query },
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<template #default>
|
||||
<div>
|
||||
<h1 as="h3" class="text-lg font-medium leading-6 text-white">
|
||||
Pick a launch option
|
||||
Select a launch option
|
||||
</h1>
|
||||
<p class="mt-1 text-zinc-400 text-sm">
|
||||
Select a launch option as an executor for your new launch option.
|
||||
@@ -28,14 +28,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 space-y-4">
|
||||
<div
|
||||
class="inline-flex items-center w-full gap-x-2 text-zinc-100 font-bold"
|
||||
>
|
||||
Game:
|
||||
<div>
|
||||
<h1 class="block text-sm font-medium leading-6 text-zinc-100">
|
||||
Search for an executor
|
||||
</h1>
|
||||
<SelectorGame
|
||||
:search="search"
|
||||
:model-value="game"
|
||||
class="w-full"
|
||||
class="w-full mt-2"
|
||||
@update:model-value="(value) => updateGame(value)"
|
||||
/>
|
||||
</div>
|
||||
@@ -45,28 +45,27 @@
|
||||
>
|
||||
No versions imported.
|
||||
</div>
|
||||
<div
|
||||
v-else-if="versions !== undefined"
|
||||
class="inline-flex items-center w-full gap-x-2 text-zinc-100 font-bold"
|
||||
>
|
||||
Version:
|
||||
<div v-else-if="versions !== undefined">
|
||||
<h1 class="block text-sm font-medium leading-6 text-zinc-100">
|
||||
Select a version
|
||||
</h1>
|
||||
<SelectorCombox
|
||||
:search="
|
||||
(v) =>
|
||||
Object.values(versions!)
|
||||
.filter((k) =>
|
||||
(k.displayName || k.versionPath)
|
||||
(k.displayName || k.versionPath)!
|
||||
.toLowerCase()
|
||||
.includes(v.toLowerCase()),
|
||||
)
|
||||
.map((v) => ({
|
||||
id: v.versionId,
|
||||
name: v.displayName ?? v.versionPath,
|
||||
name: (v.displayName ?? v.versionPath)!,
|
||||
}))
|
||||
"
|
||||
:display="(v) => v.name"
|
||||
:model-value="version"
|
||||
class="w-full"
|
||||
class="w-full mt-2"
|
||||
@update:model-value="updateVersion"
|
||||
>
|
||||
<template #default="{ value }">
|
||||
@@ -74,11 +73,10 @@
|
||||
</template>
|
||||
</SelectorCombox>
|
||||
</div>
|
||||
<div
|
||||
v-if="versions && version"
|
||||
class="inline-flex items-center w-full gap-x-2 text-zinc-100 font-bold"
|
||||
>
|
||||
Launch:
|
||||
<div v-if="versions && version">
|
||||
<h1 class="block text-sm font-medium leading-6 text-zinc-100">
|
||||
Select a launch command
|
||||
</h1>
|
||||
<SelectorCombox
|
||||
:search="
|
||||
(v) =>
|
||||
@@ -99,7 +97,7 @@
|
||||
"
|
||||
:display="(v) => v.name"
|
||||
:model-value="launchId"
|
||||
class="w-full"
|
||||
class="w-full mt-2"
|
||||
@update:model-value="(v) => (launchId = v)"
|
||||
>
|
||||
<template #default="{ value }">
|
||||
@@ -169,7 +167,7 @@ const versions = ref<
|
||||
platform: Platform;
|
||||
}[];
|
||||
versionId: string;
|
||||
versionPath: string;
|
||||
versionPath: string | null;
|
||||
};
|
||||
}
|
||||
| undefined
|
||||
@@ -180,7 +178,9 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
async function search(query: string) {
|
||||
return await $dropFetch("/api/v1/admin/search/game", { query: { q: query } });
|
||||
return await $dropFetch("/api/v1/admin/search/game", {
|
||||
query: { q: query, type: "Executor" },
|
||||
});
|
||||
}
|
||||
|
||||
function updateGame(value: GameMetadataSearchResult | undefined) {
|
||||
|
||||
118
components/Selector/FileExtension.vue
Normal file
118
components/Selector/FileExtension.vue
Normal file
@@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex gap-1 flex-wrap">
|
||||
<span
|
||||
v-for="extension in model"
|
||||
:key="extension"
|
||||
class="inline-flex items-center gap-x-0.5 rounded-md bg-blue-400/10 px-2 py-1 text-xs font-medium text-blue-400 inset-ring inset-ring-blue-400/30"
|
||||
>
|
||||
{{ extension }}
|
||||
<button
|
||||
type="button"
|
||||
class="group relative -mr-1 size-3.5 rounded-xs hover:bg-blue-500/30"
|
||||
@click="() => removeFileExtension(extension)"
|
||||
>
|
||||
<span class="sr-only">Remove</span>
|
||||
<svg
|
||||
viewBox="0 0 14 14"
|
||||
class="size-3.5 stroke-blue-400 group-hover:stroke-blue-300"
|
||||
>
|
||||
<path d="M4 4l6 6m0-6l-6 6" />
|
||||
</svg>
|
||||
<span class="absolute -inset-1"></span>
|
||||
</button>
|
||||
</span>
|
||||
<span v-if="model.length == 0" class="text-zinc-500 text-xs"
|
||||
>No extensions selected.</span
|
||||
>
|
||||
</div>
|
||||
<Combobox
|
||||
as="div"
|
||||
nullable
|
||||
:immediate="true"
|
||||
:model-value="model"
|
||||
class="mt-2 bg-zinc-800 rounded"
|
||||
@update:model-value="addFileExtension"
|
||||
>
|
||||
<div class="relative">
|
||||
<ComboboxInput
|
||||
class="block flex-1 border-0 py-1.5 pl-2 bg-transparent text-zinc-100 placeholder:text-zinc-400 focus:ring-0 sm:text-sm sm:leading-6 w-full"
|
||||
placeholder="Start typing..."
|
||||
:display-value="(_) => ''"
|
||||
@change="query = $event.target.value"
|
||||
@blur="query = ''"
|
||||
/>
|
||||
<ComboboxButton
|
||||
class="absolute inset-0 right-0 flex items-center justify-end rounded-r-md px-2 focus:outline-none"
|
||||
>
|
||||
<ChevronUpDownIcon class="size-5 text-gray-400" aria-hidden="true" />
|
||||
</ComboboxButton>
|
||||
|
||||
<ComboboxOptions
|
||||
class="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-zinc-900 py-1 text-base shadow-lg ring-1 ring-white/5 focus:outline-none sm:text-sm"
|
||||
>
|
||||
<ComboboxOption
|
||||
v-if="query"
|
||||
v-slot="{ active, selected }"
|
||||
:value="query"
|
||||
as="template"
|
||||
>
|
||||
<li
|
||||
:class="[
|
||||
'relative cursor-default select-none py-2 pl-3 pr-9',
|
||||
active
|
||||
? 'bg-blue-600 text-white outline-none'
|
||||
: 'text-zinc-100',
|
||||
]"
|
||||
>
|
||||
<span> Add "{{ normalize(query) }}" </span>
|
||||
|
||||
<span
|
||||
v-if="selected"
|
||||
:class="[
|
||||
'absolute inset-y-0 right-0 flex items-center pr-4',
|
||||
active ? 'text-white' : 'text-blue-600',
|
||||
]"
|
||||
>
|
||||
<CheckIcon class="size-5" aria-hidden="true" />
|
||||
</span>
|
||||
</li>
|
||||
</ComboboxOption>
|
||||
</ComboboxOptions>
|
||||
</div>
|
||||
</Combobox>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Combobox,
|
||||
ComboboxButton,
|
||||
ComboboxInput,
|
||||
ComboboxOption,
|
||||
ComboboxOptions,
|
||||
} from "@headlessui/vue";
|
||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/24/outline";
|
||||
|
||||
const model = defineModel<string[]>({ required: true });
|
||||
|
||||
const query = ref("");
|
||||
|
||||
function normalize(v: string) {
|
||||
const k = v.toLowerCase().replaceAll(/[^a-zA-Z0-9]*/g, "");
|
||||
if (k.startsWith(".")) return k;
|
||||
return `.${k}`;
|
||||
}
|
||||
|
||||
function addFileExtension(raw: string) {
|
||||
const value = normalize(raw);
|
||||
if (model.value.includes(value)) return;
|
||||
model.value.push(value);
|
||||
}
|
||||
|
||||
function removeFileExtension(extension: string) {
|
||||
const index = model.value.findIndex((v) => v === extension);
|
||||
if (index == -1) return;
|
||||
model.value.splice(index, 1);
|
||||
}
|
||||
</script>
|
||||
@@ -51,9 +51,9 @@
|
||||
</div>
|
||||
<div
|
||||
v-else-if="results.length == 0"
|
||||
class="text-zinc-300 uppercase font-display font-bold text-center p-4"
|
||||
class="text-zinc-500 uppercase font-display font-bold text-center p-4"
|
||||
>
|
||||
No results.
|
||||
No results
|
||||
</div>
|
||||
<ComboboxOption
|
||||
v-for="result in results"
|
||||
@@ -70,7 +70,7 @@
|
||||
]"
|
||||
>
|
||||
<span>
|
||||
<GameSearchResultWidget :game="result" />
|
||||
<GameSearchResultWidget :game="result" :raw-icon="false" />
|
||||
</span>
|
||||
|
||||
<span
|
||||
@@ -123,8 +123,7 @@ watch(gameSearchQuery, async (v) => {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
resultsLoading.value = true;
|
||||
timeout = setTimeout(async () => {
|
||||
const newResults = await props.search(v);
|
||||
results.value = newResults.map((v) => ({ ...v, icon: useObject(v.icon) }));
|
||||
results.value = await props.search(v);
|
||||
resultsLoading.value = false;
|
||||
timeout = undefined;
|
||||
}, 600);
|
||||
|
||||
@@ -21,11 +21,6 @@ async function signIn() {
|
||||
redirect: `/auth/signin?redirect=${encodeURIComponent(route.fullPath)}`,
|
||||
});
|
||||
}
|
||||
switch (statusCode) {
|
||||
case 401:
|
||||
case 403:
|
||||
await signIn();
|
||||
}
|
||||
|
||||
useHead({
|
||||
title: t("errors.pageTitle", [statusCode ?? message]),
|
||||
|
||||
@@ -65,6 +65,7 @@ export default defineNuxtConfig({
|
||||
experimental: {
|
||||
buildCache: true,
|
||||
viewTransition: false,
|
||||
appManifest: false,
|
||||
componentIslands: true,
|
||||
},
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"@lobomfz/prismark": "0.0.3",
|
||||
"@nuxt/fonts": "^0.11.0",
|
||||
"@nuxt/image": "^1.10.0",
|
||||
"@nuxt/kit": "3.20.1",
|
||||
"@nuxtjs/i18n": "^9.5.5",
|
||||
"@prisma/client": "^6.11.1",
|
||||
"@simplewebauthn/browser": "^13.2.2",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-y-4 max-w-[35vw]">
|
||||
<div class="flex flex-col gap-y-4 sm:max-w-[40rem]">
|
||||
<Listbox
|
||||
as="div"
|
||||
:model-value="currentlySelectedVersion"
|
||||
@@ -13,7 +13,7 @@
|
||||
class="relative w-full cursor-default rounded-md bg-zinc-950 py-1.5 pl-3 pr-10 text-left text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-800 focus:outline-none focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6"
|
||||
>
|
||||
<span v-if="currentlySelectedVersion != -1" class="block truncate">{{
|
||||
versions[currentlySelectedVersion]
|
||||
versions[currentlySelectedVersion].name
|
||||
}}</span>
|
||||
<span v-else class="block truncate text-zinc-600">{{
|
||||
$t("library.admin.import.selectDir")
|
||||
@@ -38,7 +38,7 @@
|
||||
>
|
||||
<ListboxOption
|
||||
v-for="(version, versionIdx) in versions"
|
||||
:key="version"
|
||||
:key="version.identifier"
|
||||
v-slot="{ active, selected }"
|
||||
as="template"
|
||||
:value="versionIdx"
|
||||
@@ -54,7 +54,7 @@
|
||||
selected ? 'font-semibold' : 'font-normal',
|
||||
'block truncate',
|
||||
]"
|
||||
>{{ version }}</span
|
||||
>{{ version.name }}</span
|
||||
>
|
||||
|
||||
<span
|
||||
@@ -92,7 +92,7 @@
|
||||
<li
|
||||
v-for="(launch, launchIdx) in versionSettings.setups"
|
||||
:key="launchIdx"
|
||||
class="py-2 inline-flex items-start gap-x-1"
|
||||
class="py-2 inline-flex items-start gap-x-1 w-full"
|
||||
>
|
||||
<ImportVersionLaunchRow
|
||||
v-model="versionSettings.setups[launchIdx]"
|
||||
@@ -122,6 +122,7 @@
|
||||
>
|
||||
</div>
|
||||
<!-- setup mode -->
|
||||
<div class="relative">
|
||||
<SwitchGroup
|
||||
as="div"
|
||||
class="bg-zinc-800 p-4 rounded-xl flex items-center justify-between gap-4"
|
||||
@@ -153,6 +154,11 @@
|
||||
/>
|
||||
</Switch>
|
||||
</SwitchGroup>
|
||||
<div
|
||||
v-if="type === GameType.Redist"
|
||||
class="absolute inset-0 bg-zinc-900/50"
|
||||
/>
|
||||
</div>
|
||||
<!-- launch executables -->
|
||||
<div class="relative flex flex-col gap-y-2 bg-zinc-800 p-4 rounded-xl">
|
||||
<div>
|
||||
@@ -172,19 +178,48 @@
|
||||
:key="launchIdx"
|
||||
class="py-2 inline-flex items-start gap-x-1 w-full"
|
||||
>
|
||||
<ImportVersionLaunchRow
|
||||
v-model="versionSettings.launches[launchIdx]"
|
||||
:version-guesses="versionGuesses"
|
||||
:needs-name="true"
|
||||
/>
|
||||
<Disclosure
|
||||
v-slot="{ open }"
|
||||
:default-open="true"
|
||||
as="div"
|
||||
class="py-2 px-3 w-full bg-zinc-900 rounded-lg"
|
||||
>
|
||||
<dt>
|
||||
<DisclosureButton
|
||||
class="flex w-full items-center text-left text-white"
|
||||
>
|
||||
<span v-if="launch.name" class="text-sm font-semibold">{{
|
||||
launch.name
|
||||
}}</span>
|
||||
<span v-else class="text-sm text-zinc-500 italic"
|
||||
>No name provided.</span
|
||||
>
|
||||
<span class="ml-auto flex h-7 items-center">
|
||||
<PlusIcon v-if="!open" class="size-6" aria-hidden="true" />
|
||||
<MinusIcon v-else class="size-6" aria-hidden="true" />
|
||||
</span>
|
||||
<button
|
||||
class="transition rounded p-1 bg-zinc-900/30 group hover:bg-red-600/30"
|
||||
@click="() => versionSettings.launches.splice(launchIdx, 1)"
|
||||
class="ml-1 transition rounded p-1 bg-zinc-900/30 group hover:bg-red-600/30"
|
||||
@click.prevent="
|
||||
() => versionSettings.launches.splice(launchIdx, 1)
|
||||
"
|
||||
>
|
||||
<TrashIcon
|
||||
class="transition size-5 text-zinc-700 group-hover:text-red-700"
|
||||
/>
|
||||
</button>
|
||||
</DisclosureButton>
|
||||
</dt>
|
||||
<DisclosurePanel as="dd" class="mt-2">
|
||||
<ImportVersionLaunchRow
|
||||
v-model="versionSettings.launches[launchIdx]"
|
||||
:version-guesses="versionGuesses"
|
||||
:needs-name="true"
|
||||
:allow-executor="true"
|
||||
:type="type"
|
||||
/>
|
||||
</DisclosurePanel>
|
||||
</Disclosure>
|
||||
</li>
|
||||
</ol>
|
||||
<span
|
||||
@@ -295,15 +330,21 @@ import {
|
||||
SwitchDescription,
|
||||
SwitchGroup,
|
||||
SwitchLabel,
|
||||
Disclosure,
|
||||
DisclosureButton,
|
||||
DisclosurePanel,
|
||||
} from "@headlessui/vue";
|
||||
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
||||
import {
|
||||
CheckIcon,
|
||||
ChevronUpDownIcon,
|
||||
TrashIcon,
|
||||
MinusIcon,
|
||||
PlusIcon,
|
||||
} from "@heroicons/vue/20/solid";
|
||||
import type { Platform } from "~/prisma/client/enums";
|
||||
import { GameType } from "~/prisma/client/enums";
|
||||
import type { ImportVersion } from "~/server/api/v1/admin/import/version/index.post";
|
||||
import type { VersionGuess } from "~/server/internal/library";
|
||||
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
@@ -313,20 +354,21 @@ const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const gameId = route.params.id.toString();
|
||||
const versions = await $dropFetch(
|
||||
const { versions, type } = await $dropFetch(
|
||||
`/api/v1/admin/import/version?id=${encodeURIComponent(gameId)}`,
|
||||
);
|
||||
const currentlySelectedVersion = ref(-1);
|
||||
const versionSettings = ref<typeof ImportVersion.infer>({
|
||||
id: gameId,
|
||||
version: "",
|
||||
const versionSettings = ref<Omit<typeof ImportVersion.infer, "version" | "id">>(
|
||||
{
|
||||
delta: false,
|
||||
onlySetup: false,
|
||||
onlySetup: type === GameType.Redist,
|
||||
launches: [],
|
||||
setups: [],
|
||||
});
|
||||
requiredContent: [],
|
||||
},
|
||||
);
|
||||
|
||||
const versionGuesses = ref<Array<{ platform: Platform; filename: string }>>();
|
||||
const versionGuesses = ref<Array<VersionGuess>>();
|
||||
|
||||
const importLoading = ref(false);
|
||||
const importError = ref<string | undefined>();
|
||||
@@ -336,14 +378,14 @@ async function updateCurrentlySelectedVersion(value: number) {
|
||||
currentlySelectedVersion.value = value;
|
||||
const version = versions[currentlySelectedVersion.value];
|
||||
try {
|
||||
const results = await $dropFetch(
|
||||
`/api/v1/admin/import/version/preload?id=${encodeURIComponent(
|
||||
gameId,
|
||||
)}&version=${encodeURIComponent(version)}`,
|
||||
{
|
||||
const results = await $dropFetch(`/api/v1/admin/import/version/preload`, {
|
||||
failTitle: "Failed to fetch version information",
|
||||
query: {
|
||||
id: gameId,
|
||||
type: version.type,
|
||||
version: version.identifier,
|
||||
},
|
||||
);
|
||||
});
|
||||
versionGuesses.value = results as typeof versionGuesses.value;
|
||||
} catch {
|
||||
currentlySelectedVersion.value = -1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-y-6 w-full max-w-md">
|
||||
<div class="flex flex-col gap-y-6 w-full max-w-lg">
|
||||
<Listbox
|
||||
as="div"
|
||||
:model="currentlySelectedGame"
|
||||
@@ -114,6 +114,40 @@
|
||||
</div>
|
||||
|
||||
<div v-if="currentlySelectedGame !== -1" class="flex flex-col gap-y-4">
|
||||
<fieldset>
|
||||
<legend class="text-sm/6 font-semibold text-white">Import as</legend>
|
||||
<div class="mt-6 grid grid-cols-1 gap-y-6 sm:grid-cols-3 sm:gap-x-4">
|
||||
<label
|
||||
v-for="[type, meta] in Object.entries(importModes)"
|
||||
:key="type"
|
||||
:aria-label="meta.title"
|
||||
:aria-description="`Import as ${meta.title}`"
|
||||
class="cursor-pointer group relative flex rounded-lg border border-white/10 bg-gray-800/50 p-4 has-checked:bg-blue-500/10 has-checked:outline-2 has-checked:-outline-offset-2 has-checked:outline-blue-500 has-focus-visible:outline-3 has-focus-visible:-outline-offset-1 has-disabled:bg-gray-800 has-disabled:opacity-25"
|
||||
>
|
||||
<input
|
||||
v-model="importMode"
|
||||
type="radio"
|
||||
name="mailing-list"
|
||||
:value="type"
|
||||
:checked="importMode === type"
|
||||
class="absolute inset-0 opacity-0 focus:outline-none"
|
||||
/>
|
||||
<div class="flex flex-col grow">
|
||||
<span class="block text-sm font-medium text-white">{{
|
||||
meta.title
|
||||
}}</span>
|
||||
<span class="mt-1 block text-xs text-gray-400">{{
|
||||
meta.description
|
||||
}}</span>
|
||||
</div>
|
||||
<CheckCircleIcon
|
||||
class="invisible size-5 text-blue-500 group-has-checked:visible"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- without metadata option -->
|
||||
<div>
|
||||
<LoadingButton
|
||||
@@ -309,6 +343,7 @@ import {
|
||||
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
||||
import { MagnifyingGlassIcon } from "@heroicons/vue/24/outline";
|
||||
import type { GameType } from "~/prisma/client/enums";
|
||||
import type { GameMetadataSearchResult } from "~/server/internal/metadata/types";
|
||||
|
||||
definePageMeta({
|
||||
@@ -326,6 +361,25 @@ const gameSearchTerm = ref("");
|
||||
const gameSearchLoading = ref(false);
|
||||
const bulkImportMode = ref(false);
|
||||
|
||||
const importModes: {
|
||||
[key in GameType]: { title: string; description: string };
|
||||
} = {
|
||||
Game: {
|
||||
title: "Game",
|
||||
description: "Games are shown in store, and are discoverable.",
|
||||
},
|
||||
Executor: {
|
||||
title: "Executor",
|
||||
description:
|
||||
"Executors are used to launch games. Mainly emulators or wrappers.",
|
||||
},
|
||||
Redist: {
|
||||
title: "Redistributable",
|
||||
description:
|
||||
"Additional content that must be downloaded and installed before running the game.",
|
||||
},
|
||||
};
|
||||
|
||||
async function updateSelectedGame(value: number) {
|
||||
if (currentlySelectedGame.value == value) return;
|
||||
currentlySelectedGame.value = value;
|
||||
@@ -374,6 +428,7 @@ const router = useRouter();
|
||||
|
||||
const importLoading = ref(false);
|
||||
const importError = ref<string | undefined>();
|
||||
const importMode = ref<GameType>("Game");
|
||||
async function importGame(useMetadata: boolean) {
|
||||
if (!metadataResults.value && useMetadata) return;
|
||||
|
||||
@@ -389,6 +444,7 @@ async function importGame(useMetadata: boolean) {
|
||||
path: option.game,
|
||||
library: option.library.id,
|
||||
metadata,
|
||||
type: importMode.value,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
/>
|
||||
<div class="flex flex-col">
|
||||
<h3
|
||||
class="gap-x-2 text-sm inline-flex items-center font-medium text-zinc-100 font-display"
|
||||
class="gap-2 text-sm flex flex-wrap items-center font-medium text-zinc-100 font-display"
|
||||
>
|
||||
{{ game.mName }}
|
||||
<button
|
||||
@@ -128,6 +128,10 @@
|
||||
class="inline-flex items-center rounded-full bg-blue-600/10 px-2 py-1 text-xs font-medium text-blue-600 ring-1 ring-inset ring-blue-600/20"
|
||||
>{{ game.library!.name }}</span
|
||||
>
|
||||
<span
|
||||
class="inline-flex items-center rounded-full bg-green-600/10 px-2 py-1 text-xs font-medium text-green-600 ring-1 ring-inset ring-green-600/20"
|
||||
>{{ game.type }}</span
|
||||
>
|
||||
</h3>
|
||||
<dl class="mt-1 flex flex-col justify-between">
|
||||
<dt class="sr-only">{{ $t("library.admin.shortDesc") }}</dt>
|
||||
|
||||
139
pnpm-lock.yaml
generated
139
pnpm-lock.yaml
generated
@@ -29,6 +29,9 @@ importers:
|
||||
'@nuxt/image':
|
||||
specifier: ^1.10.0
|
||||
version: 1.10.0(@netlify/blobs@9.1.2)(db0@0.3.4)(ioredis@5.8.2)(magicast@0.5.1)
|
||||
'@nuxt/kit':
|
||||
specifier: 3.20.1
|
||||
version: 3.20.1(magicast@0.5.1)
|
||||
'@nuxtjs/i18n':
|
||||
specifier: ^9.5.5
|
||||
version: 9.5.6(@vue/compiler-dom@3.5.27)(eslint@9.31.0(jiti@2.6.1))(magicast@0.5.1)(rollup@4.53.3)(vue@3.5.27(typescript@5.8.3))
|
||||
@@ -1370,18 +1373,10 @@ packages:
|
||||
resolution: {integrity: sha512-/B58GeEmme7bkmQUrXzEw8P9sJb9BkMaYZqLDtq8ZdDLEddE3P4nVya8RQPB+p4b7EdqWajpPqdy1A2ZPLev/A==}
|
||||
engines: {node: '>=18.20.6'}
|
||||
|
||||
'@nuxt/kit@3.18.0':
|
||||
resolution: {integrity: sha512-svS1CBEx7gMgEIaNYrQt26J/t5bDSUdIf7GQWr5M6yszOzLw+IVzyfH7TBmuxZEbjovhLaJEG379mgKp82H/lA==}
|
||||
engines: {node: '>=18.12.0'}
|
||||
|
||||
'@nuxt/kit@3.20.1':
|
||||
resolution: {integrity: sha512-TIslaylfI5kd3AxX5qts0qyrIQ9Uq3HAA1bgIIJ+c+zpDfK338YS+YrCWxBBzDMECRCbAS58mqAd2MtJfG1ENA==}
|
||||
engines: {node: '>=18.12.0'}
|
||||
|
||||
'@nuxt/kit@4.0.2':
|
||||
resolution: {integrity: sha512-OtLkVYHpfrm1FzGSGxl0H3QXLgO41yxOgni5S6zzLG4gblG71Fy82B2QTdqJLzTLKWObiILKDhrysBtmDkp3LA==}
|
||||
engines: {node: '>=18.12.0'}
|
||||
|
||||
'@nuxt/kit@4.2.1':
|
||||
resolution: {integrity: sha512-lLt8KLHyl7IClc3RqRpRikz15eCfTRlAWL9leVzPyg5N87FfKE/7EWgWvpiL/z4Tf3dQCIqQb88TmHE0JTIDvA==}
|
||||
engines: {node: '>=18.12.0'}
|
||||
@@ -7537,10 +7532,10 @@ snapshots:
|
||||
find-up: 7.0.0
|
||||
get-port-please: 3.2.0
|
||||
h3: 1.15.5
|
||||
mlly: 1.7.4
|
||||
mlly: 1.8.0
|
||||
mrmime: 2.0.1
|
||||
open: 10.2.0
|
||||
tinyglobby: 0.2.14
|
||||
tinyglobby: 0.2.15
|
||||
ws: 8.18.3
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
@@ -7613,7 +7608,7 @@ snapshots:
|
||||
escodegen: 2.1.0
|
||||
estree-walker: 2.0.2
|
||||
jsonc-eslint-parser: 2.4.0
|
||||
mlly: 1.7.4
|
||||
mlly: 1.8.0
|
||||
source-map-js: 1.2.1
|
||||
yaml-eslint-parser: 1.3.0
|
||||
optionalDependencies:
|
||||
@@ -7960,7 +7955,7 @@ snapshots:
|
||||
|
||||
'@nuxt/devtools-kit@2.6.2(magicast@0.5.1)(vite@7.2.2(@types/node@22.16.5)(jiti@2.6.1)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(yaml@2.8.1))':
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.18.0(magicast@0.5.1)
|
||||
'@nuxt/kit': 3.20.1(magicast@0.5.1)
|
||||
execa: 8.0.1
|
||||
vite: 7.2.2(@types/node@22.16.5)(jiti@2.6.1)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(yaml@2.8.1)
|
||||
transitivePeerDependencies:
|
||||
@@ -8072,7 +8067,7 @@ snapshots:
|
||||
'@nuxt/devtools-kit': 2.6.2(magicast@0.5.1)(vite@7.2.2(@types/node@22.16.5)(jiti@2.6.1)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(yaml@2.8.1))
|
||||
'@nuxt/eslint-config': 1.7.1(@typescript-eslint/utils@8.50.0(eslint@9.31.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.27)(eslint@9.31.0(jiti@2.6.1))(typescript@5.8.3)
|
||||
'@nuxt/eslint-plugin': 1.7.1(eslint@9.31.0(jiti@2.6.1))(typescript@5.8.3)
|
||||
'@nuxt/kit': 4.0.2(magicast@0.5.1)
|
||||
'@nuxt/kit': 4.2.1(magicast@0.5.1)
|
||||
chokidar: 4.0.3
|
||||
eslint: 9.31.0(jiti@2.6.1)
|
||||
eslint-flat-config-utils: 2.1.1
|
||||
@@ -8097,7 +8092,7 @@ snapshots:
|
||||
'@nuxt/fonts@0.11.4(@netlify/blobs@9.1.2)(db0@0.3.4)(ioredis@5.8.2)(magicast@0.5.1)(vite@7.2.2(@types/node@22.16.5)(jiti@2.6.1)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(yaml@2.8.1))':
|
||||
dependencies:
|
||||
'@nuxt/devtools-kit': 2.6.2(magicast@0.5.1)(vite@7.2.2(@types/node@22.16.5)(jiti@2.6.1)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(yaml@2.8.1))
|
||||
'@nuxt/kit': 3.18.0(magicast@0.5.1)
|
||||
'@nuxt/kit': 3.20.1(magicast@0.5.1)
|
||||
consola: 3.4.2
|
||||
css-tree: 3.1.0
|
||||
defu: 6.1.4
|
||||
@@ -8141,7 +8136,7 @@ snapshots:
|
||||
|
||||
'@nuxt/image@1.10.0(@netlify/blobs@9.1.2)(db0@0.3.4)(ioredis@5.8.2)(magicast@0.5.1)':
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.18.0(magicast@0.5.1)
|
||||
'@nuxt/kit': 3.20.1(magicast@0.5.1)
|
||||
consola: 3.4.2
|
||||
defu: 6.1.4
|
||||
h3: 1.15.5
|
||||
@@ -8175,33 +8170,6 @@ snapshots:
|
||||
- magicast
|
||||
- uploadthing
|
||||
|
||||
'@nuxt/kit@3.18.0(magicast@0.5.1)':
|
||||
dependencies:
|
||||
c12: 3.2.0(magicast@0.5.1)
|
||||
consola: 3.4.2
|
||||
defu: 6.1.4
|
||||
destr: 2.0.5
|
||||
errx: 0.1.0
|
||||
exsolve: 1.0.7
|
||||
ignore: 7.0.5
|
||||
jiti: 2.5.1
|
||||
klona: 2.0.6
|
||||
knitwork: 1.2.0
|
||||
mlly: 1.7.4
|
||||
ohash: 2.0.11
|
||||
pathe: 2.0.3
|
||||
pkg-types: 2.2.0
|
||||
scule: 1.3.0
|
||||
semver: 7.7.2
|
||||
std-env: 3.9.0
|
||||
tinyglobby: 0.2.14
|
||||
ufo: 1.6.3
|
||||
unctx: 2.4.1
|
||||
unimport: 5.2.0
|
||||
untyped: 2.0.0
|
||||
transitivePeerDependencies:
|
||||
- magicast
|
||||
|
||||
'@nuxt/kit@3.20.1(magicast@0.5.1)':
|
||||
dependencies:
|
||||
c12: 3.3.2(magicast@0.5.1)
|
||||
@@ -8228,32 +8196,6 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- magicast
|
||||
|
||||
'@nuxt/kit@4.0.2(magicast@0.5.1)':
|
||||
dependencies:
|
||||
c12: 3.2.0(magicast@0.5.1)
|
||||
consola: 3.4.2
|
||||
defu: 6.1.4
|
||||
destr: 2.0.5
|
||||
errx: 0.1.0
|
||||
exsolve: 1.0.7
|
||||
ignore: 7.0.5
|
||||
jiti: 2.5.1
|
||||
klona: 2.0.6
|
||||
mlly: 1.7.4
|
||||
ohash: 2.0.11
|
||||
pathe: 2.0.3
|
||||
pkg-types: 2.2.0
|
||||
scule: 1.3.0
|
||||
semver: 7.7.2
|
||||
std-env: 3.9.0
|
||||
tinyglobby: 0.2.14
|
||||
ufo: 1.6.3
|
||||
unctx: 2.4.1
|
||||
unimport: 5.2.0
|
||||
untyped: 2.0.0
|
||||
transitivePeerDependencies:
|
||||
- magicast
|
||||
|
||||
'@nuxt/kit@4.2.1(magicast@0.5.1)':
|
||||
dependencies:
|
||||
c12: 3.3.2(magicast@0.5.1)
|
||||
@@ -8436,7 +8378,7 @@ snapshots:
|
||||
'@intlify/unplugin-vue-i18n': 6.0.8(@vue/compiler-dom@3.5.27)(eslint@9.31.0(jiti@2.6.1))(rollup@4.53.3)(typescript@5.8.3)(vue-i18n@10.0.8(vue@3.5.27(typescript@5.8.3)))(vue@3.5.27(typescript@5.8.3))
|
||||
'@intlify/utils': 0.13.0
|
||||
'@miyaneee/rollup-plugin-json5': 1.2.0(rollup@4.53.3)
|
||||
'@nuxt/kit': 3.18.0(magicast@0.5.1)
|
||||
'@nuxt/kit': 3.20.1(magicast@0.5.1)
|
||||
'@oxc-parser/wasm': 0.60.0
|
||||
'@rollup/plugin-yaml': 4.1.2(rollup@4.53.3)
|
||||
'@vue/compiler-sfc': 3.5.18
|
||||
@@ -9427,7 +9369,7 @@ snapshots:
|
||||
fast-glob: 3.3.3
|
||||
is-glob: 4.0.3
|
||||
minimatch: 9.0.5
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
ts-api-utils: 2.1.0(typescript@5.8.3)
|
||||
typescript: 5.8.3
|
||||
transitivePeerDependencies:
|
||||
@@ -9826,7 +9768,7 @@ snapshots:
|
||||
|
||||
'@vueuse/nuxt@13.6.0(magicast@0.5.1)(nuxt@3.20.1(@netlify/blobs@9.1.2)(@parcel/watcher@2.5.1)(@types/node@22.16.5)(@vue/compiler-sfc@3.5.27)(db0@0.3.4)(eslint@9.31.0(jiti@2.6.1))(ioredis@5.8.2)(lightningcss@1.30.1)(magicast@0.5.1)(ms@2.1.3)(optionator@0.9.4)(rollup@4.53.3)(sass@1.89.2)(terser@5.43.1)(typescript@5.8.3)(vite@7.2.2(@types/node@22.16.5)(jiti@2.6.1)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(yaml@2.8.1))(vue-tsc@3.0.4(typescript@5.8.3))(yaml@2.8.1))(vue@3.5.27(typescript@5.8.3))':
|
||||
dependencies:
|
||||
'@nuxt/kit': 4.0.2(magicast@0.5.1)
|
||||
'@nuxt/kit': 4.2.1(magicast@0.5.1)
|
||||
'@vueuse/core': 13.6.0(vue@3.5.27(typescript@5.8.3))
|
||||
'@vueuse/metadata': 13.6.0
|
||||
local-pkg: 1.1.1
|
||||
@@ -10129,23 +10071,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
magicast: 0.3.5
|
||||
|
||||
c12@3.2.0(magicast@0.5.1):
|
||||
dependencies:
|
||||
chokidar: 4.0.3
|
||||
confbox: 0.2.2
|
||||
defu: 6.1.4
|
||||
dotenv: 17.2.3
|
||||
exsolve: 1.0.7
|
||||
giget: 2.0.0
|
||||
jiti: 2.5.1
|
||||
ohash: 2.0.11
|
||||
pathe: 2.0.3
|
||||
perfect-debounce: 1.0.0
|
||||
pkg-types: 2.2.0
|
||||
rc9: 2.1.2
|
||||
optionalDependencies:
|
||||
magicast: 0.5.1
|
||||
|
||||
c12@3.3.2(magicast@0.5.1):
|
||||
dependencies:
|
||||
chokidar: 4.0.3
|
||||
@@ -10844,7 +10769,7 @@ snapshots:
|
||||
eslint-import-context: 0.1.9(unrs-resolver@1.11.1)
|
||||
is-glob: 4.0.3
|
||||
minimatch: 10.0.3
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
stable-hash-x: 0.2.0
|
||||
unrs-resolver: 1.11.1
|
||||
optionalDependencies:
|
||||
@@ -10863,7 +10788,7 @@ snapshots:
|
||||
espree: 10.4.0
|
||||
esquery: 1.6.0
|
||||
parse-imports-exports: 0.2.4
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
spdx-expression-parse: 4.0.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -10898,7 +10823,7 @@ snapshots:
|
||||
pluralize: 8.0.0
|
||||
regexp-tree: 0.1.27
|
||||
regjsparser: 0.12.0
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
strip-indent: 4.0.0
|
||||
|
||||
eslint-plugin-vue@10.4.0(@typescript-eslint/parser@8.38.0(eslint@9.31.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.31.0(jiti@2.6.1))(vue-eslint-parser@10.2.0(eslint@9.31.0(jiti@2.6.1))):
|
||||
@@ -10908,7 +10833,7 @@ snapshots:
|
||||
natural-compare: 1.4.0
|
||||
nth-check: 2.1.1
|
||||
postcss-selector-parser: 6.1.2
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
vue-eslint-parser: 10.2.0(eslint@9.31.0(jiti@2.6.1))
|
||||
xml-name-validator: 4.0.0
|
||||
optionalDependencies:
|
||||
@@ -11636,7 +11561,7 @@ snapshots:
|
||||
acorn: 8.15.0
|
||||
eslint-visitor-keys: 3.4.3
|
||||
espree: 9.6.1
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
|
||||
jsonfile@4.0.0:
|
||||
optionalDependencies:
|
||||
@@ -11760,8 +11685,8 @@ snapshots:
|
||||
|
||||
local-pkg@1.1.1:
|
||||
dependencies:
|
||||
mlly: 1.7.4
|
||||
pkg-types: 2.2.0
|
||||
mlly: 1.8.0
|
||||
pkg-types: 2.3.0
|
||||
quansync: 0.2.10
|
||||
|
||||
local-pkg@1.1.2:
|
||||
@@ -11819,7 +11744,7 @@ snapshots:
|
||||
dependencies:
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.17
|
||||
mlly: 1.7.4
|
||||
mlly: 1.8.0
|
||||
regexp-tree: 0.1.27
|
||||
type-level-regexp: 0.1.17
|
||||
ufo: 1.6.3
|
||||
@@ -12312,7 +12237,7 @@ snapshots:
|
||||
|
||||
node-abi@3.75.0:
|
||||
dependencies:
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
optional: true
|
||||
|
||||
node-addon-api@6.1.0:
|
||||
@@ -12363,7 +12288,7 @@ snapshots:
|
||||
normalize-package-data@6.0.2:
|
||||
dependencies:
|
||||
hosted-git-info: 7.0.2
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
validate-npm-package-license: 3.0.4
|
||||
|
||||
normalize-path@2.1.1:
|
||||
@@ -12391,7 +12316,7 @@ snapshots:
|
||||
|
||||
nuxt-csurf@1.6.5(magicast@0.5.1):
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.18.0(magicast@0.5.1)
|
||||
'@nuxt/kit': 3.20.1(magicast@0.5.1)
|
||||
defu: 6.1.4
|
||||
uncsrf: 1.2.0
|
||||
transitivePeerDependencies:
|
||||
@@ -12399,7 +12324,7 @@ snapshots:
|
||||
|
||||
nuxt-security@2.2.0(magicast@0.5.1)(rollup@4.53.3):
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.18.0(magicast@0.5.1)
|
||||
'@nuxt/kit': 3.20.1(magicast@0.5.1)
|
||||
basic-auth: 2.0.1
|
||||
defu: 6.1.4
|
||||
nuxt-csurf: 1.6.5(magicast@0.5.1)
|
||||
@@ -13424,7 +13349,7 @@ snapshots:
|
||||
detect-libc: 2.0.4
|
||||
node-addon-api: 6.1.0
|
||||
prebuild-install: 7.1.3
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
simple-get: 4.0.1
|
||||
tar-fs: 3.1.1
|
||||
tunnel-agent: 0.6.0
|
||||
@@ -13902,13 +13827,13 @@ snapshots:
|
||||
estree-walker: 3.0.3
|
||||
local-pkg: 1.1.1
|
||||
magic-string: 0.30.17
|
||||
mlly: 1.7.4
|
||||
mlly: 1.8.0
|
||||
pathe: 2.0.3
|
||||
picomatch: 4.0.3
|
||||
pkg-types: 2.2.0
|
||||
pkg-types: 2.3.0
|
||||
scule: 1.3.0
|
||||
strip-literal: 3.0.0
|
||||
tinyglobby: 0.2.14
|
||||
tinyglobby: 0.2.15
|
||||
unplugin: 2.3.5
|
||||
unplugin-utils: 0.2.4
|
||||
|
||||
@@ -13969,7 +13894,7 @@ snapshots:
|
||||
local-pkg: 1.1.1
|
||||
magic-string: 0.30.17
|
||||
micromatch: 4.0.8
|
||||
mlly: 1.7.4
|
||||
mlly: 1.8.0
|
||||
pathe: 2.0.3
|
||||
scule: 1.3.0
|
||||
unplugin: 2.3.5
|
||||
@@ -14266,7 +14191,7 @@ snapshots:
|
||||
eslint-visitor-keys: 4.2.1
|
||||
espree: 10.4.0
|
||||
esquery: 1.6.0
|
||||
semver: 7.7.2
|
||||
semver: 7.7.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -14290,7 +14215,7 @@ snapshots:
|
||||
|
||||
vue3-carousel-nuxt@1.1.6(magicast@0.5.1)(vue@3.5.27(typescript@5.8.3)):
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.18.0(magicast@0.5.1)
|
||||
'@nuxt/kit': 3.20.1(magicast@0.5.1)
|
||||
vue3-carousel: 0.15.1(vue@3.5.27(typescript@5.8.3))
|
||||
transitivePeerDependencies:
|
||||
- magicast
|
||||
|
||||
17
prisma/migrations/20260119070859_add_game_type/migration.sql
Normal file
17
prisma/migrations/20260119070859_add_game_type/migration.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "GameType" AS ENUM ('Game', 'Executor', 'Redist');
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "Game_mName_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "GameTag_name_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Game" ADD COLUMN "type" "GameType" NOT NULL DEFAULT 'Game';
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Game_mName_idx" ON "Game" USING GIST ("mName" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `GameVersion` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `gameId` on the `LaunchConfiguration` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `gameId` on the `SetupConfiguration` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "LaunchConfiguration" DROP CONSTRAINT "LaunchConfiguration_executorId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "LaunchConfiguration" DROP CONSTRAINT "LaunchConfiguration_gameId_versionId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "SetupConfiguration" DROP CONSTRAINT "SetupConfiguration_gameId_versionId_fkey";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "Game_mName_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "GameTag_name_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "GameVersion" DROP CONSTRAINT "GameVersion_pkey",
|
||||
ADD CONSTRAINT "GameVersion_pkey" PRIMARY KEY ("versionId");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "LaunchConfiguration" DROP COLUMN "gameId";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "SetupConfiguration" DROP COLUMN "gameId";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_requiredContent" (
|
||||
"A" TEXT NOT NULL,
|
||||
"B" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "_requiredContent_AB_pkey" PRIMARY KEY ("A","B")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_requiredContent_B_index" ON "_requiredContent"("B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Game_mName_idx" ON "Game" USING GIST ("mName" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SetupConfiguration" ADD CONSTRAINT "SetupConfiguration_versionId_fkey" FOREIGN KEY ("versionId") REFERENCES "GameVersion"("versionId") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "LaunchConfiguration" ADD CONSTRAINT "LaunchConfiguration_executorId_fkey" FOREIGN KEY ("executorId") REFERENCES "LaunchConfiguration"("launchId") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "LaunchConfiguration" ADD CONSTRAINT "LaunchConfiguration_versionId_fkey" FOREIGN KEY ("versionId") REFERENCES "GameVersion"("versionId") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_requiredContent" ADD CONSTRAINT "_requiredContent_A_fkey" FOREIGN KEY ("A") REFERENCES "GameVersion"("versionId") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_requiredContent" ADD CONSTRAINT "_requiredContent_B_fkey" FOREIGN KEY ("B") REFERENCES "GameVersion"("versionId") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,14 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "Game_mName_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "GameTag_name_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "LaunchConfiguration" ADD COLUMN "executorSuggestions" TEXT[];
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Game_mName_idx" ON "Game" USING GIST ("mName" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
|
||||
@@ -0,0 +1,27 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "Game_mName_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "GameTag_name_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "GameVersion" ALTER COLUMN "versionPath" DROP NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "UnimportedGameVersion" (
|
||||
"id" TEXT NOT NULL,
|
||||
"gameId" TEXT NOT NULL,
|
||||
"versionName" TEXT NOT NULL,
|
||||
"manifest" JSONB NOT NULL,
|
||||
|
||||
CONSTRAINT "UnimportedGameVersion_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Game_mName_idx" ON "Game" USING GIST ("mName" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UnimportedGameVersion" ADD CONSTRAINT "UnimportedGameVersion_gameId_fkey" FOREIGN KEY ("gameId") REFERENCES "Game"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,14 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "Game_mName_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "GameTag_name_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "UnimportedGameVersion" ADD COLUMN "fileList" TEXT[];
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Game_mName_idx" ON "Game" USING GIST ("mName" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
|
||||
15
prisma/migrations/20260123021108_add_file_list/migration.sql
Normal file
15
prisma/migrations/20260123021108_add_file_list/migration.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "Game_mName_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "GameTag_name_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "GameVersion" ADD COLUMN "fileList" TEXT[],
|
||||
ADD COLUMN "negativeFileList" TEXT[];
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Game_mName_idx" ON "Game" USING GIST ("mName" gist_trgm_ops(siglen=32));
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
|
||||
@@ -8,6 +8,12 @@ enum MetadataSource {
|
||||
OpenCritic
|
||||
}
|
||||
|
||||
enum GameType {
|
||||
Game
|
||||
Executor
|
||||
Redist
|
||||
}
|
||||
|
||||
model Game {
|
||||
id String @id @default(uuid())
|
||||
|
||||
@@ -15,6 +21,8 @@ model Game {
|
||||
metadataId String
|
||||
created DateTime @default(now())
|
||||
|
||||
type GameType @default(Game)
|
||||
|
||||
// Any field prefixed with m is filled in from metadata
|
||||
// Acts as a cache so we can search and filter it
|
||||
mName String // Name of game
|
||||
@@ -49,6 +57,7 @@ model Game {
|
||||
|
||||
developers Company[] @relation(name: "developers")
|
||||
publishers Company[] @relation(name: "publishers")
|
||||
unimportedGameVersions UnimportedGameVersion[]
|
||||
|
||||
@@unique([metadataSource, metadataId], name: "metadataKey")
|
||||
@@unique([libraryId, libraryPath], name: "libraryKey")
|
||||
@@ -82,14 +91,24 @@ model GameRating {
|
||||
@@unique([metadataSource, metadataId], name: "metadataKey")
|
||||
}
|
||||
|
||||
model UnimportedGameVersion {
|
||||
id String @id @default(uuid())
|
||||
gameId String
|
||||
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
||||
versionName String
|
||||
|
||||
manifest Json
|
||||
fileList String[]
|
||||
}
|
||||
|
||||
// A particular set of files that relate to the version
|
||||
model GameVersion {
|
||||
gameId String
|
||||
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
||||
versionId String @default(uuid())
|
||||
versionId String @id @default(uuid())
|
||||
|
||||
displayName String?
|
||||
versionPath String
|
||||
versionPath String?
|
||||
|
||||
created DateTime @default(now())
|
||||
|
||||
@@ -99,11 +118,14 @@ model GameVersion {
|
||||
onlySetup Boolean @default(false)
|
||||
|
||||
dropletManifest Json // Results from droplet
|
||||
fileList String[] // List of all files, for delta updates
|
||||
negativeFileList String[] // List of files to remove, for delta updates
|
||||
|
||||
versionIndex Int
|
||||
delta Boolean @default(false)
|
||||
|
||||
@@id([gameId, versionId])
|
||||
requiredContent GameVersion[] @relation(name: "requiredContent")
|
||||
requiringContent GameVersion[] @relation(name: "requiredContent")
|
||||
}
|
||||
|
||||
model SetupConfiguration {
|
||||
@@ -113,9 +135,8 @@ model SetupConfiguration {
|
||||
|
||||
platform Platform
|
||||
|
||||
gameId String
|
||||
versionId String
|
||||
gameVersion GameVersion @relation(fields: [gameId, versionId], references: [gameId, versionId], onDelete: Cascade, onUpdate: Cascade)
|
||||
gameVersion GameVersion @relation(fields: [versionId], references: [versionId], onDelete: Cascade, onUpdate: Cascade)
|
||||
}
|
||||
|
||||
model LaunchConfiguration {
|
||||
@@ -129,13 +150,13 @@ model LaunchConfiguration {
|
||||
|
||||
// For emulation targets
|
||||
executorId String?
|
||||
executor LaunchConfiguration? @relation(fields: [executorId], references: [launchId], name: "executor", onDelete: Cascade, onUpdate: Cascade)
|
||||
executor LaunchConfiguration? @relation(fields: [executorId], references: [launchId], name: "executor")
|
||||
executorSuggestions String[]
|
||||
|
||||
umuIdOverride String?
|
||||
|
||||
gameId String
|
||||
versionId String
|
||||
gameVersion GameVersion @relation(fields: [gameId, versionId], references: [gameId, versionId], onDelete: Cascade, onUpdate: Cascade)
|
||||
gameVersion GameVersion @relation(fields: [versionId], references: [versionId], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
executions LaunchConfiguration[] @relation("executor")
|
||||
}
|
||||
|
||||
11
server/api/v1/admin/depot/index.get.ts
Normal file
11
server/api/v1/admin/depot/index.get.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["depot:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const depots = await prisma.depot.findMany({});
|
||||
|
||||
return depots;
|
||||
});
|
||||
@@ -6,7 +6,6 @@ import { castManifest } from "~/server/internal/library/manifest";
|
||||
const AUTHORIZATION_HEADER_PREFIX = "Bearer ";
|
||||
|
||||
const Query = type({
|
||||
game: "string",
|
||||
version: "string",
|
||||
});
|
||||
|
||||
@@ -31,11 +30,8 @@ export default defineEventHandler(async (h3) => {
|
||||
|
||||
const version = await prisma.gameVersion.findUnique({
|
||||
where: {
|
||||
gameId_versionId: {
|
||||
gameId: query.game,
|
||||
versionId: query.version,
|
||||
},
|
||||
},
|
||||
select: {
|
||||
dropletManifest: true,
|
||||
versionPath: true,
|
||||
@@ -11,6 +11,11 @@ export default defineEventHandler(async (h3) => {
|
||||
select: {
|
||||
versionId: true,
|
||||
},
|
||||
where: {
|
||||
versionPath: {
|
||||
not: null
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
51
server/api/v1/admin/depot/upload.post.ts
Normal file
51
server/api/v1/admin/depot/upload.post.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
const UploadManifest = type({
|
||||
gameId: "string",
|
||||
versionName: "string",
|
||||
|
||||
manifest: type({
|
||||
version: "'2'",
|
||||
size: "number",
|
||||
key: "16 <= number[] <= 16",
|
||||
chunks: type({
|
||||
["string"]: {
|
||||
checksum: "string",
|
||||
iv: "16 <= number[] <= 16",
|
||||
files: type({
|
||||
filename: "string",
|
||||
start: "number",
|
||||
length: "number",
|
||||
permissions: "number",
|
||||
}).array(),
|
||||
},
|
||||
}),
|
||||
}),
|
||||
fileList: "string[]",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["depot:upload:new"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const { gameId, versionName, manifest, fileList } =
|
||||
await readDropValidatedBody(h3, UploadManifest);
|
||||
|
||||
const version = await prisma.unimportedGameVersion.create({
|
||||
data: {
|
||||
game: {
|
||||
connect: {
|
||||
id: gameId,
|
||||
},
|
||||
},
|
||||
versionName,
|
||||
manifest,
|
||||
fileList,
|
||||
},
|
||||
});
|
||||
|
||||
return { id: version.id };
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { GameVersion, Prisma } from "~/prisma/client/client";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import type { UnimportedVersionInformation } from "~/server/internal/library";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
async function getGameVersionSize<
|
||||
@@ -59,7 +60,7 @@ export default defineEventHandler<
|
||||
{ body: never },
|
||||
Promise<{
|
||||
game: AdminFetchGameType;
|
||||
unimportedVersions: string[] | undefined;
|
||||
unimportedVersions: UnimportedVersionInformation[] | undefined;
|
||||
}>
|
||||
>(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:read"]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { type } from "arktype";
|
||||
import { GameType } from "~/prisma/client/enums";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
@@ -7,6 +8,7 @@ import metadataHandler from "~/server/internal/metadata";
|
||||
const ImportGameBody = type({
|
||||
library: "string",
|
||||
path: "string",
|
||||
type: type.valueOf(GameType),
|
||||
["metadata?"]: {
|
||||
id: "string",
|
||||
sourceId: "string",
|
||||
@@ -19,7 +21,7 @@ export default defineEventHandler<{ body: typeof ImportGameBody.infer }>(
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["import:game:new"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const { library, path, metadata } = await readDropValidatedBody(
|
||||
const { library, path, metadata, type } = await readDropValidatedBody(
|
||||
h3,
|
||||
ImportGameBody,
|
||||
);
|
||||
@@ -38,8 +40,8 @@ export default defineEventHandler<{ body: typeof ImportGameBody.infer }>(
|
||||
});
|
||||
|
||||
const taskId = metadata
|
||||
? await metadataHandler.createGame(metadata, library, path)
|
||||
: await metadataHandler.createGameWithoutMetadata(library, path);
|
||||
? await metadataHandler.createGame(metadata, library, path, type)
|
||||
: await metadataHandler.createGameWithoutMetadata(library, path, type);
|
||||
|
||||
if (!taskId)
|
||||
throw createError({
|
||||
|
||||
@@ -16,7 +16,7 @@ export default defineEventHandler(async (h3) => {
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
where: { id: gameId },
|
||||
select: { libraryId: true, libraryPath: true },
|
||||
select: { libraryId: true, libraryPath: true, type: true },
|
||||
});
|
||||
if (!game || !game.libraryId)
|
||||
throw createError({ statusCode: 404, statusMessage: "Game not found" });
|
||||
@@ -28,5 +28,5 @@ export default defineEventHandler(async (h3) => {
|
||||
if (!unimportedVersions)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
|
||||
|
||||
return unimportedVersions;
|
||||
return { versions: unimportedVersions, type: game.type };
|
||||
});
|
||||
|
||||
@@ -7,7 +7,11 @@ import libraryManager from "~/server/internal/library";
|
||||
|
||||
export const ImportVersion = type({
|
||||
id: "string",
|
||||
version: "string",
|
||||
version: type({
|
||||
type: "'depot' | 'local'",
|
||||
identifier: "string",
|
||||
name: "string",
|
||||
}),
|
||||
displayName: "string?",
|
||||
|
||||
launches: type({
|
||||
@@ -16,6 +20,7 @@ export const ImportVersion = type({
|
||||
launch: "string",
|
||||
umuId: "string?",
|
||||
executorId: "string?",
|
||||
suggestions: "string[]?",
|
||||
}).array(),
|
||||
|
||||
setups: type({
|
||||
@@ -25,6 +30,10 @@ export const ImportVersion = type({
|
||||
|
||||
onlySetup: "boolean = false",
|
||||
delta: "boolean = false",
|
||||
|
||||
requiredContent: type("string")
|
||||
.array()
|
||||
.default(() => []),
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
@@ -47,7 +56,7 @@ export default defineEventHandler(async (h3) => {
|
||||
if (validOverlayVersions == 0)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Update mode requires a pre-existing version.",
|
||||
statusMessage: `Update mode requires a pre-existing version for platform: ${platformObject.platform}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,43 @@
|
||||
import { ArkErrors, type } from "arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
const Query = type({
|
||||
id: "string",
|
||||
type: "'depot' | 'local'",
|
||||
version: "string",
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["import:version:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const query = await getQuery(h3);
|
||||
const gameId = query.id?.toString();
|
||||
const versionName = query.version?.toString();
|
||||
if (!gameId || !versionName)
|
||||
const query = Query(getQuery(h3));
|
||||
if (query instanceof ArkErrors)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id or version in request params",
|
||||
message: query.summary,
|
||||
});
|
||||
|
||||
try {
|
||||
const preload = await libraryManager.fetchUnimportedVersionInformation(
|
||||
gameId,
|
||||
versionName,
|
||||
query.id,
|
||||
{
|
||||
type: query.type,
|
||||
identifier: query.version,
|
||||
},
|
||||
);
|
||||
if (!preload)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid game or version id/name",
|
||||
message: "Invalid game or version id/name",
|
||||
});
|
||||
|
||||
return preload;
|
||||
} catch (e) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: `Failed to fetch preload information for ${gameId}: ${e}`,
|
||||
message: `Failed to fetch preload information for ${query.id}: ${e}`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import { ArkErrors, type } from "arktype";
|
||||
import { GameType } from "~/prisma/client/enums";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import type { GameMetadataSearchResult } from "~/server/internal/metadata/types";
|
||||
|
||||
const Query = type({
|
||||
q: "string",
|
||||
type: type.valueOf(GameType).optional(),
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:read"]);
|
||||
const allowed = await aclManager.allowSystemACL(h3, [
|
||||
"game:read",
|
||||
"depot:read",
|
||||
]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const query = Query(getQuery(h3));
|
||||
@@ -22,7 +27,7 @@ export default defineEventHandler(async (h3) => {
|
||||
mShortDescription: string;
|
||||
mReleased: string;
|
||||
}[] =
|
||||
await prisma.$queryRaw`SELECT id, "mName", "mIconObjectId", "mShortDescription", "mReleased" FROM "Game" WHERE SIMILARITY("mName", ${query.q}) > 0.2 ORDER BY SIMILARITY("mName", ${query.q}) DESC;`;
|
||||
await prisma.$queryRaw`SELECT id, "mName", "mIconObjectId", "mShortDescription", "mReleased" FROM "Game" WHERE SIMILARITY("mName", ${query.q}) > 0.2 AND (${query.type || "undefined"} = 'undefined' OR type::text = ${query.type}) ORDER BY SIMILARITY("mName", ${query.q}) DESC;`;
|
||||
|
||||
const resultsMapped = results.map(
|
||||
(v) =>
|
||||
|
||||
@@ -13,15 +13,24 @@ export default defineClientEventHandler(async (h3) => {
|
||||
|
||||
const gameVersion = await prisma.gameVersion.findUnique({
|
||||
where: {
|
||||
gameId_versionId: {
|
||||
gameId: id,
|
||||
versionId: version,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
launches: {
|
||||
include: {
|
||||
executor: true,
|
||||
executor: {
|
||||
include: {
|
||||
gameVersion: {
|
||||
select: {
|
||||
game: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
setups: true,
|
||||
@@ -34,8 +43,22 @@ export default defineClientEventHandler(async (h3) => {
|
||||
statusMessage: "Game version not found",
|
||||
});
|
||||
|
||||
return {
|
||||
const gameVersionMapped = {
|
||||
...gameVersion,
|
||||
launches: gameVersion.launches.map((launch) => ({
|
||||
...launch,
|
||||
executor: launch.executor
|
||||
? {
|
||||
...launch.executor,
|
||||
gameVersion: undefined,
|
||||
gameId: launch.executor.gameVersion.game.id,
|
||||
}
|
||||
: undefined,
|
||||
})),
|
||||
};
|
||||
|
||||
return {
|
||||
...gameVersionMapped,
|
||||
size: libraryManager.getGameVersionSize(id, version),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { createDownloadManifestDetails } from "~/server/internal/library/manifest/index";
|
||||
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
const query = getQuery(h3);
|
||||
const id = query.id?.toString();
|
||||
const version = query.version?.toString();
|
||||
if (!id || !version)
|
||||
if (!version)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id or version in query",
|
||||
statusMessage: "Missing version ID in query",
|
||||
});
|
||||
|
||||
const manifest = await prisma.gameVersion.findUnique({
|
||||
where: { gameId_versionId: { gameId: id, versionId: version } },
|
||||
select: { dropletManifest: true },
|
||||
});
|
||||
if (!manifest)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid game or version, or no versions added.",
|
||||
});
|
||||
return manifest.dropletManifest;
|
||||
const result = await createDownloadManifestDetails(version);
|
||||
return result;
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@ import gameSizeManager from "~/server/internal/gamesize";
|
||||
|
||||
type VersionDownloadOption = {
|
||||
versionId: string;
|
||||
displayName?: string;
|
||||
versionPath: string;
|
||||
displayName?: string | undefined;
|
||||
versionPath?: string | undefined;
|
||||
platform: Platform;
|
||||
size: number;
|
||||
requiredContent: Array<{
|
||||
@@ -106,7 +106,8 @@ export default defineClientEventHandler(async (h3) => {
|
||||
([platform, requiredContent]) =>
|
||||
({
|
||||
versionId: v.versionId,
|
||||
versionPath: v.versionPath,
|
||||
displayName: v.displayName || undefined,
|
||||
versionPath: v.versionPath || undefined,
|
||||
platform,
|
||||
requiredContent,
|
||||
size: size!,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ArkErrors, type } from "arktype";
|
||||
import type { Prisma } from "~/prisma/client/client";
|
||||
import { GameType } from "~/prisma/client/enums";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { parsePlatform } from "~/server/internal/utils/parseplatform";
|
||||
@@ -100,6 +101,7 @@ export default defineEventHandler(async (h3) => {
|
||||
...tagFilter,
|
||||
...platformFilter,
|
||||
...companyFilter,
|
||||
type: GameType.Game,
|
||||
};
|
||||
|
||||
const sort: Prisma.GameOrderByWithRelationInput = {};
|
||||
|
||||
@@ -108,8 +108,11 @@ export const systemACLDescriptions: ObjectFromList<typeof systemACLs> = {
|
||||
|
||||
"settings:update": "Update system settings.",
|
||||
|
||||
"depot:read": "Read depot information, and search for games",
|
||||
"depot:new": "Create a new download depot",
|
||||
"depot:delete": "Remove a download depot",
|
||||
"depot:upload:new": "Upload a new version to a depot",
|
||||
"depot:upload:delete": "Remove a depot version",
|
||||
|
||||
"system-data:listen":
|
||||
"Connect to a websocket to receive system data updates.",
|
||||
|
||||
@@ -47,8 +47,11 @@ export type UserACL = Array<(typeof userACLs)[number]>;
|
||||
export const systemACLs = [
|
||||
"setup",
|
||||
|
||||
"depot:read",
|
||||
"depot:new",
|
||||
"depot:delete",
|
||||
"depot:upload:new",
|
||||
"depot:upload:delete",
|
||||
|
||||
"auth:read",
|
||||
"auth:simple:invitation:read",
|
||||
|
||||
@@ -69,7 +69,7 @@ class GameSizeManager {
|
||||
}
|
||||
|
||||
const { dropletManifest } = (await prisma.gameVersion.findUnique({
|
||||
where: { gameId_versionId: { versionId, gameId } },
|
||||
where: { versionId },
|
||||
}))!;
|
||||
|
||||
return castManifest(dropletManifest).size;
|
||||
|
||||
@@ -18,6 +18,8 @@ import type { WorkingLibrarySource } from "~/server/api/v1/admin/library/sources
|
||||
import gameSizeManager from "~/server/internal/gamesize";
|
||||
import { TORRENTIAL_SERVICE } from "../services/services/torrential";
|
||||
import type { ImportVersion } from "~/server/api/v1/admin/import/version/index.post";
|
||||
import { GameType, type Platform } from "~/prisma/client/enums";
|
||||
import { castManifest } from "./manifest";
|
||||
|
||||
export function createGameImportTaskId(libraryId: string, libraryPath: string) {
|
||||
return createHash("md5")
|
||||
@@ -34,6 +36,30 @@ export function createVersionImportTaskKey(
|
||||
.digest("hex");
|
||||
}
|
||||
|
||||
export interface ExecutorVersionGuess {
|
||||
type: "executor";
|
||||
executorId: string;
|
||||
icon: string;
|
||||
gameName: string;
|
||||
versionName: string;
|
||||
launchName: string;
|
||||
platform: Platform;
|
||||
}
|
||||
export interface PlatformVersionGuess {
|
||||
platform: Platform;
|
||||
type: "platform";
|
||||
}
|
||||
export type VersionGuess = {
|
||||
filename: string;
|
||||
match: number;
|
||||
} & (PlatformVersionGuess | ExecutorVersionGuess);
|
||||
|
||||
export interface UnimportedVersionInformation {
|
||||
type: "local" | "depot";
|
||||
name: string;
|
||||
identifier: string;
|
||||
}
|
||||
|
||||
class LibraryManager {
|
||||
private libraries: Map<string, LibraryProvider<unknown>> = new Map();
|
||||
|
||||
@@ -95,7 +121,10 @@ class LibraryManager {
|
||||
return unimportedGames;
|
||||
}
|
||||
|
||||
async fetchUnimportedGameVersions(libraryId: string, libraryPath: string) {
|
||||
async fetchUnimportedGameVersions(
|
||||
libraryId: string,
|
||||
libraryPath: string,
|
||||
): Promise<UnimportedVersionInformation[] | undefined> {
|
||||
const provider = this.libraries.get(libraryId);
|
||||
if (!provider) return undefined;
|
||||
const game = await prisma.game.findUnique({
|
||||
@@ -115,14 +144,40 @@ class LibraryManager {
|
||||
try {
|
||||
const versions = await provider.listVersions(
|
||||
libraryPath,
|
||||
game.versions.map((v) => v.versionPath),
|
||||
game.versions.map((v) => v.versionPath).filter((v) => v !== null),
|
||||
);
|
||||
const unimportedVersions = versions.filter(
|
||||
const unimportedVersions = versions
|
||||
.filter(
|
||||
(e) =>
|
||||
game.versions.findIndex((v) => v.versionPath == e) == -1 &&
|
||||
!taskHandler.hasTaskKey(createVersionImportTaskKey(game.id, e)),
|
||||
)
|
||||
.map(
|
||||
(v) =>
|
||||
({
|
||||
type: "local",
|
||||
name: v,
|
||||
identifier: v,
|
||||
}) satisfies UnimportedVersionInformation,
|
||||
);
|
||||
return unimportedVersions;
|
||||
const depotVersions = await prisma.unimportedGameVersion.findMany({
|
||||
where: {
|
||||
gameId: game.id,
|
||||
},
|
||||
select: {
|
||||
versionName: true,
|
||||
id: true,
|
||||
},
|
||||
});
|
||||
const mappedDepotVersions = depotVersions.map(
|
||||
(v) =>
|
||||
({
|
||||
type: "depot",
|
||||
name: v.versionName,
|
||||
identifier: v.id,
|
||||
}) satisfies UnimportedVersionInformation,
|
||||
);
|
||||
return [...unimportedVersions, ...mappedDepotVersions];
|
||||
} catch (e) {
|
||||
if (e instanceof GameNotFoundError) {
|
||||
logger.warn(e);
|
||||
@@ -165,10 +220,13 @@ class LibraryManager {
|
||||
/**
|
||||
* Fetches recommendations and extra data about the version. Doesn't actually check if it's been imported.
|
||||
* @param gameId
|
||||
* @param versionName
|
||||
* @param versionIdentifier
|
||||
* @returns
|
||||
*/
|
||||
async fetchUnimportedVersionInformation(gameId: string, versionName: string) {
|
||||
async fetchUnimportedVersionInformation(
|
||||
gameId: string,
|
||||
versionIdentifier: Omit<UnimportedVersionInformation, "name">,
|
||||
) {
|
||||
const game = await prisma.game.findUnique({
|
||||
where: { id: gameId },
|
||||
select: { libraryPath: true, libraryId: true, mName: true },
|
||||
@@ -178,7 +236,7 @@ class LibraryManager {
|
||||
const library = this.libraries.get(game.libraryId);
|
||||
if (!library) return undefined;
|
||||
|
||||
const fileExts: { [key: string]: string[] } = {
|
||||
const fileExts: { [key in Platform]: string[] } = {
|
||||
Linux: [
|
||||
// Ext for Unity games
|
||||
".x86_64",
|
||||
@@ -196,13 +254,60 @@ class LibraryManager {
|
||||
],
|
||||
};
|
||||
|
||||
const options: Array<{
|
||||
filename: string;
|
||||
platform: string;
|
||||
match: number;
|
||||
}> = [];
|
||||
const executorSuggestions = await prisma.launchConfiguration.findMany({
|
||||
where: {
|
||||
executorSuggestions: {
|
||||
isEmpty: false,
|
||||
},
|
||||
gameVersion: {
|
||||
game: {
|
||||
type: GameType.Executor,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
executorSuggestions: true,
|
||||
gameVersion: {
|
||||
select: {
|
||||
game: {
|
||||
select: {
|
||||
mIconObjectId: true,
|
||||
mName: true,
|
||||
},
|
||||
},
|
||||
displayName: true,
|
||||
versionPath: true,
|
||||
},
|
||||
},
|
||||
name: true,
|
||||
launchId: true,
|
||||
platform: true,
|
||||
},
|
||||
});
|
||||
|
||||
const options: Array<VersionGuess> = [];
|
||||
|
||||
let files;
|
||||
if (versionIdentifier.type === "local") {
|
||||
files = await library.versionReaddir(
|
||||
game.libraryPath,
|
||||
versionIdentifier.identifier,
|
||||
);
|
||||
} else if (versionIdentifier.type === "depot") {
|
||||
const unimported = await prisma.unimportedGameVersion.findUnique({
|
||||
where: {
|
||||
id: versionIdentifier.identifier,
|
||||
},
|
||||
select: {
|
||||
fileList: true,
|
||||
},
|
||||
});
|
||||
if (!unimported) return undefined;
|
||||
files = unimported.fileList;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const files = await library.versionReaddir(game.libraryPath, versionName);
|
||||
for (const filename of files) {
|
||||
const basename = path.basename(filename);
|
||||
const dotLocation = filename.lastIndexOf(".");
|
||||
@@ -213,12 +318,32 @@ class LibraryManager {
|
||||
if (checkExt != ext) continue;
|
||||
const fuzzyValue = fuzzy(basename, game.mName);
|
||||
options.push({
|
||||
type: "platform",
|
||||
filename: filename.replaceAll(" ", "\\ "),
|
||||
platform,
|
||||
platform: platform as Platform,
|
||||
match: fuzzyValue,
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const executorSuggestion of executorSuggestions) {
|
||||
for (const suggestion of executorSuggestion.executorSuggestions) {
|
||||
if (suggestion != ext) continue;
|
||||
const fuzzyValue = fuzzy(basename, game.mName);
|
||||
options.push({
|
||||
type: "executor",
|
||||
filename: filename.replaceAll(" ", "\\ "),
|
||||
match: fuzzyValue,
|
||||
executorId: executorSuggestion.launchId,
|
||||
|
||||
icon: executorSuggestion.gameVersion.game.mIconObjectId,
|
||||
gameName: executorSuggestion.gameVersion.game.mName,
|
||||
versionName: (executorSuggestion.gameVersion.displayName ??
|
||||
executorSuggestion.gameVersion.versionPath)!,
|
||||
launchName: executorSuggestion.name,
|
||||
platform: executorSuggestion.platform,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sortedOptions = options.sort((a, b) => b.match - a.match);
|
||||
@@ -247,29 +372,49 @@ class LibraryManager {
|
||||
|
||||
async importVersion(
|
||||
gameId: string,
|
||||
versionPath: string,
|
||||
version: UnimportedVersionInformation,
|
||||
metadata: typeof ImportVersion.infer,
|
||||
) {
|
||||
const taskKey = createVersionImportTaskKey(gameId, versionPath);
|
||||
const taskKey = createVersionImportTaskKey(gameId, version.identifier);
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
where: { id: gameId },
|
||||
select: { mName: true, libraryId: true, libraryPath: true },
|
||||
select: { mName: true, libraryId: true, libraryPath: true, type: true },
|
||||
});
|
||||
if (!game || !game.libraryId) return undefined;
|
||||
|
||||
if (game.type === GameType.Redist && !metadata.onlySetup)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: "Redistributables can only be in setup-only mode.",
|
||||
});
|
||||
|
||||
const library = this.libraries.get(game.libraryId);
|
||||
if (!library) return undefined;
|
||||
|
||||
const unimportedVersion =
|
||||
version.type === "depot"
|
||||
? await prisma.unimportedGameVersion.findUnique({
|
||||
where: { id: version.identifier },
|
||||
})
|
||||
: undefined;
|
||||
|
||||
return await taskHandler.create({
|
||||
key: taskKey,
|
||||
taskGroup: "import:game",
|
||||
name: `Importing version ${versionPath} for ${game.mName}`,
|
||||
name: `Importing version ${version.name} for ${game.mName}`,
|
||||
acls: ["system:import:version:read"],
|
||||
async run({ progress, logger }) {
|
||||
let versionPath: string | null = null;
|
||||
let manifest;
|
||||
let fileList;
|
||||
|
||||
if (version.type === "local") {
|
||||
versionPath = version.identifier;
|
||||
// First, create the manifest via droplet.
|
||||
// This takes up 90% of our progress, so we wrap it in a *0.9
|
||||
const manifest = await library.generateDropletManifest(
|
||||
|
||||
manifest = await library.generateDropletManifest(
|
||||
game.libraryPath,
|
||||
versionPath,
|
||||
(err, value) => {
|
||||
@@ -281,15 +426,25 @@ class LibraryManager {
|
||||
logger.info(value);
|
||||
},
|
||||
);
|
||||
|
||||
fileList = await library.versionReaddir(
|
||||
game.libraryPath,
|
||||
versionPath,
|
||||
);
|
||||
logger.info("Created manifest successfully!");
|
||||
} else if (version.type === "depot" && unimportedVersion) {
|
||||
manifest = castManifest(unimportedVersion.manifest);
|
||||
fileList = unimportedVersion.fileList;
|
||||
progress(90);
|
||||
} else {
|
||||
throw "Could not find or create manifest for this version.";
|
||||
}
|
||||
|
||||
const currentIndex = await prisma.gameVersion.count({
|
||||
where: { gameId: gameId },
|
||||
});
|
||||
|
||||
// Then, create the database object
|
||||
await prisma.gameVersion.create({
|
||||
const newVersion = await prisma.gameVersion.create({
|
||||
data: {
|
||||
game: {
|
||||
connect: {
|
||||
@@ -301,6 +456,7 @@ class LibraryManager {
|
||||
|
||||
versionPath,
|
||||
dropletManifest: manifest,
|
||||
fileList,
|
||||
versionIndex: currentIndex,
|
||||
delta: metadata.delta,
|
||||
|
||||
@@ -321,9 +477,13 @@ class LibraryManager {
|
||||
name: v.name,
|
||||
command: v.launch,
|
||||
platform: v.platform,
|
||||
...(v.executorId
|
||||
? { executorId: v.executorId }
|
||||
...(v.executorId && game.type === "Game"
|
||||
? {
|
||||
executorId: v.executorId,
|
||||
}
|
||||
: undefined),
|
||||
executorSuggestions:
|
||||
game.type === "Executor" ? (v.suggestions ?? []) : [],
|
||||
})),
|
||||
}
|
||||
: { data: [] },
|
||||
@@ -333,17 +493,30 @@ class LibraryManager {
|
||||
logger.info("Successfully created version!");
|
||||
|
||||
notificationSystem.systemPush({
|
||||
nonce: `version-create-${gameId}-${versionPath}`,
|
||||
title: `'${game.mName}' ('${versionPath}') finished importing.`,
|
||||
description: `Drop finished importing version ${versionPath} for ${game.mName}.`,
|
||||
nonce: `version-create-${gameId}-${version}`,
|
||||
title: `'${game.mName}' ('${version}') finished importing.`,
|
||||
description: `Drop finished importing version ${version} for ${game.mName}.`,
|
||||
actions: [`View|/admin/library/${gameId}`],
|
||||
acls: ["system:import:version:read"],
|
||||
});
|
||||
|
||||
await libraryManager.cacheCombinedGameSize(gameId);
|
||||
await libraryManager.cacheGameVersionSize(gameId, versionPath);
|
||||
await libraryManager.cacheGameVersionSize(gameId, newVersion.versionId);
|
||||
|
||||
await TORRENTIAL_SERVICE.utils().invalidate(gameId, versionPath);
|
||||
await TORRENTIAL_SERVICE.utils().invalidate(
|
||||
gameId,
|
||||
newVersion.versionId,
|
||||
);
|
||||
|
||||
if (version.type === "depot") {
|
||||
// SAFETY: we can only reach this if the type is depot and identifier is valid
|
||||
// eslint-disable-next-line drop/no-prisma-delete
|
||||
await prisma.unimportedGameVersion.delete({
|
||||
where: {
|
||||
id: version.identifier,
|
||||
},
|
||||
});
|
||||
}
|
||||
progress(100);
|
||||
},
|
||||
});
|
||||
@@ -390,6 +563,20 @@ class LibraryManager {
|
||||
},
|
||||
});
|
||||
await gameSizeManager.deleteGame(gameId);
|
||||
// Delete all game versions that depended on this game
|
||||
await prisma.gameVersion.deleteMany({
|
||||
where: {
|
||||
launches: {
|
||||
some: {
|
||||
executor: {
|
||||
gameVersion: {
|
||||
gameId,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getGameVersionSize(
|
||||
@@ -421,7 +608,7 @@ class LibraryManager {
|
||||
await gameSizeManager.cacheCombinedGame(game);
|
||||
}
|
||||
|
||||
async cacheGameVersionSize(gameId: string, versionName: string) {
|
||||
async cacheGameVersionSize(gameId: string, versionId: string) {
|
||||
const game = await prisma.game.findFirst({
|
||||
where: { id: gameId },
|
||||
include: { versions: true },
|
||||
@@ -429,7 +616,7 @@ class LibraryManager {
|
||||
if (!game) {
|
||||
return;
|
||||
}
|
||||
await gameSizeManager.cacheGameVersion(game, versionName);
|
||||
await gameSizeManager.cacheGameVersion(game, versionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { JsonValue } from "@prisma/client/runtime/library";
|
||||
|
||||
export type Manifest = V2Manifest;
|
||||
export type DropletManifest = V2Manifest;
|
||||
|
||||
export type V2Manifest = {
|
||||
version: "2";
|
||||
size: number;
|
||||
key: number[];
|
||||
chunks: { [key: string]: V2ChunkData[] };
|
||||
chunks: { [key: string]: V2ChunkData };
|
||||
};
|
||||
|
||||
export type V2ChunkData = {
|
||||
@@ -22,6 +22,6 @@ export type V2FileEntry = {
|
||||
permissions: number;
|
||||
};
|
||||
|
||||
export function castManifest(manifest: JsonValue): Manifest {
|
||||
return JSON.parse(manifest as string) as Manifest;
|
||||
export function castManifest(manifest: JsonValue): DropletManifest {
|
||||
return JSON.parse(manifest as string) as DropletManifest;
|
||||
}
|
||||
|
||||
100
server/internal/library/manifest/index.ts
Normal file
100
server/internal/library/manifest/index.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import prisma from "../../db/database";
|
||||
import { castManifest, type DropletManifest } from "../manifest";
|
||||
|
||||
export type DownloadManifestDetails = {
|
||||
manifests: { [key: string]: DropletManifest };
|
||||
fileList: { [key: string]: string };
|
||||
};
|
||||
|
||||
function convertMap<T>(map: Map<string, T>): { [key: string]: T } {
|
||||
return Object.fromEntries(map.entries().toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gameId Game ID
|
||||
* @param versionId Version ID
|
||||
*/
|
||||
export async function createDownloadManifestDetails(
|
||||
versionId: string,
|
||||
): Promise<DownloadManifestDetails> {
|
||||
const mainVersion = await prisma.gameVersion.findUnique({
|
||||
where: { versionId },
|
||||
select: {
|
||||
versionId: true,
|
||||
delta: true,
|
||||
versionIndex: true,
|
||||
fileList: true,
|
||||
negativeFileList: true,
|
||||
gameId: true,
|
||||
dropletManifest: true,
|
||||
},
|
||||
});
|
||||
if (!mainVersion)
|
||||
throw createError({ statusCode: 404, message: "Version not found" });
|
||||
|
||||
const collectedVersions = [];
|
||||
let versionIndex = mainVersion.versionIndex;
|
||||
while (true) {
|
||||
const nextVersion = await prisma.gameVersion.findFirst({
|
||||
where: { gameId: mainVersion.gameId, versionIndex: { lt: versionIndex } },
|
||||
orderBy: {
|
||||
versionIndex: "desc",
|
||||
},
|
||||
select: {
|
||||
versionId: true,
|
||||
versionIndex: true,
|
||||
delta: true,
|
||||
fileList: true,
|
||||
negativeFileList: true,
|
||||
dropletManifest: true,
|
||||
},
|
||||
});
|
||||
if (!nextVersion)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: "Delta version without version underneath it.",
|
||||
});
|
||||
|
||||
versionIndex = nextVersion.versionIndex;
|
||||
collectedVersions.push(nextVersion);
|
||||
if (!nextVersion.delta) break;
|
||||
}
|
||||
|
||||
collectedVersions.reverse();
|
||||
// Apply fileList in lowest priority to newest priority
|
||||
const versionOrder = [...collectedVersions, mainVersion];
|
||||
|
||||
const fileList = new Map<string, string>();
|
||||
for (const version of versionOrder) {
|
||||
for (const file of version.fileList) {
|
||||
fileList.set(file, version.versionId);
|
||||
}
|
||||
for (const negFile of version.negativeFileList) {
|
||||
fileList.delete(negFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we have our file list, filter the manifests
|
||||
const manifests = new Map<string, DropletManifest>();
|
||||
for (const version of versionOrder) {
|
||||
const files = fileList
|
||||
.entries()
|
||||
.filter(([, versionId]) => version.versionId === versionId)
|
||||
.toArray();
|
||||
if (files.length == 0) continue;
|
||||
const fileNames = Object.fromEntries(files);
|
||||
const manifest = castManifest(version.dropletManifest);
|
||||
const filteredChunks = Object.fromEntries(
|
||||
Object.entries(manifest.chunks).filter(([, chunkData]) =>
|
||||
chunkData.files.some((fileEntry) => !!fileNames[fileEntry.filename]),
|
||||
),
|
||||
);
|
||||
manifests.set(version.versionId, {
|
||||
...manifest,
|
||||
chunks: filteredChunks,
|
||||
});
|
||||
}
|
||||
|
||||
return { fileList: convertMap(fileList), manifests: convertMap(manifests) };
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Prisma } from "~/prisma/client/client";
|
||||
import type { GameType } from "~/prisma/client/enums";
|
||||
import { MetadataSource } from "~/prisma/client/enums";
|
||||
import prisma from "../db/database";
|
||||
import type {
|
||||
@@ -118,7 +119,11 @@ export class MetadataHandler {
|
||||
return successfulResults;
|
||||
}
|
||||
|
||||
async createGameWithoutMetadata(libraryId: string, libraryPath: string) {
|
||||
async createGameWithoutMetadata(
|
||||
libraryId: string,
|
||||
libraryPath: string,
|
||||
type: GameType,
|
||||
) {
|
||||
return await this.createGame(
|
||||
{
|
||||
id: "",
|
||||
@@ -127,6 +132,7 @@ export class MetadataHandler {
|
||||
},
|
||||
libraryId,
|
||||
libraryPath,
|
||||
type,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -174,6 +180,7 @@ export class MetadataHandler {
|
||||
result: { sourceId: string; id: string; name: string },
|
||||
libraryId: string,
|
||||
libraryPath: string,
|
||||
type: GameType,
|
||||
) {
|
||||
const provider = this.providers.get(result.sourceId);
|
||||
if (!provider)
|
||||
@@ -286,6 +293,8 @@ export class MetadataHandler {
|
||||
|
||||
libraryId,
|
||||
libraryPath,
|
||||
|
||||
type,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,33 @@ export type SystemData = {
|
||||
cpuCores: number;
|
||||
};
|
||||
|
||||
// See https://github.com/oscmejia/os-utils/blob/master/lib/osutils.js
|
||||
function getCPUInfo() {
|
||||
const cpus = os.cpus();
|
||||
|
||||
let user = 0;
|
||||
let nice = 0;
|
||||
let sys = 0;
|
||||
let idle = 0;
|
||||
let irq = 0;
|
||||
|
||||
for (const cpu in cpus) {
|
||||
if (!Object.prototype.hasOwnProperty.call(cpus, cpu)) continue;
|
||||
user += cpus[cpu].times.user;
|
||||
nice += cpus[cpu].times.nice;
|
||||
sys += cpus[cpu].times.sys;
|
||||
irq += cpus[cpu].times.irq;
|
||||
idle += cpus[cpu].times.idle;
|
||||
}
|
||||
|
||||
const total = user + nice + sys + idle + irq;
|
||||
|
||||
return {
|
||||
idle: idle,
|
||||
total: total,
|
||||
};
|
||||
}
|
||||
|
||||
class SystemManager {
|
||||
// userId to acl to listenerId
|
||||
private listeners = new Map<
|
||||
@@ -14,6 +41,20 @@ class SystemManager {
|
||||
Map<string, { callback: (systemData: SystemData) => void }>
|
||||
>();
|
||||
|
||||
private lastCPUUpdate: { idle: number; total: number } | undefined;
|
||||
|
||||
constructor() {
|
||||
setInterval(() => {
|
||||
const systemData = this.getSystemData();
|
||||
if (!systemData) return;
|
||||
for (const [, map] of this.listeners.entries()) {
|
||||
for (const [, { callback }] of map.entries()) {
|
||||
callback(systemData);
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
listen(
|
||||
userId: string,
|
||||
id: string,
|
||||
@@ -22,25 +63,17 @@ class SystemManager {
|
||||
if (!this.listeners.has(userId)) this.listeners.set(userId, new Map());
|
||||
// eslint-disable-next-line @typescript-eslint/no-extra-non-null-assertion
|
||||
this.listeners.get(userId)!!.set(id, { callback });
|
||||
this.pushUpdate(userId, id);
|
||||
setInterval(() => this.pushUpdate(userId, id), 3000);
|
||||
}
|
||||
|
||||
unlisten(userId: string, id: string) {
|
||||
this.listeners.get(userId)?.delete(id);
|
||||
}
|
||||
|
||||
private async pushUpdate(userId: string, id: string) {
|
||||
const listener = this.listeners.get(userId)?.get(id);
|
||||
if (!listener) {
|
||||
throw new Error("Failed to catch-up listener: callback does not exist");
|
||||
}
|
||||
listener.callback(this.getSystemData());
|
||||
}
|
||||
|
||||
getSystemData(): SystemData {
|
||||
getSystemData(): SystemData | undefined {
|
||||
const cpu = this.cpuLoad();
|
||||
if (!cpu) return undefined;
|
||||
return {
|
||||
cpuLoad: this.cpuLoad(),
|
||||
cpuLoad: cpu * 100,
|
||||
totalRam: os.totalmem(),
|
||||
freeRam: os.freemem(),
|
||||
cpuCores: os.cpus().length,
|
||||
@@ -48,9 +81,15 @@ class SystemManager {
|
||||
}
|
||||
|
||||
private cpuLoad() {
|
||||
const [oneMinLoad, _fiveMinLoad, _fiftenMinLoad] = os.loadavg();
|
||||
const numberCpus = os.cpus().length;
|
||||
return 100 - ((numberCpus - oneMinLoad) / numberCpus) * 100;
|
||||
const last = this.lastCPUUpdate;
|
||||
this.lastCPUUpdate = getCPUInfo();
|
||||
if (!last) return undefined;
|
||||
|
||||
const idle = this.lastCPUUpdate.idle - last.idle;
|
||||
const total = this.lastCPUUpdate.total - last.total;
|
||||
|
||||
const perc = idle / total;
|
||||
return 1 - perc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Submodule torrential updated: 57f0b9b548...0098bee3e0
Reference in New Issue
Block a user