Socket
Socket
Sign inDemoInstall

wikipedia

Package Overview
Dependencies
9
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.8 to 1.1.9

6

dist/index.d.ts

@@ -1,2 +0,2 @@

import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions, fcOptions, pdfOptions } from './optionTypes';
import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions, fcOptions, randomFormats, pdfOptions, citationFormat } from './optionTypes';
import Page from './page';

@@ -263,3 +263,3 @@ import { coordinatesResult, eventResult, featuredContentResult, geoSearchResult, imageResult, langLinksResult, languageResult, mobileSections, relatedResult, title, wikiMediaResult, wikiSearchResult, wikiSummary, notFound } from './resultTypes';

*/
random(format?: "summary" | "related" | "title" | "mobile-sections" | "mobile-sections-lead" | undefined): Promise<wikiSummary | title | relatedResult | mobileSections | string>;
random(format?: randomFormats): Promise<wikiSummary | title | relatedResult | mobileSections | string>;
/**

@@ -289,3 +289,3 @@ * Returns mobile-optimised HTML of a page

*/
citation(query: string, format?: "mediawiki" | "mediawiki-basefields" | "zotero" | "bibtex" | "wikibase" | undefined, language?: string | undefined): Promise<any>;
citation(query: string, format?: citationFormat, language?: string): Promise<any>;
};

@@ -292,0 +292,0 @@ export default wiki;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -10,3 +14,3 @@ if (k2 === undefined) k2 = k;

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -48,3 +52,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

(searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.suggestion) ? searchParams['srinfo'] = 'suggestion' : null;
const response = await request_1.default(searchParams);
const response = await (0, request_1.default)(searchParams);
const result = {

@@ -73,3 +77,3 @@ results: response.query.search,

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}

@@ -81,6 +85,6 @@ let pageParams = {

};
pageParams = utils_1.setPageIdOrTitleParam(pageParams, title);
const response = await request_1.default(pageParams);
pageParams = (0, utils_1.setPageIdOrTitleParam)(pageParams, title);
const response = await (0, request_1.default)(pageParams);
let pageInfo = response.query.pages;
const pageId = utils_1.setPageId(pageParams, response);
const pageId = (0, utils_1.setPageId)(pageParams, response);
pageInfo = pageInfo[pageId];

@@ -118,5 +122,5 @@ if (pageInfo.missing == '') {

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const result = await page_1.intro(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, page_1.intro)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return result;

@@ -141,5 +145,5 @@ }

if (listOptions === null || listOptions === void 0 ? void 0 : listOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const result = await page_1.images(title, listOptions);
const result = await (0, page_1.images)(title, listOptions);
return result;

@@ -164,5 +168,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const result = await page_1.summary(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, page_1.summary)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return result;

@@ -189,5 +193,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const result = await page_1.html(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, page_1.html)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return result;

@@ -212,5 +216,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.content(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const response = await (0, page_1.content)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return response.result;

@@ -235,5 +239,5 @@ }

if (listOptions === null || listOptions === void 0 ? void 0 : listOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.categories(title, listOptions);
const response = await (0, page_1.categories)(title, listOptions);
return response;

@@ -261,5 +265,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.related(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const response = await (0, page_1.related)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return response;

@@ -287,5 +291,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.media(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const response = await (0, page_1.media)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return response;

@@ -310,5 +314,5 @@ }

if (listOptions === null || listOptions === void 0 ? void 0 : listOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.links(title, listOptions);
const response = await (0, page_1.links)(title, listOptions);
return response;

@@ -333,5 +337,5 @@ }

if (listOptions === null || listOptions === void 0 ? void 0 : listOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.references(title, listOptions);
const response = await (0, page_1.references)(title, listOptions);
return response;

@@ -356,5 +360,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.coordinates(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const response = await (0, page_1.coordinates)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return response;

@@ -379,5 +383,5 @@ }

if (listOptions === null || listOptions === void 0 ? void 0 : listOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.langLinks(title, listOptions);
const response = await (0, page_1.langLinks)(title, listOptions);
return response;

@@ -402,5 +406,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.infobox(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const response = await (0, page_1.infobox)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return response;

@@ -425,5 +429,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const response = await page_1.tables(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const response = await (0, page_1.tables)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return response;

@@ -449,3 +453,3 @@ }

};
const response = await request_1.default(langParams);
const response = await (0, request_1.default)(langParams);
const languages = [];

@@ -470,3 +474,3 @@ for (const lang of response.query.languages) {

wiki.setLang = (language) => {
const apiUrl = request_1.setAPIUrl(language);
const apiUrl = (0, request_1.setAPIUrl)(language);
return apiUrl;

@@ -494,3 +498,3 @@ };

};
const results = await request_1.default(geoSearchParams);
const results = await (0, request_1.default)(geoSearchParams);
const searchPages = results.query.geosearch;

@@ -521,3 +525,3 @@ return searchPages;

};
const result = await request_1.default(suggestParams);
const result = await (0, request_1.default)(suggestParams);
return ((_b = (_a = result.query) === null || _a === void 0 ? void 0 : _a.searchinfo) === null || _b === void 0 ? void 0 : _b.suggestion) ? (_d = (_c = result.query) === null || _c === void 0 ? void 0 : _c.searchinfo) === null || _d === void 0 ? void 0 : _d.suggestion : null;

@@ -541,6 +545,6 @@ }

const type = eventOptions.type || 'all';
const mm = (eventOptions.month || utils_1.getCurrentMonth()).toString().padStart(2, "0");
const dd = (eventOptions.day || utils_1.getCurrentDay()).toString().padStart(2, "0");
const mm = (eventOptions.month || (0, utils_1.getCurrentMonth)()).toString().padStart(2, "0");
const dd = (eventOptions.day || (0, utils_1.getCurrentDay)()).toString().padStart(2, "0");
const path = `feed/onthisday/${type}/${mm}/${dd}`;
const result = await request_1.makeRestRequest(path, true);
const result = await (0, request_1.makeRestRequest)(path, true);
return result;

@@ -563,7 +567,7 @@ }

try {
const yyyy = (fcOptions.year || utils_1.getCurrentYear()).toString();
const mm = (fcOptions.month || utils_1.getCurrentMonth()).toString().padStart(2, "0");
const dd = (fcOptions.day || utils_1.getCurrentDay()).toString().padStart(2, "0");
const yyyy = (fcOptions.year || (0, utils_1.getCurrentYear)()).toString();
const mm = (fcOptions.month || (0, utils_1.getCurrentMonth)()).toString().padStart(2, "0");
const dd = (fcOptions.day || (0, utils_1.getCurrentDay)()).toString().padStart(2, "0");
const path = `feed/featured/${yyyy}/${mm}/${dd}`;
const result = await request_1.makeRestRequest(path, true);
const result = await (0, request_1.makeRestRequest)(path, true);
return result;

@@ -587,3 +591,3 @@ }

const path = `page/random/${format}`;
const result = await request_1.makeRestRequest(path);
const result = await (0, request_1.makeRestRequest)(path);
return result;

@@ -605,5 +609,5 @@ }

if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const result = await page_1.mobileHtml(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, page_1.mobileHtml)(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return result;

@@ -625,5 +629,5 @@ }

if (pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
title = await (0, utils_1.setTitleForPage)(title);
}
const result = await page_1.pdf(title, pdfOptions);
const result = await (0, page_1.pdf)(title, pdfOptions);
return result;

@@ -645,3 +649,3 @@ }

try {
const result = await page_1.citation(query, format, language);
const result = await (0, page_1.citation)(query, format, language);
return result;

@@ -648,0 +652,0 @@ }

import { coordinatesResult, imageResult, langLinksResult, notFound, pageResult, relatedResult, wikiMediaResult, wikiSummary } from './resultTypes';
import { listOptions, pageOptions, pdfOptions } from './optionTypes';
import { citationFormat, listOptions, pageOptions, pdfOptions } from './optionTypes';
export declare class Page {

@@ -413,3 +413,3 @@ pageid: number;

*/
export declare const citation: (query: string, format?: "mediawiki" | "mediawiki-basefields" | "zotero" | "bibtex" | "wikibase" | undefined, language?: string | undefined) => Promise<any>;
export declare const citation: (query: string, format?: citationFormat, language?: string) => Promise<any>;
export default Page;

@@ -25,3 +25,3 @@ "use strict";

if (!this._intro) {
const response = await exports.intro(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const response = await (0, exports.intro)(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._intro = response;

@@ -48,3 +48,3 @@ }

if (!this._images) {
const result = await exports.images(this.pageid.toString(), listOptions);
const result = await (0, exports.images)(this.pageid.toString(), listOptions);
this._images = result;

@@ -72,3 +72,3 @@ }

if (!this._summary) {
const result = await exports.summary(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.summary)(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._summary = result;

@@ -97,3 +97,3 @@ }

if (!this._html) {
const result = await exports.html(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.html)(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._html = result;

@@ -120,3 +120,3 @@ }

if (!this._content) {
const result = await exports.content(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.content)(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this.parentid = result.ids.parentId;

@@ -145,3 +145,3 @@ this.revid = result.ids.revId;

if (!this._categories) {
const result = await exports.categories(this.pageid.toString(), listOptions);
const result = await (0, exports.categories)(this.pageid.toString(), listOptions);
this._categories = result;

@@ -168,3 +168,3 @@ }

if (!this._links) {
const result = await exports.links(this.pageid.toString(), listOptions);
const result = await (0, exports.links)(this.pageid.toString(), listOptions);
this._links = result;

@@ -191,3 +191,3 @@ }

if (!this._references) {
const result = await exports.references(this.pageid.toString(), listOptions);
const result = await (0, exports.references)(this.pageid.toString(), listOptions);
this._references = result;

@@ -214,3 +214,3 @@ }

if (!this._coordinates) {
const result = await exports.coordinates(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.coordinates)(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._coordinates = result;

@@ -237,3 +237,3 @@ }

if (!this._langLinks) {
const result = await exports.langLinks(this.pageid.toString(), listOptions);
const result = await (0, exports.langLinks)(this.pageid.toString(), listOptions);
this._langLinks = result;

@@ -260,3 +260,3 @@ }

if (!this._infobox) {
const result = await exports.infobox(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.infobox)(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._infobox = result;

@@ -283,3 +283,3 @@ }

if (!this._tables) {
const result = await exports.tables(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.tables)(this.pageid.toString(), pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._tables = result;

@@ -309,3 +309,3 @@ }

if (!this._related) {
const result = await exports.related(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.related)(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._related = result;

@@ -335,3 +335,3 @@ }

if (!this._media) {
const result = await exports.media(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.media)(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._media = result;

@@ -355,3 +355,3 @@ }

if (!this._mobileHtml) {
const result = await exports.mobileHtml(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
const result = await (0, exports.mobileHtml)(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._mobileHtml = result;

@@ -373,3 +373,3 @@ }

try {
const result = await exports.pdf(this.title, pdfOptions);
const result = await (0, exports.pdf)(this.title, pdfOptions);
return result;

@@ -415,3 +415,3 @@ }

*/
exports.images = async (title, listOptions) => {
const images = async (title, listOptions) => {
try {

@@ -424,4 +424,4 @@ let imageOptions = {

};
imageOptions = utils_1.setPageIdOrTitleParam(imageOptions, title);
const response = await request_1.default(imageOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
imageOptions = (0, utils_1.setPageIdOrTitleParam)(imageOptions, title);
const response = await (0, request_1.default)(imageOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const images = [];

@@ -440,2 +440,3 @@ const imageKeys = Object.keys(response.query.pages);

};
exports.images = images;
/**

@@ -451,3 +452,3 @@ * Returns the intro present in a wiki page

*/
exports.intro = async (title, redirect = true) => {
const intro = async (title, redirect = true) => {
var _a;

@@ -460,5 +461,5 @@ try {

};
introOptions = utils_1.setPageIdOrTitleParam(introOptions, title);
const response = await request_1.default(introOptions, redirect);
const pageId = utils_1.setPageId(introOptions, response);
introOptions = (0, utils_1.setPageIdOrTitleParam)(introOptions, title);
const response = await (0, request_1.default)(introOptions, redirect);
const pageId = (0, utils_1.setPageId)(introOptions, response);
return (_a = response === null || response === void 0 ? void 0 : response.query) === null || _a === void 0 ? void 0 : _a.pages[pageId].extract;

@@ -470,2 +471,3 @@ }

};
exports.intro = intro;
/**

@@ -483,3 +485,3 @@ * Returns the html content of a page

*/
exports.html = async (title, redirect = true) => {
const html = async (title, redirect = true) => {
try {

@@ -492,5 +494,5 @@ let htmlOptions = {

};
htmlOptions = utils_1.setPageIdOrTitleParam(htmlOptions, title);
const response = await request_1.default(htmlOptions, redirect);
const pageId = utils_1.setPageId(htmlOptions, response);
htmlOptions = (0, utils_1.setPageIdOrTitleParam)(htmlOptions, title);
const response = await (0, request_1.default)(htmlOptions, redirect);
const pageId = (0, utils_1.setPageId)(htmlOptions, response);
return response.query.pages[pageId].revisions[0]['*'];

@@ -502,2 +504,3 @@ }

};
exports.html = html;
/**

@@ -513,3 +516,3 @@ * Returns the plain text content of a page as well as parent id and revision id

*/
exports.content = async (title, redirect = true) => {
const content = async (title, redirect = true) => {
try {

@@ -521,5 +524,5 @@ let contentOptions = {

};
contentOptions = utils_1.setPageIdOrTitleParam(contentOptions, title);
const response = await request_1.default(contentOptions, redirect);
const pageId = utils_1.setPageId(contentOptions, response);
contentOptions = (0, utils_1.setPageIdOrTitleParam)(contentOptions, title);
const response = await (0, request_1.default)(contentOptions, redirect);
const pageId = (0, utils_1.setPageId)(contentOptions, response);
const result = response['query']['pages'][pageId]['extract'];

@@ -539,2 +542,3 @@ const ids = {

};
exports.content = content;
/**

@@ -550,3 +554,3 @@ * Returns the cetegories present in page

*/
exports.categories = async (title, listOptions) => {
const categories = async (title, listOptions) => {
try {

@@ -557,5 +561,5 @@ let categoryOptions = {

};
categoryOptions = utils_1.setPageIdOrTitleParam(categoryOptions, title);
const response = await request_1.default(categoryOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = utils_1.setPageId(categoryOptions, response);
categoryOptions = (0, utils_1.setPageIdOrTitleParam)(categoryOptions, title);
const response = await (0, request_1.default)(categoryOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = (0, utils_1.setPageId)(categoryOptions, response);
return response.query.pages[pageId].categories.map((category) => category.title);

@@ -567,2 +571,3 @@ }

};
exports.categories = categories;
/**

@@ -578,3 +583,3 @@ * Returns the links present in page

*/
exports.links = async (title, listOptions) => {
const links = async (title, listOptions) => {
try {

@@ -586,5 +591,5 @@ let linksOptions = {

};
linksOptions = utils_1.setPageIdOrTitleParam(linksOptions, title);
const response = await request_1.default(linksOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = utils_1.setPageId(linksOptions, response);
linksOptions = (0, utils_1.setPageIdOrTitleParam)(linksOptions, title);
const response = await (0, request_1.default)(linksOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = (0, utils_1.setPageId)(linksOptions, response);
const result = response.query.pages[pageId].links.map((link) => link.title);

@@ -597,2 +602,3 @@ return result;

};
exports.links = links;
/**

@@ -608,3 +614,3 @@ * Returns the references of external links present in page

*/
exports.references = async (title, listOptions) => {
const references = async (title, listOptions) => {
try {

@@ -615,5 +621,5 @@ let extLinksOptions = {

};
extLinksOptions = utils_1.setPageIdOrTitleParam(extLinksOptions, title);
const response = await request_1.default(extLinksOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = utils_1.setPageId(extLinksOptions, response);
extLinksOptions = (0, utils_1.setPageIdOrTitleParam)(extLinksOptions, title);
const response = await (0, request_1.default)(extLinksOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = (0, utils_1.setPageId)(extLinksOptions, response);
const result = response.query.pages[pageId].extlinks.map((link) => link['*']);

@@ -626,2 +632,3 @@ return result;

};
exports.references = references;
/**

@@ -637,3 +644,3 @@ * Returns the coordinates of a page

*/
exports.coordinates = async (title, redirect = true) => {
const coordinates = async (title, redirect = true) => {
try {

@@ -643,5 +650,5 @@ let coordinatesOptions = {

};
coordinatesOptions = utils_1.setPageIdOrTitleParam(coordinatesOptions, title);
const response = await request_1.default(coordinatesOptions, redirect);
const pageId = utils_1.setPageId(coordinatesOptions, response);
coordinatesOptions = (0, utils_1.setPageIdOrTitleParam)(coordinatesOptions, title);
const response = await (0, request_1.default)(coordinatesOptions, redirect);
const pageId = (0, utils_1.setPageId)(coordinatesOptions, response);
const coordinates = response.query.pages[pageId].coordinates;

@@ -654,2 +661,3 @@ return coordinates ? coordinates[0] : null;

};
exports.coordinates = coordinates;
/**

@@ -665,3 +673,3 @@ * Returns the language links present in the page

*/
exports.langLinks = async (title, listOptions) => {
const langLinks = async (title, listOptions) => {
try {

@@ -673,5 +681,5 @@ let languageOptions = {

};
languageOptions = utils_1.setPageIdOrTitleParam(languageOptions, title);
const response = await request_1.default(languageOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = utils_1.setPageId(languageOptions, response);
languageOptions = (0, utils_1.setPageIdOrTitleParam)(languageOptions, title);
const response = await (0, request_1.default)(languageOptions, listOptions === null || listOptions === void 0 ? void 0 : listOptions.redirect);
const pageId = (0, utils_1.setPageId)(languageOptions, response);
const result = response.query.pages[pageId].langlinks.map((link) => {

@@ -690,2 +698,3 @@ return {

};
exports.langLinks = langLinks;
/**

@@ -701,3 +710,3 @@ * Returns the infobox content of page if present

*/
exports.infobox = async (title, redirect = true) => {
const infobox = async (title, redirect = true) => {
try {

@@ -709,3 +718,3 @@ const infoboxOptions = {

};
const fullInfo = await exports.rawInfo(title, infoboxOptions, redirect);
const fullInfo = await (0, exports.rawInfo)(title, infoboxOptions, redirect);
const info = infoboxParser(fullInfo).general;

@@ -718,2 +727,3 @@ return info;

};
exports.infobox = infobox;
/**

@@ -729,3 +739,3 @@ * Returns the table content of page if present

*/
exports.tables = async (title, redirect = true) => {
const tables = async (title, redirect = true) => {
try {

@@ -736,3 +746,3 @@ const tableOptions = {

};
const fullInfo = await exports.rawInfo(title, tableOptions, redirect);
const fullInfo = await (0, exports.rawInfo)(title, tableOptions, redirect);
const info = infoboxParser(fullInfo).tables;

@@ -745,2 +755,3 @@ return info;

};
exports.tables = tables;
/**

@@ -757,11 +768,11 @@ * Returns the raw info of the page

*/
exports.rawInfo = async (title, options, redirect = true) => {
const rawInfo = async (title, options, redirect = true) => {
var _a;
try {
options = utils_1.setPageIdOrTitleParam(options, title);
const response = await request_1.default(options, redirect);
options = (0, utils_1.setPageIdOrTitleParam)(options, title);
const response = await (0, request_1.default)(options, redirect);
if (!((_a = response.query) === null || _a === void 0 ? void 0 : _a.pages)) {
throw new errors_1.wikiError(messages_1.MSGS.INFOBOX_NOT_EXIST);
}
const pageId = utils_1.setPageId(options, response);
const pageId = (0, utils_1.setPageId)(options, response);
const data = response.query.pages[pageId]['revisions'][0];

@@ -774,2 +785,3 @@ return data ? data['*'] : '';

};
exports.rawInfo = rawInfo;
//REST-API Requests based on https://en.wikipedia.org/api/rest_v1/#/

@@ -787,6 +799,6 @@ //APIs seems to support only title parameters which is a drawback

*/
exports.summary = async (title, redirect = true) => {
const summary = async (title, redirect = true) => {
try {
const path = 'page/summary/' + title.replace(" ", "_");
const response = await request_1.makeRestRequest(path, redirect);
const response = await (0, request_1.makeRestRequest)(path, redirect);
return response;

@@ -798,2 +810,3 @@ }

};
exports.summary = summary;
/**

@@ -812,6 +825,6 @@ * Returns summaries for 20 pages related to the given page. Summaries include page title, namespace

*/
exports.related = async (title, redirect = true) => {
const related = async (title, redirect = true) => {
try {
const path = 'page/related/' + title.replace(" ", "_");
const response = await request_1.makeRestRequest(path, redirect);
const response = await (0, request_1.makeRestRequest)(path, redirect);
return response;

@@ -823,2 +836,3 @@ }

};
exports.related = related;
/**

@@ -837,6 +851,6 @@ * Gets the list of media items (images, audio, and video) in the

*/
exports.media = async (title, redirect = true) => {
const media = async (title, redirect = true) => {
try {
const path = 'page/media-list/' + title.replace(" ", "_");
const response = await request_1.makeRestRequest(path, redirect);
const response = await (0, request_1.makeRestRequest)(path, redirect);
return response;

@@ -848,2 +862,3 @@ }

};
exports.media = media;
/**

@@ -856,6 +871,6 @@ * Returns mobile-optimised HTML of a page

*/
exports.mobileHtml = async (title, redirect = true) => {
const mobileHtml = async (title, redirect = true) => {
try {
const path = `page/mobile-html/${title}`;
const result = await request_1.makeRestRequest(path, redirect);
const result = await (0, request_1.makeRestRequest)(path, redirect);
return result;

@@ -867,2 +882,3 @@ }

};
exports.mobileHtml = mobileHtml;
/**

@@ -875,3 +891,3 @@ * Returns pdf of a given page

*/
exports.pdf = async (title, pdfOptions) => {
const pdf = async (title, pdfOptions) => {
try {

@@ -881,3 +897,3 @@ let path = `page/pdf/${title}`;

(pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.type) ? path += `/${pdfOptions.type}` : null;
const result = request_1.returnRestUrl(path);
const result = (0, request_1.returnRestUrl)(path);
return result;

@@ -889,2 +905,3 @@ }

};
exports.pdf = pdf;
/**

@@ -898,3 +915,3 @@ * Returns citation of a given page, or query string

*/
exports.citation = async (query, format, language) => {
const citation = async (query, format, language) => {
try {

@@ -905,3 +922,3 @@ let path = `data/citation`;

language ? path += `/${language}` : null;
const result = await request_1.makeRestRequest(path);
const result = await (0, request_1.makeRestRequest)(path);
return result;

@@ -913,2 +930,3 @@ }

};
exports.citation = citation;
exports.default = Page;

@@ -24,3 +24,3 @@ "use strict";

headers: {
'User-Agent': USER_AGENT,
'Api-User-Agent': USER_AGENT,
}

@@ -32,3 +32,3 @@ };

});
const response = await node_fetch_1.default(encodeURI(API_URL + searchParam), options);
const response = await (0, node_fetch_1.default)(encodeURI(API_URL + searchParam), options);
const result = await response.json();

@@ -49,6 +49,6 @@ return result;

headers: {
'User-Agent': USER_AGENT
'Api-User-Agent': USER_AGENT
}
};
const response = await node_fetch_1.default(encodeURI(REST_API_URL + path), options);
const response = await (0, node_fetch_1.default)(encodeURI(REST_API_URL + path), options);
let result = await response.text();

@@ -55,0 +55,0 @@ try {

@@ -111,6 +111,8 @@ export interface wikiSearchResult {

rank: number;
view_history: [{
date: string;
views: number;
}];
view_history: [
{
date: string;
views: number;
}
];
}

@@ -135,26 +137,36 @@ export interface wikiMediaResult {

export interface eventResult {
births?: [{
text: string;
pages: Array<wikiSummary>;
year?: number;
}];
deaths?: [{
text: string;
pages: Array<wikiSummary>;
year?: number;
}];
events?: [{
text: string;
pages: Array<wikiSummary>;
year?: number;
}];
holidays?: [{
text: string;
pages: Array<wikiSummary>;
}];
selected?: [{
text: string;
pages: Array<wikiSummary>;
year?: number;
}];
births?: [
{
text: string;
pages: Array<wikiSummary>;
year?: number;
}
];
deaths?: [
{
text: string;
pages: Array<wikiSummary>;
year?: number;
}
];
events?: [
{
text: string;
pages: Array<wikiSummary>;
year?: number;
}
];
holidays?: [
{
text: string;
pages: Array<wikiSummary>;
}
];
selected?: [
{
text: string;
pages: Array<wikiSummary>;
year?: number;
}
];
}

@@ -278,11 +290,15 @@ export interface titleItem {

};
news: [{
links: Array<wikiSummary>;
story: string;
}];
onthisday: [{
text: string;
pages: Array<wikiSummary>;
year: number;
}];
news: [
{
links: Array<wikiSummary>;
story: string;
}
];
onthisday: [
{
text: string;
pages: Array<wikiSummary>;
year: number;
}
];
}
{
"name": "wikipedia",
"version": "1.1.8",
"version": "1.1.9",
"description": "A JavaScript wrapper for the wikipedia apis",

@@ -35,3 +35,3 @@ "main": "dist",

"ts-jest": "^26.4.3",
"typescript": "^3.8.3"
"typescript": "^4.4.4"
},

@@ -38,0 +38,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc