From 31283ad9caa6da1cb5b806e4d29bb6c2dfd10c3f Mon Sep 17 00:00:00 2001 From: Zach Posten Date: Fri, 4 Jan 2019 13:21:20 -0600 Subject: [PATCH] fix: Flesh out possible server url configurations --- types/react-filepond/index.d.ts | 39 ++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/types/react-filepond/index.d.ts b/types/react-filepond/index.d.ts index 0d06b58871..67a9e40ab4 100644 --- a/types/react-filepond/index.d.ts +++ b/types/react-filepond/index.d.ts @@ -48,6 +48,40 @@ export interface FilePondItem { abortProcessing: () => void; getMetadata: (key?: any) => any; setMetadata: (key: any, value: any, silent?: boolean) => void; + +interface ServerUrl { + url: string; + method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; + withCredentials?: boolean; + headers?: {[key: string]: string|boolean|number}; + timeout?: number; + + /** + * Called when server response is received, useful for getting + * the unique file id from the server response + */ + onload?: () => any; + /** + * Called when server error is received, receives the response + * body, useful to select the relevant error data + */ + onerror?: (responseBody: any) => any; + /** + * Called with the formdata object right before it is sent, + * return extended formdata object to make changes + */ + ondata?: (data: any) => any; +} + +interface FilePondServerConfigProps { + instantUpload?: boolean; + server?: string | { + process: string | ServerUrl; + revert: string | ServerUrl; + restore: string | ServerUrl; + load: string | ServerUrl; + fetch: string | ServerUrl; + }; } interface FilePondDragDropProps { @@ -57,11 +91,6 @@ interface FilePondDragDropProps { ignoredFiles?: string[]; } -interface FilePondServerConfigProps { - server?: string; - instantUpload?: boolean; -} - interface FilePondLabelProps { labelDecimalSeparator?: string; labelThousandsSeparator?: string;