mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 14:22:09 +03:00
`kieExecutor.createTask()` returns `JsonObject` (`Record<string, unknown>`), so `createData.data` is `unknown` and the `createData?.data?.taskId` read that image, video and music generation each duplicated could not compile. The same three-line expression appeared verbatim in all three handlers. `open-sse/utils/kieTask.ts` already holds two helpers with exactly this shape — `normalizeKieTaskState()` and `parseKieResultJson()` both take `unknown`, guard with `isJsonObject()` and return a declared type. `getKieTaskId()` follows them, so the three handlers now share one guarded read instead of three unguarded ones. `getKieCallbackUrl()` took `KieCallbackBody`, a weak type (all properties optional). Passing a request body whose declared keys are `prompt` / `timeout_ms` / `poll_interval_ms` tripped TS2559 "no properties in common" at both music call sites. It receives arbitrary upstream request bodies, so it now takes `unknown` and guards the same way its neighbours do; `KieCallbackBody` had no other reference and is gone. Behaviour is unchanged. `isJsonObject()` rejects arrays and null exactly where optional chaining already yielded `undefined`, and the callers' `String(taskId)` coercion moved inside the helper, so a numeric id still reaches `pollTask()` as a string and a falsy id still takes the 502 branch. Fixes 5 of the 208 `tsc -p open-sse/tsconfig.json` diagnostics with no new ones: 3 x TS2339 `taskId` on `unknown`, 2 x TS2559 on `KieCallbackBody`. Refs #8484