@pbip-tools/tmdl-parser
v0.2.0
Published
TMDL file parser and serializer for Power BI PBIP projects
Maintainers
Readme
@pbip-tools/tmdl-parser
Full TMDL (Tabular Model Definition Language) parser and serializer for Power BI PBIP projects.
Part of the pbip-tools monorepo.
Installation
npm install @pbip-tools/tmdl-parserUsage
import { parseTmdl, serializeTable } from '@pbip-tools/tmdl-parser';
// Parse a TMDL file
const result = parseTmdl(tmdlContent, 'table');
console.log(result.tables[0].measures);
// Serialize back to TMDL
const tmdl = serializeTable(table);Features
- All 3 DAX expression forms: inline, multi-line indent-based, backtick-delimited
- Database/model metadata, tables, columns, measures, partitions, hierarchies
- Calculation groups with precedence and format string expressions
- Relationships (GUID-named and descriptive-named, many-to-many, bi-directional)
- Expressions with M-code and
metaparameters - Cultures with
linguisticMetadataJSON blobs - RLS roles with
tablePermissionDAX filters - Forward compatibility — unknown syntax captured as
UnknownNode
API
Parser
parseTmdl(content, fileType)— Parse TMDL content into structured objectsdetectFileType(content)— Auto-detect the TMDL file type
Lexer
tokenize(content)— Tokenize TMDL content into tokensunquoteName(name)— Remove quotes from TMDL identifiers
Serializer
serializeDatabase(database)— Serialize database metadataserializeModel(model)— Serialize model metadataserializeTable(table)— Serialize a table with all childrenserializeRelationships(relationships)— Serialize relationshipsserializeExpressions(expressions)— Serialize expressionsserializeCulture(culture)— Serialize a cultureserializeRole(role)— Serialize an RLS role
License
MIT
