docs(comfy-router): narrow RunResult in the TypeScript snippets for SDK 0.3.0 - #1679
mattmillerai wants to merge 2 commits into
Conversation
…DK 0.3.0
`@comfyorg/sdk@0.3.0` makes `RunResult` a discriminated union, because the
run route's `200` has two documented shapes: an `application/json` document
and a `*/*` binary body, which is how a partner whose generation IS the
response answers. Destructuring `data` straight off the result no longer
compiles when a type argument is supplied:
error TS2339: Property 'result' does not exist on type
'Uint8Array<ArrayBufferLike> | Result'.
Every TypeScript snippet on the Router model pages is written that way, as is
the quickstart, so each one is a copy-paste that fails to build against the
current SDK.
The generated pages are fixed at the source: `typescriptSnippet` in
`.github/scripts/snippets/gen-code-pages.ts` now assigns the result and
narrows on `kind` before reading `data`. The 27 affected pages are
regenerated output, not hand edits, and `--check --validate` reports all 204
fresh.
The quickstart is hand-written and is patched directly. Its install line also
pinned `@comfyorg/sdk@^0.1.9`, which on a `0.x` caret resolves below `0.2.0`
and so never picked up either of the last two releases; now `^0.3.0`.
The untyped snippets (`const { data } = await comfy.models.run(...)` with no
type argument) still compile, since `data` is `unknown` either way, and are
left alone.
Not in this change: the binary models have more to say now than they used to.
`elevenlabs/eleven_v3` and `elevenlabs/eleven_sfx_v2` answer with audio bytes,
which 0.3.0 can finally return, and their pages still print the result as if
it were a document. Teaching the generator to emit a binary branch for those
models is worth its own pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
🌐 i18n translation sync reminder@comfyui-wiki English documentation was updated in this PR. Please complete or schedule translation updates for the following files: Japanese (
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (29)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughTypeScript snippets and quick-start examples now retain the SDK result wrapper, reject non-JSON results, and read payloads through ChangesSDK result envelope updates
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No actionable correctness, availability, or documentation-contract issue remains from the reviewed changes. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
ELI-5
@comfyorg/sdk@0.3.0shipped today and changed the typemodels.run()returns. Every TypeScript snippet on the Comfy Router pages, plus the quickstart, is written in the old style, so copy-pasting one no longer compiles. This updates them.Why they break
RunResultis now a discriminated union, because the run route's200has two documented shapes: anapplication/jsondocument, and a*/*binary body, which is how a partner whose generation is the response answers (the ElevenLabs audio models). Pullingdatastraight off the result no longer typechecks once a type argument is supplied:Before / after:
What changed
.github/scripts/snippets/gen-code-pages.tsis the real change.typescriptSnippetassigns the result and narrows onkindbefore readingdata. The 27 modelcode.mdxfiles in this PR are regenerated output, not hand edits.development/comfy-router/quickstart.mdxis hand-written, so it is patched directly. Its install line also pinned@comfyorg/sdk@^0.1.9, which on a0.xcaret resolves below0.2.0and so never picked up either of the last two releases. Now^0.3.0.Untyped snippets (
const { data } = await comfy.models.run(...)with no type argument) still compile, becausedataisunknowneither way. They are left alone. Theja/zh/kotrees carry no typed snippets and are untouched; the i18n sync owns them regardless.Verification
bun .github/scripts/snippets/gen-code-pages.ts --check --validatereports 204 code pages fresh (27 curated, 177 derived), so the committed output matches a clean generation.tsc --noEmit. The same two shapes before the change produce theTS2339above, which is how the break was confirmed rather than assumed.Follow-up, not in this PR
The binary models have more to say now than they used to.
elevenlabs/eleven_v3andelevenlabs/eleven_sfx_v2answer with audio bytes, which 0.3.0 can finally hand back, and their pages still print the result as though it were a document. Teaching the generator to emit a binary branch (result.kind === "binary"and write the bytes) for those models is worth its own pass.Provenance
@comfyorg/sdk@0.3.0release.🤖 Generated with Claude Code