This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100// SPDX-License-Identifier: AGPL-3.0-or-later
import type {AdminArchiveResponseSchema} from '@fluxer/schema/src/domains/admin/AdminSchemas';import type {z} from 'zod';import type {AdminArchiveRow} from '../../database/types/AdminArchiveTypes';
export type ArchiveSubjectType = 'user' | 'guild';
export class AdminArchive { subjectType: ArchiveSubjectType; subjectId: bigint; archiveId: bigint; requestedBy: bigint; requestedAt: Date; startedAt: Date | null; completedAt: Date | null; failedAt: Date | null; storageKey: string | null; fileSize: bigint | null; progressPercent: number; progressStep: string | null; errorMessage: string | null; downloadUrlExpiresAt: Date | null; expiresAt: Date | null;
constructor(row: AdminArchiveRow) { this.subjectType = row.subject_type; this.subjectId = row.subject_id; this.archiveId = row.archive_id; this.requestedBy = row.requested_by; this.requestedAt = row.requested_at; this.startedAt = row.started_at ?? null; this.completedAt = row.completed_at ?? null; this.failedAt = row.failed_at ?? null; this.storageKey = row.storage_key ?? null; this.fileSize = row.file_size ?? null; this.progressPercent = row.progress_percent; this.progressStep = row.progress_step ?? null; this.errorMessage = row.error_message ?? null; this.downloadUrlExpiresAt = row.download_url_expires_at ?? null; this.expiresAt = row.expires_at ?? null; }
toRow(): AdminArchiveRow { return { subject_type: this.subjectType, subject_id: this.subjectId, archive_id: this.archiveId, requested_by: this.requestedBy, requested_at: this.requestedAt, started_at: this.startedAt, completed_at: this.completedAt, failed_at: this.failedAt, storage_key: this.storageKey, file_size: this.fileSize, progress_percent: this.progressPercent, progress_step: this.progressStep, error_message: this.errorMessage, download_url_expires_at: this.downloadUrlExpiresAt, expires_at: this.expiresAt, }; }
toResponse(): { archive_id: string; subject_type: ArchiveSubjectType; subject_id: string; requested_by: string; requested_at: string; started_at: string | null; completed_at: string | null; failed_at: string | null; file_size: string | null; progress_percent: number; progress_step: string | null; error_message: string | null; download_url_expires_at: string | null; expires_at: string | null; } { return { archive_id: this.archiveId.toString(), subject_type: this.subjectType, subject_id: this.subjectId.toString(), requested_by: this.requestedBy.toString(), requested_at: this.requestedAt.toISOString(), started_at: this.startedAt?.toISOString() ?? null, completed_at: this.completedAt?.toISOString() ?? null, failed_at: this.failedAt?.toISOString() ?? null, file_size: this.fileSize?.toString() ?? null, progress_percent: this.progressPercent, progress_step: this.progressStep, error_message: this.errorMessage, download_url_expires_at: this.downloadUrlExpiresAt?.toISOString() ?? null, expires_at: this.expiresAt?.toISOString() ?? null, }; }}
export type AdminArchiveResponse = z.infer<typeof AdminArchiveResponseSchema>;