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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { apId, Metadata, spreadIfDefined } from '@activepieces/core-utils'
import { FlowVersionTemplate, Template, TemplateStatus, TemplateTag, TemplateType, UpdateTemplateRequestBody } from '@activepieces/shared'
import { repoFactory } from '../../core/db/repo-factory'
import { TemplateEntity } from '../../template/template.entity'
const templateRepo = repoFactory<Template>(TemplateEntity)
export const platformTemplateService = () => ({
async create({ platformId, name, summary, description, pieces, tags, blogUrl, metadata, author, categories, flows }: CreateParams): Promise<Template> {
const newTags = tags ?? []
const newTemplate: NewTemplate = {
id: apId(),
name,
type: TemplateType.CUSTOM,
summary,
description,
platformId,
tags: newTags,
blogUrl,
metadata,
author,
categories,
pieces,
flows,
status: TemplateStatus.PUBLISHED,
}
return templateRepo().save(newTemplate)
},
async update({ id, params, flows, pieces }: UpdateParams): Promise<Template> {
const { name, description, summary, tags, blogUrl, metadata, categories, status } = params
await templateRepo().update(id, {
...spreadIfDefined('name', name),
...spreadIfDefined('description', description),
...spreadIfDefined('summary', summary),
...spreadIfDefined('tags', tags),
...spreadIfDefined('blogUrl', blogUrl),
...spreadIfDefined('metadata', metadata),
...spreadIfDefined('categories', categories),
...spreadIfDefined('flows', flows),
...spreadIfDefined('pieces', pieces),
...spreadIfDefined('status', status),
})
return templateRepo().findOneByOrFail({ id })
},
})
type CreateParams = {
platformId: string | undefined
name: string
summary: string
description: string
tags: TemplateTag[]
blogUrl: string | undefined
metadata: Metadata | null | undefined
author: string
categories: string[]
flows: FlowVersionTemplate[]
pieces: string[]
}
type NewTemplate = Omit<Template, 'created' | 'updated'>
type UpdateParams = {
id: string
params: UpdateTemplateRequestBody
flows: FlowVersionTemplate[] | undefined
pieces: string[] | undefined
}