mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 00:18:03 +08:00
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.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import type {
|
||||
AppAssetDeleteResponse,
|
||||
AppAssetFileContentResponse,
|
||||
AppAssetFileDownloadUrlResponse,
|
||||
AppAssetNode,
|
||||
AppAssetPublishResponse,
|
||||
AppAssetTreeResponse,
|
||||
@ -54,6 +55,16 @@ export const getFileContentContract = base
|
||||
}>())
|
||||
.output(type<AppAssetFileContentResponse>())
|
||||
|
||||
export const getFileDownloadUrlContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/files/{nodeId}/download-url',
|
||||
method: 'GET',
|
||||
})
|
||||
.input(type<{
|
||||
params: { appId: string, nodeId: string }
|
||||
}>())
|
||||
.output(type<AppAssetFileDownloadUrlResponse>())
|
||||
|
||||
export const updateFileContentContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/files/{nodeId}',
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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})
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user