Commander register api
talking about permissions, im working on the registering api for the Commander, and I wanted to ask for some general feedback: if it makes sense, if I might be missing something obvious, possible ideas for something to add, you name it.
interface Command {
name: string; // name of the command - used for finding command suggestions
description?: string; // OPTIONAL will shown when hovering over a command suggestion, and can also be seen listing the command by console
schema: string; // expression that constitutes the command - MUST start with command name, and have each Argument name separated by spaces, each starting with a $ (e.g. "sum $first $second")
args: Argument[]; // array of arguments present on the schema
roles: Roles[]; // array of any user roles that can execute this as defined in CONST.USER_ROLES (default ['GAMEMASTER'])
permissions: Permissions[]; // array of user permissions needed to execute this command as defined in CONST.USER_PERMISSIONS; requires ALL to execute (default [])
// ideally it should be any permissions needed by whatever the handler() and suggestions() functions are doing, but it can impose artificial restrictions too
anyPermission: boolean; // changes the permissions behavoir to be require ANY instead of ALL (default false)
handler: (...params: any) => any; // waht you actually wanted to
}
interface Argument {
name: string; //schema must have this name prefixed by a $, and this name will be used for the param sent to the handler function
type: ARGUMENT_TYPES; // defines what regex to use to get this argument from the command line input. string | number | boolean | raw
suggestions: () => Suggestion[]; // OPTIONAL should return an array of objects with a displayName - handler function should know how to handle these
};
interface Suggestion {
displayName: string;
}
enum ARGUMENT_TYPES {
NUMBER = 'number',
STRING = 'string',
BOOLEAN = 'boolean',
RAW = 'raw',
}interface Command {
name: string; // name of the command - used for finding command suggestions
description?: string; // OPTIONAL will shown when hovering over a command suggestion, and can also be seen listing the command by console
schema: string; // expression that constitutes the command - MUST start with command name, and have each Argument name separated by spaces, each starting with a $ (e.g. "sum $first $second")
args: Argument[]; // array of arguments present on the schema
roles: Roles[]; // array of any user roles that can execute this as defined in CONST.USER_ROLES (default ['GAMEMASTER'])
permissions: Permissions[]; // array of user permissions needed to execute this command as defined in CONST.USER_PERMISSIONS; requires ALL to execute (default [])
// ideally it should be any permissions needed by whatever the handler() and suggestions() functions are doing, but it can impose artificial restrictions too
anyPermission: boolean; // changes the permissions behavoir to be require ANY instead of ALL (default false)
handler: (...params: any) => any; // waht you actually wanted to
}
interface Argument {
name: string; //schema must have this name prefixed by a $, and this name will be used for the param sent to the handler function
type: ARGUMENT_TYPES; // defines what regex to use to get this argument from the command line input. string | number | boolean | raw
suggestions: () => Suggestion[]; // OPTIONAL should return an array of objects with a displayName - handler function should know how to handle these
};
interface Suggestion {
displayName: string;
}
enum ARGUMENT_TYPES {
NUMBER = 'number',
STRING = 'string',
BOOLEAN = 'boolean',
RAW = 'raw',
}