| author | |
| committer | |
| log | 31aa32b83bb234ef7f2bdad6a898d06ea1d0552e |
| tree | a565c4f86750a68f09637d5662566e49dc03da8b |
| parent | 53c367420cac82f7c5baba55bad29432f77a9633 |
- add `packages/contracts/src/keybindings.ts` with keybinding schemas and types
- import keybindings config schema from `server.ts`
- re-export keybindings contracts from `packages/contracts/src/index.ts`3 files changed, 24 insertions(+), 20 deletions(-)
packages/contracts/src/index.ts+1| ... | ... | @@ -5,6 +5,7 @@ export * from "./terminal"; |
| 5 | 5 | export * from "./provider"; |
| 6 | 6 | export * from "./model"; |
| 7 | 7 | export * from "./ws"; |
| 8 | export * from "./keybindings"; | |
| 8 | 9 | export * from "./server"; |
| 9 | 10 | export * from "./project"; |
| 10 | 11 | export * from "./git"; |
packages/contracts/src/keybindings.ts created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | import { z } from "zod"; | |
| 2 | ||
| 3 | export const keybindingCommandSchema = z.enum([ | |
| 4 | "terminal.toggle", | |
| 5 | "terminal.split", | |
| 6 | "terminal.new", | |
| 7 | ]); | |
| 8 | ||
| 9 | const keybindingValueSchema = z.string().trim().min(1).max(64); | |
| 10 | const keybindingWhenSchema = z.string().trim().min(1).max(256); | |
| 11 | ||
| 12 | export const keybindingRuleSchema = z.object({ | |
| 13 | key: keybindingValueSchema, | |
| 14 | command: keybindingCommandSchema, | |
| 15 | when: keybindingWhenSchema.optional(), | |
| 16 | }); | |
| 17 | ||
| 18 | export const keybindingsConfigSchema = z.array(keybindingRuleSchema).max(256); | |
| 19 | ||
| 20 | export type KeybindingCommand = z.infer<typeof keybindingCommandSchema>; | |
| 21 | export type KeybindingRule = z.infer<typeof keybindingRuleSchema>; | |
| 22 | export type KeybindingsConfig = z.infer<typeof keybindingsConfigSchema>; |
packages/contracts/src/server.ts+1-20| ... | ... | @@ -1,28 +1,9 @@ |
| 1 | 1 | import { z } from "zod"; |
| 2 | ||
| 3 | export const keybindingCommandSchema = z.enum([ | |
| 4 | "terminal.toggle", | |
| 5 | "terminal.split", | |
| 6 | "terminal.new", | |
| 7 | ]); | |
| 8 | ||
| 9 | const keybindingValueSchema = z.string().trim().min(1).max(64); | |
| 10 | const keybindingWhenSchema = z.string().trim().min(1).max(256); | |
| 11 | ||
| 12 | export const keybindingRuleSchema = z.object({ | |
| 13 | key: keybindingValueSchema, | |
| 14 | command: keybindingCommandSchema, | |
| 15 | when: keybindingWhenSchema.optional(), | |
| 16 | }); | |
| 17 | ||
| 18 | export const keybindingsConfigSchema = z.array(keybindingRuleSchema).max(256); | |
| 2 | import { keybindingsConfigSchema } from "./keybindings"; | |
| 19 | 3 | |
| 20 | 4 | export const serverConfigSchema = z.object({ |
| 21 | 5 | cwd: z.string().min(1), |
| 22 | 6 | keybindings: keybindingsConfigSchema.default([]), |
| 23 | 7 | }); |
| 24 | 8 | |
| 25 | export type KeybindingCommand = z.infer<typeof keybindingCommandSchema>; | |
| 26 | export type KeybindingRule = z.infer<typeof keybindingRuleSchema>; | |
| 27 | export type KeybindingsConfig = z.infer<typeof keybindingsConfigSchema>; | |
| 28 | 9 | export type ServerConfig = z.infer<typeof serverConfigSchema>; |