@dbml/core 6.2.1 → 6.3.0-alpha.1

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.2.1",
4
+ "version": "6.3.0-alpha.1",
5
5
  "description": "> TODO: description",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -48,7 +48,7 @@
48
48
  "lint:fix": "eslint --fix ."
49
49
  },
50
50
  "dependencies": {
51
- "@dbml/parse": "^6.2.1",
51
+ "@dbml/parse": "^6.3.0-alpha.1",
52
52
  "antlr4": "^4.13.1",
53
53
  "lodash": "^4.17.15",
54
54
  "lodash-es": "^4.17.15",
@@ -58,7 +58,7 @@
58
58
  "devDependencies": {
59
59
  "bluebird": "^3.5.5"
60
60
  },
61
- "gitHead": "403ffd5a0d15bbf0f2b22db2c507659ce3f8fe35",
61
+ "gitHead": "58d2942cf407869367ed7f41a7cd4f24fc1317d3",
62
62
  "engines": {
63
63
  "node": ">=16"
64
64
  }
@@ -1,4 +1,5 @@
1
1
  import { ExportFormatOption } from './ModelExporter';
2
+ import { RecordValueType } from '../model_structure/database';
2
3
 
3
4
  declare function _export(str: string, format: ExportFormatOption): string;
4
5
  declare const _default: {
package/types/index.d.ts CHANGED
@@ -2,8 +2,34 @@ import ModelExporter from './export/ModelExporter';
2
2
  import Parser from './parse/Parser';
3
3
  import importer from './import';
4
4
  import exporter from './export';
5
- import { renameTable } from './transform';
6
- export { renameTable, importer, exporter, ModelExporter, Parser };
7
- export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel, } from './parse/error';
5
+ import {
6
+ renameTable,
7
+ } from './transform';
8
+ export {
9
+ renameTable,
10
+ importer,
11
+ exporter,
12
+ ModelExporter,
13
+ Parser,
14
+ };
15
+ export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel } from './parse/error';
8
16
 
9
17
  export * from './model_structure';
18
+ export {
19
+ isIntegerType,
20
+ isFloatType,
21
+ isNumericType,
22
+ isBooleanType,
23
+ isStringType,
24
+ isBinaryType,
25
+ isDateTimeType,
26
+ isSerialType,
27
+ tryExtractBoolean,
28
+ tryExtractNumeric,
29
+ tryExtractInteger,
30
+ tryExtractString,
31
+ tryExtractDateTime,
32
+ tryExtractEnum,
33
+ addDoubleQuoteIfNeeded,
34
+ formatRecordValue,
35
+ } from '@dbml/parse';
@@ -19,13 +19,20 @@ export interface Project {
19
19
  name: string;
20
20
  }
21
21
 
22
- interface RawTableRecord {
22
+ export type RecordValueType = 'string' | 'bool' | 'integer' | 'real' | 'date' | 'time' | 'datetime' | string;
23
+
24
+ export interface RecordValue {
25
+ value: any;
26
+ type: RecordValueType;
27
+ }
28
+
29
+ export interface RawTableRecord {
23
30
  schemaName: string | undefined;
24
31
  tableName: string;
25
32
  columns: string[];
26
33
  values: {
27
34
  value: any;
28
- type: string;
35
+ type: RecordValueType;
29
36
  }[][];
30
37
  }
31
38
 
@@ -1,8 +1,9 @@
1
- import Element, { Token } from './element';
1
+ import Element from './element';
2
2
  import Field from './field';
3
3
  import Ref from './ref';
4
4
  import DbState from './dbState';
5
5
  import { NormalizedModel } from './database';
6
+ import { Token } from './element';
6
7
 
7
8
  export interface RawEndpoint {
8
9
  schemaName: string | null;
@@ -6,7 +6,22 @@ import Enum from './enum';
6
6
  import Table from './table';
7
7
  import TablePartial from './tablePartial';
8
8
  import Check from './check';
9
- interface RawField {
9
+
10
+ export interface InlineRef {
11
+ schemaName: string | null;
12
+ tableName: string;
13
+ fieldNames: string[];
14
+ relation: '>' | '<' | '-' | '<>';
15
+ token: Token;
16
+ }
17
+
18
+ export interface ColumnType {
19
+ schemaName: string | null;
20
+ type_name: string;
21
+ args: string | null;
22
+ }
23
+
24
+ export interface RawField {
10
25
  name: string;
11
26
  type: any;
12
27
  unique: boolean;
@@ -14,14 +29,12 @@ interface RawField {
14
29
  token: Token;
15
30
  not_null: boolean;
16
31
  note: RawNote;
17
- dbdefault?: {
18
- type: 'number' | 'string' | 'boolean' | 'expression';
19
- value: number | string;
20
- };
32
+ dbdefault: any;
21
33
  increment: boolean;
22
34
  checks?: any[];
23
35
  table: Table;
24
36
  }
37
+
25
38
  declare class Field extends Element {
26
39
  name: string;
27
40
  type: any;
@@ -75,6 +88,7 @@ declare class Field extends Element {
75
88
  };
76
89
  normalize(model: NormalizedModel): void;
77
90
  }
91
+
78
92
  export interface NormalizedField {
79
93
  id: number;
80
94
  name: string;
@@ -86,7 +100,10 @@ export interface NormalizedField {
86
100
  pk: boolean;
87
101
  not_null: boolean;
88
102
  note: string | null;
89
- dbdefault: unknown;
103
+ dbdefault?: {
104
+ type: 'number' | 'string' | 'boolean' | 'expression';
105
+ value: number | string;
106
+ };
90
107
  increment: boolean;
91
108
  endpointIds: number[];
92
109
  tableId: number;