Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
fix: TypeScript declaration for lib/core/s3; add retry option
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyayers committed Mar 27, 2018
1 parent 5be9ba1 commit af39cae
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 53 deletions.
152 changes: 100 additions & 52 deletions client/typescript/fine-uploader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,10 @@ declare module "fine-uploader/lib/core" {
* RequestOptions
*/
request?: RequestOptions;
/**
* RetryOptions
*/
retry?: RetryOptions;
/**
* ScalingOptions
*/
Expand All @@ -933,8 +937,6 @@ declare module "fine-uploader/lib/core" {
* Core callback functions
*/
callbacks?: CoreEvents;


}

/**
Expand Down Expand Up @@ -2700,6 +2702,7 @@ declare module "fine-uploader/lib/azure" {
UIDeleteFileOptions,
UIMessages,
UIPasteOptions,
UIRetryOptions,
UIScalingOptions,
UITextOptions
} from 'fine-uploader';
Expand All @@ -2709,6 +2712,7 @@ declare module "fine-uploader/lib/azure" {
ChunkingOptions,
CorsOptions,
RequestOptions,
RetryOptions,
CoreOptions,
ResumableFileObject,
PromiseOptions
Expand Down Expand Up @@ -3062,10 +3066,12 @@ declare module "fine-uploader/lib/azure" {
* RequestOptions
*/
request?: AzureRequestOptions;

/**
* Retry options
*/
retry?: UIRetryOptions & RetryOptions;
}


}

}
Expand All @@ -3079,26 +3085,26 @@ declare module "fine-uploader/lib/s3" {
UIDeleteFileOptions,
UIMessages,
UIPasteOptions,
UIRetryOptions,
UIScalingOptions,
UITextOptions
} from 'fine-uploader';

import {
FineUploaderBasic as FineUploaderBasicCore,
ChunkingOptions,
CorsOptions,
RequestOptions,
CoreOptions,
ResumableFileObject,
CoreEvents,
PromiseOptions
PromiseOptions,
RetryOptions
} from 'fine-uploader/lib/core';


import { s3 as s3Core } from 'fine-uploader/lib/core/s3';

export namespace s3 {


export class FineUploader extends FineUploaderCore {

constructor(fineuploaderOptions?: S3UIOptions);
Expand Down Expand Up @@ -3175,6 +3181,90 @@ declare module "fine-uploader/lib/s3" {
setUploadSuccessParams(newParams: any, id?: number): void;
}

/**
* S3UIOptions
*/
export interface S3UIOptions extends UIOptions, S3CoreOptions {
/**
* failedUploadText options
*/
failedUploadTextDisplay?: S3FailedUploadTextDisplayOptions;
/**
* chunking options
*/
chunking?: S3ChunkingOptions;
/**
* cors options
*/
cors?: S3CorsOptions;
/**
* request options
*/
request?: S3RequestOptions;
/**
* deleteFile options
*/
deleteFile?: UIDeleteFileOptions;
/**
* messages
*/
messages?: UIMessages;
/**
* paste UI options
*/
paste?: UIPasteOptions;
/**
* Retry options
*/
retry?: UIRetryOptions & RetryOptions;
/**
* UI scaling options
*/
scaling?: UIScalingOptions;
/**
* UI text options
*/
text?: UITextOptions;
}

export import FineUploaderBasic = s3Core.FineUploaderBasic;
export type S3ChunkingOptions = s3Core.S3ChunkingOptions;
export type S3CredentialsOptions = s3Core.S3CredentialsOptions;
export type S3CorsOptions = s3Core.S3CorsOptions;
export type S3iFrameSupportOptions = s3Core.S3iFrameSupportOptions;
export type BucketFunction = s3Core.BucketFunction;
export type HostFunction = s3Core.HostFunction;
export type KeyFunction = s3Core.KeyFunction;
export type S3ObjectPropertyOptions = s3Core.S3ObjectPropertyOptions;
export type S3RequestOptions = s3Core.S3RequestOptions;
export type S3CustomHeaderFunction = s3Core.S3CustomHeaderFunction;
export type S3SignatureOptions = s3Core.S3SignatureOptions;
export type S3UploadSuccessOptions = s3Core.S3UploadSuccessOptions;
export type S3CoreOptions = s3Core.S3CoreOptions;
export type S3FailedUploadTextDisplayOptions = s3Core.S3FailedUploadTextDisplayOptions;
export type OnCredentialsExpired = s3Core.OnCredentialsExpired;
export type S3Events = s3Core.S3Events;
export type S3ResumableFileObject = s3Core.S3ResumableFileObject;

}

}

declare module "fine-uploader/lib/core/s3" {

import {
FineUploaderBasic as FineUploaderBasicCore,
ChunkingOptions,
CorsOptions,
RequestOptions,
CoreOptions,
ResumableFileObject,
CoreEvents,
PromiseOptions
} from 'fine-uploader/lib/core';

export namespace s3 {

export class FineUploaderBasic extends FineUploaderBasicCore {

constructor(fineuploaderOptions?: S3CoreOptions);
Expand Down Expand Up @@ -3252,7 +3342,6 @@ declare module "fine-uploader/lib/s3" {

}


/**
* S3CredentialsOptions
*/
Expand Down Expand Up @@ -3583,48 +3672,6 @@ declare module "fine-uploader/lib/s3" {
onCredentialsExpired?: OnCredentialsExpired;
}

/**
* S3UIOptions
*/
export interface S3UIOptions extends UIOptions, S3CoreOptions {
/**
* failedUploadText options
*/
failedUploadTextDisplay?: S3FailedUploadTextDisplayOptions;
/**
* chunking options
*/
chunking?: S3ChunkingOptions;
/**
* cors options
*/
cors?: S3CorsOptions;
/**
* request options
*/
request?: S3RequestOptions;
/**
* deleteFile options
*/
deleteFile?: UIDeleteFileOptions;
/**
* messages
*/
messages?: UIMessages;
/**
* paste UI options
*/
paste?: UIPasteOptions;
/**
* UI scaling options
*/
scaling?: UIScalingOptions;
/**
* UI text options
*/
text?: UITextOptions;
}

/**
* Resumable file object type for S3
*/
Expand All @@ -3634,6 +3681,7 @@ declare module "fine-uploader/lib/s3" {
*/
key?: string;
}

}

}
}
31 changes: 30 additions & 1 deletion client/typescript/fine-uploader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FineUploader, UIOptions } from 'fine-uploader';
import { s3 } from 'fine-uploader/lib/s3';
import { azure } from 'fine-uploader/lib/azure';
import { PromiseOptions } from 'fine-uploader/lib/core';
import { s3 as s3Core } from 'fine-uploader/lib/core/s3';

/**
* Prepare/set options for the core + UI FineUploader
Expand Down Expand Up @@ -59,6 +60,34 @@ let s3UIOptions: s3.S3UIOptions = {
let s3Uploader = new s3.FineUploader(s3UIOptions);


/**
* Prepare/set options for the core Amazon S3 FineUploaderBasic
*/
let s3CoreOptions: s3Core.S3CoreOptions = {
debug: true,
request: {
endpoint: '{ YOUR_BUCKET_NAME }.s3.amazonaws.com',
accessKey: '{ YOUR_ACCESS_KEY }'
},
signature: {
endpoint: '/s3/signature'
},
uploadSuccess: {
endpoint: '/s3/success'
},
iframeSupport: {
localBlankPagePath: '/success.html'
},
retry: {
enableAuto: true // defaults to false
},
deleteFile: {
enabled: true,
endpoint: '/s3handler'
}
}
let s3CoreUploader = new s3Core.FineUploaderBasic(s3CoreOptions);


/**
* Prepare/set options for the Amazon S3 FineUploader
Expand Down Expand Up @@ -102,4 +131,4 @@ promise.then(() => {
});
promise.done(() => {
//promise is fulfilled whether successful or not, do something here
});
});

0 comments on commit af39cae

Please sign in to comment.