feat(core): scaffold account manager platform
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const isoDateTimeSchema = z.iso.datetime({ offset: true });
|
||||
const minecraftUuidSchema = z
|
||||
.string()
|
||||
.regex(/^[0-9a-f]{32}$/i, "Expected a compact Java Edition UUID");
|
||||
const minecraftUsernameSchema = z
|
||||
.string()
|
||||
.regex(/^[A-Za-z0-9_]{3,16}$/, "Expected a valid Java Edition username");
|
||||
|
||||
export const cloudEventSchema = z.object({
|
||||
id: z.uuid(),
|
||||
specversion: z.literal("1.0"),
|
||||
source: z.string().startsWith("/"),
|
||||
type: z.string().min(1),
|
||||
subject: z.string().min(1).optional(),
|
||||
time: isoDateTimeSchema,
|
||||
datacontenttype: z.literal("application/json").default("application/json"),
|
||||
dataschema: z.url().optional(),
|
||||
data: z.record(z.string(), z.unknown()),
|
||||
});
|
||||
|
||||
export type CloudEvent = z.infer<typeof cloudEventSchema>;
|
||||
|
||||
export const velocityAccessRequestSchema = z.object({
|
||||
requestId: z.uuid(),
|
||||
serverId: z.string().min(1).max(100),
|
||||
minecraftUuid: minecraftUuidSchema,
|
||||
username: minecraftUsernameSchema,
|
||||
ipAddress: z.union([z.ipv4(), z.ipv6()]),
|
||||
occurredAt: isoDateTimeSchema,
|
||||
});
|
||||
|
||||
export type VelocityAccessRequest = z.infer<typeof velocityAccessRequestSchema>;
|
||||
|
||||
export const velocityAccessResponseSchema = z.discriminatedUnion("allowed", [
|
||||
z.object({
|
||||
allowed: z.literal(true),
|
||||
message: z.string().min(1).optional(),
|
||||
}),
|
||||
z.object({
|
||||
allowed: z.literal(false),
|
||||
message: z.string().min(1),
|
||||
}),
|
||||
]);
|
||||
|
||||
export type VelocityAccessResponse = z.infer<typeof velocityAccessResponseSchema>;
|
||||
Reference in New Issue
Block a user