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.5 KB
Raw Blame
import {  DiffState, FlowProjectOperationType, ProjectState, TableOperationType } from '@activepieces/shared'
import { connectionDiffService } from './diff/connection-diff.service'
import { flowDiffService } from './diff/flow-diff.service'
import { tableDiffService } from './diff/table-diff.service'

export const projectDiffService = {
    async diff({ newState, currentState }: DiffParams): Promise<DiffState> {
        const flowOperations = await flowDiffService.diff({ newState, currentState })
        const connections = connectionDiffService.diff({ newState, currentState })
        const tables = tableDiffService.diff({ newState, currentState })
        return {
            flows: flowOperations,
            connections,
            tables,
        }
    },
    async filterFlows(selectedFlowsIds: string[], diffs: DiffState): Promise<DiffState> {
        return {
            flows: diffs.flows.filter(operation => selectedFlowsIds.includes(operation.flowState.id)),
            connections: diffs.connections,
            tables: diffs.tables,
        }
    },
    async filterDeleteOperation(diffs: DiffState): Promise<DiffState> {
        return {
            flows: diffs.flows.filter(f =>![FlowProjectOperationType.DELETE_FLOW].includes(f.type)),
            connections: diffs.connections,
            tables: diffs.tables.filter(t =>![TableOperationType.DELETE_TABLE].includes(t.type)),
        }
    },
}

type DiffParams = {
    currentState: ProjectState
    newState: ProjectState
}