All files / src/types PrjTypes.ts

0% Statements 0/37
0% Branches 0/33
0% Functions 0/12
0% Lines 0/37

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
/* eslint-disable deprecation/deprecation */
import Lng from 'src/classes/Lng';
import { StatusTypes } from 'src/libs/StatusType/interfaces/IStatusType';
import { StatusType } from 'src/libs/StatusType/StatusType';
import { FileType as FileType_ } from '../libs/FileType/FileType';
import { FileTypes } from '../libs/FileType/interfaces/IFileType';
 
/**
 * Represents the types used in the app.
 * @deprecated Use {@link FileTypes} instead.
 */
export type FileType = 'Topic' | 'Project' | 'Task' | 'Metadata' | 'Note';
 
/**
 * Represents the subtypes of a file.
 */
export type FileSubType = null | 'Cluster' | 'Kanban';
 
/**
 * Represents a history entry.
 */
export type HistoryEntry = {
    status: string;
    date: string;
};
 
/**
 * Represents a list of history entries.
 */
export type HistoryEntries = HistoryEntry[];
 
/**
 * Represents the status of a task.
 * @deprecated Use {@link StatusTypes} instead.
 */
export type Status = 'Active' | 'Waiting' | 'Later' | 'Someday' | 'Done';
 
/**
 * Represents the priority of a task.
 */
export type Priority = 0 | 1 | 2 | 3;
 
/**
 * Represents the energy level of a task.
 */
export type Energy = 0 | 1 | 2 | 3;
 
/**
 * Represents the symbols used for urgency.
 */
export type UrgencySymbols = '🔴' | '🟠' | '🟡' | '🟢' | '🔵';
 
/**
 * Represents the PrjTypes class.
 */
export default class PrjTypes {
    /**
     * An array of valid file types.
     * @deprecated Use {@link FileType_.types} instead.
     */
    public static readonly fileTypes: FileType[] = [
        'Topic',
        'Project',
        'Task',
        'Metadata',
        'Note',
    ];
 
    /**
     * Checks if a given value is a valid file type.
     * @param fileType - The value to check.
     * @returns The valid file type or undefined if the value is not valid.
     * @deprecated Use {@link FileType_.validate} instead.
     */
    public static isValidFileType(fileType: unknown): FileType | undefined {
        Iif (
            fileType &&
            typeof fileType === 'string' &&
            PrjTypes.fileTypes.includes(fileType as FileType)
        ) {
            return fileType as FileType;
        }
 
        return undefined;
    }
 
    /**
     * Checks if a given file type or an array of file types is included in another given file type or an array of file types.
     * @param typesToCheck The file type or array of file types to check.
     * @param typesToBeChecked The file type or array of file types to be checked against.
     * @returns A boolean indicating whether the file type(s) to be checked are included in the file type(s) to check.
     * @deprecated Use {@link FileType_.isValidOf} instead.
     */
    public static isTypeIncluded(
        typesToCheck: FileType | FileType[],
        typesToBeChecked: FileType | FileType[],
    ): boolean {
        const _typesToCheck: FileType[] = Array.isArray(typesToCheck)
            ? typesToCheck
            : typesToCheck
              ? [typesToCheck]
              : [];
 
        const _typesToBeChecked: FileType[] = Array.isArray(typesToBeChecked)
            ? typesToBeChecked
            : typesToBeChecked
              ? [typesToBeChecked]
              : [];
 
        return _typesToCheck.some((typeToCheck) =>
            _typesToBeChecked.some(
                (typeToBeChecked) => typeToBeChecked === typeToCheck,
            ),
        );
    }
 
    /**
     * An array of valid file subtypes.
     */
    public static readonly fileSubTypes: FileSubType[] = [
        null,
        'Cluster',
        'Kanban',
    ];
 
    /**
     * Checks if a given value is a valid file subtype.
     * @param fileSubType - The value to check.
     * @returns The valid file subtype or undefined if the value is not valid.
     */
    public static isValidFileSubType(
        fileSubType: unknown,
    ): FileSubType | undefined {
        Iif (
            fileSubType &&
            typeof fileSubType === 'string' &&
            PrjTypes.fileSubTypes.includes(fileSubType as FileSubType)
        ) {
            return fileSubType as FileSubType;
        }
 
        return undefined;
    }
 
    /**
     * An array of valid task statuses.
     * @deprecated Use {@link StatusType.types} instead.
     */
    public static readonly statuses: Status[] = [
        'Active',
        'Waiting',
        'Later',
        'Someday',
        'Done',
    ];
 
    /**
     * Checks if a given value is a valid task status.
     * @param status - The value to check.
     * @returns The valid task status or undefined if the value is not valid.
     * @deprecated Use {@link StatusType.validate} instead.
     */
    public static isValidStatus(status: unknown): Status | undefined {
        Iif (
            status &&
            typeof status === 'string' &&
            PrjTypes.statuses.includes(status as Status)
        ) {
            return status as Status;
        }
 
        return undefined;
    }
 
    /**
     * Returns a valid status if the given status is a valid translation.
     * @param status The status to check.
     * @returns The valid status or undefined if the status is not valid.
     * @deprecated Use {@link StatusType.getValidStatusFromTranslation} instead.
     */
    public static getValidStatusFromLanguage(
        status: string,
    ): Status | undefined {
        let validStatus: Status | undefined;
 
        this.statuses.forEach((statusFromValidStatuses) => {
            const translation = Lng.gtAll(`Status${statusFromValidStatuses}`);
 
            translation.forEach((translationFromStatus) => {
                Iif (translationFromStatus === status) {
                    validStatus = statusFromValidStatuses;
                }
            });
        });
 
        return validStatus;
    }
 
    /**
     * An array of valid task priorities.
     */
    public static readonly priorities: Priority[] = [0, 1, 2, 3];
 
    /**
     * Checks if a given value is a valid task priority.
     * @param priority - The value to check.
     * @returns The valid task priority or undefined if the value is not valid.
     */
    public static isValidPriority(priority: unknown): Priority | undefined {
        Iif (
            priority &&
            typeof priority === 'number' &&
            PrjTypes.priorities.includes(priority as Priority)
        ) {
            return priority as Priority;
        }
 
        return undefined;
    }
 
    /**
     * An array of valid task energy levels.
     */
    public static readonly energies: Energy[] = [0, 1, 2, 3];
 
    /**
     * Checks if a given value is a valid task energy level.
     * @param energy - The value to check.
     * @returns The valid task energy level or undefined if the value is not valid.
     */
    public static isValidEnergy(energy: unknown): Energy | undefined {
        Iif (
            energy &&
            typeof energy === 'number' &&
            PrjTypes.energies.includes(energy as Energy)
        ) {
            return energy as Energy;
        }
 
        return undefined;
    }
 
    /**
     * An array of valid urgency symbols.
     */
    public static readonly urgencySymbols: UrgencySymbols[] = [
        '🔴',
        '🟠',
        '🟡',
        '🟢',
        '🔵',
    ];
 
    /**
     * Checks if a given value is a valid urgency symbol.
     * @param urgencySymbol - The value to check.
     * @returns The valid urgency symbol or undefined if the value is not valid.
     */
    public static isValidUrgencySymbol(
        urgencySymbol: unknown,
    ): UrgencySymbols | undefined {
        Iif (
            urgencySymbol &&
            typeof urgencySymbol === 'string' &&
            PrjTypes.urgencySymbols.includes(urgencySymbol as UrgencySymbols)
        ) {
            return urgencySymbol as UrgencySymbols;
        }
 
        return undefined;
    }
}
 
Zur TypeDoc-Dokumentation