Comfy-Org / Comfy-Org/ComfyUI_frontend

Refactor: Add getAssetsByName to assetService and remove duplicated AssetRecord interface

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

Description

## Summary

In `src/platform/assets/utils/assetPreviewUtil.ts`, the `fetchAssetsByName` function currently uses raw `api.fetchApi` with unvalidated `res.json()` instead of routing through `assetService`, which provides Zod schema validation. Additionally, the local `AssetRecord` interface duplicates the existing `AssetItem` type.

## Proposed Changes

1. Add a `getAssetsByName(name: string)` method to `assetService` (following the existing `safeParse` + Zod validation pattern used throughout the service).
2. Replace the raw `api.fetchApi` call in `fetchAssetsByName` with the new `assetService.getAssetsByName()`.
3. Remove the duplicated `AssetRecord` interface from `assetPreviewUtil.ts` and use `AssetItem` (or a `Pick` of it) instead.

## References

- Raised in PR #9471 (comment): https://github.com/Comfy-Org/ComfyUI_frontend/pull/9471#discussion_r2938399196
- Requested by: @christian-byrne

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10015-Refactor-Add-getAssetsByName-to-assetService-and-remove-duplicated-AssetRecord-inter-3256d73d36508160bd76c1f8eb1659e1) 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.