mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
53 lines
1,009 B
TypeScript
53 lines
1,009 B
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm'
|
|
import { User } from './user'
|
|
|
|
export enum RuleActionType {
|
|
AddLabel = 'ADD_LABEL',
|
|
Archive = 'ARCHIVE',
|
|
MarkAsRead = 'MARK_AS_READ',
|
|
SendNotification = 'SEND_NOTIFICATION',
|
|
}
|
|
|
|
export interface RuleAction {
|
|
type: RuleActionType
|
|
params: string[]
|
|
}
|
|
|
|
@Entity({ name: 'rules' })
|
|
export class Rule {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string
|
|
|
|
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'user_id' })
|
|
user!: User
|
|
|
|
@Column('text')
|
|
name!: string
|
|
|
|
@Column('text')
|
|
filter!: string
|
|
|
|
@Column('simple-json')
|
|
actions!: RuleAction[]
|
|
|
|
@Column('text', { nullable: true })
|
|
description?: string | null
|
|
|
|
@Column('boolean', { default: true })
|
|
enabled!: boolean
|
|
|
|
@CreateDateColumn({ default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date
|
|
|
|
@UpdateDateColumn({ default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date
|
|
}
|