import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo, OakException } from "../types"; import { EntityDict as BaseEntityDict } from '../base-app-domain'; import { IncomingHttpHeaders } from "http"; /** * 服务器端执行的异步环境的底层抽象 */ export declare abstract class AsyncContext implements Context { rowStore: AsyncRowStore; private uuid?; opRecords: OpRecord[]; private scene?; headers?: IncomingHttpHeaders; clusterInfo?: ClusterInfo; opResult: OperationResult; private message?; events: { commit: Array<(records: OpRecord[], cxtStr: string) => Promise>; rollback: Array<(records: OpRecord[], cxtStr: string) => Promise>; }; /** * 在返回结果前调用,对数据行进行一些预处理,比如将一些敏感的列隐藏 */ abstract refineOpRecords(): Promise; constructor(store: AsyncRowStore>); restartToExecute(routine: (context: this) => Promise): Promise; getHeader(key: string): string | string[] | undefined; getScene(): string | undefined; setScene(scene?: string): void; private resetEvents; on(event: 'commit' | 'rollback', callback: (records: OpRecord[], cxtStr: string) => Promise): void; saveOpRecord(entity: T, operation: ED[T]['Operation']): void; /** * 查询某operation所处理的row ids * 如果该operation还未执行,可能返回空数组(不知道实际关联的row id);但是在after的trigger中,返回是准确的ids值(此时如果是空数组说明没有有关row id) * @param id */ getRowIdsOfOperation(operation: ED[keyof ED]['Operation']): string[]; /** * 一个context中不应该有并发的事务,这里将事务串行化,使用的时候千万要注意不要自己等自己 * @param options */ begin(options?: TxnOption): Promise; commit(): Promise; rollback(): Promise; operate(entity: T, operation: ED[T]['Operation'], option: OP): Promise>; select(entity: T, selection: ED[T]['Selection'], option: OP): Promise[]>; aggregate(entity: T, aggregation: ED[T]['Aggregation'], option: OP): Promise>; count(entity: T, selection: Pick, option: OP): Promise; exec(script: string, txnId?: string): Promise; mergeMultipleResults(toBeMerged: OperationResult[]): OperationResult; getCurrentTxnId(): string | undefined; getSchema(): import("../types").StorageSchema; setMessage(message: string): void; getMessage(): string | undefined; abstract isRoot(): boolean; abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined; abstract setCurrentUserId(userId: string | undefined): void; abstract toString(): Promise; protected abstract getSerializedData(): Promise; abstract initialize(data?: any, later?: boolean): Promise; abstract allowUserUpdate(): boolean; abstract openRootMode(): () => void; abstract tryDeduceException(err: Error): Promise | void>; } export interface AsyncRowStore> extends RowStore { operate(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): Promise>; select(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise[]>; aggregate(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise>; count(entity: T, selection: Pick, context: Cxt, option: OP): Promise; begin(option?: TxnOption): Promise; commit(txnId: string): Promise; rollback(txnId: string): Promise; exec(script: string, txnId?: string): Promise; checkRelationAsync>(entity: T, operation: Omit, context: Cxt): Promise; }