forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvitation.entity.ts
More file actions
56 lines (44 loc) · 1.62 KB
/
Copy pathinvitation.entity.ts
File metadata and controls
56 lines (44 loc) · 1.62 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
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { Split } from '../entities/split.entity';
@Entity('invitations')
export class Invitation {
@PrimaryGeneratedColumn('uuid')
id!: string;
/** Unique token for the invite link (UUID). */
@Column({ type: 'varchar', length: 36, unique: true, name: 'token' })
token!: string;
@Column({ type: 'uuid', name: 'split_id' })
splitId!: string;
@Column({ type: 'timestamp', name: 'expires_at' })
expiresAt!: Date;
/** Set when the invite is used; null until then. */
@Column({ type: 'timestamp', name: 'used_at', nullable: true })
usedAt!: Date | null;
/** Maximum number of times this invitation can be used (default 1). */
@Column({ type: 'int', default: 1, name: 'max_uses' })
maxUses!: number;
/** Current number of times this invitation has been used. */
@Column({ type: 'int', default: 0, name: 'uses_count' })
usesCount!: number;
/** Whether this invitation can be upgraded to a registered user. */
@Column({ type: 'boolean', default: true, name: 'is_upgradeable' })
isUpgradeable!: boolean;
/** Email of the invitee (optional, for duplicate detection). */
@Column({ type: 'varchar', nullable: true, name: 'invitee_email' })
inviteeEmail?: string;
/** Token version for security (used to invalidate old tokens). */
@Column({ type: 'int', default: 1, name: 'token_version' })
tokenVersion!: number;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
@ManyToOne(() => Split, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'split_id' })
split?: Split;
}