mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
* feat(web): lighter timeline buckets * GalleryViewer * weird ssr * Remove generics from AssetInteraction * ensure keys on getAssetInfo, alt-text * empty - trigger ci * re-add alt-text * test fix * update tests * tests * missing import * feat(server): lighter buckets * fix: flappy e2e test * lint * revert settings * unneeded cast * fix after merge * Adapt web client to consume new server response format * test * missing import * lint * Use nulls, make-sql * openapi battle * date->string * tests * tests * lint/tests * lint * test * push aggregation to query * openapi * stack as tuple * openapi * update references to description * update alt text tests * update sql * update sql * update timeline tests * linting, fix expected response * string tuple * fix spec * fix * silly generator * rename patch * minimize sorting * review * lint * lint * sql * test * avoid abbreviations * review comment - type safety in test * merge conflicts * lint * lint/abbreviations * remove unncessary code * review comments * sql * re-add package-lock * use booleans, fix visibility in openapi spec, less cursed controller * update sql * no need to use sql template * array access actually doesn't seem to matter * remove redundant code * re-add sql decorator * unused type * remove null assertions * bad merge * Fix test * shave * extra clean shave * use decorator for content type * redundant types * redundant comment * update comment * unnecessary res --------- Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
94 lines
3.4 KiB
TypeScript
94 lines
3.4 KiB
TypeScript
import type { TimelineAsset } from '$lib/stores/assets-store.svelte';
|
|
import { faker } from '@faker-js/faker';
|
|
import {
|
|
AssetTypeEnum,
|
|
AssetVisibility,
|
|
Visibility,
|
|
type AssetResponseDto,
|
|
type TimeBucketAssetResponseDto,
|
|
} from '@immich/sdk';
|
|
import { Sync } from 'factory.ts';
|
|
|
|
export const assetFactory = Sync.makeFactory<AssetResponseDto>({
|
|
id: Sync.each(() => faker.string.uuid()),
|
|
deviceAssetId: Sync.each(() => faker.string.uuid()),
|
|
ownerId: Sync.each(() => faker.string.uuid()),
|
|
deviceId: '',
|
|
libraryId: Sync.each(() => faker.string.uuid()),
|
|
type: Sync.each(() => faker.helpers.enumValue(AssetTypeEnum)),
|
|
originalPath: Sync.each(() => faker.system.filePath()),
|
|
originalFileName: Sync.each(() => faker.system.fileName()),
|
|
originalMimeType: Sync.each(() => faker.system.mimeType()),
|
|
thumbhash: Sync.each(() => faker.string.alphanumeric(28)),
|
|
fileCreatedAt: Sync.each(() => faker.date.past().toISOString()),
|
|
fileModifiedAt: Sync.each(() => faker.date.past().toISOString()),
|
|
localDateTime: Sync.each(() => faker.date.past().toISOString()),
|
|
updatedAt: Sync.each(() => faker.date.past().toISOString()),
|
|
isFavorite: Sync.each(() => faker.datatype.boolean()),
|
|
isArchived: false,
|
|
isTrashed: false,
|
|
duration: '0:00:00.00000',
|
|
checksum: Sync.each(() => faker.string.alphanumeric(28)),
|
|
isOffline: Sync.each(() => faker.datatype.boolean()),
|
|
hasMetadata: Sync.each(() => faker.datatype.boolean()),
|
|
visibility: Visibility.Timeline,
|
|
});
|
|
|
|
export const timelineAssetFactory = Sync.makeFactory<TimelineAsset>({
|
|
id: Sync.each(() => faker.string.uuid()),
|
|
ratio: Sync.each(() => faker.number.int()),
|
|
ownerId: Sync.each(() => faker.string.uuid()),
|
|
thumbhash: Sync.each(() => faker.string.alphanumeric(28)),
|
|
localDateTime: Sync.each(() => faker.date.past().toISOString()),
|
|
isFavorite: Sync.each(() => faker.datatype.boolean()),
|
|
visibility: AssetVisibility.Timeline,
|
|
isTrashed: false,
|
|
isImage: true,
|
|
isVideo: false,
|
|
duration: '0:00:00.00000',
|
|
stack: null,
|
|
projectionType: null,
|
|
livePhotoVideoId: Sync.each(() => faker.string.uuid()),
|
|
city: faker.location.city(),
|
|
country: faker.location.country(),
|
|
people: [faker.person.fullName()],
|
|
});
|
|
|
|
export const toResponseDto = (...timelineAsset: TimelineAsset[]) => {
|
|
const bucketAssets: TimeBucketAssetResponseDto = {
|
|
city: [],
|
|
country: [],
|
|
duration: [],
|
|
id: [],
|
|
visibility: [],
|
|
isFavorite: [],
|
|
isImage: [],
|
|
isTrashed: [],
|
|
livePhotoVideoId: [],
|
|
localDateTime: [],
|
|
ownerId: [],
|
|
projectionType: [],
|
|
ratio: [],
|
|
stack: [],
|
|
thumbhash: [],
|
|
};
|
|
for (const asset of timelineAsset) {
|
|
bucketAssets.city.push(asset.city);
|
|
bucketAssets.country.push(asset.country);
|
|
bucketAssets.duration.push(asset.duration!);
|
|
bucketAssets.id.push(asset.id);
|
|
bucketAssets.visibility.push(asset.visibility);
|
|
bucketAssets.isFavorite.push(asset.isFavorite);
|
|
bucketAssets.isImage.push(asset.isImage);
|
|
bucketAssets.isTrashed.push(asset.isTrashed);
|
|
bucketAssets.livePhotoVideoId.push(asset.livePhotoVideoId!);
|
|
bucketAssets.localDateTime.push(asset.localDateTime);
|
|
bucketAssets.ownerId.push(asset.ownerId);
|
|
bucketAssets.projectionType.push(asset.projectionType!);
|
|
bucketAssets.ratio.push(asset.ratio);
|
|
bucketAssets.stack?.push(asset.stack ? [asset.stack.id, asset.stack.assetCount.toString()] : null);
|
|
bucketAssets.thumbhash.push(asset.thumbhash!);
|
|
}
|
|
|
|
return bucketAssets;
|
|
};
|