增加了一些debug用的输出接口
This commit is contained in:
parent
67d64364cb
commit
81c462d5b2
|
|
@ -4,9 +4,15 @@ import { Checker, Context } from 'oak-domain/lib/types';
|
|||
import { TreeStore } from 'oak-memory-tree-store';
|
||||
export declare class CacheStore<ED extends EntityDict, Cxt extends Context<ED>> extends TreeStore<ED, Cxt> {
|
||||
private executor;
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString: string) => (store: CacheStore<ED, Cxt>) => Cxt);
|
||||
private getFullDataFn?;
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString: string) => (store: CacheStore<ED, Cxt>) => Cxt, getFullDataFn?: () => any);
|
||||
operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, params?: Object): Promise<OperationResult<ED>>;
|
||||
sync(opRecords: Array<OpRecord<ED>>, context: Cxt): Promise<void>;
|
||||
select<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, context: Cxt, params?: Object): Promise<import("oak-domain/lib/types").SelectionResult<ED[T]["Schema"], S["data"]>>;
|
||||
registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>): void;
|
||||
/**
|
||||
* 这个函数是在debug下用来获取debugStore的数据,release下不能使用
|
||||
* @returns
|
||||
*/
|
||||
getFullData(): any;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,11 +56,12 @@ var TriggerExecutor_1 = require("oak-domain/lib/store/TriggerExecutor");
|
|||
var oak_memory_tree_store_1 = require("oak-memory-tree-store");
|
||||
var CacheStore = /** @class */ (function (_super) {
|
||||
__extends(CacheStore, _super);
|
||||
function CacheStore(storageSchema, contextBuilder) {
|
||||
function CacheStore(storageSchema, contextBuilder, getFullDataFn) {
|
||||
var _this = _super.call(this, storageSchema) || this;
|
||||
_this.executor = new TriggerExecutor_1.TriggerExecutor(function (cxtStr) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/, contextBuilder(cxtStr)(this)];
|
||||
}); }); });
|
||||
_this.getFullDataFn = getFullDataFn;
|
||||
return _this;
|
||||
}
|
||||
CacheStore.prototype.operate = function (entity, operation, context, params) {
|
||||
|
|
@ -177,6 +178,13 @@ var CacheStore = /** @class */ (function (_super) {
|
|||
CacheStore.prototype.registerChecker = function (checker) {
|
||||
this.executor.registerChecker(checker);
|
||||
};
|
||||
/**
|
||||
* 这个函数是在debug下用来获取debugStore的数据,release下不能使用
|
||||
* @returns
|
||||
*/
|
||||
CacheStore.prototype.getFullData = function () {
|
||||
return this.getFullDataFn();
|
||||
};
|
||||
return CacheStore;
|
||||
}(oak_memory_tree_store_1.TreeStore));
|
||||
exports.CacheStore = CacheStore;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ export declare class Cache<ED extends EntityDict, Cxt extends Context<ED>, AD ex
|
|||
*/
|
||||
operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], params?: OperateParams): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
|
||||
get<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, params?: object): Promise<import("oak-domain/lib/types").SelectRowShape<ED[T]["Schema"], S["data"]>[]>;
|
||||
judgeRelation(entity: keyof ED, attr: string): string | 0 | 2 | string[] | 1;
|
||||
judgeRelation(entity: keyof ED, attr: string): string | 0 | 1 | 2 | string[];
|
||||
bindOnSync(callback: (opRecords: OpRecord<ED>[]) => Promise<void>): void;
|
||||
unbindOnSync(callback: (opRecords: OpRecord<ED>[]) => Promise<void>): void;
|
||||
getCachedData(): { [T in keyof ED]?: ED[T]["OpSchema"][] | undefined; };
|
||||
getFullData(): any;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,6 +182,12 @@ var Cache = /** @class */ (function (_super) {
|
|||
Cache.prototype.unbindOnSync = function (callback) {
|
||||
(0, lodash_1.pull)(this.syncEventsCallbacks, callback);
|
||||
};
|
||||
Cache.prototype.getCachedData = function () {
|
||||
return this.cacheStore.getCurrentData();
|
||||
};
|
||||
Cache.prototype.getFullData = function () {
|
||||
return this.cacheStore.getFullData();
|
||||
};
|
||||
__decorate([
|
||||
Feature_1.Action
|
||||
], Cache.prototype, "refresh", null);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ declare abstract class Node<ED extends EntityDict, T extends keyof ED, Cxt exten
|
|||
getBeforeExecute(): ((updateData: import("oak-domain/lib/types").DeduceUpdateOperationData<ED[T]["OpSchema"]>, action: ED[T]["Action"]) => Promise<void>) | undefined;
|
||||
getAfterExecute(): ((updateData: import("oak-domain/lib/types").DeduceUpdateOperationData<ED[T]["OpSchema"]>, action: ED[T]["Action"]) => Promise<void>) | undefined;
|
||||
destroy(): void;
|
||||
protected judgeRelation(attr: string): string | 0 | 2 | string[] | 1;
|
||||
protected judgeRelation(attr: string): string | 0 | 1 | 2 | string[];
|
||||
protected contains(filter: ED[T]['Selection']['filter'], conditionalFilter: ED[T]['Selection']['filter']): boolean;
|
||||
protected repel(filter1: ED[T]['Selection']['filter'], filter2: ED[T]['Selection']['filter']): boolean;
|
||||
}
|
||||
|
|
@ -169,5 +169,6 @@ export declare class RunningTree<ED extends EntityDict, Cxt extends Context<ED>,
|
|||
removeNode(parent: string, path: string): Promise<void>;
|
||||
resetUpdateData(path: string): void;
|
||||
toggleNode(path: string, nodeData: Record<string, any>, checked: boolean): void;
|
||||
getRoot(): Record<string, SingleNode<ED, keyof ED, Cxt, AD> | ListNode<ED, keyof ED, Cxt, AD>>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -2307,6 +2307,9 @@ var RunningTree = /** @class */ (function (_super) {
|
|||
updateData: nodeData,
|
||||
}, checked);
|
||||
};
|
||||
RunningTree.prototype.getRoot = function () {
|
||||
return this.root;
|
||||
};
|
||||
__decorate([
|
||||
Feature_1.Action
|
||||
], RunningTree.prototype, "setUpdateData", null);
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ export declare function initialize<ED extends EntityDict, Cxt extends Context<ED
|
|||
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
||||
}, actionDict?: ActionDictOfEntityDict<ED>): {
|
||||
features: BasicFeatures<ED, Cxt, {
|
||||
operate: typeof import("oak-common-aspect/lib/crud").operate;
|
||||
select: typeof import("oak-common-aspect/lib/crud").select;
|
||||
amap: typeof import("oak-common-aspect/lib/amap").amap;
|
||||
getTranslations: typeof import("oak-common-aspect/lib/locales").getTranslations;
|
||||
operate: typeof import("oak-common-aspect/src/crud").operate;
|
||||
select: typeof import("oak-common-aspect/src/crud").select;
|
||||
amap: typeof import("oak-common-aspect/src/amap").amap;
|
||||
getTranslations: typeof import("oak-common-aspect/src/locales").getTranslations;
|
||||
} & AD> & FD;
|
||||
context: Cxt;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ function initialize(storageSchema, createFeatures, contextBuilder, aspectDict, t
|
|||
}
|
||||
var aspectDict2 = Object.assign({}, oak_common_aspect_1.default, aspectDict);
|
||||
var debugStore = (0, debugStore_1.createDebugStore)(storageSchema, contextBuilder, triggers || [], checkers || [], watchers || [], initialData, actionDict);
|
||||
var cacheStore = new CacheStore_1.CacheStore(storageSchema, contextBuilder);
|
||||
var cacheStore = new CacheStore_1.CacheStore(storageSchema, contextBuilder, function () { return debugStore.getCurrentData(); });
|
||||
if (checkers) {
|
||||
checkers.forEach(function (checker) { return cacheStore.registerChecker(checker); });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ import { TreeStore } from 'oak-memory-tree-store';
|
|||
|
||||
export class CacheStore<ED extends EntityDict, Cxt extends Context<ED>> extends TreeStore<ED, Cxt> {
|
||||
private executor: TriggerExecutor<ED, Cxt>;
|
||||
private getFullDataFn?: () => any;
|
||||
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString: string) => (store: CacheStore<ED, Cxt>) => Cxt) {
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString: string) => (store: CacheStore<ED, Cxt>) => Cxt, getFullDataFn?: () => any) {
|
||||
super(storageSchema);
|
||||
this.executor = new TriggerExecutor(async (cxtStr) => contextBuilder(cxtStr)(this));
|
||||
this.getFullDataFn = getFullDataFn;
|
||||
}
|
||||
|
||||
async operate<T extends keyof ED>(
|
||||
|
|
@ -86,4 +88,12 @@ export class CacheStore<ED extends EntityDict, Cxt extends Context<ED>> extends
|
|||
registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>) {
|
||||
this.executor.registerChecker(checker);
|
||||
}
|
||||
|
||||
/**
|
||||
* 这个函数是在debug下用来获取debugStore的数据,release下不能使用
|
||||
* @returns
|
||||
*/
|
||||
getFullData() {
|
||||
return this.getFullDataFn!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,4 +91,12 @@ export class Cache<ED extends EntityDict, Cxt extends Context<ED>, AD extends Co
|
|||
unbindOnSync(callback: (opRecords: OpRecord<ED>[]) => Promise<void>) {
|
||||
pull(this.syncEventsCallbacks, callback);
|
||||
}
|
||||
|
||||
getCachedData() {
|
||||
return this.cacheStore.getCurrentData();
|
||||
}
|
||||
|
||||
getFullData() {
|
||||
return this.cacheStore.getFullData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1659,4 +1659,8 @@ export class RunningTree<ED extends EntityDict, Cxt extends Context<ED>, AD exte
|
|||
updateData: nodeData as any,
|
||||
}, checked);
|
||||
}
|
||||
|
||||
getRoot() {
|
||||
return this.root;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ export function initialize<
|
|||
actionDict
|
||||
);
|
||||
|
||||
const cacheStore = new CacheStore(storageSchema, contextBuilder);
|
||||
const cacheStore = new CacheStore(storageSchema, contextBuilder, () => debugStore.getCurrentData());
|
||||
if (checkers) {
|
||||
checkers.forEach((checker) => cacheStore.registerChecker(checker));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue