Spaces:
Runtime error
Runtime error
| import { | |
| Entity, | |
| Column, | |
| Index, | |
| PrimaryGeneratedColumn, | |
| CreateDateColumn, | |
| UpdateDateColumn, | |
| ManyToOne, | |
| JoinColumn, | |
| } from 'typeorm'; | |
| import { Session } from '../../session/entities/session.entity'; | |
| import { DateTransformer } from '../../../common/transformers/date.transformer'; | |
| import { jsonColumnType, dateColumnType } from '../../../common/utils/column-types'; | |
| import { WebhookFilters } from '../filters/filter-types'; | |
| ('webhooks') | |
| export class Webhook { | |
| ('uuid') | |
| id: string; | |
| // varchar (not uuid) to match the authoritative migration DDL and sessions.id; the data connection | |
| // runs synchronize:false, so a 'uuid' decorator here would only mislead schema diffs / a stray sync. | |
| // Indexed: the dispatch path filters webhooks by sessionId on every emitted event (see the | |
| // AddWebhooksSessionIdIndex migration, which creates the index on migration-managed DBs). | |
| ('IDX_webhooks_sessionId') | |
| ({ type: 'varchar' }) | |
| sessionId: string; | |
| (() => Session, { onDelete: 'CASCADE' }) | |
| ({ name: 'sessionId' }) | |
| session: Session; | |
| ({ type: 'varchar', length: 2048 }) | |
| url: string; | |
| ({ type: jsonColumnType(), default: '["message.received"]' }) | |
| events: string[]; | |
| ({ type: 'varchar', length: 255, nullable: true }) | |
| secret: string | null; | |
| ({ type: jsonColumnType(), default: '{}' }) | |
| headers: Record<string, string>; | |
| // Optional smart pre-filter. Null/absent means "no filtering" (fire on every subscribed event). | |
| ({ type: jsonColumnType(), nullable: true }) | |
| filters: WebhookFilters | null; | |
| ({ type: 'boolean', default: true }) | |
| active: boolean; | |
| ({ type: 'int', default: 3 }) | |
| retryCount: number; | |
| ({ type: dateColumnType(), nullable: true, transformer: DateTransformer }) | |
| lastTriggeredAt: Date | null; | |
| () | |
| createdAt: Date; | |
| () | |
| updatedAt: Date; | |
| } | |