feat: import of custom platforms & file extensions

This commit is contained in:
DecDuck
2025-09-06 18:29:04 +10:00
parent 7266d0485b
commit fcfc30e5df
36 changed files with 13182 additions and 271 deletions

View File

@ -0,0 +1,47 @@
import { Platform, type HardwarePlatform } from "~/prisma/client/enums";
import prisma from "../db/database";
import type { PlatformLink } from "~/prisma/client/client";
export async function convertIDsToPlatforms(platformIDs: string[]) {
const userPlatforms = await prisma.userPlatform.findMany({
where: {
id: {
in: platformIDs,
},
},
});
const platforms = platformIDs.map(
(e) => userPlatforms.find((v) => v.id === e) ?? (e as HardwarePlatform),
);
return platforms;
}
export async function convertIDToLink(
id: string,
): Promise<PlatformLink | undefined> {
const link = await prisma.platformLink.findUnique({
where: { id },
});
if (link) return link;
if (Platform[id as Platform]) {
return await prisma.platformLink.create({
data: {
id,
},
});
}
const userPlatform = await prisma.userPlatform.findUnique({
where: { id },
});
if (!userPlatform) return undefined;
return await prisma.platformLink.create({
data: {
id,
},
});
}