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

615 B
Raw Blame
import { ApFile } from "@activepieces/pieces-framework";
import { isNil } from '@activepieces/pieces-framework';

export function toEmailObjects(addresses: unknown[]) {
  return addresses
    .filter((addr): addr is string => typeof addr === 'string')
    .map((address) => ({ address }));
}

export function buildAttachmentList(attachments: Array<{ file: ApFile }>) {
  return attachments
    .filter(
      (item): item is { file: ApFile } =>
        typeof item === 'object' && !isNil(item) && 'file' in item,
    )
    .map(({ file }) => ({
      file_name: file.filename,
      content: file.base64,
    }));
}