From d296a1a3d43e5b2cc02cacad9538043cc4a1065e Mon Sep 17 00:00:00 2001 From: Matt Voboril Date: Fri, 7 Aug 2020 11:59:57 -0500 Subject: [PATCH] fix: leverage only generated types (#203) --- package.json | 2 +- types/.gitkeep | 1 + types/src/Feed.d.ts | 90 -------------------------------------- types/src/FeedEmitter.d.ts | 88 ------------------------------------- types/src/FeedError.d.ts | 5 --- types/src/FeedItem.d.ts | 80 --------------------------------- types/src/FeedManager.d.ts | 26 ----------- 7 files changed, 2 insertions(+), 290 deletions(-) create mode 100644 types/.gitkeep delete mode 100644 types/src/Feed.d.ts delete mode 100644 types/src/FeedEmitter.d.ts delete mode 100644 types/src/FeedError.d.ts delete mode 100644 types/src/FeedItem.d.ts delete mode 100644 types/src/FeedManager.d.ts diff --git a/package.json b/package.json index 67b9d4e..cef8caf 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "3.0.0", "description": "Super RSS News Feed aggregator written in Node.js and ES6", "main": "src/FeedEmitter.js", - "types": "types/src/FeedEmitter.d.ts", + "types": "types/FeedEmitter.d.ts", "directories": { "test": "test/**/*.spec.js" }, diff --git a/types/.gitkeep b/types/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/types/.gitkeep @@ -0,0 +1 @@ + diff --git a/types/src/Feed.d.ts b/types/src/Feed.d.ts deleted file mode 100644 index ca1820e..0000000 --- a/types/src/Feed.d.ts +++ /dev/null @@ -1,90 +0,0 @@ -export = Feed; -/** - * Storage object for properties of a feed - * @typedef {Object} Feed - * @property {string} url Feed url - * @property {FeedItem[]} items items currently retrieved from the feed - * @property {number} refresh timeout between refreshes - * @property {string} userAgent User Agent string to fetch the feed with - * @property {string} eventName event name to use when emitting this feed - */ -declare class Feed { - constructor(data: any); - items: any[]; - refresh: number; - userAgent: string; - /** - * event name for this feed to emit when a new item becomes available - * @type {String} - */ - eventName: string; - /** - * Given a feed and item, try to find - * it inside the feed item list. We will use - * this to see if there's already an item inside - * the feed item list. If there is, we know it's - * not a new item. - * @param {FeedItem} item item specitics - * @returns {FeedItem} the matched element - */ - findItem(item: import("./FeedItem")): import("./FeedItem"); - /** - * Update the maximum history length based on the length of a feed retrieval - * @param {FeedItem[]} newItems new list of items to base the history length on - * @mutator - */ - updateHxLength(newItems: import("./FeedItem")[]): void; - maxHistoryLength: number; - /** - * Add an item to the feed - * @param {FeedItem} item Feed item. Indeterminant structure. - */ - addItem(item: import("./FeedItem")): void; - /** - * Fetch the data for this feed - * @returns {Promise} array of new feed items - */ - fetchData(): Promise; - /** - * Perform the feed parsing - * @param {FeedParser} feedparser feedparser instance to use for parsing a retrieved feed - */ - get(feedparser: import("feedparser")): void; - /** - * Private: handle errors inside the feed retrieval process - * @param {Error} error error to be handled - */ - handleError(error: Error): void; - /** - * Destroy feed - */ - destroy(): void; -} -declare namespace Feed { - export { Feed }; -} -/** - * Storage object for properties of a feed - */ -type Feed = { - /** - * Feed url - */ - url: string; - /** - * items currently retrieved from the feed - */ - items: import("./FeedItem")[]; - /** - * timeout between refreshes - */ - refresh: number; - /** - * User Agent string to fetch the feed with - */ - userAgent: string; - /** - * event name to use when emitting this feed - */ - eventName: string; -}; diff --git a/types/src/FeedEmitter.d.ts b/types/src/FeedEmitter.d.ts deleted file mode 100644 index 9a42f0e..0000000 --- a/types/src/FeedEmitter.d.ts +++ /dev/null @@ -1,88 +0,0 @@ -/// -export = FeedEmitter; -declare const FeedEmitter_base: typeof import("events").EventEmitter; -/** - * MAIN CLASS - * This is where we extend from TinyEmitter and absorve - * the #emit and #on methods to emit 'new-item' events - * when we have new feed items. - * @extends EventEmitter - */ -declare class FeedEmitter extends FeedEmitter_base { - /** - * Checks that the feed object is valid - * @param {Object} feed to validate - * @param {string} ua User Agent string to pass to feeds - */ - static validateFeedObject(feed: any, ua: string): void; - /** - * The constructor special method is called everytime - * we create a new instance of this "Class". - * @param {Object} [options={ userAgent: defaultUA }] [description] - */ - constructor(options?: any); - feedList: any[]; - /** - * If the user has specified a User Agent - * we will use that as the 'user-agent' header when - * making requests, otherwise we use the default option. - * @type {string} - */ - userAgent: string; - /** - * Whether or not to skip the normal emit event on first load - * @type {boolean} - */ - skipFirstLoad: boolean; - /** - * UserFeedConfig typedef - * @typedef {Object} UserFeedConfig - * @property {(string|string[])} url Url string or string array. Cannot be null or empty - * @property {Number} refresh Refresh cycle duration for the feed. - */ - /** - * ADD - * The #add method is one of the main ones. Basically it - * receives one parameter with the feed options, for example: - * { - * url: "http://www.nintendolife.com/feeds/news", - * refresh: 2000 - * } - * @param {UserFeedConfig[]} userFeedConfig user feed config - * @returns {Feed[]} - */ - add(...userFeedConfig: { - /** - * Url string or string array. Cannot be null or empty - */ - url: (string | string[]); - /** - * Refresh cycle duration for the feed. - */ - refresh: number; - }[]): import("./Feed")[]; - /** - * REMOVE - * This is a very simple method and its functionality is - * remove a feed from the feedList. - * @param {string} url URL to add - * @returns {Feed} item removed from list - */ - remove(url: string): import("./Feed"); - get list(): any[]; - /** - * DESTROY - * Remove all feeds from feedList - */ - destroy(): void; - addOrUpdateFeedList(feed: any): void; - findFeed(feed: any): any; - addToFeedList(feed: any): void; - /** - * Set up a recurring task to check for new items - * @param {Object} feed Feed to be removed - * @returns {Interval} interval for updating the feed - */ - createSetInterval(feed: any): any; - removeFromFeedList(feed: any): void; -} diff --git a/types/src/FeedError.d.ts b/types/src/FeedError.d.ts deleted file mode 100644 index 393abe6..0000000 --- a/types/src/FeedError.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export = FeedError; -declare class FeedError extends Error { - constructor(message: any, type: any, feed: any); - feed: any; -} diff --git a/types/src/FeedItem.d.ts b/types/src/FeedItem.d.ts deleted file mode 100644 index 87d39cc..0000000 --- a/types/src/FeedItem.d.ts +++ /dev/null @@ -1,80 +0,0 @@ -export = FeedItem; -/** - * @typedef {Object} FeedItem - * @property {string} title Title of the feed item - * @property {string} description description of the feed item - * @property {string} summary summary on the feed item - * @property {Date|null} date date the item "occurred" - * @property {Date|null} pubdate Published date of the item - * @property {string} link link to item relating to the feed - * @property {string} origlink original link - * @property {string} author author string - * @property {string} guid globally unique identifying string - * @property {string} comments comment string(s) - * @property {Object} image Image, indeterminant format - * @property {string} categories categories of the feed - * @property {Object} enclosures - * @property {Object} meta - * @property {any} [x] String-keyed object. Various more are allowed than are representable - */ -declare class FeedItem { -} -declare namespace FeedItem { - export { FeedItem }; -} -type FeedItem = { - /** - * Title of the feed item - */ - title: string; - /** - * description of the feed item - */ - description: string; - /** - * summary on the feed item - */ - summary: string; - /** - * date the item "occurred" - */ - date: Date | null; - /** - * Published date of the item - */ - pubdate: Date | null; - /** - * link to item relating to the feed - */ - link: string; - /** - * original link - */ - origlink: string; - /** - * author string - */ - author: string; - /** - * globally unique identifying string - */ - guid: string; - /** - * comment string(s) - */ - comments: string; - /** - * Image, indeterminant format - */ - image: any; - /** - * categories of the feed - */ - categories: string; - enclosures: any; - meta: any; - /** - * String-keyed object. Various more are allowed than are representable - */ - x?: any; -}; diff --git a/types/src/FeedManager.d.ts b/types/src/FeedManager.d.ts deleted file mode 100644 index 058b442..0000000 --- a/types/src/FeedManager.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export = FeedManager; -declare class FeedManager { - constructor(emitter: any, feed: any); - instance: any; - feed: any; - /** - * Sort all received items since we want to - * emit them in ascending order. - * @param {Object} data data to sort items on - */ - sortItemsByDate(data: any): void; - /** - * Put all new items inside a "newItems" property - * @param {Object} data Data to mutate - */ - identifyNewItems(data: any): void; - /** - * Now that we have all the new items, add them to the - feed item list. - * @param {Object} data data to mutate - * @param {boolean} firstload Whether or not this is the first laod - */ - populateNewItemsInFeed(data: any, firstload: boolean): void; - onError(error: any): void; - getContent(firstload: any): Promise; -}