Updates and more
This commit is contained in:
34
src/components/types/data.ts
Normal file
34
src/components/types/data.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import {z} from "zod";
|
||||
|
||||
export const SchematicTypeSchema = z.object({
|
||||
name: z.string(),
|
||||
db: z.string(),
|
||||
})
|
||||
|
||||
export type SchematicType = z.infer<typeof SchematicTypeSchema>;
|
||||
|
||||
export const PlayerSchema = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
uuid: z.string(),
|
||||
prefix: z.string(),
|
||||
perms: z.array(z.string()),
|
||||
})
|
||||
|
||||
export type Player = z.infer<typeof PlayerSchema>;
|
||||
|
||||
export const ServerSchema = z.object({
|
||||
description: z.any(),
|
||||
players: z.object({
|
||||
online: z.number(),
|
||||
max: z.number(),
|
||||
sample: z.array(z.any()).optional()
|
||||
}),
|
||||
version: z.object({
|
||||
name: z.string(),
|
||||
protocol: z.number()
|
||||
}),
|
||||
favicon: z.string().optional()
|
||||
})
|
||||
|
||||
export type Server = z.infer<typeof ServerSchema>;
|
||||
46
src/components/types/event.ts
Normal file
46
src/components/types/event.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type {Team} from "./team.js";
|
||||
import type {Player} from "./data.js";
|
||||
import {z} from "zod";
|
||||
import {TeamSchema} from "./team.js";
|
||||
import {PlayerSchema} from "./data.js";
|
||||
|
||||
export const ShortEventSchema = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
start: z.number(),
|
||||
end: z.number(),
|
||||
})
|
||||
|
||||
export type ShortEvent = z.infer<typeof ShortEventSchema>;
|
||||
|
||||
export const SWEventSchema = ShortEventSchema.extend({
|
||||
deadline: z.number(),
|
||||
maxTeamMembers: z.number(),
|
||||
schemType: z.string().nullable(),
|
||||
publicSchemsOnly: z.boolean(),
|
||||
spectateSystem: z.boolean(),
|
||||
})
|
||||
|
||||
export type SWEvent = z.infer<typeof SWEventSchema>;
|
||||
|
||||
export const EventFightSchema = z.object({
|
||||
id: z.number(),
|
||||
spielmodus: z.string(),
|
||||
map: z.string(),
|
||||
blueTeam: TeamSchema,
|
||||
redTeam: TeamSchema,
|
||||
kampfleiter: PlayerSchema.nullable(),
|
||||
start: z.number(),
|
||||
ergebnis: z.number(),
|
||||
group: z.string().nullable(),
|
||||
})
|
||||
|
||||
export type EventFight = z.infer<typeof EventFightSchema>;
|
||||
|
||||
export const ExtendedEventSchema = z.object({
|
||||
event: SWEventSchema,
|
||||
teams: z.array(TeamSchema),
|
||||
fights: z.array(EventFightSchema),
|
||||
})
|
||||
|
||||
export type ExtendedEvent = z.infer<typeof ExtendedEventSchema>;
|
||||
32
src/components/types/page.ts
Normal file
32
src/components/types/page.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {z} from "zod";
|
||||
|
||||
export const ListPageSchema = z.object({
|
||||
path: z.string(),
|
||||
name: z.string(),
|
||||
sha: z.string(),
|
||||
downloadUrl: z.string().url(),
|
||||
id: z.number().positive()
|
||||
});
|
||||
|
||||
export type ListPage = z.infer<typeof ListPageSchema>;
|
||||
|
||||
export const PageListSchema = z.array(ListPageSchema)
|
||||
|
||||
export type PageList = z.infer<typeof PageListSchema>;
|
||||
|
||||
export const PageSchema = z.object({
|
||||
path: z.string(),
|
||||
name: z.string(),
|
||||
sha: z.string(),
|
||||
downloadUrl: z.string().url(),
|
||||
content: z.string(),
|
||||
size: z.number().gte(0),
|
||||
id: z.number().positive()
|
||||
})
|
||||
|
||||
export type Page = z.infer<typeof PageSchema>;
|
||||
|
||||
export type Pages = {
|
||||
dirs: {[key: string]: Pages},
|
||||
files: {[key: string]: ListPage}
|
||||
}
|
||||
23
src/components/types/perms.ts
Normal file
23
src/components/types/perms.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {z} from "zod";
|
||||
|
||||
export const PrefixSchema = z.object({
|
||||
name: z.string().startsWith("PREFIX_"),
|
||||
colorCode: z.string().length(2).startsWith("§"),
|
||||
chatPrefix: z.string()
|
||||
})
|
||||
|
||||
export type Prefix = z.infer<typeof PrefixSchema>;
|
||||
|
||||
export const PermsSchema = z.object({
|
||||
perms: z.array(z.string()),
|
||||
prefixes: z.record(PrefixSchema),
|
||||
})
|
||||
|
||||
export type Perms = z.infer<typeof PermsSchema>;
|
||||
|
||||
export const UserPermsSchema = z.object({
|
||||
prefix: PrefixSchema,
|
||||
perms: z.array(z.string()),
|
||||
})
|
||||
|
||||
export type UserPerms = z.infer<typeof UserPermsSchema>;
|
||||
35
src/components/types/schem.ts
Normal file
35
src/components/types/schem.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {z} from "zod";
|
||||
import {PlayerSchema} from "./data.ts";
|
||||
|
||||
export const SchematicSchema = z.object({
|
||||
name: z.string(),
|
||||
id: z.number(),
|
||||
type: z.string().nullable(),
|
||||
owner: z.number(),
|
||||
item: z.string(),
|
||||
lastUpdate: z.number().positive(),
|
||||
rank: z.number(),
|
||||
replaceColor: z.boolean(),
|
||||
allowReplay: z.boolean()
|
||||
})
|
||||
|
||||
export type Schematic = z.infer<typeof SchematicSchema>
|
||||
|
||||
export const SchematicListSchema = z.object({
|
||||
breadcrumbs: z.array(z.object({
|
||||
name: z.string(),
|
||||
id: z.number()
|
||||
})),
|
||||
schematics: z.array(SchematicSchema),
|
||||
players: z.record(z.string(), PlayerSchema)
|
||||
})
|
||||
|
||||
export type SchematicList = z.infer<typeof SchematicListSchema>
|
||||
|
||||
export const SchematicInfoSchema = z.object({
|
||||
members: z.array(PlayerSchema),
|
||||
path: z.string(),
|
||||
schem: SchematicSchema
|
||||
})
|
||||
|
||||
export type SchematicInfo = z.infer<typeof SchematicInfoSchema>
|
||||
12
src/components/types/team.ts
Normal file
12
src/components/types/team.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {z} from "zod";
|
||||
|
||||
export const TeamSchema = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
kuerzel: z.string().min(1).max(4),
|
||||
color: z.string().max(1),
|
||||
})
|
||||
|
||||
export type Team = z.infer<typeof TeamSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user