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

2.1 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { clicdataAuth } from '../common/auth';
import { clicdataApiCall } from '../common/client';
import { clicdataCommonProps } from '../common/props';
import { HttpMethod } from '@activepieces/pieces-common';

export const refreshTable = createAction({
  auth: clicdataAuth,
  name: 'refresh_table',
  classification: 'WRITE',
  displayName: 'Refresh Table',
  description: 'Refresh the selected table depending on the refresh mode',
  audience: 'both',
  aiMetadata: { description: 'Triggers a refresh of a ClicData table by table ID to re-pull or recompute its data. The refresh mode is required and controls how data is applied — reload, rebuild, update, append, or update+append. Use after a source changes to update the table. Not idempotent: append-based modes add rows on each call, so repeated runs change the result.', idempotent: false },
  props: {
    table_id: clicdataCommonProps.table_id,
    mode: Property.StaticDropdown({
      displayName: 'Refresh Mode',
      description: 'Select the refresh mode for the table',
      required: true,
      options: {
        options: [
          {
            label: 'Reload',
            value: 'reload',
          },
          {
            label: 'Rebuild',
            value: 'rebuild',
          },
          {
            label: 'Update',
            value: 'update',
          },
          {
            label: 'Append',
            value: 'append',
          },
          {
            label: 'Update + Append',
            value: 'updateappend',
          },
        ],
      },
      defaultValue: 'reload',
    }),
    apiVersion: clicdataCommonProps.apiVersion,
  },
  async run(context) {
    const { table_id, mode, apiVersion } = context.propsValue;

    const response = await clicdataApiCall<{
      success: boolean;
    }>({
      method: HttpMethod.POST,
      path: `/table/${table_id}/refresh`,
      auth: context.auth,
      body: {
        mode: mode,
      },
      apiVersion: apiVersion || '2025.3',
    });

    return response.result;
  },
});