import { Entity, PrimaryColumn, Column, CreateDateColumn, UpdateDateColumn, Index, } from 'typeorm'; export type InboxSource = 'all' | 'user'; export interface StoredQrCode { page: number; value: string; } @Entity('inbox_documents') @Index(['Source', 'OwnerUsername']) export class InboxDocument { @PrimaryColumn({ type: 'char', length: 36 }) Id!: string; @Column({ type: 'varchar', length: 255 }) OriginalName!: string; @Column({ type: 'varchar', length: 10 }) Source!: InboxSource; @Column({ type: 'varchar', length: 100, nullable: true }) OwnerUsername!: string | null; @Column({ type: 'int', default: 0 }) PageCount!: number; @Column({ type: 'json' }) QrCodes!: StoredQrCode[]; @Column({ type: 'json', nullable: true, transformer: { to: (v: number[] | null | undefined) => (v && v.length ? v : null), from: (v: number[] | null) => v ?? [], }, }) DeletedPages!: number[]; @Column({ type: 'json', nullable: true, transformer: { to: (v: Record | null | undefined) => v && Object.keys(v).length ? v : null, from: (v: Record | null) => v ?? {}, }, }) Rotations!: Record; @CreateDateColumn() CreatedAt!: Date; @UpdateDateColumn() UpdatedAt!: Date; }