Updates
This commit is contained in:
@@ -1543,6 +1543,11 @@ export type DsqlCrudParam<
|
||||
dbConfig?: ConnectionConfig;
|
||||
};
|
||||
|
||||
export type DsqlCrudParamWhereClause = {
|
||||
clause: string;
|
||||
params?: string[];
|
||||
};
|
||||
|
||||
export type ErrorCallback = (title: string, error: Error, data?: any) => void;
|
||||
|
||||
export interface MariaDBUser {
|
||||
@@ -2840,3 +2845,109 @@ export type CrudQueryObject<
|
||||
userKey?: string;
|
||||
crudParams?: Omit<DsqlCrudParam<P>, "action" | "table">;
|
||||
};
|
||||
|
||||
export type APIPathsParams<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = {
|
||||
/**
|
||||
* Full URL with http and query
|
||||
* @example
|
||||
* https://example.com/api/table?searchQuery={}
|
||||
*/
|
||||
href: string;
|
||||
/**
|
||||
* Base path before the dynamic path of the url.
|
||||
* If no base path URL will be taken as the complete
|
||||
* dynamic url
|
||||
*/
|
||||
basePath?: string;
|
||||
auth?: () => Promise<boolean>;
|
||||
getMiddleware?: (params: {
|
||||
query: APIPathsQuery<T>;
|
||||
}) => Promise<APIPathsQuery<T>>;
|
||||
postMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
putMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
deleteMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
/** Runs For `POST`, `PUT`, and `DELETE` */
|
||||
crudMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
method: "GET" | "POST" | "PUT" | "DELETE";
|
||||
/**
|
||||
* Request Query
|
||||
*/
|
||||
query?: APIPathsQuery<T>;
|
||||
/**
|
||||
* Request Body
|
||||
*/
|
||||
body?: APIPathsBody<T>;
|
||||
allowedTables: APIPathsParamsAllowedTable[];
|
||||
};
|
||||
|
||||
export type APIPathsBody<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = APIPathsQuery & {
|
||||
data?: T;
|
||||
};
|
||||
|
||||
export type APIPathsQuery<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = {
|
||||
searchQuery?: DsqlCrudQueryObject<T>;
|
||||
crudParams?: Pick<
|
||||
DsqlCrudParam<T>,
|
||||
| "count"
|
||||
| "countOnly"
|
||||
| "targetId"
|
||||
| "targetField"
|
||||
| "targetValue"
|
||||
| "tableSchema"
|
||||
>;
|
||||
};
|
||||
|
||||
export type APIPathsParamsGetMiddleware<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = (params: { query: APIPathsQuery<T> }) => Promise<DsqlCrudQueryObject<T>>;
|
||||
|
||||
export type APIPathsParamsCrudMiddleware<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = (params: {
|
||||
body: APIPathsBody<T>;
|
||||
query: DsqlCrudQueryObject<T>;
|
||||
}) => Promise<APIPathsBody<T>>;
|
||||
|
||||
export type APIPathsParamsAllowedTable = {
|
||||
table: string;
|
||||
allowedFields?: (string | RegExp)[];
|
||||
disallowedFields?: (string | RegExp)[];
|
||||
};
|
||||
|
||||
export type APIPathsCrudParams<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = APIPathsParams<T> & {
|
||||
isAuthorized?: boolean;
|
||||
table: string;
|
||||
targetId?: string;
|
||||
allowedTable?: APIPathsParamsAllowedTable;
|
||||
url?: URL;
|
||||
};
|
||||
|
||||
export type APIPathsData<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = {
|
||||
table: string;
|
||||
targetId?: string;
|
||||
query?: APIPathsQuery<T>;
|
||||
url: URL;
|
||||
};
|
||||
|
||||
export type ClientCrudFetchParams<
|
||||
T extends { [k: string]: any } = { [k: string]: any },
|
||||
P = string
|
||||
> = {
|
||||
table: P;
|
||||
method?: "GET" | "POST" | "PUT" | "DELETE";
|
||||
query?: APIPathsQuery<T>;
|
||||
body?: APIPathsBody<T>;
|
||||
basePath?: string;
|
||||
targetId?: string | number | null;
|
||||
apiOrigin?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user