Prettify scripts

pull/81/head
MillenniumEarl 2021-03-05 13:06:09 +01:00
parent eace0e6056
commit 9d8118aca8
32 changed files with 1271 additions and 1196 deletions

16
index.d.ts vendored
View File

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

@ -2,21 +2,21 @@
* Represents the credentials used to access the platform. * Represents the credentials used to access the platform.
*/ */
export default class Credentials { export default class Credentials {
/** /**
* Username * Username
*/ */
username: string; username: string;
/** /**
* Password of the user. * Password of the user.
*/ */
password: string; password: string;
/** /**
* One time token used during login. * One time token used during login.
*/ */
token: string; token: string;
constructor(username: string, password: string); constructor(username: string, password: string);
/** /**
* Fetch and save the token used to log in to F95Zone. * Fetch and save the token used to log in to F95Zone.
*/ */
fetchToken(): Promise<void>; fetchToken(): Promise<void>;
} }

View File

@ -1,33 +1,30 @@
interface IBaseError { interface IBaseError {
/** /**
* Unique identifier of the error. * Unique identifier of the error.
*/ */
id: number; id: number;
/** /**
* Error message. * Error message.
*/ */
message: string; message: string;
/** /**
* Error to report. * Error to report.
*/ */
error: Error; error: Error;
} }
export declare class GenericAxiosError extends Error implements IBaseError { export declare class GenericAxiosError extends Error implements IBaseError {
id: number; id: number;
message: string; message: string;
error: Error; error: Error;
constructor(args: IBaseError); constructor(args: IBaseError);
} }
export declare class UnexpectedResponseContentType extends Error implements IBaseError { export declare class UnexpectedResponseContentType extends Error implements IBaseError {
id: number; id: number;
message: string; message: string;
error: Error; error: Error;
constructor(args: IBaseError); 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 {}; export {};

View File

@ -1,23 +1,23 @@
import { TAuthor, IAnimation, TRating, TCategory } from "../../interfaces"; import { TAuthor, IAnimation, TRating, TCategory } from "../../interfaces";
export default class Animation implements IAnimation { export default class Animation implements IAnimation {
censored: boolean; censored: boolean;
genre: string[]; genre: string[];
installation: string; installation: string;
language: string[]; language: string[];
lenght: string; lenght: string;
pages: string; pages: string;
resolution: string[]; resolution: string[];
authors: TAuthor[]; authors: TAuthor[];
category: TCategory; category: TCategory;
changelog: string[]; changelog: string[];
cover: string; cover: string;
id: number; id: number;
lastThreadUpdate: Date; lastThreadUpdate: Date;
name: string; name: string;
overview: string; overview: string;
prefixes: string[]; prefixes: string[];
rating: TRating; rating: TRating;
tags: string[]; tags: string[];
threadPublishingDate: Date; threadPublishingDate: Date;
url: string; url: string;
} }

View File

@ -1,22 +1,22 @@
import { TAuthor, IAsset, TRating, TCategory } from "../../interfaces"; import { TAuthor, IAsset, TRating, TCategory } from "../../interfaces";
export default class Asset implements IAsset { export default class Asset implements IAsset {
assetLink: string; assetLink: string;
associatedAssets: string[]; associatedAssets: string[];
compatibleSoftware: string; compatibleSoftware: string;
includedAssets: string[]; includedAssets: string[];
officialLinks: string[]; officialLinks: string[];
sku: string; sku: string;
authors: TAuthor[]; authors: TAuthor[];
category: TCategory; category: TCategory;
changelog: string[]; changelog: string[];
cover: string; cover: string;
id: number; id: number;
lastThreadUpdate: Date; lastThreadUpdate: Date;
name: string; name: string;
overview: string; overview: string;
prefixes: string[]; prefixes: string[];
rating: TRating; rating: TRating;
tags: string[]; tags: string[];
threadPublishingDate: Date; threadPublishingDate: Date;
url: string; url: string;
} }

View File

@ -1,19 +1,19 @@
import { TAuthor, IComic, TRating, TCategory } from "../../interfaces"; import { TAuthor, IComic, TRating, TCategory } from "../../interfaces";
export default class Comic implements IComic { export default class Comic implements IComic {
genre: string[]; genre: string[];
pages: string; pages: string;
resolution: string[]; resolution: string[];
authors: TAuthor[]; authors: TAuthor[];
category: TCategory; category: TCategory;
changelog: string[]; changelog: string[];
cover: string; cover: string;
id: number; id: number;
lastThreadUpdate: Date; lastThreadUpdate: Date;
name: string; name: string;
overview: string; overview: string;
prefixes: string[]; prefixes: string[];
rating: TRating; rating: TRating;
tags: string[]; tags: string[];
threadPublishingDate: Date; threadPublishingDate: Date;
url: string; url: string;
} }

View File

@ -1,26 +1,26 @@
import { TAuthor, TEngine, IGame, TRating, TStatus, TCategory } from "../../interfaces"; import { TAuthor, TEngine, IGame, TRating, TStatus, TCategory } from "../../interfaces";
export default class Game implements IGame { export default class Game implements IGame {
censored: boolean; censored: boolean;
engine: TEngine; engine: TEngine;
genre: string[]; genre: string[];
installation: string; installation: string;
language: string[]; language: string[];
lastRelease: Date; lastRelease: Date;
mod: boolean; mod: boolean;
os: string[]; os: string[];
status: TStatus; status: TStatus;
version: string; version: string;
authors: TAuthor[]; authors: TAuthor[];
category: TCategory; category: TCategory;
changelog: string[]; changelog: string[];
cover: string; cover: string;
id: number; id: number;
lastThreadUpdate: Date; lastThreadUpdate: Date;
name: string; name: string;
overview: string; overview: string;
prefixes: string[]; prefixes: string[];
rating: TRating; rating: TRating;
tags: string[]; tags: string[];
threadPublishingDate: Date; threadPublishingDate: Date;
url: string; url: string;
} }

View File

@ -1,38 +1,45 @@
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. * It represents a generic work, be it a game, a comic, an animation or an asset.
*/ */
export default class HandiWork implements IHandiwork { export default class HandiWork implements IHandiwork {
censored: boolean; censored: boolean;
engine: TEngine; engine: TEngine;
genre: string[]; genre: string[];
installation: string; installation: string;
language: string[]; language: string[];
lastRelease: Date; lastRelease: Date;
mod: boolean; mod: boolean;
os: string[]; os: string[];
status: TStatus; status: TStatus;
version: string; version: string;
authors: TAuthor[]; authors: TAuthor[];
category: TCategory; category: TCategory;
changelog: string[]; changelog: string[];
cover: string; cover: string;
id: number; id: number;
lastThreadUpdate: Date; lastThreadUpdate: Date;
name: string; name: string;
overview: string; overview: string;
prefixes: string[]; prefixes: string[];
rating: TRating; rating: TRating;
tags: string[]; tags: string[];
threadPublishingDate: Date; threadPublishingDate: Date;
url: string; url: string;
pages: string; pages: string;
resolution: string[]; resolution: string[];
lenght: string; lenght: string;
assetLink: string; assetLink: string;
associatedAssets: string[]; associatedAssets: string[];
compatibleSoftware: string; compatibleSoftware: string;
includedAssets: string[]; includedAssets: string[];
officialLinks: string[]; officialLinks: string[];
sku: string; sku: string;
} }

View File

@ -2,24 +2,24 @@
* Object obtained in response to an attempt to login to the portal. * Object obtained in response to an attempt to login to the portal.
*/ */
export default class LoginResult { export default class LoginResult {
static REQUIRE_2FA: number; static REQUIRE_2FA: number;
static AUTH_SUCCESSFUL: number; static AUTH_SUCCESSFUL: number;
static AUTH_SUCCESSFUL_2FA: number; static AUTH_SUCCESSFUL_2FA: number;
static ALREADY_AUTHENTICATED: number; static ALREADY_AUTHENTICATED: number;
static UNKNOWN_ERROR: number; static UNKNOWN_ERROR: number;
static INCORRECT_CREDENTIALS: number; static INCORRECT_CREDENTIALS: number;
static INCORRECT_2FA_CODE: number; static INCORRECT_2FA_CODE: number;
/** /**
* Result of the login operation * Result of the login operation
*/ */
readonly success: boolean; readonly success: boolean;
/** /**
* Code associated with the result of the login operation. * Code associated with the result of the login operation.
*/ */
readonly code: number; readonly code: number;
/** /**
* Login response message * Login response message
*/ */
readonly message: string; readonly message: string;
constructor(success: boolean, code: number, message?: string); constructor(success: boolean, code: number, message?: string);
} }

View File

@ -2,82 +2,82 @@
* Represents a generic user registered on the platform. * Represents a generic user registered on the platform.
*/ */
export default class PlatformUser { export default class PlatformUser {
private _id; private _id;
private _name; private _name;
private _title; private _title;
private _banners; private _banners;
private _messages; private _messages;
private _reactionScore; private _reactionScore;
private _points; private _points;
private _ratingsReceived; private _ratingsReceived;
private _joined; private _joined;
private _lastSeen; private _lastSeen;
private _followed; private _followed;
private _ignored; private _ignored;
private _private; private _private;
private _avatar; private _avatar;
private _amountDonated; private _amountDonated;
/** /**
* Unique user ID. * Unique user ID.
*/ */
get id(): number; get id(): number;
/** /**
* Username. * Username.
*/ */
get name(): string; get name(): string;
/** /**
* Title assigned to the user by the platform. * Title assigned to the user by the platform.
*/ */
get title(): string; get title(): string;
/** /**
* List of banners assigned by the platform. * List of banners assigned by the platform.
*/ */
get banners(): string[]; get banners(): string[];
/** /**
* Number of messages written by the user. * Number of messages written by the user.
*/ */
get messages(): number; get messages(): number;
/** /**
* @todo Reaction score. * @todo Reaction score.
*/ */
get reactionScore(): number; get reactionScore(): number;
/** /**
* @todo Points. * @todo Points.
*/ */
get points(): number; get points(): number;
/** /**
* Number of ratings received. * Number of ratings received.
*/ */
get ratingsReceived(): number; get ratingsReceived(): number;
/** /**
* Date of joining the platform. * Date of joining the platform.
*/ */
get joined(): Date; get joined(): Date;
/** /**
* Date of the last connection to the platform. * Date of the last connection to the platform.
*/ */
get lastSeen(): Date; get lastSeen(): Date;
/** /**
* Indicates whether the user is followed by the currently logged in user. * Indicates whether the user is followed by the currently logged in user.
*/ */
get followed(): boolean; get followed(): boolean;
/** /**
* Indicates whether the user is ignored by the currently logged on user. * Indicates whether the user is ignored by the currently logged on user.
*/ */
get ignored(): boolean; get ignored(): boolean;
/** /**
* Indicates that the profile is private and not viewable by the user. * Indicates that the profile is private and not viewable by the user.
*/ */
get private(): boolean; get private(): boolean;
/** /**
* URL of the image used as the user's avatar. * URL of the image used as the user's avatar.
*/ */
get avatar(): string; get avatar(): string;
/** /**
* Value of donations made. * Value of donations made.
*/ */
get donation(): number; get donation(): number;
constructor(id?: number); constructor(id?: number);
setID(id: number): void; setID(id: number): void;
fetch(): Promise<void>; fetch(): Promise<void>;
} }

View File

@ -4,50 +4,50 @@ import { IPostElement } from "../../scrape-data/post-parse.js";
* Represents a post published by a user on the F95Zone platform. * Represents a post published by a user on the F95Zone platform.
*/ */
export default class Post { export default class Post {
private _id; private _id;
private _number; private _number;
private _published; private _published;
private _lastEdit; private _lastEdit;
private _owner; private _owner;
private _bookmarked; private _bookmarked;
private _message; private _message;
private _body; private _body;
/** /**
* Represents a post published by a user on the F95Zone platform. * Represents a post published by a user on the F95Zone platform.
*/ */
get id(): number; get id(): number;
/** /**
* Unique ID of the post within the thread in which it is present. * Unique ID of the post within the thread in which it is present.
*/ */
get number(): number; get number(): number;
/** /**
* Date the post was first published. * Date the post was first published.
*/ */
get published(): Date; get published(): Date;
/** /**
* Date the post was last modified. * Date the post was last modified.
*/ */
get lastEdit(): Date; get lastEdit(): Date;
/** /**
* User who owns the post. * User who owns the post.
*/ */
get owner(): PlatformUser; get owner(): PlatformUser;
/** /**
* Indicates whether the post has been bookmarked. * Indicates whether the post has been bookmarked.
*/ */
get bookmarked(): boolean; get bookmarked(): boolean;
/** /**
* Post message text. * Post message text.
*/ */
get message(): string; get message(): string;
/** /**
* Set of the elements that make up the body of the post. * Set of the elements that make up the body of the post.
*/ */
get body(): IPostElement[]; get body(): IPostElement[];
constructor(id: number); constructor(id: number);
/** /**
* Gets the post data starting from its unique ID for the entire platform. * Gets the post data starting from its unique ID for the entire platform.
*/ */
fetch(): Promise<void>; fetch(): Promise<void>;
private parsePost; private parsePost;
} }

View File

@ -5,97 +5,97 @@ import { TCategory, TRating } from "../../interfaces.js";
* Represents a generic F95Zone platform thread. * Represents a generic F95Zone platform thread.
*/ */
export default class Thread { export default class Thread {
private POST_FOR_PAGE; private POST_FOR_PAGE;
private _id; private _id;
private _url; private _url;
private _title; private _title;
private _tags; private _tags;
private _prefixes; private _prefixes;
private _rating; private _rating;
private _owner; private _owner;
private _publication; private _publication;
private _modified; private _modified;
private _category; private _category;
/** /**
* Unique ID of the thread on the platform. * Unique ID of the thread on the platform.
*/ */
get id(): number; get id(): number;
/** /**
* URL of the thread. * URL of the thread.
* *
* It may vary depending on any versions of the contained product. * It may vary depending on any versions of the contained product.
*/ */
get url(): string; get url(): string;
/** /**
* Thread title. * Thread title.
*/ */
get title(): string; get title(): string;
/** /**
* Tags associated with the thread. * Tags associated with the thread.
*/ */
get tags(): string[]; get tags(): string[];
/** /**
* Prefixes associated with the thread * Prefixes associated with the thread
*/ */
get prefixes(): string[]; get prefixes(): string[];
/** /**
* Rating assigned to the thread. * Rating assigned to the thread.
*/ */
get rating(): TRating; get rating(): TRating;
/** /**
* Owner of the thread. * Owner of the thread.
*/ */
get owner(): PlatformUser; get owner(): PlatformUser;
/** /**
* Date the thread was first published. * Date the thread was first published.
*/ */
get publication(): Date; get publication(): Date;
/** /**
* Date the thread was last modified. * Date the thread was last modified.
*/ */
get modified(): Date; get modified(): Date;
/** /**
* Category to which the content of the thread belongs. * Category to which the content of the thread belongs.
*/ */
get category(): TCategory; get category(): TCategory;
/** /**
* Initializes an object for mapping a thread. * Initializes an object for mapping a thread.
* *
* The unique ID of the thread must be specified. * The unique ID of the thread must be specified.
*/ */
constructor(id: number); constructor(id: number);
/** /**
* Set the number of posts to display for the current thread. * Set the number of posts to display for the current thread.
*/ */
private setMaximumPostsForPage; private setMaximumPostsForPage;
/** /**
* Gets all posts on a page. * Gets all posts on a page.
*/ */
private parsePostsInPage; private parsePostsInPage;
/** /**
* Gets all posts in the thread. * Gets all posts in the thread.
*/ */
private fetchPosts; private fetchPosts;
/** /**
* It processes the rating of the thread * It processes the rating of the thread
* starting from the data contained in the JSON+LD tag. * starting from the data contained in the JSON+LD tag.
*/ */
private parseRating; private parseRating;
/** /**
* Clean the title of a thread, removing prefixes * Clean the title of a thread, removing prefixes
* and generic elements between square brackets, and * and generic elements between square brackets, and
* returns the clean title of the work. * returns the clean title of the work.
*/ */
private cleanHeadline; private cleanHeadline;
/** /**
* Gets information about this thread. * Gets information about this thread.
*/ */
fetch(): Promise<void>; fetch(): Promise<void>;
/** /**
* Gets the post in the `index` position with respect to the posts in the thread. * Gets the post in the `index` position with respect to the posts in the thread.
* *
* `index` must be greater or equal to 1. * `index` must be greater or equal to 1.
* If the post is not found, `null` is returned. * If the post is not found, `null` is returned.
*/ */
getPost(index: number): Promise<Post | null>; getPost(index: number): Promise<Post | null>;
} }

View File

@ -1,60 +1,60 @@
import Post from "./post.js"; import Post from "./post.js";
import PlatformUser from "./platform-user.js"; import PlatformUser from "./platform-user.js";
interface IWatchedThread { interface IWatchedThread {
/** /**
* URL of the thread * URL of the thread
*/ */
url: string; url: string;
/** /**
* Indicates whether the thread has any unread posts. * Indicates whether the thread has any unread posts.
*/ */
unread: boolean; unread: boolean;
/** /**
* Specifies the forum to which the thread belongs. * Specifies the forum to which the thread belongs.
*/ */
forum: string; forum: string;
} }
/** /**
* Class containing the data of the user currently connected to the F95Zone platform. * Class containing the data of the user currently connected to the F95Zone platform.
*/ */
export default class UserProfile extends PlatformUser { export default class UserProfile extends PlatformUser {
private _watched; private _watched;
private _bookmarks; private _bookmarks;
private _alerts; private _alerts;
private _conversations; private _conversations;
/** /**
* List of followed thread data. * List of followed thread data.
*/ */
get watched(): IWatchedThread[]; get watched(): IWatchedThread[];
/** /**
* List of bookmarked posts. * List of bookmarked posts.
* @todo * @todo
*/ */
get bookmarks(): Post[]; get bookmarks(): Post[];
/** /**
* List of alerts. * List of alerts.
* @todo * @todo
*/ */
get alerts(): string[]; get alerts(): string[];
/** /**
* List of conversations. * List of conversations.
* @todo * @todo
*/ */
get conversation(): string[]; get conversation(): string[];
constructor(); constructor();
fetch(): Promise<void>; fetch(): Promise<void>;
private fetchUserID; private fetchUserID;
private fetchWatchedThread; private fetchWatchedThread;
/** /**
* Gets the pages containing the thread data. * Gets the pages containing the thread data.
* @param url Base URL to use for scraping a page * @param url Base URL to use for scraping a page
* @param n Total number of pages * @param n Total number of pages
* @param s Page to start from * @param s Page to start from
*/ */
private fetchPages; private fetchPages;
/** /**
* Gets thread data starting from the source code of the page passed by parameter. * Gets thread data starting from the source code of the page passed by parameter.
*/ */
private fetchPageThreadElements; private fetchPageThreadElements;
} }
export {}; export {};

View File

@ -2,33 +2,33 @@
* Convert prefixes and platform tags from string to ID and vice versa. * Convert prefixes and platform tags from string to ID and vice versa.
*/ */
export default class PrefixParser { export default class PrefixParser {
/** /**
* Gets the key associated with a given value from a dictionary. * Gets the key associated with a given value from a dictionary.
* @param {Object} object Dictionary to search * @param {Object} object Dictionary to search
* @param {Any} value Value associated with the key * @param {Any} value Value associated with the key
* @returns {String|undefined} Key found or undefined * @returns {String|undefined} Key found or undefined
*/ */
private getKeyByValue; private getKeyByValue;
/** /**
* Makes an array of strings uppercase. * Makes an array of strings uppercase.
*/ */
private toUpperCaseArray; private toUpperCaseArray;
/** /**
* Check if `dict` contains `value` as a value. * Check if `dict` contains `value` as a value.
*/ */
private valueInDict; private valueInDict;
/** /**
* Search within the platform prefixes for the * Search within the platform prefixes for the
* desired element and return the dictionary that contains it. * desired element and return the dictionary that contains it.
* @param element Element to search in the prefixes as a key or as a value * @param element Element to search in the prefixes as a key or as a value
*/ */
private searchElementInPrefixes; private searchElementInPrefixes;
/** /**
* Convert a list of prefixes to their respective IDs. * Convert a list of prefixes to their respective IDs.
*/ */
prefixesToIDs(prefixes: string[]): number[]; prefixesToIDs(prefixes: string[]): number[];
/** /**
* It converts a list of IDs into their respective prefixes. * It converts a list of IDs into their respective prefixes.
*/ */
idsToPrefixes(ids: number[]): string[]; idsToPrefixes(ids: number[]): string[];
} }

View File

@ -20,45 +20,51 @@ import { Result } from "../result.js";
* *
* `views`: Order based on the number of visits. Replacement: `replies`. * `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>>; declare type TExecuteResult = Result<GenericAxiosError, AxiosResponse<any>>;
export default class HandiworkSearchQuery implements IQuery { export default class HandiworkSearchQuery implements IQuery {
static MIN_PAGE: number; static MIN_PAGE: number;
/** /**
* Keywords to use in the search. * Keywords to use in the search.
*/ */
keywords: string; keywords: string;
/** /**
* The results must be more recent than the date indicated. * The results must be more recent than the date indicated.
*/ */
newerThan: Date; newerThan: Date;
/** /**
* The results must be older than the date indicated. * The results must be older than the date indicated.
*/ */
olderThan: Date; olderThan: Date;
includedTags: string[]; includedTags: string[];
/** /**
* Tags to exclude from the search. * Tags to exclude from the search.
*/ */
excludedTags: string[]; excludedTags: string[];
includedPrefixes: string[]; includedPrefixes: string[];
category: TCategory; category: TCategory;
/** /**
* Results presentation order. * Results presentation order.
*/ */
order: THandiworkOrder; order: THandiworkOrder;
page: number; page: number;
itype: TQueryInterface; itype: TQueryInterface;
/** /**
* Select what kind of search should be * Select what kind of search should be
* performed based on the properties of * performed based on the properties of
* the query. * the query.
*/ */
selectSearchType(): "latest" | "thread"; selectSearchType(): "latest" | "thread";
validate(): boolean; validate(): boolean;
execute(): Promise<TExecuteResult>; execute(): Promise<TExecuteResult>;
cast<T extends IQuery>(type: TQueryInterface): T; cast<T extends IQuery>(type: TQueryInterface): T;
private castToLatest; private castToLatest;
private castToThread; private castToThread;
} }
export {}; export {};

View File

@ -8,39 +8,39 @@ declare type TDate = 365 | 180 | 90 | 30 | 14 | 7 | 3 | 1;
* Query used to search handiwork in the "Latest" tab. * Query used to search handiwork in the "Latest" tab.
*/ */
export default class LatestSearchQuery implements IQuery { export default class LatestSearchQuery implements IQuery {
private static MAX_TAGS; private static MAX_TAGS;
private static MIN_PAGE; private static MIN_PAGE;
category: TCategory; category: TCategory;
/** /**
* Ordering type. * Ordering type.
* *
* Default: `date`. * Default: `date`.
*/ */
order: TLatestOrder; order: TLatestOrder;
/** /**
* Date limit in days, to be understood as "less than". * Date limit in days, to be understood as "less than".
* Use `1` to indicate "today" or `null` to indicate "anytime". * Use `1` to indicate "today" or `null` to indicate "anytime".
* *
* Default: `null` * Default: `null`
*/ */
date: TDate; date: TDate;
includedTags: string[]; includedTags: string[];
includedPrefixes: string[]; includedPrefixes: string[];
page: number; page: number;
itype: TQueryInterface; itype: TQueryInterface;
validate(): boolean; validate(): boolean;
execute(): Promise<Result<GenericAxiosError, AxiosResponse<any>>>; execute(): Promise<Result<GenericAxiosError, AxiosResponse<any>>>;
/** /**
* Gets the value (in days) acceptable in the query starting from a generic date. * Gets the value (in days) acceptable in the query starting from a generic date.
*/ */
findNearestDate(d: Date): TDate; findNearestDate(d: Date): TDate;
/** /**
* Prepare the URL by filling out the GET parameters with the data in the query. * Prepare the URL by filling out the GET parameters with the data in the query.
*/ */
private prepareGETurl; private prepareGETurl;
/** /**
* *
*/ */
private dateDiffInDays; private dateDiffInDays;
} }
export {}; export {};

View File

@ -4,52 +4,52 @@ import { GenericAxiosError } from "../errors.js";
import { Result } from "../result.js"; import { Result } from "../result.js";
export declare type TThreadOrder = "relevance" | "date" | "last_update" | "replies"; export declare type TThreadOrder = "relevance" | "date" | "last_update" | "replies";
export default class ThreadSearchQuery implements IQuery { export default class ThreadSearchQuery implements IQuery {
static MIN_PAGE: number; static MIN_PAGE: number;
/** /**
* Keywords to use in the search. * Keywords to use in the search.
*/ */
keywords: string; keywords: string;
/** /**
* Indicates to search by checking only the thread titles and not the content. * Indicates to search by checking only the thread titles and not the content.
*/ */
onlyTitles: boolean; onlyTitles: boolean;
/** /**
* The results must be more recent than the date indicated. * The results must be more recent than the date indicated.
*/ */
newerThan: Date; newerThan: Date;
/** /**
* The results must be older than the date indicated. * The results must be older than the date indicated.
*/ */
olderThan: Date; olderThan: Date;
includedTags: string[]; includedTags: string[];
/** /**
* Tags to exclude from the search. * Tags to exclude from the search.
*/ */
excludedTags: string[]; excludedTags: string[];
/** /**
* Minimum number of answers that the thread must possess. * Minimum number of answers that the thread must possess.
*/ */
minimumReplies: number; minimumReplies: number;
includedPrefixes: string[]; includedPrefixes: string[];
category: TCategory; category: TCategory;
/** /**
* Results presentation order. * Results presentation order.
*/ */
order: TThreadOrder; order: TThreadOrder;
page: number; page: number;
itype: TQueryInterface; itype: TQueryInterface;
validate(): boolean; validate(): boolean;
execute(): Promise<Result<GenericAxiosError, AxiosResponse<any>>>; execute(): Promise<Result<GenericAxiosError, AxiosResponse<any>>>;
/** /**
* Prepare the parameters for post request with the data in the query. * Prepare the parameters for post request with the data in the query.
*/ */
private preparePOSTParameters; private preparePOSTParameters;
/** /**
* Convert a date in the YYYY-MM-DD format taking into account the time zone. * Convert a date in the YYYY-MM-DD format taking into account the time zone.
*/ */
private convertShortDate; private convertShortDate;
/** /**
* Gets the unique ID of the selected category. * Gets the unique ID of the selected category.
*/ */
private categoryToID; private categoryToID;
} }

View File

@ -1,17 +1,17 @@
export declare type Result<L, A> = Failure<L, A> | Success<L, A>; export declare type Result<L, A> = Failure<L, A> | Success<L, A>;
export declare class Failure<L, A> { export declare class Failure<L, A> {
readonly value: L; readonly value: L;
constructor(value: L); constructor(value: L);
isFailure(): this is Failure<L, A>; isFailure(): this is Failure<L, A>;
isSuccess(): this is Success<L, A>; isSuccess(): this is Success<L, A>;
applyOnSuccess<B>(_: (a: A) => B): Result<L, B>; applyOnSuccess<B>(_: (a: A) => B): Result<L, B>;
} }
export declare class Success<L, A> { export declare class Success<L, A> {
readonly value: A; readonly value: A;
constructor(value: A); constructor(value: A);
isFailure(): this is Failure<L, A>; isFailure(): this is Failure<L, A>;
isSuccess(): this is Success<L, A>; isSuccess(): this is Success<L, A>;
applyOnSuccess<B>(func: (a: A) => B): Result<L, B>; applyOnSuccess<B>(func: (a: A) => B): Result<L, B>;
} }
export declare const failure: <L, A>(l: L) => Result<L, A>; export declare const failure: <L, A>(l: L) => Result<L, A>;
export declare const success: <L, A>(a: A) => Result<L, A>; export declare const success: <L, A>(a: A) => Result<L, A>;

View File

@ -1,71 +1,71 @@
import tough from "tough-cookie"; import tough from "tough-cookie";
export default class Session { export default class Session {
/** /**
* Max number of days the session is valid. * Max number of days the session is valid.
*/ */
private readonly SESSION_TIME; private readonly SESSION_TIME;
private readonly COOKIEJAR_FILENAME; private readonly COOKIEJAR_FILENAME;
private _path; private _path;
private _isMapped; private _isMapped;
private _created; private _created;
private _hash; private _hash;
private _token; private _token;
private _cookieJar; private _cookieJar;
private _cookieJarPath; private _cookieJarPath;
/** /**
* Path of the session map file on disk. * Path of the session map file on disk.
*/ */
get path(): string; get path(): string;
/** /**
* Indicates if the session is mapped on disk. * Indicates if the session is mapped on disk.
*/ */
get isMapped(): boolean; get isMapped(): boolean;
/** /**
* Date of creation of the session. * Date of creation of the session.
*/ */
get created(): Date; get created(): Date;
/** /**
* MD5 hash of the username and the password. * MD5 hash of the username and the password.
*/ */
get hash(): string; get hash(): string;
/** /**
* Token used to login to F95Zone. * Token used to login to F95Zone.
*/ */
get token(): string; get token(): string;
/** /**
* Cookie holder. * Cookie holder.
*/ */
get cookieJar(): tough.CookieJar; get cookieJar(): tough.CookieJar;
/** /**
* Initializes the session by setting the path for saving information to disk. * Initializes the session by setting the path for saving information to disk.
*/ */
constructor(p: string); constructor(p: string);
/** /**
* Get the difference in days between two dates. * Get the difference in days between two dates.
*/ */
private dateDiffInDays; private dateDiffInDays;
/** /**
* Convert the object to a dictionary serializable in JSON. * Convert the object to a dictionary serializable in JSON.
*/ */
private toJSON; private toJSON;
/** /**
* Create a new session. * Create a new session.
*/ */
create(username: string, password: string, token: string): void; create(username: string, password: string, token: string): void;
/** /**
* Save the session to disk. * Save the session to disk.
*/ */
save(): Promise<void>; save(): Promise<void>;
/** /**
* Load the session from disk. * Load the session from disk.
*/ */
load(): Promise<void>; load(): Promise<void>;
/** /**
* Delete the session from disk. * Delete the session from disk.
*/ */
delete(): Promise<void>; delete(): Promise<void>;
/** /**
* Check if the session is valid. * Check if the session is valid.
*/ */
isValid(username: string, password: string): boolean; isValid(username: string, password: string): boolean;
} }

View File

@ -1,201 +1,201 @@
export declare const GENERIC: { export declare const GENERIC: {
/** /**
* The ID of the user currently logged into * The ID of the user currently logged into
* the platform in the attribute `data-user-id`. * the platform in the attribute `data-user-id`.
*/ */
CURRENT_USER_ID: string; CURRENT_USER_ID: string;
/** /**
* Banner containing any error messages as text. * Banner containing any error messages as text.
*/ */
ERROR_BANNER: string; ERROR_BANNER: string;
/** /**
* Locate the token used for the session. * Locate the token used for the session.
*/ */
GET_REQUEST_TOKEN: string; GET_REQUEST_TOKEN: string;
/** /**
* Block containing the text of any errors that occurred during the login. * Block containing the text of any errors that occurred during the login.
*/ */
LOGIN_MESSAGE_ERROR: string; LOGIN_MESSAGE_ERROR: string;
/** /**
* Locate the script containing the tags and prefixes of the platform content in JSON format. * Locate the script containing the tags and prefixes of the platform content in JSON format.
*/ */
LATEST_UPDATES_TAGS_SCRIPT: string; LATEST_UPDATES_TAGS_SCRIPT: string;
}; };
export declare const WATCHED_THREAD: { export declare const WATCHED_THREAD: {
/** /**
* List of elements containing the data of the watched threads. * List of elements containing the data of the watched threads.
*/ */
BODIES: string; BODIES: string;
/** /**
* Link element containing the partial URL * Link element containing the partial URL
* of the thread in the `href` attribute. * of the thread in the `href` attribute.
* *
* It may be followed by the `/unread` segment. * It may be followed by the `/unread` segment.
* *
* For use within a `WATCHED_THREAD.BODIES` selector. * For use within a `WATCHED_THREAD.BODIES` selector.
*/ */
URL: string; URL: string;
/** /**
* Name of the forum to which the thread belongs as text. * Name of the forum to which the thread belongs as text.
* *
* For use within a `WATCHED_THREAD.BODIES` selector. * For use within a `WATCHED_THREAD.BODIES` selector.
*/ */
FORUM: string; FORUM: string;
/** /**
* Index of the last page available as text. * Index of the last page available as text.
*/ */
LAST_PAGE: string; LAST_PAGE: string;
}; };
export declare const THREAD: { export declare const THREAD: {
/** /**
* Number of pages in the thread (as text of the element). * Number of pages in the thread (as text of the element).
* *
* Two identical elements are identified. * Two identical elements are identified.
*/ */
LAST_PAGE: string; LAST_PAGE: string;
/** /**
* Identify the creator of the thread. * Identify the creator of the thread.
* *
* The ID is contained in the `data-user-id` attribute. * The ID is contained in the `data-user-id` attribute.
*/ */
OWNER_ID: string; OWNER_ID: string;
/** /**
* Contains the creation date of the thread. * Contains the creation date of the thread.
* *
* The date is contained in the `datetime` attribute as an ISO string. * The date is contained in the `datetime` attribute as an ISO string.
*/ */
CREATION: string; CREATION: string;
/** /**
* List of tags assigned to the thread. * List of tags assigned to the thread.
*/ */
TAGS: string; TAGS: string;
/** /**
* List of prefixes assigned to the thread. * List of prefixes assigned to the thread.
*/ */
PREFIXES: string; PREFIXES: string;
/** /**
* Thread title. * Thread title.
*/ */
TITLE: string; TITLE: string;
/** /**
* JSON containing thread information. * JSON containing thread information.
* *
* Two different elements are found. * Two different elements are found.
*/ */
JSONLD: string; JSONLD: string;
/** /**
* Posts on the current page. * Posts on the current page.
*/ */
POSTS_IN_PAGE: string; POSTS_IN_PAGE: string;
}; };
export declare const THREAD_SEARCH: { export declare const THREAD_SEARCH: {
/** /**
* Thread title resulting from research. * Thread title resulting from research.
*/ */
THREAD_TITLE: string; THREAD_TITLE: string;
/** /**
*Thread body resulting from research. *Thread body resulting from research.
*/ */
BODY: string; BODY: string;
}; };
export declare const POST: { export declare const POST: {
/** /**
* Unique post number for the current thread. * Unique post number for the current thread.
* *
* For use within a `THREAD.POSTS_IN_PAGE` selector. * For use within a `THREAD.POSTS_IN_PAGE` selector.
*/ */
NUMBER: string; NUMBER: string;
/** /**
* Unique ID of the post in the F95Zone platform in the `id` attribute. * Unique ID of the post in the F95Zone platform in the `id` attribute.
* *
* For use within a `THREAD.POSTS_IN_PAGE` selector. * For use within a `THREAD.POSTS_IN_PAGE` selector.
*/ */
ID: string; ID: string;
/** /**
* Unique ID of the post author in the `data-user-id` attribute. * Unique ID of the post author in the `data-user-id` attribute.
* *
* For use within a `THREAD.POSTS_IN_PAGE` selector. * For use within a `THREAD.POSTS_IN_PAGE` selector.
*/ */
OWNER_ID: string; OWNER_ID: string;
/** /**
* Main body of the post where the message written by the user is contained. * Main body of the post where the message written by the user is contained.
* *
* For use within a `THREAD.POSTS_IN_PAGE` selector. * For use within a `THREAD.POSTS_IN_PAGE` selector.
*/ */
BODY: string; BODY: string;
/** /**
* Publication date of the post contained in the `datetime` attribute as an ISO date. * Publication date of the post contained in the `datetime` attribute as an ISO date.
* *
* For use within a `THREAD.POSTS_IN_PAGE` selector. * For use within a `THREAD.POSTS_IN_PAGE` selector.
*/ */
PUBLISH_DATE: string; PUBLISH_DATE: string;
/** /**
* Last modified date of the post contained in the `datetime` attribute as the ISO date. * Last modified date of the post contained in the `datetime` attribute as the ISO date.
* *
* For use within a `THREAD.POSTS_IN_PAGE` selector. * For use within a `THREAD.POSTS_IN_PAGE` selector.
*/ */
LAST_EDIT: string; LAST_EDIT: string;
/** /**
* Gets the element only if the post has been bookmarked. * Gets the element only if the post has been bookmarked.
* *
* For use within a `THREAD.POSTS_IN_PAGE` selector. * For use within a `THREAD.POSTS_IN_PAGE` selector.
*/ */
BOOKMARKED: string; BOOKMARKED: string;
}; };
export declare const MEMBER: { export declare const MEMBER: {
/** /**
* Name of the user. * Name of the user.
* *
* It also contains the unique ID of the user in the `data-user-id` attribute. * It also contains the unique ID of the user in the `data-user-id` attribute.
*/ */
NAME: string; NAME: string;
/** /**
* Title of the user in the platform. * Title of the user in the platform.
* *
* i.e.: Member * i.e.: Member
*/ */
TITLE: string; TITLE: string;
/** /**
* Avatar used by the user. * Avatar used by the user.
* *
* Source in the attribute `src`. * Source in the attribute `src`.
*/ */
AVATAR: string; AVATAR: string;
/** /**
* User assigned banners. * User assigned banners.
* *
* The last element is always empty and can be ignored. * The last element is always empty and can be ignored.
*/ */
BANNERS: string; BANNERS: string;
/** /**
* Date the user joined the platform. * Date the user joined the platform.
* *
* The date is contained in the `datetime` attribute as an ISO string. * The date is contained in the `datetime` attribute as an ISO string.
*/ */
JOINED: string; JOINED: string;
/** /**
* Last time the user connected to the platform. * Last time the user connected to the platform.
* *
* The date is contained in the `datetime` attribute as an ISO string. * The date is contained in the `datetime` attribute as an ISO string.
*/ */
LAST_SEEN: string; LAST_SEEN: string;
MESSAGES: string; MESSAGES: string;
REACTION_SCORE: string; REACTION_SCORE: string;
POINTS: string; POINTS: string;
RATINGS_RECEIVED: string; RATINGS_RECEIVED: string;
AMOUNT_DONATED: string; AMOUNT_DONATED: string;
/** /**
* Button used to follow/unfollow the user. * Button used to follow/unfollow the user.
* *
* If the text is `Unfollow` then the user is followed. * If the text is `Unfollow` then the user is followed.
* If the text is `Follow` then the user is not followed. * If the text is `Follow` then the user is not followed.
*/ */
FOLLOWED: string; FOLLOWED: string;
/** /**
* Button used to ignore/unignore the user. * Button used to ignore/unignore the user.
* *
* If the text is `Unignore` then the user is ignored. * If the text is `Unignore` then the user is ignored.
* If the text is `Ignore` then the user is not ignored. * If the text is `Ignore` then the user is not ignored.
*/ */
IGNORED: string; IGNORED: string;
}; };

View File

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

View File

@ -8,4 +8,7 @@ import HandiworkSearchQuery from "../classes/query/handiwork-search-query";
* Maximum number of items to get. Default: 30 * Maximum number of items to get. Default: 30
* @returns {Promise<String[]>} URLs of the handiworks * @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,4 +9,7 @@ import LatestSearchQuery from "../classes/query/latest-search-query.js";
* Maximum number of items to get. Default: 30 * Maximum number of items to get. Default: 30
* @returns {Promise<String[]>} URLs of the handiworks * @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,4 +4,7 @@ import { IQuery } from "../interfaces.js";
* @param limit Maximum number of items to get. Default: 30 * @param limit Maximum number of items to get. Default: 30
* @returns URLs of the fetched games * @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,4 +9,7 @@ import ThreadSearchQuery from "../classes/query/thread-search-query.js";
* Maximum number of items to get. Default: 30 * Maximum number of items to get. Default: 30
* @returns {Promise<String[]>} URLs of the handiworks * @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

@ -2,49 +2,63 @@
* Data relating to an external platform (i.e. Patreon). * Data relating to an external platform (i.e. Patreon).
*/ */
export declare type TExternalPlatform = { export declare type TExternalPlatform = {
/** /**
* name of the platform. * name of the platform.
*/ */
name: string; name: string;
/** /**
* link to the platform. * link to the platform.
*/ */
link: string; link: string;
}; };
/** /**
* Information about the author of a work. * Information about the author of a work.
*/ */
export declare type TAuthor = { export declare type TAuthor = {
/** /**
* Plain name or username of the author. * Plain name or username of the author.
*/ */
name: string; name: string;
/** /**
* *
*/ */
platforms: TExternalPlatform[]; platforms: TExternalPlatform[];
}; };
/** /**
* Information on the evaluation of a work. * Information on the evaluation of a work.
*/ */
export declare type TRating = { export declare type TRating = {
/** /**
* average value of evaluations. * average value of evaluations.
*/ */
average: number; average: number;
/** /**
* Best rating received. * Best rating received.
*/ */
best: number; best: number;
/** /**
* Number of ratings made by users. * Number of ratings made by users.
*/ */
count: number; count: number;
}; };
/** /**
* List of possible graphics engines used for game development. * 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. * List of possible progress states associated with a game.
*/ */
@ -56,229 +70,231 @@ export declare type TCategory = "games" | "mods" | "comics" | "animations" | "as
/** /**
* Valid names of classes that implement the IQuery interface. * 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 * Collection of values defined for each
* handiwork on the F95Zone platform. * handiwork on the F95Zone platform.
*/ */
export interface IBasic { export interface IBasic {
/** /**
* Authors of the work. * Authors of the work.
*/ */
authors: TAuthor[]; authors: TAuthor[];
/** /**
* Category of the work.. * Category of the work..
*/ */
category: TCategory; category: TCategory;
/** /**
* List of changes of the work for each version. * List of changes of the work for each version.
*/ */
changelog: string[]; changelog: string[];
/** /**
* link to the cover image of the work. * link to the cover image of the work.
*/ */
cover: string; cover: string;
/** /**
* Unique ID of the work on the platform. * Unique ID of the work on the platform.
*/ */
id: number; id: number;
/** /**
* Last update of the opera thread. * Last update of the opera thread.
*/ */
lastThreadUpdate: Date; lastThreadUpdate: Date;
/** /**
* Plain name of the work (without tags and/or prefixes) * Plain name of the work (without tags and/or prefixes)
*/ */
name: string; name: string;
/** /**
* Work description * Work description
*/ */
overview: string; overview: string;
/** /**
* List of prefixes associated with the work. * List of prefixes associated with the work.
*/ */
prefixes: string[]; prefixes: string[];
/** /**
* Evaluation of the work by the users of the platform. * Evaluation of the work by the users of the platform.
*/ */
rating: TRating; rating: TRating;
/** /**
* List of tags associated with the work. * List of tags associated with the work.
*/ */
tags: string[]; tags: string[];
/** /**
* Date of publication of the thread associated with the work. * Date of publication of the thread associated with the work.
*/ */
threadPublishingDate: Date; threadPublishingDate: Date;
/** /**
* URL to the work's official conversation on the F95Zone portal. * URL to the work's official conversation on the F95Zone portal.
*/ */
url: string; url: string;
} }
/** /**
* Collection of values representing a game present on the F95Zone platform. * Collection of values representing a game present on the F95Zone platform.
*/ */
export interface IGame extends IBasic { export interface IGame extends IBasic {
/** /**
* Specify whether the work has censorship * Specify whether the work has censorship
* measures regarding NSFW scenes * measures regarding NSFW scenes
*/ */
censored: boolean; censored: boolean;
/** /**
* Graphics engine used for game development. * Graphics engine used for game development.
*/ */
engine: TEngine; engine: TEngine;
/** /**
* List of genres associated with the work. * List of genres associated with the work.
*/ */
genre: string[]; genre: string[];
/** /**
* Author's Guide to Installation. * Author's Guide to Installation.
*/ */
installation: string; installation: string;
/** /**
* List of available languages. * List of available languages.
*/ */
language: string[]; language: string[];
/** /**
* Last time the work underwent updates. * Last time the work underwent updates.
*/ */
lastRelease: Date; lastRelease: Date;
/** /**
* Indicates that this item represents a mod. * Indicates that this item represents a mod.
*/ */
mod: boolean; mod: boolean;
/** /**
* List of OS for which the work is compatible. * List of OS for which the work is compatible.
*/ */
os: string[]; os: string[];
/** /**
* Indicates the progress of a game. * Indicates the progress of a game.
*/ */
status: TStatus; status: TStatus;
/** /**
* Version of the work. * Version of the work.
*/ */
version: string; version: string;
} }
/** /**
* Collection of values representing a comic present on the F95Zone platform. * Collection of values representing a comic present on the F95Zone platform.
*/ */
export interface IComic extends IBasic { export interface IComic extends IBasic {
/** /**
* List of genres associated with the work. * List of genres associated with the work.
*/ */
genre: string[]; genre: string[];
/** /**
* Number of pages or elements that make up the work. * Number of pages or elements that make up the work.
*/ */
pages: string; pages: string;
/** /**
* List of resolutions available for the work. * List of resolutions available for the work.
*/ */
resolution: string[]; resolution: string[];
} }
/** /**
* Collection of values representing an animation present on the F95Zone platform. * Collection of values representing an animation present on the F95Zone platform.
*/ */
export interface IAnimation extends IBasic { export interface IAnimation extends IBasic {
/** /**
* Specify whether the work has censorship * Specify whether the work has censorship
* measures regarding NSFW scenes * measures regarding NSFW scenes
*/ */
censored: boolean; censored: boolean;
/** /**
* List of genres associated with the work. * List of genres associated with the work.
*/ */
genre: string[]; genre: string[];
/** /**
* Author's Guide to Installation. * Author's Guide to Installation.
*/ */
installation: string; installation: string;
/** /**
* List of available languages. * List of available languages.
*/ */
language: string[]; language: string[];
/** /**
* Length of the animation. * Length of the animation.
*/ */
lenght: string; lenght: string;
/** /**
* Number of pages or elements that make up the work. * Number of pages or elements that make up the work.
*/ */
pages: string; pages: string;
/** /**
* List of resolutions available for the work. * List of resolutions available for the work.
*/ */
resolution: string[]; resolution: string[];
} }
/** /**
* Collection of values representing an asset present on the F95Zone platform. * Collection of values representing an asset present on the F95Zone platform.
*/ */
export interface IAsset extends IBasic { export interface IAsset extends IBasic {
/** /**
* External URL of the asset. * External URL of the asset.
*/ */
assetLink: string; assetLink: string;
/** /**
* List of URLs of assets associated with the work * List of URLs of assets associated with the work
* (for example same collection). * (for example same collection).
*/ */
associatedAssets: string[]; associatedAssets: string[];
/** /**
* Software compatible with the work. * Software compatible with the work.
*/ */
compatibleSoftware: string; compatibleSoftware: string;
/** /**
* List of assets url included in the work or used to develop it. * List of assets url included in the work or used to develop it.
*/ */
includedAssets: string[]; includedAssets: string[];
/** /**
* List of official links of the work, external to the platform. * List of official links of the work, external to the platform.
*/ */
officialLinks: string[]; officialLinks: string[];
/** /**
* Unique SKU value of the work. * Unique SKU value of the work.
*/ */
sku: string; sku: string;
} }
/** /**
* Collection of values extrapolated from the * Collection of values extrapolated from the
* F95 platform representing a particular work. * 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 { export interface IQuery {
/** /**
* Name of the implemented interface. * Name of the implemented interface.
*/ */
itype: TQueryInterface; itype: TQueryInterface;
/** /**
* Category of items to search among. * Category of items to search among.
*/ */
category: TCategory; category: TCategory;
/** /**
* Tags to be include in the search. * Tags to be include in the search.
* Max. 5 tags * Max. 5 tags
*/ */
includedTags: string[]; includedTags: string[];
/** /**
* Prefixes to include in the search. * Prefixes to include in the search.
*/ */
includedPrefixes: string[]; includedPrefixes: string[];
/** /**
* Index of the page to be obtained. * Index of the page to be obtained.
* Between 1 and infinity. * Between 1 and infinity.
*/ */
page: number; page: number;
/** /**
* Verify that the query values are valid. * Verify that the query values are valid.
*/ */
validate(): boolean; validate(): boolean;
/** /**
* Search with the data in the query and returns the result. * Search with the data in the query and returns the result.
* *
* If the query is invalid it throws an exception. * If the query is invalid it throws an exception.
*/ */
execute(): any; execute(): any;
} }

View File

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

View File

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

@ -3,7 +3,7 @@
* Represents information contained in a JSON+LD tag. * Represents information contained in a JSON+LD tag.
*/ */
export declare type TJsonLD = { export declare type TJsonLD = {
[s: string]: string | TJsonLD; [s: string]: string | TJsonLD;
}; };
/** /**
* Extracts and processes the JSON-LD values of the page. * Extracts and processes the JSON-LD values of the page.

View File

@ -1,15 +1,18 @@
/// <reference types="cheerio" /> /// <reference types="cheerio" />
export interface IPostElement { export interface IPostElement {
type: "Empty" | "Text" | "Link" | "Image" | "Spoiler"; type: "Empty" | "Text" | "Link" | "Image" | "Spoiler";
name: string; name: string;
text: string; text: string;
content: IPostElement[]; content: IPostElement[];
} }
export interface ILink extends IPostElement { export interface ILink extends IPostElement {
type: "Image" | "Link"; type: "Image" | "Link";
href: string; href: string;
} }
/** /**
* Given a post of a thread page it extracts the information contained in the body. * 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,4 +5,7 @@ import { IBasic, IQuery } from "./interfaces.js";
* @param {Number} limit * @param {Number} limit
* Maximum number of items to get. Default: 30 * 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[]>;

58
scripts/shared.d.ts vendored
View File

@ -1,40 +1,40 @@
import log4js from "log4js"; import log4js from "log4js";
import Session from "./classes/session.js"; import Session from "./classes/session.js";
export declare type TPrefixDict = { export declare type TPrefixDict = {
[n: number]: string; [n: number]: string;
}; };
declare type TPrefixKey = "engines" | "statuses" | "tags" | "others"; declare type TPrefixKey = "engines" | "statuses" | "tags" | "others";
/** /**
* Class containing variables shared between modules. * Class containing variables shared between modules.
*/ */
export default abstract class Shared { export default abstract class Shared {
private static _isLogged; private static _isLogged;
private static _prefixes; private static _prefixes;
private static _logger; private static _logger;
private static _session; private static _session;
/** /**
* Indicates whether a user is logged in to the F95Zone platform or not. * Indicates whether a user is logged in to the F95Zone platform or not.
*/ */
static get isLogged(): boolean; static get isLogged(): boolean;
/** /**
* List of platform prefixes and tags. * List of platform prefixes and tags.
*/ */
static get prefixes(): { static get prefixes(): {
[s: string]: TPrefixDict; [s: string]: TPrefixDict;
}; };
/** /**
* Logger object used to write to both file and console. * Logger object used to write to both file and console.
*/ */
static get logger(): log4js.Logger; static get logger(): log4js.Logger;
/** /**
* Path to the cache used by this module wich contains engines, statuses, tags... * Path to the cache used by this module wich contains engines, statuses, tags...
*/ */
static get cachePath(): string; static get cachePath(): string;
/** /**
* Session on the F95Zone platform. * Session on the F95Zone platform.
*/ */
static get session(): Session; static get session(): Session;
static setPrefixPair(key: TPrefixKey, val: TPrefixDict): void; static setPrefixPair(key: TPrefixKey, val: TPrefixDict): void;
static setIsLogged(val: boolean): void; static setIsLogged(val: boolean): void;
} }
export {}; export {};