1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-09 23:17:29 +02:00

refactor: remove album entity, update types (#17450)

This commit is contained in:
Daniel Dietzler
2025-04-18 23:10:34 +02:00
committed by GitHub
parent 854ea13d6a
commit 52ae06c119
44 changed files with 473 additions and 396 deletions

View File

@@ -1,5 +1,5 @@
import { AssetFile, Exif } from 'src/database';
import { AssetEntity } from 'src/entities/asset.entity';
import { AssetFace, AssetFile, Exif } from 'src/database';
import { MapAsset } from 'src/dtos/asset-response.dto';
import { AssetFileType, AssetStatus, AssetType } from 'src/enum';
import { StorageAsset } from 'src/types';
import { authStub } from 'test/fixtures/auth.stub';
@@ -26,13 +26,15 @@ const fullsizeFile: AssetFile = {
const files: AssetFile[] = [fullsizeFile, previewFile, thumbnailFile];
export const stackStub = (stackId: string, assets: AssetEntity[]) => {
export const stackStub = (stackId: string, assets: (MapAsset & { exifInfo: Exif })[]) => {
return {
id: stackId,
assets,
ownerId: assets[0].ownerId,
primaryAsset: assets[0],
primaryAssetId: assets[0].id,
createdAt: new Date('2023-02-23T05:06:29.716Z'),
updatedAt: new Date('2023-02-23T05:06:29.716Z'),
};
};
@@ -85,9 +87,12 @@ export const assetStub = {
isExternal: false,
duplicateId: null,
isOffline: false,
libraryId: null,
stackId: null,
updateId: '42',
}),
noWebpPath: Object.freeze<AssetEntity>({
noWebpPath: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -122,9 +127,12 @@ export const assetStub = {
deletedAt: null,
duplicateId: null,
isOffline: false,
libraryId: null,
stackId: null,
updateId: '42',
}),
noThumbhash: Object.freeze<AssetEntity>({
noThumbhash: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -156,6 +164,9 @@ export const assetStub = {
deletedAt: null,
duplicateId: null,
isOffline: false,
libraryId: null,
stackId: null,
updateId: '42',
}),
primaryImage: Object.freeze({
@@ -195,12 +206,13 @@ export const assetStub = {
} as Exif,
stackId: 'stack-1',
stack: stackStub('stack-1', [
{ id: 'primary-asset-id' } as AssetEntity,
{ id: 'stack-child-asset-1' } as AssetEntity,
{ id: 'stack-child-asset-2' } as AssetEntity,
{ id: 'primary-asset-id' } as MapAsset & { exifInfo: Exif },
{ id: 'stack-child-asset-1' } as MapAsset & { exifInfo: Exif },
{ id: 'stack-child-asset-2' } as MapAsset & { exifInfo: Exif },
]),
duplicateId: null,
isOffline: false,
updateId: '42',
libraryId: null,
}),
@@ -229,6 +241,9 @@ export const assetStub = {
isExternal: false,
livePhotoVideo: null,
livePhotoVideoId: null,
updateId: 'foo',
libraryId: null,
stackId: null,
sharedLinks: [],
originalFileName: 'asset-id.jpg',
faces: [],
@@ -241,10 +256,10 @@ export const assetStub = {
} as Exif,
duplicateId: null,
isOffline: false,
libraryId: null,
stack: null,
}),
trashed: Object.freeze<AssetEntity>({
trashed: Object.freeze({
id: 'asset-id',
deviceAssetId: 'device-asset-id',
fileModifiedAt: new Date('2023-02-23T05:06:29.716Z'),
@@ -281,9 +296,12 @@ export const assetStub = {
duplicateId: null,
isOffline: false,
status: AssetStatus.TRASHED,
libraryId: null,
stackId: null,
updateId: '42',
}),
trashedOffline: Object.freeze<AssetEntity>({
trashedOffline: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -321,8 +339,10 @@ export const assetStub = {
} as Exif,
duplicateId: null,
isOffline: true,
stackId: null,
updateId: '42',
}),
archived: Object.freeze<AssetEntity>({
archived: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -359,9 +379,12 @@ export const assetStub = {
} as Exif,
duplicateId: null,
isOffline: false,
libraryId: null,
stackId: null,
updateId: '42',
}),
external: Object.freeze<AssetEntity>({
external: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -397,9 +420,12 @@ export const assetStub = {
} as Exif,
duplicateId: null,
isOffline: false,
updateId: '42',
stackId: null,
stack: null,
}),
image1: Object.freeze<AssetEntity>({
image1: Object.freeze({
id: 'asset-id-1',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -434,9 +460,13 @@ export const assetStub = {
} as Exif,
duplicateId: null,
isOffline: false,
updateId: '42',
stackId: null,
libraryId: null,
stack: null,
}),
imageFrom2015: Object.freeze<AssetEntity>({
imageFrom2015: Object.freeze({
id: 'asset-id-1',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -510,7 +540,9 @@ export const assetStub = {
deletedAt: null,
duplicateId: null,
isOffline: false,
updateId: '42',
libraryId: null,
stackId: null,
}),
livePhotoMotionAsset: Object.freeze({
@@ -527,7 +559,7 @@ export const assetStub = {
timeZone: `America/New_York`,
},
libraryId: null,
} as AssetEntity & { libraryId: string | null; files: AssetFile[]; exifInfo: Exif }),
} as MapAsset & { faces: AssetFace[]; files: AssetFile[]; exifInfo: Exif }),
livePhotoStillAsset: Object.freeze({
id: 'live-photo-still-asset',
@@ -544,7 +576,8 @@ export const assetStub = {
timeZone: `America/New_York`,
},
files,
} as AssetEntity & { libraryId: string | null }),
faces: [] as AssetFace[],
} as MapAsset & { faces: AssetFace[] }),
livePhotoWithOriginalFileName: Object.freeze({
id: 'live-photo-still-asset',
@@ -562,7 +595,8 @@ export const assetStub = {
timeZone: `America/New_York`,
},
libraryId: null,
} as AssetEntity & { libraryId: string | null }),
faces: [] as AssetFace[],
} as MapAsset & { faces: AssetFace[] }),
withLocation: Object.freeze({
id: 'asset-with-favorite-id',
@@ -590,6 +624,9 @@ export const assetStub = {
isVisible: true,
livePhotoVideo: null,
livePhotoVideoId: null,
updateId: 'foo',
libraryId: null,
stackId: null,
sharedLinks: [],
originalFileName: 'asset-id.ext',
faces: [],
@@ -604,7 +641,7 @@ export const assetStub = {
deletedAt: null,
duplicateId: null,
isOffline: false,
libraryId: null,
tags: [],
}),
sidecar: Object.freeze({
@@ -639,10 +676,12 @@ export const assetStub = {
deletedAt: null,
duplicateId: null,
isOffline: false,
updateId: 'foo',
libraryId: null,
stackId: null,
}),
sidecarWithoutExt: Object.freeze<AssetEntity>({
sidecarWithoutExt: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -676,7 +715,7 @@ export const assetStub = {
isOffline: false,
}),
hasEncodedVideo: Object.freeze<AssetEntity>({
hasEncodedVideo: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
originalFileName: 'asset-id.ext',
@@ -711,9 +750,13 @@ export const assetStub = {
deletedAt: null,
duplicateId: null,
isOffline: false,
updateId: '42',
libraryId: null,
stackId: null,
stack: null,
}),
hasFileExtension: Object.freeze<AssetEntity>({
hasFileExtension: Object.freeze({
id: 'asset-id',
status: AssetStatus.ACTIVE,
deviceAssetId: 'device-asset-id',
@@ -788,6 +831,9 @@ export const assetStub = {
} as Exif,
duplicateId: null,
isOffline: false,
updateId: '42',
libraryId: null,
stackId: null,
}),
imageHif: Object.freeze({
@@ -827,5 +873,8 @@ export const assetStub = {
} as Exif,
duplicateId: null,
isOffline: false,
updateId: '42',
libraryId: null,
stackId: null,
}),
};