Skip to main content
Glama
ListCreateStrategy.ts1.96 kB
import type { AttioRecord } from '../../../types/attio.js'; import type { CreateStrategy, CreateStrategyParams, } from './BaseCreateStrategy.js'; interface ListCreateResponse { id: { list_id: string; }; name?: string; title?: string; description?: string; object_slug?: string; parent_object?: string; api_slug?: string; workspace_id?: string; workspace_member_access?: string; created_at?: string; } import { createList } from '../../../objects/lists.js'; import { getFieldSuggestions } from '../../../handlers/tool-configs/universal/field-mapper.js'; import { UniversalValidationError, ErrorType, } from '../../../handlers/tool-configs/universal/schemas.js'; export class ListCreateStrategy implements CreateStrategy { async create(params: CreateStrategyParams): Promise<AttioRecord> { const { values, resourceType } = params; try { const list = (await createList(values)) as ListCreateResponse; return { id: { record_id: list.id.list_id, list_id: list.id.list_id, }, values: { name: list.name || list.title, description: list.description, parent_object: list.object_slug || list.parent_object, api_slug: list.api_slug, workspace_id: list.workspace_id, workspace_member_access: list.workspace_member_access, created_at: list.created_at, }, } as unknown as AttioRecord; } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); if (msg.includes('Cannot find attribute')) { const match = msg.match(/slug\/ID "([^"]+)"/); if (match && match[1]) { const suggestion = getFieldSuggestions(resourceType, match[1]); throw new UniversalValidationError(msg, ErrorType.USER_ERROR, { suggestion, field: match[1], }); } } throw err; } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kesslerio/attio-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server