nextcloud/apps/files/src/services/WebdavClient.ts
Ferdinand Thiessen f9a137ea87
refactor(files): migrate favorite sidebar action to new Sidebar API
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2026-01-05 02:23:15 +01:00

24 lines
753 B
TypeScript

import type { Node } from '@nextcloud/files'
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { FileStat, ResponseDataDetailed } from 'webdav'
import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav'
export const client = getClient()
/**
* Fetches a node from the given path
*
* @param path - The path to fetch the node from
*/
export async function fetchNode(path: string): Promise<Node> {
const propfindPayload = getDefaultPropfind()
const result = await client.stat(`${getRootPath()}${path}`, {
details: true,
data: propfindPayload,
}) as ResponseDataDetailed<FileStat>
return resultToNode(result.data)
}