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.9 KB
Raw Blame
import { Platform, User } from '@activepieces/shared'
import { EntitySchema } from 'typeorm'
import {
    ApIdSchema,
    BaseColumnSchemaPart,
} from '../database/database-common'

type PlatformSchema = Platform & {
    owner: User
}

export const PlatformEntity = new EntitySchema<PlatformSchema>({
    name: 'platform',
    columns: {
        ...BaseColumnSchemaPart,
        ownerId: {
            ...ApIdSchema,
            nullable: false,
        },
        name: {
            type: String,
            nullable: false,
        },
        primaryColor: {
            type: String,
            nullable: false,
        },
        themeColors: {
            type: 'jsonb',
            nullable: true,
        },
        logoIconUrl: {
            type: String,
            nullable: false,
        },
        fullLogoUrl: {
            type: String,
            nullable: false,
        },
        favIconUrl: {
            type: String,
            nullable: false,
        },
        cloudAuthEnabled: {
            type: Boolean,
            nullable: false,
            default: true,
        },
        googleAuthEnabled: {
            type: Boolean,
            nullable: false,
            default: true,
        },
        allowedAuthDomains: {
            type: String,
            array: true,
        },
        allowedEmbedOrigins: {
            type: String,
            array: true,
            nullable: false,
            default: [],
        },
        ssoDomain: {
            type: String,
            nullable: true,
        },
        ssoDomainVerification: {
            type: 'jsonb',
            nullable: true,
        },
        enforceAllowedAuthDomains: {
            type: Boolean,
            nullable: false,
        },
        emailAuthEnabled: {
            type: Boolean,
            nullable: false,
        },
        autoCreatePersonalProjects: {
            type: Boolean,
            nullable: false,
            default: true,
        },
        federatedAuthProviders: {
            type: 'jsonb',
            select: false,
        },
        pinnedPieces: {
            type: String,
            array: true,
            nullable: false,
        },
        pieceSelectorConfig: {
            type: 'jsonb',
            nullable: true,
        },
        auditLogRetentionDays: {
            type: Number,
            nullable: true,
        },
    },
    indices: [
        {
            name: 'idx_platform_sso_domain',
            columns: ['ssoDomain'],
            unique: true,
            where: '"ssoDomain" IS NOT NULL',
        },
    ],
    relations: {
        owner: {
            type: 'one-to-one',
            target: 'user',
            onDelete: 'RESTRICT',
            onUpdate: 'RESTRICT',
            joinColumn: {
                name: 'ownerId',
                referencedColumnName: 'id',
                foreignKeyConstraintName: 'fk_platform_user',
            },
        },
    },
})