@dbml/core 6.3.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/core",
4
- "version": "6.3.0",
4
+ "version": "6.4.0",
5
5
  "description": "> TODO: description",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -19,7 +19,6 @@
19
19
  "lib",
20
20
  "types"
21
21
  ],
22
- "type": "module",
23
22
  "types": "./types/index.d.ts",
24
23
  "main": "./lib/index.cjs",
25
24
  "module": "./lib/index.mjs",
@@ -47,7 +46,7 @@
47
46
  "lint:fix": "eslint --fix ."
48
47
  },
49
48
  "dependencies": {
50
- "@dbml/parse": "^6.3.0",
49
+ "@dbml/parse": "^6.4.0",
51
50
  "antlr4": "^4.13.1",
52
51
  "lodash": "^4.17.15",
53
52
  "lodash-es": "^4.17.15",
@@ -58,7 +57,7 @@
58
57
  "devDependencies": {
59
58
  "bluebird": "^3.5.5"
60
59
  },
61
- "gitHead": "f9928b19cbf40509c32383b96b7569d8603c8eb0",
60
+ "gitHead": "e365a1165ce3610f2bc9563b9eefac206d2f5c35",
62
61
  "engines": {
63
62
  "node": ">=16"
64
63
  }
@@ -0,0 +1,30 @@
1
+ import type { NormalizedModel } from '../model_structure/database';
2
+ import type { NormalizedTable } from '../model_structure/table';
3
+ import type { NormalizedTableGroup } from '../model_structure/tableGroup';
4
+
5
+ export interface DbmlExporterOptions {
6
+ /** When false, TableData (Records) blocks are omitted from the output. Defaults to true. */
7
+ includeRecords: boolean;
8
+ }
9
+
10
+ declare class DbmlExporter {
11
+ static hasWhiteSpace(str: string): boolean;
12
+ static hasSquareBracket(str: string): boolean;
13
+ static isExpression(str: string): boolean;
14
+ static escapeNote(str: string | null): string;
15
+ static exportEnums(enumIds: number[], model: NormalizedModel): string;
16
+ static getFieldLines(tableId: number, model: NormalizedModel): string[];
17
+ static getIndexLines(tableId: number, model: NormalizedModel): string[];
18
+ static getCheckLines(tableId: number, model: NormalizedModel): string[];
19
+ static getTableSettings(table: NormalizedTable): string;
20
+ static exportTables(tableIds: number[], model: NormalizedModel): string;
21
+ static buildFieldName(fieldIds: number[], model: NormalizedModel): string;
22
+ static exportRefs(refIds: number[], model: NormalizedModel): string;
23
+ static getTableGroupSettings(tableGroup: NormalizedTableGroup): string;
24
+ static exportTableGroups(tableGroupIds: number[], model: NormalizedModel): string;
25
+ static exportStickyNotes(model: NormalizedModel): string;
26
+ static exportRecords(model: NormalizedModel): string;
27
+ static export(model: NormalizedModel, options: DbmlExporterOptions): string;
28
+ }
29
+
30
+ export default DbmlExporter;
@@ -0,0 +1,13 @@
1
+ import type Database from '../model_structure/database';
2
+ import type { NormalizedModel } from '../model_structure/database';
3
+
4
+ export interface JsonExporterOptions {
5
+ /** When false, the model is exported via its `.export()` method before stringifying. Defaults to true. */
6
+ isNormalized: boolean;
7
+ }
8
+
9
+ declare class JsonExporter {
10
+ static export(model: Database | NormalizedModel, options: JsonExporterOptions): string;
11
+ }
12
+
13
+ export default JsonExporter;
@@ -1,7 +1,13 @@
1
- import Database, { NormalizedModel } from '../model_structure/database';
1
+ import type Database from '../model_structure/database';
2
+ import type { NormalizedModel } from '../model_structure/database';
3
+ import type { ExportFormat, ExportOptions } from './index';
2
4
 
3
- export declare type ExportFormatOption = 'dbml' | 'mysql' | 'postgres' | 'json' | 'mssql' | 'oracle';
4
5
  declare class ModelExporter {
5
- static export(model: Database | NormalizedModel, format: ExportFormatOption, isNormalized?: boolean): string;
6
+ /**
7
+ * @deprecated Passing a boolean as the third argument is deprecated. Use `ExportOptions` instead.
8
+ */
9
+ static export(model: Database | NormalizedModel, format: ExportFormat, options: boolean): string;
10
+ static export(model: Database | NormalizedModel, format: ExportFormat, options?: ExportOptions): string;
6
11
  }
12
+
7
13
  export default ModelExporter;
@@ -1,7 +1,15 @@
1
- import { ExportFormatOption } from './ModelExporter';
2
- import { RecordValueType } from '../model_structure/database';
1
+ import type { DbmlExporterOptions } from './DbmlExporter';
2
+ import type { JsonExporterOptions } from './JsonExporter';
3
+
4
+ export type ExportFormat = 'dbml' | 'mysql' | 'postgres' | 'json' | 'mssql' | 'oracle';
5
+
6
+ export type ExportOptions =
7
+ Partial<DbmlExporterOptions> &
8
+ Partial<JsonExporterOptions>;
9
+
10
+ declare function _export(str: string, format: ExportFormat, options: boolean): string;
11
+ declare function _export(str: string, format: ExportFormat, options?: ExportOptions): string;
3
12
 
4
- declare function _export(str: string, format: ExportFormatOption): string;
5
13
  declare const _default: {
6
14
  export: typeof _export;
7
15
  };
@@ -1,11 +1,18 @@
1
- declare function _import(str: string, format: 'dbml' | 'mysql' | 'postgres' | 'json' | 'mssql' | 'postgresLegacy' | 'mssqlLegacy' | 'oracle'): string;
1
+ import type { DbmlExporterOptions } from '../export/DbmlExporter';
2
+
3
+ export type ImportFormat = 'dbml' | 'mysql' | 'postgres' | 'json' | 'mssql' | 'postgresLegacy' | 'mssqlLegacy' | 'schemarb' | 'snowflake' | 'oracle';
4
+
5
+ export type ImportOptions = Partial<DbmlExporterOptions>;
6
+
7
+ declare function _import(str: string, format: ImportFormat, options?: ImportOptions): string;
2
8
 
3
9
  /**
4
- * @param {any} schemaJson
10
+ * @param schemaJson
5
11
  * @description Type of schemaJson is `DatabaseSchema`.
6
12
  * The type definition of `DatabaseSchema` object can be found [here](https://github.com/holistics/dbml/blob/a4dcb110f1d79f5d95b0d3db4b919914439e039d/packages/dbml-connector/src/connectors/types.ts#L89)
7
13
  */
8
- declare function generateDbml(schemaJson: any): string;
14
+ declare function generateDbml(schemaJson: unknown): string;
15
+
9
16
  declare const _default: {
10
17
  import: typeof _import;
11
18
  generateDbml: typeof generateDbml;
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import ModelExporter, { ExportFormatOption } from './export/ModelExporter';
1
+ import ModelExporter from './export/ModelExporter';
2
2
  import Parser from './parse/Parser';
3
3
  import importer from './import';
4
4
  import exporter from './export';
@@ -10,9 +10,12 @@ export {
10
10
  importer,
11
11
  exporter,
12
12
  ModelExporter,
13
- ExportFormatOption,
14
13
  Parser,
15
14
  };
15
+ export type { ExportFormat, ExportOptions } from './export/index';
16
+ export type { DbmlExporterOptions } from './export/DbmlExporter';
17
+ export type { JsonExporterOptions } from './export/JsonExporter';
18
+ export type { ImportFormat, ImportOptions } from './import/index';
16
19
  export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel } from './parse/error';
17
20
 
18
21
  export * from './model_structure';