mirror of
https://github.com/immich-app/immich.git
synced 2026-05-11 10:15:07 +03:00
feat: getAssetEdits respond with edit IDs (#26445)
* feat: getAssetEdits respond with edit IDs * chore: cleanup typings for edit API * chore: cleanup types with jason * fix: openapi sync * fix: factory
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Selectable } from 'kysely';
|
||||
import { AssetEditAction } from 'src/dtos/editing.dto';
|
||||
import { AssetEditAction, AssetEditActionItem } from 'src/dtos/editing.dto';
|
||||
import { AssetEditTable } from 'src/schema/tables/asset-edit.table';
|
||||
import { AssetFactory } from 'test/factories/asset.factory';
|
||||
import { build } from 'test/factories/builder.factory';
|
||||
@@ -33,6 +33,6 @@ export class AssetEditFactory {
|
||||
}
|
||||
|
||||
build() {
|
||||
return { ...this.value } as Selectable<AssetEditTable<AssetEditAction.Crop>>;
|
||||
return { ...this.value } as Omit<Selectable<AssetEditTable>, 'action' | 'parameters'> & AssetEditActionItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Stats } from 'node:fs';
|
||||
import { Writable } from 'node:stream';
|
||||
import { AssetFace } from 'src/database';
|
||||
import { AuthDto, LoginResponseDto } from 'src/dtos/auth.dto';
|
||||
import { AssetEditActionListDto } from 'src/dtos/editing.dto';
|
||||
import { AssetEditActionItem, AssetEditsCreateDto } from 'src/dtos/editing.dto';
|
||||
import {
|
||||
AlbumUserRole,
|
||||
AssetType,
|
||||
@@ -282,8 +282,8 @@ export class MediumTestContext<S extends BaseService = BaseService> {
|
||||
return { tagsAssets, result };
|
||||
}
|
||||
|
||||
async newEdits(assetId: string, dto: AssetEditActionListDto) {
|
||||
const edits = await this.get(AssetEditRepository).replaceAll(assetId, dto.edits);
|
||||
async newEdits(assetId: string, dto: AssetEditsCreateDto) {
|
||||
const edits = await this.get(AssetEditRepository).replaceAll(assetId, dto.edits as AssetEditActionItem[]);
|
||||
return { edits };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -887,15 +887,16 @@ describe(AssetService.name, () => {
|
||||
await ctx.newExif({ assetId: asset.id, exifImageHeight: 42, exifImageWidth: 69, orientation: '1' });
|
||||
|
||||
const editAction = { action: AssetEditAction.Rotate, parameters: { angle: 90 } } as const;
|
||||
const editResponse = { ...editAction, id: expect.any(String) };
|
||||
await expect(sut.editAsset(auth, asset.id, { edits: [editAction] })).resolves.toEqual({
|
||||
assetId: asset.id,
|
||||
edits: [editAction],
|
||||
edits: [editResponse],
|
||||
});
|
||||
|
||||
await expect(ctx.get(AssetRepository).getById(asset.id)).resolves.toEqual(
|
||||
expect.objectContaining({ isEdited: true }),
|
||||
);
|
||||
await expect(ctx.get(AssetEditRepository).getAll(asset.id)).resolves.toEqual([editAction]);
|
||||
await expect(ctx.get(AssetEditRepository).getAll(asset.id)).resolves.toEqual([editResponse]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user