mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
Store overhaul (#142)
* feat: small library tweaks + company page * feat: new store view * fix: ci merge error * feat: add genres to store page * feat: sorting * feat: lock game/version imports while their tasks are running * feat: feature games * feat: tag based filtering * fix: make tags alphabetical * refactor: move a bunch of i18n to common * feat: add localizations for everything * fix: title description on panel * fix: feature carousel text * fix: i18n footer strings * feat: add tag page * fix: develop merge * feat: offline games support (don't error out if provider throws) * feat: tag management * feat: show library next to game import + small fixes * feat: most of the company and tag managers * feat: company text field editing * fix: small fixes + tsgo experiemental * feat: upload icon and banner * feat: store infinite scrolling and bulk import mode * fix: lint * fix: add drop-base to prettier ignore
This commit is contained in:
51
server/api/v1/admin/company/[id]/banner.post.ts
Normal file
51
server/api/v1/admin/company/[id]/banner.post.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import objectHandler from "~/server/internal/objects";
|
||||
import { handleFileUpload } from "~/server/internal/utils/handlefileupload";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const companyId = getRouterParam(h3, "id")!;
|
||||
const company = await prisma.company.findUnique({
|
||||
where: {
|
||||
id: companyId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!company)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid company id" });
|
||||
|
||||
const result = await handleFileUpload(h3, {}, ["internal:read"], 1);
|
||||
if (!result)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "File upload required (multipart form)",
|
||||
});
|
||||
|
||||
const [ids, , pull, dump] = result;
|
||||
const id = ids.at(0);
|
||||
if (!id)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Upload at least one file.",
|
||||
});
|
||||
|
||||
try {
|
||||
await objectHandler.deleteAsSystem(company.mBannerObjectId);
|
||||
await prisma.company.update({
|
||||
where: {
|
||||
id: companyId,
|
||||
},
|
||||
data: {
|
||||
mBannerObjectId: id,
|
||||
},
|
||||
});
|
||||
await pull();
|
||||
} catch {
|
||||
await dump();
|
||||
}
|
||||
|
||||
return { id: id };
|
||||
});
|
||||
37
server/api/v1/admin/company/[id]/game.delete.ts
Normal file
37
server/api/v1/admin/company/[id]/game.delete.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
const GameDelete = type({
|
||||
id: "string",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const companyId = getRouterParam(h3, "id")!;
|
||||
|
||||
const body = await readDropValidatedBody(h3, GameDelete);
|
||||
|
||||
await prisma.game.update({
|
||||
where: {
|
||||
id: body.id,
|
||||
},
|
||||
data: {
|
||||
publishers: {
|
||||
disconnect: {
|
||||
id: companyId,
|
||||
},
|
||||
},
|
||||
developers: {
|
||||
disconnect: {
|
||||
id: companyId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
37
server/api/v1/admin/company/[id]/game.patch.ts
Normal file
37
server/api/v1/admin/company/[id]/game.patch.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
const GamePatch = type({
|
||||
action: "'developed' | 'published'",
|
||||
enabled: "boolean",
|
||||
id: "string",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const companyId = getRouterParam(h3, "id")!;
|
||||
|
||||
const body = await readDropValidatedBody(h3, GamePatch);
|
||||
|
||||
const action = body.action === "developed" ? "developers" : "publishers";
|
||||
const actionType = body.enabled ? "connect" : "disconnect";
|
||||
|
||||
await prisma.game.update({
|
||||
where: {
|
||||
id: body.id,
|
||||
},
|
||||
data: {
|
||||
[action]: {
|
||||
[actionType]: {
|
||||
id: companyId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
69
server/api/v1/admin/company/[id]/game.post.ts
Normal file
69
server/api/v1/admin/company/[id]/game.post.ts
Normal file
@ -0,0 +1,69 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
const GamePost = type({
|
||||
published: "boolean",
|
||||
developed: "boolean",
|
||||
id: "string",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const companyId = getRouterParam(h3, "id")!;
|
||||
|
||||
const body = await readDropValidatedBody(h3, GamePost);
|
||||
|
||||
if (!body.published && !body.developed)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Must be related (either developed or published).",
|
||||
});
|
||||
|
||||
const publisherConnect = body.published
|
||||
? {
|
||||
publishers: {
|
||||
connect: {
|
||||
id: companyId,
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const developerConnect = body.developed
|
||||
? {
|
||||
developers: {
|
||||
connect: {
|
||||
id: companyId,
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const game = await prisma.game.update({
|
||||
where: {
|
||||
id: body.id,
|
||||
},
|
||||
data: {
|
||||
...publisherConnect,
|
||||
...developerConnect,
|
||||
},
|
||||
include: {
|
||||
publishers: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
developers: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return game;
|
||||
});
|
||||
51
server/api/v1/admin/company/[id]/icon.post.ts
Normal file
51
server/api/v1/admin/company/[id]/icon.post.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import objectHandler from "~/server/internal/objects";
|
||||
import { handleFileUpload } from "~/server/internal/utils/handlefileupload";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const companyId = getRouterParam(h3, "id")!;
|
||||
const company = await prisma.company.findUnique({
|
||||
where: {
|
||||
id: companyId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!company)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid company id" });
|
||||
|
||||
const result = await handleFileUpload(h3, {}, ["internal:read"], 1);
|
||||
if (!result)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "File upload required (multipart form)",
|
||||
});
|
||||
|
||||
const [ids, , pull, dump] = result;
|
||||
const id = ids.at(0);
|
||||
if (!id)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Upload at least one file.",
|
||||
});
|
||||
|
||||
try {
|
||||
await objectHandler.deleteAsSystem(company.mLogoObjectId);
|
||||
await prisma.company.update({
|
||||
where: {
|
||||
id: companyId,
|
||||
},
|
||||
data: {
|
||||
mLogoObjectId: id,
|
||||
},
|
||||
});
|
||||
await pull();
|
||||
} catch {
|
||||
await dump();
|
||||
}
|
||||
|
||||
return { id: id };
|
||||
});
|
||||
14
server/api/v1/admin/company/[id]/index.delete.ts
Normal file
14
server/api/v1/admin/company/[id]/index.delete.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:delete"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
const company = await prisma.company.deleteMany({ where: { id } });
|
||||
if (company.count == 0)
|
||||
throw createError({ statusCode: 404, statusMessage: "Company not found" });
|
||||
return;
|
||||
});
|
||||
54
server/api/v1/admin/company/[id]/index.get.ts
Normal file
54
server/api/v1/admin/company/[id]/index.get.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
const company = await prisma.company.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
published: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
developed: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!company)
|
||||
throw createError({ statusCode: 404, statusMessage: "Company not found" });
|
||||
const games = await prisma.game.findMany({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
developers: {
|
||||
some: {
|
||||
id: company.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
publishers: {
|
||||
some: {
|
||||
id: company.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
distinct: ["id"],
|
||||
});
|
||||
const companyFlatten = {
|
||||
...company,
|
||||
developed: company.developed.map((e) => e.id),
|
||||
published: company.published.map((e) => e.id),
|
||||
};
|
||||
return { company: companyFlatten, games };
|
||||
});
|
||||
23
server/api/v1/admin/company/[id]/index.patch.ts
Normal file
23
server/api/v1/admin/company/[id]/index.patch.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const body = await readBody(h3);
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
const restOfTheBody = { ...body };
|
||||
delete restOfTheBody["id"];
|
||||
|
||||
const newObj = await prisma.company.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: restOfTheBody,
|
||||
// I would put a select here, but it would be based on the body, and muck up the types
|
||||
});
|
||||
|
||||
return newObj;
|
||||
});
|
||||
10
server/api/v1/admin/company/index.get.ts
Normal file
10
server/api/v1/admin/company/index.get.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["company:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const companies = await prisma.company.findMany({});
|
||||
return companies;
|
||||
});
|
||||
@ -1,17 +1,11 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler<{ query: { id: string } }>(async (h3) => {
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:delete"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const query = getQuery(h3);
|
||||
const gameId = query.id?.toString();
|
||||
if (!gameId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id in query",
|
||||
});
|
||||
const gameId = getRouterParam(h3, "id")!;
|
||||
|
||||
await prisma.game.delete({
|
||||
where: {
|
||||
40
server/api/v1/admin/game/[id]/index.get.ts
Normal file
40
server/api/v1/admin/game/[id]/index.get.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const gameId = getRouterParam(h3, "id")!;
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
where: {
|
||||
id: gameId,
|
||||
},
|
||||
include: {
|
||||
versions: {
|
||||
orderBy: {
|
||||
versionIndex: "asc",
|
||||
},
|
||||
select: {
|
||||
versionIndex: true,
|
||||
versionName: true,
|
||||
platform: true,
|
||||
delta: true,
|
||||
},
|
||||
},
|
||||
tags: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!game || !game.libraryId)
|
||||
throw createError({ statusCode: 404, statusMessage: "Game ID not found" });
|
||||
|
||||
const unimportedVersions = await libraryManager.fetchUnimportedGameVersions(
|
||||
game.libraryId,
|
||||
game.libraryPath,
|
||||
);
|
||||
|
||||
return { game, unimportedVersions };
|
||||
});
|
||||
@ -6,9 +6,7 @@ export default defineEventHandler(async (h3) => {
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const body = await readBody(h3);
|
||||
const id = body.id;
|
||||
if (!id)
|
||||
throw createError({ statusCode: 400, statusMessage: "Missing id in body" });
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
const restOfTheBody = { ...body };
|
||||
delete restOfTheBody["id"];
|
||||
@ -14,6 +14,8 @@ export default defineEventHandler(async (h3) => {
|
||||
statusMessage: "This endpoint requires multipart form data.",
|
||||
});
|
||||
|
||||
const gameId = getRouterParam(h3, "id")!;
|
||||
|
||||
const uploadResult = await handleFileUpload(h3, {}, ["internal:read"], 1);
|
||||
if (!uploadResult)
|
||||
throw createError({
|
||||
@ -28,7 +30,6 @@ export default defineEventHandler(async (h3) => {
|
||||
// handleFileUpload reads the rest of the options for us.
|
||||
const name = options.name;
|
||||
const description = options.description;
|
||||
const gameId = options.id;
|
||||
|
||||
const updateModel: Prisma.GameUpdateInput = {
|
||||
mName: name,
|
||||
29
server/api/v1/admin/game/[id]/tags.patch.ts
Normal file
29
server/api/v1/admin/game/[id]/tags.patch.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
const PatchTags = type({
|
||||
tags: "string[]",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:update"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const body = await readDropValidatedBody(h3, PatchTags);
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
await prisma.game.update({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
data: {
|
||||
tags: {
|
||||
connect: body.tags.map((e) => ({ id: e })),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
@ -1,45 +1,16 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const query = getQuery(h3);
|
||||
const gameId = query.id?.toString();
|
||||
if (!gameId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id in query",
|
||||
});
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
where: {
|
||||
id: gameId,
|
||||
},
|
||||
include: {
|
||||
versions: {
|
||||
orderBy: {
|
||||
versionIndex: "asc",
|
||||
},
|
||||
select: {
|
||||
versionIndex: true,
|
||||
versionName: true,
|
||||
platform: true,
|
||||
delta: true,
|
||||
},
|
||||
},
|
||||
return await prisma.game.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
mShortDescription: true,
|
||||
mIconObjectId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!game || !game.libraryId)
|
||||
throw createError({ statusCode: 404, statusMessage: "Game ID not found" });
|
||||
|
||||
const unimportedVersions = await libraryManager.fetchUnimportedGameVersions(
|
||||
game.libraryId,
|
||||
game.libraryPath,
|
||||
);
|
||||
|
||||
return { game, unimportedVersions };
|
||||
});
|
||||
|
||||
@ -5,10 +5,13 @@ export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["import:game:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const unimportedGames = await libraryManager.fetchAllUnimportedGames();
|
||||
const unimportedGames = await libraryManager.fetchUnimportedGames();
|
||||
const libraries = Object.fromEntries(
|
||||
(await libraryManager.fetchLibraries()).map((e) => [e.id, e]),
|
||||
);
|
||||
const iterableUnimportedGames = Object.entries(unimportedGames)
|
||||
.map(([libraryId, gameArray]) =>
|
||||
gameArray.map((e) => ({ game: e, library: libraryId })),
|
||||
gameArray.map((e) => ({ game: e, library: libraries[libraryId] })),
|
||||
)
|
||||
.flat();
|
||||
return { unimportedGames: iterableUnimportedGames };
|
||||
|
||||
@ -5,7 +5,7 @@ export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["library:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const unimportedGames = await libraryManager.fetchAllUnimportedGames();
|
||||
const unimportedGames = await libraryManager.fetchUnimportedGames();
|
||||
const games = await libraryManager.fetchGamesWithStatus();
|
||||
|
||||
// Fetch other library data here
|
||||
|
||||
14
server/api/v1/admin/tags/[id]/index.delete.ts
Normal file
14
server/api/v1/admin/tags/[id]/index.delete.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["tags:delete"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const id = getRouterParam(h3, "id")!;
|
||||
|
||||
const tag = await prisma.gameTag.deleteMany({ where: { id } });
|
||||
if (tag.count == 0)
|
||||
throw createError({ statusCode: 404, statusMessage: "Tag not found" });
|
||||
return;
|
||||
});
|
||||
10
server/api/v1/admin/tags/index.get.ts
Normal file
10
server/api/v1/admin/tags/index.get.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["tags:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const tags = await prisma.gameTag.findMany({ orderBy: { name: "asc" } });
|
||||
return tags;
|
||||
});
|
||||
22
server/api/v1/admin/tags/index.post.ts
Normal file
22
server/api/v1/admin/tags/index.post.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
const CreateTag = type({
|
||||
name: "string",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["tags:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const body = await readDropValidatedBody(h3, CreateTag);
|
||||
|
||||
const tag = await prisma.gameTag.create({
|
||||
data: {
|
||||
...body,
|
||||
},
|
||||
});
|
||||
return tag;
|
||||
});
|
||||
23
server/api/v1/companies/[id]/index.get.ts
Normal file
23
server/api/v1/companies/[id]/index.get.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserIdACL(h3, ["store:read"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const companyId = getRouterParam(h3, "id");
|
||||
if (!companyId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing gameId in route params (somehow...?)",
|
||||
});
|
||||
|
||||
const company = await prisma.company.findUnique({
|
||||
where: { id: companyId },
|
||||
});
|
||||
|
||||
if (!company)
|
||||
throw createError({ statusCode: 404, statusMessage: "Company not found" });
|
||||
|
||||
return { company };
|
||||
});
|
||||
@ -16,6 +16,23 @@ export default defineEventHandler(async (h3) => {
|
||||
where: { id: gameId },
|
||||
include: {
|
||||
versions: true,
|
||||
publishers: {
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
mShortDescription: true,
|
||||
mLogoObjectId: true,
|
||||
},
|
||||
},
|
||||
developers: {
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
mShortDescription: true,
|
||||
mLogoObjectId: true,
|
||||
},
|
||||
},
|
||||
tags: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -6,6 +6,9 @@ export default defineEventHandler(async (h3) => {
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const games = await prisma.game.findMany({
|
||||
where: {
|
||||
featured: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
mName: true,
|
||||
@ -28,7 +31,6 @@ export default defineEventHandler(async (h3) => {
|
||||
orderBy: {
|
||||
created: "desc",
|
||||
},
|
||||
take: 8,
|
||||
});
|
||||
|
||||
return games;
|
||||
122
server/api/v1/store/index.get.ts
Normal file
122
server/api/v1/store/index.get.ts
Normal file
@ -0,0 +1,122 @@
|
||||
import { ArkErrors, type } from "arktype";
|
||||
import type { Prisma } from "~/prisma/client/client";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { parsePlatform } from "~/server/internal/utils/parseplatform";
|
||||
|
||||
const StoreRead = type({
|
||||
skip: type("string")
|
||||
.pipe((s) => Number.parseInt(s))
|
||||
.default("0"),
|
||||
take: type("string")
|
||||
.pipe((s) => Number.parseInt(s))
|
||||
.default("10"),
|
||||
|
||||
tags: "string?",
|
||||
platform: "string?",
|
||||
|
||||
company: "string?",
|
||||
companyActions: "string = 'published,developed'",
|
||||
|
||||
sort: "'default' | 'newest' | 'recent' = 'default'",
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserIdACL(h3, ["store:read"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const query = getQuery(h3);
|
||||
const options = StoreRead(query);
|
||||
if (options instanceof ArkErrors)
|
||||
throw createError({ statusCode: 400, statusMessage: options.summary });
|
||||
|
||||
/**
|
||||
* Generic filters
|
||||
*/
|
||||
const tagFilter = options.tags
|
||||
? {
|
||||
tags: {
|
||||
some: {
|
||||
id: {
|
||||
in: options.tags.split(","),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const platformFilter = options.platform
|
||||
? {
|
||||
versions: {
|
||||
some: {
|
||||
platform: {
|
||||
in: options.platform
|
||||
.split(",")
|
||||
.map(parsePlatform)
|
||||
.filter((e) => e !== undefined),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
|
||||
/**
|
||||
* Company filtering
|
||||
*/
|
||||
const companyActions = options.companyActions.split(",");
|
||||
const developedFilter = companyActions.includes("developed")
|
||||
? {
|
||||
developers: {
|
||||
some: {
|
||||
id: options.company!,
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const publishedFilter = companyActions.includes("published")
|
||||
? {
|
||||
publishers: {
|
||||
some: {
|
||||
id: options.company!,
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const companyFilter = options.company
|
||||
? ({
|
||||
OR: [developedFilter, publishedFilter].filter((e) => e !== undefined),
|
||||
} satisfies Prisma.GameWhereInput)
|
||||
: undefined;
|
||||
|
||||
/**
|
||||
* Query
|
||||
*/
|
||||
|
||||
const finalFilter: Prisma.GameWhereInput = {
|
||||
...tagFilter,
|
||||
...platformFilter,
|
||||
...companyFilter,
|
||||
};
|
||||
|
||||
const sort: Prisma.GameOrderByWithRelationInput = {};
|
||||
switch (options.sort) {
|
||||
case "default":
|
||||
case "newest":
|
||||
sort.mReleased = "desc";
|
||||
break;
|
||||
case "recent":
|
||||
sort.created = "desc";
|
||||
break;
|
||||
}
|
||||
|
||||
const [results, count] = await prisma.$transaction([
|
||||
prisma.game.findMany({
|
||||
skip: options.skip,
|
||||
take: Math.min(options.take, 50),
|
||||
where: finalFilter,
|
||||
orderBy: sort,
|
||||
}),
|
||||
prisma.game.count({ where: finalFilter }),
|
||||
]);
|
||||
|
||||
return { results, count };
|
||||
});
|
||||
@ -2,15 +2,9 @@ import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserACL(h3, ["store:read"]);
|
||||
const userId = await aclManager.getUserIdACL(h3, ["store:read"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const games = await prisma.game.findMany({
|
||||
orderBy: {
|
||||
mReleased: "desc",
|
||||
},
|
||||
take: 12,
|
||||
});
|
||||
|
||||
return games;
|
||||
const tags = await prisma.gameTag.findMany({ orderBy: { name: "asc" } });
|
||||
return tags;
|
||||
});
|
||||
@ -1,28 +0,0 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserACL(h3, ["store:read"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const versions = await prisma.gameVersion.findMany({
|
||||
where: {
|
||||
versionIndex: {
|
||||
gte: 1,
|
||||
},
|
||||
},
|
||||
select: {
|
||||
game: true,
|
||||
},
|
||||
orderBy: {
|
||||
created: "desc",
|
||||
},
|
||||
take: 12,
|
||||
});
|
||||
|
||||
const games = versions
|
||||
.map((e) => e.game)
|
||||
.filter((v, i, a) => a.findIndex((e) => e.id === v.id) === i);
|
||||
|
||||
return games;
|
||||
});
|
||||
23
server/api/v1/tags/[id]/index.get.ts
Normal file
23
server/api/v1/tags/[id]/index.get.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserIdACL(h3, ["store:read"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const tagId = getRouterParam(h3, "id");
|
||||
if (!tagId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing gameId in route params (somehow...?)",
|
||||
});
|
||||
|
||||
const tag = await prisma.gameTag.findUnique({
|
||||
where: { id: tagId },
|
||||
});
|
||||
|
||||
if (!tag)
|
||||
throw createError({ statusCode: 404, statusMessage: "Tag not found" });
|
||||
|
||||
return { tag };
|
||||
});
|
||||
@ -70,6 +70,11 @@ export const systemACLDescriptions: ObjectFromList<typeof systemACLs> = {
|
||||
"game:image:new": "Upload an image for a game.",
|
||||
"game:image:delete": "Delete an image for a game.",
|
||||
|
||||
"company:read": "Fetch companies.",
|
||||
"company:create": "Create a new company.",
|
||||
"company:update": "Update existing companies.",
|
||||
"company:delete": "Delete companies.",
|
||||
|
||||
"import:version:read":
|
||||
"Fetch versions to be imported, and information about versions to be imported.",
|
||||
"import:version:new": "Import a game version.",
|
||||
@ -77,6 +82,10 @@ export const systemACLDescriptions: ObjectFromList<typeof systemACLs> = {
|
||||
"Fetch games to be imported, and search the metadata for games.",
|
||||
"import:game:new": "Import a game.",
|
||||
|
||||
"tags:read": "Fetch all tags",
|
||||
"tags:create": "Create a tag",
|
||||
"tags:delete": "Delete a tag",
|
||||
|
||||
"user:read": "Fetch any user's information.",
|
||||
"user:delete": "Delete a user.",
|
||||
|
||||
|
||||
@ -65,6 +65,11 @@ export const systemACLs = [
|
||||
"game:image:new",
|
||||
"game:image:delete",
|
||||
|
||||
"company:read",
|
||||
"company:update",
|
||||
"company:create",
|
||||
"company:delete",
|
||||
|
||||
"import:version:read",
|
||||
"import:version:new",
|
||||
|
||||
@ -78,6 +83,10 @@ export const systemACLs = [
|
||||
"news:create",
|
||||
"news:delete",
|
||||
|
||||
"tags:read",
|
||||
"tags:create",
|
||||
"tags:delete",
|
||||
|
||||
"task:read",
|
||||
"task:start",
|
||||
|
||||
|
||||
@ -11,11 +11,15 @@ import { fuzzy } from "fast-fuzzy";
|
||||
import taskHandler from "../tasks";
|
||||
import { parsePlatform } from "../utils/parseplatform";
|
||||
import notificationSystem from "../notifications";
|
||||
import type { LibraryProvider } from "./provider";
|
||||
import { GameNotFoundError, type LibraryProvider } from "./provider";
|
||||
import { logger } from "../logging";
|
||||
|
||||
class LibraryManager {
|
||||
private libraries: Map<string, LibraryProvider<unknown>> = new Map();
|
||||
|
||||
private gameImportLocks: Map<string, Array<string>> = new Map(); // Library ID to Library Path
|
||||
private versionImportLocks: Map<string, Array<string>> = new Map(); // Game ID to Version Name
|
||||
|
||||
addLibrary(library: LibraryProvider<unknown>) {
|
||||
this.libraries.set(library.id(), library);
|
||||
}
|
||||
@ -33,7 +37,7 @@ class LibraryManager {
|
||||
return libraryWithMetadata;
|
||||
}
|
||||
|
||||
async fetchAllUnimportedGames() {
|
||||
async fetchUnimportedGames() {
|
||||
const unimportedGames: { [key: string]: string[] } = {};
|
||||
|
||||
for (const [id, library] of this.libraries.entries()) {
|
||||
@ -48,7 +52,9 @@ class LibraryManager {
|
||||
},
|
||||
});
|
||||
const providerUnimportedGames = games.filter(
|
||||
(e) => validGames.findIndex((v) => v.libraryPath == e) == -1,
|
||||
(e) =>
|
||||
validGames.findIndex((v) => v.libraryPath == e) == -1 &&
|
||||
!(this.gameImportLocks.get(id) ?? []).includes(e),
|
||||
);
|
||||
unimportedGames[id] = providerUnimportedGames;
|
||||
}
|
||||
@ -67,30 +73,34 @@ class LibraryManager {
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
versions: true,
|
||||
},
|
||||
});
|
||||
if (!game) return undefined;
|
||||
|
||||
const versions = await provider.listVersions(libraryPath);
|
||||
const unimportedVersions = versions.filter(
|
||||
(e) => game.versions.findIndex((v) => v.versionName == e) == -1,
|
||||
);
|
||||
|
||||
return unimportedVersions;
|
||||
try {
|
||||
const versions = await provider.listVersions(libraryPath);
|
||||
const unimportedVersions = versions.filter(
|
||||
(e) =>
|
||||
game.versions.findIndex((v) => v.versionName == e) == -1 &&
|
||||
!(this.versionImportLocks.get(game.id) ?? []).includes(e),
|
||||
);
|
||||
return unimportedVersions;
|
||||
} catch (e) {
|
||||
if (e instanceof GameNotFoundError) {
|
||||
logger.warn(e);
|
||||
return undefined;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
async fetchGamesWithStatus() {
|
||||
const games = await prisma.game.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
include: {
|
||||
versions: true,
|
||||
mName: true,
|
||||
mShortDescription: true,
|
||||
metadataSource: true,
|
||||
mIconObjectId: true,
|
||||
libraryId: true,
|
||||
libraryPath: true,
|
||||
library: true,
|
||||
},
|
||||
orderBy: {
|
||||
mName: "asc",
|
||||
@ -98,19 +108,30 @@ class LibraryManager {
|
||||
});
|
||||
|
||||
return await Promise.all(
|
||||
games.map(async (e) => ({
|
||||
game: e,
|
||||
status: {
|
||||
noVersions: e.versions.length == 0,
|
||||
unimportedVersions: (await this.fetchUnimportedGameVersions(
|
||||
e.libraryId ?? "",
|
||||
e.libraryPath,
|
||||
))!,
|
||||
},
|
||||
})),
|
||||
games.map(async (e) => {
|
||||
const versions = await this.fetchUnimportedGameVersions(
|
||||
e.libraryId ?? "",
|
||||
e.libraryPath,
|
||||
);
|
||||
return {
|
||||
game: e,
|
||||
status: versions
|
||||
? {
|
||||
noVersions: e.versions.length == 0,
|
||||
unimportedVersions: versions,
|
||||
}
|
||||
: ("offline" as const),
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches recommendations and extra data about the version. Doesn't actually check if it's been imported.
|
||||
* @param gameId
|
||||
* @param versionName
|
||||
* @returns
|
||||
*/
|
||||
async fetchUnimportedVersionInformation(gameId: string, versionName: string) {
|
||||
const game = await prisma.game.findUnique({
|
||||
where: { id: gameId },
|
||||
@ -130,10 +151,7 @@ class LibraryManager {
|
||||
// No extension is common for Linux binaries
|
||||
"",
|
||||
],
|
||||
Windows: [
|
||||
// Pretty much the only one
|
||||
".exe",
|
||||
],
|
||||
Windows: [".exe", ".bat"],
|
||||
macOS: [
|
||||
// App files
|
||||
".app",
|
||||
@ -188,6 +206,70 @@ class LibraryManager {
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Locks the game so you can't be imported
|
||||
* @param libraryId
|
||||
* @param libraryPath
|
||||
*/
|
||||
async lockGame(libraryId: string, libraryPath: string) {
|
||||
let games = this.gameImportLocks.get(libraryId);
|
||||
if (!games) this.gameImportLocks.set(libraryId, (games = []));
|
||||
|
||||
if (!games.includes(libraryPath)) games.push(libraryPath);
|
||||
|
||||
this.gameImportLocks.set(libraryId, games);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks the game, call once imported
|
||||
* @param libraryId
|
||||
* @param libraryPath
|
||||
*/
|
||||
async unlockGame(libraryId: string, libraryPath: string) {
|
||||
let games = this.gameImportLocks.get(libraryId);
|
||||
if (!games) this.gameImportLocks.set(libraryId, (games = []));
|
||||
|
||||
if (games.includes(libraryPath))
|
||||
games.splice(
|
||||
games.findIndex((e) => e === libraryPath),
|
||||
1,
|
||||
);
|
||||
|
||||
this.gameImportLocks.set(libraryId, games);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks a version so it can't be imported
|
||||
* @param gameId
|
||||
* @param versionName
|
||||
*/
|
||||
async lockVersion(gameId: string, versionName: string) {
|
||||
let versions = this.versionImportLocks.get(gameId);
|
||||
if (!versions) this.versionImportLocks.set(gameId, (versions = []));
|
||||
|
||||
if (!versions.includes(versionName)) versions.push(versionName);
|
||||
|
||||
this.versionImportLocks.set(gameId, versions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks the version, call once imported
|
||||
* @param libraryId
|
||||
* @param libraryPath
|
||||
*/
|
||||
async unlockVersion(gameId: string, versionName: string) {
|
||||
let versions = this.versionImportLocks.get(gameId);
|
||||
if (!versions) this.versionImportLocks.set(gameId, (versions = []));
|
||||
|
||||
if (versions.includes(gameId))
|
||||
versions.splice(
|
||||
versions.findIndex((e) => e === versionName),
|
||||
1,
|
||||
);
|
||||
|
||||
this.versionImportLocks.set(gameId, versions);
|
||||
}
|
||||
|
||||
async importVersion(
|
||||
gameId: string,
|
||||
versionName: string,
|
||||
@ -218,6 +300,8 @@ class LibraryManager {
|
||||
const library = this.libraries.get(game.libraryId);
|
||||
if (!library) return undefined;
|
||||
|
||||
await this.lockVersion(gameId, versionName);
|
||||
|
||||
taskHandler.create({
|
||||
id: taskId,
|
||||
taskGroup: "import:game",
|
||||
@ -294,6 +378,9 @@ class LibraryManager {
|
||||
|
||||
progress(100);
|
||||
},
|
||||
async finally() {
|
||||
await libraryManager.unlockVersion(gameId, versionName);
|
||||
},
|
||||
});
|
||||
|
||||
return taskId;
|
||||
|
||||
@ -65,6 +65,11 @@ interface GameResult {
|
||||
reviews?: Array<{
|
||||
api_detail_url: string;
|
||||
}>;
|
||||
|
||||
genres?: Array<{
|
||||
name: string;
|
||||
id: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface ReviewResult {
|
||||
@ -189,7 +194,7 @@ export class GiantBombProvider implements MetadataProvider {
|
||||
context?.logger.warn(`Failed to import publisher "${pub}"`);
|
||||
continue;
|
||||
}
|
||||
context?.logger.info(`Imported publisher "${pub}"`);
|
||||
context?.logger.info(`Imported publisher "${pub.name}"`);
|
||||
publishers.push(res);
|
||||
}
|
||||
}
|
||||
@ -224,11 +229,7 @@ export class GiantBombProvider implements MetadataProvider {
|
||||
|
||||
const releaseDate = gameData.original_release_date
|
||||
? DateTime.fromISO(gameData.original_release_date).toJSDate()
|
||||
: DateTime.fromISO(
|
||||
`${gameData.expected_release_year ?? new Date().getFullYear()}-${
|
||||
gameData.expected_release_month ?? 1
|
||||
}-${gameData.expected_release_day ?? 1}`,
|
||||
).toJSDate();
|
||||
: new Date();
|
||||
|
||||
context?.progress(85);
|
||||
|
||||
@ -249,6 +250,8 @@ export class GiantBombProvider implements MetadataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
const tags = (gameData.genres ?? []).map((e) => e.name);
|
||||
|
||||
const metadata: GameMetadata = {
|
||||
id: gameData.guid,
|
||||
name: gameData.name,
|
||||
@ -256,7 +259,7 @@ export class GiantBombProvider implements MetadataProvider {
|
||||
description: longDescription,
|
||||
released: releaseDate,
|
||||
|
||||
tags: [],
|
||||
tags,
|
||||
|
||||
reviews,
|
||||
|
||||
|
||||
@ -450,7 +450,7 @@ export class IGDBProvider implements MetadataProvider {
|
||||
mReviewHref: currentGame.url,
|
||||
};
|
||||
|
||||
const tags = await this.getGenres(currentGame.genres);
|
||||
const genres = await this.getGenres(currentGame.genres);
|
||||
|
||||
const deck = this.trimMessage(currentGame.summary, 280);
|
||||
|
||||
@ -461,12 +461,13 @@ export class IGDBProvider implements MetadataProvider {
|
||||
description: currentGame.summary,
|
||||
released,
|
||||
|
||||
genres,
|
||||
reviews: [review],
|
||||
|
||||
publishers,
|
||||
developers,
|
||||
|
||||
tags,
|
||||
tags: [],
|
||||
|
||||
icon,
|
||||
bannerId: banner,
|
||||
|
||||
@ -18,6 +18,8 @@ import taskHandler, { wrapTaskContext } from "../tasks";
|
||||
import { randomUUID } from "crypto";
|
||||
import { fuzzy } from "fast-fuzzy";
|
||||
import { logger } from "~/server/internal/logging";
|
||||
import libraryManager from "../library";
|
||||
import type { GameTagModel } from "~/prisma/client/models";
|
||||
|
||||
export class MissingMetadataProviderConfig extends Error {
|
||||
private providerName: string;
|
||||
@ -124,19 +126,22 @@ export class MetadataHandler {
|
||||
);
|
||||
}
|
||||
|
||||
private parseTags(tags: string[]) {
|
||||
const results: Array<Prisma.TagCreateOrConnectWithoutGamesInput> = [];
|
||||
private async parseTags(tags: string[]) {
|
||||
const results: Array<GameTagModel> = [];
|
||||
|
||||
tags.forEach((t) =>
|
||||
results.push({
|
||||
where: {
|
||||
name: t,
|
||||
},
|
||||
create: {
|
||||
name: t,
|
||||
},
|
||||
}),
|
||||
);
|
||||
for (const tag of tags) {
|
||||
const rawResults: GameTagModel[] =
|
||||
await prisma.$queryRaw`SELECT * FROM "GameTag" WHERE SIMILARITY(name, ${tag}) > 0.45;`;
|
||||
let resultTag = rawResults.at(0);
|
||||
if (!resultTag) {
|
||||
resultTag = await prisma.gameTag.create({
|
||||
data: {
|
||||
name: tag,
|
||||
},
|
||||
});
|
||||
}
|
||||
results.push(resultTag);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
@ -180,6 +185,8 @@ export class MetadataHandler {
|
||||
});
|
||||
if (existing) return undefined;
|
||||
|
||||
await libraryManager.lockGame(libraryId, libraryPath);
|
||||
|
||||
const gameId = randomUUID();
|
||||
|
||||
const taskId = `import:${gameId}`;
|
||||
@ -262,7 +269,7 @@ export class MetadataHandler {
|
||||
connectOrCreate: metadataHandler.parseRatings(metadata.reviews),
|
||||
},
|
||||
tags: {
|
||||
connectOrCreate: metadataHandler.parseTags(metadata.tags),
|
||||
connect: await metadataHandler.parseTags(metadata.tags),
|
||||
},
|
||||
|
||||
libraryId,
|
||||
@ -271,6 +278,10 @@ export class MetadataHandler {
|
||||
});
|
||||
|
||||
logger.info(`Finished game import.`);
|
||||
progress(100);
|
||||
},
|
||||
async finally() {
|
||||
await libraryManager.unlockGame(libraryId, libraryPath);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -206,6 +206,8 @@ class TaskHandler {
|
||||
};
|
||||
}
|
||||
|
||||
if (task.finally) await task.finally();
|
||||
|
||||
taskEntry.endTime = new Date().toISOString();
|
||||
await updateAllClients();
|
||||
|
||||
@ -427,6 +429,7 @@ export interface Task {
|
||||
taskGroup: TaskGroup;
|
||||
name: string;
|
||||
run: (context: TaskRunContext) => Promise<void>;
|
||||
finally?: () => Promise<void> | void;
|
||||
acls: GlobalACL[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user