MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / compatibleLegaoSchema

Function compatibleLegaoSchema

packages/utils/src/schema.ts:20–79  ·  view source on GitHub ↗
(props: any)

Source from the content-addressed store, hash-verified

18 * @returns
19 */
20export function compatibleLegaoSchema(props: any): any {
21 if (!props) {
22 return props;
23 }
24
25 if (Array.isArray(props)) {
26 return props.map(k => compatibleLegaoSchema(k));
27 }
28
29 if (!isPlainObject(props)) {
30 return props;
31 }
32
33 if (isJSBlock(props)) {
34 if (props.value.componentName === 'Slot') {
35 return {
36 type: 'JSSlot',
37 title: (props.value.props as any)?.slotTitle,
38 name: (props.value.props as any)?.slotName,
39 value: compatibleLegaoSchema(props.value.children),
40 params: (props.value.props as any)?.slotParams,
41 };
42 } else {
43 return props.value;
44 }
45 }
46 if (isVariable(props)) {
47 return {
48 type: 'JSExpression',
49 value: props.variable,
50 mock: props.value,
51 };
52 }
53 if (isJsObject(props)) {
54 return {
55 type: 'JSExpression',
56 value: props.compiled,
57 extType: 'function',
58 };
59 }
60 if (isActionRef(props)) {
61 return {
62 type: 'JSExpression',
63 value: `${props.id}.bind(this)`,
64 };
65 }
66 const newProps: any = {};
67 Object.keys(props).forEach((key) => {
68 if (/^__slot__/.test(key) && props[key] === true) {
69 return;
70 }
71 // TODO: 先移除,目前没有业务使用
72 // if (key === 'dataSource') {
73 // newProps[key] = props[key];
74 // return;
75 // }
76 newProps[key] = compatibleLegaoSchema(props[key]);
77 });

Callers 1

schema.test.tsFile · 0.90

Calls 7

isPlainObjectFunction · 0.90
isJSBlockFunction · 0.90
isVariableFunction · 0.90
isJsObjectFunction · 0.85
isActionRefFunction · 0.85
mapMethod · 0.65
forEachMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…