cozy-dataproxy-lib
Version:
Library meant to be by Cozy Cloud's DataProxy apps for data manipulation
31 lines (30 loc) • 1.21 kB
TypeScript
import CozyClient from 'cozy-client';
import { IOCozyFile } from 'cozy-client/types/types';
import { CozyDoc } from '../types';
export declare const getFilePath: (id: string) => string | undefined;
export declare const resetAllPaths: () => void;
/**
* Compute and set paths for given files.
*
* The paths are kept in memory to be quickly retrieved later.
* From a list of io.cozy.files, we first extract the directories paths.
* Then, for each file, we compute the path from its parent.
*
* @param {CozyDoc[]} docs - The list of docs to compute paths
* @returns {CozyDoc[]} the list of docs with paths
*/
export declare const setFilePaths: (docs: CozyDoc[]) => CozyDoc[];
/**
* Compute paths for files
*
* There are several ways to get a path:
* - It is already defined in the file
* - The file path exists in memory
* - The directory path exists in memory
* - The directory path is retrieved from db
*
* @param { CozyClient} client - The cozy client instance
* @param { IOCozyFile} file - The file to compute path
* @returns {Promise<IOCozyFile>} the completed file with path
*/
export declare const computeFileFullpath: (client: CozyClient, file: IOCozyFile) => Promise<IOCozyFile>;