feat: add shared dashboard API contracts
This commit is contained in:
1 parent
939cf408a0
commit
59c3a61a88
14 files changed
+648
No files matched your search
@@ -0,0 +1,34 @@
|
||||
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>;
|
||||
Reference in new issue
Block a user