(schema: any)
| 25 | * @returns boolean |
| 26 | */ |
| 27 | export function isSchema(schema: any): schema is IPublicTypeNodeSchema { |
| 28 | if (isEmpty(schema)) { |
| 29 | return false; |
| 30 | } |
| 31 | // Leaf and Slot should be valid |
| 32 | if (schema.componentName === 'Leaf' || schema.componentName === 'Slot') { |
| 33 | return true; |
| 34 | } |
| 35 | if (Array.isArray(schema)) { |
| 36 | return schema.every((item) => isSchema(item)); |
| 37 | } |
| 38 | // check if props is valid |
| 39 | const isValidProps = (props: any) => { |
| 40 | if (!props) { |
| 41 | return false; |
| 42 | } |
| 43 | if (isJSExpression(props)) { |
| 44 | return true; |
| 45 | } |
| 46 | return (typeof schema.props === 'object' && !Array.isArray(props)); |
| 47 | }; |
| 48 | return !!(schema.componentName && isValidProps(schema.props)); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * check if schema passed in is a container type, including : Component Block Page |
no test coverage detected
searching dependent graphs…