35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export const RedditSessionStateSchema = z.union([
|
|
z.literal('unknown'),
|
|
z.literal('authenticated'),
|
|
z.literal('login-required'),
|
|
z.literal('unreachable'),
|
|
]);
|
|
export const LoginInfoResponseSchema = z.strictObject({
|
|
vncEnabled: z.boolean(),
|
|
novncPort: z.number(),
|
|
publicUrl: z.string().nullable(),
|
|
passwordRequired: z.boolean(),
|
|
});
|
|
export const LoginStatusResponseSchema = z.union([
|
|
z.strictObject({ ready: z.literal(false), error: z.string() }),
|
|
z.strictObject({
|
|
ready: z.literal(true),
|
|
loggedIn: z.boolean(),
|
|
status: RedditSessionStateSchema,
|
|
}),
|
|
z.strictObject({
|
|
ready: z.literal(true),
|
|
loggedIn: z.literal(false),
|
|
error: z.string(),
|
|
}),
|
|
]);
|
|
export const LoginStartResponseSchema = z.union([
|
|
z.strictObject({ ok: z.literal(true) }),
|
|
z.strictObject({ ok: z.literal(false), error: z.string() }),
|
|
]);
|
|
|
|
export type RedditSessionState = z.infer<typeof RedditSessionStateSchema>;
|
|
export type LoginStatusResponse = z.infer<typeof LoginStatusResponseSchema>;
|