import { Column, Entity, Index, PrimaryColumn } from "typeorm";
import { id } from "../id.js";
import type { User } from "./user.js";
import type { DriveFile } from "./drive-file.js";
import type { noteVisibilities } from "../../types.js";
import type { MemorietTextLayer } from "./memoriet.js";

@Entity("memoriet_archive")
export class MemorietArchive {
	@PrimaryColumn(id())
	public id: string;

	@Index()
	@Column("timestamp with time zone")
	public createdAt: Date;

	@Index()
	@Column("timestamp with time zone")
	public deletedAt: Date;

	@Index()
	@Column(id())
	public userId: User["id"];

	@Column("text", { nullable: true })
	public text: string | null;

	@Column("varchar", { length: 128, nullable: true })
	public cw: string | null;

	@Column({
		...id(),
		array: true,
		default: "{}",
	})
	public fileIds: DriveFile["id"][];

	@Column("jsonb", { default: [] })
	public textLayers: MemorietTextLayer[];

	@Column("varchar", { length: 32, default: "home" })
	public visibility: (typeof noteVisibilities)[number];
}
