(keys: string[])
| 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); |
no test coverage detected