MCPcopy Create free account
hub / github.com/ModelEngine-Group/app-platform / getConfigByKeys

Function getConfigByKeys

agent-flow/src/data/GraphOperator.js:44–66  ·  view source on GitHub ↗
(keys)

Source from the content-addressed store, hash-verified

42 };
43
44 const getConfigByKeys = (keys) => {
45 if (!Array.isArray(keys)) {
46 throw new Error('Expected keys to be an array');
47 }
48
49 if (keys.length === 0) {
50 return null;
51 }
52
53 const tmpKeys = [...keys];
54 const shapeId = tmpKeys.shift();
55 const shape = getShapeById(shapeId);
56 const inputParams = getInputParams(shape);
57 if (!inputParams) {
58 throw new Error('Expected inputParams exists');
59 }
60 let config = {type: DATA_TYPES.OBJECT, value: inputParams};
61 while (tmpKeys.length > 0 && config && config.value) {
62 const key = tmpKeys.shift();
63 config = config.value.find(v => v.name === key);
64 }
65 return config;
66 };
67
68 const getShapeById = (shapeId) => {
69 return shapes.find((shape) => shape.id === shapeId);

Callers 1

graphOperatorFunction · 0.70

Calls 4

isArrayMethod · 0.80
getShapeByIdFunction · 0.70
getInputParamsFunction · 0.70
findMethod · 0.65

Tested by

no test coverage detected