feat: Implemented launching and downloading of roms

This is just an initial implementation lots of kings to iron out
This commit is contained in:
Simeon Radivoev 2026-02-19 16:10:29 +02:00
parent ef08fa6114
commit f15bf9a1e0
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
117 changed files with 37776 additions and 1073 deletions

54
src/bun/api/schema/app.ts Normal file
View file

@ -0,0 +1,54 @@
import { sql } from "drizzle-orm";
import { integer, text, sqliteTable, blob } from "drizzle-orm/sqlite-core";
export const games = sqliteTable('games', {
id: integer('id').primaryKey({ autoIncrement: true }),
source_id: integer('source_id').unique(),
source: text("source"),
igdb_id: integer("igdb_id").unique(),
name: text("name"),
ra_id: integer('ra_id').unique(),
path_fs: text("path_fs"),
last_played: integer("last_played", { mode: 'timestamp' }),
created_at: integer("created_at", { mode: 'timestamp' }).default(sql`(unixepoch())`).notNull(),
metadata: text("metadata", { mode: 'json' }).default(sql`'{}'`),
slug: text("slug").unique(),
platform_id: integer("platform_id").references(() => platforms.id, { onUpdate: 'cascade' }).notNull(),
cover: blob("cover", { mode: 'buffer' }),
cover_type: text('type'),
summary: text("summary")
});
export const platforms = sqliteTable('platforms', {
id: integer("id").primaryKey({ autoIncrement: true }),
igdb_id: integer("igdb_id").unique(),
igdb_slug: text("igdb_slug").unique(),
moby_id: integer("moby_id").unique(),
name: text("name").notNull(),
es_slug: text('es_slug').unique(),
ra_id: integer('ra_id').unique(),
created_at: integer("created_at", { mode: 'timestamp' }).default(sql`(unixepoch())`).notNull(),
slug: text("slug").unique().notNull(),
metadata: text("metadata", { mode: 'json' }),
cover: blob("cover", { mode: 'buffer' }),
cover_type: text('type'),
family_name: text("family_name")
});
export const collections_games = sqliteTable('collections_games', {
collection_id: integer('collection_id').notNull().references(() => collections.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
game_id: integer('game_id').notNull().references(() => games.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
created_at: integer("created_at", { mode: 'timestamp' }).default(sql`(unixepoch())`).notNull(),
});
export const collections = sqliteTable('collections', {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text('name')
});
export const screenshots = sqliteTable('screenshots', {
id: integer("id").primaryKey({ autoIncrement: true }),
game_id: integer('game_id').references(() => games.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
content: blob('content', { mode: 'buffer' }).notNull(),
type: text('type')
});

View file

@ -0,0 +1,43 @@
import { relations, sql } from "drizzle-orm";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const emulators = sqliteTable('emulators', {
name: text().primaryKey().unique(),
systempath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
staticpath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
corepath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
androidpackage: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
winregistrypath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
});
export const systems = sqliteTable('systems', {
name: text().primaryKey().unique(),
fullname: text(),
path: text(),
extension: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`)
});
export const systemsRelations = relations(systems, ({ many }) =>
({
commands: many(commands)
}));
export const systemMappings = sqliteTable('systemMappings', {
source: text(),
sourceSlug: text(),
sourceId: integer(),
system: text().notNull().references(() => systems.name)
});
export const commands = sqliteTable('commands', {
system: text().references(() => systems.name, { onDelete: 'cascade', onUpdate: 'cascade' }),
label: text(),
command: text().notNull()
});
export const commandsRelations = relations(commands, ({ one }) => ({
author: one(systems, {
fields: [commands.system],
references: [systems.name],
}),
}));