refactor: Convert all enums to const object types in nodes-base (no-changelog) (#14131)

This commit is contained in:
Alex Grozav
2025-03-24 14:40:19 +02:00
committed by GitHub
parent defeb2e817
commit b9608647ca
31 changed files with 422 additions and 345 deletions

View File

@@ -43,14 +43,16 @@ export interface Command {
};
}
export const enum CommandType {
ITEM_MOVE = 'item_move',
ITEM_ADD = 'item_add',
ITEM_UPDATE = 'item_update',
ITEM_REORDER = 'item_reorder',
ITEM_DELETE = 'item_delete',
ITEM_COMPLETE = 'item_complete',
}
export const CommandTypes = {
ITEM_MOVE: 'item_move',
ITEM_ADD: 'item_add',
ITEM_UPDATE: 'item_update',
ITEM_REORDER: 'item_reorder',
ITEM_DELETE: 'item_delete',
ITEM_COMPLETE: 'item_complete',
} as const;
export type CommandType = (typeof CommandTypes)[keyof typeof CommandTypes];
async function getLabelNameFromId(ctx: Context, labelIds: number[]): Promise<string[]> {
const labelList = [];
@@ -263,7 +265,7 @@ export class MoveHandler implements OperationHandler {
const body: SyncRequest = {
commands: [
{
type: CommandType.ITEM_MOVE,
type: CommandTypes.ITEM_MOVE,
uuid: uuid(),
args: {
id: taskId,
@@ -339,7 +341,7 @@ export class SyncHandler implements OperationHandler {
}
private requiresProjectId(command: Command) {
return command.type === CommandType.ITEM_ADD;
return command.type === CommandTypes.ITEM_ADD;
}
private enrichTempId(command: Command, tempIdMapping: Map<string, string>, projectId: number) {
@@ -350,6 +352,6 @@ export class SyncHandler implements OperationHandler {
}
private requiresTempId(command: Command) {
return command.type === CommandType.ITEM_ADD;
return command.type === CommandTypes.ITEM_ADD;
}
}