2024-04-16 07:26:37 +02:00
|
|
|
import { ApiProperty } from '@nestjs/swagger';
|
2025-02-21 04:37:57 +00:00
|
|
|
import { IsEnum, IsInt, IsPositive, IsString } from 'class-validator';
|
2024-04-16 07:26:37 +02:00
|
|
|
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
2025-05-21 15:35:32 -04:00
|
|
|
import { AlbumUserRole, AssetOrder, AssetType, AssetVisibility, SyncEntityType, SyncRequestType } from 'src/enum';
|
2025-02-21 04:37:57 +00:00
|
|
|
import { Optional, ValidateDate, ValidateUUID } from 'src/validation';
|
2024-04-16 07:26:37 +02:00
|
|
|
|
|
|
|
|
export class AssetFullSyncDto {
|
|
|
|
|
@ValidateUUID({ optional: true })
|
|
|
|
|
lastId?: string;
|
|
|
|
|
|
|
|
|
|
@ValidateDate()
|
|
|
|
|
updatedUntil!: Date;
|
|
|
|
|
|
|
|
|
|
@IsInt()
|
|
|
|
|
@IsPositive()
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
limit!: number;
|
|
|
|
|
|
|
|
|
|
@ValidateUUID({ optional: true })
|
|
|
|
|
userId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class AssetDeltaSyncDto {
|
|
|
|
|
@ValidateDate()
|
|
|
|
|
updatedAfter!: Date;
|
2024-04-29 05:24:21 +02:00
|
|
|
|
2024-04-16 07:26:37 +02:00
|
|
|
@ValidateUUID({ each: true })
|
|
|
|
|
userIds!: string[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class AssetDeltaSyncResponseDto {
|
|
|
|
|
needsFullSync!: boolean;
|
|
|
|
|
upserted!: AssetResponseDto[];
|
|
|
|
|
deleted!: string[];
|
|
|
|
|
}
|
2025-02-21 04:37:57 +00:00
|
|
|
|
|
|
|
|
export class SyncUserV1 {
|
|
|
|
|
id!: string;
|
|
|
|
|
name!: string;
|
|
|
|
|
email!: string;
|
|
|
|
|
deletedAt!: Date | null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncUserDeleteV1 {
|
|
|
|
|
userId!: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-03 11:05:30 +00:00
|
|
|
export class SyncPartnerV1 {
|
|
|
|
|
sharedById!: string;
|
|
|
|
|
sharedWithId!: string;
|
|
|
|
|
inTimeline!: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncPartnerDeleteV1 {
|
|
|
|
|
sharedById!: string;
|
|
|
|
|
sharedWithId!: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-10 12:05:39 -04:00
|
|
|
export class SyncAssetV1 {
|
|
|
|
|
id!: string;
|
|
|
|
|
ownerId!: string;
|
|
|
|
|
thumbhash!: string | null;
|
|
|
|
|
checksum!: string;
|
|
|
|
|
fileCreatedAt!: Date | null;
|
|
|
|
|
fileModifiedAt!: Date | null;
|
|
|
|
|
localDateTime!: Date | null;
|
|
|
|
|
type!: AssetType;
|
|
|
|
|
deletedAt!: Date | null;
|
|
|
|
|
isFavorite!: boolean;
|
2025-05-06 12:12:48 -05:00
|
|
|
visibility!: AssetVisibility;
|
2025-03-10 12:05:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAssetDeleteV1 {
|
|
|
|
|
assetId!: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAssetExifV1 {
|
|
|
|
|
assetId!: string;
|
|
|
|
|
description!: string | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
exifImageWidth!: number | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
exifImageHeight!: number | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
fileSizeInByte!: number | null;
|
|
|
|
|
orientation!: string | null;
|
|
|
|
|
dateTimeOriginal!: Date | null;
|
|
|
|
|
modifyDate!: Date | null;
|
|
|
|
|
timeZone!: string | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
latitude!: number | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
longitude!: number | null;
|
|
|
|
|
projectionType!: string | null;
|
|
|
|
|
city!: string | null;
|
|
|
|
|
state!: string | null;
|
|
|
|
|
country!: string | null;
|
|
|
|
|
make!: string | null;
|
|
|
|
|
model!: string | null;
|
|
|
|
|
lensModel!: string | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
fNumber!: number | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
focalLength!: number | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
iso!: number | null;
|
|
|
|
|
exposureTime!: string | null;
|
|
|
|
|
profileDescription!: string | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
rating!: number | null;
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
fps!: number | null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-21 15:35:32 -04:00
|
|
|
export class SyncAlbumDeleteV1 {
|
|
|
|
|
albumId!: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAlbumUserDeleteV1 {
|
|
|
|
|
albumId!: string;
|
|
|
|
|
userId!: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAlbumUserV1 {
|
|
|
|
|
albumId!: string;
|
|
|
|
|
userId!: string;
|
|
|
|
|
role!: AlbumUserRole;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAlbumV1 {
|
|
|
|
|
id!: string;
|
|
|
|
|
ownerId!: string;
|
|
|
|
|
name!: string;
|
|
|
|
|
description!: string;
|
|
|
|
|
createdAt!: Date;
|
|
|
|
|
updatedAt!: Date;
|
|
|
|
|
thumbnailAssetId!: string | null;
|
|
|
|
|
isActivityEnabled!: boolean;
|
|
|
|
|
@ApiProperty({ enumName: 'AssetOrder', enum: AssetOrder })
|
|
|
|
|
order!: AssetOrder;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-21 04:37:57 +00:00
|
|
|
export type SyncItem = {
|
|
|
|
|
[SyncEntityType.UserV1]: SyncUserV1;
|
|
|
|
|
[SyncEntityType.UserDeleteV1]: SyncUserDeleteV1;
|
2025-03-03 11:05:30 +00:00
|
|
|
[SyncEntityType.PartnerV1]: SyncPartnerV1;
|
|
|
|
|
[SyncEntityType.PartnerDeleteV1]: SyncPartnerDeleteV1;
|
2025-03-10 12:05:39 -04:00
|
|
|
[SyncEntityType.AssetV1]: SyncAssetV1;
|
|
|
|
|
[SyncEntityType.AssetDeleteV1]: SyncAssetDeleteV1;
|
|
|
|
|
[SyncEntityType.AssetExifV1]: SyncAssetExifV1;
|
|
|
|
|
[SyncEntityType.PartnerAssetV1]: SyncAssetV1;
|
|
|
|
|
[SyncEntityType.PartnerAssetDeleteV1]: SyncAssetDeleteV1;
|
|
|
|
|
[SyncEntityType.PartnerAssetExifV1]: SyncAssetExifV1;
|
2025-05-21 15:35:32 -04:00
|
|
|
[SyncEntityType.AlbumV1]: SyncAlbumV1;
|
|
|
|
|
[SyncEntityType.AlbumDeleteV1]: SyncAlbumDeleteV1;
|
|
|
|
|
[SyncEntityType.AlbumUserV1]: SyncAlbumUserV1;
|
|
|
|
|
[SyncEntityType.AlbumUserDeleteV1]: SyncAlbumUserDeleteV1;
|
2025-02-21 04:37:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const responseDtos = [
|
|
|
|
|
SyncUserV1,
|
|
|
|
|
SyncUserDeleteV1,
|
2025-03-03 11:05:30 +00:00
|
|
|
SyncPartnerV1,
|
|
|
|
|
SyncPartnerDeleteV1,
|
2025-03-10 12:05:39 -04:00
|
|
|
SyncAssetV1,
|
|
|
|
|
SyncAssetDeleteV1,
|
|
|
|
|
SyncAssetExifV1,
|
2025-05-21 15:35:32 -04:00
|
|
|
SyncAlbumV1,
|
|
|
|
|
SyncAlbumDeleteV1,
|
|
|
|
|
SyncAlbumUserV1,
|
|
|
|
|
SyncAlbumUserDeleteV1,
|
2025-02-21 04:37:57 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const extraSyncModels = responseDtos;
|
|
|
|
|
|
|
|
|
|
export class SyncStreamDto {
|
|
|
|
|
@IsEnum(SyncRequestType, { each: true })
|
|
|
|
|
@ApiProperty({ enumName: 'SyncRequestType', enum: SyncRequestType, isArray: true })
|
|
|
|
|
types!: SyncRequestType[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAckDto {
|
|
|
|
|
@ApiProperty({ enumName: 'SyncEntityType', enum: SyncEntityType })
|
|
|
|
|
type!: SyncEntityType;
|
|
|
|
|
ack!: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAckSetDto {
|
|
|
|
|
@IsString({ each: true })
|
|
|
|
|
acks!: string[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SyncAckDeleteDto {
|
|
|
|
|
@IsEnum(SyncEntityType, { each: true })
|
|
|
|
|
@ApiProperty({ enumName: 'SyncEntityType', enum: SyncEntityType, isArray: true })
|
|
|
|
|
@Optional()
|
|
|
|
|
types?: SyncEntityType[];
|
|
|
|
|
}
|