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

Function getConfigByKeys

frontend/src/shared/utils/common.ts:510–532  ·  view source on GitHub ↗
(keys: string[])

Source from the content-addressed store, hash-verified

508 };
509
510 const getConfigByKeys = (keys: string[]) => {
511 if (!Array.isArray(keys)) {
512 throw new Error('Expected keys to be an array');
513 }
514
515 if (keys.length === 0) {
516 return null;
517 }
518
519 const tmpKeys = [...keys];
520 const shapeId = tmpKeys.shift();
521 const shape = getShapeById(shapeId);
522 const inputParams = getInputParams(shape);
523 if (!inputParams) {
524 throw new Error('Expected inputParams exists');
525 }
526 let config = {type: DATA_TYPES.OBJECT, value: inputParams};
527 while (tmpKeys.length > 0 && config && config.value) {
528 const key = tmpKeys.shift();
529 config = config.value.find(v => v.name === key);
530 }
531 return config;
532 };
533
534 const getShapeById = (shapeId: string) => {
535 return shapes.find((shape) => shape.id === shapeId);

Callers 1

createGraphOperatorFunction · 0.70

Calls 4

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

Tested by

no test coverage detected