mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-10-31 02:27:11 -04:00 
			
		
		
		
	Format code
This commit is contained in:
		
							parent
							
								
									02d1197f6b
								
							
						
					
					
						commit
						a8fb84daf0
					
				| @ -6,8 +6,8 @@ export const base = new Elysia({ name: "base" }) | ||||
| 		if (code === "VALIDATION") { | ||||
| 			const details = JSON.parse(error.message); | ||||
| 			if (details.code === "KError") { | ||||
| 				delete details.code; | ||||
| 				return details; | ||||
| 				const { code, ...ret } = details; | ||||
| 				return ret; | ||||
| 			} | ||||
| 			return { | ||||
| 				status: error.status, | ||||
|  | ||||
| @ -1,15 +1,13 @@ | ||||
| import { and, eq, exists, SQL, sql } from "drizzle-orm"; | ||||
| import { type SQL, and, eq, exists, sql } from "drizzle-orm"; | ||||
| import { Elysia, t } from "elysia"; | ||||
| import { KError } from "~/models/error"; | ||||
| import { comment } from "~/utils"; | ||||
| import { db } from "../db"; | ||||
| import { | ||||
| 	entries, | ||||
| 	entryVideoJointure as entryVideoJoint, | ||||
| 	shows, | ||||
| 	showTranslations, | ||||
| 	shows, | ||||
| } from "~/db/schema"; | ||||
| import { getColumns, sqlarr } from "~/db/schema/utils"; | ||||
| import { KError } from "~/models/error"; | ||||
| import { bubble } from "~/models/examples"; | ||||
| import { | ||||
| 	FullMovie, | ||||
| @ -19,16 +17,18 @@ import { | ||||
| } from "~/models/movie"; | ||||
| import { | ||||
| 	Filter, | ||||
| 	type Image, | ||||
| 	Sort, | ||||
| 	type FilterDef, | ||||
| 	Genre, | ||||
| 	type Image, | ||||
| 	Page, | ||||
| 	Sort, | ||||
| 	createPage, | ||||
| 	isUuid, | ||||
| 	keysetPaginate, | ||||
| 	Page, | ||||
| 	processLanguages, | ||||
| 	createPage, | ||||
| } from "~/models/utils"; | ||||
| import { comment } from "~/utils"; | ||||
| import { db } from "../db"; | ||||
| 
 | ||||
| const movieFilters: FilterDef = { | ||||
| 	genres: { | ||||
|  | ||||
| @ -1,10 +1,10 @@ | ||||
| import Elysia from "elysia"; | ||||
| import { Value } from "@sinclair/typebox/value"; | ||||
| import Elysia from "elysia"; | ||||
| import { KError } from "~/models/error"; | ||||
| import { Movie, SeedMovie } from "~/models/movie"; | ||||
| import { seedMovie, SeedMovieResponse } from "./movies"; | ||||
| import { Resource } from "~/models/utils"; | ||||
| import { comment } from "~/utils"; | ||||
| import { KError } from "~/models/error"; | ||||
| import { SeedMovieResponse, seedMovie } from "./movies"; | ||||
| 
 | ||||
| export const seed = new Elysia() | ||||
| 	.model({ | ||||
|  | ||||
| @ -1,19 +1,19 @@ | ||||
| import { inArray, sql, eq } from "drizzle-orm"; | ||||
| import { eq, inArray, sql } from "drizzle-orm"; | ||||
| import { t } from "elysia"; | ||||
| import { db } from "~/db"; | ||||
| import { | ||||
| 	entries, | ||||
| 	entryTranslations, | ||||
| 	entryVideoJointure as evj, | ||||
| 	shows, | ||||
| 	showTranslations, | ||||
| 	shows, | ||||
| 	videos, | ||||
| } from "~/db/schema"; | ||||
| import { conflictUpdateAllExcept } from "~/db/schema/utils"; | ||||
| import { KErrorT } from "~/models/error"; | ||||
| import type { SeedMovie } from "~/models/movie"; | ||||
| import { processOptImage } from "./images"; | ||||
| import { guessNextRefresh } from "./refresh"; | ||||
| import { KErrorT } from "~/models/error"; | ||||
| 
 | ||||
| type Show = typeof shows.$inferInsert; | ||||
| type ShowTrans = typeof showTranslations.$inferInsert; | ||||
|  | ||||
| @ -1,9 +1,9 @@ | ||||
| import { Elysia, t } from "elysia"; | ||||
| import { SeedVideo, Video } from "~/models/video"; | ||||
| import { db } from "~/db"; | ||||
| import { videos as videosT } from "~/db/schema"; | ||||
| import { comment } from "~/utils"; | ||||
| import { bubbleVideo } from "~/models/examples"; | ||||
| import { SeedVideo, Video } from "~/models/video"; | ||||
| import { comment } from "~/utils"; | ||||
| 
 | ||||
| const CreatedVideo = t.Object({ | ||||
| 	id: t.String({ format: "uuid" }), | ||||
|  | ||||
| @ -12,8 +12,8 @@ import { | ||||
| 	uuid, | ||||
| 	varchar, | ||||
| } from "drizzle-orm/pg-core"; | ||||
| import { image, language, schema } from "./utils"; | ||||
| import { shows } from "./shows"; | ||||
| import { image, language, schema } from "./utils"; | ||||
| 
 | ||||
| export const entryType = schema.enum("entry_type", [ | ||||
| 	"unknown", | ||||
|  | ||||
| @ -9,8 +9,8 @@ import { | ||||
| 	uuid, | ||||
| 	varchar, | ||||
| } from "drizzle-orm/pg-core"; | ||||
| import { image, language, schema } from "./utils"; | ||||
| import { shows } from "./shows"; | ||||
| import { image, language, schema } from "./utils"; | ||||
| 
 | ||||
| export const season_extid = () => | ||||
| 	jsonb() | ||||
|  | ||||
| @ -1,14 +1,15 @@ | ||||
| import { | ||||
| 	is, | ||||
| 	type ColumnsSelection, | ||||
| 	type SQL, | ||||
| 	type Subquery, | ||||
| 	Table, | ||||
| 	View, | ||||
| 	ViewBaseConfig, | ||||
| 	getTableColumns, | ||||
| 	is, | ||||
| 	sql, | ||||
| 	SQL, | ||||
| } from "drizzle-orm"; | ||||
| import type { CasingCache } from "drizzle-orm/casing"; | ||||
| import type { AnyMySqlSelect } from "drizzle-orm/mysql-core"; | ||||
| import { | ||||
| 	type AnyPgSelect, | ||||
| @ -19,7 +20,6 @@ import { | ||||
| import type { AnySQLiteSelect } from "drizzle-orm/sqlite-core"; | ||||
| import type { WithSubquery } from "drizzle-orm/subquery"; | ||||
| import { db } from ".."; | ||||
| import type { CasingCache } from "drizzle-orm/casing"; | ||||
| 
 | ||||
| export const schema = pgSchema("kyoo"); | ||||
| 
 | ||||
|  | ||||
| @ -3,14 +3,14 @@ import { | ||||
| 	check, | ||||
| 	integer, | ||||
| 	jsonb, | ||||
| 	primaryKey, | ||||
| 	text, | ||||
| 	timestamp, | ||||
| 	uuid, | ||||
| 	varchar, | ||||
| 	primaryKey, | ||||
| } from "drizzle-orm/pg-core"; | ||||
| import { schema } from "./utils"; | ||||
| import { entries } from "./entries"; | ||||
| import { schema } from "./utils"; | ||||
| 
 | ||||
| export const videos = schema.table( | ||||
| 	"videos", | ||||
|  | ||||
| @ -2,6 +2,7 @@ import jwt from "@elysiajs/jwt"; | ||||
| import { swagger } from "@elysiajs/swagger"; | ||||
| import { migrate } from "drizzle-orm/node-postgres/migrator"; | ||||
| import { Elysia } from "elysia"; | ||||
| import { base } from "./base"; | ||||
| import { entries } from "./controllers/entries"; | ||||
| import { movies } from "./controllers/movies"; | ||||
| import { seasons } from "./controllers/seasons"; | ||||
| @ -11,7 +12,6 @@ import { videos } from "./controllers/videos"; | ||||
| import { db } from "./db"; | ||||
| import { Image } from "./models/utils"; | ||||
| import { comment } from "./utils"; | ||||
| import { base } from "./base"; | ||||
| 
 | ||||
| await migrate(db, { migrationsSchema: "kyoo", migrationsFolder: "./drizzle" }); | ||||
| 
 | ||||
|  | ||||
| @ -17,7 +17,6 @@ export const EntryTranslation = t.Object({ | ||||
| 	description: t.Nullable(t.String()), | ||||
| }); | ||||
| 
 | ||||
| 
 | ||||
| // export const SeedEntry = t.Intersect([
 | ||||
| // 	Entry,
 | ||||
| // 	t.Object({ videos: t.Optional(t.Array(Video)) }),
 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| import { t } from "elysia"; | ||||
| import { BaseEntry, EntryTranslation } from "./base-entry"; | ||||
| import { EpisodeId } from "../utils/external-id"; | ||||
| import { Resource } from "../utils/resource"; | ||||
| import { BaseEntry, EntryTranslation } from "./base-entry"; | ||||
| 
 | ||||
| export const BaseEpisode = t.Intersect([ | ||||
| 	BaseEntry, | ||||
|  | ||||
| @ -1,8 +1,8 @@ | ||||
| import { t } from "elysia"; | ||||
| import { BaseEntry, EntryTranslation } from "./base-entry"; | ||||
| import { EpisodeId } from "../utils/external-id"; | ||||
| import { comment } from "../../utils"; | ||||
| import { EpisodeId } from "../utils/external-id"; | ||||
| import { Resource } from "../utils/resource"; | ||||
| import { BaseEntry, EntryTranslation } from "./base-entry"; | ||||
| 
 | ||||
| export const ExtraType = t.UnionEnum([ | ||||
| 	"other", | ||||
| @ -33,5 +33,3 @@ export const BaseExtra = t.Intersect( | ||||
| 
 | ||||
| export const Extra = t.Intersect([Resource, BaseExtra, EntryTranslation]); | ||||
| export type Extra = typeof Extra.static; | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -1,9 +1,9 @@ | ||||
| import type { TSchema } from "elysia"; | ||||
| import { KindGuard } from "@sinclair/typebox"; | ||||
| import type { TSchema } from "elysia"; | ||||
| 
 | ||||
| export const registerExamples = <T extends TSchema>( | ||||
| 	schema: T, | ||||
| 	...examples: (Partial<T["static"] >| undefined)[] | ||||
| 	...examples: (Partial<T["static"]> | undefined)[] | ||||
| ) => { | ||||
| 	if (KindGuard.IsUnion(schema)) { | ||||
| 		for (const union of schema.anyOf) { | ||||
|  | ||||
| @ -1,4 +1,6 @@ | ||||
| import { t } from "elysia"; | ||||
| import { bubble, registerExamples } from "./examples"; | ||||
| import { bubbleImages } from "./examples/bubble"; | ||||
| import { | ||||
| 	ExternalId, | ||||
| 	Genre, | ||||
| @ -7,8 +9,6 @@ import { | ||||
| 	SeedImage, | ||||
| 	TranslationRecord, | ||||
| } from "./utils"; | ||||
| import { bubble, registerExamples } from "./examples"; | ||||
| import { bubbleImages } from "./examples/bubble"; | ||||
| import { Video } from "./video"; | ||||
| 
 | ||||
| export const MovieStatus = t.UnionEnum(["unknown", "finished", "planned"]); | ||||
|  | ||||
| @ -1,8 +1,8 @@ | ||||
| import { t } from "elysia"; | ||||
| import { Image } from "./utils/image"; | ||||
| import { SeasonId } from "./utils/external-id"; | ||||
| import { Resource } from "./utils/resource"; | ||||
| import { Image } from "./utils/image"; | ||||
| import { Language } from "./utils/language"; | ||||
| import { Resource } from "./utils/resource"; | ||||
| 
 | ||||
| export const BaseSeason = t.Object({ | ||||
| 	seasonNumber: t.Number({ minimum: 1 }), | ||||
|  | ||||
| @ -1,11 +1,11 @@ | ||||
| import { t } from "elysia"; | ||||
| import { madeInAbyss, registerExamples } from "./examples"; | ||||
| import { SeedSeason } from "./season"; | ||||
| import { ExternalId } from "./utils/external-id"; | ||||
| import { Genre } from "./utils/genres"; | ||||
| import { Image } from "./utils/image"; | ||||
| import { ExternalId } from "./utils/external-id"; | ||||
| import { madeInAbyss, registerExamples } from "./examples"; | ||||
| import { Resource } from "./utils/resource"; | ||||
| import { Language } from "./utils/language"; | ||||
| import { SeedSeason } from "./season"; | ||||
| import { Resource } from "./utils/resource"; | ||||
| 
 | ||||
| export const SerieStatus = t.UnionEnum([ | ||||
| 	"unknown", | ||||
|  | ||||
| @ -1,9 +1,9 @@ | ||||
| import type { Column } from "drizzle-orm"; | ||||
| import { t } from "elysia"; | ||||
| import { KErrorT } from "~/models/error"; | ||||
| import { comment } from "~/utils"; | ||||
| import { expression } from "./parser"; | ||||
| import { toDrizzle } from "./to-sql"; | ||||
| import { KErrorT } from "~/models/error"; | ||||
| 
 | ||||
| export type FilterDef = { | ||||
| 	[key: string]: | ||||
|  | ||||
| @ -1,26 +1,26 @@ | ||||
| import { | ||||
| 	type Parjser, | ||||
| 	anyStringOf, | ||||
| 	digit, | ||||
| 	float, | ||||
| 	int, | ||||
| 	letter, | ||||
| 	noCharOf, | ||||
| 	type Parjser, | ||||
| 	string, | ||||
| } from "parjs"; | ||||
| import { | ||||
| 	between, | ||||
| 	exactly, | ||||
| 	later, | ||||
| 	many, | ||||
| 	many1, | ||||
| 	map, | ||||
| 	or, | ||||
| 	qthen, | ||||
| 	recover, | ||||
| 	stringify, | ||||
| 	then, | ||||
| 	thenq, | ||||
| 	qthen, | ||||
| 	later, | ||||
| 	between, | ||||
| 	recover, | ||||
| } from "parjs/combinators"; | ||||
| 
 | ||||
| export type Property = string; | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { | ||||
| 	type SQL, | ||||
| 	and, | ||||
| 	eq, | ||||
| 	gt, | ||||
| @ -8,13 +9,12 @@ import { | ||||
| 	ne, | ||||
| 	not, | ||||
| 	or, | ||||
| 	type SQL, | ||||
| 	sql, | ||||
| } from "drizzle-orm"; | ||||
| import { KErrorT } from "~/models/error"; | ||||
| import { comment } from "~/utils"; | ||||
| import type { FilterDef } from "./index"; | ||||
| import type { Expression, Operator } from "./parser"; | ||||
| import { KErrorT } from "~/models/error"; | ||||
| 
 | ||||
| const opMap: Record<Operator, typeof eq> = { | ||||
| 	eq: eq, | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| import { type Column, and, eq, gt, isNull, lt, or, sql } from "drizzle-orm"; | ||||
| import type { NonEmptyArray, Sort } from "./sort"; | ||||
| import { eq, or, type Column, and, gt, lt, isNull, sql } from "drizzle-orm"; | ||||
| 
 | ||||
| type Table<Name extends string> = Record<Name, Column>; | ||||
| 
 | ||||
|  | ||||
| @ -1,8 +1,8 @@ | ||||
| import { | ||||
| 	FormatRegistry, | ||||
| 	StaticDecode, | ||||
| 	TSchema, | ||||
| 	TString, | ||||
| 	type StaticDecode, | ||||
| 	type TSchema, | ||||
| 	type TString, | ||||
| } from "@sinclair/typebox"; | ||||
| import { t } from "elysia"; | ||||
| import { comment } from "../../utils"; | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| import type { ObjectOptions } from "@sinclair/typebox"; | ||||
| import { t, type TSchema } from "elysia"; | ||||
| import type { Sort } from "./sort"; | ||||
| import { type TSchema, t } from "elysia"; | ||||
| import { generateAfter } from "./keyset-paginate"; | ||||
| import type { Sort } from "./sort"; | ||||
| 
 | ||||
| export const Page = <T extends TSchema>(schema: T, options?: ObjectOptions) => | ||||
| 	t.Object( | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| import { t } from "elysia"; | ||||
| import { comment } from "../utils"; | ||||
| import { registerExamples, bubbleVideo  } from "./examples"; | ||||
| import { bubbleVideo, registerExamples } from "./examples"; | ||||
| 
 | ||||
| export const Video = t.Object({ | ||||
| 	id: t.String({ format: "uuid" }), | ||||
|  | ||||
| @ -1,12 +1,12 @@ | ||||
| import { afterAll, beforeAll, describe, expect, it } from "bun:test"; | ||||
| import { eq } from "drizzle-orm"; | ||||
| import { expectStatus } from "tests/utils"; | ||||
| import { seedMovie } from "~/controllers/seed/movies"; | ||||
| import { db } from "~/db"; | ||||
| import { shows } from "~/db/schema"; | ||||
| import { bubble } from "~/models/examples"; | ||||
| import { dune1984 } from "~/models/examples/dune-1984"; | ||||
| import { dune } from "~/models/examples/dune-2021"; | ||||
| import { eq } from "drizzle-orm"; | ||||
| import { expectStatus } from "tests/utils"; | ||||
| import { createMovie, getMovies, movieApp } from "./movies-helper"; | ||||
| 
 | ||||
| beforeAll(async () => { | ||||
|  | ||||
| @ -6,9 +6,9 @@ import { shows } from "~/db/schema"; | ||||
| import { bubble } from "~/models/examples"; | ||||
| import { dune1984 } from "~/models/examples/dune-1984"; | ||||
| import { dune } from "~/models/examples/dune-2021"; | ||||
| import { getMovie, getMovies, movieApp } from "./movies-helper"; | ||||
| import type { Movie } from "~/models/movie"; | ||||
| import { isUuid } from "~/models/utils"; | ||||
| import { getMovie, getMovies, movieApp } from "./movies-helper"; | ||||
| 
 | ||||
| beforeAll(async () => { | ||||
| 	await db.delete(shows); | ||||
|  | ||||
| @ -1,8 +1,8 @@ | ||||
| import { beforeAll, describe, expect, it } from "bun:test"; | ||||
| import { expectStatus } from "tests/utils"; | ||||
| import { seedMovie } from "~/controllers/seed/movies"; | ||||
| import { bubble } from "~/models/examples"; | ||||
| import { getMovie } from "./movies-helper"; | ||||
| import { expectStatus } from "tests/utils"; | ||||
| 
 | ||||
| let bubbleId = ""; | ||||
| 
 | ||||
|  | ||||
| @ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it, test } from "bun:test"; | ||||
| import { eq } from "drizzle-orm"; | ||||
| import { expectStatus } from "tests/utils"; | ||||
| import { db } from "~/db"; | ||||
| import { shows, showTranslations, videos } from "~/db/schema"; | ||||
| import { showTranslations, shows, videos } from "~/db/schema"; | ||||
| import { bubble } from "~/models/examples"; | ||||
| import { dune, duneVideo } from "~/models/examples/dune-2021"; | ||||
| import { createMovie } from "./movies-helper"; | ||||
|  | ||||
| @ -3,9 +3,7 @@ | ||||
| 		"target": "ES2021", | ||||
| 		"module": "ES2022", | ||||
| 		"moduleResolution": "node", | ||||
| 		"types": [ | ||||
| 			"bun-types" | ||||
| 		], | ||||
| 		"types": ["bun-types"], | ||||
| 		"esModuleInterop": true, | ||||
| 		"forceConsistentCasingInFileNames": true, | ||||
| 		"strict": true, | ||||
| @ -13,9 +11,7 @@ | ||||
| 		"noErrorTruncation": true, | ||||
| 		"baseUrl": ".", | ||||
| 		"paths": { | ||||
| 			"~/*": [ | ||||
| 				"./src/*" | ||||
| 			] | ||||
| 			"~/*": ["./src/*"] | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user