@byted-apaas/server-sdk-node 1.1.21-beta.0 → 1.1.21-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kunlun/operator/impl/logic.js +21 -11
- package/package.json +1 -1
|
@@ -86,7 +86,6 @@ function buildCriterion(logic, objectApiName) {
|
|
|
86
86
|
let logs = [];
|
|
87
87
|
for (let left of Object.keys(exps)) {
|
|
88
88
|
let right = parseCondition(logic[left]);
|
|
89
|
-
// let right: { [index: string]: any } = logic[left];
|
|
90
89
|
let copy = right;
|
|
91
90
|
if (server_common_node_1.utils.isObject(right) && !(right instanceof Condition) && !isKunlunTypeOrSerializedObject(right)) {
|
|
92
91
|
for (let leftInner of Object.keys(right)) {
|
|
@@ -146,18 +145,29 @@ function buildCriterion(logic, objectApiName) {
|
|
|
146
145
|
exports.buildCriterion = buildCriterion;
|
|
147
146
|
// 避免引入组件库导致 app 使用的是组件库的 condition 是出现判断失败的问题。
|
|
148
147
|
function parseCondition(obj) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
if (!(obj instanceof Object)) {
|
|
149
|
+
return obj;
|
|
150
|
+
}
|
|
151
|
+
// 检查是否有 Condition 类定义的属性
|
|
152
|
+
const expectedKeys = ['left', 'right', 'op'];
|
|
153
|
+
const keys = Object.keys(obj);
|
|
154
|
+
// 检查属性数量是否匹配
|
|
155
|
+
if (keys.length !== expectedKeys.length) {
|
|
156
|
+
return obj;
|
|
157
|
+
}
|
|
158
|
+
// 检查属性是否都存在
|
|
159
|
+
for (const key of expectedKeys) {
|
|
160
|
+
if (!keys.includes(key)) {
|
|
161
|
+
return obj;
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
|
-
|
|
164
|
+
// 校验 op 属性的值是否在 operates 中
|
|
165
|
+
const opValue = obj.op;
|
|
166
|
+
if (!Object.values(operator_1.operates).includes(opValue)) {
|
|
167
|
+
return obj;
|
|
168
|
+
}
|
|
169
|
+
// 创建一个 Condition 的实例并比较属性
|
|
170
|
+
return new Condition(obj.left, obj.right, obj.op);
|
|
161
171
|
}
|
|
162
172
|
function buildExpression(objectApiName, left, right, index = 1) {
|
|
163
173
|
if (!(right instanceof Condition)) {
|