(message: WebviewMessage)
| 143 | } |
| 144 | |
| 145 | function parseDeleteRuleInput(message: WebviewMessage): DeleteRuleInput { |
| 146 | const values = message.values ?? {} |
| 147 | const scope = parseRuleScope(values.scope) |
| 148 | const kind = parseRuleKind(values.kind) |
| 149 | const relativePath = values.relativePath ?? message.text |
| 150 | |
| 151 | if (!scope || !kind || !relativePath) { |
| 152 | throw new Error("Missing required fields: scope, kind, or relativePath") |
| 153 | } |
| 154 | |
| 155 | return { |
| 156 | id: typeof values.id === "string" ? values.id : undefined, |
| 157 | scope, |
| 158 | kind, |
| 159 | modeSlug: typeof values.modeSlug === "string" ? values.modeSlug : undefined, |
| 160 | relativePath, |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | function parseRuleScope(value: unknown): RuleScope | undefined { |
| 165 | return value === "global" || value === "project" ? value : undefined |
no test coverage detected