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

Function getNodeSchemaFromPropsById

packages/utils/src/schema.ts:101–120  ·  view source on GitHub ↗
(props: any, nodeId: string)

Source from the content-addressed store, hash-verified

99}
100
101function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNodeSchema | undefined {
102 let found: IPublicTypeNodeSchema | undefined;
103 for (const [_key, value] of Object.entries(props)) {
104 if (isJSSlot(value)) {
105 // value 是数组类型 { type: 'JSSlot', value: IPublicTypeNodeSchema[] }
106 if (Array.isArray(value.value)) {
107 for (const child of value.value) {
108 found = getNodeSchemaById(child as IPublicTypeNodeSchema, nodeId);
109 if (found) return found;
110 }
111 }
112 // value 是对象类型 { type: 'JSSlot', value: IPublicTypeNodeSchema }
113 found = getNodeSchemaById(value.value as IPublicTypeNodeSchema, nodeId);
114 if (found) return found;
115 } else if (isPlainObject(value)) {
116 found = getNodeSchemaFromPropsById(value, nodeId);
117 if (found) return found;
118 }
119 }
120}
121
122/**
123 * TODO: not sure if this is used anywhere

Callers 1

getNodeSchemaByIdFunction · 0.85

Calls 3

isJSSlotFunction · 0.90
isPlainObjectFunction · 0.90
getNodeSchemaByIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…