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