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.3 KB
Raw Blame
import {
  createPiece,
  PieceAuth,
  Property,
} from '@activepieces/pieces-framework';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import { launchWorkflow } from './lib/actions/launch-workflow';
import { getJobResults } from './lib/actions/get-job-results';

export const CAPTAIN_DATA_BASE_URL = 'https://api.captaindata.co/v3';

export const captainDataAuth = PieceAuth.CustomAuth({
  required: true,
  props: {
    apiKey: PieceAuth.SecretText({
      displayName: 'API key',
      required: true,
    }),
    projectId: Property.ShortText({
      displayName: 'Project ID',
      required: true,
    }),
  },
});

export type CaptainDataAuthType = {
  apiKey: string;
  projectId: string;
};

export const captainData = createPiece({
  displayName: 'Captain-data',
  auth: captainDataAuth,
  minimumSupportedRelease: '0.30.0',
  logoUrl: 'https://cdn.activepieces.com/pieces/captain-data.png',
  authors: ['AdamSelene'],
  actions: [
    launchWorkflow,
    getJobResults,
    createCustomApiCallAction({
      auth: captainDataAuth,
      baseUrl: () => CAPTAIN_DATA_BASE_URL,
      authMapping: async (auth) => ({
        Authorization: `x-api-key ${auth.props.apiKey}`,
        'x-project-id': auth.props.projectId,
      }),
    }),
  ],
  triggers: [],
});