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.7 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { OAuth2PropertyValue } from '@activepieces/pieces-framework';
import {
  HttpMethod,
  AuthenticationType,
  httpClient,
} from '@activepieces/pieces-common';
import { googleTasksCommon } from '../common';
import { googleTasksAuth } from '../auth';
import { googleTasksClearCompletedTasksOutputSchema } from '../output-schemas';

export const googleTasksClearCompletedTasksAction = createAction({
  auth: googleTasksAuth,
  name: 'clear_completed_tasks',
  classification: 'DESTRUCTIVE',
  displayName: 'Clear Completed Tasks',
  description: 'Hide all completed tasks in a task list.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Hide all completed tasks in a task list (they are marked hidden and drop out of the default view, not permanently deleted). Use to tidy a list after a batch of completions. Affects every completed task at once — there is no per-task selection; to remove a single task use Delete Task. Not idempotent — operates on whatever is completed at call time.',
    idempotent: false,
  },
  outputSchema: googleTasksClearCompletedTasksOutputSchema,
  props: {
    tasks_list: googleTasksCommon.tasksList,
  },
  async run({ auth, propsValue }) {
    const authProp = auth as OAuth2PropertyValue;
    const { tasks_list } = propsValue;

    await httpClient.sendRequest({
      method: HttpMethod.POST,
      url: `${googleTasksCommon.baseUrl}/tasks/v1/lists/${tasks_list}/clear`,
      authentication: {
        type: AuthenticationType.BEARER_TOKEN,
        token: authProp.access_token,
      },
    });

    // tasks.clear returns 204 No Content on success.
    return { cleared: true };
  },
});