///
///
import { Request, Response } from "express";
import { Types } from "mongoose";
import { IPitmartContext } from "../system/interfaces/IPitmartContext";
import { EventEmitter } from "events";
import { IPRequest, IPResponse } from "../interfaces";
import { MessageError } from "../types/pitmart";
import { PMResponse } from "../types/pitmart";
import { PitmartError } from "../errors";
import { Logger } from "../logger/Logger";
import { PMSSendStatusOptions } from "../system/messages/messages";
/**
* EventType
*/
export declare class EventType {
static Running: string;
static Finished: string;
static Failed: string;
}
/**
* IPitmartBaseService
*/
export interface IPitmartBaseService {
name: String;
run(): void;
post(ctx: IPitmartContext): Promise;
put(ctx: IPitmartContext): Promise;
patch(ctx: IPitmartContext): Promise;
get(ctx: IPitmartContext, signal?: AbortSignal): Promise;
delete(ctx: IPitmartContext): Promise;
}
/**
* PitmartBaseAbstractService
*/
export declare abstract class PitmartBaseAbstractService extends EventEmitter implements IPitmartBaseService {
name: string;
protected sessionId: Types.ObjectId;
protected userId: any;
protected userName: any;
protected request: IPRequest;
protected response: IPResponse;
protected method: string;
protected path: string;
protected t1: Date;
protected Context: IPitmartContext;
private initialized;
private version;
private canceled;
email?: string;
appId?: Types.ObjectId;
appName?: string;
permissionLevel?: number;
roles: string[];
protected logger: Logger;
constructor(args: [req: Request, res: Response]);
private init;
/**
*
* @param method
* @param status
* @returns
*/
private getOptions;
/**
*
* @param process
*/
run(process?: Function, ...args: any[]): Promise;
/**
* execute
* @param f
* @param method
*/
private execute;
/**
*
* @param obj
*/
protected runEventHandler(obj: any): void;
/**
* Finish
* @param obj
*/
protected finishEventHandler(obj: any, status?: number): void;
/**
* Failed
* @param obj
* @param message
* @param status
*/
protected failEventHandler(obj: any): void;
/**
* post
* @param ctx
*/
post(ctx: IPitmartContext): Promise;
put(ctx: IPitmartContext): Promise;
/**
* patch
* @param ctx
*/
patch(ctx: IPitmartContext): Promise;
/**
* get
* @param ctx
* @param signal
*/
get(ctx: IPitmartContext, signal?: AbortSignal): Promise;
/**
* delete
* @param ctx
*/
delete(ctx: IPitmartContext): Promise;
/**
*
* @param message
* @returns
*/
private getStatus;
/**
* Handle errors
* We can handle generic app errors depending on the status code
* @param error
* @returns
*/
protected handleError(ctx: IPitmartContext, error: PitmartError | MessageError | string | any, options: PMSSendStatusOptions): PMResponse;
/**
* { sessionId: Types.ObjectId, method: string, path: string, status: number }
* @param result
* @param options
*/
protected Done(ctx: IPitmartContext, result: any, options: PMSSendStatusOptions): Promise;
/**
*
* @param ctx
* @param result
* @param options
*/
protected Fail(ctx: IPitmartContext, result: any, options: PMSSendStatusOptions): Promise;
/**
*
* @param msg
* @returns
*/
protected returnError(msg: PitmartError | MessageError | string | any): PMResponse;
/**
* sendFile
* path: string, filename: string
* @param ctx
* @param fileNamePath
*/
private sendFile;
/**
*
* @param ctx
* @param result
* @param options
*/
private sendStatus;
}
//# sourceMappingURL=PitmartBaseAbstractService.d.ts.map