File size: 1,185 Bytes
9a951d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  CreateDateColumn,
  JoinColumn,
} from 'typeorm';
import { User } from '../user.entity';
import { DataSourceType } from '../../../common/enums/user-enums';

/**
 * Tracks all information sources about the user
 * Maintains data lineage for quality and debugging
 */
@Entity('user_data_sources')
export class UserDataSource {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'uuid' })
  userId: string;

  @ManyToOne(() => User, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'userId' })
  user: User;

  @Column({
    type: 'enum',
    enum: DataSourceType,
  })
  sourceType: DataSourceType;

  @Column({ type: 'varchar', length: 100 })
  sourceName: string; // "onboarding_v1", "resume_2024.pdf", "search_history_jan"

  /**
   * Raw extracted data from this source
   * Can be processed and distributed to other tables
   */
  @Column({ type: 'jsonb' })
  rawData: Record<string, any>;

  @Column({ type: 'boolean', default: false })
  isProcessed: boolean;

  @Column({ type: 'int', default: 100 })
  confidence: number; // Data quality score 0-100

  @CreateDateColumn()
  createdAt: Date;
}