From 31fc92ecd37e7a61a372d74b5d831ce19e50c398 Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 13 Nov 2018 22:39:28 +0000 Subject: [PATCH] Add missing definitions to tus-js-client (#30384) --- types/tus-js-client/index.d.ts | 9 ++++++++- types/tus-js-client/tus-js-client-tests.ts | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/types/tus-js-client/index.d.ts b/types/tus-js-client/index.d.ts index 40097af209..defb27fea0 100644 --- a/types/tus-js-client/index.d.ts +++ b/types/tus-js-client/index.d.ts @@ -1,12 +1,14 @@ -// Type definitions for tus-js-client 1.4 +// Type definitions for tus-js-client 1.5 // Project: https://github.com/tus/tus-js-client/ // Definitions by: Kevin Somers-Higgins +// Marius Kleidl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface UploadOptions { endpoint: string; fingerprint?: string; resume?: boolean; + metadata?: { [key: string]: string }; onProgress?: ((bytesSent: number, bytesTotal: number) => void) | null; onChunkComplete?: ((chunkSize: number, bytesAccepted: number, bytesTotal: number) => void) | null; onSuccess?: (() => void) | null; @@ -18,6 +20,7 @@ export interface UploadOptions { uploadSize?: number | null; overridePatchMethod?: boolean; retryDelays?: number[]; + removeFingerprintOnSuccess?: boolean; } export class Upload { @@ -30,3 +33,7 @@ export class Upload { start(): void; abort(): void; } + +export const isSupported: boolean; +export const canStoreURLs: boolean; +export const defaultOptions: UploadOptions; diff --git a/types/tus-js-client/tus-js-client-tests.ts b/types/tus-js-client/tus-js-client-tests.ts index 7f187e735e..a13d9da12f 100644 --- a/types/tus-js-client/tus-js-client-tests.ts +++ b/types/tus-js-client/tus-js-client-tests.ts @@ -1,5 +1,9 @@ import * as Tus from 'tus-js-client'; +const isSupported = Tus.isSupported; +const canStoreURLs = Tus.canStoreURLs; +const defaultChunkSize = Tus.defaultOptions.chunkSize; + const file = new File(["foo"], "foo.txt", { type: "text/plain", }); @@ -8,6 +12,9 @@ const upload = new Tus.Upload(file, { endpoint: "", fingerprint: "fingerprint", resume: true, + metadata: { + filename: "foo.txt" + }, onProgress: (bytesSent: number, bytesTotal: number) => { const percentage = (bytesSent / bytesTotal * 100).toFixed(2); console.log(bytesSent, bytesTotal, percentage + "%"); @@ -25,7 +32,8 @@ const upload = new Tus.Upload(file, { uploadUrl: "", uploadSize: 50, overridePatchMethod: true, - retryDelays: [10, 20, 50] + retryDelays: [10, 20, 50], + removeFingerprintOnSuccess: true }); upload.start();