refactor(server): enums (#11809)

This commit is contained in:
Jason Rasmussen
2024-08-15 06:57:01 -04:00
committed by GitHub
parent fa64277476
commit b288241a5c
82 changed files with 242 additions and 207 deletions

View File

@@ -1,4 +1,5 @@
import { UserEntity } from 'src/entities/user.entity';
import { UserAvatarColor, UserMetadataKey } from 'src/enum';
import { HumanReadableSize } from 'src/utils/bytes';
import { Column, DeepPartial, Entity, ManyToOne, PrimaryColumn } from 'typeorm';
@@ -17,19 +18,6 @@ export class UserMetadataEntity<T extends keyof UserMetadata = UserMetadataKey>
value!: UserMetadata[T];
}
export enum UserAvatarColor {
PRIMARY = 'primary',
PINK = 'pink',
RED = 'red',
YELLOW = 'yellow',
BLUE = 'blue',
GREEN = 'green',
PURPLE = 'purple',
ORANGE = 'orange',
GRAY = 'gray',
AMBER = 'amber',
}
export interface UserPreferences {
rating: {
enabled: boolean;
@@ -85,11 +73,6 @@ export const getDefaultPreferences = (user: { email: string }): UserPreferences
};
};
export enum UserMetadataKey {
PREFERENCES = 'preferences',
LICENSE = 'license',
}
export interface UserMetadata extends Record<UserMetadataKey, Record<string, any>> {
[UserMetadataKey.PREFERENCES]: DeepPartial<UserPreferences>;
[UserMetadataKey.LICENSE]: { licenseKey: string; activationKey: string; activatedAt: Date };