@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.
@@ -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
- // 判断当前对象是否是 Condition 类型的实例
150
- if (obj instanceof Object &&
151
- Object.keys(obj).length === 3 &&
152
- obj.hasOwnProperty('op') &&
153
- obj.hasOwnProperty('left') &&
154
- obj.hasOwnProperty('right')) {
155
- // 判断 op 是否是 Condition 支持的操作符
156
- if (Object.values(operator_1.operates).includes(obj['op'])) {
157
- return new Condition(obj.left, obj.right, obj.op);
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
- return obj;
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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byted-apaas/server-sdk-node",
3
- "version": "1.1.21-beta.0",
3
+ "version": "1.1.21-beta.2",
4
4
  "description": "aPaaS Server SDK",
5
5
  "author": "zhouwexin <zhouwexin@bytedance.com>",
6
6
  "homepage": "",