@dbml/core 6.0.0 → 6.1.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.
@@ -138,7 +138,7 @@ var Field = /*#__PURE__*/function (_Element) {
138
138
  }, {
139
139
  key: "shallowExport",
140
140
  value: function shallowExport() {
141
- var _this$injectedPartial;
141
+ var _this$injectedPartial, _this$injectedPartial2;
142
142
  return {
143
143
  name: this.name,
144
144
  type: this.type,
@@ -148,7 +148,7 @@ var Field = /*#__PURE__*/function (_Element) {
148
148
  note: this.note,
149
149
  dbdefault: this.dbdefault,
150
150
  increment: this.increment,
151
- injectedPartialId: (_this$injectedPartial = this.injectedPartial) === null || _this$injectedPartial === void 0 ? void 0 : _this$injectedPartial.id,
151
+ injectedPartialId: (_this$injectedPartial = (_this$injectedPartial2 = this.injectedPartial) === null || _this$injectedPartial2 === void 0 ? void 0 : _this$injectedPartial2.id) !== null && _this$injectedPartial !== void 0 ? _this$injectedPartial : null,
152
152
  checkIds: this.checks.map(function (check) {
153
153
  return check.id;
154
154
  })
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.0.0",
4
+ "version": "6.1.0",
5
5
  "description": "> TODO: description",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -36,7 +36,7 @@
36
36
  "lint:fix": "eslint --fix ."
37
37
  },
38
38
  "dependencies": {
39
- "@dbml/parse": "^6.0.0",
39
+ "@dbml/parse": "^6.1.0",
40
40
  "antlr4": "^4.13.1",
41
41
  "lodash": "^4.17.15",
42
42
  "parsimmon": "^1.13.0",
@@ -63,7 +63,7 @@
63
63
  "typescript": "^5.9.3",
64
64
  "typescript-eslint": "^8.46.3"
65
65
  },
66
- "gitHead": "75a218687814d8b1c538b26908745e0d0ee8b35a",
66
+ "gitHead": "4897a3e1f59dd9eed89ee4a9f945b4e740e9bc0a",
67
67
  "engines": {
68
68
  "node": ">=16"
69
69
  }
package/types/index.d.ts CHANGED
@@ -5,3 +5,41 @@ import exporter from './export';
5
5
  import { renameTable } from './transform';
6
6
  export { renameTable, importer, exporter, ModelExporter, Parser };
7
7
  export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel, } from './parse/error';
8
+
9
+ // 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';
@@ -1,4 +1,4 @@
1
- import { NormalizedDatabase } from './database';
1
+ import { NormalizedModel } from './database';
2
2
  import Element, { Token } from './element';
3
3
  import Field from './field';
4
4
  import Table from './table';
@@ -35,18 +35,20 @@ declare class Check extends Element {
35
35
  name: string;
36
36
  expression: string;
37
37
  };
38
- normalize(model: NormalizedDatabase): void;
38
+ normalize(model: NormalizedModel): void;
39
39
  }
40
40
 
41
41
  export interface NormalizedCheck {
42
- [_id: number]: {
43
- id: number;
44
- name: string;
45
- expression: string;
46
- tableId: number;
47
- columnId: number | null;
48
- injectedPartialId: number | null;
49
- };
42
+ id: number;
43
+ name: string;
44
+ expression: string;
45
+ tableId: number;
46
+ columnId: number | null;
47
+ injectedPartialId: number | null;
48
+ }
49
+
50
+ export interface NormalizedCheckIdMap {
51
+ [_id: number]: NormalizedCheck;
50
52
  }
51
53
 
52
54
  export default Check;
@@ -1,18 +1,18 @@
1
- import Schema, { NormalizedSchema, RawSchema } from './schema';
2
- import Ref, { NormalizedRef } from './ref';
3
- import Enum, { NormalizedEnum } from './enum';
4
- import TableGroup, { NormalizedTableGroup } from './tableGroup';
5
- import Table, { NormalizedTable } from './table';
6
- import StickyNote, { NormalizedStickyNote } from './stickyNote';
1
+ import Schema, { NormalizedSchemaIdMap, RawSchema } from './schema';
2
+ import Ref, { NormalizedRefIdMap } from './ref';
3
+ import Enum, { NormalizedEnumIdMap } from './enum';
4
+ import TableGroup, { NormalizedTableGroupIdMap } from './tableGroup';
5
+ import Table, { NormalizedTableIdMap } from './table';
6
+ import StickyNote, { NormalizedNoteIdMap } from './stickyNote';
7
7
  import Element, { RawNote, Token } from './element';
8
8
  import DbState from './dbState';
9
- import { NormalizedEndpoint } from './endpoint';
10
- import { NormalizedEnumValue } from './enumValue';
11
- import { NormalizedField } from './field';
12
- import { NormalizedIndexColumn } from './indexColumn';
13
- import { NormalizedIndex } from './indexes';
14
- import { NormalizedCheck } from './check';
15
- import TablePartial, { NormalizedTablePartial } from './tablePartial';
9
+ import { NormalizedEndpointIdMap } from './endpoint';
10
+ import { NormalizedEnumValueIdMap } from './enumValue';
11
+ import { NormalizedFieldIdMap } from './field';
12
+ import { NormalizedIndexColumnIdMap } from './indexColumn';
13
+ import { NormalizedIndexIdMap } from './indexes';
14
+ import { NormalizedCheckIdMap } from './check';
15
+ import TablePartial, { NormalizedTablePartialIdMap } from './tablePartial';
16
16
  export interface Project {
17
17
  note: RawNote;
18
18
  database_type: string;
@@ -276,33 +276,36 @@ declare class Database extends Element {
276
276
  schemaIds: number[];
277
277
  noteIds: number[];
278
278
  };
279
- normalize(): NormalizedDatabase;
279
+ normalize(): NormalizedModel;
280
280
  }
281
281
  export interface NormalizedDatabase {
282
- database: {
283
- [_id: number]: {
284
- id: number;
285
- hasDefaultSchema: boolean;
286
- note: string;
287
- databaseType: string;
288
- name: string;
289
- schemaIds: number[];
290
- noteIds: number[];
291
- };
292
- };
293
- schemas: NormalizedSchema;
294
- notes: NormalizedStickyNote;
295
- refs: NormalizedRef;
296
- enums: NormalizedEnum;
297
- tableGroups: NormalizedTableGroup;
298
- tables: NormalizedTable;
299
- endpoints: NormalizedEndpoint;
300
- enumValues: NormalizedEnumValue;
301
- indexes: NormalizedIndex;
302
- indexColumns: NormalizedIndexColumn;
303
- checks: NormalizedCheck;
304
- fields: NormalizedField;
305
- records: NormalizedRecords;
306
- tablePartials: NormalizedTablePartial;
282
+ id: number;
283
+ hasDefaultSchema: boolean;
284
+ note: string | null;
285
+ databaseType: string;
286
+ name: string;
287
+ schemaIds: number[];
288
+ noteIds: number[];
289
+ }
290
+
291
+ export interface NormalizedDatabaseIdMap {
292
+ [_id: number]: NormalizedDatabase;
293
+ }
294
+
295
+ export interface NormalizedModel {
296
+ database: NormalizedDatabaseIdMap;
297
+ schemas: NormalizedSchemaIdMap;
298
+ endpoints: NormalizedEndpointIdMap;
299
+ refs: NormalizedRefIdMap;
300
+ fields: NormalizedFieldIdMap;
301
+ tables: NormalizedTableIdMap;
302
+ tableGroups: NormalizedTableGroupIdMap;
303
+ enums: NormalizedEnumIdMap;
304
+ enumValues: NormalizedEnumValueIdMap;
305
+ indexes: NormalizedIndexIdMap;
306
+ indexColumns: NormalizedIndexColumnIdMap;
307
+ notes: NormalizedNoteIdMap;
308
+ checks: NormalizedCheckIdMap;
309
+ tablePartials: NormalizedTablePartialIdMap;
307
310
  }
308
311
  export default Database;
@@ -2,7 +2,7 @@ import Element from './element';
2
2
  import Field from './field';
3
3
  import Ref from './ref';
4
4
  import DbState from './dbState';
5
- import { NormalizedDatabase } from './database';
5
+ import { NormalizedModel } from './database';
6
6
  declare class Endpoint extends Element {
7
7
  relation: any;
8
8
  schemaName: string;
@@ -39,17 +39,20 @@ declare class Endpoint extends Element {
39
39
  relation: any;
40
40
  };
41
41
  setFields(fieldNames: any, table: any): void;
42
- normalize(model: NormalizedDatabase): void;
42
+ normalize(model: NormalizedModel): void;
43
43
  }
44
44
  export interface NormalizedEndpoint {
45
- [_id: number]: {
46
- id: number;
47
- schemaName: string;
48
- tableName: string;
49
- fieldNames: string[];
50
- relation: any;
51
- refId: number;
52
- fieldIds: number[];
53
- };
45
+ id: number;
46
+ schemaName: string | null;
47
+ tableName: string;
48
+ fieldNames: string[];
49
+ fieldIds: number[];
50
+ relation: string;
51
+ refId: number;
52
+ }
53
+
54
+ export interface NormalizedEndpointIdMap {
55
+ [_id: number]: NormalizedEndpoint;
54
56
  }
57
+
55
58
  export default Endpoint;
@@ -1,4 +1,4 @@
1
- import { NormalizedDatabase } from './database';
1
+ import { NormalizedModel } from './database';
2
2
  import DbState from './dbState';
3
3
  import Element, { Token, RawNote } from './element';
4
4
  import EnumValue from './enumValue';
@@ -53,16 +53,19 @@ declare class Enum extends Element {
53
53
  name: string;
54
54
  note: string;
55
55
  };
56
- normalize(model: NormalizedDatabase): void;
56
+ normalize(model: NormalizedModel): void;
57
57
  }
58
58
  export interface NormalizedEnum {
59
- [_id: number]: {
60
- id: number;
61
- name: string;
62
- note: string;
63
- valueIds: number[];
64
- fieldIds: number[];
65
- schemaId: number;
66
- };
59
+ id: number;
60
+ name: string;
61
+ note: string | null;
62
+ valueIds: number[];
63
+ fieldIds: number[];
64
+ schemaId: number;
65
+ }
66
+
67
+ export interface NormalizedEnumIdMap {
68
+ [_id: number]: NormalizedEnum;
67
69
  }
70
+
68
71
  export default Enum;
@@ -1,4 +1,4 @@
1
- import { NormalizedDatabase } from './database';
1
+ import { NormalizedModel } from './database';
2
2
  import DbState from './dbState';
3
3
  import Element, { Token, RawNote } from './element';
4
4
  import Enum from './enum';
@@ -27,14 +27,17 @@ declare class EnumValue extends Element {
27
27
  name: string;
28
28
  note: string;
29
29
  };
30
- normalize(model: NormalizedDatabase): void;
30
+ normalize(model: NormalizedModel): void;
31
31
  }
32
32
  export interface NormalizedEnumValue {
33
- [_id: number]: {
34
- id: number;
35
- name: string;
36
- note: string;
37
- enumId: number;
38
- };
33
+ id: number;
34
+ name: string;
35
+ note: string | null;
36
+ enumId: number;
37
+ }
38
+
39
+ export interface NormalizedEnumValueIdMap {
40
+ [_id: number]: NormalizedEnumValue;
39
41
  }
42
+
40
43
  export default EnumValue;
@@ -1,4 +1,4 @@
1
- import { NormalizedDatabase } from './database';
1
+ import { NormalizedModel } from './database';
2
2
  import DbState from './dbState';
3
3
  import Element, { Token, RawNote } from './element';
4
4
  import Endpoint from './endpoint';
@@ -70,24 +70,30 @@ declare class Field extends Element {
70
70
  injectedPartialId?: number;
71
71
  checkIds: number[];
72
72
  };
73
- normalize(model: NormalizedDatabase): void;
73
+ normalize(model: NormalizedModel): void;
74
74
  }
75
75
  export interface NormalizedField {
76
- [_id: number]: {
77
- id: number;
78
- name: string;
79
- type: any;
80
- unique: boolean;
81
- pk: boolean;
82
- not_null: boolean;
83
- note: string;
84
- dbdefault: any;
85
- increment: boolean;
86
- tableId: number;
87
- endpointIds: number[];
88
- enumId: number;
89
- injectedPartialId?: number;
90
- checkIds: number[];
76
+ id: number;
77
+ name: string;
78
+ type: {
79
+ schemaName: string | null;
80
+ type_name: string;
91
81
  };
82
+ unique: boolean;
83
+ pk: boolean;
84
+ not_null: boolean;
85
+ note: string | null;
86
+ dbdefault: unknown;
87
+ increment: boolean;
88
+ endpointIds: number[];
89
+ tableId: number;
90
+ enumId: number | null;
91
+ injectedPartialId: number | null;
92
+ checkIds: number[];
93
+ }
94
+
95
+ export interface NormalizedFieldIdMap {
96
+ [_id: number]: NormalizedField;
92
97
  }
98
+
93
99
  export default Field;
@@ -0,0 +1,91 @@
1
+ // Export main classes
2
+ export { default as Database } from './database';
3
+ export { default as Schema } from './schema';
4
+ export { default as Table } from './table';
5
+ export { default as Field } from './field';
6
+ export { default as Index } from './indexes';
7
+ export { default as IndexColumn } from './indexColumn';
8
+ export { default as Enum } from './enum';
9
+ export { default as EnumValue } from './enumValue';
10
+ export { default as Ref } from './ref';
11
+ export { default as Endpoint } from './endpoint';
12
+ export { default as TableGroup } from './tableGroup';
13
+ export { default as StickyNote } from './stickyNote';
14
+ export { default as Check } from './check';
15
+ export { default as TablePartial } from './tablePartial';
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';
@@ -1,4 +1,4 @@
1
- import { NormalizedDatabase } from './database';
1
+ import { NormalizedModel } from './database';
2
2
  import DbState from './dbState';
3
3
  import Element from './element';
4
4
  import Index from './indexes';
@@ -24,14 +24,17 @@ declare class IndexColumn extends Element {
24
24
  type: any;
25
25
  value: any;
26
26
  };
27
- normalize(model: NormalizedDatabase): void;
27
+ normalize(model: NormalizedModel): void;
28
28
  }
29
29
  export interface NormalizedIndexColumn {
30
- [_id: number]: {
31
- id: number;
32
- type: any;
33
- value: any;
34
- indexId: number;
35
- };
30
+ id: number;
31
+ type: string;
32
+ value: string;
33
+ indexId: number;
34
+ }
35
+
36
+ export interface NormalizedIndexColumnIdMap {
37
+ [_id: number]: NormalizedIndexColumn;
36
38
  }
39
+
37
40
  export default IndexColumn;
@@ -1,4 +1,4 @@
1
- import { NormalizedDatabase } from './database';
1
+ import { NormalizedModel } from './database';
2
2
  import DbState from './dbState';
3
3
  import Element, { RawNote, Token } from './element';
4
4
  import IndexColumn from './indexColumn';
@@ -62,18 +62,22 @@ declare class Index extends Element {
62
62
  note: string;
63
63
  injectedPartialId?: number;
64
64
  };
65
- normalize(model: NormalizedDatabase): void;
65
+ normalize(model: NormalizedModel): void;
66
66
  }
67
67
  export interface NormalizedIndex {
68
- [_id: number]: {
69
- id: number;
70
- name: string;
71
- type: any;
72
- unique: boolean;
73
- pk: string;
74
- note: string;
75
- columnIds: number[];
76
- tableId: number;
77
- };
68
+ id: number;
69
+ name: string | null;
70
+ type: any;
71
+ unique: boolean;
72
+ pk: string;
73
+ note: string | null;
74
+ columnIds: number[];
75
+ tableId: number;
76
+ injectedPartialId?: number;
77
+ }
78
+
79
+ export interface NormalizedIndexIdMap {
80
+ [_id: number]: NormalizedIndex;
78
81
  }
82
+
79
83
  export default Index;
@@ -2,7 +2,7 @@ import Element, { Token } from './element';
2
2
  import Endpoint from './endpoint';
3
3
  import Schema from './schema';
4
4
  import DbState from './dbState';
5
- import Database, { NormalizedDatabase } from './database';
5
+ import Database, { NormalizedModel } from './database';
6
6
  import TablePartial from './tablePartial';
7
7
  interface RawRef {
8
8
  name: string;
@@ -60,18 +60,21 @@ declare class Ref extends Element {
60
60
  exportParentIds(): {
61
61
  schemaId: number;
62
62
  };
63
- normalize(model: NormalizedDatabase): void;
63
+ normalize(model: NormalizedModel): void;
64
64
  }
65
65
  export interface NormalizedRef {
66
- [_id: number]: {
67
- id: number;
68
- name?: string;
69
- color?: string;
70
- onUpdate?: string;
71
- onDelete?: string;
72
- endpointIds: number[];
73
- schemaId: number;
74
- injectedPartialId?: number;
75
- };
66
+ id: number;
67
+ name: string | null;
68
+ color?: string;
69
+ onUpdate?: string;
70
+ onDelete?: string;
71
+ schemaId: number;
72
+ endpointIds: number[];
73
+ injectedPartialId?: number;
74
+ }
75
+
76
+ export interface NormalizedRefIdMap {
77
+ [_id: number]: NormalizedRef;
76
78
  }
79
+
77
80
  export default Ref;
@@ -3,7 +3,7 @@ import Element, { RawNote, Token } from './element';
3
3
  import Enum from './enum';
4
4
  import TableGroup from './tableGroup';
5
5
  import Ref from './ref';
6
- import Database, { NormalizedDatabase } from './database';
6
+ import Database, { NormalizedModel } from './database';
7
7
  import DbState from './dbState';
8
8
  export interface RawSchema {
9
9
  name: string;
@@ -172,20 +172,23 @@ declare class Schema extends Element {
172
172
  note: string;
173
173
  alias: string;
174
174
  };
175
- normalize(model: NormalizedDatabase): void;
175
+ normalize(model: NormalizedModel): void;
176
176
  }
177
177
  export interface NormalizedSchema {
178
- [_id: number]: {
179
- id: number;
180
- name: string;
181
- note: string;
182
- alias: string;
183
- tableIds: number[];
184
- noteIds: number[];
185
- enumIds: number[];
186
- tableGroupIds: number[];
187
- refIds: number[];
188
- databaseId: number;
189
- };
178
+ id: number;
179
+ name: string;
180
+ note: string | null;
181
+ alias: string;
182
+ tableIds: number[];
183
+ noteIds: number[];
184
+ refIds: number[];
185
+ tableGroupIds: number[];
186
+ enumIds: number[];
187
+ databaseId: number;
188
+ }
189
+
190
+ export interface NormalizedSchemaIdMap {
191
+ [_id: number]: NormalizedSchema;
190
192
  }
193
+
191
194
  export default Schema;
@@ -1,7 +1,7 @@
1
1
  import Element, { Token } from './element';
2
2
  import Database from './database';
3
3
  import DbState from './dbState';
4
- import { NormalizedDatabase } from './database';
4
+ import { NormalizedModel } from './database';
5
5
  interface RawStickyNote {
6
6
  name: string;
7
7
  content: string;
@@ -24,14 +24,17 @@ declare class StickyNote extends Element {
24
24
  content: string;
25
25
  headerColor: string;
26
26
  };
27
- normalize(model: NormalizedDatabase): void;
27
+ normalize(model: NormalizedModel): void;
28
28
  }
29
- export interface NormalizedStickyNote {
30
- [id: number]: {
31
- id: number;
32
- name: string;
33
- content: string;
34
- headerColor: string;
35
- };
29
+ export interface NormalizedNote {
30
+ id: number;
31
+ name: string;
32
+ content: string;
33
+ headerColor: string | null;
34
+ }
35
+
36
+ export interface NormalizedNoteIdMap {
37
+ [id: number]: NormalizedNote;
36
38
  }
39
+
37
40
  export default StickyNote;
@@ -6,7 +6,7 @@ import Schema from './schema';
6
6
  import DbState from './dbState';
7
7
  import TableGroup from './tableGroup';
8
8
  import TablePartial from './tablePartial';
9
- import { NormalizedDatabase } from './database';
9
+ import { NormalizedModel } from './database';
10
10
 
11
11
  interface RawTable {
12
12
  name: string;
@@ -116,23 +116,25 @@ declare class Table extends Element {
116
116
  headerColor: string;
117
117
  partials: TablePartial[];
118
118
  };
119
- normalize(model: NormalizedDatabase): void;
119
+ normalize(model: NormalizedModel): void;
120
120
  }
121
121
 
122
122
  export interface NormalizedTable {
123
- [id: number]: {
124
- id: number;
125
- name: string;
126
- alias: string;
127
- note: string;
128
- headerColor: string;
129
- fieldIds: number[];
130
- indexIds: number[];
131
- checkIds: number[];
132
- schemaId: number;
133
- groupId: number;
134
- partials: TablePartial[];
135
- };
123
+ id: number;
124
+ name: string;
125
+ alias: string | null;
126
+ note: string | null;
127
+ headerColor: string;
128
+ fieldIds: number[];
129
+ indexIds: number[];
130
+ checkIds: number[];
131
+ schemaId: number;
132
+ groupId: number | null;
133
+ partials: TablePartial[];
134
+ }
135
+
136
+ export interface NormalizedTableIdMap {
137
+ [id: number]: NormalizedTable;
136
138
  }
137
139
 
138
140
  export default Table;
@@ -1,4 +1,4 @@
1
- import { NormalizedDatabase } from './database';
1
+ import { NormalizedModel } from './database';
2
2
  import DbState from './dbState';
3
3
  import Element, { RawNote, Token} from './element';
4
4
  import Schema from './schema';
@@ -53,16 +53,19 @@ declare class TableGroup extends Element {
53
53
  note: string;
54
54
  color: string;
55
55
  };
56
- normalize(model: NormalizedDatabase): void;
56
+ normalize(model: NormalizedModel): void;
57
57
  }
58
58
  export interface NormalizedTableGroup {
59
- [_id: number]: {
60
- id: number;
61
- name: string;
62
- tableIds: number[];
63
- schemaId: number;
64
- note: string;
65
- color: string;
66
- };
59
+ id: number;
60
+ name: string;
61
+ note: string | null;
62
+ color: string;
63
+ tableIds: number[];
64
+ schemaId: number;
67
65
  }
66
+
67
+ export interface NormalizedTableGroupIdMap {
68
+ [_id: number]: NormalizedTableGroup;
69
+ }
70
+
68
71
  export default TableGroup;
@@ -3,7 +3,7 @@ import Field from './field';
3
3
  import Index from './indexes';
4
4
  import Check from './check';
5
5
  import DbState from './dbState';
6
- import { NormalizedDatabase } from './database';
6
+ import { NormalizedModel } from './database';
7
7
 
8
8
  interface RawTablePartial {
9
9
  name: string;
@@ -83,18 +83,21 @@ declare class TablePartial extends Element {
83
83
  note: string;
84
84
  }[];
85
85
  };
86
- normalize(model: NormalizedDatabase): void;
86
+ normalize(model: NormalizedModel): void;
87
87
  }
88
88
 
89
89
  export interface NormalizedTablePartial {
90
- [id: number]: {
91
- id: number;
92
- name: string;
93
- note: string;
94
- headerColor: string;
95
- fieldIds: number[];
96
- indexIds: number[];
97
- };
90
+ id: number;
91
+ name: string;
92
+ note: string;
93
+ headerColor: string;
94
+ fieldIds: number[];
95
+ indexIds: number[];
96
+ checkIds: number[];
97
+ }
98
+
99
+ export interface NormalizedTablePartialIdMap {
100
+ [id: number]: NormalizedTablePartial;
98
101
  }
99
102
 
100
103
  export default TablePartial;