MCPcopy
hub / github.com/alibaba/lowcode-engine / isSchema

Function isSchema

packages/renderer-core/src/utils/common.ts:27–49  ·  view source on GitHub ↗
(schema: any)

Source from the content-addressed store, hash-verified

25 * @returns boolean
26 */
27export 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

Callers 4

executeLifeCycleMethodFunction · 0.90
BaseRendererClass · 0.90
common.test.tsFile · 0.90
isFileSchemaFunction · 0.85

Calls 2

isValidPropsFunction · 0.85
everyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…