forked from MindFlowInteractive/quest-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheat-violation.entity.ts
More file actions
125 lines (105 loc) · 2.63 KB
/
Copy pathcheat-violation.entity.ts
File metadata and controls
125 lines (105 loc) · 2.63 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
ManyToOne,
JoinColumn,
OneToMany
} from 'typeorm';
import { ViolationType, Severity, ViolationStatus, ActionType } from '../constants';
/**
* Entity for tracking cheat violations detected in the system
*/
@Entity('cheat_violations')
@Index(['playerId', 'createdAt'])
@Index(['violationType', 'severity'])
@Index(['status', 'createdAt'])
export class CheatViolation {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'uuid' })
@Index()
playerId: string;
@Column({ type: 'uuid', nullable: true })
@Index()
puzzleId: string | null;
@Column({ type: 'uuid', nullable: true })
sessionId: string | null;
@Column({
type: 'enum',
enum: ViolationType
})
@Index()
violationType: ViolationType;
@Column({
type: 'enum',
enum: Severity
})
@Index()
severity: Severity;
@Column({ type: 'decimal', precision: 5, scale: 2 })
confidenceScore: number;
@Column({ type: 'jsonb' })
evidence: {
detectionMethod: string;
metrics: Record<string, any>;
movesAnalyzed?: number;
statisticalData?: {
zScores?: Record<string, number>;
populationComparison?: any;
baseline?: any;
};
flaggedMoves?: string[];
timestamps?: Date[];
anomalies?: Array<{
type: string;
severity: string;
description: string;
value?: any;
}>;
additionalContext?: Record<string, any>;
};
@Column({
type: 'enum',
enum: ViolationStatus,
default: ViolationStatus.PENDING
})
@Index()
status: ViolationStatus;
@Column({ type: 'boolean', default: false })
autoDetected: boolean;
@Column({ type: 'boolean', default: false })
actionTaken: boolean;
@Column({ type: 'jsonb', nullable: true })
actionDetails: {
actionType: ActionType;
appliedAt: Date;
appliedBy?: string;
duration?: number;
expiresAt?: Date;
notes?: string;
} | null;
@Column({ type: 'uuid', nullable: true })
reviewedBy: string | null;
@Column({ type: 'timestamp with time zone', nullable: true })
reviewedAt: Date | null;
@Column({ type: 'text', nullable: true })
reviewNotes: string | null;
@CreateDateColumn()
@Index()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
// Relations will be added when User and Puzzle entities are imported
// @ManyToOne('User', 'cheatViolations')
// @JoinColumn({ name: 'playerId' })
// player: any;
// @ManyToOne('Puzzle', { nullable: true })
// @JoinColumn({ name: 'puzzleId' })
// puzzle?: any;
// @OneToMany('CheatAppeal', 'violation')
// appeals: CheatAppeal[];
}