From 55fd3f7c86a08184f9016da44209d4f59485da0b Mon Sep 17 00:00:00 2001 From: Dolan Date: Sat, 8 Jul 2017 01:11:05 +0100 Subject: [PATCH 1/3] Initial commit --- types/google-images/google-images-tests.ts | 27 ++++++++++++++++++++++ types/google-images/index.d.ts | 12 ++++++++++ types/google-images/tsconfig.json | 22 ++++++++++++++++++ types/google-images/tslint.json | 1 + 4 files changed, 62 insertions(+) create mode 100644 types/google-images/google-images-tests.ts create mode 100644 types/google-images/index.d.ts create mode 100644 types/google-images/tsconfig.json create mode 100644 types/google-images/tslint.json diff --git a/types/google-images/google-images-tests.ts b/types/google-images/google-images-tests.ts new file mode 100644 index 0000000000..b50e8f2ac1 --- /dev/null +++ b/types/google-images/google-images-tests.ts @@ -0,0 +1,27 @@ +import * as GoogleImages from "google-images"; + +const client = new GoogleImages('CSE ID', 'API KEY'); + +client.search('Steve Angello') + .then(images => { + /* + [{ + "url": "http://steveangello.com/boss.jpg", + "type": "image/jpeg", + "width": 1024, + "height": 768, + "size": 102451, + "thumbnail": { + "url": "http://steveangello.com/thumbnail.jpg", + "width": 512, + "height": 512 + } + }] + */ + }); + +// paginate results +client.search('Steve Angello', {page: 2}); + +// search for certain size +client.search('Steve Angello', {size: 'large'}); diff --git a/types/google-images/index.d.ts b/types/google-images/index.d.ts new file mode 100644 index 0000000000..eceb0ca445 --- /dev/null +++ b/types/google-images/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for google-images 1.2 +// Project: https://github.com/beatgammit/base64-js +// Definitions by: Dolan Miu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace GoogleImages { + interface GoogleImages { + + } +} + +export = GoogleImages; diff --git a/types/google-images/tsconfig.json b/types/google-images/tsconfig.json new file mode 100644 index 0000000000..692c9ac5a5 --- /dev/null +++ b/types/google-images/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "google-images-tests.ts" + ] +} diff --git a/types/google-images/tslint.json b/types/google-images/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/google-images/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 372dece74cbf618cd1cfa0aa6a9a185aadff5fcc Mon Sep 17 00:00:00 2001 From: Dolan Date: Sat, 8 Jul 2017 12:02:48 +0100 Subject: [PATCH 2/3] Added typings --- types/google-images/index.d.ts | 41 +++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/types/google-images/index.d.ts b/types/google-images/index.d.ts index eceb0ca445..935cbda432 100644 --- a/types/google-images/index.d.ts +++ b/types/google-images/index.d.ts @@ -1,12 +1,43 @@ -// Type definitions for google-images 1.2 -// Project: https://github.com/beatgammit/base64-js +// Type definitions for google-images 2.1 +// Project: https://github.com/vadimdemedes/google-images // Definitions by: Dolan Miu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace GoogleImages { - interface GoogleImages { +export as namespace GoogleImages; +export = GoogleImages; +declare namespace GoogleImages { + type SearchImageSize = "icon" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "huge"; + type SearchImageType = "clipart" | "face" | "lineart" | "news" | "photo"; + type SearchDominantColor = "black" | "blue" | "brown" | "gray" | "green" | "pink" | "purple" | "teal" | "white" | "yellow"; + type SearchColorType = "color" | "gray" | "mono"; + type SearchSafe = "high" | "medium" | "off"; + + interface SearchOptions { + page?: number; + size?: SearchImageSize; + type?: SearchImageType; + dominantColor?: SearchDominantColor; + colorType?: SearchColorType; + safe?: SearchSafe; + } + + interface Image { + url: string; + type: string; + width: number; + height: number; + size: number; + thumbnail: { + url: string, + width: number, + height: number + }; } } -export = GoogleImages; +declare class GoogleImages { + constructor(engineId: string, apiKey: string); + + search(searchTerm: string, options?: GoogleImages.SearchOptions): Promise; +} From 36998695aefdd385c2564c4d367db9e8768e4004 Mon Sep 17 00:00:00 2001 From: Dolan Date: Thu, 13 Jul 2017 23:47:50 +0100 Subject: [PATCH 3/3] Removed UMD export --- types/google-images/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/google-images/index.d.ts b/types/google-images/index.d.ts index 935cbda432..6ed5b20abf 100644 --- a/types/google-images/index.d.ts +++ b/types/google-images/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: Dolan Miu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export as namespace GoogleImages; export = GoogleImages; declare namespace GoogleImages {