import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn, Relation, Index, } from 'typeorm'; import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface'; import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity'; export type CronTriggerSettings = { pattern: string; }; @Entity({ name: 'cronTrigger', schema: 'core' }) @Index('IDX_CRON_TRIGGER_WORKSPACE_ID', ['workspaceId']) export class CronTrigger extends SyncableEntity { @PrimaryGeneratedColumn('uuid') id: string; @Column({ nullable: false, type: 'jsonb' }) settings: CronTriggerSettings; @ManyToOne( () => ServerlessFunctionEntity, (serverlessFunction) => serverlessFunction.cronTriggers, { onDelete: 'CASCADE' }, ) @JoinColumn({ name: 'serverlessFunctionId' }) serverlessFunction: Relation; @Column({ nullable: false, type: 'uuid' }) workspaceId: string; @CreateDateColumn({ type: 'timestamptz' }) createdAt: Date; @UpdateDateColumn({ type: 'timestamptz' }) updatedAt: Date; }