- doc types with side (front/back/single): license, national_id, vehicle_registration (both sides), criminal_record, selfie, vehicle_photo - fields: side, holder_name(encrypted), issue_date, extra jsonb; REQUIRED_DOCS checklist + /requirements - CS/admin: POST /admin/drivers/:id/documents (upload for driver), list, review auto-approves when complete - face-match endpoint stub (Gemini/Face provider later) - DB pool extra.max=30 (raises concurrency ceiling); migration DocumentsFields Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
Index,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { EncryptedTransformer } from '../../../common/crypto/crypto.util';
|
|
|
|
export type DocType =
|
|
| 'license' // رخصة القيادة (وجهين)
|
|
| 'national_id' // هوية الأحوال المدنية (وجهين)
|
|
| 'vehicle_registration' // دفتر/بطاقة المركبة (وجهين)
|
|
| 'insurance' // تأمين
|
|
| 'criminal_record' // عدم محكومية (البحث الجنائي)
|
|
| 'selfie' // صورة شخصية
|
|
| 'vehicle_photo'; // صورة/صور السيارة
|
|
export type DocSide = 'front' | 'back' | 'single';
|
|
export type DocStatus = 'pending' | 'approved' | 'rejected';
|
|
|
|
/** وثيقة سائق (صورة + بيانات). الجدول: tripz_driver_documents. */
|
|
@Entity('driver_documents')
|
|
@Index(['tenant_id', 'driver_id'])
|
|
@Index(['tenant_id', 'status'])
|
|
export class DriverDocument {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ type: 'uuid' })
|
|
tenant_id: string;
|
|
|
|
@Column({ type: 'uuid' })
|
|
driver_id: string;
|
|
|
|
@Column()
|
|
type: DocType;
|
|
|
|
@Column({ type: 'varchar', default: 'single' })
|
|
side: DocSide; // front | back | single
|
|
|
|
@Column()
|
|
file_key: string; // مفتاح التخزين (سيرفر التوطين لاحقاً)
|
|
|
|
// رقم الرخصة/الهوية — مشفّر at-rest (AES-256-GCM)
|
|
@Column({ type: 'varchar', nullable: true, transformer: EncryptedTransformer })
|
|
number: string | null;
|
|
|
|
// اسم حامل الوثيقة — مشفّر at-rest
|
|
@Column({ type: 'varchar', nullable: true, transformer: EncryptedTransformer })
|
|
holder_name: string | null;
|
|
|
|
@Column({ type: 'date', nullable: true })
|
|
issue_date: string | null;
|
|
|
|
@Column({ type: 'date', nullable: true })
|
|
expiry_date: string | null;
|
|
|
|
// حقول إضافية يدخلها موظف خدمة العملاء (سلطة إصدار، ملاحظات...)
|
|
@Column({ type: 'jsonb', default: {} })
|
|
extra: Record<string, any>;
|
|
|
|
@Column({ type: 'varchar', default: 'pending' })
|
|
status: DocStatus;
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
review_note: string | null;
|
|
|
|
@Column({ type: 'uuid', nullable: true })
|
|
reviewed_by: string | null;
|
|
|
|
@CreateDateColumn()
|
|
created_at: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updated_at: Date;
|
|
}
|