2024-06-06 11:05:54 +00:00
|
|
|
import { IListResponse_DTO } from "@shared/contexts";
|
2024-08-18 20:39:06 +00:00
|
|
|
import { AxiosHeaderValue } from "axios";
|
2024-06-06 11:05:54 +00:00
|
|
|
|
|
|
|
|
export interface IPaginationDataProviderParam {
|
|
|
|
|
pageIndex: number;
|
|
|
|
|
pageSize: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ISortItemDataProviderParam {
|
|
|
|
|
order: string;
|
|
|
|
|
field: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IFilterItemDataProviderParam {
|
|
|
|
|
field: string;
|
|
|
|
|
operator?: string;
|
|
|
|
|
value?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IGetListDataProviderParams {
|
|
|
|
|
resource: string;
|
|
|
|
|
quickSearchTerm?: string;
|
|
|
|
|
pagination?: IPaginationDataProviderParam;
|
|
|
|
|
sort?: ISortItemDataProviderParam[];
|
|
|
|
|
filters?: IFilterItemDataProviderParam[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IGetOneDataProviderParams {
|
|
|
|
|
resource: string;
|
|
|
|
|
id: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ISaveOneDataProviderParams<T> {
|
|
|
|
|
resource: string;
|
|
|
|
|
data: T;
|
|
|
|
|
id: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ICreateOneDataProviderParams<T> {
|
|
|
|
|
resource: string;
|
|
|
|
|
data: T;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IUpdateOneDataProviderParams<T> {
|
|
|
|
|
resource: string;
|
|
|
|
|
data: T;
|
|
|
|
|
id: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IRemoveOneDataProviderParams {
|
|
|
|
|
resource: string;
|
|
|
|
|
id: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-18 20:39:06 +00:00
|
|
|
export interface ICustomDataProviderParam {
|
|
|
|
|
url: string;
|
|
|
|
|
method: "get" | "delete" | "head" | "options" | "post" | "put" | "patch";
|
|
|
|
|
headers?: {
|
|
|
|
|
[key: string]: AxiosHeaderValue;
|
|
|
|
|
};
|
|
|
|
|
payload?: unknown;
|
|
|
|
|
}
|
2024-06-06 11:05:54 +00:00
|
|
|
|
|
|
|
|
export interface IDataSource {
|
|
|
|
|
name: () => string;
|
|
|
|
|
getList: <R>(params: IGetListDataProviderParams) => Promise<IListResponse_DTO<R>>;
|
|
|
|
|
getOne: <R>(params: IGetOneDataProviderParams) => Promise<R>;
|
|
|
|
|
//saveOne: <P, R>(params: ISaveOneDataProviderParams<P>) => Promise<R>;
|
|
|
|
|
createOne: <P, R>(params: ICreateOneDataProviderParams<P>) => Promise<R>;
|
|
|
|
|
updateOne: <P, R>(params: IUpdateOneDataProviderParams<P>) => Promise<R>;
|
|
|
|
|
removeOne: (params: IRemoveOneDataProviderParams) => Promise<void>;
|
|
|
|
|
|
2024-08-18 20:39:06 +00:00
|
|
|
custom: <R>(params: ICustomDataProviderParam) => Promise<R>;
|
2024-06-06 11:05:54 +00:00
|
|
|
|
2024-08-18 20:39:06 +00:00
|
|
|
getApiUrl: () => string;
|
2024-06-06 11:05:54 +00:00
|
|
|
|
|
|
|
|
//create: () => any;
|
|
|
|
|
//createMany: () => any;
|
|
|
|
|
//removeMany: () => any;
|
|
|
|
|
//getMany: () => any;
|
|
|
|
|
//update: () => any;
|
|
|
|
|
//updateMany: () => any;
|
|
|
|
|
//upload: () => any;
|
|
|
|
|
//custom: () => any;
|
|
|
|
|
//getApiUrl: () => string;
|
|
|
|
|
}
|