Comparing version 1.1.2 to 1.1.3
@@ -53,1 +53,4 @@ export declare class wikiError extends Error { | ||
} | ||
export declare class pdfError extends wikiError { | ||
constructor(message: string); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.eventsError = exports.mediaError = exports.relatedError = exports.introError = exports.preloadError = exports.infoboxError = exports.coordinatesError = exports.geoSearchError = exports.linksError = exports.categoriesError = exports.contentError = exports.htmlError = exports.imageError = exports.summaryError = exports.pageError = exports.searchError = exports.wikiError = void 0; | ||
exports.pdfError = exports.eventsError = exports.mediaError = exports.relatedError = exports.introError = exports.preloadError = exports.infoboxError = exports.coordinatesError = exports.geoSearchError = exports.linksError = exports.categoriesError = exports.contentError = exports.htmlError = exports.imageError = exports.summaryError = exports.pageError = exports.searchError = exports.wikiError = void 0; | ||
class wikiError extends Error { | ||
@@ -124,1 +124,8 @@ constructor(message, code) { | ||
exports.eventsError = eventsError; | ||
class pdfError extends wikiError { | ||
constructor(message) { | ||
super(message); | ||
this.name = 'pdfError'; | ||
} | ||
} | ||
exports.pdfError = pdfError; |
@@ -1,2 +0,2 @@ | ||
import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions } from './optionTypes'; | ||
import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions, pdfOptions } from './optionTypes'; | ||
import Page from './page'; | ||
@@ -262,3 +262,11 @@ import { coordinatesResult, eventResult, geoSearchResult, imageResult, langLinksResult, languageResult, mobileSections, relatedResult, title, wikiMediaResult, wikiSearchResult, wikiSummary, notFound } from './resultTypes'; | ||
mobileHtml(title: string, pageOptions?: pageOptions | undefined): Promise<notFound | string>; | ||
/** | ||
* Returns pdf of a given page | ||
* | ||
* @param title - The title of the page to query | ||
* @param pdfOptions - {@link pdfOptions | pdfOptions } | ||
* @returns Returns pdf format | ||
*/ | ||
pdf(title: string, pdfOptions?: pdfOptions | undefined): Promise<any>; | ||
}; | ||
export default wiki; |
@@ -557,2 +557,21 @@ "use strict"; | ||
}; | ||
/** | ||
* Returns pdf of a given page | ||
* | ||
* @param title - The title of the page to query | ||
* @param pdfOptions - {@link pdfOptions | pdfOptions } | ||
* @returns Returns pdf format | ||
*/ | ||
wiki.pdf = async (title, pdfOptions) => { | ||
try { | ||
if (pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.autoSuggest) { | ||
title = await utils_1.setTitleForPage(title); | ||
} | ||
const result = await page_1.pdf(title, pdfOptions); | ||
return result; | ||
} | ||
catch (error) { | ||
throw new errors_1.pdfError(error); | ||
} | ||
}; | ||
exports.default = wiki; | ||
@@ -559,0 +578,0 @@ // For CommonJS default export support |
@@ -0,0 +0,0 @@ export declare const MSGS: { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -28,1 +28,8 @@ export interface searchOptions { | ||
export declare type randomFormats = 'title' | 'summary' | 'related' | 'mobile-sections' | 'mobile-sections-lead'; | ||
export declare type format = 'a4' | 'letter' | 'legal'; | ||
export declare type pdfType = 'desktop' | 'mobile'; | ||
export interface pdfOptions { | ||
autoSuggest?: boolean; | ||
format?: format; | ||
type?: pdfType; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
import { coordinatesResult, imageResult, langLinksResult, notFound, pageResult, relatedResult, wikiMediaResult, wikiSummary } from './resultTypes'; | ||
import { listOptions, pageOptions } from './optionTypes'; | ||
import { listOptions, pageOptions, pdfOptions } from './optionTypes'; | ||
export declare class Page { | ||
@@ -206,2 +206,9 @@ pageid: number; | ||
mobileHtml: (pageOptions?: pageOptions | undefined) => Promise<notFound | string>; | ||
/** | ||
* Returns pdf of a given page | ||
* | ||
* @param pdfOptions - {@link pdfOptions | pdfOptions } | ||
* @returns Returns path string | ||
*/ | ||
pdf: (pdfOptions?: pdfOptions | undefined) => Promise<string>; | ||
runMethod(functionName: string): Promise<any>; | ||
@@ -391,2 +398,10 @@ } | ||
export declare const mobileHtml: (title: string, redirect?: boolean) => Promise<notFound | string>; | ||
/** | ||
* Returns pdf of a given page | ||
* | ||
* @param title - The title of the page to query | ||
* @param pdfOptions - {@link pdfOptions | pdfOptions } | ||
* @returns Returns pdf format | ||
*/ | ||
export declare const pdf: (title: string, pdfOptions?: pdfOptions | undefined) => Promise<string>; | ||
export default Page; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mobileHtml = exports.media = exports.related = exports.summary = exports.rawInfo = exports.tables = exports.infobox = exports.langLinks = exports.coordinates = exports.references = exports.links = exports.categories = exports.content = exports.html = exports.intro = exports.images = exports.Page = void 0; | ||
exports.pdf = exports.mobileHtml = exports.media = exports.related = exports.summary = exports.rawInfo = exports.tables = exports.infobox = exports.langLinks = exports.coordinates = exports.references = exports.links = exports.categories = exports.content = exports.html = exports.intro = exports.images = exports.Page = void 0; | ||
const errors_1 = require("./errors"); | ||
@@ -350,2 +350,17 @@ const request_1 = require("./request"); | ||
}; | ||
/** | ||
* Returns pdf of a given page | ||
* | ||
* @param pdfOptions - {@link pdfOptions | pdfOptions } | ||
* @returns Returns path string | ||
*/ | ||
this.pdf = async (pdfOptions) => { | ||
try { | ||
const result = await exports.pdf(this.title, pdfOptions); | ||
return result; | ||
} | ||
catch (error) { | ||
throw new errors_1.pdfError(error); | ||
} | ||
}; | ||
this.pageid = response.pageid; | ||
@@ -795,2 +810,21 @@ this.ns = response.ns; | ||
}; | ||
/** | ||
* Returns pdf of a given page | ||
* | ||
* @param title - The title of the page to query | ||
* @param pdfOptions - {@link pdfOptions | pdfOptions } | ||
* @returns Returns pdf format | ||
*/ | ||
exports.pdf = async (title, pdfOptions) => { | ||
try { | ||
let path = `page/pdf/${title}`; | ||
(pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.format) ? path += `/${pdfOptions.format}` : null; | ||
(pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.type) ? path += `/${pdfOptions.type}` : null; | ||
const result = request_1.returnRestUrl(path); | ||
return result; | ||
} | ||
catch (error) { | ||
throw new errors_1.pdfError(error); | ||
} | ||
}; | ||
exports.default = Page; |
declare function makeRequest(params: any, redirect?: boolean): Promise<any>; | ||
export declare function makeRestRequest(path: string, redirect?: boolean): Promise<any>; | ||
export declare function returnRestUrl(path: string): string; | ||
export declare function setAPIUrl(prefix: string): string; | ||
export default makeRequest; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setAPIUrl = exports.makeRestRequest = void 0; | ||
exports.setAPIUrl = exports.returnRestUrl = exports.makeRestRequest = void 0; | ||
const node_fetch_1 = require("node-fetch"); | ||
@@ -50,2 +50,3 @@ const errors_1 = require("./errors"); | ||
}; | ||
console.log(encodeURI(REST_API_URL + path)); | ||
const response = await node_fetch_1.default(encodeURI(REST_API_URL + path), options); | ||
@@ -65,2 +66,8 @@ let result = await response.text(); | ||
exports.makeRestRequest = makeRestRequest; | ||
//return rest uri | ||
function returnRestUrl(path) { | ||
const url = encodeURI(REST_API_URL + path); | ||
return url; | ||
} | ||
exports.returnRestUrl = returnRestUrl; | ||
//change language of both urls | ||
@@ -67,0 +74,0 @@ function setAPIUrl(prefix) { |
@@ -0,0 +0,0 @@ export interface wikiSearchResult { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export declare function isString(title: any): boolean; |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "wikipedia", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A JavaScript wrapper for the wikipedia apis", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
@@ -42,2 +42,3 @@ # WIKIPEDIA [![build](https://github.com/dopecodez/Wikipedia/workflows/build/badge.svg)](https://github.com/dopecodez/Wikipedia/actions) [![Test Coverage](https://api.codeclimate.com/v1/badges/a44c826dbef8c7f5ea45/test_coverage)](https://codeclimate.com/github/dopecodez/Wikipedia/test_coverage) [![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dopecodez/Wikipedia/issues) [![npm version](https://badge.fury.io/js/wikipedia.svg)](https://badge.fury.io/js/wikipedia) | ||
- Find articles by geographical location | ||
- Get a wikipedia page as a pdf document | ||
- Supports switching languages | ||
@@ -44,0 +45,0 @@ - Parses infoboxes using [infobox-parser](https://github.com/dijs/infobox-parser) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101261
2697
197