* refactor: library scanning fix tests remove offline files step cleanup library service improve tests cleanup tests add db migration fix e2e cleanup openapi fix tests fix tests update docs update docs update mobile code fix formatting don't remove assets from library with invalid import path use trash for offline files add migration simplify scan endpoint cleanup library panel fix library tests e2e lint fix e2e trash e2e fix lint add asset trash tests add more tests ensure thumbs are generated cleanup svelte cleanup queue names fix tests fix lint add warning due to trash fix trash tests fix lint fix tests Admin message for offline asset fix comments Update web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> add permission to library scan endpoint revert asset interface sort add trash reason to shared link stub improve path view in offline update docs improve trash performance fix comments remove stray comment * refactor: add back isOffline and remove trashReason from asset, change sync job flow * chore(server): drop coverage to 80% for functions * chore: rebase and generated files --------- Co-authored-by: Zack Pollard <zackpollard@ymail.com>
140 lines
2.8 KiB
TypeScript
140 lines
2.8 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { ArrayMaxSize, ArrayUnique, IsNotEmpty, IsString } from 'class-validator';
|
|
import { LibraryEntity } from 'src/entities/library.entity';
|
|
import { Optional, ValidateUUID } from 'src/validation';
|
|
|
|
export class CreateLibraryDto {
|
|
@ValidateUUID()
|
|
ownerId!: string;
|
|
|
|
@IsString()
|
|
@Optional()
|
|
@IsNotEmpty()
|
|
name?: string;
|
|
|
|
@Optional()
|
|
@IsString({ each: true })
|
|
@IsNotEmpty({ each: true })
|
|
@ArrayUnique()
|
|
@ArrayMaxSize(128)
|
|
importPaths?: string[];
|
|
|
|
@Optional()
|
|
@IsString({ each: true })
|
|
@IsNotEmpty({ each: true })
|
|
@ArrayUnique()
|
|
@ArrayMaxSize(128)
|
|
exclusionPatterns?: string[];
|
|
}
|
|
|
|
export class UpdateLibraryDto {
|
|
@Optional()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
name?: string;
|
|
|
|
@Optional()
|
|
@IsString({ each: true })
|
|
@IsNotEmpty({ each: true })
|
|
@ArrayUnique()
|
|
@ArrayMaxSize(128)
|
|
importPaths?: string[];
|
|
|
|
@Optional()
|
|
@IsNotEmpty({ each: true })
|
|
@IsString({ each: true })
|
|
@ArrayUnique()
|
|
@ArrayMaxSize(128)
|
|
exclusionPatterns?: string[];
|
|
}
|
|
|
|
export interface CrawlOptionsDto {
|
|
pathsToCrawl: string[];
|
|
includeHidden?: boolean;
|
|
exclusionPatterns?: string[];
|
|
}
|
|
|
|
export interface WalkOptionsDto extends CrawlOptionsDto {
|
|
take: number;
|
|
}
|
|
|
|
export class ValidateLibraryDto {
|
|
@Optional()
|
|
@IsString({ each: true })
|
|
@IsNotEmpty({ each: true })
|
|
@ArrayUnique()
|
|
@ArrayMaxSize(128)
|
|
importPaths?: string[];
|
|
|
|
@Optional()
|
|
@IsNotEmpty({ each: true })
|
|
@IsString({ each: true })
|
|
@ArrayUnique()
|
|
@ArrayMaxSize(128)
|
|
exclusionPatterns?: string[];
|
|
}
|
|
|
|
export class ValidateLibraryResponseDto {
|
|
importPaths?: ValidateLibraryImportPathResponseDto[];
|
|
}
|
|
|
|
export class ValidateLibraryImportPathResponseDto {
|
|
importPath!: string;
|
|
isValid: boolean = false;
|
|
message?: string;
|
|
}
|
|
|
|
export class LibrarySearchDto {
|
|
@ValidateUUID({ optional: true })
|
|
userId?: string;
|
|
}
|
|
|
|
export class LibraryResponseDto {
|
|
id!: string;
|
|
ownerId!: string;
|
|
name!: string;
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
assetCount!: number;
|
|
|
|
importPaths!: string[];
|
|
|
|
exclusionPatterns!: string[];
|
|
|
|
createdAt!: Date;
|
|
updatedAt!: Date;
|
|
refreshedAt!: Date | null;
|
|
}
|
|
|
|
export class LibraryStatsResponseDto {
|
|
@ApiProperty({ type: 'integer' })
|
|
photos = 0;
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
videos = 0;
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
total = 0;
|
|
|
|
@ApiProperty({ type: 'integer', format: 'int64' })
|
|
usage = 0;
|
|
}
|
|
|
|
export function mapLibrary(entity: LibraryEntity): LibraryResponseDto {
|
|
let assetCount = 0;
|
|
if (entity.assets) {
|
|
assetCount = entity.assets.length;
|
|
}
|
|
return {
|
|
id: entity.id,
|
|
ownerId: entity.ownerId,
|
|
name: entity.name,
|
|
createdAt: entity.createdAt,
|
|
updatedAt: entity.updatedAt,
|
|
refreshedAt: entity.refreshedAt,
|
|
assetCount,
|
|
importPaths: entity.importPaths,
|
|
exclusionPatterns: entity.exclusionPatterns,
|
|
};
|
|
}
|