2023-06-26 08:22:15 +02:00
|
|
|
import { Expose, plainToClass, Type } from "class-transformer";
|
2022-10-09 22:30:32 +02:00
|
|
|
import { ShareDTO } from "./share.dto";
|
2023-06-26 08:22:15 +02:00
|
|
|
import {FileDTO} from "../../file/dto/file.dto";
|
|
|
|
|
import {OmitType} from "@nestjs/swagger";
|
2022-10-09 22:30:32 +02:00
|
|
|
|
2023-06-26 08:22:15 +02:00
|
|
|
export class MyShareDTO extends OmitType(ShareDTO, [
|
|
|
|
|
"files",
|
|
|
|
|
"from",
|
|
|
|
|
"fromList",
|
|
|
|
|
] as const) {
|
2022-10-09 22:30:32 +02:00
|
|
|
@Expose()
|
|
|
|
|
views: number;
|
|
|
|
|
|
|
|
|
|
@Expose()
|
|
|
|
|
createdAt: Date;
|
|
|
|
|
|
2022-11-11 15:12:16 +01:00
|
|
|
@Expose()
|
|
|
|
|
recipients: string[];
|
|
|
|
|
|
2023-06-26 08:22:15 +02:00
|
|
|
@Expose()
|
|
|
|
|
@Type(() => OmitType(FileDTO, ["share", "from"] as const))
|
|
|
|
|
files: Omit<FileDTO, "share" | "from">[];
|
|
|
|
|
|
2022-10-09 22:30:32 +02:00
|
|
|
from(partial: Partial<MyShareDTO>) {
|
|
|
|
|
return plainToClass(MyShareDTO, partial, { excludeExtraneousValues: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fromList(partial: Partial<MyShareDTO>[]) {
|
|
|
|
|
return partial.map((part) =>
|
|
|
|
|
plainToClass(MyShareDTO, part, { excludeExtraneousValues: true })
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-06-26 08:22:15 +02:00
|
|
|
}
|