mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 05:20:24 +08:00
Added typing for url-metadata 2.1 (#21035)
This commit is contained in:
57
types/url-metadata/index.d.ts
vendored
Normal file
57
types/url-metadata/index.d.ts
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Type definitions for url-metadata 2.1
|
||||
// Project: https://github.com/LevelNewsOrg/url-metadata
|
||||
// Definitions by: Kevin Gravier <https://github.com/mrkmg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = urlMetadata;
|
||||
|
||||
declare function urlMetadata(url: string, options?: urlMetadata.Options): Promise<urlMetadata.Result>;
|
||||
|
||||
declare namespace urlMetadata {
|
||||
interface Options {
|
||||
userAgent?: string;
|
||||
fromEmail?: string;
|
||||
maxRedirects?: number;
|
||||
timeout?: number;
|
||||
descriptionLength?: number;
|
||||
ensureSecureImageRequest?: boolean;
|
||||
sourceMap?: { [key: string]: string };
|
||||
encode?: () => void;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
"url": string;
|
||||
"canonical": string;
|
||||
"title": string;
|
||||
"image": string;
|
||||
"author": string;
|
||||
"description": string;
|
||||
"keywords": string;
|
||||
"source": string;
|
||||
"og:url": string;
|
||||
"og:locale": string;
|
||||
"og:locale:alternate": string;
|
||||
"og:title": string;
|
||||
"og:type": string;
|
||||
"og:description": string;
|
||||
"og:determiner": string;
|
||||
"og:site_name": string;
|
||||
"og:image": string;
|
||||
"og:image:secure_url": string;
|
||||
"og:image:type": string;
|
||||
"og:image:width": string;
|
||||
"og:image:height": string;
|
||||
"article:published_time"?: string;
|
||||
"article:modified_time"?: string;
|
||||
"article:expiration_time"?: string;
|
||||
"article:author"?: string;
|
||||
"article:section"?: string;
|
||||
"article:tag"?: string;
|
||||
"og:article:published_time"?: string;
|
||||
"og:article:modified_time"?: string;
|
||||
"og:article:expiration_time"?: string;
|
||||
"og:article:author"?: string;
|
||||
"og:article:section"?: string;
|
||||
"og:article:tag"?: string;
|
||||
}
|
||||
}
|
||||
23
types/url-metadata/tsconfig.json
Normal file
23
types/url-metadata/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"url-metadata-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/url-metadata/tslint.json
Normal file
1
types/url-metadata/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
15
types/url-metadata/url-metadata-tests.ts
Normal file
15
types/url-metadata/url-metadata-tests.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as urlMetadata from "url-metadata";
|
||||
|
||||
const opts: urlMetadata.Options = {
|
||||
userAgent: "url-metadata-test",
|
||||
fromEmail: "testing@url-metadata.com",
|
||||
maxRedirects: 3,
|
||||
timeout: 10000,
|
||||
descriptionLength: 10000,
|
||||
ensureSecureImageRequest: true
|
||||
};
|
||||
const url = "https://google.com";
|
||||
|
||||
urlMetadata(url, opts).then((result: urlMetadata.Result) => {
|
||||
result; // $ExpectType Result
|
||||
});
|
||||
Reference in New Issue
Block a user