forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebhook-delivery.entity.ts
More file actions
69 lines (55 loc) · 1.36 KB
/
Copy pathwebhook-delivery.entity.ts
File metadata and controls
69 lines (55 loc) · 1.36 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
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
Index,
} from 'typeorm';
import { Webhook } from './webhook.entity';
export enum DeliveryStatus {
PENDING = 'pending',
SUCCESS = 'success',
FAILED = 'failed',
}
@Entity('webhook_deliveries')
@Index(['webhookId'])
@Index(['status'])
@Index(['webhookId', 'status'])
@Index(['createdAt'])
export class WebhookDelivery {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'uuid' })
webhookId!: string;
@Column({ type: 'varchar' })
eventType!: string;
@Column({ type: 'jsonb' })
payload!: Record<string, any>;
@Column({
type: 'enum',
enum: DeliveryStatus,
default: DeliveryStatus.PENDING,
})
status!: DeliveryStatus;
@Column({ type: 'integer', default: 0 })
attemptCount!: number;
@Column({ type: 'integer', nullable: true })
httpStatus?: number;
@Column({ type: 'integer', nullable: true })
statusCode?: number;
@Column({ type: 'text', nullable: true })
responseBody?: string;
@Column({ type: 'text', nullable: true })
errorMessage?: string;
@Column({ type: 'timestamp', nullable: true })
deliveredAt?: Date;
@CreateDateColumn()
createdAt!: Date;
@ManyToOne(() => Webhook, (webhook) => webhook.deliveries, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'webhookId' })
webhook?: Webhook;
}