Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor: consolidate Zod schemas into a shared package

Open
#10,715 0 comments 0 reactions 1 assignee Claimed by @christian-byrne View on GitHub
developer experience documentation
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

As suggested in [PR #10642](https://github.com/Comfy-Org/ComfyUI_frontend/pull/10642#discussion_r3005407188) by @DrJKL, the project's Zod schemas and TypeScript types that are currently spread across `src/` should be consolidated into a dedicated shared package. This would make them easier to consume, version, and reuse — including from Playwright E2E test fixtures.

## Motivation

The Playwright test guidance in `docs/guidance/playwright.md` currently points test authors to individual schema files scattered across the codebase. Grouping them into a single package would:

- Provide a single import surface for consumers (tests, external tools, etc.)
- Make schema versioning and breaking-change tracking explicit
- Reduce the risk of test fixtures drifting from production types

## Schemas / Types to consolidate

| File | Key exports |
|------|-------------|
| `src/schemas/apiSchema.ts` | `PromptResponse`, `SystemStats`, `User`, `UserDataFullInfo`, WebSocket message types |
| `src/schemas/nodeDefSchema.ts` | `ComfyNodeDef`, `InputSpec`, `ComboInputSpec` |
| `src/schemas/nodeDef/nodeDefSchemaV2.ts` | V2 node definition schema |
| `src/platform/remote/comfyui/jobs/jobTypes.ts` | `zJobDetail`, `zJobsListResponse`, `zRawJobListItem` |
| `src/platform/workflow/validation/schemas/workflowSchema.ts` | `ComfyWorkflowJSON`, `ComfyApiWorkflow` |
| `src/types/metadataTypes.ts` | Asset metadata types |

## Proposed approach

1. Create a new package (e.g., `packages/comfyui-schemas` or similar) in the monorepo.
2. Move or re-export the schemas listed above from the new package.
3. Update all internal imports to reference the new package.
4. Update `docs/guidance/playwright.md` to point to the new package import path.

## References

- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10642
- Comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10642#discussion_r3005407188
- Requested by: @christian-byrne

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10715-refactor-consolidate-Zod-schemas-into-a-shared-package-3326d73d365081d78120d202533749d0) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.