modi相关的trigger的声明修正
This commit is contained in:
parent
35338986df
commit
958d2a6b60
|
|
@ -1,11 +1,26 @@
|
||||||
import { EntityDict } from '../base-app-domain';
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||||
import { UniversalContext } from '../store/UniversalContext';
|
import { UniversalContext } from '../store/UniversalContext';
|
||||||
import { OpSchema as Modi, Filter } from '../base-app-domain/Modi/Schema';
|
import { OpSchema as Modi } from '../base-app-domain/Modi/Schema';
|
||||||
import { Checker, Operation, StorageSchema, EntityDict as BaseEntityDict, Context } from '../types';
|
import { Checker, Operation, StorageSchema, EntityDict, Context } from '../types';
|
||||||
export declare function createOperationsFromModies(modies: Modi[]): Array<{
|
export declare function createOperationsFromModies(modies: Modi[]): Array<{
|
||||||
operation: Operation<string, Object, Object>;
|
operation: Operation<string, Object, Object>;
|
||||||
entity: string;
|
entity: string;
|
||||||
}>;
|
}>;
|
||||||
export declare function applyModis<ED extends EntityDict, Cxt extends UniversalContext<ED>>(filter: Filter, context: Cxt): Promise<import("../types").OperationResult<ED>>;
|
export declare function applyModis<ED extends EntityDict & BaseEntityDict, Cxt extends UniversalContext<ED>>(filter: ED['modi']['Selection']['filter'], context: Cxt): Promise<import("../types").OperationResult<ED>>;
|
||||||
export declare function abandonModis<ED extends EntityDict, Cxt extends UniversalContext<ED>>(filter: Filter, context: Cxt): Promise<import("../types").OperationResult<ED>>;
|
export declare function abandonModis<ED extends EntityDict & BaseEntityDict, Cxt extends UniversalContext<ED>>(filter: ED['modi']['Selection']['filter'], context: Cxt): Promise<import("../types").OperationResult<ED>>;
|
||||||
export declare function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>>(schema: StorageSchema<ED>): Checker<ED, keyof ED, Cxt>[];
|
export declare function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>>(schema: StorageSchema<ED>): Checker<ED, keyof ED, Cxt>[];
|
||||||
|
export declare function getModiSubSelection(): {
|
||||||
|
data: {
|
||||||
|
id: number;
|
||||||
|
targetEntity: number;
|
||||||
|
entity: number;
|
||||||
|
entityId: number;
|
||||||
|
action: number;
|
||||||
|
data: number;
|
||||||
|
filter: number;
|
||||||
|
iState: number;
|
||||||
|
};
|
||||||
|
filter: {
|
||||||
|
iState: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.createModiRelatedCheckers = exports.abandonModis = exports.applyModis = exports.createOperationsFromModies = void 0;
|
exports.getModiSubSelection = exports.createModiRelatedCheckers = exports.abandonModis = exports.applyModis = exports.createOperationsFromModies = void 0;
|
||||||
var tslib_1 = require("tslib");
|
var tslib_1 = require("tslib");
|
||||||
var types_1 = require("../types");
|
var types_1 = require("../types");
|
||||||
var action_1 = require("../actions/action");
|
var action_1 = require("../actions/action");
|
||||||
|
|
@ -141,3 +141,21 @@ function createModiRelatedCheckers(schema) {
|
||||||
return checkers;
|
return checkers;
|
||||||
}
|
}
|
||||||
exports.createModiRelatedCheckers = createModiRelatedCheckers;
|
exports.createModiRelatedCheckers = createModiRelatedCheckers;
|
||||||
|
function getModiSubSelection() {
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
targetEntity: 1,
|
||||||
|
entity: 1,
|
||||||
|
entityId: 1,
|
||||||
|
action: 1,
|
||||||
|
data: 1,
|
||||||
|
filter: 1,
|
||||||
|
iState: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
iState: 'active',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.getModiSubSelection = getModiSubSelection;
|
||||||
|
|
|
||||||
|
|
@ -129,4 +129,13 @@ export declare function isMathExpression<A>(expression: any): expression is Math
|
||||||
export declare function isExpression<A>(expression: any): expression is Expression<A>;
|
export declare function isExpression<A>(expression: any): expression is Expression<A>;
|
||||||
export declare function opMultipleParams(op: string): boolean;
|
export declare function opMultipleParams(op: string): boolean;
|
||||||
export declare function execOp(op: string, params: any, obscure?: boolean): ExpressionConstant;
|
export declare function execOp(op: string, params: any, obscure?: boolean): ExpressionConstant;
|
||||||
|
/**
|
||||||
|
* 检查一个表达式,并分析其涉及到的属性
|
||||||
|
* @param expression
|
||||||
|
* @returns {
|
||||||
|
* '#current': [当前结点涉及的属性]
|
||||||
|
* 'node-1': [node-1结点上涉及的属性]
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
export declare function getAttrRefInExpression(expression: Expression<any>): Record<string, string[]>;
|
||||||
export {};
|
export {};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.execOp = exports.opMultipleParams = exports.isExpression = exports.isMathExpression = exports.isCompareExpression = exports.isBoolExpression = exports.isLogicExpression = exports.isDateExpression = exports.isGeoExpression = void 0;
|
exports.getAttrRefInExpression = exports.execOp = exports.opMultipleParams = exports.isExpression = exports.isMathExpression = exports.isCompareExpression = exports.isBoolExpression = exports.isLogicExpression = exports.isDateExpression = exports.isGeoExpression = void 0;
|
||||||
var tslib_1 = require("tslib");
|
var tslib_1 = require("tslib");
|
||||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||||
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
||||||
|
|
@ -347,3 +347,41 @@ function execOp(op, params, obscure) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.execOp = execOp;
|
exports.execOp = execOp;
|
||||||
|
/**
|
||||||
|
* 检查一个表达式,并分析其涉及到的属性
|
||||||
|
* @param expression
|
||||||
|
* @returns {
|
||||||
|
* '#current': [当前结点涉及的属性]
|
||||||
|
* 'node-1': [node-1结点上涉及的属性]
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
function getAttrRefInExpression(expression) {
|
||||||
|
var _a;
|
||||||
|
var result = (_a = {},
|
||||||
|
_a['#current'] = [],
|
||||||
|
_a);
|
||||||
|
var check = function (node) {
|
||||||
|
var _a;
|
||||||
|
if (node['#attr']) {
|
||||||
|
result['#current'].push(node['#attr']);
|
||||||
|
}
|
||||||
|
else if (node['#refAttr']) {
|
||||||
|
if (result[node['#refId']]) {
|
||||||
|
result[node['#refId']].push(node['#refAttr']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Object.assign(result, (_a = {},
|
||||||
|
_a[node['#refId']] = [node['#refAttr']],
|
||||||
|
_a));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (var attr in expression) {
|
||||||
|
check(expression[attr]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
check(expression);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
exports.getAttrRefInExpression = getAttrRefInExpression;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import { EntityDict } from '../base-app-domain';
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||||
import { UniversalContext } from '../store/UniversalContext';
|
import { UniversalContext } from '../store/UniversalContext';
|
||||||
import { OpSchema as Modi, Filter } from '../base-app-domain/Modi/Schema';
|
import { OpSchema as Modi, Filter } from '../base-app-domain/Modi/Schema';
|
||||||
import { Checker, Operation, StorageSchema, UpdateChecker, EntityDict as BaseEntityDict, OakRowLockedException, Context } from '../types';
|
import { Checker, Operation, StorageSchema, UpdateChecker, EntityDict, OakRowLockedException, Context } from '../types';
|
||||||
import { appendOnlyActions } from '../actions/action';
|
import { appendOnlyActions } from '../actions/action';
|
||||||
import { difference } from '../utils/lodash';
|
import { difference } from '../utils/lodash';
|
||||||
|
|
||||||
export function createOperationsFromModies(modies: Modi[]): Array<{
|
export function createOperationsFromModies(modies: Modi[]): Array<{
|
||||||
operation: Operation <string, Object, Object>,
|
operation: Operation<string, Object, Object>,
|
||||||
entity: string,
|
entity: string,
|
||||||
}>{
|
}> {
|
||||||
return modies.map(
|
return modies.map(
|
||||||
(modi) => {
|
(modi) => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -24,7 +24,7 @@ export function createOperationsFromModies(modies: Modi[]): Array<{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function applyModis<ED extends EntityDict, Cxt extends UniversalContext<ED>>(filter: Filter, context: Cxt) {
|
export async function applyModis<ED extends EntityDict & BaseEntityDict, Cxt extends UniversalContext<ED>>(filter: ED['modi']['Selection']['filter'], context: Cxt) {
|
||||||
return context.rowStore.operate('modi', {
|
return context.rowStore.operate('modi', {
|
||||||
id: await generateNewId(),
|
id: await generateNewId(),
|
||||||
action: 'apply',
|
action: 'apply',
|
||||||
|
|
@ -44,7 +44,7 @@ export async function applyModis<ED extends EntityDict, Cxt extends UniversalCon
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function abandonModis<ED extends EntityDict, Cxt extends UniversalContext<ED>>(filter: Filter, context: Cxt) {
|
export async function abandonModis<ED extends EntityDict & BaseEntityDict, Cxt extends UniversalContext<ED>>(filter: ED['modi']['Selection']['filter'], context: Cxt) {
|
||||||
return context.rowStore.operate('modi', {
|
return context.rowStore.operate('modi', {
|
||||||
id: await generateNewId(),
|
id: await generateNewId(),
|
||||||
action: 'abadon',
|
action: 'abadon',
|
||||||
|
|
@ -65,7 +65,7 @@ export async function abandonModis<ED extends EntityDict, Cxt extends UniversalC
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>>(schema: StorageSchema<ED>) {
|
export function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>>(schema: StorageSchema<ED>) {
|
||||||
const checkers:Checker<ED, keyof ED, Cxt>[] = [];
|
const checkers: Checker<ED, keyof ED, Cxt>[] = [];
|
||||||
|
|
||||||
for (const entity in schema) {
|
for (const entity in schema) {
|
||||||
const { actionType, actions } = schema[entity];
|
const { actionType, actions } = schema[entity];
|
||||||
|
|
@ -78,7 +78,7 @@ export function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict
|
||||||
action: restActions as any,
|
action: restActions as any,
|
||||||
type: 'row',
|
type: 'row',
|
||||||
checker: async ({ operation }, context) => {
|
checker: async ({ operation }, context) => {
|
||||||
const { filter } = operation;
|
const { filter } = operation;
|
||||||
const filter2 = {
|
const filter2 = {
|
||||||
modi: {
|
modi: {
|
||||||
iState: 'active',
|
iState: 'active',
|
||||||
|
|
@ -111,4 +111,22 @@ export function createModiRelatedCheckers<ED extends EntityDict & BaseEntityDict
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkers;
|
return checkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getModiSubSelection() {
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
targetEntity: 1,
|
||||||
|
entity: 1,
|
||||||
|
entityId: 1,
|
||||||
|
action: 1,
|
||||||
|
data: 1,
|
||||||
|
filter: 1,
|
||||||
|
iState: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
iState: 'active',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -439,4 +439,41 @@ export function execOp(op: string, params: any, obscure?: boolean): ExpressionCo
|
||||||
assert(false, `不能识别的expression运算符:${op}`);
|
assert(false, `不能识别的expression运算符:${op}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查一个表达式,并分析其涉及到的属性
|
||||||
|
* @param expression
|
||||||
|
* @returns {
|
||||||
|
* '#current': [当前结点涉及的属性]
|
||||||
|
* 'node-1': [node-1结点上涉及的属性]
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
export function getAttrRefInExpression(expression: Expression<any>) {
|
||||||
|
const result: Record<string, string[]> = {
|
||||||
|
['#current']: [],
|
||||||
|
};
|
||||||
|
const check = (node: RefOrExpression<any>) => {
|
||||||
|
if ((node as any)['#attr']) {
|
||||||
|
result['#current'].push((node as any)['#attr']);
|
||||||
|
}
|
||||||
|
else if ((node as any)['#refAttr']) {
|
||||||
|
if (result[(node as any)['#refId']]) {
|
||||||
|
result[(node as any)['#refId']].push((node as any)['#refAttr']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Object.assign(result, {
|
||||||
|
[(node as any)['#refId']]: [(node as any)['#refAttr']],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (const attr in expression) {
|
||||||
|
check((expression as any)[attr]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
check(expression);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue