@dbml/core 6.2.0 → 6.3.0-alpha.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.2.0",
4
+ "version": "6.3.0-alpha.0",
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.0",
51
+ "@dbml/parse": "^6.3.0-alpha.0",
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": "10e5ddf632432ea6a1636504fd33a8c53f6108ed",
61
+ "gitHead": "9187af4387902a08a1721bffdcc94586b49340fe",
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,44 +2,36 @@ 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 };
5
+ import {
6
+ renameTable,
7
+ } from './transform';
8
+ export {
9
+ renameTable,
10
+ importer,
11
+ exporter,
12
+ ModelExporter,
13
+ Parser,
14
+ };
7
15
  export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel, } from './parse/error';
8
16
 
9
17
  // Export normalized types
10
- export type {
11
- NormalizedDatabase,
12
- NormalizedDatabaseIdMap,
13
- NormalizedModel,
14
- NormalizedSchema,
15
- NormalizedSchemaIdMap,
16
- NormalizedTable,
17
- NormalizedTableIdMap,
18
- NormalizedField,
19
- NormalizedFieldIdMap,
20
- NormalizedIndex,
21
- NormalizedIndexIdMap,
22
- NormalizedIndexColumn,
23
- NormalizedIndexColumnIdMap,
24
- NormalizedEnum,
25
- NormalizedEnumIdMap,
26
- NormalizedEnumValue,
27
- NormalizedEnumValueIdMap,
28
- NormalizedRef,
29
- NormalizedRefIdMap,
30
- NormalizedEndpoint,
31
- NormalizedEndpointIdMap,
32
- NormalizedTableGroup,
33
- NormalizedTableGroupIdMap,
34
- NormalizedNote,
35
- NormalizedNoteIdMap,
36
- NormalizedCheck,
37
- NormalizedCheckIdMap,
38
- NormalizedTablePartial,
39
- NormalizedTablePartialIdMap,
40
- Project,
41
- RawDatabase,
42
- TableRecord,
43
- NormalizedRecords,
44
- RawSchema,
45
- } from './model_structure';
18
+ export type * from './model_structure';
19
+ export { RecordValueType, RecordValue } from './model_structure/database';
20
+ export {
21
+ isIntegerType,
22
+ isFloatType,
23
+ isNumericType,
24
+ isBooleanType,
25
+ isStringType,
26
+ isBinaryType,
27
+ isDateTimeType,
28
+ isSerialType,
29
+ tryExtractBoolean,
30
+ tryExtractNumeric,
31
+ tryExtractInteger,
32
+ tryExtractString,
33
+ tryExtractDateTime,
34
+ tryExtractEnum,
35
+ addDoubleQuoteIfNeeded,
36
+ formatRecordValue,
37
+ } 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
 
@@ -33,8 +40,10 @@ export interface TableRecord extends RawTableRecord {
33
40
  id: number;
34
41
  }
35
42
 
36
- export interface NormalizedRecords {
37
- [_id: number]: TableRecord;
43
+ export type NormalizedRecord = TableRecord;
44
+
45
+ export interface NormalizedRecordIdMap {
46
+ [_id: number]: NormalizedRecord;
38
47
  }
39
48
 
40
49
  export interface RawDatabase {
@@ -307,5 +316,6 @@ export interface NormalizedModel {
307
316
  notes: NormalizedNoteIdMap;
308
317
  checks: NormalizedCheckIdMap;
309
318
  tablePartials: NormalizedTablePartialIdMap;
319
+ records: NormalizedRecordIdMap;
310
320
  }
311
321
  export default Database;
@@ -3,6 +3,16 @@ 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 'antlr4';
7
+
8
+ export interface RawEndpoint {
9
+ schemaName: string | null;
10
+ tableName: string;
11
+ fieldNames: string[];
12
+ relation: '1' | '*';
13
+ token: Token;
14
+ }
15
+
6
16
  declare class Endpoint extends Element {
7
17
  relation: any;
8
18
  schemaName: string;
@@ -83,7 +83,10 @@ export interface NormalizedField {
83
83
  pk: boolean;
84
84
  not_null: boolean;
85
85
  note: string | null;
86
- dbdefault: unknown;
86
+ dbdefault?: {
87
+ type: 'number' | 'string' | 'boolean' | 'expression';
88
+ value: number | string;
89
+ };
87
90
  increment: boolean;
88
91
  endpointIds: number[];
89
92
  tableId: number;
@@ -14,78 +14,17 @@ export { default as StickyNote } from './stickyNote';
14
14
  export { default as Check } from './check';
15
15
  export { default as TablePartial } from './tablePartial';
16
16
 
17
- // Export normalized individual types
18
- export type {
19
- NormalizedDatabase,
20
- NormalizedDatabaseIdMap,
21
- NormalizedModel,
22
- } from './database';
23
-
24
- export type {
25
- NormalizedSchema,
26
- NormalizedSchemaIdMap,
27
- } from './schema';
28
-
29
- export type {
30
- NormalizedTable,
31
- NormalizedTableIdMap,
32
- } from './table';
33
-
34
- export type {
35
- NormalizedField,
36
- NormalizedFieldIdMap,
37
- } from './field';
38
-
39
- export type {
40
- NormalizedIndex,
41
- NormalizedIndexIdMap,
42
- } from './indexes';
43
-
44
- export type {
45
- NormalizedIndexColumn,
46
- NormalizedIndexColumnIdMap,
47
- } from './indexColumn';
48
-
49
- export type {
50
- NormalizedEnum,
51
- NormalizedEnumIdMap,
52
- } from './enum';
53
-
54
- export type {
55
- NormalizedEnumValue,
56
- NormalizedEnumValueIdMap,
57
- } from './enumValue';
58
-
59
- export type {
60
- NormalizedRef,
61
- NormalizedRefIdMap,
62
- } from './ref';
63
-
64
- export type {
65
- NormalizedEndpoint,
66
- NormalizedEndpointIdMap,
67
- } from './endpoint';
68
-
69
- export type {
70
- NormalizedTableGroup,
71
- NormalizedTableGroupIdMap,
72
- } from './tableGroup';
73
-
74
- export type {
75
- NormalizedNote,
76
- NormalizedNoteIdMap,
77
- } from './stickyNote';
78
-
79
- export type {
80
- NormalizedTablePartial,
81
- NormalizedTablePartialIdMap,
82
- } from './tablePartial';
83
-
84
- export type {
85
- NormalizedCheck,
86
- NormalizedCheckIdMap,
87
- } from './check';
88
-
89
- // Export other types
90
- export type { Project, RawDatabase, TableRecord, NormalizedRecords } from './database';
91
- export type { RawSchema } from './schema';
17
+ export * from './database';
18
+ export * from './schema';
19
+ export * from './table';
20
+ export * from './field';
21
+ export * from './indexes';
22
+ export * from './indexColumn';
23
+ export * from './enum';
24
+ export * from './enumValue';
25
+ export * from './ref';
26
+ export * from './endpoint';
27
+ export * from './tableGroup';
28
+ export * from './stickyNote';
29
+ export * from './tablePartial';
30
+ export * from './check';
@@ -2,13 +2,15 @@ import Element, { Token } from './element';
2
2
  import Database from './database';
3
3
  import DbState from './dbState';
4
4
  import { NormalizedModel } from './database';
5
- interface RawStickyNote {
5
+
6
+ export interface RawStickyNote {
6
7
  name: string;
7
8
  content: string;
8
9
  database: Database;
9
10
  token: Token;
10
11
  headerColor: string;
11
12
  }
13
+
12
14
  declare class StickyNote extends Element {
13
15
  name: string;
14
16
  content: string;