(value: unknown)
| 16325 | } |
| 16326 | |
| 16327 | function parseAutomationJobPatch(value: unknown): AutomationJobPatch { |
| 16328 | const parsed = value && typeof value === 'object' && !Array.isArray(value) |
| 16329 | ? value as Record<string, any> |
| 16330 | : {}; |
| 16331 | const patch: AutomationJobPatch = {}; |
| 16332 | const title = compactWhitespace(parsed.title ?? ''); |
| 16333 | if (title) { |
| 16334 | patch.title = title; |
| 16335 | } |
| 16336 | const prompt = compactWhitespace(parsed.task ?? parsed.prompt ?? ''); |
| 16337 | if (prompt) { |
| 16338 | patch.prompt = prompt; |
| 16339 | } |
| 16340 | const modeValue = compactWhitespace(parsed.mode).toLowerCase(); |
| 16341 | if (modeValue === 'standalone' || modeValue === 'thread') { |
| 16342 | patch.mode = modeValue; |
| 16343 | } |
| 16344 | const schedules = normalizeAutomationSchedules(parsed); |
| 16345 | if (schedules.length > 0) { |
| 16346 | patch.schedule = schedules[0]; |
| 16347 | } |
| 16348 | return patch; |
| 16349 | } |
| 16350 | |
| 16351 | function parseAutomationDraftCandidate(text: string): AutomationDraftCandidate | null { |
| 16352 | const payload = extractFirstJsonObject(text); |
no test coverage detected