4a8887f37b
* refactor(server): delete assets endpoint * fix: formatting * chore: cleanup * chore: open api * chore(mobile): replace DeleteAssetDTO with BulkIdsDTOs * feat: trash an asset * chore(server): formatting * chore: open api * chore: wording * chore: open-api * feat(server): add withDeleted to getAssets queries * WIP: mobile-recycle-bin * feat(server): recycle-bin to system config * feat(web): use recycle-bin system config * chore(server): domain assetcore removed * chore(server): rename recycle-bin to trash * chore(web): rename recycle-bin to trash * chore(server): always send soft deleted assets for getAllByUserId * chore(web): formatting * feat(server): permanent delete assets older than trashed period * feat(web): trash empty placeholder image * feat(server): empty trash * feat(web): empty trash * WIP: mobile-recycle-bin * refactor(server): empty / restore trash to separate endpoint * test(server): handle failures * test(server): fix e2e server-info test * test(server): deletion test refactor * feat(mobile): use map settings from server-config to enable / disable map * feat(mobile): trash asset * fix(server): operations on assets in trash * feat(web): show trash statistics * fix(web): handle trash enabled * fix(mobile): restore updates from trash * fix(server): ignore trashed assets for person * fix(server): add / remove search index when trashed / restored * chore(web): format * fix(server): asset service test * fix(server): include trashed assts for duplicates from uploads * feat(mobile): no dialog for trash, always dialog for permanent delete * refactor(mobile): use isar where instead of dart filter * refactor(mobile): asset provide - handle deletes in single db txn * chore(mobile): review changes * feat(web): confirmation before empty trash * server: review changes * fix(server): handle library changes * fix: filter external assets from getting trashed / deleted * fix(server): empty-bin * feat: broadcast config update events through ws * change order of trash button on mobile * styling * fix(mobile): do not show trashed toast for local only assets --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
127 lines
3.9 KiB
TypeScript
127 lines
3.9 KiB
TypeScript
import { AssetEntity, AssetType, ExifEntity } from '@app/infra/entities';
|
|
import { Paginated, PaginationOptions } from '../domain.util';
|
|
|
|
export type AssetStats = Record<AssetType, number>;
|
|
|
|
export interface AssetStatsOptions {
|
|
isFavorite?: boolean;
|
|
isArchived?: boolean;
|
|
isTrashed?: boolean;
|
|
}
|
|
|
|
export interface AssetSearchOptions {
|
|
isVisible?: boolean;
|
|
trashedBefore?: Date;
|
|
type?: AssetType;
|
|
order?: 'ASC' | 'DESC';
|
|
}
|
|
|
|
export interface LivePhotoSearchOptions {
|
|
ownerId: string;
|
|
livePhotoCID: string;
|
|
otherAssetId: string;
|
|
type: AssetType;
|
|
}
|
|
|
|
export interface MapMarkerSearchOptions {
|
|
isArchived?: boolean;
|
|
isFavorite?: boolean;
|
|
fileCreatedBefore?: Date;
|
|
fileCreatedAfter?: Date;
|
|
}
|
|
|
|
export interface MapMarker {
|
|
id: string;
|
|
lat: number;
|
|
lon: number;
|
|
}
|
|
|
|
export enum WithoutProperty {
|
|
THUMBNAIL = 'thumbnail',
|
|
ENCODED_VIDEO = 'encoded-video',
|
|
EXIF = 'exif',
|
|
CLIP_ENCODING = 'clip-embedding',
|
|
OBJECT_TAGS = 'object-tags',
|
|
FACES = 'faces',
|
|
SIDECAR = 'sidecar',
|
|
}
|
|
|
|
export enum WithProperty {
|
|
SIDECAR = 'sidecar',
|
|
IS_OFFLINE = 'isOffline',
|
|
}
|
|
|
|
export enum TimeBucketSize {
|
|
DAY = 'DAY',
|
|
MONTH = 'MONTH',
|
|
}
|
|
|
|
export interface TimeBucketOptions {
|
|
size: TimeBucketSize;
|
|
isArchived?: boolean;
|
|
isFavorite?: boolean;
|
|
isTrashed?: boolean;
|
|
albumId?: string;
|
|
personId?: string;
|
|
userId?: string;
|
|
}
|
|
|
|
export interface TimeBucketItem {
|
|
timeBucket: string;
|
|
count: number;
|
|
}
|
|
|
|
export type AssetCreate = Pick<
|
|
AssetEntity,
|
|
| 'deviceAssetId'
|
|
| 'ownerId'
|
|
| 'libraryId'
|
|
| 'deviceId'
|
|
| 'type'
|
|
| 'originalPath'
|
|
| 'fileCreatedAt'
|
|
| 'localDateTime'
|
|
| 'fileModifiedAt'
|
|
| 'checksum'
|
|
| 'originalFileName'
|
|
> &
|
|
Partial<AssetEntity>;
|
|
|
|
export interface MonthDay {
|
|
day: number;
|
|
month: number;
|
|
}
|
|
|
|
export const IAssetRepository = 'IAssetRepository';
|
|
|
|
export interface IAssetRepository {
|
|
create(asset: AssetCreate): Promise<AssetEntity>;
|
|
getByDate(ownerId: string, date: Date): Promise<AssetEntity[]>;
|
|
getByIds(ids: string[]): Promise<AssetEntity[]>;
|
|
getByDayOfYear(ownerId: string, monthDay: MonthDay): Promise<AssetEntity[]>;
|
|
getByChecksum(userId: string, checksum: Buffer): Promise<AssetEntity | null>;
|
|
getByAlbumId(pagination: PaginationOptions, albumId: string): Paginated<AssetEntity>;
|
|
getByUserId(pagination: PaginationOptions, userId: string, options?: AssetSearchOptions): Paginated<AssetEntity>;
|
|
getById(id: string): Promise<AssetEntity | null>;
|
|
getWithout(pagination: PaginationOptions, property: WithoutProperty): Paginated<AssetEntity>;
|
|
getWith(pagination: PaginationOptions, property: WithProperty, libraryId?: string): Paginated<AssetEntity>;
|
|
getRandom(userId: string, count: number): Promise<AssetEntity[]>;
|
|
getFirstAssetForAlbumId(albumId: string): Promise<AssetEntity | null>;
|
|
getLastUpdatedAssetForAlbumId(albumId: string): Promise<AssetEntity | null>;
|
|
getByLibraryId(libraryIds: string[]): Promise<AssetEntity[]>;
|
|
getByLibraryIdAndOriginalPath(libraryId: string, originalPath: string): Promise<AssetEntity | null>;
|
|
deleteAll(ownerId: string): Promise<void>;
|
|
getAll(pagination: PaginationOptions, options?: AssetSearchOptions): Paginated<AssetEntity>;
|
|
updateAll(ids: string[], options: Partial<AssetEntity>): Promise<void>;
|
|
save(asset: Pick<AssetEntity, 'id'> & Partial<AssetEntity>): Promise<AssetEntity>;
|
|
remove(asset: AssetEntity): Promise<void>;
|
|
softDeleteAll(ids: string[]): Promise<void>;
|
|
restoreAll(ids: string[]): Promise<void>;
|
|
findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null>;
|
|
getMapMarkers(ownerId: string, options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
|
|
getStatistics(ownerId: string, options: AssetStatsOptions): Promise<AssetStats>;
|
|
getTimeBuckets(options: TimeBucketOptions): Promise<TimeBucketItem[]>;
|
|
getByTimeBucket(timeBucket: string, options: TimeBucketOptions): Promise<AssetEntity[]>;
|
|
upsertExif(exif: Partial<ExifEntity>): Promise<void>;
|
|
}
|