<commit_before>// @ts-ignore
import Attachments from '../../app/attachments';
import { formatPhoneNumber } from '../util/formatPhoneNumber';

export interface Contact {
  name: Name;
  number?: Array<Phone>;
  email?: Array<Email>;
  address?: Array<PostalAddress>;
  avatar?: Avatar;
  organization?: string;
}

interface Name {
  givenName?: string;
  familyName?: string;
  prefix?: string;
  suffix?: string;
  middleName?: string;
  displayName: string;
}

export enum ContactType {
  HOME = 1,
  MOBILE = 2,
  WORK = 3,
  CUSTOM = 4,
}

export enum AddressType {
  HOME = 1,
  WORK = 2,
  CUSTOM = 3,
}

export interface Phone {
  value: string;
  type: ContactType;
  label?: string;
}

export interface Email {
  value: string;
  type: ContactType;
  label?: string;
}

export interface PostalAddress {
  type: AddressType;
  label?: string;
  street?: string;
  pobox?: string;
  neighborhood?: string;
  city?: string;
  region?: string;
  postcode?: string;
  country?: string;
}

interface Avatar {
  avatar: Attachment;
  isProfile: boolean;
}

interface Attachment {
  path: string;
}

export function contactSelector(
  contact: Contact,
  options: {
    regionCode: string;
    getAbsoluteAttachmentPath: (path: string) => string;
  }
) {
  const { regionCode, getAbsoluteAttachmentPath } = options;

  let { avatar } = contact;
  if (avatar && avatar.avatar && avatar.avatar.path) {
    avatar = {
      ...avatar,
      avatar: {
        ...avatar.avatar,
        path: getAbsoluteAttachmentPath(avatar.avatar.path),
      },
    };
  }
  return Object.assign({}, contact, {
    avatar,
    number:
      contact.number &&
      contact.number.map(item => ({
        ...item,
        value: formatPhoneNumber(item.value, {
          ourRegionCode: regionCode,
        }),
      })),
  });
}

export function getName(contact: Contact): string | null {
  const { name, organization } = contact;
  return (name && name.displayName) || organization || null;
}<commit_msg>Remove Object.assign still hanging around in typescript<commit_after>// @ts-ignore
import Attachments from '../../app/attachments';
import { formatPhoneNumber } from '../util/formatPhoneNumber';

export interface Contact {
  name: Name;
  number?: Array<Phone>;
  email?: Array<Email>;
  address?: Array<PostalAddress>;
  avatar?: Avatar;
  organization?: string;
}

interface Name {
  givenName?: string;
  familyName?: string;
  prefix?: string;
  suffix?: string;
  middleName?: string;
  displayName: string;
}

export enum ContactType {
  HOME = 1,
  MOBILE = 2,
  WORK = 3,
  CUSTOM = 4,
}

export enum AddressType {
  HOME = 1,
  WORK = 2,
  CUSTOM = 3,
}

export interface Phone {
  value: string;
  type: ContactType;
  label?: string;
}

export interface Email {
  value: string;
  type: ContactType;
  label?: string;
}

export interface PostalAddress {
  type: AddressType;
  label?: string;
  street?: string;
  pobox?: string;
  neighborhood?: string;
  city?: string;
  region?: string;
  postcode?: string;
  country?: string;
}

interface Avatar {
  avatar: Attachment;
  isProfile: boolean;
}

interface Attachment {
  path: string;
}

export function contactSelector(
  contact: Contact,
  options: {
    regionCode: string;
    getAbsoluteAttachmentPath: (path: string) => string;
  }
) {
  const { regionCode, getAbsoluteAttachmentPath } = options;

  let { avatar } = contact;
  if (avatar && avatar.avatar && avatar.avatar.path) {
    avatar = {
      ...avatar,
      avatar: {
        ...avatar.avatar,
        path: getAbsoluteAttachmentPath(avatar.avatar.path),
      },
    };
  }
  return {
    ...contact,
    avatar,
    number:
      contact.number &&
      contact.number.map(item => ({
        ...item,
        value: formatPhoneNumber(item.value, {
          ourRegionCode: regionCode,
        }),
      })),
  };
}

export function getName(contact: Contact): string | null {
  const { name, organization } = contact;
  return (name && name.displayName) || organization || null;
}
{'fraction_non_alphanumeric': 0.133, 'fraction_numerical': 0.0035, 'mean_word_length': 3.1035897435897435, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '310356', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1270, 'n_words': 333}