The VS Code of video editing, built for agents.
TypeScript
Update API specifications and type definitions for asset tree structure. Adjusted documentation to clarify the behavior of `children` in asset and folder entries, ensuring accurate representation of folder contents. Refactored related types in CLI to support optional `children` property for better flexibility.
konstantin-paulus5bee05ba8378
diff --git a/apps/cli/api-spec.md b/apps/cli/api-spec.mdindex 2b8b2a2b..aa110ad8 100644--- a/apps/cli/api-spec.md+++ b/apps/cli/api-spec.md@@ -453,12 +453,12 @@ Lists the asset library of the open project as its folder tree — folders and a- **Input:**- `--folder <id>` — folder whose contents to list (optional; default the library root)- - `--depth <N>` — max depth, positive integer (optional; default = full tree). `--depth 1` yields just the direct entries of the listing root; a folder at the cutoff is listed with an empty `children` array (indistinguishable from a genuinely empty folder — raise the depth to tell them apart).+ - `--depth <N>` — max depth, positive integer (optional; default = full tree). `--depth 1` yields just the direct entries of the listing root; a folder at the cutoff is listed without `children` (indistinguishable from a genuinely empty folder — raise the depth to tell them apart).- **Output:** JSON Lines, one per entry of the listing root (no output if the listing root is empty); each entry carries its own subtree in `children````ts- AssetTree = Array<(Asset | Folder) & { children: AssetTree }> // one root entry per line+ AssetTree = Array<(Asset | Folder) & { children?: AssetTree }> // one root entry per line```- Folders are the entries with type `folder`. An asset's `children` is always empty.+ Folders are the entries with type `folder`. `children` is present only on folders with contents; assets never carry it.- **Errors:** exits non-zero if `--folder` doesn't resolve to a folder.---diff --git a/apps/cli/src/cli-channels.ts b/apps/cli/src/cli-channels.tsindex da7a3517..3bb7fd12 100644--- a/apps/cli/src/cli-channels.ts+++ b/apps/cli/src/cli-channels.ts@@ -165,7 +165,7 @@ export type GeneratedAsset = { id: string; name: string; type: string };export type FolderInfo = { id: string; name: string; type: "folder" };-export type AssetTreeEntry = { id: string; name: string; type: string; children: AssetTreeEntry[] };+export type AssetTreeEntry = { id: string; name: string; type: string; children?: AssetTreeEntry[] };export type AssetMoveResult =| { status: "fulfilled"; id: string; folderId: string | null }diff --git a/apps/web/src/context/electron/assets.ts b/apps/web/src/context/electron/assets.tsindex 9644339f..4d010a27 100644--- a/apps/web/src/context/electron/assets.ts+++ b/apps/web/src/context/electron/assets.ts@@ -60,16 +60,17 @@ export function handleAssetsList(engine: Accessor<Engine>) {.map((folder) => {visited.add(folder.id);const next = remaining === undefined ? undefined : remaining - 1;+ const children = next === undefined || next > 0 ? entries(folder.id, next) : [];return {id: folder.id,name: folder.name,type: "folder",- children: next === undefined || next > 0 ? entries(folder.id, next) : [],+ ...(children.length > 0 && { children }),};});const assetEntries = assets.filter((asset) => assetFolderId(world, asset) === parentId)- .map((asset) => ({ id: asset.id, name: asset.name, type: asset.type, children: [] }));+ .map((asset) => ({ id: asset.id, name: asset.name, type: asset.type }));return [...folderEntries, ...assetEntries];};