INNER CODE UNIT · TypeScript

plainText

rowboatlabs/rowboat · apps/harbor/packages/server/src/connectors/attio/index.ts:30

function plainText(value: string, limit: number): string {
  const flat = value.replace(/\s+/g, ' ').trim();
  const text = flat.length > limit ? `${flat.slice(0, limit)}…` : flat;
  return text.replace(/[&<>\[\]`*_\\|()#!]/g, (char) => `&#${char.charCodeAt(0)};`);
}

const current = <T extends { active_until?: string | null }>(values: T[] = []) => values.filter((value) => !value.active_until);

function companySummary(company: AttioCompany): string {
  const name = current(company.values.name)[0]?.value || 'Unnamed company';
  const description = current(company.values.description)[0]?.value;
  const domains = current(company.values.domains).slice(0, 5).map((value) => plainText(value.domain, 253));
  const lines = [`**${plainText(name, 160)}**`];
  if (domains.length) lines.push(`Domains: ${domains.join(', ')}`);
  if (description) lines.push(plainText(description, 500));
  return [...lines, ...recordFooter(company)].join('\n\n');
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…