Comparing version 1.1.6 to 1.1.7
@@ -53,2 +53,5 @@ export declare class wikiError extends Error { | ||
} | ||
export declare class fcError extends wikiError { | ||
constructor(message: string); | ||
} | ||
export declare class pdfError extends wikiError { | ||
@@ -55,0 +58,0 @@ constructor(message: string); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.citationError = 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; | ||
exports.citationError = exports.pdfError = exports.fcError = 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,2 +124,9 @@ constructor(message, code) { | ||
exports.eventsError = eventsError; | ||
class fcError extends wikiError { | ||
constructor(message) { | ||
super(message); | ||
this.name = 'featuredContentError'; | ||
} | ||
} | ||
exports.fcError = fcError; | ||
class pdfError extends wikiError { | ||
@@ -126,0 +133,0 @@ constructor(message) { |
@@ -1,4 +0,4 @@ | ||
import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions, pdfOptions } from './optionTypes'; | ||
import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions, fcOptions, pdfOptions } from './optionTypes'; | ||
import Page from './page'; | ||
import { coordinatesResult, eventResult, geoSearchResult, imageResult, langLinksResult, languageResult, mobileSections, relatedResult, title, wikiMediaResult, wikiSearchResult, wikiSummary, notFound } from './resultTypes'; | ||
import { coordinatesResult, eventResult, featuredContentResult, geoSearchResult, imageResult, langLinksResult, languageResult, mobileSections, relatedResult, title, wikiMediaResult, wikiSearchResult, wikiSummary, notFound } from './resultTypes'; | ||
/** | ||
@@ -248,2 +248,12 @@ * The default wiki export | ||
/** | ||
* Returns featured content for a given day | ||
* | ||
* @remarks | ||
* The api returns content featured at a particular date | ||
* | ||
* @param fcOptions - the year/month/day of featured content by {@link fcOptions | eventOptions} | ||
* @returns Returns the results as array of {@link fcResult | fcResult} | ||
*/ | ||
featuredContent(fcOptions?: fcOptions): Promise<featuredContentResult>; | ||
/** | ||
* Returns a random page | ||
@@ -250,0 +260,0 @@ * |
@@ -530,2 +530,24 @@ "use strict"; | ||
/** | ||
* Returns featured content for a given day | ||
* | ||
* @remarks | ||
* The api returns content featured at a particular date | ||
* | ||
* @param fcOptions - the year/month/day of featured content by {@link fcOptions | eventOptions} | ||
* @returns Returns the results as array of {@link fcResult | fcResult} | ||
*/ | ||
wiki.featuredContent = async (fcOptions = {}) => { | ||
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 path = `feed/featured/${yyyy}/${mm}/${dd}`; | ||
const result = await request_1.makeRestRequest(path, true); | ||
return result; | ||
} | ||
catch (error) { | ||
throw new errors_1.fcError(error); | ||
} | ||
}; | ||
/** | ||
* Returns a random page | ||
@@ -532,0 +554,0 @@ * |
@@ -26,2 +26,7 @@ export interface searchOptions { | ||
} | ||
export interface fcOptions { | ||
year?: string; | ||
month?: string; | ||
day?: string; | ||
} | ||
export declare type eventTypes = 'all' | 'selected' | 'births' | 'deaths' | 'events' | 'holidays'; | ||
@@ -28,0 +33,0 @@ export declare type randomFormats = 'title' | 'summary' | 'related' | 'mobile-sections' | 'mobile-sections-lead'; |
@@ -108,2 +108,10 @@ export interface wikiSearchResult { | ||
} | ||
export interface MostRead extends wikiSummary { | ||
views: number; | ||
rank: number; | ||
view_history: [{ | ||
date: string; | ||
views: number; | ||
}]; | ||
} | ||
export interface wikiMediaResult { | ||
@@ -222,2 +230,9 @@ revision: string; | ||
} | ||
export interface Artist extends htmlText { | ||
name: string; | ||
user_page?: string; | ||
} | ||
export interface Description extends htmlText { | ||
lang: string; | ||
} | ||
export interface notFound { | ||
@@ -230,1 +245,44 @@ type: string; | ||
} | ||
export interface featuredContentResult { | ||
tfa: wikiSummary; | ||
mostread: { | ||
date: string; | ||
articles: Array<wikiSummary>; | ||
}; | ||
image: { | ||
title: string; | ||
thumbnail: { | ||
source: string; | ||
width: number; | ||
height: number; | ||
}; | ||
image: { | ||
source: string; | ||
width: number; | ||
height: number; | ||
}; | ||
file_page: string; | ||
artist: Artist; | ||
credit: htmlText; | ||
license: { | ||
type: string; | ||
code: string; | ||
}; | ||
description: Description; | ||
wb_entity_id: string; | ||
structured: { | ||
captions: { | ||
[key: string]: string; | ||
}; | ||
}; | ||
}; | ||
news: [{ | ||
links: Array<wikiSummary>; | ||
story: string; | ||
}]; | ||
onthisday: [{ | ||
text: string; | ||
pages: Array<wikiSummary>; | ||
year: number; | ||
}]; | ||
} |
@@ -5,3 +5,4 @@ export declare function isString(title: any): boolean; | ||
export declare function setPageId(params: any, results: any): number; | ||
export declare function getCurrentYear(): number; | ||
export declare function getCurrentMonth(): number; | ||
export declare function getCurrentDay(): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCurrentDay = exports.getCurrentMonth = exports.setPageId = exports.setPageIdOrTitleParam = exports.setTitleForPage = exports.isString = void 0; | ||
exports.getCurrentDay = exports.getCurrentMonth = exports.getCurrentYear = exports.setPageId = exports.setPageIdOrTitleParam = exports.setTitleForPage = exports.isString = void 0; | ||
const _1 = require("."); | ||
@@ -47,2 +47,9 @@ const errors_1 = require("./errors"); | ||
exports.setPageId = setPageId; | ||
//Get current year | ||
function getCurrentYear() { | ||
const date = new Date(); | ||
const year = date.getFullYear(); | ||
return (year); | ||
} | ||
exports.getCurrentYear = getCurrentYear; | ||
//Get current month | ||
@@ -49,0 +56,0 @@ function getCurrentMonth() { |
{ | ||
"name": "wikipedia", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "A JavaScript wrapper for the wikipedia apis", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
@@ -198,6 +198,6 @@ # 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) | ||
<td align="center"> | ||
<a href="https://github.com/zaccolley"> | ||
<img src="https://avatars.githubusercontent.com/u/2591901?v=4" width="100;" alt="zaccolley"/> | ||
<a href="https://github.com/zactopus"> | ||
<img src="https://avatars.githubusercontent.com/u/2591901?v=4" width="100;" alt="zactopus"/> | ||
<br /> | ||
<sub><b>Zac Colley</b></sub> | ||
<sub><b>Zac [they/them]</b></sub> | ||
</a> | ||
@@ -204,0 +204,0 @@ </td></tr> |
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
108227
2895