dbgate-datalib 5.0.9 → 5.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.
@@ -35,8 +35,8 @@ export declare class TableGridDisplay extends GridDisplay {
35
35
  isForeignKeyUnique: boolean;
36
36
  pairingId?: string;
37
37
  columnName: string;
38
- notNull: boolean;
39
- autoIncrement: boolean;
38
+ notNull?: boolean;
39
+ autoIncrement?: boolean;
40
40
  dataType: string;
41
41
  precision?: number;
42
42
  scale?: number;
@@ -49,6 +49,8 @@ export declare class TableGridDisplay extends GridDisplay {
49
49
  columnComment?: string;
50
50
  isUnsigned?: boolean;
51
51
  isZerofill?: boolean;
52
+ contentHash?: string;
53
+ engine?: string;
52
54
  }[];
53
55
  addJoinsFromExpandedColumns(select: Select, columns: DisplayColumn[], parentAlias: string, columnSources: any): void;
54
56
  addReferenceToSelect(select: Select, parentAlias: string, column: DisplayColumn): void;
@@ -71,8 +73,8 @@ export declare class TableGridDisplay extends GridDisplay {
71
73
  isForeignKeyUnique: boolean;
72
74
  pairingId?: string;
73
75
  columnName: string;
74
- notNull: boolean;
75
- autoIncrement: boolean;
76
+ notNull?: boolean;
77
+ autoIncrement?: boolean;
76
78
  dataType: string;
77
79
  precision?: number;
78
80
  scale?: number;
@@ -85,6 +87,8 @@ export declare class TableGridDisplay extends GridDisplay {
85
87
  columnComment?: string;
86
88
  isUnsigned?: boolean;
87
89
  isZerofill?: boolean;
90
+ contentHash?: string;
91
+ engine?: string;
88
92
  };
89
93
  addAddedColumnsToSelect(select: Select, columns: DisplayColumn[], parentAlias: string, displayedColumnInfo: DisplayedColumnInfo): void;
90
94
  get hasReferences(): boolean;
@@ -13,8 +13,8 @@ export declare class ViewGridDisplay extends GridDisplay {
13
13
  uniquePath: string[];
14
14
  pairingId?: string;
15
15
  columnName: string;
16
- notNull: boolean;
17
- autoIncrement: boolean;
16
+ notNull?: boolean;
17
+ autoIncrement?: boolean;
18
18
  dataType: string;
19
19
  precision?: number;
20
20
  scale?: number;
@@ -27,6 +27,8 @@ export declare class ViewGridDisplay extends GridDisplay {
27
27
  columnComment?: string;
28
28
  isUnsigned?: boolean;
29
29
  isZerofill?: boolean;
30
+ contentHash?: string;
31
+ engine?: string;
30
32
  }[];
31
33
  getDisplayColumn(view: ViewInfo, col: ColumnInfo): {
32
34
  pureName: string;
@@ -36,8 +38,8 @@ export declare class ViewGridDisplay extends GridDisplay {
36
38
  uniquePath: string[];
37
39
  pairingId?: string;
38
40
  columnName: string;
39
- notNull: boolean;
40
- autoIncrement: boolean;
41
+ notNull?: boolean;
42
+ autoIncrement?: boolean;
41
43
  dataType: string;
42
44
  precision?: number;
43
45
  scale?: number;
@@ -50,6 +52,8 @@ export declare class ViewGridDisplay extends GridDisplay {
50
52
  columnComment?: string;
51
53
  isUnsigned?: boolean;
52
54
  isZerofill?: boolean;
55
+ contentHash?: string;
56
+ engine?: string;
53
57
  };
54
58
  createSelect(options?: {}): import("dbgate-sqltree").Select;
55
59
  }
@@ -0,0 +1,2 @@
1
+ import { DatabaseInfo, TableInfo, ViewInfo } from 'dbgate-types';
2
+ export declare function getPerspectiveDefaultColumns(table: TableInfo | ViewInfo, db: DatabaseInfo, circularColumns: string[]): string[];
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPerspectiveDefaultColumns = void 0;
4
+ const dbgate_tools_1 = require("dbgate-tools");
5
+ function getPerspectiveDefaultColumns(table, db, circularColumns) {
6
+ const columns = table.columns.map(x => x.columnName);
7
+ const predicates = [
8
+ x => x.toLowerCase() == 'name',
9
+ x => x.toLowerCase() == 'title',
10
+ x => x.toLowerCase().includes('name'),
11
+ x => x.toLowerCase().includes('title'),
12
+ x => x.toLowerCase().includes('subject'),
13
+ // x => x.toLowerCase().includes('text'),
14
+ // x => x.toLowerCase().includes('desc'),
15
+ x => {
16
+ var _a, _b, _c;
17
+ return (_c = (_b = (_a = table.columns
18
+ .find(y => y.columnName == x)) === null || _a === void 0 ? void 0 : _a.dataType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === null || _c === void 0 ? void 0 : _c.includes('char');
19
+ },
20
+ x => { var _a, _b; return ((_b = (_a = (0, dbgate_tools_1.findForeignKeyForColumn)(table, x)) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.length) == 1 && !circularColumns.includes(x); },
21
+ x => { var _a, _b; return ((_b = (_a = (0, dbgate_tools_1.findForeignKeyForColumn)(table, x)) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.length) == 1; },
22
+ ];
23
+ for (const predicate of predicates) {
24
+ const col = columns.find(predicate);
25
+ if (col)
26
+ return [col];
27
+ }
28
+ return [columns[0]];
29
+ }
30
+ exports.getPerspectiveDefaultColumns = getPerspectiveDefaultColumns;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from './GridDisplay';
2
2
  export * from './GridConfig';
3
+ export * from './PerspectiveConfig';
4
+ export * from './PerspectiveTreeNode';
3
5
  export * from './TableGridDisplay';
4
6
  export * from './ViewGridDisplay';
5
7
  export * from './JslGridDisplay';
@@ -12,3 +14,7 @@ export * from './FormViewDisplay';
12
14
  export * from './TableFormViewDisplay';
13
15
  export * from './CollectionGridDisplay';
14
16
  export * from './deleteCascade';
17
+ export * from './PerspectiveDisplay';
18
+ export * from './PerspectiveDataProvider';
19
+ export * from './PerspectiveCache';
20
+ export * from './PerspectiveConfig';
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -12,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./GridDisplay"), exports);
14
18
  __exportStar(require("./GridConfig"), exports);
19
+ __exportStar(require("./PerspectiveConfig"), exports);
20
+ __exportStar(require("./PerspectiveTreeNode"), exports);
15
21
  __exportStar(require("./TableGridDisplay"), exports);
16
22
  __exportStar(require("./ViewGridDisplay"), exports);
17
23
  __exportStar(require("./JslGridDisplay"), exports);
@@ -24,3 +30,7 @@ __exportStar(require("./FormViewDisplay"), exports);
24
30
  __exportStar(require("./TableFormViewDisplay"), exports);
25
31
  __exportStar(require("./CollectionGridDisplay"), exports);
26
32
  __exportStar(require("./deleteCascade"), exports);
33
+ __exportStar(require("./PerspectiveDisplay"), exports);
34
+ __exportStar(require("./PerspectiveDataProvider"), exports);
35
+ __exportStar(require("./PerspectiveCache"), exports);
36
+ __exportStar(require("./PerspectiveConfig"), exports);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const PerspectiveDisplay_1 = require("../PerspectiveDisplay");
7
+ const PerspectiveTreeNode_1 = require("../PerspectiveTreeNode");
8
+ const chinookDbInfo_1 = require("./chinookDbInfo");
9
+ const PerspectiveConfig_1 = require("../PerspectiveConfig");
10
+ const artistDataFlat_1 = __importDefault(require("./artistDataFlat"));
11
+ const artistDataAlbum_1 = __importDefault(require("./artistDataAlbum"));
12
+ const artistDataAlbumTrack_1 = __importDefault(require("./artistDataAlbumTrack"));
13
+ test('test flat view', () => {
14
+ const artistTable = chinookDbInfo_1.chinookDbInfo.tables.find(x => x.pureName == 'Artist');
15
+ const root = new PerspectiveTreeNode_1.PerspectiveTableNode(artistTable, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, (0, PerspectiveConfig_1.createPerspectiveConfig)({ pureName: 'Artist' }), null, null, { conid: 'conid', database: 'db' }, null);
16
+ const display = new PerspectiveDisplay_1.PerspectiveDisplay(root, artistDataFlat_1.default);
17
+ // console.log(display.loadIndicatorsCounts);
18
+ // console.log(display.rows);
19
+ expect(display.rows.length).toEqual(4);
20
+ expect(display.rows[0]).toEqual(expect.objectContaining({
21
+ rowData: ['AC/DC'],
22
+ }));
23
+ expect(display.loadIndicatorsCounts).toEqual({
24
+ Artist: 4,
25
+ });
26
+ });
27
+ test('test one level nesting', () => {
28
+ const artistTable = chinookDbInfo_1.chinookDbInfo.tables.find(x => x.pureName == 'Artist');
29
+ const root = new PerspectiveTreeNode_1.PerspectiveTableNode(artistTable, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, Object.assign(Object.assign({}, (0, PerspectiveConfig_1.createPerspectiveConfig)({ pureName: 'Artist' })), { checkedColumns: ['Artist::Album'] }), null, null, { conid: 'conid', database: 'db' }, null);
30
+ const display = new PerspectiveDisplay_1.PerspectiveDisplay(root, artistDataAlbum_1.default);
31
+ console.log(display.loadIndicatorsCounts);
32
+ // console.log(display.rows);
33
+ expect(display.rows.length).toEqual(6);
34
+ expect(display.rows[0]).toEqual(expect.objectContaining({
35
+ rowData: ['AC/DC', 'For Those About To Rock We Salute You'],
36
+ rowSpans: [2, 1],
37
+ rowCellSkips: [false, false],
38
+ }));
39
+ expect(display.rows[1]).toEqual(expect.objectContaining({
40
+ rowData: [undefined, 'Let There Be Rock'],
41
+ rowSpans: [1, 1],
42
+ rowCellSkips: [true, false],
43
+ }));
44
+ expect(display.rows[2]).toEqual(expect.objectContaining({
45
+ rowData: ['Accept', 'Balls to the Wall'],
46
+ rowSpans: [2, 1],
47
+ rowCellSkips: [false, false],
48
+ }));
49
+ expect(display.rows[5]).toEqual(expect.objectContaining({
50
+ rowData: ['Alanis Morissette', 'Jagged Little Pill'],
51
+ rowSpans: [1, 1],
52
+ }));
53
+ expect(display.loadIndicatorsCounts).toEqual({
54
+ Artist: 6,
55
+ 'Artist.Album': 6,
56
+ });
57
+ });
58
+ test('test two level nesting', () => {
59
+ const artistTable = chinookDbInfo_1.chinookDbInfo.tables.find(x => x.pureName == 'Artist');
60
+ const root = new PerspectiveTreeNode_1.PerspectiveTableNode(artistTable, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, Object.assign(Object.assign({}, (0, PerspectiveConfig_1.createPerspectiveConfig)({ pureName: 'Artist' })), { checkedColumns: ['Artist::Album', 'Artist::Album::Track'] }), null, null, { conid: 'conid', database: 'db' }, null);
61
+ const display = new PerspectiveDisplay_1.PerspectiveDisplay(root, artistDataAlbumTrack_1.default);
62
+ console.log(display.rows);
63
+ expect(display.rows.length).toEqual(8);
64
+ expect(display.rows[0]).toEqual(expect.objectContaining({
65
+ rowData: ['AC/DC', 'For Those About To Rock We Salute You', 'For Those About To Rock (We Salute You)'],
66
+ rowSpans: [4, 2, 1],
67
+ rowCellSkips: [false, false, false],
68
+ }));
69
+ expect(display.rows[1]).toEqual(expect.objectContaining({
70
+ rowData: [undefined, undefined, 'Put The Finger On You'],
71
+ rowSpans: [1, 1, 1],
72
+ rowCellSkips: [true, true, false],
73
+ }));
74
+ expect(display.rows[2]).toEqual(expect.objectContaining({
75
+ rowData: [undefined, 'Let There Be Rock', 'Go Down'],
76
+ rowSpans: [1, 2, 1],
77
+ rowCellSkips: [true, false, false],
78
+ }));
79
+ });
@@ -0,0 +1,20 @@
1
+ declare const _default: ({
2
+ ArtistId: number;
3
+ Name: string;
4
+ Album: ({
5
+ Title: string;
6
+ ArtistId: number;
7
+ incompleteRowsIndicator?: undefined;
8
+ } | {
9
+ incompleteRowsIndicator: string[];
10
+ Title?: undefined;
11
+ ArtistId?: undefined;
12
+ })[];
13
+ incompleteRowsIndicator?: undefined;
14
+ } | {
15
+ incompleteRowsIndicator: string[];
16
+ ArtistId?: undefined;
17
+ Name?: undefined;
18
+ Album?: undefined;
19
+ })[];
20
+ export default _default;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = [
4
+ {
5
+ ArtistId: 1,
6
+ Name: 'AC/DC',
7
+ Album: [
8
+ {
9
+ Title: 'For Those About To Rock We Salute You',
10
+ ArtistId: 1,
11
+ },
12
+ {
13
+ Title: 'Let There Be Rock',
14
+ ArtistId: 1,
15
+ },
16
+ ],
17
+ },
18
+ {
19
+ ArtistId: 2,
20
+ Name: 'Accept',
21
+ Album: [
22
+ {
23
+ Title: 'Balls to the Wall',
24
+ ArtistId: 2,
25
+ },
26
+ {
27
+ Title: 'Restless and Wild',
28
+ ArtistId: 2,
29
+ },
30
+ ],
31
+ },
32
+ {
33
+ ArtistId: 3,
34
+ Name: 'Aerosmith',
35
+ Album: [
36
+ {
37
+ Title: 'Big Ones',
38
+ ArtistId: 3,
39
+ },
40
+ ],
41
+ },
42
+ {
43
+ ArtistId: 4,
44
+ Name: 'Alanis Morissette',
45
+ Album: [
46
+ {
47
+ Title: 'Jagged Little Pill',
48
+ ArtistId: 4,
49
+ },
50
+ {
51
+ incompleteRowsIndicator: ['Artist.Album'],
52
+ },
53
+ ],
54
+ },
55
+ {
56
+ incompleteRowsIndicator: ['Artist'],
57
+ },
58
+ ];
@@ -0,0 +1,20 @@
1
+ declare const _default: ({
2
+ ArtistId: number;
3
+ Name: string;
4
+ Album: {
5
+ Title: string;
6
+ AlbumId: number;
7
+ ArtistId: number;
8
+ Track: {
9
+ Name: string;
10
+ AlbumId: number;
11
+ }[];
12
+ }[];
13
+ incompleteRowsIndicator?: undefined;
14
+ } | {
15
+ incompleteRowsIndicator: string[];
16
+ ArtistId?: undefined;
17
+ Name?: undefined;
18
+ Album?: undefined;
19
+ })[];
20
+ export default _default;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = [
4
+ {
5
+ ArtistId: 1,
6
+ Name: 'AC/DC',
7
+ Album: [
8
+ {
9
+ Title: 'For Those About To Rock We Salute You',
10
+ AlbumId: 1,
11
+ ArtistId: 1,
12
+ Track: [
13
+ {
14
+ Name: 'For Those About To Rock (We Salute You)',
15
+ AlbumId: 1,
16
+ },
17
+ {
18
+ Name: 'Put The Finger On You',
19
+ AlbumId: 1,
20
+ },
21
+ ],
22
+ },
23
+ {
24
+ Title: 'Let There Be Rock',
25
+ AlbumId: 4,
26
+ ArtistId: 1,
27
+ Track: [
28
+ {
29
+ Name: 'Go Down',
30
+ AlbumId: 4,
31
+ },
32
+ {
33
+ Name: 'Dog Eat Dog',
34
+ AlbumId: 4,
35
+ },
36
+ ],
37
+ },
38
+ ],
39
+ },
40
+ {
41
+ ArtistId: 2,
42
+ Name: 'Accept',
43
+ Album: [
44
+ {
45
+ Title: 'Balls to the Wall',
46
+ AlbumId: 2,
47
+ ArtistId: 2,
48
+ Track: [
49
+ {
50
+ Name: 'Balls to the Wall',
51
+ AlbumId: 2,
52
+ },
53
+ ],
54
+ },
55
+ {
56
+ Title: 'Restless and Wild',
57
+ AlbumId: 3,
58
+ ArtistId: 2,
59
+ Track: [
60
+ {
61
+ Name: 'Fast As a Shark',
62
+ AlbumId: 3,
63
+ },
64
+ {
65
+ Name: 'Restless and Wild',
66
+ AlbumId: 3,
67
+ },
68
+ {
69
+ Name: 'Princess of the Dawn',
70
+ AlbumId: 3,
71
+ },
72
+ ],
73
+ },
74
+ ],
75
+ },
76
+ {
77
+ incompleteRowsIndicator: ['Artist'],
78
+ },
79
+ ];
@@ -0,0 +1,10 @@
1
+ declare const _default: ({
2
+ ArtistId: number;
3
+ Name: string;
4
+ incompleteRowsIndicator?: undefined;
5
+ } | {
6
+ incompleteRowsIndicator: string[];
7
+ ArtistId?: undefined;
8
+ Name?: undefined;
9
+ })[];
10
+ export default _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = [
4
+ {
5
+ ArtistId: 1,
6
+ Name: 'AC/DC',
7
+ },
8
+ {
9
+ ArtistId: 2,
10
+ Name: 'Accept',
11
+ },
12
+ {
13
+ ArtistId: 3,
14
+ Name: 'Aerosmith',
15
+ },
16
+ {
17
+ ArtistId: 4,
18
+ Name: 'Alanis Morissette',
19
+ },
20
+ {
21
+ incompleteRowsIndicator: ['Artist'],
22
+ },
23
+ ];
@@ -0,0 +1,2 @@
1
+ import { DatabaseInfo } from 'dbgate-types';
2
+ export declare const chinookDbInfo: DatabaseInfo;