Add types and renamed class
							parent
							
								
									71ba083666
								
							
						
					
					
						commit
						31d31bbf08
					
				| 
						 | 
					@ -5,6 +5,11 @@ import validator from 'class-validator';
 | 
				
			||||||
import { urls } from "../constants/url.js";
 | 
					import { urls } from "../constants/url.js";
 | 
				
			||||||
import PrefixParser from './prefix-parser.js';
 | 
					import PrefixParser from './prefix-parser.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Type definitions
 | 
				
			||||||
 | 
					type TCategory = "games" | "comics" | "animations" | "assets";
 | 
				
			||||||
 | 
					type TSort = "date" | "likes" | "views" | "title" | "rating";
 | 
				
			||||||
 | 
					type TDate = 365 | 180 | 90 | 30 | 14 | 7 | 3 | 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Query used to search for specific threads on the platform.
 | 
					 * Query used to search for specific threads on the platform.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -13,21 +18,14 @@ export default class HandiworkSearchQuery {
 | 
				
			||||||
    //#region Private fields
 | 
					    //#region Private fields
 | 
				
			||||||
    private static MAX_TAGS = 5;
 | 
					    private static MAX_TAGS = 5;
 | 
				
			||||||
    private static MIN_PAGE = 1;
 | 
					    private static MIN_PAGE = 1;
 | 
				
			||||||
    private static VALID_CATEGORY = ["games", "comics", "animations", "assets"];
 | 
					 | 
				
			||||||
    private static VALID_SORT = ["date", "likes", "views", "title", "rating"];
 | 
					 | 
				
			||||||
    private static VALID_DATE = [365, 180, 90, 30, 14, 7, 3, 1, null];
 | 
					 | 
				
			||||||
    //#endregion Private fields
 | 
					    //#endregion Private fields
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //#region Properties
 | 
					    //#region Properties
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Category of items to search among:
 | 
					     * Category of items to search among.
 | 
				
			||||||
     * `games`, `comics`, `animations`, `assets`.
 | 
					 | 
				
			||||||
     * Default: `games`
 | 
					     * Default: `games`
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @validator.IsIn(HandiworkSearchQuery.VALID_CATEGORY, {
 | 
					    public category: TCategory = 'games';
 | 
				
			||||||
        message: "Invalid $property parameter: $value"
 | 
					 | 
				
			||||||
    })
 | 
					 | 
				
			||||||
    public category = 'games';
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * List of IDs of tags to be included in the search.
 | 
					     * List of IDs of tags to be included in the search.
 | 
				
			||||||
     * Max. 5 tags
 | 
					     * Max. 5 tags
 | 
				
			||||||
| 
						 | 
					@ -47,24 +45,15 @@ export default class HandiworkSearchQuery {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    public prefixes: string[] = [];
 | 
					    public prefixes: string[] = [];
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sorting type between (default: `date`):
 | 
					     * Sorting type. Default: `date`.
 | 
				
			||||||
     * `date`, `likes`, `views`, `title`, `rating`
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @validator.IsIn(HandiworkSearchQuery.VALID_SORT, {
 | 
					    public sort: TSort = 'date';
 | 
				
			||||||
        message: "Invalid $property parameter: $value"
 | 
					 | 
				
			||||||
    })
 | 
					 | 
				
			||||||
    public sort = 'date';
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Date limit in days, to be understood as "less than".
 | 
					     * Date limit in days, to be understood as "less than".
 | 
				
			||||||
     * Possible values:
 | 
					 | 
				
			||||||
     * `365`, `180`, `90`, `30`, `14`, `7`, `3`, `1`.
 | 
					 | 
				
			||||||
     * Use `1` to indicate "today" or `null` to indicate "anytime".
 | 
					     * Use `1` to indicate "today" or `null` to indicate "anytime".
 | 
				
			||||||
     * Default: `null`
 | 
					     * Default: `null`
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @validator.IsIn(HandiworkSearchQuery.VALID_DATE, {
 | 
					    public date: TDate = null;
 | 
				
			||||||
        message: "Invalid $property parameter: $value"
 | 
					 | 
				
			||||||
    })
 | 
					 | 
				
			||||||
    public date: number = null;
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Index of the page to be obtained.
 | 
					     * Index of the page to be obtained.
 | 
				
			||||||
     * Between 1 and infinity.
 | 
					     * Between 1 and infinity.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue