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

Function getNodeSchemaById

packages/utils/src/schema.ts:81–99  ·  view source on GitHub ↗
(schema: IPublicTypeNodeSchema, nodeId: string)

Source from the content-addressed store, hash-verified

79}
80
81export function getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string): IPublicTypeNodeSchema | undefined {
82 let found: IPublicTypeNodeSchema | undefined;
83 if (schema.id === nodeId) {
84 return schema;
85 }
86 const { children, props } = schema;
87 // 查找 children
88 if (Array.isArray(children)) {
89 for (const child of children) {
90 found = getNodeSchemaById(child as IPublicTypeNodeSchema, nodeId);
91 if (found) return found;
92 }
93 }
94 if (isPlainObject(props)) {
95 // 查找 props,主要是 slot 类型
96 found = getNodeSchemaFromPropsById(props, nodeId);
97 if (found) return found;
98 }
99}
100
101function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNodeSchema | undefined {
102 let found: IPublicTypeNodeSchema | undefined;

Callers 3

schema.test.tsFile · 0.90
applyActivitiesFunction · 0.85

Calls 2

isPlainObjectFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…