@devino.solutions/upup
Version:
167 lines (166 loc) • 5.41 kB
TypeScript
import { FC } from 'react';
export declare enum UploadAdapter {
INTERNAL = "INTERNAL",
GOOGLE_DRIVE = "GOOGLE_DRIVE",
ONE_DRIVE = "ONE_DRIVE",
LINK = "LINK",
CAMERA = "CAMERA"
}
export declare type GoogleDriveConfigs = {
google_api_key: string;
google_app_id: string;
google_client_id: string;
};
export declare type OneDriveConfigs = {
onedrive_client_id: string;
redirectUri?: string;
};
export declare enum UpupProvider {
AWS = "aws",
Azure = "azure",
BackBlaze = "backblaze",
DigitalOcean = "digitalocean"
}
declare type MaxFileSizeObject = {
size: number;
unit: 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB' | 'EB' | 'ZB' | 'YB';
};
declare type UpupUploaderPropsClassNames = {
containerMini?: string;
containerFull?: string;
containerHeader?: string;
containerCancelButton?: string;
containerAddMoreButton?: string;
adapterButtonList?: string;
adapterButton?: string;
adapterButtonIcon?: string;
adapterButtonText?: string;
adapterViewHeader?: string;
adapterViewCancelButton?: string;
adapterView?: string;
driveLoading?: string;
driveHeader?: string;
driveLogoutButton?: string;
driveSearchContainer?: string;
driveSearchInput?: string;
driveBody?: string;
driveItemContainerDefault?: string;
driveItemContainerSelected?: string;
driveItemContainerInner?: string;
driveItemInnerText?: string;
driveFooter?: string;
driveAddFilesButton?: string;
driveCancelFilesButton?: string;
urlInput?: string;
urlFetchButton?: string;
cameraPreviewContainer?: string;
cameraDeleteButton?: string;
cameraCaptureButton?: string;
cameraRotateButton?: string;
cameraAddButton?: string;
fileListContainer?: string;
fileListContainerInnerSingle?: string;
fileListContainerInnerMultiple?: string;
fileListFooter?: string;
filePreviewPortal?: string;
fileItemSingle?: string;
fileItemMultiple?: string;
fileThumbnailSingle?: string;
fileThumbnailMultiple?: string;
fileInfo?: string;
fileName?: string;
fileSize?: string;
filePreviewButton?: string;
fileDeleteButton?: string;
uploadButton?: string;
uploadDoneButton?: string;
progressBarContainer?: string;
progressBar?: string;
progressBarInner?: string;
progressBarText?: string;
};
export declare type UpupUploaderPropsIcons = {
ContainerAddMoreIcon?: FC<{
className?: string;
}>;
FileDeleteIcon?: FC<{
className?: string;
}>;
CameraDeleteIcon?: FC<{
className?: string;
}>;
CameraCaptureIcon?: FC<{
className?: string;
}>;
CameraRotateIcon?: FC<{
className?: string;
}>;
LoaderIcon?: FC<{
className?: string;
}>;
};
export declare type UpupUploaderProps = {
uploadAdapters?: UploadAdapter[];
driveConfigs?: {
googleDrive?: GoogleDriveConfigs;
oneDrive?: OneDriveConfigs;
};
provider: UpupProvider;
tokenEndpoint: string;
shouldCompress?: boolean;
accept?: string;
limit?: number;
mini?: boolean;
maxFileSize?: MaxFileSizeObject;
onFilesSelected?: (files: File[]) => void;
onPrepareFiles?: (files: FileWithParams[]) => Promise<FileWithParams[]>;
onFileClick?: (file: FileWithParams) => void;
onIntegrationClick?: (integrationType: string) => void;
onFileUploadStart?: (file: FileWithParams) => void;
onFileUploadComplete?: (file: FileWithParams, key: string) => void;
onFilesUploadComplete?: (keys: string[]) => void;
onFileUploadProgress?: (file: FileWithParams, { loaded, total, percentage, }: {
loaded: number;
total: number;
percentage: number;
}) => void;
onFilesUploadProgress?: (completedFiles: number, totalFiles: number) => void;
onFileRemove?: (file: FileWithParams) => void;
onFilesDragOver?: (files: File[]) => void;
onFilesDragLeave?: (files: File[]) => void;
onFilesDrop?: (files: File[]) => void;
onFileTypeMismatch?: (file: File, acceptedTypes: string) => void;
onError?: (errorMessage: string) => void;
onWarn?: (warningMessage: string) => void;
dark?: boolean;
classNames?: UpupUploaderPropsClassNames;
icons?: UpupUploaderPropsIcons;
};
export declare type PresignedUrlResponse = {
key: string;
publicUrl: string;
uploadUrl: string;
expiresIn: number;
};
export declare enum UploadErrorType {
PERMISSION_ERROR = "PERMISSION_ERROR",
EXPIRED_URL = "EXPIRED_URL",
FILE_VALIDATION_ERROR = "FILE_VALIDATION_ERROR",
PRESIGNED_URL_ERROR = "PRESIGNED_URL_ERROR",
SIGNED_URL_ERROR = "SIGNED_URL_ERROR",
CORS_CONFIG_ERROR = "CORS_CONFIG_ERROR",
TEMPORARY_CREDENTIALS_ERROR = "TEMPORARY_CREDENTIALS_ERROR",
UNKNOWN_UPLOAD_ERROR = "UNKNOWN_UPLOAD_ERROR"
}
export declare class UploadError extends Error {
type: UploadErrorType;
retryable: boolean;
status?: number | undefined;
private DEFAULT_ERROR_STATUS_CODE;
constructor(message: string, type?: UploadErrorType, retryable?: boolean, status?: number | undefined);
}
export declare type FileWithParams = File & {
id: string;
url: string;
};
export {};