@overture-stack/lyric
Version:
Data Submission system
37 lines (36 loc) • 1.25 kB
TypeScript
import { Schema } from '@overture-stack/lectern-client';
import { type OrderType } from './types.js';
export interface SchemaParentNode {
schemaName: string;
fieldName: string;
}
export interface SchemaChildNode {
schemaName: string;
fieldName: string;
parent: SchemaParentNode;
}
interface SchemaDefinition extends Schema {
}
/**
* Returns all the children and it's relations by each schema on a Dictionary
* @param {SchemaDefinition[]} schemaDefinition
* @returns {Record<string, SchemaChildNode[]>}
*/
export declare const getDictionarySchemaRelations: (schemaDefinition: SchemaDefinition[]) => Record<string, SchemaChildNode[]>;
export interface TreeNode {
schemaName: string;
parentFieldName?: string;
fieldName?: string;
children?: TreeNode[];
parent?: TreeNode;
}
/**
* Function to generate the hierarchy tree of a dictionary schemas
* Order by `asc` should return children to parent relations
* Order by `desc` should return parent to chilren relations
* @param source The list of all schemas.
* @param order Order of the structed.
* @returns The hierarchical tree structure.
*/
export declare const generateHierarchy: (source: SchemaDefinition[], order: OrderType) => TreeNode[];
export {};