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

fix: TypeScript declaration for lib/core/s3; add retry option #1989

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions client/commonJs/all.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"use strict";

module.exports = require("../../all.fine-uploader/all.fine-uploader.core");
module.exports = require("../../all.fine-uploader/all.fine-uploader");
3 changes: 3 additions & 0 deletions client/commonJs/all/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../typescript/fine-uploader.d.ts"
}
3 changes: 0 additions & 3 deletions client/commonJs/azure.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"use strict";

module.exports = require("../../azure.fine-uploader/azure.fine-uploader.core");
module.exports = require("../../azure.fine-uploader/azure.fine-uploader");
3 changes: 3 additions & 0 deletions client/commonJs/azure/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../typescript/fine-uploader.d.ts"
}
3 changes: 3 additions & 0 deletions client/commonJs/core/all/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../../all.fine-uploader/all.fine-uploader.core");
3 changes: 3 additions & 0 deletions client/commonJs/core/all/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../../typescript/fine-uploader.d.ts"
}
3 changes: 3 additions & 0 deletions client/commonJs/core/azure/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../../azure.fine-uploader/azure.fine-uploader.core");
3 changes: 3 additions & 0 deletions client/commonJs/core/azure/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../../typescript/fine-uploader.d.ts"
}
3 changes: 3 additions & 0 deletions client/commonJs/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../typescript/fine-uploader.d.ts"
}
3 changes: 3 additions & 0 deletions client/commonJs/core/s3/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../../s3.fine-uploader/s3.fine-uploader.core");
3 changes: 3 additions & 0 deletions client/commonJs/core/s3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../../typescript/fine-uploader.d.ts"
}
3 changes: 0 additions & 3 deletions client/commonJs/core/traditional.js

This file was deleted.

3 changes: 3 additions & 0 deletions client/commonJs/core/traditional/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../../fine-uploader/fine-uploader.core");
3 changes: 3 additions & 0 deletions client/commonJs/core/traditional/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../../typescript/fine-uploader.d.ts"
}
File renamed without changes.
3 changes: 3 additions & 0 deletions client/commonJs/dnd/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../typescript/fine-uploader.d.ts"
}
3 changes: 0 additions & 3 deletions client/commonJs/s3.js

This file was deleted.

2 changes: 1 addition & 1 deletion client/commonJs/core/s3.js → client/commonJs/s3/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"use strict";

module.exports = require("../../s3.fine-uploader/s3.fine-uploader.core");
module.exports = require("../../s3.fine-uploader/s3.fine-uploader");
3 changes: 3 additions & 0 deletions client/commonJs/s3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../typescript/fine-uploader.d.ts"
}
3 changes: 0 additions & 3 deletions client/commonJs/traditional.js

This file was deleted.

3 changes: 3 additions & 0 deletions client/commonJs/traditional/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../fine-uploader/fine-uploader");
3 changes: 3 additions & 0 deletions client/commonJs/traditional/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typings": "../../typescript/fine-uploader.d.ts"
}
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;

This comment was marked as spam.

/**
* 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;
}


}

}
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;
/**
* UI scaling options
*/
scaling?: UIScalingOptions;
/**
* UI text options
*/
text?: UITextOptions;
}

export import FineUploaderBasic = s3Core.FineUploaderBasic;
export import S3ChunkingOptions = s3Core.S3ChunkingOptions;
export import S3CredentialsOptions = s3Core.S3CredentialsOptions;
export import S3CorsOptions = s3Core.S3CorsOptions;
export import S3iFrameSupportOptions = s3Core.S3iFrameSupportOptions;
export import BucketFunction = s3Core.BucketFunction;
export import HostFunction = s3Core.HostFunction;
export import KeyFunction = s3Core.KeyFunction;
export import S3ObjectPropertyOptions = s3Core.S3ObjectPropertyOptions;
export import S3RequestOptions = s3Core.S3RequestOptions;
export import S3CustomHeaderFunction = s3Core.S3CustomHeaderFunction;
export import S3SignatureOptions = s3Core.S3SignatureOptions;
export import S3UploadSuccessOptions = s3Core.S3UploadSuccessOptions;
export import S3CoreOptions = s3Core.S3CoreOptions;
export import S3FailedUploadTextDisplayOptions = s3Core.S3FailedUploadTextDisplayOptions;
export import OnCredentialsExpired = s3Core.OnCredentialsExpired;
export import S3Events = s3Core.S3Events;
export import 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
});
});