diff --git a/types/uploadcare/index.d.ts b/types/uploadcare/index.d.ts new file mode 100644 index 0000000000..3b3e4e1b09 --- /dev/null +++ b/types/uploadcare/index.d.ts @@ -0,0 +1,68 @@ +// Type definitions for uploadcare 0.4 +// Project: https://github.com/rexmorgan/uploadcare-node +// Definitions by: Jinesh Shah +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { ReadStream } from "fs"; + +declare namespace Uploadcare { + interface File { + original_file_url: string; + image_info: ImageInfo; + mime_type: string; + is_ready: boolean; + url: string; + uuid: string; + original_filename: string; + datetime_uploaded: string; + size: number; + is_image: boolean; + datetime_stored: string; + datetime_removed: string | null; + } + + interface ImageInfo { + orientation: null; + sequence: boolean; + format: string; + height: number; + width: number; + geo_location: null; + datetime_original: null; + dpi: number[]; + } + + interface Instance { + file: { + upload: ( + readStream: ReadStream, + options: { store?: boolean }, + callback: (err: Error, res: { file: string }) => void + ) => void; + fromUrl: ( + url: string, + options: { store?: boolean }, + callback: (err: Error, res: File) => void + ) => void; + }; + files: { + store: ( + uuid: string, + callback: (err: Error, res: File) => void + ) => void; + remove: ( + uuid: string, + callback: (err: Error, res: File) => void + ) => void; + }; + } +} + +declare function Uploadcare( + publicKey: string, + privateKey: string +): Uploadcare.Instance; + +export = Uploadcare; diff --git a/types/uploadcare/tsconfig.json b/types/uploadcare/tsconfig.json new file mode 100644 index 0000000000..44810d6b42 --- /dev/null +++ b/types/uploadcare/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "uploadcare-tests.ts"] +} diff --git a/types/uploadcare/tslint.json b/types/uploadcare/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/uploadcare/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/uploadcare/uploadcare-tests.ts b/types/uploadcare/uploadcare-tests.ts new file mode 100644 index 0000000000..295a470691 --- /dev/null +++ b/types/uploadcare/uploadcare-tests.ts @@ -0,0 +1,7 @@ +import * as Uploadcare from "uploadcare"; + +const uploadcare = Uploadcare("", ""); + +uploadcare.file.fromUrl("", {}, (err, res) => { + const file: Uploadcare.File = res; +});