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

type OAuthAppSchema = {
    platform: Platform[]
    clientSecret: EncryptedObject
} & OAuthApp

export type OAuthAppWithSecret = OAuthApp & { clientSecret: string }
export type OAuthAppWithEncryptedSecret = OAuthApp & {
    clientSecret: EncryptedObject
}

export const OAuthAppEntity = new EntitySchema<OAuthAppSchema>({
    name: 'oauth_app',
    columns: {
        ...BaseColumnSchemaPart,
        pieceName: {
            type: String,
        },
        platformId: ApIdSchema,
        clientId: {
            type: String,
        },
        clientSecret: {
            type: 'jsonb',
        },
    },
    indices: [
        {
            name: 'idx_oauth_app_platformId_pieceName',
            columns: ['platformId', 'pieceName'],
            unique: true,
        },
    ],
    relations: {
        platform: {
            type: 'many-to-one',
            target: 'platform',
            cascade: true,
            onDelete: 'CASCADE',
            joinColumn: {
                name: 'platformId',
                foreignKeyConstraintName: 'fk_oauth_app_platform_id',
            },
        },
    },
})