MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / buildJsonObj

Function buildJsonObj

packages/plugin-datasource/src/utils.ts:83–101  ·  view source on GitHub ↗
(params: JSONObject | JSExpression, context: IDataSourceRuntimeContext)

Source from the content-addressed store, hash-verified

81}
82
83export 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
103export const buildShouldFetch = (ds: InterpretDataSourceConfig, context: IDataSourceRuntimeContext) => {
104 if (!ds.options || !ds.shouldFetch) {

Callers 1

buildOptionsFunction · 0.85

Calls 3

isJSExpressionFunction · 0.90
transformExpressionFunction · 0.85
isObjectFunction · 0.70

Tested by

no test coverage detected