在检查updateAt矩阵时,过滤掉一些内置属性

This commit is contained in:
Xu Chang 2024-09-25 12:38:56 +08:00
parent 14655b08ff
commit 8afa88af4f
4 changed files with 8 additions and 9 deletions

View File

@ -79,7 +79,7 @@ function createUniqueCheckers(schema) {
entity,
action: 'create',
type: 'logicalData',
priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低所有前置的checker/trigger将数据完整之后再在这里检测
priority: types_1.CHECKER_MAX_PRIORITY,
checker: (operation, context) => {
const { data } = operation;
if (data instanceof Array) {
@ -95,9 +95,9 @@ function createUniqueCheckers(schema) {
}
}, {
entity,
action: 'update', // 只检查update其它状态转换的action应该不会涉及unique约束的属性
action: 'update',
type: 'logicalData',
priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低所有前置的checker/trigger将数据完整之后再在这里检测
priority: types_1.CHECKER_MAX_PRIORITY,
checker: (operation, context) => {
const { data, filter: operationFilter } = operation;
if (data) {
@ -227,7 +227,7 @@ function createActionTransformerCheckers(actionDefDict) {
action: 'create',
type: 'logical',
entity,
priority: 10, // 优先级要高先于真正的data检查进行
priority: 10,
checker: (operation) => {
const { data } = operation;
if (data instanceof Array) {
@ -311,7 +311,7 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) {
const checkers = [];
for (const entity in attrUpdateMatrix) {
const matrix = attrUpdateMatrix[entity];
const updateAttrs = Object.keys(matrix);
const updateAttrs = [types_1.UpdateAtAttribute, types_1.TriggerDataAttribute, types_1.TriggerUuidAttribute].concat(Object.keys(matrix));
const { actions } = schema[entity];
const updateActions = actions.filter((a) => !action_1.readOnlyActions.concat(['create', 'remove']).includes(a));
/**

View File

@ -1,4 +1,3 @@
/// <reference types="node" />
/**
* assert打包体积过大
*/

View File

@ -60,7 +60,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) {
},
filter: relationFilter,
} // as ED['userRelation']['Selection']
}, // as ED[keyof ED]['Selection']['data'],
},
getData: (d) => {
return d.userRelation$entity;
},

View File

@ -1,4 +1,4 @@
import { ActionDefDict, Checker, EntityDict, StorageSchema, RowChecker, OakUniqueViolationException, CHECKER_MAX_PRIORITY, AttrUpdateMatrix, LogicalChecker, OakAttrCantUpdateException } from "../types";
import { ActionDefDict, Checker, EntityDict, StorageSchema, RowChecker, OakUniqueViolationException, CHECKER_MAX_PRIORITY, AttrUpdateMatrix, LogicalChecker, OakAttrCantUpdateException, UpdateAtAttribute, TriggerDataAttribute, TriggerUuidAttribute } from "../types";
import { SyncContext } from "./SyncRowStore";
import { AsyncContext } from "./AsyncRowStore";
import { pick, intersection, difference, omit } from '../utils/lodash';
@ -380,7 +380,7 @@ function createAttrUpdateCheckers<ED extends EntityDict & BaseEntityDict, Cxt ex
const checkers: Checker<ED, keyof ED, Cxt | FrontCxt>[] = [];
for (const entity in attrUpdateMatrix) {
const matrix = attrUpdateMatrix[entity]!;
const updateAttrs = Object.keys(matrix) as string[];
const updateAttrs = [UpdateAtAttribute, TriggerDataAttribute, TriggerUuidAttribute].concat(Object.keys(matrix));
const { actions } = schema[entity];
const updateActions = actions.filter(
(a) => !readOnlyActions.concat(['create', 'remove']).includes(a)