import { IndexSignature } from '../utils';

/* REQUEST_EXPORTS */

export interface Status {
  name: 'idle' | 'loading' | 'success' | 'failed';
}

export interface UpsertRequest<UM, UMR = null> {
  data: {
    attributes: UM;
    relationships?: UMR | null;
  };
}

export interface GetRelationshipsDataResponse {
  id: number;
  type: string;
}

export interface GetRelationshipsResponse {
  data: GetRelationshipsDataResponse[];
}

export interface GetDataResponse<M, MR = null> extends IndexSignature {
  type?: string | null;
  id?: number | null;
  attributes: M;
  relationships?: MR | null;
}

export interface GetAllResponse<M, MR = null, R = null> {
  data: GetDataResponse<M, MR>[];
  included?: GetDataResponse<R>[] | null;
}

export interface GetOneResponse<M, MR = null, R = null> {
  data: GetDataResponse<M, MR>;
  included?: GetDataResponse<R>[] | null;
}

export interface DeleteResponse {
  data: {
    attributes: {
      success: boolean;
      purged?: { id: string }[] | null;
    };
  };
}

export interface ErrorResponse {
  errors?: {
    status?: number | null;
    title?: string | null;
    detail?: string | null;
  } | null;
}
