68 lines
3.5 KiB
TypeScript
68 lines
3.5 KiB
TypeScript
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||
import { AppLoader as GeneralAppLoader, Trigger, EntityDict, Watcher, OpRecord, FreeTimer, OperationResult } from "oak-domain/lib/types";
|
||
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
|
||
import { IncomingHttpHeaders, IncomingMessage } from 'http';
|
||
import { Namespace } from 'socket.io';
|
||
import DataSubscriber from './cluster/DataSubscriber';
|
||
import Synchronizer from './Synchronizer';
|
||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||
import { InternalErrorHandler } from './types';
|
||
import { AppDbStore } from './DbStore';
|
||
export declare class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>> extends GeneralAppLoader<ED, Cxt> {
|
||
protected dbStore: AppDbStore<ED, Cxt>;
|
||
private aspectDict;
|
||
private externalDependencies;
|
||
protected dataSubscriber?: DataSubscriber<ED, Cxt>;
|
||
protected synchronizer?: Synchronizer<ED, Cxt>;
|
||
protected contextBuilder: (store: AppDbStore<ED, Cxt>) => Cxt;
|
||
private nsSocket?;
|
||
private watcherTimerId?;
|
||
private scheduledJobs;
|
||
private internalErrorHandlers;
|
||
regAllExceptionHandler(): void;
|
||
/**
|
||
* 注册一个内部错误处理器
|
||
* @param handler 内部错误处理器
|
||
*/
|
||
registerInternalErrorHandler(handler: InternalErrorHandler<ED, Cxt>): void;
|
||
/**
|
||
* 发布内部错误事件给注册的处理器
|
||
*/
|
||
private publishInternalError;
|
||
private requireSth;
|
||
protected makeContext(cxtStr?: string, headers?: IncomingHttpHeaders): Promise<Cxt>;
|
||
/**
|
||
* 后台启动的configuration,统一放在这里读取
|
||
*/
|
||
private getConfiguration;
|
||
constructor(path: string, nsSubscribe?: Namespace, nsSocket?: Namespace, nsServer?: Namespace);
|
||
protected registerTrigger(trigger: Trigger<ED, keyof ED, Cxt>): void;
|
||
protected initTriggers(): void;
|
||
protected initSocket(): void;
|
||
mount(initialize?: true): Promise<void>;
|
||
unmount(): Promise<void>;
|
||
execAspect(name: string, headers?: IncomingHttpHeaders, contextString?: string, params?: any): Promise<{
|
||
opRecords: OpRecord<ED>[];
|
||
result: any;
|
||
message?: string;
|
||
}>;
|
||
initialize(ifExists?: 'drop' | 'omit' | 'dropIfNotStatic'): Promise<void>;
|
||
getStore(): AppDbStore<ED, Cxt>;
|
||
getEndpoints(prefix: string): [string, "post" | "get" | "put" | "delete", string, (params: Record<string, string>, headers: IncomingHttpHeaders, req: IncomingMessage, body?: any) => Promise<{
|
||
headers?: Record<string, string | string[]>;
|
||
data: any;
|
||
statusCode?: number;
|
||
}>][];
|
||
protected operateInWatcher<T extends keyof ED>(entity: T, operation: ED[T]['Update'], context: Cxt, singleton?: true): Promise<OperationResult<ED>>;
|
||
protected selectInWatcher<T extends keyof ED>(entity: T, selection: ED[T]['Selection'], context: Cxt, forUpdate?: true, singleton?: true): Promise<Partial<ED[T]["Schema"]>[]>;
|
||
protected execWatcher(watcher: Watcher<ED, keyof ED, Cxt>): Promise<OperationResult<ED> | undefined>;
|
||
protected getCheckpointTs(): number;
|
||
protected checkpoint(): Promise<number>;
|
||
startWatchers(): void;
|
||
protected execFreeTimer(timer: FreeTimer<ED, Cxt>, context: Cxt): Promise<OperationResult<ED>> | undefined;
|
||
startTimers(): void;
|
||
execStartRoutines(): Promise<void>;
|
||
execStopRoutines(): Promise<void>;
|
||
execRoutine(routine: <Cxt extends AsyncContext<ED>>(context: Cxt) => Promise<void>): Promise<void>;
|
||
}
|