From 3252748345fdd18ffd1286435d0937ad8361a2d5 Mon Sep 17 00:00:00 2001 From: yyh Date: Fri, 16 Jan 2026 09:55:17 +0800 Subject: [PATCH] feat(skill): add oRPC contract and hook for file download URL Add frontend oRPC integration for the existing backend download URL endpoint to enable file downloads from the asset tree. --- web/contract/console/app-asset.ts | 11 +++++++++++ web/contract/router.ts | 2 ++ web/service/use-app-asset.ts | 8 ++++++++ web/types/app-asset.ts | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/web/contract/console/app-asset.ts b/web/contract/console/app-asset.ts index 0c9ab34e8f..af2d7ed30f 100644 --- a/web/contract/console/app-asset.ts +++ b/web/contract/console/app-asset.ts @@ -1,6 +1,7 @@ import type { AppAssetDeleteResponse, AppAssetFileContentResponse, + AppAssetFileDownloadUrlResponse, AppAssetNode, AppAssetPublishResponse, AppAssetTreeResponse, @@ -54,6 +55,16 @@ export const getFileContentContract = base }>()) .output(type()) +export const getFileDownloadUrlContract = base + .route({ + path: '/apps/{appId}/assets/files/{nodeId}/download-url', + method: 'GET', + }) + .input(type<{ + params: { appId: string, nodeId: string } + }>()) + .output(type()) + export const updateFileContentContract = base .route({ path: '/apps/{appId}/assets/files/{nodeId}', diff --git a/web/contract/router.ts b/web/contract/router.ts index c7acc01013..b2422b6cc1 100644 --- a/web/contract/router.ts +++ b/web/contract/router.ts @@ -4,6 +4,7 @@ import { createFolderContract, deleteNodeContract, getFileContentContract, + getFileDownloadUrlContract, moveNodeContract, publishContract, renameNodeContract, @@ -50,6 +51,7 @@ export const consoleRouterContract = { createFolder: createFolderContract, createFile: createFileContract, getFileContent: getFileContentContract, + getFileDownloadUrl: getFileDownloadUrlContract, updateFileContent: updateFileContentContract, deleteNode: deleteNodeContract, renameNode: renameNodeContract, diff --git a/web/service/use-app-asset.ts b/web/service/use-app-asset.ts index ebf4c01773..a963305e84 100644 --- a/web/service/use-app-asset.ts +++ b/web/service/use-app-asset.ts @@ -104,6 +104,14 @@ export const useGetAppAssetFileContent = (appId: string, nodeId: string) => { }) } +export const useGetAppAssetFileDownloadUrl = (appId: string, nodeId: string, options?: { enabled?: boolean }) => { + return useQuery({ + queryKey: consoleQuery.appAsset.getFileDownloadUrl.queryKey({ input: { params: { appId, nodeId } } }), + queryFn: () => consoleClient.appAsset.getFileDownloadUrl({ params: { appId, nodeId } }), + enabled: (options?.enabled ?? true) && !!appId && !!nodeId, + }) +} + export const useUpdateAppAssetFileContent = () => { const queryClient = useQueryClient() return useMutation({ diff --git a/web/types/app-asset.ts b/web/types/app-asset.ts index 7916de8856..8bd60ae37f 100644 --- a/web/types/app-asset.ts +++ b/web/types/app-asset.ts @@ -70,6 +70,14 @@ export type AppAssetFileContentResponse = { content: string } +/** + * File download URL response (GET /apps/{app_id}/assets/files/{node_id}/download-url) + */ +export type AppAssetFileDownloadUrlResponse = { + /** Presigned download URL */ + download_url: string +} + /** * Delete node response (DELETE /apps/{app_id}/assets/nodes/{node_id}) */