<commit_before>declare module 'plaid' {
  import { CoreOptions } from 'request';

  type Callback<T extends Object> = (err: Error, response: T) => void;
  type Iso8601DateString = string; // YYYY-MM-DD
  type Iso8601DateTimeString = string; // YYYY-MM-DDTHH:MM:SSZ

  interface AccessTokenFn<T> {
    (accessToken: string): Promise<T>;
    (accessToken: string, cb: Callback<T>): void;
  }

  // OPTIONS /////////////////////////////////////////////////////////////////

  interface ClientRequestOptions {
    timeout: number;
  }

  interface ItemRequestOptions {
    account_ids?: Array<string>;
  }

  interface TransactionsRequestOptions extends ItemRequestOptions {
    count?: number;
    offset?: number;
  }

  interface InvestmentTransactionsRequestOptions extends ItemRequestOptions {
    count?: number;
    offset?: number;
  }

  interface GetAllTransactionsRequestOptions extends ItemRequestOptions {}

  interface AssetReportUser {
    client_user_id?: string | null;
    first_name?: string | null;
    middle_name?: string | null;
    last_name?: string | null;
    ssn?: string | null;
    phone_number?: string | null;
    email?: string | null;
  }

  interface AssetReportCreateOptions {
    client_report_id?: string | null;
    webhook?: string;
    user?: AssetReportUser;
  }

  type AssetReportRefreshOptions = AssetReportCreateOptions;

  // DATA TYPES //////////////////////////////////////////////////////////////

  interface AccountCommon {
    account_id: string;
    mask: string | null;
    name: string | null;
    official_name: string | null;
    subtype: string | null;
    type: string  | null;
  }

  interface Account extends AccountCommon {
    balances: {
      available: number | null;
      current: number | null;
      limit: number | null;
      iso_currency_code: string | null;
      official_currency_code: string | null;
    };
  }

  interface Security {
    security_id: string;
    cusip: string | null;
    sedol: string | null;
    isin: string | null;
    institution_security_id: string | null;
    institution_id: string | null;
    proxy_security_id: string | null;
    name: string | null;
    ticker_symbol: string | null;
    is_cash_equivalent: boolean | null;
    type: string | null;
    close_price: number | null;
    close_price_as_of: string | null;
    iso_currency_code: string | null;
    unofficial_currency_code: string | null;
  }

  interface AccountWithOwners extends Account {
    owners: Array<Identity>;
  }

  interface Category {
    type: string;
    hierarchy: Array<string>;
    category_id: string;
  }

  export class PlaidError extends Error {
    error_type: string;
    error_code: string;
    error_message: string;
    display_message: string | null;
    causes?: Array<Cause>;
  }

  // IPlaidError is a dupliate of PlaidError that is not an instance of Error.
  export interface IPlaidError {
    error_type: string;
    error_code: string;
    error_message: string;
    display_message: string | null;
    causes?: Array<Cause>;
  }

  interface Warning {
    warning_type: string;
    warning_code: string;
    cause: Cause;
  }

  interface Cause extends IPlaidError {
    item_id: string;
  }

  interface Item {
    available_products: Array<string>;
    billed_products: Array<string>;
    error: IPlaidError | null;
    institution_id: string;
    item_id: string;
    webhook: string;
  }

  interface Credential {
    name: string;
    label: string;
    type: 'text' | 'password';
  }

  interface Institution {
    credentials: Array<Credential>;
    has_mfa: boolean;
    institution_id: string;
    mfa: Array<string>;
    name: string;
    products: Array<string>;
    country_codes: Array<string>;
  }

  interface InstitutionWithDisplayData extends Institution {
    colors: Map<string, string>;
    logo: string | null;
    name_break: number | null;
    url_account_locked: string | null;
    url_account_setup: string | null;
    url_forgotten_password: string | null;
  }

  interface InstitutionWithInstitutionData extends Institution {
    logo: string;
    primary_color: string;
    url: string;
  }

  interface IncomeStream {
    monthly_income: number;
    confidence: number;
    days: number;
    name: string;
  }

  interface Income {
    income_streams: Array<IncomeStream>;
    last_year_income: number;
    last_year_income_before_tax: number;
    projected_yearly_income: number;
    projected_yearly_income_before_tax: number;
    max_number_of_overlapping_income_streams: number;
    number_of_income_streams: number;
  }

  interface Identity {
    addresses: Array<Address>;
    emails: Array<Email>;
    names: Array<string>;
    phone_numbers: Array<PhoneNumber>;
  }

  interface Address {
    data: AddressData;
    primary: boolean;
  }

  interface AddressData {
    city: string | null;
    region: string | null;
    postal_code: string | null;
    street: string | null;
    country: string | null;
  }

  interface Email {
    data: string;
    primary: boolean;
    type: string;
  }

  interface Holding {
    account_id: string;
    security_id: string;
    institution_value: number | null;
    institution_price: number | null;
    quantity: number | null;
    institution_price_as_of: string | null;
    cost_basis: number | null;
    iso_currency_code: string | null;
    unofficial_currency_code: string | null;
  }

  interface InvestmentTransaction {
    investment_transaction_id: string;
    account_id: string;
    security_id: string;
    cancel_transaction_id: string;
    date: Iso8601DateString;
    name: string | null;
    quantity: number | null;
    amount: number | null;
    price: number | null;
    fees: number | null;
    class: string | null;
    iso_currency_code: string | null;
    unofficial_currency_code: string | null;
  }

  interface PhoneNumber {
    data: string;
    primary: boolean;
    type: string;
  }

  interface TransactionLocation {
    address: string | null;
    city: string | null;
    lat: number | null;
    lon: number | null;
    region: string | null;
    store_number: string | null;
    postal_code: string | null;
    country: string | null;
  }

  interface TransactionPaymentMeta {
    by_order_of: string | null;
    payee: string | null;
    payer: string | null;
    payment_method: string | null;
    payment_processor: string | null;
    ppd_id: string | null;<commit_msg>change investment transaction `class` prop to `type`u (#206)<commit_after>declare module 'plaid' {
  import { CoreOptions } from 'request';

  type Callback<T extends Object> = (err: Error, response: T) => void;
  type Iso8601DateString = string; // YYYY-MM-DD
  type Iso8601DateTimeString = string; // YYYY-MM-DDTHH:MM:SSZ

  interface AccessTokenFn<T> {
    (accessToken: string): Promise<T>;
    (accessToken: string, cb: Callback<T>): void;
  }

  // OPTIONS /////////////////////////////////////////////////////////////////

  interface ClientRequestOptions {
    timeout: number;
  }

  interface ItemRequestOptions {
    account_ids?: Array<string>;
  }

  interface TransactionsRequestOptions extends ItemRequestOptions {
    count?: number;
    offset?: number;
  }

  interface InvestmentTransactionsRequestOptions extends ItemRequestOptions {
    count?: number;
    offset?: number;
  }

  interface GetAllTransactionsRequestOptions extends ItemRequestOptions {}

  interface AssetReportUser {
    client_user_id?: string | null;
    first_name?: string | null;
    middle_name?: string | null;
    last_name?: string | null;
    ssn?: string | null;
    phone_number?: string | null;
    email?: string | null;
  }

  interface AssetReportCreateOptions {
    client_report_id?: string | null;
    webhook?: string;
    user?: AssetReportUser;
  }

  type AssetReportRefreshOptions = AssetReportCreateOptions;

  // DATA TYPES //////////////////////////////////////////////////////////////

  interface AccountCommon {
    account_id: string;
    mask: string | null;
    name: string | null;
    official_name: string | null;
    subtype: string | null;
    type: string  | null;
  }

  interface Account extends AccountCommon {
    balances: {
      available: number | null;
      current: number | null;
      limit: number | null;
      iso_currency_code: string | null;
      official_currency_code: string | null;
    };
  }

  interface Security {
    security_id: string;
    cusip: string | null;
    sedol: string | null;
    isin: string | null;
    institution_security_id: string | null;
    institution_id: string | null;
    proxy_security_id: string | null;
    name: string | null;
    ticker_symbol: string | null;
    is_cash_equivalent: boolean | null;
    type: string | null;
    close_price: number | null;
    close_price_as_of: string | null;
    iso_currency_code: string | null;
    unofficial_currency_code: string | null;
  }

  interface AccountWithOwners extends Account {
    owners: Array<Identity>;
  }

  interface Category {
    type: string;
    hierarchy: Array<string>;
    category_id: string;
  }

  export class PlaidError extends Error {
    error_type: string;
    error_code: string;
    error_message: string;
    display_message: string | null;
    causes?: Array<Cause>;
  }

  // IPlaidError is a dupliate of PlaidError that is not an instance of Error.
  export interface IPlaidError {
    error_type: string;
    error_code: string;
    error_message: string;
    display_message: string | null;
    causes?: Array<Cause>;
  }

  interface Warning {
    warning_type: string;
    warning_code: string;
    cause: Cause;
  }

  interface Cause extends IPlaidError {
    item_id: string;
  }

  interface Item {
    available_products: Array<string>;
    billed_products: Array<string>;
    error: IPlaidError | null;
    institution_id: string;
    item_id: string;
    webhook: string;
  }

  interface Credential {
    name: string;
    label: string;
    type: 'text' | 'password';
  }

  interface Institution {
    credentials: Array<Credential>;
    has_mfa: boolean;
    institution_id: string;
    mfa: Array<string>;
    name: string;
    products: Array<string>;
    country_codes: Array<string>;
  }

  interface InstitutionWithDisplayData extends Institution {
    colors: Map<string, string>;
    logo: string | null;
    name_break: number | null;
    url_account_locked: string | null;
    url_account_setup: string | null;
    url_forgotten_password: string | null;
  }

  interface InstitutionWithInstitutionData extends Institution {
    logo: string;
    primary_color: string;
    url: string;
  }

  interface IncomeStream {
    monthly_income: number;
    confidence: number;
    days: number;
    name: string;
  }

  interface Income {
    income_streams: Array<IncomeStream>;
    last_year_income: number;
    last_year_income_before_tax: number;
    projected_yearly_income: number;
    projected_yearly_income_before_tax: number;
    max_number_of_overlapping_income_streams: number;
    number_of_income_streams: number;
  }

  interface Identity {
    addresses: Array<Address>;
    emails: Array<Email>;
    names: Array<string>;
    phone_numbers: Array<PhoneNumber>;
  }

  interface Address {
    data: AddressData;
    primary: boolean;
  }

  interface AddressData {
    city: string | null;
    region: string | null;
    postal_code: string | null;
    street: string | null;
    country: string | null;
  }

  interface Email {
    data: string;
    primary: boolean;
    type: string;
  }

  interface Holding {
    account_id: string;
    security_id: string;
    institution_value: number | null;
    institution_price: number | null;
    quantity: number | null;
    institution_price_as_of: string | null;
    cost_basis: number | null;
    iso_currency_code: string | null;
    unofficial_currency_code: string | null;
  }

  interface InvestmentTransaction {
    investment_transaction_id: string;
    account_id: string;
    security_id: string;
    cancel_transaction_id: string;
    date: Iso8601DateString;
    name: string | null;
    quantity: number | null;
    amount: number | null;
    price: number | null;
    fees: number | null;
    type: string | null;
    iso_currency_code: string | null;
    unofficial_currency_code: string | null;
  }

  interface PhoneNumber {
    data: string;
    primary: boolean;
    type: string;
  }

  interface TransactionLocation {
    address: string | null;
    city: string | null;
    lat: number | null;
    lon: number | null;
    region: string | null;
    store_number: string | null;
    postal_code: string | null;
    country: string | null;
  }

  interface TransactionPaymentMeta {
    by_order_of: string | null;
    payee: string | null;
    payer: string | null;
    payment_method: string | null;
    payment_processor: string | null;
    ppd_id: string | null;
{'fraction_non_alphanumeric': 0.1078783151326053, 'fraction_numerical': 0.0021060842433697348, 'mean_word_length': 2.964440321583179, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 47, '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': '4953629', 'n_tokens_mistral': 3936, 'n_tokens_neox': 3798, 'n_words': 1030}