refactor(server): system config (#1353)

* refactor(server): system config

* fix: jest circular import

* chore: ignore migrations in coverage report

* chore: tests

* chore: tests

* chore: todo note

* chore: remove vite config backup

* chore: fix redis hostname
This commit is contained in:
Jason Rasmussen
2023-01-21 11:11:55 -05:00
committed by GitHub
parent 66cd7dd809
commit c0a6b3d5a3
92 changed files with 842 additions and 614 deletions

View File

@@ -0,0 +1,3 @@
export * from './interfaces';
export * from './job.constants';
export * from './job.repository';

View File

@@ -0,0 +1,13 @@
import { AssetEntity } from '@app/infra/db/entities';
export interface IAssetUploadedJob {
/**
* The Asset entity that was saved in the database
*/
asset: AssetEntity;
/**
* Original file name
*/
fileName: string;
}

View File

@@ -0,0 +1,5 @@
import { AssetEntity } from '@app/infra/db/entities';
export interface IDeleteFileOnDiskJob {
assets: AssetEntity[];
}

View File

@@ -0,0 +1,7 @@
export * from './asset-uploaded.interface';
export * from './background-task.interface';
export * from './machine-learning.interface';
export * from './metadata-extraction.interface';
export * from './thumbnail-generation.interface';
export * from './user-deletion.interface';
export * from './video-transcode.interface';

View File

@@ -0,0 +1,8 @@
import { AssetEntity } from '@app/infra/db/entities';
export interface IMachineLearningJob {
/**
* The Asset entity that was saved in the database
*/
asset: AssetEntity;
}

View File

@@ -0,0 +1,36 @@
import { AssetEntity } from '@app/infra/db/entities';
export interface IExifExtractionProcessor {
/**
* The Asset entity that was saved in the database
*/
asset: AssetEntity;
/**
* Original file name
*/
fileName: string;
}
export interface IVideoLengthExtractionProcessor {
/**
* The Asset entity that was saved in the database
*/
asset: AssetEntity;
/**
* Original file name
*/
fileName: string;
}
export interface IReverseGeocodingProcessor {
exifId: string;
latitude: number;
longitude: number;
}
export type IMetadataExtractionJob =
| IExifExtractionProcessor
| IVideoLengthExtractionProcessor
| IReverseGeocodingProcessor;

View File

@@ -0,0 +1,17 @@
import { AssetEntity } from '@app/infra/db/entities';
export interface JpegGeneratorProcessor {
/**
* The Asset entity that was saved in the database
*/
asset: AssetEntity;
}
export interface WebpGeneratorProcessor {
/**
* The Asset entity that was saved in the database
*/
asset: AssetEntity;
}
export type IThumbnailGenerationJob = JpegGeneratorProcessor | WebpGeneratorProcessor;

View File

@@ -0,0 +1,8 @@
import { UserEntity } from '@app/infra/db/entities';
export interface IUserDeletionJob {
/**
* The user entity that was saved in the database
*/
user: UserEntity;
}

View File

@@ -0,0 +1,10 @@
import { AssetEntity } from '@app/infra/db/entities';
export interface IMp4ConversionProcessor {
/**
* The Asset entity that was saved in the database
*/
asset: AssetEntity;
}
export type IVideoTranscodeJob = IMp4ConversionProcessor;

View File

@@ -0,0 +1,27 @@
export enum QueueName {
THUMBNAIL_GENERATION = 'thumbnail-generation-queue',
METADATA_EXTRACTION = 'metadata-extraction-queue',
VIDEO_CONVERSION = 'video-conversion-queue',
CHECKSUM_GENERATION = 'generate-checksum-queue',
ASSET_UPLOADED = 'asset-uploaded-queue',
MACHINE_LEARNING = 'machine-learning-queue',
USER_DELETION = 'user-deletion-queue',
CONFIG = 'config-queue',
BACKGROUND_TASK = 'background-task',
}
export enum JobName {
ASSET_UPLOADED = 'asset-uploaded',
MP4_CONVERSION = 'mp4-conversion',
GENERATE_JPEG_THUMBNAIL = 'generate-jpeg-thumbnail',
GENERATE_WEBP_THUMBNAIL = 'generate-webp-thumbnail',
EXIF_EXTRACTION = 'exif-extraction',
EXTRACT_VIDEO_METADATA = 'extract-video-metadata',
REVERSE_GEOCODING = 'reverse-geocoding',
USER_DELETION = 'user-deletion',
TEMPLATE_MIGRATION = 'template-migration',
CONFIG_CHANGE = 'config-change',
OBJECT_DETECTION = 'detect-object',
IMAGE_TAGGING = 'tag-image',
DELETE_FILE_ON_DISK = 'delete-file-on-disk',
}

View File

@@ -0,0 +1,32 @@
import {
IAssetUploadedJob,
IDeleteFileOnDiskJob,
IExifExtractionProcessor,
IMachineLearningJob,
IMp4ConversionProcessor,
IReverseGeocodingProcessor,
IUserDeletionJob,
JpegGeneratorProcessor,
WebpGeneratorProcessor,
} from './interfaces';
import { JobName } from './job.constants';
export type JobItem =
| { name: JobName.ASSET_UPLOADED; data: IAssetUploadedJob }
| { name: JobName.MP4_CONVERSION; data: IMp4ConversionProcessor }
| { name: JobName.GENERATE_JPEG_THUMBNAIL; data: JpegGeneratorProcessor }
| { name: JobName.GENERATE_WEBP_THUMBNAIL; data: WebpGeneratorProcessor }
| { name: JobName.EXIF_EXTRACTION; data: IExifExtractionProcessor }
| { name: JobName.REVERSE_GEOCODING; data: IReverseGeocodingProcessor }
| { name: JobName.USER_DELETION; data: IUserDeletionJob }
| { name: JobName.TEMPLATE_MIGRATION }
| { name: JobName.CONFIG_CHANGE }
| { name: JobName.OBJECT_DETECTION; data: IMachineLearningJob }
| { name: JobName.IMAGE_TAGGING; data: IMachineLearningJob }
| { name: JobName.DELETE_FILE_ON_DISK; data: IDeleteFileOnDiskJob };
export const IJobRepository = 'IJobRepository';
export interface IJobRepository {
add(item: JobItem): Promise<void>;
}