Build a namespace tree by recursively walking a schema section object
(node: Record<string, unknown>)
| 1511 | |
| 1512 | /** Build a namespace tree by recursively walking a schema section object */ |
| 1513 | function buildNamespaceTree(node: Record<string, unknown>): NamespaceTree { |
| 1514 | const tree: NamespaceTree = { methods: new Map(), subspaces: new Map() }; |
| 1515 | for (const [key, value] of Object.entries(node)) { |
| 1516 | if (typeof value !== "object" || value === null) continue; |
| 1517 | const obj = value as Record<string, unknown>; |
| 1518 | if ("rpcMethod" in obj) { |
| 1519 | tree.methods.set(key, { |
| 1520 | rpcMethod: String(obj.rpcMethod), |
| 1521 | stability: String(obj.stability ?? "stable"), |
| 1522 | deprecated: obj.deprecated === true, |
| 1523 | params: (obj.params as JSONSchema7) ?? null, |
| 1524 | result: (obj.result as JSONSchema7) ?? null, |
| 1525 | }); |
| 1526 | } else { |
| 1527 | const child = buildNamespaceTree(obj); |
| 1528 | // Only add non-empty sub-trees |
| 1529 | if (child.methods.size > 0 || child.subspaces.size > 0) { |
| 1530 | tree.subspaces.set(key, child); |
| 1531 | } |
| 1532 | } |
| 1533 | } |
| 1534 | return tree; |
| 1535 | } |
| 1536 | |
| 1537 | /** |
| 1538 | * Derive the Java class name for an API namespace class. |
no test coverage detected
searching dependent graphs…