Skip to main content
Glama
PersonUpdateStrategy.ts1.83 kB
import type { AttioRecord } from '../../../types/attio.js'; import type { PersonAttributes } from '../../../objects/people/types.js'; import { updatePerson } from '../../../objects/people-write.js'; import { getFieldSuggestions } from '../../../handlers/tool-configs/universal/field-mapper.js'; import { UniversalValidationError, ErrorType, } from '../../../handlers/tool-configs/universal/schemas.js'; import type { UniversalResourceType } from '../../../handlers/tool-configs/universal/types.js'; import type { UpdateStrategy } from './BaseUpdateStrategy.js'; import { ValidationService } from '../../ValidationService.js'; /** * PersonUpdateStrategy - Handles updates for People (with email validation) */ export class PersonUpdateStrategy implements UpdateStrategy { async update( recordId: string, values: Record<string, unknown>, resourceType: UniversalResourceType ): Promise<AttioRecord> { try { // Validate emails same as create operations ValidationService.validateEmailAddresses(values); // Coerce mapped/validated values to PersonAttributes for update return (await updatePerson( recordId, values as unknown as PersonAttributes )) as unknown as AttioRecord; } catch (err: unknown) { const errorMessage = err instanceof Error ? err.message : String(err); if (errorMessage.includes('Cannot find attribute')) { const match = errorMessage.match(/slug\/ID "([^"]+)"/); if (match && match[1]) { const suggestion = getFieldSuggestions(resourceType, match[1]); throw new UniversalValidationError( errorMessage, 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