|
| 1 | +import { z } from "zod"; |
| 2 | + |
| 3 | +export const taskContextMenuInput = z.object({ |
| 4 | + taskTitle: z.string(), |
| 5 | + worktreePath: z.string().optional(), |
| 6 | +}); |
| 7 | + |
| 8 | +export const folderContextMenuInput = z.object({ |
| 9 | + folderName: z.string(), |
| 10 | + folderPath: z.string().optional(), |
| 11 | +}); |
| 12 | + |
| 13 | +export const tabContextMenuInput = z.object({ |
| 14 | + canClose: z.boolean(), |
| 15 | + filePath: z.string().optional(), |
| 16 | +}); |
| 17 | + |
| 18 | +export const fileContextMenuInput = z.object({ |
| 19 | + filePath: z.string(), |
| 20 | + showCollapseAll: z.boolean().optional(), |
| 21 | +}); |
| 22 | + |
| 23 | +const externalAppAction = z.discriminatedUnion("type", [ |
| 24 | + z.object({ type: z.literal("open-in-app"), appId: z.string() }), |
| 25 | + z.object({ type: z.literal("copy-path") }), |
| 26 | +]); |
| 27 | + |
| 28 | +const taskAction = z.discriminatedUnion("type", [ |
| 29 | + z.object({ type: z.literal("rename") }), |
| 30 | + z.object({ type: z.literal("duplicate") }), |
| 31 | + z.object({ type: z.literal("delete") }), |
| 32 | + z.object({ type: z.literal("external-app"), action: externalAppAction }), |
| 33 | +]); |
| 34 | + |
| 35 | +const folderAction = z.discriminatedUnion("type", [ |
| 36 | + z.object({ type: z.literal("remove") }), |
| 37 | + z.object({ type: z.literal("external-app"), action: externalAppAction }), |
| 38 | +]); |
| 39 | + |
| 40 | +const tabAction = z.discriminatedUnion("type", [ |
| 41 | + z.object({ type: z.literal("close") }), |
| 42 | + z.object({ type: z.literal("close-others") }), |
| 43 | + z.object({ type: z.literal("close-right") }), |
| 44 | + z.object({ type: z.literal("external-app"), action: externalAppAction }), |
| 45 | +]); |
| 46 | + |
| 47 | +const fileAction = z.discriminatedUnion("type", [ |
| 48 | + z.object({ type: z.literal("collapse-all") }), |
| 49 | + z.object({ type: z.literal("external-app"), action: externalAppAction }), |
| 50 | +]); |
| 51 | + |
| 52 | +const splitDirection = z.enum(["left", "right", "up", "down"]); |
| 53 | + |
| 54 | +export const taskContextMenuOutput = z.object({ |
| 55 | + action: taskAction.nullable(), |
| 56 | +}); |
| 57 | +export const folderContextMenuOutput = z.object({ |
| 58 | + action: folderAction.nullable(), |
| 59 | +}); |
| 60 | +export const tabContextMenuOutput = z.object({ action: tabAction.nullable() }); |
| 61 | +export const fileContextMenuOutput = z.object({ |
| 62 | + action: fileAction.nullable(), |
| 63 | +}); |
| 64 | +export const splitContextMenuOutput = z.object({ |
| 65 | + direction: splitDirection.nullable(), |
| 66 | +}); |
| 67 | + |
| 68 | +export type TaskContextMenuInput = z.infer<typeof taskContextMenuInput>; |
| 69 | +export type FolderContextMenuInput = z.infer<typeof folderContextMenuInput>; |
| 70 | +export type TabContextMenuInput = z.infer<typeof tabContextMenuInput>; |
| 71 | +export type FileContextMenuInput = z.infer<typeof fileContextMenuInput>; |
| 72 | + |
| 73 | +export type ExternalAppAction = z.infer<typeof externalAppAction>; |
| 74 | +export type TaskAction = z.infer<typeof taskAction>; |
| 75 | +export type FolderAction = z.infer<typeof folderAction>; |
| 76 | +export type TabAction = z.infer<typeof tabAction>; |
| 77 | +export type FileAction = z.infer<typeof fileAction>; |
| 78 | +export type SplitDirection = z.infer<typeof splitDirection>; |
| 79 | + |
| 80 | +export type TaskContextMenuResult = z.infer<typeof taskContextMenuOutput>; |
| 81 | +export type FolderContextMenuResult = z.infer<typeof folderContextMenuOutput>; |
| 82 | +export type TabContextMenuResult = z.infer<typeof tabContextMenuOutput>; |
| 83 | +export type FileContextMenuResult = z.infer<typeof fileContextMenuOutput>; |
| 84 | +export type SplitContextMenuResult = z.infer<typeof splitContextMenuOutput>; |
0 commit comments