Skip to main content
Glama

Activepieces MCP Server

by eldoonreval
duplicate-step.tsβ€’3.08 kB
import { isNil } from '../../common' import { Action, BranchExecutionType, RouterAction } from '../actions/action' import { FlowVersion } from '../flow-version' import { flowStructureUtil } from '../util/flow-structure-util' import { addActionUtils } from './add-action-util' import { _getImportOperations } from './import-flow' import { FlowOperationRequest, FlowOperationType, StepLocationRelativeToParent } from '.' function _duplicateStep(stepName: string, flowVersion: FlowVersion): FlowOperationRequest[] { const clonedAction: Action = JSON.parse(JSON.stringify(flowStructureUtil.getActionOrThrow(stepName, flowVersion.trigger))) const clonedActionWithoutNextAction = { ...clonedAction, nextAction: undefined, } const oldNameToNewName = addActionUtils.mapToNewNames(flowVersion, [clonedActionWithoutNextAction]) const clonedSubflow = flowStructureUtil.transferStep(clonedActionWithoutNextAction, (step: Action) => { return addActionUtils.clone(step, oldNameToNewName) }) const importOperations = _getImportOperations(clonedSubflow) return [ { type: FlowOperationType.ADD_ACTION, request: { action: clonedSubflow as Action, parentStep: stepName, stepLocationRelativeToParent: StepLocationRelativeToParent.AFTER, }, }, ...importOperations, ] } function _duplicateBranch( routerName: string, childIndex: number, flowVersion: FlowVersion, ): FlowOperationRequest[] { const router = flowStructureUtil.getActionOrThrow(routerName, flowVersion.trigger) const clonedRouter: RouterAction = JSON.parse(JSON.stringify(router)) const operations: FlowOperationRequest[] = [{ type: FlowOperationType.ADD_BRANCH, request: { branchName: `${clonedRouter.settings.branches[childIndex].branchName} Copy`, branchIndex: childIndex + 1, stepName: routerName, conditions: clonedRouter.settings.branches[childIndex].branchType === BranchExecutionType.CONDITION ? clonedRouter.settings.branches[childIndex].conditions : undefined, }, }] const childRouter = clonedRouter.children[childIndex] if (!isNil(childRouter)) { const oldNameToNewName = addActionUtils.mapToNewNames(flowVersion, [childRouter]) const clonedSubflow = flowStructureUtil.transferStep(childRouter, (step: Action) => { return addActionUtils.clone(step, oldNameToNewName) }) const importOperations = _getImportOperations(clonedSubflow) operations.push({ type: FlowOperationType.ADD_ACTION, request: { stepLocationRelativeToParent: StepLocationRelativeToParent.INSIDE_BRANCH, action: clonedSubflow as Action, parentStep: routerName, branchIndex: childIndex + 1, }, }) operations.push(...importOperations) } return operations } export { _duplicateStep, _duplicateBranch }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/eldoonreval/activepieces'

If you have feedback or need assistance with the MCP directory API, please join our Discord server