forked from MindFlowInteractive/quest-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuzzle-move-audit.entity.ts
More file actions
79 lines (64 loc) · 1.69 KB
/
Copy pathpuzzle-move-audit.entity.ts
File metadata and controls
79 lines (64 loc) · 1.69 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
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
Index,
ManyToOne,
JoinColumn
} from 'typeorm';
import type { PuzzleMove, ValidationResult } from '../../game-engine/types/puzzle.types';
/**
* Entity for detailed audit trail of puzzle moves
* Used for forensic analysis and pattern detection
*/
@Entity('puzzle_move_audit')
@Index(['playerId', 'puzzleId', 'createdAt'])
@Index(['sessionId'])
@Index(['flaggedAsSuspicious', 'createdAt'])
export class PuzzleMoveAudit {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'uuid' })
@Index()
playerId: string;
@Column({ type: 'uuid' })
@Index()
puzzleId: string;
@Column({ type: 'uuid' })
@Index()
sessionId: string;
@Column({ type: 'jsonb' })
moveData: PuzzleMove;
@Column({ type: 'int' })
moveNumber: number;
@Column({ type: 'int' })
timeSincePreviousMove: number;
@Column({ type: 'boolean' })
wasValid: boolean;
@Column({ type: 'jsonb', nullable: true })
validationResult: ValidationResult | null;
@Column({ type: 'jsonb', nullable: true })
behaviorMetrics: {
mouseMovements?: number;
keystrokes?: number;
focusLost?: boolean;
clientTimestamp?: Date;
deviceFingerprint?: string;
} | null;
@Column({ type: 'boolean', default: false })
@Index()
flaggedAsSuspicious: boolean;
@Column({ type: 'jsonb', nullable: true })
suspicionReasons: string[] | null;
@CreateDateColumn()
@Index()
createdAt: Date;
// Relations will be added when User and Puzzle entities are imported
// @ManyToOne('User')
// @JoinColumn({ name: 'playerId' })
// player: any;
// @ManyToOne('Puzzle')
// @JoinColumn({ name: 'puzzleId' })
// puzzle: any;
}