MCPcopy Create free account
hub / github.com/apitable/apitable / getObjectOperandProperty

Function getObjectOperandProperty

packages/core/src/automation_manager/utils.ts:54–76  ·  view source on GitHub ↗
(objectOperand: any, key: string, propertySchema: any)

Source from the content-addressed store, hash-verified

52 * @param propertySchema
53 */
54export const getObjectOperandProperty = (objectOperand: any, key: string, propertySchema: any) => {
55 if (isObjectOperand(objectOperand)) {
56 const keyIndex = (objectOperand.value.operands as any[]).findIndex((operand, index) => {
57 return index % 2 === 0 && typeof operand === 'string' ? key === operand : isEqual(operand, key);
58 });
59 if (keyIndex > -1) {
60 return objectOperand.value.operands[keyIndex + 1];
61 }
62 return JSON.parse(JSON.stringify(EmptyNullOperand));
63 }
64 // when formData is empty, return default null value
65 if (objectOperand == null || Object.keys(objectOperand).length === 0) {
66 return JSON.parse(JSON.stringify(EmptyNullOperand));
67 }
68 switch (propertySchema.type) {
69 case 'object':
70 return JSON.parse(JSON.stringify(EmptyObjectOperand));
71 case 'array':
72 return JSON.parse(JSON.stringify(EmptyArrayOperand));
73 default:
74 return JSON.parse(JSON.stringify(EmptyNullOperand));
75 }
76};
77
78const getExpressionOperatorReturnType = (operator: string) => {
79 const OperatorReturnTypeMap = {

Callers 5

validateMagicFormFunction · 0.90
computeDefaultsFunction · 0.90
processDependenciesFunction · 0.90
ObjectFieldFunction · 0.90
isOperandNullValueFunction · 0.85

Calls 5

isObjectOperandFunction · 0.85
findIndexMethod · 0.80
stringifyMethod · 0.80
parseMethod · 0.65
keysMethod · 0.65

Tested by

no test coverage detected