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.4 KB
Raw Blame
import {
  PiecePropValueSchema,
  Property,
  createAction,
} from '@activepieces/pieces-framework';
import { drupalAuth } from '../auth';
import { drupal } from '../common/jsonapi';
import { fetchEntityTypesForReading } from '../common/drupal-entities';

export const drupalGetEntityAction = createAction({
  auth: drupalAuth,
  name: 'drupal-get-entity',
  classification: 'READ',
  displayName: 'Get Entity',
  description: 'Retrieve a single entity by UUID',
  audience: 'both',
  aiMetadata: { description: 'Retrieves a single Drupal entity by its entity type, bundle, and UUID via JSON:API. Use when the exact UUID is known; to find entities by criteria use List Entities instead. Read-only and idempotent.', idempotent: true },
  props: {
    entity_type: Property.Dropdown({
      displayName: 'Entity Type',
      description: 'Choose the type of content to retrieve.',
      required: true,
      refreshers: [],
      auth: drupalAuth,
      options: async ({ auth }) => fetchEntityTypesForReading(auth),
    }),
    entity_uuid: Property.ShortText({
      displayName: 'Entity UUID',
      description: 'The unique identifier (UUID) of the specific content item to retrieve.',
      required: true,
    }),
  },
  async run({ auth, propsValue }) {
    const entityInfo = propsValue.entity_type as any;

    return await drupal.getEntity(
      auth,
      entityInfo.entity_type,
      entityInfo.bundle,
      propsValue.entity_uuid
    );
  },
});