synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
46 lines • 2.52 kB
TypeScript
import { BaseFilePreparedForUpload, BaseFileUploadArgs } from '@/utils/hooks/useUploadFileEntity/useUploadFiles';
import { SynapseClientError } from '@sage-bionetworks/synapse-client';
import { UseMutationOptions } from '@tanstack/react-query';
export type NewEntityFileUploadArgs = BaseFileUploadArgs & {
rootContainerId: string;
};
export type NewEntityFilePreparedForUpload = BaseFilePreparedForUpload & {
parentId: string;
};
export type UpdateEntityFilePreparedForUpload = BaseFilePreparedForUpload & {
existingEntityId: string;
};
export type FilePreparedForUpload = BaseFilePreparedForUpload | NewEntityFilePreparedForUpload | UpdateEntityFilePreparedForUpload;
export type PrepareDirsForUploadReturn = {
filesReadyForUpload: FilePreparedForUpload[];
filesToPromptForNewVersion: FilePreparedForUpload[];
};
export type PrepareFileEntityUploadArgs = (NewEntityFileUploadArgs | UpdateEntityFilePreparedForUpload)[];
/**
* Mutation used to check and prepare the entity tree just before uploading a list of files.
*
* Given a list of files and a parent ID in which the files should be uploaded, the mutation will:
*
* 1. Create the necessary Folder entities in which the files to be uploaded (e.g. if the user uploaded a folder)
* 2. Check if any of the files to be uploaded already exist in the target parent folder
*
* The mutation will return two lists of files and their destination parentIds:
* - filesReadyForUpload: New files that do not have corresponding file entities in the target parent folder, or a file
* that should be updated without a prompt.
* - filesToPromptForNewVersion: Files that have corresponding file entities in the target parent folder. The user
* should be prompted to accept or reject the creation of a new version of the file.
*
* In the future, this sequence could be amended to check if the storage location has enough space to accommodate all the
* new files, and return an error if not.
*
* @param options
*/
export declare function usePrepareFileEntityUpload(options?: Partial<UseMutationOptions<PrepareDirsForUploadReturn, SynapseClientError, PrepareFileEntityUploadArgs>>): import("@tanstack/react-query").UseMutationResult<{
filesReadyForUpload: FilePreparedForUpload[];
filesToPromptForNewVersion: {
existingEntityId: string | null;
file: File;
parentId: string;
}[];
}, SynapseClientError, PrepareFileEntityUploadArgs, unknown>;
//# sourceMappingURL=usePrepareFileEntityUpload.d.ts.map