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.2 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction } from '@activepieces/pieces-framework';
import { hedyAuth } from '../../auth';
import { createClient } from '../../common/client';
import { commonProps } from '../../common/props';
import { assertIdPrefix } from '../../common/validation';

export const deleteTopic = createAction({
  auth: hedyAuth,
  name: 'delete-topic',
  classification: 'DESTRUCTIVE',
  displayName: 'Delete Topic',
  description: 'Delete a topic.',
  audience: 'both',
  aiMetadata: {
    description: 'Permanently delete a Hedy topic identified by a topic ID (must be prefixed with "topic_"). Idempotent in effect: once deleted, repeating the call leaves the topic absent (a repeat may error if the topic no longer exists).',
    idempotent: true,
  },
  props: {
    topicId: commonProps.topicId,
  },
  async run(context) {
    const topicId = assertIdPrefix(context.propsValue['topicId'] as string, 'topic_', 'Topic ID');
    const client = createClient(context.auth);

    const response = await client.request({
      method: HttpMethod.DELETE,
      path: `/topics/${topicId}`,
    });

    return response ?? { success: true, deleted: true };
  },
});