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

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

type TemplateSchema = Template & {
    platform: Platform
}

export const TemplateEntity = new EntitySchema<TemplateSchema>({
    name: 'template',
    columns: {
        ...BaseColumnSchemaPart,
        name: {
            type: String,
        },
        summary: {
            type: String,
            nullable: false,
        },
        description: {
            type: String,
        },
        type: {
            type: String,
        },
        platformId: {
            type: String,
            nullable: true,
        },
        status: {
            type: String,
            nullable: false,
        },
        flows: {
            type: 'jsonb',
            nullable: true,
        },
        tables: {
            type: 'jsonb',
            nullable: true,
        },
        tags: {
            type: 'jsonb',
            nullable: false,
        },
        blogUrl: {
            type: String,
            nullable: true,
        },
        metadata: {
            type: 'jsonb',
            nullable: true,
        },
        author: {
            type: String,
            nullable: false,
        },
        categories: {
            type: String,
            array: true,
            nullable: false,
        },
        pieces: {
            type: String,
            array: true,
        },
    },
    indices: [
        {
            name: 'idx_template_pieces',
            columns: ['pieces'],
            unique: false,
        },
        {
            name: 'idx_template_categories',
            columns: ['categories'],
            unique: false,
        },
        {
            name: 'idx_template_platform_id',
            columns: ['platformId'],
            unique: false,
        },
    ],
    relations: {
        platform: {
            type: 'many-to-one',
            target: 'platform',
            cascade: true,
            onDelete: 'CASCADE',
            nullable: true,
            joinColumn: {
                name: 'platformId',
                foreignKeyConstraintName: 'fk_template_platform_id',
            },
        },
    },
})