Type simplifications (for documentation)

This commit is contained in:
DJj123dj
2025-02-27 20:51:59 +01:00
parent 0d40c23aa8
commit 177dee7468
3 changed files with 183 additions and 139 deletions
+5
View File
@@ -40,6 +40,11 @@ export type ODValidJsonType = string|number|boolean|object|ODValidJsonType[]|nul
*/
export type ODInterfaceWithPartialProperty<Interface,Key extends keyof Interface> = Omit<Interface,Key> & Partial<Pick<Interface,Key>>
/**## ODDiscordIdType `type`
* A list of all available discord ID types. Used in the config checker.
*/
export type ODDiscordIdType = "role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message"
/**## ODId `class`
* This is an Open Ticket identifier.
*
+13 -8
View File
@@ -1,7 +1,7 @@
///////////////////////////////////////
//CONFIG CHECKER MODULE
///////////////////////////////////////
import { ODId, ODManager, ODManagerData, ODValidId, ODValidJsonType } from "./base"
import { ODDiscordIdType, ODId, ODManager, ODManagerData, ODValidId, ODValidJsonType } from "./base"
import { ODConfig } from "./config"
import { ODLanguageManager } from "./language"
import { ODDebugger } from "./console"
@@ -218,6 +218,11 @@ export class ODCheckerTranslationRegister {
}
}
/**## ODCheckerFunctionCallback `type`
* This is the function used in the `ODCheckerFunction` class.
*/
export type ODCheckerFunctionCallback = (manager:ODCheckerManager, functions:ODCheckerFunctionManager) => ODCheckerResult
/**## ODCheckerFunction `class`
* This is an Open Ticket config checker function.
*
@@ -225,10 +230,10 @@ export class ODCheckerTranslationRegister {
* It's mostly used for things that need to be checked globally!
*/
export class ODCheckerFunction extends ODManagerData {
/**The function itself :) */
func: (manager:ODCheckerManager, functions:ODCheckerFunctionManager) => ODCheckerResult
/**The function which will be executed globally after all config checkers. */
func: ODCheckerFunctionCallback
constructor(id:ODValidId, func:(manager:ODCheckerManager, functions:ODCheckerFunctionManager) => ODCheckerResult){
constructor(id:ODValidId, func:ODCheckerFunctionCallback){
super(id)
this.func = func
}
@@ -1043,13 +1048,13 @@ export class ODCheckerEnabledObjectStructure extends ODCheckerStructure {
*/
export class ODCheckerCustomStructure_DiscordId extends ODCheckerStringStructure {
/**The type of id (used in rendering) */
readonly type: "role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message"
readonly type: ODDiscordIdType
/**Is this id allowed to be empty */
readonly emptyAllowed: boolean
/**Extra matches (value will also be valid when one of these options match) */
readonly extraOptions: string[]
constructor(id:ODValidId, type:"role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message", emptyAllowed:boolean, extraOptions:string[], options?:ODCheckerStringStructureOptions){
constructor(id:ODValidId, type:ODDiscordIdType, emptyAllowed:boolean, extraOptions:string[], options?:ODCheckerStringStructureOptions){
//add premade custom structure checker
const newOptions = options ?? {}
newOptions.custom = (checker,value,locationTrace,locationId,locationDocs) => {
@@ -1083,11 +1088,11 @@ export class ODCheckerCustomStructure_DiscordId extends ODCheckerStringStructure
*/
export class ODCheckerCustomStructure_DiscordIdArray extends ODCheckerArrayStructure {
/**The type of id (used in rendering) */
readonly type: "role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message"
readonly type: ODDiscordIdType
/**Extra matches (value will also be valid when one of these options match) */
readonly extraOptions: string[]
constructor(id:ODValidId, type:"role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message", extraOptions:string[], options?:ODCheckerArrayStructureOptions, idOptions?:ODCheckerStringStructureOptions){
constructor(id:ODValidId, type:ODDiscordIdType, extraOptions:string[], options?:ODCheckerArrayStructureOptions, idOptions?:ODCheckerStringStructureOptions){
//add premade custom structure checker
const newOptions = options ?? {}
newOptions.propertyChecker = new ODCheckerCustomStructure_DiscordId(id,type,false,extraOptions,idOptions)