# MidFirst Standard Types

# MidlandResult

The MidlandResult type is our standard response type, it supports optional pagination and additional, informational messages

type MidlandResult = {
  pageInfo: PageInfo | null;
  results: any | any[];
  messages: string[] | null;
}

type PageInfo = {
  pageSize: number;
  pageNumber: number;
  numberOfPages: number;
  numberOfRecords: number;
}

# ErrorResponse type

The ErrorResponse type should be returned for all non 100-200 level status codes

type ErrorResponse = {
  code: string;
  title: string;
  description: string;

  errors: ErrorDetail[];
  eattsError: EATTSError;
  requestPath: string;
  requestQuery: string;
  requestId: string | null;
  traceId: string | null;
  
  // details field for debugging purposes, omitted in production environments
  innerDetails: DebugDetail[] | null;
  messages: string | null;
}

export type ErrorType = "field" | "general";

export type ErrorDetail = {
  name: string;
  type: ErrorType;
  value: string;
}

export type DebugDetail = {
    exceptionData: DataDict | null;
    exceptionMessage: string | null;
    exceptionType: string | null;
    source: string | null;
    stackTrace: string[] | null;
    data: DataDict | null;
    fullDescription: string | null;
    headers: string[] | null;
    innerDetails: DebugDetail[] | null;
};

export type DataDict = {
    [key: string]: unknown;
};

export type EATTSError = {
    environment: Environment;
    entryRef: number;
    occurrenceRef: number;
};

export type Environment = "DEV" | "UAT" | "PROD" | "STG"; // TO BE CONTINUED

# Tracked type

The Tracked, Created, and Updated types are used to track the created and/or modified state of many objects.

type Created = {
  createdDate: string; // ISO-8601 datetime string in UTC time
  createdBy: number | null;
};

type Updated = {
  updatedDate: string | null; // ISO-8601 datetime string in UTC time
  updatedBy: number | null;
};

type Tracked = UpdatedBy & CreatedBy;