// @ts-nocheck import { CoreModels } from 'tnp-core/websql'; import { RequestHandler } from 'express'; import { Response as ExpressResponse, Request as ExpressRequest } from 'express'; import { Models as ModelsNg2Rest } from 'ng2-rest/websql'; export declare namespace Models { type FrameworkMode = 'backend-frontend(tcp+udp)' | 'remote-backend(tcp+udp)' | 'backend-frontend(ipc-electron)' | 'backend-frontend(websql)'; enum ClassType { ENTITY = "ENTITY", CONTROLLER = "CONTROLLER", REPOSITORY = "REPOSITORY", PROVIDER = "PROVIDER", SUBSCRIBER = "SUBSCRIBER" } const ClassTypeKey: { [key in ClassType]: keyof ContextOptions; }; type MiddlewareType = [Function, any[]]; interface DatabaseConfig { /** * database name */ database?: string; /** * only for file base db: sqlite, sqljs */ location?: string; synchronize: boolean; dropSchema: boolean; type?: CoreModels.DatabaseType; autoSave: boolean; /** * for websql db mode */ useLocalForage?: boolean; logging: boolean; databasePort?: number; databaseHost?: string; databaseUsername?: string; databasePassword?: string; } type ISession = { secret?: string; saveUninitialized?: boolean; /** * max age of session */ cookieMaxAge?: number; secure?: boolean; resave?: boolean; }; type ContectionOptionsLogs = { http: boolean; realtime: boolean; framework: boolean; db: boolean; }; interface ContextOptions { contextName: string; host?: string; /** * frontend host only needed when we are using * withCredentials for axios * and session cookie */ frontendHost?: string; remoteHost?: string; useIpcWhenElectron?: boolean; contexts?: CONTEXTS; controllers?: CONTROLLERS; entities?: ENTITIES; repositories?: REPOSITORIES; providers?: PROVIDERS; subscribers?: SUBSCRIBERS; session?: ISession; productionMode?: boolean; abstract?: boolean; logs?: boolean | ContectionOptionsLogs; database?: boolean | DatabaseConfig; disabledRealtime?: boolean; https?: { key: string; cert: string; }; publicAssets?: { serverPath: string; locationOnDisk: string; }[]; middlewares?: MiddlewareType[]; /** * @deprecated * only for debugging purpose */ override?: { entities?: Function[]; controllers?: Function[]; repositories?: Function[]; providers?: Function[]; subscribers?: Function[]; }; } class DecoratorAbstractOpt { className: string; } class ParamConfig { paramName: string; paramType: CoreModels.ParamType; index: number; defaultType: any; expireInSeconds?: number; } class MethodConfig { methodName: string; /** * path is global in express app */ global?: boolean; /** * override default content type */ contentType?: any; /** * override default axiso response type */ responseType?: any; path: string; descriptor: PropertyDescriptor; type: CoreModels.HttpMethod; requestHandler: any; parameters: { [paramName: string]: ParamConfig; }; } class ControllerConfig extends DecoratorAbstractOpt { realtime?: boolean; path: string; uniqueKey?: string; methods: { [methodName: string]: MethodConfig; }; } class RuntimeControllerConfig extends ControllerConfig { calculatedPath?: string; browserTransformFn?: (entity: any) => any; } namespace Http { export import Rest = ModelsNg2Rest; type ContextENDPOINT = { target: Function; initFN: Function; }; type FormlyFromType = 'material' | 'bootstrap'; type ExpressContext = (req: ExpressRequest, res: ExpressResponse) => T; type SyncResponse = string | T; type ResponseFuncOpt = { limitSize?: (enties: Function | Function[], include: string[], exclude: string[]) => void; }; type SyncResponseFunc = (options?: ResponseFuncOpt) => SyncResponse; type MixResponse = SyncResponse | ExpressContext; interface ClientAction { received?: Rest.PromiseObservableMix>; } interface __Response { send?: MixResponse; } interface AsyncResponse { (req?: ExpressRequest, res?: ExpressResponse): Promise | SyncResponseFunc>; } type Response = (__Response | AsyncResponse) & ClientAction & __Response; class Errors { message: string; private code; toString: () => string; private constructor(); private static create; static entityNotFound(entity?: Function): Errors; static custom(message: string, code?: ModelsNg2Rest.HttpCode): Errors; } interface AuthCallBack { (methodReference: Function): RequestHandler; } } }