适配common-aspect的写法
This commit is contained in:
parent
32c19eb2c4
commit
6323526d25
|
|
@ -14,21 +14,19 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict, Cxt extends C
|
||||||
count?: number | undefined;
|
count?: number | undefined;
|
||||||
}>;
|
}>;
|
||||||
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], option?: OP): Promise<import("oak-domain/lib/types").OperationResult<ED> | import("oak-domain/lib/types").OperationResult<ED>[]>;
|
operate<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], option?: OP): Promise<import("oak-domain/lib/types").OperationResult<ED> | import("oak-domain/lib/types").OperationResult<ED>[]>;
|
||||||
|
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], option?: OP): Promise<number>;
|
||||||
private sync;
|
private sync;
|
||||||
/**
|
/**
|
||||||
* 前端缓存做operation只可能是测试权限,必然回滚
|
* 前端缓存做operation只可能是测试权限,必然回滚
|
||||||
* @param entity
|
* @param entity
|
||||||
* @param operation
|
* @param operation
|
||||||
* @param scene
|
|
||||||
* @param commit
|
|
||||||
* @param option
|
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
testOperation<T extends keyof ED>(entity: T, operation: ED[T]['Operation']): Promise<boolean>;
|
testOperation<T extends keyof ED>(entity: T, operation: ED[T]['Operation']): Promise<boolean>;
|
||||||
/**
|
/**
|
||||||
* 尝试在cache中重做一些动作,然后选择重做后的数据(为了实现modi)
|
* 尝试在cache中重做一些动作,然后选择重做后的数据(为了实现modi)
|
||||||
* @param entity
|
* @param entity
|
||||||
* @param projection
|
* @param selection
|
||||||
* @param opers
|
* @param opers
|
||||||
*/
|
*/
|
||||||
tryRedoOperations<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, opers: Array<{
|
tryRedoOperations<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, opers: Array<{
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,25 @@ var Cache = /** @class */ (function (_super) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Cache.prototype.count = function (entity, selection, option) {
|
||||||
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
|
var result;
|
||||||
|
return tslib_1.__generator(this, function (_a) {
|
||||||
|
switch (_a.label) {
|
||||||
|
case 0:
|
||||||
|
(0, selection_1.reinforceSelection)(this.cacheStore.getSchema(), entity, selection);
|
||||||
|
return [4 /*yield*/, this.getAspectWrapper().exec('count', {
|
||||||
|
entity: entity,
|
||||||
|
selection: selection,
|
||||||
|
option: option,
|
||||||
|
})];
|
||||||
|
case 1:
|
||||||
|
result = (_a.sent()).result;
|
||||||
|
return [2 /*return*/, result];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
Cache.prototype.sync = function (records) {
|
Cache.prototype.sync = function (records) {
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
var context, result;
|
var context, result;
|
||||||
|
|
@ -100,9 +119,6 @@ var Cache = /** @class */ (function (_super) {
|
||||||
* 前端缓存做operation只可能是测试权限,必然回滚
|
* 前端缓存做operation只可能是测试权限,必然回滚
|
||||||
* @param entity
|
* @param entity
|
||||||
* @param operation
|
* @param operation
|
||||||
* @param scene
|
|
||||||
* @param commit
|
|
||||||
* @param option
|
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
Cache.prototype.testOperation = function (entity, operation) {
|
Cache.prototype.testOperation = function (entity, operation) {
|
||||||
|
|
@ -142,7 +158,7 @@ var Cache = /** @class */ (function (_super) {
|
||||||
/**
|
/**
|
||||||
* 尝试在cache中重做一些动作,然后选择重做后的数据(为了实现modi)
|
* 尝试在cache中重做一些动作,然后选择重做后的数据(为了实现modi)
|
||||||
* @param entity
|
* @param entity
|
||||||
* @param projection
|
* @param selection
|
||||||
* @param opers
|
* @param opers
|
||||||
*/
|
*/
|
||||||
Cache.prototype.tryRedoOperations = function (entity, selection, opers) {
|
Cache.prototype.tryRedoOperations = function (entity, selection, opers) {
|
||||||
|
|
@ -258,6 +274,9 @@ var Cache = /** @class */ (function (_super) {
|
||||||
tslib_1.__decorate([
|
tslib_1.__decorate([
|
||||||
Feature_1.Action
|
Feature_1.Action
|
||||||
], Cache.prototype, "operate", null);
|
], Cache.prototype, "operate", null);
|
||||||
|
tslib_1.__decorate([
|
||||||
|
Feature_1.Action
|
||||||
|
], Cache.prototype, "count", null);
|
||||||
return Cache;
|
return Cache;
|
||||||
}(Feature_1.Feature));
|
}(Feature_1.Feature));
|
||||||
exports.Cache = Cache;
|
exports.Cache = Cache;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { EntityDict, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Context } from 'oak-domain/lib/types';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
export declare class EventBus<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
export declare class EventBus<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
private EventTable;
|
private EventTable;
|
||||||
sub(type: string, callback: Function): void;
|
sub(type: string, callback: Function): void;
|
||||||
unsub(type: string, callback: Function): void;
|
unsub(type: string, callback: Function): void;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { EntityDict, Context, AspectWrapper } from 'oak-domain/lib/types';
|
import { EntityDict, Context, AspectWrapper } from 'oak-domain/lib/types';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
export declare class LocalStorage<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
export declare class LocalStorage<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
keys: Record<string, boolean>;
|
keys: Record<string, boolean>;
|
||||||
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>);
|
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>);
|
||||||
setKey(key: string): void;
|
setKey(key: string): void;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { EntityDict, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Context } from 'oak-domain/lib/types';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
export declare class Locales<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
export declare class Locales<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
get(namespace: string | string[], locale: string, scene: string): Promise<{
|
get(namespace: string | string[], locale: string, scene: string): Promise<{
|
||||||
translations: Awaited<ReturnType<AD["getTranslations"]>>;
|
translations: Awaited<ReturnType<AD["getTranslations"]>>;
|
||||||
}>;
|
}>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { EntityDict, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Context } from 'oak-domain/lib/types';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
export declare class Location<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
export declare class Location<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
private latitude?;
|
private latitude?;
|
||||||
private longitude?;
|
private longitude?;
|
||||||
private lastTimestamp?;
|
private lastTimestamp?;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import { EntityDict, Context } from 'oak-domain/lib/types';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
import { MessageProps } from '../types/Message';
|
import { MessageProps } from '../types/Message';
|
||||||
export declare class Message<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
export declare class Message<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
private data?;
|
private data?;
|
||||||
setMessage(data: MessageProps): void;
|
setMessage(data: MessageProps): void;
|
||||||
consumeMessage(): MessageProps | undefined;
|
consumeMessage(): MessageProps | undefined;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import { EntityDict, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Context } from 'oak-domain/lib/types';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
import { NotificationProps } from '../types/Notification';
|
import { NotificationProps } from '../types/Notification';
|
||||||
export declare class Notification<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
export declare class Notification<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
private data?;
|
private data?;
|
||||||
setNotification(data: NotificationProps): void;
|
setNotification(data: NotificationProps): void;
|
||||||
consumeNotification(): NotificationProps | undefined;
|
consumeNotification(): NotificationProps | undefined;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ function initialize(storageSchema, createFeatures, frontendContextBuilder, backe
|
||||||
if (intersected.length > 0) {
|
if (intersected.length > 0) {
|
||||||
throw new Error("\u7528\u6237\u5B9A\u4E49\u7684aspect\u4E2D\u4E0D\u80FD\u548C\u7CFB\u7EDFaspect\u540C\u540D\uFF1A\u300C".concat(intersected.join(','), "\u300D"));
|
throw new Error("\u7528\u6237\u5B9A\u4E49\u7684aspect\u4E2D\u4E0D\u80FD\u548C\u7CFB\u7EDFaspect\u540C\u540D\uFF1A\u300C".concat(intersected.join(','), "\u300D"));
|
||||||
}
|
}
|
||||||
var aspectDict2 = Object.assign({}, oak_common_aspect_1.default, aspectDict);
|
var aspectDict2 = Object.assign({}, aspectDict, oak_common_aspect_1.default);
|
||||||
var checkers2 = (0, index_1.createDynamicCheckers)(storageSchema).concat(checkers || []);
|
var checkers2 = (0, index_1.createDynamicCheckers)(storageSchema).concat(checkers || []);
|
||||||
var triggers2 = (0, index_2.createDynamicTriggers)(storageSchema).concat(triggers || []);
|
var triggers2 = (0, index_2.createDynamicTriggers)(storageSchema).concat(triggers || []);
|
||||||
var debugStore = (0, debugStore_1.createDebugStore)(storageSchema, backendContextBuilder, triggers2, checkers2, watchers || [], initialData, actionDict);
|
var debugStore = (0, debugStore_1.createDebugStore)(storageSchema, backendContextBuilder, triggers2, checkers2, watchers || [], initialData, actionDict);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { EntityDict, AspectWrapper, Context } from 'oak-domain/lib/types';
|
import { EntityDict, AspectWrapper, Context } from 'oak-domain/lib/types';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
export declare abstract class Feature<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> {
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
export declare abstract class Feature<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> {
|
||||||
private aspectWrapper;
|
private aspectWrapper;
|
||||||
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>);
|
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>);
|
||||||
protected getAspectWrapper(): AspectWrapper<ED, Cxt, AD>;
|
protected getAspectWrapper(): AspectWrapper<ED, Cxt, AD>;
|
||||||
|
|
|
||||||
|
|
@ -66,5 +66,5 @@
|
||||||
"test": "ts-node ./test/test.ts",
|
"test": "ts-node ./test/test.ts",
|
||||||
"prepare": "rimraf node_modules/react & rimraf node_modules/react-dom & rimraf node_modules/react-router"
|
"prepare": "rimraf node_modules/react & rimraf node_modules/react-dom & rimraf node_modules/react-router"
|
||||||
},
|
},
|
||||||
"main": "lib/index"
|
"main": "src/index"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ import { EntityDict, Context } from 'oak-domain/lib/types';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
import { pull, unset } from 'oak-domain/lib/utils/lodash';
|
import { pull, unset } from 'oak-domain/lib/utils/lodash';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
|
||||||
export class EventBus<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
export class EventBus<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
private EventTable: Record<string, Function[]> = {};
|
private EventTable: Record<string, Function[]> = {};
|
||||||
|
|
||||||
sub(type: string, callback: Function) {
|
sub(type: string, callback: Function) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { AspectWrapper, Checker, Context, EntityDict, RowStore } from 'oak-domain/lib/types';
|
import { AspectWrapper, Checker, Context, EntityDict, Aspect } from 'oak-domain/lib/types';
|
||||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ import { unset } from 'oak-domain/lib/utils/lodash';
|
||||||
import { Feature } from '../types/Feature';
|
import { Feature } from '../types/Feature';
|
||||||
import { LOCAL_STORAGE_KEYS } from '../constant/constant';
|
import { LOCAL_STORAGE_KEYS } from '../constant/constant';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
|
||||||
export class LocalStorage<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
export class LocalStorage<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
keys: Record<string, boolean>;
|
keys: Record<string, boolean>;
|
||||||
|
|
||||||
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>) {
|
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { EntityDict, Aspect, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Aspect, Context } from 'oak-domain/lib/types';
|
||||||
import { Action, Feature } from '../types/Feature';
|
import { Action, Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
|
||||||
export class Locales<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
|
||||||
|
export class Locales<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature<ED, Cxt, AD> {
|
||||||
async get(namespace: string | string[], locale: string, scene: string) {
|
async get(namespace: string | string[], locale: string, scene: string) {
|
||||||
const { result } = await this.getAspectWrapper().exec('getTranslations',
|
const { result } = await this.getAspectWrapper().exec('getTranslations',
|
||||||
{ namespace, locale },
|
{ namespace, locale },
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { EntityDict, Aspect, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Aspect, Context } from 'oak-domain/lib/types';
|
||||||
import { Action, Feature } from '../types/Feature';
|
import { Action, Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
|
||||||
export class Location<
|
export class Location<
|
||||||
ED extends EntityDict,
|
ED extends EntityDict & BaseEntityDict,
|
||||||
Cxt extends Context<ED>,
|
Cxt extends Context<ED>,
|
||||||
AD extends CommonAspectDict<ED, Cxt>
|
AD extends CommonAspectDict<ED, Cxt>
|
||||||
> extends Feature<ED, Cxt, AD> {
|
> extends Feature<ED, Cxt, AD> {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,11 @@ import { EntityDict, Aspect, Context } from 'oak-domain/lib/types';
|
||||||
import { Action, Feature } from '../types/Feature';
|
import { Action, Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
import { MessageProps } from '../types/Message';
|
import { MessageProps } from '../types/Message';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
|
||||||
|
|
||||||
export class Message<
|
export class Message<
|
||||||
ED extends EntityDict,
|
ED extends EntityDict & BaseEntityDict,
|
||||||
Cxt extends Context<ED>,
|
Cxt extends Context<ED>,
|
||||||
AD extends CommonAspectDict<ED, Cxt>
|
AD extends CommonAspectDict<ED, Cxt>
|
||||||
> extends Feature<ED, Cxt, AD> {
|
> extends Feature<ED, Cxt, AD> {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import { EntityDict, Aspect, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Aspect, Context } from 'oak-domain/lib/types';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { Action, Feature } from '../types/Feature';
|
import { Action, Feature } from '../types/Feature';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
import { NotificationProps } from '../types/Notification';
|
import { NotificationProps } from '../types/Notification';
|
||||||
|
|
||||||
export class Notification<
|
export class Notification<
|
||||||
ED extends EntityDict,
|
ED extends EntityDict & BaseEntityDict,
|
||||||
Cxt extends Context<ED>,
|
Cxt extends Context<ED>,
|
||||||
AD extends CommonAspectDict<ED, Cxt>
|
AD extends CommonAspectDict<ED, Cxt>
|
||||||
> extends Feature<ED, Cxt, AD> {
|
> extends Feature<ED, Cxt, AD> {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ export function initialize<
|
||||||
`用户定义的aspect中不能和系统aspect同名:「${intersected.join(',')}」`
|
`用户定义的aspect中不能和系统aspect同名:「${intersected.join(',')}」`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const aspectDict2 = Object.assign({}, commonAspectDict, aspectDict);
|
const aspectDict2 = Object.assign({}, aspectDict, commonAspectDict);
|
||||||
const checkers2 = createDynamicCheckers<ED, Cxt>(storageSchema).concat(checkers || []);
|
const checkers2 = createDynamicCheckers<ED, Cxt>(storageSchema).concat(checkers || []);
|
||||||
const triggers2 = createDynamicTriggers<ED, Cxt>(storageSchema).concat(triggers || []);
|
const triggers2 = createDynamicTriggers<ED, Cxt>(storageSchema).concat(triggers || []);
|
||||||
const debugStore = createDebugStore(
|
const debugStore = createDebugStore(
|
||||||
|
|
@ -88,7 +88,7 @@ export function initialize<
|
||||||
() => clearMaterializedData(),
|
() => clearMaterializedData(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const wrapper: AspectWrapper<ED, Cxt, typeof aspectDict2> = {
|
const wrapper: AspectWrapper<ED, Cxt, CommonAspectDict<ED, Cxt> & AD> = {
|
||||||
exec: async (name, params) => {
|
exec: async (name, params) => {
|
||||||
const context = frontendContextBuilder(features)(cacheStore);
|
const context = frontendContextBuilder(features)(cacheStore);
|
||||||
const str = await context.toString();
|
const str = await context.toString();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import { pull } from 'oak-domain/lib/utils/lodash';
|
import { pull } from 'oak-domain/lib/utils/lodash';
|
||||||
import { EntityDict, Aspect, AspectWrapper, Context } from 'oak-domain/lib/types';
|
import { EntityDict, Aspect, AspectWrapper, Context } from 'oak-domain/lib/types';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
|
||||||
|
|
||||||
export abstract class Feature<ED extends EntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> {
|
|
||||||
|
export abstract class Feature<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>> {
|
||||||
private aspectWrapper: AspectWrapper<ED, Cxt, AD>;
|
private aspectWrapper: AspectWrapper<ED, Cxt, AD>;
|
||||||
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>) {
|
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>) {
|
||||||
this.aspectWrapper = aspectWrapper;
|
this.aspectWrapper = aspectWrapper;
|
||||||
|
|
|
||||||
32
test/test.ts
32
test/test.ts
|
|
@ -1 +1,31 @@
|
||||||
console.log(/^[a-z][a-z|A-Z]+$/.test('create-page'));
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
|
import commonAspectDict from 'oak-common-aspect';
|
||||||
|
import {
|
||||||
|
Aspect,
|
||||||
|
AspectWrapper,
|
||||||
|
Checker,
|
||||||
|
Trigger,
|
||||||
|
StorageSchema,
|
||||||
|
Context,
|
||||||
|
RowStore,
|
||||||
|
OakRowInconsistencyException,
|
||||||
|
Watcher,
|
||||||
|
} from 'oak-domain/lib/types';
|
||||||
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
|
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||||
|
|
||||||
|
function tt<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends CommonAspectDict<ED, Cxt>>(ad: AD) {
|
||||||
|
console.log(111);
|
||||||
|
}
|
||||||
|
|
||||||
|
function init<
|
||||||
|
ED extends EntityDict & BaseEntityDict,
|
||||||
|
Cxt extends Context<ED>,
|
||||||
|
AD extends Record<string, Aspect<ED, Cxt>>
|
||||||
|
> (aspectDict: AD) {
|
||||||
|
const ad2 = Object.assign({}, aspectDict, commonAspectDict);
|
||||||
|
tt(ad2);
|
||||||
|
}
|
||||||
|
|
||||||
|
init({});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue