@intuitionrobotics/db-api-generator
Version:
33 lines (32 loc) • 2.83 kB
TypeScript
import { BaseDB_ApiGenerator } from "./BaseDB_ApiGenerator";
import { ApiTypeBinder, QueryParams } from "@intuitionrobotics/thunderstorm";
import { ApiBinder_DBCreate, ApiBinder_DBDelete, ApiBinder_DBQuery, ApiBinder_DBUniuqe, ApiBinder_DBUpdate, GenericApiDef } from "..";
import { Clause_Where, DB_Object } from "@intuitionrobotics/firebase";
import { ApiResponse, ExpressRequest, ServerApi } from "@intuitionrobotics/thunderstorm/backend";
export declare function resolveUrlPart(dbModule: BaseDB_ApiGenerator<any>, pathPart?: string, pathSuffix?: string): string;
export declare abstract class GenericServerApi<DBType extends DB_Object, Binder extends ApiTypeBinder<string, R, B, P>, PostProcessor = never, R = Binder["response"], B = Binder["body"], P extends QueryParams | {} = Binder["queryParams"]> extends ServerApi<Binder> {
protected readonly dbModule: BaseDB_ApiGenerator<DBType>;
protected readonly postProcessors: PostProcessor[];
protected constructor(dbModule: BaseDB_ApiGenerator<DBType>, def: GenericApiDef, pathPart?: string);
addPostProcessor(processor: PostProcessor): void;
}
export declare class ServerApi_Create<DBType extends DB_Object> extends GenericServerApi<DBType, ApiBinder_DBCreate<DBType>, (item: DBType) => DBType> {
constructor(dbModule: BaseDB_ApiGenerator<DBType>, pathPart?: string);
protected process(request: ExpressRequest, response: ApiResponse, queryParams: {}, body: Omit<DBType, "_id">): Promise<DBType>;
}
export declare class ServerApi_Update<DBType extends DB_Object> extends GenericServerApi<DBType, ApiBinder_DBUpdate<DBType>> {
constructor(dbModule: BaseDB_ApiGenerator<DBType>, pathPart?: string);
protected process(request: ExpressRequest, response: ApiResponse, queryParams: {}, body: DBType): Promise<DBType>;
}
export declare class ServerApi_Unique<DBType extends DB_Object> extends GenericServerApi<DBType, ApiBinder_DBUniuqe<DBType>> {
constructor(dbModule: BaseDB_ApiGenerator<DBType>, pathPart?: string);
protected process(request: ExpressRequest, response: ApiResponse, queryParams: DB_Object, body: void): Promise<DBType>;
}
export declare class ServerApi_Query<DBType extends DB_Object> extends GenericServerApi<DBType, ApiBinder_DBQuery<DB_Object>, () => Promise<Partial<DBType>[]>> {
constructor(dbModule: BaseDB_ApiGenerator<DBType>, pathPart?: string);
protected process(request: ExpressRequest, response: ApiResponse, queryParams: {}, _body: Clause_Where<DBType>): Promise<DBType[]>;
}
export declare class ServerApi_Delete<DBType extends DB_Object> extends GenericServerApi<DBType, ApiBinder_DBDelete<DBType>> {
constructor(dbModule: BaseDB_ApiGenerator<DBType>, pathPart?: string);
protected process(request: ExpressRequest, response: ApiResponse, queryParams: DB_Object, body: void): Promise<DBType>;
}