Skip to content

MetaData class

Represents a data model


The default constructor. ⊕ new MetaData(): MetaData



The list of value editors.

● editors: ValueEditor[]


The ID of the data mode.

● id: string


The name of the data model.

● name: string


The root entity.

● rootEntity: MetaEntity


The version of the data model.

● version: string



● mainEntity: MetaEntity | null = null



Add default value editors.

▸ addDefaultValueEditors(): void

Returns void


Add or update a value editor.

▸ addOrUpdateValueEditor(id: string,tag: EditorTag,resType: DataType): ValueEditor

  • id: string - The id.
  • tag: EditorTag - The tag.
  • resType: DataType - The result type.

Returns ValueEditor - The value editor.


Checks wether attribute contains such property.

▸ checkAttrProperty(attrId: string,propName: string): boolean

  • attrId: string - The attribute ID.
  • propName: string - The property name.

Returns boolean - true if the attribute contains the property, otherwise false.


Clears data model.

▸ clear(): void

Returns void


▸ createEntity(parent?: MetaEntity): MetaEntity

Returns MetaEntity


▸ createEntityAttr(parent?: MetaEntity): MetaEntityAttr

Returns MetaEntityAttr


▸ createValueEditor(): ValueEditor

Returns ValueEditor


Gets entity attribute by its ID. This function runs through all attributes inside specified model (it’s root entity and all its sub-entities).

▸ getAttributeById(attrId: string): MetaEntityAttr | null

  • attrId: string - The attribute ID.

Returns MetaEntityAttr | null - The attribute or null.


Gets the attribute text.

▸ getAttributeText(attr: MetaEntityAttr,format: string): string

Returns string - Formatted text.


Finds editor by its ID.

▸ getEditorById(editorId: string): ValueEditor | null

  • editorId: string - The editor ID.

Returns ValueEditor | null - The value editor or null.


Gets entities tree.

▸ getEntitiesTree(opts: any,filterFunc?: (ent: MetaEntity, attr: MetaEntityAttr) => boolean): any

  • opts: any - The options.
  • filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => boolean, Optional - The filter function. Takes two parameters, Entity and EntityAttr (second parameter will be null for entities), and returns boolean (true if the corresponding entity or attribute).

Returns any - The tree of the entities and their attributes according to options and the filter function


Gets entities tree due to filter.

▸ getEntitiesTreeWithFilter(filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => boolean): MetaEntity[]

  • filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => boolean - The filter function. Takes two parameters, Entity and EntityAttr (second parameter will be null for entities), and returns boolean (true if the corresponding entity or attribute).

Returns MetaEntity[] - The tree of the entities and their attributes according to the filter function


Gets entity attribute by its ID. This function runs through all attributes inside specified entity and all its sub-entities.

▸ getEntityAttrById(entity: MetaEntity,attrId: string): MetaEntityAttr | null

Returns MetaEntityAttr | null - The attribute or null.


Finds entity path by attribute

▸ getEntityPathByAttr(entity: MetaEntity,attrId: string,sep: string,root: boolean): string

  • entity: MetaEntity - The entity.
  • attrId: string - The attribute id.
  • sep: string - The separator.
  • root: boolean - The root option.

Returns string - The path.


Finds first attribute by filter.

▸ getFirstAttributeByFilter(filterFunc: (attr: MetaEntityAttr) => boolean): MetaEntityAttr

  • filterFunc: (attr: MetaEntityAttr) => boolean - The filter function. Takes EntityAttr object in parameter and returns boolean

Returns MetaEntityAttr


Finds full entity path by attribute

▸ getFullEntityPathByAttr(attrId: string,sep: string): string

  • attrId: string - The attribute id.
  • sep: string - The separator.

Returns string - The path.


Gets ID of the data model.

▸ getId(): string

Returns string - The ID.


Gets the main entity of model

▸ getMainEntity(): MetaEntity

Returns MetaEntity - The main entity.


Gets name of the data model.

▸ getName(): string

Returns string - The name.


Gets root entity of the data model.

▸ getRootEntity(): MetaEntity

Returns MetaEntity - The root entity.


Checks wether the data model is empty.

▸ isEmpty(): boolean

Returns boolean - true if the data model is empty, otherwise false.


Loads data model from its JSON representation object.

▸ loadFromData(data: MetaDataDTO): void

Returns void


Loads data model from JSON.

▸ loadFromJSON(stringJson: string): void

  • stringJson: string - The JSON string.

Returns void


Scans model’s entity tree and calls the callback functions for each attribute and entity.

▸ runThroughEntities(processAttribute?: (attr: MetaEntityAttr, opts: any) => void,processEntity?: (entity: MetaEntity, opts: any) => void): void

  • processAttribute: (attr: MetaEntityAttr, opts: any) => void, Optional - The callback function which is called for each attribute in model’s entity tree. The processed attribute is passed in the first function parameter.
  • processEntity: (entity: MetaEntity, opts: any) => void, Optional - The callback function which is called for each entity in tree. The processed entity is passed in the first function parameter.

Returns void


Sets data to data model.

▸ setData(model: MetaDataDTO | string): void

  • model: MetaDataDTO | string - Its JSON representation object or JSON string.

Returns void