Skip to content

Commit

Permalink
feat(react-upload): export upload client
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Mar 25, 2024
1 parent 3ae9375 commit d92f612
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 9 deletions.
75 changes: 66 additions & 9 deletions build/api/react-uploader.api.md
Expand Up @@ -130,8 +130,6 @@ export interface FileType {
acceptFile?: ((file: FileWithMeta) => boolean | Promise<void>) | undefined;
// (undocumented)
extractors?: FileDataExtractor[];
// Warning: (ae-forgotten-export) The symbol "UploadClient" needs to be exported by the entry point index.d.ts
//
// (undocumented)
uploader?: UploadClient<any>;
}
Expand Down Expand Up @@ -168,6 +166,22 @@ export interface FileUploadHandlerStaticRenderArgs {
environment: Environment_2;
}

// @public (undocumented)
export interface FileUploadProgress {
// (undocumented)
progress: number;
// (undocumented)
totalBytes: number;
// (undocumented)
uploadedBytes: number;
}

// @public (undocumented)
export interface FileUploadResult {
// (undocumented)
publicUrl: string;
}

// @public (undocumented)
export interface FileUrlDataExtractorProps {
// (undocumented)
Expand Down Expand Up @@ -237,6 +251,39 @@ type ProgressEvent_2 = {
};
export { ProgressEvent_2 as ProgressEvent }

// @public (undocumented)
export interface S3FileOptions {
// (undocumented)
acl?: GenerateUploadUrlMutationBuilder.Acl;
// (undocumented)
contentType?: GenerateUploadUrlMutationBuilder.FileParameters['contentType'];
// (undocumented)
expiration?: number;
// (undocumented)
extension?: string;
// (undocumented)
fileName?: string;
// (undocumented)
prefix?: string;
// (undocumented)
size?: number;
// (undocumented)
suffix?: string;
}

// @public (undocumented)
export class S3UploadClient implements UploadClient<S3FileOptions> {
constructor(contentApiClient: GraphQlClient, options?: S3UploadClientOptions);
// Warning: (ae-forgotten-export) The symbol "S3UploadClientOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
readonly options: S3UploadClientOptions;
// (undocumented)
upload({ file, signal, onProgress, ...options }: UploadClientUploadArgs & S3FileOptions): Promise<{
publicUrl: string;
}>;
}

// @public (undocumented)
export type StartUploadEvent = {
file: FileWithMeta;
Expand All @@ -250,6 +297,23 @@ export type SuccessEvent = {
fileType: FileType;
};

// @public (undocumented)
export interface UploadClient<Options, // contains file-specific options
Result extends FileUploadResult = FileUploadResult> {
// (undocumented)
upload: (args: UploadClientUploadArgs & Omit<Options, keyof UploadClientUploadArgs>) => Promise<Result>;
}

// @public (undocumented)
export interface UploadClientUploadArgs {
// (undocumented)
file: File;
// (undocumented)
onProgress: (progress: FileUploadProgress) => void;
// (undocumented)
signal: AbortSignal;
}

// @public (undocumented)
export const Uploader: NamedExoticComponent<UploaderProps>;

Expand Down Expand Up @@ -397,8 +461,6 @@ export const UploaderStateContext: Context<UploaderState>;
// @public (undocumented)
export const UploaderUploadFilesContext: Context<(files: File[]) => void>;

// Warning: (ae-forgotten-export) The symbol "S3UploadClient" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export const useS3Client: () => S3UploadClient;

Expand Down Expand Up @@ -441,11 +503,6 @@ export interface VideoFileDataExtractorProps {
// @public (undocumented)
export type VideoFileTypeProps = FileType & FileUrlDataExtractorProps & GenericFileMetadataExtractorProps & VideoFileDataExtractorProps;

// Warnings were encountered during analysis:
//
// src/types/events.ts:17:2 - (ae-forgotten-export) The symbol "FileUploadProgress" needs to be exported by the entry point index.d.ts
// src/types/events.ts:29:2 - (ae-forgotten-export) The symbol "FileUploadResult" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

```
1 change: 1 addition & 0 deletions packages/react-uploader/src/index.ts
Expand Up @@ -4,6 +4,7 @@ export * from './extractors'
export * from './fileTypes'
export * from './types'
export * from './hooks'
export * from './uploadClient'
export * from './UploaderError'


Expand Down
2 changes: 2 additions & 0 deletions packages/react-uploader/src/uploadClient/index.ts
@@ -0,0 +1,2 @@
export * from './S3UploadClient'
export * from './UploadClient'

0 comments on commit d92f612

Please sign in to comment.