(params: JSONObject | JSExpression, context: IDataSourceRuntimeContext)
| 81 | } |
| 82 | |
| 83 | export const buildJsonObj = (params: JSONObject | JSExpression, context: IDataSourceRuntimeContext) => { |
| 84 | if (isJSExpression(params)) { |
| 85 | return transformExpression(params.value, context) |
| 86 | } else if (isObject(params)) { |
| 87 | // 处理params内部为JSExpression的问题 |
| 88 | const newParams: Record<string, unknown> = {} |
| 89 | for (const [name, param] of Object.entries(params)) { |
| 90 | if (isJSExpression(param)) { |
| 91 | newParams[name] = transformExpression(param?.value, context) |
| 92 | } else if (isObject(param)) { |
| 93 | newParams[name] = buildJsonObj(param as JSONObject, context) |
| 94 | } else { |
| 95 | newParams[name] = param |
| 96 | } |
| 97 | } |
| 98 | return newParams |
| 99 | } |
| 100 | return params |
| 101 | } |
| 102 | |
| 103 | export const buildShouldFetch = (ds: InterpretDataSourceConfig, context: IDataSourceRuntimeContext) => { |
| 104 | if (!ds.options || !ds.shouldFetch) { |
no test coverage detected