Update definitions

pull/81/head
MillenniumEarl 2021-03-05 13:05:49 +01:00
parent ca11a442ed
commit eace0e6056
32 changed files with 1199 additions and 1239 deletions

16
index.d.ts vendored
View File

@ -33,11 +33,7 @@ export declare function isLogged(): boolean;
* Callback used if two-factor authentication is required for the profile.
* It must return he OTP code to use for the login.
*/
export declare function login(
username: string,
password: string,
cb2fa?: () => Promise<number>
): Promise<LoginResult>;
export declare function login(username: string, password: string, cb2fa?: () => Promise<number>): Promise<LoginResult>;
/**
* Chek if exists a new version of the handiwork.
*
@ -52,10 +48,7 @@ export declare function checkIfHandiworkHasUpdate(hw: HandiWork): Promise<boolea
* @param {HandiworkSearchQuery} query Parameters used for the search.
* @param {Number} limit Maximum number of results. Default: 10
*/
export declare function searchHandiwork<T extends IBasic>(
query: HandiworkSearchQuery,
limit?: number
): Promise<T[]>;
export declare function searchHandiwork<T extends IBasic>(query: HandiworkSearchQuery, limit?: number): Promise<T[]>;
/**
* Given the url, it gets all the information about the handiwork requested.
*
@ -78,7 +71,4 @@ export declare function getUserData(): Promise<UserProfile>;
* @param {LatestSearchQuery} query Parameters used for the search.
* @param {Number} limit Maximum number of results. Default: 10
*/
export declare function getLatestUpdates<T extends IBasic>(
query: LatestSearchQuery,
limit?: number
): Promise<T[]>;
export declare function getLatestUpdates<T extends IBasic>(query: LatestSearchQuery, limit?: number): Promise<T[]>;

View File

@ -24,7 +24,10 @@ export declare class UnexpectedResponseContentType extends Error implements IBas
error: Error;
constructor(args: IBaseError);
}
export declare class InvalidF95Token extends Error {}
export declare class UserNotLogged extends Error {}
export declare class ParameterError extends Error {}
export declare class InvalidF95Token extends Error {
}
export declare class UserNotLogged extends Error {
}
export declare class ParameterError extends Error {
}
export {};

View File

@ -1,11 +1,4 @@
import {
TAuthor,
TRating,
IHandiwork,
TEngine,
TCategory,
TStatus
} from "../../interfaces";
import { TAuthor, TRating, IHandiwork, TEngine, TCategory, TStatus } from "../../interfaces";
/**
* It represents a generic work, be it a game, a comic, an animation or an asset.
*/

View File

@ -20,13 +20,7 @@ import { Result } from "../result.js";
*
* `views`: Order based on the number of visits. Replacement: `replies`.
*/
declare type THandiworkOrder =
| "date"
| "likes"
| "relevance"
| "replies"
| "title"
| "views";
declare type THandiworkOrder = "date" | "likes" | "relevance" | "replies" | "title" | "views";
declare type TExecuteResult = Result<GenericAxiosError, AxiosResponse<any>>;
export default class HandiworkSearchQuery implements IQuery {
static MIN_PAGE: number;

View File

@ -1,27 +1,3 @@
export declare const selectors: {
WT_FILTER_POPUP_BUTTON: string;
WT_NEXT_PAGE: string;
WT_URLS: string;
WT_UNREAD_THREAD_CHECKBOX: string;
GS_POSTS: string;
GS_RESULT_THREAD_TITLE: string;
GS_RESULT_BODY: string;
GS_MEMBERSHIP: string;
GET_REQUEST_TOKEN: string;
UD_USERNAME_ELEMENT: string;
UD_AVATAR_PIC: string;
LOGIN_MESSAGE_ERROR: string;
LU_TAGS_SCRIPT: string;
BK_RESULTS: string;
BK_POST_URL: string;
BK_DESCRIPTION: string;
BK_POST_OWNER: string;
BK_TAGS: string;
/**
* Attribute `datetime` contains an ISO date.
*/
BK_TIME: string;
};
export declare const GENERIC: {
/**
* The ID of the user currently logged into
@ -32,6 +8,18 @@ export declare const GENERIC: {
* Banner containing any error messages as text.
*/
ERROR_BANNER: string;
/**
* Locate the token used for the session.
*/
GET_REQUEST_TOKEN: string;
/**
* Block containing the text of any errors that occurred during the login.
*/
LOGIN_MESSAGE_ERROR: string;
/**
* Locate the script containing the tags and prefixes of the platform content in JSON format.
*/
LATEST_UPDATES_TAGS_SCRIPT: string;
};
export declare const WATCHED_THREAD: {
/**
@ -100,6 +88,16 @@ export declare const THREAD: {
*/
POSTS_IN_PAGE: string;
};
export declare const THREAD_SEARCH: {
/**
* Thread title resulting from research.
*/
THREAD_TITLE: string;
/**
*Thread body resulting from research.
*/
BODY: string;
};
export declare const POST: {
/**
* Unique post number for the current thread.

View File

@ -1,13 +1,42 @@
export declare const urls: {
/**
* Page with the list of alerts for the user currently logged.
*/
ALERTS: string;
/**
* Basic URL of the platform.
*/
BASE: string;
LOGIN_2FA: string;
SEARCH: string;
LATEST_UPDATES: string;
THREADS: string;
LOGIN: string;
WATCHED_THREADS: string;
LATEST_PHP: string;
/**
* Page with the list of favorite posts of the user currently logged.
*/
BOOKMARKS: string;
/**
* Page with the list of conversations of the currently logged user.
*/
CONVERSATIONS: string;
/**
* URL of the script used for searching for content
* in the "Latest Updates" section of the platform.
*/
LATEST_PHP: string;
/**
* Page with the latest updated platform content.
*/
LATEST_UPDATES: string;
/**
* Page used for user login.
*/
LOGIN: string;
/**
* Page used for entering the OTP code in the case of two-factor authentication.
*/
LOGIN_2FA: string;
/**
* Summary page of users registered on the platform.
* Used for the search for a specific member through ID.
*/
MEMBERS: string;
/**
* Add the unique ID of the post to
* get the thread page where the post
@ -15,13 +44,21 @@ export declare const urls: {
*/
POSTS: string;
/**
* @todo
* URL used to send a POST request and change
* the number of posts that can be viewed per
* page of a specific thread.
*/
CONVERSATIONS: string;
/**
* @todo
*/
ALERTS: string;
POSTS_NUMBER: string;
MEMBERS: string;
/**
* URL used to search the platform by POST request.
*/
SEARCH: string;
/**
* Add the unique ID of the thread to get it's page.
*/
THREADS: string;
/**
* Page with the list of watched threads of the currently logged user.
*/
WATCHED_THREADS: string;
};

View File

@ -8,7 +8,4 @@ import HandiworkSearchQuery from "../classes/query/handiwork-search-query";
* Maximum number of items to get. Default: 30
* @returns {Promise<String[]>} URLs of the handiworks
*/
export default function fetchHandiworkURLs(
query: HandiworkSearchQuery,
limit?: number
): Promise<string[]>;
export default function fetchHandiworkURLs(query: HandiworkSearchQuery, limit?: number): Promise<string[]>;

View File

@ -9,7 +9,4 @@ import LatestSearchQuery from "../classes/query/latest-search-query.js";
* Maximum number of items to get. Default: 30
* @returns {Promise<String[]>} URLs of the handiworks
*/
export default function fetchLatestHandiworkURLs(
query: LatestSearchQuery,
limit?: number
): Promise<string[]>;
export default function fetchLatestHandiworkURLs(query: LatestSearchQuery, limit?: number): Promise<string[]>;

View File

@ -4,7 +4,4 @@ import { IQuery } from "../interfaces.js";
* @param limit Maximum number of items to get. Default: 30
* @returns URLs of the fetched games
*/
export default function getURLsFromQuery(
query: IQuery,
limit?: number
): Promise<string[]>;
export default function getURLsFromQuery(query: IQuery, limit?: number): Promise<string[]>;

View File

@ -9,7 +9,4 @@ import ThreadSearchQuery from "../classes/query/thread-search-query.js";
* Maximum number of items to get. Default: 30
* @returns {Promise<String[]>} URLs of the handiworks
*/
export default function fetchThreadHandiworkURLs(
query: ThreadSearchQuery,
limit?: number
): Promise<string[]>;
export default function fetchThreadHandiworkURLs(query: ThreadSearchQuery, limit?: number): Promise<string[]>;

View File

@ -44,21 +44,7 @@ export declare type TRating = {
/**
* List of possible graphics engines used for game development.
*/
export declare type TEngine =
| "QSP"
| "RPGM"
| "Unity"
| "HTML"
| "RAGS"
| "Java"
| "Ren'Py"
| "Flash"
| "ADRIFT"
| "Others"
| "Tads"
| "Wolf RPG"
| "Unreal Engine"
| "WebGL";
export declare type TEngine = "QSP" | "RPGM" | "Unity" | "HTML" | "RAGS" | "Java" | "Ren'Py" | "Flash" | "ADRIFT" | "Others" | "Tads" | "Wolf RPG" | "Unreal Engine" | "WebGL";
/**
* List of possible progress states associated with a game.
*/
@ -70,10 +56,7 @@ export declare type TCategory = "games" | "mods" | "comics" | "animations" | "as
/**
* Valid names of classes that implement the IQuery interface.
*/
export declare type TQueryInterface =
| "LatestSearchQuery"
| "ThreadSearchQuery"
| "HandiworkSearchQuery";
export declare type TQueryInterface = "LatestSearchQuery" | "ThreadSearchQuery" | "HandiworkSearchQuery";
/**
* Collection of values defined for each
* handiwork on the F95Zone platform.
@ -263,7 +246,8 @@ export interface IAsset extends IBasic {
* Collection of values extrapolated from the
* F95 platform representing a particular work.
*/
export interface IHandiwork extends IGame, IComic, IAnimation, IAsset {}
export interface IHandiwork extends IGame, IComic, IAnimation, IAsset {
}
export interface IQuery {
/**
* Name of the implemented interface.

View File

@ -6,9 +6,7 @@ import Credentials from "./classes/credentials.js";
/**
* Gets the HTML code of a page.
*/
export declare function fetchHTML(
url: string
): Promise<Result<GenericAxiosError | UnexpectedResponseContentType, string>>;
export declare function fetchHTML(url: string): Promise<Result<GenericAxiosError | UnexpectedResponseContentType, string>>;
/**
* It authenticates to the platform using the credentials
* and token obtained previously. Save cookies on your
@ -17,21 +15,14 @@ export declare function fetchHTML(
* @param {Boolean} force Specifies whether the request should be forced, ignoring any saved cookies
* @returns {Promise<LoginResult>} Result of the operation
*/
export declare function authenticate(
credentials: Credentials,
force?: boolean
): Promise<LoginResult>;
export declare function authenticate(credentials: Credentials, force?: boolean): Promise<LoginResult>;
/**
* Send an OTP code if the login procedure requires it.
* @param code OTP code.
* @param token Unique token for the session associated with the credentials in use.
* @param trustedDevice If the device in use is trusted, 2FA authentication is not required for 30 days.
*/
export declare function send2faCode(
code: number,
token: string,
trustedDevice?: boolean
): Promise<Result<GenericAxiosError, LoginResult>>;
export declare function send2faCode(code: number, token: string, trustedDevice?: boolean): Promise<Result<GenericAxiosError, LoginResult>>;
/**
* Obtain the token used to authenticate the user to the platform.
*/
@ -39,22 +30,16 @@ export declare function getF95Token(): Promise<string>;
/**
* Performs a GET request to a specific URL and returns the response.
*/
export declare function fetchGETResponse(
url: string
): Promise<Result<GenericAxiosError, AxiosResponse<any>>>;
export declare function fetchGETResponse(url: string): Promise<Result<GenericAxiosError, AxiosResponse<any>>>;
/**
* Performs a POST request through axios.
* @param url URL to request
* @param params List of value pairs to send with the request
* @param force If `true`, the request ignores the sending of cookies already present on the device.
*/
export declare function fetchPOSTResponse(
url: string,
params: {
export declare function fetchPOSTResponse(url: string, params: {
[s: string]: string;
},
force?: boolean
): Promise<Result<GenericAxiosError, AxiosResponse<any>>>;
}, force?: boolean): Promise<Result<GenericAxiosError, AxiosResponse<any>>>;
/**
* Enforces the scheme of the URL is https and returns the new URL.
*/

View File

@ -1,11 +1,7 @@
import Thread from "../classes/mapping/thread.js";
import { IBasic } from "../interfaces.js";
export declare function getHandiworkInformation<T extends IBasic>(
url: string
): Promise<T>;
export declare function getHandiworkInformation<T extends IBasic>(
url: string
): Promise<T>;
export declare function getHandiworkInformation<T extends IBasic>(url: string): Promise<T>;
export declare function getHandiworkInformation<T extends IBasic>(url: string): Promise<T>;
/**
* Gets information of a particular handiwork from its thread.
*
@ -13,6 +9,4 @@ export declare function getHandiworkInformation<T extends IBasic>(
*
* @todo It does not currently support assets.
*/
export default function getHandiworkInformation<T extends IBasic>(
arg: string | Thread
): Promise<T>;
export default function getHandiworkInformation<T extends IBasic>(arg: string | Thread): Promise<T>;

View File

@ -12,7 +12,4 @@ export interface ILink extends IPostElement {
/**
* Given a post of a thread page it extracts the information contained in the body.
*/
export declare function parseF95ThreadPost(
$: cheerio.Root,
post: cheerio.Cheerio
): IPostElement[];
export declare function parseF95ThreadPost($: cheerio.Root, post: cheerio.Cheerio): IPostElement[];

5
scripts/search.d.ts vendored
View File

@ -5,7 +5,4 @@ import { IBasic, IQuery } from "./interfaces.js";
* @param {Number} limit
* Maximum number of items to get. Default: 30
*/
export default function search<T extends IBasic>(
query: IQuery,
limit?: number
): Promise<T[]>;
export default function search<T extends IBasic>(query: IQuery, limit?: number): Promise<T[]>;