Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.8 KB
Raw Blame
import { ApplicationEvent, Platform } from '@activepieces/shared'
import { EntitySchema } from 'typeorm'
import { BaseColumnSchemaPart } from '../../database/database-common'

type AuditEventSchema = ApplicationEvent & {
    platform: Platform
}

export const AuditEventEntity = new EntitySchema<AuditEventSchema>({
    name: 'audit_event',
    columns: {
        ...BaseColumnSchemaPart,
        platformId: {
            type: String,
        },
        projectId: {
            type: String,
            nullable: true,
        },
        action: {
            type: String,
        },
        userEmail: {
            type: String,
            nullable: true,
        },
        projectDisplayName: {
            type: String,
            nullable: true,
        },
        data: {
            type: 'jsonb',
        },
        ip: {
            type: String,
            nullable: true,
        },
        userId: {
            type: String,
            nullable: true,
        },
    },
    indices: [
        {
            name: 'audit_event_platform_id_project_id_user_id_action_idx',
            columns: ['platformId', 'projectId', 'userId', 'action'],
        },
        {
            name: 'audit_event_platform_id_user_id_action_idx',
            columns: ['platformId', 'userId', 'action'],
        },
        {
            name: 'audit_event_platform_id_action_idx',
            columns: ['platformId', 'action'],
        },
        {
            name: 'audit_event_platform_id_created_id_desc_idx',
            columns: ['platformId', 'created', 'id'],
        },
    ],
    relations: {
        platform: {
            type: 'many-to-one',
            target: 'platform',
            cascade: true,
            onDelete: 'CASCADE',
            joinColumn: {
                name: 'platformId',
                referencedColumnName: 'id',
            },
        },
    },
})