Files
linux-odyssey/packages/game/schema/command.ts
T
Justin Lin f0a09ac4d9 Feat filegraph (#194)
* feat: update filegraph on touch command

* feat: update filegraph on mkdir

* feat: add different parsing opts for each command

* refactor: replace axios with fetch. put handleCommand to a new file

* feat: add config for mounting cli in dev stage

* refactor: clean up unused validators

* feat: add command handler for copy files. reuse resolvePath function

* feat: add rm handler, support specific files deletion. Glob not supported yet

* feat: handle discover cases that the folder is actually empty

* feat: handle discover empty folder better and support rmdir

* feat: handle mv command

* refactor: remove unused console logs
2025-04-29 20:40:02 +08:00

28 lines
714 B
TypeScript

import { z } from 'zod'
const fileSchema = z.object({
path: z.string(),
type: z.enum(['file', 'directory']),
discovered: z.boolean(),
empty: z.boolean().optional(),
})
export const commandParamsSchema = z.object({
discover: fileSchema.array().optional(),
add: fileSchema.array().optional(),
remove: fileSchema.array().optional(),
pwd: z.string().optional(),
})
export type ICommandParams = z.infer<typeof commandParamsSchema>
export const commandSchema = z.object({
command: z.string().optional(),
output: z.string().optional(),
error: z.string().optional(),
pwd: z.string().optional(),
params: commandParamsSchema.optional(),
})
export type ICommand = z.infer<typeof commandSchema>