UNPKG

mission.common

Version:

Request and Response dto object

95 lines (94 loc) 2.25 kB
import { ClientOperaters } from './client-operaters'; export interface PageContext { pageSize?: number; pageNumber?: number; totalRecords?: number; } export declare class Paginator { static get defaultPageSize(): any; static init(defaultPageSize: number): void; private static pageSize; private pc; constructor(pc?: PageContext); get limit(): number; get offset(): number; get totalPages(): number; firstPage(): PageContext; lastPage(): PageContext; nextPage(): PageContext; previousPage(): PageContext; } export declare enum SearchType { Contains = 1, StartsWith = 2 } export declare enum OrderBy { ASC = 1, DESC = 2 } export interface SortParam { key?: string; orderBy?: OrderBy; } export interface JPath { key: string; path: string; } export interface FilterParam<Tk> { key: Tk | ClientOperaters; value: FilterParam<Tk> | ClientOperaters | any; searchType?: SearchType; jPath?: JPath; } export interface IRequest { } export interface Include { key: string; attributes?: string[]; as?: string; required?: boolean; include?: Include[]; where?: { [key: string]: any; }; } export type FindAttributeOptions = Array<string | [string, string]> | { exclude: string[]; include?: Array<string | [string, string]>; } | { exclude?: string[]; include: Array<string | [string, string]>; }; export interface BaseRequest extends IRequest { id?: number; data?: any; attributes?: FindAttributeOptions; file?: any; include?: Include[]; } export interface ApiRequest<Tk> extends BaseRequest { pageContext?: PageContext; filters?: Array<FilterParam<Tk>>; sorters?: SortParam[]; } export interface FacadeRequest extends IRequest { key: string; route: string; request: ApiRequest<any>; } export interface IBaseDto { } export interface IResponse { } export interface ApiResponse<T extends IBaseDto> extends IResponse { pageContext?: PageContext; error?: Error; data?: T; } export interface FacadeResponse extends IResponse { [route: string]: ApiResponse<any>; } export interface KeyValuePair { key: string; value: KeyValuePair | string | any; }