Skip to content

Commit

Permalink
Merge pull request #664 from holistics/core/update-type-definition-fo…
Browse files Browse the repository at this point in the history
…r-parser

Update type definition for Parser.js
  • Loading branch information
nguyenalter authored Dec 13, 2024
2 parents 7dcc73b + c5104d2 commit 28a39df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/dbml-core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import ModelExporter from './export/ModelExporter';
import Parser from './parse/Parser';
import importer from './import';
import exporter from './export';
export { importer, exporter, ModelExporter, Parser, };
export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel, } from './parse/error'
export { importer, exporter, ModelExporter, Parser };
export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel, } from './parse/error';
17 changes: 15 additions & 2 deletions packages/dbml-core/types/parse/Parser.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import { Compiler } from '@dbml/parse';
import Database, { RawDatabase } from '../model_structure/database';

declare type ParseFormat = 'json'
| 'mysql' | 'mysqlLegacy'
| 'postgres' | 'postgresLegacy'
| 'dbml' | 'dbmlv2'
| 'mssql'
| 'schemarb'
| 'snowflake';

declare class Parser {
public DBMLCompiler: Compiler;
constructor(dbmlCompiler?: Compiler);
static parseJSONToDatabase(rawDatabase: RawDatabase): Database;
static parseMySQLToJSON(str: string): RawDatabase;
static parseMySQLToJSONv2(str: string): RawDatabase;
static parsePostgresToJSON(str: string): RawDatabase;
static parsePostgresToJSONv2(str: string): RawDatabase;
static parseDBMLToJSON(str: string): RawDatabase;
static parseDBMLToJSONv2(str: string, dbmlCompiler: Compiler): RawDatabase;
static parseSchemaRbToJSON(str: string): RawDatabase;
static parseMSSQLToJSON(str: string): RawDatabase;
static parseSnowflakeToJSON(str: string): RawDatabase;
/**
* Should use parse() instance method instead of this static method whenever possible
*/
static parse(str: string, format: 'mysql' | 'postgres' | 'dbml' | 'dbmlv2' | 'schemarb' | 'mssql' | 'json'): Database;
static parse(str: string, format: ParseFormat): Database;
static parse(str: RawDatabase, format: 'json'): Database;
parse(str: string, format: 'mysql' | 'postgres' | 'dbml' | 'dbmlv2' | 'schemarb' | 'mssql' | 'json'): Database;
parse(str: string, format: ParseFormat): Database;
parse(str: RawDatabase, format: 'json'): Database;
}
export default Parser;

0 comments on commit 28a39df

Please sign in to comment.