重构了feature和aspect结构
This commit is contained in:
parent
4b6e1d6b58
commit
241787f49d
|
|
@ -3,11 +3,14 @@ export declare abstract class UniversalContext<ED extends EntityDict> implements
|
|||
rowStore: RowStore<ED, this>;
|
||||
uuid?: string;
|
||||
opRecords: OpRecord<ED>[];
|
||||
private scene?;
|
||||
events: {
|
||||
commit: Array<() => Promise<void>>;
|
||||
rollback: Array<() => Promise<void>>;
|
||||
};
|
||||
constructor(store: RowStore<ED, UniversalContext<ED>>);
|
||||
getScene(): string | undefined;
|
||||
setScene(scene?: string): void;
|
||||
private resetEvents;
|
||||
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
||||
begin(options?: TxnOption): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ class UniversalContext {
|
|||
rowStore;
|
||||
uuid;
|
||||
opRecords;
|
||||
scene;
|
||||
events;
|
||||
constructor(store) {
|
||||
this.rowStore = store;
|
||||
|
|
@ -14,6 +15,12 @@ class UniversalContext {
|
|||
rollback: [],
|
||||
};
|
||||
}
|
||||
getScene() {
|
||||
return this.scene;
|
||||
}
|
||||
setScene(scene) {
|
||||
this.scene = scene;
|
||||
}
|
||||
resetEvents() {
|
||||
this.events = {
|
||||
commit: [],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
import { Context } from ".";
|
||||
import { Context, RowStore } from ".";
|
||||
import { EntityDict } from "./Entity";
|
||||
export declare abstract class AppLoader<ED extends EntityDict, Cxt extends Context<ED>> {
|
||||
protected path: string;
|
||||
constructor(path: string);
|
||||
abstract goAspect(name: string, context: Cxt, params?: any): Promise<any>;
|
||||
abstract initialize(dropIfExists?: boolean): Promise<void>;
|
||||
abstract mount(): Promise<void>;
|
||||
abstract unmount(): Promise<void>;
|
||||
abstract getStore(): RowStore<ED, Cxt>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { EntityDict } from "./Entity";
|
||||
import { Context } from './Context';
|
||||
import { OpRecord } from "./Entity";
|
||||
export interface Aspect<ED extends EntityDict, Cxt extends Context<ED>> {
|
||||
(params: any, context: Cxt): Promise<any>;
|
||||
}
|
||||
export declare type AspectProxy<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>> = {
|
||||
[K in keyof AD]: (p: Parameters<AD[K]>[0], scene: string) => ReturnType<AD[K]>;
|
||||
};
|
||||
export interface AspectWrapper<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>> {
|
||||
exec: <T extends keyof AD>(name: T, params: Parameters<AD[T]>[0]) => Promise<{
|
||||
result: Awaited<ReturnType<AD[T]>>;
|
||||
opRecords: OpRecord<ED>[];
|
||||
}>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
;
|
||||
;
|
||||
|
|
|
|||
|
|
@ -9,4 +9,6 @@ export interface Context<ED extends EntityDict> {
|
|||
getCurrentTxnId(): string | undefined;
|
||||
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
||||
toString(): Promise<string>;
|
||||
getScene(): string | undefined;
|
||||
setScene(scene?: string): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ export abstract class UniversalContext<ED extends EntityDict> implements Context
|
|||
rowStore: RowStore<ED, this>;
|
||||
uuid?: string;
|
||||
opRecords: OpRecord<ED>[];
|
||||
private scene?: string;
|
||||
events: {
|
||||
commit: Array<() => Promise<void>>;
|
||||
rollback: Array<() => Promise<void>>;
|
||||
|
|
@ -17,6 +18,12 @@ export abstract class UniversalContext<ED extends EntityDict> implements Context
|
|||
rollback: [],
|
||||
};
|
||||
}
|
||||
getScene(): string | undefined {
|
||||
return this.scene;
|
||||
}
|
||||
setScene(scene?: string): void {
|
||||
this.scene = scene;
|
||||
}
|
||||
|
||||
private resetEvents() {
|
||||
this.events = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Context } from ".";
|
||||
import { Context, RowStore } from ".";
|
||||
import { EntityDict } from "./Entity";
|
||||
|
||||
export abstract class AppLoader<ED extends EntityDict, Cxt extends Context<ED>> {
|
||||
|
|
@ -8,4 +8,12 @@ export abstract class AppLoader<ED extends EntityDict, Cxt extends Context<ED>>
|
|||
}
|
||||
|
||||
abstract goAspect(name: string, context: Cxt, params?: any): Promise<any>;
|
||||
|
||||
abstract initialize(dropIfExists?: boolean): Promise<void>;
|
||||
|
||||
abstract mount(): Promise<void>;
|
||||
|
||||
abstract unmount(): Promise<void>;
|
||||
|
||||
abstract getStore(): RowStore<ED, Cxt>;
|
||||
}
|
||||
|
|
@ -1,10 +1,14 @@
|
|||
import { EntityDict } from "./Entity";
|
||||
import { Context } from './Context';
|
||||
import { OpRecord } from "./Entity";
|
||||
|
||||
export interface Aspect<ED extends EntityDict, Cxt extends Context<ED>>{
|
||||
(params: any, context: Cxt): Promise<any>;
|
||||
};
|
||||
|
||||
export type AspectProxy<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>> = {
|
||||
[K in keyof AD]: (p: Parameters<AD[K]>[0], scene: string) => ReturnType<AD[K]>;
|
||||
};
|
||||
export interface AspectWrapper<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>>{
|
||||
exec: <T extends keyof AD>(name: T, params: Parameters<AD[T]>[0]) => Promise<{
|
||||
result: Awaited<ReturnType<AD[T]>>;
|
||||
opRecords: OpRecord<ED>[];
|
||||
}>;
|
||||
};
|
||||
|
|
@ -11,5 +11,7 @@ export interface Context<ED extends EntityDict>{
|
|||
getCurrentTxnId(): string | undefined;
|
||||
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
||||
toString(): Promise<string>;
|
||||
getScene(): string | undefined;
|
||||
setScene(scene?: string): void;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue