forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebhook.entity.ts
More file actions
59 lines (47 loc) · 1.26 KB
/
Copy pathwebhook.entity.ts
File metadata and controls
59 lines (47 loc) · 1.26 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
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
OneToMany,
} from 'typeorm';
import { WebhookDelivery } from './webhook-delivery.entity';
export enum WebhookEventType {
SPLIT_CREATED = 'split.created',
SPLIT_UPDATED = 'split.updated',
SPLIT_COMPLETED = 'split.completed',
PAYMENT_RECEIVED = 'payment.received',
PAYMENT_MADE = 'payment.made',
PARTICIPANT_ADDED = 'participant.added',
}
@Entity('webhooks')
@Index(['userId'])
@Index(['isActive'])
@Index(['userId', 'isActive'])
export class Webhook {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'varchar' })
@Index()
userId!: string;
@Column({ type: 'varchar', length: 500 })
url!: string;
@Column({ type: 'jsonb', default: [] })
events!: WebhookEventType[];
@Column({ type: 'varchar', length: 255 })
secret!: string;
@Column({ type: 'boolean', default: true })
isActive!: boolean;
@Column({ type: 'integer', default: 0 })
failureCount!: number;
@Column({ type: 'timestamp', nullable: true })
lastTriggeredAt?: Date;
@CreateDateColumn()
createdAt!: Date;
@UpdateDateColumn()
updatedAt!: Date;
@OneToMany(() => WebhookDelivery, (delivery) => delivery.webhook)
deliveries?: WebhookDelivery[];
}