import type { BaseModel } from './model';

export interface BasicPageParams {
  page: number;
  pageSize: number;
}

export interface BasicFetchResult<T> {
  items: T[];
  total: number;
}

export interface RemoteData {
  key: string | number;
  data?: any;
}

export type PageQueryExtraKeyPrefix<T> = keyof T & string;
export type PageQueryExtraKeySuffix = 'in' | 'like' | 'likeLeft' | 'likeRight' | 'ge' | 'le' | 'precisest' | 'preciseed';
export type PageQueryExtraKey<T> = `${PageQueryExtraKeyPrefix<T>}_${PageQueryExtraKeySuffix}`;
// export type PageQueryExtra<T> = Partial<Record<PageQueryExtraKey<T>, any>>;
export type PageQueryExtra<T> = {
  [K in PageQueryExtraKey<T>]?: any;
};

export interface PageParams<T> {
  model: T;
  size: number;
  current: number;
  sort?: keyof T & string;
  order?: 'ascending' | 'descending';
  extra?: PageQueryExtra<T & BaseModel>;
}

export interface PageResult<T> {
  records: T[];
  // offset: number
  pages: string;
  current: string;
  total: string;
  size: string;
  orders: any[];
}
